From c14d6adb2af596044e577952919dcf860dfd0776 Mon Sep 17 00:00:00 2001 From: Tomas Knap Date: Mon, 21 Mar 2016 14:41:03 +0100 Subject: [PATCH 001/211] Add possibility to process CSV data - see and run TestTableInterpretation_CSV.java --- any23-sti/pom.xml | 2 +- .../extension/extractor/LRDFa11Parser.java | 286 +++++++------ common-util/target/common-util-1.0.jar | Bin 10015 -> 15972 bytes .../target/maven-archiver/pom.properties | 4 +- core/pom.xml | 22 +- .../MainInterpreter_and_Forward_learner.java | 66 +-- .../oak/sti/algorithm/tm/TripleGenerator.java | 28 +- .../tm/maincol/ColumnFeatureGenerator.java | 26 +- .../LTableContentRow_Sampler_nonEmpty.java | 13 +- .../TestTableInterpretation_CSV.java | 243 +++++++++++ .../TestTableInterpretation_IMDB.java | 53 ++- .../dcs/oak/sti/experiment/TimeWatch.java | 33 ++ .../oak/sti/io/LTableAnnotationWriter.java | 371 +++++++++++++++-- .../kb/KnowledgeBaseSearcher_Freebase.java | 89 ++-- .../uk/ac/shef/dcs/oak/sti/rep/LTable.java | 78 ++-- .../dcs/oak/sti/rep/LTableAnnotation.java | 169 ++++---- .../oak/sti/xtractor/csv/CharsetDetector.java | 98 +++++ .../sti/xtractor/csv/NoCSVDataException.java | 16 + .../dcs/oak/sti/xtractor/csv/ParseFailed.java | 17 + .../shef/dcs/oak/sti/xtractor/csv/Parser.java | 20 + .../dcs/oak/sti/xtractor/csv/ParserCsv.java | 390 ++++++++++++++++++ .../oak/sti/xtractor/csv/ParserCsvConfig.java | 72 ++++ .../sti/xtractor/csv/TableXtractorCSV.java | 82 ++++ .../oak/sti/xtractor/csv/TestDetector.java | 55 +++ core/target/maven-archiver/pom.properties | 6 +- simmetrics-core/pom.xml | 20 +- .../target/maven-archiver/pom.properties | 6 +- triplesearch/target/triplesearch-1.0.jar | Bin 11283 -> 0 bytes 28 files changed, 1893 insertions(+), 372 deletions(-) create mode 100644 core/src/main/java/uk/ac/shef/dcs/oak/sti/experiment/TestTableInterpretation_CSV.java create mode 100644 core/src/main/java/uk/ac/shef/dcs/oak/sti/experiment/TimeWatch.java create mode 100644 core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/CharsetDetector.java create mode 100644 core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/NoCSVDataException.java create mode 100644 core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/ParseFailed.java create mode 100644 core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/Parser.java create mode 100644 core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/ParserCsv.java create mode 100644 core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/ParserCsvConfig.java create mode 100644 core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/TableXtractorCSV.java create mode 100644 core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/TestDetector.java delete mode 100644 triplesearch/target/triplesearch-1.0.jar diff --git a/any23-sti/pom.xml b/any23-sti/pom.xml index dfcdfaf1..33af7520 100644 --- a/any23-sti/pom.xml +++ b/any23-sti/pom.xml @@ -65,4 +65,4 @@ - \ No newline at end of file + diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Parser.java b/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Parser.java index 5ae167b2..52abc54f 100644 --- a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Parser.java +++ b/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Parser.java @@ -33,25 +33,35 @@ public class LRDFa11Parser { private static final Logger logger = Logger.getLogger(LRDFa11Parser.class.getName()); public static final String CURIE_SEPARATOR = ":"; + public static final char URI_PREFIX_SEPARATOR = ':'; + public static final String URI_SCHEMA_SEPARATOR = "://"; + public static final String URI_PATH_SEPARATOR = "/"; public static final String HEAD_TAG = "HEAD"; + public static final String BODY_TAG = "BODY"; public static final String XMLNS_ATTRIBUTE = "xmlns"; + public static final String XML_LANG_ATTRIBUTE = "xml:lang"; public static final String REL_ATTRIBUTE = "rel"; + public static final String REV_ATTRIBUTE = "rev"; public static final String ABOUT_ATTRIBUTE = "about"; + public static final String RESOURCE_ATTRIBUTE = "resource"; + public static final String SRC_ATTRIBUTE = "src"; + public static final String HREF_ATTRIBUTE = "href"; public static final String TYPE_ATTRIBUTE = "type"; + public static final String ATTRIBUTE_CSS = "text/css"; public static final String[] SUBJECT_ATTRIBUTES = { @@ -62,11 +72,17 @@ public class LRDFa11Parser { }; public static final String PREFIX_ATTRIBUTE = "prefix"; + public static final String TYPEOF_ATTRIBUTE = "typeof"; + public static final String PROPERTY_ATTRIBUTE = "property"; + public static final String DATATYPE_ATTRIBUTE = "datatype"; + public static final String CONTENT_ATTRIBUTE = "content"; + public static final String VOCAB_ATTRIBUTE = "vocab"; + // TODO: introduce support for RDFa profiles. (http://www.w3.org/TR/rdfa-core/#s_profiles) public static final String PROFILE_ATTRIBUTE = "profile"; @@ -77,6 +93,7 @@ public class LRDFa11Parser { private IssueReport issueReport; private URL documentBase; + private String docmentBaseCtx; private final Stack uriMappingStack = new Stack(); @@ -90,13 +107,13 @@ public class LRDFa11Parser { protected static Object[] getDocumentBase(URL documentURL, Document document) throws MalformedURLException { Object[] rs = new Object[2]; String base; - base = DomUtils.find(document, "/HTML/HEAD/BASE/@href"); // Non XHTML documents. + base = DomUtils.find(document, "/HTML/HEAD/BASE/@href"); // Non XHTML documents. if (!"".equals(base)) { rs[0] = new URL(base); rs[1] = "/BASE/@href"; return rs; } - base = DomUtils.find(document, "//*/h:head/h:base[position()=1]/@href"); // XHTML documents. + base = DomUtils.find(document, "//*/h:head/h:base[position()=1]/@href"); // XHTML documents. if (!"".equals(base)) { rs[0] = new URL(base); rs[1] = "h:base[position()=1]/@href"; @@ -111,7 +128,7 @@ protected static Object[] getDocumentBase(URL documentURL, Document document) th /** * Given a prefix declaration returns a list of prefixID:prefixURL strings * normalizing blanks where present. - * + * * @param prefixesDeclaration * @return list of extracted prefixes. */ @@ -127,7 +144,8 @@ protected static String[] extractPrefixSections(String prefixesDeclaration) { } if (part.charAt(part.length() - 1) == URI_PREFIX_SEPARATOR) { i++; - while (i < parts.length && parts[i].length() == 0) i++; + while (i < parts.length && parts[i].length() == 0) + i++; out.add(part + (i < parts.length ? parts[i] : "")); i++; } else { @@ -146,10 +164,12 @@ protected static boolean isCURIE(String curie) { if (curie == null) { throw new NullPointerException("curie string cannot be null."); } - if (curie.trim().length() == 0) return false; + if (curie.trim().length() == 0) + return false; // '[' PREFIX ':' VALUE ']' - if (curie.charAt(0) != '[' || curie.charAt(curie.length() - 1) != ']') return false; + if (curie.charAt(0) != '[' || curie.charAt(curie.length() - 1) != ']') + return false; int separatorIndex = curie.indexOf(CURIE_SEPARATOR); return separatorIndex > 0 && curie.indexOf(CURIE_SEPARATOR, separatorIndex + 1) == -1; } @@ -159,7 +179,8 @@ protected static boolean isCURIEBNode(String curie) { } protected static boolean isRelativeNode(Node node) { - if (ATTRIBUTE_CSS.equals(DomUtils.readAttribute(node, TYPE_ATTRIBUTE))) return false; + if (ATTRIBUTE_CSS.equals(DomUtils.readAttribute(node, TYPE_ATTRIBUTE))) + return false; return DomUtils.hasAttribute(node, REL_ATTRIBUTE) || DomUtils.hasAttribute(node, REV_ATTRIBUTE); } @@ -190,7 +211,8 @@ protected static Object[] getAsPlainLiteral(Node node, String currentLanguage) { protected static Object[] getAsXMLLiteral(Node node) throws IOException, TransformerException { final String datatype = DomUtils.readAttribute(node, DATATYPE_ATTRIBUTE, null); - if (!XML_LITERAL_DATATYPE.equals(datatype)) return null; + if (!XML_LITERAL_DATATYPE.equals(datatype)) + return null; final String xmlSerializedNode = DomUtils.serializeToXML(node, false); Literal literal = RDFUtils.literal(xmlSerializedNode, RDF.XMLLITERAL); @@ -205,7 +227,8 @@ protected static Object[] getAsXMLLiteral(Node node) throws IOException, Transfo protected static boolean isXMLNSDeclared(Document document) { final String attributeValue = document.getDocumentElement().getAttribute(XMLNS_ATTRIBUTE); - if (attributeValue.length() == 0) return false; + if (attributeValue.length() == 0) + return false; return XMLNS_DEFAULT.equals(attributeValue); } @@ -214,7 +237,7 @@ public LRDFa11Parser() { /** * RDFa Syntax - Processing Model. - * + * * @param documentURL * @param extractionResult * @param document @@ -231,16 +254,15 @@ public void processDocument(URL documentURL, Document document, LExtractionResul String.format( "The default %s namespace is expected to be declared and equal to '%s' .", XMLNS_ATTRIBUTE, XMLNS_DEFAULT - ) - ); + )); } try { Object[] docbase = getDocumentBase(documentURL, document); documentBase = (URL) docbase[0]; docmentBaseCtx = (String) docbase[1]; - if(docmentBaseCtx.equals("null")) - docmentBaseCtx=LAny23Util.appendArbitraryDocument(); + if (docmentBaseCtx.equals("null")) + docmentBaseCtx = LAny23Util.appendArbitraryDocument(); } catch (MalformedURLException murle) { throw new RDFa11ParserException("Invalid document base URL.", murle); } @@ -250,9 +272,7 @@ public void processDocument(URL documentURL, Document document, LExtractionResul depthFirstNode(document, extractionResult); - assert listOfIncompleteTriples.isEmpty() - : - "The list of incomplete triples is expected to be empty at the end of processing."; + assert listOfIncompleteTriples.isEmpty() : "The list of incomplete triples is expected to be empty at the end of processing."; } finally { reset(); } @@ -271,12 +291,14 @@ public void reset() { /** * Updates the vocabulary context with possible @vocab declarations. - * - * @param currentNode the current node. + * + * @param currentNode + * the current node. */ protected void updateVocabulary(Node currentNode) { final String vocabularyStr = DomUtils.readAttribute(currentNode, VOCAB_ATTRIBUTE, null); - if (vocabularyStr == null) return; + if (vocabularyStr == null) + return; try { pushVocabulary(currentNode, RDFUtils.uri(vocabularyStr)); } catch (Exception e) { @@ -286,12 +308,14 @@ protected void updateVocabulary(Node currentNode) { /** * Updates the URI mapping with the XMLNS attributes declared in the current node. - * - * @param node input node. + * + * @param node + * input node. */ protected void updateURIMapping(Node node) { final NamedNodeMap attributes = node.getAttributes(); - if (null == attributes) return; + if (null == attributes) + return; Node attribute; final List prefixMapList = new ArrayList(); @@ -304,23 +328,24 @@ protected void updateURIMapping(Node node) { attribute.getNodeName().substring(namespacePrefix.length()), resolveURI(attribute.getNodeValue()) ) - ); + ); } } extractPrefixes(node, prefixMapList); - if (prefixMapList.size() == 0) return; + if (prefixMapList.size() == 0) + return; pushMappings( node, - prefixMapList - ); + prefixMapList); } /** * Returns a URI mapping for a given prefix. - * - * @param prefix input prefix. + * + * @param prefix + * input prefix. * @return URI mapping. */ protected URI getMapping(String prefix) { @@ -335,15 +360,18 @@ protected URI getMapping(String prefix) { /** * Resolves a whitelist separated list of CURIE or URI. - * - * @param n current node. - * @param curieOrURIList list of CURIE/URI. + * + * @param n + * current node. + * @param curieOrURIList + * list of CURIE/URI. * @return list of resolved URIs. * @throws java.net.URISyntaxException */ protected URI[] resolveCurieOrURIList(Node n, String curieOrURIList, boolean termAllowed) throws URISyntaxException { - if (curieOrURIList == null || curieOrURIList.trim().length() == 0) return new URI[0]; + if (curieOrURIList == null || curieOrURIList.trim().length() == 0) + return new URI[0]; final String[] curieOrURIListParts = curieOrURIList.split("\\s"); final List result = new ArrayList(); @@ -361,40 +389,41 @@ protected URI[] resolveCurieOrURIList(Node n, String curieOrURIList, boolean ter /** * Resolves a URI string as URI. - * - * @param uriStr (partial) URI string to be resolved. + * + * @param uriStr + * (partial) URI string to be resolved. * @return the resolved URI. */ protected URI resolveURI(String uriStr) { - return - isAbsoluteURI(uriStr) - ? - RDFUtils.uri(uriStr) - : - RDFUtils.uri(this.documentBase.toExternalForm(), uriStr); + return isAbsoluteURI(uriStr) + ? + RDFUtils.uri(uriStr) + : + RDFUtils.uri(this.documentBase.toExternalForm(), uriStr); } /** * Resolves a CURIE or URI string. - * + * * @param curieOrURI - * @param termAllowed if true the resolution can be a term. + * @param termAllowed + * if true the resolution can be a term. * @return the resolved resource. */ protected Resource resolveCURIEOrURI(String curieOrURI, boolean termAllowed) { if (isCURIE(curieOrURI)) { return resolveNamespacedURI(curieOrURI.substring(1, curieOrURI.length() - 1), ResolutionPolicy.NSRequired); } - if (isAbsoluteURI(curieOrURI)) return resolveURI(curieOrURI); + if (isAbsoluteURI(curieOrURI)) + return resolveURI(curieOrURI); return resolveNamespacedURI( curieOrURI, - termAllowed ? ResolutionPolicy.TermAllowed : ResolutionPolicy.NSNotRequired - ); + termAllowed ? ResolutionPolicy.TermAllowed : ResolutionPolicy.NSNotRequired); } /** * Pushes a context whiting the evaluation context stack, associated to tha given generation node. - * + * * @param current * @param ec */ @@ -412,8 +441,9 @@ private EvaluationContext getContext() { /** * Pops out the peek evaluation context if ancestor of current node. - * - * @param current current node. + * + * @param current + * current node. */ private void popContext(Node current) { final Node peekNode = evaluationContextStack.peek().node; @@ -424,9 +454,11 @@ private void popContext(Node current) { /** * Pushes a new vocabulary definition. - * - * @param currentNode node proving the vocabulary. - * @param vocab the vocabulary URI. + * + * @param currentNode + * node proving the vocabulary. + * @param vocab + * the vocabulary URI. */ private void pushVocabulary(Node currentNode, URI vocab) { vocabularyStack.push(new Vocabulary(currentNode, vocab)); @@ -436,17 +468,19 @@ private void pushVocabulary(Node currentNode, URI vocab) { * @return the current peek vocabulary. */ private URI getVocabulary() { - if (vocabularyStack.isEmpty()) return null; + if (vocabularyStack.isEmpty()) + return null; return vocabularyStack.peek().prefix; } /** * Pops out the vocabulary definition. - * + * * @param current */ private void popVocabulary(Node current) { - if (vocabularyStack.isEmpty()) return; + if (vocabularyStack.isEmpty()) + return; if (DomUtils.isAncestorOf(current, vocabularyStack.peek().originatingNode)) { vocabularyStack.pop(); } @@ -454,7 +488,7 @@ private void popVocabulary(Node current) { /** * Purge all incomplete triples originated from a node that is descendant of current. - * + * * @param current */ private void purgeIncompleteTriples(Node current) { @@ -470,28 +504,31 @@ private void purgeIncompleteTriples(Node current) { /** * Reports an error to the error reporter. - * - * @param n originating node. - * @param msg human readable message. + * + * @param n + * originating node. + * @param msg + * human readable message. */ private void reportError(Node n, String msg) { final String errorMsg = String.format( "Error while processing node [%s] : '%s'", DomUtils.getXPathForNode(n), msg - ); + ); final int[] errorLocation = DomUtils.getNodeLocation(n); this.issueReport.notifyIssue( IssueReport.IssueLevel.Warning, errorMsg, errorLocation == null ? -1 : errorLocation[0], errorLocation == null ? -1 : errorLocation[1] - ); + ); } /** * Performs a deep-first tree visit on the given root node. - * - * @param node root node. + * + * @param node + * root node. * @param extractionResult */ private void depthFirstNode(Node node, LExtractionResultImpl extractionResult) { @@ -508,7 +545,7 @@ private void depthFirstNode(Node node, LExtractionResultImpl extractionResult) { /** * Performs a deep-first children list visit. - * + * * @param nodeList * @param extractionResult */ @@ -524,7 +561,7 @@ private void depthFirstChildren(NodeList nodeList, LExtractionResultImpl extract /** * Writes a triple on the extraction result. - * + * * @param s * @param p * @param o @@ -541,9 +578,8 @@ private void writeTriple(Resource s, URI p, Value o, String sCtx, String pCtx, S /** * Processes the current node on the extraction algorithm. * All the steps of this algorithm are annotated with the - * specification and section which describes it. The annotation is at form - * RDFa<spec-version%gt;[<section>] - * + * specification and section which describes it. The annotation is at form RDFa<spec-version%gt;[<section>] + * * @param currentElement * @param extractionResult * @throws Exception @@ -553,11 +589,10 @@ private void processNode(Node currentElement, LExtractionResultImpl extractionRe // if(logger.isTraceEnabled()) logger.trace("processNode(" + DomUtils.getXPathForNode(currentElement) + ")"); final EvaluationContext currentEvaluationContext = getContext(); try { - if ( - currentElement.getNodeType() != Node.DOCUMENT_NODE - && - currentElement.getNodeType() != Node.ELEMENT_NODE - ) return; + if (currentElement.getNodeType() != Node.DOCUMENT_NODE + && + currentElement.getNodeType() != Node.ELEMENT_NODE) + return; // RDFa1.1[7.5.3] updateVocabulary(currentElement); @@ -576,8 +611,7 @@ private void processNode(Node currentElement, LExtractionResultImpl extractionRe // RDFa1.0[5.5.5] / RDFa1.1[7.5.7] establishNewSubjectCurrentObjectResource( currentElement, - currentEvaluationContext - ); + currentEvaluationContext); } /* @@ -586,8 +620,9 @@ private void processNode(Node currentElement, LExtractionResultImpl extractionRe } assert currentEvaluationContext.newSubject != null : "newSubject must be not null."; */ - if (currentEvaluationContext.newSubject == null) return; - logger.warning("newSubject: " + currentEvaluationContext.newSubject); + if (currentEvaluationContext.newSubject == null) + return; + //logger.warning("newSubject: " + currentEvaluationContext.newSubject); // RDFa1.0[5.5.6] / RDFa1.1[7.5.8] final URI[] types = getTypes(currentElement); @@ -613,8 +648,7 @@ private void processNode(Node currentElement, LExtractionResultImpl extractionRe rel, currentEvaluationContext.currentObjectResource, subjectCtx, predicateCtx, objectCtx, - extractionResult - ); + extractionResult); } for (URI rev : revs) { String objectCtx = currentEvaluationContext.currentObjectResourceCtx; @@ -625,8 +659,7 @@ private void processNode(Node currentElement, LExtractionResultImpl extractionRe rev, currentEvaluationContext.newSubject, subjectCtx, predicateCtx, objectCtx, - extractionResult - ); + extractionResult); } } else { // RDFa1.0[5.5.8] / RDFa1.1[7.5.10] for (URI rel : rels) { @@ -637,7 +670,7 @@ private void processNode(Node currentElement, LExtractionResultImpl extractionRe rel, IncompleteTripleDirection.Forward ) - ); + ); } for (URI rev : revs) { listOfIncompleteTriples.add( @@ -647,7 +680,7 @@ private void processNode(Node currentElement, LExtractionResultImpl extractionRe rev, IncompleteTripleDirection.Reverse ) - ); + ); } } @@ -672,7 +705,7 @@ private void processNode(Node currentElement, LExtractionResultImpl extractionRe currentElement, currentEvaluationContext.newSubject, extractionResult - ); + ); } } } catch (Exception e) { @@ -714,13 +747,14 @@ private void processNode(Node currentElement, LExtractionResultImpl extractionRe /** * Extract URI namespaces (prefixes) from the current node. - * + * * @param node * @param prefixMapList */ private void extractPrefixes(Node node, List prefixMapList) { final String prefixAttribute = DomUtils.readAttribute(node, PREFIX_ATTRIBUTE, null); - if (prefixAttribute == null) return; + if (prefixAttribute == null) + return; final String[] prefixParts = extractPrefixSections(prefixAttribute); for (String prefixPart : prefixParts) { int splitPoint = prefixPart.indexOf(URI_PREFIX_SEPARATOR); @@ -739,8 +773,7 @@ private void extractPrefixes(Node node, List prefixMapList) { String.format( "Resolution of prefix '%s' defines an invalid URI: '%s'", prefixAttribute, uriStr - ) - ); + )); continue; } prefixMapList.add(new PrefixMap(prefix, uri)); @@ -749,19 +782,20 @@ private void extractPrefixes(Node node, List prefixMapList) { /** * Updates the current language. - * + * * @param node * @param currentEvaluationContext */ private void updateLanguage(Node node, EvaluationContext currentEvaluationContext) { final String candidateLanguage = DomUtils.readAttribute(node, XML_LANG_ATTRIBUTE, null); - if (candidateLanguage != null) currentEvaluationContext.language = candidateLanguage; + if (candidateLanguage != null) + currentEvaluationContext.language = candidateLanguage; } /** * Establish the new subject for the current recursion. * See RDFa 1.0 Specification section 5.5.4, RDFa 1.1 Specification section 7.5.6. - * + * * @param node * @param currentEvaluationContext * @throws URISyntaxException @@ -807,7 +841,7 @@ private void establishNewSubject(Node node, EvaluationContext currentEvaluationC * Establishes the new subject and the current object resource. *

* See RDFa 1.0 Specification section 5.5.5, RDFa 1.1 Specification section 7.5.7. - * + * * @param node * @param currentEvaluationContext * @throws URISyntaxException @@ -878,14 +912,15 @@ private URI[] getRevs(Node node) throws URISyntaxException { private URI[] getPredicate(Node node) throws URISyntaxException { final String candidateURI = DomUtils.readAttribute(node, PROPERTY_ATTRIBUTE, null); - if (candidateURI == null) return null; + if (candidateURI == null) + return null; return resolveCurieOrURIList(node, candidateURI, true); } /** * Establishes the new object value. * See RDFa 1.0 Specification section 5.5.9, RDFa 1.1 Specification section 7.5.11. - * + * * @param node * @return * @throws URISyntaxException @@ -911,7 +946,8 @@ private Object[] gerCurrentObjectLiteral(Node node) Object[] rs; rs = getAsTypedLiteral(node); - if (rs != null) return rs; + if (rs != null) + return rs; rs = getAsXMLLiteral(node); if (rs != null) { @@ -920,21 +956,23 @@ private Object[] gerCurrentObjectLiteral(Node node) } rs = getAsPlainLiteral(node, currentEvaluationContext.language); - if (rs != null) return rs; + if (rs != null) + return rs; return null; } private static String getNodeContent(Node node) { final String candidateContent = DomUtils.readAttribute(node, CONTENT_ATTRIBUTE, null); - if (candidateContent != null) return candidateContent; + if (candidateContent != null) + return candidateContent; return node.getTextContent(); } /** * Extracts the current typed literal from the given node. * See RDFa 1.0 Specification section 5.5.9.1. - * + * * @param node * @return * @throws URISyntaxException @@ -966,7 +1004,8 @@ private void pushMappings(Node sourceNode, List prefixMapList) { } private void popMappings(Node node) { - if (uriMappingStack.isEmpty()) return; + if (uriMappingStack.isEmpty()) + return; final URIMapping peek = uriMappingStack.peek(); if (!DomUtils.isAncestorOf(peek.sourceNode, node)) { // logger.trace("popMappings()"); @@ -975,9 +1014,8 @@ private void popMappings(Node node) { } /** - * Resolve a namespaced URI, if safe is true - * then the mapping must define a prefix, otherwise it is considered relative. - * + * Resolve a namespaced URI, if safe is true then the mapping must define a prefix, otherwise it is considered relative. + * * @param mapping * @param resolutionPolicy * @return @@ -991,8 +1029,7 @@ private Resource resolveNamespacedURI(String mapping, ResolutionPolicy resolutio if (prefixSeparatorIndex == -1) { // there is no prefix separator. if (resolutionPolicy == ResolutionPolicy.NSRequired) { throw new IllegalArgumentException( - String.format("Invalid mapping string [%s], must declare a prefix.", mapping) - ); + String.format("Invalid mapping string [%s], must declare a prefix.", mapping)); } if (resolutionPolicy == ResolutionPolicy.TermAllowed) { final URI currentVocabulary = getVocabulary(); @@ -1016,13 +1053,11 @@ private Resource resolveNamespacedURI(String mapping, ResolutionPolicy resolutio } catch (URISyntaxException urise) { throw new IllegalArgumentException(String.format("Invalid CURIE '%s'", candidateCURIEStr)); } - return resolveURI( - candidateCURIE.isAbsolute() - ? - candidateCURIE.toString() - : - documentBase.toString() + candidateCURIE.toString() - ); + return resolveURI(candidateCURIE.isAbsolute() + ? + candidateCURIE.toString() + : + documentBase.toString() + candidateCURIE.toString()); } /** @@ -1039,22 +1074,34 @@ enum ResolutionPolicy { */ private class EvaluationContext { private Node node; + private URL base; + private Resource parentSubject; + private String parentSubjectCtx; + private Value parentObject; + private String parentObjectCtx; + private String language; + private boolean recourse; + private boolean skipElem; + private Resource newSubject; + private String newSubjectCtx; + private Resource currentObjectResource; + private String currentObjectResourceCtx; /** * Sections RDFa1.0[5.5], RDFa1.0[5.5.1], RDFa1.1[7.5.1] . - * + * * @param base */ EvaluationContext(URL base) { @@ -1074,6 +1121,7 @@ private class EvaluationContext { */ private class PrefixMap { final String prefix; + final URI uri; public PrefixMap(String prefix, URI uri) { @@ -1087,6 +1135,7 @@ public PrefixMap(String prefix, URI uri) { */ private class URIMapping { final Node sourceNode; + final Map map; public URIMapping(Node sourceNode, Map map) { @@ -1108,16 +1157,18 @@ private enum IncompleteTripleDirection { */ private class IncompleteTriple { final Node originatingNode; + final Resource subject; + final URI predicate; + final IncompleteTripleDirection direction; public IncompleteTriple( Node originatingNode, Resource subject, URI predicate, - IncompleteTripleDirection direction - ) { + IncompleteTripleDirection direction) { if (originatingNode == null || subject == null || predicate == null || direction == null) throw new IllegalArgumentException(); @@ -1128,9 +1179,11 @@ public IncompleteTriple( } public boolean produceTriple(Node resourceNode, Resource r, ExtractionResult extractionResult) { - if (!DomUtils.isAncestorOf(originatingNode, resourceNode, true)) return false; + if (!DomUtils.isAncestorOf(originatingNode, resourceNode, true)) + return false; - if (r == null) throw new IllegalArgumentException(); + if (r == null) + throw new IllegalArgumentException(); switch (direction) { case Forward: extractionResult.writeTriple(subject, predicate, r); @@ -1150,6 +1203,7 @@ public boolean produceTriple(Node resourceNode, Resource r, ExtractionResult ext */ private class Vocabulary { final Node originatingNode; + final URI prefix; public Vocabulary(Node originatingNode, URI prefix) { diff --git a/common-util/target/common-util-1.0.jar b/common-util/target/common-util-1.0.jar index 8ce204fc80bd35534edc66b385363d7ac9bb4e56..986b983b70c7f106a0dc1891a9a342169cda23de 100644 GIT binary patch literal 15972 zcmbVz1ymi&5-q{q-Q6WP1Pc({-QC>@9^Bo7ySuv`+%32}1a}L3^6q=r?_K}@UNh&+ zS*L1GPfyp>R8?{jV4#kolV!j~Xtq z`P<*#Z#(Mm#iaP9#e{_v6zQdeucSstBqiwRr{E;$sK-YqYUSV0GH>kK(~6G|(n`>%E?MfT7f(zoau z0*2U)s#O_p84b7R27VzN*rwU03G~0d{q+(+-umWb@oVS*DggeAfS$p>$iVz6<6vrJ z{4atCe-tz{aQGKtl)nnw=>1z)G5=n{$$g! z?1d>lJ^-JQyF#zxo|kAa_Ck!2n=Dage+!G7#yN8YpnZ%2@PccE4g~RimSTi8cj3iQ zIG4o_1T}(m@4b{`#2E$fAKT4#-!otUIPx|FG~+ilu(eUwk>D82?i+vyrgb?mbt<}) zwX3ClmJknNDF-2#T2(!yOVuG`#b2qwRC=% z!&^{XJ&aNkxu*N(d7)d>LWB$r_I#mB+Lk!7fQ)|#`{;UkblE@l$kzTLFQ~OdV|z-s z$wKTy{uVfxI`?$mz>ihvnk8&h%G8I(P&XS`XQ3N>df%N8u@_f?F&3h^TaWQ@1;aGc z_u_Ooe%1HL7IBs(eABIQ{`huw-ssX|^u5m5HjHqMDwjxc&CGg@ae{dl-gsyRK!e3QXd<3DwNaA zxo`yaBP~{`t#Q9ynJqX#k=VGm$yd#6E=o%UvA=ARoALdm?3?9XqNRbLxyFbM>j;$dC~WGF@wJ!ex_4MtIK-RVP!eFwDmlNjlqIk6iS? ztkbqJ^8-fSdrJh+)|Ty_Sp2}wD#!>@T%P(Rp!HHp4xULGw>r!0#D*S1)Th^K?3iCwstC1mFV=9j zgGVK~M)>1zleEIWBF3;{B7p0k#MrvGaZTb!SQdJ_A=?ejCii{jOKZYs*U~4;V zvEtfoQEGqQ;?j2!r0onlJ`{aD8z1vNWN!^9JQYFAQbdO)7n59XelOiONgcMrMH0-SR~sgpoE-;`>PH}w&L z29zTEV-w9d`X~{0q8m|w$U?-TV+>Kn<@HR@Hp)N~1G#n7C!rx48x69$5%?4t4j3<2 z`@-1kIvMH0%l5N5gE1dGJ2S{id4PQk^kfl{Vy$-kf?Z5baGL4IS-hdoLc=hk&0nR- zx)MHDi=3eESw)CDS|jEkL+31iih(kb-e?K9Au~sO@7D>pH;B$d5E|?mxvQykReEl5 zhZ}VHfkLfl;~=_M(}m*$9Jq_zkPW;?5feO3>jMgLQXNQ!!Jzud?&JaIJB_#`!7Hkw z#)n9NcIlG&aRSArtnBu|XH8qq+uZW$T@EO^FtJ#z(q<(C_Ex?pUmABl^VJfX<)v{u zi-v$x+~po3$)=P!c+g7i<`b_p_(cpxz(vlHZ2>ONw) z6qB(Y<~$+WhNw9}Go0hzVV(H}`kbMYzWOU6X2F}{D`TtfvY}5y)v0`;_`S3tL*(L3 zaqpE4=#iSC<}a>246mNW6XTjET?`=5WA_m6H?U_#&k;7%$L}vUkZ61KbF_jXWJkV6 zuzSKua45LWt5n6CoT&CQ8?7+kCuuy7(7o(VL(uB2pul@Z6e@aQKs`s1G)^^?`JWCc za0M|AcrC3R*Sd;Fb~n!zx{1%iGhRJLZie3cP#Yc$$aIfVcNxp$$r`n+fIj>|{MZ@3 zb~pLzAXd6bS#^HiLHts>y(FwfoxiFk05L1kTH9O;G(U4{WXz2f4?b=k&G?x_PBSLB zv(^64~wa48(ek?_yHg6&qt? z7Pm*~!GPzbR}AHcku&c=V~JV^uCN5gC1vmA)}l}IgdJqKeJ}xgEjLJB?>>j$Ha;f) zp~tc*#$v#LvWG~}l5|ei;oJD$MB@T#Zi{*PH4^R~w{dg5Nl?zNkO}H!IAJn@$x_j{ zyHb%bOVdwk7}=5LW`Pz^jNv+K905z5098vLBRp(wPB;@>o4^!-POVTa4!%sB@9kD@ z48$9PVj6F9cUf&sJQm4tj|R0Xi)s($iha{OB)NpEKBb=*#gvN7qFoJeKz@KuQI#U6 zjz`@wj1|}>XMY-ZnSj+RS0{l^g#}&zsz-a%jC(a4Rk75LHpPEikZr-&*^^XE?lVn7 zb5?^^3F`Z%XXg|>@?NY^42LcbpIM5UCxD8@%sfuEZm=$UP*#{E+$~c1#NgBE{@Od?Z9=UJ?pljrPG?#5 z*63;>&&dF5vjJ>SP88=d(xx6V=6liyP^p4+ydN#Li#Lvw;-!I z#9Osxx{3Amrc(U_)@ug&=+Tj2!q!M>Ka|I%Q>j`?>1JP}K=I~aN-nGzf{WHZlq-es zhm6WbGU%2}z~VNV3y(uuB(n1}vqy*)S5u_04J;JJrd9YSPjTSr+MqMaz@2M_-eXt@ zEm79YqsW}!DZ)qAa&mPaU6UUc1|OMi*#+L5TFo8SmdT$n;jEd2dwjGUuO?3)XuprX zxR3etjK0_as~(Jy61=}*7UF=O&)1_)ol}_{Kt`@n;q-}>zEr=ptRlzwl>JAx*cZ$U z+`4B*(?>w`vf0o{)sD05X^}~Tnw(pPW2+pM)P!Qnl&YDq!LBI_`j$8|awBPLn9SoC zTJ8o`!evm~o`~Z1fXC>Uo|hAp#2=Z{X_;!CDMcPox<_=n=wG{n@#QfsC5pd7`F*GJ z!}tmwh26Lc&DAH_-SAq7J7vmj+K-)1h4Y0!>NR%iipF@ma5PlM;fy^zb)5<4%YfxG z&w4cIQ6_Ro!#ZzDy0gSmb%6^PR!cj9=26nqkg7&`COa8I3)s zvuxvy?#TFH)dZyq^w9dfmq0c|xzm$JVHW}dj29=nRx1*%gu>le@}L-_&1l_i@hRk}amNSDf}_VijiQ%HqN8_rN?=nqIcsRPmaWT!r121%AiQAwFH-y^PLk-d%rkt8 zeZ}5FSc-p%lZ4GIjeZv)rK_5`DDI+pozdQnOM*lCKw*(+pe9Qq6NmDX2Pg1bi9?$E zv-GRm7+Y`j7#b%B2$ioM!ZiQ$z9lPTY zV7`*SX-&{Z>>L&NgZKV|j==ofO6~N9AMg$Ve)x)4?G)n{1RH<$JR0GK7^jPf0gab- zIf#{eOE4GHq8CZ6BX_e10Y=D{RoKu~ag>MLJ!&Xsz{piVyOU;QyM~*}+Dj&}kj3(H zBN;(v8w;U>p=QGE90UOxKith$6O+QwRXULoA!GjBH!u!*meqKAv|MQemeodXBeY;E z&{u8Mc=})n0Rj7~#dS9*r_*Y2a>hcAiKHt7lUB2pv2r)(>I2@1TNzL57^ZpDK+Or2 zr-(bR3HcHOJ4(MX@}ji4X!2s(`x+ITY7cUY)0{xlBKOt~iN^d^s!6lXRI2Zm``$lN zCgU`g-5s!)o9k;`FQFb84MVw@DKf}(CJe`oSU?omkcDG$#FK!7#CqtUF~v?4SI3*a z%5AXT2A^^IU8hk?Qx#=GPOe>Zh=!3LYBEoKt>^xJ!rDlFqsc3Hv0(VAVDNPUQmOi2 z2-8jT7L^uC>YJ?RS z&ZVVlrfzWsTWhBzn)2Y~j*;8maK~{;vRZ6y#j3~Ld)|l&rElY2dG<5<%h!@~gJKu& zTl(c4wT2vd2OI)N%Z^7TOD^ zomd@<;V{NdDH8Lg8E$fdFD$HCVo@}bjW9RQ!UJLl;i(~|8SCh6$d8kaDHOiy@#w9Y zicVas4l4Q4sH0hTeqHGUToj=~hph-}k6<49o6O3ZB%iW?*P6SPZw! zmq3+}otsY`Hqj5HW2|M-P6|Wta@3FTZB7V?U(r*ws@Nps^9oL4eIAS=*hb@%-elQd zHC+Fp3gO0FShhVaDZFkW6Z&|hwk=td#=xeK=BkvKd4GYeeYXwQR^dIrC)0O7;eX|D z!Ny^AMwzTq+@P;B`_dD&dT_NZ)y7KC!5Zb&7NPTaLBq(?sDANSjVGoipK~?u^$gy5 zv;FzLJ?+_#;0x+nrvIHu8vwMRW`ryO`(mQTXOkCii~}!=N438f><4FX+O0*8P2~{Es%C88bLj8I zyL)<&TT*H9F+J=DmN-X;fj;rGI`26_wUZ|uC32CQuQHyh5|d5X7A+m0l%0kSi1ycd z7HH}#wHw8kWJoKNa8JKn>C#2P$j}?r9=H}slojL3YxJRS?y<<{FEWfRE+1Fb3M!F{ zs1XFIRJ0a#CG4W=7w^g|Gf+bYfR~UKL)+;4osI3m3aHn98`SzLmLDM**}^hcS#2^i z$&&1-HaLPwv*gTpC&vYS+AIh%wMVBqdiD)+X8=N|0C7I-VQ!ov760^{GQLoZqbjk~ zoYBG-%8*bM_#Tsf_evRyFFqD<)-zjk%bpjXp^ad#d*blkD0(p2a$L=gPjb9VSe}# zZ%>z=uMi|T3fz%UR0Z1>Y`g~dnIrumtM05VY+dB zkQO@9mZ}&E)Ucy&a&RXjD$SUd(1}tyQMbb})&92o z%yG=V(ToOQ;~Npp!bv1YG+7)wFfFHAm?AEq1UWYRk6NXcqt!^*oLA^N1BVLS+>K65 zh!UIKOo1z-=RKMln6@ylPqG3jo9E^3 z1QNRnDfg+ttR%E#ie=)qiT4Bb?_1DbvhX@`rb7)q-5H-V7(p?;+Wq+|olxPBl7NsM zkwSyH4jQ^-!C;lTWc|#s!tcPs*%m2%F38`yqOxe$9|U5EPbCdT2x{cR6m`F7z8}^K6 zADFpa&awgfD>@%Du#Nm>uF$c@82VsKU04{fN1;_;HyD1t$i6rE6 zfe0{wMLtqEoHR^WS)JP)il)B2UTR=Uan5og_ywBX6Wu&HkH+Y`eHlq*;7zUKQNb`SfD(riX}mCD3}>7`8kEyVVXV4?WHpevpAh$^ z4j}2{++gth=gDkJ`w^nDST}MfeZAcfyR#(n&=**-9l2mk@%g3lvzbANMd6tJPSrI4 zU$4kH7}2ut@Ar}Ak{8dJ7!@tQj6fSIuk$mx~?1#>&H3=sfoNAHeD+(K*AiCMeh zNIW;nW+uvO4)RK?3_APrTBN#Yb#|+&h$k-%a&lbzHXA04L(e*|@>G6e(S6>bvZltm z-{e?ZA!kP{^Q_W>D{?oDjK|991T1ae1#+zg4M#+FUHS9N{S%mn%6DaJ!w@aXxQCr9 z>(U)y>O(-2Z!Jew1#Q;07mJ$VNlws|u0kVjH+NV{gkaF7$@sVaF_L5=|GxD$8KXy$ zfvg*d)m+s+9~J9lNMm~=Cq_I6TRxj=2*_DK{}aTZ2NDhf5f=%9T|yi^>P*7-GE5I5 zUrS8NKs5*AZv2nXEo|xN>p`2`CHPd$nmpwOQ=0&*)TpEkZ z-QH8eOyT6OI>yczO|E^bLo}f!M*^LV^1bl|=Z`O{`IKdX{lGv#Rd3}A(tmkTmC-kU z+kVO8Cn#FjOv_?=LBk5GEci#fB@n}`1GJ9XT8TbLJ=Yu}tBGD~KqNRBRDD#-(Rr3g z;Yc*yLO2(}%A85m&{F{6IdjjrTFcm%_4@Jhg3<-vVDza9DbTl7zZs*)6YHJj;0ib5 z8bFU5`L_CF2BZzMe>ox(5qAP%=7F)%*~TEHDzbj7$m7?Fgd1@&hblU#%`~-=1La&} z(etx2M66=@XFAD7Jb!TsH{A!5Q6=B>s zE9WJvKX-dOna+`op0Gu-wr71qh(J)UmYpwote&eHt-%b`X%M?E_`+?KAp07dy19eP zGJ-u~&Nt@usVX}1Ax#eW+Yq{Ho}p@GD+`W_f}bLeyh4L=jGN7UulHV#rEDFdbo|X- z%MDtBf6r9QzBkplC_tIjGRe?P?v%Ma z(^)ZIqB0GTq|Fo5sld_C2W*=Gv=8NgvFn&Kloq$ghO{Q-ZoWA-b+s75C0Bb=q{?NU zCI>&_s^4btxd?v1=G^nbR`MA|r0|$dzp;8J(bFbu>;u~bywIX>VKSH1yflZLl{x>N zud&;>@v=$vtr6Xf0>t#WyBX=LpKz$E+k3dqq<&xr42Eo^PG8})#;KfYfhe2Ar!bTs z$01(`&rf|VQy|%pLgCnv3K(W=^m|8aio=A#&4$ZR^9qOq0K4;N zHtX-oHuXUDPyw=X$Wiu?cf^hrp>;$#p}}(kO%sS5RgVpT=#>vUHqBF;tBG=@1SxR) zjDju$=1$Gb2dS{br{G4u4T}d(si=zO6}x53J2yk)Ly~$?{GLk|$g&SD9XXeU_AI1ArhzceTGBC+0D-juu_-zKtf&? zY7b|}J&DM#C_{wv`JlI))cUeo%pHFw-q+T4mkE4KcTqJzYDhA6d9AnH8oep zatA+$BNDVvh4LyxI$+%8f=0F4G4!kc1M0AeIF;x$vshOaTY_%SEN1Q;s*$}l&Rz_- z;Z9^gSqQSFaUS(|m9YmU-!useAA8byk{f^P9CF!b->)*f30aZ_J1%2%=lv$aOlqzu zRblb1kvRCr9gab^dE*WtNMFa~&wP8wo0K~0vMA`7FSX`gt;av#kqb#E7*TFBp}#5! zTerX(Y4#)E?9oRfJq3j?B*QLoxrMqCw4oKpdkOFeS6_o1HQXBwn?R-!xrEmtiZ({K z1D;U|E z=~FNI=SrMVQD32nC$iu$eg_u|skiOvy#a}_W1)KxQUkrWjEiWX;D@m@x^nNtY znE$-=8jQC166Be3q$4gs)SC%mmDy9~j&rqedrlVGcb08DLUfwmuN0f=hVVZPbSHmdqFeAJNp ze#-Burqdgp##W|q1v^yykSYzE-m>Xm23gZv$u7QPI3+DF5#8|sc9wn53oev;_~g5^ zvX-n_DeY5e_VzK!XC6RKRJRL^Pp-;)d?woiBn3^E9bhdo0n`sF?~jf`=!Y}(G%A4IWKf0T_Fk^F=^fIe zO?{F>Na~VE3{+ta#&YJ$zpxAu!Rt)TLdsQ%mNZzcPxYk`QLL}CEMk4d7r{V=&25zS z(L30?H40F%quq4EwW%s2#2A2Hn;x~c5HK!hf?Zqi1ug5lfIq`xdTpnJ)l#7tom3!E zTQ6Bh5j;X}(l@VYHFLLUutCEi^gA3uV%Kh3d1_#Y+zi1MT6cn>lFQIK%V^+BkNM19 zxh%4BLubwPq)B7pCU%a(&%SF9xb!zLBWI5sCTGA`St=`+l~i>*w`pyWxbch{2HC=E zQe107zZA_c)R+2f^O%y*3;N-JhUkml`({GJ*29Q6lbyE^M0fp=$REF^nh;aOMi&I= zaZ;uOO$-)MoII&WHTih~OrUiia-RWlaV&$Rg^|Z8Q1upe7@^LiROO_=23b^Cf{>8^ zrUfKWF&`S7@l!{@766lI4s?l8`~tC`3O`#k^q#`DaQL-&IJ52JcY4;WSZ_8e!VX5y zz*~u}NT4~9p;)HHk14%cD=F)~}F2 zK*5MWKve%`503U`)+WD8+eIi_s3^{3d5y1_a1eimbl%y5Ljy-D1t($mGeriS@>S`b z1dQr&xFusvaFRqP=aHxEEj^JqToFBg6LVL%<>okEk|mXH{NRm4@BpfO=xQDv%{p@fkkh~$0x;;;;1 zn+eF8{iXbE==@aL7=U?!CSvC`$gMHN3g`=UNSly{?>+s?`Ys~0>k%6~Z3I0K`WF%J zzpaOFXxux4u6KX#Te}mu?^t-^hvb9Z1Rz!fy~pc`>MbUKxQHXY3|F>|DG9Z0*pr!lU5~URcsRr~RwHamFmIVA+*;CbRJZbi?%?J&Rcgxw|BRl{oov zLAZ0br&U*VxZ@G1P^wM26H~gevt+K`Did;HKdgvMxLKlaxl=`0L8A07L;W0IiTp-q z-dD~;=@_YRL%5UjA|f(IWu&W1%Do308@fNB+1%ikH-#qhX}e7ml}a}bYx^XhBzeZ9 z@>7E%)O|EF9Z~(qM*XeHSW@Y!{H{Nu+)vZ$A+}t@_!Z|tw6PnX;Tk)Q=;@D}H9!m%=s<`Rk)da=v4^9OV zS{F5iM5*D9bSI&P!OAlF$tZIB8TacATFWwqWtQB3l^x&Q=YJOHW4NGM(!z4Sn4?4M z?5BXv+G5}OIQA;@uBAq;&xTPZTddE@qeK7@92$?w3pn$=Zx01q(er>Ja+U7W8ZBLj z>?b@ezQ?`uyY~y_)0gYZ?5*BN-Zs=oF+HBZ)RUKzlsqO3$dwn{>TRGCnwUg%w_kl} zxUJ>Fxl1ptTwd4bN}3rOQNFBUR<7J)xG(h`lbKW)da@tJ#pA4`NP|!efQ?dhn=>49 zOeyd+3ENpjab8EJn4!VePO@~dI0|hv<+8w*zPQ!UX=|3(b%t0lP#|8tr_#@)^Q_{O zEhmdZNC*j2OB9>B+{Bnz%@kEz=P6l+c_Q3GT3=Fgy?t6x z&)Hk_+EKtpYmtBTyU2<}xezS@)xuRsAhlTm4OyTkaVlLei#}J%?m{7~+HJ_Fi?aOu z{r#Ck%ontU!7uOOo+*UfbMz?_WQ_$kn&M~}YZW)6)_v?#eS^NVczY`*>SKJu8Ua~| z;7J4IknJ#>1*)6|Y|F{awgRm`3xdy;y+`cV=BC;AG~J}amd)72EwDb~eKt8IoZKpH zir1Hzqu!QRuQk0zvPu_=-f7F7 zNg!Zv1~s)LC%>VV)Ah|!VO!ode9gm%3hz~HnRguGH1`_z%GJpR06d%{Lr3VA4#mp{ zp<~0{V*GB`>cSMP@OHRF4V0$1@~G%`EeU5(Cg&5*8~z+Otf5~L#sF@-dAD}iEKKc^R4j`gBkp>#-l4IkA(7yb93#kk zqDZa<7iUefT@_%rDy&6vQ9l^ZC-rQCS;?QlJJJMu@fn^$PFg=%h?!Vz5nu}8;vlMj zOmylXPt2BKm2?()*{0h!kgAhV=HK@PI0=Ry?=U)#P|?RcM#xRzuY2 zhLHK*v^2DRWyD?QXt|a|eaHdGQ9`19v0$+jdC582!)DPBxE1zIzEEvLZaU<<=g4UD z(a}&_n<0i7p)`|ZXjFl^@vX%C@?i3W>cyhvu`+Uk81oFefEo*Hb}uU-cKU2TYj(Co z$>Z@<$bt6Qp$G&Vmu(+sFJ7CCo>(7*!?**zvKlFv1#T&soO*f6D3L}{{s@sq`KD9* zHmUgRN)crP!|L+sr0WTNr?##;zvsEZms@o63%2E9u4l*g5nqp}u}x2=JD=ze~P3DW6{Gz-WK>0BLe|Z z{>xjGs;r))>F-{m5>(V|QRmTkcxISanaw2x^g&5T-={{iAp04Tp!;+YLe>P4LBbeF z+LF}g1*+|Q#jgfss76Ds8Nd-HvaF`#O2q5Btpejz5+hR@m*1uC&=T9FDIQkwy4>Aq zJH@vOhbB%~Ydvdk&2V4$ET8CXVFk~E$^@J8t_zh!bkGYSq6y?@#6<%zGU8$YpwQM) zuiln~R&IfTF@Vd3*ZC&-QVOXbf05`Lq1KjTBvoEVf1*H3L%#Z~=+OvSc)^3Vu5tlV zeFGr$@+Sz}q=5FKCe?=9U~Q||iXbF*VGd??k?2!H15kSvY^C{T(r_?zcaBS@D5rwj zSZO7Jx;m5$M9U&G$Mr{AZbiqe3hK8`6`!yCKC zX`jkCm1M~$2r;H(#`iQ&vcBOHqn@GWAA#+avXCj6VFIVDFJp67C78{%<5|Qwshc*g zsjRntZFfiZ7yvI4zL(voivQHpfHK28hu<#Ka|E0Mvp}6UW67?}-1kSE<$f!7QfU_3TSq4qymO68-p)bFY` zGU|RUCVfC7(LpSsO3OChGW_7R=)xF0?S5ifoOj`3Ld~_|g3&S1ETzW0W{@|e&UkZ) zM=+?A7<}ZBw!S0ITyWIu5rQjNEH3S45morYPe@H>(q&hd8p*XmU%)f}F z4QbWyu(RTJv7}Lan8_81ATv$m_L!>R&Z_{VdsTF&VHABDd7g2Ui5vc-yJyKqy zLs(tkdj!1BSw2345``E87>AYOYkL<}zTizOA>)^A95k|r-9tf`!h@t-K<)$K_lc`C zg{*8z7BgJ!Y_u~;wYkJL`J$KA^r;v`(7ZsmMRPJl&h8UdR$gj;?nY5V`pRNT9EHW(slkpPid_|Z zM|(m60nZ!&KA#O=!ILH!gKMy*15ceUzk@WmHf1(N*C3_D0laX44cQD1>;jvrSx+%Y zvXyqGrGtjm8qOJ0vWFKjOTYo6^X(v71pDEPj~nHY#_XLcI9mOuO88nVS+IGfQC(i{ z2-g)!3GHFUoK<)s@7lf_1Kx%$iw1&a%*5>hksYKIjiUi#0~^7J@QC+k2H)GQz9}VD zS9P?wmg8=2z>Me-wBrQI)7^!`yB@CVl#)Mde46-J;twX*ZJ#{g>ym6YKXYq;$}>StD`AavK3?Sl$Ddmhw9}@YHiRWwLZ7 zMXSyaoTU;ip`(sb6e#(~q)UQj8x1STe|b$x`nig>3z8>Xs#kr?#T-)%#6VU0bsn)3 zZb8N)Q_tsoYQJ)bAqw;Y*L%FE)ef1*#phD+pi%C`D33LMBDW>r184~&hE4*uz-)8q zfr>17)S1NgJuhG6S%{s7OvE51ynVpL=l#n_QQ5rCuKFv>jLyNZw?!k(bL7}w^)5(CetD=k5?iEjM z`kwTsotokC`WMlKFDO^s3#sfVb}l`<-E!X!aU(ZY`Aaw4+~t+E)8KVKii7TZTr`su|tqp!pz#3d;_!xytx z6~*l$!Am-6#rLb|e8^T7E*LmE7p_3OZM{eSVi0z>1a?iHXz!6A=9!MS4aW;<;&O}b zKB-pVo{V>h%W&XYa0{&96%*h9<@fCGZ%PxxW+k*H&%@JvfHKSIWA z7yBhL>O#iD_shlgdXvxVMgi$|V%|oi;<(L(x(7MyCi^sYS`6Dpa1XCl!4I&v}u((WaDnMfF0$@GUdhkM9ckH6X)_@$g0`BHlBER9m}M z>Bp}r-oFx(esYL@C0$wRIU8C3O78iqF!5i7oh<0}4CsFnmFVC2NA&+rDWdQS^26*Hei7nFdn6E?D+{)5wg^EzkHO4#Q(^H_dIWo#{9Tw_9{6fAlt zCEvTofouF@(eUMQ512h<84C^HrRIi@qEq~)q8h{I@1#_+llDPc{JzSB#O=Z)>etxU zM{Gk5EbBH6)!=&K-&XSSPbr#zFEZA*XsoHyYhe#>IUoJuVnoC1cl-Ulsvc=SM-KcS_vot=HgSM_PRqo8%5O{6` zuV2!SxaSqlGN&omlk)SrD$>ZDUFh@DB)FitYdjQ$B#RhZ+VBb{USum~m9*zy$!xzY zQRJAqud;p{S=+ar`~Pc%ZS8GrjqDxGj2z&G+M#>iBLZ#w$k@tqh$0t+36Lhv*-*CS zjVldYO4}*iSYE!^wxCBQvqOrSAXsxvf*jkPj38NhC&jm$`-h^6zQ_X|jBApZE0{DH?eTE6bfc7khQxgrfvm(kU{sKQW){9(%v(bQI^qBM z{p*zfP3`ZQhChXWwmhGoD>i>s`yKD_H-x_$%uhbxFYV`v0dI%@VF&(mPk-_Qe`!Az zcHR!(6#l~&{AZn?e8FGZPaViN`}jrYzwE((R{UxEzbP{QQSlcx;XfKz zUmgYj4Dgd*_!~gf-vj*jA@DzxzvmnN4=2y3?_W^|BuKxW7 z982)e!2eJS{4@BUODVsB=e&8Af9kcup9?F0hW&GH;WyZWx1#+&!TveZ@Ehu1&G`3* z^7`uZ=6Zg85d6<&{%?l?^S*~MKt^W&nbTMF|rar*Jk`Ag`)!9zE!MM IIez~7Kjq>$wEzGB literal 10015 zcmb7K1ymf_(jEvd!6gh52<~BUO>lP@bO`S5lCVH<3+{vKAipMV`jq7!AfN%hk2q5f(f^$M_XG9*TR}qoIg5;-DaXP%G%#GP%03QS z-f&`;9qM70V-ZC`UeD8vCuC};_GnBGSH+W4RddN;EW;;7$BhH268PZttDfFpkp(%+ zwy$agYGB)im4juudu%{L0Ul4(AgmBpz;9jw0Pa6I|KQ#$SL@&1{;L7fuLg$3|6+sw zyN$DjsoB36V*T0B#Mt>?jPd?zY;X8)t`h$}z}3al=J(s6{3inC6&^~e_wyEm0|3zd z3rf<`##G}T?#yazW9aOhp=Ir&4koxgXgM%(dO*qkX5|sQUvD^E=VL#AY)cs#cm~ z=um@GUw%tr5PSH9Lr_12ZH=kQUA-IZ>cjGj5g$9wF#huHRnTW2weEU&l+~w?pb0B{ zWZm#6p{s>QEf{Pe!)sOUdQs_bR_3aFRD$q0((%ECF6oJfAb!ZnngCq-M?R6E@GpoW zkc+h(ily^40-UqHqY{jY?JH>1q4iN&7~R^173P7%h9)L7NPS?Gy^;Z1qvO@&u9Jd1 zn1L!Qo2se;s+<_;G!>#go7O)r4f0eFYJOtI8M|M_PgQBb9n0Y^<+bNQV>fGh!1V+bH1o)^7IbW~)kl^PC7*%EMSh&8&@AV(lwX$pIA+$| zG{-E_(L#XOx66qBqdV|8)PN~BdweFmkZRY9pT9JM!28*LNG`%5%y4H~j$9hcz~z?A z47@-#VwK8ZRXh0kzzkFtwSDE6Ghm77cm6e3b2h3lR+~)3 z!=x<%?|OQy8n2rE0TUM54gxxEkmOrS`2uenX!XDWrH8aJCh$%~X|2;Xxl#+3zzr(M z$hk!Hi~w)SHN6XXEt|UVdN5OgZq-eUNv4^7>G;BDt2Tn#^Qt7u<26F<$}vjp(sZoj z`5X{P(uMlCPw9b(<13P09Y`?#!dP5Y8S(DWY-U|fI(Htf(1Hx^?1W;Ozs*CYiqVZn z0=09hBr_Q#qV9aUQ+P_eGrK1BBkT+*eJ*LCSI_0bsw51Pu^NI}+JVRG5b`K46l*Ou z#fN7R35v-oLwXFdtt#eI6N`@-&kBv%dY4jndc_lTG4UjIK2SLtFOLK<*n3yE#kfb1z zTg1v>z+l92;u+B-u?PBtjwbgtyJg!Jd6 zfqs_~Ze)j*g$vss+A)2eeLCTgS287%adWvDZ4aJS>}~VlNSsaLI%4t>=Mcg#uFz3y zvpT07t(c>x)Q|D1dTO*hbrnhfO_S^Rx*bP6GG~d4wA!PSeN=GC=6hX-VW6FT(R^5=519_q z^;R$~X26WQXnq);4Jd&YwOy_9;?a6gN!$Xt0L-|??e%UYRqG=xzR z)tx`Qh4!ypyOKkdokKT;81oQaFxwWdpOWP#hdK?2(wLpnI)4h`uz4?7W7vk~nSw{C zX&l+)EFc_S+Y&@krWK3?sfu6QdJ82==|EqQ6T&(GHkIbq`sqZ*%Li={%DT>17_ZSK z=jRsZVGlAgW3o)=vCow{T(<;-YbsvyZ!`xvSUzeOUsYvpkT2Pml4+HCgXS5c(#o^0 zL4S=vlbN-Se(gm6O+vXOArdEEc+<(_wk;j1oEA`w1{Y-r$%%cYaVk_x7+x9TDB-d4 zaXN@51UHK{_F2~KvN%8dL^)-V$pyfaRcE&Nne*79nds?bAq{MPzhSxEOZqFH+~v9A zWoM?Vf)CC>0<<<3wD&XDIPkB!llE);?piLsZq@*n8Hsoct4PCS~#vF z`4Oo6Y4xFQG;f{W7CjSnFCj`}iG91l-eF+HY-guBQ!b zdCuWRf{c;StJlXx-=1s;y^-y{aOCZ^CgDYqU0lt zt|6o+O<&n7hyruTFzdppSmaSW!^zMC!n;XfZBaQ^^=A>+B;1buDXjrvFsUpSfms4KIdCXTDG`Q6+T6fH_$Nx zs?cMh~6ql^x- zRxJf^40iY6F^{Z#aJk@iP+~L`2t!suzzSEDs_z05zY`>7m-gn%p2M-KSIM#BEq>`w zrFq1HZ;@U;S>PQGZ_1N>hYpG2!ATYls%KaPC)Aj!(Uxs`$XuZ@&J5{T$@L6dO=;uD zk8@rcS=q|$A9>+SwZ%$<2nhSt)@J7*5}&i8PthBqheNaMwJ8$QpEsrwCS^z!gS>C3 z3W{f_)0+VS5hsJwqv2F3^w)_`gkxd800LV|dy&MdtxX+iAzBBY#B7o7N#6*p^sSU2 zqU3nIqW3b)9~lacG2)JK+1$y$%7k?2QJ8+wEE>{i-(04Z$#Z8VPALdli5iae+jgn9V>s1N|AfD^q zR%YF}fkPZJC#iDA=JGqZ-xj97F3U6!Ioog$0019k0D%5qmSw7@=B6HhSeHd=*n;uE z*soY;-cqu{#}Mr|htQzDuCXd6@JH+<0m5@pX}qqo;qDc!lHmbjot=dXc|{d|`!sxk zbyZup)!CLlM)B!RecPEwWpQ-`OThVXK1BdDJTU+5^4j1Iz>6#p5|_N!4#0gbzfu)8 z9H7kpsFTx-IwfIU7TdXjq@5_%AdZ@$*Hxws<1x*(55TgQD9RAWptu3&nIyzh?PF}1 zEe*g;d+~U|E2ZcuJs7e3KuaT;!MOgE%O0xVg-n0lJOi8ouPDg0E}aXp zNj1^7z&amutg+Z0p8++$F9_0-FOWFT6BwrZwgg_Rcve%7XLZ6qCEPsHs-@JPt7YNM zVq!zd=)`flsri^!?|`~XN4(pL9yQ@yvB-Pn(vS=0tvm&ZvIw3o}z}sWZeI z4Y0c&T#N~BfdW^ihM9x;B?H}lX=AIhGm#T$BQ>LJ$QEe!v9=Ev?wu*v>OhW1k*Q@9 zD5WYu$A_lT)#Rv{{M_q9pWXx(QwDSOA#<&(EE{PB1j1L3zYS&a z1KBIH`^7kTG^^LZlDcw|@R;0@!M!x$K1*-tG=qdjj;yG2vO{9qmv_I$5iFdxy{)t) zu?h79pTT)wKb}V}1$xxKwNuP!zy3y$&hlBY>!!|ZHpnw8Dp*%3=5!5nhb+2kNuZ=Q z(rQfKmp3J%h6H=!q>q=tbzQov2GqcI3wDz4U8XlIH?8^YD z>f+V0>KU;x%uXSR3Hl^P2)GL}_8EDJBYm^kEB25XS<8(TEL=X*lXvJuL`SrK`xz8c zs8_QhH0q`_9eOEK8w4-BZ2Alt$uUTWlkn0*TfkK0HmJ^mtZjTr*-j+D_f=lhMYlul zI^(-%8A|rdglLnF^4b+*uw2kS5Nza1N^#jOs_*J@2hT#dv$Fb>{|mlpMxiRX7bTWV zqd~9gJEiT@Q%TQWi#?@ui;k1Hh0HM}H(!!(36&3*g~_v$?yysOF`8t&v7d#&AkYir zkTZBg8SGd@|0?lkC$IB5OWiD7GaH3p9ANcQJT(aYz*SVEyWyUw?Hjh6eqi`TdKpd1 zC;3V+PZL1}ii;DWjCJ?=KhhPmyq-u=9 zI3JeQmP{Lj?MRTZ8N2e`wF|>rzEvj$3hrx!o}-?B^SfOdxfq9ifjo_lgPdT{-6H=v zt&r5BRQlcj(S3NIR%reut*CiAD?8ac{Q6(-KBuVRnd1wkA#mFy(Voz%m&Jt9;>?Ts zm1Jv4RE{4Rjq$H_2M^*BCfb-)Z`XVi%Gd_0pp#{6V||Xc@;;!Y^zW~U>pk^4Xx&*}O9{sQYVc3(g?0kF!!DP96&Kw+eJk2FH~+(lx~&j{CCx==f`+O?(t;2AN$ceax?dBk$~McZjWzZQHelblC;EmJLYeSW zDU^u^eS5Nw(it+0V1_MnT(n;|EkBD3lQYCRL+*7e&jZBoUpjythEwlN~bqwR7S z=~P(PKIe6#m1HkjF`5BuOg^4cSo!|bzKBVK@cFQkIkuHtiNkd_&p(yyD?XP!c6`6)lImMvwILA8J*+orR6p@I>$ zDr8tyxQw`0AiZeHSYA15A~_Q@p4AZQA>2mAv|{HFXBuQywHj@jd;Oz?@ z*$2V+%9+cByWvIj?LeJ`$`L1edv9Al+7pKQT4ZhS8`6?JJ?J}1Y>P{m!!eFoy&Hx2 zW?rD!8DG4#+BF8!Z1y!(9NHDZ$%K|i&&6>}Yf!`qBLeCpYj0oOgW92B1LO~R2q!a;M1Q@#-& z2xtAyl_<9PYPgX@nuQ(FU=rs%Wx*l-pg#Y>WTjL`Qb2M@2FU?x4!%I(JlJI(wkAw= z89oC3c(b1~16#93^Z;P(ct}fSCV%n5UTWu&IAy{7CVI01Xp21jJWUrNh})TaRUUP? zebp8PNA{JA^wUu?{N0TQhaC_7k*0dNN)~s)EDNGUrN^kw$XM%0Urj0yFP$MOe|Dgg z1cXOq?5(6gNEVJ&tNQJk9!qnp5QX?!Axm zW_;dx^?uB!D?1fExl~HBjN6$N3hOa#U7=!{ZZEazs%bo{EvQv{6`8Dg(%gV?+S)Nv zI|y|*qQ@nCjfyM^sN$Oq22ot#M*q;`Ju6r>ogx2#dV9 zrk4BKBkGaYv)02*`niBIjMy=zrlm-In( zMt6JK-eadR$vp?z4^`>~b2UkJ*43kKf(dyoW*ZOv$ccuOL5(=>H?gFKq-)Xj#(A-m zCyDAxv&XDH>CWNatD$a8Vk4s?h!)=b;MZnRDgq){D43_5ffnsRKq;bi&C(DgL?Q7rQ{)kD*(%52>vXpqq{TOx=sTBwqSOw2G%9Fo61yd9~g zSd}7ya2=7nvRS6{ka=HBAx25*E#9$<^eQZqp(qNvG)t;0vNig7H9>AN^f0!7Yj@a5 z_@IcD$MSI`3&|q;k#kFNmh3?SP->5)l_oVj|0EBSf%i1eGV=9$jy}5?C31| zoxD_bt7;-O^n9e0V9Kw-Ui)(=8Lf4vYzfwev7mJe;jm2nW{d?c72IS`DJgn(K|u?T zg>av>LP{v<~-L%ZS6~frGwHlj@4ZVxMs%9Qx;C0g1yc-TcyKQs6740 z%ieRgVQf9SVfuv%4QH;JFYE+%vHfh29vB^j4aLNN5F# z;o0^_z4NS?>gOK9ohB03znsD`zgL}luUYPWg(-nV{NxTPYfMIAKVWB{!l^gZt%*~A z$EKZQ>O~LNG`-qq2JN2QK&4fmsSktrL=4G0`pSfl=EG%Ts%8neI0+hnZB@5q4ecD(M71Ifva7cB(?tn zCYPax+oa|M#*29X+U_@;r!>tvwb*g`3wQWolb#*7iLO>!*4kU>yDZ4;udw<~Smm<_ zYJCy*6LXXIRVC{pW~^5&wW5y2`NT>4Lre&&wfhBG%@z|u#zY_>s@`izX@@K6eix08 zy-%uASR`(MTyi!hhW!^Rj~pNR*3lbN5Vh;EtA_{NhiTudi}@FMVr z5^Cn#swj%^!K)N2Fy^h|{6)y1fcnW5xhwBfc#3vbfQnmew|*(PDopCisR+TK!YS-<>(Gy`13TvfJD8={0$SU`Vzi4r@(Z0d2h<$R$@RJo z&OGk=GNHOOtYi@`gxAmxQ-*v*)~7_2_uYd|cj05at1av%HwV6VHPcbpUhtyjQN!g7jvFewErEqOw?P%WQzA$wkt8jXY+ir(c zWNT+LswnwsI_iR2-tdOxjBTst$7AI9&4lv_&XNzMuE|ERUbvyl5I&4>)5qS+t5;s^X_-3aUZhb_m+25-kK13%>xyd$fv(1_TM9pe8qT~-%;S?z*+M<1geV7V zGa685LyT~EMQ2+Fl7^Y)?-(ym>OTdHH)p;JgmeJ+T4jLmauVu~bZ_8&yV#C-Zb%MS z$l&kFb5?o6f|eL)u3A<7MChH5q&D;f%hH42(f1#LH&k!*N3WfP;hQ`?&7?&{xDaK$ z(rSuT!`4CVQsGm%QiNZoq^BU-pAG2B>e0MZ>#KR%!6WjXa4>(P1E3;!vZ~aci0EyV ztT3%$a$dR;415I8+itriEr#ihRs=gnRN!P%pG?G#OuZSDdYS@KW1=G<&pl}`n#czF zv8iKD5x$N-e$S@~$M(eu>gm{3Uf9fYl*h-G47s%Bzf@7j2a^L1&qF?IV!2xfHJf9& z=PJ5ivFx=p-oF2OE(HDNi@WYyIeC-DmV6iCu{>m&k7KUCQcNUZ|K;~q>t8$N-`l^x zcgk%I-AwKN#hCoB#;(?^hQ_Sld(5nV?ganbl4tyXvBvhcw)S=`KlO&oRXIehZ?J`B z-~fPHcmUw(|HR{9Z_DaoYZIu_Z`bh{TX4?c`Ag(IPE{C6oEnpc?6~a9A~0GfW#xMg zUd6jM1Uf>#nvJf#y@4TCZSph{QWNup5mU`9!3V0&PvXn__P*`oESk%u#@2xZddZG# zZ2N6?^_tro43Ud*tRF4Onlz!k6RbEU-GI;_CK2fnO2G>142eHE07=X|Au@LV|rctnk+U&ly}1x>`x+bs&0vSo{J?cGcl8SYM6hy zkooi~npnz>iKpkS(0d{ulggoD%(bBh^PG_*Z{161c|S<4dS2G>UX#(n)@x2Qz3OT> z6=M4lKY=T({7Sb4SSf~*a#oZP?s|`@AOzi23^-K@I#=P*zK6~aD2o&{t_cB@k@QOt zBiTcSQ+<5?P`u1=$4P25ezA}G@d?Y*RLqD5!>%7j8OXo=VRN|beqIVrS~RWi=fmdy z;QgQH#o>Nq$JEKi($rbaO=(b$MV47cK}EVm{YZgXZg5TYA@a%1Nk4uBGd>1pnS4Z< z{2;;nOELTi42;NzKGpCr(CMiS<~c^gX!wa7x}chkT=h9_+<6#Cb?oc}ueuR8T$W=D zH%{&sj^69W#%s@}e3}$Ky?faO96bJme^!m$KgIpP2JAoo{{8!#@dNhvDw6NU-$$O` zckROOus>)@elYx1(D7aI@$2}01$M&cz=2i_>UgspE2JR zA-|6A82J0w=~v8u^&$TZ{GK9y0Ga*_{8caV&*1Nhksn~Kzk+|w8vji2T|x4LAoTAE z{+ly?WBGeU$!|P)e((N;))4-Usjate 2.0Alpha-SNAPSHOT + + org.openrdf.sesame + sesame-util + 2.8.1 + jar + + + net.sf.supercsv + super-csv + 2.4.0 + jar + + + com.googlecode.juniversalchardet + juniversalchardet + 1.0.3 + jar + @@ -207,8 +225,8 @@ org.apache.maven.plugins maven-compiler-plugin - 1.6 - 1.6 + 1.7 + 1.7 UTF-8 diff --git a/core/src/main/java/uk/ac/shef/dcs/oak/sti/algorithm/tm/MainInterpreter_and_Forward_learner.java b/core/src/main/java/uk/ac/shef/dcs/oak/sti/algorithm/tm/MainInterpreter_and_Forward_learner.java index a744f0aa..4bc80ffc 100644 --- a/core/src/main/java/uk/ac/shef/dcs/oak/sti/algorithm/tm/MainInterpreter_and_Forward_learner.java +++ b/core/src/main/java/uk/ac/shef/dcs/oak/sti/algorithm/tm/MainInterpreter_and_Forward_learner.java @@ -11,37 +11,47 @@ import java.io.IOException; import java.util.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** */ public class MainInterpreter_and_Forward_learner { + private static final Logger log = LoggerFactory.getLogger(MainInterpreter_and_Forward_learner.class); + private MainColumnFinder main_col_finder; + private ColumnInterpreter interpreter_column; + private ColumnInterpreter_relDepend interpreter_column_with_knownReltaions; + private BinaryRelationInterpreter interpreter_relation; + private HeaderBinaryRelationScorer hbr_scorer; + //private static Logger log = Logger.getLogger(MainInterpreter.class.getName()); private Set ignoreCols; + private int[] forceInterpretColumn; - private Backward_updater backward_updater; + private Backward_updater backward_updater; public MainInterpreter_and_Forward_learner(MainColumnFinder main_col_finder, - ColumnInterpreter interpreter_column, - ColumnInterpreter_relDepend interpreter_column_with_knownReltaions, - BinaryRelationInterpreter interpreter_relation, - int[] ignoreColumns, - int[] forceInterpretColumn, - Backward_updater backward_updater, - HeaderBinaryRelationScorer hbr_scorer) { + ColumnInterpreter interpreter_column, + ColumnInterpreter_relDepend interpreter_column_with_knownReltaions, + BinaryRelationInterpreter interpreter_relation, + int[] ignoreColumns, + int[] forceInterpretColumn, + Backward_updater backward_updater, + HeaderBinaryRelationScorer hbr_scorer) { this.main_col_finder = main_col_finder; this.interpreter_column = interpreter_column; this.interpreter_column_with_knownReltaions = interpreter_column_with_knownReltaions; this.interpreter_relation = interpreter_relation; this.ignoreCols = new HashSet(); - for(int i: ignoreColumns) + for (int i : ignoreColumns) ignoreCols.add(i); this.forceInterpretColumn = forceInterpretColumn; this.backward_updater = backward_updater; @@ -50,10 +60,15 @@ public MainInterpreter_and_Forward_learner(MainColumnFinder main_col_finder, public LTableAnnotation start(LTable table, boolean relationLearning) throws IOException, APIKeysDepletedException, STIException, STIException { //1. find the main subject column of this table - System.out.println(">\t Detecting main column..."); + log.info("*** Detecting main column..."); int[] ignoreColumnsArray = new int[ignoreCols.size()]; - for(int i=0; i>> candidate_main_NE_columns = main_col_finder.compute(table, ignoreColumnsArray); //ignore columns that are likely to be acronyms only, because they are highly ambiguous @@ -67,8 +82,13 @@ public LTableAnnotation start(LTable table, boolean relationLearning) throws IOE }*/ LTableAnnotation tab_annotations = new LTableAnnotation(table.getNumRows(), table.getNumCols()); tab_annotations.setSubjectColumn(candidate_main_NE_columns.get(0).getMainObject()); + + //set also all candidates for subject column + tab_annotations.setCandidateNEForSubjectColumn(candidate_main_NE_columns); + List interpreted_columns = new ArrayList(); - System.out.println(">\t FORWARD LEARNING..."); + log.info("*** FORWARD LEARNING..."); + log.info("Processing table: {}", table); for (int col = 0; col < table.getNumCols(); col++) { /*if(col!=1) continue;*/ @@ -77,7 +97,8 @@ public LTableAnnotation start(LTable table, boolean relationLearning) throws IOE interpreted_columns.add(col); interpreter_column.interpret(table, tab_annotations, col); } else { - if (ignoreColumn(col)) continue; + if (ignoreColumn(col)) + continue; if (!table.getColumnHeader(col).getFeature().getMostDataType().getCandidateType().equals(DataTypeClassifier.DataType.NAMED_ENTITY)) continue; /*if (table.getColumnHeader(col).getFeature().isCode_or_Acronym()) @@ -92,7 +113,7 @@ public LTableAnnotation start(LTable table, boolean relationLearning) throws IOE } if (backward_updater != null) { - System.out.println(">\t BACKWARD UPDATE..."); + log.info("*** BACKWARD UPDATE..."); backward_updater.update(interpreted_columns, table, tab_annotations); } @@ -103,9 +124,10 @@ public LTableAnnotation start(LTable table, boolean relationLearning) throws IOE for (ObjObj> mainCol : candidate_main_NE_columns) { //tab_annotations = new LTableAnnotation(table.getNumRows(), table.getNumCols()); main_subject_column = mainCol.getMainObject(); - if (ignoreColumn(main_subject_column)) continue; + if (ignoreColumn(main_subject_column)) + continue; - System.out.println(">\t Interpret relations with the main column, =" + main_subject_column); + log.info("*** Interpret relations with the main column, =" + main_subject_column); int columns_having_relations_with_main_col = interpreter_relation.interpret(tab_annotations, table, main_subject_column); boolean interpretable = false; if (columns_having_relations_with_main_col > 0) { @@ -131,19 +153,18 @@ public LTableAnnotation start(LTable table, boolean relationLearning) throws IOE tab_annotations = best_annotations; } - if (TableMinerConstants.REVISE_HBR_BY_DC && backward_updater!=null) { + if (TableMinerConstants.REVISE_HBR_BY_DC && backward_updater != null) { List domain_rep = backward_updater.construct_domain_represtation(table, tab_annotations, interpreted_columns); revise_header_binary_relations(tab_annotations, domain_rep); } //4. consolidation-for columns that have relation with main subject column, if the column is // entity column, do column typing and disambiguation; otherwise, simply create header annotation - System.out.println(">\t Classify columns (non-NE) in relation with main column"); + log.info("*** Classify columns (non-NE) in relation with main column"); interpreter_column_with_knownReltaions.interpret(table, tab_annotations, interpreted_columns.toArray(new Integer[0])); } - return tab_annotations; } @@ -207,9 +228,8 @@ private boolean forceInterpret(Integer i) { } private void revise_header_binary_relations(LTableAnnotation annotation, List domain_representation - ) { - for (Map.Entry> - entry : annotation.getRelationAnnotations_across_columns().entrySet()) { + ) { + for (Map.Entry> entry : annotation.getRelationAnnotations_across_columns().entrySet()) { for (HeaderBinaryRelationAnnotation hbr : entry.getValue()) { double domain_consensus = hbr_scorer.score_domain_consensus(hbr, domain_representation); diff --git a/core/src/main/java/uk/ac/shef/dcs/oak/sti/algorithm/tm/TripleGenerator.java b/core/src/main/java/uk/ac/shef/dcs/oak/sti/algorithm/tm/TripleGenerator.java index 3e663bb0..286c4e4f 100644 --- a/core/src/main/java/uk/ac/shef/dcs/oak/sti/algorithm/tm/TripleGenerator.java +++ b/core/src/main/java/uk/ac/shef/dcs/oak/sti/algorithm/tm/TripleGenerator.java @@ -14,6 +14,7 @@ public class TripleGenerator { private String namespace; + private String dummyNamespace; public TripleGenerator(String namespace, String dummyNamespace) { @@ -32,12 +33,11 @@ public List generate_newTriples(LTableAnnotation tab_annotation, L if (bestHeaderAnnotations.size() == 0) continue; - for (int row = 0; row < table.getNumRows(); row++) { for (HeaderAnnotation final_type_for_the_column : bestHeaderAnnotations) { - if (final_type_for_the_column.getSupportingRows().contains(row)) - continue; + // if (final_type_for_the_column.getSupportingRows().contains(row)) + // continue; LTableContentCell tcc = table.getContentCell(row, col); CellAnnotation[] cell_annotations = tab_annotation.getContentCellAnnotations(row, col); if (cell_annotations == null || cell_annotations.length == 0) //no entity found for this cell @@ -48,12 +48,12 @@ public List generate_newTriples(LTableAnnotation tab_annotation, L //new triple LTableTriple ltt = new LTableTriple(); - ltt.setSubject_position(new int[]{row, col}); + ltt.setSubject_position(new int[] { row, col }); ltt.setSubject(tcc.getText()); ltt.setSubject_annotation(namespace + entity.getId()); ltt.setObject(header.getHeaderText()); ltt.setObject_annotation(namespace + final_type_for_the_column.getAnnotation_url()); - ltt.setObject_position(new int[]{-1, -1}); + ltt.setObject_position(new int[] { -1, -1 }); ltt.setRelation_annotation("rdf:type"); result.add(ltt); } @@ -63,10 +63,8 @@ public List generate_newTriples(LTableAnnotation tab_annotation, L //across column relations at each row List related_columns_with_subject = new ArrayList(); int main_subject_column = 0; - Map> - relations_across_columns = tab_annotation.getRelationAnnotations_across_columns(); - for (Map.Entry> entry : - relations_across_columns.entrySet()) { + Map> relations_across_columns = tab_annotation.getRelationAnnotations_across_columns(); + for (Map.Entry> entry : relations_across_columns.entrySet()) { Key_SubjectCol_ObjectCol the_two_columns = entry.getKey(); int subCol = the_two_columns.getSubjectCol(); int objCol = the_two_columns.getObjectCol(); @@ -90,11 +88,11 @@ public List generate_newTriples(LTableAnnotation tab_annotation, L CellAnnotation final_object_cell_annotation = object_cell_annotations == null || object_cell_annotations.length == 0 ? null : object_cell_annotations[0]; LTableTriple triple = new LTableTriple(); - triple.setSubject_position(new int[]{row, subCol}); + triple.setSubject_position(new int[] { row, subCol }); triple.setSubject(final_subject_cell_annotation.getTerm()); triple.setSubject_annotation(namespace + final_subject_cell_annotation.getAnnotation().getId()); - triple.setObject_position(new int[]{row, objCol}); + triple.setObject_position(new int[] { row, objCol }); if (final_object_cell_annotation != null) { triple.setObject_annotation(namespace + final_object_cell_annotation.getAnnotation().getId()); triple.setObject(final_object_cell_annotation.getTerm()); @@ -114,11 +112,11 @@ public List generate_newTriples(LTableAnnotation tab_annotation, L continue; LTableColumnHeader header = table.getColumnHeader(col); - if (header!=null&&header.getTypes() != null) { + if (header != null && header.getTypes() != null) { if (header.getTypes().get(0).getCandidateType().equals(DataTypeClassifier.DataType.ORDERED_NUMBER)) continue; } - else{ + else { continue; } @@ -131,11 +129,11 @@ public List generate_newTriples(LTableAnnotation tab_annotation, L CellAnnotation final_subject_cell_annotation = subject_cell_annotations[0]; LTableTriple triple = new LTableTriple(); - triple.setSubject_position(new int[]{row, main_subject_column}); + triple.setSubject_position(new int[] { row, main_subject_column }); triple.setSubject(final_subject_cell_annotation.getTerm()); triple.setSubject_annotation(namespace + final_subject_cell_annotation.getAnnotation().getId()); - triple.setObject_position(new int[]{row, col}); + triple.setObject_position(new int[] { row, col }); triple.setObject(object_cell.getText()); triple.setObject_annotation("'" + object_cell.getText() + "'"); triple.setRelation_annotation(dummyNamespace + "/" + header.getHeaderText()); diff --git a/core/src/main/java/uk/ac/shef/dcs/oak/sti/algorithm/tm/maincol/ColumnFeatureGenerator.java b/core/src/main/java/uk/ac/shef/dcs/oak/sti/algorithm/tm/maincol/ColumnFeatureGenerator.java index 3518240e..381a5d92 100644 --- a/core/src/main/java/uk/ac/shef/dcs/oak/sti/algorithm/tm/maincol/ColumnFeatureGenerator.java +++ b/core/src/main/java/uk/ac/shef/dcs/oak/sti/algorithm/tm/maincol/ColumnFeatureGenerator.java @@ -16,18 +16,24 @@ import java.io.IOException; import java.util.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import uk.ac.shef.dcs.oak.sti.xtractor.csv.ParserCsv; /** */ public class ColumnFeatureGenerator { private HeaderAndContextMatcher ctxMatcher; + private HeaderWebsearchMatcher_token websearchMatcher; + private NLPTools nlpTools; + private static final Logger log = LoggerFactory.getLogger(ColumnFeatureGenerator.class); public ColumnFeatureGenerator(String cache, String nlpResource, - List stopWords, String... searchAPIKeys) throws IOException { + List stopWords, String... searchAPIKeys) throws IOException { ctxMatcher = new HeaderAndContextMatcher(nlpResource); nlpTools = NLPTools.getInstance(nlpResource); websearchMatcher = new HeaderWebsearchMatcher_token( @@ -38,10 +44,10 @@ public ColumnFeatureGenerator(String cache, String nlpResource, } public ColumnFeatureGenerator(SolrServer cache, String nlpResource, - List stopWords, String... searchAPIKeys) throws IOException { + List stopWords, String... searchAPIKeys) throws IOException { ctxMatcher = new HeaderAndContextMatcher(nlpResource); websearchMatcher = new HeaderWebsearchMatcher_token(new HeaderWebsearchMatcherCache(cache), - new BingWebSearch(searchAPIKeys),stopWords); + new BingWebSearch(searchAPIKeys), stopWords); nlpTools = NLPTools.getInstance(nlpResource); } @@ -67,6 +73,7 @@ public static void feature_columnDataTypes(LTable table) { for (int row = 0; row < table.getNumRows(); row++) { LTableContentCell tcc = table.getContentCell(row, col); + // log.info("About to process table content for row and col: " + row + " " + col); String textContent = tcc.getText(); if (textContent != null) { DataTypeClassifier.DataType dt = DataTypeClassifier.classify(textContent); @@ -180,7 +187,6 @@ public void feature_contextMatchScore(List features, LTable table cf.setContextMatchScore(s); } - } //how does each cell on each row score against a websearch result? @@ -223,12 +229,11 @@ public DoubleMatrix2D feature_webSearchScore(List features, LTabl return scores; } - //since using web search is expensive, we can use data sampling technique to incrementally interpret main column public DoubleMatrix2D feature_webSearchScore_with_sampling(List features, LTable table, - RowSelector sampleSelector, - StoppingCriteria stopper, - int minimumRows) throws APIKeysDepletedException, IOException { + RowSelector sampleSelector, + StoppingCriteria stopper, + int minimumRows) throws APIKeysDepletedException, IOException { if (minimumRows > table.getNumRows()) return feature_webSearchScore(features, table); @@ -244,7 +249,6 @@ public DoubleMatrix2D feature_webSearchScore_with_sampling(List f } } - int[] rowRanking = sampleSelector.select(table); int rows = 0; //then search row-by-row @@ -340,13 +344,11 @@ public void feature_isColumnAcronymOrCode(List allNEColumnCandida } } - } - if (countAcronym_or_Code > (table.getNumRows() - cf.getEmptyCells()-countAcronym_or_Code)) + if (countAcronym_or_Code > (table.getNumRows() - cf.getEmptyCells() - countAcronym_or_Code)) cf.setCode_or_Acronym(true); } } - } diff --git a/core/src/main/java/uk/ac/shef/dcs/oak/sti/algorithm/tm/selector/LTableContentRow_Sampler_nonEmpty.java b/core/src/main/java/uk/ac/shef/dcs/oak/sti/algorithm/tm/selector/LTableContentRow_Sampler_nonEmpty.java index 4b5048d7..b75bc6cf 100644 --- a/core/src/main/java/uk/ac/shef/dcs/oak/sti/algorithm/tm/selector/LTableContentRow_Sampler_nonEmpty.java +++ b/core/src/main/java/uk/ac/shef/dcs/oak/sti/algorithm/tm/selector/LTableContentRow_Sampler_nonEmpty.java @@ -7,8 +7,13 @@ import java.util.*; /** + * Selects certain sample set of rows (as it is it seems that it selects all rows) */ public class LTableContentRow_Sampler_nonEmpty extends RowSelector { + /** + * @param table + * @return Array of row numbers + */ @Override public int[] select(LTable table) { int[] rs = new int[table.getNumRows()]; @@ -21,9 +26,9 @@ public int[] select(LTable table) { if (tcc.getType() != null && !tcc.getType().equals(DataTypeClassifier.DataType.UNKNOWN) && !tcc.getType().equals(DataTypeClassifier.DataType.EMPTY)) count_non_empty++; - else if(tcc.getType()==null){ + else if (tcc.getType() == null) { String cellText = tcc.getText().trim(); - if(cellText.length()>0) + if (cellText.length() > 0) count_non_empty++; } } @@ -38,8 +43,8 @@ public int compare(Integer o1, Integer o2) { } }); - for (int i=0; i stopWords = uk.ac.shef.dcs.oak.util.FileUtils.readList(nlpResources + "/stoplist.txt", true); + //object to find main subject column + MainColumnFinder main_col_finder = new MainColumnFinder( + new LTableContentRow_Sampler_nonEmpty(), + EntropyConvergence.class.getName(), + new String[] { "0.0", "1", "0.01" }, /*Stopping criteria params - double minimum_state_score_sum, int minimum_iterations, double convergence_threshold*/ + server, /* Solr server */ + nlpResources, false, stopWords, + MultiKeyStringSplitter.split(properties.getProperty("BING_API_KEYS"))); + + //stop words and stop properties (freebase) are used for disambiguation + //List stopProperties = FileUtils.readList("D:\\Work\\lodie\\resources\\nlp_resources/stopproperties_freebase.txt", true); + + //object to score columns, and disambiguate entities + Disambiguator disambiguator = new Disambiguator(freebaseMatcher, new DisambiguationScorer_Overlap( + stopWords, + new double[] { 1.0, 0.5, 0.5, 1.0, 1.0 }, //row, column, tablecontext other, refent, tablecontext pagetitle (unused) + nlpResources)); + ClassificationScorer class_scorer = new ClassificationScorer_Vote(nlpResources, + new Creator_ConceptHierarchicalBOW_Freebase(), + stopWords, + new double[] { 1.0, 1.0, 1.0, 1.0 } //all 1.0 + ); + + CellSelector selector = new Sampler_LTableContentCell_OSPD_nonEmpty(); + ColumnLearner_LEARN_Seeding column_learnerSeeding = new ColumnLearner_LEARN_Seeding( + selector, + EntropyConvergence.class.getName(), + new String[] { "0.0", "2", "0.01" }, /*Stopping criteria params - double minimum_state_score_sum, int minimum_iterations, double convergence_threshold*/ + freebaseMatcher, + disambiguator, + class_scorer + ); + /*ColumnLearner_LEARN_Seeding column_learnerSeeding = new ColumnLearner_LEARN_Seeding( + selector, + FixedNumberOfRows.class.getName(), + new String[]{TableMinerConstants.SAMPLE_SIZE}, + freebaseMatcher, + disambiguator, + class_scorer + );*/ + + ColumnLearner_LEARN_Update column_updater = new ColumnLearner_LEARN_Update( + freebaseMatcher, disambiguator, class_scorer + ); + + ColumnInterpreter columnInterpreter = new ColumnInterpreter(column_learnerSeeding, column_updater, TableMinerConstants.MAX_REFERENCE_ENTITY_FOR_DISAMBIGUATION); + + //object to interpret relations between columns + HeaderBinaryRelationScorer relation_scorer = new HeaderBinaryRelationScorer_Vote(nlpResources, + new Creator_RelationHierarchicalBOW_Freebase(), + stopWords, + new double[] { 1.0, 1.0, 0.0, 0.0, 1.0 } //entity, header text, column, title&caption, other + ); + BinaryRelationInterpreter interpreter_relation = new BinaryRelationInterpreter( + new RelationTextMatch_Scorer(0.0, stopWords), + relation_scorer + ); + + //object to consolidate previous output, further score columns and disamgiuate entities + ColumnInterpreter_relDepend interpreter_with_knownRelations = new ColumnInterpreter_relDepend_exclude_entity_col( + IGNORE_COLUMNS + ); + + Backward_updater updater = null;//new Backward_updater(selector,freebaseMatcher,disambiguator,class_scorer,stopWords,nlpResources); + MainInterpreter_and_Forward_learner interpreter = new MainInterpreter_and_Forward_learner( + main_col_finder, /* object responsible for finding main column */ + columnInterpreter, + interpreter_with_knownRelations, + interpreter_relation, + IGNORE_COLUMNS, new int[0], + updater, relation_scorer); + + LTableAnnotationWriter writer = new LTableAnnotationWriter( + new TripleGenerator("http://www.freebase.com", "http://lodie.dcs.shef.ac.uk")); + + // Table extractor + TableXtractorCSV xtractor = new TableXtractorCSV(); + // TableXtractorIMDB xtractor = new TableXtractorIMDB(new TableNormalizerFrequentRowLength(true), + // new TableHODetectorByHTMLTag(), + // new TableObjCreatorIMDB(), + // new TabValGeneric()); + int count = 0; + List all = Arrays.asList(new File(inFolder).listFiles()); + Collections.sort(all); + log.info("Number of files to be processed: " + all.size()); + for (File f : all) { + count++; + if (count - 1 < offset) + continue; + + boolean complete = false; + String inFile = f.toString(); + log.info("\n\n*************** Processing file: " + f.getName()); + TimeWatch watch = TimeWatch.start(); + try { + + List tables = xtractor.extract(f, inFile); + log.info("Extraction of tables finished"); + log.info("Extracted: " + tables.size() + " tables"); + + if (tables.size() == 0) { + log.warning("No tables"); + continue; + } + + LTable table = tables.get(0); + + String sourceTableFile = inFile; + if (sourceTableFile.startsWith("\"") && sourceTableFile.endsWith("\"")) + sourceTableFile = sourceTableFile.substring(1, sourceTableFile.length() - 1).trim(); + System.out.println(count + "_" + sourceTableFile + " " + new Date()); + log.info(">>>" + count + "_" + sourceTableFile); + + complete = process(f, interpreter, table, sourceTableFile, writer, outFolder, relationLearning); + //server.commit(); + if (TableMinerConstants.COMMIT_SOLR_PER_FILE) + server.commit(); + if (!complete) { + System.out.println("\t\t\t missed: " + count + "_" + sourceTableFile); + PrintWriter missedWriter = null; + try { + missedWriter = new PrintWriter(new FileWriter("ti_imdb_missed.csv", true)); + missedWriter.println(count + "," + inFile); + missedWriter.close(); + } catch (IOException e1) { + e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } + } + long passedTimeInSeconds = watch.time(TimeUnit.SECONDS); + log.info("Processed in seconds: " + passedTimeInSeconds); + //gs annotator + + } catch (Exception e) { + e.printStackTrace(); + PrintWriter missedWriter = null; + try { + missedWriter = new PrintWriter(new FileWriter("ti_imdb_missed.csv", true)); + missedWriter.println(count + "," + inFile); + missedWriter.close(); + } catch (IOException e1) { + e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } + e.printStackTrace(); + } + + } + server.shutdown(); + System.out.println(new Date()); + } + + public static boolean process(File f, MainInterpreter_and_Forward_learner interpreter, LTable table, String sourceTableFile, LTableAnnotationWriter writer, String outFolder, boolean relationLearning) throws Exception { + String outFilename = sourceTableFile.replaceAll("\\\\", "/"); + try { + LTableAnnotation annotations = interpreter.start(table, relationLearning); + + int startIndex = outFilename.lastIndexOf("/"); + if (startIndex != -1) { + outFilename = outFilename.substring(startIndex + 1).trim(); + } + writer.writeHTML(table, annotations, outFolder + "/" + outFilename + ".html"); + + String basicStatsFileName = outFolder + "/" + "_basicStats"; + log.info("Writing basic stats to " + basicStatsFileName); + writer.writeBasicSubjectColumnStatisticsCSV(f, table, annotations, basicStatsFileName); + + String classificationFileName = outFolder + "/" + "_classifyStats"; + log.info("Writing classification stats to " + classificationFileName); + writer.writeClassificationStatisticsCSV(f, table, annotations, classificationFileName); + + String classificationAllFileName = outFolder + "/" + "_classifyStatsAll"; + log.info("Writing all classification stats to " + classificationAllFileName); + writer.writeClassificationStatisticsAllConceptsCSV(f, table, annotations, classificationAllFileName); + + } catch (Exception ste) { + if (ste instanceof SocketTimeoutException || ste instanceof HttpResponseException) { + ste.printStackTrace(); + System.out.println("Remote server timed out, continue 10 seconds. Missed." + outFilename); + try { + Thread.sleep(10000); + } catch (Exception e) { + } + return false; + } else + throw ste; + + } + return true; + } +} diff --git a/core/src/main/java/uk/ac/shef/dcs/oak/sti/experiment/TestTableInterpretation_IMDB.java b/core/src/main/java/uk/ac/shef/dcs/oak/sti/experiment/TestTableInterpretation_IMDB.java index cf76fe4e..a427c2a6 100644 --- a/core/src/main/java/uk/ac/shef/dcs/oak/sti/experiment/TestTableInterpretation_IMDB.java +++ b/core/src/main/java/uk/ac/shef/dcs/oak/sti/experiment/TestTableInterpretation_IMDB.java @@ -32,7 +32,7 @@ public class TestTableInterpretation_IMDB { private static Logger log = Logger.getLogger(TestTableInterpretation_IMDB.class.getName()); - public static int[] IGNORE_COLUMNS = new int[]{0, 2, 3}; + public static int[] IGNORE_COLUMNS = new int[] { 0, 2, 3 }; public static void main(String[] args) throws IOException { String inFolder = args[0]; @@ -40,10 +40,10 @@ public static void main(String[] args) throws IOException { String propertyFile = args[2]; //"D:\\Work\\lodiecrawler\\src\\main\\java/freebase.properties" Properties properties = new Properties(); properties.load(new FileInputStream(propertyFile)); - String cacheFolder = args[3]; //String cacheFolder = "D:\\Work\\lodiedata\\tableminer_cache\\solrindex_cache\\zookeeper\\solr"; + String cacheFolder = args[3]; //String cacheFolder = "D:\\Work\\lodiedata\\tableminer_cache\\solrindex_cache\\zookeeper\\solr"; String nlpResources = args[4]; //"D:\\Work\\lodie\\resources\\nlp_resources"; int start = Integer.valueOf(args[5]); - boolean relationLearning=Boolean.valueOf(args[6]); + boolean relationLearning = Boolean.valueOf(args[6]); //cache target location File configFile = new File(cacheFolder + File.separator + "solr.xml"); @@ -52,41 +52,40 @@ public static void main(String[] args) throws IOException { SolrServer server = new EmbeddedSolrServer(container, "collection1"); //object to fetch things from KB - KnowledgeBaseSearcher_Freebase freebaseMatcher = new KnowledgeBaseSearcher_Freebase(propertyFile,true, server, null,null); + KnowledgeBaseSearcher_Freebase freebaseMatcher = new KnowledgeBaseSearcher_Freebase(propertyFile, true, server, null, null); List stopWords = uk.ac.shef.dcs.oak.util.FileUtils.readList(nlpResources + "/stoplist.txt", true); //object to find main subject column MainColumnFinder main_col_finder = new MainColumnFinder( new LTableContentRow_Sampler_nonEmpty(), EntropyConvergence.class.getName(), - new String[]{"0.0", "1", "0.01"}, + new String[] { "0.0", "1", "0.01" }, server, - nlpResources, false,stopWords, + nlpResources, false, stopWords, MultiKeyStringSplitter.split(properties.getProperty("BING_API_KEYS"))); - //stop words and stop properties (freebase) are used for disambiguation //List stopProperties = FileUtils.readList("D:\\Work\\lodie\\resources\\nlp_resources/stopproperties_freebase.txt", true); //object to score columns, and disambiguate entities Disambiguator disambiguator = new Disambiguator(freebaseMatcher, new DisambiguationScorer_Overlap( stopWords, - new double[]{1.0, 0.5, 0.5, 1.0, 1.0}, //row,column, tablecontext other,refent, tablecontext pagetitle (unused) + new double[] { 1.0, 0.5, 0.5, 1.0, 1.0 }, //row,column, tablecontext other,refent, tablecontext pagetitle (unused) nlpResources)); ClassificationScorer class_scorer = new ClassificationScorer_Vote(nlpResources, new Creator_ConceptHierarchicalBOW_Freebase(), stopWords, - new double[]{1.0, 1.0,1.0, 1.0} //all 1.0 + new double[] { 1.0, 1.0, 1.0, 1.0 } //all 1.0 ); - CellSelector selector=new Sampler_LTableContentCell_OSPD_nonEmpty(); + CellSelector selector = new Sampler_LTableContentCell_OSPD_nonEmpty(); ColumnLearner_LEARN_Seeding column_learnerSeeding = new ColumnLearner_LEARN_Seeding( selector, EntropyConvergence.class.getName(), - new String[]{"0.0", "2", "0.01"}, + new String[] { "0.0", "2", "0.01" }, freebaseMatcher, disambiguator, class_scorer - ); + ); /*ColumnLearner_LEARN_Seeding column_learnerSeeding = new ColumnLearner_LEARN_Seeding( selector, FixedNumberOfRows.class.getName(), @@ -98,8 +97,7 @@ public static void main(String[] args) throws IOException { ColumnLearner_LEARN_Update column_updater = new ColumnLearner_LEARN_Update( freebaseMatcher, disambiguator, class_scorer - ); - + ); ColumnInterpreter columnInterpreter = new ColumnInterpreter(column_learnerSeeding, column_updater, TableMinerConstants.MAX_REFERENCE_ENTITY_FOR_DISAMBIGUATION); @@ -107,18 +105,17 @@ public static void main(String[] args) throws IOException { HeaderBinaryRelationScorer relation_scorer = new HeaderBinaryRelationScorer_Vote(nlpResources, new Creator_RelationHierarchicalBOW_Freebase(), stopWords, - new double[]{1.0, 1.0, 0.0, 0.0, 1.0} //entity, header text, column, title&caption, other + new double[] { 1.0, 1.0, 0.0, 0.0, 1.0 } //entity, header text, column, title&caption, other ); BinaryRelationInterpreter interpreter_relation = new BinaryRelationInterpreter( new RelationTextMatch_Scorer(0.0, stopWords), relation_scorer - ); + ); //object to consolidate previous output, further score columns and disamgiuate entities ColumnInterpreter_relDepend interpreter_with_knownRelations = new ColumnInterpreter_relDepend_exclude_entity_col( IGNORE_COLUMNS - ); - + ); Backward_updater updater = null;//new Backward_updater(selector,freebaseMatcher,disambiguator,class_scorer,stopWords,nlpResources); MainInterpreter_and_Forward_learner interpreter = new MainInterpreter_and_Forward_learner( @@ -127,12 +124,11 @@ public static void main(String[] args) throws IOException { interpreter_with_knownRelations, interpreter_relation, IGNORE_COLUMNS, new int[0], - updater,relation_scorer); + updater, relation_scorer); LTableAnnotationWriter writer = new LTableAnnotationWriter( new TripleGenerator("http://www.freebase.com", "http://lodie.dcs.shef.ac.uk")); - TableXtractorIMDB xtractor = new TableXtractorIMDB(new TableNormalizerFrequentRowLength(true), new TableHODetectorByHTMLTag(), new TableObjCreatorIMDB(), @@ -141,11 +137,11 @@ public static void main(String[] args) throws IOException { List all = Arrays.asList(new File(inFolder).listFiles()); Collections.sort(all); System.out.println(all.size()); - int[] onlyDo = new int[]{1240, + int[] onlyDo = new int[] { 1240, 2598, 4991, 5146, - 5153}; + 5153 }; for (File f : all) { count++; if (count - 1 < start) @@ -177,9 +173,9 @@ public static void main(String[] args) throws IOException { System.out.println(count + "_" + sourceTableFile + " " + new Date()); log.info(">>>" + count + "_" + sourceTableFile); - complete = process(interpreter, table, sourceTableFile, writer, outFolder,relationLearning); + complete = process(interpreter, table, sourceTableFile, writer, outFolder, relationLearning); //server.commit(); - if(TableMinerConstants.COMMIT_SOLR_PER_FILE) + if (TableMinerConstants.COMMIT_SOLR_PER_FILE) server.commit(); if (!complete) { System.out.println("\t\t\t missed: " + count + "_" + sourceTableFile); @@ -189,7 +185,7 @@ public static void main(String[] args) throws IOException { missedWriter.println(count + "," + inFile); missedWriter.close(); } catch (IOException e1) { - e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } //gs annotator @@ -202,7 +198,7 @@ public static void main(String[] args) throws IOException { missedWriter.println(count + "," + inFile); missedWriter.close(); } catch (IOException e1) { - e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } e.printStackTrace(); } @@ -212,12 +208,11 @@ public static void main(String[] args) throws IOException { System.out.println(new Date()); } - public static boolean process(MainInterpreter_and_Forward_learner interpreter, LTable table, String sourceTableFile, LTableAnnotationWriter writer, - String outFolder,boolean relationLearning) throws Exception { + String outFolder, boolean relationLearning) throws Exception { String outFilename = sourceTableFile.replaceAll("\\\\", "/"); try { - LTableAnnotation annotations = interpreter.start(table,relationLearning); + LTableAnnotation annotations = interpreter.start(table, relationLearning); int startIndex = outFilename.lastIndexOf("/"); if (startIndex != -1) { diff --git a/core/src/main/java/uk/ac/shef/dcs/oak/sti/experiment/TimeWatch.java b/core/src/main/java/uk/ac/shef/dcs/oak/sti/experiment/TimeWatch.java new file mode 100644 index 00000000..541dc041 --- /dev/null +++ b/core/src/main/java/uk/ac/shef/dcs/oak/sti/experiment/TimeWatch.java @@ -0,0 +1,33 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package uk.ac.shef.dcs.oak.sti.experiment; + +import java.util.concurrent.TimeUnit; + +public class TimeWatch { + long starts; + + public static TimeWatch start() { + return new TimeWatch(); + } + + private TimeWatch() { + reset(); + } + + public TimeWatch reset() { + starts = System.currentTimeMillis(); + return this; + } + + public long time() { + long ends = System.currentTimeMillis(); + return ends - starts; + } + + public long time(TimeUnit unit) { + return unit.convert(time(), TimeUnit.MILLISECONDS); + } +} diff --git a/core/src/main/java/uk/ac/shef/dcs/oak/sti/io/LTableAnnotationWriter.java b/core/src/main/java/uk/ac/shef/dcs/oak/sti/io/LTableAnnotationWriter.java index f4f7d487..6ed3cbc8 100644 --- a/core/src/main/java/uk/ac/shef/dcs/oak/sti/io/LTableAnnotationWriter.java +++ b/core/src/main/java/uk/ac/shef/dcs/oak/sti/io/LTableAnnotationWriter.java @@ -1,15 +1,23 @@ package uk.ac.shef.dcs.oak.sti.io; +import java.io.BufferedWriter; import uk.ac.shef.dcs.oak.sti.algorithm.tm.TripleGenerator; import uk.ac.shef.dcs.oak.sti.misc.DataTypeClassifier; import uk.ac.shef.dcs.oak.sti.rep.*; import java.io.File; import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.OutputStreamWriter; import java.io.PrintWriter; +import java.nio.charset.Charset; +import java.text.DecimalFormat; import java.util.Collections; import java.util.List; import java.util.Map; +import uk.ac.shef.dcs.oak.util.ObjObj; /** @@ -17,14 +25,15 @@ public class LTableAnnotationWriter { protected String linkPrefix = "http://www.freebase.com"; + protected boolean showLosingCandidates = true; + protected TripleGenerator tripleGenerator; public LTableAnnotationWriter(TripleGenerator tripleGenerator) { this.tripleGenerator = tripleGenerator; } - public void writeHTML(LTable table, LTableAnnotation tab_annotations, String outFile) throws FileNotFoundException { StringBuilder table_sb = new StringBuilder(); table_sb.append("\n"); @@ -76,15 +85,15 @@ protected void writeCellKeyFile(LTable table, LTableAnnotation table_annotation, if (cans != null && cans.length > 0) { StringBuilder s = new StringBuilder(); s.append(r).append(",").append(c).append("="); - double prevScore=0.0; + double prevScore = 0.0; for (CellAnnotation ca : cans) { if (prevScore == 0.0) { s.append(ca.getAnnotation().getId()); - prevScore=ca.getFinalScore(); + prevScore = ca.getFinalScore(); } - else{ - if(ca.getFinalScore()==prevScore){ + else { + if (ca.getFinalScore() == prevScore) { s.append("=").append(ca.getAnnotation().getId()); } else @@ -98,24 +107,336 @@ protected void writeCellKeyFile(LTable table, LTableAnnotation table_annotation, p.close(); } + /** + * It writes for each row + * + * @param table + * @param table_annotation + * @param cell_key + * @throws FileNotFoundException + */ + public void writeBasicStatistics(File f, LTable table, LTableAnnotation table_annotation, String cell_key) throws FileNotFoundException { + + PrintWriter p = new PrintWriter(cell_key); + + //p.println("Rows;Cols;NECols;SubjectColID"); + + p.print(" File: " + f.getName()); + int nRows = table_annotation.getRows(); + p.print(" Rows: " + nRows); + int nColumns = table_annotation.getCols(); + p.print(" Cols: " + nColumns); + + p.print(" Columns: "); + for (int i = 0; i < nColumns; i++) { + String columnHeaderText = table.getColumnHeader(i).getHeaderText(); + p.print(columnHeaderText + ","); + } + + int nneColumns = table_annotation.getCandidateNEForSubjectColumn().size(); + p.print(" NECols: " + nneColumns); + + //subject column and candidates + + int subjectColumnID = table_annotation.getSubjectColumn(); + String columnName = table.getColumnHeader(subjectColumnID).getHeaderText();; + p.print(" SubjCol: " + columnName); + p.print(" SubjColCandidates:: "); + for (ObjObj object : table_annotation.getCandidateNEForSubjectColumn()) { + int columnID = (int) object.getMainObject(); + columnName = table.getColumnHeader(columnID).getHeaderText();; + p.print(columnName); + ObjObj otherObject = (ObjObj) object.getOtherObject(); + p.print(":" + otherObject.getMainObject()); + p.print(","); + + } + + //classification + p.print(" Classification:: "); + for (ObjObj object : table_annotation.getCandidateNEForSubjectColumn()) { + int columnID = (int) object.getMainObject(); + columnName = table.getColumnHeader(columnID).getHeaderText();; + p.print(columnName + ":"); + + //get classification + HeaderAnnotation[] anns = table_annotation.getHeaderAnnotation(columnID); + if (anns != null && anns.length > 0) { + StringBuilder s = new StringBuilder(); + //s.append("\n" + columnName); + + //get only top concepts (with highest score - more concept can have the highest score!) + double prevScore = 0.0; + for (HeaderAnnotation ha : anns) { + + if (prevScore == 0.0) { + prevScore = ha.getFinalScore(); + } + + if (ha.getFinalScore() < prevScore) { + //it is not the highest score, we break (the values are sorted) + break; + } + + s.append(ha.getAnnotation_url()); + s.append(":" + ha.getFinalScore()); + s.append(","); + } + p.print(s.toString()); + } + + } + + p.close(); + } + + /** + * It writes for each row + * + * @param table + * @param table_annotation + * @param cell_key + * @throws FileNotFoundException + */ + public void writeBasicSubjectColumnStatisticsCSV(File f, LTable table, LTableAnnotation table_annotation, String cell_key) throws FileNotFoundException { + + boolean prepareHeader = false; + File temp = new File(cell_key); + if (!temp.exists()) { + // do something + prepareHeader = true; + } + + Charset encoding = table.getEncoding(); + + PrintWriter p = null; + try { + p = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(cell_key, true), encoding))); + + //PrintWriter p = new PrintWriter(cell_key); + + if (prepareHeader) { + p.println("File;Rows;Cols;Columns;SubjCol;NECols;SubjColCandidates"); + } + + p.append(f.getName()); + p.append(";"); + int nRows = table_annotation.getRows(); + p.append(String.valueOf(nRows)); + p.append(";"); + int nColumns = table_annotation.getCols(); + p.append(String.valueOf(nColumns)); + p.append(";"); + + //column headers + for (int i = 0; i < nColumns; i++) { + String columnHeaderText = table.getColumnHeader(i).getHeaderText(); + p.append(columnHeaderText.trim()); + if (i < nColumns - 1) + p.append(","); + } + p.append(";"); + + //subject column and candidates for subject column + int subjectColumnID = table_annotation.getSubjectColumn(); + String subjectColumnName = table.getColumnHeader(subjectColumnID).getHeaderText();; + p.append(subjectColumnName); + p.append(";"); + + int nneColumns = table_annotation.getCandidateNEForSubjectColumn().size(); + p.append(String.valueOf(nneColumns)); + p.append(";"); + + //list the candidates (name:score) + for (ObjObj object : table_annotation.getCandidateNEForSubjectColumn()) { + int columnID = (int) object.getMainObject(); + subjectColumnName = table.getColumnHeader(columnID).getHeaderText();; + p.append(subjectColumnName.trim()); + ObjObj otherObject = (ObjObj) object.getOtherObject(); + p.append(":" + otherObject.getMainObject()); + p.append(","); + + } + p.append("\n"); + + } catch (IOException e) { + System.err.println(e); + } finally { + if (p != null) { + p.close(); + } + } + } + + /** + * It writes for each row + * + * @param table + * @param table_annotation + * @param cell_key + * @throws FileNotFoundException + */ + public void writeClassificationStatisticsCSV(File f, LTable table, LTableAnnotation table_annotation, String cell_key) throws FileNotFoundException { + + boolean prepareHeader = false; + File temp = new File(cell_key); + if (!temp.exists()) { + // do something + prepareHeader = true; + } + + Charset encoding = table.getEncoding(); + + PrintWriter p = null; + try { + p = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(cell_key, true), encoding))); + + // PrintWriter p = new PrintWriter(new FileOutputStream( + // new File("cell_key"), + // true /* append = true */)); + + if (prepareHeader) { + p.println("File;ClassifiedColumn;TopScore;TopConcept"); + } + //classification + for (ObjObj object : table_annotation.getCandidateNEForSubjectColumn()) { + + int columnID = (int) object.getMainObject(); + String columnName = table.getColumnHeader(columnID).getHeaderText(); + + //get classification + HeaderAnnotation[] anns = table_annotation.getHeaderAnnotation(columnID); + if (anns != null && anns.length > 0) { + StringBuilder s = new StringBuilder(); + //s.append("\n" + columnName); + + //get only top concepts (with highest score - more concept can have the highest score!) + double prevScore = 0.0; + for (HeaderAnnotation ha : anns) { + + if (prevScore == 0.0) { + + prevScore = ha.getFinalScore(); + + } + + if (ha.getFinalScore() < prevScore) { + //it is not the highest score, we break (the values are sorted) + break; + } + + s.append(f.getName()); + s.append(";"); + + s.append(columnName.trim()); + s.append(";"); + + s.append(new DecimalFormat("#.###").format(prevScore)); + s.append(";"); + + s.append(ha.getAnnotation_url()); + s.append("\n"); + } + p.append(s.toString()); + } + + } + } catch (IOException e) { + System.err.println(e); + } finally { + if (p != null) { + p.close(); + } + } + } + + /** + * It writes for each row + * + * @param table + * @param table_annotation + * @param cell_key + * @throws FileNotFoundException + */ + public void writeClassificationStatisticsAllConceptsCSV(File f, LTable table, LTableAnnotation table_annotation, String cell_key) throws FileNotFoundException { + + boolean prepareHeader = false; + File temp = new File(cell_key); + if (!temp.exists()) { + // do something + prepareHeader = true; + } + + Charset encoding = table.getEncoding(); + + PrintWriter p = null; + try { + p = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(cell_key, true), encoding))); + + // PrintWriter p = new PrintWriter(new FileOutputStream( + // new File("cell_key"), + // true /* append = true */)); + + if (prepareHeader) { + p.println("File;ClassifiedColumn;Score;Concept"); + } + //classification + for (ObjObj object : table_annotation.getCandidateNEForSubjectColumn()) { + + int columnID = (int) object.getMainObject(); + String columnName = table.getColumnHeader(columnID).getHeaderText(); + + //get classification + HeaderAnnotation[] anns = table_annotation.getHeaderAnnotation(columnID); + if (anns != null && anns.length > 0) { + StringBuilder s = new StringBuilder(); + //s.append("\n" + columnName); + + //get only top concepts (with highest score - more concept can have the highest score!) + for (HeaderAnnotation ha : anns) { + + s.append(f.getName()); + s.append(";"); + + s.append(columnName.trim()); + s.append(";"); + + s.append(new DecimalFormat("#.###").format(ha.getFinalScore())); + s.append(";"); + + s.append(ha.getAnnotation_url()); + s.append("\n"); + } + p.append(s.toString()); + } + + } + } catch (IOException e) { + System.err.println(e); + } finally { + if (p != null) { + p.close(); + } + } + } + protected void writeRelationKeyFile(LTableAnnotation table_annotation, String relation_key) throws FileNotFoundException { PrintWriter p = new PrintWriter(relation_key); - for (Map.Entry> e : - table_annotation.getRelationAnnotations_across_columns().entrySet()) { + for (Map.Entry> e : table_annotation.getRelationAnnotations_across_columns().entrySet()) { int subCol = e.getKey().getSubjectCol(); int objCol = e.getKey().getObjectCol(); List relations = e.getValue(); Collections.sort(relations); StringBuilder s = new StringBuilder(); - double prevScore=0.0; + double prevScore = 0.0; for (HeaderBinaryRelationAnnotation hr : relations) { if (prevScore == 0.0) { s.append(hr.getAnnotation_url()); - prevScore=hr.getFinalScore(); + prevScore = hr.getFinalScore(); } - else{ - if(hr.getFinalScore()==prevScore){ + else { + if (hr.getFinalScore() == prevScore) { s.append("=").append(hr.getAnnotation_url()); } else @@ -141,19 +462,19 @@ protected void writeHeaderKeyFile(LTable table, LTableAnnotation table_annotatio if (prevScore == 0.0) { s.append(ha.getAnnotation_url()); - prevScore=ha.getFinalScore(); + prevScore = ha.getFinalScore(); } - else{ - if(ha.getFinalScore()==prevScore){ + else { + if (ha.getFinalScore() == prevScore) { s.append("=").append(ha.getAnnotation_url()); } else s.append("|").append(ha.getAnnotation_url()); } } - if(table.getColumnHeader(c).getFeature().getMostDataType().getCandidateType().equals( + if (table.getColumnHeader(c).getFeature().getMostDataType().getCandidateType().equals( DataTypeClassifier.DataType.NAMED_ENTITY - )) + )) s.append("\t\t\t___NE"); p.println(s.toString()); } @@ -197,7 +518,7 @@ protected String writeRelation_inCell(LTable table, LTableAnnotation tab_annotat CellAnnotation cAnn = cAnns[i]; if (i == 0) { //the winning annotation annotation.append("
").append(generateCellAnnotationString(cAnn)).append("
"); - } else if (showLosingCandidates) { //others + } else if (showLosingCandidates) { //others annotation.append("
"). append(generateCellAnnotationString(cAnn)).append("
"); } @@ -228,7 +549,7 @@ protected String writeRelation_inCell(LTable table, LTableAnnotation tab_annotat CellBinaryRelationAnnotation crAnn = crAnns.get(i); if (i == 0) { //the winning annotation annotation.append("
").append(generateAcrossCellRelationString(crAnn)).append("
"); - } else if (showLosingCandidates) { //others + } else if (showLosingCandidates) { //others annotation.append("
"). append(generateAcrossCellRelationString(crAnn)).append("
"); } @@ -250,7 +571,7 @@ protected String writeRelation_inHeader(LTable table, LTableAnnotation tab_annot for (int col = 0; col < table.getNumCols(); col++) { String color = col == tab_annotations.getSubjectColumn() ? " bgcolor=\"yellow\"" : ""; LTableColumnHeader header = table.getColumnHeader(col); - if(header==null) + if (header == null) continue; out.append("\t").append(header.getHeaderText()).append("\n"); @@ -271,7 +592,7 @@ protected String writeRelation_inHeader(LTable table, LTableAnnotation tab_annot best_score = hAnn.getFinalScore(); } else if (hAnn.getFinalScore() == best_score) { annotation.append("
").append(generateHeaderAnnotationString(hAnn)).append("
"); - } else if (showLosingCandidates) { //others + } else if (showLosingCandidates) { //others annotation.append("
"). append(generateHeaderAnnotationString(hAnn)).append("
"); } @@ -295,7 +616,7 @@ protected String writeRelation_inHeader(LTable table, LTableAnnotation tab_annot HeaderBinaryRelationAnnotation hAnn = hAnns.get(i); if (i == 0) { //the winning annotation annotation.append("
").append(generateAcrossHeaderRelationString(hAnn)).append("
"); - } else if (showLosingCandidates) { //others + } else if (showLosingCandidates) { //others annotation.append("
"). append(generateAcrossHeaderRelationString(hAnn)).append("
"); } @@ -310,13 +631,12 @@ protected String writeRelation_inHeader(LTable table, LTableAnnotation tab_annot return out.toString(); } - protected String writeHeader(LTable table, LTableAnnotation tab_annotations) { StringBuilder out = new StringBuilder(); out.append("\n"); for (int col = 0; col < table.getNumCols(); col++) { LTableColumnHeader header = table.getColumnHeader(col); - if(header==null) + if (header == null) continue; out.append("\t").append(header.getHeaderText()).append("\n"); @@ -336,7 +656,7 @@ protected String writeHeader(LTable table, LTableAnnotation tab_annotations) { best_score = hAnn.getFinalScore(); } else if (hAnn.getFinalScore() == best_score) { annotation.append("
").append(generateHeaderAnnotationString(hAnn)).append("
"); - } else if (showLosingCandidates) { //others + } else if (showLosingCandidates) { //others annotation.append("
"). append(generateHeaderAnnotationString(hAnn)).append("
"); } @@ -372,7 +692,7 @@ protected String writeCell(LTable table, LTableAnnotation tab_annotations) { CellAnnotation cAnn = cAnns[i]; if (i == 0) { //the winning annotation annotation.append("
").append(generateCellAnnotationString(cAnn)).append("
"); - } else if (showLosingCandidates) { //others + } else if (showLosingCandidates) { //others annotation.append("
"). append(generateCellAnnotationString(cAnn)).append("
"); } @@ -419,4 +739,5 @@ protected String generateAcrossCellRelationString(CellBinaryRelationAnnotation c append("=").append(Math.round(ca.getScore() * 100.0) / 100.0); return sb.toString(); } + } diff --git a/core/src/main/java/uk/ac/shef/dcs/oak/sti/kb/KnowledgeBaseSearcher_Freebase.java b/core/src/main/java/uk/ac/shef/dcs/oak/sti/kb/KnowledgeBaseSearcher_Freebase.java index c68c61d1..0b949298 100644 --- a/core/src/main/java/uk/ac/shef/dcs/oak/sti/kb/KnowledgeBaseSearcher_Freebase.java +++ b/core/src/main/java/uk/ac/shef/dcs/oak/sti/kb/KnowledgeBaseSearcher_Freebase.java @@ -17,25 +17,35 @@ import java.util.*; import java.util.logging.Logger; +import org.slf4j.LoggerFactory; /** */ public class KnowledgeBaseSearcher_Freebase extends KnowledgeBaseSearcher { + private static final org.slf4j.Logger log = LoggerFactory.getLogger(KnowledgeBaseSearcher_Freebase.class); + public static String NAME_SIMILARITY_CACHE = "similarity"; + private boolean commit; + private FreebaseQueryHelper searcher; - private static Logger log = Logger.getLogger(KnowledgeBaseSearcher_Freebase.class.getName()); + + //private static Logger log = Logger.getLogger(KnowledgeBaseSearcher_Freebase.class.getName()); + protected SearchCacheSolr cacheEntity; + protected SearchCacheSolr cacheConcept; + protected SearchCacheSolr cacheProperty; + protected Map otherCache; - protected boolean split_at_conjunction; + protected boolean split_at_conjunction; public KnowledgeBaseSearcher_Freebase(String freebase_properties, boolean split_at_conjunection, - SolrServer cacheEntity, SolrServer cacheConcept, - SolrServer cacheProperty) throws IOException { + SolrServer cacheEntity, SolrServer cacheConcept, + SolrServer cacheProperty) throws IOException { searcher = new FreebaseQueryHelper(freebase_properties); if (TableMinerConstants.COMMIT_SOLR_PER_FILE) commit = false; @@ -87,8 +97,9 @@ protected List find_matchingEntitiesForText_clientFilterTypes(S try { result = (List) cacheEntity.retrieve(toSolrKey(text)); if (result != null) - log.warning("QUERY (cache load)=" + toSolrKey(text) + "|" + text); + log.debug("QUERY (cache load)=" + toSolrKey(text) + "|" + text); } catch (Exception e) { + log.error(e.getLocalizedMessage()); } } if (result == null) { @@ -104,7 +115,7 @@ protected List find_matchingEntitiesForText_clientFilterTypes(S if (f[0].equals("/type/object/type") && f[3].equals("n") && !ec.hasTypeId(f[2])) - ec.addType(new String[]{f[2], f[1]}); + ec.addType(new String[] { f[2], f[1] }); } } @@ -132,7 +143,8 @@ protected List find_matchingEntitiesForText_clientFilterTypes(S if (queries.length > 1) { for (String q : queries) { q = q.trim(); - if (q.length() < 1) continue; + if (q.length() < 1) + continue; result.addAll(find_matchingEntitiesForText_clientFilterTypes(q, types)); } } @@ -141,9 +153,9 @@ protected List find_matchingEntitiesForText_clientFilterTypes(S result.addAll(topics); try { cacheEntity.cache(toSolrKey(text), result, commit); - log.warning("QUERY (cache save)=" + toSolrKey(text) + "|" + text); + log.debug("QUERY (cache save)=" + toSolrKey(text) + "|" + text); } catch (Exception e) { - e.printStackTrace(); + log.error(e.getLocalizedMessage()); } } @@ -175,11 +187,10 @@ protected List find_matchingEntitiesForText_clientFilterTypes(S ec.addType(ft); } - System.out.println("(QUERY_KB:" + beforeFiltering + " => " + result.size() + id); + log.debug("(QUERY_KB:" + beforeFiltering + " => " + result.size() + id); return result; } - public List find_triplesForEntity_filtered(String entityId) throws IOException { return find_triples_filtered(entityId, cacheEntity); } @@ -202,12 +213,13 @@ public List find_triplesForConcept_filtered(String conceptId) throws I forceQuery = true; List facts = new ArrayList(); String query = createQuery_findFacts(conceptId); - if (query.length() == 0) return facts; + if (query.length() == 0) + return facts; try { facts = (List) cacheConcept.retrieve(toSolrKey(query)); if (facts != null) - log.warning("QUERY (cache load)=" + toSolrKey(query) + "|" + query); + log.warn("QUERY (cache load)=" + toSolrKey(query) + "|" + query); } catch (Exception e) { } if (facts == null || forceQuery) { @@ -224,7 +236,7 @@ public List find_triplesForConcept_filtered(String conceptId) throws I if (!isConcept) { try { cacheConcept.cache(toSolrKey(query), facts, commit); - log.warning("QUERY (cache save)=" + toSolrKey(query) + "|" + query); + log.warn("QUERY (cache save)=" + toSolrKey(query) + "|" + query); } catch (Exception e) { e.printStackTrace(); } @@ -236,14 +248,15 @@ public List find_triplesForConcept_filtered(String conceptId) throws I for (String[] f : retrievedFacts) { if (f[0].equals("/type/type/properties")) { //this is a property of a concept, we need to process it further String propertyId = f[2]; - if (f[2] == null) continue; + if (f[2] == null) + continue; List triples4Property = find_triplesForProperty_filtered(propertyId); for (String[] t : triples4Property) { if (t[0].equals("/type/property/expected_type")) { String rangeLabel = t[1]; String rangeURL = t[2]; - facts.add(new String[]{f[2], rangeLabel, rangeURL, "n"}); + facts.add(new String[] { f[2], rangeLabel, rangeURL, "n" }); } } } else { @@ -252,7 +265,7 @@ public List find_triplesForConcept_filtered(String conceptId) throws I } try { cacheConcept.cache(toSolrKey(query), facts, commit); - log.warning("QUERY (cache save)=" + toSolrKey(query) + "|" + query); + log.warn("QUERY (cache save)=" + toSolrKey(query) + "|" + query); } catch (Exception e) { e.printStackTrace(); } @@ -275,7 +288,7 @@ public double find_granularityForConcept(String type) throws IOException { try { Object o = cacheConcept.retrieve(toSolrKey(query)); if (o != null) { - log.warning("QUERY (cache load)=" + toSolrKey(query) + "|" + type); + log.warn("QUERY (cache load)=" + toSolrKey(query) + "|" + type); return (Double) o; } } catch (Exception e) { @@ -287,13 +300,13 @@ public double find_granularityForConcept(String type) throws IOException { result = granularity; try { cacheConcept.cache(toSolrKey(query), result, commit); - log.warning("QUERY (cache save)=" + toSolrKey(query) + "|" + type); + log.warn("QUERY (cache save)=" + toSolrKey(query) + "|" + type); } catch (Exception e) { System.out.println("FAILED:" + type); e.printStackTrace(); } } catch (IOException ioe) { - log.warning("ERROR(Instances of Type): Unable to fetch freebase page of instances of type: " + type); + log.warn("ERROR(Instances of Type): Unable to fetch freebase page of instances of type: " + type); } } if (result == null) @@ -307,7 +320,7 @@ public List find_expected_types_of_relation(String majority_relation_n List types = new ArrayList(); for (String[] t : triples) { if (t[0].equals("/type/property/expected_type")) { - types.add(new String[]{t[2], t[1]}); + types.add(new String[] { t[2], t[1] }); } } return types; @@ -319,7 +332,7 @@ public List find_typesForEntity_filtered(String id) throws IOException try { result = (List) cacheEntity.retrieve(toSolrKey(query)); if (result != null) { - log.warning("QUERY (cache load)=" + toSolrKey(query) + "|" + query); + log.warn("QUERY (cache load)=" + toSolrKey(query) + "|" + query); } } catch (Exception e) { } @@ -328,12 +341,12 @@ public List find_typesForEntity_filtered(String id) throws IOException List facts = searcher.topicapi_types_of_id(id); for (String[] f : facts) { String type = f[2]; //this is the id of the type - result.add(new String[]{type, f[1]}); + result.add(new String[] { type, f[1] }); } try { cacheEntity.cache(toSolrKey(query), result, commit); // debug_helper_method(id, facts); - log.warning("QUERY (cache save)=" + toSolrKey(query) + "|" + query); + log.warn("QUERY (cache save)=" + toSolrKey(query) + "|" + query); } catch (Exception e) { e.printStackTrace(); } @@ -347,13 +360,14 @@ private List find_triples_filtered(String id, SearchCacheSolr cache) t forceQuery = true; String query = createQuery_findFacts(id); + log.info("Query: {}", query); if (query.length() == 0) return new ArrayList(); List result = null; try { result = (List) cache.retrieve(toSolrKey(query)); if (result != null) - log.warning("QUERY (cache load)=" + toSolrKey(query) + "|" + query); + log.warn("QUERY (cache load)=" + toSolrKey(query) + "|" + query); } catch (Exception e) { } if (result == null || forceQuery) { @@ -368,9 +382,16 @@ private List find_triples_filtered(String id, SearchCacheSolr cache) t } result = new ArrayList(); result.addAll(facts); + // log.info("Results:"); + // for (String[] rs : result) { + // for (String r : rs) { + // log.info("Result: " + r); + // } + // log.info("#####"); + // } try { cache.cache(toSolrKey(query), result, commit); - log.warning("QUERY (cache save)=" + toSolrKey(query) + "|" + query); + log.warn("QUERY (cache save)=" + toSolrKey(query) + "|" + query); } catch (Exception e) { e.printStackTrace(); } @@ -392,24 +413,24 @@ public double find_similarity(String id1, String id2) { try { result = otherCache.get(NAME_SIMILARITY_CACHE).retrieve(toSolrKey(query)); if (result != null) - log.warning("QUERY (cache load)=" + toSolrKey(query) + "|" + query); + log.warn("QUERY (cache load)=" + toSolrKey(query) + "|" + query); } catch (Exception e) { } - if(result==null) + if (result == null) return -1.0; return (Double) result; } public void saveSimilarity(String id1, String id2, double score, boolean biDirectional, - boolean commit) { + boolean commit) { String query = id1 + "<>" + id2; try { otherCache.get(NAME_SIMILARITY_CACHE).cache(toSolrKey(query), score, commit); - log.warning("QUERY (cache saving)=" + toSolrKey(query) + "|" + query); - if(biDirectional){ + log.warn("QUERY (cache saving)=" + toSolrKey(query) + "|" + query); + if (biDirectional) { query = id2 + "<>" + id1; otherCache.get(NAME_SIMILARITY_CACHE).cache(toSolrKey(query), score, commit); - log.warning("QUERY (cache saving)=" + toSolrKey(query) + "|" + query); + log.warn("QUERY (cache saving)=" + toSolrKey(query) + "|" + query); } } catch (Exception e) { e.printStackTrace(); @@ -420,7 +441,7 @@ public void commitChanges() throws IOException, SolrServerException { cacheConcept.commit(); cacheEntity.commit(); cacheProperty.commit(); - for(SearchCacheSolr cache: otherCache.values()) + for (SearchCacheSolr cache : otherCache.values()) cache.commit(); } @@ -431,13 +452,11 @@ private boolean donotRepeatQuery(HttpResponseException e) { return false; } - private String toSolrKey(String text) { //return String.valueOf(text.hashCode()); return String.valueOf(text); } - @Override public void finalizeConnection() { if (cacheEntity != null) diff --git a/core/src/main/java/uk/ac/shef/dcs/oak/sti/rep/LTable.java b/core/src/main/java/uk/ac/shef/dcs/oak/sti/rep/LTable.java index 21e12a84..635088e8 100644 --- a/core/src/main/java/uk/ac/shef/dcs/oak/sti/rep/LTable.java +++ b/core/src/main/java/uk/ac/shef/dcs/oak/sti/rep/LTable.java @@ -6,30 +6,30 @@ import cern.colt.matrix.impl.SparseObjectMatrix2D; import java.io.Serializable; +import java.nio.charset.Charset; import java.util.*; - /** * An LTable always has horizontally related columns. First row always headers - * - * - * * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) * Date: 01/10/12 * Time: 15:06 */ public class LTable implements Serializable { private String sourceId; + private String tableId; private String tableXPath; + private Map rowXPaths; private ObjectMatrix1D headers; //an object can only be a LTableColumnHeader object - private ObjectMatrix2D contents;//an object can only be a LTableContentCell object + private ObjectMatrix2D contents;//an object can only be a LTableContentCell object private int rows; //# of rows in the table (excluding header) + private int cols; //# of columns in the table //private List relations = new ArrayList(); @@ -37,6 +37,22 @@ public class LTable implements Serializable { private LTableAnnotation tableAnnotations; + private Charset encoding; + + @Override + public String toString() { + StringBuilder res = new StringBuilder(); + res.append("Table: SourceID " + sourceId + ",\n"); + res.append("Table: TableID " + tableId + ",\n"); + res.append("Table: TableXPath " + tableXPath + ",\n"); + res.append("Table: RowXPaths " + rowXPaths + ",\n"); + res.append("Table: rows " + rows + ",\n"); + res.append("Table: cols " + cols + ",\n"); + res.append("Table: headers " + headers + ",\n"); + res.append("Table: contents " + contents + ",\n"); + + return res.toString(); + } public LTable(String id, String sourceId, int rows, int cols) { this.tableId = id; @@ -51,31 +67,40 @@ public LTable(String id, String sourceId, int rows, int cols) { tableAnnotations = new LTableAnnotation(rows, cols); } + public LTable(String id, String sourceId) { + this.tableId = id; + this.sourceId = sourceId; + + rowXPaths = new LinkedHashMap(); + } + public int getNumRows() { return rows; } - public void setNumRows(int row){ - this.rows=row; + public void setNumRows(int row) { + this.rows = row; } public int getNumCols() { return cols; } - public void setNumCols(int col){ - this.cols=col; + + public void setNumCols(int col) { + this.cols = col; } - //single header/cell - public void setColumnHeader(int c,LTableColumnHeader header){ + //single header/cell + public void setColumnHeader(int c, LTableColumnHeader header) { headers.set(c, header); } - public LTableColumnHeader getColumnHeader(int c){ + + public LTableColumnHeader getColumnHeader(int c) { Object o = headers.get(c); - if(o==null) + if (o == null) return null; - return (LTableColumnHeader)o; + return (LTableColumnHeader) o; } public void setContentCell(int r, int c, LTableContentCell cell) { @@ -83,20 +108,19 @@ public void setContentCell(int r, int c, LTableContentCell cell) { } public LTableContentCell getContentCell(int r, int c) { - return (LTableContentCell)contents.get(r, c); + return (LTableContentCell) contents.get(r, c); } - //headers and content cells; protected ObjectMatrix1D getTableHeaders() { - return headers; + return headers; } + protected ObjectMatrix2D getContentCells() { ObjectMatrix2D contentCells = contents.viewPart(1, 0, contents.rows() - 1, contents.columns()); return contentCells; } - public String getTableId() { return tableId; } @@ -105,7 +129,6 @@ public void setTableId(String tableId) { this.tableId = tableId; } - public List getContexts() { return contexts; } @@ -130,13 +153,10 @@ public void setSourceId(String sourceId) { this.sourceId = sourceId; } - public String toString() { - return getSourceId() + "," + getTableId(); - } - public String getTableXPath() { return tableXPath; } + public void setTableXPath(String tableXPath) { this.tableXPath = tableXPath; } @@ -145,7 +165,6 @@ public Map getRowXPaths() { return rowXPaths; } - public LTableAnnotation getTableAnnotations() { return tableAnnotations; } @@ -154,11 +173,20 @@ public void setTableAnnotations(LTableAnnotation tableAnnotations) { this.tableAnnotations = tableAnnotations; } - public int size(){ + public int size() { return contents.size(); } public int getNumHeaders() { return headers.size(); } + + public void setEncoding(Charset encoding) { + this.encoding = encoding; + + } + + public Charset getEncoding() { + return encoding; + } } diff --git a/core/src/main/java/uk/ac/shef/dcs/oak/sti/rep/LTableAnnotation.java b/core/src/main/java/uk/ac/shef/dcs/oak/sti/rep/LTableAnnotation.java index d2efc6e7..21da2c43 100644 --- a/core/src/main/java/uk/ac/shef/dcs/oak/sti/rep/LTableAnnotation.java +++ b/core/src/main/java/uk/ac/shef/dcs/oak/sti/rep/LTableAnnotation.java @@ -7,98 +7,119 @@ import uk.ac.shef.dcs.oak.sti.STIException; import java.util.*; +import uk.ac.shef.dcs.oak.util.ObjObj; /** */ public class LTableAnnotation { protected int rows; + protected int cols; + protected int subjectColumn; + + protected List>> candidateNEForSubjectColumn; + protected ObjectMatrix1D headerAnnotations; //each object in the matrix is an array of HeaderAnnotation + protected ObjectMatrix2D contentAnnotations; //each object in the matrix is an array of CellAnnotation + protected Map>> relationAnnotations_per_row; //first key being the sub-obj column; second key is the row index + private Map> relationAnnotations_across_columns; - public LTableAnnotation(int rows, int cols){ - this.rows=rows; - this.cols=cols; - headerAnnotations=new SparseObjectMatrix1D(cols); + public LTableAnnotation(int rows, int cols) { + this.rows = rows; + this.cols = cols; + headerAnnotations = new SparseObjectMatrix1D(cols); contentAnnotations = new SparseObjectMatrix2D(rows, cols); - relationAnnotations_per_row =new HashMap>>(); + relationAnnotations_per_row = new HashMap>>(); relationAnnotations_across_columns = new HashMap>(); } - public int getRows(){ + public int getRows() { return rows; } - public int getCols(){ + + public int getCols() { return cols; } - public void resetRelationAnnotations(){ + public void resetRelationAnnotations() { relationAnnotations_per_row.clear(); relationAnnotations_across_columns.clear(); } - public void resetHeaderAnnotations(){ + public void resetHeaderAnnotations() { headerAnnotations = new SparseObjectMatrix1D(headerAnnotations.size()); } - public void resetCellAnnotations(){ + + public void resetCellAnnotations() { contentAnnotations = new SparseObjectMatrix2D(contentAnnotations.rows(), contentAnnotations.columns()); } + public List>> getCandidateNEForSubjectColumn() { + return candidateNEForSubjectColumn; + } + + public void setCandidateNEForSubjectColumn(List>> candidateNEForSubjectColumn) { + this.candidateNEForSubjectColumn = candidateNEForSubjectColumn; + } + /** * Target and Source must have the same dimension!!! + * * @param source * @param target * @return */ public static void copy(LTableAnnotation source, LTableAnnotation target) throws STIException { - if(source.getCols()!=target.getCols() || source.getRows()!=target.rows) + if (source.getCols() != target.getCols() || source.getRows() != target.rows) throw new STIException("Source and target table annotation object has different dimensions!"); - for(int col=0; col>>( source.getRelationAnnotations_per_row() - ); + ); target.relationAnnotations_across_columns = new HashMap>( source.getRelationAnnotations_across_columns() - ); + ); } - public void setHeaderAnnotation(int headerCol, HeaderAnnotation[] annotations){ + public void setHeaderAnnotation(int headerCol, HeaderAnnotation[] annotations) { Set deduplicateCheck = new HashSet(Arrays.asList(annotations)); - if(deduplicateCheck.size()!=annotations.length) - System.err.println("duplicate header anntoations "+headerCol+":"+deduplicateCheck); + if (deduplicateCheck.size() != annotations.length) + System.err.println("duplicate header anntoations " + headerCol + ":" + deduplicateCheck); headerAnnotations.set(headerCol, annotations); } - public HeaderAnnotation[] getHeaderAnnotation(int headerCol){ - Object o=headerAnnotations.get(headerCol); - if(o==null) + + public HeaderAnnotation[] getHeaderAnnotation(int headerCol) { + Object o = headerAnnotations.get(headerCol); + if (o == null) return new HeaderAnnotation[0]; HeaderAnnotation[] ha = (HeaderAnnotation[]) o; Arrays.sort(ha); @@ -106,20 +127,20 @@ public HeaderAnnotation[] getHeaderAnnotation(int headerCol){ return ha; } - public List getBestHeaderAnnotations(int headerCol){ - HeaderAnnotation[] annotations =getHeaderAnnotation(headerCol); + public List getBestHeaderAnnotations(int headerCol) { + HeaderAnnotation[] annotations = getHeaderAnnotation(headerCol); List result = new ArrayList(); - if(annotations==null||annotations.length==0) + if (annotations == null || annotations.length == 0) return result; double prevScore = 0.0; - for(HeaderAnnotation h: annotations){ - if(prevScore==0.0){ - prevScore=h.getFinalScore(); + for (HeaderAnnotation h : annotations) { + if (prevScore == 0.0) { + prevScore = h.getFinalScore(); result.add(h); continue; } - if(h.getFinalScore()==prevScore) + if (h.getFinalScore() == prevScore) result.add(h); else break; @@ -127,35 +148,36 @@ public List getBestHeaderAnnotations(int headerCol){ return result; } - public void setContentCellAnnotations(int row, int col, CellAnnotation[] annotations){ + public void setContentCellAnnotations(int row, int col, CellAnnotation[] annotations) { Set deduplicateCheck = new HashSet(Arrays.asList(annotations)); - if(deduplicateCheck.size()!=annotations.length) - System.err.println("duplicate cell anntoations "+row+","+col+":"+deduplicateCheck); + if (deduplicateCheck.size() != annotations.length) + System.err.println("duplicate cell anntoations " + row + "," + col + ":" + deduplicateCheck); contentAnnotations.set(row, col, annotations); } - public CellAnnotation[] getContentCellAnnotations(int row, int col){ + + public CellAnnotation[] getContentCellAnnotations(int row, int col) { Object o = contentAnnotations.get(row, col); - if(o==null) + if (o == null) return new CellAnnotation[0]; CellAnnotation[] ca = (CellAnnotation[]) o; Arrays.sort(ca); return ca; } - public List getBestContentCellAnnotations(int row, int col){ - CellAnnotation[] annotations =getContentCellAnnotations(row, col); + public List getBestContentCellAnnotations(int row, int col) { + CellAnnotation[] annotations = getContentCellAnnotations(row, col); List result = new ArrayList(); - if(annotations==null||annotations.length==0) + if (annotations == null || annotations.length == 0) return result; double prevScore = 0.0; - for(CellAnnotation c: annotations){ - if(prevScore==0.0){ - prevScore=c.getFinalScore(); + for (CellAnnotation c : annotations) { + if (prevScore == 0.0) { + prevScore = c.getFinalScore(); result.add(c); continue; } - if(c.getFinalScore()==prevScore) + if (c.getFinalScore() == prevScore) result.add(c); else break; @@ -163,38 +185,38 @@ public List getBestContentCellAnnotations(int row, int col){ return result; } - public void addRelationAnnotation_per_row(CellBinaryRelationAnnotation ra){ + public void addRelationAnnotation_per_row(CellBinaryRelationAnnotation ra) { - Map> annotations_for_columns - = relationAnnotations_per_row.get(ra.getSubject_object_key()); //get the container of binary relations between the two columns - if(annotations_for_columns==null) - annotations_for_columns=new HashMap>(); - List annotations_for_row=annotations_for_columns.get(ra.getRow()); //get the container for binary relations for that row, and between the two columns - if(annotations_for_row==null) + Map> annotations_for_columns = relationAnnotations_per_row.get(ra.getSubject_object_key()); //get the container of binary relations between the two columns + if (annotations_for_columns == null) + annotations_for_columns = new HashMap>(); + List annotations_for_row = annotations_for_columns.get(ra.getRow()); //get the container for binary relations for that row, and between the two columns + if (annotations_for_row == null) annotations_for_row = new ArrayList(); - if(annotations_for_row.contains(ra)){ + if (annotations_for_row.contains(ra)) { //System.out.println(ra); /*CellBinaryRelationAnnotation contained_ra =annotations_for_row.get(annotations_for_row.indexOf(ra)); contained_ra.setScore(contained_ra.getScore()+ra.getScore()); contained_ra.addMatched_values(ra.getMatched_values());*/ - double new_score =ra.getScore(); - CellBinaryRelationAnnotation contained_ra =annotations_for_row.get(annotations_for_row.indexOf(ra)); - if(contained_ra.getScore()> getRelationAnnotationsBetween(int subjectCol, int objectCol){ + + public Map> getRelationAnnotationsBetween(int subjectCol, int objectCol) { Key_SubjectCol_ObjectCol binary_key = new Key_SubjectCol_ObjectCol(subjectCol, objectCol); return relationAnnotations_per_row.get(binary_key); } - public Map>> getRelationAnnotations_per_row(){ + public Map>> getRelationAnnotations_per_row() { return relationAnnotations_per_row; } @@ -210,32 +232,31 @@ public Map> getRe return relationAnnotations_across_columns; } - public void addRelationAnnotation_across_column(HeaderBinaryRelationAnnotation ra){ - if(ra.getAnnotation_url().startsWith("/type")) + public void addRelationAnnotation_across_column(HeaderBinaryRelationAnnotation ra) { + if (ra.getAnnotation_url().startsWith("/type")) System.out.println(); - List annotations_for_columns - = relationAnnotations_across_columns.get(ra.getSubject_object_key()); //get the container of binary relations between the two columns - if(annotations_for_columns==null) - annotations_for_columns=new ArrayList(); - if(annotations_for_columns.contains(ra)) + List annotations_for_columns = relationAnnotations_across_columns.get(ra.getSubject_object_key()); //get the container of binary relations between the two columns + if (annotations_for_columns == null) + annotations_for_columns = new ArrayList(); + if (annotations_for_columns.contains(ra)) System.err.println("hbr already contained"); annotations_for_columns.add(ra); relationAnnotations_across_columns.put(ra.getSubject_object_key(), annotations_for_columns); } - public List getBestRelationAnnotationsBetween(int subjectCol, int objectCol){ + public List getBestRelationAnnotationsBetween(int subjectCol, int objectCol) { Key_SubjectCol_ObjectCol binary_key = new Key_SubjectCol_ObjectCol(subjectCol, objectCol); return getBestRelationAnnotationsBetween(binary_key); } - public List getBestRelationAnnotationsBetween(Key_SubjectCol_ObjectCol subobj){ + public List getBestRelationAnnotationsBetween(Key_SubjectCol_ObjectCol subobj) { List candidates = relationAnnotations_across_columns.get(subobj); Collections.sort(candidates); List result = new ArrayList(); double maxScore = candidates.get(0).getFinalScore(); - for(HeaderBinaryRelationAnnotation hbr: candidates){ - if(hbr.getFinalScore()==maxScore) + for (HeaderBinaryRelationAnnotation hbr : candidates) { + if (hbr.getFinalScore() == maxScore) result.add(hbr); } return result; diff --git a/core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/CharsetDetector.java b/core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/CharsetDetector.java new file mode 100644 index 00000000..cc177fdf --- /dev/null +++ b/core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/CharsetDetector.java @@ -0,0 +1,98 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package uk.ac.shef.dcs.oak.sti.xtractor.csv; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.ByteBuffer; +import java.nio.charset.CharacterCodingException; +import java.nio.charset.Charset; +import java.nio.charset.CharsetDecoder; + +/** + * @author Georgios Migdos + */ +public class CharsetDetector { + + public Charset detectCharset(File f, String[] charsets) { + + Charset charset = null; + + for (String charsetName : charsets) { + charset = detectCharset(f, Charset.forName(charsetName)); + if (charset != null) { + break; + } + } + + return charset; + } + + private Charset detectCharset(File f, Charset charset) { + try { + BufferedInputStream input = new BufferedInputStream(new FileInputStream(f)); + + CharsetDecoder decoder = charset.newDecoder(); + decoder.reset(); + + byte[] buffer = new byte[512]; + boolean identified = false; + while ((input.read(buffer) != -1) && (!identified)) { + identified = identify(buffer, decoder); + } + + input.close(); + + if (identified) { + return charset; + } else { + return null; + } + + } catch (Exception e) { + return null; + } + } + + private boolean identify(byte[] bytes, CharsetDecoder decoder) { + try { + decoder.decode(ByteBuffer.wrap(bytes)); + } catch (CharacterCodingException e) { + return false; + } + return true; + } + + public static void main(String[] args) { + File f = new File("example.txt"); + + String[] charsetsToBeTested = { "UTF-8", "windows-1253", "ISO-8859-7" }; + + CharsetDetector cd = new CharsetDetector(); + Charset charset = cd.detectCharset(f, charsetsToBeTested); + + if (charset != null) { + try { + InputStreamReader reader = new InputStreamReader(new FileInputStream(f), charset); + int c = 0; + while ((c = reader.read()) != -1) { + System.out.print((char) c); + } + reader.close(); + } catch (FileNotFoundException fnfe) { + fnfe.printStackTrace(); + } catch (IOException ioe) { + ioe.printStackTrace(); + } + + } else { + System.out.println("Unrecognized charset."); + } + } +} diff --git a/core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/NoCSVDataException.java b/core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/NoCSVDataException.java new file mode 100644 index 00000000..685472fc --- /dev/null +++ b/core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/NoCSVDataException.java @@ -0,0 +1,16 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package uk.ac.shef.dcs.oak.sti.xtractor.csv; + +/** + * @author tomasknap + */ +public class NoCSVDataException extends Exception { + + public NoCSVDataException(String message) { + super(message); + } + +} diff --git a/core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/ParseFailed.java b/core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/ParseFailed.java new file mode 100644 index 00000000..6bbbc0b2 --- /dev/null +++ b/core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/ParseFailed.java @@ -0,0 +1,17 @@ +package uk.ac.shef.dcs.oak.sti.xtractor.csv; + +/** + * + * @author Škoda Petr + */ +public class ParseFailed extends Exception { + + public ParseFailed(String message) { + super(message); + } + + public ParseFailed(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/Parser.java b/core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/Parser.java new file mode 100644 index 00000000..1b2805d0 --- /dev/null +++ b/core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/Parser.java @@ -0,0 +1,20 @@ +package uk.ac.shef.dcs.oak.sti.xtractor.csv; + +import java.io.File; +import uk.ac.shef.dcs.oak.sti.rep.LTable; + +/** + * @author Škoda Petr + */ +public interface Parser { + + /** + * Parse given file. + * + * @param inFile + * @throws DPUException + * @throws ParseFailed + */ + LTable parse(File inFile) throws ParseFailed, NoCSVDataException; + +} diff --git a/core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/ParserCsv.java b/core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/ParserCsv.java new file mode 100644 index 00000000..f574d3c9 --- /dev/null +++ b/core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/ParserCsv.java @@ -0,0 +1,390 @@ +package uk.ac.shef.dcs.oak.sti.xtractor.csv; + +import cern.colt.matrix.ObjectMatrix2D; +import java.io.*; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.apache.any23.extractor.html.DomUtils; + +import org.apache.commons.io.input.BOMInputStream; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.supercsv.exception.SuperCsvException; +import org.supercsv.io.AbstractCsvReader; +import org.supercsv.io.CsvListReader; +import org.supercsv.prefs.CsvPreference; +import org.supercsv.quote.QuoteMode; +import org.supercsv.util.CsvContext; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import uk.ac.shef.dcs.oak.sti.PlaceHolder; +import uk.ac.shef.dcs.oak.sti.rep.LTable; +import uk.ac.shef.dcs.oak.sti.rep.LTableColumnHeader; +import uk.ac.shef.dcs.oak.sti.rep.LTableContentCell; + +/** + * Parse csv file. + * //TODO specify delimiter automatically - now it has to be manually tuned. - check first row, try to detect - how many times there is ",", ";". + * //not now, as it is ";" + * //TODO detect automatically the header - so far we assume header is there + * //not now, as there is always header + * + * @author Škoda Petr + */ +public class ParserCsv implements Parser { + + private static final Logger log = LoggerFactory.getLogger(ParserCsv.class); + + private final ParserCsvConfig config; + + public ParserCsv(ParserCsvConfig config) { + this.config = config; + } + + @Override + public LTable parse(File inFile) throws ParseFailed, NoCSVDataException { + + log.debug("Starting parsing file: " + inFile.getName()); + LTable resultingTable = null; + + final CsvPreference csvPreference; + // We will use quates only if they are provided + if (config.quoteChar == null || config.quoteChar.isEmpty()) { + // We do not use quates. + log.info("We do not use quotes."); + final QuoteMode customQuoteMode = new QuoteMode() { + @Override + public boolean quotesRequired(String csvColumn, CsvContext context, CsvPreference preference) { + return false; + } + }; + // Quate char is never used. + csvPreference = new CsvPreference.Builder(' ', config.delimiterChar.charAt(0), + "\\n").useQuoteMode(customQuoteMode).build(); + + } else { + csvPreference = new CsvPreference.Builder( + config.quoteChar.charAt(0), + config.delimiterChar.charAt(0), + "\\n").build(); + } + + //try to detect encoding + + //Charset decoder 1 + TestDetector td = new TestDetector(); + String encoding = td.detect(inFile); + Charset charset = Charset.forName(encoding); + // Charset charset = Charset.forName("ISO-8859-1"); + + //Charset decoder 2 + // String[] charsetsToBeTested = { "UTF-8", "ISO-8859-1", "ASCII" }; + // CharsetDetector cd = new CharsetDetector(); + // Charset charset = cd.detectCharset(inFile, charsetsToBeTested); + + if (charset != null) { + log.info("Charset is: " + charset.toString()); + + } else { + log.error("Unrecognized charset."); + } + + try { + + //get number of columns/rows + + FileInputStream fileInputStreamStat = new FileInputStream(inFile); + + InputStreamReader inputStreamReaderStat = getInputStream(fileInputStreamStat, charset); + + BufferedReader bufferedReaderStat = new BufferedReader(inputStreamReaderStat); + + CsvListReader csvStatsListReader = new CsvListReader(bufferedReaderStat, csvPreference); + + log.debug("Analyzing the CSV file"); + + //get header and set cursor after header + List headerStat = null; + int nColumns = 0; + if (config.hasHeader) { + headerStat = Arrays.asList(csvStatsListReader.getHeader(true)); + nColumns = headerStat.size(); + } + + //count number of rows, columns + int nRows = 0; + List lines; + while ((lines = csvStatsListReader.read()) != null) { + nRows++; + if (lines.size() != nColumns) { + log.warn("Number of columns of row " + nRows + " is different then in the header!"); + nColumns = lines.size(); + } + + } + + log.info("Number of columns: " + nColumns); + log.info("Number of rows: " + nRows); + + if (config.rowLimit < nRows) { + nRows = config.rowLimit; + log.info("Number of processed rows (limit): " + nRows); + } + + FileInputStream fileInputStream = new FileInputStream(inFile); + + InputStreamReader inputStreamReader = getInputStream(fileInputStream, charset); + BufferedReader bufferedReader = new BufferedReader(inputStreamReader); + + CsvListReader csvListReader = new CsvListReader(bufferedReader, csvPreference); + + log.debug("Creating resulting table"); + //prepare the target table + resultingTable = new LTable(String.valueOf(inFile.getName().hashCode()), inFile.getName(), nRows, nColumns); + resultingTable.setEncoding(charset); + + // + // ignore initial ? lines + // + for (int i = 0; i < config.numberOfStartLinesToIgnore; ++i) { + bufferedReader.readLine(); + } + // + // get header + // + List header; + if (config.hasHeader) { + + header = Arrays.asList(csvListReader.getHeader(true)); + + for (int c = 0; c < header.size(); c++) { + String headerCell = header.get(c); + //set headers + LTableColumnHeader h = new LTableColumnHeader(headerCell); + resultingTable.setColumnHeader(c, h); + } + + } else { + + header = null; + + for (int c = 0; c < nColumns; c++) { + //set dummy headers TODO number of columns + LTableColumnHeader h = new LTableColumnHeader(PlaceHolder.TABLE_HEADER_UNKNOWN.getValue()); + resultingTable.setColumnHeader(c, h); + } + + } + + // + // read rows and parse + // + int rowNumPerFile = 0; + List row = csvListReader.read(); + if (row == null) { + // no data + log.warn("No data found!"); + throw new NoCSVDataException("No data"); + } + + // configure parser + // TableToRdfConfigurator.configure(tableToRdf, header, (List) row, 0); + // initial checks + + // if (header != null && header.size() != row.size()) { + // throw new ParseFailed("Diff number of cells in header (" + // + header.size() + ") and data (" + data.size() + ")"); + // } + + if (config.rowLimit == null) { + log.debug("Row limit: not used"); + } else { + log.debug("Row limit: {}", config.rowLimit); + } + while (row != null && (config.rowLimit == null || rowNumPerFile < config.rowLimit)) { + + log.debug("Row: " + row); + addRow(resultingTable, (List) row, rowNumPerFile); + // read next row + // rowNumber++; + rowNumPerFile++; + row = csvListReader.read(); + // log + if ((rowNumPerFile % 1000) == 0) { + log.debug("Row number {} processed.", rowNumPerFile); + } + } + + //resultingTable.setNumRows(rowNumPerFile); + + } catch (IOException ex) { + throw new ParseFailed("Parse of '" + inFile.toString() + "' failed", ex); + } catch (SuperCsvException ex) { + // here's what you're after! + log.error(ex.getLocalizedMessage()); + CsvContext context = ex.getCsvContext(); + log.warn(String.format( + "Something went wrong on lineNo=%s, rowNo=%s, colNo=%s", + context.getLineNumber(), + context.getRowNumber(), + context.getColumnNumber())); + } + + return resultingTable; + + } + + private void addRow(LTable resultingTable, List row, int rowNumber) { + // + // // + // // trim string values + // // + // if (config.trimString) { + // List newRow = new ArrayList<>(row.size()); + // for (Object item : row) { + // if (item instanceof String) { + // final String itemAsString = (String) item; + // newRow.add(itemAsString.trim()); + // } else { + // newRow.add(item); + // } + // } + // row = newRow; + // } + + int c = 0; + for (Object item : row) { + if (item instanceof String) { + final String itemAsString = (String) item; + LTableContentCell cell = new LTableContentCell(itemAsString); + cell.setText(itemAsString); + log.debug("About to store cell " + item + " under: " + rowNumber + " " + c); + resultingTable.setContentCell(rowNumber, c, cell); + c++; + } + else { + log.debug("Cell item " + item + " is not String, set to empty String"); + LTableContentCell cell = new LTableContentCell(""); + resultingTable.setContentCell(rowNumber, c, cell); + c++; + } + + } + + } + + // public LTable create(String tableId, String sourceId, LTableContext... contexts) { + // LTable table = new LTable(tableId, sourceId, preTable.rows() - 1, preTable.columns()); + // // for (LTableContext ctx : contexts) + // // table.addContext(ctx); + // + // // //firstly add the header row + // // for (int c = 0; c < preTable.columns(); c++) { + // // Object o = preTable.get(0, c); + // // if (o == null) { //a null value will be inserted by TableHODetector if no user defined header was found + // // //todo: header column type + // // LTableColumnHeader header = new LTableColumnHeader(PlaceHolder.TABLE_HEADER_UNKNOWN.getValue()); + // // table.setColumnHeader(c, header); + // // + // // } else { + // // //todo: header column type + // // Node e = (Node) o; + // // String text = e.getTextContent(); + // // String xPath = DomUtils.getXPathForNode(e); + // // + // // LTableColumnHeader header = new LTableColumnHeader(text); + // // header.setHeaderXPath(xPath); + // // table.setColumnHeader(c, header); + // // } + // // } + // + // //then go thru each other rows + // for (int r = 1; r < preTable.rows(); r++) { + // for (int c = 0; c < preTable.columns(); c++) { + // //get url + // Node e = (Node) preTable.get(r, c); + // String text = ""; + // String xPath = ""; + // if (c == 0) { + // NodeList nl = e.getChildNodes(); + // for (int i = 0; i < nl.getLength(); i++) { + // Node an = nl.item(i); + // if (an.getNodeName().equalsIgnoreCase("A")) { + // String link = an.getAttributes().getNamedItem("href").getTextContent(); + // text = "http://www.imdb.com" + link; + // xPath = DomUtils.getXPathForNode(an); + // break; + // } + // } + // } else { + // e = (Node) preTable.get(r, c); + // text = e.getTextContent().trim(); + // xPath = DomUtils.getXPathForNode(e); + // } + // + // LTableContentCell cell = new LTableContentCell(text); + // cell.setText(text); + // + // table.setContentCell(r - 1, c, cell); + // + // //handle the table row once + // if (c == 0 && xPath != null) { + // String rowXPath = XPathUtils.trimXPathLastTag("TR", xPath); + // table.getRowXPaths().put(r, rowXPath); + // } + // } + // } + // + // if (table.getRowXPaths().size() > 0) { + // String rowXPath = table.getRowXPaths().get(0); + // if (rowXPath == null && table.getRowXPaths().size() > 1) + // rowXPath = table.getRowXPaths().get(1); + // if (rowXPath == null) { + // } + // //System.out.println(); + // else { + // String tableXPath = XPathUtils.trimXPathLastTag("TABLE", rowXPath); + // table.setTableXPath(tableXPath); + // } + // } + // + // return table; + // } + + /** + * Create {@link InputStreamReader}. If "UTF-8" as encoding is given then {@link BOMInputStream} is used + * as intermedian between given fileInputStream and output {@link InputStreamReader} to remove possible + * BOM mark at the start of "UTF" files. + * + * @param fileInputStream + * @return + * @throws UnsupportedEncodingException + */ + private InputStreamReader getInputStream(FileInputStream fileInputStream, Charset charset) throws UnsupportedEncodingException { + if (charset.toString().compareToIgnoreCase("UTF-8") == 0) { + return new InputStreamReader(new BOMInputStream(fileInputStream, false), charset); + } else { + return new InputStreamReader(fileInputStream, charset); + } + } + + /** + * Create {@link InputStreamReader}. If "UTF-8" as encoding is given then {@link BOMInputStream} is used + * as intermedian between given fileInputStream and output {@link InputStreamReader} to remove possible + * BOM mark at the start of "UTF" files. + * + * @param fileInputStream + * @return + * @throws UnsupportedEncodingException + */ + // private InputStreamReader getInputStream(FileInputStream fileInputStream) throws UnsupportedEncodingException { + // if (config.encoding.compareToIgnoreCase("UTF-8") == 0) { + // return new InputStreamReader(new BOMInputStream(fileInputStream, false), config.encoding); + // } else { + // return new InputStreamReader(fileInputStream, config.encoding); + // } + // } + +} diff --git a/core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/ParserCsvConfig.java b/core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/ParserCsvConfig.java new file mode 100644 index 00000000..46f1c22f --- /dev/null +++ b/core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/ParserCsvConfig.java @@ -0,0 +1,72 @@ +package uk.ac.shef.dcs.oak.sti.xtractor.csv; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Configuration for {@link ParserCsv}. + * + * @author Škoda Petr + */ +public class ParserCsvConfig { + + private static final Logger LOG = LoggerFactory.getLogger( + ParserCsvConfig.class); + + String quoteChar = "\""; + + String delimiterChar = ";"; + + // String encoding = "UTF-8"; + + // String encoding = "ISO-8859-1"; + + int numberOfStartLinesToIgnore = 0; + + Integer rowLimit = 1000; + + boolean hasHeader = true; + + // boolean checkStaticRowCounter = ; + + public ParserCsvConfig() { + + } + + public ParserCsvConfig(String quoteChar, String delimiterChar, + String encoding, Integer numberOfStartLinesToIgnore, + Integer rowLimit, boolean hasHeader, boolean checkStaticRowCounter) { + if (quoteChar == null) { + this.quoteChar = "\""; + LOG.warn("Property quoteChar is not set, '{}' is used as default.", + this.quoteChar); + } else { + this.quoteChar = quoteChar; + } + if (delimiterChar == null) { + this.delimiterChar = ","; + LOG.warn( + "Property delimiterChar is not set, '{}' is used as default.", + this.delimiterChar); + } else { + this.delimiterChar = delimiterChar; + } + // if (encoding == null) { + // this.encoding = "UTF-8"; + // LOG.warn("Property encoding is not set, '{}' is used as default.", + // this.encoding); + // } else { + // this.encoding = encoding; + // LOG.info("Encoding is: " + encoding); + // } + if (numberOfStartLinesToIgnore == null) { + this.numberOfStartLinesToIgnore = 0; + } else { + this.numberOfStartLinesToIgnore = numberOfStartLinesToIgnore; + } + this.rowLimit = rowLimit; + this.hasHeader = hasHeader; + // this.checkStaticRowCounter = checkStaticRowCounter; + } + +} diff --git a/core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/TableXtractorCSV.java b/core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/TableXtractorCSV.java new file mode 100644 index 00000000..f6507f24 --- /dev/null +++ b/core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/TableXtractorCSV.java @@ -0,0 +1,82 @@ +package uk.ac.shef.dcs.oak.sti.xtractor.csv; + +import org.apache.any23.extractor.html.DomUtils; +import org.apache.any23.extractor.html.TagSoupParser; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import uk.ac.shef.dcs.oak.sti.STIException; +import uk.ac.shef.dcs.oak.sti.rep.LTable; +import uk.ac.shef.dcs.oak.sti.rep.LTableContext; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; +import uk.ac.shef.dcs.oak.sti.experiment.TestTableInterpretation_CSV; +import uk.ac.shef.dcs.oak.sti.xtractor.Table_ContextExtractor_IMDB; + +/** + * TODO: Detect header? + */ +public class TableXtractorCSV { + + private static final Logger log = Logger.getLogger(TableXtractorCSV.class.getName()); + + public TableXtractorCSV() { + + } + + public List extract(File file, String sourceId) { + List rs = new ArrayList(); + + ParserCsvConfig config = new ParserCsvConfig(); + Parser csvParser = new ParserCsv(config); + try { + LTable tableParsed = csvParser.parse(file); + rs.add(tableParsed); + } catch (ParseFailed ex) { + log.severe(ex.getLocalizedMessage()); + } catch (NoCSVDataException ex) { + log.warning(ex.getLocalizedMessage()); + } + + // + // parser = new TagSoupParser(new ByteArrayInputStream(input.getBytes()), sourceId, "UTF-8"); + // Document doc = null; + // try { + // doc = parser.getDOM(); + // } catch (IOException e) { + // return rs; + // } + // + // List tables = DomUtils.findAll(doc, "//TABLE[@class='cast_list']"); + // List contexts = new ArrayList(); + // try { + // contexts = Table_ContextExtractor_IMDB.extract_tripleContexts(sourceId, doc); + // } catch (STIException e) { + // e.printStackTrace(); + // } + // int tableCount = 0; + // for (Node n : tables) { + // tableCount++; + // + // LTableContext[] contexts_array = new LTableContext[contexts.size()]; + // for (int i = 0; i < contexts.size(); i++) + // contexts_array[i] = contexts.get(i); + // LTable table = extractTable(n, String.valueOf(tableCount), + // sourceId, contexts_array); + // if (table != null) + // rs.add(table); + // + // } + return rs; + } + + private LTable extractTable(Node n, String valueOf, String sourceId, LTableContext[] contexts_array) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + +} diff --git a/core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/TestDetector.java b/core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/TestDetector.java new file mode 100644 index 00000000..fcb4db64 --- /dev/null +++ b/core/src/main/java/uk/ac/shef/dcs/oak/sti/xtractor/csv/TestDetector.java @@ -0,0 +1,55 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package uk.ac.shef.dcs.oak.sti.xtractor.csv; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.mozilla.universalchardet.UniversalDetector; + +public class TestDetector { + public String detect(File f) { + byte[] buf = new byte[4096]; + + java.io.FileInputStream fis = null; + try { + fis = new java.io.FileInputStream(f); + } catch (FileNotFoundException ex) { + Logger.getLogger(TestDetector.class.getName()).log(Level.SEVERE, null, ex); + } + + // (1) + UniversalDetector detector = new UniversalDetector(null); + + // (2) + int nread; + try { + while ((nread = fis.read(buf)) > 0 && !detector.isDone()) { + detector.handleData(buf, 0, nread); + } + } catch (IOException ex) { + Logger.getLogger(TestDetector.class.getName()).log(Level.SEVERE, null, ex); + } + + // (3) + detector.dataEnd(); + + // (4) + String encoding = detector.getDetectedCharset(); + if (encoding != null) { + System.out.println("Detected encoding = " + encoding); + } else { + System.out.println("No encoding detected."); + } + + // (5) + detector.reset(); + return encoding; + } +} diff --git a/core/target/maven-archiver/pom.properties b/core/target/maven-archiver/pom.properties index 7502edb6..0223d4ac 100644 --- a/core/target/maven-archiver/pom.properties +++ b/core/target/maven-archiver/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven -#Wed Nov 28 11:46:08 GMT 2012 +#Thu Jan 28 12:44:21 CET 2016 version=1.0 -groupId=uk.ac.shef.oak -artifactId=lodie-core +groupId=uk.ac.shef.dcs.oak +artifactId=sti diff --git a/simmetrics-core/pom.xml b/simmetrics-core/pom.xml index baed1fc4..5b0b66ae 100644 --- a/simmetrics-core/pom.xml +++ b/simmetrics-core/pom.xml @@ -4,8 +4,20 @@ com.github.mpkorstanje simmetrics-core 3.0.1 - - + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.7 + 1.7 + + + + + junit junit @@ -25,11 +37,13 @@ 1.10 - + + org.mockito mockito-core 1.10.19 test + diff --git a/triplesearch/target/maven-archiver/pom.properties b/triplesearch/target/maven-archiver/pom.properties index b4767a3b..39504a6d 100644 --- a/triplesearch/target/maven-archiver/pom.properties +++ b/triplesearch/target/maven-archiver/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven -#Wed Nov 28 11:45:02 GMT 2012 +#Wed Jan 27 16:46:00 CET 2016 version=1.0 -groupId=uk.ac.shef.oak -artifactId=triplesearch +groupId=uk.ac.shef.dcs.oak +artifactId=kbsearch diff --git a/triplesearch/target/triplesearch-1.0.jar b/triplesearch/target/triplesearch-1.0.jar deleted file mode 100644 index 9cdeb11b5e8291ee071a401c404409c073790a01..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11283 zcmb_?1zeO{^FPuhAl=>Ft@P5pba%tT(kV!HNq46bB8}3Gq@Xl{(kLJ)@Pmu@s@!<* z`+xuEv&$}@otf`E=bUGr@0l4TStw{kh?@~&A1U(Nm+yZNu0Q1^fFexN3IGtymCt@?argU%2h)}_hRZ(@$q_4yzL_$yCP{H!X7*sj9{zZlZEc1FL z%)=v$FSR=itr}DBd7^DBjJYT57XY9|w?!A?ch?{wLalzi0;p@(Tx|aE{m%lhw*p2c z{~&|(hYZ-#%={k&QGXRQH39#FFvg#S9gP0TRnos!aCWi+*_wgPjGRm?{{fESUuc7^ z>`kpq%#1)*|6qvbUl_Xe=?^3DzpYERW5l@&JOso5Is}C9zcBKXH>$Uei6}`cIXSp{ zFq_yKfx(#?r(PJ-SPxML@yVdsjB9DhYQ#brO)#-B$l)=E(2I@3>_GP^he@M88+rhU zqmXywU);Bb;D`SjuR<@jL>4+WX6|HYRtY@UNY$5~#x z`&m~PuVS7<%>?>cYLdn>#}pjemT}sysy5ovnQc+fO|wP7cV)(VSp34opDNegAuyaPWlvNzyV_)?B@Ge_P%A*`N%_VUt|I-R*({=SJ z*8w(}wSe?Z4Vm-F0`aZoi%+$HF)q9E0y65+hsi8Z)+?o@nNy$n{Oi7c>=_8=h{Iou z=ht){Q0$Y2KStyvA>bXYdl-2>T13WNC71gWna8DqrFLvr~oX-|Z*8o}mlQ7{LlKIV_A zXj{0!G(b#VpXC1W*;z-glKNmtfU5!Yx#Q#AB;@+VDI)GV;k@aHGm{60>c^hjHERRi zEPcQ}cxUR54xwBc`_2*i(X}c#I^`y4HEj0VwY6)?V$3cyA7#n_Tt&GCq$&p8MueR? zu&!0-A4hT8aoD=L9+@=QHc&tgV%#r3q0E{DSp#ZkEKY`3=%yH*tnmRPO>2@dOPn>3 zvbNX;F?L#V#!nr~%c;G&c#hW*6D-ZRLXMISJUZE&e1a7?@JHag%Dh_DtA|3X6#%U} zta6c-ygCnsWIdo^BGFOwDg_v;$`C)PS32{f>R{_C=WvZFiGP$viN;)^da+#;3m0~d zKk$MzVYJn(HixuXlTzptMat`B>0E0dpZ_xe&Ugit!7vKKO8EnCc>ue(A)klaK(__O z3BM@&8lr1|Y*HIuJ6L9@?jaGG;G6R|4g&kOf_pRhUusmPWKZqyvjFpbZEQ^01t9If z)QpSwfPe*uu*R078W+AX&*n%pO~Zw`?5CIliM@s7dkW?X+b=Pz8&laq@pxymRnr`& zk7D#Eo=QkrH0B7c$}I&wbkck0Av~G#IP8en0(tXH7~BPpQpCZ{;@&1 z(0)%(g~nwvrTP7dQLUErX_sC*3#H>LOsS!W28{SdhLbweT^{EuHZ>PkdobKv{~RgV zx{8?zIO=eKbkCR77JV7AZ~72q-n4uAJxXp9VXQ?Ud9k%5w+0%Lc9Jh_1jh~fv;>m- zEuLHRM+=)#!`>YX%)SLNsL@*$%P6q#zQ!`!KqNjaUB~q}5R{OAYx_#iwWjBuYFlga z8+R#(#Nx3YNpFlRNTcO}WWfSO(Y9}=dVTNmb&K;g6DvqFA_0#&;!%0^9%K6^m*m@^ zy>5j!VM=ns{?hfJo4qiJh16i`UY7Rj#VVDlcfzU}Y42%gpK(?m7Wl|JQQjNps8I4M zZ@^xvP_w#XVUj+1LQa&@vza@xo@S%jEaKBVSxKWe?b&=EZsWr;zK|6xP6p31?Wsq=!ckmy{%Q@0^jY20=h=3=3aG*E`;=6Q zj>poz+3JFsD$B#u?gO{4bHV<&7eq?=6og!0uJQ(?@$lYEzy+}z{#Qb(qSQH;{fx+w z8P2m{{$f_rQ-0<4WE8uUj){=sID#~QZ;1_JCzd8wWPb)YgdSIs$Dlh;6U@jP1b)Jv z-^QMZa(PgD)wj&SR&yTJFBZ>9N8GB^USHrk;AHZI63F*fQM+wtq8{n^vrT+>?ach|C%h)LaSs#X?`c|$;sJWOV+f_F#k>JCc8+pK z)d!pANlP-E#F>81?C+#^T-e&zvo}i6R31#3DvQm|A47^o&B1PYJ)aD}Z?>i|uBrseZG?Zm?KSoE&=;#lQvfNAzVLyRfEiDlA(Dj!8`QPdA+L zYb@q`%gW2`)6)E-;fk$ z#|u5`2{Y&Ahbzs2yIVlpSH$=3NeOCbVCrkAFM9g8H3m-cp*8 z)JW-#YbsN8@4u!rz~5+_guAnok%_Z|(=DZW8r!VUDU2quml8|0OosRf5+6W1W+;wB zFDsQ2Z~l(4pSs6p2WoAW_5|V)VzoXJBEDgnz;h0bgUc^xuuI5rkTA>a&$Q@|WG}kF zYwrfQ;4GQ|UQC(VH9R|Wv`hk>$BmC>p=s2r6b!|Ab^CGpqik`!&l|?+(E^F7;Xn00 zt$AYr@A|%%8kE`Y#z&`Eh8)_?S^7Yx!}+Ch6H?DheM8ZPli_7Un;hRgbm}^-7wqE2 z2&h-wPHGoBwjT33&+MFK7E`F_`Om%-O=JmBqrDu3D|~Ke5(!CemJeLKwguTNy=PW; zh4AY%I;Hh!SY1!yCrAhgiT{on-kC-bdk=Pw+qo=MkynIdL(60)VF=BmEs?ZeY6r*( z!ndOdDGtQ2gf6EC%>>bjex7fozC5aj)|hc8HeVk z-p*3ahN19$m;(PyuMeH~w3*Z2Ru)#J9-+Yc>m&a|EnZ9ysdnpox|(E4ho+>@hHOcJ zG55Via#n*fPJN0@BXLZ%W6Z>JK3p86$wNMq!i9`V>+O6u{h& zA5YMttn}m{o^Up>pCl6=p3qu?Luow&9@Sn!o>~wv=L~B*VZ0s1j)&F^A@}?y)F+@+ z)2O4qimOG_v$~Nk`i>qLzb;C)U}r+ftXpmQ3FFtbZ2i!eb`A{zk$-(^Qv9FR@;m7l zGcvI>yJr5ktJx*(a6KlVg&K-bOkOVC=F)k__@PboGHhug(shwpxbGm9x z>~_!m{f@}w=;X`C3qTfY2MMM~_9w@e_pSnYM%+K;v{|^_L({rpygDYGKb-nhaE1ib407lEEGD?%=L-iqp|$n-cA~J}VSC6;@DD6P?cF z+0mETrD(a)RF=Rza`Ms*$j)_D&{9H|kjR#wOH2Jw#zfW^>+OOD+dpfHJ3!bG-5VV` z&mGlWh$$Azk`$3v_72%LBT3r|{0<~q&1nBVEmtQ$t#Am_BMU`-BA2YLWFzh2&{9Nq zG43}jiZ`7llKFwK!D&0^MG>ar0E{%ew1c^Exh#@*oauE~&BlCyqVjf-Zg6CNLH3yQ zBW1c_5Lo3k`=kZ38l3`N5%t?FR^HXP223v^lCI*8&$;pdBx~r1l1S^o?ul9U=mtd^ zQz`f{iJbsIpaUW7-Wq}^8LkJ@*@qA0kmznZ9EaWPWycu%}m|1Wk)HQze%~hq#KwOJa zn&s`~0n3m*(~M4!U_e3wqyfkzJ{vfsr4TJg5_m;SL&&gj4*?3X68FLq z$pp=rw14!-iGe-%GxHQgHU2?3m)$z|beO3sqpwh{p1oF6=p)&M#=r*%$p)4Wce5fH zq$0$*>(KQcVlP$_b>L2|LX}IVcqsO8DVe})2Fg9wtDZ;nQjP^ZLG;vVQ9Cp#vPwa> zXD6I3buP@qI+#OV#ugihP@9ysWhfJ$uLA4@7)u_&*5@@DNg@qE#%Q;$=~HN{+oq>` zvPU8>;C%I#(1 zCrl}NXYZ*H`K3)vM4Xh3&`z5_KEK{pO9^YJqTWLtk$DrTON-CvZN1fIl3b#%L_YO7 zwrofVmt(*1+&q>dH;tMvcQ2p4BHURi&Tsz2$6wFHiNTf=m7^01WN5F?zo*=5Tw5OF z1{x8WEF?14hUG|LP z5({}c=Gl@p`yo;ELx2V43u5npw_Lh!D#;Scvo*Wz9O;__n#)rz8{O`sg5zSJv!L%! z@Ql`n$M|;1VeR@78_N3^ElvCRiRBOxTQ2)S?OY@gE`c*1$)!R&DRDIxM+2+^*~4M! z@27!N+C97hTP&b^1}o%QDj1po^jG9Ti&hsjRuM~cj{7bq47>y>#jz6t5SPLT{EclW zuiAxES>GtteuJilF^5k!YNwtr)~Q)z(hAz{Gwqzx1$CU2V)S(T{gLImr5+JlM9+y} zt`l0S$nSU|ymi;DzQ3H%M&;L8xP(sVdKk(uRg|ag%ewOYE$% z^2Lw!%kgvMj-I!c$M~!j?j)eL9a1w6mhFJA#ID2*n$$_&?{cI*)}=R|wtg#PKJv)R z?_A*Ab$`o1XaNpHm`zt=%xlo}bX9x2KZ2k?<0B=LFT=)r&oQ*SNKUE(}@lW$$sj62-@e;Ab1m zP_h#$EWo62haT40cm8nM+{(oDm8U_NVjswMc{^NP2AxMXQL@>@qg(W-9H7#2)0+hP z&_Zdb@d7B+6#^fKBm@A0o9YgtaiR0_@R*R9_?FjS_TASotYvnSjfQio!$z*82X0fJ zN7{#1s~7=hFvgk0C{3*9QdVCwPq(phE+ybbUnM6LO@#HcLh_avlWbDPq#(j@?N^FP z*q!dghO@ekDbKekB(iLGeGp>^B(DtJ#};!C%-0GEw;RV+=m#Zep?;~Um!e|Vcb0u- zKN>9iae2%`9j;M}3n|-s4Nz6_?n~RQuyZh)YI?UF<&aA$)9f&JUsPTDn z#M4l00eH9qtrpDGCp_e_oUwFNk;9thfqA53DTVB3&`uW|T!)eMNg+!CuSc2?`GeLW z!@3FYXC*W&I%G7770%82tx&V34$APjlP6yW*Q3+l2Z>~;vvyTkTttT(WyHzvBBp!o zEY^(h?+hX=Gmg;VQk@Jp(`WU1&>JR{Mdg+Te15H&CuX3@Q(1$l4d#yIWT$5~mP>k7 ziNmd(Jf*^gTdd!<>n!_ZkiI6xu*7wJX?0J^yH;f7y?H8R8cn6m%9IhC^=wk*5>;?3 zLDWd1GX>2y{-~|YsTul#*Fe~p>vWp2eO7aI231CiRb#baHU?X9@r+4#_*@}w>V=Wq za#IE*3kRn|x0{M}OW6t+2w$j06O%fsE2|R76XqRHhmc#^*Khf@L7l2g10?2|HNW&u zQO;P!e*|H2&xCx-~g}($EN-+5xr$)n!C|+M$ z!H4QiCYwyKZ5j`7NQ0kTZ)WtturJ9|uTK?)PZ6_Pd}j5{OV~q|XStc=Gl=+zHo4`M zs0p0F$R(Z;bFNl%Jod_^lR;Y!g+az^=9^yIV^R}>HcxHkGbX5%dc~ecn~Wp9-*817 zt;ZJu_D4iq_5%BD2EE1$VJ7PbBA&jz7r!e)WHs$|<%+vnOxBS!S_Mz#PSF1Pc;>v) z0>5xEwivw~BMbV)`;d#aMv-{Zhv`j8jyVkOIClHRt>x#;{L^UKp}34H*EkEvtGQQe^(J*lOz3)FC;Js){e;v8XYFdQN~UpyY! zr6O!@2uPS1boY#ewrhXBM5x!nar~KZo^Pt&kxAPJl>+${={!j!Z1QK()p2zFZB(C- z)`<1U;N6h6u1hT4RQ>iz=fKC$q$@R&SZk5LfZrhQPmC$$@Zckk*EhN0@$BU)1<{4c zeyuq^x-)3ZYY4q8JF5rG8yf{JA{+`zd7xC+0%>OR}@%P;L zcXq3)B%-1$cgt-vfwL+YB4`iqOJj@1rsw43ET@48l*OsA)v&1)>FjNm%R9{}kKr$t0gES=Q#^c>mXm~VaMdv$_fh(Lv87r1sJB_$cC_Ei~} zp=9YnnfJQViyp`hDjSZf(tEYSKd|6i+pPLBmi&--0E13&gCw-_LTpVuaL8ubEuTx& zE4M*Xs&XrQAde`MuON=>Fj3FIuBXlit0mz)i~KOTj-vG;UW54}XHi}m0lNCY6^2e& ztPLU0QDCa*DLF8G?*y)}JZVKA+XuI5R1w$BSsu9c?YJvAf+YB4<#m!#uSUdc8yAcP5A_8`Wd1LON|% z{+u%s$P{8V1d`ZDsfHz>*JFCAW!xqDwBm~_Hk*Y}l2U`er5GF+o&-H>$w44$5cqW^ zZ&|P30|(@ja4`y!jxqn0nHR;V#@$?I3l3~>MrA@f?))Omw69dADJ^`iK!I)@~>gL2y)_daC#wf$F_C4eeCX;h4#_OqrwN4nT$olLS8$YG0U-xBL zFv}?QR6hG*FQQ81cnFSrzeS)1!t^G|uRD6;>MIJ(b>-~ib#aXGU+n1HGx+Tuj#AZ8 z#85`NRM7GKAZ3LlA(HdhxEUr%K$HQIRy4pEl5C77$u$?Lu5vypds*PhA5OjiS3a`s zEI$%F!VEJIA3MC8nwmMtvp95mzSqkFfuVWa-p#5jpi)<1{qd_0S2EXByla6v1E4V{ zy-B_QRkxuf!Arc% z7A1BCoIo_kKw;41KP8j;7Ud);{#>fiiB<|>7Ftqw2DgY8cFfBMY8zxME?kyW5&lTf zY~8x2T9*Tnua$h91ym51TgU$vk;@01eKdhEDc=^5(wR3C=qseJG}XY$2(DP7aw&N_ z=*cGO!^`H=Y5F0KPlL}~!lAuVr80g><9;1vPP&Yok>;@nL$<&nMHP{25=eY0W>~F^LVLhi)$B3Dx(-#5snqZ zJO@{B_;{0*&Lv?rUIkU!zGi%Bdw@Q(qg>)Ncr+P6$G}Og3Lb1%7#yJhkuZK9 z=#9WhTRD$8LBY|*_#Bq^Ii&<}Ws;cwh%O}?(rxcKO;^&^X-jYN=%cE-LvdraN6@NL%$qobMu{v02E z!}qiVzTJGB`}Zae}iszO%cUr(uo9d0TraLcO(p z2mDDDyUEO^)_$eY8p8+D1{?ZT&R5!=m3JQ@0m^fv!q@pP=j+Faz`wrXRDUb^O1PVt zft;-z?7u%lVuocpg)xKPOmdEC?qsVu77EOUKS6R--T+_*E>RbrTk&(7n5e`9eV8<0 za2`EIrCN{{gSiiH?#S_J0o;~){^j%tWeNElTL$^l0UZvpqPNGJUi}UVwl%8?bAP#l z(1+Qm?91jWXWa?4K#5$KC%LDjS2=E^oSCb6dx4-0#|02wThp(_2W=LyX=(516VnBtAGxExH zm#s=X!LKy}R@?!LS@I%4{=HbMjqKig)2ew(Vy}I`h9ohjzHiwBUda5EOBrYS&I0SW zrov~tI+?rukXz4FjS|Y_{c=Qmn95!+j{~d)IyFo30BAmC`Ee%cd@mKXKMgCm`DbQN z;`43cxwvg;D-UN3Smtqf8T=jz|J)35Q{4Zf8N$xU)y)2n`u3lNiT^C@V#91?!hF*~ z!2D~S|8CdCO{M-0&>h`d3UR084-bK+7AYcHC5_{My_KS`Q*iA6ogt8e9kaWgZC&DT zdDGy%a|Uj&#UxZznItC;wlPa`{O1X~5HM#(I?z|Gg-^{8a;P`6To*hn-WMB8SyCjQ z5@^%Bz{l1br*i`8PK(NibWfZ#wJ-u0%Oj`2tB+9a*Mhr;yf|`z9R&1{uqVi2FICS# zev&LwG|v6|^Ek4w1T<+iUp?jDUTBVPIX4}y?H;i?$0{MN3DQRIIMKi|n>%p9krbcq zd_Lvt?U|Bh%#R6dFm$Yv*~CwNV@0Joq<$zoSYw)@-OA3xrNaadS~2G(!^g&&-{^;V z8-V~Kfp!Se$`h;dRv%L*=M&P%cB!Y>4M;@9FnG%6N#Ri%82?=`rqRak`px&>FDS^#0c7UnY-I+%-(QXR zgcS{9^rCHr)JsYs+T|zK!F>*Z0N$`|N%P|0OAU7yItX{|7c3-hamazB#`G{hSB5i*xrp_5%ls@IT|+ zZkt;`zg}Gs(ZT{FgNJ2hg9n(a*u|>gqn(Pr>|mTJ`(=`e)@EVs$&vAg-?X z|Ezq6D*clqKS!#oE7$*M>vqNdpk2Q^`PanjcQ*_CU;TH6ztgZEj{h|e_+dYm;!iVp hXA*vK{KozdR-hyc^V^dS2LcD85)J}FiSowq{{gR?I0gU! From e74a5e5f695255e127008b631135465a1eb84cea Mon Sep 17 00:00:00 2001 From: Tomas Knap Date: Mon, 21 Mar 2016 15:05:42 +0100 Subject: [PATCH 002/211] Update README.md --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index ace28cb1..54e65a1b 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,29 @@ # sti Implementation of algorithms for semantic table implementation + +# To test TableMiner+ on top of HTML tables from IMDB: +- download the cache, and experimental datasets, from: http://staffwww.dcs.shef.ac.uk/people/Z.Zhang/resources/tableminerplus/data.tar.gz +- unpack data.tar.gz, then keep going to unpack contained archieves (only those related to IMDB data - cache-imdb, dataset-imdb) +- run uk.ac.shef.dcs.oak.sti.experiment.TestTableInterpretation_IMDB with the following parameters (if you use intellij, open the project folder /sti/core, it should load all the app configurations and that saves you lots of time) +uk.ac.shef.dcs.oak.sti.experiment.TestTableInterpretation_IMDB 1 2 3 4 5 6 +1: create the input folder which contains one HTML page from IMDB, e.g., http://www.imdb.com/title/tt0133093/ . Specify path to this folder as first param +2: create the output folder, specify the path to this folder as second param. +3: create freebase.properties file and introduce a path to it (see below for the structure fo the file) +4: the cache folder to save and re-use data gathered from freebase (taken from the unziped archive data.tar.gz): “.../cache/cache/tableminer_cache_imdb/solrindex_cache/zookeeper/solr" +5: nlp resources (taken from the unziped archive data.tar.gz): “…/sti/resources/nlp_resources" +6: just put “0”, meaning which webpage to start with (so that in case your program breaks half-way you can resume) +7: put “false”, which means do not learn relations across columns (imdb dataset has only 1 data column) + +# Freebase properties file structure +BING_API_KEYS=khkFliAQ0J5RBQeUWEWTOJ4afIF1t1hDTKivb3ExAhQ +FREEBASE_API_KEY=AIzaSyBgOUGvZTEzlkgks4S3Juj-JpI60acEfRs +FREEBASE_MAX_QUERY_PER_SECOND=10 +FREEBASE_MAX_QUERY_PER_DAY=100000 +FREEBASE_MQL_QUERY_URL=https://www.googleapis.com/freebase/v1/mqlread +FREEBASE_TOPIC_QUERY_URL=https://www.googleapis.com/freebase/v1/topic +FREEBASE_SEARCH_QUERY_URL=https://www.googleapis.com/freebase/v1/search +FREEBASE_HOMEPAGE=http://www.freebase.com +FREEBASE_LIMIT=1000 + +Note: Do not forget to change your API_KEY (you may get one) and, also BING_API_KEYS. For the latter, you can obtain one for free from https://datamarket.azure.com/dataset/bing/search. + From a4ec139790d79c2fda76559895c6b7e77f8a9c33 Mon Sep 17 00:00:00 2001 From: Tomas Knap Date: Mon, 21 Mar 2016 15:09:58 +0100 Subject: [PATCH 003/211] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 54e65a1b..9c18e92e 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ Implementation of algorithms for semantic table implementation # To test TableMiner+ on top of HTML tables from IMDB: - download the cache, and experimental datasets, from: http://staffwww.dcs.shef.ac.uk/people/Z.Zhang/resources/tableminerplus/data.tar.gz - unpack data.tar.gz, then keep going to unpack contained archieves (only those related to IMDB data - cache-imdb, dataset-imdb) +- build (mvn clean install) all the packages the sti/core depends on, which are required to run the program - run uk.ac.shef.dcs.oak.sti.experiment.TestTableInterpretation_IMDB with the following parameters (if you use intellij, open the project folder /sti/core, it should load all the app configurations and that saves you lots of time) uk.ac.shef.dcs.oak.sti.experiment.TestTableInterpretation_IMDB 1 2 3 4 5 6 1: create the input folder which contains one HTML page from IMDB, e.g., http://www.imdb.com/title/tt0133093/ . Specify path to this folder as first param From 674b39e219be80828a24997e849769657357af4c Mon Sep 17 00:00:00 2001 From: Tomas Knap Date: Wed, 23 Mar 2016 13:55:03 +0100 Subject: [PATCH 004/211] Update README.md --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 9c18e92e..b28bf16e 100644 --- a/README.md +++ b/README.md @@ -7,13 +7,13 @@ Implementation of algorithms for semantic table implementation - build (mvn clean install) all the packages the sti/core depends on, which are required to run the program - run uk.ac.shef.dcs.oak.sti.experiment.TestTableInterpretation_IMDB with the following parameters (if you use intellij, open the project folder /sti/core, it should load all the app configurations and that saves you lots of time) uk.ac.shef.dcs.oak.sti.experiment.TestTableInterpretation_IMDB 1 2 3 4 5 6 -1: create the input folder which contains one HTML page from IMDB, e.g., http://www.imdb.com/title/tt0133093/ . Specify path to this folder as first param -2: create the output folder, specify the path to this folder as second param. -3: create freebase.properties file and introduce a path to it (see below for the structure fo the file) -4: the cache folder to save and re-use data gathered from freebase (taken from the unziped archive data.tar.gz): “.../cache/cache/tableminer_cache_imdb/solrindex_cache/zookeeper/solr" -5: nlp resources (taken from the unziped archive data.tar.gz): “…/sti/resources/nlp_resources" -6: just put “0”, meaning which webpage to start with (so that in case your program breaks half-way you can resume) -7: put “false”, which means do not learn relations across columns (imdb dataset has only 1 data column) + 1. create the input folder which contains one HTML page from IMDB, e.g., http://www.imdb.com/title/tt0133093/ . Specify path to this folder as first param + 2. create the output folder, specify the path to this folder as second param. + 3. create freebase.properties file and introduce a path to it (see below for the structure fo the file) + 4. the cache folder to save and re-use data gathered from freebase (taken from the unziped archive data.tar.gz): “.../cache/cache/tableminer_cache_imdb/solrindex_cache/zookeeper/solr" + 5. nlp resources (taken from the unziped archive data.tar.gz): “…/sti/resources/nlp_resources" + 6. just put “0”, meaning which webpage to start with (so that in case your program breaks half-way you can resume) + 7. put “false”, which means do not learn relations across columns (imdb dataset has only 1 data column) # Freebase properties file structure BING_API_KEYS=khkFliAQ0J5RBQeUWEWTOJ4afIF1t1hDTKivb3ExAhQ From 1c55e9ea765947de04200fd39adf8d12a58b2829 Mon Sep 17 00:00:00 2001 From: brodecva Date: Fri, 13 May 2016 01:06:22 +0200 Subject: [PATCH 005/211] Fixes to enable the test case run Added archive Aduna repository to any23-sti and core pom.xml files. Fixed mvninstall.bat by adding call command before every mvn-install call to prevent premature finish of the script execution. Renaming of declared package in files in "todo" package to lower case. Solr core dependencies now exclude jdktools.jar (casued pom.xml errors in Eclipse IDE). Forgotten index directories content in solr purged. Added runtime javax.json dependency. --- .gitignore | 55 ++++++++ any23-sti/pom.xml | 13 +- common-util/pom.xml | 123 +++++++++--------- core/pom.xml | 14 ++ .../FreebaseTypeGranularityPopulator.java | 2 +- .../sti/todo/TAnnotationKeyFileReader.java | 2 +- .../uk/ac/shef/dcs/sti/todo/TestGRMM.java | 2 +- .../sti/todo/TestSubjectColumnDetector.java | 2 +- .../dcs/sti/todo/evaluation/DataStats.java | 2 +- ...bleSize_NameLength_Analysis_LimayeNew.java | 2 +- ...TableSize_NameLength_Analysis_MB_IMDB.java | 2 +- ...bleSize_NameLength_Anaylsis_LimayeOld.java | 2 +- .../evaluation/Evaluator_AllInOne_IMDB.java | 2 +- .../evaluation/Evaluator_AllInOne_Limaye.java | 2 +- .../evaluation/Evaluator_AllInOne_MB.java | 2 +- .../todo/evaluation/Evaluator_ClassOnly.java | 4 +- .../Evaluator_ClassOnly_IMDB_MusicBrainz.java | 4 +- .../todo/evaluation/Evaluator_EntityOnly.java | 6 +- ...Classification_ignoreUpdateIterations.java | 4 +- .../Evaluator_ISWC_Helper_ClassOnly.java | 4 +- .../Evaluator_Limaye_Entity_Only.java | 2 +- .../evaluation/Evaluator_RelationOnly.java | 6 +- ...aluator_RelationOnly_IMDB_MusicBrainz.java | 4 +- .../KeyFileGenerator_from_HTMLOutput.java | 2 +- ...t_Entity_Discrepancy_Analysis_Generic.java | 4 +- ...ty_Discrepancy_btw_Baseline_Tm_Finder.java | 4 +- .../shef/dcs/sti/todo/gs/GSBuilder_IMDB.java | 2 +- .../dcs/sti/todo/gs/GSBuilder_Limaye.java | 2 +- .../todo/gs/GSBuilder_Limaye_Wikitables.java | 2 +- ...Builder_Limaye_Wikitables_consolidate.java | 2 +- .../GSBuilder_Limaye_Wikitables_with_Ref.java | 2 +- .../sti/todo/gs/GSBuilder_MusicBrainz.java | 2 +- .../shef/dcs/sti/todo/gs/GSFile_Rewriter.java | 2 +- ...S_Class_Relation_Consolidation_Helper.java | 2 +- .../shef/dcs/sti/todo/gs/GS_Stats_Limaye.java | 2 +- .../todo/gs/WikipediaTL_GSCreator_Pass1.java | 2 +- .../todo/gs/WikipediaTL_GSCreator_Pass2.java | 2 +- .../todo/gs/WikipediaTableListPageFilter.java | 2 +- kbsearch/pom.xml | 10 ++ mvninstall.bat | 4 +- 40 files changed, 201 insertions(+), 108 deletions(-) diff --git a/.gitignore b/.gitignore index 6c23b80f..2c28946a 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,58 @@ cache/empty/relation/data/* cache/empty/websearch/data/* cache/empty/similarity/data/* delete/* + +# ========================= +# Eclipse files +# ========================= + +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.recommenders + +# Eclipse Core +.project + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# PyDev specific (Python IDE for Eclipse) +*.pydevproject + +# CDT-specific (C/C++ Development Tooling) +.cproject + +# JDT-specific (Eclipse Java Development Tools) +.classpath + +# Java annotation processor (APT) +.factorypath + +# PDT-specific (PHP Development Tools) +.buildpath + +# sbteclipse plugin +.target + +# Tern plugin +.tern-project + +# TeXlipse plugin +.texlipse + +# STS (Spring Tool Suite) +.springBeans + +# Code Recommenders +.recommenders/ diff --git a/any23-sti/pom.xml b/any23-sti/pom.xml index 4dbc72e8..c3aeed60 100644 --- a/any23-sti/pom.xml +++ b/any23-sti/pom.xml @@ -76,5 +76,16 @@ - + + + aduna-old-repository + http://maven.ontotext.com/content/repositories/aduna/ + + true + + + true + + + \ No newline at end of file diff --git a/common-util/pom.xml b/common-util/pom.xml index 0eaa54e3..b4568c77 100644 --- a/common-util/pom.xml +++ b/common-util/pom.xml @@ -1,69 +1,72 @@ - - 4.0.0 + + 4.0.0 - uk.ac.shef.dcs - common-util - 1.0 + uk.ac.shef.dcs + common-util + 1.0 - - - org.apache.solr - solr-core - 5.4.0 - - - org.slf4j - slf4j-log4j12 + + + org.apache.solr + solr-core + 5.4.0 + + + org.slf4j + slf4j-log4j12 + + + log4j + log4j + + + org.slf4j + slf4j-jdk14 + + + jdk.tools + jdk.tools - - log4j - log4j - - - org.slf4j - slf4j-jdk14 - - - - - org.apache.solr - solr-solrj - 5.4.0 - - - org.slf4j - slf4j-log4j12 - - - log4j - log4j - - - org.slf4j - slf4j-jdk14 - - - - + + + + org.apache.solr + solr-solrj + 5.4.0 + + + org.slf4j + slf4j-log4j12 + + + log4j + log4j + + + org.slf4j + slf4j-jdk14 + + + + UTF-8 - - - - true - org.apache.maven.plugins - maven-compiler-plugin - - 1.8 - 1.8 - UTF-8 - - - - + + + + true + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + UTF-8 + + + + \ No newline at end of file diff --git a/core/pom.xml b/core/pom.xml index f7e609e9..3f68e0a2 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -134,6 +134,10 @@ org.slf4j slf4j-jdk14 + + jdk.tools + jdk.tools + @@ -201,6 +205,16 @@ true + + aduna-old-repository + http://maven.ontotext.com/content/repositories/aduna/ + + true + + + true + + diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/FreebaseTypeGranularityPopulator.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/FreebaseTypeGranularityPopulator.java index bd4bfb85..64d96d0a 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/FreebaseTypeGranularityPopulator.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/FreebaseTypeGranularityPopulator.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO; +package uk.ac.shef.dcs.sti.todo; import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; import uk.ac.shef.dcs.kbsearch.KBSearchException; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/TAnnotationKeyFileReader.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/TAnnotationKeyFileReader.java index df1a00b3..439ee4a2 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/TAnnotationKeyFileReader.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/TAnnotationKeyFileReader.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO; +package uk.ac.shef.dcs.sti.todo; import uk.ac.shef.dcs.sti.util.FileUtils; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/TestGRMM.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/TestGRMM.java index c47908fb..acb2d2d6 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/TestGRMM.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/TestGRMM.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO; +package uk.ac.shef.dcs.sti.todo; import cc.mallet.grmm.inference.Inferencer; import cc.mallet.grmm.inference.LoopyBP; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/TestSubjectColumnDetector.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/TestSubjectColumnDetector.java index f9e0756b..aabc3a75 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/TestSubjectColumnDetector.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/TestSubjectColumnDetector.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO; +package uk.ac.shef.dcs.sti.todo; import javafx.util.Pair; import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats.java index 45b41b6c..6085f339 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; import uk.ac.shef.dcs.sti.util.FileUtils; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_LimayeNew.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_LimayeNew.java index 99b116ea..d3589432 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_LimayeNew.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_LimayeNew.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; import org.apache.any23.extractor.html.DomUtils; import org.apache.any23.util.FileUtils; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_MB_IMDB.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_MB_IMDB.java index dd852943..244ff16d 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_MB_IMDB.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_MB_IMDB.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; import org.apache.any23.util.FileUtils; import org.apache.commons.lang3.StringEscapeUtils; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Anaylsis_LimayeOld.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Anaylsis_LimayeOld.java index 76fc9b02..985eb5fc 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Anaylsis_LimayeOld.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Anaylsis_LimayeOld.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; import org.apache.any23.extractor.html.DomUtils; import org.apache.any23.util.FileUtils; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_IMDB.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_IMDB.java index e70be711..d29d5ef5 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_IMDB.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_IMDB.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; import java.io.IOException; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_Limaye.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_Limaye.java index 0f7d1372..4e302b23 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_Limaye.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_Limaye.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; import java.io.IOException; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_MB.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_MB.java index 779a3ebb..9834295c 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_MB.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_MB.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; import java.io.IOException; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly.java index 4b8e70b7..14c6ce82 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly.java @@ -1,6 +1,6 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; -import uk.ac.shef.dcs.sti.TODO.TAnnotationKeyFileReader; +import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; import uk.ac.shef.dcs.sti.util.FileUtils; import java.io.File; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly_IMDB_MusicBrainz.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly_IMDB_MusicBrainz.java index 8b86c4e7..025a7ebe 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly_IMDB_MusicBrainz.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly_IMDB_MusicBrainz.java @@ -1,8 +1,8 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; import uk.ac.shef.dcs.kbsearch.freebase.FreebaseQueryProxy; import uk.ac.shef.dcs.kbsearch.model.Attribute; -import uk.ac.shef.dcs.sti.TODO.TAnnotationKeyFileReader; +import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; import java.io.File; import java.io.IOException; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_EntityOnly.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_EntityOnly.java index c0dd6eb6..4c096273 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_EntityOnly.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_EntityOnly.java @@ -1,12 +1,12 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; - -import uk.ac.shef.dcs.sti.TODO.TAnnotationKeyFileReader; +package uk.ac.shef.dcs.sti.todo.evaluation; import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.util.*; +import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; + /** */ diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Generic_Classification_ignoreUpdateIterations.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Generic_Classification_ignoreUpdateIterations.java index a77c2d7d..1facd31e 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Generic_Classification_ignoreUpdateIterations.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Generic_Classification_ignoreUpdateIterations.java @@ -1,6 +1,6 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; -import uk.ac.shef.dcs.sti.TODO.TAnnotationKeyFileReader; +import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; import uk.ac.shef.dcs.sti.util.FileUtils; import java.io.File; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ISWC_Helper_ClassOnly.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ISWC_Helper_ClassOnly.java index 3b3f2bef..5ddbfd2f 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ISWC_Helper_ClassOnly.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ISWC_Helper_ClassOnly.java @@ -1,7 +1,7 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; import uk.ac.shef.dcs.kbsearch.model.Attribute; -import uk.ac.shef.dcs.sti.TODO.TAnnotationKeyFileReader; +import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; import uk.ac.shef.dcs.kbsearch.freebase.FreebaseQueryProxy; import java.io.File; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Limaye_Entity_Only.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Limaye_Entity_Only.java index 81311b18..ffbb8ea1 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Limaye_Entity_Only.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Limaye_Entity_Only.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; import java.io.IOException; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly.java index 9792c314..fcb20251 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly.java @@ -1,12 +1,12 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; - -import uk.ac.shef.dcs.sti.TODO.TAnnotationKeyFileReader; +package uk.ac.shef.dcs.sti.todo.evaluation; import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.util.*; +import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; + /** * Created with IntelliJ IDEA. * User: zqz diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly_IMDB_MusicBrainz.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly_IMDB_MusicBrainz.java index 0f52de66..9ceae661 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly_IMDB_MusicBrainz.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly_IMDB_MusicBrainz.java @@ -1,7 +1,7 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; import uk.ac.shef.dcs.kbsearch.freebase.FreebaseQueryProxy; -import uk.ac.shef.dcs.sti.TODO.TAnnotationKeyFileReader; +import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; import java.io.File; import java.io.IOException; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/KeyFileGenerator_from_HTMLOutput.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/KeyFileGenerator_from_HTMLOutput.java index 523820ce..0becbd26 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/KeyFileGenerator_from_HTMLOutput.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/KeyFileGenerator_from_HTMLOutput.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; import org.apache.any23.extractor.html.DomUtils; import org.apache.any23.extractor.html.TagSoupParser; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_Analysis_Generic.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_Analysis_Generic.java index fd06809f..45a8b2f4 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_Analysis_Generic.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_Analysis_Generic.java @@ -1,12 +1,12 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; import info.aduna.io.FileUtil; import org.xml.sax.SAXException; import uk.ac.shef.dcs.kbsearch.KBSearchException; import uk.ac.shef.dcs.kbsearch.freebase.FreebaseSearch; import uk.ac.shef.dcs.kbsearch.model.Attribute; -import uk.ac.shef.dcs.sti.TODO.TAnnotationKeyFileReader; import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; import uk.ac.shef.dcs.sti.util.FileUtils; import javax.xml.parsers.DocumentBuilder; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_btw_Baseline_Tm_Finder.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_btw_Baseline_Tm_Finder.java index 4b051338..4ac24f6a 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_btw_Baseline_Tm_Finder.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_btw_Baseline_Tm_Finder.java @@ -1,11 +1,11 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; import info.aduna.io.FileUtil; import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; import uk.ac.shef.dcs.kbsearch.freebase.FreebaseSearch; import uk.ac.shef.dcs.kbsearch.model.Attribute; -import uk.ac.shef.dcs.sti.TODO.TAnnotationKeyFileReader; import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; import uk.ac.shef.dcs.sti.util.FileUtils; import java.io.File; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_IMDB.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_IMDB.java index fa040088..2425b1d5 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_IMDB.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_IMDB.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.gs; +package uk.ac.shef.dcs.sti.todo.gs; import org.apache.any23.util.FileUtils; import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye.java index 82aa9f70..1333f978 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.gs; +package uk.ac.shef.dcs.sti.todo.gs; import org.apache.any23.extractor.html.DomUtils; import org.w3c.dom.Document; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables.java index 5971dc90..9677f982 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.gs; +package uk.ac.shef.dcs.sti.todo.gs; import org.apache.any23.extractor.html.DomUtils; import org.apache.any23.extractor.html.TagSoupParser; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_consolidate.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_consolidate.java index 60103cb8..27accd9b 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_consolidate.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_consolidate.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.gs; +package uk.ac.shef.dcs.sti.todo.gs; import info.aduna.io.FileUtil; import uk.ac.shef.dcs.sti.util.FileUtils; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_with_Ref.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_with_Ref.java index ec7eaa24..e29a8177 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_with_Ref.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_with_Ref.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.gs; +package uk.ac.shef.dcs.sti.todo.gs; import org.apache.commons.lang3.StringUtils; import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_MusicBrainz.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_MusicBrainz.java index 37ffcad7..418e9238 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_MusicBrainz.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_MusicBrainz.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.gs; +package uk.ac.shef.dcs.sti.todo.gs; import org.apache.any23.util.FileUtils; import uk.ac.shef.dcs.kbsearch.freebase.FreebaseQueryProxy; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSFile_Rewriter.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSFile_Rewriter.java index 76c8c1d8..2d5fddb5 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSFile_Rewriter.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSFile_Rewriter.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.gs; +package uk.ac.shef.dcs.sti.todo.gs; import uk.ac.shef.dcs.sti.util.FileUtils; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Class_Relation_Consolidation_Helper.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Class_Relation_Consolidation_Helper.java index 3131953a..4daae294 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Class_Relation_Consolidation_Helper.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Class_Relation_Consolidation_Helper.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.gs; +package uk.ac.shef.dcs.sti.todo.gs; import uk.ac.shef.dcs.sti.util.FileUtils; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Stats_Limaye.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Stats_Limaye.java index f4c75e67..dcd59394 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Stats_Limaye.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Stats_Limaye.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.gs; +package uk.ac.shef.dcs.sti.todo.gs; import org.apache.any23.extractor.html.DomUtils; import org.apache.any23.util.FileUtils; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass1.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass1.java index 3b7b55c9..b477c15c 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass1.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass1.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.gs; +package uk.ac.shef.dcs.sti.todo.gs; import info.bliki.wiki.dump.WikiXMLParser; import org.xml.sax.SAXException; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass2.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass2.java index f01597bd..a05b1ca5 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass2.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass2.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.gs; +package uk.ac.shef.dcs.sti.todo.gs; import uk.ac.shef.dcs.sti.core.model.List; import uk.ac.shef.dcs.sti.core.model.Table; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTableListPageFilter.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTableListPageFilter.java index 821cf053..1966996b 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTableListPageFilter.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTableListPageFilter.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.gs; +package uk.ac.shef.dcs.sti.todo.gs; import info.bliki.wiki.dump.IArticleFilter; import info.bliki.wiki.dump.Siteinfo; diff --git a/kbsearch/pom.xml b/kbsearch/pom.xml index bf4d7837..db03de56 100644 --- a/kbsearch/pom.xml +++ b/kbsearch/pom.xml @@ -60,6 +60,10 @@ org.slf4j slf4j-jdk14 + + jdk.tools + jdk.tools + @@ -82,6 +86,12 @@ + + org.glassfish + javax.json + 1.0.4 + + diff --git a/mvninstall.bat b/mvninstall.bat index 72a7f991..05fc5020 100755 --- a/mvninstall.bat +++ b/mvninstall.bat @@ -1,2 +1,2 @@ -mvn install:install-file -DgroupId=nlp.dragontools -DartifactId=dragontools -Dversion=1.0 -Dpackaging=jar -Dfile=libs/dragontool.jar -mvn install:install-file -DgroupId=com.github.mpkorstanje -DartifactId=simmetrics -Dversion=4.1.0L -Dpackaging=jar -Dfile=libs/simmetrics.jar +call mvn install:install-file -DgroupId=nlp.dragontools -DartifactId=dragontools -Dversion=1.0 -Dpackaging=jar -Dfile=libs/dragontool.jar +call mvn install:install-file -DgroupId=com.github.mpkorstanje -DartifactId=simmetrics -Dversion=4.1.0L -Dpackaging=jar -Dfile=libs/simmetrics.jar From c9109260b593a44c173e1933c6d4464cefbf7db4 Mon Sep 17 00:00:00 2001 From: JanVana Date: Wed, 18 May 2016 10:55:01 +0200 Subject: [PATCH 006/211] Update of POM packages --- any23-sti/pom.xml | 47 ++----- .../oak/any23/extension/extractor/LAny23.java | 1 - .../extractor/LMicrodataExtractor.java | 15 +- .../extractor/LMicrodataExtractorFactory.java | 39 ++++++ .../extension/extractor/LNTripleWriter.java | 2 - .../extension/extractor/LRDFa11Extractor.java | 9 +- .../extractor/LRDFa11ExtractorFactory.java | 40 ++++++ common-util/pom.xml | 34 +---- core/pom.xml | 131 +++++------------- .../algorithm/smp/CellAnnotationUpdater.java | 1 + .../algorithm/smp/ChangeMessageComputer.java | 1 + .../dcs/sti/core/subjectcol/WSScorer.java | 1 + .../dcs/sti/parser/list/ListXtractor.java | 2 +- .../dcs/sti/parser/list/ListXtractorHTML.java | 3 +- .../parser/list/ListXtractorWikipedia.java | 4 +- .../dcs/sti/parser/table/TableParser.java | 2 +- .../parser/table/TableParserWikipedia.java | 2 +- .../FreebaseTypeGranularityPopulator.java | 2 +- .../sti/todo/TAnnotationKeyFileReader.java | 2 +- .../uk/ac/shef/dcs/sti/todo/TestGRMM.java | 2 +- .../sti/todo/TestSubjectColumnDetector.java | 2 +- .../dcs/sti/todo/evaluation/DataStats.java | 2 +- ...bleSize_NameLength_Analysis_LimayeNew.java | 2 +- ...TableSize_NameLength_Analysis_MB_IMDB.java | 2 +- ...bleSize_NameLength_Anaylsis_LimayeOld.java | 2 +- .../evaluation/Evaluator_AllInOne_IMDB.java | 2 +- .../evaluation/Evaluator_AllInOne_Limaye.java | 2 +- .../evaluation/Evaluator_AllInOne_MB.java | 2 +- .../todo/evaluation/Evaluator_ClassOnly.java | 4 +- .../Evaluator_ClassOnly_IMDB_MusicBrainz.java | 4 +- .../todo/evaluation/Evaluator_EntityOnly.java | 7 +- ...Classification_ignoreUpdateIterations.java | 4 +- .../Evaluator_ISWC_Helper_ClassOnly.java | 4 +- .../Evaluator_Limaye_Entity_Only.java | 2 +- .../evaluation/Evaluator_RelationOnly.java | 4 +- ...aluator_RelationOnly_IMDB_MusicBrainz.java | 4 +- .../KeyFileGenerator_from_HTMLOutput.java | 2 +- ...t_Entity_Discrepancy_Analysis_Generic.java | 4 +- ...ty_Discrepancy_btw_Baseline_Tm_Finder.java | 4 +- .../shef/dcs/sti/todo/gs/GSBuilder_IMDB.java | 2 +- .../dcs/sti/todo/gs/GSBuilder_Limaye.java | 2 +- .../todo/gs/GSBuilder_Limaye_Wikitables.java | 2 +- ...Builder_Limaye_Wikitables_consolidate.java | 2 +- .../GSBuilder_Limaye_Wikitables_with_Ref.java | 2 +- .../sti/todo/gs/GSBuilder_MusicBrainz.java | 2 +- .../shef/dcs/sti/todo/gs/GSFile_Rewriter.java | 2 +- ...S_Class_Relation_Consolidation_Helper.java | 2 +- .../shef/dcs/sti/todo/gs/GS_Stats_Limaye.java | 2 +- .../todo/gs/WikipediaTL_GSCreator_Pass1.java | 32 +++-- .../todo/gs/WikipediaTL_GSCreator_Pass2.java | 2 +- .../todo/gs/WikipediaTableListPageFilter.java | 5 +- kbsearch/pom.xml | 85 +++++------- mvninstall.bat | 4 +- websearch/pom.xml | 59 ++++---- 54 files changed, 273 insertions(+), 331 deletions(-) create mode 100644 any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractorFactory.java create mode 100644 any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11ExtractorFactory.java diff --git a/any23-sti/pom.xml b/any23-sti/pom.xml index 4dbc72e8..20037c19 100644 --- a/any23-sti/pom.xml +++ b/any23-sti/pom.xml @@ -8,16 +8,9 @@ src - maven-compiler-plugin - 2.3.2 - - - - - - + org.apache.maven.plugins maven-assembly-plugin - 2.2.1 + 2.6 jar-with-dependencies @@ -39,16 +32,16 @@ - - true - org.apache.maven.plugins - maven-compiler-plugin - - 1.8 - 1.8 - UTF-8 - - + + true + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + UTF-8 + + @@ -57,21 +50,7 @@ org.apache.any23 apache-any23-core - 0.7.0-incubating - - - org.slf4j - slf4j-api - - - org.slf4j - slf4j-jdk14 - - - org.slf4j - jcl-over-slf4j - - + 1.1 diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LAny23.java b/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LAny23.java index f752f2a7..e07b737a 100644 --- a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LAny23.java +++ b/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LAny23.java @@ -31,7 +31,6 @@ import org.apache.any23.mime.purifier.WhiteSpacesPurifier; import org.apache.any23.source.*; import org.apache.any23.writer.TripleHandler; -import org.apache.log4j.spi.LoggerFactory; import java.io.File; import java.io.IOException; diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractor.java b/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractor.java index d56b7ed6..4d0f93a5 100644 --- a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractor.java +++ b/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractor.java @@ -32,7 +32,7 @@ import org.apache.any23.extractor.microdata.MicrodataParserReport; import org.apache.any23.rdf.PopularPrefixes; import org.apache.any23.rdf.RDFUtils; -import org.apache.any23.vocab.DCTERMS; +import org.apache.any23.vocab.DCTerms; import org.apache.any23.vocab.XHTML; import org.openrdf.model.Literal; import org.openrdf.model.Resource; @@ -53,14 +53,7 @@ public class LMicrodataExtractor extends MicrodataExtractor{ private static final URI MICRODATA_ITEM = RDFUtils.uri("http://www.w3.org/1999/xhtml/microdata#item"); - public final static ExtractorFactory factory = - SimpleExtractorFactory.create( - "lodie-html-microdata", - PopularPrefixes.createSubset("rdf", "doac", "foaf"), - Arrays.asList("text/html;q=0.1", "application/xhtml+xml;q=0.1"), - "example-microdata.html", - LMicrodataExtractor.class - ); + public final static ExtractorFactory factory = new LMicrodataExtractorFactory(); private String documentLanguage; @@ -200,7 +193,7 @@ private void processTitle(Document in, URI documentURI, ExtractionResult out) { } out.writeTriple( documentURI, - DCTERMS.getInstance().title, + DCTerms.getInstance().title, object ); } @@ -418,7 +411,7 @@ private void processCiteElement(Node item, URI documentURI, ExtractionResult out if (item.getAttributes().getNamedItem("cite") != null) { out.writeTriple( documentURI, - DCTERMS.getInstance().source, + DCTerms.getInstance().source, RDFUtils.uri(item.getAttributes().getNamedItem("cite").getTextContent()) ); } diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractorFactory.java b/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractorFactory.java new file mode 100644 index 00000000..e58551c5 --- /dev/null +++ b/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractorFactory.java @@ -0,0 +1,39 @@ +package uk.ac.shef.oak.any23.extension.extractor; + +import java.util.Arrays; + +import org.apache.any23.extractor.ExtractorDescription; +import org.apache.any23.extractor.ExtractorFactory; +import org.apache.any23.extractor.SimpleExtractorFactory; +import org.apache.any23.rdf.PopularPrefixes; +import org.apache.any23.rdf.Prefixes; + +/** + * Created by Jan on 10.05.2016. + */ +public class LMicrodataExtractorFactory extends SimpleExtractorFactory implements + ExtractorFactory { + + public static final String NAME = "lodie-html-microdata"; + + public static final Prefixes PREFIXES = PopularPrefixes.createSubset("rdf", "doac", "foaf"); + + private static final ExtractorDescription descriptionInstance = new LMicrodataExtractorFactory(); + + public LMicrodataExtractorFactory() { + super( + LMicrodataExtractorFactory.NAME, + LMicrodataExtractorFactory.PREFIXES, + Arrays.asList("text/html;q=0.1", "application/xhtml+xml;q=0.1"), + "example-microdata.html"); + } + + @Override + public LMicrodataExtractor createExtractor() { + return new LMicrodataExtractor(); + } + + public static ExtractorDescription getDescriptionInstance() { + return descriptionInstance; + } +} diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LNTripleWriter.java b/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LNTripleWriter.java index 5b4a2c27..1c4bada4 100644 --- a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LNTripleWriter.java +++ b/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LNTripleWriter.java @@ -4,7 +4,6 @@ import org.apache.any23.rdf.RDFUtils; import org.apache.any23.writer.NTriplesWriter; import org.apache.any23.writer.TripleHandlerException; -import org.apache.any23.writer.Writer; import org.openrdf.model.Resource; import org.openrdf.model.Statement; import org.openrdf.model.URI; @@ -19,7 +18,6 @@ * Date: 29/10/12 * Time: 20:39 */ -@Writer(identifier = "lodie-ntriples", mimeType = "text/plain") public class LNTripleWriter extends NTriplesWriter { private List triples; diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Extractor.java b/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Extractor.java index b0745d07..dd4c6422 100644 --- a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Extractor.java +++ b/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Extractor.java @@ -17,14 +17,7 @@ public class LRDFa11Extractor extends RDFa11Extractor { public final static String NAME = "lodie-html-rdfa11"; - public final static ExtractorFactory factory = - SimpleExtractorFactory.create( - NAME, - null, - Arrays.asList("text/html;q=0.3", "application/xhtml+xml;q=0.3"), - "example-rdfa11.html", - LRDFa11Extractor.class - ); + public final static ExtractorFactory factory = new LRDFa11ExtractorFactory(); private final LRDFa11Parser parser; diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11ExtractorFactory.java b/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11ExtractorFactory.java new file mode 100644 index 00000000..4a8afd93 --- /dev/null +++ b/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11ExtractorFactory.java @@ -0,0 +1,40 @@ +package uk.ac.shef.oak.any23.extension.extractor; + +import org.apache.any23.extractor.ExtractorDescription; +import org.apache.any23.extractor.ExtractorFactory; +import org.apache.any23.extractor.SimpleExtractorFactory; +import org.apache.any23.rdf.PopularPrefixes; +import org.apache.any23.rdf.Prefixes; + +import java.util.Arrays; + +/** + * Created by Jan on 10.05.2016. + */ +public class LRDFa11ExtractorFactory + extends SimpleExtractorFactory + implements ExtractorFactory{ + + public static final String NAME = "lodie-html-rdfa11"; + + public static final Prefixes PREFIXES = null; + + private static final ExtractorDescription descriptionInstance = new LRDFa11ExtractorFactory(); + + public LRDFa11ExtractorFactory() { + super( + LMicrodataExtractorFactory.NAME, + LMicrodataExtractorFactory.PREFIXES, + Arrays.asList("text/html;q=0.3", "application/xhtml+xml;q=0.3"), + "example-rdfa11.html"); + } + + @Override + public LRDFa11Extractor createExtractor() { + return new LRDFa11Extractor(); + } + + public static ExtractorDescription getDescriptionInstance() { + return descriptionInstance; + } +} diff --git a/common-util/pom.xml b/common-util/pom.xml index 0eaa54e3..4a4de9d5 100644 --- a/common-util/pom.xml +++ b/common-util/pom.xml @@ -12,47 +12,21 @@ org.apache.solr solr-core - 5.4.0 - - - org.slf4j - slf4j-log4j12 - - - log4j - log4j - - - org.slf4j - slf4j-jdk14 - - + 6.0.0 org.apache.solr solr-solrj - 5.4.0 - - - org.slf4j - slf4j-log4j12 - - - log4j - log4j - - - org.slf4j - slf4j-jdk14 - - + 6.0.0 UTF-8 + + src/main/java true diff --git a/core/pom.xml b/core/pom.xml index f7e609e9..e39b4f65 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -6,12 +6,13 @@ uk.ac.shef.dcs sti - 1.0alpha + 1.0 UTF-8 UTF-8 + Apache 2.0 @@ -29,11 +30,6 @@ called 4.1.0L. Run mvninstall.bat to add it to your local maven repository --> - uk.ac.shef.dcs websearch @@ -45,139 +41,94 @@ kbsearch 1.0 + org.apache.opennlp opennlp-tools 1.6.0 + nlp.dragontools dragontools 1.0 + org.jsoup jsoup - 1.6.3 + 1.9.1 + uk.ac.shef.dcs any23-sti 1.0 + uk.ac.shef.dcs common-util 1.0 - + cc.mallet mallet - 2.0.7-RC2 + 2.0.8 + colt colt 1.2.0 + info.bliki.wiki bliki-core - 3.0.19 + 3.1.0 + org.apache.any23 apache-any23-core - 0.7.0-incubating - - - org.slf4j - slf4j-api - - - org.slf4j - slf4j-jdk14 - - - org.slf4j - jcl-over-slf4j - - + 1.1 + - commons-lang - commons-lang - 2.6 + org.apache.commons + commons-lang3 + 3.4 + org.apache.solr solr-core - 5.4.0 - - - org.slf4j - slf4j-log4j12 - - - log4j - log4j - - - org.slf4j - slf4j-jdk14 - - + 6.0.0 + org.apache.solr solr-solrj - 5.4.0 - - - org.slf4j - slf4j-log4j12 - - - log4j - log4j - - - org.slf4j - slf4j-jdk14 - - + 6.0.0 + org.apache.jena jena-arq - 2.9.3 + 3.0.1 + javax.servlet - servlet-api - 2.5 + javax.servlet-api + 3.1.0 - - - @@ -191,19 +142,8 @@ false - - ossrh @@ -214,26 +154,23 @@ https://oss.sonatype.org/service/local/staging/deploy/maven2/ + install + src/main/java maven-antrun-plugin install - - - - - - run + org.sonatype.plugins nexus-staging-maven-plugin @@ -245,6 +182,7 @@ true + org.apache.maven.plugins maven-source-plugin @@ -267,7 +205,6 @@ - true org.apache.maven.plugins @@ -276,12 +213,13 @@ 1.8 1.8 UTF-8 + -Xlint:unchecked maven-assembly-plugin - 2.2.1 + 2.6 jar-with-dependencies @@ -301,7 +239,6 @@ - \ No newline at end of file diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/CellAnnotationUpdater.java b/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/CellAnnotationUpdater.java index 468d6ea7..c8d0d1db 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/CellAnnotationUpdater.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/CellAnnotationUpdater.java @@ -25,6 +25,7 @@ public int[] update(ObjectMatrix2D messages, TAnnotation tableAnnotation) { if (container == null) continue; countUpdateNeeded++; + @SuppressWarnings("unchecked") List messages_for_cell = (List) container; if(messages_for_cell.size()==0) continue; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageComputer.java b/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageComputer.java index eed87ce6..6a68ab0e 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageComputer.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageComputer.java @@ -115,6 +115,7 @@ public ObjectMatrix2D computeChangeMessages(TAnnotation tableAnnotation, Table t return messages; } + @SuppressWarnings("unchecked") private void updateMessageForCell(ObjectMatrix2D messages, int row, int col, ChangeMessage m) { if (m.getConfidence() >= minConfidence) { Object container = messages.get(row, col); diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/WSScorer.java b/core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/WSScorer.java index e391d5dd..29a33401 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/WSScorer.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/WSScorer.java @@ -32,6 +32,7 @@ public WSScorer(SolrCache cache, WebSearch searcher, this.stopWords = stopWords; } + @SuppressWarnings("unchecked") protected List findInCache(String queryId) throws IOException, ClassNotFoundException, SolrServerException { return (List)cache.retrieve(queryId); } diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractor.java b/core/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractor.java index c0343771..fe7d96af 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractor.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractor.java @@ -26,7 +26,7 @@ public ListXtractor(ListItemSplitter tokenizer, ListValidator... validators) { this.tokenizer = tokenizer; } - public abstract java.util.List extract(String input, String sourceId); + public abstract java.util.List extract(String input, String sourceId) throws IOException; /** * ONLY extracts IMMEDIATE children diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorHTML.java b/core/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorHTML.java index e6697dff..0d63cc15 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorHTML.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorHTML.java @@ -26,8 +26,9 @@ public ListXtractorHTML(ListItemSplitter tokenizer, ListValidator... validator) listTagSelectors = new String[]{"UL","OL"}; } + @SuppressWarnings("unchecked") @Override - public java.util.List extract(String input, String sourceId) { + public java.util.List extract(String input, String sourceId) throws IOException { /*if (sourceId.startsWith("Altruism")) System.out.println();*/ java.util.List rs = new ArrayList(); diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorWikipedia.java b/core/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorWikipedia.java index 63333cce..a7bbbfb7 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorWikipedia.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorWikipedia.java @@ -5,6 +5,8 @@ import uk.ac.shef.dcs.sti.parser.list.splitter.ListItemSplitter; import uk.ac.shef.dcs.sti.parser.list.validator.ListValidator; +import java.io.IOException; + /** * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) * Date: 09/10/12 @@ -24,7 +26,7 @@ public ListXtractorWikipedia(ListItemSplitter tokenizer, ListValidator... valida } @Override - public java.util.List extract(String input, String sourceId) { + public java.util.List extract(String input, String sourceId) throws IOException { String html = model.render(input); return super.extract(html, sourceId); } diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParser.java b/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParser.java index 13aaf922..aecdf6df 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParser.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParser.java @@ -40,7 +40,7 @@ public TableParser(TableNormalizer normalizer, this.validators = validators; } - public abstract List extract(String input, String sourceId) throws STIException; + public abstract List
extract(String input, String sourceId) throws STIException, IOException; /** * Processes table elements following the basic principles: diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserWikipedia.java b/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserWikipedia.java index 72f51749..1790727f 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserWikipedia.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserWikipedia.java @@ -36,7 +36,7 @@ public TableParserWikipedia(TableNormalizer normalizer, TableHODetector detector @Override - public List
extract(String inFile, String sourceId) throws STIException { + public List
extract(String inFile, String sourceId) throws STIException, IOException { String input; try { input = FileUtils.readFileToString(new File(inFile)); diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/FreebaseTypeGranularityPopulator.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/FreebaseTypeGranularityPopulator.java index bd4bfb85..64d96d0a 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/FreebaseTypeGranularityPopulator.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/FreebaseTypeGranularityPopulator.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO; +package uk.ac.shef.dcs.sti.todo; import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; import uk.ac.shef.dcs.kbsearch.KBSearchException; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/TAnnotationKeyFileReader.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/TAnnotationKeyFileReader.java index df1a00b3..439ee4a2 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/TAnnotationKeyFileReader.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/TAnnotationKeyFileReader.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO; +package uk.ac.shef.dcs.sti.todo; import uk.ac.shef.dcs.sti.util.FileUtils; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/TestGRMM.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/TestGRMM.java index c47908fb..acb2d2d6 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/TestGRMM.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/TestGRMM.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO; +package uk.ac.shef.dcs.sti.todo; import cc.mallet.grmm.inference.Inferencer; import cc.mallet.grmm.inference.LoopyBP; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/TestSubjectColumnDetector.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/TestSubjectColumnDetector.java index f9e0756b..aabc3a75 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/TestSubjectColumnDetector.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/TestSubjectColumnDetector.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO; +package uk.ac.shef.dcs.sti.todo; import javafx.util.Pair; import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats.java index 45b41b6c..6085f339 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; import uk.ac.shef.dcs.sti.util.FileUtils; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_LimayeNew.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_LimayeNew.java index 99b116ea..d3589432 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_LimayeNew.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_LimayeNew.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; import org.apache.any23.extractor.html.DomUtils; import org.apache.any23.util.FileUtils; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_MB_IMDB.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_MB_IMDB.java index dd852943..244ff16d 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_MB_IMDB.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_MB_IMDB.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; import org.apache.any23.util.FileUtils; import org.apache.commons.lang3.StringEscapeUtils; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Anaylsis_LimayeOld.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Anaylsis_LimayeOld.java index 76fc9b02..985eb5fc 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Anaylsis_LimayeOld.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Anaylsis_LimayeOld.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; import org.apache.any23.extractor.html.DomUtils; import org.apache.any23.util.FileUtils; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_IMDB.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_IMDB.java index e70be711..d29d5ef5 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_IMDB.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_IMDB.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; import java.io.IOException; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_Limaye.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_Limaye.java index 0f7d1372..4e302b23 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_Limaye.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_Limaye.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; import java.io.IOException; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_MB.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_MB.java index 779a3ebb..9834295c 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_MB.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_MB.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; import java.io.IOException; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly.java index 4b8e70b7..14c6ce82 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly.java @@ -1,6 +1,6 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; -import uk.ac.shef.dcs.sti.TODO.TAnnotationKeyFileReader; +import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; import uk.ac.shef.dcs.sti.util.FileUtils; import java.io.File; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly_IMDB_MusicBrainz.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly_IMDB_MusicBrainz.java index 8b86c4e7..025a7ebe 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly_IMDB_MusicBrainz.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly_IMDB_MusicBrainz.java @@ -1,8 +1,8 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; import uk.ac.shef.dcs.kbsearch.freebase.FreebaseQueryProxy; import uk.ac.shef.dcs.kbsearch.model.Attribute; -import uk.ac.shef.dcs.sti.TODO.TAnnotationKeyFileReader; +import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; import java.io.File; import java.io.IOException; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_EntityOnly.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_EntityOnly.java index c0dd6eb6..ebb82b29 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_EntityOnly.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_EntityOnly.java @@ -1,6 +1,6 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; -import uk.ac.shef.dcs.sti.TODO.TAnnotationKeyFileReader; +import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; import java.io.File; import java.io.IOException; @@ -235,10 +235,11 @@ public void evaluate(String in_computed_folder, Map>> cp_cells = TAnnotationKeyFileReader.readCellAnnotation(cpFile_name); - + @SuppressWarnings("deprecation") double[] cell_data_mode_0 = Evaluator_ClassOnly.compute_prf_relation_or_entity(gs_cells, cp_cells, 0); line.append(appendResult(cell_data_mode_0)); + @SuppressWarnings("deprecation") double[] cell_data_mode_1 = Evaluator_ClassOnly.compute_prf_relation_or_entity(gs_cells, cp_cells, 1); line.append(appendResult(cell_data_mode_1)); diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Generic_Classification_ignoreUpdateIterations.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Generic_Classification_ignoreUpdateIterations.java index a77c2d7d..1facd31e 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Generic_Classification_ignoreUpdateIterations.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Generic_Classification_ignoreUpdateIterations.java @@ -1,6 +1,6 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; -import uk.ac.shef.dcs.sti.TODO.TAnnotationKeyFileReader; +import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; import uk.ac.shef.dcs.sti.util.FileUtils; import java.io.File; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ISWC_Helper_ClassOnly.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ISWC_Helper_ClassOnly.java index 3b3f2bef..5ddbfd2f 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ISWC_Helper_ClassOnly.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ISWC_Helper_ClassOnly.java @@ -1,7 +1,7 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; import uk.ac.shef.dcs.kbsearch.model.Attribute; -import uk.ac.shef.dcs.sti.TODO.TAnnotationKeyFileReader; +import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; import uk.ac.shef.dcs.kbsearch.freebase.FreebaseQueryProxy; import java.io.File; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Limaye_Entity_Only.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Limaye_Entity_Only.java index 81311b18..ffbb8ea1 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Limaye_Entity_Only.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Limaye_Entity_Only.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; import java.io.IOException; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly.java index 9792c314..3ffa4e9c 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly.java @@ -1,6 +1,6 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; -import uk.ac.shef.dcs.sti.TODO.TAnnotationKeyFileReader; +import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; import java.io.File; import java.io.IOException; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly_IMDB_MusicBrainz.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly_IMDB_MusicBrainz.java index 0f52de66..9ceae661 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly_IMDB_MusicBrainz.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly_IMDB_MusicBrainz.java @@ -1,7 +1,7 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; import uk.ac.shef.dcs.kbsearch.freebase.FreebaseQueryProxy; -import uk.ac.shef.dcs.sti.TODO.TAnnotationKeyFileReader; +import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; import java.io.File; import java.io.IOException; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/KeyFileGenerator_from_HTMLOutput.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/KeyFileGenerator_from_HTMLOutput.java index 523820ce..0becbd26 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/KeyFileGenerator_from_HTMLOutput.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/KeyFileGenerator_from_HTMLOutput.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; import org.apache.any23.extractor.html.DomUtils; import org.apache.any23.extractor.html.TagSoupParser; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_Analysis_Generic.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_Analysis_Generic.java index fd06809f..3e0fb95f 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_Analysis_Generic.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_Analysis_Generic.java @@ -1,11 +1,11 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; import info.aduna.io.FileUtil; import org.xml.sax.SAXException; import uk.ac.shef.dcs.kbsearch.KBSearchException; import uk.ac.shef.dcs.kbsearch.freebase.FreebaseSearch; import uk.ac.shef.dcs.kbsearch.model.Attribute; -import uk.ac.shef.dcs.sti.TODO.TAnnotationKeyFileReader; +import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; import uk.ac.shef.dcs.kbsearch.model.Entity; import uk.ac.shef.dcs.sti.util.FileUtils; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_btw_Baseline_Tm_Finder.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_btw_Baseline_Tm_Finder.java index 4b051338..c7be108b 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_btw_Baseline_Tm_Finder.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_btw_Baseline_Tm_Finder.java @@ -1,10 +1,10 @@ -package uk.ac.shef.dcs.sti.TODO.evaluation; +package uk.ac.shef.dcs.sti.todo.evaluation; import info.aduna.io.FileUtil; import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; import uk.ac.shef.dcs.kbsearch.freebase.FreebaseSearch; import uk.ac.shef.dcs.kbsearch.model.Attribute; -import uk.ac.shef.dcs.sti.TODO.TAnnotationKeyFileReader; +import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; import uk.ac.shef.dcs.kbsearch.model.Entity; import uk.ac.shef.dcs.sti.util.FileUtils; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_IMDB.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_IMDB.java index fa040088..2425b1d5 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_IMDB.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_IMDB.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.gs; +package uk.ac.shef.dcs.sti.todo.gs; import org.apache.any23.util.FileUtils; import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye.java index 82aa9f70..1333f978 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.gs; +package uk.ac.shef.dcs.sti.todo.gs; import org.apache.any23.extractor.html.DomUtils; import org.w3c.dom.Document; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables.java index 5971dc90..9677f982 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.gs; +package uk.ac.shef.dcs.sti.todo.gs; import org.apache.any23.extractor.html.DomUtils; import org.apache.any23.extractor.html.TagSoupParser; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_consolidate.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_consolidate.java index 60103cb8..27accd9b 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_consolidate.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_consolidate.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.gs; +package uk.ac.shef.dcs.sti.todo.gs; import info.aduna.io.FileUtil; import uk.ac.shef.dcs.sti.util.FileUtils; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_with_Ref.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_with_Ref.java index ec7eaa24..e29a8177 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_with_Ref.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_with_Ref.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.gs; +package uk.ac.shef.dcs.sti.todo.gs; import org.apache.commons.lang3.StringUtils; import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_MusicBrainz.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_MusicBrainz.java index 37ffcad7..418e9238 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_MusicBrainz.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_MusicBrainz.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.gs; +package uk.ac.shef.dcs.sti.todo.gs; import org.apache.any23.util.FileUtils; import uk.ac.shef.dcs.kbsearch.freebase.FreebaseQueryProxy; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSFile_Rewriter.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSFile_Rewriter.java index 76c8c1d8..2d5fddb5 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSFile_Rewriter.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSFile_Rewriter.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.gs; +package uk.ac.shef.dcs.sti.todo.gs; import uk.ac.shef.dcs.sti.util.FileUtils; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Class_Relation_Consolidation_Helper.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Class_Relation_Consolidation_Helper.java index 3131953a..4daae294 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Class_Relation_Consolidation_Helper.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Class_Relation_Consolidation_Helper.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.gs; +package uk.ac.shef.dcs.sti.todo.gs; import uk.ac.shef.dcs.sti.util.FileUtils; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Stats_Limaye.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Stats_Limaye.java index f4c75e67..dcd59394 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Stats_Limaye.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Stats_Limaye.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.gs; +package uk.ac.shef.dcs.sti.todo.gs; import org.apache.any23.extractor.html.DomUtils; import org.apache.any23.util.FileUtils; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass1.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass1.java index 3b7b55c9..203c6a4d 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass1.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass1.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.gs; +package uk.ac.shef.dcs.sti.todo.gs; import info.bliki.wiki.dump.WikiXMLParser; import org.xml.sax.SAXException; @@ -11,6 +11,7 @@ import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizerDiscardIrregularRows; import uk.ac.shef.dcs.sti.parser.table.validator.TableValidatorForWikipediaGSLanient; +import java.io.FileInputStream; import java.io.IOException; /** @@ -26,19 +27,22 @@ public class WikipediaTL_GSCreator_Pass1 { public static void parse(String inputWikib2zFile, String outputTableDir, String outputListDir) throws IOException, SAXException { - WikiXMLParser parser = new WikiXMLParser(inputWikib2zFile, - new WikipediaTableListPageFilter( - new TableParserWikipedia(new TableNormalizerDiscardIrregularRows(true), - new TableHODetectorByHTMLTag(), - new TableObjCreatorWikipediaGS(false), - new TableValidatorForWikipediaGSLanient()), - outputTableDir, - new ListXtractorWikipedia(new ListItemSplitterByURL(), - new ListVaildatorLanient()), - outputListDir - )); - - parser.parse(); + try(FileInputStream stream = new FileInputStream(inputWikib2zFile)) { + + WikiXMLParser parser = new WikiXMLParser(stream, + new WikipediaTableListPageFilter( + new TableParserWikipedia(new TableNormalizerDiscardIrregularRows(true), + new TableHODetectorByHTMLTag(), + new TableObjCreatorWikipediaGS(false), + new TableValidatorForWikipediaGSLanient()), + outputTableDir, + new ListXtractorWikipedia(new ListItemSplitterByURL(), + new ListVaildatorLanient()), + outputListDir + )); + + parser.parse(); + } } diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass2.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass2.java index f01597bd..a05b1ca5 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass2.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass2.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.gs; +package uk.ac.shef.dcs.sti.todo.gs; import uk.ac.shef.dcs.sti.core.model.List; import uk.ac.shef.dcs.sti.core.model.Table; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTableListPageFilter.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTableListPageFilter.java index 821cf053..57164b8c 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTableListPageFilter.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTableListPageFilter.java @@ -1,4 +1,4 @@ -package uk.ac.shef.dcs.sti.TODO.gs; +package uk.ac.shef.dcs.sti.todo.gs; import info.bliki.wiki.dump.IArticleFilter; import info.bliki.wiki.dump.Siteinfo; @@ -49,8 +49,9 @@ public WikipediaTableListPageFilter(TableParser tXtractor, String targetTableDir } + @SuppressWarnings("unchecked") @Override - public void process(WikiArticle page, Siteinfo siteinfo) throws SAXException { + public void process(WikiArticle page, Siteinfo siteinfo) throws IOException { if (countMainPages % 200 == 0) { logger.info("Pages processed: " + countMainPages + ", tables " + countTables + ", lists " + countLists); } diff --git a/kbsearch/pom.xml b/kbsearch/pom.xml index bf4d7837..c220aed0 100644 --- a/kbsearch/pom.xml +++ b/kbsearch/pom.xml @@ -4,37 +4,56 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - uk.ac.shef.dcs kbsearch 1.0 jar kbsearch + + + src/main/java + + + true + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + UTF-8 + + + + + - log4j - log4j - 1.2.17 + org.apache.logging.log4j + log4j-core + 2.5 + uk.ac.shef.dcs common-util - 1.0 + 1.0 + + org.apache.commons commons-lang3 - 3.1 + 3.4 javax.servlet - servlet-api - 2.5 + javax.servlet-api + 3.1.0 com.google.api-client google-api-client - 1.17.0-rc + 1.22.0 @@ -46,57 +65,15 @@ org.apache.solr solr-core - 5.4.0 - - - org.slf4j - slf4j-log4j12 - - - log4j - log4j - - - org.slf4j - slf4j-jdk14 - - + 6.0.0 + org.apache.solr solr-solrj - 5.4.0 - - - org.slf4j - slf4j-log4j12 - - - log4j - log4j - - - org.slf4j - slf4j-jdk14 - - + 6.0.0 - - - - true - org.apache.maven.plugins - maven-compiler-plugin - - 1.8 - 1.8 - UTF-8 - - - - - \ No newline at end of file diff --git a/mvninstall.bat b/mvninstall.bat index 72a7f991..05fc5020 100755 --- a/mvninstall.bat +++ b/mvninstall.bat @@ -1,2 +1,2 @@ -mvn install:install-file -DgroupId=nlp.dragontools -DartifactId=dragontools -Dversion=1.0 -Dpackaging=jar -Dfile=libs/dragontool.jar -mvn install:install-file -DgroupId=com.github.mpkorstanje -DartifactId=simmetrics -Dversion=4.1.0L -Dpackaging=jar -Dfile=libs/simmetrics.jar +call mvn install:install-file -DgroupId=nlp.dragontools -DartifactId=dragontools -Dversion=1.0 -Dpackaging=jar -Dfile=libs/dragontool.jar +call mvn install:install-file -DgroupId=com.github.mpkorstanje -DartifactId=simmetrics -Dversion=4.1.0L -Dpackaging=jar -Dfile=libs/simmetrics.jar diff --git a/websearch/pom.xml b/websearch/pom.xml index 07f1dbad..7b5da392 100644 --- a/websearch/pom.xml +++ b/websearch/pom.xml @@ -11,40 +11,41 @@ UTF-8 + src - - - true - org.apache.maven.plugins - maven-compiler-plugin - - 1.8 - 1.8 - UTF-8 - - - + + + true + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + UTF-8 + + + - - - commons-lang - commons-lang - 2.6 - + + + commons-lang + commons-lang + 2.6 + - - commons-codec - commons-codec - 1.9 - - - javax.json - javax.json-api - 1.0 - + + commons-codec + commons-codec + 1.10 + + + javax.json + javax.json-api + 1.0 + - + \ No newline at end of file From a02bba8da121ad1fb625b652a1fb0ce5e8eae828 Mon Sep 17 00:00:00 2001 From: JanVana Date: Wed, 18 May 2016 11:43:57 +0200 Subject: [PATCH 007/211] Basic structure for Dbpedia search --- .../uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryProxy.java | 1 + 1 file changed, 1 insertion(+) diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryProxy.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryProxy.java index 656ba9c7..9faa6afb 100644 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryProxy.java +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryProxy.java @@ -133,6 +133,7 @@ public List topicapi_getAttributesOfTopicID(String id, String filter) private void parseTopicAPIResult(JSONObject json, List out, boolean directRelation) { /*if(json==null) System.out.println();*/ + @SuppressWarnings("unchecked") Iterator prop_keys = json.keySet().iterator(); while (prop_keys.hasNext()) { String prop = prop_keys.next(); From dcfbf1c4fe941e67862070ba90d629229ac36e21 Mon Sep 17 00:00:00 2001 From: JanVana Date: Wed, 18 May 2016 11:44:14 +0200 Subject: [PATCH 008/211] Basic structure for Dbpedia search --- .gitignore | 55 ++++++++++++++ any23-sti/pom.xml | 13 +++- .../todo/evaluation/Evaluator_EntityOnly.java | 4 +- .../evaluation/Evaluator_RelationOnly.java | 4 +- ...t_Entity_Discrepancy_Analysis_Generic.java | 2 +- ...ty_Discrepancy_btw_Baseline_Tm_Finder.java | 2 +- .../kbsearch/dbpedia/DbpediaAttribute.java | 23 ++++++ .../dcs/kbsearch/dbpedia/DbpediaEnum.java | 20 +++++ .../dcs/kbsearch/dbpedia/DbpediaSearch.java | 73 +++++++++++++++++++ .../dcs/kbsearch/freebase/FreebaseSearch.java | 3 + 10 files changed, 192 insertions(+), 7 deletions(-) create mode 100644 kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaAttribute.java create mode 100644 kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaEnum.java create mode 100644 kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaSearch.java diff --git a/.gitignore b/.gitignore index 6c23b80f..2c28946a 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,58 @@ cache/empty/relation/data/* cache/empty/websearch/data/* cache/empty/similarity/data/* delete/* + +# ========================= +# Eclipse files +# ========================= + +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.recommenders + +# Eclipse Core +.project + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# PyDev specific (Python IDE for Eclipse) +*.pydevproject + +# CDT-specific (C/C++ Development Tooling) +.cproject + +# JDT-specific (Eclipse Java Development Tools) +.classpath + +# Java annotation processor (APT) +.factorypath + +# PDT-specific (PHP Development Tools) +.buildpath + +# sbteclipse plugin +.target + +# Tern plugin +.tern-project + +# TeXlipse plugin +.texlipse + +# STS (Spring Tool Suite) +.springBeans + +# Code Recommenders +.recommenders/ diff --git a/any23-sti/pom.xml b/any23-sti/pom.xml index 20037c19..5c343fa3 100644 --- a/any23-sti/pom.xml +++ b/any23-sti/pom.xml @@ -55,5 +55,16 @@ - + + + aduna-old-repository + http://maven.ontotext.com/content/repositories/aduna/ + + true + + + true + + + \ No newline at end of file diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_EntityOnly.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_EntityOnly.java index ebb82b29..c1f007c7 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_EntityOnly.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_EntityOnly.java @@ -1,12 +1,12 @@ package uk.ac.shef.dcs.sti.todo.evaluation; -import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; - import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.util.*; +import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; + /** */ diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly.java index 3ffa4e9c..fcb20251 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly.java @@ -1,12 +1,12 @@ package uk.ac.shef.dcs.sti.todo.evaluation; -import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; - import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.util.*; +import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; + /** * Created with IntelliJ IDEA. * User: zqz diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_Analysis_Generic.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_Analysis_Generic.java index 3e0fb95f..45a8b2f4 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_Analysis_Generic.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_Analysis_Generic.java @@ -5,8 +5,8 @@ import uk.ac.shef.dcs.kbsearch.KBSearchException; import uk.ac.shef.dcs.kbsearch.freebase.FreebaseSearch; import uk.ac.shef.dcs.kbsearch.model.Attribute; -import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; import uk.ac.shef.dcs.sti.util.FileUtils; import javax.xml.parsers.DocumentBuilder; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_btw_Baseline_Tm_Finder.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_btw_Baseline_Tm_Finder.java index c7be108b..4ac24f6a 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_btw_Baseline_Tm_Finder.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_btw_Baseline_Tm_Finder.java @@ -4,8 +4,8 @@ import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; import uk.ac.shef.dcs.kbsearch.freebase.FreebaseSearch; import uk.ac.shef.dcs.kbsearch.model.Attribute; -import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; import uk.ac.shef.dcs.sti.util.FileUtils; import java.io.File; diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaAttribute.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaAttribute.java new file mode 100644 index 00000000..83002a76 --- /dev/null +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaAttribute.java @@ -0,0 +1,23 @@ +package uk.ac.shef.dcs.kbsearch.dbpedia; + +import uk.ac.shef.dcs.kbsearch.model.Attribute; + +/** + * Created by Jan on 18.05.2016. + */ +public class DbpediaAttribute extends Attribute { + + public DbpediaAttribute(String relationURI, String value) { + super(relationURI, value); + } + + @Override + public boolean isAlias() { + return getRelationURI().equals(DbpediaEnum.RELATION_HASALIAS.getString()); + } + + @Override + public boolean isDescription() { + return getRelationURI().equals(DbpediaEnum.RELATION_HASDESCRIPTION.getString()); + } +} diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaEnum.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaEnum.java new file mode 100644 index 00000000..18b39ece --- /dev/null +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaEnum.java @@ -0,0 +1,20 @@ +package uk.ac.shef.dcs.kbsearch.dbpedia; + +/** + * Created by Jan on 18.05.2016. + */ +public enum DbpediaEnum { + + RELATION_HASALIAS("http://dbpedia.org/ontology/alias"), + RELATION_HASDESCRIPTION("http://dbpedia.org/ontology/description"); + + private String string; + + DbpediaEnum(String s){ + this.string=s; + } + + public String getString(){ + return string; + } +} diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaSearch.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaSearch.java new file mode 100644 index 00000000..1b74c559 --- /dev/null +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaSearch.java @@ -0,0 +1,73 @@ +package uk.ac.shef.dcs.kbsearch.dbpedia; + +import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; +import uk.ac.shef.dcs.kbsearch.KBSearch; +import uk.ac.shef.dcs.kbsearch.KBSearchException; +import uk.ac.shef.dcs.kbsearch.model.Attribute; +import uk.ac.shef.dcs.kbsearch.model.Entity; + +import java.io.IOException; +import java.util.List; +import java.util.Properties; + +/** + * Created by Jan on 18.05.2016. + */ +public class DbpediaSearch extends KBSearch { + + public DbpediaSearch(Properties properties, Boolean fuzzyKeywords, + EmbeddedSolrServer cacheEntity, EmbeddedSolrServer cacheConcept, + EmbeddedSolrServer cacheProperty, EmbeddedSolrServer cacheSimilarity) throws IOException { + super(fuzzyKeywords, cacheEntity, cacheConcept, cacheProperty,cacheSimilarity); + } + + @Override + public List findEntityCandidates(String content) throws KBSearchException { + return null; + } + + @Override + public List findEntityCandidatesOfTypes(String content, String... types) throws KBSearchException { + return null; + } + + @Override + public List findAttributesOfEntities(Entity ec) throws KBSearchException { + return null; + } + + @Override + public List findAttributesOfClazz(String clazzId) throws KBSearchException { + return null; + } + + @Override + public List findAttributesOfProperty(String propertyId) throws KBSearchException { + return null; + } + + @Override + public double findGranularityOfClazz(String clazz) throws KBSearchException { + return 0; + } + + @Override + public double findEntityClazzSimilarity(String entity_id, String clazz_url) throws KBSearchException { + return 0; + } + + @Override + public void cacheEntityClazztSimilarity(String entity_id, String clazz_url, double score, boolean biDirectional, boolean commit) throws KBSearchException { + + } + + @Override + public void commitChanges() throws KBSearchException { + + } + + @Override + public void closeConnection() throws KBSearchException { + + } +} diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearch.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearch.java index be95d62b..e86f0e03 100644 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearch.java +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearch.java @@ -62,6 +62,7 @@ public List findAttributesOfProperty(String propertyId) throws KBSear } + @SuppressWarnings("unchecked") private List find_matchingEntitiesForTextAndType(String text, String... types) throws KBSearchException { String query = createSolrCacheQuery_findResources(text); ; @@ -171,6 +172,7 @@ private List find_matchingEntitiesForTextAndType(String text, String... and cannot use find_attributes method */ @Override + @SuppressWarnings("unchecked") public List findAttributesOfClazz(String clazz) throws KBSearchException { //return find_triplesForEntity(conceptId); boolean forceQuery = false; @@ -310,6 +312,7 @@ public void cacheEntityClazztSimilarity(String id1, String clazz_url, double sco } } + @SuppressWarnings("unchecked") private List find_attributes(String id, SolrCache cache) throws KBSearchException { if (id.length() == 0) return new ArrayList<>(); From 361ff24809fffdbdbf70811a32453cc692d71da2 Mon Sep 17 00:00:00 2001 From: JanVana Date: Thu, 2 Jun 2016 16:06:49 +0200 Subject: [PATCH 009/211] Extracting calls to DBpedia proxy --- kbsearch/pom.xml | 6 ++ .../kbsearch/dbpedia/DBpediaQueryProxy.java | 24 +++++ .../dbpedia/DBpediaSearchResultFilter.java | 88 +++++++++++++++++++ .../kbsearch/dbpedia/DbpediaAttribute.java | 8 +- 4 files changed, 122 insertions(+), 4 deletions(-) create mode 100644 kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DBpediaQueryProxy.java create mode 100644 kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DBpediaSearchResultFilter.java diff --git a/kbsearch/pom.xml b/kbsearch/pom.xml index c220aed0..e9291f5f 100644 --- a/kbsearch/pom.xml +++ b/kbsearch/pom.xml @@ -74,6 +74,12 @@ 6.0.0 + + org.apache.jena + jena-arq + 3.0.1 + + \ No newline at end of file diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DBpediaQueryProxy.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DBpediaQueryProxy.java new file mode 100644 index 00000000..3205a544 --- /dev/null +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DBpediaQueryProxy.java @@ -0,0 +1,24 @@ +package uk.ac.shef.dcs.kbsearch.dbpedia; + +import uk.ac.shef.dcs.kbsearch.model.Attribute; +import uk.ac.shef.dcs.kbsearch.model.Entity; + +import java.io.IOException; +import java.util.List; + +/** + * Created by Jan on 02.06.2016. + */ +public class DBpediaQueryProxy { + public double find_granularityForType(String clazz) throws IOException { + return -1.0; + } + + public List topicapi_getAttributesOfTopic(String clazzId) { + return null; + } + + public List searchapi_getTopicsByNameAndType(String text, String any, boolean b, int i) { + return null; + } +} diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DBpediaSearchResultFilter.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DBpediaSearchResultFilter.java new file mode 100644 index 00000000..f264bf23 --- /dev/null +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DBpediaSearchResultFilter.java @@ -0,0 +1,88 @@ +package uk.ac.shef.dcs.kbsearch.dbpedia; + +import uk.ac.shef.dcs.kbsearch.KBSearchResultFilter; +import uk.ac.shef.dcs.kbsearch.model.Attribute; +import uk.ac.shef.dcs.kbsearch.model.Clazz; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Set; + +/** + * Created by Jan on 24.05.2016. + */ +public class DBpediaSearchResultFilter extends KBSearchResultFilter { + + public DBpediaSearchResultFilter(String stoplistsFile) throws IOException { + super(stoplistsFile); + } + + public boolean isValidClazz(Clazz c) { + /*if (type.startsWith("/user/") || + type.startsWith("/common/")|| + //type.equals("/common/image") || + *//*type.equals("/type/content") || + type.startsWith("/type/type/domain")||*//* + type.startsWith("/type/")|| + type.endsWith("topic") || type.startsWith("/pipeline/") || + type.endsWith("skos_concept") || + type.endsWith("_instance") || + type.startsWith("/base/type_ontology") + ||label.equalsIgnoreCase("topic")||label.equalsIgnoreCase("thing")||label.equalsIgnoreCase("concept") + ||label.equalsIgnoreCase("things")||label.equalsIgnoreCase("entity")) + return true; + return false;*/ + Set stop = stoplists.get(LABEL_INVALID_CLAZZ); + if (stop == null) + return true; + + for (String s : stop) { + if (c.getId().contains(s) || c.getLabel().equalsIgnoreCase(s)) + return false; + } + return true; + + } + + public List filterClazz(Collection types) { + List r = new ArrayList<>(); + if (types == null) + System.out.println(); + for (Clazz t : types) { + if (!isValidClazz(t)) continue; + r.add(t); + } + return r; + } + + public List filterAttribute(Collection facts) { + List r = new ArrayList<>(); + for (Attribute t : facts) { + if (!isValidAttribute(t)) continue; + r.add(t); + } + return r; + } + + public boolean isValidAttribute(Attribute attribute) { + //here is a list of 'pass' relations that should always be kept as the stoplist can be over-generalising + String rel = attribute.getRelationURI(); + if (rel.startsWith(DBpediaEnum.TYPE_COMMON_TOPIC.getString()) || rel.equals(DBpediaEnum.RELATION_HASTYPE.getString()) + || rel.equals(DBpediaEnum.RELATION_HASNAME.getString())) + return true; + + Set stop = stoplists.get(LABEL_INVALID_ATTRIBUTE); + String relation = attribute.getRelationURI(); + if (stop != null) { + relation = attribute.getRelationURI(); + for (String s : stop) { + if (relation.startsWith(s)) + return false; + } + + } + return !relation.equalsIgnoreCase("id"); + } +} diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaAttribute.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaAttribute.java index 83002a76..93bbb8a5 100644 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaAttribute.java +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaAttribute.java @@ -5,19 +5,19 @@ /** * Created by Jan on 18.05.2016. */ -public class DbpediaAttribute extends Attribute { +public class DBpediaAttribute extends Attribute { - public DbpediaAttribute(String relationURI, String value) { + public DBpediaAttribute(String relationURI, String value) { super(relationURI, value); } @Override public boolean isAlias() { - return getRelationURI().equals(DbpediaEnum.RELATION_HASALIAS.getString()); + return getRelationURI().equals(DBpediaEnum.RELATION_HASALIAS.getString()); } @Override public boolean isDescription() { - return getRelationURI().equals(DbpediaEnum.RELATION_HASDESCRIPTION.getString()); + return getRelationURI().equals(DBpediaEnum.RELATION_HASDESCRIPTION.getString()); } } From e72a84d6488fba15aff3504f4234acbcc03c54d3 Mon Sep 17 00:00:00 2001 From: brodecva Date: Mon, 13 Jun 2016 15:18:52 +0200 Subject: [PATCH 010/211] Odalic project set up This tutorial was used as an inspiration: http://www.codingpedia.org/ama/tutorial-rest-api-design-and-implementation-in-java-with-jersey-and-spring/#2_Configuration For now it uses slightly older libraries, but it should not be problem to fix this in the future. I have tested the deployment in the Tomcat, but no thorough tests for the set up are provided. I have provided empty implementations of the resources in the 1st iteration API. Depending tasks are now clear to go. This closes #7. --- odalic/.gitignore | 2 + odalic/pom.xml | 134 ++++++++++++++++++ .../xrg/odalic/api/rest/Configuration.java | 44 ++++++ .../CustomJsonDateDeserializer.java | 28 ++++ .../conversions/CustomJsonDateSerializer.java | 26 ++++ .../xrg/odalic/api/rest/errors/Message.java | 59 ++++++++ .../api/rest/errors/ThrowableMapper.java | 40 ++++++ .../api/rest/filters/CorsResponseFilter.java | 21 +++ .../rest/filters/LoggingResponseFilter.java | 29 ++++ .../xrg/odalic/feedbacks/ColumnFeedback.java | 36 +++++ .../mff/xrg/odalic/feedbacks/Feedback.java | 35 +++++ .../cz/cuni/mff/xrg/odalic/files/File.java | 72 ++++++++++ .../mff/xrg/odalic/files/FileResource.java | 82 +++++++++++ .../mff/xrg/odalic/files/FileService.java | 21 +++ .../odalic/files/MemoryOnlyFileService.java | 73 ++++++++++ .../cz/cuni/mff/xrg/odalic/tasks/State.java | 14 ++ .../cz/cuni/mff/xrg/odalic/tasks/Task.java | 92 ++++++++++++ .../cuni/mff/xrg/odalic/tasks/TaskDigest.java | 81 +++++++++++ .../mff/xrg/odalic/tasks/TaskResource.java | 82 +++++++++++ .../mff/xrg/odalic/tasks/TaskService.java | 20 +++ .../mff/xrg/odalic/tasks/TaskServiceImpl.java | 47 ++++++ .../tasks/configurations/Configuration.java | 10 ++ .../configurations/ConfigurationResource.java | 20 +++ .../configurations/ConfigurationService.java | 3 + .../ConfigurationServiceImpl.java | 10 ++ .../mff/xrg/odalic/tasks/drafts/Draft.java | 10 ++ .../odalic/tasks/drafts/DraftResource.java | 20 +++ .../xrg/odalic/tasks/drafts/DraftService.java | 7 + .../odalic/tasks/drafts/DraftServiceImpl.java | 10 ++ .../odalic/tasks/executions/Execution.java | 10 ++ .../tasks/executions/ExecutionResource.java | 20 +++ .../tasks/executions/ExecutionService.java | 7 + .../executions/ExecutionServiceImpl.java | 10 ++ .../mff/xrg/odalic/tasks/results/Result.java | 12 ++ .../odalic/tasks/results/ResultResource.java | 20 +++ .../odalic/tasks/results/ResultService.java | 7 + .../tasks/results/ResultServiceImpl.java | 10 ++ odalic/src/main/resources/logback.xml | 23 +++ .../resources/spring/applicationContext.xml | 30 ++++ odalic/src/main/webapp/WEB-INF/web.xml | 34 +++++ 40 files changed, 1311 insertions(+) create mode 100644 odalic/.gitignore create mode 100644 odalic/pom.xml create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateDeserializer.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateSerializer.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/Message.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/ThrowableMapper.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/CorsResponseFilter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/LoggingResponseFilter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnFeedback.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/File.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileResource.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileService.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/MemoryOnlyFileService.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/State.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/Task.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskDigest.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskResource.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskService.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskServiceImpl.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationResource.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationService.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationServiceImpl.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/Draft.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftResource.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftService.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftServiceImpl.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/Execution.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionResource.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionService.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionServiceImpl.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/Result.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultResource.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultService.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultServiceImpl.java create mode 100644 odalic/src/main/resources/logback.xml create mode 100644 odalic/src/main/resources/spring/applicationContext.xml create mode 100644 odalic/src/main/webapp/WEB-INF/web.xml diff --git a/odalic/.gitignore b/odalic/.gitignore new file mode 100644 index 00000000..59ddbdbb --- /dev/null +++ b/odalic/.gitignore @@ -0,0 +1,2 @@ +/.apt_generated/ +/Users \ No newline at end of file diff --git a/odalic/pom.xml b/odalic/pom.xml new file mode 100644 index 00000000..8bc1df86 --- /dev/null +++ b/odalic/pom.xml @@ -0,0 +1,134 @@ + + 4.0.0 + cz.cuni.mff.odalic + odalic + 0.0.1-SNAPSHOT + war + Odalic + Odalic server + + + 1.8 + 1.7.6 + 2.8 + 9.0.7.v20131107 + 1.1.1 + 4.0.3.RELEASE + + + + + Apache 2.0 + http://www.apache.org/licenses/LICENSE-2.0 + + + + + + maven2-repository.java.net + Java.net Repository for Maven + http://download.java.net/maven/2/ + + + + + + + uk.ac.shef.dcs + sti + 1.0alpha + + + + + org.glassfish.jersey.ext + jersey-spring3 + ${jersey.version} + + + org.springframework + spring-core + + + org.springframework + spring-web + + + org.springframework + spring-beans + + + + + org.glassfish.jersey.media + jersey-media-json-jackson + ${jersey.version} + + + org.glassfish.jersey.media + jersey-media-multipart + ${jersey.version} + + + org.glassfish.jersey.ext + jersey-entity-filtering + ${jersey.version} + + + + + org.springframework + spring-core + ${spring.version} + + + org.springframework + spring-context + ${spring.version} + + + commons-logging + commons-logging + + + + + org.springframework + spring-web + ${spring.version} + + + org.springframework + spring-tx + ${spring.version} + + + + + ch.qos.logback + logback-classic + ${logback.version} + + + org.slf4j + jcl-over-slf4j + ${jcloverslf4j.version} + + + + + + + true + org.apache.maven.plugins + maven-compiler-plugin + + ${java.version} + ${java.version} + UTF-8 + + + + + \ No newline at end of file diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java new file mode 100644 index 00000000..2cc50610 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java @@ -0,0 +1,44 @@ +/** + * + */ +package cz.cuni.mff.xrg.odalic.api.rest; + +import org.glassfish.jersey.jackson.JacksonFeature; +import org.glassfish.jersey.media.multipart.MultiPartFeature; +import org.glassfish.jersey.server.ResourceConfig; +import org.glassfish.jersey.server.spring.scope.RequestContextFilter; + +import cz.cuni.mff.xrg.odalic.api.rest.errors.ThrowableMapper; +import cz.cuni.mff.xrg.odalic.api.rest.filters.CorsResponseFilter; +import cz.cuni.mff.xrg.odalic.api.rest.filters.LoggingResponseFilter; +import cz.cuni.mff.xrg.odalic.files.FileResource; +import cz.cuni.mff.xrg.odalic.tasks.TaskResource; +import cz.cuni.mff.xrg.odalic.tasks.configurations.ConfigurationResource; +import cz.cuni.mff.xrg.odalic.tasks.drafts.DraftResource; +import cz.cuni.mff.xrg.odalic.tasks.executions.ExecutionResource; +import cz.cuni.mff.xrg.odalic.tasks.results.ResultResource; + +public final class Configuration extends ResourceConfig { + + public Configuration() { + // Resources registration + register(FileResource.class); + register(TaskResource.class); + register(ConfigurationResource.class); + register(DraftResource.class); + register(ExecutionResource.class); + register(ResultResource.class); + + // Filters registration + register(RequestContextFilter.class); + register(LoggingResponseFilter.class); + register(CorsResponseFilter.class); + + // Exception mappers registration + register(ThrowableMapper.class); + + // Features registration + register(JacksonFeature.class); + register(MultiPartFeature.class); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateDeserializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateDeserializer.java new file mode 100644 index 00000000..7ff89c92 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateDeserializer.java @@ -0,0 +1,28 @@ +package cz.cuni.mff.xrg.odalic.api.rest.conversions; + +import java.io.IOException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.codehaus.jackson.JsonParser; +import org.codehaus.jackson.JsonProcessingException; +import org.codehaus.jackson.map.DeserializationContext; +import org.codehaus.jackson.map.JsonDeserializer; + +public class CustomJsonDateDeserializer extends JsonDeserializer { + + @Override + public Date deserialize(JsonParser jsonparser, DeserializationContext context) + throws IOException, JsonProcessingException { + + SimpleDateFormat format = new SimpleDateFormat(CustomJsonDateSerializer.DATE_FORMAT); + String date = jsonparser.getText(); + try { + return format.parse(date); + } catch (ParseException e) { + throw new RuntimeException(e); + } + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateSerializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateSerializer.java new file mode 100644 index 00000000..1dcd6710 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateSerializer.java @@ -0,0 +1,26 @@ +package cz.cuni.mff.xrg.odalic.api.rest.conversions; + +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.codehaus.jackson.JsonGenerator; +import org.codehaus.jackson.JsonProcessingException; +import org.codehaus.jackson.map.JsonSerializer; +import org.codehaus.jackson.map.SerializerProvider; + +public class CustomJsonDateSerializer extends JsonSerializer { + + public static final String DATE_FORMAT = "dd-MM-yyyy HH:mm"; + + @Override + public void serialize(Date value, JsonGenerator jgen, + SerializerProvider provider) throws IOException, + JsonProcessingException { + + SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); + String dateString = dateFormat.format(value); + jgen.writeString(dateString); + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/Message.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/Message.java new file mode 100644 index 00000000..3e7a006e --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/Message.java @@ -0,0 +1,59 @@ +package cz.cuni.mff.xrg.odalic.api.rest.errors; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + + +@XmlRootElement +public class Message { + + @XmlElement(name = "status") + int status; + + @XmlElement(name = "text") + String text; + + @XmlElement(name = "link") + String link; + + @XmlElement(name = "developerText") + String developerText; + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public String getDeveloperText() { + return developerText; + } + + public void setDeveloperText(String developerText) { + this.developerText = developerText; + } + + public String getLink() { + return link; + } + + public void setLink(String link) { + this.link = link; + } + + public Message() {} + + public Message(int status) { + this.status = status; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/ThrowableMapper.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/ThrowableMapper.java new file mode 100644 index 00000000..a68f4dbb --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/ThrowableMapper.java @@ -0,0 +1,40 @@ +package cz.cuni.mff.xrg.odalic.api.rest.errors; + +import java.io.PrintWriter; +import java.io.StringWriter; + +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.ExceptionMapper; + +public class ThrowableMapper implements ExceptionMapper { + + public Response toResponse(Throwable throwable) { + Message errorMessage = new Message(getHttpStatus(throwable)); + + errorMessage.setText(throwable.getMessage()); + + StringWriter trace = new StringWriter(); + throwable.printStackTrace(new PrintWriter(trace)); + errorMessage.setDeveloperText(trace.toString()); + + return Response.status(errorMessage.getStatus()).entity(errorMessage) + .type(MediaType.APPLICATION_JSON).build(); + } + + /** + * Defaults to internal server error in case the exception is not instance of {@link WebApplicationException}. + * + * @param throwable throwable instance + * @return HTTP status code + */ + private int getHttpStatus(Throwable throwable) { + if (throwable instanceof WebApplicationException) { + return ((WebApplicationException) throwable).getResponse().getStatus(); + } else { + return Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(); + } + } +} + diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/CorsResponseFilter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/CorsResponseFilter.java new file mode 100644 index 00000000..6b7e43d8 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/CorsResponseFilter.java @@ -0,0 +1,21 @@ +package cz.cuni.mff.xrg.odalic.api.rest.filters; + +import java.io.IOException; + +import javax.ws.rs.container.ContainerRequestContext; +import javax.ws.rs.container.ContainerResponseContext; +import javax.ws.rs.container.ContainerResponseFilter; +import javax.ws.rs.core.MultivaluedMap; + +public class CorsResponseFilter implements ContainerResponseFilter { + + public void filter(ContainerRequestContext requestContext, + ContainerResponseContext responseContext) throws IOException { + MultivaluedMap headers = responseContext.getHeaders(); + + headers.add("Access-Control-Allow-Origin", "*"); + headers.add("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); + headers.add("Access-Control-Allow-Headers", "X-Requested-With, Content-Type, X-Odalic"); + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/LoggingResponseFilter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/LoggingResponseFilter.java new file mode 100644 index 00000000..5167a84f --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/LoggingResponseFilter.java @@ -0,0 +1,29 @@ +package cz.cuni.mff.xrg.odalic.api.rest.filters; + +import java.io.IOException; + +import javax.ws.rs.container.ContainerRequestContext; +import javax.ws.rs.container.ContainerResponseContext; +import javax.ws.rs.container.ContainerResponseFilter; + +import org.codehaus.jackson.map.ObjectMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class LoggingResponseFilter + implements ContainerResponseFilter { + + private static final Logger logger = LoggerFactory.getLogger(LoggingResponseFilter.class); + + public void filter(ContainerRequestContext requestContext, + ContainerResponseContext responseContext) throws IOException { + String method = requestContext.getMethod(); + + logger.debug("Requesting " + method + " for path " + requestContext.getUriInfo().getPath()); + Object entity = responseContext.getEntity(); + if (entity != null) { + logger.debug("Response " + new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(entity)); + } + } + +} \ No newline at end of file diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnFeedback.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnFeedback.java new file mode 100644 index 00000000..f6b2e5b8 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnFeedback.java @@ -0,0 +1,36 @@ +package cz.cuni.mff.xrg.odalic.feedbacks; + +import java.io.Serializable; +import java.net.URI; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class ColumnFeedback implements Serializable { + + private static final long serialVersionUID = -9087389821835847372L; + + @XmlElement(name = "index") + private int index; + + @XmlElement(name = "suggestions") + private Set suggestions; + + public int getIndex() { + return index; + } + + public void setIndex(int index) { + this.index = index; + } + + public Set getSuggestions() { + return suggestions; + } + + public void setSuggestions(Set suggestions) { + this.suggestions = suggestions; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java new file mode 100644 index 00000000..ac56d3f6 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java @@ -0,0 +1,35 @@ +package cz.cuni.mff.xrg.odalic.feedbacks; + +import java.io.Serializable; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class Feedback implements Serializable { + + private static final long serialVersionUID = -6359038623760039155L; + + @XmlElement(name = "subjectColumnIndex") + private int subjectColumnIndex; + + @XmlElement(name = "columns") + private Set columns; + + public int getSubjectColumnIndex() { + return subjectColumnIndex; + } + + public void setSubjectColumnIndex(int subjectColumnIndex) { + this.subjectColumnIndex = subjectColumnIndex; + } + + public Set getColumns() { + return columns; + } + + public void setColumns(Set columns) { + this.columns = columns; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/File.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/File.java new file mode 100644 index 00000000..c0c93b77 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/File.java @@ -0,0 +1,72 @@ +package cz.cuni.mff.xrg.odalic.files; + +import java.io.Serializable; +import java.util.Date; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.codehaus.jackson.map.annotate.JsonDeserialize; +import org.codehaus.jackson.map.annotate.JsonSerialize; + +import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateSerializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateDeserializer; + +@XmlRootElement +public class File implements Serializable { + + private static final long serialVersionUID = -6359038623760039155L; + + @XmlElement(name = "id") + private String id; + + @JsonSerialize(using = CustomJsonDateSerializer.class) + @JsonDeserialize(using = CustomJsonDateDeserializer.class) + @XmlElement(name = "uploaded") + private Date uploaded; + + @XmlElement(name = "format") + private String format; + + @XmlElement(name = "owner") + private String owner; + + public File(String id, Date uploaded, String format, String owner) { + this.id = id; + this.uploaded = uploaded; + this.format = format; + this.owner = owner; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Date getUploaded() { + return uploaded; + } + + public void setUploaded(Date uploaded) { + this.uploaded = uploaded; + } + + public String getFormat() { + return format; + } + + public void setFormat(String format) { + this.format = format; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileResource.java new file mode 100644 index 00000000..65101d01 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileResource.java @@ -0,0 +1,82 @@ +package cz.cuni.mff.xrg.odalic.files; + +import java.util.List; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * File resource definition. + * + * @author Václav Brodec + */ +@Component +@Path("/files") +public class FileResource { + + private FileService fileService; + + @GET + @Produces(MediaType.APPLICATION_JSON) + public List getFiles() { + return fileService.getFiles(); + } + + @GET + @Path("{id}") + @Produces(MediaType.APPLICATION_JSON) + public Response getFileById(@PathParam("id") String id) { + File file = fileService.getById(id); + return Response.status(Response.Status.OK).entity(file).build(); + } + + @PUT + @Path("{id}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response putFileById(@PathParam("id") String id, File file) { + if (!fileService.hasId(file, id)) { + return Response.status(Response.Status.NOT_ACCEPTABLE) + .entity("The ID in the payload is not the same as the ID of resource.").build(); + } + + File fileById = fileService.verifyFileExistenceById(id); + + if (fileById == null) { + fileService.create(file); + return Response.status(Response.Status.CREATED) + .entity("A new file has been created AT THE LOCATION you specified") + .header("Location", "/files/" + String.valueOf(id)).build(); + } else { + fileService.replace(file); + return Response.status(Response.Status.OK) + .entity( + "The file you specified has been fully updated AT THE LOCATION you specified.") + .header("Location", "/files/" + String.valueOf(id)).build(); + } + } + + @DELETE + @Path("{id}") + @Produces({MediaType.APPLICATION_JSON}) + public Response deleteFileById(@PathParam("id") String id) { + fileService.deleteById(id); + return Response.status(Response.Status.NO_CONTENT) + .entity("File successfully removed from database").build(); + } + + @Autowired + public FileResource(FileService fileService) { + this.fileService = fileService; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileService.java new file mode 100644 index 00000000..48c696e7 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileService.java @@ -0,0 +1,21 @@ +package cz.cuni.mff.xrg.odalic.files; + +import java.util.List; + +public interface FileService { + + void create(File file); + + void deleteById(String id); + + File getById(String id); + + List getFiles(); + + void replace(File file); + + File verifyFileExistenceById(String id); + + boolean hasId(File file, String id); + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/MemoryOnlyFileService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/MemoryOnlyFileService.java new file mode 100644 index 00000000..2afbed45 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/MemoryOnlyFileService.java @@ -0,0 +1,73 @@ +/** + * + */ +package cz.cuni.mff.xrg.odalic.files; + +import java.util.Collections; +import java.util.List; + +/** + * @author Václav Brodec + * + */ +public final class MemoryOnlyFileService implements FileService { + + public MemoryOnlyFileService() {} + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.files.FileService#create(cz.cuni.mff.xrg.odalic.files.File) + */ + public void create(File file) { + // TODO Auto-generated method stub + } + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.files.FileService#deleteById(java.lang.String) + */ + public void deleteById(String id) { + // TODO Auto-generated method stub + } + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.files.FileService#getById(java.lang.String) + */ + public File getById(String id) { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.files.FileService#getFiles() + */ + public List getFiles() { + // TODO Auto-generated method stub + return Collections.emptyList(); + } + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.files.FileService#replace(cz.cuni.mff.xrg.odalic.files.File) + */ + public void replace(File file) { + // TODO Auto-generated method stub + } + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.files.FileService#verifyFileExistenceById(java.lang.String) + */ + public File verifyFileExistenceById(String id) { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.files.FileService#hasId(cz.cuni.mff.xrg.odalic.files.File, java.lang.String) + */ + public boolean hasId(File file, String id) { + if (file.getId() == null) { + return false; + } + + return file.getId().equals(id); + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/State.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/State.java new file mode 100644 index 00000000..42842d00 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/State.java @@ -0,0 +1,14 @@ +package cz.cuni.mff.xrg.odalic.tasks; + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; +import javax.xml.bind.annotation.XmlType; + +@XmlType +@XmlEnum(Integer.class) +public enum State { + @XmlEnumValue("1") READY, + @XmlEnumValue("2") RUNNING, + @XmlEnumValue("3") CANCELED, + @XmlEnumValue("4") FINISHED +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/Task.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/Task.java new file mode 100644 index 00000000..2dc45118 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/Task.java @@ -0,0 +1,92 @@ +package cz.cuni.mff.xrg.odalic.tasks; + +import java.io.Serializable; +import java.net.URL; +import java.util.Date; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.codehaus.jackson.map.annotate.JsonDeserialize; +import org.codehaus.jackson.map.annotate.JsonSerialize; + +import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateDeserializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateSerializer; +import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; +import cz.cuni.mff.xrg.odalic.tasks.results.Result; + +@XmlRootElement +public class Task implements Serializable { + + private static final long serialVersionUID = 1610346823333685091L; + + @XmlElement(name = "id") + private String id; + + @JsonSerialize(using = CustomJsonDateSerializer.class) + @JsonDeserialize(using = CustomJsonDateDeserializer.class) + @XmlElement(name = "created") + private Date created; + + @XmlElement(name = "input") + private URL input; + + @XmlElement(name = "feedback") + private Feedback feedback; + + @XmlElement(name = "state") + private State state; + + @XmlElement(name = "result") + private Result result; + + public Task() {} + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Date getCreated() { + return created; + } + + public void setCreated(Date created) { + this.created = created; + } + + public URL getInput() { + return input; + } + + public void setInput(URL input) { + this.input = input; + } + + public Feedback getFeedback() { + return feedback; + } + + public void setFeedback(Feedback feedback) { + this.feedback = feedback; + } + + public State getState() { + return state; + } + + public void setState(State state) { + this.state = state; + } + + public Result getResult() { + return result; + } + + public void setResult(Result result) { + this.result = result; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskDigest.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskDigest.java new file mode 100644 index 00000000..7e52036a --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskDigest.java @@ -0,0 +1,81 @@ +package cz.cuni.mff.xrg.odalic.tasks; + +import java.io.Serializable; +import java.net.URL; +import java.util.Date; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.codehaus.jackson.map.annotate.JsonDeserialize; +import org.codehaus.jackson.map.annotate.JsonSerialize; + +import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateDeserializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateSerializer; +import cz.cuni.mff.xrg.odalic.tasks.results.Result; + + +@XmlRootElement +public class TaskDigest implements Serializable { + + private static final long serialVersionUID = 1610346823333685091L; + + @XmlElement(name = "id") + private String id; + + @JsonSerialize(using = CustomJsonDateSerializer.class) + @JsonDeserialize(using = CustomJsonDateDeserializer.class) + @XmlElement(name = "created") + private Date created; + + @XmlElement(name = "input") + private URL input; + + @XmlElement(name = "state") + private State state; + + @XmlElement(name = "result") + private Result result; + + public TaskDigest() {} + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Date getCreated() { + return created; + } + + public void setCreated(Date created) { + this.created = created; + } + + public URL getInput() { + return input; + } + + public void setInput(URL input) { + this.input = input; + } + + public State getState() { + return state; + } + + public void setState(State state) { + this.state = state; + } + + public Result getResult() { + return result; + } + + public void setResult(Result result) { + this.result = result; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskResource.java new file mode 100644 index 00000000..d2755fef --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskResource.java @@ -0,0 +1,82 @@ +package cz.cuni.mff.xrg.odalic.tasks; + +import java.util.List; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * Task resource definition. + * + * @author Václav Brodec + */ +@Component +@Path("/tasks") +public class TaskResource { + + private TaskService taskService; + + @GET + @Produces(MediaType.APPLICATION_JSON) + public List getTasks() { + return taskService.getTasks(); + } + + @GET + @Path("/tasks/{id}") + @Produces(MediaType.APPLICATION_JSON) + public Response getTaskById(@PathParam("id") String id) { + Task task = taskService.getById(id); + return Response.status(Response.Status.OK).entity(task).build(); + } + + @PUT + @Path("/tasks/{id}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response putTaskById(@PathParam("id") String id, Task task) { + if (!taskService.hasId(task, id)) { + return Response.status(Response.Status.NOT_ACCEPTABLE) + .entity("The ID in the payload is not the same as the ID of resource.").build(); + } + + Task taskById = taskService.verifyTaskExistenceById(id); + + if (taskById == null) { + taskService.create(task); + return Response.status(Response.Status.CREATED) + .entity("A new task has been created AT THE LOCATION you specified") + .header("Location", "/tasks/" + String.valueOf(id)).build(); + } else { + taskService.replace(task); + return Response.status(Response.Status.OK) + .entity( + "The task you specified has been fully updated AT THE LOCATION you specified.") + .header("Location", "/tasks/" + String.valueOf(id)).build(); + } + } + + @DELETE + @Path("/tasks/{id}") + @Produces({MediaType.APPLICATION_JSON}) + public Response deleteTaskById(@PathParam("id") String id) { + taskService.deleteById(id); + return Response.status(Response.Status.NO_CONTENT) + .entity("Task successfully removed from database").build(); + } + + @Autowired + public TaskResource(TaskService taskService) { + this.taskService = taskService; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskService.java new file mode 100644 index 00000000..75cfc494 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskService.java @@ -0,0 +1,20 @@ +package cz.cuni.mff.xrg.odalic.tasks; + +import java.util.List; + +public interface TaskService { + + List getTasks(); + + Task getById(String id); + + boolean hasId(Task task, String id); + + void deleteById(String id); + + Task verifyTaskExistenceById(String id); + + void create(Task task); + + void replace(Task task); +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskServiceImpl.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskServiceImpl.java new file mode 100644 index 00000000..696507e8 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskServiceImpl.java @@ -0,0 +1,47 @@ +package cz.cuni.mff.xrg.odalic.tasks; + +import java.util.Collections; +import java.util.List; + +/** + * @author Václav Brodec + * + */ +public final class TaskServiceImpl implements TaskService { + + public TaskServiceImpl() {} + + public List getTasks() { + return Collections.emptyList(); + } + + public Task getById(String id) { + // TODO Auto-generated method stub + return null; + } + + public boolean hasId(Task task, String id) { + if (task.getId() == null) { + return false; + } + + return task.getId().equals(id); + } + + public void deleteById(String id) { + // TODO Auto-generated method stub + } + + public Task verifyTaskExistenceById(String id) { + // TODO Auto-generated method stub + return null; + } + + public void create(Task task) { + // TODO Auto-generated method stub + } + + public void replace(Task task) { + // TODO Auto-generated method stub + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java new file mode 100644 index 00000000..1d6a5ff7 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java @@ -0,0 +1,10 @@ +package cz.cuni.mff.xrg.odalic.tasks.configurations; + +import java.io.Serializable; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class Configuration implements Serializable { + + private static final long serialVersionUID = -6359038623760039155L; +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationResource.java new file mode 100644 index 00000000..6ca78745 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationResource.java @@ -0,0 +1,20 @@ +package cz.cuni.mff.xrg.odalic.tasks.configurations; + +import javax.ws.rs.Path; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +@Path("/tasks/{id}/configuration") +public class ConfigurationResource { + + @SuppressWarnings("unused") + private ConfigurationService configurationService; + + //TODO: Methods. + + @Autowired + public ConfigurationResource(ConfigurationService configurationService) { + this.configurationService = configurationService; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationService.java new file mode 100644 index 00000000..e7d58b3c --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationService.java @@ -0,0 +1,3 @@ +package cz.cuni.mff.xrg.odalic.tasks.configurations; + +public interface ConfigurationService {} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationServiceImpl.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationServiceImpl.java new file mode 100644 index 00000000..b3574ec2 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationServiceImpl.java @@ -0,0 +1,10 @@ +/** + * + */ +package cz.cuni.mff.xrg.odalic.tasks.configurations; + +/** + * @author Václav Brodec + * + */ +public final class ConfigurationServiceImpl implements ConfigurationService {} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/Draft.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/Draft.java new file mode 100644 index 00000000..14781e55 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/Draft.java @@ -0,0 +1,10 @@ +package cz.cuni.mff.xrg.odalic.tasks.drafts; + +import java.io.Serializable; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class Draft implements Serializable { + + private static final long serialVersionUID = -6359038623760039155L; +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftResource.java new file mode 100644 index 00000000..83fe6d53 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftResource.java @@ -0,0 +1,20 @@ +package cz.cuni.mff.xrg.odalic.tasks.drafts; + +import javax.ws.rs.Path; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +@Path("/tasks/{id}/draft") +public class DraftResource { + + @SuppressWarnings("unused") + private DraftService draftService; + + //TODO: Methods. + + @Autowired + public DraftResource(DraftService draftService) { + this.draftService = draftService; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftService.java new file mode 100644 index 00000000..40c841f5 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftService.java @@ -0,0 +1,7 @@ +package cz.cuni.mff.xrg.odalic.tasks.drafts; + +public interface DraftService { + + + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftServiceImpl.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftServiceImpl.java new file mode 100644 index 00000000..31ffa103 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftServiceImpl.java @@ -0,0 +1,10 @@ +/** + * + */ +package cz.cuni.mff.xrg.odalic.tasks.drafts; + +/** + * @author Václav Brodec + * + */ +public final class DraftServiceImpl implements DraftService {} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/Execution.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/Execution.java new file mode 100644 index 00000000..259d0227 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/Execution.java @@ -0,0 +1,10 @@ +package cz.cuni.mff.xrg.odalic.tasks.executions; + +import java.io.Serializable; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class Execution implements Serializable { + + private static final long serialVersionUID = -6359038623760039155L; +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionResource.java new file mode 100644 index 00000000..2311aaae --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionResource.java @@ -0,0 +1,20 @@ +package cz.cuni.mff.xrg.odalic.tasks.executions; + +import javax.ws.rs.Path; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +@Path("/tasks/{id}/execution") +public class ExecutionResource { + + @SuppressWarnings("unused") + private ExecutionService executionService; + + // TODO: Methods. + + @Autowired + public ExecutionResource(ExecutionService executionService) { + this.executionService = executionService; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionService.java new file mode 100644 index 00000000..8c2d247a --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionService.java @@ -0,0 +1,7 @@ +package cz.cuni.mff.xrg.odalic.tasks.executions; + +public interface ExecutionService { + + + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionServiceImpl.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionServiceImpl.java new file mode 100644 index 00000000..a685136f --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionServiceImpl.java @@ -0,0 +1,10 @@ +/** + * + */ +package cz.cuni.mff.xrg.odalic.tasks.executions; + +/** + * @author Václav Brodec + * + */ +public final class ExecutionServiceImpl implements ExecutionService {} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/Result.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/Result.java new file mode 100644 index 00000000..e149983e --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/Result.java @@ -0,0 +1,12 @@ +package cz.cuni.mff.xrg.odalic.tasks.results; + +import java.io.Serializable; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class Result implements Serializable { + + private static final long serialVersionUID = -6359038623760039155L; + + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultResource.java new file mode 100644 index 00000000..ab8c6f67 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultResource.java @@ -0,0 +1,20 @@ +package cz.cuni.mff.xrg.odalic.tasks.results; + +import javax.ws.rs.Path; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +@Path("/tasks/{id}/result") +public class ResultResource { + + @SuppressWarnings("unused") + private ResultService resultService; + + //TODO: Methods. + + @Autowired + public ResultResource(ResultService resultService) { + this.resultService = resultService; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultService.java new file mode 100644 index 00000000..59acd7cc --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultService.java @@ -0,0 +1,7 @@ +package cz.cuni.mff.xrg.odalic.tasks.results; + +public interface ResultService { + + + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultServiceImpl.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultServiceImpl.java new file mode 100644 index 00000000..45fdcea9 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultServiceImpl.java @@ -0,0 +1,10 @@ +/** + * + */ +package cz.cuni.mff.xrg.odalic.tasks.results; + +/** + * @author Václav Brodec + * + */ +public final class ResultServiceImpl implements ResultService {} diff --git a/odalic/src/main/resources/logback.xml b/odalic/src/main/resources/logback.xml new file mode 100644 index 00000000..671d8e1a --- /dev/null +++ b/odalic/src/main/resources/logback.xml @@ -0,0 +1,23 @@ + + + + + + .%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg %n + + + + TRACE + + + + + + + + + + + + + \ No newline at end of file diff --git a/odalic/src/main/resources/spring/applicationContext.xml b/odalic/src/main/resources/spring/applicationContext.xml new file mode 100644 index 00000000..76e19bc2 --- /dev/null +++ b/odalic/src/main/resources/spring/applicationContext.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/odalic/src/main/webapp/WEB-INF/web.xml b/odalic/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 00000000..157dc937 --- /dev/null +++ b/odalic/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,34 @@ + + + Demo - Restful Web Application + + + + org.springframework.web.context.ContextLoaderListener + + + + + contextConfigLocation + classpath:spring/applicationContext.xml + + + + jersey-servlet + + org.glassfish.jersey.servlet.ServletContainer + + + javax.ws.rs.Application + cz.cuni.mff.xrg.odalic.api.rest.Configuration + + 1 + + + + jersey-servlet + /* + + \ No newline at end of file From 7f1be0f2c04bb423b4662161a076d6d035149fd0 Mon Sep 17 00:00:00 2001 From: brodecva Date: Mon, 13 Jun 2016 15:36:17 +0200 Subject: [PATCH 011/211] File .travis.yml added. This should suffice to integrate with Travis CI and closes #57. --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..86a0aa42 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,3 @@ +## Travis build file + +language: java From ef9719e3017ee5814377ad16807391d043b2fb91 Mon Sep 17 00:00:00 2001 From: brodecva Date: Mon, 13 Jun 2016 15:43:47 +0200 Subject: [PATCH 012/211] Fix of the .travis.yml location. --- .travis.yml => odalic/.travis.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .travis.yml => odalic/.travis.yml (100%) diff --git a/.travis.yml b/odalic/.travis.yml similarity index 100% rename from .travis.yml rename to odalic/.travis.yml From ae056cc7b0c50ef2c7ced5931608893a808f29f6 Mon Sep 17 00:00:00 2001 From: brodecva Date: Mon, 13 Jun 2016 16:00:45 +0200 Subject: [PATCH 013/211] Added cd instruction to .travis.yml --- odalic/.travis.yml => .travis.yml | 1 + 1 file changed, 1 insertion(+) rename odalic/.travis.yml => .travis.yml (59%) diff --git a/odalic/.travis.yml b/.travis.yml similarity index 59% rename from odalic/.travis.yml rename to .travis.yml index 86a0aa42..313e5769 100644 --- a/odalic/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ ## Travis build file language: java +before_script: cd odalic From f950939865b2f4d203f973ccbc054803de0593fb Mon Sep 17 00:00:00 2001 From: JanVana Date: Wed, 15 Jun 2016 18:01:52 +0200 Subject: [PATCH 014/211] Autocorrection of line endings removed --- .gitattributes | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/.gitattributes b/.gitattributes index bdb0cabc..22b3b40c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,17 +1,14 @@ -# Auto detect text files and perform LF normalization -* text=auto - -# Custom for Visual Studio -*.cs diff=csharp - -# Standard to msysgit -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain +# Custom for Visual Studio +*.cs diff=csharp + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain From 217c87136c40724cfd55e3727f4fbe0c4c4d1d76 Mon Sep 17 00:00:00 2001 From: JanVana Date: Wed, 15 Jun 2016 18:15:22 +0200 Subject: [PATCH 015/211] Revert "Autocorrection of line endings removed" This reverts commit f950939865b2f4d203f973ccbc054803de0593fb. --- .gitattributes | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/.gitattributes b/.gitattributes index 22b3b40c..bdb0cabc 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,14 +1,17 @@ -# Custom for Visual Studio -*.cs diff=csharp - -# Standard to msysgit -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain +# Auto detect text files and perform LF normalization +* text=auto + +# Custom for Visual Studio +*.cs diff=csharp + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain From c87ca2df823c874d660d5fa146a5734737e3b7fc Mon Sep 17 00:00:00 2001 From: JanVana Date: Wed, 15 Jun 2016 18:16:51 +0200 Subject: [PATCH 016/211] Odalic - fix of line ending --- odalic/pom.xml | 266 +++++++++--------- .../xrg/odalic/api/rest/Configuration.java | 88 +++--- .../CustomJsonDateDeserializer.java | 56 ++-- .../conversions/CustomJsonDateSerializer.java | 52 ++-- .../xrg/odalic/api/rest/errors/Message.java | 118 ++++---- .../api/rest/errors/ThrowableMapper.java | 80 +++--- .../api/rest/filters/CorsResponseFilter.java | 42 +-- .../rest/filters/LoggingResponseFilter.java | 56 ++-- .../xrg/odalic/feedbacks/ColumnFeedback.java | 72 ++--- .../mff/xrg/odalic/feedbacks/Feedback.java | 70 ++--- .../cz/cuni/mff/xrg/odalic/files/File.java | 144 +++++----- .../mff/xrg/odalic/files/FileResource.java | 164 +++++------ .../mff/xrg/odalic/files/FileService.java | 42 +-- .../odalic/files/MemoryOnlyFileService.java | 146 +++++----- .../cz/cuni/mff/xrg/odalic/tasks/State.java | 28 +- .../cz/cuni/mff/xrg/odalic/tasks/Task.java | 184 ++++++------ .../cuni/mff/xrg/odalic/tasks/TaskDigest.java | 162 +++++------ .../mff/xrg/odalic/tasks/TaskResource.java | 164 +++++------ .../mff/xrg/odalic/tasks/TaskService.java | 40 +-- .../mff/xrg/odalic/tasks/TaskServiceImpl.java | 94 +++---- .../tasks/configurations/Configuration.java | 20 +- .../configurations/ConfigurationResource.java | 40 +-- .../configurations/ConfigurationService.java | 6 +- .../ConfigurationServiceImpl.java | 20 +- .../mff/xrg/odalic/tasks/drafts/Draft.java | 20 +- .../odalic/tasks/drafts/DraftResource.java | 40 +-- .../xrg/odalic/tasks/drafts/DraftService.java | 14 +- .../odalic/tasks/drafts/DraftServiceImpl.java | 20 +- .../odalic/tasks/executions/Execution.java | 20 +- .../tasks/executions/ExecutionResource.java | 40 +-- .../tasks/executions/ExecutionService.java | 14 +- .../executions/ExecutionServiceImpl.java | 20 +- .../mff/xrg/odalic/tasks/results/Result.java | 24 +- .../odalic/tasks/results/ResultResource.java | 40 +-- .../odalic/tasks/results/ResultService.java | 14 +- .../tasks/results/ResultServiceImpl.java | 20 +- odalic/src/main/resources/logback.xml | 44 +-- .../resources/spring/applicationContext.xml | 58 ++-- odalic/src/main/webapp/WEB-INF/web.xml | 66 ++--- 39 files changed, 1304 insertions(+), 1304 deletions(-) diff --git a/odalic/pom.xml b/odalic/pom.xml index 8bc1df86..94988b9d 100644 --- a/odalic/pom.xml +++ b/odalic/pom.xml @@ -1,134 +1,134 @@ - - 4.0.0 - cz.cuni.mff.odalic - odalic - 0.0.1-SNAPSHOT - war - Odalic - Odalic server - - - 1.8 - 1.7.6 - 2.8 - 9.0.7.v20131107 - 1.1.1 - 4.0.3.RELEASE - - - - - Apache 2.0 - http://www.apache.org/licenses/LICENSE-2.0 - - - - - - maven2-repository.java.net - Java.net Repository for Maven - http://download.java.net/maven/2/ - - - - - - - uk.ac.shef.dcs - sti - 1.0alpha - - - - - org.glassfish.jersey.ext - jersey-spring3 - ${jersey.version} - - - org.springframework - spring-core - - - org.springframework - spring-web - - - org.springframework - spring-beans - - - - - org.glassfish.jersey.media - jersey-media-json-jackson - ${jersey.version} - - - org.glassfish.jersey.media - jersey-media-multipart - ${jersey.version} - - - org.glassfish.jersey.ext - jersey-entity-filtering - ${jersey.version} - - - - - org.springframework - spring-core - ${spring.version} - - - org.springframework - spring-context - ${spring.version} - - - commons-logging - commons-logging - - - - - org.springframework - spring-web - ${spring.version} - - - org.springframework - spring-tx - ${spring.version} - - - - - ch.qos.logback - logback-classic - ${logback.version} - - - org.slf4j - jcl-over-slf4j - ${jcloverslf4j.version} - - - - - - - true - org.apache.maven.plugins - maven-compiler-plugin - - ${java.version} - ${java.version} - UTF-8 - - - - + + 4.0.0 + cz.cuni.mff.odalic + odalic + 0.0.1-SNAPSHOT + war + Odalic + Odalic server + + + 1.8 + 1.7.6 + 2.8 + 9.0.7.v20131107 + 1.1.1 + 4.0.3.RELEASE + + + + + Apache 2.0 + http://www.apache.org/licenses/LICENSE-2.0 + + + + + + maven2-repository.java.net + Java.net Repository for Maven + http://download.java.net/maven/2/ + + + + + + + uk.ac.shef.dcs + sti + 1.0alpha + + + + + org.glassfish.jersey.ext + jersey-spring3 + ${jersey.version} + + + org.springframework + spring-core + + + org.springframework + spring-web + + + org.springframework + spring-beans + + + + + org.glassfish.jersey.media + jersey-media-json-jackson + ${jersey.version} + + + org.glassfish.jersey.media + jersey-media-multipart + ${jersey.version} + + + org.glassfish.jersey.ext + jersey-entity-filtering + ${jersey.version} + + + + + org.springframework + spring-core + ${spring.version} + + + org.springframework + spring-context + ${spring.version} + + + commons-logging + commons-logging + + + + + org.springframework + spring-web + ${spring.version} + + + org.springframework + spring-tx + ${spring.version} + + + + + ch.qos.logback + logback-classic + ${logback.version} + + + org.slf4j + jcl-over-slf4j + ${jcloverslf4j.version} + + + + + + + true + org.apache.maven.plugins + maven-compiler-plugin + + ${java.version} + ${java.version} + UTF-8 + + + + \ No newline at end of file diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java index 2cc50610..76649acc 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java @@ -1,44 +1,44 @@ -/** - * - */ -package cz.cuni.mff.xrg.odalic.api.rest; - -import org.glassfish.jersey.jackson.JacksonFeature; -import org.glassfish.jersey.media.multipart.MultiPartFeature; -import org.glassfish.jersey.server.ResourceConfig; -import org.glassfish.jersey.server.spring.scope.RequestContextFilter; - -import cz.cuni.mff.xrg.odalic.api.rest.errors.ThrowableMapper; -import cz.cuni.mff.xrg.odalic.api.rest.filters.CorsResponseFilter; -import cz.cuni.mff.xrg.odalic.api.rest.filters.LoggingResponseFilter; -import cz.cuni.mff.xrg.odalic.files.FileResource; -import cz.cuni.mff.xrg.odalic.tasks.TaskResource; -import cz.cuni.mff.xrg.odalic.tasks.configurations.ConfigurationResource; -import cz.cuni.mff.xrg.odalic.tasks.drafts.DraftResource; -import cz.cuni.mff.xrg.odalic.tasks.executions.ExecutionResource; -import cz.cuni.mff.xrg.odalic.tasks.results.ResultResource; - -public final class Configuration extends ResourceConfig { - - public Configuration() { - // Resources registration - register(FileResource.class); - register(TaskResource.class); - register(ConfigurationResource.class); - register(DraftResource.class); - register(ExecutionResource.class); - register(ResultResource.class); - - // Filters registration - register(RequestContextFilter.class); - register(LoggingResponseFilter.class); - register(CorsResponseFilter.class); - - // Exception mappers registration - register(ThrowableMapper.class); - - // Features registration - register(JacksonFeature.class); - register(MultiPartFeature.class); - } -} +/** + * + */ +package cz.cuni.mff.xrg.odalic.api.rest; + +import org.glassfish.jersey.jackson.JacksonFeature; +import org.glassfish.jersey.media.multipart.MultiPartFeature; +import org.glassfish.jersey.server.ResourceConfig; +import org.glassfish.jersey.server.spring.scope.RequestContextFilter; + +import cz.cuni.mff.xrg.odalic.api.rest.errors.ThrowableMapper; +import cz.cuni.mff.xrg.odalic.api.rest.filters.CorsResponseFilter; +import cz.cuni.mff.xrg.odalic.api.rest.filters.LoggingResponseFilter; +import cz.cuni.mff.xrg.odalic.files.FileResource; +import cz.cuni.mff.xrg.odalic.tasks.TaskResource; +import cz.cuni.mff.xrg.odalic.tasks.configurations.ConfigurationResource; +import cz.cuni.mff.xrg.odalic.tasks.drafts.DraftResource; +import cz.cuni.mff.xrg.odalic.tasks.executions.ExecutionResource; +import cz.cuni.mff.xrg.odalic.tasks.results.ResultResource; + +public final class Configuration extends ResourceConfig { + + public Configuration() { + // Resources registration + register(FileResource.class); + register(TaskResource.class); + register(ConfigurationResource.class); + register(DraftResource.class); + register(ExecutionResource.class); + register(ResultResource.class); + + // Filters registration + register(RequestContextFilter.class); + register(LoggingResponseFilter.class); + register(CorsResponseFilter.class); + + // Exception mappers registration + register(ThrowableMapper.class); + + // Features registration + register(JacksonFeature.class); + register(MultiPartFeature.class); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateDeserializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateDeserializer.java index 7ff89c92..072ff3fb 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateDeserializer.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateDeserializer.java @@ -1,28 +1,28 @@ -package cz.cuni.mff.xrg.odalic.api.rest.conversions; - -import java.io.IOException; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; - -import org.codehaus.jackson.JsonParser; -import org.codehaus.jackson.JsonProcessingException; -import org.codehaus.jackson.map.DeserializationContext; -import org.codehaus.jackson.map.JsonDeserializer; - -public class CustomJsonDateDeserializer extends JsonDeserializer { - - @Override - public Date deserialize(JsonParser jsonparser, DeserializationContext context) - throws IOException, JsonProcessingException { - - SimpleDateFormat format = new SimpleDateFormat(CustomJsonDateSerializer.DATE_FORMAT); - String date = jsonparser.getText(); - try { - return format.parse(date); - } catch (ParseException e) { - throw new RuntimeException(e); - } - } - -} +package cz.cuni.mff.xrg.odalic.api.rest.conversions; + +import java.io.IOException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.codehaus.jackson.JsonParser; +import org.codehaus.jackson.JsonProcessingException; +import org.codehaus.jackson.map.DeserializationContext; +import org.codehaus.jackson.map.JsonDeserializer; + +public class CustomJsonDateDeserializer extends JsonDeserializer { + + @Override + public Date deserialize(JsonParser jsonparser, DeserializationContext context) + throws IOException, JsonProcessingException { + + SimpleDateFormat format = new SimpleDateFormat(CustomJsonDateSerializer.DATE_FORMAT); + String date = jsonparser.getText(); + try { + return format.parse(date); + } catch (ParseException e) { + throw new RuntimeException(e); + } + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateSerializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateSerializer.java index 1dcd6710..9b591a0b 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateSerializer.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateSerializer.java @@ -1,26 +1,26 @@ -package cz.cuni.mff.xrg.odalic.api.rest.conversions; - -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.Date; - -import org.codehaus.jackson.JsonGenerator; -import org.codehaus.jackson.JsonProcessingException; -import org.codehaus.jackson.map.JsonSerializer; -import org.codehaus.jackson.map.SerializerProvider; - -public class CustomJsonDateSerializer extends JsonSerializer { - - public static final String DATE_FORMAT = "dd-MM-yyyy HH:mm"; - - @Override - public void serialize(Date value, JsonGenerator jgen, - SerializerProvider provider) throws IOException, - JsonProcessingException { - - SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); - String dateString = dateFormat.format(value); - jgen.writeString(dateString); - } - -} +package cz.cuni.mff.xrg.odalic.api.rest.conversions; + +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.codehaus.jackson.JsonGenerator; +import org.codehaus.jackson.JsonProcessingException; +import org.codehaus.jackson.map.JsonSerializer; +import org.codehaus.jackson.map.SerializerProvider; + +public class CustomJsonDateSerializer extends JsonSerializer { + + public static final String DATE_FORMAT = "dd-MM-yyyy HH:mm"; + + @Override + public void serialize(Date value, JsonGenerator jgen, + SerializerProvider provider) throws IOException, + JsonProcessingException { + + SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); + String dateString = dateFormat.format(value); + jgen.writeString(dateString); + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/Message.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/Message.java index 3e7a006e..cce9ce4d 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/Message.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/Message.java @@ -1,59 +1,59 @@ -package cz.cuni.mff.xrg.odalic.api.rest.errors; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - - -@XmlRootElement -public class Message { - - @XmlElement(name = "status") - int status; - - @XmlElement(name = "text") - String text; - - @XmlElement(name = "link") - String link; - - @XmlElement(name = "developerText") - String developerText; - - public int getStatus() { - return status; - } - - public void setStatus(int status) { - this.status = status; - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - public String getDeveloperText() { - return developerText; - } - - public void setDeveloperText(String developerText) { - this.developerText = developerText; - } - - public String getLink() { - return link; - } - - public void setLink(String link) { - this.link = link; - } - - public Message() {} - - public Message(int status) { - this.status = status; - } -} +package cz.cuni.mff.xrg.odalic.api.rest.errors; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + + +@XmlRootElement +public class Message { + + @XmlElement(name = "status") + int status; + + @XmlElement(name = "text") + String text; + + @XmlElement(name = "link") + String link; + + @XmlElement(name = "developerText") + String developerText; + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public String getDeveloperText() { + return developerText; + } + + public void setDeveloperText(String developerText) { + this.developerText = developerText; + } + + public String getLink() { + return link; + } + + public void setLink(String link) { + this.link = link; + } + + public Message() {} + + public Message(int status) { + this.status = status; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/ThrowableMapper.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/ThrowableMapper.java index a68f4dbb..e443bdec 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/ThrowableMapper.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/ThrowableMapper.java @@ -1,40 +1,40 @@ -package cz.cuni.mff.xrg.odalic.api.rest.errors; - -import java.io.PrintWriter; -import java.io.StringWriter; - -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.ext.ExceptionMapper; - -public class ThrowableMapper implements ExceptionMapper { - - public Response toResponse(Throwable throwable) { - Message errorMessage = new Message(getHttpStatus(throwable)); - - errorMessage.setText(throwable.getMessage()); - - StringWriter trace = new StringWriter(); - throwable.printStackTrace(new PrintWriter(trace)); - errorMessage.setDeveloperText(trace.toString()); - - return Response.status(errorMessage.getStatus()).entity(errorMessage) - .type(MediaType.APPLICATION_JSON).build(); - } - - /** - * Defaults to internal server error in case the exception is not instance of {@link WebApplicationException}. - * - * @param throwable throwable instance - * @return HTTP status code - */ - private int getHttpStatus(Throwable throwable) { - if (throwable instanceof WebApplicationException) { - return ((WebApplicationException) throwable).getResponse().getStatus(); - } else { - return Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(); - } - } -} - +package cz.cuni.mff.xrg.odalic.api.rest.errors; + +import java.io.PrintWriter; +import java.io.StringWriter; + +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.ExceptionMapper; + +public class ThrowableMapper implements ExceptionMapper { + + public Response toResponse(Throwable throwable) { + Message errorMessage = new Message(getHttpStatus(throwable)); + + errorMessage.setText(throwable.getMessage()); + + StringWriter trace = new StringWriter(); + throwable.printStackTrace(new PrintWriter(trace)); + errorMessage.setDeveloperText(trace.toString()); + + return Response.status(errorMessage.getStatus()).entity(errorMessage) + .type(MediaType.APPLICATION_JSON).build(); + } + + /** + * Defaults to internal server error in case the exception is not instance of {@link WebApplicationException}. + * + * @param throwable throwable instance + * @return HTTP status code + */ + private int getHttpStatus(Throwable throwable) { + if (throwable instanceof WebApplicationException) { + return ((WebApplicationException) throwable).getResponse().getStatus(); + } else { + return Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(); + } + } +} + diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/CorsResponseFilter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/CorsResponseFilter.java index 6b7e43d8..c40fb2bc 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/CorsResponseFilter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/CorsResponseFilter.java @@ -1,21 +1,21 @@ -package cz.cuni.mff.xrg.odalic.api.rest.filters; - -import java.io.IOException; - -import javax.ws.rs.container.ContainerRequestContext; -import javax.ws.rs.container.ContainerResponseContext; -import javax.ws.rs.container.ContainerResponseFilter; -import javax.ws.rs.core.MultivaluedMap; - -public class CorsResponseFilter implements ContainerResponseFilter { - - public void filter(ContainerRequestContext requestContext, - ContainerResponseContext responseContext) throws IOException { - MultivaluedMap headers = responseContext.getHeaders(); - - headers.add("Access-Control-Allow-Origin", "*"); - headers.add("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); - headers.add("Access-Control-Allow-Headers", "X-Requested-With, Content-Type, X-Odalic"); - } - -} +package cz.cuni.mff.xrg.odalic.api.rest.filters; + +import java.io.IOException; + +import javax.ws.rs.container.ContainerRequestContext; +import javax.ws.rs.container.ContainerResponseContext; +import javax.ws.rs.container.ContainerResponseFilter; +import javax.ws.rs.core.MultivaluedMap; + +public class CorsResponseFilter implements ContainerResponseFilter { + + public void filter(ContainerRequestContext requestContext, + ContainerResponseContext responseContext) throws IOException { + MultivaluedMap headers = responseContext.getHeaders(); + + headers.add("Access-Control-Allow-Origin", "*"); + headers.add("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); + headers.add("Access-Control-Allow-Headers", "X-Requested-With, Content-Type, X-Odalic"); + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/LoggingResponseFilter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/LoggingResponseFilter.java index 5167a84f..13627979 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/LoggingResponseFilter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/LoggingResponseFilter.java @@ -1,29 +1,29 @@ -package cz.cuni.mff.xrg.odalic.api.rest.filters; - -import java.io.IOException; - -import javax.ws.rs.container.ContainerRequestContext; -import javax.ws.rs.container.ContainerResponseContext; -import javax.ws.rs.container.ContainerResponseFilter; - -import org.codehaus.jackson.map.ObjectMapper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class LoggingResponseFilter - implements ContainerResponseFilter { - - private static final Logger logger = LoggerFactory.getLogger(LoggingResponseFilter.class); - - public void filter(ContainerRequestContext requestContext, - ContainerResponseContext responseContext) throws IOException { - String method = requestContext.getMethod(); - - logger.debug("Requesting " + method + " for path " + requestContext.getUriInfo().getPath()); - Object entity = responseContext.getEntity(); - if (entity != null) { - logger.debug("Response " + new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(entity)); - } - } - +package cz.cuni.mff.xrg.odalic.api.rest.filters; + +import java.io.IOException; + +import javax.ws.rs.container.ContainerRequestContext; +import javax.ws.rs.container.ContainerResponseContext; +import javax.ws.rs.container.ContainerResponseFilter; + +import org.codehaus.jackson.map.ObjectMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class LoggingResponseFilter + implements ContainerResponseFilter { + + private static final Logger logger = LoggerFactory.getLogger(LoggingResponseFilter.class); + + public void filter(ContainerRequestContext requestContext, + ContainerResponseContext responseContext) throws IOException { + String method = requestContext.getMethod(); + + logger.debug("Requesting " + method + " for path " + requestContext.getUriInfo().getPath()); + Object entity = responseContext.getEntity(); + if (entity != null) { + logger.debug("Response " + new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(entity)); + } + } + } \ No newline at end of file diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnFeedback.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnFeedback.java index f6b2e5b8..6593d111 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnFeedback.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnFeedback.java @@ -1,36 +1,36 @@ -package cz.cuni.mff.xrg.odalic.feedbacks; - -import java.io.Serializable; -import java.net.URI; -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement -public class ColumnFeedback implements Serializable { - - private static final long serialVersionUID = -9087389821835847372L; - - @XmlElement(name = "index") - private int index; - - @XmlElement(name = "suggestions") - private Set suggestions; - - public int getIndex() { - return index; - } - - public void setIndex(int index) { - this.index = index; - } - - public Set getSuggestions() { - return suggestions; - } - - public void setSuggestions(Set suggestions) { - this.suggestions = suggestions; - } -} +package cz.cuni.mff.xrg.odalic.feedbacks; + +import java.io.Serializable; +import java.net.URI; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class ColumnFeedback implements Serializable { + + private static final long serialVersionUID = -9087389821835847372L; + + @XmlElement(name = "index") + private int index; + + @XmlElement(name = "suggestions") + private Set suggestions; + + public int getIndex() { + return index; + } + + public void setIndex(int index) { + this.index = index; + } + + public Set getSuggestions() { + return suggestions; + } + + public void setSuggestions(Set suggestions) { + this.suggestions = suggestions; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java index ac56d3f6..c04d2498 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java @@ -1,35 +1,35 @@ -package cz.cuni.mff.xrg.odalic.feedbacks; - -import java.io.Serializable; -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement -public class Feedback implements Serializable { - - private static final long serialVersionUID = -6359038623760039155L; - - @XmlElement(name = "subjectColumnIndex") - private int subjectColumnIndex; - - @XmlElement(name = "columns") - private Set columns; - - public int getSubjectColumnIndex() { - return subjectColumnIndex; - } - - public void setSubjectColumnIndex(int subjectColumnIndex) { - this.subjectColumnIndex = subjectColumnIndex; - } - - public Set getColumns() { - return columns; - } - - public void setColumns(Set columns) { - this.columns = columns; - } -} +package cz.cuni.mff.xrg.odalic.feedbacks; + +import java.io.Serializable; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class Feedback implements Serializable { + + private static final long serialVersionUID = -6359038623760039155L; + + @XmlElement(name = "subjectColumnIndex") + private int subjectColumnIndex; + + @XmlElement(name = "columns") + private Set columns; + + public int getSubjectColumnIndex() { + return subjectColumnIndex; + } + + public void setSubjectColumnIndex(int subjectColumnIndex) { + this.subjectColumnIndex = subjectColumnIndex; + } + + public Set getColumns() { + return columns; + } + + public void setColumns(Set columns) { + this.columns = columns; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/File.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/File.java index c0c93b77..b66da420 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/File.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/File.java @@ -1,72 +1,72 @@ -package cz.cuni.mff.xrg.odalic.files; - -import java.io.Serializable; -import java.util.Date; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import org.codehaus.jackson.map.annotate.JsonDeserialize; -import org.codehaus.jackson.map.annotate.JsonSerialize; - -import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateSerializer; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateDeserializer; - -@XmlRootElement -public class File implements Serializable { - - private static final long serialVersionUID = -6359038623760039155L; - - @XmlElement(name = "id") - private String id; - - @JsonSerialize(using = CustomJsonDateSerializer.class) - @JsonDeserialize(using = CustomJsonDateDeserializer.class) - @XmlElement(name = "uploaded") - private Date uploaded; - - @XmlElement(name = "format") - private String format; - - @XmlElement(name = "owner") - private String owner; - - public File(String id, Date uploaded, String format, String owner) { - this.id = id; - this.uploaded = uploaded; - this.format = format; - this.owner = owner; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public Date getUploaded() { - return uploaded; - } - - public void setUploaded(Date uploaded) { - this.uploaded = uploaded; - } - - public String getFormat() { - return format; - } - - public void setFormat(String format) { - this.format = format; - } - - public String getOwner() { - return owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } -} +package cz.cuni.mff.xrg.odalic.files; + +import java.io.Serializable; +import java.util.Date; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.codehaus.jackson.map.annotate.JsonDeserialize; +import org.codehaus.jackson.map.annotate.JsonSerialize; + +import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateSerializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateDeserializer; + +@XmlRootElement +public class File implements Serializable { + + private static final long serialVersionUID = -6359038623760039155L; + + @XmlElement(name = "id") + private String id; + + @JsonSerialize(using = CustomJsonDateSerializer.class) + @JsonDeserialize(using = CustomJsonDateDeserializer.class) + @XmlElement(name = "uploaded") + private Date uploaded; + + @XmlElement(name = "format") + private String format; + + @XmlElement(name = "owner") + private String owner; + + public File(String id, Date uploaded, String format, String owner) { + this.id = id; + this.uploaded = uploaded; + this.format = format; + this.owner = owner; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Date getUploaded() { + return uploaded; + } + + public void setUploaded(Date uploaded) { + this.uploaded = uploaded; + } + + public String getFormat() { + return format; + } + + public void setFormat(String format) { + this.format = format; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileResource.java index 65101d01..9a617ec8 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileResource.java @@ -1,82 +1,82 @@ -package cz.cuni.mff.xrg.odalic.files; - -import java.util.List; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -/** - * File resource definition. - * - * @author Václav Brodec - */ -@Component -@Path("/files") -public class FileResource { - - private FileService fileService; - - @GET - @Produces(MediaType.APPLICATION_JSON) - public List getFiles() { - return fileService.getFiles(); - } - - @GET - @Path("{id}") - @Produces(MediaType.APPLICATION_JSON) - public Response getFileById(@PathParam("id") String id) { - File file = fileService.getById(id); - return Response.status(Response.Status.OK).entity(file).build(); - } - - @PUT - @Path("{id}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response putFileById(@PathParam("id") String id, File file) { - if (!fileService.hasId(file, id)) { - return Response.status(Response.Status.NOT_ACCEPTABLE) - .entity("The ID in the payload is not the same as the ID of resource.").build(); - } - - File fileById = fileService.verifyFileExistenceById(id); - - if (fileById == null) { - fileService.create(file); - return Response.status(Response.Status.CREATED) - .entity("A new file has been created AT THE LOCATION you specified") - .header("Location", "/files/" + String.valueOf(id)).build(); - } else { - fileService.replace(file); - return Response.status(Response.Status.OK) - .entity( - "The file you specified has been fully updated AT THE LOCATION you specified.") - .header("Location", "/files/" + String.valueOf(id)).build(); - } - } - - @DELETE - @Path("{id}") - @Produces({MediaType.APPLICATION_JSON}) - public Response deleteFileById(@PathParam("id") String id) { - fileService.deleteById(id); - return Response.status(Response.Status.NO_CONTENT) - .entity("File successfully removed from database").build(); - } - - @Autowired - public FileResource(FileService fileService) { - this.fileService = fileService; - } -} +package cz.cuni.mff.xrg.odalic.files; + +import java.util.List; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * File resource definition. + * + * @author Václav Brodec + */ +@Component +@Path("/files") +public class FileResource { + + private FileService fileService; + + @GET + @Produces(MediaType.APPLICATION_JSON) + public List getFiles() { + return fileService.getFiles(); + } + + @GET + @Path("{id}") + @Produces(MediaType.APPLICATION_JSON) + public Response getFileById(@PathParam("id") String id) { + File file = fileService.getById(id); + return Response.status(Response.Status.OK).entity(file).build(); + } + + @PUT + @Path("{id}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response putFileById(@PathParam("id") String id, File file) { + if (!fileService.hasId(file, id)) { + return Response.status(Response.Status.NOT_ACCEPTABLE) + .entity("The ID in the payload is not the same as the ID of resource.").build(); + } + + File fileById = fileService.verifyFileExistenceById(id); + + if (fileById == null) { + fileService.create(file); + return Response.status(Response.Status.CREATED) + .entity("A new file has been created AT THE LOCATION you specified") + .header("Location", "/files/" + String.valueOf(id)).build(); + } else { + fileService.replace(file); + return Response.status(Response.Status.OK) + .entity( + "The file you specified has been fully updated AT THE LOCATION you specified.") + .header("Location", "/files/" + String.valueOf(id)).build(); + } + } + + @DELETE + @Path("{id}") + @Produces({MediaType.APPLICATION_JSON}) + public Response deleteFileById(@PathParam("id") String id) { + fileService.deleteById(id); + return Response.status(Response.Status.NO_CONTENT) + .entity("File successfully removed from database").build(); + } + + @Autowired + public FileResource(FileService fileService) { + this.fileService = fileService; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileService.java index 48c696e7..8d4458bb 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileService.java @@ -1,21 +1,21 @@ -package cz.cuni.mff.xrg.odalic.files; - -import java.util.List; - -public interface FileService { - - void create(File file); - - void deleteById(String id); - - File getById(String id); - - List getFiles(); - - void replace(File file); - - File verifyFileExistenceById(String id); - - boolean hasId(File file, String id); - -} +package cz.cuni.mff.xrg.odalic.files; + +import java.util.List; + +public interface FileService { + + void create(File file); + + void deleteById(String id); + + File getById(String id); + + List getFiles(); + + void replace(File file); + + File verifyFileExistenceById(String id); + + boolean hasId(File file, String id); + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/MemoryOnlyFileService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/MemoryOnlyFileService.java index 2afbed45..974de820 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/MemoryOnlyFileService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/MemoryOnlyFileService.java @@ -1,73 +1,73 @@ -/** - * - */ -package cz.cuni.mff.xrg.odalic.files; - -import java.util.Collections; -import java.util.List; - -/** - * @author Václav Brodec - * - */ -public final class MemoryOnlyFileService implements FileService { - - public MemoryOnlyFileService() {} - - /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.files.FileService#create(cz.cuni.mff.xrg.odalic.files.File) - */ - public void create(File file) { - // TODO Auto-generated method stub - } - - /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.files.FileService#deleteById(java.lang.String) - */ - public void deleteById(String id) { - // TODO Auto-generated method stub - } - - /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.files.FileService#getById(java.lang.String) - */ - public File getById(String id) { - // TODO Auto-generated method stub - return null; - } - - /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.files.FileService#getFiles() - */ - public List getFiles() { - // TODO Auto-generated method stub - return Collections.emptyList(); - } - - /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.files.FileService#replace(cz.cuni.mff.xrg.odalic.files.File) - */ - public void replace(File file) { - // TODO Auto-generated method stub - } - - /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.files.FileService#verifyFileExistenceById(java.lang.String) - */ - public File verifyFileExistenceById(String id) { - // TODO Auto-generated method stub - return null; - } - - /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.files.FileService#hasId(cz.cuni.mff.xrg.odalic.files.File, java.lang.String) - */ - public boolean hasId(File file, String id) { - if (file.getId() == null) { - return false; - } - - return file.getId().equals(id); - } - -} +/** + * + */ +package cz.cuni.mff.xrg.odalic.files; + +import java.util.Collections; +import java.util.List; + +/** + * @author Václav Brodec + * + */ +public final class MemoryOnlyFileService implements FileService { + + public MemoryOnlyFileService() {} + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.files.FileService#create(cz.cuni.mff.xrg.odalic.files.File) + */ + public void create(File file) { + // TODO Auto-generated method stub + } + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.files.FileService#deleteById(java.lang.String) + */ + public void deleteById(String id) { + // TODO Auto-generated method stub + } + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.files.FileService#getById(java.lang.String) + */ + public File getById(String id) { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.files.FileService#getFiles() + */ + public List getFiles() { + // TODO Auto-generated method stub + return Collections.emptyList(); + } + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.files.FileService#replace(cz.cuni.mff.xrg.odalic.files.File) + */ + public void replace(File file) { + // TODO Auto-generated method stub + } + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.files.FileService#verifyFileExistenceById(java.lang.String) + */ + public File verifyFileExistenceById(String id) { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.files.FileService#hasId(cz.cuni.mff.xrg.odalic.files.File, java.lang.String) + */ + public boolean hasId(File file, String id) { + if (file.getId() == null) { + return false; + } + + return file.getId().equals(id); + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/State.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/State.java index 42842d00..8387cd55 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/State.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/State.java @@ -1,14 +1,14 @@ -package cz.cuni.mff.xrg.odalic.tasks; - -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlEnumValue; -import javax.xml.bind.annotation.XmlType; - -@XmlType -@XmlEnum(Integer.class) -public enum State { - @XmlEnumValue("1") READY, - @XmlEnumValue("2") RUNNING, - @XmlEnumValue("3") CANCELED, - @XmlEnumValue("4") FINISHED -} +package cz.cuni.mff.xrg.odalic.tasks; + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; +import javax.xml.bind.annotation.XmlType; + +@XmlType +@XmlEnum(Integer.class) +public enum State { + @XmlEnumValue("1") READY, + @XmlEnumValue("2") RUNNING, + @XmlEnumValue("3") CANCELED, + @XmlEnumValue("4") FINISHED +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/Task.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/Task.java index 2dc45118..a24f03b9 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/Task.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/Task.java @@ -1,92 +1,92 @@ -package cz.cuni.mff.xrg.odalic.tasks; - -import java.io.Serializable; -import java.net.URL; -import java.util.Date; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import org.codehaus.jackson.map.annotate.JsonDeserialize; -import org.codehaus.jackson.map.annotate.JsonSerialize; - -import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateDeserializer; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateSerializer; -import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; -import cz.cuni.mff.xrg.odalic.tasks.results.Result; - -@XmlRootElement -public class Task implements Serializable { - - private static final long serialVersionUID = 1610346823333685091L; - - @XmlElement(name = "id") - private String id; - - @JsonSerialize(using = CustomJsonDateSerializer.class) - @JsonDeserialize(using = CustomJsonDateDeserializer.class) - @XmlElement(name = "created") - private Date created; - - @XmlElement(name = "input") - private URL input; - - @XmlElement(name = "feedback") - private Feedback feedback; - - @XmlElement(name = "state") - private State state; - - @XmlElement(name = "result") - private Result result; - - public Task() {} - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public Date getCreated() { - return created; - } - - public void setCreated(Date created) { - this.created = created; - } - - public URL getInput() { - return input; - } - - public void setInput(URL input) { - this.input = input; - } - - public Feedback getFeedback() { - return feedback; - } - - public void setFeedback(Feedback feedback) { - this.feedback = feedback; - } - - public State getState() { - return state; - } - - public void setState(State state) { - this.state = state; - } - - public Result getResult() { - return result; - } - - public void setResult(Result result) { - this.result = result; - } -} +package cz.cuni.mff.xrg.odalic.tasks; + +import java.io.Serializable; +import java.net.URL; +import java.util.Date; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.codehaus.jackson.map.annotate.JsonDeserialize; +import org.codehaus.jackson.map.annotate.JsonSerialize; + +import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateDeserializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateSerializer; +import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; +import cz.cuni.mff.xrg.odalic.tasks.results.Result; + +@XmlRootElement +public class Task implements Serializable { + + private static final long serialVersionUID = 1610346823333685091L; + + @XmlElement(name = "id") + private String id; + + @JsonSerialize(using = CustomJsonDateSerializer.class) + @JsonDeserialize(using = CustomJsonDateDeserializer.class) + @XmlElement(name = "created") + private Date created; + + @XmlElement(name = "input") + private URL input; + + @XmlElement(name = "feedback") + private Feedback feedback; + + @XmlElement(name = "state") + private State state; + + @XmlElement(name = "result") + private Result result; + + public Task() {} + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Date getCreated() { + return created; + } + + public void setCreated(Date created) { + this.created = created; + } + + public URL getInput() { + return input; + } + + public void setInput(URL input) { + this.input = input; + } + + public Feedback getFeedback() { + return feedback; + } + + public void setFeedback(Feedback feedback) { + this.feedback = feedback; + } + + public State getState() { + return state; + } + + public void setState(State state) { + this.state = state; + } + + public Result getResult() { + return result; + } + + public void setResult(Result result) { + this.result = result; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskDigest.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskDigest.java index 7e52036a..fddcfb9c 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskDigest.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskDigest.java @@ -1,81 +1,81 @@ -package cz.cuni.mff.xrg.odalic.tasks; - -import java.io.Serializable; -import java.net.URL; -import java.util.Date; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import org.codehaus.jackson.map.annotate.JsonDeserialize; -import org.codehaus.jackson.map.annotate.JsonSerialize; - -import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateDeserializer; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateSerializer; -import cz.cuni.mff.xrg.odalic.tasks.results.Result; - - -@XmlRootElement -public class TaskDigest implements Serializable { - - private static final long serialVersionUID = 1610346823333685091L; - - @XmlElement(name = "id") - private String id; - - @JsonSerialize(using = CustomJsonDateSerializer.class) - @JsonDeserialize(using = CustomJsonDateDeserializer.class) - @XmlElement(name = "created") - private Date created; - - @XmlElement(name = "input") - private URL input; - - @XmlElement(name = "state") - private State state; - - @XmlElement(name = "result") - private Result result; - - public TaskDigest() {} - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public Date getCreated() { - return created; - } - - public void setCreated(Date created) { - this.created = created; - } - - public URL getInput() { - return input; - } - - public void setInput(URL input) { - this.input = input; - } - - public State getState() { - return state; - } - - public void setState(State state) { - this.state = state; - } - - public Result getResult() { - return result; - } - - public void setResult(Result result) { - this.result = result; - } -} +package cz.cuni.mff.xrg.odalic.tasks; + +import java.io.Serializable; +import java.net.URL; +import java.util.Date; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.codehaus.jackson.map.annotate.JsonDeserialize; +import org.codehaus.jackson.map.annotate.JsonSerialize; + +import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateDeserializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateSerializer; +import cz.cuni.mff.xrg.odalic.tasks.results.Result; + + +@XmlRootElement +public class TaskDigest implements Serializable { + + private static final long serialVersionUID = 1610346823333685091L; + + @XmlElement(name = "id") + private String id; + + @JsonSerialize(using = CustomJsonDateSerializer.class) + @JsonDeserialize(using = CustomJsonDateDeserializer.class) + @XmlElement(name = "created") + private Date created; + + @XmlElement(name = "input") + private URL input; + + @XmlElement(name = "state") + private State state; + + @XmlElement(name = "result") + private Result result; + + public TaskDigest() {} + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Date getCreated() { + return created; + } + + public void setCreated(Date created) { + this.created = created; + } + + public URL getInput() { + return input; + } + + public void setInput(URL input) { + this.input = input; + } + + public State getState() { + return state; + } + + public void setState(State state) { + this.state = state; + } + + public Result getResult() { + return result; + } + + public void setResult(Result result) { + this.result = result; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskResource.java index d2755fef..acaf3f5f 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskResource.java @@ -1,82 +1,82 @@ -package cz.cuni.mff.xrg.odalic.tasks; - -import java.util.List; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -/** - * Task resource definition. - * - * @author Václav Brodec - */ -@Component -@Path("/tasks") -public class TaskResource { - - private TaskService taskService; - - @GET - @Produces(MediaType.APPLICATION_JSON) - public List getTasks() { - return taskService.getTasks(); - } - - @GET - @Path("/tasks/{id}") - @Produces(MediaType.APPLICATION_JSON) - public Response getTaskById(@PathParam("id") String id) { - Task task = taskService.getById(id); - return Response.status(Response.Status.OK).entity(task).build(); - } - - @PUT - @Path("/tasks/{id}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response putTaskById(@PathParam("id") String id, Task task) { - if (!taskService.hasId(task, id)) { - return Response.status(Response.Status.NOT_ACCEPTABLE) - .entity("The ID in the payload is not the same as the ID of resource.").build(); - } - - Task taskById = taskService.verifyTaskExistenceById(id); - - if (taskById == null) { - taskService.create(task); - return Response.status(Response.Status.CREATED) - .entity("A new task has been created AT THE LOCATION you specified") - .header("Location", "/tasks/" + String.valueOf(id)).build(); - } else { - taskService.replace(task); - return Response.status(Response.Status.OK) - .entity( - "The task you specified has been fully updated AT THE LOCATION you specified.") - .header("Location", "/tasks/" + String.valueOf(id)).build(); - } - } - - @DELETE - @Path("/tasks/{id}") - @Produces({MediaType.APPLICATION_JSON}) - public Response deleteTaskById(@PathParam("id") String id) { - taskService.deleteById(id); - return Response.status(Response.Status.NO_CONTENT) - .entity("Task successfully removed from database").build(); - } - - @Autowired - public TaskResource(TaskService taskService) { - this.taskService = taskService; - } -} +package cz.cuni.mff.xrg.odalic.tasks; + +import java.util.List; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * Task resource definition. + * + * @author Václav Brodec + */ +@Component +@Path("/tasks") +public class TaskResource { + + private TaskService taskService; + + @GET + @Produces(MediaType.APPLICATION_JSON) + public List getTasks() { + return taskService.getTasks(); + } + + @GET + @Path("/tasks/{id}") + @Produces(MediaType.APPLICATION_JSON) + public Response getTaskById(@PathParam("id") String id) { + Task task = taskService.getById(id); + return Response.status(Response.Status.OK).entity(task).build(); + } + + @PUT + @Path("/tasks/{id}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response putTaskById(@PathParam("id") String id, Task task) { + if (!taskService.hasId(task, id)) { + return Response.status(Response.Status.NOT_ACCEPTABLE) + .entity("The ID in the payload is not the same as the ID of resource.").build(); + } + + Task taskById = taskService.verifyTaskExistenceById(id); + + if (taskById == null) { + taskService.create(task); + return Response.status(Response.Status.CREATED) + .entity("A new task has been created AT THE LOCATION you specified") + .header("Location", "/tasks/" + String.valueOf(id)).build(); + } else { + taskService.replace(task); + return Response.status(Response.Status.OK) + .entity( + "The task you specified has been fully updated AT THE LOCATION you specified.") + .header("Location", "/tasks/" + String.valueOf(id)).build(); + } + } + + @DELETE + @Path("/tasks/{id}") + @Produces({MediaType.APPLICATION_JSON}) + public Response deleteTaskById(@PathParam("id") String id) { + taskService.deleteById(id); + return Response.status(Response.Status.NO_CONTENT) + .entity("Task successfully removed from database").build(); + } + + @Autowired + public TaskResource(TaskService taskService) { + this.taskService = taskService; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskService.java index 75cfc494..e41610bd 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskService.java @@ -1,20 +1,20 @@ -package cz.cuni.mff.xrg.odalic.tasks; - -import java.util.List; - -public interface TaskService { - - List getTasks(); - - Task getById(String id); - - boolean hasId(Task task, String id); - - void deleteById(String id); - - Task verifyTaskExistenceById(String id); - - void create(Task task); - - void replace(Task task); -} +package cz.cuni.mff.xrg.odalic.tasks; + +import java.util.List; + +public interface TaskService { + + List getTasks(); + + Task getById(String id); + + boolean hasId(Task task, String id); + + void deleteById(String id); + + Task verifyTaskExistenceById(String id); + + void create(Task task); + + void replace(Task task); +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskServiceImpl.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskServiceImpl.java index 696507e8..4981502f 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskServiceImpl.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskServiceImpl.java @@ -1,47 +1,47 @@ -package cz.cuni.mff.xrg.odalic.tasks; - -import java.util.Collections; -import java.util.List; - -/** - * @author Václav Brodec - * - */ -public final class TaskServiceImpl implements TaskService { - - public TaskServiceImpl() {} - - public List getTasks() { - return Collections.emptyList(); - } - - public Task getById(String id) { - // TODO Auto-generated method stub - return null; - } - - public boolean hasId(Task task, String id) { - if (task.getId() == null) { - return false; - } - - return task.getId().equals(id); - } - - public void deleteById(String id) { - // TODO Auto-generated method stub - } - - public Task verifyTaskExistenceById(String id) { - // TODO Auto-generated method stub - return null; - } - - public void create(Task task) { - // TODO Auto-generated method stub - } - - public void replace(Task task) { - // TODO Auto-generated method stub - } -} +package cz.cuni.mff.xrg.odalic.tasks; + +import java.util.Collections; +import java.util.List; + +/** + * @author Václav Brodec + * + */ +public final class TaskServiceImpl implements TaskService { + + public TaskServiceImpl() {} + + public List getTasks() { + return Collections.emptyList(); + } + + public Task getById(String id) { + // TODO Auto-generated method stub + return null; + } + + public boolean hasId(Task task, String id) { + if (task.getId() == null) { + return false; + } + + return task.getId().equals(id); + } + + public void deleteById(String id) { + // TODO Auto-generated method stub + } + + public Task verifyTaskExistenceById(String id) { + // TODO Auto-generated method stub + return null; + } + + public void create(Task task) { + // TODO Auto-generated method stub + } + + public void replace(Task task) { + // TODO Auto-generated method stub + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java index 1d6a5ff7..06d4f0e4 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java @@ -1,10 +1,10 @@ -package cz.cuni.mff.xrg.odalic.tasks.configurations; - -import java.io.Serializable; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement -public class Configuration implements Serializable { - - private static final long serialVersionUID = -6359038623760039155L; -} +package cz.cuni.mff.xrg.odalic.tasks.configurations; + +import java.io.Serializable; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class Configuration implements Serializable { + + private static final long serialVersionUID = -6359038623760039155L; +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationResource.java index 6ca78745..331113b3 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationResource.java @@ -1,20 +1,20 @@ -package cz.cuni.mff.xrg.odalic.tasks.configurations; - -import javax.ws.rs.Path; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -@Path("/tasks/{id}/configuration") -public class ConfigurationResource { - - @SuppressWarnings("unused") - private ConfigurationService configurationService; - - //TODO: Methods. - - @Autowired - public ConfigurationResource(ConfigurationService configurationService) { - this.configurationService = configurationService; - } -} +package cz.cuni.mff.xrg.odalic.tasks.configurations; + +import javax.ws.rs.Path; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +@Path("/tasks/{id}/configuration") +public class ConfigurationResource { + + @SuppressWarnings("unused") + private ConfigurationService configurationService; + + //TODO: Methods. + + @Autowired + public ConfigurationResource(ConfigurationService configurationService) { + this.configurationService = configurationService; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationService.java index e7d58b3c..8cd5ff83 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationService.java @@ -1,3 +1,3 @@ -package cz.cuni.mff.xrg.odalic.tasks.configurations; - -public interface ConfigurationService {} +package cz.cuni.mff.xrg.odalic.tasks.configurations; + +public interface ConfigurationService {} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationServiceImpl.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationServiceImpl.java index b3574ec2..06fa8322 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationServiceImpl.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationServiceImpl.java @@ -1,10 +1,10 @@ -/** - * - */ -package cz.cuni.mff.xrg.odalic.tasks.configurations; - -/** - * @author Václav Brodec - * - */ -public final class ConfigurationServiceImpl implements ConfigurationService {} +/** + * + */ +package cz.cuni.mff.xrg.odalic.tasks.configurations; + +/** + * @author Václav Brodec + * + */ +public final class ConfigurationServiceImpl implements ConfigurationService {} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/Draft.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/Draft.java index 14781e55..ede05d79 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/Draft.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/Draft.java @@ -1,10 +1,10 @@ -package cz.cuni.mff.xrg.odalic.tasks.drafts; - -import java.io.Serializable; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement -public class Draft implements Serializable { - - private static final long serialVersionUID = -6359038623760039155L; -} +package cz.cuni.mff.xrg.odalic.tasks.drafts; + +import java.io.Serializable; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class Draft implements Serializable { + + private static final long serialVersionUID = -6359038623760039155L; +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftResource.java index 83fe6d53..e1c0e54b 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftResource.java @@ -1,20 +1,20 @@ -package cz.cuni.mff.xrg.odalic.tasks.drafts; - -import javax.ws.rs.Path; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -@Path("/tasks/{id}/draft") -public class DraftResource { - - @SuppressWarnings("unused") - private DraftService draftService; - - //TODO: Methods. - - @Autowired - public DraftResource(DraftService draftService) { - this.draftService = draftService; - } -} +package cz.cuni.mff.xrg.odalic.tasks.drafts; + +import javax.ws.rs.Path; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +@Path("/tasks/{id}/draft") +public class DraftResource { + + @SuppressWarnings("unused") + private DraftService draftService; + + //TODO: Methods. + + @Autowired + public DraftResource(DraftService draftService) { + this.draftService = draftService; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftService.java index 40c841f5..377ce832 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftService.java @@ -1,7 +1,7 @@ -package cz.cuni.mff.xrg.odalic.tasks.drafts; - -public interface DraftService { - - - -} +package cz.cuni.mff.xrg.odalic.tasks.drafts; + +public interface DraftService { + + + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftServiceImpl.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftServiceImpl.java index 31ffa103..16368cf9 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftServiceImpl.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftServiceImpl.java @@ -1,10 +1,10 @@ -/** - * - */ -package cz.cuni.mff.xrg.odalic.tasks.drafts; - -/** - * @author Václav Brodec - * - */ -public final class DraftServiceImpl implements DraftService {} +/** + * + */ +package cz.cuni.mff.xrg.odalic.tasks.drafts; + +/** + * @author Václav Brodec + * + */ +public final class DraftServiceImpl implements DraftService {} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/Execution.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/Execution.java index 259d0227..f9be993e 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/Execution.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/Execution.java @@ -1,10 +1,10 @@ -package cz.cuni.mff.xrg.odalic.tasks.executions; - -import java.io.Serializable; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement -public class Execution implements Serializable { - - private static final long serialVersionUID = -6359038623760039155L; -} +package cz.cuni.mff.xrg.odalic.tasks.executions; + +import java.io.Serializable; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class Execution implements Serializable { + + private static final long serialVersionUID = -6359038623760039155L; +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionResource.java index 2311aaae..a24cd6ae 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionResource.java @@ -1,20 +1,20 @@ -package cz.cuni.mff.xrg.odalic.tasks.executions; - -import javax.ws.rs.Path; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -@Path("/tasks/{id}/execution") -public class ExecutionResource { - - @SuppressWarnings("unused") - private ExecutionService executionService; - - // TODO: Methods. - - @Autowired - public ExecutionResource(ExecutionService executionService) { - this.executionService = executionService; - } -} +package cz.cuni.mff.xrg.odalic.tasks.executions; + +import javax.ws.rs.Path; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +@Path("/tasks/{id}/execution") +public class ExecutionResource { + + @SuppressWarnings("unused") + private ExecutionService executionService; + + // TODO: Methods. + + @Autowired + public ExecutionResource(ExecutionService executionService) { + this.executionService = executionService; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionService.java index 8c2d247a..0f312d73 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionService.java @@ -1,7 +1,7 @@ -package cz.cuni.mff.xrg.odalic.tasks.executions; - -public interface ExecutionService { - - - -} +package cz.cuni.mff.xrg.odalic.tasks.executions; + +public interface ExecutionService { + + + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionServiceImpl.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionServiceImpl.java index a685136f..5b1ad15d 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionServiceImpl.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionServiceImpl.java @@ -1,10 +1,10 @@ -/** - * - */ -package cz.cuni.mff.xrg.odalic.tasks.executions; - -/** - * @author Václav Brodec - * - */ -public final class ExecutionServiceImpl implements ExecutionService {} +/** + * + */ +package cz.cuni.mff.xrg.odalic.tasks.executions; + +/** + * @author Václav Brodec + * + */ +public final class ExecutionServiceImpl implements ExecutionService {} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/Result.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/Result.java index e149983e..2041e133 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/Result.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/Result.java @@ -1,12 +1,12 @@ -package cz.cuni.mff.xrg.odalic.tasks.results; - -import java.io.Serializable; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement -public class Result implements Serializable { - - private static final long serialVersionUID = -6359038623760039155L; - - -} +package cz.cuni.mff.xrg.odalic.tasks.results; + +import java.io.Serializable; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class Result implements Serializable { + + private static final long serialVersionUID = -6359038623760039155L; + + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultResource.java index ab8c6f67..e41db613 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultResource.java @@ -1,20 +1,20 @@ -package cz.cuni.mff.xrg.odalic.tasks.results; - -import javax.ws.rs.Path; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -@Path("/tasks/{id}/result") -public class ResultResource { - - @SuppressWarnings("unused") - private ResultService resultService; - - //TODO: Methods. - - @Autowired - public ResultResource(ResultService resultService) { - this.resultService = resultService; - } -} +package cz.cuni.mff.xrg.odalic.tasks.results; + +import javax.ws.rs.Path; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +@Path("/tasks/{id}/result") +public class ResultResource { + + @SuppressWarnings("unused") + private ResultService resultService; + + //TODO: Methods. + + @Autowired + public ResultResource(ResultService resultService) { + this.resultService = resultService; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultService.java index 59acd7cc..8e73a684 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultService.java @@ -1,7 +1,7 @@ -package cz.cuni.mff.xrg.odalic.tasks.results; - -public interface ResultService { - - - -} +package cz.cuni.mff.xrg.odalic.tasks.results; + +public interface ResultService { + + + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultServiceImpl.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultServiceImpl.java index 45fdcea9..408219ce 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultServiceImpl.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultServiceImpl.java @@ -1,10 +1,10 @@ -/** - * - */ -package cz.cuni.mff.xrg.odalic.tasks.results; - -/** - * @author Václav Brodec - * - */ -public final class ResultServiceImpl implements ResultService {} +/** + * + */ +package cz.cuni.mff.xrg.odalic.tasks.results; + +/** + * @author Václav Brodec + * + */ +public final class ResultServiceImpl implements ResultService {} diff --git a/odalic/src/main/resources/logback.xml b/odalic/src/main/resources/logback.xml index 671d8e1a..b5209872 100644 --- a/odalic/src/main/resources/logback.xml +++ b/odalic/src/main/resources/logback.xml @@ -1,23 +1,23 @@ - - - - - - .%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg %n - - - - TRACE - - - - - - - - - - - - + + + + + + .%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg %n + + + + TRACE + + + + + + + + + + + + \ No newline at end of file diff --git a/odalic/src/main/resources/spring/applicationContext.xml b/odalic/src/main/resources/spring/applicationContext.xml index 76e19bc2..19c75b02 100644 --- a/odalic/src/main/resources/spring/applicationContext.xml +++ b/odalic/src/main/resources/spring/applicationContext.xml @@ -1,30 +1,30 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/odalic/src/main/webapp/WEB-INF/web.xml b/odalic/src/main/webapp/WEB-INF/web.xml index 157dc937..c42a748b 100644 --- a/odalic/src/main/webapp/WEB-INF/web.xml +++ b/odalic/src/main/webapp/WEB-INF/web.xml @@ -1,34 +1,34 @@ - - - Demo - Restful Web Application - - - - org.springframework.web.context.ContextLoaderListener - - - - - contextConfigLocation - classpath:spring/applicationContext.xml - - - - jersey-servlet - - org.glassfish.jersey.servlet.ServletContainer - - - javax.ws.rs.Application - cz.cuni.mff.xrg.odalic.api.rest.Configuration - - 1 - - - - jersey-servlet - /* - + + + Demo - Restful Web Application + + + + org.springframework.web.context.ContextLoaderListener + + + + + contextConfigLocation + classpath:spring/applicationContext.xml + + + + jersey-servlet + + org.glassfish.jersey.servlet.ServletContainer + + + javax.ws.rs.Application + cz.cuni.mff.xrg.odalic.api.rest.Configuration + + 1 + + + + jersey-servlet + /* + \ No newline at end of file From 1739d198777a7ba7a9090d580a66ecf209d0033b Mon Sep 17 00:00:00 2001 From: brodecva Date: Mon, 20 Jun 2016 03:55:49 +0200 Subject: [PATCH 017/211] File resource and memory file service implementation. Additionally task feedback model completed (might be split into two commits). --- .../xrg/odalic/api/rest/Configuration.java | 12 +- .../api/rest/adapters/AmbiguityAdapter.java | 23 ++ .../rest/adapters/CellPositionAdapter.java | 23 ++ .../rest/adapters/CellRelationAdapter.java | 23 ++ .../rest/adapters/ClassificationAdapter.java | 23 ++ .../rest/adapters/ColumnAmbiguityAdapter.java | 20 ++ .../rest/adapters/ColumnIgnoreAdapter.java | 20 ++ .../rest/adapters/ColumnPositionAdapter.java | 23 ++ .../rest/adapters/ColumnRelationAdapter.java | 21 ++ .../rest/adapters/DisambiguationAdapter.java | 23 ++ .../api/rest/adapters/EntityAdapter.java | 24 ++ .../api/rest/adapters/FeedbackAdapter.java | 22 ++ .../api/rest/adapters/RowPositionAdapter.java | 23 ++ .../xrg/odalic/api/rest/errors/Message.java | 20 +- .../rest/resources/ConfigurationResource.java | 44 +++ .../rest/resources}/DraftResource.java | 4 +- .../api/rest/resources/ExecutionResource.java | 53 ++++ .../rest/resources}/FileResource.java | 62 +++- .../rest/resources}/ResultResource.java | 4 +- .../rest/resources}/TaskResource.java | 6 +- .../api/rest/values/AmbiguityValue.java | 52 ++++ .../api/rest/values/CellPositionValue.java | 74 +++++ .../api/rest/values/CellRelationValue.java | 117 ++++++++ .../api/rest/values/ClassificationValue.java | 77 +++++ .../api/rest/values/ColumnAmbiguityValue.java | 52 ++++ .../api/rest/values/ColumnIgnoreValue.java | 52 ++++ .../api/rest/values/ColumnPositionValue.java | 48 +++ .../api/rest/values/ColumnRelationValue.java | 97 ++++++ .../api/rest/values/DisambiguationValue.java | 74 +++++ .../odalic/api/rest/values/EntityValue.java | 73 +++++ .../odalic/api/rest/values/FeedbackValue.java | 203 +++++++++++++ .../api/rest/values/RowPositionValue.java | 44 +++ .../mff/xrg/odalic/feedbacks/Ambiguity.java | 80 +++++ .../xrg/odalic/feedbacks/CellRelation.java | 156 ++++++++++ .../xrg/odalic/feedbacks/Classification.java | 104 +++++++ .../xrg/odalic/feedbacks/ColumnAmbiguity.java | 83 ++++++ .../xrg/odalic/feedbacks/ColumnFeedback.java | 36 --- .../xrg/odalic/feedbacks/ColumnIgnore.java | 83 ++++++ .../xrg/odalic/feedbacks/ColumnRelation.java | 138 +++++++++ .../xrg/odalic/feedbacks/Disambiguation.java | 105 +++++++ .../mff/xrg/odalic/feedbacks/Feedback.java | 276 +++++++++++++++++- .../odalic/feedbacks/types/CellPosition.java | 105 +++++++ .../feedbacks/types/ColumnPosition.java | 85 ++++++ .../xrg/odalic/feedbacks/types/Entity.java | 100 +++++++ .../odalic/feedbacks/types/RowPosition.java | 77 +++++ .../cz/cuni/mff/xrg/odalic/files/File.java | 144 +++++++-- .../mff/xrg/odalic/files/FileService.java | 9 +- .../odalic/files/MemoryOnlyFileService.java | 74 ++++- .../cz/cuni/mff/xrg/odalic/tasks/Task.java | 170 ++++++++--- .../tasks/configurations/Configuration.java | 28 ++ .../configurations/ConfigurationResource.java | 20 -- .../configurations/ConfigurationService.java | 9 +- .../ConfigurationServiceImpl.java | 18 +- .../odalic/tasks/executions/Execution.java | 40 +++ .../tasks/executions/ExecutionResource.java | 20 -- .../tasks/executions/ExecutionService.java | 4 +- .../executions/ExecutionServiceImpl.java | 18 +- .../resources/spring/applicationContext.xml | 12 +- 58 files changed, 3226 insertions(+), 204 deletions(-) create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/AmbiguityAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellPositionAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ClassificationAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnAmbiguityAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnIgnoreAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnPositionAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/DisambiguationAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/FeedbackAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/RowPositionAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ConfigurationResource.java rename odalic/src/main/java/cz/cuni/mff/xrg/odalic/{tasks/drafts => api/rest/resources}/DraftResource.java (78%) create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ExecutionResource.java rename odalic/src/main/java/cz/cuni/mff/xrg/odalic/{files => api/rest/resources}/FileResource.java (54%) rename odalic/src/main/java/cz/cuni/mff/xrg/odalic/{tasks/results => api/rest/resources}/ResultResource.java (78%) rename odalic/src/main/java/cz/cuni/mff/xrg/odalic/{tasks => api/rest/resources}/TaskResource.java (92%) create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/AmbiguityValue.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellPositionValue.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationValue.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ClassificationValue.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnAmbiguityValue.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnIgnoreValue.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnPositionValue.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationValue.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/DisambiguationValue.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityValue.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/FeedbackValue.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/RowPositionValue.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Ambiguity.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/CellRelation.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Classification.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnAmbiguity.java delete mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnFeedback.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnIgnore.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnRelation.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Disambiguation.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/types/CellPosition.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/types/ColumnPosition.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/types/Entity.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/types/RowPosition.java delete mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationResource.java delete mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionResource.java diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java index 76649acc..14dd4777 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java @@ -11,12 +11,12 @@ import cz.cuni.mff.xrg.odalic.api.rest.errors.ThrowableMapper; import cz.cuni.mff.xrg.odalic.api.rest.filters.CorsResponseFilter; import cz.cuni.mff.xrg.odalic.api.rest.filters.LoggingResponseFilter; -import cz.cuni.mff.xrg.odalic.files.FileResource; -import cz.cuni.mff.xrg.odalic.tasks.TaskResource; -import cz.cuni.mff.xrg.odalic.tasks.configurations.ConfigurationResource; -import cz.cuni.mff.xrg.odalic.tasks.drafts.DraftResource; -import cz.cuni.mff.xrg.odalic.tasks.executions.ExecutionResource; -import cz.cuni.mff.xrg.odalic.tasks.results.ResultResource; +import cz.cuni.mff.xrg.odalic.api.rest.resources.ConfigurationResource; +import cz.cuni.mff.xrg.odalic.api.rest.resources.DraftResource; +import cz.cuni.mff.xrg.odalic.api.rest.resources.ExecutionResource; +import cz.cuni.mff.xrg.odalic.api.rest.resources.FileResource; +import cz.cuni.mff.xrg.odalic.api.rest.resources.ResultResource; +import cz.cuni.mff.xrg.odalic.api.rest.resources.TaskResource; public final class Configuration extends ResourceConfig { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/AmbiguityAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/AmbiguityAdapter.java new file mode 100644 index 00000000..89c7e5c9 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/AmbiguityAdapter.java @@ -0,0 +1,23 @@ +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.AmbiguityValue; +import cz.cuni.mff.xrg.odalic.feedbacks.Ambiguity; + + +public class AmbiguityAdapter + extends XmlAdapter { + + @Override + public AmbiguityValue marshal(Ambiguity bound) + throws Exception { + return new AmbiguityValue(bound); + } + + @Override + public Ambiguity unmarshal(AmbiguityValue value) + throws Exception { + return new Ambiguity(value.getPosition()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellPositionAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellPositionAdapter.java new file mode 100644 index 00000000..a89245ca --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellPositionAdapter.java @@ -0,0 +1,23 @@ +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.CellPositionValue; +import cz.cuni.mff.xrg.odalic.feedbacks.types.CellPosition; + + +public class CellPositionAdapter + extends XmlAdapter { + + @Override + public CellPositionValue marshal(CellPosition bound) + throws Exception { + return new CellPositionValue(bound); + } + + @Override + public CellPosition unmarshal(CellPositionValue value) + throws Exception { + return new CellPosition(value.getRowPosition(), value.getColumnPosition()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAdapter.java new file mode 100644 index 00000000..708fd11d --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAdapter.java @@ -0,0 +1,23 @@ +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.CellRelationValue; +import cz.cuni.mff.xrg.odalic.feedbacks.CellRelation; + + +public class CellRelationAdapter + extends XmlAdapter { + + @Override + public CellRelationValue marshal(CellRelation bound) + throws Exception { + return new CellRelationValue(bound); + } + + @Override + public CellRelation unmarshal(CellRelationValue value) + throws Exception { + return new CellRelation(value.getSubjectColumnPosition(), value.getObjectColumnPosition(), value.getRowPosition(), value.getEntity()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ClassificationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ClassificationAdapter.java new file mode 100644 index 00000000..41a9ce4e --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ClassificationAdapter.java @@ -0,0 +1,23 @@ +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.ClassificationValue; +import cz.cuni.mff.xrg.odalic.feedbacks.Classification; + + +public class ClassificationAdapter + extends XmlAdapter { + + @Override + public ClassificationValue marshal(Classification bound) + throws Exception { + return new ClassificationValue(bound); + } + + @Override + public Classification unmarshal(ClassificationValue value) + throws Exception { + return new Classification(value.getPosition(), value.getEntities()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnAmbiguityAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnAmbiguityAdapter.java new file mode 100644 index 00000000..caf41a37 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnAmbiguityAdapter.java @@ -0,0 +1,20 @@ +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.ColumnAmbiguityValue; +import cz.cuni.mff.xrg.odalic.feedbacks.ColumnAmbiguity; + +public class ColumnAmbiguityAdapter extends XmlAdapter { + + @Override + public ColumnAmbiguityValue marshal(ColumnAmbiguity bound) throws Exception { + return new ColumnAmbiguityValue(bound); + } + + @Override + public ColumnAmbiguity unmarshal(ColumnAmbiguityValue value) throws Exception { + return new ColumnAmbiguity(value.getPosition()); + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnIgnoreAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnIgnoreAdapter.java new file mode 100644 index 00000000..5a5c1533 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnIgnoreAdapter.java @@ -0,0 +1,20 @@ +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.ColumnIgnoreValue; +import cz.cuni.mff.xrg.odalic.feedbacks.ColumnIgnore; + +public class ColumnIgnoreAdapter extends XmlAdapter { + + @Override + public ColumnIgnoreValue marshal(ColumnIgnore bound) throws Exception { + return new ColumnIgnoreValue(bound); + } + + @Override + public ColumnIgnore unmarshal(ColumnIgnoreValue value) throws Exception { + return new ColumnIgnore(value.getPosition()); + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnPositionAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnPositionAdapter.java new file mode 100644 index 00000000..5d84137c --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnPositionAdapter.java @@ -0,0 +1,23 @@ +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.ColumnPositionValue; +import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; + + +public class ColumnPositionAdapter + extends XmlAdapter { + + @Override + public ColumnPositionValue marshal(ColumnPosition bound) + throws Exception { + return new ColumnPositionValue(bound); + } + + @Override + public ColumnPosition unmarshal(ColumnPositionValue value) + throws Exception { + return new ColumnPosition(value.getIndex()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAdapter.java new file mode 100644 index 00000000..807ce499 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAdapter.java @@ -0,0 +1,21 @@ +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.ColumnRelationValue; +import cz.cuni.mff.xrg.odalic.feedbacks.ColumnRelation; + + +public class ColumnRelationAdapter extends XmlAdapter { + + @Override + public ColumnRelationValue marshal(ColumnRelation bound) throws Exception { + return new ColumnRelationValue(bound); + } + + @Override + public ColumnRelation unmarshal(ColumnRelationValue value) throws Exception { + return new ColumnRelation(value.getSubjectColumnPosition(), value.getObjectColumnPosition(), + value.getEntity()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/DisambiguationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/DisambiguationAdapter.java new file mode 100644 index 00000000..cb23c69b --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/DisambiguationAdapter.java @@ -0,0 +1,23 @@ +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.DisambiguationValue; +import cz.cuni.mff.xrg.odalic.feedbacks.Disambiguation; + + +public class DisambiguationAdapter + extends XmlAdapter { + + @Override + public DisambiguationValue marshal(Disambiguation bound) + throws Exception { + return new DisambiguationValue(bound); + } + + @Override + public Disambiguation unmarshal(DisambiguationValue value) + throws Exception { + return new Disambiguation(value.getPosition(), value.getEntity()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityAdapter.java new file mode 100644 index 00000000..72e10944 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityAdapter.java @@ -0,0 +1,24 @@ +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.EntityValue; +import cz.cuni.mff.xrg.odalic.feedbacks.types.Entity; + + +public class EntityAdapter + extends XmlAdapter { + + @Override + public EntityValue marshal(Entity bound) + throws Exception { + return new EntityValue(bound); + } + + @Override + public Entity unmarshal(EntityValue value) + throws Exception { + return new Entity(value.getResource(), + value.getLabel()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/FeedbackAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/FeedbackAdapter.java new file mode 100644 index 00000000..beb75fd7 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/FeedbackAdapter.java @@ -0,0 +1,22 @@ +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.FeedbackValue; +import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; + + +public class FeedbackAdapter extends XmlAdapter { + + @Override + public FeedbackValue marshal(Feedback bound) throws Exception { + return new FeedbackValue(bound); + } + + @Override + public Feedback unmarshal(FeedbackValue value) throws Exception { + return new Feedback(value.getSubjectColumnPosition(), value.getColumnIgnores(), + value.getColumnAmbiguities(), value.getClassifications(), value.getCellRelations(), + value.getColumnRelations(), value.getDisambiguations(), value.getAmbiguities()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/RowPositionAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/RowPositionAdapter.java new file mode 100644 index 00000000..81cb4a63 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/RowPositionAdapter.java @@ -0,0 +1,23 @@ +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.RowPositionValue; +import cz.cuni.mff.xrg.odalic.feedbacks.types.RowPosition; + + +public class RowPositionAdapter + extends XmlAdapter { + + @Override + public RowPositionValue marshal(RowPosition bound) + throws Exception { + return new RowPositionValue(bound); + } + + @Override + public RowPosition unmarshal(RowPositionValue value) + throws Exception { + return new RowPosition(value.getIndex()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/Message.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/Message.java index cce9ce4d..14ab4e47 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/Message.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/Message.java @@ -7,18 +7,24 @@ @XmlRootElement public class Message { - @XmlElement(name = "status") + @XmlElement int status; - @XmlElement(name = "text") + @XmlElement String text; - @XmlElement(name = "link") + @XmlElement String link; - @XmlElement(name = "developerText") + @XmlElement String developerText; + public Message() {} + + public Message(int status) { + this.status = status; + } + public int getStatus() { return status; } @@ -50,10 +56,4 @@ public String getLink() { public void setLink(String link) { this.link = link; } - - public Message() {} - - public Message(int status) { - this.status = status; - } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ConfigurationResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ConfigurationResource.java new file mode 100644 index 00000000..a4c7d5b9 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ConfigurationResource.java @@ -0,0 +1,44 @@ +package cz.cuni.mff.xrg.odalic.api.rest.resources; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; +import cz.cuni.mff.xrg.odalic.tasks.configurations.ConfigurationService; + +@Component +@Path("/tasks/{id}/configuration") +public class ConfigurationResource { + + private ConfigurationService configurationService; + + @PUT + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response putConfigurationForTaskId(@PathParam("id") String id, Configuration configuration) { + configurationService.setConfigurationForTaskId(id, configuration); + return Response.status(Response.Status.OK).entity("Configuration set.").build(); + } + + @GET + @Produces(MediaType.APPLICATION_JSON) + public Response getConfigurationForTaskId(@PathParam("id") String taskId) { + Configuration configurationForTaskId = configurationService.getConfigurationForTaskId(taskId); + + return Response.status(Response.Status.OK).entity(configurationForTaskId).build(); + } + + @Autowired + public ConfigurationResource(ConfigurationService configurationService) { + this.configurationService = configurationService; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/DraftResource.java similarity index 78% rename from odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftResource.java rename to odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/DraftResource.java index e1c0e54b..2f9cacce 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/DraftResource.java @@ -1,9 +1,11 @@ -package cz.cuni.mff.xrg.odalic.tasks.drafts; +package cz.cuni.mff.xrg.odalic.api.rest.resources; import javax.ws.rs.Path; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import cz.cuni.mff.xrg.odalic.tasks.drafts.DraftService; + @Component @Path("/tasks/{id}/draft") public class DraftResource { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ExecutionResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ExecutionResource.java new file mode 100644 index 00000000..d06ed211 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ExecutionResource.java @@ -0,0 +1,53 @@ +package cz.cuni.mff.xrg.odalic.api.rest.resources; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import cz.cuni.mff.xrg.odalic.tasks.executions.Execution; +import cz.cuni.mff.xrg.odalic.tasks.executions.ExecutionService; + +@Component +@Path("/tasks/{id}/execution") +public class ExecutionResource { + + private ExecutionService executionService; + + @PUT + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response putExecutionForTaskId(@PathParam("id") String id, Execution execution) { + executionService.scheduleExecutionForTaskId(id, execution); + return Response.status(Response.Status.OK).entity("Execution scheduled.").build(); + } + + @GET + @Produces(MediaType.APPLICATION_JSON) + public Response getExecutionForTaskId(@PathParam("id") String taskId) { + Execution executionForTaskId = executionService.getExecutionForTaskId(taskId); + + return Response.status(Response.Status.OK).entity(executionForTaskId).build(); + } + + @DELETE + @Produces({MediaType.APPLICATION_JSON}) + public Response deleteExecutionForTaskId(@PathParam("id") String id) { + executionService.stopExecutionForTaskId(id); + return Response.status(Response.Status.OK) + .entity("Execution signaled to stop.").build(); + } + + @Autowired + public ExecutionResource(ExecutionService executionService) { + this.executionService = executionService; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java similarity index 54% rename from odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileResource.java rename to odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java index 9a617ec8..1064b562 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java @@ -1,5 +1,7 @@ -package cz.cuni.mff.xrg.odalic.files; +package cz.cuni.mff.xrg.odalic.api.rest.resources; +import java.io.IOException; +import java.io.InputStream; import java.util.List; import javax.ws.rs.Consumes; @@ -12,9 +14,16 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import org.glassfish.jersey.media.multipart.FormDataContentDisposition; +import org.glassfish.jersey.media.multipart.FormDataParam; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.files.File; +import cz.cuni.mff.xrg.odalic.files.FileService; + /** * File resource definition. * @@ -26,6 +35,13 @@ public class FileResource { private FileService fileService; + @Autowired + public FileResource(FileService fileService) { + Preconditions.checkNotNull(fileService); + + this.fileService = fileService; + } + @GET @Produces(MediaType.APPLICATION_JSON) public List getFiles() { @@ -40,28 +56,57 @@ public Response getFileById(@PathParam("id") String id) { return Response.status(Response.Status.OK).entity(file).build(); } + @PUT + @Path("{id}") + @Consumes(MediaType.MULTIPART_FORM_DATA) + @Produces(MediaType.APPLICATION_JSON) + public Response putFileById( + @PathParam("id") String id, + @FormDataParam("input") InputStream fileInputStream, + @FormDataParam("disposition") FormDataContentDisposition disposition, + @FormDataParam("file") File file) throws IOException { + + if (!fileService.hasId(file, id)) { + return Response.status(Response.Status.NOT_ACCEPTABLE) + .entity("The ID in the payload is not the same as the ID of resource.").build(); + } + + if (!fileService.existsFileWithId(id)) { + fileService.create(file, fileInputStream); + + return Response.status(Response.Status.CREATED) + .entity("A new file has been created AT THE STANDARD LOCATION.") + .header("Location", "/files/" + String.valueOf(id)).build(); + } else { + fileService.replace(file); + return Response.status(Response.Status.OK) + .entity( + "The file you specified has been fully updated AT THE STANDARD LOCATION.") + .header("Location", "/files/" + String.valueOf(id)).build(); + } + } + @PUT @Path("{id}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response putFileById(@PathParam("id") String id, File file) { + if (!fileService.hasId(file, id)) { return Response.status(Response.Status.NOT_ACCEPTABLE) .entity("The ID in the payload is not the same as the ID of resource.").build(); } - File fileById = fileService.verifyFileExistenceById(id); - - if (fileById == null) { + if (!fileService.existsFileWithId(id)) { fileService.create(file); return Response.status(Response.Status.CREATED) - .entity("A new file has been created AT THE LOCATION you specified") + .entity("A new file has been registered FOR THE LOCATION you specified") .header("Location", "/files/" + String.valueOf(id)).build(); } else { fileService.replace(file); return Response.status(Response.Status.OK) .entity( - "The file you specified has been fully updated AT THE LOCATION you specified.") + "The file description you specified has been fully updated FOR THE LOCATION you specified.") .header("Location", "/files/" + String.valueOf(id)).build(); } } @@ -74,9 +119,4 @@ public Response deleteFileById(@PathParam("id") String id) { return Response.status(Response.Status.NO_CONTENT) .entity("File successfully removed from database").build(); } - - @Autowired - public FileResource(FileService fileService) { - this.fileService = fileService; - } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ResultResource.java similarity index 78% rename from odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultResource.java rename to odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ResultResource.java index e41db613..fc020a2a 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ResultResource.java @@ -1,9 +1,11 @@ -package cz.cuni.mff.xrg.odalic.tasks.results; +package cz.cuni.mff.xrg.odalic.api.rest.resources; import javax.ws.rs.Path; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import cz.cuni.mff.xrg.odalic.tasks.results.ResultService; + @Component @Path("/tasks/{id}/result") public class ResultResource { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/TaskResource.java similarity index 92% rename from odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskResource.java rename to odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/TaskResource.java index acaf3f5f..29f09ecd 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/TaskResource.java @@ -1,4 +1,4 @@ -package cz.cuni.mff.xrg.odalic.tasks; +package cz.cuni.mff.xrg.odalic.api.rest.resources; import java.util.List; @@ -15,6 +15,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import cz.cuni.mff.xrg.odalic.tasks.Task; +import cz.cuni.mff.xrg.odalic.tasks.TaskDigest; +import cz.cuni.mff.xrg.odalic.tasks.TaskService; + /** * Task resource definition. * diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/AmbiguityValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/AmbiguityValue.java new file mode 100644 index 00000000..fe40e798 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/AmbiguityValue.java @@ -0,0 +1,52 @@ +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.feedbacks.Ambiguity; +import cz.cuni.mff.xrg.odalic.feedbacks.types.CellPosition; + +@XmlRootElement(name = "ambiguity") +public final class AmbiguityValue implements Serializable { + + private static final long serialVersionUID = -9087389821835847372L; + + @XmlElement + private CellPosition position; + + public AmbiguityValue() {} + + public AmbiguityValue(Ambiguity adaptee) { + this.position = adaptee.getPosition(); + } + + /** + * @return the position + */ + @Nullable + public CellPosition getPosition() { + return position; + } + + /** + * @param position the position to set + */ + public void setPosition(CellPosition position) { + Preconditions.checkNotNull(position); + + this.position = position; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "AmbiguityValue [position=" + position + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellPositionValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellPositionValue.java new file mode 100644 index 00000000..b378f906 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellPositionValue.java @@ -0,0 +1,74 @@ +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.feedbacks.types.CellPosition; +import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; +import cz.cuni.mff.xrg.odalic.feedbacks.types.RowPosition; + +@XmlRootElement(name = "cellPosition") +public class CellPositionValue { + + @XmlElement + private RowPosition rowPosition; + + @XmlElement + private ColumnPosition columnPosition; + + public CellPositionValue() {} + + /** + * @param adaptee + */ + public CellPositionValue(CellPosition adaptee) { + this.columnPosition = adaptee.getColumnPosition(); + this.rowPosition = adaptee.getRowPosition(); + } + + /** + * @return the rowPosition + */ + @Nullable + public RowPosition getRowPosition() { + return rowPosition; + } + + /** + * @param rowPosition the rowPosition to set + */ + public void setRowPosition(RowPosition rowPosition) { + Preconditions.checkNotNull(rowPosition); + + this.rowPosition = rowPosition; + } + + /** + * @return the columnPosition + */ + @Nullable + public ColumnPosition getColumnPosition() { + return columnPosition; + } + + /** + * @param columnPosition the columnPosition to set + */ + public void setColumnPosition(ColumnPosition columnPosition) { + Preconditions.checkNotNull(columnPosition); + + this.columnPosition = columnPosition; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "CellPositionValue [rowPosition=" + rowPosition + ", columnPosition=" + columnPosition + + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationValue.java new file mode 100644 index 00000000..92685115 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationValue.java @@ -0,0 +1,117 @@ +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.feedbacks.CellRelation; +import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; +import cz.cuni.mff.xrg.odalic.feedbacks.types.Entity; +import cz.cuni.mff.xrg.odalic.feedbacks.types.RowPosition; + +@XmlRootElement(name = "cellRelation") +public final class CellRelationValue implements Serializable { + + private static final long serialVersionUID = -9087389821835847372L; + + @XmlElement + private ColumnPosition subjectColumnPosition; + + @XmlElement + private ColumnPosition objectColumnPosition; + + @XmlElement + private RowPosition rowPosition; + + @XmlElement + private Entity entity; + + public CellRelationValue() {} + + public CellRelationValue(CellRelation adaptee) { + this.subjectColumnPosition = adaptee.getSubjectColumnPosition(); + this.objectColumnPosition = adaptee.getObjectColumnPosition(); + this.rowPosition = adaptee.getRowPosition(); + this.entity = adaptee.getEntity(); + } + + /** + * @return the subjectColumnPosition + */ + @Nullable + public ColumnPosition getSubjectColumnPosition() { + return subjectColumnPosition; + } + + /** + * @param subjectColumnPosition the subjectColumnPosition to set + */ + public void setSubjectColumnPosition(@Nullable ColumnPosition subjectColumnPosition) { + this.subjectColumnPosition = subjectColumnPosition; + } + + /** + * @return the objectColumnPosition + */ + @Nullable + public ColumnPosition getObjectColumnPosition() { + return objectColumnPosition; + } + + /** + * @param objectColumnPosition the objectColumnPosition to set + */ + public void setObjectColumnPosition(ColumnPosition objectColumnPosition) { + Preconditions.checkNotNull(objectColumnPosition); + + this.objectColumnPosition = objectColumnPosition; + } + + /** + * @return the rowPosition + */ + @Nullable + public RowPosition getRowPosition() { + return rowPosition; + } + + /** + * @param rowPosition the rowPosition to set + */ + public void setRowPosition(RowPosition rowPosition) { + Preconditions.checkNotNull(rowPosition); + + this.rowPosition = rowPosition; + } + + /** + * @return the entity + */ + @Nullable + public Entity getEntity() { + return entity; + } + + /** + * @param entity the entity to set + */ + public void setEntity(Entity entity) { + Preconditions.checkNotNull(entity); + + this.entity = entity; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "CellRelationValue [subjectColumnPosition=" + subjectColumnPosition + + ", objectColumnPosition=" + objectColumnPosition + ", rowPosition=" + + rowPosition + ", entity=" + entity + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ClassificationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ClassificationValue.java new file mode 100644 index 00000000..ee5c1774 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ClassificationValue.java @@ -0,0 +1,77 @@ +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; +import java.util.Set; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableSet; + +import cz.cuni.mff.xrg.odalic.feedbacks.Classification; +import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; +import cz.cuni.mff.xrg.odalic.feedbacks.types.Entity; + +@XmlRootElement(name = "classification") +public class ClassificationValue implements Serializable { + + private static final long serialVersionUID = 6470286409364911894L; + + @XmlElement + private ColumnPosition position; + + @XmlElement + private Set entities; + + public ClassificationValue() { + entities = ImmutableSet.of(); + } + + public ClassificationValue(Classification adaptee) { + this.position = adaptee.getPosition(); + this.entities = adaptee.getEntities(); + } + + /** + * @return the position + */ + @Nullable + public ColumnPosition getPosition() { + return position; + } + + /** + * @param position the position to set + */ + public void setPosition(ColumnPosition position) { + Preconditions.checkNotNull(position); + + this.position = position; + } + + /** + * @return the entities + */ + public Set getEntities() { + return entities; + } + + /** + * @param entities the entities to set + */ + public void setEntities(Set entities) { + Preconditions.checkNotNull(entities); + + this.entities = ImmutableSet.copyOf(entities); + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ClassificationValue [position=" + position + ", entities=" + entities + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnAmbiguityValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnAmbiguityValue.java new file mode 100644 index 00000000..3e06f2d4 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnAmbiguityValue.java @@ -0,0 +1,52 @@ +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.feedbacks.ColumnAmbiguity; +import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; + +@XmlRootElement(name = "columnAmbiguity") +public final class ColumnAmbiguityValue implements Serializable { + + private static final long serialVersionUID = -9087389821835847372L; + + @XmlElement + private ColumnPosition position; + + public ColumnAmbiguityValue() {} + + public ColumnAmbiguityValue(ColumnAmbiguity adaptee) { + this.position = adaptee.getPosition(); + } + + /** + * @return the position + */ + @Nullable + public ColumnPosition getPosition() { + return position; + } + + /** + * @param position the position to set + */ + public void setPosition(ColumnPosition position) { + Preconditions.checkNotNull(position); + + this.position = position; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ColumnAmbiguityValue [position=" + position + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnIgnoreValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnIgnoreValue.java new file mode 100644 index 00000000..e5505a5c --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnIgnoreValue.java @@ -0,0 +1,52 @@ +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.feedbacks.ColumnIgnore; +import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; + +@XmlRootElement(name = "columnIgnore") +public final class ColumnIgnoreValue implements Serializable { + + private static final long serialVersionUID = -9087389821835847372L; + + @XmlElement + private ColumnPosition position; + + public ColumnIgnoreValue() {} + + public ColumnIgnoreValue(ColumnIgnore adaptee) { + this.position = adaptee.getPosition(); + } + + /** + * @return the position + */ + @Nullable + public ColumnPosition getPosition() { + return position; + } + + /** + * @param position the position to set + */ + public void setPosition(ColumnPosition position) { + Preconditions.checkNotNull(position); + + this.position = position; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ColumnIgnoreValue [position=" + position + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnPositionValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnPositionValue.java new file mode 100644 index 00000000..910413f3 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnPositionValue.java @@ -0,0 +1,48 @@ +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; + +@XmlRootElement(name = "columnPosition") +public class ColumnPositionValue { + + @XmlElement + private int index; + + public ColumnPositionValue() {} + + /** + * @param adaptee + */ + public ColumnPositionValue(ColumnPosition adaptee) { + this.index = adaptee.getIndex(); + } + + /** + * @return the index + */ + public int getIndex() { + return index; + } + + /** + * @param index the index to set + */ + public void setIndex(int index) { + Preconditions.checkArgument(index >= 0); + + this.index = index; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ColumnPositionValue [index=" + index + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationValue.java new file mode 100644 index 00000000..0b354bcd --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationValue.java @@ -0,0 +1,97 @@ +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.feedbacks.ColumnRelation; +import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; +import cz.cuni.mff.xrg.odalic.feedbacks.types.Entity; + +@XmlRootElement(name = "columnRelation") +public final class ColumnRelationValue implements Serializable { + + private static final long serialVersionUID = -9087389821835847372L; + + @XmlElement + private ColumnPosition subjectColumnPosition; + + @XmlElement + private ColumnPosition objectColumnPosition; + + @XmlElement + private Entity entity; + + public ColumnRelationValue() {} + + public ColumnRelationValue(ColumnRelation adaptee) { + this.subjectColumnPosition = adaptee.getSubjectColumnPosition(); + this.objectColumnPosition = adaptee.getObjectColumnPosition(); + this.entity = adaptee.getEntity(); + } + + /** + * @return the subjectColumnPosition + */ + @Nullable + public ColumnPosition getSubjectColumnPosition() { + return subjectColumnPosition; + } + + /** + * @param subjectColumnPosition the subjectColumnPosition to set + */ + public void setSubjectColumnPosition(ColumnPosition subjectColumnPosition) { + Preconditions.checkNotNull(subjectColumnPosition); + + this.subjectColumnPosition = subjectColumnPosition; + } + + /** + * @return the objectColumnPosition + */ + @Nullable + public ColumnPosition getObjectColumnPosition() { + return objectColumnPosition; + } + + /** + * @param objectColumnPosition the objectColumnPosition to set + */ + public void setObjectColumnPosition(ColumnPosition objectColumnPosition) { + Preconditions.checkNotNull(objectColumnPosition); + + this.objectColumnPosition = objectColumnPosition; + } + + /** + * @return the entity + */ + @Nullable + public Entity getEntity() { + return entity; + } + + /** + * @param entity the entity to set + */ + public void setEntity(Entity entity) { + Preconditions.checkNotNull(entity); + + this.entity = entity; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "CellRelationValue [subjectColumnPosition=" + subjectColumnPosition + + ", objectColumnPosition=" + objectColumnPosition + ", rowPosition=" + + ", entity=" + entity + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/DisambiguationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/DisambiguationValue.java new file mode 100644 index 00000000..c28ec25c --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/DisambiguationValue.java @@ -0,0 +1,74 @@ +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.feedbacks.Disambiguation; +import cz.cuni.mff.xrg.odalic.feedbacks.types.CellPosition; +import cz.cuni.mff.xrg.odalic.feedbacks.types.Entity; + +@XmlRootElement(name = "disambiguation") +public final class DisambiguationValue implements Serializable { + + private static final long serialVersionUID = -9087389821835847372L; + + @XmlElement + private CellPosition position; + + @XmlElement + private Entity entity; + + public DisambiguationValue() {} + + public DisambiguationValue(Disambiguation adaptee) { + this.position = adaptee.getPosition(); + this.entity = adaptee.getEntity(); + } + + /** + * @return the position + */ + @Nullable + public CellPosition getPosition() { + return position; + } + + /** + * @param position the position to set + */ + public void setPosition(CellPosition position) { + Preconditions.checkNotNull(position); + + this.position = position; + } + + /** + * @return the entity + */ + @Nullable + public Entity getEntity() { + return entity; + } + + /** + * @param entity the entity to set + */ + public void setEntity(Entity entity) { + Preconditions.checkNotNull(entity); + + this.entity = entity; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "DisambiguationValue [position=" + position + ", entity=" + entity + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityValue.java new file mode 100644 index 00000000..4f2bc25a --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityValue.java @@ -0,0 +1,73 @@ +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; +import java.net.URI; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.feedbacks.types.Entity; + +@XmlRootElement(name = "entity") +public class EntityValue implements Serializable { + + private static final long serialVersionUID = 5750987769573292984L; + + @XmlElement + private URI resource; + + @XmlElement + private String label; + + public EntityValue() {} + + public EntityValue(Entity adaptee) { + this.resource = adaptee.getResource(); + this.label = adaptee.getLabel(); + } + + /** + * @return the resource + */ + @Nullable + public URI getResource() { + return resource; + } + + /** + * @param resource the resource to set + */ + public void setResouce(URI resource) { + Preconditions.checkNotNull(resource); + + this.resource = resource; + } + + /** + * @return the label + */ + @Nullable + public String getLabel() { + return label; + } + + /** + * @param label the label to set + */ + public void setLabel(String label) { + Preconditions.checkNotNull(label); + + this.label = label; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "EntityValue [resource=" + resource + ", label=" + label + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/FeedbackValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/FeedbackValue.java new file mode 100644 index 00000000..b0882cae --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/FeedbackValue.java @@ -0,0 +1,203 @@ +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; +import java.util.Set; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableSet; + +import cz.cuni.mff.xrg.odalic.feedbacks.Ambiguity; +import cz.cuni.mff.xrg.odalic.feedbacks.CellRelation; +import cz.cuni.mff.xrg.odalic.feedbacks.Classification; +import cz.cuni.mff.xrg.odalic.feedbacks.ColumnAmbiguity; +import cz.cuni.mff.xrg.odalic.feedbacks.ColumnIgnore; +import cz.cuni.mff.xrg.odalic.feedbacks.ColumnRelation; +import cz.cuni.mff.xrg.odalic.feedbacks.Disambiguation; +import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; +import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; + +@XmlRootElement(name = "feedback") +public class FeedbackValue implements Serializable { + + private static final long serialVersionUID = -7968455903789693405L; + + @XmlElement + private ColumnPosition subjectColumnPosition; + + @XmlElement + private Set columnIgnores; + + @XmlElement + private Set columnAmbiguities; + + @XmlElement + private Set classifications; + + @XmlElement + private Set cellRelations; + + @XmlElement + private Set columnRelations; + + @XmlElement + private Set disambiguations; + + @XmlElement + private Set ambiguities; + + public FeedbackValue() { + this.subjectColumnPosition = null; + this.columnIgnores = ImmutableSet.of(); + this.columnAmbiguities = ImmutableSet.of(); + this.classifications = ImmutableSet.of(); + this.cellRelations = ImmutableSet.of(); + this.columnRelations = ImmutableSet.of(); + this.disambiguations = ImmutableSet.of(); + this.ambiguities = ImmutableSet.of(); + } + + public FeedbackValue(Feedback adaptee) { + Preconditions.checkNotNull(adaptee); + + this.subjectColumnPosition = adaptee.getSubjectColumnPosition(); + this.columnIgnores = adaptee.getColumnIgnores(); + this.columnAmbiguities = adaptee.getColumnAmbiguities(); + this.classifications = adaptee.getClassifications(); + this.cellRelations = adaptee.getCellRelations(); + this.columnRelations = adaptee.getColumnRelations(); + this.disambiguations = adaptee.getDisambiguations(); + this.ambiguities = adaptee.getAmbiguities(); + } + + /** + * @return the subjectColumnPosition + */ + @Nullable + public ColumnPosition getSubjectColumnPosition() { + return subjectColumnPosition; + } + + /** + * @param subjectColumnPosition the subjectColumnPosition to set + */ + public void setSubjectColumnPosition(ColumnPosition subjectColumnPosition) { + this.subjectColumnPosition = subjectColumnPosition; + } + + /** + * @return the columnIgnores + */ + public Set getColumnIgnores() { + return columnIgnores; + } + + /** + * @param columnIgnores the columnIgnores to set + */ + public void setColumnIgnores(Set columnIgnores) { + Preconditions.checkNotNull(columnIgnores); + + this.columnIgnores = ImmutableSet.copyOf(columnIgnores); + } + + /** + * @return the columnAmbiguities + */ + public Set getColumnAmbiguities() { + return columnAmbiguities; + } + + /** + * @param columnAmbiguities the columnAmbiguities to set + */ + public void setColumnAmbiguities(Set columnAmbiguities) { + Preconditions.checkNotNull(columnAmbiguities); + + this.columnAmbiguities = ImmutableSet.copyOf(columnAmbiguities); + } + + /** + * @return the classifications + */ + public Set getClassifications() { + return classifications; + } + + /** + * @param classifications the classifications to set + */ + public void setClassifications(Set classifications) { + Preconditions.checkNotNull(classifications); + + this.classifications = ImmutableSet.copyOf(classifications); + } + + /** + * @return the cellRelations + */ + public Set getCellRelations() { + return cellRelations; + } + + /** + * @param cellRelations the cellRelations to set + */ + public void setCellRelations(Set cellRelations) { + Preconditions.checkNotNull(cellRelations); + + this.cellRelations = ImmutableSet.copyOf(cellRelations); + } + + /** + * @return the columnRelations + */ + public Set getColumnRelations() { + return columnRelations; + } + + /** + * @param columnRelations the columnRelations to set + */ + public void setColumnRelations(Set columnRelations) { + Preconditions.checkNotNull(columnRelations); + + this.columnRelations = ImmutableSet.copyOf(columnRelations); + } + + /** + * @return the disambiguations + */ + public Set getDisambiguations() { + return disambiguations; + } + + /** + * @param disambiguations the disambiguations to set + */ + public void setDisambiguations(Set disambiguations) { + Preconditions.checkNotNull(disambiguations); + + this.disambiguations = ImmutableSet.copyOf(disambiguations); + } + + /** + * @return the ambiguities + */ + public Set getAmbiguities() { + return ambiguities; + } + + /** + * @param ambiguities the ambiguities to set + */ + public void setAmbiguities(Set ambiguities) { + Preconditions.checkNotNull(ambiguities); + + this.ambiguities = ImmutableSet.copyOf(ambiguities); + } + + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/RowPositionValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/RowPositionValue.java new file mode 100644 index 00000000..91d5e189 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/RowPositionValue.java @@ -0,0 +1,44 @@ +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import cz.cuni.mff.xrg.odalic.feedbacks.types.RowPosition; + +@XmlRootElement(name = "rowPosition") +public class RowPositionValue { + + @XmlElement + private int index; + + public RowPositionValue() {} + + /** + * @param adaptee + */ + public RowPositionValue(RowPosition adaptee) { + this.index = adaptee.getIndex(); + } + + /** + * @return the index + */ + public int getIndex() { + return index; + } + + /** + * @param index the index to set + */ + public void setIndex(int index) { + this.index = index; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "RowPositionValue [index=" + index + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Ambiguity.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Ambiguity.java new file mode 100644 index 00000000..b6a9971f --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Ambiguity.java @@ -0,0 +1,80 @@ +package cz.cuni.mff.xrg.odalic.feedbacks; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.feedbacks.types.CellPosition; + +@XmlRootElement(name = "ambiguity") +public final class Ambiguity implements Serializable { + + private static final long serialVersionUID = -9087389821835847372L; + + @XmlElement + private final CellPosition position; + + @SuppressWarnings("unused") + private Ambiguity() { + position = null; + } + + public Ambiguity(CellPosition position) { + Preconditions.checkNotNull(position); + + this.position = position; + } + + /** + * @return the position + */ + public CellPosition getPosition() { + return position; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((position == null) ? 0 : position.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Ambiguity other = (Ambiguity) obj; + if (position == null) { + if (other.position != null) { + return false; + } + } else if (!position.equals(other.position)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Ambiguity [position=" + position + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/CellRelation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/CellRelation.java new file mode 100644 index 00000000..f2613c3b --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/CellRelation.java @@ -0,0 +1,156 @@ +package cz.cuni.mff.xrg.odalic.feedbacks; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; +import cz.cuni.mff.xrg.odalic.feedbacks.types.Entity; +import cz.cuni.mff.xrg.odalic.feedbacks.types.RowPosition; + +@XmlRootElement(name = "cellRelation") +public final class CellRelation implements Serializable { + + private static final long serialVersionUID = -9087389821835847372L; + + @XmlElement + private final ColumnPosition subjectColumnPosition; + + @XmlElement + private final ColumnPosition objectColumnPosition; + + @XmlElement + private final RowPosition rowPosition; + + @XmlElement + private final Entity entity; + + @SuppressWarnings("unused") + private CellRelation() { + subjectColumnPosition = null; + objectColumnPosition = null; + rowPosition = null; + entity = null; + } + + /** + * @param subjectColumnPosition + * @param objectColumnPosition + * @param rowPosition + * @param entity + */ + public CellRelation(ColumnPosition subjectColumnPosition, ColumnPosition objectColumnPosition, + RowPosition rowPosition, Entity entity) { + Preconditions.checkNotNull(subjectColumnPosition); + Preconditions.checkNotNull(objectColumnPosition); + Preconditions.checkNotNull(rowPosition); + Preconditions.checkNotNull(entity); + + this.subjectColumnPosition = subjectColumnPosition; + this.objectColumnPosition = objectColumnPosition; + this.rowPosition = rowPosition; + this.entity = entity; + } + + /** + * @return the subjectColumnPosition + */ + public ColumnPosition getSubjectColumnPosition() { + return subjectColumnPosition; + } + + /** + * @return the objectColumnPosition + */ + public ColumnPosition getObjectColumnPosition() { + return objectColumnPosition; + } + + /** + * @return the rowPosition + */ + public RowPosition getRowPosition() { + return rowPosition; + } + + /** + * @return the entity + */ + public Entity getEntity() { + return entity; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((entity == null) ? 0 : entity.hashCode()); + result = + prime * result + ((objectColumnPosition == null) ? 0 : objectColumnPosition.hashCode()); + result = prime * result + ((rowPosition == null) ? 0 : rowPosition.hashCode()); + result = + prime * result + ((subjectColumnPosition == null) ? 0 : subjectColumnPosition.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + CellRelation other = (CellRelation) obj; + if (entity == null) { + if (other.entity != null) { + return false; + } + } else if (!entity.equals(other.entity)) { + return false; + } + if (objectColumnPosition == null) { + if (other.objectColumnPosition != null) { + return false; + } + } else if (!objectColumnPosition.equals(other.objectColumnPosition)) { + return false; + } + if (rowPosition == null) { + if (other.rowPosition != null) { + return false; + } + } else if (!rowPosition.equals(other.rowPosition)) { + return false; + } + if (subjectColumnPosition == null) { + if (other.subjectColumnPosition != null) { + return false; + } + } else if (!subjectColumnPosition.equals(other.subjectColumnPosition)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "CellRelation [subjectColumnPosition=" + subjectColumnPosition + + ", objectColumnPosition=" + objectColumnPosition + ", rowPosition=" + rowPosition + + ", entity=" + entity + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Classification.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Classification.java new file mode 100644 index 00000000..3c95219e --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Classification.java @@ -0,0 +1,104 @@ +package cz.cuni.mff.xrg.odalic.feedbacks; + +import java.io.Serializable; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableSet; + +import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; +import cz.cuni.mff.xrg.odalic.feedbacks.types.Entity; + +@XmlRootElement(name = "classification") +public final class Classification implements Serializable { + + private static final long serialVersionUID = 6053349406668481968L; + + @XmlElement + private final ColumnPosition position; + + @XmlElement + private final Set entities; + + @SuppressWarnings("unused") + private Classification() { + position = null; + entities = ImmutableSet.of(); + } + + public Classification(ColumnPosition position, Set entity) { + Preconditions.checkNotNull(position); + Preconditions.checkNotNull(entity); + + this.position = position; + this.entities = ImmutableSet.copyOf(entity); + } + + /** + * @return the position + */ + public ColumnPosition getPosition() { + return position; + } + + /** + * @return the entity + */ + public Set getEntities() { + return ImmutableSet.copyOf(entities); + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((entities == null) ? 0 : entities.hashCode()); + result = prime * result + ((position == null) ? 0 : position.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Classification other = (Classification) obj; + if (entities == null) { + if (other.entities != null) { + return false; + } + } else if (!entities.equals(other.entities)) { + return false; + } + if (position == null) { + if (other.position != null) { + return false; + } + } else if (!position.equals(other.position)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Classification [position=" + position + ", entities=" + entities + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnAmbiguity.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnAmbiguity.java new file mode 100644 index 00000000..353e7cd5 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnAmbiguity.java @@ -0,0 +1,83 @@ +package cz.cuni.mff.xrg.odalic.feedbacks; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; + +@XmlRootElement(name = "columnAmbiguity") +public final class ColumnAmbiguity implements Serializable { + + private static final long serialVersionUID = -6608929731300596230L; + + @XmlElement + private final ColumnPosition position; + + @SuppressWarnings("unused") + private ColumnAmbiguity() { + position = null; + } + + /** + * @param position + */ + public ColumnAmbiguity(ColumnPosition position) { + Preconditions.checkNotNull(position); + + this.position = position; + } + + /** + * @return the position + */ + public ColumnPosition getPosition() { + return position; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((position == null) ? 0 : position.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ColumnAmbiguity other = (ColumnAmbiguity) obj; + if (position == null) { + if (other.position != null) { + return false; + } + } else if (!position.equals(other.position)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ColumnAmbiguity [position=" + position + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnFeedback.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnFeedback.java deleted file mode 100644 index 6593d111..00000000 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnFeedback.java +++ /dev/null @@ -1,36 +0,0 @@ -package cz.cuni.mff.xrg.odalic.feedbacks; - -import java.io.Serializable; -import java.net.URI; -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement -public class ColumnFeedback implements Serializable { - - private static final long serialVersionUID = -9087389821835847372L; - - @XmlElement(name = "index") - private int index; - - @XmlElement(name = "suggestions") - private Set suggestions; - - public int getIndex() { - return index; - } - - public void setIndex(int index) { - this.index = index; - } - - public Set getSuggestions() { - return suggestions; - } - - public void setSuggestions(Set suggestions) { - this.suggestions = suggestions; - } -} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnIgnore.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnIgnore.java new file mode 100644 index 00000000..536a0b90 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnIgnore.java @@ -0,0 +1,83 @@ +package cz.cuni.mff.xrg.odalic.feedbacks; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; + +@XmlRootElement(name = "columnIgnore") +public final class ColumnIgnore implements Serializable { + + private static final long serialVersionUID = -4305681863714969261L; + + @XmlElement + private final ColumnPosition position; + + @SuppressWarnings("unused") + private ColumnIgnore() { + position = null; + } + + /** + * @param position + */ + public ColumnIgnore(ColumnPosition position) { + Preconditions.checkNotNull(position); + + this.position = position; + } + + /** + * @return the position + */ + public ColumnPosition getPosition() { + return position; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((position == null) ? 0 : position.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ColumnIgnore other = (ColumnIgnore) obj; + if (position == null) { + if (other.position != null) { + return false; + } + } else if (!position.equals(other.position)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ColumnIgnore [position=" + position + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnRelation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnRelation.java new file mode 100644 index 00000000..8703a3a7 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnRelation.java @@ -0,0 +1,138 @@ +package cz.cuni.mff.xrg.odalic.feedbacks; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; +import cz.cuni.mff.xrg.odalic.feedbacks.types.Entity; + +@XmlRootElement(name = "columnRelation") +public final class ColumnRelation implements Serializable { + + private static final long serialVersionUID = -9087389821835847372L; + + @XmlElement + private final ColumnPosition subjectColumnPosition; + + @XmlElement + private final ColumnPosition objectColumnPosition; + + @XmlElement + private final Entity entity; + + @SuppressWarnings("unused") + private ColumnRelation() { + subjectColumnPosition = null; + objectColumnPosition = null; + entity = null; + } + + /** + * @param subjectColumnPosition + * @param objectColumnPosition + * @param entity + */ + public ColumnRelation(ColumnPosition subjectColumnPosition, ColumnPosition objectColumnPosition, + Entity entity) { + Preconditions.checkNotNull(subjectColumnPosition); + Preconditions.checkNotNull(objectColumnPosition); + Preconditions.checkNotNull(entity); + + this.subjectColumnPosition = subjectColumnPosition; + this.objectColumnPosition = objectColumnPosition; + this.entity = entity; + } + + /** + * @return the subjectColumnPosition + */ + public ColumnPosition getSubjectColumnPosition() { + return subjectColumnPosition; + } + + /** + * @return the objectColumnPosition + */ + public ColumnPosition getObjectColumnPosition() { + return objectColumnPosition; + } + + /** + * @return the entity + */ + public Entity getEntity() { + return entity; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((entity == null) ? 0 : entity.hashCode()); + result = + prime * result + ((objectColumnPosition == null) ? 0 : objectColumnPosition.hashCode()); + result = + prime * result + ((subjectColumnPosition == null) ? 0 : subjectColumnPosition.hashCode()); + return result; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ColumnRelation other = (ColumnRelation) obj; + if (entity == null) { + if (other.entity != null) { + return false; + } + } else if (!entity.equals(other.entity)) { + return false; + } + if (objectColumnPosition == null) { + if (other.objectColumnPosition != null) { + return false; + } + } else if (!objectColumnPosition.equals(other.objectColumnPosition)) { + return false; + } + if (subjectColumnPosition == null) { + if (other.subjectColumnPosition != null) { + return false; + } + } else if (!subjectColumnPosition.equals(other.subjectColumnPosition)) { + return false; + } + return true; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "CellRelation [subjectColumnPosition=" + subjectColumnPosition + + ", objectColumnPosition=" + objectColumnPosition + ", entity=" + entity + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Disambiguation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Disambiguation.java new file mode 100644 index 00000000..c038584c --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Disambiguation.java @@ -0,0 +1,105 @@ +package cz.cuni.mff.xrg.odalic.feedbacks; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.feedbacks.types.CellPosition; +import cz.cuni.mff.xrg.odalic.feedbacks.types.Entity; + +@XmlRootElement(name = "disambiguation") +public final class Disambiguation implements Serializable { + + private static final long serialVersionUID = -5229197850609921790L; + + @XmlElement + private final CellPosition position; + + @XmlElement + private final Entity entity; + + public Disambiguation() { + position = null; + entity = null; + } + + /** + * @param position + * @param entity + */ + public Disambiguation(CellPosition position, Entity entity) { + Preconditions.checkNotNull(position); + Preconditions.checkNotNull(entity); + + this.position = position; + this.entity = entity; + } + + /** + * @return the position + */ + public CellPosition getPosition() { + return position; + } + + /** + * @return the entity + */ + public Entity getEntity() { + return entity; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((entity == null) ? 0 : entity.hashCode()); + result = prime * result + ((position == null) ? 0 : position.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Disambiguation other = (Disambiguation) obj; + if (entity == null) { + if (other.entity != null) { + return false; + } + } else if (!entity.equals(other.entity)) { + return false; + } + if (position == null) { + if (other.position != null) { + return false; + } + } else if (!position.equals(other.position)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Disambiguation [position=" + position + ", entity=" + entity + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java index c04d2498..691a9bd5 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java @@ -3,33 +3,281 @@ import java.io.Serializable; import java.util.Set; +import javax.annotation.Nullable; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableSet; -@XmlRootElement -public class Feedback implements Serializable { +import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; + +@XmlRootElement(name = "feedback") +public final class Feedback implements Serializable { private static final long serialVersionUID = -6359038623760039155L; - @XmlElement(name = "subjectColumnIndex") - private int subjectColumnIndex; + @XmlElement + private final ColumnPosition subjectColumnPosition; + + @XmlElement + private final Set columnIgnores; + + @XmlElement + private final Set columnAmbiguities; + + @XmlElement + private final Set classifications; + + @XmlElement + private final Set cellRelations; + + @XmlElement + private final Set columnRelations; + + @XmlElement + private final Set disambiguations; + + @XmlElement + private final Set ambiguities; + + @SuppressWarnings("unused") + private Feedback() { + this.subjectColumnPosition = null; + this.columnIgnores = ImmutableSet.of(); + this.columnAmbiguities = ImmutableSet.of(); + this.classifications = ImmutableSet.of(); + this.cellRelations = ImmutableSet.of(); + this.columnRelations = ImmutableSet.of(); + this.disambiguations = ImmutableSet.of(); + this.ambiguities = ImmutableSet.of(); + } + + /** + * @param columnIgnores + * @param columnAmbiguities + * @param classifications + * @param cellRelations + * @param columnRelations + * @param disambiguations + * @param ambiguities + */ + public Feedback(Set columnIgnores, + Set columnAmbiguities, Set classifications, + Set cellRelations, Set columnRelations, + Set disambiguations, Set ambiguities) { + checkMandatory(columnIgnores, columnAmbiguities, classifications, cellRelations, + columnRelations, disambiguations, ambiguities); + + this.subjectColumnPosition = null; + this.columnIgnores = ImmutableSet.copyOf(columnIgnores); + this.columnAmbiguities = ImmutableSet.copyOf(columnAmbiguities); + this.classifications = ImmutableSet.copyOf(classifications); + this.cellRelations = ImmutableSet.copyOf(cellRelations); + this.columnRelations = ImmutableSet.copyOf(columnRelations); + this.disambiguations = ImmutableSet.copyOf(disambiguations); + this.ambiguities = ImmutableSet.copyOf(ambiguities); + } - @XmlElement(name = "columns") - private Set columns; + private static void checkMandatory(Set columnIgnores, + Set columnAmbiguities, + Set classifications, Set cellRelations, + Set columnRelations, Set disambiguations, + Set ambiguities) { + Preconditions.checkNotNull(columnIgnores); + Preconditions.checkNotNull(columnAmbiguities); + Preconditions.checkNotNull(classifications); + Preconditions.checkNotNull(cellRelations); + Preconditions.checkNotNull(columnRelations); + Preconditions.checkNotNull(disambiguations); + Preconditions.checkNotNull(ambiguities); + } + + /** + * @param subjectColumnIndex + * @param columnIgnores + * @param columnAmbiguities + * @param classifications + * @param cellRelations + * @param columnRelations + * @param disambiguations + * @param ambiguities + */ + public Feedback(ColumnPosition subjectColumnPosition, Set columnIgnores, + Set columnAmbiguities, Set classifications, + Set cellRelations, Set columnRelations, + Set disambiguations, Set ambiguities) { + Preconditions.checkNotNull(subjectColumnPosition); + checkMandatory(columnIgnores, columnAmbiguities, classifications, cellRelations, columnRelations, disambiguations, ambiguities); + + this.subjectColumnPosition = subjectColumnPosition; + this.columnIgnores = ImmutableSet.copyOf(columnIgnores); + this.columnAmbiguities = ImmutableSet.copyOf(columnAmbiguities); + this.classifications = ImmutableSet.copyOf(classifications); + this.cellRelations = ImmutableSet.copyOf(cellRelations); + this.columnRelations = ImmutableSet.copyOf(columnRelations); + this.disambiguations = ImmutableSet.copyOf(disambiguations); + this.ambiguities = ImmutableSet.copyOf(ambiguities); + } + + /** + * @return the subjectColumnPosition + */ + @Nullable + public ColumnPosition getSubjectColumnPosition() { + return subjectColumnPosition; + } + + /** + * @return the columnIgnores + */ + public Set getColumnIgnores() { + return ImmutableSet.copyOf(columnIgnores); + } + + /** + * @return the columnAmbiguities + */ + public Set getColumnAmbiguities() { + return ImmutableSet.copyOf(columnAmbiguities); + } + + /** + * @return the classifications + */ + public Set getClassifications() { + return ImmutableSet.copyOf(classifications); + } + + /** + * @return the cellRelations + */ + public Set getCellRelations() { + return ImmutableSet.copyOf(cellRelations); + } + + /** + * @return the columnRelations + */ + public Set getColumnRelations() { + return ImmutableSet.copyOf(columnRelations); + } + + /** + * @return the disambiguations + */ + public Set getDisambiguations() { + return ImmutableSet.copyOf(disambiguations); + } - public int getSubjectColumnIndex() { - return subjectColumnIndex; + /** + * @return the ambiguities + */ + public Set getAmbiguities() { + return ImmutableSet.copyOf(ambiguities); } - public void setSubjectColumnIndex(int subjectColumnIndex) { - this.subjectColumnIndex = subjectColumnIndex; + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((ambiguities == null) ? 0 : ambiguities.hashCode()); + result = prime * result + ((cellRelations == null) ? 0 : cellRelations.hashCode()); + result = prime * result + ((classifications == null) ? 0 : classifications.hashCode()); + result = prime * result + ((columnAmbiguities == null) ? 0 : columnAmbiguities.hashCode()); + result = prime * result + ((columnIgnores == null) ? 0 : columnIgnores.hashCode()); + result = prime * result + ((columnRelations == null) ? 0 : columnRelations.hashCode()); + result = prime * result + ((disambiguations == null) ? 0 : disambiguations.hashCode()); + result = + prime * result + ((subjectColumnPosition == null) ? 0 : subjectColumnPosition.hashCode()); + return result; } - public Set getColumns() { - return columns; + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Feedback other = (Feedback) obj; + if (ambiguities == null) { + if (other.ambiguities != null) { + return false; + } + } else if (!ambiguities.equals(other.ambiguities)) { + return false; + } + if (cellRelations == null) { + if (other.cellRelations != null) { + return false; + } + } else if (!cellRelations.equals(other.cellRelations)) { + return false; + } + if (classifications == null) { + if (other.classifications != null) { + return false; + } + } else if (!classifications.equals(other.classifications)) { + return false; + } + if (columnAmbiguities == null) { + if (other.columnAmbiguities != null) { + return false; + } + } else if (!columnAmbiguities.equals(other.columnAmbiguities)) { + return false; + } + if (columnIgnores == null) { + if (other.columnIgnores != null) { + return false; + } + } else if (!columnIgnores.equals(other.columnIgnores)) { + return false; + } + if (columnRelations == null) { + if (other.columnRelations != null) { + return false; + } + } else if (!columnRelations.equals(other.columnRelations)) { + return false; + } + if (disambiguations == null) { + if (other.disambiguations != null) { + return false; + } + } else if (!disambiguations.equals(other.disambiguations)) { + return false; + } + if (subjectColumnPosition == null) { + if (other.subjectColumnPosition != null) { + return false; + } + } else if (!subjectColumnPosition.equals(other.subjectColumnPosition)) { + return false; + } + return true; } - public void setColumns(Set columns) { - this.columns = columns; + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Feedback [subjectColumnPosition=" + subjectColumnPosition + ", columnIgnores=" + + columnIgnores + ", columnAmbiguities=" + columnAmbiguities + ", classifications=" + + classifications + ", cellRelations=" + cellRelations + ", columnRelations=" + + columnRelations + ", disambiguations=" + disambiguations + ", ambiguities=" + ambiguities + + "]"; } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/types/CellPosition.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/types/CellPosition.java new file mode 100644 index 00000000..c3ff9ca1 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/types/CellPosition.java @@ -0,0 +1,105 @@ +package cz.cuni.mff.xrg.odalic.feedbacks.types; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +@XmlRootElement(name = "cellPosition") +public final class CellPosition implements Serializable { + + private static final long serialVersionUID = 7955615617737637528L; + + @XmlElement + private final RowPosition rowPosition; + + @XmlElement + private final ColumnPosition columnPosition; + + + @SuppressWarnings("unused") + private CellPosition() { + rowPosition = null; + columnPosition = null; + } + + /** + * @param rowPosition + * @param columnPosition + */ + public CellPosition(RowPosition rowPosition, ColumnPosition columnPosition) { + Preconditions.checkNotNull(rowPosition); + Preconditions.checkNotNull(columnPosition); + + this.rowPosition = rowPosition; + this.columnPosition = columnPosition; + } + + /** + * @return the rowPosition + */ + public RowPosition getRowPosition() { + return rowPosition; + } + + /** + * @return the columnPosition + */ + public ColumnPosition getColumnPosition() { + return columnPosition; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((columnPosition == null) ? 0 : columnPosition.hashCode()); + result = prime * result + ((rowPosition == null) ? 0 : rowPosition.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + CellPosition other = (CellPosition) obj; + if (columnPosition == null) { + if (other.columnPosition != null) { + return false; + } + } else if (!columnPosition.equals(other.columnPosition)) { + return false; + } + if (rowPosition == null) { + if (other.rowPosition != null) { + return false; + } + } else if (!rowPosition.equals(other.rowPosition)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "" + rowPosition + columnPosition; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/types/ColumnPosition.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/types/ColumnPosition.java new file mode 100644 index 00000000..8225a631 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/types/ColumnPosition.java @@ -0,0 +1,85 @@ +package cz.cuni.mff.xrg.odalic.feedbacks.types; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +@XmlRootElement(name = "columnPosition") +public final class ColumnPosition implements Serializable { + + private static final long serialVersionUID = -1179554576389130985L; + + @XmlElement + private final int index; + + @SuppressWarnings("unused") + private ColumnPosition() { + index = Integer.MIN_VALUE; + } + + /** + * @param index + */ + public ColumnPosition(int index) { + Preconditions.checkArgument(index >= 0); + + this.index = index; + } + + + /** + * @return the index + */ + public int getIndex() { + return index; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + index; + return result; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ColumnPosition other = (ColumnPosition) obj; + if (index != other.index) { + return false; + } + return true; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "[" + index + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/types/Entity.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/types/Entity.java new file mode 100644 index 00000000..beb12ad7 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/types/Entity.java @@ -0,0 +1,100 @@ +package cz.cuni.mff.xrg.odalic.feedbacks.types; + +import java.io.Serializable; +import java.net.URI; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import com.google.common.base.Preconditions; + + +/** + * Groups the resource URI and its label in one handy class. + * + * @author Václav Brodec + */ +@XmlRootElement(name = "entity") +public final class Entity implements Serializable { + + private static final long serialVersionUID = -3001706805535088480L; + + @XmlElement + private final URI resource; + + @XmlElement + private final String label; + + @SuppressWarnings("unused") + private Entity() { + resource = null; + label = null; + } + + public Entity(URI resource, String label) { + Preconditions.checkNotNull(resource); + Preconditions.checkNotNull(label); + + this.resource = resource; + this.label = label; + } + + public URI getResource() { + return resource; + } + + public String getLabel() { + return label; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((resource == null) ? 0 : resource.hashCode()); + result = prime * result + ((label == null) ? 0 : label.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Entity other = (Entity) obj; + if (resource == null) { + if (other.resource != null) { + return false; + } + } else if (!resource.equals(other.resource)) { + return false; + } + if (label == null) { + if (other.label != null) { + return false; + } + } else if (!label.equals(other.label)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Annotation [resource=" + resource + ", label=" + label + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/types/RowPosition.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/types/RowPosition.java new file mode 100644 index 00000000..49687382 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/types/RowPosition.java @@ -0,0 +1,77 @@ +package cz.cuni.mff.xrg.odalic.feedbacks.types; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import com.google.common.base.Preconditions; + +@XmlRootElement(name = "rowPosition") +public final class RowPosition implements Serializable { + + private static final long serialVersionUID = 3435359552551500579L; + + @XmlElement + private final int index; + + @SuppressWarnings("unused") + private RowPosition() { + index = Integer.MIN_VALUE; + } + + /** + * @param index + */ + public RowPosition(int index) { + Preconditions.checkArgument(index >= 0); + + this.index = index; + } + + /** + * @return the index + */ + public int getIndex() { + return index; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + index; + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + RowPosition other = (RowPosition) obj; + if (index != other.index) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "[" + index + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/File.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/File.java index b66da420..1d941572 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/File.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/File.java @@ -1,6 +1,7 @@ package cz.cuni.mff.xrg.odalic.files; import java.io.Serializable; +import java.net.URL; import java.util.Date; import javax.xml.bind.annotation.XmlElement; @@ -9,64 +10,171 @@ import org.codehaus.jackson.map.annotate.JsonDeserialize; import org.codehaus.jackson.map.annotate.JsonSerialize; +import com.google.common.base.Preconditions; + import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateSerializer; import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateDeserializer; -@XmlRootElement +@XmlRootElement(name = "file") public class File implements Serializable { private static final long serialVersionUID = -6359038623760039155L; - @XmlElement(name = "id") + @XmlElement private String id; @JsonSerialize(using = CustomJsonDateSerializer.class) @JsonDeserialize(using = CustomJsonDateDeserializer.class) - @XmlElement(name = "uploaded") + @XmlElement private Date uploaded; - @XmlElement(name = "format") - private String format; - - @XmlElement(name = "owner") + @XmlElement private String owner; - - public File(String id, Date uploaded, String format, String owner) { + + @XmlElement + private URL location; + + @SuppressWarnings("unused") + private File() { + id = null; + uploaded = null; + owner = null; + } + + public File(String id, Date uploaded, String owner, URL location) { + Preconditions.checkNotNull(id); + Preconditions.checkNotNull(uploaded); + Preconditions.checkNotNull(owner); + Preconditions.checkNotNull(location); + this.id = id; this.uploaded = uploaded; - this.format = format; this.owner = owner; + this.location = location; } + /** + * @return the id + */ public String getId() { return id; } + /** + * @param id the id to set + */ public void setId(String id) { this.id = id; } + /** + * @return the uploaded + */ public Date getUploaded() { return uploaded; } + /** + * @param uploaded the uploaded to set + */ public void setUploaded(Date uploaded) { this.uploaded = uploaded; } - public String getFormat() { - return format; - } - - public void setFormat(String format) { - this.format = format; - } - + /** + * @return the owner + */ public String getOwner() { return owner; } + /** + * @param owner the owner to set + */ public void setOwner(String owner) { this.owner = owner; } + + /** + * @return the location + */ + public URL getLocation() { + return location; + } + + /** + * @param location the location to set + */ + public void setLocation(URL location) { + this.location = location; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((location == null) ? 0 : location.hashCode()); + result = prime * result + ((owner == null) ? 0 : owner.hashCode()); + result = prime * result + ((uploaded == null) ? 0 : uploaded.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + File other = (File) obj; + if (id == null) { + if (other.id != null) { + return false; + } + } else if (!id.equals(other.id)) { + return false; + } + if (location == null) { + if (other.location != null) { + return false; + } + } else if (!location.equals(other.location)) { + return false; + } + if (owner == null) { + if (other.owner != null) { + return false; + } + } else if (!owner.equals(other.owner)) { + return false; + } + if (uploaded == null) { + if (other.uploaded != null) { + return false; + } + } else if (!uploaded.equals(other.uploaded)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "File [id=" + id + ", uploaded=" + uploaded + ", owner=" + owner + ", location=" + + location + "]"; + } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileService.java index 8d4458bb..e54c6c86 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileService.java @@ -1,11 +1,15 @@ package cz.cuni.mff.xrg.odalic.files; +import java.io.IOException; +import java.io.InputStream; import java.util.List; public interface FileService { void create(File file); + void create(File file, InputStream fileInputStream) throws IOException; + void deleteById(String id); File getById(String id); @@ -13,9 +17,10 @@ public interface FileService { List getFiles(); void replace(File file); + + void replace(File file, InputStream fileInputStream) throws IOException; - File verifyFileExistenceById(String id); + boolean existsFileWithId(String id); boolean hasId(File file, String id); - } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/MemoryOnlyFileService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/MemoryOnlyFileService.java index 974de820..f007019d 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/MemoryOnlyFileService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/MemoryOnlyFileService.java @@ -3,8 +3,17 @@ */ package cz.cuni.mff.xrg.odalic.files; -import java.util.Collections; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.HashMap; import java.util.List; +import java.util.Map; + +import org.apache.commons.io.IOUtils; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; /** * @author Václav Brodec @@ -12,62 +21,99 @@ */ public final class MemoryOnlyFileService implements FileService { - public MemoryOnlyFileService() {} + private final Map files = new HashMap<>(); + + private final Map data = new HashMap<>(); + /* (non-Javadoc) * @see cz.cuni.mff.xrg.odalic.files.FileService#create(cz.cuni.mff.xrg.odalic.files.File) */ public void create(File file) { - // TODO Auto-generated method stub + if (existsFileWithId(file.getId())) { + throw new IllegalArgumentException(); + } + + replace(file); + } + + @Override + public void create(File file, InputStream fileInputStream) throws IOException { + if (existsFileWithId(file.getId())) { + throw new IllegalArgumentException(); + } + + replace(file, fileInputStream); } /* (non-Javadoc) * @see cz.cuni.mff.xrg.odalic.files.FileService#deleteById(java.lang.String) */ public void deleteById(String id) { - // TODO Auto-generated method stub + Preconditions.checkNotNull(id); + + File file = this.files.remove(id); + if (file == null) { + throw new IllegalArgumentException(); + } + + this.data.remove(file.getLocation()); } /* (non-Javadoc) * @see cz.cuni.mff.xrg.odalic.files.FileService#getById(java.lang.String) */ public File getById(String id) { - // TODO Auto-generated method stub - return null; + Preconditions.checkNotNull(id); + + File file = this.files.get(id); + if (file == null) { + throw new IllegalArgumentException(); + } + + return file; } /* (non-Javadoc) * @see cz.cuni.mff.xrg.odalic.files.FileService#getFiles() */ public List getFiles() { - // TODO Auto-generated method stub - return Collections.emptyList(); + return ImmutableList.copyOf(this.files.values()); } /* (non-Javadoc) * @see cz.cuni.mff.xrg.odalic.files.FileService#replace(cz.cuni.mff.xrg.odalic.files.File) */ public void replace(File file) { - // TODO Auto-generated method stub + this.files.put(file.getId(), file); + } + + + @Override + public void replace(File file, InputStream fileInputStream) throws IOException { + this.files.put(file.getId(), file); + this.data.put(file.getLocation(), IOUtils.toString(fileInputStream)); } /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.files.FileService#verifyFileExistenceById(java.lang.String) + * @see cz.cuni.mff.xrg.odalic.files.FileService#existsFileWithId(java.lang.String) */ - public File verifyFileExistenceById(String id) { - // TODO Auto-generated method stub - return null; + public boolean existsFileWithId(String id) { + Preconditions.checkNotNull(id); + + return this.files.containsKey(id); } /* (non-Javadoc) * @see cz.cuni.mff.xrg.odalic.files.FileService#hasId(cz.cuni.mff.xrg.odalic.files.File, java.lang.String) */ public boolean hasId(File file, String id) { + Preconditions.checkNotNull(id); + if (file.getId() == null) { return false; } return file.getId().equals(id); } - } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/Task.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/Task.java index a24f03b9..3464d817 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/Task.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/Task.java @@ -10,83 +10,173 @@ import org.codehaus.jackson.map.annotate.JsonDeserialize; import org.codehaus.jackson.map.annotate.JsonSerialize; +import com.google.common.base.Preconditions; + import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateDeserializer; import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateSerializer; import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; import cz.cuni.mff.xrg.odalic.tasks.results.Result; -@XmlRootElement -public class Task implements Serializable { +@XmlRootElement(name = "task") +public final class Task implements Serializable { private static final long serialVersionUID = 1610346823333685091L; - @XmlElement(name = "id") - private String id; + @XmlElement + private final String id; @JsonSerialize(using = CustomJsonDateSerializer.class) @JsonDeserialize(using = CustomJsonDateDeserializer.class) - @XmlElement(name = "created") - private Date created; + @XmlElement + private final Date created; - @XmlElement(name = "input") - private URL input; + @XmlElement + private final URL input; - @XmlElement(name = "feedback") - private Feedback feedback; - - @XmlElement(name = "state") - private State state; + @XmlElement + private final Feedback feedback; - @XmlElement(name = "result") - private Result result; + @XmlElement + private final Result result; + + @SuppressWarnings("unused") + private Task() { + id = null; + created = null; + input = null; + feedback = null; + result = null; + } - public Task() {} + /** + * @param id + * @param created + * @param input + * @param feedback + * @param result + */ + public Task(String id, Date created, URL input, Feedback feedback, Result result) { + Preconditions.checkNotNull(id); + Preconditions.checkNotNull(input); + Preconditions.checkNotNull(feedback); + Preconditions.checkNotNull(result); + + this.id = id; + this.created = created; + this.input = input; + this.feedback = feedback; + this.result = result; + } + /** + * @return the id + */ public String getId() { return id; } - public void setId(String id) { - this.id = id; - } - + /** + * @return the created + */ public Date getCreated() { return created; } - public void setCreated(Date created) { - this.created = created; - } - + /** + * @return the input + */ public URL getInput() { return input; } - public void setInput(URL input) { - this.input = input; - } - + /** + * @return the feedback + */ public Feedback getFeedback() { return feedback; } - public void setFeedback(Feedback feedback) { - this.feedback = feedback; + /** + * @return the result + */ + public Result getResult() { + return result; } - public State getState() { - return state; + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((created == null) ? 0 : created.hashCode()); + result = prime * result + ((feedback == null) ? 0 : feedback.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((input == null) ? 0 : input.hashCode()); + result = prime * result + ((this.result == null) ? 0 : this.result.hashCode()); + return result; } - public void setState(State state) { - this.state = state; + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Task other = (Task) obj; + if (created == null) { + if (other.created != null) { + return false; + } + } else if (!created.equals(other.created)) { + return false; + } + if (feedback == null) { + if (other.feedback != null) { + return false; + } + } else if (!feedback.equals(other.feedback)) { + return false; + } + if (id == null) { + if (other.id != null) { + return false; + } + } else if (!id.equals(other.id)) { + return false; + } + if (input == null) { + if (other.input != null) { + return false; + } + } else if (!input.equals(other.input)) { + return false; + } + if (result == null) { + if (other.result != null) { + return false; + } + } else if (!result.equals(other.result)) { + return false; + } + return true; } - public Result getResult() { - return result; + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Task [id=" + id + ", created=" + created + ", input=" + input + ", feedback=" + feedback + + ", result=" + result + "]"; } - - public void setResult(Result result) { - this.result = result; - } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java index 06d4f0e4..5181ed41 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java @@ -1,10 +1,38 @@ package cz.cuni.mff.xrg.odalic.tasks.configurations; import java.io.Serializable; +import java.net.URL; +import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; + @XmlRootElement public class Configuration implements Serializable { private static final long serialVersionUID = -6359038623760039155L; + + @XmlElement(name = "input") + private URL input; + + @XmlElement(name = "feedback") + private Feedback feedback; + + public Configuration() {} + + public URL getInput() { + return input; + } + + public void setInput(URL input) { + this.input = input; + } + + public Feedback getFeedback() { + return feedback; + } + + public void setFeedback(Feedback feedback) { + this.feedback = feedback; + } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationResource.java deleted file mode 100644 index 331113b3..00000000 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationResource.java +++ /dev/null @@ -1,20 +0,0 @@ -package cz.cuni.mff.xrg.odalic.tasks.configurations; - -import javax.ws.rs.Path; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -@Path("/tasks/{id}/configuration") -public class ConfigurationResource { - - @SuppressWarnings("unused") - private ConfigurationService configurationService; - - //TODO: Methods. - - @Autowired - public ConfigurationResource(ConfigurationService configurationService) { - this.configurationService = configurationService; - } -} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationService.java index 8cd5ff83..ed7be26e 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationService.java @@ -1,3 +1,10 @@ package cz.cuni.mff.xrg.odalic.tasks.configurations; -public interface ConfigurationService {} +public interface ConfigurationService { + + void setConfigurationForTaskId(String id, Configuration execution); + + Configuration getConfigurationForTaskId(String id); + + void deleteConfigurationForTaskId(String id); +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationServiceImpl.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationServiceImpl.java index 06fa8322..175e154d 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationServiceImpl.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationServiceImpl.java @@ -7,4 +7,20 @@ * @author Václav Brodec * */ -public final class ConfigurationServiceImpl implements ConfigurationService {} +public final class ConfigurationServiceImpl implements ConfigurationService { + + @Override + public void setConfigurationForTaskId(String id, Configuration execution) { + // TODO Auto-generated method stub + } + + @Override + public Configuration getConfigurationForTaskId(String id) { + // TODO Auto-generated method stub + return null; + } + + @Override + public void deleteConfigurationForTaskId(String id) { + // TODO Auto-generated method stub + }} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/Execution.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/Execution.java index f9be993e..5f084137 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/Execution.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/Execution.java @@ -1,10 +1,50 @@ package cz.cuni.mff.xrg.odalic.tasks.executions; import java.io.Serializable; +import java.net.URL; + +import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import cz.cuni.mff.xrg.odalic.tasks.State; + @XmlRootElement public class Execution implements Serializable { private static final long serialVersionUID = -6359038623760039155L; + + @XmlElement(name = "state") + private State state; + + @XmlElement(name = "draft") + private boolean draft; + + @XmlElement(name = "result") + private URL result; + + public State getState() { + return state; + } + + public void setState(State state) { + this.state = state; + } + + public boolean isDraft() { + return draft; + } + + public void setDraft(boolean draft) { + this.draft = draft; + } + + public URL getResult() { + return result; + } + + public void setResult(URL result) { + this.result = result; + } + + public Execution() {} } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionResource.java deleted file mode 100644 index a24cd6ae..00000000 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionResource.java +++ /dev/null @@ -1,20 +0,0 @@ -package cz.cuni.mff.xrg.odalic.tasks.executions; - -import javax.ws.rs.Path; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -@Path("/tasks/{id}/execution") -public class ExecutionResource { - - @SuppressWarnings("unused") - private ExecutionService executionService; - - // TODO: Methods. - - @Autowired - public ExecutionResource(ExecutionService executionService) { - this.executionService = executionService; - } -} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionService.java index 0f312d73..85fac9a5 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionService.java @@ -1,7 +1,9 @@ package cz.cuni.mff.xrg.odalic.tasks.executions; public interface ExecutionService { - + void scheduleExecutionForTaskId(String id, Execution execution); + Execution getExecutionForTaskId(String id); + void stopExecutionForTaskId(String id); } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionServiceImpl.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionServiceImpl.java index 5b1ad15d..dd4b141a 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionServiceImpl.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionServiceImpl.java @@ -7,4 +7,20 @@ * @author Václav Brodec * */ -public final class ExecutionServiceImpl implements ExecutionService {} +public final class ExecutionServiceImpl implements ExecutionService { + + @Override + public void scheduleExecutionForTaskId(String id, Execution execution) { + // TODO Auto-generated method stub + } + + @Override + public Execution getExecutionForTaskId(String id) { + // TODO Auto-generated method stub + return null; + } + + @Override + public void stopExecutionForTaskId(String id) { + // TODO Auto-generated method stub + }} diff --git a/odalic/src/main/resources/spring/applicationContext.xml b/odalic/src/main/resources/spring/applicationContext.xml index 19c75b02..351d4926 100644 --- a/odalic/src/main/resources/spring/applicationContext.xml +++ b/odalic/src/main/resources/spring/applicationContext.xml @@ -21,10 +21,10 @@ - - - - - - + + + + + + \ No newline at end of file From 1f740c2204189084ec01c782f437840f4709477c Mon Sep 17 00:00:00 2001 From: brodecva Date: Mon, 20 Jun 2016 04:51:21 +0200 Subject: [PATCH 018/211] File access implementation. --- .../api/rest/resources/FileResource.java | 43 ++++++++++++++----- .../mff/xrg/odalic/files/FileService.java | 2 + .../odalic/files/MemoryOnlyFileService.java | 16 ++++++- 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java index 1064b562..87b3e36a 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java @@ -2,6 +2,8 @@ import java.io.IOException; import java.io.InputStream; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; import java.util.List; import javax.ws.rs.Consumes; @@ -11,8 +13,10 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; +import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.glassfish.jersey.media.multipart.FormDataParam; @@ -33,15 +37,17 @@ @Path("/files") public class FileResource { + public static final String TEXT_CSV_MEDIA_TYPE = "text/csv"; + private FileService fileService; @Autowired public FileResource(FileService fileService) { Preconditions.checkNotNull(fileService); - + this.fileService = fileService; } - + @GET @Produces(MediaType.APPLICATION_JSON) public List getFiles() { @@ -60,12 +66,11 @@ public Response getFileById(@PathParam("id") String id) { @Path("{id}") @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) - public Response putFileById( - @PathParam("id") String id, + public Response putFileById(@PathParam("id") String id, @FormDataParam("input") InputStream fileInputStream, @FormDataParam("disposition") FormDataContentDisposition disposition, @FormDataParam("file") File file) throws IOException { - + if (!fileService.hasId(file, id)) { return Response.status(Response.Status.NOT_ACCEPTABLE) .entity("The ID in the payload is not the same as the ID of resource.").build(); @@ -73,25 +78,24 @@ public Response putFileById( if (!fileService.existsFileWithId(id)) { fileService.create(file, fileInputStream); - + return Response.status(Response.Status.CREATED) .entity("A new file has been created AT THE STANDARD LOCATION.") .header("Location", "/files/" + String.valueOf(id)).build(); } else { fileService.replace(file); return Response.status(Response.Status.OK) - .entity( - "The file you specified has been fully updated AT THE STANDARD LOCATION.") + .entity("The file you specified has been fully updated AT THE STANDARD LOCATION.") .header("Location", "/files/" + String.valueOf(id)).build(); } } - + @PUT @Path("{id}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response putFileById(@PathParam("id") String id, File file) { - + if (!fileService.hasId(file, id)) { return Response.status(Response.Status.NOT_ACCEPTABLE) .entity("The ID in the payload is not the same as the ID of resource.").build(); @@ -119,4 +123,23 @@ public Response deleteFileById(@PathParam("id") String id) { return Response.status(Response.Status.NO_CONTENT) .entity("File successfully removed from database").build(); } + + @GET + @Path("{id}") + @Produces(TEXT_CSV_MEDIA_TYPE) + public Response getDataById(@PathParam("id") String id) throws IOException { + String data = fileService.getDataById(id); + + StreamingOutput output = new StreamingOutput() { + + @Override + public void write(OutputStream output) throws IOException, WebApplicationException { + output.write(data.getBytes(StandardCharsets.UTF_8)); + output.flush(); + } + + }; + + return Response.status(Response.Status.OK).entity(output).type(TEXT_CSV_MEDIA_TYPE).build(); + } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileService.java index e54c6c86..bb94d9d9 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileService.java @@ -23,4 +23,6 @@ public interface FileService { boolean existsFileWithId(String id); boolean hasId(File file, String id); + + String getDataById(String id) throws IOException; } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/MemoryOnlyFileService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/MemoryOnlyFileService.java index f007019d..159f199e 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/MemoryOnlyFileService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/MemoryOnlyFileService.java @@ -6,6 +6,7 @@ import java.io.IOException; import java.io.InputStream; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -92,7 +93,7 @@ public void replace(File file) { @Override public void replace(File file, InputStream fileInputStream) throws IOException { this.files.put(file.getId(), file); - this.data.put(file.getLocation(), IOUtils.toString(fileInputStream)); + this.data.put(file.getLocation(), IOUtils.toString(fileInputStream, StandardCharsets.UTF_8)); } /* (non-Javadoc) @@ -116,4 +117,17 @@ public boolean hasId(File file, String id) { return file.getId().equals(id); } + + @Override + public String getDataById(String id) throws IOException { + File file = getById(id); + + String data = this.data.get(file.getLocation()); + if (data == null) { + return IOUtils.toString(file.getLocation(), StandardCharsets.UTF_8); + } else { + return data; + } + + } } From ab70ed08511c391088dc1a76c6816a80ed891c9f Mon Sep 17 00:00:00 2001 From: JanVana Date: Mon, 20 Jun 2016 08:32:43 +0200 Subject: [PATCH 019/211] #1, #3, #70 Merge branch 'develop' of https://github.com/odalic/sti into Dbpedia # Conflicts: # any23-sti/pom.xml # common-util/pom.xml # core/pom.xml # kbsearch/pom.xml --- any23-sti/pom.xml | 1 - .../kbsearch/dbpedia/DBpediaQueryProxy.java | 5 + .../dcs/kbsearch/dbpedia/DbpediaEnum.java | 13 +- .../dcs/kbsearch/dbpedia/DbpediaSearch.java | 318 +++++++++++++++++- 4 files changed, 315 insertions(+), 22 deletions(-) diff --git a/any23-sti/pom.xml b/any23-sti/pom.xml index 5c343fa3..eab949bd 100644 --- a/any23-sti/pom.xml +++ b/any23-sti/pom.xml @@ -42,7 +42,6 @@ UTF-8 - diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DBpediaQueryProxy.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DBpediaQueryProxy.java index 3205a544..9af588d6 100644 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DBpediaQueryProxy.java +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DBpediaQueryProxy.java @@ -1,5 +1,8 @@ package uk.ac.shef.dcs.kbsearch.dbpedia; +import org.apache.jena.query.Query; +import org.apache.jena.query.QueryFactory; +import org.apache.jena.rdf.model.Model; import uk.ac.shef.dcs.kbsearch.model.Attribute; import uk.ac.shef.dcs.kbsearch.model.Entity; @@ -15,6 +18,8 @@ public double find_granularityForType(String clazz) throws IOException { } public List topicapi_getAttributesOfTopic(String clazzId) { + Query query = QueryFactory.create("test"); + return null; } diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaEnum.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaEnum.java index 18b39ece..5d0cf3a1 100644 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaEnum.java +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaEnum.java @@ -3,14 +3,21 @@ /** * Created by Jan on 18.05.2016. */ -public enum DbpediaEnum { +public enum DBpediaEnum { RELATION_HASALIAS("http://dbpedia.org/ontology/alias"), - RELATION_HASDESCRIPTION("http://dbpedia.org/ontology/description"); + RELATION_HASTYPE("/type/object/type"), + RELATION_RANGEOFPROPERTY("/type/property/expected_type"), + RELATION_HASNAME("/type/object/name"), + RELATION_HASDESCRIPTION("http://dbpedia.org/ontology/description"), + + TYPE_TYPE("/type/type"), + TYPE_PROPERTYOFTYPE("/type/type/properties"), + TYPE_COMMON_TOPIC("/common/topic"); private String string; - DbpediaEnum(String s){ + DBpediaEnum(String s){ this.string=s; } diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaSearch.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaSearch.java index 1b74c559..1b4c0cff 100644 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaSearch.java +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaSearch.java @@ -1,73 +1,355 @@ package uk.ac.shef.dcs.kbsearch.dbpedia; +import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.log4j.Logger; import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; import uk.ac.shef.dcs.kbsearch.KBSearch; import uk.ac.shef.dcs.kbsearch.KBSearchException; import uk.ac.shef.dcs.kbsearch.model.Attribute; +import uk.ac.shef.dcs.kbsearch.model.Clazz; import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.util.SolrCache; +import uk.ac.shef.dcs.util.StringUtils; import java.io.IOException; -import java.util.List; -import java.util.Properties; +import java.util.*; /** * Created by Jan on 18.05.2016. */ -public class DbpediaSearch extends KBSearch { +public class DBpediaSearch extends KBSearch { + private static final Logger LOG = Logger.getLogger(DBpediaSearch.class.getName()); + private static final boolean AUTO_COMMIT = true; - public DbpediaSearch(Properties properties, Boolean fuzzyKeywords, + private DBpediaQueryProxy searcher; + + public DBpediaSearch(Properties properties, Boolean fuzzyKeywords, EmbeddedSolrServer cacheEntity, EmbeddedSolrServer cacheConcept, EmbeddedSolrServer cacheProperty, EmbeddedSolrServer cacheSimilarity) throws IOException { - super(fuzzyKeywords, cacheEntity, cacheConcept, cacheProperty,cacheSimilarity); - } + super(fuzzyKeywords, cacheEntity, cacheConcept, cacheProperty, cacheSimilarity); + + searcher = new DBpediaQueryProxy(); + otherCache = new HashMap<>(); + resultFilter = new DBpediaSearchResultFilter(properties.getProperty(KB_SEARCH_RESULT_STOPLIST)); } @Override public List findEntityCandidates(String content) throws KBSearchException { - return null; + return find_matchingEntitiesForTextAndType(content); } @Override public List findEntityCandidatesOfTypes(String content, String... types) throws KBSearchException { - return null; + return find_matchingEntitiesForTextAndType(content, types); } @Override public List findAttributesOfEntities(Entity ec) throws KBSearchException { - return null; + return find_attributes(ec.getId(), cacheEntity); } @Override - public List findAttributesOfClazz(String clazzId) throws KBSearchException { - return null; + public List findAttributesOfProperty(String propertyId) throws KBSearchException { + return find_attributes(propertyId, cacheProperty); } @Override - public List findAttributesOfProperty(String propertyId) throws KBSearchException { - return null; + public List findAttributesOfClazz(String clazzId) throws KBSearchException { + boolean forceQuery = false; + + List attributes = new ArrayList<>(); + String query = createSolrCacheQuery_findAttributesOfResource(clazzId); + if (query.length() == 0) return attributes; + + try { + attributes = (List) cacheConcept.retrieve(query); + if (attributes != null) + LOG.debug("QUERY (attributes of clazz, cache load)=" + query + "|" + query); + } catch (Exception e) { + } + + if (attributes == null || forceQuery) { + try { + attributes = new ArrayList<>(); + List retrievedAttributes = searcher.topicapi_getAttributesOfTopic(clazzId); + //check firstly, is this a concept? + boolean isConcept = false; + for (Attribute f : retrievedAttributes) { + if (f.getRelationURI().equals(DBpediaEnum.RELATION_HASTYPE.getString()) + && f.getValueURI() != null && f.getValueURI().equals(DBpediaEnum.TYPE_TYPE.getString())) { + isConcept = true; + break; + } + } + if (!isConcept) { + try { + cacheConcept.cache(query, attributes, AUTO_COMMIT); + LOG.debug("QUERY (attributes of clazz, cache save)=" + query + "|" + query); + } catch (Exception e) { + e.printStackTrace(); + } + return attributes; + } + + //ok, this is a concept. We need to deep-fetch its properties, and find out the range of their properties + for (Attribute f : retrievedAttributes) { + if (f.getRelationURI().equals(DBpediaEnum.TYPE_PROPERTYOFTYPE.getString())) { //this is a property of a concept, we need to process it further + String propertyId = f.getValueURI(); + if (propertyId == null) continue; + + List attrOfProperty = findAttributesOfProperty(propertyId); + for (Attribute t : attrOfProperty) { + if (t.getRelationURI().equals(DBpediaEnum.RELATION_RANGEOFPROPERTY.getString())) { + String rangeLabel = t.getValue(); + String rangeURL = t.getValueURI(); + Attribute attr = new DBpediaAttribute(f.getValueURI(), rangeLabel); + attr.setValueURI(rangeURL); + attr.setIsDirect(true); + //attributes.add(new String[]{f[2], rangeLabel, rangeURL, "n"}); + } + } + } else { + attributes.add(f); + } + } + + cacheConcept.cache(query, attributes, AUTO_COMMIT); + LOG.debug("QUERY (attributes of clazz, cache save)=" + query + "|" + query); + } catch (Exception e) { + throw new KBSearchException(e); + } + } + + //filtering + attributes=getResultFilter().filterAttribute(attributes); + return attributes; } @Override public double findGranularityOfClazz(String clazz) throws KBSearchException { - return 0; + /*if(clazz.equals("/location/citytown")) + System.out.println();*/ + String query = createSolrCacheQuery_findGranularityOfClazz(clazz); + Double result = null; + try { + Object o = cacheConcept.retrieve(query); + if (o != null) { + LOG.debug("QUERY (granularity of clazz, cache load)=" + query + "|" + clazz); + return (Double) o; + } + } catch (Exception e) { + } + + if (result == null) { + try { + double granularity = searcher.find_granularityForType(clazz); + result = granularity; + try { + cacheConcept.cache(query, result, AUTO_COMMIT); + LOG.debug("QUERY (granularity of clazz, cache save)=" + query + "|" + clazz); + } catch (Exception e) { + LOG.error("FAILED:" + clazz); + e.printStackTrace(); + } + } catch (IOException ioe) { + LOG.error("ERROR(Instances of Type): Unable to fetch freebase page of instances of type: " + clazz); + } + } + if (result == null) + return -1.0; + return result; } @Override public double findEntityClazzSimilarity(String entity_id, String clazz_url) throws KBSearchException { - return 0; + String query = createSolrCacheQuery_findEntityClazzSimilarity(entity_id, clazz_url); + Object result = null; + try { + result = cacheSimilarity.retrieve(query); + if (result != null) + LOG.debug("QUERY (entity-clazz similarity, cache load)=" + query + "|" + query); + } catch (Exception e) { + } + if (result == null) + return -1.0; + return (Double) result; } @Override - public void cacheEntityClazztSimilarity(String entity_id, String clazz_url, double score, boolean biDirectional, boolean commit) throws KBSearchException { - + public void cacheEntityClazzSimilarity(String entity_id, String clazz_url, double score, boolean biDirectional, boolean commit) throws KBSearchException { + String query = createSolrCacheQuery_findEntityClazzSimilarity(entity_id, clazz_url); + try { + cacheSimilarity.cache(query, score, commit); + LOG.debug("QUERY (entity-clazz similarity, cache saving)=" + query + "|" + query); + if (biDirectional) { + query = clazz_url + "<>" + entity_id; + cacheSimilarity.cache(query, score, commit); + LOG.debug("QUERY (entity-clazz similarity, cache saving)=" + query + "|" + query); + } + } catch (Exception e) { + e.printStackTrace(); + } } @Override public void commitChanges() throws KBSearchException { - + try { + cacheConcept.commit(); + cacheEntity.commit(); + cacheProperty.commit(); + for (SolrCache cache : otherCache.values()) + cache.commit(); + } catch (Exception e) { + throw new KBSearchException(e); + } } @Override public void closeConnection() throws KBSearchException { + try { + if (cacheEntity != null) + cacheEntity.shutdown(); + if (cacheConcept != null) + cacheConcept.shutdown(); + if (cacheProperty != null) + cacheProperty.shutdown(); + } catch (Exception e) { + throw new KBSearchException(e); + } + } + + private List find_matchingEntitiesForTextAndType(String text, String... types) throws KBSearchException { + String query = createSolrCacheQuery_findResources(text); + boolean forceQuery = false; + + text = StringEscapeUtils.unescapeXml(text); + int bracket = text.indexOf("("); + if (bracket != -1) { + text = text.substring(0, bracket).trim(); + } + if (StringUtils.toAlphaNumericWhitechar(text).trim().length() == 0) + return new ArrayList<>(); + + + List result = null; + + if (!forceQuery) { + try { + result = (List) cacheEntity.retrieve(query); + if (result != null) + LOG.debug("QUERY (entities, cache load)=" + query + "|" + query); + } catch (Exception e) { + } + } + if (result == null) { + result = new ArrayList<>(); + try { + //firstly fetch candidate freebase topics. pass 'true' to only keep candidates whose name overlap with the query term + List topics = searcher.searchapi_getTopicsByNameAndType(text, "any", true, 20); //search api does not retrieve complete types, find types for them + LOG.debug("(FB QUERY =" +topics.size()+" results)"); + for (Entity ec : topics) { + //Next get attributes for each topic + List attributes = findAttributesOfEntities(ec); + ec.setAttributes(attributes); + for (Attribute attr : attributes) { + if (attr.getRelationURI().equals(DBpediaEnum.RELATION_HASTYPE.getString()) && + attr.isDirect() && + !ec.hasType(attr.getValueURI())) { + ec.addType(new Clazz(attr.getValueURI(), attr.getValue())); + } + } + } + + if (topics.size() == 0 && fuzzyKeywords) { //does the query has conjunection word? if so, we may need to try again with split queries + String[] queries = text.split("\\band\\b"); + if (queries.length < 2) { + queries = text.split("\\bor\\b"); + if (queries.length < 2) { + queries = text.split("/"); + if (queries.length < 2) { + queries = text.split(","); + } + } + } + if (queries.length > 1) { + for (String q : queries) { + q = q.trim(); + if (q.length() < 1) continue; + result.addAll(find_matchingEntitiesForTextAndType(q, types)); + } + } + } + + result.addAll(topics); + cacheEntity.cache(query, result, AUTO_COMMIT); + LOG.debug("QUERY (entities, cache save)=" + query + "|" + query); + } catch (Exception e) { + throw new KBSearchException(e); + } + } + + if (types.length > 0) { + Iterator it = result.iterator(); + while (it.hasNext()) { + Entity ec = it.next(); + boolean typeSatisfied = false; + for (String t : types) { + if (ec.hasType(t)) { + typeSatisfied = true; + break; + } + } + if (!typeSatisfied) + it.remove(); + } + } + + //filter entity's clazz, and attributes + String id = "|"; + for (Entity ec : result) { + id = id + ec.getId() + ","; + //ec.setTypes(FreebaseSearchResultFilter.filterClazz(ec.getTypes())); + List filteredTypes = getResultFilter().filterClazz(ec.getTypes()); + ec.clearTypes(); + for (Clazz ft : filteredTypes) + ec.addType(ft); + } + + return result; + } + + private List find_attributes(String id, SolrCache cache) throws KBSearchException { + if (id.length() == 0) + return new ArrayList<>(); + boolean forceQuery = false; + + String query = createSolrCacheQuery_findAttributesOfResource(id); + List result = null; + + try { + result = (List) cache.retrieve(query); + if (result != null) + LOG.debug("QUERY (attributes of id, cache load)=" + query + "|" + query); + } catch (Exception e) { + } + if (result == null || forceQuery) { + List attributes; + try { + attributes = searcher.topicapi_getAttributesOfTopic(id); + } catch (Exception e) { + throw new KBSearchException(e); + } + result = new ArrayList<>(); + result.addAll(attributes); + try { + cache.cache(query, result, AUTO_COMMIT); + LOG.debug("QUERY (attributes of id, cache save)=" + query + "|" + query); + } catch (Exception e) { + e.printStackTrace(); + } + } + //filtering + result = getResultFilter().filterAttribute(result); + return result; } } From 638c05789a2809a9ad73198234b36902307603a6 Mon Sep 17 00:00:00 2001 From: Josef Janousek Date: Wed, 22 Jun 2016 16:08:29 +0200 Subject: [PATCH 020/211] Task Service Implementation: #12 --- .../mff/xrg/odalic/tasks/TaskServiceImpl.java | 49 +++++++++++++++---- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskServiceImpl.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskServiceImpl.java index 4981502f..1e248a65 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskServiceImpl.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskServiceImpl.java @@ -1,7 +1,11 @@ package cz.cuni.mff.xrg.odalic.tasks; -import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; /** * @author Václav Brodec @@ -9,18 +13,30 @@ */ public final class TaskServiceImpl implements TaskService { + private final Map tasksDigests = new HashMap<>(); + + private final Map tasks = new HashMap<>(); + public TaskServiceImpl() {} public List getTasks() { - return Collections.emptyList(); + return ImmutableList.copyOf(this.tasksDigests.values()); } public Task getById(String id) { - // TODO Auto-generated method stub - return null; + Preconditions.checkNotNull(id); + + Task task = this.tasks.get(id); + if (task == null) { + throw new IllegalArgumentException(); + } + + return task; } public boolean hasId(Task task, String id) { + Preconditions.checkNotNull(id); + if (task.getId() == null) { return false; } @@ -29,19 +45,34 @@ public boolean hasId(Task task, String id) { } public void deleteById(String id) { - // TODO Auto-generated method stub + Preconditions.checkNotNull(id); + + Task task = this.tasks.remove(id); + if (task == null) { + throw new IllegalArgumentException(); + } } public Task verifyTaskExistenceById(String id) { - // TODO Auto-generated method stub - return null; + Preconditions.checkNotNull(id); + + if(this.tasks.containsKey(id)) { + return this.tasks.get(id); + } + else { + return null; + } } public void create(Task task) { - // TODO Auto-generated method stub + if (verifyTaskExistenceById(task.getId()) != null) { + throw new IllegalArgumentException(); + } + + replace(task); } public void replace(Task task) { - // TODO Auto-generated method stub + this.tasks.put(task.getId(), task); } } From 870a88a2fe32a1c60df2f4e75d480c1fe4fab3d1 Mon Sep 17 00:00:00 2001 From: JanVana Date: Thu, 23 Jun 2016 16:47:46 +0200 Subject: [PATCH 021/211] Adding configuration files to the ignore list --- .gitignore | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index b63534bd..0518cbe7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,15 @@ +# ========================= +# Configuration files +# ========================= + +kbsearch.properties +sti.properties +websearch.properties + +# ========================= +# Operating System Files +# ========================= + # Windows image file caches Thumbs.db ehthumbs.db @@ -18,9 +30,6 @@ $RECYCLE.BIN/ *.lnk # ========================= -# Operating System Files -# ========================= - # OSX # ========================= From 9cd2b7ab5d60ae38100bbfc665a4c393deb5ea16 Mon Sep 17 00:00:00 2001 From: JanVana Date: Thu, 23 Jun 2016 16:50:15 +0200 Subject: [PATCH 022/211] Revert of: Adding configuration files to the ignore list --- .gitignore | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.gitignore b/.gitignore index 0518cbe7..453d7215 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,3 @@ -# ========================= -# Configuration files -# ========================= - -kbsearch.properties -sti.properties -websearch.properties - # ========================= # Operating System Files # ========================= From 1f1453bc37919bdd2ba22e0c539f1462282cd391 Mon Sep 17 00:00:00 2001 From: JanVana Date: Thu, 23 Jun 2016 21:09:07 +0200 Subject: [PATCH 023/211] #70 - Test DBpedia integration --- common-util/pom.xml | 37 +- core/pom.xml | 36 +- kbsearch/pom.xml | 36 +- .../kbsearch/dbpedia/DBpediaQueryProxy.java | 29 -- .../dbpedia/DBpediaSearchResultFilter.java | 88 ----- .../kbsearch/dbpedia/DbpediaAttribute.java | 23 -- .../dcs/kbsearch/dbpedia/DbpediaEnum.java | 27 -- .../dcs/kbsearch/dbpedia/DbpediaSearch.java | 355 ------------------ 8 files changed, 103 insertions(+), 528 deletions(-) delete mode 100644 kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DBpediaQueryProxy.java delete mode 100644 kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DBpediaSearchResultFilter.java delete mode 100644 kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaAttribute.java delete mode 100644 kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaEnum.java delete mode 100644 kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaSearch.java diff --git a/common-util/pom.xml b/common-util/pom.xml index 41110dad..2e460fb9 100644 --- a/common-util/pom.xml +++ b/common-util/pom.xml @@ -11,12 +11,45 @@ org.apache.solr solr-core - 6.0.0 + 5.5.1 + + + org.slf4j + slf4j-log4j12 + + + log4j + log4j + + + org.slf4j + slf4j-jdk14 + + + jdk.tools + jdk.tools + + + org.apache.solr solr-solrj - 6.0.0 + 5.5.1 + + + org.slf4j + slf4j-log4j12 + + + log4j + log4j + + + org.slf4j + slf4j-jdk14 + + diff --git a/core/pom.xml b/core/pom.xml index 636d8024..b2e834c8 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -108,13 +108,45 @@ org.apache.solr solr-core - 6.0.0 + 5.5.1 + + + org.slf4j + slf4j-log4j12 + + + log4j + log4j + + + org.slf4j + slf4j-jdk14 + + + jdk.tools + jdk.tools + + org.apache.solr solr-solrj - 6.0.0 + 5.5.1 + + + org.slf4j + slf4j-log4j12 + + + log4j + log4j + + + org.slf4j + slf4j-jdk14 + + diff --git a/kbsearch/pom.xml b/kbsearch/pom.xml index 77c04b7c..94ef6416 100644 --- a/kbsearch/pom.xml +++ b/kbsearch/pom.xml @@ -69,13 +69,45 @@ org.apache.solr solr-core - 6.0.0 + 5.5.1 + + + org.slf4j + slf4j-log4j12 + + + log4j + log4j + + + org.slf4j + slf4j-jdk14 + + + jdk.tools + jdk.tools + + org.apache.solr solr-solrj - 6.0.0 + 5.5.1 + + + org.slf4j + slf4j-log4j12 + + + log4j + log4j + + + org.slf4j + slf4j-jdk14 + + diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DBpediaQueryProxy.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DBpediaQueryProxy.java deleted file mode 100644 index 9af588d6..00000000 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DBpediaQueryProxy.java +++ /dev/null @@ -1,29 +0,0 @@ -package uk.ac.shef.dcs.kbsearch.dbpedia; - -import org.apache.jena.query.Query; -import org.apache.jena.query.QueryFactory; -import org.apache.jena.rdf.model.Model; -import uk.ac.shef.dcs.kbsearch.model.Attribute; -import uk.ac.shef.dcs.kbsearch.model.Entity; - -import java.io.IOException; -import java.util.List; - -/** - * Created by Jan on 02.06.2016. - */ -public class DBpediaQueryProxy { - public double find_granularityForType(String clazz) throws IOException { - return -1.0; - } - - public List topicapi_getAttributesOfTopic(String clazzId) { - Query query = QueryFactory.create("test"); - - return null; - } - - public List searchapi_getTopicsByNameAndType(String text, String any, boolean b, int i) { - return null; - } -} diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DBpediaSearchResultFilter.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DBpediaSearchResultFilter.java deleted file mode 100644 index f264bf23..00000000 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DBpediaSearchResultFilter.java +++ /dev/null @@ -1,88 +0,0 @@ -package uk.ac.shef.dcs.kbsearch.dbpedia; - -import uk.ac.shef.dcs.kbsearch.KBSearchResultFilter; -import uk.ac.shef.dcs.kbsearch.model.Attribute; -import uk.ac.shef.dcs.kbsearch.model.Clazz; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -/** - * Created by Jan on 24.05.2016. - */ -public class DBpediaSearchResultFilter extends KBSearchResultFilter { - - public DBpediaSearchResultFilter(String stoplistsFile) throws IOException { - super(stoplistsFile); - } - - public boolean isValidClazz(Clazz c) { - /*if (type.startsWith("/user/") || - type.startsWith("/common/")|| - //type.equals("/common/image") || - *//*type.equals("/type/content") || - type.startsWith("/type/type/domain")||*//* - type.startsWith("/type/")|| - type.endsWith("topic") || type.startsWith("/pipeline/") || - type.endsWith("skos_concept") || - type.endsWith("_instance") || - type.startsWith("/base/type_ontology") - ||label.equalsIgnoreCase("topic")||label.equalsIgnoreCase("thing")||label.equalsIgnoreCase("concept") - ||label.equalsIgnoreCase("things")||label.equalsIgnoreCase("entity")) - return true; - return false;*/ - Set stop = stoplists.get(LABEL_INVALID_CLAZZ); - if (stop == null) - return true; - - for (String s : stop) { - if (c.getId().contains(s) || c.getLabel().equalsIgnoreCase(s)) - return false; - } - return true; - - } - - public List filterClazz(Collection types) { - List r = new ArrayList<>(); - if (types == null) - System.out.println(); - for (Clazz t : types) { - if (!isValidClazz(t)) continue; - r.add(t); - } - return r; - } - - public List filterAttribute(Collection facts) { - List r = new ArrayList<>(); - for (Attribute t : facts) { - if (!isValidAttribute(t)) continue; - r.add(t); - } - return r; - } - - public boolean isValidAttribute(Attribute attribute) { - //here is a list of 'pass' relations that should always be kept as the stoplist can be over-generalising - String rel = attribute.getRelationURI(); - if (rel.startsWith(DBpediaEnum.TYPE_COMMON_TOPIC.getString()) || rel.equals(DBpediaEnum.RELATION_HASTYPE.getString()) - || rel.equals(DBpediaEnum.RELATION_HASNAME.getString())) - return true; - - Set stop = stoplists.get(LABEL_INVALID_ATTRIBUTE); - String relation = attribute.getRelationURI(); - if (stop != null) { - relation = attribute.getRelationURI(); - for (String s : stop) { - if (relation.startsWith(s)) - return false; - } - - } - return !relation.equalsIgnoreCase("id"); - } -} diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaAttribute.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaAttribute.java deleted file mode 100644 index 93bbb8a5..00000000 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaAttribute.java +++ /dev/null @@ -1,23 +0,0 @@ -package uk.ac.shef.dcs.kbsearch.dbpedia; - -import uk.ac.shef.dcs.kbsearch.model.Attribute; - -/** - * Created by Jan on 18.05.2016. - */ -public class DBpediaAttribute extends Attribute { - - public DBpediaAttribute(String relationURI, String value) { - super(relationURI, value); - } - - @Override - public boolean isAlias() { - return getRelationURI().equals(DBpediaEnum.RELATION_HASALIAS.getString()); - } - - @Override - public boolean isDescription() { - return getRelationURI().equals(DBpediaEnum.RELATION_HASDESCRIPTION.getString()); - } -} diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaEnum.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaEnum.java deleted file mode 100644 index 5d0cf3a1..00000000 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaEnum.java +++ /dev/null @@ -1,27 +0,0 @@ -package uk.ac.shef.dcs.kbsearch.dbpedia; - -/** - * Created by Jan on 18.05.2016. - */ -public enum DBpediaEnum { - - RELATION_HASALIAS("http://dbpedia.org/ontology/alias"), - RELATION_HASTYPE("/type/object/type"), - RELATION_RANGEOFPROPERTY("/type/property/expected_type"), - RELATION_HASNAME("/type/object/name"), - RELATION_HASDESCRIPTION("http://dbpedia.org/ontology/description"), - - TYPE_TYPE("/type/type"), - TYPE_PROPERTYOFTYPE("/type/type/properties"), - TYPE_COMMON_TOPIC("/common/topic"); - - private String string; - - DBpediaEnum(String s){ - this.string=s; - } - - public String getString(){ - return string; - } -} diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaSearch.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaSearch.java deleted file mode 100644 index 1b4c0cff..00000000 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/dbpedia/DbpediaSearch.java +++ /dev/null @@ -1,355 +0,0 @@ -package uk.ac.shef.dcs.kbsearch.dbpedia; - -import org.apache.commons.lang3.StringEscapeUtils; -import org.apache.log4j.Logger; -import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; -import uk.ac.shef.dcs.kbsearch.KBSearch; -import uk.ac.shef.dcs.kbsearch.KBSearchException; -import uk.ac.shef.dcs.kbsearch.model.Attribute; -import uk.ac.shef.dcs.kbsearch.model.Clazz; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.util.SolrCache; -import uk.ac.shef.dcs.util.StringUtils; - -import java.io.IOException; -import java.util.*; - -/** - * Created by Jan on 18.05.2016. - */ -public class DBpediaSearch extends KBSearch { - private static final Logger LOG = Logger.getLogger(DBpediaSearch.class.getName()); - private static final boolean AUTO_COMMIT = true; - - private DBpediaQueryProxy searcher; - - public DBpediaSearch(Properties properties, Boolean fuzzyKeywords, - EmbeddedSolrServer cacheEntity, EmbeddedSolrServer cacheConcept, - EmbeddedSolrServer cacheProperty, EmbeddedSolrServer cacheSimilarity) throws IOException { - super(fuzzyKeywords, cacheEntity, cacheConcept, cacheProperty, cacheSimilarity); - - searcher = new DBpediaQueryProxy(); - otherCache = new HashMap<>(); - resultFilter = new DBpediaSearchResultFilter(properties.getProperty(KB_SEARCH_RESULT_STOPLIST)); } - - @Override - public List findEntityCandidates(String content) throws KBSearchException { - return find_matchingEntitiesForTextAndType(content); - } - - @Override - public List findEntityCandidatesOfTypes(String content, String... types) throws KBSearchException { - return find_matchingEntitiesForTextAndType(content, types); - } - - @Override - public List findAttributesOfEntities(Entity ec) throws KBSearchException { - return find_attributes(ec.getId(), cacheEntity); - } - - @Override - public List findAttributesOfProperty(String propertyId) throws KBSearchException { - return find_attributes(propertyId, cacheProperty); - } - - @Override - public List findAttributesOfClazz(String clazzId) throws KBSearchException { - boolean forceQuery = false; - - List attributes = new ArrayList<>(); - String query = createSolrCacheQuery_findAttributesOfResource(clazzId); - if (query.length() == 0) return attributes; - - try { - attributes = (List) cacheConcept.retrieve(query); - if (attributes != null) - LOG.debug("QUERY (attributes of clazz, cache load)=" + query + "|" + query); - } catch (Exception e) { - } - - if (attributes == null || forceQuery) { - try { - attributes = new ArrayList<>(); - List retrievedAttributes = searcher.topicapi_getAttributesOfTopic(clazzId); - //check firstly, is this a concept? - boolean isConcept = false; - for (Attribute f : retrievedAttributes) { - if (f.getRelationURI().equals(DBpediaEnum.RELATION_HASTYPE.getString()) - && f.getValueURI() != null && f.getValueURI().equals(DBpediaEnum.TYPE_TYPE.getString())) { - isConcept = true; - break; - } - } - if (!isConcept) { - try { - cacheConcept.cache(query, attributes, AUTO_COMMIT); - LOG.debug("QUERY (attributes of clazz, cache save)=" + query + "|" + query); - } catch (Exception e) { - e.printStackTrace(); - } - return attributes; - } - - //ok, this is a concept. We need to deep-fetch its properties, and find out the range of their properties - for (Attribute f : retrievedAttributes) { - if (f.getRelationURI().equals(DBpediaEnum.TYPE_PROPERTYOFTYPE.getString())) { //this is a property of a concept, we need to process it further - String propertyId = f.getValueURI(); - if (propertyId == null) continue; - - List attrOfProperty = findAttributesOfProperty(propertyId); - for (Attribute t : attrOfProperty) { - if (t.getRelationURI().equals(DBpediaEnum.RELATION_RANGEOFPROPERTY.getString())) { - String rangeLabel = t.getValue(); - String rangeURL = t.getValueURI(); - Attribute attr = new DBpediaAttribute(f.getValueURI(), rangeLabel); - attr.setValueURI(rangeURL); - attr.setIsDirect(true); - //attributes.add(new String[]{f[2], rangeLabel, rangeURL, "n"}); - } - } - } else { - attributes.add(f); - } - } - - cacheConcept.cache(query, attributes, AUTO_COMMIT); - LOG.debug("QUERY (attributes of clazz, cache save)=" + query + "|" + query); - } catch (Exception e) { - throw new KBSearchException(e); - } - } - - //filtering - attributes=getResultFilter().filterAttribute(attributes); - return attributes; - } - - @Override - public double findGranularityOfClazz(String clazz) throws KBSearchException { - /*if(clazz.equals("/location/citytown")) - System.out.println();*/ - String query = createSolrCacheQuery_findGranularityOfClazz(clazz); - Double result = null; - try { - Object o = cacheConcept.retrieve(query); - if (o != null) { - LOG.debug("QUERY (granularity of clazz, cache load)=" + query + "|" + clazz); - return (Double) o; - } - } catch (Exception e) { - } - - if (result == null) { - try { - double granularity = searcher.find_granularityForType(clazz); - result = granularity; - try { - cacheConcept.cache(query, result, AUTO_COMMIT); - LOG.debug("QUERY (granularity of clazz, cache save)=" + query + "|" + clazz); - } catch (Exception e) { - LOG.error("FAILED:" + clazz); - e.printStackTrace(); - } - } catch (IOException ioe) { - LOG.error("ERROR(Instances of Type): Unable to fetch freebase page of instances of type: " + clazz); - } - } - if (result == null) - return -1.0; - return result; - } - - @Override - public double findEntityClazzSimilarity(String entity_id, String clazz_url) throws KBSearchException { - String query = createSolrCacheQuery_findEntityClazzSimilarity(entity_id, clazz_url); - Object result = null; - try { - result = cacheSimilarity.retrieve(query); - if (result != null) - LOG.debug("QUERY (entity-clazz similarity, cache load)=" + query + "|" + query); - } catch (Exception e) { - } - if (result == null) - return -1.0; - return (Double) result; - } - - @Override - public void cacheEntityClazzSimilarity(String entity_id, String clazz_url, double score, boolean biDirectional, boolean commit) throws KBSearchException { - String query = createSolrCacheQuery_findEntityClazzSimilarity(entity_id, clazz_url); - try { - cacheSimilarity.cache(query, score, commit); - LOG.debug("QUERY (entity-clazz similarity, cache saving)=" + query + "|" + query); - if (biDirectional) { - query = clazz_url + "<>" + entity_id; - cacheSimilarity.cache(query, score, commit); - LOG.debug("QUERY (entity-clazz similarity, cache saving)=" + query + "|" + query); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Override - public void commitChanges() throws KBSearchException { - try { - cacheConcept.commit(); - cacheEntity.commit(); - cacheProperty.commit(); - for (SolrCache cache : otherCache.values()) - cache.commit(); - } catch (Exception e) { - throw new KBSearchException(e); - } - } - - @Override - public void closeConnection() throws KBSearchException { - try { - if (cacheEntity != null) - cacheEntity.shutdown(); - if (cacheConcept != null) - cacheConcept.shutdown(); - if (cacheProperty != null) - cacheProperty.shutdown(); - } catch (Exception e) { - throw new KBSearchException(e); - } - } - - private List find_matchingEntitiesForTextAndType(String text, String... types) throws KBSearchException { - String query = createSolrCacheQuery_findResources(text); - boolean forceQuery = false; - - text = StringEscapeUtils.unescapeXml(text); - int bracket = text.indexOf("("); - if (bracket != -1) { - text = text.substring(0, bracket).trim(); - } - if (StringUtils.toAlphaNumericWhitechar(text).trim().length() == 0) - return new ArrayList<>(); - - - List result = null; - - if (!forceQuery) { - try { - result = (List) cacheEntity.retrieve(query); - if (result != null) - LOG.debug("QUERY (entities, cache load)=" + query + "|" + query); - } catch (Exception e) { - } - } - if (result == null) { - result = new ArrayList<>(); - try { - //firstly fetch candidate freebase topics. pass 'true' to only keep candidates whose name overlap with the query term - List topics = searcher.searchapi_getTopicsByNameAndType(text, "any", true, 20); //search api does not retrieve complete types, find types for them - LOG.debug("(FB QUERY =" +topics.size()+" results)"); - for (Entity ec : topics) { - //Next get attributes for each topic - List attributes = findAttributesOfEntities(ec); - ec.setAttributes(attributes); - for (Attribute attr : attributes) { - if (attr.getRelationURI().equals(DBpediaEnum.RELATION_HASTYPE.getString()) && - attr.isDirect() && - !ec.hasType(attr.getValueURI())) { - ec.addType(new Clazz(attr.getValueURI(), attr.getValue())); - } - } - } - - if (topics.size() == 0 && fuzzyKeywords) { //does the query has conjunection word? if so, we may need to try again with split queries - String[] queries = text.split("\\band\\b"); - if (queries.length < 2) { - queries = text.split("\\bor\\b"); - if (queries.length < 2) { - queries = text.split("/"); - if (queries.length < 2) { - queries = text.split(","); - } - } - } - if (queries.length > 1) { - for (String q : queries) { - q = q.trim(); - if (q.length() < 1) continue; - result.addAll(find_matchingEntitiesForTextAndType(q, types)); - } - } - } - - result.addAll(topics); - cacheEntity.cache(query, result, AUTO_COMMIT); - LOG.debug("QUERY (entities, cache save)=" + query + "|" + query); - } catch (Exception e) { - throw new KBSearchException(e); - } - } - - if (types.length > 0) { - Iterator it = result.iterator(); - while (it.hasNext()) { - Entity ec = it.next(); - boolean typeSatisfied = false; - for (String t : types) { - if (ec.hasType(t)) { - typeSatisfied = true; - break; - } - } - if (!typeSatisfied) - it.remove(); - } - } - - //filter entity's clazz, and attributes - String id = "|"; - for (Entity ec : result) { - id = id + ec.getId() + ","; - //ec.setTypes(FreebaseSearchResultFilter.filterClazz(ec.getTypes())); - List filteredTypes = getResultFilter().filterClazz(ec.getTypes()); - ec.clearTypes(); - for (Clazz ft : filteredTypes) - ec.addType(ft); - } - - return result; - } - - private List find_attributes(String id, SolrCache cache) throws KBSearchException { - if (id.length() == 0) - return new ArrayList<>(); - boolean forceQuery = false; - - String query = createSolrCacheQuery_findAttributesOfResource(id); - List result = null; - - try { - result = (List) cache.retrieve(query); - if (result != null) - LOG.debug("QUERY (attributes of id, cache load)=" + query + "|" + query); - } catch (Exception e) { - } - if (result == null || forceQuery) { - List attributes; - try { - attributes = searcher.topicapi_getAttributesOfTopic(id); - } catch (Exception e) { - throw new KBSearchException(e); - } - result = new ArrayList<>(); - result.addAll(attributes); - try { - cache.cache(query, result, AUTO_COMMIT); - LOG.debug("QUERY (attributes of id, cache save)=" + query + "|" + query); - } catch (Exception e) { - e.printStackTrace(); - } - } - - //filtering - result = getResultFilter().filterAttribute(result); - return result; - } -} From ac4e722427cd368604397a6af790e12a321ab7e4 Mon Sep 17 00:00:00 2001 From: JanVana Date: Thu, 23 Jun 2016 21:19:33 +0200 Subject: [PATCH 024/211] Adding more ignores for IDEA --- .gitignore | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 453d7215..b80ec7d4 100644 --- a/.gitignore +++ b/.gitignore @@ -54,8 +54,6 @@ failed.txt output/* *.log */target -*.iml -*/.idea cache/empty/class/data/* cache/empty/entity/data/* cache/empty/relation/data/* @@ -117,3 +115,11 @@ local.properties # Code Recommenders .recommenders/ + +# ========================= +# IntelliJ IDEA +# ========================= + +*.iml +*/.idea +.Idea/* \ No newline at end of file From 3eda893dd364ed70146724d53f8e4701d2e78335 Mon Sep 17 00:00:00 2001 From: brodecva Date: Sat, 25 Jun 2016 16:09:21 +0200 Subject: [PATCH 025/211] Task, configuration, feedback and result model created. --- odalic/pom.xml | 7 + .../xrg/odalic/api/rest/Configuration.java | 4 + .../rest/adapters/CellAnnotationAdapter.java | 23 ++ .../rest/adapters/CellPositionAdapter.java | 2 +- .../rest/adapters/CellRelationAdapter.java | 2 +- .../CellRelationAnnotationAdapter.java | 23 ++ .../rest/adapters/ClassificationAdapter.java | 2 +- .../rest/adapters/ColumnPositionAdapter.java | 2 +- .../rest/adapters/ColumnRelationAdapter.java | 3 +- .../ColumnRelationAnnotationAdapter.java | 23 ++ .../rest/adapters/ConfigurationAdapter.java | 20 ++ .../rest/adapters/DisambiguationAdapter.java | 2 +- .../api/rest/adapters/EntityAdapter.java | 2 +- .../rest/adapters/EntityCandidateAdapter.java | 24 ++ .../adapters/HeaderAnnotationAdapter.java | 23 ++ .../rest/adapters/KnowledgeBaseAdapter.java | 23 ++ .../api/rest/adapters/LikelihoodAdapter.java | 23 ++ .../api/rest/adapters/RowPositionAdapter.java | 2 +- .../odalic/api/rest/adapters/TaskAdapter.java | 20 ++ .../rest/resources/ConfigurationResource.java | 4 +- .../api/rest/resources/ExecutionResource.java | 17 +- .../api/rest/resources/FeedbackResource.java | 54 +++++ .../api/rest/resources/FileResource.java | 6 +- .../api/rest/resources/ResultResource.java | 28 ++- .../api/rest/resources/StateResource.java | 46 ++++ .../api/rest/resources/TaskResource.java | 2 +- .../api/rest/values/AmbiguityValue.java | 2 +- .../api/rest/values/CellAnnotationValue.java | 91 ++++++++ .../api/rest/values/CellPositionValue.java | 6 +- .../values/CellRelationAnnotationValue.java | 91 ++++++++ .../values/CellRelationPositionValue.java | 75 +++++++ .../api/rest/values/CellRelationValue.java | 85 ++----- .../api/rest/values/ClassificationValue.java | 31 ++- .../api/rest/values/ColumnAmbiguityValue.java | 2 +- .../api/rest/values/ColumnIgnoreValue.java | 2 +- .../api/rest/values/ColumnPositionValue.java | 2 +- .../values/ColumnRelationAnnotationValue.java | 91 ++++++++ .../values/ColumnRelationPositionValue.java | 72 ++++++ .../api/rest/values/ColumnRelationValue.java | 65 ++---- .../api/rest/values/ConfigurationValue.java | 77 +++++++ .../api/rest/values/DisambiguationValue.java | 24 +- .../api/rest/values/EntityCandidateValue.java | 82 +++++++ .../odalic/api/rest/values/EntityValue.java | 2 +- .../odalic/api/rest/values/FeedbackValue.java | 2 +- .../rest/values/HeaderAnnotationValue.java | 91 ++++++++ .../api/rest/values/KnowledgeBaseValue.java | 21 ++ .../api/rest/values/LikelihoodValue.java | 50 +++++ .../api/rest/values/RowPositionValue.java | 2 +- .../xrg/odalic/api/rest/values/TaskValue.java | 111 +++++++++ .../mff/xrg/odalic/feedbacks/Ambiguity.java | 2 +- .../xrg/odalic/feedbacks/CellRelation.java | 106 +++------ .../xrg/odalic/feedbacks/Classification.java | 33 ++- .../xrg/odalic/feedbacks/ColumnAmbiguity.java | 2 +- .../xrg/odalic/feedbacks/ColumnIgnore.java | 2 +- .../xrg/odalic/feedbacks/ColumnRelation.java | 89 +++----- .../xrg/odalic/feedbacks/Disambiguation.java | 35 +-- .../mff/xrg/odalic/feedbacks/Feedback.java | 18 +- .../input/DefaultCsvInputParser.java | 12 + .../input/DefaultInputToTableAdapter.java | 13 ++ .../input/DefaultTableToInputAdapter.java | 13 ++ .../mff/xrg/odalic/feedbacks/input/Input.java | 19 ++ .../odalic/feedbacks/input/InputParser.java | 5 + .../feedbacks/input/InputToTableAdapter.java | 7 + .../odalic/feedbacks/input/SimpleInput.java | 112 +++++++++ .../feedbacks/input/TableToInputAdapter.java | 7 + .../odalic/files/MemoryOnlyFileService.java | 1 - .../types => positions}/CellPosition.java | 2 +- .../positions/CellRelationPosition.java | 92 ++++++++ .../types => positions}/ColumnPosition.java | 2 +- .../positions/ColumnRelationPosition.java | 85 +++++++ .../types => positions}/RowPosition.java | 2 +- .../cz/cuni/mff/xrg/odalic/tasks/Task.java | 108 +++------ .../cuni/mff/xrg/odalic/tasks/TaskDigest.java | 1 + .../tasks/annotations/CellAnnotation.java | 124 ++++++++++ .../annotations/CellRelationAnnotation.java | 123 ++++++++++ .../annotations/ColumnRelationAnnotation.java | 123 ++++++++++ .../types => tasks/annotations}/Entity.java | 11 +- .../tasks/annotations/EntityCandidate.java | 108 +++++++++ .../tasks/annotations/HeaderAnnotation.java | 123 ++++++++++ .../tasks/annotations/KnowledgeBase.java | 8 + .../odalic/tasks/annotations/Likelihood.java | 92 ++++++++ .../tasks/configurations/Configuration.java | 93 +++++++- .../configurations/ConfigurationService.java | 6 +- .../ConfigurationServiceImpl.java | 26 --- .../MemoryOnlyConfigurationService.java | 45 ++++ .../odalic/tasks/executions/Execution.java | 46 ++-- .../tasks/executions/ExecutionService.java | 16 +- .../executions/ExecutionServiceImpl.java | 26 --- .../FutureBasedExecutionService.java | 143 ++++++++++++ .../odalic/tasks/{ => executions}/State.java | 6 +- .../tasks/feedbacks/FeedbackService.java | 15 ++ .../feedbacks/MemoryOnlyFeedbackService.java | 59 +++++ .../results/AnnotationToResultAdapter.java | 7 + .../DefaultAnnotationToResultAdapter.java | 13 ++ .../mff/xrg/odalic/tasks/results/Result.java | 212 +++++++++++++++++- .../odalic/tasks/results/ResultService.java | 7 - .../tasks/results/ResultServiceImpl.java | 10 - .../cz/cuni/mff/xrg/odalic/util/Arrays.java | 61 +++++ .../resources/spring/applicationContext.xml | 12 +- odalic/src/main/webapp/WEB-INF/web.xml | 6 + 100 files changed, 3182 insertions(+), 571 deletions(-) create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellAnnotationAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAnnotationAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAnnotationAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ConfigurationAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityCandidateAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/HeaderAnnotationAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/KnowledgeBaseAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/LikelihoodAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/TaskAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FeedbackResource.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/StateResource.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellAnnotationValue.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationAnnotationValue.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationPositionValue.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationAnnotationValue.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationPositionValue.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityCandidateValue.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/HeaderAnnotationValue.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/KnowledgeBaseValue.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/LikelihoodValue.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/TaskValue.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultCsvInputParser.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultInputToTableAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultTableToInputAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/Input.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputParser.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputToTableAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/SimpleInput.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/TableToInputAdapter.java rename odalic/src/main/java/cz/cuni/mff/xrg/odalic/{feedbacks/types => positions}/CellPosition.java (98%) create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/CellRelationPosition.java rename odalic/src/main/java/cz/cuni/mff/xrg/odalic/{feedbacks/types => positions}/ColumnPosition.java (96%) create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/ColumnRelationPosition.java rename odalic/src/main/java/cz/cuni/mff/xrg/odalic/{feedbacks/types => positions}/RowPosition.java (96%) create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellAnnotation.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellRelationAnnotation.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/ColumnRelationAnnotation.java rename odalic/src/main/java/cz/cuni/mff/xrg/odalic/{feedbacks/types => tasks/annotations}/Entity.java (90%) create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/EntityCandidate.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/HeaderAnnotation.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/KnowledgeBase.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Likelihood.java delete mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationServiceImpl.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/MemoryOnlyConfigurationService.java delete mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionServiceImpl.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java rename odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/{ => executions}/State.java (68%) create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/FeedbackService.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/MemoryOnlyFeedbackService.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/AnnotationToResultAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/DefaultAnnotationToResultAdapter.java delete mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultService.java delete mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultServiceImpl.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/Arrays.java diff --git a/odalic/pom.xml b/odalic/pom.xml index 94988b9d..ee1a5ccd 100644 --- a/odalic/pom.xml +++ b/odalic/pom.xml @@ -103,6 +103,13 @@ spring-tx ${spring.version} + + + + org.ujmp + ujmp-core + 0.3.0 + diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java index 14dd4777..e501f7a6 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java @@ -14,8 +14,10 @@ import cz.cuni.mff.xrg.odalic.api.rest.resources.ConfigurationResource; import cz.cuni.mff.xrg.odalic.api.rest.resources.DraftResource; import cz.cuni.mff.xrg.odalic.api.rest.resources.ExecutionResource; +import cz.cuni.mff.xrg.odalic.api.rest.resources.FeedbackResource; import cz.cuni.mff.xrg.odalic.api.rest.resources.FileResource; import cz.cuni.mff.xrg.odalic.api.rest.resources.ResultResource; +import cz.cuni.mff.xrg.odalic.api.rest.resources.StateResource; import cz.cuni.mff.xrg.odalic.api.rest.resources.TaskResource; public final class Configuration extends ResourceConfig { @@ -25,9 +27,11 @@ public Configuration() { register(FileResource.class); register(TaskResource.class); register(ConfigurationResource.class); + register(FeedbackResource.class); register(DraftResource.class); register(ExecutionResource.class); register(ResultResource.class); + register(StateResource.class); // Filters registration register(RequestContextFilter.class); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellAnnotationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellAnnotationAdapter.java new file mode 100644 index 00000000..34c86cb7 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellAnnotationAdapter.java @@ -0,0 +1,23 @@ +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.CellAnnotationValue; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellAnnotation; + + +public class CellAnnotationAdapter + extends XmlAdapter { + + @Override + public CellAnnotationValue marshal(CellAnnotation bound) + throws Exception { + return new CellAnnotationValue(bound); + } + + @Override + public CellAnnotation unmarshal(CellAnnotationValue value) + throws Exception { + return new CellAnnotation(value.getCandidates(), value.getChosen()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellPositionAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellPositionAdapter.java index a89245ca..8d2549ac 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellPositionAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellPositionAdapter.java @@ -3,7 +3,7 @@ import javax.xml.bind.annotation.adapters.XmlAdapter; import cz.cuni.mff.xrg.odalic.api.rest.values.CellPositionValue; -import cz.cuni.mff.xrg.odalic.feedbacks.types.CellPosition; +import cz.cuni.mff.xrg.odalic.positions.CellPosition; public class CellPositionAdapter diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAdapter.java index 708fd11d..b819992e 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAdapter.java @@ -18,6 +18,6 @@ public CellRelationValue marshal(CellRelation bound) @Override public CellRelation unmarshal(CellRelationValue value) throws Exception { - return new CellRelation(value.getSubjectColumnPosition(), value.getObjectColumnPosition(), value.getRowPosition(), value.getEntity()); + return new CellRelation(value.getPosition(), value.getAnnotation()); } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAnnotationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAnnotationAdapter.java new file mode 100644 index 00000000..fcaf4cfa --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAnnotationAdapter.java @@ -0,0 +1,23 @@ +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.CellRelationAnnotationValue; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; + + +public class CellRelationAnnotationAdapter + extends XmlAdapter { + + @Override + public CellRelationAnnotationValue marshal(CellRelationAnnotation bound) + throws Exception { + return new CellRelationAnnotationValue(bound); + } + + @Override + public CellRelationAnnotation unmarshal(CellRelationAnnotationValue value) + throws Exception { + return new CellRelationAnnotation(value.getCandidates(), value.getChosen()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ClassificationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ClassificationAdapter.java index 41a9ce4e..6d287fd6 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ClassificationAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ClassificationAdapter.java @@ -18,6 +18,6 @@ public ClassificationValue marshal(Classification bound) @Override public Classification unmarshal(ClassificationValue value) throws Exception { - return new Classification(value.getPosition(), value.getEntities()); + return new Classification(value.getPosition(), value.getAnnotation()); } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnPositionAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnPositionAdapter.java index 5d84137c..193e19e2 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnPositionAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnPositionAdapter.java @@ -3,7 +3,7 @@ import javax.xml.bind.annotation.adapters.XmlAdapter; import cz.cuni.mff.xrg.odalic.api.rest.values.ColumnPositionValue; -import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; public class ColumnPositionAdapter diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAdapter.java index 807ce499..3feabfda 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAdapter.java @@ -15,7 +15,6 @@ public ColumnRelationValue marshal(ColumnRelation bound) throws Exception { @Override public ColumnRelation unmarshal(ColumnRelationValue value) throws Exception { - return new ColumnRelation(value.getSubjectColumnPosition(), value.getObjectColumnPosition(), - value.getEntity()); + return new ColumnRelation(value.getPosition(), value.getAnnotation()); } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAnnotationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAnnotationAdapter.java new file mode 100644 index 00000000..a06ff9c0 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAnnotationAdapter.java @@ -0,0 +1,23 @@ +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.ColumnRelationAnnotationValue; +import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; + + +public class ColumnRelationAnnotationAdapter + extends XmlAdapter { + + @Override + public ColumnRelationAnnotationValue marshal(ColumnRelationAnnotation bound) + throws Exception { + return new ColumnRelationAnnotationValue(bound); + } + + @Override + public ColumnRelationAnnotation unmarshal(ColumnRelationAnnotationValue value) + throws Exception { + return new ColumnRelationAnnotation(value.getCandidates(), value.getChosen()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ConfigurationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ConfigurationAdapter.java new file mode 100644 index 00000000..1b8147a5 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ConfigurationAdapter.java @@ -0,0 +1,20 @@ +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.ConfigurationValue; +import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; + + +public class ConfigurationAdapter extends XmlAdapter { + + @Override + public ConfigurationValue marshal(Configuration bound) throws Exception { + return new ConfigurationValue(bound); + } + + @Override + public Configuration unmarshal(ConfigurationValue value) throws Exception { + return new Configuration(value.getInput(), value.getFeedback()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/DisambiguationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/DisambiguationAdapter.java index cb23c69b..62f91cc5 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/DisambiguationAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/DisambiguationAdapter.java @@ -18,6 +18,6 @@ public DisambiguationValue marshal(Disambiguation bound) @Override public Disambiguation unmarshal(DisambiguationValue value) throws Exception { - return new Disambiguation(value.getPosition(), value.getEntity()); + return new Disambiguation(value.getPosition(), value.getAnnotation()); } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityAdapter.java index 72e10944..63bfbe23 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityAdapter.java @@ -3,7 +3,7 @@ import javax.xml.bind.annotation.adapters.XmlAdapter; import cz.cuni.mff.xrg.odalic.api.rest.values.EntityValue; -import cz.cuni.mff.xrg.odalic.feedbacks.types.Entity; +import cz.cuni.mff.xrg.odalic.tasks.annotations.Entity; public class EntityAdapter diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityCandidateAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityCandidateAdapter.java new file mode 100644 index 00000000..98e53bff --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityCandidateAdapter.java @@ -0,0 +1,24 @@ +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.EntityCandidateValue; +import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; + + +public class EntityCandidateAdapter + extends XmlAdapter { + + @Override + public EntityCandidateValue marshal(EntityCandidate bound) + throws Exception { + return new EntityCandidateValue(bound); + } + + @Override + public EntityCandidate unmarshal(EntityCandidateValue value) + throws Exception { + return new EntityCandidate(value.getEntity(), + value.getLikelihood()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/HeaderAnnotationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/HeaderAnnotationAdapter.java new file mode 100644 index 00000000..5bbc1412 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/HeaderAnnotationAdapter.java @@ -0,0 +1,23 @@ +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.HeaderAnnotationValue; +import cz.cuni.mff.xrg.odalic.tasks.annotations.HeaderAnnotation; + + +public class HeaderAnnotationAdapter + extends XmlAdapter { + + @Override + public HeaderAnnotationValue marshal(HeaderAnnotation bound) + throws Exception { + return new HeaderAnnotationValue(bound); + } + + @Override + public HeaderAnnotation unmarshal(HeaderAnnotationValue value) + throws Exception { + return new HeaderAnnotation(value.getCandidates(), value.getChosen()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/KnowledgeBaseAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/KnowledgeBaseAdapter.java new file mode 100644 index 00000000..7ac41530 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/KnowledgeBaseAdapter.java @@ -0,0 +1,23 @@ +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.KnowledgeBaseValue; +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; + + +public class KnowledgeBaseAdapter + extends XmlAdapter { + + @Override + public KnowledgeBaseValue marshal(KnowledgeBase bound) + throws Exception { + return new KnowledgeBaseValue(bound); + } + + @Override + public KnowledgeBase unmarshal(KnowledgeBaseValue value) + throws Exception { + return new KnowledgeBase(); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/LikelihoodAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/LikelihoodAdapter.java new file mode 100644 index 00000000..03f7f095 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/LikelihoodAdapter.java @@ -0,0 +1,23 @@ +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.LikelihoodValue; +import cz.cuni.mff.xrg.odalic.tasks.annotations.Likelihood; + + +public class LikelihoodAdapter + extends XmlAdapter { + + @Override + public LikelihoodValue marshal(Likelihood bound) + throws Exception { + return new LikelihoodValue(bound); + } + + @Override + public Likelihood unmarshal(LikelihoodValue value) + throws Exception { + return new Likelihood(value.getValue()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/RowPositionAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/RowPositionAdapter.java index 81cb4a63..c4604d1d 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/RowPositionAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/RowPositionAdapter.java @@ -3,7 +3,7 @@ import javax.xml.bind.annotation.adapters.XmlAdapter; import cz.cuni.mff.xrg.odalic.api.rest.values.RowPositionValue; -import cz.cuni.mff.xrg.odalic.feedbacks.types.RowPosition; +import cz.cuni.mff.xrg.odalic.positions.RowPosition; public class RowPositionAdapter diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/TaskAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/TaskAdapter.java new file mode 100644 index 00000000..f9a42296 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/TaskAdapter.java @@ -0,0 +1,20 @@ +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.TaskValue; +import cz.cuni.mff.xrg.odalic.tasks.Task; + + +public class TaskAdapter extends XmlAdapter { + + @Override + public TaskValue marshal(Task bound) throws Exception { + return new TaskValue(bound); + } + + @Override + public Task unmarshal(TaskValue value) throws Exception { + return new Task(value.getId(), value.getCreated(), value.getConfiguration()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ConfigurationResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ConfigurationResource.java index a4c7d5b9..1c87b8e2 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ConfigurationResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ConfigurationResource.java @@ -25,14 +25,14 @@ public class ConfigurationResource { @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response putConfigurationForTaskId(@PathParam("id") String id, Configuration configuration) { - configurationService.setConfigurationForTaskId(id, configuration); + configurationService.setForTaskId(id, configuration); return Response.status(Response.Status.OK).entity("Configuration set.").build(); } @GET @Produces(MediaType.APPLICATION_JSON) public Response getConfigurationForTaskId(@PathParam("id") String taskId) { - Configuration configurationForTaskId = configurationService.getConfigurationForTaskId(taskId); + Configuration configurationForTaskId = configurationService.getForTaskId(taskId); return Response.status(Response.Status.OK).entity(configurationForTaskId).build(); } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ExecutionResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ExecutionResource.java index d06ed211..9871b35f 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ExecutionResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ExecutionResource.java @@ -2,7 +2,6 @@ import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; -import javax.ws.rs.GET; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; @@ -26,24 +25,16 @@ public class ExecutionResource { @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response putExecutionForTaskId(@PathParam("id") String id, Execution execution) { - executionService.scheduleExecutionForTaskId(id, execution); - return Response.status(Response.Status.OK).entity("Execution scheduled.").build(); + executionService.submitForTaskId(id); + return Response.status(Response.Status.OK).entity("Execution submitted.").build(); } - @GET - @Produces(MediaType.APPLICATION_JSON) - public Response getExecutionForTaskId(@PathParam("id") String taskId) { - Execution executionForTaskId = executionService.getExecutionForTaskId(taskId); - - return Response.status(Response.Status.OK).entity(executionForTaskId).build(); - } - @DELETE @Produces({MediaType.APPLICATION_JSON}) public Response deleteExecutionForTaskId(@PathParam("id") String id) { - executionService.stopExecutionForTaskId(id); + executionService.cancelForTaskId(id); return Response.status(Response.Status.OK) - .entity("Execution signaled to stop.").build(); + .entity("Execution cancelled.").build(); } @Autowired diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FeedbackResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FeedbackResource.java new file mode 100644 index 00000000..044b4871 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FeedbackResource.java @@ -0,0 +1,54 @@ +package cz.cuni.mff.xrg.odalic.api.rest.resources; + +import java.io.IOException; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; +import cz.cuni.mff.xrg.odalic.feedbacks.input.Input; +import cz.cuni.mff.xrg.odalic.tasks.feedbacks.FeedbackService; + +@Component +@Path("/tasks/{id}/configuration/feedback") +public class FeedbackResource { + + private FeedbackService feedbackService; + + @PUT + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response putFeedbackForTaskId(@PathParam("id") String id, Feedback feedback) { + feedbackService.setForTaskId(id, feedback); + return Response.status(Response.Status.OK).entity("Feedback set.").build(); + } + + @GET + @Produces(MediaType.APPLICATION_JSON) + public Response getFeedbackForTaskId(@PathParam("id") String taskId) { + Feedback feedbackForTaskId = feedbackService.getForTaskId(taskId); + + return Response.status(Response.Status.OK).entity(feedbackForTaskId).build(); + } + + @GET + @Path("/input") + @Produces(MediaType.APPLICATION_JSON) + public Input getJsonDataById(@PathParam("id") String id) throws IOException { + return feedbackService.getInputForTaskId(id); + } + + @Autowired + public FeedbackResource(FeedbackService feedbackService) { + this.feedbackService = feedbackService; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java index 87b3e36a..af76e9d6 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java @@ -39,8 +39,8 @@ public class FileResource { public static final String TEXT_CSV_MEDIA_TYPE = "text/csv"; - private FileService fileService; - + private final FileService fileService; + @Autowired public FileResource(FileService fileService) { Preconditions.checkNotNull(fileService); @@ -127,7 +127,7 @@ public Response deleteFileById(@PathParam("id") String id) { @GET @Path("{id}") @Produces(TEXT_CSV_MEDIA_TYPE) - public Response getDataById(@PathParam("id") String id) throws IOException { + public Response getCsvDataById(@PathParam("id") String id) throws IOException { String data = fileService.getDataById(id); StreamingOutput output = new StreamingOutput() { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ResultResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ResultResource.java index fc020a2a..bae62eb0 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ResultResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ResultResource.java @@ -1,22 +1,38 @@ package cz.cuni.mff.xrg.odalic.api.rest.resources; +import java.util.concurrent.ExecutionException; + +import javax.ws.rs.GET; import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import cz.cuni.mff.xrg.odalic.tasks.results.ResultService; +import cz.cuni.mff.xrg.odalic.tasks.executions.ExecutionService; @Component @Path("/tasks/{id}/result") public class ResultResource { - @SuppressWarnings("unused") - private ResultService resultService; + private final ExecutionService executionService; - //TODO: Methods. + @GET + @Produces(MediaType.APPLICATION_JSON) + public Response getResult(@PathParam("id") String taskId) throws InterruptedException, ExecutionException { + if (!executionService.isDoneForTaskId(taskId) || executionService.isCancelledForTaskId(taskId)) { + return Response.status(Response.Status.NO_CONTENT).entity("The result is not ready.") + .build(); + } + + return Response.ok(executionService.getResultForTaskId(taskId)).build(); + } @Autowired - public ResultResource(ResultService resultService) { - this.resultService = resultService; + public ResultResource(ExecutionService executionService) { + this.executionService = executionService; } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/StateResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/StateResource.java new file mode 100644 index 00000000..98cb709a --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/StateResource.java @@ -0,0 +1,46 @@ +package cz.cuni.mff.xrg.odalic.api.rest.resources; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import cz.cuni.mff.xrg.odalic.tasks.executions.ExecutionService; +import cz.cuni.mff.xrg.odalic.tasks.executions.State; + +@Component +@Path("/tasks/{id}/state") +public class StateResource { + + private ExecutionService executionService; + + @GET + @Produces({MediaType.APPLICATION_JSON}) + public State getStateForTaskId(@PathParam("id") String id) { + final boolean scheduled = executionService.hasBeenScheduledForTaskId(id); + if (!scheduled) { + return State.READY; + } + + final boolean done = executionService.isDoneForTaskId(id); + final boolean cancelled = executionService.isCancelledForTaskId(id); + + if (done) { + if (cancelled) { + return State.CANCELLED; + } else { + return State.FINISHED; + } + } else { + return State.SCHEDULED; + } + } + + @Autowired + public StateResource(ExecutionService executionService) { + this.executionService = executionService; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/TaskResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/TaskResource.java index 29f09ecd..b18d264b 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/TaskResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/TaskResource.java @@ -48,7 +48,7 @@ public Response getTaskById(@PathParam("id") String id) { @Path("/tasks/{id}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public Response putTaskById(@PathParam("id") String id, Task task) { + public Response putTaskWithId(@PathParam("id") String id, Task task) { if (!taskService.hasId(task, id)) { return Response.status(Response.Status.NOT_ACCEPTABLE) .entity("The ID in the payload is not the same as the ID of resource.").build(); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/AmbiguityValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/AmbiguityValue.java index fe40e798..70965904 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/AmbiguityValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/AmbiguityValue.java @@ -9,7 +9,7 @@ import com.google.common.base.Preconditions; import cz.cuni.mff.xrg.odalic.feedbacks.Ambiguity; -import cz.cuni.mff.xrg.odalic.feedbacks.types.CellPosition; +import cz.cuni.mff.xrg.odalic.positions.CellPosition; @XmlRootElement(name = "ambiguity") public final class AmbiguityValue implements Serializable { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellAnnotationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellAnnotationValue.java new file mode 100644 index 00000000..9c33e710 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellAnnotationValue.java @@ -0,0 +1,91 @@ +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.util.Map; +import java.util.NavigableSet; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSortedSet; + +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; + +@XmlRootElement(name = "cellAnnotation") +public final class CellAnnotationValue { + + @XmlElement + private Map> candidates; + + @XmlElement + private Map> chosen; + + public CellAnnotationValue() { + candidates = ImmutableMap.of(); + chosen = ImmutableMap.of(); + } + + /** + * @param entities + */ + public CellAnnotationValue(CellAnnotation adaptee) { + this.candidates = adaptee.getCandidates(); + this.chosen = adaptee.getChosen(); + } + + /** + * @return the candidates + */ + public Map> getCandidates() { + return candidates; + } + + /** + * @param candidates the candidates to set + */ + public void setCandidates(Map> candidates) { + ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); + for (final Map.Entry> candidateEntry : candidates.entrySet()) { + candidatesBuilder.put(candidateEntry.getKey(), ImmutableSortedSet.copyOf(candidateEntry.getValue())); + } + + for (final Map.Entry> chosenEntry : chosen.entrySet()) { + final KnowledgeBase chosenBase = chosenEntry.getKey(); + + final Set baseCandidates = candidates.get(chosenBase); + Preconditions.checkArgument(baseCandidates != null); + Preconditions.checkArgument(baseCandidates.containsAll(chosenEntry.getValue())); + } + + this.candidates = candidatesBuilder.build(); + } + + /** + * @return the chosen + */ + public Map> getChosen() { + return chosen; + } + + /** + * @param chosen the chosen to set + */ + public void setChosen(Map> chosen) { + ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); + for (final Map.Entry> chosenEntry : chosen.entrySet()) { + final KnowledgeBase chosenBase = chosenEntry.getKey(); + + final Set baseCandidates = this.candidates.get(chosenBase); + Preconditions.checkArgument(baseCandidates != null); + Preconditions.checkArgument(baseCandidates.containsAll(chosenEntry.getValue())); + + chosenBuilder.put(chosenEntry.getKey(), ImmutableSet.copyOf(chosenEntry.getValue())); + } + this.chosen = chosenBuilder.build(); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellPositionValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellPositionValue.java index b378f906..22ead54f 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellPositionValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellPositionValue.java @@ -6,9 +6,9 @@ import com.google.common.base.Preconditions; -import cz.cuni.mff.xrg.odalic.feedbacks.types.CellPosition; -import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; -import cz.cuni.mff.xrg.odalic.feedbacks.types.RowPosition; +import cz.cuni.mff.xrg.odalic.positions.CellPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.positions.RowPosition; @XmlRootElement(name = "cellPosition") public class CellPositionValue { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationAnnotationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationAnnotationValue.java new file mode 100644 index 00000000..044eac8a --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationAnnotationValue.java @@ -0,0 +1,91 @@ +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.util.Map; +import java.util.NavigableSet; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSortedSet; + +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; + +@XmlRootElement(name = "cellRelationAnnotation") +public final class CellRelationAnnotationValue { + + @XmlElement + private Map> candidates; + + @XmlElement + private Map> chosen; + + public CellRelationAnnotationValue() { + candidates = ImmutableMap.of(); + chosen = ImmutableMap.of(); + } + + /** + * @param entities + */ + public CellRelationAnnotationValue(CellRelationAnnotation adaptee) { + this.candidates = adaptee.getCandidates(); + this.chosen = adaptee.getChosen(); + } + + /** + * @return the candidates + */ + public Map> getCandidates() { + return candidates; + } + + /** + * @param candidates the candidates to set + */ + public void setCandidates(Map> candidates) { + ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); + for (final Map.Entry> candidateEntry : candidates.entrySet()) { + candidatesBuilder.put(candidateEntry.getKey(), ImmutableSortedSet.copyOf(candidateEntry.getValue())); + } + + for (final Map.Entry> chosenEntry : chosen.entrySet()) { + final KnowledgeBase chosenBase = chosenEntry.getKey(); + + final Set baseCandidates = candidates.get(chosenBase); + Preconditions.checkArgument(baseCandidates != null); + Preconditions.checkArgument(baseCandidates.containsAll(chosenEntry.getValue())); + } + + this.candidates = candidatesBuilder.build(); + } + + /** + * @return the chosen + */ + public Map> getChosen() { + return chosen; + } + + /** + * @param chosen the chosen to set + */ + public void setChosen(Map> chosen) { + ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); + for (final Map.Entry> chosenEntry : chosen.entrySet()) { + final KnowledgeBase chosenBase = chosenEntry.getKey(); + + final Set baseCandidates = this.candidates.get(chosenBase); + Preconditions.checkArgument(baseCandidates != null); + Preconditions.checkArgument(baseCandidates.containsAll(chosenEntry.getValue())); + + chosenBuilder.put(chosenEntry.getKey(), ImmutableSet.copyOf(chosenEntry.getValue())); + } + this.chosen = chosenBuilder.build(); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationPositionValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationPositionValue.java new file mode 100644 index 00000000..07596205 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationPositionValue.java @@ -0,0 +1,75 @@ +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.positions.CellRelationPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; +import cz.cuni.mff.xrg.odalic.positions.RowPosition; + +@XmlRootElement(name = "cellRelationPosition") +public class CellRelationPositionValue implements Serializable { + + private static final long serialVersionUID = 2155060933372152653L; + + @XmlElement + private RowPosition rowPosition; + + @XmlElement + private ColumnRelationPosition columnsPosition; + + public CellRelationPositionValue() {} + + public CellRelationPositionValue(CellRelationPosition adaptee) { + this.rowPosition = adaptee.getRowPosition(); + this.columnsPosition = adaptee.getColumnsPosition(); + } + + /** + * @return the rowPosition + */ + @Nullable + public RowPosition getRowPosition() { + return rowPosition; + } + + /** + * @param rowPosition the rowPosition to set + */ + public void setRowPosition(RowPosition rowPosition) { + Preconditions.checkNotNull(rowPosition); + + this.rowPosition = rowPosition; + } + + /** + * @return the columnsPosition + */ + @Nullable + public ColumnRelationPosition getColumnsPosition() { + return columnsPosition; + } + + /** + * @param columnsPosition the columnsPosition to set + */ + public void setColumnsPosition(ColumnRelationPosition columnsPosition) { + Preconditions.checkNotNull(columnsPosition); + + this.columnsPosition = columnsPosition; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "CellRelationPositionValue [rowPosition=" + rowPosition + ", columnsPosition=" + + columnsPosition + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationValue.java index 92685115..0fdb88a0 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationValue.java @@ -9,9 +9,8 @@ import com.google.common.base.Preconditions; import cz.cuni.mff.xrg.odalic.feedbacks.CellRelation; -import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; -import cz.cuni.mff.xrg.odalic.feedbacks.types.Entity; -import cz.cuni.mff.xrg.odalic.feedbacks.types.RowPosition; +import cz.cuni.mff.xrg.odalic.positions.CellRelationPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; @XmlRootElement(name = "cellRelation") public final class CellRelationValue implements Serializable { @@ -19,90 +18,50 @@ public final class CellRelationValue implements Serializable { private static final long serialVersionUID = -9087389821835847372L; @XmlElement - private ColumnPosition subjectColumnPosition; + private CellRelationPosition position; @XmlElement - private ColumnPosition objectColumnPosition; - - @XmlElement - private RowPosition rowPosition; - - @XmlElement - private Entity entity; + private CellRelationAnnotation annotation; public CellRelationValue() {} public CellRelationValue(CellRelation adaptee) { - this.subjectColumnPosition = adaptee.getSubjectColumnPosition(); - this.objectColumnPosition = adaptee.getObjectColumnPosition(); - this.rowPosition = adaptee.getRowPosition(); - this.entity = adaptee.getEntity(); - } - - /** - * @return the subjectColumnPosition - */ - @Nullable - public ColumnPosition getSubjectColumnPosition() { - return subjectColumnPosition; - } - - /** - * @param subjectColumnPosition the subjectColumnPosition to set - */ - public void setSubjectColumnPosition(@Nullable ColumnPosition subjectColumnPosition) { - this.subjectColumnPosition = subjectColumnPosition; - } - - /** - * @return the objectColumnPosition - */ - @Nullable - public ColumnPosition getObjectColumnPosition() { - return objectColumnPosition; - } - - /** - * @param objectColumnPosition the objectColumnPosition to set - */ - public void setObjectColumnPosition(ColumnPosition objectColumnPosition) { - Preconditions.checkNotNull(objectColumnPosition); - - this.objectColumnPosition = objectColumnPosition; + this.position = adaptee.getPosition(); + this.annotation = adaptee.getAnnotation(); } /** - * @return the rowPosition + * @return the position */ @Nullable - public RowPosition getRowPosition() { - return rowPosition; + public CellRelationPosition getPosition() { + return position; } /** - * @param rowPosition the rowPosition to set + * @param position the position to set */ - public void setRowPosition(RowPosition rowPosition) { - Preconditions.checkNotNull(rowPosition); + public void setPosition(CellRelationPosition position) { + Preconditions.checkNotNull(position); - this.rowPosition = rowPosition; + this.position = position; } /** - * @return the entity + * @return the annotation */ @Nullable - public Entity getEntity() { - return entity; + public CellRelationAnnotation getAnnotation() { + return annotation; } /** - * @param entity the entity to set + * @param annotation the annotation to set */ - public void setEntity(Entity entity) { - Preconditions.checkNotNull(entity); + public void setAnnotation(CellRelationAnnotation annotation) { + Preconditions.checkNotNull(annotation); - this.entity = entity; + this.annotation = annotation; } /* (non-Javadoc) @@ -110,8 +69,6 @@ public void setEntity(Entity entity) { */ @Override public String toString() { - return "CellRelationValue [subjectColumnPosition=" + subjectColumnPosition - + ", objectColumnPosition=" + objectColumnPosition + ", rowPosition=" - + rowPosition + ", entity=" + entity + "]"; + return "CellRelationValue [position=" + position + ", annotation=" + annotation + "]"; } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ClassificationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ClassificationValue.java index ee5c1774..61da2cc4 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ClassificationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ClassificationValue.java @@ -1,18 +1,16 @@ package cz.cuni.mff.xrg.odalic.api.rest.values; import java.io.Serializable; -import java.util.Set; import javax.annotation.Nullable; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableSet; import cz.cuni.mff.xrg.odalic.feedbacks.Classification; -import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; -import cz.cuni.mff.xrg.odalic.feedbacks.types.Entity; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.HeaderAnnotation; @XmlRootElement(name = "classification") public class ClassificationValue implements Serializable { @@ -23,15 +21,13 @@ public class ClassificationValue implements Serializable { private ColumnPosition position; @XmlElement - private Set entities; + private HeaderAnnotation annotation; - public ClassificationValue() { - entities = ImmutableSet.of(); - } + public ClassificationValue() {} public ClassificationValue(Classification adaptee) { this.position = adaptee.getPosition(); - this.entities = adaptee.getEntities(); + this.annotation = adaptee.getAnnotation(); } /** @@ -52,19 +48,20 @@ public void setPosition(ColumnPosition position) { } /** - * @return the entities + * @return the annotation */ - public Set getEntities() { - return entities; + @Nullable + public HeaderAnnotation getAnnotation() { + return annotation; } /** - * @param entities the entities to set + * @param annotation the annotation to set */ - public void setEntities(Set entities) { - Preconditions.checkNotNull(entities); + public void setAnnotation(HeaderAnnotation annotation) { + Preconditions.checkNotNull(annotation); - this.entities = ImmutableSet.copyOf(entities); + this.annotation = annotation; } /* (non-Javadoc) @@ -72,6 +69,6 @@ public void setEntities(Set entities) { */ @Override public String toString() { - return "ClassificationValue [position=" + position + ", entities=" + entities + "]"; + return "ClassificationValue [position=" + position + ", annotation=" + annotation + "]"; } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnAmbiguityValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnAmbiguityValue.java index 3e06f2d4..bd16e713 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnAmbiguityValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnAmbiguityValue.java @@ -9,7 +9,7 @@ import com.google.common.base.Preconditions; import cz.cuni.mff.xrg.odalic.feedbacks.ColumnAmbiguity; -import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; @XmlRootElement(name = "columnAmbiguity") public final class ColumnAmbiguityValue implements Serializable { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnIgnoreValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnIgnoreValue.java index e5505a5c..6b01b38e 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnIgnoreValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnIgnoreValue.java @@ -9,7 +9,7 @@ import com.google.common.base.Preconditions; import cz.cuni.mff.xrg.odalic.feedbacks.ColumnIgnore; -import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; @XmlRootElement(name = "columnIgnore") public final class ColumnIgnoreValue implements Serializable { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnPositionValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnPositionValue.java index 910413f3..da6b089b 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnPositionValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnPositionValue.java @@ -5,7 +5,7 @@ import com.google.common.base.Preconditions; -import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; @XmlRootElement(name = "columnPosition") public class ColumnPositionValue { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationAnnotationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationAnnotationValue.java new file mode 100644 index 00000000..249cf1df --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationAnnotationValue.java @@ -0,0 +1,91 @@ +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.util.Map; +import java.util.NavigableSet; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSortedSet; + +import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; + +@XmlRootElement(name = "columnRelationAnnotation") +public final class ColumnRelationAnnotationValue { + + @XmlElement + private Map> candidates; + + @XmlElement + private Map> chosen; + + public ColumnRelationAnnotationValue() { + candidates = ImmutableMap.of(); + chosen = ImmutableMap.of(); + } + + /** + * @param entities + */ + public ColumnRelationAnnotationValue(ColumnRelationAnnotation adaptee) { + this.candidates = adaptee.getCandidates(); + this.chosen = adaptee.getChosen(); + } + + /** + * @return the candidates + */ + public Map> getCandidates() { + return candidates; + } + + /** + * @param candidates the candidates to set + */ + public void setCandidates(Map> candidates) { + ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); + for (final Map.Entry> candidateEntry : candidates.entrySet()) { + candidatesBuilder.put(candidateEntry.getKey(), ImmutableSortedSet.copyOf(candidateEntry.getValue())); + } + + for (final Map.Entry> chosenEntry : chosen.entrySet()) { + final KnowledgeBase chosenBase = chosenEntry.getKey(); + + final Set baseCandidates = candidates.get(chosenBase); + Preconditions.checkArgument(baseCandidates != null); + Preconditions.checkArgument(baseCandidates.containsAll(chosenEntry.getValue())); + } + + this.candidates = candidatesBuilder.build(); + } + + /** + * @return the chosen + */ + public Map> getChosen() { + return chosen; + } + + /** + * @param chosen the chosen to set + */ + public void setChosen(Map> chosen) { + ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); + for (final Map.Entry> chosenEntry : chosen.entrySet()) { + final KnowledgeBase chosenBase = chosenEntry.getKey(); + + final Set baseCandidates = this.candidates.get(chosenBase); + Preconditions.checkArgument(baseCandidates != null); + Preconditions.checkArgument(baseCandidates.containsAll(chosenEntry.getValue())); + + chosenBuilder.put(chosenEntry.getKey(), ImmutableSet.copyOf(chosenEntry.getValue())); + } + this.chosen = chosenBuilder.build(); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationPositionValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationPositionValue.java new file mode 100644 index 00000000..916300ce --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationPositionValue.java @@ -0,0 +1,72 @@ +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; + +@XmlRootElement(name = "cellPosition") +public class ColumnRelationPositionValue { + + @XmlElement + private ColumnPosition first; + + @XmlElement + private ColumnPosition second; + + public ColumnRelationPositionValue() {} + + /** + * @param adaptee + */ + public ColumnRelationPositionValue(ColumnRelationPosition adaptee) { + this.first = adaptee.getFirst(); + this.second = adaptee.getSecond(); + } + + /** + * @return the first + */ + @Nullable + public ColumnPosition getFirst() { + return first; + } + + /** + * @param first the first to set + */ + public void setFirst(ColumnPosition first) { + Preconditions.checkNotNull(first); + + this.first = first; + } + + /** + * @return the second + */ + @Nullable + public ColumnPosition getSecond() { + return second; + } + + /** + * @param second the second to set + */ + public void setSecond(ColumnPosition second) { + Preconditions.checkNotNull(second); + + this.second = second; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ColumnRelationPositionValue [first=" + first + ", second=" + second + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationValue.java index 0b354bcd..f3c1e852 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationValue.java @@ -9,8 +9,8 @@ import com.google.common.base.Preconditions; import cz.cuni.mff.xrg.odalic.feedbacks.ColumnRelation; -import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; -import cz.cuni.mff.xrg.odalic.feedbacks.types.Entity; +import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; @XmlRootElement(name = "columnRelation") public final class ColumnRelationValue implements Serializable { @@ -18,71 +18,50 @@ public final class ColumnRelationValue implements Serializable { private static final long serialVersionUID = -9087389821835847372L; @XmlElement - private ColumnPosition subjectColumnPosition; + private ColumnRelationPosition position; @XmlElement - private ColumnPosition objectColumnPosition; - - @XmlElement - private Entity entity; + private ColumnRelationAnnotation annotation; public ColumnRelationValue() {} public ColumnRelationValue(ColumnRelation adaptee) { - this.subjectColumnPosition = adaptee.getSubjectColumnPosition(); - this.objectColumnPosition = adaptee.getObjectColumnPosition(); - this.entity = adaptee.getEntity(); - } - - /** - * @return the subjectColumnPosition - */ - @Nullable - public ColumnPosition getSubjectColumnPosition() { - return subjectColumnPosition; - } - - /** - * @param subjectColumnPosition the subjectColumnPosition to set - */ - public void setSubjectColumnPosition(ColumnPosition subjectColumnPosition) { - Preconditions.checkNotNull(subjectColumnPosition); - - this.subjectColumnPosition = subjectColumnPosition; + this.position = adaptee.getPosition(); + this.annotation = adaptee.getAnnotation(); } /** - * @return the objectColumnPosition + * @return the position */ @Nullable - public ColumnPosition getObjectColumnPosition() { - return objectColumnPosition; + public ColumnRelationPosition getPosition() { + return position; } /** - * @param objectColumnPosition the objectColumnPosition to set + * @param position the position to set */ - public void setObjectColumnPosition(ColumnPosition objectColumnPosition) { - Preconditions.checkNotNull(objectColumnPosition); + public void setPosition(ColumnRelationPosition position) { + Preconditions.checkNotNull(position); - this.objectColumnPosition = objectColumnPosition; + this.position = position; } /** - * @return the entity + * @return the annotation */ @Nullable - public Entity getEntity() { - return entity; + public ColumnRelationAnnotation getAnnotation() { + return annotation; } /** - * @param entity the entity to set + * @param annotation the annotation to set */ - public void setEntity(Entity entity) { - Preconditions.checkNotNull(entity); + public void setAnnotation(ColumnRelationAnnotation annotation) { + Preconditions.checkNotNull(annotation); - this.entity = entity; + this.annotation = annotation; } /* (non-Javadoc) @@ -90,8 +69,6 @@ public void setEntity(Entity entity) { */ @Override public String toString() { - return "CellRelationValue [subjectColumnPosition=" + subjectColumnPosition - + ", objectColumnPosition=" + objectColumnPosition + ", rowPosition=" - + ", entity=" + entity + "]"; + return "ColumnRelationValue [position=" + position + ", annotation=" + annotation + "]"; } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java new file mode 100644 index 00000000..ff57d5f8 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java @@ -0,0 +1,77 @@ +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; +import cz.cuni.mff.xrg.odalic.files.File; +import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; + +@XmlRootElement(name = "configuration") +public class ConfigurationValue implements Serializable { + + private static final long serialVersionUID = -6359038623760039155L; + + @XmlElement(name = "input") + private File input; + + @XmlElement(name = "feedback") + private Feedback feedback; + + public ConfigurationValue() { + input = null; + feedback = null; + } + + public ConfigurationValue(Configuration adaptee) { + input = adaptee.getInput(); + feedback = adaptee.getFeedback(); + } + + /** + * @return the input + */ + @Nullable + public File getInput() { + return input; + } + + /** + * @param input the input to set + */ + public void setInput(File input) { + Preconditions.checkNotNull(input); + + this.input = input; + } + + /** + * @return the feedback + */ + @Nullable + public Feedback getFeedback() { + return feedback; + } + + /** + * @param feedback the feedback to set + */ + public void setFeedback(Feedback feedback) { + Preconditions.checkNotNull(feedback); + + this.feedback = feedback; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ConfigurationValue [input=" + input + ", feedback=" + feedback + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/DisambiguationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/DisambiguationValue.java index c28ec25c..73be2b65 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/DisambiguationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/DisambiguationValue.java @@ -9,8 +9,8 @@ import com.google.common.base.Preconditions; import cz.cuni.mff.xrg.odalic.feedbacks.Disambiguation; -import cz.cuni.mff.xrg.odalic.feedbacks.types.CellPosition; -import cz.cuni.mff.xrg.odalic.feedbacks.types.Entity; +import cz.cuni.mff.xrg.odalic.positions.CellPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellAnnotation; @XmlRootElement(name = "disambiguation") public final class DisambiguationValue implements Serializable { @@ -21,13 +21,13 @@ public final class DisambiguationValue implements Serializable { private CellPosition position; @XmlElement - private Entity entity; + private CellAnnotation annotation; public DisambiguationValue() {} public DisambiguationValue(Disambiguation adaptee) { this.position = adaptee.getPosition(); - this.entity = adaptee.getEntity(); + this.annotation = adaptee.getAnnotation(); } /** @@ -48,20 +48,20 @@ public void setPosition(CellPosition position) { } /** - * @return the entity + * @return the annotation */ @Nullable - public Entity getEntity() { - return entity; + public CellAnnotation getAnnotation() { + return annotation; } /** - * @param entity the entity to set + * @param annotation the annotation to set */ - public void setEntity(Entity entity) { - Preconditions.checkNotNull(entity); + public void setAnnotation(CellAnnotation annotation) { + Preconditions.checkNotNull(annotation); - this.entity = entity; + this.annotation = annotation; } /* (non-Javadoc) @@ -69,6 +69,6 @@ public void setEntity(Entity entity) { */ @Override public String toString() { - return "DisambiguationValue [position=" + position + ", entity=" + entity + "]"; + return "DisambiguationValue [position=" + position + ", annotation=" + annotation + "]"; } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityCandidateValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityCandidateValue.java new file mode 100644 index 00000000..208acabe --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityCandidateValue.java @@ -0,0 +1,82 @@ +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.tasks.annotations.Entity; +import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; +import cz.cuni.mff.xrg.odalic.tasks.annotations.Likelihood; + +public final class EntityCandidateValue implements Serializable { + + private static final long serialVersionUID = 3072774254576336747L; + + @XmlElement + private Entity entity; + + @XmlElement + private Likelihood likelihood; + + /** + * @param entity + * @param likelihood + */ + public EntityCandidateValue() { + entity = null; + likelihood = null; + } + + /** + * @param adaptee + */ + public EntityCandidateValue(EntityCandidate adaptee) { + entity = adaptee.getEntity(); + likelihood = adaptee.getLikelihood(); + } + + /** + * @return the entity + */ + @Nullable + public Entity getEntity() { + return entity; + } + + /** + * @param entity the entity to set + */ + public void setEntity(Entity entity) { + Preconditions.checkNotNull(entity); + + this.entity = entity; + } + + /** + * @return the likelihood + */ + @Nullable + public Likelihood getLikelihood() { + return likelihood; + } + + /** + * @param likelihood the likelihood to set + */ + public void setLikelihood(Likelihood likelihood) { + Preconditions.checkNotNull(likelihood); + + this.likelihood = likelihood; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "EntityCandidateValue [entity=" + entity + ", likelihood=" + likelihood + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityValue.java index 4f2bc25a..67e0bfa1 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityValue.java @@ -9,7 +9,7 @@ import com.google.common.base.Preconditions; -import cz.cuni.mff.xrg.odalic.feedbacks.types.Entity; +import cz.cuni.mff.xrg.odalic.tasks.annotations.Entity; @XmlRootElement(name = "entity") public class EntityValue implements Serializable { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/FeedbackValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/FeedbackValue.java index b0882cae..ca86c561 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/FeedbackValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/FeedbackValue.java @@ -17,7 +17,7 @@ import cz.cuni.mff.xrg.odalic.feedbacks.ColumnRelation; import cz.cuni.mff.xrg.odalic.feedbacks.Disambiguation; import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; -import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; @XmlRootElement(name = "feedback") public class FeedbackValue implements Serializable { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/HeaderAnnotationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/HeaderAnnotationValue.java new file mode 100644 index 00000000..d5fd803f --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/HeaderAnnotationValue.java @@ -0,0 +1,91 @@ +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.util.Map; +import java.util.NavigableSet; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSortedSet; + +import cz.cuni.mff.xrg.odalic.tasks.annotations.HeaderAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; + +@XmlRootElement(name = "headerAnnotation") +public final class HeaderAnnotationValue { + + @XmlElement + private Map> candidates; + + @XmlElement + private Map> chosen; + + public HeaderAnnotationValue() { + candidates = ImmutableMap.of(); + chosen = ImmutableMap.of(); + } + + /** + * @param entities + */ + public HeaderAnnotationValue(HeaderAnnotation adaptee) { + this.candidates = adaptee.getCandidates(); + this.chosen = adaptee.getChosen(); + } + + /** + * @return the candidates + */ + public Map> getCandidates() { + return candidates; + } + + /** + * @param candidates the candidates to set + */ + public void setCandidates(Map> candidates) { + ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); + for (final Map.Entry> candidateEntry : candidates.entrySet()) { + candidatesBuilder.put(candidateEntry.getKey(), ImmutableSortedSet.copyOf(candidateEntry.getValue())); + } + + for (final Map.Entry> chosenEntry : chosen.entrySet()) { + final KnowledgeBase chosenBase = chosenEntry.getKey(); + + final Set baseCandidates = candidates.get(chosenBase); + Preconditions.checkArgument(baseCandidates != null); + Preconditions.checkArgument(baseCandidates.containsAll(chosenEntry.getValue())); + } + + this.candidates = candidatesBuilder.build(); + } + + /** + * @return the chosen + */ + public Map> getChosen() { + return chosen; + } + + /** + * @param chosen the chosen to set + */ + public void setChosen(Map> chosen) { + ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); + for (final Map.Entry> chosenEntry : chosen.entrySet()) { + final KnowledgeBase chosenBase = chosenEntry.getKey(); + + final Set baseCandidates = this.candidates.get(chosenBase); + Preconditions.checkArgument(baseCandidates != null); + Preconditions.checkArgument(baseCandidates.containsAll(chosenEntry.getValue())); + + chosenBuilder.put(chosenEntry.getKey(), ImmutableSet.copyOf(chosenEntry.getValue())); + } + this.chosen = chosenBuilder.build(); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/KnowledgeBaseValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/KnowledgeBaseValue.java new file mode 100644 index 00000000..1da6b415 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/KnowledgeBaseValue.java @@ -0,0 +1,21 @@ +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import javax.xml.bind.annotation.XmlRootElement; + +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; + +@XmlRootElement(name = "knowledgeBase") +public class KnowledgeBaseValue { + + public KnowledgeBaseValue() {} + + public KnowledgeBaseValue(KnowledgeBase adaptee) {} + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "KnowledgeBaseValue"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/LikelihoodValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/LikelihoodValue.java new file mode 100644 index 00000000..9f874206 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/LikelihoodValue.java @@ -0,0 +1,50 @@ +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.tasks.annotations.Likelihood; + +@XmlRootElement(name = "likelihood") +public final class LikelihoodValue implements Serializable { + + private static final long serialVersionUID = -901650058091668104L; + + @XmlElement + private double value; + + public LikelihoodValue() {} + + public LikelihoodValue(Likelihood adaptee) { + value = adaptee.getValue(); + } + + /** + * @return the value + */ + public double getValue() { + return value; + } + + /** + * @param value the value to set + */ + public void setValue(double value) { + Preconditions.checkArgument(value >= 0); + Preconditions.checkArgument(value <= 1); + + this.value = value; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "LikelihoodValue [value=" + value + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/RowPositionValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/RowPositionValue.java index 91d5e189..5e8d6c43 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/RowPositionValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/RowPositionValue.java @@ -3,7 +3,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import cz.cuni.mff.xrg.odalic.feedbacks.types.RowPosition; +import cz.cuni.mff.xrg.odalic.positions.RowPosition; @XmlRootElement(name = "rowPosition") public class RowPositionValue { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/TaskValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/TaskValue.java new file mode 100644 index 00000000..9dcf4c51 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/TaskValue.java @@ -0,0 +1,111 @@ +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; +import java.util.Date; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.codehaus.jackson.map.annotate.JsonDeserialize; +import org.codehaus.jackson.map.annotate.JsonSerialize; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateDeserializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateSerializer; +import cz.cuni.mff.xrg.odalic.tasks.Task; +import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; + +@XmlRootElement(name = "task") +public final class TaskValue implements Serializable { + + private static final long serialVersionUID = 1610346823333685091L; + + @XmlElement + private String id; + + @JsonSerialize(using = CustomJsonDateSerializer.class) + @JsonDeserialize(using = CustomJsonDateDeserializer.class) + @XmlElement + private Date created; + + @XmlElement + private Configuration configuration; + + public TaskValue() { + id = null; + created = null; + configuration = null; + } + + /** + * @param id + * @param created + */ + public TaskValue(Task adaptee) { + id = adaptee.getId(); + created = adaptee.getCreated(); + configuration = adaptee.getConfiguration(); + } + + /** + * @return the id + */ + @Nullable + public String getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(String id) { + Preconditions.checkNotNull(id); + + this.id = id; + } + + /** + * @return the created + */ + @Nullable + public Date getCreated() { + return created; + } + + /** + * @param created the created to set + */ + public void setCreated(Date created) { + Preconditions.checkNotNull(created); + + this.created = created; + } + + /** + * @return the configuration + */ + @Nullable + public Configuration getConfiguration() { + return configuration; + } + + /** + * @param configuration the configuration to set + */ + public void setConfiguration(Configuration configuration) { + Preconditions.checkNotNull(configuration); + + this.configuration = configuration; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "TaskValue [id=" + id + ", created=" + created + ", configuration=" + configuration + + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Ambiguity.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Ambiguity.java index b6a9971f..9327fd24 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Ambiguity.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Ambiguity.java @@ -6,7 +6,7 @@ import javax.xml.bind.annotation.XmlRootElement; import com.google.common.base.Preconditions; -import cz.cuni.mff.xrg.odalic.feedbacks.types.CellPosition; +import cz.cuni.mff.xrg.odalic.positions.CellPosition; @XmlRootElement(name = "ambiguity") public final class Ambiguity implements Serializable { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/CellRelation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/CellRelation.java index f2613c3b..ca491845 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/CellRelation.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/CellRelation.java @@ -6,9 +6,8 @@ import javax.xml.bind.annotation.XmlRootElement; import com.google.common.base.Preconditions; -import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; -import cz.cuni.mff.xrg.odalic.feedbacks.types.Entity; -import cz.cuni.mff.xrg.odalic.feedbacks.types.RowPosition; +import cz.cuni.mff.xrg.odalic.positions.CellRelationPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; @XmlRootElement(name = "cellRelation") public final class CellRelation implements Serializable { @@ -16,70 +15,41 @@ public final class CellRelation implements Serializable { private static final long serialVersionUID = -9087389821835847372L; @XmlElement - private final ColumnPosition subjectColumnPosition; + private final CellRelationPosition position; @XmlElement - private final ColumnPosition objectColumnPosition; - - @XmlElement - private final RowPosition rowPosition; - - @XmlElement - private final Entity entity; + private final CellRelationAnnotation annotation; @SuppressWarnings("unused") private CellRelation() { - subjectColumnPosition = null; - objectColumnPosition = null; - rowPosition = null; - entity = null; + position = null; + annotation = null; } /** - * @param subjectColumnPosition - * @param objectColumnPosition - * @param rowPosition - * @param entity + * @param position + * @param annotation */ - public CellRelation(ColumnPosition subjectColumnPosition, ColumnPosition objectColumnPosition, - RowPosition rowPosition, Entity entity) { - Preconditions.checkNotNull(subjectColumnPosition); - Preconditions.checkNotNull(objectColumnPosition); - Preconditions.checkNotNull(rowPosition); - Preconditions.checkNotNull(entity); + public CellRelation(CellRelationPosition position, CellRelationAnnotation annotation) { + Preconditions.checkNotNull(position); + Preconditions.checkNotNull(annotation); - this.subjectColumnPosition = subjectColumnPosition; - this.objectColumnPosition = objectColumnPosition; - this.rowPosition = rowPosition; - this.entity = entity; - } - - /** - * @return the subjectColumnPosition - */ - public ColumnPosition getSubjectColumnPosition() { - return subjectColumnPosition; - } - - /** - * @return the objectColumnPosition - */ - public ColumnPosition getObjectColumnPosition() { - return objectColumnPosition; + this.position = position; + this.annotation = annotation; } /** - * @return the rowPosition + * @return the position */ - public RowPosition getRowPosition() { - return rowPosition; + public CellRelationPosition getPosition() { + return position; } /** - * @return the entity + * @return the annotation */ - public Entity getEntity() { - return entity; + public CellRelationAnnotation getAnnotation() { + return annotation; } /* (non-Javadoc) @@ -89,12 +59,8 @@ public Entity getEntity() { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((entity == null) ? 0 : entity.hashCode()); - result = - prime * result + ((objectColumnPosition == null) ? 0 : objectColumnPosition.hashCode()); - result = prime * result + ((rowPosition == null) ? 0 : rowPosition.hashCode()); - result = - prime * result + ((subjectColumnPosition == null) ? 0 : subjectColumnPosition.hashCode()); + result = prime * result + ((annotation == null) ? 0 : annotation.hashCode()); + result = prime * result + ((position == null) ? 0 : position.hashCode()); return result; } @@ -113,32 +79,18 @@ public boolean equals(Object obj) { return false; } CellRelation other = (CellRelation) obj; - if (entity == null) { - if (other.entity != null) { - return false; - } - } else if (!entity.equals(other.entity)) { - return false; - } - if (objectColumnPosition == null) { - if (other.objectColumnPosition != null) { - return false; - } - } else if (!objectColumnPosition.equals(other.objectColumnPosition)) { - return false; - } - if (rowPosition == null) { - if (other.rowPosition != null) { + if (annotation == null) { + if (other.annotation != null) { return false; } - } else if (!rowPosition.equals(other.rowPosition)) { + } else if (!annotation.equals(other.annotation)) { return false; } - if (subjectColumnPosition == null) { - if (other.subjectColumnPosition != null) { + if (position == null) { + if (other.position != null) { return false; } - } else if (!subjectColumnPosition.equals(other.subjectColumnPosition)) { + } else if (!position.equals(other.position)) { return false; } return true; @@ -149,8 +101,6 @@ public boolean equals(Object obj) { */ @Override public String toString() { - return "CellRelation [subjectColumnPosition=" + subjectColumnPosition - + ", objectColumnPosition=" + objectColumnPosition + ", rowPosition=" + rowPosition - + ", entity=" + entity + "]"; + return "CellRelation [position=" + position + ", annotation=" + annotation + "]"; } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Classification.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Classification.java index 3c95219e..8091e23d 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Classification.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Classification.java @@ -1,15 +1,12 @@ package cz.cuni.mff.xrg.odalic.feedbacks; import java.io.Serializable; -import java.util.Set; - import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableSet; -import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; -import cz.cuni.mff.xrg.odalic.feedbacks.types.Entity; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.HeaderAnnotation; @XmlRootElement(name = "classification") public final class Classification implements Serializable { @@ -20,20 +17,20 @@ public final class Classification implements Serializable { private final ColumnPosition position; @XmlElement - private final Set entities; + private final HeaderAnnotation annotation; @SuppressWarnings("unused") private Classification() { position = null; - entities = ImmutableSet.of(); + annotation = null; } - public Classification(ColumnPosition position, Set entity) { + public Classification(ColumnPosition position, HeaderAnnotation annotation) { Preconditions.checkNotNull(position); - Preconditions.checkNotNull(entity); + Preconditions.checkNotNull(annotation); this.position = position; - this.entities = ImmutableSet.copyOf(entity); + this.annotation = annotation; } /** @@ -44,10 +41,10 @@ public ColumnPosition getPosition() { } /** - * @return the entity + * @return the annotation */ - public Set getEntities() { - return ImmutableSet.copyOf(entities); + public HeaderAnnotation getAnnotation() { + return annotation; } /* (non-Javadoc) @@ -57,7 +54,7 @@ public Set getEntities() { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((entities == null) ? 0 : entities.hashCode()); + result = prime * result + ((annotation == null) ? 0 : annotation.hashCode()); result = prime * result + ((position == null) ? 0 : position.hashCode()); return result; } @@ -77,11 +74,11 @@ public boolean equals(Object obj) { return false; } Classification other = (Classification) obj; - if (entities == null) { - if (other.entities != null) { + if (annotation == null) { + if (other.annotation != null) { return false; } - } else if (!entities.equals(other.entities)) { + } else if (!annotation.equals(other.annotation)) { return false; } if (position == null) { @@ -99,6 +96,6 @@ public boolean equals(Object obj) { */ @Override public String toString() { - return "Classification [position=" + position + ", entities=" + entities + "]"; + return "Classification [position=" + position + ", annotation=" + annotation + "]"; } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnAmbiguity.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnAmbiguity.java index 353e7cd5..fdc62094 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnAmbiguity.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnAmbiguity.java @@ -6,7 +6,7 @@ import javax.xml.bind.annotation.XmlRootElement; import com.google.common.base.Preconditions; -import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; @XmlRootElement(name = "columnAmbiguity") public final class ColumnAmbiguity implements Serializable { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnIgnore.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnIgnore.java index 536a0b90..fd0ea7c7 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnIgnore.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnIgnore.java @@ -6,7 +6,7 @@ import javax.xml.bind.annotation.XmlRootElement; import com.google.common.base.Preconditions; -import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; @XmlRootElement(name = "columnIgnore") public final class ColumnIgnore implements Serializable { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnRelation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnRelation.java index 8703a3a7..d5286f70 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnRelation.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnRelation.java @@ -6,8 +6,8 @@ import javax.xml.bind.annotation.XmlRootElement; import com.google.common.base.Preconditions; -import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; -import cz.cuni.mff.xrg.odalic.feedbacks.types.Entity; +import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; @XmlRootElement(name = "columnRelation") public final class ColumnRelation implements Serializable { @@ -15,19 +15,15 @@ public final class ColumnRelation implements Serializable { private static final long serialVersionUID = -9087389821835847372L; @XmlElement - private final ColumnPosition subjectColumnPosition; + private final ColumnRelationPosition position; @XmlElement - private final ColumnPosition objectColumnPosition; - - @XmlElement - private final Entity entity; + private final ColumnRelationAnnotation annotation; @SuppressWarnings("unused") private ColumnRelation() { - subjectColumnPosition = null; - objectColumnPosition = null; - entity = null; + position = null; + annotation = null; } /** @@ -35,58 +31,41 @@ private ColumnRelation() { * @param objectColumnPosition * @param entity */ - public ColumnRelation(ColumnPosition subjectColumnPosition, ColumnPosition objectColumnPosition, - Entity entity) { - Preconditions.checkNotNull(subjectColumnPosition); - Preconditions.checkNotNull(objectColumnPosition); - Preconditions.checkNotNull(entity); + public ColumnRelation(ColumnRelationPosition position, ColumnRelationAnnotation annotation) { + Preconditions.checkNotNull(position); + Preconditions.checkNotNull(annotation); - this.subjectColumnPosition = subjectColumnPosition; - this.objectColumnPosition = objectColumnPosition; - this.entity = entity; - } - - /** - * @return the subjectColumnPosition - */ - public ColumnPosition getSubjectColumnPosition() { - return subjectColumnPosition; + this.position = position; + this.annotation = annotation; } /** - * @return the objectColumnPosition + * @return the position */ - public ColumnPosition getObjectColumnPosition() { - return objectColumnPosition; + public ColumnRelationPosition getPosition() { + return position; } /** - * @return the entity + * @return the annotation */ - public Entity getEntity() { - return entity; + public ColumnRelationAnnotation getAnnotation() { + return annotation; } - /* - * (non-Javadoc) - * + /* (non-Javadoc) * @see java.lang.Object#hashCode() */ @Override public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((entity == null) ? 0 : entity.hashCode()); - result = - prime * result + ((objectColumnPosition == null) ? 0 : objectColumnPosition.hashCode()); - result = - prime * result + ((subjectColumnPosition == null) ? 0 : subjectColumnPosition.hashCode()); + result = prime * result + ((annotation == null) ? 0 : annotation.hashCode()); + result = prime * result + ((position == null) ? 0 : position.hashCode()); return result; } - /* - * (non-Javadoc) - * + /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ @Override @@ -101,38 +80,28 @@ public boolean equals(Object obj) { return false; } ColumnRelation other = (ColumnRelation) obj; - if (entity == null) { - if (other.entity != null) { - return false; - } - } else if (!entity.equals(other.entity)) { - return false; - } - if (objectColumnPosition == null) { - if (other.objectColumnPosition != null) { + if (annotation == null) { + if (other.annotation != null) { return false; } - } else if (!objectColumnPosition.equals(other.objectColumnPosition)) { + } else if (!annotation.equals(other.annotation)) { return false; } - if (subjectColumnPosition == null) { - if (other.subjectColumnPosition != null) { + if (position == null) { + if (other.position != null) { return false; } - } else if (!subjectColumnPosition.equals(other.subjectColumnPosition)) { + } else if (!position.equals(other.position)) { return false; } return true; } - /* - * (non-Javadoc) - * + /* (non-Javadoc) * @see java.lang.Object#toString() */ @Override public String toString() { - return "CellRelation [subjectColumnPosition=" + subjectColumnPosition - + ", objectColumnPosition=" + objectColumnPosition + ", entity=" + entity + "]"; + return "ColumnRelation [position=" + position + ", annotation=" + annotation + "]"; } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Disambiguation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Disambiguation.java index c038584c..fc4da1fd 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Disambiguation.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Disambiguation.java @@ -6,8 +6,8 @@ import javax.xml.bind.annotation.XmlRootElement; import com.google.common.base.Preconditions; -import cz.cuni.mff.xrg.odalic.feedbacks.types.CellPosition; -import cz.cuni.mff.xrg.odalic.feedbacks.types.Entity; +import cz.cuni.mff.xrg.odalic.positions.CellPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellAnnotation; @XmlRootElement(name = "disambiguation") public final class Disambiguation implements Serializable { @@ -18,23 +18,24 @@ public final class Disambiguation implements Serializable { private final CellPosition position; @XmlElement - private final Entity entity; + private final CellAnnotation annotation; - public Disambiguation() { + @SuppressWarnings("unused") + private Disambiguation() { position = null; - entity = null; + annotation = null; } /** * @param position - * @param entity + * @param annotation */ - public Disambiguation(CellPosition position, Entity entity) { + public Disambiguation(CellPosition position, CellAnnotation annotation) { Preconditions.checkNotNull(position); - Preconditions.checkNotNull(entity); + Preconditions.checkNotNull(annotation); this.position = position; - this.entity = entity; + this.annotation = annotation; } /** @@ -45,10 +46,10 @@ public CellPosition getPosition() { } /** - * @return the entity + * @return the annotation */ - public Entity getEntity() { - return entity; + public CellAnnotation getAnnotation() { + return annotation; } /* (non-Javadoc) @@ -58,7 +59,7 @@ public Entity getEntity() { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((entity == null) ? 0 : entity.hashCode()); + result = prime * result + ((annotation == null) ? 0 : annotation.hashCode()); result = prime * result + ((position == null) ? 0 : position.hashCode()); return result; } @@ -78,11 +79,11 @@ public boolean equals(Object obj) { return false; } Disambiguation other = (Disambiguation) obj; - if (entity == null) { - if (other.entity != null) { + if (annotation == null) { + if (other.annotation != null) { return false; } - } else if (!entity.equals(other.entity)) { + } else if (!annotation.equals(other.annotation)) { return false; } if (position == null) { @@ -100,6 +101,6 @@ public boolean equals(Object obj) { */ @Override public String toString() { - return "Disambiguation [position=" + position + ", entity=" + entity + "]"; + return "Disambiguation [position=" + position + ", annotation=" + annotation + "]"; } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java index 691a9bd5..f628bde5 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java @@ -9,7 +9,7 @@ import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableSet; -import cz.cuni.mff.xrg.odalic.feedbacks.types.ColumnPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; @XmlRootElement(name = "feedback") public final class Feedback implements Serializable { @@ -22,26 +22,26 @@ public final class Feedback implements Serializable { @XmlElement private final Set columnIgnores; - @XmlElement - private final Set columnAmbiguities; - @XmlElement private final Set classifications; @XmlElement - private final Set cellRelations; + private final Set columnAmbiguities; @XmlElement - private final Set columnRelations; + private final Set ambiguities; @XmlElement private final Set disambiguations; @XmlElement - private final Set ambiguities; + private final Set cellRelations; + + @XmlElement + private final Set columnRelations; + - @SuppressWarnings("unused") - private Feedback() { + public Feedback() { this.subjectColumnPosition = null; this.columnIgnores = ImmutableSet.of(); this.columnAmbiguities = ImmutableSet.of(); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultCsvInputParser.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultCsvInputParser.java new file mode 100644 index 00000000..e672e205 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultCsvInputParser.java @@ -0,0 +1,12 @@ +package cz.cuni.mff.xrg.odalic.feedbacks.input; + +public class DefaultCsvInputParser implements InputParser { + + @Override + public Input parse(String content) { + // TODO: Provide implementation. Probably using the extractor. + return null; + } + + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultInputToTableAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultInputToTableAdapter.java new file mode 100644 index 00000000..c7c5c579 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultInputToTableAdapter.java @@ -0,0 +1,13 @@ +package cz.cuni.mff.xrg.odalic.feedbacks.input; + +import uk.ac.shef.dcs.sti.core.model.Table; + +public class DefaultInputToTableAdapter implements InputToTableAdapter { + + @Override + public Table toTable(Input input) { + // TODO: Provide implementation. + return null; + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultTableToInputAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultTableToInputAdapter.java new file mode 100644 index 00000000..5fbc934d --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultTableToInputAdapter.java @@ -0,0 +1,13 @@ +package cz.cuni.mff.xrg.odalic.feedbacks.input; + +import uk.ac.shef.dcs.sti.core.model.Table; + +public class DefaultTableToInputAdapter implements TableToInputAdapter { + + @Override + public Input toInput(Table table) { + // TODO: Provide implementation. + return null; + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/Input.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/Input.java new file mode 100644 index 00000000..d3608a44 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/Input.java @@ -0,0 +1,19 @@ +package cz.cuni.mff.xrg.odalic.feedbacks.input; + +import java.util.List; + +import cz.cuni.mff.xrg.odalic.positions.CellPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.positions.RowPosition; + +public interface Input { + String at(CellPosition position); + String headerAt(ColumnPosition position); + List rowAt(RowPosition position); + List columnAt(ColumnPosition position); + int rowsCount(); + int columnsCount(); + List headers(); + List> rows(); + List> columns(); +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputParser.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputParser.java new file mode 100644 index 00000000..e34895d0 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputParser.java @@ -0,0 +1,5 @@ +package cz.cuni.mff.xrg.odalic.feedbacks.input; + +public interface InputParser { + Input parse(String content); +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputToTableAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputToTableAdapter.java new file mode 100644 index 00000000..6ada902c --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputToTableAdapter.java @@ -0,0 +1,7 @@ +package cz.cuni.mff.xrg.odalic.feedbacks.input; + +import uk.ac.shef.dcs.sti.core.model.Table; + +public interface InputToTableAdapter { + Table toTable(Input input); +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/SimpleInput.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/SimpleInput.java new file mode 100644 index 00000000..d09fdc57 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/SimpleInput.java @@ -0,0 +1,112 @@ +package cz.cuni.mff.xrg.odalic.feedbacks.input; + +import java.io.Serializable; +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import cz.cuni.mff.xrg.odalic.positions.CellPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.positions.RowPosition; +import cz.cuni.mff.xrg.odalic.util.Arrays; + +@XmlRootElement(name = "input") +public class SimpleInput implements Input, Serializable { + + private static final long serialVersionUID = 4101912998363935336L; + + @XmlElement + private final List headers; + + @XmlElement + private final String[][] content; + + @SuppressWarnings("unused") + private SimpleInput() { + headers = ImmutableList.of(); + content = new String[0][0]; + } + + /** + * @param headers + * @param content + */ + public SimpleInput(List headers, String[][] content) { + Preconditions.checkNotNull(headers); + Preconditions.checkNotNull(content); + + Preconditions.checkArgument(!Arrays.containsNull(content)); + Preconditions.checkArgument(Arrays.isMatrix(content)); + + this.headers = ImmutableList.copyOf(headers); + this.content = Arrays.deepCopy(String.class, content); + } + + /** + * @return the headers + */ + public List getHeaders() { + return headers; + } + + /** + * @return the content + */ + public String[][] getContent() { + return Arrays.deepCopy(String.class, content); + } + + @Override + public String at(CellPosition position) { + return content[position.getRowPosition().getIndex()][position.getColumnPosition().getIndex()]; + } + + @Override + public String headerAt(ColumnPosition position) { + return headers.get(position.getIndex()); + } + + @Override + public int rowsCount() { + return content.length; + } + + @Override + public int columnsCount() { + return headers.size(); + } + + @Override + public List headers() { + return headers; + } + + @Override + public List rowAt(RowPosition position) { + // TODO Auto-generated method stub + return null; + } + + @Override + public List columnAt(ColumnPosition position) { + // TODO Auto-generated method stub + return null; + } + + @Override + public List> rows() { + // TODO Auto-generated method stub + return null; + } + + @Override + public List> columns() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/TableToInputAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/TableToInputAdapter.java new file mode 100644 index 00000000..e1010d15 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/TableToInputAdapter.java @@ -0,0 +1,7 @@ +package cz.cuni.mff.xrg.odalic.feedbacks.input; + +import uk.ac.shef.dcs.sti.core.model.Table; + +public interface TableToInputAdapter { + Input toInput(Table table); +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/MemoryOnlyFileService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/MemoryOnlyFileService.java index 159f199e..eee55fe5 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/MemoryOnlyFileService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/MemoryOnlyFileService.java @@ -128,6 +128,5 @@ public String getDataById(String id) throws IOException { } else { return data; } - } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/types/CellPosition.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/CellPosition.java similarity index 98% rename from odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/types/CellPosition.java rename to odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/CellPosition.java index c3ff9ca1..c29ff295 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/types/CellPosition.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/CellPosition.java @@ -1,4 +1,4 @@ -package cz.cuni.mff.xrg.odalic.feedbacks.types; +package cz.cuni.mff.xrg.odalic.positions; import java.io.Serializable; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/CellRelationPosition.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/CellRelationPosition.java new file mode 100644 index 00000000..1964f3af --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/CellRelationPosition.java @@ -0,0 +1,92 @@ +package cz.cuni.mff.xrg.odalic.positions; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +@XmlRootElement(name = "cellRelationPosition") +public final class CellRelationPosition { + + @XmlElement + private final ColumnRelationPosition columnsPosition; + + @XmlElement + private final RowPosition rowPosition; + + + public CellRelationPosition(ColumnRelationPosition columnsPosition, RowPosition rowPosition) { + Preconditions.checkNotNull(columnsPosition); + Preconditions.checkNotNull(rowPosition); + + this.columnsPosition = columnsPosition; + this.rowPosition = rowPosition; + } + + /** + * @return the rowPosition + */ + public RowPosition getRowPosition() { + return rowPosition; + } + + /** + * @return the columnsPosition + */ + public ColumnRelationPosition getColumnsPosition() { + return columnsPosition; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((columnsPosition == null) ? 0 : columnsPosition.hashCode()); + result = prime * result + ((rowPosition == null) ? 0 : rowPosition.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + CellRelationPosition other = (CellRelationPosition) obj; + if (columnsPosition == null) { + if (other.columnsPosition != null) { + return false; + } + } else if (!columnsPosition.equals(other.columnsPosition)) { + return false; + } + if (rowPosition == null) { + if (other.rowPosition != null) { + return false; + } + } else if (!rowPosition.equals(other.rowPosition)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "CellRelationPosition [columnsPosition=" + columnsPosition + ", rowPosition=" + + rowPosition + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/types/ColumnPosition.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/ColumnPosition.java similarity index 96% rename from odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/types/ColumnPosition.java rename to odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/ColumnPosition.java index 8225a631..1dbde5a3 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/types/ColumnPosition.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/ColumnPosition.java @@ -1,4 +1,4 @@ -package cz.cuni.mff.xrg.odalic.feedbacks.types; +package cz.cuni.mff.xrg.odalic.positions; import java.io.Serializable; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/ColumnRelationPosition.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/ColumnRelationPosition.java new file mode 100644 index 00000000..a2f3d675 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/ColumnRelationPosition.java @@ -0,0 +1,85 @@ +package cz.cuni.mff.xrg.odalic.positions; + +import com.google.common.base.Preconditions; + +public final class ColumnRelationPosition { + + private final ColumnPosition first; + + private final ColumnPosition second; + + public ColumnRelationPosition(ColumnPosition first, ColumnPosition second) { + Preconditions.checkNotNull(first); + Preconditions.checkNotNull(second); + Preconditions.checkArgument(first.getIndex() != second.getIndex()); + + this.first = first; + this.second = second; + } + + /** + * @return the first + */ + public ColumnPosition getFirst() { + return first; + } + + /** + * @return the second + */ + public ColumnPosition getSecond() { + return second; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((first == null) ? 0 : first.hashCode()); + result = prime * result + ((second == null) ? 0 : second.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ColumnRelationPosition other = (ColumnRelationPosition) obj; + if (first == null) { + if (other.first != null) { + return false; + } + } else if (!first.equals(other.first)) { + return false; + } + if (second == null) { + if (other.second != null) { + return false; + } + } else if (!second.equals(other.second)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ColumnRelationPosition [first=" + first + ", second=" + second + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/types/RowPosition.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/RowPosition.java similarity index 96% rename from odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/types/RowPosition.java rename to odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/RowPosition.java index 49687382..8b0a4eb4 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/types/RowPosition.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/RowPosition.java @@ -1,4 +1,4 @@ -package cz.cuni.mff.xrg.odalic.feedbacks.types; +package cz.cuni.mff.xrg.odalic.positions; import java.io.Serializable; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/Task.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/Task.java index 3464d817..8b35ec2c 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/Task.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/Task.java @@ -1,7 +1,6 @@ package cz.cuni.mff.xrg.odalic.tasks; import java.io.Serializable; -import java.net.URL; import java.util.Date; import javax.xml.bind.annotation.XmlElement; @@ -14,8 +13,8 @@ import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateDeserializer; import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateSerializer; -import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; -import cz.cuni.mff.xrg.odalic.tasks.results.Result; +import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; +import cz.cuni.mff.xrg.odalic.tasks.executions.Execution; @XmlRootElement(name = "task") public final class Task implements Serializable { @@ -31,76 +30,67 @@ public final class Task implements Serializable { private final Date created; @XmlElement - private final URL input; - - @XmlElement - private final Feedback feedback; - - @XmlElement - private final Result result; + private Configuration configuration; @SuppressWarnings("unused") private Task() { id = null; created = null; - input = null; - feedback = null; - result = null; + configuration = null; } /** * @param id * @param created - * @param input - * @param feedback - * @param result + * @param configuration * */ - public Task(String id, Date created, URL input, Feedback feedback, Result result) { + public Task(String id, Date created, Configuration configuration) { Preconditions.checkNotNull(id); - Preconditions.checkNotNull(input); - Preconditions.checkNotNull(feedback); - Preconditions.checkNotNull(result); + Preconditions.checkNotNull(created); + Preconditions.checkNotNull(configuration); this.id = id; this.created = created; - this.input = input; - this.feedback = feedback; - this.result = result; + this.configuration = configuration; } - - /** - * @return the id - */ - public String getId() { - return id; + + public Task(String id, Date created, Configuration configuration, Execution execution) { + Preconditions.checkNotNull(id); + Preconditions.checkNotNull(created); + Preconditions.checkNotNull(configuration); + Preconditions.checkNotNull(execution); + + this.id = id; + this.created = created; + this.configuration = configuration; } /** - * @return the created + * @return the configuration */ - public Date getCreated() { - return created; + public Configuration getConfiguration() { + return configuration; } /** - * @return the input + * @param configuration the configuration to set */ - public URL getInput() { - return input; + public void setConfiguration(Configuration configuration) { + this.configuration = configuration; } /** - * @return the feedback + * @return the id */ - public Feedback getFeedback() { - return feedback; + public String getId() { + return id; } /** - * @return the result + * @return the created */ - public Result getResult() { - return result; + public Date getCreated() { + return created; } /* (non-Javadoc) @@ -110,11 +100,7 @@ public Result getResult() { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((created == null) ? 0 : created.hashCode()); - result = prime * result + ((feedback == null) ? 0 : feedback.hashCode()); result = prime * result + ((id == null) ? 0 : id.hashCode()); - result = prime * result + ((input == null) ? 0 : input.hashCode()); - result = prime * result + ((this.result == null) ? 0 : this.result.hashCode()); return result; } @@ -133,20 +119,6 @@ public boolean equals(Object obj) { return false; } Task other = (Task) obj; - if (created == null) { - if (other.created != null) { - return false; - } - } else if (!created.equals(other.created)) { - return false; - } - if (feedback == null) { - if (other.feedback != null) { - return false; - } - } else if (!feedback.equals(other.feedback)) { - return false; - } if (id == null) { if (other.id != null) { return false; @@ -154,20 +126,6 @@ public boolean equals(Object obj) { } else if (!id.equals(other.id)) { return false; } - if (input == null) { - if (other.input != null) { - return false; - } - } else if (!input.equals(other.input)) { - return false; - } - if (result == null) { - if (other.result != null) { - return false; - } - } else if (!result.equals(other.result)) { - return false; - } return true; } @@ -176,7 +134,7 @@ public boolean equals(Object obj) { */ @Override public String toString() { - return "Task [id=" + id + ", created=" + created + ", input=" + input + ", feedback=" + feedback - + ", result=" + result + "]"; + return "Task [id=" + id + ", created=" + created + ", configuration=" + configuration + + "]"; } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskDigest.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskDigest.java index fddcfb9c..c7bd82eb 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskDigest.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskDigest.java @@ -12,6 +12,7 @@ import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateDeserializer; import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateSerializer; +import cz.cuni.mff.xrg.odalic.tasks.executions.State; import cz.cuni.mff.xrg.odalic.tasks.results.Result; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellAnnotation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellAnnotation.java new file mode 100644 index 00000000..ad8648a8 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellAnnotation.java @@ -0,0 +1,124 @@ +package cz.cuni.mff.xrg.odalic.tasks.annotations; + +import java.util.Map; +import java.util.NavigableSet; +import java.util.Set; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.apache.jena.ext.com.google.common.collect.ImmutableSet; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSortedSet; + + +@XmlRootElement(name = "cellAnnotation") +public final class CellAnnotation { + + @XmlElement + private final Map> candidates; + + @XmlElement + private final Map> chosen; + + @SuppressWarnings("unused") + private CellAnnotation() { + candidates = ImmutableMap.of(); + chosen = ImmutableMap.of(); + } + + /** + * @param candidates + * @param chosen + */ + public CellAnnotation(Map> candidates, + Map> chosen) { + Preconditions.checkNotNull(candidates); + Preconditions.checkNotNull(chosen); + + ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); + for (final Map.Entry> candidateEntry : candidates.entrySet()) { + candidatesBuilder.put(candidateEntry.getKey(), ImmutableSortedSet.copyOf(candidateEntry.getValue())); + } + this.candidates = candidatesBuilder.build(); + + ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); + for (final Map.Entry> chosenEntry : chosen.entrySet()) { + final KnowledgeBase chosenBase = chosenEntry.getKey(); + + final Set baseCandidates = this.candidates.get(chosenBase); + Preconditions.checkArgument(baseCandidates != null); + Preconditions.checkArgument(baseCandidates.containsAll(chosenEntry.getValue())); + + chosenBuilder.put(chosenEntry.getKey(), ImmutableSet.copyOf(chosenEntry.getValue())); + } + this.chosen = chosenBuilder.build(); + } + + /** + * @return the candidates + */ + public Map> getCandidates() { + return candidates; + } + + /** + * @return the chosen + */ + public Map> getChosen() { + return chosen; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((candidates == null) ? 0 : candidates.hashCode()); + result = prime * result + ((chosen == null) ? 0 : chosen.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + CellAnnotation other = (CellAnnotation) obj; + if (candidates == null) { + if (other.candidates != null) { + return false; + } + } else if (!candidates.equals(other.candidates)) { + return false; + } + if (chosen == null) { + if (other.chosen != null) { + return false; + } + } else if (!chosen.equals(other.chosen)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "CellAnnotation [candidates=" + candidates + ", chosen=" + chosen + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellRelationAnnotation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellRelationAnnotation.java new file mode 100644 index 00000000..77025b4e --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellRelationAnnotation.java @@ -0,0 +1,123 @@ +package cz.cuni.mff.xrg.odalic.tasks.annotations; + +import java.util.Map; +import java.util.NavigableSet; +import java.util.Set; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.apache.jena.ext.com.google.common.collect.ImmutableSet; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSortedSet; + +@XmlRootElement(name = "cellRelationAnnotation") +public final class CellRelationAnnotation { + + @XmlElement + private final Map> candidates; + + @XmlElement + private final Map> chosen; + + @SuppressWarnings("unused") + private CellRelationAnnotation() { + candidates = ImmutableMap.of(); + chosen = ImmutableMap.of(); + } + + /** + * @param candidates + * @param chosen + */ + public CellRelationAnnotation(Map> candidates, + Map> chosen) { + Preconditions.checkNotNull(candidates); + Preconditions.checkNotNull(chosen); + + ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); + for (final Map.Entry> candidateEntry : candidates.entrySet()) { + candidatesBuilder.put(candidateEntry.getKey(), ImmutableSortedSet.copyOf(candidateEntry.getValue())); + } + this.candidates = candidatesBuilder.build(); + + ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); + for (final Map.Entry> chosenEntry : chosen.entrySet()) { + final KnowledgeBase chosenBase = chosenEntry.getKey(); + + final Set baseCandidates = this.candidates.get(chosenBase); + Preconditions.checkArgument(baseCandidates != null); + Preconditions.checkArgument(baseCandidates.containsAll(chosenEntry.getValue())); + + chosenBuilder.put(chosenEntry.getKey(), ImmutableSet.copyOf(chosenEntry.getValue())); + } + this.chosen = chosenBuilder.build(); + } + + /** + * @return the candidates + */ + public Map> getCandidates() { + return candidates; + } + + /** + * @return the chosen + */ + public Map> getChosen() { + return chosen; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((candidates == null) ? 0 : candidates.hashCode()); + result = prime * result + ((chosen == null) ? 0 : chosen.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + CellRelationAnnotation other = (CellRelationAnnotation) obj; + if (candidates == null) { + if (other.candidates != null) { + return false; + } + } else if (!candidates.equals(other.candidates)) { + return false; + } + if (chosen == null) { + if (other.chosen != null) { + return false; + } + } else if (!chosen.equals(other.chosen)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "CellRelationAnnotation [candidates=" + candidates + ", chosen=" + chosen + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/ColumnRelationAnnotation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/ColumnRelationAnnotation.java new file mode 100644 index 00000000..ccac4cf9 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/ColumnRelationAnnotation.java @@ -0,0 +1,123 @@ +package cz.cuni.mff.xrg.odalic.tasks.annotations; + +import java.util.Map; +import java.util.NavigableSet; +import java.util.Set; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.apache.jena.ext.com.google.common.collect.ImmutableSet; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSortedSet; + +@XmlRootElement(name = "columnRelationAnnotation") +public final class ColumnRelationAnnotation { + + @XmlElement + private final Map> candidates; + + @XmlElement + private final Map> chosen; + + @SuppressWarnings("unused") + private ColumnRelationAnnotation() { + candidates = ImmutableMap.of(); + chosen = ImmutableMap.of(); + } + + /** + * @param candidates + * @param chosen + */ + public ColumnRelationAnnotation(Map> candidates, + Map> chosen) { + Preconditions.checkNotNull(candidates); + Preconditions.checkNotNull(chosen); + + ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); + for (final Map.Entry> candidateEntry : candidates.entrySet()) { + candidatesBuilder.put(candidateEntry.getKey(), ImmutableSortedSet.copyOf(candidateEntry.getValue())); + } + this.candidates = candidatesBuilder.build(); + + ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); + for (final Map.Entry> chosenEntry : chosen.entrySet()) { + final KnowledgeBase chosenBase = chosenEntry.getKey(); + + final Set baseCandidates = this.candidates.get(chosenBase); + Preconditions.checkArgument(baseCandidates != null); + Preconditions.checkArgument(baseCandidates.containsAll(chosenEntry.getValue())); + + chosenBuilder.put(chosenEntry.getKey(), ImmutableSet.copyOf(chosenEntry.getValue())); + } + this.chosen = chosenBuilder.build(); + } + + /** + * @return the candidates + */ + public Map> getCandidates() { + return candidates; + } + + /** + * @return the chosen + */ + public Map> getChosen() { + return chosen; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((candidates == null) ? 0 : candidates.hashCode()); + result = prime * result + ((chosen == null) ? 0 : chosen.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ColumnRelationAnnotation other = (ColumnRelationAnnotation) obj; + if (candidates == null) { + if (other.candidates != null) { + return false; + } + } else if (!candidates.equals(other.candidates)) { + return false; + } + if (chosen == null) { + if (other.chosen != null) { + return false; + } + } else if (!chosen.equals(other.chosen)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ColumnRelationAnnotation [candidates=" + candidates + ", chosen=" + chosen + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/types/Entity.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Entity.java similarity index 90% rename from odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/types/Entity.java rename to odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Entity.java index beb12ad7..560d3553 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/types/Entity.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Entity.java @@ -1,4 +1,4 @@ -package cz.cuni.mff.xrg.odalic.feedbacks.types; +package cz.cuni.mff.xrg.odalic.tasks.annotations; import java.io.Serializable; import java.net.URI; @@ -14,7 +14,7 @@ * @author Václav Brodec */ @XmlRootElement(name = "entity") -public final class Entity implements Serializable { +public final class Entity implements Comparable, Serializable { private static final long serialVersionUID = -3001706805535088480L; @@ -97,4 +97,11 @@ public boolean equals(Object obj) { public String toString() { return "Annotation [resource=" + resource + ", label=" + label + "]"; } + + @Override + public int compareTo(Entity o) { + return resource.compareTo(o.resource); + } + + } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/EntityCandidate.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/EntityCandidate.java new file mode 100644 index 00000000..176953bb --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/EntityCandidate.java @@ -0,0 +1,108 @@ +package cz.cuni.mff.xrg.odalic.tasks.annotations; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +@XmlRootElement(name = "entityCandidate") +public final class EntityCandidate implements Comparable, Serializable { + + private static final long serialVersionUID = 3072774254576336747L; + + @XmlElement + private final Entity entity; + + @XmlElement + private final Likelihood likelihood; + + /** + * @param entity + * @param likelihood + */ + public EntityCandidate(Entity entity, Likelihood likelihood) { + Preconditions.checkNotNull(entity); + + this.entity = entity; + this.likelihood = likelihood; + } + + /** + * @return the entity + */ + public Entity getEntity() { + return entity; + } + + /** + * @return the likelihood + */ + public Likelihood getLikelihood() { + return likelihood; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((entity == null) ? 0 : entity.hashCode()); + result = prime * result + ((likelihood == null) ? 0 : likelihood.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + EntityCandidate other = (EntityCandidate) obj; + if (entity == null) { + if (other.entity != null) { + return false; + } + } else if (!entity.equals(other.entity)) { + return false; + } + if (likelihood == null) { + if (other.likelihood != null) { + return false; + } + } else if (!likelihood.equals(other.likelihood)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "EntityCandidate [entity=" + entity + ", likelihood=" + likelihood + "]"; + } + + @Override + public int compareTo(EntityCandidate o) { + final int likelihoodComparison = likelihood.compareTo(o.likelihood); + + if (likelihoodComparison == 0) { + return entity.compareTo(o.entity); + } else { + return likelihoodComparison; + } + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/HeaderAnnotation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/HeaderAnnotation.java new file mode 100644 index 00000000..5afa8f6a --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/HeaderAnnotation.java @@ -0,0 +1,123 @@ +package cz.cuni.mff.xrg.odalic.tasks.annotations; + +import java.util.Map; +import java.util.NavigableSet; +import java.util.Set; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.apache.jena.ext.com.google.common.collect.ImmutableSet; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSortedSet; + +@XmlRootElement(name = "headerAnnotation") +public final class HeaderAnnotation { + + @XmlElement + private final Map> candidates; + + @XmlElement + private final Map> chosen; + + @SuppressWarnings("unused") + private HeaderAnnotation() { + candidates = ImmutableMap.of(); + chosen = ImmutableMap.of(); + } + + /** + * @param candidates + * @param chosen + */ + public HeaderAnnotation(Map> candidates, + Map> chosen) { + Preconditions.checkNotNull(candidates); + Preconditions.checkNotNull(chosen); + + ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); + for (final Map.Entry> candidateEntry : candidates.entrySet()) { + candidatesBuilder.put(candidateEntry.getKey(), ImmutableSortedSet.copyOf(candidateEntry.getValue())); + } + this.candidates = candidatesBuilder.build(); + + ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); + for (final Map.Entry> chosenEntry : chosen.entrySet()) { + final KnowledgeBase chosenBase = chosenEntry.getKey(); + + final Set baseCandidates = this.candidates.get(chosenBase); + Preconditions.checkArgument(baseCandidates != null); + Preconditions.checkArgument(baseCandidates.containsAll(chosenEntry.getValue())); + + chosenBuilder.put(chosenEntry.getKey(), ImmutableSet.copyOf(chosenEntry.getValue())); + } + this.chosen = chosenBuilder.build(); + } + + /** + * @return the candidates + */ + public Map> getCandidates() { + return candidates; + } + + /** + * @return the chosen + */ + public Map> getChosen() { + return chosen; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((candidates == null) ? 0 : candidates.hashCode()); + result = prime * result + ((chosen == null) ? 0 : chosen.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + HeaderAnnotation other = (HeaderAnnotation) obj; + if (candidates == null) { + if (other.candidates != null) { + return false; + } + } else if (!candidates.equals(other.candidates)) { + return false; + } + if (chosen == null) { + if (other.chosen != null) { + return false; + } + } else if (!chosen.equals(other.chosen)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "HeaderAnnotation [candidates=" + candidates + ", chosen=" + chosen + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/KnowledgeBase.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/KnowledgeBase.java new file mode 100644 index 00000000..76a7356a --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/KnowledgeBase.java @@ -0,0 +1,8 @@ +package cz.cuni.mff.xrg.odalic.tasks.annotations; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "knowledgeBase") +public class KnowledgeBase { + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Likelihood.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Likelihood.java new file mode 100644 index 00000000..0ae03138 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Likelihood.java @@ -0,0 +1,92 @@ +package cz.cuni.mff.xrg.odalic.tasks.annotations; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +@XmlRootElement(name = "likelihood") +public final class Likelihood implements Comparable, Serializable { + + private static final long serialVersionUID = -901650058091668104L; + + @XmlElement + private final double value; + + @SuppressWarnings("unused") + private Likelihood() { + value = Double.NEGATIVE_INFINITY; + } + + /** + * @param value + */ + public Likelihood(double value) { + Preconditions.checkArgument(value >= 0); + Preconditions.checkArgument(value <= 1); + + this.value = value; + } + + /** + * @return the value + */ + public double getValue() { + return value; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + long temp; + temp = Double.doubleToLongBits(value); + result = prime * result + (int) (temp ^ (temp >>> 32)); + return result; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Likelihood other = (Likelihood) obj; + if (Double.doubleToLongBits(value) != Double.doubleToLongBits(other.value)) { + return false; + } + return true; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Likelihood [value=" + value + "]"; + } + + @Override + public int compareTo(Likelihood o) { + return Double.compare(value, o.value); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java index 5181ed41..a450b49b 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java @@ -1,38 +1,109 @@ package cz.cuni.mff.xrg.odalic.tasks.configurations; import java.io.Serializable; -import java.net.URL; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import com.google.common.base.Preconditions; + import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; +import cz.cuni.mff.xrg.odalic.files.File; -@XmlRootElement +@XmlRootElement(name = "configuration") public class Configuration implements Serializable { private static final long serialVersionUID = -6359038623760039155L; @XmlElement(name = "input") - private URL input; + private final File input; @XmlElement(name = "feedback") - private Feedback feedback; - - public Configuration() {} + private final Feedback feedback; - public URL getInput() { - return input; + @SuppressWarnings("unused") + private Configuration() { + input = null; + feedback = new Feedback(); } - public void setInput(URL input) { + public Configuration(File input) { + Preconditions.checkNotNull(input); + + this.input = input; + this.feedback = new Feedback(); + } + + public Configuration(File input, Feedback feedback) { + Preconditions.checkNotNull(input); + Preconditions.checkNotNull(feedback); + this.input = input; + this.feedback = feedback; } + /** + * @return the input + */ + public File getInput() { + return input; + } + + /** + * @return the feedback + */ public Feedback getFeedback() { return feedback; } - public void setFeedback(Feedback feedback) { - this.feedback = feedback; + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((feedback == null) ? 0 : feedback.hashCode()); + result = prime * result + ((input == null) ? 0 : input.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Configuration other = (Configuration) obj; + if (feedback == null) { + if (other.feedback != null) { + return false; + } + } else if (!feedback.equals(other.feedback)) { + return false; + } + if (input == null) { + if (other.input != null) { + return false; + } + } else if (!input.equals(other.input)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Configuration [input=" + input + ", feedback=" + feedback + "]"; } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationService.java index ed7be26e..4a24fd09 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationService.java @@ -2,9 +2,7 @@ public interface ConfigurationService { - void setConfigurationForTaskId(String id, Configuration execution); + Configuration getForTaskId(String taskId); - Configuration getConfigurationForTaskId(String id); - - void deleteConfigurationForTaskId(String id); + void setForTaskId(String taskId, Configuration execution); } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationServiceImpl.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationServiceImpl.java deleted file mode 100644 index 175e154d..00000000 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationServiceImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * - */ -package cz.cuni.mff.xrg.odalic.tasks.configurations; - -/** - * @author Václav Brodec - * - */ -public final class ConfigurationServiceImpl implements ConfigurationService { - - @Override - public void setConfigurationForTaskId(String id, Configuration execution) { - // TODO Auto-generated method stub - } - - @Override - public Configuration getConfigurationForTaskId(String id) { - // TODO Auto-generated method stub - return null; - } - - @Override - public void deleteConfigurationForTaskId(String id) { - // TODO Auto-generated method stub - }} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/MemoryOnlyConfigurationService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/MemoryOnlyConfigurationService.java new file mode 100644 index 00000000..a4473244 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/MemoryOnlyConfigurationService.java @@ -0,0 +1,45 @@ +package cz.cuni.mff.xrg.odalic.tasks.configurations; + +import org.springframework.beans.factory.annotation.Autowired; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.tasks.Task; +import cz.cuni.mff.xrg.odalic.tasks.TaskService; + +/** + * @author Václav Brodec + * + */ +public final class MemoryOnlyConfigurationService implements ConfigurationService { + + private final TaskService taskService; + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.tasks.configurations.ConfigurationService#getForTaskId(java.lang.String) + */ + @Override + public Configuration getForTaskId(String taskId) { + final Task task = taskService.getById(taskId); + + return task.getConfiguration(); + } + + /** + * @param taskId + * @param configuration + */ + @Override + public void setForTaskId(String taskId, Configuration configuration) { + final Task task = taskService.getById(taskId); + + task.setConfiguration(configuration); + } + + @Autowired + public MemoryOnlyConfigurationService(TaskService taskService) { + Preconditions.checkNotNull(taskService); + + this.taskService = taskService; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/Execution.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/Execution.java index 5f084137..cc127504 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/Execution.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/Execution.java @@ -1,50 +1,38 @@ package cz.cuni.mff.xrg.odalic.tasks.executions; import java.io.Serializable; -import java.net.URL; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import cz.cuni.mff.xrg.odalic.tasks.State; - -@XmlRootElement +@XmlRootElement(name = "execution") public class Execution implements Serializable { private static final long serialVersionUID = -6359038623760039155L; - @XmlElement(name = "state") - private State state; - - @XmlElement(name = "draft") - private boolean draft; + @XmlElement + private final boolean draft; - @XmlElement(name = "result") - private URL result; - - public State getState() { - return state; + public Execution() { + draft = false; } - - public void setState(State state) { - this.state = state; + + public Execution(boolean draft) { + this.draft = draft; } + /** + * @return the draft + */ public boolean isDraft() { return draft; } - public void setDraft(boolean draft) { - this.draft = draft; - } - - public URL getResult() { - return result; + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Execution [draft=" + draft + "]"; } - - public void setResult(URL result) { - this.result = result; - } - - public Execution() {} } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionService.java index 85fac9a5..5b79946e 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionService.java @@ -1,9 +1,19 @@ package cz.cuni.mff.xrg.odalic.tasks.executions; +import java.util.concurrent.ExecutionException; + +import cz.cuni.mff.xrg.odalic.tasks.results.Result; + public interface ExecutionService { - void scheduleExecutionForTaskId(String id, Execution execution); + void submitForTaskId(String id); + + void cancelForTaskId(String id); + + boolean isDoneForTaskId(String id); + + boolean isCancelledForTaskId(String id); - Execution getExecutionForTaskId(String id); + Result getResultForTaskId(String id) throws InterruptedException, ExecutionException; - void stopExecutionForTaskId(String id); + boolean hasBeenScheduledForTaskId(String id); } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionServiceImpl.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionServiceImpl.java deleted file mode 100644 index dd4b141a..00000000 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionServiceImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * - */ -package cz.cuni.mff.xrg.odalic.tasks.executions; - -/** - * @author Václav Brodec - * - */ -public final class ExecutionServiceImpl implements ExecutionService { - - @Override - public void scheduleExecutionForTaskId(String id, Execution execution) { - // TODO Auto-generated method stub - } - - @Override - public Execution getExecutionForTaskId(String id) { - // TODO Auto-generated method stub - return null; - } - - @Override - public void stopExecutionForTaskId(String id) { - // TODO Auto-generated method stub - }} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java new file mode 100644 index 00000000..abe954aa --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java @@ -0,0 +1,143 @@ +/** + * + */ +package cz.cuni.mff.xrg.odalic.tasks.executions; + +import java.net.URISyntaxException; +import java.net.URL; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +import org.springframework.beans.factory.annotation.Autowired; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.files.File; +import cz.cuni.mff.xrg.odalic.tasks.Task; +import cz.cuni.mff.xrg.odalic.tasks.TaskService; +import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; +import cz.cuni.mff.xrg.odalic.tasks.results.AnnotationToResultAdapter; +import cz.cuni.mff.xrg.odalic.tasks.results.Result; +import uk.ac.shef.dcs.sti.core.algorithm.SemanticTableInterpreter; +import uk.ac.shef.dcs.sti.core.model.TAnnotation; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.xtractor.csv.TableXtractorCSV; + +/** + * @author Václav Brodec + * + */ +public final class FutureBasedExecutionService implements ExecutionService { + + private final TaskService taskService; + private final AnnotationToResultAdapter annotationResultAdapter; + private final ExecutorService executorService = Executors.newFixedThreadPool(1); + private final Map> tasksToResults = new HashMap<>(); + + // TODO: Initialize, but verify whether per submit instantiation is not necessary. Provide as injected bean then. + private final SemanticTableInterpreter semanticTableInterpreter = null; + + //TODO: This dependency should be made explicit and more reliable. + private final TableXtractorCSV tableExtractor = new TableXtractorCSV(); + + @Autowired + public FutureBasedExecutionService(TaskService taskService, + AnnotationToResultAdapter annotationToResultAdapter) { + Preconditions.checkNotNull(taskService); + //TODO: When set, uncomment this: Preconditions.checkNotNull(semanticTableInterpreter); + + this.taskService = taskService; + this.annotationResultAdapter = annotationToResultAdapter; + } + + @Override + public void submitForTaskId(String id) { + final Task task = taskService.getById(id); + + final Future resultFuture = tasksToResults.get(task); + if (resultFuture != null) { + if (!resultFuture.isDone()) { + throw new IllegalStateException(); + } + } + + final Configuration configuration = task.getConfiguration(); + final File file = configuration.getInput(); + final URL fileLocation = file.getLocation(); + final java.io.File inputFile = urlToFile(fileLocation); + + final Callable execution = () -> { + final List
tables = tableExtractor.extract(inputFile, inputFile.getName()); + + if (tables.isEmpty()) { + throw new IllegalArgumentException(); + } + + final TAnnotation annotationResult = semanticTableInterpreter.start(tables.get(0), true); + + final Result result = annotationResultAdapter.toResult(annotationResult); + + return result; + }; + + final Future future = executorService.submit(execution); + + tasksToResults.put(task, future); + } + + private java.io.File urlToFile(final URL fileLocation) { + java.io.File inputFile; + try { + inputFile = new java.io.File(fileLocation.toURI()); + } catch (URISyntaxException e) { + inputFile = new java.io.File(fileLocation.getPath()); + } + return inputFile; + } + + @Override + public Result getResultForTaskId(String id) throws InterruptedException, ExecutionException { + final Task task = taskService.getById(id); + final Future resultFuture = tasksToResults.get(task); + + return resultFuture.get(); + } + + @Override + public void cancelForTaskId(String id) { + final Task task = taskService.getById(id); + final Future resultFuture = tasksToResults.get(task); + + resultFuture.cancel(true); + } + + @Override + public boolean isDoneForTaskId(String id) { + final Task task = taskService.getById(id); + final Future resultFuture = tasksToResults.get(task); + + return resultFuture.isDone(); + } + + @Override + public boolean isCancelledForTaskId(String id) { + final Task task = taskService.getById(id); + final Future resultFuture = tasksToResults.get(task); + + return resultFuture.isCancelled(); + } + + @Override + public boolean hasBeenScheduledForTaskId(String id) { + final Task task = taskService.getById(id); + final Future resultFuture = tasksToResults.get(task); + + return resultFuture != null; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/State.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/State.java similarity index 68% rename from odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/State.java rename to odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/State.java index 8387cd55..10fdbca7 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/State.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/State.java @@ -1,4 +1,4 @@ -package cz.cuni.mff.xrg.odalic.tasks; +package cz.cuni.mff.xrg.odalic.tasks.executions; import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; @@ -8,7 +8,7 @@ @XmlEnum(Integer.class) public enum State { @XmlEnumValue("1") READY, - @XmlEnumValue("2") RUNNING, - @XmlEnumValue("3") CANCELED, + @XmlEnumValue("2") SCHEDULED, + @XmlEnumValue("3") CANCELLED, @XmlEnumValue("4") FINISHED } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/FeedbackService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/FeedbackService.java new file mode 100644 index 00000000..7322124f --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/FeedbackService.java @@ -0,0 +1,15 @@ +package cz.cuni.mff.xrg.odalic.tasks.feedbacks; + +import java.io.IOException; + +import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; +import cz.cuni.mff.xrg.odalic.feedbacks.input.Input; + +public interface FeedbackService { + + Feedback getForTaskId(String taskId); + + void setForTaskId(String taskId, Feedback feedback); + + Input getInputForTaskId(String id) throws IOException; +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/MemoryOnlyFeedbackService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/MemoryOnlyFeedbackService.java new file mode 100644 index 00000000..f499eb21 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/MemoryOnlyFeedbackService.java @@ -0,0 +1,59 @@ +package cz.cuni.mff.xrg.odalic.tasks.feedbacks; + +import java.io.IOException; + +import org.springframework.beans.factory.annotation.Autowired; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; +import cz.cuni.mff.xrg.odalic.feedbacks.input.Input; +import cz.cuni.mff.xrg.odalic.feedbacks.input.InputParser; +import cz.cuni.mff.xrg.odalic.files.File; +import cz.cuni.mff.xrg.odalic.files.FileService; +import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; +import cz.cuni.mff.xrg.odalic.tasks.configurations.ConfigurationService; + +/** + * @author Václav Brodec + * + */ +public final class MemoryOnlyFeedbackService implements FeedbackService { + + private final ConfigurationService configurationService; + private final FileService fileService; + private final InputParser inputParser; + + @Autowired + public MemoryOnlyFeedbackService(ConfigurationService configurationService, FileService fileService, InputParser inputParser) { + Preconditions.checkNotNull(configurationService); + Preconditions.checkNotNull(fileService); + Preconditions.checkNotNull(inputParser); + + this.configurationService = configurationService; + this.fileService = fileService; + this.inputParser = inputParser; + } + + @Override + public Feedback getForTaskId(String taskId) { + final Configuration configuration = configurationService.getForTaskId(taskId); + + return configuration.getFeedback(); + } + + @Override + public void setForTaskId(String taskId, Feedback feedback) { + final Configuration oldConfiguration = configurationService.getForTaskId(taskId); + configurationService.setForTaskId(taskId, new Configuration(oldConfiguration.getInput(), feedback)); + } + + @Override + public Input getInputForTaskId(String taskId) throws IOException { + final Configuration configuration = configurationService.getForTaskId(taskId); + final File file = configuration.getInput(); + final String data = fileService.getDataById(file.getId()); + + return inputParser.parse(data); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/AnnotationToResultAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/AnnotationToResultAdapter.java new file mode 100644 index 00000000..6e1c24e4 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/AnnotationToResultAdapter.java @@ -0,0 +1,7 @@ +package cz.cuni.mff.xrg.odalic.tasks.results; + +import uk.ac.shef.dcs.sti.core.model.TAnnotation; + +public interface AnnotationToResultAdapter { + Result toResult(TAnnotation annotation); +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/DefaultAnnotationToResultAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/DefaultAnnotationToResultAdapter.java new file mode 100644 index 00000000..d63e8e77 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/DefaultAnnotationToResultAdapter.java @@ -0,0 +1,13 @@ +package cz.cuni.mff.xrg.odalic.tasks.results; + +import uk.ac.shef.dcs.sti.core.model.TAnnotation; + +public class DefaultAnnotationToResultAdapter implements AnnotationToResultAdapter { + + @Override + public Result toResult(TAnnotation annotation) { + // TODO Missing implementation. + return null; + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/Result.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/Result.java index 2041e133..98f5cdc9 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/Result.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/Result.java @@ -1,12 +1,222 @@ package cz.cuni.mff.xrg.odalic.tasks.results; import java.io.Serializable; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -@XmlRootElement +import org.apache.jena.ext.com.google.common.collect.ImmutableMap; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import cz.cuni.mff.xrg.odalic.positions.CellRelationPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.HeaderAnnotation; + +@XmlRootElement(name = "result") public class Result implements Serializable { private static final long serialVersionUID = -6359038623760039155L; + @XmlElement + private final ColumnPosition subjectColumnPosition; + + @XmlElement + private final List headerAnnotations; + + @XmlElement + private final CellAnnotation[][] cellAnnotations; + + @XmlElement + private final Map columnRelationAnnotations; + + @XmlElement + private final Map cellRelationAnnotations; + + @SuppressWarnings("unused") + private Result() { + subjectColumnPosition = null; + headerAnnotations = ImmutableList.of(); + cellAnnotations = new CellAnnotation[0][0];; + columnRelationAnnotations = ImmutableMap.of(); + cellRelationAnnotations = ImmutableMap.of(); + } + /** + * @param subjectColumnPosition + * @param headerAnnotations + * @param cellAnnotations + * @param columnRelationAnnotations + * @param cellRelationAnnotations + */ + public Result(List headerAnnotations, + CellAnnotation[][] cellAnnotations, + Map columnRelationAnnotations, + Map cellRelationAnnotations) { + checkMandatory(headerAnnotations, cellAnnotations, columnRelationAnnotations, + cellRelationAnnotations); + + this.subjectColumnPosition = null; + this.headerAnnotations = ImmutableList.copyOf(headerAnnotations); + this.cellAnnotations = cz.cuni.mff.xrg.odalic.util.Arrays.deepCopy(CellAnnotation.class, cellAnnotations); + this.columnRelationAnnotations = ImmutableMap.copyOf(columnRelationAnnotations); + this.cellRelationAnnotations = ImmutableMap.copyOf(cellRelationAnnotations); + } + + private static void checkMandatory(List headerAnnotations, + CellAnnotation[][] cellAnnotations, + Map columnRelationAnnotations, + Map cellRelationAnnotations) { + checkMandatory(headerAnnotations, cellAnnotations, columnRelationAnnotations, + cellRelationAnnotations); + + Preconditions.checkArgument(!cz.cuni.mff.xrg.odalic.util.Arrays.containsNull(cellAnnotations)); + Preconditions.checkArgument(cz.cuni.mff.xrg.odalic.util.Arrays.isMatrix(cellAnnotations)); + } + + /** + * @param subjectColumnPosition + * @param headerAnnotations + * @param cellAnnotations + * @param columnRelationAnnotations + * @param cellRelationAnnotations + */ + public Result(ColumnPosition subjectColumnPosition, + List headerAnnotations, + CellAnnotation[][] cellAnnotations, + Map columnRelationAnnotations, + Map cellRelationAnnotations) { + Preconditions.checkNotNull(subjectColumnPosition); + checkMandatory(headerAnnotations, cellAnnotations, columnRelationAnnotations, + cellRelationAnnotations); + + this.subjectColumnPosition = subjectColumnPosition; + this.headerAnnotations = ImmutableList.copyOf(headerAnnotations); + this.cellAnnotations = cz.cuni.mff.xrg.odalic.util.Arrays.deepCopy(CellAnnotation.class, cellAnnotations); + this.columnRelationAnnotations = ImmutableMap.copyOf(columnRelationAnnotations); + this.cellRelationAnnotations = ImmutableMap.copyOf(cellRelationAnnotations); + } + + /** + * @return the subjectColumnPosition + */ + @Nullable + public ColumnPosition getSubjectColumnPosition() { + return subjectColumnPosition; + } + + /** + * @return the headerAnnotations + */ + public List getHeaderAnnotations() { + return headerAnnotations; + } + + /** + * @return the cellAnnotations + */ + public CellAnnotation[][] getCellAnnotations() { + return cz.cuni.mff.xrg.odalic.util.Arrays.deepCopy(CellAnnotation.class, cellAnnotations); + } + + /** + * @return the columnRelationAnnotations + */ + public Map getColumnRelationAnnotations() { + return columnRelationAnnotations; + } + + /** + * @return the cellRelationAnnotations + */ + public Map getCellRelationAnnotations() { + return cellRelationAnnotations; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + Arrays.deepHashCode(cellAnnotations); + result = prime * result + + ((cellRelationAnnotations == null) ? 0 : cellRelationAnnotations.hashCode()); + result = prime * result + + ((columnRelationAnnotations == null) ? 0 : columnRelationAnnotations.hashCode()); + result = prime * result + ((headerAnnotations == null) ? 0 : headerAnnotations.hashCode()); + result = + prime * result + ((subjectColumnPosition == null) ? 0 : subjectColumnPosition.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Result other = (Result) obj; + if (!Arrays.deepEquals(cellAnnotations, other.cellAnnotations)) { + return false; + } + if (cellRelationAnnotations == null) { + if (other.cellRelationAnnotations != null) { + return false; + } + } else if (!cellRelationAnnotations.equals(other.cellRelationAnnotations)) { + return false; + } + if (columnRelationAnnotations == null) { + if (other.columnRelationAnnotations != null) { + return false; + } + } else if (!columnRelationAnnotations.equals(other.columnRelationAnnotations)) { + return false; + } + if (headerAnnotations == null) { + if (other.headerAnnotations != null) { + return false; + } + } else if (!headerAnnotations.equals(other.headerAnnotations)) { + return false; + } + if (subjectColumnPosition == null) { + if (other.subjectColumnPosition != null) { + return false; + } + } else if (!subjectColumnPosition.equals(other.subjectColumnPosition)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Result [subjectColumnPosition=" + subjectColumnPosition + ", headerAnnotations=" + + headerAnnotations + ", cellAnnotations=" + Arrays.deepToString(cellAnnotations) + + ", columnRelationAnnotations=" + columnRelationAnnotations + ", cellRelationAnnotations=" + + cellRelationAnnotations + "]"; + } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultService.java deleted file mode 100644 index 8e73a684..00000000 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultService.java +++ /dev/null @@ -1,7 +0,0 @@ -package cz.cuni.mff.xrg.odalic.tasks.results; - -public interface ResultService { - - - -} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultServiceImpl.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultServiceImpl.java deleted file mode 100644 index 408219ce..00000000 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/ResultServiceImpl.java +++ /dev/null @@ -1,10 +0,0 @@ -/** - * - */ -package cz.cuni.mff.xrg.odalic.tasks.results; - -/** - * @author Václav Brodec - * - */ -public final class ResultServiceImpl implements ResultService {} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/Arrays.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/Arrays.java new file mode 100644 index 00000000..f29ab998 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/Arrays.java @@ -0,0 +1,61 @@ +package cz.cuni.mff.xrg.odalic.util; + +import java.lang.reflect.Array; + +public class Arrays { + private Arrays() {} + + /** + * @param arrayOfArrays + * @return + */ + public static boolean containsNull(Object[][] arrayOfArrays) { + for (int i = 0; i < arrayOfArrays.length; i++) { + if (arrayOfArrays[i] == null) { + return true; + } + + for (int j = 0; j < arrayOfArrays[i].length; j++) { + if (arrayOfArrays[i][j] == null) { + return true; + } + } + } + + return false; + } + + /** + * @param matrix + * @return + */ + public static boolean isMatrix(Object[][] matrix) { + for (int i = 0; i < matrix.length; i++) { + if (matrix[i].length != matrix.length) { + return false; + } + } + + return true; + } + + /** + * @param type + * @param matrix + * @return + */ + public static T[][] deepCopy(Class type, T[][] matrix) { + final int rows = matrix.length; + final int columns = (rows > 0) ? (matrix[0].length) : 0; + + @SuppressWarnings("unchecked") + T[][] copy = (T[][]) Array.newInstance(type, rows, columns); + for(int i = 0; i < matrix.length; i++) { + copy[i] = matrix[i].clone(); + } + + return copy; + } + + +} diff --git a/odalic/src/main/resources/spring/applicationContext.xml b/odalic/src/main/resources/spring/applicationContext.xml index 351d4926..6031a362 100644 --- a/odalic/src/main/resources/spring/applicationContext.xml +++ b/odalic/src/main/resources/spring/applicationContext.xml @@ -14,12 +14,16 @@ + + + + - - + - - + + + diff --git a/odalic/src/main/webapp/WEB-INF/web.xml b/odalic/src/main/webapp/WEB-INF/web.xml index c42a748b..6b19bb97 100644 --- a/odalic/src/main/webapp/WEB-INF/web.xml +++ b/odalic/src/main/webapp/WEB-INF/web.xml @@ -20,6 +20,10 @@ org.glassfish.jersey.servlet.ServletContainer + + com.sun.jersey.api.json.POJOMappingFeature + true + javax.ws.rs.Application cz.cuni.mff.xrg.odalic.api.rest.Configuration @@ -31,4 +35,6 @@ jersey-servlet /* + + \ No newline at end of file From 083f0cef93ff67780c30ff21dc26cc18d70c00d6 Mon Sep 17 00:00:00 2001 From: Josef Janousek Date: Sun, 26 Jun 2016 19:29:54 +0200 Subject: [PATCH 026/211] Factory class for providing TMPInterpreter instance --- .../FutureBasedExecutionService.java | 5 +- .../tasks/executions/InterpreterFactory.java | 313 ++++++++++++++++++ 2 files changed, 316 insertions(+), 2 deletions(-) create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterFactory.java diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java index abe954aa..037d456c 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java @@ -41,7 +41,7 @@ public final class FutureBasedExecutionService implements ExecutionService { private final Map> tasksToResults = new HashMap<>(); // TODO: Initialize, but verify whether per submit instantiation is not necessary. Provide as injected bean then. - private final SemanticTableInterpreter semanticTableInterpreter = null; + private final SemanticTableInterpreter semanticTableInterpreter = InterpreterFactory.getInterpreter(); //TODO: This dependency should be made explicit and more reliable. private final TableXtractorCSV tableExtractor = new TableXtractorCSV(); @@ -50,7 +50,8 @@ public final class FutureBasedExecutionService implements ExecutionService { public FutureBasedExecutionService(TaskService taskService, AnnotationToResultAdapter annotationToResultAdapter) { Preconditions.checkNotNull(taskService); - //TODO: When set, uncomment this: Preconditions.checkNotNull(semanticTableInterpreter); + + Preconditions.checkNotNull(semanticTableInterpreter); this.taskService = taskService; this.annotationResultAdapter = annotationToResultAdapter; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterFactory.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterFactory.java new file mode 100644 index 00000000..5f3490e0 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterFactory.java @@ -0,0 +1,313 @@ +package cz.cuni.mff.xrg.odalic.tasks.executions; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.nio.file.Paths; +import java.util.List; +import java.util.Properties; + +import org.apache.commons.lang.exception.ExceptionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; +import org.apache.solr.core.CoreContainer; +import org.simmetrics.metrics.StringMetrics; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import uk.ac.shef.dcs.kbsearch.KBSearch; +import uk.ac.shef.dcs.kbsearch.KBSearchFactory; +import uk.ac.shef.dcs.sti.STIConstantProperty; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.algorithm.SemanticTableInterpreter; +import uk.ac.shef.dcs.sti.core.algorithm.tmp.*; +import uk.ac.shef.dcs.sti.core.algorithm.tmp.scorer.TMPClazzScorer; +import uk.ac.shef.dcs.sti.core.algorithm.tmp.scorer.TMPEntityScorer; +import uk.ac.shef.dcs.sti.core.algorithm.tmp.scorer.TMPRelationScorer; +import uk.ac.shef.dcs.sti.core.feature.FreebaseConceptBoWCreator; +import uk.ac.shef.dcs.sti.core.feature.FreebaseRelationBoWCreator; +import uk.ac.shef.dcs.sti.core.scorer.AttributeValueMatcher; +import uk.ac.shef.dcs.sti.core.scorer.RelationScorer; +import uk.ac.shef.dcs.sti.core.algorithm.tmp.sampler.OSPD_nonEmpty; +import uk.ac.shef.dcs.sti.core.algorithm.tmp.sampler.TContentCellRanker; +import uk.ac.shef.dcs.sti.core.algorithm.tmp.sampler.TContentTContentRowRankerImpl; +import uk.ac.shef.dcs.sti.core.subjectcol.SubjectColumnDetector; +import uk.ac.shef.dcs.sti.util.FileUtils; + +public class InterpreterFactory { + + private static final Logger LOG = LoggerFactory.getLogger(InterpreterFactory.class); + + //TODO: Write your own path to the property file. + protected static final String PROPERTYFILE = "C:\\Users\\Acer\\git\\sti\\sti.properties"; + + protected static KBSearch kbSearch; + + protected static SemanticTableInterpreter interpreter; + + protected static final String PROPERTY_HOME = "sti.home"; + protected static final String PROPERTY_WEBSEARCH_PROP_FILE = "sti.websearch.properties"; + protected static final String PROPERTY_NLP_RESOURCES = "sti.nlp"; + protected static final String PROPERTY_KBSEARCH_PROP_FILE = "sti.kbsearch.propertyfile"; + protected static final String PROPERTY_CACHE_FOLDER = "sti.cache.main.dir"; + + private static final String PROPERTY_ENTITY_CACHE_CORENAME = "entity"; + private static final String PROPERTY_RELATION_CACHE_CORENAME = "relation"; + private static final String PROPERTY_WEBSEARCH_CACHE_CORENAME = "websearch"; + + protected static final String PROPERTY_IGNORE_COLUMNS = "sti.columns.ignore"; + protected static final String PROPERTY_MUSTDO_COLUMNS = "sti.columns.mustdo"; + + protected static final String PROPERTY_TMP_SUBJECT_COLUMN_DETECTION_USE_WEBSEARCH = + "sti.subjectcolumndetection.ws"; + protected static final String PROPERTY_TMP_IINF_WEBSEARCH_STOPPING_CLASS = "sti.iinf.websearch.stopping.class"; + protected static final String PROPERTY_TMP_IINF_WEBSEARCH_STOPPING_CLASS_CONSTR_PARAM = + "sti.iinf.websearch.stopping.class.constructor.params"; + + protected static final String PROPERTY_TMP_IINF_LEARNING_STOPPING_CLASS = "sti.tmp.iinf.learning.stopping.class"; + protected static final String PROPERTY_TMP_IINF_LEARNING_STOPPING_CLASS_CONSTR_PARAM = + "sti.tmp.iinf.learning.stopping.class.constructor.params"; + + protected static Properties properties; + + protected static CoreContainer cores; + private static EmbeddedSolrServer entityCache; + private static EmbeddedSolrServer websearchCache; + + public static SemanticTableInterpreter getInterpreter() { + if (interpreter == null) { + try { + initComponents(); + } catch (STIException | IOException e) { + e.printStackTrace(); + } + } + return interpreter; + } + + //Initialize kbsearcher, websearcher + protected static void initComponents() throws STIException, IOException { + properties = new Properties(); + properties.load(new FileInputStream(PROPERTYFILE)); + + LOG.info("Initializing entity cache..."); + EmbeddedSolrServer kbEntityServer = getSolrServerCacheEntity(); + //object to fetch things from KB + + LOG.info("Initializing KBSearch..."); + KBSearchFactory fbf = new KBSearchFactory(); + try { + kbSearch = fbf.createInstance( + getAbsolutePath(PROPERTY_KBSEARCH_PROP_FILE), + kbEntityServer, null, null,null); + } catch (Exception e) { + e.printStackTrace(); + LOG.error(ExceptionUtils.getFullStackTrace(e)); + throw new STIException("Failed initialising KBSearch:" + + getAbsolutePath(PROPERTY_KBSEARCH_PROP_FILE) + , e); + } + + //LOG.info("Initializing WebSearcher..."); + + + LOG.info("Initializing SUBJECT COLUMN DETECTION components ..."); + SubjectColumnDetector subcolDetector; + try { + subcolDetector = new SubjectColumnDetector( + new TContentTContentRowRankerImpl(), + properties.getProperty(PROPERTY_TMP_IINF_WEBSEARCH_STOPPING_CLASS), + StringUtils.split(properties.getProperty(PROPERTY_TMP_IINF_WEBSEARCH_STOPPING_CLASS_CONSTR_PARAM), + ','), + //new String[]{"0.0", "1", "0.01"}, + getSolrServerCacheWebsearch(), + getNLPResourcesDir(), + Boolean.valueOf(properties.getProperty(PROPERTY_TMP_SUBJECT_COLUMN_DETECTION_USE_WEBSEARCH)), + //"/BlhLSReljQ3Koh+vDSOaYMji9/Ccwe/7/b9mGJLwDQ="); //zqz.work + //"fXhmgvVQnz1aLBti87+AZlPYDXcQL0G9L2dVAav+aK0="); //ziqizhang + getStopwords(), + getAbsolutePath(PROPERTY_WEBSEARCH_PROP_FILE) + //, lodie + //"7ql9acl+fXXfdjBGIIAH+N2WHk/dIZxdSkl4Uur68Hg" + );// dobs + } catch (Exception e) { + e.printStackTrace(); + LOG.error(ExceptionUtils.getFullStackTrace(e)); + throw new STIException("Failed initialising SUBJECT COLUMN DETECTION components:" + properties.getProperty(PROPERTY_WEBSEARCH_PROP_FILE) + , e); + } + + + LOG.info("Initializing LEARNING components ..."); + LEARNINGPreliminaryColumnClassifier preliminaryClassify; + TCellDisambiguator disambiguator; + TColumnClassifier classifier; + TContentCellRanker selector; + LEARNING learning; + try { + disambiguator = new TCellDisambiguator(kbSearch, + new TMPEntityScorer( + getStopwords(), + STIConstantProperty.SCORER_ENTITY_CONTEXT_WEIGHT, //row,column, column header, tablecontext all + getNLPResourcesDir())); + classifier = new TColumnClassifier(new TMPClazzScorer(getNLPResourcesDir(), + new FreebaseConceptBoWCreator(), + getStopwords(), + STIConstantProperty.SCORER_CLAZZ_CONTEXT_WEIGHT) //all 1.0 + ); //header,column,out trivial, out important + selector = new OSPD_nonEmpty(); + preliminaryClassify = new LEARNINGPreliminaryColumnClassifier( + selector, + properties.getProperty(PROPERTY_TMP_IINF_LEARNING_STOPPING_CLASS), + StringUtils.split( + properties.getProperty(PROPERTY_TMP_IINF_LEARNING_STOPPING_CLASS_CONSTR_PARAM), + ','), + kbSearch, + disambiguator, + classifier + ); + LEARNINGPreliminaryDisamb preliminaryDisamb = new LEARNINGPreliminaryDisamb( + kbSearch, disambiguator, classifier + ); + + learning = new LEARNING( + preliminaryClassify, preliminaryDisamb); + } catch (Exception e) { + e.printStackTrace(); + LOG.error(ExceptionUtils.getFullStackTrace(e)); + throw new STIException("Failed initialising LEARNING components:" + , e); + } + + + LOG.info("Initializing UPDATE components ..."); + UPDATE update; + try { + update = + new UPDATE(selector, kbSearch, disambiguator, classifier, getStopwords(), getNLPResourcesDir()); + } catch (Exception e) { + e.printStackTrace(); + LOG.error(ExceptionUtils.getFullStackTrace(e)); + throw new STIException("Failed initialising LEARNING components:" + , e); + } + + + LOG.info("Initializing RELATIONLEARNING components ..."); + RelationScorer relationScorer = null; + TColumnColumnRelationEnumerator relationEnumerator = null; + LiteralColumnTagger literalColumnTagger = null; + try { + //object to computeElementScores relations between columns + relationScorer = new TMPRelationScorer( + getNLPResourcesDir(), + new FreebaseRelationBoWCreator(), + getStopwords(), + STIConstantProperty.SCORER_RELATION_CONTEXT_WEIGHT + // new double[]{1.0, 1.0, 0.0, 0.0, 1.0} + ); + relationEnumerator = new TColumnColumnRelationEnumerator( + new AttributeValueMatcher( + STIConstantProperty.ATTRIBUTE_MATCHER_MIN_SCORE, getStopwords(), + StringMetrics.levenshtein()), + relationScorer + ); + + //object to consolidate previous output, further computeElementScores columns and disamgiuate entities + literalColumnTagger = + new LiteralColumnTaggerImpl( + getIgnoreColumns() + ); + } catch (Exception e) { + + } + + interpreter = new TMPInterpreter( + subcolDetector, + learning, + update, + relationEnumerator, + literalColumnTagger, + getIgnoreColumns(), getMustdoColumns() + ); + + } + + protected static EmbeddedSolrServer getSolrServerCacheEntity() throws STIException { + if (entityCache == null) { + String solrHomePath = properties.getProperty(PROPERTY_CACHE_FOLDER); + if (solrHomePath == null || !new File(solrHomePath).exists()) { + String error = "Cannot proceed: the cache dir is not set or does not exist. " + + PROPERTY_CACHE_FOLDER + "=" + solrHomePath; + LOG.error(error); + throw new STIException(error); + } + + if (cores == null) { + entityCache = new EmbeddedSolrServer(Paths.get(solrHomePath), PROPERTY_ENTITY_CACHE_CORENAME); + cores = entityCache.getCoreContainer(); + } else + entityCache = new EmbeddedSolrServer(cores.getCore(PROPERTY_ENTITY_CACHE_CORENAME)); + } + return entityCache; + } + + protected static EmbeddedSolrServer getSolrServerCacheWebsearch() throws STIException { + if (websearchCache == null) { + String solrHomePath = properties.getProperty(PROPERTY_CACHE_FOLDER); + if (solrHomePath == null || !new File(solrHomePath).exists() || PROPERTY_RELATION_CACHE_CORENAME == null) { + String error = "Cannot proceed: the cache dir is not set or does not exist. " + + PROPERTY_CACHE_FOLDER + "=" + solrHomePath; + LOG.error(error); + throw new STIException(error); + } + if (cores == null) { + websearchCache = new EmbeddedSolrServer(Paths.get(solrHomePath), PROPERTY_WEBSEARCH_CACHE_CORENAME); + cores = websearchCache.getCoreContainer(); + } else + websearchCache = new EmbeddedSolrServer(cores.getCore(PROPERTY_WEBSEARCH_CACHE_CORENAME)); + } + return websearchCache; + } + + protected static String getNLPResourcesDir() throws STIException { + String prop = getAbsolutePath(PROPERTY_NLP_RESOURCES); + if (prop == null || !new File(prop).exists()) { + String error = "Cannot proceed: nlp resources folder is not set or does not exist. " + + PROPERTY_KBSEARCH_PROP_FILE + "=" + prop; + LOG.error(error); + throw new STIException(error); + } + return prop; + } + + protected static List getStopwords() throws STIException, IOException { + return FileUtils.readList(getNLPResourcesDir() + File.separator + "stoplist.txt", true); + } + + protected static String getAbsolutePath(String propertyName) { + return properties.getProperty(PROPERTY_HOME) + + File.separator + properties.getProperty(propertyName); + } + + protected static int[] getIgnoreColumns() { + String ignore = properties.getProperty(PROPERTY_IGNORE_COLUMNS); + String[] splits = StringUtils.split(ignore, ','); + int[] res = new int[splits.length]; + for (int i = 0; i < splits.length; i++) { + res[i] = Integer.valueOf(splits[i].trim()); + } + return res; + } + + protected static int[] getMustdoColumns() { + String ignore = properties.getProperty(PROPERTY_MUSTDO_COLUMNS); + String[] splits = StringUtils.split(ignore, ','); + int[] res = new int[0]; + for (int i = 0; i < splits.length; i++) { + res[i] = Integer.valueOf(splits[i].trim()); + } + return res; + } + +} From d3f415cb26f7af286fbf5a0b2de9f5531e1edf91 Mon Sep 17 00:00:00 2001 From: brodecva Date: Mon, 27 Jun 2016 19:29:16 +0200 Subject: [PATCH 027/211] Minor API fixes. --- .travis.yml | 8 ++++---- .../api/rest/adapters/ConfigurationAdapter.java | 12 +++++++++++- .../rest/conversions/CustomJsonDateSerializer.java | 2 +- .../odalic/api/rest/resources/ResultResource.java | 4 ++-- .../odalic/api/rest/values/ConfigurationValue.java | 9 ++++----- .../odalic/tasks/configurations/Configuration.java | 5 ++++- .../cuni/mff/xrg/odalic/tasks/executions/State.java | 4 +++- 7 files changed, 29 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index ac187a03..313e5769 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -## Travis build file - -language: java -before_script: cd odalic +## Travis build file + +language: java +before_script: cd odalic diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ConfigurationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ConfigurationAdapter.java index 1b8147a5..4c77323a 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ConfigurationAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ConfigurationAdapter.java @@ -2,12 +2,22 @@ import javax.xml.bind.annotation.adapters.XmlAdapter; +import org.springframework.beans.factory.annotation.Autowired; + import cz.cuni.mff.xrg.odalic.api.rest.values.ConfigurationValue; +import cz.cuni.mff.xrg.odalic.files.FileService; import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; public class ConfigurationAdapter extends XmlAdapter { + private final FileService fileService; + + @Autowired + public ConfigurationAdapter(FileService fileService) { + this.fileService = fileService; + } + @Override public ConfigurationValue marshal(Configuration bound) throws Exception { return new ConfigurationValue(bound); @@ -15,6 +25,6 @@ public ConfigurationValue marshal(Configuration bound) throws Exception { @Override public Configuration unmarshal(ConfigurationValue value) throws Exception { - return new Configuration(value.getInput(), value.getFeedback()); + return new Configuration(fileService.getById(value.getInput()), value.getFeedback()); } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateSerializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateSerializer.java index 9b591a0b..a95dacbe 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateSerializer.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateSerializer.java @@ -11,7 +11,7 @@ public class CustomJsonDateSerializer extends JsonSerializer { - public static final String DATE_FORMAT = "dd-MM-yyyy HH:mm"; + public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm"; @Override public void serialize(Date value, JsonGenerator jgen, diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ResultResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ResultResource.java index bae62eb0..36d491c7 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ResultResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ResultResource.java @@ -23,8 +23,8 @@ public class ResultResource { @GET @Produces(MediaType.APPLICATION_JSON) public Response getResult(@PathParam("id") String taskId) throws InterruptedException, ExecutionException { - if (!executionService.isDoneForTaskId(taskId) || executionService.isCancelledForTaskId(taskId)) { - return Response.status(Response.Status.NO_CONTENT).entity("The result is not ready.") + if (executionService.isCancelledForTaskId(taskId)) { + return Response.status(Response.Status.NOT_FOUND).entity("The execution was cancelled.") .build(); } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java index ff57d5f8..355b9c65 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java @@ -9,7 +9,6 @@ import com.google.common.base.Preconditions; import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; -import cz.cuni.mff.xrg.odalic.files.File; import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; @XmlRootElement(name = "configuration") @@ -18,7 +17,7 @@ public class ConfigurationValue implements Serializable { private static final long serialVersionUID = -6359038623760039155L; @XmlElement(name = "input") - private File input; + private String input; @XmlElement(name = "feedback") private Feedback feedback; @@ -29,7 +28,7 @@ public ConfigurationValue() { } public ConfigurationValue(Configuration adaptee) { - input = adaptee.getInput(); + input = adaptee.getInput().getId(); feedback = adaptee.getFeedback(); } @@ -37,14 +36,14 @@ public ConfigurationValue(Configuration adaptee) { * @return the input */ @Nullable - public File getInput() { + public String getInput() { return input; } /** * @param input the input to set */ - public void setInput(File input) { + public void setInput(String input) { Preconditions.checkNotNull(input); this.input = input; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java index a450b49b..93dbbb4c 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java @@ -3,19 +3,22 @@ import java.io.Serializable; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import com.google.common.base.Preconditions; +import cz.cuni.mff.xrg.odalic.api.rest.adapters.ConfigurationAdapter; import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; import cz.cuni.mff.xrg.odalic.files.File; +@XmlJavaTypeAdapter(ConfigurationAdapter.class) @XmlRootElement(name = "configuration") public class Configuration implements Serializable { private static final long serialVersionUID = -6359038623760039155L; @XmlElement(name = "input") - private final File input; + private final File input; @XmlElement(name = "feedback") private final Feedback feedback; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/State.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/State.java index 10fdbca7..9c17f999 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/State.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/State.java @@ -2,10 +2,12 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; +import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; @XmlType -@XmlEnum(Integer.class) +@XmlEnum(String.class) +@XmlRootElement public enum State { @XmlEnumValue("1") READY, @XmlEnumValue("2") SCHEDULED, From 2bb2c92c8396dd647338ce0cdbbf6702e9daac11 Mon Sep 17 00:00:00 2001 From: Josef Janousek Date: Mon, 27 Jun 2016 23:05:59 +0200 Subject: [PATCH 028/211] Class for testing the execution of interpreter from Odalic project --- .../executions/InterpreterExecutionBatch.java | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 odalic/src/test/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterExecutionBatch.java diff --git a/odalic/src/test/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterExecutionBatch.java b/odalic/src/test/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterExecutionBatch.java new file mode 100644 index 00000000..2bd4c467 --- /dev/null +++ b/odalic/src/test/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterExecutionBatch.java @@ -0,0 +1,60 @@ +package cz.cuni.mff.xrg.odalic.tasks.executions; + +import java.io.File; +//import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.common.base.Preconditions; + +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.algorithm.SemanticTableInterpreter; +import uk.ac.shef.dcs.sti.core.model.TAnnotation; +import uk.ac.shef.dcs.sti.core.model.Table; +//import uk.ac.shef.dcs.sti.parser.table.TableParserLimayeDataset; +import uk.ac.shef.dcs.sti.xtractor.csv.TableXtractorCSV; + +public class InterpreterExecutionBatch { + + public static void main(String[] args) { + // for test of execution of semantic table interpreter from Odalic project + + SemanticTableInterpreter semanticTableInterpreter = InterpreterFactory.getInterpreter(); + Preconditions.checkNotNull(semanticTableInterpreter); + + //TODO: Write path of your own folder containing the input file + List all = Arrays.asList(new File("C:\\Users\\Acer\\data-odalic\\sti-data\\Limaye200\\my").listFiles()); + File inputFile = all.get(0); + + // code for extraction from CSV + TableXtractorCSV tableExtractor = new TableXtractorCSV(); + List
tables = tableExtractor.extract(inputFile, inputFile.getName()); + + // code for extraction from LimayeDataset + /*TableParserLimayeDataset tableExtractor = new TableParserLimayeDataset(); + List
tables; + try { + tables = tableExtractor.extract(inputFile.toString(), inputFile.toString()); + } catch (STIException e1) { + e1.printStackTrace(); + tables = new ArrayList<>(); + }*/ + + if (tables.isEmpty()) { + throw new IllegalArgumentException(); + } + + TAnnotation annotationResult; + try { + annotationResult = semanticTableInterpreter.start(tables.get(0), true); + + System.out.println("Vsledek - OK:"); + System.out.println(annotationResult.toString()); + } catch (STIException e) { + System.out.println("Vsledek - Chyba:"); + e.printStackTrace(); + } + System.out.println("Konec vsledku."); + } + +} From a7ce56694a594e45d1efbd39495c3ed934cea7ce Mon Sep 17 00:00:00 2001 From: Josef Janousek Date: Tue, 28 Jun 2016 02:36:45 +0200 Subject: [PATCH 029/211] Add method for setting IgnoreColumns to SemanticTableInterpreter and LiteralColumnTagger --- .../shef/dcs/sti/core/algorithm/SemanticTableInterpreter.java | 4 ++++ .../shef/dcs/sti/core/algorithm/tmp/LiteralColumnTagger.java | 2 ++ .../dcs/sti/core/algorithm/tmp/LiteralColumnTaggerImpl.java | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/SemanticTableInterpreter.java b/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/SemanticTableInterpreter.java index 24c2e2a5..76ec2c5e 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/SemanticTableInterpreter.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/SemanticTableInterpreter.java @@ -44,6 +44,10 @@ protected boolean isCompulsoryColumn(Integer i) { protected Set getIgnoreColumns(){ return ignoreCols; } + + public void setIgnoreColumns(Set ignoreCols) { + this.ignoreCols = ignoreCols; + } protected Set getMustdoColumns() {return mustdoColumns;} } diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTagger.java b/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTagger.java index bb173616..6b2c752b 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTagger.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTagger.java @@ -8,4 +8,6 @@ */ public interface LiteralColumnTagger { void annotate(Table table, TAnnotation annotations, Integer... enColumnIndexes) throws KBSearchException; + + void setIgnoreColumns(int... ignoreCols); } diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTaggerImpl.java b/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTaggerImpl.java index eca812cc..1c89316c 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTaggerImpl.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTaggerImpl.java @@ -20,6 +20,10 @@ public LiteralColumnTaggerImpl( this.ignoreColumns = ignoreColumns; } + + public void setIgnoreColumns(int... ignoreCols) { + this.ignoreColumns = ignoreCols; + } public void annotate(Table table, TAnnotation annotations, Integer... neColumns) throws KBSearchException { //for each column that has a relation with the subject column, infer its type From cd54afa901e9dd0ff3dc030de51bc4ed7d4abbf7 Mon Sep 17 00:00:00 2001 From: Josef Janousek Date: Tue, 28 Jun 2016 02:54:02 +0200 Subject: [PATCH 030/211] Add support for setting of IgnoreColumns for interpreter from Execution service --- .../FutureBasedExecutionService.java | 11 ++++++++ .../tasks/executions/InterpreterFactory.java | 25 +++++++++++++------ .../executions/InterpreterExecutionBatch.java | 5 ++-- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java index 037d456c..92bd0127 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java @@ -8,6 +8,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; @@ -18,6 +19,7 @@ import com.google.common.base.Preconditions; +import cz.cuni.mff.xrg.odalic.feedbacks.ColumnIgnore; import cz.cuni.mff.xrg.odalic.files.File; import cz.cuni.mff.xrg.odalic.tasks.Task; import cz.cuni.mff.xrg.odalic.tasks.TaskService; @@ -73,6 +75,15 @@ public void submitForTaskId(String id) { final URL fileLocation = file.getLocation(); final java.io.File inputFile = urlToFile(fileLocation); + final Set columnIgnores = configuration.getFeedback().getColumnIgnores(); + Integer[] ignoreCols = new Integer[columnIgnores.size()]; + int i = 0; + for (ColumnIgnore col : columnIgnores) { + ignoreCols[i] = col.getPosition().getIndex(); + i++; + } + InterpreterFactory.setIgnoreColumnsForInterpreter(ignoreCols); + final Callable execution = () -> { final List
tables = tableExtractor.extract(inputFile, inputFile.getName()); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterFactory.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterFactory.java index 5f3490e0..4450ce30 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterFactory.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterFactory.java @@ -4,10 +4,13 @@ import java.io.FileInputStream; import java.io.IOException; import java.nio.file.Paths; +import java.util.Arrays; +import java.util.HashSet; import java.util.List; import java.util.Properties; import org.apache.commons.lang.exception.ExceptionUtils; +import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; import org.apache.solr.core.CoreContainer; @@ -39,12 +42,13 @@ public class InterpreterFactory { private static final Logger LOG = LoggerFactory.getLogger(InterpreterFactory.class); //TODO: Write your own path to the property file. - protected static final String PROPERTYFILE = "C:\\Users\\Acer\\git\\sti\\sti.properties"; - - protected static KBSearch kbSearch; + protected static final String PROPERTYFILE = "/Users/-/work/sti/sti.properties"; protected static SemanticTableInterpreter interpreter; + protected static KBSearch kbSearch; + protected static LiteralColumnTagger literalColumnTagger; + protected static final String PROPERTY_HOME = "sti.home"; protected static final String PROPERTY_WEBSEARCH_PROP_FILE = "sti.websearch.properties"; protected static final String PROPERTY_NLP_RESOURCES = "sti.nlp"; @@ -84,6 +88,11 @@ public static SemanticTableInterpreter getInterpreter() { } return interpreter; } + + public static void setIgnoreColumnsForInterpreter(Integer[] ignoreCols) { + interpreter.setIgnoreColumns(new HashSet(Arrays.asList(ignoreCols))); + literalColumnTagger.setIgnoreColumns(ArrayUtils.toPrimitive(ignoreCols)); + } //Initialize kbsearcher, websearcher protected static void initComponents() throws STIException, IOException { @@ -148,13 +157,13 @@ protected static void initComponents() throws STIException, IOException { disambiguator = new TCellDisambiguator(kbSearch, new TMPEntityScorer( getStopwords(), - STIConstantProperty.SCORER_ENTITY_CONTEXT_WEIGHT, //row,column, column header, tablecontext all + STIConstantProperty.SCORER_ENTITY_CONTEXT_WEIGHT, //row, column, column header, tablecontext all getNLPResourcesDir())); classifier = new TColumnClassifier(new TMPClazzScorer(getNLPResourcesDir(), new FreebaseConceptBoWCreator(), getStopwords(), - STIConstantProperty.SCORER_CLAZZ_CONTEXT_WEIGHT) //all 1.0 - ); //header,column,out trivial, out important + STIConstantProperty.SCORER_CLAZZ_CONTEXT_WEIGHT) //all 1.0 + ); //header, column, out trivial, out important selector = new OSPD_nonEmpty(); preliminaryClassify = new LEARNINGPreliminaryColumnClassifier( selector, @@ -196,7 +205,7 @@ protected static void initComponents() throws STIException, IOException { LOG.info("Initializing RELATIONLEARNING components ..."); RelationScorer relationScorer = null; TColumnColumnRelationEnumerator relationEnumerator = null; - LiteralColumnTagger literalColumnTagger = null; + try { //object to computeElementScores relations between columns relationScorer = new TMPRelationScorer( @@ -213,7 +222,7 @@ STIConstantProperty.ATTRIBUTE_MATCHER_MIN_SCORE, getStopwords(), relationScorer ); - //object to consolidate previous output, further computeElementScores columns and disamgiuate entities + //object to consolidate previous output, further computeElementScores columns and disambiguate entities literalColumnTagger = new LiteralColumnTaggerImpl( getIgnoreColumns() diff --git a/odalic/src/test/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterExecutionBatch.java b/odalic/src/test/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterExecutionBatch.java index 2bd4c467..c95de616 100644 --- a/odalic/src/test/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterExecutionBatch.java +++ b/odalic/src/test/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterExecutionBatch.java @@ -21,9 +21,10 @@ public static void main(String[] args) { SemanticTableInterpreter semanticTableInterpreter = InterpreterFactory.getInterpreter(); Preconditions.checkNotNull(semanticTableInterpreter); + InterpreterFactory.setIgnoreColumnsForInterpreter(new Integer[]{}); - //TODO: Write path of your own folder containing the input file - List all = Arrays.asList(new File("C:\\Users\\Acer\\data-odalic\\sti-data\\Limaye200\\my").listFiles()); + //TODO: Write your own path to the folder containing (only) the input file. + List all = Arrays.asList(new File("/Users/-/work/sti/sti_data/Limaye200").listFiles()); File inputFile = all.get(0); // code for extraction from CSV From 6fd5ec065fda8dbacc4a3681a19a60169fb3a615 Mon Sep 17 00:00:00 2001 From: brodecva Date: Wed, 29 Jun 2016 06:09:58 +0200 Subject: [PATCH 031/211] API output format change (index mapping changed to nested, chosen flag). --- .../rest/adapters/CellAnnotationAdapter.java | 38 +++- .../CellRelationAnnotationAdapter.java | 23 -- ...CellRelationRelationAnnotationAdapter.java | 47 ++++ .../ColumnRelationAnnotationAdapter.java | 38 +++- .../rest/adapters/EntityCandidateAdapter.java | 2 +- .../adapters/HeaderAnnotationAdapter.java | 38 +++- .../api/rest/adapters/ResultAdapter.java | 59 ++++++ .../api/rest/values/CellAnnotationValue.java | 66 +++--- .../values/CellRelationAnnotationValue.java | 66 +++--- .../values/ColumnRelationAnnotationValue.java | 66 +++--- .../api/rest/values/EntityCandidateValue.java | 28 ++- .../rest/values/HeaderAnnotationValue.java | 66 +++--- .../odalic/api/rest/values/ResultValue.java | 200 ++++++++++++++++++ .../tasks/annotations/EntityCandidate.java | 1 - .../mff/xrg/odalic/tasks/results/Result.java | 3 + 15 files changed, 521 insertions(+), 220 deletions(-) delete mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAnnotationAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationRelationAnnotationAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ResultAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ResultValue.java diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellAnnotationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellAnnotationAdapter.java index 34c86cb7..4e5f1cfe 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellAnnotationAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellAnnotationAdapter.java @@ -1,23 +1,47 @@ package cz.cuni.mff.xrg.odalic.api.rest.adapters; +import java.util.Map; +import java.util.NavigableSet; +import java.util.Set; + import javax.xml.bind.annotation.adapters.XmlAdapter; +import org.apache.jena.ext.com.google.common.collect.ImmutableSet; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSortedSet; + import cz.cuni.mff.xrg.odalic.api.rest.values.CellAnnotationValue; +import cz.cuni.mff.xrg.odalic.api.rest.values.EntityCandidateValue; import cz.cuni.mff.xrg.odalic.tasks.annotations.CellAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; -public class CellAnnotationAdapter - extends XmlAdapter { +public class CellAnnotationAdapter extends XmlAdapter { @Override - public CellAnnotationValue marshal(CellAnnotation bound) - throws Exception { + public CellAnnotationValue marshal(CellAnnotation bound) throws Exception { return new CellAnnotationValue(bound); } @Override - public CellAnnotation unmarshal(CellAnnotationValue value) - throws Exception { - return new CellAnnotation(value.getCandidates(), value.getChosen()); + public CellAnnotation unmarshal(CellAnnotationValue value) throws Exception { + final ImmutableMap.Builder> candidatesBuilder = + ImmutableMap.builder(); + final ImmutableMap.Builder> chosenBuilder = + ImmutableMap.builder(); + for (final Map.Entry> entry : value + .getCandidates().entrySet()) { + final KnowledgeBase base = entry.getKey(); + final Set values = entry.getValue(); + + candidatesBuilder.put(base, ImmutableSortedSet.copyOf(values.stream() + .map(e -> new EntityCandidate(e.getEntity(), e.getLikelihood())).iterator())); + chosenBuilder.put(base, ImmutableSet.copyOf(values.stream().filter(e -> e.isChosen()) + .map(e -> new EntityCandidate(e.getEntity(), e.getLikelihood())).iterator())); + } + + return new CellAnnotation(candidatesBuilder.build(), chosenBuilder.build()); } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAnnotationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAnnotationAdapter.java deleted file mode 100644 index fcaf4cfa..00000000 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAnnotationAdapter.java +++ /dev/null @@ -1,23 +0,0 @@ -package cz.cuni.mff.xrg.odalic.api.rest.adapters; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -import cz.cuni.mff.xrg.odalic.api.rest.values.CellRelationAnnotationValue; -import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; - - -public class CellRelationAnnotationAdapter - extends XmlAdapter { - - @Override - public CellRelationAnnotationValue marshal(CellRelationAnnotation bound) - throws Exception { - return new CellRelationAnnotationValue(bound); - } - - @Override - public CellRelationAnnotation unmarshal(CellRelationAnnotationValue value) - throws Exception { - return new CellRelationAnnotation(value.getCandidates(), value.getChosen()); - } -} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationRelationAnnotationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationRelationAnnotationAdapter.java new file mode 100644 index 00000000..8b98c122 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationRelationAnnotationAdapter.java @@ -0,0 +1,47 @@ +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import java.util.Map; +import java.util.NavigableSet; +import java.util.Set; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import org.apache.jena.ext.com.google.common.collect.ImmutableSet; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSortedSet; + +import cz.cuni.mff.xrg.odalic.api.rest.values.CellRelationAnnotationValue; +import cz.cuni.mff.xrg.odalic.api.rest.values.EntityCandidateValue; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; + + +public class CellRelationRelationAnnotationAdapter extends XmlAdapter { + + @Override + public CellRelationAnnotationValue marshal(CellRelationAnnotation bound) throws Exception { + return new CellRelationAnnotationValue(bound); + } + + @Override + public CellRelationAnnotation unmarshal(CellRelationAnnotationValue value) throws Exception { + final ImmutableMap.Builder> candidatesBuilder = + ImmutableMap.builder(); + final ImmutableMap.Builder> chosenBuilder = + ImmutableMap.builder(); + for (final Map.Entry> entry : value + .getCandidates().entrySet()) { + final KnowledgeBase base = entry.getKey(); + final Set values = entry.getValue(); + + candidatesBuilder.put(base, ImmutableSortedSet.copyOf(values.stream() + .map(e -> new EntityCandidate(e.getEntity(), e.getLikelihood())).iterator())); + chosenBuilder.put(base, ImmutableSet.copyOf(values.stream().filter(e -> e.isChosen()) + .map(e -> new EntityCandidate(e.getEntity(), e.getLikelihood())).iterator())); + } + + return new CellRelationAnnotation(candidatesBuilder.build(), chosenBuilder.build()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAnnotationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAnnotationAdapter.java index a06ff9c0..88c76f9c 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAnnotationAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAnnotationAdapter.java @@ -1,23 +1,47 @@ package cz.cuni.mff.xrg.odalic.api.rest.adapters; +import java.util.Map; +import java.util.NavigableSet; +import java.util.Set; + import javax.xml.bind.annotation.adapters.XmlAdapter; +import org.apache.jena.ext.com.google.common.collect.ImmutableSet; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSortedSet; + import cz.cuni.mff.xrg.odalic.api.rest.values.ColumnRelationAnnotationValue; +import cz.cuni.mff.xrg.odalic.api.rest.values.EntityCandidateValue; import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; -public class ColumnRelationAnnotationAdapter - extends XmlAdapter { +public class ColumnRelationAnnotationAdapter extends XmlAdapter { @Override - public ColumnRelationAnnotationValue marshal(ColumnRelationAnnotation bound) - throws Exception { + public ColumnRelationAnnotationValue marshal(ColumnRelationAnnotation bound) throws Exception { return new ColumnRelationAnnotationValue(bound); } @Override - public ColumnRelationAnnotation unmarshal(ColumnRelationAnnotationValue value) - throws Exception { - return new ColumnRelationAnnotation(value.getCandidates(), value.getChosen()); + public ColumnRelationAnnotation unmarshal(ColumnRelationAnnotationValue value) throws Exception { + final ImmutableMap.Builder> candidatesBuilder = + ImmutableMap.builder(); + final ImmutableMap.Builder> chosenBuilder = + ImmutableMap.builder(); + for (final Map.Entry> entry : value + .getCandidates().entrySet()) { + final KnowledgeBase base = entry.getKey(); + final Set values = entry.getValue(); + + candidatesBuilder.put(base, ImmutableSortedSet.copyOf(values.stream() + .map(e -> new EntityCandidate(e.getEntity(), e.getLikelihood())).iterator())); + chosenBuilder.put(base, ImmutableSet.copyOf(values.stream().filter(e -> e.isChosen()) + .map(e -> new EntityCandidate(e.getEntity(), e.getLikelihood())).iterator())); + } + + return new ColumnRelationAnnotation(candidatesBuilder.build(), chosenBuilder.build()); } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityCandidateAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityCandidateAdapter.java index 98e53bff..fd1ac924 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityCandidateAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityCandidateAdapter.java @@ -12,7 +12,7 @@ public class EntityCandidateAdapter @Override public EntityCandidateValue marshal(EntityCandidate bound) throws Exception { - return new EntityCandidateValue(bound); + return new EntityCandidateValue(bound, false); } @Override diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/HeaderAnnotationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/HeaderAnnotationAdapter.java index 5bbc1412..c996d027 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/HeaderAnnotationAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/HeaderAnnotationAdapter.java @@ -1,23 +1,47 @@ package cz.cuni.mff.xrg.odalic.api.rest.adapters; +import java.util.Map; +import java.util.NavigableSet; +import java.util.Set; + import javax.xml.bind.annotation.adapters.XmlAdapter; +import org.apache.jena.ext.com.google.common.collect.ImmutableSet; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSortedSet; + import cz.cuni.mff.xrg.odalic.api.rest.values.HeaderAnnotationValue; +import cz.cuni.mff.xrg.odalic.api.rest.values.EntityCandidateValue; import cz.cuni.mff.xrg.odalic.tasks.annotations.HeaderAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; -public class HeaderAnnotationAdapter - extends XmlAdapter { +public class HeaderAnnotationAdapter extends XmlAdapter { @Override - public HeaderAnnotationValue marshal(HeaderAnnotation bound) - throws Exception { + public HeaderAnnotationValue marshal(HeaderAnnotation bound) throws Exception { return new HeaderAnnotationValue(bound); } @Override - public HeaderAnnotation unmarshal(HeaderAnnotationValue value) - throws Exception { - return new HeaderAnnotation(value.getCandidates(), value.getChosen()); + public HeaderAnnotation unmarshal(HeaderAnnotationValue value) throws Exception { + final ImmutableMap.Builder> candidatesBuilder = + ImmutableMap.builder(); + final ImmutableMap.Builder> chosenBuilder = + ImmutableMap.builder(); + for (final Map.Entry> entry : value + .getCandidates().entrySet()) { + final KnowledgeBase base = entry.getKey(); + final Set values = entry.getValue(); + + candidatesBuilder.put(base, ImmutableSortedSet.copyOf(values.stream() + .map(e -> new EntityCandidate(e.getEntity(), e.getLikelihood())).iterator())); + chosenBuilder.put(base, ImmutableSet.copyOf(values.stream().filter(e -> e.isChosen()) + .map(e -> new EntityCandidate(e.getEntity(), e.getLikelihood())).iterator())); + } + + return new HeaderAnnotation(candidatesBuilder.build(), chosenBuilder.build()); } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ResultAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ResultAdapter.java new file mode 100644 index 00000000..a83b357a --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ResultAdapter.java @@ -0,0 +1,59 @@ +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import java.util.Map; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import com.google.common.collect.ImmutableMap; + +import cz.cuni.mff.xrg.odalic.api.rest.values.ResultValue; +import cz.cuni.mff.xrg.odalic.positions.CellRelationPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; +import cz.cuni.mff.xrg.odalic.positions.RowPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.results.Result; + + +public class ResultAdapter extends XmlAdapter { + + @Override + public ResultValue marshal(Result bound) throws Exception { + return new ResultValue(bound); + } + + @Override + public Result unmarshal(ResultValue value) throws Exception { + final ImmutableMap.Builder columnRelationAnnotationsBuilder = ImmutableMap.builder(); + for (final Map.Entry> entry : value.getColumnRelationAnnotations().entrySet()) { + final ColumnPosition first = entry.getKey(); + + for (final Map.Entry innerEntry : entry.getValue().entrySet()) { + final ColumnPosition second = innerEntry.getKey(); + final ColumnRelationAnnotation annotation = innerEntry.getValue(); + + columnRelationAnnotationsBuilder.put(new ColumnRelationPosition(first, second), annotation); + } + } + + final ImmutableMap.Builder cellRelationAnnotationsBuilder = ImmutableMap.builder(); + for (final Map.Entry>> entry : value.getCellRelationAnnotations().entrySet()) { + final RowPosition row = entry.getKey(); + + for (final Map.Entry> innerEntry : entry.getValue().entrySet()) { + final ColumnPosition first = innerEntry.getKey(); + + for (final Map.Entry subInnerEntry : innerEntry.getValue().entrySet()) { + final ColumnPosition second = subInnerEntry.getKey(); + final CellRelationAnnotation annotation = subInnerEntry.getValue(); + + cellRelationAnnotationsBuilder.put(new CellRelationPosition(new ColumnRelationPosition(first, second), row), annotation); + } + } + } + + return new Result(value.getHeaderAnnotations(), value.getCellAnnotations(), + columnRelationAnnotationsBuilder.build(), cellRelationAnnotationsBuilder.build()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellAnnotationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellAnnotationValue.java index 9c33e710..71ad7403 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellAnnotationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellAnnotationValue.java @@ -3,13 +3,12 @@ import java.util.Map; import java.util.NavigableSet; import java.util.Set; +import java.util.stream.Stream; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; import cz.cuni.mff.xrg.odalic.tasks.annotations.CellAnnotation; @@ -20,72 +19,55 @@ public final class CellAnnotationValue { @XmlElement - private Map> candidates; - - @XmlElement - private Map> chosen; + private Map> candidates; public CellAnnotationValue() { candidates = ImmutableMap.of(); - chosen = ImmutableMap.of(); } /** * @param entities */ public CellAnnotationValue(CellAnnotation adaptee) { - this.candidates = adaptee.getCandidates(); - this.chosen = adaptee.getChosen(); + final Map> chosen = adaptee.getChosen(); + + final ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); + for (final Map.Entry> entry : adaptee.getCandidates().entrySet()) { + final KnowledgeBase base = entry.getKey(); + final Set baseChosen = chosen.get(base); + final NavigableSet baseCandidates = entry.getValue(); + + final Stream stream = baseCandidates.stream().map(e -> new EntityCandidateValue(e, baseChosen.contains(e))); + candidatesBuilder.put(entry.getKey(), ImmutableSortedSet.copyOf(stream.iterator())); + } + + this.candidates = candidatesBuilder.build(); } /** * @return the candidates */ - public Map> getCandidates() { + public Map> getCandidates() { return candidates; } /** * @param candidates the candidates to set */ - public void setCandidates(Map> candidates) { - ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); - for (final Map.Entry> candidateEntry : candidates.entrySet()) { + public void setCandidates(Map> candidates) { + ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); + for (final Map.Entry> candidateEntry : candidates.entrySet()) { candidatesBuilder.put(candidateEntry.getKey(), ImmutableSortedSet.copyOf(candidateEntry.getValue())); } - for (final Map.Entry> chosenEntry : chosen.entrySet()) { - final KnowledgeBase chosenBase = chosenEntry.getKey(); - - final Set baseCandidates = candidates.get(chosenBase); - Preconditions.checkArgument(baseCandidates != null); - Preconditions.checkArgument(baseCandidates.containsAll(chosenEntry.getValue())); - } - this.candidates = candidatesBuilder.build(); } - /** - * @return the chosen + /* (non-Javadoc) + * @see java.lang.Object#toString() */ - public Map> getChosen() { - return chosen; - } - - /** - * @param chosen the chosen to set - */ - public void setChosen(Map> chosen) { - ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); - for (final Map.Entry> chosenEntry : chosen.entrySet()) { - final KnowledgeBase chosenBase = chosenEntry.getKey(); - - final Set baseCandidates = this.candidates.get(chosenBase); - Preconditions.checkArgument(baseCandidates != null); - Preconditions.checkArgument(baseCandidates.containsAll(chosenEntry.getValue())); - - chosenBuilder.put(chosenEntry.getKey(), ImmutableSet.copyOf(chosenEntry.getValue())); - } - this.chosen = chosenBuilder.build(); + @Override + public String toString() { + return "CellAnnotationValue [candidates=" + candidates + "]"; } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationAnnotationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationAnnotationValue.java index 044eac8a..487ace4f 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationAnnotationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationAnnotationValue.java @@ -3,13 +3,12 @@ import java.util.Map; import java.util.NavigableSet; import java.util.Set; +import java.util.stream.Stream; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; @@ -20,72 +19,55 @@ public final class CellRelationAnnotationValue { @XmlElement - private Map> candidates; - - @XmlElement - private Map> chosen; + private Map> candidates; public CellRelationAnnotationValue() { candidates = ImmutableMap.of(); - chosen = ImmutableMap.of(); } /** * @param entities */ public CellRelationAnnotationValue(CellRelationAnnotation adaptee) { - this.candidates = adaptee.getCandidates(); - this.chosen = adaptee.getChosen(); + final Map> chosen = adaptee.getChosen(); + + final ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); + for (final Map.Entry> entry : adaptee.getCandidates().entrySet()) { + final KnowledgeBase base = entry.getKey(); + final Set baseChosen = chosen.get(base); + final NavigableSet baseCandidates = entry.getValue(); + + final Stream stream = baseCandidates.stream().map(e -> new EntityCandidateValue(e, baseChosen.contains(e))); + candidatesBuilder.put(entry.getKey(), ImmutableSortedSet.copyOf(stream.iterator())); + } + + this.candidates = candidatesBuilder.build(); } /** * @return the candidates */ - public Map> getCandidates() { + public Map> getCandidates() { return candidates; } /** * @param candidates the candidates to set */ - public void setCandidates(Map> candidates) { - ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); - for (final Map.Entry> candidateEntry : candidates.entrySet()) { + public void setCandidates(Map> candidates) { + ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); + for (final Map.Entry> candidateEntry : candidates.entrySet()) { candidatesBuilder.put(candidateEntry.getKey(), ImmutableSortedSet.copyOf(candidateEntry.getValue())); } - for (final Map.Entry> chosenEntry : chosen.entrySet()) { - final KnowledgeBase chosenBase = chosenEntry.getKey(); - - final Set baseCandidates = candidates.get(chosenBase); - Preconditions.checkArgument(baseCandidates != null); - Preconditions.checkArgument(baseCandidates.containsAll(chosenEntry.getValue())); - } - this.candidates = candidatesBuilder.build(); } - /** - * @return the chosen + /* (non-Javadoc) + * @see java.lang.Object#toString() */ - public Map> getChosen() { - return chosen; - } - - /** - * @param chosen the chosen to set - */ - public void setChosen(Map> chosen) { - ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); - for (final Map.Entry> chosenEntry : chosen.entrySet()) { - final KnowledgeBase chosenBase = chosenEntry.getKey(); - - final Set baseCandidates = this.candidates.get(chosenBase); - Preconditions.checkArgument(baseCandidates != null); - Preconditions.checkArgument(baseCandidates.containsAll(chosenEntry.getValue())); - - chosenBuilder.put(chosenEntry.getKey(), ImmutableSet.copyOf(chosenEntry.getValue())); - } - this.chosen = chosenBuilder.build(); + @Override + public String toString() { + return "CellRelationAnnotationValue [candidates=" + candidates + "]"; } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationAnnotationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationAnnotationValue.java index 249cf1df..a268213e 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationAnnotationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationAnnotationValue.java @@ -3,13 +3,12 @@ import java.util.Map; import java.util.NavigableSet; import java.util.Set; +import java.util.stream.Stream; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; @@ -20,72 +19,55 @@ public final class ColumnRelationAnnotationValue { @XmlElement - private Map> candidates; - - @XmlElement - private Map> chosen; + private Map> candidates; public ColumnRelationAnnotationValue() { candidates = ImmutableMap.of(); - chosen = ImmutableMap.of(); } /** * @param entities */ public ColumnRelationAnnotationValue(ColumnRelationAnnotation adaptee) { - this.candidates = adaptee.getCandidates(); - this.chosen = adaptee.getChosen(); + final Map> chosen = adaptee.getChosen(); + + final ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); + for (final Map.Entry> entry : adaptee.getCandidates().entrySet()) { + final KnowledgeBase base = entry.getKey(); + final Set baseChosen = chosen.get(base); + final NavigableSet baseCandidates = entry.getValue(); + + final Stream stream = baseCandidates.stream().map(e -> new EntityCandidateValue(e, baseChosen.contains(e))); + candidatesBuilder.put(entry.getKey(), ImmutableSortedSet.copyOf(stream.iterator())); + } + + this.candidates = candidatesBuilder.build(); } /** * @return the candidates */ - public Map> getCandidates() { + public Map> getCandidates() { return candidates; } /** * @param candidates the candidates to set */ - public void setCandidates(Map> candidates) { - ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); - for (final Map.Entry> candidateEntry : candidates.entrySet()) { + public void setCandidates(Map> candidates) { + ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); + for (final Map.Entry> candidateEntry : candidates.entrySet()) { candidatesBuilder.put(candidateEntry.getKey(), ImmutableSortedSet.copyOf(candidateEntry.getValue())); } - for (final Map.Entry> chosenEntry : chosen.entrySet()) { - final KnowledgeBase chosenBase = chosenEntry.getKey(); - - final Set baseCandidates = candidates.get(chosenBase); - Preconditions.checkArgument(baseCandidates != null); - Preconditions.checkArgument(baseCandidates.containsAll(chosenEntry.getValue())); - } - this.candidates = candidatesBuilder.build(); } - /** - * @return the chosen + /* (non-Javadoc) + * @see java.lang.Object#toString() */ - public Map> getChosen() { - return chosen; - } - - /** - * @param chosen the chosen to set - */ - public void setChosen(Map> chosen) { - ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); - for (final Map.Entry> chosenEntry : chosen.entrySet()) { - final KnowledgeBase chosenBase = chosenEntry.getKey(); - - final Set baseCandidates = this.candidates.get(chosenBase); - Preconditions.checkArgument(baseCandidates != null); - Preconditions.checkArgument(baseCandidates.containsAll(chosenEntry.getValue())); - - chosenBuilder.put(chosenEntry.getKey(), ImmutableSet.copyOf(chosenEntry.getValue())); - } - this.chosen = chosenBuilder.build(); + @Override + public String toString() { + return "ColumnRelationAnnotationValue [candidates=" + candidates + "]"; } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityCandidateValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityCandidateValue.java index 208acabe..ae924ab4 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityCandidateValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityCandidateValue.java @@ -20,22 +20,23 @@ public final class EntityCandidateValue implements Serializable { @XmlElement private Likelihood likelihood; + + @XmlElement + private boolean chosen; /** * @param entity * @param likelihood */ - public EntityCandidateValue() { - entity = null; - likelihood = null; - } + public EntityCandidateValue() { } /** * @param adaptee */ - public EntityCandidateValue(EntityCandidate adaptee) { + public EntityCandidateValue(EntityCandidate adaptee, boolean chosen) { entity = adaptee.getEntity(); likelihood = adaptee.getLikelihood(); + this.chosen = chosen; } /** @@ -72,11 +73,26 @@ public void setLikelihood(Likelihood likelihood) { this.likelihood = likelihood; } + /** + * @return the chosen + */ + public boolean isChosen() { + return chosen; + } + + /** + * @param chosen the chosen to set + */ + public void setChosen(boolean chosen) { + this.chosen = chosen; + } + /* (non-Javadoc) * @see java.lang.Object#toString() */ @Override public String toString() { - return "EntityCandidateValue [entity=" + entity + ", likelihood=" + likelihood + "]"; + return "EntityCandidateValue [entity=" + entity + ", likelihood=" + likelihood + ", chosen=" + + chosen + "]"; } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/HeaderAnnotationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/HeaderAnnotationValue.java index d5fd803f..edfe9fb5 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/HeaderAnnotationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/HeaderAnnotationValue.java @@ -3,13 +3,12 @@ import java.util.Map; import java.util.NavigableSet; import java.util.Set; +import java.util.stream.Stream; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; import cz.cuni.mff.xrg.odalic.tasks.annotations.HeaderAnnotation; @@ -20,72 +19,55 @@ public final class HeaderAnnotationValue { @XmlElement - private Map> candidates; - - @XmlElement - private Map> chosen; + private Map> candidates; public HeaderAnnotationValue() { candidates = ImmutableMap.of(); - chosen = ImmutableMap.of(); } /** * @param entities */ public HeaderAnnotationValue(HeaderAnnotation adaptee) { - this.candidates = adaptee.getCandidates(); - this.chosen = adaptee.getChosen(); + final Map> chosen = adaptee.getChosen(); + + final ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); + for (final Map.Entry> entry : adaptee.getCandidates().entrySet()) { + final KnowledgeBase base = entry.getKey(); + final Set baseChosen = chosen.get(base); + final NavigableSet baseCandidates = entry.getValue(); + + final Stream stream = baseCandidates.stream().map(e -> new EntityCandidateValue(e, baseChosen.contains(e))); + candidatesBuilder.put(entry.getKey(), ImmutableSortedSet.copyOf(stream.iterator())); + } + + this.candidates = candidatesBuilder.build(); } /** * @return the candidates */ - public Map> getCandidates() { + public Map> getCandidates() { return candidates; } /** * @param candidates the candidates to set */ - public void setCandidates(Map> candidates) { - ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); - for (final Map.Entry> candidateEntry : candidates.entrySet()) { + public void setCandidates(Map> candidates) { + ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); + for (final Map.Entry> candidateEntry : candidates.entrySet()) { candidatesBuilder.put(candidateEntry.getKey(), ImmutableSortedSet.copyOf(candidateEntry.getValue())); } - for (final Map.Entry> chosenEntry : chosen.entrySet()) { - final KnowledgeBase chosenBase = chosenEntry.getKey(); - - final Set baseCandidates = candidates.get(chosenBase); - Preconditions.checkArgument(baseCandidates != null); - Preconditions.checkArgument(baseCandidates.containsAll(chosenEntry.getValue())); - } - this.candidates = candidatesBuilder.build(); } - /** - * @return the chosen + /* (non-Javadoc) + * @see java.lang.Object#toString() */ - public Map> getChosen() { - return chosen; - } - - /** - * @param chosen the chosen to set - */ - public void setChosen(Map> chosen) { - ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); - for (final Map.Entry> chosenEntry : chosen.entrySet()) { - final KnowledgeBase chosenBase = chosenEntry.getKey(); - - final Set baseCandidates = this.candidates.get(chosenBase); - Preconditions.checkArgument(baseCandidates != null); - Preconditions.checkArgument(baseCandidates.containsAll(chosenEntry.getValue())); - - chosenBuilder.put(chosenEntry.getKey(), ImmutableSet.copyOf(chosenEntry.getValue())); - } - this.chosen = chosenBuilder.build(); + @Override + public String toString() { + return "HeaderAnnotationValue [candidates=" + candidates + "]"; } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ResultValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ResultValue.java new file mode 100644 index 00000000..a8bc1786 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ResultValue.java @@ -0,0 +1,200 @@ +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.apache.jena.ext.com.google.common.collect.ImmutableMap; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import cz.cuni.mff.xrg.odalic.positions.CellRelationPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; +import cz.cuni.mff.xrg.odalic.positions.RowPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.HeaderAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.results.Result; + +@XmlRootElement(name = "result") +public class ResultValue implements Serializable { + + private static final long serialVersionUID = -6359038623760039155L; + + @XmlElement + private ColumnPosition subjectColumnPosition; + + @XmlElement + private List headerAnnotations; + + @XmlElement + private CellAnnotation[][] cellAnnotations; + + @XmlElement + private Map> columnRelationAnnotations; + + @XmlElement + private Map>> cellRelationAnnotations; + + @SuppressWarnings("unused") + private ResultValue() { + subjectColumnPosition = null; + headerAnnotations = ImmutableList.of(); + cellAnnotations = new CellAnnotation[0][0];; + columnRelationAnnotations = ImmutableMap.of(); + cellRelationAnnotations = ImmutableMap.of(); + } + + /** + * @param subjectColumnPosition + * @param headerAnnotations + * @param cellAnnotations + * @param columnRelationAnnotations + * @param cellRelationAnnotations + */ + public ResultValue(Result adaptee) { + subjectColumnPosition = adaptee.getSubjectColumnPosition(); + headerAnnotations = adaptee.getHeaderAnnotations(); + cellAnnotations = adaptee.getCellAnnotations(); + + final ImmutableMap.Builder> columnRelationAnnotationsBuilder = ImmutableMap.builder(); + for (final Map.Entry entry : adaptee.getColumnRelationAnnotations().entrySet()) { + final ColumnRelationPosition key = entry.getKey(); + final ColumnPosition firstColumn = key.getFirst(); + final ColumnPosition secondColumn = key.getSecond(); + final ColumnRelationAnnotation annotation = entry.getValue(); + + columnRelationAnnotationsBuilder.put(firstColumn, ImmutableMap.of(secondColumn, annotation)); + } + columnRelationAnnotations = columnRelationAnnotationsBuilder.build(); + + final ImmutableMap.Builder>> cellRelationAnnotationsBuilder = ImmutableMap.builder(); + for (final Map.Entry entry : adaptee.getCellRelationAnnotations().entrySet()) { + final CellRelationPosition key = entry.getKey(); + final RowPosition row = key.getRowPosition(); + final ColumnRelationPosition columns = key.getColumnsPosition(); + + final ColumnPosition firstColumn = columns.getFirst(); + final ColumnPosition secondColumn = columns.getSecond(); + + final CellRelationAnnotation annotation = entry.getValue(); + + cellRelationAnnotationsBuilder.put(row, ImmutableMap.of(firstColumn, ImmutableMap.of(secondColumn, annotation))); + } + cellRelationAnnotations = cellRelationAnnotationsBuilder.build(); + } + + /** + * @return the subjectColumnPosition + */ + public ColumnPosition getSubjectColumnPosition() { + return subjectColumnPosition; + } + + /** + * @param subjectColumnPosition the subjectColumnPosition to set + */ + public void setSubjectColumnPosition(ColumnPosition subjectColumnPosition) { + Preconditions.checkNotNull(subjectColumnPosition); + + this.subjectColumnPosition = subjectColumnPosition; + } + + /** + * @return the headerAnnotations + */ + @Nullable + public List getHeaderAnnotations() { + return headerAnnotations; + } + + /** + * @param headerAnnotations the headerAnnotations to set + */ + public void setHeaderAnnotations(List headerAnnotations) { + Preconditions.checkNotNull(headerAnnotations); + + this.headerAnnotations = ImmutableList.copyOf(headerAnnotations); + } + + /** + * @return the cellAnnotations + */ + @Nullable + public CellAnnotation[][] getCellAnnotations() { + return cz.cuni.mff.xrg.odalic.util.Arrays.deepCopy(CellAnnotation.class, cellAnnotations); + } + + /** + * @param cellAnnotations the cellAnnotations to set + */ + public void setCellAnnotations(CellAnnotation[][] cellAnnotations) { + Preconditions.checkNotNull(cellAnnotations); + + this.cellAnnotations = cz.cuni.mff.xrg.odalic.util.Arrays.deepCopy(CellAnnotation.class, cellAnnotations); + } + + /** + * @return the columnRelationAnnotations + */ + @Nullable + public Map> getColumnRelationAnnotations() { + return columnRelationAnnotations; + } + + /** + * @param columnRelationAnnotations the columnRelationAnnotations to set + */ + public void setColumnRelationAnnotations( + Map> columnRelationAnnotations) { + final ImmutableMap.Builder> columnRelationAnnotationsBuilder = ImmutableMap.builder(); + for (final Map.Entry> entry : columnRelationAnnotations.entrySet()) { + columnRelationAnnotationsBuilder.put(entry.getKey(), ImmutableMap.copyOf(entry.getValue())); + } + this.columnRelationAnnotations = columnRelationAnnotationsBuilder.build(); + } + + /** + * @return the cellRelationAnnotations + */ + @Nullable + public Map>> getCellRelationAnnotations() { + return cellRelationAnnotations; + } + + /** + * @param cellRelationAnnotations the cellRelationAnnotations to set + */ + public void setCellRelationAnnotations( + Map>> cellRelationAnnotations) { + final ImmutableMap.Builder>> cellRelationAnnotationsBuilder = ImmutableMap.builder(); + for (final Map.Entry>> entry : cellRelationAnnotations.entrySet()) { + final ImmutableMap.Builder> innerMapBuilder = ImmutableMap.builder(); + for (final Map.Entry> innerEntry : entry.getValue().entrySet()) { + innerMapBuilder.put(innerEntry.getKey(), ImmutableMap.copyOf(innerEntry.getValue())); + } + + cellRelationAnnotationsBuilder.put(entry.getKey(), innerMapBuilder.build()); + } + this.cellRelationAnnotations = cellRelationAnnotationsBuilder.build(); + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ResultValue [subjectColumnPosition=" + subjectColumnPosition + ", headerAnnotations=" + + headerAnnotations + ", cellAnnotations=" + Arrays.toString(cellAnnotations) + + ", columnRelationAnnotations=" + columnRelationAnnotations + ", cellRelationAnnotations=" + + cellRelationAnnotations + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/EntityCandidate.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/EntityCandidate.java index 176953bb..0e26fa56 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/EntityCandidate.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/EntityCandidate.java @@ -4,7 +4,6 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; - import com.google.common.base.Preconditions; @XmlRootElement(name = "entityCandidate") diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/Result.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/Result.java index 98f5cdc9..c8be8bdc 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/Result.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/Result.java @@ -8,12 +8,14 @@ import javax.annotation.Nullable; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.apache.jena.ext.com.google.common.collect.ImmutableMap; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; +import cz.cuni.mff.xrg.odalic.api.rest.adapters.ResultAdapter; import cz.cuni.mff.xrg.odalic.positions.CellRelationPosition; import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; @@ -22,6 +24,7 @@ import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; import cz.cuni.mff.xrg.odalic.tasks.annotations.HeaderAnnotation; +@XmlJavaTypeAdapter(ResultAdapter.class) @XmlRootElement(name = "result") public class Result implements Serializable { From 463c3f3835978eca58d9a5d72b3de4e12b432cb1 Mon Sep 17 00:00:00 2001 From: brodecva Date: Wed, 29 Jun 2016 14:49:19 +0200 Subject: [PATCH 032/211] Interpreter instantiation adapted to Spring DI. --- .../FutureBasedExecutionService.java | 72 ++++++------ .../SemanticTableInterpreterFactory.java | 12 ++ ...actory.java => TableMinerPlusFactory.java} | 111 ++++++++++-------- .../resources/spring/applicationContext.xml | 44 ++++--- .../executions/InterpreterExecutionBatch.java | 11 +- 5 files changed, 141 insertions(+), 109 deletions(-) create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/SemanticTableInterpreterFactory.java rename odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/{InterpreterFactory.java => TableMinerPlusFactory.java} (75%) diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java index 92bd0127..3f1f4b0c 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java @@ -14,7 +14,6 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; - import org.springframework.beans.factory.annotation.Autowired; import com.google.common.base.Preconditions; @@ -39,67 +38,62 @@ public final class FutureBasedExecutionService implements ExecutionService { private final TaskService taskService; private final AnnotationToResultAdapter annotationResultAdapter; + private final SemanticTableInterpreterFactory semanticTableInterpreterFactory; + private final TableXtractorCSV tableExtractor; private final ExecutorService executorService = Executors.newFixedThreadPool(1); private final Map> tasksToResults = new HashMap<>(); - - // TODO: Initialize, but verify whether per submit instantiation is not necessary. Provide as injected bean then. - private final SemanticTableInterpreter semanticTableInterpreter = InterpreterFactory.getInterpreter(); - - //TODO: This dependency should be made explicit and more reliable. - private final TableXtractorCSV tableExtractor = new TableXtractorCSV(); - + @Autowired public FutureBasedExecutionService(TaskService taskService, - AnnotationToResultAdapter annotationToResultAdapter) { + AnnotationToResultAdapter annotationToResultAdapter, + SemanticTableInterpreterFactory semanticTableInterpreterFactory, TableXtractorCSV tableExtractor) { Preconditions.checkNotNull(taskService); - - Preconditions.checkNotNull(semanticTableInterpreter); - + Preconditions.checkNotNull(annotationToResultAdapter); + Preconditions.checkNotNull(semanticTableInterpreterFactory); + Preconditions.checkNotNull(tableExtractor); + this.taskService = taskService; this.annotationResultAdapter = annotationToResultAdapter; + this.semanticTableInterpreterFactory = semanticTableInterpreterFactory; + this.tableExtractor = tableExtractor; } - + @Override public void submitForTaskId(String id) { final Task task = taskService.getById(id); - + final Future resultFuture = tasksToResults.get(task); if (resultFuture != null) { if (!resultFuture.isDone()) { throw new IllegalStateException(); } } - + final Configuration configuration = task.getConfiguration(); final File file = configuration.getInput(); final URL fileLocation = file.getLocation(); final java.io.File inputFile = urlToFile(fileLocation); - + final Set columnIgnores = configuration.getFeedback().getColumnIgnores(); - Integer[] ignoreCols = new Integer[columnIgnores.size()]; - int i = 0; - for (ColumnIgnore col : columnIgnores) { - ignoreCols[i] = col.getPosition().getIndex(); - i++; - } - InterpreterFactory.setIgnoreColumnsForInterpreter(ignoreCols); - + final Integer[] columnIgnoresArray = + columnIgnores.stream().map(e -> e.getPosition().getIndex()).toArray(Integer[]::new); + final Callable execution = () -> { final List
tables = tableExtractor.extract(inputFile, inputFile.getName()); - if (tables.isEmpty()) { throw new IllegalArgumentException(); } - - final TAnnotation annotationResult = semanticTableInterpreter.start(tables.get(0), true); - - final Result result = annotationResultAdapter.toResult(annotationResult); - + + final SemanticTableInterpreter interpreter = semanticTableInterpreterFactory.getInterpreter(); + semanticTableInterpreterFactory.setIgnoreColumnsForInterpreter(columnIgnoresArray); + + final TAnnotation annotationResult = interpreter.start(tables.get(0), true); + final Result result = annotationResultAdapter.toResult(annotationResult); + return result; }; - - final Future future = executorService.submit(execution); + final Future future = executorService.submit(execution); tasksToResults.put(task, future); } @@ -117,7 +111,7 @@ private java.io.File urlToFile(final URL fileLocation) { public Result getResultForTaskId(String id) throws InterruptedException, ExecutionException { final Task task = taskService.getById(id); final Future resultFuture = tasksToResults.get(task); - + return resultFuture.get(); } @@ -125,7 +119,7 @@ public Result getResultForTaskId(String id) throws InterruptedException, Executi public void cancelForTaskId(String id) { final Task task = taskService.getById(id); final Future resultFuture = tasksToResults.get(task); - + resultFuture.cancel(true); } @@ -133,23 +127,23 @@ public void cancelForTaskId(String id) { public boolean isDoneForTaskId(String id) { final Task task = taskService.getById(id); final Future resultFuture = tasksToResults.get(task); - + return resultFuture.isDone(); } - + @Override public boolean isCancelledForTaskId(String id) { final Task task = taskService.getById(id); final Future resultFuture = tasksToResults.get(task); - + return resultFuture.isCancelled(); } - + @Override public boolean hasBeenScheduledForTaskId(String id) { final Task task = taskService.getById(id); final Future resultFuture = tasksToResults.get(task); - + return resultFuture != null; } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/SemanticTableInterpreterFactory.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/SemanticTableInterpreterFactory.java new file mode 100644 index 00000000..7f6dba1a --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/SemanticTableInterpreterFactory.java @@ -0,0 +1,12 @@ +package cz.cuni.mff.xrg.odalic.tasks.executions; + +import uk.ac.shef.dcs.sti.core.algorithm.SemanticTableInterpreter; + + +public interface SemanticTableInterpreterFactory { + + SemanticTableInterpreter getInterpreter(); + + void setIgnoreColumnsForInterpreter(Integer[] ignoreCols); + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterFactory.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/TableMinerPlusFactory.java similarity index 75% rename from odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterFactory.java rename to odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/TableMinerPlusFactory.java index 4450ce30..e66823db 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterFactory.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/TableMinerPlusFactory.java @@ -17,6 +17,7 @@ import org.simmetrics.metrics.StringMetrics; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; import uk.ac.shef.dcs.kbsearch.KBSearch; import uk.ac.shef.dcs.kbsearch.KBSearchFactory; @@ -37,48 +38,52 @@ import uk.ac.shef.dcs.sti.core.subjectcol.SubjectColumnDetector; import uk.ac.shef.dcs.sti.util.FileUtils; -public class InterpreterFactory { +public final class TableMinerPlusFactory implements SemanticTableInterpreterFactory { - private static final Logger LOG = LoggerFactory.getLogger(InterpreterFactory.class); - - //TODO: Write your own path to the property file. - protected static final String PROPERTYFILE = "/Users/-/work/sti/sti.properties"; - - protected static SemanticTableInterpreter interpreter; - - protected static KBSearch kbSearch; - protected static LiteralColumnTagger literalColumnTagger; - - protected static final String PROPERTY_HOME = "sti.home"; - protected static final String PROPERTY_WEBSEARCH_PROP_FILE = "sti.websearch.properties"; - protected static final String PROPERTY_NLP_RESOURCES = "sti.nlp"; - protected static final String PROPERTY_KBSEARCH_PROP_FILE = "sti.kbsearch.propertyfile"; - protected static final String PROPERTY_CACHE_FOLDER = "sti.cache.main.dir"; + private static final String PROPERTY_HOME = "sti.home"; + private static final String PROPERTY_WEBSEARCH_PROP_FILE = "sti.websearch.properties"; + private static final String PROPERTY_NLP_RESOURCES = "sti.nlp"; + private static final String PROPERTY_KBSEARCH_PROP_FILE = "sti.kbsearch.propertyfile"; + private static final String PROPERTY_CACHE_FOLDER = "sti.cache.main.dir"; private static final String PROPERTY_ENTITY_CACHE_CORENAME = "entity"; private static final String PROPERTY_RELATION_CACHE_CORENAME = "relation"; private static final String PROPERTY_WEBSEARCH_CACHE_CORENAME = "websearch"; - protected static final String PROPERTY_IGNORE_COLUMNS = "sti.columns.ignore"; - protected static final String PROPERTY_MUSTDO_COLUMNS = "sti.columns.mustdo"; + private static final String PROPERTY_IGNORE_COLUMNS = "sti.columns.ignore"; + private static final String PROPERTY_MUSTDO_COLUMNS = "sti.columns.mustdo"; - protected static final String PROPERTY_TMP_SUBJECT_COLUMN_DETECTION_USE_WEBSEARCH = + private static final String PROPERTY_TMP_SUBJECT_COLUMN_DETECTION_USE_WEBSEARCH = "sti.subjectcolumndetection.ws"; - protected static final String PROPERTY_TMP_IINF_WEBSEARCH_STOPPING_CLASS = "sti.iinf.websearch.stopping.class"; - protected static final String PROPERTY_TMP_IINF_WEBSEARCH_STOPPING_CLASS_CONSTR_PARAM = + private static final String PROPERTY_TMP_IINF_WEBSEARCH_STOPPING_CLASS = "sti.iinf.websearch.stopping.class"; + private static final String PROPERTY_TMP_IINF_WEBSEARCH_STOPPING_CLASS_CONSTR_PARAM = "sti.iinf.websearch.stopping.class.constructor.params"; - protected static final String PROPERTY_TMP_IINF_LEARNING_STOPPING_CLASS = "sti.tmp.iinf.learning.stopping.class"; - protected static final String PROPERTY_TMP_IINF_LEARNING_STOPPING_CLASS_CONSTR_PARAM = + private static final String PROPERTY_TMP_IINF_LEARNING_STOPPING_CLASS = "sti.tmp.iinf.learning.stopping.class"; + private static final String PROPERTY_TMP_IINF_LEARNING_STOPPING_CLASS_CONSTR_PARAM = "sti.tmp.iinf.learning.stopping.class.constructor.params"; + + private static final Logger logger = LoggerFactory.getLogger(TableMinerPlusFactory.class); + + @Value("${cz.cuni.mff.xrg.odalic.sti}") + private String propertyFilePath; + + private SemanticTableInterpreter interpreter; + + private KBSearch kbSearch; + private LiteralColumnTagger literalColumnTagger; - protected static Properties properties; + private Properties properties; - protected static CoreContainer cores; - private static EmbeddedSolrServer entityCache; - private static EmbeddedSolrServer websearchCache; + private CoreContainer cores; + private EmbeddedSolrServer entityCache; + private EmbeddedSolrServer websearchCache; - public static SemanticTableInterpreter getInterpreter() { + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.tasks.executions.InterpreterFactory#getInterpreter() + */ + @Override + public SemanticTableInterpreter getInterpreter() { if (interpreter == null) { try { initComponents(); @@ -89,21 +94,25 @@ public static SemanticTableInterpreter getInterpreter() { return interpreter; } - public static void setIgnoreColumnsForInterpreter(Integer[] ignoreCols) { + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.tasks.executions.InterpreterFactory#setIgnoreColumnsForInterpreter(java.lang.Integer[]) + */ + @Override + public void setIgnoreColumnsForInterpreter(Integer[] ignoreCols) { interpreter.setIgnoreColumns(new HashSet(Arrays.asList(ignoreCols))); literalColumnTagger.setIgnoreColumns(ArrayUtils.toPrimitive(ignoreCols)); } //Initialize kbsearcher, websearcher - protected static void initComponents() throws STIException, IOException { + private void initComponents() throws STIException, IOException { properties = new Properties(); - properties.load(new FileInputStream(PROPERTYFILE)); + properties.load(new FileInputStream(propertyFilePath)); - LOG.info("Initializing entity cache..."); + logger.info("Initializing entity cache..."); EmbeddedSolrServer kbEntityServer = getSolrServerCacheEntity(); //object to fetch things from KB - LOG.info("Initializing KBSearch..."); + logger.info("Initializing KBSearch..."); KBSearchFactory fbf = new KBSearchFactory(); try { kbSearch = fbf.createInstance( @@ -111,7 +120,7 @@ protected static void initComponents() throws STIException, IOException { kbEntityServer, null, null,null); } catch (Exception e) { e.printStackTrace(); - LOG.error(ExceptionUtils.getFullStackTrace(e)); + logger.error(ExceptionUtils.getFullStackTrace(e)); throw new STIException("Failed initialising KBSearch:" + getAbsolutePath(PROPERTY_KBSEARCH_PROP_FILE) , e); @@ -120,7 +129,7 @@ protected static void initComponents() throws STIException, IOException { //LOG.info("Initializing WebSearcher..."); - LOG.info("Initializing SUBJECT COLUMN DETECTION components ..."); + logger.info("Initializing SUBJECT COLUMN DETECTION components ..."); SubjectColumnDetector subcolDetector; try { subcolDetector = new SubjectColumnDetector( @@ -141,13 +150,13 @@ protected static void initComponents() throws STIException, IOException { );// dobs } catch (Exception e) { e.printStackTrace(); - LOG.error(ExceptionUtils.getFullStackTrace(e)); + logger.error(ExceptionUtils.getFullStackTrace(e)); throw new STIException("Failed initialising SUBJECT COLUMN DETECTION components:" + properties.getProperty(PROPERTY_WEBSEARCH_PROP_FILE) , e); } - LOG.info("Initializing LEARNING components ..."); + logger.info("Initializing LEARNING components ..."); LEARNINGPreliminaryColumnClassifier preliminaryClassify; TCellDisambiguator disambiguator; TColumnClassifier classifier; @@ -183,26 +192,26 @@ protected static void initComponents() throws STIException, IOException { preliminaryClassify, preliminaryDisamb); } catch (Exception e) { e.printStackTrace(); - LOG.error(ExceptionUtils.getFullStackTrace(e)); + logger.error(ExceptionUtils.getFullStackTrace(e)); throw new STIException("Failed initialising LEARNING components:" , e); } - LOG.info("Initializing UPDATE components ..."); + logger.info("Initializing UPDATE components ..."); UPDATE update; try { update = new UPDATE(selector, kbSearch, disambiguator, classifier, getStopwords(), getNLPResourcesDir()); } catch (Exception e) { e.printStackTrace(); - LOG.error(ExceptionUtils.getFullStackTrace(e)); + logger.error(ExceptionUtils.getFullStackTrace(e)); throw new STIException("Failed initialising LEARNING components:" , e); } - LOG.info("Initializing RELATIONLEARNING components ..."); + logger.info("Initializing RELATIONLEARNING components ..."); RelationScorer relationScorer = null; TColumnColumnRelationEnumerator relationEnumerator = null; @@ -242,13 +251,13 @@ STIConstantProperty.ATTRIBUTE_MATCHER_MIN_SCORE, getStopwords(), } - protected static EmbeddedSolrServer getSolrServerCacheEntity() throws STIException { + private EmbeddedSolrServer getSolrServerCacheEntity() throws STIException { if (entityCache == null) { String solrHomePath = properties.getProperty(PROPERTY_CACHE_FOLDER); if (solrHomePath == null || !new File(solrHomePath).exists()) { String error = "Cannot proceed: the cache dir is not set or does not exist. " + PROPERTY_CACHE_FOLDER + "=" + solrHomePath; - LOG.error(error); + logger.error(error); throw new STIException(error); } @@ -261,13 +270,13 @@ protected static EmbeddedSolrServer getSolrServerCacheEntity() throws STIExcepti return entityCache; } - protected static EmbeddedSolrServer getSolrServerCacheWebsearch() throws STIException { + private EmbeddedSolrServer getSolrServerCacheWebsearch() throws STIException { if (websearchCache == null) { String solrHomePath = properties.getProperty(PROPERTY_CACHE_FOLDER); if (solrHomePath == null || !new File(solrHomePath).exists() || PROPERTY_RELATION_CACHE_CORENAME == null) { String error = "Cannot proceed: the cache dir is not set or does not exist. " + PROPERTY_CACHE_FOLDER + "=" + solrHomePath; - LOG.error(error); + logger.error(error); throw new STIException(error); } if (cores == null) { @@ -279,27 +288,27 @@ protected static EmbeddedSolrServer getSolrServerCacheWebsearch() throws STIExce return websearchCache; } - protected static String getNLPResourcesDir() throws STIException { + private String getNLPResourcesDir() throws STIException { String prop = getAbsolutePath(PROPERTY_NLP_RESOURCES); if (prop == null || !new File(prop).exists()) { String error = "Cannot proceed: nlp resources folder is not set or does not exist. " + PROPERTY_KBSEARCH_PROP_FILE + "=" + prop; - LOG.error(error); + logger.error(error); throw new STIException(error); } return prop; } - protected static List getStopwords() throws STIException, IOException { + private List getStopwords() throws STIException, IOException { return FileUtils.readList(getNLPResourcesDir() + File.separator + "stoplist.txt", true); } - protected static String getAbsolutePath(String propertyName) { + private String getAbsolutePath(String propertyName) { return properties.getProperty(PROPERTY_HOME) + File.separator + properties.getProperty(propertyName); } - protected static int[] getIgnoreColumns() { + private int[] getIgnoreColumns() { String ignore = properties.getProperty(PROPERTY_IGNORE_COLUMNS); String[] splits = StringUtils.split(ignore, ','); int[] res = new int[splits.length]; @@ -309,7 +318,7 @@ protected static int[] getIgnoreColumns() { return res; } - protected static int[] getMustdoColumns() { + private int[] getMustdoColumns() { String ignore = properties.getProperty(PROPERTY_MUSTDO_COLUMNS); String[] splits = StringUtils.split(ignore, ','); int[] res = new int[0]; diff --git a/odalic/src/main/resources/spring/applicationContext.xml b/odalic/src/main/resources/spring/applicationContext.xml index 6031a362..4e162eda 100644 --- a/odalic/src/main/resources/spring/applicationContext.xml +++ b/odalic/src/main/resources/spring/applicationContext.xml @@ -1,7 +1,6 @@ - + + - - - + + + + + + + + - + - - + + - + - + - - + + \ No newline at end of file diff --git a/odalic/src/test/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterExecutionBatch.java b/odalic/src/test/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterExecutionBatch.java index c95de616..93c8c9ad 100644 --- a/odalic/src/test/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterExecutionBatch.java +++ b/odalic/src/test/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterExecutionBatch.java @@ -19,9 +19,10 @@ public class InterpreterExecutionBatch { public static void main(String[] args) { // for test of execution of semantic table interpreter from Odalic project - SemanticTableInterpreter semanticTableInterpreter = InterpreterFactory.getInterpreter(); + SemanticTableInterpreterFactory factory = new TableMinerPlusFactory(); + SemanticTableInterpreter semanticTableInterpreter = factory.getInterpreter(); Preconditions.checkNotNull(semanticTableInterpreter); - InterpreterFactory.setIgnoreColumnsForInterpreter(new Integer[]{}); + factory.setIgnoreColumnsForInterpreter(new Integer[]{}); //TODO: Write your own path to the folder containing (only) the input file. List all = Arrays.asList(new File("/Users/-/work/sti/sti_data/Limaye200").listFiles()); @@ -49,13 +50,13 @@ public static void main(String[] args) { try { annotationResult = semanticTableInterpreter.start(tables.get(0), true); - System.out.println("Vsledek - OK:"); + System.out.println("V�sledek - OK:"); System.out.println(annotationResult.toString()); } catch (STIException e) { - System.out.println("Vsledek - Chyba:"); + System.out.println("V�sledek - Chyba:"); e.printStackTrace(); } - System.out.println("Konec vsledku."); + System.out.println("Konec v�sledku."); } } From cf052582e7685e0200ed59247b6b16a04bfc5dc8 Mon Sep 17 00:00:00 2001 From: brodecva Date: Wed, 29 Jun 2016 16:17:08 +0200 Subject: [PATCH 033/211] File resource fixes. --- .../api/rest/resources/FileResource.java | 28 ++++--------------- .../resources/spring/applicationContext.xml | 6 ++-- 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java index af76e9d6..22fff740 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java @@ -2,8 +2,6 @@ import java.io.IOException; import java.io.InputStream; -import java.io.OutputStream; -import java.nio.charset.StandardCharsets; import java.util.List; import javax.ws.rs.Consumes; @@ -13,12 +11,8 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; -import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import javax.ws.rs.core.StreamingOutput; - -import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.glassfish.jersey.media.multipart.FormDataParam; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -65,10 +59,9 @@ public Response getFileById(@PathParam("id") String id) { @PUT @Path("{id}") @Consumes(MediaType.MULTIPART_FORM_DATA) - @Produces(MediaType.APPLICATION_JSON) + @Produces(MediaType.TEXT_PLAIN) public Response putFileById(@PathParam("id") String id, @FormDataParam("input") InputStream fileInputStream, - @FormDataParam("disposition") FormDataContentDisposition disposition, @FormDataParam("file") File file) throws IOException { if (!fileService.hasId(file, id)) { @@ -93,7 +86,7 @@ public Response putFileById(@PathParam("id") String id, @PUT @Path("{id}") @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) + @Produces(MediaType.TEXT_PLAIN) public Response putFileById(@PathParam("id") String id, File file) { if (!fileService.hasId(file, id)) { @@ -117,11 +110,10 @@ public Response putFileById(@PathParam("id") String id, File file) { @DELETE @Path("{id}") - @Produces({MediaType.APPLICATION_JSON}) + @Produces({MediaType.TEXT_PLAIN}) public Response deleteFileById(@PathParam("id") String id) { fileService.deleteById(id); - return Response.status(Response.Status.NO_CONTENT) - .entity("File successfully removed from database").build(); + return Response.status(Response.Status.NO_CONTENT).build(); } @GET @@ -130,16 +122,6 @@ public Response deleteFileById(@PathParam("id") String id) { public Response getCsvDataById(@PathParam("id") String id) throws IOException { String data = fileService.getDataById(id); - StreamingOutput output = new StreamingOutput() { - - @Override - public void write(OutputStream output) throws IOException, WebApplicationException { - output.write(data.getBytes(StandardCharsets.UTF_8)); - output.flush(); - } - - }; - - return Response.status(Response.Status.OK).entity(output).type(TEXT_CSV_MEDIA_TYPE).build(); + return Response.ok(data).build(); } } diff --git a/odalic/src/main/resources/spring/applicationContext.xml b/odalic/src/main/resources/spring/applicationContext.xml index 4e162eda..5455ab20 100644 --- a/odalic/src/main/resources/spring/applicationContext.xml +++ b/odalic/src/main/resources/spring/applicationContext.xml @@ -38,13 +38,15 @@ class="cz.cuni.mff.xrg.odalic.tasks.feedbacks.MemoryOnlyFeedbackService" /> - - + + + + \ No newline at end of file From 9958ed187abc87d5a81334abcb60833a9a79c32d Mon Sep 17 00:00:00 2001 From: JanVana Date: Wed, 29 Jun 2016 17:03:31 +0200 Subject: [PATCH 034/211] #70 - Fixed pom conflicts and hidden some compilation warnings, that won't be fixed in the first iteration. --- core/pom.xml | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index b2e834c8..587da9ae 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -115,12 +115,16 @@ slf4j-log4j12 - log4j - log4j + org.slf4j + jcl-over-slf4j org.slf4j - slf4j-jdk14 + slf4j-api + + + log4j + log4j jdk.tools @@ -139,12 +143,16 @@ slf4j-log4j12 - log4j - log4j + org.slf4j + jcl-over-slf4j org.slf4j - slf4j-jdk14 + slf4j-api + + + log4j + log4j @@ -153,6 +161,16 @@ org.apache.jena jena-arq 3.0.1 + + + org.slf4j + slf4j-log4j12 + + + org.slf4j + slf4j-api + + From 7696b43414a49276563349dbf97d1ec1ca98d6d2 Mon Sep 17 00:00:00 2001 From: JanVana Date: Wed, 29 Jun 2016 17:03:52 +0200 Subject: [PATCH 035/211] #70 - Fixed pom conflicts and hidden some compilation warnings, that won't be fixed in the first iteration. --- common-util/pom.xml | 23 +++++++++----- .../shef/dcs/sti/xtractor/csv/ParserCsv.java | 1 + kbsearch/pom.xml | 30 +++++++++++++++---- .../dcs/kbsearch/sparql/DBpediaSearch.java | 4 +++ 4 files changed, 45 insertions(+), 13 deletions(-) diff --git a/common-util/pom.xml b/common-util/pom.xml index 2e460fb9..01914b16 100644 --- a/common-util/pom.xml +++ b/common-util/pom.xml @@ -18,12 +18,16 @@ slf4j-log4j12 - log4j - log4j + org.slf4j + jcl-over-slf4j org.slf4j - slf4j-jdk14 + slf4j-api + + + log4j + log4j jdk.tools @@ -42,18 +46,23 @@ slf4j-log4j12 - log4j - log4j + org.slf4j + jcl-over-slf4j org.slf4j - slf4j-jdk14 + slf4j-api + + + log4j + log4j - + + UTF-8 diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsv.java b/core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsv.java index 6705ff02..ee27d123 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsv.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsv.java @@ -43,6 +43,7 @@ public ParserCsv(ParserCsvConfig config) { } @Override + @SuppressWarnings("unchecked") public Table parse(File inFile) throws ParseFailed, NoCSVDataException { log.debug("Starting parsing file: " + inFile.getName()); diff --git a/kbsearch/pom.xml b/kbsearch/pom.xml index 94ef6416..05437ea6 100644 --- a/kbsearch/pom.xml +++ b/kbsearch/pom.xml @@ -76,12 +76,16 @@ slf4j-log4j12 - log4j - log4j + org.slf4j + jcl-over-slf4j org.slf4j - slf4j-jdk14 + slf4j-api + + + log4j + log4j jdk.tools @@ -100,12 +104,16 @@ slf4j-log4j12 - log4j - log4j + org.slf4j + jcl-over-slf4j org.slf4j - slf4j-jdk14 + slf4j-api + + + log4j + log4j @@ -114,6 +122,16 @@ org.apache.jena jena-arq 3.0.1 + + + org.slf4j + slf4j-log4j12 + + + org.slf4j + slf4j-api + + com.github.mpkorstanje diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearch.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearch.java index f3db129e..926106a7 100644 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearch.java +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearch.java @@ -64,6 +64,7 @@ private OntModel loadModel(String ontURL) { } @Override + @SuppressWarnings("unchecked") public List findEntityCandidates(String content) throws KBSearchException { String query = createSolrCacheQuery_findResources(content); boolean forceQuery = false; @@ -146,6 +147,7 @@ public List findEntityCandidates(String content) throws KBSearchExceptio } @Override + @SuppressWarnings("unchecked") public List findEntityCandidatesOfTypes(String content, String... types) throws KBSearchException { String queryCache = createSolrCacheQuery_findResources(content); boolean forceQuery = false; @@ -265,6 +267,7 @@ public List findEntityCandidatesOfTypes(String content, String... types) } // if the attribute's value is an URL, fetch the label of that resource, and reset its attr value + @SuppressWarnings("unchecked") private void resetResourceValue(Attribute attr) throws KBSearchException { String value = attr.getValue(); if (value.startsWith("http")) { @@ -311,6 +314,7 @@ public List findAttributesOfEntities(Entity ec) throws KBSearchExcept return find_attributes(ec.getId(), cacheEntity); } + @SuppressWarnings("unchecked") private List find_attributes(String id, SolrCache cache) throws KBSearchException { if (id.length() == 0) return new ArrayList<>(); From e9a4b237d026628fd14818161a1336cbf279e6db Mon Sep 17 00:00:00 2001 From: brodecva Date: Thu, 30 Jun 2016 09:08:50 +0200 Subject: [PATCH 036/211] File resource POST method implemented. --- .../api/rest/resources/FileResource.java | 69 +++++++++++++++---- .../api/rest/resources/TaskResource.java | 10 ++- .../cz/cuni/mff/xrg/odalic/files/File.java | 12 ++++ 3 files changed, 72 insertions(+), 19 deletions(-) diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java index 22fff740..c351ff75 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java @@ -2,17 +2,24 @@ import java.io.IOException; import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; import java.util.List; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; +import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; + +import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.glassfish.jersey.media.multipart.FormDataParam; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -34,7 +41,7 @@ public class FileResource { public static final String TEXT_CSV_MEDIA_TYPE = "text/csv"; private final FileService fileService; - + @Autowired public FileResource(FileService fileService) { Preconditions.checkNotNull(fileService); @@ -59,58 +66,94 @@ public Response getFileById(@PathParam("id") String id) { @PUT @Path("{id}") @Consumes(MediaType.MULTIPART_FORM_DATA) - @Produces(MediaType.TEXT_PLAIN) - public Response putFileById(@PathParam("id") String id, - @FormDataParam("input") InputStream fileInputStream, - @FormDataParam("file") File file) throws IOException { + @Produces(MediaType.APPLICATION_JSON) + public Response putFileById(@Context UriInfo uriInfo, @PathParam("id") String id, + @FormDataParam("input") InputStream fileInputStream, @FormDataParam("file") File file) + throws IOException { if (!fileService.hasId(file, id)) { return Response.status(Response.Status.NOT_ACCEPTABLE) .entity("The ID in the payload is not the same as the ID of resource.").build(); } + if (!file.getLocation().equals(getDefaultFileLocation(uriInfo, id))) { + return Response.status(Response.Status.NOT_ACCEPTABLE) + .entity( + "The location you provided for the file is not equal to the default location for uploaded file.") + .build(); + } + + final URL location = file.getLocation(); + if (!fileService.existsFileWithId(id)) { fileService.create(file, fileInputStream); return Response.status(Response.Status.CREATED) .entity("A new file has been created AT THE STANDARD LOCATION.") - .header("Location", "/files/" + String.valueOf(id)).build(); + .header("Location", location).build(); } else { fileService.replace(file); return Response.status(Response.Status.OK) .entity("The file you specified has been fully updated AT THE STANDARD LOCATION.") - .header("Location", "/files/" + String.valueOf(id)).build(); + .header("Location", location).build(); } } + private static URL getDefaultFileLocation(UriInfo uriInfo, String id) + throws MalformedURLException { + return uriInfo.getAbsolutePath().resolve(id).toURL(); + } + @PUT @Path("{id}") @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.TEXT_PLAIN) - public Response putFileById(@PathParam("id") String id, File file) { + @Produces(MediaType.APPLICATION_JSON) + public Response putFileById(@PathParam("id") String id, File file) throws MalformedURLException { if (!fileService.hasId(file, id)) { return Response.status(Response.Status.NOT_ACCEPTABLE) .entity("The ID in the payload is not the same as the ID of resource.").build(); } + final URL location = file.getLocation(); + if (!fileService.existsFileWithId(id)) { fileService.create(file); return Response.status(Response.Status.CREATED) .entity("A new file has been registered FOR THE LOCATION you specified") - .header("Location", "/files/" + String.valueOf(id)).build(); + .header("Location", location).build(); } else { fileService.replace(file); return Response.status(Response.Status.OK) .entity( "The file description you specified has been fully updated FOR THE LOCATION you specified.") - .header("Location", "/files/" + String.valueOf(id)).build(); + .header("Location", location).build(); } } + @POST + @Consumes(MediaType.MULTIPART_FORM_DATA) + @Produces(MediaType.APPLICATION_JSON) + public Response putFileById(@Context UriInfo uriInfo, + @FormDataParam("file") InputStream fileInputStream, + @FormDataParam("file") FormDataContentDisposition fileDetail) throws IOException { + + final String id = fileDetail.getFileName(); + final File file = new File(id, "", getDefaultFileLocation(uriInfo, id)); + + if (fileService.existsFileWithId(id)) { + return Response.status(Response.Status.NOT_ACCEPTABLE) + .entity("There already exists a file with the same name as you provided.").build(); + } + + fileService.create(file, fileInputStream); + return Response.status(Response.Status.CREATED) + .entity("A new file has been registered AT THE LOCATION DERIVED from the name of the one uploaded.") + .header("Location", file.getLocation()).build(); + } + @DELETE @Path("{id}") - @Produces({MediaType.TEXT_PLAIN}) public Response deleteFileById(@PathParam("id") String id) { fileService.deleteById(id); return Response.status(Response.Status.NO_CONTENT).build(); @@ -121,7 +164,7 @@ public Response deleteFileById(@PathParam("id") String id) { @Produces(TEXT_CSV_MEDIA_TYPE) public Response getCsvDataById(@PathParam("id") String id) throws IOException { String data = fileService.getDataById(id); - + return Response.ok(data).build(); } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/TaskResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/TaskResource.java index b18d264b..a21f8cea 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/TaskResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/TaskResource.java @@ -37,7 +37,7 @@ public List getTasks() { } @GET - @Path("/tasks/{id}") + @Path("{id}") @Produces(MediaType.APPLICATION_JSON) public Response getTaskById(@PathParam("id") String id) { Task task = taskService.getById(id); @@ -45,7 +45,7 @@ public Response getTaskById(@PathParam("id") String id) { } @PUT - @Path("/tasks/{id}") + @Path("{id}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response putTaskWithId(@PathParam("id") String id, Task task) { @@ -71,12 +71,10 @@ public Response putTaskWithId(@PathParam("id") String id, Task task) { } @DELETE - @Path("/tasks/{id}") - @Produces({MediaType.APPLICATION_JSON}) + @Path("{id}") public Response deleteTaskById(@PathParam("id") String id) { taskService.deleteById(id); - return Response.status(Response.Status.NO_CONTENT) - .entity("Task successfully removed from database").build(); + return Response.status(Response.Status.NO_CONTENT).build(); } @Autowired diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/File.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/File.java index 1d941572..19b65b9b 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/File.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/File.java @@ -1,6 +1,7 @@ package cz.cuni.mff.xrg.odalic.files; import java.io.Serializable; +import java.net.MalformedURLException; import java.net.URL; import java.util.Date; @@ -41,6 +42,17 @@ private File() { owner = null; } + public File(String id, String owner, URL location) throws MalformedURLException { + Preconditions.checkNotNull(id); + Preconditions.checkNotNull(owner); + Preconditions.checkNotNull(location); + + this.id = id; + this.uploaded = new Date(); + this.owner = owner; + this.location = location; + } + public File(String id, Date uploaded, String owner, URL location) { Preconditions.checkNotNull(id); Preconditions.checkNotNull(uploaded); From 8d35fec96329931e18a4b080b412691b22e39265 Mon Sep 17 00:00:00 2001 From: brodecva Date: Thu, 30 Jun 2016 15:06:14 +0200 Subject: [PATCH 037/211] Task resource fixes. --- odalic/pom.xml | 28 +++++--- .../xrg/odalic/api/rest/Configuration.java | 5 +- .../rest/adapters/ConfigurationAdapter.java | 12 +--- .../rest/adapters/KnowledgeBaseAdapter.java | 2 +- .../odalic/api/rest/adapters/TaskAdapter.java | 2 +- .../CustomJsonDateDeserializer.java | 8 +-- .../conversions/CustomJsonDateSerializer.java | 8 +-- .../KnowledgeBaseKeyJsonDeserializer.java | 14 ++++ .../KnowledgeBaseKeyJsonSerializer.java | 22 ++++++ .../rest/filters/LoggingResponseFilter.java | 2 +- .../rest/resources/ConfigurationResource.java | 25 +++++-- .../api/rest/resources/FileResource.java | 9 +-- .../api/rest/resources/TaskResource.java | 33 +++++++-- .../api/rest/values/CellAnnotationValue.java | 7 ++ .../values/CellRelationAnnotationValue.java | 7 ++ .../values/ColumnRelationAnnotationValue.java | 7 ++ .../api/rest/values/ConfigurationValue.java | 30 ++------ .../rest/values/HeaderAnnotationValue.java | 7 ++ .../api/rest/values/KnowledgeBaseValue.java | 28 +++++++- .../xrg/odalic/api/rest/values/TaskValue.java | 13 ++-- .../cz/cuni/mff/xrg/odalic/files/File.java | 4 +- .../positions/CellRelationPosition.java | 7 +- .../positions/ColumnRelationPosition.java | 6 ++ .../cz/cuni/mff/xrg/odalic/tasks/Task.java | 4 +- .../cuni/mff/xrg/odalic/tasks/TaskDigest.java | 4 +- .../mff/xrg/odalic/tasks/TaskService.java | 4 +- .../mff/xrg/odalic/tasks/TaskServiceImpl.java | 10 ++- .../tasks/annotations/CellAnnotation.java | 9 +++ .../annotations/CellRelationAnnotation.java | 9 +++ .../annotations/ColumnRelationAnnotation.java | 9 +++ .../tasks/annotations/HeaderAnnotation.java | 9 +++ .../tasks/annotations/KnowledgeBase.java | 70 ++++++++++++++++++- .../java/cz/cuni/mff/xrg/odalic/util/URL.java | 14 ++++ .../resources/spring/applicationContext.xml | 17 +++-- odalic/src/main/webapp/WEB-INF/web.xml | 4 +- 35 files changed, 338 insertions(+), 111 deletions(-) create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/KnowledgeBaseKeyJsonDeserializer.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/KnowledgeBaseKeyJsonSerializer.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/URL.java diff --git a/odalic/pom.xml b/odalic/pom.xml index ee1a5ccd..fcbfc1f2 100644 --- a/odalic/pom.xml +++ b/odalic/pom.xml @@ -10,11 +10,11 @@ 1.8 - 1.7.6 - 2.8 - 9.0.7.v20131107 - 1.1.1 - 4.0.3.RELEASE + 1.7.21 + 2.23.1 + 1.1.7 + 4.3.0.RELEASE + 1.7.2.RELEASE @@ -30,6 +30,11 @@ Java.net Repository for Maven http://download.java.net/maven/2/ + + com.springsource.repository.bundles.external + SpringSource Enterprise Bundle Repository - External Bundle Releases + http://repository.springsource.com/maven/bundles/external + @@ -103,12 +108,15 @@ spring-tx ${spring.version} - - - org.ujmp - ujmp-core - 0.3.0 + org.springframework + spring-aspects + ${spring.version} + + + org.aspectj + com.springsource.org.aspectj.weaver + ${weaver.version} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java index e501f7a6..776af0e4 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java @@ -3,10 +3,12 @@ */ package cz.cuni.mff.xrg.odalic.api.rest; +import javax.xml.bind.JAXBException; import org.glassfish.jersey.jackson.JacksonFeature; import org.glassfish.jersey.media.multipart.MultiPartFeature; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.spring.scope.RequestContextFilter; +import org.springframework.stereotype.Component; import cz.cuni.mff.xrg.odalic.api.rest.errors.ThrowableMapper; import cz.cuni.mff.xrg.odalic.api.rest.filters.CorsResponseFilter; @@ -20,9 +22,10 @@ import cz.cuni.mff.xrg.odalic.api.rest.resources.StateResource; import cz.cuni.mff.xrg.odalic.api.rest.resources.TaskResource; +@Component public final class Configuration extends ResourceConfig { - public Configuration() { + public Configuration() throws JAXBException { // Resources registration register(FileResource.class); register(TaskResource.class); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ConfigurationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ConfigurationAdapter.java index 4c77323a..260803b3 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ConfigurationAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ConfigurationAdapter.java @@ -2,22 +2,12 @@ import javax.xml.bind.annotation.adapters.XmlAdapter; -import org.springframework.beans.factory.annotation.Autowired; - import cz.cuni.mff.xrg.odalic.api.rest.values.ConfigurationValue; -import cz.cuni.mff.xrg.odalic.files.FileService; import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; public class ConfigurationAdapter extends XmlAdapter { - private final FileService fileService; - - @Autowired - public ConfigurationAdapter(FileService fileService) { - this.fileService = fileService; - } - @Override public ConfigurationValue marshal(Configuration bound) throws Exception { return new ConfigurationValue(bound); @@ -25,6 +15,6 @@ public ConfigurationValue marshal(Configuration bound) throws Exception { @Override public Configuration unmarshal(ConfigurationValue value) throws Exception { - return new Configuration(fileService.getById(value.getInput()), value.getFeedback()); + throw new UnsupportedOperationException(); } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/KnowledgeBaseAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/KnowledgeBaseAdapter.java index 7ac41530..2affe613 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/KnowledgeBaseAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/KnowledgeBaseAdapter.java @@ -18,6 +18,6 @@ public KnowledgeBaseValue marshal(KnowledgeBase bound) @Override public KnowledgeBase unmarshal(KnowledgeBaseValue value) throws Exception { - return new KnowledgeBase(); + return new KnowledgeBase(value.getName()); } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/TaskAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/TaskAdapter.java index f9a42296..185968e2 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/TaskAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/TaskAdapter.java @@ -15,6 +15,6 @@ public TaskValue marshal(Task bound) throws Exception { @Override public Task unmarshal(TaskValue value) throws Exception { - return new Task(value.getId(), value.getCreated(), value.getConfiguration()); + throw new UnsupportedOperationException(); } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateDeserializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateDeserializer.java index 072ff3fb..6daffe74 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateDeserializer.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateDeserializer.java @@ -5,10 +5,10 @@ import java.text.SimpleDateFormat; import java.util.Date; -import org.codehaus.jackson.JsonParser; -import org.codehaus.jackson.JsonProcessingException; -import org.codehaus.jackson.map.DeserializationContext; -import org.codehaus.jackson.map.JsonDeserializer; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; public class CustomJsonDateDeserializer extends JsonDeserializer { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateSerializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateSerializer.java index a95dacbe..5909461e 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateSerializer.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateSerializer.java @@ -4,10 +4,10 @@ import java.text.SimpleDateFormat; import java.util.Date; -import org.codehaus.jackson.JsonGenerator; -import org.codehaus.jackson.JsonProcessingException; -import org.codehaus.jackson.map.JsonSerializer; -import org.codehaus.jackson.map.SerializerProvider; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; public class CustomJsonDateSerializer extends JsonSerializer { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/KnowledgeBaseKeyJsonDeserializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/KnowledgeBaseKeyJsonDeserializer.java new file mode 100644 index 00000000..71b583ce --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/KnowledgeBaseKeyJsonDeserializer.java @@ -0,0 +1,14 @@ +package cz.cuni.mff.xrg.odalic.api.rest.conversions; + +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.KeyDeserializer; + +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; + +public class KnowledgeBaseKeyJsonDeserializer extends KeyDeserializer { + + @Override + public Object deserializeKey(String key, DeserializationContext ctxt) { + return new KnowledgeBase(key); + } +} \ No newline at end of file diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/KnowledgeBaseKeyJsonSerializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/KnowledgeBaseKeyJsonSerializer.java new file mode 100644 index 00000000..087a373e --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/KnowledgeBaseKeyJsonSerializer.java @@ -0,0 +1,22 @@ +package cz.cuni.mff.xrg.odalic.api.rest.conversions; + +import java.io.IOException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; + +public class KnowledgeBaseKeyJsonSerializer extends JsonSerializer { + + public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm"; + + @Override + public void serialize(KnowledgeBase value, JsonGenerator jgen, + SerializerProvider provider) throws IOException, + JsonProcessingException { + jgen.writeString(value.getName()); + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/LoggingResponseFilter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/LoggingResponseFilter.java index 13627979..f64dcabb 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/LoggingResponseFilter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/LoggingResponseFilter.java @@ -6,7 +6,7 @@ import javax.ws.rs.container.ContainerResponseContext; import javax.ws.rs.container.ContainerResponseFilter; -import org.codehaus.jackson.map.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ConfigurationResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ConfigurationResource.java index 1c87b8e2..43eac8a4 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ConfigurationResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ConfigurationResource.java @@ -12,6 +12,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.values.ConfigurationValue; +import cz.cuni.mff.xrg.odalic.files.File; +import cz.cuni.mff.xrg.odalic.files.FileService; import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; import cz.cuni.mff.xrg.odalic.tasks.configurations.ConfigurationService; @@ -19,26 +24,36 @@ @Path("/tasks/{id}/configuration") public class ConfigurationResource { - private ConfigurationService configurationService; + private final ConfigurationService configurationService; + + private final FileService fileService; @PUT @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public Response putConfigurationForTaskId(@PathParam("id") String id, Configuration configuration) { + public Response putConfigurationForTaskId(@PathParam("id") String id, + ConfigurationValue configurationValue) { + final File input = fileService.getById(configurationValue.getInput()); + final Configuration configuration = new Configuration(input, configurationValue.getFeedback()); + configurationService.setForTaskId(id, configuration); return Response.status(Response.Status.OK).entity("Configuration set.").build(); } - + @GET @Produces(MediaType.APPLICATION_JSON) public Response getConfigurationForTaskId(@PathParam("id") String taskId) { Configuration configurationForTaskId = configurationService.getForTaskId(taskId); - + return Response.status(Response.Status.OK).entity(configurationForTaskId).build(); } @Autowired - public ConfigurationResource(ConfigurationService configurationService) { + public ConfigurationResource(ConfigurationService configurationService, FileService fileService) { + Preconditions.checkNotNull(configurationService); + Preconditions.checkNotNull(fileService); + this.configurationService = configurationService; + this.fileService = fileService; } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java index c351ff75..3c6dbd94 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java @@ -76,7 +76,7 @@ public Response putFileById(@Context UriInfo uriInfo, @PathParam("id") String id .entity("The ID in the payload is not the same as the ID of resource.").build(); } - if (!file.getLocation().equals(getDefaultFileLocation(uriInfo, id))) { + if (!file.getLocation().equals(cz.cuni.mff.xrg.odalic.util.URL.getResourceUrL(uriInfo, id))) { return Response.status(Response.Status.NOT_ACCEPTABLE) .entity( "The location you provided for the file is not equal to the default location for uploaded file.") @@ -99,11 +99,6 @@ public Response putFileById(@Context UriInfo uriInfo, @PathParam("id") String id } } - private static URL getDefaultFileLocation(UriInfo uriInfo, String id) - throws MalformedURLException { - return uriInfo.getAbsolutePath().resolve(id).toURL(); - } - @PUT @Path("{id}") @Consumes(MediaType.APPLICATION_JSON) @@ -139,7 +134,7 @@ public Response putFileById(@Context UriInfo uriInfo, @FormDataParam("file") FormDataContentDisposition fileDetail) throws IOException { final String id = fileDetail.getFileName(); - final File file = new File(id, "", getDefaultFileLocation(uriInfo, id)); + final File file = new File(id, "", cz.cuni.mff.xrg.odalic.util.URL.getResourceUrL(uriInfo, id)); if (fileService.existsFileWithId(id)) { return Response.status(Response.Status.NOT_ACCEPTABLE) diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/TaskResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/TaskResource.java index a21f8cea..4e430647 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/TaskResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/TaskResource.java @@ -1,6 +1,7 @@ package cz.cuni.mff.xrg.odalic.api.rest.resources; -import java.util.List; +import java.net.MalformedURLException; +import java.util.Set; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -9,15 +10,23 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.values.ConfigurationValue; +import cz.cuni.mff.xrg.odalic.api.rest.values.TaskValue; +import cz.cuni.mff.xrg.odalic.files.File; +import cz.cuni.mff.xrg.odalic.files.FileService; import cz.cuni.mff.xrg.odalic.tasks.Task; -import cz.cuni.mff.xrg.odalic.tasks.TaskDigest; import cz.cuni.mff.xrg.odalic.tasks.TaskService; +import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; /** * Task resource definition. @@ -29,10 +38,11 @@ public class TaskResource { private TaskService taskService; + private FileService fileService; @GET @Produces(MediaType.APPLICATION_JSON) - public List getTasks() { + public Set getTasks() { return taskService.getTasks(); } @@ -48,7 +58,12 @@ public Response getTaskById(@PathParam("id") String id) { @Path("{id}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public Response putTaskWithId(@PathParam("id") String id, Task task) { + public Response putTaskWithId(@Context UriInfo uriInfo, @PathParam("id") String id, TaskValue taskValue) throws MalformedURLException { + final ConfigurationValue configurationValue = taskValue.getConfiguration(); + final File input = fileService.getById(configurationValue.getInput()); + final Configuration configuration = new Configuration(input, configurationValue.getFeedback()); + final Task task = new Task(taskValue.getId(), taskValue.getCreated(), new Configuration(input, configuration.getFeedback())); + if (!taskService.hasId(task, id)) { return Response.status(Response.Status.NOT_ACCEPTABLE) .entity("The ID in the payload is not the same as the ID of resource.").build(); @@ -60,13 +75,13 @@ public Response putTaskWithId(@PathParam("id") String id, Task task) { taskService.create(task); return Response.status(Response.Status.CREATED) .entity("A new task has been created AT THE LOCATION you specified") - .header("Location", "/tasks/" + String.valueOf(id)).build(); + .header("Location", cz.cuni.mff.xrg.odalic.util.URL.getResourceUrL(uriInfo, id)).build(); } else { taskService.replace(task); return Response.status(Response.Status.OK) .entity( "The task you specified has been fully updated AT THE LOCATION you specified.") - .header("Location", "/tasks/" + String.valueOf(id)).build(); + .header("Location", cz.cuni.mff.xrg.odalic.util.URL.getResourceUrL(uriInfo, id)).build(); } } @@ -78,7 +93,11 @@ public Response deleteTaskById(@PathParam("id") String id) { } @Autowired - public TaskResource(TaskService taskService) { + public TaskResource(TaskService taskService, FileService fileService) { + Preconditions.checkNotNull(taskService); + Preconditions.checkNotNull(fileService); + this.taskService = taskService; + this.fileService = fileService; } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellAnnotationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellAnnotationValue.java index 71ad7403..792bd8e2 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellAnnotationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellAnnotationValue.java @@ -8,9 +8,14 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSortedSet; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonDeserializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonSerializer; import cz.cuni.mff.xrg.odalic.tasks.annotations.CellAnnotation; import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; @@ -19,6 +24,8 @@ public final class CellAnnotationValue { @XmlElement + @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) + @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) private Map> candidates; public CellAnnotationValue() { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationAnnotationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationAnnotationValue.java index 487ace4f..3716965a 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationAnnotationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationAnnotationValue.java @@ -8,9 +8,14 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSortedSet; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonDeserializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonSerializer; import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; @@ -19,6 +24,8 @@ public final class CellRelationAnnotationValue { @XmlElement + @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) + @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) private Map> candidates; public CellRelationAnnotationValue() { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationAnnotationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationAnnotationValue.java index a268213e..654af6d0 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationAnnotationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationAnnotationValue.java @@ -8,9 +8,14 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSortedSet; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonDeserializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonSerializer; import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; @@ -19,6 +24,8 @@ public final class ColumnRelationAnnotationValue { @XmlElement + @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) + @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) private Map> candidates; public ColumnRelationAnnotationValue() { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java index 355b9c65..1a3c9a32 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java @@ -2,12 +2,9 @@ import java.io.Serializable; -import javax.annotation.Nullable; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import com.google.common.base.Preconditions; - import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; @@ -17,12 +14,13 @@ public class ConfigurationValue implements Serializable { private static final long serialVersionUID = -6359038623760039155L; @XmlElement(name = "input") - private String input; + private final String input; @XmlElement(name = "feedback") - private Feedback feedback; + private final Feedback feedback; - public ConfigurationValue() { + @SuppressWarnings("unused") + private ConfigurationValue() { input = null; feedback = null; } @@ -35,37 +33,17 @@ public ConfigurationValue(Configuration adaptee) { /** * @return the input */ - @Nullable public String getInput() { return input; } - /** - * @param input the input to set - */ - public void setInput(String input) { - Preconditions.checkNotNull(input); - - this.input = input; - } - /** * @return the feedback */ - @Nullable public Feedback getFeedback() { return feedback; } - /** - * @param feedback the feedback to set - */ - public void setFeedback(Feedback feedback) { - Preconditions.checkNotNull(feedback); - - this.feedback = feedback; - } - /* (non-Javadoc) * @see java.lang.Object#toString() */ diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/HeaderAnnotationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/HeaderAnnotationValue.java index edfe9fb5..4051d5e3 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/HeaderAnnotationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/HeaderAnnotationValue.java @@ -8,10 +8,15 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSortedSet; import cz.cuni.mff.xrg.odalic.tasks.annotations.HeaderAnnotation; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonDeserializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonSerializer; import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; @@ -19,6 +24,8 @@ public final class HeaderAnnotationValue { @XmlElement + @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) + @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) private Map> candidates; public HeaderAnnotationValue() { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/KnowledgeBaseValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/KnowledgeBaseValue.java index 1da6b415..05f0cf33 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/KnowledgeBaseValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/KnowledgeBaseValue.java @@ -1,21 +1,45 @@ package cz.cuni.mff.xrg.odalic.api.rest.values; +import javax.annotation.Nullable; import javax.xml.bind.annotation.XmlRootElement; +import com.google.common.base.Preconditions; + import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; @XmlRootElement(name = "knowledgeBase") public class KnowledgeBaseValue { + private String name; + public KnowledgeBaseValue() {} - public KnowledgeBaseValue(KnowledgeBase adaptee) {} + public KnowledgeBaseValue(KnowledgeBase adaptee) { + name = adaptee.getName(); + } + /** + * @return the name + */ + @Nullable + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + Preconditions.checkNotNull(name); + + this.name = name; + } + /* (non-Javadoc) * @see java.lang.Object#toString() */ @Override public String toString() { - return "KnowledgeBaseValue"; + return "KnowledgeBaseValue [name=" + name + "]"; } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/TaskValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/TaskValue.java index 9dcf4c51..9b409a76 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/TaskValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/TaskValue.java @@ -7,15 +7,14 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import org.codehaus.jackson.map.annotate.JsonDeserialize; -import org.codehaus.jackson.map.annotate.JsonSerialize; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.google.common.base.Preconditions; import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateDeserializer; import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateSerializer; import cz.cuni.mff.xrg.odalic.tasks.Task; -import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; @XmlRootElement(name = "task") public final class TaskValue implements Serializable { @@ -31,7 +30,7 @@ public final class TaskValue implements Serializable { private Date created; @XmlElement - private Configuration configuration; + private ConfigurationValue configuration; public TaskValue() { id = null; @@ -46,7 +45,7 @@ public TaskValue() { public TaskValue(Task adaptee) { id = adaptee.getId(); created = adaptee.getCreated(); - configuration = adaptee.getConfiguration(); + configuration = new ConfigurationValue(adaptee.getConfiguration()); } /** @@ -87,14 +86,14 @@ public void setCreated(Date created) { * @return the configuration */ @Nullable - public Configuration getConfiguration() { + public ConfigurationValue getConfiguration() { return configuration; } /** * @param configuration the configuration to set */ - public void setConfiguration(Configuration configuration) { + public void setConfiguration(ConfigurationValue configuration) { Preconditions.checkNotNull(configuration); this.configuration = configuration; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/File.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/File.java index 19b65b9b..23208b7b 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/File.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/File.java @@ -8,8 +8,8 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import org.codehaus.jackson.map.annotate.JsonDeserialize; -import org.codehaus.jackson.map.annotate.JsonSerialize; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.google.common.base.Preconditions; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/CellRelationPosition.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/CellRelationPosition.java index 1964f3af..c5dbc5d3 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/CellRelationPosition.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/CellRelationPosition.java @@ -14,7 +14,12 @@ public final class CellRelationPosition { @XmlElement private final RowPosition rowPosition; - + @SuppressWarnings("unused") + private CellRelationPosition() { + columnsPosition = null; + rowPosition = null; + } + public CellRelationPosition(ColumnRelationPosition columnsPosition, RowPosition rowPosition) { Preconditions.checkNotNull(columnsPosition); Preconditions.checkNotNull(rowPosition); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/ColumnRelationPosition.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/ColumnRelationPosition.java index a2f3d675..b91ebbaa 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/ColumnRelationPosition.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/ColumnRelationPosition.java @@ -8,6 +8,12 @@ public final class ColumnRelationPosition { private final ColumnPosition second; + @SuppressWarnings("unused") + private ColumnRelationPosition() { + first = null; + second = null; + } + public ColumnRelationPosition(ColumnPosition first, ColumnPosition second) { Preconditions.checkNotNull(first); Preconditions.checkNotNull(second); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/Task.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/Task.java index 8b35ec2c..6772fd1e 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/Task.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/Task.java @@ -6,8 +6,8 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import org.codehaus.jackson.map.annotate.JsonDeserialize; -import org.codehaus.jackson.map.annotate.JsonSerialize; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.google.common.base.Preconditions; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskDigest.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskDigest.java index c7bd82eb..445ed709 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskDigest.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskDigest.java @@ -7,8 +7,8 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import org.codehaus.jackson.map.annotate.JsonDeserialize; -import org.codehaus.jackson.map.annotate.JsonSerialize; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateDeserializer; import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateSerializer; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskService.java index e41610bd..37933ba1 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskService.java @@ -1,10 +1,10 @@ package cz.cuni.mff.xrg.odalic.tasks; -import java.util.List; +import java.util.Set; public interface TaskService { - List getTasks(); + Set getTasks(); Task getById(String id); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskServiceImpl.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskServiceImpl.java index 1e248a65..5b9109e8 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskServiceImpl.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskServiceImpl.java @@ -1,11 +1,11 @@ package cz.cuni.mff.xrg.odalic.tasks; import java.util.HashMap; -import java.util.List; import java.util.Map; +import java.util.Set; import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; /** * @author Václav Brodec @@ -13,14 +13,12 @@ */ public final class TaskServiceImpl implements TaskService { - private final Map tasksDigests = new HashMap<>(); - private final Map tasks = new HashMap<>(); public TaskServiceImpl() {} - public List getTasks() { - return ImmutableList.copyOf(this.tasksDigests.values()); + public Set getTasks() { + return ImmutableSet.copyOf(this.tasks.values()); } public Task getById(String id) { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellAnnotation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellAnnotation.java index ad8648a8..0ce73492 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellAnnotation.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellAnnotation.java @@ -7,19 +7,28 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.jena.ext.com.google.common.collect.ImmutableSet; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSortedSet; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonDeserializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonSerializer; + @XmlRootElement(name = "cellAnnotation") public final class CellAnnotation { @XmlElement + @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) + @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) private final Map> candidates; @XmlElement + @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) + @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) private final Map> chosen; @SuppressWarnings("unused") diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellRelationAnnotation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellRelationAnnotation.java index 77025b4e..d531dbca 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellRelationAnnotation.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellRelationAnnotation.java @@ -7,18 +7,27 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.jena.ext.com.google.common.collect.ImmutableSet; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSortedSet; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonDeserializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonSerializer; + @XmlRootElement(name = "cellRelationAnnotation") public final class CellRelationAnnotation { @XmlElement + @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) + @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) private final Map> candidates; @XmlElement + @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) + @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) private final Map> chosen; @SuppressWarnings("unused") diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/ColumnRelationAnnotation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/ColumnRelationAnnotation.java index ccac4cf9..48bc2fad 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/ColumnRelationAnnotation.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/ColumnRelationAnnotation.java @@ -7,18 +7,27 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.jena.ext.com.google.common.collect.ImmutableSet; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSortedSet; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonDeserializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonSerializer; + @XmlRootElement(name = "columnRelationAnnotation") public final class ColumnRelationAnnotation { @XmlElement + @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) + @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) private final Map> candidates; @XmlElement + @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) + @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) private final Map> chosen; @SuppressWarnings("unused") diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/HeaderAnnotation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/HeaderAnnotation.java index 5afa8f6a..8899dcd3 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/HeaderAnnotation.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/HeaderAnnotation.java @@ -7,18 +7,27 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.jena.ext.com.google.common.collect.ImmutableSet; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSortedSet; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonDeserializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonSerializer; + @XmlRootElement(name = "headerAnnotation") public final class HeaderAnnotation { @XmlElement + @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) + @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) private final Map> candidates; @XmlElement + @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) + @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) private final Map> chosen; @SuppressWarnings("unused") diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/KnowledgeBase.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/KnowledgeBase.java index 76a7356a..bf2eaf05 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/KnowledgeBase.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/KnowledgeBase.java @@ -2,7 +2,75 @@ import javax.xml.bind.annotation.XmlRootElement; +import com.google.common.base.Preconditions; + @XmlRootElement(name = "knowledgeBase") -public class KnowledgeBase { +public final class KnowledgeBase { + + private final String name; + + @SuppressWarnings("unused") + private KnowledgeBase() { + name = null; + } + + /** + * @param name + */ + public KnowledgeBase(String name) { + Preconditions.checkNotNull(name); + + this.name = name; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + KnowledgeBase other = (KnowledgeBase) obj; + if (name == null) { + if (other.name != null) { + return false; + } + } else if (!name.equals(other.name)) { + return false; + } + return true; + } + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "KnowledgeBase [name=" + name + "]"; + } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/URL.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/URL.java new file mode 100644 index 00000000..9e06ebb4 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/URL.java @@ -0,0 +1,14 @@ +package cz.cuni.mff.xrg.odalic.util; + +import java.net.MalformedURLException; + +import javax.ws.rs.core.UriInfo; + +public final class URL { + private URL() {} + + public static java.net.URL getResourceUrL(UriInfo requestUriInfo, String resourceName) + throws MalformedURLException { + return requestUriInfo.getAbsolutePath().resolve(resourceName).toURL(); + } +} diff --git a/odalic/src/main/resources/spring/applicationContext.xml b/odalic/src/main/resources/spring/applicationContext.xml index 5455ab20..70681755 100644 --- a/odalic/src/main/resources/spring/applicationContext.xml +++ b/odalic/src/main/resources/spring/applicationContext.xml @@ -17,16 +17,22 @@ to sti.properties file". --> + + - + - + + class="cz.cuni.mff.xrg.odalic.feedbacks.input.DefaultCsvInputParser" + scope="prototype" /> + class="cz.cuni.mff.xrg.odalic.tasks.results.DefaultAnnotationToResultAdapter" + scope="prototype" /> - + diff --git a/odalic/src/main/webapp/WEB-INF/web.xml b/odalic/src/main/webapp/WEB-INF/web.xml index 6b19bb97..eb59fd10 100644 --- a/odalic/src/main/webapp/WEB-INF/web.xml +++ b/odalic/src/main/webapp/WEB-INF/web.xml @@ -2,7 +2,7 @@ - Demo - Restful Web Application + Odalic @@ -35,6 +35,4 @@ jersey-servlet /* - - \ No newline at end of file From 60c477bff8c75af36ec962c67077be0649841ffc Mon Sep 17 00:00:00 2001 From: brodecva Date: Thu, 30 Jun 2016 15:27:11 +0200 Subject: [PATCH 038/211] Entity candidate serialization fix. --- ...pter.java => CellRelationAnnotationAdapter.java} | 2 +- .../api/rest/values/EntityCandidateValue.java | 13 ++++++++++++- .../odalic/tasks/annotations/CellAnnotation.java | 3 +++ .../tasks/annotations/CellRelationAnnotation.java | 4 ++++ .../tasks/annotations/ColumnRelationAnnotation.java | 3 +++ .../odalic/tasks/annotations/EntityCandidate.java | 6 ++++++ .../odalic/tasks/annotations/HeaderAnnotation.java | 3 +++ 7 files changed, 32 insertions(+), 2 deletions(-) rename odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/{CellRelationRelationAnnotationAdapter.java => CellRelationAnnotationAdapter.java} (93%) diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationRelationAnnotationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAnnotationAdapter.java similarity index 93% rename from odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationRelationAnnotationAdapter.java rename to odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAnnotationAdapter.java index 8b98c122..34390ef4 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationRelationAnnotationAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAnnotationAdapter.java @@ -18,7 +18,7 @@ import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; -public class CellRelationRelationAnnotationAdapter extends XmlAdapter { +public class CellRelationAnnotationAdapter extends XmlAdapter { @Override public CellRelationAnnotationValue marshal(CellRelationAnnotation bound) throws Exception { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityCandidateValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityCandidateValue.java index ae924ab4..e2c53b5c 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityCandidateValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityCandidateValue.java @@ -11,7 +11,7 @@ import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; import cz.cuni.mff.xrg.odalic.tasks.annotations.Likelihood; -public final class EntityCandidateValue implements Serializable { +public final class EntityCandidateValue implements Serializable, Comparable { private static final long serialVersionUID = 3072774254576336747L; @@ -95,4 +95,15 @@ public String toString() { return "EntityCandidateValue [entity=" + entity + ", likelihood=" + likelihood + ", chosen=" + chosen + "]"; } + + @Override + public int compareTo(EntityCandidateValue o) { + final int likelihoodComparison = likelihood.compareTo(o.likelihood); + + if (likelihoodComparison == 0) { + return entity.compareTo(o.entity); + } else { + return likelihoodComparison; + } + } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellAnnotation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellAnnotation.java index 0ce73492..a7ad86c1 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellAnnotation.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellAnnotation.java @@ -5,6 +5,7 @@ import java.util.Set; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.apache.jena.ext.com.google.common.collect.ImmutableSet; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; @@ -14,10 +15,12 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSortedSet; +import cz.cuni.mff.xrg.odalic.api.rest.adapters.CellAnnotationAdapter; import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonDeserializer; import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonSerializer; +@XmlJavaTypeAdapter(CellAnnotationAdapter.class) @XmlRootElement(name = "cellAnnotation") public final class CellAnnotation { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellRelationAnnotation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellRelationAnnotation.java index d531dbca..141601ec 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellRelationAnnotation.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellRelationAnnotation.java @@ -3,8 +3,10 @@ import java.util.Map; import java.util.NavigableSet; import java.util.Set; + import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.apache.jena.ext.com.google.common.collect.ImmutableSet; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; @@ -14,9 +16,11 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSortedSet; +import cz.cuni.mff.xrg.odalic.api.rest.adapters.CellRelationAnnotationAdapter; import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonDeserializer; import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonSerializer; +@XmlJavaTypeAdapter(CellRelationAnnotationAdapter.class) @XmlRootElement(name = "cellRelationAnnotation") public final class CellRelationAnnotation { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/ColumnRelationAnnotation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/ColumnRelationAnnotation.java index 48bc2fad..3c6e2c75 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/ColumnRelationAnnotation.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/ColumnRelationAnnotation.java @@ -5,6 +5,7 @@ import java.util.Set; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.apache.jena.ext.com.google.common.collect.ImmutableSet; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; @@ -14,9 +15,11 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSortedSet; +import cz.cuni.mff.xrg.odalic.api.rest.adapters.ColumnRelationAnnotationAdapter; import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonDeserializer; import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonSerializer; +@XmlJavaTypeAdapter(ColumnRelationAnnotationAdapter.class) @XmlRootElement(name = "columnRelationAnnotation") public final class ColumnRelationAnnotation { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/EntityCandidate.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/EntityCandidate.java index 0e26fa56..b3c87cad 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/EntityCandidate.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/EntityCandidate.java @@ -17,6 +17,12 @@ public final class EntityCandidate implements Comparable, Seria @XmlElement private final Likelihood likelihood; + @SuppressWarnings("unused") + private EntityCandidate() { + entity = null; + likelihood = null; + } + /** * @param entity * @param likelihood diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/HeaderAnnotation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/HeaderAnnotation.java index 8899dcd3..a5c2e6f0 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/HeaderAnnotation.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/HeaderAnnotation.java @@ -5,6 +5,7 @@ import java.util.Set; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.apache.jena.ext.com.google.common.collect.ImmutableSet; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; @@ -14,9 +15,11 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSortedSet; +import cz.cuni.mff.xrg.odalic.api.rest.adapters.HeaderAnnotationAdapter; import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonDeserializer; import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonSerializer; +@XmlJavaTypeAdapter(HeaderAnnotationAdapter.class) @XmlRootElement(name = "headerAnnotation") public final class HeaderAnnotation { From b1265bd419ade6a90aa23a5962b45eeef5fe37c0 Mon Sep 17 00:00:00 2001 From: brodecva Date: Thu, 30 Jun 2016 16:38:28 +0200 Subject: [PATCH 039/211] Execution fixes. --- odalic/pom.xml | 6 - .../FutureBasedExecutionService.java | 35 ++-- .../executions/TableMinerPlusFactory.java | 192 ++++++++---------- .../resources/spring/applicationContext.xml | 8 - 4 files changed, 104 insertions(+), 137 deletions(-) diff --git a/odalic/pom.xml b/odalic/pom.xml index fcbfc1f2..646afefa 100644 --- a/odalic/pom.xml +++ b/odalic/pom.xml @@ -14,7 +14,6 @@ 2.23.1 1.1.7 4.3.0.RELEASE - 1.7.2.RELEASE @@ -113,11 +112,6 @@ spring-aspects ${spring.version} - - org.aspectj - com.springsource.org.aspectj.weaver - ${weaver.version} - diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java index 3f1f4b0c..22fa5339 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java @@ -3,8 +3,6 @@ */ package cz.cuni.mff.xrg.odalic.tasks.executions; -import java.net.URISyntaxException; -import java.net.URL; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -14,12 +12,14 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; + +import org.apache.commons.io.FileUtils; import org.springframework.beans.factory.annotation.Autowired; import com.google.common.base.Preconditions; - import cz.cuni.mff.xrg.odalic.feedbacks.ColumnIgnore; import cz.cuni.mff.xrg.odalic.files.File; +import cz.cuni.mff.xrg.odalic.files.FileService; import cz.cuni.mff.xrg.odalic.tasks.Task; import cz.cuni.mff.xrg.odalic.tasks.TaskService; import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; @@ -37,6 +37,7 @@ public final class FutureBasedExecutionService implements ExecutionService { private final TaskService taskService; + private final FileService fileService; private final AnnotationToResultAdapter annotationResultAdapter; private final SemanticTableInterpreterFactory semanticTableInterpreterFactory; private final TableXtractorCSV tableExtractor; @@ -44,15 +45,17 @@ public final class FutureBasedExecutionService implements ExecutionService { private final Map> tasksToResults = new HashMap<>(); @Autowired - public FutureBasedExecutionService(TaskService taskService, + public FutureBasedExecutionService(TaskService taskService, FileService fileService, AnnotationToResultAdapter annotationToResultAdapter, SemanticTableInterpreterFactory semanticTableInterpreterFactory, TableXtractorCSV tableExtractor) { Preconditions.checkNotNull(taskService); + Preconditions.checkNotNull(fileService); Preconditions.checkNotNull(annotationToResultAdapter); Preconditions.checkNotNull(semanticTableInterpreterFactory); Preconditions.checkNotNull(tableExtractor); this.taskService = taskService; + this.fileService = fileService; this.annotationResultAdapter = annotationToResultAdapter; this.semanticTableInterpreterFactory = semanticTableInterpreterFactory; this.tableExtractor = tableExtractor; @@ -71,15 +74,19 @@ public void submitForTaskId(String id) { final Configuration configuration = task.getConfiguration(); final File file = configuration.getInput(); - final URL fileLocation = file.getLocation(); - final java.io.File inputFile = urlToFile(fileLocation); - + final Set columnIgnores = configuration.getFeedback().getColumnIgnores(); final Integer[] columnIgnoresArray = columnIgnores.stream().map(e -> e.getPosition().getIndex()).toArray(Integer[]::new); - + final Callable execution = () -> { - final List
tables = tableExtractor.extract(inputFile, inputFile.getName()); + final String data = fileService.getDataById(file.getId()); + + final java.io.File tempFile = java.io.File.createTempFile("odalic", "csv"); + tempFile.deleteOnExit(); + FileUtils.writeStringToFile(tempFile, data); + + final List
tables = tableExtractor.extract(tempFile, tempFile.getName()); if (tables.isEmpty()) { throw new IllegalArgumentException(); } @@ -97,16 +104,6 @@ public void submitForTaskId(String id) { tasksToResults.put(task, future); } - private java.io.File urlToFile(final URL fileLocation) { - java.io.File inputFile; - try { - inputFile = new java.io.File(fileLocation.toURI()); - } catch (URISyntaxException e) { - inputFile = new java.io.File(fileLocation.getPath()); - } - return inputFile; - } - @Override public Result getResultForTaskId(String id) throws InterruptedException, ExecutionException { final Task task = taskService.getById(id); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/TableMinerPlusFactory.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/TableMinerPlusFactory.java index e66823db..461a61cf 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/TableMinerPlusFactory.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/TableMinerPlusFactory.java @@ -17,8 +17,6 @@ import org.simmetrics.metrics.StringMetrics; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; - import uk.ac.shef.dcs.kbsearch.KBSearch; import uk.ac.shef.dcs.kbsearch.KBSearchFactory; import uk.ac.shef.dcs.sti.STIConstantProperty; @@ -55,18 +53,19 @@ public final class TableMinerPlusFactory implements SemanticTableInterpreterFact private static final String PROPERTY_TMP_SUBJECT_COLUMN_DETECTION_USE_WEBSEARCH = "sti.subjectcolumndetection.ws"; - private static final String PROPERTY_TMP_IINF_WEBSEARCH_STOPPING_CLASS = "sti.iinf.websearch.stopping.class"; + private static final String PROPERTY_TMP_IINF_WEBSEARCH_STOPPING_CLASS = + "sti.iinf.websearch.stopping.class"; private static final String PROPERTY_TMP_IINF_WEBSEARCH_STOPPING_CLASS_CONSTR_PARAM = "sti.iinf.websearch.stopping.class.constructor.params"; - private static final String PROPERTY_TMP_IINF_LEARNING_STOPPING_CLASS = "sti.tmp.iinf.learning.stopping.class"; + private static final String PROPERTY_TMP_IINF_LEARNING_STOPPING_CLASS = + "sti.tmp.iinf.learning.stopping.class"; private static final String PROPERTY_TMP_IINF_LEARNING_STOPPING_CLASS_CONSTR_PARAM = "sti.tmp.iinf.learning.stopping.class.constructor.params"; - + private static final Logger logger = LoggerFactory.getLogger(TableMinerPlusFactory.class); - @Value("${cz.cuni.mff.xrg.odalic.sti}") - private String propertyFilePath; + private static final String PROPERTY_FILE_PATH = System.getProperty("cz.cuni.mff.xrg.odalic.sti"); private SemanticTableInterpreter interpreter; @@ -79,7 +78,9 @@ public final class TableMinerPlusFactory implements SemanticTableInterpreterFact private EmbeddedSolrServer entityCache; private EmbeddedSolrServer websearchCache; - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see cz.cuni.mff.xrg.odalic.tasks.executions.InterpreterFactory#getInterpreter() */ @Override @@ -93,9 +94,13 @@ public SemanticTableInterpreter getInterpreter() { } return interpreter; } - - /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.tasks.executions.InterpreterFactory#setIgnoreColumnsForInterpreter(java.lang.Integer[]) + + /* + * (non-Javadoc) + * + * @see + * cz.cuni.mff.xrg.odalic.tasks.executions.InterpreterFactory#setIgnoreColumnsForInterpreter(java. + * lang.Integer[]) */ @Override public void setIgnoreColumnsForInterpreter(Integer[] ignoreCols) { @@ -103,56 +108,52 @@ public void setIgnoreColumnsForInterpreter(Integer[] ignoreCols) { literalColumnTagger.setIgnoreColumns(ArrayUtils.toPrimitive(ignoreCols)); } - //Initialize kbsearcher, websearcher + // Initialize kbsearcher, websearcher private void initComponents() throws STIException, IOException { properties = new Properties(); - properties.load(new FileInputStream(propertyFilePath)); + properties.load(new FileInputStream(PROPERTY_FILE_PATH)); logger.info("Initializing entity cache..."); EmbeddedSolrServer kbEntityServer = getSolrServerCacheEntity(); - //object to fetch things from KB + // object to fetch things from KB logger.info("Initializing KBSearch..."); KBSearchFactory fbf = new KBSearchFactory(); try { - kbSearch = fbf.createInstance( - getAbsolutePath(PROPERTY_KBSEARCH_PROP_FILE), - kbEntityServer, null, null,null); + kbSearch = fbf.createInstance(getAbsolutePath(PROPERTY_KBSEARCH_PROP_FILE), kbEntityServer, + null, null, null); } catch (Exception e) { e.printStackTrace(); logger.error(ExceptionUtils.getFullStackTrace(e)); - throw new STIException("Failed initialising KBSearch:" + - getAbsolutePath(PROPERTY_KBSEARCH_PROP_FILE) - , e); + throw new STIException( + "Failed initialising KBSearch:" + getAbsolutePath(PROPERTY_KBSEARCH_PROP_FILE), e); } - //LOG.info("Initializing WebSearcher..."); + // LOG.info("Initializing WebSearcher..."); logger.info("Initializing SUBJECT COLUMN DETECTION components ..."); SubjectColumnDetector subcolDetector; try { - subcolDetector = new SubjectColumnDetector( - new TContentTContentRowRankerImpl(), + subcolDetector = new SubjectColumnDetector(new TContentTContentRowRankerImpl(), properties.getProperty(PROPERTY_TMP_IINF_WEBSEARCH_STOPPING_CLASS), - StringUtils.split(properties.getProperty(PROPERTY_TMP_IINF_WEBSEARCH_STOPPING_CLASS_CONSTR_PARAM), - ','), - //new String[]{"0.0", "1", "0.01"}, - getSolrServerCacheWebsearch(), - getNLPResourcesDir(), - Boolean.valueOf(properties.getProperty(PROPERTY_TMP_SUBJECT_COLUMN_DETECTION_USE_WEBSEARCH)), - //"/BlhLSReljQ3Koh+vDSOaYMji9/Ccwe/7/b9mGJLwDQ="); //zqz.work - //"fXhmgvVQnz1aLBti87+AZlPYDXcQL0G9L2dVAav+aK0="); //ziqizhang - getStopwords(), - getAbsolutePath(PROPERTY_WEBSEARCH_PROP_FILE) - //, lodie - //"7ql9acl+fXXfdjBGIIAH+N2WHk/dIZxdSkl4Uur68Hg" - );// dobs + StringUtils.split( + properties.getProperty(PROPERTY_TMP_IINF_WEBSEARCH_STOPPING_CLASS_CONSTR_PARAM), ','), + // new String[]{"0.0", "1", "0.01"}, + getSolrServerCacheWebsearch(), getNLPResourcesDir(), + Boolean + .valueOf(properties.getProperty(PROPERTY_TMP_SUBJECT_COLUMN_DETECTION_USE_WEBSEARCH)), + // "/BlhLSReljQ3Koh+vDSOaYMji9/Ccwe/7/b9mGJLwDQ="); //zqz.work + // "fXhmgvVQnz1aLBti87+AZlPYDXcQL0G9L2dVAav+aK0="); //ziqizhang + getStopwords(), getAbsolutePath(PROPERTY_WEBSEARCH_PROP_FILE) + // , lodie + // "7ql9acl+fXXfdjBGIIAH+N2WHk/dIZxdSkl4Uur68Hg" + );// dobs } catch (Exception e) { e.printStackTrace(); logger.error(ExceptionUtils.getFullStackTrace(e)); - throw new STIException("Failed initialising SUBJECT COLUMN DETECTION components:" + properties.getProperty(PROPERTY_WEBSEARCH_PROP_FILE) - , e); + throw new STIException("Failed initialising SUBJECT COLUMN DETECTION components:" + + properties.getProperty(PROPERTY_WEBSEARCH_PROP_FILE), e); } @@ -164,90 +165,70 @@ private void initComponents() throws STIException, IOException { LEARNING learning; try { disambiguator = new TCellDisambiguator(kbSearch, - new TMPEntityScorer( - getStopwords(), - STIConstantProperty.SCORER_ENTITY_CONTEXT_WEIGHT, //row, column, column header, tablecontext all + new TMPEntityScorer(getStopwords(), STIConstantProperty.SCORER_ENTITY_CONTEXT_WEIGHT, // row, + // column, + // column + // header, + // tablecontext + // all getNLPResourcesDir())); - classifier = new TColumnClassifier(new TMPClazzScorer(getNLPResourcesDir(), - new FreebaseConceptBoWCreator(), - getStopwords(), - STIConstantProperty.SCORER_CLAZZ_CONTEXT_WEIGHT) //all 1.0 - ); //header, column, out trivial, out important + classifier = new TColumnClassifier( + new TMPClazzScorer(getNLPResourcesDir(), new FreebaseConceptBoWCreator(), getStopwords(), + STIConstantProperty.SCORER_CLAZZ_CONTEXT_WEIGHT) // all 1.0 + ); // header, column, out trivial, out important selector = new OSPD_nonEmpty(); - preliminaryClassify = new LEARNINGPreliminaryColumnClassifier( - selector, + preliminaryClassify = new LEARNINGPreliminaryColumnClassifier(selector, properties.getProperty(PROPERTY_TMP_IINF_LEARNING_STOPPING_CLASS), StringUtils.split( - properties.getProperty(PROPERTY_TMP_IINF_LEARNING_STOPPING_CLASS_CONSTR_PARAM), - ','), - kbSearch, - disambiguator, - classifier - ); - LEARNINGPreliminaryDisamb preliminaryDisamb = new LEARNINGPreliminaryDisamb( - kbSearch, disambiguator, classifier - ); - - learning = new LEARNING( - preliminaryClassify, preliminaryDisamb); + properties.getProperty(PROPERTY_TMP_IINF_LEARNING_STOPPING_CLASS_CONSTR_PARAM), ','), + kbSearch, disambiguator, classifier); + LEARNINGPreliminaryDisamb preliminaryDisamb = + new LEARNINGPreliminaryDisamb(kbSearch, disambiguator, classifier); + + learning = new LEARNING(preliminaryClassify, preliminaryDisamb); } catch (Exception e) { e.printStackTrace(); logger.error(ExceptionUtils.getFullStackTrace(e)); - throw new STIException("Failed initialising LEARNING components:" - , e); + throw new STIException("Failed initialising LEARNING components:", e); } logger.info("Initializing UPDATE components ..."); UPDATE update; try { - update = - new UPDATE(selector, kbSearch, disambiguator, classifier, getStopwords(), getNLPResourcesDir()); + update = new UPDATE(selector, kbSearch, disambiguator, classifier, getStopwords(), + getNLPResourcesDir()); } catch (Exception e) { e.printStackTrace(); logger.error(ExceptionUtils.getFullStackTrace(e)); - throw new STIException("Failed initialising LEARNING components:" - , e); + throw new STIException("Failed initialising LEARNING components:", e); } logger.info("Initializing RELATIONLEARNING components ..."); RelationScorer relationScorer = null; TColumnColumnRelationEnumerator relationEnumerator = null; - + try { - //object to computeElementScores relations between columns - relationScorer = new TMPRelationScorer( - getNLPResourcesDir(), - new FreebaseRelationBoWCreator(), - getStopwords(), - STIConstantProperty.SCORER_RELATION_CONTEXT_WEIGHT - // new double[]{1.0, 1.0, 0.0, 0.0, 1.0} - ); + // object to computeElementScores relations between columns + relationScorer = new TMPRelationScorer(getNLPResourcesDir(), new FreebaseRelationBoWCreator(), + getStopwords(), STIConstantProperty.SCORER_RELATION_CONTEXT_WEIGHT + // new double[]{1.0, 1.0, 0.0, 0.0, 1.0} + ); relationEnumerator = new TColumnColumnRelationEnumerator( - new AttributeValueMatcher( - STIConstantProperty.ATTRIBUTE_MATCHER_MIN_SCORE, getStopwords(), + new AttributeValueMatcher(STIConstantProperty.ATTRIBUTE_MATCHER_MIN_SCORE, getStopwords(), StringMetrics.levenshtein()), - relationScorer - ); - - //object to consolidate previous output, further computeElementScores columns and disambiguate entities - literalColumnTagger = - new LiteralColumnTaggerImpl( - getIgnoreColumns() - ); + relationScorer); + + // object to consolidate previous output, further computeElementScores columns and + // disambiguate entities + literalColumnTagger = new LiteralColumnTaggerImpl(getIgnoreColumns()); } catch (Exception e) { } - interpreter = new TMPInterpreter( - subcolDetector, - learning, - update, - relationEnumerator, - literalColumnTagger, - getIgnoreColumns(), getMustdoColumns() - ); + interpreter = new TMPInterpreter(subcolDetector, learning, update, relationEnumerator, + literalColumnTagger, getIgnoreColumns(), getMustdoColumns()); } @@ -255,14 +236,15 @@ private EmbeddedSolrServer getSolrServerCacheEntity() throws STIException { if (entityCache == null) { String solrHomePath = properties.getProperty(PROPERTY_CACHE_FOLDER); if (solrHomePath == null || !new File(solrHomePath).exists()) { - String error = "Cannot proceed: the cache dir is not set or does not exist. " + - PROPERTY_CACHE_FOLDER + "=" + solrHomePath; + String error = "Cannot proceed: the cache dir is not set or does not exist. " + + PROPERTY_CACHE_FOLDER + "=" + solrHomePath; logger.error(error); throw new STIException(error); } if (cores == null) { - entityCache = new EmbeddedSolrServer(Paths.get(solrHomePath), PROPERTY_ENTITY_CACHE_CORENAME); + entityCache = + new EmbeddedSolrServer(Paths.get(solrHomePath), PROPERTY_ENTITY_CACHE_CORENAME); cores = entityCache.getCoreContainer(); } else entityCache = new EmbeddedSolrServer(cores.getCore(PROPERTY_ENTITY_CACHE_CORENAME)); @@ -273,14 +255,16 @@ private EmbeddedSolrServer getSolrServerCacheEntity() throws STIException { private EmbeddedSolrServer getSolrServerCacheWebsearch() throws STIException { if (websearchCache == null) { String solrHomePath = properties.getProperty(PROPERTY_CACHE_FOLDER); - if (solrHomePath == null || !new File(solrHomePath).exists() || PROPERTY_RELATION_CACHE_CORENAME == null) { - String error = "Cannot proceed: the cache dir is not set or does not exist. " + - PROPERTY_CACHE_FOLDER + "=" + solrHomePath; + if (solrHomePath == null || !new File(solrHomePath).exists() + || PROPERTY_RELATION_CACHE_CORENAME == null) { + String error = "Cannot proceed: the cache dir is not set or does not exist. " + + PROPERTY_CACHE_FOLDER + "=" + solrHomePath; logger.error(error); throw new STIException(error); } if (cores == null) { - websearchCache = new EmbeddedSolrServer(Paths.get(solrHomePath), PROPERTY_WEBSEARCH_CACHE_CORENAME); + websearchCache = + new EmbeddedSolrServer(Paths.get(solrHomePath), PROPERTY_WEBSEARCH_CACHE_CORENAME); cores = websearchCache.getCoreContainer(); } else websearchCache = new EmbeddedSolrServer(cores.getCore(PROPERTY_WEBSEARCH_CACHE_CORENAME)); @@ -291,8 +275,8 @@ private EmbeddedSolrServer getSolrServerCacheWebsearch() throws STIException { private String getNLPResourcesDir() throws STIException { String prop = getAbsolutePath(PROPERTY_NLP_RESOURCES); if (prop == null || !new File(prop).exists()) { - String error = "Cannot proceed: nlp resources folder is not set or does not exist. " + - PROPERTY_KBSEARCH_PROP_FILE + "=" + prop; + String error = "Cannot proceed: nlp resources folder is not set or does not exist. " + + PROPERTY_KBSEARCH_PROP_FILE + "=" + prop; logger.error(error); throw new STIException(error); } @@ -304,8 +288,8 @@ private List getStopwords() throws STIException, IOException { } private String getAbsolutePath(String propertyName) { - return properties.getProperty(PROPERTY_HOME) - + File.separator + properties.getProperty(propertyName); + return properties.getProperty(PROPERTY_HOME) + File.separator + + properties.getProperty(propertyName); } private int[] getIgnoreColumns() { diff --git a/odalic/src/main/resources/spring/applicationContext.xml b/odalic/src/main/resources/spring/applicationContext.xml index 70681755..092bf6a1 100644 --- a/odalic/src/main/resources/spring/applicationContext.xml +++ b/odalic/src/main/resources/spring/applicationContext.xml @@ -11,14 +11,6 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> - - - - - Date: Thu, 30 Jun 2016 18:09:21 +0200 Subject: [PATCH 040/211] Guava conflict fixed. --- odalic/pom.xml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/odalic/pom.xml b/odalic/pom.xml index 646afefa..825db6bb 100644 --- a/odalic/pom.xml +++ b/odalic/pom.xml @@ -41,7 +41,19 @@ uk.ac.shef.dcs sti - 1.0alpha + 1.0 + + + guava-jdk5 + com.google.guava + + + + + + com.google.guava + guava + 19.0 From 77e8924de0990e23956b5e83e41b4fe2add24136 Mon Sep 17 00:00:00 2001 From: brodecva Date: Fri, 1 Jul 2016 15:28:29 +0200 Subject: [PATCH 041/211] Parser forced to use UTF8 as the detection is broken. --- .../java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsv.java | 6 ++++-- odalic/pom.xml | 6 +----- .../mff/xrg/odalic/api/rest/values/ConfigurationValue.java | 5 ++++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsv.java b/core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsv.java index ee27d123..eb281766 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsv.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsv.java @@ -3,6 +3,7 @@ import cern.colt.matrix.ObjectMatrix2D; import java.io.*; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -75,8 +76,9 @@ public boolean quotesRequired(String csvColumn, CsvContext context, CsvPreferenc //Charset decoder 1 TestDetector td = new TestDetector(); - String encoding = td.detect(inFile); - Charset charset = Charset.forName(encoding); + //String encoding = td.detect(inFile); + //Charset charset = Charset.forName(encoding); + Charset charset = StandardCharsets.UTF_8; // Charset charset = Charset.forName("ISO-8859-1"); //Charset decoder 2 diff --git a/odalic/pom.xml b/odalic/pom.xml index 825db6bb..6f7c81fe 100644 --- a/odalic/pom.xml +++ b/odalic/pom.xml @@ -29,11 +29,6 @@ Java.net Repository for Maven http://download.java.net/maven/2/ - - com.springsource.repository.bundles.external - SpringSource Enterprise Bundle Repository - External Bundle Releases - http://repository.springsource.com/maven/bundles/external - @@ -50,6 +45,7 @@ + com.google.guava guava diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java index 1a3c9a32..8748a6e0 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java @@ -2,6 +2,7 @@ import java.io.Serializable; +import javax.annotation.Nullable; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -9,7 +10,7 @@ import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; @XmlRootElement(name = "configuration") -public class ConfigurationValue implements Serializable { +public final class ConfigurationValue implements Serializable { private static final long serialVersionUID = -6359038623760039155L; @@ -33,6 +34,7 @@ public ConfigurationValue(Configuration adaptee) { /** * @return the input */ + @Nullable public String getInput() { return input; } @@ -40,6 +42,7 @@ public String getInput() { /** * @return the feedback */ + @Nullable public Feedback getFeedback() { return feedback; } From 8652ef95682f9ac0fb9f3302767f3a76c78f7480 Mon Sep 17 00:00:00 2001 From: brodecva Date: Mon, 4 Jul 2016 15:41:45 +0200 Subject: [PATCH 042/211] Draft dropped (for now), file logging switched off for core. --- core/log4j.properties | 6 ++--- core/src/main/java/log4j.properties | 6 ++--- .../xrg/odalic/api/rest/Configuration.java | 2 -- .../rest/resources/ConfigurationResource.java | 8 ++++++- .../api/rest/resources/DraftResource.java | 22 ------------------- .../odalic/api/rest/values/FeedbackValue.java | 14 ++++++------ .../mff/xrg/odalic/feedbacks/Feedback.java | 15 ++++--------- .../tasks/configurations/Configuration.java | 13 +---------- .../mff/xrg/odalic/tasks/drafts/Draft.java | 10 --------- .../xrg/odalic/tasks/drafts/DraftService.java | 7 ------ .../odalic/tasks/drafts/DraftServiceImpl.java | 10 --------- .../xrg/odalic/tasks/executions/State.java | 8 +++---- .../resources/spring/applicationContext.xml | 2 -- 13 files changed, 29 insertions(+), 94 deletions(-) delete mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/DraftResource.java delete mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/Draft.java delete mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftService.java delete mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftServiceImpl.java diff --git a/core/log4j.properties b/core/log4j.properties index 7715bfbc..c2849bb6 100644 --- a/core/log4j.properties +++ b/core/log4j.properties @@ -1,6 +1,6 @@ # Root logger option # switch logging level for other options(TRACE, DEBUG, INFO, WARN, ERROR, FATAL) -log4j.rootLogger=ERROR, file, stdout +log4j.rootLogger=ERROR, stdout # Direct LOG messages to a LOG file log4j.appender.file=org.apache.log4j.RollingFileAppender @@ -10,8 +10,8 @@ log4j.appender.file.MaxBackupIndex=10 log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n -log4j.logger.uk.ac.shef.dcs=INFO,myappender -log4j.logger.uk.ac.shef.dcs.kbsearch=INFO,myappender +log4j.logger.uk.ac.shef.dcs=INFO +log4j.logger.uk.ac.shef.dcs.kbsearch=INFO,stdout # Direct LOG messages to stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender diff --git a/core/src/main/java/log4j.properties b/core/src/main/java/log4j.properties index 841060bc..324fc993 100644 --- a/core/src/main/java/log4j.properties +++ b/core/src/main/java/log4j.properties @@ -1,6 +1,6 @@ # Root logger option # switch logging level for other options(TRACE, DEBUG, INFO, WARN, ERROR, FATAL) -log4j.rootLogger=ERROR, file, stdout +log4j.rootLogger=ERROR, stdout # Direct LOG messages to a LOG file log4j.appender.file=org.apache.log4j.RollingFileAppender @@ -10,8 +10,8 @@ log4j.appender.file.MaxBackupIndex=10 log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n -log4j.logger.uk.ac.shef.dcs.sti=INFO,myappender -log4j.logger.org.apache.lucene.analysis.sti=INFO,myappender,stdout +log4j.logger.uk.ac.shef.dcs.sti=INFO +log4j.logger.org.apache.lucene.analysis.sti=INFO,stdout # Direct LOG messages to stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java index 776af0e4..5c7a596d 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java @@ -14,7 +14,6 @@ import cz.cuni.mff.xrg.odalic.api.rest.filters.CorsResponseFilter; import cz.cuni.mff.xrg.odalic.api.rest.filters.LoggingResponseFilter; import cz.cuni.mff.xrg.odalic.api.rest.resources.ConfigurationResource; -import cz.cuni.mff.xrg.odalic.api.rest.resources.DraftResource; import cz.cuni.mff.xrg.odalic.api.rest.resources.ExecutionResource; import cz.cuni.mff.xrg.odalic.api.rest.resources.FeedbackResource; import cz.cuni.mff.xrg.odalic.api.rest.resources.FileResource; @@ -31,7 +30,6 @@ public Configuration() throws JAXBException { register(TaskResource.class); register(ConfigurationResource.class); register(FeedbackResource.class); - register(DraftResource.class); register(ExecutionResource.class); register(ResultResource.class); register(StateResource.class); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ConfigurationResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ConfigurationResource.java index 43eac8a4..3f54122d 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ConfigurationResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ConfigurationResource.java @@ -34,7 +34,13 @@ public class ConfigurationResource { public Response putConfigurationForTaskId(@PathParam("id") String id, ConfigurationValue configurationValue) { final File input = fileService.getById(configurationValue.getInput()); - final Configuration configuration = new Configuration(input, configurationValue.getFeedback()); + + final Configuration configuration; + if (configurationValue.getFeedback() == null) { + configuration = new Configuration(input); + } else { + configuration = new Configuration(input, configurationValue.getFeedback()); + } configurationService.setForTaskId(id, configuration); return Response.status(Response.Status.OK).entity("Configuration set.").build(); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/DraftResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/DraftResource.java deleted file mode 100644 index 2f9cacce..00000000 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/DraftResource.java +++ /dev/null @@ -1,22 +0,0 @@ -package cz.cuni.mff.xrg.odalic.api.rest.resources; - -import javax.ws.rs.Path; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import cz.cuni.mff.xrg.odalic.tasks.drafts.DraftService; - -@Component -@Path("/tasks/{id}/draft") -public class DraftResource { - - @SuppressWarnings("unused") - private DraftService draftService; - - //TODO: Methods. - - @Autowired - public DraftResource(DraftService draftService) { - this.draftService = draftService; - } -} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/FeedbackValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/FeedbackValue.java index ca86c561..cae42ffa 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/FeedbackValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/FeedbackValue.java @@ -97,7 +97,7 @@ public Set getColumnIgnores() { /** * @param columnIgnores the columnIgnores to set */ - public void setColumnIgnores(Set columnIgnores) { + public void setColumnIgnores(Set columnIgnores) { Preconditions.checkNotNull(columnIgnores); this.columnIgnores = ImmutableSet.copyOf(columnIgnores); @@ -113,7 +113,7 @@ public Set getColumnAmbiguities() { /** * @param columnAmbiguities the columnAmbiguities to set */ - public void setColumnAmbiguities(Set columnAmbiguities) { + public void setColumnAmbiguities(Set columnAmbiguities) { Preconditions.checkNotNull(columnAmbiguities); this.columnAmbiguities = ImmutableSet.copyOf(columnAmbiguities); @@ -129,7 +129,7 @@ public Set getClassifications() { /** * @param classifications the classifications to set */ - public void setClassifications(Set classifications) { + public void setClassifications(Set classifications) { Preconditions.checkNotNull(classifications); this.classifications = ImmutableSet.copyOf(classifications); @@ -145,7 +145,7 @@ public Set getCellRelations() { /** * @param cellRelations the cellRelations to set */ - public void setCellRelations(Set cellRelations) { + public void setCellRelations(Set cellRelations) { Preconditions.checkNotNull(cellRelations); this.cellRelations = ImmutableSet.copyOf(cellRelations); @@ -161,7 +161,7 @@ public Set getColumnRelations() { /** * @param columnRelations the columnRelations to set */ - public void setColumnRelations(Set columnRelations) { + public void setColumnRelations(Set columnRelations) { Preconditions.checkNotNull(columnRelations); this.columnRelations = ImmutableSet.copyOf(columnRelations); @@ -177,7 +177,7 @@ public Set getDisambiguations() { /** * @param disambiguations the disambiguations to set */ - public void setDisambiguations(Set disambiguations) { + public void setDisambiguations(Set disambiguations) { Preconditions.checkNotNull(disambiguations); this.disambiguations = ImmutableSet.copyOf(disambiguations); @@ -193,7 +193,7 @@ public Set getAmbiguities() { /** * @param ambiguities the ambiguities to set */ - public void setAmbiguities(Set ambiguities) { + public void setAmbiguities(Set ambiguities) { Preconditions.checkNotNull(ambiguities); this.ambiguities = ImmutableSet.copyOf(ambiguities); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java index f628bde5..6b3918f1 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java @@ -4,40 +4,33 @@ import java.util.Set; import javax.annotation.Nullable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableSet; +import cz.cuni.mff.xrg.odalic.api.rest.adapters.FeedbackAdapter; import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; -@XmlRootElement(name = "feedback") +@XmlJavaTypeAdapter(FeedbackAdapter.class) public final class Feedback implements Serializable { private static final long serialVersionUID = -6359038623760039155L; - @XmlElement private final ColumnPosition subjectColumnPosition; - @XmlElement private final Set columnIgnores; - @XmlElement private final Set classifications; - @XmlElement private final Set columnAmbiguities; - @XmlElement private final Set ambiguities; - @XmlElement private final Set disambiguations; - @XmlElement private final Set cellRelations; - @XmlElement private final Set columnRelations; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java index 93dbbb4c..eb75355b 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java @@ -1,8 +1,6 @@ package cz.cuni.mff.xrg.odalic.tasks.configurations; import java.io.Serializable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import com.google.common.base.Preconditions; @@ -12,23 +10,14 @@ import cz.cuni.mff.xrg.odalic.files.File; @XmlJavaTypeAdapter(ConfigurationAdapter.class) -@XmlRootElement(name = "configuration") -public class Configuration implements Serializable { +public final class Configuration implements Serializable { private static final long serialVersionUID = -6359038623760039155L; - @XmlElement(name = "input") private final File input; - @XmlElement(name = "feedback") private final Feedback feedback; - @SuppressWarnings("unused") - private Configuration() { - input = null; - feedback = new Feedback(); - } - public Configuration(File input) { Preconditions.checkNotNull(input); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/Draft.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/Draft.java deleted file mode 100644 index ede05d79..00000000 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/Draft.java +++ /dev/null @@ -1,10 +0,0 @@ -package cz.cuni.mff.xrg.odalic.tasks.drafts; - -import java.io.Serializable; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement -public class Draft implements Serializable { - - private static final long serialVersionUID = -6359038623760039155L; -} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftService.java deleted file mode 100644 index 377ce832..00000000 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftService.java +++ /dev/null @@ -1,7 +0,0 @@ -package cz.cuni.mff.xrg.odalic.tasks.drafts; - -public interface DraftService { - - - -} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftServiceImpl.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftServiceImpl.java deleted file mode 100644 index 16368cf9..00000000 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/drafts/DraftServiceImpl.java +++ /dev/null @@ -1,10 +0,0 @@ -/** - * - */ -package cz.cuni.mff.xrg.odalic.tasks.drafts; - -/** - * @author Václav Brodec - * - */ -public final class DraftServiceImpl implements DraftService {} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/State.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/State.java index 9c17f999..a252f7ae 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/State.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/State.java @@ -9,8 +9,8 @@ @XmlEnum(String.class) @XmlRootElement public enum State { - @XmlEnumValue("1") READY, - @XmlEnumValue("2") SCHEDULED, - @XmlEnumValue("3") CANCELLED, - @XmlEnumValue("4") FINISHED + @XmlEnumValue("READY") READY, + @XmlEnumValue("SCHEDULED") SCHEDULED, + @XmlEnumValue("CANCELLED") CANCELLED, + @XmlEnumValue("FINISHED") FINISHED } diff --git a/odalic/src/main/resources/spring/applicationContext.xml b/odalic/src/main/resources/spring/applicationContext.xml index 092bf6a1..74fed33b 100644 --- a/odalic/src/main/resources/spring/applicationContext.xml +++ b/odalic/src/main/resources/spring/applicationContext.xml @@ -29,7 +29,6 @@ - - Date: Mon, 4 Jul 2016 19:05:23 +0200 Subject: [PATCH 043/211] #72 - TAnnotation to Result conversion --- .../odalic/api/rest/values/EntityValue.java | 8 +- .../xrg/odalic/tasks/annotations/Entity.java | 26 +-- .../DefaultAnnotationToResultAdapter.java | 203 +++++++++++++++++- 3 files changed, 214 insertions(+), 23 deletions(-) diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityValue.java index 67e0bfa1..c205d285 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityValue.java @@ -17,7 +17,7 @@ public class EntityValue implements Serializable { private static final long serialVersionUID = 5750987769573292984L; @XmlElement - private URI resource; + private String resource; @XmlElement private String label; @@ -25,7 +25,7 @@ public class EntityValue implements Serializable { public EntityValue() {} public EntityValue(Entity adaptee) { - this.resource = adaptee.getResource(); + this.resource = adaptee.getResourceID(); this.label = adaptee.getLabel(); } @@ -33,14 +33,14 @@ public EntityValue(Entity adaptee) { * @return the resource */ @Nullable - public URI getResource() { + public String getResource() { return resource; } /** * @param resource the resource to set */ - public void setResouce(URI resource) { + public void setResouce(String resource) { Preconditions.checkNotNull(resource); this.resource = resource; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Entity.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Entity.java index 560d3553..317d6f1f 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Entity.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Entity.java @@ -19,27 +19,27 @@ public final class Entity implements Comparable, Serializable { private static final long serialVersionUID = -3001706805535088480L; @XmlElement - private final URI resource; + private final String resourceID; @XmlElement private final String label; @SuppressWarnings("unused") private Entity() { - resource = null; + resourceID = null; label = null; } - public Entity(URI resource, String label) { - Preconditions.checkNotNull(resource); + public Entity(String resourceID, String label) { + Preconditions.checkNotNull(resourceID); Preconditions.checkNotNull(label); - this.resource = resource; + this.resourceID = resourceID; this.label = label; } - public URI getResource() { - return resource; + public String getResourceID() { + return resourceID; } public String getLabel() { @@ -53,7 +53,7 @@ public String getLabel() { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((resource == null) ? 0 : resource.hashCode()); + result = prime * result + ((resourceID == null) ? 0 : resourceID.hashCode()); result = prime * result + ((label == null) ? 0 : label.hashCode()); return result; } @@ -73,11 +73,11 @@ public boolean equals(Object obj) { return false; } Entity other = (Entity) obj; - if (resource == null) { - if (other.resource != null) { + if (resourceID == null) { + if (other.resourceID != null) { return false; } - } else if (!resource.equals(other.resource)) { + } else if (!resourceID.equals(other.resourceID)) { return false; } if (label == null) { @@ -95,12 +95,12 @@ public boolean equals(Object obj) { */ @Override public String toString() { - return "Annotation [resource=" + resource + ", label=" + label + "]"; + return "Annotation [resourceID=" + resourceID + ", label=" + label + "]"; } @Override public int compareTo(Entity o) { - return resource.compareTo(o.resource); + return resourceID.compareTo(o.resourceID); } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/DefaultAnnotationToResultAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/DefaultAnnotationToResultAdapter.java index d63e8e77..295641b5 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/DefaultAnnotationToResultAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/DefaultAnnotationToResultAdapter.java @@ -1,13 +1,204 @@ package cz.cuni.mff.xrg.odalic.tasks.results; -import uk.ac.shef.dcs.sti.core.model.TAnnotation; +import cz.cuni.mff.xrg.odalic.positions.CellRelationPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; +import cz.cuni.mff.xrg.odalic.positions.RowPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.*; +import uk.ac.shef.dcs.kbsearch.model.Clazz; +import uk.ac.shef.dcs.sti.core.model.*; + +import java.util.*; +import java.util.List; public class DefaultAnnotationToResultAdapter implements AnnotationToResultAdapter { - @Override - public Result toResult(TAnnotation annotation) { - // TODO Missing implementation. - return null; - } + @Override + public Result toResult(TAnnotation original) { + // TODO: Pass this from the core + KnowledgeBase knowledgeBase = new KnowledgeBase("DBpedia"); + + List headerAnnotations = ConvertColumnAnnotations(original, knowledgeBase); + CellAnnotation[][] cellAnnotations = ConvertCellAnnotations(original, knowledgeBase); + Map columnRelations = ConvertColumnRelations(original, knowledgeBase); + Map cellCellRelations = ConvertCellRelations(original, knowledgeBase); + ColumnPosition subjectColumn = new ColumnPosition(original.getSubjectColumn()); + + Result result = new Result(subjectColumn, headerAnnotations, cellAnnotations, columnRelations, cellCellRelations); + + return result; + } + + Map ConvertCellRelations(TAnnotation original, KnowledgeBase knowledgeBase) { + Map cellCellRelations = new HashMap<>(); + for (Map.Entry>> columnAnnotations : original.getCellcellRelations().entrySet() ){ + for(Map.Entry> annotations : columnAnnotations.getValue().entrySet()){ + HashMap> candidates = new HashMap<>(); + HashMap> chosen = new HashMap<>(); + + Set candidatesSet = new HashSet<>(); + Set chosenSet = new HashSet<>(); + + candidates.put(knowledgeBase, candidatesSet); + chosen.put(knowledgeBase, chosenSet); + + EntityCandidate bestCandidate = null; + for (TCellCellRelationAnotation annotation : annotations.getValue()) { + Entity entity = new Entity(annotation.getRelationURI(), annotation.getRelationLabel()); + Likelihood likelihood = new Likelihood(annotation.getWinningAttributeMatchScore()); + + EntityCandidate candidate = new EntityCandidate(entity, likelihood); + + candidatesSet.add(candidate); + + if (bestCandidate == null || bestCandidate.getLikelihood().getValue() < candidate.getLikelihood().getValue()) { + bestCandidate = candidate; + } + } + + if (bestCandidate != null){ + chosenSet.add(bestCandidate); + } + + RelationColumns relationColumns = columnAnnotations.getKey(); + ColumnRelationPosition columnPosition = new ColumnRelationPosition(new ColumnPosition(relationColumns.getSubjectCol()), new ColumnPosition(relationColumns.getObjectCol())); + RowPosition rowPosition = new RowPosition(annotations.getKey()); + CellRelationPosition position = new CellRelationPosition(columnPosition, rowPosition); + CellRelationAnnotation relationAnnotation = new CellRelationAnnotation(candidates, chosen); + cellCellRelations.put(position, relationAnnotation); + } + } + return cellCellRelations; + } + + Map ConvertColumnRelations(TAnnotation original, KnowledgeBase knowledgeBase) { + Map columnRelations = new HashMap<>(); + for (Map.Entry> annotations : original.getColumncolumnRelations().entrySet() ){ + HashMap> candidates = new HashMap<>(); + HashMap> chosen = new HashMap<>(); + + Set candidatesSet = new HashSet<>(); + Set chosenSet = new HashSet<>(); + + candidates.put(knowledgeBase, candidatesSet); + chosen.put(knowledgeBase, chosenSet); + + EntityCandidate bestCandidate = null; + for (TColumnColumnRelationAnnotation annotation : annotations.getValue()) { + Entity entity = new Entity(annotation.getRelationURI(), annotation.getRelationLabel()); + Likelihood likelihood = new Likelihood(annotation.getFinalScore()); + + EntityCandidate candidate = new EntityCandidate(entity, likelihood); + + candidatesSet.add(candidate); + + if (bestCandidate == null || bestCandidate.getLikelihood().getValue() < candidate.getLikelihood().getValue()) { + bestCandidate = candidate; + } + } + + if (bestCandidate != null){ + chosenSet.add(bestCandidate); + } + + RelationColumns relationColumns = annotations.getKey(); + ColumnRelationPosition position = new ColumnRelationPosition(new ColumnPosition(relationColumns.getSubjectCol()), new ColumnPosition(relationColumns.getObjectCol())); + ColumnRelationAnnotation relationAnnotation = new ColumnRelationAnnotation(candidates, chosen); + columnRelations.put(position, relationAnnotation); + } + return columnRelations; + } + + CellAnnotation[][] ConvertCellAnnotations(TAnnotation original, KnowledgeBase knowledgeBase) { + int columnCount = original.getCols(); + int rowCount = original.getRows(); + CellAnnotation[][] cellAnnotations = new CellAnnotation[rowCount][columnCount]; + + for (int columnIndex = 0; columnIndex < columnCount; columnIndex++) { + for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) { + TCellAnnotation[] annotations = original.getContentCellAnnotations(rowIndex, columnIndex); + + HashMap> candidates = new HashMap<>(); + HashMap> chosen = new HashMap<>(); + + if (annotations != null) { + Set candidatesSet = new HashSet<>(); + Set chosenSet = new HashSet<>(); + + candidates.put(knowledgeBase, candidatesSet); + chosen.put(knowledgeBase, chosenSet); + + EntityCandidate bestCandidate = null; + for (TCellAnnotation annotation : annotations) { + uk.ac.shef.dcs.kbsearch.model.Entity clazz = annotation.getAnnotation(); + + Entity entity = new Entity(clazz.getId(), clazz.getLabel()); + Likelihood likelihood = new Likelihood(annotation.getFinalScore()); + + EntityCandidate candidate = new EntityCandidate(entity, likelihood); + + candidatesSet.add(candidate); + + if (bestCandidate == null || bestCandidate.getLikelihood().getValue() < candidate.getLikelihood().getValue()) { + bestCandidate = candidate; + } + } + + if (bestCandidate != null){ + chosenSet.add(bestCandidate); + } + } + + CellAnnotation cellAnnotation = new CellAnnotation(candidates, chosen); + cellAnnotations[rowIndex][columnIndex] = cellAnnotation; + } + } + + return cellAnnotations; + } + + List ConvertColumnAnnotations(TAnnotation original, KnowledgeBase knowledgeBase) { + int columnCount = original.getCols(); + List headerAnnotations = new ArrayList<>(columnCount); + + for (int columnIndex = 0; columnIndex < columnCount; columnIndex++) { + TColumnHeaderAnnotation[] annotations = original.getHeaderAnnotation(columnIndex); + + HashMap> candidates = new HashMap<>(); + HashMap> chosen = new HashMap<>(); + + if (annotations != null) { + Set candidatesSet = new HashSet<>(); + Set chosenSet = new HashSet<>(); + + candidates.put(knowledgeBase, candidatesSet); + chosen.put(knowledgeBase, chosenSet); + + EntityCandidate bestCandidate = null; + for (TColumnHeaderAnnotation annotation : annotations) { + Clazz clazz = annotation.getAnnotation(); + + Entity entity = new Entity(clazz.getId(), clazz.getLabel()); + Likelihood likelihood = new Likelihood(annotation.getFinalScore()); + + EntityCandidate candidate = new EntityCandidate(entity, likelihood); + + candidatesSet.add(candidate); + + if (bestCandidate == null || bestCandidate.getLikelihood().getValue() < candidate.getLikelihood().getValue()) { + bestCandidate = candidate; + } + } + + if (bestCandidate != null){ + chosenSet.add(bestCandidate); + } + } + + HeaderAnnotation headerAnnotation = new HeaderAnnotation(candidates, chosen); + headerAnnotations.add(headerAnnotation); + } + return headerAnnotations; + } } From bf5475e37d9ca908bbf30c495e8aee9a1c2726c9 Mon Sep 17 00:00:00 2001 From: brodecva Date: Mon, 4 Jul 2016 19:20:17 +0200 Subject: [PATCH 044/211] Feedback conversion NullPointerException fix. --- .../odalic/api/rest/resources/FileResource.java | 2 +- .../cuni/mff/xrg/odalic/feedbacks/Feedback.java | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java index 3c6dbd94..1ea1a68b 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java @@ -129,7 +129,7 @@ public Response putFileById(@PathParam("id") String id, File file) throws Malfor @POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) - public Response putFileById(@Context UriInfo uriInfo, + public Response postFile(@Context UriInfo uriInfo, @FormDataParam("file") InputStream fileInputStream, @FormDataParam("file") FormDataContentDisposition fileDetail) throws IOException { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java index 6b3918f1..5f584e4b 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java @@ -95,11 +95,10 @@ private static void checkMandatory(Set columnIgnores, * @param disambiguations * @param ambiguities */ - public Feedback(ColumnPosition subjectColumnPosition, Set columnIgnores, + public Feedback(@Nullable ColumnPosition subjectColumnPosition, Set columnIgnores, Set columnAmbiguities, Set classifications, Set cellRelations, Set columnRelations, Set disambiguations, Set ambiguities) { - Preconditions.checkNotNull(subjectColumnPosition); checkMandatory(columnIgnores, columnAmbiguities, classifications, cellRelations, columnRelations, disambiguations, ambiguities); this.subjectColumnPosition = subjectColumnPosition; @@ -124,49 +123,49 @@ public ColumnPosition getSubjectColumnPosition() { * @return the columnIgnores */ public Set getColumnIgnores() { - return ImmutableSet.copyOf(columnIgnores); + return columnIgnores; } /** * @return the columnAmbiguities */ public Set getColumnAmbiguities() { - return ImmutableSet.copyOf(columnAmbiguities); + return columnAmbiguities; } /** * @return the classifications */ public Set getClassifications() { - return ImmutableSet.copyOf(classifications); + return classifications; } /** * @return the cellRelations */ public Set getCellRelations() { - return ImmutableSet.copyOf(cellRelations); + return cellRelations; } /** * @return the columnRelations */ public Set getColumnRelations() { - return ImmutableSet.copyOf(columnRelations); + return columnRelations; } /** * @return the disambiguations */ public Set getDisambiguations() { - return ImmutableSet.copyOf(disambiguations); + return disambiguations; } /** * @return the ambiguities */ public Set getAmbiguities() { - return ImmutableSet.copyOf(ambiguities); + return ambiguities; } /* (non-Javadoc) From 450f9d090a62f6f4e935d8ed88c39fb5dafc08fd Mon Sep 17 00:00:00 2001 From: brodecva Date: Mon, 4 Jul 2016 20:03:04 +0200 Subject: [PATCH 045/211] Added constructor for TableMinerPlustFactory taking sti.properties path. --- .../tasks/executions/TableMinerPlusFactory.java | 17 +++++++++++++++-- .../executions/InterpreterExecutionBatch.java | 7 +++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/TableMinerPlusFactory.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/TableMinerPlusFactory.java index 461a61cf..3125753f 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/TableMinerPlusFactory.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/TableMinerPlusFactory.java @@ -17,6 +17,9 @@ import org.simmetrics.metrics.StringMetrics; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + +import com.google.common.base.Preconditions; + import uk.ac.shef.dcs.kbsearch.KBSearch; import uk.ac.shef.dcs.kbsearch.KBSearchFactory; import uk.ac.shef.dcs.sti.STIConstantProperty; @@ -65,7 +68,7 @@ public final class TableMinerPlusFactory implements SemanticTableInterpreterFact private static final Logger logger = LoggerFactory.getLogger(TableMinerPlusFactory.class); - private static final String PROPERTY_FILE_PATH = System.getProperty("cz.cuni.mff.xrg.odalic.sti"); + private final String propertyFilePath; private SemanticTableInterpreter interpreter; @@ -78,6 +81,16 @@ public final class TableMinerPlusFactory implements SemanticTableInterpreterFact private EmbeddedSolrServer entityCache; private EmbeddedSolrServer websearchCache; + public TableMinerPlusFactory(String propertyFilePath) { + Preconditions.checkNotNull(propertyFilePath); + + this.propertyFilePath = propertyFilePath; + } + + public TableMinerPlusFactory() { + this(System.getProperty("cz.cuni.mff.xrg.odalic.sti")); + } + /* * (non-Javadoc) * @@ -111,7 +124,7 @@ public void setIgnoreColumnsForInterpreter(Integer[] ignoreCols) { // Initialize kbsearcher, websearcher private void initComponents() throws STIException, IOException { properties = new Properties(); - properties.load(new FileInputStream(PROPERTY_FILE_PATH)); + properties.load(new FileInputStream(propertyFilePath)); logger.info("Initializing entity cache..."); EmbeddedSolrServer kbEntityServer = getSolrServerCacheEntity(); diff --git a/odalic/src/test/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterExecutionBatch.java b/odalic/src/test/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterExecutionBatch.java index 93c8c9ad..29790907 100644 --- a/odalic/src/test/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterExecutionBatch.java +++ b/odalic/src/test/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterExecutionBatch.java @@ -19,13 +19,16 @@ public class InterpreterExecutionBatch { public static void main(String[] args) { // for test of execution of semantic table interpreter from Odalic project - SemanticTableInterpreterFactory factory = new TableMinerPlusFactory(); + final String propertyFilePath = args[0]; + final String testFileDirectoryPath = args[1]; + + SemanticTableInterpreterFactory factory = new TableMinerPlusFactory(propertyFilePath); SemanticTableInterpreter semanticTableInterpreter = factory.getInterpreter(); Preconditions.checkNotNull(semanticTableInterpreter); factory.setIgnoreColumnsForInterpreter(new Integer[]{}); //TODO: Write your own path to the folder containing (only) the input file. - List all = Arrays.asList(new File("/Users/-/work/sti/sti_data/Limaye200").listFiles()); + List all = Arrays.asList(new File(testFileDirectoryPath).listFiles()); File inputFile = all.get(0); // code for extraction from CSV From 9410450e067a2d69aaba0778f260b5f5a715c33d Mon Sep 17 00:00:00 2001 From: JanVana Date: Tue, 5 Jul 2016 02:27:00 +0200 Subject: [PATCH 046/211] #70 - DBpedia configs --- configs/Jan/kbsearch.properties | 40 +++++++++++ configs/Jan/sti.properties | 119 +++++++++++++++++++++++++++++++ configs/Jan/websearch.properties | 18 +++++ 3 files changed, 177 insertions(+) create mode 100644 configs/Jan/kbsearch.properties create mode 100644 configs/Jan/sti.properties create mode 100644 configs/Jan/websearch.properties diff --git a/configs/Jan/kbsearch.properties b/configs/Jan/kbsearch.properties new file mode 100644 index 00000000..b5f8bde4 --- /dev/null +++ b/configs/Jan/kbsearch.properties @@ -0,0 +1,40 @@ +##################################### +# GENERIC VARIABLE # +##################################### +# A file (MUST BE ABSOLUTE PATH) that lists things (e.g., predicate URIs) to be used by an instance of uk.ac.shef.dcs.kbsearch.KBSearchResultFilter, which decides what triples/relations/classes to remove. Specific rules are implemented by subclasses of uk.ac.shef.dcs.kbsearch.KBSearchResultFilter, which should be instantiated as part of uk.ac.shef.dcs.kbsearch.KBSearch. Details of how the stoplist is used can be found in the kbstoplist.txt documentation +#kb.search.result.stoplistfile=/Users/-/work/sti/resources/kbstoplist.txt +kb.search.result.stoplistfile=d:\\Documents\\Odalic\\Sti\\resources\\kbstoplist_dbpedia.txt + +# Name of the implementation class of uk.ac.shef.dcs.kbsearch.KBSearch. This is responsible for querying the knowledge base +#kb.search.class=uk.ac.shef.dcs.kbsearch.freebase.FreebaseSearch +kb.search.class=uk.ac.shef.dcs.kbsearch.sparql.DBpediaSearch +# If a query keyword does not match to anything in a KB, you can try splitting if it contains conjunctive word "and","or". set to true if you want this +kb.search.tryfuzzykeyword=true + + +################################################################ +# Specific instance of uk.ac.shef.dcs.kbsearch.KBSearch # +################################################################ + +#>> An instance of uk.ac.shef.dcs.kbsearch.freebase.FreebaseSearch, uses Freebase API +# max number of queries allowed per second +fb.query.max.sec=10 +# max number of queries allowed per day +fb.query.max.day=100000 +# freebase api key. YOU SHOULD USE YOUR OWN +fb.query.api.key=AIzaSyAcL9jlS9czJrT0OLlWH24Od0mYrsycnSk +# access URL for the freebase mql api +fb.query.apiurl.mql=https://www.googleapis.com/freebase/v1/mqlread +# access URL for the freebase topic api +fb.query.apiurl.topic=https://www.googleapis.com/freebase/v1/topic +# access URL for the freebase search api +fb.query.apiurl.search=https://www.googleapis.com/freebase/v1/search +# freebase homepage +fb.homepage= +# number of results to obtain in the freebase query +fb.query.param.limit=1000 + + +dbp.sparql.endpoint=http://dbpedia.org/sparql +dbp.ontology.url=file:///d:/Documents/Odalic/Sti/resources/dbpedia_ontology_2014.owl + diff --git a/configs/Jan/sti.properties b/configs/Jan/sti.properties new file mode 100644 index 00000000..5d8980c7 --- /dev/null +++ b/configs/Jan/sti.properties @@ -0,0 +1,119 @@ +#################### +# FILE PATHS # +#################### +# STI home folder. All other file paths wil be relative to this (except otherwise stated). +sti.home=d:\\Documents\\Odalic\\Sti\\ +# Folder containing nlp resources (by default this is the '/resource' folder in the distribution) +sti.nlp=resources +# Folder containing cached data (must be ABSOLUTE PATH). Whenever KB search or Web search is performed, the query and results are cached in a Solr instance. This specifies the path to Solr. (by default this is the /cache/empty folder in the distribution. The folder contains only solr schemas, but no data. This means you can use them directly as long as you correct the path. And the system will begin with remotely querying KB or the Web and gradually builds up the cache). +sti.cache.main.dir=d:\\Documents\\Odalic\\Sti\\cache\\empty\\ +# Web search configuration file. By default this is located in the home folder of the distribution +sti.websearch.properties=configs\\Jan\\websearch.properties +# KB search configuration file. By default this is located in the home folder of the distribution +sti.kbsearch.propertyfile=configs\\Jan\\kbsearch.properties +# When STI is run in batch mode (e.g., processing a folder containing multiple input files, by using an instance of uk.ac.shef.dcs.sti.experiment.STIBatch), it loads in all files and sort them by file name. If for any input file the process failed due to any exception, the indexes of such files (as index of the file in the sorted list) are written to this provided file. +sti.list.failure=failed.txt +# Input files must be parsed to create an internal uk.ac.shef.dcs.sti.core.model.Table objects. Depending on the input data files, specific TableParser class must be implemented and specified here. The class must have a defult constructor that does not take any arguments +sti.input.parser.class=uk.ac.shef.dcs.sti.parser.table.TableParserLimayeDataset + + +#################################### +# SELECTIVE START (generic) # +#################################### +# STI tries to classify the data type of table columns, and typically only certain types of columns are passed for interpretation. While this process is highly accurate, it is not guaranteed to be perfect so in some occassions it is possible to have, e.g., NE-columns mis-classified as numeric, or long text. Therefore, for all input tables, if you know some columns should not be considered for interpretation, specify them here as a comma delimieted string. E.g, '0,1,5' will tell STI to ignore the first, 2nd and 6th columns in input tables. +sti.columns.ignore= +# Similar as the above, if you know some columns must be analyzed, you can provide their index here +sti.columns.mustdo= + + +################################ +# SELECTIVE START (batch) # +################################ +# when running in batch mode, instead of always processing the entire input folder, starting from the first file, it is possible to make the process selective by defining the following parameters + +# Given the input files read from a folder sorted by their file names, you can choose to start from a particular index position in the sorted list. The first file's index is 0. This is useful when, e.g., the previously process broke down and you want to continue from a particular position. The index position of each processed input file will be output in the log file +sti.start=0 +# Similar as above, you can provide a list of indexes representing the files you want to process. Note that if this variable is defined, ONLY THESE SPECIFIED files will be processed. This variable must be an absolute file path pointing to a plain text file, where each line is the index of a file in the sorted input folder. Leave this variable empty if you do not want to be selective +sti.list.select= + + +################################################ +# Subject column detection, the ws scorer # +################################################ + +# Whether STI should use the ws score in detecting subject column +sti.subjectcolumndetection.ws=true +# If ws is used, what stopping criteria class should be used +sti.iinf.websearch.stopping.class=uk.ac.shef.dcs.sti.core.algorithm.tmp.stopping.IInf +# if ws is used, for the stopping criteria class provided above, also provide its contructor parameters in the order it is defined in the class, delimited by , +sti.iinf.websearch.stopping.class.constructor.params=0.0,1,0.01 + + +######################## +# RELATION ENUMERATION # +######################## +# Choose whether or not STI should annotate relations +sti.learning.relation=true + +########## +# OUTPUT # +########## + +# What is the namespace that the KB uses +sti.output.triple.namespace.kb=www.freebase.org +# What is the namespace to use for newly extracted classes, relations and entities that are not available in the KB +sti.output.triple.namespace.default=www.shef.ac.uk + + + + + + +############################################################# +# TABLEMINER+: LEARNING (only needed if you run tableminer+ # +############################################################# +# What stopping criteria class should be used in the iinf for preliminary column classification +sti.tmp.iinf.learning.stopping.class=uk.ac.shef.dcs.sti.core.algorithm.tmp.stopping.IInf +# for the stopping criteria class provided above, also provide its contructor parameters in the order it is defined in the class values separated by , +sti.tmp.iinf.learning.stopping.class.constructor.params=0.0,1,0.05 + + + +############################################################# +# BASELINE: (only needed if you run baseline nm or sim) # +############################################################# +# what baseline method to use. Two options: nm=name match; sim=string similarity based +sti.baseline.method=sim +# if string similarity based baseline is used, define what string similarity metric to be used. This must be the name of the method of class org.simmetrics.metrics.StringMetrics (simmetrics library), which you want to call and obtain an instance of StringMetric +sti.baseline.similarity.stringmetrics.method=levenshtein + + + +############################################################# +# SEMANTIC MESSAGE PASSING: (only needed if you run smp) # +############################################################# +# whether smp should use tableminer+ subject column detection and use the information of subejct column in interpretation +sti.smp.usesubjectcolumn=false +# the choice of entity ranker to use. Two options: tmp to use the cell disambiguation method proposed by tableminer+; smpfreebase to use the method adapted from the original smp algorithm to Freebase +sti.smp.entityranker=smpfreebase +# maximum number of iterations in the semantic message passing phase. default is 10 if not provided +sti.smp.halting.maxiteration=10 +# when smp computes changemessages, it will check the score assigned to the annotations of the cell, column or relation. If the score is less than this threshold, it is considered 'unstable' and therefore a changemessage is created to indicate that in the next iteration, this cell/column/relation's annotation should be changed +sti.smp.changemessage.minscore=0.5 +# an implementation class of uk.ac.shef.dcs.sti.core.algorithm.smp.ClazzSpecificityCalculator, which should compute the specificity score of a class from the KB. This class will be created via reflection, so if new implementing classes are created, you must revise uk.ac.shef.dcs.sti.experiment.SemanticMessagePassingBatch getClazzSpecificityCalculator() method that is responsible for instance creation accordingly +sti.smp.clazzspecificitycalculator=uk.ac.shef.dcs.sti.core.algorithm.smp.FreebaseClazzSpecificityCalculator + + + + +############################################################# +# JOINT INFERENCE: (only needed if you run ji) # +############################################################# +# whether smp should use tableminer+ subject column detection and use the information of subejct column in interpretation +sti.ji.usesubjectcolumn=false +# the maximum number of iterations of joint inference. If set to 0, inference will continue until convergence (if possible) +sti.ji.maxiterations=0 +# if true additional procedure will be performed to check the consistency of the created factor graph and output additional logs +sti.ji.debugmode=false +# an implementation class of uk.ac.shef.dcs.sti.core.algorithm.smp.ClazzSpecificityCalculator, which should compute the specificity score of a class from the KB. This class will be created via reflection, so if new implementing classes are created, you must revise uk.ac.shef.dcs.sti.experiment.SemanticMessagePassingBatch getClazzSpecificityCalculator() method that is responsible for instance creation accordingly +sti.ji.clazzspecificitycalculator=uk.ac.shef.dcs.sti.core.algorithm.smp.FreebaseClazzSpecificityCalculator diff --git a/configs/Jan/websearch.properties b/configs/Jan/websearch.properties new file mode 100644 index 00000000..2b435f43 --- /dev/null +++ b/configs/Jan/websearch.properties @@ -0,0 +1,18 @@ + +################################# +# GENERIC VARIABLE # +################################# + +#What class should be use to do web search (used in subject column detection for computing the ws score). It must extend uk.ac.shef.dcs.websearch.WebSearch and uk.ac.shef.dcs.kbsearch.KBSearchFactory must be revised to instantiate it by reflection. +web.search.class=uk.ac.shef.dcs.websearch.bing.v2.BingSearch + + +############################################################################ +# Specific k.ac.shef.dcs.websearch.WebSearch instance configuration # +############################################################################ + +#>> For the instance of uk.ac.shef.dcs.websearch.bing.v2.BingSearch +#This is the API key to be used with BingSearch. You should apply for your own at: https://datamarket.azure.com/dataset/bing/searchweb (Bing Search API, Web Results Only) +bing.keys=I9K1ihpDVkrmX8w2SN08NS5kMZPTDvTi/St9yfl9vVQ +#Default URL to access Bing Search API (Web Results Only) +bing.url=https://api.datamarket.azure.com/Bing/SearchWeb/v1/Web?Query= \ No newline at end of file From 13bb2bb64c2764877ee5a8f31582a89c51e91429 Mon Sep 17 00:00:00 2001 From: JanVana Date: Tue, 5 Jul 2016 02:29:50 +0200 Subject: [PATCH 047/211] #70 - Minor fixes and hacks to get the DBpedia working on test data --- .../shef/dcs/kbsearch/KBSearchException.java | 4 + .../dcs/kbsearch/sparql/DBpediaSearch.java | 90 ++++++++++--------- .../sparql/DBpediaSearchResultFilter.java | 4 + .../dcs/kbsearch/sparql/SPARQLSearch.java | 3 +- 4 files changed, 57 insertions(+), 44 deletions(-) diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchException.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchException.java index 25181b9f..e6630762 100644 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchException.java +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchException.java @@ -12,4 +12,8 @@ public KBSearchException(String msg){ public KBSearchException(Exception e){ super(e); } + + public KBSearchException(String msg, Exception e){ + super(msg, e); + } } diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearch.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearch.java index 926106a7..18eaa3f3 100644 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearch.java +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearch.java @@ -437,57 +437,61 @@ protected String createSolrCacheQuery_findLabelForResource(String url) { } @Override - protected List queryForLabel(String sparqlQuery, String resourceURI) { - org.apache.jena.query.Query query = QueryFactory.create(sparqlQuery); - QueryExecution qexec = QueryExecutionFactory.sparqlService(sparqlEndpoint, query); - - List out = new ArrayList<>(); - ResultSet rs = qexec.execSelect(); - while (rs.hasNext()) { - QuerySolution qs = rs.next(); - RDFNode domain = qs.get("?o"); - String d = null; - if (domain != null) - d = domain.toString(); - if (d != null) { - if (d.contains("@")) { //language tag in dbpedia literals - if (!d.endsWith("@en")) - continue; - else { - int trim = d.lastIndexOf("@en"); - if (trim != -1) - d = d.substring(0, trim).trim(); + protected List queryForLabel(String sparqlQuery, String resourceURI) throws KBSearchException { + try { + org.apache.jena.query.Query query = QueryFactory.create(sparqlQuery); + QueryExecution qexec = QueryExecutionFactory.sparqlService(sparqlEndpoint, query); + + List out = new ArrayList<>(); + ResultSet rs = qexec.execSelect(); + while (rs.hasNext()) { + QuerySolution qs = rs.next(); + RDFNode domain = qs.get("?o"); + String d = null; + if (domain != null) + d = domain.toString(); + if (d != null) { + if (d.contains("@")) { //language tag in dbpedia literals + if (!d.endsWith("@en")) + continue; + else { + int trim = d.lastIndexOf("@en"); + if (trim != -1) + d = d.substring(0, trim).trim(); + } } - } + } + out.add(d); } - out.add(d); - } - if (out.size() == 0) { //the resource has no statement with prop "rdfs:label", apply heuristics to parse the - //resource uri - int trim = resourceURI.lastIndexOf("#"); - if (trim == -1) - trim = resourceURI.lastIndexOf("/"); - if (trim != -1) { - String stringValue = resourceURI.substring(trim + 1).replaceAll("[^a-zA-Z0-9]", "").trim(); - if (resourceURI.contains("yago")) { //this is an yago resource, which may have numbered ids as suffix - //e.g., City015467 - int end = 0; - for (int i = 0; i < stringValue.length(); i++) { - if (Character.isDigit(stringValue.charAt(i))) { - end = i; - break; + if (out.size() == 0) { //the resource has no statement with prop "rdfs:label", apply heuristics to parse the + //resource uri + int trim = resourceURI.lastIndexOf("#"); + if (trim == -1) + trim = resourceURI.lastIndexOf("/"); + if (trim != -1) { + String stringValue = resourceURI.substring(trim + 1).replaceAll("[^a-zA-Z0-9]", "").trim(); + if (resourceURI.contains("yago")) { //this is an yago resource, which may have numbered ids as suffix + //e.g., City015467 + int end = 0; + for (int i = 0; i < stringValue.length(); i++) { + if (Character.isDigit(stringValue.charAt(i))) { + end = i; + break; + } } + if (end > 0) + stringValue = stringValue.substring(0, end); } - if (end > 0) - stringValue = stringValue.substring(0, end); + stringValue = StringUtils.splitCamelCase(stringValue); + out.add(stringValue); } - stringValue = StringUtils.splitCamelCase(stringValue); - out.add(stringValue); } + return out; + } + catch (QueryParseException ex) { + throw new KBSearchException("Invalid query: " + sparqlQuery, ex); } - return out; - } } diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearchResultFilter.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearchResultFilter.java index b6ef5f76..2abe7fc0 100644 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearchResultFilter.java +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearchResultFilter.java @@ -37,6 +37,10 @@ public boolean isValidClazz(Clazz c) { if (stop == null) return true; + // TODO: How can ID be null?? + if (c.getId() == null) + return false; + for (String s : stop) { if (c.getId().contains(s) || c.getLabel().equalsIgnoreCase(s)) return false; diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLSearch.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLSearch.java index 99ebc07b..80e5767a 100644 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLSearch.java +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLSearch.java @@ -7,6 +7,7 @@ import org.simmetrics.StringMetric; import org.simmetrics.metrics.Levenshtein; import uk.ac.shef.dcs.kbsearch.KBSearch; +import uk.ac.shef.dcs.kbsearch.KBSearchException; import java.io.IOException; import java.util.*; @@ -124,7 +125,7 @@ protected List> queryByLabel(String sparqlQuery, String str return out; } - protected abstract List queryForLabel(String sparqlQuery, String resourceURI); + protected abstract List queryForLabel(String sparqlQuery, String resourceURI) throws KBSearchException; protected void rank(List> candidates, String originalQueryLabel){ From d7cc202e247cffeb83ba1b3ba5fb94f95fe4436a Mon Sep 17 00:00:00 2001 From: JanVana Date: Tue, 5 Jul 2016 02:30:15 +0200 Subject: [PATCH 048/211] #72 - TAnnotation to Result conversion fixes --- .../uk/ac/shef/dcs/kbsearch/model/Attribute.java | 14 ++++++++++++-- .../xrg/odalic/tasks/annotations/Likelihood.java | 4 +++- .../cuni/mff/xrg/odalic/tasks/results/Result.java | 7 +++---- .../executions/InterpreterExecutionBatch.java | 15 ++++++++++----- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Attribute.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Attribute.java index 488a360e..de85d7e1 100644 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Attribute.java +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Attribute.java @@ -18,7 +18,7 @@ public abstract class Attribute implements Serializable{ public Attribute(String relationURI, String value) { this.relationURI =relationURI; - this.value=value; + this.value= fixValue(value); } /** @@ -42,7 +42,7 @@ public String getValue() { } public void setValue(String value) { - this.value = value; + this.value = fixValue(value); } public String getRelationURI() { @@ -76,4 +76,14 @@ public void setIsDirect(boolean isDirect) { public String toString(){ return "r="+ relationURI +",o="+value+" ("+valueURI+"), direct="+isDirect; } + + String fixValue(String originalValue) { + Integer index = originalValue.indexOf("^^"); + if (originalValue.startsWith("http") && index > 0) { + return originalValue.substring(0, index); + } + else { + return originalValue; + } + } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Likelihood.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Likelihood.java index 0ae03138..d0f055a1 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Likelihood.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Likelihood.java @@ -25,7 +25,9 @@ private Likelihood() { */ public Likelihood(double value) { Preconditions.checkArgument(value >= 0); - Preconditions.checkArgument(value <= 1); + + // TODO: Check what this means. Core algorithm returns unbound score. + // Preconditions.checkArgument(value <= 1); this.value = value; } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/Result.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/Result.java index c8be8bdc..e42363ef 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/Result.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/Result.java @@ -79,11 +79,10 @@ private static void checkMandatory(List headerAnnotations, CellAnnotation[][] cellAnnotations, Map columnRelationAnnotations, Map cellRelationAnnotations) { - checkMandatory(headerAnnotations, cellAnnotations, columnRelationAnnotations, - cellRelationAnnotations); - + Preconditions.checkArgument(!cz.cuni.mff.xrg.odalic.util.Arrays.containsNull(cellAnnotations)); - Preconditions.checkArgument(cz.cuni.mff.xrg.odalic.util.Arrays.isMatrix(cellAnnotations)); + // TODO: Check this with Vaclac. It makes no sense, why should it be a square matrix. + // Preconditions.checkArgument(cz.cuni.mff.xrg.odalic.util.Arrays.isMatrix(cellAnnotations)); } /** diff --git a/odalic/src/test/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterExecutionBatch.java b/odalic/src/test/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterExecutionBatch.java index 93c8c9ad..c478c782 100644 --- a/odalic/src/test/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterExecutionBatch.java +++ b/odalic/src/test/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterExecutionBatch.java @@ -7,6 +7,8 @@ import com.google.common.base.Preconditions; +import cz.cuni.mff.xrg.odalic.tasks.results.DefaultAnnotationToResultAdapter; +import cz.cuni.mff.xrg.odalic.tasks.results.Result; import uk.ac.shef.dcs.sti.STIException; import uk.ac.shef.dcs.sti.core.algorithm.SemanticTableInterpreter; import uk.ac.shef.dcs.sti.core.model.TAnnotation; @@ -25,7 +27,7 @@ public static void main(String[] args) { factory.setIgnoreColumnsForInterpreter(new Integer[]{}); //TODO: Write your own path to the folder containing (only) the input file. - List all = Arrays.asList(new File("/Users/-/work/sti/sti_data/Limaye200").listFiles()); + List all = Arrays.asList(new File("d:\\Documents\\Odalic\\Input\\").listFiles()); File inputFile = all.get(0); // code for extraction from CSV @@ -49,14 +51,17 @@ public static void main(String[] args) { TAnnotation annotationResult; try { annotationResult = semanticTableInterpreter.start(tables.get(0), true); + + DefaultAnnotationToResultAdapter adapter = new DefaultAnnotationToResultAdapter(); + Result odalicResult = adapter.toResult(annotationResult); - System.out.println("V�sledek - OK:"); - System.out.println(annotationResult.toString()); + System.out.println("Výsledek - OK:"); + System.out.println(odalicResult.toString()); } catch (STIException e) { - System.out.println("V�sledek - Chyba:"); + System.out.println("Výsledek - Chyba:"); e.printStackTrace(); } - System.out.println("Konec v�sledku."); + System.out.println("Konec výsledku."); } } From a2dd308abe75ed4ea9fb453a9361c8867e76da85 Mon Sep 17 00:00:00 2001 From: brodecva Date: Wed, 6 Jul 2016 05:19:20 +0200 Subject: [PATCH 049/211] Final polish for the first iteration. --- .../xrg/odalic/api/rest/Configuration.java | 10 +- .../api/rest/adapters/AmbiguityAdapter.java | 2 +- .../rest/adapters/CellAnnotationAdapter.java | 4 +- .../rest/adapters/CellPositionAdapter.java | 2 +- .../rest/adapters/CellRelationAdapter.java | 2 +- .../CellRelationAnnotationAdapter.java | 4 +- .../adapters/CellRelationPositionAdapter.java | 23 +++ .../rest/adapters/ClassificationAdapter.java | 2 +- .../rest/adapters/ColumnAmbiguityAdapter.java | 2 +- .../rest/adapters/ColumnIgnoreAdapter.java | 2 +- .../rest/adapters/ColumnPositionAdapter.java | 2 +- .../rest/adapters/ColumnRelationAdapter.java | 2 +- .../ColumnRelationAnnotationAdapter.java | 4 +- .../ColumnRelationPositionAdapter.java | 23 +++ .../rest/adapters/ConfigurationAdapter.java | 2 +- .../rest/adapters/DisambiguationAdapter.java | 2 +- .../api/rest/adapters/EntityAdapter.java | 2 +- .../rest/adapters/EntityCandidateAdapter.java | 4 +- .../api/rest/adapters/FeedbackAdapter.java | 2 +- .../odalic/api/rest/adapters/FileAdapter.java | 23 +++ .../adapters/HeaderAnnotationAdapter.java | 4 +- .../rest/adapters/KnowledgeBaseAdapter.java | 2 +- .../api/rest/adapters/LikelihoodAdapter.java | 2 +- .../api/rest/adapters/ResultAdapter.java | 4 +- .../api/rest/adapters/RowPositionAdapter.java | 2 +- .../odalic/api/rest/adapters/TaskAdapter.java | 2 +- .../ColumnPositionKeyJsonDeserializer.java | 23 +++ .../ColumnPositionKeyJsonSerializer.java | 29 +++ ...lRelationAnnotationMapMapDeserializer.java | 30 +++ ...ellRelationAnnotationMapMapSerializer.java | 43 +++++ ...lumnRelationAnnotationMapDeserializer.java | 29 +++ ...ColumnRelationAnnotationMapSerializer.java | 33 ++++ .../CustomJsonDateDeserializer.java | 16 +- .../conversions/CustomJsonDateSerializer.java | 12 +- .../KnowledgeBaseKeyJsonDeserializer.java | 11 +- .../KnowledgeBaseKeyJsonSerializer.java | 8 +- .../RowPositionKeyJsonDeserializer.java | 23 +++ .../RowPositionKeyJsonSerializer.java | 30 +++ .../xrg/odalic/api/rest/errors/Message.java | 83 +++++++-- .../api/rest/errors/ThrowableMapper.java | 17 +- .../api/rest/filters/CorsResponseFilter.java | 12 +- .../rest/filters/LoggingResponseFilter.java | 16 +- .../rest/resources/ConfigurationResource.java | 21 +-- .../api/rest/resources/ExecutionResource.java | 22 ++- .../api/rest/resources/FeedbackResource.java | 18 +- .../api/rest/resources/FileResource.java | 6 +- .../api/rest/resources/ResultResource.java | 26 ++- .../api/rest/resources/StateResource.java | 40 ++-- .../api/rest/resources/TaskResource.java | 28 +-- .../api/rest/values/AmbiguityValue.java | 6 + .../api/rest/values/CellAnnotationValue.java | 48 +++-- .../api/rest/values/CellPositionValue.java | 6 + .../values/CellRelationAnnotationValue.java | 48 +++-- .../values/CellRelationPositionValue.java | 6 + .../api/rest/values/CellRelationValue.java | 6 + .../api/rest/values/ClassificationValue.java | 6 + .../api/rest/values/ColumnAmbiguityValue.java | 6 + .../api/rest/values/ColumnIgnoreValue.java | 6 + .../api/rest/values/ColumnPositionValue.java | 8 +- .../values/ColumnRelationAnnotationValue.java | 48 +++-- .../values/ColumnRelationPositionValue.java | 11 +- .../api/rest/values/ColumnRelationValue.java | 6 + .../api/rest/values/ConfigurationValue.java | 37 +++- .../api/rest/values/DisambiguationValue.java | 6 + .../api/rest/values/EntityCandidateValue.java | 87 ++++++--- .../odalic/api/rest/values/EntityValue.java | 18 +- .../api/rest/values/ExecutionValue.java | 62 +++++++ .../odalic/api/rest/values/FeedbackValue.java | 60 +++--- .../xrg/odalic/api/rest/values/FileValue.java | 130 +++++++++++++ .../rest/values/HeaderAnnotationValue.java | 48 +++-- .../api/rest/values/KnowledgeBaseValue.java | 8 +- .../api/rest/values/LikelihoodValue.java | 12 +- .../odalic/api/rest/values/ResultValue.java | 50 +++-- .../api/rest/values/RowPositionValue.java | 12 +- .../odalic/api/rest/values/StateValue.java | 41 +++++ .../xrg/odalic/api/rest/values/TaskValue.java | 16 +- .../mff/xrg/odalic/feedbacks/Ambiguity.java | 20 +- .../xrg/odalic/feedbacks/CellRelation.java | 29 +-- .../xrg/odalic/feedbacks/Classification.java | 24 ++- .../xrg/odalic/feedbacks/ColumnAmbiguity.java | 25 ++- .../xrg/odalic/feedbacks/ColumnIgnore.java | 25 ++- .../xrg/odalic/feedbacks/ColumnRelation.java | 24 +-- .../xrg/odalic/feedbacks/Disambiguation.java | 23 +-- .../mff/xrg/odalic/feedbacks/Feedback.java | 109 +++++------ .../mff/xrg/odalic/feedbacks/input/Input.java | 6 + .../odalic/feedbacks/input/InputParser.java | 6 + .../odalic/feedbacks/input/SimpleInput.java | 2 +- .../cz/cuni/mff/xrg/odalic/files/File.java | 107 ++++------- .../mff/xrg/odalic/files/FileService.java | 37 ++++ .../odalic/files/MemoryOnlyFileService.java | 39 +++- .../xrg/odalic/positions/CellPosition.java | 57 ++++-- .../positions/CellRelationPosition.java | 115 +++++++++--- .../xrg/odalic/positions/ColumnPosition.java | 33 ++-- .../positions/ColumnRelationPosition.java | 72 ++++++-- .../mff/xrg/odalic/positions/RowPosition.java | 44 +++-- ...ceImpl.java => MemoryOnlyTaskService.java} | 35 ++-- .../cz/cuni/mff/xrg/odalic/tasks/Task.java | 82 ++++----- .../cuni/mff/xrg/odalic/tasks/TaskDigest.java | 82 --------- .../mff/xrg/odalic/tasks/TaskService.java | 6 + .../tasks/annotations/CellAnnotation.java | 66 ++++--- .../annotations/CellRelationAnnotation.java | 67 ++++--- .../annotations/ColumnRelationAnnotation.java | 70 ++++--- .../xrg/odalic/tasks/annotations/Entity.java | 70 +++---- .../tasks/annotations/EntityCandidate.java | 62 ++++--- .../tasks/annotations/HeaderAnnotation.java | 99 ++++++---- .../tasks/annotations/KnowledgeBase.java | 38 ++-- .../odalic/tasks/annotations/Likelihood.java | 44 +++-- .../tasks/configurations/Configuration.java | 20 ++ .../configurations/ConfigurationService.java | 6 + .../MemoryOnlyConfigurationService.java | 2 + .../odalic/tasks/executions/Execution.java | 38 ---- .../tasks/executions/ExecutionService.java | 49 ++++- .../FutureBasedExecutionService.java | 47 +++-- .../SemanticTableInterpreterFactory.java | 21 ++- .../xrg/odalic/tasks/executions/State.java | 16 -- .../executions/TableMinerPlusFactory.java | 36 ++-- .../tasks/feedbacks/FeedbackService.java | 6 + .../feedbacks/MemoryOnlyFeedbackService.java | 2 + .../results/AnnotationToResultAdapter.java | 19 +- .../DefaultAnnotationToResultAdapter.java | 171 +++++++++++++++--- .../mff/xrg/odalic/tasks/results/Result.java | 128 ++++++------- .../cz/cuni/mff/xrg/odalic/util/Arrays.java | 125 ++++++++++--- .../cz/cuni/mff/xrg/odalic/util/Lists.java | 49 +++++ .../cz/cuni/mff/xrg/odalic/util/Maps.java | 48 +++++ .../java/cz/cuni/mff/xrg/odalic/util/URL.java | 29 ++- .../resources/spring/applicationContext.xml | 2 +- .../executions/InterpreterExecutionBatch.java | 56 +++--- 127 files changed, 2734 insertions(+), 1163 deletions(-) create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationPositionAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationPositionAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/FileAdapter.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionKeyJsonDeserializer.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionKeyJsonSerializer.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnPositionToCellRelationAnnotationMapMapDeserializer.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnPositionToCellRelationAnnotationMapMapSerializer.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnRelationAnnotationMapDeserializer.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnRelationAnnotationMapSerializer.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/RowPositionKeyJsonDeserializer.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/RowPositionKeyJsonSerializer.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ExecutionValue.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/FileValue.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/StateValue.java rename odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/{TaskServiceImpl.java => MemoryOnlyTaskService.java} (62%) delete mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskDigest.java delete mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/Execution.java delete mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/State.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/Lists.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/Maps.java diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java index 5c7a596d..12c333e3 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java @@ -8,8 +8,6 @@ import org.glassfish.jersey.media.multipart.MultiPartFeature; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.spring.scope.RequestContextFilter; -import org.springframework.stereotype.Component; - import cz.cuni.mff.xrg.odalic.api.rest.errors.ThrowableMapper; import cz.cuni.mff.xrg.odalic.api.rest.filters.CorsResponseFilter; import cz.cuni.mff.xrg.odalic.api.rest.filters.LoggingResponseFilter; @@ -21,7 +19,13 @@ import cz.cuni.mff.xrg.odalic.api.rest.resources.StateResource; import cz.cuni.mff.xrg.odalic.api.rest.resources.TaskResource; -@Component +/** + * Configures the provided resources, filters, mappers and features. + * + * @author Václav Brodec + * + * @see org.glassfish.jersey.server.ResourceConfig + */ public final class Configuration extends ResourceConfig { public Configuration() throws JAXBException { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/AmbiguityAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/AmbiguityAdapter.java index 89c7e5c9..0540f95b 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/AmbiguityAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/AmbiguityAdapter.java @@ -6,7 +6,7 @@ import cz.cuni.mff.xrg.odalic.feedbacks.Ambiguity; -public class AmbiguityAdapter +public final class AmbiguityAdapter extends XmlAdapter { @Override diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellAnnotationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellAnnotationAdapter.java index 4e5f1cfe..ab428992 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellAnnotationAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellAnnotationAdapter.java @@ -6,9 +6,9 @@ import javax.xml.bind.annotation.adapters.XmlAdapter; -import org.apache.jena.ext.com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; import cz.cuni.mff.xrg.odalic.api.rest.values.CellAnnotationValue; @@ -18,7 +18,7 @@ import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; -public class CellAnnotationAdapter extends XmlAdapter { +public final class CellAnnotationAdapter extends XmlAdapter { @Override public CellAnnotationValue marshal(CellAnnotation bound) throws Exception { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellPositionAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellPositionAdapter.java index 8d2549ac..0c6ad184 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellPositionAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellPositionAdapter.java @@ -6,7 +6,7 @@ import cz.cuni.mff.xrg.odalic.positions.CellPosition; -public class CellPositionAdapter +public final class CellPositionAdapter extends XmlAdapter { @Override diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAdapter.java index b819992e..91f583f6 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAdapter.java @@ -6,7 +6,7 @@ import cz.cuni.mff.xrg.odalic.feedbacks.CellRelation; -public class CellRelationAdapter +public final class CellRelationAdapter extends XmlAdapter { @Override diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAnnotationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAnnotationAdapter.java index 34390ef4..dd8ab615 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAnnotationAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAnnotationAdapter.java @@ -6,9 +6,9 @@ import javax.xml.bind.annotation.adapters.XmlAdapter; -import org.apache.jena.ext.com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; import cz.cuni.mff.xrg.odalic.api.rest.values.CellRelationAnnotationValue; @@ -18,7 +18,7 @@ import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; -public class CellRelationAnnotationAdapter extends XmlAdapter { +public final class CellRelationAnnotationAdapter extends XmlAdapter { @Override public CellRelationAnnotationValue marshal(CellRelationAnnotation bound) throws Exception { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationPositionAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationPositionAdapter.java new file mode 100644 index 00000000..ee7da084 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationPositionAdapter.java @@ -0,0 +1,23 @@ +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.CellRelationPositionValue; +import cz.cuni.mff.xrg.odalic.positions.CellRelationPosition; + + +public final class CellRelationPositionAdapter + extends XmlAdapter { + + @Override + public CellRelationPositionValue marshal(CellRelationPosition bound) + throws Exception { + return new CellRelationPositionValue(bound); + } + + @Override + public CellRelationPosition unmarshal(CellRelationPositionValue value) + throws Exception { + return new CellRelationPosition(value.getColumnsPosition(), value.getRowPosition()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ClassificationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ClassificationAdapter.java index 6d287fd6..5b2be252 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ClassificationAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ClassificationAdapter.java @@ -6,7 +6,7 @@ import cz.cuni.mff.xrg.odalic.feedbacks.Classification; -public class ClassificationAdapter +public final class ClassificationAdapter extends XmlAdapter { @Override diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnAmbiguityAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnAmbiguityAdapter.java index caf41a37..3cbc75f1 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnAmbiguityAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnAmbiguityAdapter.java @@ -5,7 +5,7 @@ import cz.cuni.mff.xrg.odalic.api.rest.values.ColumnAmbiguityValue; import cz.cuni.mff.xrg.odalic.feedbacks.ColumnAmbiguity; -public class ColumnAmbiguityAdapter extends XmlAdapter { +public final class ColumnAmbiguityAdapter extends XmlAdapter { @Override public ColumnAmbiguityValue marshal(ColumnAmbiguity bound) throws Exception { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnIgnoreAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnIgnoreAdapter.java index 5a5c1533..75b87a99 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnIgnoreAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnIgnoreAdapter.java @@ -5,7 +5,7 @@ import cz.cuni.mff.xrg.odalic.api.rest.values.ColumnIgnoreValue; import cz.cuni.mff.xrg.odalic.feedbacks.ColumnIgnore; -public class ColumnIgnoreAdapter extends XmlAdapter { +public final class ColumnIgnoreAdapter extends XmlAdapter { @Override public ColumnIgnoreValue marshal(ColumnIgnore bound) throws Exception { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnPositionAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnPositionAdapter.java index 193e19e2..a30bbd4e 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnPositionAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnPositionAdapter.java @@ -6,7 +6,7 @@ import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; -public class ColumnPositionAdapter +public final class ColumnPositionAdapter extends XmlAdapter { @Override diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAdapter.java index 3feabfda..e01bef88 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAdapter.java @@ -6,7 +6,7 @@ import cz.cuni.mff.xrg.odalic.feedbacks.ColumnRelation; -public class ColumnRelationAdapter extends XmlAdapter { +public final class ColumnRelationAdapter extends XmlAdapter { @Override public ColumnRelationValue marshal(ColumnRelation bound) throws Exception { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAnnotationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAnnotationAdapter.java index 88c76f9c..8af0faae 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAnnotationAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAnnotationAdapter.java @@ -6,9 +6,9 @@ import javax.xml.bind.annotation.adapters.XmlAdapter; -import org.apache.jena.ext.com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; import cz.cuni.mff.xrg.odalic.api.rest.values.ColumnRelationAnnotationValue; @@ -18,7 +18,7 @@ import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; -public class ColumnRelationAnnotationAdapter extends XmlAdapter { +public final class ColumnRelationAnnotationAdapter extends XmlAdapter { @Override public ColumnRelationAnnotationValue marshal(ColumnRelationAnnotation bound) throws Exception { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationPositionAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationPositionAdapter.java new file mode 100644 index 00000000..02edef8e --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationPositionAdapter.java @@ -0,0 +1,23 @@ +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.ColumnRelationPositionValue; +import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; + + +public final class ColumnRelationPositionAdapter + extends XmlAdapter { + + @Override + public ColumnRelationPositionValue marshal(ColumnRelationPosition bound) + throws Exception { + return new ColumnRelationPositionValue(bound); + } + + @Override + public ColumnRelationPosition unmarshal(ColumnRelationPositionValue value) + throws Exception { + return new ColumnRelationPosition(value.getFirst(), value.getSecond()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ConfigurationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ConfigurationAdapter.java index 260803b3..d1f48a99 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ConfigurationAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ConfigurationAdapter.java @@ -6,7 +6,7 @@ import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; -public class ConfigurationAdapter extends XmlAdapter { +public final class ConfigurationAdapter extends XmlAdapter { @Override public ConfigurationValue marshal(Configuration bound) throws Exception { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/DisambiguationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/DisambiguationAdapter.java index 62f91cc5..f9a170c9 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/DisambiguationAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/DisambiguationAdapter.java @@ -6,7 +6,7 @@ import cz.cuni.mff.xrg.odalic.feedbacks.Disambiguation; -public class DisambiguationAdapter +public final class DisambiguationAdapter extends XmlAdapter { @Override diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityAdapter.java index 63bfbe23..5754a863 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityAdapter.java @@ -6,7 +6,7 @@ import cz.cuni.mff.xrg.odalic.tasks.annotations.Entity; -public class EntityAdapter +public final class EntityAdapter extends XmlAdapter { @Override diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityCandidateAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityCandidateAdapter.java index fd1ac924..3f6105e2 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityCandidateAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityCandidateAdapter.java @@ -6,13 +6,13 @@ import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; -public class EntityCandidateAdapter +public final class EntityCandidateAdapter extends XmlAdapter { @Override public EntityCandidateValue marshal(EntityCandidate bound) throws Exception { - return new EntityCandidateValue(bound, false); + throw new UnsupportedOperationException(); } @Override diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/FeedbackAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/FeedbackAdapter.java index beb75fd7..226da739 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/FeedbackAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/FeedbackAdapter.java @@ -6,7 +6,7 @@ import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; -public class FeedbackAdapter extends XmlAdapter { +public final class FeedbackAdapter extends XmlAdapter { @Override public FeedbackValue marshal(Feedback bound) throws Exception { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/FileAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/FileAdapter.java new file mode 100644 index 00000000..e1efaeae --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/FileAdapter.java @@ -0,0 +1,23 @@ +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.FileValue; +import cz.cuni.mff.xrg.odalic.files.File; + + +public final class FileAdapter + extends XmlAdapter { + + @Override + public FileValue marshal(File bound) + throws Exception { + return new FileValue(bound); + } + + @Override + public File unmarshal(FileValue value) + throws Exception { + return new File(value.getId(), value.getUploaded(), value.getOwner(), value.getLocation()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/HeaderAnnotationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/HeaderAnnotationAdapter.java index c996d027..4ef248ed 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/HeaderAnnotationAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/HeaderAnnotationAdapter.java @@ -6,9 +6,9 @@ import javax.xml.bind.annotation.adapters.XmlAdapter; -import org.apache.jena.ext.com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; import cz.cuni.mff.xrg.odalic.api.rest.values.HeaderAnnotationValue; @@ -18,7 +18,7 @@ import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; -public class HeaderAnnotationAdapter extends XmlAdapter { +public final class HeaderAnnotationAdapter extends XmlAdapter { @Override public HeaderAnnotationValue marshal(HeaderAnnotation bound) throws Exception { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/KnowledgeBaseAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/KnowledgeBaseAdapter.java index 2affe613..eade46a4 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/KnowledgeBaseAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/KnowledgeBaseAdapter.java @@ -6,7 +6,7 @@ import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; -public class KnowledgeBaseAdapter +public final class KnowledgeBaseAdapter extends XmlAdapter { @Override diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/LikelihoodAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/LikelihoodAdapter.java index 03f7f095..68d623d9 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/LikelihoodAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/LikelihoodAdapter.java @@ -6,7 +6,7 @@ import cz.cuni.mff.xrg.odalic.tasks.annotations.Likelihood; -public class LikelihoodAdapter +public final class LikelihoodAdapter extends XmlAdapter { @Override diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ResultAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ResultAdapter.java index a83b357a..3833940b 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ResultAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ResultAdapter.java @@ -16,7 +16,7 @@ import cz.cuni.mff.xrg.odalic.tasks.results.Result; -public class ResultAdapter extends XmlAdapter { +public final class ResultAdapter extends XmlAdapter { @Override public ResultValue marshal(Result bound) throws Exception { @@ -53,7 +53,7 @@ public Result unmarshal(ResultValue value) throws Exception { } } - return new Result(value.getHeaderAnnotations(), value.getCellAnnotations(), + return new Result(value.getSubjectColumnPosition(), value.getHeaderAnnotations(), value.getCellAnnotations(), columnRelationAnnotationsBuilder.build(), cellRelationAnnotationsBuilder.build()); } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/RowPositionAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/RowPositionAdapter.java index c4604d1d..e44ff245 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/RowPositionAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/RowPositionAdapter.java @@ -6,7 +6,7 @@ import cz.cuni.mff.xrg.odalic.positions.RowPosition; -public class RowPositionAdapter +public final class RowPositionAdapter extends XmlAdapter { @Override diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/TaskAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/TaskAdapter.java index 185968e2..1ec9053c 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/TaskAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/TaskAdapter.java @@ -6,7 +6,7 @@ import cz.cuni.mff.xrg.odalic.tasks.Task; -public class TaskAdapter extends XmlAdapter { +public final class TaskAdapter extends XmlAdapter { @Override public TaskValue marshal(Task bound) throws Exception { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionKeyJsonDeserializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionKeyJsonDeserializer.java new file mode 100644 index 00000000..68111828 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionKeyJsonDeserializer.java @@ -0,0 +1,23 @@ +package cz.cuni.mff.xrg.odalic.api.rest.conversions; + +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.KeyDeserializer; + +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; + +/** + * Map key JSON deserializer for {@link ColumnPosition} instances. + * + * @author Václav Brodec + * + */ +public final class ColumnPositionKeyJsonDeserializer extends KeyDeserializer { + + /* (non-Javadoc) + * @see com.fasterxml.jackson.databind.KeyDeserializer#deserializeKey(java.lang.String, com.fasterxml.jackson.databind.DeserializationContext) + */ + @Override + public Object deserializeKey(String key, DeserializationContext ctxt) { + return new ColumnPosition(Integer.parseInt(key)); + } +} \ No newline at end of file diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionKeyJsonSerializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionKeyJsonSerializer.java new file mode 100644 index 00000000..c3fac5c4 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionKeyJsonSerializer.java @@ -0,0 +1,29 @@ +package cz.cuni.mff.xrg.odalic.api.rest.conversions; + +import java.io.IOException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; + +/** + * Map key JSON serializer for {@link ColumnPosition} instances. + * + * @author Václav Brodec + * + */ +public final class ColumnPositionKeyJsonSerializer extends JsonSerializer { + + /* (non-Javadoc) + * @see com.fasterxml.jackson.databind.JsonSerializer#serialize(java.lang.Object, com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider) + */ + @Override + public void serialize(ColumnPosition value, JsonGenerator jgen, + SerializerProvider provider) throws IOException, + JsonProcessingException { + jgen.writeString(Integer.toString(value.getIndex())); + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnPositionToCellRelationAnnotationMapMapDeserializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnPositionToCellRelationAnnotationMapMapDeserializer.java new file mode 100644 index 00000000..c9450ad4 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnPositionToCellRelationAnnotationMapMapDeserializer.java @@ -0,0 +1,30 @@ +package cz.cuni.mff.xrg.odalic.api.rest.conversions; + +import java.io.IOException; +import java.util.Map; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; + +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; + +/** + * A custom nested map JSON deserializer. + * + * @author Václav Brodec + * + */ +public final class ColumnPositionToColumnPositionToCellRelationAnnotationMapMapDeserializer extends JsonDeserializer> { + + /* (non-Javadoc) + * @see com.fasterxml.jackson.databind.JsonDeserializer#deserialize(com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.databind.DeserializationContext) + */ + @Override + public Map deserialize(JsonParser parser, + DeserializationContext ctxt) throws IOException, JsonProcessingException { + throw new UnsupportedOperationException(); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnPositionToCellRelationAnnotationMapMapSerializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnPositionToCellRelationAnnotationMapMapSerializer.java new file mode 100644 index 00000000..55712981 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnPositionToCellRelationAnnotationMapMapSerializer.java @@ -0,0 +1,43 @@ +package cz.cuni.mff.xrg.odalic.api.rest.conversions; + +import java.io.IOException; +import java.util.Map; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; + +/** + * A custom nested map JSON serializer. + * + * @author Václav Brodec + * + */ +public final class ColumnPositionToColumnPositionToCellRelationAnnotationMapMapSerializer +extends JsonSerializer>> { + + /* (non-Javadoc) + * @see com.fasterxml.jackson.databind.JsonSerializer#serialize(java.lang.Object, com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider) + */ + @Override + public void serialize(Map> value, JsonGenerator jgen, + SerializerProvider provider) throws IOException, + JsonProcessingException { + jgen.writeStartObject(); + for (final Map.Entry> entry : value.entrySet()) { + jgen.writeFieldName(Integer.toString(entry.getKey().getIndex())); + + jgen.writeStartObject(); + for (final Map.Entry> subentry : value.entrySet()) { + jgen.writeObjectField(Integer.toString(entry.getKey().getIndex()), subentry.getValue()); + } + jgen.writeEndObject(); + } + jgen.writeEndObject(); + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnRelationAnnotationMapDeserializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnRelationAnnotationMapDeserializer.java new file mode 100644 index 00000000..74e4f5b7 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnRelationAnnotationMapDeserializer.java @@ -0,0 +1,29 @@ +package cz.cuni.mff.xrg.odalic.api.rest.conversions; + +import java.io.IOException; +import java.util.Map; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; + +/** + * A custom nested map JSON deserializer. + * + * @author Václav Brodec + * + */ +public final class ColumnPositionToColumnRelationAnnotationMapDeserializer extends JsonDeserializer> { + + /* (non-Javadoc) + * @see com.fasterxml.jackson.databind.JsonDeserializer#deserialize(com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.databind.DeserializationContext) + */ + @Override + public Map deserialize(JsonParser parser, + DeserializationContext ctxt) throws IOException, JsonProcessingException { + throw new UnsupportedOperationException(); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnRelationAnnotationMapSerializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnRelationAnnotationMapSerializer.java new file mode 100644 index 00000000..4e693cd2 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnRelationAnnotationMapSerializer.java @@ -0,0 +1,33 @@ +package cz.cuni.mff.xrg.odalic.api.rest.conversions; + +import java.io.IOException; +import java.util.Map; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; + +/** + * A custom nested map JSON serializer. + * + * @author Václav Brodec + * + */ +public final class ColumnPositionToColumnRelationAnnotationMapSerializer extends JsonSerializer> { + + @Override + public void serialize(Map value, JsonGenerator jgen, + SerializerProvider provider) throws IOException, + JsonProcessingException { + jgen.writeStartObject(); + for (final Map.Entry entry : value.entrySet()) { + jgen.writeObjectField(Integer.toString(entry.getKey().getIndex()), entry.getValue()); + } + jgen.writeEndObject(); + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateDeserializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateDeserializer.java index 6daffe74..1222fcb1 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateDeserializer.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateDeserializer.java @@ -10,14 +10,24 @@ import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; -public class CustomJsonDateDeserializer extends JsonDeserializer { +/** + * Deserializer from a custom date format. + * + * @author Václav Brodec + * + * @see CustomJsonDateSerializer + */ +public final class CustomJsonDateDeserializer extends JsonDeserializer { + /* (non-Javadoc) + * @see com.fasterxml.jackson.databind.JsonDeserializer#deserialize(com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.databind.DeserializationContext) + */ @Override public Date deserialize(JsonParser jsonparser, DeserializationContext context) throws IOException, JsonProcessingException { - SimpleDateFormat format = new SimpleDateFormat(CustomJsonDateSerializer.DATE_FORMAT); - String date = jsonparser.getText(); + final SimpleDateFormat format = new SimpleDateFormat(CustomJsonDateSerializer.DATE_FORMAT); + final String date = jsonparser.getText(); try { return format.parse(date); } catch (ParseException e) { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateSerializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateSerializer.java index 5909461e..9c725b24 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateSerializer.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateSerializer.java @@ -9,7 +9,13 @@ import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; -public class CustomJsonDateSerializer extends JsonSerializer { +/** + * Serializer to custom date format {@value #DATE_FORMAT}. + * + * @author Václav Brodec + * + */ +public final class CustomJsonDateSerializer extends JsonSerializer { public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm"; @@ -18,8 +24,8 @@ public void serialize(Date value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { - SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); - String dateString = dateFormat.format(value); + final SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); + final String dateString = dateFormat.format(value); jgen.writeString(dateString); } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/KnowledgeBaseKeyJsonDeserializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/KnowledgeBaseKeyJsonDeserializer.java index 71b583ce..70e55765 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/KnowledgeBaseKeyJsonDeserializer.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/KnowledgeBaseKeyJsonDeserializer.java @@ -5,8 +5,17 @@ import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; -public class KnowledgeBaseKeyJsonDeserializer extends KeyDeserializer { +/** + * Map key JSON deserializer for {@link KnowledgeBase} instances. + * + * @author Václav Brodec + * + */ +public final class KnowledgeBaseKeyJsonDeserializer extends KeyDeserializer { + /* (non-Javadoc) + * @see com.fasterxml.jackson.databind.KeyDeserializer#deserializeKey(java.lang.String, com.fasterxml.jackson.databind.DeserializationContext) + */ @Override public Object deserializeKey(String key, DeserializationContext ctxt) { return new KnowledgeBase(key); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/KnowledgeBaseKeyJsonSerializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/KnowledgeBaseKeyJsonSerializer.java index 087a373e..8bd77dd1 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/KnowledgeBaseKeyJsonSerializer.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/KnowledgeBaseKeyJsonSerializer.java @@ -8,7 +8,13 @@ import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; -public class KnowledgeBaseKeyJsonSerializer extends JsonSerializer { +/** + * Map key JSON serializer for {@link KnowledgeBase} instances. + * + * @author Václav Brodec + * + */ +public final class KnowledgeBaseKeyJsonSerializer extends JsonSerializer { public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm"; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/RowPositionKeyJsonDeserializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/RowPositionKeyJsonDeserializer.java new file mode 100644 index 00000000..37645e74 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/RowPositionKeyJsonDeserializer.java @@ -0,0 +1,23 @@ +package cz.cuni.mff.xrg.odalic.api.rest.conversions; + +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.KeyDeserializer; + +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; + +/** + * Map key JSON deserializer for {@link ColumnPosition} instances. + * + * @author Václav Brodec + * + */ +public final class RowPositionKeyJsonDeserializer extends KeyDeserializer { + + /* (non-Javadoc) + * @see com.fasterxml.jackson.databind.KeyDeserializer#deserializeKey(java.lang.String, com.fasterxml.jackson.databind.DeserializationContext) + */ + @Override + public Object deserializeKey(String key, DeserializationContext ctxt) { + return new ColumnPosition(Integer.parseInt(key)); + } +} \ No newline at end of file diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/RowPositionKeyJsonSerializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/RowPositionKeyJsonSerializer.java new file mode 100644 index 00000000..f5997860 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/RowPositionKeyJsonSerializer.java @@ -0,0 +1,30 @@ +package cz.cuni.mff.xrg.odalic.api.rest.conversions; + +import java.io.IOException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; + +/** + * Map key JSON serializer for {@link KnowledgeBase} instances. + * + * @author Václav Brodec + * + */ +public final class RowPositionKeyJsonSerializer extends JsonSerializer { + + /* (non-Javadoc) + * @see com.fasterxml.jackson.databind.JsonSerializer#serialize(java.lang.Object, com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider) + */ + @Override + public void serialize(ColumnPosition value, JsonGenerator jgen, + SerializerProvider provider) throws IOException, + JsonProcessingException { + jgen.writeString(Integer.toString(value.getIndex())); + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/Message.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/Message.java index 14ab4e47..f169222f 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/Message.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/Message.java @@ -1,59 +1,104 @@ package cz.cuni.mff.xrg.odalic.api.rest.errors; +import javax.annotation.Nullable; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import com.google.common.base.Preconditions; + +/** + * Reporting message with extra details for developers. + * + * @author Václav Brodec + * + */ @XmlRootElement -public class Message { +public final class Message { @XmlElement - int status; + private int status; @XmlElement - String text; + private String text; @XmlElement - String link; + private String link; @XmlElement - String developerText; + private String developerText; - public Message() {} + public Message() { + status = Integer.MIN_VALUE; + } + /** + * Creates new message. + * + * @param status HTTP status code + */ public Message(int status) { + Preconditions.checkArgument(status >= 100); + Preconditions.checkArgument(status <= 599); + this.status = status; } - + + /** + * @return the status + */ public int getStatus() { return status; } - public void setStatus(int status) { - this.status = status; - } - + /** + * @return the text + */ + @Nullable public String getText() { return text; } + /** + * @param text the text to set + */ public void setText(String text) { + Preconditions.checkNotNull(text); + this.text = text; } - public String getDeveloperText() { - return developerText; - } - - public void setDeveloperText(String developerText) { - this.developerText = developerText; - } - + /** + * @return the link + */ + @Nullable public String getLink() { return link; } + /** + * @param link the link to set + */ public void setLink(String link) { + Preconditions.checkNotNull(link); + this.link = link; } + + /** + * @return the developer text + */ + @Nullable + public String getDeveloperText() { + return developerText; + } + + /** + * @param developerText the developer text to set + */ + public void setDeveloperText(String developerText) { + Preconditions.checkNotNull(developerText); + + this.developerText = developerText; + } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/ThrowableMapper.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/ThrowableMapper.java index e443bdec..8e1c4104 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/ThrowableMapper.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/ThrowableMapper.java @@ -8,14 +8,25 @@ import javax.ws.rs.core.Response; import javax.ws.rs.ext.ExceptionMapper; -public class ThrowableMapper implements ExceptionMapper { +/** + * Catch-all throwable mapper. + * + * @author Václav Brodec + * + */ +public final class ThrowableMapper implements ExceptionMapper { + /* (non-Javadoc) + * @see javax.ws.rs.ext.ExceptionMapper#toResponse(java.lang.Throwable) + */ + @Override public Response toResponse(Throwable throwable) { - Message errorMessage = new Message(getHttpStatus(throwable)); + //TODO: Add specialized mappers. + final Message errorMessage = new Message(getHttpStatus(throwable)); errorMessage.setText(throwable.getMessage()); - StringWriter trace = new StringWriter(); + final StringWriter trace = new StringWriter(); throwable.printStackTrace(new PrintWriter(trace)); errorMessage.setDeveloperText(trace.toString()); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/CorsResponseFilter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/CorsResponseFilter.java index c40fb2bc..486ea081 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/CorsResponseFilter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/CorsResponseFilter.java @@ -7,8 +7,18 @@ import javax.ws.rs.container.ContainerResponseFilter; import javax.ws.rs.core.MultivaluedMap; -public class CorsResponseFilter implements ContainerResponseFilter { +/** + * Same origin problem workaround filter. + * + * @author Václav Brodec + * + */ +public final class CorsResponseFilter implements ContainerResponseFilter { + /* (non-Javadoc) + * @see javax.ws.rs.container.ContainerResponseFilter#filter(javax.ws.rs.container.ContainerRequestContext, javax.ws.rs.container.ContainerResponseContext) + */ + @Override public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException { MultivaluedMap headers = responseContext.getHeaders(); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/LoggingResponseFilter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/LoggingResponseFilter.java index f64dcabb..e0b0c6e4 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/LoggingResponseFilter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/LoggingResponseFilter.java @@ -10,17 +10,27 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class LoggingResponseFilter +/** + * Filter that logs the API responses. + * + * @author Václav Brodec + * + */ +public final class LoggingResponseFilter implements ContainerResponseFilter { private static final Logger logger = LoggerFactory.getLogger(LoggingResponseFilter.class); + /* (non-Javadoc) + * @see javax.ws.rs.container.ContainerResponseFilter#filter(javax.ws.rs.container.ContainerRequestContext, javax.ws.rs.container.ContainerResponseContext) + */ + @Override public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException { - String method = requestContext.getMethod(); + final String method = requestContext.getMethod(); logger.debug("Requesting " + method + " for path " + requestContext.getUriInfo().getPath()); - Object entity = responseContext.getEntity(); + final Object entity = responseContext.getEntity(); if (entity != null) { logger.debug("Response " + new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(entity)); } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ConfigurationResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ConfigurationResource.java index 3f54122d..3d305a02 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ConfigurationResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ConfigurationResource.java @@ -22,11 +22,19 @@ @Component @Path("/tasks/{id}/configuration") -public class ConfigurationResource { +public final class ConfigurationResource { private final ConfigurationService configurationService; - private final FileService fileService; + + @Autowired + public ConfigurationResource(ConfigurationService configurationService, FileService fileService) { + Preconditions.checkNotNull(configurationService); + Preconditions.checkNotNull(fileService); + + this.configurationService = configurationService; + this.fileService = fileService; + } @PUT @Consumes(MediaType.APPLICATION_JSON) @@ -53,13 +61,4 @@ public Response getConfigurationForTaskId(@PathParam("id") String taskId) { return Response.status(Response.Status.OK).entity(configurationForTaskId).build(); } - - @Autowired - public ConfigurationResource(ConfigurationService configurationService, FileService fileService) { - Preconditions.checkNotNull(configurationService); - Preconditions.checkNotNull(fileService); - - this.configurationService = configurationService; - this.fileService = fileService; - } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ExecutionResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ExecutionResource.java index 9871b35f..59d28cda 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ExecutionResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ExecutionResource.java @@ -12,19 +12,28 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import cz.cuni.mff.xrg.odalic.tasks.executions.Execution; +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.values.ExecutionValue; import cz.cuni.mff.xrg.odalic.tasks.executions.ExecutionService; @Component @Path("/tasks/{id}/execution") -public class ExecutionResource { +public final class ExecutionResource { private ExecutionService executionService; + + @Autowired + public ExecutionResource(ExecutionService executionService) { + Preconditions.checkNotNull(executionService); + + this.executionService = executionService; + } @PUT @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public Response putExecutionForTaskId(@PathParam("id") String id, Execution execution) { + public Response putExecutionForTaskId(@PathParam("id") String id, ExecutionValue execution) { executionService.submitForTaskId(id); return Response.status(Response.Status.OK).entity("Execution submitted.").build(); } @@ -34,11 +43,6 @@ public Response putExecutionForTaskId(@PathParam("id") String id, Execution exec public Response deleteExecutionForTaskId(@PathParam("id") String id) { executionService.cancelForTaskId(id); return Response.status(Response.Status.OK) - .entity("Execution cancelled.").build(); - } - - @Autowired - public ExecutionResource(ExecutionService executionService) { - this.executionService = executionService; + .entity("Execution canceled.").build(); } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FeedbackResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FeedbackResource.java index 044b4871..4895a113 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FeedbackResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FeedbackResource.java @@ -14,15 +14,24 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import com.google.common.base.Preconditions; + import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; import cz.cuni.mff.xrg.odalic.feedbacks.input.Input; import cz.cuni.mff.xrg.odalic.tasks.feedbacks.FeedbackService; @Component @Path("/tasks/{id}/configuration/feedback") -public class FeedbackResource { +public final class FeedbackResource { - private FeedbackService feedbackService; + private final FeedbackService feedbackService; + + @Autowired + public FeedbackResource(FeedbackService feedbackService) { + Preconditions.checkNotNull(feedbackService); + + this.feedbackService = feedbackService; + } @PUT @Consumes(MediaType.APPLICATION_JSON) @@ -46,9 +55,4 @@ public Response getFeedbackForTaskId(@PathParam("id") String taskId) { public Input getJsonDataById(@PathParam("id") String id) throws IOException { return feedbackService.getInputForTaskId(id); } - - @Autowired - public FeedbackResource(FeedbackService feedbackService) { - this.feedbackService = feedbackService; - } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java index 1ea1a68b..5d0207ce 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java @@ -36,7 +36,7 @@ */ @Component @Path("/files") -public class FileResource { +public final class FileResource { public static final String TEXT_CSV_MEDIA_TYPE = "text/csv"; @@ -76,7 +76,7 @@ public Response putFileById(@Context UriInfo uriInfo, @PathParam("id") String id .entity("The ID in the payload is not the same as the ID of resource.").build(); } - if (!file.getLocation().equals(cz.cuni.mff.xrg.odalic.util.URL.getResourceUrL(uriInfo, id))) { + if (!file.getLocation().equals(cz.cuni.mff.xrg.odalic.util.URL.getSubResourceAbsolutePath(uriInfo, id))) { return Response.status(Response.Status.NOT_ACCEPTABLE) .entity( "The location you provided for the file is not equal to the default location for uploaded file.") @@ -134,7 +134,7 @@ public Response postFile(@Context UriInfo uriInfo, @FormDataParam("file") FormDataContentDisposition fileDetail) throws IOException { final String id = fileDetail.getFileName(); - final File file = new File(id, "", cz.cuni.mff.xrg.odalic.util.URL.getResourceUrL(uriInfo, id)); + final File file = new File(id, "", cz.cuni.mff.xrg.odalic.util.URL.getSubResourceAbsolutePath(uriInfo, id)); if (fileService.existsFileWithId(id)) { return Response.status(Response.Status.NOT_ACCEPTABLE) diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ResultResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ResultResource.java index 36d491c7..a7565caf 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ResultResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ResultResource.java @@ -12,27 +12,37 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import com.google.common.base.Preconditions; + import cz.cuni.mff.xrg.odalic.tasks.executions.ExecutionService; +/** + * Result resource definition. + * + * @author Václav Brodec + * + */ @Component @Path("/tasks/{id}/result") -public class ResultResource { +public final class ResultResource { private final ExecutionService executionService; + + @Autowired + public ResultResource(ExecutionService executionService) { + Preconditions.checkNotNull(executionService); + + this.executionService = executionService; + } @GET @Produces(MediaType.APPLICATION_JSON) public Response getResult(@PathParam("id") String taskId) throws InterruptedException, ExecutionException { - if (executionService.isCancelledForTaskId(taskId)) { - return Response.status(Response.Status.NOT_FOUND).entity("The execution was cancelled.") + if (executionService.isCanceledForTaskId(taskId)) { + return Response.status(Response.Status.NOT_FOUND).entity("The execution was canceled.") .build(); } return Response.ok(executionService.getResultForTaskId(taskId)).build(); } - - @Autowired - public ResultResource(ExecutionService executionService) { - this.executionService = executionService; - } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/StateResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/StateResource.java index 98cb709a..de5285b3 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/StateResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/StateResource.java @@ -8,39 +8,49 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.values.StateValue; import cz.cuni.mff.xrg.odalic.tasks.executions.ExecutionService; -import cz.cuni.mff.xrg.odalic.tasks.executions.State; +/** + * State resource definition. + * + * @author Václav Brodec + * + */ @Component @Path("/tasks/{id}/state") -public class StateResource { +public final class StateResource { - private ExecutionService executionService; + private final ExecutionService executionService; + + @Autowired + public StateResource(ExecutionService executionService) { + Preconditions.checkNotNull(executionService); + + this.executionService = executionService; + } @GET @Produces({MediaType.APPLICATION_JSON}) - public State getStateForTaskId(@PathParam("id") String id) { + public StateValue getStateForTaskId(@PathParam("id") String id) { final boolean scheduled = executionService.hasBeenScheduledForTaskId(id); if (!scheduled) { - return State.READY; + return StateValue.READY; } final boolean done = executionService.isDoneForTaskId(id); - final boolean cancelled = executionService.isCancelledForTaskId(id); + final boolean canceled = executionService.isCanceledForTaskId(id); if (done) { - if (cancelled) { - return State.CANCELLED; + if (canceled) { + return StateValue.CANCELLED; } else { - return State.FINISHED; + return StateValue.FINISHED; } } else { - return State.SCHEDULED; + return StateValue.SCHEDULED; } } - - @Autowired - public StateResource(ExecutionService executionService) { - this.executionService = executionService; - } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/TaskResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/TaskResource.java index 4e430647..8072abca 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/TaskResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/TaskResource.java @@ -35,10 +35,19 @@ */ @Component @Path("/tasks") -public class TaskResource { +public final class TaskResource { - private TaskService taskService; - private FileService fileService; + private final TaskService taskService; + private final FileService fileService; + + @Autowired + public TaskResource(TaskService taskService, FileService fileService) { + Preconditions.checkNotNull(taskService); + Preconditions.checkNotNull(fileService); + + this.taskService = taskService; + this.fileService = fileService; + } @GET @Produces(MediaType.APPLICATION_JSON) @@ -75,13 +84,13 @@ public Response putTaskWithId(@Context UriInfo uriInfo, @PathParam("id") String taskService.create(task); return Response.status(Response.Status.CREATED) .entity("A new task has been created AT THE LOCATION you specified") - .header("Location", cz.cuni.mff.xrg.odalic.util.URL.getResourceUrL(uriInfo, id)).build(); + .header("Location", cz.cuni.mff.xrg.odalic.util.URL.getSubResourceAbsolutePath(uriInfo, id)).build(); } else { taskService.replace(task); return Response.status(Response.Status.OK) .entity( "The task you specified has been fully updated AT THE LOCATION you specified.") - .header("Location", cz.cuni.mff.xrg.odalic.util.URL.getResourceUrL(uriInfo, id)).build(); + .header("Location", cz.cuni.mff.xrg.odalic.util.URL.getSubResourceAbsolutePath(uriInfo, id)).build(); } } @@ -91,13 +100,4 @@ public Response deleteTaskById(@PathParam("id") String id) { taskService.deleteById(id); return Response.status(Response.Status.NO_CONTENT).build(); } - - @Autowired - public TaskResource(TaskService taskService, FileService fileService) { - Preconditions.checkNotNull(taskService); - Preconditions.checkNotNull(fileService); - - this.taskService = taskService; - this.fileService = fileService; - } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/AmbiguityValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/AmbiguityValue.java index 70965904..d965d203 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/AmbiguityValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/AmbiguityValue.java @@ -11,6 +11,12 @@ import cz.cuni.mff.xrg.odalic.feedbacks.Ambiguity; import cz.cuni.mff.xrg.odalic.positions.CellPosition; +/** + * Domain class {@link Ambiguity} adapted for REST API. + * + * @author Václav Brodec + * + */ @XmlRootElement(name = "ambiguity") public final class AmbiguityValue implements Serializable { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellAnnotationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellAnnotationValue.java index 792bd8e2..0b6b3fca 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellAnnotationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellAnnotationValue.java @@ -20,6 +20,19 @@ import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; +/** + *

+ * Domain class {@link CellAnnotation} adapted for REST API. + *

+ * + *

+ * In contrast to the adapted class, annotation in this version have only one set of candidates and + * the chosen ones are indicated by flags on each element. + *

+ * + * @author Václav Brodec + * + */ @XmlRootElement(name = "cellAnnotation") public final class CellAnnotationValue { @@ -27,7 +40,7 @@ public final class CellAnnotationValue { @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) private Map> candidates; - + public CellAnnotationValue() { candidates = ImmutableMap.of(); } @@ -37,17 +50,20 @@ public CellAnnotationValue() { */ public CellAnnotationValue(CellAnnotation adaptee) { final Map> chosen = adaptee.getChosen(); - - final ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); - for (final Map.Entry> entry : adaptee.getCandidates().entrySet()) { + + final ImmutableMap.Builder> candidatesBuilder = + ImmutableMap.builder(); + for (final Map.Entry> entry : adaptee + .getCandidates().entrySet()) { final KnowledgeBase base = entry.getKey(); final Set baseChosen = chosen.get(base); final NavigableSet baseCandidates = entry.getValue(); - - final Stream stream = baseCandidates.stream().map(e -> new EntityCandidateValue(e, baseChosen.contains(e))); + + final Stream stream = + baseCandidates.stream().map(e -> new EntityCandidateValue(e, baseChosen.contains(e))); candidatesBuilder.put(entry.getKey(), ImmutableSortedSet.copyOf(stream.iterator())); } - + this.candidates = candidatesBuilder.build(); } @@ -61,16 +77,22 @@ public Map> getCandidates() { /** * @param candidates the candidates to set */ - public void setCandidates(Map> candidates) { - ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); - for (final Map.Entry> candidateEntry : candidates.entrySet()) { - candidatesBuilder.put(candidateEntry.getKey(), ImmutableSortedSet.copyOf(candidateEntry.getValue())); + public void setCandidates( + Map> candidates) { + ImmutableMap.Builder> candidatesBuilder = + ImmutableMap.builder(); + for (final Map.Entry> candidateEntry : candidates + .entrySet()) { + candidatesBuilder.put(candidateEntry.getKey(), + ImmutableSortedSet.copyOf(candidateEntry.getValue())); } - + this.candidates = candidatesBuilder.build(); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellPositionValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellPositionValue.java index 22ead54f..4fcfa6cc 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellPositionValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellPositionValue.java @@ -10,6 +10,12 @@ import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; import cz.cuni.mff.xrg.odalic.positions.RowPosition; +/** + * Domain class {@link CellPosition} adapted for REST API. + * + * @author Václav Brodec + * + */ @XmlRootElement(name = "cellPosition") public class CellPositionValue { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationAnnotationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationAnnotationValue.java index 3716965a..8c4c4a8d 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationAnnotationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationAnnotationValue.java @@ -20,6 +20,19 @@ import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; +/** + *

+ * Domain class {@link CellRelationAnnotation} adapted for REST API. + *

+ * + *

+ * In contrast to the adapted class, annotation in this version have only one set of candidates and + * the chosen ones are indicated by flags on each element. + *

+ * + * @author Václav Brodec + * + */ @XmlRootElement(name = "cellRelationAnnotation") public final class CellRelationAnnotationValue { @@ -27,7 +40,7 @@ public final class CellRelationAnnotationValue { @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) private Map> candidates; - + public CellRelationAnnotationValue() { candidates = ImmutableMap.of(); } @@ -37,17 +50,20 @@ public CellRelationAnnotationValue() { */ public CellRelationAnnotationValue(CellRelationAnnotation adaptee) { final Map> chosen = adaptee.getChosen(); - - final ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); - for (final Map.Entry> entry : adaptee.getCandidates().entrySet()) { + + final ImmutableMap.Builder> candidatesBuilder = + ImmutableMap.builder(); + for (final Map.Entry> entry : adaptee + .getCandidates().entrySet()) { final KnowledgeBase base = entry.getKey(); final Set baseChosen = chosen.get(base); final NavigableSet baseCandidates = entry.getValue(); - - final Stream stream = baseCandidates.stream().map(e -> new EntityCandidateValue(e, baseChosen.contains(e))); + + final Stream stream = + baseCandidates.stream().map(e -> new EntityCandidateValue(e, baseChosen.contains(e))); candidatesBuilder.put(entry.getKey(), ImmutableSortedSet.copyOf(stream.iterator())); } - + this.candidates = candidatesBuilder.build(); } @@ -61,16 +77,22 @@ public Map> getCandidates() { /** * @param candidates the candidates to set */ - public void setCandidates(Map> candidates) { - ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); - for (final Map.Entry> candidateEntry : candidates.entrySet()) { - candidatesBuilder.put(candidateEntry.getKey(), ImmutableSortedSet.copyOf(candidateEntry.getValue())); + public void setCandidates( + Map> candidates) { + ImmutableMap.Builder> candidatesBuilder = + ImmutableMap.builder(); + for (final Map.Entry> candidateEntry : candidates + .entrySet()) { + candidatesBuilder.put(candidateEntry.getKey(), + ImmutableSortedSet.copyOf(candidateEntry.getValue())); } - + this.candidates = candidatesBuilder.build(); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationPositionValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationPositionValue.java index 07596205..4c905ff6 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationPositionValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationPositionValue.java @@ -12,6 +12,12 @@ import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; import cz.cuni.mff.xrg.odalic.positions.RowPosition; +/** + * Domain class {@link CellRelationPosition} adapted for REST API. + * + * @author Václav Brodec + * + */ @XmlRootElement(name = "cellRelationPosition") public class CellRelationPositionValue implements Serializable { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationValue.java index 0fdb88a0..8f0238c9 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationValue.java @@ -12,6 +12,12 @@ import cz.cuni.mff.xrg.odalic.positions.CellRelationPosition; import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; +/** + * Domain class {@link CellRelation} adapted for REST API. + * + * @author Václav Brodec + * + */ @XmlRootElement(name = "cellRelation") public final class CellRelationValue implements Serializable { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ClassificationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ClassificationValue.java index 61da2cc4..1c7b40f1 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ClassificationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ClassificationValue.java @@ -12,6 +12,12 @@ import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; import cz.cuni.mff.xrg.odalic.tasks.annotations.HeaderAnnotation; +/** + * Domain class {@link Classification} adapted for REST API. + * + * @author Václav Brodec + * + */ @XmlRootElement(name = "classification") public class ClassificationValue implements Serializable { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnAmbiguityValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnAmbiguityValue.java index bd16e713..8e9cdb2f 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnAmbiguityValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnAmbiguityValue.java @@ -11,6 +11,12 @@ import cz.cuni.mff.xrg.odalic.feedbacks.ColumnAmbiguity; import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +/** + * Domain class {@link ColumnAmbiguity} adapted for REST API. + * + * @author Václav Brodec + * + */ @XmlRootElement(name = "columnAmbiguity") public final class ColumnAmbiguityValue implements Serializable { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnIgnoreValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnIgnoreValue.java index 6b01b38e..025aa291 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnIgnoreValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnIgnoreValue.java @@ -11,6 +11,12 @@ import cz.cuni.mff.xrg.odalic.feedbacks.ColumnIgnore; import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +/** + * Domain class {@link ColumnIgnore} adapted for REST API. + * + * @author Václav Brodec + * + */ @XmlRootElement(name = "columnIgnore") public final class ColumnIgnoreValue implements Serializable { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnPositionValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnPositionValue.java index da6b089b..a1b81551 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnPositionValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnPositionValue.java @@ -7,8 +7,14 @@ import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +/** + * Domain class {@link ColumnPosition} adapted for REST API. + * + * @author Václav Brodec + * + */ @XmlRootElement(name = "columnPosition") -public class ColumnPositionValue { +public final class ColumnPositionValue { @XmlElement private int index; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationAnnotationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationAnnotationValue.java index 654af6d0..4400c599 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationAnnotationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationAnnotationValue.java @@ -20,6 +20,19 @@ import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; +/** + *

+ * Domain class {@link ColumnRelationAnnotation} adapted for REST API. + *

+ * + *

+ * In contrast to the adapted class, annotation in this version have only one set of candidates and + * the chosen ones are indicated by flags on each element. + *

+ * + * @author Václav Brodec + * + */ @XmlRootElement(name = "columnRelationAnnotation") public final class ColumnRelationAnnotationValue { @@ -27,7 +40,7 @@ public final class ColumnRelationAnnotationValue { @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) private Map> candidates; - + public ColumnRelationAnnotationValue() { candidates = ImmutableMap.of(); } @@ -37,17 +50,20 @@ public ColumnRelationAnnotationValue() { */ public ColumnRelationAnnotationValue(ColumnRelationAnnotation adaptee) { final Map> chosen = adaptee.getChosen(); - - final ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); - for (final Map.Entry> entry : adaptee.getCandidates().entrySet()) { + + final ImmutableMap.Builder> candidatesBuilder = + ImmutableMap.builder(); + for (final Map.Entry> entry : adaptee + .getCandidates().entrySet()) { final KnowledgeBase base = entry.getKey(); final Set baseChosen = chosen.get(base); final NavigableSet baseCandidates = entry.getValue(); - - final Stream stream = baseCandidates.stream().map(e -> new EntityCandidateValue(e, baseChosen.contains(e))); + + final Stream stream = + baseCandidates.stream().map(e -> new EntityCandidateValue(e, baseChosen.contains(e))); candidatesBuilder.put(entry.getKey(), ImmutableSortedSet.copyOf(stream.iterator())); } - + this.candidates = candidatesBuilder.build(); } @@ -61,16 +77,22 @@ public Map> getCandidates() { /** * @param candidates the candidates to set */ - public void setCandidates(Map> candidates) { - ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); - for (final Map.Entry> candidateEntry : candidates.entrySet()) { - candidatesBuilder.put(candidateEntry.getKey(), ImmutableSortedSet.copyOf(candidateEntry.getValue())); + public void setCandidates( + Map> candidates) { + ImmutableMap.Builder> candidatesBuilder = + ImmutableMap.builder(); + for (final Map.Entry> candidateEntry : candidates + .entrySet()) { + candidatesBuilder.put(candidateEntry.getKey(), + ImmutableSortedSet.copyOf(candidateEntry.getValue())); } - + this.candidates = candidatesBuilder.build(); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationPositionValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationPositionValue.java index 916300ce..b403b5a0 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationPositionValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationPositionValue.java @@ -9,8 +9,14 @@ import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; +/** + * Domain class {@link ColumnRelationPosition} adapted for REST API. + * + * @author Václav Brodec + * + */ @XmlRootElement(name = "cellPosition") -public class ColumnRelationPositionValue { +public final class ColumnRelationPositionValue { @XmlElement private ColumnPosition first; @@ -20,9 +26,6 @@ public class ColumnRelationPositionValue { public ColumnRelationPositionValue() {} - /** - * @param adaptee - */ public ColumnRelationPositionValue(ColumnRelationPosition adaptee) { this.first = adaptee.getFirst(); this.second = adaptee.getSecond(); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationValue.java index f3c1e852..b489b262 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationValue.java @@ -12,6 +12,12 @@ import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; +/** + * Domain class {@link ColumnRelation} adapted for REST API. + * + * @author Václav Brodec + * + */ @XmlRootElement(name = "columnRelation") public final class ColumnRelationValue implements Serializable { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java index 8748a6e0..d8ef2d63 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java @@ -6,25 +6,29 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import com.google.common.base.Preconditions; + import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; +/** + * Domain class {@link Configuration} adapted for REST API. + * + * @author Václav Brodec + * + */ @XmlRootElement(name = "configuration") public final class ConfigurationValue implements Serializable { private static final long serialVersionUID = -6359038623760039155L; @XmlElement(name = "input") - private final String input; + private String input; @XmlElement(name = "feedback") - private final Feedback feedback; + private Feedback feedback; - @SuppressWarnings("unused") - private ConfigurationValue() { - input = null; - feedback = null; - } + public ConfigurationValue() {} public ConfigurationValue(Configuration adaptee) { input = adaptee.getInput().getId(); @@ -39,6 +43,15 @@ public String getInput() { return input; } + /** + * @param input the input to set + */ + public void setInput(String input) { + Preconditions.checkNotNull(input); + + this.input = input; + } + /** * @return the feedback */ @@ -47,6 +60,16 @@ public Feedback getFeedback() { return feedback; } + + /** + * @param feedback the feedback to set + */ + public void setFeedback(Feedback feedback) { + Preconditions.checkNotNull(feedback); + + this.feedback = feedback; + } + /* (non-Javadoc) * @see java.lang.Object#toString() */ diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/DisambiguationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/DisambiguationValue.java index 73be2b65..f4a9dd86 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/DisambiguationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/DisambiguationValue.java @@ -12,6 +12,12 @@ import cz.cuni.mff.xrg.odalic.positions.CellPosition; import cz.cuni.mff.xrg.odalic.tasks.annotations.CellAnnotation; +/** + * Domain class {@link Disambiguation} adapted for REST API. + * + * @author Václav Brodec + * + */ @XmlRootElement(name = "disambiguation") public final class DisambiguationValue implements Serializable { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityCandidateValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityCandidateValue.java index e2c53b5c..3178880f 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityCandidateValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityCandidateValue.java @@ -4,6 +4,7 @@ import javax.annotation.Nullable; import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; import com.google.common.base.Preconditions; @@ -11,28 +12,35 @@ import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; import cz.cuni.mff.xrg.odalic.tasks.annotations.Likelihood; +/** + *

+ * Domain class {@link EntityCandidate} adapted for REST API. + *

+ * + *

+ * In this version it supports a chosen flag instead of annotations classes providing the chosen + * set separately. + *

+ * + * @author Václav Brodec + * + */ +@XmlRootElement(name = "entityCandidate") public final class EntityCandidateValue implements Serializable, Comparable { - + private static final long serialVersionUID = 3072774254576336747L; @XmlElement private Entity entity; - + @XmlElement private Likelihood likelihood; - + @XmlElement private boolean chosen; - /** - * @param entity - * @param likelihood - */ - public EntityCandidateValue() { } + public EntityCandidateValue() {} - /** - * @param adaptee - */ public EntityCandidateValue(EntityCandidate adaptee, boolean chosen) { entity = adaptee.getEntity(); likelihood = adaptee.getLikelihood(); @@ -52,7 +60,7 @@ public Entity getEntity() { */ public void setEntity(Entity entity) { Preconditions.checkNotNull(entity); - + this.entity = entity; } @@ -69,7 +77,7 @@ public Likelihood getLikelihood() { */ public void setLikelihood(Likelihood likelihood) { Preconditions.checkNotNull(likelihood); - + this.likelihood = likelihood; } @@ -86,8 +94,50 @@ public boolean isChosen() { public void setChosen(boolean chosen) { this.chosen = chosen; } + + + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + new EntityCandidate(entity, likelihood).hashCode(); + return result; + } /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + EntityCandidateValue other = (EntityCandidateValue) obj; + return new EntityCandidate(entity, likelihood).equals(new EntityCandidate(other.entity, other.likelihood)); + } + + /* (non-Javadoc) + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ + @Override + public int compareTo(EntityCandidateValue other) { + return new EntityCandidate(entity, likelihood) + .compareTo(new EntityCandidate(other.entity, other.likelihood)); + } + + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override @@ -95,15 +145,4 @@ public String toString() { return "EntityCandidateValue [entity=" + entity + ", likelihood=" + likelihood + ", chosen=" + chosen + "]"; } - - @Override - public int compareTo(EntityCandidateValue o) { - final int likelihoodComparison = likelihood.compareTo(o.likelihood); - - if (likelihoodComparison == 0) { - return entity.compareTo(o.entity); - } else { - return likelihoodComparison; - } - } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityValue.java index c205d285..22cb9e54 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityValue.java @@ -1,8 +1,6 @@ package cz.cuni.mff.xrg.odalic.api.rest.values; import java.io.Serializable; -import java.net.URI; - import javax.annotation.Nullable; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -11,8 +9,14 @@ import cz.cuni.mff.xrg.odalic.tasks.annotations.Entity; +/** + * Domain class {@link Entity} adapted for REST API. + * + * @author Václav Brodec + * + */ @XmlRootElement(name = "entity") -public class EntityValue implements Serializable { +public final class EntityValue implements Serializable { private static final long serialVersionUID = 5750987769573292984L; @@ -25,12 +29,12 @@ public class EntityValue implements Serializable { public EntityValue() {} public EntityValue(Entity adaptee) { - this.resource = adaptee.getResourceID(); + this.resource = adaptee.getResource(); this.label = adaptee.getLabel(); } /** - * @return the resource + * @return the resource ID */ @Nullable public String getResource() { @@ -38,9 +42,9 @@ public String getResource() { } /** - * @param resource the resource to set + * @param resource the resource ID to set */ - public void setResouce(String resource) { + public void setResource(String resource) { Preconditions.checkNotNull(resource); this.resource = resource; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ExecutionValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ExecutionValue.java new file mode 100644 index 00000000..9a6a0bca --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ExecutionValue.java @@ -0,0 +1,62 @@ +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Abstract resource used to symbolize submitting a task for execution when put and canceling the + * execution when deleted. + * + * @author Václav Brodec + * + */ +@XmlRootElement(name = "execution") +public final class ExecutionValue implements Serializable { + + private static final long serialVersionUID = -6359038623760039155L; + + /** + * Draft flag (reserved for future versions). + */ + @XmlElement + private boolean draft; + + public ExecutionValue() { + draft = false; + } + + /** + * Creates execution resource representation. + * + * @param draft draft indicator + */ + public ExecutionValue(boolean draft) { + this.draft = draft; + } + + /** + * @return indicates draft execution + */ + public boolean isDraft() { + return draft; + } + + /** + * @param draft the draft indicator to set + */ + public void setDraft(boolean draft) { + this.draft = draft; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ExecutionValue [draft=" + draft + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/FeedbackValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/FeedbackValue.java index cae42ffa..1ac65d85 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/FeedbackValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/FeedbackValue.java @@ -19,8 +19,14 @@ import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +/** + * Domain class {@link Feedback} adapted for REST API. + * + * @author Václav Brodec + * + */ @XmlRootElement(name = "feedback") -public class FeedbackValue implements Serializable { +public final class FeedbackValue implements Serializable { private static final long serialVersionUID = -7968455903789693405L; @@ -49,31 +55,29 @@ public class FeedbackValue implements Serializable { private Set ambiguities; public FeedbackValue() { - this.subjectColumnPosition = null; - this.columnIgnores = ImmutableSet.of(); - this.columnAmbiguities = ImmutableSet.of(); - this.classifications = ImmutableSet.of(); - this.cellRelations = ImmutableSet.of(); - this.columnRelations = ImmutableSet.of(); - this.disambiguations = ImmutableSet.of(); - this.ambiguities = ImmutableSet.of(); + subjectColumnPosition = null; + columnIgnores = ImmutableSet.of(); + columnAmbiguities = ImmutableSet.of(); + classifications = ImmutableSet.of(); + cellRelations = ImmutableSet.of(); + columnRelations = ImmutableSet.of(); + disambiguations = ImmutableSet.of(); + ambiguities = ImmutableSet.of(); } public FeedbackValue(Feedback adaptee) { - Preconditions.checkNotNull(adaptee); - - this.subjectColumnPosition = adaptee.getSubjectColumnPosition(); - this.columnIgnores = adaptee.getColumnIgnores(); - this.columnAmbiguities = adaptee.getColumnAmbiguities(); - this.classifications = adaptee.getClassifications(); - this.cellRelations = adaptee.getCellRelations(); - this.columnRelations = adaptee.getColumnRelations(); - this.disambiguations = adaptee.getDisambiguations(); - this.ambiguities = adaptee.getAmbiguities(); + subjectColumnPosition = adaptee.getSubjectColumnPosition(); + columnIgnores = adaptee.getColumnIgnores(); + columnAmbiguities = adaptee.getColumnAmbiguities(); + classifications = adaptee.getClassifications(); + cellRelations = adaptee.getCellRelations(); + columnRelations = adaptee.getColumnRelations(); + disambiguations = adaptee.getDisambiguations(); + ambiguities = adaptee.getAmbiguities(); } /** - * @return the subjectColumnPosition + * @return the subject column position */ @Nullable public ColumnPosition getSubjectColumnPosition() { @@ -81,21 +85,21 @@ public ColumnPosition getSubjectColumnPosition() { } /** - * @param subjectColumnPosition the subjectColumnPosition to set + * @param subjectColumnPosition the subject column position to set */ public void setSubjectColumnPosition(ColumnPosition subjectColumnPosition) { this.subjectColumnPosition = subjectColumnPosition; } /** - * @return the columnIgnores + * @return the column ignores */ public Set getColumnIgnores() { return columnIgnores; } /** - * @param columnIgnores the columnIgnores to set + * @param columnIgnores the column ignores to set */ public void setColumnIgnores(Set columnIgnores) { Preconditions.checkNotNull(columnIgnores); @@ -104,14 +108,14 @@ public void setColumnIgnores(Set columnIgnores) { } /** - * @return the columnAmbiguities + * @return the column ambiguities */ public Set getColumnAmbiguities() { return columnAmbiguities; } /** - * @param columnAmbiguities the columnAmbiguities to set + * @param columnAmbiguities the column ambiguities to set */ public void setColumnAmbiguities(Set columnAmbiguities) { Preconditions.checkNotNull(columnAmbiguities); @@ -136,7 +140,7 @@ public void setClassifications(Set classifications) { } /** - * @return the cellRelations + * @return the cell relations */ public Set getCellRelations() { return cellRelations; @@ -152,14 +156,14 @@ public void setCellRelations(Set cellRelations) { } /** - * @return the columnRelations + * @return the column relations */ public Set getColumnRelations() { return columnRelations; } /** - * @param columnRelations the columnRelations to set + * @param columnRelations the column relations to set */ public void setColumnRelations(Set columnRelations) { Preconditions.checkNotNull(columnRelations); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/FileValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/FileValue.java new file mode 100644 index 00000000..f81bb286 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/FileValue.java @@ -0,0 +1,130 @@ +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; +import java.net.URL; +import java.util.Date; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateSerializer; +import cz.cuni.mff.xrg.odalic.files.File; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateDeserializer; + +/** + * Domain class {@link File} adapted for REST API. + * + * @author Václav Brodec + * + */ +@XmlRootElement(name = "file") +public final class FileValue implements Serializable { + + private static final long serialVersionUID = -6359038623760039155L; + + @XmlElement + private String id; + + @JsonSerialize(using = CustomJsonDateSerializer.class) + @JsonDeserialize(using = CustomJsonDateDeserializer.class) + @XmlElement + private Date uploaded; + + @XmlElement + private String owner; + + @XmlElement + private URL location; + + public FileValue() {} + + public FileValue(File adaptee) { + id = adaptee.getId(); + uploaded = adaptee.getUploaded(); + owner = adaptee.getOwner(); + location = adaptee.getLocation(); + } + + /** + * @return the id + */ + @Nullable + public String getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(String id) { + Preconditions.checkNotNull(id); + + this.id = id; + } + + /** + * @return the uploaded + */ + @Nullable + public Date getUploaded() { + return uploaded; + } + + /** + * @param uploaded the uploaded to set + */ + public void setUploaded(Date uploaded) { + Preconditions.checkNotNull(uploaded); + + this.uploaded = uploaded; + } + + /** + * @return the owner + */ + @Nullable + public String getOwner() { + return owner; + } + + /** + * @param owner the owner to set + */ + public void setOwner(String owner) { + Preconditions.checkNotNull(owner); + + this.owner = owner; + } + + /** + * @return the location + */ + @Nullable + public URL getLocation() { + return location; + } + + /** + * @param location the location to set + */ + public void setLocation(URL location) { + Preconditions.checkNotNull(location); + + this.location = location; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "FileValue [id=" + id + ", uploaded=" + uploaded + ", owner=" + owner + ", location=" + + location + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/HeaderAnnotationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/HeaderAnnotationValue.java index 4051d5e3..4d4eb70b 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/HeaderAnnotationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/HeaderAnnotationValue.java @@ -20,6 +20,19 @@ import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; +/** + *

+ * Domain class {@link HeaderAnnotation} adapted for REST API. + *

+ * + *

+ * In contrast to the adapted class, annotation in this version have only one set of candidates and + * the chosen ones are indicated by flags on each element. + *

+ * + * @author Václav Brodec + * + */ @XmlRootElement(name = "headerAnnotation") public final class HeaderAnnotationValue { @@ -27,7 +40,7 @@ public final class HeaderAnnotationValue { @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) private Map> candidates; - + public HeaderAnnotationValue() { candidates = ImmutableMap.of(); } @@ -37,17 +50,20 @@ public HeaderAnnotationValue() { */ public HeaderAnnotationValue(HeaderAnnotation adaptee) { final Map> chosen = adaptee.getChosen(); - - final ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); - for (final Map.Entry> entry : adaptee.getCandidates().entrySet()) { + + final ImmutableMap.Builder> candidatesBuilder = + ImmutableMap.builder(); + for (final Map.Entry> entry : adaptee + .getCandidates().entrySet()) { final KnowledgeBase base = entry.getKey(); final Set baseChosen = chosen.get(base); final NavigableSet baseCandidates = entry.getValue(); - - final Stream stream = baseCandidates.stream().map(e -> new EntityCandidateValue(e, baseChosen.contains(e))); + + final Stream stream = + baseCandidates.stream().map(e -> new EntityCandidateValue(e, baseChosen.contains(e))); candidatesBuilder.put(entry.getKey(), ImmutableSortedSet.copyOf(stream.iterator())); } - + this.candidates = candidatesBuilder.build(); } @@ -61,16 +77,22 @@ public Map> getCandidates() { /** * @param candidates the candidates to set */ - public void setCandidates(Map> candidates) { - ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); - for (final Map.Entry> candidateEntry : candidates.entrySet()) { - candidatesBuilder.put(candidateEntry.getKey(), ImmutableSortedSet.copyOf(candidateEntry.getValue())); + public void setCandidates( + Map> candidates) { + ImmutableMap.Builder> candidatesBuilder = + ImmutableMap.builder(); + for (final Map.Entry> candidateEntry : candidates + .entrySet()) { + candidatesBuilder.put(candidateEntry.getKey(), + ImmutableSortedSet.copyOf(candidateEntry.getValue())); } - + this.candidates = candidatesBuilder.build(); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/KnowledgeBaseValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/KnowledgeBaseValue.java index 05f0cf33..ba60284f 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/KnowledgeBaseValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/KnowledgeBaseValue.java @@ -7,8 +7,14 @@ import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; +/** + * Domain class {@link KnowledgeBase} adapted for REST API. + * + * @author Václav Brodec + * + */ @XmlRootElement(name = "knowledgeBase") -public class KnowledgeBaseValue { +public final class KnowledgeBaseValue { private String name; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/LikelihoodValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/LikelihoodValue.java index 9f874206..918e630a 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/LikelihoodValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/LikelihoodValue.java @@ -9,6 +9,12 @@ import cz.cuni.mff.xrg.odalic.tasks.annotations.Likelihood; +/** + * Domain class {@link Likelihood} adapted for REST API. + * + * @author Václav Brodec + * + */ @XmlRootElement(name = "likelihood") public final class LikelihoodValue implements Serializable { @@ -17,14 +23,16 @@ public final class LikelihoodValue implements Serializable { @XmlElement private double value; - public LikelihoodValue() {} + public LikelihoodValue() { + value = Double.MIN_VALUE; + } public LikelihoodValue(Likelihood adaptee) { value = adaptee.getValue(); } /** - * @return the value + * @return the value (when not set, may be out of range) */ public double getValue() { return value; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ResultValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ResultValue.java index a8bc1786..f43fbbb0 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ResultValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ResultValue.java @@ -11,9 +11,19 @@ import org.apache.jena.ext.com.google.common.collect.ImmutableMap; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.ColumnPositionKeyJsonDeserializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.ColumnPositionKeyJsonSerializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.ColumnPositionToColumnPositionToCellRelationAnnotationMapMapDeserializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.ColumnPositionToColumnPositionToCellRelationAnnotationMapMapSerializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.ColumnPositionToColumnRelationAnnotationMapDeserializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.ColumnPositionToColumnRelationAnnotationMapSerializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.RowPositionKeyJsonDeserializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.RowPositionKeyJsonSerializer; import cz.cuni.mff.xrg.odalic.positions.CellRelationPosition; import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; @@ -24,8 +34,14 @@ import cz.cuni.mff.xrg.odalic.tasks.annotations.HeaderAnnotation; import cz.cuni.mff.xrg.odalic.tasks.results.Result; +/** + * Domain class {@link Result} adapted for REST API. + * + * @author Václav Brodec + * + */ @XmlRootElement(name = "result") -public class ResultValue implements Serializable { +public final class ResultValue implements Serializable { private static final long serialVersionUID = -6359038623760039155L; @@ -39,13 +55,16 @@ public class ResultValue implements Serializable { private CellAnnotation[][] cellAnnotations; @XmlElement + @JsonDeserialize(keyUsing = ColumnPositionKeyJsonDeserializer.class, contentUsing = ColumnPositionToColumnRelationAnnotationMapDeserializer.class) + @JsonSerialize(keyUsing = ColumnPositionKeyJsonSerializer.class, contentUsing = ColumnPositionToColumnRelationAnnotationMapSerializer.class) private Map> columnRelationAnnotations; @XmlElement + @JsonDeserialize(keyUsing = RowPositionKeyJsonDeserializer.class, contentUsing = ColumnPositionToColumnPositionToCellRelationAnnotationMapMapDeserializer.class) + @JsonSerialize(keyUsing = RowPositionKeyJsonSerializer.class, contentUsing = ColumnPositionToColumnPositionToCellRelationAnnotationMapMapSerializer.class) private Map>> cellRelationAnnotations; - @SuppressWarnings("unused") - private ResultValue() { + public ResultValue() { subjectColumnPosition = null; headerAnnotations = ImmutableList.of(); cellAnnotations = new CellAnnotation[0][0];; @@ -93,14 +112,15 @@ public ResultValue(Result adaptee) { } /** - * @return the subjectColumnPosition + * @return the subject column position */ + @Nullable public ColumnPosition getSubjectColumnPosition() { return subjectColumnPosition; } /** - * @param subjectColumnPosition the subjectColumnPosition to set + * @param subjectColumnPosition the subject column position to set */ public void setSubjectColumnPosition(ColumnPosition subjectColumnPosition) { Preconditions.checkNotNull(subjectColumnPosition); @@ -109,15 +129,14 @@ public void setSubjectColumnPosition(ColumnPosition subjectColumnPosition) { } /** - * @return the headerAnnotations + * @return the header annotations */ - @Nullable public List getHeaderAnnotations() { return headerAnnotations; } /** - * @param headerAnnotations the headerAnnotations to set + * @param headerAnnotations the header annotations to set */ public void setHeaderAnnotations(List headerAnnotations) { Preconditions.checkNotNull(headerAnnotations); @@ -126,15 +145,14 @@ public void setHeaderAnnotations(List headerAnnotations) { } /** - * @return the cellAnnotations + * @return the cell annotations */ - @Nullable public CellAnnotation[][] getCellAnnotations() { return cz.cuni.mff.xrg.odalic.util.Arrays.deepCopy(CellAnnotation.class, cellAnnotations); } /** - * @param cellAnnotations the cellAnnotations to set + * @param cellAnnotations the cell annotations to set */ public void setCellAnnotations(CellAnnotation[][] cellAnnotations) { Preconditions.checkNotNull(cellAnnotations); @@ -143,15 +161,14 @@ public void setCellAnnotations(CellAnnotation[][] cellAnnotations) { } /** - * @return the columnRelationAnnotations + * @return the column relation Annotations */ - @Nullable public Map> getColumnRelationAnnotations() { return columnRelationAnnotations; } /** - * @param columnRelationAnnotations the columnRelationAnnotations to set + * @param columnRelationAnnotations the column relation annotations to set */ public void setColumnRelationAnnotations( Map> columnRelationAnnotations) { @@ -163,15 +180,14 @@ public void setColumnRelationAnnotations( } /** - * @return the cellRelationAnnotations + * @return the cell relation annotations */ - @Nullable public Map>> getCellRelationAnnotations() { return cellRelationAnnotations; } /** - * @param cellRelationAnnotations the cellRelationAnnotations to set + * @param cellRelationAnnotations the cell relation annotations to set */ public void setCellRelationAnnotations( Map>> cellRelationAnnotations) { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/RowPositionValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/RowPositionValue.java index 5e8d6c43..662ff88f 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/RowPositionValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/RowPositionValue.java @@ -3,10 +3,18 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import com.google.common.base.Preconditions; + import cz.cuni.mff.xrg.odalic.positions.RowPosition; +/** + * Domain class {@link RowPosition} adapted for REST API. + * + * @author Václav Brodec + * + */ @XmlRootElement(name = "rowPosition") -public class RowPositionValue { +public final class RowPositionValue { @XmlElement private int index; @@ -31,6 +39,8 @@ public int getIndex() { * @param index the index to set */ public void setIndex(int index) { + Preconditions.checkArgument(index >= 0); + this.index = index; } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/StateValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/StateValue.java new file mode 100644 index 00000000..0f8a02fb --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/StateValue.java @@ -0,0 +1,41 @@ +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +import cz.cuni.mff.xrg.odalic.tasks.Task; +import cz.cuni.mff.xrg.odalic.tasks.executions.ExecutionService; + +/** + * Explicit {@link Task} execution state representation for REST API. + * + * @author Václav Brodec + * + * @see ExecutionService + */ +@XmlType +@XmlEnum(String.class) +@XmlRootElement(name = "state") +public enum StateValue { + /** + * Task is specified, but not yet submitted for execution. + */ + @XmlEnumValue("READY") READY, + + /** + * Task is submitted for execution, but not done or canceled yet. + */ + @XmlEnumValue("SCHEDULED") SCHEDULED, + + /** + * Task execution has been voluntarily canceled and no new is submitted. + */ + @XmlEnumValue("CANCELLED") CANCELLED, + + /** + * Task execution has ended (either with result or error). + */ + @XmlEnumValue("FINISHED") FINISHED +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/TaskValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/TaskValue.java index 9b409a76..1a8e60a9 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/TaskValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/TaskValue.java @@ -16,6 +16,12 @@ import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateSerializer; import cz.cuni.mff.xrg.odalic.tasks.Task; +/** + * Domain class {@link Task} adapted for REST API. + * + * @author Václav Brodec + * + */ @XmlRootElement(name = "task") public final class TaskValue implements Serializable { @@ -32,16 +38,8 @@ public final class TaskValue implements Serializable { @XmlElement private ConfigurationValue configuration; - public TaskValue() { - id = null; - created = null; - configuration = null; - } + public TaskValue() {} - /** - * @param id - * @param created - */ public TaskValue(Task adaptee) { id = adaptee.getId(); created = adaptee.getCreated(); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Ambiguity.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Ambiguity.java index 9327fd24..17241e40 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Ambiguity.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Ambiguity.java @@ -2,25 +2,27 @@ import java.io.Serializable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + import com.google.common.base.Preconditions; +import cz.cuni.mff.xrg.odalic.api.rest.adapters.AmbiguityAdapter; import cz.cuni.mff.xrg.odalic.positions.CellPosition; -@XmlRootElement(name = "ambiguity") +@Immutable +@XmlJavaTypeAdapter(AmbiguityAdapter.class) public final class Ambiguity implements Serializable { private static final long serialVersionUID = -9087389821835847372L; - @XmlElement private final CellPosition position; - @SuppressWarnings("unused") - private Ambiguity() { - position = null; - } - + /** + * Creates a new hint to keep a cell ambiguous. + * + * @param position position of the cell + */ public Ambiguity(CellPosition position) { Preconditions.checkNotNull(position); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/CellRelation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/CellRelation.java index ca491845..912093d6 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/CellRelation.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/CellRelation.java @@ -2,33 +2,36 @@ import java.io.Serializable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + import com.google.common.base.Preconditions; +import cz.cuni.mff.xrg.odalic.api.rest.adapters.CellRelationAdapter; import cz.cuni.mff.xrg.odalic.positions.CellRelationPosition; import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; -@XmlRootElement(name = "cellRelation") +/** + * Cell relation hint. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(CellRelationAdapter.class) public final class CellRelation implements Serializable { private static final long serialVersionUID = -9087389821835847372L; - @XmlElement private final CellRelationPosition position; - @XmlElement private final CellRelationAnnotation annotation; - @SuppressWarnings("unused") - private CellRelation() { - position = null; - annotation = null; - } - /** - * @param position - * @param annotation + * Creates new hint for discovered cell relations. + * + * @param position cell position + * @param annotation custom annotation */ public CellRelation(CellRelationPosition position, CellRelationAnnotation annotation) { Preconditions.checkNotNull(position); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Classification.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Classification.java index 8091e23d..24494ac2 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Classification.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Classification.java @@ -2,13 +2,21 @@ import java.io.Serializable; import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + import com.google.common.base.Preconditions; +import cz.cuni.mff.xrg.odalic.api.rest.adapters.ClassificationAdapter; import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; import cz.cuni.mff.xrg.odalic.tasks.annotations.HeaderAnnotation; -@XmlRootElement(name = "classification") +/** + * Classification hint. + * + * @author Václav Brodec + * + */ +@XmlJavaTypeAdapter(ClassificationAdapter.class) public final class Classification implements Serializable { private static final long serialVersionUID = 6053349406668481968L; @@ -19,12 +27,12 @@ public final class Classification implements Serializable { @XmlElement private final HeaderAnnotation annotation; - @SuppressWarnings("unused") - private Classification() { - position = null; - annotation = null; - } - + /** + * Creates custom classification hint of a column. + * + * @param position column position + * @param annotation custom annotation + */ public Classification(ColumnPosition position, HeaderAnnotation annotation) { Preconditions.checkNotNull(position); Preconditions.checkNotNull(annotation); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnAmbiguity.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnAmbiguity.java index fdc62094..e32f4652 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnAmbiguity.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnAmbiguity.java @@ -2,27 +2,32 @@ import java.io.Serializable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + import com.google.common.base.Preconditions; +import cz.cuni.mff.xrg.odalic.api.rest.adapters.ColumnAmbiguityAdapter; import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; -@XmlRootElement(name = "columnAmbiguity") +/** + * Hint to leave the cells in column ambiguous. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(ColumnAmbiguityAdapter.class) public final class ColumnAmbiguity implements Serializable { private static final long serialVersionUID = -6608929731300596230L; - @XmlElement private final ColumnPosition position; - @SuppressWarnings("unused") - private ColumnAmbiguity() { - position = null; - } - /** - * @param position + * Creates a new hint to leave the cells in column ambiguous. + * + * @param position column position */ public ColumnAmbiguity(ColumnPosition position) { Preconditions.checkNotNull(position); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnIgnore.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnIgnore.java index fd0ea7c7..0dcae759 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnIgnore.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnIgnore.java @@ -2,27 +2,32 @@ import java.io.Serializable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + import com.google.common.base.Preconditions; +import cz.cuni.mff.xrg.odalic.api.rest.adapters.ColumnIgnoreAdapter; import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; -@XmlRootElement(name = "columnIgnore") +/** + * Hint to ignore column. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(ColumnIgnoreAdapter.class) public final class ColumnIgnore implements Serializable { private static final long serialVersionUID = -4305681863714969261L; - @XmlElement private final ColumnPosition position; - @SuppressWarnings("unused") - private ColumnIgnore() { - position = null; - } - /** - * @param position + * Creates new hint to ignore column at given position. + * + * @param position position of the ignored column */ public ColumnIgnore(ColumnPosition position) { Preconditions.checkNotNull(position); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnRelation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnRelation.java index d5286f70..0b52c739 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnRelation.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnRelation.java @@ -2,34 +2,30 @@ import java.io.Serializable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + import com.google.common.base.Preconditions; +import cz.cuni.mff.xrg.odalic.api.rest.adapters.ColumnRelationAdapter; import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; -@XmlRootElement(name = "columnRelation") +@Immutable +@XmlJavaTypeAdapter(ColumnRelationAdapter.class) public final class ColumnRelation implements Serializable { private static final long serialVersionUID = -9087389821835847372L; - @XmlElement private final ColumnRelationPosition position; - @XmlElement private final ColumnRelationAnnotation annotation; - @SuppressWarnings("unused") - private ColumnRelation() { - position = null; - annotation = null; - } - /** - * @param subjectColumnPosition - * @param objectColumnPosition - * @param entity + * Creates column relation hint. + * + * @param position position of columns + * @param annotation relation annotation hint */ public ColumnRelation(ColumnRelationPosition position, ColumnRelationAnnotation annotation) { Preconditions.checkNotNull(position); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Disambiguation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Disambiguation.java index fc4da1fd..afcb284b 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Disambiguation.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Disambiguation.java @@ -2,33 +2,30 @@ import java.io.Serializable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + import com.google.common.base.Preconditions; +import cz.cuni.mff.xrg.odalic.api.rest.adapters.DisambiguationAdapter; import cz.cuni.mff.xrg.odalic.positions.CellPosition; import cz.cuni.mff.xrg.odalic.tasks.annotations.CellAnnotation; -@XmlRootElement(name = "disambiguation") +@Immutable +@XmlJavaTypeAdapter(DisambiguationAdapter.class) public final class Disambiguation implements Serializable { private static final long serialVersionUID = -5229197850609921790L; - @XmlElement private final CellPosition position; - @XmlElement private final CellAnnotation annotation; - @SuppressWarnings("unused") - private Disambiguation() { - position = null; - annotation = null; - } - /** - * @param position - * @param annotation + * Creates new cell disambiguation hint. + * + * @param position cell position + * @param annotation hinted cell annotation */ public Disambiguation(CellPosition position, CellAnnotation annotation) { Preconditions.checkNotNull(position); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java index 5f584e4b..ae9124aa 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java @@ -4,6 +4,7 @@ import java.util.Set; import javax.annotation.Nullable; +import javax.annotation.concurrent.Immutable; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import com.google.common.base.Preconditions; @@ -12,6 +13,14 @@ import cz.cuni.mff.xrg.odalic.api.rest.adapters.FeedbackAdapter; import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +/** + * User feedback for the result of annotating algorithm. Expresses also input constraints for the + * next run. + * + * @author Václav Brodec + * + */ +@Immutable @XmlJavaTypeAdapter(FeedbackAdapter.class) public final class Feedback implements Serializable { @@ -20,20 +29,23 @@ public final class Feedback implements Serializable { private final ColumnPosition subjectColumnPosition; private final Set columnIgnores; - + private final Set classifications; - + private final Set columnAmbiguities; - + private final Set ambiguities; - + private final Set disambiguations; - + private final Set cellRelations; - + private final Set columnRelations; - + + /** + * Creates empty feedback. + */ public Feedback() { this.subjectColumnPosition = null; this.columnIgnores = ImmutableSet.of(); @@ -44,35 +56,21 @@ public Feedback() { this.disambiguations = ImmutableSet.of(); this.ambiguities = ImmutableSet.of(); } - + /** - * @param columnIgnores - * @param columnAmbiguities - * @param classifications - * @param cellRelations - * @param columnRelations - * @param disambiguations - * @param ambiguities + * Creates feedback. + * + * @param subjectColumnPosition position of the subject column (optional) + * @param columnIgnores ignored columns + * @param columnAmbiguities columns whose cells will not be disambiguated + * @param classifications classification hints for columns + * @param cellRelations hints with relations between cells on the same rows + * @param columnRelations hints with relation between columns + * @param disambiguations custom disambiguations + * @param ambiguities hints for cells to be left ambiguous */ - public Feedback(Set columnIgnores, - Set columnAmbiguities, Set classifications, - Set cellRelations, Set columnRelations, - Set disambiguations, Set ambiguities) { - checkMandatory(columnIgnores, columnAmbiguities, classifications, cellRelations, - columnRelations, disambiguations, ambiguities); - - this.subjectColumnPosition = null; - this.columnIgnores = ImmutableSet.copyOf(columnIgnores); - this.columnAmbiguities = ImmutableSet.copyOf(columnAmbiguities); - this.classifications = ImmutableSet.copyOf(classifications); - this.cellRelations = ImmutableSet.copyOf(cellRelations); - this.columnRelations = ImmutableSet.copyOf(columnRelations); - this.disambiguations = ImmutableSet.copyOf(disambiguations); - this.ambiguities = ImmutableSet.copyOf(ambiguities); - } - - private static void checkMandatory(Set columnIgnores, - Set columnAmbiguities, + public Feedback(@Nullable ColumnPosition subjectColumnPosition, + Set columnIgnores, Set columnAmbiguities, Set classifications, Set cellRelations, Set columnRelations, Set disambiguations, Set ambiguities) { @@ -83,24 +81,7 @@ private static void checkMandatory(Set columnIgnores, Preconditions.checkNotNull(columnRelations); Preconditions.checkNotNull(disambiguations); Preconditions.checkNotNull(ambiguities); - } - - /** - * @param subjectColumnIndex - * @param columnIgnores - * @param columnAmbiguities - * @param classifications - * @param cellRelations - * @param columnRelations - * @param disambiguations - * @param ambiguities - */ - public Feedback(@Nullable ColumnPosition subjectColumnPosition, Set columnIgnores, - Set columnAmbiguities, Set classifications, - Set cellRelations, Set columnRelations, - Set disambiguations, Set ambiguities) { - checkMandatory(columnIgnores, columnAmbiguities, classifications, cellRelations, columnRelations, disambiguations, ambiguities); - + this.subjectColumnPosition = subjectColumnPosition; this.columnIgnores = ImmutableSet.copyOf(columnIgnores); this.columnAmbiguities = ImmutableSet.copyOf(columnAmbiguities); @@ -112,7 +93,7 @@ public Feedback(@Nullable ColumnPosition subjectColumnPosition, Set getColumnIgnores() { return columnIgnores; } /** - * @return the columnAmbiguities + * @return ambiguous columns */ public Set getColumnAmbiguities() { return columnAmbiguities; @@ -141,14 +122,14 @@ public Set getClassifications() { } /** - * @return the cellRelations + * @return the cell relations */ public Set getCellRelations() { return cellRelations; } /** - * @return the columnRelations + * @return the column relations */ public Set getColumnRelations() { return columnRelations; @@ -162,13 +143,15 @@ public Set getDisambiguations() { } /** - * @return the ambiguities + * @return the forced ambiguous cells */ public Set getAmbiguities() { return ambiguities; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#hashCode() */ @Override @@ -187,7 +170,9 @@ public int hashCode() { return result; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#equals(java.lang.Object) */ @Override @@ -261,7 +246,9 @@ public boolean equals(Object obj) { return true; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/Input.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/Input.java index d3608a44..7fac64dc 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/Input.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/Input.java @@ -6,6 +6,12 @@ import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; import cz.cuni.mff.xrg.odalic.positions.RowPosition; +/** + * Input interface. + * + * @author Václav Brodec + * + */ public interface Input { String at(CellPosition position); String headerAt(ColumnPosition position); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputParser.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputParser.java index e34895d0..5e10374f 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputParser.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputParser.java @@ -1,5 +1,11 @@ package cz.cuni.mff.xrg.odalic.feedbacks.input; +/** + * Input parser. + * + * @author Václav Brodec + * + */ public interface InputParser { Input parse(String content); } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/SimpleInput.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/SimpleInput.java index d09fdc57..a308c973 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/SimpleInput.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/SimpleInput.java @@ -62,7 +62,7 @@ public String[][] getContent() { @Override public String at(CellPosition position) { - return content[position.getRowPosition().getIndex()][position.getColumnPosition().getIndex()]; + return content[position.getRowIndex()][position.getColumnIndex()]; } @Override diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/File.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/File.java index 23208b7b..ab98dfe1 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/File.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/File.java @@ -1,58 +1,44 @@ package cz.cuni.mff.xrg.odalic.files; import java.io.Serializable; -import java.net.MalformedURLException; import java.net.URL; import java.util.Date; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import com.google.common.base.Preconditions; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateSerializer; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateDeserializer; +import cz.cuni.mff.xrg.odalic.api.rest.adapters.FileAdapter; -@XmlRootElement(name = "file") +/** + * File description. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(FileAdapter.class) public class File implements Serializable { private static final long serialVersionUID = -6359038623760039155L; - @XmlElement - private String id; + private final String id; - @JsonSerialize(using = CustomJsonDateSerializer.class) - @JsonDeserialize(using = CustomJsonDateDeserializer.class) - @XmlElement - private Date uploaded; + private final Date uploaded; - @XmlElement - private String owner; - - @XmlElement - private URL location; - - @SuppressWarnings("unused") - private File() { - id = null; - uploaded = null; - owner = null; - } - - public File(String id, String owner, URL location) throws MalformedURLException { - Preconditions.checkNotNull(id); - Preconditions.checkNotNull(owner); - Preconditions.checkNotNull(location); - - this.id = id; - this.uploaded = new Date(); - this.owner = owner; - this.location = location; - } + private final String owner; + private final URL location; + + /** + * Create new file description. + * + * @param id file ID + * @param uploaded time of upload + * @param owner file owner description + * @param location file location + */ public File(String id, Date uploaded, String owner, URL location) { Preconditions.checkNotNull(id); Preconditions.checkNotNull(uploaded); @@ -64,19 +50,23 @@ public File(String id, Date uploaded, String owner, URL location) { this.owner = owner; this.location = location; } - + /** - * @return the id + * Create new file description for a file uploaded now. + * + * @param id file ID + * @param owner file owner description + * @param location file location */ - public String getId() { - return id; + public File(String id, String owner, URL location) { + this(id, new Date(), owner, location); } /** - * @param id the id to set + * @return the id */ - public void setId(String id) { - this.id = id; + public String getId() { + return id; } /** @@ -86,13 +76,6 @@ public Date getUploaded() { return uploaded; } - /** - * @param uploaded the uploaded to set - */ - public void setUploaded(Date uploaded) { - this.uploaded = uploaded; - } - /** * @return the owner */ @@ -100,13 +83,6 @@ public String getOwner() { return owner; } - /** - * @param owner the owner to set - */ - public void setOwner(String owner) { - this.owner = owner; - } - /** * @return the location */ @@ -115,13 +91,8 @@ public URL getLocation() { } /** - * @param location the location to set - */ - public void setLocation(URL location) { - this.location = location; - } - - /* (non-Javadoc) + * Computes the hash code based on all components. + * * @see java.lang.Object#hashCode() */ @Override @@ -135,7 +106,9 @@ public int hashCode() { return result; } - /* (non-Javadoc) + /** + * Compares for equivalence (only other File description with the same components passes). + * * @see java.lang.Object#equals(java.lang.Object) */ @Override diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileService.java index bb94d9d9..f8e6294b 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileService.java @@ -4,10 +4,28 @@ import java.io.InputStream; import java.util.List; +/** + * Provides basic set of operations for uploaded or remote files. + * + * @author Václav Brodec + * + */ public interface FileService { + /** + * Registers a new remote file. + * + * @param file file description + */ void create(File file); + /** + * Registers a new file and reads its content from the stream. + * + * @param file file description + * @param fileInputStream file content + * @throws IOException if an I/O error occurs + */ void create(File file, InputStream fileInputStream) throws IOException; void deleteById(String id); @@ -16,13 +34,32 @@ public interface FileService { List getFiles(); + /** + * Replaces file description. + * + * @param file file description + */ void replace(File file); + /** + * Replaces the file description and the file content. + * + * @param file file description + * @param fileInputStream file content + * @throws IOException if an I/O error occurs + */ void replace(File file, InputStream fileInputStream) throws IOException; boolean existsFileWithId(String id); boolean hasId(File file, String id); + /** + * Reads content of the file. + * + * @param id file ID + * @return textual content of the file + * @throws IOException if an I/O error occurs + */ String getDataById(String id) throws IOException; } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/MemoryOnlyFileService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/MemoryOnlyFileService.java index eee55fe5..56645eab 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/MemoryOnlyFileService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/MemoryOnlyFileService.java @@ -12,24 +12,40 @@ import java.util.Map; import org.apache.commons.io.IOUtils; - import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; /** + * This {@link FileService} implementation provides no persistence. + * * @author Václav Brodec * */ public final class MemoryOnlyFileService implements FileService { - private final Map files = new HashMap<>(); + private final Map files; - private final Map data = new HashMap<>(); + private final Map data; - + private MemoryOnlyFileService(Map files, Map data) { + Preconditions.checkNotNull(files); + Preconditions.checkNotNull(data); + + this.files = files; + this.data = data; + } + + /** + * Creates the file service with no registered files and data. + */ + public MemoryOnlyFileService() { + this(new HashMap<>(), new HashMap<>()); + } + /* (non-Javadoc) * @see cz.cuni.mff.xrg.odalic.files.FileService#create(cz.cuni.mff.xrg.odalic.files.File) */ + @Override public void create(File file) { if (existsFileWithId(file.getId())) { throw new IllegalArgumentException(); @@ -38,6 +54,9 @@ public void create(File file) { replace(file); } + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.files.FileService#create(cz.cuni.mff.xrg.odalic.files.File, java.io.InputStream) + */ @Override public void create(File file, InputStream fileInputStream) throws IOException { if (existsFileWithId(file.getId())) { @@ -50,6 +69,7 @@ public void create(File file, InputStream fileInputStream) throws IOException { /* (non-Javadoc) * @see cz.cuni.mff.xrg.odalic.files.FileService#deleteById(java.lang.String) */ + @Override public void deleteById(String id) { Preconditions.checkNotNull(id); @@ -64,6 +84,7 @@ public void deleteById(String id) { /* (non-Javadoc) * @see cz.cuni.mff.xrg.odalic.files.FileService#getById(java.lang.String) */ + @Override public File getById(String id) { Preconditions.checkNotNull(id); @@ -78,6 +99,7 @@ public File getById(String id) { /* (non-Javadoc) * @see cz.cuni.mff.xrg.odalic.files.FileService#getFiles() */ + @Override public List getFiles() { return ImmutableList.copyOf(this.files.values()); } @@ -85,11 +107,15 @@ public List getFiles() { /* (non-Javadoc) * @see cz.cuni.mff.xrg.odalic.files.FileService#replace(cz.cuni.mff.xrg.odalic.files.File) */ + @Override public void replace(File file) { this.files.put(file.getId(), file); } + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.files.FileService#replace(cz.cuni.mff.xrg.odalic.files.File, java.io.InputStream) + */ @Override public void replace(File file, InputStream fileInputStream) throws IOException { this.files.put(file.getId(), file); @@ -99,6 +125,7 @@ public void replace(File file, InputStream fileInputStream) throws IOException { /* (non-Javadoc) * @see cz.cuni.mff.xrg.odalic.files.FileService#existsFileWithId(java.lang.String) */ + @Override public boolean existsFileWithId(String id) { Preconditions.checkNotNull(id); @@ -108,6 +135,7 @@ public boolean existsFileWithId(String id) { /* (non-Javadoc) * @see cz.cuni.mff.xrg.odalic.files.FileService#hasId(cz.cuni.mff.xrg.odalic.files.File, java.lang.String) */ + @Override public boolean hasId(File file, String id) { Preconditions.checkNotNull(id); @@ -118,6 +146,9 @@ public boolean hasId(File file, String id) { return file.getId().equals(id); } + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.files.FileService#getDataById(java.lang.String) + */ @Override public String getDataById(String id) throws IOException { File file = getById(id); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/CellPosition.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/CellPosition.java index c29ff295..415d06fd 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/CellPosition.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/CellPosition.java @@ -2,32 +2,35 @@ import java.io.Serializable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import com.google.common.base.Preconditions; -@XmlRootElement(name = "cellPosition") +import cz.cuni.mff.xrg.odalic.api.rest.adapters.CellPositionAdapter; + +/** + * Position of a common cell in a table. Headers do not count. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(CellPositionAdapter.class) public final class CellPosition implements Serializable { private static final long serialVersionUID = 7955615617737637528L; - @XmlElement private final RowPosition rowPosition; - @XmlElement private final ColumnPosition columnPosition; - @SuppressWarnings("unused") - private CellPosition() { - rowPosition = null; - columnPosition = null; - } - /** - * @param rowPosition - * @param columnPosition + * Creates new representation of cell position in a table. + * + * @param rowPosition row position + * @param columnPosition column position */ public CellPosition(RowPosition rowPosition, ColumnPosition columnPosition) { Preconditions.checkNotNull(rowPosition); @@ -38,19 +41,43 @@ public CellPosition(RowPosition rowPosition, ColumnPosition columnPosition) { } /** - * @return the rowPosition + * Creates new representation of cell position in a table. + * + * @param rowIndex row index + * @param columnIndex column index + */ + public CellPosition(int rowIndex, int columnIndex) { + this(new RowPosition(rowIndex), new ColumnPosition(columnIndex)); + } + + /** + * @return the row position */ public RowPosition getRowPosition() { return rowPosition; } /** - * @return the columnPosition + * @return the column position */ public ColumnPosition getColumnPosition() { return columnPosition; } + /** + * @return the row index + */ + public int getRowIndex() { + return rowPosition.getIndex(); + } + + /** + * @return the column index + */ + public int getColumnIndex() { + return columnPosition.getIndex(); + } + /* (non-Javadoc) * @see java.lang.Object#hashCode() */ diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/CellRelationPosition.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/CellRelationPosition.java index c5dbc5d3..caf5159d 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/CellRelationPosition.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/CellRelationPosition.java @@ -1,48 +1,116 @@ package cz.cuni.mff.xrg.odalic.positions; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import com.google.common.base.Preconditions; -@XmlRootElement(name = "cellRelationPosition") +import cz.cuni.mff.xrg.odalic.api.rest.adapters.CellRelationPositionAdapter; + +/** + * Position of cells at the same row in a relation. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(CellRelationPositionAdapter.class) public final class CellRelationPosition { - @XmlElement private final ColumnRelationPosition columnsPosition; - - @XmlElement + private final RowPosition rowPosition; - - @SuppressWarnings("unused") - private CellRelationPosition() { - columnsPosition = null; - rowPosition = null; - } - + + /** + * Creates new representation of position of two cells at the same row in a relation. + * + * @param columnsPosition position of columns in which the cells are located + * @param rowPosition position of row that the cells share + */ public CellRelationPosition(ColumnRelationPosition columnsPosition, RowPosition rowPosition) { Preconditions.checkNotNull(columnsPosition); Preconditions.checkNotNull(rowPosition); - + this.columnsPosition = columnsPosition; this.rowPosition = rowPosition; } /** - * @return the rowPosition + * Creates new representation of position of two cells at the same row in a relation. + * + * @param first column position of the first cell + * @param second column position of the second cell + * @param rowPosition position of row that the cells share + */ + public CellRelationPosition(ColumnPosition first, ColumnPosition second, + RowPosition rowPosition) { + this(new ColumnRelationPosition(first, second), rowPosition); + } + + /** + * Creates new representation of position of two cells at the same row in a relation. + * + * @param firstColumnIndex column index of the first cell + * @param secondColumnIndex column index of the second cell + * @param rowIndex index of the row that the cells share + */ + public CellRelationPosition(int firstColumnIndex, int secondColumnIndex, int rowIndex) { + this(new ColumnRelationPosition(firstColumnIndex, secondColumnIndex), + new RowPosition(rowIndex)); + } + + /** + * @return the row position */ public RowPosition getRowPosition() { return rowPosition; } - + /** - * @return the columnsPosition + * @return the columns position */ public ColumnRelationPosition getColumnsPosition() { return columnsPosition; } - - /* (non-Javadoc) + + /** + * @return the row index + */ + public int getRowIndex() { + return rowPosition.getIndex(); + } + + /** + * @return the first cell column position + */ + public ColumnPosition getFirstColumnPosition() { + return columnsPosition.getFirst(); + } + + /** + * @return the second cell column position + */ + public ColumnPosition getSecondColumnPosition() { + return columnsPosition.getSecond(); + } + + /** + * @return the first cell column index + */ + public int getFirstColumnIndex() { + return columnsPosition.getFirstIndex(); + } + + /** + * @return the second cell column index + */ + public int getSecondColumnIndex() { + return columnsPosition.getSecondIndex(); + } + + /** + * Computes hash code based on the column position and the row position. + * * @see java.lang.Object#hashCode() */ @Override @@ -54,7 +122,10 @@ public int hashCode() { return result; } - /* (non-Javadoc) + /** + * Compares for equality (only other cell relation position with the same column position and row + * position passes). + * * @see java.lang.Object#equals(java.lang.Object) */ @Override @@ -86,7 +157,9 @@ public boolean equals(Object obj) { return true; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/ColumnPosition.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/ColumnPosition.java index 1dbde5a3..8c8e1fd6 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/ColumnPosition.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/ColumnPosition.java @@ -2,26 +2,31 @@ import java.io.Serializable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import com.google.common.base.Preconditions; -@XmlRootElement(name = "columnPosition") +import cz.cuni.mff.xrg.odalic.api.rest.adapters.ColumnPositionAdapter; + +/** + * Position of column in a table. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(ColumnPositionAdapter.class) public final class ColumnPosition implements Serializable { private static final long serialVersionUID = -1179554576389130985L; - @XmlElement private final int index; - @SuppressWarnings("unused") - private ColumnPosition() { - index = Integer.MIN_VALUE; - } - /** - * @param index + * Creates new column position representation. + * + * @param index zero-based index */ public ColumnPosition(int index) { Preconditions.checkArgument(index >= 0); @@ -37,8 +42,8 @@ public int getIndex() { return index; } - /* - * (non-Javadoc) + /** + * Computes hash code based on the index. * * @see java.lang.Object#hashCode() */ @@ -50,8 +55,8 @@ public int hashCode() { return result; } - /* - * (non-Javadoc) + /** + * Compares for equality (only other column position with the same index passes). * * @see java.lang.Object#equals(java.lang.Object) */ diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/ColumnRelationPosition.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/ColumnRelationPosition.java index b91ebbaa..2a3ee301 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/ColumnRelationPosition.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/ColumnRelationPosition.java @@ -1,43 +1,82 @@ package cz.cuni.mff.xrg.odalic.positions; +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + import com.google.common.base.Preconditions; +import cz.cuni.mff.xrg.odalic.api.rest.adapters.ColumnRelationPositionAdapter; + +/** + * Position of columns in a relation. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(ColumnRelationPositionAdapter.class) public final class ColumnRelationPosition { private final ColumnPosition first; - + private final ColumnPosition second; - - @SuppressWarnings("unused") - private ColumnRelationPosition() { - first = null; - second = null; - } - + + /** + * Creates new representation of a position of columns in relation. + * + * @param first first column position + * @param second second column position + */ public ColumnRelationPosition(ColumnPosition first, ColumnPosition second) { Preconditions.checkNotNull(first); Preconditions.checkNotNull(second); Preconditions.checkArgument(first.getIndex() != second.getIndex()); - + this.first = first; this.second = second; } + + /** + * Creates new representation of a position of columns in relation. + * + * @param firstIndex first column index + * @param second second column index + */ + public ColumnRelationPosition(int firstIndex, int secondIndex) { + this(new ColumnPosition(firstIndex), new ColumnPosition(secondIndex)); + } /** - * @return the first + * @return the first column position */ public ColumnPosition getFirst() { return first; } /** - * @return the second + * @return the second column position */ public ColumnPosition getSecond() { return second; } + + /** + * @return the first column index + */ + public int getFirstIndex() { + return first.getIndex(); + } + + /** + * @return the second column index + */ + public int getSecondIndex() { + return second.getIndex(); + } - /* (non-Javadoc) + /** + * Computes hash code based on the first and second column position. + * * @see java.lang.Object#hashCode() */ @Override @@ -49,7 +88,10 @@ public int hashCode() { return result; } - /* (non-Javadoc) + /** + * Compares for equivalence (only other column relation position with the same first and second + * column position passes). + * * @see java.lang.Object#equals(java.lang.Object) */ @Override @@ -81,7 +123,9 @@ public boolean equals(Object obj) { return true; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/RowPosition.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/RowPosition.java index 8b0a4eb4..e8aae41a 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/RowPosition.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/RowPosition.java @@ -2,25 +2,31 @@ import java.io.Serializable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + import com.google.common.base.Preconditions; -@XmlRootElement(name = "rowPosition") -public final class RowPosition implements Serializable { +import cz.cuni.mff.xrg.odalic.api.rest.adapters.RowPositionAdapter; + +/** + * Position of a row in a table. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(RowPositionAdapter.class) +public final class RowPosition implements Serializable, Comparable { private static final long serialVersionUID = 3435359552551500579L; - @XmlElement private final int index; - @SuppressWarnings("unused") - private RowPosition() { - index = Integer.MIN_VALUE; - } - /** - * @param index + * Creates new row position representation. + * + * @param index zero-base index */ public RowPosition(int index) { Preconditions.checkArgument(index >= 0); @@ -35,7 +41,9 @@ public int getIndex() { return index; } - /* (non-Javadoc) + /** + * Computes hash code based on the index. + * * @see java.lang.Object#hashCode() */ @Override @@ -46,7 +54,9 @@ public int hashCode() { return result; } - /* (non-Javadoc) + /** + * Compares for equality (only other row position with the same index passes). + * * @see java.lang.Object#equals(java.lang.Object) */ @Override @@ -66,6 +76,14 @@ public boolean equals(Object obj) { } return true; } + + /* (non-Javadoc) + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ + @Override + public int compareTo(RowPosition other) { + return Integer.compare(index, other.index); + } /* (non-Javadoc) * @see java.lang.Object#toString() diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskServiceImpl.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/MemoryOnlyTaskService.java similarity index 62% rename from odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskServiceImpl.java rename to odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/MemoryOnlyTaskService.java index 5b9109e8..3248b566 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskServiceImpl.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/MemoryOnlyTaskService.java @@ -4,18 +4,34 @@ import java.util.Map; import java.util.Set; +import javax.annotation.Nullable; + import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableSet; /** + * This {@link TaskService} implementation provides no persistence. + * * @author Václav Brodec + * @author Josef Janoušek * */ -public final class TaskServiceImpl implements TaskService { +public final class MemoryOnlyTaskService implements TaskService { - private final Map tasks = new HashMap<>(); + private final Map tasks; + + private MemoryOnlyTaskService(Map tasks) { + Preconditions.checkNotNull(tasks); + + this.tasks = tasks; + } - public TaskServiceImpl() {} + /** + * Creates the task service with no registered tasks. + */ + public MemoryOnlyTaskService() { + this(new HashMap<>()); + } public Set getTasks() { return ImmutableSet.copyOf(this.tasks.values()); @@ -25,9 +41,7 @@ public Task getById(String id) { Preconditions.checkNotNull(id); Task task = this.tasks.get(id); - if (task == null) { - throw new IllegalArgumentException(); - } + Preconditions.checkArgument(task != null); return task; } @@ -46,11 +60,10 @@ public void deleteById(String id) { Preconditions.checkNotNull(id); Task task = this.tasks.remove(id); - if (task == null) { - throw new IllegalArgumentException(); - } + Preconditions.checkArgument(task != null); } + @Nullable public Task verifyTaskExistenceById(String id) { Preconditions.checkNotNull(id); @@ -63,9 +76,7 @@ public Task verifyTaskExistenceById(String id) { } public void create(Task task) { - if (verifyTaskExistenceById(task.getId()) != null) { - throw new IllegalArgumentException(); - } + Preconditions.checkArgument(verifyTaskExistenceById(task.getId()) == null); replace(task); } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/Task.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/Task.java index 6772fd1e..e817b509 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/Task.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/Task.java @@ -3,68 +3,58 @@ import java.io.Serializable; import java.util.Date; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import com.google.common.base.Preconditions; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateDeserializer; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateSerializer; +import cz.cuni.mff.xrg.odalic.api.rest.adapters.TaskAdapter; import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; -import cz.cuni.mff.xrg.odalic.tasks.executions.Execution; -@XmlRootElement(name = "task") +/** + * Task represents the single unit of work done by the Odalic core. Its configuration is + * replaceable. + * + * @author Václav Brodec + * + */ +@XmlJavaTypeAdapter(TaskAdapter.class) public final class Task implements Serializable { private static final long serialVersionUID = 1610346823333685091L; - @XmlElement private final String id; - - @JsonSerialize(using = CustomJsonDateSerializer.class) - @JsonDeserialize(using = CustomJsonDateDeserializer.class) - @XmlElement + private final Date created; - @XmlElement private Configuration configuration; - @SuppressWarnings("unused") - private Task() { - id = null; - created = null; - configuration = null; - } - /** - * @param id - * @param created - * @param configuration * + * Creates the task instance. + * + * @param id ID of the task + * @param created provided time of creation + * @param configuration configuration of the task */ public Task(String id, Date created, Configuration configuration) { - Preconditions.checkNotNull(id); - Preconditions.checkNotNull(created); - Preconditions.checkNotNull(configuration); - - this.id = id; - this.created = created; - this.configuration = configuration; - } - - public Task(String id, Date created, Configuration configuration, Execution execution) { Preconditions.checkNotNull(id); Preconditions.checkNotNull(created); Preconditions.checkNotNull(configuration); - Preconditions.checkNotNull(execution); - + this.id = id; this.created = created; this.configuration = configuration; } + /** + * Creates the task instance and sets it creation date to now. + * + * @param id ID of the task + * @param configuration configuration of the task + */ + public Task(String id, Configuration configuration) { + this(id, new Date(), configuration); + } + /** * @return the configuration */ @@ -76,6 +66,8 @@ public Configuration getConfiguration() { * @param configuration the configuration to set */ public void setConfiguration(Configuration configuration) { + Preconditions.checkNotNull(configuration); + this.configuration = configuration; } @@ -93,7 +85,9 @@ public Date getCreated() { return created; } - /* (non-Javadoc) + /** + * Computes hash code value for this object based solely on its ID. + * * @see java.lang.Object#hashCode() */ @Override @@ -104,7 +98,10 @@ public int hashCode() { return result; } - /* (non-Javadoc) + /** + * Compares for equality (comparable to other {@link Task} instances only, based solely on their + * IDs). + * * @see java.lang.Object#equals(java.lang.Object) */ @Override @@ -129,12 +126,13 @@ public boolean equals(Object obj) { return true; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override public String toString() { - return "Task [id=" + id + ", created=" + created + ", configuration=" + configuration - + "]"; + return "Task [id=" + id + ", created=" + created + ", configuration=" + configuration + "]"; } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskDigest.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskDigest.java deleted file mode 100644 index 445ed709..00000000 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskDigest.java +++ /dev/null @@ -1,82 +0,0 @@ -package cz.cuni.mff.xrg.odalic.tasks; - -import java.io.Serializable; -import java.net.URL; -import java.util.Date; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateDeserializer; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateSerializer; -import cz.cuni.mff.xrg.odalic.tasks.executions.State; -import cz.cuni.mff.xrg.odalic.tasks.results.Result; - - -@XmlRootElement -public class TaskDigest implements Serializable { - - private static final long serialVersionUID = 1610346823333685091L; - - @XmlElement(name = "id") - private String id; - - @JsonSerialize(using = CustomJsonDateSerializer.class) - @JsonDeserialize(using = CustomJsonDateDeserializer.class) - @XmlElement(name = "created") - private Date created; - - @XmlElement(name = "input") - private URL input; - - @XmlElement(name = "state") - private State state; - - @XmlElement(name = "result") - private Result result; - - public TaskDigest() {} - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public Date getCreated() { - return created; - } - - public void setCreated(Date created) { - this.created = created; - } - - public URL getInput() { - return input; - } - - public void setInput(URL input) { - this.input = input; - } - - public State getState() { - return state; - } - - public void setState(State state) { - this.state = state; - } - - public Result getResult() { - return result; - } - - public void setResult(Result result) { - this.result = result; - } -} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskService.java index 37933ba1..bb63239c 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskService.java @@ -2,6 +2,12 @@ import java.util.Set; +/** + * Task service handles the CRUD operations for {@link Task} instances. + * + * @author Václav Brodec + * + */ public interface TaskService { Set getTasks(); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellAnnotation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellAnnotation.java index a7ad86c1..1784ad96 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellAnnotation.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellAnnotation.java @@ -3,46 +3,38 @@ import java.util.Map; import java.util.NavigableSet; import java.util.Set; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import org.apache.jena.ext.com.google.common.collect.ImmutableSet; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; import cz.cuni.mff.xrg.odalic.api.rest.adapters.CellAnnotationAdapter; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonDeserializer; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonSerializer; +/** + * Annotates cell in a table. + * + * @author Václav Brodec + * + */ +@Immutable @XmlJavaTypeAdapter(CellAnnotationAdapter.class) -@XmlRootElement(name = "cellAnnotation") public final class CellAnnotation { - @XmlElement - @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) - @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) private final Map> candidates; - @XmlElement - @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) - @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) private final Map> chosen; - @SuppressWarnings("unused") - private CellAnnotation() { - candidates = ImmutableMap.of(); - chosen = ImmutableMap.of(); - } - /** - * @param candidates - * @param chosen + * Creates new annotation. + * + * @param candidates all possible candidates for the assigned entity sorted by with their + * likelihood + * @param chosen subset of candidates chosen to annotate the element */ public CellAnnotation(Map> candidates, Map> chosen) { @@ -82,7 +74,26 @@ public Map> getChosen() { return chosen; } - /* (non-Javadoc) + /** + * Merges with the other annotation. + * + * @param other annotation based on different set of knowledge bases + * @return merged annotation + * @throws IllegalArgumentException If both this and the other annotation have some candidates from the same knowledge base + */ + public CellAnnotation merge(CellAnnotation other) throws IllegalArgumentException { + final ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); + candidatesBuilder.putAll(other.candidates); + + final ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); + chosenBuilder.putAll(other.chosen); + + return new CellAnnotation(candidatesBuilder.build(), chosenBuilder.build()); + } + + /** + * Computes hash code based on the candidates and the chosen. + * * @see java.lang.Object#hashCode() */ @Override @@ -126,8 +137,11 @@ public boolean equals(Object obj) { return true; } - /* (non-Javadoc) - * @see java.lang.Object#toString() + /** + * Compares for equality (only other annotation of the same kind with equally ordered set of + * candidates and the same chosen set passes). + * + * @see java.lang.Object#equals(java.lang.Object) */ @Override public String toString() { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellRelationAnnotation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellRelationAnnotation.java index 141601ec..ef6171fb 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellRelationAnnotation.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellRelationAnnotation.java @@ -4,58 +4,49 @@ import java.util.NavigableSet; import java.util.Set; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; +import javax.annotation.concurrent.Immutable; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import org.apache.jena.ext.com.google.common.collect.ImmutableSet; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; import cz.cuni.mff.xrg.odalic.api.rest.adapters.CellRelationAnnotationAdapter; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonDeserializer; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonSerializer; +/** + * Annotates relation between two cells on the same row in a table. + * + * @author Václav Brodec + * + */ +@Immutable @XmlJavaTypeAdapter(CellRelationAnnotationAdapter.class) -@XmlRootElement(name = "cellRelationAnnotation") public final class CellRelationAnnotation { - @XmlElement - @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) - @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) private final Map> candidates; - @XmlElement - @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) - @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) private final Map> chosen; - @SuppressWarnings("unused") - private CellRelationAnnotation() { - candidates = ImmutableMap.of(); - chosen = ImmutableMap.of(); - } - /** - * @param candidates - * @param chosen + * Creates new annotation. + * + * @param candidates all possible candidates for the assigned entity sorted by with their + * likelihood + * @param chosen subset of candidates chosen to annotate the element */ public CellRelationAnnotation(Map> candidates, Map> chosen) { Preconditions.checkNotNull(candidates); Preconditions.checkNotNull(chosen); - ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); + final ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); for (final Map.Entry> candidateEntry : candidates.entrySet()) { candidatesBuilder.put(candidateEntry.getKey(), ImmutableSortedSet.copyOf(candidateEntry.getValue())); } this.candidates = candidatesBuilder.build(); - ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); + final ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); for (final Map.Entry> chosenEntry : chosen.entrySet()) { final KnowledgeBase chosenBase = chosenEntry.getKey(); @@ -81,8 +72,27 @@ public Map> getCandidates() { public Map> getChosen() { return chosen; } + + /** + * Merges with the other annotation. + * + * @param other annotation based on different set of knowledge bases + * @return merged annotation + * @throws IllegalArgumentException If both this and the other annotation have some candidates from the same knowledge base + */ + public CellRelationAnnotation merge(CellRelationAnnotation other) throws IllegalArgumentException { + final ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); + candidatesBuilder.putAll(other.candidates); + + final ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); + chosenBuilder.putAll(other.chosen); + + return new CellRelationAnnotation(candidatesBuilder.build(), chosenBuilder.build()); + } - /* (non-Javadoc) + /** + * Computes hash code based on the candidates and the chosen. + * * @see java.lang.Object#hashCode() */ @Override @@ -94,7 +104,10 @@ public int hashCode() { return result; } - /* (non-Javadoc) + /** + * Compares for equality (only other annotation of the same kind with equally ordered set of + * candidates and the same chosen set passes). + * * @see java.lang.Object#equals(java.lang.Object) */ @Override diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/ColumnRelationAnnotation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/ColumnRelationAnnotation.java index 3c6e2c75..cfd1703f 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/ColumnRelationAnnotation.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/ColumnRelationAnnotation.java @@ -3,58 +3,50 @@ import java.util.Map; import java.util.NavigableSet; import java.util.Set; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import org.apache.jena.ext.com.google.common.collect.ImmutableSet; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; import cz.cuni.mff.xrg.odalic.api.rest.adapters.ColumnRelationAnnotationAdapter; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonDeserializer; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonSerializer; +/** + * Annotates relation between two columns in a table. + * + * @author Václav Brodec + * + */ +@Immutable @XmlJavaTypeAdapter(ColumnRelationAnnotationAdapter.class) -@XmlRootElement(name = "columnRelationAnnotation") public final class ColumnRelationAnnotation { - @XmlElement - @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) - @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) private final Map> candidates; - @XmlElement - @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) - @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) private final Map> chosen; - @SuppressWarnings("unused") - private ColumnRelationAnnotation() { - candidates = ImmutableMap.of(); - chosen = ImmutableMap.of(); - } - /** - * @param candidates - * @param chosen + * Creates new annotation. + * + * @param candidates all possible candidates for the assigned entity sorted by with their + * likelihood + * @param chosen subset of candidates chosen to annotate the element */ public ColumnRelationAnnotation(Map> candidates, Map> chosen) { Preconditions.checkNotNull(candidates); Preconditions.checkNotNull(chosen); - ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); + final ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); for (final Map.Entry> candidateEntry : candidates.entrySet()) { candidatesBuilder.put(candidateEntry.getKey(), ImmutableSortedSet.copyOf(candidateEntry.getValue())); } this.candidates = candidatesBuilder.build(); - ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); + final ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); for (final Map.Entry> chosenEntry : chosen.entrySet()) { final KnowledgeBase chosenBase = chosenEntry.getKey(); @@ -73,15 +65,34 @@ public ColumnRelationAnnotation(Map> getCandidates() { return candidates; } - + /** * @return the chosen */ public Map> getChosen() { return chosen; } + + /** + * Merges with the other annotation. + * + * @param other annotation based on different set of knowledge bases + * @return merged annotation + * @throws IllegalArgumentException If both this and the other annotation have some candidates from the same knowledge base + */ + public ColumnRelationAnnotation merge(ColumnRelationAnnotation other) throws IllegalArgumentException { + final ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); + candidatesBuilder.putAll(other.candidates); + + final ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); + chosenBuilder.putAll(other.chosen); + + return new ColumnRelationAnnotation(candidatesBuilder.build(), chosenBuilder.build()); + } - /* (non-Javadoc) + /** + * Computes hash code based on the candidates and the chosen. + * * @see java.lang.Object#hashCode() */ @Override @@ -93,7 +104,10 @@ public int hashCode() { return result; } - /* (non-Javadoc) + /** + * Compares for equality (only other annotation of the same kind with equally ordered set of + * candidates and the same chosen set passes). + * * @see java.lang.Object#equals(java.lang.Object) */ @Override diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Entity.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Entity.java index 317d6f1f..81fc7c26 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Entity.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Entity.java @@ -1,47 +1,51 @@ package cz.cuni.mff.xrg.odalic.tasks.annotations; import java.io.Serializable; -import java.net.URI; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; import com.google.common.base.Preconditions; +import cz.cuni.mff.xrg.odalic.api.rest.adapters.EntityAdapter; + /** - * Groups the resource URI and its label in one handy class. + * Groups the resource ID and its label in one handy class. * * @author Václav Brodec */ -@XmlRootElement(name = "entity") +@XmlJavaTypeAdapter(EntityAdapter.class) public final class Entity implements Comparable, Serializable { private static final long serialVersionUID = -3001706805535088480L; - @XmlElement - private final String resourceID; + private final String resource; - @XmlElement private final String label; - @SuppressWarnings("unused") - private Entity() { - resourceID = null; - label = null; - } - - public Entity(String resourceID, String label) { - Preconditions.checkNotNull(resourceID); + /** + * Creates new entity representation. + * + * @param resource entity resource ID + * @param label label + */ + public Entity(String resource, String label) { + Preconditions.checkNotNull(resource); Preconditions.checkNotNull(label); - this.resourceID = resourceID; + this.resource = resource; this.label = label; } - public String getResourceID() { - return resourceID; + /** + * @return the resource ID + */ + public String getResource() { + return resource; } + /** + * @return the label + */ public String getLabel() { return label; } @@ -53,7 +57,7 @@ public String getLabel() { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((resourceID == null) ? 0 : resourceID.hashCode()); + result = prime * result + ((resource == null) ? 0 : resource.hashCode()); result = prime * result + ((label == null) ? 0 : label.hashCode()); return result; } @@ -73,11 +77,11 @@ public boolean equals(Object obj) { return false; } Entity other = (Entity) obj; - if (resourceID == null) { - if (other.resourceID != null) { + if (resource == null) { + if (other.resource != null) { return false; } - } else if (!resourceID.equals(other.resourceID)) { + } else if (!resource.equals(other.resource)) { return false; } if (label == null) { @@ -90,18 +94,22 @@ public boolean equals(Object obj) { return true; } + /** + * Compares the entities by their resource ID lexicographically. + * + * @see java.lang.Comparable#compareTo(java.lang.Object) + * @see java.lang.String#compareTo(String) for the definition of resource ID comparison + */ + @Override + public int compareTo(Entity o) { + return resource.compareTo(o.resource); + } + /* (non-Javadoc) * @see java.lang.Object#toString() */ @Override public String toString() { - return "Annotation [resourceID=" + resourceID + ", label=" + label + "]"; - } - - @Override - public int compareTo(Entity o) { - return resourceID.compareTo(o.resourceID); + return "Annotation [resource=" + resource + ", label=" + label + "]"; } - - } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/EntityCandidate.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/EntityCandidate.java index b3c87cad..86e96829 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/EntityCandidate.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/EntityCandidate.java @@ -2,34 +2,36 @@ import java.io.Serializable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + import com.google.common.base.Preconditions; -@XmlRootElement(name = "entityCandidate") +import cz.cuni.mff.xrg.odalic.api.rest.adapters.EntityCandidateAdapter; + +/** + * Encapsulates annotating entity and the likelihood that is assigned to it. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(EntityCandidateAdapter.class) public final class EntityCandidate implements Comparable, Serializable { - + private static final long serialVersionUID = 3072774254576336747L; - @XmlElement private final Entity entity; - - @XmlElement + private final Likelihood likelihood; - @SuppressWarnings("unused") - private EntityCandidate() { - entity = null; - likelihood = null; - } - /** * @param entity * @param likelihood */ public EntityCandidate(Entity entity, Likelihood likelihood) { Preconditions.checkNotNull(entity); - + this.entity = entity; this.likelihood = likelihood; } @@ -48,7 +50,9 @@ public Likelihood getLikelihood() { return likelihood; } - /* (non-Javadoc) + /** + * Computes hash code based on the entity and the likelihood. + * * @see java.lang.Object#hashCode() */ @Override @@ -60,7 +64,9 @@ public int hashCode() { return result; } - /* (non-Javadoc) + /** + * Compares for equality (only other candidates entity with the same likelihood passes). + * * @see java.lang.Object#equals(java.lang.Object) */ @Override @@ -91,15 +97,13 @@ public boolean equals(Object obj) { } return true; } - - /* (non-Javadoc) - * @see java.lang.Object#toString() + + /** + * Entity candidates are naturally ordered by their likelihood in ascending order. In case of the + * equal likelihood the natural ordering of entities is taken into account. + * + * @see java.lang.Comparable#compareTo(java.lang.Object) */ - @Override - public String toString() { - return "EntityCandidate [entity=" + entity + ", likelihood=" + likelihood + "]"; - } - @Override public int compareTo(EntityCandidate o) { final int likelihoodComparison = likelihood.compareTo(o.likelihood); @@ -110,4 +114,14 @@ public int compareTo(EntityCandidate o) { return likelihoodComparison; } } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "EntityCandidate [entity=" + entity + ", likelihood=" + likelihood + "]"; + } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/HeaderAnnotation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/HeaderAnnotation.java index a5c2e6f0..f339eddb 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/HeaderAnnotation.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/HeaderAnnotation.java @@ -3,65 +3,63 @@ import java.util.Map; import java.util.NavigableSet; import java.util.Set; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import org.apache.jena.ext.com.google.common.collect.ImmutableSet; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; import cz.cuni.mff.xrg.odalic.api.rest.adapters.HeaderAnnotationAdapter; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonDeserializer; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonSerializer; +/** + * Annotates table header and thus affects the whole column and all relations it takes part in. + * + * @author Václav Brodec + * + */ +@Immutable @XmlJavaTypeAdapter(HeaderAnnotationAdapter.class) -@XmlRootElement(name = "headerAnnotation") public final class HeaderAnnotation { - @XmlElement - @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) - @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) private final Map> candidates; - - @XmlElement - @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) - @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) + private final Map> chosen; - @SuppressWarnings("unused") - private HeaderAnnotation() { - candidates = ImmutableMap.of(); - chosen = ImmutableMap.of(); - } - /** - * @param candidates - * @param chosen + * Creates new annotation. + * + * @param candidates all possible candidates for the assigned entity sorted by with their + * likelihood + * @param chosen subset of candidates chosen to annotate the element */ - public HeaderAnnotation(Map> candidates, + public HeaderAnnotation( + Map> candidates, Map> chosen) { Preconditions.checkNotNull(candidates); Preconditions.checkNotNull(chosen); - - ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); - for (final Map.Entry> candidateEntry : candidates.entrySet()) { - candidatesBuilder.put(candidateEntry.getKey(), ImmutableSortedSet.copyOf(candidateEntry.getValue())); + + final ImmutableMap.Builder> candidatesBuilder = + ImmutableMap.builder(); + for (final Map.Entry> candidateEntry : candidates + .entrySet()) { + candidatesBuilder.put(candidateEntry.getKey(), + ImmutableSortedSet.copyOf(candidateEntry.getValue())); } this.candidates = candidatesBuilder.build(); - - ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); - for (final Map.Entry> chosenEntry : chosen.entrySet()) { + + final ImmutableMap.Builder> chosenBuilder = + ImmutableMap.builder(); + for (final Map.Entry> chosenEntry : chosen + .entrySet()) { final KnowledgeBase chosenBase = chosenEntry.getKey(); - + final Set baseCandidates = this.candidates.get(chosenBase); Preconditions.checkArgument(baseCandidates != null); Preconditions.checkArgument(baseCandidates.containsAll(chosenEntry.getValue())); - + chosenBuilder.put(chosenEntry.getKey(), ImmutableSet.copyOf(chosenEntry.getValue())); } this.chosen = chosenBuilder.build(); @@ -81,7 +79,29 @@ public Map> getChosen() { return chosen; } - /* (non-Javadoc) + /** + * Merges with the other annotation. + * + * @param other annotation based on different set of knowledge bases + * @return merged annotation + * @throws IllegalArgumentException If both this and the other annotation have some candidates + * from the same knowledge base + */ + public HeaderAnnotation merge(HeaderAnnotation other) throws IllegalArgumentException { + final ImmutableMap.Builder> candidatesBuilder = + ImmutableMap.builder(); + candidatesBuilder.putAll(other.candidates); + + final ImmutableMap.Builder> chosenBuilder = + ImmutableMap.builder(); + chosenBuilder.putAll(other.chosen); + + return new HeaderAnnotation(candidatesBuilder.build(), chosenBuilder.build()); + } + + /** + * Computes hash code based on the candidates and the chosen. + * * @see java.lang.Object#hashCode() */ @Override @@ -93,7 +113,10 @@ public int hashCode() { return result; } - /* (non-Javadoc) + /** + * Compares for equality (only other annotation of the same kind with equally ordered set of + * candidates and the same chosen set passes). + * * @see java.lang.Object#equals(java.lang.Object) */ @Override @@ -125,7 +148,9 @@ public boolean equals(Object obj) { return true; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/KnowledgeBase.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/KnowledgeBase.java index bf2eaf05..4271ba2d 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/KnowledgeBase.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/KnowledgeBase.java @@ -1,25 +1,27 @@ package cz.cuni.mff.xrg.odalic.tasks.annotations; -import javax.xml.bind.annotation.XmlRootElement; +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import com.google.common.base.Preconditions; -@XmlRootElement(name = "knowledgeBase") +import cz.cuni.mff.xrg.odalic.api.rest.adapters.KnowledgeBaseAdapter; + +/** + * Knowledge base identifier. May turn into full-fledged domain entity class in future version. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(KnowledgeBaseAdapter.class) public final class KnowledgeBase { - + private final String name; - @SuppressWarnings("unused") - private KnowledgeBase() { - name = null; - } - - /** - * @param name - */ public KnowledgeBase(String name) { Preconditions.checkNotNull(name); - + this.name = name; } @@ -30,7 +32,9 @@ public String getName() { return name; } - /* (non-Javadoc) + /** + * Computes hash code (for now) based on the name. + * * @see java.lang.Object#hashCode() */ @Override @@ -41,7 +45,9 @@ public int hashCode() { return result; } - /* (non-Javadoc) + /** + * Compares for equality (only other knowledge base instance with the same name passes, for now). + * * @see java.lang.Object#equals(java.lang.Object) */ @Override @@ -66,7 +72,9 @@ public boolean equals(Object obj) { return true; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Likelihood.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Likelihood.java index 0ae03138..6de1998a 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Likelihood.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Likelihood.java @@ -2,27 +2,27 @@ import java.io.Serializable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import com.google.common.base.Preconditions; -@XmlRootElement(name = "likelihood") +import cz.cuni.mff.xrg.odalic.api.rest.adapters.LikelihoodAdapter; + +/** + * Probability based score value for annotation. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(LikelihoodAdapter.class) public final class Likelihood implements Comparable, Serializable { private static final long serialVersionUID = -901650058091668104L; - @XmlElement private final double value; - @SuppressWarnings("unused") - private Likelihood() { - value = Double.NEGATIVE_INFINITY; - } - - /** - * @param value - */ public Likelihood(double value) { Preconditions.checkArgument(value >= 0); Preconditions.checkArgument(value <= 1); @@ -37,8 +37,8 @@ public double getValue() { return value; } - /* - * (non-Javadoc) + /** + * Computes hash code based on the value. * * @see java.lang.Object#hashCode() */ @@ -52,8 +52,8 @@ public int hashCode() { return result; } - /* - * (non-Javadoc) + /** + * Compares for equality (only other Likelihood with the same values passes). * * @see java.lang.Object#equals(java.lang.Object) */ @@ -75,6 +75,14 @@ public boolean equals(Object obj) { return true; } + /* (non-Javadoc) + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ + @Override + public int compareTo(Likelihood o) { + return Double.compare(value, o.value); + } + /* * (non-Javadoc) * @@ -85,8 +93,4 @@ public String toString() { return "Likelihood [value=" + value + "]"; } - @Override - public int compareTo(Likelihood o) { - return Double.compare(value, o.value); - } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java index eb75355b..928f4043 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java @@ -1,6 +1,8 @@ package cz.cuni.mff.xrg.odalic.tasks.configurations; import java.io.Serializable; + +import javax.annotation.concurrent.Immutable; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import com.google.common.base.Preconditions; @@ -9,6 +11,13 @@ import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; import cz.cuni.mff.xrg.odalic.files.File; +/** + * Task configuration. + * + * @author Václav Brodec + * + */ +@Immutable @XmlJavaTypeAdapter(ConfigurationAdapter.class) public final class Configuration implements Serializable { @@ -18,6 +27,11 @@ public final class Configuration implements Serializable { private final Feedback feedback; + /** + * Creates configuration without any feedback, thus implying fully automatic processing. + * + * @param input input specification + */ public Configuration(File input) { Preconditions.checkNotNull(input); @@ -25,6 +39,12 @@ public Configuration(File input) { this.feedback = new Feedback(); } + /** + * Creates configuration with provided feedback, which serves as hint for the processing algorithm. + * + * @param input input specification + * @param feedback constraints for the algorithm + */ public Configuration(File input, Feedback feedback) { Preconditions.checkNotNull(input); Preconditions.checkNotNull(feedback); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationService.java index 4a24fd09..8df983d8 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationService.java @@ -1,5 +1,11 @@ package cz.cuni.mff.xrg.odalic.tasks.configurations; +/** + * Configuration service handles the CRUD operations for {@link Configuration} instances. + * + * @author Václav Brodec + * + */ public interface ConfigurationService { Configuration getForTaskId(String taskId); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/MemoryOnlyConfigurationService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/MemoryOnlyConfigurationService.java index a4473244..93a4eb82 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/MemoryOnlyConfigurationService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/MemoryOnlyConfigurationService.java @@ -8,6 +8,8 @@ import cz.cuni.mff.xrg.odalic.tasks.TaskService; /** + * This {@link ConfigurationService} implementation provides no persistence. + * * @author Václav Brodec * */ diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/Execution.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/Execution.java deleted file mode 100644 index cc127504..00000000 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/Execution.java +++ /dev/null @@ -1,38 +0,0 @@ -package cz.cuni.mff.xrg.odalic.tasks.executions; - -import java.io.Serializable; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "execution") -public class Execution implements Serializable { - - private static final long serialVersionUID = -6359038623760039155L; - - @XmlElement - private final boolean draft; - - public Execution() { - draft = false; - } - - public Execution(boolean draft) { - this.draft = draft; - } - - /** - * @return the draft - */ - public boolean isDraft() { - return draft; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "Execution [draft=" + draft + "]"; - } -} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionService.java index 5b79946e..5f732358 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionService.java @@ -1,19 +1,62 @@ package cz.cuni.mff.xrg.odalic.tasks.executions; import java.util.concurrent.ExecutionException; - import cz.cuni.mff.xrg.odalic.tasks.results.Result; +/** + * Manages the task execution. + * + * @author Václav Brodec + * + */ public interface ExecutionService { - void submitForTaskId(String id); + /** + * Submits execution of the task. + * + * @param id task ID + * @throws IllegalStateException if the task has already been submitted for execution + */ + void submitForTaskId(String id) throws IllegalStateException; + /** + * Attempts to cancel execution of the task. + * + * @param id task ID + */ void cancelForTaskId(String id); + /** + * Indicates whether the task is done. + * + * @param id task ID + * @return true if done, false otherwise + * + */ boolean isDoneForTaskId(String id); - boolean isCancelledForTaskId(String id); + /** + * Indicates whether the task was voluntarily canceled. + * + * @param id task ID + * @return true if canceled, false otherwise + */ + boolean isCanceledForTaskId(String id); + /** + * Gets result of the task. Blocks until the result is available or the execution canceled. + * + * @param id task ID + * @return annotations for the task input + * @throws InterruptedException if the execution was interrupted while waiting + * @throws ExecutionException if the computation threw an exception + */ Result getResultForTaskId(String id) throws InterruptedException, ExecutionException; + /** + * Indicates the state of scheduling. + * + * @param id task ID + * @return true, if the execution has been scheduled for the task, false otherwise + */ boolean hasBeenScheduledForTaskId(String id); } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java index 22fa5339..9d182084 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java @@ -17,11 +17,14 @@ import org.springframework.beans.factory.annotation.Autowired; import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; + import cz.cuni.mff.xrg.odalic.feedbacks.ColumnIgnore; import cz.cuni.mff.xrg.odalic.files.File; import cz.cuni.mff.xrg.odalic.files.FileService; import cz.cuni.mff.xrg.odalic.tasks.Task; import cz.cuni.mff.xrg.odalic.tasks.TaskService; +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; import cz.cuni.mff.xrg.odalic.tasks.results.AnnotationToResultAdapter; import cz.cuni.mff.xrg.odalic.tasks.results.Result; @@ -31,11 +34,19 @@ import uk.ac.shef.dcs.sti.xtractor.csv.TableXtractorCSV; /** + *

Implementation of {@link ExecutionService} based on {@link Future} and {@link ExecutorServicee} + * implementations.

+ * + *

Provides no persistence whatsoever

+ * * @author Václav Brodec * */ public final class FutureBasedExecutionService implements ExecutionService { + private static final String TEMP_FILE_PREFIX = "odalic"; + private static final String TEMP_FILE_SUFFIX = "csv"; + private final TaskService taskService; private final FileService fileService; private final AnnotationToResultAdapter annotationResultAdapter; @@ -47,7 +58,8 @@ public final class FutureBasedExecutionService implements ExecutionService { @Autowired public FutureBasedExecutionService(TaskService taskService, FileService fileService, AnnotationToResultAdapter annotationToResultAdapter, - SemanticTableInterpreterFactory semanticTableInterpreterFactory, TableXtractorCSV tableExtractor) { + SemanticTableInterpreterFactory semanticTableInterpreterFactory, + TableXtractorCSV tableExtractor) { Preconditions.checkNotNull(taskService); Preconditions.checkNotNull(fileService); Preconditions.checkNotNull(annotationToResultAdapter); @@ -61,41 +73,42 @@ public FutureBasedExecutionService(TaskService taskService, FileService fileServ this.tableExtractor = tableExtractor; } + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.tasks.executions.ExecutionService#submitForTaskId(java.lang.String) + */ @Override - public void submitForTaskId(String id) { + public void submitForTaskId(String id) throws IllegalStateException { final Task task = taskService.getById(id); final Future resultFuture = tasksToResults.get(task); - if (resultFuture != null) { - if (!resultFuture.isDone()) { - throw new IllegalStateException(); - } - } + Preconditions.checkState(resultFuture == null || resultFuture.isDone()); final Configuration configuration = task.getConfiguration(); final File file = configuration.getInput(); - + final Set columnIgnores = configuration.getFeedback().getColumnIgnores(); - final Integer[] columnIgnoresArray = - columnIgnores.stream().map(e -> e.getPosition().getIndex()).toArray(Integer[]::new); - + final Callable execution = () -> { final String data = fileService.getDataById(file.getId()); - - final java.io.File tempFile = java.io.File.createTempFile("odalic", "csv"); + + //TODO: Remove dependency on temporary file creation. + final java.io.File tempFile = java.io.File.createTempFile(TEMP_FILE_PREFIX, TEMP_FILE_SUFFIX); tempFile.deleteOnExit(); FileUtils.writeStringToFile(tempFile, data); - + + //TODO: Substitute table extractor with something more robust as soon as possible. final List
tables = tableExtractor.extract(tempFile, tempFile.getName()); if (tables.isEmpty()) { throw new IllegalArgumentException(); } final SemanticTableInterpreter interpreter = semanticTableInterpreterFactory.getInterpreter(); - semanticTableInterpreterFactory.setIgnoreColumnsForInterpreter(columnIgnoresArray); + semanticTableInterpreterFactory.setColumnIgnoresForInterpreter(columnIgnores); final TAnnotation annotationResult = interpreter.start(tables.get(0), true); - final Result result = annotationResultAdapter.toResult(annotationResult); + //TODO: Add multiple KB support to configuration. + final Result result = annotationResultAdapter + .toResult(ImmutableMap.of(new KnowledgeBase("DBpedia"), annotationResult)); return result; }; @@ -129,7 +142,7 @@ public boolean isDoneForTaskId(String id) { } @Override - public boolean isCancelledForTaskId(String id) { + public boolean isCanceledForTaskId(String id) { final Task task = taskService.getById(id); final Future resultFuture = tasksToResults.get(task); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/SemanticTableInterpreterFactory.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/SemanticTableInterpreterFactory.java index 7f6dba1a..aa124d15 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/SemanticTableInterpreterFactory.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/SemanticTableInterpreterFactory.java @@ -1,12 +1,31 @@ package cz.cuni.mff.xrg.odalic.tasks.executions; +import java.util.Set; + +import cz.cuni.mff.xrg.odalic.feedbacks.ColumnIgnore; import uk.ac.shef.dcs.sti.core.algorithm.SemanticTableInterpreter; +/** + * This factory class loosely encapsulates (notice the {@link #setColumnIgnoresForInterpreter(Set)} method) the process of interpreter creation. + * + * @author Václav Brodec + * + */ public interface SemanticTableInterpreterFactory { + /** + * Lazily initializes the interpreter. + * + * @return the interpreter implementation + */ SemanticTableInterpreter getInterpreter(); - void setIgnoreColumnsForInterpreter(Integer[] ignoreCols); + /** + * Sets the ignored columns for the created interpreter. + * + * @param columnIgnores positions of ignored columns + */ + void setColumnIgnoresForInterpreter(Set columnIgnores); } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/State.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/State.java deleted file mode 100644 index a252f7ae..00000000 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/State.java +++ /dev/null @@ -1,16 +0,0 @@ -package cz.cuni.mff.xrg.odalic.tasks.executions; - -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlEnumValue; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -@XmlType -@XmlEnum(String.class) -@XmlRootElement -public enum State { - @XmlEnumValue("READY") READY, - @XmlEnumValue("SCHEDULED") SCHEDULED, - @XmlEnumValue("CANCELLED") CANCELLED, - @XmlEnumValue("FINISHED") FINISHED -} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/TableMinerPlusFactory.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/TableMinerPlusFactory.java index 3125753f..8594c596 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/TableMinerPlusFactory.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/TableMinerPlusFactory.java @@ -4,22 +4,21 @@ import java.io.FileInputStream; import java.io.IOException; import java.nio.file.Paths; -import java.util.Arrays; -import java.util.HashSet; import java.util.List; import java.util.Properties; +import java.util.Set; +import java.util.stream.Collectors; import org.apache.commons.lang.exception.ExceptionUtils; -import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; import org.apache.solr.core.CoreContainer; import org.simmetrics.metrics.StringMetrics; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - import com.google.common.base.Preconditions; +import cz.cuni.mff.xrg.odalic.feedbacks.ColumnIgnore; import uk.ac.shef.dcs.kbsearch.KBSearch; import uk.ac.shef.dcs.kbsearch.KBSearchFactory; import uk.ac.shef.dcs.sti.STIConstantProperty; @@ -39,6 +38,13 @@ import uk.ac.shef.dcs.sti.core.subjectcol.SubjectColumnDetector; import uk.ac.shef.dcs.sti.util.FileUtils; +/** + * Implementation of {@link SemanticTableInterpreterFactory} that provides {@link TMPInterpreter} + * instances. + * + * @author Josef Janoušek + * + */ public final class TableMinerPlusFactory implements SemanticTableInterpreterFactory { private static final String PROPERTY_HOME = "sti.home"; @@ -83,14 +89,14 @@ public final class TableMinerPlusFactory implements SemanticTableInterpreterFact public TableMinerPlusFactory(String propertyFilePath) { Preconditions.checkNotNull(propertyFilePath); - + this.propertyFilePath = propertyFilePath; } - + public TableMinerPlusFactory() { this(System.getProperty("cz.cuni.mff.xrg.odalic.sti")); } - + /* * (non-Javadoc) * @@ -111,14 +117,17 @@ public SemanticTableInterpreter getInterpreter() { /* * (non-Javadoc) * - * @see - * cz.cuni.mff.xrg.odalic.tasks.executions.InterpreterFactory#setIgnoreColumnsForInterpreter(java. - * lang.Integer[]) + * @see cz.cuni.mff.xrg.odalic.tasks.executions.SemanticTableInterpreterFactory# + * setColumnIgnoresForInterpreter(java.util.Set) */ @Override - public void setIgnoreColumnsForInterpreter(Integer[] ignoreCols) { - interpreter.setIgnoreColumns(new HashSet(Arrays.asList(ignoreCols))); - literalColumnTagger.setIgnoreColumns(ArrayUtils.toPrimitive(ignoreCols)); + public void setColumnIgnoresForInterpreter(Set ignoreColumnsPositions) { + final Set indexSet = ignoreColumnsPositions.stream() + .map(e -> e.getPosition().getIndex()).collect(Collectors.toSet()); + + interpreter.setIgnoreColumns(indexSet); + literalColumnTagger + .setIgnoreColumns(indexSet.stream().mapToInt(e -> e.intValue()).sorted().toArray()); } // Initialize kbsearcher, websearcher @@ -324,5 +333,4 @@ private int[] getMustdoColumns() { } return res; } - } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/FeedbackService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/FeedbackService.java index 7322124f..47b6d968 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/FeedbackService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/FeedbackService.java @@ -5,6 +5,12 @@ import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; import cz.cuni.mff.xrg.odalic.feedbacks.input.Input; +/** + * Feedback service handles the CRUD operations for {@link Feedback} instances. + * + * @author Václav Brodec + * + */ public interface FeedbackService { Feedback getForTaskId(String taskId); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/MemoryOnlyFeedbackService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/MemoryOnlyFeedbackService.java index f499eb21..d4a9cd37 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/MemoryOnlyFeedbackService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/MemoryOnlyFeedbackService.java @@ -15,6 +15,8 @@ import cz.cuni.mff.xrg.odalic.tasks.configurations.ConfigurationService; /** + * This {@link FeedbackService} implementation provides no persistence. + * * @author Václav Brodec * */ diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/AnnotationToResultAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/AnnotationToResultAdapter.java index 6e1c24e4..8e2bfff8 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/AnnotationToResultAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/AnnotationToResultAdapter.java @@ -1,7 +1,24 @@ package cz.cuni.mff.xrg.odalic.tasks.results; +import java.util.Map; + +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; import uk.ac.shef.dcs.sti.core.model.TAnnotation; +/** + * Converts the complete annotation result provided by the Semantic Table Interpreter to the + * representation used by Odalic server to facilitate RDF output and user feedback. + * + * @author Václav Brodec + * + */ public interface AnnotationToResultAdapter { - Result toResult(TAnnotation annotation); + /** + * Converts the annotation formats. + * + * @param basesToTableAnnotations map to table annotations from the knowledge bases that were used + * to make them + * @return Odalic result format + */ + Result toResult(Map basesToTableAnnotations); } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/DefaultAnnotationToResultAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/DefaultAnnotationToResultAdapter.java index 295641b5..3bdb55ba 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/DefaultAnnotationToResultAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/DefaultAnnotationToResultAdapter.java @@ -4,32 +4,155 @@ import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; import cz.cuni.mff.xrg.odalic.positions.RowPosition; -import cz.cuni.mff.xrg.odalic.tasks.annotations.*; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.Entity; +import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; +import cz.cuni.mff.xrg.odalic.tasks.annotations.HeaderAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; +import cz.cuni.mff.xrg.odalic.tasks.annotations.Likelihood; +import cz.cuni.mff.xrg.odalic.util.Arrays; +import cz.cuni.mff.xrg.odalic.util.Lists; +import cz.cuni.mff.xrg.odalic.util.Maps; import uk.ac.shef.dcs.kbsearch.model.Clazz; -import uk.ac.shef.dcs.sti.core.model.*; - -import java.util.*; +import uk.ac.shef.dcs.sti.core.model.RelationColumns; +import uk.ac.shef.dcs.sti.core.model.TAnnotation; +import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; +import uk.ac.shef.dcs.sti.core.model.TCellCellRelationAnotation; +import uk.ac.shef.dcs.sti.core.model.TColumnColumnRelationAnnotation; +import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; import java.util.List; - +import java.util.Map; +import java.util.Set; + +import javax.annotation.concurrent.Immutable; + +import com.google.common.base.Preconditions; + +/** + * This implementation of {@link AnnotationToResultAdapter} simply merges the annotations done with + * different knowledge bases. + * + * @author Jan Váňa + * @author Václav Brodec + * + */ +@Immutable public class DefaultAnnotationToResultAdapter implements AnnotationToResultAdapter { - @Override - public Result toResult(TAnnotation original) { - // TODO: Pass this from the core - KnowledgeBase knowledgeBase = new KnowledgeBase("DBpedia"); - - List headerAnnotations = ConvertColumnAnnotations(original, knowledgeBase); - CellAnnotation[][] cellAnnotations = ConvertCellAnnotations(original, knowledgeBase); - Map columnRelations = ConvertColumnRelations(original, knowledgeBase); - Map cellCellRelations = ConvertCellRelations(original, knowledgeBase); - ColumnPosition subjectColumn = new ColumnPosition(original.getSubjectColumn()); - - Result result = new Result(subjectColumn, headerAnnotations, cellAnnotations, columnRelations, cellCellRelations); - - return result; + /** + * This implementation demands that the subject columns recognized in the annotations are the same. + * + * @see cz.cuni.mff.xrg.odalic.tasks.results.AnnotationToResultAdapter#toResult(java.util.Map) + */ + @Override + public Result toResult(Map basesToTableAnnotations) { + Preconditions.checkArgument(!basesToTableAnnotations.isEmpty()); + + final Iterator> entrySetIterator = + initializeEntrySetIterator(basesToTableAnnotations); + + // Process the first entry to initialize working structures for the merges. + final Map.Entry firstEntry = entrySetIterator.next(); + final KnowledgeBase firstKnowledgeBase = firstEntry.getKey(); + final TAnnotation firstTableAnnotation = firstEntry.getValue(); + + final ColumnPosition firstSubjectColumn = convertSubjectColumn(firstTableAnnotation); + final List mergedHeaderAnnotations = + convertColumnAnnotations(firstKnowledgeBase, firstTableAnnotation); + final CellAnnotation[][] mergedCellAnnotations = + convertCellAnnotations(firstKnowledgeBase, firstTableAnnotation); + final Map mergedColumnRelations = + convertColumnRelations(firstKnowledgeBase, firstTableAnnotation); + final Map mergedCellCellRelations = + convertCellRelations(firstKnowledgeBase, firstTableAnnotation); + + // Process the rest. + processTheRest(entrySetIterator, firstSubjectColumn, mergedHeaderAnnotations, + mergedCellAnnotations, mergedColumnRelations, mergedCellCellRelations); + + return new Result(firstSubjectColumn, mergedHeaderAnnotations, mergedCellAnnotations, mergedColumnRelations, mergedCellCellRelations); + } + + private static Iterator> initializeEntrySetIterator( + Map basesToTableAnnotations) { + final Set> entrySet = basesToTableAnnotations.entrySet(); + final Iterator> entrySetIterator = entrySet.iterator(); + return entrySetIterator; + } + + private static void processTheRest( + final Iterator> entrySetIterator, + final ColumnPosition firstSubjectColumn, final List mergedHeaderAnnotations, + final CellAnnotation[][] mergedCellAnnotations, + final Map mergedColumnRelations, + final Map mergedCellCellRelations) { + while (entrySetIterator.hasNext()) { + final Map.Entry entry = entrySetIterator.next(); + + final KnowledgeBase knowledgeBase = entry.getKey(); + final TAnnotation tableAnnotation = entry.getValue(); + + checkSubjectColumnEquality(firstSubjectColumn, tableAnnotation); // The annotations must agree on the subject column!!! + + mergeHeaders(mergedHeaderAnnotations, knowledgeBase, tableAnnotation); + mergeCells(mergedCellAnnotations, knowledgeBase, tableAnnotation); + mergeColumnRelations(mergedColumnRelations, knowledgeBase, tableAnnotation); + mergeCellRelations(mergedCellCellRelations, knowledgeBase, tableAnnotation); } - - Map ConvertCellRelations(TAnnotation original, KnowledgeBase knowledgeBase) { + } + + private static void checkSubjectColumnEquality(final ColumnPosition firstSubjectColumn, + final TAnnotation tableAnnotation) { + final ColumnPosition subjectColumn = convertSubjectColumn(tableAnnotation); + Preconditions.checkArgument(subjectColumn.equals(firstSubjectColumn)); + } + + private static ColumnPosition convertSubjectColumn(final TAnnotation tableAnnotation) { + final ColumnPosition subjectColumn = new ColumnPosition(tableAnnotation.getSubjectColumn()); + return subjectColumn; + } + + private static void mergeCellRelations( + final Map mergedCellCellRelations, + final KnowledgeBase knowledgeBase, final TAnnotation tableAnnotation) { + final Map cellCellRelations = + convertCellRelations(knowledgeBase, tableAnnotation); + Maps.mergeWith(mergedCellCellRelations, cellCellRelations, + (first, second) -> first.merge(second)); + } + + private static void mergeColumnRelations( + final Map mergedColumnRelations, + final KnowledgeBase knowledgeBase, final TAnnotation tableAnnotation) { + final Map columnRelations = + convertColumnRelations(knowledgeBase, tableAnnotation); + Maps.mergeWith(mergedColumnRelations, columnRelations, + (first, second) -> first.merge(second)); + } + + private static void mergeCells(final CellAnnotation[][] mergedCellAnnotations, + final KnowledgeBase knowledgeBase, final TAnnotation tableAnnotation) { + final CellAnnotation[][] cellAnnotations = convertCellAnnotations(knowledgeBase, tableAnnotation); + Arrays.zipMatrixWith(mergedCellAnnotations, cellAnnotations, + (first, second) -> first.merge(second)); + } + + private static void mergeHeaders(final List mergedHeaderAnnotations, + final KnowledgeBase knowledgeBase, final TAnnotation tableAnnotation) { + final List headerAnnotations = + convertColumnAnnotations(knowledgeBase, tableAnnotation); + Lists.zipWith(mergedHeaderAnnotations, headerAnnotations, + (first, second) -> first.merge(second)); + } + + private static Map convertCellRelations(KnowledgeBase knowledgeBase, TAnnotation original) { Map cellCellRelations = new HashMap<>(); for (Map.Entry>> columnAnnotations : original.getCellcellRelations().entrySet() ){ for(Map.Entry> annotations : columnAnnotations.getValue().entrySet()){ @@ -71,7 +194,7 @@ Map ConvertCellRelations(TAnnotati return cellCellRelations; } - Map ConvertColumnRelations(TAnnotation original, KnowledgeBase knowledgeBase) { + private static Map convertColumnRelations(KnowledgeBase knowledgeBase, TAnnotation original) { Map columnRelations = new HashMap<>(); for (Map.Entry> annotations : original.getColumncolumnRelations().entrySet() ){ HashMap> candidates = new HashMap<>(); @@ -109,7 +232,7 @@ Map ConvertColumnRelations(TAn return columnRelations; } - CellAnnotation[][] ConvertCellAnnotations(TAnnotation original, KnowledgeBase knowledgeBase) { + private static CellAnnotation[][] convertCellAnnotations(KnowledgeBase knowledgeBase, TAnnotation original) { int columnCount = original.getCols(); int rowCount = original.getRows(); CellAnnotation[][] cellAnnotations = new CellAnnotation[rowCount][columnCount]; @@ -157,7 +280,7 @@ CellAnnotation[][] ConvertCellAnnotations(TAnnotation original, KnowledgeBase kn return cellAnnotations; } - List ConvertColumnAnnotations(TAnnotation original, KnowledgeBase knowledgeBase) { + private static List convertColumnAnnotations(KnowledgeBase knowledgeBase, TAnnotation original) { int columnCount = original.getCols(); List headerAnnotations = new ArrayList<>(columnCount); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/Result.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/Result.java index c8be8bdc..130a52fe 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/Result.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/Result.java @@ -6,14 +6,12 @@ import java.util.Map; import javax.annotation.Nullable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; +import javax.annotation.concurrent.Immutable; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import org.apache.jena.ext.com.google.common.collect.ImmutableMap; - import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import cz.cuni.mff.xrg.odalic.api.rest.adapters.ResultAdapter; import cz.cuni.mff.xrg.odalic.positions.CellRelationPosition; @@ -24,93 +22,71 @@ import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; import cz.cuni.mff.xrg.odalic.tasks.annotations.HeaderAnnotation; +/** + *

+ * This class represents a partial result of the table annotation process. + *

+ * + *

+ * It includes all the data necessary to produce the final triples and also serves as the base for + * user-defined hints to the annotating algorithm. + *

+ * + *

+ * Any benchmarking, debugging or temporary result data are not included. + *

+ * + * @author Václav Brodec + * + */ +@Immutable @XmlJavaTypeAdapter(ResultAdapter.class) -@XmlRootElement(name = "result") public class Result implements Serializable { private static final long serialVersionUID = -6359038623760039155L; - @XmlElement private final ColumnPosition subjectColumnPosition; - - @XmlElement + private final List headerAnnotations; - - @XmlElement + private final CellAnnotation[][] cellAnnotations; - - @XmlElement + private final Map columnRelationAnnotations; - - @XmlElement + private final Map cellRelationAnnotations; - @SuppressWarnings("unused") - private Result() { - subjectColumnPosition = null; - headerAnnotations = ImmutableList.of(); - cellAnnotations = new CellAnnotation[0][0];; - columnRelationAnnotations = ImmutableMap.of(); - cellRelationAnnotations = ImmutableMap.of(); - } - /** - * @param subjectColumnPosition - * @param headerAnnotations - * @param cellAnnotations - * @param columnRelationAnnotations - * @param cellRelationAnnotations + * Creates new annotation result representation. + * + * @param subjectColumnPosition suggested position of the subject column + * @param headerAnnotations suggested header annotations + * @param cellAnnotations suggested cell annotations + * @param columnRelationAnnotations suggested annotations for the relations between two columns + * @param cellRelationAnnotations suggested annotation for relations existing between two cells at + * the same row */ - public Result(List headerAnnotations, + public Result(ColumnPosition subjectColumnPosition, List headerAnnotations, CellAnnotation[][] cellAnnotations, Map columnRelationAnnotations, Map cellRelationAnnotations) { - checkMandatory(headerAnnotations, cellAnnotations, columnRelationAnnotations, - cellRelationAnnotations); - - this.subjectColumnPosition = null; - this.headerAnnotations = ImmutableList.copyOf(headerAnnotations); - this.cellAnnotations = cz.cuni.mff.xrg.odalic.util.Arrays.deepCopy(CellAnnotation.class, cellAnnotations); - this.columnRelationAnnotations = ImmutableMap.copyOf(columnRelationAnnotations); - this.cellRelationAnnotations = ImmutableMap.copyOf(cellRelationAnnotations); - } - - private static void checkMandatory(List headerAnnotations, - CellAnnotation[][] cellAnnotations, - Map columnRelationAnnotations, - Map cellRelationAnnotations) { - checkMandatory(headerAnnotations, cellAnnotations, columnRelationAnnotations, - cellRelationAnnotations); - + Preconditions.checkNotNull(subjectColumnPosition); + Preconditions.checkNotNull(headerAnnotations); + Preconditions.checkNotNull(cellAnnotations); + Preconditions.checkNotNull(columnRelationAnnotations); + Preconditions.checkNotNull(cellRelationAnnotations); Preconditions.checkArgument(!cz.cuni.mff.xrg.odalic.util.Arrays.containsNull(cellAnnotations)); Preconditions.checkArgument(cz.cuni.mff.xrg.odalic.util.Arrays.isMatrix(cellAnnotations)); - } - - /** - * @param subjectColumnPosition - * @param headerAnnotations - * @param cellAnnotations - * @param columnRelationAnnotations - * @param cellRelationAnnotations - */ - public Result(ColumnPosition subjectColumnPosition, - List headerAnnotations, - CellAnnotation[][] cellAnnotations, - Map columnRelationAnnotations, - Map cellRelationAnnotations) { - Preconditions.checkNotNull(subjectColumnPosition); - checkMandatory(headerAnnotations, cellAnnotations, columnRelationAnnotations, - cellRelationAnnotations); - + this.subjectColumnPosition = subjectColumnPosition; this.headerAnnotations = ImmutableList.copyOf(headerAnnotations); - this.cellAnnotations = cz.cuni.mff.xrg.odalic.util.Arrays.deepCopy(CellAnnotation.class, cellAnnotations); + this.cellAnnotations = + cz.cuni.mff.xrg.odalic.util.Arrays.deepCopy(CellAnnotation.class, cellAnnotations); this.columnRelationAnnotations = ImmutableMap.copyOf(columnRelationAnnotations); this.cellRelationAnnotations = ImmutableMap.copyOf(cellRelationAnnotations); } /** - * @return the subjectColumnPosition + * @return the subject column position */ @Nullable public ColumnPosition getSubjectColumnPosition() { @@ -118,34 +94,36 @@ public ColumnPosition getSubjectColumnPosition() { } /** - * @return the headerAnnotations + * @return the header annotations */ public List getHeaderAnnotations() { return headerAnnotations; } /** - * @return the cellAnnotations + * @return the cell annotations */ public CellAnnotation[][] getCellAnnotations() { return cz.cuni.mff.xrg.odalic.util.Arrays.deepCopy(CellAnnotation.class, cellAnnotations); } /** - * @return the columnRelationAnnotations + * @return the column relation annotations */ public Map getColumnRelationAnnotations() { return columnRelationAnnotations; } /** - * @return the cellRelationAnnotations + * @return the cell relation annotations */ public Map getCellRelationAnnotations() { return cellRelationAnnotations; } - /* (non-Javadoc) + /** + * Computes hash code based on all its parts. + * * @see java.lang.Object#hashCode() */ @Override @@ -163,7 +141,9 @@ public int hashCode() { return result; } - /* (non-Javadoc) + /** + * Compares to another object for equality (only another Result composed from equal parts passes). + * * @see java.lang.Object#equals(java.lang.Object) */ @Override @@ -212,7 +192,9 @@ public boolean equals(Object obj) { return true; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/Arrays.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/Arrays.java index f29ab998..d52548e3 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/Arrays.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/Arrays.java @@ -1,61 +1,134 @@ package cz.cuni.mff.xrg.odalic.util; import java.lang.reflect.Array; +import java.util.function.BiFunction; -public class Arrays { +import com.google.common.base.Preconditions; + +/** + * Utility class for -- you guessed it -- working with arrays. + * + * @author Václav Brodec + * + */ +public final class Arrays { + + /** + * We want to keep this class uninstantiable, so no visible constructor is available. + */ private Arrays() {} /** - * @param arrayOfArrays - * @return + *

+ * Checks for {@code null} every (array) element of the array and elements of the element array. + *

+ * + *

+ * Please note that the method does not expect the elements of the nested array to be also arrays + * (in other words: it does not go beyond the second dimension). + *

+ * + * @param arrayOfArrays array of arrays + * @return true, if any element up to second dimension is null, false otherwise + * @throws NullPointerException If the arrayOfArrays itself is {@code null} */ - public static boolean containsNull(Object[][] arrayOfArrays) { + public static boolean containsNull(Object[][] arrayOfArrays) throws NullPointerException { for (int i = 0; i < arrayOfArrays.length; i++) { if (arrayOfArrays[i] == null) { return true; } - + for (int j = 0; j < arrayOfArrays[i].length; j++) { if (arrayOfArrays[i][j] == null) { return true; } } } - + return false; } /** - * @param matrix - * @return + *

+ * Checks whether the array of arrays is a matrix (all the rows has the same number of cells). + *

+ * + *

+ * Please note that the method does not expect the elements of the nested array to be also arrays + * (in other words: it does not go beyond the second dimension). + *

+ * + *

+ * Also it accepts empty array of arrays and array of zero-length arrays as a valid matrix. + *

+ * + * @param arrayOfArrays array of arrays + * @return true, if the array of arrays is a matrix (up to second dimension) */ - public static boolean isMatrix(Object[][] matrix) { - for (int i = 0; i < matrix.length; i++) { - if (matrix[i].length != matrix.length) { + public static boolean isMatrix(Object[][] arrayOfArrays) { + if (arrayOfArrays.length == 0) { + return true; + } + + final int columnsCount = arrayOfArrays[0].length; + for (int i = 1; i < arrayOfArrays.length; i++) { + if (arrayOfArrays[i].length != columnsCount) { return false; } - } - + } + return true; } /** - * @param type - * @param matrix - * @return + * Creates a deep copy of a matrix (up to second dimension). + * + * @param type type of elements + * @param matrix the matrix + * @return deep copy of the matrix + * @throws IllegalArgumentException if either of dimensions of the matrix is zero, if the type of + * elements is Void.TYPE, or if the number of any dimension of the matrix exceeds 255. + * + * @param type of elements */ - public static T[][] deepCopy(Class type, T[][] matrix) { - final int rows = matrix.length; - final int columns = (rows > 0) ? (matrix[0].length) : 0; - + public static T[][] deepCopy(Class type, T[][] matrix) throws IllegalArgumentException { + final int rowsCount = matrix.length; + final int columnsCount = (rowsCount > 0) ? (matrix[0].length) : 0; + @SuppressWarnings("unchecked") - T[][] copy = (T[][]) Array.newInstance(type, rows, columns); - for(int i = 0; i < matrix.length; i++) { - copy[i] = matrix[i].clone(); + T[][] copy = (T[][]) Array.newInstance(type, rowsCount, columnsCount); + for (int i = 0; i < rowsCount; i++) { + copy[i] = matrix[i].clone(); } - + return copy; } - - + + /** + * Executes functional zip over a two matrices, but modifies the first one in the process. + * + * @param modified the matrix whose elements serve as the first argument of the zip function and + * then are replaced by its result + * @param added matrix whose elements serve as the second argument of the zip function + * @param zipFunction zip function + * @throws IllegalArgumentException If the modified and added are not matrices or have different dimensions + * + * @param type of elements in modified + * @param type of elements in added + */ + public static void zipMatrixWith(T[][] modified, U[][] added, + BiFunction zipFunction) throws IllegalArgumentException { + Preconditions.checkArgument(modified.length != 0); + Preconditions.checkArgument(added.length == modified.length); + Preconditions.checkArgument(added[0].length == modified[0].length); + Preconditions.checkArgument(isMatrix(modified)); + Preconditions.checkArgument(isMatrix(added)); + + for (int i = 0; i < modified.length; i++) { + for (int j = 0; j < modified[0].length; j++) { + modified[i][j] = zipFunction.apply(modified[i][j], added[i][j]); + } + } + } + } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/Lists.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/Lists.java new file mode 100644 index 00000000..c84becc4 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/Lists.java @@ -0,0 +1,49 @@ +package cz.cuni.mff.xrg.odalic.util; + +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.function.BiFunction; + +/** + * Utility class for -- you guessed it -- working with collections. + * + * @author Václav Brodec + * + */ +public final class Lists { + + /** + * We want to keep this class uninstantiable, so no visible constructor is available. + */ + private Lists() {} + + /** + * Executes functional zip over a list and a collection, but modifies the list in the process. + * + * @param modified the list whose elements serve as the first argument of the zip function and + * then are replaced by its result + * @param added collection whose elements serve as the second argument of the zip function + * @param zipFunction zip function + * @throws IllegalArgumentException If the modified and added have different number of elements + * @throws UnsupportedOperationException if the set operation is not supported by the list iterator + * + * @param type of elements in modified + * @param type of elements in added + */ + public static void zipWith(List modified, Collection added, + BiFunction zipFunction) throws IllegalArgumentException { + if (modified.size() != added.size()) { + throw new IllegalArgumentException(); + } + + final ListIterator listIterator = modified.listIterator(); + final Iterator iterator = added.iterator(); + while (listIterator.hasNext() && iterator.hasNext()) { + listIterator.set(zipFunction.apply(listIterator.next(), iterator.next())); + } + } + + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/Maps.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/Maps.java new file mode 100644 index 00000000..f43d025a --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/Maps.java @@ -0,0 +1,48 @@ +package cz.cuni.mff.xrg.odalic.util; + +import java.util.Map; +import java.util.function.BiFunction; + +/** + * Utility class for -- you guessed it -- working with maps. + * + * @author Václav Brodec + * + */ +public final class Maps { + + /** + * We want to keep this class uninstantiable, so no visible constructor is available. + */ + private Maps() {} + + /** + * Merges the added map into the modified one. If the key of the added entry is not found in the map, the entry is simply added. + * + * @param modified the map whose elements serve as the first argument of the merge function and + * then are replaced by its result + * @param added collection whose elements serve as the second argument of the merge function + * @param mergeFunction merge function + * + * @param type of keys + * @param type of values + */ + public static void mergeWith(Map modified, Map added, + BiFunction mergeFunction) throws IllegalArgumentException { + + for (Map.Entry addedEntry : added.entrySet()) { + final K key = addedEntry.getKey(); + + final V addedValue = addedEntry.getValue(); + final V modifiedValue = modified.get(key); + + if (modifiedValue == null) { + modified.put(key, addedValue); + } else { + modified.put(key, mergeFunction.apply(modifiedValue, addedValue)); + } + } + } + + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/URL.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/URL.java index 9e06ebb4..1a968078 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/URL.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/URL.java @@ -4,11 +4,34 @@ import javax.ws.rs.core.UriInfo; +/** + * Utility class for -- you guessed it -- working with URLs. + * + * @author Václav Brodec + * + */ public final class URL { + + /** + * We want to keep this class uninstantiable, so no visible constructor is available. + */ private URL() {} - public static java.net.URL getResourceUrL(UriInfo requestUriInfo, String resourceName) - throws MalformedURLException { - return requestUriInfo.getAbsolutePath().resolve(resourceName).toURL(); + /** + * One-off function that essentially takes the absolute path of the request URI (encapsulated by + * the {@link UriInfo} instance) and resolves the sub-resource name against it to get the absolute + * path of the sub-resource. + * + * @param requestUriInfo URI info + * @param subResource a string to resolve against the URI + * @return absolute path of the string + * @throws MalformedURLException If a protocol handler for the URL could not be found, or if some + * other error occurred while constructing the URL + * @throws IllegalStateException If called outside a scope of a request + * @throws IllegalArgumentException If the given string violates RFC 2396 + */ + public static java.net.URL getSubResourceAbsolutePath(UriInfo requestUriInfo, String subResource) + throws MalformedURLException, IllegalStateException { + return requestUriInfo.getAbsolutePath().resolve(subResource).toURL(); } } diff --git a/odalic/src/main/resources/spring/applicationContext.xml b/odalic/src/main/resources/spring/applicationContext.xml index 74fed33b..150c4e80 100644 --- a/odalic/src/main/resources/spring/applicationContext.xml +++ b/odalic/src/main/resources/spring/applicationContext.xml @@ -33,7 +33,7 @@ class="cz.cuni.mff.xrg.odalic.tasks.executions.FutureBasedExecutionService" /> - + diff --git a/odalic/src/test/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterExecutionBatch.java b/odalic/src/test/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterExecutionBatch.java index 29790907..7e3678a5 100644 --- a/odalic/src/test/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterExecutionBatch.java +++ b/odalic/src/test/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterExecutionBatch.java @@ -1,65 +1,61 @@ package cz.cuni.mff.xrg.odalic.tasks.executions; import java.io.File; -//import java.util.ArrayList; +// import java.util.ArrayList; import java.util.Arrays; import java.util.List; import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableSet; import uk.ac.shef.dcs.sti.STIException; import uk.ac.shef.dcs.sti.core.algorithm.SemanticTableInterpreter; import uk.ac.shef.dcs.sti.core.model.TAnnotation; import uk.ac.shef.dcs.sti.core.model.Table; -//import uk.ac.shef.dcs.sti.parser.table.TableParserLimayeDataset; +// import uk.ac.shef.dcs.sti.parser.table.TableParserLimayeDataset; import uk.ac.shef.dcs.sti.xtractor.csv.TableXtractorCSV; public class InterpreterExecutionBatch { + /** + * Expects sti.properties file path as the first and test file directory path as the second + * command line argument + * + * @param args command line arguments + * + * @author Josef Janoušek + */ public static void main(String[] args) { - // for test of execution of semantic table interpreter from Odalic project - final String propertyFilePath = args[0]; final String testFileDirectoryPath = args[1]; - - SemanticTableInterpreterFactory factory = new TableMinerPlusFactory(propertyFilePath); - SemanticTableInterpreter semanticTableInterpreter = factory.getInterpreter(); + + final SemanticTableInterpreterFactory factory = new TableMinerPlusFactory(propertyFilePath); + final SemanticTableInterpreter semanticTableInterpreter = factory.getInterpreter(); Preconditions.checkNotNull(semanticTableInterpreter); - factory.setIgnoreColumnsForInterpreter(new Integer[]{}); - //TODO: Write your own path to the folder containing (only) the input file. - List all = Arrays.asList(new File(testFileDirectoryPath).listFiles()); - File inputFile = all.get(0); - - // code for extraction from CSV + factory.setColumnIgnoresForInterpreter(ImmutableSet.of()); + + final List all = Arrays.asList(new File(testFileDirectoryPath).listFiles()); + final File inputFile = all.get(0); + + // Code for extraction from CSV TableXtractorCSV tableExtractor = new TableXtractorCSV(); List
tables = tableExtractor.extract(inputFile, inputFile.getName()); - - // code for extraction from LimayeDataset - /*TableParserLimayeDataset tableExtractor = new TableParserLimayeDataset(); - List
tables; - try { - tables = tableExtractor.extract(inputFile.toString(), inputFile.toString()); - } catch (STIException e1) { - e1.printStackTrace(); - tables = new ArrayList<>(); - }*/ - if (tables.isEmpty()) { throw new IllegalArgumentException(); } - - TAnnotation annotationResult; + + final TAnnotation annotationResult; try { annotationResult = semanticTableInterpreter.start(tables.get(0), true); - - System.out.println("V�sledek - OK:"); + + System.out.println("Result - OK:"); System.out.println(annotationResult.toString()); } catch (STIException e) { - System.out.println("V�sledek - Chyba:"); + System.out.println("Result - Error:"); e.printStackTrace(); } - System.out.println("Konec v�sledku."); + System.out.println("End of result."); } } From 5adc1e4de33ad641041e372765d03ff3c8e7644a Mon Sep 17 00:00:00 2001 From: brodecva Date: Wed, 6 Jul 2016 09:30:44 +0200 Subject: [PATCH 050/211] Result output fix. --- .../ColumnPositionKeyJsonSerializer.java | 2 +- ...ellRelationAnnotationMapMapSerializer.java | 4 +- .../KnowledgeBaseKeyJsonSerializer.java | 4 +- .../RowPositionKeyJsonDeserializer.java | 3 +- .../RowPositionKeyJsonSerializer.java | 8 +- .../xrg/odalic/api/rest/errors/Message.java | 6 - .../api/rest/values/LikelihoodValue.java | 1 - .../odalic/api/rest/values/ResultValue.java | 137 ++++++++++++------ .../tasks/annotations/EntityCandidate.java | 4 +- .../odalic/tasks/annotations/Likelihood.java | 2 +- 10 files changed, 102 insertions(+), 69 deletions(-) diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionKeyJsonSerializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionKeyJsonSerializer.java index c3fac5c4..45eb001e 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionKeyJsonSerializer.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionKeyJsonSerializer.java @@ -23,7 +23,7 @@ public final class ColumnPositionKeyJsonSerializer extends JsonSerializer> subentry : value.entrySet()) { - jgen.writeObjectField(Integer.toString(entry.getKey().getIndex()), subentry.getValue()); + for (final Map.Entry subEntry : entry.getValue().entrySet()) { + jgen.writeObjectField(Integer.toString(subEntry.getKey().getIndex()), subEntry.getValue()); } jgen.writeEndObject(); } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/KnowledgeBaseKeyJsonSerializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/KnowledgeBaseKeyJsonSerializer.java index 8bd77dd1..3a6d430f 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/KnowledgeBaseKeyJsonSerializer.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/KnowledgeBaseKeyJsonSerializer.java @@ -16,13 +16,11 @@ */ public final class KnowledgeBaseKeyJsonSerializer extends JsonSerializer { - public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm"; - @Override public void serialize(KnowledgeBase value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { - jgen.writeString(value.getName()); + jgen.writeFieldName(value.getName()); } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/RowPositionKeyJsonDeserializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/RowPositionKeyJsonDeserializer.java index 37645e74..cb956d90 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/RowPositionKeyJsonDeserializer.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/RowPositionKeyJsonDeserializer.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.KeyDeserializer; import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.positions.RowPosition; /** * Map key JSON deserializer for {@link ColumnPosition} instances. @@ -18,6 +19,6 @@ public final class RowPositionKeyJsonDeserializer extends KeyDeserializer { */ @Override public Object deserializeKey(String key, DeserializationContext ctxt) { - return new ColumnPosition(Integer.parseInt(key)); + return new RowPosition(Integer.parseInt(key)); } } \ No newline at end of file diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/RowPositionKeyJsonSerializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/RowPositionKeyJsonSerializer.java index f5997860..2a911f49 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/RowPositionKeyJsonSerializer.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/RowPositionKeyJsonSerializer.java @@ -6,7 +6,7 @@ import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; -import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.positions.RowPosition; import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; /** @@ -15,16 +15,16 @@ * @author Václav Brodec * */ -public final class RowPositionKeyJsonSerializer extends JsonSerializer { +public final class RowPositionKeyJsonSerializer extends JsonSerializer { /* (non-Javadoc) * @see com.fasterxml.jackson.databind.JsonSerializer#serialize(java.lang.Object, com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider) */ @Override - public void serialize(ColumnPosition value, JsonGenerator jgen, + public void serialize(RowPosition value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { - jgen.writeString(Integer.toString(value.getIndex())); + jgen.writeFieldName(Integer.toString(value.getIndex())); } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/Message.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/Message.java index f169222f..c36f1027 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/Message.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/Message.java @@ -63,8 +63,6 @@ public String getText() { * @param text the text to set */ public void setText(String text) { - Preconditions.checkNotNull(text); - this.text = text; } @@ -80,8 +78,6 @@ public String getLink() { * @param link the link to set */ public void setLink(String link) { - Preconditions.checkNotNull(link); - this.link = link; } @@ -97,8 +93,6 @@ public String getDeveloperText() { * @param developerText the developer text to set */ public void setDeveloperText(String developerText) { - Preconditions.checkNotNull(developerText); - this.developerText = developerText; } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/LikelihoodValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/LikelihoodValue.java index 918e630a..226c5d89 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/LikelihoodValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/LikelihoodValue.java @@ -43,7 +43,6 @@ public double getValue() { */ public void setValue(double value) { Preconditions.checkArgument(value >= 0); - Preconditions.checkArgument(value <= 1); this.value = value; } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ResultValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ResultValue.java index f43fbbb0..523ff29b 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ResultValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ResultValue.java @@ -2,6 +2,7 @@ import java.io.Serializable; import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -15,6 +16,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; +import com.google.common.collect.Maps; import cz.cuni.mff.xrg.odalic.api.rest.conversions.ColumnPositionKeyJsonDeserializer; import cz.cuni.mff.xrg.odalic.api.rest.conversions.ColumnPositionKeyJsonSerializer; @@ -47,21 +49,25 @@ public final class ResultValue implements Serializable { @XmlElement private ColumnPosition subjectColumnPosition; - + @XmlElement private List headerAnnotations; - + @XmlElement private CellAnnotation[][] cellAnnotations; - + @XmlElement - @JsonDeserialize(keyUsing = ColumnPositionKeyJsonDeserializer.class, contentUsing = ColumnPositionToColumnRelationAnnotationMapDeserializer.class) - @JsonSerialize(keyUsing = ColumnPositionKeyJsonSerializer.class, contentUsing = ColumnPositionToColumnRelationAnnotationMapSerializer.class) + @JsonDeserialize(keyUsing = ColumnPositionKeyJsonDeserializer.class, + contentUsing = ColumnPositionToColumnRelationAnnotationMapDeserializer.class) + @JsonSerialize(keyUsing = ColumnPositionKeyJsonSerializer.class, + contentUsing = ColumnPositionToColumnRelationAnnotationMapSerializer.class) private Map> columnRelationAnnotations; - + @XmlElement - @JsonDeserialize(keyUsing = RowPositionKeyJsonDeserializer.class, contentUsing = ColumnPositionToColumnPositionToCellRelationAnnotationMapMapDeserializer.class) - @JsonSerialize(keyUsing = RowPositionKeyJsonSerializer.class, contentUsing = ColumnPositionToColumnPositionToCellRelationAnnotationMapMapSerializer.class) + @JsonDeserialize(keyUsing = RowPositionKeyJsonDeserializer.class, + contentUsing = ColumnPositionToColumnPositionToCellRelationAnnotationMapMapDeserializer.class) + @JsonSerialize(keyUsing = RowPositionKeyJsonSerializer.class, + contentUsing = ColumnPositionToColumnPositionToCellRelationAnnotationMapMapSerializer.class) private Map>> cellRelationAnnotations; public ResultValue() { @@ -71,44 +77,70 @@ public ResultValue() { columnRelationAnnotations = ImmutableMap.of(); cellRelationAnnotations = ImmutableMap.of(); } - - /** - * @param subjectColumnPosition - * @param headerAnnotations - * @param cellAnnotations - * @param columnRelationAnnotations - * @param cellRelationAnnotations - */ + public ResultValue(Result adaptee) { subjectColumnPosition = adaptee.getSubjectColumnPosition(); headerAnnotations = adaptee.getHeaderAnnotations(); cellAnnotations = adaptee.getCellAnnotations(); - - final ImmutableMap.Builder> columnRelationAnnotationsBuilder = ImmutableMap.builder(); - for (final Map.Entry entry : adaptee.getColumnRelationAnnotations().entrySet()) { - final ColumnRelationPosition key = entry.getKey(); - final ColumnPosition firstColumn = key.getFirst(); - final ColumnPosition secondColumn = key.getSecond(); - final ColumnRelationAnnotation annotation = entry.getValue(); - - columnRelationAnnotationsBuilder.put(firstColumn, ImmutableMap.of(secondColumn, annotation)); - } - columnRelationAnnotations = columnRelationAnnotationsBuilder.build(); - - final ImmutableMap.Builder>> cellRelationAnnotationsBuilder = ImmutableMap.builder(); - for (final Map.Entry entry : adaptee.getCellRelationAnnotations().entrySet()) { + + initializeColumnRelationAnnotations(adaptee); + initializeCellRelationAnnotations(adaptee); + } + + private void initializeCellRelationAnnotations(Result adaptee) { + cellRelationAnnotations = new HashMap<>(); + for (final Map.Entry entry : adaptee + .getCellRelationAnnotations().entrySet()) { final CellRelationPosition key = entry.getKey(); final RowPosition row = key.getRowPosition(); final ColumnRelationPosition columns = key.getColumnsPosition(); - + final ColumnPosition firstColumn = columns.getFirst(); final ColumnPosition secondColumn = columns.getSecond(); - + final CellRelationAnnotation annotation = entry.getValue(); - - cellRelationAnnotationsBuilder.put(row, ImmutableMap.of(firstColumn, ImmutableMap.of(secondColumn, annotation))); + + final Map> subMap = + cellRelationAnnotations.get(row); + if (subMap == null) { + final Map newSubSubMap = + Maps.newHashMap(ImmutableMap.of(secondColumn, annotation)); + final Map> newSubMap = + new HashMap<>(); + newSubMap.put(firstColumn, newSubSubMap); + + cellRelationAnnotations.put(row, newSubMap); + } else { + final Map subSubMap = subMap.get(firstColumn); + if (subSubMap == null) { + final Map newSubSubMap = + Maps.newHashMap(ImmutableMap.of(secondColumn, annotation)); + subMap.put(firstColumn, newSubSubMap); + } else { + subSubMap.put(secondColumn, annotation); + } + } + } + } + + private void initializeColumnRelationAnnotations(Result adaptee) { + columnRelationAnnotations = new HashMap<>(); + for (final Map.Entry entry : adaptee + .getColumnRelationAnnotations().entrySet()) { + final ColumnRelationPosition key = entry.getKey(); + final ColumnPosition firstColumn = key.getFirst(); + final ColumnPosition secondColumn = key.getSecond(); + final ColumnRelationAnnotation annotation = entry.getValue(); + + final Map subMap = + columnRelationAnnotations.get(firstColumn); + if (subMap == null) { + columnRelationAnnotations.put(firstColumn, + new HashMap<>(ImmutableMap.of(secondColumn, annotation))); + } else { + subMap.put(secondColumn, annotation); + } } - cellRelationAnnotations = cellRelationAnnotationsBuilder.build(); } /** @@ -124,7 +156,7 @@ public ColumnPosition getSubjectColumnPosition() { */ public void setSubjectColumnPosition(ColumnPosition subjectColumnPosition) { Preconditions.checkNotNull(subjectColumnPosition); - + this.subjectColumnPosition = subjectColumnPosition; } @@ -140,7 +172,7 @@ public List getHeaderAnnotations() { */ public void setHeaderAnnotations(List headerAnnotations) { Preconditions.checkNotNull(headerAnnotations); - + this.headerAnnotations = ImmutableList.copyOf(headerAnnotations); } @@ -156,8 +188,9 @@ public CellAnnotation[][] getCellAnnotations() { */ public void setCellAnnotations(CellAnnotation[][] cellAnnotations) { Preconditions.checkNotNull(cellAnnotations); - - this.cellAnnotations = cz.cuni.mff.xrg.odalic.util.Arrays.deepCopy(CellAnnotation.class, cellAnnotations); + + this.cellAnnotations = + cz.cuni.mff.xrg.odalic.util.Arrays.deepCopy(CellAnnotation.class, cellAnnotations); } /** @@ -172,8 +205,10 @@ public Map> getCol */ public void setColumnRelationAnnotations( Map> columnRelationAnnotations) { - final ImmutableMap.Builder> columnRelationAnnotationsBuilder = ImmutableMap.builder(); - for (final Map.Entry> entry : columnRelationAnnotations.entrySet()) { + final ImmutableMap.Builder> columnRelationAnnotationsBuilder = + ImmutableMap.builder(); + for (final Map.Entry> entry : columnRelationAnnotations + .entrySet()) { columnRelationAnnotationsBuilder.put(entry.getKey(), ImmutableMap.copyOf(entry.getValue())); } this.columnRelationAnnotations = columnRelationAnnotationsBuilder.build(); @@ -191,19 +226,25 @@ public Map>> cellRelationAnnotations) { - final ImmutableMap.Builder>> cellRelationAnnotationsBuilder = ImmutableMap.builder(); - for (final Map.Entry>> entry : cellRelationAnnotations.entrySet()) { - final ImmutableMap.Builder> innerMapBuilder = ImmutableMap.builder(); - for (final Map.Entry> innerEntry : entry.getValue().entrySet()) { + final ImmutableMap.Builder>> cellRelationAnnotationsBuilder = + ImmutableMap.builder(); + for (final Map.Entry>> entry : cellRelationAnnotations + .entrySet()) { + final ImmutableMap.Builder> innerMapBuilder = + ImmutableMap.builder(); + for (final Map.Entry> innerEntry : entry + .getValue().entrySet()) { innerMapBuilder.put(innerEntry.getKey(), ImmutableMap.copyOf(innerEntry.getValue())); } - + cellRelationAnnotationsBuilder.put(entry.getKey(), innerMapBuilder.build()); } this.cellRelationAnnotations = cellRelationAnnotationsBuilder.build(); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override @@ -212,5 +253,5 @@ public String toString() { + headerAnnotations + ", cellAnnotations=" + Arrays.toString(cellAnnotations) + ", columnRelationAnnotations=" + columnRelationAnnotations + ", cellRelationAnnotations=" + cellRelationAnnotations + "]"; - } + } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/EntityCandidate.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/EntityCandidate.java index 86e96829..06707c2a 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/EntityCandidate.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/EntityCandidate.java @@ -99,7 +99,7 @@ public boolean equals(Object obj) { } /** - * Entity candidates are naturally ordered by their likelihood in ascending order. In case of the + * Entity candidates are naturally ordered by their likelihood in descending order. In case of the * equal likelihood the natural ordering of entities is taken into account. * * @see java.lang.Comparable#compareTo(java.lang.Object) @@ -109,7 +109,7 @@ public int compareTo(EntityCandidate o) { final int likelihoodComparison = likelihood.compareTo(o.likelihood); if (likelihoodComparison == 0) { - return entity.compareTo(o.entity); + return -entity.compareTo(o.entity); } else { return likelihoodComparison; } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Likelihood.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Likelihood.java index 0dc5081d..fa73ebd7 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Likelihood.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Likelihood.java @@ -10,7 +10,7 @@ import cz.cuni.mff.xrg.odalic.api.rest.adapters.LikelihoodAdapter; /** - * Probability based score value for annotation. + * Score value for annotation. * * @author Václav Brodec * From bbba9185ebcffad2e34aa0de652f160c5453cd70 Mon Sep 17 00:00:00 2001 From: brodecva Date: Wed, 6 Jul 2016 10:54:15 +0200 Subject: [PATCH 051/211] Ascending order candidate fix. --- .../mff/xrg/odalic/tasks/annotations/EntityCandidate.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/EntityCandidate.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/EntityCandidate.java index 06707c2a..86e96829 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/EntityCandidate.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/EntityCandidate.java @@ -99,7 +99,7 @@ public boolean equals(Object obj) { } /** - * Entity candidates are naturally ordered by their likelihood in descending order. In case of the + * Entity candidates are naturally ordered by their likelihood in ascending order. In case of the * equal likelihood the natural ordering of entities is taken into account. * * @see java.lang.Comparable#compareTo(java.lang.Object) @@ -109,7 +109,7 @@ public int compareTo(EntityCandidate o) { final int likelihoodComparison = likelihood.compareTo(o.likelihood); if (likelihoodComparison == 0) { - return -entity.compareTo(o.entity); + return entity.compareTo(o.entity); } else { return likelihoodComparison; } From fbad19b30a5f4cd587858cd421e1387f332eb172 Mon Sep 17 00:00:00 2001 From: JanVana Date: Tue, 19 Jul 2016 18:57:30 +0200 Subject: [PATCH 052/211] #6, #74, #80 - First iteration --- odalic/pom.xml | 8 ++ .../feedbacks/input/CsvConfiguration.java | 115 ++++++++++++++++++ .../input/DefaultCsvInputParser.java | 57 ++++++++- .../input/DefaultInputToTableAdapter.java | 35 +++++- .../input/DefaultTableToInputAdapter.java | 21 +++- .../mff/xrg/odalic/feedbacks/input/Input.java | 3 +- .../odalic/feedbacks/input/InputParser.java | 4 +- .../odalic/feedbacks/input/SimpleInput.java | 88 ++++++-------- .../feedbacks/MemoryOnlyFeedbackService.java | 2 +- 9 files changed, 268 insertions(+), 65 deletions(-) create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/CsvConfiguration.java diff --git a/odalic/pom.xml b/odalic/pom.xml index 6f7c81fe..fb1de139 100644 --- a/odalic/pom.xml +++ b/odalic/pom.xml @@ -132,6 +132,14 @@ jcl-over-slf4j ${jcloverslf4j.version} + + + + org.apache.commons + commons-csv + 1.4 + + diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/CsvConfiguration.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/CsvConfiguration.java new file mode 100644 index 00000000..938e9a3e --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/CsvConfiguration.java @@ -0,0 +1,115 @@ +package cz.cuni.mff.xrg.odalic.feedbacks.input; + +import org.apache.commons.csv.CSVFormat; + +/** + * Created by Jan on 17.07.2016. + */ +public class CsvConfiguration { + public String getEncoding() { + return encoding; + } + + public void setEncoding(String encoding) { + this.encoding = encoding; + } + + public char getDelimiter() { + return delimiter; + } + + public void setDelimiter(char delimiter) { + this.delimiter = delimiter; + } + + public boolean isHasHeader() { + return hasHeader; + } + + public void setHasHeader(boolean hasHeader) { + this.hasHeader = hasHeader; + } + + public boolean isIgnoreEmptyLines() { + return ignoreEmptyLines; + } + + public void setIgnoreEmptyLines(boolean ignoreEmptyLines) { + this.ignoreEmptyLines = ignoreEmptyLines; + } + + public boolean isIgnoreHeaderCase() { + return ignoreHeaderCase; + } + + public void setIgnoreHeaderCase(boolean ignoreHeaderCase) { + this.ignoreHeaderCase = ignoreHeaderCase; + } + + public Character getQuoteCharacter() { + return quoteCharacter; + } + + public void setQuoteCharacter(Character quoteCharacter) { + this.quoteCharacter = quoteCharacter; + } + + public Character getEscapeCharacter() { + return escapeCharacter; + } + + public void setEscapeCharacter(Character escapeCharacter) { + this.escapeCharacter = escapeCharacter; + } + + public Character getCommentMarker() { + return commentMarker; + } + + public void setCommentMarker(Character commentMarker) { + this.commentMarker = commentMarker; + } + + private String encoding; + private char delimiter; + private boolean hasHeader; + private boolean ignoreEmptyLines; + private boolean ignoreHeaderCase; + private Character quoteCharacter; + private Character escapeCharacter; + private Character commentMarker; + + public CsvConfiguration() { + delimiter = ';'; + hasHeader = true; + ignoreHeaderCase = false; + ignoreEmptyLines = true; + encoding = "UTF-8"; + } + + CSVFormat toApacheConfiguration() { + CSVFormat format = CSVFormat + .newFormat(delimiter) + .withAllowMissingColumnNames() + .withIgnoreEmptyLines(ignoreEmptyLines) + .withIgnoreHeaderCase(ignoreHeaderCase); + + if (quoteCharacter != null) { + format = format.withQuote(quoteCharacter); + } + + if (hasHeader) { + format = format.withHeader(); + } + + if (escapeCharacter != null) { + format = format.withEscape(escapeCharacter); + } + + if (commentMarker != null) { + format = format.withCommentMarker(commentMarker); + } + + return format; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultCsvInputParser.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultCsvInputParser.java index e672e205..37e88f3c 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultCsvInputParser.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultCsvInputParser.java @@ -1,12 +1,61 @@ package cz.cuni.mff.xrg.odalic.feedbacks.input; +import org.apache.commons.csv.CSVFormat; +import org.apache.commons.csv.CSVParser; +import org.apache.commons.csv.CSVRecord; +import sun.java2d.pipe.SpanShapeRenderer; + +import java.io.*; +import java.util.Map; + public class DefaultCsvInputParser implements InputParser { @Override - public Input parse(String content) { - // TODO: Provide implementation. Probably using the extractor. - return null; + public Input parse(String content, String fileIdentifier) throws IOException { + CsvConfiguration defaultConfiguration = new CsvConfiguration(); + + try (Reader reader = new StringReader(content)) { + return parse(reader, defaultConfiguration, fileIdentifier); + } + } + + public Input parse(InputStream stream, CsvConfiguration configuration, String fileIdentifier) throws IOException { + try (Reader reader = new InputStreamReader(stream, configuration.getEncoding())) { + return parse(reader, configuration, fileIdentifier); + } + } + + public Input parse(Reader reader, CsvConfiguration configuration, String fileIdentifier) throws IOException { + CSVFormat format = configuration.toApacheConfiguration(); + CSVParser parser = format.parse(reader); + + SimpleInput result = new SimpleInput(fileIdentifier); + HandleHeaders(result, parser); + + int row = 0; + + for(CSVRecord record : parser) { + HandleInputRow(result, record, row); + row++; + } + + return result; + } + + private void HandleInputRow(SimpleInput input, CSVRecord row, int rowIndex) { + int column = 0; + + for (String value : row) { + input.insertCell(value, rowIndex, column); + column++; + } } - + private void HandleHeaders(SimpleInput input, CSVParser parser) { + Map headerMap = parser.getHeaderMap(); + + for(Map.Entry headerEntry : headerMap.entrySet()) { + input.insertHeader(headerEntry.getKey(), headerEntry.getValue()); + } + } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultInputToTableAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultInputToTableAdapter.java index c7c5c579..5c1cadfb 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultInputToTableAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultInputToTableAdapter.java @@ -1,13 +1,44 @@ package cz.cuni.mff.xrg.odalic.feedbacks.input; +import com.sun.syndication.feed.rss.Guid; +import uk.ac.shef.dcs.sti.core.model.TCell; +import uk.ac.shef.dcs.sti.core.model.TColumnHeader; import uk.ac.shef.dcs.sti.core.model.Table; +import java.util.List; +import java.util.UUID; + public class DefaultInputToTableAdapter implements InputToTableAdapter { @Override public Table toTable(Input input) { - // TODO: Provide implementation. - return null; + Table result = new Table( + UUID.randomUUID().toString(), + input.fileIdentifier(), + input.rowsCount(), + input.columnsCount()); + + int columnIndex = 0; + for (String value : input.headers()) { + TColumnHeader header = new TColumnHeader(value); + result.setColumnHeader(columnIndex, header); + + columnIndex++; + } + + int rowIndex = 0; + for (List row : input.rows()) { + columnIndex = 0; + for (String value : row) { + TCell cell = new TCell(value); + result.setContentCell(rowIndex, columnIndex, cell); + + columnIndex++; + } + rowIndex++; + } + + return result; } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultTableToInputAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultTableToInputAdapter.java index 5fbc934d..61f1312d 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultTableToInputAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultTableToInputAdapter.java @@ -1,13 +1,30 @@ package cz.cuni.mff.xrg.odalic.feedbacks.input; +import uk.ac.shef.dcs.sti.core.model.TCell; +import uk.ac.shef.dcs.sti.core.model.TColumnHeader; import uk.ac.shef.dcs.sti.core.model.Table; +import java.util.List; + public class DefaultTableToInputAdapter implements TableToInputAdapter { @Override public Input toInput(Table table) { - // TODO: Provide implementation. - return null; + SimpleInput result = new SimpleInput(table.getSourceId()); + + for (int columnIndex = 0; columnIndex < table.getNumHeaders(); columnIndex++) { + TColumnHeader header = table.getColumnHeader(columnIndex); + result.insertHeader(header.getHeaderText(), columnIndex); + } + + for (int columnIndex = 0; columnIndex < table.getNumCols(); columnIndex++) { + for (int rowIndex = 0; rowIndex < table.getNumRows(); rowIndex++) { + TCell cell = table.getContentCell(rowIndex, columnIndex); + result.insertCell(cell.getText(), rowIndex, columnIndex); + } + } + + return result; } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/Input.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/Input.java index 7fac64dc..f569077a 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/Input.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/Input.java @@ -16,10 +16,9 @@ public interface Input { String at(CellPosition position); String headerAt(ColumnPosition position); List rowAt(RowPosition position); - List columnAt(ColumnPosition position); int rowsCount(); int columnsCount(); List headers(); List> rows(); - List> columns(); + String fileIdentifier(); } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputParser.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputParser.java index 5e10374f..3f4d84bd 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputParser.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputParser.java @@ -1,5 +1,7 @@ package cz.cuni.mff.xrg.odalic.feedbacks.input; +import java.io.IOException; + /** * Input parser. * @@ -7,5 +9,5 @@ * */ public interface InputParser { - Input parse(String content); + Input parse(String content, String fileIdentifier) throws IOException; } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/SimpleInput.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/SimpleInput.java index a308c973..28dc3baa 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/SimpleInput.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/SimpleInput.java @@ -1,6 +1,8 @@ package cz.cuni.mff.xrg.odalic.feedbacks.input; import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; import javax.xml.bind.annotation.XmlElement; @@ -18,51 +20,21 @@ public class SimpleInput implements Input, Serializable { private static final long serialVersionUID = 4101912998363935336L; - + @XmlElement - private final List headers; - + private final List> rows = new ArrayList<>(); @XmlElement - private final String[][] content; - - @SuppressWarnings("unused") - private SimpleInput() { - headers = ImmutableList.of(); - content = new String[0][0]; - } - - /** - * @param headers - * @param content - */ - public SimpleInput(List headers, String[][] content) { - Preconditions.checkNotNull(headers); - Preconditions.checkNotNull(content); - - Preconditions.checkArgument(!Arrays.containsNull(content)); - Preconditions.checkArgument(Arrays.isMatrix(content)); - - this.headers = ImmutableList.copyOf(headers); - this.content = Arrays.deepCopy(String.class, content); - } - - /** - * @return the headers - */ - public List getHeaders() { - return headers; - } + private final List headers = new ArrayList<>(); + @XmlElement + private final String fileIdentifier; - /** - * @return the content - */ - public String[][] getContent() { - return Arrays.deepCopy(String.class, content); + public SimpleInput(String fileIdentifier) { + this.fileIdentifier = fileIdentifier; } @Override public String at(CellPosition position) { - return content[position.getRowIndex()][position.getColumnIndex()]; + return rows.get(position.getRowIndex()).get(position.getColumnIndex()); } @Override @@ -70,9 +42,14 @@ public String headerAt(ColumnPosition position) { return headers.get(position.getIndex()); } + @Override + public List rowAt(RowPosition position) { + return rows.get(position.getIndex()); + } + @Override public int rowsCount() { - return content.length; + return rows.size(); } @Override @@ -86,27 +63,32 @@ public List headers() { } @Override - public List rowAt(RowPosition position) { - // TODO Auto-generated method stub - return null; + public List> rows() { + return rows; } @Override - public List columnAt(ColumnPosition position) { - // TODO Auto-generated method stub - return null; + public String fileIdentifier() { + return fileIdentifier; } - @Override - public List> rows() { - // TODO Auto-generated method stub - return null; + void insertCell(String value, int rowIndex, int columnIndex) { + while (rows.size() <= rowIndex) { + rows.add(new ArrayList<>()); + } + + insertToList(rows.get(rowIndex), value, columnIndex); } - @Override - public List> columns() { - // TODO Auto-generated method stub - return null; + void insertHeader(String value, int position) { + insertToList(headers, value, position); } + private void insertToList(List list, String value, int position){ + while (list.size() <= position) { + list.add(null); + } + + list.set(position, value); + } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/MemoryOnlyFeedbackService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/MemoryOnlyFeedbackService.java index d4a9cd37..fbb1d9fe 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/MemoryOnlyFeedbackService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/MemoryOnlyFeedbackService.java @@ -56,6 +56,6 @@ public Input getInputForTaskId(String taskId) throws IOException { final File file = configuration.getInput(); final String data = fileService.getDataById(file.getId()); - return inputParser.parse(data); + return inputParser.parse(data, file.getId()); } } From 35098f1d59144bfc5d5ea4aac8b34dda7f1eee25 Mon Sep 17 00:00:00 2001 From: Tomas Knap Date: Wed, 20 Jul 2016 13:08:45 +0200 Subject: [PATCH 053/211] Added dependency needed to build the project --- odalic/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/odalic/pom.xml b/odalic/pom.xml index 6f7c81fe..3bd8fec3 100644 --- a/odalic/pom.xml +++ b/odalic/pom.xml @@ -132,6 +132,11 @@ jcl-over-slf4j ${jcloverslf4j.version} + + javax.ws.rs + jsr311-api + 1.1.1 + From c039c020a7bc2e374f3aebcbcb48808b81f61b2f Mon Sep 17 00:00:00 2001 From: Tomas Knap Date: Wed, 20 Jul 2016 13:16:58 +0200 Subject: [PATCH 054/211] Adjusted kbsearch implementation - refactoring --- .../uk/ac/shef/dcs/kbsearch/KBSearch.java | 82 +++++++--- .../dcs/kbsearch/KBSearchResultFilter.java | 66 +++++++- .../dcs/kbsearch/freebase/FreebaseSearch.java | 49 +----- .../freebase/FreebaseSearchResultFilter.java | 52 +------ .../dcs/kbsearch/sparql/DBpediaAttribute.java | 3 + .../shef/dcs/kbsearch/sparql/DBpediaEnum.java | 2 + .../dcs/kbsearch/sparql/DBpediaSearch.java | 146 ++++++------------ .../sparql/DBpediaSearchResultFilter.java | 51 ------ .../dcs/kbsearch/sparql/SPARQLSearch.java | 51 +++--- 9 files changed, 199 insertions(+), 303 deletions(-) diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearch.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearch.java index f3a94c7b..151392bd 100644 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearch.java +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearch.java @@ -1,5 +1,6 @@ package uk.ac.shef.dcs.kbsearch; +import org.apache.log4j.Logger; import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; import uk.ac.shef.dcs.kbsearch.model.Attribute; import uk.ac.shef.dcs.kbsearch.model.Clazz; @@ -20,16 +21,16 @@ public abstract class KBSearch { protected SolrCache cacheConcept; protected SolrCache cacheProperty; protected SolrCache cacheSimilarity; - protected Map otherCache; protected boolean fuzzyKeywords; protected static final String KB_SEARCH_RESULT_STOPLIST="kb.search.result.stoplistfile"; protected static final String KB_SEARCH_CLASS = "kb.search.class"; protected static final String KB_SEARCH_TRY_FUZZY_KEYWORD = "kb.search.tryfuzzykeyword"; - protected KBSearchResultFilter resultFilter; + private static final Logger LOG = Logger.getLogger(KBSearch.class.getName()); + /** * * @param fuzzyKeywords given a query string, kbsearch will firstly try to fetch results matching the exact query. when no match is @@ -57,21 +58,10 @@ public KBSearch(Boolean fuzzyKeywords, } - /** - * If any other cache is needed you may add them here - * @param name - * @param cacheServer - */ - public void registerOtherCache(String name, EmbeddedSolrServer cacheServer) { - otherCache.put(name, new SolrCache(cacheServer)); - } - - public KBSearchResultFilter getResultFilter(){ - return resultFilter; - } /** - * given a string, fetch candidate entities from a KB + * Given a string, fetch candidate entities (resources) from the KB + * Candidate entities are those resources for which label or part of the label matches the given content * @param content * @return * @throws IOException @@ -79,7 +69,7 @@ public KBSearchResultFilter getResultFilter(){ public abstract List findEntityCandidates(String content) throws KBSearchException; /** - * given a string fetch candidate entities that only match certain types from a KB + * Given a string, fetch candidate entities (resources) from the KB that only match certain types * @param content * @param types * @return @@ -88,7 +78,10 @@ public KBSearchResultFilter getResultFilter(){ public abstract List findEntityCandidatesOfTypes(String content, String... types) throws KBSearchException; /** - * get attributes of the entity candidate + * Get attributes of the entity candidate + * (all predicates and object values of the triples where the candidate entity is the subject). + * + * Note: Certain predicates may be blacklisted. * @throws KBSearchException */ public abstract List findAttributesOfEntities(Entity ec) throws KBSearchException; @@ -112,7 +105,9 @@ public KBSearchResultFilter getResultFilter(){ * @return the granularity of the class in the KB. * @throws KBSearchException if the method is not supported */ - public abstract double findGranularityOfClazz(String clazz) throws KBSearchException; + public double findGranularityOfClazz(String clazz) throws KBSearchException { + return 0; + } /** * compute the seamntic similarity between an entity and a class @@ -121,7 +116,9 @@ public KBSearchResultFilter getResultFilter(){ * @return * @throws KBSearchException */ - public abstract double findEntityClazzSimilarity(String entity_id, String clazz_url) throws KBSearchException; + public double findEntityClazzSimilarity(String entity_id, String clazz_url) throws KBSearchException { + return 0; + } /** * save the computed semantic similarity between the entity and class @@ -132,14 +129,53 @@ public KBSearchResultFilter getResultFilter(){ * @param commit * @throws KBSearchException */ - public abstract void cacheEntityClazzSimilarity(String entity_id, String clazz_url, double score, boolean biDirectional, - boolean commit) throws KBSearchException; + public void cacheEntityClazzSimilarity(String entity_id, String clazz_url, double score, boolean biDirectional, + boolean commit) throws KBSearchException { + String query = createSolrCacheQuery_findEntityClazzSimilarity(entity_id, clazz_url); + try { + cacheSimilarity.cache(query, score, commit); + LOG.debug("QUERY (entity-clazz similarity, cache saving)=" + query + "|" + query); + if (biDirectional) { + query = clazz_url + "<>" + entity_id; + cacheSimilarity.cache(query, score, commit); + LOG.debug("QUERY (entity-clazz similarity, cache saving)=" + query + "|" + query); + } + } catch (Exception e) { + LOG.error(e.getLocalizedMessage(), e); + } + } + + public void commitChanges() throws KBSearchException { + + try { + cacheConcept.commit(); + cacheEntity.commit(); + cacheProperty.commit(); + } catch (Exception e) { + throw new KBSearchException(e); + } + } - public abstract void commitChanges() throws KBSearchException; - public abstract void closeConnection() throws KBSearchException; + + public void closeConnection() throws KBSearchException { + + try { + if (cacheEntity != null) + cacheEntity.shutdown(); + if (cacheConcept != null) + cacheConcept.shutdown(); + if (cacheProperty != null) { + cacheProperty.shutdown(); + } + } catch (Exception e) { + throw new KBSearchException(e); + } + + } + //TODO the properties below should be moved to a different class (SolrCacheHelper?) and renamed properly /* createSolrCacheQuery_XXX defines how a solr query should be constructed. If your implementing class want to benefit from solr cache, you should call these methods to generate a query string, which will diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchResultFilter.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchResultFilter.java index ab30653e..c7504c53 100644 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchResultFilter.java +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchResultFilter.java @@ -26,8 +26,11 @@ public KBSearchResultFilter(String stoplistsFile) throws IOException { } /** - * an external file defining class/relation/entities to be filtered. the file must correspond to certain format. + * An external file defining class/relation/entities to be filtered. the file must correspond to certain format. * See 'resources/kbstoplist.txt' for explanation + * + * It loads all given classes/relations/entities to a Map, which contains as the key for the set of stop wrods the label obtained from the file (from the line starting with !). + * So there are different stop words for attributes and classes, e.g. * @param stoplistsFile * @throws IOException */ @@ -55,16 +58,67 @@ protected void loadStoplists(String stoplistsFile) throws IOException { stoplists.put(label, elements); } - public abstract List filterClazz(Collection types); + public List filterClazz(Collection types) { + List r = new ArrayList<>(); + for (Clazz t : types) { + if (isValidClazz(t)) { + r.add(t); + } + } + return r; + } + + /** + * Checks whether the class is valid class. Class is valid if it is not blacklisted. + * @param c + * @return true if the class is valid + */ + protected boolean isValidClazz(Clazz c) { + + Set stop = stoplists.get(LABEL_INVALID_CLAZZ); + if (stop == null) + return true; + + for (String s : stop) { + if (c.getId().contains(s) || c.getLabel().equalsIgnoreCase(s)) + return false; + } + return true; + + } - public abstract boolean isValidClazz(Clazz c); /** - * remove any attributes that contain an invalid relation + * Creates new list of attributes, which contains only attributes which are valid. * @param facts * @return */ - public abstract List filterAttribute(Collection facts); + public List filterAttribute(Collection facts) { + List filteredList = new ArrayList<>(); + for (Attribute t : facts) { + if(isValidAttribute(t)) { + filteredList.add(t); + } + } + return filteredList; + } + + + /** + * Checks whether the attribute is valid attribute. Attribute is valid if it is not blacklisted. + * @param attribute + * @return true if the attribute is valid + */ + protected boolean isValidAttribute(Attribute attribute) { + Set stop = stoplists.get(LABEL_INVALID_ATTRIBUTE); + String relation = attribute.getRelationURI(); + if (stop != null) { + for (String s : stop) { + if (relation.startsWith(s)) + return false; + } + } + return true; + } - public abstract boolean isValidAttribute(Attribute attribute); } diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearch.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearch.java index a9739d45..7dff8b4c 100644 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearch.java +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearch.java @@ -34,7 +34,6 @@ public FreebaseSearch(Properties properties, Boolean fuzzyKeywords, EmbeddedSolrServer cacheProperty, EmbeddedSolrServer cacheSimilarity) throws IOException { super(fuzzyKeywords, cacheEntity, cacheConcept, cacheProperty,cacheSimilarity); searcher = new FreebaseQueryProxy(properties); - otherCache = new HashMap<>(); resultFilter = new FreebaseSearchResultFilter(properties.getProperty(KB_SEARCH_RESULT_STOPLIST)); } @@ -154,7 +153,7 @@ private List find_matchingEntitiesForTextAndType(String text, String... for (Entity ec : result) { id = id + ec.getId() + ","; //ec.setTypes(FreebaseSearchResultFilter.filterClazz(ec.getTypes())); - List filteredTypes = getResultFilter().filterClazz(ec.getTypes()); + List filteredTypes = resultFilter.filterClazz(ec.getTypes()); ec.clearTypes(); for (Clazz ft : filteredTypes) ec.addType(ft); @@ -239,7 +238,7 @@ public List findAttributesOfClazz(String clazz) throws KBSearchExcept } //filtering - attributes=getResultFilter().filterAttribute(attributes); + attributes=resultFilter.filterAttribute(attributes); return attributes; } @@ -279,6 +278,7 @@ public double findGranularityOfClazz(String clazz) throws KBSearchException { } + @Override public double findEntityClazzSimilarity(String id1, String clazz_url) { String query = createSolrCacheQuery_findEntityClazzSimilarity(id1, clazz_url); Object result = null; @@ -293,21 +293,6 @@ public double findEntityClazzSimilarity(String id1, String clazz_url) { return (Double) result; } - public void cacheEntityClazzSimilarity(String id1, String clazz_url, double score, boolean biDirectional, - boolean commit) { - String query = createSolrCacheQuery_findEntityClazzSimilarity(id1, clazz_url); - try { - cacheSimilarity.cache(query, score, commit); - LOG.debug("QUERY (entity-clazz similarity, cache saving)=" + query + "|" + query); - if (biDirectional) { - query = clazz_url + "<>" + id1; - cacheSimilarity.cache(query, score, commit); - LOG.debug("QUERY (entity-clazz similarity, cache saving)=" + query + "|" + query); - } - } catch (Exception e) { - e.printStackTrace(); - } - } @SuppressWarnings("unchecked") private List find_attributes(String id, SolrCache cache) throws KBSearchException { @@ -346,22 +331,10 @@ private List find_attributes(String id, SolrCache cache) throws KBSea } //filtering - result = getResultFilter().filterAttribute(result); + result = resultFilter.filterAttribute(result); return result; } - public void commitChanges() throws KBSearchException { - try { - cacheConcept.commit(); - cacheEntity.commit(); - cacheProperty.commit(); - for (SolrCache cache : otherCache.values()) - cache.commit(); - } catch (Exception e) { - throw new KBSearchException(e); - } - } - private boolean donotRepeatQuery(HttpResponseException e) { String message = e.getContent(); if (message.contains("\"reason\": \"notFound\"")) @@ -370,17 +343,5 @@ private boolean donotRepeatQuery(HttpResponseException e) { } - @Override - public void closeConnection() throws KBSearchException { - try { - if (cacheEntity != null) - cacheEntity.shutdown(); - if (cacheConcept != null) - cacheConcept.shutdown(); - if (cacheProperty != null) - cacheProperty.shutdown(); - } catch (Exception e) { - throw new KBSearchException(e); - } - } + } diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearchResultFilter.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearchResultFilter.java index fd60ad25..851cac69 100644 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearchResultFilter.java +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearchResultFilter.java @@ -20,53 +20,13 @@ public FreebaseSearchResultFilter(String stoplistsFile) throws IOException { super(stoplistsFile); } - public boolean isValidClazz(Clazz c) { - /*if (type.startsWith("/user/") || - type.startsWith("/common/")|| - //type.equals("/common/image") || - *//*type.equals("/type/content") || - type.startsWith("/type/type/domain")||*//* - type.startsWith("/type/")|| - type.endsWith("topic") || type.startsWith("/pipeline/") || - type.endsWith("skos_concept") || - type.endsWith("_instance") || - type.startsWith("/base/type_ontology") - ||label.equalsIgnoreCase("topic")||label.equalsIgnoreCase("thing")||label.equalsIgnoreCase("concept") - ||label.equalsIgnoreCase("things")||label.equalsIgnoreCase("entity")) - return true; - return false;*/ - Set stop = stoplists.get(LABEL_INVALID_CLAZZ); - if (stop == null) - return true; - - for (String s : stop) { - if (c.getId().contains(s) || c.getLabel().equalsIgnoreCase(s)) - return false; - } - return true; - - } - - public List filterClazz(Collection types) { - List r = new ArrayList<>(); - /*if(types==null) - System.out.println();*/ - for (Clazz t : types) { - if (!isValidClazz(t)) continue; - r.add(t); - } - return r; - } - - public List filterAttribute(Collection facts) { - List r = new ArrayList<>(); - for (Attribute t : facts) { - if(!isValidAttribute(t)) continue; - r.add(t); - } - return r; - } + /** + * Provides + * @param attribute + * @return + */ + @Override public boolean isValidAttribute(Attribute attribute) { //here is a list of 'pass' relations that should always be kept as the stoplist can be over-generalising String rel = attribute.getRelationURI(); diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaAttribute.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaAttribute.java index 62ffe138..773c6c63 100644 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaAttribute.java +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaAttribute.java @@ -4,6 +4,9 @@ /** * Created by - on 10/06/2016. + * + * TODO no need for this class, alias predicates, description predicates can be stored in config. + * */ public class DBpediaAttribute extends Attribute { diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaEnum.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaEnum.java index b7b3796b..cd5be1fb 100644 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaEnum.java +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaEnum.java @@ -2,6 +2,8 @@ /** * Created by - on 10/06/2016. + * + * */ public enum DBpediaEnum { diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearch.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearch.java index 24efcfc6..1473dcd7 100644 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearch.java +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearch.java @@ -53,7 +53,6 @@ public DBpediaSearch(Properties properties, String ontURL = properties.getProperty(DBP_ONTOLOGY_URL); if (ontURL != null) ontology = loadModel(ontURL); - otherCache = new HashMap<>(); resultFilter = new DBpediaSearchResultFilter(properties.getProperty(KB_SEARCH_RESULT_STOPLIST)); } @@ -66,10 +65,7 @@ private OntModel loadModel(String ontURL) { @Override @SuppressWarnings("unchecked") public List findEntityCandidates(String content) throws KBSearchException { - /*if(content.equals("Ramji Manjhi")) - System.out.println();*/ String query = createSolrCacheQuery_findResources(content); - boolean forceQuery = false; content = StringEscapeUtils.unescapeXml(content); int bracket = content.indexOf("("); @@ -78,17 +74,16 @@ public List findEntityCandidates(String content) throws KBSearchExceptio } if (StringUtils.toAlphaNumericWhitechar(content).trim().length() == 0) return new ArrayList<>(); - if (ALWAYS_CALL_REMOTE_SEARCHAPI) - forceQuery = true; List result = null; - if (!forceQuery) { + if (!ALWAYS_CALL_REMOTE_SEARCHAPI) { try { result = (List) cacheEntity.retrieve(query); if (result != null) LOG.debug("QUERY (entities, cache load)=" + query + "|" + query); } catch (Exception e) { + LOG.error(e.getLocalizedMessage(),e); } } if (result == null) { @@ -107,10 +102,9 @@ public List findEntityCandidates(String content) throws KBSearchExceptio //3. rank result by the degree of matches rank(queryResult, content); - //firstly fetch candidate freebase topics. pass 'true' to only keep candidates whose name overlap with the query term - LOG.debug("(DBpedia QUERY =" + queryResult.size() + " results)"); + //get attributes for each resource + LOG.debug("(QUERY =" + queryResult.size() + " results)"); for (Pair candidate : queryResult) { - //Next get attributes for each topic String label = candidate.getValue(); if (label == null) label = content; @@ -118,7 +112,7 @@ public List findEntityCandidates(String content) throws KBSearchExceptio List attributes = findAttributesOfEntities(ec); ec.setAttributes(attributes); for (Attribute attr : attributes) { - resetResourceValue(attr); + adjustValueOfURLResource(attr); if (attr.getRelationURI().endsWith(RDFEnum.RELATION_HASTYPE_SUFFIX_PATTERN.getString()) && !ec.hasType(attr.getValueURI())) { ec.addType(new Clazz(attr.getValueURI(), attr.getValue())); @@ -139,7 +133,7 @@ public List findEntityCandidates(String content) throws KBSearchExceptio for (Entity ec : result) { id = id + ec.getId() + ","; //ec.setTypes(FreebaseSearchResultFilter.filterClazz(ec.getTypes())); - List filteredTypes = getResultFilter().filterClazz(ec.getTypes()); + List filteredTypes = resultFilter.filterClazz(ec.getTypes()); ec.clearTypes(); for (Clazz ft : filteredTypes) ec.addType(ft); @@ -152,7 +146,6 @@ public List findEntityCandidates(String content) throws KBSearchExceptio @SuppressWarnings("unchecked") public List findEntityCandidatesOfTypes(String content, String... types) throws KBSearchException { String queryCache = createSolrCacheQuery_findResources(content); - boolean forceQuery = false; content = StringEscapeUtils.unescapeXml(content); int bracket = content.indexOf("("); @@ -161,12 +154,10 @@ public List findEntityCandidatesOfTypes(String content, String... types) } if (StringUtils.toAlphaNumericWhitechar(content).trim().length() == 0) return new ArrayList<>(); - if (ALWAYS_CALL_REMOTE_SEARCHAPI) - forceQuery = true; List result = null; - if (!forceQuery) { + if (!ALWAYS_CALL_REMOTE_SEARCHAPI) { try { result = (List) cacheEntity.retrieve(queryCache); if (result != null) { @@ -188,6 +179,7 @@ public List findEntityCandidatesOfTypes(String content, String... types) } } } catch (Exception e) { + LOG.error(e.getLocalizedMessage(),e); } } if (result == null) { @@ -228,7 +220,7 @@ public List findEntityCandidatesOfTypes(String content, String... types) rank(queryResult, content); //firstly fetch candidate freebase topics. pass 'true' to only keep candidates whose name overlap with the query term - LOG.debug("(DBpedia QUERY =" + queryResult.size() + " results)"); + LOG.debug("(DB QUERY =" + queryResult.size() + " results)"); for (Pair candidate : queryResult) { //Next get attributes for each topic String label = candidate.getValue(); @@ -238,7 +230,7 @@ public List findEntityCandidatesOfTypes(String content, String... types) List attributes = findAttributesOfEntities(ec); ec.setAttributes(attributes); for (Attribute attr : attributes) { - resetResourceValue(attr); + adjustValueOfURLResource(attr); if (attr.getRelationURI().endsWith(RDFEnum.RELATION_HASTYPE_SUFFIX_PATTERN.getString()) && !ec.hasType(attr.getValueURI())) { ec.addType(new Clazz(attr.getValueURI(), attr.getValue())); @@ -259,7 +251,7 @@ public List findEntityCandidatesOfTypes(String content, String... types) for (Entity ec : result) { id = id + ec.getId() + ","; //ec.setTypes(FreebaseSearchResultFilter.filterClazz(ec.getTypes())); - List filteredTypes = getResultFilter().filterClazz(ec.getTypes()); + List filteredTypes = resultFilter.filterClazz(ec.getTypes()); ec.clearTypes(); for (Clazz ft : filteredTypes) ec.addType(ft); @@ -269,18 +261,14 @@ public List findEntityCandidatesOfTypes(String content, String... types) } // if the attribute's value is an URL, fetch the label of that resource, and reset its attr value - @SuppressWarnings("unchecked") - private void resetResourceValue(Attribute attr) throws KBSearchException { + private void adjustValueOfURLResource(Attribute attr) throws KBSearchException { String value = attr.getValue(); if (value.startsWith("http")) { String queryCache = createSolrCacheQuery_findLabelForResource(value); - boolean forceQuery = false; - if (ALWAYS_CALL_REMOTE_SEARCHAPI) - forceQuery = true; List result = null; - if (!forceQuery) { + if (!ALWAYS_CALL_REMOTE_SEARCHAPI) { try { result = (List) cacheEntity.retrieve(queryCache); if (result != null) { @@ -313,26 +301,26 @@ private void resetResourceValue(Attribute attr) throws KBSearchException { @Override public List findAttributesOfEntities(Entity ec) throws KBSearchException { - return find_attributes(ec.getId(), cacheEntity); + return findAttributes(ec.getId(), cacheEntity); } - @SuppressWarnings("unchecked") - private List find_attributes(String id, SolrCache cache) throws KBSearchException { + private List findAttributes(String id, SolrCache cache) throws KBSearchException { if (id.length() == 0) return new ArrayList<>(); - boolean forceQuery = false; - if (ALWAYS_CALL_REMOTE_SEARCHAPI) - forceQuery = true; String queryCache = createSolrCacheQuery_findAttributesOfResource(id); List result = null; - try { - result = (List) cache.retrieve(queryCache); - if (result != null) - LOG.debug("QUERY (attributes of id, cache load)=" + queryCache + "|" + queryCache); - } catch (Exception e) { + if (!ALWAYS_CALL_REMOTE_SEARCHAPI) { + try { + result = (List) cache.retrieve(queryCache); + if (result != null) + LOG.debug("QUERY (attributes of id, cache load)=" + queryCache + "|" + queryCache); + } catch (Exception e) { + LOG.error(e.getLocalizedMessage(), e); + } } - if (result == null || forceQuery) { + + if (result == null) { result = new ArrayList<>(); String query = "SELECT DISTINCT ?p ?o WHERE {\n" + "<" + id + "> ?p ?o .\n" + @@ -344,12 +332,10 @@ private List find_attributes(String id, SolrCache cache) throws KBSea ResultSet rs = qexec.execSelect(); while (rs.hasNext()) { QuerySolution qs = rs.next(); - RDFNode range = qs.get("?p"); - String r = range.toString(); - RDFNode domain = qs.get("?o"); - if (domain != null) { - String d = domain.toString(); - Attribute attr = new DBpediaAttribute(r, d); + RDFNode predicate = qs.get("?p"); + RDFNode object = qs.get("?o"); + if (object != null) { + Attribute attr = new DBpediaAttribute(predicate.toString(), object.toString()); result.add(attr); } } @@ -358,81 +344,39 @@ private List find_attributes(String id, SolrCache cache) throws KBSea cache.cache(queryCache, result, AUTO_COMMIT); LOG.debug("QUERY (attributes of id, cache save)=" + query + "|" + query); } catch (Exception e) { - e.printStackTrace(); + LOG.error(e.getLocalizedMessage(), e); } } //filtering - result = getResultFilter().filterAttribute(result); + result = resultFilter.filterAttribute(result); return result; } @Override public List findAttributesOfClazz(String clazzId) throws KBSearchException { - return find_attributes(clazzId, cacheEntity); + return findAttributes(clazzId, cacheEntity); } @Override public List findAttributesOfProperty(String propertyId) throws KBSearchException { - return find_attributes(propertyId, cacheEntity); + return findAttributes(propertyId, cacheEntity); } - @Override - public double findGranularityOfClazz(String clazz) throws KBSearchException { - if (ontology == null) - throw new KBSearchException("Not supported"); - return 0; - } +// @Override +// public double findGranularityOfClazz(String clazz) throws KBSearchException { +// if (ontology == null) +// throw new KBSearchException("Not supported"); +// return 0; +// } - @Override - public double findEntityClazzSimilarity(String entity_id, String clazz_url) throws KBSearchException { - if (ontology == null) - throw new KBSearchException("Not supported"); - return 0; - } +// @Override +// public double findEntityClazzSimilarity(String entity_id, String clazz_url) throws KBSearchException { +// if (ontology == null) +// throw new KBSearchException("Not supported"); +// return 0; +// } - @Override - public void cacheEntityClazzSimilarity(String entity_id, String clazz_url, double score, boolean biDirectional, boolean commit) throws KBSearchException { - String query = createSolrCacheQuery_findEntityClazzSimilarity(entity_id, clazz_url); - try { - cacheSimilarity.cache(query, score, commit); - LOG.debug("QUERY (entity-clazz similarity, cache saving)=" + query + "|" + query); - if (biDirectional) { - query = clazz_url + "<>" + entity_id; - cacheSimilarity.cache(query, score, commit); - LOG.debug("QUERY (entity-clazz similarity, cache saving)=" + query + "|" + query); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - public void commitChanges() throws KBSearchException { - try { - cacheConcept.commit(); - cacheEntity.commit(); - cacheProperty.commit(); - for (SolrCache cache : otherCache.values()) - cache.commit(); - } catch (Exception e) { - throw new KBSearchException(e); - } - } - - - @Override - public void closeConnection() throws KBSearchException { - try { - if (cacheEntity != null) - cacheEntity.shutdown(); - if (cacheConcept != null) - cacheConcept.shutdown(); - if (cacheProperty != null) - cacheProperty.shutdown(); - } catch (Exception e) { - throw new KBSearchException(e); - } - } protected String createSolrCacheQuery_findLabelForResource(String url) { return "LABEL_" + url; diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearchResultFilter.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearchResultFilter.java index 2abe7fc0..89eab2bc 100644 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearchResultFilter.java +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearchResultFilter.java @@ -19,56 +19,5 @@ public DBpediaSearchResultFilter(String property) throws IOException { super(property); } - @Override - public List filterClazz(Collection types) { - List r = new ArrayList<>(); - /*if(types==null) - System.out.println();*/ - for (Clazz t : types) { - if (!isValidClazz(t)) continue; - r.add(t); - } - return r; - } - - @Override - public boolean isValidClazz(Clazz c) { - Set stop = stoplists.get(LABEL_INVALID_CLAZZ); - if (stop == null) - return true; - - // TODO: How can ID be null?? - if (c.getId() == null) - return false; - - for (String s : stop) { - if (c.getId().contains(s) || c.getLabel().equalsIgnoreCase(s)) - return false; - } - return true; - } - @Override - public List filterAttribute(Collection facts) { - List r = new ArrayList<>(); - for (Attribute t : facts) { - if(!isValidAttribute(t)) continue; - r.add(t); - } - return r; - } - - @Override - public boolean isValidAttribute(Attribute attribute) { - Set stop = stoplists.get(LABEL_INVALID_ATTRIBUTE); - String relation =attribute.getRelationURI(); - if (stop != null) { - for (String s : stop) { - if (relation.startsWith(s)) - return false; - } - - } - return true; - } } diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLSearch.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLSearch.java index f7c9c2b7..5a0d4b15 100644 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLSearch.java +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLSearch.java @@ -55,30 +55,11 @@ public SPARQLSearch(String sparqlEndpoint, Boolean fuzzyKeywords, this.sparqlEndpoint=sparqlEndpoint; } - - /** - * SELECT DISTINCT ?s ?o - WHERE - { - { - ?s ?o . - ?o bif:contains "Ramji" - } - UNION - { - ?s ?o . - ?o bif:contains "Manjhi" - } - } - ORDER BY ?s - * @param content - * @return - */ protected String createRegexQuery(String content){ + //the query is using word boundary. Is it supported on all SPARQL endpoints? String query = "SELECT DISTINCT ?s ?o WHERE {"+ - "?s <"+RDFEnum.RELATION_HASLABEL.getString()+"> ?o . \n"+ - //"?o bif:contains \""+content+"\"}"; - "FILTER ( regex (str(?o), \"\\\\b"+content+"\\\\b\", \"i\") ) }"; + "?s <"+RDFEnum.RELATION_HASLABEL.getString()+"> ?o ."+ + "FILTER ( regex (str(?o), \"\\b"+content+"\\b\", \"i\") ) }"; return query; } @@ -123,7 +104,12 @@ protected String createGetLabelQuery(String content){ } - + /** + * + * @param sparqlQuery + * @param string + * @return + */ protected List> queryByLabel(String sparqlQuery, String string){ org.apache.jena.query.Query query = QueryFactory.create(sparqlQuery); QueryExecution qexec = QueryExecutionFactory.sparqlService(sparqlEndpoint, query); @@ -131,16 +117,11 @@ protected List> queryByLabel(String sparqlQuery, String str List> out = new ArrayList<>(); ResultSet rs = qexec.execSelect(); while(rs.hasNext()){ + QuerySolution qs = rs.next(); - RDFNode range = qs.get("?s"); - String r = range.toString(); - RDFNode domain = qs.get("?o"); - String d=null; - if(domain!=null) - d=domain.toString(); - if(d==null) - d=string; - out.add(new Pair<>(r,d)); + RDFNode subject = qs.get("?s"); + RDFNode object = qs.get("?o"); + out.add(new Pair<>(subject.toString(), object!=null ? object.toString() : string)); } return out; } @@ -148,6 +129,12 @@ protected List> queryByLabel(String sparqlQuery, String str protected abstract List queryForLabel(String sparqlQuery, String resourceURI) throws KBSearchException; + /** + * Compares the similarity of the object value of certain resource (entity) and the cell value text (original label). + * Then, it also sorts the list of candidates based on the scores. + * @param candidates + * @param originalQueryLabel + */ protected void rank(List> candidates, String originalQueryLabel){ final Map, Double> scores = new HashMap<>(); for(Pair p : candidates){ From d1af01f5a605625b4bcc8d05ff9cef8af701b29a Mon Sep 17 00:00:00 2001 From: brodecva Date: Thu, 21 Jul 2016 15:04:59 +0200 Subject: [PATCH 055/211] Cleaning-up of the merged CSV parsing code. --- .../input/DefaultCsvInputParser.java | 2 - .../input/DefaultInputToTableAdapter.java | 1 - .../input/DefaultTableToInputAdapter.java | 2 - .../odalic/feedbacks/input/SimpleInput.java | 5 - pom.xml | 151 ++++++++++++++++++ 5 files changed, 151 insertions(+), 10 deletions(-) create mode 100644 pom.xml diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultCsvInputParser.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultCsvInputParser.java index 37e88f3c..55ccbe24 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultCsvInputParser.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultCsvInputParser.java @@ -3,8 +3,6 @@ import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVRecord; -import sun.java2d.pipe.SpanShapeRenderer; - import java.io.*; import java.util.Map; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultInputToTableAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultInputToTableAdapter.java index 5c1cadfb..1add9f11 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultInputToTableAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultInputToTableAdapter.java @@ -1,6 +1,5 @@ package cz.cuni.mff.xrg.odalic.feedbacks.input; -import com.sun.syndication.feed.rss.Guid; import uk.ac.shef.dcs.sti.core.model.TCell; import uk.ac.shef.dcs.sti.core.model.TColumnHeader; import uk.ac.shef.dcs.sti.core.model.Table; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultTableToInputAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultTableToInputAdapter.java index 61f1312d..e039a704 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultTableToInputAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultTableToInputAdapter.java @@ -4,8 +4,6 @@ import uk.ac.shef.dcs.sti.core.model.TColumnHeader; import uk.ac.shef.dcs.sti.core.model.Table; -import java.util.List; - public class DefaultTableToInputAdapter implements TableToInputAdapter { @Override diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/SimpleInput.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/SimpleInput.java index 28dc3baa..7bb34809 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/SimpleInput.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/SimpleInput.java @@ -2,19 +2,14 @@ import java.io.Serializable; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableList; - import cz.cuni.mff.xrg.odalic.positions.CellPosition; import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; import cz.cuni.mff.xrg.odalic.positions.RowPosition; -import cz.cuni.mff.xrg.odalic.util.Arrays; @XmlRootElement(name = "input") public class SimpleInput implements Input, Serializable { diff --git a/pom.xml b/pom.xml new file mode 100644 index 00000000..debd5432 --- /dev/null +++ b/pom.xml @@ -0,0 +1,151 @@ + + 4.0.0 + cz.cuni.mff.xrg.odalic + odalic + 0.0.1-SNAPSHOT + war + Odalic + Odalic server + + + 1.8 + 1.7.21 + 2.23.1 + 1.1.7 + 4.3.0.RELEASE + + + + + Apache 2.0 + http://www.apache.org/licenses/LICENSE-2.0 + + + + + + maven2-repository.java.net + Java.net Repository for Maven + http://download.java.net/maven/2/ + + + + + + + uk.ac.shef.dcs + sti + 1.0 + + + guava-jdk5 + com.google.guava + + + + + + + com.google.guava + guava + 19.0 + + + + + org.glassfish.jersey.ext + jersey-spring3 + ${jersey.version} + + + org.springframework + spring-core + + + org.springframework + spring-web + + + org.springframework + spring-beans + + + + + org.glassfish.jersey.media + jersey-media-json-jackson + ${jersey.version} + + + org.glassfish.jersey.media + jersey-media-multipart + ${jersey.version} + + + org.glassfish.jersey.ext + jersey-entity-filtering + ${jersey.version} + + + + + org.springframework + spring-core + ${spring.version} + + + org.springframework + spring-context + ${spring.version} + + + commons-logging + commons-logging + + + + + org.springframework + spring-web + ${spring.version} + + + org.springframework + spring-tx + ${spring.version} + + + org.springframework + spring-aspects + ${spring.version} + + + + + ch.qos.logback + logback-classic + ${logback.version} + + + org.slf4j + jcl-over-slf4j + ${jcloverslf4j.version} + + + + + + + true + org.apache.maven.plugins + maven-compiler-plugin + + ${java.version} + ${java.version} + UTF-8 + + + + + \ No newline at end of file From 4db0428be67a7b9287e60323248877ac2045c8a7 Mon Sep 17 00:00:00 2001 From: brodecva Date: Mon, 25 Jul 2016 19:05:51 +0200 Subject: [PATCH 056/211] New CSV parser integration. --- .../feedbacks/input/CsvConfiguration.java | 341 ++++++++++++------ .../feedbacks/input/CsvInputParser.java | 22 ++ .../input/DefaultCsvInputParser.java | 65 ++-- .../input/DefaultInputToTableAdapter.java | 14 +- .../input/DefaultTableToInputAdapter.java | 28 -- .../mff/xrg/odalic/feedbacks/input/Input.java | 2 +- .../odalic/feedbacks/input/InputParser.java | 13 - .../feedbacks/input/InputToTableAdapter.java | 6 + ...SimpleInput.java => ListsBackedInput.java} | 56 +-- .../input/ListsBackedInputBuilder.java | 58 +++ .../feedbacks/input/TableToInputAdapter.java | 6 + .../input/TableToListsBackedInputAdapter.java | 48 +++ .../FutureBasedExecutionService.java | 38 +- .../feedbacks/MemoryOnlyFeedbackService.java | 10 +- 14 files changed, 485 insertions(+), 222 deletions(-) create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/CsvInputParser.java delete mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultTableToInputAdapter.java delete mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputParser.java rename odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/{SimpleInput.java => ListsBackedInput.java} (56%) create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/ListsBackedInputBuilder.java create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/TableToListsBackedInputAdapter.java diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/CsvConfiguration.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/CsvConfiguration.java index 938e9a3e..e88a023b 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/CsvConfiguration.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/CsvConfiguration.java @@ -1,115 +1,248 @@ package cz.cuni.mff.xrg.odalic.feedbacks.input; -import org.apache.commons.csv.CSVFormat; - -/** - * Created by Jan on 17.07.2016. - */ -public class CsvConfiguration { - public String getEncoding() { - return encoding; - } - - public void setEncoding(String encoding) { - this.encoding = encoding; - } - - public char getDelimiter() { - return delimiter; - } - - public void setDelimiter(char delimiter) { - this.delimiter = delimiter; - } - - public boolean isHasHeader() { - return hasHeader; - } - - public void setHasHeader(boolean hasHeader) { - this.hasHeader = hasHeader; - } +import java.io.Serializable; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; - public boolean isIgnoreEmptyLines() { - return ignoreEmptyLines; - } - - public void setIgnoreEmptyLines(boolean ignoreEmptyLines) { - this.ignoreEmptyLines = ignoreEmptyLines; - } - - public boolean isIgnoreHeaderCase() { - return ignoreHeaderCase; - } +import javax.annotation.Nullable; +import javax.annotation.concurrent.Immutable; - public void setIgnoreHeaderCase(boolean ignoreHeaderCase) { - this.ignoreHeaderCase = ignoreHeaderCase; - } - - public Character getQuoteCharacter() { - return quoteCharacter; - } - - public void setQuoteCharacter(Character quoteCharacter) { - this.quoteCharacter = quoteCharacter; - } - - public Character getEscapeCharacter() { - return escapeCharacter; - } - - public void setEscapeCharacter(Character escapeCharacter) { - this.escapeCharacter = escapeCharacter; - } - - public Character getCommentMarker() { - return commentMarker; - } - - public void setCommentMarker(Character commentMarker) { - this.commentMarker = commentMarker; - } - - private String encoding; - private char delimiter; - private boolean hasHeader; - private boolean ignoreEmptyLines; - private boolean ignoreHeaderCase; - private Character quoteCharacter; - private Character escapeCharacter; - private Character commentMarker; - - public CsvConfiguration() { - delimiter = ';'; - hasHeader = true; - ignoreHeaderCase = false; - ignoreEmptyLines = true; - encoding = "UTF-8"; - } +import org.apache.commons.csv.CSVFormat; - CSVFormat toApacheConfiguration() { - CSVFormat format = CSVFormat - .newFormat(delimiter) - .withAllowMissingColumnNames() - .withIgnoreEmptyLines(ignoreEmptyLines) - .withIgnoreHeaderCase(ignoreHeaderCase); +import com.google.common.base.Preconditions; - if (quoteCharacter != null) { - format = format.withQuote(quoteCharacter); - } +/** + * Configuration of the CSV file for the parser. + * + * @author Jan Váňa + * @author Václav Brodec + */ +@Immutable +public final class CsvConfiguration implements Serializable { + + private static final long serialVersionUID = 5335583951933923025L; + + private final Charset charset; + private final char delimiter; + private final boolean headerPresent; + private final boolean emptyLinesIgnored; + private final boolean headerCaseIgnored; + private final Character quoteCharacter; + private final Character escapeCharacter; + private final Character commentMarker; + + + public CsvConfiguration(Charset charset, char delimiter, boolean headerPresent, + boolean emptyLinesIgnored, boolean headerCaseIgnored, @Nullable Character quoteCharacter, + @Nullable Character escapeCharacter, @Nullable Character commentMarker) { + Preconditions.checkNotNull(charset); + + this.charset = charset; + this.delimiter = delimiter; + this.headerPresent = headerPresent; + this.emptyLinesIgnored = emptyLinesIgnored; + this.headerCaseIgnored = headerCaseIgnored; + this.quoteCharacter = quoteCharacter; + this.escapeCharacter = escapeCharacter; + this.commentMarker = commentMarker; + } - if (hasHeader) { - format = format.withHeader(); - } - if (escapeCharacter != null) { - format = format.withEscape(escapeCharacter); - } + public CsvConfiguration() { + charset = StandardCharsets.UTF_8; + delimiter = ';'; + headerPresent = true; + emptyLinesIgnored = true; + headerCaseIgnored = false; + quoteCharacter = null; + escapeCharacter = null; + commentMarker = null; + } - if (commentMarker != null) { - format = format.withCommentMarker(commentMarker); - } - return format; - } + /** + * @return the character set + */ + public Charset getCharset() { + return charset; + } + + + /** + * @return the delimiter + */ + public char getDelimiter() { + return delimiter; + } + + + /** + * @return the header present + */ + public boolean isHeaderPresent() { + return headerPresent; + } + + + /** + * @return the empty lines ignored + */ + public boolean isEmptyLinesIgnored() { + return emptyLinesIgnored; + } + + + /** + * @return the header case ignored + */ + public boolean isHeaderCaseIgnored() { + return headerCaseIgnored; + } + + + /** + * @return the quote character + */ + @Nullable + public Character getQuoteCharacter() { + return quoteCharacter; + } + + + /** + * @return the escape character + */ + @Nullable + public Character getEscapeCharacter() { + return escapeCharacter; + } + + + /** + * @return the comment marker + */ + @Nullable + public Character getCommentMarker() { + return commentMarker; + } + + + CSVFormat toApacheConfiguration() { + CSVFormat format = CSVFormat.newFormat(delimiter).withAllowMissingColumnNames() + .withIgnoreEmptyLines(emptyLinesIgnored).withIgnoreHeaderCase(headerCaseIgnored); + + if (quoteCharacter != null) { + format = format.withQuote(quoteCharacter); + } + + if (headerPresent) { + format = format.withHeader(); + } + + if (escapeCharacter != null) { + format = format.withEscape(escapeCharacter); + } + + if (commentMarker != null) { + format = format.withCommentMarker(commentMarker); + } + + return format; + } + + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((charset == null) ? 0 : charset.hashCode()); + result = prime * result + ((commentMarker == null) ? 0 : commentMarker.hashCode()); + result = prime * result + delimiter; + result = prime * result + (emptyLinesIgnored ? 1231 : 1237); + result = prime * result + ((escapeCharacter == null) ? 0 : escapeCharacter.hashCode()); + result = prime * result + (headerCaseIgnored ? 1231 : 1237); + result = prime * result + (headerPresent ? 1231 : 1237); + result = prime * result + ((quoteCharacter == null) ? 0 : quoteCharacter.hashCode()); + return result; + } + + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + CsvConfiguration other = (CsvConfiguration) obj; + if (charset == null) { + if (other.charset != null) { + return false; + } + } else if (!charset.equals(other.charset)) { + return false; + } + if (commentMarker == null) { + if (other.commentMarker != null) { + return false; + } + } else if (!commentMarker.equals(other.commentMarker)) { + return false; + } + if (delimiter != other.delimiter) { + return false; + } + if (emptyLinesIgnored != other.emptyLinesIgnored) { + return false; + } + if (escapeCharacter == null) { + if (other.escapeCharacter != null) { + return false; + } + } else if (!escapeCharacter.equals(other.escapeCharacter)) { + return false; + } + if (headerCaseIgnored != other.headerCaseIgnored) { + return false; + } + if (headerPresent != other.headerPresent) { + return false; + } + if (quoteCharacter == null) { + if (other.quoteCharacter != null) { + return false; + } + } else if (!quoteCharacter.equals(other.quoteCharacter)) { + return false; + } + return true; + } + + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "CsvConfiguration [charset=" + charset + ", delimiter=" + delimiter + ", headerPresent=" + + headerPresent + ", emptyLinesIgnored=" + emptyLinesIgnored + ", headerCaseIgnored=" + + headerCaseIgnored + ", quoteCharacter=" + quoteCharacter + ", escapeCharacter=" + + escapeCharacter + ", commentMarker=" + commentMarker + "]"; + } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/CsvInputParser.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/CsvInputParser.java new file mode 100644 index 00000000..17d53503 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/CsvInputParser.java @@ -0,0 +1,22 @@ +package cz.cuni.mff.xrg.odalic.feedbacks.input; + +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; + +/** + * CSV input parser. + * + * @author Václav Brodec + * + */ +public interface CsvInputParser { + Input parse(String csvContent, String identifier, CsvConfiguration configuration) + throws IOException; + + Input parse(Reader csvReader, String identifier, CsvConfiguration configuration) + throws IOException; + + Input parse(InputStream csvStream, String identifier, CsvConfiguration configuration) + throws IOException; +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultCsvInputParser.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultCsvInputParser.java index 55ccbe24..356a9738 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultCsvInputParser.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultCsvInputParser.java @@ -3,57 +3,76 @@ import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVRecord; -import java.io.*; + +import com.google.common.base.Preconditions; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.StringReader; import java.util.Map; -public class DefaultCsvInputParser implements InputParser { +/** + * Default implementation of the {@link CsvInputParser}. + * + * @author Jan Váňa + */ +public final class DefaultCsvInputParser implements CsvInputParser { - @Override - public Input parse(String content, String fileIdentifier) throws IOException { - CsvConfiguration defaultConfiguration = new CsvConfiguration(); + private final ListsBackedInputBuilder inputBuilder; + public DefaultCsvInputParser(ListsBackedInputBuilder inputBuilder) { + Preconditions.checkNotNull(inputBuilder); + + this.inputBuilder = inputBuilder; + } + + @Override + public Input parse(String content, String identifier, CsvConfiguration configuration) throws IOException { try (Reader reader = new StringReader(content)) { - return parse(reader, defaultConfiguration, fileIdentifier); + return parse(reader, identifier, configuration); } } - public Input parse(InputStream stream, CsvConfiguration configuration, String fileIdentifier) throws IOException { - try (Reader reader = new InputStreamReader(stream, configuration.getEncoding())) { - return parse(reader, configuration, fileIdentifier); + @Override + public Input parse(InputStream stream, String identifier, CsvConfiguration configuration) throws IOException { + try (Reader reader = new InputStreamReader(stream, configuration.getCharset())) { + return parse(reader, identifier, configuration); } } - public Input parse(Reader reader, CsvConfiguration configuration, String fileIdentifier) throws IOException { - CSVFormat format = configuration.toApacheConfiguration(); - CSVParser parser = format.parse(reader); + @Override + public Input parse(Reader reader, String identifier, CsvConfiguration configuration) throws IOException { + final CSVFormat format = configuration.toApacheConfiguration(); + final CSVParser parser = format.parse(reader); - SimpleInput result = new SimpleInput(fileIdentifier); - HandleHeaders(result, parser); + inputBuilder.clear(); + inputBuilder.setFileIdentifier(identifier); + handleHeaders(parser); int row = 0; - for(CSVRecord record : parser) { - HandleInputRow(result, record, row); + handleInputRow(record, row); row++; } - return result; + return inputBuilder.build(); } - private void HandleInputRow(SimpleInput input, CSVRecord row, int rowIndex) { + private void handleInputRow(CSVRecord row, int rowIndex) { int column = 0; - for (String value : row) { - input.insertCell(value, rowIndex, column); + inputBuilder.insertCell(value, rowIndex, column); column++; } } - private void HandleHeaders(SimpleInput input, CSVParser parser) { - Map headerMap = parser.getHeaderMap(); + private void handleHeaders(CSVParser parser) { + final Map headerMap = parser.getHeaderMap(); for(Map.Entry headerEntry : headerMap.entrySet()) { - input.insertHeader(headerEntry.getKey(), headerEntry.getValue()); + inputBuilder.insertHeader(headerEntry.getKey(), headerEntry.getValue()); } } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultInputToTableAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultInputToTableAdapter.java index 1add9f11..38eb56dd 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultInputToTableAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultInputToTableAdapter.java @@ -7,13 +7,25 @@ import java.util.List; import java.util.UUID; +import javax.annotation.concurrent.Immutable; + +/** + * The default {@link InputToTableAdapter} implementation. + * + * @author Jan Váňa + * + */ +@Immutable public class DefaultInputToTableAdapter implements InputToTableAdapter { + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.feedbacks.input.InputToTableAdapter#toTable(cz.cuni.mff.xrg.odalic.feedbacks.input.Input) + */ @Override public Table toTable(Input input) { Table result = new Table( UUID.randomUUID().toString(), - input.fileIdentifier(), + input.identifier(), input.rowsCount(), input.columnsCount()); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultTableToInputAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultTableToInputAdapter.java deleted file mode 100644 index e039a704..00000000 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultTableToInputAdapter.java +++ /dev/null @@ -1,28 +0,0 @@ -package cz.cuni.mff.xrg.odalic.feedbacks.input; - -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.TColumnHeader; -import uk.ac.shef.dcs.sti.core.model.Table; - -public class DefaultTableToInputAdapter implements TableToInputAdapter { - - @Override - public Input toInput(Table table) { - SimpleInput result = new SimpleInput(table.getSourceId()); - - for (int columnIndex = 0; columnIndex < table.getNumHeaders(); columnIndex++) { - TColumnHeader header = table.getColumnHeader(columnIndex); - result.insertHeader(header.getHeaderText(), columnIndex); - } - - for (int columnIndex = 0; columnIndex < table.getNumCols(); columnIndex++) { - for (int rowIndex = 0; rowIndex < table.getNumRows(); rowIndex++) { - TCell cell = table.getContentCell(rowIndex, columnIndex); - result.insertCell(cell.getText(), rowIndex, columnIndex); - } - } - - return result; - } - -} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/Input.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/Input.java index f569077a..b43dd577 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/Input.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/Input.java @@ -20,5 +20,5 @@ public interface Input { int columnsCount(); List headers(); List> rows(); - String fileIdentifier(); + String identifier(); } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputParser.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputParser.java deleted file mode 100644 index 3f4d84bd..00000000 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputParser.java +++ /dev/null @@ -1,13 +0,0 @@ -package cz.cuni.mff.xrg.odalic.feedbacks.input; - -import java.io.IOException; - -/** - * Input parser. - * - * @author Václav Brodec - * - */ -public interface InputParser { - Input parse(String content, String fileIdentifier) throws IOException; -} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputToTableAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputToTableAdapter.java index 6ada902c..6bf804f9 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputToTableAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputToTableAdapter.java @@ -2,6 +2,12 @@ import uk.ac.shef.dcs.sti.core.model.Table; +/** + * Interface for {@link Input} to {@link Table} conversion. + * + * @author Václav Brodec + * + */ public interface InputToTableAdapter { Table toTable(Input input); } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/SimpleInput.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/ListsBackedInput.java similarity index 56% rename from odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/SimpleInput.java rename to odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/ListsBackedInput.java index 7bb34809..0ab33ec2 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/SimpleInput.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/ListsBackedInput.java @@ -1,30 +1,54 @@ package cz.cuni.mff.xrg.odalic.feedbacks.input; import java.io.Serializable; -import java.util.ArrayList; import java.util.List; +import javax.annotation.concurrent.Immutable; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + import cz.cuni.mff.xrg.odalic.positions.CellPosition; import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; import cz.cuni.mff.xrg.odalic.positions.RowPosition; +/** + * An {@link Input} implementation using a list of lists to store the cells. + * + * @author Václav Brodec + * @author Jan Váňa + */ @XmlRootElement(name = "input") -public class SimpleInput implements Input, Serializable { +@Immutable +public final class ListsBackedInput implements Input, Serializable { private static final long serialVersionUID = 4101912998363935336L; @XmlElement - private final List> rows = new ArrayList<>(); + private final List> rows; + @XmlElement - private final List headers = new ArrayList<>(); + private final List headers; + @XmlElement private final String fileIdentifier; - public SimpleInput(String fileIdentifier) { + public ListsBackedInput(String fileIdentifier, List headers, List> rows) { + Preconditions.checkNotNull(fileIdentifier); + Preconditions.checkNotNull(headers); + Preconditions.checkNotNull(rows); + this.fileIdentifier = fileIdentifier; + + this.headers = ImmutableList.copyOf(headers); + + final ImmutableList.Builder> rowsBuilder = ImmutableList.builder(); + for (final List row : rows) { + rowsBuilder.add(ImmutableList.copyOf(row)); + } + this.rows = rowsBuilder.build(); } @Override @@ -63,27 +87,7 @@ public List> rows() { } @Override - public String fileIdentifier() { + public String identifier() { return fileIdentifier; } - - void insertCell(String value, int rowIndex, int columnIndex) { - while (rows.size() <= rowIndex) { - rows.add(new ArrayList<>()); - } - - insertToList(rows.get(rowIndex), value, columnIndex); - } - - void insertHeader(String value, int position) { - insertToList(headers, value, position); - } - - private void insertToList(List list, String value, int position){ - while (list.size() <= position) { - list.add(null); - } - - list.set(position, value); - } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/ListsBackedInputBuilder.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/ListsBackedInputBuilder.java new file mode 100644 index 00000000..d8094676 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/ListsBackedInputBuilder.java @@ -0,0 +1,58 @@ +package cz.cuni.mff.xrg.odalic.feedbacks.input; + +import java.util.ArrayList; +import java.util.List; + +import com.google.common.base.Preconditions; + +/** + * Incrementally, row by row, helps to produce the complete {@link ListsBackedInput}. + * + * @author Jan Váňa + * @author Václav Brodec + * + */ +public final class ListsBackedInputBuilder { + + private String fileIdentifier; + private List headers = new ArrayList<>(); + private List> rows = new ArrayList<>(); + + public ListsBackedInputBuilder() { } + + void setFileIdentifier(String fileIdentifier) { + Preconditions.checkNotNull(fileIdentifier); + + this.fileIdentifier = fileIdentifier; + } + + public void insertCell(String value, int rowIndex, int columnIndex) { + while (rows.size() <= rowIndex) { + rows.add(new ArrayList<>()); + } + + insertToList(rows.get(rowIndex), value, columnIndex); + } + + public void insertHeader(String value, int position) { + insertToList(headers, value, position); + } + + public void insertToList(List list, String value, int position){ + while (list.size() <= position) { + list.add(null); + } + + list.set(position, value); + } + + ListsBackedInput build() { + return new ListsBackedInput(this.fileIdentifier, this.headers, this.rows); + } + + public void clear() { + this.fileIdentifier = null; + headers.clear(); + rows.clear(); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/TableToInputAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/TableToInputAdapter.java index e1010d15..0c6e6c97 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/TableToInputAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/TableToInputAdapter.java @@ -2,6 +2,12 @@ import uk.ac.shef.dcs.sti.core.model.Table; +/** + * Interface for {@link Table} to {@link Input} conversion. + * + * @author Václav Brodec + * + */ public interface TableToInputAdapter { Input toInput(Table table); } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/TableToListsBackedInputAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/TableToListsBackedInputAdapter.java new file mode 100644 index 00000000..7e781924 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/TableToListsBackedInputAdapter.java @@ -0,0 +1,48 @@ +package cz.cuni.mff.xrg.odalic.feedbacks.input; + +import com.google.common.base.Preconditions; + +import uk.ac.shef.dcs.sti.core.model.TCell; +import uk.ac.shef.dcs.sti.core.model.TColumnHeader; +import uk.ac.shef.dcs.sti.core.model.Table; + +/** + * Converts the {@link Table} to {@link ListsBackedInputBuilder}. + * + * @author Jan Váňa + * + */ +public final class TableToListsBackedInputAdapter implements TableToInputAdapter { + + private final ListsBackedInputBuilder builder; + + public TableToListsBackedInputAdapter(ListsBackedInputBuilder builder) { + Preconditions.checkNotNull(builder); + + this.builder = builder; + } + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.feedbacks.input.TableToInputAdapter#toInput(uk.ac.shef.dcs.sti.core.model.Table) + */ + @Override + public Input toInput(Table table) { + builder.clear(); + builder.setFileIdentifier(table.getSourceId()); + + for (int columnIndex = 0; columnIndex < table.getNumHeaders(); columnIndex++) { + TColumnHeader header = table.getColumnHeader(columnIndex); + builder.insertHeader(header.getHeaderText(), columnIndex); + } + + for (int columnIndex = 0; columnIndex < table.getNumCols(); columnIndex++) { + for (int rowIndex = 0; rowIndex < table.getNumRows(); rowIndex++) { + TCell cell = table.getContentCell(rowIndex, columnIndex); + builder.insertCell(cell.getText(), rowIndex, columnIndex); + } + } + + return builder.build(); + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java index 9d182084..f74a6cb4 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java @@ -4,7 +4,6 @@ package cz.cuni.mff.xrg.odalic.tasks.executions; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.Callable; @@ -13,13 +12,16 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; -import org.apache.commons.io.FileUtils; import org.springframework.beans.factory.annotation.Autowired; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; import cz.cuni.mff.xrg.odalic.feedbacks.ColumnIgnore; +import cz.cuni.mff.xrg.odalic.feedbacks.input.Input; +import cz.cuni.mff.xrg.odalic.feedbacks.input.CsvConfiguration; +import cz.cuni.mff.xrg.odalic.feedbacks.input.CsvInputParser; +import cz.cuni.mff.xrg.odalic.feedbacks.input.InputToTableAdapter; import cz.cuni.mff.xrg.odalic.files.File; import cz.cuni.mff.xrg.odalic.files.FileService; import cz.cuni.mff.xrg.odalic.tasks.Task; @@ -31,7 +33,6 @@ import uk.ac.shef.dcs.sti.core.algorithm.SemanticTableInterpreter; import uk.ac.shef.dcs.sti.core.model.TAnnotation; import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.xtractor.csv.TableXtractorCSV; /** *

Implementation of {@link ExecutionService} based on {@link Future} and {@link ExecutorServicee} @@ -44,14 +45,12 @@ */ public final class FutureBasedExecutionService implements ExecutionService { - private static final String TEMP_FILE_PREFIX = "odalic"; - private static final String TEMP_FILE_SUFFIX = "csv"; - private final TaskService taskService; private final FileService fileService; private final AnnotationToResultAdapter annotationResultAdapter; private final SemanticTableInterpreterFactory semanticTableInterpreterFactory; - private final TableXtractorCSV tableExtractor; + private final CsvInputParser inputParser; + private final InputToTableAdapter inputToTableAdapter; private final ExecutorService executorService = Executors.newFixedThreadPool(1); private final Map> tasksToResults = new HashMap<>(); @@ -59,18 +58,20 @@ public final class FutureBasedExecutionService implements ExecutionService { public FutureBasedExecutionService(TaskService taskService, FileService fileService, AnnotationToResultAdapter annotationToResultAdapter, SemanticTableInterpreterFactory semanticTableInterpreterFactory, - TableXtractorCSV tableExtractor) { + CsvInputParser inputParser, InputToTableAdapter inputToTableAdapter) { Preconditions.checkNotNull(taskService); Preconditions.checkNotNull(fileService); Preconditions.checkNotNull(annotationToResultAdapter); Preconditions.checkNotNull(semanticTableInterpreterFactory); - Preconditions.checkNotNull(tableExtractor); + Preconditions.checkNotNull(inputParser); + Preconditions.checkNotNull(inputToTableAdapter); this.taskService = taskService; this.fileService = fileService; this.annotationResultAdapter = annotationToResultAdapter; this.semanticTableInterpreterFactory = semanticTableInterpreterFactory; - this.tableExtractor = tableExtractor; + this.inputParser = inputParser; + this.inputToTableAdapter = inputToTableAdapter; } /* (non-Javadoc) @@ -91,22 +92,15 @@ public void submitForTaskId(String id) throws IllegalStateException { final Callable execution = () -> { final String data = fileService.getDataById(file.getId()); - //TODO: Remove dependency on temporary file creation. - final java.io.File tempFile = java.io.File.createTempFile(TEMP_FILE_PREFIX, TEMP_FILE_SUFFIX); - tempFile.deleteOnExit(); - FileUtils.writeStringToFile(tempFile, data); - - //TODO: Substitute table extractor with something more robust as soon as possible. - final List

tables = tableExtractor.extract(tempFile, tempFile.getName()); - if (tables.isEmpty()) { - throw new IllegalArgumentException(); - } + // TODO: Read configuration attributed to the file instead of the default one. + final Input input = inputParser.parse(data, file.getId(), new CsvConfiguration()); + final Table table = inputToTableAdapter.toTable(input); final SemanticTableInterpreter interpreter = semanticTableInterpreterFactory.getInterpreter(); semanticTableInterpreterFactory.setColumnIgnoresForInterpreter(columnIgnores); - final TAnnotation annotationResult = interpreter.start(tables.get(0), true); - //TODO: Add multiple KB support to configuration. + final TAnnotation annotationResult = interpreter.start(table, true); + // TODO: Add multiple KB support to configuration. final Result result = annotationResultAdapter .toResult(ImmutableMap.of(new KnowledgeBase("DBpedia"), annotationResult)); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/MemoryOnlyFeedbackService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/MemoryOnlyFeedbackService.java index fbb1d9fe..98002a71 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/MemoryOnlyFeedbackService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/MemoryOnlyFeedbackService.java @@ -8,7 +8,8 @@ import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; import cz.cuni.mff.xrg.odalic.feedbacks.input.Input; -import cz.cuni.mff.xrg.odalic.feedbacks.input.InputParser; +import cz.cuni.mff.xrg.odalic.feedbacks.input.CsvConfiguration; +import cz.cuni.mff.xrg.odalic.feedbacks.input.CsvInputParser; import cz.cuni.mff.xrg.odalic.files.File; import cz.cuni.mff.xrg.odalic.files.FileService; import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; @@ -24,10 +25,10 @@ public final class MemoryOnlyFeedbackService implements FeedbackService { private final ConfigurationService configurationService; private final FileService fileService; - private final InputParser inputParser; + private final CsvInputParser inputParser; @Autowired - public MemoryOnlyFeedbackService(ConfigurationService configurationService, FileService fileService, InputParser inputParser) { + public MemoryOnlyFeedbackService(ConfigurationService configurationService, FileService fileService, CsvInputParser inputParser) { Preconditions.checkNotNull(configurationService); Preconditions.checkNotNull(fileService); Preconditions.checkNotNull(inputParser); @@ -56,6 +57,7 @@ public Input getInputForTaskId(String taskId) throws IOException { final File file = configuration.getInput(); final String data = fileService.getDataById(file.getId()); - return inputParser.parse(data, file.getId()); + // TODO: Read configuration attributed to the file instead of the default one. + return inputParser.parse(data, file.getId(), new CsvConfiguration()); } } From 15841a5e5366c12b775d4baf3e4db73fb0dd0c7b Mon Sep 17 00:00:00 2001 From: brodecva Date: Mon, 25 Jul 2016 20:50:56 +0200 Subject: [PATCH 057/211] New CSV parser Spring configuration. --- .../input/DefaultCsvInputParser.java | 2 ++ .../odalic/feedbacks/input/InputBuilder.java | 24 +++++++++++++++++++ .../input/ListsBackedInputBuilder.java | 24 +++++++++++++++++-- .../FutureBasedExecutionService.java | 10 ++++---- .../resources/spring/applicationContext.xml | 14 ++++++----- 5 files changed, 61 insertions(+), 13 deletions(-) create mode 100644 odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputBuilder.java diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultCsvInputParser.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultCsvInputParser.java index 356a9738..fda905ee 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultCsvInputParser.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultCsvInputParser.java @@ -3,6 +3,7 @@ import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVRecord; +import org.springframework.beans.factory.annotation.Autowired; import com.google.common.base.Preconditions; @@ -22,6 +23,7 @@ public final class DefaultCsvInputParser implements CsvInputParser { private final ListsBackedInputBuilder inputBuilder; + @Autowired public DefaultCsvInputParser(ListsBackedInputBuilder inputBuilder) { Preconditions.checkNotNull(inputBuilder); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputBuilder.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputBuilder.java new file mode 100644 index 00000000..9f376f45 --- /dev/null +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputBuilder.java @@ -0,0 +1,24 @@ +package cz.cuni.mff.xrg.odalic.feedbacks.input; + +import java.util.List; + + +/** + * {@link Input} builder interface. + * + * @author Václav Brodec + * + */ +public interface InputBuilder { + + void insertCell(String value, int rowIndex, int columnIndex); + + void insertHeader(String value, int position); + + void insertToList(List list, String value, int position); + + Input build(); + + void clear(); + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/ListsBackedInputBuilder.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/ListsBackedInputBuilder.java index d8094676..bda884f8 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/ListsBackedInputBuilder.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/ListsBackedInputBuilder.java @@ -12,7 +12,7 @@ * @author Václav Brodec * */ -public final class ListsBackedInputBuilder { +public final class ListsBackedInputBuilder implements InputBuilder { private String fileIdentifier; private List headers = new ArrayList<>(); @@ -26,6 +26,10 @@ void setFileIdentifier(String fileIdentifier) { this.fileIdentifier = fileIdentifier; } + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.feedbacks.input.InputBuilder#insertCell(java.lang.String, int, int) + */ + @Override public void insertCell(String value, int rowIndex, int columnIndex) { while (rows.size() <= rowIndex) { rows.add(new ArrayList<>()); @@ -34,10 +38,18 @@ public void insertCell(String value, int rowIndex, int columnIndex) { insertToList(rows.get(rowIndex), value, columnIndex); } + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.feedbacks.input.InputBuilder#insertHeader(java.lang.String, int) + */ + @Override public void insertHeader(String value, int position) { insertToList(headers, value, position); } + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.feedbacks.input.InputBuilder#insertToList(java.util.List, java.lang.String, int) + */ + @Override public void insertToList(List list, String value, int position){ while (list.size() <= position) { list.add(null); @@ -46,10 +58,18 @@ public void insertToList(List list, String value, int position){ list.set(position, value); } - ListsBackedInput build() { + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.feedbacks.input.InputBuilder#build() + */ + @Override + public Input build() { return new ListsBackedInput(this.fileIdentifier, this.headers, this.rows); } + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.feedbacks.input.InputBuilder#clear() + */ + @Override public void clear() { this.fileIdentifier = null; headers.clear(); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java index f74a6cb4..f1394179 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java @@ -49,7 +49,7 @@ public final class FutureBasedExecutionService implements ExecutionService { private final FileService fileService; private final AnnotationToResultAdapter annotationResultAdapter; private final SemanticTableInterpreterFactory semanticTableInterpreterFactory; - private final CsvInputParser inputParser; + private final CsvInputParser csvInputParser; private final InputToTableAdapter inputToTableAdapter; private final ExecutorService executorService = Executors.newFixedThreadPool(1); private final Map> tasksToResults = new HashMap<>(); @@ -58,19 +58,19 @@ public final class FutureBasedExecutionService implements ExecutionService { public FutureBasedExecutionService(TaskService taskService, FileService fileService, AnnotationToResultAdapter annotationToResultAdapter, SemanticTableInterpreterFactory semanticTableInterpreterFactory, - CsvInputParser inputParser, InputToTableAdapter inputToTableAdapter) { + CsvInputParser csvInputParser, InputToTableAdapter inputToTableAdapter) { Preconditions.checkNotNull(taskService); Preconditions.checkNotNull(fileService); Preconditions.checkNotNull(annotationToResultAdapter); Preconditions.checkNotNull(semanticTableInterpreterFactory); - Preconditions.checkNotNull(inputParser); + Preconditions.checkNotNull(csvInputParser); Preconditions.checkNotNull(inputToTableAdapter); this.taskService = taskService; this.fileService = fileService; this.annotationResultAdapter = annotationToResultAdapter; this.semanticTableInterpreterFactory = semanticTableInterpreterFactory; - this.inputParser = inputParser; + this.csvInputParser = csvInputParser; this.inputToTableAdapter = inputToTableAdapter; } @@ -93,7 +93,7 @@ public void submitForTaskId(String id) throws IllegalStateException { final String data = fileService.getDataById(file.getId()); // TODO: Read configuration attributed to the file instead of the default one. - final Input input = inputParser.parse(data, file.getId(), new CsvConfiguration()); + final Input input = csvInputParser.parse(data, file.getId(), new CsvConfiguration()); final Table table = inputToTableAdapter.toTable(input); final SemanticTableInterpreter interpreter = semanticTableInterpreterFactory.getInterpreter(); diff --git a/odalic/src/main/resources/spring/applicationContext.xml b/odalic/src/main/resources/spring/applicationContext.xml index 150c4e80..6958f143 100644 --- a/odalic/src/main/resources/spring/applicationContext.xml +++ b/odalic/src/main/resources/spring/applicationContext.xml @@ -13,18 +13,20 @@ - - - - - + + + + Date: Tue, 26 Jul 2016 14:39:49 +0200 Subject: [PATCH 058/211] Move of input package to the odalic root package. --- .../odalic/api/rest/resources/FeedbackResource.java | 2 +- .../{feedbacks => }/input/CsvConfiguration.java | 2 +- .../odalic/{feedbacks => }/input/CsvInputParser.java | 2 +- .../{feedbacks => }/input/DefaultCsvInputParser.java | 2 +- .../input/DefaultInputToTableAdapter.java | 4 ++-- .../mff/xrg/odalic/{feedbacks => }/input/Input.java | 2 +- .../odalic/{feedbacks => }/input/InputBuilder.java | 2 +- .../{feedbacks => }/input/InputToTableAdapter.java | 2 +- .../{feedbacks => }/input/ListsBackedInput.java | 2 +- .../input/ListsBackedInputBuilder.java | 12 ++++++------ .../{feedbacks => }/input/TableToInputAdapter.java | 2 +- .../input/TableToListsBackedInputAdapter.java | 4 ++-- .../executions/FutureBasedExecutionService.java | 8 ++++---- .../xrg/odalic/tasks/feedbacks/FeedbackService.java | 2 +- .../tasks/feedbacks/MemoryOnlyFeedbackService.java | 6 +++--- .../src/main/resources/spring/applicationContext.xml | 6 +++--- 16 files changed, 30 insertions(+), 30 deletions(-) rename odalic/src/main/java/cz/cuni/mff/xrg/odalic/{feedbacks => }/input/CsvConfiguration.java (99%) rename odalic/src/main/java/cz/cuni/mff/xrg/odalic/{feedbacks => }/input/CsvInputParser.java (91%) rename odalic/src/main/java/cz/cuni/mff/xrg/odalic/{feedbacks => }/input/DefaultCsvInputParser.java (97%) rename odalic/src/main/java/cz/cuni/mff/xrg/odalic/{feedbacks => }/input/DefaultInputToTableAdapter.java (87%) rename odalic/src/main/java/cz/cuni/mff/xrg/odalic/{feedbacks => }/input/Input.java (91%) rename odalic/src/main/java/cz/cuni/mff/xrg/odalic/{feedbacks => }/input/InputBuilder.java (88%) rename odalic/src/main/java/cz/cuni/mff/xrg/odalic/{feedbacks => }/input/InputToTableAdapter.java (81%) rename odalic/src/main/java/cz/cuni/mff/xrg/odalic/{feedbacks => }/input/ListsBackedInput.java (97%) rename odalic/src/main/java/cz/cuni/mff/xrg/odalic/{feedbacks => }/input/ListsBackedInputBuilder.java (75%) rename odalic/src/main/java/cz/cuni/mff/xrg/odalic/{feedbacks => }/input/TableToInputAdapter.java (81%) rename odalic/src/main/java/cz/cuni/mff/xrg/odalic/{feedbacks => }/input/TableToListsBackedInputAdapter.java (88%) diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FeedbackResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FeedbackResource.java index 4895a113..0ed6d85c 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FeedbackResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FeedbackResource.java @@ -17,7 +17,7 @@ import com.google.common.base.Preconditions; import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; -import cz.cuni.mff.xrg.odalic.feedbacks.input.Input; +import cz.cuni.mff.xrg.odalic.input.Input; import cz.cuni.mff.xrg.odalic.tasks.feedbacks.FeedbackService; @Component diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/CsvConfiguration.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/CsvConfiguration.java similarity index 99% rename from odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/CsvConfiguration.java rename to odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/CsvConfiguration.java index e88a023b..186c9cea 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/CsvConfiguration.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/CsvConfiguration.java @@ -1,4 +1,4 @@ -package cz.cuni.mff.xrg.odalic.feedbacks.input; +package cz.cuni.mff.xrg.odalic.input; import java.io.Serializable; import java.nio.charset.Charset; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/CsvInputParser.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/CsvInputParser.java similarity index 91% rename from odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/CsvInputParser.java rename to odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/CsvInputParser.java index 17d53503..96226e50 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/CsvInputParser.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/CsvInputParser.java @@ -1,4 +1,4 @@ -package cz.cuni.mff.xrg.odalic.feedbacks.input; +package cz.cuni.mff.xrg.odalic.input; import java.io.IOException; import java.io.InputStream; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultCsvInputParser.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/DefaultCsvInputParser.java similarity index 97% rename from odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultCsvInputParser.java rename to odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/DefaultCsvInputParser.java index fda905ee..6c884103 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultCsvInputParser.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/DefaultCsvInputParser.java @@ -1,4 +1,4 @@ -package cz.cuni.mff.xrg.odalic.feedbacks.input; +package cz.cuni.mff.xrg.odalic.input; import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVParser; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultInputToTableAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/DefaultInputToTableAdapter.java similarity index 87% rename from odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultInputToTableAdapter.java rename to odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/DefaultInputToTableAdapter.java index 38eb56dd..4fcf9765 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/DefaultInputToTableAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/DefaultInputToTableAdapter.java @@ -1,4 +1,4 @@ -package cz.cuni.mff.xrg.odalic.feedbacks.input; +package cz.cuni.mff.xrg.odalic.input; import uk.ac.shef.dcs.sti.core.model.TCell; import uk.ac.shef.dcs.sti.core.model.TColumnHeader; @@ -19,7 +19,7 @@ public class DefaultInputToTableAdapter implements InputToTableAdapter { /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.feedbacks.input.InputToTableAdapter#toTable(cz.cuni.mff.xrg.odalic.feedbacks.input.Input) + * @see cz.cuni.mff.xrg.odalic.input.InputToTableAdapter#toTable(cz.cuni.mff.xrg.odalic.input.Input) */ @Override public Table toTable(Input input) { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/Input.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/Input.java similarity index 91% rename from odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/Input.java rename to odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/Input.java index b43dd577..05dbc042 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/Input.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/Input.java @@ -1,4 +1,4 @@ -package cz.cuni.mff.xrg.odalic.feedbacks.input; +package cz.cuni.mff.xrg.odalic.input; import java.util.List; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputBuilder.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/InputBuilder.java similarity index 88% rename from odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputBuilder.java rename to odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/InputBuilder.java index 9f376f45..b2b26dda 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputBuilder.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/InputBuilder.java @@ -1,4 +1,4 @@ -package cz.cuni.mff.xrg.odalic.feedbacks.input; +package cz.cuni.mff.xrg.odalic.input; import java.util.List; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputToTableAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/InputToTableAdapter.java similarity index 81% rename from odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputToTableAdapter.java rename to odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/InputToTableAdapter.java index 6bf804f9..c74f922c 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/InputToTableAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/InputToTableAdapter.java @@ -1,4 +1,4 @@ -package cz.cuni.mff.xrg.odalic.feedbacks.input; +package cz.cuni.mff.xrg.odalic.input; import uk.ac.shef.dcs.sti.core.model.Table; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/ListsBackedInput.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/ListsBackedInput.java similarity index 97% rename from odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/ListsBackedInput.java rename to odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/ListsBackedInput.java index 0ab33ec2..0dbe7496 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/ListsBackedInput.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/ListsBackedInput.java @@ -1,4 +1,4 @@ -package cz.cuni.mff.xrg.odalic.feedbacks.input; +package cz.cuni.mff.xrg.odalic.input; import java.io.Serializable; import java.util.List; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/ListsBackedInputBuilder.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/ListsBackedInputBuilder.java similarity index 75% rename from odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/ListsBackedInputBuilder.java rename to odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/ListsBackedInputBuilder.java index bda884f8..b63289c0 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/ListsBackedInputBuilder.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/ListsBackedInputBuilder.java @@ -1,4 +1,4 @@ -package cz.cuni.mff.xrg.odalic.feedbacks.input; +package cz.cuni.mff.xrg.odalic.input; import java.util.ArrayList; import java.util.List; @@ -27,7 +27,7 @@ void setFileIdentifier(String fileIdentifier) { } /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.feedbacks.input.InputBuilder#insertCell(java.lang.String, int, int) + * @see cz.cuni.mff.xrg.odalic.input.InputBuilder#insertCell(java.lang.String, int, int) */ @Override public void insertCell(String value, int rowIndex, int columnIndex) { @@ -39,7 +39,7 @@ public void insertCell(String value, int rowIndex, int columnIndex) { } /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.feedbacks.input.InputBuilder#insertHeader(java.lang.String, int) + * @see cz.cuni.mff.xrg.odalic.input.InputBuilder#insertHeader(java.lang.String, int) */ @Override public void insertHeader(String value, int position) { @@ -47,7 +47,7 @@ public void insertHeader(String value, int position) { } /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.feedbacks.input.InputBuilder#insertToList(java.util.List, java.lang.String, int) + * @see cz.cuni.mff.xrg.odalic.input.InputBuilder#insertToList(java.util.List, java.lang.String, int) */ @Override public void insertToList(List list, String value, int position){ @@ -59,7 +59,7 @@ public void insertToList(List list, String value, int position){ } /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.feedbacks.input.InputBuilder#build() + * @see cz.cuni.mff.xrg.odalic.input.InputBuilder#build() */ @Override public Input build() { @@ -67,7 +67,7 @@ public Input build() { } /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.feedbacks.input.InputBuilder#clear() + * @see cz.cuni.mff.xrg.odalic.input.InputBuilder#clear() */ @Override public void clear() { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/TableToInputAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/TableToInputAdapter.java similarity index 81% rename from odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/TableToInputAdapter.java rename to odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/TableToInputAdapter.java index 0c6e6c97..3c2852e2 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/TableToInputAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/TableToInputAdapter.java @@ -1,4 +1,4 @@ -package cz.cuni.mff.xrg.odalic.feedbacks.input; +package cz.cuni.mff.xrg.odalic.input; import uk.ac.shef.dcs.sti.core.model.Table; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/TableToListsBackedInputAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/TableToListsBackedInputAdapter.java similarity index 88% rename from odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/TableToListsBackedInputAdapter.java rename to odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/TableToListsBackedInputAdapter.java index 7e781924..9444a253 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/input/TableToListsBackedInputAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/TableToListsBackedInputAdapter.java @@ -1,4 +1,4 @@ -package cz.cuni.mff.xrg.odalic.feedbacks.input; +package cz.cuni.mff.xrg.odalic.input; import com.google.common.base.Preconditions; @@ -23,7 +23,7 @@ public TableToListsBackedInputAdapter(ListsBackedInputBuilder builder) { } /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.feedbacks.input.TableToInputAdapter#toInput(uk.ac.shef.dcs.sti.core.model.Table) + * @see cz.cuni.mff.xrg.odalic.input.TableToInputAdapter#toInput(uk.ac.shef.dcs.sti.core.model.Table) */ @Override public Input toInput(Table table) { diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java index f1394179..1a162f9a 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java @@ -18,12 +18,12 @@ import com.google.common.collect.ImmutableMap; import cz.cuni.mff.xrg.odalic.feedbacks.ColumnIgnore; -import cz.cuni.mff.xrg.odalic.feedbacks.input.Input; -import cz.cuni.mff.xrg.odalic.feedbacks.input.CsvConfiguration; -import cz.cuni.mff.xrg.odalic.feedbacks.input.CsvInputParser; -import cz.cuni.mff.xrg.odalic.feedbacks.input.InputToTableAdapter; import cz.cuni.mff.xrg.odalic.files.File; import cz.cuni.mff.xrg.odalic.files.FileService; +import cz.cuni.mff.xrg.odalic.input.CsvConfiguration; +import cz.cuni.mff.xrg.odalic.input.CsvInputParser; +import cz.cuni.mff.xrg.odalic.input.Input; +import cz.cuni.mff.xrg.odalic.input.InputToTableAdapter; import cz.cuni.mff.xrg.odalic.tasks.Task; import cz.cuni.mff.xrg.odalic.tasks.TaskService; import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/FeedbackService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/FeedbackService.java index 47b6d968..e6b18fd2 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/FeedbackService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/FeedbackService.java @@ -3,7 +3,7 @@ import java.io.IOException; import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; -import cz.cuni.mff.xrg.odalic.feedbacks.input.Input; +import cz.cuni.mff.xrg.odalic.input.Input; /** * Feedback service handles the CRUD operations for {@link Feedback} instances. diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/MemoryOnlyFeedbackService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/MemoryOnlyFeedbackService.java index 98002a71..605515bf 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/MemoryOnlyFeedbackService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/MemoryOnlyFeedbackService.java @@ -7,11 +7,11 @@ import com.google.common.base.Preconditions; import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; -import cz.cuni.mff.xrg.odalic.feedbacks.input.Input; -import cz.cuni.mff.xrg.odalic.feedbacks.input.CsvConfiguration; -import cz.cuni.mff.xrg.odalic.feedbacks.input.CsvInputParser; import cz.cuni.mff.xrg.odalic.files.File; import cz.cuni.mff.xrg.odalic.files.FileService; +import cz.cuni.mff.xrg.odalic.input.CsvConfiguration; +import cz.cuni.mff.xrg.odalic.input.CsvInputParser; +import cz.cuni.mff.xrg.odalic.input.Input; import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; import cz.cuni.mff.xrg.odalic.tasks.configurations.ConfigurationService; diff --git a/odalic/src/main/resources/spring/applicationContext.xml b/odalic/src/main/resources/spring/applicationContext.xml index 6958f143..6552f903 100644 --- a/odalic/src/main/resources/spring/applicationContext.xml +++ b/odalic/src/main/resources/spring/applicationContext.xml @@ -13,13 +13,13 @@ - - Date: Tue, 26 Jul 2016 16:52:58 +0200 Subject: [PATCH 059/211] Configuration extended with primary knowledge base specification. --- .../rest/resources/ConfigurationResource.java | 4 +-- .../api/rest/resources/TaskResource.java | 4 +-- .../api/rest/values/ConfigurationValue.java | 25 ++++++++++++++++++- .../tasks/configurations/Configuration.java | 22 +++++++++++----- .../feedbacks/MemoryOnlyFeedbackService.java | 2 +- 5 files changed, 45 insertions(+), 12 deletions(-) diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ConfigurationResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ConfigurationResource.java index 3d305a02..82f2a5b8 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ConfigurationResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ConfigurationResource.java @@ -45,9 +45,9 @@ public Response putConfigurationForTaskId(@PathParam("id") String id, final Configuration configuration; if (configurationValue.getFeedback() == null) { - configuration = new Configuration(input); + configuration = new Configuration(input, configurationValue.getPrimaryBase()); } else { - configuration = new Configuration(input, configurationValue.getFeedback()); + configuration = new Configuration(input, configurationValue.getPrimaryBase(), configurationValue.getFeedback()); } configurationService.setForTaskId(id, configuration); diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/TaskResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/TaskResource.java index 8072abca..9eab7ef7 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/TaskResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/TaskResource.java @@ -70,8 +70,8 @@ public Response getTaskById(@PathParam("id") String id) { public Response putTaskWithId(@Context UriInfo uriInfo, @PathParam("id") String id, TaskValue taskValue) throws MalformedURLException { final ConfigurationValue configurationValue = taskValue.getConfiguration(); final File input = fileService.getById(configurationValue.getInput()); - final Configuration configuration = new Configuration(input, configurationValue.getFeedback()); - final Task task = new Task(taskValue.getId(), taskValue.getCreated(), new Configuration(input, configuration.getFeedback())); + final Configuration configuration = new Configuration(input, configurationValue.getPrimaryBase(), configurationValue.getFeedback()); + final Task task = new Task(taskValue.getId(), taskValue.getCreated(), configuration); if (!taskService.hasId(task, id)) { return Response.status(Response.Status.NOT_ACCEPTABLE) diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java index d8ef2d63..02dcdb91 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java @@ -9,6 +9,7 @@ import com.google.common.base.Preconditions; import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; /** @@ -27,12 +28,16 @@ public final class ConfigurationValue implements Serializable { @XmlElement(name = "feedback") private Feedback feedback; + + @XmlElement(name = "primaryBase") + private KnowledgeBase primaryBase; public ConfigurationValue() {} public ConfigurationValue(Configuration adaptee) { input = adaptee.getInput().getId(); feedback = adaptee.getFeedback(); + primaryBase = adaptee.getPrimaryBase(); } /** @@ -70,11 +75,29 @@ public void setFeedback(Feedback feedback) { this.feedback = feedback; } + /** + * @return the primary knowledge base + */ + @Nullable + public KnowledgeBase getPrimaryBase() { + return primaryBase; + } + + /** + * @param primaryBase the primary knowledge base to set + */ + public void setPrimaryBase(KnowledgeBase primaryBase) { + Preconditions.checkNotNull(primaryBase); + + this.primaryBase = primaryBase; + } + /* (non-Javadoc) * @see java.lang.Object#toString() */ @Override public String toString() { - return "ConfigurationValue [input=" + input + ", feedback=" + feedback + "]"; + return "ConfigurationValue [input=" + input + ", feedback=" + feedback + ", primaryBase=" + + primaryBase + "]"; } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java index 928f4043..6936ba96 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java @@ -10,6 +10,7 @@ import cz.cuni.mff.xrg.odalic.api.rest.adapters.ConfigurationAdapter; import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; import cz.cuni.mff.xrg.odalic.files.File; +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; /** * Task configuration. @@ -26,30 +27,32 @@ public final class Configuration implements Serializable { private final File input; private final Feedback feedback; + + private final KnowledgeBase primaryBase; /** * Creates configuration without any feedback, thus implying fully automatic processing. * * @param input input specification */ - public Configuration(File input) { - Preconditions.checkNotNull(input); - - this.input = input; - this.feedback = new Feedback(); + public Configuration(File input, KnowledgeBase primaryBase) { + this(input, primaryBase, new Feedback()); } /** * Creates configuration with provided feedback, which serves as hint for the processing algorithm. * * @param input input specification + * @param primaryBase primary knowledge base * @param feedback constraints for the algorithm */ - public Configuration(File input, Feedback feedback) { + public Configuration(File input, KnowledgeBase primaryBase, Feedback feedback) { Preconditions.checkNotNull(input); + Preconditions.checkNotNull(primaryBase); Preconditions.checkNotNull(feedback); this.input = input; + this.primaryBase = primaryBase; this.feedback = feedback; } @@ -67,6 +70,13 @@ public Feedback getFeedback() { return feedback; } + /** + * @return the primary knowledge base + */ + public KnowledgeBase getPrimaryBase() { + return primaryBase; + } + /* (non-Javadoc) * @see java.lang.Object#hashCode() */ diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/MemoryOnlyFeedbackService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/MemoryOnlyFeedbackService.java index 605515bf..7de0cba0 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/MemoryOnlyFeedbackService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/MemoryOnlyFeedbackService.java @@ -48,7 +48,7 @@ public Feedback getForTaskId(String taskId) { @Override public void setForTaskId(String taskId, Feedback feedback) { final Configuration oldConfiguration = configurationService.getForTaskId(taskId); - configurationService.setForTaskId(taskId, new Configuration(oldConfiguration.getInput(), feedback)); + configurationService.setForTaskId(taskId, new Configuration(oldConfiguration.getInput(), oldConfiguration.getPrimaryBase(), feedback)); } @Override From 6522d047d0115cb90d8b302711a6605f18909c55 Mon Sep 17 00:00:00 2001 From: brodecva Date: Tue, 26 Jul 2016 17:12:11 +0200 Subject: [PATCH 060/211] Primary base field name fix (camel case to underscore notation). --- .../cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java index 02dcdb91..1d4b14b6 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java @@ -29,7 +29,7 @@ public final class ConfigurationValue implements Serializable { @XmlElement(name = "feedback") private Feedback feedback; - @XmlElement(name = "primaryBase") + @XmlElement(name = "primary_base") private KnowledgeBase primaryBase; public ConfigurationValue() {} From 3590b81d17d8b662e70ce8b2cba3c89a1fb5b97f Mon Sep 17 00:00:00 2001 From: brodecva Date: Wed, 27 Jul 2016 12:46:59 +0200 Subject: [PATCH 061/211] Pulling up common methods and fields. --- .../core/algorithm/smp/TCellEntityRanker.java | 2 +- .../tmp/LiteralColumnTaggerImpl.java | 2 +- .../algorithm/tmp/TCellDisambiguator.java | 2 +- .../dcs/sti/experiment/BaselineBatch.java | 2 +- .../sti/experiment/TableMinerPlusBatch.java | 2 +- .../FreebaseTypeGranularityPopulator.java | 4 +- ...t_Entity_Discrepancy_Analysis_Generic.java | 5 +- ...ty_Discrepancy_btw_Baseline_Tm_Finder.java | 7 +- .../dcs/sti/xtractor/csv/ParserCsvConfig.java | 4 +- .../uk/ac/shef/dcs/kbsearch/KBSearch.java | 11 +- .../dcs/kbsearch/freebase/FreebaseSearch.java | 33 +- .../dcs/kbsearch/sparql/DBpediaSearch.java | 316 +----------------- .../dcs/kbsearch/sparql/SPARQLSearch.java | 314 ++++++++++++++++- .../executions/TableMinerPlusFactory.java | 2 +- 14 files changed, 353 insertions(+), 353 deletions(-) diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TCellEntityRanker.java b/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TCellEntityRanker.java index aafac9a6..cfecbb3e 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TCellEntityRanker.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TCellEntityRanker.java @@ -50,7 +50,7 @@ public List>> score(Table table, int row, int column ) throws KBSearchException { //do disambiguation scoring - //LOG.info("\t>> Disambiguation-LEARN, position at (" + entity_row + "," + entity_column + ") candidates=" + candidates.size()); + //log.info("\t>> Disambiguation-LEARN, position at (" + entity_row + "," + entity_column + ") candidates=" + candidates.size()); TCell cell = table.getContentCell(row, column); List candidates = kbSearch.findEntityCandidates(cell.getText()); LOG.info("\t\t>> position at (" + row + "," + column + ") " + diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTaggerImpl.java b/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTaggerImpl.java index 1c89316c..3abefcf6 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTaggerImpl.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTaggerImpl.java @@ -30,7 +30,7 @@ public void annotate(Table table, TAnnotation annotations, Integer... neColumns) Map>> relationAnnotations = annotations.getCellcellRelations(); - //LOG.info("\t>> Annotating literal columns"); + //log.info("\t>> Annotating literal columns"); for (Map.Entry>> e : relationAnnotations.entrySet()) { RelationColumns subcol_objcol = e.getKey(); diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TCellDisambiguator.java b/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TCellDisambiguator.java index 3bea1110..4c7fd29c 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TCellDisambiguator.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TCellDisambiguator.java @@ -72,7 +72,7 @@ public List>> disambiguate(List candida List entity_rows, int entity_column ) throws KBSearchException { //do disambiguation scoring - //LOG.info("\t>> Disambiguation-LEARN, position at (" + entity_row + "," + entity_column + ") candidates=" + candidates.size()); + //log.info("\t>> Disambiguation-LEARN, position at (" + entity_row + "," + entity_column + ") candidates=" + candidates.size()); TCell sample_tcc = table.getContentCell(entity_rows.get(0), entity_column); List>> disambiguationScores = new ArrayList<>(); for (Entity c : candidates) { diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/experiment/BaselineBatch.java b/core/src/main/java/uk/ac/shef/dcs/sti/experiment/BaselineBatch.java index 50f3eb1a..f7245398 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/experiment/BaselineBatch.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/experiment/BaselineBatch.java @@ -109,7 +109,7 @@ protected void initComponents() throws STIException { , e); } - //LOG.info("Initializing WebSearcher..."); + //log.info("Initializing WebSearcher..."); LOG.info("Initializing SUBJECT COLUMN DETECTION components ..."); diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/experiment/TableMinerPlusBatch.java b/core/src/main/java/uk/ac/shef/dcs/sti/experiment/TableMinerPlusBatch.java index c8715cdb..0b240378 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/experiment/TableMinerPlusBatch.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/experiment/TableMinerPlusBatch.java @@ -61,7 +61,7 @@ protected void initComponents() throws STIException { , e); } - //LOG.info("Initializing WebSearcher..."); + //log.info("Initializing WebSearcher..."); LOG.info("Initializing SUBJECT COLUMN DETECTION components ..."); diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/FreebaseTypeGranularityPopulator.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/FreebaseTypeGranularityPopulator.java index 64d96d0a..669adee7 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/FreebaseTypeGranularityPopulator.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/FreebaseTypeGranularityPopulator.java @@ -1,6 +1,8 @@ package uk.ac.shef.dcs.sti.todo; import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; + +import uk.ac.shef.dcs.kbsearch.KBSearch; import uk.ac.shef.dcs.kbsearch.KBSearchException; import uk.ac.shef.dcs.kbsearch.freebase.FreebaseSearch; import uk.ac.shef.dcs.sti.util.FileUtils; @@ -74,7 +76,7 @@ public static void main(String[] args) throws IOException, ClassNotFoundExceptio Properties properties = new Properties(); properties.load(new FileReader(new File(args[2]))); - FreebaseSearch kbSeacher = + KBSearch kbSeacher = new FreebaseSearch(properties, true, null, serverConcept, serverProperty,null); //kbSeacher.find_triplesForProperty("/award/award_category/nomination_announcement"); diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_Analysis_Generic.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_Analysis_Generic.java index 45a8b2f4..b2d0aa6d 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_Analysis_Generic.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_Analysis_Generic.java @@ -2,8 +2,9 @@ import info.aduna.io.FileUtil; import org.xml.sax.SAXException; + +import uk.ac.shef.dcs.kbsearch.KBSearch; import uk.ac.shef.dcs.kbsearch.KBSearchException; -import uk.ac.shef.dcs.kbsearch.freebase.FreebaseSearch; import uk.ac.shef.dcs.kbsearch.model.Attribute; import uk.ac.shef.dcs.kbsearch.model.Entity; import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; @@ -229,7 +230,7 @@ public static void calculate_different_accuracy_between(String analysis_file_fol public static void find_discrepancies_between( String gs_entity_annotation_folder, String out_folder, - FreebaseSearch searcher, + KBSearch searcher, Map result_annotation_folders_to_consider) throws IOException, KBSearchException, ParserConfigurationException, SAXException { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_btw_Baseline_Tm_Finder.java b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_btw_Baseline_Tm_Finder.java index 4ac24f6a..6044f94b 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_btw_Baseline_Tm_Finder.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_btw_Baseline_Tm_Finder.java @@ -2,7 +2,8 @@ import info.aduna.io.FileUtil; import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; -import uk.ac.shef.dcs.kbsearch.freebase.FreebaseSearch; + +import uk.ac.shef.dcs.kbsearch.KBSearch; import uk.ac.shef.dcs.kbsearch.model.Attribute; import uk.ac.shef.dcs.kbsearch.model.Entity; import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; @@ -29,7 +30,7 @@ public static void main(String[] args) throws IOException { //object to fetch things from KB String freebaseProperties = "D:\\Work\\lodiecrawler\\src\\main\\java/freebase.properties"; //todo: this will not work - FreebaseSearch freebaseMatcher = null;//new FreebaseSearch(freebaseProperties, true, server, null,null); + KBSearch freebaseMatcher = null;//new FreebaseSearch(freebaseProperties, true, server, null,null); find_discrepancies_between( "E:\\Data\\table annotation\\corpus_analysis\\100_tables\\tableminer_aclshort_no_ref_ent", @@ -166,7 +167,7 @@ public static void find_discrepancies_between( String inFolder_tableminer, String inFolder_baseline, String outFolder, - FreebaseSearch searcher) throws IOException { + KBSearch searcher) throws IOException { for (File tableminer_entity_file : new File(inFolder_tableminer).listFiles()) { Map>> tableminer_cells = null, baseline_cells = null; diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsvConfig.java b/core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsvConfig.java index 12b6a57d..9907dca7 100644 --- a/core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsvConfig.java +++ b/core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsvConfig.java @@ -53,11 +53,11 @@ public ParserCsvConfig(String quoteChar, String delimiterChar, } // if (encoding == null) { // this.encoding = "UTF-8"; - // LOG.warn("Property encoding is not set, '{}' is used as default.", + // log.warn("Property encoding is not set, '{}' is used as default.", // this.encoding); // } else { // this.encoding = encoding; - // LOG.info("Encoding is: " + encoding); + // log.info("Encoding is: " + encoding); // } if (numberOfStartLinesToIgnore == null) { this.numberOfStartLinesToIgnore = 0; diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearch.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearch.java index 151392bd..d2a6322f 100644 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearch.java +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearch.java @@ -26,10 +26,13 @@ public abstract class KBSearch { protected static final String KB_SEARCH_RESULT_STOPLIST="kb.search.result.stoplistfile"; protected static final String KB_SEARCH_CLASS = "kb.search.class"; protected static final String KB_SEARCH_TRY_FUZZY_KEYWORD = "kb.search.tryfuzzykeyword"; + + protected static final boolean AUTO_COMMIT = true; + protected static final boolean ALWAYS_CALL_REMOTE_SEARCHAPI = false; protected KBSearchResultFilter resultFilter; - private static final Logger LOG = Logger.getLogger(KBSearch.class.getName()); + protected final Logger log = Logger.getLogger(getClass()); /** * @@ -134,14 +137,14 @@ public void cacheEntityClazzSimilarity(String entity_id, String clazz_url, doubl String query = createSolrCacheQuery_findEntityClazzSimilarity(entity_id, clazz_url); try { cacheSimilarity.cache(query, score, commit); - LOG.debug("QUERY (entity-clazz similarity, cache saving)=" + query + "|" + query); + log.debug("QUERY (entity-clazz similarity, cache saving)=" + query + "|" + query); if (biDirectional) { query = clazz_url + "<>" + entity_id; cacheSimilarity.cache(query, score, commit); - LOG.debug("QUERY (entity-clazz similarity, cache saving)=" + query + "|" + query); + log.debug("QUERY (entity-clazz similarity, cache saving)=" + query + "|" + query); } } catch (Exception e) { - LOG.error(e.getLocalizedMessage(), e); + log.error(e.getLocalizedMessage(), e); } } diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearch.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearch.java index 7dff8b4c..26faec20 100644 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearch.java +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearch.java @@ -20,13 +20,8 @@ */ public class FreebaseSearch extends KBSearch { - private static final Logger LOG = Logger.getLogger(FreebaseSearch.class.getName()); - private static final boolean AUTO_COMMIT = true; - - //two propperties for debugging purposes.In practice both should be false. set to true - //if you want to deliberately trigger calls to FB apis - private static final boolean ALWAYS_CALL_REMOTE_SEARCHAPI = false; private static final boolean ALWAYS_CALL_REMOTE_TOPICAPI = false; + private FreebaseQueryProxy searcher; public FreebaseSearch(Properties properties, Boolean fuzzyKeywords, @@ -81,7 +76,7 @@ private List find_matchingEntitiesForTextAndType(String text, String... try { result = (List) cacheEntity.retrieve(query); if (result != null) - LOG.debug("QUERY (entities, cache load)=" + query + "|" + query); + log.debug("QUERY (entities, cache load)=" + query + "|" + query); } catch (Exception e) { } } @@ -90,7 +85,7 @@ private List find_matchingEntitiesForTextAndType(String text, String... try { //firstly fetch candidate freebase topics. pass 'true' to only keep candidates whose name overlap with the query term List topics = searcher.searchapi_getTopicsByNameAndType(text, "any", true, 20); //search api does not retrieve complete types, find types for them - LOG.debug("(FB QUERY =" +topics.size()+" results)"); + log.debug("(FB QUERY =" +topics.size()+" results)"); for (FreebaseTopic ec : topics) { //Next get attributes for each topic List attributes = findAttributesOfEntities(ec); @@ -126,7 +121,7 @@ private List find_matchingEntitiesForTextAndType(String text, String... result.addAll(topics); cacheEntity.cache(query, result, AUTO_COMMIT); - LOG.debug("QUERY (entities, cache save)=" + query + "|" + query); + log.debug("QUERY (entities, cache save)=" + query + "|" + query); } catch (Exception e) { throw new KBSearchException(e); } @@ -181,7 +176,7 @@ public List findAttributesOfClazz(String clazz) throws KBSearchExcept try { attributes = (List) cacheConcept.retrieve(query); if (attributes != null) - LOG.debug("QUERY (attributes of clazz, cache load)=" + query + "|" + query); + log.debug("QUERY (attributes of clazz, cache load)=" + query + "|" + query); } catch (Exception e) { } @@ -201,7 +196,7 @@ public List findAttributesOfClazz(String clazz) throws KBSearchExcept if (!isConcept) { try { cacheConcept.cache(query, attributes, AUTO_COMMIT); - LOG.debug("QUERY (attributes of clazz, cache save)=" + query + "|" + query); + log.debug("QUERY (attributes of clazz, cache save)=" + query + "|" + query); } catch (Exception e) { e.printStackTrace(); } @@ -231,7 +226,7 @@ public List findAttributesOfClazz(String clazz) throws KBSearchExcept } cacheConcept.cache(query, attributes, AUTO_COMMIT); - LOG.debug("QUERY (attributes of clazz, cache save)=" + query + "|" + query); + log.debug("QUERY (attributes of clazz, cache save)=" + query + "|" + query); } catch (Exception e) { throw new KBSearchException(e); } @@ -251,7 +246,7 @@ public double findGranularityOfClazz(String clazz) throws KBSearchException { try { Object o = cacheConcept.retrieve(query); if (o != null) { - LOG.debug("QUERY (granularity of clazz, cache load)=" + query + "|" + clazz); + log.debug("QUERY (granularity of clazz, cache load)=" + query + "|" + clazz); return (Double) o; } } catch (Exception e) { @@ -263,13 +258,13 @@ public double findGranularityOfClazz(String clazz) throws KBSearchException { result = granularity; try { cacheConcept.cache(query, result, AUTO_COMMIT); - LOG.debug("QUERY (granularity of clazz, cache save)=" + query + "|" + clazz); + log.debug("QUERY (granularity of clazz, cache save)=" + query + "|" + clazz); } catch (Exception e) { - LOG.error("FAILED:" + clazz); + log.error("FAILED:" + clazz); e.printStackTrace(); } } catch (IOException ioe) { - LOG.error("ERROR(Instances of Type): Unable to fetch freebase page of instances of type: " + clazz); + log.error("ERROR(Instances of Type): Unable to fetch freebase page of instances of type: " + clazz); } } if (result == null) @@ -285,7 +280,7 @@ public double findEntityClazzSimilarity(String id1, String clazz_url) { try { result = cacheSimilarity.retrieve(query); if (result != null) - LOG.debug("QUERY (entity-clazz similarity, cache load)=" + query + "|" + query); + log.debug("QUERY (entity-clazz similarity, cache load)=" + query + "|" + query); } catch (Exception e) { } if (result == null) @@ -307,7 +302,7 @@ private List find_attributes(String id, SolrCache cache) throws KBSea try { result = (List) cache.retrieve(query); if (result != null) - LOG.debug("QUERY (attributes of id, cache load)=" + query + "|" + query); + log.debug("QUERY (attributes of id, cache load)=" + query + "|" + query); } catch (Exception e) { } if (result == null || forceQuery) { @@ -324,7 +319,7 @@ private List find_attributes(String id, SolrCache cache) throws KBSea result.addAll(attributes); try { cache.cache(query, result, AUTO_COMMIT); - LOG.debug("QUERY (attributes of id, cache save)=" + query + "|" + query); + log.debug("QUERY (attributes of id, cache save)=" + query + "|" + query); } catch (Exception e) { e.printStackTrace(); } diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearch.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearch.java index 1473dcd7..2424989a 100644 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearch.java +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearch.java @@ -1,19 +1,12 @@ package uk.ac.shef.dcs.kbsearch.sparql; -import javafx.util.Pair; -import org.apache.commons.lang3.StringEscapeUtils; import org.apache.jena.ontology.OntModel; import org.apache.jena.ontology.OntModelSpec; import org.apache.jena.query.*; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.RDFNode; -import org.apache.log4j.Logger; import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; import uk.ac.shef.dcs.kbsearch.KBSearchException; -import uk.ac.shef.dcs.kbsearch.model.Attribute; -import uk.ac.shef.dcs.kbsearch.model.Clazz; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.util.SolrCache; import uk.ac.shef.dcs.util.StringUtils; import java.io.IOException; @@ -24,10 +17,6 @@ */ public class DBpediaSearch extends SPARQLSearch { - private static final boolean ALWAYS_CALL_REMOTE_SEARCHAPI = false; - private static final Logger LOG = Logger.getLogger(DBpediaSearch.class.getName()); - private static final boolean AUTO_COMMIT = true; - private static final String DBP_SPARQL_ENDPOINT = "dbp.sparql.endpoint"; private static final String DBP_ONTOLOGY_URL = "dbp.ontology.url"; @@ -62,306 +51,7 @@ private OntModel loadModel(String ontURL) { return ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF, base); } - @Override - @SuppressWarnings("unchecked") - public List findEntityCandidates(String content) throws KBSearchException { - String query = createSolrCacheQuery_findResources(content); - - content = StringEscapeUtils.unescapeXml(content); - int bracket = content.indexOf("("); - if (bracket != -1) { - content = content.substring(0, bracket).trim(); - } - if (StringUtils.toAlphaNumericWhitechar(content).trim().length() == 0) - return new ArrayList<>(); - - - List result = null; - if (!ALWAYS_CALL_REMOTE_SEARCHAPI) { - try { - result = (List) cacheEntity.retrieve(query); - if (result != null) - LOG.debug("QUERY (entities, cache load)=" + query + "|" + query); - } catch (Exception e) { - LOG.error(e.getLocalizedMessage(),e); - } - } - if (result == null) { - result = new ArrayList<>(); - try { - //1. try exact string - String sparqlQuery = createExactMatchQueries(content); - List> queryResult = queryByLabel(sparqlQuery, content); - - //2. if result is empty, try regex - if (queryResult.size() == 0 && fuzzyKeywords) { - LOG.debug("(query by regex. This can take a long time)"); - sparqlQuery = createRegexQuery(content); - queryResult = queryByLabel(sparqlQuery, content); - } - //3. rank result by the degree of matches - rank(queryResult, content); - - //get attributes for each resource - LOG.debug("(QUERY =" + queryResult.size() + " results)"); - for (Pair candidate : queryResult) { - String label = candidate.getValue(); - if (label == null) - label = content; - Entity ec = new Entity(candidate.getKey(), label); - List attributes = findAttributesOfEntities(ec); - ec.setAttributes(attributes); - for (Attribute attr : attributes) { - adjustValueOfURLResource(attr); - if (attr.getRelationURI().endsWith(RDFEnum.RELATION_HASTYPE_SUFFIX_PATTERN.getString()) && - !ec.hasType(attr.getValueURI())) { - ec.addType(new Clazz(attr.getValueURI(), attr.getValue())); - } - } - result.add(ec); - } - - cacheEntity.cache(query, result, AUTO_COMMIT); - LOG.debug("QUERY (entities, cache save)=" + query + "|" + query); - } catch (Exception e) { - throw new KBSearchException(e); - } - } - - //filter entity's clazz, and attributes - String id = "|"; - for (Entity ec : result) { - id = id + ec.getId() + ","; - //ec.setTypes(FreebaseSearchResultFilter.filterClazz(ec.getTypes())); - List filteredTypes = resultFilter.filterClazz(ec.getTypes()); - ec.clearTypes(); - for (Clazz ft : filteredTypes) - ec.addType(ft); - } - - return result; - } - - @Override - @SuppressWarnings("unchecked") - public List findEntityCandidatesOfTypes(String content, String... types) throws KBSearchException { - String queryCache = createSolrCacheQuery_findResources(content); - - content = StringEscapeUtils.unescapeXml(content); - int bracket = content.indexOf("("); - if (bracket != -1) { - content = content.substring(0, bracket).trim(); - } - if (StringUtils.toAlphaNumericWhitechar(content).trim().length() == 0) - return new ArrayList<>(); - - - List result = null; - if (!ALWAYS_CALL_REMOTE_SEARCHAPI) { - try { - result = (List) cacheEntity.retrieve(queryCache); - if (result != null) { - LOG.debug("QUERY (entities, cache load)=" + queryCache + "|" + queryCache); - if (types.length > 0) { - Iterator it = result.iterator(); - while (it.hasNext()) { - Entity ec = it.next(); - boolean typeSatisfied = false; - for (String t : types) { - if (ec.hasType(t)) { - typeSatisfied = true; - break; - } - } - if (!typeSatisfied) - it.remove(); - } - } - } - } catch (Exception e) { - LOG.error(e.getLocalizedMessage(),e); - } - } - if (result == null) { - result = new ArrayList<>(); - try { - //1. try exact string - String sparqlQuery = createExactMatchWithOptionalTypes(content); - List> resourceAndType = queryByLabel(sparqlQuery, content); - boolean hasExactMatch = resourceAndType.size() > 0; - if (types.length > 0) { - Iterator> it = resourceAndType.iterator(); - while (it.hasNext()) { - Pair ec = it.next(); - boolean typeSatisfied = false; - for (String t : types) { - if (t.equals(ec.getValue())) { - typeSatisfied = true; - break; - } - } - if (!typeSatisfied) - it.remove(); - } - }//with this query the 'value' of the pair will be the type, now need to reset it to actual value - List> queryResult = new ArrayList<>(); - if (resourceAndType.size() > 0) { - Pair matchedResource = resourceAndType.get(0); - queryResult.add(new Pair<>(matchedResource.getKey(), content)); - } - - //2. if result is empty, try regex - if (!hasExactMatch && fuzzyKeywords) { - LOG.debug("(query by regex. This can take a long time)"); - sparqlQuery = createRegexQuery(content, types); - queryResult = queryByLabel(sparqlQuery, content); - } - //3. rank result by the degree of matches - rank(queryResult, content); - - //firstly fetch candidate freebase topics. pass 'true' to only keep candidates whose name overlap with the query term - LOG.debug("(DB QUERY =" + queryResult.size() + " results)"); - for (Pair candidate : queryResult) { - //Next get attributes for each topic - String label = candidate.getValue(); - if (label == null) - label = content; - Entity ec = new Entity(candidate.getKey(), label); - List attributes = findAttributesOfEntities(ec); - ec.setAttributes(attributes); - for (Attribute attr : attributes) { - adjustValueOfURLResource(attr); - if (attr.getRelationURI().endsWith(RDFEnum.RELATION_HASTYPE_SUFFIX_PATTERN.getString()) && - !ec.hasType(attr.getValueURI())) { - ec.addType(new Clazz(attr.getValueURI(), attr.getValue())); - } - } - result.add(ec); - } - - cacheEntity.cache(queryCache, result, AUTO_COMMIT); - LOG.debug("QUERY (entities, cache save)=" + queryCache + "|" + queryCache); - } catch (Exception e) { - throw new KBSearchException(e); - } - } - - //filter entity's clazz, and attributes - String id = "|"; - for (Entity ec : result) { - id = id + ec.getId() + ","; - //ec.setTypes(FreebaseSearchResultFilter.filterClazz(ec.getTypes())); - List filteredTypes = resultFilter.filterClazz(ec.getTypes()); - ec.clearTypes(); - for (Clazz ft : filteredTypes) - ec.addType(ft); - } - - return result; - } - - // if the attribute's value is an URL, fetch the label of that resource, and reset its attr value - private void adjustValueOfURLResource(Attribute attr) throws KBSearchException { - String value = attr.getValue(); - if (value.startsWith("http")) { - String queryCache = createSolrCacheQuery_findLabelForResource(value); - - - List result = null; - if (!ALWAYS_CALL_REMOTE_SEARCHAPI) { - try { - result = (List) cacheEntity.retrieve(queryCache); - if (result != null) { - LOG.debug("QUERY (resource labels, cache load)=" + queryCache + "|" + queryCache); - } - } catch (Exception e) { - } - } - if (result == null) { - try { - //1. try exact string - String sparqlQuery = createGetLabelQuery(value); - result = queryForLabel(sparqlQuery, value); - - cacheEntity.cache(queryCache, result, AUTO_COMMIT); - LOG.debug("QUERY (entities, cache save)=" + queryCache + "|" + queryCache); - } catch (Exception e) { - throw new KBSearchException(e); - } - } - - if (result.size() > 0) { - attr.setValueURI(value); - attr.setValue(result.get(0)); - } else { - attr.setValueURI(value); - } - } - } - - @Override - public List findAttributesOfEntities(Entity ec) throws KBSearchException { - return findAttributes(ec.getId(), cacheEntity); - } - - private List findAttributes(String id, SolrCache cache) throws KBSearchException { - if (id.length() == 0) - return new ArrayList<>(); - - String queryCache = createSolrCacheQuery_findAttributesOfResource(id); - List result = null; - if (!ALWAYS_CALL_REMOTE_SEARCHAPI) { - try { - result = (List) cache.retrieve(queryCache); - if (result != null) - LOG.debug("QUERY (attributes of id, cache load)=" + queryCache + "|" + queryCache); - } catch (Exception e) { - LOG.error(e.getLocalizedMessage(), e); - } - } - - if (result == null) { - result = new ArrayList<>(); - String query = "SELECT DISTINCT ?p ?o WHERE {\n" + - "<" + id + "> ?p ?o .\n" + - "}"; - - Query sparqlQuery = QueryFactory.create(query); - QueryExecution qexec = QueryExecutionFactory.sparqlService(sparqlEndpoint, sparqlQuery); - - ResultSet rs = qexec.execSelect(); - while (rs.hasNext()) { - QuerySolution qs = rs.next(); - RDFNode predicate = qs.get("?p"); - RDFNode object = qs.get("?o"); - if (object != null) { - Attribute attr = new DBpediaAttribute(predicate.toString(), object.toString()); - result.add(attr); - } - } - - try { - cache.cache(queryCache, result, AUTO_COMMIT); - LOG.debug("QUERY (attributes of id, cache save)=" + query + "|" + query); - } catch (Exception e) { - LOG.error(e.getLocalizedMessage(), e); - } - } - - //filtering - result = resultFilter.filterAttribute(result); - return result; - } - - @Override - public List findAttributesOfClazz(String clazzId) throws KBSearchException { - return findAttributes(clazzId, cacheEntity); - } - - @Override - public List findAttributesOfProperty(String propertyId) throws KBSearchException { - return findAttributes(propertyId, cacheEntity); - } + // @Override // public double findGranularityOfClazz(String clazz) throws KBSearchException { @@ -378,10 +68,6 @@ public List findAttributesOfProperty(String propertyId) throws KBSear // } - protected String createSolrCacheQuery_findLabelForResource(String url) { - return "LABEL_" + url; - } - @Override protected List queryForLabel(String sparqlQuery, String resourceURI) throws KBSearchException { try { diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLSearch.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLSearch.java index 5a0d4b15..7e748b41 100644 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLSearch.java +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLSearch.java @@ -1,13 +1,21 @@ package uk.ac.shef.dcs.kbsearch.sparql; import javafx.util.Pair; + +import org.apache.commons.lang3.StringEscapeUtils; import org.apache.jena.query.*; import org.apache.jena.rdf.model.RDFNode; +import org.apache.log4j.Logger; import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; import org.simmetrics.StringMetric; import org.simmetrics.metrics.Levenshtein; import uk.ac.shef.dcs.kbsearch.KBSearch; import uk.ac.shef.dcs.kbsearch.KBSearchException; +import uk.ac.shef.dcs.kbsearch.model.Attribute; +import uk.ac.shef.dcs.kbsearch.model.Clazz; +import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.util.SolrCache; +import uk.ac.shef.dcs.util.StringUtils; import java.io.IOException; import java.util.*; @@ -33,7 +41,7 @@ */ public abstract class SPARQLSearch extends KBSearch { - protected String sparqlEndpoint; + protected String sparqlEndpoint; protected StringMetric stringMetric = new Levenshtein(); /** @@ -149,4 +157,308 @@ protected void rank(List> candidates, String originalQueryL return s2.compareTo(s1); }); } + + @Override + @SuppressWarnings("unchecked") + public List findEntityCandidates(String content) throws KBSearchException { + String query = createSolrCacheQuery_findResources(content); + + content = StringEscapeUtils.unescapeXml(content); + int bracket = content.indexOf("("); + if (bracket != -1) { + content = content.substring(0, bracket).trim(); + } + if (StringUtils.toAlphaNumericWhitechar(content).trim().length() == 0) + return new ArrayList<>(); + + + List result = null; + if (!ALWAYS_CALL_REMOTE_SEARCHAPI) { + try { + result = (List) cacheEntity.retrieve(query); + if (result != null) + log.debug("QUERY (entities, cache load)=" + query + "|" + query); + } catch (Exception e) { + log.error(e.getLocalizedMessage(),e); + } + } + if (result == null) { + result = new ArrayList<>(); + try { + //1. try exact string + String sparqlQuery = createExactMatchQueries(content); + List> queryResult = queryByLabel(sparqlQuery, content); + + //2. if result is empty, try regex + if (queryResult.size() == 0 && fuzzyKeywords) { + log.debug("(query by regex. This can take a long time)"); + sparqlQuery = createRegexQuery(content); + queryResult = queryByLabel(sparqlQuery, content); + } + //3. rank result by the degree of matches + rank(queryResult, content); + + //get attributes for each resource + log.debug("(QUERY =" + queryResult.size() + " results)"); + for (Pair candidate : queryResult) { + String label = candidate.getValue(); + if (label == null) + label = content; + Entity ec = new Entity(candidate.getKey(), label); + List attributes = findAttributesOfEntities(ec); + ec.setAttributes(attributes); + for (Attribute attr : attributes) { + adjustValueOfURLResource(attr); + if (attr.getRelationURI().endsWith(RDFEnum.RELATION_HASTYPE_SUFFIX_PATTERN.getString()) && + !ec.hasType(attr.getValueURI())) { + ec.addType(new Clazz(attr.getValueURI(), attr.getValue())); + } + } + result.add(ec); + } + + cacheEntity.cache(query, result, AUTO_COMMIT); + log.debug("QUERY (entities, cache save)=" + query + "|" + query); + } catch (Exception e) { + throw new KBSearchException(e); + } + } + + //filter entity's clazz, and attributes + String id = "|"; + for (Entity ec : result) { + id = id + ec.getId() + ","; + //ec.setTypes(FreebaseSearchResultFilter.filterClazz(ec.getTypes())); + List filteredTypes = resultFilter.filterClazz(ec.getTypes()); + ec.clearTypes(); + for (Clazz ft : filteredTypes) + ec.addType(ft); + } + + return result; + } + + @Override + @SuppressWarnings("unchecked") + public List findEntityCandidatesOfTypes(String content, String... types) throws KBSearchException { + String queryCache = createSolrCacheQuery_findResources(content); + + content = StringEscapeUtils.unescapeXml(content); + int bracket = content.indexOf("("); + if (bracket != -1) { + content = content.substring(0, bracket).trim(); + } + if (StringUtils.toAlphaNumericWhitechar(content).trim().length() == 0) + return new ArrayList<>(); + + + List result = null; + if (!ALWAYS_CALL_REMOTE_SEARCHAPI) { + try { + result = (List) cacheEntity.retrieve(queryCache); + if (result != null) { + log.debug("QUERY (entities, cache load)=" + queryCache + "|" + queryCache); + if (types.length > 0) { + Iterator it = result.iterator(); + while (it.hasNext()) { + Entity ec = it.next(); + boolean typeSatisfied = false; + for (String t : types) { + if (ec.hasType(t)) { + typeSatisfied = true; + break; + } + } + if (!typeSatisfied) + it.remove(); + } + } + } + } catch (Exception e) { + log.error(e.getLocalizedMessage(),e); + } + } + if (result == null) { + result = new ArrayList<>(); + try { + //1. try exact string + String sparqlQuery = createExactMatchWithOptionalTypes(content); + List> resourceAndType = queryByLabel(sparqlQuery, content); + boolean hasExactMatch = resourceAndType.size() > 0; + if (types.length > 0) { + Iterator> it = resourceAndType.iterator(); + while (it.hasNext()) { + Pair ec = it.next(); + boolean typeSatisfied = false; + for (String t : types) { + if (t.equals(ec.getValue())) { + typeSatisfied = true; + break; + } + } + if (!typeSatisfied) + it.remove(); + } + }//with this query the 'value' of the pair will be the type, now need to reset it to actual value + List> queryResult = new ArrayList<>(); + if (resourceAndType.size() > 0) { + Pair matchedResource = resourceAndType.get(0); + queryResult.add(new Pair<>(matchedResource.getKey(), content)); + } + + //2. if result is empty, try regex + if (!hasExactMatch && fuzzyKeywords) { + log.debug("(query by regex. This can take a long time)"); + sparqlQuery = createRegexQuery(content, types); + queryResult = queryByLabel(sparqlQuery, content); + } + //3. rank result by the degree of matches + rank(queryResult, content); + + //firstly fetch candidate freebase topics. pass 'true' to only keep candidates whose name overlap with the query term + log.debug("(DB QUERY =" + queryResult.size() + " results)"); + for (Pair candidate : queryResult) { + //Next get attributes for each topic + String label = candidate.getValue(); + if (label == null) + label = content; + Entity ec = new Entity(candidate.getKey(), label); + List attributes = findAttributesOfEntities(ec); + ec.setAttributes(attributes); + for (Attribute attr : attributes) { + adjustValueOfURLResource(attr); + if (attr.getRelationURI().endsWith(RDFEnum.RELATION_HASTYPE_SUFFIX_PATTERN.getString()) && + !ec.hasType(attr.getValueURI())) { + ec.addType(new Clazz(attr.getValueURI(), attr.getValue())); + } + } + result.add(ec); + } + + cacheEntity.cache(queryCache, result, AUTO_COMMIT); + log.debug("QUERY (entities, cache save)=" + queryCache + "|" + queryCache); + } catch (Exception e) { + throw new KBSearchException(e); + } + } + + //filter entity's clazz, and attributes + String id = "|"; + for (Entity ec : result) { + id = id + ec.getId() + ","; + //ec.setTypes(FreebaseSearchResultFilter.filterClazz(ec.getTypes())); + List filteredTypes = resultFilter.filterClazz(ec.getTypes()); + ec.clearTypes(); + for (Clazz ft : filteredTypes) + ec.addType(ft); + } + + return result; + } + + private void adjustValueOfURLResource(Attribute attr) throws KBSearchException { + String value = attr.getValue(); + if (value.startsWith("http")) { + String queryCache = createSolrCacheQuery_findLabelForResource(value); + + + List result = null; + if (!ALWAYS_CALL_REMOTE_SEARCHAPI) { + try { + result = (List) cacheEntity.retrieve(queryCache); + if (result != null) { + log.debug("QUERY (resource labels, cache load)=" + queryCache + "|" + queryCache); + } + } catch (Exception e) { + } + } + if (result == null) { + try { + //1. try exact string + String sparqlQuery = createGetLabelQuery(value); + result = queryForLabel(sparqlQuery, value); + + cacheEntity.cache(queryCache, result, AUTO_COMMIT); + log.debug("QUERY (entities, cache save)=" + queryCache + "|" + queryCache); + } catch (Exception e) { + throw new KBSearchException(e); + } + } + + if (result.size() > 0) { + attr.setValueURI(value); + attr.setValue(result.get(0)); + } else { + attr.setValueURI(value); + } + } + } + + @Override + public List findAttributesOfEntities(Entity ec) throws KBSearchException { + return findAttributes(ec.getId(), cacheEntity); + } + + private List findAttributes(String id, SolrCache cache) throws KBSearchException { + if (id.length() == 0) + return new ArrayList<>(); + + String queryCache = createSolrCacheQuery_findAttributesOfResource(id); + List result = null; + if (!ALWAYS_CALL_REMOTE_SEARCHAPI) { + try { + result = (List) cache.retrieve(queryCache); + if (result != null) + log.debug("QUERY (attributes of id, cache load)=" + queryCache + "|" + queryCache); + } catch (Exception e) { + log.error(e.getLocalizedMessage(), e); + } + } + + if (result == null) { + result = new ArrayList<>(); + String query = "SELECT DISTINCT ?p ?o WHERE {\n" + + "<" + id + "> ?p ?o .\n" + + "}"; + + Query sparqlQuery = QueryFactory.create(query); + QueryExecution qexec = QueryExecutionFactory.sparqlService(sparqlEndpoint, sparqlQuery); + + ResultSet rs = qexec.execSelect(); + while (rs.hasNext()) { + QuerySolution qs = rs.next(); + RDFNode predicate = qs.get("?p"); + RDFNode object = qs.get("?o"); + if (object != null) { + Attribute attr = new DBpediaAttribute(predicate.toString(), object.toString()); + result.add(attr); + } + } + + try { + cache.cache(queryCache, result, AUTO_COMMIT); + log.debug("QUERY (attributes of id, cache save)=" + query + "|" + query); + } catch (Exception e) { + log.error(e.getLocalizedMessage(), e); + } + } + + //filtering + result = resultFilter.filterAttribute(result); + return result; + } + + @Override + public List findAttributesOfClazz(String clazzId) throws KBSearchException { + return findAttributes(clazzId, cacheEntity); + } + + @Override + public List findAttributesOfProperty(String propertyId) throws KBSearchException { + return findAttributes(propertyId, cacheEntity); + } + + protected String createSolrCacheQuery_findLabelForResource(String url) { + return "LABEL_" + url; + } } diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/TableMinerPlusFactory.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/TableMinerPlusFactory.java index 8594c596..32a8a809 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/TableMinerPlusFactory.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/TableMinerPlusFactory.java @@ -151,7 +151,7 @@ private void initComponents() throws STIException, IOException { "Failed initialising KBSearch:" + getAbsolutePath(PROPERTY_KBSEARCH_PROP_FILE), e); } - // LOG.info("Initializing WebSearcher..."); + // log.info("Initializing WebSearcher..."); logger.info("Initializing SUBJECT COLUMN DETECTION components ..."); From 50af2b583595f731e9ec8666859092a9ffbd9bee Mon Sep 17 00:00:00 2001 From: brodecva Date: Wed, 27 Jul 2016 13:49:36 +0200 Subject: [PATCH 062/211] Code duplication removal. --- ...diaAttribute.java => SPARQLAttribute.java} | 4 +- .../dcs/kbsearch/sparql/SPARQLSearch.java | 327 +++++++----------- 2 files changed, 129 insertions(+), 202 deletions(-) rename kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/{DBpediaAttribute.java => SPARQLAttribute.java} (91%) diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaAttribute.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLAttribute.java similarity index 91% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaAttribute.java rename to kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLAttribute.java index 773c6c63..d32ce57f 100644 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaAttribute.java +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLAttribute.java @@ -8,9 +8,9 @@ * TODO no need for this class, alias predicates, description predicates can be stored in config. * */ -public class DBpediaAttribute extends Attribute { +public class SPARQLAttribute extends Attribute { - public DBpediaAttribute(String relationURI, String value) { + public SPARQLAttribute(String relationURI, String value) { super(relationURI, value); } diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLSearch.java b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLSearch.java index 7e748b41..c8ee5355 100644 --- a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLSearch.java +++ b/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLSearch.java @@ -63,14 +63,6 @@ public SPARQLSearch(String sparqlEndpoint, Boolean fuzzyKeywords, this.sparqlEndpoint=sparqlEndpoint; } - protected String createRegexQuery(String content){ - //the query is using word boundary. Is it supported on all SPARQL endpoints? - String query = "SELECT DISTINCT ?s ?o WHERE {"+ - "?s <"+RDFEnum.RELATION_HASLABEL.getString()+"> ?o ."+ - "FILTER ( regex (str(?o), \"\\b"+content+"\\b\", \"i\") ) }"; - return query; - } - protected String createRegexQuery(String content, String... types){ StringBuilder query = new StringBuilder("SELECT DISTINCT ?s ?o WHERE {").append( "?s <").append(RDFEnum.RELATION_HASLABEL.getString()).append("> ?o .").append("\n"); @@ -101,7 +93,7 @@ protected String createExactMatchWithOptionalTypes(String content){ return query; } - + protected String createGetLabelQuery(String content){ content=content.replaceAll("\\s+",""); String query = "SELECT DISTINCT ?o WHERE {<"+ @@ -159,201 +151,136 @@ protected void rank(List> candidates, String originalQueryL } @Override - @SuppressWarnings("unchecked") public List findEntityCandidates(String content) throws KBSearchException { - String query = createSolrCacheQuery_findResources(content); - - content = StringEscapeUtils.unescapeXml(content); - int bracket = content.indexOf("("); - if (bracket != -1) { - content = content.substring(0, bracket).trim(); - } - if (StringUtils.toAlphaNumericWhitechar(content).trim().length() == 0) - return new ArrayList<>(); - - - List result = null; - if (!ALWAYS_CALL_REMOTE_SEARCHAPI) { - try { - result = (List) cacheEntity.retrieve(query); - if (result != null) - log.debug("QUERY (entities, cache load)=" + query + "|" + query); - } catch (Exception e) { - log.error(e.getLocalizedMessage(),e); - } - } - if (result == null) { - result = new ArrayList<>(); - try { - //1. try exact string - String sparqlQuery = createExactMatchQueries(content); - List> queryResult = queryByLabel(sparqlQuery, content); - - //2. if result is empty, try regex - if (queryResult.size() == 0 && fuzzyKeywords) { - log.debug("(query by regex. This can take a long time)"); - sparqlQuery = createRegexQuery(content); - queryResult = queryByLabel(sparqlQuery, content); - } - //3. rank result by the degree of matches - rank(queryResult, content); - - //get attributes for each resource - log.debug("(QUERY =" + queryResult.size() + " results)"); - for (Pair candidate : queryResult) { - String label = candidate.getValue(); - if (label == null) - label = content; - Entity ec = new Entity(candidate.getKey(), label); - List attributes = findAttributesOfEntities(ec); - ec.setAttributes(attributes); - for (Attribute attr : attributes) { - adjustValueOfURLResource(attr); - if (attr.getRelationURI().endsWith(RDFEnum.RELATION_HASTYPE_SUFFIX_PATTERN.getString()) && - !ec.hasType(attr.getValueURI())) { - ec.addType(new Clazz(attr.getValueURI(), attr.getValue())); - } - } - result.add(ec); - } - - cacheEntity.cache(query, result, AUTO_COMMIT); - log.debug("QUERY (entities, cache save)=" + query + "|" + query); - } catch (Exception e) { - throw new KBSearchException(e); - } - } - - //filter entity's clazz, and attributes - String id = "|"; - for (Entity ec : result) { - id = id + ec.getId() + ","; - //ec.setTypes(FreebaseSearchResultFilter.filterClazz(ec.getTypes())); - List filteredTypes = resultFilter.filterClazz(ec.getTypes()); - ec.clearTypes(); - for (Clazz ft : filteredTypes) - ec.addType(ft); - } - - return result; + return findEntityCandidatesOfTypes(content); } @Override - @SuppressWarnings("unchecked") public List findEntityCandidatesOfTypes(String content, String... types) throws KBSearchException { - String queryCache = createSolrCacheQuery_findResources(content); - - content = StringEscapeUtils.unescapeXml(content); - int bracket = content.indexOf("("); - if (bracket != -1) { - content = content.substring(0, bracket).trim(); - } - if (StringUtils.toAlphaNumericWhitechar(content).trim().length() == 0) - return new ArrayList<>(); - - - List result = null; - if (!ALWAYS_CALL_REMOTE_SEARCHAPI) { - try { - result = (List) cacheEntity.retrieve(queryCache); - if (result != null) { - log.debug("QUERY (entities, cache load)=" + queryCache + "|" + queryCache); - if (types.length > 0) { - Iterator it = result.iterator(); - while (it.hasNext()) { - Entity ec = it.next(); - boolean typeSatisfied = false; - for (String t : types) { - if (ec.hasType(t)) { - typeSatisfied = true; - break; - } - } - if (!typeSatisfied) - it.remove(); - } - } - } - } catch (Exception e) { - log.error(e.getLocalizedMessage(),e); - } - } - if (result == null) { - result = new ArrayList<>(); - try { - //1. try exact string - String sparqlQuery = createExactMatchWithOptionalTypes(content); - List> resourceAndType = queryByLabel(sparqlQuery, content); - boolean hasExactMatch = resourceAndType.size() > 0; - if (types.length > 0) { - Iterator> it = resourceAndType.iterator(); - while (it.hasNext()) { - Pair ec = it.next(); - boolean typeSatisfied = false; - for (String t : types) { - if (t.equals(ec.getValue())) { - typeSatisfied = true; - break; - } - } - if (!typeSatisfied) - it.remove(); - } - }//with this query the 'value' of the pair will be the type, now need to reset it to actual value - List> queryResult = new ArrayList<>(); - if (resourceAndType.size() > 0) { - Pair matchedResource = resourceAndType.get(0); - queryResult.add(new Pair<>(matchedResource.getKey(), content)); - } - - //2. if result is empty, try regex - if (!hasExactMatch && fuzzyKeywords) { - log.debug("(query by regex. This can take a long time)"); - sparqlQuery = createRegexQuery(content, types); - queryResult = queryByLabel(sparqlQuery, content); - } - //3. rank result by the degree of matches - rank(queryResult, content); - - //firstly fetch candidate freebase topics. pass 'true' to only keep candidates whose name overlap with the query term - log.debug("(DB QUERY =" + queryResult.size() + " results)"); - for (Pair candidate : queryResult) { - //Next get attributes for each topic - String label = candidate.getValue(); - if (label == null) - label = content; - Entity ec = new Entity(candidate.getKey(), label); - List attributes = findAttributesOfEntities(ec); - ec.setAttributes(attributes); - for (Attribute attr : attributes) { - adjustValueOfURLResource(attr); - if (attr.getRelationURI().endsWith(RDFEnum.RELATION_HASTYPE_SUFFIX_PATTERN.getString()) && - !ec.hasType(attr.getValueURI())) { - ec.addType(new Clazz(attr.getValueURI(), attr.getValue())); - } - } - result.add(ec); - } - - cacheEntity.cache(queryCache, result, AUTO_COMMIT); - log.debug("QUERY (entities, cache save)=" + queryCache + "|" + queryCache); - } catch (Exception e) { - throw new KBSearchException(e); - } - } - - //filter entity's clazz, and attributes - String id = "|"; - for (Entity ec : result) { - id = id + ec.getId() + ","; - //ec.setTypes(FreebaseSearchResultFilter.filterClazz(ec.getTypes())); - List filteredTypes = resultFilter.filterClazz(ec.getTypes()); - ec.clearTypes(); - for (Clazz ft : filteredTypes) - ec.addType(ft); - } - - return result; + final String sparqlQuery; + if (types.length > 0) { + sparqlQuery = createExactMatchQueries(content); + } else { + sparqlQuery = createExactMatchWithOptionalTypes(content); + } + + return queryEntityCandidates(content, sparqlQuery, types); + } + + private List queryEntityCandidates(String content, String sparqlQuery, String... types) + throws KBSearchException { + String queryCache = createSolrCacheQuery_findResources(content); + + content = StringEscapeUtils.unescapeXml(content); + int bracket = content.indexOf("("); + if (bracket != -1) { + content = content.substring(0, bracket).trim(); + } + if (StringUtils.toAlphaNumericWhitechar(content).trim().length() == 0) + return new ArrayList<>(); + + + List result = null; + if (!ALWAYS_CALL_REMOTE_SEARCHAPI) { + try { + result = (List) cacheEntity.retrieve(queryCache); + if (result != null) { + log.debug("QUERY (entities, cache load)=" + queryCache + "|" + queryCache); + if (types.length > 0) { + Iterator it = result.iterator(); + while (it.hasNext()) { + Entity ec = it.next(); + boolean typeSatisfied = false; + for (String t : types) { + if (ec.hasType(t)) { + typeSatisfied = true; + break; + } + } + if (!typeSatisfied) + it.remove(); + } + } + } + } catch (Exception e) { + log.error(e.getLocalizedMessage(),e); + } + } + if (result == null) { + result = new ArrayList<>(); + try { + //1. try exact string + List> resourceAndType = queryByLabel(sparqlQuery, content); + boolean hasExactMatch = resourceAndType.size() > 0; + if (types.length > 0) { + Iterator> it = resourceAndType.iterator(); + while (it.hasNext()) { + Pair ec = it.next(); + boolean typeSatisfied = false; + for (String t : types) { + if (t.equals(ec.getValue())) { + typeSatisfied = true; + break; + } + } + if (!typeSatisfied) + it.remove(); + } + }//with this query the 'value' of the pair will be the type, now need to reset it to actual value + List> queryResult = new ArrayList<>(); + if (resourceAndType.size() > 0) { + Pair matchedResource = resourceAndType.get(0); + queryResult.add(new Pair<>(matchedResource.getKey(), content)); + } + + //2. if result is empty, try regex + if (!hasExactMatch && fuzzyKeywords) { + log.debug("(query by regex. This can take a long time)"); + sparqlQuery = createRegexQuery(content, types); + queryResult = queryByLabel(sparqlQuery, content); + } + //3. rank result by the degree of matches + rank(queryResult, content); + + //firstly fetch candidate freebase topics. pass 'true' to only keep candidates whose name overlap with the query term + log.debug("(DB QUERY =" + queryResult.size() + " results)"); + for (Pair candidate : queryResult) { + //Next get attributes for each topic + String label = candidate.getValue(); + if (label == null) + label = content; + Entity ec = new Entity(candidate.getKey(), label); + List attributes = findAttributesOfEntities(ec); + ec.setAttributes(attributes); + for (Attribute attr : attributes) { + adjustValueOfURLResource(attr); + if (attr.getRelationURI().endsWith(RDFEnum.RELATION_HASTYPE_SUFFIX_PATTERN.getString()) && + !ec.hasType(attr.getValueURI())) { + ec.addType(new Clazz(attr.getValueURI(), attr.getValue())); + } + } + result.add(ec); + } + + cacheEntity.cache(queryCache, result, AUTO_COMMIT); + log.debug("QUERY (entities, cache save)=" + queryCache + "|" + queryCache); + } catch (Exception e) { + throw new KBSearchException(e); + } + } + + //filter entity's clazz, and attributes + String id = "|"; + for (Entity ec : result) { + id = id + ec.getId() + ","; + //ec.setTypes(FreebaseSearchResultFilter.filterClazz(ec.getTypes())); + List filteredTypes = resultFilter.filterClazz(ec.getTypes()); + ec.clearTypes(); + for (Clazz ft : filteredTypes) + ec.addType(ft); + } + + return result; } private void adjustValueOfURLResource(Attribute attr) throws KBSearchException { @@ -430,7 +357,7 @@ private List findAttributes(String id, SolrCache cache) throws KBSear RDFNode predicate = qs.get("?p"); RDFNode object = qs.get("?o"); if (object != null) { - Attribute attr = new DBpediaAttribute(predicate.toString(), object.toString()); + Attribute attr = new SPARQLAttribute(predicate.toString(), object.toString()); result.add(attr); } } From 33ebecff44fbecf7b98fcd8a317f09f5a49c9e0f Mon Sep 17 00:00:00 2001 From: brodecva Date: Wed, 27 Jul 2016 18:30:26 +0200 Subject: [PATCH 063/211] Added encoding of the ID when put out as a part of a URL. --- .../src/main/java/cz/cuni/mff/xrg/odalic/util/URL.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/URL.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/URL.java index 1a968078..2afc83ef 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/URL.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/URL.java @@ -1,6 +1,9 @@ package cz.cuni.mff.xrg.odalic.util; +import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import javax.ws.rs.core.UriInfo; @@ -32,6 +35,11 @@ private URL() {} */ public static java.net.URL getSubResourceAbsolutePath(UriInfo requestUriInfo, String subResource) throws MalformedURLException, IllegalStateException { - return requestUriInfo.getAbsolutePath().resolve(subResource).toURL(); + try { + return requestUriInfo.getAbsolutePath() + .resolve(URLEncoder.encode(subResource, StandardCharsets.UTF_8.displayName())).toURL(); + } catch (UnsupportedEncodingException e) { + throw new AssertionError(e); + } } } From 1876d0a52499f03a5f5fc5613432bf8c3e621145 Mon Sep 17 00:00:00 2001 From: brodecva Date: Sat, 30 Jul 2016 20:12:22 +0200 Subject: [PATCH 064/211] Root pom set. --- .travis.yml | 1 - pom.xml | 158 +++++----------------------------------------------- 2 files changed, 13 insertions(+), 146 deletions(-) diff --git a/.travis.yml b/.travis.yml index 313e5769..86a0aa42 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,3 @@ ## Travis build file language: java -before_script: cd odalic diff --git a/pom.xml b/pom.xml index debd5432..f6f231e7 100644 --- a/pom.xml +++ b/pom.xml @@ -2,150 +2,18 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 cz.cuni.mff.xrg.odalic - odalic + odalic-sti 0.0.1-SNAPSHOT - war - Odalic - Odalic server - - - 1.8 - 1.7.21 - 2.23.1 - 1.1.7 - 4.3.0.RELEASE - - - - - Apache 2.0 - http://www.apache.org/licenses/LICENSE-2.0 - - - - - - maven2-repository.java.net - Java.net Repository for Maven - http://download.java.net/maven/2/ - - - - - - - uk.ac.shef.dcs - sti - 1.0 - - - guava-jdk5 - com.google.guava - - - - - - - com.google.guava - guava - 19.0 - - - - - org.glassfish.jersey.ext - jersey-spring3 - ${jersey.version} - - - org.springframework - spring-core - - - org.springframework - spring-web - - - org.springframework - spring-beans - - - - - org.glassfish.jersey.media - jersey-media-json-jackson - ${jersey.version} - - - org.glassfish.jersey.media - jersey-media-multipart - ${jersey.version} - - - org.glassfish.jersey.ext - jersey-entity-filtering - ${jersey.version} - - - - - org.springframework - spring-core - ${spring.version} - - - org.springframework - spring-context - ${spring.version} - - - commons-logging - commons-logging - - - - - org.springframework - spring-web - ${spring.version} - - - org.springframework - spring-tx - ${spring.version} - - - org.springframework - spring-aspects - ${spring.version} - - - - - ch.qos.logback - logback-classic - ${logback.version} - - - org.slf4j - jcl-over-slf4j - ${jcloverslf4j.version} - - - - - - - true - org.apache.maven.plugins - maven-compiler-plugin - - ${java.version} - ${java.version} - UTF-8 - - - - + pom + Odalic STI + Odalic Semantic Table Interpreter + + + common-util + any23-sti + kbsearch + websearch + core + odalic + \ No newline at end of file From a8374ffca7818943125c1f8ea064ba09c35714dd Mon Sep 17 00:00:00 2001 From: brodecva Date: Sat, 30 Jul 2016 20:22:37 +0200 Subject: [PATCH 065/211] JDK set to Oracle JDK 8. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 86a0aa42..782620d9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ ## Travis build file language: java +jdk: oraclejdk8 From 2b3bc52388a243b2e45f786c433b2a7bf470c990 Mon Sep 17 00:00:00 2001 From: brodecva Date: Sat, 30 Jul 2016 20:33:10 +0200 Subject: [PATCH 066/211] Manual mvn install of libs added. --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 782620d9..9c182cb7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,3 +2,6 @@ language: java jdk: oraclejdk8 +before_install: + - mvn install:install-file -DgroupId=nlp.dragontools -DartifactId=dragontools -Dversion=1.0 -Dpackaging=jar -Dfile=libs/dragontool.jar + - mvn install:install-file -DgroupId=com.github.mpkorstanje -DartifactId=simmetrics -Dversion=4.1.0L -Dpackaging=jar -Dfile=libs/simmetrics.jar From 8d2b4e73405639ba5aaa4e02cb81a7056c3ab371 Mon Sep 17 00:00:00 2001 From: brodecva Date: Sat, 30 Jul 2016 21:17:08 +0200 Subject: [PATCH 067/211] Memory limits for Maven set. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 9c182cb7..53f55c18 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,5 +3,6 @@ language: java jdk: oraclejdk8 before_install: + - echo "MAVEN_OPTS='-Xmx2048m -XX:MaxPermSize=512m'" > ~/.mavenrc - mvn install:install-file -DgroupId=nlp.dragontools -DartifactId=dragontools -Dversion=1.0 -Dpackaging=jar -Dfile=libs/dragontool.jar - mvn install:install-file -DgroupId=com.github.mpkorstanje -DartifactId=simmetrics -Dversion=4.1.0L -Dpackaging=jar -Dfile=libs/simmetrics.jar From f2c48f0e752d78ab7ea14e0f78739a81fa7fd518 Mon Sep 17 00:00:00 2001 From: brodecva Date: Mon, 1 Aug 2016 13:08:51 +0200 Subject: [PATCH 068/211] Rename of subprojects to make the merge easier. --- {any23-sti => sti-any23}/pom.xml | 0 .../src/org/apache/any23/extractor/LExtractionResultImpl.java | 0 .../src/uk/ac/shef/oak/any23/extension/extractor/LAny23.java | 0 .../src/uk/ac/shef/oak/any23/extension/extractor/LAny23Util.java | 0 .../ac/shef/oak/any23/extension/extractor/LExtractorRegistry.java | 0 .../shef/oak/any23/extension/extractor/LMicrodataExtractor.java | 0 .../oak/any23/extension/extractor/LMicrodataExtractorFactory.java | 0 .../ac/shef/oak/any23/extension/extractor/LMicrodataParser.java | 0 .../uk/ac/shef/oak/any23/extension/extractor/LNTripleWriter.java | 0 .../ac/shef/oak/any23/extension/extractor/LRDFa11Extractor.java | 0 .../oak/any23/extension/extractor/LRDFa11ExtractorFactory.java | 0 .../uk/ac/shef/oak/any23/extension/extractor/LRDFa11Parser.java | 0 .../oak/any23/extension/extractor/LSingleDocumentExtraction.java | 0 .../src/uk/ac/shef/oak/any23/extension/extractor/LTriple.java | 0 {common-util => sti-common-util}/pom.xml | 0 .../src/main/java/uk/ac/shef/dcs/util/SerializationUtils.java | 0 .../src/main/java/uk/ac/shef/dcs/util/SolrCache.java | 0 .../src/main/java/uk/ac/shef/dcs/util/StringUtils.java | 0 {kbsearch => sti-kbsearch}/pom.xml | 0 .../src/main/java/uk/ac/shef/dcs/kbsearch/KBSearch.java | 0 .../src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchException.java | 0 .../src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchFactory.java | 0 .../main/java/uk/ac/shef/dcs/kbsearch/KBSearchResultFilter.java | 0 .../java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseAttribute.java | 0 .../main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseEnum.java | 0 .../ac/shef/dcs/kbsearch/freebase/FreebaseQueryInterrupter.java | 0 .../java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryProxy.java | 0 .../java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearch.java | 0 .../ac/shef/dcs/kbsearch/freebase/FreebaseSearchResultFilter.java | 0 .../main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseTopic.java | 0 .../src/main/java/uk/ac/shef/dcs/kbsearch/model/Attribute.java | 0 .../src/main/java/uk/ac/shef/dcs/kbsearch/model/Clazz.java | 0 .../src/main/java/uk/ac/shef/dcs/kbsearch/model/Entity.java | 0 .../src/main/java/uk/ac/shef/dcs/kbsearch/model/Resource.java | 0 .../java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaAttribute.java | 0 .../src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaEnum.java | 0 .../main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearch.java | 0 .../uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearchResultFilter.java | 0 .../src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DCEnum.java | 0 .../src/main/java/uk/ac/shef/dcs/kbsearch/sparql/FOAFEnum.java | 0 .../src/main/java/uk/ac/shef/dcs/kbsearch/sparql/RDFEnum.java | 0 .../main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLSearch.java | 0 {core => sti-main}/log4j.properties | 0 {core => sti-main}/pom.xml | 0 {core => sti-main}/src/main/java/log4j.properties | 0 .../src/main/java/uk/ac/shef/dcs/sti/STIConstantProperty.java | 0 {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/STIEnum.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/STIException.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/any23/Any23Xtractor.java | 0 .../ac/shef/dcs/sti/core/algorithm/SemanticTableInterpreter.java | 0 .../shef/dcs/sti/core/algorithm/baseline/BaselineInterpreter.java | 0 .../dcs/sti/core/algorithm/baseline/BaselineRelationScorer.java | 0 .../core/algorithm/baseline/BaselineSimilarityClazzScorer.java | 0 .../core/algorithm/baseline/BaselineSimilarityEntityScorer.java | 0 .../shef/dcs/sti/core/algorithm/baseline/TCellDisambiguator.java | 0 .../sti/core/algorithm/baseline/TCellDisambiguatorNameMatch.java | 0 .../sti/core/algorithm/baseline/TCellDisambiguatorSimilarity.java | 0 .../shef/dcs/sti/core/algorithm/baseline/TColumnClassifier.java | 0 .../sti/core/algorithm/baseline/TColumnClassifierNameMatch.java | 0 .../sti/core/algorithm/baseline/TColumnClassifierSimilarity.java | 0 .../shef/dcs/sti/core/algorithm/ji/CandidateConceptGenerator.java | 0 .../shef/dcs/sti/core/algorithm/ji/CandidateEntityGenerator.java | 0 .../dcs/sti/core/algorithm/ji/CandidateRelationGenerator.java | 0 .../java/uk/ac/shef/dcs/sti/core/algorithm/ji/DebuggingUtil.java | 0 .../shef/dcs/sti/core/algorithm/ji/JIAdaptedAttributeMatcher.java | 0 .../ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedEntityScorer.java | 0 .../java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIClazzScorer.java | 0 .../java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIInterpreter.java | 0 .../java/uk/ac/shef/dcs/sti/core/algorithm/ji/TAnnotationJI.java | 0 .../java/uk/ac/shef/dcs/sti/core/algorithm/ji/VariableType.java | 0 .../shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilder.java | 0 .../dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCell.java | 0 .../algorithm/ji/factorgraph/FactorBuilderCellAndRelation.java | 0 .../sti/core/algorithm/ji/factorgraph/FactorBuilderHeader.java | 0 .../core/algorithm/ji/factorgraph/FactorBuilderHeaderAndCell.java | 0 .../algorithm/ji/factorgraph/FactorBuilderHeaderAndRelation.java | 0 .../dcs/sti/core/algorithm/ji/factorgraph/FactorGraphBuilder.java | 0 .../algorithm/ji/similarity/EntityAndClazzSimilarityScorer.java | 0 .../core/algorithm/ji/similarity/SimilarityComputerManager.java | 0 .../core/algorithm/ji/similarity/SimilarityComputerThread.java | 0 .../ac/shef/dcs/sti/core/algorithm/smp/CellAnnotationUpdater.java | 0 .../java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessage.java | 0 .../ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageComputer.java | 0 .../dcs/sti/core/algorithm/smp/ChangeMessageFromRelation.java | 0 .../dcs/sti/core/algorithm/smp/ClazzSpecificityCalculator.java | 0 .../core/algorithm/smp/FreebaseClazzSpecificityCalculator.java | 0 .../shef/dcs/sti/core/algorithm/smp/SMPAdaptedEntityScorer.java | 0 .../uk/ac/shef/dcs/sti/core/algorithm/smp/SMPInterpreter.java | 0 .../shef/dcs/sti/core/algorithm/smp/SemanticMessagePassing.java | 0 .../shef/dcs/sti/core/algorithm/smp/TAnnotationSMPFreebase.java | 0 .../ac/shef/dcs/sti/core/algorithm/smp/TAnnotationWriterSMP.java | 0 .../uk/ac/shef/dcs/sti/core/algorithm/smp/TCellEntityRanker.java | 0 .../uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnClassifier.java | 0 .../sti/core/algorithm/smp/TColumnColumnRelationEnumerator.java | 0 .../main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNING.java | 0 .../core/algorithm/tmp/LEARNINGPreliminaryColumnClassifier.java | 0 .../dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryDisamb.java | 0 .../ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTagger.java | 0 .../shef/dcs/sti/core/algorithm/tmp/LiteralColumnTaggerImpl.java | 0 .../ac/shef/dcs/sti/core/algorithm/tmp/RELATIONENUMERATION.java | 0 .../uk/ac/shef/dcs/sti/core/algorithm/tmp/TCellDisambiguator.java | 0 .../uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnClassifier.java | 0 .../sti/core/algorithm/tmp/TColumnColumnRelationEnumerator.java | 0 .../uk/ac/shef/dcs/sti/core/algorithm/tmp/TMPInterpreter.java | 0 .../main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/UPDATE.java | 0 .../ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_combined.java | 0 .../dcs/sti/core/algorithm/tmp/sampler/OSPD_contextWords.java | 0 .../shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nameLength.java | 0 .../dcs/sti/core/algorithm/tmp/sampler/OSPD_namelength_merge.java | 0 .../ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nonEmpty.java | 0 .../ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_random.java | 0 .../uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/Random.java | 0 .../dcs/sti/core/algorithm/tmp/sampler/TContentCellRanker.java | 0 .../dcs/sti/core/algorithm/tmp/sampler/TContentRowRanker.java | 0 .../core/algorithm/tmp/sampler/TContentTContentRowRankerImpl.java | 0 .../ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPClazzScorer.java | 0 .../shef/dcs/sti/core/algorithm/tmp/scorer/TMPEntityScorer.java | 0 .../shef/dcs/sti/core/algorithm/tmp/scorer/TMPRelationScorer.java | 0 .../dcs/sti/core/algorithm/tmp/stopping/FixedNumberOfRows.java | 0 .../java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/IInf.java | 0 .../uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/NoStop.java | 0 .../dcs/sti/core/algorithm/tmp/stopping/StoppingCriteria.java | 0 .../core/algorithm/tmp/stopping/StoppingCriteriaInstantiator.java | 0 .../ac/shef/dcs/sti/core/feature/FreebaseConceptBoWCreator.java | 0 .../ac/shef/dcs/sti/core/feature/FreebaseRelationBoWCreator.java | 0 .../uk/ac/shef/dcs/sti/core/feature/OntologyBasedBoWCreator.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/core/model/List.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/core/model/ListItem.java | 0 .../main/java/uk/ac/shef/dcs/sti/core/model/RelationColumns.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/core/model/TAnnotation.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/core/model/TCell.java | 0 .../main/java/uk/ac/shef/dcs/sti/core/model/TCellAnnotation.java | 0 .../uk/ac/shef/dcs/sti/core/model/TCellCellRelationAnotation.java | 0 .../shef/dcs/sti/core/model/TColumnColumnRelationAnnotation.java | 0 .../main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeader.java | 0 .../uk/ac/shef/dcs/sti/core/model/TColumnHeaderAnnotation.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/core/model/TContext.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/core/model/Table.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/core/model/TableTriple.java | 0 .../uk/ac/shef/dcs/sti/core/scorer/AttributeValueMatcher.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/core/scorer/ClazzScorer.java | 0 .../main/java/uk/ac/shef/dcs/sti/core/scorer/EntityScorer.java | 0 .../main/java/uk/ac/shef/dcs/sti/core/scorer/RelationScorer.java | 0 .../main/java/uk/ac/shef/dcs/sti/core/subjectcol/CMScorer.java | 0 .../uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnDetector.java | 0 .../uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorer.java | 0 .../dcs/sti/core/subjectcol/SubjectColumnScorerHeuristic.java | 0 .../java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnDataType.java | 0 .../java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeature.java | 0 .../ac/shef/dcs/sti/core/subjectcol/TColumnFeatureGenerator.java | 0 .../main/java/uk/ac/shef/dcs/sti/core/subjectcol/WSScorer.java | 0 .../main/java/uk/ac/shef/dcs/sti/experiment/BaselineBatch.java | 0 .../java/uk/ac/shef/dcs/sti/experiment/JointInferenceBatch.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/experiment/STIBatch.java | 0 .../ac/shef/dcs/sti/experiment/SemanticMessagePassingBatch.java | 0 .../java/uk/ac/shef/dcs/sti/experiment/TableMinerPlusBatch.java | 0 .../main/java/uk/ac/shef/dcs/sti/io/JSONOutputCellAnnotation.java | 0 .../java/uk/ac/shef/dcs/sti/io/JSONOutputColumnAnnotation.java | 0 .../java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotation.java | 0 .../uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotationPerRow.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriter.java | 0 .../main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriterJSON.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/nlp/Lemmatizer.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/nlp/NLPTools.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/nlp/TermFreqCounter.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/parser/ContentValidator.java | 0 .../main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractor.java | 0 .../java/uk/ac/shef/dcs/sti/parser/list/ListXtractorHTML.java | 0 .../uk/ac/shef/dcs/sti/parser/list/ListXtractorWikipedia.java | 0 .../uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitter.java | 0 .../shef/dcs/sti/parser/list/splitter/ListItemSplitterByURL.java | 0 .../shef/dcs/sti/parser/list/validator/ListVaildatorLanient.java | 0 .../uk/ac/shef/dcs/sti/parser/list/validator/ListValidator.java | 0 .../shef/dcs/sti/parser/list/validator/ListValidatorStrict.java | 0 .../main/java/uk/ac/shef/dcs/sti/parser/table/TableParser.java | 0 .../uk/ac/shef/dcs/sti/parser/table/TableParserGoodreads.java | 0 .../java/uk/ac/shef/dcs/sti/parser/table/TableParserHTML.java | 0 .../java/uk/ac/shef/dcs/sti/parser/table/TableParserIMDB.java | 0 .../uk/ac/shef/dcs/sti/parser/table/TableParserLimayeDataset.java | 0 .../uk/ac/shef/dcs/sti/parser/table/TableParserMusicBrainz.java | 0 .../uk/ac/shef/dcs/sti/parser/table/TableParserReverbnation.java | 0 .../uk/ac/shef/dcs/sti/parser/table/TableParserRottenTomato.java | 0 .../uk/ac/shef/dcs/sti/parser/table/TableParserWikipedia.java | 0 .../shef/dcs/sti/parser/table/context/TableContextExtractor.java | 0 .../sti/parser/table/context/TableContextExtractorGeneric.java | 0 .../dcs/sti/parser/table/context/TableContextExtractorIMDB.java | 0 .../parser/table/context/TableContextExtractorMusicBrainz.java | 0 .../uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreator.java | 0 .../dcs/sti/parser/table/creator/TableObjCreatorGoodreads.java | 0 .../ac/shef/dcs/sti/parser/table/creator/TableObjCreatorHTML.java | 0 .../ac/shef/dcs/sti/parser/table/creator/TableObjCreatorIMDB.java | 0 .../dcs/sti/parser/table/creator/TableObjCreatorMusicBrainz.java | 0 .../sti/parser/table/creator/TableObjCreatorReverbnationList.java | 0 .../dcs/sti/parser/table/creator/TableObjCreatorWikipediaGS.java | 0 .../ac/shef/dcs/sti/parser/table/hodetector/TableHODetector.java | 0 .../dcs/sti/parser/table/hodetector/TableHODetectorByHTMLTag.java | 0 .../ac/shef/dcs/sti/parser/table/normalizer/TableNormalizer.java | 0 .../table/normalizer/TableNormalizerDiscardIrregularRows.java | 0 .../parser/table/normalizer/TableNormalizerListTransformer.java | 0 .../dcs/sti/parser/table/normalizer/TableNormalizerSimple.java | 0 .../uk/ac/shef/dcs/sti/parser/table/validator/TableValidator.java | 0 .../table/validator/TableValidatorForWikipediaGSLanient.java | 0 .../table/validator/TableValidatorForWikipediaGSStrict.java | 0 .../dcs/sti/parser/table/validator/TableValidatorGeneric.java | 0 .../uk/ac/shef/dcs/sti/todo/FreebaseTypeGranularityPopulator.java | 0 .../java/uk/ac/shef/dcs/sti/todo/TAnnotationKeyFileReader.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/todo/TestGRMM.java | 0 .../java/uk/ac/shef/dcs/sti/todo/TestSubjectColumnDetector.java | 0 .../main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats.java | 0 .../DataStats_TableSize_NameLength_Analysis_LimayeNew.java | 0 .../DataStats_TableSize_NameLength_Analysis_MB_IMDB.java | 0 .../DataStats_TableSize_NameLength_Anaylsis_LimayeOld.java | 0 .../ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_IMDB.java | 0 .../shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_Limaye.java | 0 .../uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_MB.java | 0 .../uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly.java | 0 .../sti/todo/evaluation/Evaluator_ClassOnly_IMDB_MusicBrainz.java | 0 .../uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_EntityOnly.java | 0 .../Evaluator_Generic_Classification_ignoreUpdateIterations.java | 0 .../dcs/sti/todo/evaluation/Evaluator_ISWC_Helper_ClassOnly.java | 0 .../dcs/sti/todo/evaluation/Evaluator_Limaye_Entity_Only.java | 0 .../ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly.java | 0 .../todo/evaluation/Evaluator_RelationOnly_IMDB_MusicBrainz.java | 0 .../dcs/sti/todo/evaluation/KeyFileGenerator_from_HTMLOutput.java | 0 .../LimayeDataset_Entity_Discrepancy_Analysis_Generic.java | 0 .../LimayeDataset_Entity_Discrepancy_btw_Baseline_Tm_Finder.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_IMDB.java | 0 .../main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye.java | 0 .../uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables.java | 0 .../dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_consolidate.java | 0 .../dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_with_Ref.java | 0 .../java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_MusicBrainz.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSFile_Rewriter.java | 0 .../dcs/sti/todo/gs/GS_Class_Relation_Consolidation_Helper.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Stats_Limaye.java | 0 .../uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass1.java | 0 .../uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass2.java | 0 .../uk/ac/shef/dcs/sti/todo/gs/WikipediaTableListPageFilter.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/util/CollectionUtils.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/util/DataTypeClassifier.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/util/FileUtils.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/util/SubsetGenerator.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/util/TripleGenerator.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/util/XPathUtils.java | 0 .../java/uk/ac/shef/dcs/sti/xtractor/csv/CharsetDetector.java | 0 .../java/uk/ac/shef/dcs/sti/xtractor/csv/NoCSVDataException.java | 0 .../main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParseFailed.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/Parser.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsv.java | 0 .../java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsvConfig.java | 0 .../java/uk/ac/shef/dcs/sti/xtractor/csv/TableXtractorCSV.java | 0 .../main/java/uk/ac/shef/dcs/sti/xtractor/csv/TestDetector.java | 0 {websearch => sti-websearch}/pom.xml | 0 .../src/uk/ac/shef/dcs/websearch/SearchResultParser.java | 0 .../src/uk/ac/shef/dcs/websearch/WebSearch.java | 0 .../src/uk/ac/shef/dcs/websearch/WebSearchException.java | 0 .../src/uk/ac/shef/dcs/websearch/WebSearchFactory.java | 0 .../src/uk/ac/shef/dcs/websearch/WebSearchResultDoc.java | 0 .../ac/shef/dcs/websearch/bing/v2/APIKeysDepletedException.java | 0 .../src/uk/ac/shef/dcs/websearch/bing/v2/BingSearch.java | 0 .../uk/ac/shef/dcs/websearch/bing/v2/BingSearchResultParser.java | 0 261 files changed, 0 insertions(+), 0 deletions(-) rename {any23-sti => sti-any23}/pom.xml (100%) rename {any23-sti => sti-any23}/src/org/apache/any23/extractor/LExtractionResultImpl.java (100%) rename {any23-sti => sti-any23}/src/uk/ac/shef/oak/any23/extension/extractor/LAny23.java (100%) rename {any23-sti => sti-any23}/src/uk/ac/shef/oak/any23/extension/extractor/LAny23Util.java (100%) rename {any23-sti => sti-any23}/src/uk/ac/shef/oak/any23/extension/extractor/LExtractorRegistry.java (100%) rename {any23-sti => sti-any23}/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractor.java (100%) rename {any23-sti => sti-any23}/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractorFactory.java (100%) rename {any23-sti => sti-any23}/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataParser.java (100%) rename {any23-sti => sti-any23}/src/uk/ac/shef/oak/any23/extension/extractor/LNTripleWriter.java (100%) rename {any23-sti => sti-any23}/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Extractor.java (100%) rename {any23-sti => sti-any23}/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11ExtractorFactory.java (100%) rename {any23-sti => sti-any23}/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Parser.java (100%) rename {any23-sti => sti-any23}/src/uk/ac/shef/oak/any23/extension/extractor/LSingleDocumentExtraction.java (100%) rename {any23-sti => sti-any23}/src/uk/ac/shef/oak/any23/extension/extractor/LTriple.java (100%) rename {common-util => sti-common-util}/pom.xml (100%) rename {common-util => sti-common-util}/src/main/java/uk/ac/shef/dcs/util/SerializationUtils.java (100%) rename {common-util => sti-common-util}/src/main/java/uk/ac/shef/dcs/util/SolrCache.java (100%) rename {common-util => sti-common-util}/src/main/java/uk/ac/shef/dcs/util/StringUtils.java (100%) rename {kbsearch => sti-kbsearch}/pom.xml (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearch.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchException.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchFactory.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchResultFilter.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseAttribute.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseEnum.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryInterrupter.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryProxy.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearch.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearchResultFilter.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseTopic.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/model/Attribute.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/model/Clazz.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/model/Entity.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/model/Resource.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaAttribute.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaEnum.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearch.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearchResultFilter.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DCEnum.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/FOAFEnum.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/RDFEnum.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLSearch.java (100%) rename {core => sti-main}/log4j.properties (100%) rename {core => sti-main}/pom.xml (100%) rename {core => sti-main}/src/main/java/log4j.properties (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/STIConstantProperty.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/STIEnum.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/STIException.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/any23/Any23Xtractor.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/SemanticTableInterpreter.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineInterpreter.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineRelationScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineSimilarityClazzScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineSimilarityEntityScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguatorNameMatch.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguatorSimilarity.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifier.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifierNameMatch.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifierSimilarity.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateConceptGenerator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateEntityGenerator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateRelationGenerator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/DebuggingUtil.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedAttributeMatcher.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedEntityScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIClazzScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIInterpreter.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/TAnnotationJI.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/VariableType.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilder.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCell.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCellAndRelation.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeader.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeaderAndCell.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeaderAndRelation.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorGraphBuilder.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/EntityAndClazzSimilarityScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/SimilarityComputerManager.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/SimilarityComputerThread.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/CellAnnotationUpdater.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessage.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageComputer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageFromRelation.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ClazzSpecificityCalculator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/FreebaseClazzSpecificityCalculator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SMPAdaptedEntityScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SMPInterpreter.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SemanticMessagePassing.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TAnnotationSMPFreebase.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TAnnotationWriterSMP.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TCellEntityRanker.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnClassifier.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnColumnRelationEnumerator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNING.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryColumnClassifier.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryDisamb.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTagger.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTaggerImpl.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/RELATIONENUMERATION.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TCellDisambiguator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnClassifier.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnColumnRelationEnumerator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TMPInterpreter.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/UPDATE.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_combined.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_contextWords.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nameLength.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_namelength_merge.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nonEmpty.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_random.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/Random.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentCellRanker.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentRowRanker.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentTContentRowRankerImpl.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPClazzScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPEntityScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPRelationScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/FixedNumberOfRows.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/IInf.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/NoStop.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/StoppingCriteria.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/StoppingCriteriaInstantiator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/feature/FreebaseConceptBoWCreator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/feature/FreebaseRelationBoWCreator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/feature/OntologyBasedBoWCreator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/model/List.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/model/ListItem.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/model/RelationColumns.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/model/TAnnotation.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/model/TCell.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/model/TCellAnnotation.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/model/TCellCellRelationAnotation.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnColumnRelationAnnotation.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeader.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeaderAnnotation.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/model/TContext.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/model/Table.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/model/TableTriple.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/scorer/AttributeValueMatcher.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/scorer/ClazzScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/scorer/EntityScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/scorer/RelationScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/CMScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnDetector.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorerHeuristic.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnDataType.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeature.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeatureGenerator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/WSScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/experiment/BaselineBatch.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/experiment/JointInferenceBatch.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/experiment/STIBatch.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/experiment/SemanticMessagePassingBatch.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/experiment/TableMinerPlusBatch.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputCellAnnotation.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputColumnAnnotation.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotation.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotationPerRow.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriter.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriterJSON.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/nlp/Lemmatizer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/nlp/NLPTools.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/nlp/TermFreqCounter.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/ContentValidator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractor.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorHTML.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorWikipedia.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitter.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitterByURL.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListVaildatorLanient.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListValidator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListValidatorStrict.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParser.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserGoodreads.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserHTML.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserIMDB.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserLimayeDataset.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserMusicBrainz.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserReverbnation.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserRottenTomato.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserWikipedia.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractor.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorGeneric.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorIMDB.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorMusicBrainz.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorGoodreads.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorHTML.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorIMDB.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorMusicBrainz.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorReverbnationList.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorWikipediaGS.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/hodetector/TableHODetector.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/hodetector/TableHODetectorByHTMLTag.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerDiscardIrregularRows.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerListTransformer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerSimple.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorForWikipediaGSLanient.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorForWikipediaGSStrict.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorGeneric.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/FreebaseTypeGranularityPopulator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/TAnnotationKeyFileReader.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/TestGRMM.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/TestSubjectColumnDetector.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_LimayeNew.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_MB_IMDB.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Anaylsis_LimayeOld.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_IMDB.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_Limaye.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_MB.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly_IMDB_MusicBrainz.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_EntityOnly.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Generic_Classification_ignoreUpdateIterations.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ISWC_Helper_ClassOnly.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Limaye_Entity_Only.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly_IMDB_MusicBrainz.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/KeyFileGenerator_from_HTMLOutput.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_Analysis_Generic.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_btw_Baseline_Tm_Finder.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_IMDB.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_consolidate.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_with_Ref.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_MusicBrainz.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSFile_Rewriter.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Class_Relation_Consolidation_Helper.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Stats_Limaye.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass1.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass2.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTableListPageFilter.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/util/CollectionUtils.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/util/DataTypeClassifier.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/util/FileUtils.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/util/SubsetGenerator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/util/TripleGenerator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/util/XPathUtils.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/CharsetDetector.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/NoCSVDataException.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParseFailed.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/Parser.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsv.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsvConfig.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/TableXtractorCSV.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/TestDetector.java (100%) rename {websearch => sti-websearch}/pom.xml (100%) rename {websearch => sti-websearch}/src/uk/ac/shef/dcs/websearch/SearchResultParser.java (100%) rename {websearch => sti-websearch}/src/uk/ac/shef/dcs/websearch/WebSearch.java (100%) rename {websearch => sti-websearch}/src/uk/ac/shef/dcs/websearch/WebSearchException.java (100%) rename {websearch => sti-websearch}/src/uk/ac/shef/dcs/websearch/WebSearchFactory.java (100%) rename {websearch => sti-websearch}/src/uk/ac/shef/dcs/websearch/WebSearchResultDoc.java (100%) rename {websearch => sti-websearch}/src/uk/ac/shef/dcs/websearch/bing/v2/APIKeysDepletedException.java (100%) rename {websearch => sti-websearch}/src/uk/ac/shef/dcs/websearch/bing/v2/BingSearch.java (100%) rename {websearch => sti-websearch}/src/uk/ac/shef/dcs/websearch/bing/v2/BingSearchResultParser.java (100%) diff --git a/any23-sti/pom.xml b/sti-any23/pom.xml similarity index 100% rename from any23-sti/pom.xml rename to sti-any23/pom.xml diff --git a/any23-sti/src/org/apache/any23/extractor/LExtractionResultImpl.java b/sti-any23/src/org/apache/any23/extractor/LExtractionResultImpl.java similarity index 100% rename from any23-sti/src/org/apache/any23/extractor/LExtractionResultImpl.java rename to sti-any23/src/org/apache/any23/extractor/LExtractionResultImpl.java diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LAny23.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LAny23.java similarity index 100% rename from any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LAny23.java rename to sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LAny23.java diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LAny23Util.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LAny23Util.java similarity index 100% rename from any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LAny23Util.java rename to sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LAny23Util.java diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LExtractorRegistry.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LExtractorRegistry.java similarity index 100% rename from any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LExtractorRegistry.java rename to sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LExtractorRegistry.java diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractor.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractor.java similarity index 100% rename from any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractor.java rename to sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractor.java diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractorFactory.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractorFactory.java similarity index 100% rename from any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractorFactory.java rename to sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractorFactory.java diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataParser.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataParser.java similarity index 100% rename from any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataParser.java rename to sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataParser.java diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LNTripleWriter.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LNTripleWriter.java similarity index 100% rename from any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LNTripleWriter.java rename to sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LNTripleWriter.java diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Extractor.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Extractor.java similarity index 100% rename from any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Extractor.java rename to sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Extractor.java diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11ExtractorFactory.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11ExtractorFactory.java similarity index 100% rename from any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11ExtractorFactory.java rename to sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11ExtractorFactory.java diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Parser.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Parser.java similarity index 100% rename from any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Parser.java rename to sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Parser.java diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LSingleDocumentExtraction.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LSingleDocumentExtraction.java similarity index 100% rename from any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LSingleDocumentExtraction.java rename to sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LSingleDocumentExtraction.java diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LTriple.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LTriple.java similarity index 100% rename from any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LTriple.java rename to sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LTriple.java diff --git a/common-util/pom.xml b/sti-common-util/pom.xml similarity index 100% rename from common-util/pom.xml rename to sti-common-util/pom.xml diff --git a/common-util/src/main/java/uk/ac/shef/dcs/util/SerializationUtils.java b/sti-common-util/src/main/java/uk/ac/shef/dcs/util/SerializationUtils.java similarity index 100% rename from common-util/src/main/java/uk/ac/shef/dcs/util/SerializationUtils.java rename to sti-common-util/src/main/java/uk/ac/shef/dcs/util/SerializationUtils.java diff --git a/common-util/src/main/java/uk/ac/shef/dcs/util/SolrCache.java b/sti-common-util/src/main/java/uk/ac/shef/dcs/util/SolrCache.java similarity index 100% rename from common-util/src/main/java/uk/ac/shef/dcs/util/SolrCache.java rename to sti-common-util/src/main/java/uk/ac/shef/dcs/util/SolrCache.java diff --git a/common-util/src/main/java/uk/ac/shef/dcs/util/StringUtils.java b/sti-common-util/src/main/java/uk/ac/shef/dcs/util/StringUtils.java similarity index 100% rename from common-util/src/main/java/uk/ac/shef/dcs/util/StringUtils.java rename to sti-common-util/src/main/java/uk/ac/shef/dcs/util/StringUtils.java diff --git a/kbsearch/pom.xml b/sti-kbsearch/pom.xml similarity index 100% rename from kbsearch/pom.xml rename to sti-kbsearch/pom.xml diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearch.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearch.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearch.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearch.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchException.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchException.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchException.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchException.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchFactory.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchFactory.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchFactory.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchFactory.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchResultFilter.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchResultFilter.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchResultFilter.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchResultFilter.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseAttribute.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseAttribute.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseAttribute.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseAttribute.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseEnum.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseEnum.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseEnum.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseEnum.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryInterrupter.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryInterrupter.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryInterrupter.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryInterrupter.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryProxy.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryProxy.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryProxy.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryProxy.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearch.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearch.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearch.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearch.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearchResultFilter.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearchResultFilter.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearchResultFilter.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearchResultFilter.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseTopic.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseTopic.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseTopic.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseTopic.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Attribute.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Attribute.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Attribute.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Attribute.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Clazz.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Clazz.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Clazz.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Clazz.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Entity.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Entity.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Entity.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Entity.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Resource.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Resource.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Resource.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Resource.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaAttribute.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaAttribute.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaAttribute.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaAttribute.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaEnum.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaEnum.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaEnum.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaEnum.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearch.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearch.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearch.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearch.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearchResultFilter.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearchResultFilter.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearchResultFilter.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearchResultFilter.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DCEnum.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DCEnum.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DCEnum.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DCEnum.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/FOAFEnum.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/FOAFEnum.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/FOAFEnum.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/FOAFEnum.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/RDFEnum.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/RDFEnum.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/RDFEnum.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/RDFEnum.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLSearch.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLSearch.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLSearch.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLSearch.java diff --git a/core/log4j.properties b/sti-main/log4j.properties similarity index 100% rename from core/log4j.properties rename to sti-main/log4j.properties diff --git a/core/pom.xml b/sti-main/pom.xml similarity index 100% rename from core/pom.xml rename to sti-main/pom.xml diff --git a/core/src/main/java/log4j.properties b/sti-main/src/main/java/log4j.properties similarity index 100% rename from core/src/main/java/log4j.properties rename to sti-main/src/main/java/log4j.properties diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/STIConstantProperty.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/STIConstantProperty.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/STIConstantProperty.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/STIConstantProperty.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/STIEnum.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/STIEnum.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/STIEnum.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/STIEnum.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/STIException.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/STIException.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/STIException.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/STIException.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/any23/Any23Xtractor.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/any23/Any23Xtractor.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/any23/Any23Xtractor.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/any23/Any23Xtractor.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/SemanticTableInterpreter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/SemanticTableInterpreter.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/SemanticTableInterpreter.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/SemanticTableInterpreter.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineInterpreter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineInterpreter.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineInterpreter.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineInterpreter.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineRelationScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineRelationScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineRelationScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineRelationScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineSimilarityClazzScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineSimilarityClazzScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineSimilarityClazzScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineSimilarityClazzScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineSimilarityEntityScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineSimilarityEntityScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineSimilarityEntityScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineSimilarityEntityScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguatorNameMatch.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguatorNameMatch.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguatorNameMatch.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguatorNameMatch.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguatorSimilarity.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguatorSimilarity.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguatorSimilarity.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguatorSimilarity.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifier.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifier.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifier.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifier.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifierNameMatch.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifierNameMatch.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifierNameMatch.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifierNameMatch.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifierSimilarity.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifierSimilarity.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifierSimilarity.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifierSimilarity.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateConceptGenerator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateConceptGenerator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateConceptGenerator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateConceptGenerator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateEntityGenerator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateEntityGenerator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateEntityGenerator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateEntityGenerator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateRelationGenerator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateRelationGenerator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateRelationGenerator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateRelationGenerator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/DebuggingUtil.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/DebuggingUtil.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/DebuggingUtil.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/DebuggingUtil.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedAttributeMatcher.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedAttributeMatcher.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedAttributeMatcher.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedAttributeMatcher.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedEntityScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedEntityScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedEntityScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedEntityScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIClazzScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIClazzScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIClazzScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIClazzScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIInterpreter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIInterpreter.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIInterpreter.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIInterpreter.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/TAnnotationJI.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/TAnnotationJI.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/TAnnotationJI.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/TAnnotationJI.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/VariableType.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/VariableType.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/VariableType.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/VariableType.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilder.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilder.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilder.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilder.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCell.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCell.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCell.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCell.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCellAndRelation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCellAndRelation.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCellAndRelation.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCellAndRelation.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeader.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeader.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeader.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeader.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeaderAndCell.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeaderAndCell.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeaderAndCell.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeaderAndCell.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeaderAndRelation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeaderAndRelation.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeaderAndRelation.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeaderAndRelation.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorGraphBuilder.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorGraphBuilder.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorGraphBuilder.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorGraphBuilder.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/EntityAndClazzSimilarityScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/EntityAndClazzSimilarityScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/EntityAndClazzSimilarityScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/EntityAndClazzSimilarityScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/SimilarityComputerManager.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/SimilarityComputerManager.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/SimilarityComputerManager.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/SimilarityComputerManager.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/SimilarityComputerThread.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/SimilarityComputerThread.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/SimilarityComputerThread.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/SimilarityComputerThread.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/CellAnnotationUpdater.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/CellAnnotationUpdater.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/CellAnnotationUpdater.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/CellAnnotationUpdater.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessage.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessage.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessage.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessage.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageComputer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageComputer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageComputer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageComputer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageFromRelation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageFromRelation.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageFromRelation.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageFromRelation.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ClazzSpecificityCalculator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ClazzSpecificityCalculator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ClazzSpecificityCalculator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ClazzSpecificityCalculator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/FreebaseClazzSpecificityCalculator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/FreebaseClazzSpecificityCalculator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/FreebaseClazzSpecificityCalculator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/FreebaseClazzSpecificityCalculator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SMPAdaptedEntityScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SMPAdaptedEntityScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SMPAdaptedEntityScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SMPAdaptedEntityScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SMPInterpreter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SMPInterpreter.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SMPInterpreter.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SMPInterpreter.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SemanticMessagePassing.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SemanticMessagePassing.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SemanticMessagePassing.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SemanticMessagePassing.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TAnnotationSMPFreebase.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TAnnotationSMPFreebase.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TAnnotationSMPFreebase.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TAnnotationSMPFreebase.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TAnnotationWriterSMP.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TAnnotationWriterSMP.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TAnnotationWriterSMP.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TAnnotationWriterSMP.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TCellEntityRanker.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TCellEntityRanker.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TCellEntityRanker.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TCellEntityRanker.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnClassifier.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnClassifier.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnClassifier.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnClassifier.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnColumnRelationEnumerator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnColumnRelationEnumerator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnColumnRelationEnumerator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnColumnRelationEnumerator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNING.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNING.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNING.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNING.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryColumnClassifier.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryColumnClassifier.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryColumnClassifier.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryColumnClassifier.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryDisamb.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryDisamb.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryDisamb.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryDisamb.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTagger.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTagger.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTagger.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTagger.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTaggerImpl.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTaggerImpl.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTaggerImpl.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTaggerImpl.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/RELATIONENUMERATION.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/RELATIONENUMERATION.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/RELATIONENUMERATION.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/RELATIONENUMERATION.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TCellDisambiguator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TCellDisambiguator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TCellDisambiguator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TCellDisambiguator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnClassifier.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnClassifier.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnClassifier.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnClassifier.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnColumnRelationEnumerator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnColumnRelationEnumerator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnColumnRelationEnumerator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnColumnRelationEnumerator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TMPInterpreter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TMPInterpreter.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TMPInterpreter.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TMPInterpreter.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/UPDATE.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/UPDATE.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/UPDATE.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/UPDATE.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_combined.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_combined.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_combined.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_combined.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_contextWords.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_contextWords.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_contextWords.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_contextWords.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nameLength.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nameLength.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nameLength.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nameLength.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_namelength_merge.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_namelength_merge.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_namelength_merge.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_namelength_merge.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nonEmpty.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nonEmpty.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nonEmpty.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nonEmpty.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_random.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_random.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_random.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_random.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/Random.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/Random.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/Random.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/Random.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentCellRanker.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentCellRanker.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentCellRanker.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentCellRanker.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentRowRanker.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentRowRanker.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentRowRanker.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentRowRanker.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentTContentRowRankerImpl.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentTContentRowRankerImpl.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentTContentRowRankerImpl.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentTContentRowRankerImpl.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPClazzScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPClazzScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPClazzScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPClazzScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPEntityScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPEntityScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPEntityScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPEntityScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPRelationScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPRelationScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPRelationScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPRelationScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/FixedNumberOfRows.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/FixedNumberOfRows.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/FixedNumberOfRows.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/FixedNumberOfRows.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/IInf.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/IInf.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/IInf.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/IInf.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/NoStop.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/NoStop.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/NoStop.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/NoStop.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/StoppingCriteria.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/StoppingCriteria.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/StoppingCriteria.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/StoppingCriteria.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/StoppingCriteriaInstantiator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/StoppingCriteriaInstantiator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/StoppingCriteriaInstantiator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/StoppingCriteriaInstantiator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/feature/FreebaseConceptBoWCreator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/feature/FreebaseConceptBoWCreator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/feature/FreebaseConceptBoWCreator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/feature/FreebaseConceptBoWCreator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/feature/FreebaseRelationBoWCreator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/feature/FreebaseRelationBoWCreator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/feature/FreebaseRelationBoWCreator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/feature/FreebaseRelationBoWCreator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/feature/OntologyBasedBoWCreator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/feature/OntologyBasedBoWCreator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/feature/OntologyBasedBoWCreator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/feature/OntologyBasedBoWCreator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/model/List.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/List.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/model/List.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/List.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/model/ListItem.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/ListItem.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/model/ListItem.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/ListItem.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/model/RelationColumns.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/RelationColumns.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/model/RelationColumns.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/RelationColumns.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/model/TAnnotation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TAnnotation.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/model/TAnnotation.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TAnnotation.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/model/TCell.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TCell.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/model/TCell.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TCell.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/model/TCellAnnotation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TCellAnnotation.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/model/TCellAnnotation.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TCellAnnotation.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/model/TCellCellRelationAnotation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TCellCellRelationAnotation.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/model/TCellCellRelationAnotation.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TCellCellRelationAnotation.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnColumnRelationAnnotation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnColumnRelationAnnotation.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnColumnRelationAnnotation.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnColumnRelationAnnotation.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeader.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeader.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeader.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeader.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeaderAnnotation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeaderAnnotation.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeaderAnnotation.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeaderAnnotation.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/model/TContext.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TContext.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/model/TContext.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TContext.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/model/Table.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/Table.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/model/Table.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/Table.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/model/TableTriple.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TableTriple.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/model/TableTriple.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TableTriple.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/scorer/AttributeValueMatcher.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/AttributeValueMatcher.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/scorer/AttributeValueMatcher.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/AttributeValueMatcher.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/scorer/ClazzScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/ClazzScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/scorer/ClazzScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/ClazzScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/scorer/EntityScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/EntityScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/scorer/EntityScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/EntityScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/scorer/RelationScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/RelationScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/scorer/RelationScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/RelationScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/CMScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/CMScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/CMScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/CMScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnDetector.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnDetector.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnDetector.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnDetector.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorerHeuristic.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorerHeuristic.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorerHeuristic.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorerHeuristic.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnDataType.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnDataType.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnDataType.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnDataType.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeature.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeature.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeature.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeature.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeatureGenerator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeatureGenerator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeatureGenerator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeatureGenerator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/WSScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/WSScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/WSScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/WSScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/experiment/BaselineBatch.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/BaselineBatch.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/experiment/BaselineBatch.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/BaselineBatch.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/experiment/JointInferenceBatch.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/JointInferenceBatch.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/experiment/JointInferenceBatch.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/JointInferenceBatch.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/experiment/STIBatch.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/STIBatch.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/experiment/STIBatch.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/STIBatch.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/experiment/SemanticMessagePassingBatch.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/SemanticMessagePassingBatch.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/experiment/SemanticMessagePassingBatch.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/SemanticMessagePassingBatch.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/experiment/TableMinerPlusBatch.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/TableMinerPlusBatch.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/experiment/TableMinerPlusBatch.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/TableMinerPlusBatch.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputCellAnnotation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputCellAnnotation.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputCellAnnotation.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputCellAnnotation.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputColumnAnnotation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputColumnAnnotation.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputColumnAnnotation.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputColumnAnnotation.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotation.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotation.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotation.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotationPerRow.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotationPerRow.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotationPerRow.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotationPerRow.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriter.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriter.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriter.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriterJSON.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriterJSON.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriterJSON.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriterJSON.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/nlp/Lemmatizer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/nlp/Lemmatizer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/nlp/Lemmatizer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/nlp/Lemmatizer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/nlp/NLPTools.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/nlp/NLPTools.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/nlp/NLPTools.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/nlp/NLPTools.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/nlp/TermFreqCounter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/nlp/TermFreqCounter.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/nlp/TermFreqCounter.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/nlp/TermFreqCounter.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/ContentValidator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/ContentValidator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/ContentValidator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/ContentValidator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractor.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractor.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractor.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractor.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorHTML.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorHTML.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorHTML.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorHTML.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorWikipedia.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorWikipedia.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorWikipedia.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorWikipedia.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitter.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitter.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitter.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitterByURL.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitterByURL.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitterByURL.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitterByURL.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListVaildatorLanient.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListVaildatorLanient.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListVaildatorLanient.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListVaildatorLanient.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListValidator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListValidator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListValidator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListValidator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListValidatorStrict.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListValidatorStrict.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListValidatorStrict.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListValidatorStrict.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParser.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParser.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParser.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParser.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserGoodreads.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserGoodreads.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserGoodreads.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserGoodreads.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserHTML.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserHTML.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserHTML.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserHTML.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserIMDB.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserIMDB.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserIMDB.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserIMDB.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserLimayeDataset.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserLimayeDataset.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserLimayeDataset.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserLimayeDataset.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserMusicBrainz.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserMusicBrainz.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserMusicBrainz.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserMusicBrainz.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserReverbnation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserReverbnation.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserReverbnation.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserReverbnation.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserRottenTomato.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserRottenTomato.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserRottenTomato.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserRottenTomato.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserWikipedia.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserWikipedia.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserWikipedia.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserWikipedia.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractor.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractor.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractor.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractor.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorGeneric.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorGeneric.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorGeneric.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorGeneric.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorIMDB.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorIMDB.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorIMDB.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorIMDB.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorMusicBrainz.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorMusicBrainz.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorMusicBrainz.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorMusicBrainz.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorGoodreads.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorGoodreads.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorGoodreads.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorGoodreads.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorHTML.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorHTML.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorHTML.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorHTML.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorIMDB.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorIMDB.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorIMDB.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorIMDB.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorMusicBrainz.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorMusicBrainz.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorMusicBrainz.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorMusicBrainz.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorReverbnationList.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorReverbnationList.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorReverbnationList.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorReverbnationList.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorWikipediaGS.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorWikipediaGS.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorWikipediaGS.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorWikipediaGS.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/hodetector/TableHODetector.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/hodetector/TableHODetector.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/hodetector/TableHODetector.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/hodetector/TableHODetector.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/hodetector/TableHODetectorByHTMLTag.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/hodetector/TableHODetectorByHTMLTag.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/hodetector/TableHODetectorByHTMLTag.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/hodetector/TableHODetectorByHTMLTag.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerDiscardIrregularRows.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerDiscardIrregularRows.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerDiscardIrregularRows.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerDiscardIrregularRows.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerListTransformer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerListTransformer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerListTransformer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerListTransformer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerSimple.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerSimple.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerSimple.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerSimple.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorForWikipediaGSLanient.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorForWikipediaGSLanient.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorForWikipediaGSLanient.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorForWikipediaGSLanient.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorForWikipediaGSStrict.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorForWikipediaGSStrict.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorForWikipediaGSStrict.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorForWikipediaGSStrict.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorGeneric.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorGeneric.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorGeneric.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorGeneric.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/FreebaseTypeGranularityPopulator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/FreebaseTypeGranularityPopulator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/FreebaseTypeGranularityPopulator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/FreebaseTypeGranularityPopulator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/TAnnotationKeyFileReader.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/TAnnotationKeyFileReader.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/TAnnotationKeyFileReader.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/TAnnotationKeyFileReader.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/TestGRMM.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/TestGRMM.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/TestGRMM.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/TestGRMM.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/TestSubjectColumnDetector.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/TestSubjectColumnDetector.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/TestSubjectColumnDetector.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/TestSubjectColumnDetector.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_LimayeNew.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_LimayeNew.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_LimayeNew.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_LimayeNew.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_MB_IMDB.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_MB_IMDB.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_MB_IMDB.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_MB_IMDB.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Anaylsis_LimayeOld.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Anaylsis_LimayeOld.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Anaylsis_LimayeOld.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Anaylsis_LimayeOld.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_IMDB.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_IMDB.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_IMDB.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_IMDB.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_Limaye.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_Limaye.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_Limaye.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_Limaye.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_MB.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_MB.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_MB.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_MB.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly_IMDB_MusicBrainz.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly_IMDB_MusicBrainz.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly_IMDB_MusicBrainz.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly_IMDB_MusicBrainz.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_EntityOnly.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_EntityOnly.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_EntityOnly.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_EntityOnly.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Generic_Classification_ignoreUpdateIterations.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Generic_Classification_ignoreUpdateIterations.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Generic_Classification_ignoreUpdateIterations.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Generic_Classification_ignoreUpdateIterations.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ISWC_Helper_ClassOnly.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ISWC_Helper_ClassOnly.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ISWC_Helper_ClassOnly.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ISWC_Helper_ClassOnly.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Limaye_Entity_Only.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Limaye_Entity_Only.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Limaye_Entity_Only.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Limaye_Entity_Only.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly_IMDB_MusicBrainz.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly_IMDB_MusicBrainz.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly_IMDB_MusicBrainz.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly_IMDB_MusicBrainz.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/KeyFileGenerator_from_HTMLOutput.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/KeyFileGenerator_from_HTMLOutput.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/KeyFileGenerator_from_HTMLOutput.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/KeyFileGenerator_from_HTMLOutput.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_Analysis_Generic.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_Analysis_Generic.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_Analysis_Generic.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_Analysis_Generic.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_btw_Baseline_Tm_Finder.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_btw_Baseline_Tm_Finder.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_btw_Baseline_Tm_Finder.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_btw_Baseline_Tm_Finder.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_IMDB.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_IMDB.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_IMDB.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_IMDB.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_consolidate.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_consolidate.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_consolidate.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_consolidate.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_with_Ref.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_with_Ref.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_with_Ref.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_with_Ref.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_MusicBrainz.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_MusicBrainz.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_MusicBrainz.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_MusicBrainz.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSFile_Rewriter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSFile_Rewriter.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSFile_Rewriter.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSFile_Rewriter.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Class_Relation_Consolidation_Helper.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Class_Relation_Consolidation_Helper.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Class_Relation_Consolidation_Helper.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Class_Relation_Consolidation_Helper.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Stats_Limaye.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Stats_Limaye.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Stats_Limaye.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Stats_Limaye.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass1.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass1.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass1.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass1.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass2.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass2.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass2.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass2.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTableListPageFilter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTableListPageFilter.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTableListPageFilter.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTableListPageFilter.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/util/CollectionUtils.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/CollectionUtils.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/util/CollectionUtils.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/util/CollectionUtils.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/util/DataTypeClassifier.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/DataTypeClassifier.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/util/DataTypeClassifier.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/util/DataTypeClassifier.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/util/FileUtils.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/FileUtils.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/util/FileUtils.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/util/FileUtils.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/util/SubsetGenerator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/SubsetGenerator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/util/SubsetGenerator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/util/SubsetGenerator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/util/TripleGenerator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/TripleGenerator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/util/TripleGenerator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/util/TripleGenerator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/util/XPathUtils.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/XPathUtils.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/util/XPathUtils.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/util/XPathUtils.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/CharsetDetector.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/CharsetDetector.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/CharsetDetector.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/CharsetDetector.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/NoCSVDataException.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/NoCSVDataException.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/NoCSVDataException.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/NoCSVDataException.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParseFailed.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParseFailed.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParseFailed.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParseFailed.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/Parser.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/Parser.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/Parser.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/Parser.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsv.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsv.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsv.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsv.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsvConfig.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsvConfig.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsvConfig.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsvConfig.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/TableXtractorCSV.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/TableXtractorCSV.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/TableXtractorCSV.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/TableXtractorCSV.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/TestDetector.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/TestDetector.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/TestDetector.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/TestDetector.java diff --git a/websearch/pom.xml b/sti-websearch/pom.xml similarity index 100% rename from websearch/pom.xml rename to sti-websearch/pom.xml diff --git a/websearch/src/uk/ac/shef/dcs/websearch/SearchResultParser.java b/sti-websearch/src/uk/ac/shef/dcs/websearch/SearchResultParser.java similarity index 100% rename from websearch/src/uk/ac/shef/dcs/websearch/SearchResultParser.java rename to sti-websearch/src/uk/ac/shef/dcs/websearch/SearchResultParser.java diff --git a/websearch/src/uk/ac/shef/dcs/websearch/WebSearch.java b/sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearch.java similarity index 100% rename from websearch/src/uk/ac/shef/dcs/websearch/WebSearch.java rename to sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearch.java diff --git a/websearch/src/uk/ac/shef/dcs/websearch/WebSearchException.java b/sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearchException.java similarity index 100% rename from websearch/src/uk/ac/shef/dcs/websearch/WebSearchException.java rename to sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearchException.java diff --git a/websearch/src/uk/ac/shef/dcs/websearch/WebSearchFactory.java b/sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearchFactory.java similarity index 100% rename from websearch/src/uk/ac/shef/dcs/websearch/WebSearchFactory.java rename to sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearchFactory.java diff --git a/websearch/src/uk/ac/shef/dcs/websearch/WebSearchResultDoc.java b/sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearchResultDoc.java similarity index 100% rename from websearch/src/uk/ac/shef/dcs/websearch/WebSearchResultDoc.java rename to sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearchResultDoc.java diff --git a/websearch/src/uk/ac/shef/dcs/websearch/bing/v2/APIKeysDepletedException.java b/sti-websearch/src/uk/ac/shef/dcs/websearch/bing/v2/APIKeysDepletedException.java similarity index 100% rename from websearch/src/uk/ac/shef/dcs/websearch/bing/v2/APIKeysDepletedException.java rename to sti-websearch/src/uk/ac/shef/dcs/websearch/bing/v2/APIKeysDepletedException.java diff --git a/websearch/src/uk/ac/shef/dcs/websearch/bing/v2/BingSearch.java b/sti-websearch/src/uk/ac/shef/dcs/websearch/bing/v2/BingSearch.java similarity index 100% rename from websearch/src/uk/ac/shef/dcs/websearch/bing/v2/BingSearch.java rename to sti-websearch/src/uk/ac/shef/dcs/websearch/bing/v2/BingSearch.java diff --git a/websearch/src/uk/ac/shef/dcs/websearch/bing/v2/BingSearchResultParser.java b/sti-websearch/src/uk/ac/shef/dcs/websearch/bing/v2/BingSearchResultParser.java similarity index 100% rename from websearch/src/uk/ac/shef/dcs/websearch/bing/v2/BingSearchResultParser.java rename to sti-websearch/src/uk/ac/shef/dcs/websearch/bing/v2/BingSearchResultParser.java From 17f627147a0c7dc6ce8ce53a5639aec2944fd485 Mon Sep 17 00:00:00 2001 From: brodecva Date: Wed, 3 Aug 2016 23:34:12 +0200 Subject: [PATCH 069/211] Rename to make the merge easier. --- {any23-sti => sti-any23}/pom.xml | 0 .../src/org/apache/any23/extractor/LExtractionResultImpl.java | 0 .../src/uk/ac/shef/oak/any23/extension/extractor/LAny23.java | 0 .../src/uk/ac/shef/oak/any23/extension/extractor/LAny23Util.java | 0 .../ac/shef/oak/any23/extension/extractor/LExtractorRegistry.java | 0 .../shef/oak/any23/extension/extractor/LMicrodataExtractor.java | 0 .../oak/any23/extension/extractor/LMicrodataExtractorFactory.java | 0 .../ac/shef/oak/any23/extension/extractor/LMicrodataParser.java | 0 .../uk/ac/shef/oak/any23/extension/extractor/LNTripleWriter.java | 0 .../ac/shef/oak/any23/extension/extractor/LRDFa11Extractor.java | 0 .../oak/any23/extension/extractor/LRDFa11ExtractorFactory.java | 0 .../uk/ac/shef/oak/any23/extension/extractor/LRDFa11Parser.java | 0 .../oak/any23/extension/extractor/LSingleDocumentExtraction.java | 0 .../src/uk/ac/shef/oak/any23/extension/extractor/LTriple.java | 0 {common-util => sti-common-util}/pom.xml | 0 .../src/main/java/uk/ac/shef/dcs/util/SerializationUtils.java | 0 .../src/main/java/uk/ac/shef/dcs/util/SolrCache.java | 0 .../src/main/java/uk/ac/shef/dcs/util/StringUtils.java | 0 {kbsearch => sti-kbsearch}/pom.xml | 0 .../src/main/java/uk/ac/shef/dcs/kbsearch/KBSearch.java | 0 .../src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchException.java | 0 .../src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchFactory.java | 0 .../main/java/uk/ac/shef/dcs/kbsearch/KBSearchResultFilter.java | 0 .../java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseAttribute.java | 0 .../main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseEnum.java | 0 .../ac/shef/dcs/kbsearch/freebase/FreebaseQueryInterrupter.java | 0 .../java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryProxy.java | 0 .../java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearch.java | 0 .../ac/shef/dcs/kbsearch/freebase/FreebaseSearchResultFilter.java | 0 .../main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseTopic.java | 0 .../src/main/java/uk/ac/shef/dcs/kbsearch/model/Attribute.java | 0 .../src/main/java/uk/ac/shef/dcs/kbsearch/model/Clazz.java | 0 .../src/main/java/uk/ac/shef/dcs/kbsearch/model/Entity.java | 0 .../src/main/java/uk/ac/shef/dcs/kbsearch/model/Resource.java | 0 .../src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaEnum.java | 0 .../main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearch.java | 0 .../uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearchResultFilter.java | 0 .../src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DCEnum.java | 0 .../src/main/java/uk/ac/shef/dcs/kbsearch/sparql/FOAFEnum.java | 0 .../src/main/java/uk/ac/shef/dcs/kbsearch/sparql/RDFEnum.java | 0 .../main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLAttribute.java | 0 .../main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLSearch.java | 0 {core => sti-main}/log4j.properties | 0 {core => sti-main}/pom.xml | 0 {core => sti-main}/src/main/java/log4j.properties | 0 .../src/main/java/uk/ac/shef/dcs/sti/STIConstantProperty.java | 0 {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/STIEnum.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/STIException.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/any23/Any23Xtractor.java | 0 .../ac/shef/dcs/sti/core/algorithm/SemanticTableInterpreter.java | 0 .../shef/dcs/sti/core/algorithm/baseline/BaselineInterpreter.java | 0 .../dcs/sti/core/algorithm/baseline/BaselineRelationScorer.java | 0 .../core/algorithm/baseline/BaselineSimilarityClazzScorer.java | 0 .../core/algorithm/baseline/BaselineSimilarityEntityScorer.java | 0 .../shef/dcs/sti/core/algorithm/baseline/TCellDisambiguator.java | 0 .../sti/core/algorithm/baseline/TCellDisambiguatorNameMatch.java | 0 .../sti/core/algorithm/baseline/TCellDisambiguatorSimilarity.java | 0 .../shef/dcs/sti/core/algorithm/baseline/TColumnClassifier.java | 0 .../sti/core/algorithm/baseline/TColumnClassifierNameMatch.java | 0 .../sti/core/algorithm/baseline/TColumnClassifierSimilarity.java | 0 .../shef/dcs/sti/core/algorithm/ji/CandidateConceptGenerator.java | 0 .../shef/dcs/sti/core/algorithm/ji/CandidateEntityGenerator.java | 0 .../dcs/sti/core/algorithm/ji/CandidateRelationGenerator.java | 0 .../java/uk/ac/shef/dcs/sti/core/algorithm/ji/DebuggingUtil.java | 0 .../shef/dcs/sti/core/algorithm/ji/JIAdaptedAttributeMatcher.java | 0 .../ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedEntityScorer.java | 0 .../java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIClazzScorer.java | 0 .../java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIInterpreter.java | 0 .../java/uk/ac/shef/dcs/sti/core/algorithm/ji/TAnnotationJI.java | 0 .../java/uk/ac/shef/dcs/sti/core/algorithm/ji/VariableType.java | 0 .../shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilder.java | 0 .../dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCell.java | 0 .../algorithm/ji/factorgraph/FactorBuilderCellAndRelation.java | 0 .../sti/core/algorithm/ji/factorgraph/FactorBuilderHeader.java | 0 .../core/algorithm/ji/factorgraph/FactorBuilderHeaderAndCell.java | 0 .../algorithm/ji/factorgraph/FactorBuilderHeaderAndRelation.java | 0 .../dcs/sti/core/algorithm/ji/factorgraph/FactorGraphBuilder.java | 0 .../algorithm/ji/similarity/EntityAndClazzSimilarityScorer.java | 0 .../core/algorithm/ji/similarity/SimilarityComputerManager.java | 0 .../core/algorithm/ji/similarity/SimilarityComputerThread.java | 0 .../ac/shef/dcs/sti/core/algorithm/smp/CellAnnotationUpdater.java | 0 .../java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessage.java | 0 .../ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageComputer.java | 0 .../dcs/sti/core/algorithm/smp/ChangeMessageFromRelation.java | 0 .../dcs/sti/core/algorithm/smp/ClazzSpecificityCalculator.java | 0 .../core/algorithm/smp/FreebaseClazzSpecificityCalculator.java | 0 .../shef/dcs/sti/core/algorithm/smp/SMPAdaptedEntityScorer.java | 0 .../uk/ac/shef/dcs/sti/core/algorithm/smp/SMPInterpreter.java | 0 .../shef/dcs/sti/core/algorithm/smp/SemanticMessagePassing.java | 0 .../shef/dcs/sti/core/algorithm/smp/TAnnotationSMPFreebase.java | 0 .../ac/shef/dcs/sti/core/algorithm/smp/TAnnotationWriterSMP.java | 0 .../uk/ac/shef/dcs/sti/core/algorithm/smp/TCellEntityRanker.java | 0 .../uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnClassifier.java | 0 .../sti/core/algorithm/smp/TColumnColumnRelationEnumerator.java | 0 .../main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNING.java | 0 .../core/algorithm/tmp/LEARNINGPreliminaryColumnClassifier.java | 0 .../dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryDisamb.java | 0 .../ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTagger.java | 0 .../shef/dcs/sti/core/algorithm/tmp/LiteralColumnTaggerImpl.java | 0 .../ac/shef/dcs/sti/core/algorithm/tmp/RELATIONENUMERATION.java | 0 .../uk/ac/shef/dcs/sti/core/algorithm/tmp/TCellDisambiguator.java | 0 .../uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnClassifier.java | 0 .../sti/core/algorithm/tmp/TColumnColumnRelationEnumerator.java | 0 .../uk/ac/shef/dcs/sti/core/algorithm/tmp/TMPInterpreter.java | 0 .../main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/UPDATE.java | 0 .../ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_combined.java | 0 .../dcs/sti/core/algorithm/tmp/sampler/OSPD_contextWords.java | 0 .../shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nameLength.java | 0 .../dcs/sti/core/algorithm/tmp/sampler/OSPD_namelength_merge.java | 0 .../ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nonEmpty.java | 0 .../ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_random.java | 0 .../uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/Random.java | 0 .../dcs/sti/core/algorithm/tmp/sampler/TContentCellRanker.java | 0 .../dcs/sti/core/algorithm/tmp/sampler/TContentRowRanker.java | 0 .../core/algorithm/tmp/sampler/TContentTContentRowRankerImpl.java | 0 .../ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPClazzScorer.java | 0 .../shef/dcs/sti/core/algorithm/tmp/scorer/TMPEntityScorer.java | 0 .../shef/dcs/sti/core/algorithm/tmp/scorer/TMPRelationScorer.java | 0 .../dcs/sti/core/algorithm/tmp/stopping/FixedNumberOfRows.java | 0 .../java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/IInf.java | 0 .../uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/NoStop.java | 0 .../dcs/sti/core/algorithm/tmp/stopping/StoppingCriteria.java | 0 .../core/algorithm/tmp/stopping/StoppingCriteriaInstantiator.java | 0 .../ac/shef/dcs/sti/core/feature/FreebaseConceptBoWCreator.java | 0 .../ac/shef/dcs/sti/core/feature/FreebaseRelationBoWCreator.java | 0 .../uk/ac/shef/dcs/sti/core/feature/OntologyBasedBoWCreator.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/core/model/List.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/core/model/ListItem.java | 0 .../main/java/uk/ac/shef/dcs/sti/core/model/RelationColumns.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/core/model/TAnnotation.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/core/model/TCell.java | 0 .../main/java/uk/ac/shef/dcs/sti/core/model/TCellAnnotation.java | 0 .../uk/ac/shef/dcs/sti/core/model/TCellCellRelationAnotation.java | 0 .../shef/dcs/sti/core/model/TColumnColumnRelationAnnotation.java | 0 .../main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeader.java | 0 .../uk/ac/shef/dcs/sti/core/model/TColumnHeaderAnnotation.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/core/model/TContext.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/core/model/Table.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/core/model/TableTriple.java | 0 .../uk/ac/shef/dcs/sti/core/scorer/AttributeValueMatcher.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/core/scorer/ClazzScorer.java | 0 .../main/java/uk/ac/shef/dcs/sti/core/scorer/EntityScorer.java | 0 .../main/java/uk/ac/shef/dcs/sti/core/scorer/RelationScorer.java | 0 .../main/java/uk/ac/shef/dcs/sti/core/subjectcol/CMScorer.java | 0 .../uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnDetector.java | 0 .../uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorer.java | 0 .../dcs/sti/core/subjectcol/SubjectColumnScorerHeuristic.java | 0 .../java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnDataType.java | 0 .../java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeature.java | 0 .../ac/shef/dcs/sti/core/subjectcol/TColumnFeatureGenerator.java | 0 .../main/java/uk/ac/shef/dcs/sti/core/subjectcol/WSScorer.java | 0 .../main/java/uk/ac/shef/dcs/sti/experiment/BaselineBatch.java | 0 .../java/uk/ac/shef/dcs/sti/experiment/JointInferenceBatch.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/experiment/STIBatch.java | 0 .../ac/shef/dcs/sti/experiment/SemanticMessagePassingBatch.java | 0 .../java/uk/ac/shef/dcs/sti/experiment/TableMinerPlusBatch.java | 0 .../main/java/uk/ac/shef/dcs/sti/io/JSONOutputCellAnnotation.java | 0 .../java/uk/ac/shef/dcs/sti/io/JSONOutputColumnAnnotation.java | 0 .../java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotation.java | 0 .../uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotationPerRow.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriter.java | 0 .../main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriterJSON.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/nlp/Lemmatizer.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/nlp/NLPTools.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/nlp/TermFreqCounter.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/parser/ContentValidator.java | 0 .../main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractor.java | 0 .../java/uk/ac/shef/dcs/sti/parser/list/ListXtractorHTML.java | 0 .../uk/ac/shef/dcs/sti/parser/list/ListXtractorWikipedia.java | 0 .../uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitter.java | 0 .../shef/dcs/sti/parser/list/splitter/ListItemSplitterByURL.java | 0 .../shef/dcs/sti/parser/list/validator/ListVaildatorLanient.java | 0 .../uk/ac/shef/dcs/sti/parser/list/validator/ListValidator.java | 0 .../shef/dcs/sti/parser/list/validator/ListValidatorStrict.java | 0 .../main/java/uk/ac/shef/dcs/sti/parser/table/TableParser.java | 0 .../uk/ac/shef/dcs/sti/parser/table/TableParserGoodreads.java | 0 .../java/uk/ac/shef/dcs/sti/parser/table/TableParserHTML.java | 0 .../java/uk/ac/shef/dcs/sti/parser/table/TableParserIMDB.java | 0 .../uk/ac/shef/dcs/sti/parser/table/TableParserLimayeDataset.java | 0 .../uk/ac/shef/dcs/sti/parser/table/TableParserMusicBrainz.java | 0 .../uk/ac/shef/dcs/sti/parser/table/TableParserReverbnation.java | 0 .../uk/ac/shef/dcs/sti/parser/table/TableParserRottenTomato.java | 0 .../uk/ac/shef/dcs/sti/parser/table/TableParserWikipedia.java | 0 .../shef/dcs/sti/parser/table/context/TableContextExtractor.java | 0 .../sti/parser/table/context/TableContextExtractorGeneric.java | 0 .../dcs/sti/parser/table/context/TableContextExtractorIMDB.java | 0 .../parser/table/context/TableContextExtractorMusicBrainz.java | 0 .../uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreator.java | 0 .../dcs/sti/parser/table/creator/TableObjCreatorGoodreads.java | 0 .../ac/shef/dcs/sti/parser/table/creator/TableObjCreatorHTML.java | 0 .../ac/shef/dcs/sti/parser/table/creator/TableObjCreatorIMDB.java | 0 .../dcs/sti/parser/table/creator/TableObjCreatorMusicBrainz.java | 0 .../sti/parser/table/creator/TableObjCreatorReverbnationList.java | 0 .../dcs/sti/parser/table/creator/TableObjCreatorWikipediaGS.java | 0 .../ac/shef/dcs/sti/parser/table/hodetector/TableHODetector.java | 0 .../dcs/sti/parser/table/hodetector/TableHODetectorByHTMLTag.java | 0 .../ac/shef/dcs/sti/parser/table/normalizer/TableNormalizer.java | 0 .../table/normalizer/TableNormalizerDiscardIrregularRows.java | 0 .../parser/table/normalizer/TableNormalizerListTransformer.java | 0 .../dcs/sti/parser/table/normalizer/TableNormalizerSimple.java | 0 .../uk/ac/shef/dcs/sti/parser/table/validator/TableValidator.java | 0 .../table/validator/TableValidatorForWikipediaGSLanient.java | 0 .../table/validator/TableValidatorForWikipediaGSStrict.java | 0 .../dcs/sti/parser/table/validator/TableValidatorGeneric.java | 0 .../uk/ac/shef/dcs/sti/todo/FreebaseTypeGranularityPopulator.java | 0 .../java/uk/ac/shef/dcs/sti/todo/TAnnotationKeyFileReader.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/todo/TestGRMM.java | 0 .../java/uk/ac/shef/dcs/sti/todo/TestSubjectColumnDetector.java | 0 .../main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats.java | 0 .../DataStats_TableSize_NameLength_Analysis_LimayeNew.java | 0 .../DataStats_TableSize_NameLength_Analysis_MB_IMDB.java | 0 .../DataStats_TableSize_NameLength_Anaylsis_LimayeOld.java | 0 .../ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_IMDB.java | 0 .../shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_Limaye.java | 0 .../uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_MB.java | 0 .../uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly.java | 0 .../sti/todo/evaluation/Evaluator_ClassOnly_IMDB_MusicBrainz.java | 0 .../uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_EntityOnly.java | 0 .../Evaluator_Generic_Classification_ignoreUpdateIterations.java | 0 .../dcs/sti/todo/evaluation/Evaluator_ISWC_Helper_ClassOnly.java | 0 .../dcs/sti/todo/evaluation/Evaluator_Limaye_Entity_Only.java | 0 .../ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly.java | 0 .../todo/evaluation/Evaluator_RelationOnly_IMDB_MusicBrainz.java | 0 .../dcs/sti/todo/evaluation/KeyFileGenerator_from_HTMLOutput.java | 0 .../LimayeDataset_Entity_Discrepancy_Analysis_Generic.java | 0 .../LimayeDataset_Entity_Discrepancy_btw_Baseline_Tm_Finder.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_IMDB.java | 0 .../main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye.java | 0 .../uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables.java | 0 .../dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_consolidate.java | 0 .../dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_with_Ref.java | 0 .../java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_MusicBrainz.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSFile_Rewriter.java | 0 .../dcs/sti/todo/gs/GS_Class_Relation_Consolidation_Helper.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Stats_Limaye.java | 0 .../uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass1.java | 0 .../uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass2.java | 0 .../uk/ac/shef/dcs/sti/todo/gs/WikipediaTableListPageFilter.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/util/CollectionUtils.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/util/DataTypeClassifier.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/util/FileUtils.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/util/SubsetGenerator.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/util/TripleGenerator.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/util/XPathUtils.java | 0 .../java/uk/ac/shef/dcs/sti/xtractor/csv/CharsetDetector.java | 0 .../java/uk/ac/shef/dcs/sti/xtractor/csv/NoCSVDataException.java | 0 .../main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParseFailed.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/Parser.java | 0 .../src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsv.java | 0 .../java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsvConfig.java | 0 .../java/uk/ac/shef/dcs/sti/xtractor/csv/TableXtractorCSV.java | 0 .../main/java/uk/ac/shef/dcs/sti/xtractor/csv/TestDetector.java | 0 {websearch => sti-websearch}/pom.xml | 0 .../src/uk/ac/shef/dcs/websearch/SearchResultParser.java | 0 .../src/uk/ac/shef/dcs/websearch/WebSearch.java | 0 .../src/uk/ac/shef/dcs/websearch/WebSearchException.java | 0 .../src/uk/ac/shef/dcs/websearch/WebSearchFactory.java | 0 .../src/uk/ac/shef/dcs/websearch/WebSearchResultDoc.java | 0 .../ac/shef/dcs/websearch/bing/v2/APIKeysDepletedException.java | 0 .../src/uk/ac/shef/dcs/websearch/bing/v2/BingSearch.java | 0 .../uk/ac/shef/dcs/websearch/bing/v2/BingSearchResultParser.java | 0 261 files changed, 0 insertions(+), 0 deletions(-) rename {any23-sti => sti-any23}/pom.xml (100%) rename {any23-sti => sti-any23}/src/org/apache/any23/extractor/LExtractionResultImpl.java (100%) rename {any23-sti => sti-any23}/src/uk/ac/shef/oak/any23/extension/extractor/LAny23.java (100%) rename {any23-sti => sti-any23}/src/uk/ac/shef/oak/any23/extension/extractor/LAny23Util.java (100%) rename {any23-sti => sti-any23}/src/uk/ac/shef/oak/any23/extension/extractor/LExtractorRegistry.java (100%) rename {any23-sti => sti-any23}/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractor.java (100%) rename {any23-sti => sti-any23}/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractorFactory.java (100%) rename {any23-sti => sti-any23}/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataParser.java (100%) rename {any23-sti => sti-any23}/src/uk/ac/shef/oak/any23/extension/extractor/LNTripleWriter.java (100%) rename {any23-sti => sti-any23}/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Extractor.java (100%) rename {any23-sti => sti-any23}/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11ExtractorFactory.java (100%) rename {any23-sti => sti-any23}/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Parser.java (100%) rename {any23-sti => sti-any23}/src/uk/ac/shef/oak/any23/extension/extractor/LSingleDocumentExtraction.java (100%) rename {any23-sti => sti-any23}/src/uk/ac/shef/oak/any23/extension/extractor/LTriple.java (100%) rename {common-util => sti-common-util}/pom.xml (100%) rename {common-util => sti-common-util}/src/main/java/uk/ac/shef/dcs/util/SerializationUtils.java (100%) rename {common-util => sti-common-util}/src/main/java/uk/ac/shef/dcs/util/SolrCache.java (100%) rename {common-util => sti-common-util}/src/main/java/uk/ac/shef/dcs/util/StringUtils.java (100%) rename {kbsearch => sti-kbsearch}/pom.xml (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearch.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchException.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchFactory.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchResultFilter.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseAttribute.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseEnum.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryInterrupter.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryProxy.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearch.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearchResultFilter.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseTopic.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/model/Attribute.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/model/Clazz.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/model/Entity.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/model/Resource.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaEnum.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearch.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearchResultFilter.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DCEnum.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/FOAFEnum.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/RDFEnum.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLAttribute.java (100%) rename {kbsearch => sti-kbsearch}/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLSearch.java (100%) rename {core => sti-main}/log4j.properties (100%) rename {core => sti-main}/pom.xml (100%) rename {core => sti-main}/src/main/java/log4j.properties (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/STIConstantProperty.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/STIEnum.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/STIException.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/any23/Any23Xtractor.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/SemanticTableInterpreter.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineInterpreter.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineRelationScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineSimilarityClazzScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineSimilarityEntityScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguatorNameMatch.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguatorSimilarity.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifier.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifierNameMatch.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifierSimilarity.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateConceptGenerator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateEntityGenerator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateRelationGenerator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/DebuggingUtil.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedAttributeMatcher.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedEntityScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIClazzScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIInterpreter.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/TAnnotationJI.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/VariableType.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilder.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCell.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCellAndRelation.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeader.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeaderAndCell.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeaderAndRelation.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorGraphBuilder.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/EntityAndClazzSimilarityScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/SimilarityComputerManager.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/SimilarityComputerThread.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/CellAnnotationUpdater.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessage.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageComputer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageFromRelation.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ClazzSpecificityCalculator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/FreebaseClazzSpecificityCalculator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SMPAdaptedEntityScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SMPInterpreter.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SemanticMessagePassing.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TAnnotationSMPFreebase.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TAnnotationWriterSMP.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TCellEntityRanker.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnClassifier.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnColumnRelationEnumerator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNING.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryColumnClassifier.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryDisamb.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTagger.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTaggerImpl.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/RELATIONENUMERATION.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TCellDisambiguator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnClassifier.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnColumnRelationEnumerator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TMPInterpreter.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/UPDATE.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_combined.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_contextWords.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nameLength.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_namelength_merge.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nonEmpty.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_random.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/Random.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentCellRanker.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentRowRanker.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentTContentRowRankerImpl.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPClazzScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPEntityScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPRelationScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/FixedNumberOfRows.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/IInf.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/NoStop.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/StoppingCriteria.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/StoppingCriteriaInstantiator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/feature/FreebaseConceptBoWCreator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/feature/FreebaseRelationBoWCreator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/feature/OntologyBasedBoWCreator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/model/List.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/model/ListItem.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/model/RelationColumns.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/model/TAnnotation.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/model/TCell.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/model/TCellAnnotation.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/model/TCellCellRelationAnotation.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnColumnRelationAnnotation.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeader.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeaderAnnotation.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/model/TContext.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/model/Table.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/model/TableTriple.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/scorer/AttributeValueMatcher.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/scorer/ClazzScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/scorer/EntityScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/scorer/RelationScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/CMScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnDetector.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorerHeuristic.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnDataType.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeature.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeatureGenerator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/WSScorer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/experiment/BaselineBatch.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/experiment/JointInferenceBatch.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/experiment/STIBatch.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/experiment/SemanticMessagePassingBatch.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/experiment/TableMinerPlusBatch.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputCellAnnotation.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputColumnAnnotation.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotation.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotationPerRow.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriter.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriterJSON.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/nlp/Lemmatizer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/nlp/NLPTools.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/nlp/TermFreqCounter.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/ContentValidator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractor.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorHTML.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorWikipedia.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitter.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitterByURL.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListVaildatorLanient.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListValidator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListValidatorStrict.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParser.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserGoodreads.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserHTML.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserIMDB.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserLimayeDataset.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserMusicBrainz.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserReverbnation.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserRottenTomato.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserWikipedia.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractor.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorGeneric.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorIMDB.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorMusicBrainz.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorGoodreads.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorHTML.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorIMDB.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorMusicBrainz.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorReverbnationList.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorWikipediaGS.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/hodetector/TableHODetector.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/hodetector/TableHODetectorByHTMLTag.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerDiscardIrregularRows.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerListTransformer.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerSimple.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorForWikipediaGSLanient.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorForWikipediaGSStrict.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorGeneric.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/FreebaseTypeGranularityPopulator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/TAnnotationKeyFileReader.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/TestGRMM.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/TestSubjectColumnDetector.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_LimayeNew.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_MB_IMDB.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Anaylsis_LimayeOld.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_IMDB.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_Limaye.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_MB.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly_IMDB_MusicBrainz.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_EntityOnly.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Generic_Classification_ignoreUpdateIterations.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ISWC_Helper_ClassOnly.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Limaye_Entity_Only.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly_IMDB_MusicBrainz.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/KeyFileGenerator_from_HTMLOutput.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_Analysis_Generic.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_btw_Baseline_Tm_Finder.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_IMDB.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_consolidate.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_with_Ref.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_MusicBrainz.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSFile_Rewriter.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Class_Relation_Consolidation_Helper.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Stats_Limaye.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass1.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass2.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTableListPageFilter.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/util/CollectionUtils.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/util/DataTypeClassifier.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/util/FileUtils.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/util/SubsetGenerator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/util/TripleGenerator.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/util/XPathUtils.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/CharsetDetector.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/NoCSVDataException.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParseFailed.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/Parser.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsv.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsvConfig.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/TableXtractorCSV.java (100%) rename {core => sti-main}/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/TestDetector.java (100%) rename {websearch => sti-websearch}/pom.xml (100%) rename {websearch => sti-websearch}/src/uk/ac/shef/dcs/websearch/SearchResultParser.java (100%) rename {websearch => sti-websearch}/src/uk/ac/shef/dcs/websearch/WebSearch.java (100%) rename {websearch => sti-websearch}/src/uk/ac/shef/dcs/websearch/WebSearchException.java (100%) rename {websearch => sti-websearch}/src/uk/ac/shef/dcs/websearch/WebSearchFactory.java (100%) rename {websearch => sti-websearch}/src/uk/ac/shef/dcs/websearch/WebSearchResultDoc.java (100%) rename {websearch => sti-websearch}/src/uk/ac/shef/dcs/websearch/bing/v2/APIKeysDepletedException.java (100%) rename {websearch => sti-websearch}/src/uk/ac/shef/dcs/websearch/bing/v2/BingSearch.java (100%) rename {websearch => sti-websearch}/src/uk/ac/shef/dcs/websearch/bing/v2/BingSearchResultParser.java (100%) diff --git a/any23-sti/pom.xml b/sti-any23/pom.xml similarity index 100% rename from any23-sti/pom.xml rename to sti-any23/pom.xml diff --git a/any23-sti/src/org/apache/any23/extractor/LExtractionResultImpl.java b/sti-any23/src/org/apache/any23/extractor/LExtractionResultImpl.java similarity index 100% rename from any23-sti/src/org/apache/any23/extractor/LExtractionResultImpl.java rename to sti-any23/src/org/apache/any23/extractor/LExtractionResultImpl.java diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LAny23.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LAny23.java similarity index 100% rename from any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LAny23.java rename to sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LAny23.java diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LAny23Util.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LAny23Util.java similarity index 100% rename from any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LAny23Util.java rename to sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LAny23Util.java diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LExtractorRegistry.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LExtractorRegistry.java similarity index 100% rename from any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LExtractorRegistry.java rename to sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LExtractorRegistry.java diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractor.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractor.java similarity index 100% rename from any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractor.java rename to sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractor.java diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractorFactory.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractorFactory.java similarity index 100% rename from any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractorFactory.java rename to sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractorFactory.java diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataParser.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataParser.java similarity index 100% rename from any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataParser.java rename to sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataParser.java diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LNTripleWriter.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LNTripleWriter.java similarity index 100% rename from any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LNTripleWriter.java rename to sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LNTripleWriter.java diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Extractor.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Extractor.java similarity index 100% rename from any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Extractor.java rename to sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Extractor.java diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11ExtractorFactory.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11ExtractorFactory.java similarity index 100% rename from any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11ExtractorFactory.java rename to sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11ExtractorFactory.java diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Parser.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Parser.java similarity index 100% rename from any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Parser.java rename to sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Parser.java diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LSingleDocumentExtraction.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LSingleDocumentExtraction.java similarity index 100% rename from any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LSingleDocumentExtraction.java rename to sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LSingleDocumentExtraction.java diff --git a/any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LTriple.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LTriple.java similarity index 100% rename from any23-sti/src/uk/ac/shef/oak/any23/extension/extractor/LTriple.java rename to sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LTriple.java diff --git a/common-util/pom.xml b/sti-common-util/pom.xml similarity index 100% rename from common-util/pom.xml rename to sti-common-util/pom.xml diff --git a/common-util/src/main/java/uk/ac/shef/dcs/util/SerializationUtils.java b/sti-common-util/src/main/java/uk/ac/shef/dcs/util/SerializationUtils.java similarity index 100% rename from common-util/src/main/java/uk/ac/shef/dcs/util/SerializationUtils.java rename to sti-common-util/src/main/java/uk/ac/shef/dcs/util/SerializationUtils.java diff --git a/common-util/src/main/java/uk/ac/shef/dcs/util/SolrCache.java b/sti-common-util/src/main/java/uk/ac/shef/dcs/util/SolrCache.java similarity index 100% rename from common-util/src/main/java/uk/ac/shef/dcs/util/SolrCache.java rename to sti-common-util/src/main/java/uk/ac/shef/dcs/util/SolrCache.java diff --git a/common-util/src/main/java/uk/ac/shef/dcs/util/StringUtils.java b/sti-common-util/src/main/java/uk/ac/shef/dcs/util/StringUtils.java similarity index 100% rename from common-util/src/main/java/uk/ac/shef/dcs/util/StringUtils.java rename to sti-common-util/src/main/java/uk/ac/shef/dcs/util/StringUtils.java diff --git a/kbsearch/pom.xml b/sti-kbsearch/pom.xml similarity index 100% rename from kbsearch/pom.xml rename to sti-kbsearch/pom.xml diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearch.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearch.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearch.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearch.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchException.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchException.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchException.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchException.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchFactory.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchFactory.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchFactory.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchFactory.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchResultFilter.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchResultFilter.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchResultFilter.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchResultFilter.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseAttribute.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseAttribute.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseAttribute.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseAttribute.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseEnum.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseEnum.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseEnum.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseEnum.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryInterrupter.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryInterrupter.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryInterrupter.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryInterrupter.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryProxy.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryProxy.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryProxy.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryProxy.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearch.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearch.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearch.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearch.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearchResultFilter.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearchResultFilter.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearchResultFilter.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseSearchResultFilter.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseTopic.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseTopic.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseTopic.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseTopic.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Attribute.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Attribute.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Attribute.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Attribute.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Clazz.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Clazz.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Clazz.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Clazz.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Entity.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Entity.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Entity.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Entity.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Resource.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Resource.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Resource.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Resource.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaEnum.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaEnum.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaEnum.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaEnum.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearch.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearch.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearch.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearch.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearchResultFilter.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearchResultFilter.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearchResultFilter.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaSearchResultFilter.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DCEnum.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DCEnum.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DCEnum.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DCEnum.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/FOAFEnum.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/FOAFEnum.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/FOAFEnum.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/FOAFEnum.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/RDFEnum.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/RDFEnum.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/RDFEnum.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/RDFEnum.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLAttribute.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLAttribute.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLAttribute.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLAttribute.java diff --git a/kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLSearch.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLSearch.java similarity index 100% rename from kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLSearch.java rename to sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/SPARQLSearch.java diff --git a/core/log4j.properties b/sti-main/log4j.properties similarity index 100% rename from core/log4j.properties rename to sti-main/log4j.properties diff --git a/core/pom.xml b/sti-main/pom.xml similarity index 100% rename from core/pom.xml rename to sti-main/pom.xml diff --git a/core/src/main/java/log4j.properties b/sti-main/src/main/java/log4j.properties similarity index 100% rename from core/src/main/java/log4j.properties rename to sti-main/src/main/java/log4j.properties diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/STIConstantProperty.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/STIConstantProperty.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/STIConstantProperty.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/STIConstantProperty.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/STIEnum.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/STIEnum.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/STIEnum.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/STIEnum.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/STIException.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/STIException.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/STIException.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/STIException.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/any23/Any23Xtractor.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/any23/Any23Xtractor.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/any23/Any23Xtractor.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/any23/Any23Xtractor.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/SemanticTableInterpreter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/SemanticTableInterpreter.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/SemanticTableInterpreter.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/SemanticTableInterpreter.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineInterpreter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineInterpreter.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineInterpreter.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineInterpreter.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineRelationScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineRelationScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineRelationScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineRelationScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineSimilarityClazzScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineSimilarityClazzScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineSimilarityClazzScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineSimilarityClazzScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineSimilarityEntityScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineSimilarityEntityScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineSimilarityEntityScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineSimilarityEntityScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguatorNameMatch.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguatorNameMatch.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguatorNameMatch.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguatorNameMatch.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguatorSimilarity.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguatorSimilarity.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguatorSimilarity.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguatorSimilarity.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifier.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifier.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifier.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifier.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifierNameMatch.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifierNameMatch.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifierNameMatch.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifierNameMatch.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifierSimilarity.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifierSimilarity.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifierSimilarity.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifierSimilarity.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateConceptGenerator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateConceptGenerator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateConceptGenerator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateConceptGenerator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateEntityGenerator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateEntityGenerator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateEntityGenerator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateEntityGenerator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateRelationGenerator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateRelationGenerator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateRelationGenerator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateRelationGenerator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/DebuggingUtil.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/DebuggingUtil.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/DebuggingUtil.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/DebuggingUtil.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedAttributeMatcher.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedAttributeMatcher.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedAttributeMatcher.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedAttributeMatcher.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedEntityScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedEntityScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedEntityScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedEntityScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIClazzScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIClazzScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIClazzScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIClazzScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIInterpreter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIInterpreter.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIInterpreter.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIInterpreter.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/TAnnotationJI.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/TAnnotationJI.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/TAnnotationJI.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/TAnnotationJI.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/VariableType.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/VariableType.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/VariableType.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/VariableType.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilder.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilder.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilder.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilder.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCell.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCell.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCell.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCell.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCellAndRelation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCellAndRelation.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCellAndRelation.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCellAndRelation.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeader.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeader.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeader.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeader.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeaderAndCell.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeaderAndCell.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeaderAndCell.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeaderAndCell.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeaderAndRelation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeaderAndRelation.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeaderAndRelation.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeaderAndRelation.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorGraphBuilder.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorGraphBuilder.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorGraphBuilder.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorGraphBuilder.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/EntityAndClazzSimilarityScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/EntityAndClazzSimilarityScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/EntityAndClazzSimilarityScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/EntityAndClazzSimilarityScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/SimilarityComputerManager.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/SimilarityComputerManager.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/SimilarityComputerManager.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/SimilarityComputerManager.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/SimilarityComputerThread.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/SimilarityComputerThread.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/SimilarityComputerThread.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/SimilarityComputerThread.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/CellAnnotationUpdater.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/CellAnnotationUpdater.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/CellAnnotationUpdater.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/CellAnnotationUpdater.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessage.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessage.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessage.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessage.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageComputer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageComputer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageComputer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageComputer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageFromRelation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageFromRelation.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageFromRelation.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageFromRelation.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ClazzSpecificityCalculator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ClazzSpecificityCalculator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ClazzSpecificityCalculator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ClazzSpecificityCalculator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/FreebaseClazzSpecificityCalculator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/FreebaseClazzSpecificityCalculator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/FreebaseClazzSpecificityCalculator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/FreebaseClazzSpecificityCalculator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SMPAdaptedEntityScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SMPAdaptedEntityScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SMPAdaptedEntityScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SMPAdaptedEntityScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SMPInterpreter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SMPInterpreter.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SMPInterpreter.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SMPInterpreter.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SemanticMessagePassing.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SemanticMessagePassing.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SemanticMessagePassing.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SemanticMessagePassing.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TAnnotationSMPFreebase.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TAnnotationSMPFreebase.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TAnnotationSMPFreebase.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TAnnotationSMPFreebase.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TAnnotationWriterSMP.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TAnnotationWriterSMP.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TAnnotationWriterSMP.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TAnnotationWriterSMP.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TCellEntityRanker.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TCellEntityRanker.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TCellEntityRanker.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TCellEntityRanker.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnClassifier.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnClassifier.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnClassifier.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnClassifier.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnColumnRelationEnumerator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnColumnRelationEnumerator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnColumnRelationEnumerator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnColumnRelationEnumerator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNING.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNING.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNING.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNING.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryColumnClassifier.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryColumnClassifier.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryColumnClassifier.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryColumnClassifier.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryDisamb.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryDisamb.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryDisamb.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryDisamb.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTagger.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTagger.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTagger.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTagger.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTaggerImpl.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTaggerImpl.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTaggerImpl.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTaggerImpl.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/RELATIONENUMERATION.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/RELATIONENUMERATION.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/RELATIONENUMERATION.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/RELATIONENUMERATION.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TCellDisambiguator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TCellDisambiguator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TCellDisambiguator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TCellDisambiguator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnClassifier.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnClassifier.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnClassifier.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnClassifier.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnColumnRelationEnumerator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnColumnRelationEnumerator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnColumnRelationEnumerator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnColumnRelationEnumerator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TMPInterpreter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TMPInterpreter.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TMPInterpreter.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TMPInterpreter.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/UPDATE.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/UPDATE.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/UPDATE.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/UPDATE.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_combined.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_combined.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_combined.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_combined.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_contextWords.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_contextWords.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_contextWords.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_contextWords.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nameLength.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nameLength.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nameLength.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nameLength.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_namelength_merge.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_namelength_merge.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_namelength_merge.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_namelength_merge.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nonEmpty.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nonEmpty.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nonEmpty.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nonEmpty.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_random.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_random.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_random.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_random.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/Random.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/Random.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/Random.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/Random.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentCellRanker.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentCellRanker.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentCellRanker.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentCellRanker.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentRowRanker.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentRowRanker.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentRowRanker.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentRowRanker.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentTContentRowRankerImpl.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentTContentRowRankerImpl.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentTContentRowRankerImpl.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentTContentRowRankerImpl.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPClazzScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPClazzScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPClazzScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPClazzScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPEntityScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPEntityScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPEntityScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPEntityScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPRelationScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPRelationScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPRelationScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPRelationScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/FixedNumberOfRows.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/FixedNumberOfRows.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/FixedNumberOfRows.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/FixedNumberOfRows.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/IInf.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/IInf.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/IInf.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/IInf.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/NoStop.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/NoStop.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/NoStop.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/NoStop.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/StoppingCriteria.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/StoppingCriteria.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/StoppingCriteria.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/StoppingCriteria.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/StoppingCriteriaInstantiator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/StoppingCriteriaInstantiator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/StoppingCriteriaInstantiator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/StoppingCriteriaInstantiator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/feature/FreebaseConceptBoWCreator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/feature/FreebaseConceptBoWCreator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/feature/FreebaseConceptBoWCreator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/feature/FreebaseConceptBoWCreator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/feature/FreebaseRelationBoWCreator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/feature/FreebaseRelationBoWCreator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/feature/FreebaseRelationBoWCreator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/feature/FreebaseRelationBoWCreator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/feature/OntologyBasedBoWCreator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/feature/OntologyBasedBoWCreator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/feature/OntologyBasedBoWCreator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/feature/OntologyBasedBoWCreator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/model/List.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/List.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/model/List.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/List.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/model/ListItem.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/ListItem.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/model/ListItem.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/ListItem.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/model/RelationColumns.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/RelationColumns.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/model/RelationColumns.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/RelationColumns.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/model/TAnnotation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TAnnotation.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/model/TAnnotation.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TAnnotation.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/model/TCell.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TCell.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/model/TCell.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TCell.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/model/TCellAnnotation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TCellAnnotation.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/model/TCellAnnotation.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TCellAnnotation.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/model/TCellCellRelationAnotation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TCellCellRelationAnotation.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/model/TCellCellRelationAnotation.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TCellCellRelationAnotation.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnColumnRelationAnnotation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnColumnRelationAnnotation.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnColumnRelationAnnotation.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnColumnRelationAnnotation.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeader.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeader.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeader.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeader.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeaderAnnotation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeaderAnnotation.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeaderAnnotation.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeaderAnnotation.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/model/TContext.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TContext.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/model/TContext.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TContext.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/model/Table.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/Table.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/model/Table.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/Table.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/model/TableTriple.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TableTriple.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/model/TableTriple.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TableTriple.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/scorer/AttributeValueMatcher.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/AttributeValueMatcher.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/scorer/AttributeValueMatcher.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/AttributeValueMatcher.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/scorer/ClazzScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/ClazzScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/scorer/ClazzScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/ClazzScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/scorer/EntityScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/EntityScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/scorer/EntityScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/EntityScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/scorer/RelationScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/RelationScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/scorer/RelationScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/RelationScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/CMScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/CMScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/CMScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/CMScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnDetector.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnDetector.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnDetector.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnDetector.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorerHeuristic.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorerHeuristic.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorerHeuristic.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorerHeuristic.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnDataType.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnDataType.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnDataType.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnDataType.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeature.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeature.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeature.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeature.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeatureGenerator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeatureGenerator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeatureGenerator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeatureGenerator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/WSScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/WSScorer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/WSScorer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/WSScorer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/experiment/BaselineBatch.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/BaselineBatch.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/experiment/BaselineBatch.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/BaselineBatch.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/experiment/JointInferenceBatch.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/JointInferenceBatch.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/experiment/JointInferenceBatch.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/JointInferenceBatch.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/experiment/STIBatch.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/STIBatch.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/experiment/STIBatch.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/STIBatch.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/experiment/SemanticMessagePassingBatch.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/SemanticMessagePassingBatch.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/experiment/SemanticMessagePassingBatch.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/SemanticMessagePassingBatch.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/experiment/TableMinerPlusBatch.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/TableMinerPlusBatch.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/experiment/TableMinerPlusBatch.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/TableMinerPlusBatch.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputCellAnnotation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputCellAnnotation.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputCellAnnotation.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputCellAnnotation.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputColumnAnnotation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputColumnAnnotation.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputColumnAnnotation.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputColumnAnnotation.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotation.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotation.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotation.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotationPerRow.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotationPerRow.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotationPerRow.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotationPerRow.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriter.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriter.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriter.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriterJSON.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriterJSON.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriterJSON.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriterJSON.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/nlp/Lemmatizer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/nlp/Lemmatizer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/nlp/Lemmatizer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/nlp/Lemmatizer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/nlp/NLPTools.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/nlp/NLPTools.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/nlp/NLPTools.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/nlp/NLPTools.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/nlp/TermFreqCounter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/nlp/TermFreqCounter.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/nlp/TermFreqCounter.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/nlp/TermFreqCounter.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/ContentValidator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/ContentValidator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/ContentValidator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/ContentValidator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractor.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractor.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractor.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractor.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorHTML.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorHTML.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorHTML.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorHTML.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorWikipedia.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorWikipedia.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorWikipedia.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorWikipedia.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitter.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitter.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitter.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitterByURL.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitterByURL.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitterByURL.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitterByURL.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListVaildatorLanient.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListVaildatorLanient.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListVaildatorLanient.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListVaildatorLanient.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListValidator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListValidator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListValidator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListValidator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListValidatorStrict.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListValidatorStrict.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListValidatorStrict.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListValidatorStrict.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParser.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParser.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParser.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParser.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserGoodreads.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserGoodreads.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserGoodreads.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserGoodreads.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserHTML.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserHTML.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserHTML.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserHTML.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserIMDB.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserIMDB.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserIMDB.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserIMDB.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserLimayeDataset.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserLimayeDataset.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserLimayeDataset.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserLimayeDataset.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserMusicBrainz.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserMusicBrainz.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserMusicBrainz.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserMusicBrainz.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserReverbnation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserReverbnation.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserReverbnation.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserReverbnation.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserRottenTomato.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserRottenTomato.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserRottenTomato.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserRottenTomato.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserWikipedia.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserWikipedia.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserWikipedia.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserWikipedia.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractor.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractor.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractor.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractor.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorGeneric.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorGeneric.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorGeneric.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorGeneric.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorIMDB.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorIMDB.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorIMDB.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorIMDB.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorMusicBrainz.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorMusicBrainz.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorMusicBrainz.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorMusicBrainz.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorGoodreads.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorGoodreads.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorGoodreads.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorGoodreads.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorHTML.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorHTML.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorHTML.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorHTML.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorIMDB.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorIMDB.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorIMDB.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorIMDB.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorMusicBrainz.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorMusicBrainz.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorMusicBrainz.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorMusicBrainz.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorReverbnationList.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorReverbnationList.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorReverbnationList.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorReverbnationList.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorWikipediaGS.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorWikipediaGS.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorWikipediaGS.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorWikipediaGS.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/hodetector/TableHODetector.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/hodetector/TableHODetector.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/hodetector/TableHODetector.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/hodetector/TableHODetector.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/hodetector/TableHODetectorByHTMLTag.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/hodetector/TableHODetectorByHTMLTag.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/hodetector/TableHODetectorByHTMLTag.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/hodetector/TableHODetectorByHTMLTag.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerDiscardIrregularRows.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerDiscardIrregularRows.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerDiscardIrregularRows.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerDiscardIrregularRows.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerListTransformer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerListTransformer.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerListTransformer.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerListTransformer.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerSimple.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerSimple.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerSimple.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerSimple.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorForWikipediaGSLanient.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorForWikipediaGSLanient.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorForWikipediaGSLanient.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorForWikipediaGSLanient.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorForWikipediaGSStrict.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorForWikipediaGSStrict.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorForWikipediaGSStrict.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorForWikipediaGSStrict.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorGeneric.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorGeneric.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorGeneric.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorGeneric.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/FreebaseTypeGranularityPopulator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/FreebaseTypeGranularityPopulator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/FreebaseTypeGranularityPopulator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/FreebaseTypeGranularityPopulator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/TAnnotationKeyFileReader.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/TAnnotationKeyFileReader.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/TAnnotationKeyFileReader.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/TAnnotationKeyFileReader.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/TestGRMM.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/TestGRMM.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/TestGRMM.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/TestGRMM.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/TestSubjectColumnDetector.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/TestSubjectColumnDetector.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/TestSubjectColumnDetector.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/TestSubjectColumnDetector.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_LimayeNew.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_LimayeNew.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_LimayeNew.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_LimayeNew.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_MB_IMDB.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_MB_IMDB.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_MB_IMDB.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_MB_IMDB.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Anaylsis_LimayeOld.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Anaylsis_LimayeOld.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Anaylsis_LimayeOld.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Anaylsis_LimayeOld.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_IMDB.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_IMDB.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_IMDB.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_IMDB.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_Limaye.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_Limaye.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_Limaye.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_Limaye.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_MB.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_MB.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_MB.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_MB.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly_IMDB_MusicBrainz.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly_IMDB_MusicBrainz.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly_IMDB_MusicBrainz.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly_IMDB_MusicBrainz.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_EntityOnly.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_EntityOnly.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_EntityOnly.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_EntityOnly.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Generic_Classification_ignoreUpdateIterations.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Generic_Classification_ignoreUpdateIterations.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Generic_Classification_ignoreUpdateIterations.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Generic_Classification_ignoreUpdateIterations.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ISWC_Helper_ClassOnly.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ISWC_Helper_ClassOnly.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ISWC_Helper_ClassOnly.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ISWC_Helper_ClassOnly.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Limaye_Entity_Only.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Limaye_Entity_Only.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Limaye_Entity_Only.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Limaye_Entity_Only.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly_IMDB_MusicBrainz.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly_IMDB_MusicBrainz.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly_IMDB_MusicBrainz.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly_IMDB_MusicBrainz.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/KeyFileGenerator_from_HTMLOutput.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/KeyFileGenerator_from_HTMLOutput.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/KeyFileGenerator_from_HTMLOutput.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/KeyFileGenerator_from_HTMLOutput.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_Analysis_Generic.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_Analysis_Generic.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_Analysis_Generic.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_Analysis_Generic.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_btw_Baseline_Tm_Finder.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_btw_Baseline_Tm_Finder.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_btw_Baseline_Tm_Finder.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/LimayeDataset_Entity_Discrepancy_btw_Baseline_Tm_Finder.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_IMDB.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_IMDB.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_IMDB.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_IMDB.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_consolidate.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_consolidate.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_consolidate.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_consolidate.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_with_Ref.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_with_Ref.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_with_Ref.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_with_Ref.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_MusicBrainz.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_MusicBrainz.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_MusicBrainz.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_MusicBrainz.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSFile_Rewriter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSFile_Rewriter.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSFile_Rewriter.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSFile_Rewriter.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Class_Relation_Consolidation_Helper.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Class_Relation_Consolidation_Helper.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Class_Relation_Consolidation_Helper.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Class_Relation_Consolidation_Helper.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Stats_Limaye.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Stats_Limaye.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Stats_Limaye.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Stats_Limaye.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass1.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass1.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass1.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass1.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass2.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass2.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass2.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass2.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTableListPageFilter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTableListPageFilter.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTableListPageFilter.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTableListPageFilter.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/util/CollectionUtils.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/CollectionUtils.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/util/CollectionUtils.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/util/CollectionUtils.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/util/DataTypeClassifier.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/DataTypeClassifier.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/util/DataTypeClassifier.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/util/DataTypeClassifier.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/util/FileUtils.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/FileUtils.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/util/FileUtils.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/util/FileUtils.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/util/SubsetGenerator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/SubsetGenerator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/util/SubsetGenerator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/util/SubsetGenerator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/util/TripleGenerator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/TripleGenerator.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/util/TripleGenerator.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/util/TripleGenerator.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/util/XPathUtils.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/XPathUtils.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/util/XPathUtils.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/util/XPathUtils.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/CharsetDetector.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/CharsetDetector.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/CharsetDetector.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/CharsetDetector.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/NoCSVDataException.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/NoCSVDataException.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/NoCSVDataException.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/NoCSVDataException.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParseFailed.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParseFailed.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParseFailed.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParseFailed.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/Parser.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/Parser.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/Parser.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/Parser.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsv.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsv.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsv.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsv.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsvConfig.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsvConfig.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsvConfig.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/ParserCsvConfig.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/TableXtractorCSV.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/TableXtractorCSV.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/TableXtractorCSV.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/TableXtractorCSV.java diff --git a/core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/TestDetector.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/TestDetector.java similarity index 100% rename from core/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/TestDetector.java rename to sti-main/src/main/java/uk/ac/shef/dcs/sti/xtractor/csv/TestDetector.java diff --git a/websearch/pom.xml b/sti-websearch/pom.xml similarity index 100% rename from websearch/pom.xml rename to sti-websearch/pom.xml diff --git a/websearch/src/uk/ac/shef/dcs/websearch/SearchResultParser.java b/sti-websearch/src/uk/ac/shef/dcs/websearch/SearchResultParser.java similarity index 100% rename from websearch/src/uk/ac/shef/dcs/websearch/SearchResultParser.java rename to sti-websearch/src/uk/ac/shef/dcs/websearch/SearchResultParser.java diff --git a/websearch/src/uk/ac/shef/dcs/websearch/WebSearch.java b/sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearch.java similarity index 100% rename from websearch/src/uk/ac/shef/dcs/websearch/WebSearch.java rename to sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearch.java diff --git a/websearch/src/uk/ac/shef/dcs/websearch/WebSearchException.java b/sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearchException.java similarity index 100% rename from websearch/src/uk/ac/shef/dcs/websearch/WebSearchException.java rename to sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearchException.java diff --git a/websearch/src/uk/ac/shef/dcs/websearch/WebSearchFactory.java b/sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearchFactory.java similarity index 100% rename from websearch/src/uk/ac/shef/dcs/websearch/WebSearchFactory.java rename to sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearchFactory.java diff --git a/websearch/src/uk/ac/shef/dcs/websearch/WebSearchResultDoc.java b/sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearchResultDoc.java similarity index 100% rename from websearch/src/uk/ac/shef/dcs/websearch/WebSearchResultDoc.java rename to sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearchResultDoc.java diff --git a/websearch/src/uk/ac/shef/dcs/websearch/bing/v2/APIKeysDepletedException.java b/sti-websearch/src/uk/ac/shef/dcs/websearch/bing/v2/APIKeysDepletedException.java similarity index 100% rename from websearch/src/uk/ac/shef/dcs/websearch/bing/v2/APIKeysDepletedException.java rename to sti-websearch/src/uk/ac/shef/dcs/websearch/bing/v2/APIKeysDepletedException.java diff --git a/websearch/src/uk/ac/shef/dcs/websearch/bing/v2/BingSearch.java b/sti-websearch/src/uk/ac/shef/dcs/websearch/bing/v2/BingSearch.java similarity index 100% rename from websearch/src/uk/ac/shef/dcs/websearch/bing/v2/BingSearch.java rename to sti-websearch/src/uk/ac/shef/dcs/websearch/bing/v2/BingSearch.java diff --git a/websearch/src/uk/ac/shef/dcs/websearch/bing/v2/BingSearchResultParser.java b/sti-websearch/src/uk/ac/shef/dcs/websearch/bing/v2/BingSearchResultParser.java similarity index 100% rename from websearch/src/uk/ac/shef/dcs/websearch/bing/v2/BingSearchResultParser.java rename to sti-websearch/src/uk/ac/shef/dcs/websearch/bing/v2/BingSearchResultParser.java From df21d8c752cc6db165e83628c1fbd531d0d7cde7 Mon Sep 17 00:00:00 2001 From: brodecva Date: Thu, 4 Aug 2016 13:27:52 +0200 Subject: [PATCH 070/211] EOL changes --- .gitattributes | 55 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/.gitattributes b/.gitattributes index bdb0cabc..2e72c6c0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,17 +1,42 @@ -# Auto detect text files and perform LF normalization -* text=auto +# Perform EOL normalization when needed +* text=auto -# Custom for Visual Studio -*.cs diff=csharp +Cakefile text eol=lf +LICENCE text eol=lf +LICENSE text eol=lf +LICENSE-MIT text eol=lf +Makefile text eol=lf +*.coffee text eol=lf +*.css text eol=lf +*.eslintignore text eol=lf +*.eslintrc text eol=lf +*.gitattributes text eol=lf +*.gitignore text eol=lf +*.gitmodules text eol=lf +*.html text eol=lf +*.info text eol=lf +*.jamignore text eol=lf +*.java text eol=lf +*.js text eol=lf +*.jshintrc text eol=lf +*.json text eol=lf +*.js text eol=lf +*.md text eol=lf +*.md~ text eol=lf +*.npmignore text eol=lf +*.properties text eol=lf +*.py text eol=lf +*.sh text eol=lf +*.txt text eol=lf +*.watchr text eol=lf +*.xml text eol=lf +*.yml text eol=lf -# Standard to msysgit -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain +*.bat text eol=crlf + +*.bin binary +*.gif binary +*.jar binary +*.jpg binary +*.png binary +*.zip binary From e9bbc2e0d57f314d5f0a5534d0802812efe8a9e5 Mon Sep 17 00:00:00 2001 From: brodecva Date: Thu, 4 Aug 2016 13:52:13 +0200 Subject: [PATCH 071/211] Fixed EOLs --- .gitignore | 270 +- .travis.yml | 16 +- README.md | 60 +- config/kbsearch.properties | 82 +- config/log4j.properties | 50 +- config/sti.imdb.properties | 102 +- config/sti.musicbrainz.properties | 98 +- config/sti.properties | 238 +- config/websearch.properties | 34 +- configs/Jan/kbsearch.properties | 80 +- configs/Jan/sti.properties | 238 +- configs/Jan/websearch.properties | 34 +- demo/README.md | 6 +- mvninstall.bat | 4 +- odalic/.gitignore | 2 +- odalic/pom.xml | 328 +- .../xrg/odalic/api/rest/Configuration.java | 106 +- .../api/rest/adapters/AmbiguityAdapter.java | 46 +- .../rest/adapters/CellAnnotationAdapter.java | 94 +- .../rest/adapters/CellPositionAdapter.java | 46 +- .../rest/adapters/CellRelationAdapter.java | 46 +- .../CellRelationAnnotationAdapter.java | 94 +- .../adapters/CellRelationPositionAdapter.java | 46 +- .../rest/adapters/ClassificationAdapter.java | 46 +- .../rest/adapters/ColumnAmbiguityAdapter.java | 40 +- .../rest/adapters/ColumnIgnoreAdapter.java | 40 +- .../rest/adapters/ColumnPositionAdapter.java | 46 +- .../rest/adapters/ColumnRelationAdapter.java | 40 +- .../ColumnRelationAnnotationAdapter.java | 94 +- .../ColumnRelationPositionAdapter.java | 46 +- .../rest/adapters/ConfigurationAdapter.java | 40 +- .../rest/adapters/DisambiguationAdapter.java | 46 +- .../api/rest/adapters/EntityAdapter.java | 48 +- .../rest/adapters/EntityCandidateAdapter.java | 48 +- .../api/rest/adapters/FeedbackAdapter.java | 44 +- .../odalic/api/rest/adapters/FileAdapter.java | 46 +- .../adapters/HeaderAnnotationAdapter.java | 94 +- .../rest/adapters/KnowledgeBaseAdapter.java | 46 +- .../api/rest/adapters/LikelihoodAdapter.java | 46 +- .../api/rest/adapters/ResultAdapter.java | 118 +- .../api/rest/adapters/RowPositionAdapter.java | 46 +- .../odalic/api/rest/adapters/TaskAdapter.java | 40 +- .../ColumnPositionKeyJsonDeserializer.java | 44 +- .../ColumnPositionKeyJsonSerializer.java | 58 +- ...lRelationAnnotationMapMapDeserializer.java | 60 +- ...ellRelationAnnotationMapMapSerializer.java | 86 +- ...lumnRelationAnnotationMapDeserializer.java | 58 +- ...ColumnRelationAnnotationMapSerializer.java | 66 +- .../CustomJsonDateDeserializer.java | 76 +- .../conversions/CustomJsonDateSerializer.java | 64 +- .../KnowledgeBaseKeyJsonDeserializer.java | 44 +- .../KnowledgeBaseKeyJsonSerializer.java | 52 +- .../RowPositionKeyJsonDeserializer.java | 46 +- .../RowPositionKeyJsonSerializer.java | 60 +- .../xrg/odalic/api/rest/errors/Message.java | 196 +- .../api/rest/errors/ThrowableMapper.java | 102 +- .../api/rest/filters/CorsResponseFilter.java | 62 +- .../rest/filters/LoggingResponseFilter.java | 76 +- .../rest/resources/ConfigurationResource.java | 128 +- .../api/rest/resources/ExecutionResource.java | 96 +- .../api/rest/resources/FeedbackResource.java | 116 +- .../api/rest/resources/FileResource.java | 330 +- .../api/rest/resources/ResultResource.java | 96 +- .../api/rest/resources/StateResource.java | 112 +- .../api/rest/resources/TaskResource.java | 206 +- .../api/rest/values/AmbiguityValue.java | 116 +- .../api/rest/values/CellAnnotationValue.java | 204 +- .../api/rest/values/CellPositionValue.java | 160 +- .../values/CellRelationAnnotationValue.java | 204 +- .../values/CellRelationPositionValue.java | 162 +- .../api/rest/values/CellRelationValue.java | 160 +- .../api/rest/values/ClassificationValue.java | 160 +- .../api/rest/values/ColumnAmbiguityValue.java | 116 +- .../api/rest/values/ColumnIgnoreValue.java | 116 +- .../api/rest/values/ColumnPositionValue.java | 108 +- .../values/ColumnRelationAnnotationValue.java | 204 +- .../values/ColumnRelationPositionValue.java | 150 +- .../api/rest/values/ColumnRelationValue.java | 160 +- .../api/rest/values/ConfigurationValue.java | 206 +- .../api/rest/values/DisambiguationValue.java | 160 +- .../api/rest/values/EntityCandidateValue.java | 296 +- .../odalic/api/rest/values/EntityValue.java | 154 +- .../api/rest/values/ExecutionValue.java | 124 +- .../odalic/api/rest/values/FeedbackValue.java | 414 +- .../xrg/odalic/api/rest/values/FileValue.java | 260 +- .../rest/values/HeaderAnnotationValue.java | 204 +- .../api/rest/values/KnowledgeBaseValue.java | 102 +- .../api/rest/values/LikelihoodValue.java | 114 +- .../odalic/api/rest/values/ResultValue.java | 514 +- .../api/rest/values/RowPositionValue.java | 108 +- .../odalic/api/rest/values/StateValue.java | 82 +- .../xrg/odalic/api/rest/values/TaskValue.java | 216 +- .../mff/xrg/odalic/feedbacks/Ambiguity.java | 164 +- .../xrg/odalic/feedbacks/CellRelation.java | 218 +- .../xrg/odalic/feedbacks/Classification.java | 218 +- .../xrg/odalic/feedbacks/ColumnAmbiguity.java | 176 +- .../xrg/odalic/feedbacks/ColumnIgnore.java | 176 +- .../xrg/odalic/feedbacks/ColumnRelation.java | 206 +- .../xrg/odalic/feedbacks/Disambiguation.java | 206 +- .../mff/xrg/odalic/feedbacks/Feedback.java | 524 +- .../cz/cuni/mff/xrg/odalic/files/File.java | 330 +- .../mff/xrg/odalic/files/FileService.java | 130 +- .../odalic/files/MemoryOnlyFileService.java | 326 +- .../xrg/odalic/input/CsvConfiguration.java | 496 +- .../mff/xrg/odalic/input/CsvInputParser.java | 44 +- .../odalic/input/DefaultCsvInputParser.java | 160 +- .../input/DefaultInputToTableAdapter.java | 110 +- .../cz/cuni/mff/xrg/odalic/input/Input.java | 48 +- .../mff/xrg/odalic/input/InputBuilder.java | 48 +- .../xrg/odalic/input/InputToTableAdapter.java | 26 +- .../xrg/odalic/input/ListsBackedInput.java | 186 +- .../odalic/input/ListsBackedInputBuilder.java | 156 +- .../xrg/odalic/input/TableToInputAdapter.java | 26 +- .../input/TableToListsBackedInputAdapter.java | 96 +- .../xrg/odalic/positions/CellPosition.java | 264 +- .../positions/CellRelationPosition.java | 340 +- .../xrg/odalic/positions/ColumnPosition.java | 180 +- .../positions/ColumnRelationPosition.java | 270 +- .../mff/xrg/odalic/positions/RowPosition.java | 190 +- .../odalic/tasks/MemoryOnlyTaskService.java | 174 +- .../cz/cuni/mff/xrg/odalic/tasks/Task.java | 276 +- .../mff/xrg/odalic/tasks/TaskService.java | 52 +- .../tasks/annotations/CellAnnotation.java | 300 +- .../annotations/CellRelationAnnotation.java | 298 +- .../annotations/ColumnRelationAnnotation.java | 298 +- .../xrg/odalic/tasks/annotations/Entity.java | 230 +- .../tasks/annotations/EntityCandidate.java | 254 +- .../tasks/annotations/HeaderAnnotation.java | 320 +- .../tasks/annotations/KnowledgeBase.java | 168 +- .../odalic/tasks/annotations/Likelihood.java | 190 +- .../tasks/configurations/Configuration.java | 262 +- .../configurations/ConfigurationService.java | 28 +- .../MemoryOnlyConfigurationService.java | 94 +- .../tasks/executions/ExecutionService.java | 124 +- .../FutureBasedExecutionService.java | 306 +- .../SemanticTableInterpreterFactory.java | 62 +- .../tasks/feedbacks/FeedbackService.java | 42 +- .../feedbacks/MemoryOnlyFeedbackService.java | 126 +- .../results/AnnotationToResultAdapter.java | 48 +- .../DefaultAnnotationToResultAdapter.java | 654 +- .../mff/xrg/odalic/tasks/results/Result.java | 476 +- .../cz/cuni/mff/xrg/odalic/util/Arrays.java | 268 +- .../cz/cuni/mff/xrg/odalic/util/Lists.java | 98 +- .../cz/cuni/mff/xrg/odalic/util/Maps.java | 96 +- .../java/cz/cuni/mff/xrg/odalic/util/URL.java | 90 +- odalic/src/main/resources/logback.xml | 44 +- .../resources/spring/applicationContext.xml | 100 +- odalic/src/main/webapp/WEB-INF/web.xml | 74 +- .../executions/InterpreterExecutionBatch.java | 154 +- pom.xml | 38 +- resources/cache/empty/class/conf/currency.xml | 134 +- resources/cache/empty/class/conf/elevate.xml | 76 +- .../empty/class/conf/lang/contractions_ca.txt | 16 +- .../empty/class/conf/lang/contractions_fr.txt | 30 +- .../empty/class/conf/lang/contractions_ga.txt | 10 +- .../empty/class/conf/lang/contractions_it.txt | 46 +- .../empty/class/conf/lang/hyphenations_ga.txt | 10 +- .../empty/class/conf/lang/stemdict_nl.txt | 12 +- .../empty/class/conf/lang/stoptags_ja.txt | 840 +- .../empty/class/conf/lang/stopwords_ar.txt | 250 +- .../empty/class/conf/lang/stopwords_bg.txt | 386 +- .../empty/class/conf/lang/stopwords_ca.txt | 440 +- .../empty/class/conf/lang/stopwords_cz.txt | 344 +- .../empty/class/conf/lang/stopwords_da.txt | 220 +- .../empty/class/conf/lang/stopwords_de.txt | 588 +- .../empty/class/conf/lang/stopwords_el.txt | 156 +- .../empty/class/conf/lang/stopwords_en.txt | 108 +- .../empty/class/conf/lang/stopwords_es.txt | 712 +- .../empty/class/conf/lang/stopwords_eu.txt | 198 +- .../empty/class/conf/lang/stopwords_fa.txt | 626 +- .../empty/class/conf/lang/stopwords_fi.txt | 194 +- .../empty/class/conf/lang/stopwords_fr.txt | 372 +- .../empty/class/conf/lang/stopwords_ga.txt | 220 +- .../empty/class/conf/lang/stopwords_gl.txt | 322 +- .../empty/class/conf/lang/stopwords_hi.txt | 470 +- .../empty/class/conf/lang/stopwords_hu.txt | 422 +- .../empty/class/conf/lang/stopwords_hy.txt | 92 +- .../empty/class/conf/lang/stopwords_id.txt | 718 +- .../empty/class/conf/lang/stopwords_it.txt | 606 +- .../empty/class/conf/lang/stopwords_ja.txt | 254 +- .../empty/class/conf/lang/stopwords_lv.txt | 344 +- .../empty/class/conf/lang/stopwords_nl.txt | 238 +- .../empty/class/conf/lang/stopwords_no.txt | 388 +- .../empty/class/conf/lang/stopwords_pt.txt | 506 +- .../empty/class/conf/lang/stopwords_ro.txt | 466 +- .../empty/class/conf/lang/stopwords_ru.txt | 486 +- .../empty/class/conf/lang/stopwords_sv.txt | 266 +- .../empty/class/conf/lang/stopwords_th.txt | 238 +- .../empty/class/conf/lang/stopwords_tr.txt | 424 +- .../empty/class/conf/lang/userdict_ja.txt | 58 +- resources/cache/empty/class/conf/params.json | 40 +- .../cache/empty/class/conf/protwords.txt | 42 +- resources/cache/empty/class/conf/schema.xml | 480 +- .../cache/empty/class/conf/solrconfig.xml | 3898 ++--- .../cache/empty/class/conf/stopwords.txt | 374 +- resources/cache/empty/class/conf/synonyms.txt | 58 +- resources/cache/empty/class/core.properties | 6 +- .../cache/empty/entity/conf/currency.xml | 134 +- resources/cache/empty/entity/conf/elevate.xml | 76 +- .../entity/conf/lang/contractions_ca.txt | 16 +- .../entity/conf/lang/contractions_fr.txt | 30 +- .../entity/conf/lang/contractions_ga.txt | 10 +- .../entity/conf/lang/contractions_it.txt | 46 +- .../entity/conf/lang/hyphenations_ga.txt | 10 +- .../empty/entity/conf/lang/stemdict_nl.txt | 12 +- .../empty/entity/conf/lang/stoptags_ja.txt | 840 +- .../empty/entity/conf/lang/stopwords_ar.txt | 250 +- .../empty/entity/conf/lang/stopwords_bg.txt | 386 +- .../empty/entity/conf/lang/stopwords_ca.txt | 440 +- .../empty/entity/conf/lang/stopwords_cz.txt | 344 +- .../empty/entity/conf/lang/stopwords_da.txt | 220 +- .../empty/entity/conf/lang/stopwords_de.txt | 588 +- .../empty/entity/conf/lang/stopwords_el.txt | 156 +- .../empty/entity/conf/lang/stopwords_en.txt | 108 +- .../empty/entity/conf/lang/stopwords_es.txt | 712 +- .../empty/entity/conf/lang/stopwords_eu.txt | 198 +- .../empty/entity/conf/lang/stopwords_fa.txt | 626 +- .../empty/entity/conf/lang/stopwords_fi.txt | 194 +- .../empty/entity/conf/lang/stopwords_fr.txt | 372 +- .../empty/entity/conf/lang/stopwords_ga.txt | 220 +- .../empty/entity/conf/lang/stopwords_gl.txt | 322 +- .../empty/entity/conf/lang/stopwords_hi.txt | 470 +- .../empty/entity/conf/lang/stopwords_hu.txt | 422 +- .../empty/entity/conf/lang/stopwords_hy.txt | 92 +- .../empty/entity/conf/lang/stopwords_id.txt | 718 +- .../empty/entity/conf/lang/stopwords_it.txt | 606 +- .../empty/entity/conf/lang/stopwords_ja.txt | 254 +- .../empty/entity/conf/lang/stopwords_lv.txt | 344 +- .../empty/entity/conf/lang/stopwords_nl.txt | 238 +- .../empty/entity/conf/lang/stopwords_no.txt | 388 +- .../empty/entity/conf/lang/stopwords_pt.txt | 506 +- .../empty/entity/conf/lang/stopwords_ro.txt | 466 +- .../empty/entity/conf/lang/stopwords_ru.txt | 486 +- .../empty/entity/conf/lang/stopwords_sv.txt | 266 +- .../empty/entity/conf/lang/stopwords_th.txt | 238 +- .../empty/entity/conf/lang/stopwords_tr.txt | 424 +- .../empty/entity/conf/lang/userdict_ja.txt | 58 +- resources/cache/empty/entity/conf/params.json | 40 +- .../cache/empty/entity/conf/protwords.txt | 42 +- resources/cache/empty/entity/conf/schema.xml | 480 +- .../cache/empty/entity/conf/solrconfig.xml | 3898 ++--- .../cache/empty/entity/conf/stopwords.txt | 374 +- .../cache/empty/entity/conf/synonyms.txt | 58 +- resources/cache/empty/entity/core.properties | 6 +- .../cache/empty/relation/conf/currency.xml | 134 +- .../cache/empty/relation/conf/elevate.xml | 76 +- .../relation/conf/lang/contractions_ca.txt | 16 +- .../relation/conf/lang/contractions_fr.txt | 30 +- .../relation/conf/lang/contractions_ga.txt | 10 +- .../relation/conf/lang/contractions_it.txt | 46 +- .../relation/conf/lang/hyphenations_ga.txt | 10 +- .../empty/relation/conf/lang/stemdict_nl.txt | 12 +- .../empty/relation/conf/lang/stoptags_ja.txt | 840 +- .../empty/relation/conf/lang/stopwords_ar.txt | 250 +- .../empty/relation/conf/lang/stopwords_bg.txt | 386 +- .../empty/relation/conf/lang/stopwords_ca.txt | 440 +- .../empty/relation/conf/lang/stopwords_cz.txt | 344 +- .../empty/relation/conf/lang/stopwords_da.txt | 220 +- .../empty/relation/conf/lang/stopwords_de.txt | 588 +- .../empty/relation/conf/lang/stopwords_el.txt | 156 +- .../empty/relation/conf/lang/stopwords_en.txt | 108 +- .../empty/relation/conf/lang/stopwords_es.txt | 712 +- .../empty/relation/conf/lang/stopwords_eu.txt | 198 +- .../empty/relation/conf/lang/stopwords_fa.txt | 626 +- .../empty/relation/conf/lang/stopwords_fi.txt | 194 +- .../empty/relation/conf/lang/stopwords_fr.txt | 372 +- .../empty/relation/conf/lang/stopwords_ga.txt | 220 +- .../empty/relation/conf/lang/stopwords_gl.txt | 322 +- .../empty/relation/conf/lang/stopwords_hi.txt | 470 +- .../empty/relation/conf/lang/stopwords_hu.txt | 422 +- .../empty/relation/conf/lang/stopwords_hy.txt | 92 +- .../empty/relation/conf/lang/stopwords_id.txt | 718 +- .../empty/relation/conf/lang/stopwords_it.txt | 606 +- .../empty/relation/conf/lang/stopwords_ja.txt | 254 +- .../empty/relation/conf/lang/stopwords_lv.txt | 344 +- .../empty/relation/conf/lang/stopwords_nl.txt | 238 +- .../empty/relation/conf/lang/stopwords_no.txt | 388 +- .../empty/relation/conf/lang/stopwords_pt.txt | 506 +- .../empty/relation/conf/lang/stopwords_ro.txt | 466 +- .../empty/relation/conf/lang/stopwords_ru.txt | 486 +- .../empty/relation/conf/lang/stopwords_sv.txt | 266 +- .../empty/relation/conf/lang/stopwords_th.txt | 238 +- .../empty/relation/conf/lang/stopwords_tr.txt | 424 +- .../empty/relation/conf/lang/userdict_ja.txt | 58 +- .../cache/empty/relation/conf/params.json | 40 +- .../cache/empty/relation/conf/protwords.txt | 42 +- .../cache/empty/relation/conf/schema.xml | 480 +- .../cache/empty/relation/conf/solrconfig.xml | 3898 ++--- .../cache/empty/relation/conf/stopwords.txt | 374 +- .../cache/empty/relation/conf/synonyms.txt | 58 +- .../cache/empty/relation/core.properties | 6 +- .../cache/empty/similarity/conf/currency.xml | 134 +- .../cache/empty/similarity/conf/elevate.xml | 76 +- .../similarity/conf/lang/contractions_ca.txt | 16 +- .../similarity/conf/lang/contractions_fr.txt | 30 +- .../similarity/conf/lang/contractions_ga.txt | 10 +- .../similarity/conf/lang/contractions_it.txt | 46 +- .../similarity/conf/lang/hyphenations_ga.txt | 10 +- .../similarity/conf/lang/stemdict_nl.txt | 12 +- .../similarity/conf/lang/stoptags_ja.txt | 840 +- .../similarity/conf/lang/stopwords_ar.txt | 250 +- .../similarity/conf/lang/stopwords_bg.txt | 386 +- .../similarity/conf/lang/stopwords_ca.txt | 440 +- .../similarity/conf/lang/stopwords_cz.txt | 344 +- .../similarity/conf/lang/stopwords_da.txt | 220 +- .../similarity/conf/lang/stopwords_de.txt | 588 +- .../similarity/conf/lang/stopwords_el.txt | 156 +- .../similarity/conf/lang/stopwords_en.txt | 108 +- .../similarity/conf/lang/stopwords_es.txt | 712 +- .../similarity/conf/lang/stopwords_eu.txt | 198 +- .../similarity/conf/lang/stopwords_fa.txt | 626 +- .../similarity/conf/lang/stopwords_fi.txt | 194 +- .../similarity/conf/lang/stopwords_fr.txt | 372 +- .../similarity/conf/lang/stopwords_ga.txt | 220 +- .../similarity/conf/lang/stopwords_gl.txt | 322 +- .../similarity/conf/lang/stopwords_hi.txt | 470 +- .../similarity/conf/lang/stopwords_hu.txt | 422 +- .../similarity/conf/lang/stopwords_hy.txt | 92 +- .../similarity/conf/lang/stopwords_id.txt | 718 +- .../similarity/conf/lang/stopwords_it.txt | 606 +- .../similarity/conf/lang/stopwords_ja.txt | 254 +- .../similarity/conf/lang/stopwords_lv.txt | 344 +- .../similarity/conf/lang/stopwords_nl.txt | 238 +- .../similarity/conf/lang/stopwords_no.txt | 388 +- .../similarity/conf/lang/stopwords_pt.txt | 506 +- .../similarity/conf/lang/stopwords_ro.txt | 466 +- .../similarity/conf/lang/stopwords_ru.txt | 486 +- .../similarity/conf/lang/stopwords_sv.txt | 266 +- .../similarity/conf/lang/stopwords_th.txt | 238 +- .../similarity/conf/lang/stopwords_tr.txt | 424 +- .../similarity/conf/lang/userdict_ja.txt | 58 +- .../cache/empty/similarity/conf/params.json | 40 +- .../cache/empty/similarity/conf/protwords.txt | 42 +- .../cache/empty/similarity/conf/schema.xml | 480 +- .../empty/similarity/conf/solrconfig.xml | 3898 ++--- .../cache/empty/similarity/conf/stopwords.txt | 374 +- .../cache/empty/similarity/conf/synonyms.txt | 58 +- .../cache/empty/similarity/core.properties | 6 +- resources/cache/empty/solr.xml | 2 +- .../cache/empty/websearch/conf/currency.xml | 134 +- .../cache/empty/websearch/conf/elevate.xml | 76 +- .../websearch/conf/lang/contractions_ca.txt | 16 +- .../websearch/conf/lang/contractions_fr.txt | 30 +- .../websearch/conf/lang/contractions_ga.txt | 10 +- .../websearch/conf/lang/contractions_it.txt | 46 +- .../websearch/conf/lang/hyphenations_ga.txt | 10 +- .../empty/websearch/conf/lang/stemdict_nl.txt | 12 +- .../empty/websearch/conf/lang/stoptags_ja.txt | 840 +- .../websearch/conf/lang/stopwords_ar.txt | 250 +- .../websearch/conf/lang/stopwords_bg.txt | 386 +- .../websearch/conf/lang/stopwords_ca.txt | 440 +- .../websearch/conf/lang/stopwords_cz.txt | 344 +- .../websearch/conf/lang/stopwords_da.txt | 220 +- .../websearch/conf/lang/stopwords_de.txt | 588 +- .../websearch/conf/lang/stopwords_el.txt | 156 +- .../websearch/conf/lang/stopwords_en.txt | 108 +- .../websearch/conf/lang/stopwords_es.txt | 712 +- .../websearch/conf/lang/stopwords_eu.txt | 198 +- .../websearch/conf/lang/stopwords_fa.txt | 626 +- .../websearch/conf/lang/stopwords_fi.txt | 194 +- .../websearch/conf/lang/stopwords_fr.txt | 372 +- .../websearch/conf/lang/stopwords_ga.txt | 220 +- .../websearch/conf/lang/stopwords_gl.txt | 322 +- .../websearch/conf/lang/stopwords_hi.txt | 470 +- .../websearch/conf/lang/stopwords_hu.txt | 422 +- .../websearch/conf/lang/stopwords_hy.txt | 92 +- .../websearch/conf/lang/stopwords_id.txt | 718 +- .../websearch/conf/lang/stopwords_it.txt | 606 +- .../websearch/conf/lang/stopwords_ja.txt | 254 +- .../websearch/conf/lang/stopwords_lv.txt | 344 +- .../websearch/conf/lang/stopwords_nl.txt | 238 +- .../websearch/conf/lang/stopwords_no.txt | 388 +- .../websearch/conf/lang/stopwords_pt.txt | 506 +- .../websearch/conf/lang/stopwords_ro.txt | 466 +- .../websearch/conf/lang/stopwords_ru.txt | 486 +- .../websearch/conf/lang/stopwords_sv.txt | 266 +- .../websearch/conf/lang/stopwords_th.txt | 238 +- .../websearch/conf/lang/stopwords_tr.txt | 424 +- .../empty/websearch/conf/lang/userdict_ja.txt | 58 +- .../cache/empty/websearch/conf/params.json | 40 +- .../cache/empty/websearch/conf/protwords.txt | 42 +- .../cache/empty/websearch/conf/schema.xml | 480 +- .../cache/empty/websearch/conf/solrconfig.xml | 3898 ++--- .../cache/empty/websearch/conf/stopwords.txt | 374 +- .../cache/empty/websearch/conf/synonyms.txt | 58 +- .../cache/empty/websearch/core.properties | 6 +- .../any23/extension/extractor/LAny23Util.java | 274 +- .../extractor/LExtractorRegistry.java | 282 +- .../extractor/LMicrodataExtractor.java | 1216 +- .../extractor/LMicrodataExtractorFactory.java | 78 +- .../extension/extractor/LMicrodataParser.java | 1028 +- .../extension/extractor/LNTripleWriter.java | 90 +- .../extension/extractor/LRDFa11Extractor.java | 174 +- .../extractor/LRDFa11ExtractorFactory.java | 80 +- .../any23/extension/extractor/LTriple.java | 116 +- .../ac/shef/dcs/util/SerializationUtils.java | 50 +- .../java/uk/ac/shef/dcs/util/SolrCache.java | 152 +- .../shef/dcs/kbsearch/KBSearchException.java | 38 +- .../ac/shef/dcs/kbsearch/KBSearchFactory.java | 116 +- .../kbsearch/freebase/FreebaseAttribute.java | 52 +- .../dcs/kbsearch/freebase/FreebaseEnum.java | 60 +- .../freebase/FreebaseQueryInterrupter.java | 186 +- .../kbsearch/freebase/FreebaseQueryProxy.java | 1066 +- .../dcs/kbsearch/freebase/FreebaseTopic.java | 98 +- .../ac/shef/dcs/kbsearch/model/Attribute.java | 178 +- .../uk/ac/shef/dcs/kbsearch/model/Clazz.java | 54 +- .../uk/ac/shef/dcs/kbsearch/model/Entity.java | 102 +- .../ac/shef/dcs/kbsearch/model/Resource.java | 168 +- .../dcs/kbsearch/sparql/DBpediaAttribute.java | 78 +- .../ac/shef/dcs/kbsearch/sparql/DCEnum.java | 46 +- .../ac/shef/dcs/kbsearch/sparql/FOAFEnum.java | 40 +- .../ac/shef/dcs/kbsearch/sparql/RDFEnum.java | 52 +- sti-main/log4j.properties | 50 +- sti-main/src/main/java/log4j.properties | 50 +- .../ac/shef/dcs/sti/STIConstantProperty.java | 112 +- .../main/java/uk/ac/shef/dcs/sti/STIEnum.java | 50 +- .../java/uk/ac/shef/dcs/sti/STIException.java | 42 +- .../ac/shef/dcs/sti/any23/Any23Xtractor.java | 178 +- .../algorithm/SemanticTableInterpreter.java | 106 +- .../baseline/BaselineInterpreter.java | 210 +- .../baseline/BaselineRelationScorer.java | 146 +- .../BaselineSimilarityClazzScorer.java | 346 +- .../BaselineSimilarityEntityScorer.java | 252 +- .../baseline/TCellDisambiguator.java | 282 +- .../baseline/TCellDisambiguatorNameMatch.java | 216 +- .../TCellDisambiguatorSimilarity.java | 90 +- .../algorithm/baseline/TColumnClassifier.java | 92 +- .../baseline/TColumnClassifierNameMatch.java | 120 +- .../baseline/TColumnClassifierSimilarity.java | 94 +- .../ji/CandidateConceptGenerator.java | 234 +- .../ji/CandidateEntityGenerator.java | 186 +- .../ji/CandidateRelationGenerator.java | 574 +- .../sti/core/algorithm/ji/DebuggingUtil.java | 298 +- .../ji/JIAdaptedAttributeMatcher.java | 430 +- .../algorithm/ji/JIAdaptedEntityScorer.java | 152 +- .../sti/core/algorithm/ji/JIClazzScorer.java | 250 +- .../sti/core/algorithm/ji/JIInterpreter.java | 714 +- .../sti/core/algorithm/ji/TAnnotationJI.java | 358 +- .../sti/core/algorithm/ji/VariableType.java | 40 +- .../ji/factorgraph/FactorBuilder.java | 236 +- .../ji/factorgraph/FactorBuilderCell.java | 154 +- .../FactorBuilderCellAndRelation.java | 266 +- .../ji/factorgraph/FactorBuilderHeader.java | 142 +- .../FactorBuilderHeaderAndCell.java | 160 +- .../FactorBuilderHeaderAndRelation.java | 298 +- .../ji/factorgraph/FactorGraphBuilder.java | 308 +- .../EntityAndClazzSimilarityScorer.java | 178 +- .../similarity/SimilarityComputerManager.java | 222 +- .../similarity/SimilarityComputerThread.java | 124 +- .../algorithm/smp/CellAnnotationUpdater.java | 516 +- .../sti/core/algorithm/smp/ChangeMessage.java | 74 +- .../algorithm/smp/ChangeMessageComputer.java | 270 +- .../smp/ChangeMessageFromRelation.java | 54 +- .../smp/ClazzSpecificityCalculator.java | 18 +- .../FreebaseClazzSpecificityCalculator.java | 62 +- .../algorithm/smp/SMPAdaptedEntityScorer.java | 286 +- .../core/algorithm/smp/SMPInterpreter.java | 284 +- .../algorithm/smp/SemanticMessagePassing.java | 276 +- .../algorithm/smp/TAnnotationSMPFreebase.java | 156 +- .../algorithm/smp/TAnnotationWriterSMP.java | 204 +- .../core/algorithm/smp/TColumnClassifier.java | 226 +- .../smp/TColumnColumnRelationEnumerator.java | 456 +- .../dcs/sti/core/algorithm/tmp/LEARNING.java | 37 - .../LEARNINGPreliminaryColumnClassifier.java | 172 - .../tmp/LEARNINGPreliminaryDisamb.java | 150 - .../algorithm/tmp/LiteralColumnTagger.java | 13 - .../tmp/LiteralColumnTaggerImpl.java | 89 - .../algorithm/tmp/RELATIONENUMERATION.java | 111 - .../algorithm/tmp/TCellDisambiguator.java | 123 - .../core/algorithm/tmp/TColumnClassifier.java | 218 - .../tmp/TColumnColumnRelationEnumerator.java | 139 - .../core/algorithm/tmp/TMPInterpreter.java | 110 - .../dcs/sti/core/algorithm/tmp/UPDATE.java | 281 - .../algorithm/tmp/sampler/OSPD_combined.java | 256 - .../tmp/sampler/OSPD_contextWords.java | 117 - .../tmp/sampler/OSPD_nameLength.java | 53 - .../tmp/sampler/OSPD_namelength_merge.java | 104 - .../algorithm/tmp/sampler/OSPD_nonEmpty.java | 97 - .../algorithm/tmp/sampler/OSPD_random.java | 102 - .../core/algorithm/tmp/sampler/Random.java | 53 - .../tmp/sampler/TContentCellRanker.java | 16 - .../tmp/sampler/TContentRowRanker.java | 12 - .../TContentTContentRowRankerImpl.java | 42 - .../algorithm/tmp/scorer/TMPClazzScorer.java | 408 - .../algorithm/tmp/scorer/TMPEntityScorer.java | 227 - .../tmp/scorer/TMPRelationScorer.java | 332 - .../tmp/stopping/FixedNumberOfRows.java | 25 - .../sti/core/algorithm/tmp/stopping/IInf.java | 76 - .../core/algorithm/tmp/stopping/NoStop.java | 18 - .../tmp/stopping/StoppingCriteria.java | 11 - .../StoppingCriteriaInstantiator.java | 30 - .../feature/FreebaseConceptBoWCreator.java | 54 +- .../feature/FreebaseRelationBoWCreator.java | 68 +- .../core/feature/OntologyBasedBoWCreator.java | 20 +- .../uk/ac/shef/dcs/sti/core/model/List.java | 102 +- .../ac/shef/dcs/sti/core/model/ListItem.java | 100 +- .../dcs/sti/core/model/RelationColumns.java | 98 +- .../shef/dcs/sti/core/model/TAnnotation.java | 486 +- .../uk/ac/shef/dcs/sti/core/model/TCell.java | 126 +- .../dcs/sti/core/model/TCellAnnotation.java | 170 +- .../model/TCellCellRelationAnotation.java | 226 +- .../TColumnColumnRelationAnnotation.java | 234 +- .../dcs/sti/core/model/TColumnHeader.java | 114 +- .../core/model/TColumnHeaderAnnotation.java | 224 +- .../ac/shef/dcs/sti/core/model/TContext.java | 144 +- .../uk/ac/shef/dcs/sti/core/model/Table.java | 314 +- .../shef/dcs/sti/core/model/TableTriple.java | 146 +- .../core/scorer/AttributeValueMatcher.java | 390 +- .../shef/dcs/sti/core/scorer/ClazzScorer.java | 94 +- .../dcs/sti/core/scorer/EntityScorer.java | 70 +- .../dcs/sti/core/scorer/RelationScorer.java | 62 +- .../dcs/sti/core/subjectcol/CMScorer.java | 286 +- .../subjectcol/SubjectColumnDetector.java | 818 +- .../core/subjectcol/SubjectColumnScorer.java | 28 +- .../SubjectColumnScorerHeuristic.java | 220 +- .../sti/core/subjectcol/TColumnDataType.java | 114 +- .../sti/core/subjectcol/TColumnFeature.java | 294 +- .../subjectcol/TColumnFeatureGenerator.java | 846 +- .../dcs/sti/core/subjectcol/WSScorer.java | 588 +- .../sti/experiment/JointInferenceBatch.java | 414 +- .../ac/shef/dcs/sti/experiment/STIBatch.java | 770 +- .../SemanticMessagePassingBatch.java | 404 +- .../dcs/sti/io/JSONOutputCellAnnotation.java | 70 +- .../sti/io/JSONOutputColumnAnnotation.java | 64 +- .../sti/io/JSONOutputRelationAnnotation.java | 70 +- .../JSONOutputRelationAnnotationPerRow.java | 70 +- .../ac/shef/dcs/sti/io/TAnnotationWriter.java | 844 +- .../dcs/sti/io/TAnnotationWriterJSON.java | 258 +- .../uk/ac/shef/dcs/sti/nlp/Lemmatizer.java | 114 +- .../java/uk/ac/shef/dcs/sti/nlp/NLPTools.java | 156 +- .../ac/shef/dcs/sti/nlp/TermFreqCounter.java | 78 +- .../shef/dcs/sti/parser/ContentValidator.java | 152 +- .../dcs/sti/parser/list/ListXtractor.java | 176 +- .../dcs/sti/parser/list/ListXtractorHTML.java | 144 +- .../parser/list/ListXtractorWikipedia.java | 112 +- .../list/splitter/ListItemSplitter.java | 28 +- .../list/splitter/ListItemSplitterByURL.java | 72 +- .../list/validator/ListVaildatorLanient.java | 158 +- .../parser/list/validator/ListValidator.java | 24 +- .../list/validator/ListValidatorStrict.java | 148 +- .../dcs/sti/parser/table/TableParser.java | 200 +- .../parser/table/TableParserGoodreads.java | 150 +- .../dcs/sti/parser/table/TableParserHTML.java | 136 +- .../dcs/sti/parser/table/TableParserIMDB.java | 178 +- .../table/TableParserLimayeDataset.java | 524 +- .../parser/table/TableParserMusicBrainz.java | 174 +- .../parser/table/TableParserReverbnation.java | 172 +- .../parser/table/TableParserRottenTomato.java | 238 +- .../parser/table/TableParserWikipedia.java | 154 +- .../table/context/TableContextExtractor.java | 32 +- .../context/TableContextExtractorGeneric.java | 92 +- .../context/TableContextExtractorIMDB.java | 162 +- .../TableContextExtractorMusicBrainz.java | 136 +- .../parser/table/creator/TableObjCreator.java | 36 +- .../creator/TableObjCreatorGoodreads.java | 208 +- .../table/creator/TableObjCreatorHTML.java | 164 +- .../table/creator/TableObjCreatorIMDB.java | 192 +- .../creator/TableObjCreatorMusicBrainz.java | 208 +- .../TableObjCreatorReverbnationList.java | 224 +- .../creator/TableObjCreatorWikipediaGS.java | 424 +- .../table/hodetector/TableHODetector.java | 46 +- .../hodetector/TableHODetectorByHTMLTag.java | 222 +- .../table/normalizer/TableNormalizer.java | 40 +- .../TableNormalizerDiscardIrregularRows.java | 238 +- .../TableNormalizerListTransformer.java | 60 +- .../normalizer/TableNormalizerSimple.java | 160 +- .../table/validator/TableValidator.java | 26 +- .../TableValidatorForWikipediaGSLanient.java | 162 +- .../TableValidatorForWikipediaGSStrict.java | 208 +- .../validator/TableValidatorGeneric.java | 214 +- .../sti/todo/TAnnotationKeyFileReader.java | 456 +- .../uk/ac/shef/dcs/sti/todo/TestGRMM.java | 300 +- .../sti/todo/TestSubjectColumnDetector.java | 366 +- .../dcs/sti/todo/evaluation/DataStats.java | 1366 +- ...bleSize_NameLength_Analysis_LimayeNew.java | 500 +- ...TableSize_NameLength_Analysis_MB_IMDB.java | 320 +- ...bleSize_NameLength_Anaylsis_LimayeOld.java | 576 +- .../evaluation/Evaluator_AllInOne_IMDB.java | 288 +- .../evaluation/Evaluator_AllInOne_Limaye.java | 660 +- .../evaluation/Evaluator_AllInOne_MB.java | 606 +- .../todo/evaluation/Evaluator_ClassOnly.java | 964 +- .../Evaluator_ClassOnly_IMDB_MusicBrainz.java | 456 +- .../todo/evaluation/Evaluator_EntityOnly.java | 560 +- ...Classification_ignoreUpdateIterations.java | 272 +- .../Evaluator_ISWC_Helper_ClassOnly.java | 322 +- .../Evaluator_Limaye_Entity_Only.java | 206 +- .../evaluation/Evaluator_RelationOnly.java | 620 +- ...aluator_RelationOnly_IMDB_MusicBrainz.java | 444 +- .../KeyFileGenerator_from_HTMLOutput.java | 478 +- .../shef/dcs/sti/todo/gs/GSBuilder_IMDB.java | 268 +- .../dcs/sti/todo/gs/GSBuilder_Limaye.java | 516 +- .../todo/gs/GSBuilder_Limaye_Wikitables.java | 1826 +- ...Builder_Limaye_Wikitables_consolidate.java | 224 +- .../GSBuilder_Limaye_Wikitables_with_Ref.java | 580 +- .../sti/todo/gs/GSBuilder_MusicBrainz.java | 320 +- .../shef/dcs/sti/todo/gs/GSFile_Rewriter.java | 86 +- ...S_Class_Relation_Consolidation_Helper.java | 178 +- .../shef/dcs/sti/todo/gs/GS_Stats_Limaye.java | 422 +- .../todo/gs/WikipediaTL_GSCreator_Pass1.java | 186 +- .../todo/gs/WikipediaTL_GSCreator_Pass2.java | 172 +- .../todo/gs/WikipediaTableListPageFilter.java | 200 +- .../ac/shef/dcs/sti/util/CollectionUtils.java | 118 +- .../shef/dcs/sti/util/DataTypeClassifier.java | 452 +- .../uk/ac/shef/dcs/sti/util/FileUtils.java | 110 +- .../ac/shef/dcs/sti/util/SubsetGenerator.java | 60 +- .../ac/shef/dcs/sti/util/TripleGenerator.java | 294 +- .../uk/ac/shef/dcs/sti/util/XPathUtils.java | 62 +- .../dcs/websearch/SearchResultParser.java | 24 +- .../uk/ac/shef/dcs/websearch/WebSearch.java | 54 +- .../dcs/websearch/WebSearchException.java | 28 +- .../shef/dcs/websearch/WebSearchFactory.java | 66 +- .../dcs/websearch/WebSearchResultDoc.java | 112 +- .../bing/v2/APIKeysDepletedException.java | 18 +- .../dcs/websearch/bing/v2/BingSearch.java | 204 +- .../bing/v2/BingSearchResultParser.java | 192 +- ui/README.md | 64 +- ui/config.json | 48 +- ui/main.js | 490 +- ui/nbproject/project.properties | 12 +- ui/nbproject/project.xml | 18 +- ui/node_modules/express/History.md | 6284 +++---- ui/node_modules/express/LICENSE | 48 +- ui/node_modules/express/Readme.md | 284 +- ui/node_modules/express/index.js | 22 +- ui/node_modules/express/lib/application.js | 1286 +- ui/node_modules/express/lib/express.js | 206 +- .../express/lib/middleware/init.js | 72 +- .../express/lib/middleware/query.js | 92 +- ui/node_modules/express/lib/request.js | 1004 +- ui/node_modules/express/lib/response.js | 2130 +-- ui/node_modules/express/lib/router/index.js | 1290 +- ui/node_modules/express/lib/router/layer.js | 352 +- ui/node_modules/express/lib/router/route.js | 420 +- ui/node_modules/express/lib/utils.js | 598 +- ui/node_modules/express/lib/view.js | 346 +- .../express/node_modules/accepts/HISTORY.md | 424 +- .../express/node_modules/accepts/LICENSE | 46 +- .../express/node_modules/accepts/README.md | 270 +- .../express/node_modules/accepts/index.js | 462 +- .../node_modules/mime-types/HISTORY.md | 394 +- .../accepts/node_modules/mime-types/LICENSE | 46 +- .../accepts/node_modules/mime-types/README.md | 206 +- .../accepts/node_modules/mime-types/index.js | 376 +- .../node_modules/mime-db/HISTORY.md | 682 +- .../mime-types/node_modules/mime-db/LICENSE | 44 +- .../mime-types/node_modules/mime-db/README.md | 164 +- .../mime-types/node_modules/mime-db/db.json | 13254 +++++++------- .../mime-types/node_modules/mime-db/index.js | 22 +- .../node_modules/mime-db/package.json | 198 +- .../node_modules/mime-types/package.json | 178 +- .../node_modules/negotiator/HISTORY.md | 196 +- .../accepts/node_modules/negotiator/LICENSE | 48 +- .../accepts/node_modules/negotiator/README.md | 406 +- .../accepts/node_modules/negotiator/index.js | 248 +- .../node_modules/negotiator/lib/charset.js | 338 +- .../node_modules/negotiator/lib/encoding.js | 368 +- .../node_modules/negotiator/lib/language.js | 358 +- .../node_modules/negotiator/lib/mediaType.js | 588 +- .../node_modules/negotiator/package.json | 182 +- .../express/node_modules/accepts/package.json | 158 +- .../node_modules/array-flatten/LICENSE | 42 +- .../node_modules/array-flatten/README.md | 86 +- .../array-flatten/array-flatten.js | 128 +- .../node_modules/array-flatten/package.json | 124 +- .../content-disposition/HISTORY.md | 90 +- .../node_modules/content-disposition/LICENSE | 44 +- .../content-disposition/README.md | 282 +- .../node_modules/content-disposition/index.js | 890 +- .../content-disposition/package.json | 132 +- .../node_modules/content-type/HISTORY.md | 28 +- .../express/node_modules/content-type/LICENSE | 44 +- .../node_modules/content-type/README.md | 184 +- .../node_modules/content-type/index.js | 432 +- .../node_modules/content-type/package.json | 140 +- .../node_modules/cookie-signature/.npmignore | 8 +- .../node_modules/cookie-signature/History.md | 76 +- .../node_modules/cookie-signature/Readme.md | 82 +- .../node_modules/cookie-signature/index.js | 102 +- .../cookie-signature/package.json | 118 +- .../express/node_modules/cookie/HISTORY.md | 236 +- .../express/node_modules/cookie/LICENSE | 48 +- .../express/node_modules/cookie/README.md | 440 +- .../express/node_modules/cookie/index.js | 390 +- .../express/node_modules/cookie/package.json | 144 +- .../express/node_modules/debug/.jshintrc | 6 +- .../express/node_modules/debug/.npmignore | 12 +- .../express/node_modules/debug/History.md | 390 +- .../express/node_modules/debug/Makefile | 72 +- .../express/node_modules/debug/Readme.md | 376 +- .../express/node_modules/debug/bower.json | 56 +- .../express/node_modules/debug/browser.js | 336 +- .../express/node_modules/debug/component.json | 38 +- .../express/node_modules/debug/debug.js | 394 +- .../express/node_modules/debug/node.js | 418 +- .../debug/node_modules/ms/.npmignore | 10 +- .../debug/node_modules/ms/History.md | 132 +- .../debug/node_modules/ms/LICENSE | 40 +- .../debug/node_modules/ms/README.md | 70 +- .../debug/node_modules/ms/index.js | 250 +- .../debug/node_modules/ms/package.json | 96 +- .../express/node_modules/debug/package.json | 146 +- .../express/node_modules/depd/History.md | 168 +- .../express/node_modules/depd/LICENSE | 44 +- .../express/node_modules/depd/Readme.md | 562 +- .../express/node_modules/depd/index.js | 1042 +- .../node_modules/depd/lib/browser/index.js | 158 +- .../depd/lib/compat/buffer-concat.js | 70 +- .../depd/lib/compat/callsite-tostring.js | 206 +- .../depd/lib/compat/event-listener-count.js | 44 +- .../node_modules/depd/lib/compat/index.js | 168 +- .../express/node_modules/depd/package.json | 134 +- .../express/node_modules/encodeurl/HISTORY.md | 18 +- .../express/node_modules/encodeurl/LICENSE | 44 +- .../express/node_modules/encodeurl/README.md | 248 +- .../express/node_modules/encodeurl/index.js | 120 +- .../node_modules/encodeurl/package.json | 150 +- .../express/node_modules/escape-html/LICENSE | 48 +- .../node_modules/escape-html/Readme.md | 84 +- .../express/node_modules/escape-html/index.js | 156 +- .../node_modules/escape-html/package.json | 114 +- .../express/node_modules/etag/HISTORY.md | 142 +- .../express/node_modules/etag/LICENSE | 44 +- .../express/node_modules/etag/README.md | 330 +- .../express/node_modules/etag/index.js | 264 +- .../express/node_modules/etag/package.json | 146 +- .../node_modules/finalhandler/HISTORY.md | 216 +- .../express/node_modules/finalhandler/LICENSE | 44 +- .../node_modules/finalhandler/README.md | 284 +- .../node_modules/finalhandler/index.js | 378 +- .../node_modules/statuses/HISTORY.md | 100 +- .../node_modules/statuses/LICENSE | 46 +- .../node_modules/statuses/README.md | 228 +- .../node_modules/statuses/codes.json | 128 +- .../node_modules/statuses/index.js | 220 +- .../node_modules/statuses/package.json | 208 +- .../node_modules/unpipe/HISTORY.md | 8 +- .../finalhandler/node_modules/unpipe/LICENSE | 44 +- .../node_modules/unpipe/README.md | 86 +- .../finalhandler/node_modules/unpipe/index.js | 138 +- .../node_modules/unpipe/package.json | 118 +- .../node_modules/finalhandler/package.json | 150 +- .../express/node_modules/fresh/HISTORY.md | 76 +- .../express/node_modules/fresh/LICENSE | 44 +- .../express/node_modules/fresh/README.md | 116 +- .../express/node_modules/fresh/index.js | 114 +- .../express/node_modules/fresh/package.json | 174 +- .../node_modules/merge-descriptors/HISTORY.md | 42 +- .../node_modules/merge-descriptors/LICENSE | 46 +- .../node_modules/merge-descriptors/README.md | 96 +- .../node_modules/merge-descriptors/index.js | 120 +- .../merge-descriptors/package.json | 276 +- .../express/node_modules/methods/HISTORY.md | 58 +- .../express/node_modules/methods/LICENSE | 48 +- .../express/node_modules/methods/README.md | 102 +- .../express/node_modules/methods/index.js | 138 +- .../express/node_modules/methods/package.json | 176 +- .../node_modules/on-finished/HISTORY.md | 176 +- .../express/node_modules/on-finished/LICENSE | 46 +- .../node_modules/on-finished/README.md | 308 +- .../express/node_modules/on-finished/index.js | 392 +- .../on-finished/node_modules/ee-first/LICENSE | 44 +- .../node_modules/ee-first/README.md | 160 +- .../node_modules/ee-first/index.js | 190 +- .../node_modules/ee-first/package.json | 128 +- .../node_modules/on-finished/package.json | 142 +- .../express/node_modules/parseurl/HISTORY.md | 94 +- .../express/node_modules/parseurl/LICENSE | 48 +- .../express/node_modules/parseurl/README.md | 240 +- .../express/node_modules/parseurl/index.js | 276 +- .../node_modules/parseurl/package.json | 178 +- .../node_modules/path-to-regexp/History.md | 72 +- .../node_modules/path-to-regexp/LICENSE | 42 +- .../node_modules/path-to-regexp/Readme.md | 70 +- .../node_modules/path-to-regexp/index.js | 258 +- .../node_modules/path-to-regexp/package.json | 370 +- .../node_modules/proxy-addr/HISTORY.md | 198 +- .../express/node_modules/proxy-addr/LICENSE | 44 +- .../express/node_modules/proxy-addr/README.md | 272 +- .../express/node_modules/proxy-addr/index.js | 642 +- .../node_modules/forwarded/HISTORY.md | 8 +- .../proxy-addr/node_modules/forwarded/LICENSE | 44 +- .../node_modules/forwarded/README.md | 106 +- .../node_modules/forwarded/index.js | 70 +- .../node_modules/forwarded/package.json | 130 +- .../node_modules/ipaddr.js/.npmignore | 4 +- .../node_modules/ipaddr.js/.travis.yml | 20 +- .../node_modules/ipaddr.js/Cakefile | 36 +- .../proxy-addr/node_modules/ipaddr.js/LICENSE | 36 +- .../node_modules/ipaddr.js/README.md | 418 +- .../node_modules/ipaddr.js/bower.json | 58 +- .../node_modules/ipaddr.js/lib/ipaddr.js | 1052 +- .../node_modules/ipaddr.js/package.json | 128 +- .../node_modules/ipaddr.js/src/ipaddr.coffee | 900 +- .../ipaddr.js/test/ipaddr.test.coffee | 678 +- .../node_modules/proxy-addr/package.json | 150 +- .../express/node_modules/qs/.eslintignore | 2 +- .../express/node_modules/qs/.eslintrc | 38 +- .../express/node_modules/qs/.jscs.json | 352 +- .../express/node_modules/qs/CHANGELOG.md | 240 +- .../express/node_modules/qs/CONTRIBUTING.md | 2 +- .../express/node_modules/qs/LICENSE | 56 +- .../express/node_modules/qs/dist/qs.js | 972 +- .../express/node_modules/qs/lib/index.js | 18 +- .../express/node_modules/qs/lib/parse.js | 334 +- .../express/node_modules/qs/lib/stringify.js | 274 +- .../express/node_modules/qs/lib/utils.js | 328 +- .../express/node_modules/qs/package.json | 172 +- .../express/node_modules/qs/test/index.js | 10 +- .../express/node_modules/qs/test/parse.js | 846 +- .../express/node_modules/qs/test/stringify.js | 610 +- .../express/node_modules/qs/test/utils.js | 18 +- .../node_modules/range-parser/HISTORY.md | 102 +- .../express/node_modules/range-parser/LICENSE | 46 +- .../node_modules/range-parser/README.md | 150 +- .../node_modules/range-parser/index.js | 316 +- .../node_modules/range-parser/package.json | 198 +- .../express/node_modules/send/HISTORY.md | 692 +- .../express/node_modules/send/LICENSE | 46 +- .../express/node_modules/send/README.md | 494 +- .../express/node_modules/send/index.js | 1896 +- .../send/node_modules/destroy/LICENSE | 44 +- .../send/node_modules/destroy/README.md | 120 +- .../send/node_modules/destroy/index.js | 150 +- .../send/node_modules/destroy/package.json | 144 +- .../send/node_modules/http-errors/HISTORY.md | 190 +- .../send/node_modules/http-errors/LICENSE | 46 +- .../send/node_modules/http-errors/README.md | 224 +- .../send/node_modules/http-errors/index.js | 446 +- .../http-errors/node_modules/inherits/LICENSE | 32 +- .../node_modules/inherits/README.md | 84 +- .../node_modules/inherits/inherits.js | 2 +- .../node_modules/inherits/inherits_browser.js | 46 +- .../node_modules/inherits/package.json | 100 +- .../http-errors/node_modules/inherits/test.js | 50 +- .../node_modules/setprototypeof/LICENSE | 26 +- .../node_modules/setprototypeof/README.md | 42 +- .../node_modules/setprototypeof/index.js | 22 +- .../node_modules/setprototypeof/package.json | 106 +- .../node_modules/http-errors/package.json | 192 +- .../send/node_modules/mime/LICENSE | 38 +- .../send/node_modules/mime/README.md | 180 +- .../send/node_modules/mime/build/build.js | 22 +- .../send/node_modules/mime/build/test.js | 114 +- .../send/node_modules/mime/cli.js | 16 +- .../send/node_modules/mime/mime.js | 216 +- .../send/node_modules/mime/package.json | 146 +- .../send/node_modules/mime/types.json | 2 +- .../send/node_modules/ms/.npmignore | 10 +- .../send/node_modules/ms/History.md | 132 +- .../node_modules/send/node_modules/ms/LICENSE | 40 +- .../send/node_modules/ms/README.md | 70 +- .../send/node_modules/ms/index.js | 250 +- .../send/node_modules/ms/package.json | 96 +- .../send/node_modules/statuses/HISTORY.md | 100 +- .../send/node_modules/statuses/LICENSE | 46 +- .../send/node_modules/statuses/README.md | 228 +- .../send/node_modules/statuses/codes.json | 128 +- .../send/node_modules/statuses/index.js | 220 +- .../send/node_modules/statuses/package.json | 208 +- .../express/node_modules/send/package.json | 192 +- .../node_modules/serve-static/HISTORY.md | 664 +- .../express/node_modules/serve-static/LICENSE | 50 +- .../node_modules/serve-static/README.md | 490 +- .../node_modules/serve-static/index.js | 376 +- .../node_modules/serve-static/package.json | 148 +- .../express/node_modules/type-is/HISTORY.md | 412 +- .../express/node_modules/type-is/LICENSE | 46 +- .../express/node_modules/type-is/README.md | 272 +- .../express/node_modules/type-is/index.js | 524 +- .../node_modules/media-typer/HISTORY.md | 44 +- .../type-is/node_modules/media-typer/LICENSE | 44 +- .../node_modules/media-typer/README.md | 162 +- .../type-is/node_modules/media-typer/index.js | 540 +- .../node_modules/media-typer/package.json | 116 +- .../node_modules/mime-types/HISTORY.md | 394 +- .../type-is/node_modules/mime-types/LICENSE | 46 +- .../type-is/node_modules/mime-types/README.md | 206 +- .../type-is/node_modules/mime-types/index.js | 376 +- .../node_modules/mime-db/HISTORY.md | 682 +- .../mime-types/node_modules/mime-db/LICENSE | 44 +- .../mime-types/node_modules/mime-db/README.md | 164 +- .../mime-types/node_modules/mime-db/db.json | 13254 +++++++------- .../mime-types/node_modules/mime-db/index.js | 22 +- .../node_modules/mime-db/package.json | 198 +- .../node_modules/mime-types/package.json | 178 +- .../express/node_modules/type-is/package.json | 174 +- .../node_modules/utils-merge/.travis.yml | 12 +- .../express/node_modules/utils-merge/LICENSE | 40 +- .../node_modules/utils-merge/README.md | 68 +- .../express/node_modules/utils-merge/index.js | 46 +- .../node_modules/utils-merge/package.json | 120 +- .../express/node_modules/vary/HISTORY.md | 58 +- .../express/node_modules/vary/LICENSE | 44 +- .../express/node_modules/vary/README.md | 182 +- .../express/node_modules/vary/index.js | 248 +- .../express/node_modules/vary/package.json | 144 +- ui/node_modules/express/package.json | 320 +- ui/node_modules/socket.io/.npmignore | 8 +- ui/node_modules/socket.io/.travis.yml | 40 +- ui/node_modules/socket.io/History.md | 1142 +- ui/node_modules/socket.io/LICENSE | 44 +- ui/node_modules/socket.io/Makefile | 30 +- ui/node_modules/socket.io/Readme.md | 854 +- ui/node_modules/socket.io/lib/client.js | 502 +- ui/node_modules/socket.io/lib/index.js | 770 +- ui/node_modules/socket.io/lib/namespace.js | 544 +- ui/node_modules/socket.io/lib/socket.js | 940 +- .../socket.io/node_modules/debug/.jshintrc | 6 +- .../socket.io/node_modules/debug/.npmignore | 12 +- .../socket.io/node_modules/debug/History.md | 390 +- .../socket.io/node_modules/debug/Makefile | 72 +- .../socket.io/node_modules/debug/Readme.md | 376 +- .../socket.io/node_modules/debug/bower.json | 56 +- .../socket.io/node_modules/debug/browser.js | 336 +- .../node_modules/debug/component.json | 38 +- .../socket.io/node_modules/debug/debug.js | 394 +- .../socket.io/node_modules/debug/node.js | 418 +- .../debug/node_modules/ms/.npmignore | 10 +- .../debug/node_modules/ms/History.md | 132 +- .../debug/node_modules/ms/LICENSE | 40 +- .../debug/node_modules/ms/README.md | 70 +- .../debug/node_modules/ms/index.js | 250 +- .../debug/node_modules/ms/package.json | 96 +- .../socket.io/node_modules/debug/package.json | 146 +- .../node_modules/engine.io/.npmignore | 12 +- .../node_modules/engine.io/.travis.yml | 20 +- .../node_modules/engine.io/History.md | 1002 +- .../socket.io/node_modules/engine.io/LICENSE | 38 +- .../socket.io/node_modules/engine.io/Makefile | 46 +- .../node_modules/engine.io/README.md | 1068 +- .../socket.io/node_modules/engine.io/index.js | 8 +- .../node_modules/engine.io/lib/engine.io.js | 252 +- .../node_modules/engine.io/lib/server.js | 914 +- .../node_modules/engine.io/lib/socket.js | 942 +- .../node_modules/engine.io/lib/transport.js | 254 +- .../engine.io/lib/transports/index.js | 72 +- .../engine.io/lib/transports/polling-jsonp.js | 148 +- .../engine.io/lib/transports/polling-xhr.js | 140 +- .../engine.io/lib/transports/polling.js | 814 +- .../engine.io/lib/transports/websocket.js | 250 +- .../engine.io/node_modules/accepts/HISTORY.md | 148 +- .../engine.io/node_modules/accepts/LICENSE | 44 +- .../engine.io/node_modules/accepts/README.md | 188 +- .../engine.io/node_modules/accepts/index.js | 320 +- .../node_modules/mime-types/HISTORY.md | 230 +- .../accepts/node_modules/mime-types/LICENSE | 44 +- .../accepts/node_modules/mime-types/README.md | 204 +- .../accepts/node_modules/mime-types/index.js | 126 +- .../node_modules/mime-db/HISTORY.md | 424 +- .../mime-types/node_modules/mime-db/LICENSE | 44 +- .../mime-types/node_modules/mime-db/README.md | 152 +- .../mime-types/node_modules/mime-db/db.json | 12718 +++++++------- .../mime-types/node_modules/mime-db/index.js | 22 +- .../node_modules/mime-db/package.json | 188 +- .../node_modules/mime-types/package.json | 168 +- .../accepts/node_modules/negotiator/LICENSE | 46 +- .../accepts/node_modules/negotiator/README.md | 322 +- .../node_modules/negotiator/lib/charset.js | 174 +- .../node_modules/negotiator/lib/encoding.js | 234 +- .../node_modules/negotiator/lib/language.js | 200 +- .../node_modules/negotiator/lib/mediaType.js | 244 +- .../node_modules/negotiator/lib/negotiator.js | 74 +- .../node_modules/negotiator/package.json | 158 +- .../node_modules/accepts/package.json | 184 +- .../node_modules/base64id/.npmignore | 6 +- .../engine.io/node_modules/base64id/README.md | 36 +- .../node_modules/base64id/lib/base64id.js | 206 +- .../node_modules/base64id/package.json | 96 +- .../node_modules/engine.io-parser/.npmignore | 34 +- .../node_modules/engine.io-parser/.travis.yml | 86 +- .../node_modules/engine.io-parser/.zuul.yml | 10 +- .../node_modules/engine.io-parser/History.md | 230 +- .../node_modules/engine.io-parser/LICENSE | 42 +- .../node_modules/engine.io-parser/Makefile | 52 +- .../node_modules/engine.io-parser/Readme.md | 404 +- .../node_modules/engine.io-parser/index.js | 4 +- .../engine.io-parser/lib/browser.js | 1188 +- .../engine.io-parser/lib/index.js | 920 +- .../node_modules/engine.io-parser/lib/keys.js | 38 +- .../node_modules/after/.npmignore | 4 +- .../node_modules/after/.travis.yml | 10 +- .../node_modules/after/LICENCE | 36 +- .../node_modules/after/README.md | 150 +- .../node_modules/after/index.js | 56 +- .../node_modules/after/package.json | 124 +- .../node_modules/after/test/after-test.js | 240 +- .../node_modules/arraybuffer.slice/.npmignore | 34 +- .../node_modules/arraybuffer.slice/Makefile | 16 +- .../node_modules/arraybuffer.slice/README.md | 34 +- .../node_modules/arraybuffer.slice/index.js | 58 +- .../arraybuffer.slice/package.json | 78 +- .../arraybuffer.slice/test/slice-buffer.js | 454 +- .../base64-arraybuffer/.npmignore | 2 +- .../base64-arraybuffer/.travis.yml | 12 +- .../base64-arraybuffer/LICENSE-MIT | 44 +- .../node_modules/base64-arraybuffer/README.md | 46 +- .../base64-arraybuffer/README.md~ | 46 +- .../node_modules/base64-arraybuffer/grunt.js | 76 +- .../lib/base64-arraybuffer.js | 118 +- .../base64-arraybuffer/package.json | 112 +- .../base64-arraybuffer/package.json~ | 70 +- .../test/base64-arraybuffer_test.js | 144 +- .../node_modules/blob/.npmignore | 4 +- .../node_modules/blob/.zuul.yml | 28 +- .../node_modules/blob/Makefile | 28 +- .../node_modules/blob/README.md | 28 +- .../node_modules/blob/index.js | 192 +- .../node_modules/blob/package.json | 88 +- .../node_modules/blob/test/index.js | 188 +- .../node_modules/has-binary/.npmignore | 30 +- .../node_modules/has-binary/History.md | 22 +- .../node_modules/has-binary/LICENSE | 40 +- .../node_modules/has-binary/Makefile | 6 +- .../node_modules/has-binary/README.md | 8 +- .../node_modules/has-binary/fixtures/big.json | 2 +- .../node_modules/has-binary/index.js | 116 +- .../has-binary/node_modules/isarray/README.md | 108 +- .../node_modules/isarray/build/build.js | 418 +- .../node_modules/isarray/component.json | 38 +- .../has-binary/node_modules/isarray/index.js | 6 +- .../node_modules/isarray/package.json | 106 +- .../node_modules/has-binary/package.json | 78 +- .../node_modules/has-binary/test.js | 216 +- .../node_modules/utf8/.gitattributes | 4 +- .../node_modules/utf8/.npmignore | 40 +- .../node_modules/utf8/.travis.yml | 42 +- .../node_modules/utf8/Gruntfile.js | 150 +- .../node_modules/utf8/LICENSE-MIT.txt | 40 +- .../node_modules/utf8/README.md | 238 +- .../node_modules/utf8/bower.json | 28 +- .../node_modules/utf8/component.json | 32 +- .../node_modules/utf8/package.json | 128 +- .../utf8/tests/generate-test-data.py | 100 +- .../node_modules/utf8/tests/index.html | 70 +- .../node_modules/utf8/tests/tests.js | 552 +- .../node_modules/utf8/utf8.js | 488 +- .../engine.io-parser/package.json | 108 +- .../engine.io/node_modules/ws/.npmignore | 22 +- .../engine.io/node_modules/ws/.travis.yml | 30 +- .../engine.io/node_modules/ws/Makefile | 90 +- .../engine.io/node_modules/ws/README.md | 470 +- .../engine.io/node_modules/ws/SECURITY.md | 66 +- .../engine.io/node_modules/ws/index.js | 98 +- .../node_modules/ws/lib/BufferPool.js | 126 +- .../ws/lib/BufferUtil.fallback.js | 94 +- .../node_modules/ws/lib/BufferUtil.js | 26 +- .../node_modules/ws/lib/ErrorCodes.js | 46 +- .../node_modules/ws/lib/Extensions.js | 140 +- .../node_modules/ws/lib/PerMessageDeflate.js | 674 +- .../node_modules/ws/lib/Receiver.hixie.js | 388 +- .../engine.io/node_modules/ws/lib/Receiver.js | 1586 +- .../node_modules/ws/lib/Sender.hixie.js | 248 +- .../engine.io/node_modules/ws/lib/Sender.js | 648 +- .../ws/lib/Validation.fallback.js | 22 +- .../node_modules/ws/lib/Validation.js | 26 +- .../node_modules/ws/lib/WebSocket.js | 1974 +-- .../node_modules/ws/lib/WebSocketServer.js | 1108 +- .../ws/node_modules/options/.npmignore | 14 +- .../ws/node_modules/options/Makefile | 24 +- .../ws/node_modules/options/README.md | 138 +- .../ws/node_modules/options/lib/options.js | 172 +- .../ws/node_modules/options/package.json | 102 +- .../ws/node_modules/ultron/.npmignore | 6 +- .../ws/node_modules/ultron/.travis.yml | 42 +- .../ws/node_modules/ultron/LICENSE | 44 +- .../ws/node_modules/ultron/README.md | 194 +- .../ws/node_modules/ultron/index.js | 258 +- .../ws/node_modules/ultron/package.json | 148 +- .../ws/node_modules/ultron/test.js | 654 +- .../engine.io/node_modules/ws/package.json | 164 +- .../node_modules/engine.io/package.json | 162 +- .../node_modules/has-binary/.npmignore | 30 +- .../node_modules/has-binary/History.md | 38 +- .../socket.io/node_modules/has-binary/LICENSE | 40 +- .../node_modules/has-binary/Makefile | 6 +- .../node_modules/has-binary/README.md | 8 +- .../node_modules/has-binary/index.js | 118 +- .../has-binary/node_modules/isarray/README.md | 108 +- .../node_modules/isarray/build/build.js | 418 +- .../node_modules/isarray/component.json | 38 +- .../has-binary/node_modules/isarray/index.js | 6 +- .../node_modules/isarray/package.json | 106 +- .../node_modules/has-binary/package.json | 80 +- .../socket.io/node_modules/has-binary/test.js | 146 +- .../node_modules/socket.io-adapter/.npmignore | 2 +- .../node_modules/socket.io-adapter/History.md | 66 +- .../node_modules/socket.io-adapter/LICENSE | 40 +- .../node_modules/socket.io-adapter/Readme.md | 32 +- .../node_modules/socket.io-adapter/index.js | 472 +- .../node_modules/socket.io-parser/.npmignore | 10 +- .../node_modules/socket.io-parser/.travis.yml | 22 +- .../node_modules/socket.io-parser/.zuul.yml | 32 +- .../node_modules/socket.io-parser/History.md | 174 +- .../node_modules/socket.io-parser/Makefile | 22 +- .../node_modules/socket.io-parser/Readme.md | 146 +- .../socket.io-parser/bench/bench.js | 20 +- .../socket.io-parser/bench/index.js | 162 +- .../node_modules/socket.io-parser/binary.js | 282 +- .../node_modules/socket.io-parser/index.js | 792 +- .../socket.io-parser/is-buffer.js | 26 +- .../node_modules/benchmark/LICENSE.txt | 44 +- .../node_modules/benchmark/README.md | 262 +- .../node_modules/benchmark/benchmark.js | 7836 ++++----- .../node_modules/benchmark/doc/README.md | 5256 +++--- .../node_modules/benchmark/package.json | 122 +- .../node_modules/benchmark/test/run-test.sh | 18 +- .../node_modules/benchmark/test/test.js | 4148 ++--- .../node_modules/component-emitter/.npmignore | 4 +- .../component-emitter/.travis.yml | 6 +- .../node_modules/component-emitter/History.md | 104 +- .../node_modules/component-emitter/Makefile | 12 +- .../node_modules/component-emitter/Readme.md | 148 +- .../node_modules/component-emitter/bower.json | 42 +- .../component-emitter/component.json | 28 +- .../node_modules/component-emitter/index.js | 328 +- .../component-emitter/package.json | 94 +- .../node_modules/debug/Readme.md | 230 +- .../node_modules/debug/debug.js | 274 +- .../node_modules/debug/index.js | 10 +- .../node_modules/debug/lib/debug.js | 294 +- .../node_modules/debug/package.json | 126 +- .../node_modules/isarray/README.md | 108 +- .../node_modules/isarray/build/build.js | 418 +- .../node_modules/isarray/component.json | 38 +- .../node_modules/isarray/index.js | 6 +- .../node_modules/isarray/package.json | 106 +- .../node_modules/json3/.gitmodules | 12 +- .../node_modules/json3/.jamignore | 20 +- .../node_modules/json3/.npmignore | 22 +- .../node_modules/json3/.travis.yml | 66 +- .../node_modules/json3/LICENSE | 38 +- .../node_modules/json3/README.md | 250 +- .../coverage/lcov-report/lib/json3.js.html | 5806 +++---- .../json3/coverage/lcov-report/prettify.css | 2 +- .../json3/coverage/lcov-report/prettify.js | 2 +- .../node_modules/json3/coverage/lcov.info | 4070 ++--- .../node_modules/json3/lib/json3.js | 1722 +- .../node_modules/json3/lib/json3.min.js | 34 +- .../node_modules/json3/package.json | 204 +- .../socket.io-parser/package.json | 102 +- .../socket.io-adapter/package.json | 82 +- .../node_modules/socket.io-client/History.md | 922 +- .../node_modules/socket.io-client/LICENSE | 42 +- .../node_modules/socket.io-client/README.md | 376 +- .../socket.io-client/lib/index.js | 184 +- .../socket.io-client/lib/manager.js | 1114 +- .../node_modules/socket.io-client/lib/on.js | 48 +- .../socket.io-client/lib/socket.js | 824 +- .../node_modules/socket.io-client/lib/url.js | 152 +- .../node_modules/backo2/.npmignore | 2 +- .../node_modules/backo2/History.md | 24 +- .../node_modules/backo2/Makefile | 14 +- .../node_modules/backo2/Readme.md | 68 +- .../node_modules/backo2/component.json | 22 +- .../node_modules/backo2/index.js | 170 +- .../node_modules/backo2/package.json | 90 +- .../node_modules/backo2/test/index.js | 34 +- .../node_modules/component-bind/.npmignore | 8 +- .../node_modules/component-bind/History.md | 26 +- .../node_modules/component-bind/Makefile | 12 +- .../node_modules/component-bind/Readme.md | 126 +- .../component-bind/component.json | 26 +- .../node_modules/component-bind/index.js | 46 +- .../node_modules/component-bind/package.json | 94 +- .../node_modules/component-emitter/History.md | 126 +- .../node_modules/component-emitter/LICENSE | 48 +- .../node_modules/component-emitter/Readme.md | 148 +- .../node_modules/component-emitter/index.js | 322 +- .../component-emitter/package.json | 348 +- .../node_modules/engine.io-client/.npmignore | 4 +- .../node_modules/engine.io-client/.travis.yml | 92 +- .../node_modules/engine.io-client/.zuul.yml | 12 +- .../node_modules/engine.io-client/History.md | 1136 +- .../node_modules/engine.io-client/LICENSE | 44 +- .../node_modules/engine.io-client/Makefile | 76 +- .../node_modules/engine.io-client/README.md | 584 +- .../engine.io-client/engine.io.js | 8488 ++++----- .../node_modules/engine.io-client/index.js | 4 +- .../engine.io-client/lib/index.js | 20 +- .../engine.io-client/lib/socket.js | 1456 +- .../engine.io-client/lib/transport.js | 310 +- .../engine.io-client/lib/transports/index.js | 106 +- .../lib/transports/polling-jsonp.js | 476 +- .../lib/transports/polling-xhr.js | 824 +- .../lib/transports/polling.js | 494 +- .../lib/transports/websocket.js | 576 +- .../engine.io-client/lib/xmlhttprequest.js | 72 +- .../node_modules/component-emitter/.npmignore | 4 +- .../component-emitter/.travis.yml | 6 +- .../node_modules/component-emitter/History.md | 104 +- .../node_modules/component-emitter/Makefile | 12 +- .../node_modules/component-emitter/Readme.md | 148 +- .../node_modules/component-emitter/bower.json | 42 +- .../component-emitter/component.json | 28 +- .../node_modules/component-emitter/index.js | 328 +- .../component-emitter/package.json | 94 +- .../node_modules/component-inherit/.npmignore | 6 +- .../node_modules/component-inherit/History.md | 10 +- .../node_modules/component-inherit/Makefile | 32 +- .../node_modules/component-inherit/Readme.md | 48 +- .../component-inherit/component.json | 20 +- .../node_modules/component-inherit/index.js | 12 +- .../component-inherit/package.json | 88 +- .../component-inherit/test/inherit.js | 40 +- .../node_modules/engine.io-parser/.npmignore | 34 +- .../node_modules/engine.io-parser/.travis.yml | 86 +- .../node_modules/engine.io-parser/.zuul.yml | 10 +- .../node_modules/engine.io-parser/History.md | 230 +- .../node_modules/engine.io-parser/LICENSE | 42 +- .../node_modules/engine.io-parser/Makefile | 52 +- .../node_modules/engine.io-parser/Readme.md | 404 +- .../node_modules/engine.io-parser/index.js | 4 +- .../engine.io-parser/lib/browser.js | 1188 +- .../engine.io-parser/lib/index.js | 920 +- .../node_modules/engine.io-parser/lib/keys.js | 38 +- .../node_modules/after/.npmignore | 4 +- .../node_modules/after/.travis.yml | 10 +- .../node_modules/after/LICENCE | 36 +- .../node_modules/after/README.md | 150 +- .../node_modules/after/index.js | 56 +- .../node_modules/after/package.json | 124 +- .../node_modules/after/test/after-test.js | 240 +- .../node_modules/arraybuffer.slice/.npmignore | 34 +- .../node_modules/arraybuffer.slice/Makefile | 16 +- .../node_modules/arraybuffer.slice/README.md | 34 +- .../node_modules/arraybuffer.slice/index.js | 58 +- .../arraybuffer.slice/package.json | 78 +- .../arraybuffer.slice/test/slice-buffer.js | 454 +- .../base64-arraybuffer/.npmignore | 2 +- .../base64-arraybuffer/.travis.yml | 12 +- .../base64-arraybuffer/LICENSE-MIT | 44 +- .../node_modules/base64-arraybuffer/README.md | 46 +- .../base64-arraybuffer/README.md~ | 46 +- .../node_modules/base64-arraybuffer/grunt.js | 76 +- .../lib/base64-arraybuffer.js | 118 +- .../base64-arraybuffer/package.json | 112 +- .../base64-arraybuffer/package.json~ | 70 +- .../test/base64-arraybuffer_test.js | 144 +- .../node_modules/blob/.npmignore | 4 +- .../node_modules/blob/.zuul.yml | 28 +- .../node_modules/blob/Makefile | 28 +- .../node_modules/blob/README.md | 28 +- .../node_modules/blob/index.js | 192 +- .../node_modules/blob/package.json | 88 +- .../node_modules/blob/test/index.js | 188 +- .../node_modules/has-binary/.npmignore | 30 +- .../node_modules/has-binary/History.md | 22 +- .../node_modules/has-binary/LICENSE | 40 +- .../node_modules/has-binary/Makefile | 6 +- .../node_modules/has-binary/README.md | 8 +- .../node_modules/has-binary/fixtures/big.json | 2 +- .../node_modules/has-binary/index.js | 116 +- .../has-binary/node_modules/isarray/README.md | 108 +- .../node_modules/isarray/build/build.js | 418 +- .../node_modules/isarray/component.json | 38 +- .../has-binary/node_modules/isarray/index.js | 6 +- .../node_modules/isarray/package.json | 106 +- .../node_modules/has-binary/package.json | 78 +- .../node_modules/has-binary/test.js | 216 +- .../node_modules/utf8/.gitattributes | 4 +- .../node_modules/utf8/.npmignore | 40 +- .../node_modules/utf8/.travis.yml | 42 +- .../node_modules/utf8/Gruntfile.js | 150 +- .../node_modules/utf8/LICENSE-MIT.txt | 40 +- .../node_modules/utf8/README.md | 238 +- .../node_modules/utf8/bower.json | 28 +- .../node_modules/utf8/component.json | 32 +- .../node_modules/utf8/package.json | 128 +- .../utf8/tests/generate-test-data.py | 100 +- .../node_modules/utf8/tests/index.html | 70 +- .../node_modules/utf8/tests/tests.js | 552 +- .../node_modules/utf8/utf8.js | 488 +- .../engine.io-parser/package.json | 108 +- .../node_modules/has-cors/.npmignore | 6 +- .../node_modules/has-cors/History.md | 42 +- .../node_modules/has-cors/Makefile | 22 +- .../node_modules/has-cors/Readme.md | 48 +- .../node_modules/has-cors/component.json | 26 +- .../node_modules/has-cors/index.js | 34 +- .../node_modules/has-cors/package.json | 124 +- .../node_modules/has-cors/test.js | 48 +- .../node_modules/parsejson/Makefile | 6 +- .../node_modules/parsejson/index.js | 62 +- .../node_modules/better-assert/.npmignore | 8 +- .../node_modules/better-assert/History.md | 30 +- .../node_modules/better-assert/Makefile | 8 +- .../node_modules/better-assert/Readme.md | 120 +- .../node_modules/better-assert/example.js | 18 +- .../node_modules/better-assert/index.js | 76 +- .../node_modules/callsite/.npmignore | 8 +- .../node_modules/callsite/History.md | 20 +- .../node_modules/callsite/Makefile | 10 +- .../node_modules/callsite/Readme.md | 88 +- .../node_modules/callsite/index.js | 20 +- .../node_modules/callsite/package.json | 88 +- .../node_modules/better-assert/package.json | 128 +- .../node_modules/parsejson/package.json | 74 +- .../node_modules/parsejson/test.js | 42 +- .../node_modules/parseqs/Makefile | 6 +- .../node_modules/parseqs/index.js | 74 +- .../node_modules/better-assert/.npmignore | 8 +- .../node_modules/better-assert/History.md | 30 +- .../node_modules/better-assert/Makefile | 8 +- .../node_modules/better-assert/Readme.md | 120 +- .../node_modules/better-assert/example.js | 18 +- .../node_modules/better-assert/index.js | 76 +- .../node_modules/callsite/.npmignore | 8 +- .../node_modules/callsite/History.md | 20 +- .../node_modules/callsite/Makefile | 10 +- .../node_modules/callsite/Readme.md | 88 +- .../node_modules/callsite/index.js | 20 +- .../node_modules/callsite/package.json | 88 +- .../node_modules/better-assert/package.json | 128 +- .../node_modules/parseqs/package.json | 74 +- .../node_modules/parseqs/test.js | 54 +- .../node_modules/ws/.npmignore | 22 +- .../node_modules/ws/.travis.yml | 30 +- .../engine.io-client/node_modules/ws/Makefile | 80 +- .../node_modules/ws/README.md | 484 +- .../engine.io-client/node_modules/ws/index.js | 98 +- .../node_modules/ws/lib/BufferPool.js | 126 +- .../ws/lib/BufferUtil.fallback.js | 94 +- .../node_modules/ws/lib/BufferUtil.js | 26 +- .../node_modules/ws/lib/ErrorCodes.js | 46 +- .../node_modules/ws/lib/Extensions.js | 140 +- .../node_modules/ws/lib/PerMessageDeflate.js | 650 +- .../node_modules/ws/lib/Receiver.hixie.js | 368 +- .../node_modules/ws/lib/Receiver.js | 1404 +- .../node_modules/ws/lib/Sender.hixie.js | 248 +- .../node_modules/ws/lib/Sender.js | 648 +- .../ws/lib/Validation.fallback.js | 24 +- .../node_modules/ws/lib/Validation.js | 26 +- .../node_modules/ws/lib/WebSocket.js | 1930 +- .../node_modules/ws/lib/WebSocketServer.js | 1026 +- .../ws/node_modules/options/.npmignore | 14 +- .../ws/node_modules/options/Makefile | 24 +- .../ws/node_modules/options/README.md | 138 +- .../ws/node_modules/options/lib/options.js | 172 +- .../ws/node_modules/options/package.json | 102 +- .../ws/node_modules/ultron/.npmignore | 6 +- .../ws/node_modules/ultron/.travis.yml | 42 +- .../ws/node_modules/ultron/LICENSE | 44 +- .../ws/node_modules/ultron/README.md | 194 +- .../ws/node_modules/ultron/index.js | 258 +- .../ws/node_modules/ultron/package.json | 148 +- .../ws/node_modules/ultron/test.js | 654 +- .../node_modules/ws/package.json | 154 +- .../node_modules/xmlhttprequest-ssl/LICENSE | 44 +- .../node_modules/xmlhttprequest-ssl/README.md | 122 +- .../xmlhttprequest-ssl/autotest.watchr | 16 +- .../xmlhttprequest-ssl/example/demo.js | 32 +- .../xmlhttprequest-ssl/lib/XMLHttpRequest.js | 1292 +- .../xmlhttprequest-ssl/package.json | 116 +- .../tests/test-constants.js | 26 +- .../xmlhttprequest-ssl/tests/test-events.js | 100 +- .../tests/test-exceptions.js | 118 +- .../xmlhttprequest-ssl/tests/test-headers.js | 152 +- .../tests/test-redirect-302.js | 82 +- .../tests/test-redirect-303.js | 82 +- .../tests/test-redirect-307.js | 86 +- .../tests/test-request-methods.js | 124 +- .../tests/test-request-protocols.js | 64 +- .../node_modules/yeast/LICENSE | 44 +- .../node_modules/yeast/README.md | 164 +- .../node_modules/yeast/index.js | 136 +- .../node_modules/yeast/package.json | 132 +- .../engine.io-client/package.json | 186 +- .../node_modules/indexof/.npmignore | 4 +- .../node_modules/indexof/Makefile | 22 +- .../node_modules/indexof/Readme.md | 28 +- .../node_modules/indexof/component.json | 18 +- .../node_modules/indexof/index.js | 18 +- .../node_modules/indexof/package.json | 64 +- .../node_modules/object-component/.npmignore | 6 +- .../node_modules/object-component/History.md | 20 +- .../node_modules/object-component/Makefile | 32 +- .../node_modules/object-component/Readme.md | 60 +- .../object-component/component.json | 18 +- .../node_modules/object-component/index.js | 166 +- .../object-component/package.json | 70 +- .../object-component/test/object.js | 94 +- .../node_modules/parseuri/History.md | 10 +- .../node_modules/parseuri/Makefile | 6 +- .../node_modules/parseuri/index.js | 78 +- .../node_modules/better-assert/.npmignore | 8 +- .../node_modules/better-assert/History.md | 30 +- .../node_modules/better-assert/Makefile | 8 +- .../node_modules/better-assert/Readme.md | 120 +- .../node_modules/better-assert/example.js | 18 +- .../node_modules/better-assert/index.js | 76 +- .../node_modules/callsite/.npmignore | 8 +- .../node_modules/callsite/History.md | 20 +- .../node_modules/callsite/Makefile | 10 +- .../node_modules/callsite/Readme.md | 88 +- .../node_modules/callsite/index.js | 20 +- .../node_modules/callsite/package.json | 88 +- .../node_modules/better-assert/package.json | 128 +- .../node_modules/parseuri/package.json | 90 +- .../node_modules/parseuri/test.js | 102 +- .../node_modules/to-array/.npmignore | 4 +- .../node_modules/to-array/LICENCE | 36 +- .../node_modules/to-array/README.md | 44 +- .../node_modules/to-array/index.js | 26 +- .../node_modules/to-array/package.json | 130 +- .../socket.io-client/package.json | 202 +- .../socket.io-client/socket.io.js | 14496 ++++++++-------- .../node_modules/socket.io-parser/.npmignore | 10 +- .../node_modules/socket.io-parser/.travis.yml | 92 +- .../node_modules/socket.io-parser/.zuul.yml | 40 +- .../node_modules/socket.io-parser/History.md | 216 +- .../node_modules/socket.io-parser/LICENSE | 40 +- .../node_modules/socket.io-parser/Makefile | 54 +- .../node_modules/socket.io-parser/Readme.md | 146 +- .../socket.io-parser/bench/bench.js | 20 +- .../socket.io-parser/bench/index.js | 162 +- .../node_modules/socket.io-parser/binary.js | 282 +- .../node_modules/socket.io-parser/index.js | 800 +- .../socket.io-parser/is-buffer.js | 26 +- .../node_modules/benchmark/LICENSE.txt | 44 +- .../node_modules/benchmark/README.md | 262 +- .../node_modules/benchmark/benchmark.js | 7836 ++++----- .../node_modules/benchmark/doc/README.md | 5256 +++--- .../node_modules/benchmark/package.json | 122 +- .../node_modules/benchmark/test/run-test.sh | 18 +- .../node_modules/benchmark/test/test.js | 4148 ++--- .../node_modules/component-emitter/.npmignore | 4 +- .../component-emitter/.travis.yml | 6 +- .../node_modules/component-emitter/History.md | 104 +- .../node_modules/component-emitter/Makefile | 12 +- .../node_modules/component-emitter/Readme.md | 148 +- .../node_modules/component-emitter/bower.json | 42 +- .../component-emitter/component.json | 28 +- .../node_modules/component-emitter/index.js | 328 +- .../component-emitter/package.json | 94 +- .../node_modules/isarray/README.md | 108 +- .../node_modules/isarray/build/build.js | 418 +- .../node_modules/isarray/component.json | 38 +- .../node_modules/isarray/index.js | 6 +- .../node_modules/isarray/package.json | 106 +- .../node_modules/json3/LICENSE | 38 +- .../node_modules/json3/README.md | 304 +- .../node_modules/json3/lib/json3.js | 1804 +- .../node_modules/json3/lib/json3.min.js | 34 +- .../node_modules/json3/package.json | 226 +- .../socket.io-parser/package.json | 106 +- ui/node_modules/socket.io/package.json | 176 +- ui/package.json | 16 +- ui/public/index.html | 512 +- ui/public/resources/gears.gif | Bin ui/public/resources/icon_email.png | Bin ui/public/resources/icon_kb.png | Bin ui/public/resources/icon_parser.png | Bin ui/public/resources/icon_url.png | Bin ui/public/resources/tmp.css | 144 +- 1454 files changed, 209629 insertions(+), 213051 deletions(-) mode change 100755 => 100644 config/kbsearch.properties mode change 100755 => 100644 config/sti.imdb.properties mode change 100755 => 100644 config/sti.musicbrainz.properties mode change 100755 => 100644 config/sti.properties mode change 100755 => 100644 config/websearch.properties delete mode 100644 sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNING.java delete mode 100644 sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryColumnClassifier.java delete mode 100644 sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryDisamb.java delete mode 100644 sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTagger.java delete mode 100644 sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTaggerImpl.java delete mode 100644 sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/RELATIONENUMERATION.java delete mode 100644 sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TCellDisambiguator.java delete mode 100644 sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnClassifier.java delete mode 100644 sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnColumnRelationEnumerator.java delete mode 100644 sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TMPInterpreter.java delete mode 100644 sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/UPDATE.java delete mode 100644 sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_combined.java delete mode 100644 sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_contextWords.java delete mode 100644 sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nameLength.java delete mode 100644 sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_namelength_merge.java delete mode 100644 sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nonEmpty.java delete mode 100644 sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_random.java delete mode 100644 sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/Random.java delete mode 100644 sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentCellRanker.java delete mode 100644 sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentRowRanker.java delete mode 100644 sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentTContentRowRankerImpl.java delete mode 100644 sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPClazzScorer.java delete mode 100644 sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPEntityScorer.java delete mode 100644 sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPRelationScorer.java delete mode 100644 sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/FixedNumberOfRows.java delete mode 100644 sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/IInf.java delete mode 100644 sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/NoStop.java delete mode 100644 sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/StoppingCriteria.java delete mode 100644 sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/StoppingCriteriaInstantiator.java mode change 100755 => 100644 ui/config.json mode change 100755 => 100644 ui/node_modules/express/node_modules/qs/lib/index.js mode change 100755 => 100644 ui/node_modules/express/node_modules/qs/lib/parse.js mode change 100755 => 100644 ui/node_modules/express/node_modules/qs/lib/stringify.js mode change 100755 => 100644 ui/node_modules/express/node_modules/qs/lib/utils.js mode change 100755 => 100644 ui/node_modules/express/node_modules/qs/test/parse.js mode change 100755 => 100644 ui/node_modules/express/node_modules/qs/test/stringify.js mode change 100755 => 100644 ui/node_modules/express/node_modules/qs/test/utils.js mode change 100755 => 100644 ui/node_modules/express/node_modules/send/node_modules/mime/cli.js mode change 100755 => 100644 ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/tests/generate-test-data.py mode change 100755 => 100644 ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/benchmark/test/run-test.sh mode change 100755 => 100644 ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/index.js mode change 100755 => 100644 ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/polling-xhr.js mode change 100755 => 100644 ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/utf8/tests/generate-test-data.py mode change 100755 => 100644 ui/node_modules/socket.io/node_modules/socket.io-parser/node_modules/benchmark/test/run-test.sh mode change 100755 => 100644 ui/public/index.html mode change 100755 => 100644 ui/public/resources/gears.gif mode change 100755 => 100644 ui/public/resources/icon_email.png mode change 100755 => 100644 ui/public/resources/icon_kb.png mode change 100755 => 100644 ui/public/resources/icon_parser.png mode change 100755 => 100644 ui/public/resources/icon_url.png mode change 100755 => 100644 ui/public/resources/tmp.css diff --git a/.gitignore b/.gitignore index 7adb95a3..60d6cbe8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,135 +1,135 @@ -# ========================= -# Operating System Files -# ========================= - -ui/tmp -ui/output - -# Windows image file caches -Thumbs.db -ehthumbs.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msm -*.msp - -# Windows shortcuts -*.lnk - -# ========================= -# OSX -# ========================= - -.DS_Store -.AppleDouble -.LSOverride - -# Thumbnails -._* - -# Files that might appear on external disk -.Spotlight-V100 -.Trashes - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk -*.class -*.log -*.lck -graph.txt -*.csv -core/lodie.log.1 -*.csv -*.1 -failed.txt -output/* -*.log -*/target -*.iml -.idea/* -cache/empty/class/data/* -cache/empty/entity/data/* -cache/empty/relation/data/* -cache/empty/websearch/data/* -cache/empty/similarity/data/* -delete/* - -# ========================= -# Eclipse files -# ========================= - -.metadata -bin/ -tmp/ -*.tmp -*.bak -*.swp -*~.nib -local.properties -.settings/ -.loadpath -.recommenders - -# Eclipse Core -.project - -# External tool builders -.externalToolBuilders/ - -# Locally stored "Eclipse launch configurations" -*.launch - -# PyDev specific (Python IDE for Eclipse) -*.pydevproject - -# CDT-specific (C/C++ Development Tooling) -.cproject - -# JDT-specific (Eclipse Java Development Tools) -.classpath - -# Java annotation processor (APT) -.factorypath - -# PDT-specific (PHP Development Tools) -.buildpath - -# sbteclipse plugin -.target - -# Tern plugin -.tern-project - -# TeXlipse plugin -.texlipse - -# STS (Spring Tool Suite) -.springBeans - -# Code Recommenders -.recommenders/ - -# ========================= -# IntelliJ IDEA -# ========================= - -*.iml -*/.idea -.Idea/* -out/* -classes/* -/ui/nbproject/private/ -*/.idea/* -target/* +# ========================= +# Operating System Files +# ========================= + +ui/tmp +ui/output + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# ========================= +# OSX +# ========================= + +.DS_Store +.AppleDouble +.LSOverride + +# Thumbnails +._* + +# Files that might appear on external disk +.Spotlight-V100 +.Trashes + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk +*.class +*.log +*.lck +graph.txt +*.csv +core/lodie.log.1 +*.csv +*.1 +failed.txt +output/* +*.log +*/target +*.iml +.idea/* +cache/empty/class/data/* +cache/empty/entity/data/* +cache/empty/relation/data/* +cache/empty/websearch/data/* +cache/empty/similarity/data/* +delete/* + +# ========================= +# Eclipse files +# ========================= + +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.recommenders + +# Eclipse Core +.project + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# PyDev specific (Python IDE for Eclipse) +*.pydevproject + +# CDT-specific (C/C++ Development Tooling) +.cproject + +# JDT-specific (Eclipse Java Development Tools) +.classpath + +# Java annotation processor (APT) +.factorypath + +# PDT-specific (PHP Development Tools) +.buildpath + +# sbteclipse plugin +.target + +# Tern plugin +.tern-project + +# TeXlipse plugin +.texlipse + +# STS (Spring Tool Suite) +.springBeans + +# Code Recommenders +.recommenders/ + +# ========================= +# IntelliJ IDEA +# ========================= + +*.iml +*/.idea +.Idea/* +out/* +classes/* +/ui/nbproject/private/ +*/.idea/* +target/* diff --git a/.travis.yml b/.travis.yml index 406d6acf..fe779bbd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ -## Travis build file - -language: java -jdk: oraclejdk8 -before_install: - - echo "MAVEN_OPTS='-Xmx2048m -XX:MaxPermSize=512m'" > ~/.mavenrc - - mvn install:install-file -DgroupId=edu.drexel -DartifactId=dragontool -Dversion=1.3.3 -Dpackaging=jar -Dfile=libs/dragontool.jar - - mvn install:install-file -DgroupId=com.github.mpkorstanje -DartifactId=simmetrics -Dversion=4.1.0L -Dpackaging=jar -Dfile=libs/simmetrics.jar +## Travis build file + +language: java +jdk: oraclejdk8 +before_install: + - echo "MAVEN_OPTS='-Xmx2048m -XX:MaxPermSize=512m'" > ~/.mavenrc + - mvn install:install-file -DgroupId=edu.drexel -DartifactId=dragontool -Dversion=1.3.3 -Dpackaging=jar -Dfile=libs/dragontool.jar + - mvn install:install-file -DgroupId=com.github.mpkorstanje -DartifactId=simmetrics -Dversion=4.1.0L -Dpackaging=jar -Dfile=libs/simmetrics.jar diff --git a/README.md b/README.md index bd3c5fca..6e32292e 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,30 @@ -# Semantic Table Interpretation - -### DISCLAIMER - -This project is based on the work described at [1]. The original code referred to in the paper is now hosted and can be downloaded from [here](http://staffwww.dcs.shef.ac.uk/people/Z.Zhang/resources/tableminerplus/sti_2015.zip). The code has then been significantly improved, undergone a lot of refactorization and re-implementation, and therefore, may not work with the cache included in the published data [here](http://staffwww.dcs.shef.ac.uk/people/Z.Zhang/resources/tableminerplus/data.tar.gz). - -In addition to TableMiner+, this project provides implementation of several other semantic table interpretation algorithms, including: Joint Inference based on Liamye2011, and Semantic Message Passing based on Mulwad2013. **However, due to many things out of our control (e.g., use of in-house software in original works, different versions of knowledge bases), please note that we cannot guarantee identical replication of the original systems or reproduction of experiment results.** - - -### ACKNOWLEDGEMENT -Part of this work was funded by the EPSRC project LODIE - Linked Open Data for Information Extraction, EP/ J019488/1. - -### LICENCE -Apache 2.0 - -### Quick Start - - Place a copy of STI on your computer - - Run maven to install two 3rd party libraries (in 'libs') to your local maven repository. See https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html and the maven plugin with id 'maven-install-plugin' for howto. - - Download test data, from [here](http://staffwww.dcs.shef.ac.uk/people/Z.Zhang/resources/tableminerplus/data.tar.gz) - - Unzip the test data, into e.g., [sti_data] - - Navigate into [sti_data/dataset], unzip, depending on the test cases: imdb.tar.gz for the IMDB dataset; musicbrainz.tar.gz for the MusicBrainz dataset; Limaye200.tar.gz for the Limaye200 dataset; Limaye_complete.tar.gz for the LimayeAll dataset - - Configure your local copy of STI - - - open 'sti.properties', as a minimum, you need to change 'sti.home', and 'sti.cache.main.dir'. Please follow the documentation inside the property file - - - open 'kbsearch.properties', as a minimum, you need to change 'kb.search.result.stoplistfile', and 'fb.query.api.key' to use your own Freebase API key - - - open 'websearch.properties', as a minimum, you need to change 'bing.keys' to use your own bing web search key - - Run a test case. For example, to run TMP, use: **uk.ac.shef.dcs.sti.experiment.TableMinerPlusBatch "[sti_data/Limaye200]" "[output_dir]" "/[sit_home_dir]/sti.properties"** - -**Note:** 'sti.properties' distributed with code is a default configuration for Limaye200 and LimayeAll datasets; for IMDB and MusicBrainz datasets, you can edit a template inside '/resources'. For both IMDB and MusicBrainz, you may want to provide the VM variable '-Djava.util.logging.config.file=' to configure the logging output of the any23-sti module (which can produce too many logs). - -[1] Under minor revision review: http://www.semantic-web-journal.net/content/effective-and-efficient-semantic-table-interpretation-using-tableminer-0 +# Semantic Table Interpretation + +### DISCLAIMER + +This project is based on the work described at [1]. The original code referred to in the paper is now hosted and can be downloaded from [here](http://staffwww.dcs.shef.ac.uk/people/Z.Zhang/resources/tableminerplus/sti_2015.zip). The code has then been significantly improved, undergone a lot of refactorization and re-implementation, and therefore, may not work with the cache included in the published data [here](http://staffwww.dcs.shef.ac.uk/people/Z.Zhang/resources/tableminerplus/data.tar.gz). + +In addition to TableMiner+, this project provides implementation of several other semantic table interpretation algorithms, including: Joint Inference based on Liamye2011, and Semantic Message Passing based on Mulwad2013. **However, due to many things out of our control (e.g., use of in-house software in original works, different versions of knowledge bases), please note that we cannot guarantee identical replication of the original systems or reproduction of experiment results.** + + +### ACKNOWLEDGEMENT +Part of this work was funded by the EPSRC project LODIE - Linked Open Data for Information Extraction, EP/ J019488/1. + +### LICENCE +Apache 2.0 + +### Quick Start + - Place a copy of STI on your computer + - Run maven to install two 3rd party libraries (in 'libs') to your local maven repository. See https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html and the maven plugin with id 'maven-install-plugin' for howto. + - Download test data, from [here](http://staffwww.dcs.shef.ac.uk/people/Z.Zhang/resources/tableminerplus/data.tar.gz) + - Unzip the test data, into e.g., [sti_data] + - Navigate into [sti_data/dataset], unzip, depending on the test cases: imdb.tar.gz for the IMDB dataset; musicbrainz.tar.gz for the MusicBrainz dataset; Limaye200.tar.gz for the Limaye200 dataset; Limaye_complete.tar.gz for the LimayeAll dataset + - Configure your local copy of STI + - - open 'sti.properties', as a minimum, you need to change 'sti.home', and 'sti.cache.main.dir'. Please follow the documentation inside the property file + - - open 'kbsearch.properties', as a minimum, you need to change 'kb.search.result.stoplistfile', and 'fb.query.api.key' to use your own Freebase API key + - - open 'websearch.properties', as a minimum, you need to change 'bing.keys' to use your own bing web search key + - Run a test case. For example, to run TMP, use: **uk.ac.shef.dcs.sti.experiment.TableMinerPlusBatch "[sti_data/Limaye200]" "[output_dir]" "/[sit_home_dir]/sti.properties"** + +**Note:** 'sti.properties' distributed with code is a default configuration for Limaye200 and LimayeAll datasets; for IMDB and MusicBrainz datasets, you can edit a template inside '/resources'. For both IMDB and MusicBrainz, you may want to provide the VM variable '-Djava.util.logging.config.file=' to configure the logging output of the any23-sti module (which can produce too many logs). + +[1] Under minor revision review: http://www.semantic-web-journal.net/content/effective-and-efficient-semantic-table-interpretation-using-tableminer-0 diff --git a/config/kbsearch.properties b/config/kbsearch.properties old mode 100755 new mode 100644 index 454059a2..f3344d11 --- a/config/kbsearch.properties +++ b/config/kbsearch.properties @@ -1,41 +1,41 @@ -##################################### -# GENERIC VARIABLE # -##################################### -# A file (MUST BE ABSOLUTE PATH) that lists things (e.g., predicate URIs) to be used by an instance of uk.ac.shef.dcs.kbsearch.KBSearchResultFilter, which decides what triples/relations/classes to remove. Specific rules are implemented by subclasses of uk.ac.shef.dcs.kbsearch.KBSearchResultFilter, which should be instantiated as part of uk.ac.shef.dcs.kbsearch.KBSearch. Details of how the stoplist is used can be found in the kbstoplist.txt documentation -#kb.search.result.stoplistfile=/Users/-/work/sti/resources/kbstoplist.txt -kb.search.result.stoplistfile=/Users/-/work/sti/resources/kbstoplist_dbpedia.txt - -# Name of the implementation class of uk.ac.shef.dcs.kbsearch.KBSearch. This is responsible for querying the knowledge base -#kb.search.class=uk.ac.shef.dcs.kbsearch.freebase.FreebaseSearch -kb.search.class=uk.ac.shef.dcs.kbsearch.sparql.DBpediaSearch -# If a query keyword does not match to anything in a KB, you can try splitting if it contains conjunctive word "and","or". set to true if you want this -kb.search.tryfuzzykeyword=true - - -################################################################ -# Specific instance of uk.ac.shef.dcs.kbsearch.KBSearch # -################################################################ - -#>> An instance of uk.ac.shef.dcs.kbsearch.freebase.FreebaseSearch, uses Freebase API -# max number of queries allowed per second -fb.query.max.sec=10 -# max number of queries allowed per day -fb.query.max.day=100000 -# freebase api key. YOU SHOULD USE YOUR OWN -fb.query.api.key=AIzaSyAcL9jlS9czJrT0OLlWH24Od0mYrsycnSk -# access URL for the freebase mql api -fb.query.apiurl.mql=https://www.googleapis.com/freebase/v1/mqlread -# access URL for the freebase topic api -fb.query.apiurl.topic=https://www.googleapis.com/freebase/v1/topic -# access URL for the freebase search api -fb.query.apiurl.search=https://www.googleapis.com/freebase/v1/search -# freebase homepage -fb.homepage=http://www.freebase.com -# number of results to obtain in the freebase query -fb.query.param.limit=1000 - - -dbp.sparql.endpoint=http://galaxy.dcs.shef.ac.uk:8893/sparql -#dbp.sparql.endpoint=http://dbpedia.org/sparql -dbp.ontology.url=file:/Users/-/work/sti/resources/dbpedia_ontology_2014.owl - +##################################### +# GENERIC VARIABLE # +##################################### +# A file (MUST BE ABSOLUTE PATH) that lists things (e.g., predicate URIs) to be used by an instance of uk.ac.shef.dcs.kbsearch.KBSearchResultFilter, which decides what triples/relations/classes to remove. Specific rules are implemented by subclasses of uk.ac.shef.dcs.kbsearch.KBSearchResultFilter, which should be instantiated as part of uk.ac.shef.dcs.kbsearch.KBSearch. Details of how the stoplist is used can be found in the kbstoplist.txt documentation +#kb.search.result.stoplistfile=/Users/-/work/sti/resources/kbstoplist.txt +kb.search.result.stoplistfile=/Users/-/work/sti/resources/kbstoplist_dbpedia.txt + +# Name of the implementation class of uk.ac.shef.dcs.kbsearch.KBSearch. This is responsible for querying the knowledge base +#kb.search.class=uk.ac.shef.dcs.kbsearch.freebase.FreebaseSearch +kb.search.class=uk.ac.shef.dcs.kbsearch.sparql.DBpediaSearch +# If a query keyword does not match to anything in a KB, you can try splitting if it contains conjunctive word "and","or". set to true if you want this +kb.search.tryfuzzykeyword=true + + +################################################################ +# Specific instance of uk.ac.shef.dcs.kbsearch.KBSearch # +################################################################ + +#>> An instance of uk.ac.shef.dcs.kbsearch.freebase.FreebaseSearch, uses Freebase API +# max number of queries allowed per second +fb.query.max.sec=10 +# max number of queries allowed per day +fb.query.max.day=100000 +# freebase api key. YOU SHOULD USE YOUR OWN +fb.query.api.key=AIzaSyAcL9jlS9czJrT0OLlWH24Od0mYrsycnSk +# access URL for the freebase mql api +fb.query.apiurl.mql=https://www.googleapis.com/freebase/v1/mqlread +# access URL for the freebase topic api +fb.query.apiurl.topic=https://www.googleapis.com/freebase/v1/topic +# access URL for the freebase search api +fb.query.apiurl.search=https://www.googleapis.com/freebase/v1/search +# freebase homepage +fb.homepage=http://www.freebase.com +# number of results to obtain in the freebase query +fb.query.param.limit=1000 + + +dbp.sparql.endpoint=http://galaxy.dcs.shef.ac.uk:8893/sparql +#dbp.sparql.endpoint=http://dbpedia.org/sparql +dbp.ontology.url=file:/Users/-/work/sti/resources/dbpedia_ontology_2014.owl + diff --git a/config/log4j.properties b/config/log4j.properties index 772a123b..841060bc 100644 --- a/config/log4j.properties +++ b/config/log4j.properties @@ -1,26 +1,26 @@ -# Root logger option -# switch logging level for other options(TRACE, DEBUG, INFO, WARN, ERROR, FATAL) -log4j.rootLogger=ERROR, file, stdout - -# Direct LOG messages to a LOG file -log4j.appender.file=org.apache.log4j.RollingFileAppender -log4j.appender.file.File=sti.log -log4j.appender.file.MaxFileSize=10MB -log4j.appender.file.MaxBackupIndex=10 -log4j.appender.file.layout=org.apache.log4j.PatternLayout -log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n - -log4j.logger.uk.ac.shef.dcs.sti=INFO,myappender -log4j.logger.org.apache.lucene.analysis.sti=INFO,myappender,stdout - -# Direct LOG messages to stdout -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Target=System.out -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n - -log4j.appender.myappender=org.apache.log4j.DailyRollingFileAppender -log4j.appender.myappender.datePattern='-'dd'.log' -log4j.appender.myappender.File=sti.log -log4j.appender.myappender.layout=org.apache.log4j.PatternLayout +# Root logger option +# switch logging level for other options(TRACE, DEBUG, INFO, WARN, ERROR, FATAL) +log4j.rootLogger=ERROR, file, stdout + +# Direct LOG messages to a LOG file +log4j.appender.file=org.apache.log4j.RollingFileAppender +log4j.appender.file.File=sti.log +log4j.appender.file.MaxFileSize=10MB +log4j.appender.file.MaxBackupIndex=10 +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n + +log4j.logger.uk.ac.shef.dcs.sti=INFO,myappender +log4j.logger.org.apache.lucene.analysis.sti=INFO,myappender,stdout + +# Direct LOG messages to stdout +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n + +log4j.appender.myappender=org.apache.log4j.DailyRollingFileAppender +log4j.appender.myappender.datePattern='-'dd'.log' +log4j.appender.myappender.File=sti.log +log4j.appender.myappender.layout=org.apache.log4j.PatternLayout log4j.appender.myappender.layout.ConversionPattern=%-6r %d{ISO8601} %-5p %40.40c %x - %m%n \ No newline at end of file diff --git a/config/sti.imdb.properties b/config/sti.imdb.properties old mode 100755 new mode 100644 index 176cf056..ef69c5fb --- a/config/sti.imdb.properties +++ b/config/sti.imdb.properties @@ -1,52 +1,52 @@ -################################################################### -# For explanations of the variables, please see sti.properties, # -# originally distributed in the project's root folder. This # -# property file is to be used for the IMDB dataset # -################################################################### - -sti.home=/Users/-/work/sti -sti.nlp=resources -sti.cache.main.dir=/Users/-/work/sti/cache/empty -sti.websearch.properties=websearch.properties -sti.kbsearch.propertyfile=kbsearch.properties -sti.list.failure=failed.txt -sti.input.parser.class=uk.ac.shef.dcs.sti.parser.table.TableParserIMDB - - -sti.start=0 -sti.list.select= -sti.columns.ignore=0,2,3 -sti.columns.mustdo= - -sti.subjectcolumndetection.ws=true -sti.iinf.websearch.stopping.class=uk.ac.shef.dcs.sti.core.algorithm.tmp.stopping.IInf -sti.iinf.websearch.stopping.class.constructor.params=0.0,1,0.01 - -sti.tmp.iinf.learning.stopping.class=uk.ac.shef.dcs.sti.core.algorithm.tmp.stopping.IInf -sti.tmp.iinf.learning.stopping.class.constructor.params=0.0,1,0.05 - -sti.learning.relation=false - -sti.output.triple.namespace.kb=www.freebase.org -sti.output.triple.namespace.default=www.shef.ac.uk - - - - -sti.baseline.method=sim -sti.baseline.similarity.stringmetrics.method=levenshtein - - - -sti.smp.usesubjectcolumn=false -sti.smp.entityranker=smpfreebase -sti.smp.halting.maxiteration=10 -sti.smp.changemessage.minscore=0.5 -sti.smp.clazzspecificitycalculator=uk.ac.shef.dcs.sti.core.algorithm.smp.FreebaseClazzSpecificityCalculator - - - -sti.ji.usesubjectcolumn=false -sti.ji.maxiterations=0 -sti.ji.debugmode=false +################################################################### +# For explanations of the variables, please see sti.properties, # +# originally distributed in the project's root folder. This # +# property file is to be used for the IMDB dataset # +################################################################### + +sti.home=/Users/-/work/sti +sti.nlp=resources +sti.cache.main.dir=/Users/-/work/sti/cache/empty +sti.websearch.properties=websearch.properties +sti.kbsearch.propertyfile=kbsearch.properties +sti.list.failure=failed.txt +sti.input.parser.class=uk.ac.shef.dcs.sti.parser.table.TableParserIMDB + + +sti.start=0 +sti.list.select= +sti.columns.ignore=0,2,3 +sti.columns.mustdo= + +sti.subjectcolumndetection.ws=true +sti.iinf.websearch.stopping.class=uk.ac.shef.dcs.sti.core.algorithm.tmp.stopping.IInf +sti.iinf.websearch.stopping.class.constructor.params=0.0,1,0.01 + +sti.tmp.iinf.learning.stopping.class=uk.ac.shef.dcs.sti.core.algorithm.tmp.stopping.IInf +sti.tmp.iinf.learning.stopping.class.constructor.params=0.0,1,0.05 + +sti.learning.relation=false + +sti.output.triple.namespace.kb=www.freebase.org +sti.output.triple.namespace.default=www.shef.ac.uk + + + + +sti.baseline.method=sim +sti.baseline.similarity.stringmetrics.method=levenshtein + + + +sti.smp.usesubjectcolumn=false +sti.smp.entityranker=smpfreebase +sti.smp.halting.maxiteration=10 +sti.smp.changemessage.minscore=0.5 +sti.smp.clazzspecificitycalculator=uk.ac.shef.dcs.sti.core.algorithm.smp.FreebaseClazzSpecificityCalculator + + + +sti.ji.usesubjectcolumn=false +sti.ji.maxiterations=0 +sti.ji.debugmode=false sti.ji.clazzspecificitycalculator=uk.ac.shef.dcs.sti.core.algorithm.smp.FreebaseClazzSpecificityCalculator \ No newline at end of file diff --git a/config/sti.musicbrainz.properties b/config/sti.musicbrainz.properties old mode 100755 new mode 100644 index cd33103a..f27d7bdc --- a/config/sti.musicbrainz.properties +++ b/config/sti.musicbrainz.properties @@ -1,50 +1,50 @@ -################################################################### -# For explanations of the variables, please see sti.properties, # -# originally distributed in the project's root folder. This # -# property file is to be used for the MusicBrainz dataset # -################################################################### -sti.home=/Users/-/work/sti -sti.nlp=resources -sti.cache.main.dir=/Users/-/work/sti/cache/empty -sti.websearch.properties=websearch.properties -sti.kbsearch.propertyfile=kbsearch.properties -sti.list.failure=failed.txt -sti.input.parser.class=uk.ac.shef.dcs.sti.parser.table.TableParserMusicBrainz - -sti.start=0 -sti.list.select= -sti.columns.ignore=1 -sti.columns.mustdo= - -sti.subjectcolumndetection.ws=true -sti.iinf.websearch.stopping.class=uk.ac.shef.dcs.sti.core.algorithm.tmp.stopping.IInf -sti.iinf.websearch.stopping.class.constructor.params=0.0,1,0.01 - -sti.tmp.iinf.learning.stopping.class=uk.ac.shef.dcs.sti.core.algorithm.tmp.stopping.IInf -sti.tmp.iinf.learning.stopping.class.constructor.params=0.0,1,0.01 - -sti.learning.relation=true - -sti.output.triple.namespace.kb=www.freebase.org -sti.output.triple.namespace.default=www.shef.ac.uk - - - -sti.baseline.method=sim -sti.baseline.similarity.stringmetrics.method=levenshtein - - - - -sti.smp.usesubjectcolumn=false -sti.smp.entityranker=smpfreebase -sti.smp.halting.maxiteration=10 -sti.smp.changemessage.minscore=0.5 -sti.smp.clazzspecificitycalculator=uk.ac.shef.dcs.sti.core.algorithm.smp.FreebaseClazzSpecificityCalculator - - - -sti.ji.usesubjectcolumn=false -sti.ji.maxiterations=0 -sti.ji.debugmode=false +################################################################### +# For explanations of the variables, please see sti.properties, # +# originally distributed in the project's root folder. This # +# property file is to be used for the MusicBrainz dataset # +################################################################### +sti.home=/Users/-/work/sti +sti.nlp=resources +sti.cache.main.dir=/Users/-/work/sti/cache/empty +sti.websearch.properties=websearch.properties +sti.kbsearch.propertyfile=kbsearch.properties +sti.list.failure=failed.txt +sti.input.parser.class=uk.ac.shef.dcs.sti.parser.table.TableParserMusicBrainz + +sti.start=0 +sti.list.select= +sti.columns.ignore=1 +sti.columns.mustdo= + +sti.subjectcolumndetection.ws=true +sti.iinf.websearch.stopping.class=uk.ac.shef.dcs.sti.core.algorithm.tmp.stopping.IInf +sti.iinf.websearch.stopping.class.constructor.params=0.0,1,0.01 + +sti.tmp.iinf.learning.stopping.class=uk.ac.shef.dcs.sti.core.algorithm.tmp.stopping.IInf +sti.tmp.iinf.learning.stopping.class.constructor.params=0.0,1,0.01 + +sti.learning.relation=true + +sti.output.triple.namespace.kb=www.freebase.org +sti.output.triple.namespace.default=www.shef.ac.uk + + + +sti.baseline.method=sim +sti.baseline.similarity.stringmetrics.method=levenshtein + + + + +sti.smp.usesubjectcolumn=false +sti.smp.entityranker=smpfreebase +sti.smp.halting.maxiteration=10 +sti.smp.changemessage.minscore=0.5 +sti.smp.clazzspecificitycalculator=uk.ac.shef.dcs.sti.core.algorithm.smp.FreebaseClazzSpecificityCalculator + + + +sti.ji.usesubjectcolumn=false +sti.ji.maxiterations=0 +sti.ji.debugmode=false sti.ji.clazzspecificitycalculator=uk.ac.shef.dcs.sti.core.algorithm.smp.FreebaseClazzSpecificityCalculator \ No newline at end of file diff --git a/config/sti.properties b/config/sti.properties old mode 100755 new mode 100644 index c0d368f7..21d9a6cd --- a/config/sti.properties +++ b/config/sti.properties @@ -1,119 +1,119 @@ -#################### -# FILE PATHS # -#################### -# STI home folder. All other file paths wil be relative to this (except otherwise stated). -sti.home=/Users/-/work/sti -# Folder containing nlp resources (by default this is the '/resource' folder in the distribution) -sti.nlp=resources -# Folder containing cached data (must be ABSOLUTE PATH). Whenever KB search or Web search is performed, the query and results are cached in a Solr instance. This specifies the path to Solr. (by default this is the /cache/empty folder in the distribution. The folder contains only solr schemas, but no data. This means you can use them directly as long as you correct the path. And the system will begin with remotely querying KB or the Web and gradually builds up the cache). -sti.cache.main.dir=/Users/-/work/sti/resources/cache/empty -# Web search configuration file. By default this is located in the home folder of the distribution -sti.websearch.properties=config/websearch.properties -# KB search configuration file. By default this is located in the home folder of the distribution -sti.kbsearch.propertyfile=config/kbsearch.properties -# When STI is run in batch mode (e.g., processing a folder containing multiple input files, by using an instance of uk.ac.shef.dcs.sti.experiment.STIBatch), it loads in all files and sort them by file name. If for any input file the process failed due to any exception, the indexes of such files (as index of the file in the sorted list) are written to this provided file. -sti.list.failure=resources/failed.txt -# [IF YOU USE UI, this is not used]Input files must be parsed to create an internal uk.ac.shef.dcs.sti.core.model.Table objects. Depending on the input data files, specific TableParser class must be implemented and specified here. The class must have a defult constructor that does not take any arguments -sti.input.parser.class=uk.ac.shef.dcs.sti.parser.table.TableParserLimayeDataset - - -#################################### -# SELECTIVE START (generic) # -#################################### -# STI tries to classify the data type of table columns, and typically only certain types of columns are passed for interpretation. While this process is highly accurate, it is not guaranteed to be perfect so in some occassions it is possible to have, e.g., NE-columns mis-classified as numeric, or long text. Therefore, for all input tables, if you know some columns should not be considered for interpretation, specify them here as a comma delimieted string. E.g, '0,1,5' will tell STI to ignore the first, 2nd and 6th columns in input tables. -sti.columns.ignore= -# Similar as the above, if you know some columns must be analyzed, you can provide their index here -sti.columns.mustdo= - - -################################ -# SELECTIVE START (batch) # -################################ -# when running in batch mode, instead of always processing the entire input folder, starting from the first file, it is possible to make the process selective by defining the following parameters - -# Given the input files read from a folder sorted by their file names, you can choose to start from a particular index position in the sorted list. The first file's index is 0. This is useful when, e.g., the previously process broke down and you want to continue from a particular position. The index position of each processed input file will be output in the log file -sti.start=0 -# Similar as above, you can provide a list of indexes representing the files you want to process. Note that if this variable is defined, ONLY THESE SPECIFIED files will be processed. This variable must be an absolute file path pointing to a plain text file, where each line is the index of a file in the sorted input folder. Leave this variable empty if you do not want to be selective -sti.list.select= - - -################################################ -# Subject column detection, the ws scorer # -################################################ - -# Whether STI should use the ws score in detecting subject column -sti.subjectcolumndetection.ws=true -# If ws is used, what stopping criteria class should be used -sti.iinf.websearch.stopping.class=uk.ac.shef.dcs.sti.core.algorithm.tmp.stopping.IInf -# if ws is used, for the stopping criteria class provided above, also provide its contructor parameters in the order it is defined in the class, delimited by , -sti.iinf.websearch.stopping.class.constructor.params=0.0,1,0.01 - - -######################## -# RELATION ENUMERATION # -######################## -# Choose whether or not STI should annotate relations -sti.learning.relation=true - -########## -# OUTPUT # -########## - -# What is the namespace that the KB uses -sti.output.triple.namespace.kb=www.freebase.org -# What is the namespace to use for newly extracted classes, relations and entities that are not available in the KB -sti.output.triple.namespace.default=www.shef.ac.uk - - - - - - -############################################################# -# TABLEMINER+: LEARNING (only needed if you run tableminer+ # -############################################################# -# What stopping criteria class should be used in the iinf for preliminary column classification -sti.tmp.iinf.learning.stopping.class=uk.ac.shef.dcs.sti.core.algorithm.tmp.stopping.IInf -# for the stopping criteria class provided above, also provide its contructor parameters in the order it is defined in the class values separated by , -sti.tmp.iinf.learning.stopping.class.constructor.params=0.0,1,0.05 - - - -############################################################# -# BASELINE: (only needed if you run baseline nm or sim) # -############################################################# -# what baseline method to use. Two options: nm=name match; sim=string similarity based -sti.baseline.method=sim -# if string similarity based baseline is used, define what string similarity metric to be used. This must be the name of the method of class org.simmetrics.metrics.StringMetrics (simmetrics library), which you want to call and obtain an instance of StringMetric -sti.baseline.similarity.stringmetrics.method=levenshtein - - - -############################################################# -# SEMANTIC MESSAGE PASSING: (only needed if you run smp) # -############################################################# -# whether smp should use tableminer+ subject column detection and use the information of subejct column in interpretation -sti.smp.usesubjectcolumn=false -# the choice of entity ranker to use. Two options: tmp to use the cell disambiguation method proposed by tableminer+; smpfreebase to use the method adapted from the original smp algorithm to Freebase -sti.smp.entityranker=smpfreebase -# maximum number of iterations in the semantic message passing phase. default is 10 if not provided -sti.smp.halting.maxiteration=10 -# when smp computes changemessages, it will check the score assigned to the annotations of the cell, column or relation. If the score is less than this threshold, it is considered 'unstable' and therefore a changemessage is created to indicate that in the next iteration, this cell/column/relation's annotation should be changed -sti.smp.changemessage.minscore=0.5 -# an implementation class of uk.ac.shef.dcs.sti.core.algorithm.smp.ClazzSpecificityCalculator, which should compute the specificity score of a class from the KB. This class will be created via reflection, so if new implementing classes are created, you must revise uk.ac.shef.dcs.sti.experiment.SemanticMessagePassingBatch getClazzSpecificityCalculator() method that is responsible for instance creation accordingly -sti.smp.clazzspecificitycalculator=uk.ac.shef.dcs.sti.core.algorithm.smp.FreebaseClazzSpecificityCalculator - - - - -############################################################# -# JOINT INFERENCE: (only needed if you run ji) # -############################################################# -# whether smp should use tableminer+ subject column detection and use the information of subejct column in interpretation -sti.ji.usesubjectcolumn=false -# the maximum number of iterations of joint inference. If set to 0, inference will continue until convergence (if possible) -sti.ji.maxiterations=0 -# if true additional procedure will be performed to check the consistency of the created factor graph and output additional logs -sti.ji.debugmode=false -# an implementation class of uk.ac.shef.dcs.sti.core.algorithm.smp.ClazzSpecificityCalculator, which should compute the specificity score of a class from the KB. This class will be created via reflection, so if new implementing classes are created, you must revise uk.ac.shef.dcs.sti.experiment.SemanticMessagePassingBatch getClazzSpecificityCalculator() method that is responsible for instance creation accordingly -sti.ji.clazzspecificitycalculator=uk.ac.shef.dcs.sti.core.algorithm.smp.FreebaseClazzSpecificityCalculator +#################### +# FILE PATHS # +#################### +# STI home folder. All other file paths wil be relative to this (except otherwise stated). +sti.home=/Users/-/work/sti +# Folder containing nlp resources (by default this is the '/resource' folder in the distribution) +sti.nlp=resources +# Folder containing cached data (must be ABSOLUTE PATH). Whenever KB search or Web search is performed, the query and results are cached in a Solr instance. This specifies the path to Solr. (by default this is the /cache/empty folder in the distribution. The folder contains only solr schemas, but no data. This means you can use them directly as long as you correct the path. And the system will begin with remotely querying KB or the Web and gradually builds up the cache). +sti.cache.main.dir=/Users/-/work/sti/resources/cache/empty +# Web search configuration file. By default this is located in the home folder of the distribution +sti.websearch.properties=config/websearch.properties +# KB search configuration file. By default this is located in the home folder of the distribution +sti.kbsearch.propertyfile=config/kbsearch.properties +# When STI is run in batch mode (e.g., processing a folder containing multiple input files, by using an instance of uk.ac.shef.dcs.sti.experiment.STIBatch), it loads in all files and sort them by file name. If for any input file the process failed due to any exception, the indexes of such files (as index of the file in the sorted list) are written to this provided file. +sti.list.failure=resources/failed.txt +# [IF YOU USE UI, this is not used]Input files must be parsed to create an internal uk.ac.shef.dcs.sti.core.model.Table objects. Depending on the input data files, specific TableParser class must be implemented and specified here. The class must have a defult constructor that does not take any arguments +sti.input.parser.class=uk.ac.shef.dcs.sti.parser.table.TableParserLimayeDataset + + +#################################### +# SELECTIVE START (generic) # +#################################### +# STI tries to classify the data type of table columns, and typically only certain types of columns are passed for interpretation. While this process is highly accurate, it is not guaranteed to be perfect so in some occassions it is possible to have, e.g., NE-columns mis-classified as numeric, or long text. Therefore, for all input tables, if you know some columns should not be considered for interpretation, specify them here as a comma delimieted string. E.g, '0,1,5' will tell STI to ignore the first, 2nd and 6th columns in input tables. +sti.columns.ignore= +# Similar as the above, if you know some columns must be analyzed, you can provide their index here +sti.columns.mustdo= + + +################################ +# SELECTIVE START (batch) # +################################ +# when running in batch mode, instead of always processing the entire input folder, starting from the first file, it is possible to make the process selective by defining the following parameters + +# Given the input files read from a folder sorted by their file names, you can choose to start from a particular index position in the sorted list. The first file's index is 0. This is useful when, e.g., the previously process broke down and you want to continue from a particular position. The index position of each processed input file will be output in the log file +sti.start=0 +# Similar as above, you can provide a list of indexes representing the files you want to process. Note that if this variable is defined, ONLY THESE SPECIFIED files will be processed. This variable must be an absolute file path pointing to a plain text file, where each line is the index of a file in the sorted input folder. Leave this variable empty if you do not want to be selective +sti.list.select= + + +################################################ +# Subject column detection, the ws scorer # +################################################ + +# Whether STI should use the ws score in detecting subject column +sti.subjectcolumndetection.ws=true +# If ws is used, what stopping criteria class should be used +sti.iinf.websearch.stopping.class=uk.ac.shef.dcs.sti.core.algorithm.tmp.stopping.IInf +# if ws is used, for the stopping criteria class provided above, also provide its contructor parameters in the order it is defined in the class, delimited by , +sti.iinf.websearch.stopping.class.constructor.params=0.0,1,0.01 + + +######################## +# RELATION ENUMERATION # +######################## +# Choose whether or not STI should annotate relations +sti.learning.relation=true + +########## +# OUTPUT # +########## + +# What is the namespace that the KB uses +sti.output.triple.namespace.kb=www.freebase.org +# What is the namespace to use for newly extracted classes, relations and entities that are not available in the KB +sti.output.triple.namespace.default=www.shef.ac.uk + + + + + + +############################################################# +# TABLEMINER+: LEARNING (only needed if you run tableminer+ # +############################################################# +# What stopping criteria class should be used in the iinf for preliminary column classification +sti.tmp.iinf.learning.stopping.class=uk.ac.shef.dcs.sti.core.algorithm.tmp.stopping.IInf +# for the stopping criteria class provided above, also provide its contructor parameters in the order it is defined in the class values separated by , +sti.tmp.iinf.learning.stopping.class.constructor.params=0.0,1,0.05 + + + +############################################################# +# BASELINE: (only needed if you run baseline nm or sim) # +############################################################# +# what baseline method to use. Two options: nm=name match; sim=string similarity based +sti.baseline.method=sim +# if string similarity based baseline is used, define what string similarity metric to be used. This must be the name of the method of class org.simmetrics.metrics.StringMetrics (simmetrics library), which you want to call and obtain an instance of StringMetric +sti.baseline.similarity.stringmetrics.method=levenshtein + + + +############################################################# +# SEMANTIC MESSAGE PASSING: (only needed if you run smp) # +############################################################# +# whether smp should use tableminer+ subject column detection and use the information of subejct column in interpretation +sti.smp.usesubjectcolumn=false +# the choice of entity ranker to use. Two options: tmp to use the cell disambiguation method proposed by tableminer+; smpfreebase to use the method adapted from the original smp algorithm to Freebase +sti.smp.entityranker=smpfreebase +# maximum number of iterations in the semantic message passing phase. default is 10 if not provided +sti.smp.halting.maxiteration=10 +# when smp computes changemessages, it will check the score assigned to the annotations of the cell, column or relation. If the score is less than this threshold, it is considered 'unstable' and therefore a changemessage is created to indicate that in the next iteration, this cell/column/relation's annotation should be changed +sti.smp.changemessage.minscore=0.5 +# an implementation class of uk.ac.shef.dcs.sti.core.algorithm.smp.ClazzSpecificityCalculator, which should compute the specificity score of a class from the KB. This class will be created via reflection, so if new implementing classes are created, you must revise uk.ac.shef.dcs.sti.experiment.SemanticMessagePassingBatch getClazzSpecificityCalculator() method that is responsible for instance creation accordingly +sti.smp.clazzspecificitycalculator=uk.ac.shef.dcs.sti.core.algorithm.smp.FreebaseClazzSpecificityCalculator + + + + +############################################################# +# JOINT INFERENCE: (only needed if you run ji) # +############################################################# +# whether smp should use tableminer+ subject column detection and use the information of subejct column in interpretation +sti.ji.usesubjectcolumn=false +# the maximum number of iterations of joint inference. If set to 0, inference will continue until convergence (if possible) +sti.ji.maxiterations=0 +# if true additional procedure will be performed to check the consistency of the created factor graph and output additional logs +sti.ji.debugmode=false +# an implementation class of uk.ac.shef.dcs.sti.core.algorithm.smp.ClazzSpecificityCalculator, which should compute the specificity score of a class from the KB. This class will be created via reflection, so if new implementing classes are created, you must revise uk.ac.shef.dcs.sti.experiment.SemanticMessagePassingBatch getClazzSpecificityCalculator() method that is responsible for instance creation accordingly +sti.ji.clazzspecificitycalculator=uk.ac.shef.dcs.sti.core.algorithm.smp.FreebaseClazzSpecificityCalculator diff --git a/config/websearch.properties b/config/websearch.properties old mode 100755 new mode 100644 index 7b9be553..06edda3f --- a/config/websearch.properties +++ b/config/websearch.properties @@ -1,18 +1,18 @@ - -################################# -# GENERIC VARIABLE # -################################# - -#What class should be use to do web search (used in subject column detection for computing the ws score). It must extend uk.ac.shef.dcs.websearch.WebSearch and uk.ac.shef.dcs.kbsearch.KBSearchFactory must be revised to instantiate it by reflection. -web.search.class=uk.ac.shef.dcs.websearch.bing.v2.BingSearch - - -############################################################################ -# Specific k.ac.shef.dcs.websearch.WebSearch instance configuration # -############################################################################ - -#>> For the instance of uk.ac.shef.dcs.websearch.bing.v2.BingSearch -#This is the API key to be used with BingSearch. You should apply for your own at: https://datamarket.azure.com/dataset/bing/searchweb (Bing Search API, Web Results Only) -bing.keys=bryJj2e+op4vItDhWpPZM6/Cosmvq8OWVfMKBSHU9XQ= -#Default URL to access Bing Search API (Web Results Only) + +################################# +# GENERIC VARIABLE # +################################# + +#What class should be use to do web search (used in subject column detection for computing the ws score). It must extend uk.ac.shef.dcs.websearch.WebSearch and uk.ac.shef.dcs.kbsearch.KBSearchFactory must be revised to instantiate it by reflection. +web.search.class=uk.ac.shef.dcs.websearch.bing.v2.BingSearch + + +############################################################################ +# Specific k.ac.shef.dcs.websearch.WebSearch instance configuration # +############################################################################ + +#>> For the instance of uk.ac.shef.dcs.websearch.bing.v2.BingSearch +#This is the API key to be used with BingSearch. You should apply for your own at: https://datamarket.azure.com/dataset/bing/searchweb (Bing Search API, Web Results Only) +bing.keys=bryJj2e+op4vItDhWpPZM6/Cosmvq8OWVfMKBSHU9XQ= +#Default URL to access Bing Search API (Web Results Only) bing.url=https://api.datamarket.azure.com/Bing/SearchWeb/v1/Web?Query= \ No newline at end of file diff --git a/configs/Jan/kbsearch.properties b/configs/Jan/kbsearch.properties index 54c1ff29..b5f8bde4 100644 --- a/configs/Jan/kbsearch.properties +++ b/configs/Jan/kbsearch.properties @@ -1,40 +1,40 @@ -##################################### -# GENERIC VARIABLE # -##################################### -# A file (MUST BE ABSOLUTE PATH) that lists things (e.g., predicate URIs) to be used by an instance of uk.ac.shef.dcs.kbsearch.KBSearchResultFilter, which decides what triples/relations/classes to remove. Specific rules are implemented by subclasses of uk.ac.shef.dcs.kbsearch.KBSearchResultFilter, which should be instantiated as part of uk.ac.shef.dcs.kbsearch.KBSearch. Details of how the stoplist is used can be found in the kbstoplist.txt documentation -#kb.search.result.stoplistfile=/Users/-/work/sti/resources/kbstoplist.txt -kb.search.result.stoplistfile=d:\\Documents\\Odalic\\Sti\\resources\\kbstoplist_dbpedia.txt - -# Name of the implementation class of uk.ac.shef.dcs.kbsearch.KBSearch. This is responsible for querying the knowledge base -#kb.search.class=uk.ac.shef.dcs.kbsearch.freebase.FreebaseSearch -kb.search.class=uk.ac.shef.dcs.kbsearch.sparql.DBpediaSearch -# If a query keyword does not match to anything in a KB, you can try splitting if it contains conjunctive word "and","or". set to true if you want this -kb.search.tryfuzzykeyword=true - - -################################################################ -# Specific instance of uk.ac.shef.dcs.kbsearch.KBSearch # -################################################################ - -#>> An instance of uk.ac.shef.dcs.kbsearch.freebase.FreebaseSearch, uses Freebase API -# max number of queries allowed per second -fb.query.max.sec=10 -# max number of queries allowed per day -fb.query.max.day=100000 -# freebase api key. YOU SHOULD USE YOUR OWN -fb.query.api.key=AIzaSyAcL9jlS9czJrT0OLlWH24Od0mYrsycnSk -# access URL for the freebase mql api -fb.query.apiurl.mql=https://www.googleapis.com/freebase/v1/mqlread -# access URL for the freebase topic api -fb.query.apiurl.topic=https://www.googleapis.com/freebase/v1/topic -# access URL for the freebase search api -fb.query.apiurl.search=https://www.googleapis.com/freebase/v1/search -# freebase homepage -fb.homepage= -# number of results to obtain in the freebase query -fb.query.param.limit=1000 - - -dbp.sparql.endpoint=http://dbpedia.org/sparql -dbp.ontology.url=file:///d:/Documents/Odalic/Sti/resources/dbpedia_ontology_2014.owl - +##################################### +# GENERIC VARIABLE # +##################################### +# A file (MUST BE ABSOLUTE PATH) that lists things (e.g., predicate URIs) to be used by an instance of uk.ac.shef.dcs.kbsearch.KBSearchResultFilter, which decides what triples/relations/classes to remove. Specific rules are implemented by subclasses of uk.ac.shef.dcs.kbsearch.KBSearchResultFilter, which should be instantiated as part of uk.ac.shef.dcs.kbsearch.KBSearch. Details of how the stoplist is used can be found in the kbstoplist.txt documentation +#kb.search.result.stoplistfile=/Users/-/work/sti/resources/kbstoplist.txt +kb.search.result.stoplistfile=d:\\Documents\\Odalic\\Sti\\resources\\kbstoplist_dbpedia.txt + +# Name of the implementation class of uk.ac.shef.dcs.kbsearch.KBSearch. This is responsible for querying the knowledge base +#kb.search.class=uk.ac.shef.dcs.kbsearch.freebase.FreebaseSearch +kb.search.class=uk.ac.shef.dcs.kbsearch.sparql.DBpediaSearch +# If a query keyword does not match to anything in a KB, you can try splitting if it contains conjunctive word "and","or". set to true if you want this +kb.search.tryfuzzykeyword=true + + +################################################################ +# Specific instance of uk.ac.shef.dcs.kbsearch.KBSearch # +################################################################ + +#>> An instance of uk.ac.shef.dcs.kbsearch.freebase.FreebaseSearch, uses Freebase API +# max number of queries allowed per second +fb.query.max.sec=10 +# max number of queries allowed per day +fb.query.max.day=100000 +# freebase api key. YOU SHOULD USE YOUR OWN +fb.query.api.key=AIzaSyAcL9jlS9czJrT0OLlWH24Od0mYrsycnSk +# access URL for the freebase mql api +fb.query.apiurl.mql=https://www.googleapis.com/freebase/v1/mqlread +# access URL for the freebase topic api +fb.query.apiurl.topic=https://www.googleapis.com/freebase/v1/topic +# access URL for the freebase search api +fb.query.apiurl.search=https://www.googleapis.com/freebase/v1/search +# freebase homepage +fb.homepage= +# number of results to obtain in the freebase query +fb.query.param.limit=1000 + + +dbp.sparql.endpoint=http://dbpedia.org/sparql +dbp.ontology.url=file:///d:/Documents/Odalic/Sti/resources/dbpedia_ontology_2014.owl + diff --git a/configs/Jan/sti.properties b/configs/Jan/sti.properties index 040a0949..5d8980c7 100644 --- a/configs/Jan/sti.properties +++ b/configs/Jan/sti.properties @@ -1,119 +1,119 @@ -#################### -# FILE PATHS # -#################### -# STI home folder. All other file paths wil be relative to this (except otherwise stated). -sti.home=d:\\Documents\\Odalic\\Sti\\ -# Folder containing nlp resources (by default this is the '/resource' folder in the distribution) -sti.nlp=resources -# Folder containing cached data (must be ABSOLUTE PATH). Whenever KB search or Web search is performed, the query and results are cached in a Solr instance. This specifies the path to Solr. (by default this is the /cache/empty folder in the distribution. The folder contains only solr schemas, but no data. This means you can use them directly as long as you correct the path. And the system will begin with remotely querying KB or the Web and gradually builds up the cache). -sti.cache.main.dir=d:\\Documents\\Odalic\\Sti\\cache\\empty\\ -# Web search configuration file. By default this is located in the home folder of the distribution -sti.websearch.properties=configs\\Jan\\websearch.properties -# KB search configuration file. By default this is located in the home folder of the distribution -sti.kbsearch.propertyfile=configs\\Jan\\kbsearch.properties -# When STI is run in batch mode (e.g., processing a folder containing multiple input files, by using an instance of uk.ac.shef.dcs.sti.experiment.STIBatch), it loads in all files and sort them by file name. If for any input file the process failed due to any exception, the indexes of such files (as index of the file in the sorted list) are written to this provided file. -sti.list.failure=failed.txt -# Input files must be parsed to create an internal uk.ac.shef.dcs.sti.core.model.Table objects. Depending on the input data files, specific TableParser class must be implemented and specified here. The class must have a defult constructor that does not take any arguments -sti.input.parser.class=uk.ac.shef.dcs.sti.parser.table.TableParserLimayeDataset - - -#################################### -# SELECTIVE START (generic) # -#################################### -# STI tries to classify the data type of table columns, and typically only certain types of columns are passed for interpretation. While this process is highly accurate, it is not guaranteed to be perfect so in some occassions it is possible to have, e.g., NE-columns mis-classified as numeric, or long text. Therefore, for all input tables, if you know some columns should not be considered for interpretation, specify them here as a comma delimieted string. E.g, '0,1,5' will tell STI to ignore the first, 2nd and 6th columns in input tables. -sti.columns.ignore= -# Similar as the above, if you know some columns must be analyzed, you can provide their index here -sti.columns.mustdo= - - -################################ -# SELECTIVE START (batch) # -################################ -# when running in batch mode, instead of always processing the entire input folder, starting from the first file, it is possible to make the process selective by defining the following parameters - -# Given the input files read from a folder sorted by their file names, you can choose to start from a particular index position in the sorted list. The first file's index is 0. This is useful when, e.g., the previously process broke down and you want to continue from a particular position. The index position of each processed input file will be output in the log file -sti.start=0 -# Similar as above, you can provide a list of indexes representing the files you want to process. Note that if this variable is defined, ONLY THESE SPECIFIED files will be processed. This variable must be an absolute file path pointing to a plain text file, where each line is the index of a file in the sorted input folder. Leave this variable empty if you do not want to be selective -sti.list.select= - - -################################################ -# Subject column detection, the ws scorer # -################################################ - -# Whether STI should use the ws score in detecting subject column -sti.subjectcolumndetection.ws=true -# If ws is used, what stopping criteria class should be used -sti.iinf.websearch.stopping.class=uk.ac.shef.dcs.sti.core.algorithm.tmp.stopping.IInf -# if ws is used, for the stopping criteria class provided above, also provide its contructor parameters in the order it is defined in the class, delimited by , -sti.iinf.websearch.stopping.class.constructor.params=0.0,1,0.01 - - -######################## -# RELATION ENUMERATION # -######################## -# Choose whether or not STI should annotate relations -sti.learning.relation=true - -########## -# OUTPUT # -########## - -# What is the namespace that the KB uses -sti.output.triple.namespace.kb=www.freebase.org -# What is the namespace to use for newly extracted classes, relations and entities that are not available in the KB -sti.output.triple.namespace.default=www.shef.ac.uk - - - - - - -############################################################# -# TABLEMINER+: LEARNING (only needed if you run tableminer+ # -############################################################# -# What stopping criteria class should be used in the iinf for preliminary column classification -sti.tmp.iinf.learning.stopping.class=uk.ac.shef.dcs.sti.core.algorithm.tmp.stopping.IInf -# for the stopping criteria class provided above, also provide its contructor parameters in the order it is defined in the class values separated by , -sti.tmp.iinf.learning.stopping.class.constructor.params=0.0,1,0.05 - - - -############################################################# -# BASELINE: (only needed if you run baseline nm or sim) # -############################################################# -# what baseline method to use. Two options: nm=name match; sim=string similarity based -sti.baseline.method=sim -# if string similarity based baseline is used, define what string similarity metric to be used. This must be the name of the method of class org.simmetrics.metrics.StringMetrics (simmetrics library), which you want to call and obtain an instance of StringMetric -sti.baseline.similarity.stringmetrics.method=levenshtein - - - -############################################################# -# SEMANTIC MESSAGE PASSING: (only needed if you run smp) # -############################################################# -# whether smp should use tableminer+ subject column detection and use the information of subejct column in interpretation -sti.smp.usesubjectcolumn=false -# the choice of entity ranker to use. Two options: tmp to use the cell disambiguation method proposed by tableminer+; smpfreebase to use the method adapted from the original smp algorithm to Freebase -sti.smp.entityranker=smpfreebase -# maximum number of iterations in the semantic message passing phase. default is 10 if not provided -sti.smp.halting.maxiteration=10 -# when smp computes changemessages, it will check the score assigned to the annotations of the cell, column or relation. If the score is less than this threshold, it is considered 'unstable' and therefore a changemessage is created to indicate that in the next iteration, this cell/column/relation's annotation should be changed -sti.smp.changemessage.minscore=0.5 -# an implementation class of uk.ac.shef.dcs.sti.core.algorithm.smp.ClazzSpecificityCalculator, which should compute the specificity score of a class from the KB. This class will be created via reflection, so if new implementing classes are created, you must revise uk.ac.shef.dcs.sti.experiment.SemanticMessagePassingBatch getClazzSpecificityCalculator() method that is responsible for instance creation accordingly -sti.smp.clazzspecificitycalculator=uk.ac.shef.dcs.sti.core.algorithm.smp.FreebaseClazzSpecificityCalculator - - - - -############################################################# -# JOINT INFERENCE: (only needed if you run ji) # -############################################################# -# whether smp should use tableminer+ subject column detection and use the information of subejct column in interpretation -sti.ji.usesubjectcolumn=false -# the maximum number of iterations of joint inference. If set to 0, inference will continue until convergence (if possible) -sti.ji.maxiterations=0 -# if true additional procedure will be performed to check the consistency of the created factor graph and output additional logs -sti.ji.debugmode=false -# an implementation class of uk.ac.shef.dcs.sti.core.algorithm.smp.ClazzSpecificityCalculator, which should compute the specificity score of a class from the KB. This class will be created via reflection, so if new implementing classes are created, you must revise uk.ac.shef.dcs.sti.experiment.SemanticMessagePassingBatch getClazzSpecificityCalculator() method that is responsible for instance creation accordingly -sti.ji.clazzspecificitycalculator=uk.ac.shef.dcs.sti.core.algorithm.smp.FreebaseClazzSpecificityCalculator +#################### +# FILE PATHS # +#################### +# STI home folder. All other file paths wil be relative to this (except otherwise stated). +sti.home=d:\\Documents\\Odalic\\Sti\\ +# Folder containing nlp resources (by default this is the '/resource' folder in the distribution) +sti.nlp=resources +# Folder containing cached data (must be ABSOLUTE PATH). Whenever KB search or Web search is performed, the query and results are cached in a Solr instance. This specifies the path to Solr. (by default this is the /cache/empty folder in the distribution. The folder contains only solr schemas, but no data. This means you can use them directly as long as you correct the path. And the system will begin with remotely querying KB or the Web and gradually builds up the cache). +sti.cache.main.dir=d:\\Documents\\Odalic\\Sti\\cache\\empty\\ +# Web search configuration file. By default this is located in the home folder of the distribution +sti.websearch.properties=configs\\Jan\\websearch.properties +# KB search configuration file. By default this is located in the home folder of the distribution +sti.kbsearch.propertyfile=configs\\Jan\\kbsearch.properties +# When STI is run in batch mode (e.g., processing a folder containing multiple input files, by using an instance of uk.ac.shef.dcs.sti.experiment.STIBatch), it loads in all files and sort them by file name. If for any input file the process failed due to any exception, the indexes of such files (as index of the file in the sorted list) are written to this provided file. +sti.list.failure=failed.txt +# Input files must be parsed to create an internal uk.ac.shef.dcs.sti.core.model.Table objects. Depending on the input data files, specific TableParser class must be implemented and specified here. The class must have a defult constructor that does not take any arguments +sti.input.parser.class=uk.ac.shef.dcs.sti.parser.table.TableParserLimayeDataset + + +#################################### +# SELECTIVE START (generic) # +#################################### +# STI tries to classify the data type of table columns, and typically only certain types of columns are passed for interpretation. While this process is highly accurate, it is not guaranteed to be perfect so in some occassions it is possible to have, e.g., NE-columns mis-classified as numeric, or long text. Therefore, for all input tables, if you know some columns should not be considered for interpretation, specify them here as a comma delimieted string. E.g, '0,1,5' will tell STI to ignore the first, 2nd and 6th columns in input tables. +sti.columns.ignore= +# Similar as the above, if you know some columns must be analyzed, you can provide their index here +sti.columns.mustdo= + + +################################ +# SELECTIVE START (batch) # +################################ +# when running in batch mode, instead of always processing the entire input folder, starting from the first file, it is possible to make the process selective by defining the following parameters + +# Given the input files read from a folder sorted by their file names, you can choose to start from a particular index position in the sorted list. The first file's index is 0. This is useful when, e.g., the previously process broke down and you want to continue from a particular position. The index position of each processed input file will be output in the log file +sti.start=0 +# Similar as above, you can provide a list of indexes representing the files you want to process. Note that if this variable is defined, ONLY THESE SPECIFIED files will be processed. This variable must be an absolute file path pointing to a plain text file, where each line is the index of a file in the sorted input folder. Leave this variable empty if you do not want to be selective +sti.list.select= + + +################################################ +# Subject column detection, the ws scorer # +################################################ + +# Whether STI should use the ws score in detecting subject column +sti.subjectcolumndetection.ws=true +# If ws is used, what stopping criteria class should be used +sti.iinf.websearch.stopping.class=uk.ac.shef.dcs.sti.core.algorithm.tmp.stopping.IInf +# if ws is used, for the stopping criteria class provided above, also provide its contructor parameters in the order it is defined in the class, delimited by , +sti.iinf.websearch.stopping.class.constructor.params=0.0,1,0.01 + + +######################## +# RELATION ENUMERATION # +######################## +# Choose whether or not STI should annotate relations +sti.learning.relation=true + +########## +# OUTPUT # +########## + +# What is the namespace that the KB uses +sti.output.triple.namespace.kb=www.freebase.org +# What is the namespace to use for newly extracted classes, relations and entities that are not available in the KB +sti.output.triple.namespace.default=www.shef.ac.uk + + + + + + +############################################################# +# TABLEMINER+: LEARNING (only needed if you run tableminer+ # +############################################################# +# What stopping criteria class should be used in the iinf for preliminary column classification +sti.tmp.iinf.learning.stopping.class=uk.ac.shef.dcs.sti.core.algorithm.tmp.stopping.IInf +# for the stopping criteria class provided above, also provide its contructor parameters in the order it is defined in the class values separated by , +sti.tmp.iinf.learning.stopping.class.constructor.params=0.0,1,0.05 + + + +############################################################# +# BASELINE: (only needed if you run baseline nm or sim) # +############################################################# +# what baseline method to use. Two options: nm=name match; sim=string similarity based +sti.baseline.method=sim +# if string similarity based baseline is used, define what string similarity metric to be used. This must be the name of the method of class org.simmetrics.metrics.StringMetrics (simmetrics library), which you want to call and obtain an instance of StringMetric +sti.baseline.similarity.stringmetrics.method=levenshtein + + + +############################################################# +# SEMANTIC MESSAGE PASSING: (only needed if you run smp) # +############################################################# +# whether smp should use tableminer+ subject column detection and use the information of subejct column in interpretation +sti.smp.usesubjectcolumn=false +# the choice of entity ranker to use. Two options: tmp to use the cell disambiguation method proposed by tableminer+; smpfreebase to use the method adapted from the original smp algorithm to Freebase +sti.smp.entityranker=smpfreebase +# maximum number of iterations in the semantic message passing phase. default is 10 if not provided +sti.smp.halting.maxiteration=10 +# when smp computes changemessages, it will check the score assigned to the annotations of the cell, column or relation. If the score is less than this threshold, it is considered 'unstable' and therefore a changemessage is created to indicate that in the next iteration, this cell/column/relation's annotation should be changed +sti.smp.changemessage.minscore=0.5 +# an implementation class of uk.ac.shef.dcs.sti.core.algorithm.smp.ClazzSpecificityCalculator, which should compute the specificity score of a class from the KB. This class will be created via reflection, so if new implementing classes are created, you must revise uk.ac.shef.dcs.sti.experiment.SemanticMessagePassingBatch getClazzSpecificityCalculator() method that is responsible for instance creation accordingly +sti.smp.clazzspecificitycalculator=uk.ac.shef.dcs.sti.core.algorithm.smp.FreebaseClazzSpecificityCalculator + + + + +############################################################# +# JOINT INFERENCE: (only needed if you run ji) # +############################################################# +# whether smp should use tableminer+ subject column detection and use the information of subejct column in interpretation +sti.ji.usesubjectcolumn=false +# the maximum number of iterations of joint inference. If set to 0, inference will continue until convergence (if possible) +sti.ji.maxiterations=0 +# if true additional procedure will be performed to check the consistency of the created factor graph and output additional logs +sti.ji.debugmode=false +# an implementation class of uk.ac.shef.dcs.sti.core.algorithm.smp.ClazzSpecificityCalculator, which should compute the specificity score of a class from the KB. This class will be created via reflection, so if new implementing classes are created, you must revise uk.ac.shef.dcs.sti.experiment.SemanticMessagePassingBatch getClazzSpecificityCalculator() method that is responsible for instance creation accordingly +sti.ji.clazzspecificitycalculator=uk.ac.shef.dcs.sti.core.algorithm.smp.FreebaseClazzSpecificityCalculator diff --git a/configs/Jan/websearch.properties b/configs/Jan/websearch.properties index 40deea58..2b435f43 100644 --- a/configs/Jan/websearch.properties +++ b/configs/Jan/websearch.properties @@ -1,18 +1,18 @@ - -################################# -# GENERIC VARIABLE # -################################# - -#What class should be use to do web search (used in subject column detection for computing the ws score). It must extend uk.ac.shef.dcs.websearch.WebSearch and uk.ac.shef.dcs.kbsearch.KBSearchFactory must be revised to instantiate it by reflection. -web.search.class=uk.ac.shef.dcs.websearch.bing.v2.BingSearch - - -############################################################################ -# Specific k.ac.shef.dcs.websearch.WebSearch instance configuration # -############################################################################ - -#>> For the instance of uk.ac.shef.dcs.websearch.bing.v2.BingSearch -#This is the API key to be used with BingSearch. You should apply for your own at: https://datamarket.azure.com/dataset/bing/searchweb (Bing Search API, Web Results Only) -bing.keys=I9K1ihpDVkrmX8w2SN08NS5kMZPTDvTi/St9yfl9vVQ -#Default URL to access Bing Search API (Web Results Only) + +################################# +# GENERIC VARIABLE # +################################# + +#What class should be use to do web search (used in subject column detection for computing the ws score). It must extend uk.ac.shef.dcs.websearch.WebSearch and uk.ac.shef.dcs.kbsearch.KBSearchFactory must be revised to instantiate it by reflection. +web.search.class=uk.ac.shef.dcs.websearch.bing.v2.BingSearch + + +############################################################################ +# Specific k.ac.shef.dcs.websearch.WebSearch instance configuration # +############################################################################ + +#>> For the instance of uk.ac.shef.dcs.websearch.bing.v2.BingSearch +#This is the API key to be used with BingSearch. You should apply for your own at: https://datamarket.azure.com/dataset/bing/searchweb (Bing Search API, Web Results Only) +bing.keys=I9K1ihpDVkrmX8w2SN08NS5kMZPTDvTi/St9yfl9vVQ +#Default URL to access Bing Search API (Web Results Only) bing.url=https://api.datamarket.azure.com/Bing/SearchWeb/v1/Web?Query= \ No newline at end of file diff --git a/demo/README.md b/demo/README.md index bf1c10bb..509d24b9 100644 --- a/demo/README.md +++ b/demo/README.md @@ -1,4 +1,4 @@ -Please visit -http://staffwww.dcs.shef.ac.uk/people/Z.Zhang/resources/ISWC_tableminer.mov - +Please visit +http://staffwww.dcs.shef.ac.uk/people/Z.Zhang/resources/ISWC_tableminer.mov + for the HD video of the demo. \ No newline at end of file diff --git a/mvninstall.bat b/mvninstall.bat index dbe674be..90647741 100644 --- a/mvninstall.bat +++ b/mvninstall.bat @@ -1,2 +1,2 @@ -call mvn install:install-file -DgroupId=edu.drexel -DartifactId=dragontool -Dversion=1.3.3 -Dpackaging=jar -Dfile=libs/dragontool.jar -call mvn install:install-file -DgroupId=com.github.mpkorstanje -DartifactId=simmetrics -Dversion=4.1.0L -Dpackaging=jar -Dfile=libs/simmetrics.jar +call mvn install:install-file -DgroupId=edu.drexel -DartifactId=dragontool -Dversion=1.3.3 -Dpackaging=jar -Dfile=libs/dragontool.jar +call mvn install:install-file -DgroupId=com.github.mpkorstanje -DartifactId=simmetrics -Dversion=4.1.0L -Dpackaging=jar -Dfile=libs/simmetrics.jar diff --git a/odalic/.gitignore b/odalic/.gitignore index e8734ea4..59ddbdbb 100644 --- a/odalic/.gitignore +++ b/odalic/.gitignore @@ -1,2 +1,2 @@ -/.apt_generated/ +/.apt_generated/ /Users \ No newline at end of file diff --git a/odalic/pom.xml b/odalic/pom.xml index 6107ed43..f225a558 100644 --- a/odalic/pom.xml +++ b/odalic/pom.xml @@ -1,165 +1,165 @@ - - 4.0.0 - cz.cuni.mff.odalic - odalic - 0.0.1-SNAPSHOT - war - Odalic - Odalic server - - - 1.8 - 1.7.21 - 2.23.1 - 1.1.7 - 4.3.0.RELEASE - - - - - Apache 2.0 - http://www.apache.org/licenses/LICENSE-2.0 - - - - - - maven2-repository.java.net - Java.net Repository for Maven - http://download.java.net/maven/2/ - - - - - - - uk.ac.shef.dcs - sti-main - 1.0alpha - - - guava-jdk5 - com.google.guava - - - - - - - com.google.guava - guava - 19.0 - - - - - org.glassfish.jersey.ext - jersey-spring3 - ${jersey.version} - - - org.springframework - spring-core - - - org.springframework - spring-web - - - org.springframework - spring-beans - - - - - org.glassfish.jersey.media - jersey-media-json-jackson - ${jersey.version} - - - org.glassfish.jersey.media - jersey-media-multipart - ${jersey.version} - - - org.glassfish.jersey.ext - jersey-entity-filtering - ${jersey.version} - - - - - org.springframework - spring-core - ${spring.version} - - - org.springframework - spring-context - ${spring.version} - - - commons-logging - commons-logging - - - - - org.springframework - spring-web - ${spring.version} - - - org.springframework - spring-tx - ${spring.version} - - - org.springframework - spring-aspects - ${spring.version} - - - - - ch.qos.logback - logback-classic - ${logback.version} - - - org.slf4j - jcl-over-slf4j - ${jcloverslf4j.version} - - - - - javax.ws.rs - jsr311-api - 1.1.1 - - - - - org.apache.commons - commons-csv - 1.4 - - - - - - - true - org.apache.maven.plugins - maven-compiler-plugin - - ${java.version} - ${java.version} - UTF-8 - - - - + + 4.0.0 + cz.cuni.mff.odalic + odalic + 0.0.1-SNAPSHOT + war + Odalic + Odalic server + + + 1.8 + 1.7.21 + 2.23.1 + 1.1.7 + 4.3.0.RELEASE + + + + + Apache 2.0 + http://www.apache.org/licenses/LICENSE-2.0 + + + + + + maven2-repository.java.net + Java.net Repository for Maven + http://download.java.net/maven/2/ + + + + + + + uk.ac.shef.dcs + sti-main + 1.0alpha + + + guava-jdk5 + com.google.guava + + + + + + + com.google.guava + guava + 19.0 + + + + + org.glassfish.jersey.ext + jersey-spring3 + ${jersey.version} + + + org.springframework + spring-core + + + org.springframework + spring-web + + + org.springframework + spring-beans + + + + + org.glassfish.jersey.media + jersey-media-json-jackson + ${jersey.version} + + + org.glassfish.jersey.media + jersey-media-multipart + ${jersey.version} + + + org.glassfish.jersey.ext + jersey-entity-filtering + ${jersey.version} + + + + + org.springframework + spring-core + ${spring.version} + + + org.springframework + spring-context + ${spring.version} + + + commons-logging + commons-logging + + + + + org.springframework + spring-web + ${spring.version} + + + org.springframework + spring-tx + ${spring.version} + + + org.springframework + spring-aspects + ${spring.version} + + + + + ch.qos.logback + logback-classic + ${logback.version} + + + org.slf4j + jcl-over-slf4j + ${jcloverslf4j.version} + + + + + javax.ws.rs + jsr311-api + 1.1.1 + + + + + org.apache.commons + commons-csv + 1.4 + + + + + + + true + org.apache.maven.plugins + maven-compiler-plugin + + ${java.version} + ${java.version} + UTF-8 + + + + \ No newline at end of file diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java index c5bcda67..12c333e3 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/Configuration.java @@ -1,53 +1,53 @@ -/** - * - */ -package cz.cuni.mff.xrg.odalic.api.rest; - -import javax.xml.bind.JAXBException; -import org.glassfish.jersey.jackson.JacksonFeature; -import org.glassfish.jersey.media.multipart.MultiPartFeature; -import org.glassfish.jersey.server.ResourceConfig; -import org.glassfish.jersey.server.spring.scope.RequestContextFilter; -import cz.cuni.mff.xrg.odalic.api.rest.errors.ThrowableMapper; -import cz.cuni.mff.xrg.odalic.api.rest.filters.CorsResponseFilter; -import cz.cuni.mff.xrg.odalic.api.rest.filters.LoggingResponseFilter; -import cz.cuni.mff.xrg.odalic.api.rest.resources.ConfigurationResource; -import cz.cuni.mff.xrg.odalic.api.rest.resources.ExecutionResource; -import cz.cuni.mff.xrg.odalic.api.rest.resources.FeedbackResource; -import cz.cuni.mff.xrg.odalic.api.rest.resources.FileResource; -import cz.cuni.mff.xrg.odalic.api.rest.resources.ResultResource; -import cz.cuni.mff.xrg.odalic.api.rest.resources.StateResource; -import cz.cuni.mff.xrg.odalic.api.rest.resources.TaskResource; - -/** - * Configures the provided resources, filters, mappers and features. - * - * @author Václav Brodec - * - * @see org.glassfish.jersey.server.ResourceConfig - */ -public final class Configuration extends ResourceConfig { - - public Configuration() throws JAXBException { - // Resources registration - register(FileResource.class); - register(TaskResource.class); - register(ConfigurationResource.class); - register(FeedbackResource.class); - register(ExecutionResource.class); - register(ResultResource.class); - register(StateResource.class); - - // Filters registration - register(RequestContextFilter.class); - register(LoggingResponseFilter.class); - register(CorsResponseFilter.class); - - // Exception mappers registration - register(ThrowableMapper.class); - - // Features registration - register(JacksonFeature.class); - register(MultiPartFeature.class); - } -} +/** + * + */ +package cz.cuni.mff.xrg.odalic.api.rest; + +import javax.xml.bind.JAXBException; +import org.glassfish.jersey.jackson.JacksonFeature; +import org.glassfish.jersey.media.multipart.MultiPartFeature; +import org.glassfish.jersey.server.ResourceConfig; +import org.glassfish.jersey.server.spring.scope.RequestContextFilter; +import cz.cuni.mff.xrg.odalic.api.rest.errors.ThrowableMapper; +import cz.cuni.mff.xrg.odalic.api.rest.filters.CorsResponseFilter; +import cz.cuni.mff.xrg.odalic.api.rest.filters.LoggingResponseFilter; +import cz.cuni.mff.xrg.odalic.api.rest.resources.ConfigurationResource; +import cz.cuni.mff.xrg.odalic.api.rest.resources.ExecutionResource; +import cz.cuni.mff.xrg.odalic.api.rest.resources.FeedbackResource; +import cz.cuni.mff.xrg.odalic.api.rest.resources.FileResource; +import cz.cuni.mff.xrg.odalic.api.rest.resources.ResultResource; +import cz.cuni.mff.xrg.odalic.api.rest.resources.StateResource; +import cz.cuni.mff.xrg.odalic.api.rest.resources.TaskResource; + +/** + * Configures the provided resources, filters, mappers and features. + * + * @author Václav Brodec + * + * @see org.glassfish.jersey.server.ResourceConfig + */ +public final class Configuration extends ResourceConfig { + + public Configuration() throws JAXBException { + // Resources registration + register(FileResource.class); + register(TaskResource.class); + register(ConfigurationResource.class); + register(FeedbackResource.class); + register(ExecutionResource.class); + register(ResultResource.class); + register(StateResource.class); + + // Filters registration + register(RequestContextFilter.class); + register(LoggingResponseFilter.class); + register(CorsResponseFilter.class); + + // Exception mappers registration + register(ThrowableMapper.class); + + // Features registration + register(JacksonFeature.class); + register(MultiPartFeature.class); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/AmbiguityAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/AmbiguityAdapter.java index 8ebfce5a..0540f95b 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/AmbiguityAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/AmbiguityAdapter.java @@ -1,23 +1,23 @@ -package cz.cuni.mff.xrg.odalic.api.rest.adapters; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -import cz.cuni.mff.xrg.odalic.api.rest.values.AmbiguityValue; -import cz.cuni.mff.xrg.odalic.feedbacks.Ambiguity; - - -public final class AmbiguityAdapter - extends XmlAdapter { - - @Override - public AmbiguityValue marshal(Ambiguity bound) - throws Exception { - return new AmbiguityValue(bound); - } - - @Override - public Ambiguity unmarshal(AmbiguityValue value) - throws Exception { - return new Ambiguity(value.getPosition()); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.AmbiguityValue; +import cz.cuni.mff.xrg.odalic.feedbacks.Ambiguity; + + +public final class AmbiguityAdapter + extends XmlAdapter { + + @Override + public AmbiguityValue marshal(Ambiguity bound) + throws Exception { + return new AmbiguityValue(bound); + } + + @Override + public Ambiguity unmarshal(AmbiguityValue value) + throws Exception { + return new Ambiguity(value.getPosition()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellAnnotationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellAnnotationAdapter.java index 2152df1b..ab428992 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellAnnotationAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellAnnotationAdapter.java @@ -1,47 +1,47 @@ -package cz.cuni.mff.xrg.odalic.api.rest.adapters; - -import java.util.Map; -import java.util.NavigableSet; -import java.util.Set; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSortedSet; - -import cz.cuni.mff.xrg.odalic.api.rest.values.CellAnnotationValue; -import cz.cuni.mff.xrg.odalic.api.rest.values.EntityCandidateValue; -import cz.cuni.mff.xrg.odalic.tasks.annotations.CellAnnotation; -import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; -import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; - - -public final class CellAnnotationAdapter extends XmlAdapter { - - @Override - public CellAnnotationValue marshal(CellAnnotation bound) throws Exception { - return new CellAnnotationValue(bound); - } - - @Override - public CellAnnotation unmarshal(CellAnnotationValue value) throws Exception { - final ImmutableMap.Builder> candidatesBuilder = - ImmutableMap.builder(); - final ImmutableMap.Builder> chosenBuilder = - ImmutableMap.builder(); - for (final Map.Entry> entry : value - .getCandidates().entrySet()) { - final KnowledgeBase base = entry.getKey(); - final Set values = entry.getValue(); - - candidatesBuilder.put(base, ImmutableSortedSet.copyOf(values.stream() - .map(e -> new EntityCandidate(e.getEntity(), e.getLikelihood())).iterator())); - chosenBuilder.put(base, ImmutableSet.copyOf(values.stream().filter(e -> e.isChosen()) - .map(e -> new EntityCandidate(e.getEntity(), e.getLikelihood())).iterator())); - } - - return new CellAnnotation(candidatesBuilder.build(), chosenBuilder.build()); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import java.util.Map; +import java.util.NavigableSet; +import java.util.Set; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSortedSet; + +import cz.cuni.mff.xrg.odalic.api.rest.values.CellAnnotationValue; +import cz.cuni.mff.xrg.odalic.api.rest.values.EntityCandidateValue; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; + + +public final class CellAnnotationAdapter extends XmlAdapter { + + @Override + public CellAnnotationValue marshal(CellAnnotation bound) throws Exception { + return new CellAnnotationValue(bound); + } + + @Override + public CellAnnotation unmarshal(CellAnnotationValue value) throws Exception { + final ImmutableMap.Builder> candidatesBuilder = + ImmutableMap.builder(); + final ImmutableMap.Builder> chosenBuilder = + ImmutableMap.builder(); + for (final Map.Entry> entry : value + .getCandidates().entrySet()) { + final KnowledgeBase base = entry.getKey(); + final Set values = entry.getValue(); + + candidatesBuilder.put(base, ImmutableSortedSet.copyOf(values.stream() + .map(e -> new EntityCandidate(e.getEntity(), e.getLikelihood())).iterator())); + chosenBuilder.put(base, ImmutableSet.copyOf(values.stream().filter(e -> e.isChosen()) + .map(e -> new EntityCandidate(e.getEntity(), e.getLikelihood())).iterator())); + } + + return new CellAnnotation(candidatesBuilder.build(), chosenBuilder.build()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellPositionAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellPositionAdapter.java index ae773add..0c6ad184 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellPositionAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellPositionAdapter.java @@ -1,23 +1,23 @@ -package cz.cuni.mff.xrg.odalic.api.rest.adapters; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -import cz.cuni.mff.xrg.odalic.api.rest.values.CellPositionValue; -import cz.cuni.mff.xrg.odalic.positions.CellPosition; - - -public final class CellPositionAdapter - extends XmlAdapter { - - @Override - public CellPositionValue marshal(CellPosition bound) - throws Exception { - return new CellPositionValue(bound); - } - - @Override - public CellPosition unmarshal(CellPositionValue value) - throws Exception { - return new CellPosition(value.getRowPosition(), value.getColumnPosition()); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.CellPositionValue; +import cz.cuni.mff.xrg.odalic.positions.CellPosition; + + +public final class CellPositionAdapter + extends XmlAdapter { + + @Override + public CellPositionValue marshal(CellPosition bound) + throws Exception { + return new CellPositionValue(bound); + } + + @Override + public CellPosition unmarshal(CellPositionValue value) + throws Exception { + return new CellPosition(value.getRowPosition(), value.getColumnPosition()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAdapter.java index a39048eb..91f583f6 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAdapter.java @@ -1,23 +1,23 @@ -package cz.cuni.mff.xrg.odalic.api.rest.adapters; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -import cz.cuni.mff.xrg.odalic.api.rest.values.CellRelationValue; -import cz.cuni.mff.xrg.odalic.feedbacks.CellRelation; - - -public final class CellRelationAdapter - extends XmlAdapter { - - @Override - public CellRelationValue marshal(CellRelation bound) - throws Exception { - return new CellRelationValue(bound); - } - - @Override - public CellRelation unmarshal(CellRelationValue value) - throws Exception { - return new CellRelation(value.getPosition(), value.getAnnotation()); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.CellRelationValue; +import cz.cuni.mff.xrg.odalic.feedbacks.CellRelation; + + +public final class CellRelationAdapter + extends XmlAdapter { + + @Override + public CellRelationValue marshal(CellRelation bound) + throws Exception { + return new CellRelationValue(bound); + } + + @Override + public CellRelation unmarshal(CellRelationValue value) + throws Exception { + return new CellRelation(value.getPosition(), value.getAnnotation()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAnnotationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAnnotationAdapter.java index 74abb4d4..dd8ab615 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAnnotationAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationAnnotationAdapter.java @@ -1,47 +1,47 @@ -package cz.cuni.mff.xrg.odalic.api.rest.adapters; - -import java.util.Map; -import java.util.NavigableSet; -import java.util.Set; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSortedSet; - -import cz.cuni.mff.xrg.odalic.api.rest.values.CellRelationAnnotationValue; -import cz.cuni.mff.xrg.odalic.api.rest.values.EntityCandidateValue; -import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; -import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; -import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; - - -public final class CellRelationAnnotationAdapter extends XmlAdapter { - - @Override - public CellRelationAnnotationValue marshal(CellRelationAnnotation bound) throws Exception { - return new CellRelationAnnotationValue(bound); - } - - @Override - public CellRelationAnnotation unmarshal(CellRelationAnnotationValue value) throws Exception { - final ImmutableMap.Builder> candidatesBuilder = - ImmutableMap.builder(); - final ImmutableMap.Builder> chosenBuilder = - ImmutableMap.builder(); - for (final Map.Entry> entry : value - .getCandidates().entrySet()) { - final KnowledgeBase base = entry.getKey(); - final Set values = entry.getValue(); - - candidatesBuilder.put(base, ImmutableSortedSet.copyOf(values.stream() - .map(e -> new EntityCandidate(e.getEntity(), e.getLikelihood())).iterator())); - chosenBuilder.put(base, ImmutableSet.copyOf(values.stream().filter(e -> e.isChosen()) - .map(e -> new EntityCandidate(e.getEntity(), e.getLikelihood())).iterator())); - } - - return new CellRelationAnnotation(candidatesBuilder.build(), chosenBuilder.build()); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import java.util.Map; +import java.util.NavigableSet; +import java.util.Set; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSortedSet; + +import cz.cuni.mff.xrg.odalic.api.rest.values.CellRelationAnnotationValue; +import cz.cuni.mff.xrg.odalic.api.rest.values.EntityCandidateValue; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; + + +public final class CellRelationAnnotationAdapter extends XmlAdapter { + + @Override + public CellRelationAnnotationValue marshal(CellRelationAnnotation bound) throws Exception { + return new CellRelationAnnotationValue(bound); + } + + @Override + public CellRelationAnnotation unmarshal(CellRelationAnnotationValue value) throws Exception { + final ImmutableMap.Builder> candidatesBuilder = + ImmutableMap.builder(); + final ImmutableMap.Builder> chosenBuilder = + ImmutableMap.builder(); + for (final Map.Entry> entry : value + .getCandidates().entrySet()) { + final KnowledgeBase base = entry.getKey(); + final Set values = entry.getValue(); + + candidatesBuilder.put(base, ImmutableSortedSet.copyOf(values.stream() + .map(e -> new EntityCandidate(e.getEntity(), e.getLikelihood())).iterator())); + chosenBuilder.put(base, ImmutableSet.copyOf(values.stream().filter(e -> e.isChosen()) + .map(e -> new EntityCandidate(e.getEntity(), e.getLikelihood())).iterator())); + } + + return new CellRelationAnnotation(candidatesBuilder.build(), chosenBuilder.build()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationPositionAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationPositionAdapter.java index 6d7a74ff..ee7da084 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationPositionAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/CellRelationPositionAdapter.java @@ -1,23 +1,23 @@ -package cz.cuni.mff.xrg.odalic.api.rest.adapters; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -import cz.cuni.mff.xrg.odalic.api.rest.values.CellRelationPositionValue; -import cz.cuni.mff.xrg.odalic.positions.CellRelationPosition; - - -public final class CellRelationPositionAdapter - extends XmlAdapter { - - @Override - public CellRelationPositionValue marshal(CellRelationPosition bound) - throws Exception { - return new CellRelationPositionValue(bound); - } - - @Override - public CellRelationPosition unmarshal(CellRelationPositionValue value) - throws Exception { - return new CellRelationPosition(value.getColumnsPosition(), value.getRowPosition()); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.CellRelationPositionValue; +import cz.cuni.mff.xrg.odalic.positions.CellRelationPosition; + + +public final class CellRelationPositionAdapter + extends XmlAdapter { + + @Override + public CellRelationPositionValue marshal(CellRelationPosition bound) + throws Exception { + return new CellRelationPositionValue(bound); + } + + @Override + public CellRelationPosition unmarshal(CellRelationPositionValue value) + throws Exception { + return new CellRelationPosition(value.getColumnsPosition(), value.getRowPosition()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ClassificationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ClassificationAdapter.java index 76a8892a..5b2be252 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ClassificationAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ClassificationAdapter.java @@ -1,23 +1,23 @@ -package cz.cuni.mff.xrg.odalic.api.rest.adapters; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -import cz.cuni.mff.xrg.odalic.api.rest.values.ClassificationValue; -import cz.cuni.mff.xrg.odalic.feedbacks.Classification; - - -public final class ClassificationAdapter - extends XmlAdapter { - - @Override - public ClassificationValue marshal(Classification bound) - throws Exception { - return new ClassificationValue(bound); - } - - @Override - public Classification unmarshal(ClassificationValue value) - throws Exception { - return new Classification(value.getPosition(), value.getAnnotation()); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.ClassificationValue; +import cz.cuni.mff.xrg.odalic.feedbacks.Classification; + + +public final class ClassificationAdapter + extends XmlAdapter { + + @Override + public ClassificationValue marshal(Classification bound) + throws Exception { + return new ClassificationValue(bound); + } + + @Override + public Classification unmarshal(ClassificationValue value) + throws Exception { + return new Classification(value.getPosition(), value.getAnnotation()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnAmbiguityAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnAmbiguityAdapter.java index 3fb388ea..3cbc75f1 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnAmbiguityAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnAmbiguityAdapter.java @@ -1,20 +1,20 @@ -package cz.cuni.mff.xrg.odalic.api.rest.adapters; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -import cz.cuni.mff.xrg.odalic.api.rest.values.ColumnAmbiguityValue; -import cz.cuni.mff.xrg.odalic.feedbacks.ColumnAmbiguity; - -public final class ColumnAmbiguityAdapter extends XmlAdapter { - - @Override - public ColumnAmbiguityValue marshal(ColumnAmbiguity bound) throws Exception { - return new ColumnAmbiguityValue(bound); - } - - @Override - public ColumnAmbiguity unmarshal(ColumnAmbiguityValue value) throws Exception { - return new ColumnAmbiguity(value.getPosition()); - } - -} +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.ColumnAmbiguityValue; +import cz.cuni.mff.xrg.odalic.feedbacks.ColumnAmbiguity; + +public final class ColumnAmbiguityAdapter extends XmlAdapter { + + @Override + public ColumnAmbiguityValue marshal(ColumnAmbiguity bound) throws Exception { + return new ColumnAmbiguityValue(bound); + } + + @Override + public ColumnAmbiguity unmarshal(ColumnAmbiguityValue value) throws Exception { + return new ColumnAmbiguity(value.getPosition()); + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnIgnoreAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnIgnoreAdapter.java index 4dca2317..75b87a99 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnIgnoreAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnIgnoreAdapter.java @@ -1,20 +1,20 @@ -package cz.cuni.mff.xrg.odalic.api.rest.adapters; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -import cz.cuni.mff.xrg.odalic.api.rest.values.ColumnIgnoreValue; -import cz.cuni.mff.xrg.odalic.feedbacks.ColumnIgnore; - -public final class ColumnIgnoreAdapter extends XmlAdapter { - - @Override - public ColumnIgnoreValue marshal(ColumnIgnore bound) throws Exception { - return new ColumnIgnoreValue(bound); - } - - @Override - public ColumnIgnore unmarshal(ColumnIgnoreValue value) throws Exception { - return new ColumnIgnore(value.getPosition()); - } - -} +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.ColumnIgnoreValue; +import cz.cuni.mff.xrg.odalic.feedbacks.ColumnIgnore; + +public final class ColumnIgnoreAdapter extends XmlAdapter { + + @Override + public ColumnIgnoreValue marshal(ColumnIgnore bound) throws Exception { + return new ColumnIgnoreValue(bound); + } + + @Override + public ColumnIgnore unmarshal(ColumnIgnoreValue value) throws Exception { + return new ColumnIgnore(value.getPosition()); + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnPositionAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnPositionAdapter.java index fcb2714c..a30bbd4e 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnPositionAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnPositionAdapter.java @@ -1,23 +1,23 @@ -package cz.cuni.mff.xrg.odalic.api.rest.adapters; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -import cz.cuni.mff.xrg.odalic.api.rest.values.ColumnPositionValue; -import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; - - -public final class ColumnPositionAdapter - extends XmlAdapter { - - @Override - public ColumnPositionValue marshal(ColumnPosition bound) - throws Exception { - return new ColumnPositionValue(bound); - } - - @Override - public ColumnPosition unmarshal(ColumnPositionValue value) - throws Exception { - return new ColumnPosition(value.getIndex()); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.ColumnPositionValue; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; + + +public final class ColumnPositionAdapter + extends XmlAdapter { + + @Override + public ColumnPositionValue marshal(ColumnPosition bound) + throws Exception { + return new ColumnPositionValue(bound); + } + + @Override + public ColumnPosition unmarshal(ColumnPositionValue value) + throws Exception { + return new ColumnPosition(value.getIndex()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAdapter.java index bd526b24..e01bef88 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAdapter.java @@ -1,20 +1,20 @@ -package cz.cuni.mff.xrg.odalic.api.rest.adapters; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -import cz.cuni.mff.xrg.odalic.api.rest.values.ColumnRelationValue; -import cz.cuni.mff.xrg.odalic.feedbacks.ColumnRelation; - - -public final class ColumnRelationAdapter extends XmlAdapter { - - @Override - public ColumnRelationValue marshal(ColumnRelation bound) throws Exception { - return new ColumnRelationValue(bound); - } - - @Override - public ColumnRelation unmarshal(ColumnRelationValue value) throws Exception { - return new ColumnRelation(value.getPosition(), value.getAnnotation()); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.ColumnRelationValue; +import cz.cuni.mff.xrg.odalic.feedbacks.ColumnRelation; + + +public final class ColumnRelationAdapter extends XmlAdapter { + + @Override + public ColumnRelationValue marshal(ColumnRelation bound) throws Exception { + return new ColumnRelationValue(bound); + } + + @Override + public ColumnRelation unmarshal(ColumnRelationValue value) throws Exception { + return new ColumnRelation(value.getPosition(), value.getAnnotation()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAnnotationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAnnotationAdapter.java index 667ae2bd..8af0faae 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAnnotationAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationAnnotationAdapter.java @@ -1,47 +1,47 @@ -package cz.cuni.mff.xrg.odalic.api.rest.adapters; - -import java.util.Map; -import java.util.NavigableSet; -import java.util.Set; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSortedSet; - -import cz.cuni.mff.xrg.odalic.api.rest.values.ColumnRelationAnnotationValue; -import cz.cuni.mff.xrg.odalic.api.rest.values.EntityCandidateValue; -import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; -import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; -import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; - - -public final class ColumnRelationAnnotationAdapter extends XmlAdapter { - - @Override - public ColumnRelationAnnotationValue marshal(ColumnRelationAnnotation bound) throws Exception { - return new ColumnRelationAnnotationValue(bound); - } - - @Override - public ColumnRelationAnnotation unmarshal(ColumnRelationAnnotationValue value) throws Exception { - final ImmutableMap.Builder> candidatesBuilder = - ImmutableMap.builder(); - final ImmutableMap.Builder> chosenBuilder = - ImmutableMap.builder(); - for (final Map.Entry> entry : value - .getCandidates().entrySet()) { - final KnowledgeBase base = entry.getKey(); - final Set values = entry.getValue(); - - candidatesBuilder.put(base, ImmutableSortedSet.copyOf(values.stream() - .map(e -> new EntityCandidate(e.getEntity(), e.getLikelihood())).iterator())); - chosenBuilder.put(base, ImmutableSet.copyOf(values.stream().filter(e -> e.isChosen()) - .map(e -> new EntityCandidate(e.getEntity(), e.getLikelihood())).iterator())); - } - - return new ColumnRelationAnnotation(candidatesBuilder.build(), chosenBuilder.build()); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import java.util.Map; +import java.util.NavigableSet; +import java.util.Set; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSortedSet; + +import cz.cuni.mff.xrg.odalic.api.rest.values.ColumnRelationAnnotationValue; +import cz.cuni.mff.xrg.odalic.api.rest.values.EntityCandidateValue; +import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; + + +public final class ColumnRelationAnnotationAdapter extends XmlAdapter { + + @Override + public ColumnRelationAnnotationValue marshal(ColumnRelationAnnotation bound) throws Exception { + return new ColumnRelationAnnotationValue(bound); + } + + @Override + public ColumnRelationAnnotation unmarshal(ColumnRelationAnnotationValue value) throws Exception { + final ImmutableMap.Builder> candidatesBuilder = + ImmutableMap.builder(); + final ImmutableMap.Builder> chosenBuilder = + ImmutableMap.builder(); + for (final Map.Entry> entry : value + .getCandidates().entrySet()) { + final KnowledgeBase base = entry.getKey(); + final Set values = entry.getValue(); + + candidatesBuilder.put(base, ImmutableSortedSet.copyOf(values.stream() + .map(e -> new EntityCandidate(e.getEntity(), e.getLikelihood())).iterator())); + chosenBuilder.put(base, ImmutableSet.copyOf(values.stream().filter(e -> e.isChosen()) + .map(e -> new EntityCandidate(e.getEntity(), e.getLikelihood())).iterator())); + } + + return new ColumnRelationAnnotation(candidatesBuilder.build(), chosenBuilder.build()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationPositionAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationPositionAdapter.java index f8353afd..02edef8e 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationPositionAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ColumnRelationPositionAdapter.java @@ -1,23 +1,23 @@ -package cz.cuni.mff.xrg.odalic.api.rest.adapters; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -import cz.cuni.mff.xrg.odalic.api.rest.values.ColumnRelationPositionValue; -import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; - - -public final class ColumnRelationPositionAdapter - extends XmlAdapter { - - @Override - public ColumnRelationPositionValue marshal(ColumnRelationPosition bound) - throws Exception { - return new ColumnRelationPositionValue(bound); - } - - @Override - public ColumnRelationPosition unmarshal(ColumnRelationPositionValue value) - throws Exception { - return new ColumnRelationPosition(value.getFirst(), value.getSecond()); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.ColumnRelationPositionValue; +import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; + + +public final class ColumnRelationPositionAdapter + extends XmlAdapter { + + @Override + public ColumnRelationPositionValue marshal(ColumnRelationPosition bound) + throws Exception { + return new ColumnRelationPositionValue(bound); + } + + @Override + public ColumnRelationPosition unmarshal(ColumnRelationPositionValue value) + throws Exception { + return new ColumnRelationPosition(value.getFirst(), value.getSecond()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ConfigurationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ConfigurationAdapter.java index cef6b962..d1f48a99 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ConfigurationAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ConfigurationAdapter.java @@ -1,20 +1,20 @@ -package cz.cuni.mff.xrg.odalic.api.rest.adapters; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -import cz.cuni.mff.xrg.odalic.api.rest.values.ConfigurationValue; -import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; - - -public final class ConfigurationAdapter extends XmlAdapter { - - @Override - public ConfigurationValue marshal(Configuration bound) throws Exception { - return new ConfigurationValue(bound); - } - - @Override - public Configuration unmarshal(ConfigurationValue value) throws Exception { - throw new UnsupportedOperationException(); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.ConfigurationValue; +import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; + + +public final class ConfigurationAdapter extends XmlAdapter { + + @Override + public ConfigurationValue marshal(Configuration bound) throws Exception { + return new ConfigurationValue(bound); + } + + @Override + public Configuration unmarshal(ConfigurationValue value) throws Exception { + throw new UnsupportedOperationException(); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/DisambiguationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/DisambiguationAdapter.java index 5a714cce..f9a170c9 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/DisambiguationAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/DisambiguationAdapter.java @@ -1,23 +1,23 @@ -package cz.cuni.mff.xrg.odalic.api.rest.adapters; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -import cz.cuni.mff.xrg.odalic.api.rest.values.DisambiguationValue; -import cz.cuni.mff.xrg.odalic.feedbacks.Disambiguation; - - -public final class DisambiguationAdapter - extends XmlAdapter { - - @Override - public DisambiguationValue marshal(Disambiguation bound) - throws Exception { - return new DisambiguationValue(bound); - } - - @Override - public Disambiguation unmarshal(DisambiguationValue value) - throws Exception { - return new Disambiguation(value.getPosition(), value.getAnnotation()); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.DisambiguationValue; +import cz.cuni.mff.xrg.odalic.feedbacks.Disambiguation; + + +public final class DisambiguationAdapter + extends XmlAdapter { + + @Override + public DisambiguationValue marshal(Disambiguation bound) + throws Exception { + return new DisambiguationValue(bound); + } + + @Override + public Disambiguation unmarshal(DisambiguationValue value) + throws Exception { + return new Disambiguation(value.getPosition(), value.getAnnotation()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityAdapter.java index 3b6c0690..5754a863 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityAdapter.java @@ -1,24 +1,24 @@ -package cz.cuni.mff.xrg.odalic.api.rest.adapters; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -import cz.cuni.mff.xrg.odalic.api.rest.values.EntityValue; -import cz.cuni.mff.xrg.odalic.tasks.annotations.Entity; - - -public final class EntityAdapter - extends XmlAdapter { - - @Override - public EntityValue marshal(Entity bound) - throws Exception { - return new EntityValue(bound); - } - - @Override - public Entity unmarshal(EntityValue value) - throws Exception { - return new Entity(value.getResource(), - value.getLabel()); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.EntityValue; +import cz.cuni.mff.xrg.odalic.tasks.annotations.Entity; + + +public final class EntityAdapter + extends XmlAdapter { + + @Override + public EntityValue marshal(Entity bound) + throws Exception { + return new EntityValue(bound); + } + + @Override + public Entity unmarshal(EntityValue value) + throws Exception { + return new Entity(value.getResource(), + value.getLabel()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityCandidateAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityCandidateAdapter.java index ebb8d53b..3f6105e2 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityCandidateAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/EntityCandidateAdapter.java @@ -1,24 +1,24 @@ -package cz.cuni.mff.xrg.odalic.api.rest.adapters; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -import cz.cuni.mff.xrg.odalic.api.rest.values.EntityCandidateValue; -import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; - - -public final class EntityCandidateAdapter - extends XmlAdapter { - - @Override - public EntityCandidateValue marshal(EntityCandidate bound) - throws Exception { - throw new UnsupportedOperationException(); - } - - @Override - public EntityCandidate unmarshal(EntityCandidateValue value) - throws Exception { - return new EntityCandidate(value.getEntity(), - value.getLikelihood()); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.EntityCandidateValue; +import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; + + +public final class EntityCandidateAdapter + extends XmlAdapter { + + @Override + public EntityCandidateValue marshal(EntityCandidate bound) + throws Exception { + throw new UnsupportedOperationException(); + } + + @Override + public EntityCandidate unmarshal(EntityCandidateValue value) + throws Exception { + return new EntityCandidate(value.getEntity(), + value.getLikelihood()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/FeedbackAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/FeedbackAdapter.java index f6a9f6af..226da739 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/FeedbackAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/FeedbackAdapter.java @@ -1,22 +1,22 @@ -package cz.cuni.mff.xrg.odalic.api.rest.adapters; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -import cz.cuni.mff.xrg.odalic.api.rest.values.FeedbackValue; -import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; - - -public final class FeedbackAdapter extends XmlAdapter { - - @Override - public FeedbackValue marshal(Feedback bound) throws Exception { - return new FeedbackValue(bound); - } - - @Override - public Feedback unmarshal(FeedbackValue value) throws Exception { - return new Feedback(value.getSubjectColumnPosition(), value.getColumnIgnores(), - value.getColumnAmbiguities(), value.getClassifications(), value.getCellRelations(), - value.getColumnRelations(), value.getDisambiguations(), value.getAmbiguities()); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.FeedbackValue; +import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; + + +public final class FeedbackAdapter extends XmlAdapter { + + @Override + public FeedbackValue marshal(Feedback bound) throws Exception { + return new FeedbackValue(bound); + } + + @Override + public Feedback unmarshal(FeedbackValue value) throws Exception { + return new Feedback(value.getSubjectColumnPosition(), value.getColumnIgnores(), + value.getColumnAmbiguities(), value.getClassifications(), value.getCellRelations(), + value.getColumnRelations(), value.getDisambiguations(), value.getAmbiguities()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/FileAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/FileAdapter.java index eba30d16..e1efaeae 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/FileAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/FileAdapter.java @@ -1,23 +1,23 @@ -package cz.cuni.mff.xrg.odalic.api.rest.adapters; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -import cz.cuni.mff.xrg.odalic.api.rest.values.FileValue; -import cz.cuni.mff.xrg.odalic.files.File; - - -public final class FileAdapter - extends XmlAdapter { - - @Override - public FileValue marshal(File bound) - throws Exception { - return new FileValue(bound); - } - - @Override - public File unmarshal(FileValue value) - throws Exception { - return new File(value.getId(), value.getUploaded(), value.getOwner(), value.getLocation()); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.FileValue; +import cz.cuni.mff.xrg.odalic.files.File; + + +public final class FileAdapter + extends XmlAdapter { + + @Override + public FileValue marshal(File bound) + throws Exception { + return new FileValue(bound); + } + + @Override + public File unmarshal(FileValue value) + throws Exception { + return new File(value.getId(), value.getUploaded(), value.getOwner(), value.getLocation()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/HeaderAnnotationAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/HeaderAnnotationAdapter.java index 6484a6b9..4ef248ed 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/HeaderAnnotationAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/HeaderAnnotationAdapter.java @@ -1,47 +1,47 @@ -package cz.cuni.mff.xrg.odalic.api.rest.adapters; - -import java.util.Map; -import java.util.NavigableSet; -import java.util.Set; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSortedSet; - -import cz.cuni.mff.xrg.odalic.api.rest.values.HeaderAnnotationValue; -import cz.cuni.mff.xrg.odalic.api.rest.values.EntityCandidateValue; -import cz.cuni.mff.xrg.odalic.tasks.annotations.HeaderAnnotation; -import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; -import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; - - -public final class HeaderAnnotationAdapter extends XmlAdapter { - - @Override - public HeaderAnnotationValue marshal(HeaderAnnotation bound) throws Exception { - return new HeaderAnnotationValue(bound); - } - - @Override - public HeaderAnnotation unmarshal(HeaderAnnotationValue value) throws Exception { - final ImmutableMap.Builder> candidatesBuilder = - ImmutableMap.builder(); - final ImmutableMap.Builder> chosenBuilder = - ImmutableMap.builder(); - for (final Map.Entry> entry : value - .getCandidates().entrySet()) { - final KnowledgeBase base = entry.getKey(); - final Set values = entry.getValue(); - - candidatesBuilder.put(base, ImmutableSortedSet.copyOf(values.stream() - .map(e -> new EntityCandidate(e.getEntity(), e.getLikelihood())).iterator())); - chosenBuilder.put(base, ImmutableSet.copyOf(values.stream().filter(e -> e.isChosen()) - .map(e -> new EntityCandidate(e.getEntity(), e.getLikelihood())).iterator())); - } - - return new HeaderAnnotation(candidatesBuilder.build(), chosenBuilder.build()); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import java.util.Map; +import java.util.NavigableSet; +import java.util.Set; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSortedSet; + +import cz.cuni.mff.xrg.odalic.api.rest.values.HeaderAnnotationValue; +import cz.cuni.mff.xrg.odalic.api.rest.values.EntityCandidateValue; +import cz.cuni.mff.xrg.odalic.tasks.annotations.HeaderAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; + + +public final class HeaderAnnotationAdapter extends XmlAdapter { + + @Override + public HeaderAnnotationValue marshal(HeaderAnnotation bound) throws Exception { + return new HeaderAnnotationValue(bound); + } + + @Override + public HeaderAnnotation unmarshal(HeaderAnnotationValue value) throws Exception { + final ImmutableMap.Builder> candidatesBuilder = + ImmutableMap.builder(); + final ImmutableMap.Builder> chosenBuilder = + ImmutableMap.builder(); + for (final Map.Entry> entry : value + .getCandidates().entrySet()) { + final KnowledgeBase base = entry.getKey(); + final Set values = entry.getValue(); + + candidatesBuilder.put(base, ImmutableSortedSet.copyOf(values.stream() + .map(e -> new EntityCandidate(e.getEntity(), e.getLikelihood())).iterator())); + chosenBuilder.put(base, ImmutableSet.copyOf(values.stream().filter(e -> e.isChosen()) + .map(e -> new EntityCandidate(e.getEntity(), e.getLikelihood())).iterator())); + } + + return new HeaderAnnotation(candidatesBuilder.build(), chosenBuilder.build()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/KnowledgeBaseAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/KnowledgeBaseAdapter.java index 61d6e48c..eade46a4 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/KnowledgeBaseAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/KnowledgeBaseAdapter.java @@ -1,23 +1,23 @@ -package cz.cuni.mff.xrg.odalic.api.rest.adapters; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -import cz.cuni.mff.xrg.odalic.api.rest.values.KnowledgeBaseValue; -import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; - - -public final class KnowledgeBaseAdapter - extends XmlAdapter { - - @Override - public KnowledgeBaseValue marshal(KnowledgeBase bound) - throws Exception { - return new KnowledgeBaseValue(bound); - } - - @Override - public KnowledgeBase unmarshal(KnowledgeBaseValue value) - throws Exception { - return new KnowledgeBase(value.getName()); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.KnowledgeBaseValue; +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; + + +public final class KnowledgeBaseAdapter + extends XmlAdapter { + + @Override + public KnowledgeBaseValue marshal(KnowledgeBase bound) + throws Exception { + return new KnowledgeBaseValue(bound); + } + + @Override + public KnowledgeBase unmarshal(KnowledgeBaseValue value) + throws Exception { + return new KnowledgeBase(value.getName()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/LikelihoodAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/LikelihoodAdapter.java index eea357d9..68d623d9 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/LikelihoodAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/LikelihoodAdapter.java @@ -1,23 +1,23 @@ -package cz.cuni.mff.xrg.odalic.api.rest.adapters; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -import cz.cuni.mff.xrg.odalic.api.rest.values.LikelihoodValue; -import cz.cuni.mff.xrg.odalic.tasks.annotations.Likelihood; - - -public final class LikelihoodAdapter - extends XmlAdapter { - - @Override - public LikelihoodValue marshal(Likelihood bound) - throws Exception { - return new LikelihoodValue(bound); - } - - @Override - public Likelihood unmarshal(LikelihoodValue value) - throws Exception { - return new Likelihood(value.getValue()); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.LikelihoodValue; +import cz.cuni.mff.xrg.odalic.tasks.annotations.Likelihood; + + +public final class LikelihoodAdapter + extends XmlAdapter { + + @Override + public LikelihoodValue marshal(Likelihood bound) + throws Exception { + return new LikelihoodValue(bound); + } + + @Override + public Likelihood unmarshal(LikelihoodValue value) + throws Exception { + return new Likelihood(value.getValue()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ResultAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ResultAdapter.java index e60b89ee..3833940b 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ResultAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/ResultAdapter.java @@ -1,59 +1,59 @@ -package cz.cuni.mff.xrg.odalic.api.rest.adapters; - -import java.util.Map; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -import com.google.common.collect.ImmutableMap; - -import cz.cuni.mff.xrg.odalic.api.rest.values.ResultValue; -import cz.cuni.mff.xrg.odalic.positions.CellRelationPosition; -import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; -import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; -import cz.cuni.mff.xrg.odalic.positions.RowPosition; -import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; -import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; -import cz.cuni.mff.xrg.odalic.tasks.results.Result; - - -public final class ResultAdapter extends XmlAdapter { - - @Override - public ResultValue marshal(Result bound) throws Exception { - return new ResultValue(bound); - } - - @Override - public Result unmarshal(ResultValue value) throws Exception { - final ImmutableMap.Builder columnRelationAnnotationsBuilder = ImmutableMap.builder(); - for (final Map.Entry> entry : value.getColumnRelationAnnotations().entrySet()) { - final ColumnPosition first = entry.getKey(); - - for (final Map.Entry innerEntry : entry.getValue().entrySet()) { - final ColumnPosition second = innerEntry.getKey(); - final ColumnRelationAnnotation annotation = innerEntry.getValue(); - - columnRelationAnnotationsBuilder.put(new ColumnRelationPosition(first, second), annotation); - } - } - - final ImmutableMap.Builder cellRelationAnnotationsBuilder = ImmutableMap.builder(); - for (final Map.Entry>> entry : value.getCellRelationAnnotations().entrySet()) { - final RowPosition row = entry.getKey(); - - for (final Map.Entry> innerEntry : entry.getValue().entrySet()) { - final ColumnPosition first = innerEntry.getKey(); - - for (final Map.Entry subInnerEntry : innerEntry.getValue().entrySet()) { - final ColumnPosition second = subInnerEntry.getKey(); - final CellRelationAnnotation annotation = subInnerEntry.getValue(); - - cellRelationAnnotationsBuilder.put(new CellRelationPosition(new ColumnRelationPosition(first, second), row), annotation); - } - } - } - - return new Result(value.getSubjectColumnPosition(), value.getHeaderAnnotations(), value.getCellAnnotations(), - columnRelationAnnotationsBuilder.build(), cellRelationAnnotationsBuilder.build()); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import java.util.Map; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import com.google.common.collect.ImmutableMap; + +import cz.cuni.mff.xrg.odalic.api.rest.values.ResultValue; +import cz.cuni.mff.xrg.odalic.positions.CellRelationPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; +import cz.cuni.mff.xrg.odalic.positions.RowPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.results.Result; + + +public final class ResultAdapter extends XmlAdapter { + + @Override + public ResultValue marshal(Result bound) throws Exception { + return new ResultValue(bound); + } + + @Override + public Result unmarshal(ResultValue value) throws Exception { + final ImmutableMap.Builder columnRelationAnnotationsBuilder = ImmutableMap.builder(); + for (final Map.Entry> entry : value.getColumnRelationAnnotations().entrySet()) { + final ColumnPosition first = entry.getKey(); + + for (final Map.Entry innerEntry : entry.getValue().entrySet()) { + final ColumnPosition second = innerEntry.getKey(); + final ColumnRelationAnnotation annotation = innerEntry.getValue(); + + columnRelationAnnotationsBuilder.put(new ColumnRelationPosition(first, second), annotation); + } + } + + final ImmutableMap.Builder cellRelationAnnotationsBuilder = ImmutableMap.builder(); + for (final Map.Entry>> entry : value.getCellRelationAnnotations().entrySet()) { + final RowPosition row = entry.getKey(); + + for (final Map.Entry> innerEntry : entry.getValue().entrySet()) { + final ColumnPosition first = innerEntry.getKey(); + + for (final Map.Entry subInnerEntry : innerEntry.getValue().entrySet()) { + final ColumnPosition second = subInnerEntry.getKey(); + final CellRelationAnnotation annotation = subInnerEntry.getValue(); + + cellRelationAnnotationsBuilder.put(new CellRelationPosition(new ColumnRelationPosition(first, second), row), annotation); + } + } + } + + return new Result(value.getSubjectColumnPosition(), value.getHeaderAnnotations(), value.getCellAnnotations(), + columnRelationAnnotationsBuilder.build(), cellRelationAnnotationsBuilder.build()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/RowPositionAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/RowPositionAdapter.java index 8891dd67..e44ff245 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/RowPositionAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/RowPositionAdapter.java @@ -1,23 +1,23 @@ -package cz.cuni.mff.xrg.odalic.api.rest.adapters; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -import cz.cuni.mff.xrg.odalic.api.rest.values.RowPositionValue; -import cz.cuni.mff.xrg.odalic.positions.RowPosition; - - -public final class RowPositionAdapter - extends XmlAdapter { - - @Override - public RowPositionValue marshal(RowPosition bound) - throws Exception { - return new RowPositionValue(bound); - } - - @Override - public RowPosition unmarshal(RowPositionValue value) - throws Exception { - return new RowPosition(value.getIndex()); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.RowPositionValue; +import cz.cuni.mff.xrg.odalic.positions.RowPosition; + + +public final class RowPositionAdapter + extends XmlAdapter { + + @Override + public RowPositionValue marshal(RowPosition bound) + throws Exception { + return new RowPositionValue(bound); + } + + @Override + public RowPosition unmarshal(RowPositionValue value) + throws Exception { + return new RowPosition(value.getIndex()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/TaskAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/TaskAdapter.java index 0d1473d7..1ec9053c 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/TaskAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/adapters/TaskAdapter.java @@ -1,20 +1,20 @@ -package cz.cuni.mff.xrg.odalic.api.rest.adapters; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -import cz.cuni.mff.xrg.odalic.api.rest.values.TaskValue; -import cz.cuni.mff.xrg.odalic.tasks.Task; - - -public final class TaskAdapter extends XmlAdapter { - - @Override - public TaskValue marshal(Task bound) throws Exception { - return new TaskValue(bound); - } - - @Override - public Task unmarshal(TaskValue value) throws Exception { - throw new UnsupportedOperationException(); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.adapters; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import cz.cuni.mff.xrg.odalic.api.rest.values.TaskValue; +import cz.cuni.mff.xrg.odalic.tasks.Task; + + +public final class TaskAdapter extends XmlAdapter { + + @Override + public TaskValue marshal(Task bound) throws Exception { + return new TaskValue(bound); + } + + @Override + public Task unmarshal(TaskValue value) throws Exception { + throw new UnsupportedOperationException(); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionKeyJsonDeserializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionKeyJsonDeserializer.java index 1522dd4d..68111828 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionKeyJsonDeserializer.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionKeyJsonDeserializer.java @@ -1,23 +1,23 @@ -package cz.cuni.mff.xrg.odalic.api.rest.conversions; - -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.KeyDeserializer; - -import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; - -/** - * Map key JSON deserializer for {@link ColumnPosition} instances. - * - * @author Václav Brodec - * - */ -public final class ColumnPositionKeyJsonDeserializer extends KeyDeserializer { - - /* (non-Javadoc) - * @see com.fasterxml.jackson.databind.KeyDeserializer#deserializeKey(java.lang.String, com.fasterxml.jackson.databind.DeserializationContext) - */ - @Override - public Object deserializeKey(String key, DeserializationContext ctxt) { - return new ColumnPosition(Integer.parseInt(key)); - } +package cz.cuni.mff.xrg.odalic.api.rest.conversions; + +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.KeyDeserializer; + +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; + +/** + * Map key JSON deserializer for {@link ColumnPosition} instances. + * + * @author Václav Brodec + * + */ +public final class ColumnPositionKeyJsonDeserializer extends KeyDeserializer { + + /* (non-Javadoc) + * @see com.fasterxml.jackson.databind.KeyDeserializer#deserializeKey(java.lang.String, com.fasterxml.jackson.databind.DeserializationContext) + */ + @Override + public Object deserializeKey(String key, DeserializationContext ctxt) { + return new ColumnPosition(Integer.parseInt(key)); + } } \ No newline at end of file diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionKeyJsonSerializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionKeyJsonSerializer.java index 2e64fa28..45eb001e 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionKeyJsonSerializer.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionKeyJsonSerializer.java @@ -1,29 +1,29 @@ -package cz.cuni.mff.xrg.odalic.api.rest.conversions; - -import java.io.IOException; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; - -import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; - -/** - * Map key JSON serializer for {@link ColumnPosition} instances. - * - * @author Václav Brodec - * - */ -public final class ColumnPositionKeyJsonSerializer extends JsonSerializer { - - /* (non-Javadoc) - * @see com.fasterxml.jackson.databind.JsonSerializer#serialize(java.lang.Object, com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider) - */ - @Override - public void serialize(ColumnPosition value, JsonGenerator jgen, - SerializerProvider provider) throws IOException, - JsonProcessingException { - jgen.writeFieldName(Integer.toString(value.getIndex())); - } - -} +package cz.cuni.mff.xrg.odalic.api.rest.conversions; + +import java.io.IOException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; + +/** + * Map key JSON serializer for {@link ColumnPosition} instances. + * + * @author Václav Brodec + * + */ +public final class ColumnPositionKeyJsonSerializer extends JsonSerializer { + + /* (non-Javadoc) + * @see com.fasterxml.jackson.databind.JsonSerializer#serialize(java.lang.Object, com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider) + */ + @Override + public void serialize(ColumnPosition value, JsonGenerator jgen, + SerializerProvider provider) throws IOException, + JsonProcessingException { + jgen.writeFieldName(Integer.toString(value.getIndex())); + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnPositionToCellRelationAnnotationMapMapDeserializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnPositionToCellRelationAnnotationMapMapDeserializer.java index c4d0ea00..c9450ad4 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnPositionToCellRelationAnnotationMapMapDeserializer.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnPositionToCellRelationAnnotationMapMapDeserializer.java @@ -1,30 +1,30 @@ -package cz.cuni.mff.xrg.odalic.api.rest.conversions; - -import java.io.IOException; -import java.util.Map; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; - -import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; -import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; - -/** - * A custom nested map JSON deserializer. - * - * @author Václav Brodec - * - */ -public final class ColumnPositionToColumnPositionToCellRelationAnnotationMapMapDeserializer extends JsonDeserializer> { - - /* (non-Javadoc) - * @see com.fasterxml.jackson.databind.JsonDeserializer#deserialize(com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.databind.DeserializationContext) - */ - @Override - public Map deserialize(JsonParser parser, - DeserializationContext ctxt) throws IOException, JsonProcessingException { - throw new UnsupportedOperationException(); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.conversions; + +import java.io.IOException; +import java.util.Map; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; + +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; + +/** + * A custom nested map JSON deserializer. + * + * @author Václav Brodec + * + */ +public final class ColumnPositionToColumnPositionToCellRelationAnnotationMapMapDeserializer extends JsonDeserializer> { + + /* (non-Javadoc) + * @see com.fasterxml.jackson.databind.JsonDeserializer#deserialize(com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.databind.DeserializationContext) + */ + @Override + public Map deserialize(JsonParser parser, + DeserializationContext ctxt) throws IOException, JsonProcessingException { + throw new UnsupportedOperationException(); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnPositionToCellRelationAnnotationMapMapSerializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnPositionToCellRelationAnnotationMapMapSerializer.java index 7ce6574d..2d6fb079 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnPositionToCellRelationAnnotationMapMapSerializer.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnPositionToCellRelationAnnotationMapMapSerializer.java @@ -1,43 +1,43 @@ -package cz.cuni.mff.xrg.odalic.api.rest.conversions; - -import java.io.IOException; -import java.util.Map; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; - -import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; -import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; - -/** - * A custom nested map JSON serializer. - * - * @author Václav Brodec - * - */ -public final class ColumnPositionToColumnPositionToCellRelationAnnotationMapMapSerializer -extends JsonSerializer>> { - - /* (non-Javadoc) - * @see com.fasterxml.jackson.databind.JsonSerializer#serialize(java.lang.Object, com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider) - */ - @Override - public void serialize(Map> value, JsonGenerator jgen, - SerializerProvider provider) throws IOException, - JsonProcessingException { - jgen.writeStartObject(); - for (final Map.Entry> entry : value.entrySet()) { - jgen.writeFieldName(Integer.toString(entry.getKey().getIndex())); - - jgen.writeStartObject(); - for (final Map.Entry subEntry : entry.getValue().entrySet()) { - jgen.writeObjectField(Integer.toString(subEntry.getKey().getIndex()), subEntry.getValue()); - } - jgen.writeEndObject(); - } - jgen.writeEndObject(); - } - -} +package cz.cuni.mff.xrg.odalic.api.rest.conversions; + +import java.io.IOException; +import java.util.Map; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; + +/** + * A custom nested map JSON serializer. + * + * @author Václav Brodec + * + */ +public final class ColumnPositionToColumnPositionToCellRelationAnnotationMapMapSerializer +extends JsonSerializer>> { + + /* (non-Javadoc) + * @see com.fasterxml.jackson.databind.JsonSerializer#serialize(java.lang.Object, com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider) + */ + @Override + public void serialize(Map> value, JsonGenerator jgen, + SerializerProvider provider) throws IOException, + JsonProcessingException { + jgen.writeStartObject(); + for (final Map.Entry> entry : value.entrySet()) { + jgen.writeFieldName(Integer.toString(entry.getKey().getIndex())); + + jgen.writeStartObject(); + for (final Map.Entry subEntry : entry.getValue().entrySet()) { + jgen.writeObjectField(Integer.toString(subEntry.getKey().getIndex()), subEntry.getValue()); + } + jgen.writeEndObject(); + } + jgen.writeEndObject(); + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnRelationAnnotationMapDeserializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnRelationAnnotationMapDeserializer.java index 9ce3a2f9..74e4f5b7 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnRelationAnnotationMapDeserializer.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnRelationAnnotationMapDeserializer.java @@ -1,29 +1,29 @@ -package cz.cuni.mff.xrg.odalic.api.rest.conversions; - -import java.io.IOException; -import java.util.Map; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; -import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; - -/** - * A custom nested map JSON deserializer. - * - * @author Václav Brodec - * - */ -public final class ColumnPositionToColumnRelationAnnotationMapDeserializer extends JsonDeserializer> { - - /* (non-Javadoc) - * @see com.fasterxml.jackson.databind.JsonDeserializer#deserialize(com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.databind.DeserializationContext) - */ - @Override - public Map deserialize(JsonParser parser, - DeserializationContext ctxt) throws IOException, JsonProcessingException { - throw new UnsupportedOperationException(); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.conversions; + +import java.io.IOException; +import java.util.Map; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; + +/** + * A custom nested map JSON deserializer. + * + * @author Václav Brodec + * + */ +public final class ColumnPositionToColumnRelationAnnotationMapDeserializer extends JsonDeserializer> { + + /* (non-Javadoc) + * @see com.fasterxml.jackson.databind.JsonDeserializer#deserialize(com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.databind.DeserializationContext) + */ + @Override + public Map deserialize(JsonParser parser, + DeserializationContext ctxt) throws IOException, JsonProcessingException { + throw new UnsupportedOperationException(); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnRelationAnnotationMapSerializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnRelationAnnotationMapSerializer.java index 56b9a3ca..4e693cd2 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnRelationAnnotationMapSerializer.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/ColumnPositionToColumnRelationAnnotationMapSerializer.java @@ -1,33 +1,33 @@ -package cz.cuni.mff.xrg.odalic.api.rest.conversions; - -import java.io.IOException; -import java.util.Map; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; - -import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; -import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; - -/** - * A custom nested map JSON serializer. - * - * @author Václav Brodec - * - */ -public final class ColumnPositionToColumnRelationAnnotationMapSerializer extends JsonSerializer> { - - @Override - public void serialize(Map value, JsonGenerator jgen, - SerializerProvider provider) throws IOException, - JsonProcessingException { - jgen.writeStartObject(); - for (final Map.Entry entry : value.entrySet()) { - jgen.writeObjectField(Integer.toString(entry.getKey().getIndex()), entry.getValue()); - } - jgen.writeEndObject(); - } - -} +package cz.cuni.mff.xrg.odalic.api.rest.conversions; + +import java.io.IOException; +import java.util.Map; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; + +/** + * A custom nested map JSON serializer. + * + * @author Václav Brodec + * + */ +public final class ColumnPositionToColumnRelationAnnotationMapSerializer extends JsonSerializer> { + + @Override + public void serialize(Map value, JsonGenerator jgen, + SerializerProvider provider) throws IOException, + JsonProcessingException { + jgen.writeStartObject(); + for (final Map.Entry entry : value.entrySet()) { + jgen.writeObjectField(Integer.toString(entry.getKey().getIndex()), entry.getValue()); + } + jgen.writeEndObject(); + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateDeserializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateDeserializer.java index 1e736493..1222fcb1 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateDeserializer.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateDeserializer.java @@ -1,38 +1,38 @@ -package cz.cuni.mff.xrg.odalic.api.rest.conversions; - -import java.io.IOException; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; - -/** - * Deserializer from a custom date format. - * - * @author Václav Brodec - * - * @see CustomJsonDateSerializer - */ -public final class CustomJsonDateDeserializer extends JsonDeserializer { - - /* (non-Javadoc) - * @see com.fasterxml.jackson.databind.JsonDeserializer#deserialize(com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.databind.DeserializationContext) - */ - @Override - public Date deserialize(JsonParser jsonparser, DeserializationContext context) - throws IOException, JsonProcessingException { - - final SimpleDateFormat format = new SimpleDateFormat(CustomJsonDateSerializer.DATE_FORMAT); - final String date = jsonparser.getText(); - try { - return format.parse(date); - } catch (ParseException e) { - throw new RuntimeException(e); - } - } - -} +package cz.cuni.mff.xrg.odalic.api.rest.conversions; + +import java.io.IOException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; + +/** + * Deserializer from a custom date format. + * + * @author Václav Brodec + * + * @see CustomJsonDateSerializer + */ +public final class CustomJsonDateDeserializer extends JsonDeserializer { + + /* (non-Javadoc) + * @see com.fasterxml.jackson.databind.JsonDeserializer#deserialize(com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.databind.DeserializationContext) + */ + @Override + public Date deserialize(JsonParser jsonparser, DeserializationContext context) + throws IOException, JsonProcessingException { + + final SimpleDateFormat format = new SimpleDateFormat(CustomJsonDateSerializer.DATE_FORMAT); + final String date = jsonparser.getText(); + try { + return format.parse(date); + } catch (ParseException e) { + throw new RuntimeException(e); + } + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateSerializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateSerializer.java index 69ca6fd1..9c725b24 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateSerializer.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/CustomJsonDateSerializer.java @@ -1,32 +1,32 @@ -package cz.cuni.mff.xrg.odalic.api.rest.conversions; - -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.Date; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; - -/** - * Serializer to custom date format {@value #DATE_FORMAT}. - * - * @author Václav Brodec - * - */ -public final class CustomJsonDateSerializer extends JsonSerializer { - - public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm"; - - @Override - public void serialize(Date value, JsonGenerator jgen, - SerializerProvider provider) throws IOException, - JsonProcessingException { - - final SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); - final String dateString = dateFormat.format(value); - jgen.writeString(dateString); - } - -} +package cz.cuni.mff.xrg.odalic.api.rest.conversions; + +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +/** + * Serializer to custom date format {@value #DATE_FORMAT}. + * + * @author Václav Brodec + * + */ +public final class CustomJsonDateSerializer extends JsonSerializer { + + public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm"; + + @Override + public void serialize(Date value, JsonGenerator jgen, + SerializerProvider provider) throws IOException, + JsonProcessingException { + + final SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); + final String dateString = dateFormat.format(value); + jgen.writeString(dateString); + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/KnowledgeBaseKeyJsonDeserializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/KnowledgeBaseKeyJsonDeserializer.java index c1da8393..70e55765 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/KnowledgeBaseKeyJsonDeserializer.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/KnowledgeBaseKeyJsonDeserializer.java @@ -1,23 +1,23 @@ -package cz.cuni.mff.xrg.odalic.api.rest.conversions; - -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.KeyDeserializer; - -import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; - -/** - * Map key JSON deserializer for {@link KnowledgeBase} instances. - * - * @author Václav Brodec - * - */ -public final class KnowledgeBaseKeyJsonDeserializer extends KeyDeserializer { - - /* (non-Javadoc) - * @see com.fasterxml.jackson.databind.KeyDeserializer#deserializeKey(java.lang.String, com.fasterxml.jackson.databind.DeserializationContext) - */ - @Override - public Object deserializeKey(String key, DeserializationContext ctxt) { - return new KnowledgeBase(key); - } +package cz.cuni.mff.xrg.odalic.api.rest.conversions; + +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.KeyDeserializer; + +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; + +/** + * Map key JSON deserializer for {@link KnowledgeBase} instances. + * + * @author Václav Brodec + * + */ +public final class KnowledgeBaseKeyJsonDeserializer extends KeyDeserializer { + + /* (non-Javadoc) + * @see com.fasterxml.jackson.databind.KeyDeserializer#deserializeKey(java.lang.String, com.fasterxml.jackson.databind.DeserializationContext) + */ + @Override + public Object deserializeKey(String key, DeserializationContext ctxt) { + return new KnowledgeBase(key); + } } \ No newline at end of file diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/KnowledgeBaseKeyJsonSerializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/KnowledgeBaseKeyJsonSerializer.java index a6dc26a2..3a6d430f 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/KnowledgeBaseKeyJsonSerializer.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/KnowledgeBaseKeyJsonSerializer.java @@ -1,26 +1,26 @@ -package cz.cuni.mff.xrg.odalic.api.rest.conversions; - -import java.io.IOException; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; - -import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; - -/** - * Map key JSON serializer for {@link KnowledgeBase} instances. - * - * @author Václav Brodec - * - */ -public final class KnowledgeBaseKeyJsonSerializer extends JsonSerializer { - - @Override - public void serialize(KnowledgeBase value, JsonGenerator jgen, - SerializerProvider provider) throws IOException, - JsonProcessingException { - jgen.writeFieldName(value.getName()); - } - -} +package cz.cuni.mff.xrg.odalic.api.rest.conversions; + +import java.io.IOException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; + +/** + * Map key JSON serializer for {@link KnowledgeBase} instances. + * + * @author Václav Brodec + * + */ +public final class KnowledgeBaseKeyJsonSerializer extends JsonSerializer { + + @Override + public void serialize(KnowledgeBase value, JsonGenerator jgen, + SerializerProvider provider) throws IOException, + JsonProcessingException { + jgen.writeFieldName(value.getName()); + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/RowPositionKeyJsonDeserializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/RowPositionKeyJsonDeserializer.java index bda172a5..cb956d90 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/RowPositionKeyJsonDeserializer.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/RowPositionKeyJsonDeserializer.java @@ -1,24 +1,24 @@ -package cz.cuni.mff.xrg.odalic.api.rest.conversions; - -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.KeyDeserializer; - -import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; -import cz.cuni.mff.xrg.odalic.positions.RowPosition; - -/** - * Map key JSON deserializer for {@link ColumnPosition} instances. - * - * @author Václav Brodec - * - */ -public final class RowPositionKeyJsonDeserializer extends KeyDeserializer { - - /* (non-Javadoc) - * @see com.fasterxml.jackson.databind.KeyDeserializer#deserializeKey(java.lang.String, com.fasterxml.jackson.databind.DeserializationContext) - */ - @Override - public Object deserializeKey(String key, DeserializationContext ctxt) { - return new RowPosition(Integer.parseInt(key)); - } +package cz.cuni.mff.xrg.odalic.api.rest.conversions; + +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.KeyDeserializer; + +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.positions.RowPosition; + +/** + * Map key JSON deserializer for {@link ColumnPosition} instances. + * + * @author Václav Brodec + * + */ +public final class RowPositionKeyJsonDeserializer extends KeyDeserializer { + + /* (non-Javadoc) + * @see com.fasterxml.jackson.databind.KeyDeserializer#deserializeKey(java.lang.String, com.fasterxml.jackson.databind.DeserializationContext) + */ + @Override + public Object deserializeKey(String key, DeserializationContext ctxt) { + return new RowPosition(Integer.parseInt(key)); + } } \ No newline at end of file diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/RowPositionKeyJsonSerializer.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/RowPositionKeyJsonSerializer.java index 700c4c85..2a911f49 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/RowPositionKeyJsonSerializer.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/conversions/RowPositionKeyJsonSerializer.java @@ -1,30 +1,30 @@ -package cz.cuni.mff.xrg.odalic.api.rest.conversions; - -import java.io.IOException; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; - -import cz.cuni.mff.xrg.odalic.positions.RowPosition; -import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; - -/** - * Map key JSON serializer for {@link KnowledgeBase} instances. - * - * @author Václav Brodec - * - */ -public final class RowPositionKeyJsonSerializer extends JsonSerializer { - - /* (non-Javadoc) - * @see com.fasterxml.jackson.databind.JsonSerializer#serialize(java.lang.Object, com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider) - */ - @Override - public void serialize(RowPosition value, JsonGenerator jgen, - SerializerProvider provider) throws IOException, - JsonProcessingException { - jgen.writeFieldName(Integer.toString(value.getIndex())); - } - -} +package cz.cuni.mff.xrg.odalic.api.rest.conversions; + +import java.io.IOException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +import cz.cuni.mff.xrg.odalic.positions.RowPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; + +/** + * Map key JSON serializer for {@link KnowledgeBase} instances. + * + * @author Václav Brodec + * + */ +public final class RowPositionKeyJsonSerializer extends JsonSerializer { + + /* (non-Javadoc) + * @see com.fasterxml.jackson.databind.JsonSerializer#serialize(java.lang.Object, com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider) + */ + @Override + public void serialize(RowPosition value, JsonGenerator jgen, + SerializerProvider provider) throws IOException, + JsonProcessingException { + jgen.writeFieldName(Integer.toString(value.getIndex())); + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/Message.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/Message.java index 71d08280..c36f1027 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/Message.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/Message.java @@ -1,98 +1,98 @@ -package cz.cuni.mff.xrg.odalic.api.rest.errors; - -import javax.annotation.Nullable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Preconditions; - - -/** - * Reporting message with extra details for developers. - * - * @author Václav Brodec - * - */ -@XmlRootElement -public final class Message { - - @XmlElement - private int status; - - @XmlElement - private String text; - - @XmlElement - private String link; - - @XmlElement - private String developerText; - - public Message() { - status = Integer.MIN_VALUE; - } - - /** - * Creates new message. - * - * @param status HTTP status code - */ - public Message(int status) { - Preconditions.checkArgument(status >= 100); - Preconditions.checkArgument(status <= 599); - - this.status = status; - } - - /** - * @return the status - */ - public int getStatus() { - return status; - } - - /** - * @return the text - */ - @Nullable - public String getText() { - return text; - } - - /** - * @param text the text to set - */ - public void setText(String text) { - this.text = text; - } - - /** - * @return the link - */ - @Nullable - public String getLink() { - return link; - } - - /** - * @param link the link to set - */ - public void setLink(String link) { - this.link = link; - } - - /** - * @return the developer text - */ - @Nullable - public String getDeveloperText() { - return developerText; - } - - /** - * @param developerText the developer text to set - */ - public void setDeveloperText(String developerText) { - this.developerText = developerText; - } -} +package cz.cuni.mff.xrg.odalic.api.rest.errors; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + + +/** + * Reporting message with extra details for developers. + * + * @author Václav Brodec + * + */ +@XmlRootElement +public final class Message { + + @XmlElement + private int status; + + @XmlElement + private String text; + + @XmlElement + private String link; + + @XmlElement + private String developerText; + + public Message() { + status = Integer.MIN_VALUE; + } + + /** + * Creates new message. + * + * @param status HTTP status code + */ + public Message(int status) { + Preconditions.checkArgument(status >= 100); + Preconditions.checkArgument(status <= 599); + + this.status = status; + } + + /** + * @return the status + */ + public int getStatus() { + return status; + } + + /** + * @return the text + */ + @Nullable + public String getText() { + return text; + } + + /** + * @param text the text to set + */ + public void setText(String text) { + this.text = text; + } + + /** + * @return the link + */ + @Nullable + public String getLink() { + return link; + } + + /** + * @param link the link to set + */ + public void setLink(String link) { + this.link = link; + } + + /** + * @return the developer text + */ + @Nullable + public String getDeveloperText() { + return developerText; + } + + /** + * @param developerText the developer text to set + */ + public void setDeveloperText(String developerText) { + this.developerText = developerText; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/ThrowableMapper.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/ThrowableMapper.java index bc79797c..8e1c4104 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/ThrowableMapper.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/errors/ThrowableMapper.java @@ -1,51 +1,51 @@ -package cz.cuni.mff.xrg.odalic.api.rest.errors; - -import java.io.PrintWriter; -import java.io.StringWriter; - -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.ext.ExceptionMapper; - -/** - * Catch-all throwable mapper. - * - * @author Václav Brodec - * - */ -public final class ThrowableMapper implements ExceptionMapper { - - /* (non-Javadoc) - * @see javax.ws.rs.ext.ExceptionMapper#toResponse(java.lang.Throwable) - */ - @Override - public Response toResponse(Throwable throwable) { - //TODO: Add specialized mappers. - - final Message errorMessage = new Message(getHttpStatus(throwable)); - errorMessage.setText(throwable.getMessage()); - - final StringWriter trace = new StringWriter(); - throwable.printStackTrace(new PrintWriter(trace)); - errorMessage.setDeveloperText(trace.toString()); - - return Response.status(errorMessage.getStatus()).entity(errorMessage) - .type(MediaType.APPLICATION_JSON).build(); - } - - /** - * Defaults to internal server error in case the exception is not instance of {@link WebApplicationException}. - * - * @param throwable throwable instance - * @return HTTP status code - */ - private int getHttpStatus(Throwable throwable) { - if (throwable instanceof WebApplicationException) { - return ((WebApplicationException) throwable).getResponse().getStatus(); - } else { - return Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(); - } - } -} - +package cz.cuni.mff.xrg.odalic.api.rest.errors; + +import java.io.PrintWriter; +import java.io.StringWriter; + +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.ExceptionMapper; + +/** + * Catch-all throwable mapper. + * + * @author Václav Brodec + * + */ +public final class ThrowableMapper implements ExceptionMapper { + + /* (non-Javadoc) + * @see javax.ws.rs.ext.ExceptionMapper#toResponse(java.lang.Throwable) + */ + @Override + public Response toResponse(Throwable throwable) { + //TODO: Add specialized mappers. + + final Message errorMessage = new Message(getHttpStatus(throwable)); + errorMessage.setText(throwable.getMessage()); + + final StringWriter trace = new StringWriter(); + throwable.printStackTrace(new PrintWriter(trace)); + errorMessage.setDeveloperText(trace.toString()); + + return Response.status(errorMessage.getStatus()).entity(errorMessage) + .type(MediaType.APPLICATION_JSON).build(); + } + + /** + * Defaults to internal server error in case the exception is not instance of {@link WebApplicationException}. + * + * @param throwable throwable instance + * @return HTTP status code + */ + private int getHttpStatus(Throwable throwable) { + if (throwable instanceof WebApplicationException) { + return ((WebApplicationException) throwable).getResponse().getStatus(); + } else { + return Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(); + } + } +} + diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/CorsResponseFilter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/CorsResponseFilter.java index 953f0689..486ea081 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/CorsResponseFilter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/CorsResponseFilter.java @@ -1,31 +1,31 @@ -package cz.cuni.mff.xrg.odalic.api.rest.filters; - -import java.io.IOException; - -import javax.ws.rs.container.ContainerRequestContext; -import javax.ws.rs.container.ContainerResponseContext; -import javax.ws.rs.container.ContainerResponseFilter; -import javax.ws.rs.core.MultivaluedMap; - -/** - * Same origin problem workaround filter. - * - * @author Václav Brodec - * - */ -public final class CorsResponseFilter implements ContainerResponseFilter { - - /* (non-Javadoc) - * @see javax.ws.rs.container.ContainerResponseFilter#filter(javax.ws.rs.container.ContainerRequestContext, javax.ws.rs.container.ContainerResponseContext) - */ - @Override - public void filter(ContainerRequestContext requestContext, - ContainerResponseContext responseContext) throws IOException { - MultivaluedMap headers = responseContext.getHeaders(); - - headers.add("Access-Control-Allow-Origin", "*"); - headers.add("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); - headers.add("Access-Control-Allow-Headers", "X-Requested-With, Content-Type, X-Odalic"); - } - -} +package cz.cuni.mff.xrg.odalic.api.rest.filters; + +import java.io.IOException; + +import javax.ws.rs.container.ContainerRequestContext; +import javax.ws.rs.container.ContainerResponseContext; +import javax.ws.rs.container.ContainerResponseFilter; +import javax.ws.rs.core.MultivaluedMap; + +/** + * Same origin problem workaround filter. + * + * @author Václav Brodec + * + */ +public final class CorsResponseFilter implements ContainerResponseFilter { + + /* (non-Javadoc) + * @see javax.ws.rs.container.ContainerResponseFilter#filter(javax.ws.rs.container.ContainerRequestContext, javax.ws.rs.container.ContainerResponseContext) + */ + @Override + public void filter(ContainerRequestContext requestContext, + ContainerResponseContext responseContext) throws IOException { + MultivaluedMap headers = responseContext.getHeaders(); + + headers.add("Access-Control-Allow-Origin", "*"); + headers.add("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); + headers.add("Access-Control-Allow-Headers", "X-Requested-With, Content-Type, X-Odalic"); + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/LoggingResponseFilter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/LoggingResponseFilter.java index de16f8a9..e0b0c6e4 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/LoggingResponseFilter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/filters/LoggingResponseFilter.java @@ -1,39 +1,39 @@ -package cz.cuni.mff.xrg.odalic.api.rest.filters; - -import java.io.IOException; - -import javax.ws.rs.container.ContainerRequestContext; -import javax.ws.rs.container.ContainerResponseContext; -import javax.ws.rs.container.ContainerResponseFilter; - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Filter that logs the API responses. - * - * @author Václav Brodec - * - */ -public final class LoggingResponseFilter - implements ContainerResponseFilter { - - private static final Logger logger = LoggerFactory.getLogger(LoggingResponseFilter.class); - - /* (non-Javadoc) - * @see javax.ws.rs.container.ContainerResponseFilter#filter(javax.ws.rs.container.ContainerRequestContext, javax.ws.rs.container.ContainerResponseContext) - */ - @Override - public void filter(ContainerRequestContext requestContext, - ContainerResponseContext responseContext) throws IOException { - final String method = requestContext.getMethod(); - - logger.debug("Requesting " + method + " for path " + requestContext.getUriInfo().getPath()); - final Object entity = responseContext.getEntity(); - if (entity != null) { - logger.debug("Response " + new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(entity)); - } - } - +package cz.cuni.mff.xrg.odalic.api.rest.filters; + +import java.io.IOException; + +import javax.ws.rs.container.ContainerRequestContext; +import javax.ws.rs.container.ContainerResponseContext; +import javax.ws.rs.container.ContainerResponseFilter; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Filter that logs the API responses. + * + * @author Václav Brodec + * + */ +public final class LoggingResponseFilter + implements ContainerResponseFilter { + + private static final Logger logger = LoggerFactory.getLogger(LoggingResponseFilter.class); + + /* (non-Javadoc) + * @see javax.ws.rs.container.ContainerResponseFilter#filter(javax.ws.rs.container.ContainerRequestContext, javax.ws.rs.container.ContainerResponseContext) + */ + @Override + public void filter(ContainerRequestContext requestContext, + ContainerResponseContext responseContext) throws IOException { + final String method = requestContext.getMethod(); + + logger.debug("Requesting " + method + " for path " + requestContext.getUriInfo().getPath()); + final Object entity = responseContext.getEntity(); + if (entity != null) { + logger.debug("Response " + new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(entity)); + } + } + } \ No newline at end of file diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ConfigurationResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ConfigurationResource.java index d193c250..82f2a5b8 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ConfigurationResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ConfigurationResource.java @@ -1,64 +1,64 @@ -package cz.cuni.mff.xrg.odalic.api.rest.resources; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.api.rest.values.ConfigurationValue; -import cz.cuni.mff.xrg.odalic.files.File; -import cz.cuni.mff.xrg.odalic.files.FileService; -import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; -import cz.cuni.mff.xrg.odalic.tasks.configurations.ConfigurationService; - -@Component -@Path("/tasks/{id}/configuration") -public final class ConfigurationResource { - - private final ConfigurationService configurationService; - private final FileService fileService; - - @Autowired - public ConfigurationResource(ConfigurationService configurationService, FileService fileService) { - Preconditions.checkNotNull(configurationService); - Preconditions.checkNotNull(fileService); - - this.configurationService = configurationService; - this.fileService = fileService; - } - - @PUT - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response putConfigurationForTaskId(@PathParam("id") String id, - ConfigurationValue configurationValue) { - final File input = fileService.getById(configurationValue.getInput()); - - final Configuration configuration; - if (configurationValue.getFeedback() == null) { - configuration = new Configuration(input, configurationValue.getPrimaryBase()); - } else { - configuration = new Configuration(input, configurationValue.getPrimaryBase(), configurationValue.getFeedback()); - } - - configurationService.setForTaskId(id, configuration); - return Response.status(Response.Status.OK).entity("Configuration set.").build(); - } - - @GET - @Produces(MediaType.APPLICATION_JSON) - public Response getConfigurationForTaskId(@PathParam("id") String taskId) { - Configuration configurationForTaskId = configurationService.getForTaskId(taskId); - - return Response.status(Response.Status.OK).entity(configurationForTaskId).build(); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.resources; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.values.ConfigurationValue; +import cz.cuni.mff.xrg.odalic.files.File; +import cz.cuni.mff.xrg.odalic.files.FileService; +import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; +import cz.cuni.mff.xrg.odalic.tasks.configurations.ConfigurationService; + +@Component +@Path("/tasks/{id}/configuration") +public final class ConfigurationResource { + + private final ConfigurationService configurationService; + private final FileService fileService; + + @Autowired + public ConfigurationResource(ConfigurationService configurationService, FileService fileService) { + Preconditions.checkNotNull(configurationService); + Preconditions.checkNotNull(fileService); + + this.configurationService = configurationService; + this.fileService = fileService; + } + + @PUT + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response putConfigurationForTaskId(@PathParam("id") String id, + ConfigurationValue configurationValue) { + final File input = fileService.getById(configurationValue.getInput()); + + final Configuration configuration; + if (configurationValue.getFeedback() == null) { + configuration = new Configuration(input, configurationValue.getPrimaryBase()); + } else { + configuration = new Configuration(input, configurationValue.getPrimaryBase(), configurationValue.getFeedback()); + } + + configurationService.setForTaskId(id, configuration); + return Response.status(Response.Status.OK).entity("Configuration set.").build(); + } + + @GET + @Produces(MediaType.APPLICATION_JSON) + public Response getConfigurationForTaskId(@PathParam("id") String taskId) { + Configuration configurationForTaskId = configurationService.getForTaskId(taskId); + + return Response.status(Response.Status.OK).entity(configurationForTaskId).build(); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ExecutionResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ExecutionResource.java index d6e62b85..59d28cda 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ExecutionResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ExecutionResource.java @@ -1,48 +1,48 @@ -package cz.cuni.mff.xrg.odalic.api.rest.resources; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.api.rest.values.ExecutionValue; -import cz.cuni.mff.xrg.odalic.tasks.executions.ExecutionService; - -@Component -@Path("/tasks/{id}/execution") -public final class ExecutionResource { - - private ExecutionService executionService; - - @Autowired - public ExecutionResource(ExecutionService executionService) { - Preconditions.checkNotNull(executionService); - - this.executionService = executionService; - } - - @PUT - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response putExecutionForTaskId(@PathParam("id") String id, ExecutionValue execution) { - executionService.submitForTaskId(id); - return Response.status(Response.Status.OK).entity("Execution submitted.").build(); - } - - @DELETE - @Produces({MediaType.APPLICATION_JSON}) - public Response deleteExecutionForTaskId(@PathParam("id") String id) { - executionService.cancelForTaskId(id); - return Response.status(Response.Status.OK) - .entity("Execution canceled.").build(); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.resources; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.values.ExecutionValue; +import cz.cuni.mff.xrg.odalic.tasks.executions.ExecutionService; + +@Component +@Path("/tasks/{id}/execution") +public final class ExecutionResource { + + private ExecutionService executionService; + + @Autowired + public ExecutionResource(ExecutionService executionService) { + Preconditions.checkNotNull(executionService); + + this.executionService = executionService; + } + + @PUT + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response putExecutionForTaskId(@PathParam("id") String id, ExecutionValue execution) { + executionService.submitForTaskId(id); + return Response.status(Response.Status.OK).entity("Execution submitted.").build(); + } + + @DELETE + @Produces({MediaType.APPLICATION_JSON}) + public Response deleteExecutionForTaskId(@PathParam("id") String id) { + executionService.cancelForTaskId(id); + return Response.status(Response.Status.OK) + .entity("Execution canceled.").build(); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FeedbackResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FeedbackResource.java index 733e0c11..0ed6d85c 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FeedbackResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FeedbackResource.java @@ -1,58 +1,58 @@ -package cz.cuni.mff.xrg.odalic.api.rest.resources; - -import java.io.IOException; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; -import cz.cuni.mff.xrg.odalic.input.Input; -import cz.cuni.mff.xrg.odalic.tasks.feedbacks.FeedbackService; - -@Component -@Path("/tasks/{id}/configuration/feedback") -public final class FeedbackResource { - - private final FeedbackService feedbackService; - - @Autowired - public FeedbackResource(FeedbackService feedbackService) { - Preconditions.checkNotNull(feedbackService); - - this.feedbackService = feedbackService; - } - - @PUT - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response putFeedbackForTaskId(@PathParam("id") String id, Feedback feedback) { - feedbackService.setForTaskId(id, feedback); - return Response.status(Response.Status.OK).entity("Feedback set.").build(); - } - - @GET - @Produces(MediaType.APPLICATION_JSON) - public Response getFeedbackForTaskId(@PathParam("id") String taskId) { - Feedback feedbackForTaskId = feedbackService.getForTaskId(taskId); - - return Response.status(Response.Status.OK).entity(feedbackForTaskId).build(); - } - - @GET - @Path("/input") - @Produces(MediaType.APPLICATION_JSON) - public Input getJsonDataById(@PathParam("id") String id) throws IOException { - return feedbackService.getInputForTaskId(id); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.resources; + +import java.io.IOException; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; +import cz.cuni.mff.xrg.odalic.input.Input; +import cz.cuni.mff.xrg.odalic.tasks.feedbacks.FeedbackService; + +@Component +@Path("/tasks/{id}/configuration/feedback") +public final class FeedbackResource { + + private final FeedbackService feedbackService; + + @Autowired + public FeedbackResource(FeedbackService feedbackService) { + Preconditions.checkNotNull(feedbackService); + + this.feedbackService = feedbackService; + } + + @PUT + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response putFeedbackForTaskId(@PathParam("id") String id, Feedback feedback) { + feedbackService.setForTaskId(id, feedback); + return Response.status(Response.Status.OK).entity("Feedback set.").build(); + } + + @GET + @Produces(MediaType.APPLICATION_JSON) + public Response getFeedbackForTaskId(@PathParam("id") String taskId) { + Feedback feedbackForTaskId = feedbackService.getForTaskId(taskId); + + return Response.status(Response.Status.OK).entity(feedbackForTaskId).build(); + } + + @GET + @Path("/input") + @Produces(MediaType.APPLICATION_JSON) + public Input getJsonDataById(@PathParam("id") String id) throws IOException { + return feedbackService.getInputForTaskId(id); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java index aaf7f75b..5d0207ce 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/FileResource.java @@ -1,165 +1,165 @@ -package cz.cuni.mff.xrg.odalic.api.rest.resources; - -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.List; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; - -import org.glassfish.jersey.media.multipart.FormDataContentDisposition; -import org.glassfish.jersey.media.multipart.FormDataParam; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.files.File; -import cz.cuni.mff.xrg.odalic.files.FileService; - -/** - * File resource definition. - * - * @author Václav Brodec - */ -@Component -@Path("/files") -public final class FileResource { - - public static final String TEXT_CSV_MEDIA_TYPE = "text/csv"; - - private final FileService fileService; - - @Autowired - public FileResource(FileService fileService) { - Preconditions.checkNotNull(fileService); - - this.fileService = fileService; - } - - @GET - @Produces(MediaType.APPLICATION_JSON) - public List getFiles() { - return fileService.getFiles(); - } - - @GET - @Path("{id}") - @Produces(MediaType.APPLICATION_JSON) - public Response getFileById(@PathParam("id") String id) { - File file = fileService.getById(id); - return Response.status(Response.Status.OK).entity(file).build(); - } - - @PUT - @Path("{id}") - @Consumes(MediaType.MULTIPART_FORM_DATA) - @Produces(MediaType.APPLICATION_JSON) - public Response putFileById(@Context UriInfo uriInfo, @PathParam("id") String id, - @FormDataParam("input") InputStream fileInputStream, @FormDataParam("file") File file) - throws IOException { - - if (!fileService.hasId(file, id)) { - return Response.status(Response.Status.NOT_ACCEPTABLE) - .entity("The ID in the payload is not the same as the ID of resource.").build(); - } - - if (!file.getLocation().equals(cz.cuni.mff.xrg.odalic.util.URL.getSubResourceAbsolutePath(uriInfo, id))) { - return Response.status(Response.Status.NOT_ACCEPTABLE) - .entity( - "The location you provided for the file is not equal to the default location for uploaded file.") - .build(); - } - - final URL location = file.getLocation(); - - if (!fileService.existsFileWithId(id)) { - fileService.create(file, fileInputStream); - - return Response.status(Response.Status.CREATED) - .entity("A new file has been created AT THE STANDARD LOCATION.") - .header("Location", location).build(); - } else { - fileService.replace(file); - return Response.status(Response.Status.OK) - .entity("The file you specified has been fully updated AT THE STANDARD LOCATION.") - .header("Location", location).build(); - } - } - - @PUT - @Path("{id}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response putFileById(@PathParam("id") String id, File file) throws MalformedURLException { - - if (!fileService.hasId(file, id)) { - return Response.status(Response.Status.NOT_ACCEPTABLE) - .entity("The ID in the payload is not the same as the ID of resource.").build(); - } - - final URL location = file.getLocation(); - - if (!fileService.existsFileWithId(id)) { - fileService.create(file); - return Response.status(Response.Status.CREATED) - .entity("A new file has been registered FOR THE LOCATION you specified") - .header("Location", location).build(); - } else { - fileService.replace(file); - return Response.status(Response.Status.OK) - .entity( - "The file description you specified has been fully updated FOR THE LOCATION you specified.") - .header("Location", location).build(); - } - } - - @POST - @Consumes(MediaType.MULTIPART_FORM_DATA) - @Produces(MediaType.APPLICATION_JSON) - public Response postFile(@Context UriInfo uriInfo, - @FormDataParam("file") InputStream fileInputStream, - @FormDataParam("file") FormDataContentDisposition fileDetail) throws IOException { - - final String id = fileDetail.getFileName(); - final File file = new File(id, "", cz.cuni.mff.xrg.odalic.util.URL.getSubResourceAbsolutePath(uriInfo, id)); - - if (fileService.existsFileWithId(id)) { - return Response.status(Response.Status.NOT_ACCEPTABLE) - .entity("There already exists a file with the same name as you provided.").build(); - } - - fileService.create(file, fileInputStream); - return Response.status(Response.Status.CREATED) - .entity("A new file has been registered AT THE LOCATION DERIVED from the name of the one uploaded.") - .header("Location", file.getLocation()).build(); - } - - @DELETE - @Path("{id}") - public Response deleteFileById(@PathParam("id") String id) { - fileService.deleteById(id); - return Response.status(Response.Status.NO_CONTENT).build(); - } - - @GET - @Path("{id}") - @Produces(TEXT_CSV_MEDIA_TYPE) - public Response getCsvDataById(@PathParam("id") String id) throws IOException { - String data = fileService.getDataById(id); - - return Response.ok(data).build(); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.resources; + +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.List; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; + +import org.glassfish.jersey.media.multipart.FormDataContentDisposition; +import org.glassfish.jersey.media.multipart.FormDataParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.files.File; +import cz.cuni.mff.xrg.odalic.files.FileService; + +/** + * File resource definition. + * + * @author Václav Brodec + */ +@Component +@Path("/files") +public final class FileResource { + + public static final String TEXT_CSV_MEDIA_TYPE = "text/csv"; + + private final FileService fileService; + + @Autowired + public FileResource(FileService fileService) { + Preconditions.checkNotNull(fileService); + + this.fileService = fileService; + } + + @GET + @Produces(MediaType.APPLICATION_JSON) + public List getFiles() { + return fileService.getFiles(); + } + + @GET + @Path("{id}") + @Produces(MediaType.APPLICATION_JSON) + public Response getFileById(@PathParam("id") String id) { + File file = fileService.getById(id); + return Response.status(Response.Status.OK).entity(file).build(); + } + + @PUT + @Path("{id}") + @Consumes(MediaType.MULTIPART_FORM_DATA) + @Produces(MediaType.APPLICATION_JSON) + public Response putFileById(@Context UriInfo uriInfo, @PathParam("id") String id, + @FormDataParam("input") InputStream fileInputStream, @FormDataParam("file") File file) + throws IOException { + + if (!fileService.hasId(file, id)) { + return Response.status(Response.Status.NOT_ACCEPTABLE) + .entity("The ID in the payload is not the same as the ID of resource.").build(); + } + + if (!file.getLocation().equals(cz.cuni.mff.xrg.odalic.util.URL.getSubResourceAbsolutePath(uriInfo, id))) { + return Response.status(Response.Status.NOT_ACCEPTABLE) + .entity( + "The location you provided for the file is not equal to the default location for uploaded file.") + .build(); + } + + final URL location = file.getLocation(); + + if (!fileService.existsFileWithId(id)) { + fileService.create(file, fileInputStream); + + return Response.status(Response.Status.CREATED) + .entity("A new file has been created AT THE STANDARD LOCATION.") + .header("Location", location).build(); + } else { + fileService.replace(file); + return Response.status(Response.Status.OK) + .entity("The file you specified has been fully updated AT THE STANDARD LOCATION.") + .header("Location", location).build(); + } + } + + @PUT + @Path("{id}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response putFileById(@PathParam("id") String id, File file) throws MalformedURLException { + + if (!fileService.hasId(file, id)) { + return Response.status(Response.Status.NOT_ACCEPTABLE) + .entity("The ID in the payload is not the same as the ID of resource.").build(); + } + + final URL location = file.getLocation(); + + if (!fileService.existsFileWithId(id)) { + fileService.create(file); + return Response.status(Response.Status.CREATED) + .entity("A new file has been registered FOR THE LOCATION you specified") + .header("Location", location).build(); + } else { + fileService.replace(file); + return Response.status(Response.Status.OK) + .entity( + "The file description you specified has been fully updated FOR THE LOCATION you specified.") + .header("Location", location).build(); + } + } + + @POST + @Consumes(MediaType.MULTIPART_FORM_DATA) + @Produces(MediaType.APPLICATION_JSON) + public Response postFile(@Context UriInfo uriInfo, + @FormDataParam("file") InputStream fileInputStream, + @FormDataParam("file") FormDataContentDisposition fileDetail) throws IOException { + + final String id = fileDetail.getFileName(); + final File file = new File(id, "", cz.cuni.mff.xrg.odalic.util.URL.getSubResourceAbsolutePath(uriInfo, id)); + + if (fileService.existsFileWithId(id)) { + return Response.status(Response.Status.NOT_ACCEPTABLE) + .entity("There already exists a file with the same name as you provided.").build(); + } + + fileService.create(file, fileInputStream); + return Response.status(Response.Status.CREATED) + .entity("A new file has been registered AT THE LOCATION DERIVED from the name of the one uploaded.") + .header("Location", file.getLocation()).build(); + } + + @DELETE + @Path("{id}") + public Response deleteFileById(@PathParam("id") String id) { + fileService.deleteById(id); + return Response.status(Response.Status.NO_CONTENT).build(); + } + + @GET + @Path("{id}") + @Produces(TEXT_CSV_MEDIA_TYPE) + public Response getCsvDataById(@PathParam("id") String id) throws IOException { + String data = fileService.getDataById(id); + + return Response.ok(data).build(); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ResultResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ResultResource.java index 4b72d2e2..a7565caf 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ResultResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/ResultResource.java @@ -1,48 +1,48 @@ -package cz.cuni.mff.xrg.odalic.api.rest.resources; - -import java.util.concurrent.ExecutionException; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.tasks.executions.ExecutionService; - -/** - * Result resource definition. - * - * @author Václav Brodec - * - */ -@Component -@Path("/tasks/{id}/result") -public final class ResultResource { - - private final ExecutionService executionService; - - @Autowired - public ResultResource(ExecutionService executionService) { - Preconditions.checkNotNull(executionService); - - this.executionService = executionService; - } - - @GET - @Produces(MediaType.APPLICATION_JSON) - public Response getResult(@PathParam("id") String taskId) throws InterruptedException, ExecutionException { - if (executionService.isCanceledForTaskId(taskId)) { - return Response.status(Response.Status.NOT_FOUND).entity("The execution was canceled.") - .build(); - } - - return Response.ok(executionService.getResultForTaskId(taskId)).build(); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.resources; + +import java.util.concurrent.ExecutionException; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.tasks.executions.ExecutionService; + +/** + * Result resource definition. + * + * @author Václav Brodec + * + */ +@Component +@Path("/tasks/{id}/result") +public final class ResultResource { + + private final ExecutionService executionService; + + @Autowired + public ResultResource(ExecutionService executionService) { + Preconditions.checkNotNull(executionService); + + this.executionService = executionService; + } + + @GET + @Produces(MediaType.APPLICATION_JSON) + public Response getResult(@PathParam("id") String taskId) throws InterruptedException, ExecutionException { + if (executionService.isCanceledForTaskId(taskId)) { + return Response.status(Response.Status.NOT_FOUND).entity("The execution was canceled.") + .build(); + } + + return Response.ok(executionService.getResultForTaskId(taskId)).build(); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/StateResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/StateResource.java index 26694bcf..de5285b3 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/StateResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/StateResource.java @@ -1,56 +1,56 @@ -package cz.cuni.mff.xrg.odalic.api.rest.resources; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.api.rest.values.StateValue; -import cz.cuni.mff.xrg.odalic.tasks.executions.ExecutionService; - -/** - * State resource definition. - * - * @author Václav Brodec - * - */ -@Component -@Path("/tasks/{id}/state") -public final class StateResource { - - private final ExecutionService executionService; - - @Autowired - public StateResource(ExecutionService executionService) { - Preconditions.checkNotNull(executionService); - - this.executionService = executionService; - } - - @GET - @Produces({MediaType.APPLICATION_JSON}) - public StateValue getStateForTaskId(@PathParam("id") String id) { - final boolean scheduled = executionService.hasBeenScheduledForTaskId(id); - if (!scheduled) { - return StateValue.READY; - } - - final boolean done = executionService.isDoneForTaskId(id); - final boolean canceled = executionService.isCanceledForTaskId(id); - - if (done) { - if (canceled) { - return StateValue.CANCELLED; - } else { - return StateValue.FINISHED; - } - } else { - return StateValue.SCHEDULED; - } - } -} +package cz.cuni.mff.xrg.odalic.api.rest.resources; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.values.StateValue; +import cz.cuni.mff.xrg.odalic.tasks.executions.ExecutionService; + +/** + * State resource definition. + * + * @author Václav Brodec + * + */ +@Component +@Path("/tasks/{id}/state") +public final class StateResource { + + private final ExecutionService executionService; + + @Autowired + public StateResource(ExecutionService executionService) { + Preconditions.checkNotNull(executionService); + + this.executionService = executionService; + } + + @GET + @Produces({MediaType.APPLICATION_JSON}) + public StateValue getStateForTaskId(@PathParam("id") String id) { + final boolean scheduled = executionService.hasBeenScheduledForTaskId(id); + if (!scheduled) { + return StateValue.READY; + } + + final boolean done = executionService.isDoneForTaskId(id); + final boolean canceled = executionService.isCanceledForTaskId(id); + + if (done) { + if (canceled) { + return StateValue.CANCELLED; + } else { + return StateValue.FINISHED; + } + } else { + return StateValue.SCHEDULED; + } + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/TaskResource.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/TaskResource.java index f39b1a5d..9eab7ef7 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/TaskResource.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/resources/TaskResource.java @@ -1,103 +1,103 @@ -package cz.cuni.mff.xrg.odalic.api.rest.resources; - -import java.net.MalformedURLException; -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.api.rest.values.ConfigurationValue; -import cz.cuni.mff.xrg.odalic.api.rest.values.TaskValue; -import cz.cuni.mff.xrg.odalic.files.File; -import cz.cuni.mff.xrg.odalic.files.FileService; -import cz.cuni.mff.xrg.odalic.tasks.Task; -import cz.cuni.mff.xrg.odalic.tasks.TaskService; -import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; - -/** - * Task resource definition. - * - * @author Václav Brodec - */ -@Component -@Path("/tasks") -public final class TaskResource { - - private final TaskService taskService; - private final FileService fileService; - - @Autowired - public TaskResource(TaskService taskService, FileService fileService) { - Preconditions.checkNotNull(taskService); - Preconditions.checkNotNull(fileService); - - this.taskService = taskService; - this.fileService = fileService; - } - - @GET - @Produces(MediaType.APPLICATION_JSON) - public Set getTasks() { - return taskService.getTasks(); - } - - @GET - @Path("{id}") - @Produces(MediaType.APPLICATION_JSON) - public Response getTaskById(@PathParam("id") String id) { - Task task = taskService.getById(id); - return Response.status(Response.Status.OK).entity(task).build(); - } - - @PUT - @Path("{id}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response putTaskWithId(@Context UriInfo uriInfo, @PathParam("id") String id, TaskValue taskValue) throws MalformedURLException { - final ConfigurationValue configurationValue = taskValue.getConfiguration(); - final File input = fileService.getById(configurationValue.getInput()); - final Configuration configuration = new Configuration(input, configurationValue.getPrimaryBase(), configurationValue.getFeedback()); - final Task task = new Task(taskValue.getId(), taskValue.getCreated(), configuration); - - if (!taskService.hasId(task, id)) { - return Response.status(Response.Status.NOT_ACCEPTABLE) - .entity("The ID in the payload is not the same as the ID of resource.").build(); - } - - Task taskById = taskService.verifyTaskExistenceById(id); - - if (taskById == null) { - taskService.create(task); - return Response.status(Response.Status.CREATED) - .entity("A new task has been created AT THE LOCATION you specified") - .header("Location", cz.cuni.mff.xrg.odalic.util.URL.getSubResourceAbsolutePath(uriInfo, id)).build(); - } else { - taskService.replace(task); - return Response.status(Response.Status.OK) - .entity( - "The task you specified has been fully updated AT THE LOCATION you specified.") - .header("Location", cz.cuni.mff.xrg.odalic.util.URL.getSubResourceAbsolutePath(uriInfo, id)).build(); - } - } - - @DELETE - @Path("{id}") - public Response deleteTaskById(@PathParam("id") String id) { - taskService.deleteById(id); - return Response.status(Response.Status.NO_CONTENT).build(); - } -} +package cz.cuni.mff.xrg.odalic.api.rest.resources; + +import java.net.MalformedURLException; +import java.util.Set; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.values.ConfigurationValue; +import cz.cuni.mff.xrg.odalic.api.rest.values.TaskValue; +import cz.cuni.mff.xrg.odalic.files.File; +import cz.cuni.mff.xrg.odalic.files.FileService; +import cz.cuni.mff.xrg.odalic.tasks.Task; +import cz.cuni.mff.xrg.odalic.tasks.TaskService; +import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; + +/** + * Task resource definition. + * + * @author Václav Brodec + */ +@Component +@Path("/tasks") +public final class TaskResource { + + private final TaskService taskService; + private final FileService fileService; + + @Autowired + public TaskResource(TaskService taskService, FileService fileService) { + Preconditions.checkNotNull(taskService); + Preconditions.checkNotNull(fileService); + + this.taskService = taskService; + this.fileService = fileService; + } + + @GET + @Produces(MediaType.APPLICATION_JSON) + public Set getTasks() { + return taskService.getTasks(); + } + + @GET + @Path("{id}") + @Produces(MediaType.APPLICATION_JSON) + public Response getTaskById(@PathParam("id") String id) { + Task task = taskService.getById(id); + return Response.status(Response.Status.OK).entity(task).build(); + } + + @PUT + @Path("{id}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response putTaskWithId(@Context UriInfo uriInfo, @PathParam("id") String id, TaskValue taskValue) throws MalformedURLException { + final ConfigurationValue configurationValue = taskValue.getConfiguration(); + final File input = fileService.getById(configurationValue.getInput()); + final Configuration configuration = new Configuration(input, configurationValue.getPrimaryBase(), configurationValue.getFeedback()); + final Task task = new Task(taskValue.getId(), taskValue.getCreated(), configuration); + + if (!taskService.hasId(task, id)) { + return Response.status(Response.Status.NOT_ACCEPTABLE) + .entity("The ID in the payload is not the same as the ID of resource.").build(); + } + + Task taskById = taskService.verifyTaskExistenceById(id); + + if (taskById == null) { + taskService.create(task); + return Response.status(Response.Status.CREATED) + .entity("A new task has been created AT THE LOCATION you specified") + .header("Location", cz.cuni.mff.xrg.odalic.util.URL.getSubResourceAbsolutePath(uriInfo, id)).build(); + } else { + taskService.replace(task); + return Response.status(Response.Status.OK) + .entity( + "The task you specified has been fully updated AT THE LOCATION you specified.") + .header("Location", cz.cuni.mff.xrg.odalic.util.URL.getSubResourceAbsolutePath(uriInfo, id)).build(); + } + } + + @DELETE + @Path("{id}") + public Response deleteTaskById(@PathParam("id") String id) { + taskService.deleteById(id); + return Response.status(Response.Status.NO_CONTENT).build(); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/AmbiguityValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/AmbiguityValue.java index 1030e76c..d965d203 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/AmbiguityValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/AmbiguityValue.java @@ -1,58 +1,58 @@ -package cz.cuni.mff.xrg.odalic.api.rest.values; - -import java.io.Serializable; - -import javax.annotation.Nullable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.feedbacks.Ambiguity; -import cz.cuni.mff.xrg.odalic.positions.CellPosition; - -/** - * Domain class {@link Ambiguity} adapted for REST API. - * - * @author Václav Brodec - * - */ -@XmlRootElement(name = "ambiguity") -public final class AmbiguityValue implements Serializable { - - private static final long serialVersionUID = -9087389821835847372L; - - @XmlElement - private CellPosition position; - - public AmbiguityValue() {} - - public AmbiguityValue(Ambiguity adaptee) { - this.position = adaptee.getPosition(); - } - - /** - * @return the position - */ - @Nullable - public CellPosition getPosition() { - return position; - } - - /** - * @param position the position to set - */ - public void setPosition(CellPosition position) { - Preconditions.checkNotNull(position); - - this.position = position; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "AmbiguityValue [position=" + position + "]"; - } -} +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.feedbacks.Ambiguity; +import cz.cuni.mff.xrg.odalic.positions.CellPosition; + +/** + * Domain class {@link Ambiguity} adapted for REST API. + * + * @author Václav Brodec + * + */ +@XmlRootElement(name = "ambiguity") +public final class AmbiguityValue implements Serializable { + + private static final long serialVersionUID = -9087389821835847372L; + + @XmlElement + private CellPosition position; + + public AmbiguityValue() {} + + public AmbiguityValue(Ambiguity adaptee) { + this.position = adaptee.getPosition(); + } + + /** + * @return the position + */ + @Nullable + public CellPosition getPosition() { + return position; + } + + /** + * @param position the position to set + */ + public void setPosition(CellPosition position) { + Preconditions.checkNotNull(position); + + this.position = position; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "AmbiguityValue [position=" + position + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellAnnotationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellAnnotationValue.java index b5741ea6..0b6b3fca 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellAnnotationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellAnnotationValue.java @@ -1,102 +1,102 @@ -package cz.cuni.mff.xrg.odalic.api.rest.values; - -import java.util.Map; -import java.util.NavigableSet; -import java.util.Set; -import java.util.stream.Stream; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSortedSet; - -import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonDeserializer; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonSerializer; -import cz.cuni.mff.xrg.odalic.tasks.annotations.CellAnnotation; -import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; -import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; - -/** - *

- * Domain class {@link CellAnnotation} adapted for REST API. - *

- * - *

- * In contrast to the adapted class, annotation in this version have only one set of candidates and - * the chosen ones are indicated by flags on each element. - *

- * - * @author Václav Brodec - * - */ -@XmlRootElement(name = "cellAnnotation") -public final class CellAnnotationValue { - - @XmlElement - @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) - @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) - private Map> candidates; - - public CellAnnotationValue() { - candidates = ImmutableMap.of(); - } - - /** - * @param entities - */ - public CellAnnotationValue(CellAnnotation adaptee) { - final Map> chosen = adaptee.getChosen(); - - final ImmutableMap.Builder> candidatesBuilder = - ImmutableMap.builder(); - for (final Map.Entry> entry : adaptee - .getCandidates().entrySet()) { - final KnowledgeBase base = entry.getKey(); - final Set baseChosen = chosen.get(base); - final NavigableSet baseCandidates = entry.getValue(); - - final Stream stream = - baseCandidates.stream().map(e -> new EntityCandidateValue(e, baseChosen.contains(e))); - candidatesBuilder.put(entry.getKey(), ImmutableSortedSet.copyOf(stream.iterator())); - } - - this.candidates = candidatesBuilder.build(); - } - - /** - * @return the candidates - */ - public Map> getCandidates() { - return candidates; - } - - /** - * @param candidates the candidates to set - */ - public void setCandidates( - Map> candidates) { - ImmutableMap.Builder> candidatesBuilder = - ImmutableMap.builder(); - for (final Map.Entry> candidateEntry : candidates - .entrySet()) { - candidatesBuilder.put(candidateEntry.getKey(), - ImmutableSortedSet.copyOf(candidateEntry.getValue())); - } - - this.candidates = candidatesBuilder.build(); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "CellAnnotationValue [candidates=" + candidates + "]"; - } -} +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.util.Map; +import java.util.NavigableSet; +import java.util.Set; +import java.util.stream.Stream; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSortedSet; + +import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonDeserializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonSerializer; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; + +/** + *

+ * Domain class {@link CellAnnotation} adapted for REST API. + *

+ * + *

+ * In contrast to the adapted class, annotation in this version have only one set of candidates and + * the chosen ones are indicated by flags on each element. + *

+ * + * @author Václav Brodec + * + */ +@XmlRootElement(name = "cellAnnotation") +public final class CellAnnotationValue { + + @XmlElement + @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) + @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) + private Map> candidates; + + public CellAnnotationValue() { + candidates = ImmutableMap.of(); + } + + /** + * @param entities + */ + public CellAnnotationValue(CellAnnotation adaptee) { + final Map> chosen = adaptee.getChosen(); + + final ImmutableMap.Builder> candidatesBuilder = + ImmutableMap.builder(); + for (final Map.Entry> entry : adaptee + .getCandidates().entrySet()) { + final KnowledgeBase base = entry.getKey(); + final Set baseChosen = chosen.get(base); + final NavigableSet baseCandidates = entry.getValue(); + + final Stream stream = + baseCandidates.stream().map(e -> new EntityCandidateValue(e, baseChosen.contains(e))); + candidatesBuilder.put(entry.getKey(), ImmutableSortedSet.copyOf(stream.iterator())); + } + + this.candidates = candidatesBuilder.build(); + } + + /** + * @return the candidates + */ + public Map> getCandidates() { + return candidates; + } + + /** + * @param candidates the candidates to set + */ + public void setCandidates( + Map> candidates) { + ImmutableMap.Builder> candidatesBuilder = + ImmutableMap.builder(); + for (final Map.Entry> candidateEntry : candidates + .entrySet()) { + candidatesBuilder.put(candidateEntry.getKey(), + ImmutableSortedSet.copyOf(candidateEntry.getValue())); + } + + this.candidates = candidatesBuilder.build(); + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "CellAnnotationValue [candidates=" + candidates + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellPositionValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellPositionValue.java index eb426fbc..4fcfa6cc 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellPositionValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellPositionValue.java @@ -1,80 +1,80 @@ -package cz.cuni.mff.xrg.odalic.api.rest.values; - -import javax.annotation.Nullable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.positions.CellPosition; -import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; -import cz.cuni.mff.xrg.odalic.positions.RowPosition; - -/** - * Domain class {@link CellPosition} adapted for REST API. - * - * @author Václav Brodec - * - */ -@XmlRootElement(name = "cellPosition") -public class CellPositionValue { - - @XmlElement - private RowPosition rowPosition; - - @XmlElement - private ColumnPosition columnPosition; - - public CellPositionValue() {} - - /** - * @param adaptee - */ - public CellPositionValue(CellPosition adaptee) { - this.columnPosition = adaptee.getColumnPosition(); - this.rowPosition = adaptee.getRowPosition(); - } - - /** - * @return the rowPosition - */ - @Nullable - public RowPosition getRowPosition() { - return rowPosition; - } - - /** - * @param rowPosition the rowPosition to set - */ - public void setRowPosition(RowPosition rowPosition) { - Preconditions.checkNotNull(rowPosition); - - this.rowPosition = rowPosition; - } - - /** - * @return the columnPosition - */ - @Nullable - public ColumnPosition getColumnPosition() { - return columnPosition; - } - - /** - * @param columnPosition the columnPosition to set - */ - public void setColumnPosition(ColumnPosition columnPosition) { - Preconditions.checkNotNull(columnPosition); - - this.columnPosition = columnPosition; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "CellPositionValue [rowPosition=" + rowPosition + ", columnPosition=" + columnPosition - + "]"; - } -} +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.positions.CellPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.positions.RowPosition; + +/** + * Domain class {@link CellPosition} adapted for REST API. + * + * @author Václav Brodec + * + */ +@XmlRootElement(name = "cellPosition") +public class CellPositionValue { + + @XmlElement + private RowPosition rowPosition; + + @XmlElement + private ColumnPosition columnPosition; + + public CellPositionValue() {} + + /** + * @param adaptee + */ + public CellPositionValue(CellPosition adaptee) { + this.columnPosition = adaptee.getColumnPosition(); + this.rowPosition = adaptee.getRowPosition(); + } + + /** + * @return the rowPosition + */ + @Nullable + public RowPosition getRowPosition() { + return rowPosition; + } + + /** + * @param rowPosition the rowPosition to set + */ + public void setRowPosition(RowPosition rowPosition) { + Preconditions.checkNotNull(rowPosition); + + this.rowPosition = rowPosition; + } + + /** + * @return the columnPosition + */ + @Nullable + public ColumnPosition getColumnPosition() { + return columnPosition; + } + + /** + * @param columnPosition the columnPosition to set + */ + public void setColumnPosition(ColumnPosition columnPosition) { + Preconditions.checkNotNull(columnPosition); + + this.columnPosition = columnPosition; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "CellPositionValue [rowPosition=" + rowPosition + ", columnPosition=" + columnPosition + + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationAnnotationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationAnnotationValue.java index f772c16c..8c4c4a8d 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationAnnotationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationAnnotationValue.java @@ -1,102 +1,102 @@ -package cz.cuni.mff.xrg.odalic.api.rest.values; - -import java.util.Map; -import java.util.NavigableSet; -import java.util.Set; -import java.util.stream.Stream; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSortedSet; - -import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonDeserializer; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonSerializer; -import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; -import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; -import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; - -/** - *

- * Domain class {@link CellRelationAnnotation} adapted for REST API. - *

- * - *

- * In contrast to the adapted class, annotation in this version have only one set of candidates and - * the chosen ones are indicated by flags on each element. - *

- * - * @author Václav Brodec - * - */ -@XmlRootElement(name = "cellRelationAnnotation") -public final class CellRelationAnnotationValue { - - @XmlElement - @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) - @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) - private Map> candidates; - - public CellRelationAnnotationValue() { - candidates = ImmutableMap.of(); - } - - /** - * @param entities - */ - public CellRelationAnnotationValue(CellRelationAnnotation adaptee) { - final Map> chosen = adaptee.getChosen(); - - final ImmutableMap.Builder> candidatesBuilder = - ImmutableMap.builder(); - for (final Map.Entry> entry : adaptee - .getCandidates().entrySet()) { - final KnowledgeBase base = entry.getKey(); - final Set baseChosen = chosen.get(base); - final NavigableSet baseCandidates = entry.getValue(); - - final Stream stream = - baseCandidates.stream().map(e -> new EntityCandidateValue(e, baseChosen.contains(e))); - candidatesBuilder.put(entry.getKey(), ImmutableSortedSet.copyOf(stream.iterator())); - } - - this.candidates = candidatesBuilder.build(); - } - - /** - * @return the candidates - */ - public Map> getCandidates() { - return candidates; - } - - /** - * @param candidates the candidates to set - */ - public void setCandidates( - Map> candidates) { - ImmutableMap.Builder> candidatesBuilder = - ImmutableMap.builder(); - for (final Map.Entry> candidateEntry : candidates - .entrySet()) { - candidatesBuilder.put(candidateEntry.getKey(), - ImmutableSortedSet.copyOf(candidateEntry.getValue())); - } - - this.candidates = candidatesBuilder.build(); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "CellRelationAnnotationValue [candidates=" + candidates + "]"; - } -} +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.util.Map; +import java.util.NavigableSet; +import java.util.Set; +import java.util.stream.Stream; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSortedSet; + +import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonDeserializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonSerializer; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; + +/** + *

+ * Domain class {@link CellRelationAnnotation} adapted for REST API. + *

+ * + *

+ * In contrast to the adapted class, annotation in this version have only one set of candidates and + * the chosen ones are indicated by flags on each element. + *

+ * + * @author Václav Brodec + * + */ +@XmlRootElement(name = "cellRelationAnnotation") +public final class CellRelationAnnotationValue { + + @XmlElement + @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) + @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) + private Map> candidates; + + public CellRelationAnnotationValue() { + candidates = ImmutableMap.of(); + } + + /** + * @param entities + */ + public CellRelationAnnotationValue(CellRelationAnnotation adaptee) { + final Map> chosen = adaptee.getChosen(); + + final ImmutableMap.Builder> candidatesBuilder = + ImmutableMap.builder(); + for (final Map.Entry> entry : adaptee + .getCandidates().entrySet()) { + final KnowledgeBase base = entry.getKey(); + final Set baseChosen = chosen.get(base); + final NavigableSet baseCandidates = entry.getValue(); + + final Stream stream = + baseCandidates.stream().map(e -> new EntityCandidateValue(e, baseChosen.contains(e))); + candidatesBuilder.put(entry.getKey(), ImmutableSortedSet.copyOf(stream.iterator())); + } + + this.candidates = candidatesBuilder.build(); + } + + /** + * @return the candidates + */ + public Map> getCandidates() { + return candidates; + } + + /** + * @param candidates the candidates to set + */ + public void setCandidates( + Map> candidates) { + ImmutableMap.Builder> candidatesBuilder = + ImmutableMap.builder(); + for (final Map.Entry> candidateEntry : candidates + .entrySet()) { + candidatesBuilder.put(candidateEntry.getKey(), + ImmutableSortedSet.copyOf(candidateEntry.getValue())); + } + + this.candidates = candidatesBuilder.build(); + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "CellRelationAnnotationValue [candidates=" + candidates + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationPositionValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationPositionValue.java index c2b3a80f..4c905ff6 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationPositionValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationPositionValue.java @@ -1,81 +1,81 @@ -package cz.cuni.mff.xrg.odalic.api.rest.values; - -import java.io.Serializable; - -import javax.annotation.Nullable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.positions.CellRelationPosition; -import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; -import cz.cuni.mff.xrg.odalic.positions.RowPosition; - -/** - * Domain class {@link CellRelationPosition} adapted for REST API. - * - * @author Václav Brodec - * - */ -@XmlRootElement(name = "cellRelationPosition") -public class CellRelationPositionValue implements Serializable { - - private static final long serialVersionUID = 2155060933372152653L; - - @XmlElement - private RowPosition rowPosition; - - @XmlElement - private ColumnRelationPosition columnsPosition; - - public CellRelationPositionValue() {} - - public CellRelationPositionValue(CellRelationPosition adaptee) { - this.rowPosition = adaptee.getRowPosition(); - this.columnsPosition = adaptee.getColumnsPosition(); - } - - /** - * @return the rowPosition - */ - @Nullable - public RowPosition getRowPosition() { - return rowPosition; - } - - /** - * @param rowPosition the rowPosition to set - */ - public void setRowPosition(RowPosition rowPosition) { - Preconditions.checkNotNull(rowPosition); - - this.rowPosition = rowPosition; - } - - /** - * @return the columnsPosition - */ - @Nullable - public ColumnRelationPosition getColumnsPosition() { - return columnsPosition; - } - - /** - * @param columnsPosition the columnsPosition to set - */ - public void setColumnsPosition(ColumnRelationPosition columnsPosition) { - Preconditions.checkNotNull(columnsPosition); - - this.columnsPosition = columnsPosition; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "CellRelationPositionValue [rowPosition=" + rowPosition + ", columnsPosition=" - + columnsPosition + "]"; - } -} +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.positions.CellRelationPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; +import cz.cuni.mff.xrg.odalic.positions.RowPosition; + +/** + * Domain class {@link CellRelationPosition} adapted for REST API. + * + * @author Václav Brodec + * + */ +@XmlRootElement(name = "cellRelationPosition") +public class CellRelationPositionValue implements Serializable { + + private static final long serialVersionUID = 2155060933372152653L; + + @XmlElement + private RowPosition rowPosition; + + @XmlElement + private ColumnRelationPosition columnsPosition; + + public CellRelationPositionValue() {} + + public CellRelationPositionValue(CellRelationPosition adaptee) { + this.rowPosition = adaptee.getRowPosition(); + this.columnsPosition = adaptee.getColumnsPosition(); + } + + /** + * @return the rowPosition + */ + @Nullable + public RowPosition getRowPosition() { + return rowPosition; + } + + /** + * @param rowPosition the rowPosition to set + */ + public void setRowPosition(RowPosition rowPosition) { + Preconditions.checkNotNull(rowPosition); + + this.rowPosition = rowPosition; + } + + /** + * @return the columnsPosition + */ + @Nullable + public ColumnRelationPosition getColumnsPosition() { + return columnsPosition; + } + + /** + * @param columnsPosition the columnsPosition to set + */ + public void setColumnsPosition(ColumnRelationPosition columnsPosition) { + Preconditions.checkNotNull(columnsPosition); + + this.columnsPosition = columnsPosition; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "CellRelationPositionValue [rowPosition=" + rowPosition + ", columnsPosition=" + + columnsPosition + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationValue.java index 5302855e..8f0238c9 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/CellRelationValue.java @@ -1,80 +1,80 @@ -package cz.cuni.mff.xrg.odalic.api.rest.values; - -import java.io.Serializable; - -import javax.annotation.Nullable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.feedbacks.CellRelation; -import cz.cuni.mff.xrg.odalic.positions.CellRelationPosition; -import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; - -/** - * Domain class {@link CellRelation} adapted for REST API. - * - * @author Václav Brodec - * - */ -@XmlRootElement(name = "cellRelation") -public final class CellRelationValue implements Serializable { - - private static final long serialVersionUID = -9087389821835847372L; - - @XmlElement - private CellRelationPosition position; - - @XmlElement - private CellRelationAnnotation annotation; - - public CellRelationValue() {} - - public CellRelationValue(CellRelation adaptee) { - this.position = adaptee.getPosition(); - this.annotation = adaptee.getAnnotation(); - } - - /** - * @return the position - */ - @Nullable - public CellRelationPosition getPosition() { - return position; - } - - /** - * @param position the position to set - */ - public void setPosition(CellRelationPosition position) { - Preconditions.checkNotNull(position); - - this.position = position; - } - - /** - * @return the annotation - */ - @Nullable - public CellRelationAnnotation getAnnotation() { - return annotation; - } - - /** - * @param annotation the annotation to set - */ - public void setAnnotation(CellRelationAnnotation annotation) { - Preconditions.checkNotNull(annotation); - - this.annotation = annotation; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "CellRelationValue [position=" + position + ", annotation=" + annotation + "]"; - } -} +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.feedbacks.CellRelation; +import cz.cuni.mff.xrg.odalic.positions.CellRelationPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; + +/** + * Domain class {@link CellRelation} adapted for REST API. + * + * @author Václav Brodec + * + */ +@XmlRootElement(name = "cellRelation") +public final class CellRelationValue implements Serializable { + + private static final long serialVersionUID = -9087389821835847372L; + + @XmlElement + private CellRelationPosition position; + + @XmlElement + private CellRelationAnnotation annotation; + + public CellRelationValue() {} + + public CellRelationValue(CellRelation adaptee) { + this.position = adaptee.getPosition(); + this.annotation = adaptee.getAnnotation(); + } + + /** + * @return the position + */ + @Nullable + public CellRelationPosition getPosition() { + return position; + } + + /** + * @param position the position to set + */ + public void setPosition(CellRelationPosition position) { + Preconditions.checkNotNull(position); + + this.position = position; + } + + /** + * @return the annotation + */ + @Nullable + public CellRelationAnnotation getAnnotation() { + return annotation; + } + + /** + * @param annotation the annotation to set + */ + public void setAnnotation(CellRelationAnnotation annotation) { + Preconditions.checkNotNull(annotation); + + this.annotation = annotation; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "CellRelationValue [position=" + position + ", annotation=" + annotation + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ClassificationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ClassificationValue.java index 4ee1c72a..1c7b40f1 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ClassificationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ClassificationValue.java @@ -1,80 +1,80 @@ -package cz.cuni.mff.xrg.odalic.api.rest.values; - -import java.io.Serializable; - -import javax.annotation.Nullable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.feedbacks.Classification; -import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; -import cz.cuni.mff.xrg.odalic.tasks.annotations.HeaderAnnotation; - -/** - * Domain class {@link Classification} adapted for REST API. - * - * @author Václav Brodec - * - */ -@XmlRootElement(name = "classification") -public class ClassificationValue implements Serializable { - - private static final long serialVersionUID = 6470286409364911894L; - - @XmlElement - private ColumnPosition position; - - @XmlElement - private HeaderAnnotation annotation; - - public ClassificationValue() {} - - public ClassificationValue(Classification adaptee) { - this.position = adaptee.getPosition(); - this.annotation = adaptee.getAnnotation(); - } - - /** - * @return the position - */ - @Nullable - public ColumnPosition getPosition() { - return position; - } - - /** - * @param position the position to set - */ - public void setPosition(ColumnPosition position) { - Preconditions.checkNotNull(position); - - this.position = position; - } - - /** - * @return the annotation - */ - @Nullable - public HeaderAnnotation getAnnotation() { - return annotation; - } - - /** - * @param annotation the annotation to set - */ - public void setAnnotation(HeaderAnnotation annotation) { - Preconditions.checkNotNull(annotation); - - this.annotation = annotation; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "ClassificationValue [position=" + position + ", annotation=" + annotation + "]"; - } -} +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.feedbacks.Classification; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.HeaderAnnotation; + +/** + * Domain class {@link Classification} adapted for REST API. + * + * @author Václav Brodec + * + */ +@XmlRootElement(name = "classification") +public class ClassificationValue implements Serializable { + + private static final long serialVersionUID = 6470286409364911894L; + + @XmlElement + private ColumnPosition position; + + @XmlElement + private HeaderAnnotation annotation; + + public ClassificationValue() {} + + public ClassificationValue(Classification adaptee) { + this.position = adaptee.getPosition(); + this.annotation = adaptee.getAnnotation(); + } + + /** + * @return the position + */ + @Nullable + public ColumnPosition getPosition() { + return position; + } + + /** + * @param position the position to set + */ + public void setPosition(ColumnPosition position) { + Preconditions.checkNotNull(position); + + this.position = position; + } + + /** + * @return the annotation + */ + @Nullable + public HeaderAnnotation getAnnotation() { + return annotation; + } + + /** + * @param annotation the annotation to set + */ + public void setAnnotation(HeaderAnnotation annotation) { + Preconditions.checkNotNull(annotation); + + this.annotation = annotation; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ClassificationValue [position=" + position + ", annotation=" + annotation + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnAmbiguityValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnAmbiguityValue.java index 2b861772..8e9cdb2f 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnAmbiguityValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnAmbiguityValue.java @@ -1,58 +1,58 @@ -package cz.cuni.mff.xrg.odalic.api.rest.values; - -import java.io.Serializable; - -import javax.annotation.Nullable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.feedbacks.ColumnAmbiguity; -import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; - -/** - * Domain class {@link ColumnAmbiguity} adapted for REST API. - * - * @author Václav Brodec - * - */ -@XmlRootElement(name = "columnAmbiguity") -public final class ColumnAmbiguityValue implements Serializable { - - private static final long serialVersionUID = -9087389821835847372L; - - @XmlElement - private ColumnPosition position; - - public ColumnAmbiguityValue() {} - - public ColumnAmbiguityValue(ColumnAmbiguity adaptee) { - this.position = adaptee.getPosition(); - } - - /** - * @return the position - */ - @Nullable - public ColumnPosition getPosition() { - return position; - } - - /** - * @param position the position to set - */ - public void setPosition(ColumnPosition position) { - Preconditions.checkNotNull(position); - - this.position = position; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "ColumnAmbiguityValue [position=" + position + "]"; - } -} +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.feedbacks.ColumnAmbiguity; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; + +/** + * Domain class {@link ColumnAmbiguity} adapted for REST API. + * + * @author Václav Brodec + * + */ +@XmlRootElement(name = "columnAmbiguity") +public final class ColumnAmbiguityValue implements Serializable { + + private static final long serialVersionUID = -9087389821835847372L; + + @XmlElement + private ColumnPosition position; + + public ColumnAmbiguityValue() {} + + public ColumnAmbiguityValue(ColumnAmbiguity adaptee) { + this.position = adaptee.getPosition(); + } + + /** + * @return the position + */ + @Nullable + public ColumnPosition getPosition() { + return position; + } + + /** + * @param position the position to set + */ + public void setPosition(ColumnPosition position) { + Preconditions.checkNotNull(position); + + this.position = position; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ColumnAmbiguityValue [position=" + position + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnIgnoreValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnIgnoreValue.java index 17b3cf88..025aa291 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnIgnoreValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnIgnoreValue.java @@ -1,58 +1,58 @@ -package cz.cuni.mff.xrg.odalic.api.rest.values; - -import java.io.Serializable; - -import javax.annotation.Nullable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.feedbacks.ColumnIgnore; -import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; - -/** - * Domain class {@link ColumnIgnore} adapted for REST API. - * - * @author Václav Brodec - * - */ -@XmlRootElement(name = "columnIgnore") -public final class ColumnIgnoreValue implements Serializable { - - private static final long serialVersionUID = -9087389821835847372L; - - @XmlElement - private ColumnPosition position; - - public ColumnIgnoreValue() {} - - public ColumnIgnoreValue(ColumnIgnore adaptee) { - this.position = adaptee.getPosition(); - } - - /** - * @return the position - */ - @Nullable - public ColumnPosition getPosition() { - return position; - } - - /** - * @param position the position to set - */ - public void setPosition(ColumnPosition position) { - Preconditions.checkNotNull(position); - - this.position = position; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "ColumnIgnoreValue [position=" + position + "]"; - } -} +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.feedbacks.ColumnIgnore; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; + +/** + * Domain class {@link ColumnIgnore} adapted for REST API. + * + * @author Václav Brodec + * + */ +@XmlRootElement(name = "columnIgnore") +public final class ColumnIgnoreValue implements Serializable { + + private static final long serialVersionUID = -9087389821835847372L; + + @XmlElement + private ColumnPosition position; + + public ColumnIgnoreValue() {} + + public ColumnIgnoreValue(ColumnIgnore adaptee) { + this.position = adaptee.getPosition(); + } + + /** + * @return the position + */ + @Nullable + public ColumnPosition getPosition() { + return position; + } + + /** + * @param position the position to set + */ + public void setPosition(ColumnPosition position) { + Preconditions.checkNotNull(position); + + this.position = position; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ColumnIgnoreValue [position=" + position + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnPositionValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnPositionValue.java index 1eeb0e26..a1b81551 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnPositionValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnPositionValue.java @@ -1,54 +1,54 @@ -package cz.cuni.mff.xrg.odalic.api.rest.values; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; - -/** - * Domain class {@link ColumnPosition} adapted for REST API. - * - * @author Václav Brodec - * - */ -@XmlRootElement(name = "columnPosition") -public final class ColumnPositionValue { - - @XmlElement - private int index; - - public ColumnPositionValue() {} - - /** - * @param adaptee - */ - public ColumnPositionValue(ColumnPosition adaptee) { - this.index = adaptee.getIndex(); - } - - /** - * @return the index - */ - public int getIndex() { - return index; - } - - /** - * @param index the index to set - */ - public void setIndex(int index) { - Preconditions.checkArgument(index >= 0); - - this.index = index; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "ColumnPositionValue [index=" + index + "]"; - } -} +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; + +/** + * Domain class {@link ColumnPosition} adapted for REST API. + * + * @author Václav Brodec + * + */ +@XmlRootElement(name = "columnPosition") +public final class ColumnPositionValue { + + @XmlElement + private int index; + + public ColumnPositionValue() {} + + /** + * @param adaptee + */ + public ColumnPositionValue(ColumnPosition adaptee) { + this.index = adaptee.getIndex(); + } + + /** + * @return the index + */ + public int getIndex() { + return index; + } + + /** + * @param index the index to set + */ + public void setIndex(int index) { + Preconditions.checkArgument(index >= 0); + + this.index = index; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ColumnPositionValue [index=" + index + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationAnnotationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationAnnotationValue.java index d729ef35..4400c599 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationAnnotationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationAnnotationValue.java @@ -1,102 +1,102 @@ -package cz.cuni.mff.xrg.odalic.api.rest.values; - -import java.util.Map; -import java.util.NavigableSet; -import java.util.Set; -import java.util.stream.Stream; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSortedSet; - -import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonDeserializer; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonSerializer; -import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; -import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; -import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; - -/** - *

- * Domain class {@link ColumnRelationAnnotation} adapted for REST API. - *

- * - *

- * In contrast to the adapted class, annotation in this version have only one set of candidates and - * the chosen ones are indicated by flags on each element. - *

- * - * @author Václav Brodec - * - */ -@XmlRootElement(name = "columnRelationAnnotation") -public final class ColumnRelationAnnotationValue { - - @XmlElement - @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) - @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) - private Map> candidates; - - public ColumnRelationAnnotationValue() { - candidates = ImmutableMap.of(); - } - - /** - * @param entities - */ - public ColumnRelationAnnotationValue(ColumnRelationAnnotation adaptee) { - final Map> chosen = adaptee.getChosen(); - - final ImmutableMap.Builder> candidatesBuilder = - ImmutableMap.builder(); - for (final Map.Entry> entry : adaptee - .getCandidates().entrySet()) { - final KnowledgeBase base = entry.getKey(); - final Set baseChosen = chosen.get(base); - final NavigableSet baseCandidates = entry.getValue(); - - final Stream stream = - baseCandidates.stream().map(e -> new EntityCandidateValue(e, baseChosen.contains(e))); - candidatesBuilder.put(entry.getKey(), ImmutableSortedSet.copyOf(stream.iterator())); - } - - this.candidates = candidatesBuilder.build(); - } - - /** - * @return the candidates - */ - public Map> getCandidates() { - return candidates; - } - - /** - * @param candidates the candidates to set - */ - public void setCandidates( - Map> candidates) { - ImmutableMap.Builder> candidatesBuilder = - ImmutableMap.builder(); - for (final Map.Entry> candidateEntry : candidates - .entrySet()) { - candidatesBuilder.put(candidateEntry.getKey(), - ImmutableSortedSet.copyOf(candidateEntry.getValue())); - } - - this.candidates = candidatesBuilder.build(); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "ColumnRelationAnnotationValue [candidates=" + candidates + "]"; - } -} +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.util.Map; +import java.util.NavigableSet; +import java.util.Set; +import java.util.stream.Stream; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSortedSet; + +import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonDeserializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonSerializer; +import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; + +/** + *

+ * Domain class {@link ColumnRelationAnnotation} adapted for REST API. + *

+ * + *

+ * In contrast to the adapted class, annotation in this version have only one set of candidates and + * the chosen ones are indicated by flags on each element. + *

+ * + * @author Václav Brodec + * + */ +@XmlRootElement(name = "columnRelationAnnotation") +public final class ColumnRelationAnnotationValue { + + @XmlElement + @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) + @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) + private Map> candidates; + + public ColumnRelationAnnotationValue() { + candidates = ImmutableMap.of(); + } + + /** + * @param entities + */ + public ColumnRelationAnnotationValue(ColumnRelationAnnotation adaptee) { + final Map> chosen = adaptee.getChosen(); + + final ImmutableMap.Builder> candidatesBuilder = + ImmutableMap.builder(); + for (final Map.Entry> entry : adaptee + .getCandidates().entrySet()) { + final KnowledgeBase base = entry.getKey(); + final Set baseChosen = chosen.get(base); + final NavigableSet baseCandidates = entry.getValue(); + + final Stream stream = + baseCandidates.stream().map(e -> new EntityCandidateValue(e, baseChosen.contains(e))); + candidatesBuilder.put(entry.getKey(), ImmutableSortedSet.copyOf(stream.iterator())); + } + + this.candidates = candidatesBuilder.build(); + } + + /** + * @return the candidates + */ + public Map> getCandidates() { + return candidates; + } + + /** + * @param candidates the candidates to set + */ + public void setCandidates( + Map> candidates) { + ImmutableMap.Builder> candidatesBuilder = + ImmutableMap.builder(); + for (final Map.Entry> candidateEntry : candidates + .entrySet()) { + candidatesBuilder.put(candidateEntry.getKey(), + ImmutableSortedSet.copyOf(candidateEntry.getValue())); + } + + this.candidates = candidatesBuilder.build(); + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ColumnRelationAnnotationValue [candidates=" + candidates + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationPositionValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationPositionValue.java index 52ced387..b403b5a0 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationPositionValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationPositionValue.java @@ -1,75 +1,75 @@ -package cz.cuni.mff.xrg.odalic.api.rest.values; - -import javax.annotation.Nullable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; -import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; - -/** - * Domain class {@link ColumnRelationPosition} adapted for REST API. - * - * @author Václav Brodec - * - */ -@XmlRootElement(name = "cellPosition") -public final class ColumnRelationPositionValue { - - @XmlElement - private ColumnPosition first; - - @XmlElement - private ColumnPosition second; - - public ColumnRelationPositionValue() {} - - public ColumnRelationPositionValue(ColumnRelationPosition adaptee) { - this.first = adaptee.getFirst(); - this.second = adaptee.getSecond(); - } - - /** - * @return the first - */ - @Nullable - public ColumnPosition getFirst() { - return first; - } - - /** - * @param first the first to set - */ - public void setFirst(ColumnPosition first) { - Preconditions.checkNotNull(first); - - this.first = first; - } - - /** - * @return the second - */ - @Nullable - public ColumnPosition getSecond() { - return second; - } - - /** - * @param second the second to set - */ - public void setSecond(ColumnPosition second) { - Preconditions.checkNotNull(second); - - this.second = second; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "ColumnRelationPositionValue [first=" + first + ", second=" + second + "]"; - } -} +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; + +/** + * Domain class {@link ColumnRelationPosition} adapted for REST API. + * + * @author Václav Brodec + * + */ +@XmlRootElement(name = "cellPosition") +public final class ColumnRelationPositionValue { + + @XmlElement + private ColumnPosition first; + + @XmlElement + private ColumnPosition second; + + public ColumnRelationPositionValue() {} + + public ColumnRelationPositionValue(ColumnRelationPosition adaptee) { + this.first = adaptee.getFirst(); + this.second = adaptee.getSecond(); + } + + /** + * @return the first + */ + @Nullable + public ColumnPosition getFirst() { + return first; + } + + /** + * @param first the first to set + */ + public void setFirst(ColumnPosition first) { + Preconditions.checkNotNull(first); + + this.first = first; + } + + /** + * @return the second + */ + @Nullable + public ColumnPosition getSecond() { + return second; + } + + /** + * @param second the second to set + */ + public void setSecond(ColumnPosition second) { + Preconditions.checkNotNull(second); + + this.second = second; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ColumnRelationPositionValue [first=" + first + ", second=" + second + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationValue.java index 38c9b07a..b489b262 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ColumnRelationValue.java @@ -1,80 +1,80 @@ -package cz.cuni.mff.xrg.odalic.api.rest.values; - -import java.io.Serializable; - -import javax.annotation.Nullable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.feedbacks.ColumnRelation; -import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; -import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; - -/** - * Domain class {@link ColumnRelation} adapted for REST API. - * - * @author Václav Brodec - * - */ -@XmlRootElement(name = "columnRelation") -public final class ColumnRelationValue implements Serializable { - - private static final long serialVersionUID = -9087389821835847372L; - - @XmlElement - private ColumnRelationPosition position; - - @XmlElement - private ColumnRelationAnnotation annotation; - - public ColumnRelationValue() {} - - public ColumnRelationValue(ColumnRelation adaptee) { - this.position = adaptee.getPosition(); - this.annotation = adaptee.getAnnotation(); - } - - /** - * @return the position - */ - @Nullable - public ColumnRelationPosition getPosition() { - return position; - } - - /** - * @param position the position to set - */ - public void setPosition(ColumnRelationPosition position) { - Preconditions.checkNotNull(position); - - this.position = position; - } - - /** - * @return the annotation - */ - @Nullable - public ColumnRelationAnnotation getAnnotation() { - return annotation; - } - - /** - * @param annotation the annotation to set - */ - public void setAnnotation(ColumnRelationAnnotation annotation) { - Preconditions.checkNotNull(annotation); - - this.annotation = annotation; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "ColumnRelationValue [position=" + position + ", annotation=" + annotation + "]"; - } -} +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.feedbacks.ColumnRelation; +import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; + +/** + * Domain class {@link ColumnRelation} adapted for REST API. + * + * @author Václav Brodec + * + */ +@XmlRootElement(name = "columnRelation") +public final class ColumnRelationValue implements Serializable { + + private static final long serialVersionUID = -9087389821835847372L; + + @XmlElement + private ColumnRelationPosition position; + + @XmlElement + private ColumnRelationAnnotation annotation; + + public ColumnRelationValue() {} + + public ColumnRelationValue(ColumnRelation adaptee) { + this.position = adaptee.getPosition(); + this.annotation = adaptee.getAnnotation(); + } + + /** + * @return the position + */ + @Nullable + public ColumnRelationPosition getPosition() { + return position; + } + + /** + * @param position the position to set + */ + public void setPosition(ColumnRelationPosition position) { + Preconditions.checkNotNull(position); + + this.position = position; + } + + /** + * @return the annotation + */ + @Nullable + public ColumnRelationAnnotation getAnnotation() { + return annotation; + } + + /** + * @param annotation the annotation to set + */ + public void setAnnotation(ColumnRelationAnnotation annotation) { + Preconditions.checkNotNull(annotation); + + this.annotation = annotation; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ColumnRelationValue [position=" + position + ", annotation=" + annotation + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java index 7d163980..1d4b14b6 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ConfigurationValue.java @@ -1,103 +1,103 @@ -package cz.cuni.mff.xrg.odalic.api.rest.values; - -import java.io.Serializable; - -import javax.annotation.Nullable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; -import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; -import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; - -/** - * Domain class {@link Configuration} adapted for REST API. - * - * @author Václav Brodec - * - */ -@XmlRootElement(name = "configuration") -public final class ConfigurationValue implements Serializable { - - private static final long serialVersionUID = -6359038623760039155L; - - @XmlElement(name = "input") - private String input; - - @XmlElement(name = "feedback") - private Feedback feedback; - - @XmlElement(name = "primary_base") - private KnowledgeBase primaryBase; - - public ConfigurationValue() {} - - public ConfigurationValue(Configuration adaptee) { - input = adaptee.getInput().getId(); - feedback = adaptee.getFeedback(); - primaryBase = adaptee.getPrimaryBase(); - } - - /** - * @return the input - */ - @Nullable - public String getInput() { - return input; - } - - /** - * @param input the input to set - */ - public void setInput(String input) { - Preconditions.checkNotNull(input); - - this.input = input; - } - - /** - * @return the feedback - */ - @Nullable - public Feedback getFeedback() { - return feedback; - } - - - /** - * @param feedback the feedback to set - */ - public void setFeedback(Feedback feedback) { - Preconditions.checkNotNull(feedback); - - this.feedback = feedback; - } - - /** - * @return the primary knowledge base - */ - @Nullable - public KnowledgeBase getPrimaryBase() { - return primaryBase; - } - - /** - * @param primaryBase the primary knowledge base to set - */ - public void setPrimaryBase(KnowledgeBase primaryBase) { - Preconditions.checkNotNull(primaryBase); - - this.primaryBase = primaryBase; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "ConfigurationValue [input=" + input + ", feedback=" + feedback + ", primaryBase=" - + primaryBase + "]"; - } -} +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; +import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; + +/** + * Domain class {@link Configuration} adapted for REST API. + * + * @author Václav Brodec + * + */ +@XmlRootElement(name = "configuration") +public final class ConfigurationValue implements Serializable { + + private static final long serialVersionUID = -6359038623760039155L; + + @XmlElement(name = "input") + private String input; + + @XmlElement(name = "feedback") + private Feedback feedback; + + @XmlElement(name = "primary_base") + private KnowledgeBase primaryBase; + + public ConfigurationValue() {} + + public ConfigurationValue(Configuration adaptee) { + input = adaptee.getInput().getId(); + feedback = adaptee.getFeedback(); + primaryBase = adaptee.getPrimaryBase(); + } + + /** + * @return the input + */ + @Nullable + public String getInput() { + return input; + } + + /** + * @param input the input to set + */ + public void setInput(String input) { + Preconditions.checkNotNull(input); + + this.input = input; + } + + /** + * @return the feedback + */ + @Nullable + public Feedback getFeedback() { + return feedback; + } + + + /** + * @param feedback the feedback to set + */ + public void setFeedback(Feedback feedback) { + Preconditions.checkNotNull(feedback); + + this.feedback = feedback; + } + + /** + * @return the primary knowledge base + */ + @Nullable + public KnowledgeBase getPrimaryBase() { + return primaryBase; + } + + /** + * @param primaryBase the primary knowledge base to set + */ + public void setPrimaryBase(KnowledgeBase primaryBase) { + Preconditions.checkNotNull(primaryBase); + + this.primaryBase = primaryBase; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ConfigurationValue [input=" + input + ", feedback=" + feedback + ", primaryBase=" + + primaryBase + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/DisambiguationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/DisambiguationValue.java index 5cc5d00f..f4a9dd86 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/DisambiguationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/DisambiguationValue.java @@ -1,80 +1,80 @@ -package cz.cuni.mff.xrg.odalic.api.rest.values; - -import java.io.Serializable; - -import javax.annotation.Nullable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.feedbacks.Disambiguation; -import cz.cuni.mff.xrg.odalic.positions.CellPosition; -import cz.cuni.mff.xrg.odalic.tasks.annotations.CellAnnotation; - -/** - * Domain class {@link Disambiguation} adapted for REST API. - * - * @author Václav Brodec - * - */ -@XmlRootElement(name = "disambiguation") -public final class DisambiguationValue implements Serializable { - - private static final long serialVersionUID = -9087389821835847372L; - - @XmlElement - private CellPosition position; - - @XmlElement - private CellAnnotation annotation; - - public DisambiguationValue() {} - - public DisambiguationValue(Disambiguation adaptee) { - this.position = adaptee.getPosition(); - this.annotation = adaptee.getAnnotation(); - } - - /** - * @return the position - */ - @Nullable - public CellPosition getPosition() { - return position; - } - - /** - * @param position the position to set - */ - public void setPosition(CellPosition position) { - Preconditions.checkNotNull(position); - - this.position = position; - } - - /** - * @return the annotation - */ - @Nullable - public CellAnnotation getAnnotation() { - return annotation; - } - - /** - * @param annotation the annotation to set - */ - public void setAnnotation(CellAnnotation annotation) { - Preconditions.checkNotNull(annotation); - - this.annotation = annotation; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "DisambiguationValue [position=" + position + ", annotation=" + annotation + "]"; - } -} +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.feedbacks.Disambiguation; +import cz.cuni.mff.xrg.odalic.positions.CellPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellAnnotation; + +/** + * Domain class {@link Disambiguation} adapted for REST API. + * + * @author Václav Brodec + * + */ +@XmlRootElement(name = "disambiguation") +public final class DisambiguationValue implements Serializable { + + private static final long serialVersionUID = -9087389821835847372L; + + @XmlElement + private CellPosition position; + + @XmlElement + private CellAnnotation annotation; + + public DisambiguationValue() {} + + public DisambiguationValue(Disambiguation adaptee) { + this.position = adaptee.getPosition(); + this.annotation = adaptee.getAnnotation(); + } + + /** + * @return the position + */ + @Nullable + public CellPosition getPosition() { + return position; + } + + /** + * @param position the position to set + */ + public void setPosition(CellPosition position) { + Preconditions.checkNotNull(position); + + this.position = position; + } + + /** + * @return the annotation + */ + @Nullable + public CellAnnotation getAnnotation() { + return annotation; + } + + /** + * @param annotation the annotation to set + */ + public void setAnnotation(CellAnnotation annotation) { + Preconditions.checkNotNull(annotation); + + this.annotation = annotation; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "DisambiguationValue [position=" + position + ", annotation=" + annotation + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityCandidateValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityCandidateValue.java index fafc5811..3178880f 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityCandidateValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityCandidateValue.java @@ -1,148 +1,148 @@ -package cz.cuni.mff.xrg.odalic.api.rest.values; - -import java.io.Serializable; - -import javax.annotation.Nullable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.tasks.annotations.Entity; -import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; -import cz.cuni.mff.xrg.odalic.tasks.annotations.Likelihood; - -/** - *

- * Domain class {@link EntityCandidate} adapted for REST API. - *

- * - *

- * In this version it supports a chosen flag instead of annotations classes providing the chosen - * set separately. - *

- * - * @author Václav Brodec - * - */ -@XmlRootElement(name = "entityCandidate") -public final class EntityCandidateValue implements Serializable, Comparable { - - private static final long serialVersionUID = 3072774254576336747L; - - @XmlElement - private Entity entity; - - @XmlElement - private Likelihood likelihood; - - @XmlElement - private boolean chosen; - - public EntityCandidateValue() {} - - public EntityCandidateValue(EntityCandidate adaptee, boolean chosen) { - entity = adaptee.getEntity(); - likelihood = adaptee.getLikelihood(); - this.chosen = chosen; - } - - /** - * @return the entity - */ - @Nullable - public Entity getEntity() { - return entity; - } - - /** - * @param entity the entity to set - */ - public void setEntity(Entity entity) { - Preconditions.checkNotNull(entity); - - this.entity = entity; - } - - /** - * @return the likelihood - */ - @Nullable - public Likelihood getLikelihood() { - return likelihood; - } - - /** - * @param likelihood the likelihood to set - */ - public void setLikelihood(Likelihood likelihood) { - Preconditions.checkNotNull(likelihood); - - this.likelihood = likelihood; - } - - /** - * @return the chosen - */ - public boolean isChosen() { - return chosen; - } - - /** - * @param chosen the chosen to set - */ - public void setChosen(boolean chosen) { - this.chosen = chosen; - } - - - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + new EntityCandidate(entity, likelihood).hashCode(); - return result; - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - EntityCandidateValue other = (EntityCandidateValue) obj; - return new EntityCandidate(entity, likelihood).equals(new EntityCandidate(other.entity, other.likelihood)); - } - - /* (non-Javadoc) - * @see java.lang.Comparable#compareTo(java.lang.Object) - */ - @Override - public int compareTo(EntityCandidateValue other) { - return new EntityCandidate(entity, likelihood) - .compareTo(new EntityCandidate(other.entity, other.likelihood)); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "EntityCandidateValue [entity=" + entity + ", likelihood=" + likelihood + ", chosen=" - + chosen + "]"; - } -} +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.tasks.annotations.Entity; +import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; +import cz.cuni.mff.xrg.odalic.tasks.annotations.Likelihood; + +/** + *

+ * Domain class {@link EntityCandidate} adapted for REST API. + *

+ * + *

+ * In this version it supports a chosen flag instead of annotations classes providing the chosen + * set separately. + *

+ * + * @author Václav Brodec + * + */ +@XmlRootElement(name = "entityCandidate") +public final class EntityCandidateValue implements Serializable, Comparable { + + private static final long serialVersionUID = 3072774254576336747L; + + @XmlElement + private Entity entity; + + @XmlElement + private Likelihood likelihood; + + @XmlElement + private boolean chosen; + + public EntityCandidateValue() {} + + public EntityCandidateValue(EntityCandidate adaptee, boolean chosen) { + entity = adaptee.getEntity(); + likelihood = adaptee.getLikelihood(); + this.chosen = chosen; + } + + /** + * @return the entity + */ + @Nullable + public Entity getEntity() { + return entity; + } + + /** + * @param entity the entity to set + */ + public void setEntity(Entity entity) { + Preconditions.checkNotNull(entity); + + this.entity = entity; + } + + /** + * @return the likelihood + */ + @Nullable + public Likelihood getLikelihood() { + return likelihood; + } + + /** + * @param likelihood the likelihood to set + */ + public void setLikelihood(Likelihood likelihood) { + Preconditions.checkNotNull(likelihood); + + this.likelihood = likelihood; + } + + /** + * @return the chosen + */ + public boolean isChosen() { + return chosen; + } + + /** + * @param chosen the chosen to set + */ + public void setChosen(boolean chosen) { + this.chosen = chosen; + } + + + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + new EntityCandidate(entity, likelihood).hashCode(); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + EntityCandidateValue other = (EntityCandidateValue) obj; + return new EntityCandidate(entity, likelihood).equals(new EntityCandidate(other.entity, other.likelihood)); + } + + /* (non-Javadoc) + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ + @Override + public int compareTo(EntityCandidateValue other) { + return new EntityCandidate(entity, likelihood) + .compareTo(new EntityCandidate(other.entity, other.likelihood)); + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "EntityCandidateValue [entity=" + entity + ", likelihood=" + likelihood + ", chosen=" + + chosen + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityValue.java index 6200a38e..22cb9e54 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/EntityValue.java @@ -1,77 +1,77 @@ -package cz.cuni.mff.xrg.odalic.api.rest.values; - -import java.io.Serializable; -import javax.annotation.Nullable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.tasks.annotations.Entity; - -/** - * Domain class {@link Entity} adapted for REST API. - * - * @author Václav Brodec - * - */ -@XmlRootElement(name = "entity") -public final class EntityValue implements Serializable { - - private static final long serialVersionUID = 5750987769573292984L; - - @XmlElement - private String resource; - - @XmlElement - private String label; - - public EntityValue() {} - - public EntityValue(Entity adaptee) { - this.resource = adaptee.getResource(); - this.label = adaptee.getLabel(); - } - - /** - * @return the resource ID - */ - @Nullable - public String getResource() { - return resource; - } - - /** - * @param resource the resource ID to set - */ - public void setResource(String resource) { - Preconditions.checkNotNull(resource); - - this.resource = resource; - } - - /** - * @return the label - */ - @Nullable - public String getLabel() { - return label; - } - - /** - * @param label the label to set - */ - public void setLabel(String label) { - Preconditions.checkNotNull(label); - - this.label = label; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "EntityValue [resource=" + resource + ", label=" + label + "]"; - } -} +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.tasks.annotations.Entity; + +/** + * Domain class {@link Entity} adapted for REST API. + * + * @author Václav Brodec + * + */ +@XmlRootElement(name = "entity") +public final class EntityValue implements Serializable { + + private static final long serialVersionUID = 5750987769573292984L; + + @XmlElement + private String resource; + + @XmlElement + private String label; + + public EntityValue() {} + + public EntityValue(Entity adaptee) { + this.resource = adaptee.getResource(); + this.label = adaptee.getLabel(); + } + + /** + * @return the resource ID + */ + @Nullable + public String getResource() { + return resource; + } + + /** + * @param resource the resource ID to set + */ + public void setResource(String resource) { + Preconditions.checkNotNull(resource); + + this.resource = resource; + } + + /** + * @return the label + */ + @Nullable + public String getLabel() { + return label; + } + + /** + * @param label the label to set + */ + public void setLabel(String label) { + Preconditions.checkNotNull(label); + + this.label = label; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "EntityValue [resource=" + resource + ", label=" + label + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ExecutionValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ExecutionValue.java index 6590dca3..9a6a0bca 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ExecutionValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ExecutionValue.java @@ -1,62 +1,62 @@ -package cz.cuni.mff.xrg.odalic.api.rest.values; - -import java.io.Serializable; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Abstract resource used to symbolize submitting a task for execution when put and canceling the - * execution when deleted. - * - * @author Václav Brodec - * - */ -@XmlRootElement(name = "execution") -public final class ExecutionValue implements Serializable { - - private static final long serialVersionUID = -6359038623760039155L; - - /** - * Draft flag (reserved for future versions). - */ - @XmlElement - private boolean draft; - - public ExecutionValue() { - draft = false; - } - - /** - * Creates execution resource representation. - * - * @param draft draft indicator - */ - public ExecutionValue(boolean draft) { - this.draft = draft; - } - - /** - * @return indicates draft execution - */ - public boolean isDraft() { - return draft; - } - - /** - * @param draft the draft indicator to set - */ - public void setDraft(boolean draft) { - this.draft = draft; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "ExecutionValue [draft=" + draft + "]"; - } -} +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Abstract resource used to symbolize submitting a task for execution when put and canceling the + * execution when deleted. + * + * @author Václav Brodec + * + */ +@XmlRootElement(name = "execution") +public final class ExecutionValue implements Serializable { + + private static final long serialVersionUID = -6359038623760039155L; + + /** + * Draft flag (reserved for future versions). + */ + @XmlElement + private boolean draft; + + public ExecutionValue() { + draft = false; + } + + /** + * Creates execution resource representation. + * + * @param draft draft indicator + */ + public ExecutionValue(boolean draft) { + this.draft = draft; + } + + /** + * @return indicates draft execution + */ + public boolean isDraft() { + return draft; + } + + /** + * @param draft the draft indicator to set + */ + public void setDraft(boolean draft) { + this.draft = draft; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ExecutionValue [draft=" + draft + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/FeedbackValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/FeedbackValue.java index 9368cae4..1ac65d85 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/FeedbackValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/FeedbackValue.java @@ -1,207 +1,207 @@ -package cz.cuni.mff.xrg.odalic.api.rest.values; - -import java.io.Serializable; -import java.util.Set; - -import javax.annotation.Nullable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableSet; - -import cz.cuni.mff.xrg.odalic.feedbacks.Ambiguity; -import cz.cuni.mff.xrg.odalic.feedbacks.CellRelation; -import cz.cuni.mff.xrg.odalic.feedbacks.Classification; -import cz.cuni.mff.xrg.odalic.feedbacks.ColumnAmbiguity; -import cz.cuni.mff.xrg.odalic.feedbacks.ColumnIgnore; -import cz.cuni.mff.xrg.odalic.feedbacks.ColumnRelation; -import cz.cuni.mff.xrg.odalic.feedbacks.Disambiguation; -import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; -import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; - -/** - * Domain class {@link Feedback} adapted for REST API. - * - * @author Václav Brodec - * - */ -@XmlRootElement(name = "feedback") -public final class FeedbackValue implements Serializable { - - private static final long serialVersionUID = -7968455903789693405L; - - @XmlElement - private ColumnPosition subjectColumnPosition; - - @XmlElement - private Set columnIgnores; - - @XmlElement - private Set columnAmbiguities; - - @XmlElement - private Set classifications; - - @XmlElement - private Set cellRelations; - - @XmlElement - private Set columnRelations; - - @XmlElement - private Set disambiguations; - - @XmlElement - private Set ambiguities; - - public FeedbackValue() { - subjectColumnPosition = null; - columnIgnores = ImmutableSet.of(); - columnAmbiguities = ImmutableSet.of(); - classifications = ImmutableSet.of(); - cellRelations = ImmutableSet.of(); - columnRelations = ImmutableSet.of(); - disambiguations = ImmutableSet.of(); - ambiguities = ImmutableSet.of(); - } - - public FeedbackValue(Feedback adaptee) { - subjectColumnPosition = adaptee.getSubjectColumnPosition(); - columnIgnores = adaptee.getColumnIgnores(); - columnAmbiguities = adaptee.getColumnAmbiguities(); - classifications = adaptee.getClassifications(); - cellRelations = adaptee.getCellRelations(); - columnRelations = adaptee.getColumnRelations(); - disambiguations = adaptee.getDisambiguations(); - ambiguities = adaptee.getAmbiguities(); - } - - /** - * @return the subject column position - */ - @Nullable - public ColumnPosition getSubjectColumnPosition() { - return subjectColumnPosition; - } - - /** - * @param subjectColumnPosition the subject column position to set - */ - public void setSubjectColumnPosition(ColumnPosition subjectColumnPosition) { - this.subjectColumnPosition = subjectColumnPosition; - } - - /** - * @return the column ignores - */ - public Set getColumnIgnores() { - return columnIgnores; - } - - /** - * @param columnIgnores the column ignores to set - */ - public void setColumnIgnores(Set columnIgnores) { - Preconditions.checkNotNull(columnIgnores); - - this.columnIgnores = ImmutableSet.copyOf(columnIgnores); - } - - /** - * @return the column ambiguities - */ - public Set getColumnAmbiguities() { - return columnAmbiguities; - } - - /** - * @param columnAmbiguities the column ambiguities to set - */ - public void setColumnAmbiguities(Set columnAmbiguities) { - Preconditions.checkNotNull(columnAmbiguities); - - this.columnAmbiguities = ImmutableSet.copyOf(columnAmbiguities); - } - - /** - * @return the classifications - */ - public Set getClassifications() { - return classifications; - } - - /** - * @param classifications the classifications to set - */ - public void setClassifications(Set classifications) { - Preconditions.checkNotNull(classifications); - - this.classifications = ImmutableSet.copyOf(classifications); - } - - /** - * @return the cell relations - */ - public Set getCellRelations() { - return cellRelations; - } - - /** - * @param cellRelations the cellRelations to set - */ - public void setCellRelations(Set cellRelations) { - Preconditions.checkNotNull(cellRelations); - - this.cellRelations = ImmutableSet.copyOf(cellRelations); - } - - /** - * @return the column relations - */ - public Set getColumnRelations() { - return columnRelations; - } - - /** - * @param columnRelations the column relations to set - */ - public void setColumnRelations(Set columnRelations) { - Preconditions.checkNotNull(columnRelations); - - this.columnRelations = ImmutableSet.copyOf(columnRelations); - } - - /** - * @return the disambiguations - */ - public Set getDisambiguations() { - return disambiguations; - } - - /** - * @param disambiguations the disambiguations to set - */ - public void setDisambiguations(Set disambiguations) { - Preconditions.checkNotNull(disambiguations); - - this.disambiguations = ImmutableSet.copyOf(disambiguations); - } - - /** - * @return the ambiguities - */ - public Set getAmbiguities() { - return ambiguities; - } - - /** - * @param ambiguities the ambiguities to set - */ - public void setAmbiguities(Set ambiguities) { - Preconditions.checkNotNull(ambiguities); - - this.ambiguities = ImmutableSet.copyOf(ambiguities); - } - - -} +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; +import java.util.Set; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableSet; + +import cz.cuni.mff.xrg.odalic.feedbacks.Ambiguity; +import cz.cuni.mff.xrg.odalic.feedbacks.CellRelation; +import cz.cuni.mff.xrg.odalic.feedbacks.Classification; +import cz.cuni.mff.xrg.odalic.feedbacks.ColumnAmbiguity; +import cz.cuni.mff.xrg.odalic.feedbacks.ColumnIgnore; +import cz.cuni.mff.xrg.odalic.feedbacks.ColumnRelation; +import cz.cuni.mff.xrg.odalic.feedbacks.Disambiguation; +import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; + +/** + * Domain class {@link Feedback} adapted for REST API. + * + * @author Václav Brodec + * + */ +@XmlRootElement(name = "feedback") +public final class FeedbackValue implements Serializable { + + private static final long serialVersionUID = -7968455903789693405L; + + @XmlElement + private ColumnPosition subjectColumnPosition; + + @XmlElement + private Set columnIgnores; + + @XmlElement + private Set columnAmbiguities; + + @XmlElement + private Set classifications; + + @XmlElement + private Set cellRelations; + + @XmlElement + private Set columnRelations; + + @XmlElement + private Set disambiguations; + + @XmlElement + private Set ambiguities; + + public FeedbackValue() { + subjectColumnPosition = null; + columnIgnores = ImmutableSet.of(); + columnAmbiguities = ImmutableSet.of(); + classifications = ImmutableSet.of(); + cellRelations = ImmutableSet.of(); + columnRelations = ImmutableSet.of(); + disambiguations = ImmutableSet.of(); + ambiguities = ImmutableSet.of(); + } + + public FeedbackValue(Feedback adaptee) { + subjectColumnPosition = adaptee.getSubjectColumnPosition(); + columnIgnores = adaptee.getColumnIgnores(); + columnAmbiguities = adaptee.getColumnAmbiguities(); + classifications = adaptee.getClassifications(); + cellRelations = adaptee.getCellRelations(); + columnRelations = adaptee.getColumnRelations(); + disambiguations = adaptee.getDisambiguations(); + ambiguities = adaptee.getAmbiguities(); + } + + /** + * @return the subject column position + */ + @Nullable + public ColumnPosition getSubjectColumnPosition() { + return subjectColumnPosition; + } + + /** + * @param subjectColumnPosition the subject column position to set + */ + public void setSubjectColumnPosition(ColumnPosition subjectColumnPosition) { + this.subjectColumnPosition = subjectColumnPosition; + } + + /** + * @return the column ignores + */ + public Set getColumnIgnores() { + return columnIgnores; + } + + /** + * @param columnIgnores the column ignores to set + */ + public void setColumnIgnores(Set columnIgnores) { + Preconditions.checkNotNull(columnIgnores); + + this.columnIgnores = ImmutableSet.copyOf(columnIgnores); + } + + /** + * @return the column ambiguities + */ + public Set getColumnAmbiguities() { + return columnAmbiguities; + } + + /** + * @param columnAmbiguities the column ambiguities to set + */ + public void setColumnAmbiguities(Set columnAmbiguities) { + Preconditions.checkNotNull(columnAmbiguities); + + this.columnAmbiguities = ImmutableSet.copyOf(columnAmbiguities); + } + + /** + * @return the classifications + */ + public Set getClassifications() { + return classifications; + } + + /** + * @param classifications the classifications to set + */ + public void setClassifications(Set classifications) { + Preconditions.checkNotNull(classifications); + + this.classifications = ImmutableSet.copyOf(classifications); + } + + /** + * @return the cell relations + */ + public Set getCellRelations() { + return cellRelations; + } + + /** + * @param cellRelations the cellRelations to set + */ + public void setCellRelations(Set cellRelations) { + Preconditions.checkNotNull(cellRelations); + + this.cellRelations = ImmutableSet.copyOf(cellRelations); + } + + /** + * @return the column relations + */ + public Set getColumnRelations() { + return columnRelations; + } + + /** + * @param columnRelations the column relations to set + */ + public void setColumnRelations(Set columnRelations) { + Preconditions.checkNotNull(columnRelations); + + this.columnRelations = ImmutableSet.copyOf(columnRelations); + } + + /** + * @return the disambiguations + */ + public Set getDisambiguations() { + return disambiguations; + } + + /** + * @param disambiguations the disambiguations to set + */ + public void setDisambiguations(Set disambiguations) { + Preconditions.checkNotNull(disambiguations); + + this.disambiguations = ImmutableSet.copyOf(disambiguations); + } + + /** + * @return the ambiguities + */ + public Set getAmbiguities() { + return ambiguities; + } + + /** + * @param ambiguities the ambiguities to set + */ + public void setAmbiguities(Set ambiguities) { + Preconditions.checkNotNull(ambiguities); + + this.ambiguities = ImmutableSet.copyOf(ambiguities); + } + + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/FileValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/FileValue.java index ca4f4a20..f81bb286 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/FileValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/FileValue.java @@ -1,130 +1,130 @@ -package cz.cuni.mff.xrg.odalic.api.rest.values; - -import java.io.Serializable; -import java.net.URL; -import java.util.Date; - -import javax.annotation.Nullable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateSerializer; -import cz.cuni.mff.xrg.odalic.files.File; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateDeserializer; - -/** - * Domain class {@link File} adapted for REST API. - * - * @author Václav Brodec - * - */ -@XmlRootElement(name = "file") -public final class FileValue implements Serializable { - - private static final long serialVersionUID = -6359038623760039155L; - - @XmlElement - private String id; - - @JsonSerialize(using = CustomJsonDateSerializer.class) - @JsonDeserialize(using = CustomJsonDateDeserializer.class) - @XmlElement - private Date uploaded; - - @XmlElement - private String owner; - - @XmlElement - private URL location; - - public FileValue() {} - - public FileValue(File adaptee) { - id = adaptee.getId(); - uploaded = adaptee.getUploaded(); - owner = adaptee.getOwner(); - location = adaptee.getLocation(); - } - - /** - * @return the id - */ - @Nullable - public String getId() { - return id; - } - - /** - * @param id the id to set - */ - public void setId(String id) { - Preconditions.checkNotNull(id); - - this.id = id; - } - - /** - * @return the uploaded - */ - @Nullable - public Date getUploaded() { - return uploaded; - } - - /** - * @param uploaded the uploaded to set - */ - public void setUploaded(Date uploaded) { - Preconditions.checkNotNull(uploaded); - - this.uploaded = uploaded; - } - - /** - * @return the owner - */ - @Nullable - public String getOwner() { - return owner; - } - - /** - * @param owner the owner to set - */ - public void setOwner(String owner) { - Preconditions.checkNotNull(owner); - - this.owner = owner; - } - - /** - * @return the location - */ - @Nullable - public URL getLocation() { - return location; - } - - /** - * @param location the location to set - */ - public void setLocation(URL location) { - Preconditions.checkNotNull(location); - - this.location = location; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "FileValue [id=" + id + ", uploaded=" + uploaded + ", owner=" + owner + ", location=" - + location + "]"; - } -} +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; +import java.net.URL; +import java.util.Date; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateSerializer; +import cz.cuni.mff.xrg.odalic.files.File; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateDeserializer; + +/** + * Domain class {@link File} adapted for REST API. + * + * @author Václav Brodec + * + */ +@XmlRootElement(name = "file") +public final class FileValue implements Serializable { + + private static final long serialVersionUID = -6359038623760039155L; + + @XmlElement + private String id; + + @JsonSerialize(using = CustomJsonDateSerializer.class) + @JsonDeserialize(using = CustomJsonDateDeserializer.class) + @XmlElement + private Date uploaded; + + @XmlElement + private String owner; + + @XmlElement + private URL location; + + public FileValue() {} + + public FileValue(File adaptee) { + id = adaptee.getId(); + uploaded = adaptee.getUploaded(); + owner = adaptee.getOwner(); + location = adaptee.getLocation(); + } + + /** + * @return the id + */ + @Nullable + public String getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(String id) { + Preconditions.checkNotNull(id); + + this.id = id; + } + + /** + * @return the uploaded + */ + @Nullable + public Date getUploaded() { + return uploaded; + } + + /** + * @param uploaded the uploaded to set + */ + public void setUploaded(Date uploaded) { + Preconditions.checkNotNull(uploaded); + + this.uploaded = uploaded; + } + + /** + * @return the owner + */ + @Nullable + public String getOwner() { + return owner; + } + + /** + * @param owner the owner to set + */ + public void setOwner(String owner) { + Preconditions.checkNotNull(owner); + + this.owner = owner; + } + + /** + * @return the location + */ + @Nullable + public URL getLocation() { + return location; + } + + /** + * @param location the location to set + */ + public void setLocation(URL location) { + Preconditions.checkNotNull(location); + + this.location = location; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "FileValue [id=" + id + ", uploaded=" + uploaded + ", owner=" + owner + ", location=" + + location + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/HeaderAnnotationValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/HeaderAnnotationValue.java index a95018ec..4d4eb70b 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/HeaderAnnotationValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/HeaderAnnotationValue.java @@ -1,102 +1,102 @@ -package cz.cuni.mff.xrg.odalic.api.rest.values; - -import java.util.Map; -import java.util.NavigableSet; -import java.util.Set; -import java.util.stream.Stream; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSortedSet; - -import cz.cuni.mff.xrg.odalic.tasks.annotations.HeaderAnnotation; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonDeserializer; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonSerializer; -import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; -import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; - -/** - *

- * Domain class {@link HeaderAnnotation} adapted for REST API. - *

- * - *

- * In contrast to the adapted class, annotation in this version have only one set of candidates and - * the chosen ones are indicated by flags on each element. - *

- * - * @author Václav Brodec - * - */ -@XmlRootElement(name = "headerAnnotation") -public final class HeaderAnnotationValue { - - @XmlElement - @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) - @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) - private Map> candidates; - - public HeaderAnnotationValue() { - candidates = ImmutableMap.of(); - } - - /** - * @param entities - */ - public HeaderAnnotationValue(HeaderAnnotation adaptee) { - final Map> chosen = adaptee.getChosen(); - - final ImmutableMap.Builder> candidatesBuilder = - ImmutableMap.builder(); - for (final Map.Entry> entry : adaptee - .getCandidates().entrySet()) { - final KnowledgeBase base = entry.getKey(); - final Set baseChosen = chosen.get(base); - final NavigableSet baseCandidates = entry.getValue(); - - final Stream stream = - baseCandidates.stream().map(e -> new EntityCandidateValue(e, baseChosen.contains(e))); - candidatesBuilder.put(entry.getKey(), ImmutableSortedSet.copyOf(stream.iterator())); - } - - this.candidates = candidatesBuilder.build(); - } - - /** - * @return the candidates - */ - public Map> getCandidates() { - return candidates; - } - - /** - * @param candidates the candidates to set - */ - public void setCandidates( - Map> candidates) { - ImmutableMap.Builder> candidatesBuilder = - ImmutableMap.builder(); - for (final Map.Entry> candidateEntry : candidates - .entrySet()) { - candidatesBuilder.put(candidateEntry.getKey(), - ImmutableSortedSet.copyOf(candidateEntry.getValue())); - } - - this.candidates = candidatesBuilder.build(); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "HeaderAnnotationValue [candidates=" + candidates + "]"; - } -} +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.util.Map; +import java.util.NavigableSet; +import java.util.Set; +import java.util.stream.Stream; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSortedSet; + +import cz.cuni.mff.xrg.odalic.tasks.annotations.HeaderAnnotation; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonDeserializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.KnowledgeBaseKeyJsonSerializer; +import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; + +/** + *

+ * Domain class {@link HeaderAnnotation} adapted for REST API. + *

+ * + *

+ * In contrast to the adapted class, annotation in this version have only one set of candidates and + * the chosen ones are indicated by flags on each element. + *

+ * + * @author Václav Brodec + * + */ +@XmlRootElement(name = "headerAnnotation") +public final class HeaderAnnotationValue { + + @XmlElement + @JsonDeserialize(keyUsing = KnowledgeBaseKeyJsonDeserializer.class) + @JsonSerialize(keyUsing = KnowledgeBaseKeyJsonSerializer.class) + private Map> candidates; + + public HeaderAnnotationValue() { + candidates = ImmutableMap.of(); + } + + /** + * @param entities + */ + public HeaderAnnotationValue(HeaderAnnotation adaptee) { + final Map> chosen = adaptee.getChosen(); + + final ImmutableMap.Builder> candidatesBuilder = + ImmutableMap.builder(); + for (final Map.Entry> entry : adaptee + .getCandidates().entrySet()) { + final KnowledgeBase base = entry.getKey(); + final Set baseChosen = chosen.get(base); + final NavigableSet baseCandidates = entry.getValue(); + + final Stream stream = + baseCandidates.stream().map(e -> new EntityCandidateValue(e, baseChosen.contains(e))); + candidatesBuilder.put(entry.getKey(), ImmutableSortedSet.copyOf(stream.iterator())); + } + + this.candidates = candidatesBuilder.build(); + } + + /** + * @return the candidates + */ + public Map> getCandidates() { + return candidates; + } + + /** + * @param candidates the candidates to set + */ + public void setCandidates( + Map> candidates) { + ImmutableMap.Builder> candidatesBuilder = + ImmutableMap.builder(); + for (final Map.Entry> candidateEntry : candidates + .entrySet()) { + candidatesBuilder.put(candidateEntry.getKey(), + ImmutableSortedSet.copyOf(candidateEntry.getValue())); + } + + this.candidates = candidatesBuilder.build(); + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "HeaderAnnotationValue [candidates=" + candidates + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/KnowledgeBaseValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/KnowledgeBaseValue.java index d5525de7..ba60284f 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/KnowledgeBaseValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/KnowledgeBaseValue.java @@ -1,51 +1,51 @@ -package cz.cuni.mff.xrg.odalic.api.rest.values; - -import javax.annotation.Nullable; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; - -/** - * Domain class {@link KnowledgeBase} adapted for REST API. - * - * @author Václav Brodec - * - */ -@XmlRootElement(name = "knowledgeBase") -public final class KnowledgeBaseValue { - - private String name; - - public KnowledgeBaseValue() {} - - public KnowledgeBaseValue(KnowledgeBase adaptee) { - name = adaptee.getName(); - } - - /** - * @return the name - */ - @Nullable - public String getName() { - return name; - } - - /** - * @param name the name to set - */ - public void setName(String name) { - Preconditions.checkNotNull(name); - - this.name = name; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "KnowledgeBaseValue [name=" + name + "]"; - } -} +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; + +/** + * Domain class {@link KnowledgeBase} adapted for REST API. + * + * @author Václav Brodec + * + */ +@XmlRootElement(name = "knowledgeBase") +public final class KnowledgeBaseValue { + + private String name; + + public KnowledgeBaseValue() {} + + public KnowledgeBaseValue(KnowledgeBase adaptee) { + name = adaptee.getName(); + } + + /** + * @return the name + */ + @Nullable + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + Preconditions.checkNotNull(name); + + this.name = name; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "KnowledgeBaseValue [name=" + name + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/LikelihoodValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/LikelihoodValue.java index 8e7a4abc..226c5d89 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/LikelihoodValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/LikelihoodValue.java @@ -1,57 +1,57 @@ -package cz.cuni.mff.xrg.odalic.api.rest.values; - -import java.io.Serializable; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.tasks.annotations.Likelihood; - -/** - * Domain class {@link Likelihood} adapted for REST API. - * - * @author Václav Brodec - * - */ -@XmlRootElement(name = "likelihood") -public final class LikelihoodValue implements Serializable { - - private static final long serialVersionUID = -901650058091668104L; - - @XmlElement - private double value; - - public LikelihoodValue() { - value = Double.MIN_VALUE; - } - - public LikelihoodValue(Likelihood adaptee) { - value = adaptee.getValue(); - } - - /** - * @return the value (when not set, may be out of range) - */ - public double getValue() { - return value; - } - - /** - * @param value the value to set - */ - public void setValue(double value) { - Preconditions.checkArgument(value >= 0); - - this.value = value; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "LikelihoodValue [value=" + value + "]"; - } -} +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.tasks.annotations.Likelihood; + +/** + * Domain class {@link Likelihood} adapted for REST API. + * + * @author Václav Brodec + * + */ +@XmlRootElement(name = "likelihood") +public final class LikelihoodValue implements Serializable { + + private static final long serialVersionUID = -901650058091668104L; + + @XmlElement + private double value; + + public LikelihoodValue() { + value = Double.MIN_VALUE; + } + + public LikelihoodValue(Likelihood adaptee) { + value = adaptee.getValue(); + } + + /** + * @return the value (when not set, may be out of range) + */ + public double getValue() { + return value; + } + + /** + * @param value the value to set + */ + public void setValue(double value) { + Preconditions.checkArgument(value >= 0); + + this.value = value; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "LikelihoodValue [value=" + value + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ResultValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ResultValue.java index 034b0fb0..523ff29b 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ResultValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/ResultValue.java @@ -1,257 +1,257 @@ -package cz.cuni.mff.xrg.odalic.api.rest.values; - -import java.io.Serializable; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.annotation.Nullable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import org.apache.jena.ext.com.google.common.collect.ImmutableMap; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Maps; - -import cz.cuni.mff.xrg.odalic.api.rest.conversions.ColumnPositionKeyJsonDeserializer; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.ColumnPositionKeyJsonSerializer; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.ColumnPositionToColumnPositionToCellRelationAnnotationMapMapDeserializer; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.ColumnPositionToColumnPositionToCellRelationAnnotationMapMapSerializer; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.ColumnPositionToColumnRelationAnnotationMapDeserializer; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.ColumnPositionToColumnRelationAnnotationMapSerializer; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.RowPositionKeyJsonDeserializer; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.RowPositionKeyJsonSerializer; -import cz.cuni.mff.xrg.odalic.positions.CellRelationPosition; -import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; -import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; -import cz.cuni.mff.xrg.odalic.positions.RowPosition; -import cz.cuni.mff.xrg.odalic.tasks.annotations.CellAnnotation; -import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; -import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; -import cz.cuni.mff.xrg.odalic.tasks.annotations.HeaderAnnotation; -import cz.cuni.mff.xrg.odalic.tasks.results.Result; - -/** - * Domain class {@link Result} adapted for REST API. - * - * @author Václav Brodec - * - */ -@XmlRootElement(name = "result") -public final class ResultValue implements Serializable { - - private static final long serialVersionUID = -6359038623760039155L; - - @XmlElement - private ColumnPosition subjectColumnPosition; - - @XmlElement - private List headerAnnotations; - - @XmlElement - private CellAnnotation[][] cellAnnotations; - - @XmlElement - @JsonDeserialize(keyUsing = ColumnPositionKeyJsonDeserializer.class, - contentUsing = ColumnPositionToColumnRelationAnnotationMapDeserializer.class) - @JsonSerialize(keyUsing = ColumnPositionKeyJsonSerializer.class, - contentUsing = ColumnPositionToColumnRelationAnnotationMapSerializer.class) - private Map> columnRelationAnnotations; - - @XmlElement - @JsonDeserialize(keyUsing = RowPositionKeyJsonDeserializer.class, - contentUsing = ColumnPositionToColumnPositionToCellRelationAnnotationMapMapDeserializer.class) - @JsonSerialize(keyUsing = RowPositionKeyJsonSerializer.class, - contentUsing = ColumnPositionToColumnPositionToCellRelationAnnotationMapMapSerializer.class) - private Map>> cellRelationAnnotations; - - public ResultValue() { - subjectColumnPosition = null; - headerAnnotations = ImmutableList.of(); - cellAnnotations = new CellAnnotation[0][0];; - columnRelationAnnotations = ImmutableMap.of(); - cellRelationAnnotations = ImmutableMap.of(); - } - - public ResultValue(Result adaptee) { - subjectColumnPosition = adaptee.getSubjectColumnPosition(); - headerAnnotations = adaptee.getHeaderAnnotations(); - cellAnnotations = adaptee.getCellAnnotations(); - - initializeColumnRelationAnnotations(adaptee); - initializeCellRelationAnnotations(adaptee); - } - - private void initializeCellRelationAnnotations(Result adaptee) { - cellRelationAnnotations = new HashMap<>(); - for (final Map.Entry entry : adaptee - .getCellRelationAnnotations().entrySet()) { - final CellRelationPosition key = entry.getKey(); - final RowPosition row = key.getRowPosition(); - final ColumnRelationPosition columns = key.getColumnsPosition(); - - final ColumnPosition firstColumn = columns.getFirst(); - final ColumnPosition secondColumn = columns.getSecond(); - - final CellRelationAnnotation annotation = entry.getValue(); - - final Map> subMap = - cellRelationAnnotations.get(row); - if (subMap == null) { - final Map newSubSubMap = - Maps.newHashMap(ImmutableMap.of(secondColumn, annotation)); - final Map> newSubMap = - new HashMap<>(); - newSubMap.put(firstColumn, newSubSubMap); - - cellRelationAnnotations.put(row, newSubMap); - } else { - final Map subSubMap = subMap.get(firstColumn); - if (subSubMap == null) { - final Map newSubSubMap = - Maps.newHashMap(ImmutableMap.of(secondColumn, annotation)); - subMap.put(firstColumn, newSubSubMap); - } else { - subSubMap.put(secondColumn, annotation); - } - } - } - } - - private void initializeColumnRelationAnnotations(Result adaptee) { - columnRelationAnnotations = new HashMap<>(); - for (final Map.Entry entry : adaptee - .getColumnRelationAnnotations().entrySet()) { - final ColumnRelationPosition key = entry.getKey(); - final ColumnPosition firstColumn = key.getFirst(); - final ColumnPosition secondColumn = key.getSecond(); - final ColumnRelationAnnotation annotation = entry.getValue(); - - final Map subMap = - columnRelationAnnotations.get(firstColumn); - if (subMap == null) { - columnRelationAnnotations.put(firstColumn, - new HashMap<>(ImmutableMap.of(secondColumn, annotation))); - } else { - subMap.put(secondColumn, annotation); - } - } - } - - /** - * @return the subject column position - */ - @Nullable - public ColumnPosition getSubjectColumnPosition() { - return subjectColumnPosition; - } - - /** - * @param subjectColumnPosition the subject column position to set - */ - public void setSubjectColumnPosition(ColumnPosition subjectColumnPosition) { - Preconditions.checkNotNull(subjectColumnPosition); - - this.subjectColumnPosition = subjectColumnPosition; - } - - /** - * @return the header annotations - */ - public List getHeaderAnnotations() { - return headerAnnotations; - } - - /** - * @param headerAnnotations the header annotations to set - */ - public void setHeaderAnnotations(List headerAnnotations) { - Preconditions.checkNotNull(headerAnnotations); - - this.headerAnnotations = ImmutableList.copyOf(headerAnnotations); - } - - /** - * @return the cell annotations - */ - public CellAnnotation[][] getCellAnnotations() { - return cz.cuni.mff.xrg.odalic.util.Arrays.deepCopy(CellAnnotation.class, cellAnnotations); - } - - /** - * @param cellAnnotations the cell annotations to set - */ - public void setCellAnnotations(CellAnnotation[][] cellAnnotations) { - Preconditions.checkNotNull(cellAnnotations); - - this.cellAnnotations = - cz.cuni.mff.xrg.odalic.util.Arrays.deepCopy(CellAnnotation.class, cellAnnotations); - } - - /** - * @return the column relation Annotations - */ - public Map> getColumnRelationAnnotations() { - return columnRelationAnnotations; - } - - /** - * @param columnRelationAnnotations the column relation annotations to set - */ - public void setColumnRelationAnnotations( - Map> columnRelationAnnotations) { - final ImmutableMap.Builder> columnRelationAnnotationsBuilder = - ImmutableMap.builder(); - for (final Map.Entry> entry : columnRelationAnnotations - .entrySet()) { - columnRelationAnnotationsBuilder.put(entry.getKey(), ImmutableMap.copyOf(entry.getValue())); - } - this.columnRelationAnnotations = columnRelationAnnotationsBuilder.build(); - } - - /** - * @return the cell relation annotations - */ - public Map>> getCellRelationAnnotations() { - return cellRelationAnnotations; - } - - /** - * @param cellRelationAnnotations the cell relation annotations to set - */ - public void setCellRelationAnnotations( - Map>> cellRelationAnnotations) { - final ImmutableMap.Builder>> cellRelationAnnotationsBuilder = - ImmutableMap.builder(); - for (final Map.Entry>> entry : cellRelationAnnotations - .entrySet()) { - final ImmutableMap.Builder> innerMapBuilder = - ImmutableMap.builder(); - for (final Map.Entry> innerEntry : entry - .getValue().entrySet()) { - innerMapBuilder.put(innerEntry.getKey(), ImmutableMap.copyOf(innerEntry.getValue())); - } - - cellRelationAnnotationsBuilder.put(entry.getKey(), innerMapBuilder.build()); - } - this.cellRelationAnnotations = cellRelationAnnotationsBuilder.build(); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "ResultValue [subjectColumnPosition=" + subjectColumnPosition + ", headerAnnotations=" - + headerAnnotations + ", cellAnnotations=" + Arrays.toString(cellAnnotations) - + ", columnRelationAnnotations=" + columnRelationAnnotations + ", cellRelationAnnotations=" - + cellRelationAnnotations + "]"; - } -} +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.apache.jena.ext.com.google.common.collect.ImmutableMap; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Maps; + +import cz.cuni.mff.xrg.odalic.api.rest.conversions.ColumnPositionKeyJsonDeserializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.ColumnPositionKeyJsonSerializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.ColumnPositionToColumnPositionToCellRelationAnnotationMapMapDeserializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.ColumnPositionToColumnPositionToCellRelationAnnotationMapMapSerializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.ColumnPositionToColumnRelationAnnotationMapDeserializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.ColumnPositionToColumnRelationAnnotationMapSerializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.RowPositionKeyJsonDeserializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.RowPositionKeyJsonSerializer; +import cz.cuni.mff.xrg.odalic.positions.CellRelationPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; +import cz.cuni.mff.xrg.odalic.positions.RowPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.HeaderAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.results.Result; + +/** + * Domain class {@link Result} adapted for REST API. + * + * @author Václav Brodec + * + */ +@XmlRootElement(name = "result") +public final class ResultValue implements Serializable { + + private static final long serialVersionUID = -6359038623760039155L; + + @XmlElement + private ColumnPosition subjectColumnPosition; + + @XmlElement + private List headerAnnotations; + + @XmlElement + private CellAnnotation[][] cellAnnotations; + + @XmlElement + @JsonDeserialize(keyUsing = ColumnPositionKeyJsonDeserializer.class, + contentUsing = ColumnPositionToColumnRelationAnnotationMapDeserializer.class) + @JsonSerialize(keyUsing = ColumnPositionKeyJsonSerializer.class, + contentUsing = ColumnPositionToColumnRelationAnnotationMapSerializer.class) + private Map> columnRelationAnnotations; + + @XmlElement + @JsonDeserialize(keyUsing = RowPositionKeyJsonDeserializer.class, + contentUsing = ColumnPositionToColumnPositionToCellRelationAnnotationMapMapDeserializer.class) + @JsonSerialize(keyUsing = RowPositionKeyJsonSerializer.class, + contentUsing = ColumnPositionToColumnPositionToCellRelationAnnotationMapMapSerializer.class) + private Map>> cellRelationAnnotations; + + public ResultValue() { + subjectColumnPosition = null; + headerAnnotations = ImmutableList.of(); + cellAnnotations = new CellAnnotation[0][0];; + columnRelationAnnotations = ImmutableMap.of(); + cellRelationAnnotations = ImmutableMap.of(); + } + + public ResultValue(Result adaptee) { + subjectColumnPosition = adaptee.getSubjectColumnPosition(); + headerAnnotations = adaptee.getHeaderAnnotations(); + cellAnnotations = adaptee.getCellAnnotations(); + + initializeColumnRelationAnnotations(adaptee); + initializeCellRelationAnnotations(adaptee); + } + + private void initializeCellRelationAnnotations(Result adaptee) { + cellRelationAnnotations = new HashMap<>(); + for (final Map.Entry entry : adaptee + .getCellRelationAnnotations().entrySet()) { + final CellRelationPosition key = entry.getKey(); + final RowPosition row = key.getRowPosition(); + final ColumnRelationPosition columns = key.getColumnsPosition(); + + final ColumnPosition firstColumn = columns.getFirst(); + final ColumnPosition secondColumn = columns.getSecond(); + + final CellRelationAnnotation annotation = entry.getValue(); + + final Map> subMap = + cellRelationAnnotations.get(row); + if (subMap == null) { + final Map newSubSubMap = + Maps.newHashMap(ImmutableMap.of(secondColumn, annotation)); + final Map> newSubMap = + new HashMap<>(); + newSubMap.put(firstColumn, newSubSubMap); + + cellRelationAnnotations.put(row, newSubMap); + } else { + final Map subSubMap = subMap.get(firstColumn); + if (subSubMap == null) { + final Map newSubSubMap = + Maps.newHashMap(ImmutableMap.of(secondColumn, annotation)); + subMap.put(firstColumn, newSubSubMap); + } else { + subSubMap.put(secondColumn, annotation); + } + } + } + } + + private void initializeColumnRelationAnnotations(Result adaptee) { + columnRelationAnnotations = new HashMap<>(); + for (final Map.Entry entry : adaptee + .getColumnRelationAnnotations().entrySet()) { + final ColumnRelationPosition key = entry.getKey(); + final ColumnPosition firstColumn = key.getFirst(); + final ColumnPosition secondColumn = key.getSecond(); + final ColumnRelationAnnotation annotation = entry.getValue(); + + final Map subMap = + columnRelationAnnotations.get(firstColumn); + if (subMap == null) { + columnRelationAnnotations.put(firstColumn, + new HashMap<>(ImmutableMap.of(secondColumn, annotation))); + } else { + subMap.put(secondColumn, annotation); + } + } + } + + /** + * @return the subject column position + */ + @Nullable + public ColumnPosition getSubjectColumnPosition() { + return subjectColumnPosition; + } + + /** + * @param subjectColumnPosition the subject column position to set + */ + public void setSubjectColumnPosition(ColumnPosition subjectColumnPosition) { + Preconditions.checkNotNull(subjectColumnPosition); + + this.subjectColumnPosition = subjectColumnPosition; + } + + /** + * @return the header annotations + */ + public List getHeaderAnnotations() { + return headerAnnotations; + } + + /** + * @param headerAnnotations the header annotations to set + */ + public void setHeaderAnnotations(List headerAnnotations) { + Preconditions.checkNotNull(headerAnnotations); + + this.headerAnnotations = ImmutableList.copyOf(headerAnnotations); + } + + /** + * @return the cell annotations + */ + public CellAnnotation[][] getCellAnnotations() { + return cz.cuni.mff.xrg.odalic.util.Arrays.deepCopy(CellAnnotation.class, cellAnnotations); + } + + /** + * @param cellAnnotations the cell annotations to set + */ + public void setCellAnnotations(CellAnnotation[][] cellAnnotations) { + Preconditions.checkNotNull(cellAnnotations); + + this.cellAnnotations = + cz.cuni.mff.xrg.odalic.util.Arrays.deepCopy(CellAnnotation.class, cellAnnotations); + } + + /** + * @return the column relation Annotations + */ + public Map> getColumnRelationAnnotations() { + return columnRelationAnnotations; + } + + /** + * @param columnRelationAnnotations the column relation annotations to set + */ + public void setColumnRelationAnnotations( + Map> columnRelationAnnotations) { + final ImmutableMap.Builder> columnRelationAnnotationsBuilder = + ImmutableMap.builder(); + for (final Map.Entry> entry : columnRelationAnnotations + .entrySet()) { + columnRelationAnnotationsBuilder.put(entry.getKey(), ImmutableMap.copyOf(entry.getValue())); + } + this.columnRelationAnnotations = columnRelationAnnotationsBuilder.build(); + } + + /** + * @return the cell relation annotations + */ + public Map>> getCellRelationAnnotations() { + return cellRelationAnnotations; + } + + /** + * @param cellRelationAnnotations the cell relation annotations to set + */ + public void setCellRelationAnnotations( + Map>> cellRelationAnnotations) { + final ImmutableMap.Builder>> cellRelationAnnotationsBuilder = + ImmutableMap.builder(); + for (final Map.Entry>> entry : cellRelationAnnotations + .entrySet()) { + final ImmutableMap.Builder> innerMapBuilder = + ImmutableMap.builder(); + for (final Map.Entry> innerEntry : entry + .getValue().entrySet()) { + innerMapBuilder.put(innerEntry.getKey(), ImmutableMap.copyOf(innerEntry.getValue())); + } + + cellRelationAnnotationsBuilder.put(entry.getKey(), innerMapBuilder.build()); + } + this.cellRelationAnnotations = cellRelationAnnotationsBuilder.build(); + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ResultValue [subjectColumnPosition=" + subjectColumnPosition + ", headerAnnotations=" + + headerAnnotations + ", cellAnnotations=" + Arrays.toString(cellAnnotations) + + ", columnRelationAnnotations=" + columnRelationAnnotations + ", cellRelationAnnotations=" + + cellRelationAnnotations + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/RowPositionValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/RowPositionValue.java index 306cf497..662ff88f 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/RowPositionValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/RowPositionValue.java @@ -1,54 +1,54 @@ -package cz.cuni.mff.xrg.odalic.api.rest.values; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.positions.RowPosition; - -/** - * Domain class {@link RowPosition} adapted for REST API. - * - * @author Václav Brodec - * - */ -@XmlRootElement(name = "rowPosition") -public final class RowPositionValue { - - @XmlElement - private int index; - - public RowPositionValue() {} - - /** - * @param adaptee - */ - public RowPositionValue(RowPosition adaptee) { - this.index = adaptee.getIndex(); - } - - /** - * @return the index - */ - public int getIndex() { - return index; - } - - /** - * @param index the index to set - */ - public void setIndex(int index) { - Preconditions.checkArgument(index >= 0); - - this.index = index; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "RowPositionValue [index=" + index + "]"; - } -} +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.positions.RowPosition; + +/** + * Domain class {@link RowPosition} adapted for REST API. + * + * @author Václav Brodec + * + */ +@XmlRootElement(name = "rowPosition") +public final class RowPositionValue { + + @XmlElement + private int index; + + public RowPositionValue() {} + + /** + * @param adaptee + */ + public RowPositionValue(RowPosition adaptee) { + this.index = adaptee.getIndex(); + } + + /** + * @return the index + */ + public int getIndex() { + return index; + } + + /** + * @param index the index to set + */ + public void setIndex(int index) { + Preconditions.checkArgument(index >= 0); + + this.index = index; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "RowPositionValue [index=" + index + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/StateValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/StateValue.java index 7eb24135..0f8a02fb 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/StateValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/StateValue.java @@ -1,41 +1,41 @@ -package cz.cuni.mff.xrg.odalic.api.rest.values; - -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlEnumValue; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -import cz.cuni.mff.xrg.odalic.tasks.Task; -import cz.cuni.mff.xrg.odalic.tasks.executions.ExecutionService; - -/** - * Explicit {@link Task} execution state representation for REST API. - * - * @author Václav Brodec - * - * @see ExecutionService - */ -@XmlType -@XmlEnum(String.class) -@XmlRootElement(name = "state") -public enum StateValue { - /** - * Task is specified, but not yet submitted for execution. - */ - @XmlEnumValue("READY") READY, - - /** - * Task is submitted for execution, but not done or canceled yet. - */ - @XmlEnumValue("SCHEDULED") SCHEDULED, - - /** - * Task execution has been voluntarily canceled and no new is submitted. - */ - @XmlEnumValue("CANCELLED") CANCELLED, - - /** - * Task execution has ended (either with result or error). - */ - @XmlEnumValue("FINISHED") FINISHED -} +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +import cz.cuni.mff.xrg.odalic.tasks.Task; +import cz.cuni.mff.xrg.odalic.tasks.executions.ExecutionService; + +/** + * Explicit {@link Task} execution state representation for REST API. + * + * @author Václav Brodec + * + * @see ExecutionService + */ +@XmlType +@XmlEnum(String.class) +@XmlRootElement(name = "state") +public enum StateValue { + /** + * Task is specified, but not yet submitted for execution. + */ + @XmlEnumValue("READY") READY, + + /** + * Task is submitted for execution, but not done or canceled yet. + */ + @XmlEnumValue("SCHEDULED") SCHEDULED, + + /** + * Task execution has been voluntarily canceled and no new is submitted. + */ + @XmlEnumValue("CANCELLED") CANCELLED, + + /** + * Task execution has ended (either with result or error). + */ + @XmlEnumValue("FINISHED") FINISHED +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/TaskValue.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/TaskValue.java index d5548ff2..1a8e60a9 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/TaskValue.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/api/rest/values/TaskValue.java @@ -1,108 +1,108 @@ -package cz.cuni.mff.xrg.odalic.api.rest.values; - -import java.io.Serializable; -import java.util.Date; - -import javax.annotation.Nullable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateDeserializer; -import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateSerializer; -import cz.cuni.mff.xrg.odalic.tasks.Task; - -/** - * Domain class {@link Task} adapted for REST API. - * - * @author Václav Brodec - * - */ -@XmlRootElement(name = "task") -public final class TaskValue implements Serializable { - - private static final long serialVersionUID = 1610346823333685091L; - - @XmlElement - private String id; - - @JsonSerialize(using = CustomJsonDateSerializer.class) - @JsonDeserialize(using = CustomJsonDateDeserializer.class) - @XmlElement - private Date created; - - @XmlElement - private ConfigurationValue configuration; - - public TaskValue() {} - - public TaskValue(Task adaptee) { - id = adaptee.getId(); - created = adaptee.getCreated(); - configuration = new ConfigurationValue(adaptee.getConfiguration()); - } - - /** - * @return the id - */ - @Nullable - public String getId() { - return id; - } - - /** - * @param id the id to set - */ - public void setId(String id) { - Preconditions.checkNotNull(id); - - this.id = id; - } - - /** - * @return the created - */ - @Nullable - public Date getCreated() { - return created; - } - - /** - * @param created the created to set - */ - public void setCreated(Date created) { - Preconditions.checkNotNull(created); - - this.created = created; - } - - /** - * @return the configuration - */ - @Nullable - public ConfigurationValue getConfiguration() { - return configuration; - } - - /** - * @param configuration the configuration to set - */ - public void setConfiguration(ConfigurationValue configuration) { - Preconditions.checkNotNull(configuration); - - this.configuration = configuration; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "TaskValue [id=" + id + ", created=" + created + ", configuration=" + configuration - + "]"; - } -} +package cz.cuni.mff.xrg.odalic.api.rest.values; + +import java.io.Serializable; +import java.util.Date; + +import javax.annotation.Nullable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateDeserializer; +import cz.cuni.mff.xrg.odalic.api.rest.conversions.CustomJsonDateSerializer; +import cz.cuni.mff.xrg.odalic.tasks.Task; + +/** + * Domain class {@link Task} adapted for REST API. + * + * @author Václav Brodec + * + */ +@XmlRootElement(name = "task") +public final class TaskValue implements Serializable { + + private static final long serialVersionUID = 1610346823333685091L; + + @XmlElement + private String id; + + @JsonSerialize(using = CustomJsonDateSerializer.class) + @JsonDeserialize(using = CustomJsonDateDeserializer.class) + @XmlElement + private Date created; + + @XmlElement + private ConfigurationValue configuration; + + public TaskValue() {} + + public TaskValue(Task adaptee) { + id = adaptee.getId(); + created = adaptee.getCreated(); + configuration = new ConfigurationValue(adaptee.getConfiguration()); + } + + /** + * @return the id + */ + @Nullable + public String getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(String id) { + Preconditions.checkNotNull(id); + + this.id = id; + } + + /** + * @return the created + */ + @Nullable + public Date getCreated() { + return created; + } + + /** + * @param created the created to set + */ + public void setCreated(Date created) { + Preconditions.checkNotNull(created); + + this.created = created; + } + + /** + * @return the configuration + */ + @Nullable + public ConfigurationValue getConfiguration() { + return configuration; + } + + /** + * @param configuration the configuration to set + */ + public void setConfiguration(ConfigurationValue configuration) { + Preconditions.checkNotNull(configuration); + + this.configuration = configuration; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "TaskValue [id=" + id + ", created=" + created + ", configuration=" + configuration + + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Ambiguity.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Ambiguity.java index e44badf7..17241e40 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Ambiguity.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Ambiguity.java @@ -1,82 +1,82 @@ -package cz.cuni.mff.xrg.odalic.feedbacks; - -import java.io.Serializable; - -import javax.annotation.concurrent.Immutable; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.api.rest.adapters.AmbiguityAdapter; -import cz.cuni.mff.xrg.odalic.positions.CellPosition; - -@Immutable -@XmlJavaTypeAdapter(AmbiguityAdapter.class) -public final class Ambiguity implements Serializable { - - private static final long serialVersionUID = -9087389821835847372L; - - private final CellPosition position; - - /** - * Creates a new hint to keep a cell ambiguous. - * - * @param position position of the cell - */ - public Ambiguity(CellPosition position) { - Preconditions.checkNotNull(position); - - this.position = position; - } - - /** - * @return the position - */ - public CellPosition getPosition() { - return position; - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((position == null) ? 0 : position.hashCode()); - return result; - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Ambiguity other = (Ambiguity) obj; - if (position == null) { - if (other.position != null) { - return false; - } - } else if (!position.equals(other.position)) { - return false; - } - return true; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "Ambiguity [position=" + position + "]"; - } -} +package cz.cuni.mff.xrg.odalic.feedbacks; + +import java.io.Serializable; + +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.adapters.AmbiguityAdapter; +import cz.cuni.mff.xrg.odalic.positions.CellPosition; + +@Immutable +@XmlJavaTypeAdapter(AmbiguityAdapter.class) +public final class Ambiguity implements Serializable { + + private static final long serialVersionUID = -9087389821835847372L; + + private final CellPosition position; + + /** + * Creates a new hint to keep a cell ambiguous. + * + * @param position position of the cell + */ + public Ambiguity(CellPosition position) { + Preconditions.checkNotNull(position); + + this.position = position; + } + + /** + * @return the position + */ + public CellPosition getPosition() { + return position; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((position == null) ? 0 : position.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Ambiguity other = (Ambiguity) obj; + if (position == null) { + if (other.position != null) { + return false; + } + } else if (!position.equals(other.position)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Ambiguity [position=" + position + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/CellRelation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/CellRelation.java index 8cca6595..912093d6 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/CellRelation.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/CellRelation.java @@ -1,109 +1,109 @@ -package cz.cuni.mff.xrg.odalic.feedbacks; - -import java.io.Serializable; - -import javax.annotation.concurrent.Immutable; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.api.rest.adapters.CellRelationAdapter; -import cz.cuni.mff.xrg.odalic.positions.CellRelationPosition; -import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; - -/** - * Cell relation hint. - * - * @author Václav Brodec - * - */ -@Immutable -@XmlJavaTypeAdapter(CellRelationAdapter.class) -public final class CellRelation implements Serializable { - - private static final long serialVersionUID = -9087389821835847372L; - - private final CellRelationPosition position; - - private final CellRelationAnnotation annotation; - - /** - * Creates new hint for discovered cell relations. - * - * @param position cell position - * @param annotation custom annotation - */ - public CellRelation(CellRelationPosition position, CellRelationAnnotation annotation) { - Preconditions.checkNotNull(position); - Preconditions.checkNotNull(annotation); - - this.position = position; - this.annotation = annotation; - } - - /** - * @return the position - */ - public CellRelationPosition getPosition() { - return position; - } - - /** - * @return the annotation - */ - public CellRelationAnnotation getAnnotation() { - return annotation; - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((annotation == null) ? 0 : annotation.hashCode()); - result = prime * result + ((position == null) ? 0 : position.hashCode()); - return result; - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - CellRelation other = (CellRelation) obj; - if (annotation == null) { - if (other.annotation != null) { - return false; - } - } else if (!annotation.equals(other.annotation)) { - return false; - } - if (position == null) { - if (other.position != null) { - return false; - } - } else if (!position.equals(other.position)) { - return false; - } - return true; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "CellRelation [position=" + position + ", annotation=" + annotation + "]"; - } -} +package cz.cuni.mff.xrg.odalic.feedbacks; + +import java.io.Serializable; + +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.adapters.CellRelationAdapter; +import cz.cuni.mff.xrg.odalic.positions.CellRelationPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; + +/** + * Cell relation hint. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(CellRelationAdapter.class) +public final class CellRelation implements Serializable { + + private static final long serialVersionUID = -9087389821835847372L; + + private final CellRelationPosition position; + + private final CellRelationAnnotation annotation; + + /** + * Creates new hint for discovered cell relations. + * + * @param position cell position + * @param annotation custom annotation + */ + public CellRelation(CellRelationPosition position, CellRelationAnnotation annotation) { + Preconditions.checkNotNull(position); + Preconditions.checkNotNull(annotation); + + this.position = position; + this.annotation = annotation; + } + + /** + * @return the position + */ + public CellRelationPosition getPosition() { + return position; + } + + /** + * @return the annotation + */ + public CellRelationAnnotation getAnnotation() { + return annotation; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((annotation == null) ? 0 : annotation.hashCode()); + result = prime * result + ((position == null) ? 0 : position.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + CellRelation other = (CellRelation) obj; + if (annotation == null) { + if (other.annotation != null) { + return false; + } + } else if (!annotation.equals(other.annotation)) { + return false; + } + if (position == null) { + if (other.position != null) { + return false; + } + } else if (!position.equals(other.position)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "CellRelation [position=" + position + ", annotation=" + annotation + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Classification.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Classification.java index 67da6228..24494ac2 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Classification.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Classification.java @@ -1,109 +1,109 @@ -package cz.cuni.mff.xrg.odalic.feedbacks; - -import java.io.Serializable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.api.rest.adapters.ClassificationAdapter; -import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; -import cz.cuni.mff.xrg.odalic.tasks.annotations.HeaderAnnotation; - -/** - * Classification hint. - * - * @author Václav Brodec - * - */ -@XmlJavaTypeAdapter(ClassificationAdapter.class) -public final class Classification implements Serializable { - - private static final long serialVersionUID = 6053349406668481968L; - - @XmlElement - private final ColumnPosition position; - - @XmlElement - private final HeaderAnnotation annotation; - - /** - * Creates custom classification hint of a column. - * - * @param position column position - * @param annotation custom annotation - */ - public Classification(ColumnPosition position, HeaderAnnotation annotation) { - Preconditions.checkNotNull(position); - Preconditions.checkNotNull(annotation); - - this.position = position; - this.annotation = annotation; - } - - /** - * @return the position - */ - public ColumnPosition getPosition() { - return position; - } - - /** - * @return the annotation - */ - public HeaderAnnotation getAnnotation() { - return annotation; - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((annotation == null) ? 0 : annotation.hashCode()); - result = prime * result + ((position == null) ? 0 : position.hashCode()); - return result; - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Classification other = (Classification) obj; - if (annotation == null) { - if (other.annotation != null) { - return false; - } - } else if (!annotation.equals(other.annotation)) { - return false; - } - if (position == null) { - if (other.position != null) { - return false; - } - } else if (!position.equals(other.position)) { - return false; - } - return true; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "Classification [position=" + position + ", annotation=" + annotation + "]"; - } -} +package cz.cuni.mff.xrg.odalic.feedbacks; + +import java.io.Serializable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.adapters.ClassificationAdapter; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.HeaderAnnotation; + +/** + * Classification hint. + * + * @author Václav Brodec + * + */ +@XmlJavaTypeAdapter(ClassificationAdapter.class) +public final class Classification implements Serializable { + + private static final long serialVersionUID = 6053349406668481968L; + + @XmlElement + private final ColumnPosition position; + + @XmlElement + private final HeaderAnnotation annotation; + + /** + * Creates custom classification hint of a column. + * + * @param position column position + * @param annotation custom annotation + */ + public Classification(ColumnPosition position, HeaderAnnotation annotation) { + Preconditions.checkNotNull(position); + Preconditions.checkNotNull(annotation); + + this.position = position; + this.annotation = annotation; + } + + /** + * @return the position + */ + public ColumnPosition getPosition() { + return position; + } + + /** + * @return the annotation + */ + public HeaderAnnotation getAnnotation() { + return annotation; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((annotation == null) ? 0 : annotation.hashCode()); + result = prime * result + ((position == null) ? 0 : position.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Classification other = (Classification) obj; + if (annotation == null) { + if (other.annotation != null) { + return false; + } + } else if (!annotation.equals(other.annotation)) { + return false; + } + if (position == null) { + if (other.position != null) { + return false; + } + } else if (!position.equals(other.position)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Classification [position=" + position + ", annotation=" + annotation + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnAmbiguity.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnAmbiguity.java index d0d4197a..e32f4652 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnAmbiguity.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnAmbiguity.java @@ -1,88 +1,88 @@ -package cz.cuni.mff.xrg.odalic.feedbacks; - -import java.io.Serializable; - -import javax.annotation.concurrent.Immutable; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.api.rest.adapters.ColumnAmbiguityAdapter; -import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; - -/** - * Hint to leave the cells in column ambiguous. - * - * @author Václav Brodec - * - */ -@Immutable -@XmlJavaTypeAdapter(ColumnAmbiguityAdapter.class) -public final class ColumnAmbiguity implements Serializable { - - private static final long serialVersionUID = -6608929731300596230L; - - private final ColumnPosition position; - - /** - * Creates a new hint to leave the cells in column ambiguous. - * - * @param position column position - */ - public ColumnAmbiguity(ColumnPosition position) { - Preconditions.checkNotNull(position); - - this.position = position; - } - - /** - * @return the position - */ - public ColumnPosition getPosition() { - return position; - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((position == null) ? 0 : position.hashCode()); - return result; - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ColumnAmbiguity other = (ColumnAmbiguity) obj; - if (position == null) { - if (other.position != null) { - return false; - } - } else if (!position.equals(other.position)) { - return false; - } - return true; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "ColumnAmbiguity [position=" + position + "]"; - } -} +package cz.cuni.mff.xrg.odalic.feedbacks; + +import java.io.Serializable; + +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.adapters.ColumnAmbiguityAdapter; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; + +/** + * Hint to leave the cells in column ambiguous. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(ColumnAmbiguityAdapter.class) +public final class ColumnAmbiguity implements Serializable { + + private static final long serialVersionUID = -6608929731300596230L; + + private final ColumnPosition position; + + /** + * Creates a new hint to leave the cells in column ambiguous. + * + * @param position column position + */ + public ColumnAmbiguity(ColumnPosition position) { + Preconditions.checkNotNull(position); + + this.position = position; + } + + /** + * @return the position + */ + public ColumnPosition getPosition() { + return position; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((position == null) ? 0 : position.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ColumnAmbiguity other = (ColumnAmbiguity) obj; + if (position == null) { + if (other.position != null) { + return false; + } + } else if (!position.equals(other.position)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ColumnAmbiguity [position=" + position + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnIgnore.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnIgnore.java index d81ec0bc..0dcae759 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnIgnore.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnIgnore.java @@ -1,88 +1,88 @@ -package cz.cuni.mff.xrg.odalic.feedbacks; - -import java.io.Serializable; - -import javax.annotation.concurrent.Immutable; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.api.rest.adapters.ColumnIgnoreAdapter; -import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; - -/** - * Hint to ignore column. - * - * @author Václav Brodec - * - */ -@Immutable -@XmlJavaTypeAdapter(ColumnIgnoreAdapter.class) -public final class ColumnIgnore implements Serializable { - - private static final long serialVersionUID = -4305681863714969261L; - - private final ColumnPosition position; - - /** - * Creates new hint to ignore column at given position. - * - * @param position position of the ignored column - */ - public ColumnIgnore(ColumnPosition position) { - Preconditions.checkNotNull(position); - - this.position = position; - } - - /** - * @return the position - */ - public ColumnPosition getPosition() { - return position; - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((position == null) ? 0 : position.hashCode()); - return result; - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ColumnIgnore other = (ColumnIgnore) obj; - if (position == null) { - if (other.position != null) { - return false; - } - } else if (!position.equals(other.position)) { - return false; - } - return true; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "ColumnIgnore [position=" + position + "]"; - } -} +package cz.cuni.mff.xrg.odalic.feedbacks; + +import java.io.Serializable; + +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.adapters.ColumnIgnoreAdapter; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; + +/** + * Hint to ignore column. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(ColumnIgnoreAdapter.class) +public final class ColumnIgnore implements Serializable { + + private static final long serialVersionUID = -4305681863714969261L; + + private final ColumnPosition position; + + /** + * Creates new hint to ignore column at given position. + * + * @param position position of the ignored column + */ + public ColumnIgnore(ColumnPosition position) { + Preconditions.checkNotNull(position); + + this.position = position; + } + + /** + * @return the position + */ + public ColumnPosition getPosition() { + return position; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((position == null) ? 0 : position.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ColumnIgnore other = (ColumnIgnore) obj; + if (position == null) { + if (other.position != null) { + return false; + } + } else if (!position.equals(other.position)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ColumnIgnore [position=" + position + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnRelation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnRelation.java index fbd4673f..0b52c739 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnRelation.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/ColumnRelation.java @@ -1,103 +1,103 @@ -package cz.cuni.mff.xrg.odalic.feedbacks; - -import java.io.Serializable; - -import javax.annotation.concurrent.Immutable; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.api.rest.adapters.ColumnRelationAdapter; -import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; -import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; - -@Immutable -@XmlJavaTypeAdapter(ColumnRelationAdapter.class) -public final class ColumnRelation implements Serializable { - - private static final long serialVersionUID = -9087389821835847372L; - - private final ColumnRelationPosition position; - - private final ColumnRelationAnnotation annotation; - - /** - * Creates column relation hint. - * - * @param position position of columns - * @param annotation relation annotation hint - */ - public ColumnRelation(ColumnRelationPosition position, ColumnRelationAnnotation annotation) { - Preconditions.checkNotNull(position); - Preconditions.checkNotNull(annotation); - - this.position = position; - this.annotation = annotation; - } - - /** - * @return the position - */ - public ColumnRelationPosition getPosition() { - return position; - } - - /** - * @return the annotation - */ - public ColumnRelationAnnotation getAnnotation() { - return annotation; - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((annotation == null) ? 0 : annotation.hashCode()); - result = prime * result + ((position == null) ? 0 : position.hashCode()); - return result; - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ColumnRelation other = (ColumnRelation) obj; - if (annotation == null) { - if (other.annotation != null) { - return false; - } - } else if (!annotation.equals(other.annotation)) { - return false; - } - if (position == null) { - if (other.position != null) { - return false; - } - } else if (!position.equals(other.position)) { - return false; - } - return true; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "ColumnRelation [position=" + position + ", annotation=" + annotation + "]"; - } -} +package cz.cuni.mff.xrg.odalic.feedbacks; + +import java.io.Serializable; + +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.adapters.ColumnRelationAdapter; +import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; + +@Immutable +@XmlJavaTypeAdapter(ColumnRelationAdapter.class) +public final class ColumnRelation implements Serializable { + + private static final long serialVersionUID = -9087389821835847372L; + + private final ColumnRelationPosition position; + + private final ColumnRelationAnnotation annotation; + + /** + * Creates column relation hint. + * + * @param position position of columns + * @param annotation relation annotation hint + */ + public ColumnRelation(ColumnRelationPosition position, ColumnRelationAnnotation annotation) { + Preconditions.checkNotNull(position); + Preconditions.checkNotNull(annotation); + + this.position = position; + this.annotation = annotation; + } + + /** + * @return the position + */ + public ColumnRelationPosition getPosition() { + return position; + } + + /** + * @return the annotation + */ + public ColumnRelationAnnotation getAnnotation() { + return annotation; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((annotation == null) ? 0 : annotation.hashCode()); + result = prime * result + ((position == null) ? 0 : position.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ColumnRelation other = (ColumnRelation) obj; + if (annotation == null) { + if (other.annotation != null) { + return false; + } + } else if (!annotation.equals(other.annotation)) { + return false; + } + if (position == null) { + if (other.position != null) { + return false; + } + } else if (!position.equals(other.position)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ColumnRelation [position=" + position + ", annotation=" + annotation + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Disambiguation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Disambiguation.java index f5da2e2f..afcb284b 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Disambiguation.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Disambiguation.java @@ -1,103 +1,103 @@ -package cz.cuni.mff.xrg.odalic.feedbacks; - -import java.io.Serializable; - -import javax.annotation.concurrent.Immutable; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.api.rest.adapters.DisambiguationAdapter; -import cz.cuni.mff.xrg.odalic.positions.CellPosition; -import cz.cuni.mff.xrg.odalic.tasks.annotations.CellAnnotation; - -@Immutable -@XmlJavaTypeAdapter(DisambiguationAdapter.class) -public final class Disambiguation implements Serializable { - - private static final long serialVersionUID = -5229197850609921790L; - - private final CellPosition position; - - private final CellAnnotation annotation; - - /** - * Creates new cell disambiguation hint. - * - * @param position cell position - * @param annotation hinted cell annotation - */ - public Disambiguation(CellPosition position, CellAnnotation annotation) { - Preconditions.checkNotNull(position); - Preconditions.checkNotNull(annotation); - - this.position = position; - this.annotation = annotation; - } - - /** - * @return the position - */ - public CellPosition getPosition() { - return position; - } - - /** - * @return the annotation - */ - public CellAnnotation getAnnotation() { - return annotation; - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((annotation == null) ? 0 : annotation.hashCode()); - result = prime * result + ((position == null) ? 0 : position.hashCode()); - return result; - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Disambiguation other = (Disambiguation) obj; - if (annotation == null) { - if (other.annotation != null) { - return false; - } - } else if (!annotation.equals(other.annotation)) { - return false; - } - if (position == null) { - if (other.position != null) { - return false; - } - } else if (!position.equals(other.position)) { - return false; - } - return true; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "Disambiguation [position=" + position + ", annotation=" + annotation + "]"; - } -} +package cz.cuni.mff.xrg.odalic.feedbacks; + +import java.io.Serializable; + +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.adapters.DisambiguationAdapter; +import cz.cuni.mff.xrg.odalic.positions.CellPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellAnnotation; + +@Immutable +@XmlJavaTypeAdapter(DisambiguationAdapter.class) +public final class Disambiguation implements Serializable { + + private static final long serialVersionUID = -5229197850609921790L; + + private final CellPosition position; + + private final CellAnnotation annotation; + + /** + * Creates new cell disambiguation hint. + * + * @param position cell position + * @param annotation hinted cell annotation + */ + public Disambiguation(CellPosition position, CellAnnotation annotation) { + Preconditions.checkNotNull(position); + Preconditions.checkNotNull(annotation); + + this.position = position; + this.annotation = annotation; + } + + /** + * @return the position + */ + public CellPosition getPosition() { + return position; + } + + /** + * @return the annotation + */ + public CellAnnotation getAnnotation() { + return annotation; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((annotation == null) ? 0 : annotation.hashCode()); + result = prime * result + ((position == null) ? 0 : position.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Disambiguation other = (Disambiguation) obj; + if (annotation == null) { + if (other.annotation != null) { + return false; + } + } else if (!annotation.equals(other.annotation)) { + return false; + } + if (position == null) { + if (other.position != null) { + return false; + } + } else if (!position.equals(other.position)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Disambiguation [position=" + position + ", annotation=" + annotation + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java index 90c13556..ae9124aa 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/feedbacks/Feedback.java @@ -1,262 +1,262 @@ -package cz.cuni.mff.xrg.odalic.feedbacks; - -import java.io.Serializable; -import java.util.Set; - -import javax.annotation.Nullable; -import javax.annotation.concurrent.Immutable; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableSet; - -import cz.cuni.mff.xrg.odalic.api.rest.adapters.FeedbackAdapter; -import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; - -/** - * User feedback for the result of annotating algorithm. Expresses also input constraints for the - * next run. - * - * @author Václav Brodec - * - */ -@Immutable -@XmlJavaTypeAdapter(FeedbackAdapter.class) -public final class Feedback implements Serializable { - - private static final long serialVersionUID = -6359038623760039155L; - - private final ColumnPosition subjectColumnPosition; - - private final Set columnIgnores; - - private final Set classifications; - - private final Set columnAmbiguities; - - private final Set ambiguities; - - private final Set disambiguations; - - private final Set cellRelations; - - private final Set columnRelations; - - - /** - * Creates empty feedback. - */ - public Feedback() { - this.subjectColumnPosition = null; - this.columnIgnores = ImmutableSet.of(); - this.columnAmbiguities = ImmutableSet.of(); - this.classifications = ImmutableSet.of(); - this.cellRelations = ImmutableSet.of(); - this.columnRelations = ImmutableSet.of(); - this.disambiguations = ImmutableSet.of(); - this.ambiguities = ImmutableSet.of(); - } - - /** - * Creates feedback. - * - * @param subjectColumnPosition position of the subject column (optional) - * @param columnIgnores ignored columns - * @param columnAmbiguities columns whose cells will not be disambiguated - * @param classifications classification hints for columns - * @param cellRelations hints with relations between cells on the same rows - * @param columnRelations hints with relation between columns - * @param disambiguations custom disambiguations - * @param ambiguities hints for cells to be left ambiguous - */ - public Feedback(@Nullable ColumnPosition subjectColumnPosition, - Set columnIgnores, Set columnAmbiguities, - Set classifications, Set cellRelations, - Set columnRelations, Set disambiguations, - Set ambiguities) { - Preconditions.checkNotNull(columnIgnores); - Preconditions.checkNotNull(columnAmbiguities); - Preconditions.checkNotNull(classifications); - Preconditions.checkNotNull(cellRelations); - Preconditions.checkNotNull(columnRelations); - Preconditions.checkNotNull(disambiguations); - Preconditions.checkNotNull(ambiguities); - - this.subjectColumnPosition = subjectColumnPosition; - this.columnIgnores = ImmutableSet.copyOf(columnIgnores); - this.columnAmbiguities = ImmutableSet.copyOf(columnAmbiguities); - this.classifications = ImmutableSet.copyOf(classifications); - this.cellRelations = ImmutableSet.copyOf(cellRelations); - this.columnRelations = ImmutableSet.copyOf(columnRelations); - this.disambiguations = ImmutableSet.copyOf(disambiguations); - this.ambiguities = ImmutableSet.copyOf(ambiguities); - } - - /** - * @return the subject column position - */ - @Nullable - public ColumnPosition getSubjectColumnPosition() { - return subjectColumnPosition; - } - - /** - * @return ignored columns - */ - public Set getColumnIgnores() { - return columnIgnores; - } - - /** - * @return ambiguous columns - */ - public Set getColumnAmbiguities() { - return columnAmbiguities; - } - - /** - * @return the classifications - */ - public Set getClassifications() { - return classifications; - } - - /** - * @return the cell relations - */ - public Set getCellRelations() { - return cellRelations; - } - - /** - * @return the column relations - */ - public Set getColumnRelations() { - return columnRelations; - } - - /** - * @return the disambiguations - */ - public Set getDisambiguations() { - return disambiguations; - } - - /** - * @return the forced ambiguous cells - */ - public Set getAmbiguities() { - return ambiguities; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((ambiguities == null) ? 0 : ambiguities.hashCode()); - result = prime * result + ((cellRelations == null) ? 0 : cellRelations.hashCode()); - result = prime * result + ((classifications == null) ? 0 : classifications.hashCode()); - result = prime * result + ((columnAmbiguities == null) ? 0 : columnAmbiguities.hashCode()); - result = prime * result + ((columnIgnores == null) ? 0 : columnIgnores.hashCode()); - result = prime * result + ((columnRelations == null) ? 0 : columnRelations.hashCode()); - result = prime * result + ((disambiguations == null) ? 0 : disambiguations.hashCode()); - result = - prime * result + ((subjectColumnPosition == null) ? 0 : subjectColumnPosition.hashCode()); - return result; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Feedback other = (Feedback) obj; - if (ambiguities == null) { - if (other.ambiguities != null) { - return false; - } - } else if (!ambiguities.equals(other.ambiguities)) { - return false; - } - if (cellRelations == null) { - if (other.cellRelations != null) { - return false; - } - } else if (!cellRelations.equals(other.cellRelations)) { - return false; - } - if (classifications == null) { - if (other.classifications != null) { - return false; - } - } else if (!classifications.equals(other.classifications)) { - return false; - } - if (columnAmbiguities == null) { - if (other.columnAmbiguities != null) { - return false; - } - } else if (!columnAmbiguities.equals(other.columnAmbiguities)) { - return false; - } - if (columnIgnores == null) { - if (other.columnIgnores != null) { - return false; - } - } else if (!columnIgnores.equals(other.columnIgnores)) { - return false; - } - if (columnRelations == null) { - if (other.columnRelations != null) { - return false; - } - } else if (!columnRelations.equals(other.columnRelations)) { - return false; - } - if (disambiguations == null) { - if (other.disambiguations != null) { - return false; - } - } else if (!disambiguations.equals(other.disambiguations)) { - return false; - } - if (subjectColumnPosition == null) { - if (other.subjectColumnPosition != null) { - return false; - } - } else if (!subjectColumnPosition.equals(other.subjectColumnPosition)) { - return false; - } - return true; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "Feedback [subjectColumnPosition=" + subjectColumnPosition + ", columnIgnores=" - + columnIgnores + ", columnAmbiguities=" + columnAmbiguities + ", classifications=" - + classifications + ", cellRelations=" + cellRelations + ", columnRelations=" - + columnRelations + ", disambiguations=" + disambiguations + ", ambiguities=" + ambiguities - + "]"; - } -} +package cz.cuni.mff.xrg.odalic.feedbacks; + +import java.io.Serializable; +import java.util.Set; + +import javax.annotation.Nullable; +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableSet; + +import cz.cuni.mff.xrg.odalic.api.rest.adapters.FeedbackAdapter; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; + +/** + * User feedback for the result of annotating algorithm. Expresses also input constraints for the + * next run. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(FeedbackAdapter.class) +public final class Feedback implements Serializable { + + private static final long serialVersionUID = -6359038623760039155L; + + private final ColumnPosition subjectColumnPosition; + + private final Set columnIgnores; + + private final Set classifications; + + private final Set columnAmbiguities; + + private final Set ambiguities; + + private final Set disambiguations; + + private final Set cellRelations; + + private final Set columnRelations; + + + /** + * Creates empty feedback. + */ + public Feedback() { + this.subjectColumnPosition = null; + this.columnIgnores = ImmutableSet.of(); + this.columnAmbiguities = ImmutableSet.of(); + this.classifications = ImmutableSet.of(); + this.cellRelations = ImmutableSet.of(); + this.columnRelations = ImmutableSet.of(); + this.disambiguations = ImmutableSet.of(); + this.ambiguities = ImmutableSet.of(); + } + + /** + * Creates feedback. + * + * @param subjectColumnPosition position of the subject column (optional) + * @param columnIgnores ignored columns + * @param columnAmbiguities columns whose cells will not be disambiguated + * @param classifications classification hints for columns + * @param cellRelations hints with relations between cells on the same rows + * @param columnRelations hints with relation between columns + * @param disambiguations custom disambiguations + * @param ambiguities hints for cells to be left ambiguous + */ + public Feedback(@Nullable ColumnPosition subjectColumnPosition, + Set columnIgnores, Set columnAmbiguities, + Set classifications, Set cellRelations, + Set columnRelations, Set disambiguations, + Set ambiguities) { + Preconditions.checkNotNull(columnIgnores); + Preconditions.checkNotNull(columnAmbiguities); + Preconditions.checkNotNull(classifications); + Preconditions.checkNotNull(cellRelations); + Preconditions.checkNotNull(columnRelations); + Preconditions.checkNotNull(disambiguations); + Preconditions.checkNotNull(ambiguities); + + this.subjectColumnPosition = subjectColumnPosition; + this.columnIgnores = ImmutableSet.copyOf(columnIgnores); + this.columnAmbiguities = ImmutableSet.copyOf(columnAmbiguities); + this.classifications = ImmutableSet.copyOf(classifications); + this.cellRelations = ImmutableSet.copyOf(cellRelations); + this.columnRelations = ImmutableSet.copyOf(columnRelations); + this.disambiguations = ImmutableSet.copyOf(disambiguations); + this.ambiguities = ImmutableSet.copyOf(ambiguities); + } + + /** + * @return the subject column position + */ + @Nullable + public ColumnPosition getSubjectColumnPosition() { + return subjectColumnPosition; + } + + /** + * @return ignored columns + */ + public Set getColumnIgnores() { + return columnIgnores; + } + + /** + * @return ambiguous columns + */ + public Set getColumnAmbiguities() { + return columnAmbiguities; + } + + /** + * @return the classifications + */ + public Set getClassifications() { + return classifications; + } + + /** + * @return the cell relations + */ + public Set getCellRelations() { + return cellRelations; + } + + /** + * @return the column relations + */ + public Set getColumnRelations() { + return columnRelations; + } + + /** + * @return the disambiguations + */ + public Set getDisambiguations() { + return disambiguations; + } + + /** + * @return the forced ambiguous cells + */ + public Set getAmbiguities() { + return ambiguities; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((ambiguities == null) ? 0 : ambiguities.hashCode()); + result = prime * result + ((cellRelations == null) ? 0 : cellRelations.hashCode()); + result = prime * result + ((classifications == null) ? 0 : classifications.hashCode()); + result = prime * result + ((columnAmbiguities == null) ? 0 : columnAmbiguities.hashCode()); + result = prime * result + ((columnIgnores == null) ? 0 : columnIgnores.hashCode()); + result = prime * result + ((columnRelations == null) ? 0 : columnRelations.hashCode()); + result = prime * result + ((disambiguations == null) ? 0 : disambiguations.hashCode()); + result = + prime * result + ((subjectColumnPosition == null) ? 0 : subjectColumnPosition.hashCode()); + return result; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Feedback other = (Feedback) obj; + if (ambiguities == null) { + if (other.ambiguities != null) { + return false; + } + } else if (!ambiguities.equals(other.ambiguities)) { + return false; + } + if (cellRelations == null) { + if (other.cellRelations != null) { + return false; + } + } else if (!cellRelations.equals(other.cellRelations)) { + return false; + } + if (classifications == null) { + if (other.classifications != null) { + return false; + } + } else if (!classifications.equals(other.classifications)) { + return false; + } + if (columnAmbiguities == null) { + if (other.columnAmbiguities != null) { + return false; + } + } else if (!columnAmbiguities.equals(other.columnAmbiguities)) { + return false; + } + if (columnIgnores == null) { + if (other.columnIgnores != null) { + return false; + } + } else if (!columnIgnores.equals(other.columnIgnores)) { + return false; + } + if (columnRelations == null) { + if (other.columnRelations != null) { + return false; + } + } else if (!columnRelations.equals(other.columnRelations)) { + return false; + } + if (disambiguations == null) { + if (other.disambiguations != null) { + return false; + } + } else if (!disambiguations.equals(other.disambiguations)) { + return false; + } + if (subjectColumnPosition == null) { + if (other.subjectColumnPosition != null) { + return false; + } + } else if (!subjectColumnPosition.equals(other.subjectColumnPosition)) { + return false; + } + return true; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Feedback [subjectColumnPosition=" + subjectColumnPosition + ", columnIgnores=" + + columnIgnores + ", columnAmbiguities=" + columnAmbiguities + ", classifications=" + + classifications + ", cellRelations=" + cellRelations + ", columnRelations=" + + columnRelations + ", disambiguations=" + disambiguations + ", ambiguities=" + ambiguities + + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/File.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/File.java index c8edf1f5..ab98dfe1 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/File.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/File.java @@ -1,165 +1,165 @@ -package cz.cuni.mff.xrg.odalic.files; - -import java.io.Serializable; -import java.net.URL; -import java.util.Date; - -import javax.annotation.concurrent.Immutable; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.api.rest.adapters.FileAdapter; - -/** - * File description. - * - * @author Václav Brodec - * - */ -@Immutable -@XmlJavaTypeAdapter(FileAdapter.class) -public class File implements Serializable { - - private static final long serialVersionUID = -6359038623760039155L; - - private final String id; - - private final Date uploaded; - - private final String owner; - - private final URL location; - - /** - * Create new file description. - * - * @param id file ID - * @param uploaded time of upload - * @param owner file owner description - * @param location file location - */ - public File(String id, Date uploaded, String owner, URL location) { - Preconditions.checkNotNull(id); - Preconditions.checkNotNull(uploaded); - Preconditions.checkNotNull(owner); - Preconditions.checkNotNull(location); - - this.id = id; - this.uploaded = uploaded; - this.owner = owner; - this.location = location; - } - - /** - * Create new file description for a file uploaded now. - * - * @param id file ID - * @param owner file owner description - * @param location file location - */ - public File(String id, String owner, URL location) { - this(id, new Date(), owner, location); - } - - /** - * @return the id - */ - public String getId() { - return id; - } - - /** - * @return the uploaded - */ - public Date getUploaded() { - return uploaded; - } - - /** - * @return the owner - */ - public String getOwner() { - return owner; - } - - /** - * @return the location - */ - public URL getLocation() { - return location; - } - - /** - * Computes the hash code based on all components. - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((id == null) ? 0 : id.hashCode()); - result = prime * result + ((location == null) ? 0 : location.hashCode()); - result = prime * result + ((owner == null) ? 0 : owner.hashCode()); - result = prime * result + ((uploaded == null) ? 0 : uploaded.hashCode()); - return result; - } - - /** - * Compares for equivalence (only other File description with the same components passes). - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - File other = (File) obj; - if (id == null) { - if (other.id != null) { - return false; - } - } else if (!id.equals(other.id)) { - return false; - } - if (location == null) { - if (other.location != null) { - return false; - } - } else if (!location.equals(other.location)) { - return false; - } - if (owner == null) { - if (other.owner != null) { - return false; - } - } else if (!owner.equals(other.owner)) { - return false; - } - if (uploaded == null) { - if (other.uploaded != null) { - return false; - } - } else if (!uploaded.equals(other.uploaded)) { - return false; - } - return true; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "File [id=" + id + ", uploaded=" + uploaded + ", owner=" + owner + ", location=" - + location + "]"; - } -} +package cz.cuni.mff.xrg.odalic.files; + +import java.io.Serializable; +import java.net.URL; +import java.util.Date; + +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.adapters.FileAdapter; + +/** + * File description. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(FileAdapter.class) +public class File implements Serializable { + + private static final long serialVersionUID = -6359038623760039155L; + + private final String id; + + private final Date uploaded; + + private final String owner; + + private final URL location; + + /** + * Create new file description. + * + * @param id file ID + * @param uploaded time of upload + * @param owner file owner description + * @param location file location + */ + public File(String id, Date uploaded, String owner, URL location) { + Preconditions.checkNotNull(id); + Preconditions.checkNotNull(uploaded); + Preconditions.checkNotNull(owner); + Preconditions.checkNotNull(location); + + this.id = id; + this.uploaded = uploaded; + this.owner = owner; + this.location = location; + } + + /** + * Create new file description for a file uploaded now. + * + * @param id file ID + * @param owner file owner description + * @param location file location + */ + public File(String id, String owner, URL location) { + this(id, new Date(), owner, location); + } + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @return the uploaded + */ + public Date getUploaded() { + return uploaded; + } + + /** + * @return the owner + */ + public String getOwner() { + return owner; + } + + /** + * @return the location + */ + public URL getLocation() { + return location; + } + + /** + * Computes the hash code based on all components. + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((location == null) ? 0 : location.hashCode()); + result = prime * result + ((owner == null) ? 0 : owner.hashCode()); + result = prime * result + ((uploaded == null) ? 0 : uploaded.hashCode()); + return result; + } + + /** + * Compares for equivalence (only other File description with the same components passes). + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + File other = (File) obj; + if (id == null) { + if (other.id != null) { + return false; + } + } else if (!id.equals(other.id)) { + return false; + } + if (location == null) { + if (other.location != null) { + return false; + } + } else if (!location.equals(other.location)) { + return false; + } + if (owner == null) { + if (other.owner != null) { + return false; + } + } else if (!owner.equals(other.owner)) { + return false; + } + if (uploaded == null) { + if (other.uploaded != null) { + return false; + } + } else if (!uploaded.equals(other.uploaded)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "File [id=" + id + ", uploaded=" + uploaded + ", owner=" + owner + ", location=" + + location + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileService.java index bf270c35..f8e6294b 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/FileService.java @@ -1,65 +1,65 @@ -package cz.cuni.mff.xrg.odalic.files; - -import java.io.IOException; -import java.io.InputStream; -import java.util.List; - -/** - * Provides basic set of operations for uploaded or remote files. - * - * @author Václav Brodec - * - */ -public interface FileService { - - /** - * Registers a new remote file. - * - * @param file file description - */ - void create(File file); - - /** - * Registers a new file and reads its content from the stream. - * - * @param file file description - * @param fileInputStream file content - * @throws IOException if an I/O error occurs - */ - void create(File file, InputStream fileInputStream) throws IOException; - - void deleteById(String id); - - File getById(String id); - - List getFiles(); - - /** - * Replaces file description. - * - * @param file file description - */ - void replace(File file); - - /** - * Replaces the file description and the file content. - * - * @param file file description - * @param fileInputStream file content - * @throws IOException if an I/O error occurs - */ - void replace(File file, InputStream fileInputStream) throws IOException; - - boolean existsFileWithId(String id); - - boolean hasId(File file, String id); - - /** - * Reads content of the file. - * - * @param id file ID - * @return textual content of the file - * @throws IOException if an I/O error occurs - */ - String getDataById(String id) throws IOException; -} +package cz.cuni.mff.xrg.odalic.files; + +import java.io.IOException; +import java.io.InputStream; +import java.util.List; + +/** + * Provides basic set of operations for uploaded or remote files. + * + * @author Václav Brodec + * + */ +public interface FileService { + + /** + * Registers a new remote file. + * + * @param file file description + */ + void create(File file); + + /** + * Registers a new file and reads its content from the stream. + * + * @param file file description + * @param fileInputStream file content + * @throws IOException if an I/O error occurs + */ + void create(File file, InputStream fileInputStream) throws IOException; + + void deleteById(String id); + + File getById(String id); + + List getFiles(); + + /** + * Replaces file description. + * + * @param file file description + */ + void replace(File file); + + /** + * Replaces the file description and the file content. + * + * @param file file description + * @param fileInputStream file content + * @throws IOException if an I/O error occurs + */ + void replace(File file, InputStream fileInputStream) throws IOException; + + boolean existsFileWithId(String id); + + boolean hasId(File file, String id); + + /** + * Reads content of the file. + * + * @param id file ID + * @return textual content of the file + * @throws IOException if an I/O error occurs + */ + String getDataById(String id) throws IOException; +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/MemoryOnlyFileService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/MemoryOnlyFileService.java index 722cca83..56645eab 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/MemoryOnlyFileService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/files/MemoryOnlyFileService.java @@ -1,163 +1,163 @@ -/** - * - */ -package cz.cuni.mff.xrg.odalic.files; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.commons.io.IOUtils; -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableList; - -/** - * This {@link FileService} implementation provides no persistence. - * - * @author Václav Brodec - * - */ -public final class MemoryOnlyFileService implements FileService { - - private final Map files; - - private final Map data; - - private MemoryOnlyFileService(Map files, Map data) { - Preconditions.checkNotNull(files); - Preconditions.checkNotNull(data); - - this.files = files; - this.data = data; - } - - /** - * Creates the file service with no registered files and data. - */ - public MemoryOnlyFileService() { - this(new HashMap<>(), new HashMap<>()); - } - - /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.files.FileService#create(cz.cuni.mff.xrg.odalic.files.File) - */ - @Override - public void create(File file) { - if (existsFileWithId(file.getId())) { - throw new IllegalArgumentException(); - } - - replace(file); - } - - /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.files.FileService#create(cz.cuni.mff.xrg.odalic.files.File, java.io.InputStream) - */ - @Override - public void create(File file, InputStream fileInputStream) throws IOException { - if (existsFileWithId(file.getId())) { - throw new IllegalArgumentException(); - } - - replace(file, fileInputStream); - } - - /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.files.FileService#deleteById(java.lang.String) - */ - @Override - public void deleteById(String id) { - Preconditions.checkNotNull(id); - - File file = this.files.remove(id); - if (file == null) { - throw new IllegalArgumentException(); - } - - this.data.remove(file.getLocation()); - } - - /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.files.FileService#getById(java.lang.String) - */ - @Override - public File getById(String id) { - Preconditions.checkNotNull(id); - - File file = this.files.get(id); - if (file == null) { - throw new IllegalArgumentException(); - } - - return file; - } - - /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.files.FileService#getFiles() - */ - @Override - public List getFiles() { - return ImmutableList.copyOf(this.files.values()); - } - - /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.files.FileService#replace(cz.cuni.mff.xrg.odalic.files.File) - */ - @Override - public void replace(File file) { - this.files.put(file.getId(), file); - } - - - /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.files.FileService#replace(cz.cuni.mff.xrg.odalic.files.File, java.io.InputStream) - */ - @Override - public void replace(File file, InputStream fileInputStream) throws IOException { - this.files.put(file.getId(), file); - this.data.put(file.getLocation(), IOUtils.toString(fileInputStream, StandardCharsets.UTF_8)); - } - - /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.files.FileService#existsFileWithId(java.lang.String) - */ - @Override - public boolean existsFileWithId(String id) { - Preconditions.checkNotNull(id); - - return this.files.containsKey(id); - } - - /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.files.FileService#hasId(cz.cuni.mff.xrg.odalic.files.File, java.lang.String) - */ - @Override - public boolean hasId(File file, String id) { - Preconditions.checkNotNull(id); - - if (file.getId() == null) { - return false; - } - - return file.getId().equals(id); - } - - /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.files.FileService#getDataById(java.lang.String) - */ - @Override - public String getDataById(String id) throws IOException { - File file = getById(id); - - String data = this.data.get(file.getLocation()); - if (data == null) { - return IOUtils.toString(file.getLocation(), StandardCharsets.UTF_8); - } else { - return data; - } - } -} +/** + * + */ +package cz.cuni.mff.xrg.odalic.files; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.io.IOUtils; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +/** + * This {@link FileService} implementation provides no persistence. + * + * @author Václav Brodec + * + */ +public final class MemoryOnlyFileService implements FileService { + + private final Map files; + + private final Map data; + + private MemoryOnlyFileService(Map files, Map data) { + Preconditions.checkNotNull(files); + Preconditions.checkNotNull(data); + + this.files = files; + this.data = data; + } + + /** + * Creates the file service with no registered files and data. + */ + public MemoryOnlyFileService() { + this(new HashMap<>(), new HashMap<>()); + } + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.files.FileService#create(cz.cuni.mff.xrg.odalic.files.File) + */ + @Override + public void create(File file) { + if (existsFileWithId(file.getId())) { + throw new IllegalArgumentException(); + } + + replace(file); + } + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.files.FileService#create(cz.cuni.mff.xrg.odalic.files.File, java.io.InputStream) + */ + @Override + public void create(File file, InputStream fileInputStream) throws IOException { + if (existsFileWithId(file.getId())) { + throw new IllegalArgumentException(); + } + + replace(file, fileInputStream); + } + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.files.FileService#deleteById(java.lang.String) + */ + @Override + public void deleteById(String id) { + Preconditions.checkNotNull(id); + + File file = this.files.remove(id); + if (file == null) { + throw new IllegalArgumentException(); + } + + this.data.remove(file.getLocation()); + } + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.files.FileService#getById(java.lang.String) + */ + @Override + public File getById(String id) { + Preconditions.checkNotNull(id); + + File file = this.files.get(id); + if (file == null) { + throw new IllegalArgumentException(); + } + + return file; + } + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.files.FileService#getFiles() + */ + @Override + public List getFiles() { + return ImmutableList.copyOf(this.files.values()); + } + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.files.FileService#replace(cz.cuni.mff.xrg.odalic.files.File) + */ + @Override + public void replace(File file) { + this.files.put(file.getId(), file); + } + + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.files.FileService#replace(cz.cuni.mff.xrg.odalic.files.File, java.io.InputStream) + */ + @Override + public void replace(File file, InputStream fileInputStream) throws IOException { + this.files.put(file.getId(), file); + this.data.put(file.getLocation(), IOUtils.toString(fileInputStream, StandardCharsets.UTF_8)); + } + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.files.FileService#existsFileWithId(java.lang.String) + */ + @Override + public boolean existsFileWithId(String id) { + Preconditions.checkNotNull(id); + + return this.files.containsKey(id); + } + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.files.FileService#hasId(cz.cuni.mff.xrg.odalic.files.File, java.lang.String) + */ + @Override + public boolean hasId(File file, String id) { + Preconditions.checkNotNull(id); + + if (file.getId() == null) { + return false; + } + + return file.getId().equals(id); + } + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.files.FileService#getDataById(java.lang.String) + */ + @Override + public String getDataById(String id) throws IOException { + File file = getById(id); + + String data = this.data.get(file.getLocation()); + if (data == null) { + return IOUtils.toString(file.getLocation(), StandardCharsets.UTF_8); + } else { + return data; + } + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/CsvConfiguration.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/CsvConfiguration.java index 7f891053..186c9cea 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/CsvConfiguration.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/CsvConfiguration.java @@ -1,248 +1,248 @@ -package cz.cuni.mff.xrg.odalic.input; - -import java.io.Serializable; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; - -import javax.annotation.Nullable; -import javax.annotation.concurrent.Immutable; - -import org.apache.commons.csv.CSVFormat; - -import com.google.common.base.Preconditions; - -/** - * Configuration of the CSV file for the parser. - * - * @author Jan Váňa - * @author Václav Brodec - */ -@Immutable -public final class CsvConfiguration implements Serializable { - - private static final long serialVersionUID = 5335583951933923025L; - - private final Charset charset; - private final char delimiter; - private final boolean headerPresent; - private final boolean emptyLinesIgnored; - private final boolean headerCaseIgnored; - private final Character quoteCharacter; - private final Character escapeCharacter; - private final Character commentMarker; - - - public CsvConfiguration(Charset charset, char delimiter, boolean headerPresent, - boolean emptyLinesIgnored, boolean headerCaseIgnored, @Nullable Character quoteCharacter, - @Nullable Character escapeCharacter, @Nullable Character commentMarker) { - Preconditions.checkNotNull(charset); - - this.charset = charset; - this.delimiter = delimiter; - this.headerPresent = headerPresent; - this.emptyLinesIgnored = emptyLinesIgnored; - this.headerCaseIgnored = headerCaseIgnored; - this.quoteCharacter = quoteCharacter; - this.escapeCharacter = escapeCharacter; - this.commentMarker = commentMarker; - } - - - public CsvConfiguration() { - charset = StandardCharsets.UTF_8; - delimiter = ';'; - headerPresent = true; - emptyLinesIgnored = true; - headerCaseIgnored = false; - quoteCharacter = null; - escapeCharacter = null; - commentMarker = null; - } - - - /** - * @return the character set - */ - public Charset getCharset() { - return charset; - } - - - /** - * @return the delimiter - */ - public char getDelimiter() { - return delimiter; - } - - - /** - * @return the header present - */ - public boolean isHeaderPresent() { - return headerPresent; - } - - - /** - * @return the empty lines ignored - */ - public boolean isEmptyLinesIgnored() { - return emptyLinesIgnored; - } - - - /** - * @return the header case ignored - */ - public boolean isHeaderCaseIgnored() { - return headerCaseIgnored; - } - - - /** - * @return the quote character - */ - @Nullable - public Character getQuoteCharacter() { - return quoteCharacter; - } - - - /** - * @return the escape character - */ - @Nullable - public Character getEscapeCharacter() { - return escapeCharacter; - } - - - /** - * @return the comment marker - */ - @Nullable - public Character getCommentMarker() { - return commentMarker; - } - - - CSVFormat toApacheConfiguration() { - CSVFormat format = CSVFormat.newFormat(delimiter).withAllowMissingColumnNames() - .withIgnoreEmptyLines(emptyLinesIgnored).withIgnoreHeaderCase(headerCaseIgnored); - - if (quoteCharacter != null) { - format = format.withQuote(quoteCharacter); - } - - if (headerPresent) { - format = format.withHeader(); - } - - if (escapeCharacter != null) { - format = format.withEscape(escapeCharacter); - } - - if (commentMarker != null) { - format = format.withCommentMarker(commentMarker); - } - - return format; - } - - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((charset == null) ? 0 : charset.hashCode()); - result = prime * result + ((commentMarker == null) ? 0 : commentMarker.hashCode()); - result = prime * result + delimiter; - result = prime * result + (emptyLinesIgnored ? 1231 : 1237); - result = prime * result + ((escapeCharacter == null) ? 0 : escapeCharacter.hashCode()); - result = prime * result + (headerCaseIgnored ? 1231 : 1237); - result = prime * result + (headerPresent ? 1231 : 1237); - result = prime * result + ((quoteCharacter == null) ? 0 : quoteCharacter.hashCode()); - return result; - } - - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - CsvConfiguration other = (CsvConfiguration) obj; - if (charset == null) { - if (other.charset != null) { - return false; - } - } else if (!charset.equals(other.charset)) { - return false; - } - if (commentMarker == null) { - if (other.commentMarker != null) { - return false; - } - } else if (!commentMarker.equals(other.commentMarker)) { - return false; - } - if (delimiter != other.delimiter) { - return false; - } - if (emptyLinesIgnored != other.emptyLinesIgnored) { - return false; - } - if (escapeCharacter == null) { - if (other.escapeCharacter != null) { - return false; - } - } else if (!escapeCharacter.equals(other.escapeCharacter)) { - return false; - } - if (headerCaseIgnored != other.headerCaseIgnored) { - return false; - } - if (headerPresent != other.headerPresent) { - return false; - } - if (quoteCharacter == null) { - if (other.quoteCharacter != null) { - return false; - } - } else if (!quoteCharacter.equals(other.quoteCharacter)) { - return false; - } - return true; - } - - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "CsvConfiguration [charset=" + charset + ", delimiter=" + delimiter + ", headerPresent=" - + headerPresent + ", emptyLinesIgnored=" + emptyLinesIgnored + ", headerCaseIgnored=" - + headerCaseIgnored + ", quoteCharacter=" + quoteCharacter + ", escapeCharacter=" - + escapeCharacter + ", commentMarker=" + commentMarker + "]"; - } -} +package cz.cuni.mff.xrg.odalic.input; + +import java.io.Serializable; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; + +import javax.annotation.Nullable; +import javax.annotation.concurrent.Immutable; + +import org.apache.commons.csv.CSVFormat; + +import com.google.common.base.Preconditions; + +/** + * Configuration of the CSV file for the parser. + * + * @author Jan Váňa + * @author Václav Brodec + */ +@Immutable +public final class CsvConfiguration implements Serializable { + + private static final long serialVersionUID = 5335583951933923025L; + + private final Charset charset; + private final char delimiter; + private final boolean headerPresent; + private final boolean emptyLinesIgnored; + private final boolean headerCaseIgnored; + private final Character quoteCharacter; + private final Character escapeCharacter; + private final Character commentMarker; + + + public CsvConfiguration(Charset charset, char delimiter, boolean headerPresent, + boolean emptyLinesIgnored, boolean headerCaseIgnored, @Nullable Character quoteCharacter, + @Nullable Character escapeCharacter, @Nullable Character commentMarker) { + Preconditions.checkNotNull(charset); + + this.charset = charset; + this.delimiter = delimiter; + this.headerPresent = headerPresent; + this.emptyLinesIgnored = emptyLinesIgnored; + this.headerCaseIgnored = headerCaseIgnored; + this.quoteCharacter = quoteCharacter; + this.escapeCharacter = escapeCharacter; + this.commentMarker = commentMarker; + } + + + public CsvConfiguration() { + charset = StandardCharsets.UTF_8; + delimiter = ';'; + headerPresent = true; + emptyLinesIgnored = true; + headerCaseIgnored = false; + quoteCharacter = null; + escapeCharacter = null; + commentMarker = null; + } + + + /** + * @return the character set + */ + public Charset getCharset() { + return charset; + } + + + /** + * @return the delimiter + */ + public char getDelimiter() { + return delimiter; + } + + + /** + * @return the header present + */ + public boolean isHeaderPresent() { + return headerPresent; + } + + + /** + * @return the empty lines ignored + */ + public boolean isEmptyLinesIgnored() { + return emptyLinesIgnored; + } + + + /** + * @return the header case ignored + */ + public boolean isHeaderCaseIgnored() { + return headerCaseIgnored; + } + + + /** + * @return the quote character + */ + @Nullable + public Character getQuoteCharacter() { + return quoteCharacter; + } + + + /** + * @return the escape character + */ + @Nullable + public Character getEscapeCharacter() { + return escapeCharacter; + } + + + /** + * @return the comment marker + */ + @Nullable + public Character getCommentMarker() { + return commentMarker; + } + + + CSVFormat toApacheConfiguration() { + CSVFormat format = CSVFormat.newFormat(delimiter).withAllowMissingColumnNames() + .withIgnoreEmptyLines(emptyLinesIgnored).withIgnoreHeaderCase(headerCaseIgnored); + + if (quoteCharacter != null) { + format = format.withQuote(quoteCharacter); + } + + if (headerPresent) { + format = format.withHeader(); + } + + if (escapeCharacter != null) { + format = format.withEscape(escapeCharacter); + } + + if (commentMarker != null) { + format = format.withCommentMarker(commentMarker); + } + + return format; + } + + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((charset == null) ? 0 : charset.hashCode()); + result = prime * result + ((commentMarker == null) ? 0 : commentMarker.hashCode()); + result = prime * result + delimiter; + result = prime * result + (emptyLinesIgnored ? 1231 : 1237); + result = prime * result + ((escapeCharacter == null) ? 0 : escapeCharacter.hashCode()); + result = prime * result + (headerCaseIgnored ? 1231 : 1237); + result = prime * result + (headerPresent ? 1231 : 1237); + result = prime * result + ((quoteCharacter == null) ? 0 : quoteCharacter.hashCode()); + return result; + } + + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + CsvConfiguration other = (CsvConfiguration) obj; + if (charset == null) { + if (other.charset != null) { + return false; + } + } else if (!charset.equals(other.charset)) { + return false; + } + if (commentMarker == null) { + if (other.commentMarker != null) { + return false; + } + } else if (!commentMarker.equals(other.commentMarker)) { + return false; + } + if (delimiter != other.delimiter) { + return false; + } + if (emptyLinesIgnored != other.emptyLinesIgnored) { + return false; + } + if (escapeCharacter == null) { + if (other.escapeCharacter != null) { + return false; + } + } else if (!escapeCharacter.equals(other.escapeCharacter)) { + return false; + } + if (headerCaseIgnored != other.headerCaseIgnored) { + return false; + } + if (headerPresent != other.headerPresent) { + return false; + } + if (quoteCharacter == null) { + if (other.quoteCharacter != null) { + return false; + } + } else if (!quoteCharacter.equals(other.quoteCharacter)) { + return false; + } + return true; + } + + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "CsvConfiguration [charset=" + charset + ", delimiter=" + delimiter + ", headerPresent=" + + headerPresent + ", emptyLinesIgnored=" + emptyLinesIgnored + ", headerCaseIgnored=" + + headerCaseIgnored + ", quoteCharacter=" + quoteCharacter + ", escapeCharacter=" + + escapeCharacter + ", commentMarker=" + commentMarker + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/CsvInputParser.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/CsvInputParser.java index d2bfd1fa..96226e50 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/CsvInputParser.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/CsvInputParser.java @@ -1,22 +1,22 @@ -package cz.cuni.mff.xrg.odalic.input; - -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; - -/** - * CSV input parser. - * - * @author Václav Brodec - * - */ -public interface CsvInputParser { - Input parse(String csvContent, String identifier, CsvConfiguration configuration) - throws IOException; - - Input parse(Reader csvReader, String identifier, CsvConfiguration configuration) - throws IOException; - - Input parse(InputStream csvStream, String identifier, CsvConfiguration configuration) - throws IOException; -} +package cz.cuni.mff.xrg.odalic.input; + +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; + +/** + * CSV input parser. + * + * @author Václav Brodec + * + */ +public interface CsvInputParser { + Input parse(String csvContent, String identifier, CsvConfiguration configuration) + throws IOException; + + Input parse(Reader csvReader, String identifier, CsvConfiguration configuration) + throws IOException; + + Input parse(InputStream csvStream, String identifier, CsvConfiguration configuration) + throws IOException; +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/DefaultCsvInputParser.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/DefaultCsvInputParser.java index 2b110b63..6c884103 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/DefaultCsvInputParser.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/DefaultCsvInputParser.java @@ -1,80 +1,80 @@ -package cz.cuni.mff.xrg.odalic.input; - -import org.apache.commons.csv.CSVFormat; -import org.apache.commons.csv.CSVParser; -import org.apache.commons.csv.CSVRecord; -import org.springframework.beans.factory.annotation.Autowired; - -import com.google.common.base.Preconditions; - -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.io.StringReader; -import java.util.Map; - -/** - * Default implementation of the {@link CsvInputParser}. - * - * @author Jan Váňa - */ -public final class DefaultCsvInputParser implements CsvInputParser { - - private final ListsBackedInputBuilder inputBuilder; - - @Autowired - public DefaultCsvInputParser(ListsBackedInputBuilder inputBuilder) { - Preconditions.checkNotNull(inputBuilder); - - this.inputBuilder = inputBuilder; - } - - @Override - public Input parse(String content, String identifier, CsvConfiguration configuration) throws IOException { - try (Reader reader = new StringReader(content)) { - return parse(reader, identifier, configuration); - } - } - - @Override - public Input parse(InputStream stream, String identifier, CsvConfiguration configuration) throws IOException { - try (Reader reader = new InputStreamReader(stream, configuration.getCharset())) { - return parse(reader, identifier, configuration); - } - } - - @Override - public Input parse(Reader reader, String identifier, CsvConfiguration configuration) throws IOException { - final CSVFormat format = configuration.toApacheConfiguration(); - final CSVParser parser = format.parse(reader); - - inputBuilder.clear(); - inputBuilder.setFileIdentifier(identifier); - handleHeaders(parser); - - int row = 0; - for(CSVRecord record : parser) { - handleInputRow(record, row); - row++; - } - - return inputBuilder.build(); - } - - private void handleInputRow(CSVRecord row, int rowIndex) { - int column = 0; - for (String value : row) { - inputBuilder.insertCell(value, rowIndex, column); - column++; - } - } - - private void handleHeaders(CSVParser parser) { - final Map headerMap = parser.getHeaderMap(); - - for(Map.Entry headerEntry : headerMap.entrySet()) { - inputBuilder.insertHeader(headerEntry.getKey(), headerEntry.getValue()); - } - } -} +package cz.cuni.mff.xrg.odalic.input; + +import org.apache.commons.csv.CSVFormat; +import org.apache.commons.csv.CSVParser; +import org.apache.commons.csv.CSVRecord; +import org.springframework.beans.factory.annotation.Autowired; + +import com.google.common.base.Preconditions; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.StringReader; +import java.util.Map; + +/** + * Default implementation of the {@link CsvInputParser}. + * + * @author Jan Váňa + */ +public final class DefaultCsvInputParser implements CsvInputParser { + + private final ListsBackedInputBuilder inputBuilder; + + @Autowired + public DefaultCsvInputParser(ListsBackedInputBuilder inputBuilder) { + Preconditions.checkNotNull(inputBuilder); + + this.inputBuilder = inputBuilder; + } + + @Override + public Input parse(String content, String identifier, CsvConfiguration configuration) throws IOException { + try (Reader reader = new StringReader(content)) { + return parse(reader, identifier, configuration); + } + } + + @Override + public Input parse(InputStream stream, String identifier, CsvConfiguration configuration) throws IOException { + try (Reader reader = new InputStreamReader(stream, configuration.getCharset())) { + return parse(reader, identifier, configuration); + } + } + + @Override + public Input parse(Reader reader, String identifier, CsvConfiguration configuration) throws IOException { + final CSVFormat format = configuration.toApacheConfiguration(); + final CSVParser parser = format.parse(reader); + + inputBuilder.clear(); + inputBuilder.setFileIdentifier(identifier); + handleHeaders(parser); + + int row = 0; + for(CSVRecord record : parser) { + handleInputRow(record, row); + row++; + } + + return inputBuilder.build(); + } + + private void handleInputRow(CSVRecord row, int rowIndex) { + int column = 0; + for (String value : row) { + inputBuilder.insertCell(value, rowIndex, column); + column++; + } + } + + private void handleHeaders(CSVParser parser) { + final Map headerMap = parser.getHeaderMap(); + + for(Map.Entry headerEntry : headerMap.entrySet()) { + inputBuilder.insertHeader(headerEntry.getKey(), headerEntry.getValue()); + } + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/DefaultInputToTableAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/DefaultInputToTableAdapter.java index ca593f9c..4fcf9765 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/DefaultInputToTableAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/DefaultInputToTableAdapter.java @@ -1,55 +1,55 @@ -package cz.cuni.mff.xrg.odalic.input; - -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.TColumnHeader; -import uk.ac.shef.dcs.sti.core.model.Table; - -import java.util.List; -import java.util.UUID; - -import javax.annotation.concurrent.Immutable; - -/** - * The default {@link InputToTableAdapter} implementation. - * - * @author Jan Váňa - * - */ -@Immutable -public class DefaultInputToTableAdapter implements InputToTableAdapter { - - /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.input.InputToTableAdapter#toTable(cz.cuni.mff.xrg.odalic.input.Input) - */ - @Override - public Table toTable(Input input) { - Table result = new Table( - UUID.randomUUID().toString(), - input.identifier(), - input.rowsCount(), - input.columnsCount()); - - int columnIndex = 0; - for (String value : input.headers()) { - TColumnHeader header = new TColumnHeader(value); - result.setColumnHeader(columnIndex, header); - - columnIndex++; - } - - int rowIndex = 0; - for (List row : input.rows()) { - columnIndex = 0; - for (String value : row) { - TCell cell = new TCell(value); - result.setContentCell(rowIndex, columnIndex, cell); - - columnIndex++; - } - rowIndex++; - } - - return result; - } - -} +package cz.cuni.mff.xrg.odalic.input; + +import uk.ac.shef.dcs.sti.core.model.TCell; +import uk.ac.shef.dcs.sti.core.model.TColumnHeader; +import uk.ac.shef.dcs.sti.core.model.Table; + +import java.util.List; +import java.util.UUID; + +import javax.annotation.concurrent.Immutable; + +/** + * The default {@link InputToTableAdapter} implementation. + * + * @author Jan Váňa + * + */ +@Immutable +public class DefaultInputToTableAdapter implements InputToTableAdapter { + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.input.InputToTableAdapter#toTable(cz.cuni.mff.xrg.odalic.input.Input) + */ + @Override + public Table toTable(Input input) { + Table result = new Table( + UUID.randomUUID().toString(), + input.identifier(), + input.rowsCount(), + input.columnsCount()); + + int columnIndex = 0; + for (String value : input.headers()) { + TColumnHeader header = new TColumnHeader(value); + result.setColumnHeader(columnIndex, header); + + columnIndex++; + } + + int rowIndex = 0; + for (List row : input.rows()) { + columnIndex = 0; + for (String value : row) { + TCell cell = new TCell(value); + result.setContentCell(rowIndex, columnIndex, cell); + + columnIndex++; + } + rowIndex++; + } + + return result; + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/Input.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/Input.java index 5d0400bb..05dbc042 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/Input.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/Input.java @@ -1,24 +1,24 @@ -package cz.cuni.mff.xrg.odalic.input; - -import java.util.List; - -import cz.cuni.mff.xrg.odalic.positions.CellPosition; -import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; -import cz.cuni.mff.xrg.odalic.positions.RowPosition; - -/** - * Input interface. - * - * @author Václav Brodec - * - */ -public interface Input { - String at(CellPosition position); - String headerAt(ColumnPosition position); - List rowAt(RowPosition position); - int rowsCount(); - int columnsCount(); - List headers(); - List> rows(); - String identifier(); -} +package cz.cuni.mff.xrg.odalic.input; + +import java.util.List; + +import cz.cuni.mff.xrg.odalic.positions.CellPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.positions.RowPosition; + +/** + * Input interface. + * + * @author Václav Brodec + * + */ +public interface Input { + String at(CellPosition position); + String headerAt(ColumnPosition position); + List rowAt(RowPosition position); + int rowsCount(); + int columnsCount(); + List headers(); + List> rows(); + String identifier(); +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/InputBuilder.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/InputBuilder.java index 87beb424..b2b26dda 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/InputBuilder.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/InputBuilder.java @@ -1,24 +1,24 @@ -package cz.cuni.mff.xrg.odalic.input; - -import java.util.List; - - -/** - * {@link Input} builder interface. - * - * @author Václav Brodec - * - */ -public interface InputBuilder { - - void insertCell(String value, int rowIndex, int columnIndex); - - void insertHeader(String value, int position); - - void insertToList(List list, String value, int position); - - Input build(); - - void clear(); - -} +package cz.cuni.mff.xrg.odalic.input; + +import java.util.List; + + +/** + * {@link Input} builder interface. + * + * @author Václav Brodec + * + */ +public interface InputBuilder { + + void insertCell(String value, int rowIndex, int columnIndex); + + void insertHeader(String value, int position); + + void insertToList(List list, String value, int position); + + Input build(); + + void clear(); + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/InputToTableAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/InputToTableAdapter.java index 3bc45970..c74f922c 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/InputToTableAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/InputToTableAdapter.java @@ -1,13 +1,13 @@ -package cz.cuni.mff.xrg.odalic.input; - -import uk.ac.shef.dcs.sti.core.model.Table; - -/** - * Interface for {@link Input} to {@link Table} conversion. - * - * @author Václav Brodec - * - */ -public interface InputToTableAdapter { - Table toTable(Input input); -} +package cz.cuni.mff.xrg.odalic.input; + +import uk.ac.shef.dcs.sti.core.model.Table; + +/** + * Interface for {@link Input} to {@link Table} conversion. + * + * @author Václav Brodec + * + */ +public interface InputToTableAdapter { + Table toTable(Input input); +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/ListsBackedInput.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/ListsBackedInput.java index 7b22f0f7..0dbe7496 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/ListsBackedInput.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/ListsBackedInput.java @@ -1,93 +1,93 @@ -package cz.cuni.mff.xrg.odalic.input; - -import java.io.Serializable; -import java.util.List; - -import javax.annotation.concurrent.Immutable; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableList; - -import cz.cuni.mff.xrg.odalic.positions.CellPosition; -import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; -import cz.cuni.mff.xrg.odalic.positions.RowPosition; - -/** - * An {@link Input} implementation using a list of lists to store the cells. - * - * @author Václav Brodec - * @author Jan Váňa - */ -@XmlRootElement(name = "input") -@Immutable -public final class ListsBackedInput implements Input, Serializable { - - private static final long serialVersionUID = 4101912998363935336L; - - @XmlElement - private final List> rows; - - @XmlElement - private final List headers; - - @XmlElement - private final String fileIdentifier; - - public ListsBackedInput(String fileIdentifier, List headers, List> rows) { - Preconditions.checkNotNull(fileIdentifier); - Preconditions.checkNotNull(headers); - Preconditions.checkNotNull(rows); - - this.fileIdentifier = fileIdentifier; - - this.headers = ImmutableList.copyOf(headers); - - final ImmutableList.Builder> rowsBuilder = ImmutableList.builder(); - for (final List row : rows) { - rowsBuilder.add(ImmutableList.copyOf(row)); - } - this.rows = rowsBuilder.build(); - } - - @Override - public String at(CellPosition position) { - return rows.get(position.getRowIndex()).get(position.getColumnIndex()); - } - - @Override - public String headerAt(ColumnPosition position) { - return headers.get(position.getIndex()); - } - - @Override - public List rowAt(RowPosition position) { - return rows.get(position.getIndex()); - } - - @Override - public int rowsCount() { - return rows.size(); - } - - @Override - public int columnsCount() { - return headers.size(); - } - - @Override - public List headers() { - return headers; - } - - @Override - public List> rows() { - return rows; - } - - @Override - public String identifier() { - return fileIdentifier; - } -} +package cz.cuni.mff.xrg.odalic.input; + +import java.io.Serializable; +import java.util.List; + +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +import cz.cuni.mff.xrg.odalic.positions.CellPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.positions.RowPosition; + +/** + * An {@link Input} implementation using a list of lists to store the cells. + * + * @author Václav Brodec + * @author Jan Váňa + */ +@XmlRootElement(name = "input") +@Immutable +public final class ListsBackedInput implements Input, Serializable { + + private static final long serialVersionUID = 4101912998363935336L; + + @XmlElement + private final List> rows; + + @XmlElement + private final List headers; + + @XmlElement + private final String fileIdentifier; + + public ListsBackedInput(String fileIdentifier, List headers, List> rows) { + Preconditions.checkNotNull(fileIdentifier); + Preconditions.checkNotNull(headers); + Preconditions.checkNotNull(rows); + + this.fileIdentifier = fileIdentifier; + + this.headers = ImmutableList.copyOf(headers); + + final ImmutableList.Builder> rowsBuilder = ImmutableList.builder(); + for (final List row : rows) { + rowsBuilder.add(ImmutableList.copyOf(row)); + } + this.rows = rowsBuilder.build(); + } + + @Override + public String at(CellPosition position) { + return rows.get(position.getRowIndex()).get(position.getColumnIndex()); + } + + @Override + public String headerAt(ColumnPosition position) { + return headers.get(position.getIndex()); + } + + @Override + public List rowAt(RowPosition position) { + return rows.get(position.getIndex()); + } + + @Override + public int rowsCount() { + return rows.size(); + } + + @Override + public int columnsCount() { + return headers.size(); + } + + @Override + public List headers() { + return headers; + } + + @Override + public List> rows() { + return rows; + } + + @Override + public String identifier() { + return fileIdentifier; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/ListsBackedInputBuilder.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/ListsBackedInputBuilder.java index 290a0dad..b63289c0 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/ListsBackedInputBuilder.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/ListsBackedInputBuilder.java @@ -1,78 +1,78 @@ -package cz.cuni.mff.xrg.odalic.input; - -import java.util.ArrayList; -import java.util.List; - -import com.google.common.base.Preconditions; - -/** - * Incrementally, row by row, helps to produce the complete {@link ListsBackedInput}. - * - * @author Jan Váňa - * @author Václav Brodec - * - */ -public final class ListsBackedInputBuilder implements InputBuilder { - - private String fileIdentifier; - private List headers = new ArrayList<>(); - private List> rows = new ArrayList<>(); - - public ListsBackedInputBuilder() { } - - void setFileIdentifier(String fileIdentifier) { - Preconditions.checkNotNull(fileIdentifier); - - this.fileIdentifier = fileIdentifier; - } - - /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.input.InputBuilder#insertCell(java.lang.String, int, int) - */ - @Override - public void insertCell(String value, int rowIndex, int columnIndex) { - while (rows.size() <= rowIndex) { - rows.add(new ArrayList<>()); - } - - insertToList(rows.get(rowIndex), value, columnIndex); - } - - /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.input.InputBuilder#insertHeader(java.lang.String, int) - */ - @Override - public void insertHeader(String value, int position) { - insertToList(headers, value, position); - } - - /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.input.InputBuilder#insertToList(java.util.List, java.lang.String, int) - */ - @Override - public void insertToList(List list, String value, int position){ - while (list.size() <= position) { - list.add(null); - } - - list.set(position, value); - } - - /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.input.InputBuilder#build() - */ - @Override - public Input build() { - return new ListsBackedInput(this.fileIdentifier, this.headers, this.rows); - } - - /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.input.InputBuilder#clear() - */ - @Override - public void clear() { - this.fileIdentifier = null; - headers.clear(); - rows.clear(); - } -} +package cz.cuni.mff.xrg.odalic.input; + +import java.util.ArrayList; +import java.util.List; + +import com.google.common.base.Preconditions; + +/** + * Incrementally, row by row, helps to produce the complete {@link ListsBackedInput}. + * + * @author Jan Váňa + * @author Václav Brodec + * + */ +public final class ListsBackedInputBuilder implements InputBuilder { + + private String fileIdentifier; + private List headers = new ArrayList<>(); + private List> rows = new ArrayList<>(); + + public ListsBackedInputBuilder() { } + + void setFileIdentifier(String fileIdentifier) { + Preconditions.checkNotNull(fileIdentifier); + + this.fileIdentifier = fileIdentifier; + } + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.input.InputBuilder#insertCell(java.lang.String, int, int) + */ + @Override + public void insertCell(String value, int rowIndex, int columnIndex) { + while (rows.size() <= rowIndex) { + rows.add(new ArrayList<>()); + } + + insertToList(rows.get(rowIndex), value, columnIndex); + } + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.input.InputBuilder#insertHeader(java.lang.String, int) + */ + @Override + public void insertHeader(String value, int position) { + insertToList(headers, value, position); + } + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.input.InputBuilder#insertToList(java.util.List, java.lang.String, int) + */ + @Override + public void insertToList(List list, String value, int position){ + while (list.size() <= position) { + list.add(null); + } + + list.set(position, value); + } + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.input.InputBuilder#build() + */ + @Override + public Input build() { + return new ListsBackedInput(this.fileIdentifier, this.headers, this.rows); + } + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.input.InputBuilder#clear() + */ + @Override + public void clear() { + this.fileIdentifier = null; + headers.clear(); + rows.clear(); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/TableToInputAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/TableToInputAdapter.java index beb4139f..3c2852e2 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/TableToInputAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/TableToInputAdapter.java @@ -1,13 +1,13 @@ -package cz.cuni.mff.xrg.odalic.input; - -import uk.ac.shef.dcs.sti.core.model.Table; - -/** - * Interface for {@link Table} to {@link Input} conversion. - * - * @author Václav Brodec - * - */ -public interface TableToInputAdapter { - Input toInput(Table table); -} +package cz.cuni.mff.xrg.odalic.input; + +import uk.ac.shef.dcs.sti.core.model.Table; + +/** + * Interface for {@link Table} to {@link Input} conversion. + * + * @author Václav Brodec + * + */ +public interface TableToInputAdapter { + Input toInput(Table table); +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/TableToListsBackedInputAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/TableToListsBackedInputAdapter.java index be766fba..9444a253 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/TableToListsBackedInputAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/input/TableToListsBackedInputAdapter.java @@ -1,48 +1,48 @@ -package cz.cuni.mff.xrg.odalic.input; - -import com.google.common.base.Preconditions; - -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.TColumnHeader; -import uk.ac.shef.dcs.sti.core.model.Table; - -/** - * Converts the {@link Table} to {@link ListsBackedInputBuilder}. - * - * @author Jan Váňa - * - */ -public final class TableToListsBackedInputAdapter implements TableToInputAdapter { - - private final ListsBackedInputBuilder builder; - - public TableToListsBackedInputAdapter(ListsBackedInputBuilder builder) { - Preconditions.checkNotNull(builder); - - this.builder = builder; - } - - /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.input.TableToInputAdapter#toInput(uk.ac.shef.dcs.sti.core.model.Table) - */ - @Override - public Input toInput(Table table) { - builder.clear(); - builder.setFileIdentifier(table.getSourceId()); - - for (int columnIndex = 0; columnIndex < table.getNumHeaders(); columnIndex++) { - TColumnHeader header = table.getColumnHeader(columnIndex); - builder.insertHeader(header.getHeaderText(), columnIndex); - } - - for (int columnIndex = 0; columnIndex < table.getNumCols(); columnIndex++) { - for (int rowIndex = 0; rowIndex < table.getNumRows(); rowIndex++) { - TCell cell = table.getContentCell(rowIndex, columnIndex); - builder.insertCell(cell.getText(), rowIndex, columnIndex); - } - } - - return builder.build(); - } - -} +package cz.cuni.mff.xrg.odalic.input; + +import com.google.common.base.Preconditions; + +import uk.ac.shef.dcs.sti.core.model.TCell; +import uk.ac.shef.dcs.sti.core.model.TColumnHeader; +import uk.ac.shef.dcs.sti.core.model.Table; + +/** + * Converts the {@link Table} to {@link ListsBackedInputBuilder}. + * + * @author Jan Váňa + * + */ +public final class TableToListsBackedInputAdapter implements TableToInputAdapter { + + private final ListsBackedInputBuilder builder; + + public TableToListsBackedInputAdapter(ListsBackedInputBuilder builder) { + Preconditions.checkNotNull(builder); + + this.builder = builder; + } + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.input.TableToInputAdapter#toInput(uk.ac.shef.dcs.sti.core.model.Table) + */ + @Override + public Input toInput(Table table) { + builder.clear(); + builder.setFileIdentifier(table.getSourceId()); + + for (int columnIndex = 0; columnIndex < table.getNumHeaders(); columnIndex++) { + TColumnHeader header = table.getColumnHeader(columnIndex); + builder.insertHeader(header.getHeaderText(), columnIndex); + } + + for (int columnIndex = 0; columnIndex < table.getNumCols(); columnIndex++) { + for (int rowIndex = 0; rowIndex < table.getNumRows(); rowIndex++) { + TCell cell = table.getContentCell(rowIndex, columnIndex); + builder.insertCell(cell.getText(), rowIndex, columnIndex); + } + } + + return builder.build(); + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/CellPosition.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/CellPosition.java index b37efb14..415d06fd 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/CellPosition.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/CellPosition.java @@ -1,132 +1,132 @@ -package cz.cuni.mff.xrg.odalic.positions; - -import java.io.Serializable; - -import javax.annotation.concurrent.Immutable; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.api.rest.adapters.CellPositionAdapter; - -/** - * Position of a common cell in a table. Headers do not count. - * - * @author Václav Brodec - * - */ -@Immutable -@XmlJavaTypeAdapter(CellPositionAdapter.class) -public final class CellPosition implements Serializable { - - private static final long serialVersionUID = 7955615617737637528L; - - private final RowPosition rowPosition; - - private final ColumnPosition columnPosition; - - - /** - * Creates new representation of cell position in a table. - * - * @param rowPosition row position - * @param columnPosition column position - */ - public CellPosition(RowPosition rowPosition, ColumnPosition columnPosition) { - Preconditions.checkNotNull(rowPosition); - Preconditions.checkNotNull(columnPosition); - - this.rowPosition = rowPosition; - this.columnPosition = columnPosition; - } - - /** - * Creates new representation of cell position in a table. - * - * @param rowIndex row index - * @param columnIndex column index - */ - public CellPosition(int rowIndex, int columnIndex) { - this(new RowPosition(rowIndex), new ColumnPosition(columnIndex)); - } - - /** - * @return the row position - */ - public RowPosition getRowPosition() { - return rowPosition; - } - - /** - * @return the column position - */ - public ColumnPosition getColumnPosition() { - return columnPosition; - } - - /** - * @return the row index - */ - public int getRowIndex() { - return rowPosition.getIndex(); - } - - /** - * @return the column index - */ - public int getColumnIndex() { - return columnPosition.getIndex(); - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((columnPosition == null) ? 0 : columnPosition.hashCode()); - result = prime * result + ((rowPosition == null) ? 0 : rowPosition.hashCode()); - return result; - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - CellPosition other = (CellPosition) obj; - if (columnPosition == null) { - if (other.columnPosition != null) { - return false; - } - } else if (!columnPosition.equals(other.columnPosition)) { - return false; - } - if (rowPosition == null) { - if (other.rowPosition != null) { - return false; - } - } else if (!rowPosition.equals(other.rowPosition)) { - return false; - } - return true; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "" + rowPosition + columnPosition; - } -} +package cz.cuni.mff.xrg.odalic.positions; + +import java.io.Serializable; + +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.adapters.CellPositionAdapter; + +/** + * Position of a common cell in a table. Headers do not count. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(CellPositionAdapter.class) +public final class CellPosition implements Serializable { + + private static final long serialVersionUID = 7955615617737637528L; + + private final RowPosition rowPosition; + + private final ColumnPosition columnPosition; + + + /** + * Creates new representation of cell position in a table. + * + * @param rowPosition row position + * @param columnPosition column position + */ + public CellPosition(RowPosition rowPosition, ColumnPosition columnPosition) { + Preconditions.checkNotNull(rowPosition); + Preconditions.checkNotNull(columnPosition); + + this.rowPosition = rowPosition; + this.columnPosition = columnPosition; + } + + /** + * Creates new representation of cell position in a table. + * + * @param rowIndex row index + * @param columnIndex column index + */ + public CellPosition(int rowIndex, int columnIndex) { + this(new RowPosition(rowIndex), new ColumnPosition(columnIndex)); + } + + /** + * @return the row position + */ + public RowPosition getRowPosition() { + return rowPosition; + } + + /** + * @return the column position + */ + public ColumnPosition getColumnPosition() { + return columnPosition; + } + + /** + * @return the row index + */ + public int getRowIndex() { + return rowPosition.getIndex(); + } + + /** + * @return the column index + */ + public int getColumnIndex() { + return columnPosition.getIndex(); + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((columnPosition == null) ? 0 : columnPosition.hashCode()); + result = prime * result + ((rowPosition == null) ? 0 : rowPosition.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + CellPosition other = (CellPosition) obj; + if (columnPosition == null) { + if (other.columnPosition != null) { + return false; + } + } else if (!columnPosition.equals(other.columnPosition)) { + return false; + } + if (rowPosition == null) { + if (other.rowPosition != null) { + return false; + } + } else if (!rowPosition.equals(other.rowPosition)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "" + rowPosition + columnPosition; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/CellRelationPosition.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/CellRelationPosition.java index fd86ebea..caf5159d 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/CellRelationPosition.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/CellRelationPosition.java @@ -1,170 +1,170 @@ -package cz.cuni.mff.xrg.odalic.positions; - -import javax.annotation.concurrent.Immutable; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.api.rest.adapters.CellRelationPositionAdapter; - -/** - * Position of cells at the same row in a relation. - * - * @author Václav Brodec - * - */ -@Immutable -@XmlJavaTypeAdapter(CellRelationPositionAdapter.class) -public final class CellRelationPosition { - - private final ColumnRelationPosition columnsPosition; - - private final RowPosition rowPosition; - - /** - * Creates new representation of position of two cells at the same row in a relation. - * - * @param columnsPosition position of columns in which the cells are located - * @param rowPosition position of row that the cells share - */ - public CellRelationPosition(ColumnRelationPosition columnsPosition, RowPosition rowPosition) { - Preconditions.checkNotNull(columnsPosition); - Preconditions.checkNotNull(rowPosition); - - this.columnsPosition = columnsPosition; - this.rowPosition = rowPosition; - } - - /** - * Creates new representation of position of two cells at the same row in a relation. - * - * @param first column position of the first cell - * @param second column position of the second cell - * @param rowPosition position of row that the cells share - */ - public CellRelationPosition(ColumnPosition first, ColumnPosition second, - RowPosition rowPosition) { - this(new ColumnRelationPosition(first, second), rowPosition); - } - - /** - * Creates new representation of position of two cells at the same row in a relation. - * - * @param firstColumnIndex column index of the first cell - * @param secondColumnIndex column index of the second cell - * @param rowIndex index of the row that the cells share - */ - public CellRelationPosition(int firstColumnIndex, int secondColumnIndex, int rowIndex) { - this(new ColumnRelationPosition(firstColumnIndex, secondColumnIndex), - new RowPosition(rowIndex)); - } - - /** - * @return the row position - */ - public RowPosition getRowPosition() { - return rowPosition; - } - - /** - * @return the columns position - */ - public ColumnRelationPosition getColumnsPosition() { - return columnsPosition; - } - - /** - * @return the row index - */ - public int getRowIndex() { - return rowPosition.getIndex(); - } - - /** - * @return the first cell column position - */ - public ColumnPosition getFirstColumnPosition() { - return columnsPosition.getFirst(); - } - - /** - * @return the second cell column position - */ - public ColumnPosition getSecondColumnPosition() { - return columnsPosition.getSecond(); - } - - /** - * @return the first cell column index - */ - public int getFirstColumnIndex() { - return columnsPosition.getFirstIndex(); - } - - /** - * @return the second cell column index - */ - public int getSecondColumnIndex() { - return columnsPosition.getSecondIndex(); - } - - /** - * Computes hash code based on the column position and the row position. - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((columnsPosition == null) ? 0 : columnsPosition.hashCode()); - result = prime * result + ((rowPosition == null) ? 0 : rowPosition.hashCode()); - return result; - } - - /** - * Compares for equality (only other cell relation position with the same column position and row - * position passes). - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - CellRelationPosition other = (CellRelationPosition) obj; - if (columnsPosition == null) { - if (other.columnsPosition != null) { - return false; - } - } else if (!columnsPosition.equals(other.columnsPosition)) { - return false; - } - if (rowPosition == null) { - if (other.rowPosition != null) { - return false; - } - } else if (!rowPosition.equals(other.rowPosition)) { - return false; - } - return true; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "CellRelationPosition [columnsPosition=" + columnsPosition + ", rowPosition=" - + rowPosition + "]"; - } -} +package cz.cuni.mff.xrg.odalic.positions; + +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.adapters.CellRelationPositionAdapter; + +/** + * Position of cells at the same row in a relation. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(CellRelationPositionAdapter.class) +public final class CellRelationPosition { + + private final ColumnRelationPosition columnsPosition; + + private final RowPosition rowPosition; + + /** + * Creates new representation of position of two cells at the same row in a relation. + * + * @param columnsPosition position of columns in which the cells are located + * @param rowPosition position of row that the cells share + */ + public CellRelationPosition(ColumnRelationPosition columnsPosition, RowPosition rowPosition) { + Preconditions.checkNotNull(columnsPosition); + Preconditions.checkNotNull(rowPosition); + + this.columnsPosition = columnsPosition; + this.rowPosition = rowPosition; + } + + /** + * Creates new representation of position of two cells at the same row in a relation. + * + * @param first column position of the first cell + * @param second column position of the second cell + * @param rowPosition position of row that the cells share + */ + public CellRelationPosition(ColumnPosition first, ColumnPosition second, + RowPosition rowPosition) { + this(new ColumnRelationPosition(first, second), rowPosition); + } + + /** + * Creates new representation of position of two cells at the same row in a relation. + * + * @param firstColumnIndex column index of the first cell + * @param secondColumnIndex column index of the second cell + * @param rowIndex index of the row that the cells share + */ + public CellRelationPosition(int firstColumnIndex, int secondColumnIndex, int rowIndex) { + this(new ColumnRelationPosition(firstColumnIndex, secondColumnIndex), + new RowPosition(rowIndex)); + } + + /** + * @return the row position + */ + public RowPosition getRowPosition() { + return rowPosition; + } + + /** + * @return the columns position + */ + public ColumnRelationPosition getColumnsPosition() { + return columnsPosition; + } + + /** + * @return the row index + */ + public int getRowIndex() { + return rowPosition.getIndex(); + } + + /** + * @return the first cell column position + */ + public ColumnPosition getFirstColumnPosition() { + return columnsPosition.getFirst(); + } + + /** + * @return the second cell column position + */ + public ColumnPosition getSecondColumnPosition() { + return columnsPosition.getSecond(); + } + + /** + * @return the first cell column index + */ + public int getFirstColumnIndex() { + return columnsPosition.getFirstIndex(); + } + + /** + * @return the second cell column index + */ + public int getSecondColumnIndex() { + return columnsPosition.getSecondIndex(); + } + + /** + * Computes hash code based on the column position and the row position. + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((columnsPosition == null) ? 0 : columnsPosition.hashCode()); + result = prime * result + ((rowPosition == null) ? 0 : rowPosition.hashCode()); + return result; + } + + /** + * Compares for equality (only other cell relation position with the same column position and row + * position passes). + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + CellRelationPosition other = (CellRelationPosition) obj; + if (columnsPosition == null) { + if (other.columnsPosition != null) { + return false; + } + } else if (!columnsPosition.equals(other.columnsPosition)) { + return false; + } + if (rowPosition == null) { + if (other.rowPosition != null) { + return false; + } + } else if (!rowPosition.equals(other.rowPosition)) { + return false; + } + return true; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "CellRelationPosition [columnsPosition=" + columnsPosition + ", rowPosition=" + + rowPosition + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/ColumnPosition.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/ColumnPosition.java index e6597d63..8c8e1fd6 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/ColumnPosition.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/ColumnPosition.java @@ -1,90 +1,90 @@ -package cz.cuni.mff.xrg.odalic.positions; - -import java.io.Serializable; - -import javax.annotation.concurrent.Immutable; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.api.rest.adapters.ColumnPositionAdapter; - -/** - * Position of column in a table. - * - * @author Václav Brodec - * - */ -@Immutable -@XmlJavaTypeAdapter(ColumnPositionAdapter.class) -public final class ColumnPosition implements Serializable { - - private static final long serialVersionUID = -1179554576389130985L; - - private final int index; - - /** - * Creates new column position representation. - * - * @param index zero-based index - */ - public ColumnPosition(int index) { - Preconditions.checkArgument(index >= 0); - - this.index = index; - } - - - /** - * @return the index - */ - public int getIndex() { - return index; - } - - /** - * Computes hash code based on the index. - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + index; - return result; - } - - /** - * Compares for equality (only other column position with the same index passes). - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ColumnPosition other = (ColumnPosition) obj; - if (index != other.index) { - return false; - } - return true; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "[" + index + "]"; - } -} +package cz.cuni.mff.xrg.odalic.positions; + +import java.io.Serializable; + +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.adapters.ColumnPositionAdapter; + +/** + * Position of column in a table. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(ColumnPositionAdapter.class) +public final class ColumnPosition implements Serializable { + + private static final long serialVersionUID = -1179554576389130985L; + + private final int index; + + /** + * Creates new column position representation. + * + * @param index zero-based index + */ + public ColumnPosition(int index) { + Preconditions.checkArgument(index >= 0); + + this.index = index; + } + + + /** + * @return the index + */ + public int getIndex() { + return index; + } + + /** + * Computes hash code based on the index. + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + index; + return result; + } + + /** + * Compares for equality (only other column position with the same index passes). + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ColumnPosition other = (ColumnPosition) obj; + if (index != other.index) { + return false; + } + return true; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "[" + index + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/ColumnRelationPosition.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/ColumnRelationPosition.java index 37dffa49..2a3ee301 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/ColumnRelationPosition.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/ColumnRelationPosition.java @@ -1,135 +1,135 @@ -package cz.cuni.mff.xrg.odalic.positions; - -import javax.annotation.concurrent.Immutable; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.api.rest.adapters.ColumnRelationPositionAdapter; - -/** - * Position of columns in a relation. - * - * @author Václav Brodec - * - */ -@Immutable -@XmlJavaTypeAdapter(ColumnRelationPositionAdapter.class) -public final class ColumnRelationPosition { - - private final ColumnPosition first; - - private final ColumnPosition second; - - /** - * Creates new representation of a position of columns in relation. - * - * @param first first column position - * @param second second column position - */ - public ColumnRelationPosition(ColumnPosition first, ColumnPosition second) { - Preconditions.checkNotNull(first); - Preconditions.checkNotNull(second); - Preconditions.checkArgument(first.getIndex() != second.getIndex()); - - this.first = first; - this.second = second; - } - - /** - * Creates new representation of a position of columns in relation. - * - * @param firstIndex first column index - * @param second second column index - */ - public ColumnRelationPosition(int firstIndex, int secondIndex) { - this(new ColumnPosition(firstIndex), new ColumnPosition(secondIndex)); - } - - /** - * @return the first column position - */ - public ColumnPosition getFirst() { - return first; - } - - /** - * @return the second column position - */ - public ColumnPosition getSecond() { - return second; - } - - /** - * @return the first column index - */ - public int getFirstIndex() { - return first.getIndex(); - } - - /** - * @return the second column index - */ - public int getSecondIndex() { - return second.getIndex(); - } - - /** - * Computes hash code based on the first and second column position. - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((first == null) ? 0 : first.hashCode()); - result = prime * result + ((second == null) ? 0 : second.hashCode()); - return result; - } - - /** - * Compares for equivalence (only other column relation position with the same first and second - * column position passes). - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ColumnRelationPosition other = (ColumnRelationPosition) obj; - if (first == null) { - if (other.first != null) { - return false; - } - } else if (!first.equals(other.first)) { - return false; - } - if (second == null) { - if (other.second != null) { - return false; - } - } else if (!second.equals(other.second)) { - return false; - } - return true; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "ColumnRelationPosition [first=" + first + ", second=" + second + "]"; - } -} +package cz.cuni.mff.xrg.odalic.positions; + +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.adapters.ColumnRelationPositionAdapter; + +/** + * Position of columns in a relation. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(ColumnRelationPositionAdapter.class) +public final class ColumnRelationPosition { + + private final ColumnPosition first; + + private final ColumnPosition second; + + /** + * Creates new representation of a position of columns in relation. + * + * @param first first column position + * @param second second column position + */ + public ColumnRelationPosition(ColumnPosition first, ColumnPosition second) { + Preconditions.checkNotNull(first); + Preconditions.checkNotNull(second); + Preconditions.checkArgument(first.getIndex() != second.getIndex()); + + this.first = first; + this.second = second; + } + + /** + * Creates new representation of a position of columns in relation. + * + * @param firstIndex first column index + * @param second second column index + */ + public ColumnRelationPosition(int firstIndex, int secondIndex) { + this(new ColumnPosition(firstIndex), new ColumnPosition(secondIndex)); + } + + /** + * @return the first column position + */ + public ColumnPosition getFirst() { + return first; + } + + /** + * @return the second column position + */ + public ColumnPosition getSecond() { + return second; + } + + /** + * @return the first column index + */ + public int getFirstIndex() { + return first.getIndex(); + } + + /** + * @return the second column index + */ + public int getSecondIndex() { + return second.getIndex(); + } + + /** + * Computes hash code based on the first and second column position. + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((first == null) ? 0 : first.hashCode()); + result = prime * result + ((second == null) ? 0 : second.hashCode()); + return result; + } + + /** + * Compares for equivalence (only other column relation position with the same first and second + * column position passes). + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ColumnRelationPosition other = (ColumnRelationPosition) obj; + if (first == null) { + if (other.first != null) { + return false; + } + } else if (!first.equals(other.first)) { + return false; + } + if (second == null) { + if (other.second != null) { + return false; + } + } else if (!second.equals(other.second)) { + return false; + } + return true; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ColumnRelationPosition [first=" + first + ", second=" + second + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/RowPosition.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/RowPosition.java index 1e64e8d2..e8aae41a 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/RowPosition.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/positions/RowPosition.java @@ -1,95 +1,95 @@ -package cz.cuni.mff.xrg.odalic.positions; - -import java.io.Serializable; - -import javax.annotation.concurrent.Immutable; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.api.rest.adapters.RowPositionAdapter; - -/** - * Position of a row in a table. - * - * @author Václav Brodec - * - */ -@Immutable -@XmlJavaTypeAdapter(RowPositionAdapter.class) -public final class RowPosition implements Serializable, Comparable { - - private static final long serialVersionUID = 3435359552551500579L; - - private final int index; - - /** - * Creates new row position representation. - * - * @param index zero-base index - */ - public RowPosition(int index) { - Preconditions.checkArgument(index >= 0); - - this.index = index; - } - - /** - * @return the index - */ - public int getIndex() { - return index; - } - - /** - * Computes hash code based on the index. - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + index; - return result; - } - - /** - * Compares for equality (only other row position with the same index passes). - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - RowPosition other = (RowPosition) obj; - if (index != other.index) { - return false; - } - return true; - } - - /* (non-Javadoc) - * @see java.lang.Comparable#compareTo(java.lang.Object) - */ - @Override - public int compareTo(RowPosition other) { - return Integer.compare(index, other.index); - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "[" + index + "]"; - } -} +package cz.cuni.mff.xrg.odalic.positions; + +import java.io.Serializable; + +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.adapters.RowPositionAdapter; + +/** + * Position of a row in a table. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(RowPositionAdapter.class) +public final class RowPosition implements Serializable, Comparable { + + private static final long serialVersionUID = 3435359552551500579L; + + private final int index; + + /** + * Creates new row position representation. + * + * @param index zero-base index + */ + public RowPosition(int index) { + Preconditions.checkArgument(index >= 0); + + this.index = index; + } + + /** + * @return the index + */ + public int getIndex() { + return index; + } + + /** + * Computes hash code based on the index. + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + index; + return result; + } + + /** + * Compares for equality (only other row position with the same index passes). + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + RowPosition other = (RowPosition) obj; + if (index != other.index) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ + @Override + public int compareTo(RowPosition other) { + return Integer.compare(index, other.index); + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "[" + index + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/MemoryOnlyTaskService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/MemoryOnlyTaskService.java index 58477bd9..3248b566 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/MemoryOnlyTaskService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/MemoryOnlyTaskService.java @@ -1,87 +1,87 @@ -package cz.cuni.mff.xrg.odalic.tasks; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import javax.annotation.Nullable; - -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableSet; - -/** - * This {@link TaskService} implementation provides no persistence. - * - * @author Václav Brodec - * @author Josef Janoušek - * - */ -public final class MemoryOnlyTaskService implements TaskService { - - private final Map tasks; - - private MemoryOnlyTaskService(Map tasks) { - Preconditions.checkNotNull(tasks); - - this.tasks = tasks; - } - - /** - * Creates the task service with no registered tasks. - */ - public MemoryOnlyTaskService() { - this(new HashMap<>()); - } - - public Set getTasks() { - return ImmutableSet.copyOf(this.tasks.values()); - } - - public Task getById(String id) { - Preconditions.checkNotNull(id); - - Task task = this.tasks.get(id); - Preconditions.checkArgument(task != null); - - return task; - } - - public boolean hasId(Task task, String id) { - Preconditions.checkNotNull(id); - - if (task.getId() == null) { - return false; - } - - return task.getId().equals(id); - } - - public void deleteById(String id) { - Preconditions.checkNotNull(id); - - Task task = this.tasks.remove(id); - Preconditions.checkArgument(task != null); - } - - @Nullable - public Task verifyTaskExistenceById(String id) { - Preconditions.checkNotNull(id); - - if(this.tasks.containsKey(id)) { - return this.tasks.get(id); - } - else { - return null; - } - } - - public void create(Task task) { - Preconditions.checkArgument(verifyTaskExistenceById(task.getId()) == null); - - replace(task); - } - - public void replace(Task task) { - this.tasks.put(task.getId(), task); - } -} +package cz.cuni.mff.xrg.odalic.tasks; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.annotation.Nullable; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableSet; + +/** + * This {@link TaskService} implementation provides no persistence. + * + * @author Václav Brodec + * @author Josef Janoušek + * + */ +public final class MemoryOnlyTaskService implements TaskService { + + private final Map tasks; + + private MemoryOnlyTaskService(Map tasks) { + Preconditions.checkNotNull(tasks); + + this.tasks = tasks; + } + + /** + * Creates the task service with no registered tasks. + */ + public MemoryOnlyTaskService() { + this(new HashMap<>()); + } + + public Set getTasks() { + return ImmutableSet.copyOf(this.tasks.values()); + } + + public Task getById(String id) { + Preconditions.checkNotNull(id); + + Task task = this.tasks.get(id); + Preconditions.checkArgument(task != null); + + return task; + } + + public boolean hasId(Task task, String id) { + Preconditions.checkNotNull(id); + + if (task.getId() == null) { + return false; + } + + return task.getId().equals(id); + } + + public void deleteById(String id) { + Preconditions.checkNotNull(id); + + Task task = this.tasks.remove(id); + Preconditions.checkArgument(task != null); + } + + @Nullable + public Task verifyTaskExistenceById(String id) { + Preconditions.checkNotNull(id); + + if(this.tasks.containsKey(id)) { + return this.tasks.get(id); + } + else { + return null; + } + } + + public void create(Task task) { + Preconditions.checkArgument(verifyTaskExistenceById(task.getId()) == null); + + replace(task); + } + + public void replace(Task task) { + this.tasks.put(task.getId(), task); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/Task.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/Task.java index cc46903f..e817b509 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/Task.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/Task.java @@ -1,138 +1,138 @@ -package cz.cuni.mff.xrg.odalic.tasks; - -import java.io.Serializable; -import java.util.Date; - -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.api.rest.adapters.TaskAdapter; -import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; - -/** - * Task represents the single unit of work done by the Odalic core. Its configuration is - * replaceable. - * - * @author Václav Brodec - * - */ -@XmlJavaTypeAdapter(TaskAdapter.class) -public final class Task implements Serializable { - - private static final long serialVersionUID = 1610346823333685091L; - - private final String id; - - private final Date created; - - private Configuration configuration; - - /** - * Creates the task instance. - * - * @param id ID of the task - * @param created provided time of creation - * @param configuration configuration of the task - */ - public Task(String id, Date created, Configuration configuration) { - Preconditions.checkNotNull(id); - Preconditions.checkNotNull(created); - Preconditions.checkNotNull(configuration); - - this.id = id; - this.created = created; - this.configuration = configuration; - } - - /** - * Creates the task instance and sets it creation date to now. - * - * @param id ID of the task - * @param configuration configuration of the task - */ - public Task(String id, Configuration configuration) { - this(id, new Date(), configuration); - } - - /** - * @return the configuration - */ - public Configuration getConfiguration() { - return configuration; - } - - /** - * @param configuration the configuration to set - */ - public void setConfiguration(Configuration configuration) { - Preconditions.checkNotNull(configuration); - - this.configuration = configuration; - } - - /** - * @return the id - */ - public String getId() { - return id; - } - - /** - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Computes hash code value for this object based solely on its ID. - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((id == null) ? 0 : id.hashCode()); - return result; - } - - /** - * Compares for equality (comparable to other {@link Task} instances only, based solely on their - * IDs). - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Task other = (Task) obj; - if (id == null) { - if (other.id != null) { - return false; - } - } else if (!id.equals(other.id)) { - return false; - } - return true; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "Task [id=" + id + ", created=" + created + ", configuration=" + configuration + "]"; - } -} +package cz.cuni.mff.xrg.odalic.tasks; + +import java.io.Serializable; +import java.util.Date; + +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.adapters.TaskAdapter; +import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; + +/** + * Task represents the single unit of work done by the Odalic core. Its configuration is + * replaceable. + * + * @author Václav Brodec + * + */ +@XmlJavaTypeAdapter(TaskAdapter.class) +public final class Task implements Serializable { + + private static final long serialVersionUID = 1610346823333685091L; + + private final String id; + + private final Date created; + + private Configuration configuration; + + /** + * Creates the task instance. + * + * @param id ID of the task + * @param created provided time of creation + * @param configuration configuration of the task + */ + public Task(String id, Date created, Configuration configuration) { + Preconditions.checkNotNull(id); + Preconditions.checkNotNull(created); + Preconditions.checkNotNull(configuration); + + this.id = id; + this.created = created; + this.configuration = configuration; + } + + /** + * Creates the task instance and sets it creation date to now. + * + * @param id ID of the task + * @param configuration configuration of the task + */ + public Task(String id, Configuration configuration) { + this(id, new Date(), configuration); + } + + /** + * @return the configuration + */ + public Configuration getConfiguration() { + return configuration; + } + + /** + * @param configuration the configuration to set + */ + public void setConfiguration(Configuration configuration) { + Preconditions.checkNotNull(configuration); + + this.configuration = configuration; + } + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @return the created + */ + public Date getCreated() { + return created; + } + + /** + * Computes hash code value for this object based solely on its ID. + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; + } + + /** + * Compares for equality (comparable to other {@link Task} instances only, based solely on their + * IDs). + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Task other = (Task) obj; + if (id == null) { + if (other.id != null) { + return false; + } + } else if (!id.equals(other.id)) { + return false; + } + return true; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Task [id=" + id + ", created=" + created + ", configuration=" + configuration + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskService.java index 3e360d4d..bb63239c 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/TaskService.java @@ -1,26 +1,26 @@ -package cz.cuni.mff.xrg.odalic.tasks; - -import java.util.Set; - -/** - * Task service handles the CRUD operations for {@link Task} instances. - * - * @author Václav Brodec - * - */ -public interface TaskService { - - Set getTasks(); - - Task getById(String id); - - boolean hasId(Task task, String id); - - void deleteById(String id); - - Task verifyTaskExistenceById(String id); - - void create(Task task); - - void replace(Task task); -} +package cz.cuni.mff.xrg.odalic.tasks; + +import java.util.Set; + +/** + * Task service handles the CRUD operations for {@link Task} instances. + * + * @author Václav Brodec + * + */ +public interface TaskService { + + Set getTasks(); + + Task getById(String id); + + boolean hasId(Task task, String id); + + void deleteById(String id); + + Task verifyTaskExistenceById(String id); + + void create(Task task); + + void replace(Task task); +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellAnnotation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellAnnotation.java index 74862659..1784ad96 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellAnnotation.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellAnnotation.java @@ -1,150 +1,150 @@ -package cz.cuni.mff.xrg.odalic.tasks.annotations; - -import java.util.Map; -import java.util.NavigableSet; -import java.util.Set; - -import javax.annotation.concurrent.Immutable; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSortedSet; - -import cz.cuni.mff.xrg.odalic.api.rest.adapters.CellAnnotationAdapter; - - -/** - * Annotates cell in a table. - * - * @author Václav Brodec - * - */ -@Immutable -@XmlJavaTypeAdapter(CellAnnotationAdapter.class) -public final class CellAnnotation { - - private final Map> candidates; - - private final Map> chosen; - - /** - * Creates new annotation. - * - * @param candidates all possible candidates for the assigned entity sorted by with their - * likelihood - * @param chosen subset of candidates chosen to annotate the element - */ - public CellAnnotation(Map> candidates, - Map> chosen) { - Preconditions.checkNotNull(candidates); - Preconditions.checkNotNull(chosen); - - ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); - for (final Map.Entry> candidateEntry : candidates.entrySet()) { - candidatesBuilder.put(candidateEntry.getKey(), ImmutableSortedSet.copyOf(candidateEntry.getValue())); - } - this.candidates = candidatesBuilder.build(); - - ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); - for (final Map.Entry> chosenEntry : chosen.entrySet()) { - final KnowledgeBase chosenBase = chosenEntry.getKey(); - - final Set baseCandidates = this.candidates.get(chosenBase); - Preconditions.checkArgument(baseCandidates != null); - Preconditions.checkArgument(baseCandidates.containsAll(chosenEntry.getValue())); - - chosenBuilder.put(chosenEntry.getKey(), ImmutableSet.copyOf(chosenEntry.getValue())); - } - this.chosen = chosenBuilder.build(); - } - - /** - * @return the candidates - */ - public Map> getCandidates() { - return candidates; - } - - /** - * @return the chosen - */ - public Map> getChosen() { - return chosen; - } - - /** - * Merges with the other annotation. - * - * @param other annotation based on different set of knowledge bases - * @return merged annotation - * @throws IllegalArgumentException If both this and the other annotation have some candidates from the same knowledge base - */ - public CellAnnotation merge(CellAnnotation other) throws IllegalArgumentException { - final ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); - candidatesBuilder.putAll(other.candidates); - - final ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); - chosenBuilder.putAll(other.chosen); - - return new CellAnnotation(candidatesBuilder.build(), chosenBuilder.build()); - } - - /** - * Computes hash code based on the candidates and the chosen. - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((candidates == null) ? 0 : candidates.hashCode()); - result = prime * result + ((chosen == null) ? 0 : chosen.hashCode()); - return result; - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - CellAnnotation other = (CellAnnotation) obj; - if (candidates == null) { - if (other.candidates != null) { - return false; - } - } else if (!candidates.equals(other.candidates)) { - return false; - } - if (chosen == null) { - if (other.chosen != null) { - return false; - } - } else if (!chosen.equals(other.chosen)) { - return false; - } - return true; - } - - /** - * Compares for equality (only other annotation of the same kind with equally ordered set of - * candidates and the same chosen set passes). - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public String toString() { - return "CellAnnotation [candidates=" + candidates + ", chosen=" + chosen + "]"; - } -} +package cz.cuni.mff.xrg.odalic.tasks.annotations; + +import java.util.Map; +import java.util.NavigableSet; +import java.util.Set; + +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSortedSet; + +import cz.cuni.mff.xrg.odalic.api.rest.adapters.CellAnnotationAdapter; + + +/** + * Annotates cell in a table. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(CellAnnotationAdapter.class) +public final class CellAnnotation { + + private final Map> candidates; + + private final Map> chosen; + + /** + * Creates new annotation. + * + * @param candidates all possible candidates for the assigned entity sorted by with their + * likelihood + * @param chosen subset of candidates chosen to annotate the element + */ + public CellAnnotation(Map> candidates, + Map> chosen) { + Preconditions.checkNotNull(candidates); + Preconditions.checkNotNull(chosen); + + ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); + for (final Map.Entry> candidateEntry : candidates.entrySet()) { + candidatesBuilder.put(candidateEntry.getKey(), ImmutableSortedSet.copyOf(candidateEntry.getValue())); + } + this.candidates = candidatesBuilder.build(); + + ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); + for (final Map.Entry> chosenEntry : chosen.entrySet()) { + final KnowledgeBase chosenBase = chosenEntry.getKey(); + + final Set baseCandidates = this.candidates.get(chosenBase); + Preconditions.checkArgument(baseCandidates != null); + Preconditions.checkArgument(baseCandidates.containsAll(chosenEntry.getValue())); + + chosenBuilder.put(chosenEntry.getKey(), ImmutableSet.copyOf(chosenEntry.getValue())); + } + this.chosen = chosenBuilder.build(); + } + + /** + * @return the candidates + */ + public Map> getCandidates() { + return candidates; + } + + /** + * @return the chosen + */ + public Map> getChosen() { + return chosen; + } + + /** + * Merges with the other annotation. + * + * @param other annotation based on different set of knowledge bases + * @return merged annotation + * @throws IllegalArgumentException If both this and the other annotation have some candidates from the same knowledge base + */ + public CellAnnotation merge(CellAnnotation other) throws IllegalArgumentException { + final ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); + candidatesBuilder.putAll(other.candidates); + + final ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); + chosenBuilder.putAll(other.chosen); + + return new CellAnnotation(candidatesBuilder.build(), chosenBuilder.build()); + } + + /** + * Computes hash code based on the candidates and the chosen. + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((candidates == null) ? 0 : candidates.hashCode()); + result = prime * result + ((chosen == null) ? 0 : chosen.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + CellAnnotation other = (CellAnnotation) obj; + if (candidates == null) { + if (other.candidates != null) { + return false; + } + } else if (!candidates.equals(other.candidates)) { + return false; + } + if (chosen == null) { + if (other.chosen != null) { + return false; + } + } else if (!chosen.equals(other.chosen)) { + return false; + } + return true; + } + + /** + * Compares for equality (only other annotation of the same kind with equally ordered set of + * candidates and the same chosen set passes). + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public String toString() { + return "CellAnnotation [candidates=" + candidates + ", chosen=" + chosen + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellRelationAnnotation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellRelationAnnotation.java index 8eae8c56..ef6171fb 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellRelationAnnotation.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/CellRelationAnnotation.java @@ -1,149 +1,149 @@ -package cz.cuni.mff.xrg.odalic.tasks.annotations; - -import java.util.Map; -import java.util.NavigableSet; -import java.util.Set; - -import javax.annotation.concurrent.Immutable; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSortedSet; - -import cz.cuni.mff.xrg.odalic.api.rest.adapters.CellRelationAnnotationAdapter; - -/** - * Annotates relation between two cells on the same row in a table. - * - * @author Václav Brodec - * - */ -@Immutable -@XmlJavaTypeAdapter(CellRelationAnnotationAdapter.class) -public final class CellRelationAnnotation { - - private final Map> candidates; - - private final Map> chosen; - - /** - * Creates new annotation. - * - * @param candidates all possible candidates for the assigned entity sorted by with their - * likelihood - * @param chosen subset of candidates chosen to annotate the element - */ - public CellRelationAnnotation(Map> candidates, - Map> chosen) { - Preconditions.checkNotNull(candidates); - Preconditions.checkNotNull(chosen); - - final ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); - for (final Map.Entry> candidateEntry : candidates.entrySet()) { - candidatesBuilder.put(candidateEntry.getKey(), ImmutableSortedSet.copyOf(candidateEntry.getValue())); - } - this.candidates = candidatesBuilder.build(); - - final ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); - for (final Map.Entry> chosenEntry : chosen.entrySet()) { - final KnowledgeBase chosenBase = chosenEntry.getKey(); - - final Set baseCandidates = this.candidates.get(chosenBase); - Preconditions.checkArgument(baseCandidates != null); - Preconditions.checkArgument(baseCandidates.containsAll(chosenEntry.getValue())); - - chosenBuilder.put(chosenEntry.getKey(), ImmutableSet.copyOf(chosenEntry.getValue())); - } - this.chosen = chosenBuilder.build(); - } - - /** - * @return the candidates - */ - public Map> getCandidates() { - return candidates; - } - - /** - * @return the chosen - */ - public Map> getChosen() { - return chosen; - } - - /** - * Merges with the other annotation. - * - * @param other annotation based on different set of knowledge bases - * @return merged annotation - * @throws IllegalArgumentException If both this and the other annotation have some candidates from the same knowledge base - */ - public CellRelationAnnotation merge(CellRelationAnnotation other) throws IllegalArgumentException { - final ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); - candidatesBuilder.putAll(other.candidates); - - final ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); - chosenBuilder.putAll(other.chosen); - - return new CellRelationAnnotation(candidatesBuilder.build(), chosenBuilder.build()); - } - - /** - * Computes hash code based on the candidates and the chosen. - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((candidates == null) ? 0 : candidates.hashCode()); - result = prime * result + ((chosen == null) ? 0 : chosen.hashCode()); - return result; - } - - /** - * Compares for equality (only other annotation of the same kind with equally ordered set of - * candidates and the same chosen set passes). - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - CellRelationAnnotation other = (CellRelationAnnotation) obj; - if (candidates == null) { - if (other.candidates != null) { - return false; - } - } else if (!candidates.equals(other.candidates)) { - return false; - } - if (chosen == null) { - if (other.chosen != null) { - return false; - } - } else if (!chosen.equals(other.chosen)) { - return false; - } - return true; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "CellRelationAnnotation [candidates=" + candidates + ", chosen=" + chosen + "]"; - } -} +package cz.cuni.mff.xrg.odalic.tasks.annotations; + +import java.util.Map; +import java.util.NavigableSet; +import java.util.Set; + +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSortedSet; + +import cz.cuni.mff.xrg.odalic.api.rest.adapters.CellRelationAnnotationAdapter; + +/** + * Annotates relation between two cells on the same row in a table. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(CellRelationAnnotationAdapter.class) +public final class CellRelationAnnotation { + + private final Map> candidates; + + private final Map> chosen; + + /** + * Creates new annotation. + * + * @param candidates all possible candidates for the assigned entity sorted by with their + * likelihood + * @param chosen subset of candidates chosen to annotate the element + */ + public CellRelationAnnotation(Map> candidates, + Map> chosen) { + Preconditions.checkNotNull(candidates); + Preconditions.checkNotNull(chosen); + + final ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); + for (final Map.Entry> candidateEntry : candidates.entrySet()) { + candidatesBuilder.put(candidateEntry.getKey(), ImmutableSortedSet.copyOf(candidateEntry.getValue())); + } + this.candidates = candidatesBuilder.build(); + + final ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); + for (final Map.Entry> chosenEntry : chosen.entrySet()) { + final KnowledgeBase chosenBase = chosenEntry.getKey(); + + final Set baseCandidates = this.candidates.get(chosenBase); + Preconditions.checkArgument(baseCandidates != null); + Preconditions.checkArgument(baseCandidates.containsAll(chosenEntry.getValue())); + + chosenBuilder.put(chosenEntry.getKey(), ImmutableSet.copyOf(chosenEntry.getValue())); + } + this.chosen = chosenBuilder.build(); + } + + /** + * @return the candidates + */ + public Map> getCandidates() { + return candidates; + } + + /** + * @return the chosen + */ + public Map> getChosen() { + return chosen; + } + + /** + * Merges with the other annotation. + * + * @param other annotation based on different set of knowledge bases + * @return merged annotation + * @throws IllegalArgumentException If both this and the other annotation have some candidates from the same knowledge base + */ + public CellRelationAnnotation merge(CellRelationAnnotation other) throws IllegalArgumentException { + final ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); + candidatesBuilder.putAll(other.candidates); + + final ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); + chosenBuilder.putAll(other.chosen); + + return new CellRelationAnnotation(candidatesBuilder.build(), chosenBuilder.build()); + } + + /** + * Computes hash code based on the candidates and the chosen. + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((candidates == null) ? 0 : candidates.hashCode()); + result = prime * result + ((chosen == null) ? 0 : chosen.hashCode()); + return result; + } + + /** + * Compares for equality (only other annotation of the same kind with equally ordered set of + * candidates and the same chosen set passes). + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + CellRelationAnnotation other = (CellRelationAnnotation) obj; + if (candidates == null) { + if (other.candidates != null) { + return false; + } + } else if (!candidates.equals(other.candidates)) { + return false; + } + if (chosen == null) { + if (other.chosen != null) { + return false; + } + } else if (!chosen.equals(other.chosen)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "CellRelationAnnotation [candidates=" + candidates + ", chosen=" + chosen + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/ColumnRelationAnnotation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/ColumnRelationAnnotation.java index b31a2def..cfd1703f 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/ColumnRelationAnnotation.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/ColumnRelationAnnotation.java @@ -1,149 +1,149 @@ -package cz.cuni.mff.xrg.odalic.tasks.annotations; - -import java.util.Map; -import java.util.NavigableSet; -import java.util.Set; - -import javax.annotation.concurrent.Immutable; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSortedSet; - -import cz.cuni.mff.xrg.odalic.api.rest.adapters.ColumnRelationAnnotationAdapter; - -/** - * Annotates relation between two columns in a table. - * - * @author Václav Brodec - * - */ -@Immutable -@XmlJavaTypeAdapter(ColumnRelationAnnotationAdapter.class) -public final class ColumnRelationAnnotation { - - private final Map> candidates; - - private final Map> chosen; - - /** - * Creates new annotation. - * - * @param candidates all possible candidates for the assigned entity sorted by with their - * likelihood - * @param chosen subset of candidates chosen to annotate the element - */ - public ColumnRelationAnnotation(Map> candidates, - Map> chosen) { - Preconditions.checkNotNull(candidates); - Preconditions.checkNotNull(chosen); - - final ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); - for (final Map.Entry> candidateEntry : candidates.entrySet()) { - candidatesBuilder.put(candidateEntry.getKey(), ImmutableSortedSet.copyOf(candidateEntry.getValue())); - } - this.candidates = candidatesBuilder.build(); - - final ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); - for (final Map.Entry> chosenEntry : chosen.entrySet()) { - final KnowledgeBase chosenBase = chosenEntry.getKey(); - - final Set baseCandidates = this.candidates.get(chosenBase); - Preconditions.checkArgument(baseCandidates != null); - Preconditions.checkArgument(baseCandidates.containsAll(chosenEntry.getValue())); - - chosenBuilder.put(chosenEntry.getKey(), ImmutableSet.copyOf(chosenEntry.getValue())); - } - this.chosen = chosenBuilder.build(); - } - - /** - * @return the candidates - */ - public Map> getCandidates() { - return candidates; - } - - /** - * @return the chosen - */ - public Map> getChosen() { - return chosen; - } - - /** - * Merges with the other annotation. - * - * @param other annotation based on different set of knowledge bases - * @return merged annotation - * @throws IllegalArgumentException If both this and the other annotation have some candidates from the same knowledge base - */ - public ColumnRelationAnnotation merge(ColumnRelationAnnotation other) throws IllegalArgumentException { - final ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); - candidatesBuilder.putAll(other.candidates); - - final ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); - chosenBuilder.putAll(other.chosen); - - return new ColumnRelationAnnotation(candidatesBuilder.build(), chosenBuilder.build()); - } - - /** - * Computes hash code based on the candidates and the chosen. - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((candidates == null) ? 0 : candidates.hashCode()); - result = prime * result + ((chosen == null) ? 0 : chosen.hashCode()); - return result; - } - - /** - * Compares for equality (only other annotation of the same kind with equally ordered set of - * candidates and the same chosen set passes). - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ColumnRelationAnnotation other = (ColumnRelationAnnotation) obj; - if (candidates == null) { - if (other.candidates != null) { - return false; - } - } else if (!candidates.equals(other.candidates)) { - return false; - } - if (chosen == null) { - if (other.chosen != null) { - return false; - } - } else if (!chosen.equals(other.chosen)) { - return false; - } - return true; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "ColumnRelationAnnotation [candidates=" + candidates + ", chosen=" + chosen + "]"; - } -} +package cz.cuni.mff.xrg.odalic.tasks.annotations; + +import java.util.Map; +import java.util.NavigableSet; +import java.util.Set; + +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSortedSet; + +import cz.cuni.mff.xrg.odalic.api.rest.adapters.ColumnRelationAnnotationAdapter; + +/** + * Annotates relation between two columns in a table. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(ColumnRelationAnnotationAdapter.class) +public final class ColumnRelationAnnotation { + + private final Map> candidates; + + private final Map> chosen; + + /** + * Creates new annotation. + * + * @param candidates all possible candidates for the assigned entity sorted by with their + * likelihood + * @param chosen subset of candidates chosen to annotate the element + */ + public ColumnRelationAnnotation(Map> candidates, + Map> chosen) { + Preconditions.checkNotNull(candidates); + Preconditions.checkNotNull(chosen); + + final ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); + for (final Map.Entry> candidateEntry : candidates.entrySet()) { + candidatesBuilder.put(candidateEntry.getKey(), ImmutableSortedSet.copyOf(candidateEntry.getValue())); + } + this.candidates = candidatesBuilder.build(); + + final ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); + for (final Map.Entry> chosenEntry : chosen.entrySet()) { + final KnowledgeBase chosenBase = chosenEntry.getKey(); + + final Set baseCandidates = this.candidates.get(chosenBase); + Preconditions.checkArgument(baseCandidates != null); + Preconditions.checkArgument(baseCandidates.containsAll(chosenEntry.getValue())); + + chosenBuilder.put(chosenEntry.getKey(), ImmutableSet.copyOf(chosenEntry.getValue())); + } + this.chosen = chosenBuilder.build(); + } + + /** + * @return the candidates + */ + public Map> getCandidates() { + return candidates; + } + + /** + * @return the chosen + */ + public Map> getChosen() { + return chosen; + } + + /** + * Merges with the other annotation. + * + * @param other annotation based on different set of knowledge bases + * @return merged annotation + * @throws IllegalArgumentException If both this and the other annotation have some candidates from the same knowledge base + */ + public ColumnRelationAnnotation merge(ColumnRelationAnnotation other) throws IllegalArgumentException { + final ImmutableMap.Builder> candidatesBuilder = ImmutableMap.builder(); + candidatesBuilder.putAll(other.candidates); + + final ImmutableMap.Builder> chosenBuilder = ImmutableMap.builder(); + chosenBuilder.putAll(other.chosen); + + return new ColumnRelationAnnotation(candidatesBuilder.build(), chosenBuilder.build()); + } + + /** + * Computes hash code based on the candidates and the chosen. + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((candidates == null) ? 0 : candidates.hashCode()); + result = prime * result + ((chosen == null) ? 0 : chosen.hashCode()); + return result; + } + + /** + * Compares for equality (only other annotation of the same kind with equally ordered set of + * candidates and the same chosen set passes). + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ColumnRelationAnnotation other = (ColumnRelationAnnotation) obj; + if (candidates == null) { + if (other.candidates != null) { + return false; + } + } else if (!candidates.equals(other.candidates)) { + return false; + } + if (chosen == null) { + if (other.chosen != null) { + return false; + } + } else if (!chosen.equals(other.chosen)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ColumnRelationAnnotation [candidates=" + candidates + ", chosen=" + chosen + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Entity.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Entity.java index 483119eb..81fc7c26 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Entity.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Entity.java @@ -1,115 +1,115 @@ -package cz.cuni.mff.xrg.odalic.tasks.annotations; - -import java.io.Serializable; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.api.rest.adapters.EntityAdapter; - - -/** - * Groups the resource ID and its label in one handy class. - * - * @author Václav Brodec - */ -@XmlJavaTypeAdapter(EntityAdapter.class) -public final class Entity implements Comparable, Serializable { - - private static final long serialVersionUID = -3001706805535088480L; - - private final String resource; - - private final String label; - - /** - * Creates new entity representation. - * - * @param resource entity resource ID - * @param label label - */ - public Entity(String resource, String label) { - Preconditions.checkNotNull(resource); - Preconditions.checkNotNull(label); - - this.resource = resource; - this.label = label; - } - - /** - * @return the resource ID - */ - public String getResource() { - return resource; - } - - /** - * @return the label - */ - public String getLabel() { - return label; - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((resource == null) ? 0 : resource.hashCode()); - result = prime * result + ((label == null) ? 0 : label.hashCode()); - return result; - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Entity other = (Entity) obj; - if (resource == null) { - if (other.resource != null) { - return false; - } - } else if (!resource.equals(other.resource)) { - return false; - } - if (label == null) { - if (other.label != null) { - return false; - } - } else if (!label.equals(other.label)) { - return false; - } - return true; - } - - /** - * Compares the entities by their resource ID lexicographically. - * - * @see java.lang.Comparable#compareTo(java.lang.Object) - * @see java.lang.String#compareTo(String) for the definition of resource ID comparison - */ - @Override - public int compareTo(Entity o) { - return resource.compareTo(o.resource); - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "Annotation [resource=" + resource + ", label=" + label + "]"; - } -} +package cz.cuni.mff.xrg.odalic.tasks.annotations; + +import java.io.Serializable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.adapters.EntityAdapter; + + +/** + * Groups the resource ID and its label in one handy class. + * + * @author Václav Brodec + */ +@XmlJavaTypeAdapter(EntityAdapter.class) +public final class Entity implements Comparable, Serializable { + + private static final long serialVersionUID = -3001706805535088480L; + + private final String resource; + + private final String label; + + /** + * Creates new entity representation. + * + * @param resource entity resource ID + * @param label label + */ + public Entity(String resource, String label) { + Preconditions.checkNotNull(resource); + Preconditions.checkNotNull(label); + + this.resource = resource; + this.label = label; + } + + /** + * @return the resource ID + */ + public String getResource() { + return resource; + } + + /** + * @return the label + */ + public String getLabel() { + return label; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((resource == null) ? 0 : resource.hashCode()); + result = prime * result + ((label == null) ? 0 : label.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Entity other = (Entity) obj; + if (resource == null) { + if (other.resource != null) { + return false; + } + } else if (!resource.equals(other.resource)) { + return false; + } + if (label == null) { + if (other.label != null) { + return false; + } + } else if (!label.equals(other.label)) { + return false; + } + return true; + } + + /** + * Compares the entities by their resource ID lexicographically. + * + * @see java.lang.Comparable#compareTo(java.lang.Object) + * @see java.lang.String#compareTo(String) for the definition of resource ID comparison + */ + @Override + public int compareTo(Entity o) { + return resource.compareTo(o.resource); + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Annotation [resource=" + resource + ", label=" + label + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/EntityCandidate.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/EntityCandidate.java index 7e40a364..86e96829 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/EntityCandidate.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/EntityCandidate.java @@ -1,127 +1,127 @@ -package cz.cuni.mff.xrg.odalic.tasks.annotations; - -import java.io.Serializable; - -import javax.annotation.concurrent.Immutable; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.api.rest.adapters.EntityCandidateAdapter; - -/** - * Encapsulates annotating entity and the likelihood that is assigned to it. - * - * @author Václav Brodec - * - */ -@Immutable -@XmlJavaTypeAdapter(EntityCandidateAdapter.class) -public final class EntityCandidate implements Comparable, Serializable { - - private static final long serialVersionUID = 3072774254576336747L; - - private final Entity entity; - - private final Likelihood likelihood; - - /** - * @param entity - * @param likelihood - */ - public EntityCandidate(Entity entity, Likelihood likelihood) { - Preconditions.checkNotNull(entity); - - this.entity = entity; - this.likelihood = likelihood; - } - - /** - * @return the entity - */ - public Entity getEntity() { - return entity; - } - - /** - * @return the likelihood - */ - public Likelihood getLikelihood() { - return likelihood; - } - - /** - * Computes hash code based on the entity and the likelihood. - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((entity == null) ? 0 : entity.hashCode()); - result = prime * result + ((likelihood == null) ? 0 : likelihood.hashCode()); - return result; - } - - /** - * Compares for equality (only other candidates entity with the same likelihood passes). - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - EntityCandidate other = (EntityCandidate) obj; - if (entity == null) { - if (other.entity != null) { - return false; - } - } else if (!entity.equals(other.entity)) { - return false; - } - if (likelihood == null) { - if (other.likelihood != null) { - return false; - } - } else if (!likelihood.equals(other.likelihood)) { - return false; - } - return true; - } - - /** - * Entity candidates are naturally ordered by their likelihood in ascending order. In case of the - * equal likelihood the natural ordering of entities is taken into account. - * - * @see java.lang.Comparable#compareTo(java.lang.Object) - */ - @Override - public int compareTo(EntityCandidate o) { - final int likelihoodComparison = likelihood.compareTo(o.likelihood); - - if (likelihoodComparison == 0) { - return entity.compareTo(o.entity); - } else { - return likelihoodComparison; - } - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "EntityCandidate [entity=" + entity + ", likelihood=" + likelihood + "]"; - } -} +package cz.cuni.mff.xrg.odalic.tasks.annotations; + +import java.io.Serializable; + +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.adapters.EntityCandidateAdapter; + +/** + * Encapsulates annotating entity and the likelihood that is assigned to it. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(EntityCandidateAdapter.class) +public final class EntityCandidate implements Comparable, Serializable { + + private static final long serialVersionUID = 3072774254576336747L; + + private final Entity entity; + + private final Likelihood likelihood; + + /** + * @param entity + * @param likelihood + */ + public EntityCandidate(Entity entity, Likelihood likelihood) { + Preconditions.checkNotNull(entity); + + this.entity = entity; + this.likelihood = likelihood; + } + + /** + * @return the entity + */ + public Entity getEntity() { + return entity; + } + + /** + * @return the likelihood + */ + public Likelihood getLikelihood() { + return likelihood; + } + + /** + * Computes hash code based on the entity and the likelihood. + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((entity == null) ? 0 : entity.hashCode()); + result = prime * result + ((likelihood == null) ? 0 : likelihood.hashCode()); + return result; + } + + /** + * Compares for equality (only other candidates entity with the same likelihood passes). + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + EntityCandidate other = (EntityCandidate) obj; + if (entity == null) { + if (other.entity != null) { + return false; + } + } else if (!entity.equals(other.entity)) { + return false; + } + if (likelihood == null) { + if (other.likelihood != null) { + return false; + } + } else if (!likelihood.equals(other.likelihood)) { + return false; + } + return true; + } + + /** + * Entity candidates are naturally ordered by their likelihood in ascending order. In case of the + * equal likelihood the natural ordering of entities is taken into account. + * + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ + @Override + public int compareTo(EntityCandidate o) { + final int likelihoodComparison = likelihood.compareTo(o.likelihood); + + if (likelihoodComparison == 0) { + return entity.compareTo(o.entity); + } else { + return likelihoodComparison; + } + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "EntityCandidate [entity=" + entity + ", likelihood=" + likelihood + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/HeaderAnnotation.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/HeaderAnnotation.java index 1472a5f3..f339eddb 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/HeaderAnnotation.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/HeaderAnnotation.java @@ -1,160 +1,160 @@ -package cz.cuni.mff.xrg.odalic.tasks.annotations; - -import java.util.Map; -import java.util.NavigableSet; -import java.util.Set; - -import javax.annotation.concurrent.Immutable; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSortedSet; - -import cz.cuni.mff.xrg.odalic.api.rest.adapters.HeaderAnnotationAdapter; - -/** - * Annotates table header and thus affects the whole column and all relations it takes part in. - * - * @author Václav Brodec - * - */ -@Immutable -@XmlJavaTypeAdapter(HeaderAnnotationAdapter.class) -public final class HeaderAnnotation { - - private final Map> candidates; - - private final Map> chosen; - - /** - * Creates new annotation. - * - * @param candidates all possible candidates for the assigned entity sorted by with their - * likelihood - * @param chosen subset of candidates chosen to annotate the element - */ - public HeaderAnnotation( - Map> candidates, - Map> chosen) { - Preconditions.checkNotNull(candidates); - Preconditions.checkNotNull(chosen); - - final ImmutableMap.Builder> candidatesBuilder = - ImmutableMap.builder(); - for (final Map.Entry> candidateEntry : candidates - .entrySet()) { - candidatesBuilder.put(candidateEntry.getKey(), - ImmutableSortedSet.copyOf(candidateEntry.getValue())); - } - this.candidates = candidatesBuilder.build(); - - final ImmutableMap.Builder> chosenBuilder = - ImmutableMap.builder(); - for (final Map.Entry> chosenEntry : chosen - .entrySet()) { - final KnowledgeBase chosenBase = chosenEntry.getKey(); - - final Set baseCandidates = this.candidates.get(chosenBase); - Preconditions.checkArgument(baseCandidates != null); - Preconditions.checkArgument(baseCandidates.containsAll(chosenEntry.getValue())); - - chosenBuilder.put(chosenEntry.getKey(), ImmutableSet.copyOf(chosenEntry.getValue())); - } - this.chosen = chosenBuilder.build(); - } - - /** - * @return the candidates - */ - public Map> getCandidates() { - return candidates; - } - - /** - * @return the chosen - */ - public Map> getChosen() { - return chosen; - } - - /** - * Merges with the other annotation. - * - * @param other annotation based on different set of knowledge bases - * @return merged annotation - * @throws IllegalArgumentException If both this and the other annotation have some candidates - * from the same knowledge base - */ - public HeaderAnnotation merge(HeaderAnnotation other) throws IllegalArgumentException { - final ImmutableMap.Builder> candidatesBuilder = - ImmutableMap.builder(); - candidatesBuilder.putAll(other.candidates); - - final ImmutableMap.Builder> chosenBuilder = - ImmutableMap.builder(); - chosenBuilder.putAll(other.chosen); - - return new HeaderAnnotation(candidatesBuilder.build(), chosenBuilder.build()); - } - - /** - * Computes hash code based on the candidates and the chosen. - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((candidates == null) ? 0 : candidates.hashCode()); - result = prime * result + ((chosen == null) ? 0 : chosen.hashCode()); - return result; - } - - /** - * Compares for equality (only other annotation of the same kind with equally ordered set of - * candidates and the same chosen set passes). - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - HeaderAnnotation other = (HeaderAnnotation) obj; - if (candidates == null) { - if (other.candidates != null) { - return false; - } - } else if (!candidates.equals(other.candidates)) { - return false; - } - if (chosen == null) { - if (other.chosen != null) { - return false; - } - } else if (!chosen.equals(other.chosen)) { - return false; - } - return true; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "HeaderAnnotation [candidates=" + candidates + ", chosen=" + chosen + "]"; - } -} +package cz.cuni.mff.xrg.odalic.tasks.annotations; + +import java.util.Map; +import java.util.NavigableSet; +import java.util.Set; + +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSortedSet; + +import cz.cuni.mff.xrg.odalic.api.rest.adapters.HeaderAnnotationAdapter; + +/** + * Annotates table header and thus affects the whole column and all relations it takes part in. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(HeaderAnnotationAdapter.class) +public final class HeaderAnnotation { + + private final Map> candidates; + + private final Map> chosen; + + /** + * Creates new annotation. + * + * @param candidates all possible candidates for the assigned entity sorted by with their + * likelihood + * @param chosen subset of candidates chosen to annotate the element + */ + public HeaderAnnotation( + Map> candidates, + Map> chosen) { + Preconditions.checkNotNull(candidates); + Preconditions.checkNotNull(chosen); + + final ImmutableMap.Builder> candidatesBuilder = + ImmutableMap.builder(); + for (final Map.Entry> candidateEntry : candidates + .entrySet()) { + candidatesBuilder.put(candidateEntry.getKey(), + ImmutableSortedSet.copyOf(candidateEntry.getValue())); + } + this.candidates = candidatesBuilder.build(); + + final ImmutableMap.Builder> chosenBuilder = + ImmutableMap.builder(); + for (final Map.Entry> chosenEntry : chosen + .entrySet()) { + final KnowledgeBase chosenBase = chosenEntry.getKey(); + + final Set baseCandidates = this.candidates.get(chosenBase); + Preconditions.checkArgument(baseCandidates != null); + Preconditions.checkArgument(baseCandidates.containsAll(chosenEntry.getValue())); + + chosenBuilder.put(chosenEntry.getKey(), ImmutableSet.copyOf(chosenEntry.getValue())); + } + this.chosen = chosenBuilder.build(); + } + + /** + * @return the candidates + */ + public Map> getCandidates() { + return candidates; + } + + /** + * @return the chosen + */ + public Map> getChosen() { + return chosen; + } + + /** + * Merges with the other annotation. + * + * @param other annotation based on different set of knowledge bases + * @return merged annotation + * @throws IllegalArgumentException If both this and the other annotation have some candidates + * from the same knowledge base + */ + public HeaderAnnotation merge(HeaderAnnotation other) throws IllegalArgumentException { + final ImmutableMap.Builder> candidatesBuilder = + ImmutableMap.builder(); + candidatesBuilder.putAll(other.candidates); + + final ImmutableMap.Builder> chosenBuilder = + ImmutableMap.builder(); + chosenBuilder.putAll(other.chosen); + + return new HeaderAnnotation(candidatesBuilder.build(), chosenBuilder.build()); + } + + /** + * Computes hash code based on the candidates and the chosen. + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((candidates == null) ? 0 : candidates.hashCode()); + result = prime * result + ((chosen == null) ? 0 : chosen.hashCode()); + return result; + } + + /** + * Compares for equality (only other annotation of the same kind with equally ordered set of + * candidates and the same chosen set passes). + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + HeaderAnnotation other = (HeaderAnnotation) obj; + if (candidates == null) { + if (other.candidates != null) { + return false; + } + } else if (!candidates.equals(other.candidates)) { + return false; + } + if (chosen == null) { + if (other.chosen != null) { + return false; + } + } else if (!chosen.equals(other.chosen)) { + return false; + } + return true; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "HeaderAnnotation [candidates=" + candidates + ", chosen=" + chosen + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/KnowledgeBase.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/KnowledgeBase.java index c9c8e946..4271ba2d 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/KnowledgeBase.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/KnowledgeBase.java @@ -1,84 +1,84 @@ -package cz.cuni.mff.xrg.odalic.tasks.annotations; - -import javax.annotation.concurrent.Immutable; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.api.rest.adapters.KnowledgeBaseAdapter; - -/** - * Knowledge base identifier. May turn into full-fledged domain entity class in future version. - * - * @author Václav Brodec - * - */ -@Immutable -@XmlJavaTypeAdapter(KnowledgeBaseAdapter.class) -public final class KnowledgeBase { - - private final String name; - - public KnowledgeBase(String name) { - Preconditions.checkNotNull(name); - - this.name = name; - } - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * Computes hash code (for now) based on the name. - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; - } - - /** - * Compares for equality (only other knowledge base instance with the same name passes, for now). - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - KnowledgeBase other = (KnowledgeBase) obj; - if (name == null) { - if (other.name != null) { - return false; - } - } else if (!name.equals(other.name)) { - return false; - } - return true; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "KnowledgeBase [name=" + name + "]"; - } -} +package cz.cuni.mff.xrg.odalic.tasks.annotations; + +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.adapters.KnowledgeBaseAdapter; + +/** + * Knowledge base identifier. May turn into full-fledged domain entity class in future version. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(KnowledgeBaseAdapter.class) +public final class KnowledgeBase { + + private final String name; + + public KnowledgeBase(String name) { + Preconditions.checkNotNull(name); + + this.name = name; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * Computes hash code (for now) based on the name. + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + /** + * Compares for equality (only other knowledge base instance with the same name passes, for now). + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + KnowledgeBase other = (KnowledgeBase) obj; + if (name == null) { + if (other.name != null) { + return false; + } + } else if (!name.equals(other.name)) { + return false; + } + return true; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "KnowledgeBase [name=" + name + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Likelihood.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Likelihood.java index ec8b7e50..fa73ebd7 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Likelihood.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/annotations/Likelihood.java @@ -1,95 +1,95 @@ -package cz.cuni.mff.xrg.odalic.tasks.annotations; - -import java.io.Serializable; - -import javax.annotation.concurrent.Immutable; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.api.rest.adapters.LikelihoodAdapter; - -/** - * Score value for annotation. - * - * @author Václav Brodec - * - */ -@Immutable -@XmlJavaTypeAdapter(LikelihoodAdapter.class) -public final class Likelihood implements Comparable, Serializable { - - private static final long serialVersionUID = -901650058091668104L; - - private final double value; - - public Likelihood(double value) { - Preconditions.checkArgument(value >= 0); - - this.value = value; - } - - /** - * @return the value - */ - public double getValue() { - return value; - } - - /** - * Computes hash code based on the value. - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - long temp; - temp = Double.doubleToLongBits(value); - result = prime * result + (int) (temp ^ (temp >>> 32)); - return result; - } - - /** - * Compares for equality (only other Likelihood with the same values passes). - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Likelihood other = (Likelihood) obj; - if (Double.doubleToLongBits(value) != Double.doubleToLongBits(other.value)) { - return false; - } - return true; - } - - /* (non-Javadoc) - * @see java.lang.Comparable#compareTo(java.lang.Object) - */ - @Override - public int compareTo(Likelihood o) { - return Double.compare(value, o.value); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "Likelihood [value=" + value + "]"; - } - -} +package cz.cuni.mff.xrg.odalic.tasks.annotations; + +import java.io.Serializable; + +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.adapters.LikelihoodAdapter; + +/** + * Score value for annotation. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(LikelihoodAdapter.class) +public final class Likelihood implements Comparable, Serializable { + + private static final long serialVersionUID = -901650058091668104L; + + private final double value; + + public Likelihood(double value) { + Preconditions.checkArgument(value >= 0); + + this.value = value; + } + + /** + * @return the value + */ + public double getValue() { + return value; + } + + /** + * Computes hash code based on the value. + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + long temp; + temp = Double.doubleToLongBits(value); + result = prime * result + (int) (temp ^ (temp >>> 32)); + return result; + } + + /** + * Compares for equality (only other Likelihood with the same values passes). + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Likelihood other = (Likelihood) obj; + if (Double.doubleToLongBits(value) != Double.doubleToLongBits(other.value)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ + @Override + public int compareTo(Likelihood o) { + return Double.compare(value, o.value); + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Likelihood [value=" + value + "]"; + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java index c45f51eb..6936ba96 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/Configuration.java @@ -1,131 +1,131 @@ -package cz.cuni.mff.xrg.odalic.tasks.configurations; - -import java.io.Serializable; - -import javax.annotation.concurrent.Immutable; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.api.rest.adapters.ConfigurationAdapter; -import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; -import cz.cuni.mff.xrg.odalic.files.File; -import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; - -/** - * Task configuration. - * - * @author Václav Brodec - * - */ -@Immutable -@XmlJavaTypeAdapter(ConfigurationAdapter.class) -public final class Configuration implements Serializable { - - private static final long serialVersionUID = -6359038623760039155L; - - private final File input; - - private final Feedback feedback; - - private final KnowledgeBase primaryBase; - - /** - * Creates configuration without any feedback, thus implying fully automatic processing. - * - * @param input input specification - */ - public Configuration(File input, KnowledgeBase primaryBase) { - this(input, primaryBase, new Feedback()); - } - - /** - * Creates configuration with provided feedback, which serves as hint for the processing algorithm. - * - * @param input input specification - * @param primaryBase primary knowledge base - * @param feedback constraints for the algorithm - */ - public Configuration(File input, KnowledgeBase primaryBase, Feedback feedback) { - Preconditions.checkNotNull(input); - Preconditions.checkNotNull(primaryBase); - Preconditions.checkNotNull(feedback); - - this.input = input; - this.primaryBase = primaryBase; - this.feedback = feedback; - } - - /** - * @return the input - */ - public File getInput() { - return input; - } - - /** - * @return the feedback - */ - public Feedback getFeedback() { - return feedback; - } - - /** - * @return the primary knowledge base - */ - public KnowledgeBase getPrimaryBase() { - return primaryBase; - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((feedback == null) ? 0 : feedback.hashCode()); - result = prime * result + ((input == null) ? 0 : input.hashCode()); - return result; - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Configuration other = (Configuration) obj; - if (feedback == null) { - if (other.feedback != null) { - return false; - } - } else if (!feedback.equals(other.feedback)) { - return false; - } - if (input == null) { - if (other.input != null) { - return false; - } - } else if (!input.equals(other.input)) { - return false; - } - return true; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "Configuration [input=" + input + ", feedback=" + feedback + "]"; - } -} +package cz.cuni.mff.xrg.odalic.tasks.configurations; + +import java.io.Serializable; + +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.api.rest.adapters.ConfigurationAdapter; +import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; +import cz.cuni.mff.xrg.odalic.files.File; +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; + +/** + * Task configuration. + * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(ConfigurationAdapter.class) +public final class Configuration implements Serializable { + + private static final long serialVersionUID = -6359038623760039155L; + + private final File input; + + private final Feedback feedback; + + private final KnowledgeBase primaryBase; + + /** + * Creates configuration without any feedback, thus implying fully automatic processing. + * + * @param input input specification + */ + public Configuration(File input, KnowledgeBase primaryBase) { + this(input, primaryBase, new Feedback()); + } + + /** + * Creates configuration with provided feedback, which serves as hint for the processing algorithm. + * + * @param input input specification + * @param primaryBase primary knowledge base + * @param feedback constraints for the algorithm + */ + public Configuration(File input, KnowledgeBase primaryBase, Feedback feedback) { + Preconditions.checkNotNull(input); + Preconditions.checkNotNull(primaryBase); + Preconditions.checkNotNull(feedback); + + this.input = input; + this.primaryBase = primaryBase; + this.feedback = feedback; + } + + /** + * @return the input + */ + public File getInput() { + return input; + } + + /** + * @return the feedback + */ + public Feedback getFeedback() { + return feedback; + } + + /** + * @return the primary knowledge base + */ + public KnowledgeBase getPrimaryBase() { + return primaryBase; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((feedback == null) ? 0 : feedback.hashCode()); + result = prime * result + ((input == null) ? 0 : input.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Configuration other = (Configuration) obj; + if (feedback == null) { + if (other.feedback != null) { + return false; + } + } else if (!feedback.equals(other.feedback)) { + return false; + } + if (input == null) { + if (other.input != null) { + return false; + } + } else if (!input.equals(other.input)) { + return false; + } + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Configuration [input=" + input + ", feedback=" + feedback + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationService.java index d32636b7..8df983d8 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/ConfigurationService.java @@ -1,14 +1,14 @@ -package cz.cuni.mff.xrg.odalic.tasks.configurations; - -/** - * Configuration service handles the CRUD operations for {@link Configuration} instances. - * - * @author Václav Brodec - * - */ -public interface ConfigurationService { - - Configuration getForTaskId(String taskId); - - void setForTaskId(String taskId, Configuration execution); -} +package cz.cuni.mff.xrg.odalic.tasks.configurations; + +/** + * Configuration service handles the CRUD operations for {@link Configuration} instances. + * + * @author Václav Brodec + * + */ +public interface ConfigurationService { + + Configuration getForTaskId(String taskId); + + void setForTaskId(String taskId, Configuration execution); +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/MemoryOnlyConfigurationService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/MemoryOnlyConfigurationService.java index f5281c1e..93a4eb82 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/MemoryOnlyConfigurationService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/configurations/MemoryOnlyConfigurationService.java @@ -1,47 +1,47 @@ -package cz.cuni.mff.xrg.odalic.tasks.configurations; - -import org.springframework.beans.factory.annotation.Autowired; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.tasks.Task; -import cz.cuni.mff.xrg.odalic.tasks.TaskService; - -/** - * This {@link ConfigurationService} implementation provides no persistence. - * - * @author Václav Brodec - * - */ -public final class MemoryOnlyConfigurationService implements ConfigurationService { - - private final TaskService taskService; - - /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.tasks.configurations.ConfigurationService#getForTaskId(java.lang.String) - */ - @Override - public Configuration getForTaskId(String taskId) { - final Task task = taskService.getById(taskId); - - return task.getConfiguration(); - } - - /** - * @param taskId - * @param configuration - */ - @Override - public void setForTaskId(String taskId, Configuration configuration) { - final Task task = taskService.getById(taskId); - - task.setConfiguration(configuration); - } - - @Autowired - public MemoryOnlyConfigurationService(TaskService taskService) { - Preconditions.checkNotNull(taskService); - - this.taskService = taskService; - } -} +package cz.cuni.mff.xrg.odalic.tasks.configurations; + +import org.springframework.beans.factory.annotation.Autowired; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.tasks.Task; +import cz.cuni.mff.xrg.odalic.tasks.TaskService; + +/** + * This {@link ConfigurationService} implementation provides no persistence. + * + * @author Václav Brodec + * + */ +public final class MemoryOnlyConfigurationService implements ConfigurationService { + + private final TaskService taskService; + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.tasks.configurations.ConfigurationService#getForTaskId(java.lang.String) + */ + @Override + public Configuration getForTaskId(String taskId) { + final Task task = taskService.getById(taskId); + + return task.getConfiguration(); + } + + /** + * @param taskId + * @param configuration + */ + @Override + public void setForTaskId(String taskId, Configuration configuration) { + final Task task = taskService.getById(taskId); + + task.setConfiguration(configuration); + } + + @Autowired + public MemoryOnlyConfigurationService(TaskService taskService) { + Preconditions.checkNotNull(taskService); + + this.taskService = taskService; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionService.java index 459a3c1b..5f732358 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/ExecutionService.java @@ -1,62 +1,62 @@ -package cz.cuni.mff.xrg.odalic.tasks.executions; - -import java.util.concurrent.ExecutionException; -import cz.cuni.mff.xrg.odalic.tasks.results.Result; - -/** - * Manages the task execution. - * - * @author Václav Brodec - * - */ -public interface ExecutionService { - /** - * Submits execution of the task. - * - * @param id task ID - * @throws IllegalStateException if the task has already been submitted for execution - */ - void submitForTaskId(String id) throws IllegalStateException; - - /** - * Attempts to cancel execution of the task. - * - * @param id task ID - */ - void cancelForTaskId(String id); - - /** - * Indicates whether the task is done. - * - * @param id task ID - * @return true if done, false otherwise - * - */ - boolean isDoneForTaskId(String id); - - /** - * Indicates whether the task was voluntarily canceled. - * - * @param id task ID - * @return true if canceled, false otherwise - */ - boolean isCanceledForTaskId(String id); - - /** - * Gets result of the task. Blocks until the result is available or the execution canceled. - * - * @param id task ID - * @return annotations for the task input - * @throws InterruptedException if the execution was interrupted while waiting - * @throws ExecutionException if the computation threw an exception - */ - Result getResultForTaskId(String id) throws InterruptedException, ExecutionException; - - /** - * Indicates the state of scheduling. - * - * @param id task ID - * @return true, if the execution has been scheduled for the task, false otherwise - */ - boolean hasBeenScheduledForTaskId(String id); -} +package cz.cuni.mff.xrg.odalic.tasks.executions; + +import java.util.concurrent.ExecutionException; +import cz.cuni.mff.xrg.odalic.tasks.results.Result; + +/** + * Manages the task execution. + * + * @author Václav Brodec + * + */ +public interface ExecutionService { + /** + * Submits execution of the task. + * + * @param id task ID + * @throws IllegalStateException if the task has already been submitted for execution + */ + void submitForTaskId(String id) throws IllegalStateException; + + /** + * Attempts to cancel execution of the task. + * + * @param id task ID + */ + void cancelForTaskId(String id); + + /** + * Indicates whether the task is done. + * + * @param id task ID + * @return true if done, false otherwise + * + */ + boolean isDoneForTaskId(String id); + + /** + * Indicates whether the task was voluntarily canceled. + * + * @param id task ID + * @return true if canceled, false otherwise + */ + boolean isCanceledForTaskId(String id); + + /** + * Gets result of the task. Blocks until the result is available or the execution canceled. + * + * @param id task ID + * @return annotations for the task input + * @throws InterruptedException if the execution was interrupted while waiting + * @throws ExecutionException if the computation threw an exception + */ + Result getResultForTaskId(String id) throws InterruptedException, ExecutionException; + + /** + * Indicates the state of scheduling. + * + * @param id task ID + * @return true, if the execution has been scheduled for the task, false otherwise + */ + boolean hasBeenScheduledForTaskId(String id); +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java index 93511379..1a162f9a 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/FutureBasedExecutionService.java @@ -1,153 +1,153 @@ -/** - * - */ -package cz.cuni.mff.xrg.odalic.tasks.executions; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; - -import org.springframework.beans.factory.annotation.Autowired; - -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableMap; - -import cz.cuni.mff.xrg.odalic.feedbacks.ColumnIgnore; -import cz.cuni.mff.xrg.odalic.files.File; -import cz.cuni.mff.xrg.odalic.files.FileService; -import cz.cuni.mff.xrg.odalic.input.CsvConfiguration; -import cz.cuni.mff.xrg.odalic.input.CsvInputParser; -import cz.cuni.mff.xrg.odalic.input.Input; -import cz.cuni.mff.xrg.odalic.input.InputToTableAdapter; -import cz.cuni.mff.xrg.odalic.tasks.Task; -import cz.cuni.mff.xrg.odalic.tasks.TaskService; -import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; -import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; -import cz.cuni.mff.xrg.odalic.tasks.results.AnnotationToResultAdapter; -import cz.cuni.mff.xrg.odalic.tasks.results.Result; -import uk.ac.shef.dcs.sti.core.algorithm.SemanticTableInterpreter; -import uk.ac.shef.dcs.sti.core.model.TAnnotation; -import uk.ac.shef.dcs.sti.core.model.Table; - -/** - *

Implementation of {@link ExecutionService} based on {@link Future} and {@link ExecutorServicee} - * implementations.

- * - *

Provides no persistence whatsoever

- * - * @author Václav Brodec - * - */ -public final class FutureBasedExecutionService implements ExecutionService { - - private final TaskService taskService; - private final FileService fileService; - private final AnnotationToResultAdapter annotationResultAdapter; - private final SemanticTableInterpreterFactory semanticTableInterpreterFactory; - private final CsvInputParser csvInputParser; - private final InputToTableAdapter inputToTableAdapter; - private final ExecutorService executorService = Executors.newFixedThreadPool(1); - private final Map> tasksToResults = new HashMap<>(); - - @Autowired - public FutureBasedExecutionService(TaskService taskService, FileService fileService, - AnnotationToResultAdapter annotationToResultAdapter, - SemanticTableInterpreterFactory semanticTableInterpreterFactory, - CsvInputParser csvInputParser, InputToTableAdapter inputToTableAdapter) { - Preconditions.checkNotNull(taskService); - Preconditions.checkNotNull(fileService); - Preconditions.checkNotNull(annotationToResultAdapter); - Preconditions.checkNotNull(semanticTableInterpreterFactory); - Preconditions.checkNotNull(csvInputParser); - Preconditions.checkNotNull(inputToTableAdapter); - - this.taskService = taskService; - this.fileService = fileService; - this.annotationResultAdapter = annotationToResultAdapter; - this.semanticTableInterpreterFactory = semanticTableInterpreterFactory; - this.csvInputParser = csvInputParser; - this.inputToTableAdapter = inputToTableAdapter; - } - - /* (non-Javadoc) - * @see cz.cuni.mff.xrg.odalic.tasks.executions.ExecutionService#submitForTaskId(java.lang.String) - */ - @Override - public void submitForTaskId(String id) throws IllegalStateException { - final Task task = taskService.getById(id); - - final Future resultFuture = tasksToResults.get(task); - Preconditions.checkState(resultFuture == null || resultFuture.isDone()); - - final Configuration configuration = task.getConfiguration(); - final File file = configuration.getInput(); - - final Set columnIgnores = configuration.getFeedback().getColumnIgnores(); - - final Callable execution = () -> { - final String data = fileService.getDataById(file.getId()); - - // TODO: Read configuration attributed to the file instead of the default one. - final Input input = csvInputParser.parse(data, file.getId(), new CsvConfiguration()); - final Table table = inputToTableAdapter.toTable(input); - - final SemanticTableInterpreter interpreter = semanticTableInterpreterFactory.getInterpreter(); - semanticTableInterpreterFactory.setColumnIgnoresForInterpreter(columnIgnores); - - final TAnnotation annotationResult = interpreter.start(table, true); - // TODO: Add multiple KB support to configuration. - final Result result = annotationResultAdapter - .toResult(ImmutableMap.of(new KnowledgeBase("DBpedia"), annotationResult)); - - return result; - }; - - final Future future = executorService.submit(execution); - tasksToResults.put(task, future); - } - - @Override - public Result getResultForTaskId(String id) throws InterruptedException, ExecutionException { - final Task task = taskService.getById(id); - final Future resultFuture = tasksToResults.get(task); - - return resultFuture.get(); - } - - @Override - public void cancelForTaskId(String id) { - final Task task = taskService.getById(id); - final Future resultFuture = tasksToResults.get(task); - - resultFuture.cancel(true); - } - - @Override - public boolean isDoneForTaskId(String id) { - final Task task = taskService.getById(id); - final Future resultFuture = tasksToResults.get(task); - - return resultFuture.isDone(); - } - - @Override - public boolean isCanceledForTaskId(String id) { - final Task task = taskService.getById(id); - final Future resultFuture = tasksToResults.get(task); - - return resultFuture.isCancelled(); - } - - @Override - public boolean hasBeenScheduledForTaskId(String id) { - final Task task = taskService.getById(id); - final Future resultFuture = tasksToResults.get(task); - - return resultFuture != null; - } -} +/** + * + */ +package cz.cuni.mff.xrg.odalic.tasks.executions; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +import org.springframework.beans.factory.annotation.Autowired; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; + +import cz.cuni.mff.xrg.odalic.feedbacks.ColumnIgnore; +import cz.cuni.mff.xrg.odalic.files.File; +import cz.cuni.mff.xrg.odalic.files.FileService; +import cz.cuni.mff.xrg.odalic.input.CsvConfiguration; +import cz.cuni.mff.xrg.odalic.input.CsvInputParser; +import cz.cuni.mff.xrg.odalic.input.Input; +import cz.cuni.mff.xrg.odalic.input.InputToTableAdapter; +import cz.cuni.mff.xrg.odalic.tasks.Task; +import cz.cuni.mff.xrg.odalic.tasks.TaskService; +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; +import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; +import cz.cuni.mff.xrg.odalic.tasks.results.AnnotationToResultAdapter; +import cz.cuni.mff.xrg.odalic.tasks.results.Result; +import uk.ac.shef.dcs.sti.core.algorithm.SemanticTableInterpreter; +import uk.ac.shef.dcs.sti.core.model.TAnnotation; +import uk.ac.shef.dcs.sti.core.model.Table; + +/** + *

Implementation of {@link ExecutionService} based on {@link Future} and {@link ExecutorServicee} + * implementations.

+ * + *

Provides no persistence whatsoever

+ * + * @author Václav Brodec + * + */ +public final class FutureBasedExecutionService implements ExecutionService { + + private final TaskService taskService; + private final FileService fileService; + private final AnnotationToResultAdapter annotationResultAdapter; + private final SemanticTableInterpreterFactory semanticTableInterpreterFactory; + private final CsvInputParser csvInputParser; + private final InputToTableAdapter inputToTableAdapter; + private final ExecutorService executorService = Executors.newFixedThreadPool(1); + private final Map> tasksToResults = new HashMap<>(); + + @Autowired + public FutureBasedExecutionService(TaskService taskService, FileService fileService, + AnnotationToResultAdapter annotationToResultAdapter, + SemanticTableInterpreterFactory semanticTableInterpreterFactory, + CsvInputParser csvInputParser, InputToTableAdapter inputToTableAdapter) { + Preconditions.checkNotNull(taskService); + Preconditions.checkNotNull(fileService); + Preconditions.checkNotNull(annotationToResultAdapter); + Preconditions.checkNotNull(semanticTableInterpreterFactory); + Preconditions.checkNotNull(csvInputParser); + Preconditions.checkNotNull(inputToTableAdapter); + + this.taskService = taskService; + this.fileService = fileService; + this.annotationResultAdapter = annotationToResultAdapter; + this.semanticTableInterpreterFactory = semanticTableInterpreterFactory; + this.csvInputParser = csvInputParser; + this.inputToTableAdapter = inputToTableAdapter; + } + + /* (non-Javadoc) + * @see cz.cuni.mff.xrg.odalic.tasks.executions.ExecutionService#submitForTaskId(java.lang.String) + */ + @Override + public void submitForTaskId(String id) throws IllegalStateException { + final Task task = taskService.getById(id); + + final Future resultFuture = tasksToResults.get(task); + Preconditions.checkState(resultFuture == null || resultFuture.isDone()); + + final Configuration configuration = task.getConfiguration(); + final File file = configuration.getInput(); + + final Set columnIgnores = configuration.getFeedback().getColumnIgnores(); + + final Callable execution = () -> { + final String data = fileService.getDataById(file.getId()); + + // TODO: Read configuration attributed to the file instead of the default one. + final Input input = csvInputParser.parse(data, file.getId(), new CsvConfiguration()); + final Table table = inputToTableAdapter.toTable(input); + + final SemanticTableInterpreter interpreter = semanticTableInterpreterFactory.getInterpreter(); + semanticTableInterpreterFactory.setColumnIgnoresForInterpreter(columnIgnores); + + final TAnnotation annotationResult = interpreter.start(table, true); + // TODO: Add multiple KB support to configuration. + final Result result = annotationResultAdapter + .toResult(ImmutableMap.of(new KnowledgeBase("DBpedia"), annotationResult)); + + return result; + }; + + final Future future = executorService.submit(execution); + tasksToResults.put(task, future); + } + + @Override + public Result getResultForTaskId(String id) throws InterruptedException, ExecutionException { + final Task task = taskService.getById(id); + final Future resultFuture = tasksToResults.get(task); + + return resultFuture.get(); + } + + @Override + public void cancelForTaskId(String id) { + final Task task = taskService.getById(id); + final Future resultFuture = tasksToResults.get(task); + + resultFuture.cancel(true); + } + + @Override + public boolean isDoneForTaskId(String id) { + final Task task = taskService.getById(id); + final Future resultFuture = tasksToResults.get(task); + + return resultFuture.isDone(); + } + + @Override + public boolean isCanceledForTaskId(String id) { + final Task task = taskService.getById(id); + final Future resultFuture = tasksToResults.get(task); + + return resultFuture.isCancelled(); + } + + @Override + public boolean hasBeenScheduledForTaskId(String id) { + final Task task = taskService.getById(id); + final Future resultFuture = tasksToResults.get(task); + + return resultFuture != null; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/SemanticTableInterpreterFactory.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/SemanticTableInterpreterFactory.java index 6f6366fc..aa124d15 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/SemanticTableInterpreterFactory.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/executions/SemanticTableInterpreterFactory.java @@ -1,31 +1,31 @@ -package cz.cuni.mff.xrg.odalic.tasks.executions; - -import java.util.Set; - -import cz.cuni.mff.xrg.odalic.feedbacks.ColumnIgnore; -import uk.ac.shef.dcs.sti.core.algorithm.SemanticTableInterpreter; - - -/** - * This factory class loosely encapsulates (notice the {@link #setColumnIgnoresForInterpreter(Set)} method) the process of interpreter creation. - * - * @author Václav Brodec - * - */ -public interface SemanticTableInterpreterFactory { - - /** - * Lazily initializes the interpreter. - * - * @return the interpreter implementation - */ - SemanticTableInterpreter getInterpreter(); - - /** - * Sets the ignored columns for the created interpreter. - * - * @param columnIgnores positions of ignored columns - */ - void setColumnIgnoresForInterpreter(Set columnIgnores); - -} +package cz.cuni.mff.xrg.odalic.tasks.executions; + +import java.util.Set; + +import cz.cuni.mff.xrg.odalic.feedbacks.ColumnIgnore; +import uk.ac.shef.dcs.sti.core.algorithm.SemanticTableInterpreter; + + +/** + * This factory class loosely encapsulates (notice the {@link #setColumnIgnoresForInterpreter(Set)} method) the process of interpreter creation. + * + * @author Václav Brodec + * + */ +public interface SemanticTableInterpreterFactory { + + /** + * Lazily initializes the interpreter. + * + * @return the interpreter implementation + */ + SemanticTableInterpreter getInterpreter(); + + /** + * Sets the ignored columns for the created interpreter. + * + * @param columnIgnores positions of ignored columns + */ + void setColumnIgnoresForInterpreter(Set columnIgnores); + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/FeedbackService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/FeedbackService.java index 9eb95c36..e6b18fd2 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/FeedbackService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/FeedbackService.java @@ -1,21 +1,21 @@ -package cz.cuni.mff.xrg.odalic.tasks.feedbacks; - -import java.io.IOException; - -import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; -import cz.cuni.mff.xrg.odalic.input.Input; - -/** - * Feedback service handles the CRUD operations for {@link Feedback} instances. - * - * @author Václav Brodec - * - */ -public interface FeedbackService { - - Feedback getForTaskId(String taskId); - - void setForTaskId(String taskId, Feedback feedback); - - Input getInputForTaskId(String id) throws IOException; -} +package cz.cuni.mff.xrg.odalic.tasks.feedbacks; + +import java.io.IOException; + +import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; +import cz.cuni.mff.xrg.odalic.input.Input; + +/** + * Feedback service handles the CRUD operations for {@link Feedback} instances. + * + * @author Václav Brodec + * + */ +public interface FeedbackService { + + Feedback getForTaskId(String taskId); + + void setForTaskId(String taskId, Feedback feedback); + + Input getInputForTaskId(String id) throws IOException; +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/MemoryOnlyFeedbackService.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/MemoryOnlyFeedbackService.java index c608f4f8..7de0cba0 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/MemoryOnlyFeedbackService.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/feedbacks/MemoryOnlyFeedbackService.java @@ -1,63 +1,63 @@ -package cz.cuni.mff.xrg.odalic.tasks.feedbacks; - -import java.io.IOException; - -import org.springframework.beans.factory.annotation.Autowired; - -import com.google.common.base.Preconditions; - -import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; -import cz.cuni.mff.xrg.odalic.files.File; -import cz.cuni.mff.xrg.odalic.files.FileService; -import cz.cuni.mff.xrg.odalic.input.CsvConfiguration; -import cz.cuni.mff.xrg.odalic.input.CsvInputParser; -import cz.cuni.mff.xrg.odalic.input.Input; -import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; -import cz.cuni.mff.xrg.odalic.tasks.configurations.ConfigurationService; - -/** - * This {@link FeedbackService} implementation provides no persistence. - * - * @author Václav Brodec - * - */ -public final class MemoryOnlyFeedbackService implements FeedbackService { - - private final ConfigurationService configurationService; - private final FileService fileService; - private final CsvInputParser inputParser; - - @Autowired - public MemoryOnlyFeedbackService(ConfigurationService configurationService, FileService fileService, CsvInputParser inputParser) { - Preconditions.checkNotNull(configurationService); - Preconditions.checkNotNull(fileService); - Preconditions.checkNotNull(inputParser); - - this.configurationService = configurationService; - this.fileService = fileService; - this.inputParser = inputParser; - } - - @Override - public Feedback getForTaskId(String taskId) { - final Configuration configuration = configurationService.getForTaskId(taskId); - - return configuration.getFeedback(); - } - - @Override - public void setForTaskId(String taskId, Feedback feedback) { - final Configuration oldConfiguration = configurationService.getForTaskId(taskId); - configurationService.setForTaskId(taskId, new Configuration(oldConfiguration.getInput(), oldConfiguration.getPrimaryBase(), feedback)); - } - - @Override - public Input getInputForTaskId(String taskId) throws IOException { - final Configuration configuration = configurationService.getForTaskId(taskId); - final File file = configuration.getInput(); - final String data = fileService.getDataById(file.getId()); - - // TODO: Read configuration attributed to the file instead of the default one. - return inputParser.parse(data, file.getId(), new CsvConfiguration()); - } -} +package cz.cuni.mff.xrg.odalic.tasks.feedbacks; + +import java.io.IOException; + +import org.springframework.beans.factory.annotation.Autowired; + +import com.google.common.base.Preconditions; + +import cz.cuni.mff.xrg.odalic.feedbacks.Feedback; +import cz.cuni.mff.xrg.odalic.files.File; +import cz.cuni.mff.xrg.odalic.files.FileService; +import cz.cuni.mff.xrg.odalic.input.CsvConfiguration; +import cz.cuni.mff.xrg.odalic.input.CsvInputParser; +import cz.cuni.mff.xrg.odalic.input.Input; +import cz.cuni.mff.xrg.odalic.tasks.configurations.Configuration; +import cz.cuni.mff.xrg.odalic.tasks.configurations.ConfigurationService; + +/** + * This {@link FeedbackService} implementation provides no persistence. + * + * @author Václav Brodec + * + */ +public final class MemoryOnlyFeedbackService implements FeedbackService { + + private final ConfigurationService configurationService; + private final FileService fileService; + private final CsvInputParser inputParser; + + @Autowired + public MemoryOnlyFeedbackService(ConfigurationService configurationService, FileService fileService, CsvInputParser inputParser) { + Preconditions.checkNotNull(configurationService); + Preconditions.checkNotNull(fileService); + Preconditions.checkNotNull(inputParser); + + this.configurationService = configurationService; + this.fileService = fileService; + this.inputParser = inputParser; + } + + @Override + public Feedback getForTaskId(String taskId) { + final Configuration configuration = configurationService.getForTaskId(taskId); + + return configuration.getFeedback(); + } + + @Override + public void setForTaskId(String taskId, Feedback feedback) { + final Configuration oldConfiguration = configurationService.getForTaskId(taskId); + configurationService.setForTaskId(taskId, new Configuration(oldConfiguration.getInput(), oldConfiguration.getPrimaryBase(), feedback)); + } + + @Override + public Input getInputForTaskId(String taskId) throws IOException { + final Configuration configuration = configurationService.getForTaskId(taskId); + final File file = configuration.getInput(); + final String data = fileService.getDataById(file.getId()); + + // TODO: Read configuration attributed to the file instead of the default one. + return inputParser.parse(data, file.getId(), new CsvConfiguration()); + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/AnnotationToResultAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/AnnotationToResultAdapter.java index 504c2f84..8e2bfff8 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/AnnotationToResultAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/AnnotationToResultAdapter.java @@ -1,24 +1,24 @@ -package cz.cuni.mff.xrg.odalic.tasks.results; - -import java.util.Map; - -import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; -import uk.ac.shef.dcs.sti.core.model.TAnnotation; - -/** - * Converts the complete annotation result provided by the Semantic Table Interpreter to the - * representation used by Odalic server to facilitate RDF output and user feedback. - * - * @author Václav Brodec - * - */ -public interface AnnotationToResultAdapter { - /** - * Converts the annotation formats. - * - * @param basesToTableAnnotations map to table annotations from the knowledge bases that were used - * to make them - * @return Odalic result format - */ - Result toResult(Map basesToTableAnnotations); -} +package cz.cuni.mff.xrg.odalic.tasks.results; + +import java.util.Map; + +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; +import uk.ac.shef.dcs.sti.core.model.TAnnotation; + +/** + * Converts the complete annotation result provided by the Semantic Table Interpreter to the + * representation used by Odalic server to facilitate RDF output and user feedback. + * + * @author Václav Brodec + * + */ +public interface AnnotationToResultAdapter { + /** + * Converts the annotation formats. + * + * @param basesToTableAnnotations map to table annotations from the knowledge bases that were used + * to make them + * @return Odalic result format + */ + Result toResult(Map basesToTableAnnotations); +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/DefaultAnnotationToResultAdapter.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/DefaultAnnotationToResultAdapter.java index 6776bef3..3bdb55ba 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/DefaultAnnotationToResultAdapter.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/DefaultAnnotationToResultAdapter.java @@ -1,327 +1,327 @@ -package cz.cuni.mff.xrg.odalic.tasks.results; - -import cz.cuni.mff.xrg.odalic.positions.CellRelationPosition; -import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; -import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; -import cz.cuni.mff.xrg.odalic.positions.RowPosition; -import cz.cuni.mff.xrg.odalic.tasks.annotations.CellAnnotation; -import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; -import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; -import cz.cuni.mff.xrg.odalic.tasks.annotations.Entity; -import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; -import cz.cuni.mff.xrg.odalic.tasks.annotations.HeaderAnnotation; -import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; -import cz.cuni.mff.xrg.odalic.tasks.annotations.Likelihood; -import cz.cuni.mff.xrg.odalic.util.Arrays; -import cz.cuni.mff.xrg.odalic.util.Lists; -import cz.cuni.mff.xrg.odalic.util.Maps; -import uk.ac.shef.dcs.kbsearch.model.Clazz; -import uk.ac.shef.dcs.sti.core.model.RelationColumns; -import uk.ac.shef.dcs.sti.core.model.TAnnotation; -import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; -import uk.ac.shef.dcs.sti.core.model.TCellCellRelationAnotation; -import uk.ac.shef.dcs.sti.core.model.TColumnColumnRelationAnnotation; -import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.annotation.concurrent.Immutable; - -import com.google.common.base.Preconditions; - -/** - * This implementation of {@link AnnotationToResultAdapter} simply merges the annotations done with - * different knowledge bases. - * - * @author Jan Váňa - * @author Václav Brodec - * - */ -@Immutable -public class DefaultAnnotationToResultAdapter implements AnnotationToResultAdapter { - - /** - * This implementation demands that the subject columns recognized in the annotations are the same. - * - * @see cz.cuni.mff.xrg.odalic.tasks.results.AnnotationToResultAdapter#toResult(java.util.Map) - */ - @Override - public Result toResult(Map basesToTableAnnotations) { - Preconditions.checkArgument(!basesToTableAnnotations.isEmpty()); - - final Iterator> entrySetIterator = - initializeEntrySetIterator(basesToTableAnnotations); - - // Process the first entry to initialize working structures for the merges. - final Map.Entry firstEntry = entrySetIterator.next(); - final KnowledgeBase firstKnowledgeBase = firstEntry.getKey(); - final TAnnotation firstTableAnnotation = firstEntry.getValue(); - - final ColumnPosition firstSubjectColumn = convertSubjectColumn(firstTableAnnotation); - final List mergedHeaderAnnotations = - convertColumnAnnotations(firstKnowledgeBase, firstTableAnnotation); - final CellAnnotation[][] mergedCellAnnotations = - convertCellAnnotations(firstKnowledgeBase, firstTableAnnotation); - final Map mergedColumnRelations = - convertColumnRelations(firstKnowledgeBase, firstTableAnnotation); - final Map mergedCellCellRelations = - convertCellRelations(firstKnowledgeBase, firstTableAnnotation); - - // Process the rest. - processTheRest(entrySetIterator, firstSubjectColumn, mergedHeaderAnnotations, - mergedCellAnnotations, mergedColumnRelations, mergedCellCellRelations); - - return new Result(firstSubjectColumn, mergedHeaderAnnotations, mergedCellAnnotations, mergedColumnRelations, mergedCellCellRelations); - } - - private static Iterator> initializeEntrySetIterator( - Map basesToTableAnnotations) { - final Set> entrySet = basesToTableAnnotations.entrySet(); - final Iterator> entrySetIterator = entrySet.iterator(); - return entrySetIterator; - } - - private static void processTheRest( - final Iterator> entrySetIterator, - final ColumnPosition firstSubjectColumn, final List mergedHeaderAnnotations, - final CellAnnotation[][] mergedCellAnnotations, - final Map mergedColumnRelations, - final Map mergedCellCellRelations) { - while (entrySetIterator.hasNext()) { - final Map.Entry entry = entrySetIterator.next(); - - final KnowledgeBase knowledgeBase = entry.getKey(); - final TAnnotation tableAnnotation = entry.getValue(); - - checkSubjectColumnEquality(firstSubjectColumn, tableAnnotation); // The annotations must agree on the subject column!!! - - mergeHeaders(mergedHeaderAnnotations, knowledgeBase, tableAnnotation); - mergeCells(mergedCellAnnotations, knowledgeBase, tableAnnotation); - mergeColumnRelations(mergedColumnRelations, knowledgeBase, tableAnnotation); - mergeCellRelations(mergedCellCellRelations, knowledgeBase, tableAnnotation); - } - } - - private static void checkSubjectColumnEquality(final ColumnPosition firstSubjectColumn, - final TAnnotation tableAnnotation) { - final ColumnPosition subjectColumn = convertSubjectColumn(tableAnnotation); - Preconditions.checkArgument(subjectColumn.equals(firstSubjectColumn)); - } - - private static ColumnPosition convertSubjectColumn(final TAnnotation tableAnnotation) { - final ColumnPosition subjectColumn = new ColumnPosition(tableAnnotation.getSubjectColumn()); - return subjectColumn; - } - - private static void mergeCellRelations( - final Map mergedCellCellRelations, - final KnowledgeBase knowledgeBase, final TAnnotation tableAnnotation) { - final Map cellCellRelations = - convertCellRelations(knowledgeBase, tableAnnotation); - Maps.mergeWith(mergedCellCellRelations, cellCellRelations, - (first, second) -> first.merge(second)); - } - - private static void mergeColumnRelations( - final Map mergedColumnRelations, - final KnowledgeBase knowledgeBase, final TAnnotation tableAnnotation) { - final Map columnRelations = - convertColumnRelations(knowledgeBase, tableAnnotation); - Maps.mergeWith(mergedColumnRelations, columnRelations, - (first, second) -> first.merge(second)); - } - - private static void mergeCells(final CellAnnotation[][] mergedCellAnnotations, - final KnowledgeBase knowledgeBase, final TAnnotation tableAnnotation) { - final CellAnnotation[][] cellAnnotations = convertCellAnnotations(knowledgeBase, tableAnnotation); - Arrays.zipMatrixWith(mergedCellAnnotations, cellAnnotations, - (first, second) -> first.merge(second)); - } - - private static void mergeHeaders(final List mergedHeaderAnnotations, - final KnowledgeBase knowledgeBase, final TAnnotation tableAnnotation) { - final List headerAnnotations = - convertColumnAnnotations(knowledgeBase, tableAnnotation); - Lists.zipWith(mergedHeaderAnnotations, headerAnnotations, - (first, second) -> first.merge(second)); - } - - private static Map convertCellRelations(KnowledgeBase knowledgeBase, TAnnotation original) { - Map cellCellRelations = new HashMap<>(); - for (Map.Entry>> columnAnnotations : original.getCellcellRelations().entrySet() ){ - for(Map.Entry> annotations : columnAnnotations.getValue().entrySet()){ - HashMap> candidates = new HashMap<>(); - HashMap> chosen = new HashMap<>(); - - Set candidatesSet = new HashSet<>(); - Set chosenSet = new HashSet<>(); - - candidates.put(knowledgeBase, candidatesSet); - chosen.put(knowledgeBase, chosenSet); - - EntityCandidate bestCandidate = null; - for (TCellCellRelationAnotation annotation : annotations.getValue()) { - Entity entity = new Entity(annotation.getRelationURI(), annotation.getRelationLabel()); - Likelihood likelihood = new Likelihood(annotation.getWinningAttributeMatchScore()); - - EntityCandidate candidate = new EntityCandidate(entity, likelihood); - - candidatesSet.add(candidate); - - if (bestCandidate == null || bestCandidate.getLikelihood().getValue() < candidate.getLikelihood().getValue()) { - bestCandidate = candidate; - } - } - - if (bestCandidate != null){ - chosenSet.add(bestCandidate); - } - - RelationColumns relationColumns = columnAnnotations.getKey(); - ColumnRelationPosition columnPosition = new ColumnRelationPosition(new ColumnPosition(relationColumns.getSubjectCol()), new ColumnPosition(relationColumns.getObjectCol())); - RowPosition rowPosition = new RowPosition(annotations.getKey()); - CellRelationPosition position = new CellRelationPosition(columnPosition, rowPosition); - CellRelationAnnotation relationAnnotation = new CellRelationAnnotation(candidates, chosen); - cellCellRelations.put(position, relationAnnotation); - } - } - return cellCellRelations; - } - - private static Map convertColumnRelations(KnowledgeBase knowledgeBase, TAnnotation original) { - Map columnRelations = new HashMap<>(); - for (Map.Entry> annotations : original.getColumncolumnRelations().entrySet() ){ - HashMap> candidates = new HashMap<>(); - HashMap> chosen = new HashMap<>(); - - Set candidatesSet = new HashSet<>(); - Set chosenSet = new HashSet<>(); - - candidates.put(knowledgeBase, candidatesSet); - chosen.put(knowledgeBase, chosenSet); - - EntityCandidate bestCandidate = null; - for (TColumnColumnRelationAnnotation annotation : annotations.getValue()) { - Entity entity = new Entity(annotation.getRelationURI(), annotation.getRelationLabel()); - Likelihood likelihood = new Likelihood(annotation.getFinalScore()); - - EntityCandidate candidate = new EntityCandidate(entity, likelihood); - - candidatesSet.add(candidate); - - if (bestCandidate == null || bestCandidate.getLikelihood().getValue() < candidate.getLikelihood().getValue()) { - bestCandidate = candidate; - } - } - - if (bestCandidate != null){ - chosenSet.add(bestCandidate); - } - - RelationColumns relationColumns = annotations.getKey(); - ColumnRelationPosition position = new ColumnRelationPosition(new ColumnPosition(relationColumns.getSubjectCol()), new ColumnPosition(relationColumns.getObjectCol())); - ColumnRelationAnnotation relationAnnotation = new ColumnRelationAnnotation(candidates, chosen); - columnRelations.put(position, relationAnnotation); - } - return columnRelations; - } - - private static CellAnnotation[][] convertCellAnnotations(KnowledgeBase knowledgeBase, TAnnotation original) { - int columnCount = original.getCols(); - int rowCount = original.getRows(); - CellAnnotation[][] cellAnnotations = new CellAnnotation[rowCount][columnCount]; - - for (int columnIndex = 0; columnIndex < columnCount; columnIndex++) { - for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) { - TCellAnnotation[] annotations = original.getContentCellAnnotations(rowIndex, columnIndex); - - HashMap> candidates = new HashMap<>(); - HashMap> chosen = new HashMap<>(); - - if (annotations != null) { - Set candidatesSet = new HashSet<>(); - Set chosenSet = new HashSet<>(); - - candidates.put(knowledgeBase, candidatesSet); - chosen.put(knowledgeBase, chosenSet); - - EntityCandidate bestCandidate = null; - for (TCellAnnotation annotation : annotations) { - uk.ac.shef.dcs.kbsearch.model.Entity clazz = annotation.getAnnotation(); - - Entity entity = new Entity(clazz.getId(), clazz.getLabel()); - Likelihood likelihood = new Likelihood(annotation.getFinalScore()); - - EntityCandidate candidate = new EntityCandidate(entity, likelihood); - - candidatesSet.add(candidate); - - if (bestCandidate == null || bestCandidate.getLikelihood().getValue() < candidate.getLikelihood().getValue()) { - bestCandidate = candidate; - } - } - - if (bestCandidate != null){ - chosenSet.add(bestCandidate); - } - } - - CellAnnotation cellAnnotation = new CellAnnotation(candidates, chosen); - cellAnnotations[rowIndex][columnIndex] = cellAnnotation; - } - } - - return cellAnnotations; - } - - private static List convertColumnAnnotations(KnowledgeBase knowledgeBase, TAnnotation original) { - int columnCount = original.getCols(); - List headerAnnotations = new ArrayList<>(columnCount); - - for (int columnIndex = 0; columnIndex < columnCount; columnIndex++) { - TColumnHeaderAnnotation[] annotations = original.getHeaderAnnotation(columnIndex); - - HashMap> candidates = new HashMap<>(); - HashMap> chosen = new HashMap<>(); - - if (annotations != null) { - Set candidatesSet = new HashSet<>(); - Set chosenSet = new HashSet<>(); - - candidates.put(knowledgeBase, candidatesSet); - chosen.put(knowledgeBase, chosenSet); - - EntityCandidate bestCandidate = null; - for (TColumnHeaderAnnotation annotation : annotations) { - Clazz clazz = annotation.getAnnotation(); - - Entity entity = new Entity(clazz.getId(), clazz.getLabel()); - Likelihood likelihood = new Likelihood(annotation.getFinalScore()); - - EntityCandidate candidate = new EntityCandidate(entity, likelihood); - - candidatesSet.add(candidate); - - if (bestCandidate == null || bestCandidate.getLikelihood().getValue() < candidate.getLikelihood().getValue()) { - bestCandidate = candidate; - } - } - - if (bestCandidate != null){ - chosenSet.add(bestCandidate); - } - } - - HeaderAnnotation headerAnnotation = new HeaderAnnotation(candidates, chosen); - headerAnnotations.add(headerAnnotation); - } - - return headerAnnotations; - } -} +package cz.cuni.mff.xrg.odalic.tasks.results; + +import cz.cuni.mff.xrg.odalic.positions.CellRelationPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; +import cz.cuni.mff.xrg.odalic.positions.RowPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.Entity; +import cz.cuni.mff.xrg.odalic.tasks.annotations.EntityCandidate; +import cz.cuni.mff.xrg.odalic.tasks.annotations.HeaderAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; +import cz.cuni.mff.xrg.odalic.tasks.annotations.Likelihood; +import cz.cuni.mff.xrg.odalic.util.Arrays; +import cz.cuni.mff.xrg.odalic.util.Lists; +import cz.cuni.mff.xrg.odalic.util.Maps; +import uk.ac.shef.dcs.kbsearch.model.Clazz; +import uk.ac.shef.dcs.sti.core.model.RelationColumns; +import uk.ac.shef.dcs.sti.core.model.TAnnotation; +import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; +import uk.ac.shef.dcs.sti.core.model.TCellCellRelationAnotation; +import uk.ac.shef.dcs.sti.core.model.TColumnColumnRelationAnnotation; +import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.annotation.concurrent.Immutable; + +import com.google.common.base.Preconditions; + +/** + * This implementation of {@link AnnotationToResultAdapter} simply merges the annotations done with + * different knowledge bases. + * + * @author Jan Váňa + * @author Václav Brodec + * + */ +@Immutable +public class DefaultAnnotationToResultAdapter implements AnnotationToResultAdapter { + + /** + * This implementation demands that the subject columns recognized in the annotations are the same. + * + * @see cz.cuni.mff.xrg.odalic.tasks.results.AnnotationToResultAdapter#toResult(java.util.Map) + */ + @Override + public Result toResult(Map basesToTableAnnotations) { + Preconditions.checkArgument(!basesToTableAnnotations.isEmpty()); + + final Iterator> entrySetIterator = + initializeEntrySetIterator(basesToTableAnnotations); + + // Process the first entry to initialize working structures for the merges. + final Map.Entry firstEntry = entrySetIterator.next(); + final KnowledgeBase firstKnowledgeBase = firstEntry.getKey(); + final TAnnotation firstTableAnnotation = firstEntry.getValue(); + + final ColumnPosition firstSubjectColumn = convertSubjectColumn(firstTableAnnotation); + final List mergedHeaderAnnotations = + convertColumnAnnotations(firstKnowledgeBase, firstTableAnnotation); + final CellAnnotation[][] mergedCellAnnotations = + convertCellAnnotations(firstKnowledgeBase, firstTableAnnotation); + final Map mergedColumnRelations = + convertColumnRelations(firstKnowledgeBase, firstTableAnnotation); + final Map mergedCellCellRelations = + convertCellRelations(firstKnowledgeBase, firstTableAnnotation); + + // Process the rest. + processTheRest(entrySetIterator, firstSubjectColumn, mergedHeaderAnnotations, + mergedCellAnnotations, mergedColumnRelations, mergedCellCellRelations); + + return new Result(firstSubjectColumn, mergedHeaderAnnotations, mergedCellAnnotations, mergedColumnRelations, mergedCellCellRelations); + } + + private static Iterator> initializeEntrySetIterator( + Map basesToTableAnnotations) { + final Set> entrySet = basesToTableAnnotations.entrySet(); + final Iterator> entrySetIterator = entrySet.iterator(); + return entrySetIterator; + } + + private static void processTheRest( + final Iterator> entrySetIterator, + final ColumnPosition firstSubjectColumn, final List mergedHeaderAnnotations, + final CellAnnotation[][] mergedCellAnnotations, + final Map mergedColumnRelations, + final Map mergedCellCellRelations) { + while (entrySetIterator.hasNext()) { + final Map.Entry entry = entrySetIterator.next(); + + final KnowledgeBase knowledgeBase = entry.getKey(); + final TAnnotation tableAnnotation = entry.getValue(); + + checkSubjectColumnEquality(firstSubjectColumn, tableAnnotation); // The annotations must agree on the subject column!!! + + mergeHeaders(mergedHeaderAnnotations, knowledgeBase, tableAnnotation); + mergeCells(mergedCellAnnotations, knowledgeBase, tableAnnotation); + mergeColumnRelations(mergedColumnRelations, knowledgeBase, tableAnnotation); + mergeCellRelations(mergedCellCellRelations, knowledgeBase, tableAnnotation); + } + } + + private static void checkSubjectColumnEquality(final ColumnPosition firstSubjectColumn, + final TAnnotation tableAnnotation) { + final ColumnPosition subjectColumn = convertSubjectColumn(tableAnnotation); + Preconditions.checkArgument(subjectColumn.equals(firstSubjectColumn)); + } + + private static ColumnPosition convertSubjectColumn(final TAnnotation tableAnnotation) { + final ColumnPosition subjectColumn = new ColumnPosition(tableAnnotation.getSubjectColumn()); + return subjectColumn; + } + + private static void mergeCellRelations( + final Map mergedCellCellRelations, + final KnowledgeBase knowledgeBase, final TAnnotation tableAnnotation) { + final Map cellCellRelations = + convertCellRelations(knowledgeBase, tableAnnotation); + Maps.mergeWith(mergedCellCellRelations, cellCellRelations, + (first, second) -> first.merge(second)); + } + + private static void mergeColumnRelations( + final Map mergedColumnRelations, + final KnowledgeBase knowledgeBase, final TAnnotation tableAnnotation) { + final Map columnRelations = + convertColumnRelations(knowledgeBase, tableAnnotation); + Maps.mergeWith(mergedColumnRelations, columnRelations, + (first, second) -> first.merge(second)); + } + + private static void mergeCells(final CellAnnotation[][] mergedCellAnnotations, + final KnowledgeBase knowledgeBase, final TAnnotation tableAnnotation) { + final CellAnnotation[][] cellAnnotations = convertCellAnnotations(knowledgeBase, tableAnnotation); + Arrays.zipMatrixWith(mergedCellAnnotations, cellAnnotations, + (first, second) -> first.merge(second)); + } + + private static void mergeHeaders(final List mergedHeaderAnnotations, + final KnowledgeBase knowledgeBase, final TAnnotation tableAnnotation) { + final List headerAnnotations = + convertColumnAnnotations(knowledgeBase, tableAnnotation); + Lists.zipWith(mergedHeaderAnnotations, headerAnnotations, + (first, second) -> first.merge(second)); + } + + private static Map convertCellRelations(KnowledgeBase knowledgeBase, TAnnotation original) { + Map cellCellRelations = new HashMap<>(); + for (Map.Entry>> columnAnnotations : original.getCellcellRelations().entrySet() ){ + for(Map.Entry> annotations : columnAnnotations.getValue().entrySet()){ + HashMap> candidates = new HashMap<>(); + HashMap> chosen = new HashMap<>(); + + Set candidatesSet = new HashSet<>(); + Set chosenSet = new HashSet<>(); + + candidates.put(knowledgeBase, candidatesSet); + chosen.put(knowledgeBase, chosenSet); + + EntityCandidate bestCandidate = null; + for (TCellCellRelationAnotation annotation : annotations.getValue()) { + Entity entity = new Entity(annotation.getRelationURI(), annotation.getRelationLabel()); + Likelihood likelihood = new Likelihood(annotation.getWinningAttributeMatchScore()); + + EntityCandidate candidate = new EntityCandidate(entity, likelihood); + + candidatesSet.add(candidate); + + if (bestCandidate == null || bestCandidate.getLikelihood().getValue() < candidate.getLikelihood().getValue()) { + bestCandidate = candidate; + } + } + + if (bestCandidate != null){ + chosenSet.add(bestCandidate); + } + + RelationColumns relationColumns = columnAnnotations.getKey(); + ColumnRelationPosition columnPosition = new ColumnRelationPosition(new ColumnPosition(relationColumns.getSubjectCol()), new ColumnPosition(relationColumns.getObjectCol())); + RowPosition rowPosition = new RowPosition(annotations.getKey()); + CellRelationPosition position = new CellRelationPosition(columnPosition, rowPosition); + CellRelationAnnotation relationAnnotation = new CellRelationAnnotation(candidates, chosen); + cellCellRelations.put(position, relationAnnotation); + } + } + return cellCellRelations; + } + + private static Map convertColumnRelations(KnowledgeBase knowledgeBase, TAnnotation original) { + Map columnRelations = new HashMap<>(); + for (Map.Entry> annotations : original.getColumncolumnRelations().entrySet() ){ + HashMap> candidates = new HashMap<>(); + HashMap> chosen = new HashMap<>(); + + Set candidatesSet = new HashSet<>(); + Set chosenSet = new HashSet<>(); + + candidates.put(knowledgeBase, candidatesSet); + chosen.put(knowledgeBase, chosenSet); + + EntityCandidate bestCandidate = null; + for (TColumnColumnRelationAnnotation annotation : annotations.getValue()) { + Entity entity = new Entity(annotation.getRelationURI(), annotation.getRelationLabel()); + Likelihood likelihood = new Likelihood(annotation.getFinalScore()); + + EntityCandidate candidate = new EntityCandidate(entity, likelihood); + + candidatesSet.add(candidate); + + if (bestCandidate == null || bestCandidate.getLikelihood().getValue() < candidate.getLikelihood().getValue()) { + bestCandidate = candidate; + } + } + + if (bestCandidate != null){ + chosenSet.add(bestCandidate); + } + + RelationColumns relationColumns = annotations.getKey(); + ColumnRelationPosition position = new ColumnRelationPosition(new ColumnPosition(relationColumns.getSubjectCol()), new ColumnPosition(relationColumns.getObjectCol())); + ColumnRelationAnnotation relationAnnotation = new ColumnRelationAnnotation(candidates, chosen); + columnRelations.put(position, relationAnnotation); + } + return columnRelations; + } + + private static CellAnnotation[][] convertCellAnnotations(KnowledgeBase knowledgeBase, TAnnotation original) { + int columnCount = original.getCols(); + int rowCount = original.getRows(); + CellAnnotation[][] cellAnnotations = new CellAnnotation[rowCount][columnCount]; + + for (int columnIndex = 0; columnIndex < columnCount; columnIndex++) { + for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) { + TCellAnnotation[] annotations = original.getContentCellAnnotations(rowIndex, columnIndex); + + HashMap> candidates = new HashMap<>(); + HashMap> chosen = new HashMap<>(); + + if (annotations != null) { + Set candidatesSet = new HashSet<>(); + Set chosenSet = new HashSet<>(); + + candidates.put(knowledgeBase, candidatesSet); + chosen.put(knowledgeBase, chosenSet); + + EntityCandidate bestCandidate = null; + for (TCellAnnotation annotation : annotations) { + uk.ac.shef.dcs.kbsearch.model.Entity clazz = annotation.getAnnotation(); + + Entity entity = new Entity(clazz.getId(), clazz.getLabel()); + Likelihood likelihood = new Likelihood(annotation.getFinalScore()); + + EntityCandidate candidate = new EntityCandidate(entity, likelihood); + + candidatesSet.add(candidate); + + if (bestCandidate == null || bestCandidate.getLikelihood().getValue() < candidate.getLikelihood().getValue()) { + bestCandidate = candidate; + } + } + + if (bestCandidate != null){ + chosenSet.add(bestCandidate); + } + } + + CellAnnotation cellAnnotation = new CellAnnotation(candidates, chosen); + cellAnnotations[rowIndex][columnIndex] = cellAnnotation; + } + } + + return cellAnnotations; + } + + private static List convertColumnAnnotations(KnowledgeBase knowledgeBase, TAnnotation original) { + int columnCount = original.getCols(); + List headerAnnotations = new ArrayList<>(columnCount); + + for (int columnIndex = 0; columnIndex < columnCount; columnIndex++) { + TColumnHeaderAnnotation[] annotations = original.getHeaderAnnotation(columnIndex); + + HashMap> candidates = new HashMap<>(); + HashMap> chosen = new HashMap<>(); + + if (annotations != null) { + Set candidatesSet = new HashSet<>(); + Set chosenSet = new HashSet<>(); + + candidates.put(knowledgeBase, candidatesSet); + chosen.put(knowledgeBase, chosenSet); + + EntityCandidate bestCandidate = null; + for (TColumnHeaderAnnotation annotation : annotations) { + Clazz clazz = annotation.getAnnotation(); + + Entity entity = new Entity(clazz.getId(), clazz.getLabel()); + Likelihood likelihood = new Likelihood(annotation.getFinalScore()); + + EntityCandidate candidate = new EntityCandidate(entity, likelihood); + + candidatesSet.add(candidate); + + if (bestCandidate == null || bestCandidate.getLikelihood().getValue() < candidate.getLikelihood().getValue()) { + bestCandidate = candidate; + } + } + + if (bestCandidate != null){ + chosenSet.add(bestCandidate); + } + } + + HeaderAnnotation headerAnnotation = new HeaderAnnotation(candidates, chosen); + headerAnnotations.add(headerAnnotation); + } + + return headerAnnotations; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/Result.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/Result.java index ade84f49..4f0b512f 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/Result.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/tasks/results/Result.java @@ -1,238 +1,238 @@ -package cz.cuni.mff.xrg.odalic.tasks.results; - -import java.io.Serializable; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import javax.annotation.Nullable; -import javax.annotation.concurrent.Immutable; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - -import cz.cuni.mff.xrg.odalic.api.rest.adapters.ResultAdapter; -import cz.cuni.mff.xrg.odalic.positions.CellRelationPosition; -import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; -import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; -import cz.cuni.mff.xrg.odalic.tasks.annotations.CellAnnotation; -import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; -import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; -import cz.cuni.mff.xrg.odalic.tasks.annotations.HeaderAnnotation; - -/** - *

- * This class represents a partial result of the table annotation process. - *

- * - *

- * It includes all the data necessary to produce the final triples and also serves as the base for - * user-defined hints to the annotating algorithm. - *

- * - *

- * Any benchmarking, debugging or temporary result data are not included. - *

- * - * @author Václav Brodec - * - */ -@Immutable -@XmlJavaTypeAdapter(ResultAdapter.class) -public class Result implements Serializable { - - private static final long serialVersionUID = -6359038623760039155L; - - private final ColumnPosition subjectColumnPosition; - - private final List headerAnnotations; - - private final CellAnnotation[][] cellAnnotations; - - private final Map columnRelationAnnotations; - - private final Map cellRelationAnnotations; - - /** - * Creates new annotation result representation. - * - * @param subjectColumnPosition suggested position of the subject column - * @param headerAnnotations suggested header annotations - * @param cellAnnotations suggested cell annotations - * @param columnRelationAnnotations suggested annotations for the relations between two columns - * @param cellRelationAnnotations suggested annotation for relations existing between two cells at - * the same row - */ - public Result(List headerAnnotations, - CellAnnotation[][] cellAnnotations, - Map columnRelationAnnotations, - Map cellRelationAnnotations) { - checkMandatory(headerAnnotations, cellAnnotations, columnRelationAnnotations, - cellRelationAnnotations); - - this.subjectColumnPosition = null; - this.headerAnnotations = ImmutableList.copyOf(headerAnnotations); - this.cellAnnotations = cz.cuni.mff.xrg.odalic.util.Arrays.deepCopy(CellAnnotation.class, cellAnnotations); - this.columnRelationAnnotations = ImmutableMap.copyOf(columnRelationAnnotations); - this.cellRelationAnnotations = ImmutableMap.copyOf(cellRelationAnnotations); - } - - private static void checkMandatory(List headerAnnotations, - CellAnnotation[][] cellAnnotations, - Map columnRelationAnnotations, - Map cellRelationAnnotations) { - - Preconditions.checkArgument(!cz.cuni.mff.xrg.odalic.util.Arrays.containsNull(cellAnnotations)); - Preconditions.checkArgument(cz.cuni.mff.xrg.odalic.util.Arrays.isMatrix(cellAnnotations)); - } - - /** - * @param subjectColumnPosition - * @param headerAnnotations - * @param cellAnnotations - * @param columnRelationAnnotations - * @param cellRelationAnnotations - */ - public Result(ColumnPosition subjectColumnPosition, - List headerAnnotations, - CellAnnotation[][] cellAnnotations, - Map columnRelationAnnotations, - Map cellRelationAnnotations) { - Preconditions.checkNotNull(subjectColumnPosition); - Preconditions.checkNotNull(headerAnnotations); - Preconditions.checkNotNull(cellAnnotations); - Preconditions.checkNotNull(columnRelationAnnotations); - Preconditions.checkNotNull(cellRelationAnnotations); - Preconditions.checkArgument(!cz.cuni.mff.xrg.odalic.util.Arrays.containsNull(cellAnnotations)); - Preconditions.checkArgument(cz.cuni.mff.xrg.odalic.util.Arrays.isMatrix(cellAnnotations)); - - this.subjectColumnPosition = subjectColumnPosition; - this.headerAnnotations = ImmutableList.copyOf(headerAnnotations); - this.cellAnnotations = - cz.cuni.mff.xrg.odalic.util.Arrays.deepCopy(CellAnnotation.class, cellAnnotations); - this.columnRelationAnnotations = ImmutableMap.copyOf(columnRelationAnnotations); - this.cellRelationAnnotations = ImmutableMap.copyOf(cellRelationAnnotations); - } - - /** - * @return the subject column position - */ - @Nullable - public ColumnPosition getSubjectColumnPosition() { - return subjectColumnPosition; - } - - /** - * @return the header annotations - */ - public List getHeaderAnnotations() { - return headerAnnotations; - } - - /** - * @return the cell annotations - */ - public CellAnnotation[][] getCellAnnotations() { - return cz.cuni.mff.xrg.odalic.util.Arrays.deepCopy(CellAnnotation.class, cellAnnotations); - } - - /** - * @return the column relation annotations - */ - public Map getColumnRelationAnnotations() { - return columnRelationAnnotations; - } - - /** - * @return the cell relation annotations - */ - public Map getCellRelationAnnotations() { - return cellRelationAnnotations; - } - - /** - * Computes hash code based on all its parts. - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Arrays.deepHashCode(cellAnnotations); - result = prime * result - + ((cellRelationAnnotations == null) ? 0 : cellRelationAnnotations.hashCode()); - result = prime * result - + ((columnRelationAnnotations == null) ? 0 : columnRelationAnnotations.hashCode()); - result = prime * result + ((headerAnnotations == null) ? 0 : headerAnnotations.hashCode()); - result = - prime * result + ((subjectColumnPosition == null) ? 0 : subjectColumnPosition.hashCode()); - return result; - } - - /** - * Compares to another object for equality (only another Result composed from equal parts passes). - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Result other = (Result) obj; - if (!Arrays.deepEquals(cellAnnotations, other.cellAnnotations)) { - return false; - } - if (cellRelationAnnotations == null) { - if (other.cellRelationAnnotations != null) { - return false; - } - } else if (!cellRelationAnnotations.equals(other.cellRelationAnnotations)) { - return false; - } - if (columnRelationAnnotations == null) { - if (other.columnRelationAnnotations != null) { - return false; - } - } else if (!columnRelationAnnotations.equals(other.columnRelationAnnotations)) { - return false; - } - if (headerAnnotations == null) { - if (other.headerAnnotations != null) { - return false; - } - } else if (!headerAnnotations.equals(other.headerAnnotations)) { - return false; - } - if (subjectColumnPosition == null) { - if (other.subjectColumnPosition != null) { - return false; - } - } else if (!subjectColumnPosition.equals(other.subjectColumnPosition)) { - return false; - } - return true; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "Result [subjectColumnPosition=" + subjectColumnPosition + ", headerAnnotations=" - + headerAnnotations + ", cellAnnotations=" + Arrays.deepToString(cellAnnotations) - + ", columnRelationAnnotations=" + columnRelationAnnotations + ", cellRelationAnnotations=" - + cellRelationAnnotations + "]"; - } -} +package cz.cuni.mff.xrg.odalic.tasks.results; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import javax.annotation.Nullable; +import javax.annotation.concurrent.Immutable; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; + +import cz.cuni.mff.xrg.odalic.api.rest.adapters.ResultAdapter; +import cz.cuni.mff.xrg.odalic.positions.CellRelationPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnPosition; +import cz.cuni.mff.xrg.odalic.positions.ColumnRelationPosition; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.CellRelationAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.ColumnRelationAnnotation; +import cz.cuni.mff.xrg.odalic.tasks.annotations.HeaderAnnotation; + +/** + *

+ * This class represents a partial result of the table annotation process. + *

+ * + *

+ * It includes all the data necessary to produce the final triples and also serves as the base for + * user-defined hints to the annotating algorithm. + *

+ * + *

+ * Any benchmarking, debugging or temporary result data are not included. + *

+ * + * @author Václav Brodec + * + */ +@Immutable +@XmlJavaTypeAdapter(ResultAdapter.class) +public class Result implements Serializable { + + private static final long serialVersionUID = -6359038623760039155L; + + private final ColumnPosition subjectColumnPosition; + + private final List headerAnnotations; + + private final CellAnnotation[][] cellAnnotations; + + private final Map columnRelationAnnotations; + + private final Map cellRelationAnnotations; + + /** + * Creates new annotation result representation. + * + * @param subjectColumnPosition suggested position of the subject column + * @param headerAnnotations suggested header annotations + * @param cellAnnotations suggested cell annotations + * @param columnRelationAnnotations suggested annotations for the relations between two columns + * @param cellRelationAnnotations suggested annotation for relations existing between two cells at + * the same row + */ + public Result(List headerAnnotations, + CellAnnotation[][] cellAnnotations, + Map columnRelationAnnotations, + Map cellRelationAnnotations) { + checkMandatory(headerAnnotations, cellAnnotations, columnRelationAnnotations, + cellRelationAnnotations); + + this.subjectColumnPosition = null; + this.headerAnnotations = ImmutableList.copyOf(headerAnnotations); + this.cellAnnotations = cz.cuni.mff.xrg.odalic.util.Arrays.deepCopy(CellAnnotation.class, cellAnnotations); + this.columnRelationAnnotations = ImmutableMap.copyOf(columnRelationAnnotations); + this.cellRelationAnnotations = ImmutableMap.copyOf(cellRelationAnnotations); + } + + private static void checkMandatory(List headerAnnotations, + CellAnnotation[][] cellAnnotations, + Map columnRelationAnnotations, + Map cellRelationAnnotations) { + + Preconditions.checkArgument(!cz.cuni.mff.xrg.odalic.util.Arrays.containsNull(cellAnnotations)); + Preconditions.checkArgument(cz.cuni.mff.xrg.odalic.util.Arrays.isMatrix(cellAnnotations)); + } + + /** + * @param subjectColumnPosition + * @param headerAnnotations + * @param cellAnnotations + * @param columnRelationAnnotations + * @param cellRelationAnnotations + */ + public Result(ColumnPosition subjectColumnPosition, + List headerAnnotations, + CellAnnotation[][] cellAnnotations, + Map columnRelationAnnotations, + Map cellRelationAnnotations) { + Preconditions.checkNotNull(subjectColumnPosition); + Preconditions.checkNotNull(headerAnnotations); + Preconditions.checkNotNull(cellAnnotations); + Preconditions.checkNotNull(columnRelationAnnotations); + Preconditions.checkNotNull(cellRelationAnnotations); + Preconditions.checkArgument(!cz.cuni.mff.xrg.odalic.util.Arrays.containsNull(cellAnnotations)); + Preconditions.checkArgument(cz.cuni.mff.xrg.odalic.util.Arrays.isMatrix(cellAnnotations)); + + this.subjectColumnPosition = subjectColumnPosition; + this.headerAnnotations = ImmutableList.copyOf(headerAnnotations); + this.cellAnnotations = + cz.cuni.mff.xrg.odalic.util.Arrays.deepCopy(CellAnnotation.class, cellAnnotations); + this.columnRelationAnnotations = ImmutableMap.copyOf(columnRelationAnnotations); + this.cellRelationAnnotations = ImmutableMap.copyOf(cellRelationAnnotations); + } + + /** + * @return the subject column position + */ + @Nullable + public ColumnPosition getSubjectColumnPosition() { + return subjectColumnPosition; + } + + /** + * @return the header annotations + */ + public List getHeaderAnnotations() { + return headerAnnotations; + } + + /** + * @return the cell annotations + */ + public CellAnnotation[][] getCellAnnotations() { + return cz.cuni.mff.xrg.odalic.util.Arrays.deepCopy(CellAnnotation.class, cellAnnotations); + } + + /** + * @return the column relation annotations + */ + public Map getColumnRelationAnnotations() { + return columnRelationAnnotations; + } + + /** + * @return the cell relation annotations + */ + public Map getCellRelationAnnotations() { + return cellRelationAnnotations; + } + + /** + * Computes hash code based on all its parts. + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + Arrays.deepHashCode(cellAnnotations); + result = prime * result + + ((cellRelationAnnotations == null) ? 0 : cellRelationAnnotations.hashCode()); + result = prime * result + + ((columnRelationAnnotations == null) ? 0 : columnRelationAnnotations.hashCode()); + result = prime * result + ((headerAnnotations == null) ? 0 : headerAnnotations.hashCode()); + result = + prime * result + ((subjectColumnPosition == null) ? 0 : subjectColumnPosition.hashCode()); + return result; + } + + /** + * Compares to another object for equality (only another Result composed from equal parts passes). + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Result other = (Result) obj; + if (!Arrays.deepEquals(cellAnnotations, other.cellAnnotations)) { + return false; + } + if (cellRelationAnnotations == null) { + if (other.cellRelationAnnotations != null) { + return false; + } + } else if (!cellRelationAnnotations.equals(other.cellRelationAnnotations)) { + return false; + } + if (columnRelationAnnotations == null) { + if (other.columnRelationAnnotations != null) { + return false; + } + } else if (!columnRelationAnnotations.equals(other.columnRelationAnnotations)) { + return false; + } + if (headerAnnotations == null) { + if (other.headerAnnotations != null) { + return false; + } + } else if (!headerAnnotations.equals(other.headerAnnotations)) { + return false; + } + if (subjectColumnPosition == null) { + if (other.subjectColumnPosition != null) { + return false; + } + } else if (!subjectColumnPosition.equals(other.subjectColumnPosition)) { + return false; + } + return true; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Result [subjectColumnPosition=" + subjectColumnPosition + ", headerAnnotations=" + + headerAnnotations + ", cellAnnotations=" + Arrays.deepToString(cellAnnotations) + + ", columnRelationAnnotations=" + columnRelationAnnotations + ", cellRelationAnnotations=" + + cellRelationAnnotations + "]"; + } +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/Arrays.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/Arrays.java index a0779f6c..d52548e3 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/Arrays.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/Arrays.java @@ -1,134 +1,134 @@ -package cz.cuni.mff.xrg.odalic.util; - -import java.lang.reflect.Array; -import java.util.function.BiFunction; - -import com.google.common.base.Preconditions; - -/** - * Utility class for -- you guessed it -- working with arrays. - * - * @author Václav Brodec - * - */ -public final class Arrays { - - /** - * We want to keep this class uninstantiable, so no visible constructor is available. - */ - private Arrays() {} - - /** - *

- * Checks for {@code null} every (array) element of the array and elements of the element array. - *

- * - *

- * Please note that the method does not expect the elements of the nested array to be also arrays - * (in other words: it does not go beyond the second dimension). - *

- * - * @param arrayOfArrays array of arrays - * @return true, if any element up to second dimension is null, false otherwise - * @throws NullPointerException If the arrayOfArrays itself is {@code null} - */ - public static boolean containsNull(Object[][] arrayOfArrays) throws NullPointerException { - for (int i = 0; i < arrayOfArrays.length; i++) { - if (arrayOfArrays[i] == null) { - return true; - } - - for (int j = 0; j < arrayOfArrays[i].length; j++) { - if (arrayOfArrays[i][j] == null) { - return true; - } - } - } - - return false; - } - - /** - *

- * Checks whether the array of arrays is a matrix (all the rows has the same number of cells). - *

- * - *

- * Please note that the method does not expect the elements of the nested array to be also arrays - * (in other words: it does not go beyond the second dimension). - *

- * - *

- * Also it accepts empty array of arrays and array of zero-length arrays as a valid matrix. - *

- * - * @param arrayOfArrays array of arrays - * @return true, if the array of arrays is a matrix (up to second dimension) - */ - public static boolean isMatrix(Object[][] arrayOfArrays) { - if (arrayOfArrays.length == 0) { - return true; - } - - final int columnsCount = arrayOfArrays[0].length; - for (int i = 1; i < arrayOfArrays.length; i++) { - if (arrayOfArrays[i].length != columnsCount) { - return false; - } - } - - return true; - } - - /** - * Creates a deep copy of a matrix (up to second dimension). - * - * @param type type of elements - * @param matrix the matrix - * @return deep copy of the matrix - * @throws IllegalArgumentException if either of dimensions of the matrix is zero, if the type of - * elements is Void.TYPE, or if the number of any dimension of the matrix exceeds 255. - * - * @param type of elements - */ - public static T[][] deepCopy(Class type, T[][] matrix) throws IllegalArgumentException { - final int rowsCount = matrix.length; - final int columnsCount = (rowsCount > 0) ? (matrix[0].length) : 0; - - @SuppressWarnings("unchecked") - T[][] copy = (T[][]) Array.newInstance(type, rowsCount, columnsCount); - for (int i = 0; i < rowsCount; i++) { - copy[i] = matrix[i].clone(); - } - - return copy; - } - - /** - * Executes functional zip over a two matrices, but modifies the first one in the process. - * - * @param modified the matrix whose elements serve as the first argument of the zip function and - * then are replaced by its result - * @param added matrix whose elements serve as the second argument of the zip function - * @param zipFunction zip function - * @throws IllegalArgumentException If the modified and added are not matrices or have different dimensions - * - * @param type of elements in modified - * @param type of elements in added - */ - public static void zipMatrixWith(T[][] modified, U[][] added, - BiFunction zipFunction) throws IllegalArgumentException { - Preconditions.checkArgument(modified.length != 0); - Preconditions.checkArgument(added.length == modified.length); - Preconditions.checkArgument(added[0].length == modified[0].length); - Preconditions.checkArgument(isMatrix(modified)); - Preconditions.checkArgument(isMatrix(added)); - - for (int i = 0; i < modified.length; i++) { - for (int j = 0; j < modified[0].length; j++) { - modified[i][j] = zipFunction.apply(modified[i][j], added[i][j]); - } - } - } - -} +package cz.cuni.mff.xrg.odalic.util; + +import java.lang.reflect.Array; +import java.util.function.BiFunction; + +import com.google.common.base.Preconditions; + +/** + * Utility class for -- you guessed it -- working with arrays. + * + * @author Václav Brodec + * + */ +public final class Arrays { + + /** + * We want to keep this class uninstantiable, so no visible constructor is available. + */ + private Arrays() {} + + /** + *

+ * Checks for {@code null} every (array) element of the array and elements of the element array. + *

+ * + *

+ * Please note that the method does not expect the elements of the nested array to be also arrays + * (in other words: it does not go beyond the second dimension). + *

+ * + * @param arrayOfArrays array of arrays + * @return true, if any element up to second dimension is null, false otherwise + * @throws NullPointerException If the arrayOfArrays itself is {@code null} + */ + public static boolean containsNull(Object[][] arrayOfArrays) throws NullPointerException { + for (int i = 0; i < arrayOfArrays.length; i++) { + if (arrayOfArrays[i] == null) { + return true; + } + + for (int j = 0; j < arrayOfArrays[i].length; j++) { + if (arrayOfArrays[i][j] == null) { + return true; + } + } + } + + return false; + } + + /** + *

+ * Checks whether the array of arrays is a matrix (all the rows has the same number of cells). + *

+ * + *

+ * Please note that the method does not expect the elements of the nested array to be also arrays + * (in other words: it does not go beyond the second dimension). + *

+ * + *

+ * Also it accepts empty array of arrays and array of zero-length arrays as a valid matrix. + *

+ * + * @param arrayOfArrays array of arrays + * @return true, if the array of arrays is a matrix (up to second dimension) + */ + public static boolean isMatrix(Object[][] arrayOfArrays) { + if (arrayOfArrays.length == 0) { + return true; + } + + final int columnsCount = arrayOfArrays[0].length; + for (int i = 1; i < arrayOfArrays.length; i++) { + if (arrayOfArrays[i].length != columnsCount) { + return false; + } + } + + return true; + } + + /** + * Creates a deep copy of a matrix (up to second dimension). + * + * @param type type of elements + * @param matrix the matrix + * @return deep copy of the matrix + * @throws IllegalArgumentException if either of dimensions of the matrix is zero, if the type of + * elements is Void.TYPE, or if the number of any dimension of the matrix exceeds 255. + * + * @param type of elements + */ + public static T[][] deepCopy(Class type, T[][] matrix) throws IllegalArgumentException { + final int rowsCount = matrix.length; + final int columnsCount = (rowsCount > 0) ? (matrix[0].length) : 0; + + @SuppressWarnings("unchecked") + T[][] copy = (T[][]) Array.newInstance(type, rowsCount, columnsCount); + for (int i = 0; i < rowsCount; i++) { + copy[i] = matrix[i].clone(); + } + + return copy; + } + + /** + * Executes functional zip over a two matrices, but modifies the first one in the process. + * + * @param modified the matrix whose elements serve as the first argument of the zip function and + * then are replaced by its result + * @param added matrix whose elements serve as the second argument of the zip function + * @param zipFunction zip function + * @throws IllegalArgumentException If the modified and added are not matrices or have different dimensions + * + * @param type of elements in modified + * @param type of elements in added + */ + public static void zipMatrixWith(T[][] modified, U[][] added, + BiFunction zipFunction) throws IllegalArgumentException { + Preconditions.checkArgument(modified.length != 0); + Preconditions.checkArgument(added.length == modified.length); + Preconditions.checkArgument(added[0].length == modified[0].length); + Preconditions.checkArgument(isMatrix(modified)); + Preconditions.checkArgument(isMatrix(added)); + + for (int i = 0; i < modified.length; i++) { + for (int j = 0; j < modified[0].length; j++) { + modified[i][j] = zipFunction.apply(modified[i][j], added[i][j]); + } + } + } + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/Lists.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/Lists.java index c2ea9535..c84becc4 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/Lists.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/Lists.java @@ -1,49 +1,49 @@ -package cz.cuni.mff.xrg.odalic.util; - -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import java.util.function.BiFunction; - -/** - * Utility class for -- you guessed it -- working with collections. - * - * @author Václav Brodec - * - */ -public final class Lists { - - /** - * We want to keep this class uninstantiable, so no visible constructor is available. - */ - private Lists() {} - - /** - * Executes functional zip over a list and a collection, but modifies the list in the process. - * - * @param modified the list whose elements serve as the first argument of the zip function and - * then are replaced by its result - * @param added collection whose elements serve as the second argument of the zip function - * @param zipFunction zip function - * @throws IllegalArgumentException If the modified and added have different number of elements - * @throws UnsupportedOperationException if the set operation is not supported by the list iterator - * - * @param type of elements in modified - * @param type of elements in added - */ - public static void zipWith(List modified, Collection added, - BiFunction zipFunction) throws IllegalArgumentException { - if (modified.size() != added.size()) { - throw new IllegalArgumentException(); - } - - final ListIterator listIterator = modified.listIterator(); - final Iterator iterator = added.iterator(); - while (listIterator.hasNext() && iterator.hasNext()) { - listIterator.set(zipFunction.apply(listIterator.next(), iterator.next())); - } - } - - -} +package cz.cuni.mff.xrg.odalic.util; + +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.function.BiFunction; + +/** + * Utility class for -- you guessed it -- working with collections. + * + * @author Václav Brodec + * + */ +public final class Lists { + + /** + * We want to keep this class uninstantiable, so no visible constructor is available. + */ + private Lists() {} + + /** + * Executes functional zip over a list and a collection, but modifies the list in the process. + * + * @param modified the list whose elements serve as the first argument of the zip function and + * then are replaced by its result + * @param added collection whose elements serve as the second argument of the zip function + * @param zipFunction zip function + * @throws IllegalArgumentException If the modified and added have different number of elements + * @throws UnsupportedOperationException if the set operation is not supported by the list iterator + * + * @param type of elements in modified + * @param type of elements in added + */ + public static void zipWith(List modified, Collection added, + BiFunction zipFunction) throws IllegalArgumentException { + if (modified.size() != added.size()) { + throw new IllegalArgumentException(); + } + + final ListIterator listIterator = modified.listIterator(); + final Iterator iterator = added.iterator(); + while (listIterator.hasNext() && iterator.hasNext()) { + listIterator.set(zipFunction.apply(listIterator.next(), iterator.next())); + } + } + + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/Maps.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/Maps.java index 4d996065..f43d025a 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/Maps.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/Maps.java @@ -1,48 +1,48 @@ -package cz.cuni.mff.xrg.odalic.util; - -import java.util.Map; -import java.util.function.BiFunction; - -/** - * Utility class for -- you guessed it -- working with maps. - * - * @author Václav Brodec - * - */ -public final class Maps { - - /** - * We want to keep this class uninstantiable, so no visible constructor is available. - */ - private Maps() {} - - /** - * Merges the added map into the modified one. If the key of the added entry is not found in the map, the entry is simply added. - * - * @param modified the map whose elements serve as the first argument of the merge function and - * then are replaced by its result - * @param added collection whose elements serve as the second argument of the merge function - * @param mergeFunction merge function - * - * @param type of keys - * @param type of values - */ - public static void mergeWith(Map modified, Map added, - BiFunction mergeFunction) throws IllegalArgumentException { - - for (Map.Entry addedEntry : added.entrySet()) { - final K key = addedEntry.getKey(); - - final V addedValue = addedEntry.getValue(); - final V modifiedValue = modified.get(key); - - if (modifiedValue == null) { - modified.put(key, addedValue); - } else { - modified.put(key, mergeFunction.apply(modifiedValue, addedValue)); - } - } - } - - -} +package cz.cuni.mff.xrg.odalic.util; + +import java.util.Map; +import java.util.function.BiFunction; + +/** + * Utility class for -- you guessed it -- working with maps. + * + * @author Václav Brodec + * + */ +public final class Maps { + + /** + * We want to keep this class uninstantiable, so no visible constructor is available. + */ + private Maps() {} + + /** + * Merges the added map into the modified one. If the key of the added entry is not found in the map, the entry is simply added. + * + * @param modified the map whose elements serve as the first argument of the merge function and + * then are replaced by its result + * @param added collection whose elements serve as the second argument of the merge function + * @param mergeFunction merge function + * + * @param type of keys + * @param type of values + */ + public static void mergeWith(Map modified, Map added, + BiFunction mergeFunction) throws IllegalArgumentException { + + for (Map.Entry addedEntry : added.entrySet()) { + final K key = addedEntry.getKey(); + + final V addedValue = addedEntry.getValue(); + final V modifiedValue = modified.get(key); + + if (modifiedValue == null) { + modified.put(key, addedValue); + } else { + modified.put(key, mergeFunction.apply(modifiedValue, addedValue)); + } + } + } + + +} diff --git a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/URL.java b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/URL.java index fd97dfd5..2afc83ef 100644 --- a/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/URL.java +++ b/odalic/src/main/java/cz/cuni/mff/xrg/odalic/util/URL.java @@ -1,45 +1,45 @@ -package cz.cuni.mff.xrg.odalic.util; - -import java.io.UnsupportedEncodingException; -import java.net.MalformedURLException; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; - -import javax.ws.rs.core.UriInfo; - -/** - * Utility class for -- you guessed it -- working with URLs. - * - * @author Václav Brodec - * - */ -public final class URL { - - /** - * We want to keep this class uninstantiable, so no visible constructor is available. - */ - private URL() {} - - /** - * One-off function that essentially takes the absolute path of the request URI (encapsulated by - * the {@link UriInfo} instance) and resolves the sub-resource name against it to get the absolute - * path of the sub-resource. - * - * @param requestUriInfo URI info - * @param subResource a string to resolve against the URI - * @return absolute path of the string - * @throws MalformedURLException If a protocol handler for the URL could not be found, or if some - * other error occurred while constructing the URL - * @throws IllegalStateException If called outside a scope of a request - * @throws IllegalArgumentException If the given string violates RFC 2396 - */ - public static java.net.URL getSubResourceAbsolutePath(UriInfo requestUriInfo, String subResource) - throws MalformedURLException, IllegalStateException { - try { - return requestUriInfo.getAbsolutePath() - .resolve(URLEncoder.encode(subResource, StandardCharsets.UTF_8.displayName())).toURL(); - } catch (UnsupportedEncodingException e) { - throw new AssertionError(e); - } - } -} +package cz.cuni.mff.xrg.odalic.util; + +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; + +import javax.ws.rs.core.UriInfo; + +/** + * Utility class for -- you guessed it -- working with URLs. + * + * @author Václav Brodec + * + */ +public final class URL { + + /** + * We want to keep this class uninstantiable, so no visible constructor is available. + */ + private URL() {} + + /** + * One-off function that essentially takes the absolute path of the request URI (encapsulated by + * the {@link UriInfo} instance) and resolves the sub-resource name against it to get the absolute + * path of the sub-resource. + * + * @param requestUriInfo URI info + * @param subResource a string to resolve against the URI + * @return absolute path of the string + * @throws MalformedURLException If a protocol handler for the URL could not be found, or if some + * other error occurred while constructing the URL + * @throws IllegalStateException If called outside a scope of a request + * @throws IllegalArgumentException If the given string violates RFC 2396 + */ + public static java.net.URL getSubResourceAbsolutePath(UriInfo requestUriInfo, String subResource) + throws MalformedURLException, IllegalStateException { + try { + return requestUriInfo.getAbsolutePath() + .resolve(URLEncoder.encode(subResource, StandardCharsets.UTF_8.displayName())).toURL(); + } catch (UnsupportedEncodingException e) { + throw new AssertionError(e); + } + } +} diff --git a/odalic/src/main/resources/logback.xml b/odalic/src/main/resources/logback.xml index 671d8e1a..b5209872 100644 --- a/odalic/src/main/resources/logback.xml +++ b/odalic/src/main/resources/logback.xml @@ -1,23 +1,23 @@ - - - - - - .%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg %n - - - - TRACE - - - - - - - - - - - - + + + + + + .%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg %n + + + + TRACE + + + + + + + + + + + + \ No newline at end of file diff --git a/odalic/src/main/resources/spring/applicationContext.xml b/odalic/src/main/resources/spring/applicationContext.xml index 2b8f251c..6552f903 100644 --- a/odalic/src/main/resources/spring/applicationContext.xml +++ b/odalic/src/main/resources/spring/applicationContext.xml @@ -1,51 +1,51 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/odalic/src/main/webapp/WEB-INF/web.xml b/odalic/src/main/webapp/WEB-INF/web.xml index f935adc4..eb59fd10 100644 --- a/odalic/src/main/webapp/WEB-INF/web.xml +++ b/odalic/src/main/webapp/WEB-INF/web.xml @@ -1,38 +1,38 @@ - - - Odalic - - - - org.springframework.web.context.ContextLoaderListener - - - - - contextConfigLocation - classpath:spring/applicationContext.xml - - - - jersey-servlet - - org.glassfish.jersey.servlet.ServletContainer - - - com.sun.jersey.api.json.POJOMappingFeature - true - - - javax.ws.rs.Application - cz.cuni.mff.xrg.odalic.api.rest.Configuration - - 1 - - - - jersey-servlet - /* - + + + Odalic + + + + org.springframework.web.context.ContextLoaderListener + + + + + contextConfigLocation + classpath:spring/applicationContext.xml + + + + jersey-servlet + + org.glassfish.jersey.servlet.ServletContainer + + + com.sun.jersey.api.json.POJOMappingFeature + true + + + javax.ws.rs.Application + cz.cuni.mff.xrg.odalic.api.rest.Configuration + + 1 + + + + jersey-servlet + /* + \ No newline at end of file diff --git a/odalic/src/test/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterExecutionBatch.java b/odalic/src/test/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterExecutionBatch.java index 4adaa2ae..2e10899e 100644 --- a/odalic/src/test/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterExecutionBatch.java +++ b/odalic/src/test/java/cz/cuni/mff/xrg/odalic/tasks/executions/InterpreterExecutionBatch.java @@ -1,77 +1,77 @@ -package cz.cuni.mff.xrg.odalic.tasks.executions; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.Arrays; -import java.util.List; - -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; - -import cz.cuni.mff.xrg.odalic.input.CsvConfiguration; -import cz.cuni.mff.xrg.odalic.input.DefaultCsvInputParser; -import cz.cuni.mff.xrg.odalic.input.DefaultInputToTableAdapter; -import cz.cuni.mff.xrg.odalic.input.Input; -import cz.cuni.mff.xrg.odalic.input.ListsBackedInputBuilder; -import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; -import cz.cuni.mff.xrg.odalic.tasks.results.DefaultAnnotationToResultAdapter; -import cz.cuni.mff.xrg.odalic.tasks.results.Result; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.algorithm.SemanticTableInterpreter; -import uk.ac.shef.dcs.sti.core.model.TAnnotation; -import uk.ac.shef.dcs.sti.core.model.Table; - -public class InterpreterExecutionBatch { - - /** - * Expects sti.properties file path as the first and test file directory path as the second - * command line argument - * - * @param args command line arguments - * - * @author Josef Janoušek - * @author Jan Váňa - * @throws IOException - */ - public static void main(String[] args) throws IOException { - final String propertyFilePath = args[0]; - final String testFileDirectoryPath = args[1]; - - final SemanticTableInterpreterFactory factory = new TableMinerPlusFactory(propertyFilePath); - final SemanticTableInterpreter semanticTableInterpreter = factory.getInterpreter(); - Preconditions.checkNotNull(semanticTableInterpreter); - - factory.setColumnIgnoresForInterpreter(ImmutableSet.of()); - - final List all = Arrays.asList(new File(testFileDirectoryPath).listFiles()); - final File inputFile = all.get(0); - - // Code for extraction from CSV - try (final FileInputStream inputFileStream = new FileInputStream(inputFile)) { - final Input input = new DefaultCsvInputParser(new ListsBackedInputBuilder()) - .parse(inputFileStream, inputFile.getName(), new CsvConfiguration()); - final Table table = new DefaultInputToTableAdapter().toTable(input); - - final TAnnotation annotationResult; - try { - annotationResult = semanticTableInterpreter.start(table, true); - - System.out.println("Result - OK:"); - System.out.println(annotationResult.toString()); - - DefaultAnnotationToResultAdapter adapter = new DefaultAnnotationToResultAdapter(); - Result odalicResult = - adapter.toResult(ImmutableMap.of(new KnowledgeBase("DBpedia"), annotationResult)); - - System.out.println(odalicResult.toString()); - } catch (STIException e) { - System.out.println("Result - Error:"); - e.printStackTrace(); - } - System.out.println("End of result."); - } - } - -} +package cz.cuni.mff.xrg.odalic.tasks.executions; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; + +import cz.cuni.mff.xrg.odalic.input.CsvConfiguration; +import cz.cuni.mff.xrg.odalic.input.DefaultCsvInputParser; +import cz.cuni.mff.xrg.odalic.input.DefaultInputToTableAdapter; +import cz.cuni.mff.xrg.odalic.input.Input; +import cz.cuni.mff.xrg.odalic.input.ListsBackedInputBuilder; +import cz.cuni.mff.xrg.odalic.tasks.annotations.KnowledgeBase; +import cz.cuni.mff.xrg.odalic.tasks.results.DefaultAnnotationToResultAdapter; +import cz.cuni.mff.xrg.odalic.tasks.results.Result; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.algorithm.SemanticTableInterpreter; +import uk.ac.shef.dcs.sti.core.model.TAnnotation; +import uk.ac.shef.dcs.sti.core.model.Table; + +public class InterpreterExecutionBatch { + + /** + * Expects sti.properties file path as the first and test file directory path as the second + * command line argument + * + * @param args command line arguments + * + * @author Josef Janoušek + * @author Jan Váňa + * @throws IOException + */ + public static void main(String[] args) throws IOException { + final String propertyFilePath = args[0]; + final String testFileDirectoryPath = args[1]; + + final SemanticTableInterpreterFactory factory = new TableMinerPlusFactory(propertyFilePath); + final SemanticTableInterpreter semanticTableInterpreter = factory.getInterpreter(); + Preconditions.checkNotNull(semanticTableInterpreter); + + factory.setColumnIgnoresForInterpreter(ImmutableSet.of()); + + final List all = Arrays.asList(new File(testFileDirectoryPath).listFiles()); + final File inputFile = all.get(0); + + // Code for extraction from CSV + try (final FileInputStream inputFileStream = new FileInputStream(inputFile)) { + final Input input = new DefaultCsvInputParser(new ListsBackedInputBuilder()) + .parse(inputFileStream, inputFile.getName(), new CsvConfiguration()); + final Table table = new DefaultInputToTableAdapter().toTable(input); + + final TAnnotation annotationResult; + try { + annotationResult = semanticTableInterpreter.start(table, true); + + System.out.println("Result - OK:"); + System.out.println(annotationResult.toString()); + + DefaultAnnotationToResultAdapter adapter = new DefaultAnnotationToResultAdapter(); + Result odalicResult = + adapter.toResult(ImmutableMap.of(new KnowledgeBase("DBpedia"), annotationResult)); + + System.out.println(odalicResult.toString()); + } catch (STIException e) { + System.out.println("Result - Error:"); + e.printStackTrace(); + } + System.out.println("End of result."); + } + } + +} diff --git a/pom.xml b/pom.xml index 0b2b8b16..aa9fb8e8 100644 --- a/pom.xml +++ b/pom.xml @@ -1,19 +1,19 @@ - - 4.0.0 - cz.cuni.mff.xrg.odalic - odalic-sti - 0.0.1-SNAPSHOT - pom - Odalic STI - Odalic Semantic Table Interpreter - - - sti-common-util - sti-any23 - sti-kbsearch - sti-websearch - sti-main - odalic - - + + 4.0.0 + cz.cuni.mff.xrg.odalic + odalic-sti + 0.0.1-SNAPSHOT + pom + Odalic STI + Odalic Semantic Table Interpreter + + + sti-common-util + sti-any23 + sti-kbsearch + sti-websearch + sti-main + odalic + + diff --git a/resources/cache/empty/class/conf/currency.xml b/resources/cache/empty/class/conf/currency.xml index 5c6cfaf0..3a9c58af 100644 --- a/resources/cache/empty/class/conf/currency.xml +++ b/resources/cache/empty/class/conf/currency.xml @@ -1,67 +1,67 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/cache/empty/class/conf/elevate.xml b/resources/cache/empty/class/conf/elevate.xml index e4769ccf..25d5cebe 100644 --- a/resources/cache/empty/class/conf/elevate.xml +++ b/resources/cache/empty/class/conf/elevate.xml @@ -1,38 +1,38 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/resources/cache/empty/class/conf/lang/contractions_ca.txt b/resources/cache/empty/class/conf/lang/contractions_ca.txt index 116644f2..307a85f9 100644 --- a/resources/cache/empty/class/conf/lang/contractions_ca.txt +++ b/resources/cache/empty/class/conf/lang/contractions_ca.txt @@ -1,8 +1,8 @@ -# Set of Catalan contractions for ElisionFilter -# TODO: load this as a resource from the analyzer and sync it in build.xml -d -l -m -n -s -t +# Set of Catalan contractions for ElisionFilter +# TODO: load this as a resource from the analyzer and sync it in build.xml +d +l +m +n +s +t diff --git a/resources/cache/empty/class/conf/lang/contractions_fr.txt b/resources/cache/empty/class/conf/lang/contractions_fr.txt index 6de73c27..f1bba51b 100644 --- a/resources/cache/empty/class/conf/lang/contractions_fr.txt +++ b/resources/cache/empty/class/conf/lang/contractions_fr.txt @@ -1,15 +1,15 @@ -# Set of French contractions for ElisionFilter -# TODO: load this as a resource from the analyzer and sync it in build.xml -l -m -t -qu -n -s -j -d -c -jusqu -quoiqu -lorsqu -puisqu +# Set of French contractions for ElisionFilter +# TODO: load this as a resource from the analyzer and sync it in build.xml +l +m +t +qu +n +s +j +d +c +jusqu +quoiqu +lorsqu +puisqu diff --git a/resources/cache/empty/class/conf/lang/contractions_ga.txt b/resources/cache/empty/class/conf/lang/contractions_ga.txt index 849b0c6e..9ebe7fa3 100644 --- a/resources/cache/empty/class/conf/lang/contractions_ga.txt +++ b/resources/cache/empty/class/conf/lang/contractions_ga.txt @@ -1,5 +1,5 @@ -# Set of Irish contractions for ElisionFilter -# TODO: load this as a resource from the analyzer and sync it in build.xml -d -m -b +# Set of Irish contractions for ElisionFilter +# TODO: load this as a resource from the analyzer and sync it in build.xml +d +m +b diff --git a/resources/cache/empty/class/conf/lang/contractions_it.txt b/resources/cache/empty/class/conf/lang/contractions_it.txt index 790b5af4..cac04095 100644 --- a/resources/cache/empty/class/conf/lang/contractions_it.txt +++ b/resources/cache/empty/class/conf/lang/contractions_it.txt @@ -1,23 +1,23 @@ -# Set of Italian contractions for ElisionFilter -# TODO: load this as a resource from the analyzer and sync it in build.xml -c -l -all -dall -dell -nell -sull -coll -pell -gl -agl -dagl -degl -negl -sugl -un -m -t -s -v -d +# Set of Italian contractions for ElisionFilter +# TODO: load this as a resource from the analyzer and sync it in build.xml +c +l +all +dall +dell +nell +sull +coll +pell +gl +agl +dagl +degl +negl +sugl +un +m +t +s +v +d diff --git a/resources/cache/empty/class/conf/lang/hyphenations_ga.txt b/resources/cache/empty/class/conf/lang/hyphenations_ga.txt index fce41006..4d2642cc 100644 --- a/resources/cache/empty/class/conf/lang/hyphenations_ga.txt +++ b/resources/cache/empty/class/conf/lang/hyphenations_ga.txt @@ -1,5 +1,5 @@ -# Set of Irish hyphenations for StopFilter -# TODO: load this as a resource from the analyzer and sync it in build.xml -h -n -t +# Set of Irish hyphenations for StopFilter +# TODO: load this as a resource from the analyzer and sync it in build.xml +h +n +t diff --git a/resources/cache/empty/class/conf/lang/stemdict_nl.txt b/resources/cache/empty/class/conf/lang/stemdict_nl.txt index 01dd3bb8..44107297 100644 --- a/resources/cache/empty/class/conf/lang/stemdict_nl.txt +++ b/resources/cache/empty/class/conf/lang/stemdict_nl.txt @@ -1,6 +1,6 @@ -# Set of overrides for the dutch stemmer -# TODO: load this as a resource from the analyzer and sync it in build.xml -fiets fiets -bromfiets bromfiets -ei eier -kind kinder +# Set of overrides for the dutch stemmer +# TODO: load this as a resource from the analyzer and sync it in build.xml +fiets fiets +bromfiets bromfiets +ei eier +kind kinder diff --git a/resources/cache/empty/class/conf/lang/stoptags_ja.txt b/resources/cache/empty/class/conf/lang/stoptags_ja.txt index 2faf2a68..71b75084 100644 --- a/resources/cache/empty/class/conf/lang/stoptags_ja.txt +++ b/resources/cache/empty/class/conf/lang/stoptags_ja.txt @@ -1,420 +1,420 @@ -# -# This file defines a Japanese stoptag set for JapanesePartOfSpeechStopFilter. -# -# Any token with a part-of-speech tag that exactly matches those defined in this -# file are removed from the token stream. -# -# Set your own stoptags by uncommenting the lines below. Note that comments are -# not allowed on the same line as a stoptag. See LUCENE-3745 for frequency lists, -# etc. that can be useful for building you own stoptag set. -# -# The entire possible tagset is provided below for convenience. -# -##### -# noun: unclassified nouns -#名詞 -# -# noun-common: Common nouns or nouns where the sub-classification is undefined -#名詞-一般 -# -# noun-proper: Proper nouns where the sub-classification is undefined -#名詞-固有名詞 -# -# noun-proper-misc: miscellaneous proper nouns -#名詞-固有名詞-一般 -# -# noun-proper-person: Personal names where the sub-classification is undefined -#名詞-固有名詞-人名 -# -# noun-proper-person-misc: names that cannot be divided into surname and -# given name; foreign names; names where the surname or given name is unknown. -# e.g. お市の方 -#名詞-固有名詞-人名-一般 -# -# noun-proper-person-surname: Mainly Japanese surnames. -# e.g. 山田 -#名詞-固有名詞-人名-姓 -# -# noun-proper-person-given_name: Mainly Japanese given names. -# e.g. 太郎 -#名詞-固有名詞-人名-名 -# -# noun-proper-organization: Names representing organizations. -# e.g. 通産省, NHK -#名詞-固有名詞-組織 -# -# noun-proper-place: Place names where the sub-classification is undefined -#名詞-固有名詞-地域 -# -# noun-proper-place-misc: Place names excluding countries. -# e.g. アジア, バルセロナ, 京都 -#名詞-固有名詞-地域-一般 -# -# noun-proper-place-country: Country names. -# e.g. 日本, オーストラリア -#名詞-固有名詞-地域-国 -# -# noun-pronoun: Pronouns where the sub-classification is undefined -#名詞-代名詞 -# -# noun-pronoun-misc: miscellaneous pronouns: -# e.g. それ, ここ, あいつ, あなた, あちこち, いくつ, どこか, なに, みなさん, みんな, わたくし, われわれ -#名詞-代名詞-一般 -# -# noun-pronoun-contraction: Spoken language contraction made by combining a -# pronoun and the particle 'wa'. -# e.g. ありゃ, こりゃ, こりゃあ, そりゃ, そりゃあ -#名詞-代名詞-縮約 -# -# noun-adverbial: Temporal nouns such as names of days or months that behave -# like adverbs. Nouns that represent amount or ratios and can be used adverbially, -# e.g. 金曜, 一月, 午後, 少量 -#名詞-副詞可能 -# -# noun-verbal: Nouns that take arguments with case and can appear followed by -# 'suru' and related verbs (する, できる, なさる, くださる) -# e.g. インプット, 愛着, 悪化, 悪戦苦闘, 一安心, 下取り -#名詞-サ変接続 -# -# noun-adjective-base: The base form of adjectives, words that appear before な ("na") -# e.g. 健康, 安易, 駄目, だめ -#名詞-形容動詞語幹 -# -# noun-numeric: Arabic numbers, Chinese numerals, and counters like 何 (回), 数. -# e.g. 0, 1, 2, 何, 数, 幾 -#名詞-数 -# -# noun-affix: noun affixes where the sub-classification is undefined -#名詞-非自立 -# -# noun-affix-misc: Of adnominalizers, the case-marker の ("no"), and words that -# attach to the base form of inflectional words, words that cannot be classified -# into any of the other categories below. This category includes indefinite nouns. -# e.g. あかつき, 暁, かい, 甲斐, 気, きらい, 嫌い, くせ, 癖, こと, 事, ごと, 毎, しだい, 次第, -# 順, せい, 所為, ついで, 序で, つもり, 積もり, 点, どころ, の, はず, 筈, はずみ, 弾み, -# 拍子, ふう, ふり, 振り, ほう, 方, 旨, もの, 物, 者, ゆえ, 故, ゆえん, 所以, わけ, 訳, -# わり, 割り, 割, ん-口語/, もん-口語/ -#名詞-非自立-一般 -# -# noun-affix-adverbial: noun affixes that that can behave as adverbs. -# e.g. あいだ, 間, あげく, 挙げ句, あと, 後, 余り, 以外, 以降, 以後, 以上, 以前, 一方, うえ, -# 上, うち, 内, おり, 折り, かぎり, 限り, きり, っきり, 結果, ころ, 頃, さい, 際, 最中, さなか, -# 最中, じたい, 自体, たび, 度, ため, 為, つど, 都度, とおり, 通り, とき, 時, ところ, 所, -# とたん, 途端, なか, 中, のち, 後, ばあい, 場合, 日, ぶん, 分, ほか, 他, まえ, 前, まま, -# 儘, 侭, みぎり, 矢先 -#名詞-非自立-副詞可能 -# -# noun-affix-aux: noun affixes treated as 助動詞 ("auxiliary verb") in school grammars -# with the stem よう(だ) ("you(da)"). -# e.g. よう, やう, 様 (よう) -#名詞-非自立-助動詞語幹 -# -# noun-affix-adjective-base: noun affixes that can connect to the indeclinable -# connection form な (aux "da"). -# e.g. みたい, ふう -#名詞-非自立-形容動詞語幹 -# -# noun-special: special nouns where the sub-classification is undefined. -#名詞-特殊 -# -# noun-special-aux: The そうだ ("souda") stem form that is used for reporting news, is -# treated as 助動詞 ("auxiliary verb") in school grammars, and attach to the base -# form of inflectional words. -# e.g. そう -#名詞-特殊-助動詞語幹 -# -# noun-suffix: noun suffixes where the sub-classification is undefined. -#名詞-接尾 -# -# noun-suffix-misc: Of the nouns or stem forms of other parts of speech that connect -# to ガル or タイ and can combine into compound nouns, words that cannot be classified into -# any of the other categories below. In general, this category is more inclusive than -# 接尾語 ("suffix") and is usually the last element in a compound noun. -# e.g. おき, かた, 方, 甲斐 (がい), がかり, ぎみ, 気味, ぐるみ, (~した) さ, 次第, 済 (ず) み, -# よう, (でき)っこ, 感, 観, 性, 学, 類, 面, 用 -#名詞-接尾-一般 -# -# noun-suffix-person: Suffixes that form nouns and attach to person names more often -# than other nouns. -# e.g. 君, 様, 著 -#名詞-接尾-人名 -# -# noun-suffix-place: Suffixes that form nouns and attach to place names more often -# than other nouns. -# e.g. 町, 市, 県 -#名詞-接尾-地域 -# -# noun-suffix-verbal: Of the suffixes that attach to nouns and form nouns, those that -# can appear before スル ("suru"). -# e.g. 化, 視, 分け, 入り, 落ち, 買い -#名詞-接尾-サ変接続 -# -# noun-suffix-aux: The stem form of そうだ (様態) that is used to indicate conditions, -# is treated as 助動詞 ("auxiliary verb") in school grammars, and attach to the -# conjunctive form of inflectional words. -# e.g. そう -#名詞-接尾-助動詞語幹 -# -# noun-suffix-adjective-base: Suffixes that attach to other nouns or the conjunctive -# form of inflectional words and appear before the copula だ ("da"). -# e.g. 的, げ, がち -#名詞-接尾-形容動詞語幹 -# -# noun-suffix-adverbial: Suffixes that attach to other nouns and can behave as adverbs. -# e.g. 後 (ご), 以後, 以降, 以前, 前後, 中, 末, 上, 時 (じ) -#名詞-接尾-副詞可能 -# -# noun-suffix-classifier: Suffixes that attach to numbers and form nouns. This category -# is more inclusive than 助数詞 ("classifier") and includes common nouns that attach -# to numbers. -# e.g. 個, つ, 本, 冊, パーセント, cm, kg, カ月, か国, 区画, 時間, 時半 -#名詞-接尾-助数詞 -# -# noun-suffix-special: Special suffixes that mainly attach to inflecting words. -# e.g. (楽し) さ, (考え) 方 -#名詞-接尾-特殊 -# -# noun-suffix-conjunctive: Nouns that behave like conjunctions and join two words -# together. -# e.g. (日本) 対 (アメリカ), 対 (アメリカ), (3) 対 (5), (女優) 兼 (主婦) -#名詞-接続詞的 -# -# noun-verbal_aux: Nouns that attach to the conjunctive particle て ("te") and are -# semantically verb-like. -# e.g. ごらん, ご覧, 御覧, 頂戴 -#名詞-動詞非自立的 -# -# noun-quotation: text that cannot be segmented into words, proverbs, Chinese poetry, -# dialects, English, etc. Currently, the only entry for 名詞 引用文字列 ("noun quotation") -# is いわく ("iwaku"). -#名詞-引用文字列 -# -# noun-nai_adjective: Words that appear before the auxiliary verb ない ("nai") and -# behave like an adjective. -# e.g. 申し訳, 仕方, とんでも, 違い -#名詞-ナイ形容詞語幹 -# -##### -# prefix: unclassified prefixes -#接頭詞 -# -# prefix-nominal: Prefixes that attach to nouns (including adjective stem forms) -# excluding numerical expressions. -# e.g. お (水), 某 (氏), 同 (社), 故 (~氏), 高 (品質), お (見事), ご (立派) -#接頭詞-名詞接続 -# -# prefix-verbal: Prefixes that attach to the imperative form of a verb or a verb -# in conjunctive form followed by なる/なさる/くださる. -# e.g. お (読みなさい), お (座り) -#接頭詞-動詞接続 -# -# prefix-adjectival: Prefixes that attach to adjectives. -# e.g. お (寒いですねえ), バカ (でかい) -#接頭詞-形容詞接続 -# -# prefix-numerical: Prefixes that attach to numerical expressions. -# e.g. 約, およそ, 毎時 -#接頭詞-数接続 -# -##### -# verb: unclassified verbs -#動詞 -# -# verb-main: -#動詞-自立 -# -# verb-auxiliary: -#動詞-非自立 -# -# verb-suffix: -#動詞-接尾 -# -##### -# adjective: unclassified adjectives -#形容詞 -# -# adjective-main: -#形容詞-自立 -# -# adjective-auxiliary: -#形容詞-非自立 -# -# adjective-suffix: -#形容詞-接尾 -# -##### -# adverb: unclassified adverbs -#副詞 -# -# adverb-misc: Words that can be segmented into one unit and where adnominal -# modification is not possible. -# e.g. あいかわらず, 多分 -#副詞-一般 -# -# adverb-particle_conjunction: Adverbs that can be followed by の, は, に, -# な, する, だ, etc. -# e.g. こんなに, そんなに, あんなに, なにか, なんでも -#副詞-助詞類接続 -# -##### -# adnominal: Words that only have noun-modifying forms. -# e.g. この, その, あの, どの, いわゆる, なんらかの, 何らかの, いろんな, こういう, そういう, ああいう, -# どういう, こんな, そんな, あんな, どんな, 大きな, 小さな, おかしな, ほんの, たいした, -# 「(, も) さる (ことながら)」, 微々たる, 堂々たる, 単なる, いかなる, 我が」「同じ, 亡き -#連体詞 -# -##### -# conjunction: Conjunctions that can occur independently. -# e.g. が, けれども, そして, じゃあ, それどころか -接続詞 -# -##### -# particle: unclassified particles. -助詞 -# -# particle-case: case particles where the subclassification is undefined. -助詞-格助詞 -# -# particle-case-misc: Case particles. -# e.g. から, が, で, と, に, へ, より, を, の, にて -助詞-格助詞-一般 -# -# particle-case-quote: the "to" that appears after nouns, a person’s speech, -# quotation marks, expressions of decisions from a meeting, reasons, judgements, -# conjectures, etc. -# e.g. ( だ) と (述べた.), ( である) と (して執行猶予...) -助詞-格助詞-引用 -# -# particle-case-compound: Compounds of particles and verbs that mainly behave -# like case particles. -# e.g. という, といった, とかいう, として, とともに, と共に, でもって, にあたって, に当たって, に当って, -# にあたり, に当たり, に当り, に当たる, にあたる, において, に於いて,に於て, における, に於ける, -# にかけ, にかけて, にかんし, に関し, にかんして, に関して, にかんする, に関する, に際し, -# に際して, にしたがい, に従い, に従う, にしたがって, に従って, にたいし, に対し, にたいして, -# に対して, にたいする, に対する, について, につき, につけ, につけて, につれ, につれて, にとって, -# にとり, にまつわる, によって, に依って, に因って, により, に依り, に因り, による, に依る, に因る, -# にわたって, にわたる, をもって, を以って, を通じ, を通じて, を通して, をめぐって, をめぐり, をめぐる, -# って-口語/, ちゅう-関西弁「という」/, (何) ていう (人)-口語/, っていう-口語/, といふ, とかいふ -助詞-格助詞-連語 -# -# particle-conjunctive: -# e.g. から, からには, が, けれど, けれども, けど, し, つつ, て, で, と, ところが, どころか, とも, ども, -# ながら, なり, ので, のに, ば, ものの, や ( した), やいなや, (ころん) じゃ(いけない)-口語/, -# (行っ) ちゃ(いけない)-口語/, (言っ) たって (しかたがない)-口語/, (それがなく)ったって (平気)-口語/ -助詞-接続助詞 -# -# particle-dependency: -# e.g. こそ, さえ, しか, すら, は, も, ぞ -助詞-係助詞 -# -# particle-adverbial: -# e.g. がてら, かも, くらい, 位, ぐらい, しも, (学校) じゃ(これが流行っている)-口語/, -# (それ)じゃあ (よくない)-口語/, ずつ, (私) なぞ, など, (私) なり (に), (先生) なんか (大嫌い)-口語/, -# (私) なんぞ, (先生) なんて (大嫌い)-口語/, のみ, だけ, (私) だって-口語/, だに, -# (彼)ったら-口語/, (お茶) でも (いかが), 等 (とう), (今後) とも, ばかり, ばっか-口語/, ばっかり-口語/, -# ほど, 程, まで, 迄, (誰) も (が)([助詞-格助詞] および [助詞-係助詞] の前に位置する「も」) -助詞-副助詞 -# -# particle-interjective: particles with interjective grammatical roles. -# e.g. (松島) や -助詞-間投助詞 -# -# particle-coordinate: -# e.g. と, たり, だの, だり, とか, なり, や, やら -助詞-並立助詞 -# -# particle-final: -# e.g. かい, かしら, さ, ぜ, (だ)っけ-口語/, (とまってる) で-方言/, な, ナ, なあ-口語/, ぞ, ね, ネ, -# ねぇ-口語/, ねえ-口語/, ねん-方言/, の, のう-口語/, や, よ, ヨ, よぉ-口語/, わ, わい-口語/ -助詞-終助詞 -# -# particle-adverbial/conjunctive/final: The particle "ka" when unknown whether it is -# adverbial, conjunctive, or sentence final. For example: -# (a) 「A か B か」. Ex:「(国内で運用する) か,(海外で運用する) か (.)」 -# (b) Inside an adverb phrase. Ex:「(幸いという) か (, 死者はいなかった.)」 -# 「(祈りが届いたせい) か (, 試験に合格した.)」 -# (c) 「かのように」. Ex:「(何もなかった) か (のように振る舞った.)」 -# e.g. か -助詞-副助詞/並立助詞/終助詞 -# -# particle-adnominalizer: The "no" that attaches to nouns and modifies -# non-inflectional words. -助詞-連体化 -# -# particle-adnominalizer: The "ni" and "to" that appear following nouns and adverbs -# that are giongo, giseigo, or gitaigo. -# e.g. に, と -助詞-副詞化 -# -# particle-special: A particle that does not fit into one of the above classifications. -# This includes particles that are used in Tanka, Haiku, and other poetry. -# e.g. かな, けむ, ( しただろう) に, (あんた) にゃ(わからん), (俺) ん (家) -助詞-特殊 -# -##### -# auxiliary-verb: -助動詞 -# -##### -# interjection: Greetings and other exclamations. -# e.g. おはよう, おはようございます, こんにちは, こんばんは, ありがとう, どうもありがとう, ありがとうございます, -# いただきます, ごちそうさま, さよなら, さようなら, はい, いいえ, ごめん, ごめんなさい -#感動詞 -# -##### -# symbol: unclassified Symbols. -記号 -# -# symbol-misc: A general symbol not in one of the categories below. -# e.g. [○◎@$〒→+] -記号-一般 -# -# symbol-comma: Commas -# e.g. [,、] -記号-読点 -# -# symbol-period: Periods and full stops. -# e.g. [..。] -記号-句点 -# -# symbol-space: Full-width whitespace. -記号-空白 -# -# symbol-open_bracket: -# e.g. [({‘“『【] -記号-括弧開 -# -# symbol-close_bracket: -# e.g. [)}’”』」】] -記号-括弧閉 -# -# symbol-alphabetic: -#記号-アルファベット -# -##### -# other: unclassified other -#その他 -# -# other-interjection: Words that are hard to classify as noun-suffixes or -# sentence-final particles. -# e.g. (だ)ァ -その他-間投 -# -##### -# filler: Aizuchi that occurs during a conversation or sounds inserted as filler. -# e.g. あの, うんと, えと -フィラー -# -##### -# non-verbal: non-verbal sound. -非言語音 -# -##### -# fragment: -#語断片 -# -##### -# unknown: unknown part of speech. -#未知語 -# -##### End of file +# +# This file defines a Japanese stoptag set for JapanesePartOfSpeechStopFilter. +# +# Any token with a part-of-speech tag that exactly matches those defined in this +# file are removed from the token stream. +# +# Set your own stoptags by uncommenting the lines below. Note that comments are +# not allowed on the same line as a stoptag. See LUCENE-3745 for frequency lists, +# etc. that can be useful for building you own stoptag set. +# +# The entire possible tagset is provided below for convenience. +# +##### +# noun: unclassified nouns +#名詞 +# +# noun-common: Common nouns or nouns where the sub-classification is undefined +#名詞-一般 +# +# noun-proper: Proper nouns where the sub-classification is undefined +#名詞-固有名詞 +# +# noun-proper-misc: miscellaneous proper nouns +#名詞-固有名詞-一般 +# +# noun-proper-person: Personal names where the sub-classification is undefined +#名詞-固有名詞-人名 +# +# noun-proper-person-misc: names that cannot be divided into surname and +# given name; foreign names; names where the surname or given name is unknown. +# e.g. お市の方 +#名詞-固有名詞-人名-一般 +# +# noun-proper-person-surname: Mainly Japanese surnames. +# e.g. 山田 +#名詞-固有名詞-人名-姓 +# +# noun-proper-person-given_name: Mainly Japanese given names. +# e.g. 太郎 +#名詞-固有名詞-人名-名 +# +# noun-proper-organization: Names representing organizations. +# e.g. 通産省, NHK +#名詞-固有名詞-組織 +# +# noun-proper-place: Place names where the sub-classification is undefined +#名詞-固有名詞-地域 +# +# noun-proper-place-misc: Place names excluding countries. +# e.g. アジア, バルセロナ, 京都 +#名詞-固有名詞-地域-一般 +# +# noun-proper-place-country: Country names. +# e.g. 日本, オーストラリア +#名詞-固有名詞-地域-国 +# +# noun-pronoun: Pronouns where the sub-classification is undefined +#名詞-代名詞 +# +# noun-pronoun-misc: miscellaneous pronouns: +# e.g. それ, ここ, あいつ, あなた, あちこち, いくつ, どこか, なに, みなさん, みんな, わたくし, われわれ +#名詞-代名詞-一般 +# +# noun-pronoun-contraction: Spoken language contraction made by combining a +# pronoun and the particle 'wa'. +# e.g. ありゃ, こりゃ, こりゃあ, そりゃ, そりゃあ +#名詞-代名詞-縮約 +# +# noun-adverbial: Temporal nouns such as names of days or months that behave +# like adverbs. Nouns that represent amount or ratios and can be used adverbially, +# e.g. 金曜, 一月, 午後, 少量 +#名詞-副詞可能 +# +# noun-verbal: Nouns that take arguments with case and can appear followed by +# 'suru' and related verbs (する, できる, なさる, くださる) +# e.g. インプット, 愛着, 悪化, 悪戦苦闘, 一安心, 下取り +#名詞-サ変接続 +# +# noun-adjective-base: The base form of adjectives, words that appear before な ("na") +# e.g. 健康, 安易, 駄目, だめ +#名詞-形容動詞語幹 +# +# noun-numeric: Arabic numbers, Chinese numerals, and counters like 何 (回), 数. +# e.g. 0, 1, 2, 何, 数, 幾 +#名詞-数 +# +# noun-affix: noun affixes where the sub-classification is undefined +#名詞-非自立 +# +# noun-affix-misc: Of adnominalizers, the case-marker の ("no"), and words that +# attach to the base form of inflectional words, words that cannot be classified +# into any of the other categories below. This category includes indefinite nouns. +# e.g. あかつき, 暁, かい, 甲斐, 気, きらい, 嫌い, くせ, 癖, こと, 事, ごと, 毎, しだい, 次第, +# 順, せい, 所為, ついで, 序で, つもり, 積もり, 点, どころ, の, はず, 筈, はずみ, 弾み, +# 拍子, ふう, ふり, 振り, ほう, 方, 旨, もの, 物, 者, ゆえ, 故, ゆえん, 所以, わけ, 訳, +# わり, 割り, 割, ん-口語/, もん-口語/ +#名詞-非自立-一般 +# +# noun-affix-adverbial: noun affixes that that can behave as adverbs. +# e.g. あいだ, 間, あげく, 挙げ句, あと, 後, 余り, 以外, 以降, 以後, 以上, 以前, 一方, うえ, +# 上, うち, 内, おり, 折り, かぎり, 限り, きり, っきり, 結果, ころ, 頃, さい, 際, 最中, さなか, +# 最中, じたい, 自体, たび, 度, ため, 為, つど, 都度, とおり, 通り, とき, 時, ところ, 所, +# とたん, 途端, なか, 中, のち, 後, ばあい, 場合, 日, ぶん, 分, ほか, 他, まえ, 前, まま, +# 儘, 侭, みぎり, 矢先 +#名詞-非自立-副詞可能 +# +# noun-affix-aux: noun affixes treated as 助動詞 ("auxiliary verb") in school grammars +# with the stem よう(だ) ("you(da)"). +# e.g. よう, やう, 様 (よう) +#名詞-非自立-助動詞語幹 +# +# noun-affix-adjective-base: noun affixes that can connect to the indeclinable +# connection form な (aux "da"). +# e.g. みたい, ふう +#名詞-非自立-形容動詞語幹 +# +# noun-special: special nouns where the sub-classification is undefined. +#名詞-特殊 +# +# noun-special-aux: The そうだ ("souda") stem form that is used for reporting news, is +# treated as 助動詞 ("auxiliary verb") in school grammars, and attach to the base +# form of inflectional words. +# e.g. そう +#名詞-特殊-助動詞語幹 +# +# noun-suffix: noun suffixes where the sub-classification is undefined. +#名詞-接尾 +# +# noun-suffix-misc: Of the nouns or stem forms of other parts of speech that connect +# to ガル or タイ and can combine into compound nouns, words that cannot be classified into +# any of the other categories below. In general, this category is more inclusive than +# 接尾語 ("suffix") and is usually the last element in a compound noun. +# e.g. おき, かた, 方, 甲斐 (がい), がかり, ぎみ, 気味, ぐるみ, (~した) さ, 次第, 済 (ず) み, +# よう, (でき)っこ, 感, 観, 性, 学, 類, 面, 用 +#名詞-接尾-一般 +# +# noun-suffix-person: Suffixes that form nouns and attach to person names more often +# than other nouns. +# e.g. 君, 様, 著 +#名詞-接尾-人名 +# +# noun-suffix-place: Suffixes that form nouns and attach to place names more often +# than other nouns. +# e.g. 町, 市, 県 +#名詞-接尾-地域 +# +# noun-suffix-verbal: Of the suffixes that attach to nouns and form nouns, those that +# can appear before スル ("suru"). +# e.g. 化, 視, 分け, 入り, 落ち, 買い +#名詞-接尾-サ変接続 +# +# noun-suffix-aux: The stem form of そうだ (様態) that is used to indicate conditions, +# is treated as 助動詞 ("auxiliary verb") in school grammars, and attach to the +# conjunctive form of inflectional words. +# e.g. そう +#名詞-接尾-助動詞語幹 +# +# noun-suffix-adjective-base: Suffixes that attach to other nouns or the conjunctive +# form of inflectional words and appear before the copula だ ("da"). +# e.g. 的, げ, がち +#名詞-接尾-形容動詞語幹 +# +# noun-suffix-adverbial: Suffixes that attach to other nouns and can behave as adverbs. +# e.g. 後 (ご), 以後, 以降, 以前, 前後, 中, 末, 上, 時 (じ) +#名詞-接尾-副詞可能 +# +# noun-suffix-classifier: Suffixes that attach to numbers and form nouns. This category +# is more inclusive than 助数詞 ("classifier") and includes common nouns that attach +# to numbers. +# e.g. 個, つ, 本, 冊, パーセント, cm, kg, カ月, か国, 区画, 時間, 時半 +#名詞-接尾-助数詞 +# +# noun-suffix-special: Special suffixes that mainly attach to inflecting words. +# e.g. (楽し) さ, (考え) 方 +#名詞-接尾-特殊 +# +# noun-suffix-conjunctive: Nouns that behave like conjunctions and join two words +# together. +# e.g. (日本) 対 (アメリカ), 対 (アメリカ), (3) 対 (5), (女優) 兼 (主婦) +#名詞-接続詞的 +# +# noun-verbal_aux: Nouns that attach to the conjunctive particle て ("te") and are +# semantically verb-like. +# e.g. ごらん, ご覧, 御覧, 頂戴 +#名詞-動詞非自立的 +# +# noun-quotation: text that cannot be segmented into words, proverbs, Chinese poetry, +# dialects, English, etc. Currently, the only entry for 名詞 引用文字列 ("noun quotation") +# is いわく ("iwaku"). +#名詞-引用文字列 +# +# noun-nai_adjective: Words that appear before the auxiliary verb ない ("nai") and +# behave like an adjective. +# e.g. 申し訳, 仕方, とんでも, 違い +#名詞-ナイ形容詞語幹 +# +##### +# prefix: unclassified prefixes +#接頭詞 +# +# prefix-nominal: Prefixes that attach to nouns (including adjective stem forms) +# excluding numerical expressions. +# e.g. お (水), 某 (氏), 同 (社), 故 (~氏), 高 (品質), お (見事), ご (立派) +#接頭詞-名詞接続 +# +# prefix-verbal: Prefixes that attach to the imperative form of a verb or a verb +# in conjunctive form followed by なる/なさる/くださる. +# e.g. お (読みなさい), お (座り) +#接頭詞-動詞接続 +# +# prefix-adjectival: Prefixes that attach to adjectives. +# e.g. お (寒いですねえ), バカ (でかい) +#接頭詞-形容詞接続 +# +# prefix-numerical: Prefixes that attach to numerical expressions. +# e.g. 約, およそ, 毎時 +#接頭詞-数接続 +# +##### +# verb: unclassified verbs +#動詞 +# +# verb-main: +#動詞-自立 +# +# verb-auxiliary: +#動詞-非自立 +# +# verb-suffix: +#動詞-接尾 +# +##### +# adjective: unclassified adjectives +#形容詞 +# +# adjective-main: +#形容詞-自立 +# +# adjective-auxiliary: +#形容詞-非自立 +# +# adjective-suffix: +#形容詞-接尾 +# +##### +# adverb: unclassified adverbs +#副詞 +# +# adverb-misc: Words that can be segmented into one unit and where adnominal +# modification is not possible. +# e.g. あいかわらず, 多分 +#副詞-一般 +# +# adverb-particle_conjunction: Adverbs that can be followed by の, は, に, +# な, する, だ, etc. +# e.g. こんなに, そんなに, あんなに, なにか, なんでも +#副詞-助詞類接続 +# +##### +# adnominal: Words that only have noun-modifying forms. +# e.g. この, その, あの, どの, いわゆる, なんらかの, 何らかの, いろんな, こういう, そういう, ああいう, +# どういう, こんな, そんな, あんな, どんな, 大きな, 小さな, おかしな, ほんの, たいした, +# 「(, も) さる (ことながら)」, 微々たる, 堂々たる, 単なる, いかなる, 我が」「同じ, 亡き +#連体詞 +# +##### +# conjunction: Conjunctions that can occur independently. +# e.g. が, けれども, そして, じゃあ, それどころか +接続詞 +# +##### +# particle: unclassified particles. +助詞 +# +# particle-case: case particles where the subclassification is undefined. +助詞-格助詞 +# +# particle-case-misc: Case particles. +# e.g. から, が, で, と, に, へ, より, を, の, にて +助詞-格助詞-一般 +# +# particle-case-quote: the "to" that appears after nouns, a person’s speech, +# quotation marks, expressions of decisions from a meeting, reasons, judgements, +# conjectures, etc. +# e.g. ( だ) と (述べた.), ( である) と (して執行猶予...) +助詞-格助詞-引用 +# +# particle-case-compound: Compounds of particles and verbs that mainly behave +# like case particles. +# e.g. という, といった, とかいう, として, とともに, と共に, でもって, にあたって, に当たって, に当って, +# にあたり, に当たり, に当り, に当たる, にあたる, において, に於いて,に於て, における, に於ける, +# にかけ, にかけて, にかんし, に関し, にかんして, に関して, にかんする, に関する, に際し, +# に際して, にしたがい, に従い, に従う, にしたがって, に従って, にたいし, に対し, にたいして, +# に対して, にたいする, に対する, について, につき, につけ, につけて, につれ, につれて, にとって, +# にとり, にまつわる, によって, に依って, に因って, により, に依り, に因り, による, に依る, に因る, +# にわたって, にわたる, をもって, を以って, を通じ, を通じて, を通して, をめぐって, をめぐり, をめぐる, +# って-口語/, ちゅう-関西弁「という」/, (何) ていう (人)-口語/, っていう-口語/, といふ, とかいふ +助詞-格助詞-連語 +# +# particle-conjunctive: +# e.g. から, からには, が, けれど, けれども, けど, し, つつ, て, で, と, ところが, どころか, とも, ども, +# ながら, なり, ので, のに, ば, ものの, や ( した), やいなや, (ころん) じゃ(いけない)-口語/, +# (行っ) ちゃ(いけない)-口語/, (言っ) たって (しかたがない)-口語/, (それがなく)ったって (平気)-口語/ +助詞-接続助詞 +# +# particle-dependency: +# e.g. こそ, さえ, しか, すら, は, も, ぞ +助詞-係助詞 +# +# particle-adverbial: +# e.g. がてら, かも, くらい, 位, ぐらい, しも, (学校) じゃ(これが流行っている)-口語/, +# (それ)じゃあ (よくない)-口語/, ずつ, (私) なぞ, など, (私) なり (に), (先生) なんか (大嫌い)-口語/, +# (私) なんぞ, (先生) なんて (大嫌い)-口語/, のみ, だけ, (私) だって-口語/, だに, +# (彼)ったら-口語/, (お茶) でも (いかが), 等 (とう), (今後) とも, ばかり, ばっか-口語/, ばっかり-口語/, +# ほど, 程, まで, 迄, (誰) も (が)([助詞-格助詞] および [助詞-係助詞] の前に位置する「も」) +助詞-副助詞 +# +# particle-interjective: particles with interjective grammatical roles. +# e.g. (松島) や +助詞-間投助詞 +# +# particle-coordinate: +# e.g. と, たり, だの, だり, とか, なり, や, やら +助詞-並立助詞 +# +# particle-final: +# e.g. かい, かしら, さ, ぜ, (だ)っけ-口語/, (とまってる) で-方言/, な, ナ, なあ-口語/, ぞ, ね, ネ, +# ねぇ-口語/, ねえ-口語/, ねん-方言/, の, のう-口語/, や, よ, ヨ, よぉ-口語/, わ, わい-口語/ +助詞-終助詞 +# +# particle-adverbial/conjunctive/final: The particle "ka" when unknown whether it is +# adverbial, conjunctive, or sentence final. For example: +# (a) 「A か B か」. Ex:「(国内で運用する) か,(海外で運用する) か (.)」 +# (b) Inside an adverb phrase. Ex:「(幸いという) か (, 死者はいなかった.)」 +# 「(祈りが届いたせい) か (, 試験に合格した.)」 +# (c) 「かのように」. Ex:「(何もなかった) か (のように振る舞った.)」 +# e.g. か +助詞-副助詞/並立助詞/終助詞 +# +# particle-adnominalizer: The "no" that attaches to nouns and modifies +# non-inflectional words. +助詞-連体化 +# +# particle-adnominalizer: The "ni" and "to" that appear following nouns and adverbs +# that are giongo, giseigo, or gitaigo. +# e.g. に, と +助詞-副詞化 +# +# particle-special: A particle that does not fit into one of the above classifications. +# This includes particles that are used in Tanka, Haiku, and other poetry. +# e.g. かな, けむ, ( しただろう) に, (あんた) にゃ(わからん), (俺) ん (家) +助詞-特殊 +# +##### +# auxiliary-verb: +助動詞 +# +##### +# interjection: Greetings and other exclamations. +# e.g. おはよう, おはようございます, こんにちは, こんばんは, ありがとう, どうもありがとう, ありがとうございます, +# いただきます, ごちそうさま, さよなら, さようなら, はい, いいえ, ごめん, ごめんなさい +#感動詞 +# +##### +# symbol: unclassified Symbols. +記号 +# +# symbol-misc: A general symbol not in one of the categories below. +# e.g. [○◎@$〒→+] +記号-一般 +# +# symbol-comma: Commas +# e.g. [,、] +記号-読点 +# +# symbol-period: Periods and full stops. +# e.g. [..。] +記号-句点 +# +# symbol-space: Full-width whitespace. +記号-空白 +# +# symbol-open_bracket: +# e.g. [({‘“『【] +記号-括弧開 +# +# symbol-close_bracket: +# e.g. [)}’”』」】] +記号-括弧閉 +# +# symbol-alphabetic: +#記号-アルファベット +# +##### +# other: unclassified other +#その他 +# +# other-interjection: Words that are hard to classify as noun-suffixes or +# sentence-final particles. +# e.g. (だ)ァ +その他-間投 +# +##### +# filler: Aizuchi that occurs during a conversation or sounds inserted as filler. +# e.g. あの, うんと, えと +フィラー +# +##### +# non-verbal: non-verbal sound. +非言語音 +# +##### +# fragment: +#語断片 +# +##### +# unknown: unknown part of speech. +#未知語 +# +##### End of file diff --git a/resources/cache/empty/class/conf/lang/stopwords_ar.txt b/resources/cache/empty/class/conf/lang/stopwords_ar.txt index aca24303..046829db 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_ar.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_ar.txt @@ -1,125 +1,125 @@ -# This file was created by Jacques Savoy and is distributed under the BSD license. -# See http://members.unine.ch/jacques.savoy/clef/index.html. -# Also see http://www.opensource.org/licenses/bsd-license.html -# Cleaned on October 11, 2009 (not normalized, so use before normalization) -# This means that when modifying this list, you might need to add some -# redundant entries, for example containing forms with both أ and ا -من -ومن -منها -منه -في -وفي -فيها -فيه -و -ف -ثم -او -أو -ب -بها -به -ا -أ -اى -اي -أي -أى -لا -ولا -الا -ألا -إلا -لكن -ما -وما -كما -فما -عن -مع -اذا -إذا -ان -أن -إن -انها -أنها -إنها -انه -أنه -إنه -بان -بأن -فان -فأن -وان -وأن -وإن -التى -التي -الذى -الذي -الذين -الى -الي -إلى -إلي -على -عليها -عليه -اما -أما -إما -ايضا -أيضا -كل -وكل -لم -ولم -لن -ولن -هى -هي -هو -وهى -وهي -وهو -فهى -فهي -فهو -انت -أنت -لك -لها -له -هذه -هذا -تلك -ذلك -هناك -كانت -كان -يكون -تكون -وكانت -وكان -غير -بعض -قد -نحو -بين -بينما -منذ -ضمن -حيث -الان -الآن -خلال -بعد -قبل -حتى -عند -عندما -لدى -جميع +# This file was created by Jacques Savoy and is distributed under the BSD license. +# See http://members.unine.ch/jacques.savoy/clef/index.html. +# Also see http://www.opensource.org/licenses/bsd-license.html +# Cleaned on October 11, 2009 (not normalized, so use before normalization) +# This means that when modifying this list, you might need to add some +# redundant entries, for example containing forms with both أ and ا +من +ومن +منها +منه +في +وفي +فيها +فيه +و +ف +ثم +او +أو +ب +بها +به +ا +أ +اى +اي +أي +أى +لا +ولا +الا +ألا +إلا +لكن +ما +وما +كما +فما +عن +مع +اذا +إذا +ان +أن +إن +انها +أنها +إنها +انه +أنه +إنه +بان +بأن +فان +فأن +وان +وأن +وإن +التى +التي +الذى +الذي +الذين +الى +الي +إلى +إلي +على +عليها +عليه +اما +أما +إما +ايضا +أيضا +كل +وكل +لم +ولم +لن +ولن +هى +هي +هو +وهى +وهي +وهو +فهى +فهي +فهو +انت +أنت +لك +لها +له +هذه +هذا +تلك +ذلك +هناك +كانت +كان +يكون +تكون +وكانت +وكان +غير +بعض +قد +نحو +بين +بينما +منذ +ضمن +حيث +الان +الآن +خلال +بعد +قبل +حتى +عند +عندما +لدى +جميع diff --git a/resources/cache/empty/class/conf/lang/stopwords_bg.txt b/resources/cache/empty/class/conf/lang/stopwords_bg.txt index 842ee8a8..1ae4ba2a 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_bg.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_bg.txt @@ -1,193 +1,193 @@ -# This file was created by Jacques Savoy and is distributed under the BSD license. -# See http://members.unine.ch/jacques.savoy/clef/index.html. -# Also see http://www.opensource.org/licenses/bsd-license.html -а -аз -ако -ала -бе -без -беше -би -бил -била -били -било -близо -бъдат -бъде -бяха -в -вас -ваш -ваша -вероятно -вече -взема -ви -вие -винаги -все -всеки -всички -всичко -всяка -във -въпреки -върху -г -ги -главно -го -д -да -дали -до -докато -докога -дори -досега -доста -е -едва -един -ето -за -зад -заедно -заради -засега -затова -защо -защото -и -из -или -им -има -имат -иска -й -каза -как -каква -какво -както -какъв -като -кога -когато -което -които -кой -който -колко -която -къде -където -към -ли -м -ме -между -мен -ми -мнозина -мога -могат -може -моля -момента -му -н -на -над -назад -най -направи -напред -например -нас -не -него -нея -ни -ние -никой -нито -но -някои -някой -няма -обаче -около -освен -особено -от -отгоре -отново -още -пак -по -повече -повечето -под -поне -поради -после -почти -прави -пред -преди -през -при -пък -първо -с -са -само -се -сега -си -скоро -след -сме -според -сред -срещу -сте -съм -със -също -т -тази -така -такива -такъв -там -твой -те -тези -ти -тн -то -това -тогава -този -той -толкова -точно -трябва -тук -тъй -тя -тях -у -харесва -ч -че -често -чрез -ще -щом -я +# This file was created by Jacques Savoy and is distributed under the BSD license. +# See http://members.unine.ch/jacques.savoy/clef/index.html. +# Also see http://www.opensource.org/licenses/bsd-license.html +а +аз +ако +ала +бе +без +беше +би +бил +била +били +било +близо +бъдат +бъде +бяха +в +вас +ваш +ваша +вероятно +вече +взема +ви +вие +винаги +все +всеки +всички +всичко +всяка +във +въпреки +върху +г +ги +главно +го +д +да +дали +до +докато +докога +дори +досега +доста +е +едва +един +ето +за +зад +заедно +заради +засега +затова +защо +защото +и +из +или +им +има +имат +иска +й +каза +как +каква +какво +както +какъв +като +кога +когато +което +които +кой +който +колко +която +къде +където +към +ли +м +ме +между +мен +ми +мнозина +мога +могат +може +моля +момента +му +н +на +над +назад +най +направи +напред +например +нас +не +него +нея +ни +ние +никой +нито +но +някои +някой +няма +обаче +около +освен +особено +от +отгоре +отново +още +пак +по +повече +повечето +под +поне +поради +после +почти +прави +пред +преди +през +при +пък +първо +с +са +само +се +сега +си +скоро +след +сме +според +сред +срещу +сте +съм +със +също +т +тази +така +такива +такъв +там +твой +те +тези +ти +тн +то +това +тогава +този +той +толкова +точно +трябва +тук +тъй +тя +тях +у +харесва +ч +че +често +чрез +ще +щом +я diff --git a/resources/cache/empty/class/conf/lang/stopwords_ca.txt b/resources/cache/empty/class/conf/lang/stopwords_ca.txt index e618af55..3da65dea 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_ca.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_ca.txt @@ -1,220 +1,220 @@ -# Catalan stopwords from http://github.com/vcl/cue.language (Apache 2 Licensed) -a -abans -ací -ah -així -això -al -als -aleshores -algun -alguna -algunes -alguns -alhora -allà -allí -allò -altra -altre -altres -amb -ambdós -ambdues -apa -aquell -aquella -aquelles -aquells -aquest -aquesta -aquestes -aquests -aquí -baix -cada -cadascú -cadascuna -cadascunes -cadascuns -com -contra -d'un -d'una -d'unes -d'uns -dalt -de -del -dels -des -després -dins -dintre -donat -doncs -durant -e -eh -el -els -em -en -encara -ens -entre -érem -eren -éreu -es -és -esta -està -estàvem -estaven -estàveu -esteu -et -etc -ets -fins -fora -gairebé -ha -han -has -havia -he -hem -heu -hi -ho -i -igual -iguals -ja -l'hi -la -les -li -li'n -llavors -m'he -ma -mal -malgrat -mateix -mateixa -mateixes -mateixos -me -mentre -més -meu -meus -meva -meves -molt -molta -moltes -molts -mon -mons -n'he -n'hi -ne -ni -no -nogensmenys -només -nosaltres -nostra -nostre -nostres -o -oh -oi -on -pas -pel -pels -per -però -perquè -poc -poca -pocs -poques -potser -propi -qual -quals -quan -quant -que -què -quelcom -qui -quin -quina -quines -quins -s'ha -s'han -sa -semblant -semblants -ses -seu -seus -seva -seva -seves -si -sobre -sobretot -sóc -solament -sols -son -són -sons -sota -sou -t'ha -t'han -t'he -ta -tal -també -tampoc -tan -tant -tanta -tantes -teu -teus -teva -teves -ton -tons -tot -tota -totes -tots -un -una -unes -uns -us -va -vaig -vam -van -vas -veu -vosaltres -vostra -vostre -vostres +# Catalan stopwords from http://github.com/vcl/cue.language (Apache 2 Licensed) +a +abans +ací +ah +així +això +al +als +aleshores +algun +alguna +algunes +alguns +alhora +allà +allí +allò +altra +altre +altres +amb +ambdós +ambdues +apa +aquell +aquella +aquelles +aquells +aquest +aquesta +aquestes +aquests +aquí +baix +cada +cadascú +cadascuna +cadascunes +cadascuns +com +contra +d'un +d'una +d'unes +d'uns +dalt +de +del +dels +des +després +dins +dintre +donat +doncs +durant +e +eh +el +els +em +en +encara +ens +entre +érem +eren +éreu +es +és +esta +està +estàvem +estaven +estàveu +esteu +et +etc +ets +fins +fora +gairebé +ha +han +has +havia +he +hem +heu +hi +ho +i +igual +iguals +ja +l'hi +la +les +li +li'n +llavors +m'he +ma +mal +malgrat +mateix +mateixa +mateixes +mateixos +me +mentre +més +meu +meus +meva +meves +molt +molta +moltes +molts +mon +mons +n'he +n'hi +ne +ni +no +nogensmenys +només +nosaltres +nostra +nostre +nostres +o +oh +oi +on +pas +pel +pels +per +però +perquè +poc +poca +pocs +poques +potser +propi +qual +quals +quan +quant +que +què +quelcom +qui +quin +quina +quines +quins +s'ha +s'han +sa +semblant +semblants +ses +seu +seus +seva +seva +seves +si +sobre +sobretot +sóc +solament +sols +son +són +sons +sota +sou +t'ha +t'han +t'he +ta +tal +també +tampoc +tan +tant +tanta +tantes +teu +teus +teva +teves +ton +tons +tot +tota +totes +tots +un +una +unes +uns +us +va +vaig +vam +van +vas +veu +vosaltres +vostra +vostre +vostres diff --git a/resources/cache/empty/class/conf/lang/stopwords_cz.txt b/resources/cache/empty/class/conf/lang/stopwords_cz.txt index e928df95..53c6097d 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_cz.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_cz.txt @@ -1,172 +1,172 @@ -a -s -k -o -i -u -v -z -dnes -cz -tímto -budeš -budem -byli -jseš -můj -svým -ta -tomto -tohle -tuto -tyto -jej -zda -proč -máte -tato -kam -tohoto -kdo -kteří -mi -nám -tom -tomuto -mít -nic -proto -kterou -byla -toho -protože -asi -ho -naši -napište -re -což -tím -takže -svých -její -svými -jste -aj -tu -tedy -teto -bylo -kde -ke -pravé -ji -nad -nejsou -či -pod -téma -mezi -přes -ty -pak -vám -ani -když -však -neg -jsem -tento -článku -články -aby -jsme -před -pta -jejich -byl -ještě -až -bez -také -pouze -první -vaše -která -nás -nový -tipy -pokud -může -strana -jeho -své -jiné -zprávy -nové -není -vás -jen -podle -zde -už -být -více -bude -již -než -který -by -které -co -nebo -ten -tak -má -při -od -po -jsou -jak -další -ale -si -se -ve -to -jako -za -zpět -ze -do -pro -je -na -atd -atp -jakmile -přičemž -já -on -ona -ono -oni -ony -my -vy -jí -ji -mě -mne -jemu -tomu -těm -těmu -němu -němuž -jehož -jíž -jelikož -jež -jakož -načež +a +s +k +o +i +u +v +z +dnes +cz +tímto +budeš +budem +byli +jseš +můj +svým +ta +tomto +tohle +tuto +tyto +jej +zda +proč +máte +tato +kam +tohoto +kdo +kteří +mi +nám +tom +tomuto +mít +nic +proto +kterou +byla +toho +protože +asi +ho +naši +napište +re +což +tím +takže +svých +její +svými +jste +aj +tu +tedy +teto +bylo +kde +ke +pravé +ji +nad +nejsou +či +pod +téma +mezi +přes +ty +pak +vám +ani +když +však +neg +jsem +tento +článku +články +aby +jsme +před +pta +jejich +byl +ještě +až +bez +také +pouze +první +vaše +která +nás +nový +tipy +pokud +může +strana +jeho +své +jiné +zprávy +nové +není +vás +jen +podle +zde +už +být +více +bude +již +než +který +by +které +co +nebo +ten +tak +má +při +od +po +jsou +jak +další +ale +si +se +ve +to +jako +za +zpět +ze +do +pro +je +na +atd +atp +jakmile +přičemž +já +on +ona +ono +oni +ony +my +vy +jí +ji +mě +mne +jemu +tomu +těm +těmu +němu +němuž +jehož +jíž +jelikož +jež +jakož +načež diff --git a/resources/cache/empty/class/conf/lang/stopwords_da.txt b/resources/cache/empty/class/conf/lang/stopwords_da.txt index e25d49ce..42e6145b 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_da.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_da.txt @@ -1,110 +1,110 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/danish/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Danish stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - | This is a ranked list (commonest to rarest) of stopwords derived from - | a large text sample. - - -og | and -i | in -jeg | I -det | that (dem. pronoun)/it (pers. pronoun) -at | that (in front of a sentence)/to (with infinitive) -en | a/an -den | it (pers. pronoun)/that (dem. pronoun) -til | to/at/for/until/against/by/of/into, more -er | present tense of "to be" -som | who, as -på | on/upon/in/on/at/to/after/of/with/for, on -de | they -med | with/by/in, along -han | he -af | of/by/from/off/for/in/with/on, off -for | at/for/to/from/by/of/ago, in front/before, because -ikke | not -der | who/which, there/those -var | past tense of "to be" -mig | me/myself -sig | oneself/himself/herself/itself/themselves -men | but -et | a/an/one, one (number), someone/somebody/one -har | present tense of "to have" -om | round/about/for/in/a, about/around/down, if -vi | we -min | my -havde | past tense of "to have" -ham | him -hun | she -nu | now -over | over/above/across/by/beyond/past/on/about, over/past -da | then, when/as/since -fra | from/off/since, off, since -du | you -ud | out -sin | his/her/its/one's -dem | them -os | us/ourselves -op | up -man | you/one -hans | his -hvor | where -eller | or -hvad | what -skal | must/shall etc. -selv | myself/youself/herself/ourselves etc., even -her | here -alle | all/everyone/everybody etc. -vil | will (verb) -blev | past tense of "to stay/to remain/to get/to become" -kunne | could -ind | in -når | when -være | present tense of "to be" -dog | however/yet/after all -noget | something -ville | would -jo | you know/you see (adv), yes -deres | their/theirs -efter | after/behind/according to/for/by/from, later/afterwards -ned | down -skulle | should -denne | this -end | than -dette | this -mit | my/mine -også | also -under | under/beneath/below/during, below/underneath -have | have -dig | you -anden | other -hende | her -mine | my -alt | everything -meget | much/very, plenty of -sit | his, her, its, one's -sine | his, her, its, one's -vor | our -mod | against -disse | these -hvis | if -din | your/yours -nogle | some -hos | by/at -blive | be/become -mange | many -ad | by/through -bliver | present tense of "to be/to become" -hendes | her/hers -været | be -thi | for (conj) -jer | you -sådan | such, like this/like that + | From svn.tartarus.org/snowball/trunk/website/algorithms/danish/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Danish stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + | This is a ranked list (commonest to rarest) of stopwords derived from + | a large text sample. + + +og | and +i | in +jeg | I +det | that (dem. pronoun)/it (pers. pronoun) +at | that (in front of a sentence)/to (with infinitive) +en | a/an +den | it (pers. pronoun)/that (dem. pronoun) +til | to/at/for/until/against/by/of/into, more +er | present tense of "to be" +som | who, as +på | on/upon/in/on/at/to/after/of/with/for, on +de | they +med | with/by/in, along +han | he +af | of/by/from/off/for/in/with/on, off +for | at/for/to/from/by/of/ago, in front/before, because +ikke | not +der | who/which, there/those +var | past tense of "to be" +mig | me/myself +sig | oneself/himself/herself/itself/themselves +men | but +et | a/an/one, one (number), someone/somebody/one +har | present tense of "to have" +om | round/about/for/in/a, about/around/down, if +vi | we +min | my +havde | past tense of "to have" +ham | him +hun | she +nu | now +over | over/above/across/by/beyond/past/on/about, over/past +da | then, when/as/since +fra | from/off/since, off, since +du | you +ud | out +sin | his/her/its/one's +dem | them +os | us/ourselves +op | up +man | you/one +hans | his +hvor | where +eller | or +hvad | what +skal | must/shall etc. +selv | myself/youself/herself/ourselves etc., even +her | here +alle | all/everyone/everybody etc. +vil | will (verb) +blev | past tense of "to stay/to remain/to get/to become" +kunne | could +ind | in +når | when +være | present tense of "to be" +dog | however/yet/after all +noget | something +ville | would +jo | you know/you see (adv), yes +deres | their/theirs +efter | after/behind/according to/for/by/from, later/afterwards +ned | down +skulle | should +denne | this +end | than +dette | this +mit | my/mine +også | also +under | under/beneath/below/during, below/underneath +have | have +dig | you +anden | other +hende | her +mine | my +alt | everything +meget | much/very, plenty of +sit | his, her, its, one's +sine | his, her, its, one's +vor | our +mod | against +disse | these +hvis | if +din | your/yours +nogle | some +hos | by/at +blive | be/become +mange | many +ad | by/through +bliver | present tense of "to be/to become" +hendes | her/hers +været | be +thi | for (conj) +jer | you +sådan | such, like this/like that diff --git a/resources/cache/empty/class/conf/lang/stopwords_de.txt b/resources/cache/empty/class/conf/lang/stopwords_de.txt index bb9933ee..86525e7a 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_de.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_de.txt @@ -1,294 +1,294 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/german/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A German stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - | The number of forms in this list is reduced significantly by passing it - | through the German stemmer. - - -aber | but - -alle | all -allem -allen -aller -alles - -als | than, as -also | so -am | an + dem -an | at - -ander | other -andere -anderem -anderen -anderer -anderes -anderm -andern -anderr -anders - -auch | also -auf | on -aus | out of -bei | by -bin | am -bis | until -bist | art -da | there -damit | with it -dann | then - -der | the -den -des -dem -die -das - -daß | that - -derselbe | the same -derselben -denselben -desselben -demselben -dieselbe -dieselben -dasselbe - -dazu | to that - -dein | thy -deine -deinem -deinen -deiner -deines - -denn | because - -derer | of those -dessen | of him - -dich | thee -dir | to thee -du | thou - -dies | this -diese -diesem -diesen -dieser -dieses - - -doch | (several meanings) -dort | (over) there - - -durch | through - -ein | a -eine -einem -einen -einer -eines - -einig | some -einige -einigem -einigen -einiger -einiges - -einmal | once - -er | he -ihn | him -ihm | to him - -es | it -etwas | something - -euer | your -eure -eurem -euren -eurer -eures - -für | for -gegen | towards -gewesen | p.p. of sein -hab | have -habe | have -haben | have -hat | has -hatte | had -hatten | had -hier | here -hin | there -hinter | behind - -ich | I -mich | me -mir | to me - - -ihr | you, to her -ihre -ihrem -ihren -ihrer -ihres -euch | to you - -im | in + dem -in | in -indem | while -ins | in + das -ist | is - -jede | each, every -jedem -jeden -jeder -jedes - -jene | that -jenem -jenen -jener -jenes - -jetzt | now -kann | can - -kein | no -keine -keinem -keinen -keiner -keines - -können | can -könnte | could -machen | do -man | one - -manche | some, many a -manchem -manchen -mancher -manches - -mein | my -meine -meinem -meinen -meiner -meines - -mit | with -muss | must -musste | had to -nach | to(wards) -nicht | not -nichts | nothing -noch | still, yet -nun | now -nur | only -ob | whether -oder | or -ohne | without -sehr | very - -sein | his -seine -seinem -seinen -seiner -seines - -selbst | self -sich | herself - -sie | they, she -ihnen | to them - -sind | are -so | so - -solche | such -solchem -solchen -solcher -solches - -soll | shall -sollte | should -sondern | but -sonst | else -über | over -um | about, around -und | and - -uns | us -unse -unsem -unsen -unser -unses - -unter | under -viel | much -vom | von + dem -von | from -vor | before -während | while -war | was -waren | were -warst | wast -was | what -weg | away, off -weil | because -weiter | further - -welche | which -welchem -welchen -welcher -welches - -wenn | when -werde | will -werden | will -wie | how -wieder | again -will | want -wir | we -wird | will -wirst | willst -wo | where -wollen | want -wollte | wanted -würde | would -würden | would -zu | to -zum | zu + dem -zur | zu + der -zwar | indeed -zwischen | between - + | From svn.tartarus.org/snowball/trunk/website/algorithms/german/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A German stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + | The number of forms in this list is reduced significantly by passing it + | through the German stemmer. + + +aber | but + +alle | all +allem +allen +aller +alles + +als | than, as +also | so +am | an + dem +an | at + +ander | other +andere +anderem +anderen +anderer +anderes +anderm +andern +anderr +anders + +auch | also +auf | on +aus | out of +bei | by +bin | am +bis | until +bist | art +da | there +damit | with it +dann | then + +der | the +den +des +dem +die +das + +daß | that + +derselbe | the same +derselben +denselben +desselben +demselben +dieselbe +dieselben +dasselbe + +dazu | to that + +dein | thy +deine +deinem +deinen +deiner +deines + +denn | because + +derer | of those +dessen | of him + +dich | thee +dir | to thee +du | thou + +dies | this +diese +diesem +diesen +dieser +dieses + + +doch | (several meanings) +dort | (over) there + + +durch | through + +ein | a +eine +einem +einen +einer +eines + +einig | some +einige +einigem +einigen +einiger +einiges + +einmal | once + +er | he +ihn | him +ihm | to him + +es | it +etwas | something + +euer | your +eure +eurem +euren +eurer +eures + +für | for +gegen | towards +gewesen | p.p. of sein +hab | have +habe | have +haben | have +hat | has +hatte | had +hatten | had +hier | here +hin | there +hinter | behind + +ich | I +mich | me +mir | to me + + +ihr | you, to her +ihre +ihrem +ihren +ihrer +ihres +euch | to you + +im | in + dem +in | in +indem | while +ins | in + das +ist | is + +jede | each, every +jedem +jeden +jeder +jedes + +jene | that +jenem +jenen +jener +jenes + +jetzt | now +kann | can + +kein | no +keine +keinem +keinen +keiner +keines + +können | can +könnte | could +machen | do +man | one + +manche | some, many a +manchem +manchen +mancher +manches + +mein | my +meine +meinem +meinen +meiner +meines + +mit | with +muss | must +musste | had to +nach | to(wards) +nicht | not +nichts | nothing +noch | still, yet +nun | now +nur | only +ob | whether +oder | or +ohne | without +sehr | very + +sein | his +seine +seinem +seinen +seiner +seines + +selbst | self +sich | herself + +sie | they, she +ihnen | to them + +sind | are +so | so + +solche | such +solchem +solchen +solcher +solches + +soll | shall +sollte | should +sondern | but +sonst | else +über | over +um | about, around +und | and + +uns | us +unse +unsem +unsen +unser +unses + +unter | under +viel | much +vom | von + dem +von | from +vor | before +während | while +war | was +waren | were +warst | wast +was | what +weg | away, off +weil | because +weiter | further + +welche | which +welchem +welchen +welcher +welches + +wenn | when +werde | will +werden | will +wie | how +wieder | again +will | want +wir | we +wird | will +wirst | willst +wo | where +wollen | want +wollte | wanted +würde | would +würden | would +zu | to +zum | zu + dem +zur | zu + der +zwar | indeed +zwischen | between + diff --git a/resources/cache/empty/class/conf/lang/stopwords_el.txt b/resources/cache/empty/class/conf/lang/stopwords_el.txt index a5abfbec..232681f5 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_el.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_el.txt @@ -1,78 +1,78 @@ -# Lucene Greek Stopwords list -# Note: by default this file is used after GreekLowerCaseFilter, -# so when modifying this file use 'σ' instead of 'ς' -ο -η -το -οι -τα -του -τησ -των -τον -την -και -κι -κ -ειμαι -εισαι -ειναι -ειμαστε -ειστε -στο -στον -στη -στην -μα -αλλα -απο -για -προσ -με -σε -ωσ -παρα -αντι -κατα -μετα -θα -να -δε -δεν -μη -μην -επι -ενω -εαν -αν -τοτε -που -πωσ -ποιοσ -ποια -ποιο -ποιοι -ποιεσ -ποιων -ποιουσ -αυτοσ -αυτη -αυτο -αυτοι -αυτων -αυτουσ -αυτεσ -αυτα -εκεινοσ -εκεινη -εκεινο -εκεινοι -εκεινεσ -εκεινα -εκεινων -εκεινουσ -οπωσ -ομωσ -ισωσ -οσο -οτι +# Lucene Greek Stopwords list +# Note: by default this file is used after GreekLowerCaseFilter, +# so when modifying this file use 'σ' instead of 'ς' +ο +η +το +οι +τα +του +τησ +των +τον +την +και +κι +κ +ειμαι +εισαι +ειναι +ειμαστε +ειστε +στο +στον +στη +στην +μα +αλλα +απο +για +προσ +με +σε +ωσ +παρα +αντι +κατα +μετα +θα +να +δε +δεν +μη +μην +επι +ενω +εαν +αν +τοτε +που +πωσ +ποιοσ +ποια +ποιο +ποιοι +ποιεσ +ποιων +ποιουσ +αυτοσ +αυτη +αυτο +αυτοι +αυτων +αυτουσ +αυτεσ +αυτα +εκεινοσ +εκεινη +εκεινο +εκεινοι +εκεινεσ +εκεινα +εκεινων +εκεινουσ +οπωσ +ομωσ +ισωσ +οσο +οτι diff --git a/resources/cache/empty/class/conf/lang/stopwords_en.txt b/resources/cache/empty/class/conf/lang/stopwords_en.txt index 224230c5..2c164c0b 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_en.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_en.txt @@ -1,54 +1,54 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# a couple of test stopwords to test that the words are really being -# configured from this file: -stopworda -stopwordb - -# Standard english stop words taken from Lucene's StopAnalyzer -a -an -and -are -as -at -be -but -by -for -if -in -into -is -it -no -not -of -on -or -such -that -the -their -then -there -these -they -this -to -was -will -with +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# a couple of test stopwords to test that the words are really being +# configured from this file: +stopworda +stopwordb + +# Standard english stop words taken from Lucene's StopAnalyzer +a +an +and +are +as +at +be +but +by +for +if +in +into +is +it +no +not +of +on +or +such +that +the +their +then +there +these +they +this +to +was +will +with diff --git a/resources/cache/empty/class/conf/lang/stopwords_es.txt b/resources/cache/empty/class/conf/lang/stopwords_es.txt index 99afd937..487d78c8 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_es.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_es.txt @@ -1,356 +1,356 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/spanish/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Spanish stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - - | The following is a ranked list (commonest to rarest) of stopwords - | deriving from a large sample of text. - - | Extra words have been added at the end. - -de | from, of -la | the, her -que | who, that -el | the -en | in -y | and -a | to -los | the, them -del | de + el -se | himself, from him etc -las | the, them -por | for, by, etc -un | a -para | for -con | with -no | no -una | a -su | his, her -al | a + el - | es from SER -lo | him -como | how -más | more -pero | pero -sus | su plural -le | to him, her -ya | already -o | or - | fue from SER -este | this - | ha from HABER -sí | himself etc -porque | because -esta | this - | son from SER -entre | between - | está from ESTAR -cuando | when -muy | very -sin | without -sobre | on - | ser from SER - | tiene from TENER -también | also -me | me -hasta | until -hay | there is/are -donde | where - | han from HABER -quien | whom, that - | están from ESTAR - | estado from ESTAR -desde | from -todo | all -nos | us -durante | during - | estados from ESTAR -todos | all -uno | a -les | to them -ni | nor -contra | against -otros | other - | fueron from SER -ese | that -eso | that - | había from HABER -ante | before -ellos | they -e | and (variant of y) -esto | this -mí | me -antes | before -algunos | some -qué | what? -unos | a -yo | I -otro | other -otras | other -otra | other -él | he -tanto | so much, many -esa | that -estos | these -mucho | much, many -quienes | who -nada | nothing -muchos | many -cual | who - | sea from SER -poco | few -ella | she -estar | to be - | haber from HABER -estas | these - | estaba from ESTAR - | estamos from ESTAR -algunas | some -algo | something -nosotros | we - - | other forms - -mi | me -mis | mi plural -tú | thou -te | thee -ti | thee -tu | thy -tus | tu plural -ellas | they -nosotras | we -vosotros | you -vosotras | you -os | you -mío | mine -mía | -míos | -mías | -tuyo | thine -tuya | -tuyos | -tuyas | -suyo | his, hers, theirs -suya | -suyos | -suyas | -nuestro | ours -nuestra | -nuestros | -nuestras | -vuestro | yours -vuestra | -vuestros | -vuestras | -esos | those -esas | those - - | forms of estar, to be (not including the infinitive): -estoy -estás -está -estamos -estáis -están -esté -estés -estemos -estéis -estén -estaré -estarás -estará -estaremos -estaréis -estarán -estaría -estarías -estaríamos -estaríais -estarían -estaba -estabas -estábamos -estabais -estaban -estuve -estuviste -estuvo -estuvimos -estuvisteis -estuvieron -estuviera -estuvieras -estuviéramos -estuvierais -estuvieran -estuviese -estuvieses -estuviésemos -estuvieseis -estuviesen -estando -estado -estada -estados -estadas -estad - - | forms of haber, to have (not including the infinitive): -he -has -ha -hemos -habéis -han -haya -hayas -hayamos -hayáis -hayan -habré -habrás -habrá -habremos -habréis -habrán -habría -habrías -habríamos -habríais -habrían -había -habías -habíamos -habíais -habían -hube -hubiste -hubo -hubimos -hubisteis -hubieron -hubiera -hubieras -hubiéramos -hubierais -hubieran -hubiese -hubieses -hubiésemos -hubieseis -hubiesen -habiendo -habido -habida -habidos -habidas - - | forms of ser, to be (not including the infinitive): -soy -eres -es -somos -sois -son -sea -seas -seamos -seáis -sean -seré -serás -será -seremos -seréis -serán -sería -serías -seríamos -seríais -serían -era -eras -éramos -erais -eran -fui -fuiste -fue -fuimos -fuisteis -fueron -fuera -fueras -fuéramos -fuerais -fueran -fuese -fueses -fuésemos -fueseis -fuesen -siendo -sido - | sed also means 'thirst' - - | forms of tener, to have (not including the infinitive): -tengo -tienes -tiene -tenemos -tenéis -tienen -tenga -tengas -tengamos -tengáis -tengan -tendré -tendrás -tendrá -tendremos -tendréis -tendrán -tendría -tendrías -tendríamos -tendríais -tendrían -tenía -tenías -teníamos -teníais -tenían -tuve -tuviste -tuvo -tuvimos -tuvisteis -tuvieron -tuviera -tuvieras -tuviéramos -tuvierais -tuvieran -tuviese -tuvieses -tuviésemos -tuvieseis -tuviesen -teniendo -tenido -tenida -tenidos -tenidas -tened - + | From svn.tartarus.org/snowball/trunk/website/algorithms/spanish/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Spanish stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + + | The following is a ranked list (commonest to rarest) of stopwords + | deriving from a large sample of text. + + | Extra words have been added at the end. + +de | from, of +la | the, her +que | who, that +el | the +en | in +y | and +a | to +los | the, them +del | de + el +se | himself, from him etc +las | the, them +por | for, by, etc +un | a +para | for +con | with +no | no +una | a +su | his, her +al | a + el + | es from SER +lo | him +como | how +más | more +pero | pero +sus | su plural +le | to him, her +ya | already +o | or + | fue from SER +este | this + | ha from HABER +sí | himself etc +porque | because +esta | this + | son from SER +entre | between + | está from ESTAR +cuando | when +muy | very +sin | without +sobre | on + | ser from SER + | tiene from TENER +también | also +me | me +hasta | until +hay | there is/are +donde | where + | han from HABER +quien | whom, that + | están from ESTAR + | estado from ESTAR +desde | from +todo | all +nos | us +durante | during + | estados from ESTAR +todos | all +uno | a +les | to them +ni | nor +contra | against +otros | other + | fueron from SER +ese | that +eso | that + | había from HABER +ante | before +ellos | they +e | and (variant of y) +esto | this +mí | me +antes | before +algunos | some +qué | what? +unos | a +yo | I +otro | other +otras | other +otra | other +él | he +tanto | so much, many +esa | that +estos | these +mucho | much, many +quienes | who +nada | nothing +muchos | many +cual | who + | sea from SER +poco | few +ella | she +estar | to be + | haber from HABER +estas | these + | estaba from ESTAR + | estamos from ESTAR +algunas | some +algo | something +nosotros | we + + | other forms + +mi | me +mis | mi plural +tú | thou +te | thee +ti | thee +tu | thy +tus | tu plural +ellas | they +nosotras | we +vosotros | you +vosotras | you +os | you +mío | mine +mía | +míos | +mías | +tuyo | thine +tuya | +tuyos | +tuyas | +suyo | his, hers, theirs +suya | +suyos | +suyas | +nuestro | ours +nuestra | +nuestros | +nuestras | +vuestro | yours +vuestra | +vuestros | +vuestras | +esos | those +esas | those + + | forms of estar, to be (not including the infinitive): +estoy +estás +está +estamos +estáis +están +esté +estés +estemos +estéis +estén +estaré +estarás +estará +estaremos +estaréis +estarán +estaría +estarías +estaríamos +estaríais +estarían +estaba +estabas +estábamos +estabais +estaban +estuve +estuviste +estuvo +estuvimos +estuvisteis +estuvieron +estuviera +estuvieras +estuviéramos +estuvierais +estuvieran +estuviese +estuvieses +estuviésemos +estuvieseis +estuviesen +estando +estado +estada +estados +estadas +estad + + | forms of haber, to have (not including the infinitive): +he +has +ha +hemos +habéis +han +haya +hayas +hayamos +hayáis +hayan +habré +habrás +habrá +habremos +habréis +habrán +habría +habrías +habríamos +habríais +habrían +había +habías +habíamos +habíais +habían +hube +hubiste +hubo +hubimos +hubisteis +hubieron +hubiera +hubieras +hubiéramos +hubierais +hubieran +hubiese +hubieses +hubiésemos +hubieseis +hubiesen +habiendo +habido +habida +habidos +habidas + + | forms of ser, to be (not including the infinitive): +soy +eres +es +somos +sois +son +sea +seas +seamos +seáis +sean +seré +serás +será +seremos +seréis +serán +sería +serías +seríamos +seríais +serían +era +eras +éramos +erais +eran +fui +fuiste +fue +fuimos +fuisteis +fueron +fuera +fueras +fuéramos +fuerais +fueran +fuese +fueses +fuésemos +fueseis +fuesen +siendo +sido + | sed also means 'thirst' + + | forms of tener, to have (not including the infinitive): +tengo +tienes +tiene +tenemos +tenéis +tienen +tenga +tengas +tengamos +tengáis +tengan +tendré +tendrás +tendrá +tendremos +tendréis +tendrán +tendría +tendrías +tendríamos +tendríais +tendrían +tenía +tenías +teníamos +teníais +tenían +tuve +tuviste +tuvo +tuvimos +tuvisteis +tuvieron +tuviera +tuvieras +tuviéramos +tuvierais +tuvieran +tuviese +tuvieses +tuviésemos +tuvieseis +tuviesen +teniendo +tenido +tenida +tenidos +tenidas +tened + diff --git a/resources/cache/empty/class/conf/lang/stopwords_eu.txt b/resources/cache/empty/class/conf/lang/stopwords_eu.txt index 7e4e4bb3..25f1db93 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_eu.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_eu.txt @@ -1,99 +1,99 @@ -# example set of basque stopwords -al -anitz -arabera -asko -baina -bat -batean -batek -bati -batzuei -batzuek -batzuetan -batzuk -bera -beraiek -berau -berauek -bere -berori -beroriek -beste -bezala -da -dago -dira -ditu -du -dute -edo -egin -ere -eta -eurak -ez -gainera -gu -gutxi -guzti -haiei -haiek -haietan -hainbeste -hala -han -handik -hango -hara -hari -hark -hartan -hau -hauei -hauek -hauetan -hemen -hemendik -hemengo -hi -hona -honek -honela -honetan -honi -hor -hori -horiei -horiek -horietan -horko -horra -horrek -horrela -horretan -horri -hortik -hura -izan -ni -noiz -nola -non -nondik -nongo -nor -nora -ze -zein -zen -zenbait -zenbat -zer -zergatik -ziren -zituen -zu -zuek -zuen -zuten +# example set of basque stopwords +al +anitz +arabera +asko +baina +bat +batean +batek +bati +batzuei +batzuek +batzuetan +batzuk +bera +beraiek +berau +berauek +bere +berori +beroriek +beste +bezala +da +dago +dira +ditu +du +dute +edo +egin +ere +eta +eurak +ez +gainera +gu +gutxi +guzti +haiei +haiek +haietan +hainbeste +hala +han +handik +hango +hara +hari +hark +hartan +hau +hauei +hauek +hauetan +hemen +hemendik +hemengo +hi +hona +honek +honela +honetan +honi +hor +hori +horiei +horiek +horietan +horko +horra +horrek +horrela +horretan +horri +hortik +hura +izan +ni +noiz +nola +non +nondik +nongo +nor +nora +ze +zein +zen +zenbait +zenbat +zer +zergatik +ziren +zituen +zu +zuek +zuen +zuten diff --git a/resources/cache/empty/class/conf/lang/stopwords_fa.txt b/resources/cache/empty/class/conf/lang/stopwords_fa.txt index 76bb6354..723641c6 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_fa.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_fa.txt @@ -1,313 +1,313 @@ -# This file was created by Jacques Savoy and is distributed under the BSD license. -# See http://members.unine.ch/jacques.savoy/clef/index.html. -# Also see http://www.opensource.org/licenses/bsd-license.html -# Note: by default this file is used after normalization, so when adding entries -# to this file, use the arabic 'ي' instead of 'ی' -انان -نداشته -سراسر -خياه -ايشان -وي -تاكنون -بيشتري -دوم -پس -ناشي -وگو -يا -داشتند -سپس -هنگام -هرگز -پنج -نشان -امسال -ديگر -گروهي -شدند -چطور -ده -و -دو -نخستين -ولي -چرا -چه -وسط -ه -كدام -قابل -يك -رفت -هفت -همچنين -در -هزار -بله -بلي -شايد -اما -شناسي -گرفته -دهد -داشته -دانست -داشتن -خواهيم -ميليارد -وقتيكه -امد -خواهد -جز -اورده -شده -بلكه -خدمات -شدن -برخي -نبود -بسياري -جلوگيري -حق -كردند -نوعي -بعري -نكرده -نظير -نبايد -بوده -بودن -داد -اورد -هست -جايي -شود -دنبال -داده -بايد -سابق -هيچ -همان -انجا -كمتر -كجاست -گردد -كسي -تر -مردم -تان -دادن -بودند -سري -جدا -ندارند -مگر -يكديگر -دارد -دهند -بنابراين -هنگامي -سمت -جا -انچه -خود -دادند -زياد -دارند -اثر -بدون -بهترين -بيشتر -البته -به -براساس -بيرون -كرد -بعضي -گرفت -توي -اي -ميليون -او -جريان -تول -بر -مانند -برابر -باشيم -مدتي -گويند -اكنون -تا -تنها -جديد -چند -بي -نشده -كردن -كردم -گويد -كرده -كنيم -نمي -نزد -روي -قصد -فقط -بالاي -ديگران -اين -ديروز -توسط -سوم -ايم -دانند -سوي -استفاده -شما -كنار -داريم -ساخته -طور -امده -رفته -نخست -بيست -نزديك -طي -كنيد -از -انها -تمامي -داشت -يكي -طريق -اش -چيست -روب -نمايد -گفت -چندين -چيزي -تواند -ام -ايا -با -ان -ايد -ترين -اينكه -ديگري -راه -هايي -بروز -همچنان -پاعين -كس -حدود -مختلف -مقابل -چيز -گيرد -ندارد -ضد -همچون -سازي -شان -مورد -باره -مرسي -خويش -برخوردار -چون -خارج -شش -هنوز -تحت -ضمن -هستيم -گفته -فكر -بسيار -پيش -براي -روزهاي -انكه -نخواهد -بالا -كل -وقتي -كي -چنين -كه -گيري -نيست -است -كجا -كند -نيز -يابد -بندي -حتي -توانند -عقب -خواست -كنند -بين -تمام -همه -ما -باشند -مثل -شد -اري -باشد -اره -طبق -بعد -اگر -صورت -غير -جاي -بيش -ريزي -اند -زيرا -چگونه -بار -لطفا -مي -درباره -من -ديده -همين -گذاري -برداري -علت -گذاشته -هم -فوق -نه -ها -شوند -اباد -همواره -هر -اول -خواهند -چهار -نام -امروز -مان -هاي -قبل -كنم -سعي -تازه -را -هستند -زير -جلوي -عنوان -بود +# This file was created by Jacques Savoy and is distributed under the BSD license. +# See http://members.unine.ch/jacques.savoy/clef/index.html. +# Also see http://www.opensource.org/licenses/bsd-license.html +# Note: by default this file is used after normalization, so when adding entries +# to this file, use the arabic 'ي' instead of 'ی' +انان +نداشته +سراسر +خياه +ايشان +وي +تاكنون +بيشتري +دوم +پس +ناشي +وگو +يا +داشتند +سپس +هنگام +هرگز +پنج +نشان +امسال +ديگر +گروهي +شدند +چطور +ده +و +دو +نخستين +ولي +چرا +چه +وسط +ه +كدام +قابل +يك +رفت +هفت +همچنين +در +هزار +بله +بلي +شايد +اما +شناسي +گرفته +دهد +داشته +دانست +داشتن +خواهيم +ميليارد +وقتيكه +امد +خواهد +جز +اورده +شده +بلكه +خدمات +شدن +برخي +نبود +بسياري +جلوگيري +حق +كردند +نوعي +بعري +نكرده +نظير +نبايد +بوده +بودن +داد +اورد +هست +جايي +شود +دنبال +داده +بايد +سابق +هيچ +همان +انجا +كمتر +كجاست +گردد +كسي +تر +مردم +تان +دادن +بودند +سري +جدا +ندارند +مگر +يكديگر +دارد +دهند +بنابراين +هنگامي +سمت +جا +انچه +خود +دادند +زياد +دارند +اثر +بدون +بهترين +بيشتر +البته +به +براساس +بيرون +كرد +بعضي +گرفت +توي +اي +ميليون +او +جريان +تول +بر +مانند +برابر +باشيم +مدتي +گويند +اكنون +تا +تنها +جديد +چند +بي +نشده +كردن +كردم +گويد +كرده +كنيم +نمي +نزد +روي +قصد +فقط +بالاي +ديگران +اين +ديروز +توسط +سوم +ايم +دانند +سوي +استفاده +شما +كنار +داريم +ساخته +طور +امده +رفته +نخست +بيست +نزديك +طي +كنيد +از +انها +تمامي +داشت +يكي +طريق +اش +چيست +روب +نمايد +گفت +چندين +چيزي +تواند +ام +ايا +با +ان +ايد +ترين +اينكه +ديگري +راه +هايي +بروز +همچنان +پاعين +كس +حدود +مختلف +مقابل +چيز +گيرد +ندارد +ضد +همچون +سازي +شان +مورد +باره +مرسي +خويش +برخوردار +چون +خارج +شش +هنوز +تحت +ضمن +هستيم +گفته +فكر +بسيار +پيش +براي +روزهاي +انكه +نخواهد +بالا +كل +وقتي +كي +چنين +كه +گيري +نيست +است +كجا +كند +نيز +يابد +بندي +حتي +توانند +عقب +خواست +كنند +بين +تمام +همه +ما +باشند +مثل +شد +اري +باشد +اره +طبق +بعد +اگر +صورت +غير +جاي +بيش +ريزي +اند +زيرا +چگونه +بار +لطفا +مي +درباره +من +ديده +همين +گذاري +برداري +علت +گذاشته +هم +فوق +نه +ها +شوند +اباد +همواره +هر +اول +خواهند +چهار +نام +امروز +مان +هاي +قبل +كنم +سعي +تازه +را +هستند +زير +جلوي +عنوان +بود diff --git a/resources/cache/empty/class/conf/lang/stopwords_fi.txt b/resources/cache/empty/class/conf/lang/stopwords_fi.txt index 4d70da3b..4372c9a0 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_fi.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_fi.txt @@ -1,97 +1,97 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/finnish/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - -| forms of BE - -olla -olen -olet -on -olemme -olette -ovat -ole | negative form - -oli -olisi -olisit -olisin -olisimme -olisitte -olisivat -olit -olin -olimme -olitte -olivat -ollut -olleet - -en | negation -et -ei -emme -ette -eivät - -|Nom Gen Acc Part Iness Elat Illat Adess Ablat Allat Ess Trans -minä minun minut minua minussa minusta minuun minulla minulta minulle | I -sinä sinun sinut sinua sinussa sinusta sinuun sinulla sinulta sinulle | you -hän hänen hänet häntä hänessä hänestä häneen hänellä häneltä hänelle | he she -me meidän meidät meitä meissä meistä meihin meillä meiltä meille | we -te teidän teidät teitä teissä teistä teihin teillä teiltä teille | you -he heidän heidät heitä heissä heistä heihin heillä heiltä heille | they - -tämä tämän tätä tässä tästä tähän tallä tältä tälle tänä täksi | this -tuo tuon tuotä tuossa tuosta tuohon tuolla tuolta tuolle tuona tuoksi | that -se sen sitä siinä siitä siihen sillä siltä sille sinä siksi | it -nämä näiden näitä näissä näistä näihin näillä näiltä näille näinä näiksi | these -nuo noiden noita noissa noista noihin noilla noilta noille noina noiksi | those -ne niiden niitä niissä niistä niihin niillä niiltä niille niinä niiksi | they - -kuka kenen kenet ketä kenessä kenestä keneen kenellä keneltä kenelle kenenä keneksi| who -ketkä keiden ketkä keitä keissä keistä keihin keillä keiltä keille keinä keiksi | (pl) -mikä minkä minkä mitä missä mistä mihin millä miltä mille minä miksi | which what -mitkä | (pl) - -joka jonka jota jossa josta johon jolla jolta jolle jona joksi | who which -jotka joiden joita joissa joista joihin joilla joilta joille joina joiksi | (pl) - -| conjunctions - -että | that -ja | and -jos | if -koska | because -kuin | than -mutta | but -niin | so -sekä | and -sillä | for -tai | or -vaan | but -vai | or -vaikka | although - - -| prepositions - -kanssa | with -mukaan | according to -noin | about -poikki | across -yli | over, across - -| other - -kun | when -niin | so -nyt | now -itse | self - + | From svn.tartarus.org/snowball/trunk/website/algorithms/finnish/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + +| forms of BE + +olla +olen +olet +on +olemme +olette +ovat +ole | negative form + +oli +olisi +olisit +olisin +olisimme +olisitte +olisivat +olit +olin +olimme +olitte +olivat +ollut +olleet + +en | negation +et +ei +emme +ette +eivät + +|Nom Gen Acc Part Iness Elat Illat Adess Ablat Allat Ess Trans +minä minun minut minua minussa minusta minuun minulla minulta minulle | I +sinä sinun sinut sinua sinussa sinusta sinuun sinulla sinulta sinulle | you +hän hänen hänet häntä hänessä hänestä häneen hänellä häneltä hänelle | he she +me meidän meidät meitä meissä meistä meihin meillä meiltä meille | we +te teidän teidät teitä teissä teistä teihin teillä teiltä teille | you +he heidän heidät heitä heissä heistä heihin heillä heiltä heille | they + +tämä tämän tätä tässä tästä tähän tallä tältä tälle tänä täksi | this +tuo tuon tuotä tuossa tuosta tuohon tuolla tuolta tuolle tuona tuoksi | that +se sen sitä siinä siitä siihen sillä siltä sille sinä siksi | it +nämä näiden näitä näissä näistä näihin näillä näiltä näille näinä näiksi | these +nuo noiden noita noissa noista noihin noilla noilta noille noina noiksi | those +ne niiden niitä niissä niistä niihin niillä niiltä niille niinä niiksi | they + +kuka kenen kenet ketä kenessä kenestä keneen kenellä keneltä kenelle kenenä keneksi| who +ketkä keiden ketkä keitä keissä keistä keihin keillä keiltä keille keinä keiksi | (pl) +mikä minkä minkä mitä missä mistä mihin millä miltä mille minä miksi | which what +mitkä | (pl) + +joka jonka jota jossa josta johon jolla jolta jolle jona joksi | who which +jotka joiden joita joissa joista joihin joilla joilta joille joina joiksi | (pl) + +| conjunctions + +että | that +ja | and +jos | if +koska | because +kuin | than +mutta | but +niin | so +sekä | and +sillä | for +tai | or +vaan | but +vai | or +vaikka | although + + +| prepositions + +kanssa | with +mukaan | according to +noin | about +poikki | across +yli | over, across + +| other + +kun | when +niin | so +nyt | now +itse | self + diff --git a/resources/cache/empty/class/conf/lang/stopwords_fr.txt b/resources/cache/empty/class/conf/lang/stopwords_fr.txt index fec33952..749abae6 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_fr.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_fr.txt @@ -1,186 +1,186 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/french/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A French stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - -au | a + le -aux | a + les -avec | with -ce | this -ces | these -dans | with -de | of -des | de + les -du | de + le -elle | she -en | `of them' etc -et | and -eux | them -il | he -je | I -la | the -le | the -leur | their -lui | him -ma | my (fem) -mais | but -me | me -même | same; as in moi-même (myself) etc -mes | me (pl) -moi | me -mon | my (masc) -ne | not -nos | our (pl) -notre | our -nous | we -on | one -ou | where -par | by -pas | not -pour | for -qu | que before vowel -que | that -qui | who -sa | his, her (fem) -se | oneself -ses | his (pl) -son | his, her (masc) -sur | on -ta | thy (fem) -te | thee -tes | thy (pl) -toi | thee -ton | thy (masc) -tu | thou -un | a -une | a -vos | your (pl) -votre | your -vous | you - - | single letter forms - -c | c' -d | d' -j | j' -l | l' -à | to, at -m | m' -n | n' -s | s' -t | t' -y | there - - | forms of être (not including the infinitive): -été -étée -étées -étés -étant -suis -es -est -sommes -êtes -sont -serai -seras -sera -serons -serez -seront -serais -serait -serions -seriez -seraient -étais -était -étions -étiez -étaient -fus -fut -fûmes -fûtes -furent -sois -soit -soyons -soyez -soient -fusse -fusses -fût -fussions -fussiez -fussent - - | forms of avoir (not including the infinitive): -ayant -eu -eue -eues -eus -ai -as -avons -avez -ont -aurai -auras -aura -aurons -aurez -auront -aurais -aurait -aurions -auriez -auraient -avais -avait -avions -aviez -avaient -eut -eûmes -eûtes -eurent -aie -aies -ait -ayons -ayez -aient -eusse -eusses -eût -eussions -eussiez -eussent - - | Later additions (from Jean-Christophe Deschamps) -ceci | this -cela | that -celà | that -cet | this -cette | this -ici | here -ils | they -les | the (pl) -leurs | their (pl) -quel | which -quels | which -quelle | which -quelles | which -sans | without -soi | oneself - + | From svn.tartarus.org/snowball/trunk/website/algorithms/french/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A French stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + +au | a + le +aux | a + les +avec | with +ce | this +ces | these +dans | with +de | of +des | de + les +du | de + le +elle | she +en | `of them' etc +et | and +eux | them +il | he +je | I +la | the +le | the +leur | their +lui | him +ma | my (fem) +mais | but +me | me +même | same; as in moi-même (myself) etc +mes | me (pl) +moi | me +mon | my (masc) +ne | not +nos | our (pl) +notre | our +nous | we +on | one +ou | where +par | by +pas | not +pour | for +qu | que before vowel +que | that +qui | who +sa | his, her (fem) +se | oneself +ses | his (pl) +son | his, her (masc) +sur | on +ta | thy (fem) +te | thee +tes | thy (pl) +toi | thee +ton | thy (masc) +tu | thou +un | a +une | a +vos | your (pl) +votre | your +vous | you + + | single letter forms + +c | c' +d | d' +j | j' +l | l' +à | to, at +m | m' +n | n' +s | s' +t | t' +y | there + + | forms of être (not including the infinitive): +été +étée +étées +étés +étant +suis +es +est +sommes +êtes +sont +serai +seras +sera +serons +serez +seront +serais +serait +serions +seriez +seraient +étais +était +étions +étiez +étaient +fus +fut +fûmes +fûtes +furent +sois +soit +soyons +soyez +soient +fusse +fusses +fût +fussions +fussiez +fussent + + | forms of avoir (not including the infinitive): +ayant +eu +eue +eues +eus +ai +as +avons +avez +ont +aurai +auras +aura +aurons +aurez +auront +aurais +aurait +aurions +auriez +auraient +avais +avait +avions +aviez +avaient +eut +eûmes +eûtes +eurent +aie +aies +ait +ayons +ayez +aient +eusse +eusses +eût +eussions +eussiez +eussent + + | Later additions (from Jean-Christophe Deschamps) +ceci | this +cela | that +celà | that +cet | this +cette | this +ici | here +ils | they +les | the (pl) +leurs | their (pl) +quel | which +quels | which +quelle | which +quelles | which +sans | without +soi | oneself + diff --git a/resources/cache/empty/class/conf/lang/stopwords_ga.txt b/resources/cache/empty/class/conf/lang/stopwords_ga.txt index f03e10a9..9ff88d74 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_ga.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_ga.txt @@ -1,110 +1,110 @@ - -a -ach -ag -agus -an -aon -ar -arna -as -b' -ba -beirt -bhúr -caoga -ceathair -ceathrar -chomh -chtó -chuig -chun -cois -céad -cúig -cúigear -d' -daichead -dar -de -deich -deichniúr -den -dhá -do -don -dtí -dá -dár -dó -faoi -faoin -faoina -faoinár -fara -fiche -gach -gan -go -gur -haon -hocht -i -iad -idir -in -ina -ins -inár -is -le -leis -lena -lenár -m' -mar -mo -mé -na -nach -naoi -naonúr -ná -ní -níor -nó -nócha -ocht -ochtar -os -roimh -sa -seacht -seachtar -seachtó -seasca -seisear -siad -sibh -sinn -sna -sé -sí -tar -thar -thú -triúr -trí -trína -trínár -tríocha -tú -um -ár -é -éis -í -ó -ón -óna -ónár + +a +ach +ag +agus +an +aon +ar +arna +as +b' +ba +beirt +bhúr +caoga +ceathair +ceathrar +chomh +chtó +chuig +chun +cois +céad +cúig +cúigear +d' +daichead +dar +de +deich +deichniúr +den +dhá +do +don +dtí +dá +dár +dó +faoi +faoin +faoina +faoinár +fara +fiche +gach +gan +go +gur +haon +hocht +i +iad +idir +in +ina +ins +inár +is +le +leis +lena +lenár +m' +mar +mo +mé +na +nach +naoi +naonúr +ná +ní +níor +nó +nócha +ocht +ochtar +os +roimh +sa +seacht +seachtar +seachtó +seasca +seisear +siad +sibh +sinn +sna +sé +sí +tar +thar +thú +triúr +trí +trína +trínár +tríocha +tú +um +ár +é +éis +í +ó +ón +óna +ónár diff --git a/resources/cache/empty/class/conf/lang/stopwords_gl.txt b/resources/cache/empty/class/conf/lang/stopwords_gl.txt index 57803b31..d8760b12 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_gl.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_gl.txt @@ -1,161 +1,161 @@ -# galican stopwords -a -aínda -alí -aquel -aquela -aquelas -aqueles -aquilo -aquí -ao -aos -as -así -á -ben -cando -che -co -coa -comigo -con -connosco -contigo -convosco -coas -cos -cun -cuns -cunha -cunhas -da -dalgunha -dalgunhas -dalgún -dalgúns -das -de -del -dela -delas -deles -desde -deste -do -dos -dun -duns -dunha -dunhas -e -el -ela -elas -eles -en -era -eran -esa -esas -ese -eses -esta -estar -estaba -está -están -este -estes -estiven -estou -eu -é -facer -foi -foron -fun -había -hai -iso -isto -la -las -lle -lles -lo -los -mais -me -meu -meus -min -miña -miñas -moi -na -nas -neste -nin -no -non -nos -nosa -nosas -noso -nosos -nós -nun -nunha -nuns -nunhas -o -os -ou -ó -ós -para -pero -pode -pois -pola -polas -polo -polos -por -que -se -senón -ser -seu -seus -sexa -sido -sobre -súa -súas -tamén -tan -te -ten -teñen -teño -ter -teu -teus -ti -tido -tiña -tiven -túa -túas -un -unha -unhas -uns -vos -vosa -vosas -voso -vosos -vós +# galican stopwords +a +aínda +alí +aquel +aquela +aquelas +aqueles +aquilo +aquí +ao +aos +as +así +á +ben +cando +che +co +coa +comigo +con +connosco +contigo +convosco +coas +cos +cun +cuns +cunha +cunhas +da +dalgunha +dalgunhas +dalgún +dalgúns +das +de +del +dela +delas +deles +desde +deste +do +dos +dun +duns +dunha +dunhas +e +el +ela +elas +eles +en +era +eran +esa +esas +ese +eses +esta +estar +estaba +está +están +este +estes +estiven +estou +eu +é +facer +foi +foron +fun +había +hai +iso +isto +la +las +lle +lles +lo +los +mais +me +meu +meus +min +miña +miñas +moi +na +nas +neste +nin +no +non +nos +nosa +nosas +noso +nosos +nós +nun +nunha +nuns +nunhas +o +os +ou +ó +ós +para +pero +pode +pois +pola +polas +polo +polos +por +que +se +senón +ser +seu +seus +sexa +sido +sobre +súa +súas +tamén +tan +te +ten +teñen +teño +ter +teu +teus +ti +tido +tiña +tiven +túa +túas +un +unha +unhas +uns +vos +vosa +vosas +voso +vosos +vós diff --git a/resources/cache/empty/class/conf/lang/stopwords_hi.txt b/resources/cache/empty/class/conf/lang/stopwords_hi.txt index 1f19fd10..86286bb0 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_hi.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_hi.txt @@ -1,235 +1,235 @@ -# Also see http://www.opensource.org/licenses/bsd-license.html -# See http://members.unine.ch/jacques.savoy/clef/index.html. -# This file was created by Jacques Savoy and is distributed under the BSD license. -# Note: by default this file also contains forms normalized by HindiNormalizer -# for spelling variation (see section below), such that it can be used whether or -# not you enable that feature. When adding additional entries to this list, -# please add the normalized form as well. -अंदर -अत -अपना -अपनी -अपने -अभी -आदि -आप -इत्यादि -इन -इनका -इन्हीं -इन्हें -इन्हों -इस -इसका -इसकी -इसके -इसमें -इसी -इसे -उन -उनका -उनकी -उनके -उनको -उन्हीं -उन्हें -उन्हों -उस -उसके -उसी -उसे -एक -एवं -एस -ऐसे -और -कई -कर -करता -करते -करना -करने -करें -कहते -कहा -का -काफ़ी -कि -कितना -किन्हें -किन्हों -किया -किर -किस -किसी -किसे -की -कुछ -कुल -के -को -कोई -कौन -कौनसा -गया -घर -जब -जहाँ -जा -जितना -जिन -जिन्हें -जिन्हों -जिस -जिसे -जीधर -जैसा -जैसे -जो -तक -तब -तरह -तिन -तिन्हें -तिन्हों -तिस -तिसे -तो -था -थी -थे -दबारा -दिया -दुसरा -दूसरे -दो -द्वारा -न -नहीं -ना -निहायत -नीचे -ने -पर -पर -पहले -पूरा -पे -फिर -बनी -बही -बहुत -बाद -बाला -बिलकुल -भी -भीतर -मगर -मानो -मे -में -यदि -यह -यहाँ -यही -या -यिह -ये -रखें -रहा -रहे -ऱ्वासा -लिए -लिये -लेकिन -व -वर्ग -वह -वह -वहाँ -वहीं -वाले -वुह -वे -वग़ैरह -संग -सकता -सकते -सबसे -सभी -साथ -साबुत -साभ -सारा -से -सो -ही -हुआ -हुई -हुए -है -हैं -हो -होता -होती -होते -होना -होने -# additional normalized forms of the above -अपनि -जेसे -होति -सभि -तिंहों -इंहों -दवारा -इसि -किंहें -थि -उंहों -ओर -जिंहें -वहिं -अभि -बनि -हि -उंहिं -उंहें -हें -वगेरह -एसे -रवासा -कोन -निचे -काफि -उसि -पुरा -भितर -हे -बहि -वहां -कोइ -यहां -जिंहों -तिंहें -किसि -कइ -यहि -इंहिं -जिधर -इंहें -अदि -इतयादि -हुइ -कोनसा -इसकि -दुसरे -जहां -अप -किंहों -उनकि -भि -वरग -हुअ -जेसा -नहिं +# Also see http://www.opensource.org/licenses/bsd-license.html +# See http://members.unine.ch/jacques.savoy/clef/index.html. +# This file was created by Jacques Savoy and is distributed under the BSD license. +# Note: by default this file also contains forms normalized by HindiNormalizer +# for spelling variation (see section below), such that it can be used whether or +# not you enable that feature. When adding additional entries to this list, +# please add the normalized form as well. +अंदर +अत +अपना +अपनी +अपने +अभी +आदि +आप +इत्यादि +इन +इनका +इन्हीं +इन्हें +इन्हों +इस +इसका +इसकी +इसके +इसमें +इसी +इसे +उन +उनका +उनकी +उनके +उनको +उन्हीं +उन्हें +उन्हों +उस +उसके +उसी +उसे +एक +एवं +एस +ऐसे +और +कई +कर +करता +करते +करना +करने +करें +कहते +कहा +का +काफ़ी +कि +कितना +किन्हें +किन्हों +किया +किर +किस +किसी +किसे +की +कुछ +कुल +के +को +कोई +कौन +कौनसा +गया +घर +जब +जहाँ +जा +जितना +जिन +जिन्हें +जिन्हों +जिस +जिसे +जीधर +जैसा +जैसे +जो +तक +तब +तरह +तिन +तिन्हें +तिन्हों +तिस +तिसे +तो +था +थी +थे +दबारा +दिया +दुसरा +दूसरे +दो +द्वारा +न +नहीं +ना +निहायत +नीचे +ने +पर +पर +पहले +पूरा +पे +फिर +बनी +बही +बहुत +बाद +बाला +बिलकुल +भी +भीतर +मगर +मानो +मे +में +यदि +यह +यहाँ +यही +या +यिह +ये +रखें +रहा +रहे +ऱ्वासा +लिए +लिये +लेकिन +व +वर्ग +वह +वह +वहाँ +वहीं +वाले +वुह +वे +वग़ैरह +संग +सकता +सकते +सबसे +सभी +साथ +साबुत +साभ +सारा +से +सो +ही +हुआ +हुई +हुए +है +हैं +हो +होता +होती +होते +होना +होने +# additional normalized forms of the above +अपनि +जेसे +होति +सभि +तिंहों +इंहों +दवारा +इसि +किंहें +थि +उंहों +ओर +जिंहें +वहिं +अभि +बनि +हि +उंहिं +उंहें +हें +वगेरह +एसे +रवासा +कोन +निचे +काफि +उसि +पुरा +भितर +हे +बहि +वहां +कोइ +यहां +जिंहों +तिंहें +किसि +कइ +यहि +इंहिं +जिधर +इंहें +अदि +इतयादि +हुइ +कोनसा +इसकि +दुसरे +जहां +अप +किंहों +उनकि +भि +वरग +हुअ +जेसा +नहिं diff --git a/resources/cache/empty/class/conf/lang/stopwords_hu.txt b/resources/cache/empty/class/conf/lang/stopwords_hu.txt index f5bf755b..37526da8 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_hu.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_hu.txt @@ -1,211 +1,211 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/hungarian/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - -| Hungarian stop word list -| prepared by Anna Tordai - -a -ahogy -ahol -aki -akik -akkor -alatt -által -általában -amely -amelyek -amelyekben -amelyeket -amelyet -amelynek -ami -amit -amolyan -amíg -amikor -át -abban -ahhoz -annak -arra -arról -az -azok -azon -azt -azzal -azért -aztán -azután -azonban -bár -be -belül -benne -cikk -cikkek -cikkeket -csak -de -e -eddig -egész -egy -egyes -egyetlen -egyéb -egyik -egyre -ekkor -el -elég -ellen -elő -először -előtt -első -én -éppen -ebben -ehhez -emilyen -ennek -erre -ez -ezt -ezek -ezen -ezzel -ezért -és -fel -felé -hanem -hiszen -hogy -hogyan -igen -így -illetve -ill. -ill -ilyen -ilyenkor -ison -ismét -itt -jó -jól -jobban -kell -kellett -keresztül -keressünk -ki -kívül -között -közül -legalább -lehet -lehetett -legyen -lenne -lenni -lesz -lett -maga -magát -majd -majd -már -más -másik -meg -még -mellett -mert -mely -melyek -mi -mit -míg -miért -milyen -mikor -minden -mindent -mindenki -mindig -mint -mintha -mivel -most -nagy -nagyobb -nagyon -ne -néha -nekem -neki -nem -néhány -nélkül -nincs -olyan -ott -össze -ő -ők -őket -pedig -persze -rá -s -saját -sem -semmi -sok -sokat -sokkal -számára -szemben -szerint -szinte -talán -tehát -teljes -tovább -továbbá -több -úgy -ugyanis -új -újabb -újra -után -utána -utolsó -vagy -vagyis -valaki -valami -valamint -való -vagyok -van -vannak -volt -voltam -voltak -voltunk -vissza -vele -viszont -volna + | From svn.tartarus.org/snowball/trunk/website/algorithms/hungarian/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + +| Hungarian stop word list +| prepared by Anna Tordai + +a +ahogy +ahol +aki +akik +akkor +alatt +által +általában +amely +amelyek +amelyekben +amelyeket +amelyet +amelynek +ami +amit +amolyan +amíg +amikor +át +abban +ahhoz +annak +arra +arról +az +azok +azon +azt +azzal +azért +aztán +azután +azonban +bár +be +belül +benne +cikk +cikkek +cikkeket +csak +de +e +eddig +egész +egy +egyes +egyetlen +egyéb +egyik +egyre +ekkor +el +elég +ellen +elő +először +előtt +első +én +éppen +ebben +ehhez +emilyen +ennek +erre +ez +ezt +ezek +ezen +ezzel +ezért +és +fel +felé +hanem +hiszen +hogy +hogyan +igen +így +illetve +ill. +ill +ilyen +ilyenkor +ison +ismét +itt +jó +jól +jobban +kell +kellett +keresztül +keressünk +ki +kívül +között +közül +legalább +lehet +lehetett +legyen +lenne +lenni +lesz +lett +maga +magát +majd +majd +már +más +másik +meg +még +mellett +mert +mely +melyek +mi +mit +míg +miért +milyen +mikor +minden +mindent +mindenki +mindig +mint +mintha +mivel +most +nagy +nagyobb +nagyon +ne +néha +nekem +neki +nem +néhány +nélkül +nincs +olyan +ott +össze +ő +ők +őket +pedig +persze +rá +s +saját +sem +semmi +sok +sokat +sokkal +számára +szemben +szerint +szinte +talán +tehát +teljes +tovább +továbbá +több +úgy +ugyanis +új +újabb +újra +után +utána +utolsó +vagy +vagyis +valaki +valami +valamint +való +vagyok +van +vannak +volt +voltam +voltak +voltunk +vissza +vele +viszont +volna diff --git a/resources/cache/empty/class/conf/lang/stopwords_hy.txt b/resources/cache/empty/class/conf/lang/stopwords_hy.txt index 968a8f4a..60c1c50f 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_hy.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_hy.txt @@ -1,46 +1,46 @@ -# example set of Armenian stopwords. -այդ -այլ -այն -այս -դու -դուք -եմ -են -ենք -ես -եք -է -էի -էին -էինք -էիր -էիք -էր -ըստ -թ -ի -ին -իսկ -իր -կամ -համար -հետ -հետո -մենք -մեջ -մի -ն -նա -նաև -նրա -նրանք -որ -որը -որոնք -որպես -ու -ում -պիտի -վրա -և +# example set of Armenian stopwords. +այդ +այլ +այն +այս +դու +դուք +եմ +են +ենք +ես +եք +է +էի +էին +էինք +էիր +էիք +էր +ըստ +թ +ի +ին +իսկ +իր +կամ +համար +հետ +հետո +մենք +մեջ +մի +ն +նա +նաև +նրա +նրանք +որ +որը +որոնք +որպես +ու +ում +պիտի +վրա +և diff --git a/resources/cache/empty/class/conf/lang/stopwords_id.txt b/resources/cache/empty/class/conf/lang/stopwords_id.txt index 80df39a3..4617f83a 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_id.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_id.txt @@ -1,359 +1,359 @@ -# from appendix D of: A Study of Stemming Effects on Information -# Retrieval in Bahasa Indonesia -ada -adanya -adalah -adapun -agak -agaknya -agar -akan -akankah -akhirnya -aku -akulah -amat -amatlah -anda -andalah -antar -diantaranya -antara -antaranya -diantara -apa -apaan -mengapa -apabila -apakah -apalagi -apatah -atau -ataukah -ataupun -bagai -bagaikan -sebagai -sebagainya -bagaimana -bagaimanapun -sebagaimana -bagaimanakah -bagi -bahkan -bahwa -bahwasanya -sebaliknya -banyak -sebanyak -beberapa -seberapa -begini -beginian -beginikah -beginilah -sebegini -begitu -begitukah -begitulah -begitupun -sebegitu -belum -belumlah -sebelum -sebelumnya -sebenarnya -berapa -berapakah -berapalah -berapapun -betulkah -sebetulnya -biasa -biasanya -bila -bilakah -bisa -bisakah -sebisanya -boleh -bolehkah -bolehlah -buat -bukan -bukankah -bukanlah -bukannya -cuma -percuma -dahulu -dalam -dan -dapat -dari -daripada -dekat -demi -demikian -demikianlah -sedemikian -dengan -depan -di -dia -dialah -dini -diri -dirinya -terdiri -dong -dulu -enggak -enggaknya -entah -entahlah -terhadap -terhadapnya -hal -hampir -hanya -hanyalah -harus -haruslah -harusnya -seharusnya -hendak -hendaklah -hendaknya -hingga -sehingga -ia -ialah -ibarat -ingin -inginkah -inginkan -ini -inikah -inilah -itu -itukah -itulah -jangan -jangankan -janganlah -jika -jikalau -juga -justru -kala -kalau -kalaulah -kalaupun -kalian -kami -kamilah -kamu -kamulah -kan -kapan -kapankah -kapanpun -dikarenakan -karena -karenanya -ke -kecil -kemudian -kenapa -kepada -kepadanya -ketika -seketika -khususnya -kini -kinilah -kiranya -sekiranya -kita -kitalah -kok -lagi -lagian -selagi -lah -lain -lainnya -melainkan -selaku -lalu -melalui -terlalu -lama -lamanya -selama -selama -selamanya -lebih -terlebih -bermacam -macam -semacam -maka -makanya -makin -malah -malahan -mampu -mampukah -mana -manakala -manalagi -masih -masihkah -semasih -masing -mau -maupun -semaunya -memang -mereka -merekalah -meski -meskipun -semula -mungkin -mungkinkah -nah -namun -nanti -nantinya -nyaris -oleh -olehnya -seorang -seseorang -pada -padanya -padahal -paling -sepanjang -pantas -sepantasnya -sepantasnyalah -para -pasti -pastilah -per -pernah -pula -pun -merupakan -rupanya -serupa -saat -saatnya -sesaat -saja -sajalah -saling -bersama -sama -sesama -sambil -sampai -sana -sangat -sangatlah -saya -sayalah -se -sebab -sebabnya -sebuah -tersebut -tersebutlah -sedang -sedangkan -sedikit -sedikitnya -segala -segalanya -segera -sesegera -sejak -sejenak -sekali -sekalian -sekalipun -sesekali -sekaligus -sekarang -sekarang -sekitar -sekitarnya -sela -selain -selalu -seluruh -seluruhnya -semakin -sementara -sempat -semua -semuanya -sendiri -sendirinya -seolah -seperti -sepertinya -sering -seringnya -serta -siapa -siapakah -siapapun -disini -disinilah -sini -sinilah -sesuatu -sesuatunya -suatu -sesudah -sesudahnya -sudah -sudahkah -sudahlah -supaya -tadi -tadinya -tak -tanpa -setelah -telah -tentang -tentu -tentulah -tentunya -tertentu -seterusnya -tapi -tetapi -setiap -tiap -setidaknya -tidak -tidakkah -tidaklah -toh -waduh -wah -wahai -sewaktu -walau -walaupun -wong -yaitu -yakni -yang +# from appendix D of: A Study of Stemming Effects on Information +# Retrieval in Bahasa Indonesia +ada +adanya +adalah +adapun +agak +agaknya +agar +akan +akankah +akhirnya +aku +akulah +amat +amatlah +anda +andalah +antar +diantaranya +antara +antaranya +diantara +apa +apaan +mengapa +apabila +apakah +apalagi +apatah +atau +ataukah +ataupun +bagai +bagaikan +sebagai +sebagainya +bagaimana +bagaimanapun +sebagaimana +bagaimanakah +bagi +bahkan +bahwa +bahwasanya +sebaliknya +banyak +sebanyak +beberapa +seberapa +begini +beginian +beginikah +beginilah +sebegini +begitu +begitukah +begitulah +begitupun +sebegitu +belum +belumlah +sebelum +sebelumnya +sebenarnya +berapa +berapakah +berapalah +berapapun +betulkah +sebetulnya +biasa +biasanya +bila +bilakah +bisa +bisakah +sebisanya +boleh +bolehkah +bolehlah +buat +bukan +bukankah +bukanlah +bukannya +cuma +percuma +dahulu +dalam +dan +dapat +dari +daripada +dekat +demi +demikian +demikianlah +sedemikian +dengan +depan +di +dia +dialah +dini +diri +dirinya +terdiri +dong +dulu +enggak +enggaknya +entah +entahlah +terhadap +terhadapnya +hal +hampir +hanya +hanyalah +harus +haruslah +harusnya +seharusnya +hendak +hendaklah +hendaknya +hingga +sehingga +ia +ialah +ibarat +ingin +inginkah +inginkan +ini +inikah +inilah +itu +itukah +itulah +jangan +jangankan +janganlah +jika +jikalau +juga +justru +kala +kalau +kalaulah +kalaupun +kalian +kami +kamilah +kamu +kamulah +kan +kapan +kapankah +kapanpun +dikarenakan +karena +karenanya +ke +kecil +kemudian +kenapa +kepada +kepadanya +ketika +seketika +khususnya +kini +kinilah +kiranya +sekiranya +kita +kitalah +kok +lagi +lagian +selagi +lah +lain +lainnya +melainkan +selaku +lalu +melalui +terlalu +lama +lamanya +selama +selama +selamanya +lebih +terlebih +bermacam +macam +semacam +maka +makanya +makin +malah +malahan +mampu +mampukah +mana +manakala +manalagi +masih +masihkah +semasih +masing +mau +maupun +semaunya +memang +mereka +merekalah +meski +meskipun +semula +mungkin +mungkinkah +nah +namun +nanti +nantinya +nyaris +oleh +olehnya +seorang +seseorang +pada +padanya +padahal +paling +sepanjang +pantas +sepantasnya +sepantasnyalah +para +pasti +pastilah +per +pernah +pula +pun +merupakan +rupanya +serupa +saat +saatnya +sesaat +saja +sajalah +saling +bersama +sama +sesama +sambil +sampai +sana +sangat +sangatlah +saya +sayalah +se +sebab +sebabnya +sebuah +tersebut +tersebutlah +sedang +sedangkan +sedikit +sedikitnya +segala +segalanya +segera +sesegera +sejak +sejenak +sekali +sekalian +sekalipun +sesekali +sekaligus +sekarang +sekarang +sekitar +sekitarnya +sela +selain +selalu +seluruh +seluruhnya +semakin +sementara +sempat +semua +semuanya +sendiri +sendirinya +seolah +seperti +sepertinya +sering +seringnya +serta +siapa +siapakah +siapapun +disini +disinilah +sini +sinilah +sesuatu +sesuatunya +suatu +sesudah +sesudahnya +sudah +sudahkah +sudahlah +supaya +tadi +tadinya +tak +tanpa +setelah +telah +tentang +tentu +tentulah +tentunya +tertentu +seterusnya +tapi +tetapi +setiap +tiap +setidaknya +tidak +tidakkah +tidaklah +toh +waduh +wah +wahai +sewaktu +walau +walaupun +wong +yaitu +yakni +yang diff --git a/resources/cache/empty/class/conf/lang/stopwords_it.txt b/resources/cache/empty/class/conf/lang/stopwords_it.txt index 3b20c0ab..1219cc77 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_it.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_it.txt @@ -1,303 +1,303 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/italian/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | An Italian stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - -ad | a (to) before vowel -al | a + il -allo | a + lo -ai | a + i -agli | a + gli -all | a + l' -agl | a + gl' -alla | a + la -alle | a + le -con | with -col | con + il -coi | con + i (forms collo, cogli etc are now very rare) -da | from -dal | da + il -dallo | da + lo -dai | da + i -dagli | da + gli -dall | da + l' -dagl | da + gll' -dalla | da + la -dalle | da + le -di | of -del | di + il -dello | di + lo -dei | di + i -degli | di + gli -dell | di + l' -degl | di + gl' -della | di + la -delle | di + le -in | in -nel | in + el -nello | in + lo -nei | in + i -negli | in + gli -nell | in + l' -negl | in + gl' -nella | in + la -nelle | in + le -su | on -sul | su + il -sullo | su + lo -sui | su + i -sugli | su + gli -sull | su + l' -sugl | su + gl' -sulla | su + la -sulle | su + le -per | through, by -tra | among -contro | against -io | I -tu | thou -lui | he -lei | she -noi | we -voi | you -loro | they -mio | my -mia | -miei | -mie | -tuo | -tua | -tuoi | thy -tue | -suo | -sua | -suoi | his, her -sue | -nostro | our -nostra | -nostri | -nostre | -vostro | your -vostra | -vostri | -vostre | -mi | me -ti | thee -ci | us, there -vi | you, there -lo | him, the -la | her, the -li | them -le | them, the -gli | to him, the -ne | from there etc -il | the -un | a -uno | a -una | a -ma | but -ed | and -se | if -perché | why, because -anche | also -come | how -dov | where (as dov') -dove | where -che | who, that -chi | who -cui | whom -non | not -più | more -quale | who, that -quanto | how much -quanti | -quanta | -quante | -quello | that -quelli | -quella | -quelle | -questo | this -questi | -questa | -queste | -si | yes -tutto | all -tutti | all - - | single letter forms: - -a | at -c | as c' for ce or ci -e | and -i | the -l | as l' -o | or - - | forms of avere, to have (not including the infinitive): - -ho -hai -ha -abbiamo -avete -hanno -abbia -abbiate -abbiano -avrò -avrai -avrà -avremo -avrete -avranno -avrei -avresti -avrebbe -avremmo -avreste -avrebbero -avevo -avevi -aveva -avevamo -avevate -avevano -ebbi -avesti -ebbe -avemmo -aveste -ebbero -avessi -avesse -avessimo -avessero -avendo -avuto -avuta -avuti -avute - - | forms of essere, to be (not including the infinitive): -sono -sei -è -siamo -siete -sia -siate -siano -sarò -sarai -sarà -saremo -sarete -saranno -sarei -saresti -sarebbe -saremmo -sareste -sarebbero -ero -eri -era -eravamo -eravate -erano -fui -fosti -fu -fummo -foste -furono -fossi -fosse -fossimo -fossero -essendo - - | forms of fare, to do (not including the infinitive, fa, fat-): -faccio -fai -facciamo -fanno -faccia -facciate -facciano -farò -farai -farà -faremo -farete -faranno -farei -faresti -farebbe -faremmo -fareste -farebbero -facevo -facevi -faceva -facevamo -facevate -facevano -feci -facesti -fece -facemmo -faceste -fecero -facessi -facesse -facessimo -facessero -facendo - - | forms of stare, to be (not including the infinitive): -sto -stai -sta -stiamo -stanno -stia -stiate -stiano -starò -starai -starà -staremo -starete -staranno -starei -staresti -starebbe -staremmo -stareste -starebbero -stavo -stavi -stava -stavamo -stavate -stavano -stetti -stesti -stette -stemmo -steste -stettero -stessi -stesse -stessimo -stessero -stando + | From svn.tartarus.org/snowball/trunk/website/algorithms/italian/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | An Italian stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + +ad | a (to) before vowel +al | a + il +allo | a + lo +ai | a + i +agli | a + gli +all | a + l' +agl | a + gl' +alla | a + la +alle | a + le +con | with +col | con + il +coi | con + i (forms collo, cogli etc are now very rare) +da | from +dal | da + il +dallo | da + lo +dai | da + i +dagli | da + gli +dall | da + l' +dagl | da + gll' +dalla | da + la +dalle | da + le +di | of +del | di + il +dello | di + lo +dei | di + i +degli | di + gli +dell | di + l' +degl | di + gl' +della | di + la +delle | di + le +in | in +nel | in + el +nello | in + lo +nei | in + i +negli | in + gli +nell | in + l' +negl | in + gl' +nella | in + la +nelle | in + le +su | on +sul | su + il +sullo | su + lo +sui | su + i +sugli | su + gli +sull | su + l' +sugl | su + gl' +sulla | su + la +sulle | su + le +per | through, by +tra | among +contro | against +io | I +tu | thou +lui | he +lei | she +noi | we +voi | you +loro | they +mio | my +mia | +miei | +mie | +tuo | +tua | +tuoi | thy +tue | +suo | +sua | +suoi | his, her +sue | +nostro | our +nostra | +nostri | +nostre | +vostro | your +vostra | +vostri | +vostre | +mi | me +ti | thee +ci | us, there +vi | you, there +lo | him, the +la | her, the +li | them +le | them, the +gli | to him, the +ne | from there etc +il | the +un | a +uno | a +una | a +ma | but +ed | and +se | if +perché | why, because +anche | also +come | how +dov | where (as dov') +dove | where +che | who, that +chi | who +cui | whom +non | not +più | more +quale | who, that +quanto | how much +quanti | +quanta | +quante | +quello | that +quelli | +quella | +quelle | +questo | this +questi | +questa | +queste | +si | yes +tutto | all +tutti | all + + | single letter forms: + +a | at +c | as c' for ce or ci +e | and +i | the +l | as l' +o | or + + | forms of avere, to have (not including the infinitive): + +ho +hai +ha +abbiamo +avete +hanno +abbia +abbiate +abbiano +avrò +avrai +avrà +avremo +avrete +avranno +avrei +avresti +avrebbe +avremmo +avreste +avrebbero +avevo +avevi +aveva +avevamo +avevate +avevano +ebbi +avesti +ebbe +avemmo +aveste +ebbero +avessi +avesse +avessimo +avessero +avendo +avuto +avuta +avuti +avute + + | forms of essere, to be (not including the infinitive): +sono +sei +è +siamo +siete +sia +siate +siano +sarò +sarai +sarà +saremo +sarete +saranno +sarei +saresti +sarebbe +saremmo +sareste +sarebbero +ero +eri +era +eravamo +eravate +erano +fui +fosti +fu +fummo +foste +furono +fossi +fosse +fossimo +fossero +essendo + + | forms of fare, to do (not including the infinitive, fa, fat-): +faccio +fai +facciamo +fanno +faccia +facciate +facciano +farò +farai +farà +faremo +farete +faranno +farei +faresti +farebbe +faremmo +fareste +farebbero +facevo +facevi +faceva +facevamo +facevate +facevano +feci +facesti +fece +facemmo +faceste +fecero +facessi +facesse +facessimo +facessero +facendo + + | forms of stare, to be (not including the infinitive): +sto +stai +sta +stiamo +stanno +stia +stiate +stiano +starò +starai +starà +staremo +starete +staranno +starei +staresti +starebbe +staremmo +stareste +starebbero +stavo +stavi +stava +stavamo +stavate +stavano +stetti +stesti +stette +stemmo +steste +stettero +stessi +stesse +stessimo +stessero +stando diff --git a/resources/cache/empty/class/conf/lang/stopwords_ja.txt b/resources/cache/empty/class/conf/lang/stopwords_ja.txt index bc3077e5..d4321be6 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_ja.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_ja.txt @@ -1,127 +1,127 @@ -# -# This file defines a stopword set for Japanese. -# -# This set is made up of hand-picked frequent terms from segmented Japanese Wikipedia. -# Punctuation characters and frequent kanji have mostly been left out. See LUCENE-3745 -# for frequency lists, etc. that can be useful for making your own set (if desired) -# -# Note that there is an overlap between these stopwords and the terms stopped when used -# in combination with the JapanesePartOfSpeechStopFilter. When editing this file, note -# that comments are not allowed on the same line as stopwords. -# -# Also note that stopping is done in a case-insensitive manner. Change your StopFilter -# configuration if you need case-sensitive stopping. Lastly, note that stopping is done -# using the same character width as the entries in this file. Since this StopFilter is -# normally done after a CJKWidthFilter in your chain, you would usually want your romaji -# entries to be in half-width and your kana entries to be in full-width. -# -の -に -は -を -た -が -で -て -と -し -れ -さ -ある -いる -も -する -から -な -こと -として -い -や -れる -など -なっ -ない -この -ため -その -あっ -よう -また -もの -という -あり -まで -られ -なる -へ -か -だ -これ -によって -により -おり -より -による -ず -なり -られる -において -ば -なかっ -なく -しかし -について -せ -だっ -その後 -できる -それ -う -ので -なお -のみ -でき -き -つ -における -および -いう -さらに -でも -ら -たり -その他 -に関する -たち -ます -ん -なら -に対して -特に -せる -及び -これら -とき -では -にて -ほか -ながら -うち -そして -とともに -ただし -かつて -それぞれ -または -お -ほど -ものの -に対する -ほとんど -と共に -といった -です -とも -ところ -ここ -##### End of file +# +# This file defines a stopword set for Japanese. +# +# This set is made up of hand-picked frequent terms from segmented Japanese Wikipedia. +# Punctuation characters and frequent kanji have mostly been left out. See LUCENE-3745 +# for frequency lists, etc. that can be useful for making your own set (if desired) +# +# Note that there is an overlap between these stopwords and the terms stopped when used +# in combination with the JapanesePartOfSpeechStopFilter. When editing this file, note +# that comments are not allowed on the same line as stopwords. +# +# Also note that stopping is done in a case-insensitive manner. Change your StopFilter +# configuration if you need case-sensitive stopping. Lastly, note that stopping is done +# using the same character width as the entries in this file. Since this StopFilter is +# normally done after a CJKWidthFilter in your chain, you would usually want your romaji +# entries to be in half-width and your kana entries to be in full-width. +# +の +に +は +を +た +が +で +て +と +し +れ +さ +ある +いる +も +する +から +な +こと +として +い +や +れる +など +なっ +ない +この +ため +その +あっ +よう +また +もの +という +あり +まで +られ +なる +へ +か +だ +これ +によって +により +おり +より +による +ず +なり +られる +において +ば +なかっ +なく +しかし +について +せ +だっ +その後 +できる +それ +う +ので +なお +のみ +でき +き +つ +における +および +いう +さらに +でも +ら +たり +その他 +に関する +たち +ます +ん +なら +に対して +特に +せる +及び +これら +とき +では +にて +ほか +ながら +うち +そして +とともに +ただし +かつて +それぞれ +または +お +ほど +ものの +に対する +ほとんど +と共に +といった +です +とも +ところ +ここ +##### End of file diff --git a/resources/cache/empty/class/conf/lang/stopwords_lv.txt b/resources/cache/empty/class/conf/lang/stopwords_lv.txt index a4710974..e21a23c0 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_lv.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_lv.txt @@ -1,172 +1,172 @@ -# Set of Latvian stopwords from A Stemming Algorithm for Latvian, Karlis Kreslins -# the original list of over 800 forms was refined: -# pronouns, adverbs, interjections were removed -# -# prepositions -aiz -ap -ar -apakš -ārpus -augšpus -bez -caur -dēļ -gar -iekš -iz -kopš -labad -lejpus -līdz -no -otrpus -pa -par -pār -pēc -pie -pirms -pret -priekš -starp -šaipus -uz -viņpus -virs -virspus -zem -apakšpus -# Conjunctions -un -bet -jo -ja -ka -lai -tomēr -tikko -turpretī -arī -kaut -gan -tādēļ -tā -ne -tikvien -vien -kā -ir -te -vai -kamēr -# Particles -ar -diezin -droši -diemžēl -nebūt -ik -it -taču -nu -pat -tiklab -iekšpus -nedz -tik -nevis -turpretim -jeb -iekam -iekām -iekāms -kolīdz -līdzko -tiklīdz -jebšu -tālab -tāpēc -nekā -itin -jā -jau -jel -nē -nezin -tad -tikai -vis -tak -iekams -vien -# modal verbs -būt -biju -biji -bija -bijām -bijāt -esmu -esi -esam -esat -būšu -būsi -būs -būsim -būsiet -tikt -tiku -tiki -tika -tikām -tikāt -tieku -tiec -tiek -tiekam -tiekat -tikšu -tiks -tiksim -tiksiet -tapt -tapi -tapāt -topat -tapšu -tapsi -taps -tapsim -tapsiet -kļūt -kļuvu -kļuvi -kļuva -kļuvām -kļuvāt -kļūstu -kļūsti -kļūst -kļūstam -kļūstat -kļūšu -kļūsi -kļūs -kļūsim -kļūsiet -# verbs -varēt -varēju -varējām -varēšu -varēsim -var -varēji -varējāt -varēsi -varēsiet -varat -varēja -varēs +# Set of Latvian stopwords from A Stemming Algorithm for Latvian, Karlis Kreslins +# the original list of over 800 forms was refined: +# pronouns, adverbs, interjections were removed +# +# prepositions +aiz +ap +ar +apakš +ārpus +augšpus +bez +caur +dēļ +gar +iekš +iz +kopš +labad +lejpus +līdz +no +otrpus +pa +par +pār +pēc +pie +pirms +pret +priekš +starp +šaipus +uz +viņpus +virs +virspus +zem +apakšpus +# Conjunctions +un +bet +jo +ja +ka +lai +tomēr +tikko +turpretī +arī +kaut +gan +tādēļ +tā +ne +tikvien +vien +kā +ir +te +vai +kamēr +# Particles +ar +diezin +droši +diemžēl +nebūt +ik +it +taču +nu +pat +tiklab +iekšpus +nedz +tik +nevis +turpretim +jeb +iekam +iekām +iekāms +kolīdz +līdzko +tiklīdz +jebšu +tālab +tāpēc +nekā +itin +jā +jau +jel +nē +nezin +tad +tikai +vis +tak +iekams +vien +# modal verbs +būt +biju +biji +bija +bijām +bijāt +esmu +esi +esam +esat +būšu +būsi +būs +būsim +būsiet +tikt +tiku +tiki +tika +tikām +tikāt +tieku +tiec +tiek +tiekam +tiekat +tikšu +tiks +tiksim +tiksiet +tapt +tapi +tapāt +topat +tapšu +tapsi +taps +tapsim +tapsiet +kļūt +kļuvu +kļuvi +kļuva +kļuvām +kļuvāt +kļūstu +kļūsti +kļūst +kļūstam +kļūstat +kļūšu +kļūsi +kļūs +kļūsim +kļūsiet +# verbs +varēt +varēju +varējām +varēšu +varēsim +var +varēji +varējāt +varēsi +varēsiet +varat +varēja +varēs diff --git a/resources/cache/empty/class/conf/lang/stopwords_nl.txt b/resources/cache/empty/class/conf/lang/stopwords_nl.txt index 06ca75ba..47a2aeac 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_nl.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_nl.txt @@ -1,119 +1,119 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/dutch/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Dutch stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - | This is a ranked list (commonest to rarest) of stopwords derived from - | a large sample of Dutch text. - - | Dutch stop words frequently exhibit homonym clashes. These are indicated - | clearly below. - -de | the -en | and -van | of, from -ik | I, the ego -te | (1) chez, at etc, (2) to, (3) too -dat | that, which -die | that, those, who, which -in | in, inside -een | a, an, one -hij | he -het | the, it -niet | not, nothing, naught -zijn | (1) to be, being, (2) his, one's, its -is | is -was | (1) was, past tense of all persons sing. of 'zijn' (to be) (2) wax, (3) the washing, (4) rise of river -op | on, upon, at, in, up, used up -aan | on, upon, to (as dative) -met | with, by -als | like, such as, when -voor | (1) before, in front of, (2) furrow -had | had, past tense all persons sing. of 'hebben' (have) -er | there -maar | but, only -om | round, about, for etc -hem | him -dan | then -zou | should/would, past tense all persons sing. of 'zullen' -of | or, whether, if -wat | what, something, anything -mijn | possessive and noun 'mine' -men | people, 'one' -dit | this -zo | so, thus, in this way -door | through by -over | over, across -ze | she, her, they, them -zich | oneself -bij | (1) a bee, (2) by, near, at -ook | also, too -tot | till, until -je | you -mij | me -uit | out of, from -der | Old Dutch form of 'van der' still found in surnames -daar | (1) there, (2) because -haar | (1) her, their, them, (2) hair -naar | (1) unpleasant, unwell etc, (2) towards, (3) as -heb | present first person sing. of 'to have' -hoe | how, why -heeft | present third person sing. of 'to have' -hebben | 'to have' and various parts thereof -deze | this -u | you -want | (1) for, (2) mitten, (3) rigging -nog | yet, still -zal | 'shall', first and third person sing. of verb 'zullen' (will) -me | me -zij | she, they -nu | now -ge | 'thou', still used in Belgium and south Netherlands -geen | none -omdat | because -iets | something, somewhat -worden | to become, grow, get -toch | yet, still -al | all, every, each -waren | (1) 'were' (2) to wander, (3) wares, (3) -veel | much, many -meer | (1) more, (2) lake -doen | to do, to make -toen | then, when -moet | noun 'spot/mote' and present form of 'to must' -ben | (1) am, (2) 'are' in interrogative second person singular of 'to be' -zonder | without -kan | noun 'can' and present form of 'to be able' -hun | their, them -dus | so, consequently -alles | all, everything, anything -onder | under, beneath -ja | yes, of course -eens | once, one day -hier | here -wie | who -werd | imperfect third person sing. of 'become' -altijd | always -doch | yet, but etc -wordt | present third person sing. of 'become' -wezen | (1) to be, (2) 'been' as in 'been fishing', (3) orphans -kunnen | to be able -ons | us/our -zelf | self -tegen | against, towards, at -na | after, near -reeds | already -wil | (1) present tense of 'want', (2) 'will', noun, (3) fender -kon | could; past tense of 'to be able' -niets | nothing -uw | your -iemand | somebody -geweest | been; past participle of 'be' -andere | other + | From svn.tartarus.org/snowball/trunk/website/algorithms/dutch/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Dutch stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + | This is a ranked list (commonest to rarest) of stopwords derived from + | a large sample of Dutch text. + + | Dutch stop words frequently exhibit homonym clashes. These are indicated + | clearly below. + +de | the +en | and +van | of, from +ik | I, the ego +te | (1) chez, at etc, (2) to, (3) too +dat | that, which +die | that, those, who, which +in | in, inside +een | a, an, one +hij | he +het | the, it +niet | not, nothing, naught +zijn | (1) to be, being, (2) his, one's, its +is | is +was | (1) was, past tense of all persons sing. of 'zijn' (to be) (2) wax, (3) the washing, (4) rise of river +op | on, upon, at, in, up, used up +aan | on, upon, to (as dative) +met | with, by +als | like, such as, when +voor | (1) before, in front of, (2) furrow +had | had, past tense all persons sing. of 'hebben' (have) +er | there +maar | but, only +om | round, about, for etc +hem | him +dan | then +zou | should/would, past tense all persons sing. of 'zullen' +of | or, whether, if +wat | what, something, anything +mijn | possessive and noun 'mine' +men | people, 'one' +dit | this +zo | so, thus, in this way +door | through by +over | over, across +ze | she, her, they, them +zich | oneself +bij | (1) a bee, (2) by, near, at +ook | also, too +tot | till, until +je | you +mij | me +uit | out of, from +der | Old Dutch form of 'van der' still found in surnames +daar | (1) there, (2) because +haar | (1) her, their, them, (2) hair +naar | (1) unpleasant, unwell etc, (2) towards, (3) as +heb | present first person sing. of 'to have' +hoe | how, why +heeft | present third person sing. of 'to have' +hebben | 'to have' and various parts thereof +deze | this +u | you +want | (1) for, (2) mitten, (3) rigging +nog | yet, still +zal | 'shall', first and third person sing. of verb 'zullen' (will) +me | me +zij | she, they +nu | now +ge | 'thou', still used in Belgium and south Netherlands +geen | none +omdat | because +iets | something, somewhat +worden | to become, grow, get +toch | yet, still +al | all, every, each +waren | (1) 'were' (2) to wander, (3) wares, (3) +veel | much, many +meer | (1) more, (2) lake +doen | to do, to make +toen | then, when +moet | noun 'spot/mote' and present form of 'to must' +ben | (1) am, (2) 'are' in interrogative second person singular of 'to be' +zonder | without +kan | noun 'can' and present form of 'to be able' +hun | their, them +dus | so, consequently +alles | all, everything, anything +onder | under, beneath +ja | yes, of course +eens | once, one day +hier | here +wie | who +werd | imperfect third person sing. of 'become' +altijd | always +doch | yet, but etc +wordt | present third person sing. of 'become' +wezen | (1) to be, (2) 'been' as in 'been fishing', (3) orphans +kunnen | to be able +ons | us/our +zelf | self +tegen | against, towards, at +na | after, near +reeds | already +wil | (1) present tense of 'want', (2) 'will', noun, (3) fender +kon | could; past tense of 'to be able' +niets | nothing +uw | your +iemand | somebody +geweest | been; past participle of 'be' +andere | other diff --git a/resources/cache/empty/class/conf/lang/stopwords_no.txt b/resources/cache/empty/class/conf/lang/stopwords_no.txt index 8aefda89..a7a2c28b 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_no.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_no.txt @@ -1,194 +1,194 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/norwegian/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Norwegian stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - | This stop word list is for the dominant bokmål dialect. Words unique - | to nynorsk are marked *. - - | Revised by Jan Bruusgaard , Jan 2005 - -og | and -i | in -jeg | I -det | it/this/that -at | to (w. inf.) -en | a/an -et | a/an -den | it/this/that -til | to -er | is/am/are -som | who/that -på | on -de | they / you(formal) -med | with -han | he -av | of -ikke | not -ikkje | not * -der | there -så | so -var | was/were -meg | me -seg | you -men | but -ett | one -har | have -om | about -vi | we -min | my -mitt | my -ha | have -hadde | had -hun | she -nå | now -over | over -da | when/as -ved | by/know -fra | from -du | you -ut | out -sin | your -dem | them -oss | us -opp | up -man | you/one -kan | can -hans | his -hvor | where -eller | or -hva | what -skal | shall/must -selv | self (reflective) -sjøl | self (reflective) -her | here -alle | all -vil | will -bli | become -ble | became -blei | became * -blitt | have become -kunne | could -inn | in -når | when -være | be -kom | come -noen | some -noe | some -ville | would -dere | you -som | who/which/that -deres | their/theirs -kun | only/just -ja | yes -etter | after -ned | down -skulle | should -denne | this -for | for/because -deg | you -si | hers/his -sine | hers/his -sitt | hers/his -mot | against -å | to -meget | much -hvorfor | why -dette | this -disse | these/those -uten | without -hvordan | how -ingen | none -din | your -ditt | your -blir | become -samme | same -hvilken | which -hvilke | which (plural) -sånn | such a -inni | inside/within -mellom | between -vår | our -hver | each -hvem | who -vors | us/ours -hvis | whose -både | both -bare | only/just -enn | than -fordi | as/because -før | before -mange | many -også | also -slik | just -vært | been -være | to be -båe | both * -begge | both -siden | since -dykk | your * -dykkar | yours * -dei | they * -deira | them * -deires | theirs * -deim | them * -di | your (fem.) * -då | as/when * -eg | I * -ein | a/an * -eit | a/an * -eitt | a/an * -elles | or * -honom | he * -hjå | at * -ho | she * -hoe | she * -henne | her -hennar | her/hers -hennes | hers -hoss | how * -hossen | how * -ikkje | not * -ingi | noone * -inkje | noone * -korleis | how * -korso | how * -kva | what/which * -kvar | where * -kvarhelst | where * -kven | who/whom * -kvi | why * -kvifor | why * -me | we * -medan | while * -mi | my * -mine | my * -mykje | much * -no | now * -nokon | some (masc./neut.) * -noka | some (fem.) * -nokor | some * -noko | some * -nokre | some * -si | his/hers * -sia | since * -sidan | since * -so | so * -somt | some * -somme | some * -um | about* -upp | up * -vere | be * -vore | was * -verte | become * -vort | become * -varte | became * -vart | became * - + | From svn.tartarus.org/snowball/trunk/website/algorithms/norwegian/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Norwegian stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + | This stop word list is for the dominant bokmål dialect. Words unique + | to nynorsk are marked *. + + | Revised by Jan Bruusgaard , Jan 2005 + +og | and +i | in +jeg | I +det | it/this/that +at | to (w. inf.) +en | a/an +et | a/an +den | it/this/that +til | to +er | is/am/are +som | who/that +på | on +de | they / you(formal) +med | with +han | he +av | of +ikke | not +ikkje | not * +der | there +så | so +var | was/were +meg | me +seg | you +men | but +ett | one +har | have +om | about +vi | we +min | my +mitt | my +ha | have +hadde | had +hun | she +nå | now +over | over +da | when/as +ved | by/know +fra | from +du | you +ut | out +sin | your +dem | them +oss | us +opp | up +man | you/one +kan | can +hans | his +hvor | where +eller | or +hva | what +skal | shall/must +selv | self (reflective) +sjøl | self (reflective) +her | here +alle | all +vil | will +bli | become +ble | became +blei | became * +blitt | have become +kunne | could +inn | in +når | when +være | be +kom | come +noen | some +noe | some +ville | would +dere | you +som | who/which/that +deres | their/theirs +kun | only/just +ja | yes +etter | after +ned | down +skulle | should +denne | this +for | for/because +deg | you +si | hers/his +sine | hers/his +sitt | hers/his +mot | against +å | to +meget | much +hvorfor | why +dette | this +disse | these/those +uten | without +hvordan | how +ingen | none +din | your +ditt | your +blir | become +samme | same +hvilken | which +hvilke | which (plural) +sånn | such a +inni | inside/within +mellom | between +vår | our +hver | each +hvem | who +vors | us/ours +hvis | whose +både | both +bare | only/just +enn | than +fordi | as/because +før | before +mange | many +også | also +slik | just +vært | been +være | to be +båe | both * +begge | both +siden | since +dykk | your * +dykkar | yours * +dei | they * +deira | them * +deires | theirs * +deim | them * +di | your (fem.) * +då | as/when * +eg | I * +ein | a/an * +eit | a/an * +eitt | a/an * +elles | or * +honom | he * +hjå | at * +ho | she * +hoe | she * +henne | her +hennar | her/hers +hennes | hers +hoss | how * +hossen | how * +ikkje | not * +ingi | noone * +inkje | noone * +korleis | how * +korso | how * +kva | what/which * +kvar | where * +kvarhelst | where * +kven | who/whom * +kvi | why * +kvifor | why * +me | we * +medan | while * +mi | my * +mine | my * +mykje | much * +no | now * +nokon | some (masc./neut.) * +noka | some (fem.) * +nokor | some * +noko | some * +nokre | some * +si | his/hers * +sia | since * +sidan | since * +so | so * +somt | some * +somme | some * +um | about* +upp | up * +vere | be * +vore | was * +verte | become * +vort | become * +varte | became * +vart | became * + diff --git a/resources/cache/empty/class/conf/lang/stopwords_pt.txt b/resources/cache/empty/class/conf/lang/stopwords_pt.txt index 6afa2b5c..acfeb01a 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_pt.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_pt.txt @@ -1,253 +1,253 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/portuguese/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Portuguese stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - - | The following is a ranked list (commonest to rarest) of stopwords - | deriving from a large sample of text. - - | Extra words have been added at the end. - -de | of, from -a | the; to, at; her -o | the; him -que | who, that -e | and -do | de + o -da | de + a -em | in -um | a -para | for - | é from SER -com | with -não | not, no -uma | a -os | the; them -no | em + o -se | himself etc -na | em + a -por | for -mais | more -as | the; them -dos | de + os -como | as, like -mas | but - | foi from SER -ao | a + o -ele | he -das | de + as - | tem from TER -à | a + a -seu | his -sua | her -ou | or - | ser from SER -quando | when -muito | much - | há from HAV -nos | em + os; us -já | already, now - | está from EST -eu | I -também | also -só | only, just -pelo | per + o -pela | per + a -até | up to -isso | that -ela | he -entre | between - | era from SER -depois | after -sem | without -mesmo | same -aos | a + os - | ter from TER -seus | his -quem | whom -nas | em + as -me | me -esse | that -eles | they - | estão from EST -você | you - | tinha from TER - | foram from SER -essa | that -num | em + um -nem | nor -suas | her -meu | my -às | a + as -minha | my - | têm from TER -numa | em + uma -pelos | per + os -elas | they - | havia from HAV - | seja from SER -qual | which - | será from SER -nós | we - | tenho from TER -lhe | to him, her -deles | of them -essas | those -esses | those -pelas | per + as -este | this - | fosse from SER -dele | of him - - | other words. There are many contractions such as naquele = em+aquele, - | mo = me+o, but they are rare. - | Indefinite article plural forms are also rare. - -tu | thou -te | thee -vocês | you (plural) -vos | you -lhes | to them -meus | my -minhas -teu | thy -tua -teus -tuas -nosso | our -nossa -nossos -nossas - -dela | of her -delas | of them - -esta | this -estes | these -estas | these -aquele | that -aquela | that -aqueles | those -aquelas | those -isto | this -aquilo | that - - | forms of estar, to be (not including the infinitive): -estou -está -estamos -estão -estive -esteve -estivemos -estiveram -estava -estávamos -estavam -estivera -estivéramos -esteja -estejamos -estejam -estivesse -estivéssemos -estivessem -estiver -estivermos -estiverem - - | forms of haver, to have (not including the infinitive): -hei -há -havemos -hão -houve -houvemos -houveram -houvera -houvéramos -haja -hajamos -hajam -houvesse -houvéssemos -houvessem -houver -houvermos -houverem -houverei -houverá -houveremos -houverão -houveria -houveríamos -houveriam - - | forms of ser, to be (not including the infinitive): -sou -somos -são -era -éramos -eram -fui -foi -fomos -foram -fora -fôramos -seja -sejamos -sejam -fosse -fôssemos -fossem -for -formos -forem -serei -será -seremos -serão -seria -seríamos -seriam - - | forms of ter, to have (not including the infinitive): -tenho -tem -temos -tém -tinha -tínhamos -tinham -tive -teve -tivemos -tiveram -tivera -tivéramos -tenha -tenhamos -tenham -tivesse -tivéssemos -tivessem -tiver -tivermos -tiverem -terei -terá -teremos -terão -teria -teríamos -teriam + | From svn.tartarus.org/snowball/trunk/website/algorithms/portuguese/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Portuguese stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + + | The following is a ranked list (commonest to rarest) of stopwords + | deriving from a large sample of text. + + | Extra words have been added at the end. + +de | of, from +a | the; to, at; her +o | the; him +que | who, that +e | and +do | de + o +da | de + a +em | in +um | a +para | for + | é from SER +com | with +não | not, no +uma | a +os | the; them +no | em + o +se | himself etc +na | em + a +por | for +mais | more +as | the; them +dos | de + os +como | as, like +mas | but + | foi from SER +ao | a + o +ele | he +das | de + as + | tem from TER +à | a + a +seu | his +sua | her +ou | or + | ser from SER +quando | when +muito | much + | há from HAV +nos | em + os; us +já | already, now + | está from EST +eu | I +também | also +só | only, just +pelo | per + o +pela | per + a +até | up to +isso | that +ela | he +entre | between + | era from SER +depois | after +sem | without +mesmo | same +aos | a + os + | ter from TER +seus | his +quem | whom +nas | em + as +me | me +esse | that +eles | they + | estão from EST +você | you + | tinha from TER + | foram from SER +essa | that +num | em + um +nem | nor +suas | her +meu | my +às | a + as +minha | my + | têm from TER +numa | em + uma +pelos | per + os +elas | they + | havia from HAV + | seja from SER +qual | which + | será from SER +nós | we + | tenho from TER +lhe | to him, her +deles | of them +essas | those +esses | those +pelas | per + as +este | this + | fosse from SER +dele | of him + + | other words. There are many contractions such as naquele = em+aquele, + | mo = me+o, but they are rare. + | Indefinite article plural forms are also rare. + +tu | thou +te | thee +vocês | you (plural) +vos | you +lhes | to them +meus | my +minhas +teu | thy +tua +teus +tuas +nosso | our +nossa +nossos +nossas + +dela | of her +delas | of them + +esta | this +estes | these +estas | these +aquele | that +aquela | that +aqueles | those +aquelas | those +isto | this +aquilo | that + + | forms of estar, to be (not including the infinitive): +estou +está +estamos +estão +estive +esteve +estivemos +estiveram +estava +estávamos +estavam +estivera +estivéramos +esteja +estejamos +estejam +estivesse +estivéssemos +estivessem +estiver +estivermos +estiverem + + | forms of haver, to have (not including the infinitive): +hei +há +havemos +hão +houve +houvemos +houveram +houvera +houvéramos +haja +hajamos +hajam +houvesse +houvéssemos +houvessem +houver +houvermos +houverem +houverei +houverá +houveremos +houverão +houveria +houveríamos +houveriam + + | forms of ser, to be (not including the infinitive): +sou +somos +são +era +éramos +eram +fui +foi +fomos +foram +fora +fôramos +seja +sejamos +sejam +fosse +fôssemos +fossem +for +formos +forem +serei +será +seremos +serão +seria +seríamos +seriam + + | forms of ter, to have (not including the infinitive): +tenho +tem +temos +tém +tinha +tínhamos +tinham +tive +teve +tivemos +tiveram +tivera +tivéramos +tenha +tenhamos +tenham +tivesse +tivéssemos +tivessem +tiver +tivermos +tiverem +terei +terá +teremos +terão +teria +teríamos +teriam diff --git a/resources/cache/empty/class/conf/lang/stopwords_ro.txt b/resources/cache/empty/class/conf/lang/stopwords_ro.txt index 2d7395c4..4fdee90a 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_ro.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_ro.txt @@ -1,233 +1,233 @@ -# This file was created by Jacques Savoy and is distributed under the BSD license. -# See http://members.unine.ch/jacques.savoy/clef/index.html. -# Also see http://www.opensource.org/licenses/bsd-license.html -acea -aceasta -această -aceea -acei -aceia -acel -acela -acele -acelea -acest -acesta -aceste -acestea -aceşti -aceştia -acolo -acum -ai -aia -aibă -aici -al -ăla -ale -alea -ălea -altceva -altcineva -am -ar -are -aş -aşadar -asemenea -asta -ăsta -astăzi -astea -ăstea -ăştia -asupra -aţi -au -avea -avem -aveţi -azi -bine -bucur -bună -ca -că -căci -când -care -cărei -căror -cărui -cât -câte -câţi -către -câtva -ce -cel -ceva -chiar -cînd -cine -cineva -cît -cîte -cîţi -cîtva -contra -cu -cum -cumva -curând -curînd -da -dă -dacă -dar -datorită -de -deci -deja -deoarece -departe -deşi -din -dinaintea -dintr -dintre -drept -după -ea -ei -el -ele -eram -este -eşti -eu -face -fără -fi -fie -fiecare -fii -fim -fiţi -iar -ieri -îi -îl -îmi -împotriva -în -înainte -înaintea -încât -încît -încotro -între -întrucât -întrucît -îţi -la -lângă -le -li -lîngă -lor -lui -mă -mâine -mea -mei -mele -mereu -meu -mi -mine -mult -multă -mulţi -ne -nicăieri -nici -nimeni -nişte -noastră -noastre -noi -noştri -nostru -nu -ori -oricând -oricare -oricât -orice -oricînd -oricine -oricît -oricum -oriunde -până -pe -pentru -peste -pînă -poate -pot -prea -prima -primul -prin -printr -sa -să -săi -sale -sau -său -se -şi -sînt -sîntem -sînteţi -spre -sub -sunt -suntem -sunteţi -ta -tăi -tale -tău -te -ţi -ţie -tine -toată -toate -tot -toţi -totuşi -tu -un -una -unde -undeva -unei -unele -uneori -unor -vă -vi -voastră -voastre -voi -voştri -vostru -vouă -vreo -vreun +# This file was created by Jacques Savoy and is distributed under the BSD license. +# See http://members.unine.ch/jacques.savoy/clef/index.html. +# Also see http://www.opensource.org/licenses/bsd-license.html +acea +aceasta +această +aceea +acei +aceia +acel +acela +acele +acelea +acest +acesta +aceste +acestea +aceşti +aceştia +acolo +acum +ai +aia +aibă +aici +al +ăla +ale +alea +ălea +altceva +altcineva +am +ar +are +aş +aşadar +asemenea +asta +ăsta +astăzi +astea +ăstea +ăştia +asupra +aţi +au +avea +avem +aveţi +azi +bine +bucur +bună +ca +că +căci +când +care +cărei +căror +cărui +cât +câte +câţi +către +câtva +ce +cel +ceva +chiar +cînd +cine +cineva +cît +cîte +cîţi +cîtva +contra +cu +cum +cumva +curând +curînd +da +dă +dacă +dar +datorită +de +deci +deja +deoarece +departe +deşi +din +dinaintea +dintr +dintre +drept +după +ea +ei +el +ele +eram +este +eşti +eu +face +fără +fi +fie +fiecare +fii +fim +fiţi +iar +ieri +îi +îl +îmi +împotriva +în +înainte +înaintea +încât +încît +încotro +între +întrucât +întrucît +îţi +la +lângă +le +li +lîngă +lor +lui +mă +mâine +mea +mei +mele +mereu +meu +mi +mine +mult +multă +mulţi +ne +nicăieri +nici +nimeni +nişte +noastră +noastre +noi +noştri +nostru +nu +ori +oricând +oricare +oricât +orice +oricînd +oricine +oricît +oricum +oriunde +până +pe +pentru +peste +pînă +poate +pot +prea +prima +primul +prin +printr +sa +să +săi +sale +sau +său +se +şi +sînt +sîntem +sînteţi +spre +sub +sunt +suntem +sunteţi +ta +tăi +tale +tău +te +ţi +ţie +tine +toată +toate +tot +toţi +totuşi +tu +un +una +unde +undeva +unei +unele +uneori +unor +vă +vi +voastră +voastre +voi +voştri +vostru +vouă +vreo +vreun diff --git a/resources/cache/empty/class/conf/lang/stopwords_ru.txt b/resources/cache/empty/class/conf/lang/stopwords_ru.txt index 0141b9b8..55271400 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_ru.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_ru.txt @@ -1,243 +1,243 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/russian/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | a russian stop word list. comments begin with vertical bar. each stop - | word is at the start of a line. - - | this is a ranked list (commonest to rarest) of stopwords derived from - | a large text sample. - - | letter `ё' is translated to `е'. - -и | and -в | in/into -во | alternative form -не | not -что | what/that -он | he -на | on/onto -я | i -с | from -со | alternative form -как | how -а | milder form of `no' (but) -то | conjunction and form of `that' -все | all -она | she -так | so, thus -его | him -но | but -да | yes/and -ты | thou -к | towards, by -у | around, chez -же | intensifier particle -вы | you -за | beyond, behind -бы | conditional/subj. particle -по | up to, along -только | only -ее | her -мне | to me -было | it was -вот | here is/are, particle -от | away from -меня | me -еще | still, yet, more -нет | no, there isnt/arent -о | about -из | out of -ему | to him -теперь | now -когда | when -даже | even -ну | so, well -вдруг | suddenly -ли | interrogative particle -если | if -уже | already, but homonym of `narrower' -или | or -ни | neither -быть | to be -был | he was -него | prepositional form of его -до | up to -вас | you accusative -нибудь | indef. suffix preceded by hyphen -опять | again -уж | already, but homonym of `adder' -вам | to you -сказал | he said -ведь | particle `after all' -там | there -потом | then -себя | oneself -ничего | nothing -ей | to her -может | usually with `быть' as `maybe' -они | they -тут | here -где | where -есть | there is/are -надо | got to, must -ней | prepositional form of ей -для | for -мы | we -тебя | thee -их | them, their -чем | than -была | she was -сам | self -чтоб | in order to -без | without -будто | as if -человек | man, person, one -чего | genitive form of `what' -раз | once -тоже | also -себе | to oneself -под | beneath -жизнь | life -будет | will be -ж | short form of intensifer particle `же' -тогда | then -кто | who -этот | this -говорил | was saying -того | genitive form of `that' -потому | for that reason -этого | genitive form of `this' -какой | which -совсем | altogether -ним | prepositional form of `его', `они' -здесь | here -этом | prepositional form of `этот' -один | one -почти | almost -мой | my -тем | instrumental/dative plural of `тот', `то' -чтобы | full form of `in order that' -нее | her (acc.) -кажется | it seems -сейчас | now -были | they were -куда | where to -зачем | why -сказать | to say -всех | all (acc., gen. preposn. plural) -никогда | never -сегодня | today -можно | possible, one can -при | by -наконец | finally -два | two -об | alternative form of `о', about -другой | another -хоть | even -после | after -над | above -больше | more -тот | that one (masc.) -через | across, in -эти | these -нас | us -про | about -всего | in all, only, of all -них | prepositional form of `они' (they) -какая | which, feminine -много | lots -разве | interrogative particle -сказала | she said -три | three -эту | this, acc. fem. sing. -моя | my, feminine -впрочем | moreover, besides -хорошо | good -свою | ones own, acc. fem. sing. -этой | oblique form of `эта', fem. `this' -перед | in front of -иногда | sometimes -лучше | better -чуть | a little -том | preposn. form of `that one' -нельзя | one must not -такой | such a one -им | to them -более | more -всегда | always -конечно | of course -всю | acc. fem. sing of `all' -между | between - - - | b: some paradigms - | - | personal pronouns - | - | я меня мне мной [мною] - | ты тебя тебе тобой [тобою] - | он его ему им [него, нему, ним] - | она ее эи ею [нее, нэи, нею] - | оно его ему им [него, нему, ним] - | - | мы нас нам нами - | вы вас вам вами - | они их им ими [них, ним, ними] - | - | себя себе собой [собою] - | - | demonstrative pronouns: этот (this), тот (that) - | - | этот эта это эти - | этого эты это эти - | этого этой этого этих - | этому этой этому этим - | этим этой этим [этою] этими - | этом этой этом этих - | - | тот та то те - | того ту то те - | того той того тех - | тому той тому тем - | тем той тем [тою] теми - | том той том тех - | - | determinative pronouns - | - | (a) весь (all) - | - | весь вся все все - | всего всю все все - | всего всей всего всех - | всему всей всему всем - | всем всей всем [всею] всеми - | всем всей всем всех - | - | (b) сам (himself etc) - | - | сам сама само сами - | самого саму само самих - | самого самой самого самих - | самому самой самому самим - | самим самой самим [самою] самими - | самом самой самом самих - | - | stems of verbs `to be', `to have', `to do' and modal - | - | быть бы буд быв есть суть - | име - | дел - | мог мож мочь - | уме - | хоч хот - | долж - | можн - | нужн - | нельзя - + | From svn.tartarus.org/snowball/trunk/website/algorithms/russian/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | a russian stop word list. comments begin with vertical bar. each stop + | word is at the start of a line. + + | this is a ranked list (commonest to rarest) of stopwords derived from + | a large text sample. + + | letter `ё' is translated to `е'. + +и | and +в | in/into +во | alternative form +не | not +что | what/that +он | he +на | on/onto +я | i +с | from +со | alternative form +как | how +а | milder form of `no' (but) +то | conjunction and form of `that' +все | all +она | she +так | so, thus +его | him +но | but +да | yes/and +ты | thou +к | towards, by +у | around, chez +же | intensifier particle +вы | you +за | beyond, behind +бы | conditional/subj. particle +по | up to, along +только | only +ее | her +мне | to me +было | it was +вот | here is/are, particle +от | away from +меня | me +еще | still, yet, more +нет | no, there isnt/arent +о | about +из | out of +ему | to him +теперь | now +когда | when +даже | even +ну | so, well +вдруг | suddenly +ли | interrogative particle +если | if +уже | already, but homonym of `narrower' +или | or +ни | neither +быть | to be +был | he was +него | prepositional form of его +до | up to +вас | you accusative +нибудь | indef. suffix preceded by hyphen +опять | again +уж | already, but homonym of `adder' +вам | to you +сказал | he said +ведь | particle `after all' +там | there +потом | then +себя | oneself +ничего | nothing +ей | to her +может | usually with `быть' as `maybe' +они | they +тут | here +где | where +есть | there is/are +надо | got to, must +ней | prepositional form of ей +для | for +мы | we +тебя | thee +их | them, their +чем | than +была | she was +сам | self +чтоб | in order to +без | without +будто | as if +человек | man, person, one +чего | genitive form of `what' +раз | once +тоже | also +себе | to oneself +под | beneath +жизнь | life +будет | will be +ж | short form of intensifer particle `же' +тогда | then +кто | who +этот | this +говорил | was saying +того | genitive form of `that' +потому | for that reason +этого | genitive form of `this' +какой | which +совсем | altogether +ним | prepositional form of `его', `они' +здесь | here +этом | prepositional form of `этот' +один | one +почти | almost +мой | my +тем | instrumental/dative plural of `тот', `то' +чтобы | full form of `in order that' +нее | her (acc.) +кажется | it seems +сейчас | now +были | they were +куда | where to +зачем | why +сказать | to say +всех | all (acc., gen. preposn. plural) +никогда | never +сегодня | today +можно | possible, one can +при | by +наконец | finally +два | two +об | alternative form of `о', about +другой | another +хоть | even +после | after +над | above +больше | more +тот | that one (masc.) +через | across, in +эти | these +нас | us +про | about +всего | in all, only, of all +них | prepositional form of `они' (they) +какая | which, feminine +много | lots +разве | interrogative particle +сказала | she said +три | three +эту | this, acc. fem. sing. +моя | my, feminine +впрочем | moreover, besides +хорошо | good +свою | ones own, acc. fem. sing. +этой | oblique form of `эта', fem. `this' +перед | in front of +иногда | sometimes +лучше | better +чуть | a little +том | preposn. form of `that one' +нельзя | one must not +такой | such a one +им | to them +более | more +всегда | always +конечно | of course +всю | acc. fem. sing of `all' +между | between + + + | b: some paradigms + | + | personal pronouns + | + | я меня мне мной [мною] + | ты тебя тебе тобой [тобою] + | он его ему им [него, нему, ним] + | она ее эи ею [нее, нэи, нею] + | оно его ему им [него, нему, ним] + | + | мы нас нам нами + | вы вас вам вами + | они их им ими [них, ним, ними] + | + | себя себе собой [собою] + | + | demonstrative pronouns: этот (this), тот (that) + | + | этот эта это эти + | этого эты это эти + | этого этой этого этих + | этому этой этому этим + | этим этой этим [этою] этими + | этом этой этом этих + | + | тот та то те + | того ту то те + | того той того тех + | тому той тому тем + | тем той тем [тою] теми + | том той том тех + | + | determinative pronouns + | + | (a) весь (all) + | + | весь вся все все + | всего всю все все + | всего всей всего всех + | всему всей всему всем + | всем всей всем [всею] всеми + | всем всей всем всех + | + | (b) сам (himself etc) + | + | сам сама само сами + | самого саму само самих + | самого самой самого самих + | самому самой самому самим + | самим самой самим [самою] самими + | самом самой самом самих + | + | stems of verbs `to be', `to have', `to do' and modal + | + | быть бы буд быв есть суть + | име + | дел + | мог мож мочь + | уме + | хоч хот + | долж + | можн + | нужн + | нельзя + diff --git a/resources/cache/empty/class/conf/lang/stopwords_sv.txt b/resources/cache/empty/class/conf/lang/stopwords_sv.txt index 7216373b..096f87f6 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_sv.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_sv.txt @@ -1,133 +1,133 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/swedish/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Swedish stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - | This is a ranked list (commonest to rarest) of stopwords derived from - | a large text sample. - - | Swedish stop words occasionally exhibit homonym clashes. For example - | så = so, but also seed. These are indicated clearly below. - -och | and -det | it, this/that -att | to (with infinitive) -i | in, at -en | a -jag | I -hon | she -som | who, that -han | he -på | on -den | it, this/that -med | with -var | where, each -sig | him(self) etc -för | for -så | so (also: seed) -till | to -är | is -men | but -ett | a -om | if; around, about -hade | had -de | they, these/those -av | of -icke | not, no -mig | me -du | you -henne | her -då | then, when -sin | his -nu | now -har | have -inte | inte någon = no one -hans | his -honom | him -skulle | 'sake' -hennes | her -där | there -min | my -man | one (pronoun) -ej | nor -vid | at, by, on (also: vast) -kunde | could -något | some etc -från | from, off -ut | out -när | when -efter | after, behind -upp | up -vi | we -dem | them -vara | be -vad | what -över | over -än | than -dig | you -kan | can -sina | his -här | here -ha | have -mot | towards -alla | all -under | under (also: wonder) -någon | some etc -eller | or (else) -allt | all -mycket | much -sedan | since -ju | why -denna | this/that -själv | myself, yourself etc -detta | this/that -åt | to -utan | without -varit | was -hur | how -ingen | no -mitt | my -ni | you -bli | to be, become -blev | from bli -oss | us -din | thy -dessa | these/those -några | some etc -deras | their -blir | from bli -mina | my -samma | (the) same -vilken | who, that -er | you, your -sådan | such a -vår | our -blivit | from bli -dess | its -inom | within -mellan | between -sådant | such a -varför | why -varje | each -vilka | who, that -ditt | thy -vem | who -vilket | who, that -sitta | his -sådana | such a -vart | each -dina | thy -vars | whose -vårt | our -våra | our -ert | your -era | your -vilkas | whose - + | From svn.tartarus.org/snowball/trunk/website/algorithms/swedish/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Swedish stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + | This is a ranked list (commonest to rarest) of stopwords derived from + | a large text sample. + + | Swedish stop words occasionally exhibit homonym clashes. For example + | så = so, but also seed. These are indicated clearly below. + +och | and +det | it, this/that +att | to (with infinitive) +i | in, at +en | a +jag | I +hon | she +som | who, that +han | he +på | on +den | it, this/that +med | with +var | where, each +sig | him(self) etc +för | for +så | so (also: seed) +till | to +är | is +men | but +ett | a +om | if; around, about +hade | had +de | they, these/those +av | of +icke | not, no +mig | me +du | you +henne | her +då | then, when +sin | his +nu | now +har | have +inte | inte någon = no one +hans | his +honom | him +skulle | 'sake' +hennes | her +där | there +min | my +man | one (pronoun) +ej | nor +vid | at, by, on (also: vast) +kunde | could +något | some etc +från | from, off +ut | out +när | when +efter | after, behind +upp | up +vi | we +dem | them +vara | be +vad | what +över | over +än | than +dig | you +kan | can +sina | his +här | here +ha | have +mot | towards +alla | all +under | under (also: wonder) +någon | some etc +eller | or (else) +allt | all +mycket | much +sedan | since +ju | why +denna | this/that +själv | myself, yourself etc +detta | this/that +åt | to +utan | without +varit | was +hur | how +ingen | no +mitt | my +ni | you +bli | to be, become +blev | from bli +oss | us +din | thy +dessa | these/those +några | some etc +deras | their +blir | from bli +mina | my +samma | (the) same +vilken | who, that +er | you, your +sådan | such a +vår | our +blivit | from bli +dess | its +inom | within +mellan | between +sådant | such a +varför | why +varje | each +vilka | who, that +ditt | thy +vem | who +vilket | who, that +sitta | his +sådana | such a +vart | each +dina | thy +vars | whose +vårt | our +våra | our +ert | your +era | your +vilkas | whose + diff --git a/resources/cache/empty/class/conf/lang/stopwords_th.txt b/resources/cache/empty/class/conf/lang/stopwords_th.txt index 1415edf9..07f0fabe 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_th.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_th.txt @@ -1,119 +1,119 @@ -# Thai stopwords from: -# "Opinion Detection in Thai Political News Columns -# Based on Subjectivity Analysis" -# Khampol Sukhum, Supot Nitsuwat, and Choochart Haruechaiyasak -ไว้ -ไม่ -ไป -ได้ -ให้ -ใน -โดย -แห่ง -แล้ว -และ -แรก -แบบ -แต่ -เอง -เห็น -เลย -เริ่ม -เรา -เมื่อ -เพื่อ -เพราะ -เป็นการ -เป็น -เปิดเผย -เปิด -เนื่องจาก -เดียวกัน -เดียว -เช่น -เฉพาะ -เคย -เข้า -เขา -อีก -อาจ -อะไร -ออก -อย่าง -อยู่ -อยาก -หาก -หลาย -หลังจาก -หลัง -หรือ -หนึ่ง -ส่วน -ส่ง -สุด -สําหรับ -ว่า -วัน -ลง -ร่วม -ราย -รับ -ระหว่าง -รวม -ยัง -มี -มาก -มา -พร้อม -พบ -ผ่าน -ผล -บาง -น่า -นี้ -นํา -นั้น -นัก -นอกจาก -ทุก -ที่สุด -ที่ -ทําให้ -ทํา -ทาง -ทั้งนี้ -ทั้ง -ถ้า -ถูก -ถึง -ต้อง -ต่างๆ -ต่าง -ต่อ -ตาม -ตั้งแต่ -ตั้ง -ด้าน -ด้วย -ดัง -ซึ่ง -ช่วง -จึง -จาก -จัด -จะ -คือ -ความ -ครั้ง -คง -ขึ้น -ของ -ขอ -ขณะ -ก่อน -ก็ -การ -กับ -กัน -กว่า -กล่าว +# Thai stopwords from: +# "Opinion Detection in Thai Political News Columns +# Based on Subjectivity Analysis" +# Khampol Sukhum, Supot Nitsuwat, and Choochart Haruechaiyasak +ไว้ +ไม่ +ไป +ได้ +ให้ +ใน +โดย +แห่ง +แล้ว +และ +แรก +แบบ +แต่ +เอง +เห็น +เลย +เริ่ม +เรา +เมื่อ +เพื่อ +เพราะ +เป็นการ +เป็น +เปิดเผย +เปิด +เนื่องจาก +เดียวกัน +เดียว +เช่น +เฉพาะ +เคย +เข้า +เขา +อีก +อาจ +อะไร +ออก +อย่าง +อยู่ +อยาก +หาก +หลาย +หลังจาก +หลัง +หรือ +หนึ่ง +ส่วน +ส่ง +สุด +สําหรับ +ว่า +วัน +ลง +ร่วม +ราย +รับ +ระหว่าง +รวม +ยัง +มี +มาก +มา +พร้อม +พบ +ผ่าน +ผล +บาง +น่า +นี้ +นํา +นั้น +นัก +นอกจาก +ทุก +ที่สุด +ที่ +ทําให้ +ทํา +ทาง +ทั้งนี้ +ทั้ง +ถ้า +ถูก +ถึง +ต้อง +ต่างๆ +ต่าง +ต่อ +ตาม +ตั้งแต่ +ตั้ง +ด้าน +ด้วย +ดัง +ซึ่ง +ช่วง +จึง +จาก +จัด +จะ +คือ +ความ +ครั้ง +คง +ขึ้น +ของ +ขอ +ขณะ +ก่อน +ก็ +การ +กับ +กัน +กว่า +กล่าว diff --git a/resources/cache/empty/class/conf/lang/stopwords_tr.txt b/resources/cache/empty/class/conf/lang/stopwords_tr.txt index fe4083b7..84d9408d 100644 --- a/resources/cache/empty/class/conf/lang/stopwords_tr.txt +++ b/resources/cache/empty/class/conf/lang/stopwords_tr.txt @@ -1,212 +1,212 @@ -# Turkish stopwords from LUCENE-559 -# merged with the list from "Information Retrieval on Turkish Texts" -# (http://www.users.muohio.edu/canf/papers/JASIST2008offPrint.pdf) -acaba -altmış -altı -ama -ancak -arada -aslında -ayrıca -bana -bazı -belki -ben -benden -beni -benim -beri -beş -bile -bin -bir -birçok -biri -birkaç -birkez -birşey -birşeyi -biz -bize -bizden -bizi -bizim -böyle -böylece -bu -buna -bunda -bundan -bunlar -bunları -bunların -bunu -bunun -burada -çok -çünkü -da -daha -dahi -de -defa -değil -diğer -diye -doksan -dokuz -dolayı -dolayısıyla -dört -edecek -eden -ederek -edilecek -ediliyor -edilmesi -ediyor -eğer -elli -en -etmesi -etti -ettiği -ettiğini -gibi -göre -halen -hangi -hatta -hem -henüz -hep -hepsi -her -herhangi -herkesin -hiç -hiçbir -için -iki -ile -ilgili -ise -işte -itibaren -itibariyle -kadar -karşın -katrilyon -kendi -kendilerine -kendini -kendisi -kendisine -kendisini -kez -ki -kim -kimden -kime -kimi -kimse -kırk -milyar -milyon -mu -mü -mı -nasıl -ne -neden -nedenle -nerde -nerede -nereye -niye -niçin -o -olan -olarak -oldu -olduğu -olduğunu -olduklarını -olmadı -olmadığı -olmak -olması -olmayan -olmaz -olsa -olsun -olup -olur -olursa -oluyor -on -ona -ondan -onlar -onlardan -onları -onların -onu -onun -otuz -oysa -öyle -pek -rağmen -sadece -sanki -sekiz -seksen -sen -senden -seni -senin -siz -sizden -sizi -sizin -şey -şeyden -şeyi -şeyler -şöyle -şu -şuna -şunda -şundan -şunları -şunu -tarafından -trilyon -tüm -üç -üzere -var -vardı -ve -veya -ya -yani -yapacak -yapılan -yapılması -yapıyor -yapmak -yaptı -yaptığı -yaptığını -yaptıkları -yedi -yerine -yetmiş -yine -yirmi -yoksa -yüz -zaten +# Turkish stopwords from LUCENE-559 +# merged with the list from "Information Retrieval on Turkish Texts" +# (http://www.users.muohio.edu/canf/papers/JASIST2008offPrint.pdf) +acaba +altmış +altı +ama +ancak +arada +aslında +ayrıca +bana +bazı +belki +ben +benden +beni +benim +beri +beş +bile +bin +bir +birçok +biri +birkaç +birkez +birşey +birşeyi +biz +bize +bizden +bizi +bizim +böyle +böylece +bu +buna +bunda +bundan +bunlar +bunları +bunların +bunu +bunun +burada +çok +çünkü +da +daha +dahi +de +defa +değil +diğer +diye +doksan +dokuz +dolayı +dolayısıyla +dört +edecek +eden +ederek +edilecek +ediliyor +edilmesi +ediyor +eğer +elli +en +etmesi +etti +ettiği +ettiğini +gibi +göre +halen +hangi +hatta +hem +henüz +hep +hepsi +her +herhangi +herkesin +hiç +hiçbir +için +iki +ile +ilgili +ise +işte +itibaren +itibariyle +kadar +karşın +katrilyon +kendi +kendilerine +kendini +kendisi +kendisine +kendisini +kez +ki +kim +kimden +kime +kimi +kimse +kırk +milyar +milyon +mu +mü +mı +nasıl +ne +neden +nedenle +nerde +nerede +nereye +niye +niçin +o +olan +olarak +oldu +olduğu +olduğunu +olduklarını +olmadı +olmadığı +olmak +olması +olmayan +olmaz +olsa +olsun +olup +olur +olursa +oluyor +on +ona +ondan +onlar +onlardan +onları +onların +onu +onun +otuz +oysa +öyle +pek +rağmen +sadece +sanki +sekiz +seksen +sen +senden +seni +senin +siz +sizden +sizi +sizin +şey +şeyden +şeyi +şeyler +şöyle +şu +şuna +şunda +şundan +şunları +şunu +tarafından +trilyon +tüm +üç +üzere +var +vardı +ve +veya +ya +yani +yapacak +yapılan +yapılması +yapıyor +yapmak +yaptı +yaptığı +yaptığını +yaptıkları +yedi +yerine +yetmiş +yine +yirmi +yoksa +yüz +zaten diff --git a/resources/cache/empty/class/conf/lang/userdict_ja.txt b/resources/cache/empty/class/conf/lang/userdict_ja.txt index c79de826..6f0368e4 100644 --- a/resources/cache/empty/class/conf/lang/userdict_ja.txt +++ b/resources/cache/empty/class/conf/lang/userdict_ja.txt @@ -1,29 +1,29 @@ -# -# This is a sample user dictionary for Kuromoji (JapaneseTokenizer) -# -# Add entries to this file in order to override the statistical model in terms -# of segmentation, readings and part-of-speech tags. Notice that entries do -# not have weights since they are always used when found. This is by-design -# in order to maximize ease-of-use. -# -# Entries are defined using the following CSV format: -# , ... , ... , -# -# Notice that a single half-width space separates tokens and readings, and -# that the number tokens and readings must match exactly. -# -# Also notice that multiple entries with the same is undefined. -# -# Whitespace only lines are ignored. Comments are not allowed on entry lines. -# - -# Custom segmentation for kanji compounds -日本経済新聞,日本 経済 新聞,ニホン ケイザイ シンブン,カスタム名詞 -関西国際空港,関西 国際 空港,カンサイ コクサイ クウコウ,カスタム名詞 - -# Custom segmentation for compound katakana -トートバッグ,トート バッグ,トート バッグ,かずカナ名詞 -ショルダーバッグ,ショルダー バッグ,ショルダー バッグ,かずカナ名詞 - -# Custom reading for former sumo wrestler -朝青龍,朝青龍,アサショウリュウ,カスタム人名 +# +# This is a sample user dictionary for Kuromoji (JapaneseTokenizer) +# +# Add entries to this file in order to override the statistical model in terms +# of segmentation, readings and part-of-speech tags. Notice that entries do +# not have weights since they are always used when found. This is by-design +# in order to maximize ease-of-use. +# +# Entries are defined using the following CSV format: +# , ... , ... , +# +# Notice that a single half-width space separates tokens and readings, and +# that the number tokens and readings must match exactly. +# +# Also notice that multiple entries with the same is undefined. +# +# Whitespace only lines are ignored. Comments are not allowed on entry lines. +# + +# Custom segmentation for kanji compounds +日本経済新聞,日本 経済 新聞,ニホン ケイザイ シンブン,カスタム名詞 +関西国際空港,関西 国際 空港,カンサイ コクサイ クウコウ,カスタム名詞 + +# Custom segmentation for compound katakana +トートバッグ,トート バッグ,トート バッグ,かずカナ名詞 +ショルダーバッグ,ショルダー バッグ,ショルダー バッグ,かずカナ名詞 + +# Custom reading for former sumo wrestler +朝青龍,朝青龍,アサショウリュウ,カスタム人名 diff --git a/resources/cache/empty/class/conf/params.json b/resources/cache/empty/class/conf/params.json index abf4154e..9c259db5 100644 --- a/resources/cache/empty/class/conf/params.json +++ b/resources/cache/empty/class/conf/params.json @@ -1,20 +1,20 @@ -{"params":{ - "query":{ - "defType":"edismax", - "q.alt":"*:*", - "rows":"10", - "fl":"*,score", - "":{"v":0} - }, - "facets":{ - "facet":"on", - "facet.mincount": "1", - "":{"v":0} - }, - "velocity":{ - "wt": "velocity", - "v.template":"browse", - "v.layout": "layout", - "":{"v":0} - } -}} +{"params":{ + "query":{ + "defType":"edismax", + "q.alt":"*:*", + "rows":"10", + "fl":"*,score", + "":{"v":0} + }, + "facets":{ + "facet":"on", + "facet.mincount": "1", + "":{"v":0} + }, + "velocity":{ + "wt": "velocity", + "v.template":"browse", + "v.layout": "layout", + "":{"v":0} + } +}} diff --git a/resources/cache/empty/class/conf/protwords.txt b/resources/cache/empty/class/conf/protwords.txt index 5a32e503..1dfc0abe 100644 --- a/resources/cache/empty/class/conf/protwords.txt +++ b/resources/cache/empty/class/conf/protwords.txt @@ -1,21 +1,21 @@ -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#----------------------------------------------------------------------- -# Use a protected word file to protect against the stemmer reducing two -# unrelated words to the same base word. - -# Some non-words that normally won't be encountered, -# just to test that they won't be stemmed. -dontstems -zwhacky - +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#----------------------------------------------------------------------- +# Use a protected word file to protect against the stemmer reducing two +# unrelated words to the same base word. + +# Some non-words that normally won't be encountered, +# just to test that they won't be stemmed. +dontstems +zwhacky + diff --git a/resources/cache/empty/class/conf/schema.xml b/resources/cache/empty/class/conf/schema.xml index e287187b..637caa92 100644 --- a/resources/cache/empty/class/conf/schema.xml +++ b/resources/cache/empty/class/conf/schema.xml @@ -1,240 +1,240 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - id - - id - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id + + id + + + diff --git a/resources/cache/empty/class/conf/solrconfig.xml b/resources/cache/empty/class/conf/solrconfig.xml index 7e8babdf..a99f9628 100644 --- a/resources/cache/empty/class/conf/solrconfig.xml +++ b/resources/cache/empty/class/conf/solrconfig.xml @@ -1,1949 +1,1949 @@ - - - - - - - - - 4.10.4 - - - - - - - - - - - - - - - - - - - - - - ${solr.data.dir:} - - - - - - - - - ${solr.hdfs.home:} - - ${solr.hdfs.confdir:} - - ${solr.hdfs.blockcache.enabled:true} - - ${solr.hdfs.blockcache.global:true} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${solr.lock.type:native} - - - - - - - - - - - - - - - - - - - - - - true - - - false - - - - - - - - - - - - - - - - ${solr.ulog.dir:} - - - - - ${solr.autoCommit.maxTime:15000} - false - - - - - - ${solr.autoSoftCommit.maxTime:-1} - - - - - - - - - - - - - - - - - - 1024 - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - 20 - - - 200 - - - - - - - - - - - - static firstSearcher warming in solrconfig.xml - - - - - - false - - - 2 - - - - - - - - - - - - - - - - - - - - - - - explicit - 10 - text - - - - - - - - - - on - content features title name - true - html - <b> - </b> - 0 - title - - 3 - 200 - content - 750 - - - on - false - 5 - 2 - 5 - true - true - 5 - 3 - - - - - - explicit - json - true - text - - - - - - - - true - json - true - - - - - - - - {!xport} - xsort - false - - - - query - - - - - - - - - - - - explicit - - - velocity - browse - layout - Solritas - - - edismax - - text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 - title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0 - - text - 100% - *:* - 10 - *,score - - - text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 - title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0 - - text,features,name,sku,id,manu,cat,title,description,keywords,author,resourcename - 3 - - - on - true - cat - person - location - organisations - ipod - GB - 1 - cat,inStock - after - price - 0 - 600 - 50 - popularity - 0 - 10 - 3 - manufacturedate_dt - NOW/YEAR-10YEARS - NOW - +1YEAR - before - after - - - on - content features title name - true - html - <b> - </b> - 0 - title - - 3 - 200 - content - 750 - - - on - false - 5 - 2 - 5 - true - true - 5 - 3 - - - - - spellcheck - - - - - - - - - - - - - - - - last_modified - true - - ignored_ - - - true - links - jate_text_field - true - ignored_ - - - langid - - - - - - yyyy-MM-dd hh:mm:ss - - - - - - - - - - - - - - - - - - - - - - solrpingquery - - - all - - - - - - - - - explicit - true - - - - - - - - - - - - - - - - text_general - - - - - - default - text - solr.DirectSolrSpellChecker - - internal - - 0.5 - - 2 - - 1 - - 5 - - 4 - - 0.01 - - - - - - wordbreak - solr.WordBreakSolrSpellChecker - name - true - true - 10 - - - - - - - - - - - - - - - - text - - default - wordbreak - on - true - 10 - 5 - 5 - true - true - 10 - 5 - - - spellcheck - - - - - - - - - - - - text - true - - - tvComponent - - - - - - - lingo - - - org.carrot2.clustering.lingo.LingoClusteringAlgorithm - - - clustering/carrot2 - - - - - stc - org.carrot2.clustering.stc.STCClusteringAlgorithm - - - - - kmeans - org.carrot2.clustering.kmeans.BisectingKMeansClusteringAlgorithm - - - - - - - true - true - - name - - id - - features - - true - - - - false - - - edismax - - text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 - - *:* - 10 - *,score - - - clustering - - - - - - - - - - true - false - - - terms - - - - - - - - string - elevate.xml - - - - - - explicit - text - - - elevator - - - - - - - - - - - 100 - - - - - - - - 70 - - 0.5 - - [-\w ,/\n\"']{20,200} - - - - - - - ]]> - ]]> - - - - - - - - - - - - - - - - - - - - - - - - ,, - ,, - ,, - ,, - ,]]> - ]]> - - - - - - 10 - .,!? - - - - - - - WORD - - - en - US - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/plain; charset=UTF-8 - - - - - - - - - 5 - - - - - - - - - - - - - - - - - - *:* - - - + + + + + + + + + 4.10.4 + + + + + + + + + + + + + + + + + + + + + + ${solr.data.dir:} + + + + + + + + + ${solr.hdfs.home:} + + ${solr.hdfs.confdir:} + + ${solr.hdfs.blockcache.enabled:true} + + ${solr.hdfs.blockcache.global:true} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${solr.lock.type:native} + + + + + + + + + + + + + + + + + + + + + + true + + + false + + + + + + + + + + + + + + + + ${solr.ulog.dir:} + + + + + ${solr.autoCommit.maxTime:15000} + false + + + + + + ${solr.autoSoftCommit.maxTime:-1} + + + + + + + + + + + + + + + + + + 1024 + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + 20 + + + 200 + + + + + + + + + + + + static firstSearcher warming in solrconfig.xml + + + + + + false + + + 2 + + + + + + + + + + + + + + + + + + + + + + + explicit + 10 + text + + + + + + + + + + on + content features title name + true + html + <b> + </b> + 0 + title + + 3 + 200 + content + 750 + + + on + false + 5 + 2 + 5 + true + true + 5 + 3 + + + + + + explicit + json + true + text + + + + + + + + true + json + true + + + + + + + + {!xport} + xsort + false + + + + query + + + + + + + + + + + + explicit + + + velocity + browse + layout + Solritas + + + edismax + + text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 + title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0 + + text + 100% + *:* + 10 + *,score + + + text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 + title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0 + + text,features,name,sku,id,manu,cat,title,description,keywords,author,resourcename + 3 + + + on + true + cat + person + location + organisations + ipod + GB + 1 + cat,inStock + after + price + 0 + 600 + 50 + popularity + 0 + 10 + 3 + manufacturedate_dt + NOW/YEAR-10YEARS + NOW + +1YEAR + before + after + + + on + content features title name + true + html + <b> + </b> + 0 + title + + 3 + 200 + content + 750 + + + on + false + 5 + 2 + 5 + true + true + 5 + 3 + + + + + spellcheck + + + + + + + + + + + + + + + + last_modified + true + + ignored_ + + + true + links + jate_text_field + true + ignored_ + + + langid + + + + + + yyyy-MM-dd hh:mm:ss + + + + + + + + + + + + + + + + + + + + + + solrpingquery + + + all + + + + + + + + + explicit + true + + + + + + + + + + + + + + + + text_general + + + + + + default + text + solr.DirectSolrSpellChecker + + internal + + 0.5 + + 2 + + 1 + + 5 + + 4 + + 0.01 + + + + + + wordbreak + solr.WordBreakSolrSpellChecker + name + true + true + 10 + + + + + + + + + + + + + + + + text + + default + wordbreak + on + true + 10 + 5 + 5 + true + true + 10 + 5 + + + spellcheck + + + + + + + + + + + + text + true + + + tvComponent + + + + + + + lingo + + + org.carrot2.clustering.lingo.LingoClusteringAlgorithm + + + clustering/carrot2 + + + + + stc + org.carrot2.clustering.stc.STCClusteringAlgorithm + + + + + kmeans + org.carrot2.clustering.kmeans.BisectingKMeansClusteringAlgorithm + + + + + + + true + true + + name + + id + + features + + true + + + + false + + + edismax + + text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 + + *:* + 10 + *,score + + + clustering + + + + + + + + + + true + false + + + terms + + + + + + + + string + elevate.xml + + + + + + explicit + text + + + elevator + + + + + + + + + + + 100 + + + + + + + + 70 + + 0.5 + + [-\w ,/\n\"']{20,200} + + + + + + + ]]> + ]]> + + + + + + + + + + + + + + + + + + + + + + + + ,, + ,, + ,, + ,, + ,]]> + ]]> + + + + + + 10 + .,!? + + + + + + + WORD + + + en + US + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/plain; charset=UTF-8 + + + + + + + + + 5 + + + + + + + + + + + + + + + + + + *:* + + + diff --git a/resources/cache/empty/class/conf/stopwords.txt b/resources/cache/empty/class/conf/stopwords.txt index e525ab80..dacec479 100644 --- a/resources/cache/empty/class/conf/stopwords.txt +++ b/resources/cache/empty/class/conf/stopwords.txt @@ -1,188 +1,188 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -a -about -above -after -again -against -all -am -an -and -any -are -aren't -as -at -be -because -been -before -being -below -between -both -but -by -can't -cannot -could -couldn't -did -didn't -do -does -doesn't -doing -don't -down -during -each -few -for -from -further -had -hadn't -has -hasn't -have -haven't -having -he -he'd -he'll -he's -her -here -here's -hers -herself -him -himself -his -how -how's -i -i'd -i'll -i'm -i've -if -in -into -is -isn't -it -it's -its -itself -let's -me -more -most -mustn't -my -myself -no -nor -not -of -off -on -once -only -or -other -ought -our -ours -ourselves -out -over -own -same -shan't -she -she'd -she'll -she's -should -shouldn't -so -some -such -than -that -that's -the -their -theirs -them -themselves -then -there -there's -these -they -they'd -they'll -they're -they've -this -those -through -to -too -under -until -up -very -was -wasn't -we -we'd -we'll -we're -we've -were -weren't -what -what's -when -when's -where -where's -which -while -who -who's -whom -why -why's -with -won't -would -wouldn't -you -you'd -you'll -you're -you've -your -yours -yourself +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +a +about +above +after +again +against +all +am +an +and +any +are +aren't +as +at +be +because +been +before +being +below +between +both +but +by +can't +cannot +could +couldn't +did +didn't +do +does +doesn't +doing +don't +down +during +each +few +for +from +further +had +hadn't +has +hasn't +have +haven't +having +he +he'd +he'll +he's +her +here +here's +hers +herself +him +himself +his +how +how's +i +i'd +i'll +i'm +i've +if +in +into +is +isn't +it +it's +its +itself +let's +me +more +most +mustn't +my +myself +no +nor +not +of +off +on +once +only +or +other +ought +our +ours +ourselves +out +over +own +same +shan't +she +she'd +she'll +she's +should +shouldn't +so +some +such +than +that +that's +the +their +theirs +them +themselves +then +there +there's +these +they +they'd +they'll +they're +they've +this +those +through +to +too +under +until +up +very +was +wasn't +we +we'd +we'll +we're +we've +were +weren't +what +what's +when +when's +where +where's +which +while +who +who's +whom +why +why's +with +won't +would +wouldn't +you +you'd +you'll +you're +you've +your +yours +yourself yourselves \ No newline at end of file diff --git a/resources/cache/empty/class/conf/synonyms.txt b/resources/cache/empty/class/conf/synonyms.txt index f00294b0..7f721283 100644 --- a/resources/cache/empty/class/conf/synonyms.txt +++ b/resources/cache/empty/class/conf/synonyms.txt @@ -1,29 +1,29 @@ -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#----------------------------------------------------------------------- -#some test synonym mappings unlikely to appear in real input text -aaafoo => aaabar -bbbfoo => bbbfoo bbbbar -cccfoo => cccbar cccbaz -fooaaa,baraaa,bazaaa - -# Some synonym groups specific to this example -GB,gib,gigabyte,gigabytes -MB,mib,megabyte,megabytes -Television, Televisions, TV, TVs -#notice we use "gib" instead of "GiB" so any WordDelimiterFilter coming -#after us won't split it into two words. - -# Synonym mappings can be used for spelling correction too -pixima => pixma - +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#----------------------------------------------------------------------- +#some test synonym mappings unlikely to appear in real input text +aaafoo => aaabar +bbbfoo => bbbfoo bbbbar +cccfoo => cccbar cccbaz +fooaaa,baraaa,bazaaa + +# Some synonym groups specific to this example +GB,gib,gigabyte,gigabytes +MB,mib,megabyte,megabytes +Television, Televisions, TV, TVs +#notice we use "gib" instead of "GiB" so any WordDelimiterFilter coming +#after us won't split it into two words. + +# Synonym mappings can be used for spelling correction too +pixima => pixma + diff --git a/resources/cache/empty/class/core.properties b/resources/cache/empty/class/core.properties index b6b87485..d12e2e9d 100644 --- a/resources/cache/empty/class/core.properties +++ b/resources/cache/empty/class/core.properties @@ -1,3 +1,3 @@ -#Written by CorePropertiesLocator -#Mon Sep 14 10:05:54 UTC 2015 -name=class +#Written by CorePropertiesLocator +#Mon Sep 14 10:05:54 UTC 2015 +name=class diff --git a/resources/cache/empty/entity/conf/currency.xml b/resources/cache/empty/entity/conf/currency.xml index 5c6cfaf0..3a9c58af 100644 --- a/resources/cache/empty/entity/conf/currency.xml +++ b/resources/cache/empty/entity/conf/currency.xml @@ -1,67 +1,67 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/cache/empty/entity/conf/elevate.xml b/resources/cache/empty/entity/conf/elevate.xml index e4769ccf..25d5cebe 100644 --- a/resources/cache/empty/entity/conf/elevate.xml +++ b/resources/cache/empty/entity/conf/elevate.xml @@ -1,38 +1,38 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/resources/cache/empty/entity/conf/lang/contractions_ca.txt b/resources/cache/empty/entity/conf/lang/contractions_ca.txt index 116644f2..307a85f9 100644 --- a/resources/cache/empty/entity/conf/lang/contractions_ca.txt +++ b/resources/cache/empty/entity/conf/lang/contractions_ca.txt @@ -1,8 +1,8 @@ -# Set of Catalan contractions for ElisionFilter -# TODO: load this as a resource from the analyzer and sync it in build.xml -d -l -m -n -s -t +# Set of Catalan contractions for ElisionFilter +# TODO: load this as a resource from the analyzer and sync it in build.xml +d +l +m +n +s +t diff --git a/resources/cache/empty/entity/conf/lang/contractions_fr.txt b/resources/cache/empty/entity/conf/lang/contractions_fr.txt index 6de73c27..f1bba51b 100644 --- a/resources/cache/empty/entity/conf/lang/contractions_fr.txt +++ b/resources/cache/empty/entity/conf/lang/contractions_fr.txt @@ -1,15 +1,15 @@ -# Set of French contractions for ElisionFilter -# TODO: load this as a resource from the analyzer and sync it in build.xml -l -m -t -qu -n -s -j -d -c -jusqu -quoiqu -lorsqu -puisqu +# Set of French contractions for ElisionFilter +# TODO: load this as a resource from the analyzer and sync it in build.xml +l +m +t +qu +n +s +j +d +c +jusqu +quoiqu +lorsqu +puisqu diff --git a/resources/cache/empty/entity/conf/lang/contractions_ga.txt b/resources/cache/empty/entity/conf/lang/contractions_ga.txt index 849b0c6e..9ebe7fa3 100644 --- a/resources/cache/empty/entity/conf/lang/contractions_ga.txt +++ b/resources/cache/empty/entity/conf/lang/contractions_ga.txt @@ -1,5 +1,5 @@ -# Set of Irish contractions for ElisionFilter -# TODO: load this as a resource from the analyzer and sync it in build.xml -d -m -b +# Set of Irish contractions for ElisionFilter +# TODO: load this as a resource from the analyzer and sync it in build.xml +d +m +b diff --git a/resources/cache/empty/entity/conf/lang/contractions_it.txt b/resources/cache/empty/entity/conf/lang/contractions_it.txt index 790b5af4..cac04095 100644 --- a/resources/cache/empty/entity/conf/lang/contractions_it.txt +++ b/resources/cache/empty/entity/conf/lang/contractions_it.txt @@ -1,23 +1,23 @@ -# Set of Italian contractions for ElisionFilter -# TODO: load this as a resource from the analyzer and sync it in build.xml -c -l -all -dall -dell -nell -sull -coll -pell -gl -agl -dagl -degl -negl -sugl -un -m -t -s -v -d +# Set of Italian contractions for ElisionFilter +# TODO: load this as a resource from the analyzer and sync it in build.xml +c +l +all +dall +dell +nell +sull +coll +pell +gl +agl +dagl +degl +negl +sugl +un +m +t +s +v +d diff --git a/resources/cache/empty/entity/conf/lang/hyphenations_ga.txt b/resources/cache/empty/entity/conf/lang/hyphenations_ga.txt index fce41006..4d2642cc 100644 --- a/resources/cache/empty/entity/conf/lang/hyphenations_ga.txt +++ b/resources/cache/empty/entity/conf/lang/hyphenations_ga.txt @@ -1,5 +1,5 @@ -# Set of Irish hyphenations for StopFilter -# TODO: load this as a resource from the analyzer and sync it in build.xml -h -n -t +# Set of Irish hyphenations for StopFilter +# TODO: load this as a resource from the analyzer and sync it in build.xml +h +n +t diff --git a/resources/cache/empty/entity/conf/lang/stemdict_nl.txt b/resources/cache/empty/entity/conf/lang/stemdict_nl.txt index 01dd3bb8..44107297 100644 --- a/resources/cache/empty/entity/conf/lang/stemdict_nl.txt +++ b/resources/cache/empty/entity/conf/lang/stemdict_nl.txt @@ -1,6 +1,6 @@ -# Set of overrides for the dutch stemmer -# TODO: load this as a resource from the analyzer and sync it in build.xml -fiets fiets -bromfiets bromfiets -ei eier -kind kinder +# Set of overrides for the dutch stemmer +# TODO: load this as a resource from the analyzer and sync it in build.xml +fiets fiets +bromfiets bromfiets +ei eier +kind kinder diff --git a/resources/cache/empty/entity/conf/lang/stoptags_ja.txt b/resources/cache/empty/entity/conf/lang/stoptags_ja.txt index 2faf2a68..71b75084 100644 --- a/resources/cache/empty/entity/conf/lang/stoptags_ja.txt +++ b/resources/cache/empty/entity/conf/lang/stoptags_ja.txt @@ -1,420 +1,420 @@ -# -# This file defines a Japanese stoptag set for JapanesePartOfSpeechStopFilter. -# -# Any token with a part-of-speech tag that exactly matches those defined in this -# file are removed from the token stream. -# -# Set your own stoptags by uncommenting the lines below. Note that comments are -# not allowed on the same line as a stoptag. See LUCENE-3745 for frequency lists, -# etc. that can be useful for building you own stoptag set. -# -# The entire possible tagset is provided below for convenience. -# -##### -# noun: unclassified nouns -#名詞 -# -# noun-common: Common nouns or nouns where the sub-classification is undefined -#名詞-一般 -# -# noun-proper: Proper nouns where the sub-classification is undefined -#名詞-固有名詞 -# -# noun-proper-misc: miscellaneous proper nouns -#名詞-固有名詞-一般 -# -# noun-proper-person: Personal names where the sub-classification is undefined -#名詞-固有名詞-人名 -# -# noun-proper-person-misc: names that cannot be divided into surname and -# given name; foreign names; names where the surname or given name is unknown. -# e.g. お市の方 -#名詞-固有名詞-人名-一般 -# -# noun-proper-person-surname: Mainly Japanese surnames. -# e.g. 山田 -#名詞-固有名詞-人名-姓 -# -# noun-proper-person-given_name: Mainly Japanese given names. -# e.g. 太郎 -#名詞-固有名詞-人名-名 -# -# noun-proper-organization: Names representing organizations. -# e.g. 通産省, NHK -#名詞-固有名詞-組織 -# -# noun-proper-place: Place names where the sub-classification is undefined -#名詞-固有名詞-地域 -# -# noun-proper-place-misc: Place names excluding countries. -# e.g. アジア, バルセロナ, 京都 -#名詞-固有名詞-地域-一般 -# -# noun-proper-place-country: Country names. -# e.g. 日本, オーストラリア -#名詞-固有名詞-地域-国 -# -# noun-pronoun: Pronouns where the sub-classification is undefined -#名詞-代名詞 -# -# noun-pronoun-misc: miscellaneous pronouns: -# e.g. それ, ここ, あいつ, あなた, あちこち, いくつ, どこか, なに, みなさん, みんな, わたくし, われわれ -#名詞-代名詞-一般 -# -# noun-pronoun-contraction: Spoken language contraction made by combining a -# pronoun and the particle 'wa'. -# e.g. ありゃ, こりゃ, こりゃあ, そりゃ, そりゃあ -#名詞-代名詞-縮約 -# -# noun-adverbial: Temporal nouns such as names of days or months that behave -# like adverbs. Nouns that represent amount or ratios and can be used adverbially, -# e.g. 金曜, 一月, 午後, 少量 -#名詞-副詞可能 -# -# noun-verbal: Nouns that take arguments with case and can appear followed by -# 'suru' and related verbs (する, できる, なさる, くださる) -# e.g. インプット, 愛着, 悪化, 悪戦苦闘, 一安心, 下取り -#名詞-サ変接続 -# -# noun-adjective-base: The base form of adjectives, words that appear before な ("na") -# e.g. 健康, 安易, 駄目, だめ -#名詞-形容動詞語幹 -# -# noun-numeric: Arabic numbers, Chinese numerals, and counters like 何 (回), 数. -# e.g. 0, 1, 2, 何, 数, 幾 -#名詞-数 -# -# noun-affix: noun affixes where the sub-classification is undefined -#名詞-非自立 -# -# noun-affix-misc: Of adnominalizers, the case-marker の ("no"), and words that -# attach to the base form of inflectional words, words that cannot be classified -# into any of the other categories below. This category includes indefinite nouns. -# e.g. あかつき, 暁, かい, 甲斐, 気, きらい, 嫌い, くせ, 癖, こと, 事, ごと, 毎, しだい, 次第, -# 順, せい, 所為, ついで, 序で, つもり, 積もり, 点, どころ, の, はず, 筈, はずみ, 弾み, -# 拍子, ふう, ふり, 振り, ほう, 方, 旨, もの, 物, 者, ゆえ, 故, ゆえん, 所以, わけ, 訳, -# わり, 割り, 割, ん-口語/, もん-口語/ -#名詞-非自立-一般 -# -# noun-affix-adverbial: noun affixes that that can behave as adverbs. -# e.g. あいだ, 間, あげく, 挙げ句, あと, 後, 余り, 以外, 以降, 以後, 以上, 以前, 一方, うえ, -# 上, うち, 内, おり, 折り, かぎり, 限り, きり, っきり, 結果, ころ, 頃, さい, 際, 最中, さなか, -# 最中, じたい, 自体, たび, 度, ため, 為, つど, 都度, とおり, 通り, とき, 時, ところ, 所, -# とたん, 途端, なか, 中, のち, 後, ばあい, 場合, 日, ぶん, 分, ほか, 他, まえ, 前, まま, -# 儘, 侭, みぎり, 矢先 -#名詞-非自立-副詞可能 -# -# noun-affix-aux: noun affixes treated as 助動詞 ("auxiliary verb") in school grammars -# with the stem よう(だ) ("you(da)"). -# e.g. よう, やう, 様 (よう) -#名詞-非自立-助動詞語幹 -# -# noun-affix-adjective-base: noun affixes that can connect to the indeclinable -# connection form な (aux "da"). -# e.g. みたい, ふう -#名詞-非自立-形容動詞語幹 -# -# noun-special: special nouns where the sub-classification is undefined. -#名詞-特殊 -# -# noun-special-aux: The そうだ ("souda") stem form that is used for reporting news, is -# treated as 助動詞 ("auxiliary verb") in school grammars, and attach to the base -# form of inflectional words. -# e.g. そう -#名詞-特殊-助動詞語幹 -# -# noun-suffix: noun suffixes where the sub-classification is undefined. -#名詞-接尾 -# -# noun-suffix-misc: Of the nouns or stem forms of other parts of speech that connect -# to ガル or タイ and can combine into compound nouns, words that cannot be classified into -# any of the other categories below. In general, this category is more inclusive than -# 接尾語 ("suffix") and is usually the last element in a compound noun. -# e.g. おき, かた, 方, 甲斐 (がい), がかり, ぎみ, 気味, ぐるみ, (~した) さ, 次第, 済 (ず) み, -# よう, (でき)っこ, 感, 観, 性, 学, 類, 面, 用 -#名詞-接尾-一般 -# -# noun-suffix-person: Suffixes that form nouns and attach to person names more often -# than other nouns. -# e.g. 君, 様, 著 -#名詞-接尾-人名 -# -# noun-suffix-place: Suffixes that form nouns and attach to place names more often -# than other nouns. -# e.g. 町, 市, 県 -#名詞-接尾-地域 -# -# noun-suffix-verbal: Of the suffixes that attach to nouns and form nouns, those that -# can appear before スル ("suru"). -# e.g. 化, 視, 分け, 入り, 落ち, 買い -#名詞-接尾-サ変接続 -# -# noun-suffix-aux: The stem form of そうだ (様態) that is used to indicate conditions, -# is treated as 助動詞 ("auxiliary verb") in school grammars, and attach to the -# conjunctive form of inflectional words. -# e.g. そう -#名詞-接尾-助動詞語幹 -# -# noun-suffix-adjective-base: Suffixes that attach to other nouns or the conjunctive -# form of inflectional words and appear before the copula だ ("da"). -# e.g. 的, げ, がち -#名詞-接尾-形容動詞語幹 -# -# noun-suffix-adverbial: Suffixes that attach to other nouns and can behave as adverbs. -# e.g. 後 (ご), 以後, 以降, 以前, 前後, 中, 末, 上, 時 (じ) -#名詞-接尾-副詞可能 -# -# noun-suffix-classifier: Suffixes that attach to numbers and form nouns. This category -# is more inclusive than 助数詞 ("classifier") and includes common nouns that attach -# to numbers. -# e.g. 個, つ, 本, 冊, パーセント, cm, kg, カ月, か国, 区画, 時間, 時半 -#名詞-接尾-助数詞 -# -# noun-suffix-special: Special suffixes that mainly attach to inflecting words. -# e.g. (楽し) さ, (考え) 方 -#名詞-接尾-特殊 -# -# noun-suffix-conjunctive: Nouns that behave like conjunctions and join two words -# together. -# e.g. (日本) 対 (アメリカ), 対 (アメリカ), (3) 対 (5), (女優) 兼 (主婦) -#名詞-接続詞的 -# -# noun-verbal_aux: Nouns that attach to the conjunctive particle て ("te") and are -# semantically verb-like. -# e.g. ごらん, ご覧, 御覧, 頂戴 -#名詞-動詞非自立的 -# -# noun-quotation: text that cannot be segmented into words, proverbs, Chinese poetry, -# dialects, English, etc. Currently, the only entry for 名詞 引用文字列 ("noun quotation") -# is いわく ("iwaku"). -#名詞-引用文字列 -# -# noun-nai_adjective: Words that appear before the auxiliary verb ない ("nai") and -# behave like an adjective. -# e.g. 申し訳, 仕方, とんでも, 違い -#名詞-ナイ形容詞語幹 -# -##### -# prefix: unclassified prefixes -#接頭詞 -# -# prefix-nominal: Prefixes that attach to nouns (including adjective stem forms) -# excluding numerical expressions. -# e.g. お (水), 某 (氏), 同 (社), 故 (~氏), 高 (品質), お (見事), ご (立派) -#接頭詞-名詞接続 -# -# prefix-verbal: Prefixes that attach to the imperative form of a verb or a verb -# in conjunctive form followed by なる/なさる/くださる. -# e.g. お (読みなさい), お (座り) -#接頭詞-動詞接続 -# -# prefix-adjectival: Prefixes that attach to adjectives. -# e.g. お (寒いですねえ), バカ (でかい) -#接頭詞-形容詞接続 -# -# prefix-numerical: Prefixes that attach to numerical expressions. -# e.g. 約, およそ, 毎時 -#接頭詞-数接続 -# -##### -# verb: unclassified verbs -#動詞 -# -# verb-main: -#動詞-自立 -# -# verb-auxiliary: -#動詞-非自立 -# -# verb-suffix: -#動詞-接尾 -# -##### -# adjective: unclassified adjectives -#形容詞 -# -# adjective-main: -#形容詞-自立 -# -# adjective-auxiliary: -#形容詞-非自立 -# -# adjective-suffix: -#形容詞-接尾 -# -##### -# adverb: unclassified adverbs -#副詞 -# -# adverb-misc: Words that can be segmented into one unit and where adnominal -# modification is not possible. -# e.g. あいかわらず, 多分 -#副詞-一般 -# -# adverb-particle_conjunction: Adverbs that can be followed by の, は, に, -# な, する, だ, etc. -# e.g. こんなに, そんなに, あんなに, なにか, なんでも -#副詞-助詞類接続 -# -##### -# adnominal: Words that only have noun-modifying forms. -# e.g. この, その, あの, どの, いわゆる, なんらかの, 何らかの, いろんな, こういう, そういう, ああいう, -# どういう, こんな, そんな, あんな, どんな, 大きな, 小さな, おかしな, ほんの, たいした, -# 「(, も) さる (ことながら)」, 微々たる, 堂々たる, 単なる, いかなる, 我が」「同じ, 亡き -#連体詞 -# -##### -# conjunction: Conjunctions that can occur independently. -# e.g. が, けれども, そして, じゃあ, それどころか -接続詞 -# -##### -# particle: unclassified particles. -助詞 -# -# particle-case: case particles where the subclassification is undefined. -助詞-格助詞 -# -# particle-case-misc: Case particles. -# e.g. から, が, で, と, に, へ, より, を, の, にて -助詞-格助詞-一般 -# -# particle-case-quote: the "to" that appears after nouns, a person’s speech, -# quotation marks, expressions of decisions from a meeting, reasons, judgements, -# conjectures, etc. -# e.g. ( だ) と (述べた.), ( である) と (して執行猶予...) -助詞-格助詞-引用 -# -# particle-case-compound: Compounds of particles and verbs that mainly behave -# like case particles. -# e.g. という, といった, とかいう, として, とともに, と共に, でもって, にあたって, に当たって, に当って, -# にあたり, に当たり, に当り, に当たる, にあたる, において, に於いて,に於て, における, に於ける, -# にかけ, にかけて, にかんし, に関し, にかんして, に関して, にかんする, に関する, に際し, -# に際して, にしたがい, に従い, に従う, にしたがって, に従って, にたいし, に対し, にたいして, -# に対して, にたいする, に対する, について, につき, につけ, につけて, につれ, につれて, にとって, -# にとり, にまつわる, によって, に依って, に因って, により, に依り, に因り, による, に依る, に因る, -# にわたって, にわたる, をもって, を以って, を通じ, を通じて, を通して, をめぐって, をめぐり, をめぐる, -# って-口語/, ちゅう-関西弁「という」/, (何) ていう (人)-口語/, っていう-口語/, といふ, とかいふ -助詞-格助詞-連語 -# -# particle-conjunctive: -# e.g. から, からには, が, けれど, けれども, けど, し, つつ, て, で, と, ところが, どころか, とも, ども, -# ながら, なり, ので, のに, ば, ものの, や ( した), やいなや, (ころん) じゃ(いけない)-口語/, -# (行っ) ちゃ(いけない)-口語/, (言っ) たって (しかたがない)-口語/, (それがなく)ったって (平気)-口語/ -助詞-接続助詞 -# -# particle-dependency: -# e.g. こそ, さえ, しか, すら, は, も, ぞ -助詞-係助詞 -# -# particle-adverbial: -# e.g. がてら, かも, くらい, 位, ぐらい, しも, (学校) じゃ(これが流行っている)-口語/, -# (それ)じゃあ (よくない)-口語/, ずつ, (私) なぞ, など, (私) なり (に), (先生) なんか (大嫌い)-口語/, -# (私) なんぞ, (先生) なんて (大嫌い)-口語/, のみ, だけ, (私) だって-口語/, だに, -# (彼)ったら-口語/, (お茶) でも (いかが), 等 (とう), (今後) とも, ばかり, ばっか-口語/, ばっかり-口語/, -# ほど, 程, まで, 迄, (誰) も (が)([助詞-格助詞] および [助詞-係助詞] の前に位置する「も」) -助詞-副助詞 -# -# particle-interjective: particles with interjective grammatical roles. -# e.g. (松島) や -助詞-間投助詞 -# -# particle-coordinate: -# e.g. と, たり, だの, だり, とか, なり, や, やら -助詞-並立助詞 -# -# particle-final: -# e.g. かい, かしら, さ, ぜ, (だ)っけ-口語/, (とまってる) で-方言/, な, ナ, なあ-口語/, ぞ, ね, ネ, -# ねぇ-口語/, ねえ-口語/, ねん-方言/, の, のう-口語/, や, よ, ヨ, よぉ-口語/, わ, わい-口語/ -助詞-終助詞 -# -# particle-adverbial/conjunctive/final: The particle "ka" when unknown whether it is -# adverbial, conjunctive, or sentence final. For example: -# (a) 「A か B か」. Ex:「(国内で運用する) か,(海外で運用する) か (.)」 -# (b) Inside an adverb phrase. Ex:「(幸いという) か (, 死者はいなかった.)」 -# 「(祈りが届いたせい) か (, 試験に合格した.)」 -# (c) 「かのように」. Ex:「(何もなかった) か (のように振る舞った.)」 -# e.g. か -助詞-副助詞/並立助詞/終助詞 -# -# particle-adnominalizer: The "no" that attaches to nouns and modifies -# non-inflectional words. -助詞-連体化 -# -# particle-adnominalizer: The "ni" and "to" that appear following nouns and adverbs -# that are giongo, giseigo, or gitaigo. -# e.g. に, と -助詞-副詞化 -# -# particle-special: A particle that does not fit into one of the above classifications. -# This includes particles that are used in Tanka, Haiku, and other poetry. -# e.g. かな, けむ, ( しただろう) に, (あんた) にゃ(わからん), (俺) ん (家) -助詞-特殊 -# -##### -# auxiliary-verb: -助動詞 -# -##### -# interjection: Greetings and other exclamations. -# e.g. おはよう, おはようございます, こんにちは, こんばんは, ありがとう, どうもありがとう, ありがとうございます, -# いただきます, ごちそうさま, さよなら, さようなら, はい, いいえ, ごめん, ごめんなさい -#感動詞 -# -##### -# symbol: unclassified Symbols. -記号 -# -# symbol-misc: A general symbol not in one of the categories below. -# e.g. [○◎@$〒→+] -記号-一般 -# -# symbol-comma: Commas -# e.g. [,、] -記号-読点 -# -# symbol-period: Periods and full stops. -# e.g. [..。] -記号-句点 -# -# symbol-space: Full-width whitespace. -記号-空白 -# -# symbol-open_bracket: -# e.g. [({‘“『【] -記号-括弧開 -# -# symbol-close_bracket: -# e.g. [)}’”』」】] -記号-括弧閉 -# -# symbol-alphabetic: -#記号-アルファベット -# -##### -# other: unclassified other -#その他 -# -# other-interjection: Words that are hard to classify as noun-suffixes or -# sentence-final particles. -# e.g. (だ)ァ -その他-間投 -# -##### -# filler: Aizuchi that occurs during a conversation or sounds inserted as filler. -# e.g. あの, うんと, えと -フィラー -# -##### -# non-verbal: non-verbal sound. -非言語音 -# -##### -# fragment: -#語断片 -# -##### -# unknown: unknown part of speech. -#未知語 -# -##### End of file +# +# This file defines a Japanese stoptag set for JapanesePartOfSpeechStopFilter. +# +# Any token with a part-of-speech tag that exactly matches those defined in this +# file are removed from the token stream. +# +# Set your own stoptags by uncommenting the lines below. Note that comments are +# not allowed on the same line as a stoptag. See LUCENE-3745 for frequency lists, +# etc. that can be useful for building you own stoptag set. +# +# The entire possible tagset is provided below for convenience. +# +##### +# noun: unclassified nouns +#名詞 +# +# noun-common: Common nouns or nouns where the sub-classification is undefined +#名詞-一般 +# +# noun-proper: Proper nouns where the sub-classification is undefined +#名詞-固有名詞 +# +# noun-proper-misc: miscellaneous proper nouns +#名詞-固有名詞-一般 +# +# noun-proper-person: Personal names where the sub-classification is undefined +#名詞-固有名詞-人名 +# +# noun-proper-person-misc: names that cannot be divided into surname and +# given name; foreign names; names where the surname or given name is unknown. +# e.g. お市の方 +#名詞-固有名詞-人名-一般 +# +# noun-proper-person-surname: Mainly Japanese surnames. +# e.g. 山田 +#名詞-固有名詞-人名-姓 +# +# noun-proper-person-given_name: Mainly Japanese given names. +# e.g. 太郎 +#名詞-固有名詞-人名-名 +# +# noun-proper-organization: Names representing organizations. +# e.g. 通産省, NHK +#名詞-固有名詞-組織 +# +# noun-proper-place: Place names where the sub-classification is undefined +#名詞-固有名詞-地域 +# +# noun-proper-place-misc: Place names excluding countries. +# e.g. アジア, バルセロナ, 京都 +#名詞-固有名詞-地域-一般 +# +# noun-proper-place-country: Country names. +# e.g. 日本, オーストラリア +#名詞-固有名詞-地域-国 +# +# noun-pronoun: Pronouns where the sub-classification is undefined +#名詞-代名詞 +# +# noun-pronoun-misc: miscellaneous pronouns: +# e.g. それ, ここ, あいつ, あなた, あちこち, いくつ, どこか, なに, みなさん, みんな, わたくし, われわれ +#名詞-代名詞-一般 +# +# noun-pronoun-contraction: Spoken language contraction made by combining a +# pronoun and the particle 'wa'. +# e.g. ありゃ, こりゃ, こりゃあ, そりゃ, そりゃあ +#名詞-代名詞-縮約 +# +# noun-adverbial: Temporal nouns such as names of days or months that behave +# like adverbs. Nouns that represent amount or ratios and can be used adverbially, +# e.g. 金曜, 一月, 午後, 少量 +#名詞-副詞可能 +# +# noun-verbal: Nouns that take arguments with case and can appear followed by +# 'suru' and related verbs (する, できる, なさる, くださる) +# e.g. インプット, 愛着, 悪化, 悪戦苦闘, 一安心, 下取り +#名詞-サ変接続 +# +# noun-adjective-base: The base form of adjectives, words that appear before な ("na") +# e.g. 健康, 安易, 駄目, だめ +#名詞-形容動詞語幹 +# +# noun-numeric: Arabic numbers, Chinese numerals, and counters like 何 (回), 数. +# e.g. 0, 1, 2, 何, 数, 幾 +#名詞-数 +# +# noun-affix: noun affixes where the sub-classification is undefined +#名詞-非自立 +# +# noun-affix-misc: Of adnominalizers, the case-marker の ("no"), and words that +# attach to the base form of inflectional words, words that cannot be classified +# into any of the other categories below. This category includes indefinite nouns. +# e.g. あかつき, 暁, かい, 甲斐, 気, きらい, 嫌い, くせ, 癖, こと, 事, ごと, 毎, しだい, 次第, +# 順, せい, 所為, ついで, 序で, つもり, 積もり, 点, どころ, の, はず, 筈, はずみ, 弾み, +# 拍子, ふう, ふり, 振り, ほう, 方, 旨, もの, 物, 者, ゆえ, 故, ゆえん, 所以, わけ, 訳, +# わり, 割り, 割, ん-口語/, もん-口語/ +#名詞-非自立-一般 +# +# noun-affix-adverbial: noun affixes that that can behave as adverbs. +# e.g. あいだ, 間, あげく, 挙げ句, あと, 後, 余り, 以外, 以降, 以後, 以上, 以前, 一方, うえ, +# 上, うち, 内, おり, 折り, かぎり, 限り, きり, っきり, 結果, ころ, 頃, さい, 際, 最中, さなか, +# 最中, じたい, 自体, たび, 度, ため, 為, つど, 都度, とおり, 通り, とき, 時, ところ, 所, +# とたん, 途端, なか, 中, のち, 後, ばあい, 場合, 日, ぶん, 分, ほか, 他, まえ, 前, まま, +# 儘, 侭, みぎり, 矢先 +#名詞-非自立-副詞可能 +# +# noun-affix-aux: noun affixes treated as 助動詞 ("auxiliary verb") in school grammars +# with the stem よう(だ) ("you(da)"). +# e.g. よう, やう, 様 (よう) +#名詞-非自立-助動詞語幹 +# +# noun-affix-adjective-base: noun affixes that can connect to the indeclinable +# connection form な (aux "da"). +# e.g. みたい, ふう +#名詞-非自立-形容動詞語幹 +# +# noun-special: special nouns where the sub-classification is undefined. +#名詞-特殊 +# +# noun-special-aux: The そうだ ("souda") stem form that is used for reporting news, is +# treated as 助動詞 ("auxiliary verb") in school grammars, and attach to the base +# form of inflectional words. +# e.g. そう +#名詞-特殊-助動詞語幹 +# +# noun-suffix: noun suffixes where the sub-classification is undefined. +#名詞-接尾 +# +# noun-suffix-misc: Of the nouns or stem forms of other parts of speech that connect +# to ガル or タイ and can combine into compound nouns, words that cannot be classified into +# any of the other categories below. In general, this category is more inclusive than +# 接尾語 ("suffix") and is usually the last element in a compound noun. +# e.g. おき, かた, 方, 甲斐 (がい), がかり, ぎみ, 気味, ぐるみ, (~した) さ, 次第, 済 (ず) み, +# よう, (でき)っこ, 感, 観, 性, 学, 類, 面, 用 +#名詞-接尾-一般 +# +# noun-suffix-person: Suffixes that form nouns and attach to person names more often +# than other nouns. +# e.g. 君, 様, 著 +#名詞-接尾-人名 +# +# noun-suffix-place: Suffixes that form nouns and attach to place names more often +# than other nouns. +# e.g. 町, 市, 県 +#名詞-接尾-地域 +# +# noun-suffix-verbal: Of the suffixes that attach to nouns and form nouns, those that +# can appear before スル ("suru"). +# e.g. 化, 視, 分け, 入り, 落ち, 買い +#名詞-接尾-サ変接続 +# +# noun-suffix-aux: The stem form of そうだ (様態) that is used to indicate conditions, +# is treated as 助動詞 ("auxiliary verb") in school grammars, and attach to the +# conjunctive form of inflectional words. +# e.g. そう +#名詞-接尾-助動詞語幹 +# +# noun-suffix-adjective-base: Suffixes that attach to other nouns or the conjunctive +# form of inflectional words and appear before the copula だ ("da"). +# e.g. 的, げ, がち +#名詞-接尾-形容動詞語幹 +# +# noun-suffix-adverbial: Suffixes that attach to other nouns and can behave as adverbs. +# e.g. 後 (ご), 以後, 以降, 以前, 前後, 中, 末, 上, 時 (じ) +#名詞-接尾-副詞可能 +# +# noun-suffix-classifier: Suffixes that attach to numbers and form nouns. This category +# is more inclusive than 助数詞 ("classifier") and includes common nouns that attach +# to numbers. +# e.g. 個, つ, 本, 冊, パーセント, cm, kg, カ月, か国, 区画, 時間, 時半 +#名詞-接尾-助数詞 +# +# noun-suffix-special: Special suffixes that mainly attach to inflecting words. +# e.g. (楽し) さ, (考え) 方 +#名詞-接尾-特殊 +# +# noun-suffix-conjunctive: Nouns that behave like conjunctions and join two words +# together. +# e.g. (日本) 対 (アメリカ), 対 (アメリカ), (3) 対 (5), (女優) 兼 (主婦) +#名詞-接続詞的 +# +# noun-verbal_aux: Nouns that attach to the conjunctive particle て ("te") and are +# semantically verb-like. +# e.g. ごらん, ご覧, 御覧, 頂戴 +#名詞-動詞非自立的 +# +# noun-quotation: text that cannot be segmented into words, proverbs, Chinese poetry, +# dialects, English, etc. Currently, the only entry for 名詞 引用文字列 ("noun quotation") +# is いわく ("iwaku"). +#名詞-引用文字列 +# +# noun-nai_adjective: Words that appear before the auxiliary verb ない ("nai") and +# behave like an adjective. +# e.g. 申し訳, 仕方, とんでも, 違い +#名詞-ナイ形容詞語幹 +# +##### +# prefix: unclassified prefixes +#接頭詞 +# +# prefix-nominal: Prefixes that attach to nouns (including adjective stem forms) +# excluding numerical expressions. +# e.g. お (水), 某 (氏), 同 (社), 故 (~氏), 高 (品質), お (見事), ご (立派) +#接頭詞-名詞接続 +# +# prefix-verbal: Prefixes that attach to the imperative form of a verb or a verb +# in conjunctive form followed by なる/なさる/くださる. +# e.g. お (読みなさい), お (座り) +#接頭詞-動詞接続 +# +# prefix-adjectival: Prefixes that attach to adjectives. +# e.g. お (寒いですねえ), バカ (でかい) +#接頭詞-形容詞接続 +# +# prefix-numerical: Prefixes that attach to numerical expressions. +# e.g. 約, およそ, 毎時 +#接頭詞-数接続 +# +##### +# verb: unclassified verbs +#動詞 +# +# verb-main: +#動詞-自立 +# +# verb-auxiliary: +#動詞-非自立 +# +# verb-suffix: +#動詞-接尾 +# +##### +# adjective: unclassified adjectives +#形容詞 +# +# adjective-main: +#形容詞-自立 +# +# adjective-auxiliary: +#形容詞-非自立 +# +# adjective-suffix: +#形容詞-接尾 +# +##### +# adverb: unclassified adverbs +#副詞 +# +# adverb-misc: Words that can be segmented into one unit and where adnominal +# modification is not possible. +# e.g. あいかわらず, 多分 +#副詞-一般 +# +# adverb-particle_conjunction: Adverbs that can be followed by の, は, に, +# な, する, だ, etc. +# e.g. こんなに, そんなに, あんなに, なにか, なんでも +#副詞-助詞類接続 +# +##### +# adnominal: Words that only have noun-modifying forms. +# e.g. この, その, あの, どの, いわゆる, なんらかの, 何らかの, いろんな, こういう, そういう, ああいう, +# どういう, こんな, そんな, あんな, どんな, 大きな, 小さな, おかしな, ほんの, たいした, +# 「(, も) さる (ことながら)」, 微々たる, 堂々たる, 単なる, いかなる, 我が」「同じ, 亡き +#連体詞 +# +##### +# conjunction: Conjunctions that can occur independently. +# e.g. が, けれども, そして, じゃあ, それどころか +接続詞 +# +##### +# particle: unclassified particles. +助詞 +# +# particle-case: case particles where the subclassification is undefined. +助詞-格助詞 +# +# particle-case-misc: Case particles. +# e.g. から, が, で, と, に, へ, より, を, の, にて +助詞-格助詞-一般 +# +# particle-case-quote: the "to" that appears after nouns, a person’s speech, +# quotation marks, expressions of decisions from a meeting, reasons, judgements, +# conjectures, etc. +# e.g. ( だ) と (述べた.), ( である) と (して執行猶予...) +助詞-格助詞-引用 +# +# particle-case-compound: Compounds of particles and verbs that mainly behave +# like case particles. +# e.g. という, といった, とかいう, として, とともに, と共に, でもって, にあたって, に当たって, に当って, +# にあたり, に当たり, に当り, に当たる, にあたる, において, に於いて,に於て, における, に於ける, +# にかけ, にかけて, にかんし, に関し, にかんして, に関して, にかんする, に関する, に際し, +# に際して, にしたがい, に従い, に従う, にしたがって, に従って, にたいし, に対し, にたいして, +# に対して, にたいする, に対する, について, につき, につけ, につけて, につれ, につれて, にとって, +# にとり, にまつわる, によって, に依って, に因って, により, に依り, に因り, による, に依る, に因る, +# にわたって, にわたる, をもって, を以って, を通じ, を通じて, を通して, をめぐって, をめぐり, をめぐる, +# って-口語/, ちゅう-関西弁「という」/, (何) ていう (人)-口語/, っていう-口語/, といふ, とかいふ +助詞-格助詞-連語 +# +# particle-conjunctive: +# e.g. から, からには, が, けれど, けれども, けど, し, つつ, て, で, と, ところが, どころか, とも, ども, +# ながら, なり, ので, のに, ば, ものの, や ( した), やいなや, (ころん) じゃ(いけない)-口語/, +# (行っ) ちゃ(いけない)-口語/, (言っ) たって (しかたがない)-口語/, (それがなく)ったって (平気)-口語/ +助詞-接続助詞 +# +# particle-dependency: +# e.g. こそ, さえ, しか, すら, は, も, ぞ +助詞-係助詞 +# +# particle-adverbial: +# e.g. がてら, かも, くらい, 位, ぐらい, しも, (学校) じゃ(これが流行っている)-口語/, +# (それ)じゃあ (よくない)-口語/, ずつ, (私) なぞ, など, (私) なり (に), (先生) なんか (大嫌い)-口語/, +# (私) なんぞ, (先生) なんて (大嫌い)-口語/, のみ, だけ, (私) だって-口語/, だに, +# (彼)ったら-口語/, (お茶) でも (いかが), 等 (とう), (今後) とも, ばかり, ばっか-口語/, ばっかり-口語/, +# ほど, 程, まで, 迄, (誰) も (が)([助詞-格助詞] および [助詞-係助詞] の前に位置する「も」) +助詞-副助詞 +# +# particle-interjective: particles with interjective grammatical roles. +# e.g. (松島) や +助詞-間投助詞 +# +# particle-coordinate: +# e.g. と, たり, だの, だり, とか, なり, や, やら +助詞-並立助詞 +# +# particle-final: +# e.g. かい, かしら, さ, ぜ, (だ)っけ-口語/, (とまってる) で-方言/, な, ナ, なあ-口語/, ぞ, ね, ネ, +# ねぇ-口語/, ねえ-口語/, ねん-方言/, の, のう-口語/, や, よ, ヨ, よぉ-口語/, わ, わい-口語/ +助詞-終助詞 +# +# particle-adverbial/conjunctive/final: The particle "ka" when unknown whether it is +# adverbial, conjunctive, or sentence final. For example: +# (a) 「A か B か」. Ex:「(国内で運用する) か,(海外で運用する) か (.)」 +# (b) Inside an adverb phrase. Ex:「(幸いという) か (, 死者はいなかった.)」 +# 「(祈りが届いたせい) か (, 試験に合格した.)」 +# (c) 「かのように」. Ex:「(何もなかった) か (のように振る舞った.)」 +# e.g. か +助詞-副助詞/並立助詞/終助詞 +# +# particle-adnominalizer: The "no" that attaches to nouns and modifies +# non-inflectional words. +助詞-連体化 +# +# particle-adnominalizer: The "ni" and "to" that appear following nouns and adverbs +# that are giongo, giseigo, or gitaigo. +# e.g. に, と +助詞-副詞化 +# +# particle-special: A particle that does not fit into one of the above classifications. +# This includes particles that are used in Tanka, Haiku, and other poetry. +# e.g. かな, けむ, ( しただろう) に, (あんた) にゃ(わからん), (俺) ん (家) +助詞-特殊 +# +##### +# auxiliary-verb: +助動詞 +# +##### +# interjection: Greetings and other exclamations. +# e.g. おはよう, おはようございます, こんにちは, こんばんは, ありがとう, どうもありがとう, ありがとうございます, +# いただきます, ごちそうさま, さよなら, さようなら, はい, いいえ, ごめん, ごめんなさい +#感動詞 +# +##### +# symbol: unclassified Symbols. +記号 +# +# symbol-misc: A general symbol not in one of the categories below. +# e.g. [○◎@$〒→+] +記号-一般 +# +# symbol-comma: Commas +# e.g. [,、] +記号-読点 +# +# symbol-period: Periods and full stops. +# e.g. [..。] +記号-句点 +# +# symbol-space: Full-width whitespace. +記号-空白 +# +# symbol-open_bracket: +# e.g. [({‘“『【] +記号-括弧開 +# +# symbol-close_bracket: +# e.g. [)}’”』」】] +記号-括弧閉 +# +# symbol-alphabetic: +#記号-アルファベット +# +##### +# other: unclassified other +#その他 +# +# other-interjection: Words that are hard to classify as noun-suffixes or +# sentence-final particles. +# e.g. (だ)ァ +その他-間投 +# +##### +# filler: Aizuchi that occurs during a conversation or sounds inserted as filler. +# e.g. あの, うんと, えと +フィラー +# +##### +# non-verbal: non-verbal sound. +非言語音 +# +##### +# fragment: +#語断片 +# +##### +# unknown: unknown part of speech. +#未知語 +# +##### End of file diff --git a/resources/cache/empty/entity/conf/lang/stopwords_ar.txt b/resources/cache/empty/entity/conf/lang/stopwords_ar.txt index aca24303..046829db 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_ar.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_ar.txt @@ -1,125 +1,125 @@ -# This file was created by Jacques Savoy and is distributed under the BSD license. -# See http://members.unine.ch/jacques.savoy/clef/index.html. -# Also see http://www.opensource.org/licenses/bsd-license.html -# Cleaned on October 11, 2009 (not normalized, so use before normalization) -# This means that when modifying this list, you might need to add some -# redundant entries, for example containing forms with both أ and ا -من -ومن -منها -منه -في -وفي -فيها -فيه -و -ف -ثم -او -أو -ب -بها -به -ا -أ -اى -اي -أي -أى -لا -ولا -الا -ألا -إلا -لكن -ما -وما -كما -فما -عن -مع -اذا -إذا -ان -أن -إن -انها -أنها -إنها -انه -أنه -إنه -بان -بأن -فان -فأن -وان -وأن -وإن -التى -التي -الذى -الذي -الذين -الى -الي -إلى -إلي -على -عليها -عليه -اما -أما -إما -ايضا -أيضا -كل -وكل -لم -ولم -لن -ولن -هى -هي -هو -وهى -وهي -وهو -فهى -فهي -فهو -انت -أنت -لك -لها -له -هذه -هذا -تلك -ذلك -هناك -كانت -كان -يكون -تكون -وكانت -وكان -غير -بعض -قد -نحو -بين -بينما -منذ -ضمن -حيث -الان -الآن -خلال -بعد -قبل -حتى -عند -عندما -لدى -جميع +# This file was created by Jacques Savoy and is distributed under the BSD license. +# See http://members.unine.ch/jacques.savoy/clef/index.html. +# Also see http://www.opensource.org/licenses/bsd-license.html +# Cleaned on October 11, 2009 (not normalized, so use before normalization) +# This means that when modifying this list, you might need to add some +# redundant entries, for example containing forms with both أ and ا +من +ومن +منها +منه +في +وفي +فيها +فيه +و +ف +ثم +او +أو +ب +بها +به +ا +أ +اى +اي +أي +أى +لا +ولا +الا +ألا +إلا +لكن +ما +وما +كما +فما +عن +مع +اذا +إذا +ان +أن +إن +انها +أنها +إنها +انه +أنه +إنه +بان +بأن +فان +فأن +وان +وأن +وإن +التى +التي +الذى +الذي +الذين +الى +الي +إلى +إلي +على +عليها +عليه +اما +أما +إما +ايضا +أيضا +كل +وكل +لم +ولم +لن +ولن +هى +هي +هو +وهى +وهي +وهو +فهى +فهي +فهو +انت +أنت +لك +لها +له +هذه +هذا +تلك +ذلك +هناك +كانت +كان +يكون +تكون +وكانت +وكان +غير +بعض +قد +نحو +بين +بينما +منذ +ضمن +حيث +الان +الآن +خلال +بعد +قبل +حتى +عند +عندما +لدى +جميع diff --git a/resources/cache/empty/entity/conf/lang/stopwords_bg.txt b/resources/cache/empty/entity/conf/lang/stopwords_bg.txt index 842ee8a8..1ae4ba2a 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_bg.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_bg.txt @@ -1,193 +1,193 @@ -# This file was created by Jacques Savoy and is distributed under the BSD license. -# See http://members.unine.ch/jacques.savoy/clef/index.html. -# Also see http://www.opensource.org/licenses/bsd-license.html -а -аз -ако -ала -бе -без -беше -би -бил -била -били -било -близо -бъдат -бъде -бяха -в -вас -ваш -ваша -вероятно -вече -взема -ви -вие -винаги -все -всеки -всички -всичко -всяка -във -въпреки -върху -г -ги -главно -го -д -да -дали -до -докато -докога -дори -досега -доста -е -едва -един -ето -за -зад -заедно -заради -засега -затова -защо -защото -и -из -или -им -има -имат -иска -й -каза -как -каква -какво -както -какъв -като -кога -когато -което -които -кой -който -колко -която -къде -където -към -ли -м -ме -между -мен -ми -мнозина -мога -могат -може -моля -момента -му -н -на -над -назад -най -направи -напред -например -нас -не -него -нея -ни -ние -никой -нито -но -някои -някой -няма -обаче -около -освен -особено -от -отгоре -отново -още -пак -по -повече -повечето -под -поне -поради -после -почти -прави -пред -преди -през -при -пък -първо -с -са -само -се -сега -си -скоро -след -сме -според -сред -срещу -сте -съм -със -също -т -тази -така -такива -такъв -там -твой -те -тези -ти -тн -то -това -тогава -този -той -толкова -точно -трябва -тук -тъй -тя -тях -у -харесва -ч -че -често -чрез -ще -щом -я +# This file was created by Jacques Savoy and is distributed under the BSD license. +# See http://members.unine.ch/jacques.savoy/clef/index.html. +# Also see http://www.opensource.org/licenses/bsd-license.html +а +аз +ако +ала +бе +без +беше +би +бил +била +били +било +близо +бъдат +бъде +бяха +в +вас +ваш +ваша +вероятно +вече +взема +ви +вие +винаги +все +всеки +всички +всичко +всяка +във +въпреки +върху +г +ги +главно +го +д +да +дали +до +докато +докога +дори +досега +доста +е +едва +един +ето +за +зад +заедно +заради +засега +затова +защо +защото +и +из +или +им +има +имат +иска +й +каза +как +каква +какво +както +какъв +като +кога +когато +което +които +кой +който +колко +която +къде +където +към +ли +м +ме +между +мен +ми +мнозина +мога +могат +може +моля +момента +му +н +на +над +назад +най +направи +напред +например +нас +не +него +нея +ни +ние +никой +нито +но +някои +някой +няма +обаче +около +освен +особено +от +отгоре +отново +още +пак +по +повече +повечето +под +поне +поради +после +почти +прави +пред +преди +през +при +пък +първо +с +са +само +се +сега +си +скоро +след +сме +според +сред +срещу +сте +съм +със +също +т +тази +така +такива +такъв +там +твой +те +тези +ти +тн +то +това +тогава +този +той +толкова +точно +трябва +тук +тъй +тя +тях +у +харесва +ч +че +често +чрез +ще +щом +я diff --git a/resources/cache/empty/entity/conf/lang/stopwords_ca.txt b/resources/cache/empty/entity/conf/lang/stopwords_ca.txt index e618af55..3da65dea 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_ca.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_ca.txt @@ -1,220 +1,220 @@ -# Catalan stopwords from http://github.com/vcl/cue.language (Apache 2 Licensed) -a -abans -ací -ah -així -això -al -als -aleshores -algun -alguna -algunes -alguns -alhora -allà -allí -allò -altra -altre -altres -amb -ambdós -ambdues -apa -aquell -aquella -aquelles -aquells -aquest -aquesta -aquestes -aquests -aquí -baix -cada -cadascú -cadascuna -cadascunes -cadascuns -com -contra -d'un -d'una -d'unes -d'uns -dalt -de -del -dels -des -després -dins -dintre -donat -doncs -durant -e -eh -el -els -em -en -encara -ens -entre -érem -eren -éreu -es -és -esta -està -estàvem -estaven -estàveu -esteu -et -etc -ets -fins -fora -gairebé -ha -han -has -havia -he -hem -heu -hi -ho -i -igual -iguals -ja -l'hi -la -les -li -li'n -llavors -m'he -ma -mal -malgrat -mateix -mateixa -mateixes -mateixos -me -mentre -més -meu -meus -meva -meves -molt -molta -moltes -molts -mon -mons -n'he -n'hi -ne -ni -no -nogensmenys -només -nosaltres -nostra -nostre -nostres -o -oh -oi -on -pas -pel -pels -per -però -perquè -poc -poca -pocs -poques -potser -propi -qual -quals -quan -quant -que -què -quelcom -qui -quin -quina -quines -quins -s'ha -s'han -sa -semblant -semblants -ses -seu -seus -seva -seva -seves -si -sobre -sobretot -sóc -solament -sols -son -són -sons -sota -sou -t'ha -t'han -t'he -ta -tal -també -tampoc -tan -tant -tanta -tantes -teu -teus -teva -teves -ton -tons -tot -tota -totes -tots -un -una -unes -uns -us -va -vaig -vam -van -vas -veu -vosaltres -vostra -vostre -vostres +# Catalan stopwords from http://github.com/vcl/cue.language (Apache 2 Licensed) +a +abans +ací +ah +així +això +al +als +aleshores +algun +alguna +algunes +alguns +alhora +allà +allí +allò +altra +altre +altres +amb +ambdós +ambdues +apa +aquell +aquella +aquelles +aquells +aquest +aquesta +aquestes +aquests +aquí +baix +cada +cadascú +cadascuna +cadascunes +cadascuns +com +contra +d'un +d'una +d'unes +d'uns +dalt +de +del +dels +des +després +dins +dintre +donat +doncs +durant +e +eh +el +els +em +en +encara +ens +entre +érem +eren +éreu +es +és +esta +està +estàvem +estaven +estàveu +esteu +et +etc +ets +fins +fora +gairebé +ha +han +has +havia +he +hem +heu +hi +ho +i +igual +iguals +ja +l'hi +la +les +li +li'n +llavors +m'he +ma +mal +malgrat +mateix +mateixa +mateixes +mateixos +me +mentre +més +meu +meus +meva +meves +molt +molta +moltes +molts +mon +mons +n'he +n'hi +ne +ni +no +nogensmenys +només +nosaltres +nostra +nostre +nostres +o +oh +oi +on +pas +pel +pels +per +però +perquè +poc +poca +pocs +poques +potser +propi +qual +quals +quan +quant +que +què +quelcom +qui +quin +quina +quines +quins +s'ha +s'han +sa +semblant +semblants +ses +seu +seus +seva +seva +seves +si +sobre +sobretot +sóc +solament +sols +son +són +sons +sota +sou +t'ha +t'han +t'he +ta +tal +també +tampoc +tan +tant +tanta +tantes +teu +teus +teva +teves +ton +tons +tot +tota +totes +tots +un +una +unes +uns +us +va +vaig +vam +van +vas +veu +vosaltres +vostra +vostre +vostres diff --git a/resources/cache/empty/entity/conf/lang/stopwords_cz.txt b/resources/cache/empty/entity/conf/lang/stopwords_cz.txt index e928df95..53c6097d 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_cz.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_cz.txt @@ -1,172 +1,172 @@ -a -s -k -o -i -u -v -z -dnes -cz -tímto -budeš -budem -byli -jseš -můj -svým -ta -tomto -tohle -tuto -tyto -jej -zda -proč -máte -tato -kam -tohoto -kdo -kteří -mi -nám -tom -tomuto -mít -nic -proto -kterou -byla -toho -protože -asi -ho -naši -napište -re -což -tím -takže -svých -její -svými -jste -aj -tu -tedy -teto -bylo -kde -ke -pravé -ji -nad -nejsou -či -pod -téma -mezi -přes -ty -pak -vám -ani -když -však -neg -jsem -tento -článku -články -aby -jsme -před -pta -jejich -byl -ještě -až -bez -také -pouze -první -vaše -která -nás -nový -tipy -pokud -může -strana -jeho -své -jiné -zprávy -nové -není -vás -jen -podle -zde -už -být -více -bude -již -než -který -by -které -co -nebo -ten -tak -má -při -od -po -jsou -jak -další -ale -si -se -ve -to -jako -za -zpět -ze -do -pro -je -na -atd -atp -jakmile -přičemž -já -on -ona -ono -oni -ony -my -vy -jí -ji -mě -mne -jemu -tomu -těm -těmu -němu -němuž -jehož -jíž -jelikož -jež -jakož -načež +a +s +k +o +i +u +v +z +dnes +cz +tímto +budeš +budem +byli +jseš +můj +svým +ta +tomto +tohle +tuto +tyto +jej +zda +proč +máte +tato +kam +tohoto +kdo +kteří +mi +nám +tom +tomuto +mít +nic +proto +kterou +byla +toho +protože +asi +ho +naši +napište +re +což +tím +takže +svých +její +svými +jste +aj +tu +tedy +teto +bylo +kde +ke +pravé +ji +nad +nejsou +či +pod +téma +mezi +přes +ty +pak +vám +ani +když +však +neg +jsem +tento +článku +články +aby +jsme +před +pta +jejich +byl +ještě +až +bez +také +pouze +první +vaše +která +nás +nový +tipy +pokud +může +strana +jeho +své +jiné +zprávy +nové +není +vás +jen +podle +zde +už +být +více +bude +již +než +který +by +které +co +nebo +ten +tak +má +při +od +po +jsou +jak +další +ale +si +se +ve +to +jako +za +zpět +ze +do +pro +je +na +atd +atp +jakmile +přičemž +já +on +ona +ono +oni +ony +my +vy +jí +ji +mě +mne +jemu +tomu +těm +těmu +němu +němuž +jehož +jíž +jelikož +jež +jakož +načež diff --git a/resources/cache/empty/entity/conf/lang/stopwords_da.txt b/resources/cache/empty/entity/conf/lang/stopwords_da.txt index e25d49ce..42e6145b 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_da.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_da.txt @@ -1,110 +1,110 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/danish/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Danish stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - | This is a ranked list (commonest to rarest) of stopwords derived from - | a large text sample. - - -og | and -i | in -jeg | I -det | that (dem. pronoun)/it (pers. pronoun) -at | that (in front of a sentence)/to (with infinitive) -en | a/an -den | it (pers. pronoun)/that (dem. pronoun) -til | to/at/for/until/against/by/of/into, more -er | present tense of "to be" -som | who, as -på | on/upon/in/on/at/to/after/of/with/for, on -de | they -med | with/by/in, along -han | he -af | of/by/from/off/for/in/with/on, off -for | at/for/to/from/by/of/ago, in front/before, because -ikke | not -der | who/which, there/those -var | past tense of "to be" -mig | me/myself -sig | oneself/himself/herself/itself/themselves -men | but -et | a/an/one, one (number), someone/somebody/one -har | present tense of "to have" -om | round/about/for/in/a, about/around/down, if -vi | we -min | my -havde | past tense of "to have" -ham | him -hun | she -nu | now -over | over/above/across/by/beyond/past/on/about, over/past -da | then, when/as/since -fra | from/off/since, off, since -du | you -ud | out -sin | his/her/its/one's -dem | them -os | us/ourselves -op | up -man | you/one -hans | his -hvor | where -eller | or -hvad | what -skal | must/shall etc. -selv | myself/youself/herself/ourselves etc., even -her | here -alle | all/everyone/everybody etc. -vil | will (verb) -blev | past tense of "to stay/to remain/to get/to become" -kunne | could -ind | in -når | when -være | present tense of "to be" -dog | however/yet/after all -noget | something -ville | would -jo | you know/you see (adv), yes -deres | their/theirs -efter | after/behind/according to/for/by/from, later/afterwards -ned | down -skulle | should -denne | this -end | than -dette | this -mit | my/mine -også | also -under | under/beneath/below/during, below/underneath -have | have -dig | you -anden | other -hende | her -mine | my -alt | everything -meget | much/very, plenty of -sit | his, her, its, one's -sine | his, her, its, one's -vor | our -mod | against -disse | these -hvis | if -din | your/yours -nogle | some -hos | by/at -blive | be/become -mange | many -ad | by/through -bliver | present tense of "to be/to become" -hendes | her/hers -været | be -thi | for (conj) -jer | you -sådan | such, like this/like that + | From svn.tartarus.org/snowball/trunk/website/algorithms/danish/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Danish stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + | This is a ranked list (commonest to rarest) of stopwords derived from + | a large text sample. + + +og | and +i | in +jeg | I +det | that (dem. pronoun)/it (pers. pronoun) +at | that (in front of a sentence)/to (with infinitive) +en | a/an +den | it (pers. pronoun)/that (dem. pronoun) +til | to/at/for/until/against/by/of/into, more +er | present tense of "to be" +som | who, as +på | on/upon/in/on/at/to/after/of/with/for, on +de | they +med | with/by/in, along +han | he +af | of/by/from/off/for/in/with/on, off +for | at/for/to/from/by/of/ago, in front/before, because +ikke | not +der | who/which, there/those +var | past tense of "to be" +mig | me/myself +sig | oneself/himself/herself/itself/themselves +men | but +et | a/an/one, one (number), someone/somebody/one +har | present tense of "to have" +om | round/about/for/in/a, about/around/down, if +vi | we +min | my +havde | past tense of "to have" +ham | him +hun | she +nu | now +over | over/above/across/by/beyond/past/on/about, over/past +da | then, when/as/since +fra | from/off/since, off, since +du | you +ud | out +sin | his/her/its/one's +dem | them +os | us/ourselves +op | up +man | you/one +hans | his +hvor | where +eller | or +hvad | what +skal | must/shall etc. +selv | myself/youself/herself/ourselves etc., even +her | here +alle | all/everyone/everybody etc. +vil | will (verb) +blev | past tense of "to stay/to remain/to get/to become" +kunne | could +ind | in +når | when +være | present tense of "to be" +dog | however/yet/after all +noget | something +ville | would +jo | you know/you see (adv), yes +deres | their/theirs +efter | after/behind/according to/for/by/from, later/afterwards +ned | down +skulle | should +denne | this +end | than +dette | this +mit | my/mine +også | also +under | under/beneath/below/during, below/underneath +have | have +dig | you +anden | other +hende | her +mine | my +alt | everything +meget | much/very, plenty of +sit | his, her, its, one's +sine | his, her, its, one's +vor | our +mod | against +disse | these +hvis | if +din | your/yours +nogle | some +hos | by/at +blive | be/become +mange | many +ad | by/through +bliver | present tense of "to be/to become" +hendes | her/hers +været | be +thi | for (conj) +jer | you +sådan | such, like this/like that diff --git a/resources/cache/empty/entity/conf/lang/stopwords_de.txt b/resources/cache/empty/entity/conf/lang/stopwords_de.txt index bb9933ee..86525e7a 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_de.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_de.txt @@ -1,294 +1,294 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/german/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A German stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - | The number of forms in this list is reduced significantly by passing it - | through the German stemmer. - - -aber | but - -alle | all -allem -allen -aller -alles - -als | than, as -also | so -am | an + dem -an | at - -ander | other -andere -anderem -anderen -anderer -anderes -anderm -andern -anderr -anders - -auch | also -auf | on -aus | out of -bei | by -bin | am -bis | until -bist | art -da | there -damit | with it -dann | then - -der | the -den -des -dem -die -das - -daß | that - -derselbe | the same -derselben -denselben -desselben -demselben -dieselbe -dieselben -dasselbe - -dazu | to that - -dein | thy -deine -deinem -deinen -deiner -deines - -denn | because - -derer | of those -dessen | of him - -dich | thee -dir | to thee -du | thou - -dies | this -diese -diesem -diesen -dieser -dieses - - -doch | (several meanings) -dort | (over) there - - -durch | through - -ein | a -eine -einem -einen -einer -eines - -einig | some -einige -einigem -einigen -einiger -einiges - -einmal | once - -er | he -ihn | him -ihm | to him - -es | it -etwas | something - -euer | your -eure -eurem -euren -eurer -eures - -für | for -gegen | towards -gewesen | p.p. of sein -hab | have -habe | have -haben | have -hat | has -hatte | had -hatten | had -hier | here -hin | there -hinter | behind - -ich | I -mich | me -mir | to me - - -ihr | you, to her -ihre -ihrem -ihren -ihrer -ihres -euch | to you - -im | in + dem -in | in -indem | while -ins | in + das -ist | is - -jede | each, every -jedem -jeden -jeder -jedes - -jene | that -jenem -jenen -jener -jenes - -jetzt | now -kann | can - -kein | no -keine -keinem -keinen -keiner -keines - -können | can -könnte | could -machen | do -man | one - -manche | some, many a -manchem -manchen -mancher -manches - -mein | my -meine -meinem -meinen -meiner -meines - -mit | with -muss | must -musste | had to -nach | to(wards) -nicht | not -nichts | nothing -noch | still, yet -nun | now -nur | only -ob | whether -oder | or -ohne | without -sehr | very - -sein | his -seine -seinem -seinen -seiner -seines - -selbst | self -sich | herself - -sie | they, she -ihnen | to them - -sind | are -so | so - -solche | such -solchem -solchen -solcher -solches - -soll | shall -sollte | should -sondern | but -sonst | else -über | over -um | about, around -und | and - -uns | us -unse -unsem -unsen -unser -unses - -unter | under -viel | much -vom | von + dem -von | from -vor | before -während | while -war | was -waren | were -warst | wast -was | what -weg | away, off -weil | because -weiter | further - -welche | which -welchem -welchen -welcher -welches - -wenn | when -werde | will -werden | will -wie | how -wieder | again -will | want -wir | we -wird | will -wirst | willst -wo | where -wollen | want -wollte | wanted -würde | would -würden | would -zu | to -zum | zu + dem -zur | zu + der -zwar | indeed -zwischen | between - + | From svn.tartarus.org/snowball/trunk/website/algorithms/german/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A German stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + | The number of forms in this list is reduced significantly by passing it + | through the German stemmer. + + +aber | but + +alle | all +allem +allen +aller +alles + +als | than, as +also | so +am | an + dem +an | at + +ander | other +andere +anderem +anderen +anderer +anderes +anderm +andern +anderr +anders + +auch | also +auf | on +aus | out of +bei | by +bin | am +bis | until +bist | art +da | there +damit | with it +dann | then + +der | the +den +des +dem +die +das + +daß | that + +derselbe | the same +derselben +denselben +desselben +demselben +dieselbe +dieselben +dasselbe + +dazu | to that + +dein | thy +deine +deinem +deinen +deiner +deines + +denn | because + +derer | of those +dessen | of him + +dich | thee +dir | to thee +du | thou + +dies | this +diese +diesem +diesen +dieser +dieses + + +doch | (several meanings) +dort | (over) there + + +durch | through + +ein | a +eine +einem +einen +einer +eines + +einig | some +einige +einigem +einigen +einiger +einiges + +einmal | once + +er | he +ihn | him +ihm | to him + +es | it +etwas | something + +euer | your +eure +eurem +euren +eurer +eures + +für | for +gegen | towards +gewesen | p.p. of sein +hab | have +habe | have +haben | have +hat | has +hatte | had +hatten | had +hier | here +hin | there +hinter | behind + +ich | I +mich | me +mir | to me + + +ihr | you, to her +ihre +ihrem +ihren +ihrer +ihres +euch | to you + +im | in + dem +in | in +indem | while +ins | in + das +ist | is + +jede | each, every +jedem +jeden +jeder +jedes + +jene | that +jenem +jenen +jener +jenes + +jetzt | now +kann | can + +kein | no +keine +keinem +keinen +keiner +keines + +können | can +könnte | could +machen | do +man | one + +manche | some, many a +manchem +manchen +mancher +manches + +mein | my +meine +meinem +meinen +meiner +meines + +mit | with +muss | must +musste | had to +nach | to(wards) +nicht | not +nichts | nothing +noch | still, yet +nun | now +nur | only +ob | whether +oder | or +ohne | without +sehr | very + +sein | his +seine +seinem +seinen +seiner +seines + +selbst | self +sich | herself + +sie | they, she +ihnen | to them + +sind | are +so | so + +solche | such +solchem +solchen +solcher +solches + +soll | shall +sollte | should +sondern | but +sonst | else +über | over +um | about, around +und | and + +uns | us +unse +unsem +unsen +unser +unses + +unter | under +viel | much +vom | von + dem +von | from +vor | before +während | while +war | was +waren | were +warst | wast +was | what +weg | away, off +weil | because +weiter | further + +welche | which +welchem +welchen +welcher +welches + +wenn | when +werde | will +werden | will +wie | how +wieder | again +will | want +wir | we +wird | will +wirst | willst +wo | where +wollen | want +wollte | wanted +würde | would +würden | would +zu | to +zum | zu + dem +zur | zu + der +zwar | indeed +zwischen | between + diff --git a/resources/cache/empty/entity/conf/lang/stopwords_el.txt b/resources/cache/empty/entity/conf/lang/stopwords_el.txt index a5abfbec..232681f5 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_el.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_el.txt @@ -1,78 +1,78 @@ -# Lucene Greek Stopwords list -# Note: by default this file is used after GreekLowerCaseFilter, -# so when modifying this file use 'σ' instead of 'ς' -ο -η -το -οι -τα -του -τησ -των -τον -την -και -κι -κ -ειμαι -εισαι -ειναι -ειμαστε -ειστε -στο -στον -στη -στην -μα -αλλα -απο -για -προσ -με -σε -ωσ -παρα -αντι -κατα -μετα -θα -να -δε -δεν -μη -μην -επι -ενω -εαν -αν -τοτε -που -πωσ -ποιοσ -ποια -ποιο -ποιοι -ποιεσ -ποιων -ποιουσ -αυτοσ -αυτη -αυτο -αυτοι -αυτων -αυτουσ -αυτεσ -αυτα -εκεινοσ -εκεινη -εκεινο -εκεινοι -εκεινεσ -εκεινα -εκεινων -εκεινουσ -οπωσ -ομωσ -ισωσ -οσο -οτι +# Lucene Greek Stopwords list +# Note: by default this file is used after GreekLowerCaseFilter, +# so when modifying this file use 'σ' instead of 'ς' +ο +η +το +οι +τα +του +τησ +των +τον +την +και +κι +κ +ειμαι +εισαι +ειναι +ειμαστε +ειστε +στο +στον +στη +στην +μα +αλλα +απο +για +προσ +με +σε +ωσ +παρα +αντι +κατα +μετα +θα +να +δε +δεν +μη +μην +επι +ενω +εαν +αν +τοτε +που +πωσ +ποιοσ +ποια +ποιο +ποιοι +ποιεσ +ποιων +ποιουσ +αυτοσ +αυτη +αυτο +αυτοι +αυτων +αυτουσ +αυτεσ +αυτα +εκεινοσ +εκεινη +εκεινο +εκεινοι +εκεινεσ +εκεινα +εκεινων +εκεινουσ +οπωσ +ομωσ +ισωσ +οσο +οτι diff --git a/resources/cache/empty/entity/conf/lang/stopwords_en.txt b/resources/cache/empty/entity/conf/lang/stopwords_en.txt index 224230c5..2c164c0b 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_en.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_en.txt @@ -1,54 +1,54 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# a couple of test stopwords to test that the words are really being -# configured from this file: -stopworda -stopwordb - -# Standard english stop words taken from Lucene's StopAnalyzer -a -an -and -are -as -at -be -but -by -for -if -in -into -is -it -no -not -of -on -or -such -that -the -their -then -there -these -they -this -to -was -will -with +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# a couple of test stopwords to test that the words are really being +# configured from this file: +stopworda +stopwordb + +# Standard english stop words taken from Lucene's StopAnalyzer +a +an +and +are +as +at +be +but +by +for +if +in +into +is +it +no +not +of +on +or +such +that +the +their +then +there +these +they +this +to +was +will +with diff --git a/resources/cache/empty/entity/conf/lang/stopwords_es.txt b/resources/cache/empty/entity/conf/lang/stopwords_es.txt index 99afd937..487d78c8 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_es.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_es.txt @@ -1,356 +1,356 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/spanish/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Spanish stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - - | The following is a ranked list (commonest to rarest) of stopwords - | deriving from a large sample of text. - - | Extra words have been added at the end. - -de | from, of -la | the, her -que | who, that -el | the -en | in -y | and -a | to -los | the, them -del | de + el -se | himself, from him etc -las | the, them -por | for, by, etc -un | a -para | for -con | with -no | no -una | a -su | his, her -al | a + el - | es from SER -lo | him -como | how -más | more -pero | pero -sus | su plural -le | to him, her -ya | already -o | or - | fue from SER -este | this - | ha from HABER -sí | himself etc -porque | because -esta | this - | son from SER -entre | between - | está from ESTAR -cuando | when -muy | very -sin | without -sobre | on - | ser from SER - | tiene from TENER -también | also -me | me -hasta | until -hay | there is/are -donde | where - | han from HABER -quien | whom, that - | están from ESTAR - | estado from ESTAR -desde | from -todo | all -nos | us -durante | during - | estados from ESTAR -todos | all -uno | a -les | to them -ni | nor -contra | against -otros | other - | fueron from SER -ese | that -eso | that - | había from HABER -ante | before -ellos | they -e | and (variant of y) -esto | this -mí | me -antes | before -algunos | some -qué | what? -unos | a -yo | I -otro | other -otras | other -otra | other -él | he -tanto | so much, many -esa | that -estos | these -mucho | much, many -quienes | who -nada | nothing -muchos | many -cual | who - | sea from SER -poco | few -ella | she -estar | to be - | haber from HABER -estas | these - | estaba from ESTAR - | estamos from ESTAR -algunas | some -algo | something -nosotros | we - - | other forms - -mi | me -mis | mi plural -tú | thou -te | thee -ti | thee -tu | thy -tus | tu plural -ellas | they -nosotras | we -vosotros | you -vosotras | you -os | you -mío | mine -mía | -míos | -mías | -tuyo | thine -tuya | -tuyos | -tuyas | -suyo | his, hers, theirs -suya | -suyos | -suyas | -nuestro | ours -nuestra | -nuestros | -nuestras | -vuestro | yours -vuestra | -vuestros | -vuestras | -esos | those -esas | those - - | forms of estar, to be (not including the infinitive): -estoy -estás -está -estamos -estáis -están -esté -estés -estemos -estéis -estén -estaré -estarás -estará -estaremos -estaréis -estarán -estaría -estarías -estaríamos -estaríais -estarían -estaba -estabas -estábamos -estabais -estaban -estuve -estuviste -estuvo -estuvimos -estuvisteis -estuvieron -estuviera -estuvieras -estuviéramos -estuvierais -estuvieran -estuviese -estuvieses -estuviésemos -estuvieseis -estuviesen -estando -estado -estada -estados -estadas -estad - - | forms of haber, to have (not including the infinitive): -he -has -ha -hemos -habéis -han -haya -hayas -hayamos -hayáis -hayan -habré -habrás -habrá -habremos -habréis -habrán -habría -habrías -habríamos -habríais -habrían -había -habías -habíamos -habíais -habían -hube -hubiste -hubo -hubimos -hubisteis -hubieron -hubiera -hubieras -hubiéramos -hubierais -hubieran -hubiese -hubieses -hubiésemos -hubieseis -hubiesen -habiendo -habido -habida -habidos -habidas - - | forms of ser, to be (not including the infinitive): -soy -eres -es -somos -sois -son -sea -seas -seamos -seáis -sean -seré -serás -será -seremos -seréis -serán -sería -serías -seríamos -seríais -serían -era -eras -éramos -erais -eran -fui -fuiste -fue -fuimos -fuisteis -fueron -fuera -fueras -fuéramos -fuerais -fueran -fuese -fueses -fuésemos -fueseis -fuesen -siendo -sido - | sed also means 'thirst' - - | forms of tener, to have (not including the infinitive): -tengo -tienes -tiene -tenemos -tenéis -tienen -tenga -tengas -tengamos -tengáis -tengan -tendré -tendrás -tendrá -tendremos -tendréis -tendrán -tendría -tendrías -tendríamos -tendríais -tendrían -tenía -tenías -teníamos -teníais -tenían -tuve -tuviste -tuvo -tuvimos -tuvisteis -tuvieron -tuviera -tuvieras -tuviéramos -tuvierais -tuvieran -tuviese -tuvieses -tuviésemos -tuvieseis -tuviesen -teniendo -tenido -tenida -tenidos -tenidas -tened - + | From svn.tartarus.org/snowball/trunk/website/algorithms/spanish/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Spanish stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + + | The following is a ranked list (commonest to rarest) of stopwords + | deriving from a large sample of text. + + | Extra words have been added at the end. + +de | from, of +la | the, her +que | who, that +el | the +en | in +y | and +a | to +los | the, them +del | de + el +se | himself, from him etc +las | the, them +por | for, by, etc +un | a +para | for +con | with +no | no +una | a +su | his, her +al | a + el + | es from SER +lo | him +como | how +más | more +pero | pero +sus | su plural +le | to him, her +ya | already +o | or + | fue from SER +este | this + | ha from HABER +sí | himself etc +porque | because +esta | this + | son from SER +entre | between + | está from ESTAR +cuando | when +muy | very +sin | without +sobre | on + | ser from SER + | tiene from TENER +también | also +me | me +hasta | until +hay | there is/are +donde | where + | han from HABER +quien | whom, that + | están from ESTAR + | estado from ESTAR +desde | from +todo | all +nos | us +durante | during + | estados from ESTAR +todos | all +uno | a +les | to them +ni | nor +contra | against +otros | other + | fueron from SER +ese | that +eso | that + | había from HABER +ante | before +ellos | they +e | and (variant of y) +esto | this +mí | me +antes | before +algunos | some +qué | what? +unos | a +yo | I +otro | other +otras | other +otra | other +él | he +tanto | so much, many +esa | that +estos | these +mucho | much, many +quienes | who +nada | nothing +muchos | many +cual | who + | sea from SER +poco | few +ella | she +estar | to be + | haber from HABER +estas | these + | estaba from ESTAR + | estamos from ESTAR +algunas | some +algo | something +nosotros | we + + | other forms + +mi | me +mis | mi plural +tú | thou +te | thee +ti | thee +tu | thy +tus | tu plural +ellas | they +nosotras | we +vosotros | you +vosotras | you +os | you +mío | mine +mía | +míos | +mías | +tuyo | thine +tuya | +tuyos | +tuyas | +suyo | his, hers, theirs +suya | +suyos | +suyas | +nuestro | ours +nuestra | +nuestros | +nuestras | +vuestro | yours +vuestra | +vuestros | +vuestras | +esos | those +esas | those + + | forms of estar, to be (not including the infinitive): +estoy +estás +está +estamos +estáis +están +esté +estés +estemos +estéis +estén +estaré +estarás +estará +estaremos +estaréis +estarán +estaría +estarías +estaríamos +estaríais +estarían +estaba +estabas +estábamos +estabais +estaban +estuve +estuviste +estuvo +estuvimos +estuvisteis +estuvieron +estuviera +estuvieras +estuviéramos +estuvierais +estuvieran +estuviese +estuvieses +estuviésemos +estuvieseis +estuviesen +estando +estado +estada +estados +estadas +estad + + | forms of haber, to have (not including the infinitive): +he +has +ha +hemos +habéis +han +haya +hayas +hayamos +hayáis +hayan +habré +habrás +habrá +habremos +habréis +habrán +habría +habrías +habríamos +habríais +habrían +había +habías +habíamos +habíais +habían +hube +hubiste +hubo +hubimos +hubisteis +hubieron +hubiera +hubieras +hubiéramos +hubierais +hubieran +hubiese +hubieses +hubiésemos +hubieseis +hubiesen +habiendo +habido +habida +habidos +habidas + + | forms of ser, to be (not including the infinitive): +soy +eres +es +somos +sois +son +sea +seas +seamos +seáis +sean +seré +serás +será +seremos +seréis +serán +sería +serías +seríamos +seríais +serían +era +eras +éramos +erais +eran +fui +fuiste +fue +fuimos +fuisteis +fueron +fuera +fueras +fuéramos +fuerais +fueran +fuese +fueses +fuésemos +fueseis +fuesen +siendo +sido + | sed also means 'thirst' + + | forms of tener, to have (not including the infinitive): +tengo +tienes +tiene +tenemos +tenéis +tienen +tenga +tengas +tengamos +tengáis +tengan +tendré +tendrás +tendrá +tendremos +tendréis +tendrán +tendría +tendrías +tendríamos +tendríais +tendrían +tenía +tenías +teníamos +teníais +tenían +tuve +tuviste +tuvo +tuvimos +tuvisteis +tuvieron +tuviera +tuvieras +tuviéramos +tuvierais +tuvieran +tuviese +tuvieses +tuviésemos +tuvieseis +tuviesen +teniendo +tenido +tenida +tenidos +tenidas +tened + diff --git a/resources/cache/empty/entity/conf/lang/stopwords_eu.txt b/resources/cache/empty/entity/conf/lang/stopwords_eu.txt index 7e4e4bb3..25f1db93 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_eu.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_eu.txt @@ -1,99 +1,99 @@ -# example set of basque stopwords -al -anitz -arabera -asko -baina -bat -batean -batek -bati -batzuei -batzuek -batzuetan -batzuk -bera -beraiek -berau -berauek -bere -berori -beroriek -beste -bezala -da -dago -dira -ditu -du -dute -edo -egin -ere -eta -eurak -ez -gainera -gu -gutxi -guzti -haiei -haiek -haietan -hainbeste -hala -han -handik -hango -hara -hari -hark -hartan -hau -hauei -hauek -hauetan -hemen -hemendik -hemengo -hi -hona -honek -honela -honetan -honi -hor -hori -horiei -horiek -horietan -horko -horra -horrek -horrela -horretan -horri -hortik -hura -izan -ni -noiz -nola -non -nondik -nongo -nor -nora -ze -zein -zen -zenbait -zenbat -zer -zergatik -ziren -zituen -zu -zuek -zuen -zuten +# example set of basque stopwords +al +anitz +arabera +asko +baina +bat +batean +batek +bati +batzuei +batzuek +batzuetan +batzuk +bera +beraiek +berau +berauek +bere +berori +beroriek +beste +bezala +da +dago +dira +ditu +du +dute +edo +egin +ere +eta +eurak +ez +gainera +gu +gutxi +guzti +haiei +haiek +haietan +hainbeste +hala +han +handik +hango +hara +hari +hark +hartan +hau +hauei +hauek +hauetan +hemen +hemendik +hemengo +hi +hona +honek +honela +honetan +honi +hor +hori +horiei +horiek +horietan +horko +horra +horrek +horrela +horretan +horri +hortik +hura +izan +ni +noiz +nola +non +nondik +nongo +nor +nora +ze +zein +zen +zenbait +zenbat +zer +zergatik +ziren +zituen +zu +zuek +zuen +zuten diff --git a/resources/cache/empty/entity/conf/lang/stopwords_fa.txt b/resources/cache/empty/entity/conf/lang/stopwords_fa.txt index 76bb6354..723641c6 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_fa.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_fa.txt @@ -1,313 +1,313 @@ -# This file was created by Jacques Savoy and is distributed under the BSD license. -# See http://members.unine.ch/jacques.savoy/clef/index.html. -# Also see http://www.opensource.org/licenses/bsd-license.html -# Note: by default this file is used after normalization, so when adding entries -# to this file, use the arabic 'ي' instead of 'ی' -انان -نداشته -سراسر -خياه -ايشان -وي -تاكنون -بيشتري -دوم -پس -ناشي -وگو -يا -داشتند -سپس -هنگام -هرگز -پنج -نشان -امسال -ديگر -گروهي -شدند -چطور -ده -و -دو -نخستين -ولي -چرا -چه -وسط -ه -كدام -قابل -يك -رفت -هفت -همچنين -در -هزار -بله -بلي -شايد -اما -شناسي -گرفته -دهد -داشته -دانست -داشتن -خواهيم -ميليارد -وقتيكه -امد -خواهد -جز -اورده -شده -بلكه -خدمات -شدن -برخي -نبود -بسياري -جلوگيري -حق -كردند -نوعي -بعري -نكرده -نظير -نبايد -بوده -بودن -داد -اورد -هست -جايي -شود -دنبال -داده -بايد -سابق -هيچ -همان -انجا -كمتر -كجاست -گردد -كسي -تر -مردم -تان -دادن -بودند -سري -جدا -ندارند -مگر -يكديگر -دارد -دهند -بنابراين -هنگامي -سمت -جا -انچه -خود -دادند -زياد -دارند -اثر -بدون -بهترين -بيشتر -البته -به -براساس -بيرون -كرد -بعضي -گرفت -توي -اي -ميليون -او -جريان -تول -بر -مانند -برابر -باشيم -مدتي -گويند -اكنون -تا -تنها -جديد -چند -بي -نشده -كردن -كردم -گويد -كرده -كنيم -نمي -نزد -روي -قصد -فقط -بالاي -ديگران -اين -ديروز -توسط -سوم -ايم -دانند -سوي -استفاده -شما -كنار -داريم -ساخته -طور -امده -رفته -نخست -بيست -نزديك -طي -كنيد -از -انها -تمامي -داشت -يكي -طريق -اش -چيست -روب -نمايد -گفت -چندين -چيزي -تواند -ام -ايا -با -ان -ايد -ترين -اينكه -ديگري -راه -هايي -بروز -همچنان -پاعين -كس -حدود -مختلف -مقابل -چيز -گيرد -ندارد -ضد -همچون -سازي -شان -مورد -باره -مرسي -خويش -برخوردار -چون -خارج -شش -هنوز -تحت -ضمن -هستيم -گفته -فكر -بسيار -پيش -براي -روزهاي -انكه -نخواهد -بالا -كل -وقتي -كي -چنين -كه -گيري -نيست -است -كجا -كند -نيز -يابد -بندي -حتي -توانند -عقب -خواست -كنند -بين -تمام -همه -ما -باشند -مثل -شد -اري -باشد -اره -طبق -بعد -اگر -صورت -غير -جاي -بيش -ريزي -اند -زيرا -چگونه -بار -لطفا -مي -درباره -من -ديده -همين -گذاري -برداري -علت -گذاشته -هم -فوق -نه -ها -شوند -اباد -همواره -هر -اول -خواهند -چهار -نام -امروز -مان -هاي -قبل -كنم -سعي -تازه -را -هستند -زير -جلوي -عنوان -بود +# This file was created by Jacques Savoy and is distributed under the BSD license. +# See http://members.unine.ch/jacques.savoy/clef/index.html. +# Also see http://www.opensource.org/licenses/bsd-license.html +# Note: by default this file is used after normalization, so when adding entries +# to this file, use the arabic 'ي' instead of 'ی' +انان +نداشته +سراسر +خياه +ايشان +وي +تاكنون +بيشتري +دوم +پس +ناشي +وگو +يا +داشتند +سپس +هنگام +هرگز +پنج +نشان +امسال +ديگر +گروهي +شدند +چطور +ده +و +دو +نخستين +ولي +چرا +چه +وسط +ه +كدام +قابل +يك +رفت +هفت +همچنين +در +هزار +بله +بلي +شايد +اما +شناسي +گرفته +دهد +داشته +دانست +داشتن +خواهيم +ميليارد +وقتيكه +امد +خواهد +جز +اورده +شده +بلكه +خدمات +شدن +برخي +نبود +بسياري +جلوگيري +حق +كردند +نوعي +بعري +نكرده +نظير +نبايد +بوده +بودن +داد +اورد +هست +جايي +شود +دنبال +داده +بايد +سابق +هيچ +همان +انجا +كمتر +كجاست +گردد +كسي +تر +مردم +تان +دادن +بودند +سري +جدا +ندارند +مگر +يكديگر +دارد +دهند +بنابراين +هنگامي +سمت +جا +انچه +خود +دادند +زياد +دارند +اثر +بدون +بهترين +بيشتر +البته +به +براساس +بيرون +كرد +بعضي +گرفت +توي +اي +ميليون +او +جريان +تول +بر +مانند +برابر +باشيم +مدتي +گويند +اكنون +تا +تنها +جديد +چند +بي +نشده +كردن +كردم +گويد +كرده +كنيم +نمي +نزد +روي +قصد +فقط +بالاي +ديگران +اين +ديروز +توسط +سوم +ايم +دانند +سوي +استفاده +شما +كنار +داريم +ساخته +طور +امده +رفته +نخست +بيست +نزديك +طي +كنيد +از +انها +تمامي +داشت +يكي +طريق +اش +چيست +روب +نمايد +گفت +چندين +چيزي +تواند +ام +ايا +با +ان +ايد +ترين +اينكه +ديگري +راه +هايي +بروز +همچنان +پاعين +كس +حدود +مختلف +مقابل +چيز +گيرد +ندارد +ضد +همچون +سازي +شان +مورد +باره +مرسي +خويش +برخوردار +چون +خارج +شش +هنوز +تحت +ضمن +هستيم +گفته +فكر +بسيار +پيش +براي +روزهاي +انكه +نخواهد +بالا +كل +وقتي +كي +چنين +كه +گيري +نيست +است +كجا +كند +نيز +يابد +بندي +حتي +توانند +عقب +خواست +كنند +بين +تمام +همه +ما +باشند +مثل +شد +اري +باشد +اره +طبق +بعد +اگر +صورت +غير +جاي +بيش +ريزي +اند +زيرا +چگونه +بار +لطفا +مي +درباره +من +ديده +همين +گذاري +برداري +علت +گذاشته +هم +فوق +نه +ها +شوند +اباد +همواره +هر +اول +خواهند +چهار +نام +امروز +مان +هاي +قبل +كنم +سعي +تازه +را +هستند +زير +جلوي +عنوان +بود diff --git a/resources/cache/empty/entity/conf/lang/stopwords_fi.txt b/resources/cache/empty/entity/conf/lang/stopwords_fi.txt index 4d70da3b..4372c9a0 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_fi.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_fi.txt @@ -1,97 +1,97 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/finnish/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - -| forms of BE - -olla -olen -olet -on -olemme -olette -ovat -ole | negative form - -oli -olisi -olisit -olisin -olisimme -olisitte -olisivat -olit -olin -olimme -olitte -olivat -ollut -olleet - -en | negation -et -ei -emme -ette -eivät - -|Nom Gen Acc Part Iness Elat Illat Adess Ablat Allat Ess Trans -minä minun minut minua minussa minusta minuun minulla minulta minulle | I -sinä sinun sinut sinua sinussa sinusta sinuun sinulla sinulta sinulle | you -hän hänen hänet häntä hänessä hänestä häneen hänellä häneltä hänelle | he she -me meidän meidät meitä meissä meistä meihin meillä meiltä meille | we -te teidän teidät teitä teissä teistä teihin teillä teiltä teille | you -he heidän heidät heitä heissä heistä heihin heillä heiltä heille | they - -tämä tämän tätä tässä tästä tähän tallä tältä tälle tänä täksi | this -tuo tuon tuotä tuossa tuosta tuohon tuolla tuolta tuolle tuona tuoksi | that -se sen sitä siinä siitä siihen sillä siltä sille sinä siksi | it -nämä näiden näitä näissä näistä näihin näillä näiltä näille näinä näiksi | these -nuo noiden noita noissa noista noihin noilla noilta noille noina noiksi | those -ne niiden niitä niissä niistä niihin niillä niiltä niille niinä niiksi | they - -kuka kenen kenet ketä kenessä kenestä keneen kenellä keneltä kenelle kenenä keneksi| who -ketkä keiden ketkä keitä keissä keistä keihin keillä keiltä keille keinä keiksi | (pl) -mikä minkä minkä mitä missä mistä mihin millä miltä mille minä miksi | which what -mitkä | (pl) - -joka jonka jota jossa josta johon jolla jolta jolle jona joksi | who which -jotka joiden joita joissa joista joihin joilla joilta joille joina joiksi | (pl) - -| conjunctions - -että | that -ja | and -jos | if -koska | because -kuin | than -mutta | but -niin | so -sekä | and -sillä | for -tai | or -vaan | but -vai | or -vaikka | although - - -| prepositions - -kanssa | with -mukaan | according to -noin | about -poikki | across -yli | over, across - -| other - -kun | when -niin | so -nyt | now -itse | self - + | From svn.tartarus.org/snowball/trunk/website/algorithms/finnish/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + +| forms of BE + +olla +olen +olet +on +olemme +olette +ovat +ole | negative form + +oli +olisi +olisit +olisin +olisimme +olisitte +olisivat +olit +olin +olimme +olitte +olivat +ollut +olleet + +en | negation +et +ei +emme +ette +eivät + +|Nom Gen Acc Part Iness Elat Illat Adess Ablat Allat Ess Trans +minä minun minut minua minussa minusta minuun minulla minulta minulle | I +sinä sinun sinut sinua sinussa sinusta sinuun sinulla sinulta sinulle | you +hän hänen hänet häntä hänessä hänestä häneen hänellä häneltä hänelle | he she +me meidän meidät meitä meissä meistä meihin meillä meiltä meille | we +te teidän teidät teitä teissä teistä teihin teillä teiltä teille | you +he heidän heidät heitä heissä heistä heihin heillä heiltä heille | they + +tämä tämän tätä tässä tästä tähän tallä tältä tälle tänä täksi | this +tuo tuon tuotä tuossa tuosta tuohon tuolla tuolta tuolle tuona tuoksi | that +se sen sitä siinä siitä siihen sillä siltä sille sinä siksi | it +nämä näiden näitä näissä näistä näihin näillä näiltä näille näinä näiksi | these +nuo noiden noita noissa noista noihin noilla noilta noille noina noiksi | those +ne niiden niitä niissä niistä niihin niillä niiltä niille niinä niiksi | they + +kuka kenen kenet ketä kenessä kenestä keneen kenellä keneltä kenelle kenenä keneksi| who +ketkä keiden ketkä keitä keissä keistä keihin keillä keiltä keille keinä keiksi | (pl) +mikä minkä minkä mitä missä mistä mihin millä miltä mille minä miksi | which what +mitkä | (pl) + +joka jonka jota jossa josta johon jolla jolta jolle jona joksi | who which +jotka joiden joita joissa joista joihin joilla joilta joille joina joiksi | (pl) + +| conjunctions + +että | that +ja | and +jos | if +koska | because +kuin | than +mutta | but +niin | so +sekä | and +sillä | for +tai | or +vaan | but +vai | or +vaikka | although + + +| prepositions + +kanssa | with +mukaan | according to +noin | about +poikki | across +yli | over, across + +| other + +kun | when +niin | so +nyt | now +itse | self + diff --git a/resources/cache/empty/entity/conf/lang/stopwords_fr.txt b/resources/cache/empty/entity/conf/lang/stopwords_fr.txt index fec33952..749abae6 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_fr.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_fr.txt @@ -1,186 +1,186 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/french/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A French stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - -au | a + le -aux | a + les -avec | with -ce | this -ces | these -dans | with -de | of -des | de + les -du | de + le -elle | she -en | `of them' etc -et | and -eux | them -il | he -je | I -la | the -le | the -leur | their -lui | him -ma | my (fem) -mais | but -me | me -même | same; as in moi-même (myself) etc -mes | me (pl) -moi | me -mon | my (masc) -ne | not -nos | our (pl) -notre | our -nous | we -on | one -ou | where -par | by -pas | not -pour | for -qu | que before vowel -que | that -qui | who -sa | his, her (fem) -se | oneself -ses | his (pl) -son | his, her (masc) -sur | on -ta | thy (fem) -te | thee -tes | thy (pl) -toi | thee -ton | thy (masc) -tu | thou -un | a -une | a -vos | your (pl) -votre | your -vous | you - - | single letter forms - -c | c' -d | d' -j | j' -l | l' -à | to, at -m | m' -n | n' -s | s' -t | t' -y | there - - | forms of être (not including the infinitive): -été -étée -étées -étés -étant -suis -es -est -sommes -êtes -sont -serai -seras -sera -serons -serez -seront -serais -serait -serions -seriez -seraient -étais -était -étions -étiez -étaient -fus -fut -fûmes -fûtes -furent -sois -soit -soyons -soyez -soient -fusse -fusses -fût -fussions -fussiez -fussent - - | forms of avoir (not including the infinitive): -ayant -eu -eue -eues -eus -ai -as -avons -avez -ont -aurai -auras -aura -aurons -aurez -auront -aurais -aurait -aurions -auriez -auraient -avais -avait -avions -aviez -avaient -eut -eûmes -eûtes -eurent -aie -aies -ait -ayons -ayez -aient -eusse -eusses -eût -eussions -eussiez -eussent - - | Later additions (from Jean-Christophe Deschamps) -ceci | this -cela | that -celà | that -cet | this -cette | this -ici | here -ils | they -les | the (pl) -leurs | their (pl) -quel | which -quels | which -quelle | which -quelles | which -sans | without -soi | oneself - + | From svn.tartarus.org/snowball/trunk/website/algorithms/french/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A French stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + +au | a + le +aux | a + les +avec | with +ce | this +ces | these +dans | with +de | of +des | de + les +du | de + le +elle | she +en | `of them' etc +et | and +eux | them +il | he +je | I +la | the +le | the +leur | their +lui | him +ma | my (fem) +mais | but +me | me +même | same; as in moi-même (myself) etc +mes | me (pl) +moi | me +mon | my (masc) +ne | not +nos | our (pl) +notre | our +nous | we +on | one +ou | where +par | by +pas | not +pour | for +qu | que before vowel +que | that +qui | who +sa | his, her (fem) +se | oneself +ses | his (pl) +son | his, her (masc) +sur | on +ta | thy (fem) +te | thee +tes | thy (pl) +toi | thee +ton | thy (masc) +tu | thou +un | a +une | a +vos | your (pl) +votre | your +vous | you + + | single letter forms + +c | c' +d | d' +j | j' +l | l' +à | to, at +m | m' +n | n' +s | s' +t | t' +y | there + + | forms of être (not including the infinitive): +été +étée +étées +étés +étant +suis +es +est +sommes +êtes +sont +serai +seras +sera +serons +serez +seront +serais +serait +serions +seriez +seraient +étais +était +étions +étiez +étaient +fus +fut +fûmes +fûtes +furent +sois +soit +soyons +soyez +soient +fusse +fusses +fût +fussions +fussiez +fussent + + | forms of avoir (not including the infinitive): +ayant +eu +eue +eues +eus +ai +as +avons +avez +ont +aurai +auras +aura +aurons +aurez +auront +aurais +aurait +aurions +auriez +auraient +avais +avait +avions +aviez +avaient +eut +eûmes +eûtes +eurent +aie +aies +ait +ayons +ayez +aient +eusse +eusses +eût +eussions +eussiez +eussent + + | Later additions (from Jean-Christophe Deschamps) +ceci | this +cela | that +celà | that +cet | this +cette | this +ici | here +ils | they +les | the (pl) +leurs | their (pl) +quel | which +quels | which +quelle | which +quelles | which +sans | without +soi | oneself + diff --git a/resources/cache/empty/entity/conf/lang/stopwords_ga.txt b/resources/cache/empty/entity/conf/lang/stopwords_ga.txt index f03e10a9..9ff88d74 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_ga.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_ga.txt @@ -1,110 +1,110 @@ - -a -ach -ag -agus -an -aon -ar -arna -as -b' -ba -beirt -bhúr -caoga -ceathair -ceathrar -chomh -chtó -chuig -chun -cois -céad -cúig -cúigear -d' -daichead -dar -de -deich -deichniúr -den -dhá -do -don -dtí -dá -dár -dó -faoi -faoin -faoina -faoinár -fara -fiche -gach -gan -go -gur -haon -hocht -i -iad -idir -in -ina -ins -inár -is -le -leis -lena -lenár -m' -mar -mo -mé -na -nach -naoi -naonúr -ná -ní -níor -nó -nócha -ocht -ochtar -os -roimh -sa -seacht -seachtar -seachtó -seasca -seisear -siad -sibh -sinn -sna -sé -sí -tar -thar -thú -triúr -trí -trína -trínár -tríocha -tú -um -ár -é -éis -í -ó -ón -óna -ónár + +a +ach +ag +agus +an +aon +ar +arna +as +b' +ba +beirt +bhúr +caoga +ceathair +ceathrar +chomh +chtó +chuig +chun +cois +céad +cúig +cúigear +d' +daichead +dar +de +deich +deichniúr +den +dhá +do +don +dtí +dá +dár +dó +faoi +faoin +faoina +faoinár +fara +fiche +gach +gan +go +gur +haon +hocht +i +iad +idir +in +ina +ins +inár +is +le +leis +lena +lenár +m' +mar +mo +mé +na +nach +naoi +naonúr +ná +ní +níor +nó +nócha +ocht +ochtar +os +roimh +sa +seacht +seachtar +seachtó +seasca +seisear +siad +sibh +sinn +sna +sé +sí +tar +thar +thú +triúr +trí +trína +trínár +tríocha +tú +um +ár +é +éis +í +ó +ón +óna +ónár diff --git a/resources/cache/empty/entity/conf/lang/stopwords_gl.txt b/resources/cache/empty/entity/conf/lang/stopwords_gl.txt index 57803b31..d8760b12 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_gl.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_gl.txt @@ -1,161 +1,161 @@ -# galican stopwords -a -aínda -alí -aquel -aquela -aquelas -aqueles -aquilo -aquí -ao -aos -as -así -á -ben -cando -che -co -coa -comigo -con -connosco -contigo -convosco -coas -cos -cun -cuns -cunha -cunhas -da -dalgunha -dalgunhas -dalgún -dalgúns -das -de -del -dela -delas -deles -desde -deste -do -dos -dun -duns -dunha -dunhas -e -el -ela -elas -eles -en -era -eran -esa -esas -ese -eses -esta -estar -estaba -está -están -este -estes -estiven -estou -eu -é -facer -foi -foron -fun -había -hai -iso -isto -la -las -lle -lles -lo -los -mais -me -meu -meus -min -miña -miñas -moi -na -nas -neste -nin -no -non -nos -nosa -nosas -noso -nosos -nós -nun -nunha -nuns -nunhas -o -os -ou -ó -ós -para -pero -pode -pois -pola -polas -polo -polos -por -que -se -senón -ser -seu -seus -sexa -sido -sobre -súa -súas -tamén -tan -te -ten -teñen -teño -ter -teu -teus -ti -tido -tiña -tiven -túa -túas -un -unha -unhas -uns -vos -vosa -vosas -voso -vosos -vós +# galican stopwords +a +aínda +alí +aquel +aquela +aquelas +aqueles +aquilo +aquí +ao +aos +as +así +á +ben +cando +che +co +coa +comigo +con +connosco +contigo +convosco +coas +cos +cun +cuns +cunha +cunhas +da +dalgunha +dalgunhas +dalgún +dalgúns +das +de +del +dela +delas +deles +desde +deste +do +dos +dun +duns +dunha +dunhas +e +el +ela +elas +eles +en +era +eran +esa +esas +ese +eses +esta +estar +estaba +está +están +este +estes +estiven +estou +eu +é +facer +foi +foron +fun +había +hai +iso +isto +la +las +lle +lles +lo +los +mais +me +meu +meus +min +miña +miñas +moi +na +nas +neste +nin +no +non +nos +nosa +nosas +noso +nosos +nós +nun +nunha +nuns +nunhas +o +os +ou +ó +ós +para +pero +pode +pois +pola +polas +polo +polos +por +que +se +senón +ser +seu +seus +sexa +sido +sobre +súa +súas +tamén +tan +te +ten +teñen +teño +ter +teu +teus +ti +tido +tiña +tiven +túa +túas +un +unha +unhas +uns +vos +vosa +vosas +voso +vosos +vós diff --git a/resources/cache/empty/entity/conf/lang/stopwords_hi.txt b/resources/cache/empty/entity/conf/lang/stopwords_hi.txt index 1f19fd10..86286bb0 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_hi.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_hi.txt @@ -1,235 +1,235 @@ -# Also see http://www.opensource.org/licenses/bsd-license.html -# See http://members.unine.ch/jacques.savoy/clef/index.html. -# This file was created by Jacques Savoy and is distributed under the BSD license. -# Note: by default this file also contains forms normalized by HindiNormalizer -# for spelling variation (see section below), such that it can be used whether or -# not you enable that feature. When adding additional entries to this list, -# please add the normalized form as well. -अंदर -अत -अपना -अपनी -अपने -अभी -आदि -आप -इत्यादि -इन -इनका -इन्हीं -इन्हें -इन्हों -इस -इसका -इसकी -इसके -इसमें -इसी -इसे -उन -उनका -उनकी -उनके -उनको -उन्हीं -उन्हें -उन्हों -उस -उसके -उसी -उसे -एक -एवं -एस -ऐसे -और -कई -कर -करता -करते -करना -करने -करें -कहते -कहा -का -काफ़ी -कि -कितना -किन्हें -किन्हों -किया -किर -किस -किसी -किसे -की -कुछ -कुल -के -को -कोई -कौन -कौनसा -गया -घर -जब -जहाँ -जा -जितना -जिन -जिन्हें -जिन्हों -जिस -जिसे -जीधर -जैसा -जैसे -जो -तक -तब -तरह -तिन -तिन्हें -तिन्हों -तिस -तिसे -तो -था -थी -थे -दबारा -दिया -दुसरा -दूसरे -दो -द्वारा -न -नहीं -ना -निहायत -नीचे -ने -पर -पर -पहले -पूरा -पे -फिर -बनी -बही -बहुत -बाद -बाला -बिलकुल -भी -भीतर -मगर -मानो -मे -में -यदि -यह -यहाँ -यही -या -यिह -ये -रखें -रहा -रहे -ऱ्वासा -लिए -लिये -लेकिन -व -वर्ग -वह -वह -वहाँ -वहीं -वाले -वुह -वे -वग़ैरह -संग -सकता -सकते -सबसे -सभी -साथ -साबुत -साभ -सारा -से -सो -ही -हुआ -हुई -हुए -है -हैं -हो -होता -होती -होते -होना -होने -# additional normalized forms of the above -अपनि -जेसे -होति -सभि -तिंहों -इंहों -दवारा -इसि -किंहें -थि -उंहों -ओर -जिंहें -वहिं -अभि -बनि -हि -उंहिं -उंहें -हें -वगेरह -एसे -रवासा -कोन -निचे -काफि -उसि -पुरा -भितर -हे -बहि -वहां -कोइ -यहां -जिंहों -तिंहें -किसि -कइ -यहि -इंहिं -जिधर -इंहें -अदि -इतयादि -हुइ -कोनसा -इसकि -दुसरे -जहां -अप -किंहों -उनकि -भि -वरग -हुअ -जेसा -नहिं +# Also see http://www.opensource.org/licenses/bsd-license.html +# See http://members.unine.ch/jacques.savoy/clef/index.html. +# This file was created by Jacques Savoy and is distributed under the BSD license. +# Note: by default this file also contains forms normalized by HindiNormalizer +# for spelling variation (see section below), such that it can be used whether or +# not you enable that feature. When adding additional entries to this list, +# please add the normalized form as well. +अंदर +अत +अपना +अपनी +अपने +अभी +आदि +आप +इत्यादि +इन +इनका +इन्हीं +इन्हें +इन्हों +इस +इसका +इसकी +इसके +इसमें +इसी +इसे +उन +उनका +उनकी +उनके +उनको +उन्हीं +उन्हें +उन्हों +उस +उसके +उसी +उसे +एक +एवं +एस +ऐसे +और +कई +कर +करता +करते +करना +करने +करें +कहते +कहा +का +काफ़ी +कि +कितना +किन्हें +किन्हों +किया +किर +किस +किसी +किसे +की +कुछ +कुल +के +को +कोई +कौन +कौनसा +गया +घर +जब +जहाँ +जा +जितना +जिन +जिन्हें +जिन्हों +जिस +जिसे +जीधर +जैसा +जैसे +जो +तक +तब +तरह +तिन +तिन्हें +तिन्हों +तिस +तिसे +तो +था +थी +थे +दबारा +दिया +दुसरा +दूसरे +दो +द्वारा +न +नहीं +ना +निहायत +नीचे +ने +पर +पर +पहले +पूरा +पे +फिर +बनी +बही +बहुत +बाद +बाला +बिलकुल +भी +भीतर +मगर +मानो +मे +में +यदि +यह +यहाँ +यही +या +यिह +ये +रखें +रहा +रहे +ऱ्वासा +लिए +लिये +लेकिन +व +वर्ग +वह +वह +वहाँ +वहीं +वाले +वुह +वे +वग़ैरह +संग +सकता +सकते +सबसे +सभी +साथ +साबुत +साभ +सारा +से +सो +ही +हुआ +हुई +हुए +है +हैं +हो +होता +होती +होते +होना +होने +# additional normalized forms of the above +अपनि +जेसे +होति +सभि +तिंहों +इंहों +दवारा +इसि +किंहें +थि +उंहों +ओर +जिंहें +वहिं +अभि +बनि +हि +उंहिं +उंहें +हें +वगेरह +एसे +रवासा +कोन +निचे +काफि +उसि +पुरा +भितर +हे +बहि +वहां +कोइ +यहां +जिंहों +तिंहें +किसि +कइ +यहि +इंहिं +जिधर +इंहें +अदि +इतयादि +हुइ +कोनसा +इसकि +दुसरे +जहां +अप +किंहों +उनकि +भि +वरग +हुअ +जेसा +नहिं diff --git a/resources/cache/empty/entity/conf/lang/stopwords_hu.txt b/resources/cache/empty/entity/conf/lang/stopwords_hu.txt index f5bf755b..37526da8 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_hu.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_hu.txt @@ -1,211 +1,211 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/hungarian/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - -| Hungarian stop word list -| prepared by Anna Tordai - -a -ahogy -ahol -aki -akik -akkor -alatt -által -általában -amely -amelyek -amelyekben -amelyeket -amelyet -amelynek -ami -amit -amolyan -amíg -amikor -át -abban -ahhoz -annak -arra -arról -az -azok -azon -azt -azzal -azért -aztán -azután -azonban -bár -be -belül -benne -cikk -cikkek -cikkeket -csak -de -e -eddig -egész -egy -egyes -egyetlen -egyéb -egyik -egyre -ekkor -el -elég -ellen -elő -először -előtt -első -én -éppen -ebben -ehhez -emilyen -ennek -erre -ez -ezt -ezek -ezen -ezzel -ezért -és -fel -felé -hanem -hiszen -hogy -hogyan -igen -így -illetve -ill. -ill -ilyen -ilyenkor -ison -ismét -itt -jó -jól -jobban -kell -kellett -keresztül -keressünk -ki -kívül -között -közül -legalább -lehet -lehetett -legyen -lenne -lenni -lesz -lett -maga -magát -majd -majd -már -más -másik -meg -még -mellett -mert -mely -melyek -mi -mit -míg -miért -milyen -mikor -minden -mindent -mindenki -mindig -mint -mintha -mivel -most -nagy -nagyobb -nagyon -ne -néha -nekem -neki -nem -néhány -nélkül -nincs -olyan -ott -össze -ő -ők -őket -pedig -persze -rá -s -saját -sem -semmi -sok -sokat -sokkal -számára -szemben -szerint -szinte -talán -tehát -teljes -tovább -továbbá -több -úgy -ugyanis -új -újabb -újra -után -utána -utolsó -vagy -vagyis -valaki -valami -valamint -való -vagyok -van -vannak -volt -voltam -voltak -voltunk -vissza -vele -viszont -volna + | From svn.tartarus.org/snowball/trunk/website/algorithms/hungarian/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + +| Hungarian stop word list +| prepared by Anna Tordai + +a +ahogy +ahol +aki +akik +akkor +alatt +által +általában +amely +amelyek +amelyekben +amelyeket +amelyet +amelynek +ami +amit +amolyan +amíg +amikor +át +abban +ahhoz +annak +arra +arról +az +azok +azon +azt +azzal +azért +aztán +azután +azonban +bár +be +belül +benne +cikk +cikkek +cikkeket +csak +de +e +eddig +egész +egy +egyes +egyetlen +egyéb +egyik +egyre +ekkor +el +elég +ellen +elő +először +előtt +első +én +éppen +ebben +ehhez +emilyen +ennek +erre +ez +ezt +ezek +ezen +ezzel +ezért +és +fel +felé +hanem +hiszen +hogy +hogyan +igen +így +illetve +ill. +ill +ilyen +ilyenkor +ison +ismét +itt +jó +jól +jobban +kell +kellett +keresztül +keressünk +ki +kívül +között +közül +legalább +lehet +lehetett +legyen +lenne +lenni +lesz +lett +maga +magát +majd +majd +már +más +másik +meg +még +mellett +mert +mely +melyek +mi +mit +míg +miért +milyen +mikor +minden +mindent +mindenki +mindig +mint +mintha +mivel +most +nagy +nagyobb +nagyon +ne +néha +nekem +neki +nem +néhány +nélkül +nincs +olyan +ott +össze +ő +ők +őket +pedig +persze +rá +s +saját +sem +semmi +sok +sokat +sokkal +számára +szemben +szerint +szinte +talán +tehát +teljes +tovább +továbbá +több +úgy +ugyanis +új +újabb +újra +után +utána +utolsó +vagy +vagyis +valaki +valami +valamint +való +vagyok +van +vannak +volt +voltam +voltak +voltunk +vissza +vele +viszont +volna diff --git a/resources/cache/empty/entity/conf/lang/stopwords_hy.txt b/resources/cache/empty/entity/conf/lang/stopwords_hy.txt index 968a8f4a..60c1c50f 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_hy.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_hy.txt @@ -1,46 +1,46 @@ -# example set of Armenian stopwords. -այդ -այլ -այն -այս -դու -դուք -եմ -են -ենք -ես -եք -է -էի -էին -էինք -էիր -էիք -էր -ըստ -թ -ի -ին -իսկ -իր -կամ -համար -հետ -հետո -մենք -մեջ -մի -ն -նա -նաև -նրա -նրանք -որ -որը -որոնք -որպես -ու -ում -պիտի -վրա -և +# example set of Armenian stopwords. +այդ +այլ +այն +այս +դու +դուք +եմ +են +ենք +ես +եք +է +էի +էին +էինք +էիր +էիք +էր +ըստ +թ +ի +ին +իսկ +իր +կամ +համար +հետ +հետո +մենք +մեջ +մի +ն +նա +նաև +նրա +նրանք +որ +որը +որոնք +որպես +ու +ում +պիտի +վրա +և diff --git a/resources/cache/empty/entity/conf/lang/stopwords_id.txt b/resources/cache/empty/entity/conf/lang/stopwords_id.txt index 80df39a3..4617f83a 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_id.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_id.txt @@ -1,359 +1,359 @@ -# from appendix D of: A Study of Stemming Effects on Information -# Retrieval in Bahasa Indonesia -ada -adanya -adalah -adapun -agak -agaknya -agar -akan -akankah -akhirnya -aku -akulah -amat -amatlah -anda -andalah -antar -diantaranya -antara -antaranya -diantara -apa -apaan -mengapa -apabila -apakah -apalagi -apatah -atau -ataukah -ataupun -bagai -bagaikan -sebagai -sebagainya -bagaimana -bagaimanapun -sebagaimana -bagaimanakah -bagi -bahkan -bahwa -bahwasanya -sebaliknya -banyak -sebanyak -beberapa -seberapa -begini -beginian -beginikah -beginilah -sebegini -begitu -begitukah -begitulah -begitupun -sebegitu -belum -belumlah -sebelum -sebelumnya -sebenarnya -berapa -berapakah -berapalah -berapapun -betulkah -sebetulnya -biasa -biasanya -bila -bilakah -bisa -bisakah -sebisanya -boleh -bolehkah -bolehlah -buat -bukan -bukankah -bukanlah -bukannya -cuma -percuma -dahulu -dalam -dan -dapat -dari -daripada -dekat -demi -demikian -demikianlah -sedemikian -dengan -depan -di -dia -dialah -dini -diri -dirinya -terdiri -dong -dulu -enggak -enggaknya -entah -entahlah -terhadap -terhadapnya -hal -hampir -hanya -hanyalah -harus -haruslah -harusnya -seharusnya -hendak -hendaklah -hendaknya -hingga -sehingga -ia -ialah -ibarat -ingin -inginkah -inginkan -ini -inikah -inilah -itu -itukah -itulah -jangan -jangankan -janganlah -jika -jikalau -juga -justru -kala -kalau -kalaulah -kalaupun -kalian -kami -kamilah -kamu -kamulah -kan -kapan -kapankah -kapanpun -dikarenakan -karena -karenanya -ke -kecil -kemudian -kenapa -kepada -kepadanya -ketika -seketika -khususnya -kini -kinilah -kiranya -sekiranya -kita -kitalah -kok -lagi -lagian -selagi -lah -lain -lainnya -melainkan -selaku -lalu -melalui -terlalu -lama -lamanya -selama -selama -selamanya -lebih -terlebih -bermacam -macam -semacam -maka -makanya -makin -malah -malahan -mampu -mampukah -mana -manakala -manalagi -masih -masihkah -semasih -masing -mau -maupun -semaunya -memang -mereka -merekalah -meski -meskipun -semula -mungkin -mungkinkah -nah -namun -nanti -nantinya -nyaris -oleh -olehnya -seorang -seseorang -pada -padanya -padahal -paling -sepanjang -pantas -sepantasnya -sepantasnyalah -para -pasti -pastilah -per -pernah -pula -pun -merupakan -rupanya -serupa -saat -saatnya -sesaat -saja -sajalah -saling -bersama -sama -sesama -sambil -sampai -sana -sangat -sangatlah -saya -sayalah -se -sebab -sebabnya -sebuah -tersebut -tersebutlah -sedang -sedangkan -sedikit -sedikitnya -segala -segalanya -segera -sesegera -sejak -sejenak -sekali -sekalian -sekalipun -sesekali -sekaligus -sekarang -sekarang -sekitar -sekitarnya -sela -selain -selalu -seluruh -seluruhnya -semakin -sementara -sempat -semua -semuanya -sendiri -sendirinya -seolah -seperti -sepertinya -sering -seringnya -serta -siapa -siapakah -siapapun -disini -disinilah -sini -sinilah -sesuatu -sesuatunya -suatu -sesudah -sesudahnya -sudah -sudahkah -sudahlah -supaya -tadi -tadinya -tak -tanpa -setelah -telah -tentang -tentu -tentulah -tentunya -tertentu -seterusnya -tapi -tetapi -setiap -tiap -setidaknya -tidak -tidakkah -tidaklah -toh -waduh -wah -wahai -sewaktu -walau -walaupun -wong -yaitu -yakni -yang +# from appendix D of: A Study of Stemming Effects on Information +# Retrieval in Bahasa Indonesia +ada +adanya +adalah +adapun +agak +agaknya +agar +akan +akankah +akhirnya +aku +akulah +amat +amatlah +anda +andalah +antar +diantaranya +antara +antaranya +diantara +apa +apaan +mengapa +apabila +apakah +apalagi +apatah +atau +ataukah +ataupun +bagai +bagaikan +sebagai +sebagainya +bagaimana +bagaimanapun +sebagaimana +bagaimanakah +bagi +bahkan +bahwa +bahwasanya +sebaliknya +banyak +sebanyak +beberapa +seberapa +begini +beginian +beginikah +beginilah +sebegini +begitu +begitukah +begitulah +begitupun +sebegitu +belum +belumlah +sebelum +sebelumnya +sebenarnya +berapa +berapakah +berapalah +berapapun +betulkah +sebetulnya +biasa +biasanya +bila +bilakah +bisa +bisakah +sebisanya +boleh +bolehkah +bolehlah +buat +bukan +bukankah +bukanlah +bukannya +cuma +percuma +dahulu +dalam +dan +dapat +dari +daripada +dekat +demi +demikian +demikianlah +sedemikian +dengan +depan +di +dia +dialah +dini +diri +dirinya +terdiri +dong +dulu +enggak +enggaknya +entah +entahlah +terhadap +terhadapnya +hal +hampir +hanya +hanyalah +harus +haruslah +harusnya +seharusnya +hendak +hendaklah +hendaknya +hingga +sehingga +ia +ialah +ibarat +ingin +inginkah +inginkan +ini +inikah +inilah +itu +itukah +itulah +jangan +jangankan +janganlah +jika +jikalau +juga +justru +kala +kalau +kalaulah +kalaupun +kalian +kami +kamilah +kamu +kamulah +kan +kapan +kapankah +kapanpun +dikarenakan +karena +karenanya +ke +kecil +kemudian +kenapa +kepada +kepadanya +ketika +seketika +khususnya +kini +kinilah +kiranya +sekiranya +kita +kitalah +kok +lagi +lagian +selagi +lah +lain +lainnya +melainkan +selaku +lalu +melalui +terlalu +lama +lamanya +selama +selama +selamanya +lebih +terlebih +bermacam +macam +semacam +maka +makanya +makin +malah +malahan +mampu +mampukah +mana +manakala +manalagi +masih +masihkah +semasih +masing +mau +maupun +semaunya +memang +mereka +merekalah +meski +meskipun +semula +mungkin +mungkinkah +nah +namun +nanti +nantinya +nyaris +oleh +olehnya +seorang +seseorang +pada +padanya +padahal +paling +sepanjang +pantas +sepantasnya +sepantasnyalah +para +pasti +pastilah +per +pernah +pula +pun +merupakan +rupanya +serupa +saat +saatnya +sesaat +saja +sajalah +saling +bersama +sama +sesama +sambil +sampai +sana +sangat +sangatlah +saya +sayalah +se +sebab +sebabnya +sebuah +tersebut +tersebutlah +sedang +sedangkan +sedikit +sedikitnya +segala +segalanya +segera +sesegera +sejak +sejenak +sekali +sekalian +sekalipun +sesekali +sekaligus +sekarang +sekarang +sekitar +sekitarnya +sela +selain +selalu +seluruh +seluruhnya +semakin +sementara +sempat +semua +semuanya +sendiri +sendirinya +seolah +seperti +sepertinya +sering +seringnya +serta +siapa +siapakah +siapapun +disini +disinilah +sini +sinilah +sesuatu +sesuatunya +suatu +sesudah +sesudahnya +sudah +sudahkah +sudahlah +supaya +tadi +tadinya +tak +tanpa +setelah +telah +tentang +tentu +tentulah +tentunya +tertentu +seterusnya +tapi +tetapi +setiap +tiap +setidaknya +tidak +tidakkah +tidaklah +toh +waduh +wah +wahai +sewaktu +walau +walaupun +wong +yaitu +yakni +yang diff --git a/resources/cache/empty/entity/conf/lang/stopwords_it.txt b/resources/cache/empty/entity/conf/lang/stopwords_it.txt index 3b20c0ab..1219cc77 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_it.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_it.txt @@ -1,303 +1,303 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/italian/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | An Italian stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - -ad | a (to) before vowel -al | a + il -allo | a + lo -ai | a + i -agli | a + gli -all | a + l' -agl | a + gl' -alla | a + la -alle | a + le -con | with -col | con + il -coi | con + i (forms collo, cogli etc are now very rare) -da | from -dal | da + il -dallo | da + lo -dai | da + i -dagli | da + gli -dall | da + l' -dagl | da + gll' -dalla | da + la -dalle | da + le -di | of -del | di + il -dello | di + lo -dei | di + i -degli | di + gli -dell | di + l' -degl | di + gl' -della | di + la -delle | di + le -in | in -nel | in + el -nello | in + lo -nei | in + i -negli | in + gli -nell | in + l' -negl | in + gl' -nella | in + la -nelle | in + le -su | on -sul | su + il -sullo | su + lo -sui | su + i -sugli | su + gli -sull | su + l' -sugl | su + gl' -sulla | su + la -sulle | su + le -per | through, by -tra | among -contro | against -io | I -tu | thou -lui | he -lei | she -noi | we -voi | you -loro | they -mio | my -mia | -miei | -mie | -tuo | -tua | -tuoi | thy -tue | -suo | -sua | -suoi | his, her -sue | -nostro | our -nostra | -nostri | -nostre | -vostro | your -vostra | -vostri | -vostre | -mi | me -ti | thee -ci | us, there -vi | you, there -lo | him, the -la | her, the -li | them -le | them, the -gli | to him, the -ne | from there etc -il | the -un | a -uno | a -una | a -ma | but -ed | and -se | if -perché | why, because -anche | also -come | how -dov | where (as dov') -dove | where -che | who, that -chi | who -cui | whom -non | not -più | more -quale | who, that -quanto | how much -quanti | -quanta | -quante | -quello | that -quelli | -quella | -quelle | -questo | this -questi | -questa | -queste | -si | yes -tutto | all -tutti | all - - | single letter forms: - -a | at -c | as c' for ce or ci -e | and -i | the -l | as l' -o | or - - | forms of avere, to have (not including the infinitive): - -ho -hai -ha -abbiamo -avete -hanno -abbia -abbiate -abbiano -avrò -avrai -avrà -avremo -avrete -avranno -avrei -avresti -avrebbe -avremmo -avreste -avrebbero -avevo -avevi -aveva -avevamo -avevate -avevano -ebbi -avesti -ebbe -avemmo -aveste -ebbero -avessi -avesse -avessimo -avessero -avendo -avuto -avuta -avuti -avute - - | forms of essere, to be (not including the infinitive): -sono -sei -è -siamo -siete -sia -siate -siano -sarò -sarai -sarà -saremo -sarete -saranno -sarei -saresti -sarebbe -saremmo -sareste -sarebbero -ero -eri -era -eravamo -eravate -erano -fui -fosti -fu -fummo -foste -furono -fossi -fosse -fossimo -fossero -essendo - - | forms of fare, to do (not including the infinitive, fa, fat-): -faccio -fai -facciamo -fanno -faccia -facciate -facciano -farò -farai -farà -faremo -farete -faranno -farei -faresti -farebbe -faremmo -fareste -farebbero -facevo -facevi -faceva -facevamo -facevate -facevano -feci -facesti -fece -facemmo -faceste -fecero -facessi -facesse -facessimo -facessero -facendo - - | forms of stare, to be (not including the infinitive): -sto -stai -sta -stiamo -stanno -stia -stiate -stiano -starò -starai -starà -staremo -starete -staranno -starei -staresti -starebbe -staremmo -stareste -starebbero -stavo -stavi -stava -stavamo -stavate -stavano -stetti -stesti -stette -stemmo -steste -stettero -stessi -stesse -stessimo -stessero -stando + | From svn.tartarus.org/snowball/trunk/website/algorithms/italian/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | An Italian stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + +ad | a (to) before vowel +al | a + il +allo | a + lo +ai | a + i +agli | a + gli +all | a + l' +agl | a + gl' +alla | a + la +alle | a + le +con | with +col | con + il +coi | con + i (forms collo, cogli etc are now very rare) +da | from +dal | da + il +dallo | da + lo +dai | da + i +dagli | da + gli +dall | da + l' +dagl | da + gll' +dalla | da + la +dalle | da + le +di | of +del | di + il +dello | di + lo +dei | di + i +degli | di + gli +dell | di + l' +degl | di + gl' +della | di + la +delle | di + le +in | in +nel | in + el +nello | in + lo +nei | in + i +negli | in + gli +nell | in + l' +negl | in + gl' +nella | in + la +nelle | in + le +su | on +sul | su + il +sullo | su + lo +sui | su + i +sugli | su + gli +sull | su + l' +sugl | su + gl' +sulla | su + la +sulle | su + le +per | through, by +tra | among +contro | against +io | I +tu | thou +lui | he +lei | she +noi | we +voi | you +loro | they +mio | my +mia | +miei | +mie | +tuo | +tua | +tuoi | thy +tue | +suo | +sua | +suoi | his, her +sue | +nostro | our +nostra | +nostri | +nostre | +vostro | your +vostra | +vostri | +vostre | +mi | me +ti | thee +ci | us, there +vi | you, there +lo | him, the +la | her, the +li | them +le | them, the +gli | to him, the +ne | from there etc +il | the +un | a +uno | a +una | a +ma | but +ed | and +se | if +perché | why, because +anche | also +come | how +dov | where (as dov') +dove | where +che | who, that +chi | who +cui | whom +non | not +più | more +quale | who, that +quanto | how much +quanti | +quanta | +quante | +quello | that +quelli | +quella | +quelle | +questo | this +questi | +questa | +queste | +si | yes +tutto | all +tutti | all + + | single letter forms: + +a | at +c | as c' for ce or ci +e | and +i | the +l | as l' +o | or + + | forms of avere, to have (not including the infinitive): + +ho +hai +ha +abbiamo +avete +hanno +abbia +abbiate +abbiano +avrò +avrai +avrà +avremo +avrete +avranno +avrei +avresti +avrebbe +avremmo +avreste +avrebbero +avevo +avevi +aveva +avevamo +avevate +avevano +ebbi +avesti +ebbe +avemmo +aveste +ebbero +avessi +avesse +avessimo +avessero +avendo +avuto +avuta +avuti +avute + + | forms of essere, to be (not including the infinitive): +sono +sei +è +siamo +siete +sia +siate +siano +sarò +sarai +sarà +saremo +sarete +saranno +sarei +saresti +sarebbe +saremmo +sareste +sarebbero +ero +eri +era +eravamo +eravate +erano +fui +fosti +fu +fummo +foste +furono +fossi +fosse +fossimo +fossero +essendo + + | forms of fare, to do (not including the infinitive, fa, fat-): +faccio +fai +facciamo +fanno +faccia +facciate +facciano +farò +farai +farà +faremo +farete +faranno +farei +faresti +farebbe +faremmo +fareste +farebbero +facevo +facevi +faceva +facevamo +facevate +facevano +feci +facesti +fece +facemmo +faceste +fecero +facessi +facesse +facessimo +facessero +facendo + + | forms of stare, to be (not including the infinitive): +sto +stai +sta +stiamo +stanno +stia +stiate +stiano +starò +starai +starà +staremo +starete +staranno +starei +staresti +starebbe +staremmo +stareste +starebbero +stavo +stavi +stava +stavamo +stavate +stavano +stetti +stesti +stette +stemmo +steste +stettero +stessi +stesse +stessimo +stessero +stando diff --git a/resources/cache/empty/entity/conf/lang/stopwords_ja.txt b/resources/cache/empty/entity/conf/lang/stopwords_ja.txt index bc3077e5..d4321be6 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_ja.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_ja.txt @@ -1,127 +1,127 @@ -# -# This file defines a stopword set for Japanese. -# -# This set is made up of hand-picked frequent terms from segmented Japanese Wikipedia. -# Punctuation characters and frequent kanji have mostly been left out. See LUCENE-3745 -# for frequency lists, etc. that can be useful for making your own set (if desired) -# -# Note that there is an overlap between these stopwords and the terms stopped when used -# in combination with the JapanesePartOfSpeechStopFilter. When editing this file, note -# that comments are not allowed on the same line as stopwords. -# -# Also note that stopping is done in a case-insensitive manner. Change your StopFilter -# configuration if you need case-sensitive stopping. Lastly, note that stopping is done -# using the same character width as the entries in this file. Since this StopFilter is -# normally done after a CJKWidthFilter in your chain, you would usually want your romaji -# entries to be in half-width and your kana entries to be in full-width. -# -の -に -は -を -た -が -で -て -と -し -れ -さ -ある -いる -も -する -から -な -こと -として -い -や -れる -など -なっ -ない -この -ため -その -あっ -よう -また -もの -という -あり -まで -られ -なる -へ -か -だ -これ -によって -により -おり -より -による -ず -なり -られる -において -ば -なかっ -なく -しかし -について -せ -だっ -その後 -できる -それ -う -ので -なお -のみ -でき -き -つ -における -および -いう -さらに -でも -ら -たり -その他 -に関する -たち -ます -ん -なら -に対して -特に -せる -及び -これら -とき -では -にて -ほか -ながら -うち -そして -とともに -ただし -かつて -それぞれ -または -お -ほど -ものの -に対する -ほとんど -と共に -といった -です -とも -ところ -ここ -##### End of file +# +# This file defines a stopword set for Japanese. +# +# This set is made up of hand-picked frequent terms from segmented Japanese Wikipedia. +# Punctuation characters and frequent kanji have mostly been left out. See LUCENE-3745 +# for frequency lists, etc. that can be useful for making your own set (if desired) +# +# Note that there is an overlap between these stopwords and the terms stopped when used +# in combination with the JapanesePartOfSpeechStopFilter. When editing this file, note +# that comments are not allowed on the same line as stopwords. +# +# Also note that stopping is done in a case-insensitive manner. Change your StopFilter +# configuration if you need case-sensitive stopping. Lastly, note that stopping is done +# using the same character width as the entries in this file. Since this StopFilter is +# normally done after a CJKWidthFilter in your chain, you would usually want your romaji +# entries to be in half-width and your kana entries to be in full-width. +# +の +に +は +を +た +が +で +て +と +し +れ +さ +ある +いる +も +する +から +な +こと +として +い +や +れる +など +なっ +ない +この +ため +その +あっ +よう +また +もの +という +あり +まで +られ +なる +へ +か +だ +これ +によって +により +おり +より +による +ず +なり +られる +において +ば +なかっ +なく +しかし +について +せ +だっ +その後 +できる +それ +う +ので +なお +のみ +でき +き +つ +における +および +いう +さらに +でも +ら +たり +その他 +に関する +たち +ます +ん +なら +に対して +特に +せる +及び +これら +とき +では +にて +ほか +ながら +うち +そして +とともに +ただし +かつて +それぞれ +または +お +ほど +ものの +に対する +ほとんど +と共に +といった +です +とも +ところ +ここ +##### End of file diff --git a/resources/cache/empty/entity/conf/lang/stopwords_lv.txt b/resources/cache/empty/entity/conf/lang/stopwords_lv.txt index a4710974..e21a23c0 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_lv.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_lv.txt @@ -1,172 +1,172 @@ -# Set of Latvian stopwords from A Stemming Algorithm for Latvian, Karlis Kreslins -# the original list of over 800 forms was refined: -# pronouns, adverbs, interjections were removed -# -# prepositions -aiz -ap -ar -apakš -ārpus -augšpus -bez -caur -dēļ -gar -iekš -iz -kopš -labad -lejpus -līdz -no -otrpus -pa -par -pār -pēc -pie -pirms -pret -priekš -starp -šaipus -uz -viņpus -virs -virspus -zem -apakšpus -# Conjunctions -un -bet -jo -ja -ka -lai -tomēr -tikko -turpretī -arī -kaut -gan -tādēļ -tā -ne -tikvien -vien -kā -ir -te -vai -kamēr -# Particles -ar -diezin -droši -diemžēl -nebūt -ik -it -taču -nu -pat -tiklab -iekšpus -nedz -tik -nevis -turpretim -jeb -iekam -iekām -iekāms -kolīdz -līdzko -tiklīdz -jebšu -tālab -tāpēc -nekā -itin -jā -jau -jel -nē -nezin -tad -tikai -vis -tak -iekams -vien -# modal verbs -būt -biju -biji -bija -bijām -bijāt -esmu -esi -esam -esat -būšu -būsi -būs -būsim -būsiet -tikt -tiku -tiki -tika -tikām -tikāt -tieku -tiec -tiek -tiekam -tiekat -tikšu -tiks -tiksim -tiksiet -tapt -tapi -tapāt -topat -tapšu -tapsi -taps -tapsim -tapsiet -kļūt -kļuvu -kļuvi -kļuva -kļuvām -kļuvāt -kļūstu -kļūsti -kļūst -kļūstam -kļūstat -kļūšu -kļūsi -kļūs -kļūsim -kļūsiet -# verbs -varēt -varēju -varējām -varēšu -varēsim -var -varēji -varējāt -varēsi -varēsiet -varat -varēja -varēs +# Set of Latvian stopwords from A Stemming Algorithm for Latvian, Karlis Kreslins +# the original list of over 800 forms was refined: +# pronouns, adverbs, interjections were removed +# +# prepositions +aiz +ap +ar +apakš +ārpus +augšpus +bez +caur +dēļ +gar +iekš +iz +kopš +labad +lejpus +līdz +no +otrpus +pa +par +pār +pēc +pie +pirms +pret +priekš +starp +šaipus +uz +viņpus +virs +virspus +zem +apakšpus +# Conjunctions +un +bet +jo +ja +ka +lai +tomēr +tikko +turpretī +arī +kaut +gan +tādēļ +tā +ne +tikvien +vien +kā +ir +te +vai +kamēr +# Particles +ar +diezin +droši +diemžēl +nebūt +ik +it +taču +nu +pat +tiklab +iekšpus +nedz +tik +nevis +turpretim +jeb +iekam +iekām +iekāms +kolīdz +līdzko +tiklīdz +jebšu +tālab +tāpēc +nekā +itin +jā +jau +jel +nē +nezin +tad +tikai +vis +tak +iekams +vien +# modal verbs +būt +biju +biji +bija +bijām +bijāt +esmu +esi +esam +esat +būšu +būsi +būs +būsim +būsiet +tikt +tiku +tiki +tika +tikām +tikāt +tieku +tiec +tiek +tiekam +tiekat +tikšu +tiks +tiksim +tiksiet +tapt +tapi +tapāt +topat +tapšu +tapsi +taps +tapsim +tapsiet +kļūt +kļuvu +kļuvi +kļuva +kļuvām +kļuvāt +kļūstu +kļūsti +kļūst +kļūstam +kļūstat +kļūšu +kļūsi +kļūs +kļūsim +kļūsiet +# verbs +varēt +varēju +varējām +varēšu +varēsim +var +varēji +varējāt +varēsi +varēsiet +varat +varēja +varēs diff --git a/resources/cache/empty/entity/conf/lang/stopwords_nl.txt b/resources/cache/empty/entity/conf/lang/stopwords_nl.txt index 06ca75ba..47a2aeac 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_nl.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_nl.txt @@ -1,119 +1,119 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/dutch/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Dutch stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - | This is a ranked list (commonest to rarest) of stopwords derived from - | a large sample of Dutch text. - - | Dutch stop words frequently exhibit homonym clashes. These are indicated - | clearly below. - -de | the -en | and -van | of, from -ik | I, the ego -te | (1) chez, at etc, (2) to, (3) too -dat | that, which -die | that, those, who, which -in | in, inside -een | a, an, one -hij | he -het | the, it -niet | not, nothing, naught -zijn | (1) to be, being, (2) his, one's, its -is | is -was | (1) was, past tense of all persons sing. of 'zijn' (to be) (2) wax, (3) the washing, (4) rise of river -op | on, upon, at, in, up, used up -aan | on, upon, to (as dative) -met | with, by -als | like, such as, when -voor | (1) before, in front of, (2) furrow -had | had, past tense all persons sing. of 'hebben' (have) -er | there -maar | but, only -om | round, about, for etc -hem | him -dan | then -zou | should/would, past tense all persons sing. of 'zullen' -of | or, whether, if -wat | what, something, anything -mijn | possessive and noun 'mine' -men | people, 'one' -dit | this -zo | so, thus, in this way -door | through by -over | over, across -ze | she, her, they, them -zich | oneself -bij | (1) a bee, (2) by, near, at -ook | also, too -tot | till, until -je | you -mij | me -uit | out of, from -der | Old Dutch form of 'van der' still found in surnames -daar | (1) there, (2) because -haar | (1) her, their, them, (2) hair -naar | (1) unpleasant, unwell etc, (2) towards, (3) as -heb | present first person sing. of 'to have' -hoe | how, why -heeft | present third person sing. of 'to have' -hebben | 'to have' and various parts thereof -deze | this -u | you -want | (1) for, (2) mitten, (3) rigging -nog | yet, still -zal | 'shall', first and third person sing. of verb 'zullen' (will) -me | me -zij | she, they -nu | now -ge | 'thou', still used in Belgium and south Netherlands -geen | none -omdat | because -iets | something, somewhat -worden | to become, grow, get -toch | yet, still -al | all, every, each -waren | (1) 'were' (2) to wander, (3) wares, (3) -veel | much, many -meer | (1) more, (2) lake -doen | to do, to make -toen | then, when -moet | noun 'spot/mote' and present form of 'to must' -ben | (1) am, (2) 'are' in interrogative second person singular of 'to be' -zonder | without -kan | noun 'can' and present form of 'to be able' -hun | their, them -dus | so, consequently -alles | all, everything, anything -onder | under, beneath -ja | yes, of course -eens | once, one day -hier | here -wie | who -werd | imperfect third person sing. of 'become' -altijd | always -doch | yet, but etc -wordt | present third person sing. of 'become' -wezen | (1) to be, (2) 'been' as in 'been fishing', (3) orphans -kunnen | to be able -ons | us/our -zelf | self -tegen | against, towards, at -na | after, near -reeds | already -wil | (1) present tense of 'want', (2) 'will', noun, (3) fender -kon | could; past tense of 'to be able' -niets | nothing -uw | your -iemand | somebody -geweest | been; past participle of 'be' -andere | other + | From svn.tartarus.org/snowball/trunk/website/algorithms/dutch/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Dutch stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + | This is a ranked list (commonest to rarest) of stopwords derived from + | a large sample of Dutch text. + + | Dutch stop words frequently exhibit homonym clashes. These are indicated + | clearly below. + +de | the +en | and +van | of, from +ik | I, the ego +te | (1) chez, at etc, (2) to, (3) too +dat | that, which +die | that, those, who, which +in | in, inside +een | a, an, one +hij | he +het | the, it +niet | not, nothing, naught +zijn | (1) to be, being, (2) his, one's, its +is | is +was | (1) was, past tense of all persons sing. of 'zijn' (to be) (2) wax, (3) the washing, (4) rise of river +op | on, upon, at, in, up, used up +aan | on, upon, to (as dative) +met | with, by +als | like, such as, when +voor | (1) before, in front of, (2) furrow +had | had, past tense all persons sing. of 'hebben' (have) +er | there +maar | but, only +om | round, about, for etc +hem | him +dan | then +zou | should/would, past tense all persons sing. of 'zullen' +of | or, whether, if +wat | what, something, anything +mijn | possessive and noun 'mine' +men | people, 'one' +dit | this +zo | so, thus, in this way +door | through by +over | over, across +ze | she, her, they, them +zich | oneself +bij | (1) a bee, (2) by, near, at +ook | also, too +tot | till, until +je | you +mij | me +uit | out of, from +der | Old Dutch form of 'van der' still found in surnames +daar | (1) there, (2) because +haar | (1) her, their, them, (2) hair +naar | (1) unpleasant, unwell etc, (2) towards, (3) as +heb | present first person sing. of 'to have' +hoe | how, why +heeft | present third person sing. of 'to have' +hebben | 'to have' and various parts thereof +deze | this +u | you +want | (1) for, (2) mitten, (3) rigging +nog | yet, still +zal | 'shall', first and third person sing. of verb 'zullen' (will) +me | me +zij | she, they +nu | now +ge | 'thou', still used in Belgium and south Netherlands +geen | none +omdat | because +iets | something, somewhat +worden | to become, grow, get +toch | yet, still +al | all, every, each +waren | (1) 'were' (2) to wander, (3) wares, (3) +veel | much, many +meer | (1) more, (2) lake +doen | to do, to make +toen | then, when +moet | noun 'spot/mote' and present form of 'to must' +ben | (1) am, (2) 'are' in interrogative second person singular of 'to be' +zonder | without +kan | noun 'can' and present form of 'to be able' +hun | their, them +dus | so, consequently +alles | all, everything, anything +onder | under, beneath +ja | yes, of course +eens | once, one day +hier | here +wie | who +werd | imperfect third person sing. of 'become' +altijd | always +doch | yet, but etc +wordt | present third person sing. of 'become' +wezen | (1) to be, (2) 'been' as in 'been fishing', (3) orphans +kunnen | to be able +ons | us/our +zelf | self +tegen | against, towards, at +na | after, near +reeds | already +wil | (1) present tense of 'want', (2) 'will', noun, (3) fender +kon | could; past tense of 'to be able' +niets | nothing +uw | your +iemand | somebody +geweest | been; past participle of 'be' +andere | other diff --git a/resources/cache/empty/entity/conf/lang/stopwords_no.txt b/resources/cache/empty/entity/conf/lang/stopwords_no.txt index 8aefda89..a7a2c28b 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_no.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_no.txt @@ -1,194 +1,194 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/norwegian/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Norwegian stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - | This stop word list is for the dominant bokmål dialect. Words unique - | to nynorsk are marked *. - - | Revised by Jan Bruusgaard , Jan 2005 - -og | and -i | in -jeg | I -det | it/this/that -at | to (w. inf.) -en | a/an -et | a/an -den | it/this/that -til | to -er | is/am/are -som | who/that -på | on -de | they / you(formal) -med | with -han | he -av | of -ikke | not -ikkje | not * -der | there -så | so -var | was/were -meg | me -seg | you -men | but -ett | one -har | have -om | about -vi | we -min | my -mitt | my -ha | have -hadde | had -hun | she -nå | now -over | over -da | when/as -ved | by/know -fra | from -du | you -ut | out -sin | your -dem | them -oss | us -opp | up -man | you/one -kan | can -hans | his -hvor | where -eller | or -hva | what -skal | shall/must -selv | self (reflective) -sjøl | self (reflective) -her | here -alle | all -vil | will -bli | become -ble | became -blei | became * -blitt | have become -kunne | could -inn | in -når | when -være | be -kom | come -noen | some -noe | some -ville | would -dere | you -som | who/which/that -deres | their/theirs -kun | only/just -ja | yes -etter | after -ned | down -skulle | should -denne | this -for | for/because -deg | you -si | hers/his -sine | hers/his -sitt | hers/his -mot | against -å | to -meget | much -hvorfor | why -dette | this -disse | these/those -uten | without -hvordan | how -ingen | none -din | your -ditt | your -blir | become -samme | same -hvilken | which -hvilke | which (plural) -sånn | such a -inni | inside/within -mellom | between -vår | our -hver | each -hvem | who -vors | us/ours -hvis | whose -både | both -bare | only/just -enn | than -fordi | as/because -før | before -mange | many -også | also -slik | just -vært | been -være | to be -båe | both * -begge | both -siden | since -dykk | your * -dykkar | yours * -dei | they * -deira | them * -deires | theirs * -deim | them * -di | your (fem.) * -då | as/when * -eg | I * -ein | a/an * -eit | a/an * -eitt | a/an * -elles | or * -honom | he * -hjå | at * -ho | she * -hoe | she * -henne | her -hennar | her/hers -hennes | hers -hoss | how * -hossen | how * -ikkje | not * -ingi | noone * -inkje | noone * -korleis | how * -korso | how * -kva | what/which * -kvar | where * -kvarhelst | where * -kven | who/whom * -kvi | why * -kvifor | why * -me | we * -medan | while * -mi | my * -mine | my * -mykje | much * -no | now * -nokon | some (masc./neut.) * -noka | some (fem.) * -nokor | some * -noko | some * -nokre | some * -si | his/hers * -sia | since * -sidan | since * -so | so * -somt | some * -somme | some * -um | about* -upp | up * -vere | be * -vore | was * -verte | become * -vort | become * -varte | became * -vart | became * - + | From svn.tartarus.org/snowball/trunk/website/algorithms/norwegian/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Norwegian stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + | This stop word list is for the dominant bokmål dialect. Words unique + | to nynorsk are marked *. + + | Revised by Jan Bruusgaard , Jan 2005 + +og | and +i | in +jeg | I +det | it/this/that +at | to (w. inf.) +en | a/an +et | a/an +den | it/this/that +til | to +er | is/am/are +som | who/that +på | on +de | they / you(formal) +med | with +han | he +av | of +ikke | not +ikkje | not * +der | there +så | so +var | was/were +meg | me +seg | you +men | but +ett | one +har | have +om | about +vi | we +min | my +mitt | my +ha | have +hadde | had +hun | she +nå | now +over | over +da | when/as +ved | by/know +fra | from +du | you +ut | out +sin | your +dem | them +oss | us +opp | up +man | you/one +kan | can +hans | his +hvor | where +eller | or +hva | what +skal | shall/must +selv | self (reflective) +sjøl | self (reflective) +her | here +alle | all +vil | will +bli | become +ble | became +blei | became * +blitt | have become +kunne | could +inn | in +når | when +være | be +kom | come +noen | some +noe | some +ville | would +dere | you +som | who/which/that +deres | their/theirs +kun | only/just +ja | yes +etter | after +ned | down +skulle | should +denne | this +for | for/because +deg | you +si | hers/his +sine | hers/his +sitt | hers/his +mot | against +å | to +meget | much +hvorfor | why +dette | this +disse | these/those +uten | without +hvordan | how +ingen | none +din | your +ditt | your +blir | become +samme | same +hvilken | which +hvilke | which (plural) +sånn | such a +inni | inside/within +mellom | between +vår | our +hver | each +hvem | who +vors | us/ours +hvis | whose +både | both +bare | only/just +enn | than +fordi | as/because +før | before +mange | many +også | also +slik | just +vært | been +være | to be +båe | both * +begge | both +siden | since +dykk | your * +dykkar | yours * +dei | they * +deira | them * +deires | theirs * +deim | them * +di | your (fem.) * +då | as/when * +eg | I * +ein | a/an * +eit | a/an * +eitt | a/an * +elles | or * +honom | he * +hjå | at * +ho | she * +hoe | she * +henne | her +hennar | her/hers +hennes | hers +hoss | how * +hossen | how * +ikkje | not * +ingi | noone * +inkje | noone * +korleis | how * +korso | how * +kva | what/which * +kvar | where * +kvarhelst | where * +kven | who/whom * +kvi | why * +kvifor | why * +me | we * +medan | while * +mi | my * +mine | my * +mykje | much * +no | now * +nokon | some (masc./neut.) * +noka | some (fem.) * +nokor | some * +noko | some * +nokre | some * +si | his/hers * +sia | since * +sidan | since * +so | so * +somt | some * +somme | some * +um | about* +upp | up * +vere | be * +vore | was * +verte | become * +vort | become * +varte | became * +vart | became * + diff --git a/resources/cache/empty/entity/conf/lang/stopwords_pt.txt b/resources/cache/empty/entity/conf/lang/stopwords_pt.txt index 6afa2b5c..acfeb01a 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_pt.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_pt.txt @@ -1,253 +1,253 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/portuguese/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Portuguese stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - - | The following is a ranked list (commonest to rarest) of stopwords - | deriving from a large sample of text. - - | Extra words have been added at the end. - -de | of, from -a | the; to, at; her -o | the; him -que | who, that -e | and -do | de + o -da | de + a -em | in -um | a -para | for - | é from SER -com | with -não | not, no -uma | a -os | the; them -no | em + o -se | himself etc -na | em + a -por | for -mais | more -as | the; them -dos | de + os -como | as, like -mas | but - | foi from SER -ao | a + o -ele | he -das | de + as - | tem from TER -à | a + a -seu | his -sua | her -ou | or - | ser from SER -quando | when -muito | much - | há from HAV -nos | em + os; us -já | already, now - | está from EST -eu | I -também | also -só | only, just -pelo | per + o -pela | per + a -até | up to -isso | that -ela | he -entre | between - | era from SER -depois | after -sem | without -mesmo | same -aos | a + os - | ter from TER -seus | his -quem | whom -nas | em + as -me | me -esse | that -eles | they - | estão from EST -você | you - | tinha from TER - | foram from SER -essa | that -num | em + um -nem | nor -suas | her -meu | my -às | a + as -minha | my - | têm from TER -numa | em + uma -pelos | per + os -elas | they - | havia from HAV - | seja from SER -qual | which - | será from SER -nós | we - | tenho from TER -lhe | to him, her -deles | of them -essas | those -esses | those -pelas | per + as -este | this - | fosse from SER -dele | of him - - | other words. There are many contractions such as naquele = em+aquele, - | mo = me+o, but they are rare. - | Indefinite article plural forms are also rare. - -tu | thou -te | thee -vocês | you (plural) -vos | you -lhes | to them -meus | my -minhas -teu | thy -tua -teus -tuas -nosso | our -nossa -nossos -nossas - -dela | of her -delas | of them - -esta | this -estes | these -estas | these -aquele | that -aquela | that -aqueles | those -aquelas | those -isto | this -aquilo | that - - | forms of estar, to be (not including the infinitive): -estou -está -estamos -estão -estive -esteve -estivemos -estiveram -estava -estávamos -estavam -estivera -estivéramos -esteja -estejamos -estejam -estivesse -estivéssemos -estivessem -estiver -estivermos -estiverem - - | forms of haver, to have (not including the infinitive): -hei -há -havemos -hão -houve -houvemos -houveram -houvera -houvéramos -haja -hajamos -hajam -houvesse -houvéssemos -houvessem -houver -houvermos -houverem -houverei -houverá -houveremos -houverão -houveria -houveríamos -houveriam - - | forms of ser, to be (not including the infinitive): -sou -somos -são -era -éramos -eram -fui -foi -fomos -foram -fora -fôramos -seja -sejamos -sejam -fosse -fôssemos -fossem -for -formos -forem -serei -será -seremos -serão -seria -seríamos -seriam - - | forms of ter, to have (not including the infinitive): -tenho -tem -temos -tém -tinha -tínhamos -tinham -tive -teve -tivemos -tiveram -tivera -tivéramos -tenha -tenhamos -tenham -tivesse -tivéssemos -tivessem -tiver -tivermos -tiverem -terei -terá -teremos -terão -teria -teríamos -teriam + | From svn.tartarus.org/snowball/trunk/website/algorithms/portuguese/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Portuguese stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + + | The following is a ranked list (commonest to rarest) of stopwords + | deriving from a large sample of text. + + | Extra words have been added at the end. + +de | of, from +a | the; to, at; her +o | the; him +que | who, that +e | and +do | de + o +da | de + a +em | in +um | a +para | for + | é from SER +com | with +não | not, no +uma | a +os | the; them +no | em + o +se | himself etc +na | em + a +por | for +mais | more +as | the; them +dos | de + os +como | as, like +mas | but + | foi from SER +ao | a + o +ele | he +das | de + as + | tem from TER +à | a + a +seu | his +sua | her +ou | or + | ser from SER +quando | when +muito | much + | há from HAV +nos | em + os; us +já | already, now + | está from EST +eu | I +também | also +só | only, just +pelo | per + o +pela | per + a +até | up to +isso | that +ela | he +entre | between + | era from SER +depois | after +sem | without +mesmo | same +aos | a + os + | ter from TER +seus | his +quem | whom +nas | em + as +me | me +esse | that +eles | they + | estão from EST +você | you + | tinha from TER + | foram from SER +essa | that +num | em + um +nem | nor +suas | her +meu | my +às | a + as +minha | my + | têm from TER +numa | em + uma +pelos | per + os +elas | they + | havia from HAV + | seja from SER +qual | which + | será from SER +nós | we + | tenho from TER +lhe | to him, her +deles | of them +essas | those +esses | those +pelas | per + as +este | this + | fosse from SER +dele | of him + + | other words. There are many contractions such as naquele = em+aquele, + | mo = me+o, but they are rare. + | Indefinite article plural forms are also rare. + +tu | thou +te | thee +vocês | you (plural) +vos | you +lhes | to them +meus | my +minhas +teu | thy +tua +teus +tuas +nosso | our +nossa +nossos +nossas + +dela | of her +delas | of them + +esta | this +estes | these +estas | these +aquele | that +aquela | that +aqueles | those +aquelas | those +isto | this +aquilo | that + + | forms of estar, to be (not including the infinitive): +estou +está +estamos +estão +estive +esteve +estivemos +estiveram +estava +estávamos +estavam +estivera +estivéramos +esteja +estejamos +estejam +estivesse +estivéssemos +estivessem +estiver +estivermos +estiverem + + | forms of haver, to have (not including the infinitive): +hei +há +havemos +hão +houve +houvemos +houveram +houvera +houvéramos +haja +hajamos +hajam +houvesse +houvéssemos +houvessem +houver +houvermos +houverem +houverei +houverá +houveremos +houverão +houveria +houveríamos +houveriam + + | forms of ser, to be (not including the infinitive): +sou +somos +são +era +éramos +eram +fui +foi +fomos +foram +fora +fôramos +seja +sejamos +sejam +fosse +fôssemos +fossem +for +formos +forem +serei +será +seremos +serão +seria +seríamos +seriam + + | forms of ter, to have (not including the infinitive): +tenho +tem +temos +tém +tinha +tínhamos +tinham +tive +teve +tivemos +tiveram +tivera +tivéramos +tenha +tenhamos +tenham +tivesse +tivéssemos +tivessem +tiver +tivermos +tiverem +terei +terá +teremos +terão +teria +teríamos +teriam diff --git a/resources/cache/empty/entity/conf/lang/stopwords_ro.txt b/resources/cache/empty/entity/conf/lang/stopwords_ro.txt index 2d7395c4..4fdee90a 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_ro.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_ro.txt @@ -1,233 +1,233 @@ -# This file was created by Jacques Savoy and is distributed under the BSD license. -# See http://members.unine.ch/jacques.savoy/clef/index.html. -# Also see http://www.opensource.org/licenses/bsd-license.html -acea -aceasta -această -aceea -acei -aceia -acel -acela -acele -acelea -acest -acesta -aceste -acestea -aceşti -aceştia -acolo -acum -ai -aia -aibă -aici -al -ăla -ale -alea -ălea -altceva -altcineva -am -ar -are -aş -aşadar -asemenea -asta -ăsta -astăzi -astea -ăstea -ăştia -asupra -aţi -au -avea -avem -aveţi -azi -bine -bucur -bună -ca -că -căci -când -care -cărei -căror -cărui -cât -câte -câţi -către -câtva -ce -cel -ceva -chiar -cînd -cine -cineva -cît -cîte -cîţi -cîtva -contra -cu -cum -cumva -curând -curînd -da -dă -dacă -dar -datorită -de -deci -deja -deoarece -departe -deşi -din -dinaintea -dintr -dintre -drept -după -ea -ei -el -ele -eram -este -eşti -eu -face -fără -fi -fie -fiecare -fii -fim -fiţi -iar -ieri -îi -îl -îmi -împotriva -în -înainte -înaintea -încât -încît -încotro -între -întrucât -întrucît -îţi -la -lângă -le -li -lîngă -lor -lui -mă -mâine -mea -mei -mele -mereu -meu -mi -mine -mult -multă -mulţi -ne -nicăieri -nici -nimeni -nişte -noastră -noastre -noi -noştri -nostru -nu -ori -oricând -oricare -oricât -orice -oricînd -oricine -oricît -oricum -oriunde -până -pe -pentru -peste -pînă -poate -pot -prea -prima -primul -prin -printr -sa -să -săi -sale -sau -său -se -şi -sînt -sîntem -sînteţi -spre -sub -sunt -suntem -sunteţi -ta -tăi -tale -tău -te -ţi -ţie -tine -toată -toate -tot -toţi -totuşi -tu -un -una -unde -undeva -unei -unele -uneori -unor -vă -vi -voastră -voastre -voi -voştri -vostru -vouă -vreo -vreun +# This file was created by Jacques Savoy and is distributed under the BSD license. +# See http://members.unine.ch/jacques.savoy/clef/index.html. +# Also see http://www.opensource.org/licenses/bsd-license.html +acea +aceasta +această +aceea +acei +aceia +acel +acela +acele +acelea +acest +acesta +aceste +acestea +aceşti +aceştia +acolo +acum +ai +aia +aibă +aici +al +ăla +ale +alea +ălea +altceva +altcineva +am +ar +are +aş +aşadar +asemenea +asta +ăsta +astăzi +astea +ăstea +ăştia +asupra +aţi +au +avea +avem +aveţi +azi +bine +bucur +bună +ca +că +căci +când +care +cărei +căror +cărui +cât +câte +câţi +către +câtva +ce +cel +ceva +chiar +cînd +cine +cineva +cît +cîte +cîţi +cîtva +contra +cu +cum +cumva +curând +curînd +da +dă +dacă +dar +datorită +de +deci +deja +deoarece +departe +deşi +din +dinaintea +dintr +dintre +drept +după +ea +ei +el +ele +eram +este +eşti +eu +face +fără +fi +fie +fiecare +fii +fim +fiţi +iar +ieri +îi +îl +îmi +împotriva +în +înainte +înaintea +încât +încît +încotro +între +întrucât +întrucît +îţi +la +lângă +le +li +lîngă +lor +lui +mă +mâine +mea +mei +mele +mereu +meu +mi +mine +mult +multă +mulţi +ne +nicăieri +nici +nimeni +nişte +noastră +noastre +noi +noştri +nostru +nu +ori +oricând +oricare +oricât +orice +oricînd +oricine +oricît +oricum +oriunde +până +pe +pentru +peste +pînă +poate +pot +prea +prima +primul +prin +printr +sa +să +săi +sale +sau +său +se +şi +sînt +sîntem +sînteţi +spre +sub +sunt +suntem +sunteţi +ta +tăi +tale +tău +te +ţi +ţie +tine +toată +toate +tot +toţi +totuşi +tu +un +una +unde +undeva +unei +unele +uneori +unor +vă +vi +voastră +voastre +voi +voştri +vostru +vouă +vreo +vreun diff --git a/resources/cache/empty/entity/conf/lang/stopwords_ru.txt b/resources/cache/empty/entity/conf/lang/stopwords_ru.txt index 0141b9b8..55271400 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_ru.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_ru.txt @@ -1,243 +1,243 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/russian/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | a russian stop word list. comments begin with vertical bar. each stop - | word is at the start of a line. - - | this is a ranked list (commonest to rarest) of stopwords derived from - | a large text sample. - - | letter `ё' is translated to `е'. - -и | and -в | in/into -во | alternative form -не | not -что | what/that -он | he -на | on/onto -я | i -с | from -со | alternative form -как | how -а | milder form of `no' (but) -то | conjunction and form of `that' -все | all -она | she -так | so, thus -его | him -но | but -да | yes/and -ты | thou -к | towards, by -у | around, chez -же | intensifier particle -вы | you -за | beyond, behind -бы | conditional/subj. particle -по | up to, along -только | only -ее | her -мне | to me -было | it was -вот | here is/are, particle -от | away from -меня | me -еще | still, yet, more -нет | no, there isnt/arent -о | about -из | out of -ему | to him -теперь | now -когда | when -даже | even -ну | so, well -вдруг | suddenly -ли | interrogative particle -если | if -уже | already, but homonym of `narrower' -или | or -ни | neither -быть | to be -был | he was -него | prepositional form of его -до | up to -вас | you accusative -нибудь | indef. suffix preceded by hyphen -опять | again -уж | already, but homonym of `adder' -вам | to you -сказал | he said -ведь | particle `after all' -там | there -потом | then -себя | oneself -ничего | nothing -ей | to her -может | usually with `быть' as `maybe' -они | they -тут | here -где | where -есть | there is/are -надо | got to, must -ней | prepositional form of ей -для | for -мы | we -тебя | thee -их | them, their -чем | than -была | she was -сам | self -чтоб | in order to -без | without -будто | as if -человек | man, person, one -чего | genitive form of `what' -раз | once -тоже | also -себе | to oneself -под | beneath -жизнь | life -будет | will be -ж | short form of intensifer particle `же' -тогда | then -кто | who -этот | this -говорил | was saying -того | genitive form of `that' -потому | for that reason -этого | genitive form of `this' -какой | which -совсем | altogether -ним | prepositional form of `его', `они' -здесь | here -этом | prepositional form of `этот' -один | one -почти | almost -мой | my -тем | instrumental/dative plural of `тот', `то' -чтобы | full form of `in order that' -нее | her (acc.) -кажется | it seems -сейчас | now -были | they were -куда | where to -зачем | why -сказать | to say -всех | all (acc., gen. preposn. plural) -никогда | never -сегодня | today -можно | possible, one can -при | by -наконец | finally -два | two -об | alternative form of `о', about -другой | another -хоть | even -после | after -над | above -больше | more -тот | that one (masc.) -через | across, in -эти | these -нас | us -про | about -всего | in all, only, of all -них | prepositional form of `они' (they) -какая | which, feminine -много | lots -разве | interrogative particle -сказала | she said -три | three -эту | this, acc. fem. sing. -моя | my, feminine -впрочем | moreover, besides -хорошо | good -свою | ones own, acc. fem. sing. -этой | oblique form of `эта', fem. `this' -перед | in front of -иногда | sometimes -лучше | better -чуть | a little -том | preposn. form of `that one' -нельзя | one must not -такой | such a one -им | to them -более | more -всегда | always -конечно | of course -всю | acc. fem. sing of `all' -между | between - - - | b: some paradigms - | - | personal pronouns - | - | я меня мне мной [мною] - | ты тебя тебе тобой [тобою] - | он его ему им [него, нему, ним] - | она ее эи ею [нее, нэи, нею] - | оно его ему им [него, нему, ним] - | - | мы нас нам нами - | вы вас вам вами - | они их им ими [них, ним, ними] - | - | себя себе собой [собою] - | - | demonstrative pronouns: этот (this), тот (that) - | - | этот эта это эти - | этого эты это эти - | этого этой этого этих - | этому этой этому этим - | этим этой этим [этою] этими - | этом этой этом этих - | - | тот та то те - | того ту то те - | того той того тех - | тому той тому тем - | тем той тем [тою] теми - | том той том тех - | - | determinative pronouns - | - | (a) весь (all) - | - | весь вся все все - | всего всю все все - | всего всей всего всех - | всему всей всему всем - | всем всей всем [всею] всеми - | всем всей всем всех - | - | (b) сам (himself etc) - | - | сам сама само сами - | самого саму само самих - | самого самой самого самих - | самому самой самому самим - | самим самой самим [самою] самими - | самом самой самом самих - | - | stems of verbs `to be', `to have', `to do' and modal - | - | быть бы буд быв есть суть - | име - | дел - | мог мож мочь - | уме - | хоч хот - | долж - | можн - | нужн - | нельзя - + | From svn.tartarus.org/snowball/trunk/website/algorithms/russian/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | a russian stop word list. comments begin with vertical bar. each stop + | word is at the start of a line. + + | this is a ranked list (commonest to rarest) of stopwords derived from + | a large text sample. + + | letter `ё' is translated to `е'. + +и | and +в | in/into +во | alternative form +не | not +что | what/that +он | he +на | on/onto +я | i +с | from +со | alternative form +как | how +а | milder form of `no' (but) +то | conjunction and form of `that' +все | all +она | she +так | so, thus +его | him +но | but +да | yes/and +ты | thou +к | towards, by +у | around, chez +же | intensifier particle +вы | you +за | beyond, behind +бы | conditional/subj. particle +по | up to, along +только | only +ее | her +мне | to me +было | it was +вот | here is/are, particle +от | away from +меня | me +еще | still, yet, more +нет | no, there isnt/arent +о | about +из | out of +ему | to him +теперь | now +когда | when +даже | even +ну | so, well +вдруг | suddenly +ли | interrogative particle +если | if +уже | already, but homonym of `narrower' +или | or +ни | neither +быть | to be +был | he was +него | prepositional form of его +до | up to +вас | you accusative +нибудь | indef. suffix preceded by hyphen +опять | again +уж | already, but homonym of `adder' +вам | to you +сказал | he said +ведь | particle `after all' +там | there +потом | then +себя | oneself +ничего | nothing +ей | to her +может | usually with `быть' as `maybe' +они | they +тут | here +где | where +есть | there is/are +надо | got to, must +ней | prepositional form of ей +для | for +мы | we +тебя | thee +их | them, their +чем | than +была | she was +сам | self +чтоб | in order to +без | without +будто | as if +человек | man, person, one +чего | genitive form of `what' +раз | once +тоже | also +себе | to oneself +под | beneath +жизнь | life +будет | will be +ж | short form of intensifer particle `же' +тогда | then +кто | who +этот | this +говорил | was saying +того | genitive form of `that' +потому | for that reason +этого | genitive form of `this' +какой | which +совсем | altogether +ним | prepositional form of `его', `они' +здесь | here +этом | prepositional form of `этот' +один | one +почти | almost +мой | my +тем | instrumental/dative plural of `тот', `то' +чтобы | full form of `in order that' +нее | her (acc.) +кажется | it seems +сейчас | now +были | they were +куда | where to +зачем | why +сказать | to say +всех | all (acc., gen. preposn. plural) +никогда | never +сегодня | today +можно | possible, one can +при | by +наконец | finally +два | two +об | alternative form of `о', about +другой | another +хоть | even +после | after +над | above +больше | more +тот | that one (masc.) +через | across, in +эти | these +нас | us +про | about +всего | in all, only, of all +них | prepositional form of `они' (they) +какая | which, feminine +много | lots +разве | interrogative particle +сказала | she said +три | three +эту | this, acc. fem. sing. +моя | my, feminine +впрочем | moreover, besides +хорошо | good +свою | ones own, acc. fem. sing. +этой | oblique form of `эта', fem. `this' +перед | in front of +иногда | sometimes +лучше | better +чуть | a little +том | preposn. form of `that one' +нельзя | one must not +такой | such a one +им | to them +более | more +всегда | always +конечно | of course +всю | acc. fem. sing of `all' +между | between + + + | b: some paradigms + | + | personal pronouns + | + | я меня мне мной [мною] + | ты тебя тебе тобой [тобою] + | он его ему им [него, нему, ним] + | она ее эи ею [нее, нэи, нею] + | оно его ему им [него, нему, ним] + | + | мы нас нам нами + | вы вас вам вами + | они их им ими [них, ним, ними] + | + | себя себе собой [собою] + | + | demonstrative pronouns: этот (this), тот (that) + | + | этот эта это эти + | этого эты это эти + | этого этой этого этих + | этому этой этому этим + | этим этой этим [этою] этими + | этом этой этом этих + | + | тот та то те + | того ту то те + | того той того тех + | тому той тому тем + | тем той тем [тою] теми + | том той том тех + | + | determinative pronouns + | + | (a) весь (all) + | + | весь вся все все + | всего всю все все + | всего всей всего всех + | всему всей всему всем + | всем всей всем [всею] всеми + | всем всей всем всех + | + | (b) сам (himself etc) + | + | сам сама само сами + | самого саму само самих + | самого самой самого самих + | самому самой самому самим + | самим самой самим [самою] самими + | самом самой самом самих + | + | stems of verbs `to be', `to have', `to do' and modal + | + | быть бы буд быв есть суть + | име + | дел + | мог мож мочь + | уме + | хоч хот + | долж + | можн + | нужн + | нельзя + diff --git a/resources/cache/empty/entity/conf/lang/stopwords_sv.txt b/resources/cache/empty/entity/conf/lang/stopwords_sv.txt index 7216373b..096f87f6 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_sv.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_sv.txt @@ -1,133 +1,133 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/swedish/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Swedish stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - | This is a ranked list (commonest to rarest) of stopwords derived from - | a large text sample. - - | Swedish stop words occasionally exhibit homonym clashes. For example - | så = so, but also seed. These are indicated clearly below. - -och | and -det | it, this/that -att | to (with infinitive) -i | in, at -en | a -jag | I -hon | she -som | who, that -han | he -på | on -den | it, this/that -med | with -var | where, each -sig | him(self) etc -för | for -så | so (also: seed) -till | to -är | is -men | but -ett | a -om | if; around, about -hade | had -de | they, these/those -av | of -icke | not, no -mig | me -du | you -henne | her -då | then, when -sin | his -nu | now -har | have -inte | inte någon = no one -hans | his -honom | him -skulle | 'sake' -hennes | her -där | there -min | my -man | one (pronoun) -ej | nor -vid | at, by, on (also: vast) -kunde | could -något | some etc -från | from, off -ut | out -när | when -efter | after, behind -upp | up -vi | we -dem | them -vara | be -vad | what -över | over -än | than -dig | you -kan | can -sina | his -här | here -ha | have -mot | towards -alla | all -under | under (also: wonder) -någon | some etc -eller | or (else) -allt | all -mycket | much -sedan | since -ju | why -denna | this/that -själv | myself, yourself etc -detta | this/that -åt | to -utan | without -varit | was -hur | how -ingen | no -mitt | my -ni | you -bli | to be, become -blev | from bli -oss | us -din | thy -dessa | these/those -några | some etc -deras | their -blir | from bli -mina | my -samma | (the) same -vilken | who, that -er | you, your -sådan | such a -vår | our -blivit | from bli -dess | its -inom | within -mellan | between -sådant | such a -varför | why -varje | each -vilka | who, that -ditt | thy -vem | who -vilket | who, that -sitta | his -sådana | such a -vart | each -dina | thy -vars | whose -vårt | our -våra | our -ert | your -era | your -vilkas | whose - + | From svn.tartarus.org/snowball/trunk/website/algorithms/swedish/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Swedish stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + | This is a ranked list (commonest to rarest) of stopwords derived from + | a large text sample. + + | Swedish stop words occasionally exhibit homonym clashes. For example + | så = so, but also seed. These are indicated clearly below. + +och | and +det | it, this/that +att | to (with infinitive) +i | in, at +en | a +jag | I +hon | she +som | who, that +han | he +på | on +den | it, this/that +med | with +var | where, each +sig | him(self) etc +för | for +så | so (also: seed) +till | to +är | is +men | but +ett | a +om | if; around, about +hade | had +de | they, these/those +av | of +icke | not, no +mig | me +du | you +henne | her +då | then, when +sin | his +nu | now +har | have +inte | inte någon = no one +hans | his +honom | him +skulle | 'sake' +hennes | her +där | there +min | my +man | one (pronoun) +ej | nor +vid | at, by, on (also: vast) +kunde | could +något | some etc +från | from, off +ut | out +när | when +efter | after, behind +upp | up +vi | we +dem | them +vara | be +vad | what +över | over +än | than +dig | you +kan | can +sina | his +här | here +ha | have +mot | towards +alla | all +under | under (also: wonder) +någon | some etc +eller | or (else) +allt | all +mycket | much +sedan | since +ju | why +denna | this/that +själv | myself, yourself etc +detta | this/that +åt | to +utan | without +varit | was +hur | how +ingen | no +mitt | my +ni | you +bli | to be, become +blev | from bli +oss | us +din | thy +dessa | these/those +några | some etc +deras | their +blir | from bli +mina | my +samma | (the) same +vilken | who, that +er | you, your +sådan | such a +vår | our +blivit | from bli +dess | its +inom | within +mellan | between +sådant | such a +varför | why +varje | each +vilka | who, that +ditt | thy +vem | who +vilket | who, that +sitta | his +sådana | such a +vart | each +dina | thy +vars | whose +vårt | our +våra | our +ert | your +era | your +vilkas | whose + diff --git a/resources/cache/empty/entity/conf/lang/stopwords_th.txt b/resources/cache/empty/entity/conf/lang/stopwords_th.txt index 1415edf9..07f0fabe 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_th.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_th.txt @@ -1,119 +1,119 @@ -# Thai stopwords from: -# "Opinion Detection in Thai Political News Columns -# Based on Subjectivity Analysis" -# Khampol Sukhum, Supot Nitsuwat, and Choochart Haruechaiyasak -ไว้ -ไม่ -ไป -ได้ -ให้ -ใน -โดย -แห่ง -แล้ว -และ -แรก -แบบ -แต่ -เอง -เห็น -เลย -เริ่ม -เรา -เมื่อ -เพื่อ -เพราะ -เป็นการ -เป็น -เปิดเผย -เปิด -เนื่องจาก -เดียวกัน -เดียว -เช่น -เฉพาะ -เคย -เข้า -เขา -อีก -อาจ -อะไร -ออก -อย่าง -อยู่ -อยาก -หาก -หลาย -หลังจาก -หลัง -หรือ -หนึ่ง -ส่วน -ส่ง -สุด -สําหรับ -ว่า -วัน -ลง -ร่วม -ราย -รับ -ระหว่าง -รวม -ยัง -มี -มาก -มา -พร้อม -พบ -ผ่าน -ผล -บาง -น่า -นี้ -นํา -นั้น -นัก -นอกจาก -ทุก -ที่สุด -ที่ -ทําให้ -ทํา -ทาง -ทั้งนี้ -ทั้ง -ถ้า -ถูก -ถึง -ต้อง -ต่างๆ -ต่าง -ต่อ -ตาม -ตั้งแต่ -ตั้ง -ด้าน -ด้วย -ดัง -ซึ่ง -ช่วง -จึง -จาก -จัด -จะ -คือ -ความ -ครั้ง -คง -ขึ้น -ของ -ขอ -ขณะ -ก่อน -ก็ -การ -กับ -กัน -กว่า -กล่าว +# Thai stopwords from: +# "Opinion Detection in Thai Political News Columns +# Based on Subjectivity Analysis" +# Khampol Sukhum, Supot Nitsuwat, and Choochart Haruechaiyasak +ไว้ +ไม่ +ไป +ได้ +ให้ +ใน +โดย +แห่ง +แล้ว +และ +แรก +แบบ +แต่ +เอง +เห็น +เลย +เริ่ม +เรา +เมื่อ +เพื่อ +เพราะ +เป็นการ +เป็น +เปิดเผย +เปิด +เนื่องจาก +เดียวกัน +เดียว +เช่น +เฉพาะ +เคย +เข้า +เขา +อีก +อาจ +อะไร +ออก +อย่าง +อยู่ +อยาก +หาก +หลาย +หลังจาก +หลัง +หรือ +หนึ่ง +ส่วน +ส่ง +สุด +สําหรับ +ว่า +วัน +ลง +ร่วม +ราย +รับ +ระหว่าง +รวม +ยัง +มี +มาก +มา +พร้อม +พบ +ผ่าน +ผล +บาง +น่า +นี้ +นํา +นั้น +นัก +นอกจาก +ทุก +ที่สุด +ที่ +ทําให้ +ทํา +ทาง +ทั้งนี้ +ทั้ง +ถ้า +ถูก +ถึง +ต้อง +ต่างๆ +ต่าง +ต่อ +ตาม +ตั้งแต่ +ตั้ง +ด้าน +ด้วย +ดัง +ซึ่ง +ช่วง +จึง +จาก +จัด +จะ +คือ +ความ +ครั้ง +คง +ขึ้น +ของ +ขอ +ขณะ +ก่อน +ก็ +การ +กับ +กัน +กว่า +กล่าว diff --git a/resources/cache/empty/entity/conf/lang/stopwords_tr.txt b/resources/cache/empty/entity/conf/lang/stopwords_tr.txt index fe4083b7..84d9408d 100644 --- a/resources/cache/empty/entity/conf/lang/stopwords_tr.txt +++ b/resources/cache/empty/entity/conf/lang/stopwords_tr.txt @@ -1,212 +1,212 @@ -# Turkish stopwords from LUCENE-559 -# merged with the list from "Information Retrieval on Turkish Texts" -# (http://www.users.muohio.edu/canf/papers/JASIST2008offPrint.pdf) -acaba -altmış -altı -ama -ancak -arada -aslında -ayrıca -bana -bazı -belki -ben -benden -beni -benim -beri -beş -bile -bin -bir -birçok -biri -birkaç -birkez -birşey -birşeyi -biz -bize -bizden -bizi -bizim -böyle -böylece -bu -buna -bunda -bundan -bunlar -bunları -bunların -bunu -bunun -burada -çok -çünkü -da -daha -dahi -de -defa -değil -diğer -diye -doksan -dokuz -dolayı -dolayısıyla -dört -edecek -eden -ederek -edilecek -ediliyor -edilmesi -ediyor -eğer -elli -en -etmesi -etti -ettiği -ettiğini -gibi -göre -halen -hangi -hatta -hem -henüz -hep -hepsi -her -herhangi -herkesin -hiç -hiçbir -için -iki -ile -ilgili -ise -işte -itibaren -itibariyle -kadar -karşın -katrilyon -kendi -kendilerine -kendini -kendisi -kendisine -kendisini -kez -ki -kim -kimden -kime -kimi -kimse -kırk -milyar -milyon -mu -mü -mı -nasıl -ne -neden -nedenle -nerde -nerede -nereye -niye -niçin -o -olan -olarak -oldu -olduğu -olduğunu -olduklarını -olmadı -olmadığı -olmak -olması -olmayan -olmaz -olsa -olsun -olup -olur -olursa -oluyor -on -ona -ondan -onlar -onlardan -onları -onların -onu -onun -otuz -oysa -öyle -pek -rağmen -sadece -sanki -sekiz -seksen -sen -senden -seni -senin -siz -sizden -sizi -sizin -şey -şeyden -şeyi -şeyler -şöyle -şu -şuna -şunda -şundan -şunları -şunu -tarafından -trilyon -tüm -üç -üzere -var -vardı -ve -veya -ya -yani -yapacak -yapılan -yapılması -yapıyor -yapmak -yaptı -yaptığı -yaptığını -yaptıkları -yedi -yerine -yetmiş -yine -yirmi -yoksa -yüz -zaten +# Turkish stopwords from LUCENE-559 +# merged with the list from "Information Retrieval on Turkish Texts" +# (http://www.users.muohio.edu/canf/papers/JASIST2008offPrint.pdf) +acaba +altmış +altı +ama +ancak +arada +aslında +ayrıca +bana +bazı +belki +ben +benden +beni +benim +beri +beş +bile +bin +bir +birçok +biri +birkaç +birkez +birşey +birşeyi +biz +bize +bizden +bizi +bizim +böyle +böylece +bu +buna +bunda +bundan +bunlar +bunları +bunların +bunu +bunun +burada +çok +çünkü +da +daha +dahi +de +defa +değil +diğer +diye +doksan +dokuz +dolayı +dolayısıyla +dört +edecek +eden +ederek +edilecek +ediliyor +edilmesi +ediyor +eğer +elli +en +etmesi +etti +ettiği +ettiğini +gibi +göre +halen +hangi +hatta +hem +henüz +hep +hepsi +her +herhangi +herkesin +hiç +hiçbir +için +iki +ile +ilgili +ise +işte +itibaren +itibariyle +kadar +karşın +katrilyon +kendi +kendilerine +kendini +kendisi +kendisine +kendisini +kez +ki +kim +kimden +kime +kimi +kimse +kırk +milyar +milyon +mu +mü +mı +nasıl +ne +neden +nedenle +nerde +nerede +nereye +niye +niçin +o +olan +olarak +oldu +olduğu +olduğunu +olduklarını +olmadı +olmadığı +olmak +olması +olmayan +olmaz +olsa +olsun +olup +olur +olursa +oluyor +on +ona +ondan +onlar +onlardan +onları +onların +onu +onun +otuz +oysa +öyle +pek +rağmen +sadece +sanki +sekiz +seksen +sen +senden +seni +senin +siz +sizden +sizi +sizin +şey +şeyden +şeyi +şeyler +şöyle +şu +şuna +şunda +şundan +şunları +şunu +tarafından +trilyon +tüm +üç +üzere +var +vardı +ve +veya +ya +yani +yapacak +yapılan +yapılması +yapıyor +yapmak +yaptı +yaptığı +yaptığını +yaptıkları +yedi +yerine +yetmiş +yine +yirmi +yoksa +yüz +zaten diff --git a/resources/cache/empty/entity/conf/lang/userdict_ja.txt b/resources/cache/empty/entity/conf/lang/userdict_ja.txt index c79de826..6f0368e4 100644 --- a/resources/cache/empty/entity/conf/lang/userdict_ja.txt +++ b/resources/cache/empty/entity/conf/lang/userdict_ja.txt @@ -1,29 +1,29 @@ -# -# This is a sample user dictionary for Kuromoji (JapaneseTokenizer) -# -# Add entries to this file in order to override the statistical model in terms -# of segmentation, readings and part-of-speech tags. Notice that entries do -# not have weights since they are always used when found. This is by-design -# in order to maximize ease-of-use. -# -# Entries are defined using the following CSV format: -# , ... , ... , -# -# Notice that a single half-width space separates tokens and readings, and -# that the number tokens and readings must match exactly. -# -# Also notice that multiple entries with the same is undefined. -# -# Whitespace only lines are ignored. Comments are not allowed on entry lines. -# - -# Custom segmentation for kanji compounds -日本経済新聞,日本 経済 新聞,ニホン ケイザイ シンブン,カスタム名詞 -関西国際空港,関西 国際 空港,カンサイ コクサイ クウコウ,カスタム名詞 - -# Custom segmentation for compound katakana -トートバッグ,トート バッグ,トート バッグ,かずカナ名詞 -ショルダーバッグ,ショルダー バッグ,ショルダー バッグ,かずカナ名詞 - -# Custom reading for former sumo wrestler -朝青龍,朝青龍,アサショウリュウ,カスタム人名 +# +# This is a sample user dictionary for Kuromoji (JapaneseTokenizer) +# +# Add entries to this file in order to override the statistical model in terms +# of segmentation, readings and part-of-speech tags. Notice that entries do +# not have weights since they are always used when found. This is by-design +# in order to maximize ease-of-use. +# +# Entries are defined using the following CSV format: +# , ... , ... , +# +# Notice that a single half-width space separates tokens and readings, and +# that the number tokens and readings must match exactly. +# +# Also notice that multiple entries with the same is undefined. +# +# Whitespace only lines are ignored. Comments are not allowed on entry lines. +# + +# Custom segmentation for kanji compounds +日本経済新聞,日本 経済 新聞,ニホン ケイザイ シンブン,カスタム名詞 +関西国際空港,関西 国際 空港,カンサイ コクサイ クウコウ,カスタム名詞 + +# Custom segmentation for compound katakana +トートバッグ,トート バッグ,トート バッグ,かずカナ名詞 +ショルダーバッグ,ショルダー バッグ,ショルダー バッグ,かずカナ名詞 + +# Custom reading for former sumo wrestler +朝青龍,朝青龍,アサショウリュウ,カスタム人名 diff --git a/resources/cache/empty/entity/conf/params.json b/resources/cache/empty/entity/conf/params.json index abf4154e..9c259db5 100644 --- a/resources/cache/empty/entity/conf/params.json +++ b/resources/cache/empty/entity/conf/params.json @@ -1,20 +1,20 @@ -{"params":{ - "query":{ - "defType":"edismax", - "q.alt":"*:*", - "rows":"10", - "fl":"*,score", - "":{"v":0} - }, - "facets":{ - "facet":"on", - "facet.mincount": "1", - "":{"v":0} - }, - "velocity":{ - "wt": "velocity", - "v.template":"browse", - "v.layout": "layout", - "":{"v":0} - } -}} +{"params":{ + "query":{ + "defType":"edismax", + "q.alt":"*:*", + "rows":"10", + "fl":"*,score", + "":{"v":0} + }, + "facets":{ + "facet":"on", + "facet.mincount": "1", + "":{"v":0} + }, + "velocity":{ + "wt": "velocity", + "v.template":"browse", + "v.layout": "layout", + "":{"v":0} + } +}} diff --git a/resources/cache/empty/entity/conf/protwords.txt b/resources/cache/empty/entity/conf/protwords.txt index 5a32e503..1dfc0abe 100644 --- a/resources/cache/empty/entity/conf/protwords.txt +++ b/resources/cache/empty/entity/conf/protwords.txt @@ -1,21 +1,21 @@ -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#----------------------------------------------------------------------- -# Use a protected word file to protect against the stemmer reducing two -# unrelated words to the same base word. - -# Some non-words that normally won't be encountered, -# just to test that they won't be stemmed. -dontstems -zwhacky - +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#----------------------------------------------------------------------- +# Use a protected word file to protect against the stemmer reducing two +# unrelated words to the same base word. + +# Some non-words that normally won't be encountered, +# just to test that they won't be stemmed. +dontstems +zwhacky + diff --git a/resources/cache/empty/entity/conf/schema.xml b/resources/cache/empty/entity/conf/schema.xml index c5ae42b5..5e67b616 100644 --- a/resources/cache/empty/entity/conf/schema.xml +++ b/resources/cache/empty/entity/conf/schema.xml @@ -1,240 +1,240 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - id - - id - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id + + id + + + diff --git a/resources/cache/empty/entity/conf/solrconfig.xml b/resources/cache/empty/entity/conf/solrconfig.xml index 7e8babdf..a99f9628 100644 --- a/resources/cache/empty/entity/conf/solrconfig.xml +++ b/resources/cache/empty/entity/conf/solrconfig.xml @@ -1,1949 +1,1949 @@ - - - - - - - - - 4.10.4 - - - - - - - - - - - - - - - - - - - - - - ${solr.data.dir:} - - - - - - - - - ${solr.hdfs.home:} - - ${solr.hdfs.confdir:} - - ${solr.hdfs.blockcache.enabled:true} - - ${solr.hdfs.blockcache.global:true} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${solr.lock.type:native} - - - - - - - - - - - - - - - - - - - - - - true - - - false - - - - - - - - - - - - - - - - ${solr.ulog.dir:} - - - - - ${solr.autoCommit.maxTime:15000} - false - - - - - - ${solr.autoSoftCommit.maxTime:-1} - - - - - - - - - - - - - - - - - - 1024 - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - 20 - - - 200 - - - - - - - - - - - - static firstSearcher warming in solrconfig.xml - - - - - - false - - - 2 - - - - - - - - - - - - - - - - - - - - - - - explicit - 10 - text - - - - - - - - - - on - content features title name - true - html - <b> - </b> - 0 - title - - 3 - 200 - content - 750 - - - on - false - 5 - 2 - 5 - true - true - 5 - 3 - - - - - - explicit - json - true - text - - - - - - - - true - json - true - - - - - - - - {!xport} - xsort - false - - - - query - - - - - - - - - - - - explicit - - - velocity - browse - layout - Solritas - - - edismax - - text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 - title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0 - - text - 100% - *:* - 10 - *,score - - - text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 - title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0 - - text,features,name,sku,id,manu,cat,title,description,keywords,author,resourcename - 3 - - - on - true - cat - person - location - organisations - ipod - GB - 1 - cat,inStock - after - price - 0 - 600 - 50 - popularity - 0 - 10 - 3 - manufacturedate_dt - NOW/YEAR-10YEARS - NOW - +1YEAR - before - after - - - on - content features title name - true - html - <b> - </b> - 0 - title - - 3 - 200 - content - 750 - - - on - false - 5 - 2 - 5 - true - true - 5 - 3 - - - - - spellcheck - - - - - - - - - - - - - - - - last_modified - true - - ignored_ - - - true - links - jate_text_field - true - ignored_ - - - langid - - - - - - yyyy-MM-dd hh:mm:ss - - - - - - - - - - - - - - - - - - - - - - solrpingquery - - - all - - - - - - - - - explicit - true - - - - - - - - - - - - - - - - text_general - - - - - - default - text - solr.DirectSolrSpellChecker - - internal - - 0.5 - - 2 - - 1 - - 5 - - 4 - - 0.01 - - - - - - wordbreak - solr.WordBreakSolrSpellChecker - name - true - true - 10 - - - - - - - - - - - - - - - - text - - default - wordbreak - on - true - 10 - 5 - 5 - true - true - 10 - 5 - - - spellcheck - - - - - - - - - - - - text - true - - - tvComponent - - - - - - - lingo - - - org.carrot2.clustering.lingo.LingoClusteringAlgorithm - - - clustering/carrot2 - - - - - stc - org.carrot2.clustering.stc.STCClusteringAlgorithm - - - - - kmeans - org.carrot2.clustering.kmeans.BisectingKMeansClusteringAlgorithm - - - - - - - true - true - - name - - id - - features - - true - - - - false - - - edismax - - text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 - - *:* - 10 - *,score - - - clustering - - - - - - - - - - true - false - - - terms - - - - - - - - string - elevate.xml - - - - - - explicit - text - - - elevator - - - - - - - - - - - 100 - - - - - - - - 70 - - 0.5 - - [-\w ,/\n\"']{20,200} - - - - - - - ]]> - ]]> - - - - - - - - - - - - - - - - - - - - - - - - ,, - ,, - ,, - ,, - ,]]> - ]]> - - - - - - 10 - .,!? - - - - - - - WORD - - - en - US - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/plain; charset=UTF-8 - - - - - - - - - 5 - - - - - - - - - - - - - - - - - - *:* - - - + + + + + + + + + 4.10.4 + + + + + + + + + + + + + + + + + + + + + + ${solr.data.dir:} + + + + + + + + + ${solr.hdfs.home:} + + ${solr.hdfs.confdir:} + + ${solr.hdfs.blockcache.enabled:true} + + ${solr.hdfs.blockcache.global:true} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${solr.lock.type:native} + + + + + + + + + + + + + + + + + + + + + + true + + + false + + + + + + + + + + + + + + + + ${solr.ulog.dir:} + + + + + ${solr.autoCommit.maxTime:15000} + false + + + + + + ${solr.autoSoftCommit.maxTime:-1} + + + + + + + + + + + + + + + + + + 1024 + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + 20 + + + 200 + + + + + + + + + + + + static firstSearcher warming in solrconfig.xml + + + + + + false + + + 2 + + + + + + + + + + + + + + + + + + + + + + + explicit + 10 + text + + + + + + + + + + on + content features title name + true + html + <b> + </b> + 0 + title + + 3 + 200 + content + 750 + + + on + false + 5 + 2 + 5 + true + true + 5 + 3 + + + + + + explicit + json + true + text + + + + + + + + true + json + true + + + + + + + + {!xport} + xsort + false + + + + query + + + + + + + + + + + + explicit + + + velocity + browse + layout + Solritas + + + edismax + + text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 + title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0 + + text + 100% + *:* + 10 + *,score + + + text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 + title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0 + + text,features,name,sku,id,manu,cat,title,description,keywords,author,resourcename + 3 + + + on + true + cat + person + location + organisations + ipod + GB + 1 + cat,inStock + after + price + 0 + 600 + 50 + popularity + 0 + 10 + 3 + manufacturedate_dt + NOW/YEAR-10YEARS + NOW + +1YEAR + before + after + + + on + content features title name + true + html + <b> + </b> + 0 + title + + 3 + 200 + content + 750 + + + on + false + 5 + 2 + 5 + true + true + 5 + 3 + + + + + spellcheck + + + + + + + + + + + + + + + + last_modified + true + + ignored_ + + + true + links + jate_text_field + true + ignored_ + + + langid + + + + + + yyyy-MM-dd hh:mm:ss + + + + + + + + + + + + + + + + + + + + + + solrpingquery + + + all + + + + + + + + + explicit + true + + + + + + + + + + + + + + + + text_general + + + + + + default + text + solr.DirectSolrSpellChecker + + internal + + 0.5 + + 2 + + 1 + + 5 + + 4 + + 0.01 + + + + + + wordbreak + solr.WordBreakSolrSpellChecker + name + true + true + 10 + + + + + + + + + + + + + + + + text + + default + wordbreak + on + true + 10 + 5 + 5 + true + true + 10 + 5 + + + spellcheck + + + + + + + + + + + + text + true + + + tvComponent + + + + + + + lingo + + + org.carrot2.clustering.lingo.LingoClusteringAlgorithm + + + clustering/carrot2 + + + + + stc + org.carrot2.clustering.stc.STCClusteringAlgorithm + + + + + kmeans + org.carrot2.clustering.kmeans.BisectingKMeansClusteringAlgorithm + + + + + + + true + true + + name + + id + + features + + true + + + + false + + + edismax + + text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 + + *:* + 10 + *,score + + + clustering + + + + + + + + + + true + false + + + terms + + + + + + + + string + elevate.xml + + + + + + explicit + text + + + elevator + + + + + + + + + + + 100 + + + + + + + + 70 + + 0.5 + + [-\w ,/\n\"']{20,200} + + + + + + + ]]> + ]]> + + + + + + + + + + + + + + + + + + + + + + + + ,, + ,, + ,, + ,, + ,]]> + ]]> + + + + + + 10 + .,!? + + + + + + + WORD + + + en + US + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/plain; charset=UTF-8 + + + + + + + + + 5 + + + + + + + + + + + + + + + + + + *:* + + + diff --git a/resources/cache/empty/entity/conf/stopwords.txt b/resources/cache/empty/entity/conf/stopwords.txt index e525ab80..dacec479 100644 --- a/resources/cache/empty/entity/conf/stopwords.txt +++ b/resources/cache/empty/entity/conf/stopwords.txt @@ -1,188 +1,188 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -a -about -above -after -again -against -all -am -an -and -any -are -aren't -as -at -be -because -been -before -being -below -between -both -but -by -can't -cannot -could -couldn't -did -didn't -do -does -doesn't -doing -don't -down -during -each -few -for -from -further -had -hadn't -has -hasn't -have -haven't -having -he -he'd -he'll -he's -her -here -here's -hers -herself -him -himself -his -how -how's -i -i'd -i'll -i'm -i've -if -in -into -is -isn't -it -it's -its -itself -let's -me -more -most -mustn't -my -myself -no -nor -not -of -off -on -once -only -or -other -ought -our -ours -ourselves -out -over -own -same -shan't -she -she'd -she'll -she's -should -shouldn't -so -some -such -than -that -that's -the -their -theirs -them -themselves -then -there -there's -these -they -they'd -they'll -they're -they've -this -those -through -to -too -under -until -up -very -was -wasn't -we -we'd -we'll -we're -we've -were -weren't -what -what's -when -when's -where -where's -which -while -who -who's -whom -why -why's -with -won't -would -wouldn't -you -you'd -you'll -you're -you've -your -yours -yourself +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +a +about +above +after +again +against +all +am +an +and +any +are +aren't +as +at +be +because +been +before +being +below +between +both +but +by +can't +cannot +could +couldn't +did +didn't +do +does +doesn't +doing +don't +down +during +each +few +for +from +further +had +hadn't +has +hasn't +have +haven't +having +he +he'd +he'll +he's +her +here +here's +hers +herself +him +himself +his +how +how's +i +i'd +i'll +i'm +i've +if +in +into +is +isn't +it +it's +its +itself +let's +me +more +most +mustn't +my +myself +no +nor +not +of +off +on +once +only +or +other +ought +our +ours +ourselves +out +over +own +same +shan't +she +she'd +she'll +she's +should +shouldn't +so +some +such +than +that +that's +the +their +theirs +them +themselves +then +there +there's +these +they +they'd +they'll +they're +they've +this +those +through +to +too +under +until +up +very +was +wasn't +we +we'd +we'll +we're +we've +were +weren't +what +what's +when +when's +where +where's +which +while +who +who's +whom +why +why's +with +won't +would +wouldn't +you +you'd +you'll +you're +you've +your +yours +yourself yourselves \ No newline at end of file diff --git a/resources/cache/empty/entity/conf/synonyms.txt b/resources/cache/empty/entity/conf/synonyms.txt index f00294b0..7f721283 100644 --- a/resources/cache/empty/entity/conf/synonyms.txt +++ b/resources/cache/empty/entity/conf/synonyms.txt @@ -1,29 +1,29 @@ -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#----------------------------------------------------------------------- -#some test synonym mappings unlikely to appear in real input text -aaafoo => aaabar -bbbfoo => bbbfoo bbbbar -cccfoo => cccbar cccbaz -fooaaa,baraaa,bazaaa - -# Some synonym groups specific to this example -GB,gib,gigabyte,gigabytes -MB,mib,megabyte,megabytes -Television, Televisions, TV, TVs -#notice we use "gib" instead of "GiB" so any WordDelimiterFilter coming -#after us won't split it into two words. - -# Synonym mappings can be used for spelling correction too -pixima => pixma - +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#----------------------------------------------------------------------- +#some test synonym mappings unlikely to appear in real input text +aaafoo => aaabar +bbbfoo => bbbfoo bbbbar +cccfoo => cccbar cccbaz +fooaaa,baraaa,bazaaa + +# Some synonym groups specific to this example +GB,gib,gigabyte,gigabytes +MB,mib,megabyte,megabytes +Television, Televisions, TV, TVs +#notice we use "gib" instead of "GiB" so any WordDelimiterFilter coming +#after us won't split it into two words. + +# Synonym mappings can be used for spelling correction too +pixima => pixma + diff --git a/resources/cache/empty/entity/core.properties b/resources/cache/empty/entity/core.properties index d9d0f10f..640bcd28 100644 --- a/resources/cache/empty/entity/core.properties +++ b/resources/cache/empty/entity/core.properties @@ -1,3 +1,3 @@ -#Written by CorePropertiesLocator -#Mon Sep 14 10:05:54 UTC 2015 -name=entity +#Written by CorePropertiesLocator +#Mon Sep 14 10:05:54 UTC 2015 +name=entity diff --git a/resources/cache/empty/relation/conf/currency.xml b/resources/cache/empty/relation/conf/currency.xml index 5c6cfaf0..3a9c58af 100644 --- a/resources/cache/empty/relation/conf/currency.xml +++ b/resources/cache/empty/relation/conf/currency.xml @@ -1,67 +1,67 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/cache/empty/relation/conf/elevate.xml b/resources/cache/empty/relation/conf/elevate.xml index e4769ccf..25d5cebe 100644 --- a/resources/cache/empty/relation/conf/elevate.xml +++ b/resources/cache/empty/relation/conf/elevate.xml @@ -1,38 +1,38 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/resources/cache/empty/relation/conf/lang/contractions_ca.txt b/resources/cache/empty/relation/conf/lang/contractions_ca.txt index 116644f2..307a85f9 100644 --- a/resources/cache/empty/relation/conf/lang/contractions_ca.txt +++ b/resources/cache/empty/relation/conf/lang/contractions_ca.txt @@ -1,8 +1,8 @@ -# Set of Catalan contractions for ElisionFilter -# TODO: load this as a resource from the analyzer and sync it in build.xml -d -l -m -n -s -t +# Set of Catalan contractions for ElisionFilter +# TODO: load this as a resource from the analyzer and sync it in build.xml +d +l +m +n +s +t diff --git a/resources/cache/empty/relation/conf/lang/contractions_fr.txt b/resources/cache/empty/relation/conf/lang/contractions_fr.txt index 6de73c27..f1bba51b 100644 --- a/resources/cache/empty/relation/conf/lang/contractions_fr.txt +++ b/resources/cache/empty/relation/conf/lang/contractions_fr.txt @@ -1,15 +1,15 @@ -# Set of French contractions for ElisionFilter -# TODO: load this as a resource from the analyzer and sync it in build.xml -l -m -t -qu -n -s -j -d -c -jusqu -quoiqu -lorsqu -puisqu +# Set of French contractions for ElisionFilter +# TODO: load this as a resource from the analyzer and sync it in build.xml +l +m +t +qu +n +s +j +d +c +jusqu +quoiqu +lorsqu +puisqu diff --git a/resources/cache/empty/relation/conf/lang/contractions_ga.txt b/resources/cache/empty/relation/conf/lang/contractions_ga.txt index 849b0c6e..9ebe7fa3 100644 --- a/resources/cache/empty/relation/conf/lang/contractions_ga.txt +++ b/resources/cache/empty/relation/conf/lang/contractions_ga.txt @@ -1,5 +1,5 @@ -# Set of Irish contractions for ElisionFilter -# TODO: load this as a resource from the analyzer and sync it in build.xml -d -m -b +# Set of Irish contractions for ElisionFilter +# TODO: load this as a resource from the analyzer and sync it in build.xml +d +m +b diff --git a/resources/cache/empty/relation/conf/lang/contractions_it.txt b/resources/cache/empty/relation/conf/lang/contractions_it.txt index 790b5af4..cac04095 100644 --- a/resources/cache/empty/relation/conf/lang/contractions_it.txt +++ b/resources/cache/empty/relation/conf/lang/contractions_it.txt @@ -1,23 +1,23 @@ -# Set of Italian contractions for ElisionFilter -# TODO: load this as a resource from the analyzer and sync it in build.xml -c -l -all -dall -dell -nell -sull -coll -pell -gl -agl -dagl -degl -negl -sugl -un -m -t -s -v -d +# Set of Italian contractions for ElisionFilter +# TODO: load this as a resource from the analyzer and sync it in build.xml +c +l +all +dall +dell +nell +sull +coll +pell +gl +agl +dagl +degl +negl +sugl +un +m +t +s +v +d diff --git a/resources/cache/empty/relation/conf/lang/hyphenations_ga.txt b/resources/cache/empty/relation/conf/lang/hyphenations_ga.txt index fce41006..4d2642cc 100644 --- a/resources/cache/empty/relation/conf/lang/hyphenations_ga.txt +++ b/resources/cache/empty/relation/conf/lang/hyphenations_ga.txt @@ -1,5 +1,5 @@ -# Set of Irish hyphenations for StopFilter -# TODO: load this as a resource from the analyzer and sync it in build.xml -h -n -t +# Set of Irish hyphenations for StopFilter +# TODO: load this as a resource from the analyzer and sync it in build.xml +h +n +t diff --git a/resources/cache/empty/relation/conf/lang/stemdict_nl.txt b/resources/cache/empty/relation/conf/lang/stemdict_nl.txt index 01dd3bb8..44107297 100644 --- a/resources/cache/empty/relation/conf/lang/stemdict_nl.txt +++ b/resources/cache/empty/relation/conf/lang/stemdict_nl.txt @@ -1,6 +1,6 @@ -# Set of overrides for the dutch stemmer -# TODO: load this as a resource from the analyzer and sync it in build.xml -fiets fiets -bromfiets bromfiets -ei eier -kind kinder +# Set of overrides for the dutch stemmer +# TODO: load this as a resource from the analyzer and sync it in build.xml +fiets fiets +bromfiets bromfiets +ei eier +kind kinder diff --git a/resources/cache/empty/relation/conf/lang/stoptags_ja.txt b/resources/cache/empty/relation/conf/lang/stoptags_ja.txt index 2faf2a68..71b75084 100644 --- a/resources/cache/empty/relation/conf/lang/stoptags_ja.txt +++ b/resources/cache/empty/relation/conf/lang/stoptags_ja.txt @@ -1,420 +1,420 @@ -# -# This file defines a Japanese stoptag set for JapanesePartOfSpeechStopFilter. -# -# Any token with a part-of-speech tag that exactly matches those defined in this -# file are removed from the token stream. -# -# Set your own stoptags by uncommenting the lines below. Note that comments are -# not allowed on the same line as a stoptag. See LUCENE-3745 for frequency lists, -# etc. that can be useful for building you own stoptag set. -# -# The entire possible tagset is provided below for convenience. -# -##### -# noun: unclassified nouns -#名詞 -# -# noun-common: Common nouns or nouns where the sub-classification is undefined -#名詞-一般 -# -# noun-proper: Proper nouns where the sub-classification is undefined -#名詞-固有名詞 -# -# noun-proper-misc: miscellaneous proper nouns -#名詞-固有名詞-一般 -# -# noun-proper-person: Personal names where the sub-classification is undefined -#名詞-固有名詞-人名 -# -# noun-proper-person-misc: names that cannot be divided into surname and -# given name; foreign names; names where the surname or given name is unknown. -# e.g. お市の方 -#名詞-固有名詞-人名-一般 -# -# noun-proper-person-surname: Mainly Japanese surnames. -# e.g. 山田 -#名詞-固有名詞-人名-姓 -# -# noun-proper-person-given_name: Mainly Japanese given names. -# e.g. 太郎 -#名詞-固有名詞-人名-名 -# -# noun-proper-organization: Names representing organizations. -# e.g. 通産省, NHK -#名詞-固有名詞-組織 -# -# noun-proper-place: Place names where the sub-classification is undefined -#名詞-固有名詞-地域 -# -# noun-proper-place-misc: Place names excluding countries. -# e.g. アジア, バルセロナ, 京都 -#名詞-固有名詞-地域-一般 -# -# noun-proper-place-country: Country names. -# e.g. 日本, オーストラリア -#名詞-固有名詞-地域-国 -# -# noun-pronoun: Pronouns where the sub-classification is undefined -#名詞-代名詞 -# -# noun-pronoun-misc: miscellaneous pronouns: -# e.g. それ, ここ, あいつ, あなた, あちこち, いくつ, どこか, なに, みなさん, みんな, わたくし, われわれ -#名詞-代名詞-一般 -# -# noun-pronoun-contraction: Spoken language contraction made by combining a -# pronoun and the particle 'wa'. -# e.g. ありゃ, こりゃ, こりゃあ, そりゃ, そりゃあ -#名詞-代名詞-縮約 -# -# noun-adverbial: Temporal nouns such as names of days or months that behave -# like adverbs. Nouns that represent amount or ratios and can be used adverbially, -# e.g. 金曜, 一月, 午後, 少量 -#名詞-副詞可能 -# -# noun-verbal: Nouns that take arguments with case and can appear followed by -# 'suru' and related verbs (する, できる, なさる, くださる) -# e.g. インプット, 愛着, 悪化, 悪戦苦闘, 一安心, 下取り -#名詞-サ変接続 -# -# noun-adjective-base: The base form of adjectives, words that appear before な ("na") -# e.g. 健康, 安易, 駄目, だめ -#名詞-形容動詞語幹 -# -# noun-numeric: Arabic numbers, Chinese numerals, and counters like 何 (回), 数. -# e.g. 0, 1, 2, 何, 数, 幾 -#名詞-数 -# -# noun-affix: noun affixes where the sub-classification is undefined -#名詞-非自立 -# -# noun-affix-misc: Of adnominalizers, the case-marker の ("no"), and words that -# attach to the base form of inflectional words, words that cannot be classified -# into any of the other categories below. This category includes indefinite nouns. -# e.g. あかつき, 暁, かい, 甲斐, 気, きらい, 嫌い, くせ, 癖, こと, 事, ごと, 毎, しだい, 次第, -# 順, せい, 所為, ついで, 序で, つもり, 積もり, 点, どころ, の, はず, 筈, はずみ, 弾み, -# 拍子, ふう, ふり, 振り, ほう, 方, 旨, もの, 物, 者, ゆえ, 故, ゆえん, 所以, わけ, 訳, -# わり, 割り, 割, ん-口語/, もん-口語/ -#名詞-非自立-一般 -# -# noun-affix-adverbial: noun affixes that that can behave as adverbs. -# e.g. あいだ, 間, あげく, 挙げ句, あと, 後, 余り, 以外, 以降, 以後, 以上, 以前, 一方, うえ, -# 上, うち, 内, おり, 折り, かぎり, 限り, きり, っきり, 結果, ころ, 頃, さい, 際, 最中, さなか, -# 最中, じたい, 自体, たび, 度, ため, 為, つど, 都度, とおり, 通り, とき, 時, ところ, 所, -# とたん, 途端, なか, 中, のち, 後, ばあい, 場合, 日, ぶん, 分, ほか, 他, まえ, 前, まま, -# 儘, 侭, みぎり, 矢先 -#名詞-非自立-副詞可能 -# -# noun-affix-aux: noun affixes treated as 助動詞 ("auxiliary verb") in school grammars -# with the stem よう(だ) ("you(da)"). -# e.g. よう, やう, 様 (よう) -#名詞-非自立-助動詞語幹 -# -# noun-affix-adjective-base: noun affixes that can connect to the indeclinable -# connection form な (aux "da"). -# e.g. みたい, ふう -#名詞-非自立-形容動詞語幹 -# -# noun-special: special nouns where the sub-classification is undefined. -#名詞-特殊 -# -# noun-special-aux: The そうだ ("souda") stem form that is used for reporting news, is -# treated as 助動詞 ("auxiliary verb") in school grammars, and attach to the base -# form of inflectional words. -# e.g. そう -#名詞-特殊-助動詞語幹 -# -# noun-suffix: noun suffixes where the sub-classification is undefined. -#名詞-接尾 -# -# noun-suffix-misc: Of the nouns or stem forms of other parts of speech that connect -# to ガル or タイ and can combine into compound nouns, words that cannot be classified into -# any of the other categories below. In general, this category is more inclusive than -# 接尾語 ("suffix") and is usually the last element in a compound noun. -# e.g. おき, かた, 方, 甲斐 (がい), がかり, ぎみ, 気味, ぐるみ, (~した) さ, 次第, 済 (ず) み, -# よう, (でき)っこ, 感, 観, 性, 学, 類, 面, 用 -#名詞-接尾-一般 -# -# noun-suffix-person: Suffixes that form nouns and attach to person names more often -# than other nouns. -# e.g. 君, 様, 著 -#名詞-接尾-人名 -# -# noun-suffix-place: Suffixes that form nouns and attach to place names more often -# than other nouns. -# e.g. 町, 市, 県 -#名詞-接尾-地域 -# -# noun-suffix-verbal: Of the suffixes that attach to nouns and form nouns, those that -# can appear before スル ("suru"). -# e.g. 化, 視, 分け, 入り, 落ち, 買い -#名詞-接尾-サ変接続 -# -# noun-suffix-aux: The stem form of そうだ (様態) that is used to indicate conditions, -# is treated as 助動詞 ("auxiliary verb") in school grammars, and attach to the -# conjunctive form of inflectional words. -# e.g. そう -#名詞-接尾-助動詞語幹 -# -# noun-suffix-adjective-base: Suffixes that attach to other nouns or the conjunctive -# form of inflectional words and appear before the copula だ ("da"). -# e.g. 的, げ, がち -#名詞-接尾-形容動詞語幹 -# -# noun-suffix-adverbial: Suffixes that attach to other nouns and can behave as adverbs. -# e.g. 後 (ご), 以後, 以降, 以前, 前後, 中, 末, 上, 時 (じ) -#名詞-接尾-副詞可能 -# -# noun-suffix-classifier: Suffixes that attach to numbers and form nouns. This category -# is more inclusive than 助数詞 ("classifier") and includes common nouns that attach -# to numbers. -# e.g. 個, つ, 本, 冊, パーセント, cm, kg, カ月, か国, 区画, 時間, 時半 -#名詞-接尾-助数詞 -# -# noun-suffix-special: Special suffixes that mainly attach to inflecting words. -# e.g. (楽し) さ, (考え) 方 -#名詞-接尾-特殊 -# -# noun-suffix-conjunctive: Nouns that behave like conjunctions and join two words -# together. -# e.g. (日本) 対 (アメリカ), 対 (アメリカ), (3) 対 (5), (女優) 兼 (主婦) -#名詞-接続詞的 -# -# noun-verbal_aux: Nouns that attach to the conjunctive particle て ("te") and are -# semantically verb-like. -# e.g. ごらん, ご覧, 御覧, 頂戴 -#名詞-動詞非自立的 -# -# noun-quotation: text that cannot be segmented into words, proverbs, Chinese poetry, -# dialects, English, etc. Currently, the only entry for 名詞 引用文字列 ("noun quotation") -# is いわく ("iwaku"). -#名詞-引用文字列 -# -# noun-nai_adjective: Words that appear before the auxiliary verb ない ("nai") and -# behave like an adjective. -# e.g. 申し訳, 仕方, とんでも, 違い -#名詞-ナイ形容詞語幹 -# -##### -# prefix: unclassified prefixes -#接頭詞 -# -# prefix-nominal: Prefixes that attach to nouns (including adjective stem forms) -# excluding numerical expressions. -# e.g. お (水), 某 (氏), 同 (社), 故 (~氏), 高 (品質), お (見事), ご (立派) -#接頭詞-名詞接続 -# -# prefix-verbal: Prefixes that attach to the imperative form of a verb or a verb -# in conjunctive form followed by なる/なさる/くださる. -# e.g. お (読みなさい), お (座り) -#接頭詞-動詞接続 -# -# prefix-adjectival: Prefixes that attach to adjectives. -# e.g. お (寒いですねえ), バカ (でかい) -#接頭詞-形容詞接続 -# -# prefix-numerical: Prefixes that attach to numerical expressions. -# e.g. 約, およそ, 毎時 -#接頭詞-数接続 -# -##### -# verb: unclassified verbs -#動詞 -# -# verb-main: -#動詞-自立 -# -# verb-auxiliary: -#動詞-非自立 -# -# verb-suffix: -#動詞-接尾 -# -##### -# adjective: unclassified adjectives -#形容詞 -# -# adjective-main: -#形容詞-自立 -# -# adjective-auxiliary: -#形容詞-非自立 -# -# adjective-suffix: -#形容詞-接尾 -# -##### -# adverb: unclassified adverbs -#副詞 -# -# adverb-misc: Words that can be segmented into one unit and where adnominal -# modification is not possible. -# e.g. あいかわらず, 多分 -#副詞-一般 -# -# adverb-particle_conjunction: Adverbs that can be followed by の, は, に, -# な, する, だ, etc. -# e.g. こんなに, そんなに, あんなに, なにか, なんでも -#副詞-助詞類接続 -# -##### -# adnominal: Words that only have noun-modifying forms. -# e.g. この, その, あの, どの, いわゆる, なんらかの, 何らかの, いろんな, こういう, そういう, ああいう, -# どういう, こんな, そんな, あんな, どんな, 大きな, 小さな, おかしな, ほんの, たいした, -# 「(, も) さる (ことながら)」, 微々たる, 堂々たる, 単なる, いかなる, 我が」「同じ, 亡き -#連体詞 -# -##### -# conjunction: Conjunctions that can occur independently. -# e.g. が, けれども, そして, じゃあ, それどころか -接続詞 -# -##### -# particle: unclassified particles. -助詞 -# -# particle-case: case particles where the subclassification is undefined. -助詞-格助詞 -# -# particle-case-misc: Case particles. -# e.g. から, が, で, と, に, へ, より, を, の, にて -助詞-格助詞-一般 -# -# particle-case-quote: the "to" that appears after nouns, a person’s speech, -# quotation marks, expressions of decisions from a meeting, reasons, judgements, -# conjectures, etc. -# e.g. ( だ) と (述べた.), ( である) と (して執行猶予...) -助詞-格助詞-引用 -# -# particle-case-compound: Compounds of particles and verbs that mainly behave -# like case particles. -# e.g. という, といった, とかいう, として, とともに, と共に, でもって, にあたって, に当たって, に当って, -# にあたり, に当たり, に当り, に当たる, にあたる, において, に於いて,に於て, における, に於ける, -# にかけ, にかけて, にかんし, に関し, にかんして, に関して, にかんする, に関する, に際し, -# に際して, にしたがい, に従い, に従う, にしたがって, に従って, にたいし, に対し, にたいして, -# に対して, にたいする, に対する, について, につき, につけ, につけて, につれ, につれて, にとって, -# にとり, にまつわる, によって, に依って, に因って, により, に依り, に因り, による, に依る, に因る, -# にわたって, にわたる, をもって, を以って, を通じ, を通じて, を通して, をめぐって, をめぐり, をめぐる, -# って-口語/, ちゅう-関西弁「という」/, (何) ていう (人)-口語/, っていう-口語/, といふ, とかいふ -助詞-格助詞-連語 -# -# particle-conjunctive: -# e.g. から, からには, が, けれど, けれども, けど, し, つつ, て, で, と, ところが, どころか, とも, ども, -# ながら, なり, ので, のに, ば, ものの, や ( した), やいなや, (ころん) じゃ(いけない)-口語/, -# (行っ) ちゃ(いけない)-口語/, (言っ) たって (しかたがない)-口語/, (それがなく)ったって (平気)-口語/ -助詞-接続助詞 -# -# particle-dependency: -# e.g. こそ, さえ, しか, すら, は, も, ぞ -助詞-係助詞 -# -# particle-adverbial: -# e.g. がてら, かも, くらい, 位, ぐらい, しも, (学校) じゃ(これが流行っている)-口語/, -# (それ)じゃあ (よくない)-口語/, ずつ, (私) なぞ, など, (私) なり (に), (先生) なんか (大嫌い)-口語/, -# (私) なんぞ, (先生) なんて (大嫌い)-口語/, のみ, だけ, (私) だって-口語/, だに, -# (彼)ったら-口語/, (お茶) でも (いかが), 等 (とう), (今後) とも, ばかり, ばっか-口語/, ばっかり-口語/, -# ほど, 程, まで, 迄, (誰) も (が)([助詞-格助詞] および [助詞-係助詞] の前に位置する「も」) -助詞-副助詞 -# -# particle-interjective: particles with interjective grammatical roles. -# e.g. (松島) や -助詞-間投助詞 -# -# particle-coordinate: -# e.g. と, たり, だの, だり, とか, なり, や, やら -助詞-並立助詞 -# -# particle-final: -# e.g. かい, かしら, さ, ぜ, (だ)っけ-口語/, (とまってる) で-方言/, な, ナ, なあ-口語/, ぞ, ね, ネ, -# ねぇ-口語/, ねえ-口語/, ねん-方言/, の, のう-口語/, や, よ, ヨ, よぉ-口語/, わ, わい-口語/ -助詞-終助詞 -# -# particle-adverbial/conjunctive/final: The particle "ka" when unknown whether it is -# adverbial, conjunctive, or sentence final. For example: -# (a) 「A か B か」. Ex:「(国内で運用する) か,(海外で運用する) か (.)」 -# (b) Inside an adverb phrase. Ex:「(幸いという) か (, 死者はいなかった.)」 -# 「(祈りが届いたせい) か (, 試験に合格した.)」 -# (c) 「かのように」. Ex:「(何もなかった) か (のように振る舞った.)」 -# e.g. か -助詞-副助詞/並立助詞/終助詞 -# -# particle-adnominalizer: The "no" that attaches to nouns and modifies -# non-inflectional words. -助詞-連体化 -# -# particle-adnominalizer: The "ni" and "to" that appear following nouns and adverbs -# that are giongo, giseigo, or gitaigo. -# e.g. に, と -助詞-副詞化 -# -# particle-special: A particle that does not fit into one of the above classifications. -# This includes particles that are used in Tanka, Haiku, and other poetry. -# e.g. かな, けむ, ( しただろう) に, (あんた) にゃ(わからん), (俺) ん (家) -助詞-特殊 -# -##### -# auxiliary-verb: -助動詞 -# -##### -# interjection: Greetings and other exclamations. -# e.g. おはよう, おはようございます, こんにちは, こんばんは, ありがとう, どうもありがとう, ありがとうございます, -# いただきます, ごちそうさま, さよなら, さようなら, はい, いいえ, ごめん, ごめんなさい -#感動詞 -# -##### -# symbol: unclassified Symbols. -記号 -# -# symbol-misc: A general symbol not in one of the categories below. -# e.g. [○◎@$〒→+] -記号-一般 -# -# symbol-comma: Commas -# e.g. [,、] -記号-読点 -# -# symbol-period: Periods and full stops. -# e.g. [..。] -記号-句点 -# -# symbol-space: Full-width whitespace. -記号-空白 -# -# symbol-open_bracket: -# e.g. [({‘“『【] -記号-括弧開 -# -# symbol-close_bracket: -# e.g. [)}’”』」】] -記号-括弧閉 -# -# symbol-alphabetic: -#記号-アルファベット -# -##### -# other: unclassified other -#その他 -# -# other-interjection: Words that are hard to classify as noun-suffixes or -# sentence-final particles. -# e.g. (だ)ァ -その他-間投 -# -##### -# filler: Aizuchi that occurs during a conversation or sounds inserted as filler. -# e.g. あの, うんと, えと -フィラー -# -##### -# non-verbal: non-verbal sound. -非言語音 -# -##### -# fragment: -#語断片 -# -##### -# unknown: unknown part of speech. -#未知語 -# -##### End of file +# +# This file defines a Japanese stoptag set for JapanesePartOfSpeechStopFilter. +# +# Any token with a part-of-speech tag that exactly matches those defined in this +# file are removed from the token stream. +# +# Set your own stoptags by uncommenting the lines below. Note that comments are +# not allowed on the same line as a stoptag. See LUCENE-3745 for frequency lists, +# etc. that can be useful for building you own stoptag set. +# +# The entire possible tagset is provided below for convenience. +# +##### +# noun: unclassified nouns +#名詞 +# +# noun-common: Common nouns or nouns where the sub-classification is undefined +#名詞-一般 +# +# noun-proper: Proper nouns where the sub-classification is undefined +#名詞-固有名詞 +# +# noun-proper-misc: miscellaneous proper nouns +#名詞-固有名詞-一般 +# +# noun-proper-person: Personal names where the sub-classification is undefined +#名詞-固有名詞-人名 +# +# noun-proper-person-misc: names that cannot be divided into surname and +# given name; foreign names; names where the surname or given name is unknown. +# e.g. お市の方 +#名詞-固有名詞-人名-一般 +# +# noun-proper-person-surname: Mainly Japanese surnames. +# e.g. 山田 +#名詞-固有名詞-人名-姓 +# +# noun-proper-person-given_name: Mainly Japanese given names. +# e.g. 太郎 +#名詞-固有名詞-人名-名 +# +# noun-proper-organization: Names representing organizations. +# e.g. 通産省, NHK +#名詞-固有名詞-組織 +# +# noun-proper-place: Place names where the sub-classification is undefined +#名詞-固有名詞-地域 +# +# noun-proper-place-misc: Place names excluding countries. +# e.g. アジア, バルセロナ, 京都 +#名詞-固有名詞-地域-一般 +# +# noun-proper-place-country: Country names. +# e.g. 日本, オーストラリア +#名詞-固有名詞-地域-国 +# +# noun-pronoun: Pronouns where the sub-classification is undefined +#名詞-代名詞 +# +# noun-pronoun-misc: miscellaneous pronouns: +# e.g. それ, ここ, あいつ, あなた, あちこち, いくつ, どこか, なに, みなさん, みんな, わたくし, われわれ +#名詞-代名詞-一般 +# +# noun-pronoun-contraction: Spoken language contraction made by combining a +# pronoun and the particle 'wa'. +# e.g. ありゃ, こりゃ, こりゃあ, そりゃ, そりゃあ +#名詞-代名詞-縮約 +# +# noun-adverbial: Temporal nouns such as names of days or months that behave +# like adverbs. Nouns that represent amount or ratios and can be used adverbially, +# e.g. 金曜, 一月, 午後, 少量 +#名詞-副詞可能 +# +# noun-verbal: Nouns that take arguments with case and can appear followed by +# 'suru' and related verbs (する, できる, なさる, くださる) +# e.g. インプット, 愛着, 悪化, 悪戦苦闘, 一安心, 下取り +#名詞-サ変接続 +# +# noun-adjective-base: The base form of adjectives, words that appear before な ("na") +# e.g. 健康, 安易, 駄目, だめ +#名詞-形容動詞語幹 +# +# noun-numeric: Arabic numbers, Chinese numerals, and counters like 何 (回), 数. +# e.g. 0, 1, 2, 何, 数, 幾 +#名詞-数 +# +# noun-affix: noun affixes where the sub-classification is undefined +#名詞-非自立 +# +# noun-affix-misc: Of adnominalizers, the case-marker の ("no"), and words that +# attach to the base form of inflectional words, words that cannot be classified +# into any of the other categories below. This category includes indefinite nouns. +# e.g. あかつき, 暁, かい, 甲斐, 気, きらい, 嫌い, くせ, 癖, こと, 事, ごと, 毎, しだい, 次第, +# 順, せい, 所為, ついで, 序で, つもり, 積もり, 点, どころ, の, はず, 筈, はずみ, 弾み, +# 拍子, ふう, ふり, 振り, ほう, 方, 旨, もの, 物, 者, ゆえ, 故, ゆえん, 所以, わけ, 訳, +# わり, 割り, 割, ん-口語/, もん-口語/ +#名詞-非自立-一般 +# +# noun-affix-adverbial: noun affixes that that can behave as adverbs. +# e.g. あいだ, 間, あげく, 挙げ句, あと, 後, 余り, 以外, 以降, 以後, 以上, 以前, 一方, うえ, +# 上, うち, 内, おり, 折り, かぎり, 限り, きり, っきり, 結果, ころ, 頃, さい, 際, 最中, さなか, +# 最中, じたい, 自体, たび, 度, ため, 為, つど, 都度, とおり, 通り, とき, 時, ところ, 所, +# とたん, 途端, なか, 中, のち, 後, ばあい, 場合, 日, ぶん, 分, ほか, 他, まえ, 前, まま, +# 儘, 侭, みぎり, 矢先 +#名詞-非自立-副詞可能 +# +# noun-affix-aux: noun affixes treated as 助動詞 ("auxiliary verb") in school grammars +# with the stem よう(だ) ("you(da)"). +# e.g. よう, やう, 様 (よう) +#名詞-非自立-助動詞語幹 +# +# noun-affix-adjective-base: noun affixes that can connect to the indeclinable +# connection form な (aux "da"). +# e.g. みたい, ふう +#名詞-非自立-形容動詞語幹 +# +# noun-special: special nouns where the sub-classification is undefined. +#名詞-特殊 +# +# noun-special-aux: The そうだ ("souda") stem form that is used for reporting news, is +# treated as 助動詞 ("auxiliary verb") in school grammars, and attach to the base +# form of inflectional words. +# e.g. そう +#名詞-特殊-助動詞語幹 +# +# noun-suffix: noun suffixes where the sub-classification is undefined. +#名詞-接尾 +# +# noun-suffix-misc: Of the nouns or stem forms of other parts of speech that connect +# to ガル or タイ and can combine into compound nouns, words that cannot be classified into +# any of the other categories below. In general, this category is more inclusive than +# 接尾語 ("suffix") and is usually the last element in a compound noun. +# e.g. おき, かた, 方, 甲斐 (がい), がかり, ぎみ, 気味, ぐるみ, (~した) さ, 次第, 済 (ず) み, +# よう, (でき)っこ, 感, 観, 性, 学, 類, 面, 用 +#名詞-接尾-一般 +# +# noun-suffix-person: Suffixes that form nouns and attach to person names more often +# than other nouns. +# e.g. 君, 様, 著 +#名詞-接尾-人名 +# +# noun-suffix-place: Suffixes that form nouns and attach to place names more often +# than other nouns. +# e.g. 町, 市, 県 +#名詞-接尾-地域 +# +# noun-suffix-verbal: Of the suffixes that attach to nouns and form nouns, those that +# can appear before スル ("suru"). +# e.g. 化, 視, 分け, 入り, 落ち, 買い +#名詞-接尾-サ変接続 +# +# noun-suffix-aux: The stem form of そうだ (様態) that is used to indicate conditions, +# is treated as 助動詞 ("auxiliary verb") in school grammars, and attach to the +# conjunctive form of inflectional words. +# e.g. そう +#名詞-接尾-助動詞語幹 +# +# noun-suffix-adjective-base: Suffixes that attach to other nouns or the conjunctive +# form of inflectional words and appear before the copula だ ("da"). +# e.g. 的, げ, がち +#名詞-接尾-形容動詞語幹 +# +# noun-suffix-adverbial: Suffixes that attach to other nouns and can behave as adverbs. +# e.g. 後 (ご), 以後, 以降, 以前, 前後, 中, 末, 上, 時 (じ) +#名詞-接尾-副詞可能 +# +# noun-suffix-classifier: Suffixes that attach to numbers and form nouns. This category +# is more inclusive than 助数詞 ("classifier") and includes common nouns that attach +# to numbers. +# e.g. 個, つ, 本, 冊, パーセント, cm, kg, カ月, か国, 区画, 時間, 時半 +#名詞-接尾-助数詞 +# +# noun-suffix-special: Special suffixes that mainly attach to inflecting words. +# e.g. (楽し) さ, (考え) 方 +#名詞-接尾-特殊 +# +# noun-suffix-conjunctive: Nouns that behave like conjunctions and join two words +# together. +# e.g. (日本) 対 (アメリカ), 対 (アメリカ), (3) 対 (5), (女優) 兼 (主婦) +#名詞-接続詞的 +# +# noun-verbal_aux: Nouns that attach to the conjunctive particle て ("te") and are +# semantically verb-like. +# e.g. ごらん, ご覧, 御覧, 頂戴 +#名詞-動詞非自立的 +# +# noun-quotation: text that cannot be segmented into words, proverbs, Chinese poetry, +# dialects, English, etc. Currently, the only entry for 名詞 引用文字列 ("noun quotation") +# is いわく ("iwaku"). +#名詞-引用文字列 +# +# noun-nai_adjective: Words that appear before the auxiliary verb ない ("nai") and +# behave like an adjective. +# e.g. 申し訳, 仕方, とんでも, 違い +#名詞-ナイ形容詞語幹 +# +##### +# prefix: unclassified prefixes +#接頭詞 +# +# prefix-nominal: Prefixes that attach to nouns (including adjective stem forms) +# excluding numerical expressions. +# e.g. お (水), 某 (氏), 同 (社), 故 (~氏), 高 (品質), お (見事), ご (立派) +#接頭詞-名詞接続 +# +# prefix-verbal: Prefixes that attach to the imperative form of a verb or a verb +# in conjunctive form followed by なる/なさる/くださる. +# e.g. お (読みなさい), お (座り) +#接頭詞-動詞接続 +# +# prefix-adjectival: Prefixes that attach to adjectives. +# e.g. お (寒いですねえ), バカ (でかい) +#接頭詞-形容詞接続 +# +# prefix-numerical: Prefixes that attach to numerical expressions. +# e.g. 約, およそ, 毎時 +#接頭詞-数接続 +# +##### +# verb: unclassified verbs +#動詞 +# +# verb-main: +#動詞-自立 +# +# verb-auxiliary: +#動詞-非自立 +# +# verb-suffix: +#動詞-接尾 +# +##### +# adjective: unclassified adjectives +#形容詞 +# +# adjective-main: +#形容詞-自立 +# +# adjective-auxiliary: +#形容詞-非自立 +# +# adjective-suffix: +#形容詞-接尾 +# +##### +# adverb: unclassified adverbs +#副詞 +# +# adverb-misc: Words that can be segmented into one unit and where adnominal +# modification is not possible. +# e.g. あいかわらず, 多分 +#副詞-一般 +# +# adverb-particle_conjunction: Adverbs that can be followed by の, は, に, +# な, する, だ, etc. +# e.g. こんなに, そんなに, あんなに, なにか, なんでも +#副詞-助詞類接続 +# +##### +# adnominal: Words that only have noun-modifying forms. +# e.g. この, その, あの, どの, いわゆる, なんらかの, 何らかの, いろんな, こういう, そういう, ああいう, +# どういう, こんな, そんな, あんな, どんな, 大きな, 小さな, おかしな, ほんの, たいした, +# 「(, も) さる (ことながら)」, 微々たる, 堂々たる, 単なる, いかなる, 我が」「同じ, 亡き +#連体詞 +# +##### +# conjunction: Conjunctions that can occur independently. +# e.g. が, けれども, そして, じゃあ, それどころか +接続詞 +# +##### +# particle: unclassified particles. +助詞 +# +# particle-case: case particles where the subclassification is undefined. +助詞-格助詞 +# +# particle-case-misc: Case particles. +# e.g. から, が, で, と, に, へ, より, を, の, にて +助詞-格助詞-一般 +# +# particle-case-quote: the "to" that appears after nouns, a person’s speech, +# quotation marks, expressions of decisions from a meeting, reasons, judgements, +# conjectures, etc. +# e.g. ( だ) と (述べた.), ( である) と (して執行猶予...) +助詞-格助詞-引用 +# +# particle-case-compound: Compounds of particles and verbs that mainly behave +# like case particles. +# e.g. という, といった, とかいう, として, とともに, と共に, でもって, にあたって, に当たって, に当って, +# にあたり, に当たり, に当り, に当たる, にあたる, において, に於いて,に於て, における, に於ける, +# にかけ, にかけて, にかんし, に関し, にかんして, に関して, にかんする, に関する, に際し, +# に際して, にしたがい, に従い, に従う, にしたがって, に従って, にたいし, に対し, にたいして, +# に対して, にたいする, に対する, について, につき, につけ, につけて, につれ, につれて, にとって, +# にとり, にまつわる, によって, に依って, に因って, により, に依り, に因り, による, に依る, に因る, +# にわたって, にわたる, をもって, を以って, を通じ, を通じて, を通して, をめぐって, をめぐり, をめぐる, +# って-口語/, ちゅう-関西弁「という」/, (何) ていう (人)-口語/, っていう-口語/, といふ, とかいふ +助詞-格助詞-連語 +# +# particle-conjunctive: +# e.g. から, からには, が, けれど, けれども, けど, し, つつ, て, で, と, ところが, どころか, とも, ども, +# ながら, なり, ので, のに, ば, ものの, や ( した), やいなや, (ころん) じゃ(いけない)-口語/, +# (行っ) ちゃ(いけない)-口語/, (言っ) たって (しかたがない)-口語/, (それがなく)ったって (平気)-口語/ +助詞-接続助詞 +# +# particle-dependency: +# e.g. こそ, さえ, しか, すら, は, も, ぞ +助詞-係助詞 +# +# particle-adverbial: +# e.g. がてら, かも, くらい, 位, ぐらい, しも, (学校) じゃ(これが流行っている)-口語/, +# (それ)じゃあ (よくない)-口語/, ずつ, (私) なぞ, など, (私) なり (に), (先生) なんか (大嫌い)-口語/, +# (私) なんぞ, (先生) なんて (大嫌い)-口語/, のみ, だけ, (私) だって-口語/, だに, +# (彼)ったら-口語/, (お茶) でも (いかが), 等 (とう), (今後) とも, ばかり, ばっか-口語/, ばっかり-口語/, +# ほど, 程, まで, 迄, (誰) も (が)([助詞-格助詞] および [助詞-係助詞] の前に位置する「も」) +助詞-副助詞 +# +# particle-interjective: particles with interjective grammatical roles. +# e.g. (松島) や +助詞-間投助詞 +# +# particle-coordinate: +# e.g. と, たり, だの, だり, とか, なり, や, やら +助詞-並立助詞 +# +# particle-final: +# e.g. かい, かしら, さ, ぜ, (だ)っけ-口語/, (とまってる) で-方言/, な, ナ, なあ-口語/, ぞ, ね, ネ, +# ねぇ-口語/, ねえ-口語/, ねん-方言/, の, のう-口語/, や, よ, ヨ, よぉ-口語/, わ, わい-口語/ +助詞-終助詞 +# +# particle-adverbial/conjunctive/final: The particle "ka" when unknown whether it is +# adverbial, conjunctive, or sentence final. For example: +# (a) 「A か B か」. Ex:「(国内で運用する) か,(海外で運用する) か (.)」 +# (b) Inside an adverb phrase. Ex:「(幸いという) か (, 死者はいなかった.)」 +# 「(祈りが届いたせい) か (, 試験に合格した.)」 +# (c) 「かのように」. Ex:「(何もなかった) か (のように振る舞った.)」 +# e.g. か +助詞-副助詞/並立助詞/終助詞 +# +# particle-adnominalizer: The "no" that attaches to nouns and modifies +# non-inflectional words. +助詞-連体化 +# +# particle-adnominalizer: The "ni" and "to" that appear following nouns and adverbs +# that are giongo, giseigo, or gitaigo. +# e.g. に, と +助詞-副詞化 +# +# particle-special: A particle that does not fit into one of the above classifications. +# This includes particles that are used in Tanka, Haiku, and other poetry. +# e.g. かな, けむ, ( しただろう) に, (あんた) にゃ(わからん), (俺) ん (家) +助詞-特殊 +# +##### +# auxiliary-verb: +助動詞 +# +##### +# interjection: Greetings and other exclamations. +# e.g. おはよう, おはようございます, こんにちは, こんばんは, ありがとう, どうもありがとう, ありがとうございます, +# いただきます, ごちそうさま, さよなら, さようなら, はい, いいえ, ごめん, ごめんなさい +#感動詞 +# +##### +# symbol: unclassified Symbols. +記号 +# +# symbol-misc: A general symbol not in one of the categories below. +# e.g. [○◎@$〒→+] +記号-一般 +# +# symbol-comma: Commas +# e.g. [,、] +記号-読点 +# +# symbol-period: Periods and full stops. +# e.g. [..。] +記号-句点 +# +# symbol-space: Full-width whitespace. +記号-空白 +# +# symbol-open_bracket: +# e.g. [({‘“『【] +記号-括弧開 +# +# symbol-close_bracket: +# e.g. [)}’”』」】] +記号-括弧閉 +# +# symbol-alphabetic: +#記号-アルファベット +# +##### +# other: unclassified other +#その他 +# +# other-interjection: Words that are hard to classify as noun-suffixes or +# sentence-final particles. +# e.g. (だ)ァ +その他-間投 +# +##### +# filler: Aizuchi that occurs during a conversation or sounds inserted as filler. +# e.g. あの, うんと, えと +フィラー +# +##### +# non-verbal: non-verbal sound. +非言語音 +# +##### +# fragment: +#語断片 +# +##### +# unknown: unknown part of speech. +#未知語 +# +##### End of file diff --git a/resources/cache/empty/relation/conf/lang/stopwords_ar.txt b/resources/cache/empty/relation/conf/lang/stopwords_ar.txt index aca24303..046829db 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_ar.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_ar.txt @@ -1,125 +1,125 @@ -# This file was created by Jacques Savoy and is distributed under the BSD license. -# See http://members.unine.ch/jacques.savoy/clef/index.html. -# Also see http://www.opensource.org/licenses/bsd-license.html -# Cleaned on October 11, 2009 (not normalized, so use before normalization) -# This means that when modifying this list, you might need to add some -# redundant entries, for example containing forms with both أ and ا -من -ومن -منها -منه -في -وفي -فيها -فيه -و -ف -ثم -او -أو -ب -بها -به -ا -أ -اى -اي -أي -أى -لا -ولا -الا -ألا -إلا -لكن -ما -وما -كما -فما -عن -مع -اذا -إذا -ان -أن -إن -انها -أنها -إنها -انه -أنه -إنه -بان -بأن -فان -فأن -وان -وأن -وإن -التى -التي -الذى -الذي -الذين -الى -الي -إلى -إلي -على -عليها -عليه -اما -أما -إما -ايضا -أيضا -كل -وكل -لم -ولم -لن -ولن -هى -هي -هو -وهى -وهي -وهو -فهى -فهي -فهو -انت -أنت -لك -لها -له -هذه -هذا -تلك -ذلك -هناك -كانت -كان -يكون -تكون -وكانت -وكان -غير -بعض -قد -نحو -بين -بينما -منذ -ضمن -حيث -الان -الآن -خلال -بعد -قبل -حتى -عند -عندما -لدى -جميع +# This file was created by Jacques Savoy and is distributed under the BSD license. +# See http://members.unine.ch/jacques.savoy/clef/index.html. +# Also see http://www.opensource.org/licenses/bsd-license.html +# Cleaned on October 11, 2009 (not normalized, so use before normalization) +# This means that when modifying this list, you might need to add some +# redundant entries, for example containing forms with both أ and ا +من +ومن +منها +منه +في +وفي +فيها +فيه +و +ف +ثم +او +أو +ب +بها +به +ا +أ +اى +اي +أي +أى +لا +ولا +الا +ألا +إلا +لكن +ما +وما +كما +فما +عن +مع +اذا +إذا +ان +أن +إن +انها +أنها +إنها +انه +أنه +إنه +بان +بأن +فان +فأن +وان +وأن +وإن +التى +التي +الذى +الذي +الذين +الى +الي +إلى +إلي +على +عليها +عليه +اما +أما +إما +ايضا +أيضا +كل +وكل +لم +ولم +لن +ولن +هى +هي +هو +وهى +وهي +وهو +فهى +فهي +فهو +انت +أنت +لك +لها +له +هذه +هذا +تلك +ذلك +هناك +كانت +كان +يكون +تكون +وكانت +وكان +غير +بعض +قد +نحو +بين +بينما +منذ +ضمن +حيث +الان +الآن +خلال +بعد +قبل +حتى +عند +عندما +لدى +جميع diff --git a/resources/cache/empty/relation/conf/lang/stopwords_bg.txt b/resources/cache/empty/relation/conf/lang/stopwords_bg.txt index 842ee8a8..1ae4ba2a 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_bg.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_bg.txt @@ -1,193 +1,193 @@ -# This file was created by Jacques Savoy and is distributed under the BSD license. -# See http://members.unine.ch/jacques.savoy/clef/index.html. -# Also see http://www.opensource.org/licenses/bsd-license.html -а -аз -ако -ала -бе -без -беше -би -бил -била -били -било -близо -бъдат -бъде -бяха -в -вас -ваш -ваша -вероятно -вече -взема -ви -вие -винаги -все -всеки -всички -всичко -всяка -във -въпреки -върху -г -ги -главно -го -д -да -дали -до -докато -докога -дори -досега -доста -е -едва -един -ето -за -зад -заедно -заради -засега -затова -защо -защото -и -из -или -им -има -имат -иска -й -каза -как -каква -какво -както -какъв -като -кога -когато -което -които -кой -който -колко -която -къде -където -към -ли -м -ме -между -мен -ми -мнозина -мога -могат -може -моля -момента -му -н -на -над -назад -най -направи -напред -например -нас -не -него -нея -ни -ние -никой -нито -но -някои -някой -няма -обаче -около -освен -особено -от -отгоре -отново -още -пак -по -повече -повечето -под -поне -поради -после -почти -прави -пред -преди -през -при -пък -първо -с -са -само -се -сега -си -скоро -след -сме -според -сред -срещу -сте -съм -със -също -т -тази -така -такива -такъв -там -твой -те -тези -ти -тн -то -това -тогава -този -той -толкова -точно -трябва -тук -тъй -тя -тях -у -харесва -ч -че -често -чрез -ще -щом -я +# This file was created by Jacques Savoy and is distributed under the BSD license. +# See http://members.unine.ch/jacques.savoy/clef/index.html. +# Also see http://www.opensource.org/licenses/bsd-license.html +а +аз +ако +ала +бе +без +беше +би +бил +била +били +било +близо +бъдат +бъде +бяха +в +вас +ваш +ваша +вероятно +вече +взема +ви +вие +винаги +все +всеки +всички +всичко +всяка +във +въпреки +върху +г +ги +главно +го +д +да +дали +до +докато +докога +дори +досега +доста +е +едва +един +ето +за +зад +заедно +заради +засега +затова +защо +защото +и +из +или +им +има +имат +иска +й +каза +как +каква +какво +както +какъв +като +кога +когато +което +които +кой +който +колко +която +къде +където +към +ли +м +ме +между +мен +ми +мнозина +мога +могат +може +моля +момента +му +н +на +над +назад +най +направи +напред +например +нас +не +него +нея +ни +ние +никой +нито +но +някои +някой +няма +обаче +около +освен +особено +от +отгоре +отново +още +пак +по +повече +повечето +под +поне +поради +после +почти +прави +пред +преди +през +при +пък +първо +с +са +само +се +сега +си +скоро +след +сме +според +сред +срещу +сте +съм +със +също +т +тази +така +такива +такъв +там +твой +те +тези +ти +тн +то +това +тогава +този +той +толкова +точно +трябва +тук +тъй +тя +тях +у +харесва +ч +че +често +чрез +ще +щом +я diff --git a/resources/cache/empty/relation/conf/lang/stopwords_ca.txt b/resources/cache/empty/relation/conf/lang/stopwords_ca.txt index e618af55..3da65dea 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_ca.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_ca.txt @@ -1,220 +1,220 @@ -# Catalan stopwords from http://github.com/vcl/cue.language (Apache 2 Licensed) -a -abans -ací -ah -així -això -al -als -aleshores -algun -alguna -algunes -alguns -alhora -allà -allí -allò -altra -altre -altres -amb -ambdós -ambdues -apa -aquell -aquella -aquelles -aquells -aquest -aquesta -aquestes -aquests -aquí -baix -cada -cadascú -cadascuna -cadascunes -cadascuns -com -contra -d'un -d'una -d'unes -d'uns -dalt -de -del -dels -des -després -dins -dintre -donat -doncs -durant -e -eh -el -els -em -en -encara -ens -entre -érem -eren -éreu -es -és -esta -està -estàvem -estaven -estàveu -esteu -et -etc -ets -fins -fora -gairebé -ha -han -has -havia -he -hem -heu -hi -ho -i -igual -iguals -ja -l'hi -la -les -li -li'n -llavors -m'he -ma -mal -malgrat -mateix -mateixa -mateixes -mateixos -me -mentre -més -meu -meus -meva -meves -molt -molta -moltes -molts -mon -mons -n'he -n'hi -ne -ni -no -nogensmenys -només -nosaltres -nostra -nostre -nostres -o -oh -oi -on -pas -pel -pels -per -però -perquè -poc -poca -pocs -poques -potser -propi -qual -quals -quan -quant -que -què -quelcom -qui -quin -quina -quines -quins -s'ha -s'han -sa -semblant -semblants -ses -seu -seus -seva -seva -seves -si -sobre -sobretot -sóc -solament -sols -son -són -sons -sota -sou -t'ha -t'han -t'he -ta -tal -també -tampoc -tan -tant -tanta -tantes -teu -teus -teva -teves -ton -tons -tot -tota -totes -tots -un -una -unes -uns -us -va -vaig -vam -van -vas -veu -vosaltres -vostra -vostre -vostres +# Catalan stopwords from http://github.com/vcl/cue.language (Apache 2 Licensed) +a +abans +ací +ah +així +això +al +als +aleshores +algun +alguna +algunes +alguns +alhora +allà +allí +allò +altra +altre +altres +amb +ambdós +ambdues +apa +aquell +aquella +aquelles +aquells +aquest +aquesta +aquestes +aquests +aquí +baix +cada +cadascú +cadascuna +cadascunes +cadascuns +com +contra +d'un +d'una +d'unes +d'uns +dalt +de +del +dels +des +després +dins +dintre +donat +doncs +durant +e +eh +el +els +em +en +encara +ens +entre +érem +eren +éreu +es +és +esta +està +estàvem +estaven +estàveu +esteu +et +etc +ets +fins +fora +gairebé +ha +han +has +havia +he +hem +heu +hi +ho +i +igual +iguals +ja +l'hi +la +les +li +li'n +llavors +m'he +ma +mal +malgrat +mateix +mateixa +mateixes +mateixos +me +mentre +més +meu +meus +meva +meves +molt +molta +moltes +molts +mon +mons +n'he +n'hi +ne +ni +no +nogensmenys +només +nosaltres +nostra +nostre +nostres +o +oh +oi +on +pas +pel +pels +per +però +perquè +poc +poca +pocs +poques +potser +propi +qual +quals +quan +quant +que +què +quelcom +qui +quin +quina +quines +quins +s'ha +s'han +sa +semblant +semblants +ses +seu +seus +seva +seva +seves +si +sobre +sobretot +sóc +solament +sols +son +són +sons +sota +sou +t'ha +t'han +t'he +ta +tal +també +tampoc +tan +tant +tanta +tantes +teu +teus +teva +teves +ton +tons +tot +tota +totes +tots +un +una +unes +uns +us +va +vaig +vam +van +vas +veu +vosaltres +vostra +vostre +vostres diff --git a/resources/cache/empty/relation/conf/lang/stopwords_cz.txt b/resources/cache/empty/relation/conf/lang/stopwords_cz.txt index e928df95..53c6097d 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_cz.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_cz.txt @@ -1,172 +1,172 @@ -a -s -k -o -i -u -v -z -dnes -cz -tímto -budeš -budem -byli -jseš -můj -svým -ta -tomto -tohle -tuto -tyto -jej -zda -proč -máte -tato -kam -tohoto -kdo -kteří -mi -nám -tom -tomuto -mít -nic -proto -kterou -byla -toho -protože -asi -ho -naši -napište -re -což -tím -takže -svých -její -svými -jste -aj -tu -tedy -teto -bylo -kde -ke -pravé -ji -nad -nejsou -či -pod -téma -mezi -přes -ty -pak -vám -ani -když -však -neg -jsem -tento -článku -články -aby -jsme -před -pta -jejich -byl -ještě -až -bez -také -pouze -první -vaše -která -nás -nový -tipy -pokud -může -strana -jeho -své -jiné -zprávy -nové -není -vás -jen -podle -zde -už -být -více -bude -již -než -který -by -které -co -nebo -ten -tak -má -při -od -po -jsou -jak -další -ale -si -se -ve -to -jako -za -zpět -ze -do -pro -je -na -atd -atp -jakmile -přičemž -já -on -ona -ono -oni -ony -my -vy -jí -ji -mě -mne -jemu -tomu -těm -těmu -němu -němuž -jehož -jíž -jelikož -jež -jakož -načež +a +s +k +o +i +u +v +z +dnes +cz +tímto +budeš +budem +byli +jseš +můj +svým +ta +tomto +tohle +tuto +tyto +jej +zda +proč +máte +tato +kam +tohoto +kdo +kteří +mi +nám +tom +tomuto +mít +nic +proto +kterou +byla +toho +protože +asi +ho +naši +napište +re +což +tím +takže +svých +její +svými +jste +aj +tu +tedy +teto +bylo +kde +ke +pravé +ji +nad +nejsou +či +pod +téma +mezi +přes +ty +pak +vám +ani +když +však +neg +jsem +tento +článku +články +aby +jsme +před +pta +jejich +byl +ještě +až +bez +také +pouze +první +vaše +která +nás +nový +tipy +pokud +může +strana +jeho +své +jiné +zprávy +nové +není +vás +jen +podle +zde +už +být +více +bude +již +než +který +by +které +co +nebo +ten +tak +má +při +od +po +jsou +jak +další +ale +si +se +ve +to +jako +za +zpět +ze +do +pro +je +na +atd +atp +jakmile +přičemž +já +on +ona +ono +oni +ony +my +vy +jí +ji +mě +mne +jemu +tomu +těm +těmu +němu +němuž +jehož +jíž +jelikož +jež +jakož +načež diff --git a/resources/cache/empty/relation/conf/lang/stopwords_da.txt b/resources/cache/empty/relation/conf/lang/stopwords_da.txt index e25d49ce..42e6145b 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_da.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_da.txt @@ -1,110 +1,110 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/danish/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Danish stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - | This is a ranked list (commonest to rarest) of stopwords derived from - | a large text sample. - - -og | and -i | in -jeg | I -det | that (dem. pronoun)/it (pers. pronoun) -at | that (in front of a sentence)/to (with infinitive) -en | a/an -den | it (pers. pronoun)/that (dem. pronoun) -til | to/at/for/until/against/by/of/into, more -er | present tense of "to be" -som | who, as -på | on/upon/in/on/at/to/after/of/with/for, on -de | they -med | with/by/in, along -han | he -af | of/by/from/off/for/in/with/on, off -for | at/for/to/from/by/of/ago, in front/before, because -ikke | not -der | who/which, there/those -var | past tense of "to be" -mig | me/myself -sig | oneself/himself/herself/itself/themselves -men | but -et | a/an/one, one (number), someone/somebody/one -har | present tense of "to have" -om | round/about/for/in/a, about/around/down, if -vi | we -min | my -havde | past tense of "to have" -ham | him -hun | she -nu | now -over | over/above/across/by/beyond/past/on/about, over/past -da | then, when/as/since -fra | from/off/since, off, since -du | you -ud | out -sin | his/her/its/one's -dem | them -os | us/ourselves -op | up -man | you/one -hans | his -hvor | where -eller | or -hvad | what -skal | must/shall etc. -selv | myself/youself/herself/ourselves etc., even -her | here -alle | all/everyone/everybody etc. -vil | will (verb) -blev | past tense of "to stay/to remain/to get/to become" -kunne | could -ind | in -når | when -være | present tense of "to be" -dog | however/yet/after all -noget | something -ville | would -jo | you know/you see (adv), yes -deres | their/theirs -efter | after/behind/according to/for/by/from, later/afterwards -ned | down -skulle | should -denne | this -end | than -dette | this -mit | my/mine -også | also -under | under/beneath/below/during, below/underneath -have | have -dig | you -anden | other -hende | her -mine | my -alt | everything -meget | much/very, plenty of -sit | his, her, its, one's -sine | his, her, its, one's -vor | our -mod | against -disse | these -hvis | if -din | your/yours -nogle | some -hos | by/at -blive | be/become -mange | many -ad | by/through -bliver | present tense of "to be/to become" -hendes | her/hers -været | be -thi | for (conj) -jer | you -sådan | such, like this/like that + | From svn.tartarus.org/snowball/trunk/website/algorithms/danish/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Danish stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + | This is a ranked list (commonest to rarest) of stopwords derived from + | a large text sample. + + +og | and +i | in +jeg | I +det | that (dem. pronoun)/it (pers. pronoun) +at | that (in front of a sentence)/to (with infinitive) +en | a/an +den | it (pers. pronoun)/that (dem. pronoun) +til | to/at/for/until/against/by/of/into, more +er | present tense of "to be" +som | who, as +på | on/upon/in/on/at/to/after/of/with/for, on +de | they +med | with/by/in, along +han | he +af | of/by/from/off/for/in/with/on, off +for | at/for/to/from/by/of/ago, in front/before, because +ikke | not +der | who/which, there/those +var | past tense of "to be" +mig | me/myself +sig | oneself/himself/herself/itself/themselves +men | but +et | a/an/one, one (number), someone/somebody/one +har | present tense of "to have" +om | round/about/for/in/a, about/around/down, if +vi | we +min | my +havde | past tense of "to have" +ham | him +hun | she +nu | now +over | over/above/across/by/beyond/past/on/about, over/past +da | then, when/as/since +fra | from/off/since, off, since +du | you +ud | out +sin | his/her/its/one's +dem | them +os | us/ourselves +op | up +man | you/one +hans | his +hvor | where +eller | or +hvad | what +skal | must/shall etc. +selv | myself/youself/herself/ourselves etc., even +her | here +alle | all/everyone/everybody etc. +vil | will (verb) +blev | past tense of "to stay/to remain/to get/to become" +kunne | could +ind | in +når | when +være | present tense of "to be" +dog | however/yet/after all +noget | something +ville | would +jo | you know/you see (adv), yes +deres | their/theirs +efter | after/behind/according to/for/by/from, later/afterwards +ned | down +skulle | should +denne | this +end | than +dette | this +mit | my/mine +også | also +under | under/beneath/below/during, below/underneath +have | have +dig | you +anden | other +hende | her +mine | my +alt | everything +meget | much/very, plenty of +sit | his, her, its, one's +sine | his, her, its, one's +vor | our +mod | against +disse | these +hvis | if +din | your/yours +nogle | some +hos | by/at +blive | be/become +mange | many +ad | by/through +bliver | present tense of "to be/to become" +hendes | her/hers +været | be +thi | for (conj) +jer | you +sådan | such, like this/like that diff --git a/resources/cache/empty/relation/conf/lang/stopwords_de.txt b/resources/cache/empty/relation/conf/lang/stopwords_de.txt index bb9933ee..86525e7a 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_de.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_de.txt @@ -1,294 +1,294 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/german/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A German stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - | The number of forms in this list is reduced significantly by passing it - | through the German stemmer. - - -aber | but - -alle | all -allem -allen -aller -alles - -als | than, as -also | so -am | an + dem -an | at - -ander | other -andere -anderem -anderen -anderer -anderes -anderm -andern -anderr -anders - -auch | also -auf | on -aus | out of -bei | by -bin | am -bis | until -bist | art -da | there -damit | with it -dann | then - -der | the -den -des -dem -die -das - -daß | that - -derselbe | the same -derselben -denselben -desselben -demselben -dieselbe -dieselben -dasselbe - -dazu | to that - -dein | thy -deine -deinem -deinen -deiner -deines - -denn | because - -derer | of those -dessen | of him - -dich | thee -dir | to thee -du | thou - -dies | this -diese -diesem -diesen -dieser -dieses - - -doch | (several meanings) -dort | (over) there - - -durch | through - -ein | a -eine -einem -einen -einer -eines - -einig | some -einige -einigem -einigen -einiger -einiges - -einmal | once - -er | he -ihn | him -ihm | to him - -es | it -etwas | something - -euer | your -eure -eurem -euren -eurer -eures - -für | for -gegen | towards -gewesen | p.p. of sein -hab | have -habe | have -haben | have -hat | has -hatte | had -hatten | had -hier | here -hin | there -hinter | behind - -ich | I -mich | me -mir | to me - - -ihr | you, to her -ihre -ihrem -ihren -ihrer -ihres -euch | to you - -im | in + dem -in | in -indem | while -ins | in + das -ist | is - -jede | each, every -jedem -jeden -jeder -jedes - -jene | that -jenem -jenen -jener -jenes - -jetzt | now -kann | can - -kein | no -keine -keinem -keinen -keiner -keines - -können | can -könnte | could -machen | do -man | one - -manche | some, many a -manchem -manchen -mancher -manches - -mein | my -meine -meinem -meinen -meiner -meines - -mit | with -muss | must -musste | had to -nach | to(wards) -nicht | not -nichts | nothing -noch | still, yet -nun | now -nur | only -ob | whether -oder | or -ohne | without -sehr | very - -sein | his -seine -seinem -seinen -seiner -seines - -selbst | self -sich | herself - -sie | they, she -ihnen | to them - -sind | are -so | so - -solche | such -solchem -solchen -solcher -solches - -soll | shall -sollte | should -sondern | but -sonst | else -über | over -um | about, around -und | and - -uns | us -unse -unsem -unsen -unser -unses - -unter | under -viel | much -vom | von + dem -von | from -vor | before -während | while -war | was -waren | were -warst | wast -was | what -weg | away, off -weil | because -weiter | further - -welche | which -welchem -welchen -welcher -welches - -wenn | when -werde | will -werden | will -wie | how -wieder | again -will | want -wir | we -wird | will -wirst | willst -wo | where -wollen | want -wollte | wanted -würde | would -würden | would -zu | to -zum | zu + dem -zur | zu + der -zwar | indeed -zwischen | between - + | From svn.tartarus.org/snowball/trunk/website/algorithms/german/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A German stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + | The number of forms in this list is reduced significantly by passing it + | through the German stemmer. + + +aber | but + +alle | all +allem +allen +aller +alles + +als | than, as +also | so +am | an + dem +an | at + +ander | other +andere +anderem +anderen +anderer +anderes +anderm +andern +anderr +anders + +auch | also +auf | on +aus | out of +bei | by +bin | am +bis | until +bist | art +da | there +damit | with it +dann | then + +der | the +den +des +dem +die +das + +daß | that + +derselbe | the same +derselben +denselben +desselben +demselben +dieselbe +dieselben +dasselbe + +dazu | to that + +dein | thy +deine +deinem +deinen +deiner +deines + +denn | because + +derer | of those +dessen | of him + +dich | thee +dir | to thee +du | thou + +dies | this +diese +diesem +diesen +dieser +dieses + + +doch | (several meanings) +dort | (over) there + + +durch | through + +ein | a +eine +einem +einen +einer +eines + +einig | some +einige +einigem +einigen +einiger +einiges + +einmal | once + +er | he +ihn | him +ihm | to him + +es | it +etwas | something + +euer | your +eure +eurem +euren +eurer +eures + +für | for +gegen | towards +gewesen | p.p. of sein +hab | have +habe | have +haben | have +hat | has +hatte | had +hatten | had +hier | here +hin | there +hinter | behind + +ich | I +mich | me +mir | to me + + +ihr | you, to her +ihre +ihrem +ihren +ihrer +ihres +euch | to you + +im | in + dem +in | in +indem | while +ins | in + das +ist | is + +jede | each, every +jedem +jeden +jeder +jedes + +jene | that +jenem +jenen +jener +jenes + +jetzt | now +kann | can + +kein | no +keine +keinem +keinen +keiner +keines + +können | can +könnte | could +machen | do +man | one + +manche | some, many a +manchem +manchen +mancher +manches + +mein | my +meine +meinem +meinen +meiner +meines + +mit | with +muss | must +musste | had to +nach | to(wards) +nicht | not +nichts | nothing +noch | still, yet +nun | now +nur | only +ob | whether +oder | or +ohne | without +sehr | very + +sein | his +seine +seinem +seinen +seiner +seines + +selbst | self +sich | herself + +sie | they, she +ihnen | to them + +sind | are +so | so + +solche | such +solchem +solchen +solcher +solches + +soll | shall +sollte | should +sondern | but +sonst | else +über | over +um | about, around +und | and + +uns | us +unse +unsem +unsen +unser +unses + +unter | under +viel | much +vom | von + dem +von | from +vor | before +während | while +war | was +waren | were +warst | wast +was | what +weg | away, off +weil | because +weiter | further + +welche | which +welchem +welchen +welcher +welches + +wenn | when +werde | will +werden | will +wie | how +wieder | again +will | want +wir | we +wird | will +wirst | willst +wo | where +wollen | want +wollte | wanted +würde | would +würden | would +zu | to +zum | zu + dem +zur | zu + der +zwar | indeed +zwischen | between + diff --git a/resources/cache/empty/relation/conf/lang/stopwords_el.txt b/resources/cache/empty/relation/conf/lang/stopwords_el.txt index a5abfbec..232681f5 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_el.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_el.txt @@ -1,78 +1,78 @@ -# Lucene Greek Stopwords list -# Note: by default this file is used after GreekLowerCaseFilter, -# so when modifying this file use 'σ' instead of 'ς' -ο -η -το -οι -τα -του -τησ -των -τον -την -και -κι -κ -ειμαι -εισαι -ειναι -ειμαστε -ειστε -στο -στον -στη -στην -μα -αλλα -απο -για -προσ -με -σε -ωσ -παρα -αντι -κατα -μετα -θα -να -δε -δεν -μη -μην -επι -ενω -εαν -αν -τοτε -που -πωσ -ποιοσ -ποια -ποιο -ποιοι -ποιεσ -ποιων -ποιουσ -αυτοσ -αυτη -αυτο -αυτοι -αυτων -αυτουσ -αυτεσ -αυτα -εκεινοσ -εκεινη -εκεινο -εκεινοι -εκεινεσ -εκεινα -εκεινων -εκεινουσ -οπωσ -ομωσ -ισωσ -οσο -οτι +# Lucene Greek Stopwords list +# Note: by default this file is used after GreekLowerCaseFilter, +# so when modifying this file use 'σ' instead of 'ς' +ο +η +το +οι +τα +του +τησ +των +τον +την +και +κι +κ +ειμαι +εισαι +ειναι +ειμαστε +ειστε +στο +στον +στη +στην +μα +αλλα +απο +για +προσ +με +σε +ωσ +παρα +αντι +κατα +μετα +θα +να +δε +δεν +μη +μην +επι +ενω +εαν +αν +τοτε +που +πωσ +ποιοσ +ποια +ποιο +ποιοι +ποιεσ +ποιων +ποιουσ +αυτοσ +αυτη +αυτο +αυτοι +αυτων +αυτουσ +αυτεσ +αυτα +εκεινοσ +εκεινη +εκεινο +εκεινοι +εκεινεσ +εκεινα +εκεινων +εκεινουσ +οπωσ +ομωσ +ισωσ +οσο +οτι diff --git a/resources/cache/empty/relation/conf/lang/stopwords_en.txt b/resources/cache/empty/relation/conf/lang/stopwords_en.txt index 224230c5..2c164c0b 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_en.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_en.txt @@ -1,54 +1,54 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# a couple of test stopwords to test that the words are really being -# configured from this file: -stopworda -stopwordb - -# Standard english stop words taken from Lucene's StopAnalyzer -a -an -and -are -as -at -be -but -by -for -if -in -into -is -it -no -not -of -on -or -such -that -the -their -then -there -these -they -this -to -was -will -with +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# a couple of test stopwords to test that the words are really being +# configured from this file: +stopworda +stopwordb + +# Standard english stop words taken from Lucene's StopAnalyzer +a +an +and +are +as +at +be +but +by +for +if +in +into +is +it +no +not +of +on +or +such +that +the +their +then +there +these +they +this +to +was +will +with diff --git a/resources/cache/empty/relation/conf/lang/stopwords_es.txt b/resources/cache/empty/relation/conf/lang/stopwords_es.txt index 99afd937..487d78c8 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_es.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_es.txt @@ -1,356 +1,356 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/spanish/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Spanish stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - - | The following is a ranked list (commonest to rarest) of stopwords - | deriving from a large sample of text. - - | Extra words have been added at the end. - -de | from, of -la | the, her -que | who, that -el | the -en | in -y | and -a | to -los | the, them -del | de + el -se | himself, from him etc -las | the, them -por | for, by, etc -un | a -para | for -con | with -no | no -una | a -su | his, her -al | a + el - | es from SER -lo | him -como | how -más | more -pero | pero -sus | su plural -le | to him, her -ya | already -o | or - | fue from SER -este | this - | ha from HABER -sí | himself etc -porque | because -esta | this - | son from SER -entre | between - | está from ESTAR -cuando | when -muy | very -sin | without -sobre | on - | ser from SER - | tiene from TENER -también | also -me | me -hasta | until -hay | there is/are -donde | where - | han from HABER -quien | whom, that - | están from ESTAR - | estado from ESTAR -desde | from -todo | all -nos | us -durante | during - | estados from ESTAR -todos | all -uno | a -les | to them -ni | nor -contra | against -otros | other - | fueron from SER -ese | that -eso | that - | había from HABER -ante | before -ellos | they -e | and (variant of y) -esto | this -mí | me -antes | before -algunos | some -qué | what? -unos | a -yo | I -otro | other -otras | other -otra | other -él | he -tanto | so much, many -esa | that -estos | these -mucho | much, many -quienes | who -nada | nothing -muchos | many -cual | who - | sea from SER -poco | few -ella | she -estar | to be - | haber from HABER -estas | these - | estaba from ESTAR - | estamos from ESTAR -algunas | some -algo | something -nosotros | we - - | other forms - -mi | me -mis | mi plural -tú | thou -te | thee -ti | thee -tu | thy -tus | tu plural -ellas | they -nosotras | we -vosotros | you -vosotras | you -os | you -mío | mine -mía | -míos | -mías | -tuyo | thine -tuya | -tuyos | -tuyas | -suyo | his, hers, theirs -suya | -suyos | -suyas | -nuestro | ours -nuestra | -nuestros | -nuestras | -vuestro | yours -vuestra | -vuestros | -vuestras | -esos | those -esas | those - - | forms of estar, to be (not including the infinitive): -estoy -estás -está -estamos -estáis -están -esté -estés -estemos -estéis -estén -estaré -estarás -estará -estaremos -estaréis -estarán -estaría -estarías -estaríamos -estaríais -estarían -estaba -estabas -estábamos -estabais -estaban -estuve -estuviste -estuvo -estuvimos -estuvisteis -estuvieron -estuviera -estuvieras -estuviéramos -estuvierais -estuvieran -estuviese -estuvieses -estuviésemos -estuvieseis -estuviesen -estando -estado -estada -estados -estadas -estad - - | forms of haber, to have (not including the infinitive): -he -has -ha -hemos -habéis -han -haya -hayas -hayamos -hayáis -hayan -habré -habrás -habrá -habremos -habréis -habrán -habría -habrías -habríamos -habríais -habrían -había -habías -habíamos -habíais -habían -hube -hubiste -hubo -hubimos -hubisteis -hubieron -hubiera -hubieras -hubiéramos -hubierais -hubieran -hubiese -hubieses -hubiésemos -hubieseis -hubiesen -habiendo -habido -habida -habidos -habidas - - | forms of ser, to be (not including the infinitive): -soy -eres -es -somos -sois -son -sea -seas -seamos -seáis -sean -seré -serás -será -seremos -seréis -serán -sería -serías -seríamos -seríais -serían -era -eras -éramos -erais -eran -fui -fuiste -fue -fuimos -fuisteis -fueron -fuera -fueras -fuéramos -fuerais -fueran -fuese -fueses -fuésemos -fueseis -fuesen -siendo -sido - | sed also means 'thirst' - - | forms of tener, to have (not including the infinitive): -tengo -tienes -tiene -tenemos -tenéis -tienen -tenga -tengas -tengamos -tengáis -tengan -tendré -tendrás -tendrá -tendremos -tendréis -tendrán -tendría -tendrías -tendríamos -tendríais -tendrían -tenía -tenías -teníamos -teníais -tenían -tuve -tuviste -tuvo -tuvimos -tuvisteis -tuvieron -tuviera -tuvieras -tuviéramos -tuvierais -tuvieran -tuviese -tuvieses -tuviésemos -tuvieseis -tuviesen -teniendo -tenido -tenida -tenidos -tenidas -tened - + | From svn.tartarus.org/snowball/trunk/website/algorithms/spanish/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Spanish stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + + | The following is a ranked list (commonest to rarest) of stopwords + | deriving from a large sample of text. + + | Extra words have been added at the end. + +de | from, of +la | the, her +que | who, that +el | the +en | in +y | and +a | to +los | the, them +del | de + el +se | himself, from him etc +las | the, them +por | for, by, etc +un | a +para | for +con | with +no | no +una | a +su | his, her +al | a + el + | es from SER +lo | him +como | how +más | more +pero | pero +sus | su plural +le | to him, her +ya | already +o | or + | fue from SER +este | this + | ha from HABER +sí | himself etc +porque | because +esta | this + | son from SER +entre | between + | está from ESTAR +cuando | when +muy | very +sin | without +sobre | on + | ser from SER + | tiene from TENER +también | also +me | me +hasta | until +hay | there is/are +donde | where + | han from HABER +quien | whom, that + | están from ESTAR + | estado from ESTAR +desde | from +todo | all +nos | us +durante | during + | estados from ESTAR +todos | all +uno | a +les | to them +ni | nor +contra | against +otros | other + | fueron from SER +ese | that +eso | that + | había from HABER +ante | before +ellos | they +e | and (variant of y) +esto | this +mí | me +antes | before +algunos | some +qué | what? +unos | a +yo | I +otro | other +otras | other +otra | other +él | he +tanto | so much, many +esa | that +estos | these +mucho | much, many +quienes | who +nada | nothing +muchos | many +cual | who + | sea from SER +poco | few +ella | she +estar | to be + | haber from HABER +estas | these + | estaba from ESTAR + | estamos from ESTAR +algunas | some +algo | something +nosotros | we + + | other forms + +mi | me +mis | mi plural +tú | thou +te | thee +ti | thee +tu | thy +tus | tu plural +ellas | they +nosotras | we +vosotros | you +vosotras | you +os | you +mío | mine +mía | +míos | +mías | +tuyo | thine +tuya | +tuyos | +tuyas | +suyo | his, hers, theirs +suya | +suyos | +suyas | +nuestro | ours +nuestra | +nuestros | +nuestras | +vuestro | yours +vuestra | +vuestros | +vuestras | +esos | those +esas | those + + | forms of estar, to be (not including the infinitive): +estoy +estás +está +estamos +estáis +están +esté +estés +estemos +estéis +estén +estaré +estarás +estará +estaremos +estaréis +estarán +estaría +estarías +estaríamos +estaríais +estarían +estaba +estabas +estábamos +estabais +estaban +estuve +estuviste +estuvo +estuvimos +estuvisteis +estuvieron +estuviera +estuvieras +estuviéramos +estuvierais +estuvieran +estuviese +estuvieses +estuviésemos +estuvieseis +estuviesen +estando +estado +estada +estados +estadas +estad + + | forms of haber, to have (not including the infinitive): +he +has +ha +hemos +habéis +han +haya +hayas +hayamos +hayáis +hayan +habré +habrás +habrá +habremos +habréis +habrán +habría +habrías +habríamos +habríais +habrían +había +habías +habíamos +habíais +habían +hube +hubiste +hubo +hubimos +hubisteis +hubieron +hubiera +hubieras +hubiéramos +hubierais +hubieran +hubiese +hubieses +hubiésemos +hubieseis +hubiesen +habiendo +habido +habida +habidos +habidas + + | forms of ser, to be (not including the infinitive): +soy +eres +es +somos +sois +son +sea +seas +seamos +seáis +sean +seré +serás +será +seremos +seréis +serán +sería +serías +seríamos +seríais +serían +era +eras +éramos +erais +eran +fui +fuiste +fue +fuimos +fuisteis +fueron +fuera +fueras +fuéramos +fuerais +fueran +fuese +fueses +fuésemos +fueseis +fuesen +siendo +sido + | sed also means 'thirst' + + | forms of tener, to have (not including the infinitive): +tengo +tienes +tiene +tenemos +tenéis +tienen +tenga +tengas +tengamos +tengáis +tengan +tendré +tendrás +tendrá +tendremos +tendréis +tendrán +tendría +tendrías +tendríamos +tendríais +tendrían +tenía +tenías +teníamos +teníais +tenían +tuve +tuviste +tuvo +tuvimos +tuvisteis +tuvieron +tuviera +tuvieras +tuviéramos +tuvierais +tuvieran +tuviese +tuvieses +tuviésemos +tuvieseis +tuviesen +teniendo +tenido +tenida +tenidos +tenidas +tened + diff --git a/resources/cache/empty/relation/conf/lang/stopwords_eu.txt b/resources/cache/empty/relation/conf/lang/stopwords_eu.txt index 7e4e4bb3..25f1db93 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_eu.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_eu.txt @@ -1,99 +1,99 @@ -# example set of basque stopwords -al -anitz -arabera -asko -baina -bat -batean -batek -bati -batzuei -batzuek -batzuetan -batzuk -bera -beraiek -berau -berauek -bere -berori -beroriek -beste -bezala -da -dago -dira -ditu -du -dute -edo -egin -ere -eta -eurak -ez -gainera -gu -gutxi -guzti -haiei -haiek -haietan -hainbeste -hala -han -handik -hango -hara -hari -hark -hartan -hau -hauei -hauek -hauetan -hemen -hemendik -hemengo -hi -hona -honek -honela -honetan -honi -hor -hori -horiei -horiek -horietan -horko -horra -horrek -horrela -horretan -horri -hortik -hura -izan -ni -noiz -nola -non -nondik -nongo -nor -nora -ze -zein -zen -zenbait -zenbat -zer -zergatik -ziren -zituen -zu -zuek -zuen -zuten +# example set of basque stopwords +al +anitz +arabera +asko +baina +bat +batean +batek +bati +batzuei +batzuek +batzuetan +batzuk +bera +beraiek +berau +berauek +bere +berori +beroriek +beste +bezala +da +dago +dira +ditu +du +dute +edo +egin +ere +eta +eurak +ez +gainera +gu +gutxi +guzti +haiei +haiek +haietan +hainbeste +hala +han +handik +hango +hara +hari +hark +hartan +hau +hauei +hauek +hauetan +hemen +hemendik +hemengo +hi +hona +honek +honela +honetan +honi +hor +hori +horiei +horiek +horietan +horko +horra +horrek +horrela +horretan +horri +hortik +hura +izan +ni +noiz +nola +non +nondik +nongo +nor +nora +ze +zein +zen +zenbait +zenbat +zer +zergatik +ziren +zituen +zu +zuek +zuen +zuten diff --git a/resources/cache/empty/relation/conf/lang/stopwords_fa.txt b/resources/cache/empty/relation/conf/lang/stopwords_fa.txt index 76bb6354..723641c6 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_fa.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_fa.txt @@ -1,313 +1,313 @@ -# This file was created by Jacques Savoy and is distributed under the BSD license. -# See http://members.unine.ch/jacques.savoy/clef/index.html. -# Also see http://www.opensource.org/licenses/bsd-license.html -# Note: by default this file is used after normalization, so when adding entries -# to this file, use the arabic 'ي' instead of 'ی' -انان -نداشته -سراسر -خياه -ايشان -وي -تاكنون -بيشتري -دوم -پس -ناشي -وگو -يا -داشتند -سپس -هنگام -هرگز -پنج -نشان -امسال -ديگر -گروهي -شدند -چطور -ده -و -دو -نخستين -ولي -چرا -چه -وسط -ه -كدام -قابل -يك -رفت -هفت -همچنين -در -هزار -بله -بلي -شايد -اما -شناسي -گرفته -دهد -داشته -دانست -داشتن -خواهيم -ميليارد -وقتيكه -امد -خواهد -جز -اورده -شده -بلكه -خدمات -شدن -برخي -نبود -بسياري -جلوگيري -حق -كردند -نوعي -بعري -نكرده -نظير -نبايد -بوده -بودن -داد -اورد -هست -جايي -شود -دنبال -داده -بايد -سابق -هيچ -همان -انجا -كمتر -كجاست -گردد -كسي -تر -مردم -تان -دادن -بودند -سري -جدا -ندارند -مگر -يكديگر -دارد -دهند -بنابراين -هنگامي -سمت -جا -انچه -خود -دادند -زياد -دارند -اثر -بدون -بهترين -بيشتر -البته -به -براساس -بيرون -كرد -بعضي -گرفت -توي -اي -ميليون -او -جريان -تول -بر -مانند -برابر -باشيم -مدتي -گويند -اكنون -تا -تنها -جديد -چند -بي -نشده -كردن -كردم -گويد -كرده -كنيم -نمي -نزد -روي -قصد -فقط -بالاي -ديگران -اين -ديروز -توسط -سوم -ايم -دانند -سوي -استفاده -شما -كنار -داريم -ساخته -طور -امده -رفته -نخست -بيست -نزديك -طي -كنيد -از -انها -تمامي -داشت -يكي -طريق -اش -چيست -روب -نمايد -گفت -چندين -چيزي -تواند -ام -ايا -با -ان -ايد -ترين -اينكه -ديگري -راه -هايي -بروز -همچنان -پاعين -كس -حدود -مختلف -مقابل -چيز -گيرد -ندارد -ضد -همچون -سازي -شان -مورد -باره -مرسي -خويش -برخوردار -چون -خارج -شش -هنوز -تحت -ضمن -هستيم -گفته -فكر -بسيار -پيش -براي -روزهاي -انكه -نخواهد -بالا -كل -وقتي -كي -چنين -كه -گيري -نيست -است -كجا -كند -نيز -يابد -بندي -حتي -توانند -عقب -خواست -كنند -بين -تمام -همه -ما -باشند -مثل -شد -اري -باشد -اره -طبق -بعد -اگر -صورت -غير -جاي -بيش -ريزي -اند -زيرا -چگونه -بار -لطفا -مي -درباره -من -ديده -همين -گذاري -برداري -علت -گذاشته -هم -فوق -نه -ها -شوند -اباد -همواره -هر -اول -خواهند -چهار -نام -امروز -مان -هاي -قبل -كنم -سعي -تازه -را -هستند -زير -جلوي -عنوان -بود +# This file was created by Jacques Savoy and is distributed under the BSD license. +# See http://members.unine.ch/jacques.savoy/clef/index.html. +# Also see http://www.opensource.org/licenses/bsd-license.html +# Note: by default this file is used after normalization, so when adding entries +# to this file, use the arabic 'ي' instead of 'ی' +انان +نداشته +سراسر +خياه +ايشان +وي +تاكنون +بيشتري +دوم +پس +ناشي +وگو +يا +داشتند +سپس +هنگام +هرگز +پنج +نشان +امسال +ديگر +گروهي +شدند +چطور +ده +و +دو +نخستين +ولي +چرا +چه +وسط +ه +كدام +قابل +يك +رفت +هفت +همچنين +در +هزار +بله +بلي +شايد +اما +شناسي +گرفته +دهد +داشته +دانست +داشتن +خواهيم +ميليارد +وقتيكه +امد +خواهد +جز +اورده +شده +بلكه +خدمات +شدن +برخي +نبود +بسياري +جلوگيري +حق +كردند +نوعي +بعري +نكرده +نظير +نبايد +بوده +بودن +داد +اورد +هست +جايي +شود +دنبال +داده +بايد +سابق +هيچ +همان +انجا +كمتر +كجاست +گردد +كسي +تر +مردم +تان +دادن +بودند +سري +جدا +ندارند +مگر +يكديگر +دارد +دهند +بنابراين +هنگامي +سمت +جا +انچه +خود +دادند +زياد +دارند +اثر +بدون +بهترين +بيشتر +البته +به +براساس +بيرون +كرد +بعضي +گرفت +توي +اي +ميليون +او +جريان +تول +بر +مانند +برابر +باشيم +مدتي +گويند +اكنون +تا +تنها +جديد +چند +بي +نشده +كردن +كردم +گويد +كرده +كنيم +نمي +نزد +روي +قصد +فقط +بالاي +ديگران +اين +ديروز +توسط +سوم +ايم +دانند +سوي +استفاده +شما +كنار +داريم +ساخته +طور +امده +رفته +نخست +بيست +نزديك +طي +كنيد +از +انها +تمامي +داشت +يكي +طريق +اش +چيست +روب +نمايد +گفت +چندين +چيزي +تواند +ام +ايا +با +ان +ايد +ترين +اينكه +ديگري +راه +هايي +بروز +همچنان +پاعين +كس +حدود +مختلف +مقابل +چيز +گيرد +ندارد +ضد +همچون +سازي +شان +مورد +باره +مرسي +خويش +برخوردار +چون +خارج +شش +هنوز +تحت +ضمن +هستيم +گفته +فكر +بسيار +پيش +براي +روزهاي +انكه +نخواهد +بالا +كل +وقتي +كي +چنين +كه +گيري +نيست +است +كجا +كند +نيز +يابد +بندي +حتي +توانند +عقب +خواست +كنند +بين +تمام +همه +ما +باشند +مثل +شد +اري +باشد +اره +طبق +بعد +اگر +صورت +غير +جاي +بيش +ريزي +اند +زيرا +چگونه +بار +لطفا +مي +درباره +من +ديده +همين +گذاري +برداري +علت +گذاشته +هم +فوق +نه +ها +شوند +اباد +همواره +هر +اول +خواهند +چهار +نام +امروز +مان +هاي +قبل +كنم +سعي +تازه +را +هستند +زير +جلوي +عنوان +بود diff --git a/resources/cache/empty/relation/conf/lang/stopwords_fi.txt b/resources/cache/empty/relation/conf/lang/stopwords_fi.txt index 4d70da3b..4372c9a0 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_fi.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_fi.txt @@ -1,97 +1,97 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/finnish/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - -| forms of BE - -olla -olen -olet -on -olemme -olette -ovat -ole | negative form - -oli -olisi -olisit -olisin -olisimme -olisitte -olisivat -olit -olin -olimme -olitte -olivat -ollut -olleet - -en | negation -et -ei -emme -ette -eivät - -|Nom Gen Acc Part Iness Elat Illat Adess Ablat Allat Ess Trans -minä minun minut minua minussa minusta minuun minulla minulta minulle | I -sinä sinun sinut sinua sinussa sinusta sinuun sinulla sinulta sinulle | you -hän hänen hänet häntä hänessä hänestä häneen hänellä häneltä hänelle | he she -me meidän meidät meitä meissä meistä meihin meillä meiltä meille | we -te teidän teidät teitä teissä teistä teihin teillä teiltä teille | you -he heidän heidät heitä heissä heistä heihin heillä heiltä heille | they - -tämä tämän tätä tässä tästä tähän tallä tältä tälle tänä täksi | this -tuo tuon tuotä tuossa tuosta tuohon tuolla tuolta tuolle tuona tuoksi | that -se sen sitä siinä siitä siihen sillä siltä sille sinä siksi | it -nämä näiden näitä näissä näistä näihin näillä näiltä näille näinä näiksi | these -nuo noiden noita noissa noista noihin noilla noilta noille noina noiksi | those -ne niiden niitä niissä niistä niihin niillä niiltä niille niinä niiksi | they - -kuka kenen kenet ketä kenessä kenestä keneen kenellä keneltä kenelle kenenä keneksi| who -ketkä keiden ketkä keitä keissä keistä keihin keillä keiltä keille keinä keiksi | (pl) -mikä minkä minkä mitä missä mistä mihin millä miltä mille minä miksi | which what -mitkä | (pl) - -joka jonka jota jossa josta johon jolla jolta jolle jona joksi | who which -jotka joiden joita joissa joista joihin joilla joilta joille joina joiksi | (pl) - -| conjunctions - -että | that -ja | and -jos | if -koska | because -kuin | than -mutta | but -niin | so -sekä | and -sillä | for -tai | or -vaan | but -vai | or -vaikka | although - - -| prepositions - -kanssa | with -mukaan | according to -noin | about -poikki | across -yli | over, across - -| other - -kun | when -niin | so -nyt | now -itse | self - + | From svn.tartarus.org/snowball/trunk/website/algorithms/finnish/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + +| forms of BE + +olla +olen +olet +on +olemme +olette +ovat +ole | negative form + +oli +olisi +olisit +olisin +olisimme +olisitte +olisivat +olit +olin +olimme +olitte +olivat +ollut +olleet + +en | negation +et +ei +emme +ette +eivät + +|Nom Gen Acc Part Iness Elat Illat Adess Ablat Allat Ess Trans +minä minun minut minua minussa minusta minuun minulla minulta minulle | I +sinä sinun sinut sinua sinussa sinusta sinuun sinulla sinulta sinulle | you +hän hänen hänet häntä hänessä hänestä häneen hänellä häneltä hänelle | he she +me meidän meidät meitä meissä meistä meihin meillä meiltä meille | we +te teidän teidät teitä teissä teistä teihin teillä teiltä teille | you +he heidän heidät heitä heissä heistä heihin heillä heiltä heille | they + +tämä tämän tätä tässä tästä tähän tallä tältä tälle tänä täksi | this +tuo tuon tuotä tuossa tuosta tuohon tuolla tuolta tuolle tuona tuoksi | that +se sen sitä siinä siitä siihen sillä siltä sille sinä siksi | it +nämä näiden näitä näissä näistä näihin näillä näiltä näille näinä näiksi | these +nuo noiden noita noissa noista noihin noilla noilta noille noina noiksi | those +ne niiden niitä niissä niistä niihin niillä niiltä niille niinä niiksi | they + +kuka kenen kenet ketä kenessä kenestä keneen kenellä keneltä kenelle kenenä keneksi| who +ketkä keiden ketkä keitä keissä keistä keihin keillä keiltä keille keinä keiksi | (pl) +mikä minkä minkä mitä missä mistä mihin millä miltä mille minä miksi | which what +mitkä | (pl) + +joka jonka jota jossa josta johon jolla jolta jolle jona joksi | who which +jotka joiden joita joissa joista joihin joilla joilta joille joina joiksi | (pl) + +| conjunctions + +että | that +ja | and +jos | if +koska | because +kuin | than +mutta | but +niin | so +sekä | and +sillä | for +tai | or +vaan | but +vai | or +vaikka | although + + +| prepositions + +kanssa | with +mukaan | according to +noin | about +poikki | across +yli | over, across + +| other + +kun | when +niin | so +nyt | now +itse | self + diff --git a/resources/cache/empty/relation/conf/lang/stopwords_fr.txt b/resources/cache/empty/relation/conf/lang/stopwords_fr.txt index fec33952..749abae6 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_fr.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_fr.txt @@ -1,186 +1,186 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/french/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A French stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - -au | a + le -aux | a + les -avec | with -ce | this -ces | these -dans | with -de | of -des | de + les -du | de + le -elle | she -en | `of them' etc -et | and -eux | them -il | he -je | I -la | the -le | the -leur | their -lui | him -ma | my (fem) -mais | but -me | me -même | same; as in moi-même (myself) etc -mes | me (pl) -moi | me -mon | my (masc) -ne | not -nos | our (pl) -notre | our -nous | we -on | one -ou | where -par | by -pas | not -pour | for -qu | que before vowel -que | that -qui | who -sa | his, her (fem) -se | oneself -ses | his (pl) -son | his, her (masc) -sur | on -ta | thy (fem) -te | thee -tes | thy (pl) -toi | thee -ton | thy (masc) -tu | thou -un | a -une | a -vos | your (pl) -votre | your -vous | you - - | single letter forms - -c | c' -d | d' -j | j' -l | l' -à | to, at -m | m' -n | n' -s | s' -t | t' -y | there - - | forms of être (not including the infinitive): -été -étée -étées -étés -étant -suis -es -est -sommes -êtes -sont -serai -seras -sera -serons -serez -seront -serais -serait -serions -seriez -seraient -étais -était -étions -étiez -étaient -fus -fut -fûmes -fûtes -furent -sois -soit -soyons -soyez -soient -fusse -fusses -fût -fussions -fussiez -fussent - - | forms of avoir (not including the infinitive): -ayant -eu -eue -eues -eus -ai -as -avons -avez -ont -aurai -auras -aura -aurons -aurez -auront -aurais -aurait -aurions -auriez -auraient -avais -avait -avions -aviez -avaient -eut -eûmes -eûtes -eurent -aie -aies -ait -ayons -ayez -aient -eusse -eusses -eût -eussions -eussiez -eussent - - | Later additions (from Jean-Christophe Deschamps) -ceci | this -cela | that -celà | that -cet | this -cette | this -ici | here -ils | they -les | the (pl) -leurs | their (pl) -quel | which -quels | which -quelle | which -quelles | which -sans | without -soi | oneself - + | From svn.tartarus.org/snowball/trunk/website/algorithms/french/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A French stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + +au | a + le +aux | a + les +avec | with +ce | this +ces | these +dans | with +de | of +des | de + les +du | de + le +elle | she +en | `of them' etc +et | and +eux | them +il | he +je | I +la | the +le | the +leur | their +lui | him +ma | my (fem) +mais | but +me | me +même | same; as in moi-même (myself) etc +mes | me (pl) +moi | me +mon | my (masc) +ne | not +nos | our (pl) +notre | our +nous | we +on | one +ou | where +par | by +pas | not +pour | for +qu | que before vowel +que | that +qui | who +sa | his, her (fem) +se | oneself +ses | his (pl) +son | his, her (masc) +sur | on +ta | thy (fem) +te | thee +tes | thy (pl) +toi | thee +ton | thy (masc) +tu | thou +un | a +une | a +vos | your (pl) +votre | your +vous | you + + | single letter forms + +c | c' +d | d' +j | j' +l | l' +à | to, at +m | m' +n | n' +s | s' +t | t' +y | there + + | forms of être (not including the infinitive): +été +étée +étées +étés +étant +suis +es +est +sommes +êtes +sont +serai +seras +sera +serons +serez +seront +serais +serait +serions +seriez +seraient +étais +était +étions +étiez +étaient +fus +fut +fûmes +fûtes +furent +sois +soit +soyons +soyez +soient +fusse +fusses +fût +fussions +fussiez +fussent + + | forms of avoir (not including the infinitive): +ayant +eu +eue +eues +eus +ai +as +avons +avez +ont +aurai +auras +aura +aurons +aurez +auront +aurais +aurait +aurions +auriez +auraient +avais +avait +avions +aviez +avaient +eut +eûmes +eûtes +eurent +aie +aies +ait +ayons +ayez +aient +eusse +eusses +eût +eussions +eussiez +eussent + + | Later additions (from Jean-Christophe Deschamps) +ceci | this +cela | that +celà | that +cet | this +cette | this +ici | here +ils | they +les | the (pl) +leurs | their (pl) +quel | which +quels | which +quelle | which +quelles | which +sans | without +soi | oneself + diff --git a/resources/cache/empty/relation/conf/lang/stopwords_ga.txt b/resources/cache/empty/relation/conf/lang/stopwords_ga.txt index f03e10a9..9ff88d74 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_ga.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_ga.txt @@ -1,110 +1,110 @@ - -a -ach -ag -agus -an -aon -ar -arna -as -b' -ba -beirt -bhúr -caoga -ceathair -ceathrar -chomh -chtó -chuig -chun -cois -céad -cúig -cúigear -d' -daichead -dar -de -deich -deichniúr -den -dhá -do -don -dtí -dá -dár -dó -faoi -faoin -faoina -faoinár -fara -fiche -gach -gan -go -gur -haon -hocht -i -iad -idir -in -ina -ins -inár -is -le -leis -lena -lenár -m' -mar -mo -mé -na -nach -naoi -naonúr -ná -ní -níor -nó -nócha -ocht -ochtar -os -roimh -sa -seacht -seachtar -seachtó -seasca -seisear -siad -sibh -sinn -sna -sé -sí -tar -thar -thú -triúr -trí -trína -trínár -tríocha -tú -um -ár -é -éis -í -ó -ón -óna -ónár + +a +ach +ag +agus +an +aon +ar +arna +as +b' +ba +beirt +bhúr +caoga +ceathair +ceathrar +chomh +chtó +chuig +chun +cois +céad +cúig +cúigear +d' +daichead +dar +de +deich +deichniúr +den +dhá +do +don +dtí +dá +dár +dó +faoi +faoin +faoina +faoinár +fara +fiche +gach +gan +go +gur +haon +hocht +i +iad +idir +in +ina +ins +inár +is +le +leis +lena +lenár +m' +mar +mo +mé +na +nach +naoi +naonúr +ná +ní +níor +nó +nócha +ocht +ochtar +os +roimh +sa +seacht +seachtar +seachtó +seasca +seisear +siad +sibh +sinn +sna +sé +sí +tar +thar +thú +triúr +trí +trína +trínár +tríocha +tú +um +ár +é +éis +í +ó +ón +óna +ónár diff --git a/resources/cache/empty/relation/conf/lang/stopwords_gl.txt b/resources/cache/empty/relation/conf/lang/stopwords_gl.txt index 57803b31..d8760b12 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_gl.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_gl.txt @@ -1,161 +1,161 @@ -# galican stopwords -a -aínda -alí -aquel -aquela -aquelas -aqueles -aquilo -aquí -ao -aos -as -así -á -ben -cando -che -co -coa -comigo -con -connosco -contigo -convosco -coas -cos -cun -cuns -cunha -cunhas -da -dalgunha -dalgunhas -dalgún -dalgúns -das -de -del -dela -delas -deles -desde -deste -do -dos -dun -duns -dunha -dunhas -e -el -ela -elas -eles -en -era -eran -esa -esas -ese -eses -esta -estar -estaba -está -están -este -estes -estiven -estou -eu -é -facer -foi -foron -fun -había -hai -iso -isto -la -las -lle -lles -lo -los -mais -me -meu -meus -min -miña -miñas -moi -na -nas -neste -nin -no -non -nos -nosa -nosas -noso -nosos -nós -nun -nunha -nuns -nunhas -o -os -ou -ó -ós -para -pero -pode -pois -pola -polas -polo -polos -por -que -se -senón -ser -seu -seus -sexa -sido -sobre -súa -súas -tamén -tan -te -ten -teñen -teño -ter -teu -teus -ti -tido -tiña -tiven -túa -túas -un -unha -unhas -uns -vos -vosa -vosas -voso -vosos -vós +# galican stopwords +a +aínda +alí +aquel +aquela +aquelas +aqueles +aquilo +aquí +ao +aos +as +así +á +ben +cando +che +co +coa +comigo +con +connosco +contigo +convosco +coas +cos +cun +cuns +cunha +cunhas +da +dalgunha +dalgunhas +dalgún +dalgúns +das +de +del +dela +delas +deles +desde +deste +do +dos +dun +duns +dunha +dunhas +e +el +ela +elas +eles +en +era +eran +esa +esas +ese +eses +esta +estar +estaba +está +están +este +estes +estiven +estou +eu +é +facer +foi +foron +fun +había +hai +iso +isto +la +las +lle +lles +lo +los +mais +me +meu +meus +min +miña +miñas +moi +na +nas +neste +nin +no +non +nos +nosa +nosas +noso +nosos +nós +nun +nunha +nuns +nunhas +o +os +ou +ó +ós +para +pero +pode +pois +pola +polas +polo +polos +por +que +se +senón +ser +seu +seus +sexa +sido +sobre +súa +súas +tamén +tan +te +ten +teñen +teño +ter +teu +teus +ti +tido +tiña +tiven +túa +túas +un +unha +unhas +uns +vos +vosa +vosas +voso +vosos +vós diff --git a/resources/cache/empty/relation/conf/lang/stopwords_hi.txt b/resources/cache/empty/relation/conf/lang/stopwords_hi.txt index 1f19fd10..86286bb0 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_hi.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_hi.txt @@ -1,235 +1,235 @@ -# Also see http://www.opensource.org/licenses/bsd-license.html -# See http://members.unine.ch/jacques.savoy/clef/index.html. -# This file was created by Jacques Savoy and is distributed under the BSD license. -# Note: by default this file also contains forms normalized by HindiNormalizer -# for spelling variation (see section below), such that it can be used whether or -# not you enable that feature. When adding additional entries to this list, -# please add the normalized form as well. -अंदर -अत -अपना -अपनी -अपने -अभी -आदि -आप -इत्यादि -इन -इनका -इन्हीं -इन्हें -इन्हों -इस -इसका -इसकी -इसके -इसमें -इसी -इसे -उन -उनका -उनकी -उनके -उनको -उन्हीं -उन्हें -उन्हों -उस -उसके -उसी -उसे -एक -एवं -एस -ऐसे -और -कई -कर -करता -करते -करना -करने -करें -कहते -कहा -का -काफ़ी -कि -कितना -किन्हें -किन्हों -किया -किर -किस -किसी -किसे -की -कुछ -कुल -के -को -कोई -कौन -कौनसा -गया -घर -जब -जहाँ -जा -जितना -जिन -जिन्हें -जिन्हों -जिस -जिसे -जीधर -जैसा -जैसे -जो -तक -तब -तरह -तिन -तिन्हें -तिन्हों -तिस -तिसे -तो -था -थी -थे -दबारा -दिया -दुसरा -दूसरे -दो -द्वारा -न -नहीं -ना -निहायत -नीचे -ने -पर -पर -पहले -पूरा -पे -फिर -बनी -बही -बहुत -बाद -बाला -बिलकुल -भी -भीतर -मगर -मानो -मे -में -यदि -यह -यहाँ -यही -या -यिह -ये -रखें -रहा -रहे -ऱ्वासा -लिए -लिये -लेकिन -व -वर्ग -वह -वह -वहाँ -वहीं -वाले -वुह -वे -वग़ैरह -संग -सकता -सकते -सबसे -सभी -साथ -साबुत -साभ -सारा -से -सो -ही -हुआ -हुई -हुए -है -हैं -हो -होता -होती -होते -होना -होने -# additional normalized forms of the above -अपनि -जेसे -होति -सभि -तिंहों -इंहों -दवारा -इसि -किंहें -थि -उंहों -ओर -जिंहें -वहिं -अभि -बनि -हि -उंहिं -उंहें -हें -वगेरह -एसे -रवासा -कोन -निचे -काफि -उसि -पुरा -भितर -हे -बहि -वहां -कोइ -यहां -जिंहों -तिंहें -किसि -कइ -यहि -इंहिं -जिधर -इंहें -अदि -इतयादि -हुइ -कोनसा -इसकि -दुसरे -जहां -अप -किंहों -उनकि -भि -वरग -हुअ -जेसा -नहिं +# Also see http://www.opensource.org/licenses/bsd-license.html +# See http://members.unine.ch/jacques.savoy/clef/index.html. +# This file was created by Jacques Savoy and is distributed under the BSD license. +# Note: by default this file also contains forms normalized by HindiNormalizer +# for spelling variation (see section below), such that it can be used whether or +# not you enable that feature. When adding additional entries to this list, +# please add the normalized form as well. +अंदर +अत +अपना +अपनी +अपने +अभी +आदि +आप +इत्यादि +इन +इनका +इन्हीं +इन्हें +इन्हों +इस +इसका +इसकी +इसके +इसमें +इसी +इसे +उन +उनका +उनकी +उनके +उनको +उन्हीं +उन्हें +उन्हों +उस +उसके +उसी +उसे +एक +एवं +एस +ऐसे +और +कई +कर +करता +करते +करना +करने +करें +कहते +कहा +का +काफ़ी +कि +कितना +किन्हें +किन्हों +किया +किर +किस +किसी +किसे +की +कुछ +कुल +के +को +कोई +कौन +कौनसा +गया +घर +जब +जहाँ +जा +जितना +जिन +जिन्हें +जिन्हों +जिस +जिसे +जीधर +जैसा +जैसे +जो +तक +तब +तरह +तिन +तिन्हें +तिन्हों +तिस +तिसे +तो +था +थी +थे +दबारा +दिया +दुसरा +दूसरे +दो +द्वारा +न +नहीं +ना +निहायत +नीचे +ने +पर +पर +पहले +पूरा +पे +फिर +बनी +बही +बहुत +बाद +बाला +बिलकुल +भी +भीतर +मगर +मानो +मे +में +यदि +यह +यहाँ +यही +या +यिह +ये +रखें +रहा +रहे +ऱ्वासा +लिए +लिये +लेकिन +व +वर्ग +वह +वह +वहाँ +वहीं +वाले +वुह +वे +वग़ैरह +संग +सकता +सकते +सबसे +सभी +साथ +साबुत +साभ +सारा +से +सो +ही +हुआ +हुई +हुए +है +हैं +हो +होता +होती +होते +होना +होने +# additional normalized forms of the above +अपनि +जेसे +होति +सभि +तिंहों +इंहों +दवारा +इसि +किंहें +थि +उंहों +ओर +जिंहें +वहिं +अभि +बनि +हि +उंहिं +उंहें +हें +वगेरह +एसे +रवासा +कोन +निचे +काफि +उसि +पुरा +भितर +हे +बहि +वहां +कोइ +यहां +जिंहों +तिंहें +किसि +कइ +यहि +इंहिं +जिधर +इंहें +अदि +इतयादि +हुइ +कोनसा +इसकि +दुसरे +जहां +अप +किंहों +उनकि +भि +वरग +हुअ +जेसा +नहिं diff --git a/resources/cache/empty/relation/conf/lang/stopwords_hu.txt b/resources/cache/empty/relation/conf/lang/stopwords_hu.txt index f5bf755b..37526da8 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_hu.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_hu.txt @@ -1,211 +1,211 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/hungarian/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - -| Hungarian stop word list -| prepared by Anna Tordai - -a -ahogy -ahol -aki -akik -akkor -alatt -által -általában -amely -amelyek -amelyekben -amelyeket -amelyet -amelynek -ami -amit -amolyan -amíg -amikor -át -abban -ahhoz -annak -arra -arról -az -azok -azon -azt -azzal -azért -aztán -azután -azonban -bár -be -belül -benne -cikk -cikkek -cikkeket -csak -de -e -eddig -egész -egy -egyes -egyetlen -egyéb -egyik -egyre -ekkor -el -elég -ellen -elő -először -előtt -első -én -éppen -ebben -ehhez -emilyen -ennek -erre -ez -ezt -ezek -ezen -ezzel -ezért -és -fel -felé -hanem -hiszen -hogy -hogyan -igen -így -illetve -ill. -ill -ilyen -ilyenkor -ison -ismét -itt -jó -jól -jobban -kell -kellett -keresztül -keressünk -ki -kívül -között -közül -legalább -lehet -lehetett -legyen -lenne -lenni -lesz -lett -maga -magát -majd -majd -már -más -másik -meg -még -mellett -mert -mely -melyek -mi -mit -míg -miért -milyen -mikor -minden -mindent -mindenki -mindig -mint -mintha -mivel -most -nagy -nagyobb -nagyon -ne -néha -nekem -neki -nem -néhány -nélkül -nincs -olyan -ott -össze -ő -ők -őket -pedig -persze -rá -s -saját -sem -semmi -sok -sokat -sokkal -számára -szemben -szerint -szinte -talán -tehát -teljes -tovább -továbbá -több -úgy -ugyanis -új -újabb -újra -után -utána -utolsó -vagy -vagyis -valaki -valami -valamint -való -vagyok -van -vannak -volt -voltam -voltak -voltunk -vissza -vele -viszont -volna + | From svn.tartarus.org/snowball/trunk/website/algorithms/hungarian/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + +| Hungarian stop word list +| prepared by Anna Tordai + +a +ahogy +ahol +aki +akik +akkor +alatt +által +általában +amely +amelyek +amelyekben +amelyeket +amelyet +amelynek +ami +amit +amolyan +amíg +amikor +át +abban +ahhoz +annak +arra +arról +az +azok +azon +azt +azzal +azért +aztán +azután +azonban +bár +be +belül +benne +cikk +cikkek +cikkeket +csak +de +e +eddig +egész +egy +egyes +egyetlen +egyéb +egyik +egyre +ekkor +el +elég +ellen +elő +először +előtt +első +én +éppen +ebben +ehhez +emilyen +ennek +erre +ez +ezt +ezek +ezen +ezzel +ezért +és +fel +felé +hanem +hiszen +hogy +hogyan +igen +így +illetve +ill. +ill +ilyen +ilyenkor +ison +ismét +itt +jó +jól +jobban +kell +kellett +keresztül +keressünk +ki +kívül +között +közül +legalább +lehet +lehetett +legyen +lenne +lenni +lesz +lett +maga +magát +majd +majd +már +más +másik +meg +még +mellett +mert +mely +melyek +mi +mit +míg +miért +milyen +mikor +minden +mindent +mindenki +mindig +mint +mintha +mivel +most +nagy +nagyobb +nagyon +ne +néha +nekem +neki +nem +néhány +nélkül +nincs +olyan +ott +össze +ő +ők +őket +pedig +persze +rá +s +saját +sem +semmi +sok +sokat +sokkal +számára +szemben +szerint +szinte +talán +tehát +teljes +tovább +továbbá +több +úgy +ugyanis +új +újabb +újra +után +utána +utolsó +vagy +vagyis +valaki +valami +valamint +való +vagyok +van +vannak +volt +voltam +voltak +voltunk +vissza +vele +viszont +volna diff --git a/resources/cache/empty/relation/conf/lang/stopwords_hy.txt b/resources/cache/empty/relation/conf/lang/stopwords_hy.txt index 968a8f4a..60c1c50f 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_hy.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_hy.txt @@ -1,46 +1,46 @@ -# example set of Armenian stopwords. -այդ -այլ -այն -այս -դու -դուք -եմ -են -ենք -ես -եք -է -էի -էին -էինք -էիր -էիք -էր -ըստ -թ -ի -ին -իսկ -իր -կամ -համար -հետ -հետո -մենք -մեջ -մի -ն -նա -նաև -նրա -նրանք -որ -որը -որոնք -որպես -ու -ում -պիտի -վրա -և +# example set of Armenian stopwords. +այդ +այլ +այն +այս +դու +դուք +եմ +են +ենք +ես +եք +է +էի +էին +էինք +էիր +էիք +էր +ըստ +թ +ի +ին +իսկ +իր +կամ +համար +հետ +հետո +մենք +մեջ +մի +ն +նա +նաև +նրա +նրանք +որ +որը +որոնք +որպես +ու +ում +պիտի +վրա +և diff --git a/resources/cache/empty/relation/conf/lang/stopwords_id.txt b/resources/cache/empty/relation/conf/lang/stopwords_id.txt index 80df39a3..4617f83a 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_id.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_id.txt @@ -1,359 +1,359 @@ -# from appendix D of: A Study of Stemming Effects on Information -# Retrieval in Bahasa Indonesia -ada -adanya -adalah -adapun -agak -agaknya -agar -akan -akankah -akhirnya -aku -akulah -amat -amatlah -anda -andalah -antar -diantaranya -antara -antaranya -diantara -apa -apaan -mengapa -apabila -apakah -apalagi -apatah -atau -ataukah -ataupun -bagai -bagaikan -sebagai -sebagainya -bagaimana -bagaimanapun -sebagaimana -bagaimanakah -bagi -bahkan -bahwa -bahwasanya -sebaliknya -banyak -sebanyak -beberapa -seberapa -begini -beginian -beginikah -beginilah -sebegini -begitu -begitukah -begitulah -begitupun -sebegitu -belum -belumlah -sebelum -sebelumnya -sebenarnya -berapa -berapakah -berapalah -berapapun -betulkah -sebetulnya -biasa -biasanya -bila -bilakah -bisa -bisakah -sebisanya -boleh -bolehkah -bolehlah -buat -bukan -bukankah -bukanlah -bukannya -cuma -percuma -dahulu -dalam -dan -dapat -dari -daripada -dekat -demi -demikian -demikianlah -sedemikian -dengan -depan -di -dia -dialah -dini -diri -dirinya -terdiri -dong -dulu -enggak -enggaknya -entah -entahlah -terhadap -terhadapnya -hal -hampir -hanya -hanyalah -harus -haruslah -harusnya -seharusnya -hendak -hendaklah -hendaknya -hingga -sehingga -ia -ialah -ibarat -ingin -inginkah -inginkan -ini -inikah -inilah -itu -itukah -itulah -jangan -jangankan -janganlah -jika -jikalau -juga -justru -kala -kalau -kalaulah -kalaupun -kalian -kami -kamilah -kamu -kamulah -kan -kapan -kapankah -kapanpun -dikarenakan -karena -karenanya -ke -kecil -kemudian -kenapa -kepada -kepadanya -ketika -seketika -khususnya -kini -kinilah -kiranya -sekiranya -kita -kitalah -kok -lagi -lagian -selagi -lah -lain -lainnya -melainkan -selaku -lalu -melalui -terlalu -lama -lamanya -selama -selama -selamanya -lebih -terlebih -bermacam -macam -semacam -maka -makanya -makin -malah -malahan -mampu -mampukah -mana -manakala -manalagi -masih -masihkah -semasih -masing -mau -maupun -semaunya -memang -mereka -merekalah -meski -meskipun -semula -mungkin -mungkinkah -nah -namun -nanti -nantinya -nyaris -oleh -olehnya -seorang -seseorang -pada -padanya -padahal -paling -sepanjang -pantas -sepantasnya -sepantasnyalah -para -pasti -pastilah -per -pernah -pula -pun -merupakan -rupanya -serupa -saat -saatnya -sesaat -saja -sajalah -saling -bersama -sama -sesama -sambil -sampai -sana -sangat -sangatlah -saya -sayalah -se -sebab -sebabnya -sebuah -tersebut -tersebutlah -sedang -sedangkan -sedikit -sedikitnya -segala -segalanya -segera -sesegera -sejak -sejenak -sekali -sekalian -sekalipun -sesekali -sekaligus -sekarang -sekarang -sekitar -sekitarnya -sela -selain -selalu -seluruh -seluruhnya -semakin -sementara -sempat -semua -semuanya -sendiri -sendirinya -seolah -seperti -sepertinya -sering -seringnya -serta -siapa -siapakah -siapapun -disini -disinilah -sini -sinilah -sesuatu -sesuatunya -suatu -sesudah -sesudahnya -sudah -sudahkah -sudahlah -supaya -tadi -tadinya -tak -tanpa -setelah -telah -tentang -tentu -tentulah -tentunya -tertentu -seterusnya -tapi -tetapi -setiap -tiap -setidaknya -tidak -tidakkah -tidaklah -toh -waduh -wah -wahai -sewaktu -walau -walaupun -wong -yaitu -yakni -yang +# from appendix D of: A Study of Stemming Effects on Information +# Retrieval in Bahasa Indonesia +ada +adanya +adalah +adapun +agak +agaknya +agar +akan +akankah +akhirnya +aku +akulah +amat +amatlah +anda +andalah +antar +diantaranya +antara +antaranya +diantara +apa +apaan +mengapa +apabila +apakah +apalagi +apatah +atau +ataukah +ataupun +bagai +bagaikan +sebagai +sebagainya +bagaimana +bagaimanapun +sebagaimana +bagaimanakah +bagi +bahkan +bahwa +bahwasanya +sebaliknya +banyak +sebanyak +beberapa +seberapa +begini +beginian +beginikah +beginilah +sebegini +begitu +begitukah +begitulah +begitupun +sebegitu +belum +belumlah +sebelum +sebelumnya +sebenarnya +berapa +berapakah +berapalah +berapapun +betulkah +sebetulnya +biasa +biasanya +bila +bilakah +bisa +bisakah +sebisanya +boleh +bolehkah +bolehlah +buat +bukan +bukankah +bukanlah +bukannya +cuma +percuma +dahulu +dalam +dan +dapat +dari +daripada +dekat +demi +demikian +demikianlah +sedemikian +dengan +depan +di +dia +dialah +dini +diri +dirinya +terdiri +dong +dulu +enggak +enggaknya +entah +entahlah +terhadap +terhadapnya +hal +hampir +hanya +hanyalah +harus +haruslah +harusnya +seharusnya +hendak +hendaklah +hendaknya +hingga +sehingga +ia +ialah +ibarat +ingin +inginkah +inginkan +ini +inikah +inilah +itu +itukah +itulah +jangan +jangankan +janganlah +jika +jikalau +juga +justru +kala +kalau +kalaulah +kalaupun +kalian +kami +kamilah +kamu +kamulah +kan +kapan +kapankah +kapanpun +dikarenakan +karena +karenanya +ke +kecil +kemudian +kenapa +kepada +kepadanya +ketika +seketika +khususnya +kini +kinilah +kiranya +sekiranya +kita +kitalah +kok +lagi +lagian +selagi +lah +lain +lainnya +melainkan +selaku +lalu +melalui +terlalu +lama +lamanya +selama +selama +selamanya +lebih +terlebih +bermacam +macam +semacam +maka +makanya +makin +malah +malahan +mampu +mampukah +mana +manakala +manalagi +masih +masihkah +semasih +masing +mau +maupun +semaunya +memang +mereka +merekalah +meski +meskipun +semula +mungkin +mungkinkah +nah +namun +nanti +nantinya +nyaris +oleh +olehnya +seorang +seseorang +pada +padanya +padahal +paling +sepanjang +pantas +sepantasnya +sepantasnyalah +para +pasti +pastilah +per +pernah +pula +pun +merupakan +rupanya +serupa +saat +saatnya +sesaat +saja +sajalah +saling +bersama +sama +sesama +sambil +sampai +sana +sangat +sangatlah +saya +sayalah +se +sebab +sebabnya +sebuah +tersebut +tersebutlah +sedang +sedangkan +sedikit +sedikitnya +segala +segalanya +segera +sesegera +sejak +sejenak +sekali +sekalian +sekalipun +sesekali +sekaligus +sekarang +sekarang +sekitar +sekitarnya +sela +selain +selalu +seluruh +seluruhnya +semakin +sementara +sempat +semua +semuanya +sendiri +sendirinya +seolah +seperti +sepertinya +sering +seringnya +serta +siapa +siapakah +siapapun +disini +disinilah +sini +sinilah +sesuatu +sesuatunya +suatu +sesudah +sesudahnya +sudah +sudahkah +sudahlah +supaya +tadi +tadinya +tak +tanpa +setelah +telah +tentang +tentu +tentulah +tentunya +tertentu +seterusnya +tapi +tetapi +setiap +tiap +setidaknya +tidak +tidakkah +tidaklah +toh +waduh +wah +wahai +sewaktu +walau +walaupun +wong +yaitu +yakni +yang diff --git a/resources/cache/empty/relation/conf/lang/stopwords_it.txt b/resources/cache/empty/relation/conf/lang/stopwords_it.txt index 3b20c0ab..1219cc77 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_it.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_it.txt @@ -1,303 +1,303 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/italian/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | An Italian stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - -ad | a (to) before vowel -al | a + il -allo | a + lo -ai | a + i -agli | a + gli -all | a + l' -agl | a + gl' -alla | a + la -alle | a + le -con | with -col | con + il -coi | con + i (forms collo, cogli etc are now very rare) -da | from -dal | da + il -dallo | da + lo -dai | da + i -dagli | da + gli -dall | da + l' -dagl | da + gll' -dalla | da + la -dalle | da + le -di | of -del | di + il -dello | di + lo -dei | di + i -degli | di + gli -dell | di + l' -degl | di + gl' -della | di + la -delle | di + le -in | in -nel | in + el -nello | in + lo -nei | in + i -negli | in + gli -nell | in + l' -negl | in + gl' -nella | in + la -nelle | in + le -su | on -sul | su + il -sullo | su + lo -sui | su + i -sugli | su + gli -sull | su + l' -sugl | su + gl' -sulla | su + la -sulle | su + le -per | through, by -tra | among -contro | against -io | I -tu | thou -lui | he -lei | she -noi | we -voi | you -loro | they -mio | my -mia | -miei | -mie | -tuo | -tua | -tuoi | thy -tue | -suo | -sua | -suoi | his, her -sue | -nostro | our -nostra | -nostri | -nostre | -vostro | your -vostra | -vostri | -vostre | -mi | me -ti | thee -ci | us, there -vi | you, there -lo | him, the -la | her, the -li | them -le | them, the -gli | to him, the -ne | from there etc -il | the -un | a -uno | a -una | a -ma | but -ed | and -se | if -perché | why, because -anche | also -come | how -dov | where (as dov') -dove | where -che | who, that -chi | who -cui | whom -non | not -più | more -quale | who, that -quanto | how much -quanti | -quanta | -quante | -quello | that -quelli | -quella | -quelle | -questo | this -questi | -questa | -queste | -si | yes -tutto | all -tutti | all - - | single letter forms: - -a | at -c | as c' for ce or ci -e | and -i | the -l | as l' -o | or - - | forms of avere, to have (not including the infinitive): - -ho -hai -ha -abbiamo -avete -hanno -abbia -abbiate -abbiano -avrò -avrai -avrà -avremo -avrete -avranno -avrei -avresti -avrebbe -avremmo -avreste -avrebbero -avevo -avevi -aveva -avevamo -avevate -avevano -ebbi -avesti -ebbe -avemmo -aveste -ebbero -avessi -avesse -avessimo -avessero -avendo -avuto -avuta -avuti -avute - - | forms of essere, to be (not including the infinitive): -sono -sei -è -siamo -siete -sia -siate -siano -sarò -sarai -sarà -saremo -sarete -saranno -sarei -saresti -sarebbe -saremmo -sareste -sarebbero -ero -eri -era -eravamo -eravate -erano -fui -fosti -fu -fummo -foste -furono -fossi -fosse -fossimo -fossero -essendo - - | forms of fare, to do (not including the infinitive, fa, fat-): -faccio -fai -facciamo -fanno -faccia -facciate -facciano -farò -farai -farà -faremo -farete -faranno -farei -faresti -farebbe -faremmo -fareste -farebbero -facevo -facevi -faceva -facevamo -facevate -facevano -feci -facesti -fece -facemmo -faceste -fecero -facessi -facesse -facessimo -facessero -facendo - - | forms of stare, to be (not including the infinitive): -sto -stai -sta -stiamo -stanno -stia -stiate -stiano -starò -starai -starà -staremo -starete -staranno -starei -staresti -starebbe -staremmo -stareste -starebbero -stavo -stavi -stava -stavamo -stavate -stavano -stetti -stesti -stette -stemmo -steste -stettero -stessi -stesse -stessimo -stessero -stando + | From svn.tartarus.org/snowball/trunk/website/algorithms/italian/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | An Italian stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + +ad | a (to) before vowel +al | a + il +allo | a + lo +ai | a + i +agli | a + gli +all | a + l' +agl | a + gl' +alla | a + la +alle | a + le +con | with +col | con + il +coi | con + i (forms collo, cogli etc are now very rare) +da | from +dal | da + il +dallo | da + lo +dai | da + i +dagli | da + gli +dall | da + l' +dagl | da + gll' +dalla | da + la +dalle | da + le +di | of +del | di + il +dello | di + lo +dei | di + i +degli | di + gli +dell | di + l' +degl | di + gl' +della | di + la +delle | di + le +in | in +nel | in + el +nello | in + lo +nei | in + i +negli | in + gli +nell | in + l' +negl | in + gl' +nella | in + la +nelle | in + le +su | on +sul | su + il +sullo | su + lo +sui | su + i +sugli | su + gli +sull | su + l' +sugl | su + gl' +sulla | su + la +sulle | su + le +per | through, by +tra | among +contro | against +io | I +tu | thou +lui | he +lei | she +noi | we +voi | you +loro | they +mio | my +mia | +miei | +mie | +tuo | +tua | +tuoi | thy +tue | +suo | +sua | +suoi | his, her +sue | +nostro | our +nostra | +nostri | +nostre | +vostro | your +vostra | +vostri | +vostre | +mi | me +ti | thee +ci | us, there +vi | you, there +lo | him, the +la | her, the +li | them +le | them, the +gli | to him, the +ne | from there etc +il | the +un | a +uno | a +una | a +ma | but +ed | and +se | if +perché | why, because +anche | also +come | how +dov | where (as dov') +dove | where +che | who, that +chi | who +cui | whom +non | not +più | more +quale | who, that +quanto | how much +quanti | +quanta | +quante | +quello | that +quelli | +quella | +quelle | +questo | this +questi | +questa | +queste | +si | yes +tutto | all +tutti | all + + | single letter forms: + +a | at +c | as c' for ce or ci +e | and +i | the +l | as l' +o | or + + | forms of avere, to have (not including the infinitive): + +ho +hai +ha +abbiamo +avete +hanno +abbia +abbiate +abbiano +avrò +avrai +avrà +avremo +avrete +avranno +avrei +avresti +avrebbe +avremmo +avreste +avrebbero +avevo +avevi +aveva +avevamo +avevate +avevano +ebbi +avesti +ebbe +avemmo +aveste +ebbero +avessi +avesse +avessimo +avessero +avendo +avuto +avuta +avuti +avute + + | forms of essere, to be (not including the infinitive): +sono +sei +è +siamo +siete +sia +siate +siano +sarò +sarai +sarà +saremo +sarete +saranno +sarei +saresti +sarebbe +saremmo +sareste +sarebbero +ero +eri +era +eravamo +eravate +erano +fui +fosti +fu +fummo +foste +furono +fossi +fosse +fossimo +fossero +essendo + + | forms of fare, to do (not including the infinitive, fa, fat-): +faccio +fai +facciamo +fanno +faccia +facciate +facciano +farò +farai +farà +faremo +farete +faranno +farei +faresti +farebbe +faremmo +fareste +farebbero +facevo +facevi +faceva +facevamo +facevate +facevano +feci +facesti +fece +facemmo +faceste +fecero +facessi +facesse +facessimo +facessero +facendo + + | forms of stare, to be (not including the infinitive): +sto +stai +sta +stiamo +stanno +stia +stiate +stiano +starò +starai +starà +staremo +starete +staranno +starei +staresti +starebbe +staremmo +stareste +starebbero +stavo +stavi +stava +stavamo +stavate +stavano +stetti +stesti +stette +stemmo +steste +stettero +stessi +stesse +stessimo +stessero +stando diff --git a/resources/cache/empty/relation/conf/lang/stopwords_ja.txt b/resources/cache/empty/relation/conf/lang/stopwords_ja.txt index bc3077e5..d4321be6 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_ja.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_ja.txt @@ -1,127 +1,127 @@ -# -# This file defines a stopword set for Japanese. -# -# This set is made up of hand-picked frequent terms from segmented Japanese Wikipedia. -# Punctuation characters and frequent kanji have mostly been left out. See LUCENE-3745 -# for frequency lists, etc. that can be useful for making your own set (if desired) -# -# Note that there is an overlap between these stopwords and the terms stopped when used -# in combination with the JapanesePartOfSpeechStopFilter. When editing this file, note -# that comments are not allowed on the same line as stopwords. -# -# Also note that stopping is done in a case-insensitive manner. Change your StopFilter -# configuration if you need case-sensitive stopping. Lastly, note that stopping is done -# using the same character width as the entries in this file. Since this StopFilter is -# normally done after a CJKWidthFilter in your chain, you would usually want your romaji -# entries to be in half-width and your kana entries to be in full-width. -# -の -に -は -を -た -が -で -て -と -し -れ -さ -ある -いる -も -する -から -な -こと -として -い -や -れる -など -なっ -ない -この -ため -その -あっ -よう -また -もの -という -あり -まで -られ -なる -へ -か -だ -これ -によって -により -おり -より -による -ず -なり -られる -において -ば -なかっ -なく -しかし -について -せ -だっ -その後 -できる -それ -う -ので -なお -のみ -でき -き -つ -における -および -いう -さらに -でも -ら -たり -その他 -に関する -たち -ます -ん -なら -に対して -特に -せる -及び -これら -とき -では -にて -ほか -ながら -うち -そして -とともに -ただし -かつて -それぞれ -または -お -ほど -ものの -に対する -ほとんど -と共に -といった -です -とも -ところ -ここ -##### End of file +# +# This file defines a stopword set for Japanese. +# +# This set is made up of hand-picked frequent terms from segmented Japanese Wikipedia. +# Punctuation characters and frequent kanji have mostly been left out. See LUCENE-3745 +# for frequency lists, etc. that can be useful for making your own set (if desired) +# +# Note that there is an overlap between these stopwords and the terms stopped when used +# in combination with the JapanesePartOfSpeechStopFilter. When editing this file, note +# that comments are not allowed on the same line as stopwords. +# +# Also note that stopping is done in a case-insensitive manner. Change your StopFilter +# configuration if you need case-sensitive stopping. Lastly, note that stopping is done +# using the same character width as the entries in this file. Since this StopFilter is +# normally done after a CJKWidthFilter in your chain, you would usually want your romaji +# entries to be in half-width and your kana entries to be in full-width. +# +の +に +は +を +た +が +で +て +と +し +れ +さ +ある +いる +も +する +から +な +こと +として +い +や +れる +など +なっ +ない +この +ため +その +あっ +よう +また +もの +という +あり +まで +られ +なる +へ +か +だ +これ +によって +により +おり +より +による +ず +なり +られる +において +ば +なかっ +なく +しかし +について +せ +だっ +その後 +できる +それ +う +ので +なお +のみ +でき +き +つ +における +および +いう +さらに +でも +ら +たり +その他 +に関する +たち +ます +ん +なら +に対して +特に +せる +及び +これら +とき +では +にて +ほか +ながら +うち +そして +とともに +ただし +かつて +それぞれ +または +お +ほど +ものの +に対する +ほとんど +と共に +といった +です +とも +ところ +ここ +##### End of file diff --git a/resources/cache/empty/relation/conf/lang/stopwords_lv.txt b/resources/cache/empty/relation/conf/lang/stopwords_lv.txt index a4710974..e21a23c0 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_lv.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_lv.txt @@ -1,172 +1,172 @@ -# Set of Latvian stopwords from A Stemming Algorithm for Latvian, Karlis Kreslins -# the original list of over 800 forms was refined: -# pronouns, adverbs, interjections were removed -# -# prepositions -aiz -ap -ar -apakš -ārpus -augšpus -bez -caur -dēļ -gar -iekš -iz -kopš -labad -lejpus -līdz -no -otrpus -pa -par -pār -pēc -pie -pirms -pret -priekš -starp -šaipus -uz -viņpus -virs -virspus -zem -apakšpus -# Conjunctions -un -bet -jo -ja -ka -lai -tomēr -tikko -turpretī -arī -kaut -gan -tādēļ -tā -ne -tikvien -vien -kā -ir -te -vai -kamēr -# Particles -ar -diezin -droši -diemžēl -nebūt -ik -it -taču -nu -pat -tiklab -iekšpus -nedz -tik -nevis -turpretim -jeb -iekam -iekām -iekāms -kolīdz -līdzko -tiklīdz -jebšu -tālab -tāpēc -nekā -itin -jā -jau -jel -nē -nezin -tad -tikai -vis -tak -iekams -vien -# modal verbs -būt -biju -biji -bija -bijām -bijāt -esmu -esi -esam -esat -būšu -būsi -būs -būsim -būsiet -tikt -tiku -tiki -tika -tikām -tikāt -tieku -tiec -tiek -tiekam -tiekat -tikšu -tiks -tiksim -tiksiet -tapt -tapi -tapāt -topat -tapšu -tapsi -taps -tapsim -tapsiet -kļūt -kļuvu -kļuvi -kļuva -kļuvām -kļuvāt -kļūstu -kļūsti -kļūst -kļūstam -kļūstat -kļūšu -kļūsi -kļūs -kļūsim -kļūsiet -# verbs -varēt -varēju -varējām -varēšu -varēsim -var -varēji -varējāt -varēsi -varēsiet -varat -varēja -varēs +# Set of Latvian stopwords from A Stemming Algorithm for Latvian, Karlis Kreslins +# the original list of over 800 forms was refined: +# pronouns, adverbs, interjections were removed +# +# prepositions +aiz +ap +ar +apakš +ārpus +augšpus +bez +caur +dēļ +gar +iekš +iz +kopš +labad +lejpus +līdz +no +otrpus +pa +par +pār +pēc +pie +pirms +pret +priekš +starp +šaipus +uz +viņpus +virs +virspus +zem +apakšpus +# Conjunctions +un +bet +jo +ja +ka +lai +tomēr +tikko +turpretī +arī +kaut +gan +tādēļ +tā +ne +tikvien +vien +kā +ir +te +vai +kamēr +# Particles +ar +diezin +droši +diemžēl +nebūt +ik +it +taču +nu +pat +tiklab +iekšpus +nedz +tik +nevis +turpretim +jeb +iekam +iekām +iekāms +kolīdz +līdzko +tiklīdz +jebšu +tālab +tāpēc +nekā +itin +jā +jau +jel +nē +nezin +tad +tikai +vis +tak +iekams +vien +# modal verbs +būt +biju +biji +bija +bijām +bijāt +esmu +esi +esam +esat +būšu +būsi +būs +būsim +būsiet +tikt +tiku +tiki +tika +tikām +tikāt +tieku +tiec +tiek +tiekam +tiekat +tikšu +tiks +tiksim +tiksiet +tapt +tapi +tapāt +topat +tapšu +tapsi +taps +tapsim +tapsiet +kļūt +kļuvu +kļuvi +kļuva +kļuvām +kļuvāt +kļūstu +kļūsti +kļūst +kļūstam +kļūstat +kļūšu +kļūsi +kļūs +kļūsim +kļūsiet +# verbs +varēt +varēju +varējām +varēšu +varēsim +var +varēji +varējāt +varēsi +varēsiet +varat +varēja +varēs diff --git a/resources/cache/empty/relation/conf/lang/stopwords_nl.txt b/resources/cache/empty/relation/conf/lang/stopwords_nl.txt index 06ca75ba..47a2aeac 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_nl.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_nl.txt @@ -1,119 +1,119 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/dutch/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Dutch stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - | This is a ranked list (commonest to rarest) of stopwords derived from - | a large sample of Dutch text. - - | Dutch stop words frequently exhibit homonym clashes. These are indicated - | clearly below. - -de | the -en | and -van | of, from -ik | I, the ego -te | (1) chez, at etc, (2) to, (3) too -dat | that, which -die | that, those, who, which -in | in, inside -een | a, an, one -hij | he -het | the, it -niet | not, nothing, naught -zijn | (1) to be, being, (2) his, one's, its -is | is -was | (1) was, past tense of all persons sing. of 'zijn' (to be) (2) wax, (3) the washing, (4) rise of river -op | on, upon, at, in, up, used up -aan | on, upon, to (as dative) -met | with, by -als | like, such as, when -voor | (1) before, in front of, (2) furrow -had | had, past tense all persons sing. of 'hebben' (have) -er | there -maar | but, only -om | round, about, for etc -hem | him -dan | then -zou | should/would, past tense all persons sing. of 'zullen' -of | or, whether, if -wat | what, something, anything -mijn | possessive and noun 'mine' -men | people, 'one' -dit | this -zo | so, thus, in this way -door | through by -over | over, across -ze | she, her, they, them -zich | oneself -bij | (1) a bee, (2) by, near, at -ook | also, too -tot | till, until -je | you -mij | me -uit | out of, from -der | Old Dutch form of 'van der' still found in surnames -daar | (1) there, (2) because -haar | (1) her, their, them, (2) hair -naar | (1) unpleasant, unwell etc, (2) towards, (3) as -heb | present first person sing. of 'to have' -hoe | how, why -heeft | present third person sing. of 'to have' -hebben | 'to have' and various parts thereof -deze | this -u | you -want | (1) for, (2) mitten, (3) rigging -nog | yet, still -zal | 'shall', first and third person sing. of verb 'zullen' (will) -me | me -zij | she, they -nu | now -ge | 'thou', still used in Belgium and south Netherlands -geen | none -omdat | because -iets | something, somewhat -worden | to become, grow, get -toch | yet, still -al | all, every, each -waren | (1) 'were' (2) to wander, (3) wares, (3) -veel | much, many -meer | (1) more, (2) lake -doen | to do, to make -toen | then, when -moet | noun 'spot/mote' and present form of 'to must' -ben | (1) am, (2) 'are' in interrogative second person singular of 'to be' -zonder | without -kan | noun 'can' and present form of 'to be able' -hun | their, them -dus | so, consequently -alles | all, everything, anything -onder | under, beneath -ja | yes, of course -eens | once, one day -hier | here -wie | who -werd | imperfect third person sing. of 'become' -altijd | always -doch | yet, but etc -wordt | present third person sing. of 'become' -wezen | (1) to be, (2) 'been' as in 'been fishing', (3) orphans -kunnen | to be able -ons | us/our -zelf | self -tegen | against, towards, at -na | after, near -reeds | already -wil | (1) present tense of 'want', (2) 'will', noun, (3) fender -kon | could; past tense of 'to be able' -niets | nothing -uw | your -iemand | somebody -geweest | been; past participle of 'be' -andere | other + | From svn.tartarus.org/snowball/trunk/website/algorithms/dutch/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Dutch stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + | This is a ranked list (commonest to rarest) of stopwords derived from + | a large sample of Dutch text. + + | Dutch stop words frequently exhibit homonym clashes. These are indicated + | clearly below. + +de | the +en | and +van | of, from +ik | I, the ego +te | (1) chez, at etc, (2) to, (3) too +dat | that, which +die | that, those, who, which +in | in, inside +een | a, an, one +hij | he +het | the, it +niet | not, nothing, naught +zijn | (1) to be, being, (2) his, one's, its +is | is +was | (1) was, past tense of all persons sing. of 'zijn' (to be) (2) wax, (3) the washing, (4) rise of river +op | on, upon, at, in, up, used up +aan | on, upon, to (as dative) +met | with, by +als | like, such as, when +voor | (1) before, in front of, (2) furrow +had | had, past tense all persons sing. of 'hebben' (have) +er | there +maar | but, only +om | round, about, for etc +hem | him +dan | then +zou | should/would, past tense all persons sing. of 'zullen' +of | or, whether, if +wat | what, something, anything +mijn | possessive and noun 'mine' +men | people, 'one' +dit | this +zo | so, thus, in this way +door | through by +over | over, across +ze | she, her, they, them +zich | oneself +bij | (1) a bee, (2) by, near, at +ook | also, too +tot | till, until +je | you +mij | me +uit | out of, from +der | Old Dutch form of 'van der' still found in surnames +daar | (1) there, (2) because +haar | (1) her, their, them, (2) hair +naar | (1) unpleasant, unwell etc, (2) towards, (3) as +heb | present first person sing. of 'to have' +hoe | how, why +heeft | present third person sing. of 'to have' +hebben | 'to have' and various parts thereof +deze | this +u | you +want | (1) for, (2) mitten, (3) rigging +nog | yet, still +zal | 'shall', first and third person sing. of verb 'zullen' (will) +me | me +zij | she, they +nu | now +ge | 'thou', still used in Belgium and south Netherlands +geen | none +omdat | because +iets | something, somewhat +worden | to become, grow, get +toch | yet, still +al | all, every, each +waren | (1) 'were' (2) to wander, (3) wares, (3) +veel | much, many +meer | (1) more, (2) lake +doen | to do, to make +toen | then, when +moet | noun 'spot/mote' and present form of 'to must' +ben | (1) am, (2) 'are' in interrogative second person singular of 'to be' +zonder | without +kan | noun 'can' and present form of 'to be able' +hun | their, them +dus | so, consequently +alles | all, everything, anything +onder | under, beneath +ja | yes, of course +eens | once, one day +hier | here +wie | who +werd | imperfect third person sing. of 'become' +altijd | always +doch | yet, but etc +wordt | present third person sing. of 'become' +wezen | (1) to be, (2) 'been' as in 'been fishing', (3) orphans +kunnen | to be able +ons | us/our +zelf | self +tegen | against, towards, at +na | after, near +reeds | already +wil | (1) present tense of 'want', (2) 'will', noun, (3) fender +kon | could; past tense of 'to be able' +niets | nothing +uw | your +iemand | somebody +geweest | been; past participle of 'be' +andere | other diff --git a/resources/cache/empty/relation/conf/lang/stopwords_no.txt b/resources/cache/empty/relation/conf/lang/stopwords_no.txt index 8aefda89..a7a2c28b 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_no.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_no.txt @@ -1,194 +1,194 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/norwegian/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Norwegian stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - | This stop word list is for the dominant bokmål dialect. Words unique - | to nynorsk are marked *. - - | Revised by Jan Bruusgaard , Jan 2005 - -og | and -i | in -jeg | I -det | it/this/that -at | to (w. inf.) -en | a/an -et | a/an -den | it/this/that -til | to -er | is/am/are -som | who/that -på | on -de | they / you(formal) -med | with -han | he -av | of -ikke | not -ikkje | not * -der | there -så | so -var | was/were -meg | me -seg | you -men | but -ett | one -har | have -om | about -vi | we -min | my -mitt | my -ha | have -hadde | had -hun | she -nå | now -over | over -da | when/as -ved | by/know -fra | from -du | you -ut | out -sin | your -dem | them -oss | us -opp | up -man | you/one -kan | can -hans | his -hvor | where -eller | or -hva | what -skal | shall/must -selv | self (reflective) -sjøl | self (reflective) -her | here -alle | all -vil | will -bli | become -ble | became -blei | became * -blitt | have become -kunne | could -inn | in -når | when -være | be -kom | come -noen | some -noe | some -ville | would -dere | you -som | who/which/that -deres | their/theirs -kun | only/just -ja | yes -etter | after -ned | down -skulle | should -denne | this -for | for/because -deg | you -si | hers/his -sine | hers/his -sitt | hers/his -mot | against -å | to -meget | much -hvorfor | why -dette | this -disse | these/those -uten | without -hvordan | how -ingen | none -din | your -ditt | your -blir | become -samme | same -hvilken | which -hvilke | which (plural) -sånn | such a -inni | inside/within -mellom | between -vår | our -hver | each -hvem | who -vors | us/ours -hvis | whose -både | both -bare | only/just -enn | than -fordi | as/because -før | before -mange | many -også | also -slik | just -vært | been -være | to be -båe | both * -begge | both -siden | since -dykk | your * -dykkar | yours * -dei | they * -deira | them * -deires | theirs * -deim | them * -di | your (fem.) * -då | as/when * -eg | I * -ein | a/an * -eit | a/an * -eitt | a/an * -elles | or * -honom | he * -hjå | at * -ho | she * -hoe | she * -henne | her -hennar | her/hers -hennes | hers -hoss | how * -hossen | how * -ikkje | not * -ingi | noone * -inkje | noone * -korleis | how * -korso | how * -kva | what/which * -kvar | where * -kvarhelst | where * -kven | who/whom * -kvi | why * -kvifor | why * -me | we * -medan | while * -mi | my * -mine | my * -mykje | much * -no | now * -nokon | some (masc./neut.) * -noka | some (fem.) * -nokor | some * -noko | some * -nokre | some * -si | his/hers * -sia | since * -sidan | since * -so | so * -somt | some * -somme | some * -um | about* -upp | up * -vere | be * -vore | was * -verte | become * -vort | become * -varte | became * -vart | became * - + | From svn.tartarus.org/snowball/trunk/website/algorithms/norwegian/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Norwegian stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + | This stop word list is for the dominant bokmål dialect. Words unique + | to nynorsk are marked *. + + | Revised by Jan Bruusgaard , Jan 2005 + +og | and +i | in +jeg | I +det | it/this/that +at | to (w. inf.) +en | a/an +et | a/an +den | it/this/that +til | to +er | is/am/are +som | who/that +på | on +de | they / you(formal) +med | with +han | he +av | of +ikke | not +ikkje | not * +der | there +så | so +var | was/were +meg | me +seg | you +men | but +ett | one +har | have +om | about +vi | we +min | my +mitt | my +ha | have +hadde | had +hun | she +nå | now +over | over +da | when/as +ved | by/know +fra | from +du | you +ut | out +sin | your +dem | them +oss | us +opp | up +man | you/one +kan | can +hans | his +hvor | where +eller | or +hva | what +skal | shall/must +selv | self (reflective) +sjøl | self (reflective) +her | here +alle | all +vil | will +bli | become +ble | became +blei | became * +blitt | have become +kunne | could +inn | in +når | when +være | be +kom | come +noen | some +noe | some +ville | would +dere | you +som | who/which/that +deres | their/theirs +kun | only/just +ja | yes +etter | after +ned | down +skulle | should +denne | this +for | for/because +deg | you +si | hers/his +sine | hers/his +sitt | hers/his +mot | against +å | to +meget | much +hvorfor | why +dette | this +disse | these/those +uten | without +hvordan | how +ingen | none +din | your +ditt | your +blir | become +samme | same +hvilken | which +hvilke | which (plural) +sånn | such a +inni | inside/within +mellom | between +vår | our +hver | each +hvem | who +vors | us/ours +hvis | whose +både | both +bare | only/just +enn | than +fordi | as/because +før | before +mange | many +også | also +slik | just +vært | been +være | to be +båe | both * +begge | both +siden | since +dykk | your * +dykkar | yours * +dei | they * +deira | them * +deires | theirs * +deim | them * +di | your (fem.) * +då | as/when * +eg | I * +ein | a/an * +eit | a/an * +eitt | a/an * +elles | or * +honom | he * +hjå | at * +ho | she * +hoe | she * +henne | her +hennar | her/hers +hennes | hers +hoss | how * +hossen | how * +ikkje | not * +ingi | noone * +inkje | noone * +korleis | how * +korso | how * +kva | what/which * +kvar | where * +kvarhelst | where * +kven | who/whom * +kvi | why * +kvifor | why * +me | we * +medan | while * +mi | my * +mine | my * +mykje | much * +no | now * +nokon | some (masc./neut.) * +noka | some (fem.) * +nokor | some * +noko | some * +nokre | some * +si | his/hers * +sia | since * +sidan | since * +so | so * +somt | some * +somme | some * +um | about* +upp | up * +vere | be * +vore | was * +verte | become * +vort | become * +varte | became * +vart | became * + diff --git a/resources/cache/empty/relation/conf/lang/stopwords_pt.txt b/resources/cache/empty/relation/conf/lang/stopwords_pt.txt index 6afa2b5c..acfeb01a 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_pt.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_pt.txt @@ -1,253 +1,253 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/portuguese/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Portuguese stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - - | The following is a ranked list (commonest to rarest) of stopwords - | deriving from a large sample of text. - - | Extra words have been added at the end. - -de | of, from -a | the; to, at; her -o | the; him -que | who, that -e | and -do | de + o -da | de + a -em | in -um | a -para | for - | é from SER -com | with -não | not, no -uma | a -os | the; them -no | em + o -se | himself etc -na | em + a -por | for -mais | more -as | the; them -dos | de + os -como | as, like -mas | but - | foi from SER -ao | a + o -ele | he -das | de + as - | tem from TER -à | a + a -seu | his -sua | her -ou | or - | ser from SER -quando | when -muito | much - | há from HAV -nos | em + os; us -já | already, now - | está from EST -eu | I -também | also -só | only, just -pelo | per + o -pela | per + a -até | up to -isso | that -ela | he -entre | between - | era from SER -depois | after -sem | without -mesmo | same -aos | a + os - | ter from TER -seus | his -quem | whom -nas | em + as -me | me -esse | that -eles | they - | estão from EST -você | you - | tinha from TER - | foram from SER -essa | that -num | em + um -nem | nor -suas | her -meu | my -às | a + as -minha | my - | têm from TER -numa | em + uma -pelos | per + os -elas | they - | havia from HAV - | seja from SER -qual | which - | será from SER -nós | we - | tenho from TER -lhe | to him, her -deles | of them -essas | those -esses | those -pelas | per + as -este | this - | fosse from SER -dele | of him - - | other words. There are many contractions such as naquele = em+aquele, - | mo = me+o, but they are rare. - | Indefinite article plural forms are also rare. - -tu | thou -te | thee -vocês | you (plural) -vos | you -lhes | to them -meus | my -minhas -teu | thy -tua -teus -tuas -nosso | our -nossa -nossos -nossas - -dela | of her -delas | of them - -esta | this -estes | these -estas | these -aquele | that -aquela | that -aqueles | those -aquelas | those -isto | this -aquilo | that - - | forms of estar, to be (not including the infinitive): -estou -está -estamos -estão -estive -esteve -estivemos -estiveram -estava -estávamos -estavam -estivera -estivéramos -esteja -estejamos -estejam -estivesse -estivéssemos -estivessem -estiver -estivermos -estiverem - - | forms of haver, to have (not including the infinitive): -hei -há -havemos -hão -houve -houvemos -houveram -houvera -houvéramos -haja -hajamos -hajam -houvesse -houvéssemos -houvessem -houver -houvermos -houverem -houverei -houverá -houveremos -houverão -houveria -houveríamos -houveriam - - | forms of ser, to be (not including the infinitive): -sou -somos -são -era -éramos -eram -fui -foi -fomos -foram -fora -fôramos -seja -sejamos -sejam -fosse -fôssemos -fossem -for -formos -forem -serei -será -seremos -serão -seria -seríamos -seriam - - | forms of ter, to have (not including the infinitive): -tenho -tem -temos -tém -tinha -tínhamos -tinham -tive -teve -tivemos -tiveram -tivera -tivéramos -tenha -tenhamos -tenham -tivesse -tivéssemos -tivessem -tiver -tivermos -tiverem -terei -terá -teremos -terão -teria -teríamos -teriam + | From svn.tartarus.org/snowball/trunk/website/algorithms/portuguese/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Portuguese stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + + | The following is a ranked list (commonest to rarest) of stopwords + | deriving from a large sample of text. + + | Extra words have been added at the end. + +de | of, from +a | the; to, at; her +o | the; him +que | who, that +e | and +do | de + o +da | de + a +em | in +um | a +para | for + | é from SER +com | with +não | not, no +uma | a +os | the; them +no | em + o +se | himself etc +na | em + a +por | for +mais | more +as | the; them +dos | de + os +como | as, like +mas | but + | foi from SER +ao | a + o +ele | he +das | de + as + | tem from TER +à | a + a +seu | his +sua | her +ou | or + | ser from SER +quando | when +muito | much + | há from HAV +nos | em + os; us +já | already, now + | está from EST +eu | I +também | also +só | only, just +pelo | per + o +pela | per + a +até | up to +isso | that +ela | he +entre | between + | era from SER +depois | after +sem | without +mesmo | same +aos | a + os + | ter from TER +seus | his +quem | whom +nas | em + as +me | me +esse | that +eles | they + | estão from EST +você | you + | tinha from TER + | foram from SER +essa | that +num | em + um +nem | nor +suas | her +meu | my +às | a + as +minha | my + | têm from TER +numa | em + uma +pelos | per + os +elas | they + | havia from HAV + | seja from SER +qual | which + | será from SER +nós | we + | tenho from TER +lhe | to him, her +deles | of them +essas | those +esses | those +pelas | per + as +este | this + | fosse from SER +dele | of him + + | other words. There are many contractions such as naquele = em+aquele, + | mo = me+o, but they are rare. + | Indefinite article plural forms are also rare. + +tu | thou +te | thee +vocês | you (plural) +vos | you +lhes | to them +meus | my +minhas +teu | thy +tua +teus +tuas +nosso | our +nossa +nossos +nossas + +dela | of her +delas | of them + +esta | this +estes | these +estas | these +aquele | that +aquela | that +aqueles | those +aquelas | those +isto | this +aquilo | that + + | forms of estar, to be (not including the infinitive): +estou +está +estamos +estão +estive +esteve +estivemos +estiveram +estava +estávamos +estavam +estivera +estivéramos +esteja +estejamos +estejam +estivesse +estivéssemos +estivessem +estiver +estivermos +estiverem + + | forms of haver, to have (not including the infinitive): +hei +há +havemos +hão +houve +houvemos +houveram +houvera +houvéramos +haja +hajamos +hajam +houvesse +houvéssemos +houvessem +houver +houvermos +houverem +houverei +houverá +houveremos +houverão +houveria +houveríamos +houveriam + + | forms of ser, to be (not including the infinitive): +sou +somos +são +era +éramos +eram +fui +foi +fomos +foram +fora +fôramos +seja +sejamos +sejam +fosse +fôssemos +fossem +for +formos +forem +serei +será +seremos +serão +seria +seríamos +seriam + + | forms of ter, to have (not including the infinitive): +tenho +tem +temos +tém +tinha +tínhamos +tinham +tive +teve +tivemos +tiveram +tivera +tivéramos +tenha +tenhamos +tenham +tivesse +tivéssemos +tivessem +tiver +tivermos +tiverem +terei +terá +teremos +terão +teria +teríamos +teriam diff --git a/resources/cache/empty/relation/conf/lang/stopwords_ro.txt b/resources/cache/empty/relation/conf/lang/stopwords_ro.txt index 2d7395c4..4fdee90a 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_ro.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_ro.txt @@ -1,233 +1,233 @@ -# This file was created by Jacques Savoy and is distributed under the BSD license. -# See http://members.unine.ch/jacques.savoy/clef/index.html. -# Also see http://www.opensource.org/licenses/bsd-license.html -acea -aceasta -această -aceea -acei -aceia -acel -acela -acele -acelea -acest -acesta -aceste -acestea -aceşti -aceştia -acolo -acum -ai -aia -aibă -aici -al -ăla -ale -alea -ălea -altceva -altcineva -am -ar -are -aş -aşadar -asemenea -asta -ăsta -astăzi -astea -ăstea -ăştia -asupra -aţi -au -avea -avem -aveţi -azi -bine -bucur -bună -ca -că -căci -când -care -cărei -căror -cărui -cât -câte -câţi -către -câtva -ce -cel -ceva -chiar -cînd -cine -cineva -cît -cîte -cîţi -cîtva -contra -cu -cum -cumva -curând -curînd -da -dă -dacă -dar -datorită -de -deci -deja -deoarece -departe -deşi -din -dinaintea -dintr -dintre -drept -după -ea -ei -el -ele -eram -este -eşti -eu -face -fără -fi -fie -fiecare -fii -fim -fiţi -iar -ieri -îi -îl -îmi -împotriva -în -înainte -înaintea -încât -încît -încotro -între -întrucât -întrucît -îţi -la -lângă -le -li -lîngă -lor -lui -mă -mâine -mea -mei -mele -mereu -meu -mi -mine -mult -multă -mulţi -ne -nicăieri -nici -nimeni -nişte -noastră -noastre -noi -noştri -nostru -nu -ori -oricând -oricare -oricât -orice -oricînd -oricine -oricît -oricum -oriunde -până -pe -pentru -peste -pînă -poate -pot -prea -prima -primul -prin -printr -sa -să -săi -sale -sau -său -se -şi -sînt -sîntem -sînteţi -spre -sub -sunt -suntem -sunteţi -ta -tăi -tale -tău -te -ţi -ţie -tine -toată -toate -tot -toţi -totuşi -tu -un -una -unde -undeva -unei -unele -uneori -unor -vă -vi -voastră -voastre -voi -voştri -vostru -vouă -vreo -vreun +# This file was created by Jacques Savoy and is distributed under the BSD license. +# See http://members.unine.ch/jacques.savoy/clef/index.html. +# Also see http://www.opensource.org/licenses/bsd-license.html +acea +aceasta +această +aceea +acei +aceia +acel +acela +acele +acelea +acest +acesta +aceste +acestea +aceşti +aceştia +acolo +acum +ai +aia +aibă +aici +al +ăla +ale +alea +ălea +altceva +altcineva +am +ar +are +aş +aşadar +asemenea +asta +ăsta +astăzi +astea +ăstea +ăştia +asupra +aţi +au +avea +avem +aveţi +azi +bine +bucur +bună +ca +că +căci +când +care +cărei +căror +cărui +cât +câte +câţi +către +câtva +ce +cel +ceva +chiar +cînd +cine +cineva +cît +cîte +cîţi +cîtva +contra +cu +cum +cumva +curând +curînd +da +dă +dacă +dar +datorită +de +deci +deja +deoarece +departe +deşi +din +dinaintea +dintr +dintre +drept +după +ea +ei +el +ele +eram +este +eşti +eu +face +fără +fi +fie +fiecare +fii +fim +fiţi +iar +ieri +îi +îl +îmi +împotriva +în +înainte +înaintea +încât +încît +încotro +între +întrucât +întrucît +îţi +la +lângă +le +li +lîngă +lor +lui +mă +mâine +mea +mei +mele +mereu +meu +mi +mine +mult +multă +mulţi +ne +nicăieri +nici +nimeni +nişte +noastră +noastre +noi +noştri +nostru +nu +ori +oricând +oricare +oricât +orice +oricînd +oricine +oricît +oricum +oriunde +până +pe +pentru +peste +pînă +poate +pot +prea +prima +primul +prin +printr +sa +să +săi +sale +sau +său +se +şi +sînt +sîntem +sînteţi +spre +sub +sunt +suntem +sunteţi +ta +tăi +tale +tău +te +ţi +ţie +tine +toată +toate +tot +toţi +totuşi +tu +un +una +unde +undeva +unei +unele +uneori +unor +vă +vi +voastră +voastre +voi +voştri +vostru +vouă +vreo +vreun diff --git a/resources/cache/empty/relation/conf/lang/stopwords_ru.txt b/resources/cache/empty/relation/conf/lang/stopwords_ru.txt index 0141b9b8..55271400 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_ru.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_ru.txt @@ -1,243 +1,243 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/russian/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | a russian stop word list. comments begin with vertical bar. each stop - | word is at the start of a line. - - | this is a ranked list (commonest to rarest) of stopwords derived from - | a large text sample. - - | letter `ё' is translated to `е'. - -и | and -в | in/into -во | alternative form -не | not -что | what/that -он | he -на | on/onto -я | i -с | from -со | alternative form -как | how -а | milder form of `no' (but) -то | conjunction and form of `that' -все | all -она | she -так | so, thus -его | him -но | but -да | yes/and -ты | thou -к | towards, by -у | around, chez -же | intensifier particle -вы | you -за | beyond, behind -бы | conditional/subj. particle -по | up to, along -только | only -ее | her -мне | to me -было | it was -вот | here is/are, particle -от | away from -меня | me -еще | still, yet, more -нет | no, there isnt/arent -о | about -из | out of -ему | to him -теперь | now -когда | when -даже | even -ну | so, well -вдруг | suddenly -ли | interrogative particle -если | if -уже | already, but homonym of `narrower' -или | or -ни | neither -быть | to be -был | he was -него | prepositional form of его -до | up to -вас | you accusative -нибудь | indef. suffix preceded by hyphen -опять | again -уж | already, but homonym of `adder' -вам | to you -сказал | he said -ведь | particle `after all' -там | there -потом | then -себя | oneself -ничего | nothing -ей | to her -может | usually with `быть' as `maybe' -они | they -тут | here -где | where -есть | there is/are -надо | got to, must -ней | prepositional form of ей -для | for -мы | we -тебя | thee -их | them, their -чем | than -была | she was -сам | self -чтоб | in order to -без | without -будто | as if -человек | man, person, one -чего | genitive form of `what' -раз | once -тоже | also -себе | to oneself -под | beneath -жизнь | life -будет | will be -ж | short form of intensifer particle `же' -тогда | then -кто | who -этот | this -говорил | was saying -того | genitive form of `that' -потому | for that reason -этого | genitive form of `this' -какой | which -совсем | altogether -ним | prepositional form of `его', `они' -здесь | here -этом | prepositional form of `этот' -один | one -почти | almost -мой | my -тем | instrumental/dative plural of `тот', `то' -чтобы | full form of `in order that' -нее | her (acc.) -кажется | it seems -сейчас | now -были | they were -куда | where to -зачем | why -сказать | to say -всех | all (acc., gen. preposn. plural) -никогда | never -сегодня | today -можно | possible, one can -при | by -наконец | finally -два | two -об | alternative form of `о', about -другой | another -хоть | even -после | after -над | above -больше | more -тот | that one (masc.) -через | across, in -эти | these -нас | us -про | about -всего | in all, only, of all -них | prepositional form of `они' (they) -какая | which, feminine -много | lots -разве | interrogative particle -сказала | she said -три | three -эту | this, acc. fem. sing. -моя | my, feminine -впрочем | moreover, besides -хорошо | good -свою | ones own, acc. fem. sing. -этой | oblique form of `эта', fem. `this' -перед | in front of -иногда | sometimes -лучше | better -чуть | a little -том | preposn. form of `that one' -нельзя | one must not -такой | such a one -им | to them -более | more -всегда | always -конечно | of course -всю | acc. fem. sing of `all' -между | between - - - | b: some paradigms - | - | personal pronouns - | - | я меня мне мной [мною] - | ты тебя тебе тобой [тобою] - | он его ему им [него, нему, ним] - | она ее эи ею [нее, нэи, нею] - | оно его ему им [него, нему, ним] - | - | мы нас нам нами - | вы вас вам вами - | они их им ими [них, ним, ними] - | - | себя себе собой [собою] - | - | demonstrative pronouns: этот (this), тот (that) - | - | этот эта это эти - | этого эты это эти - | этого этой этого этих - | этому этой этому этим - | этим этой этим [этою] этими - | этом этой этом этих - | - | тот та то те - | того ту то те - | того той того тех - | тому той тому тем - | тем той тем [тою] теми - | том той том тех - | - | determinative pronouns - | - | (a) весь (all) - | - | весь вся все все - | всего всю все все - | всего всей всего всех - | всему всей всему всем - | всем всей всем [всею] всеми - | всем всей всем всех - | - | (b) сам (himself etc) - | - | сам сама само сами - | самого саму само самих - | самого самой самого самих - | самому самой самому самим - | самим самой самим [самою] самими - | самом самой самом самих - | - | stems of verbs `to be', `to have', `to do' and modal - | - | быть бы буд быв есть суть - | име - | дел - | мог мож мочь - | уме - | хоч хот - | долж - | можн - | нужн - | нельзя - + | From svn.tartarus.org/snowball/trunk/website/algorithms/russian/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | a russian stop word list. comments begin with vertical bar. each stop + | word is at the start of a line. + + | this is a ranked list (commonest to rarest) of stopwords derived from + | a large text sample. + + | letter `ё' is translated to `е'. + +и | and +в | in/into +во | alternative form +не | not +что | what/that +он | he +на | on/onto +я | i +с | from +со | alternative form +как | how +а | milder form of `no' (but) +то | conjunction and form of `that' +все | all +она | she +так | so, thus +его | him +но | but +да | yes/and +ты | thou +к | towards, by +у | around, chez +же | intensifier particle +вы | you +за | beyond, behind +бы | conditional/subj. particle +по | up to, along +только | only +ее | her +мне | to me +было | it was +вот | here is/are, particle +от | away from +меня | me +еще | still, yet, more +нет | no, there isnt/arent +о | about +из | out of +ему | to him +теперь | now +когда | when +даже | even +ну | so, well +вдруг | suddenly +ли | interrogative particle +если | if +уже | already, but homonym of `narrower' +или | or +ни | neither +быть | to be +был | he was +него | prepositional form of его +до | up to +вас | you accusative +нибудь | indef. suffix preceded by hyphen +опять | again +уж | already, but homonym of `adder' +вам | to you +сказал | he said +ведь | particle `after all' +там | there +потом | then +себя | oneself +ничего | nothing +ей | to her +может | usually with `быть' as `maybe' +они | they +тут | here +где | where +есть | there is/are +надо | got to, must +ней | prepositional form of ей +для | for +мы | we +тебя | thee +их | them, their +чем | than +была | she was +сам | self +чтоб | in order to +без | without +будто | as if +человек | man, person, one +чего | genitive form of `what' +раз | once +тоже | also +себе | to oneself +под | beneath +жизнь | life +будет | will be +ж | short form of intensifer particle `же' +тогда | then +кто | who +этот | this +говорил | was saying +того | genitive form of `that' +потому | for that reason +этого | genitive form of `this' +какой | which +совсем | altogether +ним | prepositional form of `его', `они' +здесь | here +этом | prepositional form of `этот' +один | one +почти | almost +мой | my +тем | instrumental/dative plural of `тот', `то' +чтобы | full form of `in order that' +нее | her (acc.) +кажется | it seems +сейчас | now +были | they were +куда | where to +зачем | why +сказать | to say +всех | all (acc., gen. preposn. plural) +никогда | never +сегодня | today +можно | possible, one can +при | by +наконец | finally +два | two +об | alternative form of `о', about +другой | another +хоть | even +после | after +над | above +больше | more +тот | that one (masc.) +через | across, in +эти | these +нас | us +про | about +всего | in all, only, of all +них | prepositional form of `они' (they) +какая | which, feminine +много | lots +разве | interrogative particle +сказала | she said +три | three +эту | this, acc. fem. sing. +моя | my, feminine +впрочем | moreover, besides +хорошо | good +свою | ones own, acc. fem. sing. +этой | oblique form of `эта', fem. `this' +перед | in front of +иногда | sometimes +лучше | better +чуть | a little +том | preposn. form of `that one' +нельзя | one must not +такой | such a one +им | to them +более | more +всегда | always +конечно | of course +всю | acc. fem. sing of `all' +между | between + + + | b: some paradigms + | + | personal pronouns + | + | я меня мне мной [мною] + | ты тебя тебе тобой [тобою] + | он его ему им [него, нему, ним] + | она ее эи ею [нее, нэи, нею] + | оно его ему им [него, нему, ним] + | + | мы нас нам нами + | вы вас вам вами + | они их им ими [них, ним, ними] + | + | себя себе собой [собою] + | + | demonstrative pronouns: этот (this), тот (that) + | + | этот эта это эти + | этого эты это эти + | этого этой этого этих + | этому этой этому этим + | этим этой этим [этою] этими + | этом этой этом этих + | + | тот та то те + | того ту то те + | того той того тех + | тому той тому тем + | тем той тем [тою] теми + | том той том тех + | + | determinative pronouns + | + | (a) весь (all) + | + | весь вся все все + | всего всю все все + | всего всей всего всех + | всему всей всему всем + | всем всей всем [всею] всеми + | всем всей всем всех + | + | (b) сам (himself etc) + | + | сам сама само сами + | самого саму само самих + | самого самой самого самих + | самому самой самому самим + | самим самой самим [самою] самими + | самом самой самом самих + | + | stems of verbs `to be', `to have', `to do' and modal + | + | быть бы буд быв есть суть + | име + | дел + | мог мож мочь + | уме + | хоч хот + | долж + | можн + | нужн + | нельзя + diff --git a/resources/cache/empty/relation/conf/lang/stopwords_sv.txt b/resources/cache/empty/relation/conf/lang/stopwords_sv.txt index 7216373b..096f87f6 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_sv.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_sv.txt @@ -1,133 +1,133 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/swedish/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Swedish stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - | This is a ranked list (commonest to rarest) of stopwords derived from - | a large text sample. - - | Swedish stop words occasionally exhibit homonym clashes. For example - | så = so, but also seed. These are indicated clearly below. - -och | and -det | it, this/that -att | to (with infinitive) -i | in, at -en | a -jag | I -hon | she -som | who, that -han | he -på | on -den | it, this/that -med | with -var | where, each -sig | him(self) etc -för | for -så | so (also: seed) -till | to -är | is -men | but -ett | a -om | if; around, about -hade | had -de | they, these/those -av | of -icke | not, no -mig | me -du | you -henne | her -då | then, when -sin | his -nu | now -har | have -inte | inte någon = no one -hans | his -honom | him -skulle | 'sake' -hennes | her -där | there -min | my -man | one (pronoun) -ej | nor -vid | at, by, on (also: vast) -kunde | could -något | some etc -från | from, off -ut | out -när | when -efter | after, behind -upp | up -vi | we -dem | them -vara | be -vad | what -över | over -än | than -dig | you -kan | can -sina | his -här | here -ha | have -mot | towards -alla | all -under | under (also: wonder) -någon | some etc -eller | or (else) -allt | all -mycket | much -sedan | since -ju | why -denna | this/that -själv | myself, yourself etc -detta | this/that -åt | to -utan | without -varit | was -hur | how -ingen | no -mitt | my -ni | you -bli | to be, become -blev | from bli -oss | us -din | thy -dessa | these/those -några | some etc -deras | their -blir | from bli -mina | my -samma | (the) same -vilken | who, that -er | you, your -sådan | such a -vår | our -blivit | from bli -dess | its -inom | within -mellan | between -sådant | such a -varför | why -varje | each -vilka | who, that -ditt | thy -vem | who -vilket | who, that -sitta | his -sådana | such a -vart | each -dina | thy -vars | whose -vårt | our -våra | our -ert | your -era | your -vilkas | whose - + | From svn.tartarus.org/snowball/trunk/website/algorithms/swedish/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Swedish stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + | This is a ranked list (commonest to rarest) of stopwords derived from + | a large text sample. + + | Swedish stop words occasionally exhibit homonym clashes. For example + | så = so, but also seed. These are indicated clearly below. + +och | and +det | it, this/that +att | to (with infinitive) +i | in, at +en | a +jag | I +hon | she +som | who, that +han | he +på | on +den | it, this/that +med | with +var | where, each +sig | him(self) etc +för | for +så | so (also: seed) +till | to +är | is +men | but +ett | a +om | if; around, about +hade | had +de | they, these/those +av | of +icke | not, no +mig | me +du | you +henne | her +då | then, when +sin | his +nu | now +har | have +inte | inte någon = no one +hans | his +honom | him +skulle | 'sake' +hennes | her +där | there +min | my +man | one (pronoun) +ej | nor +vid | at, by, on (also: vast) +kunde | could +något | some etc +från | from, off +ut | out +när | when +efter | after, behind +upp | up +vi | we +dem | them +vara | be +vad | what +över | over +än | than +dig | you +kan | can +sina | his +här | here +ha | have +mot | towards +alla | all +under | under (also: wonder) +någon | some etc +eller | or (else) +allt | all +mycket | much +sedan | since +ju | why +denna | this/that +själv | myself, yourself etc +detta | this/that +åt | to +utan | without +varit | was +hur | how +ingen | no +mitt | my +ni | you +bli | to be, become +blev | from bli +oss | us +din | thy +dessa | these/those +några | some etc +deras | their +blir | from bli +mina | my +samma | (the) same +vilken | who, that +er | you, your +sådan | such a +vår | our +blivit | from bli +dess | its +inom | within +mellan | between +sådant | such a +varför | why +varje | each +vilka | who, that +ditt | thy +vem | who +vilket | who, that +sitta | his +sådana | such a +vart | each +dina | thy +vars | whose +vårt | our +våra | our +ert | your +era | your +vilkas | whose + diff --git a/resources/cache/empty/relation/conf/lang/stopwords_th.txt b/resources/cache/empty/relation/conf/lang/stopwords_th.txt index 1415edf9..07f0fabe 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_th.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_th.txt @@ -1,119 +1,119 @@ -# Thai stopwords from: -# "Opinion Detection in Thai Political News Columns -# Based on Subjectivity Analysis" -# Khampol Sukhum, Supot Nitsuwat, and Choochart Haruechaiyasak -ไว้ -ไม่ -ไป -ได้ -ให้ -ใน -โดย -แห่ง -แล้ว -และ -แรก -แบบ -แต่ -เอง -เห็น -เลย -เริ่ม -เรา -เมื่อ -เพื่อ -เพราะ -เป็นการ -เป็น -เปิดเผย -เปิด -เนื่องจาก -เดียวกัน -เดียว -เช่น -เฉพาะ -เคย -เข้า -เขา -อีก -อาจ -อะไร -ออก -อย่าง -อยู่ -อยาก -หาก -หลาย -หลังจาก -หลัง -หรือ -หนึ่ง -ส่วน -ส่ง -สุด -สําหรับ -ว่า -วัน -ลง -ร่วม -ราย -รับ -ระหว่าง -รวม -ยัง -มี -มาก -มา -พร้อม -พบ -ผ่าน -ผล -บาง -น่า -นี้ -นํา -นั้น -นัก -นอกจาก -ทุก -ที่สุด -ที่ -ทําให้ -ทํา -ทาง -ทั้งนี้ -ทั้ง -ถ้า -ถูก -ถึง -ต้อง -ต่างๆ -ต่าง -ต่อ -ตาม -ตั้งแต่ -ตั้ง -ด้าน -ด้วย -ดัง -ซึ่ง -ช่วง -จึง -จาก -จัด -จะ -คือ -ความ -ครั้ง -คง -ขึ้น -ของ -ขอ -ขณะ -ก่อน -ก็ -การ -กับ -กัน -กว่า -กล่าว +# Thai stopwords from: +# "Opinion Detection in Thai Political News Columns +# Based on Subjectivity Analysis" +# Khampol Sukhum, Supot Nitsuwat, and Choochart Haruechaiyasak +ไว้ +ไม่ +ไป +ได้ +ให้ +ใน +โดย +แห่ง +แล้ว +และ +แรก +แบบ +แต่ +เอง +เห็น +เลย +เริ่ม +เรา +เมื่อ +เพื่อ +เพราะ +เป็นการ +เป็น +เปิดเผย +เปิด +เนื่องจาก +เดียวกัน +เดียว +เช่น +เฉพาะ +เคย +เข้า +เขา +อีก +อาจ +อะไร +ออก +อย่าง +อยู่ +อยาก +หาก +หลาย +หลังจาก +หลัง +หรือ +หนึ่ง +ส่วน +ส่ง +สุด +สําหรับ +ว่า +วัน +ลง +ร่วม +ราย +รับ +ระหว่าง +รวม +ยัง +มี +มาก +มา +พร้อม +พบ +ผ่าน +ผล +บาง +น่า +นี้ +นํา +นั้น +นัก +นอกจาก +ทุก +ที่สุด +ที่ +ทําให้ +ทํา +ทาง +ทั้งนี้ +ทั้ง +ถ้า +ถูก +ถึง +ต้อง +ต่างๆ +ต่าง +ต่อ +ตาม +ตั้งแต่ +ตั้ง +ด้าน +ด้วย +ดัง +ซึ่ง +ช่วง +จึง +จาก +จัด +จะ +คือ +ความ +ครั้ง +คง +ขึ้น +ของ +ขอ +ขณะ +ก่อน +ก็ +การ +กับ +กัน +กว่า +กล่าว diff --git a/resources/cache/empty/relation/conf/lang/stopwords_tr.txt b/resources/cache/empty/relation/conf/lang/stopwords_tr.txt index fe4083b7..84d9408d 100644 --- a/resources/cache/empty/relation/conf/lang/stopwords_tr.txt +++ b/resources/cache/empty/relation/conf/lang/stopwords_tr.txt @@ -1,212 +1,212 @@ -# Turkish stopwords from LUCENE-559 -# merged with the list from "Information Retrieval on Turkish Texts" -# (http://www.users.muohio.edu/canf/papers/JASIST2008offPrint.pdf) -acaba -altmış -altı -ama -ancak -arada -aslında -ayrıca -bana -bazı -belki -ben -benden -beni -benim -beri -beş -bile -bin -bir -birçok -biri -birkaç -birkez -birşey -birşeyi -biz -bize -bizden -bizi -bizim -böyle -böylece -bu -buna -bunda -bundan -bunlar -bunları -bunların -bunu -bunun -burada -çok -çünkü -da -daha -dahi -de -defa -değil -diğer -diye -doksan -dokuz -dolayı -dolayısıyla -dört -edecek -eden -ederek -edilecek -ediliyor -edilmesi -ediyor -eğer -elli -en -etmesi -etti -ettiği -ettiğini -gibi -göre -halen -hangi -hatta -hem -henüz -hep -hepsi -her -herhangi -herkesin -hiç -hiçbir -için -iki -ile -ilgili -ise -işte -itibaren -itibariyle -kadar -karşın -katrilyon -kendi -kendilerine -kendini -kendisi -kendisine -kendisini -kez -ki -kim -kimden -kime -kimi -kimse -kırk -milyar -milyon -mu -mü -mı -nasıl -ne -neden -nedenle -nerde -nerede -nereye -niye -niçin -o -olan -olarak -oldu -olduğu -olduğunu -olduklarını -olmadı -olmadığı -olmak -olması -olmayan -olmaz -olsa -olsun -olup -olur -olursa -oluyor -on -ona -ondan -onlar -onlardan -onları -onların -onu -onun -otuz -oysa -öyle -pek -rağmen -sadece -sanki -sekiz -seksen -sen -senden -seni -senin -siz -sizden -sizi -sizin -şey -şeyden -şeyi -şeyler -şöyle -şu -şuna -şunda -şundan -şunları -şunu -tarafından -trilyon -tüm -üç -üzere -var -vardı -ve -veya -ya -yani -yapacak -yapılan -yapılması -yapıyor -yapmak -yaptı -yaptığı -yaptığını -yaptıkları -yedi -yerine -yetmiş -yine -yirmi -yoksa -yüz -zaten +# Turkish stopwords from LUCENE-559 +# merged with the list from "Information Retrieval on Turkish Texts" +# (http://www.users.muohio.edu/canf/papers/JASIST2008offPrint.pdf) +acaba +altmış +altı +ama +ancak +arada +aslında +ayrıca +bana +bazı +belki +ben +benden +beni +benim +beri +beş +bile +bin +bir +birçok +biri +birkaç +birkez +birşey +birşeyi +biz +bize +bizden +bizi +bizim +böyle +böylece +bu +buna +bunda +bundan +bunlar +bunları +bunların +bunu +bunun +burada +çok +çünkü +da +daha +dahi +de +defa +değil +diğer +diye +doksan +dokuz +dolayı +dolayısıyla +dört +edecek +eden +ederek +edilecek +ediliyor +edilmesi +ediyor +eğer +elli +en +etmesi +etti +ettiği +ettiğini +gibi +göre +halen +hangi +hatta +hem +henüz +hep +hepsi +her +herhangi +herkesin +hiç +hiçbir +için +iki +ile +ilgili +ise +işte +itibaren +itibariyle +kadar +karşın +katrilyon +kendi +kendilerine +kendini +kendisi +kendisine +kendisini +kez +ki +kim +kimden +kime +kimi +kimse +kırk +milyar +milyon +mu +mü +mı +nasıl +ne +neden +nedenle +nerde +nerede +nereye +niye +niçin +o +olan +olarak +oldu +olduğu +olduğunu +olduklarını +olmadı +olmadığı +olmak +olması +olmayan +olmaz +olsa +olsun +olup +olur +olursa +oluyor +on +ona +ondan +onlar +onlardan +onları +onların +onu +onun +otuz +oysa +öyle +pek +rağmen +sadece +sanki +sekiz +seksen +sen +senden +seni +senin +siz +sizden +sizi +sizin +şey +şeyden +şeyi +şeyler +şöyle +şu +şuna +şunda +şundan +şunları +şunu +tarafından +trilyon +tüm +üç +üzere +var +vardı +ve +veya +ya +yani +yapacak +yapılan +yapılması +yapıyor +yapmak +yaptı +yaptığı +yaptığını +yaptıkları +yedi +yerine +yetmiş +yine +yirmi +yoksa +yüz +zaten diff --git a/resources/cache/empty/relation/conf/lang/userdict_ja.txt b/resources/cache/empty/relation/conf/lang/userdict_ja.txt index c79de826..6f0368e4 100644 --- a/resources/cache/empty/relation/conf/lang/userdict_ja.txt +++ b/resources/cache/empty/relation/conf/lang/userdict_ja.txt @@ -1,29 +1,29 @@ -# -# This is a sample user dictionary for Kuromoji (JapaneseTokenizer) -# -# Add entries to this file in order to override the statistical model in terms -# of segmentation, readings and part-of-speech tags. Notice that entries do -# not have weights since they are always used when found. This is by-design -# in order to maximize ease-of-use. -# -# Entries are defined using the following CSV format: -# , ... , ... , -# -# Notice that a single half-width space separates tokens and readings, and -# that the number tokens and readings must match exactly. -# -# Also notice that multiple entries with the same is undefined. -# -# Whitespace only lines are ignored. Comments are not allowed on entry lines. -# - -# Custom segmentation for kanji compounds -日本経済新聞,日本 経済 新聞,ニホン ケイザイ シンブン,カスタム名詞 -関西国際空港,関西 国際 空港,カンサイ コクサイ クウコウ,カスタム名詞 - -# Custom segmentation for compound katakana -トートバッグ,トート バッグ,トート バッグ,かずカナ名詞 -ショルダーバッグ,ショルダー バッグ,ショルダー バッグ,かずカナ名詞 - -# Custom reading for former sumo wrestler -朝青龍,朝青龍,アサショウリュウ,カスタム人名 +# +# This is a sample user dictionary for Kuromoji (JapaneseTokenizer) +# +# Add entries to this file in order to override the statistical model in terms +# of segmentation, readings and part-of-speech tags. Notice that entries do +# not have weights since they are always used when found. This is by-design +# in order to maximize ease-of-use. +# +# Entries are defined using the following CSV format: +# , ... , ... , +# +# Notice that a single half-width space separates tokens and readings, and +# that the number tokens and readings must match exactly. +# +# Also notice that multiple entries with the same is undefined. +# +# Whitespace only lines are ignored. Comments are not allowed on entry lines. +# + +# Custom segmentation for kanji compounds +日本経済新聞,日本 経済 新聞,ニホン ケイザイ シンブン,カスタム名詞 +関西国際空港,関西 国際 空港,カンサイ コクサイ クウコウ,カスタム名詞 + +# Custom segmentation for compound katakana +トートバッグ,トート バッグ,トート バッグ,かずカナ名詞 +ショルダーバッグ,ショルダー バッグ,ショルダー バッグ,かずカナ名詞 + +# Custom reading for former sumo wrestler +朝青龍,朝青龍,アサショウリュウ,カスタム人名 diff --git a/resources/cache/empty/relation/conf/params.json b/resources/cache/empty/relation/conf/params.json index abf4154e..9c259db5 100644 --- a/resources/cache/empty/relation/conf/params.json +++ b/resources/cache/empty/relation/conf/params.json @@ -1,20 +1,20 @@ -{"params":{ - "query":{ - "defType":"edismax", - "q.alt":"*:*", - "rows":"10", - "fl":"*,score", - "":{"v":0} - }, - "facets":{ - "facet":"on", - "facet.mincount": "1", - "":{"v":0} - }, - "velocity":{ - "wt": "velocity", - "v.template":"browse", - "v.layout": "layout", - "":{"v":0} - } -}} +{"params":{ + "query":{ + "defType":"edismax", + "q.alt":"*:*", + "rows":"10", + "fl":"*,score", + "":{"v":0} + }, + "facets":{ + "facet":"on", + "facet.mincount": "1", + "":{"v":0} + }, + "velocity":{ + "wt": "velocity", + "v.template":"browse", + "v.layout": "layout", + "":{"v":0} + } +}} diff --git a/resources/cache/empty/relation/conf/protwords.txt b/resources/cache/empty/relation/conf/protwords.txt index 5a32e503..1dfc0abe 100644 --- a/resources/cache/empty/relation/conf/protwords.txt +++ b/resources/cache/empty/relation/conf/protwords.txt @@ -1,21 +1,21 @@ -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#----------------------------------------------------------------------- -# Use a protected word file to protect against the stemmer reducing two -# unrelated words to the same base word. - -# Some non-words that normally won't be encountered, -# just to test that they won't be stemmed. -dontstems -zwhacky - +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#----------------------------------------------------------------------- +# Use a protected word file to protect against the stemmer reducing two +# unrelated words to the same base word. + +# Some non-words that normally won't be encountered, +# just to test that they won't be stemmed. +dontstems +zwhacky + diff --git a/resources/cache/empty/relation/conf/schema.xml b/resources/cache/empty/relation/conf/schema.xml index da7b137d..e0c315a9 100644 --- a/resources/cache/empty/relation/conf/schema.xml +++ b/resources/cache/empty/relation/conf/schema.xml @@ -1,240 +1,240 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - id - - id - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id + + id + + + diff --git a/resources/cache/empty/relation/conf/solrconfig.xml b/resources/cache/empty/relation/conf/solrconfig.xml index 7e8babdf..a99f9628 100644 --- a/resources/cache/empty/relation/conf/solrconfig.xml +++ b/resources/cache/empty/relation/conf/solrconfig.xml @@ -1,1949 +1,1949 @@ - - - - - - - - - 4.10.4 - - - - - - - - - - - - - - - - - - - - - - ${solr.data.dir:} - - - - - - - - - ${solr.hdfs.home:} - - ${solr.hdfs.confdir:} - - ${solr.hdfs.blockcache.enabled:true} - - ${solr.hdfs.blockcache.global:true} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${solr.lock.type:native} - - - - - - - - - - - - - - - - - - - - - - true - - - false - - - - - - - - - - - - - - - - ${solr.ulog.dir:} - - - - - ${solr.autoCommit.maxTime:15000} - false - - - - - - ${solr.autoSoftCommit.maxTime:-1} - - - - - - - - - - - - - - - - - - 1024 - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - 20 - - - 200 - - - - - - - - - - - - static firstSearcher warming in solrconfig.xml - - - - - - false - - - 2 - - - - - - - - - - - - - - - - - - - - - - - explicit - 10 - text - - - - - - - - - - on - content features title name - true - html - <b> - </b> - 0 - title - - 3 - 200 - content - 750 - - - on - false - 5 - 2 - 5 - true - true - 5 - 3 - - - - - - explicit - json - true - text - - - - - - - - true - json - true - - - - - - - - {!xport} - xsort - false - - - - query - - - - - - - - - - - - explicit - - - velocity - browse - layout - Solritas - - - edismax - - text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 - title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0 - - text - 100% - *:* - 10 - *,score - - - text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 - title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0 - - text,features,name,sku,id,manu,cat,title,description,keywords,author,resourcename - 3 - - - on - true - cat - person - location - organisations - ipod - GB - 1 - cat,inStock - after - price - 0 - 600 - 50 - popularity - 0 - 10 - 3 - manufacturedate_dt - NOW/YEAR-10YEARS - NOW - +1YEAR - before - after - - - on - content features title name - true - html - <b> - </b> - 0 - title - - 3 - 200 - content - 750 - - - on - false - 5 - 2 - 5 - true - true - 5 - 3 - - - - - spellcheck - - - - - - - - - - - - - - - - last_modified - true - - ignored_ - - - true - links - jate_text_field - true - ignored_ - - - langid - - - - - - yyyy-MM-dd hh:mm:ss - - - - - - - - - - - - - - - - - - - - - - solrpingquery - - - all - - - - - - - - - explicit - true - - - - - - - - - - - - - - - - text_general - - - - - - default - text - solr.DirectSolrSpellChecker - - internal - - 0.5 - - 2 - - 1 - - 5 - - 4 - - 0.01 - - - - - - wordbreak - solr.WordBreakSolrSpellChecker - name - true - true - 10 - - - - - - - - - - - - - - - - text - - default - wordbreak - on - true - 10 - 5 - 5 - true - true - 10 - 5 - - - spellcheck - - - - - - - - - - - - text - true - - - tvComponent - - - - - - - lingo - - - org.carrot2.clustering.lingo.LingoClusteringAlgorithm - - - clustering/carrot2 - - - - - stc - org.carrot2.clustering.stc.STCClusteringAlgorithm - - - - - kmeans - org.carrot2.clustering.kmeans.BisectingKMeansClusteringAlgorithm - - - - - - - true - true - - name - - id - - features - - true - - - - false - - - edismax - - text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 - - *:* - 10 - *,score - - - clustering - - - - - - - - - - true - false - - - terms - - - - - - - - string - elevate.xml - - - - - - explicit - text - - - elevator - - - - - - - - - - - 100 - - - - - - - - 70 - - 0.5 - - [-\w ,/\n\"']{20,200} - - - - - - - ]]> - ]]> - - - - - - - - - - - - - - - - - - - - - - - - ,, - ,, - ,, - ,, - ,]]> - ]]> - - - - - - 10 - .,!? - - - - - - - WORD - - - en - US - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/plain; charset=UTF-8 - - - - - - - - - 5 - - - - - - - - - - - - - - - - - - *:* - - - + + + + + + + + + 4.10.4 + + + + + + + + + + + + + + + + + + + + + + ${solr.data.dir:} + + + + + + + + + ${solr.hdfs.home:} + + ${solr.hdfs.confdir:} + + ${solr.hdfs.blockcache.enabled:true} + + ${solr.hdfs.blockcache.global:true} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${solr.lock.type:native} + + + + + + + + + + + + + + + + + + + + + + true + + + false + + + + + + + + + + + + + + + + ${solr.ulog.dir:} + + + + + ${solr.autoCommit.maxTime:15000} + false + + + + + + ${solr.autoSoftCommit.maxTime:-1} + + + + + + + + + + + + + + + + + + 1024 + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + 20 + + + 200 + + + + + + + + + + + + static firstSearcher warming in solrconfig.xml + + + + + + false + + + 2 + + + + + + + + + + + + + + + + + + + + + + + explicit + 10 + text + + + + + + + + + + on + content features title name + true + html + <b> + </b> + 0 + title + + 3 + 200 + content + 750 + + + on + false + 5 + 2 + 5 + true + true + 5 + 3 + + + + + + explicit + json + true + text + + + + + + + + true + json + true + + + + + + + + {!xport} + xsort + false + + + + query + + + + + + + + + + + + explicit + + + velocity + browse + layout + Solritas + + + edismax + + text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 + title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0 + + text + 100% + *:* + 10 + *,score + + + text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 + title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0 + + text,features,name,sku,id,manu,cat,title,description,keywords,author,resourcename + 3 + + + on + true + cat + person + location + organisations + ipod + GB + 1 + cat,inStock + after + price + 0 + 600 + 50 + popularity + 0 + 10 + 3 + manufacturedate_dt + NOW/YEAR-10YEARS + NOW + +1YEAR + before + after + + + on + content features title name + true + html + <b> + </b> + 0 + title + + 3 + 200 + content + 750 + + + on + false + 5 + 2 + 5 + true + true + 5 + 3 + + + + + spellcheck + + + + + + + + + + + + + + + + last_modified + true + + ignored_ + + + true + links + jate_text_field + true + ignored_ + + + langid + + + + + + yyyy-MM-dd hh:mm:ss + + + + + + + + + + + + + + + + + + + + + + solrpingquery + + + all + + + + + + + + + explicit + true + + + + + + + + + + + + + + + + text_general + + + + + + default + text + solr.DirectSolrSpellChecker + + internal + + 0.5 + + 2 + + 1 + + 5 + + 4 + + 0.01 + + + + + + wordbreak + solr.WordBreakSolrSpellChecker + name + true + true + 10 + + + + + + + + + + + + + + + + text + + default + wordbreak + on + true + 10 + 5 + 5 + true + true + 10 + 5 + + + spellcheck + + + + + + + + + + + + text + true + + + tvComponent + + + + + + + lingo + + + org.carrot2.clustering.lingo.LingoClusteringAlgorithm + + + clustering/carrot2 + + + + + stc + org.carrot2.clustering.stc.STCClusteringAlgorithm + + + + + kmeans + org.carrot2.clustering.kmeans.BisectingKMeansClusteringAlgorithm + + + + + + + true + true + + name + + id + + features + + true + + + + false + + + edismax + + text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 + + *:* + 10 + *,score + + + clustering + + + + + + + + + + true + false + + + terms + + + + + + + + string + elevate.xml + + + + + + explicit + text + + + elevator + + + + + + + + + + + 100 + + + + + + + + 70 + + 0.5 + + [-\w ,/\n\"']{20,200} + + + + + + + ]]> + ]]> + + + + + + + + + + + + + + + + + + + + + + + + ,, + ,, + ,, + ,, + ,]]> + ]]> + + + + + + 10 + .,!? + + + + + + + WORD + + + en + US + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/plain; charset=UTF-8 + + + + + + + + + 5 + + + + + + + + + + + + + + + + + + *:* + + + diff --git a/resources/cache/empty/relation/conf/stopwords.txt b/resources/cache/empty/relation/conf/stopwords.txt index e525ab80..dacec479 100644 --- a/resources/cache/empty/relation/conf/stopwords.txt +++ b/resources/cache/empty/relation/conf/stopwords.txt @@ -1,188 +1,188 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -a -about -above -after -again -against -all -am -an -and -any -are -aren't -as -at -be -because -been -before -being -below -between -both -but -by -can't -cannot -could -couldn't -did -didn't -do -does -doesn't -doing -don't -down -during -each -few -for -from -further -had -hadn't -has -hasn't -have -haven't -having -he -he'd -he'll -he's -her -here -here's -hers -herself -him -himself -his -how -how's -i -i'd -i'll -i'm -i've -if -in -into -is -isn't -it -it's -its -itself -let's -me -more -most -mustn't -my -myself -no -nor -not -of -off -on -once -only -or -other -ought -our -ours -ourselves -out -over -own -same -shan't -she -she'd -she'll -she's -should -shouldn't -so -some -such -than -that -that's -the -their -theirs -them -themselves -then -there -there's -these -they -they'd -they'll -they're -they've -this -those -through -to -too -under -until -up -very -was -wasn't -we -we'd -we'll -we're -we've -were -weren't -what -what's -when -when's -where -where's -which -while -who -who's -whom -why -why's -with -won't -would -wouldn't -you -you'd -you'll -you're -you've -your -yours -yourself +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +a +about +above +after +again +against +all +am +an +and +any +are +aren't +as +at +be +because +been +before +being +below +between +both +but +by +can't +cannot +could +couldn't +did +didn't +do +does +doesn't +doing +don't +down +during +each +few +for +from +further +had +hadn't +has +hasn't +have +haven't +having +he +he'd +he'll +he's +her +here +here's +hers +herself +him +himself +his +how +how's +i +i'd +i'll +i'm +i've +if +in +into +is +isn't +it +it's +its +itself +let's +me +more +most +mustn't +my +myself +no +nor +not +of +off +on +once +only +or +other +ought +our +ours +ourselves +out +over +own +same +shan't +she +she'd +she'll +she's +should +shouldn't +so +some +such +than +that +that's +the +their +theirs +them +themselves +then +there +there's +these +they +they'd +they'll +they're +they've +this +those +through +to +too +under +until +up +very +was +wasn't +we +we'd +we'll +we're +we've +were +weren't +what +what's +when +when's +where +where's +which +while +who +who's +whom +why +why's +with +won't +would +wouldn't +you +you'd +you'll +you're +you've +your +yours +yourself yourselves \ No newline at end of file diff --git a/resources/cache/empty/relation/conf/synonyms.txt b/resources/cache/empty/relation/conf/synonyms.txt index f00294b0..7f721283 100644 --- a/resources/cache/empty/relation/conf/synonyms.txt +++ b/resources/cache/empty/relation/conf/synonyms.txt @@ -1,29 +1,29 @@ -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#----------------------------------------------------------------------- -#some test synonym mappings unlikely to appear in real input text -aaafoo => aaabar -bbbfoo => bbbfoo bbbbar -cccfoo => cccbar cccbaz -fooaaa,baraaa,bazaaa - -# Some synonym groups specific to this example -GB,gib,gigabyte,gigabytes -MB,mib,megabyte,megabytes -Television, Televisions, TV, TVs -#notice we use "gib" instead of "GiB" so any WordDelimiterFilter coming -#after us won't split it into two words. - -# Synonym mappings can be used for spelling correction too -pixima => pixma - +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#----------------------------------------------------------------------- +#some test synonym mappings unlikely to appear in real input text +aaafoo => aaabar +bbbfoo => bbbfoo bbbbar +cccfoo => cccbar cccbaz +fooaaa,baraaa,bazaaa + +# Some synonym groups specific to this example +GB,gib,gigabyte,gigabytes +MB,mib,megabyte,megabytes +Television, Televisions, TV, TVs +#notice we use "gib" instead of "GiB" so any WordDelimiterFilter coming +#after us won't split it into two words. + +# Synonym mappings can be used for spelling correction too +pixima => pixma + diff --git a/resources/cache/empty/relation/core.properties b/resources/cache/empty/relation/core.properties index 914b4bfb..4e1656a8 100644 --- a/resources/cache/empty/relation/core.properties +++ b/resources/cache/empty/relation/core.properties @@ -1,3 +1,3 @@ -#Written by CorePropertiesLocator -#Mon Sep 14 10:05:54 UTC 2015 -name=relation +#Written by CorePropertiesLocator +#Mon Sep 14 10:05:54 UTC 2015 +name=relation diff --git a/resources/cache/empty/similarity/conf/currency.xml b/resources/cache/empty/similarity/conf/currency.xml index 5c6cfaf0..3a9c58af 100644 --- a/resources/cache/empty/similarity/conf/currency.xml +++ b/resources/cache/empty/similarity/conf/currency.xml @@ -1,67 +1,67 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/cache/empty/similarity/conf/elevate.xml b/resources/cache/empty/similarity/conf/elevate.xml index e4769ccf..25d5cebe 100644 --- a/resources/cache/empty/similarity/conf/elevate.xml +++ b/resources/cache/empty/similarity/conf/elevate.xml @@ -1,38 +1,38 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/resources/cache/empty/similarity/conf/lang/contractions_ca.txt b/resources/cache/empty/similarity/conf/lang/contractions_ca.txt index 116644f2..307a85f9 100644 --- a/resources/cache/empty/similarity/conf/lang/contractions_ca.txt +++ b/resources/cache/empty/similarity/conf/lang/contractions_ca.txt @@ -1,8 +1,8 @@ -# Set of Catalan contractions for ElisionFilter -# TODO: load this as a resource from the analyzer and sync it in build.xml -d -l -m -n -s -t +# Set of Catalan contractions for ElisionFilter +# TODO: load this as a resource from the analyzer and sync it in build.xml +d +l +m +n +s +t diff --git a/resources/cache/empty/similarity/conf/lang/contractions_fr.txt b/resources/cache/empty/similarity/conf/lang/contractions_fr.txt index 6de73c27..f1bba51b 100644 --- a/resources/cache/empty/similarity/conf/lang/contractions_fr.txt +++ b/resources/cache/empty/similarity/conf/lang/contractions_fr.txt @@ -1,15 +1,15 @@ -# Set of French contractions for ElisionFilter -# TODO: load this as a resource from the analyzer and sync it in build.xml -l -m -t -qu -n -s -j -d -c -jusqu -quoiqu -lorsqu -puisqu +# Set of French contractions for ElisionFilter +# TODO: load this as a resource from the analyzer and sync it in build.xml +l +m +t +qu +n +s +j +d +c +jusqu +quoiqu +lorsqu +puisqu diff --git a/resources/cache/empty/similarity/conf/lang/contractions_ga.txt b/resources/cache/empty/similarity/conf/lang/contractions_ga.txt index 849b0c6e..9ebe7fa3 100644 --- a/resources/cache/empty/similarity/conf/lang/contractions_ga.txt +++ b/resources/cache/empty/similarity/conf/lang/contractions_ga.txt @@ -1,5 +1,5 @@ -# Set of Irish contractions for ElisionFilter -# TODO: load this as a resource from the analyzer and sync it in build.xml -d -m -b +# Set of Irish contractions for ElisionFilter +# TODO: load this as a resource from the analyzer and sync it in build.xml +d +m +b diff --git a/resources/cache/empty/similarity/conf/lang/contractions_it.txt b/resources/cache/empty/similarity/conf/lang/contractions_it.txt index 790b5af4..cac04095 100644 --- a/resources/cache/empty/similarity/conf/lang/contractions_it.txt +++ b/resources/cache/empty/similarity/conf/lang/contractions_it.txt @@ -1,23 +1,23 @@ -# Set of Italian contractions for ElisionFilter -# TODO: load this as a resource from the analyzer and sync it in build.xml -c -l -all -dall -dell -nell -sull -coll -pell -gl -agl -dagl -degl -negl -sugl -un -m -t -s -v -d +# Set of Italian contractions for ElisionFilter +# TODO: load this as a resource from the analyzer and sync it in build.xml +c +l +all +dall +dell +nell +sull +coll +pell +gl +agl +dagl +degl +negl +sugl +un +m +t +s +v +d diff --git a/resources/cache/empty/similarity/conf/lang/hyphenations_ga.txt b/resources/cache/empty/similarity/conf/lang/hyphenations_ga.txt index fce41006..4d2642cc 100644 --- a/resources/cache/empty/similarity/conf/lang/hyphenations_ga.txt +++ b/resources/cache/empty/similarity/conf/lang/hyphenations_ga.txt @@ -1,5 +1,5 @@ -# Set of Irish hyphenations for StopFilter -# TODO: load this as a resource from the analyzer and sync it in build.xml -h -n -t +# Set of Irish hyphenations for StopFilter +# TODO: load this as a resource from the analyzer and sync it in build.xml +h +n +t diff --git a/resources/cache/empty/similarity/conf/lang/stemdict_nl.txt b/resources/cache/empty/similarity/conf/lang/stemdict_nl.txt index 01dd3bb8..44107297 100644 --- a/resources/cache/empty/similarity/conf/lang/stemdict_nl.txt +++ b/resources/cache/empty/similarity/conf/lang/stemdict_nl.txt @@ -1,6 +1,6 @@ -# Set of overrides for the dutch stemmer -# TODO: load this as a resource from the analyzer and sync it in build.xml -fiets fiets -bromfiets bromfiets -ei eier -kind kinder +# Set of overrides for the dutch stemmer +# TODO: load this as a resource from the analyzer and sync it in build.xml +fiets fiets +bromfiets bromfiets +ei eier +kind kinder diff --git a/resources/cache/empty/similarity/conf/lang/stoptags_ja.txt b/resources/cache/empty/similarity/conf/lang/stoptags_ja.txt index 2faf2a68..71b75084 100644 --- a/resources/cache/empty/similarity/conf/lang/stoptags_ja.txt +++ b/resources/cache/empty/similarity/conf/lang/stoptags_ja.txt @@ -1,420 +1,420 @@ -# -# This file defines a Japanese stoptag set for JapanesePartOfSpeechStopFilter. -# -# Any token with a part-of-speech tag that exactly matches those defined in this -# file are removed from the token stream. -# -# Set your own stoptags by uncommenting the lines below. Note that comments are -# not allowed on the same line as a stoptag. See LUCENE-3745 for frequency lists, -# etc. that can be useful for building you own stoptag set. -# -# The entire possible tagset is provided below for convenience. -# -##### -# noun: unclassified nouns -#名詞 -# -# noun-common: Common nouns or nouns where the sub-classification is undefined -#名詞-一般 -# -# noun-proper: Proper nouns where the sub-classification is undefined -#名詞-固有名詞 -# -# noun-proper-misc: miscellaneous proper nouns -#名詞-固有名詞-一般 -# -# noun-proper-person: Personal names where the sub-classification is undefined -#名詞-固有名詞-人名 -# -# noun-proper-person-misc: names that cannot be divided into surname and -# given name; foreign names; names where the surname or given name is unknown. -# e.g. お市の方 -#名詞-固有名詞-人名-一般 -# -# noun-proper-person-surname: Mainly Japanese surnames. -# e.g. 山田 -#名詞-固有名詞-人名-姓 -# -# noun-proper-person-given_name: Mainly Japanese given names. -# e.g. 太郎 -#名詞-固有名詞-人名-名 -# -# noun-proper-organization: Names representing organizations. -# e.g. 通産省, NHK -#名詞-固有名詞-組織 -# -# noun-proper-place: Place names where the sub-classification is undefined -#名詞-固有名詞-地域 -# -# noun-proper-place-misc: Place names excluding countries. -# e.g. アジア, バルセロナ, 京都 -#名詞-固有名詞-地域-一般 -# -# noun-proper-place-country: Country names. -# e.g. 日本, オーストラリア -#名詞-固有名詞-地域-国 -# -# noun-pronoun: Pronouns where the sub-classification is undefined -#名詞-代名詞 -# -# noun-pronoun-misc: miscellaneous pronouns: -# e.g. それ, ここ, あいつ, あなた, あちこち, いくつ, どこか, なに, みなさん, みんな, わたくし, われわれ -#名詞-代名詞-一般 -# -# noun-pronoun-contraction: Spoken language contraction made by combining a -# pronoun and the particle 'wa'. -# e.g. ありゃ, こりゃ, こりゃあ, そりゃ, そりゃあ -#名詞-代名詞-縮約 -# -# noun-adverbial: Temporal nouns such as names of days or months that behave -# like adverbs. Nouns that represent amount or ratios and can be used adverbially, -# e.g. 金曜, 一月, 午後, 少量 -#名詞-副詞可能 -# -# noun-verbal: Nouns that take arguments with case and can appear followed by -# 'suru' and related verbs (する, できる, なさる, くださる) -# e.g. インプット, 愛着, 悪化, 悪戦苦闘, 一安心, 下取り -#名詞-サ変接続 -# -# noun-adjective-base: The base form of adjectives, words that appear before な ("na") -# e.g. 健康, 安易, 駄目, だめ -#名詞-形容動詞語幹 -# -# noun-numeric: Arabic numbers, Chinese numerals, and counters like 何 (回), 数. -# e.g. 0, 1, 2, 何, 数, 幾 -#名詞-数 -# -# noun-affix: noun affixes where the sub-classification is undefined -#名詞-非自立 -# -# noun-affix-misc: Of adnominalizers, the case-marker の ("no"), and words that -# attach to the base form of inflectional words, words that cannot be classified -# into any of the other categories below. This category includes indefinite nouns. -# e.g. あかつき, 暁, かい, 甲斐, 気, きらい, 嫌い, くせ, 癖, こと, 事, ごと, 毎, しだい, 次第, -# 順, せい, 所為, ついで, 序で, つもり, 積もり, 点, どころ, の, はず, 筈, はずみ, 弾み, -# 拍子, ふう, ふり, 振り, ほう, 方, 旨, もの, 物, 者, ゆえ, 故, ゆえん, 所以, わけ, 訳, -# わり, 割り, 割, ん-口語/, もん-口語/ -#名詞-非自立-一般 -# -# noun-affix-adverbial: noun affixes that that can behave as adverbs. -# e.g. あいだ, 間, あげく, 挙げ句, あと, 後, 余り, 以外, 以降, 以後, 以上, 以前, 一方, うえ, -# 上, うち, 内, おり, 折り, かぎり, 限り, きり, っきり, 結果, ころ, 頃, さい, 際, 最中, さなか, -# 最中, じたい, 自体, たび, 度, ため, 為, つど, 都度, とおり, 通り, とき, 時, ところ, 所, -# とたん, 途端, なか, 中, のち, 後, ばあい, 場合, 日, ぶん, 分, ほか, 他, まえ, 前, まま, -# 儘, 侭, みぎり, 矢先 -#名詞-非自立-副詞可能 -# -# noun-affix-aux: noun affixes treated as 助動詞 ("auxiliary verb") in school grammars -# with the stem よう(だ) ("you(da)"). -# e.g. よう, やう, 様 (よう) -#名詞-非自立-助動詞語幹 -# -# noun-affix-adjective-base: noun affixes that can connect to the indeclinable -# connection form な (aux "da"). -# e.g. みたい, ふう -#名詞-非自立-形容動詞語幹 -# -# noun-special: special nouns where the sub-classification is undefined. -#名詞-特殊 -# -# noun-special-aux: The そうだ ("souda") stem form that is used for reporting news, is -# treated as 助動詞 ("auxiliary verb") in school grammars, and attach to the base -# form of inflectional words. -# e.g. そう -#名詞-特殊-助動詞語幹 -# -# noun-suffix: noun suffixes where the sub-classification is undefined. -#名詞-接尾 -# -# noun-suffix-misc: Of the nouns or stem forms of other parts of speech that connect -# to ガル or タイ and can combine into compound nouns, words that cannot be classified into -# any of the other categories below. In general, this category is more inclusive than -# 接尾語 ("suffix") and is usually the last element in a compound noun. -# e.g. おき, かた, 方, 甲斐 (がい), がかり, ぎみ, 気味, ぐるみ, (~した) さ, 次第, 済 (ず) み, -# よう, (でき)っこ, 感, 観, 性, 学, 類, 面, 用 -#名詞-接尾-一般 -# -# noun-suffix-person: Suffixes that form nouns and attach to person names more often -# than other nouns. -# e.g. 君, 様, 著 -#名詞-接尾-人名 -# -# noun-suffix-place: Suffixes that form nouns and attach to place names more often -# than other nouns. -# e.g. 町, 市, 県 -#名詞-接尾-地域 -# -# noun-suffix-verbal: Of the suffixes that attach to nouns and form nouns, those that -# can appear before スル ("suru"). -# e.g. 化, 視, 分け, 入り, 落ち, 買い -#名詞-接尾-サ変接続 -# -# noun-suffix-aux: The stem form of そうだ (様態) that is used to indicate conditions, -# is treated as 助動詞 ("auxiliary verb") in school grammars, and attach to the -# conjunctive form of inflectional words. -# e.g. そう -#名詞-接尾-助動詞語幹 -# -# noun-suffix-adjective-base: Suffixes that attach to other nouns or the conjunctive -# form of inflectional words and appear before the copula だ ("da"). -# e.g. 的, げ, がち -#名詞-接尾-形容動詞語幹 -# -# noun-suffix-adverbial: Suffixes that attach to other nouns and can behave as adverbs. -# e.g. 後 (ご), 以後, 以降, 以前, 前後, 中, 末, 上, 時 (じ) -#名詞-接尾-副詞可能 -# -# noun-suffix-classifier: Suffixes that attach to numbers and form nouns. This category -# is more inclusive than 助数詞 ("classifier") and includes common nouns that attach -# to numbers. -# e.g. 個, つ, 本, 冊, パーセント, cm, kg, カ月, か国, 区画, 時間, 時半 -#名詞-接尾-助数詞 -# -# noun-suffix-special: Special suffixes that mainly attach to inflecting words. -# e.g. (楽し) さ, (考え) 方 -#名詞-接尾-特殊 -# -# noun-suffix-conjunctive: Nouns that behave like conjunctions and join two words -# together. -# e.g. (日本) 対 (アメリカ), 対 (アメリカ), (3) 対 (5), (女優) 兼 (主婦) -#名詞-接続詞的 -# -# noun-verbal_aux: Nouns that attach to the conjunctive particle て ("te") and are -# semantically verb-like. -# e.g. ごらん, ご覧, 御覧, 頂戴 -#名詞-動詞非自立的 -# -# noun-quotation: text that cannot be segmented into words, proverbs, Chinese poetry, -# dialects, English, etc. Currently, the only entry for 名詞 引用文字列 ("noun quotation") -# is いわく ("iwaku"). -#名詞-引用文字列 -# -# noun-nai_adjective: Words that appear before the auxiliary verb ない ("nai") and -# behave like an adjective. -# e.g. 申し訳, 仕方, とんでも, 違い -#名詞-ナイ形容詞語幹 -# -##### -# prefix: unclassified prefixes -#接頭詞 -# -# prefix-nominal: Prefixes that attach to nouns (including adjective stem forms) -# excluding numerical expressions. -# e.g. お (水), 某 (氏), 同 (社), 故 (~氏), 高 (品質), お (見事), ご (立派) -#接頭詞-名詞接続 -# -# prefix-verbal: Prefixes that attach to the imperative form of a verb or a verb -# in conjunctive form followed by なる/なさる/くださる. -# e.g. お (読みなさい), お (座り) -#接頭詞-動詞接続 -# -# prefix-adjectival: Prefixes that attach to adjectives. -# e.g. お (寒いですねえ), バカ (でかい) -#接頭詞-形容詞接続 -# -# prefix-numerical: Prefixes that attach to numerical expressions. -# e.g. 約, およそ, 毎時 -#接頭詞-数接続 -# -##### -# verb: unclassified verbs -#動詞 -# -# verb-main: -#動詞-自立 -# -# verb-auxiliary: -#動詞-非自立 -# -# verb-suffix: -#動詞-接尾 -# -##### -# adjective: unclassified adjectives -#形容詞 -# -# adjective-main: -#形容詞-自立 -# -# adjective-auxiliary: -#形容詞-非自立 -# -# adjective-suffix: -#形容詞-接尾 -# -##### -# adverb: unclassified adverbs -#副詞 -# -# adverb-misc: Words that can be segmented into one unit and where adnominal -# modification is not possible. -# e.g. あいかわらず, 多分 -#副詞-一般 -# -# adverb-particle_conjunction: Adverbs that can be followed by の, は, に, -# な, する, だ, etc. -# e.g. こんなに, そんなに, あんなに, なにか, なんでも -#副詞-助詞類接続 -# -##### -# adnominal: Words that only have noun-modifying forms. -# e.g. この, その, あの, どの, いわゆる, なんらかの, 何らかの, いろんな, こういう, そういう, ああいう, -# どういう, こんな, そんな, あんな, どんな, 大きな, 小さな, おかしな, ほんの, たいした, -# 「(, も) さる (ことながら)」, 微々たる, 堂々たる, 単なる, いかなる, 我が」「同じ, 亡き -#連体詞 -# -##### -# conjunction: Conjunctions that can occur independently. -# e.g. が, けれども, そして, じゃあ, それどころか -接続詞 -# -##### -# particle: unclassified particles. -助詞 -# -# particle-case: case particles where the subclassification is undefined. -助詞-格助詞 -# -# particle-case-misc: Case particles. -# e.g. から, が, で, と, に, へ, より, を, の, にて -助詞-格助詞-一般 -# -# particle-case-quote: the "to" that appears after nouns, a person’s speech, -# quotation marks, expressions of decisions from a meeting, reasons, judgements, -# conjectures, etc. -# e.g. ( だ) と (述べた.), ( である) と (して執行猶予...) -助詞-格助詞-引用 -# -# particle-case-compound: Compounds of particles and verbs that mainly behave -# like case particles. -# e.g. という, といった, とかいう, として, とともに, と共に, でもって, にあたって, に当たって, に当って, -# にあたり, に当たり, に当り, に当たる, にあたる, において, に於いて,に於て, における, に於ける, -# にかけ, にかけて, にかんし, に関し, にかんして, に関して, にかんする, に関する, に際し, -# に際して, にしたがい, に従い, に従う, にしたがって, に従って, にたいし, に対し, にたいして, -# に対して, にたいする, に対する, について, につき, につけ, につけて, につれ, につれて, にとって, -# にとり, にまつわる, によって, に依って, に因って, により, に依り, に因り, による, に依る, に因る, -# にわたって, にわたる, をもって, を以って, を通じ, を通じて, を通して, をめぐって, をめぐり, をめぐる, -# って-口語/, ちゅう-関西弁「という」/, (何) ていう (人)-口語/, っていう-口語/, といふ, とかいふ -助詞-格助詞-連語 -# -# particle-conjunctive: -# e.g. から, からには, が, けれど, けれども, けど, し, つつ, て, で, と, ところが, どころか, とも, ども, -# ながら, なり, ので, のに, ば, ものの, や ( した), やいなや, (ころん) じゃ(いけない)-口語/, -# (行っ) ちゃ(いけない)-口語/, (言っ) たって (しかたがない)-口語/, (それがなく)ったって (平気)-口語/ -助詞-接続助詞 -# -# particle-dependency: -# e.g. こそ, さえ, しか, すら, は, も, ぞ -助詞-係助詞 -# -# particle-adverbial: -# e.g. がてら, かも, くらい, 位, ぐらい, しも, (学校) じゃ(これが流行っている)-口語/, -# (それ)じゃあ (よくない)-口語/, ずつ, (私) なぞ, など, (私) なり (に), (先生) なんか (大嫌い)-口語/, -# (私) なんぞ, (先生) なんて (大嫌い)-口語/, のみ, だけ, (私) だって-口語/, だに, -# (彼)ったら-口語/, (お茶) でも (いかが), 等 (とう), (今後) とも, ばかり, ばっか-口語/, ばっかり-口語/, -# ほど, 程, まで, 迄, (誰) も (が)([助詞-格助詞] および [助詞-係助詞] の前に位置する「も」) -助詞-副助詞 -# -# particle-interjective: particles with interjective grammatical roles. -# e.g. (松島) や -助詞-間投助詞 -# -# particle-coordinate: -# e.g. と, たり, だの, だり, とか, なり, や, やら -助詞-並立助詞 -# -# particle-final: -# e.g. かい, かしら, さ, ぜ, (だ)っけ-口語/, (とまってる) で-方言/, な, ナ, なあ-口語/, ぞ, ね, ネ, -# ねぇ-口語/, ねえ-口語/, ねん-方言/, の, のう-口語/, や, よ, ヨ, よぉ-口語/, わ, わい-口語/ -助詞-終助詞 -# -# particle-adverbial/conjunctive/final: The particle "ka" when unknown whether it is -# adverbial, conjunctive, or sentence final. For example: -# (a) 「A か B か」. Ex:「(国内で運用する) か,(海外で運用する) か (.)」 -# (b) Inside an adverb phrase. Ex:「(幸いという) か (, 死者はいなかった.)」 -# 「(祈りが届いたせい) か (, 試験に合格した.)」 -# (c) 「かのように」. Ex:「(何もなかった) か (のように振る舞った.)」 -# e.g. か -助詞-副助詞/並立助詞/終助詞 -# -# particle-adnominalizer: The "no" that attaches to nouns and modifies -# non-inflectional words. -助詞-連体化 -# -# particle-adnominalizer: The "ni" and "to" that appear following nouns and adverbs -# that are giongo, giseigo, or gitaigo. -# e.g. に, と -助詞-副詞化 -# -# particle-special: A particle that does not fit into one of the above classifications. -# This includes particles that are used in Tanka, Haiku, and other poetry. -# e.g. かな, けむ, ( しただろう) に, (あんた) にゃ(わからん), (俺) ん (家) -助詞-特殊 -# -##### -# auxiliary-verb: -助動詞 -# -##### -# interjection: Greetings and other exclamations. -# e.g. おはよう, おはようございます, こんにちは, こんばんは, ありがとう, どうもありがとう, ありがとうございます, -# いただきます, ごちそうさま, さよなら, さようなら, はい, いいえ, ごめん, ごめんなさい -#感動詞 -# -##### -# symbol: unclassified Symbols. -記号 -# -# symbol-misc: A general symbol not in one of the categories below. -# e.g. [○◎@$〒→+] -記号-一般 -# -# symbol-comma: Commas -# e.g. [,、] -記号-読点 -# -# symbol-period: Periods and full stops. -# e.g. [..。] -記号-句点 -# -# symbol-space: Full-width whitespace. -記号-空白 -# -# symbol-open_bracket: -# e.g. [({‘“『【] -記号-括弧開 -# -# symbol-close_bracket: -# e.g. [)}’”』」】] -記号-括弧閉 -# -# symbol-alphabetic: -#記号-アルファベット -# -##### -# other: unclassified other -#その他 -# -# other-interjection: Words that are hard to classify as noun-suffixes or -# sentence-final particles. -# e.g. (だ)ァ -その他-間投 -# -##### -# filler: Aizuchi that occurs during a conversation or sounds inserted as filler. -# e.g. あの, うんと, えと -フィラー -# -##### -# non-verbal: non-verbal sound. -非言語音 -# -##### -# fragment: -#語断片 -# -##### -# unknown: unknown part of speech. -#未知語 -# -##### End of file +# +# This file defines a Japanese stoptag set for JapanesePartOfSpeechStopFilter. +# +# Any token with a part-of-speech tag that exactly matches those defined in this +# file are removed from the token stream. +# +# Set your own stoptags by uncommenting the lines below. Note that comments are +# not allowed on the same line as a stoptag. See LUCENE-3745 for frequency lists, +# etc. that can be useful for building you own stoptag set. +# +# The entire possible tagset is provided below for convenience. +# +##### +# noun: unclassified nouns +#名詞 +# +# noun-common: Common nouns or nouns where the sub-classification is undefined +#名詞-一般 +# +# noun-proper: Proper nouns where the sub-classification is undefined +#名詞-固有名詞 +# +# noun-proper-misc: miscellaneous proper nouns +#名詞-固有名詞-一般 +# +# noun-proper-person: Personal names where the sub-classification is undefined +#名詞-固有名詞-人名 +# +# noun-proper-person-misc: names that cannot be divided into surname and +# given name; foreign names; names where the surname or given name is unknown. +# e.g. お市の方 +#名詞-固有名詞-人名-一般 +# +# noun-proper-person-surname: Mainly Japanese surnames. +# e.g. 山田 +#名詞-固有名詞-人名-姓 +# +# noun-proper-person-given_name: Mainly Japanese given names. +# e.g. 太郎 +#名詞-固有名詞-人名-名 +# +# noun-proper-organization: Names representing organizations. +# e.g. 通産省, NHK +#名詞-固有名詞-組織 +# +# noun-proper-place: Place names where the sub-classification is undefined +#名詞-固有名詞-地域 +# +# noun-proper-place-misc: Place names excluding countries. +# e.g. アジア, バルセロナ, 京都 +#名詞-固有名詞-地域-一般 +# +# noun-proper-place-country: Country names. +# e.g. 日本, オーストラリア +#名詞-固有名詞-地域-国 +# +# noun-pronoun: Pronouns where the sub-classification is undefined +#名詞-代名詞 +# +# noun-pronoun-misc: miscellaneous pronouns: +# e.g. それ, ここ, あいつ, あなた, あちこち, いくつ, どこか, なに, みなさん, みんな, わたくし, われわれ +#名詞-代名詞-一般 +# +# noun-pronoun-contraction: Spoken language contraction made by combining a +# pronoun and the particle 'wa'. +# e.g. ありゃ, こりゃ, こりゃあ, そりゃ, そりゃあ +#名詞-代名詞-縮約 +# +# noun-adverbial: Temporal nouns such as names of days or months that behave +# like adverbs. Nouns that represent amount or ratios and can be used adverbially, +# e.g. 金曜, 一月, 午後, 少量 +#名詞-副詞可能 +# +# noun-verbal: Nouns that take arguments with case and can appear followed by +# 'suru' and related verbs (する, できる, なさる, くださる) +# e.g. インプット, 愛着, 悪化, 悪戦苦闘, 一安心, 下取り +#名詞-サ変接続 +# +# noun-adjective-base: The base form of adjectives, words that appear before な ("na") +# e.g. 健康, 安易, 駄目, だめ +#名詞-形容動詞語幹 +# +# noun-numeric: Arabic numbers, Chinese numerals, and counters like 何 (回), 数. +# e.g. 0, 1, 2, 何, 数, 幾 +#名詞-数 +# +# noun-affix: noun affixes where the sub-classification is undefined +#名詞-非自立 +# +# noun-affix-misc: Of adnominalizers, the case-marker の ("no"), and words that +# attach to the base form of inflectional words, words that cannot be classified +# into any of the other categories below. This category includes indefinite nouns. +# e.g. あかつき, 暁, かい, 甲斐, 気, きらい, 嫌い, くせ, 癖, こと, 事, ごと, 毎, しだい, 次第, +# 順, せい, 所為, ついで, 序で, つもり, 積もり, 点, どころ, の, はず, 筈, はずみ, 弾み, +# 拍子, ふう, ふり, 振り, ほう, 方, 旨, もの, 物, 者, ゆえ, 故, ゆえん, 所以, わけ, 訳, +# わり, 割り, 割, ん-口語/, もん-口語/ +#名詞-非自立-一般 +# +# noun-affix-adverbial: noun affixes that that can behave as adverbs. +# e.g. あいだ, 間, あげく, 挙げ句, あと, 後, 余り, 以外, 以降, 以後, 以上, 以前, 一方, うえ, +# 上, うち, 内, おり, 折り, かぎり, 限り, きり, っきり, 結果, ころ, 頃, さい, 際, 最中, さなか, +# 最中, じたい, 自体, たび, 度, ため, 為, つど, 都度, とおり, 通り, とき, 時, ところ, 所, +# とたん, 途端, なか, 中, のち, 後, ばあい, 場合, 日, ぶん, 分, ほか, 他, まえ, 前, まま, +# 儘, 侭, みぎり, 矢先 +#名詞-非自立-副詞可能 +# +# noun-affix-aux: noun affixes treated as 助動詞 ("auxiliary verb") in school grammars +# with the stem よう(だ) ("you(da)"). +# e.g. よう, やう, 様 (よう) +#名詞-非自立-助動詞語幹 +# +# noun-affix-adjective-base: noun affixes that can connect to the indeclinable +# connection form な (aux "da"). +# e.g. みたい, ふう +#名詞-非自立-形容動詞語幹 +# +# noun-special: special nouns where the sub-classification is undefined. +#名詞-特殊 +# +# noun-special-aux: The そうだ ("souda") stem form that is used for reporting news, is +# treated as 助動詞 ("auxiliary verb") in school grammars, and attach to the base +# form of inflectional words. +# e.g. そう +#名詞-特殊-助動詞語幹 +# +# noun-suffix: noun suffixes where the sub-classification is undefined. +#名詞-接尾 +# +# noun-suffix-misc: Of the nouns or stem forms of other parts of speech that connect +# to ガル or タイ and can combine into compound nouns, words that cannot be classified into +# any of the other categories below. In general, this category is more inclusive than +# 接尾語 ("suffix") and is usually the last element in a compound noun. +# e.g. おき, かた, 方, 甲斐 (がい), がかり, ぎみ, 気味, ぐるみ, (~した) さ, 次第, 済 (ず) み, +# よう, (でき)っこ, 感, 観, 性, 学, 類, 面, 用 +#名詞-接尾-一般 +# +# noun-suffix-person: Suffixes that form nouns and attach to person names more often +# than other nouns. +# e.g. 君, 様, 著 +#名詞-接尾-人名 +# +# noun-suffix-place: Suffixes that form nouns and attach to place names more often +# than other nouns. +# e.g. 町, 市, 県 +#名詞-接尾-地域 +# +# noun-suffix-verbal: Of the suffixes that attach to nouns and form nouns, those that +# can appear before スル ("suru"). +# e.g. 化, 視, 分け, 入り, 落ち, 買い +#名詞-接尾-サ変接続 +# +# noun-suffix-aux: The stem form of そうだ (様態) that is used to indicate conditions, +# is treated as 助動詞 ("auxiliary verb") in school grammars, and attach to the +# conjunctive form of inflectional words. +# e.g. そう +#名詞-接尾-助動詞語幹 +# +# noun-suffix-adjective-base: Suffixes that attach to other nouns or the conjunctive +# form of inflectional words and appear before the copula だ ("da"). +# e.g. 的, げ, がち +#名詞-接尾-形容動詞語幹 +# +# noun-suffix-adverbial: Suffixes that attach to other nouns and can behave as adverbs. +# e.g. 後 (ご), 以後, 以降, 以前, 前後, 中, 末, 上, 時 (じ) +#名詞-接尾-副詞可能 +# +# noun-suffix-classifier: Suffixes that attach to numbers and form nouns. This category +# is more inclusive than 助数詞 ("classifier") and includes common nouns that attach +# to numbers. +# e.g. 個, つ, 本, 冊, パーセント, cm, kg, カ月, か国, 区画, 時間, 時半 +#名詞-接尾-助数詞 +# +# noun-suffix-special: Special suffixes that mainly attach to inflecting words. +# e.g. (楽し) さ, (考え) 方 +#名詞-接尾-特殊 +# +# noun-suffix-conjunctive: Nouns that behave like conjunctions and join two words +# together. +# e.g. (日本) 対 (アメリカ), 対 (アメリカ), (3) 対 (5), (女優) 兼 (主婦) +#名詞-接続詞的 +# +# noun-verbal_aux: Nouns that attach to the conjunctive particle て ("te") and are +# semantically verb-like. +# e.g. ごらん, ご覧, 御覧, 頂戴 +#名詞-動詞非自立的 +# +# noun-quotation: text that cannot be segmented into words, proverbs, Chinese poetry, +# dialects, English, etc. Currently, the only entry for 名詞 引用文字列 ("noun quotation") +# is いわく ("iwaku"). +#名詞-引用文字列 +# +# noun-nai_adjective: Words that appear before the auxiliary verb ない ("nai") and +# behave like an adjective. +# e.g. 申し訳, 仕方, とんでも, 違い +#名詞-ナイ形容詞語幹 +# +##### +# prefix: unclassified prefixes +#接頭詞 +# +# prefix-nominal: Prefixes that attach to nouns (including adjective stem forms) +# excluding numerical expressions. +# e.g. お (水), 某 (氏), 同 (社), 故 (~氏), 高 (品質), お (見事), ご (立派) +#接頭詞-名詞接続 +# +# prefix-verbal: Prefixes that attach to the imperative form of a verb or a verb +# in conjunctive form followed by なる/なさる/くださる. +# e.g. お (読みなさい), お (座り) +#接頭詞-動詞接続 +# +# prefix-adjectival: Prefixes that attach to adjectives. +# e.g. お (寒いですねえ), バカ (でかい) +#接頭詞-形容詞接続 +# +# prefix-numerical: Prefixes that attach to numerical expressions. +# e.g. 約, およそ, 毎時 +#接頭詞-数接続 +# +##### +# verb: unclassified verbs +#動詞 +# +# verb-main: +#動詞-自立 +# +# verb-auxiliary: +#動詞-非自立 +# +# verb-suffix: +#動詞-接尾 +# +##### +# adjective: unclassified adjectives +#形容詞 +# +# adjective-main: +#形容詞-自立 +# +# adjective-auxiliary: +#形容詞-非自立 +# +# adjective-suffix: +#形容詞-接尾 +# +##### +# adverb: unclassified adverbs +#副詞 +# +# adverb-misc: Words that can be segmented into one unit and where adnominal +# modification is not possible. +# e.g. あいかわらず, 多分 +#副詞-一般 +# +# adverb-particle_conjunction: Adverbs that can be followed by の, は, に, +# な, する, だ, etc. +# e.g. こんなに, そんなに, あんなに, なにか, なんでも +#副詞-助詞類接続 +# +##### +# adnominal: Words that only have noun-modifying forms. +# e.g. この, その, あの, どの, いわゆる, なんらかの, 何らかの, いろんな, こういう, そういう, ああいう, +# どういう, こんな, そんな, あんな, どんな, 大きな, 小さな, おかしな, ほんの, たいした, +# 「(, も) さる (ことながら)」, 微々たる, 堂々たる, 単なる, いかなる, 我が」「同じ, 亡き +#連体詞 +# +##### +# conjunction: Conjunctions that can occur independently. +# e.g. が, けれども, そして, じゃあ, それどころか +接続詞 +# +##### +# particle: unclassified particles. +助詞 +# +# particle-case: case particles where the subclassification is undefined. +助詞-格助詞 +# +# particle-case-misc: Case particles. +# e.g. から, が, で, と, に, へ, より, を, の, にて +助詞-格助詞-一般 +# +# particle-case-quote: the "to" that appears after nouns, a person’s speech, +# quotation marks, expressions of decisions from a meeting, reasons, judgements, +# conjectures, etc. +# e.g. ( だ) と (述べた.), ( である) と (して執行猶予...) +助詞-格助詞-引用 +# +# particle-case-compound: Compounds of particles and verbs that mainly behave +# like case particles. +# e.g. という, といった, とかいう, として, とともに, と共に, でもって, にあたって, に当たって, に当って, +# にあたり, に当たり, に当り, に当たる, にあたる, において, に於いて,に於て, における, に於ける, +# にかけ, にかけて, にかんし, に関し, にかんして, に関して, にかんする, に関する, に際し, +# に際して, にしたがい, に従い, に従う, にしたがって, に従って, にたいし, に対し, にたいして, +# に対して, にたいする, に対する, について, につき, につけ, につけて, につれ, につれて, にとって, +# にとり, にまつわる, によって, に依って, に因って, により, に依り, に因り, による, に依る, に因る, +# にわたって, にわたる, をもって, を以って, を通じ, を通じて, を通して, をめぐって, をめぐり, をめぐる, +# って-口語/, ちゅう-関西弁「という」/, (何) ていう (人)-口語/, っていう-口語/, といふ, とかいふ +助詞-格助詞-連語 +# +# particle-conjunctive: +# e.g. から, からには, が, けれど, けれども, けど, し, つつ, て, で, と, ところが, どころか, とも, ども, +# ながら, なり, ので, のに, ば, ものの, や ( した), やいなや, (ころん) じゃ(いけない)-口語/, +# (行っ) ちゃ(いけない)-口語/, (言っ) たって (しかたがない)-口語/, (それがなく)ったって (平気)-口語/ +助詞-接続助詞 +# +# particle-dependency: +# e.g. こそ, さえ, しか, すら, は, も, ぞ +助詞-係助詞 +# +# particle-adverbial: +# e.g. がてら, かも, くらい, 位, ぐらい, しも, (学校) じゃ(これが流行っている)-口語/, +# (それ)じゃあ (よくない)-口語/, ずつ, (私) なぞ, など, (私) なり (に), (先生) なんか (大嫌い)-口語/, +# (私) なんぞ, (先生) なんて (大嫌い)-口語/, のみ, だけ, (私) だって-口語/, だに, +# (彼)ったら-口語/, (お茶) でも (いかが), 等 (とう), (今後) とも, ばかり, ばっか-口語/, ばっかり-口語/, +# ほど, 程, まで, 迄, (誰) も (が)([助詞-格助詞] および [助詞-係助詞] の前に位置する「も」) +助詞-副助詞 +# +# particle-interjective: particles with interjective grammatical roles. +# e.g. (松島) や +助詞-間投助詞 +# +# particle-coordinate: +# e.g. と, たり, だの, だり, とか, なり, や, やら +助詞-並立助詞 +# +# particle-final: +# e.g. かい, かしら, さ, ぜ, (だ)っけ-口語/, (とまってる) で-方言/, な, ナ, なあ-口語/, ぞ, ね, ネ, +# ねぇ-口語/, ねえ-口語/, ねん-方言/, の, のう-口語/, や, よ, ヨ, よぉ-口語/, わ, わい-口語/ +助詞-終助詞 +# +# particle-adverbial/conjunctive/final: The particle "ka" when unknown whether it is +# adverbial, conjunctive, or sentence final. For example: +# (a) 「A か B か」. Ex:「(国内で運用する) か,(海外で運用する) か (.)」 +# (b) Inside an adverb phrase. Ex:「(幸いという) か (, 死者はいなかった.)」 +# 「(祈りが届いたせい) か (, 試験に合格した.)」 +# (c) 「かのように」. Ex:「(何もなかった) か (のように振る舞った.)」 +# e.g. か +助詞-副助詞/並立助詞/終助詞 +# +# particle-adnominalizer: The "no" that attaches to nouns and modifies +# non-inflectional words. +助詞-連体化 +# +# particle-adnominalizer: The "ni" and "to" that appear following nouns and adverbs +# that are giongo, giseigo, or gitaigo. +# e.g. に, と +助詞-副詞化 +# +# particle-special: A particle that does not fit into one of the above classifications. +# This includes particles that are used in Tanka, Haiku, and other poetry. +# e.g. かな, けむ, ( しただろう) に, (あんた) にゃ(わからん), (俺) ん (家) +助詞-特殊 +# +##### +# auxiliary-verb: +助動詞 +# +##### +# interjection: Greetings and other exclamations. +# e.g. おはよう, おはようございます, こんにちは, こんばんは, ありがとう, どうもありがとう, ありがとうございます, +# いただきます, ごちそうさま, さよなら, さようなら, はい, いいえ, ごめん, ごめんなさい +#感動詞 +# +##### +# symbol: unclassified Symbols. +記号 +# +# symbol-misc: A general symbol not in one of the categories below. +# e.g. [○◎@$〒→+] +記号-一般 +# +# symbol-comma: Commas +# e.g. [,、] +記号-読点 +# +# symbol-period: Periods and full stops. +# e.g. [..。] +記号-句点 +# +# symbol-space: Full-width whitespace. +記号-空白 +# +# symbol-open_bracket: +# e.g. [({‘“『【] +記号-括弧開 +# +# symbol-close_bracket: +# e.g. [)}’”』」】] +記号-括弧閉 +# +# symbol-alphabetic: +#記号-アルファベット +# +##### +# other: unclassified other +#その他 +# +# other-interjection: Words that are hard to classify as noun-suffixes or +# sentence-final particles. +# e.g. (だ)ァ +その他-間投 +# +##### +# filler: Aizuchi that occurs during a conversation or sounds inserted as filler. +# e.g. あの, うんと, えと +フィラー +# +##### +# non-verbal: non-verbal sound. +非言語音 +# +##### +# fragment: +#語断片 +# +##### +# unknown: unknown part of speech. +#未知語 +# +##### End of file diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_ar.txt b/resources/cache/empty/similarity/conf/lang/stopwords_ar.txt index aca24303..046829db 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_ar.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_ar.txt @@ -1,125 +1,125 @@ -# This file was created by Jacques Savoy and is distributed under the BSD license. -# See http://members.unine.ch/jacques.savoy/clef/index.html. -# Also see http://www.opensource.org/licenses/bsd-license.html -# Cleaned on October 11, 2009 (not normalized, so use before normalization) -# This means that when modifying this list, you might need to add some -# redundant entries, for example containing forms with both أ and ا -من -ومن -منها -منه -في -وفي -فيها -فيه -و -ف -ثم -او -أو -ب -بها -به -ا -أ -اى -اي -أي -أى -لا -ولا -الا -ألا -إلا -لكن -ما -وما -كما -فما -عن -مع -اذا -إذا -ان -أن -إن -انها -أنها -إنها -انه -أنه -إنه -بان -بأن -فان -فأن -وان -وأن -وإن -التى -التي -الذى -الذي -الذين -الى -الي -إلى -إلي -على -عليها -عليه -اما -أما -إما -ايضا -أيضا -كل -وكل -لم -ولم -لن -ولن -هى -هي -هو -وهى -وهي -وهو -فهى -فهي -فهو -انت -أنت -لك -لها -له -هذه -هذا -تلك -ذلك -هناك -كانت -كان -يكون -تكون -وكانت -وكان -غير -بعض -قد -نحو -بين -بينما -منذ -ضمن -حيث -الان -الآن -خلال -بعد -قبل -حتى -عند -عندما -لدى -جميع +# This file was created by Jacques Savoy and is distributed under the BSD license. +# See http://members.unine.ch/jacques.savoy/clef/index.html. +# Also see http://www.opensource.org/licenses/bsd-license.html +# Cleaned on October 11, 2009 (not normalized, so use before normalization) +# This means that when modifying this list, you might need to add some +# redundant entries, for example containing forms with both أ and ا +من +ومن +منها +منه +في +وفي +فيها +فيه +و +ف +ثم +او +أو +ب +بها +به +ا +أ +اى +اي +أي +أى +لا +ولا +الا +ألا +إلا +لكن +ما +وما +كما +فما +عن +مع +اذا +إذا +ان +أن +إن +انها +أنها +إنها +انه +أنه +إنه +بان +بأن +فان +فأن +وان +وأن +وإن +التى +التي +الذى +الذي +الذين +الى +الي +إلى +إلي +على +عليها +عليه +اما +أما +إما +ايضا +أيضا +كل +وكل +لم +ولم +لن +ولن +هى +هي +هو +وهى +وهي +وهو +فهى +فهي +فهو +انت +أنت +لك +لها +له +هذه +هذا +تلك +ذلك +هناك +كانت +كان +يكون +تكون +وكانت +وكان +غير +بعض +قد +نحو +بين +بينما +منذ +ضمن +حيث +الان +الآن +خلال +بعد +قبل +حتى +عند +عندما +لدى +جميع diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_bg.txt b/resources/cache/empty/similarity/conf/lang/stopwords_bg.txt index 842ee8a8..1ae4ba2a 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_bg.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_bg.txt @@ -1,193 +1,193 @@ -# This file was created by Jacques Savoy and is distributed under the BSD license. -# See http://members.unine.ch/jacques.savoy/clef/index.html. -# Also see http://www.opensource.org/licenses/bsd-license.html -а -аз -ако -ала -бе -без -беше -би -бил -била -били -било -близо -бъдат -бъде -бяха -в -вас -ваш -ваша -вероятно -вече -взема -ви -вие -винаги -все -всеки -всички -всичко -всяка -във -въпреки -върху -г -ги -главно -го -д -да -дали -до -докато -докога -дори -досега -доста -е -едва -един -ето -за -зад -заедно -заради -засега -затова -защо -защото -и -из -или -им -има -имат -иска -й -каза -как -каква -какво -както -какъв -като -кога -когато -което -които -кой -който -колко -която -къде -където -към -ли -м -ме -между -мен -ми -мнозина -мога -могат -може -моля -момента -му -н -на -над -назад -най -направи -напред -например -нас -не -него -нея -ни -ние -никой -нито -но -някои -някой -няма -обаче -около -освен -особено -от -отгоре -отново -още -пак -по -повече -повечето -под -поне -поради -после -почти -прави -пред -преди -през -при -пък -първо -с -са -само -се -сега -си -скоро -след -сме -според -сред -срещу -сте -съм -със -също -т -тази -така -такива -такъв -там -твой -те -тези -ти -тн -то -това -тогава -този -той -толкова -точно -трябва -тук -тъй -тя -тях -у -харесва -ч -че -често -чрез -ще -щом -я +# This file was created by Jacques Savoy and is distributed under the BSD license. +# See http://members.unine.ch/jacques.savoy/clef/index.html. +# Also see http://www.opensource.org/licenses/bsd-license.html +а +аз +ако +ала +бе +без +беше +би +бил +била +били +било +близо +бъдат +бъде +бяха +в +вас +ваш +ваша +вероятно +вече +взема +ви +вие +винаги +все +всеки +всички +всичко +всяка +във +въпреки +върху +г +ги +главно +го +д +да +дали +до +докато +докога +дори +досега +доста +е +едва +един +ето +за +зад +заедно +заради +засега +затова +защо +защото +и +из +или +им +има +имат +иска +й +каза +как +каква +какво +както +какъв +като +кога +когато +което +които +кой +който +колко +която +къде +където +към +ли +м +ме +между +мен +ми +мнозина +мога +могат +може +моля +момента +му +н +на +над +назад +най +направи +напред +например +нас +не +него +нея +ни +ние +никой +нито +но +някои +някой +няма +обаче +около +освен +особено +от +отгоре +отново +още +пак +по +повече +повечето +под +поне +поради +после +почти +прави +пред +преди +през +при +пък +първо +с +са +само +се +сега +си +скоро +след +сме +според +сред +срещу +сте +съм +със +също +т +тази +така +такива +такъв +там +твой +те +тези +ти +тн +то +това +тогава +този +той +толкова +точно +трябва +тук +тъй +тя +тях +у +харесва +ч +че +често +чрез +ще +щом +я diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_ca.txt b/resources/cache/empty/similarity/conf/lang/stopwords_ca.txt index e618af55..3da65dea 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_ca.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_ca.txt @@ -1,220 +1,220 @@ -# Catalan stopwords from http://github.com/vcl/cue.language (Apache 2 Licensed) -a -abans -ací -ah -així -això -al -als -aleshores -algun -alguna -algunes -alguns -alhora -allà -allí -allò -altra -altre -altres -amb -ambdós -ambdues -apa -aquell -aquella -aquelles -aquells -aquest -aquesta -aquestes -aquests -aquí -baix -cada -cadascú -cadascuna -cadascunes -cadascuns -com -contra -d'un -d'una -d'unes -d'uns -dalt -de -del -dels -des -després -dins -dintre -donat -doncs -durant -e -eh -el -els -em -en -encara -ens -entre -érem -eren -éreu -es -és -esta -està -estàvem -estaven -estàveu -esteu -et -etc -ets -fins -fora -gairebé -ha -han -has -havia -he -hem -heu -hi -ho -i -igual -iguals -ja -l'hi -la -les -li -li'n -llavors -m'he -ma -mal -malgrat -mateix -mateixa -mateixes -mateixos -me -mentre -més -meu -meus -meva -meves -molt -molta -moltes -molts -mon -mons -n'he -n'hi -ne -ni -no -nogensmenys -només -nosaltres -nostra -nostre -nostres -o -oh -oi -on -pas -pel -pels -per -però -perquè -poc -poca -pocs -poques -potser -propi -qual -quals -quan -quant -que -què -quelcom -qui -quin -quina -quines -quins -s'ha -s'han -sa -semblant -semblants -ses -seu -seus -seva -seva -seves -si -sobre -sobretot -sóc -solament -sols -son -són -sons -sota -sou -t'ha -t'han -t'he -ta -tal -també -tampoc -tan -tant -tanta -tantes -teu -teus -teva -teves -ton -tons -tot -tota -totes -tots -un -una -unes -uns -us -va -vaig -vam -van -vas -veu -vosaltres -vostra -vostre -vostres +# Catalan stopwords from http://github.com/vcl/cue.language (Apache 2 Licensed) +a +abans +ací +ah +així +això +al +als +aleshores +algun +alguna +algunes +alguns +alhora +allà +allí +allò +altra +altre +altres +amb +ambdós +ambdues +apa +aquell +aquella +aquelles +aquells +aquest +aquesta +aquestes +aquests +aquí +baix +cada +cadascú +cadascuna +cadascunes +cadascuns +com +contra +d'un +d'una +d'unes +d'uns +dalt +de +del +dels +des +després +dins +dintre +donat +doncs +durant +e +eh +el +els +em +en +encara +ens +entre +érem +eren +éreu +es +és +esta +està +estàvem +estaven +estàveu +esteu +et +etc +ets +fins +fora +gairebé +ha +han +has +havia +he +hem +heu +hi +ho +i +igual +iguals +ja +l'hi +la +les +li +li'n +llavors +m'he +ma +mal +malgrat +mateix +mateixa +mateixes +mateixos +me +mentre +més +meu +meus +meva +meves +molt +molta +moltes +molts +mon +mons +n'he +n'hi +ne +ni +no +nogensmenys +només +nosaltres +nostra +nostre +nostres +o +oh +oi +on +pas +pel +pels +per +però +perquè +poc +poca +pocs +poques +potser +propi +qual +quals +quan +quant +que +què +quelcom +qui +quin +quina +quines +quins +s'ha +s'han +sa +semblant +semblants +ses +seu +seus +seva +seva +seves +si +sobre +sobretot +sóc +solament +sols +son +són +sons +sota +sou +t'ha +t'han +t'he +ta +tal +també +tampoc +tan +tant +tanta +tantes +teu +teus +teva +teves +ton +tons +tot +tota +totes +tots +un +una +unes +uns +us +va +vaig +vam +van +vas +veu +vosaltres +vostra +vostre +vostres diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_cz.txt b/resources/cache/empty/similarity/conf/lang/stopwords_cz.txt index e928df95..53c6097d 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_cz.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_cz.txt @@ -1,172 +1,172 @@ -a -s -k -o -i -u -v -z -dnes -cz -tímto -budeš -budem -byli -jseš -můj -svým -ta -tomto -tohle -tuto -tyto -jej -zda -proč -máte -tato -kam -tohoto -kdo -kteří -mi -nám -tom -tomuto -mít -nic -proto -kterou -byla -toho -protože -asi -ho -naši -napište -re -což -tím -takže -svých -její -svými -jste -aj -tu -tedy -teto -bylo -kde -ke -pravé -ji -nad -nejsou -či -pod -téma -mezi -přes -ty -pak -vám -ani -když -však -neg -jsem -tento -článku -články -aby -jsme -před -pta -jejich -byl -ještě -až -bez -také -pouze -první -vaše -která -nás -nový -tipy -pokud -může -strana -jeho -své -jiné -zprávy -nové -není -vás -jen -podle -zde -už -být -více -bude -již -než -který -by -které -co -nebo -ten -tak -má -při -od -po -jsou -jak -další -ale -si -se -ve -to -jako -za -zpět -ze -do -pro -je -na -atd -atp -jakmile -přičemž -já -on -ona -ono -oni -ony -my -vy -jí -ji -mě -mne -jemu -tomu -těm -těmu -němu -němuž -jehož -jíž -jelikož -jež -jakož -načež +a +s +k +o +i +u +v +z +dnes +cz +tímto +budeš +budem +byli +jseš +můj +svým +ta +tomto +tohle +tuto +tyto +jej +zda +proč +máte +tato +kam +tohoto +kdo +kteří +mi +nám +tom +tomuto +mít +nic +proto +kterou +byla +toho +protože +asi +ho +naši +napište +re +což +tím +takže +svých +její +svými +jste +aj +tu +tedy +teto +bylo +kde +ke +pravé +ji +nad +nejsou +či +pod +téma +mezi +přes +ty +pak +vám +ani +když +však +neg +jsem +tento +článku +články +aby +jsme +před +pta +jejich +byl +ještě +až +bez +také +pouze +první +vaše +která +nás +nový +tipy +pokud +může +strana +jeho +své +jiné +zprávy +nové +není +vás +jen +podle +zde +už +být +více +bude +již +než +který +by +které +co +nebo +ten +tak +má +při +od +po +jsou +jak +další +ale +si +se +ve +to +jako +za +zpět +ze +do +pro +je +na +atd +atp +jakmile +přičemž +já +on +ona +ono +oni +ony +my +vy +jí +ji +mě +mne +jemu +tomu +těm +těmu +němu +němuž +jehož +jíž +jelikož +jež +jakož +načež diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_da.txt b/resources/cache/empty/similarity/conf/lang/stopwords_da.txt index e25d49ce..42e6145b 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_da.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_da.txt @@ -1,110 +1,110 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/danish/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Danish stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - | This is a ranked list (commonest to rarest) of stopwords derived from - | a large text sample. - - -og | and -i | in -jeg | I -det | that (dem. pronoun)/it (pers. pronoun) -at | that (in front of a sentence)/to (with infinitive) -en | a/an -den | it (pers. pronoun)/that (dem. pronoun) -til | to/at/for/until/against/by/of/into, more -er | present tense of "to be" -som | who, as -på | on/upon/in/on/at/to/after/of/with/for, on -de | they -med | with/by/in, along -han | he -af | of/by/from/off/for/in/with/on, off -for | at/for/to/from/by/of/ago, in front/before, because -ikke | not -der | who/which, there/those -var | past tense of "to be" -mig | me/myself -sig | oneself/himself/herself/itself/themselves -men | but -et | a/an/one, one (number), someone/somebody/one -har | present tense of "to have" -om | round/about/for/in/a, about/around/down, if -vi | we -min | my -havde | past tense of "to have" -ham | him -hun | she -nu | now -over | over/above/across/by/beyond/past/on/about, over/past -da | then, when/as/since -fra | from/off/since, off, since -du | you -ud | out -sin | his/her/its/one's -dem | them -os | us/ourselves -op | up -man | you/one -hans | his -hvor | where -eller | or -hvad | what -skal | must/shall etc. -selv | myself/youself/herself/ourselves etc., even -her | here -alle | all/everyone/everybody etc. -vil | will (verb) -blev | past tense of "to stay/to remain/to get/to become" -kunne | could -ind | in -når | when -være | present tense of "to be" -dog | however/yet/after all -noget | something -ville | would -jo | you know/you see (adv), yes -deres | their/theirs -efter | after/behind/according to/for/by/from, later/afterwards -ned | down -skulle | should -denne | this -end | than -dette | this -mit | my/mine -også | also -under | under/beneath/below/during, below/underneath -have | have -dig | you -anden | other -hende | her -mine | my -alt | everything -meget | much/very, plenty of -sit | his, her, its, one's -sine | his, her, its, one's -vor | our -mod | against -disse | these -hvis | if -din | your/yours -nogle | some -hos | by/at -blive | be/become -mange | many -ad | by/through -bliver | present tense of "to be/to become" -hendes | her/hers -været | be -thi | for (conj) -jer | you -sådan | such, like this/like that + | From svn.tartarus.org/snowball/trunk/website/algorithms/danish/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Danish stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + | This is a ranked list (commonest to rarest) of stopwords derived from + | a large text sample. + + +og | and +i | in +jeg | I +det | that (dem. pronoun)/it (pers. pronoun) +at | that (in front of a sentence)/to (with infinitive) +en | a/an +den | it (pers. pronoun)/that (dem. pronoun) +til | to/at/for/until/against/by/of/into, more +er | present tense of "to be" +som | who, as +på | on/upon/in/on/at/to/after/of/with/for, on +de | they +med | with/by/in, along +han | he +af | of/by/from/off/for/in/with/on, off +for | at/for/to/from/by/of/ago, in front/before, because +ikke | not +der | who/which, there/those +var | past tense of "to be" +mig | me/myself +sig | oneself/himself/herself/itself/themselves +men | but +et | a/an/one, one (number), someone/somebody/one +har | present tense of "to have" +om | round/about/for/in/a, about/around/down, if +vi | we +min | my +havde | past tense of "to have" +ham | him +hun | she +nu | now +over | over/above/across/by/beyond/past/on/about, over/past +da | then, when/as/since +fra | from/off/since, off, since +du | you +ud | out +sin | his/her/its/one's +dem | them +os | us/ourselves +op | up +man | you/one +hans | his +hvor | where +eller | or +hvad | what +skal | must/shall etc. +selv | myself/youself/herself/ourselves etc., even +her | here +alle | all/everyone/everybody etc. +vil | will (verb) +blev | past tense of "to stay/to remain/to get/to become" +kunne | could +ind | in +når | when +være | present tense of "to be" +dog | however/yet/after all +noget | something +ville | would +jo | you know/you see (adv), yes +deres | their/theirs +efter | after/behind/according to/for/by/from, later/afterwards +ned | down +skulle | should +denne | this +end | than +dette | this +mit | my/mine +også | also +under | under/beneath/below/during, below/underneath +have | have +dig | you +anden | other +hende | her +mine | my +alt | everything +meget | much/very, plenty of +sit | his, her, its, one's +sine | his, her, its, one's +vor | our +mod | against +disse | these +hvis | if +din | your/yours +nogle | some +hos | by/at +blive | be/become +mange | many +ad | by/through +bliver | present tense of "to be/to become" +hendes | her/hers +været | be +thi | for (conj) +jer | you +sådan | such, like this/like that diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_de.txt b/resources/cache/empty/similarity/conf/lang/stopwords_de.txt index bb9933ee..86525e7a 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_de.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_de.txt @@ -1,294 +1,294 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/german/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A German stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - | The number of forms in this list is reduced significantly by passing it - | through the German stemmer. - - -aber | but - -alle | all -allem -allen -aller -alles - -als | than, as -also | so -am | an + dem -an | at - -ander | other -andere -anderem -anderen -anderer -anderes -anderm -andern -anderr -anders - -auch | also -auf | on -aus | out of -bei | by -bin | am -bis | until -bist | art -da | there -damit | with it -dann | then - -der | the -den -des -dem -die -das - -daß | that - -derselbe | the same -derselben -denselben -desselben -demselben -dieselbe -dieselben -dasselbe - -dazu | to that - -dein | thy -deine -deinem -deinen -deiner -deines - -denn | because - -derer | of those -dessen | of him - -dich | thee -dir | to thee -du | thou - -dies | this -diese -diesem -diesen -dieser -dieses - - -doch | (several meanings) -dort | (over) there - - -durch | through - -ein | a -eine -einem -einen -einer -eines - -einig | some -einige -einigem -einigen -einiger -einiges - -einmal | once - -er | he -ihn | him -ihm | to him - -es | it -etwas | something - -euer | your -eure -eurem -euren -eurer -eures - -für | for -gegen | towards -gewesen | p.p. of sein -hab | have -habe | have -haben | have -hat | has -hatte | had -hatten | had -hier | here -hin | there -hinter | behind - -ich | I -mich | me -mir | to me - - -ihr | you, to her -ihre -ihrem -ihren -ihrer -ihres -euch | to you - -im | in + dem -in | in -indem | while -ins | in + das -ist | is - -jede | each, every -jedem -jeden -jeder -jedes - -jene | that -jenem -jenen -jener -jenes - -jetzt | now -kann | can - -kein | no -keine -keinem -keinen -keiner -keines - -können | can -könnte | could -machen | do -man | one - -manche | some, many a -manchem -manchen -mancher -manches - -mein | my -meine -meinem -meinen -meiner -meines - -mit | with -muss | must -musste | had to -nach | to(wards) -nicht | not -nichts | nothing -noch | still, yet -nun | now -nur | only -ob | whether -oder | or -ohne | without -sehr | very - -sein | his -seine -seinem -seinen -seiner -seines - -selbst | self -sich | herself - -sie | they, she -ihnen | to them - -sind | are -so | so - -solche | such -solchem -solchen -solcher -solches - -soll | shall -sollte | should -sondern | but -sonst | else -über | over -um | about, around -und | and - -uns | us -unse -unsem -unsen -unser -unses - -unter | under -viel | much -vom | von + dem -von | from -vor | before -während | while -war | was -waren | were -warst | wast -was | what -weg | away, off -weil | because -weiter | further - -welche | which -welchem -welchen -welcher -welches - -wenn | when -werde | will -werden | will -wie | how -wieder | again -will | want -wir | we -wird | will -wirst | willst -wo | where -wollen | want -wollte | wanted -würde | would -würden | would -zu | to -zum | zu + dem -zur | zu + der -zwar | indeed -zwischen | between - + | From svn.tartarus.org/snowball/trunk/website/algorithms/german/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A German stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + | The number of forms in this list is reduced significantly by passing it + | through the German stemmer. + + +aber | but + +alle | all +allem +allen +aller +alles + +als | than, as +also | so +am | an + dem +an | at + +ander | other +andere +anderem +anderen +anderer +anderes +anderm +andern +anderr +anders + +auch | also +auf | on +aus | out of +bei | by +bin | am +bis | until +bist | art +da | there +damit | with it +dann | then + +der | the +den +des +dem +die +das + +daß | that + +derselbe | the same +derselben +denselben +desselben +demselben +dieselbe +dieselben +dasselbe + +dazu | to that + +dein | thy +deine +deinem +deinen +deiner +deines + +denn | because + +derer | of those +dessen | of him + +dich | thee +dir | to thee +du | thou + +dies | this +diese +diesem +diesen +dieser +dieses + + +doch | (several meanings) +dort | (over) there + + +durch | through + +ein | a +eine +einem +einen +einer +eines + +einig | some +einige +einigem +einigen +einiger +einiges + +einmal | once + +er | he +ihn | him +ihm | to him + +es | it +etwas | something + +euer | your +eure +eurem +euren +eurer +eures + +für | for +gegen | towards +gewesen | p.p. of sein +hab | have +habe | have +haben | have +hat | has +hatte | had +hatten | had +hier | here +hin | there +hinter | behind + +ich | I +mich | me +mir | to me + + +ihr | you, to her +ihre +ihrem +ihren +ihrer +ihres +euch | to you + +im | in + dem +in | in +indem | while +ins | in + das +ist | is + +jede | each, every +jedem +jeden +jeder +jedes + +jene | that +jenem +jenen +jener +jenes + +jetzt | now +kann | can + +kein | no +keine +keinem +keinen +keiner +keines + +können | can +könnte | could +machen | do +man | one + +manche | some, many a +manchem +manchen +mancher +manches + +mein | my +meine +meinem +meinen +meiner +meines + +mit | with +muss | must +musste | had to +nach | to(wards) +nicht | not +nichts | nothing +noch | still, yet +nun | now +nur | only +ob | whether +oder | or +ohne | without +sehr | very + +sein | his +seine +seinem +seinen +seiner +seines + +selbst | self +sich | herself + +sie | they, she +ihnen | to them + +sind | are +so | so + +solche | such +solchem +solchen +solcher +solches + +soll | shall +sollte | should +sondern | but +sonst | else +über | over +um | about, around +und | and + +uns | us +unse +unsem +unsen +unser +unses + +unter | under +viel | much +vom | von + dem +von | from +vor | before +während | while +war | was +waren | were +warst | wast +was | what +weg | away, off +weil | because +weiter | further + +welche | which +welchem +welchen +welcher +welches + +wenn | when +werde | will +werden | will +wie | how +wieder | again +will | want +wir | we +wird | will +wirst | willst +wo | where +wollen | want +wollte | wanted +würde | would +würden | would +zu | to +zum | zu + dem +zur | zu + der +zwar | indeed +zwischen | between + diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_el.txt b/resources/cache/empty/similarity/conf/lang/stopwords_el.txt index a5abfbec..232681f5 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_el.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_el.txt @@ -1,78 +1,78 @@ -# Lucene Greek Stopwords list -# Note: by default this file is used after GreekLowerCaseFilter, -# so when modifying this file use 'σ' instead of 'ς' -ο -η -το -οι -τα -του -τησ -των -τον -την -και -κι -κ -ειμαι -εισαι -ειναι -ειμαστε -ειστε -στο -στον -στη -στην -μα -αλλα -απο -για -προσ -με -σε -ωσ -παρα -αντι -κατα -μετα -θα -να -δε -δεν -μη -μην -επι -ενω -εαν -αν -τοτε -που -πωσ -ποιοσ -ποια -ποιο -ποιοι -ποιεσ -ποιων -ποιουσ -αυτοσ -αυτη -αυτο -αυτοι -αυτων -αυτουσ -αυτεσ -αυτα -εκεινοσ -εκεινη -εκεινο -εκεινοι -εκεινεσ -εκεινα -εκεινων -εκεινουσ -οπωσ -ομωσ -ισωσ -οσο -οτι +# Lucene Greek Stopwords list +# Note: by default this file is used after GreekLowerCaseFilter, +# so when modifying this file use 'σ' instead of 'ς' +ο +η +το +οι +τα +του +τησ +των +τον +την +και +κι +κ +ειμαι +εισαι +ειναι +ειμαστε +ειστε +στο +στον +στη +στην +μα +αλλα +απο +για +προσ +με +σε +ωσ +παρα +αντι +κατα +μετα +θα +να +δε +δεν +μη +μην +επι +ενω +εαν +αν +τοτε +που +πωσ +ποιοσ +ποια +ποιο +ποιοι +ποιεσ +ποιων +ποιουσ +αυτοσ +αυτη +αυτο +αυτοι +αυτων +αυτουσ +αυτεσ +αυτα +εκεινοσ +εκεινη +εκεινο +εκεινοι +εκεινεσ +εκεινα +εκεινων +εκεινουσ +οπωσ +ομωσ +ισωσ +οσο +οτι diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_en.txt b/resources/cache/empty/similarity/conf/lang/stopwords_en.txt index 224230c5..2c164c0b 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_en.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_en.txt @@ -1,54 +1,54 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# a couple of test stopwords to test that the words are really being -# configured from this file: -stopworda -stopwordb - -# Standard english stop words taken from Lucene's StopAnalyzer -a -an -and -are -as -at -be -but -by -for -if -in -into -is -it -no -not -of -on -or -such -that -the -their -then -there -these -they -this -to -was -will -with +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# a couple of test stopwords to test that the words are really being +# configured from this file: +stopworda +stopwordb + +# Standard english stop words taken from Lucene's StopAnalyzer +a +an +and +are +as +at +be +but +by +for +if +in +into +is +it +no +not +of +on +or +such +that +the +their +then +there +these +they +this +to +was +will +with diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_es.txt b/resources/cache/empty/similarity/conf/lang/stopwords_es.txt index 99afd937..487d78c8 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_es.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_es.txt @@ -1,356 +1,356 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/spanish/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Spanish stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - - | The following is a ranked list (commonest to rarest) of stopwords - | deriving from a large sample of text. - - | Extra words have been added at the end. - -de | from, of -la | the, her -que | who, that -el | the -en | in -y | and -a | to -los | the, them -del | de + el -se | himself, from him etc -las | the, them -por | for, by, etc -un | a -para | for -con | with -no | no -una | a -su | his, her -al | a + el - | es from SER -lo | him -como | how -más | more -pero | pero -sus | su plural -le | to him, her -ya | already -o | or - | fue from SER -este | this - | ha from HABER -sí | himself etc -porque | because -esta | this - | son from SER -entre | between - | está from ESTAR -cuando | when -muy | very -sin | without -sobre | on - | ser from SER - | tiene from TENER -también | also -me | me -hasta | until -hay | there is/are -donde | where - | han from HABER -quien | whom, that - | están from ESTAR - | estado from ESTAR -desde | from -todo | all -nos | us -durante | during - | estados from ESTAR -todos | all -uno | a -les | to them -ni | nor -contra | against -otros | other - | fueron from SER -ese | that -eso | that - | había from HABER -ante | before -ellos | they -e | and (variant of y) -esto | this -mí | me -antes | before -algunos | some -qué | what? -unos | a -yo | I -otro | other -otras | other -otra | other -él | he -tanto | so much, many -esa | that -estos | these -mucho | much, many -quienes | who -nada | nothing -muchos | many -cual | who - | sea from SER -poco | few -ella | she -estar | to be - | haber from HABER -estas | these - | estaba from ESTAR - | estamos from ESTAR -algunas | some -algo | something -nosotros | we - - | other forms - -mi | me -mis | mi plural -tú | thou -te | thee -ti | thee -tu | thy -tus | tu plural -ellas | they -nosotras | we -vosotros | you -vosotras | you -os | you -mío | mine -mía | -míos | -mías | -tuyo | thine -tuya | -tuyos | -tuyas | -suyo | his, hers, theirs -suya | -suyos | -suyas | -nuestro | ours -nuestra | -nuestros | -nuestras | -vuestro | yours -vuestra | -vuestros | -vuestras | -esos | those -esas | those - - | forms of estar, to be (not including the infinitive): -estoy -estás -está -estamos -estáis -están -esté -estés -estemos -estéis -estén -estaré -estarás -estará -estaremos -estaréis -estarán -estaría -estarías -estaríamos -estaríais -estarían -estaba -estabas -estábamos -estabais -estaban -estuve -estuviste -estuvo -estuvimos -estuvisteis -estuvieron -estuviera -estuvieras -estuviéramos -estuvierais -estuvieran -estuviese -estuvieses -estuviésemos -estuvieseis -estuviesen -estando -estado -estada -estados -estadas -estad - - | forms of haber, to have (not including the infinitive): -he -has -ha -hemos -habéis -han -haya -hayas -hayamos -hayáis -hayan -habré -habrás -habrá -habremos -habréis -habrán -habría -habrías -habríamos -habríais -habrían -había -habías -habíamos -habíais -habían -hube -hubiste -hubo -hubimos -hubisteis -hubieron -hubiera -hubieras -hubiéramos -hubierais -hubieran -hubiese -hubieses -hubiésemos -hubieseis -hubiesen -habiendo -habido -habida -habidos -habidas - - | forms of ser, to be (not including the infinitive): -soy -eres -es -somos -sois -son -sea -seas -seamos -seáis -sean -seré -serás -será -seremos -seréis -serán -sería -serías -seríamos -seríais -serían -era -eras -éramos -erais -eran -fui -fuiste -fue -fuimos -fuisteis -fueron -fuera -fueras -fuéramos -fuerais -fueran -fuese -fueses -fuésemos -fueseis -fuesen -siendo -sido - | sed also means 'thirst' - - | forms of tener, to have (not including the infinitive): -tengo -tienes -tiene -tenemos -tenéis -tienen -tenga -tengas -tengamos -tengáis -tengan -tendré -tendrás -tendrá -tendremos -tendréis -tendrán -tendría -tendrías -tendríamos -tendríais -tendrían -tenía -tenías -teníamos -teníais -tenían -tuve -tuviste -tuvo -tuvimos -tuvisteis -tuvieron -tuviera -tuvieras -tuviéramos -tuvierais -tuvieran -tuviese -tuvieses -tuviésemos -tuvieseis -tuviesen -teniendo -tenido -tenida -tenidos -tenidas -tened - + | From svn.tartarus.org/snowball/trunk/website/algorithms/spanish/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Spanish stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + + | The following is a ranked list (commonest to rarest) of stopwords + | deriving from a large sample of text. + + | Extra words have been added at the end. + +de | from, of +la | the, her +que | who, that +el | the +en | in +y | and +a | to +los | the, them +del | de + el +se | himself, from him etc +las | the, them +por | for, by, etc +un | a +para | for +con | with +no | no +una | a +su | his, her +al | a + el + | es from SER +lo | him +como | how +más | more +pero | pero +sus | su plural +le | to him, her +ya | already +o | or + | fue from SER +este | this + | ha from HABER +sí | himself etc +porque | because +esta | this + | son from SER +entre | between + | está from ESTAR +cuando | when +muy | very +sin | without +sobre | on + | ser from SER + | tiene from TENER +también | also +me | me +hasta | until +hay | there is/are +donde | where + | han from HABER +quien | whom, that + | están from ESTAR + | estado from ESTAR +desde | from +todo | all +nos | us +durante | during + | estados from ESTAR +todos | all +uno | a +les | to them +ni | nor +contra | against +otros | other + | fueron from SER +ese | that +eso | that + | había from HABER +ante | before +ellos | they +e | and (variant of y) +esto | this +mí | me +antes | before +algunos | some +qué | what? +unos | a +yo | I +otro | other +otras | other +otra | other +él | he +tanto | so much, many +esa | that +estos | these +mucho | much, many +quienes | who +nada | nothing +muchos | many +cual | who + | sea from SER +poco | few +ella | she +estar | to be + | haber from HABER +estas | these + | estaba from ESTAR + | estamos from ESTAR +algunas | some +algo | something +nosotros | we + + | other forms + +mi | me +mis | mi plural +tú | thou +te | thee +ti | thee +tu | thy +tus | tu plural +ellas | they +nosotras | we +vosotros | you +vosotras | you +os | you +mío | mine +mía | +míos | +mías | +tuyo | thine +tuya | +tuyos | +tuyas | +suyo | his, hers, theirs +suya | +suyos | +suyas | +nuestro | ours +nuestra | +nuestros | +nuestras | +vuestro | yours +vuestra | +vuestros | +vuestras | +esos | those +esas | those + + | forms of estar, to be (not including the infinitive): +estoy +estás +está +estamos +estáis +están +esté +estés +estemos +estéis +estén +estaré +estarás +estará +estaremos +estaréis +estarán +estaría +estarías +estaríamos +estaríais +estarían +estaba +estabas +estábamos +estabais +estaban +estuve +estuviste +estuvo +estuvimos +estuvisteis +estuvieron +estuviera +estuvieras +estuviéramos +estuvierais +estuvieran +estuviese +estuvieses +estuviésemos +estuvieseis +estuviesen +estando +estado +estada +estados +estadas +estad + + | forms of haber, to have (not including the infinitive): +he +has +ha +hemos +habéis +han +haya +hayas +hayamos +hayáis +hayan +habré +habrás +habrá +habremos +habréis +habrán +habría +habrías +habríamos +habríais +habrían +había +habías +habíamos +habíais +habían +hube +hubiste +hubo +hubimos +hubisteis +hubieron +hubiera +hubieras +hubiéramos +hubierais +hubieran +hubiese +hubieses +hubiésemos +hubieseis +hubiesen +habiendo +habido +habida +habidos +habidas + + | forms of ser, to be (not including the infinitive): +soy +eres +es +somos +sois +son +sea +seas +seamos +seáis +sean +seré +serás +será +seremos +seréis +serán +sería +serías +seríamos +seríais +serían +era +eras +éramos +erais +eran +fui +fuiste +fue +fuimos +fuisteis +fueron +fuera +fueras +fuéramos +fuerais +fueran +fuese +fueses +fuésemos +fueseis +fuesen +siendo +sido + | sed also means 'thirst' + + | forms of tener, to have (not including the infinitive): +tengo +tienes +tiene +tenemos +tenéis +tienen +tenga +tengas +tengamos +tengáis +tengan +tendré +tendrás +tendrá +tendremos +tendréis +tendrán +tendría +tendrías +tendríamos +tendríais +tendrían +tenía +tenías +teníamos +teníais +tenían +tuve +tuviste +tuvo +tuvimos +tuvisteis +tuvieron +tuviera +tuvieras +tuviéramos +tuvierais +tuvieran +tuviese +tuvieses +tuviésemos +tuvieseis +tuviesen +teniendo +tenido +tenida +tenidos +tenidas +tened + diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_eu.txt b/resources/cache/empty/similarity/conf/lang/stopwords_eu.txt index 7e4e4bb3..25f1db93 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_eu.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_eu.txt @@ -1,99 +1,99 @@ -# example set of basque stopwords -al -anitz -arabera -asko -baina -bat -batean -batek -bati -batzuei -batzuek -batzuetan -batzuk -bera -beraiek -berau -berauek -bere -berori -beroriek -beste -bezala -da -dago -dira -ditu -du -dute -edo -egin -ere -eta -eurak -ez -gainera -gu -gutxi -guzti -haiei -haiek -haietan -hainbeste -hala -han -handik -hango -hara -hari -hark -hartan -hau -hauei -hauek -hauetan -hemen -hemendik -hemengo -hi -hona -honek -honela -honetan -honi -hor -hori -horiei -horiek -horietan -horko -horra -horrek -horrela -horretan -horri -hortik -hura -izan -ni -noiz -nola -non -nondik -nongo -nor -nora -ze -zein -zen -zenbait -zenbat -zer -zergatik -ziren -zituen -zu -zuek -zuen -zuten +# example set of basque stopwords +al +anitz +arabera +asko +baina +bat +batean +batek +bati +batzuei +batzuek +batzuetan +batzuk +bera +beraiek +berau +berauek +bere +berori +beroriek +beste +bezala +da +dago +dira +ditu +du +dute +edo +egin +ere +eta +eurak +ez +gainera +gu +gutxi +guzti +haiei +haiek +haietan +hainbeste +hala +han +handik +hango +hara +hari +hark +hartan +hau +hauei +hauek +hauetan +hemen +hemendik +hemengo +hi +hona +honek +honela +honetan +honi +hor +hori +horiei +horiek +horietan +horko +horra +horrek +horrela +horretan +horri +hortik +hura +izan +ni +noiz +nola +non +nondik +nongo +nor +nora +ze +zein +zen +zenbait +zenbat +zer +zergatik +ziren +zituen +zu +zuek +zuen +zuten diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_fa.txt b/resources/cache/empty/similarity/conf/lang/stopwords_fa.txt index 76bb6354..723641c6 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_fa.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_fa.txt @@ -1,313 +1,313 @@ -# This file was created by Jacques Savoy and is distributed under the BSD license. -# See http://members.unine.ch/jacques.savoy/clef/index.html. -# Also see http://www.opensource.org/licenses/bsd-license.html -# Note: by default this file is used after normalization, so when adding entries -# to this file, use the arabic 'ي' instead of 'ی' -انان -نداشته -سراسر -خياه -ايشان -وي -تاكنون -بيشتري -دوم -پس -ناشي -وگو -يا -داشتند -سپس -هنگام -هرگز -پنج -نشان -امسال -ديگر -گروهي -شدند -چطور -ده -و -دو -نخستين -ولي -چرا -چه -وسط -ه -كدام -قابل -يك -رفت -هفت -همچنين -در -هزار -بله -بلي -شايد -اما -شناسي -گرفته -دهد -داشته -دانست -داشتن -خواهيم -ميليارد -وقتيكه -امد -خواهد -جز -اورده -شده -بلكه -خدمات -شدن -برخي -نبود -بسياري -جلوگيري -حق -كردند -نوعي -بعري -نكرده -نظير -نبايد -بوده -بودن -داد -اورد -هست -جايي -شود -دنبال -داده -بايد -سابق -هيچ -همان -انجا -كمتر -كجاست -گردد -كسي -تر -مردم -تان -دادن -بودند -سري -جدا -ندارند -مگر -يكديگر -دارد -دهند -بنابراين -هنگامي -سمت -جا -انچه -خود -دادند -زياد -دارند -اثر -بدون -بهترين -بيشتر -البته -به -براساس -بيرون -كرد -بعضي -گرفت -توي -اي -ميليون -او -جريان -تول -بر -مانند -برابر -باشيم -مدتي -گويند -اكنون -تا -تنها -جديد -چند -بي -نشده -كردن -كردم -گويد -كرده -كنيم -نمي -نزد -روي -قصد -فقط -بالاي -ديگران -اين -ديروز -توسط -سوم -ايم -دانند -سوي -استفاده -شما -كنار -داريم -ساخته -طور -امده -رفته -نخست -بيست -نزديك -طي -كنيد -از -انها -تمامي -داشت -يكي -طريق -اش -چيست -روب -نمايد -گفت -چندين -چيزي -تواند -ام -ايا -با -ان -ايد -ترين -اينكه -ديگري -راه -هايي -بروز -همچنان -پاعين -كس -حدود -مختلف -مقابل -چيز -گيرد -ندارد -ضد -همچون -سازي -شان -مورد -باره -مرسي -خويش -برخوردار -چون -خارج -شش -هنوز -تحت -ضمن -هستيم -گفته -فكر -بسيار -پيش -براي -روزهاي -انكه -نخواهد -بالا -كل -وقتي -كي -چنين -كه -گيري -نيست -است -كجا -كند -نيز -يابد -بندي -حتي -توانند -عقب -خواست -كنند -بين -تمام -همه -ما -باشند -مثل -شد -اري -باشد -اره -طبق -بعد -اگر -صورت -غير -جاي -بيش -ريزي -اند -زيرا -چگونه -بار -لطفا -مي -درباره -من -ديده -همين -گذاري -برداري -علت -گذاشته -هم -فوق -نه -ها -شوند -اباد -همواره -هر -اول -خواهند -چهار -نام -امروز -مان -هاي -قبل -كنم -سعي -تازه -را -هستند -زير -جلوي -عنوان -بود +# This file was created by Jacques Savoy and is distributed under the BSD license. +# See http://members.unine.ch/jacques.savoy/clef/index.html. +# Also see http://www.opensource.org/licenses/bsd-license.html +# Note: by default this file is used after normalization, so when adding entries +# to this file, use the arabic 'ي' instead of 'ی' +انان +نداشته +سراسر +خياه +ايشان +وي +تاكنون +بيشتري +دوم +پس +ناشي +وگو +يا +داشتند +سپس +هنگام +هرگز +پنج +نشان +امسال +ديگر +گروهي +شدند +چطور +ده +و +دو +نخستين +ولي +چرا +چه +وسط +ه +كدام +قابل +يك +رفت +هفت +همچنين +در +هزار +بله +بلي +شايد +اما +شناسي +گرفته +دهد +داشته +دانست +داشتن +خواهيم +ميليارد +وقتيكه +امد +خواهد +جز +اورده +شده +بلكه +خدمات +شدن +برخي +نبود +بسياري +جلوگيري +حق +كردند +نوعي +بعري +نكرده +نظير +نبايد +بوده +بودن +داد +اورد +هست +جايي +شود +دنبال +داده +بايد +سابق +هيچ +همان +انجا +كمتر +كجاست +گردد +كسي +تر +مردم +تان +دادن +بودند +سري +جدا +ندارند +مگر +يكديگر +دارد +دهند +بنابراين +هنگامي +سمت +جا +انچه +خود +دادند +زياد +دارند +اثر +بدون +بهترين +بيشتر +البته +به +براساس +بيرون +كرد +بعضي +گرفت +توي +اي +ميليون +او +جريان +تول +بر +مانند +برابر +باشيم +مدتي +گويند +اكنون +تا +تنها +جديد +چند +بي +نشده +كردن +كردم +گويد +كرده +كنيم +نمي +نزد +روي +قصد +فقط +بالاي +ديگران +اين +ديروز +توسط +سوم +ايم +دانند +سوي +استفاده +شما +كنار +داريم +ساخته +طور +امده +رفته +نخست +بيست +نزديك +طي +كنيد +از +انها +تمامي +داشت +يكي +طريق +اش +چيست +روب +نمايد +گفت +چندين +چيزي +تواند +ام +ايا +با +ان +ايد +ترين +اينكه +ديگري +راه +هايي +بروز +همچنان +پاعين +كس +حدود +مختلف +مقابل +چيز +گيرد +ندارد +ضد +همچون +سازي +شان +مورد +باره +مرسي +خويش +برخوردار +چون +خارج +شش +هنوز +تحت +ضمن +هستيم +گفته +فكر +بسيار +پيش +براي +روزهاي +انكه +نخواهد +بالا +كل +وقتي +كي +چنين +كه +گيري +نيست +است +كجا +كند +نيز +يابد +بندي +حتي +توانند +عقب +خواست +كنند +بين +تمام +همه +ما +باشند +مثل +شد +اري +باشد +اره +طبق +بعد +اگر +صورت +غير +جاي +بيش +ريزي +اند +زيرا +چگونه +بار +لطفا +مي +درباره +من +ديده +همين +گذاري +برداري +علت +گذاشته +هم +فوق +نه +ها +شوند +اباد +همواره +هر +اول +خواهند +چهار +نام +امروز +مان +هاي +قبل +كنم +سعي +تازه +را +هستند +زير +جلوي +عنوان +بود diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_fi.txt b/resources/cache/empty/similarity/conf/lang/stopwords_fi.txt index 4d70da3b..4372c9a0 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_fi.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_fi.txt @@ -1,97 +1,97 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/finnish/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - -| forms of BE - -olla -olen -olet -on -olemme -olette -ovat -ole | negative form - -oli -olisi -olisit -olisin -olisimme -olisitte -olisivat -olit -olin -olimme -olitte -olivat -ollut -olleet - -en | negation -et -ei -emme -ette -eivät - -|Nom Gen Acc Part Iness Elat Illat Adess Ablat Allat Ess Trans -minä minun minut minua minussa minusta minuun minulla minulta minulle | I -sinä sinun sinut sinua sinussa sinusta sinuun sinulla sinulta sinulle | you -hän hänen hänet häntä hänessä hänestä häneen hänellä häneltä hänelle | he she -me meidän meidät meitä meissä meistä meihin meillä meiltä meille | we -te teidän teidät teitä teissä teistä teihin teillä teiltä teille | you -he heidän heidät heitä heissä heistä heihin heillä heiltä heille | they - -tämä tämän tätä tässä tästä tähän tallä tältä tälle tänä täksi | this -tuo tuon tuotä tuossa tuosta tuohon tuolla tuolta tuolle tuona tuoksi | that -se sen sitä siinä siitä siihen sillä siltä sille sinä siksi | it -nämä näiden näitä näissä näistä näihin näillä näiltä näille näinä näiksi | these -nuo noiden noita noissa noista noihin noilla noilta noille noina noiksi | those -ne niiden niitä niissä niistä niihin niillä niiltä niille niinä niiksi | they - -kuka kenen kenet ketä kenessä kenestä keneen kenellä keneltä kenelle kenenä keneksi| who -ketkä keiden ketkä keitä keissä keistä keihin keillä keiltä keille keinä keiksi | (pl) -mikä minkä minkä mitä missä mistä mihin millä miltä mille minä miksi | which what -mitkä | (pl) - -joka jonka jota jossa josta johon jolla jolta jolle jona joksi | who which -jotka joiden joita joissa joista joihin joilla joilta joille joina joiksi | (pl) - -| conjunctions - -että | that -ja | and -jos | if -koska | because -kuin | than -mutta | but -niin | so -sekä | and -sillä | for -tai | or -vaan | but -vai | or -vaikka | although - - -| prepositions - -kanssa | with -mukaan | according to -noin | about -poikki | across -yli | over, across - -| other - -kun | when -niin | so -nyt | now -itse | self - + | From svn.tartarus.org/snowball/trunk/website/algorithms/finnish/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + +| forms of BE + +olla +olen +olet +on +olemme +olette +ovat +ole | negative form + +oli +olisi +olisit +olisin +olisimme +olisitte +olisivat +olit +olin +olimme +olitte +olivat +ollut +olleet + +en | negation +et +ei +emme +ette +eivät + +|Nom Gen Acc Part Iness Elat Illat Adess Ablat Allat Ess Trans +minä minun minut minua minussa minusta minuun minulla minulta minulle | I +sinä sinun sinut sinua sinussa sinusta sinuun sinulla sinulta sinulle | you +hän hänen hänet häntä hänessä hänestä häneen hänellä häneltä hänelle | he she +me meidän meidät meitä meissä meistä meihin meillä meiltä meille | we +te teidän teidät teitä teissä teistä teihin teillä teiltä teille | you +he heidän heidät heitä heissä heistä heihin heillä heiltä heille | they + +tämä tämän tätä tässä tästä tähän tallä tältä tälle tänä täksi | this +tuo tuon tuotä tuossa tuosta tuohon tuolla tuolta tuolle tuona tuoksi | that +se sen sitä siinä siitä siihen sillä siltä sille sinä siksi | it +nämä näiden näitä näissä näistä näihin näillä näiltä näille näinä näiksi | these +nuo noiden noita noissa noista noihin noilla noilta noille noina noiksi | those +ne niiden niitä niissä niistä niihin niillä niiltä niille niinä niiksi | they + +kuka kenen kenet ketä kenessä kenestä keneen kenellä keneltä kenelle kenenä keneksi| who +ketkä keiden ketkä keitä keissä keistä keihin keillä keiltä keille keinä keiksi | (pl) +mikä minkä minkä mitä missä mistä mihin millä miltä mille minä miksi | which what +mitkä | (pl) + +joka jonka jota jossa josta johon jolla jolta jolle jona joksi | who which +jotka joiden joita joissa joista joihin joilla joilta joille joina joiksi | (pl) + +| conjunctions + +että | that +ja | and +jos | if +koska | because +kuin | than +mutta | but +niin | so +sekä | and +sillä | for +tai | or +vaan | but +vai | or +vaikka | although + + +| prepositions + +kanssa | with +mukaan | according to +noin | about +poikki | across +yli | over, across + +| other + +kun | when +niin | so +nyt | now +itse | self + diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_fr.txt b/resources/cache/empty/similarity/conf/lang/stopwords_fr.txt index fec33952..749abae6 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_fr.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_fr.txt @@ -1,186 +1,186 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/french/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A French stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - -au | a + le -aux | a + les -avec | with -ce | this -ces | these -dans | with -de | of -des | de + les -du | de + le -elle | she -en | `of them' etc -et | and -eux | them -il | he -je | I -la | the -le | the -leur | their -lui | him -ma | my (fem) -mais | but -me | me -même | same; as in moi-même (myself) etc -mes | me (pl) -moi | me -mon | my (masc) -ne | not -nos | our (pl) -notre | our -nous | we -on | one -ou | where -par | by -pas | not -pour | for -qu | que before vowel -que | that -qui | who -sa | his, her (fem) -se | oneself -ses | his (pl) -son | his, her (masc) -sur | on -ta | thy (fem) -te | thee -tes | thy (pl) -toi | thee -ton | thy (masc) -tu | thou -un | a -une | a -vos | your (pl) -votre | your -vous | you - - | single letter forms - -c | c' -d | d' -j | j' -l | l' -à | to, at -m | m' -n | n' -s | s' -t | t' -y | there - - | forms of être (not including the infinitive): -été -étée -étées -étés -étant -suis -es -est -sommes -êtes -sont -serai -seras -sera -serons -serez -seront -serais -serait -serions -seriez -seraient -étais -était -étions -étiez -étaient -fus -fut -fûmes -fûtes -furent -sois -soit -soyons -soyez -soient -fusse -fusses -fût -fussions -fussiez -fussent - - | forms of avoir (not including the infinitive): -ayant -eu -eue -eues -eus -ai -as -avons -avez -ont -aurai -auras -aura -aurons -aurez -auront -aurais -aurait -aurions -auriez -auraient -avais -avait -avions -aviez -avaient -eut -eûmes -eûtes -eurent -aie -aies -ait -ayons -ayez -aient -eusse -eusses -eût -eussions -eussiez -eussent - - | Later additions (from Jean-Christophe Deschamps) -ceci | this -cela | that -celà | that -cet | this -cette | this -ici | here -ils | they -les | the (pl) -leurs | their (pl) -quel | which -quels | which -quelle | which -quelles | which -sans | without -soi | oneself - + | From svn.tartarus.org/snowball/trunk/website/algorithms/french/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A French stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + +au | a + le +aux | a + les +avec | with +ce | this +ces | these +dans | with +de | of +des | de + les +du | de + le +elle | she +en | `of them' etc +et | and +eux | them +il | he +je | I +la | the +le | the +leur | their +lui | him +ma | my (fem) +mais | but +me | me +même | same; as in moi-même (myself) etc +mes | me (pl) +moi | me +mon | my (masc) +ne | not +nos | our (pl) +notre | our +nous | we +on | one +ou | where +par | by +pas | not +pour | for +qu | que before vowel +que | that +qui | who +sa | his, her (fem) +se | oneself +ses | his (pl) +son | his, her (masc) +sur | on +ta | thy (fem) +te | thee +tes | thy (pl) +toi | thee +ton | thy (masc) +tu | thou +un | a +une | a +vos | your (pl) +votre | your +vous | you + + | single letter forms + +c | c' +d | d' +j | j' +l | l' +à | to, at +m | m' +n | n' +s | s' +t | t' +y | there + + | forms of être (not including the infinitive): +été +étée +étées +étés +étant +suis +es +est +sommes +êtes +sont +serai +seras +sera +serons +serez +seront +serais +serait +serions +seriez +seraient +étais +était +étions +étiez +étaient +fus +fut +fûmes +fûtes +furent +sois +soit +soyons +soyez +soient +fusse +fusses +fût +fussions +fussiez +fussent + + | forms of avoir (not including the infinitive): +ayant +eu +eue +eues +eus +ai +as +avons +avez +ont +aurai +auras +aura +aurons +aurez +auront +aurais +aurait +aurions +auriez +auraient +avais +avait +avions +aviez +avaient +eut +eûmes +eûtes +eurent +aie +aies +ait +ayons +ayez +aient +eusse +eusses +eût +eussions +eussiez +eussent + + | Later additions (from Jean-Christophe Deschamps) +ceci | this +cela | that +celà | that +cet | this +cette | this +ici | here +ils | they +les | the (pl) +leurs | their (pl) +quel | which +quels | which +quelle | which +quelles | which +sans | without +soi | oneself + diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_ga.txt b/resources/cache/empty/similarity/conf/lang/stopwords_ga.txt index f03e10a9..9ff88d74 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_ga.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_ga.txt @@ -1,110 +1,110 @@ - -a -ach -ag -agus -an -aon -ar -arna -as -b' -ba -beirt -bhúr -caoga -ceathair -ceathrar -chomh -chtó -chuig -chun -cois -céad -cúig -cúigear -d' -daichead -dar -de -deich -deichniúr -den -dhá -do -don -dtí -dá -dár -dó -faoi -faoin -faoina -faoinár -fara -fiche -gach -gan -go -gur -haon -hocht -i -iad -idir -in -ina -ins -inár -is -le -leis -lena -lenár -m' -mar -mo -mé -na -nach -naoi -naonúr -ná -ní -níor -nó -nócha -ocht -ochtar -os -roimh -sa -seacht -seachtar -seachtó -seasca -seisear -siad -sibh -sinn -sna -sé -sí -tar -thar -thú -triúr -trí -trína -trínár -tríocha -tú -um -ár -é -éis -í -ó -ón -óna -ónár + +a +ach +ag +agus +an +aon +ar +arna +as +b' +ba +beirt +bhúr +caoga +ceathair +ceathrar +chomh +chtó +chuig +chun +cois +céad +cúig +cúigear +d' +daichead +dar +de +deich +deichniúr +den +dhá +do +don +dtí +dá +dár +dó +faoi +faoin +faoina +faoinár +fara +fiche +gach +gan +go +gur +haon +hocht +i +iad +idir +in +ina +ins +inár +is +le +leis +lena +lenár +m' +mar +mo +mé +na +nach +naoi +naonúr +ná +ní +níor +nó +nócha +ocht +ochtar +os +roimh +sa +seacht +seachtar +seachtó +seasca +seisear +siad +sibh +sinn +sna +sé +sí +tar +thar +thú +triúr +trí +trína +trínár +tríocha +tú +um +ár +é +éis +í +ó +ón +óna +ónár diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_gl.txt b/resources/cache/empty/similarity/conf/lang/stopwords_gl.txt index 57803b31..d8760b12 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_gl.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_gl.txt @@ -1,161 +1,161 @@ -# galican stopwords -a -aínda -alí -aquel -aquela -aquelas -aqueles -aquilo -aquí -ao -aos -as -así -á -ben -cando -che -co -coa -comigo -con -connosco -contigo -convosco -coas -cos -cun -cuns -cunha -cunhas -da -dalgunha -dalgunhas -dalgún -dalgúns -das -de -del -dela -delas -deles -desde -deste -do -dos -dun -duns -dunha -dunhas -e -el -ela -elas -eles -en -era -eran -esa -esas -ese -eses -esta -estar -estaba -está -están -este -estes -estiven -estou -eu -é -facer -foi -foron -fun -había -hai -iso -isto -la -las -lle -lles -lo -los -mais -me -meu -meus -min -miña -miñas -moi -na -nas -neste -nin -no -non -nos -nosa -nosas -noso -nosos -nós -nun -nunha -nuns -nunhas -o -os -ou -ó -ós -para -pero -pode -pois -pola -polas -polo -polos -por -que -se -senón -ser -seu -seus -sexa -sido -sobre -súa -súas -tamén -tan -te -ten -teñen -teño -ter -teu -teus -ti -tido -tiña -tiven -túa -túas -un -unha -unhas -uns -vos -vosa -vosas -voso -vosos -vós +# galican stopwords +a +aínda +alí +aquel +aquela +aquelas +aqueles +aquilo +aquí +ao +aos +as +así +á +ben +cando +che +co +coa +comigo +con +connosco +contigo +convosco +coas +cos +cun +cuns +cunha +cunhas +da +dalgunha +dalgunhas +dalgún +dalgúns +das +de +del +dela +delas +deles +desde +deste +do +dos +dun +duns +dunha +dunhas +e +el +ela +elas +eles +en +era +eran +esa +esas +ese +eses +esta +estar +estaba +está +están +este +estes +estiven +estou +eu +é +facer +foi +foron +fun +había +hai +iso +isto +la +las +lle +lles +lo +los +mais +me +meu +meus +min +miña +miñas +moi +na +nas +neste +nin +no +non +nos +nosa +nosas +noso +nosos +nós +nun +nunha +nuns +nunhas +o +os +ou +ó +ós +para +pero +pode +pois +pola +polas +polo +polos +por +que +se +senón +ser +seu +seus +sexa +sido +sobre +súa +súas +tamén +tan +te +ten +teñen +teño +ter +teu +teus +ti +tido +tiña +tiven +túa +túas +un +unha +unhas +uns +vos +vosa +vosas +voso +vosos +vós diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_hi.txt b/resources/cache/empty/similarity/conf/lang/stopwords_hi.txt index 1f19fd10..86286bb0 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_hi.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_hi.txt @@ -1,235 +1,235 @@ -# Also see http://www.opensource.org/licenses/bsd-license.html -# See http://members.unine.ch/jacques.savoy/clef/index.html. -# This file was created by Jacques Savoy and is distributed under the BSD license. -# Note: by default this file also contains forms normalized by HindiNormalizer -# for spelling variation (see section below), such that it can be used whether or -# not you enable that feature. When adding additional entries to this list, -# please add the normalized form as well. -अंदर -अत -अपना -अपनी -अपने -अभी -आदि -आप -इत्यादि -इन -इनका -इन्हीं -इन्हें -इन्हों -इस -इसका -इसकी -इसके -इसमें -इसी -इसे -उन -उनका -उनकी -उनके -उनको -उन्हीं -उन्हें -उन्हों -उस -उसके -उसी -उसे -एक -एवं -एस -ऐसे -और -कई -कर -करता -करते -करना -करने -करें -कहते -कहा -का -काफ़ी -कि -कितना -किन्हें -किन्हों -किया -किर -किस -किसी -किसे -की -कुछ -कुल -के -को -कोई -कौन -कौनसा -गया -घर -जब -जहाँ -जा -जितना -जिन -जिन्हें -जिन्हों -जिस -जिसे -जीधर -जैसा -जैसे -जो -तक -तब -तरह -तिन -तिन्हें -तिन्हों -तिस -तिसे -तो -था -थी -थे -दबारा -दिया -दुसरा -दूसरे -दो -द्वारा -न -नहीं -ना -निहायत -नीचे -ने -पर -पर -पहले -पूरा -पे -फिर -बनी -बही -बहुत -बाद -बाला -बिलकुल -भी -भीतर -मगर -मानो -मे -में -यदि -यह -यहाँ -यही -या -यिह -ये -रखें -रहा -रहे -ऱ्वासा -लिए -लिये -लेकिन -व -वर्ग -वह -वह -वहाँ -वहीं -वाले -वुह -वे -वग़ैरह -संग -सकता -सकते -सबसे -सभी -साथ -साबुत -साभ -सारा -से -सो -ही -हुआ -हुई -हुए -है -हैं -हो -होता -होती -होते -होना -होने -# additional normalized forms of the above -अपनि -जेसे -होति -सभि -तिंहों -इंहों -दवारा -इसि -किंहें -थि -उंहों -ओर -जिंहें -वहिं -अभि -बनि -हि -उंहिं -उंहें -हें -वगेरह -एसे -रवासा -कोन -निचे -काफि -उसि -पुरा -भितर -हे -बहि -वहां -कोइ -यहां -जिंहों -तिंहें -किसि -कइ -यहि -इंहिं -जिधर -इंहें -अदि -इतयादि -हुइ -कोनसा -इसकि -दुसरे -जहां -अप -किंहों -उनकि -भि -वरग -हुअ -जेसा -नहिं +# Also see http://www.opensource.org/licenses/bsd-license.html +# See http://members.unine.ch/jacques.savoy/clef/index.html. +# This file was created by Jacques Savoy and is distributed under the BSD license. +# Note: by default this file also contains forms normalized by HindiNormalizer +# for spelling variation (see section below), such that it can be used whether or +# not you enable that feature. When adding additional entries to this list, +# please add the normalized form as well. +अंदर +अत +अपना +अपनी +अपने +अभी +आदि +आप +इत्यादि +इन +इनका +इन्हीं +इन्हें +इन्हों +इस +इसका +इसकी +इसके +इसमें +इसी +इसे +उन +उनका +उनकी +उनके +उनको +उन्हीं +उन्हें +उन्हों +उस +उसके +उसी +उसे +एक +एवं +एस +ऐसे +और +कई +कर +करता +करते +करना +करने +करें +कहते +कहा +का +काफ़ी +कि +कितना +किन्हें +किन्हों +किया +किर +किस +किसी +किसे +की +कुछ +कुल +के +को +कोई +कौन +कौनसा +गया +घर +जब +जहाँ +जा +जितना +जिन +जिन्हें +जिन्हों +जिस +जिसे +जीधर +जैसा +जैसे +जो +तक +तब +तरह +तिन +तिन्हें +तिन्हों +तिस +तिसे +तो +था +थी +थे +दबारा +दिया +दुसरा +दूसरे +दो +द्वारा +न +नहीं +ना +निहायत +नीचे +ने +पर +पर +पहले +पूरा +पे +फिर +बनी +बही +बहुत +बाद +बाला +बिलकुल +भी +भीतर +मगर +मानो +मे +में +यदि +यह +यहाँ +यही +या +यिह +ये +रखें +रहा +रहे +ऱ्वासा +लिए +लिये +लेकिन +व +वर्ग +वह +वह +वहाँ +वहीं +वाले +वुह +वे +वग़ैरह +संग +सकता +सकते +सबसे +सभी +साथ +साबुत +साभ +सारा +से +सो +ही +हुआ +हुई +हुए +है +हैं +हो +होता +होती +होते +होना +होने +# additional normalized forms of the above +अपनि +जेसे +होति +सभि +तिंहों +इंहों +दवारा +इसि +किंहें +थि +उंहों +ओर +जिंहें +वहिं +अभि +बनि +हि +उंहिं +उंहें +हें +वगेरह +एसे +रवासा +कोन +निचे +काफि +उसि +पुरा +भितर +हे +बहि +वहां +कोइ +यहां +जिंहों +तिंहें +किसि +कइ +यहि +इंहिं +जिधर +इंहें +अदि +इतयादि +हुइ +कोनसा +इसकि +दुसरे +जहां +अप +किंहों +उनकि +भि +वरग +हुअ +जेसा +नहिं diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_hu.txt b/resources/cache/empty/similarity/conf/lang/stopwords_hu.txt index f5bf755b..37526da8 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_hu.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_hu.txt @@ -1,211 +1,211 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/hungarian/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - -| Hungarian stop word list -| prepared by Anna Tordai - -a -ahogy -ahol -aki -akik -akkor -alatt -által -általában -amely -amelyek -amelyekben -amelyeket -amelyet -amelynek -ami -amit -amolyan -amíg -amikor -át -abban -ahhoz -annak -arra -arról -az -azok -azon -azt -azzal -azért -aztán -azután -azonban -bár -be -belül -benne -cikk -cikkek -cikkeket -csak -de -e -eddig -egész -egy -egyes -egyetlen -egyéb -egyik -egyre -ekkor -el -elég -ellen -elő -először -előtt -első -én -éppen -ebben -ehhez -emilyen -ennek -erre -ez -ezt -ezek -ezen -ezzel -ezért -és -fel -felé -hanem -hiszen -hogy -hogyan -igen -így -illetve -ill. -ill -ilyen -ilyenkor -ison -ismét -itt -jó -jól -jobban -kell -kellett -keresztül -keressünk -ki -kívül -között -közül -legalább -lehet -lehetett -legyen -lenne -lenni -lesz -lett -maga -magát -majd -majd -már -más -másik -meg -még -mellett -mert -mely -melyek -mi -mit -míg -miért -milyen -mikor -minden -mindent -mindenki -mindig -mint -mintha -mivel -most -nagy -nagyobb -nagyon -ne -néha -nekem -neki -nem -néhány -nélkül -nincs -olyan -ott -össze -ő -ők -őket -pedig -persze -rá -s -saját -sem -semmi -sok -sokat -sokkal -számára -szemben -szerint -szinte -talán -tehát -teljes -tovább -továbbá -több -úgy -ugyanis -új -újabb -újra -után -utána -utolsó -vagy -vagyis -valaki -valami -valamint -való -vagyok -van -vannak -volt -voltam -voltak -voltunk -vissza -vele -viszont -volna + | From svn.tartarus.org/snowball/trunk/website/algorithms/hungarian/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + +| Hungarian stop word list +| prepared by Anna Tordai + +a +ahogy +ahol +aki +akik +akkor +alatt +által +általában +amely +amelyek +amelyekben +amelyeket +amelyet +amelynek +ami +amit +amolyan +amíg +amikor +át +abban +ahhoz +annak +arra +arról +az +azok +azon +azt +azzal +azért +aztán +azután +azonban +bár +be +belül +benne +cikk +cikkek +cikkeket +csak +de +e +eddig +egész +egy +egyes +egyetlen +egyéb +egyik +egyre +ekkor +el +elég +ellen +elő +először +előtt +első +én +éppen +ebben +ehhez +emilyen +ennek +erre +ez +ezt +ezek +ezen +ezzel +ezért +és +fel +felé +hanem +hiszen +hogy +hogyan +igen +így +illetve +ill. +ill +ilyen +ilyenkor +ison +ismét +itt +jó +jól +jobban +kell +kellett +keresztül +keressünk +ki +kívül +között +közül +legalább +lehet +lehetett +legyen +lenne +lenni +lesz +lett +maga +magát +majd +majd +már +más +másik +meg +még +mellett +mert +mely +melyek +mi +mit +míg +miért +milyen +mikor +minden +mindent +mindenki +mindig +mint +mintha +mivel +most +nagy +nagyobb +nagyon +ne +néha +nekem +neki +nem +néhány +nélkül +nincs +olyan +ott +össze +ő +ők +őket +pedig +persze +rá +s +saját +sem +semmi +sok +sokat +sokkal +számára +szemben +szerint +szinte +talán +tehát +teljes +tovább +továbbá +több +úgy +ugyanis +új +újabb +újra +után +utána +utolsó +vagy +vagyis +valaki +valami +valamint +való +vagyok +van +vannak +volt +voltam +voltak +voltunk +vissza +vele +viszont +volna diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_hy.txt b/resources/cache/empty/similarity/conf/lang/stopwords_hy.txt index 968a8f4a..60c1c50f 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_hy.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_hy.txt @@ -1,46 +1,46 @@ -# example set of Armenian stopwords. -այդ -այլ -այն -այս -դու -դուք -եմ -են -ենք -ես -եք -է -էի -էին -էինք -էիր -էիք -էր -ըստ -թ -ի -ին -իսկ -իր -կամ -համար -հետ -հետո -մենք -մեջ -մի -ն -նա -նաև -նրա -նրանք -որ -որը -որոնք -որպես -ու -ում -պիտի -վրա -և +# example set of Armenian stopwords. +այդ +այլ +այն +այս +դու +դուք +եմ +են +ենք +ես +եք +է +էի +էին +էինք +էիր +էիք +էր +ըստ +թ +ի +ին +իսկ +իր +կամ +համար +հետ +հետո +մենք +մեջ +մի +ն +նա +նաև +նրա +նրանք +որ +որը +որոնք +որպես +ու +ում +պիտի +վրա +և diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_id.txt b/resources/cache/empty/similarity/conf/lang/stopwords_id.txt index 80df39a3..4617f83a 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_id.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_id.txt @@ -1,359 +1,359 @@ -# from appendix D of: A Study of Stemming Effects on Information -# Retrieval in Bahasa Indonesia -ada -adanya -adalah -adapun -agak -agaknya -agar -akan -akankah -akhirnya -aku -akulah -amat -amatlah -anda -andalah -antar -diantaranya -antara -antaranya -diantara -apa -apaan -mengapa -apabila -apakah -apalagi -apatah -atau -ataukah -ataupun -bagai -bagaikan -sebagai -sebagainya -bagaimana -bagaimanapun -sebagaimana -bagaimanakah -bagi -bahkan -bahwa -bahwasanya -sebaliknya -banyak -sebanyak -beberapa -seberapa -begini -beginian -beginikah -beginilah -sebegini -begitu -begitukah -begitulah -begitupun -sebegitu -belum -belumlah -sebelum -sebelumnya -sebenarnya -berapa -berapakah -berapalah -berapapun -betulkah -sebetulnya -biasa -biasanya -bila -bilakah -bisa -bisakah -sebisanya -boleh -bolehkah -bolehlah -buat -bukan -bukankah -bukanlah -bukannya -cuma -percuma -dahulu -dalam -dan -dapat -dari -daripada -dekat -demi -demikian -demikianlah -sedemikian -dengan -depan -di -dia -dialah -dini -diri -dirinya -terdiri -dong -dulu -enggak -enggaknya -entah -entahlah -terhadap -terhadapnya -hal -hampir -hanya -hanyalah -harus -haruslah -harusnya -seharusnya -hendak -hendaklah -hendaknya -hingga -sehingga -ia -ialah -ibarat -ingin -inginkah -inginkan -ini -inikah -inilah -itu -itukah -itulah -jangan -jangankan -janganlah -jika -jikalau -juga -justru -kala -kalau -kalaulah -kalaupun -kalian -kami -kamilah -kamu -kamulah -kan -kapan -kapankah -kapanpun -dikarenakan -karena -karenanya -ke -kecil -kemudian -kenapa -kepada -kepadanya -ketika -seketika -khususnya -kini -kinilah -kiranya -sekiranya -kita -kitalah -kok -lagi -lagian -selagi -lah -lain -lainnya -melainkan -selaku -lalu -melalui -terlalu -lama -lamanya -selama -selama -selamanya -lebih -terlebih -bermacam -macam -semacam -maka -makanya -makin -malah -malahan -mampu -mampukah -mana -manakala -manalagi -masih -masihkah -semasih -masing -mau -maupun -semaunya -memang -mereka -merekalah -meski -meskipun -semula -mungkin -mungkinkah -nah -namun -nanti -nantinya -nyaris -oleh -olehnya -seorang -seseorang -pada -padanya -padahal -paling -sepanjang -pantas -sepantasnya -sepantasnyalah -para -pasti -pastilah -per -pernah -pula -pun -merupakan -rupanya -serupa -saat -saatnya -sesaat -saja -sajalah -saling -bersama -sama -sesama -sambil -sampai -sana -sangat -sangatlah -saya -sayalah -se -sebab -sebabnya -sebuah -tersebut -tersebutlah -sedang -sedangkan -sedikit -sedikitnya -segala -segalanya -segera -sesegera -sejak -sejenak -sekali -sekalian -sekalipun -sesekali -sekaligus -sekarang -sekarang -sekitar -sekitarnya -sela -selain -selalu -seluruh -seluruhnya -semakin -sementara -sempat -semua -semuanya -sendiri -sendirinya -seolah -seperti -sepertinya -sering -seringnya -serta -siapa -siapakah -siapapun -disini -disinilah -sini -sinilah -sesuatu -sesuatunya -suatu -sesudah -sesudahnya -sudah -sudahkah -sudahlah -supaya -tadi -tadinya -tak -tanpa -setelah -telah -tentang -tentu -tentulah -tentunya -tertentu -seterusnya -tapi -tetapi -setiap -tiap -setidaknya -tidak -tidakkah -tidaklah -toh -waduh -wah -wahai -sewaktu -walau -walaupun -wong -yaitu -yakni -yang +# from appendix D of: A Study of Stemming Effects on Information +# Retrieval in Bahasa Indonesia +ada +adanya +adalah +adapun +agak +agaknya +agar +akan +akankah +akhirnya +aku +akulah +amat +amatlah +anda +andalah +antar +diantaranya +antara +antaranya +diantara +apa +apaan +mengapa +apabila +apakah +apalagi +apatah +atau +ataukah +ataupun +bagai +bagaikan +sebagai +sebagainya +bagaimana +bagaimanapun +sebagaimana +bagaimanakah +bagi +bahkan +bahwa +bahwasanya +sebaliknya +banyak +sebanyak +beberapa +seberapa +begini +beginian +beginikah +beginilah +sebegini +begitu +begitukah +begitulah +begitupun +sebegitu +belum +belumlah +sebelum +sebelumnya +sebenarnya +berapa +berapakah +berapalah +berapapun +betulkah +sebetulnya +biasa +biasanya +bila +bilakah +bisa +bisakah +sebisanya +boleh +bolehkah +bolehlah +buat +bukan +bukankah +bukanlah +bukannya +cuma +percuma +dahulu +dalam +dan +dapat +dari +daripada +dekat +demi +demikian +demikianlah +sedemikian +dengan +depan +di +dia +dialah +dini +diri +dirinya +terdiri +dong +dulu +enggak +enggaknya +entah +entahlah +terhadap +terhadapnya +hal +hampir +hanya +hanyalah +harus +haruslah +harusnya +seharusnya +hendak +hendaklah +hendaknya +hingga +sehingga +ia +ialah +ibarat +ingin +inginkah +inginkan +ini +inikah +inilah +itu +itukah +itulah +jangan +jangankan +janganlah +jika +jikalau +juga +justru +kala +kalau +kalaulah +kalaupun +kalian +kami +kamilah +kamu +kamulah +kan +kapan +kapankah +kapanpun +dikarenakan +karena +karenanya +ke +kecil +kemudian +kenapa +kepada +kepadanya +ketika +seketika +khususnya +kini +kinilah +kiranya +sekiranya +kita +kitalah +kok +lagi +lagian +selagi +lah +lain +lainnya +melainkan +selaku +lalu +melalui +terlalu +lama +lamanya +selama +selama +selamanya +lebih +terlebih +bermacam +macam +semacam +maka +makanya +makin +malah +malahan +mampu +mampukah +mana +manakala +manalagi +masih +masihkah +semasih +masing +mau +maupun +semaunya +memang +mereka +merekalah +meski +meskipun +semula +mungkin +mungkinkah +nah +namun +nanti +nantinya +nyaris +oleh +olehnya +seorang +seseorang +pada +padanya +padahal +paling +sepanjang +pantas +sepantasnya +sepantasnyalah +para +pasti +pastilah +per +pernah +pula +pun +merupakan +rupanya +serupa +saat +saatnya +sesaat +saja +sajalah +saling +bersama +sama +sesama +sambil +sampai +sana +sangat +sangatlah +saya +sayalah +se +sebab +sebabnya +sebuah +tersebut +tersebutlah +sedang +sedangkan +sedikit +sedikitnya +segala +segalanya +segera +sesegera +sejak +sejenak +sekali +sekalian +sekalipun +sesekali +sekaligus +sekarang +sekarang +sekitar +sekitarnya +sela +selain +selalu +seluruh +seluruhnya +semakin +sementara +sempat +semua +semuanya +sendiri +sendirinya +seolah +seperti +sepertinya +sering +seringnya +serta +siapa +siapakah +siapapun +disini +disinilah +sini +sinilah +sesuatu +sesuatunya +suatu +sesudah +sesudahnya +sudah +sudahkah +sudahlah +supaya +tadi +tadinya +tak +tanpa +setelah +telah +tentang +tentu +tentulah +tentunya +tertentu +seterusnya +tapi +tetapi +setiap +tiap +setidaknya +tidak +tidakkah +tidaklah +toh +waduh +wah +wahai +sewaktu +walau +walaupun +wong +yaitu +yakni +yang diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_it.txt b/resources/cache/empty/similarity/conf/lang/stopwords_it.txt index 3b20c0ab..1219cc77 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_it.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_it.txt @@ -1,303 +1,303 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/italian/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | An Italian stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - -ad | a (to) before vowel -al | a + il -allo | a + lo -ai | a + i -agli | a + gli -all | a + l' -agl | a + gl' -alla | a + la -alle | a + le -con | with -col | con + il -coi | con + i (forms collo, cogli etc are now very rare) -da | from -dal | da + il -dallo | da + lo -dai | da + i -dagli | da + gli -dall | da + l' -dagl | da + gll' -dalla | da + la -dalle | da + le -di | of -del | di + il -dello | di + lo -dei | di + i -degli | di + gli -dell | di + l' -degl | di + gl' -della | di + la -delle | di + le -in | in -nel | in + el -nello | in + lo -nei | in + i -negli | in + gli -nell | in + l' -negl | in + gl' -nella | in + la -nelle | in + le -su | on -sul | su + il -sullo | su + lo -sui | su + i -sugli | su + gli -sull | su + l' -sugl | su + gl' -sulla | su + la -sulle | su + le -per | through, by -tra | among -contro | against -io | I -tu | thou -lui | he -lei | she -noi | we -voi | you -loro | they -mio | my -mia | -miei | -mie | -tuo | -tua | -tuoi | thy -tue | -suo | -sua | -suoi | his, her -sue | -nostro | our -nostra | -nostri | -nostre | -vostro | your -vostra | -vostri | -vostre | -mi | me -ti | thee -ci | us, there -vi | you, there -lo | him, the -la | her, the -li | them -le | them, the -gli | to him, the -ne | from there etc -il | the -un | a -uno | a -una | a -ma | but -ed | and -se | if -perché | why, because -anche | also -come | how -dov | where (as dov') -dove | where -che | who, that -chi | who -cui | whom -non | not -più | more -quale | who, that -quanto | how much -quanti | -quanta | -quante | -quello | that -quelli | -quella | -quelle | -questo | this -questi | -questa | -queste | -si | yes -tutto | all -tutti | all - - | single letter forms: - -a | at -c | as c' for ce or ci -e | and -i | the -l | as l' -o | or - - | forms of avere, to have (not including the infinitive): - -ho -hai -ha -abbiamo -avete -hanno -abbia -abbiate -abbiano -avrò -avrai -avrà -avremo -avrete -avranno -avrei -avresti -avrebbe -avremmo -avreste -avrebbero -avevo -avevi -aveva -avevamo -avevate -avevano -ebbi -avesti -ebbe -avemmo -aveste -ebbero -avessi -avesse -avessimo -avessero -avendo -avuto -avuta -avuti -avute - - | forms of essere, to be (not including the infinitive): -sono -sei -è -siamo -siete -sia -siate -siano -sarò -sarai -sarà -saremo -sarete -saranno -sarei -saresti -sarebbe -saremmo -sareste -sarebbero -ero -eri -era -eravamo -eravate -erano -fui -fosti -fu -fummo -foste -furono -fossi -fosse -fossimo -fossero -essendo - - | forms of fare, to do (not including the infinitive, fa, fat-): -faccio -fai -facciamo -fanno -faccia -facciate -facciano -farò -farai -farà -faremo -farete -faranno -farei -faresti -farebbe -faremmo -fareste -farebbero -facevo -facevi -faceva -facevamo -facevate -facevano -feci -facesti -fece -facemmo -faceste -fecero -facessi -facesse -facessimo -facessero -facendo - - | forms of stare, to be (not including the infinitive): -sto -stai -sta -stiamo -stanno -stia -stiate -stiano -starò -starai -starà -staremo -starete -staranno -starei -staresti -starebbe -staremmo -stareste -starebbero -stavo -stavi -stava -stavamo -stavate -stavano -stetti -stesti -stette -stemmo -steste -stettero -stessi -stesse -stessimo -stessero -stando + | From svn.tartarus.org/snowball/trunk/website/algorithms/italian/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | An Italian stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + +ad | a (to) before vowel +al | a + il +allo | a + lo +ai | a + i +agli | a + gli +all | a + l' +agl | a + gl' +alla | a + la +alle | a + le +con | with +col | con + il +coi | con + i (forms collo, cogli etc are now very rare) +da | from +dal | da + il +dallo | da + lo +dai | da + i +dagli | da + gli +dall | da + l' +dagl | da + gll' +dalla | da + la +dalle | da + le +di | of +del | di + il +dello | di + lo +dei | di + i +degli | di + gli +dell | di + l' +degl | di + gl' +della | di + la +delle | di + le +in | in +nel | in + el +nello | in + lo +nei | in + i +negli | in + gli +nell | in + l' +negl | in + gl' +nella | in + la +nelle | in + le +su | on +sul | su + il +sullo | su + lo +sui | su + i +sugli | su + gli +sull | su + l' +sugl | su + gl' +sulla | su + la +sulle | su + le +per | through, by +tra | among +contro | against +io | I +tu | thou +lui | he +lei | she +noi | we +voi | you +loro | they +mio | my +mia | +miei | +mie | +tuo | +tua | +tuoi | thy +tue | +suo | +sua | +suoi | his, her +sue | +nostro | our +nostra | +nostri | +nostre | +vostro | your +vostra | +vostri | +vostre | +mi | me +ti | thee +ci | us, there +vi | you, there +lo | him, the +la | her, the +li | them +le | them, the +gli | to him, the +ne | from there etc +il | the +un | a +uno | a +una | a +ma | but +ed | and +se | if +perché | why, because +anche | also +come | how +dov | where (as dov') +dove | where +che | who, that +chi | who +cui | whom +non | not +più | more +quale | who, that +quanto | how much +quanti | +quanta | +quante | +quello | that +quelli | +quella | +quelle | +questo | this +questi | +questa | +queste | +si | yes +tutto | all +tutti | all + + | single letter forms: + +a | at +c | as c' for ce or ci +e | and +i | the +l | as l' +o | or + + | forms of avere, to have (not including the infinitive): + +ho +hai +ha +abbiamo +avete +hanno +abbia +abbiate +abbiano +avrò +avrai +avrà +avremo +avrete +avranno +avrei +avresti +avrebbe +avremmo +avreste +avrebbero +avevo +avevi +aveva +avevamo +avevate +avevano +ebbi +avesti +ebbe +avemmo +aveste +ebbero +avessi +avesse +avessimo +avessero +avendo +avuto +avuta +avuti +avute + + | forms of essere, to be (not including the infinitive): +sono +sei +è +siamo +siete +sia +siate +siano +sarò +sarai +sarà +saremo +sarete +saranno +sarei +saresti +sarebbe +saremmo +sareste +sarebbero +ero +eri +era +eravamo +eravate +erano +fui +fosti +fu +fummo +foste +furono +fossi +fosse +fossimo +fossero +essendo + + | forms of fare, to do (not including the infinitive, fa, fat-): +faccio +fai +facciamo +fanno +faccia +facciate +facciano +farò +farai +farà +faremo +farete +faranno +farei +faresti +farebbe +faremmo +fareste +farebbero +facevo +facevi +faceva +facevamo +facevate +facevano +feci +facesti +fece +facemmo +faceste +fecero +facessi +facesse +facessimo +facessero +facendo + + | forms of stare, to be (not including the infinitive): +sto +stai +sta +stiamo +stanno +stia +stiate +stiano +starò +starai +starà +staremo +starete +staranno +starei +staresti +starebbe +staremmo +stareste +starebbero +stavo +stavi +stava +stavamo +stavate +stavano +stetti +stesti +stette +stemmo +steste +stettero +stessi +stesse +stessimo +stessero +stando diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_ja.txt b/resources/cache/empty/similarity/conf/lang/stopwords_ja.txt index bc3077e5..d4321be6 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_ja.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_ja.txt @@ -1,127 +1,127 @@ -# -# This file defines a stopword set for Japanese. -# -# This set is made up of hand-picked frequent terms from segmented Japanese Wikipedia. -# Punctuation characters and frequent kanji have mostly been left out. See LUCENE-3745 -# for frequency lists, etc. that can be useful for making your own set (if desired) -# -# Note that there is an overlap between these stopwords and the terms stopped when used -# in combination with the JapanesePartOfSpeechStopFilter. When editing this file, note -# that comments are not allowed on the same line as stopwords. -# -# Also note that stopping is done in a case-insensitive manner. Change your StopFilter -# configuration if you need case-sensitive stopping. Lastly, note that stopping is done -# using the same character width as the entries in this file. Since this StopFilter is -# normally done after a CJKWidthFilter in your chain, you would usually want your romaji -# entries to be in half-width and your kana entries to be in full-width. -# -の -に -は -を -た -が -で -て -と -し -れ -さ -ある -いる -も -する -から -な -こと -として -い -や -れる -など -なっ -ない -この -ため -その -あっ -よう -また -もの -という -あり -まで -られ -なる -へ -か -だ -これ -によって -により -おり -より -による -ず -なり -られる -において -ば -なかっ -なく -しかし -について -せ -だっ -その後 -できる -それ -う -ので -なお -のみ -でき -き -つ -における -および -いう -さらに -でも -ら -たり -その他 -に関する -たち -ます -ん -なら -に対して -特に -せる -及び -これら -とき -では -にて -ほか -ながら -うち -そして -とともに -ただし -かつて -それぞれ -または -お -ほど -ものの -に対する -ほとんど -と共に -といった -です -とも -ところ -ここ -##### End of file +# +# This file defines a stopword set for Japanese. +# +# This set is made up of hand-picked frequent terms from segmented Japanese Wikipedia. +# Punctuation characters and frequent kanji have mostly been left out. See LUCENE-3745 +# for frequency lists, etc. that can be useful for making your own set (if desired) +# +# Note that there is an overlap between these stopwords and the terms stopped when used +# in combination with the JapanesePartOfSpeechStopFilter. When editing this file, note +# that comments are not allowed on the same line as stopwords. +# +# Also note that stopping is done in a case-insensitive manner. Change your StopFilter +# configuration if you need case-sensitive stopping. Lastly, note that stopping is done +# using the same character width as the entries in this file. Since this StopFilter is +# normally done after a CJKWidthFilter in your chain, you would usually want your romaji +# entries to be in half-width and your kana entries to be in full-width. +# +の +に +は +を +た +が +で +て +と +し +れ +さ +ある +いる +も +する +から +な +こと +として +い +や +れる +など +なっ +ない +この +ため +その +あっ +よう +また +もの +という +あり +まで +られ +なる +へ +か +だ +これ +によって +により +おり +より +による +ず +なり +られる +において +ば +なかっ +なく +しかし +について +せ +だっ +その後 +できる +それ +う +ので +なお +のみ +でき +き +つ +における +および +いう +さらに +でも +ら +たり +その他 +に関する +たち +ます +ん +なら +に対して +特に +せる +及び +これら +とき +では +にて +ほか +ながら +うち +そして +とともに +ただし +かつて +それぞれ +または +お +ほど +ものの +に対する +ほとんど +と共に +といった +です +とも +ところ +ここ +##### End of file diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_lv.txt b/resources/cache/empty/similarity/conf/lang/stopwords_lv.txt index a4710974..e21a23c0 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_lv.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_lv.txt @@ -1,172 +1,172 @@ -# Set of Latvian stopwords from A Stemming Algorithm for Latvian, Karlis Kreslins -# the original list of over 800 forms was refined: -# pronouns, adverbs, interjections were removed -# -# prepositions -aiz -ap -ar -apakš -ārpus -augšpus -bez -caur -dēļ -gar -iekš -iz -kopš -labad -lejpus -līdz -no -otrpus -pa -par -pār -pēc -pie -pirms -pret -priekš -starp -šaipus -uz -viņpus -virs -virspus -zem -apakšpus -# Conjunctions -un -bet -jo -ja -ka -lai -tomēr -tikko -turpretī -arī -kaut -gan -tādēļ -tā -ne -tikvien -vien -kā -ir -te -vai -kamēr -# Particles -ar -diezin -droši -diemžēl -nebūt -ik -it -taču -nu -pat -tiklab -iekšpus -nedz -tik -nevis -turpretim -jeb -iekam -iekām -iekāms -kolīdz -līdzko -tiklīdz -jebšu -tālab -tāpēc -nekā -itin -jā -jau -jel -nē -nezin -tad -tikai -vis -tak -iekams -vien -# modal verbs -būt -biju -biji -bija -bijām -bijāt -esmu -esi -esam -esat -būšu -būsi -būs -būsim -būsiet -tikt -tiku -tiki -tika -tikām -tikāt -tieku -tiec -tiek -tiekam -tiekat -tikšu -tiks -tiksim -tiksiet -tapt -tapi -tapāt -topat -tapšu -tapsi -taps -tapsim -tapsiet -kļūt -kļuvu -kļuvi -kļuva -kļuvām -kļuvāt -kļūstu -kļūsti -kļūst -kļūstam -kļūstat -kļūšu -kļūsi -kļūs -kļūsim -kļūsiet -# verbs -varēt -varēju -varējām -varēšu -varēsim -var -varēji -varējāt -varēsi -varēsiet -varat -varēja -varēs +# Set of Latvian stopwords from A Stemming Algorithm for Latvian, Karlis Kreslins +# the original list of over 800 forms was refined: +# pronouns, adverbs, interjections were removed +# +# prepositions +aiz +ap +ar +apakš +ārpus +augšpus +bez +caur +dēļ +gar +iekš +iz +kopš +labad +lejpus +līdz +no +otrpus +pa +par +pār +pēc +pie +pirms +pret +priekš +starp +šaipus +uz +viņpus +virs +virspus +zem +apakšpus +# Conjunctions +un +bet +jo +ja +ka +lai +tomēr +tikko +turpretī +arī +kaut +gan +tādēļ +tā +ne +tikvien +vien +kā +ir +te +vai +kamēr +# Particles +ar +diezin +droši +diemžēl +nebūt +ik +it +taču +nu +pat +tiklab +iekšpus +nedz +tik +nevis +turpretim +jeb +iekam +iekām +iekāms +kolīdz +līdzko +tiklīdz +jebšu +tālab +tāpēc +nekā +itin +jā +jau +jel +nē +nezin +tad +tikai +vis +tak +iekams +vien +# modal verbs +būt +biju +biji +bija +bijām +bijāt +esmu +esi +esam +esat +būšu +būsi +būs +būsim +būsiet +tikt +tiku +tiki +tika +tikām +tikāt +tieku +tiec +tiek +tiekam +tiekat +tikšu +tiks +tiksim +tiksiet +tapt +tapi +tapāt +topat +tapšu +tapsi +taps +tapsim +tapsiet +kļūt +kļuvu +kļuvi +kļuva +kļuvām +kļuvāt +kļūstu +kļūsti +kļūst +kļūstam +kļūstat +kļūšu +kļūsi +kļūs +kļūsim +kļūsiet +# verbs +varēt +varēju +varējām +varēšu +varēsim +var +varēji +varējāt +varēsi +varēsiet +varat +varēja +varēs diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_nl.txt b/resources/cache/empty/similarity/conf/lang/stopwords_nl.txt index 06ca75ba..47a2aeac 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_nl.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_nl.txt @@ -1,119 +1,119 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/dutch/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Dutch stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - | This is a ranked list (commonest to rarest) of stopwords derived from - | a large sample of Dutch text. - - | Dutch stop words frequently exhibit homonym clashes. These are indicated - | clearly below. - -de | the -en | and -van | of, from -ik | I, the ego -te | (1) chez, at etc, (2) to, (3) too -dat | that, which -die | that, those, who, which -in | in, inside -een | a, an, one -hij | he -het | the, it -niet | not, nothing, naught -zijn | (1) to be, being, (2) his, one's, its -is | is -was | (1) was, past tense of all persons sing. of 'zijn' (to be) (2) wax, (3) the washing, (4) rise of river -op | on, upon, at, in, up, used up -aan | on, upon, to (as dative) -met | with, by -als | like, such as, when -voor | (1) before, in front of, (2) furrow -had | had, past tense all persons sing. of 'hebben' (have) -er | there -maar | but, only -om | round, about, for etc -hem | him -dan | then -zou | should/would, past tense all persons sing. of 'zullen' -of | or, whether, if -wat | what, something, anything -mijn | possessive and noun 'mine' -men | people, 'one' -dit | this -zo | so, thus, in this way -door | through by -over | over, across -ze | she, her, they, them -zich | oneself -bij | (1) a bee, (2) by, near, at -ook | also, too -tot | till, until -je | you -mij | me -uit | out of, from -der | Old Dutch form of 'van der' still found in surnames -daar | (1) there, (2) because -haar | (1) her, their, them, (2) hair -naar | (1) unpleasant, unwell etc, (2) towards, (3) as -heb | present first person sing. of 'to have' -hoe | how, why -heeft | present third person sing. of 'to have' -hebben | 'to have' and various parts thereof -deze | this -u | you -want | (1) for, (2) mitten, (3) rigging -nog | yet, still -zal | 'shall', first and third person sing. of verb 'zullen' (will) -me | me -zij | she, they -nu | now -ge | 'thou', still used in Belgium and south Netherlands -geen | none -omdat | because -iets | something, somewhat -worden | to become, grow, get -toch | yet, still -al | all, every, each -waren | (1) 'were' (2) to wander, (3) wares, (3) -veel | much, many -meer | (1) more, (2) lake -doen | to do, to make -toen | then, when -moet | noun 'spot/mote' and present form of 'to must' -ben | (1) am, (2) 'are' in interrogative second person singular of 'to be' -zonder | without -kan | noun 'can' and present form of 'to be able' -hun | their, them -dus | so, consequently -alles | all, everything, anything -onder | under, beneath -ja | yes, of course -eens | once, one day -hier | here -wie | who -werd | imperfect third person sing. of 'become' -altijd | always -doch | yet, but etc -wordt | present third person sing. of 'become' -wezen | (1) to be, (2) 'been' as in 'been fishing', (3) orphans -kunnen | to be able -ons | us/our -zelf | self -tegen | against, towards, at -na | after, near -reeds | already -wil | (1) present tense of 'want', (2) 'will', noun, (3) fender -kon | could; past tense of 'to be able' -niets | nothing -uw | your -iemand | somebody -geweest | been; past participle of 'be' -andere | other + | From svn.tartarus.org/snowball/trunk/website/algorithms/dutch/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Dutch stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + | This is a ranked list (commonest to rarest) of stopwords derived from + | a large sample of Dutch text. + + | Dutch stop words frequently exhibit homonym clashes. These are indicated + | clearly below. + +de | the +en | and +van | of, from +ik | I, the ego +te | (1) chez, at etc, (2) to, (3) too +dat | that, which +die | that, those, who, which +in | in, inside +een | a, an, one +hij | he +het | the, it +niet | not, nothing, naught +zijn | (1) to be, being, (2) his, one's, its +is | is +was | (1) was, past tense of all persons sing. of 'zijn' (to be) (2) wax, (3) the washing, (4) rise of river +op | on, upon, at, in, up, used up +aan | on, upon, to (as dative) +met | with, by +als | like, such as, when +voor | (1) before, in front of, (2) furrow +had | had, past tense all persons sing. of 'hebben' (have) +er | there +maar | but, only +om | round, about, for etc +hem | him +dan | then +zou | should/would, past tense all persons sing. of 'zullen' +of | or, whether, if +wat | what, something, anything +mijn | possessive and noun 'mine' +men | people, 'one' +dit | this +zo | so, thus, in this way +door | through by +over | over, across +ze | she, her, they, them +zich | oneself +bij | (1) a bee, (2) by, near, at +ook | also, too +tot | till, until +je | you +mij | me +uit | out of, from +der | Old Dutch form of 'van der' still found in surnames +daar | (1) there, (2) because +haar | (1) her, their, them, (2) hair +naar | (1) unpleasant, unwell etc, (2) towards, (3) as +heb | present first person sing. of 'to have' +hoe | how, why +heeft | present third person sing. of 'to have' +hebben | 'to have' and various parts thereof +deze | this +u | you +want | (1) for, (2) mitten, (3) rigging +nog | yet, still +zal | 'shall', first and third person sing. of verb 'zullen' (will) +me | me +zij | she, they +nu | now +ge | 'thou', still used in Belgium and south Netherlands +geen | none +omdat | because +iets | something, somewhat +worden | to become, grow, get +toch | yet, still +al | all, every, each +waren | (1) 'were' (2) to wander, (3) wares, (3) +veel | much, many +meer | (1) more, (2) lake +doen | to do, to make +toen | then, when +moet | noun 'spot/mote' and present form of 'to must' +ben | (1) am, (2) 'are' in interrogative second person singular of 'to be' +zonder | without +kan | noun 'can' and present form of 'to be able' +hun | their, them +dus | so, consequently +alles | all, everything, anything +onder | under, beneath +ja | yes, of course +eens | once, one day +hier | here +wie | who +werd | imperfect third person sing. of 'become' +altijd | always +doch | yet, but etc +wordt | present third person sing. of 'become' +wezen | (1) to be, (2) 'been' as in 'been fishing', (3) orphans +kunnen | to be able +ons | us/our +zelf | self +tegen | against, towards, at +na | after, near +reeds | already +wil | (1) present tense of 'want', (2) 'will', noun, (3) fender +kon | could; past tense of 'to be able' +niets | nothing +uw | your +iemand | somebody +geweest | been; past participle of 'be' +andere | other diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_no.txt b/resources/cache/empty/similarity/conf/lang/stopwords_no.txt index 8aefda89..a7a2c28b 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_no.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_no.txt @@ -1,194 +1,194 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/norwegian/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Norwegian stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - | This stop word list is for the dominant bokmål dialect. Words unique - | to nynorsk are marked *. - - | Revised by Jan Bruusgaard , Jan 2005 - -og | and -i | in -jeg | I -det | it/this/that -at | to (w. inf.) -en | a/an -et | a/an -den | it/this/that -til | to -er | is/am/are -som | who/that -på | on -de | they / you(formal) -med | with -han | he -av | of -ikke | not -ikkje | not * -der | there -så | so -var | was/were -meg | me -seg | you -men | but -ett | one -har | have -om | about -vi | we -min | my -mitt | my -ha | have -hadde | had -hun | she -nå | now -over | over -da | when/as -ved | by/know -fra | from -du | you -ut | out -sin | your -dem | them -oss | us -opp | up -man | you/one -kan | can -hans | his -hvor | where -eller | or -hva | what -skal | shall/must -selv | self (reflective) -sjøl | self (reflective) -her | here -alle | all -vil | will -bli | become -ble | became -blei | became * -blitt | have become -kunne | could -inn | in -når | when -være | be -kom | come -noen | some -noe | some -ville | would -dere | you -som | who/which/that -deres | their/theirs -kun | only/just -ja | yes -etter | after -ned | down -skulle | should -denne | this -for | for/because -deg | you -si | hers/his -sine | hers/his -sitt | hers/his -mot | against -å | to -meget | much -hvorfor | why -dette | this -disse | these/those -uten | without -hvordan | how -ingen | none -din | your -ditt | your -blir | become -samme | same -hvilken | which -hvilke | which (plural) -sånn | such a -inni | inside/within -mellom | between -vår | our -hver | each -hvem | who -vors | us/ours -hvis | whose -både | both -bare | only/just -enn | than -fordi | as/because -før | before -mange | many -også | also -slik | just -vært | been -være | to be -båe | both * -begge | both -siden | since -dykk | your * -dykkar | yours * -dei | they * -deira | them * -deires | theirs * -deim | them * -di | your (fem.) * -då | as/when * -eg | I * -ein | a/an * -eit | a/an * -eitt | a/an * -elles | or * -honom | he * -hjå | at * -ho | she * -hoe | she * -henne | her -hennar | her/hers -hennes | hers -hoss | how * -hossen | how * -ikkje | not * -ingi | noone * -inkje | noone * -korleis | how * -korso | how * -kva | what/which * -kvar | where * -kvarhelst | where * -kven | who/whom * -kvi | why * -kvifor | why * -me | we * -medan | while * -mi | my * -mine | my * -mykje | much * -no | now * -nokon | some (masc./neut.) * -noka | some (fem.) * -nokor | some * -noko | some * -nokre | some * -si | his/hers * -sia | since * -sidan | since * -so | so * -somt | some * -somme | some * -um | about* -upp | up * -vere | be * -vore | was * -verte | become * -vort | become * -varte | became * -vart | became * - + | From svn.tartarus.org/snowball/trunk/website/algorithms/norwegian/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Norwegian stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + | This stop word list is for the dominant bokmål dialect. Words unique + | to nynorsk are marked *. + + | Revised by Jan Bruusgaard , Jan 2005 + +og | and +i | in +jeg | I +det | it/this/that +at | to (w. inf.) +en | a/an +et | a/an +den | it/this/that +til | to +er | is/am/are +som | who/that +på | on +de | they / you(formal) +med | with +han | he +av | of +ikke | not +ikkje | not * +der | there +så | so +var | was/were +meg | me +seg | you +men | but +ett | one +har | have +om | about +vi | we +min | my +mitt | my +ha | have +hadde | had +hun | she +nå | now +over | over +da | when/as +ved | by/know +fra | from +du | you +ut | out +sin | your +dem | them +oss | us +opp | up +man | you/one +kan | can +hans | his +hvor | where +eller | or +hva | what +skal | shall/must +selv | self (reflective) +sjøl | self (reflective) +her | here +alle | all +vil | will +bli | become +ble | became +blei | became * +blitt | have become +kunne | could +inn | in +når | when +være | be +kom | come +noen | some +noe | some +ville | would +dere | you +som | who/which/that +deres | their/theirs +kun | only/just +ja | yes +etter | after +ned | down +skulle | should +denne | this +for | for/because +deg | you +si | hers/his +sine | hers/his +sitt | hers/his +mot | against +å | to +meget | much +hvorfor | why +dette | this +disse | these/those +uten | without +hvordan | how +ingen | none +din | your +ditt | your +blir | become +samme | same +hvilken | which +hvilke | which (plural) +sånn | such a +inni | inside/within +mellom | between +vår | our +hver | each +hvem | who +vors | us/ours +hvis | whose +både | both +bare | only/just +enn | than +fordi | as/because +før | before +mange | many +også | also +slik | just +vært | been +være | to be +båe | both * +begge | both +siden | since +dykk | your * +dykkar | yours * +dei | they * +deira | them * +deires | theirs * +deim | them * +di | your (fem.) * +då | as/when * +eg | I * +ein | a/an * +eit | a/an * +eitt | a/an * +elles | or * +honom | he * +hjå | at * +ho | she * +hoe | she * +henne | her +hennar | her/hers +hennes | hers +hoss | how * +hossen | how * +ikkje | not * +ingi | noone * +inkje | noone * +korleis | how * +korso | how * +kva | what/which * +kvar | where * +kvarhelst | where * +kven | who/whom * +kvi | why * +kvifor | why * +me | we * +medan | while * +mi | my * +mine | my * +mykje | much * +no | now * +nokon | some (masc./neut.) * +noka | some (fem.) * +nokor | some * +noko | some * +nokre | some * +si | his/hers * +sia | since * +sidan | since * +so | so * +somt | some * +somme | some * +um | about* +upp | up * +vere | be * +vore | was * +verte | become * +vort | become * +varte | became * +vart | became * + diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_pt.txt b/resources/cache/empty/similarity/conf/lang/stopwords_pt.txt index 6afa2b5c..acfeb01a 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_pt.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_pt.txt @@ -1,253 +1,253 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/portuguese/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Portuguese stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - - | The following is a ranked list (commonest to rarest) of stopwords - | deriving from a large sample of text. - - | Extra words have been added at the end. - -de | of, from -a | the; to, at; her -o | the; him -que | who, that -e | and -do | de + o -da | de + a -em | in -um | a -para | for - | é from SER -com | with -não | not, no -uma | a -os | the; them -no | em + o -se | himself etc -na | em + a -por | for -mais | more -as | the; them -dos | de + os -como | as, like -mas | but - | foi from SER -ao | a + o -ele | he -das | de + as - | tem from TER -à | a + a -seu | his -sua | her -ou | or - | ser from SER -quando | when -muito | much - | há from HAV -nos | em + os; us -já | already, now - | está from EST -eu | I -também | also -só | only, just -pelo | per + o -pela | per + a -até | up to -isso | that -ela | he -entre | between - | era from SER -depois | after -sem | without -mesmo | same -aos | a + os - | ter from TER -seus | his -quem | whom -nas | em + as -me | me -esse | that -eles | they - | estão from EST -você | you - | tinha from TER - | foram from SER -essa | that -num | em + um -nem | nor -suas | her -meu | my -às | a + as -minha | my - | têm from TER -numa | em + uma -pelos | per + os -elas | they - | havia from HAV - | seja from SER -qual | which - | será from SER -nós | we - | tenho from TER -lhe | to him, her -deles | of them -essas | those -esses | those -pelas | per + as -este | this - | fosse from SER -dele | of him - - | other words. There are many contractions such as naquele = em+aquele, - | mo = me+o, but they are rare. - | Indefinite article plural forms are also rare. - -tu | thou -te | thee -vocês | you (plural) -vos | you -lhes | to them -meus | my -minhas -teu | thy -tua -teus -tuas -nosso | our -nossa -nossos -nossas - -dela | of her -delas | of them - -esta | this -estes | these -estas | these -aquele | that -aquela | that -aqueles | those -aquelas | those -isto | this -aquilo | that - - | forms of estar, to be (not including the infinitive): -estou -está -estamos -estão -estive -esteve -estivemos -estiveram -estava -estávamos -estavam -estivera -estivéramos -esteja -estejamos -estejam -estivesse -estivéssemos -estivessem -estiver -estivermos -estiverem - - | forms of haver, to have (not including the infinitive): -hei -há -havemos -hão -houve -houvemos -houveram -houvera -houvéramos -haja -hajamos -hajam -houvesse -houvéssemos -houvessem -houver -houvermos -houverem -houverei -houverá -houveremos -houverão -houveria -houveríamos -houveriam - - | forms of ser, to be (not including the infinitive): -sou -somos -são -era -éramos -eram -fui -foi -fomos -foram -fora -fôramos -seja -sejamos -sejam -fosse -fôssemos -fossem -for -formos -forem -serei -será -seremos -serão -seria -seríamos -seriam - - | forms of ter, to have (not including the infinitive): -tenho -tem -temos -tém -tinha -tínhamos -tinham -tive -teve -tivemos -tiveram -tivera -tivéramos -tenha -tenhamos -tenham -tivesse -tivéssemos -tivessem -tiver -tivermos -tiverem -terei -terá -teremos -terão -teria -teríamos -teriam + | From svn.tartarus.org/snowball/trunk/website/algorithms/portuguese/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Portuguese stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + + | The following is a ranked list (commonest to rarest) of stopwords + | deriving from a large sample of text. + + | Extra words have been added at the end. + +de | of, from +a | the; to, at; her +o | the; him +que | who, that +e | and +do | de + o +da | de + a +em | in +um | a +para | for + | é from SER +com | with +não | not, no +uma | a +os | the; them +no | em + o +se | himself etc +na | em + a +por | for +mais | more +as | the; them +dos | de + os +como | as, like +mas | but + | foi from SER +ao | a + o +ele | he +das | de + as + | tem from TER +à | a + a +seu | his +sua | her +ou | or + | ser from SER +quando | when +muito | much + | há from HAV +nos | em + os; us +já | already, now + | está from EST +eu | I +também | also +só | only, just +pelo | per + o +pela | per + a +até | up to +isso | that +ela | he +entre | between + | era from SER +depois | after +sem | without +mesmo | same +aos | a + os + | ter from TER +seus | his +quem | whom +nas | em + as +me | me +esse | that +eles | they + | estão from EST +você | you + | tinha from TER + | foram from SER +essa | that +num | em + um +nem | nor +suas | her +meu | my +às | a + as +minha | my + | têm from TER +numa | em + uma +pelos | per + os +elas | they + | havia from HAV + | seja from SER +qual | which + | será from SER +nós | we + | tenho from TER +lhe | to him, her +deles | of them +essas | those +esses | those +pelas | per + as +este | this + | fosse from SER +dele | of him + + | other words. There are many contractions such as naquele = em+aquele, + | mo = me+o, but they are rare. + | Indefinite article plural forms are also rare. + +tu | thou +te | thee +vocês | you (plural) +vos | you +lhes | to them +meus | my +minhas +teu | thy +tua +teus +tuas +nosso | our +nossa +nossos +nossas + +dela | of her +delas | of them + +esta | this +estes | these +estas | these +aquele | that +aquela | that +aqueles | those +aquelas | those +isto | this +aquilo | that + + | forms of estar, to be (not including the infinitive): +estou +está +estamos +estão +estive +esteve +estivemos +estiveram +estava +estávamos +estavam +estivera +estivéramos +esteja +estejamos +estejam +estivesse +estivéssemos +estivessem +estiver +estivermos +estiverem + + | forms of haver, to have (not including the infinitive): +hei +há +havemos +hão +houve +houvemos +houveram +houvera +houvéramos +haja +hajamos +hajam +houvesse +houvéssemos +houvessem +houver +houvermos +houverem +houverei +houverá +houveremos +houverão +houveria +houveríamos +houveriam + + | forms of ser, to be (not including the infinitive): +sou +somos +são +era +éramos +eram +fui +foi +fomos +foram +fora +fôramos +seja +sejamos +sejam +fosse +fôssemos +fossem +for +formos +forem +serei +será +seremos +serão +seria +seríamos +seriam + + | forms of ter, to have (not including the infinitive): +tenho +tem +temos +tém +tinha +tínhamos +tinham +tive +teve +tivemos +tiveram +tivera +tivéramos +tenha +tenhamos +tenham +tivesse +tivéssemos +tivessem +tiver +tivermos +tiverem +terei +terá +teremos +terão +teria +teríamos +teriam diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_ro.txt b/resources/cache/empty/similarity/conf/lang/stopwords_ro.txt index 2d7395c4..4fdee90a 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_ro.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_ro.txt @@ -1,233 +1,233 @@ -# This file was created by Jacques Savoy and is distributed under the BSD license. -# See http://members.unine.ch/jacques.savoy/clef/index.html. -# Also see http://www.opensource.org/licenses/bsd-license.html -acea -aceasta -această -aceea -acei -aceia -acel -acela -acele -acelea -acest -acesta -aceste -acestea -aceşti -aceştia -acolo -acum -ai -aia -aibă -aici -al -ăla -ale -alea -ălea -altceva -altcineva -am -ar -are -aş -aşadar -asemenea -asta -ăsta -astăzi -astea -ăstea -ăştia -asupra -aţi -au -avea -avem -aveţi -azi -bine -bucur -bună -ca -că -căci -când -care -cărei -căror -cărui -cât -câte -câţi -către -câtva -ce -cel -ceva -chiar -cînd -cine -cineva -cît -cîte -cîţi -cîtva -contra -cu -cum -cumva -curând -curînd -da -dă -dacă -dar -datorită -de -deci -deja -deoarece -departe -deşi -din -dinaintea -dintr -dintre -drept -după -ea -ei -el -ele -eram -este -eşti -eu -face -fără -fi -fie -fiecare -fii -fim -fiţi -iar -ieri -îi -îl -îmi -împotriva -în -înainte -înaintea -încât -încît -încotro -între -întrucât -întrucît -îţi -la -lângă -le -li -lîngă -lor -lui -mă -mâine -mea -mei -mele -mereu -meu -mi -mine -mult -multă -mulţi -ne -nicăieri -nici -nimeni -nişte -noastră -noastre -noi -noştri -nostru -nu -ori -oricând -oricare -oricât -orice -oricînd -oricine -oricît -oricum -oriunde -până -pe -pentru -peste -pînă -poate -pot -prea -prima -primul -prin -printr -sa -să -săi -sale -sau -său -se -şi -sînt -sîntem -sînteţi -spre -sub -sunt -suntem -sunteţi -ta -tăi -tale -tău -te -ţi -ţie -tine -toată -toate -tot -toţi -totuşi -tu -un -una -unde -undeva -unei -unele -uneori -unor -vă -vi -voastră -voastre -voi -voştri -vostru -vouă -vreo -vreun +# This file was created by Jacques Savoy and is distributed under the BSD license. +# See http://members.unine.ch/jacques.savoy/clef/index.html. +# Also see http://www.opensource.org/licenses/bsd-license.html +acea +aceasta +această +aceea +acei +aceia +acel +acela +acele +acelea +acest +acesta +aceste +acestea +aceşti +aceştia +acolo +acum +ai +aia +aibă +aici +al +ăla +ale +alea +ălea +altceva +altcineva +am +ar +are +aş +aşadar +asemenea +asta +ăsta +astăzi +astea +ăstea +ăştia +asupra +aţi +au +avea +avem +aveţi +azi +bine +bucur +bună +ca +că +căci +când +care +cărei +căror +cărui +cât +câte +câţi +către +câtva +ce +cel +ceva +chiar +cînd +cine +cineva +cît +cîte +cîţi +cîtva +contra +cu +cum +cumva +curând +curînd +da +dă +dacă +dar +datorită +de +deci +deja +deoarece +departe +deşi +din +dinaintea +dintr +dintre +drept +după +ea +ei +el +ele +eram +este +eşti +eu +face +fără +fi +fie +fiecare +fii +fim +fiţi +iar +ieri +îi +îl +îmi +împotriva +în +înainte +înaintea +încât +încît +încotro +între +întrucât +întrucît +îţi +la +lângă +le +li +lîngă +lor +lui +mă +mâine +mea +mei +mele +mereu +meu +mi +mine +mult +multă +mulţi +ne +nicăieri +nici +nimeni +nişte +noastră +noastre +noi +noştri +nostru +nu +ori +oricând +oricare +oricât +orice +oricînd +oricine +oricît +oricum +oriunde +până +pe +pentru +peste +pînă +poate +pot +prea +prima +primul +prin +printr +sa +să +săi +sale +sau +său +se +şi +sînt +sîntem +sînteţi +spre +sub +sunt +suntem +sunteţi +ta +tăi +tale +tău +te +ţi +ţie +tine +toată +toate +tot +toţi +totuşi +tu +un +una +unde +undeva +unei +unele +uneori +unor +vă +vi +voastră +voastre +voi +voştri +vostru +vouă +vreo +vreun diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_ru.txt b/resources/cache/empty/similarity/conf/lang/stopwords_ru.txt index 0141b9b8..55271400 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_ru.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_ru.txt @@ -1,243 +1,243 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/russian/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | a russian stop word list. comments begin with vertical bar. each stop - | word is at the start of a line. - - | this is a ranked list (commonest to rarest) of stopwords derived from - | a large text sample. - - | letter `ё' is translated to `е'. - -и | and -в | in/into -во | alternative form -не | not -что | what/that -он | he -на | on/onto -я | i -с | from -со | alternative form -как | how -а | milder form of `no' (but) -то | conjunction and form of `that' -все | all -она | she -так | so, thus -его | him -но | but -да | yes/and -ты | thou -к | towards, by -у | around, chez -же | intensifier particle -вы | you -за | beyond, behind -бы | conditional/subj. particle -по | up to, along -только | only -ее | her -мне | to me -было | it was -вот | here is/are, particle -от | away from -меня | me -еще | still, yet, more -нет | no, there isnt/arent -о | about -из | out of -ему | to him -теперь | now -когда | when -даже | even -ну | so, well -вдруг | suddenly -ли | interrogative particle -если | if -уже | already, but homonym of `narrower' -или | or -ни | neither -быть | to be -был | he was -него | prepositional form of его -до | up to -вас | you accusative -нибудь | indef. suffix preceded by hyphen -опять | again -уж | already, but homonym of `adder' -вам | to you -сказал | he said -ведь | particle `after all' -там | there -потом | then -себя | oneself -ничего | nothing -ей | to her -может | usually with `быть' as `maybe' -они | they -тут | here -где | where -есть | there is/are -надо | got to, must -ней | prepositional form of ей -для | for -мы | we -тебя | thee -их | them, their -чем | than -была | she was -сам | self -чтоб | in order to -без | without -будто | as if -человек | man, person, one -чего | genitive form of `what' -раз | once -тоже | also -себе | to oneself -под | beneath -жизнь | life -будет | will be -ж | short form of intensifer particle `же' -тогда | then -кто | who -этот | this -говорил | was saying -того | genitive form of `that' -потому | for that reason -этого | genitive form of `this' -какой | which -совсем | altogether -ним | prepositional form of `его', `они' -здесь | here -этом | prepositional form of `этот' -один | one -почти | almost -мой | my -тем | instrumental/dative plural of `тот', `то' -чтобы | full form of `in order that' -нее | her (acc.) -кажется | it seems -сейчас | now -были | they were -куда | where to -зачем | why -сказать | to say -всех | all (acc., gen. preposn. plural) -никогда | never -сегодня | today -можно | possible, one can -при | by -наконец | finally -два | two -об | alternative form of `о', about -другой | another -хоть | even -после | after -над | above -больше | more -тот | that one (masc.) -через | across, in -эти | these -нас | us -про | about -всего | in all, only, of all -них | prepositional form of `они' (they) -какая | which, feminine -много | lots -разве | interrogative particle -сказала | she said -три | three -эту | this, acc. fem. sing. -моя | my, feminine -впрочем | moreover, besides -хорошо | good -свою | ones own, acc. fem. sing. -этой | oblique form of `эта', fem. `this' -перед | in front of -иногда | sometimes -лучше | better -чуть | a little -том | preposn. form of `that one' -нельзя | one must not -такой | such a one -им | to them -более | more -всегда | always -конечно | of course -всю | acc. fem. sing of `all' -между | between - - - | b: some paradigms - | - | personal pronouns - | - | я меня мне мной [мною] - | ты тебя тебе тобой [тобою] - | он его ему им [него, нему, ним] - | она ее эи ею [нее, нэи, нею] - | оно его ему им [него, нему, ним] - | - | мы нас нам нами - | вы вас вам вами - | они их им ими [них, ним, ними] - | - | себя себе собой [собою] - | - | demonstrative pronouns: этот (this), тот (that) - | - | этот эта это эти - | этого эты это эти - | этого этой этого этих - | этому этой этому этим - | этим этой этим [этою] этими - | этом этой этом этих - | - | тот та то те - | того ту то те - | того той того тех - | тому той тому тем - | тем той тем [тою] теми - | том той том тех - | - | determinative pronouns - | - | (a) весь (all) - | - | весь вся все все - | всего всю все все - | всего всей всего всех - | всему всей всему всем - | всем всей всем [всею] всеми - | всем всей всем всех - | - | (b) сам (himself etc) - | - | сам сама само сами - | самого саму само самих - | самого самой самого самих - | самому самой самому самим - | самим самой самим [самою] самими - | самом самой самом самих - | - | stems of verbs `to be', `to have', `to do' and modal - | - | быть бы буд быв есть суть - | име - | дел - | мог мож мочь - | уме - | хоч хот - | долж - | можн - | нужн - | нельзя - + | From svn.tartarus.org/snowball/trunk/website/algorithms/russian/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | a russian stop word list. comments begin with vertical bar. each stop + | word is at the start of a line. + + | this is a ranked list (commonest to rarest) of stopwords derived from + | a large text sample. + + | letter `ё' is translated to `е'. + +и | and +в | in/into +во | alternative form +не | not +что | what/that +он | he +на | on/onto +я | i +с | from +со | alternative form +как | how +а | milder form of `no' (but) +то | conjunction and form of `that' +все | all +она | she +так | so, thus +его | him +но | but +да | yes/and +ты | thou +к | towards, by +у | around, chez +же | intensifier particle +вы | you +за | beyond, behind +бы | conditional/subj. particle +по | up to, along +только | only +ее | her +мне | to me +было | it was +вот | here is/are, particle +от | away from +меня | me +еще | still, yet, more +нет | no, there isnt/arent +о | about +из | out of +ему | to him +теперь | now +когда | when +даже | even +ну | so, well +вдруг | suddenly +ли | interrogative particle +если | if +уже | already, but homonym of `narrower' +или | or +ни | neither +быть | to be +был | he was +него | prepositional form of его +до | up to +вас | you accusative +нибудь | indef. suffix preceded by hyphen +опять | again +уж | already, but homonym of `adder' +вам | to you +сказал | he said +ведь | particle `after all' +там | there +потом | then +себя | oneself +ничего | nothing +ей | to her +может | usually with `быть' as `maybe' +они | they +тут | here +где | where +есть | there is/are +надо | got to, must +ней | prepositional form of ей +для | for +мы | we +тебя | thee +их | them, their +чем | than +была | she was +сам | self +чтоб | in order to +без | without +будто | as if +человек | man, person, one +чего | genitive form of `what' +раз | once +тоже | also +себе | to oneself +под | beneath +жизнь | life +будет | will be +ж | short form of intensifer particle `же' +тогда | then +кто | who +этот | this +говорил | was saying +того | genitive form of `that' +потому | for that reason +этого | genitive form of `this' +какой | which +совсем | altogether +ним | prepositional form of `его', `они' +здесь | here +этом | prepositional form of `этот' +один | one +почти | almost +мой | my +тем | instrumental/dative plural of `тот', `то' +чтобы | full form of `in order that' +нее | her (acc.) +кажется | it seems +сейчас | now +были | they were +куда | where to +зачем | why +сказать | to say +всех | all (acc., gen. preposn. plural) +никогда | never +сегодня | today +можно | possible, one can +при | by +наконец | finally +два | two +об | alternative form of `о', about +другой | another +хоть | even +после | after +над | above +больше | more +тот | that one (masc.) +через | across, in +эти | these +нас | us +про | about +всего | in all, only, of all +них | prepositional form of `они' (they) +какая | which, feminine +много | lots +разве | interrogative particle +сказала | she said +три | three +эту | this, acc. fem. sing. +моя | my, feminine +впрочем | moreover, besides +хорошо | good +свою | ones own, acc. fem. sing. +этой | oblique form of `эта', fem. `this' +перед | in front of +иногда | sometimes +лучше | better +чуть | a little +том | preposn. form of `that one' +нельзя | one must not +такой | such a one +им | to them +более | more +всегда | always +конечно | of course +всю | acc. fem. sing of `all' +между | between + + + | b: some paradigms + | + | personal pronouns + | + | я меня мне мной [мною] + | ты тебя тебе тобой [тобою] + | он его ему им [него, нему, ним] + | она ее эи ею [нее, нэи, нею] + | оно его ему им [него, нему, ним] + | + | мы нас нам нами + | вы вас вам вами + | они их им ими [них, ним, ними] + | + | себя себе собой [собою] + | + | demonstrative pronouns: этот (this), тот (that) + | + | этот эта это эти + | этого эты это эти + | этого этой этого этих + | этому этой этому этим + | этим этой этим [этою] этими + | этом этой этом этих + | + | тот та то те + | того ту то те + | того той того тех + | тому той тому тем + | тем той тем [тою] теми + | том той том тех + | + | determinative pronouns + | + | (a) весь (all) + | + | весь вся все все + | всего всю все все + | всего всей всего всех + | всему всей всему всем + | всем всей всем [всею] всеми + | всем всей всем всех + | + | (b) сам (himself etc) + | + | сам сама само сами + | самого саму само самих + | самого самой самого самих + | самому самой самому самим + | самим самой самим [самою] самими + | самом самой самом самих + | + | stems of verbs `to be', `to have', `to do' and modal + | + | быть бы буд быв есть суть + | име + | дел + | мог мож мочь + | уме + | хоч хот + | долж + | можн + | нужн + | нельзя + diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_sv.txt b/resources/cache/empty/similarity/conf/lang/stopwords_sv.txt index 7216373b..096f87f6 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_sv.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_sv.txt @@ -1,133 +1,133 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/swedish/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Swedish stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - | This is a ranked list (commonest to rarest) of stopwords derived from - | a large text sample. - - | Swedish stop words occasionally exhibit homonym clashes. For example - | så = so, but also seed. These are indicated clearly below. - -och | and -det | it, this/that -att | to (with infinitive) -i | in, at -en | a -jag | I -hon | she -som | who, that -han | he -på | on -den | it, this/that -med | with -var | where, each -sig | him(self) etc -för | for -så | so (also: seed) -till | to -är | is -men | but -ett | a -om | if; around, about -hade | had -de | they, these/those -av | of -icke | not, no -mig | me -du | you -henne | her -då | then, when -sin | his -nu | now -har | have -inte | inte någon = no one -hans | his -honom | him -skulle | 'sake' -hennes | her -där | there -min | my -man | one (pronoun) -ej | nor -vid | at, by, on (also: vast) -kunde | could -något | some etc -från | from, off -ut | out -när | when -efter | after, behind -upp | up -vi | we -dem | them -vara | be -vad | what -över | over -än | than -dig | you -kan | can -sina | his -här | here -ha | have -mot | towards -alla | all -under | under (also: wonder) -någon | some etc -eller | or (else) -allt | all -mycket | much -sedan | since -ju | why -denna | this/that -själv | myself, yourself etc -detta | this/that -åt | to -utan | without -varit | was -hur | how -ingen | no -mitt | my -ni | you -bli | to be, become -blev | from bli -oss | us -din | thy -dessa | these/those -några | some etc -deras | their -blir | from bli -mina | my -samma | (the) same -vilken | who, that -er | you, your -sådan | such a -vår | our -blivit | from bli -dess | its -inom | within -mellan | between -sådant | such a -varför | why -varje | each -vilka | who, that -ditt | thy -vem | who -vilket | who, that -sitta | his -sådana | such a -vart | each -dina | thy -vars | whose -vårt | our -våra | our -ert | your -era | your -vilkas | whose - + | From svn.tartarus.org/snowball/trunk/website/algorithms/swedish/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Swedish stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + | This is a ranked list (commonest to rarest) of stopwords derived from + | a large text sample. + + | Swedish stop words occasionally exhibit homonym clashes. For example + | så = so, but also seed. These are indicated clearly below. + +och | and +det | it, this/that +att | to (with infinitive) +i | in, at +en | a +jag | I +hon | she +som | who, that +han | he +på | on +den | it, this/that +med | with +var | where, each +sig | him(self) etc +för | for +så | so (also: seed) +till | to +är | is +men | but +ett | a +om | if; around, about +hade | had +de | they, these/those +av | of +icke | not, no +mig | me +du | you +henne | her +då | then, when +sin | his +nu | now +har | have +inte | inte någon = no one +hans | his +honom | him +skulle | 'sake' +hennes | her +där | there +min | my +man | one (pronoun) +ej | nor +vid | at, by, on (also: vast) +kunde | could +något | some etc +från | from, off +ut | out +när | when +efter | after, behind +upp | up +vi | we +dem | them +vara | be +vad | what +över | over +än | than +dig | you +kan | can +sina | his +här | here +ha | have +mot | towards +alla | all +under | under (also: wonder) +någon | some etc +eller | or (else) +allt | all +mycket | much +sedan | since +ju | why +denna | this/that +själv | myself, yourself etc +detta | this/that +åt | to +utan | without +varit | was +hur | how +ingen | no +mitt | my +ni | you +bli | to be, become +blev | from bli +oss | us +din | thy +dessa | these/those +några | some etc +deras | their +blir | from bli +mina | my +samma | (the) same +vilken | who, that +er | you, your +sådan | such a +vår | our +blivit | from bli +dess | its +inom | within +mellan | between +sådant | such a +varför | why +varje | each +vilka | who, that +ditt | thy +vem | who +vilket | who, that +sitta | his +sådana | such a +vart | each +dina | thy +vars | whose +vårt | our +våra | our +ert | your +era | your +vilkas | whose + diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_th.txt b/resources/cache/empty/similarity/conf/lang/stopwords_th.txt index 1415edf9..07f0fabe 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_th.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_th.txt @@ -1,119 +1,119 @@ -# Thai stopwords from: -# "Opinion Detection in Thai Political News Columns -# Based on Subjectivity Analysis" -# Khampol Sukhum, Supot Nitsuwat, and Choochart Haruechaiyasak -ไว้ -ไม่ -ไป -ได้ -ให้ -ใน -โดย -แห่ง -แล้ว -และ -แรก -แบบ -แต่ -เอง -เห็น -เลย -เริ่ม -เรา -เมื่อ -เพื่อ -เพราะ -เป็นการ -เป็น -เปิดเผย -เปิด -เนื่องจาก -เดียวกัน -เดียว -เช่น -เฉพาะ -เคย -เข้า -เขา -อีก -อาจ -อะไร -ออก -อย่าง -อยู่ -อยาก -หาก -หลาย -หลังจาก -หลัง -หรือ -หนึ่ง -ส่วน -ส่ง -สุด -สําหรับ -ว่า -วัน -ลง -ร่วม -ราย -รับ -ระหว่าง -รวม -ยัง -มี -มาก -มา -พร้อม -พบ -ผ่าน -ผล -บาง -น่า -นี้ -นํา -นั้น -นัก -นอกจาก -ทุก -ที่สุด -ที่ -ทําให้ -ทํา -ทาง -ทั้งนี้ -ทั้ง -ถ้า -ถูก -ถึง -ต้อง -ต่างๆ -ต่าง -ต่อ -ตาม -ตั้งแต่ -ตั้ง -ด้าน -ด้วย -ดัง -ซึ่ง -ช่วง -จึง -จาก -จัด -จะ -คือ -ความ -ครั้ง -คง -ขึ้น -ของ -ขอ -ขณะ -ก่อน -ก็ -การ -กับ -กัน -กว่า -กล่าว +# Thai stopwords from: +# "Opinion Detection in Thai Political News Columns +# Based on Subjectivity Analysis" +# Khampol Sukhum, Supot Nitsuwat, and Choochart Haruechaiyasak +ไว้ +ไม่ +ไป +ได้ +ให้ +ใน +โดย +แห่ง +แล้ว +และ +แรก +แบบ +แต่ +เอง +เห็น +เลย +เริ่ม +เรา +เมื่อ +เพื่อ +เพราะ +เป็นการ +เป็น +เปิดเผย +เปิด +เนื่องจาก +เดียวกัน +เดียว +เช่น +เฉพาะ +เคย +เข้า +เขา +อีก +อาจ +อะไร +ออก +อย่าง +อยู่ +อยาก +หาก +หลาย +หลังจาก +หลัง +หรือ +หนึ่ง +ส่วน +ส่ง +สุด +สําหรับ +ว่า +วัน +ลง +ร่วม +ราย +รับ +ระหว่าง +รวม +ยัง +มี +มาก +มา +พร้อม +พบ +ผ่าน +ผล +บาง +น่า +นี้ +นํา +นั้น +นัก +นอกจาก +ทุก +ที่สุด +ที่ +ทําให้ +ทํา +ทาง +ทั้งนี้ +ทั้ง +ถ้า +ถูก +ถึง +ต้อง +ต่างๆ +ต่าง +ต่อ +ตาม +ตั้งแต่ +ตั้ง +ด้าน +ด้วย +ดัง +ซึ่ง +ช่วง +จึง +จาก +จัด +จะ +คือ +ความ +ครั้ง +คง +ขึ้น +ของ +ขอ +ขณะ +ก่อน +ก็ +การ +กับ +กัน +กว่า +กล่าว diff --git a/resources/cache/empty/similarity/conf/lang/stopwords_tr.txt b/resources/cache/empty/similarity/conf/lang/stopwords_tr.txt index fe4083b7..84d9408d 100644 --- a/resources/cache/empty/similarity/conf/lang/stopwords_tr.txt +++ b/resources/cache/empty/similarity/conf/lang/stopwords_tr.txt @@ -1,212 +1,212 @@ -# Turkish stopwords from LUCENE-559 -# merged with the list from "Information Retrieval on Turkish Texts" -# (http://www.users.muohio.edu/canf/papers/JASIST2008offPrint.pdf) -acaba -altmış -altı -ama -ancak -arada -aslında -ayrıca -bana -bazı -belki -ben -benden -beni -benim -beri -beş -bile -bin -bir -birçok -biri -birkaç -birkez -birşey -birşeyi -biz -bize -bizden -bizi -bizim -böyle -böylece -bu -buna -bunda -bundan -bunlar -bunları -bunların -bunu -bunun -burada -çok -çünkü -da -daha -dahi -de -defa -değil -diğer -diye -doksan -dokuz -dolayı -dolayısıyla -dört -edecek -eden -ederek -edilecek -ediliyor -edilmesi -ediyor -eğer -elli -en -etmesi -etti -ettiği -ettiğini -gibi -göre -halen -hangi -hatta -hem -henüz -hep -hepsi -her -herhangi -herkesin -hiç -hiçbir -için -iki -ile -ilgili -ise -işte -itibaren -itibariyle -kadar -karşın -katrilyon -kendi -kendilerine -kendini -kendisi -kendisine -kendisini -kez -ki -kim -kimden -kime -kimi -kimse -kırk -milyar -milyon -mu -mü -mı -nasıl -ne -neden -nedenle -nerde -nerede -nereye -niye -niçin -o -olan -olarak -oldu -olduğu -olduğunu -olduklarını -olmadı -olmadığı -olmak -olması -olmayan -olmaz -olsa -olsun -olup -olur -olursa -oluyor -on -ona -ondan -onlar -onlardan -onları -onların -onu -onun -otuz -oysa -öyle -pek -rağmen -sadece -sanki -sekiz -seksen -sen -senden -seni -senin -siz -sizden -sizi -sizin -şey -şeyden -şeyi -şeyler -şöyle -şu -şuna -şunda -şundan -şunları -şunu -tarafından -trilyon -tüm -üç -üzere -var -vardı -ve -veya -ya -yani -yapacak -yapılan -yapılması -yapıyor -yapmak -yaptı -yaptığı -yaptığını -yaptıkları -yedi -yerine -yetmiş -yine -yirmi -yoksa -yüz -zaten +# Turkish stopwords from LUCENE-559 +# merged with the list from "Information Retrieval on Turkish Texts" +# (http://www.users.muohio.edu/canf/papers/JASIST2008offPrint.pdf) +acaba +altmış +altı +ama +ancak +arada +aslında +ayrıca +bana +bazı +belki +ben +benden +beni +benim +beri +beş +bile +bin +bir +birçok +biri +birkaç +birkez +birşey +birşeyi +biz +bize +bizden +bizi +bizim +böyle +böylece +bu +buna +bunda +bundan +bunlar +bunları +bunların +bunu +bunun +burada +çok +çünkü +da +daha +dahi +de +defa +değil +diğer +diye +doksan +dokuz +dolayı +dolayısıyla +dört +edecek +eden +ederek +edilecek +ediliyor +edilmesi +ediyor +eğer +elli +en +etmesi +etti +ettiği +ettiğini +gibi +göre +halen +hangi +hatta +hem +henüz +hep +hepsi +her +herhangi +herkesin +hiç +hiçbir +için +iki +ile +ilgili +ise +işte +itibaren +itibariyle +kadar +karşın +katrilyon +kendi +kendilerine +kendini +kendisi +kendisine +kendisini +kez +ki +kim +kimden +kime +kimi +kimse +kırk +milyar +milyon +mu +mü +mı +nasıl +ne +neden +nedenle +nerde +nerede +nereye +niye +niçin +o +olan +olarak +oldu +olduğu +olduğunu +olduklarını +olmadı +olmadığı +olmak +olması +olmayan +olmaz +olsa +olsun +olup +olur +olursa +oluyor +on +ona +ondan +onlar +onlardan +onları +onların +onu +onun +otuz +oysa +öyle +pek +rağmen +sadece +sanki +sekiz +seksen +sen +senden +seni +senin +siz +sizden +sizi +sizin +şey +şeyden +şeyi +şeyler +şöyle +şu +şuna +şunda +şundan +şunları +şunu +tarafından +trilyon +tüm +üç +üzere +var +vardı +ve +veya +ya +yani +yapacak +yapılan +yapılması +yapıyor +yapmak +yaptı +yaptığı +yaptığını +yaptıkları +yedi +yerine +yetmiş +yine +yirmi +yoksa +yüz +zaten diff --git a/resources/cache/empty/similarity/conf/lang/userdict_ja.txt b/resources/cache/empty/similarity/conf/lang/userdict_ja.txt index c79de826..6f0368e4 100644 --- a/resources/cache/empty/similarity/conf/lang/userdict_ja.txt +++ b/resources/cache/empty/similarity/conf/lang/userdict_ja.txt @@ -1,29 +1,29 @@ -# -# This is a sample user dictionary for Kuromoji (JapaneseTokenizer) -# -# Add entries to this file in order to override the statistical model in terms -# of segmentation, readings and part-of-speech tags. Notice that entries do -# not have weights since they are always used when found. This is by-design -# in order to maximize ease-of-use. -# -# Entries are defined using the following CSV format: -# , ... , ... , -# -# Notice that a single half-width space separates tokens and readings, and -# that the number tokens and readings must match exactly. -# -# Also notice that multiple entries with the same is undefined. -# -# Whitespace only lines are ignored. Comments are not allowed on entry lines. -# - -# Custom segmentation for kanji compounds -日本経済新聞,日本 経済 新聞,ニホン ケイザイ シンブン,カスタム名詞 -関西国際空港,関西 国際 空港,カンサイ コクサイ クウコウ,カスタム名詞 - -# Custom segmentation for compound katakana -トートバッグ,トート バッグ,トート バッグ,かずカナ名詞 -ショルダーバッグ,ショルダー バッグ,ショルダー バッグ,かずカナ名詞 - -# Custom reading for former sumo wrestler -朝青龍,朝青龍,アサショウリュウ,カスタム人名 +# +# This is a sample user dictionary for Kuromoji (JapaneseTokenizer) +# +# Add entries to this file in order to override the statistical model in terms +# of segmentation, readings and part-of-speech tags. Notice that entries do +# not have weights since they are always used when found. This is by-design +# in order to maximize ease-of-use. +# +# Entries are defined using the following CSV format: +# , ... , ... , +# +# Notice that a single half-width space separates tokens and readings, and +# that the number tokens and readings must match exactly. +# +# Also notice that multiple entries with the same is undefined. +# +# Whitespace only lines are ignored. Comments are not allowed on entry lines. +# + +# Custom segmentation for kanji compounds +日本経済新聞,日本 経済 新聞,ニホン ケイザイ シンブン,カスタム名詞 +関西国際空港,関西 国際 空港,カンサイ コクサイ クウコウ,カスタム名詞 + +# Custom segmentation for compound katakana +トートバッグ,トート バッグ,トート バッグ,かずカナ名詞 +ショルダーバッグ,ショルダー バッグ,ショルダー バッグ,かずカナ名詞 + +# Custom reading for former sumo wrestler +朝青龍,朝青龍,アサショウリュウ,カスタム人名 diff --git a/resources/cache/empty/similarity/conf/params.json b/resources/cache/empty/similarity/conf/params.json index abf4154e..9c259db5 100644 --- a/resources/cache/empty/similarity/conf/params.json +++ b/resources/cache/empty/similarity/conf/params.json @@ -1,20 +1,20 @@ -{"params":{ - "query":{ - "defType":"edismax", - "q.alt":"*:*", - "rows":"10", - "fl":"*,score", - "":{"v":0} - }, - "facets":{ - "facet":"on", - "facet.mincount": "1", - "":{"v":0} - }, - "velocity":{ - "wt": "velocity", - "v.template":"browse", - "v.layout": "layout", - "":{"v":0} - } -}} +{"params":{ + "query":{ + "defType":"edismax", + "q.alt":"*:*", + "rows":"10", + "fl":"*,score", + "":{"v":0} + }, + "facets":{ + "facet":"on", + "facet.mincount": "1", + "":{"v":0} + }, + "velocity":{ + "wt": "velocity", + "v.template":"browse", + "v.layout": "layout", + "":{"v":0} + } +}} diff --git a/resources/cache/empty/similarity/conf/protwords.txt b/resources/cache/empty/similarity/conf/protwords.txt index 5a32e503..1dfc0abe 100644 --- a/resources/cache/empty/similarity/conf/protwords.txt +++ b/resources/cache/empty/similarity/conf/protwords.txt @@ -1,21 +1,21 @@ -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#----------------------------------------------------------------------- -# Use a protected word file to protect against the stemmer reducing two -# unrelated words to the same base word. - -# Some non-words that normally won't be encountered, -# just to test that they won't be stemmed. -dontstems -zwhacky - +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#----------------------------------------------------------------------- +# Use a protected word file to protect against the stemmer reducing two +# unrelated words to the same base word. + +# Some non-words that normally won't be encountered, +# just to test that they won't be stemmed. +dontstems +zwhacky + diff --git a/resources/cache/empty/similarity/conf/schema.xml b/resources/cache/empty/similarity/conf/schema.xml index 48457421..0dd96fca 100644 --- a/resources/cache/empty/similarity/conf/schema.xml +++ b/resources/cache/empty/similarity/conf/schema.xml @@ -1,240 +1,240 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - id - - id - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id + + id + + + diff --git a/resources/cache/empty/similarity/conf/solrconfig.xml b/resources/cache/empty/similarity/conf/solrconfig.xml index 7e8babdf..a99f9628 100644 --- a/resources/cache/empty/similarity/conf/solrconfig.xml +++ b/resources/cache/empty/similarity/conf/solrconfig.xml @@ -1,1949 +1,1949 @@ - - - - - - - - - 4.10.4 - - - - - - - - - - - - - - - - - - - - - - ${solr.data.dir:} - - - - - - - - - ${solr.hdfs.home:} - - ${solr.hdfs.confdir:} - - ${solr.hdfs.blockcache.enabled:true} - - ${solr.hdfs.blockcache.global:true} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${solr.lock.type:native} - - - - - - - - - - - - - - - - - - - - - - true - - - false - - - - - - - - - - - - - - - - ${solr.ulog.dir:} - - - - - ${solr.autoCommit.maxTime:15000} - false - - - - - - ${solr.autoSoftCommit.maxTime:-1} - - - - - - - - - - - - - - - - - - 1024 - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - 20 - - - 200 - - - - - - - - - - - - static firstSearcher warming in solrconfig.xml - - - - - - false - - - 2 - - - - - - - - - - - - - - - - - - - - - - - explicit - 10 - text - - - - - - - - - - on - content features title name - true - html - <b> - </b> - 0 - title - - 3 - 200 - content - 750 - - - on - false - 5 - 2 - 5 - true - true - 5 - 3 - - - - - - explicit - json - true - text - - - - - - - - true - json - true - - - - - - - - {!xport} - xsort - false - - - - query - - - - - - - - - - - - explicit - - - velocity - browse - layout - Solritas - - - edismax - - text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 - title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0 - - text - 100% - *:* - 10 - *,score - - - text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 - title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0 - - text,features,name,sku,id,manu,cat,title,description,keywords,author,resourcename - 3 - - - on - true - cat - person - location - organisations - ipod - GB - 1 - cat,inStock - after - price - 0 - 600 - 50 - popularity - 0 - 10 - 3 - manufacturedate_dt - NOW/YEAR-10YEARS - NOW - +1YEAR - before - after - - - on - content features title name - true - html - <b> - </b> - 0 - title - - 3 - 200 - content - 750 - - - on - false - 5 - 2 - 5 - true - true - 5 - 3 - - - - - spellcheck - - - - - - - - - - - - - - - - last_modified - true - - ignored_ - - - true - links - jate_text_field - true - ignored_ - - - langid - - - - - - yyyy-MM-dd hh:mm:ss - - - - - - - - - - - - - - - - - - - - - - solrpingquery - - - all - - - - - - - - - explicit - true - - - - - - - - - - - - - - - - text_general - - - - - - default - text - solr.DirectSolrSpellChecker - - internal - - 0.5 - - 2 - - 1 - - 5 - - 4 - - 0.01 - - - - - - wordbreak - solr.WordBreakSolrSpellChecker - name - true - true - 10 - - - - - - - - - - - - - - - - text - - default - wordbreak - on - true - 10 - 5 - 5 - true - true - 10 - 5 - - - spellcheck - - - - - - - - - - - - text - true - - - tvComponent - - - - - - - lingo - - - org.carrot2.clustering.lingo.LingoClusteringAlgorithm - - - clustering/carrot2 - - - - - stc - org.carrot2.clustering.stc.STCClusteringAlgorithm - - - - - kmeans - org.carrot2.clustering.kmeans.BisectingKMeansClusteringAlgorithm - - - - - - - true - true - - name - - id - - features - - true - - - - false - - - edismax - - text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 - - *:* - 10 - *,score - - - clustering - - - - - - - - - - true - false - - - terms - - - - - - - - string - elevate.xml - - - - - - explicit - text - - - elevator - - - - - - - - - - - 100 - - - - - - - - 70 - - 0.5 - - [-\w ,/\n\"']{20,200} - - - - - - - ]]> - ]]> - - - - - - - - - - - - - - - - - - - - - - - - ,, - ,, - ,, - ,, - ,]]> - ]]> - - - - - - 10 - .,!? - - - - - - - WORD - - - en - US - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/plain; charset=UTF-8 - - - - - - - - - 5 - - - - - - - - - - - - - - - - - - *:* - - - + + + + + + + + + 4.10.4 + + + + + + + + + + + + + + + + + + + + + + ${solr.data.dir:} + + + + + + + + + ${solr.hdfs.home:} + + ${solr.hdfs.confdir:} + + ${solr.hdfs.blockcache.enabled:true} + + ${solr.hdfs.blockcache.global:true} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${solr.lock.type:native} + + + + + + + + + + + + + + + + + + + + + + true + + + false + + + + + + + + + + + + + + + + ${solr.ulog.dir:} + + + + + ${solr.autoCommit.maxTime:15000} + false + + + + + + ${solr.autoSoftCommit.maxTime:-1} + + + + + + + + + + + + + + + + + + 1024 + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + 20 + + + 200 + + + + + + + + + + + + static firstSearcher warming in solrconfig.xml + + + + + + false + + + 2 + + + + + + + + + + + + + + + + + + + + + + + explicit + 10 + text + + + + + + + + + + on + content features title name + true + html + <b> + </b> + 0 + title + + 3 + 200 + content + 750 + + + on + false + 5 + 2 + 5 + true + true + 5 + 3 + + + + + + explicit + json + true + text + + + + + + + + true + json + true + + + + + + + + {!xport} + xsort + false + + + + query + + + + + + + + + + + + explicit + + + velocity + browse + layout + Solritas + + + edismax + + text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 + title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0 + + text + 100% + *:* + 10 + *,score + + + text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 + title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0 + + text,features,name,sku,id,manu,cat,title,description,keywords,author,resourcename + 3 + + + on + true + cat + person + location + organisations + ipod + GB + 1 + cat,inStock + after + price + 0 + 600 + 50 + popularity + 0 + 10 + 3 + manufacturedate_dt + NOW/YEAR-10YEARS + NOW + +1YEAR + before + after + + + on + content features title name + true + html + <b> + </b> + 0 + title + + 3 + 200 + content + 750 + + + on + false + 5 + 2 + 5 + true + true + 5 + 3 + + + + + spellcheck + + + + + + + + + + + + + + + + last_modified + true + + ignored_ + + + true + links + jate_text_field + true + ignored_ + + + langid + + + + + + yyyy-MM-dd hh:mm:ss + + + + + + + + + + + + + + + + + + + + + + solrpingquery + + + all + + + + + + + + + explicit + true + + + + + + + + + + + + + + + + text_general + + + + + + default + text + solr.DirectSolrSpellChecker + + internal + + 0.5 + + 2 + + 1 + + 5 + + 4 + + 0.01 + + + + + + wordbreak + solr.WordBreakSolrSpellChecker + name + true + true + 10 + + + + + + + + + + + + + + + + text + + default + wordbreak + on + true + 10 + 5 + 5 + true + true + 10 + 5 + + + spellcheck + + + + + + + + + + + + text + true + + + tvComponent + + + + + + + lingo + + + org.carrot2.clustering.lingo.LingoClusteringAlgorithm + + + clustering/carrot2 + + + + + stc + org.carrot2.clustering.stc.STCClusteringAlgorithm + + + + + kmeans + org.carrot2.clustering.kmeans.BisectingKMeansClusteringAlgorithm + + + + + + + true + true + + name + + id + + features + + true + + + + false + + + edismax + + text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 + + *:* + 10 + *,score + + + clustering + + + + + + + + + + true + false + + + terms + + + + + + + + string + elevate.xml + + + + + + explicit + text + + + elevator + + + + + + + + + + + 100 + + + + + + + + 70 + + 0.5 + + [-\w ,/\n\"']{20,200} + + + + + + + ]]> + ]]> + + + + + + + + + + + + + + + + + + + + + + + + ,, + ,, + ,, + ,, + ,]]> + ]]> + + + + + + 10 + .,!? + + + + + + + WORD + + + en + US + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/plain; charset=UTF-8 + + + + + + + + + 5 + + + + + + + + + + + + + + + + + + *:* + + + diff --git a/resources/cache/empty/similarity/conf/stopwords.txt b/resources/cache/empty/similarity/conf/stopwords.txt index e525ab80..dacec479 100644 --- a/resources/cache/empty/similarity/conf/stopwords.txt +++ b/resources/cache/empty/similarity/conf/stopwords.txt @@ -1,188 +1,188 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -a -about -above -after -again -against -all -am -an -and -any -are -aren't -as -at -be -because -been -before -being -below -between -both -but -by -can't -cannot -could -couldn't -did -didn't -do -does -doesn't -doing -don't -down -during -each -few -for -from -further -had -hadn't -has -hasn't -have -haven't -having -he -he'd -he'll -he's -her -here -here's -hers -herself -him -himself -his -how -how's -i -i'd -i'll -i'm -i've -if -in -into -is -isn't -it -it's -its -itself -let's -me -more -most -mustn't -my -myself -no -nor -not -of -off -on -once -only -or -other -ought -our -ours -ourselves -out -over -own -same -shan't -she -she'd -she'll -she's -should -shouldn't -so -some -such -than -that -that's -the -their -theirs -them -themselves -then -there -there's -these -they -they'd -they'll -they're -they've -this -those -through -to -too -under -until -up -very -was -wasn't -we -we'd -we'll -we're -we've -were -weren't -what -what's -when -when's -where -where's -which -while -who -who's -whom -why -why's -with -won't -would -wouldn't -you -you'd -you'll -you're -you've -your -yours -yourself +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +a +about +above +after +again +against +all +am +an +and +any +are +aren't +as +at +be +because +been +before +being +below +between +both +but +by +can't +cannot +could +couldn't +did +didn't +do +does +doesn't +doing +don't +down +during +each +few +for +from +further +had +hadn't +has +hasn't +have +haven't +having +he +he'd +he'll +he's +her +here +here's +hers +herself +him +himself +his +how +how's +i +i'd +i'll +i'm +i've +if +in +into +is +isn't +it +it's +its +itself +let's +me +more +most +mustn't +my +myself +no +nor +not +of +off +on +once +only +or +other +ought +our +ours +ourselves +out +over +own +same +shan't +she +she'd +she'll +she's +should +shouldn't +so +some +such +than +that +that's +the +their +theirs +them +themselves +then +there +there's +these +they +they'd +they'll +they're +they've +this +those +through +to +too +under +until +up +very +was +wasn't +we +we'd +we'll +we're +we've +were +weren't +what +what's +when +when's +where +where's +which +while +who +who's +whom +why +why's +with +won't +would +wouldn't +you +you'd +you'll +you're +you've +your +yours +yourself yourselves \ No newline at end of file diff --git a/resources/cache/empty/similarity/conf/synonyms.txt b/resources/cache/empty/similarity/conf/synonyms.txt index f00294b0..7f721283 100644 --- a/resources/cache/empty/similarity/conf/synonyms.txt +++ b/resources/cache/empty/similarity/conf/synonyms.txt @@ -1,29 +1,29 @@ -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#----------------------------------------------------------------------- -#some test synonym mappings unlikely to appear in real input text -aaafoo => aaabar -bbbfoo => bbbfoo bbbbar -cccfoo => cccbar cccbaz -fooaaa,baraaa,bazaaa - -# Some synonym groups specific to this example -GB,gib,gigabyte,gigabytes -MB,mib,megabyte,megabytes -Television, Televisions, TV, TVs -#notice we use "gib" instead of "GiB" so any WordDelimiterFilter coming -#after us won't split it into two words. - -# Synonym mappings can be used for spelling correction too -pixima => pixma - +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#----------------------------------------------------------------------- +#some test synonym mappings unlikely to appear in real input text +aaafoo => aaabar +bbbfoo => bbbfoo bbbbar +cccfoo => cccbar cccbaz +fooaaa,baraaa,bazaaa + +# Some synonym groups specific to this example +GB,gib,gigabyte,gigabytes +MB,mib,megabyte,megabytes +Television, Televisions, TV, TVs +#notice we use "gib" instead of "GiB" so any WordDelimiterFilter coming +#after us won't split it into two words. + +# Synonym mappings can be used for spelling correction too +pixima => pixma + diff --git a/resources/cache/empty/similarity/core.properties b/resources/cache/empty/similarity/core.properties index 89b2056a..04dc5854 100644 --- a/resources/cache/empty/similarity/core.properties +++ b/resources/cache/empty/similarity/core.properties @@ -1,3 +1,3 @@ -#Written by CorePropertiesLocator -#Mon Sep 14 10:05:54 UTC 2015 -name=similarity +#Written by CorePropertiesLocator +#Mon Sep 14 10:05:54 UTC 2015 +name=similarity diff --git a/resources/cache/empty/solr.xml b/resources/cache/empty/solr.xml index d547c09b..8bff33f8 100644 --- a/resources/cache/empty/solr.xml +++ b/resources/cache/empty/solr.xml @@ -1 +1 @@ - + diff --git a/resources/cache/empty/websearch/conf/currency.xml b/resources/cache/empty/websearch/conf/currency.xml index 5c6cfaf0..3a9c58af 100644 --- a/resources/cache/empty/websearch/conf/currency.xml +++ b/resources/cache/empty/websearch/conf/currency.xml @@ -1,67 +1,67 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/cache/empty/websearch/conf/elevate.xml b/resources/cache/empty/websearch/conf/elevate.xml index e4769ccf..25d5cebe 100644 --- a/resources/cache/empty/websearch/conf/elevate.xml +++ b/resources/cache/empty/websearch/conf/elevate.xml @@ -1,38 +1,38 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/resources/cache/empty/websearch/conf/lang/contractions_ca.txt b/resources/cache/empty/websearch/conf/lang/contractions_ca.txt index 116644f2..307a85f9 100644 --- a/resources/cache/empty/websearch/conf/lang/contractions_ca.txt +++ b/resources/cache/empty/websearch/conf/lang/contractions_ca.txt @@ -1,8 +1,8 @@ -# Set of Catalan contractions for ElisionFilter -# TODO: load this as a resource from the analyzer and sync it in build.xml -d -l -m -n -s -t +# Set of Catalan contractions for ElisionFilter +# TODO: load this as a resource from the analyzer and sync it in build.xml +d +l +m +n +s +t diff --git a/resources/cache/empty/websearch/conf/lang/contractions_fr.txt b/resources/cache/empty/websearch/conf/lang/contractions_fr.txt index 6de73c27..f1bba51b 100644 --- a/resources/cache/empty/websearch/conf/lang/contractions_fr.txt +++ b/resources/cache/empty/websearch/conf/lang/contractions_fr.txt @@ -1,15 +1,15 @@ -# Set of French contractions for ElisionFilter -# TODO: load this as a resource from the analyzer and sync it in build.xml -l -m -t -qu -n -s -j -d -c -jusqu -quoiqu -lorsqu -puisqu +# Set of French contractions for ElisionFilter +# TODO: load this as a resource from the analyzer and sync it in build.xml +l +m +t +qu +n +s +j +d +c +jusqu +quoiqu +lorsqu +puisqu diff --git a/resources/cache/empty/websearch/conf/lang/contractions_ga.txt b/resources/cache/empty/websearch/conf/lang/contractions_ga.txt index 849b0c6e..9ebe7fa3 100644 --- a/resources/cache/empty/websearch/conf/lang/contractions_ga.txt +++ b/resources/cache/empty/websearch/conf/lang/contractions_ga.txt @@ -1,5 +1,5 @@ -# Set of Irish contractions for ElisionFilter -# TODO: load this as a resource from the analyzer and sync it in build.xml -d -m -b +# Set of Irish contractions for ElisionFilter +# TODO: load this as a resource from the analyzer and sync it in build.xml +d +m +b diff --git a/resources/cache/empty/websearch/conf/lang/contractions_it.txt b/resources/cache/empty/websearch/conf/lang/contractions_it.txt index 790b5af4..cac04095 100644 --- a/resources/cache/empty/websearch/conf/lang/contractions_it.txt +++ b/resources/cache/empty/websearch/conf/lang/contractions_it.txt @@ -1,23 +1,23 @@ -# Set of Italian contractions for ElisionFilter -# TODO: load this as a resource from the analyzer and sync it in build.xml -c -l -all -dall -dell -nell -sull -coll -pell -gl -agl -dagl -degl -negl -sugl -un -m -t -s -v -d +# Set of Italian contractions for ElisionFilter +# TODO: load this as a resource from the analyzer and sync it in build.xml +c +l +all +dall +dell +nell +sull +coll +pell +gl +agl +dagl +degl +negl +sugl +un +m +t +s +v +d diff --git a/resources/cache/empty/websearch/conf/lang/hyphenations_ga.txt b/resources/cache/empty/websearch/conf/lang/hyphenations_ga.txt index fce41006..4d2642cc 100644 --- a/resources/cache/empty/websearch/conf/lang/hyphenations_ga.txt +++ b/resources/cache/empty/websearch/conf/lang/hyphenations_ga.txt @@ -1,5 +1,5 @@ -# Set of Irish hyphenations for StopFilter -# TODO: load this as a resource from the analyzer and sync it in build.xml -h -n -t +# Set of Irish hyphenations for StopFilter +# TODO: load this as a resource from the analyzer and sync it in build.xml +h +n +t diff --git a/resources/cache/empty/websearch/conf/lang/stemdict_nl.txt b/resources/cache/empty/websearch/conf/lang/stemdict_nl.txt index 01dd3bb8..44107297 100644 --- a/resources/cache/empty/websearch/conf/lang/stemdict_nl.txt +++ b/resources/cache/empty/websearch/conf/lang/stemdict_nl.txt @@ -1,6 +1,6 @@ -# Set of overrides for the dutch stemmer -# TODO: load this as a resource from the analyzer and sync it in build.xml -fiets fiets -bromfiets bromfiets -ei eier -kind kinder +# Set of overrides for the dutch stemmer +# TODO: load this as a resource from the analyzer and sync it in build.xml +fiets fiets +bromfiets bromfiets +ei eier +kind kinder diff --git a/resources/cache/empty/websearch/conf/lang/stoptags_ja.txt b/resources/cache/empty/websearch/conf/lang/stoptags_ja.txt index 2faf2a68..71b75084 100644 --- a/resources/cache/empty/websearch/conf/lang/stoptags_ja.txt +++ b/resources/cache/empty/websearch/conf/lang/stoptags_ja.txt @@ -1,420 +1,420 @@ -# -# This file defines a Japanese stoptag set for JapanesePartOfSpeechStopFilter. -# -# Any token with a part-of-speech tag that exactly matches those defined in this -# file are removed from the token stream. -# -# Set your own stoptags by uncommenting the lines below. Note that comments are -# not allowed on the same line as a stoptag. See LUCENE-3745 for frequency lists, -# etc. that can be useful for building you own stoptag set. -# -# The entire possible tagset is provided below for convenience. -# -##### -# noun: unclassified nouns -#名詞 -# -# noun-common: Common nouns or nouns where the sub-classification is undefined -#名詞-一般 -# -# noun-proper: Proper nouns where the sub-classification is undefined -#名詞-固有名詞 -# -# noun-proper-misc: miscellaneous proper nouns -#名詞-固有名詞-一般 -# -# noun-proper-person: Personal names where the sub-classification is undefined -#名詞-固有名詞-人名 -# -# noun-proper-person-misc: names that cannot be divided into surname and -# given name; foreign names; names where the surname or given name is unknown. -# e.g. お市の方 -#名詞-固有名詞-人名-一般 -# -# noun-proper-person-surname: Mainly Japanese surnames. -# e.g. 山田 -#名詞-固有名詞-人名-姓 -# -# noun-proper-person-given_name: Mainly Japanese given names. -# e.g. 太郎 -#名詞-固有名詞-人名-名 -# -# noun-proper-organization: Names representing organizations. -# e.g. 通産省, NHK -#名詞-固有名詞-組織 -# -# noun-proper-place: Place names where the sub-classification is undefined -#名詞-固有名詞-地域 -# -# noun-proper-place-misc: Place names excluding countries. -# e.g. アジア, バルセロナ, 京都 -#名詞-固有名詞-地域-一般 -# -# noun-proper-place-country: Country names. -# e.g. 日本, オーストラリア -#名詞-固有名詞-地域-国 -# -# noun-pronoun: Pronouns where the sub-classification is undefined -#名詞-代名詞 -# -# noun-pronoun-misc: miscellaneous pronouns: -# e.g. それ, ここ, あいつ, あなた, あちこち, いくつ, どこか, なに, みなさん, みんな, わたくし, われわれ -#名詞-代名詞-一般 -# -# noun-pronoun-contraction: Spoken language contraction made by combining a -# pronoun and the particle 'wa'. -# e.g. ありゃ, こりゃ, こりゃあ, そりゃ, そりゃあ -#名詞-代名詞-縮約 -# -# noun-adverbial: Temporal nouns such as names of days or months that behave -# like adverbs. Nouns that represent amount or ratios and can be used adverbially, -# e.g. 金曜, 一月, 午後, 少量 -#名詞-副詞可能 -# -# noun-verbal: Nouns that take arguments with case and can appear followed by -# 'suru' and related verbs (する, できる, なさる, くださる) -# e.g. インプット, 愛着, 悪化, 悪戦苦闘, 一安心, 下取り -#名詞-サ変接続 -# -# noun-adjective-base: The base form of adjectives, words that appear before な ("na") -# e.g. 健康, 安易, 駄目, だめ -#名詞-形容動詞語幹 -# -# noun-numeric: Arabic numbers, Chinese numerals, and counters like 何 (回), 数. -# e.g. 0, 1, 2, 何, 数, 幾 -#名詞-数 -# -# noun-affix: noun affixes where the sub-classification is undefined -#名詞-非自立 -# -# noun-affix-misc: Of adnominalizers, the case-marker の ("no"), and words that -# attach to the base form of inflectional words, words that cannot be classified -# into any of the other categories below. This category includes indefinite nouns. -# e.g. あかつき, 暁, かい, 甲斐, 気, きらい, 嫌い, くせ, 癖, こと, 事, ごと, 毎, しだい, 次第, -# 順, せい, 所為, ついで, 序で, つもり, 積もり, 点, どころ, の, はず, 筈, はずみ, 弾み, -# 拍子, ふう, ふり, 振り, ほう, 方, 旨, もの, 物, 者, ゆえ, 故, ゆえん, 所以, わけ, 訳, -# わり, 割り, 割, ん-口語/, もん-口語/ -#名詞-非自立-一般 -# -# noun-affix-adverbial: noun affixes that that can behave as adverbs. -# e.g. あいだ, 間, あげく, 挙げ句, あと, 後, 余り, 以外, 以降, 以後, 以上, 以前, 一方, うえ, -# 上, うち, 内, おり, 折り, かぎり, 限り, きり, っきり, 結果, ころ, 頃, さい, 際, 最中, さなか, -# 最中, じたい, 自体, たび, 度, ため, 為, つど, 都度, とおり, 通り, とき, 時, ところ, 所, -# とたん, 途端, なか, 中, のち, 後, ばあい, 場合, 日, ぶん, 分, ほか, 他, まえ, 前, まま, -# 儘, 侭, みぎり, 矢先 -#名詞-非自立-副詞可能 -# -# noun-affix-aux: noun affixes treated as 助動詞 ("auxiliary verb") in school grammars -# with the stem よう(だ) ("you(da)"). -# e.g. よう, やう, 様 (よう) -#名詞-非自立-助動詞語幹 -# -# noun-affix-adjective-base: noun affixes that can connect to the indeclinable -# connection form な (aux "da"). -# e.g. みたい, ふう -#名詞-非自立-形容動詞語幹 -# -# noun-special: special nouns where the sub-classification is undefined. -#名詞-特殊 -# -# noun-special-aux: The そうだ ("souda") stem form that is used for reporting news, is -# treated as 助動詞 ("auxiliary verb") in school grammars, and attach to the base -# form of inflectional words. -# e.g. そう -#名詞-特殊-助動詞語幹 -# -# noun-suffix: noun suffixes where the sub-classification is undefined. -#名詞-接尾 -# -# noun-suffix-misc: Of the nouns or stem forms of other parts of speech that connect -# to ガル or タイ and can combine into compound nouns, words that cannot be classified into -# any of the other categories below. In general, this category is more inclusive than -# 接尾語 ("suffix") and is usually the last element in a compound noun. -# e.g. おき, かた, 方, 甲斐 (がい), がかり, ぎみ, 気味, ぐるみ, (~した) さ, 次第, 済 (ず) み, -# よう, (でき)っこ, 感, 観, 性, 学, 類, 面, 用 -#名詞-接尾-一般 -# -# noun-suffix-person: Suffixes that form nouns and attach to person names more often -# than other nouns. -# e.g. 君, 様, 著 -#名詞-接尾-人名 -# -# noun-suffix-place: Suffixes that form nouns and attach to place names more often -# than other nouns. -# e.g. 町, 市, 県 -#名詞-接尾-地域 -# -# noun-suffix-verbal: Of the suffixes that attach to nouns and form nouns, those that -# can appear before スル ("suru"). -# e.g. 化, 視, 分け, 入り, 落ち, 買い -#名詞-接尾-サ変接続 -# -# noun-suffix-aux: The stem form of そうだ (様態) that is used to indicate conditions, -# is treated as 助動詞 ("auxiliary verb") in school grammars, and attach to the -# conjunctive form of inflectional words. -# e.g. そう -#名詞-接尾-助動詞語幹 -# -# noun-suffix-adjective-base: Suffixes that attach to other nouns or the conjunctive -# form of inflectional words and appear before the copula だ ("da"). -# e.g. 的, げ, がち -#名詞-接尾-形容動詞語幹 -# -# noun-suffix-adverbial: Suffixes that attach to other nouns and can behave as adverbs. -# e.g. 後 (ご), 以後, 以降, 以前, 前後, 中, 末, 上, 時 (じ) -#名詞-接尾-副詞可能 -# -# noun-suffix-classifier: Suffixes that attach to numbers and form nouns. This category -# is more inclusive than 助数詞 ("classifier") and includes common nouns that attach -# to numbers. -# e.g. 個, つ, 本, 冊, パーセント, cm, kg, カ月, か国, 区画, 時間, 時半 -#名詞-接尾-助数詞 -# -# noun-suffix-special: Special suffixes that mainly attach to inflecting words. -# e.g. (楽し) さ, (考え) 方 -#名詞-接尾-特殊 -# -# noun-suffix-conjunctive: Nouns that behave like conjunctions and join two words -# together. -# e.g. (日本) 対 (アメリカ), 対 (アメリカ), (3) 対 (5), (女優) 兼 (主婦) -#名詞-接続詞的 -# -# noun-verbal_aux: Nouns that attach to the conjunctive particle て ("te") and are -# semantically verb-like. -# e.g. ごらん, ご覧, 御覧, 頂戴 -#名詞-動詞非自立的 -# -# noun-quotation: text that cannot be segmented into words, proverbs, Chinese poetry, -# dialects, English, etc. Currently, the only entry for 名詞 引用文字列 ("noun quotation") -# is いわく ("iwaku"). -#名詞-引用文字列 -# -# noun-nai_adjective: Words that appear before the auxiliary verb ない ("nai") and -# behave like an adjective. -# e.g. 申し訳, 仕方, とんでも, 違い -#名詞-ナイ形容詞語幹 -# -##### -# prefix: unclassified prefixes -#接頭詞 -# -# prefix-nominal: Prefixes that attach to nouns (including adjective stem forms) -# excluding numerical expressions. -# e.g. お (水), 某 (氏), 同 (社), 故 (~氏), 高 (品質), お (見事), ご (立派) -#接頭詞-名詞接続 -# -# prefix-verbal: Prefixes that attach to the imperative form of a verb or a verb -# in conjunctive form followed by なる/なさる/くださる. -# e.g. お (読みなさい), お (座り) -#接頭詞-動詞接続 -# -# prefix-adjectival: Prefixes that attach to adjectives. -# e.g. お (寒いですねえ), バカ (でかい) -#接頭詞-形容詞接続 -# -# prefix-numerical: Prefixes that attach to numerical expressions. -# e.g. 約, およそ, 毎時 -#接頭詞-数接続 -# -##### -# verb: unclassified verbs -#動詞 -# -# verb-main: -#動詞-自立 -# -# verb-auxiliary: -#動詞-非自立 -# -# verb-suffix: -#動詞-接尾 -# -##### -# adjective: unclassified adjectives -#形容詞 -# -# adjective-main: -#形容詞-自立 -# -# adjective-auxiliary: -#形容詞-非自立 -# -# adjective-suffix: -#形容詞-接尾 -# -##### -# adverb: unclassified adverbs -#副詞 -# -# adverb-misc: Words that can be segmented into one unit and where adnominal -# modification is not possible. -# e.g. あいかわらず, 多分 -#副詞-一般 -# -# adverb-particle_conjunction: Adverbs that can be followed by の, は, に, -# な, する, だ, etc. -# e.g. こんなに, そんなに, あんなに, なにか, なんでも -#副詞-助詞類接続 -# -##### -# adnominal: Words that only have noun-modifying forms. -# e.g. この, その, あの, どの, いわゆる, なんらかの, 何らかの, いろんな, こういう, そういう, ああいう, -# どういう, こんな, そんな, あんな, どんな, 大きな, 小さな, おかしな, ほんの, たいした, -# 「(, も) さる (ことながら)」, 微々たる, 堂々たる, 単なる, いかなる, 我が」「同じ, 亡き -#連体詞 -# -##### -# conjunction: Conjunctions that can occur independently. -# e.g. が, けれども, そして, じゃあ, それどころか -接続詞 -# -##### -# particle: unclassified particles. -助詞 -# -# particle-case: case particles where the subclassification is undefined. -助詞-格助詞 -# -# particle-case-misc: Case particles. -# e.g. から, が, で, と, に, へ, より, を, の, にて -助詞-格助詞-一般 -# -# particle-case-quote: the "to" that appears after nouns, a person’s speech, -# quotation marks, expressions of decisions from a meeting, reasons, judgements, -# conjectures, etc. -# e.g. ( だ) と (述べた.), ( である) と (して執行猶予...) -助詞-格助詞-引用 -# -# particle-case-compound: Compounds of particles and verbs that mainly behave -# like case particles. -# e.g. という, といった, とかいう, として, とともに, と共に, でもって, にあたって, に当たって, に当って, -# にあたり, に当たり, に当り, に当たる, にあたる, において, に於いて,に於て, における, に於ける, -# にかけ, にかけて, にかんし, に関し, にかんして, に関して, にかんする, に関する, に際し, -# に際して, にしたがい, に従い, に従う, にしたがって, に従って, にたいし, に対し, にたいして, -# に対して, にたいする, に対する, について, につき, につけ, につけて, につれ, につれて, にとって, -# にとり, にまつわる, によって, に依って, に因って, により, に依り, に因り, による, に依る, に因る, -# にわたって, にわたる, をもって, を以って, を通じ, を通じて, を通して, をめぐって, をめぐり, をめぐる, -# って-口語/, ちゅう-関西弁「という」/, (何) ていう (人)-口語/, っていう-口語/, といふ, とかいふ -助詞-格助詞-連語 -# -# particle-conjunctive: -# e.g. から, からには, が, けれど, けれども, けど, し, つつ, て, で, と, ところが, どころか, とも, ども, -# ながら, なり, ので, のに, ば, ものの, や ( した), やいなや, (ころん) じゃ(いけない)-口語/, -# (行っ) ちゃ(いけない)-口語/, (言っ) たって (しかたがない)-口語/, (それがなく)ったって (平気)-口語/ -助詞-接続助詞 -# -# particle-dependency: -# e.g. こそ, さえ, しか, すら, は, も, ぞ -助詞-係助詞 -# -# particle-adverbial: -# e.g. がてら, かも, くらい, 位, ぐらい, しも, (学校) じゃ(これが流行っている)-口語/, -# (それ)じゃあ (よくない)-口語/, ずつ, (私) なぞ, など, (私) なり (に), (先生) なんか (大嫌い)-口語/, -# (私) なんぞ, (先生) なんて (大嫌い)-口語/, のみ, だけ, (私) だって-口語/, だに, -# (彼)ったら-口語/, (お茶) でも (いかが), 等 (とう), (今後) とも, ばかり, ばっか-口語/, ばっかり-口語/, -# ほど, 程, まで, 迄, (誰) も (が)([助詞-格助詞] および [助詞-係助詞] の前に位置する「も」) -助詞-副助詞 -# -# particle-interjective: particles with interjective grammatical roles. -# e.g. (松島) や -助詞-間投助詞 -# -# particle-coordinate: -# e.g. と, たり, だの, だり, とか, なり, や, やら -助詞-並立助詞 -# -# particle-final: -# e.g. かい, かしら, さ, ぜ, (だ)っけ-口語/, (とまってる) で-方言/, な, ナ, なあ-口語/, ぞ, ね, ネ, -# ねぇ-口語/, ねえ-口語/, ねん-方言/, の, のう-口語/, や, よ, ヨ, よぉ-口語/, わ, わい-口語/ -助詞-終助詞 -# -# particle-adverbial/conjunctive/final: The particle "ka" when unknown whether it is -# adverbial, conjunctive, or sentence final. For example: -# (a) 「A か B か」. Ex:「(国内で運用する) か,(海外で運用する) か (.)」 -# (b) Inside an adverb phrase. Ex:「(幸いという) か (, 死者はいなかった.)」 -# 「(祈りが届いたせい) か (, 試験に合格した.)」 -# (c) 「かのように」. Ex:「(何もなかった) か (のように振る舞った.)」 -# e.g. か -助詞-副助詞/並立助詞/終助詞 -# -# particle-adnominalizer: The "no" that attaches to nouns and modifies -# non-inflectional words. -助詞-連体化 -# -# particle-adnominalizer: The "ni" and "to" that appear following nouns and adverbs -# that are giongo, giseigo, or gitaigo. -# e.g. に, と -助詞-副詞化 -# -# particle-special: A particle that does not fit into one of the above classifications. -# This includes particles that are used in Tanka, Haiku, and other poetry. -# e.g. かな, けむ, ( しただろう) に, (あんた) にゃ(わからん), (俺) ん (家) -助詞-特殊 -# -##### -# auxiliary-verb: -助動詞 -# -##### -# interjection: Greetings and other exclamations. -# e.g. おはよう, おはようございます, こんにちは, こんばんは, ありがとう, どうもありがとう, ありがとうございます, -# いただきます, ごちそうさま, さよなら, さようなら, はい, いいえ, ごめん, ごめんなさい -#感動詞 -# -##### -# symbol: unclassified Symbols. -記号 -# -# symbol-misc: A general symbol not in one of the categories below. -# e.g. [○◎@$〒→+] -記号-一般 -# -# symbol-comma: Commas -# e.g. [,、] -記号-読点 -# -# symbol-period: Periods and full stops. -# e.g. [..。] -記号-句点 -# -# symbol-space: Full-width whitespace. -記号-空白 -# -# symbol-open_bracket: -# e.g. [({‘“『【] -記号-括弧開 -# -# symbol-close_bracket: -# e.g. [)}’”』」】] -記号-括弧閉 -# -# symbol-alphabetic: -#記号-アルファベット -# -##### -# other: unclassified other -#その他 -# -# other-interjection: Words that are hard to classify as noun-suffixes or -# sentence-final particles. -# e.g. (だ)ァ -その他-間投 -# -##### -# filler: Aizuchi that occurs during a conversation or sounds inserted as filler. -# e.g. あの, うんと, えと -フィラー -# -##### -# non-verbal: non-verbal sound. -非言語音 -# -##### -# fragment: -#語断片 -# -##### -# unknown: unknown part of speech. -#未知語 -# -##### End of file +# +# This file defines a Japanese stoptag set for JapanesePartOfSpeechStopFilter. +# +# Any token with a part-of-speech tag that exactly matches those defined in this +# file are removed from the token stream. +# +# Set your own stoptags by uncommenting the lines below. Note that comments are +# not allowed on the same line as a stoptag. See LUCENE-3745 for frequency lists, +# etc. that can be useful for building you own stoptag set. +# +# The entire possible tagset is provided below for convenience. +# +##### +# noun: unclassified nouns +#名詞 +# +# noun-common: Common nouns or nouns where the sub-classification is undefined +#名詞-一般 +# +# noun-proper: Proper nouns where the sub-classification is undefined +#名詞-固有名詞 +# +# noun-proper-misc: miscellaneous proper nouns +#名詞-固有名詞-一般 +# +# noun-proper-person: Personal names where the sub-classification is undefined +#名詞-固有名詞-人名 +# +# noun-proper-person-misc: names that cannot be divided into surname and +# given name; foreign names; names where the surname or given name is unknown. +# e.g. お市の方 +#名詞-固有名詞-人名-一般 +# +# noun-proper-person-surname: Mainly Japanese surnames. +# e.g. 山田 +#名詞-固有名詞-人名-姓 +# +# noun-proper-person-given_name: Mainly Japanese given names. +# e.g. 太郎 +#名詞-固有名詞-人名-名 +# +# noun-proper-organization: Names representing organizations. +# e.g. 通産省, NHK +#名詞-固有名詞-組織 +# +# noun-proper-place: Place names where the sub-classification is undefined +#名詞-固有名詞-地域 +# +# noun-proper-place-misc: Place names excluding countries. +# e.g. アジア, バルセロナ, 京都 +#名詞-固有名詞-地域-一般 +# +# noun-proper-place-country: Country names. +# e.g. 日本, オーストラリア +#名詞-固有名詞-地域-国 +# +# noun-pronoun: Pronouns where the sub-classification is undefined +#名詞-代名詞 +# +# noun-pronoun-misc: miscellaneous pronouns: +# e.g. それ, ここ, あいつ, あなた, あちこち, いくつ, どこか, なに, みなさん, みんな, わたくし, われわれ +#名詞-代名詞-一般 +# +# noun-pronoun-contraction: Spoken language contraction made by combining a +# pronoun and the particle 'wa'. +# e.g. ありゃ, こりゃ, こりゃあ, そりゃ, そりゃあ +#名詞-代名詞-縮約 +# +# noun-adverbial: Temporal nouns such as names of days or months that behave +# like adverbs. Nouns that represent amount or ratios and can be used adverbially, +# e.g. 金曜, 一月, 午後, 少量 +#名詞-副詞可能 +# +# noun-verbal: Nouns that take arguments with case and can appear followed by +# 'suru' and related verbs (する, できる, なさる, くださる) +# e.g. インプット, 愛着, 悪化, 悪戦苦闘, 一安心, 下取り +#名詞-サ変接続 +# +# noun-adjective-base: The base form of adjectives, words that appear before な ("na") +# e.g. 健康, 安易, 駄目, だめ +#名詞-形容動詞語幹 +# +# noun-numeric: Arabic numbers, Chinese numerals, and counters like 何 (回), 数. +# e.g. 0, 1, 2, 何, 数, 幾 +#名詞-数 +# +# noun-affix: noun affixes where the sub-classification is undefined +#名詞-非自立 +# +# noun-affix-misc: Of adnominalizers, the case-marker の ("no"), and words that +# attach to the base form of inflectional words, words that cannot be classified +# into any of the other categories below. This category includes indefinite nouns. +# e.g. あかつき, 暁, かい, 甲斐, 気, きらい, 嫌い, くせ, 癖, こと, 事, ごと, 毎, しだい, 次第, +# 順, せい, 所為, ついで, 序で, つもり, 積もり, 点, どころ, の, はず, 筈, はずみ, 弾み, +# 拍子, ふう, ふり, 振り, ほう, 方, 旨, もの, 物, 者, ゆえ, 故, ゆえん, 所以, わけ, 訳, +# わり, 割り, 割, ん-口語/, もん-口語/ +#名詞-非自立-一般 +# +# noun-affix-adverbial: noun affixes that that can behave as adverbs. +# e.g. あいだ, 間, あげく, 挙げ句, あと, 後, 余り, 以外, 以降, 以後, 以上, 以前, 一方, うえ, +# 上, うち, 内, おり, 折り, かぎり, 限り, きり, っきり, 結果, ころ, 頃, さい, 際, 最中, さなか, +# 最中, じたい, 自体, たび, 度, ため, 為, つど, 都度, とおり, 通り, とき, 時, ところ, 所, +# とたん, 途端, なか, 中, のち, 後, ばあい, 場合, 日, ぶん, 分, ほか, 他, まえ, 前, まま, +# 儘, 侭, みぎり, 矢先 +#名詞-非自立-副詞可能 +# +# noun-affix-aux: noun affixes treated as 助動詞 ("auxiliary verb") in school grammars +# with the stem よう(だ) ("you(da)"). +# e.g. よう, やう, 様 (よう) +#名詞-非自立-助動詞語幹 +# +# noun-affix-adjective-base: noun affixes that can connect to the indeclinable +# connection form な (aux "da"). +# e.g. みたい, ふう +#名詞-非自立-形容動詞語幹 +# +# noun-special: special nouns where the sub-classification is undefined. +#名詞-特殊 +# +# noun-special-aux: The そうだ ("souda") stem form that is used for reporting news, is +# treated as 助動詞 ("auxiliary verb") in school grammars, and attach to the base +# form of inflectional words. +# e.g. そう +#名詞-特殊-助動詞語幹 +# +# noun-suffix: noun suffixes where the sub-classification is undefined. +#名詞-接尾 +# +# noun-suffix-misc: Of the nouns or stem forms of other parts of speech that connect +# to ガル or タイ and can combine into compound nouns, words that cannot be classified into +# any of the other categories below. In general, this category is more inclusive than +# 接尾語 ("suffix") and is usually the last element in a compound noun. +# e.g. おき, かた, 方, 甲斐 (がい), がかり, ぎみ, 気味, ぐるみ, (~した) さ, 次第, 済 (ず) み, +# よう, (でき)っこ, 感, 観, 性, 学, 類, 面, 用 +#名詞-接尾-一般 +# +# noun-suffix-person: Suffixes that form nouns and attach to person names more often +# than other nouns. +# e.g. 君, 様, 著 +#名詞-接尾-人名 +# +# noun-suffix-place: Suffixes that form nouns and attach to place names more often +# than other nouns. +# e.g. 町, 市, 県 +#名詞-接尾-地域 +# +# noun-suffix-verbal: Of the suffixes that attach to nouns and form nouns, those that +# can appear before スル ("suru"). +# e.g. 化, 視, 分け, 入り, 落ち, 買い +#名詞-接尾-サ変接続 +# +# noun-suffix-aux: The stem form of そうだ (様態) that is used to indicate conditions, +# is treated as 助動詞 ("auxiliary verb") in school grammars, and attach to the +# conjunctive form of inflectional words. +# e.g. そう +#名詞-接尾-助動詞語幹 +# +# noun-suffix-adjective-base: Suffixes that attach to other nouns or the conjunctive +# form of inflectional words and appear before the copula だ ("da"). +# e.g. 的, げ, がち +#名詞-接尾-形容動詞語幹 +# +# noun-suffix-adverbial: Suffixes that attach to other nouns and can behave as adverbs. +# e.g. 後 (ご), 以後, 以降, 以前, 前後, 中, 末, 上, 時 (じ) +#名詞-接尾-副詞可能 +# +# noun-suffix-classifier: Suffixes that attach to numbers and form nouns. This category +# is more inclusive than 助数詞 ("classifier") and includes common nouns that attach +# to numbers. +# e.g. 個, つ, 本, 冊, パーセント, cm, kg, カ月, か国, 区画, 時間, 時半 +#名詞-接尾-助数詞 +# +# noun-suffix-special: Special suffixes that mainly attach to inflecting words. +# e.g. (楽し) さ, (考え) 方 +#名詞-接尾-特殊 +# +# noun-suffix-conjunctive: Nouns that behave like conjunctions and join two words +# together. +# e.g. (日本) 対 (アメリカ), 対 (アメリカ), (3) 対 (5), (女優) 兼 (主婦) +#名詞-接続詞的 +# +# noun-verbal_aux: Nouns that attach to the conjunctive particle て ("te") and are +# semantically verb-like. +# e.g. ごらん, ご覧, 御覧, 頂戴 +#名詞-動詞非自立的 +# +# noun-quotation: text that cannot be segmented into words, proverbs, Chinese poetry, +# dialects, English, etc. Currently, the only entry for 名詞 引用文字列 ("noun quotation") +# is いわく ("iwaku"). +#名詞-引用文字列 +# +# noun-nai_adjective: Words that appear before the auxiliary verb ない ("nai") and +# behave like an adjective. +# e.g. 申し訳, 仕方, とんでも, 違い +#名詞-ナイ形容詞語幹 +# +##### +# prefix: unclassified prefixes +#接頭詞 +# +# prefix-nominal: Prefixes that attach to nouns (including adjective stem forms) +# excluding numerical expressions. +# e.g. お (水), 某 (氏), 同 (社), 故 (~氏), 高 (品質), お (見事), ご (立派) +#接頭詞-名詞接続 +# +# prefix-verbal: Prefixes that attach to the imperative form of a verb or a verb +# in conjunctive form followed by なる/なさる/くださる. +# e.g. お (読みなさい), お (座り) +#接頭詞-動詞接続 +# +# prefix-adjectival: Prefixes that attach to adjectives. +# e.g. お (寒いですねえ), バカ (でかい) +#接頭詞-形容詞接続 +# +# prefix-numerical: Prefixes that attach to numerical expressions. +# e.g. 約, およそ, 毎時 +#接頭詞-数接続 +# +##### +# verb: unclassified verbs +#動詞 +# +# verb-main: +#動詞-自立 +# +# verb-auxiliary: +#動詞-非自立 +# +# verb-suffix: +#動詞-接尾 +# +##### +# adjective: unclassified adjectives +#形容詞 +# +# adjective-main: +#形容詞-自立 +# +# adjective-auxiliary: +#形容詞-非自立 +# +# adjective-suffix: +#形容詞-接尾 +# +##### +# adverb: unclassified adverbs +#副詞 +# +# adverb-misc: Words that can be segmented into one unit and where adnominal +# modification is not possible. +# e.g. あいかわらず, 多分 +#副詞-一般 +# +# adverb-particle_conjunction: Adverbs that can be followed by の, は, に, +# な, する, だ, etc. +# e.g. こんなに, そんなに, あんなに, なにか, なんでも +#副詞-助詞類接続 +# +##### +# adnominal: Words that only have noun-modifying forms. +# e.g. この, その, あの, どの, いわゆる, なんらかの, 何らかの, いろんな, こういう, そういう, ああいう, +# どういう, こんな, そんな, あんな, どんな, 大きな, 小さな, おかしな, ほんの, たいした, +# 「(, も) さる (ことながら)」, 微々たる, 堂々たる, 単なる, いかなる, 我が」「同じ, 亡き +#連体詞 +# +##### +# conjunction: Conjunctions that can occur independently. +# e.g. が, けれども, そして, じゃあ, それどころか +接続詞 +# +##### +# particle: unclassified particles. +助詞 +# +# particle-case: case particles where the subclassification is undefined. +助詞-格助詞 +# +# particle-case-misc: Case particles. +# e.g. から, が, で, と, に, へ, より, を, の, にて +助詞-格助詞-一般 +# +# particle-case-quote: the "to" that appears after nouns, a person’s speech, +# quotation marks, expressions of decisions from a meeting, reasons, judgements, +# conjectures, etc. +# e.g. ( だ) と (述べた.), ( である) と (して執行猶予...) +助詞-格助詞-引用 +# +# particle-case-compound: Compounds of particles and verbs that mainly behave +# like case particles. +# e.g. という, といった, とかいう, として, とともに, と共に, でもって, にあたって, に当たって, に当って, +# にあたり, に当たり, に当り, に当たる, にあたる, において, に於いて,に於て, における, に於ける, +# にかけ, にかけて, にかんし, に関し, にかんして, に関して, にかんする, に関する, に際し, +# に際して, にしたがい, に従い, に従う, にしたがって, に従って, にたいし, に対し, にたいして, +# に対して, にたいする, に対する, について, につき, につけ, につけて, につれ, につれて, にとって, +# にとり, にまつわる, によって, に依って, に因って, により, に依り, に因り, による, に依る, に因る, +# にわたって, にわたる, をもって, を以って, を通じ, を通じて, を通して, をめぐって, をめぐり, をめぐる, +# って-口語/, ちゅう-関西弁「という」/, (何) ていう (人)-口語/, っていう-口語/, といふ, とかいふ +助詞-格助詞-連語 +# +# particle-conjunctive: +# e.g. から, からには, が, けれど, けれども, けど, し, つつ, て, で, と, ところが, どころか, とも, ども, +# ながら, なり, ので, のに, ば, ものの, や ( した), やいなや, (ころん) じゃ(いけない)-口語/, +# (行っ) ちゃ(いけない)-口語/, (言っ) たって (しかたがない)-口語/, (それがなく)ったって (平気)-口語/ +助詞-接続助詞 +# +# particle-dependency: +# e.g. こそ, さえ, しか, すら, は, も, ぞ +助詞-係助詞 +# +# particle-adverbial: +# e.g. がてら, かも, くらい, 位, ぐらい, しも, (学校) じゃ(これが流行っている)-口語/, +# (それ)じゃあ (よくない)-口語/, ずつ, (私) なぞ, など, (私) なり (に), (先生) なんか (大嫌い)-口語/, +# (私) なんぞ, (先生) なんて (大嫌い)-口語/, のみ, だけ, (私) だって-口語/, だに, +# (彼)ったら-口語/, (お茶) でも (いかが), 等 (とう), (今後) とも, ばかり, ばっか-口語/, ばっかり-口語/, +# ほど, 程, まで, 迄, (誰) も (が)([助詞-格助詞] および [助詞-係助詞] の前に位置する「も」) +助詞-副助詞 +# +# particle-interjective: particles with interjective grammatical roles. +# e.g. (松島) や +助詞-間投助詞 +# +# particle-coordinate: +# e.g. と, たり, だの, だり, とか, なり, や, やら +助詞-並立助詞 +# +# particle-final: +# e.g. かい, かしら, さ, ぜ, (だ)っけ-口語/, (とまってる) で-方言/, な, ナ, なあ-口語/, ぞ, ね, ネ, +# ねぇ-口語/, ねえ-口語/, ねん-方言/, の, のう-口語/, や, よ, ヨ, よぉ-口語/, わ, わい-口語/ +助詞-終助詞 +# +# particle-adverbial/conjunctive/final: The particle "ka" when unknown whether it is +# adverbial, conjunctive, or sentence final. For example: +# (a) 「A か B か」. Ex:「(国内で運用する) か,(海外で運用する) か (.)」 +# (b) Inside an adverb phrase. Ex:「(幸いという) か (, 死者はいなかった.)」 +# 「(祈りが届いたせい) か (, 試験に合格した.)」 +# (c) 「かのように」. Ex:「(何もなかった) か (のように振る舞った.)」 +# e.g. か +助詞-副助詞/並立助詞/終助詞 +# +# particle-adnominalizer: The "no" that attaches to nouns and modifies +# non-inflectional words. +助詞-連体化 +# +# particle-adnominalizer: The "ni" and "to" that appear following nouns and adverbs +# that are giongo, giseigo, or gitaigo. +# e.g. に, と +助詞-副詞化 +# +# particle-special: A particle that does not fit into one of the above classifications. +# This includes particles that are used in Tanka, Haiku, and other poetry. +# e.g. かな, けむ, ( しただろう) に, (あんた) にゃ(わからん), (俺) ん (家) +助詞-特殊 +# +##### +# auxiliary-verb: +助動詞 +# +##### +# interjection: Greetings and other exclamations. +# e.g. おはよう, おはようございます, こんにちは, こんばんは, ありがとう, どうもありがとう, ありがとうございます, +# いただきます, ごちそうさま, さよなら, さようなら, はい, いいえ, ごめん, ごめんなさい +#感動詞 +# +##### +# symbol: unclassified Symbols. +記号 +# +# symbol-misc: A general symbol not in one of the categories below. +# e.g. [○◎@$〒→+] +記号-一般 +# +# symbol-comma: Commas +# e.g. [,、] +記号-読点 +# +# symbol-period: Periods and full stops. +# e.g. [..。] +記号-句点 +# +# symbol-space: Full-width whitespace. +記号-空白 +# +# symbol-open_bracket: +# e.g. [({‘“『【] +記号-括弧開 +# +# symbol-close_bracket: +# e.g. [)}’”』」】] +記号-括弧閉 +# +# symbol-alphabetic: +#記号-アルファベット +# +##### +# other: unclassified other +#その他 +# +# other-interjection: Words that are hard to classify as noun-suffixes or +# sentence-final particles. +# e.g. (だ)ァ +その他-間投 +# +##### +# filler: Aizuchi that occurs during a conversation or sounds inserted as filler. +# e.g. あの, うんと, えと +フィラー +# +##### +# non-verbal: non-verbal sound. +非言語音 +# +##### +# fragment: +#語断片 +# +##### +# unknown: unknown part of speech. +#未知語 +# +##### End of file diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_ar.txt b/resources/cache/empty/websearch/conf/lang/stopwords_ar.txt index aca24303..046829db 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_ar.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_ar.txt @@ -1,125 +1,125 @@ -# This file was created by Jacques Savoy and is distributed under the BSD license. -# See http://members.unine.ch/jacques.savoy/clef/index.html. -# Also see http://www.opensource.org/licenses/bsd-license.html -# Cleaned on October 11, 2009 (not normalized, so use before normalization) -# This means that when modifying this list, you might need to add some -# redundant entries, for example containing forms with both أ and ا -من -ومن -منها -منه -في -وفي -فيها -فيه -و -ف -ثم -او -أو -ب -بها -به -ا -أ -اى -اي -أي -أى -لا -ولا -الا -ألا -إلا -لكن -ما -وما -كما -فما -عن -مع -اذا -إذا -ان -أن -إن -انها -أنها -إنها -انه -أنه -إنه -بان -بأن -فان -فأن -وان -وأن -وإن -التى -التي -الذى -الذي -الذين -الى -الي -إلى -إلي -على -عليها -عليه -اما -أما -إما -ايضا -أيضا -كل -وكل -لم -ولم -لن -ولن -هى -هي -هو -وهى -وهي -وهو -فهى -فهي -فهو -انت -أنت -لك -لها -له -هذه -هذا -تلك -ذلك -هناك -كانت -كان -يكون -تكون -وكانت -وكان -غير -بعض -قد -نحو -بين -بينما -منذ -ضمن -حيث -الان -الآن -خلال -بعد -قبل -حتى -عند -عندما -لدى -جميع +# This file was created by Jacques Savoy and is distributed under the BSD license. +# See http://members.unine.ch/jacques.savoy/clef/index.html. +# Also see http://www.opensource.org/licenses/bsd-license.html +# Cleaned on October 11, 2009 (not normalized, so use before normalization) +# This means that when modifying this list, you might need to add some +# redundant entries, for example containing forms with both أ and ا +من +ومن +منها +منه +في +وفي +فيها +فيه +و +ف +ثم +او +أو +ب +بها +به +ا +أ +اى +اي +أي +أى +لا +ولا +الا +ألا +إلا +لكن +ما +وما +كما +فما +عن +مع +اذا +إذا +ان +أن +إن +انها +أنها +إنها +انه +أنه +إنه +بان +بأن +فان +فأن +وان +وأن +وإن +التى +التي +الذى +الذي +الذين +الى +الي +إلى +إلي +على +عليها +عليه +اما +أما +إما +ايضا +أيضا +كل +وكل +لم +ولم +لن +ولن +هى +هي +هو +وهى +وهي +وهو +فهى +فهي +فهو +انت +أنت +لك +لها +له +هذه +هذا +تلك +ذلك +هناك +كانت +كان +يكون +تكون +وكانت +وكان +غير +بعض +قد +نحو +بين +بينما +منذ +ضمن +حيث +الان +الآن +خلال +بعد +قبل +حتى +عند +عندما +لدى +جميع diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_bg.txt b/resources/cache/empty/websearch/conf/lang/stopwords_bg.txt index 842ee8a8..1ae4ba2a 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_bg.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_bg.txt @@ -1,193 +1,193 @@ -# This file was created by Jacques Savoy and is distributed under the BSD license. -# See http://members.unine.ch/jacques.savoy/clef/index.html. -# Also see http://www.opensource.org/licenses/bsd-license.html -а -аз -ако -ала -бе -без -беше -би -бил -била -били -било -близо -бъдат -бъде -бяха -в -вас -ваш -ваша -вероятно -вече -взема -ви -вие -винаги -все -всеки -всички -всичко -всяка -във -въпреки -върху -г -ги -главно -го -д -да -дали -до -докато -докога -дори -досега -доста -е -едва -един -ето -за -зад -заедно -заради -засега -затова -защо -защото -и -из -или -им -има -имат -иска -й -каза -как -каква -какво -както -какъв -като -кога -когато -което -които -кой -който -колко -която -къде -където -към -ли -м -ме -между -мен -ми -мнозина -мога -могат -може -моля -момента -му -н -на -над -назад -най -направи -напред -например -нас -не -него -нея -ни -ние -никой -нито -но -някои -някой -няма -обаче -около -освен -особено -от -отгоре -отново -още -пак -по -повече -повечето -под -поне -поради -после -почти -прави -пред -преди -през -при -пък -първо -с -са -само -се -сега -си -скоро -след -сме -според -сред -срещу -сте -съм -със -също -т -тази -така -такива -такъв -там -твой -те -тези -ти -тн -то -това -тогава -този -той -толкова -точно -трябва -тук -тъй -тя -тях -у -харесва -ч -че -често -чрез -ще -щом -я +# This file was created by Jacques Savoy and is distributed under the BSD license. +# See http://members.unine.ch/jacques.savoy/clef/index.html. +# Also see http://www.opensource.org/licenses/bsd-license.html +а +аз +ако +ала +бе +без +беше +би +бил +била +били +било +близо +бъдат +бъде +бяха +в +вас +ваш +ваша +вероятно +вече +взема +ви +вие +винаги +все +всеки +всички +всичко +всяка +във +въпреки +върху +г +ги +главно +го +д +да +дали +до +докато +докога +дори +досега +доста +е +едва +един +ето +за +зад +заедно +заради +засега +затова +защо +защото +и +из +или +им +има +имат +иска +й +каза +как +каква +какво +както +какъв +като +кога +когато +което +които +кой +който +колко +която +къде +където +към +ли +м +ме +между +мен +ми +мнозина +мога +могат +може +моля +момента +му +н +на +над +назад +най +направи +напред +например +нас +не +него +нея +ни +ние +никой +нито +но +някои +някой +няма +обаче +около +освен +особено +от +отгоре +отново +още +пак +по +повече +повечето +под +поне +поради +после +почти +прави +пред +преди +през +при +пък +първо +с +са +само +се +сега +си +скоро +след +сме +според +сред +срещу +сте +съм +със +също +т +тази +така +такива +такъв +там +твой +те +тези +ти +тн +то +това +тогава +този +той +толкова +точно +трябва +тук +тъй +тя +тях +у +харесва +ч +че +често +чрез +ще +щом +я diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_ca.txt b/resources/cache/empty/websearch/conf/lang/stopwords_ca.txt index e618af55..3da65dea 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_ca.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_ca.txt @@ -1,220 +1,220 @@ -# Catalan stopwords from http://github.com/vcl/cue.language (Apache 2 Licensed) -a -abans -ací -ah -així -això -al -als -aleshores -algun -alguna -algunes -alguns -alhora -allà -allí -allò -altra -altre -altres -amb -ambdós -ambdues -apa -aquell -aquella -aquelles -aquells -aquest -aquesta -aquestes -aquests -aquí -baix -cada -cadascú -cadascuna -cadascunes -cadascuns -com -contra -d'un -d'una -d'unes -d'uns -dalt -de -del -dels -des -després -dins -dintre -donat -doncs -durant -e -eh -el -els -em -en -encara -ens -entre -érem -eren -éreu -es -és -esta -està -estàvem -estaven -estàveu -esteu -et -etc -ets -fins -fora -gairebé -ha -han -has -havia -he -hem -heu -hi -ho -i -igual -iguals -ja -l'hi -la -les -li -li'n -llavors -m'he -ma -mal -malgrat -mateix -mateixa -mateixes -mateixos -me -mentre -més -meu -meus -meva -meves -molt -molta -moltes -molts -mon -mons -n'he -n'hi -ne -ni -no -nogensmenys -només -nosaltres -nostra -nostre -nostres -o -oh -oi -on -pas -pel -pels -per -però -perquè -poc -poca -pocs -poques -potser -propi -qual -quals -quan -quant -que -què -quelcom -qui -quin -quina -quines -quins -s'ha -s'han -sa -semblant -semblants -ses -seu -seus -seva -seva -seves -si -sobre -sobretot -sóc -solament -sols -son -són -sons -sota -sou -t'ha -t'han -t'he -ta -tal -també -tampoc -tan -tant -tanta -tantes -teu -teus -teva -teves -ton -tons -tot -tota -totes -tots -un -una -unes -uns -us -va -vaig -vam -van -vas -veu -vosaltres -vostra -vostre -vostres +# Catalan stopwords from http://github.com/vcl/cue.language (Apache 2 Licensed) +a +abans +ací +ah +així +això +al +als +aleshores +algun +alguna +algunes +alguns +alhora +allà +allí +allò +altra +altre +altres +amb +ambdós +ambdues +apa +aquell +aquella +aquelles +aquells +aquest +aquesta +aquestes +aquests +aquí +baix +cada +cadascú +cadascuna +cadascunes +cadascuns +com +contra +d'un +d'una +d'unes +d'uns +dalt +de +del +dels +des +després +dins +dintre +donat +doncs +durant +e +eh +el +els +em +en +encara +ens +entre +érem +eren +éreu +es +és +esta +està +estàvem +estaven +estàveu +esteu +et +etc +ets +fins +fora +gairebé +ha +han +has +havia +he +hem +heu +hi +ho +i +igual +iguals +ja +l'hi +la +les +li +li'n +llavors +m'he +ma +mal +malgrat +mateix +mateixa +mateixes +mateixos +me +mentre +més +meu +meus +meva +meves +molt +molta +moltes +molts +mon +mons +n'he +n'hi +ne +ni +no +nogensmenys +només +nosaltres +nostra +nostre +nostres +o +oh +oi +on +pas +pel +pels +per +però +perquè +poc +poca +pocs +poques +potser +propi +qual +quals +quan +quant +que +què +quelcom +qui +quin +quina +quines +quins +s'ha +s'han +sa +semblant +semblants +ses +seu +seus +seva +seva +seves +si +sobre +sobretot +sóc +solament +sols +son +són +sons +sota +sou +t'ha +t'han +t'he +ta +tal +també +tampoc +tan +tant +tanta +tantes +teu +teus +teva +teves +ton +tons +tot +tota +totes +tots +un +una +unes +uns +us +va +vaig +vam +van +vas +veu +vosaltres +vostra +vostre +vostres diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_cz.txt b/resources/cache/empty/websearch/conf/lang/stopwords_cz.txt index e928df95..53c6097d 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_cz.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_cz.txt @@ -1,172 +1,172 @@ -a -s -k -o -i -u -v -z -dnes -cz -tímto -budeš -budem -byli -jseš -můj -svým -ta -tomto -tohle -tuto -tyto -jej -zda -proč -máte -tato -kam -tohoto -kdo -kteří -mi -nám -tom -tomuto -mít -nic -proto -kterou -byla -toho -protože -asi -ho -naši -napište -re -což -tím -takže -svých -její -svými -jste -aj -tu -tedy -teto -bylo -kde -ke -pravé -ji -nad -nejsou -či -pod -téma -mezi -přes -ty -pak -vám -ani -když -však -neg -jsem -tento -článku -články -aby -jsme -před -pta -jejich -byl -ještě -až -bez -také -pouze -první -vaše -která -nás -nový -tipy -pokud -může -strana -jeho -své -jiné -zprávy -nové -není -vás -jen -podle -zde -už -být -více -bude -již -než -který -by -které -co -nebo -ten -tak -má -při -od -po -jsou -jak -další -ale -si -se -ve -to -jako -za -zpět -ze -do -pro -je -na -atd -atp -jakmile -přičemž -já -on -ona -ono -oni -ony -my -vy -jí -ji -mě -mne -jemu -tomu -těm -těmu -němu -němuž -jehož -jíž -jelikož -jež -jakož -načež +a +s +k +o +i +u +v +z +dnes +cz +tímto +budeš +budem +byli +jseš +můj +svým +ta +tomto +tohle +tuto +tyto +jej +zda +proč +máte +tato +kam +tohoto +kdo +kteří +mi +nám +tom +tomuto +mít +nic +proto +kterou +byla +toho +protože +asi +ho +naši +napište +re +což +tím +takže +svých +její +svými +jste +aj +tu +tedy +teto +bylo +kde +ke +pravé +ji +nad +nejsou +či +pod +téma +mezi +přes +ty +pak +vám +ani +když +však +neg +jsem +tento +článku +články +aby +jsme +před +pta +jejich +byl +ještě +až +bez +také +pouze +první +vaše +která +nás +nový +tipy +pokud +může +strana +jeho +své +jiné +zprávy +nové +není +vás +jen +podle +zde +už +být +více +bude +již +než +který +by +které +co +nebo +ten +tak +má +při +od +po +jsou +jak +další +ale +si +se +ve +to +jako +za +zpět +ze +do +pro +je +na +atd +atp +jakmile +přičemž +já +on +ona +ono +oni +ony +my +vy +jí +ji +mě +mne +jemu +tomu +těm +těmu +němu +němuž +jehož +jíž +jelikož +jež +jakož +načež diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_da.txt b/resources/cache/empty/websearch/conf/lang/stopwords_da.txt index e25d49ce..42e6145b 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_da.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_da.txt @@ -1,110 +1,110 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/danish/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Danish stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - | This is a ranked list (commonest to rarest) of stopwords derived from - | a large text sample. - - -og | and -i | in -jeg | I -det | that (dem. pronoun)/it (pers. pronoun) -at | that (in front of a sentence)/to (with infinitive) -en | a/an -den | it (pers. pronoun)/that (dem. pronoun) -til | to/at/for/until/against/by/of/into, more -er | present tense of "to be" -som | who, as -på | on/upon/in/on/at/to/after/of/with/for, on -de | they -med | with/by/in, along -han | he -af | of/by/from/off/for/in/with/on, off -for | at/for/to/from/by/of/ago, in front/before, because -ikke | not -der | who/which, there/those -var | past tense of "to be" -mig | me/myself -sig | oneself/himself/herself/itself/themselves -men | but -et | a/an/one, one (number), someone/somebody/one -har | present tense of "to have" -om | round/about/for/in/a, about/around/down, if -vi | we -min | my -havde | past tense of "to have" -ham | him -hun | she -nu | now -over | over/above/across/by/beyond/past/on/about, over/past -da | then, when/as/since -fra | from/off/since, off, since -du | you -ud | out -sin | his/her/its/one's -dem | them -os | us/ourselves -op | up -man | you/one -hans | his -hvor | where -eller | or -hvad | what -skal | must/shall etc. -selv | myself/youself/herself/ourselves etc., even -her | here -alle | all/everyone/everybody etc. -vil | will (verb) -blev | past tense of "to stay/to remain/to get/to become" -kunne | could -ind | in -når | when -være | present tense of "to be" -dog | however/yet/after all -noget | something -ville | would -jo | you know/you see (adv), yes -deres | their/theirs -efter | after/behind/according to/for/by/from, later/afterwards -ned | down -skulle | should -denne | this -end | than -dette | this -mit | my/mine -også | also -under | under/beneath/below/during, below/underneath -have | have -dig | you -anden | other -hende | her -mine | my -alt | everything -meget | much/very, plenty of -sit | his, her, its, one's -sine | his, her, its, one's -vor | our -mod | against -disse | these -hvis | if -din | your/yours -nogle | some -hos | by/at -blive | be/become -mange | many -ad | by/through -bliver | present tense of "to be/to become" -hendes | her/hers -været | be -thi | for (conj) -jer | you -sådan | such, like this/like that + | From svn.tartarus.org/snowball/trunk/website/algorithms/danish/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Danish stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + | This is a ranked list (commonest to rarest) of stopwords derived from + | a large text sample. + + +og | and +i | in +jeg | I +det | that (dem. pronoun)/it (pers. pronoun) +at | that (in front of a sentence)/to (with infinitive) +en | a/an +den | it (pers. pronoun)/that (dem. pronoun) +til | to/at/for/until/against/by/of/into, more +er | present tense of "to be" +som | who, as +på | on/upon/in/on/at/to/after/of/with/for, on +de | they +med | with/by/in, along +han | he +af | of/by/from/off/for/in/with/on, off +for | at/for/to/from/by/of/ago, in front/before, because +ikke | not +der | who/which, there/those +var | past tense of "to be" +mig | me/myself +sig | oneself/himself/herself/itself/themselves +men | but +et | a/an/one, one (number), someone/somebody/one +har | present tense of "to have" +om | round/about/for/in/a, about/around/down, if +vi | we +min | my +havde | past tense of "to have" +ham | him +hun | she +nu | now +over | over/above/across/by/beyond/past/on/about, over/past +da | then, when/as/since +fra | from/off/since, off, since +du | you +ud | out +sin | his/her/its/one's +dem | them +os | us/ourselves +op | up +man | you/one +hans | his +hvor | where +eller | or +hvad | what +skal | must/shall etc. +selv | myself/youself/herself/ourselves etc., even +her | here +alle | all/everyone/everybody etc. +vil | will (verb) +blev | past tense of "to stay/to remain/to get/to become" +kunne | could +ind | in +når | when +være | present tense of "to be" +dog | however/yet/after all +noget | something +ville | would +jo | you know/you see (adv), yes +deres | their/theirs +efter | after/behind/according to/for/by/from, later/afterwards +ned | down +skulle | should +denne | this +end | than +dette | this +mit | my/mine +også | also +under | under/beneath/below/during, below/underneath +have | have +dig | you +anden | other +hende | her +mine | my +alt | everything +meget | much/very, plenty of +sit | his, her, its, one's +sine | his, her, its, one's +vor | our +mod | against +disse | these +hvis | if +din | your/yours +nogle | some +hos | by/at +blive | be/become +mange | many +ad | by/through +bliver | present tense of "to be/to become" +hendes | her/hers +været | be +thi | for (conj) +jer | you +sådan | such, like this/like that diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_de.txt b/resources/cache/empty/websearch/conf/lang/stopwords_de.txt index bb9933ee..86525e7a 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_de.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_de.txt @@ -1,294 +1,294 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/german/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A German stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - | The number of forms in this list is reduced significantly by passing it - | through the German stemmer. - - -aber | but - -alle | all -allem -allen -aller -alles - -als | than, as -also | so -am | an + dem -an | at - -ander | other -andere -anderem -anderen -anderer -anderes -anderm -andern -anderr -anders - -auch | also -auf | on -aus | out of -bei | by -bin | am -bis | until -bist | art -da | there -damit | with it -dann | then - -der | the -den -des -dem -die -das - -daß | that - -derselbe | the same -derselben -denselben -desselben -demselben -dieselbe -dieselben -dasselbe - -dazu | to that - -dein | thy -deine -deinem -deinen -deiner -deines - -denn | because - -derer | of those -dessen | of him - -dich | thee -dir | to thee -du | thou - -dies | this -diese -diesem -diesen -dieser -dieses - - -doch | (several meanings) -dort | (over) there - - -durch | through - -ein | a -eine -einem -einen -einer -eines - -einig | some -einige -einigem -einigen -einiger -einiges - -einmal | once - -er | he -ihn | him -ihm | to him - -es | it -etwas | something - -euer | your -eure -eurem -euren -eurer -eures - -für | for -gegen | towards -gewesen | p.p. of sein -hab | have -habe | have -haben | have -hat | has -hatte | had -hatten | had -hier | here -hin | there -hinter | behind - -ich | I -mich | me -mir | to me - - -ihr | you, to her -ihre -ihrem -ihren -ihrer -ihres -euch | to you - -im | in + dem -in | in -indem | while -ins | in + das -ist | is - -jede | each, every -jedem -jeden -jeder -jedes - -jene | that -jenem -jenen -jener -jenes - -jetzt | now -kann | can - -kein | no -keine -keinem -keinen -keiner -keines - -können | can -könnte | could -machen | do -man | one - -manche | some, many a -manchem -manchen -mancher -manches - -mein | my -meine -meinem -meinen -meiner -meines - -mit | with -muss | must -musste | had to -nach | to(wards) -nicht | not -nichts | nothing -noch | still, yet -nun | now -nur | only -ob | whether -oder | or -ohne | without -sehr | very - -sein | his -seine -seinem -seinen -seiner -seines - -selbst | self -sich | herself - -sie | they, she -ihnen | to them - -sind | are -so | so - -solche | such -solchem -solchen -solcher -solches - -soll | shall -sollte | should -sondern | but -sonst | else -über | over -um | about, around -und | and - -uns | us -unse -unsem -unsen -unser -unses - -unter | under -viel | much -vom | von + dem -von | from -vor | before -während | while -war | was -waren | were -warst | wast -was | what -weg | away, off -weil | because -weiter | further - -welche | which -welchem -welchen -welcher -welches - -wenn | when -werde | will -werden | will -wie | how -wieder | again -will | want -wir | we -wird | will -wirst | willst -wo | where -wollen | want -wollte | wanted -würde | would -würden | would -zu | to -zum | zu + dem -zur | zu + der -zwar | indeed -zwischen | between - + | From svn.tartarus.org/snowball/trunk/website/algorithms/german/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A German stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + | The number of forms in this list is reduced significantly by passing it + | through the German stemmer. + + +aber | but + +alle | all +allem +allen +aller +alles + +als | than, as +also | so +am | an + dem +an | at + +ander | other +andere +anderem +anderen +anderer +anderes +anderm +andern +anderr +anders + +auch | also +auf | on +aus | out of +bei | by +bin | am +bis | until +bist | art +da | there +damit | with it +dann | then + +der | the +den +des +dem +die +das + +daß | that + +derselbe | the same +derselben +denselben +desselben +demselben +dieselbe +dieselben +dasselbe + +dazu | to that + +dein | thy +deine +deinem +deinen +deiner +deines + +denn | because + +derer | of those +dessen | of him + +dich | thee +dir | to thee +du | thou + +dies | this +diese +diesem +diesen +dieser +dieses + + +doch | (several meanings) +dort | (over) there + + +durch | through + +ein | a +eine +einem +einen +einer +eines + +einig | some +einige +einigem +einigen +einiger +einiges + +einmal | once + +er | he +ihn | him +ihm | to him + +es | it +etwas | something + +euer | your +eure +eurem +euren +eurer +eures + +für | for +gegen | towards +gewesen | p.p. of sein +hab | have +habe | have +haben | have +hat | has +hatte | had +hatten | had +hier | here +hin | there +hinter | behind + +ich | I +mich | me +mir | to me + + +ihr | you, to her +ihre +ihrem +ihren +ihrer +ihres +euch | to you + +im | in + dem +in | in +indem | while +ins | in + das +ist | is + +jede | each, every +jedem +jeden +jeder +jedes + +jene | that +jenem +jenen +jener +jenes + +jetzt | now +kann | can + +kein | no +keine +keinem +keinen +keiner +keines + +können | can +könnte | could +machen | do +man | one + +manche | some, many a +manchem +manchen +mancher +manches + +mein | my +meine +meinem +meinen +meiner +meines + +mit | with +muss | must +musste | had to +nach | to(wards) +nicht | not +nichts | nothing +noch | still, yet +nun | now +nur | only +ob | whether +oder | or +ohne | without +sehr | very + +sein | his +seine +seinem +seinen +seiner +seines + +selbst | self +sich | herself + +sie | they, she +ihnen | to them + +sind | are +so | so + +solche | such +solchem +solchen +solcher +solches + +soll | shall +sollte | should +sondern | but +sonst | else +über | over +um | about, around +und | and + +uns | us +unse +unsem +unsen +unser +unses + +unter | under +viel | much +vom | von + dem +von | from +vor | before +während | while +war | was +waren | were +warst | wast +was | what +weg | away, off +weil | because +weiter | further + +welche | which +welchem +welchen +welcher +welches + +wenn | when +werde | will +werden | will +wie | how +wieder | again +will | want +wir | we +wird | will +wirst | willst +wo | where +wollen | want +wollte | wanted +würde | would +würden | would +zu | to +zum | zu + dem +zur | zu + der +zwar | indeed +zwischen | between + diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_el.txt b/resources/cache/empty/websearch/conf/lang/stopwords_el.txt index a5abfbec..232681f5 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_el.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_el.txt @@ -1,78 +1,78 @@ -# Lucene Greek Stopwords list -# Note: by default this file is used after GreekLowerCaseFilter, -# so when modifying this file use 'σ' instead of 'ς' -ο -η -το -οι -τα -του -τησ -των -τον -την -και -κι -κ -ειμαι -εισαι -ειναι -ειμαστε -ειστε -στο -στον -στη -στην -μα -αλλα -απο -για -προσ -με -σε -ωσ -παρα -αντι -κατα -μετα -θα -να -δε -δεν -μη -μην -επι -ενω -εαν -αν -τοτε -που -πωσ -ποιοσ -ποια -ποιο -ποιοι -ποιεσ -ποιων -ποιουσ -αυτοσ -αυτη -αυτο -αυτοι -αυτων -αυτουσ -αυτεσ -αυτα -εκεινοσ -εκεινη -εκεινο -εκεινοι -εκεινεσ -εκεινα -εκεινων -εκεινουσ -οπωσ -ομωσ -ισωσ -οσο -οτι +# Lucene Greek Stopwords list +# Note: by default this file is used after GreekLowerCaseFilter, +# so when modifying this file use 'σ' instead of 'ς' +ο +η +το +οι +τα +του +τησ +των +τον +την +και +κι +κ +ειμαι +εισαι +ειναι +ειμαστε +ειστε +στο +στον +στη +στην +μα +αλλα +απο +για +προσ +με +σε +ωσ +παρα +αντι +κατα +μετα +θα +να +δε +δεν +μη +μην +επι +ενω +εαν +αν +τοτε +που +πωσ +ποιοσ +ποια +ποιο +ποιοι +ποιεσ +ποιων +ποιουσ +αυτοσ +αυτη +αυτο +αυτοι +αυτων +αυτουσ +αυτεσ +αυτα +εκεινοσ +εκεινη +εκεινο +εκεινοι +εκεινεσ +εκεινα +εκεινων +εκεινουσ +οπωσ +ομωσ +ισωσ +οσο +οτι diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_en.txt b/resources/cache/empty/websearch/conf/lang/stopwords_en.txt index 224230c5..2c164c0b 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_en.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_en.txt @@ -1,54 +1,54 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# a couple of test stopwords to test that the words are really being -# configured from this file: -stopworda -stopwordb - -# Standard english stop words taken from Lucene's StopAnalyzer -a -an -and -are -as -at -be -but -by -for -if -in -into -is -it -no -not -of -on -or -such -that -the -their -then -there -these -they -this -to -was -will -with +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# a couple of test stopwords to test that the words are really being +# configured from this file: +stopworda +stopwordb + +# Standard english stop words taken from Lucene's StopAnalyzer +a +an +and +are +as +at +be +but +by +for +if +in +into +is +it +no +not +of +on +or +such +that +the +their +then +there +these +they +this +to +was +will +with diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_es.txt b/resources/cache/empty/websearch/conf/lang/stopwords_es.txt index 99afd937..487d78c8 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_es.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_es.txt @@ -1,356 +1,356 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/spanish/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Spanish stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - - | The following is a ranked list (commonest to rarest) of stopwords - | deriving from a large sample of text. - - | Extra words have been added at the end. - -de | from, of -la | the, her -que | who, that -el | the -en | in -y | and -a | to -los | the, them -del | de + el -se | himself, from him etc -las | the, them -por | for, by, etc -un | a -para | for -con | with -no | no -una | a -su | his, her -al | a + el - | es from SER -lo | him -como | how -más | more -pero | pero -sus | su plural -le | to him, her -ya | already -o | or - | fue from SER -este | this - | ha from HABER -sí | himself etc -porque | because -esta | this - | son from SER -entre | between - | está from ESTAR -cuando | when -muy | very -sin | without -sobre | on - | ser from SER - | tiene from TENER -también | also -me | me -hasta | until -hay | there is/are -donde | where - | han from HABER -quien | whom, that - | están from ESTAR - | estado from ESTAR -desde | from -todo | all -nos | us -durante | during - | estados from ESTAR -todos | all -uno | a -les | to them -ni | nor -contra | against -otros | other - | fueron from SER -ese | that -eso | that - | había from HABER -ante | before -ellos | they -e | and (variant of y) -esto | this -mí | me -antes | before -algunos | some -qué | what? -unos | a -yo | I -otro | other -otras | other -otra | other -él | he -tanto | so much, many -esa | that -estos | these -mucho | much, many -quienes | who -nada | nothing -muchos | many -cual | who - | sea from SER -poco | few -ella | she -estar | to be - | haber from HABER -estas | these - | estaba from ESTAR - | estamos from ESTAR -algunas | some -algo | something -nosotros | we - - | other forms - -mi | me -mis | mi plural -tú | thou -te | thee -ti | thee -tu | thy -tus | tu plural -ellas | they -nosotras | we -vosotros | you -vosotras | you -os | you -mío | mine -mía | -míos | -mías | -tuyo | thine -tuya | -tuyos | -tuyas | -suyo | his, hers, theirs -suya | -suyos | -suyas | -nuestro | ours -nuestra | -nuestros | -nuestras | -vuestro | yours -vuestra | -vuestros | -vuestras | -esos | those -esas | those - - | forms of estar, to be (not including the infinitive): -estoy -estás -está -estamos -estáis -están -esté -estés -estemos -estéis -estén -estaré -estarás -estará -estaremos -estaréis -estarán -estaría -estarías -estaríamos -estaríais -estarían -estaba -estabas -estábamos -estabais -estaban -estuve -estuviste -estuvo -estuvimos -estuvisteis -estuvieron -estuviera -estuvieras -estuviéramos -estuvierais -estuvieran -estuviese -estuvieses -estuviésemos -estuvieseis -estuviesen -estando -estado -estada -estados -estadas -estad - - | forms of haber, to have (not including the infinitive): -he -has -ha -hemos -habéis -han -haya -hayas -hayamos -hayáis -hayan -habré -habrás -habrá -habremos -habréis -habrán -habría -habrías -habríamos -habríais -habrían -había -habías -habíamos -habíais -habían -hube -hubiste -hubo -hubimos -hubisteis -hubieron -hubiera -hubieras -hubiéramos -hubierais -hubieran -hubiese -hubieses -hubiésemos -hubieseis -hubiesen -habiendo -habido -habida -habidos -habidas - - | forms of ser, to be (not including the infinitive): -soy -eres -es -somos -sois -son -sea -seas -seamos -seáis -sean -seré -serás -será -seremos -seréis -serán -sería -serías -seríamos -seríais -serían -era -eras -éramos -erais -eran -fui -fuiste -fue -fuimos -fuisteis -fueron -fuera -fueras -fuéramos -fuerais -fueran -fuese -fueses -fuésemos -fueseis -fuesen -siendo -sido - | sed also means 'thirst' - - | forms of tener, to have (not including the infinitive): -tengo -tienes -tiene -tenemos -tenéis -tienen -tenga -tengas -tengamos -tengáis -tengan -tendré -tendrás -tendrá -tendremos -tendréis -tendrán -tendría -tendrías -tendríamos -tendríais -tendrían -tenía -tenías -teníamos -teníais -tenían -tuve -tuviste -tuvo -tuvimos -tuvisteis -tuvieron -tuviera -tuvieras -tuviéramos -tuvierais -tuvieran -tuviese -tuvieses -tuviésemos -tuvieseis -tuviesen -teniendo -tenido -tenida -tenidos -tenidas -tened - + | From svn.tartarus.org/snowball/trunk/website/algorithms/spanish/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Spanish stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + + | The following is a ranked list (commonest to rarest) of stopwords + | deriving from a large sample of text. + + | Extra words have been added at the end. + +de | from, of +la | the, her +que | who, that +el | the +en | in +y | and +a | to +los | the, them +del | de + el +se | himself, from him etc +las | the, them +por | for, by, etc +un | a +para | for +con | with +no | no +una | a +su | his, her +al | a + el + | es from SER +lo | him +como | how +más | more +pero | pero +sus | su plural +le | to him, her +ya | already +o | or + | fue from SER +este | this + | ha from HABER +sí | himself etc +porque | because +esta | this + | son from SER +entre | between + | está from ESTAR +cuando | when +muy | very +sin | without +sobre | on + | ser from SER + | tiene from TENER +también | also +me | me +hasta | until +hay | there is/are +donde | where + | han from HABER +quien | whom, that + | están from ESTAR + | estado from ESTAR +desde | from +todo | all +nos | us +durante | during + | estados from ESTAR +todos | all +uno | a +les | to them +ni | nor +contra | against +otros | other + | fueron from SER +ese | that +eso | that + | había from HABER +ante | before +ellos | they +e | and (variant of y) +esto | this +mí | me +antes | before +algunos | some +qué | what? +unos | a +yo | I +otro | other +otras | other +otra | other +él | he +tanto | so much, many +esa | that +estos | these +mucho | much, many +quienes | who +nada | nothing +muchos | many +cual | who + | sea from SER +poco | few +ella | she +estar | to be + | haber from HABER +estas | these + | estaba from ESTAR + | estamos from ESTAR +algunas | some +algo | something +nosotros | we + + | other forms + +mi | me +mis | mi plural +tú | thou +te | thee +ti | thee +tu | thy +tus | tu plural +ellas | they +nosotras | we +vosotros | you +vosotras | you +os | you +mío | mine +mía | +míos | +mías | +tuyo | thine +tuya | +tuyos | +tuyas | +suyo | his, hers, theirs +suya | +suyos | +suyas | +nuestro | ours +nuestra | +nuestros | +nuestras | +vuestro | yours +vuestra | +vuestros | +vuestras | +esos | those +esas | those + + | forms of estar, to be (not including the infinitive): +estoy +estás +está +estamos +estáis +están +esté +estés +estemos +estéis +estén +estaré +estarás +estará +estaremos +estaréis +estarán +estaría +estarías +estaríamos +estaríais +estarían +estaba +estabas +estábamos +estabais +estaban +estuve +estuviste +estuvo +estuvimos +estuvisteis +estuvieron +estuviera +estuvieras +estuviéramos +estuvierais +estuvieran +estuviese +estuvieses +estuviésemos +estuvieseis +estuviesen +estando +estado +estada +estados +estadas +estad + + | forms of haber, to have (not including the infinitive): +he +has +ha +hemos +habéis +han +haya +hayas +hayamos +hayáis +hayan +habré +habrás +habrá +habremos +habréis +habrán +habría +habrías +habríamos +habríais +habrían +había +habías +habíamos +habíais +habían +hube +hubiste +hubo +hubimos +hubisteis +hubieron +hubiera +hubieras +hubiéramos +hubierais +hubieran +hubiese +hubieses +hubiésemos +hubieseis +hubiesen +habiendo +habido +habida +habidos +habidas + + | forms of ser, to be (not including the infinitive): +soy +eres +es +somos +sois +son +sea +seas +seamos +seáis +sean +seré +serás +será +seremos +seréis +serán +sería +serías +seríamos +seríais +serían +era +eras +éramos +erais +eran +fui +fuiste +fue +fuimos +fuisteis +fueron +fuera +fueras +fuéramos +fuerais +fueran +fuese +fueses +fuésemos +fueseis +fuesen +siendo +sido + | sed also means 'thirst' + + | forms of tener, to have (not including the infinitive): +tengo +tienes +tiene +tenemos +tenéis +tienen +tenga +tengas +tengamos +tengáis +tengan +tendré +tendrás +tendrá +tendremos +tendréis +tendrán +tendría +tendrías +tendríamos +tendríais +tendrían +tenía +tenías +teníamos +teníais +tenían +tuve +tuviste +tuvo +tuvimos +tuvisteis +tuvieron +tuviera +tuvieras +tuviéramos +tuvierais +tuvieran +tuviese +tuvieses +tuviésemos +tuvieseis +tuviesen +teniendo +tenido +tenida +tenidos +tenidas +tened + diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_eu.txt b/resources/cache/empty/websearch/conf/lang/stopwords_eu.txt index 7e4e4bb3..25f1db93 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_eu.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_eu.txt @@ -1,99 +1,99 @@ -# example set of basque stopwords -al -anitz -arabera -asko -baina -bat -batean -batek -bati -batzuei -batzuek -batzuetan -batzuk -bera -beraiek -berau -berauek -bere -berori -beroriek -beste -bezala -da -dago -dira -ditu -du -dute -edo -egin -ere -eta -eurak -ez -gainera -gu -gutxi -guzti -haiei -haiek -haietan -hainbeste -hala -han -handik -hango -hara -hari -hark -hartan -hau -hauei -hauek -hauetan -hemen -hemendik -hemengo -hi -hona -honek -honela -honetan -honi -hor -hori -horiei -horiek -horietan -horko -horra -horrek -horrela -horretan -horri -hortik -hura -izan -ni -noiz -nola -non -nondik -nongo -nor -nora -ze -zein -zen -zenbait -zenbat -zer -zergatik -ziren -zituen -zu -zuek -zuen -zuten +# example set of basque stopwords +al +anitz +arabera +asko +baina +bat +batean +batek +bati +batzuei +batzuek +batzuetan +batzuk +bera +beraiek +berau +berauek +bere +berori +beroriek +beste +bezala +da +dago +dira +ditu +du +dute +edo +egin +ere +eta +eurak +ez +gainera +gu +gutxi +guzti +haiei +haiek +haietan +hainbeste +hala +han +handik +hango +hara +hari +hark +hartan +hau +hauei +hauek +hauetan +hemen +hemendik +hemengo +hi +hona +honek +honela +honetan +honi +hor +hori +horiei +horiek +horietan +horko +horra +horrek +horrela +horretan +horri +hortik +hura +izan +ni +noiz +nola +non +nondik +nongo +nor +nora +ze +zein +zen +zenbait +zenbat +zer +zergatik +ziren +zituen +zu +zuek +zuen +zuten diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_fa.txt b/resources/cache/empty/websearch/conf/lang/stopwords_fa.txt index 76bb6354..723641c6 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_fa.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_fa.txt @@ -1,313 +1,313 @@ -# This file was created by Jacques Savoy and is distributed under the BSD license. -# See http://members.unine.ch/jacques.savoy/clef/index.html. -# Also see http://www.opensource.org/licenses/bsd-license.html -# Note: by default this file is used after normalization, so when adding entries -# to this file, use the arabic 'ي' instead of 'ی' -انان -نداشته -سراسر -خياه -ايشان -وي -تاكنون -بيشتري -دوم -پس -ناشي -وگو -يا -داشتند -سپس -هنگام -هرگز -پنج -نشان -امسال -ديگر -گروهي -شدند -چطور -ده -و -دو -نخستين -ولي -چرا -چه -وسط -ه -كدام -قابل -يك -رفت -هفت -همچنين -در -هزار -بله -بلي -شايد -اما -شناسي -گرفته -دهد -داشته -دانست -داشتن -خواهيم -ميليارد -وقتيكه -امد -خواهد -جز -اورده -شده -بلكه -خدمات -شدن -برخي -نبود -بسياري -جلوگيري -حق -كردند -نوعي -بعري -نكرده -نظير -نبايد -بوده -بودن -داد -اورد -هست -جايي -شود -دنبال -داده -بايد -سابق -هيچ -همان -انجا -كمتر -كجاست -گردد -كسي -تر -مردم -تان -دادن -بودند -سري -جدا -ندارند -مگر -يكديگر -دارد -دهند -بنابراين -هنگامي -سمت -جا -انچه -خود -دادند -زياد -دارند -اثر -بدون -بهترين -بيشتر -البته -به -براساس -بيرون -كرد -بعضي -گرفت -توي -اي -ميليون -او -جريان -تول -بر -مانند -برابر -باشيم -مدتي -گويند -اكنون -تا -تنها -جديد -چند -بي -نشده -كردن -كردم -گويد -كرده -كنيم -نمي -نزد -روي -قصد -فقط -بالاي -ديگران -اين -ديروز -توسط -سوم -ايم -دانند -سوي -استفاده -شما -كنار -داريم -ساخته -طور -امده -رفته -نخست -بيست -نزديك -طي -كنيد -از -انها -تمامي -داشت -يكي -طريق -اش -چيست -روب -نمايد -گفت -چندين -چيزي -تواند -ام -ايا -با -ان -ايد -ترين -اينكه -ديگري -راه -هايي -بروز -همچنان -پاعين -كس -حدود -مختلف -مقابل -چيز -گيرد -ندارد -ضد -همچون -سازي -شان -مورد -باره -مرسي -خويش -برخوردار -چون -خارج -شش -هنوز -تحت -ضمن -هستيم -گفته -فكر -بسيار -پيش -براي -روزهاي -انكه -نخواهد -بالا -كل -وقتي -كي -چنين -كه -گيري -نيست -است -كجا -كند -نيز -يابد -بندي -حتي -توانند -عقب -خواست -كنند -بين -تمام -همه -ما -باشند -مثل -شد -اري -باشد -اره -طبق -بعد -اگر -صورت -غير -جاي -بيش -ريزي -اند -زيرا -چگونه -بار -لطفا -مي -درباره -من -ديده -همين -گذاري -برداري -علت -گذاشته -هم -فوق -نه -ها -شوند -اباد -همواره -هر -اول -خواهند -چهار -نام -امروز -مان -هاي -قبل -كنم -سعي -تازه -را -هستند -زير -جلوي -عنوان -بود +# This file was created by Jacques Savoy and is distributed under the BSD license. +# See http://members.unine.ch/jacques.savoy/clef/index.html. +# Also see http://www.opensource.org/licenses/bsd-license.html +# Note: by default this file is used after normalization, so when adding entries +# to this file, use the arabic 'ي' instead of 'ی' +انان +نداشته +سراسر +خياه +ايشان +وي +تاكنون +بيشتري +دوم +پس +ناشي +وگو +يا +داشتند +سپس +هنگام +هرگز +پنج +نشان +امسال +ديگر +گروهي +شدند +چطور +ده +و +دو +نخستين +ولي +چرا +چه +وسط +ه +كدام +قابل +يك +رفت +هفت +همچنين +در +هزار +بله +بلي +شايد +اما +شناسي +گرفته +دهد +داشته +دانست +داشتن +خواهيم +ميليارد +وقتيكه +امد +خواهد +جز +اورده +شده +بلكه +خدمات +شدن +برخي +نبود +بسياري +جلوگيري +حق +كردند +نوعي +بعري +نكرده +نظير +نبايد +بوده +بودن +داد +اورد +هست +جايي +شود +دنبال +داده +بايد +سابق +هيچ +همان +انجا +كمتر +كجاست +گردد +كسي +تر +مردم +تان +دادن +بودند +سري +جدا +ندارند +مگر +يكديگر +دارد +دهند +بنابراين +هنگامي +سمت +جا +انچه +خود +دادند +زياد +دارند +اثر +بدون +بهترين +بيشتر +البته +به +براساس +بيرون +كرد +بعضي +گرفت +توي +اي +ميليون +او +جريان +تول +بر +مانند +برابر +باشيم +مدتي +گويند +اكنون +تا +تنها +جديد +چند +بي +نشده +كردن +كردم +گويد +كرده +كنيم +نمي +نزد +روي +قصد +فقط +بالاي +ديگران +اين +ديروز +توسط +سوم +ايم +دانند +سوي +استفاده +شما +كنار +داريم +ساخته +طور +امده +رفته +نخست +بيست +نزديك +طي +كنيد +از +انها +تمامي +داشت +يكي +طريق +اش +چيست +روب +نمايد +گفت +چندين +چيزي +تواند +ام +ايا +با +ان +ايد +ترين +اينكه +ديگري +راه +هايي +بروز +همچنان +پاعين +كس +حدود +مختلف +مقابل +چيز +گيرد +ندارد +ضد +همچون +سازي +شان +مورد +باره +مرسي +خويش +برخوردار +چون +خارج +شش +هنوز +تحت +ضمن +هستيم +گفته +فكر +بسيار +پيش +براي +روزهاي +انكه +نخواهد +بالا +كل +وقتي +كي +چنين +كه +گيري +نيست +است +كجا +كند +نيز +يابد +بندي +حتي +توانند +عقب +خواست +كنند +بين +تمام +همه +ما +باشند +مثل +شد +اري +باشد +اره +طبق +بعد +اگر +صورت +غير +جاي +بيش +ريزي +اند +زيرا +چگونه +بار +لطفا +مي +درباره +من +ديده +همين +گذاري +برداري +علت +گذاشته +هم +فوق +نه +ها +شوند +اباد +همواره +هر +اول +خواهند +چهار +نام +امروز +مان +هاي +قبل +كنم +سعي +تازه +را +هستند +زير +جلوي +عنوان +بود diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_fi.txt b/resources/cache/empty/websearch/conf/lang/stopwords_fi.txt index 4d70da3b..4372c9a0 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_fi.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_fi.txt @@ -1,97 +1,97 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/finnish/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - -| forms of BE - -olla -olen -olet -on -olemme -olette -ovat -ole | negative form - -oli -olisi -olisit -olisin -olisimme -olisitte -olisivat -olit -olin -olimme -olitte -olivat -ollut -olleet - -en | negation -et -ei -emme -ette -eivät - -|Nom Gen Acc Part Iness Elat Illat Adess Ablat Allat Ess Trans -minä minun minut minua minussa minusta minuun minulla minulta minulle | I -sinä sinun sinut sinua sinussa sinusta sinuun sinulla sinulta sinulle | you -hän hänen hänet häntä hänessä hänestä häneen hänellä häneltä hänelle | he she -me meidän meidät meitä meissä meistä meihin meillä meiltä meille | we -te teidän teidät teitä teissä teistä teihin teillä teiltä teille | you -he heidän heidät heitä heissä heistä heihin heillä heiltä heille | they - -tämä tämän tätä tässä tästä tähän tallä tältä tälle tänä täksi | this -tuo tuon tuotä tuossa tuosta tuohon tuolla tuolta tuolle tuona tuoksi | that -se sen sitä siinä siitä siihen sillä siltä sille sinä siksi | it -nämä näiden näitä näissä näistä näihin näillä näiltä näille näinä näiksi | these -nuo noiden noita noissa noista noihin noilla noilta noille noina noiksi | those -ne niiden niitä niissä niistä niihin niillä niiltä niille niinä niiksi | they - -kuka kenen kenet ketä kenessä kenestä keneen kenellä keneltä kenelle kenenä keneksi| who -ketkä keiden ketkä keitä keissä keistä keihin keillä keiltä keille keinä keiksi | (pl) -mikä minkä minkä mitä missä mistä mihin millä miltä mille minä miksi | which what -mitkä | (pl) - -joka jonka jota jossa josta johon jolla jolta jolle jona joksi | who which -jotka joiden joita joissa joista joihin joilla joilta joille joina joiksi | (pl) - -| conjunctions - -että | that -ja | and -jos | if -koska | because -kuin | than -mutta | but -niin | so -sekä | and -sillä | for -tai | or -vaan | but -vai | or -vaikka | although - - -| prepositions - -kanssa | with -mukaan | according to -noin | about -poikki | across -yli | over, across - -| other - -kun | when -niin | so -nyt | now -itse | self - + | From svn.tartarus.org/snowball/trunk/website/algorithms/finnish/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + +| forms of BE + +olla +olen +olet +on +olemme +olette +ovat +ole | negative form + +oli +olisi +olisit +olisin +olisimme +olisitte +olisivat +olit +olin +olimme +olitte +olivat +ollut +olleet + +en | negation +et +ei +emme +ette +eivät + +|Nom Gen Acc Part Iness Elat Illat Adess Ablat Allat Ess Trans +minä minun minut minua minussa minusta minuun minulla minulta minulle | I +sinä sinun sinut sinua sinussa sinusta sinuun sinulla sinulta sinulle | you +hän hänen hänet häntä hänessä hänestä häneen hänellä häneltä hänelle | he she +me meidän meidät meitä meissä meistä meihin meillä meiltä meille | we +te teidän teidät teitä teissä teistä teihin teillä teiltä teille | you +he heidän heidät heitä heissä heistä heihin heillä heiltä heille | they + +tämä tämän tätä tässä tästä tähän tallä tältä tälle tänä täksi | this +tuo tuon tuotä tuossa tuosta tuohon tuolla tuolta tuolle tuona tuoksi | that +se sen sitä siinä siitä siihen sillä siltä sille sinä siksi | it +nämä näiden näitä näissä näistä näihin näillä näiltä näille näinä näiksi | these +nuo noiden noita noissa noista noihin noilla noilta noille noina noiksi | those +ne niiden niitä niissä niistä niihin niillä niiltä niille niinä niiksi | they + +kuka kenen kenet ketä kenessä kenestä keneen kenellä keneltä kenelle kenenä keneksi| who +ketkä keiden ketkä keitä keissä keistä keihin keillä keiltä keille keinä keiksi | (pl) +mikä minkä minkä mitä missä mistä mihin millä miltä mille minä miksi | which what +mitkä | (pl) + +joka jonka jota jossa josta johon jolla jolta jolle jona joksi | who which +jotka joiden joita joissa joista joihin joilla joilta joille joina joiksi | (pl) + +| conjunctions + +että | that +ja | and +jos | if +koska | because +kuin | than +mutta | but +niin | so +sekä | and +sillä | for +tai | or +vaan | but +vai | or +vaikka | although + + +| prepositions + +kanssa | with +mukaan | according to +noin | about +poikki | across +yli | over, across + +| other + +kun | when +niin | so +nyt | now +itse | self + diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_fr.txt b/resources/cache/empty/websearch/conf/lang/stopwords_fr.txt index fec33952..749abae6 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_fr.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_fr.txt @@ -1,186 +1,186 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/french/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A French stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - -au | a + le -aux | a + les -avec | with -ce | this -ces | these -dans | with -de | of -des | de + les -du | de + le -elle | she -en | `of them' etc -et | and -eux | them -il | he -je | I -la | the -le | the -leur | their -lui | him -ma | my (fem) -mais | but -me | me -même | same; as in moi-même (myself) etc -mes | me (pl) -moi | me -mon | my (masc) -ne | not -nos | our (pl) -notre | our -nous | we -on | one -ou | where -par | by -pas | not -pour | for -qu | que before vowel -que | that -qui | who -sa | his, her (fem) -se | oneself -ses | his (pl) -son | his, her (masc) -sur | on -ta | thy (fem) -te | thee -tes | thy (pl) -toi | thee -ton | thy (masc) -tu | thou -un | a -une | a -vos | your (pl) -votre | your -vous | you - - | single letter forms - -c | c' -d | d' -j | j' -l | l' -à | to, at -m | m' -n | n' -s | s' -t | t' -y | there - - | forms of être (not including the infinitive): -été -étée -étées -étés -étant -suis -es -est -sommes -êtes -sont -serai -seras -sera -serons -serez -seront -serais -serait -serions -seriez -seraient -étais -était -étions -étiez -étaient -fus -fut -fûmes -fûtes -furent -sois -soit -soyons -soyez -soient -fusse -fusses -fût -fussions -fussiez -fussent - - | forms of avoir (not including the infinitive): -ayant -eu -eue -eues -eus -ai -as -avons -avez -ont -aurai -auras -aura -aurons -aurez -auront -aurais -aurait -aurions -auriez -auraient -avais -avait -avions -aviez -avaient -eut -eûmes -eûtes -eurent -aie -aies -ait -ayons -ayez -aient -eusse -eusses -eût -eussions -eussiez -eussent - - | Later additions (from Jean-Christophe Deschamps) -ceci | this -cela | that -celà | that -cet | this -cette | this -ici | here -ils | they -les | the (pl) -leurs | their (pl) -quel | which -quels | which -quelle | which -quelles | which -sans | without -soi | oneself - + | From svn.tartarus.org/snowball/trunk/website/algorithms/french/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A French stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + +au | a + le +aux | a + les +avec | with +ce | this +ces | these +dans | with +de | of +des | de + les +du | de + le +elle | she +en | `of them' etc +et | and +eux | them +il | he +je | I +la | the +le | the +leur | their +lui | him +ma | my (fem) +mais | but +me | me +même | same; as in moi-même (myself) etc +mes | me (pl) +moi | me +mon | my (masc) +ne | not +nos | our (pl) +notre | our +nous | we +on | one +ou | where +par | by +pas | not +pour | for +qu | que before vowel +que | that +qui | who +sa | his, her (fem) +se | oneself +ses | his (pl) +son | his, her (masc) +sur | on +ta | thy (fem) +te | thee +tes | thy (pl) +toi | thee +ton | thy (masc) +tu | thou +un | a +une | a +vos | your (pl) +votre | your +vous | you + + | single letter forms + +c | c' +d | d' +j | j' +l | l' +à | to, at +m | m' +n | n' +s | s' +t | t' +y | there + + | forms of être (not including the infinitive): +été +étée +étées +étés +étant +suis +es +est +sommes +êtes +sont +serai +seras +sera +serons +serez +seront +serais +serait +serions +seriez +seraient +étais +était +étions +étiez +étaient +fus +fut +fûmes +fûtes +furent +sois +soit +soyons +soyez +soient +fusse +fusses +fût +fussions +fussiez +fussent + + | forms of avoir (not including the infinitive): +ayant +eu +eue +eues +eus +ai +as +avons +avez +ont +aurai +auras +aura +aurons +aurez +auront +aurais +aurait +aurions +auriez +auraient +avais +avait +avions +aviez +avaient +eut +eûmes +eûtes +eurent +aie +aies +ait +ayons +ayez +aient +eusse +eusses +eût +eussions +eussiez +eussent + + | Later additions (from Jean-Christophe Deschamps) +ceci | this +cela | that +celà | that +cet | this +cette | this +ici | here +ils | they +les | the (pl) +leurs | their (pl) +quel | which +quels | which +quelle | which +quelles | which +sans | without +soi | oneself + diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_ga.txt b/resources/cache/empty/websearch/conf/lang/stopwords_ga.txt index f03e10a9..9ff88d74 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_ga.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_ga.txt @@ -1,110 +1,110 @@ - -a -ach -ag -agus -an -aon -ar -arna -as -b' -ba -beirt -bhúr -caoga -ceathair -ceathrar -chomh -chtó -chuig -chun -cois -céad -cúig -cúigear -d' -daichead -dar -de -deich -deichniúr -den -dhá -do -don -dtí -dá -dár -dó -faoi -faoin -faoina -faoinár -fara -fiche -gach -gan -go -gur -haon -hocht -i -iad -idir -in -ina -ins -inár -is -le -leis -lena -lenár -m' -mar -mo -mé -na -nach -naoi -naonúr -ná -ní -níor -nó -nócha -ocht -ochtar -os -roimh -sa -seacht -seachtar -seachtó -seasca -seisear -siad -sibh -sinn -sna -sé -sí -tar -thar -thú -triúr -trí -trína -trínár -tríocha -tú -um -ár -é -éis -í -ó -ón -óna -ónár + +a +ach +ag +agus +an +aon +ar +arna +as +b' +ba +beirt +bhúr +caoga +ceathair +ceathrar +chomh +chtó +chuig +chun +cois +céad +cúig +cúigear +d' +daichead +dar +de +deich +deichniúr +den +dhá +do +don +dtí +dá +dár +dó +faoi +faoin +faoina +faoinár +fara +fiche +gach +gan +go +gur +haon +hocht +i +iad +idir +in +ina +ins +inár +is +le +leis +lena +lenár +m' +mar +mo +mé +na +nach +naoi +naonúr +ná +ní +níor +nó +nócha +ocht +ochtar +os +roimh +sa +seacht +seachtar +seachtó +seasca +seisear +siad +sibh +sinn +sna +sé +sí +tar +thar +thú +triúr +trí +trína +trínár +tríocha +tú +um +ár +é +éis +í +ó +ón +óna +ónár diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_gl.txt b/resources/cache/empty/websearch/conf/lang/stopwords_gl.txt index 57803b31..d8760b12 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_gl.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_gl.txt @@ -1,161 +1,161 @@ -# galican stopwords -a -aínda -alí -aquel -aquela -aquelas -aqueles -aquilo -aquí -ao -aos -as -así -á -ben -cando -che -co -coa -comigo -con -connosco -contigo -convosco -coas -cos -cun -cuns -cunha -cunhas -da -dalgunha -dalgunhas -dalgún -dalgúns -das -de -del -dela -delas -deles -desde -deste -do -dos -dun -duns -dunha -dunhas -e -el -ela -elas -eles -en -era -eran -esa -esas -ese -eses -esta -estar -estaba -está -están -este -estes -estiven -estou -eu -é -facer -foi -foron -fun -había -hai -iso -isto -la -las -lle -lles -lo -los -mais -me -meu -meus -min -miña -miñas -moi -na -nas -neste -nin -no -non -nos -nosa -nosas -noso -nosos -nós -nun -nunha -nuns -nunhas -o -os -ou -ó -ós -para -pero -pode -pois -pola -polas -polo -polos -por -que -se -senón -ser -seu -seus -sexa -sido -sobre -súa -súas -tamén -tan -te -ten -teñen -teño -ter -teu -teus -ti -tido -tiña -tiven -túa -túas -un -unha -unhas -uns -vos -vosa -vosas -voso -vosos -vós +# galican stopwords +a +aínda +alí +aquel +aquela +aquelas +aqueles +aquilo +aquí +ao +aos +as +así +á +ben +cando +che +co +coa +comigo +con +connosco +contigo +convosco +coas +cos +cun +cuns +cunha +cunhas +da +dalgunha +dalgunhas +dalgún +dalgúns +das +de +del +dela +delas +deles +desde +deste +do +dos +dun +duns +dunha +dunhas +e +el +ela +elas +eles +en +era +eran +esa +esas +ese +eses +esta +estar +estaba +está +están +este +estes +estiven +estou +eu +é +facer +foi +foron +fun +había +hai +iso +isto +la +las +lle +lles +lo +los +mais +me +meu +meus +min +miña +miñas +moi +na +nas +neste +nin +no +non +nos +nosa +nosas +noso +nosos +nós +nun +nunha +nuns +nunhas +o +os +ou +ó +ós +para +pero +pode +pois +pola +polas +polo +polos +por +que +se +senón +ser +seu +seus +sexa +sido +sobre +súa +súas +tamén +tan +te +ten +teñen +teño +ter +teu +teus +ti +tido +tiña +tiven +túa +túas +un +unha +unhas +uns +vos +vosa +vosas +voso +vosos +vós diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_hi.txt b/resources/cache/empty/websearch/conf/lang/stopwords_hi.txt index 1f19fd10..86286bb0 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_hi.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_hi.txt @@ -1,235 +1,235 @@ -# Also see http://www.opensource.org/licenses/bsd-license.html -# See http://members.unine.ch/jacques.savoy/clef/index.html. -# This file was created by Jacques Savoy and is distributed under the BSD license. -# Note: by default this file also contains forms normalized by HindiNormalizer -# for spelling variation (see section below), such that it can be used whether or -# not you enable that feature. When adding additional entries to this list, -# please add the normalized form as well. -अंदर -अत -अपना -अपनी -अपने -अभी -आदि -आप -इत्यादि -इन -इनका -इन्हीं -इन्हें -इन्हों -इस -इसका -इसकी -इसके -इसमें -इसी -इसे -उन -उनका -उनकी -उनके -उनको -उन्हीं -उन्हें -उन्हों -उस -उसके -उसी -उसे -एक -एवं -एस -ऐसे -और -कई -कर -करता -करते -करना -करने -करें -कहते -कहा -का -काफ़ी -कि -कितना -किन्हें -किन्हों -किया -किर -किस -किसी -किसे -की -कुछ -कुल -के -को -कोई -कौन -कौनसा -गया -घर -जब -जहाँ -जा -जितना -जिन -जिन्हें -जिन्हों -जिस -जिसे -जीधर -जैसा -जैसे -जो -तक -तब -तरह -तिन -तिन्हें -तिन्हों -तिस -तिसे -तो -था -थी -थे -दबारा -दिया -दुसरा -दूसरे -दो -द्वारा -न -नहीं -ना -निहायत -नीचे -ने -पर -पर -पहले -पूरा -पे -फिर -बनी -बही -बहुत -बाद -बाला -बिलकुल -भी -भीतर -मगर -मानो -मे -में -यदि -यह -यहाँ -यही -या -यिह -ये -रखें -रहा -रहे -ऱ्वासा -लिए -लिये -लेकिन -व -वर्ग -वह -वह -वहाँ -वहीं -वाले -वुह -वे -वग़ैरह -संग -सकता -सकते -सबसे -सभी -साथ -साबुत -साभ -सारा -से -सो -ही -हुआ -हुई -हुए -है -हैं -हो -होता -होती -होते -होना -होने -# additional normalized forms of the above -अपनि -जेसे -होति -सभि -तिंहों -इंहों -दवारा -इसि -किंहें -थि -उंहों -ओर -जिंहें -वहिं -अभि -बनि -हि -उंहिं -उंहें -हें -वगेरह -एसे -रवासा -कोन -निचे -काफि -उसि -पुरा -भितर -हे -बहि -वहां -कोइ -यहां -जिंहों -तिंहें -किसि -कइ -यहि -इंहिं -जिधर -इंहें -अदि -इतयादि -हुइ -कोनसा -इसकि -दुसरे -जहां -अप -किंहों -उनकि -भि -वरग -हुअ -जेसा -नहिं +# Also see http://www.opensource.org/licenses/bsd-license.html +# See http://members.unine.ch/jacques.savoy/clef/index.html. +# This file was created by Jacques Savoy and is distributed under the BSD license. +# Note: by default this file also contains forms normalized by HindiNormalizer +# for spelling variation (see section below), such that it can be used whether or +# not you enable that feature. When adding additional entries to this list, +# please add the normalized form as well. +अंदर +अत +अपना +अपनी +अपने +अभी +आदि +आप +इत्यादि +इन +इनका +इन्हीं +इन्हें +इन्हों +इस +इसका +इसकी +इसके +इसमें +इसी +इसे +उन +उनका +उनकी +उनके +उनको +उन्हीं +उन्हें +उन्हों +उस +उसके +उसी +उसे +एक +एवं +एस +ऐसे +और +कई +कर +करता +करते +करना +करने +करें +कहते +कहा +का +काफ़ी +कि +कितना +किन्हें +किन्हों +किया +किर +किस +किसी +किसे +की +कुछ +कुल +के +को +कोई +कौन +कौनसा +गया +घर +जब +जहाँ +जा +जितना +जिन +जिन्हें +जिन्हों +जिस +जिसे +जीधर +जैसा +जैसे +जो +तक +तब +तरह +तिन +तिन्हें +तिन्हों +तिस +तिसे +तो +था +थी +थे +दबारा +दिया +दुसरा +दूसरे +दो +द्वारा +न +नहीं +ना +निहायत +नीचे +ने +पर +पर +पहले +पूरा +पे +फिर +बनी +बही +बहुत +बाद +बाला +बिलकुल +भी +भीतर +मगर +मानो +मे +में +यदि +यह +यहाँ +यही +या +यिह +ये +रखें +रहा +रहे +ऱ्वासा +लिए +लिये +लेकिन +व +वर्ग +वह +वह +वहाँ +वहीं +वाले +वुह +वे +वग़ैरह +संग +सकता +सकते +सबसे +सभी +साथ +साबुत +साभ +सारा +से +सो +ही +हुआ +हुई +हुए +है +हैं +हो +होता +होती +होते +होना +होने +# additional normalized forms of the above +अपनि +जेसे +होति +सभि +तिंहों +इंहों +दवारा +इसि +किंहें +थि +उंहों +ओर +जिंहें +वहिं +अभि +बनि +हि +उंहिं +उंहें +हें +वगेरह +एसे +रवासा +कोन +निचे +काफि +उसि +पुरा +भितर +हे +बहि +वहां +कोइ +यहां +जिंहों +तिंहें +किसि +कइ +यहि +इंहिं +जिधर +इंहें +अदि +इतयादि +हुइ +कोनसा +इसकि +दुसरे +जहां +अप +किंहों +उनकि +भि +वरग +हुअ +जेसा +नहिं diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_hu.txt b/resources/cache/empty/websearch/conf/lang/stopwords_hu.txt index f5bf755b..37526da8 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_hu.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_hu.txt @@ -1,211 +1,211 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/hungarian/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - -| Hungarian stop word list -| prepared by Anna Tordai - -a -ahogy -ahol -aki -akik -akkor -alatt -által -általában -amely -amelyek -amelyekben -amelyeket -amelyet -amelynek -ami -amit -amolyan -amíg -amikor -át -abban -ahhoz -annak -arra -arról -az -azok -azon -azt -azzal -azért -aztán -azután -azonban -bár -be -belül -benne -cikk -cikkek -cikkeket -csak -de -e -eddig -egész -egy -egyes -egyetlen -egyéb -egyik -egyre -ekkor -el -elég -ellen -elő -először -előtt -első -én -éppen -ebben -ehhez -emilyen -ennek -erre -ez -ezt -ezek -ezen -ezzel -ezért -és -fel -felé -hanem -hiszen -hogy -hogyan -igen -így -illetve -ill. -ill -ilyen -ilyenkor -ison -ismét -itt -jó -jól -jobban -kell -kellett -keresztül -keressünk -ki -kívül -között -közül -legalább -lehet -lehetett -legyen -lenne -lenni -lesz -lett -maga -magát -majd -majd -már -más -másik -meg -még -mellett -mert -mely -melyek -mi -mit -míg -miért -milyen -mikor -minden -mindent -mindenki -mindig -mint -mintha -mivel -most -nagy -nagyobb -nagyon -ne -néha -nekem -neki -nem -néhány -nélkül -nincs -olyan -ott -össze -ő -ők -őket -pedig -persze -rá -s -saját -sem -semmi -sok -sokat -sokkal -számára -szemben -szerint -szinte -talán -tehát -teljes -tovább -továbbá -több -úgy -ugyanis -új -újabb -újra -után -utána -utolsó -vagy -vagyis -valaki -valami -valamint -való -vagyok -van -vannak -volt -voltam -voltak -voltunk -vissza -vele -viszont -volna + | From svn.tartarus.org/snowball/trunk/website/algorithms/hungarian/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + +| Hungarian stop word list +| prepared by Anna Tordai + +a +ahogy +ahol +aki +akik +akkor +alatt +által +általában +amely +amelyek +amelyekben +amelyeket +amelyet +amelynek +ami +amit +amolyan +amíg +amikor +át +abban +ahhoz +annak +arra +arról +az +azok +azon +azt +azzal +azért +aztán +azután +azonban +bár +be +belül +benne +cikk +cikkek +cikkeket +csak +de +e +eddig +egész +egy +egyes +egyetlen +egyéb +egyik +egyre +ekkor +el +elég +ellen +elő +először +előtt +első +én +éppen +ebben +ehhez +emilyen +ennek +erre +ez +ezt +ezek +ezen +ezzel +ezért +és +fel +felé +hanem +hiszen +hogy +hogyan +igen +így +illetve +ill. +ill +ilyen +ilyenkor +ison +ismét +itt +jó +jól +jobban +kell +kellett +keresztül +keressünk +ki +kívül +között +közül +legalább +lehet +lehetett +legyen +lenne +lenni +lesz +lett +maga +magát +majd +majd +már +más +másik +meg +még +mellett +mert +mely +melyek +mi +mit +míg +miért +milyen +mikor +minden +mindent +mindenki +mindig +mint +mintha +mivel +most +nagy +nagyobb +nagyon +ne +néha +nekem +neki +nem +néhány +nélkül +nincs +olyan +ott +össze +ő +ők +őket +pedig +persze +rá +s +saját +sem +semmi +sok +sokat +sokkal +számára +szemben +szerint +szinte +talán +tehát +teljes +tovább +továbbá +több +úgy +ugyanis +új +újabb +újra +után +utána +utolsó +vagy +vagyis +valaki +valami +valamint +való +vagyok +van +vannak +volt +voltam +voltak +voltunk +vissza +vele +viszont +volna diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_hy.txt b/resources/cache/empty/websearch/conf/lang/stopwords_hy.txt index 968a8f4a..60c1c50f 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_hy.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_hy.txt @@ -1,46 +1,46 @@ -# example set of Armenian stopwords. -այդ -այլ -այն -այս -դու -դուք -եմ -են -ենք -ես -եք -է -էի -էին -էինք -էիր -էիք -էր -ըստ -թ -ի -ին -իսկ -իր -կամ -համար -հետ -հետո -մենք -մեջ -մի -ն -նա -նաև -նրա -նրանք -որ -որը -որոնք -որպես -ու -ում -պիտի -վրա -և +# example set of Armenian stopwords. +այդ +այլ +այն +այս +դու +դուք +եմ +են +ենք +ես +եք +է +էի +էին +էինք +էիր +էիք +էր +ըստ +թ +ի +ին +իսկ +իր +կամ +համար +հետ +հետո +մենք +մեջ +մի +ն +նա +նաև +նրա +նրանք +որ +որը +որոնք +որպես +ու +ում +պիտի +վրա +և diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_id.txt b/resources/cache/empty/websearch/conf/lang/stopwords_id.txt index 80df39a3..4617f83a 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_id.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_id.txt @@ -1,359 +1,359 @@ -# from appendix D of: A Study of Stemming Effects on Information -# Retrieval in Bahasa Indonesia -ada -adanya -adalah -adapun -agak -agaknya -agar -akan -akankah -akhirnya -aku -akulah -amat -amatlah -anda -andalah -antar -diantaranya -antara -antaranya -diantara -apa -apaan -mengapa -apabila -apakah -apalagi -apatah -atau -ataukah -ataupun -bagai -bagaikan -sebagai -sebagainya -bagaimana -bagaimanapun -sebagaimana -bagaimanakah -bagi -bahkan -bahwa -bahwasanya -sebaliknya -banyak -sebanyak -beberapa -seberapa -begini -beginian -beginikah -beginilah -sebegini -begitu -begitukah -begitulah -begitupun -sebegitu -belum -belumlah -sebelum -sebelumnya -sebenarnya -berapa -berapakah -berapalah -berapapun -betulkah -sebetulnya -biasa -biasanya -bila -bilakah -bisa -bisakah -sebisanya -boleh -bolehkah -bolehlah -buat -bukan -bukankah -bukanlah -bukannya -cuma -percuma -dahulu -dalam -dan -dapat -dari -daripada -dekat -demi -demikian -demikianlah -sedemikian -dengan -depan -di -dia -dialah -dini -diri -dirinya -terdiri -dong -dulu -enggak -enggaknya -entah -entahlah -terhadap -terhadapnya -hal -hampir -hanya -hanyalah -harus -haruslah -harusnya -seharusnya -hendak -hendaklah -hendaknya -hingga -sehingga -ia -ialah -ibarat -ingin -inginkah -inginkan -ini -inikah -inilah -itu -itukah -itulah -jangan -jangankan -janganlah -jika -jikalau -juga -justru -kala -kalau -kalaulah -kalaupun -kalian -kami -kamilah -kamu -kamulah -kan -kapan -kapankah -kapanpun -dikarenakan -karena -karenanya -ke -kecil -kemudian -kenapa -kepada -kepadanya -ketika -seketika -khususnya -kini -kinilah -kiranya -sekiranya -kita -kitalah -kok -lagi -lagian -selagi -lah -lain -lainnya -melainkan -selaku -lalu -melalui -terlalu -lama -lamanya -selama -selama -selamanya -lebih -terlebih -bermacam -macam -semacam -maka -makanya -makin -malah -malahan -mampu -mampukah -mana -manakala -manalagi -masih -masihkah -semasih -masing -mau -maupun -semaunya -memang -mereka -merekalah -meski -meskipun -semula -mungkin -mungkinkah -nah -namun -nanti -nantinya -nyaris -oleh -olehnya -seorang -seseorang -pada -padanya -padahal -paling -sepanjang -pantas -sepantasnya -sepantasnyalah -para -pasti -pastilah -per -pernah -pula -pun -merupakan -rupanya -serupa -saat -saatnya -sesaat -saja -sajalah -saling -bersama -sama -sesama -sambil -sampai -sana -sangat -sangatlah -saya -sayalah -se -sebab -sebabnya -sebuah -tersebut -tersebutlah -sedang -sedangkan -sedikit -sedikitnya -segala -segalanya -segera -sesegera -sejak -sejenak -sekali -sekalian -sekalipun -sesekali -sekaligus -sekarang -sekarang -sekitar -sekitarnya -sela -selain -selalu -seluruh -seluruhnya -semakin -sementara -sempat -semua -semuanya -sendiri -sendirinya -seolah -seperti -sepertinya -sering -seringnya -serta -siapa -siapakah -siapapun -disini -disinilah -sini -sinilah -sesuatu -sesuatunya -suatu -sesudah -sesudahnya -sudah -sudahkah -sudahlah -supaya -tadi -tadinya -tak -tanpa -setelah -telah -tentang -tentu -tentulah -tentunya -tertentu -seterusnya -tapi -tetapi -setiap -tiap -setidaknya -tidak -tidakkah -tidaklah -toh -waduh -wah -wahai -sewaktu -walau -walaupun -wong -yaitu -yakni -yang +# from appendix D of: A Study of Stemming Effects on Information +# Retrieval in Bahasa Indonesia +ada +adanya +adalah +adapun +agak +agaknya +agar +akan +akankah +akhirnya +aku +akulah +amat +amatlah +anda +andalah +antar +diantaranya +antara +antaranya +diantara +apa +apaan +mengapa +apabila +apakah +apalagi +apatah +atau +ataukah +ataupun +bagai +bagaikan +sebagai +sebagainya +bagaimana +bagaimanapun +sebagaimana +bagaimanakah +bagi +bahkan +bahwa +bahwasanya +sebaliknya +banyak +sebanyak +beberapa +seberapa +begini +beginian +beginikah +beginilah +sebegini +begitu +begitukah +begitulah +begitupun +sebegitu +belum +belumlah +sebelum +sebelumnya +sebenarnya +berapa +berapakah +berapalah +berapapun +betulkah +sebetulnya +biasa +biasanya +bila +bilakah +bisa +bisakah +sebisanya +boleh +bolehkah +bolehlah +buat +bukan +bukankah +bukanlah +bukannya +cuma +percuma +dahulu +dalam +dan +dapat +dari +daripada +dekat +demi +demikian +demikianlah +sedemikian +dengan +depan +di +dia +dialah +dini +diri +dirinya +terdiri +dong +dulu +enggak +enggaknya +entah +entahlah +terhadap +terhadapnya +hal +hampir +hanya +hanyalah +harus +haruslah +harusnya +seharusnya +hendak +hendaklah +hendaknya +hingga +sehingga +ia +ialah +ibarat +ingin +inginkah +inginkan +ini +inikah +inilah +itu +itukah +itulah +jangan +jangankan +janganlah +jika +jikalau +juga +justru +kala +kalau +kalaulah +kalaupun +kalian +kami +kamilah +kamu +kamulah +kan +kapan +kapankah +kapanpun +dikarenakan +karena +karenanya +ke +kecil +kemudian +kenapa +kepada +kepadanya +ketika +seketika +khususnya +kini +kinilah +kiranya +sekiranya +kita +kitalah +kok +lagi +lagian +selagi +lah +lain +lainnya +melainkan +selaku +lalu +melalui +terlalu +lama +lamanya +selama +selama +selamanya +lebih +terlebih +bermacam +macam +semacam +maka +makanya +makin +malah +malahan +mampu +mampukah +mana +manakala +manalagi +masih +masihkah +semasih +masing +mau +maupun +semaunya +memang +mereka +merekalah +meski +meskipun +semula +mungkin +mungkinkah +nah +namun +nanti +nantinya +nyaris +oleh +olehnya +seorang +seseorang +pada +padanya +padahal +paling +sepanjang +pantas +sepantasnya +sepantasnyalah +para +pasti +pastilah +per +pernah +pula +pun +merupakan +rupanya +serupa +saat +saatnya +sesaat +saja +sajalah +saling +bersama +sama +sesama +sambil +sampai +sana +sangat +sangatlah +saya +sayalah +se +sebab +sebabnya +sebuah +tersebut +tersebutlah +sedang +sedangkan +sedikit +sedikitnya +segala +segalanya +segera +sesegera +sejak +sejenak +sekali +sekalian +sekalipun +sesekali +sekaligus +sekarang +sekarang +sekitar +sekitarnya +sela +selain +selalu +seluruh +seluruhnya +semakin +sementara +sempat +semua +semuanya +sendiri +sendirinya +seolah +seperti +sepertinya +sering +seringnya +serta +siapa +siapakah +siapapun +disini +disinilah +sini +sinilah +sesuatu +sesuatunya +suatu +sesudah +sesudahnya +sudah +sudahkah +sudahlah +supaya +tadi +tadinya +tak +tanpa +setelah +telah +tentang +tentu +tentulah +tentunya +tertentu +seterusnya +tapi +tetapi +setiap +tiap +setidaknya +tidak +tidakkah +tidaklah +toh +waduh +wah +wahai +sewaktu +walau +walaupun +wong +yaitu +yakni +yang diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_it.txt b/resources/cache/empty/websearch/conf/lang/stopwords_it.txt index 3b20c0ab..1219cc77 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_it.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_it.txt @@ -1,303 +1,303 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/italian/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | An Italian stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - -ad | a (to) before vowel -al | a + il -allo | a + lo -ai | a + i -agli | a + gli -all | a + l' -agl | a + gl' -alla | a + la -alle | a + le -con | with -col | con + il -coi | con + i (forms collo, cogli etc are now very rare) -da | from -dal | da + il -dallo | da + lo -dai | da + i -dagli | da + gli -dall | da + l' -dagl | da + gll' -dalla | da + la -dalle | da + le -di | of -del | di + il -dello | di + lo -dei | di + i -degli | di + gli -dell | di + l' -degl | di + gl' -della | di + la -delle | di + le -in | in -nel | in + el -nello | in + lo -nei | in + i -negli | in + gli -nell | in + l' -negl | in + gl' -nella | in + la -nelle | in + le -su | on -sul | su + il -sullo | su + lo -sui | su + i -sugli | su + gli -sull | su + l' -sugl | su + gl' -sulla | su + la -sulle | su + le -per | through, by -tra | among -contro | against -io | I -tu | thou -lui | he -lei | she -noi | we -voi | you -loro | they -mio | my -mia | -miei | -mie | -tuo | -tua | -tuoi | thy -tue | -suo | -sua | -suoi | his, her -sue | -nostro | our -nostra | -nostri | -nostre | -vostro | your -vostra | -vostri | -vostre | -mi | me -ti | thee -ci | us, there -vi | you, there -lo | him, the -la | her, the -li | them -le | them, the -gli | to him, the -ne | from there etc -il | the -un | a -uno | a -una | a -ma | but -ed | and -se | if -perché | why, because -anche | also -come | how -dov | where (as dov') -dove | where -che | who, that -chi | who -cui | whom -non | not -più | more -quale | who, that -quanto | how much -quanti | -quanta | -quante | -quello | that -quelli | -quella | -quelle | -questo | this -questi | -questa | -queste | -si | yes -tutto | all -tutti | all - - | single letter forms: - -a | at -c | as c' for ce or ci -e | and -i | the -l | as l' -o | or - - | forms of avere, to have (not including the infinitive): - -ho -hai -ha -abbiamo -avete -hanno -abbia -abbiate -abbiano -avrò -avrai -avrà -avremo -avrete -avranno -avrei -avresti -avrebbe -avremmo -avreste -avrebbero -avevo -avevi -aveva -avevamo -avevate -avevano -ebbi -avesti -ebbe -avemmo -aveste -ebbero -avessi -avesse -avessimo -avessero -avendo -avuto -avuta -avuti -avute - - | forms of essere, to be (not including the infinitive): -sono -sei -è -siamo -siete -sia -siate -siano -sarò -sarai -sarà -saremo -sarete -saranno -sarei -saresti -sarebbe -saremmo -sareste -sarebbero -ero -eri -era -eravamo -eravate -erano -fui -fosti -fu -fummo -foste -furono -fossi -fosse -fossimo -fossero -essendo - - | forms of fare, to do (not including the infinitive, fa, fat-): -faccio -fai -facciamo -fanno -faccia -facciate -facciano -farò -farai -farà -faremo -farete -faranno -farei -faresti -farebbe -faremmo -fareste -farebbero -facevo -facevi -faceva -facevamo -facevate -facevano -feci -facesti -fece -facemmo -faceste -fecero -facessi -facesse -facessimo -facessero -facendo - - | forms of stare, to be (not including the infinitive): -sto -stai -sta -stiamo -stanno -stia -stiate -stiano -starò -starai -starà -staremo -starete -staranno -starei -staresti -starebbe -staremmo -stareste -starebbero -stavo -stavi -stava -stavamo -stavate -stavano -stetti -stesti -stette -stemmo -steste -stettero -stessi -stesse -stessimo -stessero -stando + | From svn.tartarus.org/snowball/trunk/website/algorithms/italian/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | An Italian stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + +ad | a (to) before vowel +al | a + il +allo | a + lo +ai | a + i +agli | a + gli +all | a + l' +agl | a + gl' +alla | a + la +alle | a + le +con | with +col | con + il +coi | con + i (forms collo, cogli etc are now very rare) +da | from +dal | da + il +dallo | da + lo +dai | da + i +dagli | da + gli +dall | da + l' +dagl | da + gll' +dalla | da + la +dalle | da + le +di | of +del | di + il +dello | di + lo +dei | di + i +degli | di + gli +dell | di + l' +degl | di + gl' +della | di + la +delle | di + le +in | in +nel | in + el +nello | in + lo +nei | in + i +negli | in + gli +nell | in + l' +negl | in + gl' +nella | in + la +nelle | in + le +su | on +sul | su + il +sullo | su + lo +sui | su + i +sugli | su + gli +sull | su + l' +sugl | su + gl' +sulla | su + la +sulle | su + le +per | through, by +tra | among +contro | against +io | I +tu | thou +lui | he +lei | she +noi | we +voi | you +loro | they +mio | my +mia | +miei | +mie | +tuo | +tua | +tuoi | thy +tue | +suo | +sua | +suoi | his, her +sue | +nostro | our +nostra | +nostri | +nostre | +vostro | your +vostra | +vostri | +vostre | +mi | me +ti | thee +ci | us, there +vi | you, there +lo | him, the +la | her, the +li | them +le | them, the +gli | to him, the +ne | from there etc +il | the +un | a +uno | a +una | a +ma | but +ed | and +se | if +perché | why, because +anche | also +come | how +dov | where (as dov') +dove | where +che | who, that +chi | who +cui | whom +non | not +più | more +quale | who, that +quanto | how much +quanti | +quanta | +quante | +quello | that +quelli | +quella | +quelle | +questo | this +questi | +questa | +queste | +si | yes +tutto | all +tutti | all + + | single letter forms: + +a | at +c | as c' for ce or ci +e | and +i | the +l | as l' +o | or + + | forms of avere, to have (not including the infinitive): + +ho +hai +ha +abbiamo +avete +hanno +abbia +abbiate +abbiano +avrò +avrai +avrà +avremo +avrete +avranno +avrei +avresti +avrebbe +avremmo +avreste +avrebbero +avevo +avevi +aveva +avevamo +avevate +avevano +ebbi +avesti +ebbe +avemmo +aveste +ebbero +avessi +avesse +avessimo +avessero +avendo +avuto +avuta +avuti +avute + + | forms of essere, to be (not including the infinitive): +sono +sei +è +siamo +siete +sia +siate +siano +sarò +sarai +sarà +saremo +sarete +saranno +sarei +saresti +sarebbe +saremmo +sareste +sarebbero +ero +eri +era +eravamo +eravate +erano +fui +fosti +fu +fummo +foste +furono +fossi +fosse +fossimo +fossero +essendo + + | forms of fare, to do (not including the infinitive, fa, fat-): +faccio +fai +facciamo +fanno +faccia +facciate +facciano +farò +farai +farà +faremo +farete +faranno +farei +faresti +farebbe +faremmo +fareste +farebbero +facevo +facevi +faceva +facevamo +facevate +facevano +feci +facesti +fece +facemmo +faceste +fecero +facessi +facesse +facessimo +facessero +facendo + + | forms of stare, to be (not including the infinitive): +sto +stai +sta +stiamo +stanno +stia +stiate +stiano +starò +starai +starà +staremo +starete +staranno +starei +staresti +starebbe +staremmo +stareste +starebbero +stavo +stavi +stava +stavamo +stavate +stavano +stetti +stesti +stette +stemmo +steste +stettero +stessi +stesse +stessimo +stessero +stando diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_ja.txt b/resources/cache/empty/websearch/conf/lang/stopwords_ja.txt index bc3077e5..d4321be6 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_ja.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_ja.txt @@ -1,127 +1,127 @@ -# -# This file defines a stopword set for Japanese. -# -# This set is made up of hand-picked frequent terms from segmented Japanese Wikipedia. -# Punctuation characters and frequent kanji have mostly been left out. See LUCENE-3745 -# for frequency lists, etc. that can be useful for making your own set (if desired) -# -# Note that there is an overlap between these stopwords and the terms stopped when used -# in combination with the JapanesePartOfSpeechStopFilter. When editing this file, note -# that comments are not allowed on the same line as stopwords. -# -# Also note that stopping is done in a case-insensitive manner. Change your StopFilter -# configuration if you need case-sensitive stopping. Lastly, note that stopping is done -# using the same character width as the entries in this file. Since this StopFilter is -# normally done after a CJKWidthFilter in your chain, you would usually want your romaji -# entries to be in half-width and your kana entries to be in full-width. -# -の -に -は -を -た -が -で -て -と -し -れ -さ -ある -いる -も -する -から -な -こと -として -い -や -れる -など -なっ -ない -この -ため -その -あっ -よう -また -もの -という -あり -まで -られ -なる -へ -か -だ -これ -によって -により -おり -より -による -ず -なり -られる -において -ば -なかっ -なく -しかし -について -せ -だっ -その後 -できる -それ -う -ので -なお -のみ -でき -き -つ -における -および -いう -さらに -でも -ら -たり -その他 -に関する -たち -ます -ん -なら -に対して -特に -せる -及び -これら -とき -では -にて -ほか -ながら -うち -そして -とともに -ただし -かつて -それぞれ -または -お -ほど -ものの -に対する -ほとんど -と共に -といった -です -とも -ところ -ここ -##### End of file +# +# This file defines a stopword set for Japanese. +# +# This set is made up of hand-picked frequent terms from segmented Japanese Wikipedia. +# Punctuation characters and frequent kanji have mostly been left out. See LUCENE-3745 +# for frequency lists, etc. that can be useful for making your own set (if desired) +# +# Note that there is an overlap between these stopwords and the terms stopped when used +# in combination with the JapanesePartOfSpeechStopFilter. When editing this file, note +# that comments are not allowed on the same line as stopwords. +# +# Also note that stopping is done in a case-insensitive manner. Change your StopFilter +# configuration if you need case-sensitive stopping. Lastly, note that stopping is done +# using the same character width as the entries in this file. Since this StopFilter is +# normally done after a CJKWidthFilter in your chain, you would usually want your romaji +# entries to be in half-width and your kana entries to be in full-width. +# +の +に +は +を +た +が +で +て +と +し +れ +さ +ある +いる +も +する +から +な +こと +として +い +や +れる +など +なっ +ない +この +ため +その +あっ +よう +また +もの +という +あり +まで +られ +なる +へ +か +だ +これ +によって +により +おり +より +による +ず +なり +られる +において +ば +なかっ +なく +しかし +について +せ +だっ +その後 +できる +それ +う +ので +なお +のみ +でき +き +つ +における +および +いう +さらに +でも +ら +たり +その他 +に関する +たち +ます +ん +なら +に対して +特に +せる +及び +これら +とき +では +にて +ほか +ながら +うち +そして +とともに +ただし +かつて +それぞれ +または +お +ほど +ものの +に対する +ほとんど +と共に +といった +です +とも +ところ +ここ +##### End of file diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_lv.txt b/resources/cache/empty/websearch/conf/lang/stopwords_lv.txt index a4710974..e21a23c0 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_lv.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_lv.txt @@ -1,172 +1,172 @@ -# Set of Latvian stopwords from A Stemming Algorithm for Latvian, Karlis Kreslins -# the original list of over 800 forms was refined: -# pronouns, adverbs, interjections were removed -# -# prepositions -aiz -ap -ar -apakš -ārpus -augšpus -bez -caur -dēļ -gar -iekš -iz -kopš -labad -lejpus -līdz -no -otrpus -pa -par -pār -pēc -pie -pirms -pret -priekš -starp -šaipus -uz -viņpus -virs -virspus -zem -apakšpus -# Conjunctions -un -bet -jo -ja -ka -lai -tomēr -tikko -turpretī -arī -kaut -gan -tādēļ -tā -ne -tikvien -vien -kā -ir -te -vai -kamēr -# Particles -ar -diezin -droši -diemžēl -nebūt -ik -it -taču -nu -pat -tiklab -iekšpus -nedz -tik -nevis -turpretim -jeb -iekam -iekām -iekāms -kolīdz -līdzko -tiklīdz -jebšu -tālab -tāpēc -nekā -itin -jā -jau -jel -nē -nezin -tad -tikai -vis -tak -iekams -vien -# modal verbs -būt -biju -biji -bija -bijām -bijāt -esmu -esi -esam -esat -būšu -būsi -būs -būsim -būsiet -tikt -tiku -tiki -tika -tikām -tikāt -tieku -tiec -tiek -tiekam -tiekat -tikšu -tiks -tiksim -tiksiet -tapt -tapi -tapāt -topat -tapšu -tapsi -taps -tapsim -tapsiet -kļūt -kļuvu -kļuvi -kļuva -kļuvām -kļuvāt -kļūstu -kļūsti -kļūst -kļūstam -kļūstat -kļūšu -kļūsi -kļūs -kļūsim -kļūsiet -# verbs -varēt -varēju -varējām -varēšu -varēsim -var -varēji -varējāt -varēsi -varēsiet -varat -varēja -varēs +# Set of Latvian stopwords from A Stemming Algorithm for Latvian, Karlis Kreslins +# the original list of over 800 forms was refined: +# pronouns, adverbs, interjections were removed +# +# prepositions +aiz +ap +ar +apakš +ārpus +augšpus +bez +caur +dēļ +gar +iekš +iz +kopš +labad +lejpus +līdz +no +otrpus +pa +par +pār +pēc +pie +pirms +pret +priekš +starp +šaipus +uz +viņpus +virs +virspus +zem +apakšpus +# Conjunctions +un +bet +jo +ja +ka +lai +tomēr +tikko +turpretī +arī +kaut +gan +tādēļ +tā +ne +tikvien +vien +kā +ir +te +vai +kamēr +# Particles +ar +diezin +droši +diemžēl +nebūt +ik +it +taču +nu +pat +tiklab +iekšpus +nedz +tik +nevis +turpretim +jeb +iekam +iekām +iekāms +kolīdz +līdzko +tiklīdz +jebšu +tālab +tāpēc +nekā +itin +jā +jau +jel +nē +nezin +tad +tikai +vis +tak +iekams +vien +# modal verbs +būt +biju +biji +bija +bijām +bijāt +esmu +esi +esam +esat +būšu +būsi +būs +būsim +būsiet +tikt +tiku +tiki +tika +tikām +tikāt +tieku +tiec +tiek +tiekam +tiekat +tikšu +tiks +tiksim +tiksiet +tapt +tapi +tapāt +topat +tapšu +tapsi +taps +tapsim +tapsiet +kļūt +kļuvu +kļuvi +kļuva +kļuvām +kļuvāt +kļūstu +kļūsti +kļūst +kļūstam +kļūstat +kļūšu +kļūsi +kļūs +kļūsim +kļūsiet +# verbs +varēt +varēju +varējām +varēšu +varēsim +var +varēji +varējāt +varēsi +varēsiet +varat +varēja +varēs diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_nl.txt b/resources/cache/empty/websearch/conf/lang/stopwords_nl.txt index 06ca75ba..47a2aeac 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_nl.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_nl.txt @@ -1,119 +1,119 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/dutch/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Dutch stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - | This is a ranked list (commonest to rarest) of stopwords derived from - | a large sample of Dutch text. - - | Dutch stop words frequently exhibit homonym clashes. These are indicated - | clearly below. - -de | the -en | and -van | of, from -ik | I, the ego -te | (1) chez, at etc, (2) to, (3) too -dat | that, which -die | that, those, who, which -in | in, inside -een | a, an, one -hij | he -het | the, it -niet | not, nothing, naught -zijn | (1) to be, being, (2) his, one's, its -is | is -was | (1) was, past tense of all persons sing. of 'zijn' (to be) (2) wax, (3) the washing, (4) rise of river -op | on, upon, at, in, up, used up -aan | on, upon, to (as dative) -met | with, by -als | like, such as, when -voor | (1) before, in front of, (2) furrow -had | had, past tense all persons sing. of 'hebben' (have) -er | there -maar | but, only -om | round, about, for etc -hem | him -dan | then -zou | should/would, past tense all persons sing. of 'zullen' -of | or, whether, if -wat | what, something, anything -mijn | possessive and noun 'mine' -men | people, 'one' -dit | this -zo | so, thus, in this way -door | through by -over | over, across -ze | she, her, they, them -zich | oneself -bij | (1) a bee, (2) by, near, at -ook | also, too -tot | till, until -je | you -mij | me -uit | out of, from -der | Old Dutch form of 'van der' still found in surnames -daar | (1) there, (2) because -haar | (1) her, their, them, (2) hair -naar | (1) unpleasant, unwell etc, (2) towards, (3) as -heb | present first person sing. of 'to have' -hoe | how, why -heeft | present third person sing. of 'to have' -hebben | 'to have' and various parts thereof -deze | this -u | you -want | (1) for, (2) mitten, (3) rigging -nog | yet, still -zal | 'shall', first and third person sing. of verb 'zullen' (will) -me | me -zij | she, they -nu | now -ge | 'thou', still used in Belgium and south Netherlands -geen | none -omdat | because -iets | something, somewhat -worden | to become, grow, get -toch | yet, still -al | all, every, each -waren | (1) 'were' (2) to wander, (3) wares, (3) -veel | much, many -meer | (1) more, (2) lake -doen | to do, to make -toen | then, when -moet | noun 'spot/mote' and present form of 'to must' -ben | (1) am, (2) 'are' in interrogative second person singular of 'to be' -zonder | without -kan | noun 'can' and present form of 'to be able' -hun | their, them -dus | so, consequently -alles | all, everything, anything -onder | under, beneath -ja | yes, of course -eens | once, one day -hier | here -wie | who -werd | imperfect third person sing. of 'become' -altijd | always -doch | yet, but etc -wordt | present third person sing. of 'become' -wezen | (1) to be, (2) 'been' as in 'been fishing', (3) orphans -kunnen | to be able -ons | us/our -zelf | self -tegen | against, towards, at -na | after, near -reeds | already -wil | (1) present tense of 'want', (2) 'will', noun, (3) fender -kon | could; past tense of 'to be able' -niets | nothing -uw | your -iemand | somebody -geweest | been; past participle of 'be' -andere | other + | From svn.tartarus.org/snowball/trunk/website/algorithms/dutch/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Dutch stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + | This is a ranked list (commonest to rarest) of stopwords derived from + | a large sample of Dutch text. + + | Dutch stop words frequently exhibit homonym clashes. These are indicated + | clearly below. + +de | the +en | and +van | of, from +ik | I, the ego +te | (1) chez, at etc, (2) to, (3) too +dat | that, which +die | that, those, who, which +in | in, inside +een | a, an, one +hij | he +het | the, it +niet | not, nothing, naught +zijn | (1) to be, being, (2) his, one's, its +is | is +was | (1) was, past tense of all persons sing. of 'zijn' (to be) (2) wax, (3) the washing, (4) rise of river +op | on, upon, at, in, up, used up +aan | on, upon, to (as dative) +met | with, by +als | like, such as, when +voor | (1) before, in front of, (2) furrow +had | had, past tense all persons sing. of 'hebben' (have) +er | there +maar | but, only +om | round, about, for etc +hem | him +dan | then +zou | should/would, past tense all persons sing. of 'zullen' +of | or, whether, if +wat | what, something, anything +mijn | possessive and noun 'mine' +men | people, 'one' +dit | this +zo | so, thus, in this way +door | through by +over | over, across +ze | she, her, they, them +zich | oneself +bij | (1) a bee, (2) by, near, at +ook | also, too +tot | till, until +je | you +mij | me +uit | out of, from +der | Old Dutch form of 'van der' still found in surnames +daar | (1) there, (2) because +haar | (1) her, their, them, (2) hair +naar | (1) unpleasant, unwell etc, (2) towards, (3) as +heb | present first person sing. of 'to have' +hoe | how, why +heeft | present third person sing. of 'to have' +hebben | 'to have' and various parts thereof +deze | this +u | you +want | (1) for, (2) mitten, (3) rigging +nog | yet, still +zal | 'shall', first and third person sing. of verb 'zullen' (will) +me | me +zij | she, they +nu | now +ge | 'thou', still used in Belgium and south Netherlands +geen | none +omdat | because +iets | something, somewhat +worden | to become, grow, get +toch | yet, still +al | all, every, each +waren | (1) 'were' (2) to wander, (3) wares, (3) +veel | much, many +meer | (1) more, (2) lake +doen | to do, to make +toen | then, when +moet | noun 'spot/mote' and present form of 'to must' +ben | (1) am, (2) 'are' in interrogative second person singular of 'to be' +zonder | without +kan | noun 'can' and present form of 'to be able' +hun | their, them +dus | so, consequently +alles | all, everything, anything +onder | under, beneath +ja | yes, of course +eens | once, one day +hier | here +wie | who +werd | imperfect third person sing. of 'become' +altijd | always +doch | yet, but etc +wordt | present third person sing. of 'become' +wezen | (1) to be, (2) 'been' as in 'been fishing', (3) orphans +kunnen | to be able +ons | us/our +zelf | self +tegen | against, towards, at +na | after, near +reeds | already +wil | (1) present tense of 'want', (2) 'will', noun, (3) fender +kon | could; past tense of 'to be able' +niets | nothing +uw | your +iemand | somebody +geweest | been; past participle of 'be' +andere | other diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_no.txt b/resources/cache/empty/websearch/conf/lang/stopwords_no.txt index 8aefda89..a7a2c28b 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_no.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_no.txt @@ -1,194 +1,194 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/norwegian/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Norwegian stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - | This stop word list is for the dominant bokmål dialect. Words unique - | to nynorsk are marked *. - - | Revised by Jan Bruusgaard , Jan 2005 - -og | and -i | in -jeg | I -det | it/this/that -at | to (w. inf.) -en | a/an -et | a/an -den | it/this/that -til | to -er | is/am/are -som | who/that -på | on -de | they / you(formal) -med | with -han | he -av | of -ikke | not -ikkje | not * -der | there -så | so -var | was/were -meg | me -seg | you -men | but -ett | one -har | have -om | about -vi | we -min | my -mitt | my -ha | have -hadde | had -hun | she -nå | now -over | over -da | when/as -ved | by/know -fra | from -du | you -ut | out -sin | your -dem | them -oss | us -opp | up -man | you/one -kan | can -hans | his -hvor | where -eller | or -hva | what -skal | shall/must -selv | self (reflective) -sjøl | self (reflective) -her | here -alle | all -vil | will -bli | become -ble | became -blei | became * -blitt | have become -kunne | could -inn | in -når | when -være | be -kom | come -noen | some -noe | some -ville | would -dere | you -som | who/which/that -deres | their/theirs -kun | only/just -ja | yes -etter | after -ned | down -skulle | should -denne | this -for | for/because -deg | you -si | hers/his -sine | hers/his -sitt | hers/his -mot | against -å | to -meget | much -hvorfor | why -dette | this -disse | these/those -uten | without -hvordan | how -ingen | none -din | your -ditt | your -blir | become -samme | same -hvilken | which -hvilke | which (plural) -sånn | such a -inni | inside/within -mellom | between -vår | our -hver | each -hvem | who -vors | us/ours -hvis | whose -både | both -bare | only/just -enn | than -fordi | as/because -før | before -mange | many -også | also -slik | just -vært | been -være | to be -båe | both * -begge | both -siden | since -dykk | your * -dykkar | yours * -dei | they * -deira | them * -deires | theirs * -deim | them * -di | your (fem.) * -då | as/when * -eg | I * -ein | a/an * -eit | a/an * -eitt | a/an * -elles | or * -honom | he * -hjå | at * -ho | she * -hoe | she * -henne | her -hennar | her/hers -hennes | hers -hoss | how * -hossen | how * -ikkje | not * -ingi | noone * -inkje | noone * -korleis | how * -korso | how * -kva | what/which * -kvar | where * -kvarhelst | where * -kven | who/whom * -kvi | why * -kvifor | why * -me | we * -medan | while * -mi | my * -mine | my * -mykje | much * -no | now * -nokon | some (masc./neut.) * -noka | some (fem.) * -nokor | some * -noko | some * -nokre | some * -si | his/hers * -sia | since * -sidan | since * -so | so * -somt | some * -somme | some * -um | about* -upp | up * -vere | be * -vore | was * -verte | become * -vort | become * -varte | became * -vart | became * - + | From svn.tartarus.org/snowball/trunk/website/algorithms/norwegian/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Norwegian stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + | This stop word list is for the dominant bokmål dialect. Words unique + | to nynorsk are marked *. + + | Revised by Jan Bruusgaard , Jan 2005 + +og | and +i | in +jeg | I +det | it/this/that +at | to (w. inf.) +en | a/an +et | a/an +den | it/this/that +til | to +er | is/am/are +som | who/that +på | on +de | they / you(formal) +med | with +han | he +av | of +ikke | not +ikkje | not * +der | there +så | so +var | was/were +meg | me +seg | you +men | but +ett | one +har | have +om | about +vi | we +min | my +mitt | my +ha | have +hadde | had +hun | she +nå | now +over | over +da | when/as +ved | by/know +fra | from +du | you +ut | out +sin | your +dem | them +oss | us +opp | up +man | you/one +kan | can +hans | his +hvor | where +eller | or +hva | what +skal | shall/must +selv | self (reflective) +sjøl | self (reflective) +her | here +alle | all +vil | will +bli | become +ble | became +blei | became * +blitt | have become +kunne | could +inn | in +når | when +være | be +kom | come +noen | some +noe | some +ville | would +dere | you +som | who/which/that +deres | their/theirs +kun | only/just +ja | yes +etter | after +ned | down +skulle | should +denne | this +for | for/because +deg | you +si | hers/his +sine | hers/his +sitt | hers/his +mot | against +å | to +meget | much +hvorfor | why +dette | this +disse | these/those +uten | without +hvordan | how +ingen | none +din | your +ditt | your +blir | become +samme | same +hvilken | which +hvilke | which (plural) +sånn | such a +inni | inside/within +mellom | between +vår | our +hver | each +hvem | who +vors | us/ours +hvis | whose +både | both +bare | only/just +enn | than +fordi | as/because +før | before +mange | many +også | also +slik | just +vært | been +være | to be +båe | both * +begge | both +siden | since +dykk | your * +dykkar | yours * +dei | they * +deira | them * +deires | theirs * +deim | them * +di | your (fem.) * +då | as/when * +eg | I * +ein | a/an * +eit | a/an * +eitt | a/an * +elles | or * +honom | he * +hjå | at * +ho | she * +hoe | she * +henne | her +hennar | her/hers +hennes | hers +hoss | how * +hossen | how * +ikkje | not * +ingi | noone * +inkje | noone * +korleis | how * +korso | how * +kva | what/which * +kvar | where * +kvarhelst | where * +kven | who/whom * +kvi | why * +kvifor | why * +me | we * +medan | while * +mi | my * +mine | my * +mykje | much * +no | now * +nokon | some (masc./neut.) * +noka | some (fem.) * +nokor | some * +noko | some * +nokre | some * +si | his/hers * +sia | since * +sidan | since * +so | so * +somt | some * +somme | some * +um | about* +upp | up * +vere | be * +vore | was * +verte | become * +vort | become * +varte | became * +vart | became * + diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_pt.txt b/resources/cache/empty/websearch/conf/lang/stopwords_pt.txt index 6afa2b5c..acfeb01a 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_pt.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_pt.txt @@ -1,253 +1,253 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/portuguese/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Portuguese stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - - | The following is a ranked list (commonest to rarest) of stopwords - | deriving from a large sample of text. - - | Extra words have been added at the end. - -de | of, from -a | the; to, at; her -o | the; him -que | who, that -e | and -do | de + o -da | de + a -em | in -um | a -para | for - | é from SER -com | with -não | not, no -uma | a -os | the; them -no | em + o -se | himself etc -na | em + a -por | for -mais | more -as | the; them -dos | de + os -como | as, like -mas | but - | foi from SER -ao | a + o -ele | he -das | de + as - | tem from TER -à | a + a -seu | his -sua | her -ou | or - | ser from SER -quando | when -muito | much - | há from HAV -nos | em + os; us -já | already, now - | está from EST -eu | I -também | also -só | only, just -pelo | per + o -pela | per + a -até | up to -isso | that -ela | he -entre | between - | era from SER -depois | after -sem | without -mesmo | same -aos | a + os - | ter from TER -seus | his -quem | whom -nas | em + as -me | me -esse | that -eles | they - | estão from EST -você | you - | tinha from TER - | foram from SER -essa | that -num | em + um -nem | nor -suas | her -meu | my -às | a + as -minha | my - | têm from TER -numa | em + uma -pelos | per + os -elas | they - | havia from HAV - | seja from SER -qual | which - | será from SER -nós | we - | tenho from TER -lhe | to him, her -deles | of them -essas | those -esses | those -pelas | per + as -este | this - | fosse from SER -dele | of him - - | other words. There are many contractions such as naquele = em+aquele, - | mo = me+o, but they are rare. - | Indefinite article plural forms are also rare. - -tu | thou -te | thee -vocês | you (plural) -vos | you -lhes | to them -meus | my -minhas -teu | thy -tua -teus -tuas -nosso | our -nossa -nossos -nossas - -dela | of her -delas | of them - -esta | this -estes | these -estas | these -aquele | that -aquela | that -aqueles | those -aquelas | those -isto | this -aquilo | that - - | forms of estar, to be (not including the infinitive): -estou -está -estamos -estão -estive -esteve -estivemos -estiveram -estava -estávamos -estavam -estivera -estivéramos -esteja -estejamos -estejam -estivesse -estivéssemos -estivessem -estiver -estivermos -estiverem - - | forms of haver, to have (not including the infinitive): -hei -há -havemos -hão -houve -houvemos -houveram -houvera -houvéramos -haja -hajamos -hajam -houvesse -houvéssemos -houvessem -houver -houvermos -houverem -houverei -houverá -houveremos -houverão -houveria -houveríamos -houveriam - - | forms of ser, to be (not including the infinitive): -sou -somos -são -era -éramos -eram -fui -foi -fomos -foram -fora -fôramos -seja -sejamos -sejam -fosse -fôssemos -fossem -for -formos -forem -serei -será -seremos -serão -seria -seríamos -seriam - - | forms of ter, to have (not including the infinitive): -tenho -tem -temos -tém -tinha -tínhamos -tinham -tive -teve -tivemos -tiveram -tivera -tivéramos -tenha -tenhamos -tenham -tivesse -tivéssemos -tivessem -tiver -tivermos -tiverem -terei -terá -teremos -terão -teria -teríamos -teriam + | From svn.tartarus.org/snowball/trunk/website/algorithms/portuguese/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Portuguese stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + + | The following is a ranked list (commonest to rarest) of stopwords + | deriving from a large sample of text. + + | Extra words have been added at the end. + +de | of, from +a | the; to, at; her +o | the; him +que | who, that +e | and +do | de + o +da | de + a +em | in +um | a +para | for + | é from SER +com | with +não | not, no +uma | a +os | the; them +no | em + o +se | himself etc +na | em + a +por | for +mais | more +as | the; them +dos | de + os +como | as, like +mas | but + | foi from SER +ao | a + o +ele | he +das | de + as + | tem from TER +à | a + a +seu | his +sua | her +ou | or + | ser from SER +quando | when +muito | much + | há from HAV +nos | em + os; us +já | already, now + | está from EST +eu | I +também | also +só | only, just +pelo | per + o +pela | per + a +até | up to +isso | that +ela | he +entre | between + | era from SER +depois | after +sem | without +mesmo | same +aos | a + os + | ter from TER +seus | his +quem | whom +nas | em + as +me | me +esse | that +eles | they + | estão from EST +você | you + | tinha from TER + | foram from SER +essa | that +num | em + um +nem | nor +suas | her +meu | my +às | a + as +minha | my + | têm from TER +numa | em + uma +pelos | per + os +elas | they + | havia from HAV + | seja from SER +qual | which + | será from SER +nós | we + | tenho from TER +lhe | to him, her +deles | of them +essas | those +esses | those +pelas | per + as +este | this + | fosse from SER +dele | of him + + | other words. There are many contractions such as naquele = em+aquele, + | mo = me+o, but they are rare. + | Indefinite article plural forms are also rare. + +tu | thou +te | thee +vocês | you (plural) +vos | you +lhes | to them +meus | my +minhas +teu | thy +tua +teus +tuas +nosso | our +nossa +nossos +nossas + +dela | of her +delas | of them + +esta | this +estes | these +estas | these +aquele | that +aquela | that +aqueles | those +aquelas | those +isto | this +aquilo | that + + | forms of estar, to be (not including the infinitive): +estou +está +estamos +estão +estive +esteve +estivemos +estiveram +estava +estávamos +estavam +estivera +estivéramos +esteja +estejamos +estejam +estivesse +estivéssemos +estivessem +estiver +estivermos +estiverem + + | forms of haver, to have (not including the infinitive): +hei +há +havemos +hão +houve +houvemos +houveram +houvera +houvéramos +haja +hajamos +hajam +houvesse +houvéssemos +houvessem +houver +houvermos +houverem +houverei +houverá +houveremos +houverão +houveria +houveríamos +houveriam + + | forms of ser, to be (not including the infinitive): +sou +somos +são +era +éramos +eram +fui +foi +fomos +foram +fora +fôramos +seja +sejamos +sejam +fosse +fôssemos +fossem +for +formos +forem +serei +será +seremos +serão +seria +seríamos +seriam + + | forms of ter, to have (not including the infinitive): +tenho +tem +temos +tém +tinha +tínhamos +tinham +tive +teve +tivemos +tiveram +tivera +tivéramos +tenha +tenhamos +tenham +tivesse +tivéssemos +tivessem +tiver +tivermos +tiverem +terei +terá +teremos +terão +teria +teríamos +teriam diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_ro.txt b/resources/cache/empty/websearch/conf/lang/stopwords_ro.txt index 2d7395c4..4fdee90a 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_ro.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_ro.txt @@ -1,233 +1,233 @@ -# This file was created by Jacques Savoy and is distributed under the BSD license. -# See http://members.unine.ch/jacques.savoy/clef/index.html. -# Also see http://www.opensource.org/licenses/bsd-license.html -acea -aceasta -această -aceea -acei -aceia -acel -acela -acele -acelea -acest -acesta -aceste -acestea -aceşti -aceştia -acolo -acum -ai -aia -aibă -aici -al -ăla -ale -alea -ălea -altceva -altcineva -am -ar -are -aş -aşadar -asemenea -asta -ăsta -astăzi -astea -ăstea -ăştia -asupra -aţi -au -avea -avem -aveţi -azi -bine -bucur -bună -ca -că -căci -când -care -cărei -căror -cărui -cât -câte -câţi -către -câtva -ce -cel -ceva -chiar -cînd -cine -cineva -cît -cîte -cîţi -cîtva -contra -cu -cum -cumva -curând -curînd -da -dă -dacă -dar -datorită -de -deci -deja -deoarece -departe -deşi -din -dinaintea -dintr -dintre -drept -după -ea -ei -el -ele -eram -este -eşti -eu -face -fără -fi -fie -fiecare -fii -fim -fiţi -iar -ieri -îi -îl -îmi -împotriva -în -înainte -înaintea -încât -încît -încotro -între -întrucât -întrucît -îţi -la -lângă -le -li -lîngă -lor -lui -mă -mâine -mea -mei -mele -mereu -meu -mi -mine -mult -multă -mulţi -ne -nicăieri -nici -nimeni -nişte -noastră -noastre -noi -noştri -nostru -nu -ori -oricând -oricare -oricât -orice -oricînd -oricine -oricît -oricum -oriunde -până -pe -pentru -peste -pînă -poate -pot -prea -prima -primul -prin -printr -sa -să -săi -sale -sau -său -se -şi -sînt -sîntem -sînteţi -spre -sub -sunt -suntem -sunteţi -ta -tăi -tale -tău -te -ţi -ţie -tine -toată -toate -tot -toţi -totuşi -tu -un -una -unde -undeva -unei -unele -uneori -unor -vă -vi -voastră -voastre -voi -voştri -vostru -vouă -vreo -vreun +# This file was created by Jacques Savoy and is distributed under the BSD license. +# See http://members.unine.ch/jacques.savoy/clef/index.html. +# Also see http://www.opensource.org/licenses/bsd-license.html +acea +aceasta +această +aceea +acei +aceia +acel +acela +acele +acelea +acest +acesta +aceste +acestea +aceşti +aceştia +acolo +acum +ai +aia +aibă +aici +al +ăla +ale +alea +ălea +altceva +altcineva +am +ar +are +aş +aşadar +asemenea +asta +ăsta +astăzi +astea +ăstea +ăştia +asupra +aţi +au +avea +avem +aveţi +azi +bine +bucur +bună +ca +că +căci +când +care +cărei +căror +cărui +cât +câte +câţi +către +câtva +ce +cel +ceva +chiar +cînd +cine +cineva +cît +cîte +cîţi +cîtva +contra +cu +cum +cumva +curând +curînd +da +dă +dacă +dar +datorită +de +deci +deja +deoarece +departe +deşi +din +dinaintea +dintr +dintre +drept +după +ea +ei +el +ele +eram +este +eşti +eu +face +fără +fi +fie +fiecare +fii +fim +fiţi +iar +ieri +îi +îl +îmi +împotriva +în +înainte +înaintea +încât +încît +încotro +între +întrucât +întrucît +îţi +la +lângă +le +li +lîngă +lor +lui +mă +mâine +mea +mei +mele +mereu +meu +mi +mine +mult +multă +mulţi +ne +nicăieri +nici +nimeni +nişte +noastră +noastre +noi +noştri +nostru +nu +ori +oricând +oricare +oricât +orice +oricînd +oricine +oricît +oricum +oriunde +până +pe +pentru +peste +pînă +poate +pot +prea +prima +primul +prin +printr +sa +să +săi +sale +sau +său +se +şi +sînt +sîntem +sînteţi +spre +sub +sunt +suntem +sunteţi +ta +tăi +tale +tău +te +ţi +ţie +tine +toată +toate +tot +toţi +totuşi +tu +un +una +unde +undeva +unei +unele +uneori +unor +vă +vi +voastră +voastre +voi +voştri +vostru +vouă +vreo +vreun diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_ru.txt b/resources/cache/empty/websearch/conf/lang/stopwords_ru.txt index 0141b9b8..55271400 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_ru.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_ru.txt @@ -1,243 +1,243 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/russian/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | a russian stop word list. comments begin with vertical bar. each stop - | word is at the start of a line. - - | this is a ranked list (commonest to rarest) of stopwords derived from - | a large text sample. - - | letter `ё' is translated to `е'. - -и | and -в | in/into -во | alternative form -не | not -что | what/that -он | he -на | on/onto -я | i -с | from -со | alternative form -как | how -а | milder form of `no' (but) -то | conjunction and form of `that' -все | all -она | she -так | so, thus -его | him -но | but -да | yes/and -ты | thou -к | towards, by -у | around, chez -же | intensifier particle -вы | you -за | beyond, behind -бы | conditional/subj. particle -по | up to, along -только | only -ее | her -мне | to me -было | it was -вот | here is/are, particle -от | away from -меня | me -еще | still, yet, more -нет | no, there isnt/arent -о | about -из | out of -ему | to him -теперь | now -когда | when -даже | even -ну | so, well -вдруг | suddenly -ли | interrogative particle -если | if -уже | already, but homonym of `narrower' -или | or -ни | neither -быть | to be -был | he was -него | prepositional form of его -до | up to -вас | you accusative -нибудь | indef. suffix preceded by hyphen -опять | again -уж | already, but homonym of `adder' -вам | to you -сказал | he said -ведь | particle `after all' -там | there -потом | then -себя | oneself -ничего | nothing -ей | to her -может | usually with `быть' as `maybe' -они | they -тут | here -где | where -есть | there is/are -надо | got to, must -ней | prepositional form of ей -для | for -мы | we -тебя | thee -их | them, their -чем | than -была | she was -сам | self -чтоб | in order to -без | without -будто | as if -человек | man, person, one -чего | genitive form of `what' -раз | once -тоже | also -себе | to oneself -под | beneath -жизнь | life -будет | will be -ж | short form of intensifer particle `же' -тогда | then -кто | who -этот | this -говорил | was saying -того | genitive form of `that' -потому | for that reason -этого | genitive form of `this' -какой | which -совсем | altogether -ним | prepositional form of `его', `они' -здесь | here -этом | prepositional form of `этот' -один | one -почти | almost -мой | my -тем | instrumental/dative plural of `тот', `то' -чтобы | full form of `in order that' -нее | her (acc.) -кажется | it seems -сейчас | now -были | they were -куда | where to -зачем | why -сказать | to say -всех | all (acc., gen. preposn. plural) -никогда | never -сегодня | today -можно | possible, one can -при | by -наконец | finally -два | two -об | alternative form of `о', about -другой | another -хоть | even -после | after -над | above -больше | more -тот | that one (masc.) -через | across, in -эти | these -нас | us -про | about -всего | in all, only, of all -них | prepositional form of `они' (they) -какая | which, feminine -много | lots -разве | interrogative particle -сказала | she said -три | three -эту | this, acc. fem. sing. -моя | my, feminine -впрочем | moreover, besides -хорошо | good -свою | ones own, acc. fem. sing. -этой | oblique form of `эта', fem. `this' -перед | in front of -иногда | sometimes -лучше | better -чуть | a little -том | preposn. form of `that one' -нельзя | one must not -такой | such a one -им | to them -более | more -всегда | always -конечно | of course -всю | acc. fem. sing of `all' -между | between - - - | b: some paradigms - | - | personal pronouns - | - | я меня мне мной [мною] - | ты тебя тебе тобой [тобою] - | он его ему им [него, нему, ним] - | она ее эи ею [нее, нэи, нею] - | оно его ему им [него, нему, ним] - | - | мы нас нам нами - | вы вас вам вами - | они их им ими [них, ним, ними] - | - | себя себе собой [собою] - | - | demonstrative pronouns: этот (this), тот (that) - | - | этот эта это эти - | этого эты это эти - | этого этой этого этих - | этому этой этому этим - | этим этой этим [этою] этими - | этом этой этом этих - | - | тот та то те - | того ту то те - | того той того тех - | тому той тому тем - | тем той тем [тою] теми - | том той том тех - | - | determinative pronouns - | - | (a) весь (all) - | - | весь вся все все - | всего всю все все - | всего всей всего всех - | всему всей всему всем - | всем всей всем [всею] всеми - | всем всей всем всех - | - | (b) сам (himself etc) - | - | сам сама само сами - | самого саму само самих - | самого самой самого самих - | самому самой самому самим - | самим самой самим [самою] самими - | самом самой самом самих - | - | stems of verbs `to be', `to have', `to do' and modal - | - | быть бы буд быв есть суть - | име - | дел - | мог мож мочь - | уме - | хоч хот - | долж - | можн - | нужн - | нельзя - + | From svn.tartarus.org/snowball/trunk/website/algorithms/russian/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | a russian stop word list. comments begin with vertical bar. each stop + | word is at the start of a line. + + | this is a ranked list (commonest to rarest) of stopwords derived from + | a large text sample. + + | letter `ё' is translated to `е'. + +и | and +в | in/into +во | alternative form +не | not +что | what/that +он | he +на | on/onto +я | i +с | from +со | alternative form +как | how +а | milder form of `no' (but) +то | conjunction and form of `that' +все | all +она | she +так | so, thus +его | him +но | but +да | yes/and +ты | thou +к | towards, by +у | around, chez +же | intensifier particle +вы | you +за | beyond, behind +бы | conditional/subj. particle +по | up to, along +только | only +ее | her +мне | to me +было | it was +вот | here is/are, particle +от | away from +меня | me +еще | still, yet, more +нет | no, there isnt/arent +о | about +из | out of +ему | to him +теперь | now +когда | when +даже | even +ну | so, well +вдруг | suddenly +ли | interrogative particle +если | if +уже | already, but homonym of `narrower' +или | or +ни | neither +быть | to be +был | he was +него | prepositional form of его +до | up to +вас | you accusative +нибудь | indef. suffix preceded by hyphen +опять | again +уж | already, but homonym of `adder' +вам | to you +сказал | he said +ведь | particle `after all' +там | there +потом | then +себя | oneself +ничего | nothing +ей | to her +может | usually with `быть' as `maybe' +они | they +тут | here +где | where +есть | there is/are +надо | got to, must +ней | prepositional form of ей +для | for +мы | we +тебя | thee +их | them, their +чем | than +была | she was +сам | self +чтоб | in order to +без | without +будто | as if +человек | man, person, one +чего | genitive form of `what' +раз | once +тоже | also +себе | to oneself +под | beneath +жизнь | life +будет | will be +ж | short form of intensifer particle `же' +тогда | then +кто | who +этот | this +говорил | was saying +того | genitive form of `that' +потому | for that reason +этого | genitive form of `this' +какой | which +совсем | altogether +ним | prepositional form of `его', `они' +здесь | here +этом | prepositional form of `этот' +один | one +почти | almost +мой | my +тем | instrumental/dative plural of `тот', `то' +чтобы | full form of `in order that' +нее | her (acc.) +кажется | it seems +сейчас | now +были | they were +куда | where to +зачем | why +сказать | to say +всех | all (acc., gen. preposn. plural) +никогда | never +сегодня | today +можно | possible, one can +при | by +наконец | finally +два | two +об | alternative form of `о', about +другой | another +хоть | even +после | after +над | above +больше | more +тот | that one (masc.) +через | across, in +эти | these +нас | us +про | about +всего | in all, only, of all +них | prepositional form of `они' (they) +какая | which, feminine +много | lots +разве | interrogative particle +сказала | she said +три | three +эту | this, acc. fem. sing. +моя | my, feminine +впрочем | moreover, besides +хорошо | good +свою | ones own, acc. fem. sing. +этой | oblique form of `эта', fem. `this' +перед | in front of +иногда | sometimes +лучше | better +чуть | a little +том | preposn. form of `that one' +нельзя | one must not +такой | such a one +им | to them +более | more +всегда | always +конечно | of course +всю | acc. fem. sing of `all' +между | between + + + | b: some paradigms + | + | personal pronouns + | + | я меня мне мной [мною] + | ты тебя тебе тобой [тобою] + | он его ему им [него, нему, ним] + | она ее эи ею [нее, нэи, нею] + | оно его ему им [него, нему, ним] + | + | мы нас нам нами + | вы вас вам вами + | они их им ими [них, ним, ними] + | + | себя себе собой [собою] + | + | demonstrative pronouns: этот (this), тот (that) + | + | этот эта это эти + | этого эты это эти + | этого этой этого этих + | этому этой этому этим + | этим этой этим [этою] этими + | этом этой этом этих + | + | тот та то те + | того ту то те + | того той того тех + | тому той тому тем + | тем той тем [тою] теми + | том той том тех + | + | determinative pronouns + | + | (a) весь (all) + | + | весь вся все все + | всего всю все все + | всего всей всего всех + | всему всей всему всем + | всем всей всем [всею] всеми + | всем всей всем всех + | + | (b) сам (himself etc) + | + | сам сама само сами + | самого саму само самих + | самого самой самого самих + | самому самой самому самим + | самим самой самим [самою] самими + | самом самой самом самих + | + | stems of verbs `to be', `to have', `to do' and modal + | + | быть бы буд быв есть суть + | име + | дел + | мог мож мочь + | уме + | хоч хот + | долж + | можн + | нужн + | нельзя + diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_sv.txt b/resources/cache/empty/websearch/conf/lang/stopwords_sv.txt index 7216373b..096f87f6 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_sv.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_sv.txt @@ -1,133 +1,133 @@ - | From svn.tartarus.org/snowball/trunk/website/algorithms/swedish/stop.txt - | This file is distributed under the BSD License. - | See http://snowball.tartarus.org/license.php - | Also see http://www.opensource.org/licenses/bsd-license.html - | - Encoding was converted to UTF-8. - | - This notice was added. - | - | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" - - | A Swedish stop word list. Comments begin with vertical bar. Each stop - | word is at the start of a line. - - | This is a ranked list (commonest to rarest) of stopwords derived from - | a large text sample. - - | Swedish stop words occasionally exhibit homonym clashes. For example - | så = so, but also seed. These are indicated clearly below. - -och | and -det | it, this/that -att | to (with infinitive) -i | in, at -en | a -jag | I -hon | she -som | who, that -han | he -på | on -den | it, this/that -med | with -var | where, each -sig | him(self) etc -för | for -så | so (also: seed) -till | to -är | is -men | but -ett | a -om | if; around, about -hade | had -de | they, these/those -av | of -icke | not, no -mig | me -du | you -henne | her -då | then, when -sin | his -nu | now -har | have -inte | inte någon = no one -hans | his -honom | him -skulle | 'sake' -hennes | her -där | there -min | my -man | one (pronoun) -ej | nor -vid | at, by, on (also: vast) -kunde | could -något | some etc -från | from, off -ut | out -när | when -efter | after, behind -upp | up -vi | we -dem | them -vara | be -vad | what -över | over -än | than -dig | you -kan | can -sina | his -här | here -ha | have -mot | towards -alla | all -under | under (also: wonder) -någon | some etc -eller | or (else) -allt | all -mycket | much -sedan | since -ju | why -denna | this/that -själv | myself, yourself etc -detta | this/that -åt | to -utan | without -varit | was -hur | how -ingen | no -mitt | my -ni | you -bli | to be, become -blev | from bli -oss | us -din | thy -dessa | these/those -några | some etc -deras | their -blir | from bli -mina | my -samma | (the) same -vilken | who, that -er | you, your -sådan | such a -vår | our -blivit | from bli -dess | its -inom | within -mellan | between -sådant | such a -varför | why -varje | each -vilka | who, that -ditt | thy -vem | who -vilket | who, that -sitta | his -sådana | such a -vart | each -dina | thy -vars | whose -vårt | our -våra | our -ert | your -era | your -vilkas | whose - + | From svn.tartarus.org/snowball/trunk/website/algorithms/swedish/stop.txt + | This file is distributed under the BSD License. + | See http://snowball.tartarus.org/license.php + | Also see http://www.opensource.org/licenses/bsd-license.html + | - Encoding was converted to UTF-8. + | - This notice was added. + | + | NOTE: To use this file with StopFilterFactory, you must specify format="snowball" + + | A Swedish stop word list. Comments begin with vertical bar. Each stop + | word is at the start of a line. + + | This is a ranked list (commonest to rarest) of stopwords derived from + | a large text sample. + + | Swedish stop words occasionally exhibit homonym clashes. For example + | så = so, but also seed. These are indicated clearly below. + +och | and +det | it, this/that +att | to (with infinitive) +i | in, at +en | a +jag | I +hon | she +som | who, that +han | he +på | on +den | it, this/that +med | with +var | where, each +sig | him(self) etc +för | for +så | so (also: seed) +till | to +är | is +men | but +ett | a +om | if; around, about +hade | had +de | they, these/those +av | of +icke | not, no +mig | me +du | you +henne | her +då | then, when +sin | his +nu | now +har | have +inte | inte någon = no one +hans | his +honom | him +skulle | 'sake' +hennes | her +där | there +min | my +man | one (pronoun) +ej | nor +vid | at, by, on (also: vast) +kunde | could +något | some etc +från | from, off +ut | out +när | when +efter | after, behind +upp | up +vi | we +dem | them +vara | be +vad | what +över | over +än | than +dig | you +kan | can +sina | his +här | here +ha | have +mot | towards +alla | all +under | under (also: wonder) +någon | some etc +eller | or (else) +allt | all +mycket | much +sedan | since +ju | why +denna | this/that +själv | myself, yourself etc +detta | this/that +åt | to +utan | without +varit | was +hur | how +ingen | no +mitt | my +ni | you +bli | to be, become +blev | from bli +oss | us +din | thy +dessa | these/those +några | some etc +deras | their +blir | from bli +mina | my +samma | (the) same +vilken | who, that +er | you, your +sådan | such a +vår | our +blivit | from bli +dess | its +inom | within +mellan | between +sådant | such a +varför | why +varje | each +vilka | who, that +ditt | thy +vem | who +vilket | who, that +sitta | his +sådana | such a +vart | each +dina | thy +vars | whose +vårt | our +våra | our +ert | your +era | your +vilkas | whose + diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_th.txt b/resources/cache/empty/websearch/conf/lang/stopwords_th.txt index 1415edf9..07f0fabe 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_th.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_th.txt @@ -1,119 +1,119 @@ -# Thai stopwords from: -# "Opinion Detection in Thai Political News Columns -# Based on Subjectivity Analysis" -# Khampol Sukhum, Supot Nitsuwat, and Choochart Haruechaiyasak -ไว้ -ไม่ -ไป -ได้ -ให้ -ใน -โดย -แห่ง -แล้ว -และ -แรก -แบบ -แต่ -เอง -เห็น -เลย -เริ่ม -เรา -เมื่อ -เพื่อ -เพราะ -เป็นการ -เป็น -เปิดเผย -เปิด -เนื่องจาก -เดียวกัน -เดียว -เช่น -เฉพาะ -เคย -เข้า -เขา -อีก -อาจ -อะไร -ออก -อย่าง -อยู่ -อยาก -หาก -หลาย -หลังจาก -หลัง -หรือ -หนึ่ง -ส่วน -ส่ง -สุด -สําหรับ -ว่า -วัน -ลง -ร่วม -ราย -รับ -ระหว่าง -รวม -ยัง -มี -มาก -มา -พร้อม -พบ -ผ่าน -ผล -บาง -น่า -นี้ -นํา -นั้น -นัก -นอกจาก -ทุก -ที่สุด -ที่ -ทําให้ -ทํา -ทาง -ทั้งนี้ -ทั้ง -ถ้า -ถูก -ถึง -ต้อง -ต่างๆ -ต่าง -ต่อ -ตาม -ตั้งแต่ -ตั้ง -ด้าน -ด้วย -ดัง -ซึ่ง -ช่วง -จึง -จาก -จัด -จะ -คือ -ความ -ครั้ง -คง -ขึ้น -ของ -ขอ -ขณะ -ก่อน -ก็ -การ -กับ -กัน -กว่า -กล่าว +# Thai stopwords from: +# "Opinion Detection in Thai Political News Columns +# Based on Subjectivity Analysis" +# Khampol Sukhum, Supot Nitsuwat, and Choochart Haruechaiyasak +ไว้ +ไม่ +ไป +ได้ +ให้ +ใน +โดย +แห่ง +แล้ว +และ +แรก +แบบ +แต่ +เอง +เห็น +เลย +เริ่ม +เรา +เมื่อ +เพื่อ +เพราะ +เป็นการ +เป็น +เปิดเผย +เปิด +เนื่องจาก +เดียวกัน +เดียว +เช่น +เฉพาะ +เคย +เข้า +เขา +อีก +อาจ +อะไร +ออก +อย่าง +อยู่ +อยาก +หาก +หลาย +หลังจาก +หลัง +หรือ +หนึ่ง +ส่วน +ส่ง +สุด +สําหรับ +ว่า +วัน +ลง +ร่วม +ราย +รับ +ระหว่าง +รวม +ยัง +มี +มาก +มา +พร้อม +พบ +ผ่าน +ผล +บาง +น่า +นี้ +นํา +นั้น +นัก +นอกจาก +ทุก +ที่สุด +ที่ +ทําให้ +ทํา +ทาง +ทั้งนี้ +ทั้ง +ถ้า +ถูก +ถึง +ต้อง +ต่างๆ +ต่าง +ต่อ +ตาม +ตั้งแต่ +ตั้ง +ด้าน +ด้วย +ดัง +ซึ่ง +ช่วง +จึง +จาก +จัด +จะ +คือ +ความ +ครั้ง +คง +ขึ้น +ของ +ขอ +ขณะ +ก่อน +ก็ +การ +กับ +กัน +กว่า +กล่าว diff --git a/resources/cache/empty/websearch/conf/lang/stopwords_tr.txt b/resources/cache/empty/websearch/conf/lang/stopwords_tr.txt index fe4083b7..84d9408d 100644 --- a/resources/cache/empty/websearch/conf/lang/stopwords_tr.txt +++ b/resources/cache/empty/websearch/conf/lang/stopwords_tr.txt @@ -1,212 +1,212 @@ -# Turkish stopwords from LUCENE-559 -# merged with the list from "Information Retrieval on Turkish Texts" -# (http://www.users.muohio.edu/canf/papers/JASIST2008offPrint.pdf) -acaba -altmış -altı -ama -ancak -arada -aslında -ayrıca -bana -bazı -belki -ben -benden -beni -benim -beri -beş -bile -bin -bir -birçok -biri -birkaç -birkez -birşey -birşeyi -biz -bize -bizden -bizi -bizim -böyle -böylece -bu -buna -bunda -bundan -bunlar -bunları -bunların -bunu -bunun -burada -çok -çünkü -da -daha -dahi -de -defa -değil -diğer -diye -doksan -dokuz -dolayı -dolayısıyla -dört -edecek -eden -ederek -edilecek -ediliyor -edilmesi -ediyor -eğer -elli -en -etmesi -etti -ettiği -ettiğini -gibi -göre -halen -hangi -hatta -hem -henüz -hep -hepsi -her -herhangi -herkesin -hiç -hiçbir -için -iki -ile -ilgili -ise -işte -itibaren -itibariyle -kadar -karşın -katrilyon -kendi -kendilerine -kendini -kendisi -kendisine -kendisini -kez -ki -kim -kimden -kime -kimi -kimse -kırk -milyar -milyon -mu -mü -mı -nasıl -ne -neden -nedenle -nerde -nerede -nereye -niye -niçin -o -olan -olarak -oldu -olduğu -olduğunu -olduklarını -olmadı -olmadığı -olmak -olması -olmayan -olmaz -olsa -olsun -olup -olur -olursa -oluyor -on -ona -ondan -onlar -onlardan -onları -onların -onu -onun -otuz -oysa -öyle -pek -rağmen -sadece -sanki -sekiz -seksen -sen -senden -seni -senin -siz -sizden -sizi -sizin -şey -şeyden -şeyi -şeyler -şöyle -şu -şuna -şunda -şundan -şunları -şunu -tarafından -trilyon -tüm -üç -üzere -var -vardı -ve -veya -ya -yani -yapacak -yapılan -yapılması -yapıyor -yapmak -yaptı -yaptığı -yaptığını -yaptıkları -yedi -yerine -yetmiş -yine -yirmi -yoksa -yüz -zaten +# Turkish stopwords from LUCENE-559 +# merged with the list from "Information Retrieval on Turkish Texts" +# (http://www.users.muohio.edu/canf/papers/JASIST2008offPrint.pdf) +acaba +altmış +altı +ama +ancak +arada +aslında +ayrıca +bana +bazı +belki +ben +benden +beni +benim +beri +beş +bile +bin +bir +birçok +biri +birkaç +birkez +birşey +birşeyi +biz +bize +bizden +bizi +bizim +böyle +böylece +bu +buna +bunda +bundan +bunlar +bunları +bunların +bunu +bunun +burada +çok +çünkü +da +daha +dahi +de +defa +değil +diğer +diye +doksan +dokuz +dolayı +dolayısıyla +dört +edecek +eden +ederek +edilecek +ediliyor +edilmesi +ediyor +eğer +elli +en +etmesi +etti +ettiği +ettiğini +gibi +göre +halen +hangi +hatta +hem +henüz +hep +hepsi +her +herhangi +herkesin +hiç +hiçbir +için +iki +ile +ilgili +ise +işte +itibaren +itibariyle +kadar +karşın +katrilyon +kendi +kendilerine +kendini +kendisi +kendisine +kendisini +kez +ki +kim +kimden +kime +kimi +kimse +kırk +milyar +milyon +mu +mü +mı +nasıl +ne +neden +nedenle +nerde +nerede +nereye +niye +niçin +o +olan +olarak +oldu +olduğu +olduğunu +olduklarını +olmadı +olmadığı +olmak +olması +olmayan +olmaz +olsa +olsun +olup +olur +olursa +oluyor +on +ona +ondan +onlar +onlardan +onları +onların +onu +onun +otuz +oysa +öyle +pek +rağmen +sadece +sanki +sekiz +seksen +sen +senden +seni +senin +siz +sizden +sizi +sizin +şey +şeyden +şeyi +şeyler +şöyle +şu +şuna +şunda +şundan +şunları +şunu +tarafından +trilyon +tüm +üç +üzere +var +vardı +ve +veya +ya +yani +yapacak +yapılan +yapılması +yapıyor +yapmak +yaptı +yaptığı +yaptığını +yaptıkları +yedi +yerine +yetmiş +yine +yirmi +yoksa +yüz +zaten diff --git a/resources/cache/empty/websearch/conf/lang/userdict_ja.txt b/resources/cache/empty/websearch/conf/lang/userdict_ja.txt index c79de826..6f0368e4 100644 --- a/resources/cache/empty/websearch/conf/lang/userdict_ja.txt +++ b/resources/cache/empty/websearch/conf/lang/userdict_ja.txt @@ -1,29 +1,29 @@ -# -# This is a sample user dictionary for Kuromoji (JapaneseTokenizer) -# -# Add entries to this file in order to override the statistical model in terms -# of segmentation, readings and part-of-speech tags. Notice that entries do -# not have weights since they are always used when found. This is by-design -# in order to maximize ease-of-use. -# -# Entries are defined using the following CSV format: -# , ... , ... , -# -# Notice that a single half-width space separates tokens and readings, and -# that the number tokens and readings must match exactly. -# -# Also notice that multiple entries with the same is undefined. -# -# Whitespace only lines are ignored. Comments are not allowed on entry lines. -# - -# Custom segmentation for kanji compounds -日本経済新聞,日本 経済 新聞,ニホン ケイザイ シンブン,カスタム名詞 -関西国際空港,関西 国際 空港,カンサイ コクサイ クウコウ,カスタム名詞 - -# Custom segmentation for compound katakana -トートバッグ,トート バッグ,トート バッグ,かずカナ名詞 -ショルダーバッグ,ショルダー バッグ,ショルダー バッグ,かずカナ名詞 - -# Custom reading for former sumo wrestler -朝青龍,朝青龍,アサショウリュウ,カスタム人名 +# +# This is a sample user dictionary for Kuromoji (JapaneseTokenizer) +# +# Add entries to this file in order to override the statistical model in terms +# of segmentation, readings and part-of-speech tags. Notice that entries do +# not have weights since they are always used when found. This is by-design +# in order to maximize ease-of-use. +# +# Entries are defined using the following CSV format: +# , ... , ... , +# +# Notice that a single half-width space separates tokens and readings, and +# that the number tokens and readings must match exactly. +# +# Also notice that multiple entries with the same is undefined. +# +# Whitespace only lines are ignored. Comments are not allowed on entry lines. +# + +# Custom segmentation for kanji compounds +日本経済新聞,日本 経済 新聞,ニホン ケイザイ シンブン,カスタム名詞 +関西国際空港,関西 国際 空港,カンサイ コクサイ クウコウ,カスタム名詞 + +# Custom segmentation for compound katakana +トートバッグ,トート バッグ,トート バッグ,かずカナ名詞 +ショルダーバッグ,ショルダー バッグ,ショルダー バッグ,かずカナ名詞 + +# Custom reading for former sumo wrestler +朝青龍,朝青龍,アサショウリュウ,カスタム人名 diff --git a/resources/cache/empty/websearch/conf/params.json b/resources/cache/empty/websearch/conf/params.json index abf4154e..9c259db5 100644 --- a/resources/cache/empty/websearch/conf/params.json +++ b/resources/cache/empty/websearch/conf/params.json @@ -1,20 +1,20 @@ -{"params":{ - "query":{ - "defType":"edismax", - "q.alt":"*:*", - "rows":"10", - "fl":"*,score", - "":{"v":0} - }, - "facets":{ - "facet":"on", - "facet.mincount": "1", - "":{"v":0} - }, - "velocity":{ - "wt": "velocity", - "v.template":"browse", - "v.layout": "layout", - "":{"v":0} - } -}} +{"params":{ + "query":{ + "defType":"edismax", + "q.alt":"*:*", + "rows":"10", + "fl":"*,score", + "":{"v":0} + }, + "facets":{ + "facet":"on", + "facet.mincount": "1", + "":{"v":0} + }, + "velocity":{ + "wt": "velocity", + "v.template":"browse", + "v.layout": "layout", + "":{"v":0} + } +}} diff --git a/resources/cache/empty/websearch/conf/protwords.txt b/resources/cache/empty/websearch/conf/protwords.txt index 5a32e503..1dfc0abe 100644 --- a/resources/cache/empty/websearch/conf/protwords.txt +++ b/resources/cache/empty/websearch/conf/protwords.txt @@ -1,21 +1,21 @@ -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#----------------------------------------------------------------------- -# Use a protected word file to protect against the stemmer reducing two -# unrelated words to the same base word. - -# Some non-words that normally won't be encountered, -# just to test that they won't be stemmed. -dontstems -zwhacky - +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#----------------------------------------------------------------------- +# Use a protected word file to protect against the stemmer reducing two +# unrelated words to the same base word. + +# Some non-words that normally won't be encountered, +# just to test that they won't be stemmed. +dontstems +zwhacky + diff --git a/resources/cache/empty/websearch/conf/schema.xml b/resources/cache/empty/websearch/conf/schema.xml index 20a5ffec..b912c154 100644 --- a/resources/cache/empty/websearch/conf/schema.xml +++ b/resources/cache/empty/websearch/conf/schema.xml @@ -1,240 +1,240 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - id - - id - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id + + id + + + diff --git a/resources/cache/empty/websearch/conf/solrconfig.xml b/resources/cache/empty/websearch/conf/solrconfig.xml index 7e8babdf..a99f9628 100644 --- a/resources/cache/empty/websearch/conf/solrconfig.xml +++ b/resources/cache/empty/websearch/conf/solrconfig.xml @@ -1,1949 +1,1949 @@ - - - - - - - - - 4.10.4 - - - - - - - - - - - - - - - - - - - - - - ${solr.data.dir:} - - - - - - - - - ${solr.hdfs.home:} - - ${solr.hdfs.confdir:} - - ${solr.hdfs.blockcache.enabled:true} - - ${solr.hdfs.blockcache.global:true} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${solr.lock.type:native} - - - - - - - - - - - - - - - - - - - - - - true - - - false - - - - - - - - - - - - - - - - ${solr.ulog.dir:} - - - - - ${solr.autoCommit.maxTime:15000} - false - - - - - - ${solr.autoSoftCommit.maxTime:-1} - - - - - - - - - - - - - - - - - - 1024 - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - 20 - - - 200 - - - - - - - - - - - - static firstSearcher warming in solrconfig.xml - - - - - - false - - - 2 - - - - - - - - - - - - - - - - - - - - - - - explicit - 10 - text - - - - - - - - - - on - content features title name - true - html - <b> - </b> - 0 - title - - 3 - 200 - content - 750 - - - on - false - 5 - 2 - 5 - true - true - 5 - 3 - - - - - - explicit - json - true - text - - - - - - - - true - json - true - - - - - - - - {!xport} - xsort - false - - - - query - - - - - - - - - - - - explicit - - - velocity - browse - layout - Solritas - - - edismax - - text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 - title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0 - - text - 100% - *:* - 10 - *,score - - - text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 - title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0 - - text,features,name,sku,id,manu,cat,title,description,keywords,author,resourcename - 3 - - - on - true - cat - person - location - organisations - ipod - GB - 1 - cat,inStock - after - price - 0 - 600 - 50 - popularity - 0 - 10 - 3 - manufacturedate_dt - NOW/YEAR-10YEARS - NOW - +1YEAR - before - after - - - on - content features title name - true - html - <b> - </b> - 0 - title - - 3 - 200 - content - 750 - - - on - false - 5 - 2 - 5 - true - true - 5 - 3 - - - - - spellcheck - - - - - - - - - - - - - - - - last_modified - true - - ignored_ - - - true - links - jate_text_field - true - ignored_ - - - langid - - - - - - yyyy-MM-dd hh:mm:ss - - - - - - - - - - - - - - - - - - - - - - solrpingquery - - - all - - - - - - - - - explicit - true - - - - - - - - - - - - - - - - text_general - - - - - - default - text - solr.DirectSolrSpellChecker - - internal - - 0.5 - - 2 - - 1 - - 5 - - 4 - - 0.01 - - - - - - wordbreak - solr.WordBreakSolrSpellChecker - name - true - true - 10 - - - - - - - - - - - - - - - - text - - default - wordbreak - on - true - 10 - 5 - 5 - true - true - 10 - 5 - - - spellcheck - - - - - - - - - - - - text - true - - - tvComponent - - - - - - - lingo - - - org.carrot2.clustering.lingo.LingoClusteringAlgorithm - - - clustering/carrot2 - - - - - stc - org.carrot2.clustering.stc.STCClusteringAlgorithm - - - - - kmeans - org.carrot2.clustering.kmeans.BisectingKMeansClusteringAlgorithm - - - - - - - true - true - - name - - id - - features - - true - - - - false - - - edismax - - text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 - - *:* - 10 - *,score - - - clustering - - - - - - - - - - true - false - - - terms - - - - - - - - string - elevate.xml - - - - - - explicit - text - - - elevator - - - - - - - - - - - 100 - - - - - - - - 70 - - 0.5 - - [-\w ,/\n\"']{20,200} - - - - - - - ]]> - ]]> - - - - - - - - - - - - - - - - - - - - - - - - ,, - ,, - ,, - ,, - ,]]> - ]]> - - - - - - 10 - .,!? - - - - - - - WORD - - - en - US - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/plain; charset=UTF-8 - - - - - - - - - 5 - - - - - - - - - - - - - - - - - - *:* - - - + + + + + + + + + 4.10.4 + + + + + + + + + + + + + + + + + + + + + + ${solr.data.dir:} + + + + + + + + + ${solr.hdfs.home:} + + ${solr.hdfs.confdir:} + + ${solr.hdfs.blockcache.enabled:true} + + ${solr.hdfs.blockcache.global:true} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${solr.lock.type:native} + + + + + + + + + + + + + + + + + + + + + + true + + + false + + + + + + + + + + + + + + + + ${solr.ulog.dir:} + + + + + ${solr.autoCommit.maxTime:15000} + false + + + + + + ${solr.autoSoftCommit.maxTime:-1} + + + + + + + + + + + + + + + + + + 1024 + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + 20 + + + 200 + + + + + + + + + + + + static firstSearcher warming in solrconfig.xml + + + + + + false + + + 2 + + + + + + + + + + + + + + + + + + + + + + + explicit + 10 + text + + + + + + + + + + on + content features title name + true + html + <b> + </b> + 0 + title + + 3 + 200 + content + 750 + + + on + false + 5 + 2 + 5 + true + true + 5 + 3 + + + + + + explicit + json + true + text + + + + + + + + true + json + true + + + + + + + + {!xport} + xsort + false + + + + query + + + + + + + + + + + + explicit + + + velocity + browse + layout + Solritas + + + edismax + + text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 + title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0 + + text + 100% + *:* + 10 + *,score + + + text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 + title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0 + + text,features,name,sku,id,manu,cat,title,description,keywords,author,resourcename + 3 + + + on + true + cat + person + location + organisations + ipod + GB + 1 + cat,inStock + after + price + 0 + 600 + 50 + popularity + 0 + 10 + 3 + manufacturedate_dt + NOW/YEAR-10YEARS + NOW + +1YEAR + before + after + + + on + content features title name + true + html + <b> + </b> + 0 + title + + 3 + 200 + content + 750 + + + on + false + 5 + 2 + 5 + true + true + 5 + 3 + + + + + spellcheck + + + + + + + + + + + + + + + + last_modified + true + + ignored_ + + + true + links + jate_text_field + true + ignored_ + + + langid + + + + + + yyyy-MM-dd hh:mm:ss + + + + + + + + + + + + + + + + + + + + + + solrpingquery + + + all + + + + + + + + + explicit + true + + + + + + + + + + + + + + + + text_general + + + + + + default + text + solr.DirectSolrSpellChecker + + internal + + 0.5 + + 2 + + 1 + + 5 + + 4 + + 0.01 + + + + + + wordbreak + solr.WordBreakSolrSpellChecker + name + true + true + 10 + + + + + + + + + + + + + + + + text + + default + wordbreak + on + true + 10 + 5 + 5 + true + true + 10 + 5 + + + spellcheck + + + + + + + + + + + + text + true + + + tvComponent + + + + + + + lingo + + + org.carrot2.clustering.lingo.LingoClusteringAlgorithm + + + clustering/carrot2 + + + + + stc + org.carrot2.clustering.stc.STCClusteringAlgorithm + + + + + kmeans + org.carrot2.clustering.kmeans.BisectingKMeansClusteringAlgorithm + + + + + + + true + true + + name + + id + + features + + true + + + + false + + + edismax + + text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 + + *:* + 10 + *,score + + + clustering + + + + + + + + + + true + false + + + terms + + + + + + + + string + elevate.xml + + + + + + explicit + text + + + elevator + + + + + + + + + + + 100 + + + + + + + + 70 + + 0.5 + + [-\w ,/\n\"']{20,200} + + + + + + + ]]> + ]]> + + + + + + + + + + + + + + + + + + + + + + + + ,, + ,, + ,, + ,, + ,]]> + ]]> + + + + + + 10 + .,!? + + + + + + + WORD + + + en + US + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/plain; charset=UTF-8 + + + + + + + + + 5 + + + + + + + + + + + + + + + + + + *:* + + + diff --git a/resources/cache/empty/websearch/conf/stopwords.txt b/resources/cache/empty/websearch/conf/stopwords.txt index e525ab80..dacec479 100644 --- a/resources/cache/empty/websearch/conf/stopwords.txt +++ b/resources/cache/empty/websearch/conf/stopwords.txt @@ -1,188 +1,188 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -a -about -above -after -again -against -all -am -an -and -any -are -aren't -as -at -be -because -been -before -being -below -between -both -but -by -can't -cannot -could -couldn't -did -didn't -do -does -doesn't -doing -don't -down -during -each -few -for -from -further -had -hadn't -has -hasn't -have -haven't -having -he -he'd -he'll -he's -her -here -here's -hers -herself -him -himself -his -how -how's -i -i'd -i'll -i'm -i've -if -in -into -is -isn't -it -it's -its -itself -let's -me -more -most -mustn't -my -myself -no -nor -not -of -off -on -once -only -or -other -ought -our -ours -ourselves -out -over -own -same -shan't -she -she'd -she'll -she's -should -shouldn't -so -some -such -than -that -that's -the -their -theirs -them -themselves -then -there -there's -these -they -they'd -they'll -they're -they've -this -those -through -to -too -under -until -up -very -was -wasn't -we -we'd -we'll -we're -we've -were -weren't -what -what's -when -when's -where -where's -which -while -who -who's -whom -why -why's -with -won't -would -wouldn't -you -you'd -you'll -you're -you've -your -yours -yourself +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +a +about +above +after +again +against +all +am +an +and +any +are +aren't +as +at +be +because +been +before +being +below +between +both +but +by +can't +cannot +could +couldn't +did +didn't +do +does +doesn't +doing +don't +down +during +each +few +for +from +further +had +hadn't +has +hasn't +have +haven't +having +he +he'd +he'll +he's +her +here +here's +hers +herself +him +himself +his +how +how's +i +i'd +i'll +i'm +i've +if +in +into +is +isn't +it +it's +its +itself +let's +me +more +most +mustn't +my +myself +no +nor +not +of +off +on +once +only +or +other +ought +our +ours +ourselves +out +over +own +same +shan't +she +she'd +she'll +she's +should +shouldn't +so +some +such +than +that +that's +the +their +theirs +them +themselves +then +there +there's +these +they +they'd +they'll +they're +they've +this +those +through +to +too +under +until +up +very +was +wasn't +we +we'd +we'll +we're +we've +were +weren't +what +what's +when +when's +where +where's +which +while +who +who's +whom +why +why's +with +won't +would +wouldn't +you +you'd +you'll +you're +you've +your +yours +yourself yourselves \ No newline at end of file diff --git a/resources/cache/empty/websearch/conf/synonyms.txt b/resources/cache/empty/websearch/conf/synonyms.txt index f00294b0..7f721283 100644 --- a/resources/cache/empty/websearch/conf/synonyms.txt +++ b/resources/cache/empty/websearch/conf/synonyms.txt @@ -1,29 +1,29 @@ -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#----------------------------------------------------------------------- -#some test synonym mappings unlikely to appear in real input text -aaafoo => aaabar -bbbfoo => bbbfoo bbbbar -cccfoo => cccbar cccbaz -fooaaa,baraaa,bazaaa - -# Some synonym groups specific to this example -GB,gib,gigabyte,gigabytes -MB,mib,megabyte,megabytes -Television, Televisions, TV, TVs -#notice we use "gib" instead of "GiB" so any WordDelimiterFilter coming -#after us won't split it into two words. - -# Synonym mappings can be used for spelling correction too -pixima => pixma - +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#----------------------------------------------------------------------- +#some test synonym mappings unlikely to appear in real input text +aaafoo => aaabar +bbbfoo => bbbfoo bbbbar +cccfoo => cccbar cccbaz +fooaaa,baraaa,bazaaa + +# Some synonym groups specific to this example +GB,gib,gigabyte,gigabytes +MB,mib,megabyte,megabytes +Television, Televisions, TV, TVs +#notice we use "gib" instead of "GiB" so any WordDelimiterFilter coming +#after us won't split it into two words. + +# Synonym mappings can be used for spelling correction too +pixima => pixma + diff --git a/resources/cache/empty/websearch/core.properties b/resources/cache/empty/websearch/core.properties index 5cfdf545..52901b61 100644 --- a/resources/cache/empty/websearch/core.properties +++ b/resources/cache/empty/websearch/core.properties @@ -1,3 +1,3 @@ -#Written by CorePropertiesLocator -#Mon Sep 14 10:05:54 UTC 2015 -name=websearch +#Written by CorePropertiesLocator +#Mon Sep 14 10:05:54 UTC 2015 +name=websearch diff --git a/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LAny23Util.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LAny23Util.java index d4f30b11..eb80295a 100644 --- a/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LAny23Util.java +++ b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LAny23Util.java @@ -1,137 +1,137 @@ -package uk.ac.shef.oak.any23.extension.extractor; - -import org.apache.any23.extractor.html.DomUtils; -import org.w3c.dom.Node; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 30/10/12 - * Time: 09:42 - */ -public class LAny23Util { - - /** - * - * @param attributeName - * @return /@attributeName - */ - public static String appendAttributeToXPath(String attributeName){ - return "/@"+attributeName; - } - - /** - * - * @return /text() - */ - public static String appendTagTextValueToXPath(){ - return "/text()"; - } - - public static String appendArbitraryDocument(){ - return "/[this]"; - } - - /** - * source: - * http://stackoverflow.com/questions/5046174/get-xpath-from-the-org-w3c-dom-node - * http://lekkimworld.com/2007/06/19/building_xpath_expression_from_xml_node.html - * - * @param n - * @return - */ - /*public static String getFullXPath(Node n) { - // abort early - if (null == n) - return null; - - // declarations - Node parent = null; - Stack hierarchy = new Stack(); - StringBuffer buffer = new StringBuffer(); - - // push element on stack - hierarchy.push(n); - - switch (n.getNodeType()) { - case Node.ATTRIBUTE_NODE: - parent = ((Attr) n).getOwnerElement(); - break; - case Node.ELEMENT_NODE: - parent = n.getParentNode(); - break; - case Node.DOCUMENT_NODE: - parent = n.getParentNode(); - break; - default: - throw new IllegalStateException("Unexpected Node type" + n.getNodeType()); - } - - while (null != parent && parent.getNodeType() != Node.DOCUMENT_NODE) { - // push on stack - hierarchy.push(parent); - - // get parent of parent - parent = parent.getParentNode(); - } - - // construct xpath - Object obj = null; - while (!hierarchy.isEmpty() && null != (obj = hierarchy.pop())) { - Node node = (Node) obj; - boolean handled = false; - - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element e = (Element) node; - - // is this the root element? - if (buffer.length() == 0) { - // root element - simply append element name - buffer.append(node.getNodeName()); - } else { - // child element - append slash and element name - buffer.append("/"); - buffer.append(node.getNodeName()); - - if (node.hasAttributes()) { - // see if the element has a name or id attribute - if (e.hasAttribute("id")) { - // id attribute found - use that - buffer.append("[@id='" + e.getAttribute("id") + "']"); - handled = true; - } else if (e.hasAttribute("name")) { - // name attribute found - use that - buffer.append("[@name='" + e.getAttribute("name") + "']"); - handled = true; - } - } - - if (!handled) { - // no known attribute we could use - get sibling index - int prev_siblings = 1; - Node prev_sibling = node.getPreviousSibling(); - while (null != prev_sibling) { - if (prev_sibling.getNodeType() == node.getNodeType()) { - if (prev_sibling.getNodeName().equalsIgnoreCase( - node.getNodeName())) { - prev_siblings++; - } - } - prev_sibling = prev_sibling.getPreviousSibling(); - } - buffer.append("[" + prev_siblings + "]"); - } - } - } else if (node.getNodeType() == Node.ATTRIBUTE_NODE) { - buffer.append("/@"); - buffer.append(node.getNodeName()); - } - } - // return buffer - return buffer.toString(); - - }*/ - public static String getFullXPath(Node n){ - return DomUtils.getXPathForNode(n); - } - -} +package uk.ac.shef.oak.any23.extension.extractor; + +import org.apache.any23.extractor.html.DomUtils; +import org.w3c.dom.Node; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 30/10/12 + * Time: 09:42 + */ +public class LAny23Util { + + /** + * + * @param attributeName + * @return /@attributeName + */ + public static String appendAttributeToXPath(String attributeName){ + return "/@"+attributeName; + } + + /** + * + * @return /text() + */ + public static String appendTagTextValueToXPath(){ + return "/text()"; + } + + public static String appendArbitraryDocument(){ + return "/[this]"; + } + + /** + * source: + * http://stackoverflow.com/questions/5046174/get-xpath-from-the-org-w3c-dom-node + * http://lekkimworld.com/2007/06/19/building_xpath_expression_from_xml_node.html + * + * @param n + * @return + */ + /*public static String getFullXPath(Node n) { + // abort early + if (null == n) + return null; + + // declarations + Node parent = null; + Stack hierarchy = new Stack(); + StringBuffer buffer = new StringBuffer(); + + // push element on stack + hierarchy.push(n); + + switch (n.getNodeType()) { + case Node.ATTRIBUTE_NODE: + parent = ((Attr) n).getOwnerElement(); + break; + case Node.ELEMENT_NODE: + parent = n.getParentNode(); + break; + case Node.DOCUMENT_NODE: + parent = n.getParentNode(); + break; + default: + throw new IllegalStateException("Unexpected Node type" + n.getNodeType()); + } + + while (null != parent && parent.getNodeType() != Node.DOCUMENT_NODE) { + // push on stack + hierarchy.push(parent); + + // get parent of parent + parent = parent.getParentNode(); + } + + // construct xpath + Object obj = null; + while (!hierarchy.isEmpty() && null != (obj = hierarchy.pop())) { + Node node = (Node) obj; + boolean handled = false; + + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element e = (Element) node; + + // is this the root element? + if (buffer.length() == 0) { + // root element - simply append element name + buffer.append(node.getNodeName()); + } else { + // child element - append slash and element name + buffer.append("/"); + buffer.append(node.getNodeName()); + + if (node.hasAttributes()) { + // see if the element has a name or id attribute + if (e.hasAttribute("id")) { + // id attribute found - use that + buffer.append("[@id='" + e.getAttribute("id") + "']"); + handled = true; + } else if (e.hasAttribute("name")) { + // name attribute found - use that + buffer.append("[@name='" + e.getAttribute("name") + "']"); + handled = true; + } + } + + if (!handled) { + // no known attribute we could use - get sibling index + int prev_siblings = 1; + Node prev_sibling = node.getPreviousSibling(); + while (null != prev_sibling) { + if (prev_sibling.getNodeType() == node.getNodeType()) { + if (prev_sibling.getNodeName().equalsIgnoreCase( + node.getNodeName())) { + prev_siblings++; + } + } + prev_sibling = prev_sibling.getPreviousSibling(); + } + buffer.append("[" + prev_siblings + "]"); + } + } + } else if (node.getNodeType() == Node.ATTRIBUTE_NODE) { + buffer.append("/@"); + buffer.append(node.getNodeName()); + } + } + // return buffer + return buffer.toString(); + + }*/ + public static String getFullXPath(Node n){ + return DomUtils.getXPathForNode(n); + } + +} diff --git a/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LExtractorRegistry.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LExtractorRegistry.java index af28a568..c2110a9f 100644 --- a/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LExtractorRegistry.java +++ b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LExtractorRegistry.java @@ -1,141 +1,141 @@ -package uk.ac.shef.oak.any23.extension.extractor; - -import org.apache.any23.configuration.DefaultConfiguration; -import org.apache.any23.extractor.ExtractorFactory; -import org.apache.any23.extractor.ExtractorGroup; - -import java.util.*; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 30/10/12 - * Time: 10:56 - */ -public class LExtractorRegistry { - /** - * The instance. - */ - private static LExtractorRegistry instance = null; - - /** - * maps containing the related {@link org.apache.any23.extractor.ExtractorFactory} for each - * registered {@link org.apache.any23.extractor.Extractor}. - */ - private Map> factories = new HashMap>(); - - /** - * @return returns the {@link LExtractorRegistry} instance. - */ - public static LExtractorRegistry getInstance() { - // Thread-safe - synchronized (LExtractorRegistry.class) { - final DefaultConfiguration conf = DefaultConfiguration.singleton(); - if (instance == null) { - instance = new LExtractorRegistry(); - /*instance.register(RDFXMLExtractor.factory); - instance.register(TurtleExtractor.factory); - instance.register(NTriplesExtractor.factory); - instance.register(NQuadsExtractor.factory); - instance.register(TriXExtractor.factory);*/ - if(conf.getFlagProperty("any23.extraction.rdfa.programmatic")) { - instance.register(LRDFa11Extractor.factory); - } else { - //instance.register(RDFaExtractor.factory); - } - /*instance.register(HeadLinkExtractor.factory); - instance.register(LicenseExtractor.factory); - instance.register(TitleExtractor.factory); - instance.register(XFNExtractor.factory); - instance.register(ICBMExtractor.factory); - instance.register(AdrExtractor.factory); - instance.register(GeoExtractor.factory); - instance.register(HCalendarExtractor.factory); - instance.register(HCardExtractor.factory); - instance.register(HListingExtractor.factory); - instance.register(HResumeExtractor.factory); - instance.register(HReviewExtractor.factory); - instance.register(HRecipeExtractor.factory); - instance.register(SpeciesExtractor.factory); - instance.register(TurtleHTMLExtractor.factory);*/ - instance.register(LMicrodataExtractor.factory); - /*instance.register(CSVExtractor.factory); - if(conf.getFlagProperty("any23.extraction.head.meta")) { - instance.register(HTMLMetaExtractor.factory); - }*/ - } - } - return instance; - } - - /** - * Registers an {@link ExtractorFactory}. - * - * @param factory - * @throws IllegalArgumentException if trying to register a {@link ExtractorFactory} - * with a that already exists in the registry. - */ - public void register(ExtractorFactory factory) { - if (factories.containsKey(factory.getExtractorName())) { - throw new IllegalArgumentException(String.format("Extractor name clash: %s", - factory.getExtractorName())); - } - factories.put(factory.getExtractorName(), factory); - } - - /** - * - * Retrieves a {@link ExtractorFactory} given its name - * - * @param name of the desired factory - * @return the {@link ExtractorFactory} associated to the provided name - * @throws IllegalArgumentException if there is not a - * {@link ExtractorFactory} associated to the provided name. - */ - public ExtractorFactory getFactory(String name) { - if (!factories.containsKey(name)) { - throw new IllegalArgumentException("Unregistered extractor name: " + name); - } - return factories.get(name); - } - - /** - * @return an {@link org.apache.any23.extractor.ExtractorGroup} with all the registered - * {@link org.apache.any23.extractor.Extractor}. - */ - public ExtractorGroup getExtractorGroup() { - return getExtractorGroup(getAllNames()); - } - - /** - * Returns an {@link ExtractorGroup} containing the - * {@link ExtractorFactory} mathing the names provided as input. - * @param names a {@link java.util.List} containing the names of the desired {@link ExtractorFactory}. - * @return the extraction group. - */ - public ExtractorGroup getExtractorGroup(List names) { - List> members = new ArrayList>(names.size()); - for (String name : names) { - members.add(getFactory(name)); - } - return new ExtractorGroup(members); - } - - /** - * - * @param name of the {@link ExtractorFactory} - * @return true if is there a {@link ExtractorFactory} - * associated to the provided name. - */ - public boolean isRegisteredName(String name) { - return factories.containsKey(name); - } - - /** - * Returns the names of all registered extractors, sorted alphabetically. - */ - public List getAllNames() { - List result = new ArrayList(factories.keySet()); - Collections.sort(result); - return result; - } -} +package uk.ac.shef.oak.any23.extension.extractor; + +import org.apache.any23.configuration.DefaultConfiguration; +import org.apache.any23.extractor.ExtractorFactory; +import org.apache.any23.extractor.ExtractorGroup; + +import java.util.*; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 30/10/12 + * Time: 10:56 + */ +public class LExtractorRegistry { + /** + * The instance. + */ + private static LExtractorRegistry instance = null; + + /** + * maps containing the related {@link org.apache.any23.extractor.ExtractorFactory} for each + * registered {@link org.apache.any23.extractor.Extractor}. + */ + private Map> factories = new HashMap>(); + + /** + * @return returns the {@link LExtractorRegistry} instance. + */ + public static LExtractorRegistry getInstance() { + // Thread-safe + synchronized (LExtractorRegistry.class) { + final DefaultConfiguration conf = DefaultConfiguration.singleton(); + if (instance == null) { + instance = new LExtractorRegistry(); + /*instance.register(RDFXMLExtractor.factory); + instance.register(TurtleExtractor.factory); + instance.register(NTriplesExtractor.factory); + instance.register(NQuadsExtractor.factory); + instance.register(TriXExtractor.factory);*/ + if(conf.getFlagProperty("any23.extraction.rdfa.programmatic")) { + instance.register(LRDFa11Extractor.factory); + } else { + //instance.register(RDFaExtractor.factory); + } + /*instance.register(HeadLinkExtractor.factory); + instance.register(LicenseExtractor.factory); + instance.register(TitleExtractor.factory); + instance.register(XFNExtractor.factory); + instance.register(ICBMExtractor.factory); + instance.register(AdrExtractor.factory); + instance.register(GeoExtractor.factory); + instance.register(HCalendarExtractor.factory); + instance.register(HCardExtractor.factory); + instance.register(HListingExtractor.factory); + instance.register(HResumeExtractor.factory); + instance.register(HReviewExtractor.factory); + instance.register(HRecipeExtractor.factory); + instance.register(SpeciesExtractor.factory); + instance.register(TurtleHTMLExtractor.factory);*/ + instance.register(LMicrodataExtractor.factory); + /*instance.register(CSVExtractor.factory); + if(conf.getFlagProperty("any23.extraction.head.meta")) { + instance.register(HTMLMetaExtractor.factory); + }*/ + } + } + return instance; + } + + /** + * Registers an {@link ExtractorFactory}. + * + * @param factory + * @throws IllegalArgumentException if trying to register a {@link ExtractorFactory} + * with a that already exists in the registry. + */ + public void register(ExtractorFactory factory) { + if (factories.containsKey(factory.getExtractorName())) { + throw new IllegalArgumentException(String.format("Extractor name clash: %s", + factory.getExtractorName())); + } + factories.put(factory.getExtractorName(), factory); + } + + /** + * + * Retrieves a {@link ExtractorFactory} given its name + * + * @param name of the desired factory + * @return the {@link ExtractorFactory} associated to the provided name + * @throws IllegalArgumentException if there is not a + * {@link ExtractorFactory} associated to the provided name. + */ + public ExtractorFactory getFactory(String name) { + if (!factories.containsKey(name)) { + throw new IllegalArgumentException("Unregistered extractor name: " + name); + } + return factories.get(name); + } + + /** + * @return an {@link org.apache.any23.extractor.ExtractorGroup} with all the registered + * {@link org.apache.any23.extractor.Extractor}. + */ + public ExtractorGroup getExtractorGroup() { + return getExtractorGroup(getAllNames()); + } + + /** + * Returns an {@link ExtractorGroup} containing the + * {@link ExtractorFactory} mathing the names provided as input. + * @param names a {@link java.util.List} containing the names of the desired {@link ExtractorFactory}. + * @return the extraction group. + */ + public ExtractorGroup getExtractorGroup(List names) { + List> members = new ArrayList>(names.size()); + for (String name : names) { + members.add(getFactory(name)); + } + return new ExtractorGroup(members); + } + + /** + * + * @param name of the {@link ExtractorFactory} + * @return true if is there a {@link ExtractorFactory} + * associated to the provided name. + */ + public boolean isRegisteredName(String name) { + return factories.containsKey(name); + } + + /** + * Returns the names of all registered extractors, sorted alphabetically. + */ + public List getAllNames() { + List result = new ArrayList(factories.keySet()); + Collections.sort(result); + return result; + } +} diff --git a/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractor.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractor.java index e590fa3f..4d0f93a5 100644 --- a/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractor.java +++ b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractor.java @@ -1,608 +1,608 @@ -package uk.ac.shef.oak.any23.extension.extractor; - -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Arrays; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.print.attribute.standard.DateTimeAtCreation; - -import org.apache.any23.extractor.ExtractionContext; -import org.apache.any23.extractor.ExtractionException; -import org.apache.any23.extractor.ExtractionParameters; -import org.apache.any23.extractor.ExtractionResult; -import org.apache.any23.extractor.ExtractorDescription; -import org.apache.any23.extractor.ExtractorFactory; -import org.apache.any23.extractor.IssueReport; -import org.apache.any23.extractor.LExtractionResultImpl; -import org.apache.any23.extractor.SimpleExtractorFactory; -import org.apache.any23.extractor.html.DomUtils; -import org.apache.any23.extractor.microdata.ItemProp; -import org.apache.any23.extractor.microdata.ItemPropValue; -import org.apache.any23.extractor.microdata.ItemScope; -import org.apache.any23.extractor.microdata.MicrodataExtractor; -import org.apache.any23.extractor.microdata.MicrodataParser; -import org.apache.any23.extractor.microdata.MicrodataParserException; -import org.apache.any23.extractor.microdata.MicrodataParserReport; -import org.apache.any23.rdf.PopularPrefixes; -import org.apache.any23.rdf.RDFUtils; -import org.apache.any23.vocab.DCTerms; -import org.apache.any23.vocab.XHTML; -import org.openrdf.model.Literal; -import org.openrdf.model.Resource; -import org.openrdf.model.URI; -import org.openrdf.model.Value; -import org.openrdf.model.vocabulary.RDF; -import org.openrdf.model.vocabulary.XMLSchema; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - - -/** - * @author Anna Lisa Gentile (a.l.gentile@dcs.shef.ac.uk) - */ -public class LMicrodataExtractor extends MicrodataExtractor{ - - private static final URI MICRODATA_ITEM - = RDFUtils.uri("http://www.w3.org/1999/xhtml/microdata#item"); - - public final static ExtractorFactory factory = new LMicrodataExtractorFactory(); - - private String documentLanguage; - - private boolean isStrict; - - private String defaultNamespace; - - public ExtractorDescription getDescription() { - return factory; - } - - /** - * This extraction performs the - * Microdata to RDF conversion algorithm. - * A slight modification of the specification algorithm has been introduced - * to avoid performing actions 5.2.1, 5.2.2, 5.2.3, 5.2.4 if step 5.2.6 doesn't detect any - * Microdata. - */ - public void run( - ExtractionParameters extractionParameters, - ExtractionContext extractionContext, - Document in, - ExtractionResult outExtraction - ) throws IOException, ExtractionException { - - LExtractionResultImpl out = (LExtractionResultImpl)outExtraction; - - - final MicrodataParserReport parserReport = LMicrodataParser.getMicrodata(in); - if(parserReport.getErrors().length > 0) { - notifyError(parserReport.getErrors(), out); - } - final ItemScope[] itemScopes = parserReport.getDetectedItemScopes(); - if (itemScopes.length == 0) { - return; - } - - isStrict = extractionParameters.getFlag("any23.microdata.strict"); - if (!isStrict) { - defaultNamespace = extractionParameters.getProperty("any23.microdata.ns.default"); - } - - documentLanguage = getDocumentLanguage(in); - - /** - * 5.2.6 - */ - final URI documentURI = extractionContext.getDocumentURI(); - final Map mappings = new HashMap(); - for (ItemScope itemScope : itemScopes) { - - - Resource subject = processType(itemScope, documentURI, out, mappings); - //TODO check if this os the right way to do it - String s_Ctx =itemScope.getXpath(); - String p_Ctx =itemScope.getXpath(); - String o_Ctx =itemScope.getXpath(); - - //TODO replace writeTriple with a different method which also parse the context of the triple - out.writeTriple( - documentURI, - MICRODATA_ITEM, - subject,s_Ctx,p_Ctx,o_Ctx - ); - } - - /** - * 5.2.1 - */ - processTitle(in, documentURI, out); - /** - * 5.2.2 - */ - processHREFElements(in, documentURI, out); - /** - * 5.2.3 - */ - processMetaElements(in, documentURI, out); - - /** - * 5.2.4 - */ - processCiteElements(in, documentURI, out); - } - - /** - * Returns the {@link Document} language if declared, null otherwise. - * - * @param in a instance of {@link Document}. - * @return the language declared, could be null. - */ - private String getDocumentLanguage(Document in) { - String lang = DomUtils.find(in, "string(/HTML/@lang)"); - if (lang.equals("")) { - return null; - } - return lang; - } - - /** - * Returns the {@link Node} language if declared, or the {@link Document} one - * if not defined. - * - * @param node a {@link Node} instance. - * @return the {@link Node} language or the {@link Document} one. Could be null - */ - private String getLanguage(Node node) { - Node nodeLang = node.getAttributes().getNamedItem("lang"); - if (nodeLang == null) { - // if the element does not specify a lang, use the document one - return documentLanguage; - } - return nodeLang.getTextContent(); - } - - /** - * Implements step 5.2.1 of Microdata to RDF - * extraction algorithm. - * - * @param in {@link Document} to be processed. - * @param documentURI Document current {@link URI}. - * @param out a valid not null {@link ExtractionResult} - */ - private void processTitle(Document in, URI documentURI, ExtractionResult out) { - NodeList titles = in.getElementsByTagName("title"); - // just one title is allowed. - if (titles.getLength() == 1) { - Node title = titles.item(0); - String titleValue = title.getTextContent(); - Literal object; - String lang = getLanguage(title); - if (lang == null) { - // unable to decide the language, leave it unknown - object = RDFUtils.literal(titleValue); - } else { - object = RDFUtils.literal(titleValue, lang); - } - out.writeTriple( - documentURI, - DCTerms.getInstance().title, - object - ); - } - } - - /** - * Implements step 5.2.2 of Microdata to RDF - * extraction algorithm. - * - * @param in {@link Document} to be processed. - * @param documentURI Document current {@link URI}. - * @param out a valid not null {@link ExtractionResult} - */ - private void processHREFElements(Document in, URI documentURI, ExtractionResult out) { - NodeList anchors = in.getElementsByTagName("a"); - for (int i = 0; i < anchors.getLength(); i++) { - processHREFElement(anchors.item(i), documentURI, out); - } - NodeList areas = in.getElementsByTagName("area"); - for (int i = 0; i < areas.getLength(); i++) { - processHREFElement(areas.item(i), documentURI, out); - } - NodeList links = in.getElementsByTagName("link"); - for (int i = 0; i < links.getLength(); i++) { - processHREFElement(links.item(i), documentURI, out); - } - } - - /** - * Implements sub-step for 5.2.3 of Microdata to RDF - * extraction algorithm. - * - * @param item {@link Node} to be processed. - * @param documentURI Document current {@link URI}. - * @param out a valid not null {@link ExtractionResult} - */ - private void processHREFElement(Node item, URI documentURI, ExtractionResult out) { - Node rel = item.getAttributes().getNamedItem("rel"); - if (rel == null) { - return; - } - Node href = item.getAttributes().getNamedItem("href"); - if (href == null) { - return; - } - URL absoluteURL; - if (!isAbsoluteURL(href.getTextContent())) { - try { - absoluteURL = toAbsoluteURL( - documentURI.toString(), - href.getTextContent(), - '/' - ); - } catch (MalformedURLException e) { - // okay, it's not an absolute URL, return - return; - } - } else { - try { - absoluteURL = new URL(href.getTextContent()); - } catch (MalformedURLException e) { - // cannot happen - return; - } - } - String[] relTokens = rel.getTextContent().split(" "); - Set tokensWithNoDuplicates = new HashSet(); - for (String relToken : relTokens) { - if (relToken.contains(":")) { - // if contain semi-colon, skip - continue; - } - if (relToken.equals("alternate") || relToken.equals("stylesheet")) { - tokensWithNoDuplicates.add("ALTERNATE-STYLESHEET"); - continue; - } - tokensWithNoDuplicates.add(relToken.toLowerCase()); - } - for (String token : tokensWithNoDuplicates) { - URI predicate; - if (isAbsoluteURL(token)) { - predicate = RDFUtils.uri(token); - } else { - predicate = RDFUtils.uri(XHTML.NS + token); - } - out.writeTriple( - documentURI, - predicate, - RDFUtils.uri(absoluteURL.toString()) - ); - } - } - - /** - * Implements step 5.2.3 of Microdata to RDF - * extraction algorithm. - * - * @param in {@link Document} to be processed. - * @param documentURI Document current {@link URI}. - * @param out a valid not null {@link ExtractionResult} - */ - private void processMetaElements(Document in, URI documentURI, ExtractionResult out) { - NodeList metas = in.getElementsByTagName("meta"); - for (int i = 0; i < metas.getLength(); i++) { - Node meta = metas.item(i); - String name = DomUtils.readAttribute(meta, "name" , null); - String content = DomUtils.readAttribute(meta, "content", null); - if (name != null && content != null) { - if (isAbsoluteURL(name)) { - processMetaElement( - RDFUtils.uri(name), - content, - getLanguage(meta), - documentURI, - out - ); - } else { - processMetaElement( - name, - content, - getLanguage(meta), - documentURI, - out - ); - } - } - } - } - - /** - * Implements sub step for 5.2.3 of Microdata to RDF - * extraction algorithm. - * - * @param uri - * @param content - * @param language - * @param documentURI - * @param out - */ - private void processMetaElement( - URI uri, - String content, - String language, - URI documentURI, - ExtractionResult out - ) { - if (content.contains(":")) { - // if it contains U+003A COLON, exit - return; - } - Literal subject; - if (language == null) { - // ok, we don't know the language - subject = RDFUtils.literal(content); - } else { - subject = RDFUtils.literal(content, language); - } - out.writeTriple( - documentURI, - uri, - subject - ); - } - - /** - * Implements sub step for 5.2.3 of Microdata to RDF - * extraction algorithm. - * - * @param name - * @param content - * @param language - * @param documentURI - * @param out - */ - private void processMetaElement( - String name, - String content, - String language, - URI documentURI, - ExtractionResult out) { - Literal subject; - if (language == null) { - // ok, we don't know the language - subject = RDFUtils.literal(content); - } else { - subject = RDFUtils.literal(content, language); - } - out.writeTriple( - documentURI, - RDFUtils.uri(XHTML.NS + name.toLowerCase()), - subject - ); - } - - /** - * Implements sub step for 5.2.4 of Microdata to RDF - * extraction algorithm. - * - * @param in - * @param documentURI - * @param out - */ - private void processCiteElements(Document in, URI documentURI, ExtractionResult out) { - NodeList blockQuotes = in.getElementsByTagName("blockquote"); - for (int i = 0; i < blockQuotes.getLength(); i++) { - processCiteElement(blockQuotes.item(i), documentURI, out); - } - NodeList quotes = in.getElementsByTagName("q"); - for (int i = 0; i < quotes.getLength(); i++) { - processCiteElement(quotes.item(i), documentURI, out); - } - } - - private void processCiteElement(Node item, URI documentURI, ExtractionResult out) { - if (item.getAttributes().getNamedItem("cite") != null) { - out.writeTriple( - documentURI, - DCTerms.getInstance().source, - RDFUtils.uri(item.getAttributes().getNamedItem("cite").getTextContent()) - ); - } - } - - - /** - * Recursive method implementing 5.2.6.1 "generate the triple for the item" of - * Microdata to RDF - * extraction algorithm. - * - * @param itemScope - * @param documentURI - * @param out - * @param mappings - * @return - * @throws ExtractionException - */ - private Resource processType( - ItemScope itemScope, - URI documentURI, LExtractionResultImpl out, - Map mappings - ) throws ExtractionException { - Resource subject; - - if (mappings.containsKey(itemScope)) { - subject = mappings.get(itemScope); - } else if (isAbsoluteURL(itemScope.getItemId())) { - subject = RDFUtils.uri(itemScope.getItemId()); - } else { - subject = RDFUtils.getBNode(Integer.toString(itemScope.hashCode())); - } - mappings.put(itemScope, subject); - - // ItemScope.type could be null, but surely it's a valid URL - String itemScopeType = ""; - String itemXpath = ""; - - if (itemScope.getType() != null) { - String itemType; - itemType = itemScope.getType().toString(); - //Annalisa added this - itemXpath=itemScope.getXpath().toString(); - - //TODO check if context is correct - out.writeTriple(subject, RDF.TYPE, RDFUtils.uri(itemType), itemXpath, "", ""); - itemScopeType = itemScope.getType().toString(); - } - for (String propName : itemScope.getProperties().keySet()) { - List itemProps = itemScope.getProperties().get(propName); - for (ItemProp itemProp : itemProps) { - try { - processProperty( - subject, - itemXpath, - propName, - itemProp, - itemScopeType, - documentURI, - mappings, - out - ); - } catch (MalformedURLException e) { - throw new ExtractionException( - "Error while processing on subject '" + subject + - "' the itemProp: '" + itemProp + "' " - ); - } - } - } - return subject; - } - - - - - - - private void processProperty( - Resource subject,String subjectXpath, - String propName, - ItemProp itemProp, - String itemScopeType, - URI documentURI, - Map mappings, - LExtractionResultImpl out - ) throws MalformedURLException, ExtractionException { - - //predicate - URI predicate; - if (!isAbsoluteURL(propName) && itemScopeType.equals("") && isStrict) { - return; - } else if (!isAbsoluteURL(propName) && itemScopeType.equals("") && !isStrict) { - predicate = RDFUtils.uri( - toAbsoluteURL( - defaultNamespace, - propName, - '/' - ).toString() - ); - } else { - predicate = RDFUtils.uri( - toAbsoluteURL( - itemScopeType, - propName, - '/' - ).toString()); - } - - - - //value - Value value; - Object propValue = itemProp.getValue().getContent(); - - String propValueXpath = itemProp.getXpath().toString(); - - ItemPropValue.Type propType = itemProp.getValue().getType(); - if (propType.equals(ItemPropValue.Type.Nested)) { - value = processType((ItemScope) propValue, documentURI, out, mappings); - } else if (propType.equals(ItemPropValue.Type.Plain)) { - value = RDFUtils.literal((String) propValue, documentLanguage); - propValueXpath = propValueXpath+LAny23Util.appendTagTextValueToXPath(); - } else if (propType.equals(ItemPropValue.Type.Link)) { - value = RDFUtils.uri( - toAbsoluteURL( - documentURI.toString(), - (String) propValue, - '/' - ).toString() - ); - - propValueXpath = propValueXpath+LAny23Util.appendAttributeToXPath("href"); - - } else if (propType.equals(ItemPropValue.Type.Date)) { - value = RDFUtils.literal(ItemPropValue.formatDateTime((Date) propValue), XMLSchema.DATE); - //TODO check if it is the correct attribute - propValueXpath = propValueXpath+LAny23Util.appendAttributeToXPath("datetime"); - - } else { - throw new RuntimeException("Invalid Type '" + - propType + "' for ItemPropValue with name: '" + propName + "'"); - } - - - String sCxt=subjectXpath; - - - String pCxt=itemProp.getXpath()+LAny23Util.appendAttributeToXPath("itemprop"); - String oCxt=propValueXpath; - - //TODO populate context - - - //TODO check integrity - out.writeTriple(subject, predicate, value, sCxt, pCxt, oCxt); - } - - private boolean isAbsoluteURL(String urlString) { - boolean result = false; - try { - URL url = new URL(urlString); - String protocol = url.getProtocol(); - if (protocol != null && protocol.trim().length() > 0) - result = true; - } catch (MalformedURLException e) { - return false; - } - return result; - } - - private URL toAbsoluteURL(String ns, String part, char trailing) - throws MalformedURLException { - if (isAbsoluteURL(part)) { - return new URL(part); - } - char lastChar = ns.charAt(ns.length() - 1); - if (lastChar == '#' || lastChar == '/') - return new URL(ns + part); - return new URL(ns + trailing + part); - } - - private void notifyError(MicrodataParserException[] errors, ExtractionResult out) { - for(MicrodataParserException mpe : errors) { - out.notifyIssue( - IssueReport.IssueLevel.Error, - mpe.toJSON(), - mpe.getErrorLocationBeginRow(), - mpe.getErrorLocationBeginCol() - ); - } - } - -} +package uk.ac.shef.oak.any23.extension.extractor; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.print.attribute.standard.DateTimeAtCreation; + +import org.apache.any23.extractor.ExtractionContext; +import org.apache.any23.extractor.ExtractionException; +import org.apache.any23.extractor.ExtractionParameters; +import org.apache.any23.extractor.ExtractionResult; +import org.apache.any23.extractor.ExtractorDescription; +import org.apache.any23.extractor.ExtractorFactory; +import org.apache.any23.extractor.IssueReport; +import org.apache.any23.extractor.LExtractionResultImpl; +import org.apache.any23.extractor.SimpleExtractorFactory; +import org.apache.any23.extractor.html.DomUtils; +import org.apache.any23.extractor.microdata.ItemProp; +import org.apache.any23.extractor.microdata.ItemPropValue; +import org.apache.any23.extractor.microdata.ItemScope; +import org.apache.any23.extractor.microdata.MicrodataExtractor; +import org.apache.any23.extractor.microdata.MicrodataParser; +import org.apache.any23.extractor.microdata.MicrodataParserException; +import org.apache.any23.extractor.microdata.MicrodataParserReport; +import org.apache.any23.rdf.PopularPrefixes; +import org.apache.any23.rdf.RDFUtils; +import org.apache.any23.vocab.DCTerms; +import org.apache.any23.vocab.XHTML; +import org.openrdf.model.Literal; +import org.openrdf.model.Resource; +import org.openrdf.model.URI; +import org.openrdf.model.Value; +import org.openrdf.model.vocabulary.RDF; +import org.openrdf.model.vocabulary.XMLSchema; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + + +/** + * @author Anna Lisa Gentile (a.l.gentile@dcs.shef.ac.uk) + */ +public class LMicrodataExtractor extends MicrodataExtractor{ + + private static final URI MICRODATA_ITEM + = RDFUtils.uri("http://www.w3.org/1999/xhtml/microdata#item"); + + public final static ExtractorFactory factory = new LMicrodataExtractorFactory(); + + private String documentLanguage; + + private boolean isStrict; + + private String defaultNamespace; + + public ExtractorDescription getDescription() { + return factory; + } + + /** + * This extraction performs the + * Microdata to RDF conversion algorithm. + * A slight modification of the specification algorithm has been introduced + * to avoid performing actions 5.2.1, 5.2.2, 5.2.3, 5.2.4 if step 5.2.6 doesn't detect any + * Microdata. + */ + public void run( + ExtractionParameters extractionParameters, + ExtractionContext extractionContext, + Document in, + ExtractionResult outExtraction + ) throws IOException, ExtractionException { + + LExtractionResultImpl out = (LExtractionResultImpl)outExtraction; + + + final MicrodataParserReport parserReport = LMicrodataParser.getMicrodata(in); + if(parserReport.getErrors().length > 0) { + notifyError(parserReport.getErrors(), out); + } + final ItemScope[] itemScopes = parserReport.getDetectedItemScopes(); + if (itemScopes.length == 0) { + return; + } + + isStrict = extractionParameters.getFlag("any23.microdata.strict"); + if (!isStrict) { + defaultNamespace = extractionParameters.getProperty("any23.microdata.ns.default"); + } + + documentLanguage = getDocumentLanguage(in); + + /** + * 5.2.6 + */ + final URI documentURI = extractionContext.getDocumentURI(); + final Map mappings = new HashMap(); + for (ItemScope itemScope : itemScopes) { + + + Resource subject = processType(itemScope, documentURI, out, mappings); + //TODO check if this os the right way to do it + String s_Ctx =itemScope.getXpath(); + String p_Ctx =itemScope.getXpath(); + String o_Ctx =itemScope.getXpath(); + + //TODO replace writeTriple with a different method which also parse the context of the triple + out.writeTriple( + documentURI, + MICRODATA_ITEM, + subject,s_Ctx,p_Ctx,o_Ctx + ); + } + + /** + * 5.2.1 + */ + processTitle(in, documentURI, out); + /** + * 5.2.2 + */ + processHREFElements(in, documentURI, out); + /** + * 5.2.3 + */ + processMetaElements(in, documentURI, out); + + /** + * 5.2.4 + */ + processCiteElements(in, documentURI, out); + } + + /** + * Returns the {@link Document} language if declared, null otherwise. + * + * @param in a instance of {@link Document}. + * @return the language declared, could be null. + */ + private String getDocumentLanguage(Document in) { + String lang = DomUtils.find(in, "string(/HTML/@lang)"); + if (lang.equals("")) { + return null; + } + return lang; + } + + /** + * Returns the {@link Node} language if declared, or the {@link Document} one + * if not defined. + * + * @param node a {@link Node} instance. + * @return the {@link Node} language or the {@link Document} one. Could be null + */ + private String getLanguage(Node node) { + Node nodeLang = node.getAttributes().getNamedItem("lang"); + if (nodeLang == null) { + // if the element does not specify a lang, use the document one + return documentLanguage; + } + return nodeLang.getTextContent(); + } + + /** + * Implements step 5.2.1 of Microdata to RDF + * extraction algorithm. + * + * @param in {@link Document} to be processed. + * @param documentURI Document current {@link URI}. + * @param out a valid not null {@link ExtractionResult} + */ + private void processTitle(Document in, URI documentURI, ExtractionResult out) { + NodeList titles = in.getElementsByTagName("title"); + // just one title is allowed. + if (titles.getLength() == 1) { + Node title = titles.item(0); + String titleValue = title.getTextContent(); + Literal object; + String lang = getLanguage(title); + if (lang == null) { + // unable to decide the language, leave it unknown + object = RDFUtils.literal(titleValue); + } else { + object = RDFUtils.literal(titleValue, lang); + } + out.writeTriple( + documentURI, + DCTerms.getInstance().title, + object + ); + } + } + + /** + * Implements step 5.2.2 of Microdata to RDF + * extraction algorithm. + * + * @param in {@link Document} to be processed. + * @param documentURI Document current {@link URI}. + * @param out a valid not null {@link ExtractionResult} + */ + private void processHREFElements(Document in, URI documentURI, ExtractionResult out) { + NodeList anchors = in.getElementsByTagName("a"); + for (int i = 0; i < anchors.getLength(); i++) { + processHREFElement(anchors.item(i), documentURI, out); + } + NodeList areas = in.getElementsByTagName("area"); + for (int i = 0; i < areas.getLength(); i++) { + processHREFElement(areas.item(i), documentURI, out); + } + NodeList links = in.getElementsByTagName("link"); + for (int i = 0; i < links.getLength(); i++) { + processHREFElement(links.item(i), documentURI, out); + } + } + + /** + * Implements sub-step for 5.2.3 of Microdata to RDF + * extraction algorithm. + * + * @param item {@link Node} to be processed. + * @param documentURI Document current {@link URI}. + * @param out a valid not null {@link ExtractionResult} + */ + private void processHREFElement(Node item, URI documentURI, ExtractionResult out) { + Node rel = item.getAttributes().getNamedItem("rel"); + if (rel == null) { + return; + } + Node href = item.getAttributes().getNamedItem("href"); + if (href == null) { + return; + } + URL absoluteURL; + if (!isAbsoluteURL(href.getTextContent())) { + try { + absoluteURL = toAbsoluteURL( + documentURI.toString(), + href.getTextContent(), + '/' + ); + } catch (MalformedURLException e) { + // okay, it's not an absolute URL, return + return; + } + } else { + try { + absoluteURL = new URL(href.getTextContent()); + } catch (MalformedURLException e) { + // cannot happen + return; + } + } + String[] relTokens = rel.getTextContent().split(" "); + Set tokensWithNoDuplicates = new HashSet(); + for (String relToken : relTokens) { + if (relToken.contains(":")) { + // if contain semi-colon, skip + continue; + } + if (relToken.equals("alternate") || relToken.equals("stylesheet")) { + tokensWithNoDuplicates.add("ALTERNATE-STYLESHEET"); + continue; + } + tokensWithNoDuplicates.add(relToken.toLowerCase()); + } + for (String token : tokensWithNoDuplicates) { + URI predicate; + if (isAbsoluteURL(token)) { + predicate = RDFUtils.uri(token); + } else { + predicate = RDFUtils.uri(XHTML.NS + token); + } + out.writeTriple( + documentURI, + predicate, + RDFUtils.uri(absoluteURL.toString()) + ); + } + } + + /** + * Implements step 5.2.3 of Microdata to RDF + * extraction algorithm. + * + * @param in {@link Document} to be processed. + * @param documentURI Document current {@link URI}. + * @param out a valid not null {@link ExtractionResult} + */ + private void processMetaElements(Document in, URI documentURI, ExtractionResult out) { + NodeList metas = in.getElementsByTagName("meta"); + for (int i = 0; i < metas.getLength(); i++) { + Node meta = metas.item(i); + String name = DomUtils.readAttribute(meta, "name" , null); + String content = DomUtils.readAttribute(meta, "content", null); + if (name != null && content != null) { + if (isAbsoluteURL(name)) { + processMetaElement( + RDFUtils.uri(name), + content, + getLanguage(meta), + documentURI, + out + ); + } else { + processMetaElement( + name, + content, + getLanguage(meta), + documentURI, + out + ); + } + } + } + } + + /** + * Implements sub step for 5.2.3 of Microdata to RDF + * extraction algorithm. + * + * @param uri + * @param content + * @param language + * @param documentURI + * @param out + */ + private void processMetaElement( + URI uri, + String content, + String language, + URI documentURI, + ExtractionResult out + ) { + if (content.contains(":")) { + // if it contains U+003A COLON, exit + return; + } + Literal subject; + if (language == null) { + // ok, we don't know the language + subject = RDFUtils.literal(content); + } else { + subject = RDFUtils.literal(content, language); + } + out.writeTriple( + documentURI, + uri, + subject + ); + } + + /** + * Implements sub step for 5.2.3 of Microdata to RDF + * extraction algorithm. + * + * @param name + * @param content + * @param language + * @param documentURI + * @param out + */ + private void processMetaElement( + String name, + String content, + String language, + URI documentURI, + ExtractionResult out) { + Literal subject; + if (language == null) { + // ok, we don't know the language + subject = RDFUtils.literal(content); + } else { + subject = RDFUtils.literal(content, language); + } + out.writeTriple( + documentURI, + RDFUtils.uri(XHTML.NS + name.toLowerCase()), + subject + ); + } + + /** + * Implements sub step for 5.2.4 of Microdata to RDF + * extraction algorithm. + * + * @param in + * @param documentURI + * @param out + */ + private void processCiteElements(Document in, URI documentURI, ExtractionResult out) { + NodeList blockQuotes = in.getElementsByTagName("blockquote"); + for (int i = 0; i < blockQuotes.getLength(); i++) { + processCiteElement(blockQuotes.item(i), documentURI, out); + } + NodeList quotes = in.getElementsByTagName("q"); + for (int i = 0; i < quotes.getLength(); i++) { + processCiteElement(quotes.item(i), documentURI, out); + } + } + + private void processCiteElement(Node item, URI documentURI, ExtractionResult out) { + if (item.getAttributes().getNamedItem("cite") != null) { + out.writeTriple( + documentURI, + DCTerms.getInstance().source, + RDFUtils.uri(item.getAttributes().getNamedItem("cite").getTextContent()) + ); + } + } + + + /** + * Recursive method implementing 5.2.6.1 "generate the triple for the item" of + * Microdata to RDF + * extraction algorithm. + * + * @param itemScope + * @param documentURI + * @param out + * @param mappings + * @return + * @throws ExtractionException + */ + private Resource processType( + ItemScope itemScope, + URI documentURI, LExtractionResultImpl out, + Map mappings + ) throws ExtractionException { + Resource subject; + + if (mappings.containsKey(itemScope)) { + subject = mappings.get(itemScope); + } else if (isAbsoluteURL(itemScope.getItemId())) { + subject = RDFUtils.uri(itemScope.getItemId()); + } else { + subject = RDFUtils.getBNode(Integer.toString(itemScope.hashCode())); + } + mappings.put(itemScope, subject); + + // ItemScope.type could be null, but surely it's a valid URL + String itemScopeType = ""; + String itemXpath = ""; + + if (itemScope.getType() != null) { + String itemType; + itemType = itemScope.getType().toString(); + //Annalisa added this + itemXpath=itemScope.getXpath().toString(); + + //TODO check if context is correct + out.writeTriple(subject, RDF.TYPE, RDFUtils.uri(itemType), itemXpath, "", ""); + itemScopeType = itemScope.getType().toString(); + } + for (String propName : itemScope.getProperties().keySet()) { + List itemProps = itemScope.getProperties().get(propName); + for (ItemProp itemProp : itemProps) { + try { + processProperty( + subject, + itemXpath, + propName, + itemProp, + itemScopeType, + documentURI, + mappings, + out + ); + } catch (MalformedURLException e) { + throw new ExtractionException( + "Error while processing on subject '" + subject + + "' the itemProp: '" + itemProp + "' " + ); + } + } + } + return subject; + } + + + + + + + private void processProperty( + Resource subject,String subjectXpath, + String propName, + ItemProp itemProp, + String itemScopeType, + URI documentURI, + Map mappings, + LExtractionResultImpl out + ) throws MalformedURLException, ExtractionException { + + //predicate + URI predicate; + if (!isAbsoluteURL(propName) && itemScopeType.equals("") && isStrict) { + return; + } else if (!isAbsoluteURL(propName) && itemScopeType.equals("") && !isStrict) { + predicate = RDFUtils.uri( + toAbsoluteURL( + defaultNamespace, + propName, + '/' + ).toString() + ); + } else { + predicate = RDFUtils.uri( + toAbsoluteURL( + itemScopeType, + propName, + '/' + ).toString()); + } + + + + //value + Value value; + Object propValue = itemProp.getValue().getContent(); + + String propValueXpath = itemProp.getXpath().toString(); + + ItemPropValue.Type propType = itemProp.getValue().getType(); + if (propType.equals(ItemPropValue.Type.Nested)) { + value = processType((ItemScope) propValue, documentURI, out, mappings); + } else if (propType.equals(ItemPropValue.Type.Plain)) { + value = RDFUtils.literal((String) propValue, documentLanguage); + propValueXpath = propValueXpath+LAny23Util.appendTagTextValueToXPath(); + } else if (propType.equals(ItemPropValue.Type.Link)) { + value = RDFUtils.uri( + toAbsoluteURL( + documentURI.toString(), + (String) propValue, + '/' + ).toString() + ); + + propValueXpath = propValueXpath+LAny23Util.appendAttributeToXPath("href"); + + } else if (propType.equals(ItemPropValue.Type.Date)) { + value = RDFUtils.literal(ItemPropValue.formatDateTime((Date) propValue), XMLSchema.DATE); + //TODO check if it is the correct attribute + propValueXpath = propValueXpath+LAny23Util.appendAttributeToXPath("datetime"); + + } else { + throw new RuntimeException("Invalid Type '" + + propType + "' for ItemPropValue with name: '" + propName + "'"); + } + + + String sCxt=subjectXpath; + + + String pCxt=itemProp.getXpath()+LAny23Util.appendAttributeToXPath("itemprop"); + String oCxt=propValueXpath; + + //TODO populate context + + + //TODO check integrity + out.writeTriple(subject, predicate, value, sCxt, pCxt, oCxt); + } + + private boolean isAbsoluteURL(String urlString) { + boolean result = false; + try { + URL url = new URL(urlString); + String protocol = url.getProtocol(); + if (protocol != null && protocol.trim().length() > 0) + result = true; + } catch (MalformedURLException e) { + return false; + } + return result; + } + + private URL toAbsoluteURL(String ns, String part, char trailing) + throws MalformedURLException { + if (isAbsoluteURL(part)) { + return new URL(part); + } + char lastChar = ns.charAt(ns.length() - 1); + if (lastChar == '#' || lastChar == '/') + return new URL(ns + part); + return new URL(ns + trailing + part); + } + + private void notifyError(MicrodataParserException[] errors, ExtractionResult out) { + for(MicrodataParserException mpe : errors) { + out.notifyIssue( + IssueReport.IssueLevel.Error, + mpe.toJSON(), + mpe.getErrorLocationBeginRow(), + mpe.getErrorLocationBeginCol() + ); + } + } + +} diff --git a/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractorFactory.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractorFactory.java index 43e8a2f8..e58551c5 100644 --- a/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractorFactory.java +++ b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataExtractorFactory.java @@ -1,39 +1,39 @@ -package uk.ac.shef.oak.any23.extension.extractor; - -import java.util.Arrays; - -import org.apache.any23.extractor.ExtractorDescription; -import org.apache.any23.extractor.ExtractorFactory; -import org.apache.any23.extractor.SimpleExtractorFactory; -import org.apache.any23.rdf.PopularPrefixes; -import org.apache.any23.rdf.Prefixes; - -/** - * Created by Jan on 10.05.2016. - */ -public class LMicrodataExtractorFactory extends SimpleExtractorFactory implements - ExtractorFactory { - - public static final String NAME = "lodie-html-microdata"; - - public static final Prefixes PREFIXES = PopularPrefixes.createSubset("rdf", "doac", "foaf"); - - private static final ExtractorDescription descriptionInstance = new LMicrodataExtractorFactory(); - - public LMicrodataExtractorFactory() { - super( - LMicrodataExtractorFactory.NAME, - LMicrodataExtractorFactory.PREFIXES, - Arrays.asList("text/html;q=0.1", "application/xhtml+xml;q=0.1"), - "example-microdata.html"); - } - - @Override - public LMicrodataExtractor createExtractor() { - return new LMicrodataExtractor(); - } - - public static ExtractorDescription getDescriptionInstance() { - return descriptionInstance; - } -} +package uk.ac.shef.oak.any23.extension.extractor; + +import java.util.Arrays; + +import org.apache.any23.extractor.ExtractorDescription; +import org.apache.any23.extractor.ExtractorFactory; +import org.apache.any23.extractor.SimpleExtractorFactory; +import org.apache.any23.rdf.PopularPrefixes; +import org.apache.any23.rdf.Prefixes; + +/** + * Created by Jan on 10.05.2016. + */ +public class LMicrodataExtractorFactory extends SimpleExtractorFactory implements + ExtractorFactory { + + public static final String NAME = "lodie-html-microdata"; + + public static final Prefixes PREFIXES = PopularPrefixes.createSubset("rdf", "doac", "foaf"); + + private static final ExtractorDescription descriptionInstance = new LMicrodataExtractorFactory(); + + public LMicrodataExtractorFactory() { + super( + LMicrodataExtractorFactory.NAME, + LMicrodataExtractorFactory.PREFIXES, + Arrays.asList("text/html;q=0.1", "application/xhtml+xml;q=0.1"), + "example-microdata.html"); + } + + @Override + public LMicrodataExtractor createExtractor() { + return new LMicrodataExtractor(); + } + + public static ExtractorDescription getDescriptionInstance() { + return descriptionInstance; + } +} diff --git a/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataParser.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataParser.java index 7ec0cf7f..bd2b9b96 100644 --- a/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataParser.java +++ b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LMicrodataParser.java @@ -1,515 +1,515 @@ -package uk.ac.shef.oak.any23.extension.extractor; - - -import org.apache.any23.extractor.html.DomUtils; -import org.apache.any23.extractor.microdata.*; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.traversal.DocumentTraversal; -import org.w3c.dom.traversal.NodeFilter; -import org.w3c.dom.traversal.TreeWalker; - -import java.io.PrintStream; -import java.text.ParseException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * This class provides utility methods for handling Microdata - * nodes contained within a DOM document. - * - * @author Michele Mostarda (mostarda@fbk.eu) - */ -public class LMicrodataParser { - - enum ErrorMode { - /** - * This mode raises an exception at first encountered error. - */ - StopAtFirstError, - /** - * This mode produces a full error report. - */ - FullReport - } - - public static final String ITEMSCOPE_ATTRIBUTE = "itemscope"; - public static final String ITEMPROP_ATTRIBUTE = "itemprop"; - - /** - * List of tags providing the src property. - */ - public static final Set SRC_TAGS = Collections.unmodifiableSet( - new HashSet(Arrays.asList("audio", "embed", "iframe", "img", "source", "track", "video")) - ); - - /** - * List of tags providing the href property. - */ - public static final Set HREF_TAGS = Collections.unmodifiableSet( - new HashSet(Arrays.asList("a", "area", "link")) - ); - - private final Document document; - - /** - * This set holds the name of properties being dereferenced. - * The {@link #deferProperties(String...)} checks first if the - * required dereference has been already asked, if so raises - * a loop detection error. This map works in coordination - * with {@link #dereferenceRecursionCounter}, so that at the end of - * {@link #deferProperties(String...)} call recursion the - * {@link #loopDetectorSet} can be cleaned up. - */ - private final Set loopDetectorSet = new HashSet(); - - /** - * {@link org.apache.any23.extractor.microdata.ItemScope} cache. - */ - private final Map itemScopes = new HashMap(); - - /** - * {@link ItemPropValue} cache. - */ - private final Map itemPropValues = new HashMap(); - - /** - * Counts the recursive call of {@link #deferProperties(String...)}. - * It helps to cleanup the {@link #loopDetectorSet} when recursion ends. - */ - private int dereferenceRecursionCounter = 0; - - /** - * Current error mode. - */ - private ErrorMode errorMode = ErrorMode.FullReport; - - /** - * List of collected errors. Used when {@link #errorMode} == {@link ErrorMode#FullReport}. - */ - private List errors = new ArrayList(); - - /** - * Returns all the itemScopes detected within the given root node. - * - * @param node root node to search in. - * @return list of detected items. - */ - public static List getItemScopeNodes(Node node) { - return DomUtils.findAllByAttributeName(node, ITEMSCOPE_ATTRIBUTE); - } - - /** - * Check whether a node is an itemScope. - * - * @param node node to check. - * @return true if the node is an itemScope., false otherwise. - */ - public static boolean isItemScope(Node node) { - return DomUtils.readAttribute(node, ITEMSCOPE_ATTRIBUTE, null) != null; - } - - /** - * Returns all the itemProps detected within the given root node. - * - * @param node root node to search in. - * @return list of detected items. - */ - public static List getItemPropNodes(Node node) { - return DomUtils.findAllByAttributeName(node, ITEMPROP_ATTRIBUTE); - } - - /** - * Check whether a node is an itemProp. - * - * @param node node to check. - * @return true if the node is an itemProp., false otherwise. - */ - public static boolean isItemProp(Node node) { - return DomUtils.readAttribute(node, ITEMPROP_ATTRIBUTE, null) != null; - } - - /** - * Returns only the itemScopes that are top level items. - * - * @param node root node to search in. - * @return list of detected top item scopes. - */ - public static List getTopLevelItemScopeNodes(Node node) { - final List itemScopes = getItemScopeNodes(node); - final List topLevelItemScopes = new ArrayList(); - for (Node itemScope : itemScopes) { - if (!isItemProp(itemScope)) { - topLevelItemScopes.add(itemScope); - } - } - return getUnnestedNodes(topLevelItemScopes); - } - - /** - * Returns all the Microdata items detected within the given document. - * - * @param document document to be processed. - * @param errorMode error management policy. - * @return list of itemscope items. - * @throws MicrodataParserException if - * errorMode == {@link org.apache.any23.extractor.microdata.MicrodataParser.ErrorMode#StopAtFirstError} - * and an error occurs. - */ - public static MicrodataParserReport getMicrodata(Document document, ErrorMode errorMode) - throws MicrodataParserException { - final List itemNodes = getTopLevelItemScopeNodes(document); - final List items = new ArrayList(); - final LMicrodataParser microdataParser = new LMicrodataParser(document); - microdataParser.setErrorMode(errorMode); - for (Node itemNode : itemNodes) { - items.add(microdataParser.getItemScope(itemNode)); - } - return new MicrodataParserReport( - items.toArray(new ItemScope[items.size()]), - microdataParser.getErrors() - ); - } - - /** - * Returns all the Microdata items detected within the given document, - * works in full report mode. - * - * @param document document to be processed. - * @return list of itemscope items. - */ - public static MicrodataParserReport getMicrodata(Document document) { - try { - return getMicrodata(document, ErrorMode.FullReport); - } catch (MicrodataParserException mpe) { - throw new IllegalStateException("Unexpected exception.", mpe); - } - } - - /** - * Returns a JSON containing the list of all extracted Microdata, - * as described at Microdata JSON Specification. - * - * @param document document to be processed. - * @param ps - */ - public static void getMicrodataAsJSON(Document document, PrintStream ps) { - final MicrodataParserReport report = getMicrodata(document); - final ItemScope[] itemScopes = report.getDetectedItemScopes(); - final MicrodataParserException[] errors = report.getErrors(); - - ps.append("{ "); - - // Results. - ps.append("\"result\" : ["); - for (int i = 0; i < itemScopes.length; i++) { - ps.print(itemScopes[i].toJSON()); - if (i < itemScopes.length - 1) { - ps.print(", "); - } - } - ps.append("] "); - - // Errors. - if (errors != null && errors.length > 0) { - ps.append(", "); - ps.append("\"errors\" : ["); - for (int i = 0; i < errors.length; i++) { - ps.print(errors[i].toJSON()); - if (i < itemScopes.length - 1) { - ps.print(", "); - } - } - ps.append("] "); - } - - ps.append("}"); - } - - /** - * Returns only nodes that are not nested one each other. - * - * @param candidates list of candidate nodes. - * @return list of unnested nodes. - */ - private static List getUnnestedNodes(List candidates) { - final List unnesteds = new ArrayList(); - for (int i = 0; i < candidates.size(); i++) { - boolean skip = false; - for (int j = 0; j < candidates.size(); j++) { - if (i == j) continue; - if (DomUtils.isAncestorOf(candidates.get(j), candidates.get(i), true)) { - skip = true; - break; - } - } - if (!skip) { - unnesteds.add(candidates.get(i)); - } - } - return unnesteds; - } - - public LMicrodataParser(Document document) { - if (document == null) { - throw new NullPointerException("Document cannot be null."); - } - this.document = document; - } - - public void setErrorMode(ErrorMode errorMode) { - if (errorMode == null) throw new IllegalArgumentException("errorMode must be not null."); - this.errorMode = errorMode; - } - - public ErrorMode getErrorMode() { - return this.errorMode; - } - - public MicrodataParserException[] getErrors() { - return errors == null - ? - new MicrodataParserException[0] - : - errors.toArray(new MicrodataParserException[errors.size()]); - } - - /** - * Reads the value of a itemprop node. - * - * @param node itemprop node. - * @return value detected within the given node. - * @throws MicrodataParserException if an error occurs while extracting a nested item scope. - */ - public ItemPropValue getPropertyValue(Node node) throws MicrodataParserException { - final ItemPropValue itemPropValue = itemPropValues.get(node); - if (itemPropValue != null) return itemPropValue; - - final String nodeName = node.getNodeName().toLowerCase(); - if ("meta".equals(nodeName)) { - return new ItemPropValue(DomUtils.readAttribute(node, "content"), ItemPropValue.Type.Plain); - } - - if (SRC_TAGS.contains(nodeName)) { - return new ItemPropValue(DomUtils.readAttribute(node, "src"), ItemPropValue.Type.Link); - } - if (HREF_TAGS.contains(nodeName)) { - return new ItemPropValue(DomUtils.readAttribute(node, "href"), ItemPropValue.Type.Link); - } - - if ("object".equals(nodeName)) { - return new ItemPropValue(DomUtils.readAttribute(node, "data"), ItemPropValue.Type.Link); - } - if ("time".equals(nodeName)) { - final String dateTimeStr = DomUtils.readAttribute(node, "datetime"); - final Date dateTime; - try { - dateTime = ItemPropValue.parseDateTime(dateTimeStr); - } catch (ParseException pe) { - throw new MicrodataParserException( - String.format("Invalid format for datetime '%s'", dateTimeStr), - node - ); - } - return new ItemPropValue(dateTime, ItemPropValue.Type.Date); - } - - if (isItemScope(node)) { - return new ItemPropValue(getItemScope(node), ItemPropValue.Type.Nested); - } - - ItemPropValue newItemPropValue = null; - try { - newItemPropValue = new ItemPropValue(node.getTextContent(), ItemPropValue.Type.Plain); - } catch (IllegalArgumentException e) { - System.err.println("Cannot parse invalid annotation. Skipped"); - //e.printStackTrace(); - } - itemPropValues.put(node, newItemPropValue); - return newItemPropValue; - } - - /** - * Returns all the itemprops for the given itemscope node. - * - * @param scopeNode node representing the itemscope - * @param skipRoot if true the given root node - * will be not read as a property, even if it contains the itemprop attribute. - * @return the list of itemprops detected within the given itemscope. - * @throws MicrodataParserException if an error occurs while retrieving an property value. - */ - public List getItemProps(final Node scopeNode, boolean skipRoot) throws MicrodataParserException { - final Set accepted = new LinkedHashSet(); - - if (!skipRoot) { - NamedNodeMap attributes = scopeNode.getAttributes(); - if (attributes.getNamedItem(ITEMPROP_ATTRIBUTE) != null) { - accepted.add(scopeNode); - } - } - - // TreeWalker to walk DOM tree starting with the scopeNode. Nodes maybe visited multiple times. - TreeWalker treeWalker = ((DocumentTraversal) scopeNode.getOwnerDocument()) - .createTreeWalker(scopeNode, NodeFilter.SHOW_ELEMENT, new NodeFilter() { - @Override - public short acceptNode(Node node) { - if (node.getNodeType() == Node.ELEMENT_NODE) { - NamedNodeMap attributes = node.getAttributes(); - if (attributes.getNamedItem(ITEMPROP_ATTRIBUTE) != null && !scopeNode.equals(node)) { - accepted.add(node); - } - if (attributes.getNamedItem(ITEMSCOPE_ATTRIBUTE) != null) { - // Don't visit descendants of nodes that define a new scope - return FILTER_REJECT; - } - } - return FILTER_ACCEPT; - } - }, false); - - // To populate accepted we only need to walk the tree. - while (treeWalker.nextNode() != null) ; - - final List result = new ArrayList(); - for (Node itemPropNode : accepted) { - final String itemProp = DomUtils.readAttribute(itemPropNode, ITEMPROP_ATTRIBUTE, null); - final String[] propertyNames = itemProp.split(" "); - ItemPropValue itemPropValue; - for (String propertyName : propertyNames) { - try { - itemPropValue = getPropertyValue(itemPropNode); - } catch (MicrodataParserException mpe) { - manageError(mpe); - continue; - } - if(itemPropValue==null) - continue; - result.add( - new ItemProp( - DomUtils.getXPathForNode(itemPropNode), - propertyName, - itemPropValue - ) - ); - } - } - return result; - } - - /** - * Given a document and a list of itemprop names this method will return - * such itemprops. - * - * @param refs list of references. - * @return list of retrieved itemprops. - * @throws MicrodataParserException if a loop is detected or a property name is missing. - */ - public ItemProp[] deferProperties(String... refs) throws MicrodataParserException { - dereferenceRecursionCounter++; - final List result = new ArrayList(); - try { - for (String ref : refs) { - if (loopDetectorSet.contains(ref)) { - throw new MicrodataParserException( - String.format( - "Loop detected with depth %d while dereferencing itemProp '%s' .", - dereferenceRecursionCounter - 1, ref - ), - null - ); - } - loopDetectorSet.add(ref); - final Element element = document.getElementById(ref); - if (element == null) { - manageError( - new MicrodataParserException(String.format("Unknown itemProp id '%s'", ref), null) - ); - continue; - } - result.addAll(getItemProps(element, false)); - } - } catch (MicrodataParserException mpe) { - if (dereferenceRecursionCounter == 1) - manageError(mpe); - else throw mpe; // Recursion end, this the the top call. - } finally { - dereferenceRecursionCounter--; - if (dereferenceRecursionCounter == 0) { // Recursion end, this the the top call. - loopDetectorSet.clear(); - } - } - return result.toArray(new ItemProp[result.size()]); - } - - /** - * Returns the {@link ItemScope} instance described within the specified node. - * - * @param node node describing an itemscope. - * @return instance of ItemScope object. - * @throws MicrodataParserException if an error occurs while dereferencing properties. - */ - public ItemScope getItemScope(Node node) throws MicrodataParserException { - final ItemScope itemScope = itemScopes.get(node); - if (itemScope != null) return itemScope; - - final String id = DomUtils.readAttribute(node, "id", null); - final String itemref = DomUtils.readAttribute(node, "itemref", null); - final String itemType = DomUtils.readAttribute(node, "itemtype", null); - final String itemId = DomUtils.readAttribute(node, "itemid", null); - - final List itemProps = getItemProps(node, true); - final String[] itemrefIDs = itemref == null ? new String[0] : itemref.split(" "); - final ItemProp[] deferredProperties; - try { - deferredProperties = deferProperties(itemrefIDs); - } catch (MicrodataParserException mpe) { - //mpe.setErrorNode(node); - throw mpe; - } - for (ItemProp deferredProperty : deferredProperties) { - if (itemProps.contains(deferredProperty)) { - manageError( - new MicrodataParserException( - String.format("Duplicated deferred itemProp '%s'.", deferredProperty.getName()), - node - ) - ); - continue; - } - itemProps.add(deferredProperty); - } - - final ItemScope newItemScope = new ItemScope( - DomUtils.getXPathForNode(node), - itemProps.toArray(new ItemProp[itemProps.size()]), - id, - itemrefIDs, - itemType, - itemId - ); - itemScopes.put(node, newItemScope); - return newItemScope; - } - - private void manageError(MicrodataParserException mpe) throws MicrodataParserException { - if (errorMode == ErrorMode.StopAtFirstError) { - throw mpe; - } - if (errorMode != ErrorMode.FullReport) throw new IllegalStateException("Unsupported mode " + errorMode); - if (errors == null) { - errors = new ArrayList(); - } - errors.add(mpe); - } - +package uk.ac.shef.oak.any23.extension.extractor; + + +import org.apache.any23.extractor.html.DomUtils; +import org.apache.any23.extractor.microdata.*; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.traversal.DocumentTraversal; +import org.w3c.dom.traversal.NodeFilter; +import org.w3c.dom.traversal.TreeWalker; + +import java.io.PrintStream; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * This class provides utility methods for handling Microdata + * nodes contained within a DOM document. + * + * @author Michele Mostarda (mostarda@fbk.eu) + */ +public class LMicrodataParser { + + enum ErrorMode { + /** + * This mode raises an exception at first encountered error. + */ + StopAtFirstError, + /** + * This mode produces a full error report. + */ + FullReport + } + + public static final String ITEMSCOPE_ATTRIBUTE = "itemscope"; + public static final String ITEMPROP_ATTRIBUTE = "itemprop"; + + /** + * List of tags providing the src property. + */ + public static final Set SRC_TAGS = Collections.unmodifiableSet( + new HashSet(Arrays.asList("audio", "embed", "iframe", "img", "source", "track", "video")) + ); + + /** + * List of tags providing the href property. + */ + public static final Set HREF_TAGS = Collections.unmodifiableSet( + new HashSet(Arrays.asList("a", "area", "link")) + ); + + private final Document document; + + /** + * This set holds the name of properties being dereferenced. + * The {@link #deferProperties(String...)} checks first if the + * required dereference has been already asked, if so raises + * a loop detection error. This map works in coordination + * with {@link #dereferenceRecursionCounter}, so that at the end of + * {@link #deferProperties(String...)} call recursion the + * {@link #loopDetectorSet} can be cleaned up. + */ + private final Set loopDetectorSet = new HashSet(); + + /** + * {@link org.apache.any23.extractor.microdata.ItemScope} cache. + */ + private final Map itemScopes = new HashMap(); + + /** + * {@link ItemPropValue} cache. + */ + private final Map itemPropValues = new HashMap(); + + /** + * Counts the recursive call of {@link #deferProperties(String...)}. + * It helps to cleanup the {@link #loopDetectorSet} when recursion ends. + */ + private int dereferenceRecursionCounter = 0; + + /** + * Current error mode. + */ + private ErrorMode errorMode = ErrorMode.FullReport; + + /** + * List of collected errors. Used when {@link #errorMode} == {@link ErrorMode#FullReport}. + */ + private List errors = new ArrayList(); + + /** + * Returns all the itemScopes detected within the given root node. + * + * @param node root node to search in. + * @return list of detected items. + */ + public static List getItemScopeNodes(Node node) { + return DomUtils.findAllByAttributeName(node, ITEMSCOPE_ATTRIBUTE); + } + + /** + * Check whether a node is an itemScope. + * + * @param node node to check. + * @return true if the node is an itemScope., false otherwise. + */ + public static boolean isItemScope(Node node) { + return DomUtils.readAttribute(node, ITEMSCOPE_ATTRIBUTE, null) != null; + } + + /** + * Returns all the itemProps detected within the given root node. + * + * @param node root node to search in. + * @return list of detected items. + */ + public static List getItemPropNodes(Node node) { + return DomUtils.findAllByAttributeName(node, ITEMPROP_ATTRIBUTE); + } + + /** + * Check whether a node is an itemProp. + * + * @param node node to check. + * @return true if the node is an itemProp., false otherwise. + */ + public static boolean isItemProp(Node node) { + return DomUtils.readAttribute(node, ITEMPROP_ATTRIBUTE, null) != null; + } + + /** + * Returns only the itemScopes that are top level items. + * + * @param node root node to search in. + * @return list of detected top item scopes. + */ + public static List getTopLevelItemScopeNodes(Node node) { + final List itemScopes = getItemScopeNodes(node); + final List topLevelItemScopes = new ArrayList(); + for (Node itemScope : itemScopes) { + if (!isItemProp(itemScope)) { + topLevelItemScopes.add(itemScope); + } + } + return getUnnestedNodes(topLevelItemScopes); + } + + /** + * Returns all the Microdata items detected within the given document. + * + * @param document document to be processed. + * @param errorMode error management policy. + * @return list of itemscope items. + * @throws MicrodataParserException if + * errorMode == {@link org.apache.any23.extractor.microdata.MicrodataParser.ErrorMode#StopAtFirstError} + * and an error occurs. + */ + public static MicrodataParserReport getMicrodata(Document document, ErrorMode errorMode) + throws MicrodataParserException { + final List itemNodes = getTopLevelItemScopeNodes(document); + final List items = new ArrayList(); + final LMicrodataParser microdataParser = new LMicrodataParser(document); + microdataParser.setErrorMode(errorMode); + for (Node itemNode : itemNodes) { + items.add(microdataParser.getItemScope(itemNode)); + } + return new MicrodataParserReport( + items.toArray(new ItemScope[items.size()]), + microdataParser.getErrors() + ); + } + + /** + * Returns all the Microdata items detected within the given document, + * works in full report mode. + * + * @param document document to be processed. + * @return list of itemscope items. + */ + public static MicrodataParserReport getMicrodata(Document document) { + try { + return getMicrodata(document, ErrorMode.FullReport); + } catch (MicrodataParserException mpe) { + throw new IllegalStateException("Unexpected exception.", mpe); + } + } + + /** + * Returns a JSON containing the list of all extracted Microdata, + * as described at Microdata JSON Specification. + * + * @param document document to be processed. + * @param ps + */ + public static void getMicrodataAsJSON(Document document, PrintStream ps) { + final MicrodataParserReport report = getMicrodata(document); + final ItemScope[] itemScopes = report.getDetectedItemScopes(); + final MicrodataParserException[] errors = report.getErrors(); + + ps.append("{ "); + + // Results. + ps.append("\"result\" : ["); + for (int i = 0; i < itemScopes.length; i++) { + ps.print(itemScopes[i].toJSON()); + if (i < itemScopes.length - 1) { + ps.print(", "); + } + } + ps.append("] "); + + // Errors. + if (errors != null && errors.length > 0) { + ps.append(", "); + ps.append("\"errors\" : ["); + for (int i = 0; i < errors.length; i++) { + ps.print(errors[i].toJSON()); + if (i < itemScopes.length - 1) { + ps.print(", "); + } + } + ps.append("] "); + } + + ps.append("}"); + } + + /** + * Returns only nodes that are not nested one each other. + * + * @param candidates list of candidate nodes. + * @return list of unnested nodes. + */ + private static List getUnnestedNodes(List candidates) { + final List unnesteds = new ArrayList(); + for (int i = 0; i < candidates.size(); i++) { + boolean skip = false; + for (int j = 0; j < candidates.size(); j++) { + if (i == j) continue; + if (DomUtils.isAncestorOf(candidates.get(j), candidates.get(i), true)) { + skip = true; + break; + } + } + if (!skip) { + unnesteds.add(candidates.get(i)); + } + } + return unnesteds; + } + + public LMicrodataParser(Document document) { + if (document == null) { + throw new NullPointerException("Document cannot be null."); + } + this.document = document; + } + + public void setErrorMode(ErrorMode errorMode) { + if (errorMode == null) throw new IllegalArgumentException("errorMode must be not null."); + this.errorMode = errorMode; + } + + public ErrorMode getErrorMode() { + return this.errorMode; + } + + public MicrodataParserException[] getErrors() { + return errors == null + ? + new MicrodataParserException[0] + : + errors.toArray(new MicrodataParserException[errors.size()]); + } + + /** + * Reads the value of a itemprop node. + * + * @param node itemprop node. + * @return value detected within the given node. + * @throws MicrodataParserException if an error occurs while extracting a nested item scope. + */ + public ItemPropValue getPropertyValue(Node node) throws MicrodataParserException { + final ItemPropValue itemPropValue = itemPropValues.get(node); + if (itemPropValue != null) return itemPropValue; + + final String nodeName = node.getNodeName().toLowerCase(); + if ("meta".equals(nodeName)) { + return new ItemPropValue(DomUtils.readAttribute(node, "content"), ItemPropValue.Type.Plain); + } + + if (SRC_TAGS.contains(nodeName)) { + return new ItemPropValue(DomUtils.readAttribute(node, "src"), ItemPropValue.Type.Link); + } + if (HREF_TAGS.contains(nodeName)) { + return new ItemPropValue(DomUtils.readAttribute(node, "href"), ItemPropValue.Type.Link); + } + + if ("object".equals(nodeName)) { + return new ItemPropValue(DomUtils.readAttribute(node, "data"), ItemPropValue.Type.Link); + } + if ("time".equals(nodeName)) { + final String dateTimeStr = DomUtils.readAttribute(node, "datetime"); + final Date dateTime; + try { + dateTime = ItemPropValue.parseDateTime(dateTimeStr); + } catch (ParseException pe) { + throw new MicrodataParserException( + String.format("Invalid format for datetime '%s'", dateTimeStr), + node + ); + } + return new ItemPropValue(dateTime, ItemPropValue.Type.Date); + } + + if (isItemScope(node)) { + return new ItemPropValue(getItemScope(node), ItemPropValue.Type.Nested); + } + + ItemPropValue newItemPropValue = null; + try { + newItemPropValue = new ItemPropValue(node.getTextContent(), ItemPropValue.Type.Plain); + } catch (IllegalArgumentException e) { + System.err.println("Cannot parse invalid annotation. Skipped"); + //e.printStackTrace(); + } + itemPropValues.put(node, newItemPropValue); + return newItemPropValue; + } + + /** + * Returns all the itemprops for the given itemscope node. + * + * @param scopeNode node representing the itemscope + * @param skipRoot if true the given root node + * will be not read as a property, even if it contains the itemprop attribute. + * @return the list of itemprops detected within the given itemscope. + * @throws MicrodataParserException if an error occurs while retrieving an property value. + */ + public List getItemProps(final Node scopeNode, boolean skipRoot) throws MicrodataParserException { + final Set accepted = new LinkedHashSet(); + + if (!skipRoot) { + NamedNodeMap attributes = scopeNode.getAttributes(); + if (attributes.getNamedItem(ITEMPROP_ATTRIBUTE) != null) { + accepted.add(scopeNode); + } + } + + // TreeWalker to walk DOM tree starting with the scopeNode. Nodes maybe visited multiple times. + TreeWalker treeWalker = ((DocumentTraversal) scopeNode.getOwnerDocument()) + .createTreeWalker(scopeNode, NodeFilter.SHOW_ELEMENT, new NodeFilter() { + @Override + public short acceptNode(Node node) { + if (node.getNodeType() == Node.ELEMENT_NODE) { + NamedNodeMap attributes = node.getAttributes(); + if (attributes.getNamedItem(ITEMPROP_ATTRIBUTE) != null && !scopeNode.equals(node)) { + accepted.add(node); + } + if (attributes.getNamedItem(ITEMSCOPE_ATTRIBUTE) != null) { + // Don't visit descendants of nodes that define a new scope + return FILTER_REJECT; + } + } + return FILTER_ACCEPT; + } + }, false); + + // To populate accepted we only need to walk the tree. + while (treeWalker.nextNode() != null) ; + + final List result = new ArrayList(); + for (Node itemPropNode : accepted) { + final String itemProp = DomUtils.readAttribute(itemPropNode, ITEMPROP_ATTRIBUTE, null); + final String[] propertyNames = itemProp.split(" "); + ItemPropValue itemPropValue; + for (String propertyName : propertyNames) { + try { + itemPropValue = getPropertyValue(itemPropNode); + } catch (MicrodataParserException mpe) { + manageError(mpe); + continue; + } + if(itemPropValue==null) + continue; + result.add( + new ItemProp( + DomUtils.getXPathForNode(itemPropNode), + propertyName, + itemPropValue + ) + ); + } + } + return result; + } + + /** + * Given a document and a list of itemprop names this method will return + * such itemprops. + * + * @param refs list of references. + * @return list of retrieved itemprops. + * @throws MicrodataParserException if a loop is detected or a property name is missing. + */ + public ItemProp[] deferProperties(String... refs) throws MicrodataParserException { + dereferenceRecursionCounter++; + final List result = new ArrayList(); + try { + for (String ref : refs) { + if (loopDetectorSet.contains(ref)) { + throw new MicrodataParserException( + String.format( + "Loop detected with depth %d while dereferencing itemProp '%s' .", + dereferenceRecursionCounter - 1, ref + ), + null + ); + } + loopDetectorSet.add(ref); + final Element element = document.getElementById(ref); + if (element == null) { + manageError( + new MicrodataParserException(String.format("Unknown itemProp id '%s'", ref), null) + ); + continue; + } + result.addAll(getItemProps(element, false)); + } + } catch (MicrodataParserException mpe) { + if (dereferenceRecursionCounter == 1) + manageError(mpe); + else throw mpe; // Recursion end, this the the top call. + } finally { + dereferenceRecursionCounter--; + if (dereferenceRecursionCounter == 0) { // Recursion end, this the the top call. + loopDetectorSet.clear(); + } + } + return result.toArray(new ItemProp[result.size()]); + } + + /** + * Returns the {@link ItemScope} instance described within the specified node. + * + * @param node node describing an itemscope. + * @return instance of ItemScope object. + * @throws MicrodataParserException if an error occurs while dereferencing properties. + */ + public ItemScope getItemScope(Node node) throws MicrodataParserException { + final ItemScope itemScope = itemScopes.get(node); + if (itemScope != null) return itemScope; + + final String id = DomUtils.readAttribute(node, "id", null); + final String itemref = DomUtils.readAttribute(node, "itemref", null); + final String itemType = DomUtils.readAttribute(node, "itemtype", null); + final String itemId = DomUtils.readAttribute(node, "itemid", null); + + final List itemProps = getItemProps(node, true); + final String[] itemrefIDs = itemref == null ? new String[0] : itemref.split(" "); + final ItemProp[] deferredProperties; + try { + deferredProperties = deferProperties(itemrefIDs); + } catch (MicrodataParserException mpe) { + //mpe.setErrorNode(node); + throw mpe; + } + for (ItemProp deferredProperty : deferredProperties) { + if (itemProps.contains(deferredProperty)) { + manageError( + new MicrodataParserException( + String.format("Duplicated deferred itemProp '%s'.", deferredProperty.getName()), + node + ) + ); + continue; + } + itemProps.add(deferredProperty); + } + + final ItemScope newItemScope = new ItemScope( + DomUtils.getXPathForNode(node), + itemProps.toArray(new ItemProp[itemProps.size()]), + id, + itemrefIDs, + itemType, + itemId + ); + itemScopes.put(node, newItemScope); + return newItemScope; + } + + private void manageError(MicrodataParserException mpe) throws MicrodataParserException { + if (errorMode == ErrorMode.StopAtFirstError) { + throw mpe; + } + if (errorMode != ErrorMode.FullReport) throw new IllegalStateException("Unsupported mode " + errorMode); + if (errors == null) { + errors = new ArrayList(); + } + errors.add(mpe); + } + } \ No newline at end of file diff --git a/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LNTripleWriter.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LNTripleWriter.java index 95d75c69..1c4bada4 100644 --- a/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LNTripleWriter.java +++ b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LNTripleWriter.java @@ -1,45 +1,45 @@ -package uk.ac.shef.oak.any23.extension.extractor; - -import org.apache.any23.extractor.ExtractionContext; -import org.apache.any23.rdf.RDFUtils; -import org.apache.any23.writer.NTriplesWriter; -import org.apache.any23.writer.TripleHandlerException; -import org.openrdf.model.Resource; -import org.openrdf.model.Statement; -import org.openrdf.model.URI; -import org.openrdf.model.Value; - -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.List; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 29/10/12 - * Time: 20:39 - */ -public class LNTripleWriter extends NTriplesWriter { - - private List triples; - - public LNTripleWriter(OutputStream out) { - super(out); - triples = new ArrayList(); - } - - public void receiveTriple(Resource s, URI p, Value o, URI g, ExtractionContext context, String sCtx, String pCtx, String oCtx) throws TripleHandlerException { - receiveTriple(s, p, o, g, context); - final URI graph = g == null ? context.getDocumentURI() : g; - Statement stmt = RDFUtils.quad(s, p, o, graph); - LTriple triple = new LTriple(stmt); - triple.setsXPath(sCtx); - triple.setpXPath(pCtx); - triple.setoXPath(oCtx); - - triples.add(triple); - } - - public List getOutput() { - return triples; - } -} +package uk.ac.shef.oak.any23.extension.extractor; + +import org.apache.any23.extractor.ExtractionContext; +import org.apache.any23.rdf.RDFUtils; +import org.apache.any23.writer.NTriplesWriter; +import org.apache.any23.writer.TripleHandlerException; +import org.openrdf.model.Resource; +import org.openrdf.model.Statement; +import org.openrdf.model.URI; +import org.openrdf.model.Value; + +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.List; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 29/10/12 + * Time: 20:39 + */ +public class LNTripleWriter extends NTriplesWriter { + + private List triples; + + public LNTripleWriter(OutputStream out) { + super(out); + triples = new ArrayList(); + } + + public void receiveTriple(Resource s, URI p, Value o, URI g, ExtractionContext context, String sCtx, String pCtx, String oCtx) throws TripleHandlerException { + receiveTriple(s, p, o, g, context); + final URI graph = g == null ? context.getDocumentURI() : g; + Statement stmt = RDFUtils.quad(s, p, o, graph); + LTriple triple = new LTriple(stmt); + triple.setsXPath(sCtx); + triple.setpXPath(pCtx); + triple.setoXPath(oCtx); + + triples.add(triple); + } + + public List getOutput() { + return triples; + } +} diff --git a/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Extractor.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Extractor.java index 5e9ab348..dd4c6422 100644 --- a/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Extractor.java +++ b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11Extractor.java @@ -1,87 +1,87 @@ -package uk.ac.shef.oak.any23.extension.extractor; - -import org.apache.any23.extractor.*; -import org.apache.any23.extractor.rdfa.RDFa11Extractor; -import org.apache.any23.extractor.rdfa.RDFa11ParserException; -import org.w3c.dom.Document; - -import java.io.IOException; -import java.net.URL; -import java.util.Arrays; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 30/10/12 - * Time: 09:19 - */ -public class LRDFa11Extractor extends RDFa11Extractor { - public final static String NAME = "lodie-html-rdfa11"; - - public final static ExtractorFactory factory = new LRDFa11ExtractorFactory(); - - private final LRDFa11Parser parser; - - private boolean verifyDataType; - - private boolean stopAtFirstError; - - /** - * Constructor, allows to specify the validation and error handling policies. - * - * @param verifyDataType if true the data types will be verified, - * if false will be ignored. - * @param stopAtFirstError if true the parser will stop at first parsing error, - * if false will ignore non blocking errors. - */ - public LRDFa11Extractor(boolean verifyDataType, boolean stopAtFirstError) { - this.parser = new LRDFa11Parser(); - this.verifyDataType = verifyDataType; - this.stopAtFirstError = stopAtFirstError; - } - - /** - * Default constructor, with no verification of data types and not stop at first error. - */ - public LRDFa11Extractor() { - this(false, false); - } - - public boolean isVerifyDataType() { - return verifyDataType; - } - - public void setVerifyDataType(boolean verifyDataType) { - this.verifyDataType = verifyDataType; - } - - public boolean isStopAtFirstError() { - return stopAtFirstError; - } - - public void setStopAtFirstError(boolean stopAtFirstError) { - this.stopAtFirstError = stopAtFirstError; - } - - public void run( - ExtractionParameters extractionParameters, - ExtractionContext extractionContext, - Document in, - ExtractionResult out - ) throws IOException, ExtractionException { - try { - LExtractionResultImpl outWriter = (LExtractionResultImpl)out; - parser.processDocument( new URL(extractionContext.getDocumentURI().toString() ), in, outWriter ); - } catch (RDFa11ParserException rpe) { - throw new ExtractionException("Error while performing extraction.", rpe); - } catch (ClassCastException cce){ - throw new ExtractionException("Required: "+LExtractionResultImpl.class.getName(), cce); - } - } - - /** - * @return the {@link org.apache.any23.extractor.ExtractorDescription} of this extractor - */ - public ExtractorDescription getDescription() { - return factory; - } -} +package uk.ac.shef.oak.any23.extension.extractor; + +import org.apache.any23.extractor.*; +import org.apache.any23.extractor.rdfa.RDFa11Extractor; +import org.apache.any23.extractor.rdfa.RDFa11ParserException; +import org.w3c.dom.Document; + +import java.io.IOException; +import java.net.URL; +import java.util.Arrays; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 30/10/12 + * Time: 09:19 + */ +public class LRDFa11Extractor extends RDFa11Extractor { + public final static String NAME = "lodie-html-rdfa11"; + + public final static ExtractorFactory factory = new LRDFa11ExtractorFactory(); + + private final LRDFa11Parser parser; + + private boolean verifyDataType; + + private boolean stopAtFirstError; + + /** + * Constructor, allows to specify the validation and error handling policies. + * + * @param verifyDataType if true the data types will be verified, + * if false will be ignored. + * @param stopAtFirstError if true the parser will stop at first parsing error, + * if false will ignore non blocking errors. + */ + public LRDFa11Extractor(boolean verifyDataType, boolean stopAtFirstError) { + this.parser = new LRDFa11Parser(); + this.verifyDataType = verifyDataType; + this.stopAtFirstError = stopAtFirstError; + } + + /** + * Default constructor, with no verification of data types and not stop at first error. + */ + public LRDFa11Extractor() { + this(false, false); + } + + public boolean isVerifyDataType() { + return verifyDataType; + } + + public void setVerifyDataType(boolean verifyDataType) { + this.verifyDataType = verifyDataType; + } + + public boolean isStopAtFirstError() { + return stopAtFirstError; + } + + public void setStopAtFirstError(boolean stopAtFirstError) { + this.stopAtFirstError = stopAtFirstError; + } + + public void run( + ExtractionParameters extractionParameters, + ExtractionContext extractionContext, + Document in, + ExtractionResult out + ) throws IOException, ExtractionException { + try { + LExtractionResultImpl outWriter = (LExtractionResultImpl)out; + parser.processDocument( new URL(extractionContext.getDocumentURI().toString() ), in, outWriter ); + } catch (RDFa11ParserException rpe) { + throw new ExtractionException("Error while performing extraction.", rpe); + } catch (ClassCastException cce){ + throw new ExtractionException("Required: "+LExtractionResultImpl.class.getName(), cce); + } + } + + /** + * @return the {@link org.apache.any23.extractor.ExtractorDescription} of this extractor + */ + public ExtractorDescription getDescription() { + return factory; + } +} diff --git a/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11ExtractorFactory.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11ExtractorFactory.java index 6319202c..4a8afd93 100644 --- a/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11ExtractorFactory.java +++ b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LRDFa11ExtractorFactory.java @@ -1,40 +1,40 @@ -package uk.ac.shef.oak.any23.extension.extractor; - -import org.apache.any23.extractor.ExtractorDescription; -import org.apache.any23.extractor.ExtractorFactory; -import org.apache.any23.extractor.SimpleExtractorFactory; -import org.apache.any23.rdf.PopularPrefixes; -import org.apache.any23.rdf.Prefixes; - -import java.util.Arrays; - -/** - * Created by Jan on 10.05.2016. - */ -public class LRDFa11ExtractorFactory - extends SimpleExtractorFactory - implements ExtractorFactory{ - - public static final String NAME = "lodie-html-rdfa11"; - - public static final Prefixes PREFIXES = null; - - private static final ExtractorDescription descriptionInstance = new LRDFa11ExtractorFactory(); - - public LRDFa11ExtractorFactory() { - super( - LMicrodataExtractorFactory.NAME, - LMicrodataExtractorFactory.PREFIXES, - Arrays.asList("text/html;q=0.3", "application/xhtml+xml;q=0.3"), - "example-rdfa11.html"); - } - - @Override - public LRDFa11Extractor createExtractor() { - return new LRDFa11Extractor(); - } - - public static ExtractorDescription getDescriptionInstance() { - return descriptionInstance; - } -} +package uk.ac.shef.oak.any23.extension.extractor; + +import org.apache.any23.extractor.ExtractorDescription; +import org.apache.any23.extractor.ExtractorFactory; +import org.apache.any23.extractor.SimpleExtractorFactory; +import org.apache.any23.rdf.PopularPrefixes; +import org.apache.any23.rdf.Prefixes; + +import java.util.Arrays; + +/** + * Created by Jan on 10.05.2016. + */ +public class LRDFa11ExtractorFactory + extends SimpleExtractorFactory + implements ExtractorFactory{ + + public static final String NAME = "lodie-html-rdfa11"; + + public static final Prefixes PREFIXES = null; + + private static final ExtractorDescription descriptionInstance = new LRDFa11ExtractorFactory(); + + public LRDFa11ExtractorFactory() { + super( + LMicrodataExtractorFactory.NAME, + LMicrodataExtractorFactory.PREFIXES, + Arrays.asList("text/html;q=0.3", "application/xhtml+xml;q=0.3"), + "example-rdfa11.html"); + } + + @Override + public LRDFa11Extractor createExtractor() { + return new LRDFa11Extractor(); + } + + public static ExtractorDescription getDescriptionInstance() { + return descriptionInstance; + } +} diff --git a/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LTriple.java b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LTriple.java index 010bed79..d134c103 100644 --- a/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LTriple.java +++ b/sti-any23/src/uk/ac/shef/oak/any23/extension/extractor/LTriple.java @@ -1,58 +1,58 @@ -package uk.ac.shef.oak.any23.extension.extractor; - -import org.openrdf.model.Statement; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 09/11/12 - * Time: 11:16 - */ -public class LTriple { - - private Statement triple; - private String sXPath; - private String pXPath; - private String oXPath; - - public LTriple(Statement stmt){ - this.triple=stmt; - } - - public Statement getTriple() { - return triple; - } - - public void setTriple(Statement triple) { - this.triple = triple; - } - - public String getsXPath() { - return sXPath; - } - - public void setsXPath(String sXPath) { - this.sXPath = sXPath; - } - - public String getpXPath() { - return pXPath; - } - - public void setpXPath(String pXPath) { - this.pXPath = pXPath; - } - - public String getoXPath() { - return oXPath; - } - - public void setoXPath(String oXPath) { - this.oXPath = oXPath; - } - - public String toString(){ - return triple.toString(); - } - - -} +package uk.ac.shef.oak.any23.extension.extractor; + +import org.openrdf.model.Statement; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 09/11/12 + * Time: 11:16 + */ +public class LTriple { + + private Statement triple; + private String sXPath; + private String pXPath; + private String oXPath; + + public LTriple(Statement stmt){ + this.triple=stmt; + } + + public Statement getTriple() { + return triple; + } + + public void setTriple(Statement triple) { + this.triple = triple; + } + + public String getsXPath() { + return sXPath; + } + + public void setsXPath(String sXPath) { + this.sXPath = sXPath; + } + + public String getpXPath() { + return pXPath; + } + + public void setpXPath(String pXPath) { + this.pXPath = pXPath; + } + + public String getoXPath() { + return oXPath; + } + + public void setoXPath(String oXPath) { + this.oXPath = oXPath; + } + + public String toString(){ + return triple.toString(); + } + + +} diff --git a/sti-common-util/src/main/java/uk/ac/shef/dcs/util/SerializationUtils.java b/sti-common-util/src/main/java/uk/ac/shef/dcs/util/SerializationUtils.java index 269c3e4e..75ef7f89 100644 --- a/sti-common-util/src/main/java/uk/ac/shef/dcs/util/SerializationUtils.java +++ b/sti-common-util/src/main/java/uk/ac/shef/dcs/util/SerializationUtils.java @@ -1,25 +1,25 @@ -package uk.ac.shef.dcs.util; - -import com.sun.org.apache.xerces.internal.impl.dv.util.Base64; - -import java.io.*; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 07/05/13 - * Time: 16:20 - */ -public class SerializationUtils { - - public static String serializeBase64(Object obj) throws IOException { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - ObjectOutputStream os = new ObjectOutputStream(out); - os.writeObject(obj); - return Base64.encode(out.toByteArray()); - } - public static Object deserializeBase64(byte[] bytes) throws IOException, ClassNotFoundException { - ByteArrayInputStream in = new ByteArrayInputStream(bytes); - ObjectInputStream is = new ObjectInputStream(in); - return is.readObject(); - } -} +package uk.ac.shef.dcs.util; + +import com.sun.org.apache.xerces.internal.impl.dv.util.Base64; + +import java.io.*; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 07/05/13 + * Time: 16:20 + */ +public class SerializationUtils { + + public static String serializeBase64(Object obj) throws IOException { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + ObjectOutputStream os = new ObjectOutputStream(out); + os.writeObject(obj); + return Base64.encode(out.toByteArray()); + } + public static Object deserializeBase64(byte[] bytes) throws IOException, ClassNotFoundException { + ByteArrayInputStream in = new ByteArrayInputStream(bytes); + ObjectInputStream is = new ObjectInputStream(in); + return is.readObject(); + } +} diff --git a/sti-common-util/src/main/java/uk/ac/shef/dcs/util/SolrCache.java b/sti-common-util/src/main/java/uk/ac/shef/dcs/util/SolrCache.java index 9fd5a66a..beed9fdc 100644 --- a/sti-common-util/src/main/java/uk/ac/shef/dcs/util/SolrCache.java +++ b/sti-common-util/src/main/java/uk/ac/shef/dcs/util/SolrCache.java @@ -1,77 +1,77 @@ -package uk.ac.shef.dcs.util; - -import org.apache.solr.client.solrj.SolrServerException; -import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; -import org.apache.solr.client.solrj.response.QueryResponse; -import org.apache.solr.client.solrj.util.ClientUtils; -import org.apache.solr.common.SolrDocument; -import org.apache.solr.common.SolrInputDocument; -import org.apache.solr.common.params.ModifiableSolrParams; - -import java.io.IOException; -import java.util.ArrayList; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 21/01/14 - * Time: 12:58 - * To change this template use File | Settings | File Templates. - */ -public class SolrCache { - - private EmbeddedSolrServer server; - private static final String idFieldName = "id"; - private static final String valueFieldName = "value"; - - public SolrCache(EmbeddedSolrServer server) { - this.server=server; - } - - //queryId - what is the query - //interpretationResults: key in the map is a value from a single cell in a table row; value in the map is the score as a measure of confidence that cell should be main subject - public void cache(String queryId, Object obj, boolean commit) throws IOException, SolrServerException { - SolrInputDocument newDoc = new SolrInputDocument(); - newDoc.addField(idFieldName, queryId); - newDoc.addField(valueFieldName, SerializationUtils.serializeBase64(obj)); - // newDoc.addField(valueTextFieldName, ojbectToString(obj)); - server.add(newDoc); - if(commit) - server.commit(); - } - - - public void commit() throws IOException, SolrServerException { - server.commit(); - } - - public void shutdown() throws IOException { - server.close(); - } - /** - * @param queryId - * @return null if no cache has been created for this queryId; - * an empty List object if there are no results for the queryId (i.e., the query has been executed before but no results - * were found to match the query); - */ - public Object retrieve(String queryId) throws SolrServerException, ClassNotFoundException, IOException { - ModifiableSolrParams params = new ModifiableSolrParams(); - params.set("q", idFieldName + ":" + ClientUtils.escapeQueryChars(queryId)); - params.set("fl",idFieldName+","+valueFieldName); - - QueryResponse response = server.query(params); - if (response.getResults().getNumFound() == 0) - return null; - - SolrDocument doc = response.getResults().get(0); - if(doc.getFieldValue(valueFieldName)==null) - return null; - - Object data = doc.getFieldValue(valueFieldName); - Object dataBytes = ((ArrayList)data).get(0); - - Object object = SerializationUtils.deserializeBase64((byte[]) dataBytes); - return object; - } - +package uk.ac.shef.dcs.util; + +import org.apache.solr.client.solrj.SolrServerException; +import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; +import org.apache.solr.client.solrj.response.QueryResponse; +import org.apache.solr.client.solrj.util.ClientUtils; +import org.apache.solr.common.SolrDocument; +import org.apache.solr.common.SolrInputDocument; +import org.apache.solr.common.params.ModifiableSolrParams; + +import java.io.IOException; +import java.util.ArrayList; + +/** + * Created with IntelliJ IDEA. + * User: zqz + * Date: 21/01/14 + * Time: 12:58 + * To change this template use File | Settings | File Templates. + */ +public class SolrCache { + + private EmbeddedSolrServer server; + private static final String idFieldName = "id"; + private static final String valueFieldName = "value"; + + public SolrCache(EmbeddedSolrServer server) { + this.server=server; + } + + //queryId - what is the query + //interpretationResults: key in the map is a value from a single cell in a table row; value in the map is the score as a measure of confidence that cell should be main subject + public void cache(String queryId, Object obj, boolean commit) throws IOException, SolrServerException { + SolrInputDocument newDoc = new SolrInputDocument(); + newDoc.addField(idFieldName, queryId); + newDoc.addField(valueFieldName, SerializationUtils.serializeBase64(obj)); + // newDoc.addField(valueTextFieldName, ojbectToString(obj)); + server.add(newDoc); + if(commit) + server.commit(); + } + + + public void commit() throws IOException, SolrServerException { + server.commit(); + } + + public void shutdown() throws IOException { + server.close(); + } + /** + * @param queryId + * @return null if no cache has been created for this queryId; + * an empty List object if there are no results for the queryId (i.e., the query has been executed before but no results + * were found to match the query); + */ + public Object retrieve(String queryId) throws SolrServerException, ClassNotFoundException, IOException { + ModifiableSolrParams params = new ModifiableSolrParams(); + params.set("q", idFieldName + ":" + ClientUtils.escapeQueryChars(queryId)); + params.set("fl",idFieldName+","+valueFieldName); + + QueryResponse response = server.query(params); + if (response.getResults().getNumFound() == 0) + return null; + + SolrDocument doc = response.getResults().get(0); + if(doc.getFieldValue(valueFieldName)==null) + return null; + + Object data = doc.getFieldValue(valueFieldName); + Object dataBytes = ((ArrayList)data).get(0); + + Object object = SerializationUtils.deserializeBase64((byte[]) dataBytes); + return object; + } + } \ No newline at end of file diff --git a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchException.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchException.java index 0eb2004d..e6630762 100644 --- a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchException.java +++ b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchException.java @@ -1,19 +1,19 @@ -package uk.ac.shef.dcs.kbsearch; - -/** - * - */ -public class KBSearchException extends Exception { - - public KBSearchException(String msg){ - super(msg); - } - - public KBSearchException(Exception e){ - super(e); - } - - public KBSearchException(String msg, Exception e){ - super(msg, e); - } -} +package uk.ac.shef.dcs.kbsearch; + +/** + * + */ +public class KBSearchException extends Exception { + + public KBSearchException(String msg){ + super(msg); + } + + public KBSearchException(Exception e){ + super(e); + } + + public KBSearchException(String msg, Exception e){ + super(msg, e); + } +} diff --git a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchFactory.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchFactory.java index 9a0eded3..69dcf53d 100644 --- a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchFactory.java +++ b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/KBSearchFactory.java @@ -1,58 +1,58 @@ -package uk.ac.shef.dcs.kbsearch; - -import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; -import uk.ac.shef.dcs.kbsearch.freebase.FreebaseSearch; -import uk.ac.shef.dcs.kbsearch.sparql.DBpediaSearch; - -import java.io.FileInputStream; -import java.util.Properties; - -/** - * Created by - on 17/03/2016. - */ -public class KBSearchFactory { - - - public KBSearch createInstance( - String kbSearchPropertyFile, - EmbeddedSolrServer cacheEntity, EmbeddedSolrServer cacheConcept, - EmbeddedSolrServer cacheProperty,EmbeddedSolrServer cacheSimilarity) throws KBSearchException { - - Properties properties = new Properties(); - try { - properties.load(new FileInputStream(kbSearchPropertyFile)); - - String className = properties.getProperty(KBSearch.KB_SEARCH_CLASS); - boolean fuzzyKeywords = Boolean.valueOf(properties.getProperty(KBSearch.KB_SEARCH_TRY_FUZZY_KEYWORD,"false")); - if (className.equals(FreebaseSearch.class.getName())) { - return (KBSearch) Class.forName(className). - getDeclaredConstructor(Properties.class, - Boolean.class, - EmbeddedSolrServer.class, - EmbeddedSolrServer.class, - EmbeddedSolrServer.class, - EmbeddedSolrServer.class). - newInstance(properties, - fuzzyKeywords, cacheEntity, cacheConcept, cacheProperty, - cacheSimilarity); - }else if(className.equals(DBpediaSearch.class.getName())){ - return (KBSearch) Class.forName(className). - getDeclaredConstructor(Properties.class, - Boolean.class, - EmbeddedSolrServer.class, - EmbeddedSolrServer.class, - EmbeddedSolrServer.class, - EmbeddedSolrServer.class). - newInstance(properties, - fuzzyKeywords, cacheEntity, cacheConcept, cacheProperty, - cacheSimilarity); - } - - else { - throw new KBSearchException("Class:" + className + " not supported"); - } - } catch (Exception e) { - throw new KBSearchException(e); - } - } -} +package uk.ac.shef.dcs.kbsearch; + +import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; +import uk.ac.shef.dcs.kbsearch.freebase.FreebaseSearch; +import uk.ac.shef.dcs.kbsearch.sparql.DBpediaSearch; + +import java.io.FileInputStream; +import java.util.Properties; + +/** + * Created by - on 17/03/2016. + */ +public class KBSearchFactory { + + + public KBSearch createInstance( + String kbSearchPropertyFile, + EmbeddedSolrServer cacheEntity, EmbeddedSolrServer cacheConcept, + EmbeddedSolrServer cacheProperty,EmbeddedSolrServer cacheSimilarity) throws KBSearchException { + + Properties properties = new Properties(); + try { + properties.load(new FileInputStream(kbSearchPropertyFile)); + + String className = properties.getProperty(KBSearch.KB_SEARCH_CLASS); + boolean fuzzyKeywords = Boolean.valueOf(properties.getProperty(KBSearch.KB_SEARCH_TRY_FUZZY_KEYWORD,"false")); + if (className.equals(FreebaseSearch.class.getName())) { + return (KBSearch) Class.forName(className). + getDeclaredConstructor(Properties.class, + Boolean.class, + EmbeddedSolrServer.class, + EmbeddedSolrServer.class, + EmbeddedSolrServer.class, + EmbeddedSolrServer.class). + newInstance(properties, + fuzzyKeywords, cacheEntity, cacheConcept, cacheProperty, + cacheSimilarity); + }else if(className.equals(DBpediaSearch.class.getName())){ + return (KBSearch) Class.forName(className). + getDeclaredConstructor(Properties.class, + Boolean.class, + EmbeddedSolrServer.class, + EmbeddedSolrServer.class, + EmbeddedSolrServer.class, + EmbeddedSolrServer.class). + newInstance(properties, + fuzzyKeywords, cacheEntity, cacheConcept, cacheProperty, + cacheSimilarity); + } + + else { + throw new KBSearchException("Class:" + className + " not supported"); + } + } catch (Exception e) { + throw new KBSearchException(e); + } + } +} diff --git a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseAttribute.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseAttribute.java index 747f5b71..9869c8af 100644 --- a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseAttribute.java +++ b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseAttribute.java @@ -1,26 +1,26 @@ -package uk.ac.shef.dcs.kbsearch.freebase; - -import uk.ac.shef.dcs.kbsearch.model.Attribute; - -/** - * Created by - on 06/04/2016. - */ -public class FreebaseAttribute extends Attribute { - - private static final long serialVersionUID = -1208426557010474692L; - - - public FreebaseAttribute(String relationURI, String value) { - super(relationURI, value); - } - - @Override - public boolean isAlias() { - return getRelationURI().equals(FreebaseEnum.RELATION_HASALIAS.getString()); - } - - @Override - public boolean isDescription() { - return getRelationURI().equals(FreebaseEnum.RELATION_HASDESCRIPTION.getString()); - } -} +package uk.ac.shef.dcs.kbsearch.freebase; + +import uk.ac.shef.dcs.kbsearch.model.Attribute; + +/** + * Created by - on 06/04/2016. + */ +public class FreebaseAttribute extends Attribute { + + private static final long serialVersionUID = -1208426557010474692L; + + + public FreebaseAttribute(String relationURI, String value) { + super(relationURI, value); + } + + @Override + public boolean isAlias() { + return getRelationURI().equals(FreebaseEnum.RELATION_HASALIAS.getString()); + } + + @Override + public boolean isDescription() { + return getRelationURI().equals(FreebaseEnum.RELATION_HASDESCRIPTION.getString()); + } +} diff --git a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseEnum.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseEnum.java index a35b6138..eee9b6d9 100644 --- a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseEnum.java +++ b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseEnum.java @@ -1,30 +1,30 @@ -package uk.ac.shef.dcs.kbsearch.freebase; - -/** - * Created by - on 31/03/2016. - */ -public enum FreebaseEnum { - - RELATION_HASALIAS("/common/topic/alias"), - RELATION_HASTYPE("/type/object/type"), - RELATION_RANGEOFPROPERTY("/type/property/expected_type"), - RELATION_HASNAME("/type/object/name"), - RELATION_HASDESCRIPTION("/common/topic/description"), - RELATION_HASDOCUMENTTEXT("/common/document/text"), - - TYPE_TYPE("/type/type"), - TYPE_PROPERTYOFTYPE("/type/type/properties"), - TYPE_COMMON_TOPIC("/common/topic"), - TYPE_USER("/user"); - - - private String string; - - FreebaseEnum(String s){ - this.string=s; - } - - public String getString(){ - return string; - } -} +package uk.ac.shef.dcs.kbsearch.freebase; + +/** + * Created by - on 31/03/2016. + */ +public enum FreebaseEnum { + + RELATION_HASALIAS("/common/topic/alias"), + RELATION_HASTYPE("/type/object/type"), + RELATION_RANGEOFPROPERTY("/type/property/expected_type"), + RELATION_HASNAME("/type/object/name"), + RELATION_HASDESCRIPTION("/common/topic/description"), + RELATION_HASDOCUMENTTEXT("/common/document/text"), + + TYPE_TYPE("/type/type"), + TYPE_PROPERTYOFTYPE("/type/type/properties"), + TYPE_COMMON_TOPIC("/common/topic"), + TYPE_USER("/user"); + + + private String string; + + FreebaseEnum(String s){ + this.string=s; + } + + public String getString(){ + return string; + } +} diff --git a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryInterrupter.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryInterrupter.java index f2646687..492de77e 100644 --- a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryInterrupter.java +++ b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryInterrupter.java @@ -1,93 +1,93 @@ -package uk.ac.shef.dcs.kbsearch.freebase; - -import com.google.api.client.http.HttpRequest; -import com.google.api.client.http.HttpResponse; - -import java.io.IOException; -import java.util.Date; - -/** - */ -public class FreebaseQueryInterrupter { - - private Date timestamp_firstQueryToday; - private Date timestamp_lastQueryToday; - private int countingQuery_today; - private Date timestamp_firstQueryInTenSeconds; - private Date timestamp_lastQueryInTenSeconds; - private int countingQuery_inTenSeconds; - - private int maxQueriesPerSecond; - private int maxQueriesPerDay; - - public FreebaseQueryInterrupter(int maxQPerSec, int maxQPerDay) { - this.maxQueriesPerDay = maxQPerDay; - this.maxQueriesPerSecond = maxQPerSec; - } - - public HttpResponse executeQuery(HttpRequest request, boolean forceWait1Second) throws IOException { - if (countingQuery_inTenSeconds > maxQueriesPerSecond) { - Date now = new Date(); - if (now.getTime() > timestamp_lastQueryInTenSeconds.getTime()) { //we passed the "n query per second" timing threshold - //ok reset - resetSecondLimiter(); - } else { - System.out.println("Too many requests in a second, wait for 10 seconds."); - waitFor(10); - resetSecondLimiter(); - } - } - if (countingQuery_today > maxQueriesPerDay) { - Date now = new Date(); - long wait = timestamp_lastQueryToday.getTime() - now.getTime(); - if (wait < 0) { - //ok - resetDayLimiter(); - } else { - System.out.println("Too many requests in a day, wait for:" + (wait / 1000) + " seconds"); - waitFor(wait / 1000); - resetDayLimiter(); - } - } - - if (timestamp_firstQueryInTenSeconds == null) { - resetSecondLimiter(); - } - if (timestamp_firstQueryToday == null) { - resetDayLimiter(); - } - - - //successfully completed this query - - countingQuery_inTenSeconds++; - countingQuery_today++; - HttpResponse response=request.execute(); - if(forceWait1Second){ - try{ - Thread.sleep(1000); - }catch (Exception e){} - } - - return response; - } - - private void resetSecondLimiter() { - timestamp_firstQueryInTenSeconds = new Date(); - timestamp_lastQueryInTenSeconds = new Date(timestamp_firstQueryInTenSeconds.getTime() + (10 * 1000)); - countingQuery_inTenSeconds = 0; - } - - private void resetDayLimiter() { - timestamp_firstQueryToday = new Date(); - timestamp_lastQueryToday = new Date(timestamp_firstQueryToday.getTime() + (86400 * 1000)); - countingQuery_today = 0; - } - - private void waitFor(long seconds) { - try { - Thread.sleep(seconds * 1000); - } catch (InterruptedException e) { - } - } -} +package uk.ac.shef.dcs.kbsearch.freebase; + +import com.google.api.client.http.HttpRequest; +import com.google.api.client.http.HttpResponse; + +import java.io.IOException; +import java.util.Date; + +/** + */ +public class FreebaseQueryInterrupter { + + private Date timestamp_firstQueryToday; + private Date timestamp_lastQueryToday; + private int countingQuery_today; + private Date timestamp_firstQueryInTenSeconds; + private Date timestamp_lastQueryInTenSeconds; + private int countingQuery_inTenSeconds; + + private int maxQueriesPerSecond; + private int maxQueriesPerDay; + + public FreebaseQueryInterrupter(int maxQPerSec, int maxQPerDay) { + this.maxQueriesPerDay = maxQPerDay; + this.maxQueriesPerSecond = maxQPerSec; + } + + public HttpResponse executeQuery(HttpRequest request, boolean forceWait1Second) throws IOException { + if (countingQuery_inTenSeconds > maxQueriesPerSecond) { + Date now = new Date(); + if (now.getTime() > timestamp_lastQueryInTenSeconds.getTime()) { //we passed the "n query per second" timing threshold + //ok reset + resetSecondLimiter(); + } else { + System.out.println("Too many requests in a second, wait for 10 seconds."); + waitFor(10); + resetSecondLimiter(); + } + } + if (countingQuery_today > maxQueriesPerDay) { + Date now = new Date(); + long wait = timestamp_lastQueryToday.getTime() - now.getTime(); + if (wait < 0) { + //ok + resetDayLimiter(); + } else { + System.out.println("Too many requests in a day, wait for:" + (wait / 1000) + " seconds"); + waitFor(wait / 1000); + resetDayLimiter(); + } + } + + if (timestamp_firstQueryInTenSeconds == null) { + resetSecondLimiter(); + } + if (timestamp_firstQueryToday == null) { + resetDayLimiter(); + } + + + //successfully completed this query + + countingQuery_inTenSeconds++; + countingQuery_today++; + HttpResponse response=request.execute(); + if(forceWait1Second){ + try{ + Thread.sleep(1000); + }catch (Exception e){} + } + + return response; + } + + private void resetSecondLimiter() { + timestamp_firstQueryInTenSeconds = new Date(); + timestamp_lastQueryInTenSeconds = new Date(timestamp_firstQueryInTenSeconds.getTime() + (10 * 1000)); + countingQuery_inTenSeconds = 0; + } + + private void resetDayLimiter() { + timestamp_firstQueryToday = new Date(); + timestamp_lastQueryToday = new Date(timestamp_firstQueryToday.getTime() + (86400 * 1000)); + countingQuery_today = 0; + } + + private void waitFor(long seconds) { + try { + Thread.sleep(seconds * 1000); + } catch (InterruptedException e) { + } + } +} diff --git a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryProxy.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryProxy.java index 3ee013ea..9faa6afb 100644 --- a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryProxy.java +++ b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseQueryProxy.java @@ -1,533 +1,533 @@ -package uk.ac.shef.dcs.kbsearch.freebase; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.URL; -import java.util.*; - -import com.google.api.client.http.GenericUrl; -import com.google.api.client.http.HttpRequest; -import com.google.api.client.http.HttpRequestFactory; -import com.google.api.client.http.HttpResponse; -import com.google.api.client.http.HttpTransport; -import com.google.api.client.http.javanet.NetHttpTransport; -import org.apache.commons.collections.CollectionUtils; -import org.apache.log4j.Logger; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; -import uk.ac.shef.dcs.kbsearch.model.Attribute; -import uk.ac.shef.dcs.kbsearch.model.Clazz; -import uk.ac.shef.dcs.util.StringUtils; - - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 18/01/14 - * Time: 22:06 - * To change this template use File | Settings | File Templates. - */ -public class FreebaseQueryProxy { - - - public static Logger LOG = Logger.getLogger(FreebaseQueryProxy.class.getName()); - //private String BASE_QUERY_URL="https://www.googleapis.com/freebase/v1/mqlread"; - private JSONParser jsonParser; - private FreebaseQueryInterrupter interrupter; - private HttpTransport httpTransport; - private HttpRequestFactory requestFactory; - private Properties properties; - - private static final String FB_MAX_QUERY_PER_SECOND="fb.query.max.sec"; - - private static final String FB_MAX_QUERY_PER_DAY="fb.query.max.day"; - - private static final String FB_QUERY_API_URL_TOPIC ="fb.query.apiurl.topic"; - - private static final String FB_QUERY_API_URL_SEARCH ="fb.query.apiurl.search"; - - private static final String FB_QUERY_API_URL_MQL ="fb.query.apiurl.mql"; - - private static final String FB_QUERY_API_KEY="fb.query.api.key"; - - private static final String FB_HOMEPAGE="fb.homepage"; - - private static final String FB_QUERY_PARAM_LIMIT="fb.query.param.limit"; - - public FreebaseQueryProxy(Properties properties) throws IOException { - this.properties=properties; - interrupter = new FreebaseQueryInterrupter(Integer.valueOf(properties.get(FB_MAX_QUERY_PER_SECOND).toString()), - Integer.valueOf(properties.get(FB_MAX_QUERY_PER_DAY).toString())); - httpTransport = new NetHttpTransport(); - requestFactory = httpTransport.createRequestFactory(); - jsonParser = new JSONParser(); - } - - - //given a topic id, returns its attributes. - public List topicapi_getAttributesOfTopic(String id) throws IOException { - Date start = new Date(); - List res = new ArrayList<>(); - GenericUrl url = new GenericUrl(properties.get(FB_QUERY_API_URL_TOPIC).toString() + id); - url.put("key", properties.get(FB_QUERY_API_KEY)); - url.put("limit", 100); - HttpRequest request = requestFactory.buildGetRequest(url); - HttpResponse httpResponse = interrupter.executeQuery(request, true); - try { - JSONObject topic = (JSONObject) jsonParser.parse(httpResponse.parseAsString()); - JSONObject properties = (JSONObject) topic.get("property"); - parseTopicAPIResult(properties, res, true); - } catch (ParseException pe) { - pe.printStackTrace(); - } - LOG.debug("\tQueryFreebase (attributes):" + (new Date().getTime() - start.getTime())); - return res; - - } - - public List topicapi_getTypesOfTopicID(String id) throws IOException { - Date start = new Date(); - List res = new ArrayList<>(); - GenericUrl url = new GenericUrl(properties.get(FB_QUERY_API_URL_TOPIC).toString() + id); - url.put("key", properties.get(FB_QUERY_API_KEY)); - url.put("filter", FreebaseEnum.RELATION_HASTYPE.getString()); - HttpRequest request = requestFactory.buildGetRequest(url); - HttpResponse httpResponse = interrupter.executeQuery(request, true); - try { - JSONObject topic = (JSONObject) jsonParser.parse(httpResponse.parseAsString()); - JSONObject properties = (JSONObject) topic.get("property"); - if(properties!=null) - parseTopicAPIResult(properties, res, true); - } catch (ParseException pe) { - pe.printStackTrace(); - } - LOG.debug("\tQueryFreebase (types):" + (new Date().getTime() - start.getTime())); - return res; - - } - - public List topicapi_getAttributesOfTopicID(String id, String filter) throws IOException { - Date start = new Date(); - List res = new ArrayList<>(); - GenericUrl url = new GenericUrl(properties.get(FB_QUERY_API_URL_TOPIC).toString() + id); - url.put("key", properties.get(FB_QUERY_API_KEY)); - url.put("filter", filter); - url.put("limit", 200); - HttpRequest request = requestFactory.buildGetRequest(url); - HttpResponse httpResponse = interrupter.executeQuery(request, true); - try { - JSONObject topic = (JSONObject) jsonParser.parse(httpResponse.parseAsString()); - JSONObject properties = (JSONObject) topic.get("property"); - parseTopicAPIResult(properties, res, true); - } catch (ParseException pe) { - pe.printStackTrace(); - } - LOG.debug("\tQueryFreebase (attributes):" + (new Date().getTime() - start.getTime())); - return res; - - } - - private void parseTopicAPIResult(JSONObject json, List out, boolean directRelation) { - /*if(json==null) - System.out.println();*/ - @SuppressWarnings("unchecked") - Iterator prop_keys = json.keySet().iterator(); - while (prop_keys.hasNext()) { - String prop = prop_keys.next(); - try { - JSONObject propValueObj = (JSONObject) json.get(prop); - JSONArray jsonArray = (JSONArray) propValueObj.get("values"); - Object c = propValueObj.get("valuetype"); - if (c != null && c.toString().equals("compound")) - parsePropertyValues(jsonArray, prop, out, directRelation, true); - else - parsePropertyValues(jsonArray, prop, out, directRelation, false); - } catch (Exception e) { - } - } - } - - private FreebaseTopic parseSearchAPIResult(JSONObject json) { - FreebaseTopic obj = new FreebaseTopic(json.get("mid").toString()); - Object o = json.get("mid"); - if (o != null) - obj.setId(o.toString()); - obj.setLabel(json.get("name").toString()); - obj.setScore(Double.valueOf(json.get("score").toString())); - - obj.setLanguage(json.get("lang").toString()); - return obj; - } - - private void parsePropertyValues(JSONArray json, String property, List out, boolean directRelation, boolean skipCompound) { - Iterator entry = json.iterator(); - Object val = null, id = null, mid = null, more_props = null; - while (entry.hasNext()) { - JSONObject key = (JSONObject) entry.next(); - if (skipCompound) { - more_props = key.get("property"); - if (more_props != null) - parseTopicAPIResult((JSONObject) more_props, out, false); - continue; - } - - val = key.get("text"); - if (property.equals(FreebaseEnum.RELATION_HASDESCRIPTION.getString()) - || property.equals(FreebaseEnum.RELATION_HASDOCUMENTTEXT.getString())) { - Object changeVal = key.get("value"); - if (changeVal != null) - val = changeVal; - } - id = key.get("id"); - mid = key.get("mid"); - if (id == null && mid != null) id = mid; - Attribute attr = new FreebaseAttribute(property, val.toString()); - attr.setIsDirect(directRelation); - if (val != null && id != null) { - attr.setValueURI(id.toString()); - out.add(attr); - } - else if (val != null) { - out.add(attr); - } - } - - } - - - //operator - any means or; all means and - public List searchapi_getTopicsByNameAndType(String name, String operator, boolean tokenMatch, int maxResult, String... types) throws IOException { - List query_tokens = StringUtils.splitToAlphaNumericTokens(name, true); - - Date start = new Date(); - HttpTransport httpTransport = new NetHttpTransport(); - HttpRequestFactory requestFactory = httpTransport.createRequestFactory(); - List res = new ArrayList<>(); - - GenericUrl url = new GenericUrl(properties.get(FB_QUERY_API_URL_SEARCH).toString()); - url.put("query", name); - url.put("limit", 20); - url.put("prefixed", true); - url.put("key", properties.get(FB_QUERY_API_KEY)); - - StringBuilder filter = new StringBuilder(); - for (String t : types) { - filter.append("type:").append(t).append(" "); - } - - if (filter.length() > 0) - url.put("filter", "(" + operator + " " + filter.toString().trim() + ")"); - - HttpRequest request = requestFactory.buildGetRequest(url); - HttpResponse httpResponse = interrupter.executeQuery(request, true); - JSONObject response; - try { - response = (JSONObject) jsonParser.parse(httpResponse.parseAsString()); - JSONArray results = (JSONArray) response.get("result"); - int count = 0; - for (Object result : results) { - FreebaseTopic top = parseSearchAPIResult((JSONObject) result); - - if (count < maxResult) { - if (tokenMatch) { - List candidate_tokens = StringUtils.splitToAlphaNumericTokens(top.getLabel(), true); - candidate_tokens.retainAll(query_tokens); - if (candidate_tokens.size() > 0) { - res.add(top); - count++; - } - } else { - res.add(top); - count++; - } - } - - //print or save this id - } - - } catch (ParseException e) { - e.printStackTrace(); - } - - LOG.debug("\tQueryFreebase (search for topics):" + (new Date().getTime() - start.getTime())); - return res; - } - - - public List mql_topics_with_name(int maxResults, String name, String operator, String... types) throws IOException { - Set query_tokens = new HashSet(); - for (String t : name.split("\\s+")) { - t = t.trim(); - if (t.length() > 0) - query_tokens.add(t); - } - - Date start = new Date(); - HttpTransport httpTransport = new NetHttpTransport(); - HttpRequestFactory requestFactory = httpTransport.createRequestFactory(); - List res = new ArrayList(); - - final Map candidates = new HashMap(); - int limit = 20; - int iterations = maxResults % limit; - iterations = iterations == 0 ? maxResults / limit : maxResults / limit + 1; - String cursorPoint = ""; - for (int i = 0; i < iterations; i++) { - String query = "[{\"mid\":null," + - "\"name\":null," + - "\"name~=\":\"" + name + "\"," + - "\""+FreebaseEnum.RELATION_HASTYPE+"\":[],"; - if (types.length > 0) { - if (operator.equals("any")) { - query = query + "\"type|=\":["; - for (String t : types) { - query = query + "\"" + t + "\","; - } - if (query.endsWith(",")) - query = query.substring(0, query.length() - 1).trim(); - query = query + "],"; - } else if (operator.equals("and")) { - for (int n = 0; n < types.length; n++) { - String t = types[n]; - if (n == 0) - query = query + "\"type\":\"" + t + "\","; - else - query = query + "\"and:type\":\"" + t + "\","; - } - } - } - - query = query + - "\"limit\":" + limit + "" + - "}]"; - - GenericUrl url = new GenericUrl(properties.get(FB_QUERY_API_URL_MQL).toString()); - url.put("query", query); - url.put("key", properties.get(FB_QUERY_API_KEY)); - url.put("cursor", cursorPoint); - - HttpRequest request = requestFactory.buildGetRequest(url); - HttpResponse httpResponse = interrupter.executeQuery(request, true); - System.out.print(limit * (i + 1)); - JSONObject response; - try { - response = (JSONObject) jsonParser.parse(httpResponse.parseAsString()); - cursorPoint = response.get("cursor").toString(); - JSONArray results = (JSONArray) response.get("result"); - - for (Object result : results) { - JSONObject obj = (JSONObject) result; - String id = obj.get("mid").toString(); - String e_name = obj.get("name").toString(); - FreebaseTopic ent = new FreebaseTopic(id); - ent.setLabel(e_name); - if (obj.get(FreebaseEnum.RELATION_HASTYPE.getString()) != null) { - JSONArray jsonArray = (JSONArray) obj.get(FreebaseEnum.RELATION_HASTYPE.getString()); - for (int n = 0; n < jsonArray.size(); n++) { - String the_type = jsonArray.get(n).toString(); - if (!the_type.equals(FreebaseEnum.TYPE_COMMON_TOPIC.getString()) && !the_type.startsWith(FreebaseEnum.TYPE_USER.getString())) - ent.addType(new Clazz(the_type, the_type)); - } - } - List bow_ent = StringUtils.toBagOfWords(e_name, true, true, false); - List bow_query = StringUtils.toBagOfWords(name, true, true,false); - int intersection = CollectionUtils.intersection(bow_ent, bow_query).size(); - candidates.put(ent, ((double) intersection / bow_ent.size() + (double) intersection / bow_query.size()) / 2.0); - //print or save this id - } - - if (results.size() < limit) { - break; - } - } catch (ParseException e) { - e.printStackTrace(); - } - - } - - LOG.debug("\tQueryFreebase:" + (new Date().getTime() - start.getTime())); - res.addAll(candidates.keySet()); - Collections.sort(res, (o1, o2) -> candidates.get(o2).compareTo(candidates.get(o1))); - return res; - } - - public List mqlapi_topic_mids_with_wikipedia_pageid(String wikipedia_pageid) throws IOException { - Date start = new Date(); - httpTransport = new NetHttpTransport(); - requestFactory = httpTransport.createRequestFactory(); - List res = new ArrayList(); - - String query = "[{\"mid\":null," + - "\"id\":\"/wikipedia/en_id/" + wikipedia_pageid + "\"" + - "}]"; - - GenericUrl url = new GenericUrl(properties.get(FB_QUERY_API_URL_MQL).toString()); - url.put("query", query); - url.put("key", properties.get(FB_QUERY_API_KEY)); - - HttpRequest request = requestFactory.buildGetRequest(url); - HttpResponse httpResponse = interrupter.executeQuery(request, true); - JSONObject response; - try { - response = (JSONObject) jsonParser.parse(httpResponse.parseAsString()); - JSONArray results = (JSONArray) response.get("result"); - - for (Object result : results) { - JSONObject obj = (JSONObject) result; - String id = obj.get("mid").toString(); - res.add(id); - //print or save this id - } - } catch (ParseException e) { - e.printStackTrace(); - } - - LOG.debug("\tQueryFreebase:" + (new Date().getTime() - start.getTime())); - - return res; - } - - //given a type search for any topics of that type and return their ids - public List mqlapi_topic_mids_with_name(String name, int maxResults) throws IOException { - Date start = new Date(); - httpTransport = new NetHttpTransport(); - requestFactory = httpTransport.createRequestFactory(); - List res = new ArrayList(); - - int limit = Integer.valueOf(properties.get(FB_QUERY_PARAM_LIMIT).toString()); - int iterations = maxResults % limit; - iterations = iterations == 0 ? maxResults / limit : maxResults / limit + 1; - String cursorPoint = ""; - for (int i = 0; i < iterations; i++) { - String query = "[{\"mid\":null," + - "\"name\":\"" + name + "\"," + - "\"limit\":" + limit + "" + - "}]"; - - GenericUrl url = new GenericUrl(properties.get(FB_QUERY_API_URL_MQL).toString()); - url.put("query", query); - url.put("key", properties.get(FB_QUERY_API_KEY)); - url.put("cursor", cursorPoint); - - HttpRequest request = requestFactory.buildGetRequest(url); - HttpResponse httpResponse = interrupter.executeQuery(request, true); - System.out.println(limit * (i + 1)); - JSONObject response; - try { - response = (JSONObject) jsonParser.parse(httpResponse.parseAsString()); - cursorPoint = response.get("cursor").toString(); - JSONArray results = (JSONArray) response.get("result"); - - for (Object result : results) { - JSONObject obj = (JSONObject) result; - String id = obj.get("mid").toString(); - res.add(id); - - //print or save this id - } - - if (results.size() < limit) { - break; - } - - } catch (ParseException e) { - e.printStackTrace(); - } - } - LOG.debug("\tQueryFreebase:" + (new Date().getTime() - start.getTime())); - - return res; - } - - public List mqlapi_instances_of_type(String name, int maxResults) throws IOException { - Date start = new Date(); - httpTransport = new NetHttpTransport(); - requestFactory = httpTransport.createRequestFactory(); - List res = new ArrayList(); - - int limit = Integer.valueOf(properties.get(FB_QUERY_PARAM_LIMIT).toString()); - int iterations = maxResults % limit; - iterations = iterations == 0 ? maxResults / limit : maxResults / limit + 1; - String cursorPoint = ""; - for (int i = 0; i < iterations; i++) { - String query = "[{\"name\":null," + - "\"type\":\"" + name + "\"," + - "\"limit\":" + limit + "" + - "}]"; - - GenericUrl url = new GenericUrl(properties.get(FB_QUERY_API_URL_MQL).toString()); - url.put("query", query); - url.put("key", properties.get(FB_QUERY_API_KEY)); - url.put("cursor", cursorPoint); - - HttpRequest request = requestFactory.buildGetRequest(url); - HttpResponse httpResponse = interrupter.executeQuery(request, true); - System.out.println(limit * (i + 1)); - JSONObject response; - try { - response = (JSONObject) jsonParser.parse(httpResponse.parseAsString()); - cursorPoint = response.get("cursor").toString(); - JSONArray results = (JSONArray) response.get("result"); - - for (Object result : results) { - JSONObject obj = (JSONObject) result; - String id = obj.get("name").toString(); - res.add(id); - - //print or save this id - } - - if (results.size() < limit) { - break; - } - - } catch (ParseException e) { - e.printStackTrace(); - } - } - LOG.debug("\tQueryFreebase:" + (new Date().getTime() - start.getTime())); - - return res; - } - - /*public static void main(String[] args) throws IOException { - FreebaseQueryProxy helper = new FreebaseQueryProxy("D:\\Work\\lodiedata\\tableminer_gs/freebase.properties"); - List artist= helper.mqlapi_instances_of_type("/music/artist",10000); - System.out.println(artist); - }*/ - - - public double find_granularityForType(String type) throws IOException { - if(type.startsWith("/m/")) //if the type id starts with "/m/" in strict sense it is a topic representing a concept - //but is not listed as a type in freebase - return 1.0; - String url = properties.get(FB_HOMEPAGE).toString() +type+"?instances="; - Date startTime = new Date(); - URL connection = new URL(url); - BufferedReader in = new BufferedReader( - new InputStreamReader(connection.openStream())); - - String result=null; - String inputLine; - while ((inputLine = in.readLine()) != null) { - int start = inputLine.indexOf("span data-value="); - if(start!=-1) { - start+=16; - int end = inputLine.indexOf(" ",16); - if(start0) - return new Double(result); - return 0.0; - } -} +package uk.ac.shef.dcs.kbsearch.freebase; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.*; + +import com.google.api.client.http.GenericUrl; +import com.google.api.client.http.HttpRequest; +import com.google.api.client.http.HttpRequestFactory; +import com.google.api.client.http.HttpResponse; +import com.google.api.client.http.HttpTransport; +import com.google.api.client.http.javanet.NetHttpTransport; +import org.apache.commons.collections.CollectionUtils; +import org.apache.log4j.Logger; +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; +import uk.ac.shef.dcs.kbsearch.model.Attribute; +import uk.ac.shef.dcs.kbsearch.model.Clazz; +import uk.ac.shef.dcs.util.StringUtils; + + +/** + * Created with IntelliJ IDEA. + * User: zqz + * Date: 18/01/14 + * Time: 22:06 + * To change this template use File | Settings | File Templates. + */ +public class FreebaseQueryProxy { + + + public static Logger LOG = Logger.getLogger(FreebaseQueryProxy.class.getName()); + //private String BASE_QUERY_URL="https://www.googleapis.com/freebase/v1/mqlread"; + private JSONParser jsonParser; + private FreebaseQueryInterrupter interrupter; + private HttpTransport httpTransport; + private HttpRequestFactory requestFactory; + private Properties properties; + + private static final String FB_MAX_QUERY_PER_SECOND="fb.query.max.sec"; + + private static final String FB_MAX_QUERY_PER_DAY="fb.query.max.day"; + + private static final String FB_QUERY_API_URL_TOPIC ="fb.query.apiurl.topic"; + + private static final String FB_QUERY_API_URL_SEARCH ="fb.query.apiurl.search"; + + private static final String FB_QUERY_API_URL_MQL ="fb.query.apiurl.mql"; + + private static final String FB_QUERY_API_KEY="fb.query.api.key"; + + private static final String FB_HOMEPAGE="fb.homepage"; + + private static final String FB_QUERY_PARAM_LIMIT="fb.query.param.limit"; + + public FreebaseQueryProxy(Properties properties) throws IOException { + this.properties=properties; + interrupter = new FreebaseQueryInterrupter(Integer.valueOf(properties.get(FB_MAX_QUERY_PER_SECOND).toString()), + Integer.valueOf(properties.get(FB_MAX_QUERY_PER_DAY).toString())); + httpTransport = new NetHttpTransport(); + requestFactory = httpTransport.createRequestFactory(); + jsonParser = new JSONParser(); + } + + + //given a topic id, returns its attributes. + public List topicapi_getAttributesOfTopic(String id) throws IOException { + Date start = new Date(); + List res = new ArrayList<>(); + GenericUrl url = new GenericUrl(properties.get(FB_QUERY_API_URL_TOPIC).toString() + id); + url.put("key", properties.get(FB_QUERY_API_KEY)); + url.put("limit", 100); + HttpRequest request = requestFactory.buildGetRequest(url); + HttpResponse httpResponse = interrupter.executeQuery(request, true); + try { + JSONObject topic = (JSONObject) jsonParser.parse(httpResponse.parseAsString()); + JSONObject properties = (JSONObject) topic.get("property"); + parseTopicAPIResult(properties, res, true); + } catch (ParseException pe) { + pe.printStackTrace(); + } + LOG.debug("\tQueryFreebase (attributes):" + (new Date().getTime() - start.getTime())); + return res; + + } + + public List topicapi_getTypesOfTopicID(String id) throws IOException { + Date start = new Date(); + List res = new ArrayList<>(); + GenericUrl url = new GenericUrl(properties.get(FB_QUERY_API_URL_TOPIC).toString() + id); + url.put("key", properties.get(FB_QUERY_API_KEY)); + url.put("filter", FreebaseEnum.RELATION_HASTYPE.getString()); + HttpRequest request = requestFactory.buildGetRequest(url); + HttpResponse httpResponse = interrupter.executeQuery(request, true); + try { + JSONObject topic = (JSONObject) jsonParser.parse(httpResponse.parseAsString()); + JSONObject properties = (JSONObject) topic.get("property"); + if(properties!=null) + parseTopicAPIResult(properties, res, true); + } catch (ParseException pe) { + pe.printStackTrace(); + } + LOG.debug("\tQueryFreebase (types):" + (new Date().getTime() - start.getTime())); + return res; + + } + + public List topicapi_getAttributesOfTopicID(String id, String filter) throws IOException { + Date start = new Date(); + List res = new ArrayList<>(); + GenericUrl url = new GenericUrl(properties.get(FB_QUERY_API_URL_TOPIC).toString() + id); + url.put("key", properties.get(FB_QUERY_API_KEY)); + url.put("filter", filter); + url.put("limit", 200); + HttpRequest request = requestFactory.buildGetRequest(url); + HttpResponse httpResponse = interrupter.executeQuery(request, true); + try { + JSONObject topic = (JSONObject) jsonParser.parse(httpResponse.parseAsString()); + JSONObject properties = (JSONObject) topic.get("property"); + parseTopicAPIResult(properties, res, true); + } catch (ParseException pe) { + pe.printStackTrace(); + } + LOG.debug("\tQueryFreebase (attributes):" + (new Date().getTime() - start.getTime())); + return res; + + } + + private void parseTopicAPIResult(JSONObject json, List out, boolean directRelation) { + /*if(json==null) + System.out.println();*/ + @SuppressWarnings("unchecked") + Iterator prop_keys = json.keySet().iterator(); + while (prop_keys.hasNext()) { + String prop = prop_keys.next(); + try { + JSONObject propValueObj = (JSONObject) json.get(prop); + JSONArray jsonArray = (JSONArray) propValueObj.get("values"); + Object c = propValueObj.get("valuetype"); + if (c != null && c.toString().equals("compound")) + parsePropertyValues(jsonArray, prop, out, directRelation, true); + else + parsePropertyValues(jsonArray, prop, out, directRelation, false); + } catch (Exception e) { + } + } + } + + private FreebaseTopic parseSearchAPIResult(JSONObject json) { + FreebaseTopic obj = new FreebaseTopic(json.get("mid").toString()); + Object o = json.get("mid"); + if (o != null) + obj.setId(o.toString()); + obj.setLabel(json.get("name").toString()); + obj.setScore(Double.valueOf(json.get("score").toString())); + + obj.setLanguage(json.get("lang").toString()); + return obj; + } + + private void parsePropertyValues(JSONArray json, String property, List out, boolean directRelation, boolean skipCompound) { + Iterator entry = json.iterator(); + Object val = null, id = null, mid = null, more_props = null; + while (entry.hasNext()) { + JSONObject key = (JSONObject) entry.next(); + if (skipCompound) { + more_props = key.get("property"); + if (more_props != null) + parseTopicAPIResult((JSONObject) more_props, out, false); + continue; + } + + val = key.get("text"); + if (property.equals(FreebaseEnum.RELATION_HASDESCRIPTION.getString()) + || property.equals(FreebaseEnum.RELATION_HASDOCUMENTTEXT.getString())) { + Object changeVal = key.get("value"); + if (changeVal != null) + val = changeVal; + } + id = key.get("id"); + mid = key.get("mid"); + if (id == null && mid != null) id = mid; + Attribute attr = new FreebaseAttribute(property, val.toString()); + attr.setIsDirect(directRelation); + if (val != null && id != null) { + attr.setValueURI(id.toString()); + out.add(attr); + } + else if (val != null) { + out.add(attr); + } + } + + } + + + //operator - any means or; all means and + public List searchapi_getTopicsByNameAndType(String name, String operator, boolean tokenMatch, int maxResult, String... types) throws IOException { + List query_tokens = StringUtils.splitToAlphaNumericTokens(name, true); + + Date start = new Date(); + HttpTransport httpTransport = new NetHttpTransport(); + HttpRequestFactory requestFactory = httpTransport.createRequestFactory(); + List res = new ArrayList<>(); + + GenericUrl url = new GenericUrl(properties.get(FB_QUERY_API_URL_SEARCH).toString()); + url.put("query", name); + url.put("limit", 20); + url.put("prefixed", true); + url.put("key", properties.get(FB_QUERY_API_KEY)); + + StringBuilder filter = new StringBuilder(); + for (String t : types) { + filter.append("type:").append(t).append(" "); + } + + if (filter.length() > 0) + url.put("filter", "(" + operator + " " + filter.toString().trim() + ")"); + + HttpRequest request = requestFactory.buildGetRequest(url); + HttpResponse httpResponse = interrupter.executeQuery(request, true); + JSONObject response; + try { + response = (JSONObject) jsonParser.parse(httpResponse.parseAsString()); + JSONArray results = (JSONArray) response.get("result"); + int count = 0; + for (Object result : results) { + FreebaseTopic top = parseSearchAPIResult((JSONObject) result); + + if (count < maxResult) { + if (tokenMatch) { + List candidate_tokens = StringUtils.splitToAlphaNumericTokens(top.getLabel(), true); + candidate_tokens.retainAll(query_tokens); + if (candidate_tokens.size() > 0) { + res.add(top); + count++; + } + } else { + res.add(top); + count++; + } + } + + //print or save this id + } + + } catch (ParseException e) { + e.printStackTrace(); + } + + LOG.debug("\tQueryFreebase (search for topics):" + (new Date().getTime() - start.getTime())); + return res; + } + + + public List mql_topics_with_name(int maxResults, String name, String operator, String... types) throws IOException { + Set query_tokens = new HashSet(); + for (String t : name.split("\\s+")) { + t = t.trim(); + if (t.length() > 0) + query_tokens.add(t); + } + + Date start = new Date(); + HttpTransport httpTransport = new NetHttpTransport(); + HttpRequestFactory requestFactory = httpTransport.createRequestFactory(); + List res = new ArrayList(); + + final Map candidates = new HashMap(); + int limit = 20; + int iterations = maxResults % limit; + iterations = iterations == 0 ? maxResults / limit : maxResults / limit + 1; + String cursorPoint = ""; + for (int i = 0; i < iterations; i++) { + String query = "[{\"mid\":null," + + "\"name\":null," + + "\"name~=\":\"" + name + "\"," + + "\""+FreebaseEnum.RELATION_HASTYPE+"\":[],"; + if (types.length > 0) { + if (operator.equals("any")) { + query = query + "\"type|=\":["; + for (String t : types) { + query = query + "\"" + t + "\","; + } + if (query.endsWith(",")) + query = query.substring(0, query.length() - 1).trim(); + query = query + "],"; + } else if (operator.equals("and")) { + for (int n = 0; n < types.length; n++) { + String t = types[n]; + if (n == 0) + query = query + "\"type\":\"" + t + "\","; + else + query = query + "\"and:type\":\"" + t + "\","; + } + } + } + + query = query + + "\"limit\":" + limit + "" + + "}]"; + + GenericUrl url = new GenericUrl(properties.get(FB_QUERY_API_URL_MQL).toString()); + url.put("query", query); + url.put("key", properties.get(FB_QUERY_API_KEY)); + url.put("cursor", cursorPoint); + + HttpRequest request = requestFactory.buildGetRequest(url); + HttpResponse httpResponse = interrupter.executeQuery(request, true); + System.out.print(limit * (i + 1)); + JSONObject response; + try { + response = (JSONObject) jsonParser.parse(httpResponse.parseAsString()); + cursorPoint = response.get("cursor").toString(); + JSONArray results = (JSONArray) response.get("result"); + + for (Object result : results) { + JSONObject obj = (JSONObject) result; + String id = obj.get("mid").toString(); + String e_name = obj.get("name").toString(); + FreebaseTopic ent = new FreebaseTopic(id); + ent.setLabel(e_name); + if (obj.get(FreebaseEnum.RELATION_HASTYPE.getString()) != null) { + JSONArray jsonArray = (JSONArray) obj.get(FreebaseEnum.RELATION_HASTYPE.getString()); + for (int n = 0; n < jsonArray.size(); n++) { + String the_type = jsonArray.get(n).toString(); + if (!the_type.equals(FreebaseEnum.TYPE_COMMON_TOPIC.getString()) && !the_type.startsWith(FreebaseEnum.TYPE_USER.getString())) + ent.addType(new Clazz(the_type, the_type)); + } + } + List bow_ent = StringUtils.toBagOfWords(e_name, true, true, false); + List bow_query = StringUtils.toBagOfWords(name, true, true,false); + int intersection = CollectionUtils.intersection(bow_ent, bow_query).size(); + candidates.put(ent, ((double) intersection / bow_ent.size() + (double) intersection / bow_query.size()) / 2.0); + //print or save this id + } + + if (results.size() < limit) { + break; + } + } catch (ParseException e) { + e.printStackTrace(); + } + + } + + LOG.debug("\tQueryFreebase:" + (new Date().getTime() - start.getTime())); + res.addAll(candidates.keySet()); + Collections.sort(res, (o1, o2) -> candidates.get(o2).compareTo(candidates.get(o1))); + return res; + } + + public List mqlapi_topic_mids_with_wikipedia_pageid(String wikipedia_pageid) throws IOException { + Date start = new Date(); + httpTransport = new NetHttpTransport(); + requestFactory = httpTransport.createRequestFactory(); + List res = new ArrayList(); + + String query = "[{\"mid\":null," + + "\"id\":\"/wikipedia/en_id/" + wikipedia_pageid + "\"" + + "}]"; + + GenericUrl url = new GenericUrl(properties.get(FB_QUERY_API_URL_MQL).toString()); + url.put("query", query); + url.put("key", properties.get(FB_QUERY_API_KEY)); + + HttpRequest request = requestFactory.buildGetRequest(url); + HttpResponse httpResponse = interrupter.executeQuery(request, true); + JSONObject response; + try { + response = (JSONObject) jsonParser.parse(httpResponse.parseAsString()); + JSONArray results = (JSONArray) response.get("result"); + + for (Object result : results) { + JSONObject obj = (JSONObject) result; + String id = obj.get("mid").toString(); + res.add(id); + //print or save this id + } + } catch (ParseException e) { + e.printStackTrace(); + } + + LOG.debug("\tQueryFreebase:" + (new Date().getTime() - start.getTime())); + + return res; + } + + //given a type search for any topics of that type and return their ids + public List mqlapi_topic_mids_with_name(String name, int maxResults) throws IOException { + Date start = new Date(); + httpTransport = new NetHttpTransport(); + requestFactory = httpTransport.createRequestFactory(); + List res = new ArrayList(); + + int limit = Integer.valueOf(properties.get(FB_QUERY_PARAM_LIMIT).toString()); + int iterations = maxResults % limit; + iterations = iterations == 0 ? maxResults / limit : maxResults / limit + 1; + String cursorPoint = ""; + for (int i = 0; i < iterations; i++) { + String query = "[{\"mid\":null," + + "\"name\":\"" + name + "\"," + + "\"limit\":" + limit + "" + + "}]"; + + GenericUrl url = new GenericUrl(properties.get(FB_QUERY_API_URL_MQL).toString()); + url.put("query", query); + url.put("key", properties.get(FB_QUERY_API_KEY)); + url.put("cursor", cursorPoint); + + HttpRequest request = requestFactory.buildGetRequest(url); + HttpResponse httpResponse = interrupter.executeQuery(request, true); + System.out.println(limit * (i + 1)); + JSONObject response; + try { + response = (JSONObject) jsonParser.parse(httpResponse.parseAsString()); + cursorPoint = response.get("cursor").toString(); + JSONArray results = (JSONArray) response.get("result"); + + for (Object result : results) { + JSONObject obj = (JSONObject) result; + String id = obj.get("mid").toString(); + res.add(id); + + //print or save this id + } + + if (results.size() < limit) { + break; + } + + } catch (ParseException e) { + e.printStackTrace(); + } + } + LOG.debug("\tQueryFreebase:" + (new Date().getTime() - start.getTime())); + + return res; + } + + public List mqlapi_instances_of_type(String name, int maxResults) throws IOException { + Date start = new Date(); + httpTransport = new NetHttpTransport(); + requestFactory = httpTransport.createRequestFactory(); + List res = new ArrayList(); + + int limit = Integer.valueOf(properties.get(FB_QUERY_PARAM_LIMIT).toString()); + int iterations = maxResults % limit; + iterations = iterations == 0 ? maxResults / limit : maxResults / limit + 1; + String cursorPoint = ""; + for (int i = 0; i < iterations; i++) { + String query = "[{\"name\":null," + + "\"type\":\"" + name + "\"," + + "\"limit\":" + limit + "" + + "}]"; + + GenericUrl url = new GenericUrl(properties.get(FB_QUERY_API_URL_MQL).toString()); + url.put("query", query); + url.put("key", properties.get(FB_QUERY_API_KEY)); + url.put("cursor", cursorPoint); + + HttpRequest request = requestFactory.buildGetRequest(url); + HttpResponse httpResponse = interrupter.executeQuery(request, true); + System.out.println(limit * (i + 1)); + JSONObject response; + try { + response = (JSONObject) jsonParser.parse(httpResponse.parseAsString()); + cursorPoint = response.get("cursor").toString(); + JSONArray results = (JSONArray) response.get("result"); + + for (Object result : results) { + JSONObject obj = (JSONObject) result; + String id = obj.get("name").toString(); + res.add(id); + + //print or save this id + } + + if (results.size() < limit) { + break; + } + + } catch (ParseException e) { + e.printStackTrace(); + } + } + LOG.debug("\tQueryFreebase:" + (new Date().getTime() - start.getTime())); + + return res; + } + + /*public static void main(String[] args) throws IOException { + FreebaseQueryProxy helper = new FreebaseQueryProxy("D:\\Work\\lodiedata\\tableminer_gs/freebase.properties"); + List artist= helper.mqlapi_instances_of_type("/music/artist",10000); + System.out.println(artist); + }*/ + + + public double find_granularityForType(String type) throws IOException { + if(type.startsWith("/m/")) //if the type id starts with "/m/" in strict sense it is a topic representing a concept + //but is not listed as a type in freebase + return 1.0; + String url = properties.get(FB_HOMEPAGE).toString() +type+"?instances="; + Date startTime = new Date(); + URL connection = new URL(url); + BufferedReader in = new BufferedReader( + new InputStreamReader(connection.openStream())); + + String result=null; + String inputLine; + while ((inputLine = in.readLine()) != null) { + int start = inputLine.indexOf("span data-value="); + if(start!=-1) { + start+=16; + int end = inputLine.indexOf(" ",16); + if(start0) + return new Double(result); + return 0.0; + } +} diff --git a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseTopic.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseTopic.java index 2481bd97..ab8e6e08 100644 --- a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseTopic.java +++ b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/freebase/FreebaseTopic.java @@ -1,49 +1,49 @@ -package uk.ac.shef.dcs.kbsearch.freebase; - -import uk.ac.shef.dcs.kbsearch.model.Entity; - -import java.util.Set; - - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 23/01/14 - * Time: 13:12 - * To change this template use File | Settings | File Templates. - */ -public class FreebaseTopic extends Entity{ - private String mid; - private String language; - private double score; - - public FreebaseTopic(String mid){ - super(mid, mid); - this.mid=mid; - } - - public String getMid() { - return mid; - } - - public void setMid(String mid) { - this.mid = mid; - } - - public String getLanguage() { - return language; - } - - public void setLanguage(String language) { - this.language = language; - } - - public double getScore() { - return score; - } - - public void setScore(double score) { - this.score = score; - } - -} +package uk.ac.shef.dcs.kbsearch.freebase; + +import uk.ac.shef.dcs.kbsearch.model.Entity; + +import java.util.Set; + + +/** + * Created with IntelliJ IDEA. + * User: zqz + * Date: 23/01/14 + * Time: 13:12 + * To change this template use File | Settings | File Templates. + */ +public class FreebaseTopic extends Entity{ + private String mid; + private String language; + private double score; + + public FreebaseTopic(String mid){ + super(mid, mid); + this.mid=mid; + } + + public String getMid() { + return mid; + } + + public void setMid(String mid) { + this.mid = mid; + } + + public String getLanguage() { + return language; + } + + public void setLanguage(String language) { + this.language = language; + } + + public double getScore() { + return score; + } + + public void setScore(double score) { + this.score = score; + } + +} diff --git a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Attribute.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Attribute.java index 4800c495..de85d7e1 100644 --- a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Attribute.java +++ b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Attribute.java @@ -1,89 +1,89 @@ -package uk.ac.shef.dcs.kbsearch.model; - -import java.io.Serializable; - -/** - * An attribute of a resource forms a triple with that resource. It must contain a relation, and a value which is the object of - * the triple. The resource is always the subject - */ -public abstract class Attribute implements Serializable{ - - protected String relationURI; - protected String value; - protected String valueURI; //in case 'value' is a resource, define its URI if available - protected boolean isDirect=true; //if this attribute is a direct attribute. this is generally 'true'. for freebase, - //triples that form an indirect relation with a resource can be returned. In which case this - //is used to indicate whether the attribute is a direct attribute of the resource or not - - - public Attribute(String relationURI, String value) { - this.relationURI =relationURI; - this.value= fixValue(value); - } - - /** - * - * @return true if the attribute is about alias - */ - public abstract boolean isAlias(); - - /** - * - * @return true if the attribute is about description - */ - public abstract boolean isDescription(); - - public void setRelationURI(String relationURI) { - this.relationURI = relationURI; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = fixValue(value); - } - - public String getRelationURI() { - return relationURI; - } - - public String getValueURI() { - return valueURI; - } - - public void setValueURI(String valueURI) { - this.valueURI = valueURI; - } - - public boolean equals(Object o){ - if(o instanceof Attribute){ - Attribute a = (Attribute)o; - return a.getRelationURI().equals(this.getRelationURI()) && a.getValue().equals(this.getValue()); - } - return false; - } - - public boolean isDirect() { - return isDirect; - } - - public void setIsDirect(boolean isDirect) { - this.isDirect = isDirect; - } - - public String toString(){ - return "r="+ relationURI +",o="+value+" ("+valueURI+"), direct="+isDirect; - } - - String fixValue(String originalValue) { - Integer index = originalValue.indexOf("^^"); - if (originalValue.startsWith("http") && index > 0) { - return originalValue.substring(0, index); - } - else { - return originalValue; - } - } -} +package uk.ac.shef.dcs.kbsearch.model; + +import java.io.Serializable; + +/** + * An attribute of a resource forms a triple with that resource. It must contain a relation, and a value which is the object of + * the triple. The resource is always the subject + */ +public abstract class Attribute implements Serializable{ + + protected String relationURI; + protected String value; + protected String valueURI; //in case 'value' is a resource, define its URI if available + protected boolean isDirect=true; //if this attribute is a direct attribute. this is generally 'true'. for freebase, + //triples that form an indirect relation with a resource can be returned. In which case this + //is used to indicate whether the attribute is a direct attribute of the resource or not + + + public Attribute(String relationURI, String value) { + this.relationURI =relationURI; + this.value= fixValue(value); + } + + /** + * + * @return true if the attribute is about alias + */ + public abstract boolean isAlias(); + + /** + * + * @return true if the attribute is about description + */ + public abstract boolean isDescription(); + + public void setRelationURI(String relationURI) { + this.relationURI = relationURI; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = fixValue(value); + } + + public String getRelationURI() { + return relationURI; + } + + public String getValueURI() { + return valueURI; + } + + public void setValueURI(String valueURI) { + this.valueURI = valueURI; + } + + public boolean equals(Object o){ + if(o instanceof Attribute){ + Attribute a = (Attribute)o; + return a.getRelationURI().equals(this.getRelationURI()) && a.getValue().equals(this.getValue()); + } + return false; + } + + public boolean isDirect() { + return isDirect; + } + + public void setIsDirect(boolean isDirect) { + this.isDirect = isDirect; + } + + public String toString(){ + return "r="+ relationURI +",o="+value+" ("+valueURI+"), direct="+isDirect; + } + + String fixValue(String originalValue) { + Integer index = originalValue.indexOf("^^"); + if (originalValue.startsWith("http") && index > 0) { + return originalValue.substring(0, index); + } + else { + return originalValue; + } + } +} diff --git a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Clazz.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Clazz.java index aff5a173..0d7ffbbf 100644 --- a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Clazz.java +++ b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Clazz.java @@ -1,27 +1,27 @@ -package uk.ac.shef.dcs.kbsearch.model; - -import java.util.Set; - -/** - * Created by - on 15/03/2016. - */ -public class Clazz extends Resource{ - private static final long serialVersionUID = -1208425814000474692L; - - public Clazz (String id, String label){ - this.id=id; - this.label=label; - } - - public String toString(){ - return "id="+id+", label="+label; - } - - public boolean equals(Object o){ - if (o instanceof Clazz){ - Clazz c = (Clazz)o; - return c.getId().equals(id) && c.getLabel().equals(label); - } - return false; - } -} +package uk.ac.shef.dcs.kbsearch.model; + +import java.util.Set; + +/** + * Created by - on 15/03/2016. + */ +public class Clazz extends Resource{ + private static final long serialVersionUID = -1208425814000474692L; + + public Clazz (String id, String label){ + this.id=id; + this.label=label; + } + + public String toString(){ + return "id="+id+", label="+label; + } + + public boolean equals(Object o){ + if (o instanceof Clazz){ + Clazz c = (Clazz)o; + return c.getId().equals(id) && c.getLabel().equals(label); + } + return false; + } +} diff --git a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Entity.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Entity.java index 1a87dd2a..906a4649 100644 --- a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Entity.java +++ b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Entity.java @@ -1,51 +1,51 @@ -package uk.ac.shef.dcs.kbsearch.model; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * Created by - on 15/03/2016. - */ -public class Entity extends Resource { - private static final long serialVersionUID = -1208425814000405913L; - protected List types=new ArrayList<>(); - protected Set typeIds=new HashSet<>(); - protected Set typeNames =new HashSet<>(); - - public Entity(String id, String label){ - this.id=id; - this.label=label; - } - - public void addType(Clazz c){ - if(!types.contains(c)) { - types.add(c); - typeIds.add(c.getId()); - typeNames.add(c.getLabel()); - } - } - - public Set getTypeIds() { - return typeIds; - } - - public Set getTypeNames() { - return typeNames; - } - - public boolean hasType(String typeId) { - return typeIds.contains(typeId); - } - - public List getTypes() { - return types; - } - - public void clearTypes(){ - types.clear(); - typeIds.clear(); - typeNames.clear(); - } -} +package uk.ac.shef.dcs.kbsearch.model; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * Created by - on 15/03/2016. + */ +public class Entity extends Resource { + private static final long serialVersionUID = -1208425814000405913L; + protected List types=new ArrayList<>(); + protected Set typeIds=new HashSet<>(); + protected Set typeNames =new HashSet<>(); + + public Entity(String id, String label){ + this.id=id; + this.label=label; + } + + public void addType(Clazz c){ + if(!types.contains(c)) { + types.add(c); + typeIds.add(c.getId()); + typeNames.add(c.getLabel()); + } + } + + public Set getTypeIds() { + return typeIds; + } + + public Set getTypeNames() { + return typeNames; + } + + public boolean hasType(String typeId) { + return typeIds.contains(typeId); + } + + public List getTypes() { + return types; + } + + public void clearTypes(){ + types.clear(); + typeIds.clear(); + typeNames.clear(); + } +} diff --git a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Resource.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Resource.java index bab9dc0e..45b57fd5 100644 --- a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Resource.java +++ b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/model/Resource.java @@ -1,84 +1,84 @@ -package uk.ac.shef.dcs.kbsearch.model; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * - */ -public abstract class Resource implements Serializable { - private static final long serialVersionUID = -1208424489000405913L; - - protected String id; //id, uri - protected String label; //label - protected List attributes; - private String description; //a description, if available - private Set aliases; //aliases, if available - - public String getDescription(){ - if(description==null||description.equals("")){ - for(Attribute attr: getAttributes()){ - if(attr.isDirect()&&attr.isDescription()) { - description = attr.getValue(); - break; - } - } - } - if(description==null) - description=""; - return description; - } - - public Set getAliases(){ - if(aliases==null) { - aliases = new HashSet<>(); - return aliases; - } - if(aliases.size()==0){ - for(Attribute attr: getAttributes()){ - if(attr.isDirect()&&attr.isAlias() && !attr.getValue().equals(getLabel())) { - aliases.add(attr.getValue()); - } - } - } - return aliases; - } - - public List getAttributes() { - if(attributes==null) - attributes=new ArrayList<>(); - return attributes; - } - - public void setAttributes(List attributes) { - this.attributes = attributes; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public boolean equals(Object o) { - if (o instanceof Resource) { - Resource r = (Resource) o; - return r.getId().equals(this.getId()); - } - return false; - } - -} +package uk.ac.shef.dcs.kbsearch.model; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * + */ +public abstract class Resource implements Serializable { + private static final long serialVersionUID = -1208424489000405913L; + + protected String id; //id, uri + protected String label; //label + protected List attributes; + private String description; //a description, if available + private Set aliases; //aliases, if available + + public String getDescription(){ + if(description==null||description.equals("")){ + for(Attribute attr: getAttributes()){ + if(attr.isDirect()&&attr.isDescription()) { + description = attr.getValue(); + break; + } + } + } + if(description==null) + description=""; + return description; + } + + public Set getAliases(){ + if(aliases==null) { + aliases = new HashSet<>(); + return aliases; + } + if(aliases.size()==0){ + for(Attribute attr: getAttributes()){ + if(attr.isDirect()&&attr.isAlias() && !attr.getValue().equals(getLabel())) { + aliases.add(attr.getValue()); + } + } + } + return aliases; + } + + public List getAttributes() { + if(attributes==null) + attributes=new ArrayList<>(); + return attributes; + } + + public void setAttributes(List attributes) { + this.attributes = attributes; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public boolean equals(Object o) { + if (o instanceof Resource) { + Resource r = (Resource) o; + return r.getId().equals(this.getId()); + } + return false; + } + +} diff --git a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaAttribute.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaAttribute.java index 871cfe79..62ffe138 100644 --- a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaAttribute.java +++ b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DBpediaAttribute.java @@ -1,39 +1,39 @@ -package uk.ac.shef.dcs.kbsearch.sparql; - -import uk.ac.shef.dcs.kbsearch.model.Attribute; - -/** - * Created by - on 10/06/2016. - */ -public class DBpediaAttribute extends Attribute { - - public DBpediaAttribute(String relationURI, String value) { - super(relationURI, value); - } - - @Override - public boolean isAlias() { - return getRelationURI().endsWith(RDFEnum.RELATION_HASLABEL_SUFFIX_PATTERN.getString()) || - getRelationURI().equals(FOAFEnum.RELATION_HASLABEL.getString()) || - getRelationURI().equals(DBpediaEnum.RELATION_HASFULLNAME.getString()) || - getRelationURI().equals(DBpediaEnum.RELATION_HASNAME.getString())|| - getRelationURI().equals(DCEnum.RELATION_HASLABEL.getString()); - } - - @Override - public boolean isDescription() { - return getRelationURI().equals(DBpediaEnum.RELATION_HASABSTRACT.getString()) || - getRelationURI().endsWith(RDFEnum.RELATION_HASCOMMENT_SUFFIX_PATTERN.getString()) || - getRelationURI().equals(DCEnum.RELATION_HASDESCRIPTION.getString()); - } - - @Override - public String getValueURI() { - return valueURI; - } - - @Override - public void setValueURI(String valueURI) { - this.valueURI = valueURI; - } -} +package uk.ac.shef.dcs.kbsearch.sparql; + +import uk.ac.shef.dcs.kbsearch.model.Attribute; + +/** + * Created by - on 10/06/2016. + */ +public class DBpediaAttribute extends Attribute { + + public DBpediaAttribute(String relationURI, String value) { + super(relationURI, value); + } + + @Override + public boolean isAlias() { + return getRelationURI().endsWith(RDFEnum.RELATION_HASLABEL_SUFFIX_PATTERN.getString()) || + getRelationURI().equals(FOAFEnum.RELATION_HASLABEL.getString()) || + getRelationURI().equals(DBpediaEnum.RELATION_HASFULLNAME.getString()) || + getRelationURI().equals(DBpediaEnum.RELATION_HASNAME.getString())|| + getRelationURI().equals(DCEnum.RELATION_HASLABEL.getString()); + } + + @Override + public boolean isDescription() { + return getRelationURI().equals(DBpediaEnum.RELATION_HASABSTRACT.getString()) || + getRelationURI().endsWith(RDFEnum.RELATION_HASCOMMENT_SUFFIX_PATTERN.getString()) || + getRelationURI().equals(DCEnum.RELATION_HASDESCRIPTION.getString()); + } + + @Override + public String getValueURI() { + return valueURI; + } + + @Override + public void setValueURI(String valueURI) { + this.valueURI = valueURI; + } +} diff --git a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DCEnum.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DCEnum.java index 3692fb5b..c21bb3cc 100644 --- a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DCEnum.java +++ b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/DCEnum.java @@ -1,23 +1,23 @@ -package uk.ac.shef.dcs.kbsearch.sparql; - -/** - * Created by - on 10/06/2016. - */ -public enum DCEnum { - - RELATION_HASLABEL("http://www.w3.org/2000/01/rdf-schema#label"), - RELATION_HASDESCRIPTION("http://purl.org/dc/elements/1.1/description"); - - - private String string; - - DCEnum(String s){ - this.string=s; - } - - public String getString(){ - return string; - } - - -} +package uk.ac.shef.dcs.kbsearch.sparql; + +/** + * Created by - on 10/06/2016. + */ +public enum DCEnum { + + RELATION_HASLABEL("http://www.w3.org/2000/01/rdf-schema#label"), + RELATION_HASDESCRIPTION("http://purl.org/dc/elements/1.1/description"); + + + private String string; + + DCEnum(String s){ + this.string=s; + } + + public String getString(){ + return string; + } + + +} diff --git a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/FOAFEnum.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/FOAFEnum.java index aca1202f..9b877a61 100644 --- a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/FOAFEnum.java +++ b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/FOAFEnum.java @@ -1,20 +1,20 @@ -package uk.ac.shef.dcs.kbsearch.sparql; - -/** - * Created by - on 10/06/2016. - */ -public enum FOAFEnum { - - RELATION_HASLABEL("http://xmlns.com/foaf/0.1/name"); - - - private String string; - - FOAFEnum(String s){ - this.string=s; - } - - public String getString(){ - return string; - } -} +package uk.ac.shef.dcs.kbsearch.sparql; + +/** + * Created by - on 10/06/2016. + */ +public enum FOAFEnum { + + RELATION_HASLABEL("http://xmlns.com/foaf/0.1/name"); + + + private String string; + + FOAFEnum(String s){ + this.string=s; + } + + public String getString(){ + return string; + } +} diff --git a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/RDFEnum.java b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/RDFEnum.java index 2fb90ad2..bbad7a21 100644 --- a/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/RDFEnum.java +++ b/sti-kbsearch/src/main/java/uk/ac/shef/dcs/kbsearch/sparql/RDFEnum.java @@ -1,26 +1,26 @@ -package uk.ac.shef.dcs.kbsearch.sparql; - -/** - * Created by - on 10/06/2016. - */ -public enum RDFEnum { - //RDFS has different versions (2000/1999), so we define patterns and shorthands instead of exact URIs - RELATION_HASLABEL_SUFFIX_PATTERN("#label"), - RELATION_HASTYPE_SUFFIX_PATTERN("#type"), - RELATION_HASCOMMENT_SUFFIX_PATTERN("#comment"), - - // - RELATION_HASLABEL("http://www.w3.org/2000/01/rdf-schema#label"), - RELATION_HASTYPE("https://www.w3.org/1999/02/22-rdf-syntax-ns#type"), - RELATION_HASCOMMENT("http://www.w3.org/2000/01/rdf-schema#comment"); - - private String string; - - RDFEnum(String s){ - this.string=s; - } - - public String getString(){ - return string; - } -} +package uk.ac.shef.dcs.kbsearch.sparql; + +/** + * Created by - on 10/06/2016. + */ +public enum RDFEnum { + //RDFS has different versions (2000/1999), so we define patterns and shorthands instead of exact URIs + RELATION_HASLABEL_SUFFIX_PATTERN("#label"), + RELATION_HASTYPE_SUFFIX_PATTERN("#type"), + RELATION_HASCOMMENT_SUFFIX_PATTERN("#comment"), + + // + RELATION_HASLABEL("http://www.w3.org/2000/01/rdf-schema#label"), + RELATION_HASTYPE("https://www.w3.org/1999/02/22-rdf-syntax-ns#type"), + RELATION_HASCOMMENT("http://www.w3.org/2000/01/rdf-schema#comment"); + + private String string; + + RDFEnum(String s){ + this.string=s; + } + + public String getString(){ + return string; + } +} diff --git a/sti-main/log4j.properties b/sti-main/log4j.properties index 230634ad..c2849bb6 100644 --- a/sti-main/log4j.properties +++ b/sti-main/log4j.properties @@ -1,26 +1,26 @@ -# Root logger option -# switch logging level for other options(TRACE, DEBUG, INFO, WARN, ERROR, FATAL) -log4j.rootLogger=ERROR, stdout - -# Direct LOG messages to a LOG file -log4j.appender.file=org.apache.log4j.RollingFileAppender -log4j.appender.file.File=sti.log -log4j.appender.file.MaxFileSize=10MB -log4j.appender.file.MaxBackupIndex=10 -log4j.appender.file.layout=org.apache.log4j.PatternLayout -log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n - -log4j.logger.uk.ac.shef.dcs=INFO -log4j.logger.uk.ac.shef.dcs.kbsearch=INFO,stdout - -# Direct LOG messages to stdout -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Target=System.out -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n - -log4j.appender.myappender=org.apache.log4j.DailyRollingFileAppender -log4j.appender.myappender.datePattern='-'dd'.log' -log4j.appender.myappender.File=sti.log -log4j.appender.myappender.layout=org.apache.log4j.PatternLayout +# Root logger option +# switch logging level for other options(TRACE, DEBUG, INFO, WARN, ERROR, FATAL) +log4j.rootLogger=ERROR, stdout + +# Direct LOG messages to a LOG file +log4j.appender.file=org.apache.log4j.RollingFileAppender +log4j.appender.file.File=sti.log +log4j.appender.file.MaxFileSize=10MB +log4j.appender.file.MaxBackupIndex=10 +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n + +log4j.logger.uk.ac.shef.dcs=INFO +log4j.logger.uk.ac.shef.dcs.kbsearch=INFO,stdout + +# Direct LOG messages to stdout +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n + +log4j.appender.myappender=org.apache.log4j.DailyRollingFileAppender +log4j.appender.myappender.datePattern='-'dd'.log' +log4j.appender.myappender.File=sti.log +log4j.appender.myappender.layout=org.apache.log4j.PatternLayout log4j.appender.myappender.layout.ConversionPattern=%-6r %d{ISO8601} %-5p %40.40c %x - %m%n \ No newline at end of file diff --git a/sti-main/src/main/java/log4j.properties b/sti-main/src/main/java/log4j.properties index 72588200..324fc993 100644 --- a/sti-main/src/main/java/log4j.properties +++ b/sti-main/src/main/java/log4j.properties @@ -1,26 +1,26 @@ -# Root logger option -# switch logging level for other options(TRACE, DEBUG, INFO, WARN, ERROR, FATAL) -log4j.rootLogger=ERROR, stdout - -# Direct LOG messages to a LOG file -log4j.appender.file=org.apache.log4j.RollingFileAppender -log4j.appender.file.File=sti.log -log4j.appender.file.MaxFileSize=10MB -log4j.appender.file.MaxBackupIndex=10 -log4j.appender.file.layout=org.apache.log4j.PatternLayout -log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n - -log4j.logger.uk.ac.shef.dcs.sti=INFO -log4j.logger.org.apache.lucene.analysis.sti=INFO,stdout - -# Direct LOG messages to stdout -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Target=System.out -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n - -log4j.appender.myappender=org.apache.log4j.DailyRollingFileAppender -log4j.appender.myappender.datePattern='-'dd'.log' -log4j.appender.myappender.File=sti.log -log4j.appender.myappender.layout=org.apache.log4j.PatternLayout +# Root logger option +# switch logging level for other options(TRACE, DEBUG, INFO, WARN, ERROR, FATAL) +log4j.rootLogger=ERROR, stdout + +# Direct LOG messages to a LOG file +log4j.appender.file=org.apache.log4j.RollingFileAppender +log4j.appender.file.File=sti.log +log4j.appender.file.MaxFileSize=10MB +log4j.appender.file.MaxBackupIndex=10 +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n + +log4j.logger.uk.ac.shef.dcs.sti=INFO +log4j.logger.org.apache.lucene.analysis.sti=INFO,stdout + +# Direct LOG messages to stdout +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n + +log4j.appender.myappender=org.apache.log4j.DailyRollingFileAppender +log4j.appender.myappender.datePattern='-'dd'.log' +log4j.appender.myappender.File=sti.log +log4j.appender.myappender.layout=org.apache.log4j.PatternLayout log4j.appender.myappender.layout.ConversionPattern=%-6r %d{ISO8601} %-5p %40.40c %x - %m%n \ No newline at end of file diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/STIConstantProperty.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/STIConstantProperty.java index 71f69fae..3a80a278 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/STIConstantProperty.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/STIConstantProperty.java @@ -1,56 +1,56 @@ -package uk.ac.shef.dcs.sti; - -import java.util.ArrayList; -import java.util.List; - -/** - */ -public class STIConstantProperty { - - public static final double FREEBASE_TOTAL_TOPICS = 47560900; - public static final boolean SOLR_COMMIT_PER_FILE = true; - - public static final boolean ENFORCE_OSPD = true; - public static final boolean BOW_ENTITY_INCLUDE_INDIRECT_ATTRIBUTE = true; - public static final boolean BOW_DISCARD_SINGLE_CHAR = true; //whether discard single char words from BoW - public static final boolean BOW_CLAZZ_INCLUDE_URI = true; - public static final List FUNCTIONAL_STOPWORDS = new ArrayList<>(); - public static final boolean REVISE_RELATION_ANNOTATION_BY_DC = true; - public static final int UPDATE_PHASE_MAX_ITERATIONS = 10; - - public static final double[] SCORER_ENTITY_CONTEXT_WEIGHT = - new double[]{1.0, 0.5, 1.0, 0.5}; //row,column, column header, tablecontext all - public static final double[] SCORER_CLAZZ_CONTEXT_WEIGHT = - new double[]{1.0, 1.0, 1.0, 1.0}; //all 1.0 - //header,column,out trivial, out important - public static final double[] SCORER_RELATION_CONTEXT_WEIGHT= - new double[]{1.0, 0.0, 1.0, 1.0}; //header text, column, out-trivial, out-important - public static final double ATTRIBUTE_MATCHER_MIN_SCORE=0.5; //for TMP, 0.01; for SMP, 0.5; for JI 0.8 - //if the attributeMatcher produces a score lower than this, the score will be set to 0 - - static { - FUNCTIONAL_STOPWORDS.add("of"); - FUNCTIONAL_STOPWORDS.add("in"); - FUNCTIONAL_STOPWORDS.add("the"); - FUNCTIONAL_STOPWORDS.add("from"); - FUNCTIONAL_STOPWORDS.add("to"); - FUNCTIONAL_STOPWORDS.add("at"); - FUNCTIONAL_STOPWORDS.add("on"); - FUNCTIONAL_STOPWORDS.add("for"); - FUNCTIONAL_STOPWORDS.add("by"); - FUNCTIONAL_STOPWORDS.add("till"); - FUNCTIONAL_STOPWORDS.add("until"); - FUNCTIONAL_STOPWORDS.add("off"); - FUNCTIONAL_STOPWORDS.add("onto"); - FUNCTIONAL_STOPWORDS.add("into"); - FUNCTIONAL_STOPWORDS.add("under"); - FUNCTIONAL_STOPWORDS.add("below"); - FUNCTIONAL_STOPWORDS.add("over"); - FUNCTIONAL_STOPWORDS.add("above"); - FUNCTIONAL_STOPWORDS.add("across"); - FUNCTIONAL_STOPWORDS.add("through"); - - } - - -} +package uk.ac.shef.dcs.sti; + +import java.util.ArrayList; +import java.util.List; + +/** + */ +public class STIConstantProperty { + + public static final double FREEBASE_TOTAL_TOPICS = 47560900; + public static final boolean SOLR_COMMIT_PER_FILE = true; + + public static final boolean ENFORCE_OSPD = true; + public static final boolean BOW_ENTITY_INCLUDE_INDIRECT_ATTRIBUTE = true; + public static final boolean BOW_DISCARD_SINGLE_CHAR = true; //whether discard single char words from BoW + public static final boolean BOW_CLAZZ_INCLUDE_URI = true; + public static final List FUNCTIONAL_STOPWORDS = new ArrayList<>(); + public static final boolean REVISE_RELATION_ANNOTATION_BY_DC = true; + public static final int UPDATE_PHASE_MAX_ITERATIONS = 10; + + public static final double[] SCORER_ENTITY_CONTEXT_WEIGHT = + new double[]{1.0, 0.5, 1.0, 0.5}; //row,column, column header, tablecontext all + public static final double[] SCORER_CLAZZ_CONTEXT_WEIGHT = + new double[]{1.0, 1.0, 1.0, 1.0}; //all 1.0 + //header,column,out trivial, out important + public static final double[] SCORER_RELATION_CONTEXT_WEIGHT= + new double[]{1.0, 0.0, 1.0, 1.0}; //header text, column, out-trivial, out-important + public static final double ATTRIBUTE_MATCHER_MIN_SCORE=0.5; //for TMP, 0.01; for SMP, 0.5; for JI 0.8 + //if the attributeMatcher produces a score lower than this, the score will be set to 0 + + static { + FUNCTIONAL_STOPWORDS.add("of"); + FUNCTIONAL_STOPWORDS.add("in"); + FUNCTIONAL_STOPWORDS.add("the"); + FUNCTIONAL_STOPWORDS.add("from"); + FUNCTIONAL_STOPWORDS.add("to"); + FUNCTIONAL_STOPWORDS.add("at"); + FUNCTIONAL_STOPWORDS.add("on"); + FUNCTIONAL_STOPWORDS.add("for"); + FUNCTIONAL_STOPWORDS.add("by"); + FUNCTIONAL_STOPWORDS.add("till"); + FUNCTIONAL_STOPWORDS.add("until"); + FUNCTIONAL_STOPWORDS.add("off"); + FUNCTIONAL_STOPWORDS.add("onto"); + FUNCTIONAL_STOPWORDS.add("into"); + FUNCTIONAL_STOPWORDS.add("under"); + FUNCTIONAL_STOPWORDS.add("below"); + FUNCTIONAL_STOPWORDS.add("over"); + FUNCTIONAL_STOPWORDS.add("above"); + FUNCTIONAL_STOPWORDS.add("across"); + FUNCTIONAL_STOPWORDS.add("through"); + + } + + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/STIEnum.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/STIEnum.java index 3633c1d0..bb59a326 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/STIEnum.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/STIEnum.java @@ -1,25 +1,25 @@ -package uk.ac.shef.dcs.sti; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 05/10/12 - * Time: 15:52 - */ -public enum STIEnum { - - TABLE_HEADER_UNKNOWN("H_Unknown"); - - private String value; - - STIEnum(String value){ - this.value=value; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } -} +package uk.ac.shef.dcs.sti; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 05/10/12 + * Time: 15:52 + */ +public enum STIEnum { + + TABLE_HEADER_UNKNOWN("H_Unknown"); + + private String value; + + STIEnum(String value){ + this.value=value; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/STIException.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/STIException.java index ea7297a8..3033b7b7 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/STIException.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/STIException.java @@ -1,21 +1,21 @@ -package uk.ac.shef.dcs.sti; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 22/10/12 - * Time: 12:42 - */ -public class STIException extends Exception { - public STIException(String s, Exception e) { - super(s, e); - } - - public STIException(String s) { - super(s); - } - - public STIException(Exception e){ - super(e); - } - -} +package uk.ac.shef.dcs.sti; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 22/10/12 + * Time: 12:42 + */ +public class STIException extends Exception { + public STIException(String s, Exception e) { + super(s, e); + } + + public STIException(String s) { + super(s); + } + + public STIException(Exception e){ + super(e); + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/any23/Any23Xtractor.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/any23/Any23Xtractor.java index 57b67abf..2a285624 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/any23/Any23Xtractor.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/any23/Any23Xtractor.java @@ -1,89 +1,89 @@ -package uk.ac.shef.dcs.sti.any23; - -import org.apache.any23.extractor.ExtractionException; -import org.apache.any23.http.HTTPClient; -import org.apache.any23.source.DocumentSource; -import org.apache.any23.source.FileDocumentSource; -import org.apache.any23.source.HTTPDocumentSource; -import org.apache.any23.writer.TripleHandlerException; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.oak.any23.extension.extractor.LAny23; -import uk.ac.shef.oak.any23.extension.extractor.LNTripleWriter; -import uk.ac.shef.oak.any23.extension.extractor.LTriple; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import java.util.List; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 02/11/12 - * Time: 09:33 - */ -public class Any23Xtractor { - private static Any23Xtractor ourInstance; - private LAny23 runner; - - private static Any23Xtractor getInstance() throws STIException { - if (ourInstance == null) - ourInstance = new Any23Xtractor(); - return ourInstance; - } - - private Any23Xtractor() throws STIException { - runner = new LAny23("lodie-html-rdfa11", "lodie-html-microdata"); - runner.setHTTPUserAgent("test-user-agent"); - - } - - public static List extract(String uri) throws STIException { - LNTripleWriter handler = null; - try { - HTTPClient httpClient = getInstance().runner.getHTTPClient(); - - DocumentSource source = new HTTPDocumentSource( - httpClient, - uri - ); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - handler = new LNTripleWriter(out); - getInstance().runner.extract(source, handler); - return handler.getOutput(); - } catch (IOException ioe) { - throw new STIException("Any23 cannot obtain " + HTTPClient.class.getName(), ioe); - } catch (URISyntaxException | ExtractionException use) { - throw new STIException("Document source error " + uri, use); - } finally { - if (handler != null) - try { - handler.close(); - } catch (TripleHandlerException e) { - } - } - } - public static List extract(File file) throws STIException { - LNTripleWriter handler = null; - try { - DocumentSource source = new FileDocumentSource( - file - ); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - handler = new LNTripleWriter(out); - getInstance().runner.extract(source, handler); - return handler.getOutput(); - } catch (IOException ioe) { - throw new STIException("Any23 cannot obtain " + HTTPClient.class.getName(), ioe); - } catch (ExtractionException ee) { - throw new STIException("Document source error " + file, ee); - } finally { - if (handler != null) - try { - handler.close(); - } catch (TripleHandlerException e) { - } - } - } - -} +package uk.ac.shef.dcs.sti.any23; + +import org.apache.any23.extractor.ExtractionException; +import org.apache.any23.http.HTTPClient; +import org.apache.any23.source.DocumentSource; +import org.apache.any23.source.FileDocumentSource; +import org.apache.any23.source.HTTPDocumentSource; +import org.apache.any23.writer.TripleHandlerException; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.oak.any23.extension.extractor.LAny23; +import uk.ac.shef.oak.any23.extension.extractor.LNTripleWriter; +import uk.ac.shef.oak.any23.extension.extractor.LTriple; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; +import java.util.List; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 02/11/12 + * Time: 09:33 + */ +public class Any23Xtractor { + private static Any23Xtractor ourInstance; + private LAny23 runner; + + private static Any23Xtractor getInstance() throws STIException { + if (ourInstance == null) + ourInstance = new Any23Xtractor(); + return ourInstance; + } + + private Any23Xtractor() throws STIException { + runner = new LAny23("lodie-html-rdfa11", "lodie-html-microdata"); + runner.setHTTPUserAgent("test-user-agent"); + + } + + public static List extract(String uri) throws STIException { + LNTripleWriter handler = null; + try { + HTTPClient httpClient = getInstance().runner.getHTTPClient(); + + DocumentSource source = new HTTPDocumentSource( + httpClient, + uri + ); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + handler = new LNTripleWriter(out); + getInstance().runner.extract(source, handler); + return handler.getOutput(); + } catch (IOException ioe) { + throw new STIException("Any23 cannot obtain " + HTTPClient.class.getName(), ioe); + } catch (URISyntaxException | ExtractionException use) { + throw new STIException("Document source error " + uri, use); + } finally { + if (handler != null) + try { + handler.close(); + } catch (TripleHandlerException e) { + } + } + } + public static List extract(File file) throws STIException { + LNTripleWriter handler = null; + try { + DocumentSource source = new FileDocumentSource( + file + ); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + handler = new LNTripleWriter(out); + getInstance().runner.extract(source, handler); + return handler.getOutput(); + } catch (IOException ioe) { + throw new STIException("Any23 cannot obtain " + HTTPClient.class.getName(), ioe); + } catch (ExtractionException ee) { + throw new STIException("Document source error " + file, ee); + } finally { + if (handler != null) + try { + handler.close(); + } catch (TripleHandlerException e) { + } + } + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/SemanticTableInterpreter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/SemanticTableInterpreter.java index acef7259..76ec2c5e 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/SemanticTableInterpreter.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/SemanticTableInterpreter.java @@ -1,53 +1,53 @@ -package uk.ac.shef.dcs.sti.core.algorithm; - -import uk.ac.shef.dcs.kbsearch.KBSearchException; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.model.TAnnotation; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.websearch.bing.v2.APIKeysDepletedException; - -import java.io.IOException; -import java.util.HashSet; -import java.util.Set; - -/** - */ -public abstract class SemanticTableInterpreter { - - private Set ignoreCols; - private Set mustdoColumns; - - public SemanticTableInterpreter( - int[] ignoreColumns, - int[] mustdoColumns - ){ - this.ignoreCols = new HashSet<>(); - for (int i : ignoreColumns) - this.ignoreCols.add(i); - this.mustdoColumns = new HashSet<>(); - for(int i: mustdoColumns) - this.mustdoColumns.add(i); - } - - public abstract TAnnotation start(Table table, boolean relationLearning) - throws STIException; - - - - protected boolean isCompulsoryColumn(Integer i) { - if (i != null) { - return mustdoColumns.contains(i); - } - return false; - } - - protected Set getIgnoreColumns(){ - return ignoreCols; - } - - public void setIgnoreColumns(Set ignoreCols) { - this.ignoreCols = ignoreCols; - } - - protected Set getMustdoColumns() {return mustdoColumns;} -} +package uk.ac.shef.dcs.sti.core.algorithm; + +import uk.ac.shef.dcs.kbsearch.KBSearchException; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.model.TAnnotation; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.websearch.bing.v2.APIKeysDepletedException; + +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +/** + */ +public abstract class SemanticTableInterpreter { + + private Set ignoreCols; + private Set mustdoColumns; + + public SemanticTableInterpreter( + int[] ignoreColumns, + int[] mustdoColumns + ){ + this.ignoreCols = new HashSet<>(); + for (int i : ignoreColumns) + this.ignoreCols.add(i); + this.mustdoColumns = new HashSet<>(); + for(int i: mustdoColumns) + this.mustdoColumns.add(i); + } + + public abstract TAnnotation start(Table table, boolean relationLearning) + throws STIException; + + + + protected boolean isCompulsoryColumn(Integer i) { + if (i != null) { + return mustdoColumns.contains(i); + } + return false; + } + + protected Set getIgnoreColumns(){ + return ignoreCols; + } + + public void setIgnoreColumns(Set ignoreCols) { + this.ignoreCols = ignoreCols; + } + + protected Set getMustdoColumns() {return mustdoColumns;} +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineInterpreter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineInterpreter.java index bec69f6d..78ce9fdb 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineInterpreter.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineInterpreter.java @@ -1,105 +1,105 @@ -package uk.ac.shef.dcs.sti.core.algorithm.baseline; - -import javafx.util.Pair; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.algorithm.SemanticTableInterpreter; -import uk.ac.shef.dcs.sti.core.algorithm.tmp.LiteralColumnTagger; -import uk.ac.shef.dcs.sti.core.algorithm.tmp.RELATIONENUMERATION; -import uk.ac.shef.dcs.sti.core.algorithm.tmp.TColumnColumnRelationEnumerator; -import uk.ac.shef.dcs.sti.core.subjectcol.TColumnFeature; -import uk.ac.shef.dcs.sti.core.subjectcol.SubjectColumnDetector; -import uk.ac.shef.dcs.sti.util.DataTypeClassifier; -import uk.ac.shef.dcs.sti.core.model.*; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.logging.Logger; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 25/02/14 - * Time: 15:52 - * To change this template use File | Settings | File Templates. - */ -public class BaselineInterpreter extends SemanticTableInterpreter { - private static final Logger LOG = Logger.getLogger(BaselineInterpreter.class.getName()); - private SubjectColumnDetector subjectColumnDetector; - private TCellDisambiguator disambiguator; - private TColumnClassifier columnClassifier; - private TColumnColumnRelationEnumerator relationEnumerator; - private LiteralColumnTagger literalColumnTagger; - - - public BaselineInterpreter(SubjectColumnDetector subjectColumnDetector, - TCellDisambiguator disambiguator, - TColumnClassifier columnClassifier, - TColumnColumnRelationEnumerator relationEnumerator, - LiteralColumnTagger literalColumnTagger, - int[] ignoreColumns, int[] mustdoColumns) { - super(ignoreColumns, mustdoColumns); - this.subjectColumnDetector = subjectColumnDetector; - this.disambiguator = disambiguator; - this.columnClassifier = columnClassifier; - this.relationEnumerator = relationEnumerator; - this.literalColumnTagger = literalColumnTagger; - } - - public TAnnotation start(Table table, boolean relationLearning) throws STIException { - try { - LOG.info(">\t Detecting subject column..."); - int[] ignoreColumnsArray = new int[getIgnoreColumns().size()]; - - int index = 0; - for (Integer i : getIgnoreColumns()) { - ignoreColumnsArray[index] = i; - index++; - } - //1. find the main subject column of this table - List>> subjectColumnScores = - subjectColumnDetector.compute(table, ignoreColumnsArray); - - TAnnotation tableAnnotations = new TAnnotation(table.getNumRows(), table.getNumCols()); - List annotatedColumns = new ArrayList<>(); - Map>>> disambResults; - for (int col = 0; col < table.getNumCols(); col++) { - LOG.info(">\t Cell Disambiguation for column=" + col); - if (getMustdoColumns().contains(col)) { - LOG.info("\t>> Column=(compulsory)" + col); - disambResults = disambiguator.disambiguate(table, tableAnnotations, col); - annotatedColumns.add(col); - } else { - if (getIgnoreColumns().contains(col)) continue; - if (!table.getColumnHeader(col).getFeature().getMostFrequentDataType().getType().equals(DataTypeClassifier.DataType.NAMED_ENTITY)) - continue; - - annotatedColumns.add(col); - LOG.info("\t>> Column=" + col); - disambResults = disambiguator.disambiguate(table, tableAnnotations, col); - } - - LOG.info(">\t Column classification for column=" + col); - columnClassifier.classify(disambResults, table, tableAnnotations, col); - LOG.info(">\t Update cell annotatation based on column class for colun=" + col); - disambiguator.revise(tableAnnotations, table, disambResults, col); - } - - if (relationLearning) { - new RELATIONENUMERATION().enumerate(subjectColumnScores, - getIgnoreColumns(), relationEnumerator, - tableAnnotations, table, - annotatedColumns, null); - //4. consolidation-for columns that have relation with main subject column, if the column is - // entity column, do column typing and disambiguation; otherwise, simply create header annotation - LOG.info("\t\t>> Annotate literal-columns in relation with main column"); - literalColumnTagger.annotate(table, tableAnnotations, annotatedColumns.toArray(new Integer[0])); - } - return tableAnnotations; - } catch (Exception e) { - throw new STIException(e); - } - } - -} +package uk.ac.shef.dcs.sti.core.algorithm.baseline; + +import javafx.util.Pair; +import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.algorithm.SemanticTableInterpreter; +import uk.ac.shef.dcs.sti.core.algorithm.tmp.LiteralColumnTagger; +import uk.ac.shef.dcs.sti.core.algorithm.tmp.RELATIONENUMERATION; +import uk.ac.shef.dcs.sti.core.algorithm.tmp.TColumnColumnRelationEnumerator; +import uk.ac.shef.dcs.sti.core.subjectcol.TColumnFeature; +import uk.ac.shef.dcs.sti.core.subjectcol.SubjectColumnDetector; +import uk.ac.shef.dcs.sti.util.DataTypeClassifier; +import uk.ac.shef.dcs.sti.core.model.*; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.logging.Logger; + +/** + * Created with IntelliJ IDEA. + * User: zqz + * Date: 25/02/14 + * Time: 15:52 + * To change this template use File | Settings | File Templates. + */ +public class BaselineInterpreter extends SemanticTableInterpreter { + private static final Logger LOG = Logger.getLogger(BaselineInterpreter.class.getName()); + private SubjectColumnDetector subjectColumnDetector; + private TCellDisambiguator disambiguator; + private TColumnClassifier columnClassifier; + private TColumnColumnRelationEnumerator relationEnumerator; + private LiteralColumnTagger literalColumnTagger; + + + public BaselineInterpreter(SubjectColumnDetector subjectColumnDetector, + TCellDisambiguator disambiguator, + TColumnClassifier columnClassifier, + TColumnColumnRelationEnumerator relationEnumerator, + LiteralColumnTagger literalColumnTagger, + int[] ignoreColumns, int[] mustdoColumns) { + super(ignoreColumns, mustdoColumns); + this.subjectColumnDetector = subjectColumnDetector; + this.disambiguator = disambiguator; + this.columnClassifier = columnClassifier; + this.relationEnumerator = relationEnumerator; + this.literalColumnTagger = literalColumnTagger; + } + + public TAnnotation start(Table table, boolean relationLearning) throws STIException { + try { + LOG.info(">\t Detecting subject column..."); + int[] ignoreColumnsArray = new int[getIgnoreColumns().size()]; + + int index = 0; + for (Integer i : getIgnoreColumns()) { + ignoreColumnsArray[index] = i; + index++; + } + //1. find the main subject column of this table + List>> subjectColumnScores = + subjectColumnDetector.compute(table, ignoreColumnsArray); + + TAnnotation tableAnnotations = new TAnnotation(table.getNumRows(), table.getNumCols()); + List annotatedColumns = new ArrayList<>(); + Map>>> disambResults; + for (int col = 0; col < table.getNumCols(); col++) { + LOG.info(">\t Cell Disambiguation for column=" + col); + if (getMustdoColumns().contains(col)) { + LOG.info("\t>> Column=(compulsory)" + col); + disambResults = disambiguator.disambiguate(table, tableAnnotations, col); + annotatedColumns.add(col); + } else { + if (getIgnoreColumns().contains(col)) continue; + if (!table.getColumnHeader(col).getFeature().getMostFrequentDataType().getType().equals(DataTypeClassifier.DataType.NAMED_ENTITY)) + continue; + + annotatedColumns.add(col); + LOG.info("\t>> Column=" + col); + disambResults = disambiguator.disambiguate(table, tableAnnotations, col); + } + + LOG.info(">\t Column classification for column=" + col); + columnClassifier.classify(disambResults, table, tableAnnotations, col); + LOG.info(">\t Update cell annotatation based on column class for colun=" + col); + disambiguator.revise(tableAnnotations, table, disambResults, col); + } + + if (relationLearning) { + new RELATIONENUMERATION().enumerate(subjectColumnScores, + getIgnoreColumns(), relationEnumerator, + tableAnnotations, table, + annotatedColumns, null); + //4. consolidation-for columns that have relation with main subject column, if the column is + // entity column, do column typing and disambiguation; otherwise, simply create header annotation + LOG.info("\t\t>> Annotate literal-columns in relation with main column"); + literalColumnTagger.annotate(table, tableAnnotations, annotatedColumns.toArray(new Integer[0])); + } + return tableAnnotations; + } catch (Exception e) { + throw new STIException(e); + } + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineRelationScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineRelationScorer.java index 18001cf7..0edbbf6d 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineRelationScorer.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineRelationScorer.java @@ -1,73 +1,73 @@ -package uk.ac.shef.dcs.sti.core.algorithm.baseline; - -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.model.RelationColumns; -import uk.ac.shef.dcs.sti.core.model.TCellCellRelationAnotation; -import uk.ac.shef.dcs.sti.core.model.TColumnColumnRelationAnnotation; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.core.scorer.RelationScorer; - -import java.util.*; - -/** - * Created by - on 12/04/2016. - */ -public class BaselineRelationScorer implements RelationScorer { - @Override - public List computeElementScores( - List cellcellRelationsOnRow, - Collection output, - int subjectCol, int objectCol, Table table) throws STIException { - - for (TCellCellRelationAnotation cellcellRelationAnnotation : cellcellRelationsOnRow) { - TColumnColumnRelationAnnotation columncolumnRelationAnnotation = null; - for (TColumnColumnRelationAnnotation key : output) { - if (key.getRelationURI().equals(cellcellRelationAnnotation.getRelationURI())) { - columncolumnRelationAnnotation = key; - break; - } - } - - if (columncolumnRelationAnnotation == null) { - columncolumnRelationAnnotation = new TColumnColumnRelationAnnotation( - new RelationColumns(subjectCol, objectCol), - cellcellRelationAnnotation.getRelationURI(), - cellcellRelationAnnotation.getRelationLabel(), 0.0); - output.add(columncolumnRelationAnnotation); - } - - Map scoreElements = columncolumnRelationAnnotation.getScoreElements(); - if (scoreElements == null || scoreElements.size() == 0) { - scoreElements = new HashMap<>(); - scoreElements.put(TColumnColumnRelationAnnotation.SCORE_FINAL, 0.0); - } - - scoreElements.put(TColumnColumnRelationAnnotation.SCORE_FINAL, - scoreElements.get(TColumnColumnRelationAnnotation.SCORE_FINAL) + 1.0); - columncolumnRelationAnnotation.setFinalScore(scoreElements. - get(TColumnColumnRelationAnnotation.SCORE_FINAL)); - - } - return new ArrayList<>(output); - } - - @Override - public List computeREScore(List cellcellRelationAnotations, Collection output, int subjectCol, int objectCol) throws STIException { - throw new STIException("Not supported"); - } - - @Override - public List computeRCScore(Collection candidates, Table table, int column) throws STIException { - throw new STIException("Not supported"); - } - - @Override - public Map computeFinal(TColumnColumnRelationAnnotation relation, int tableRowsTotal) { - return relation.getScoreElements(); - } - - @Override - public double scoreDC(TColumnColumnRelationAnnotation hbr, List domain_representation) throws STIException { - throw new STIException("Not supported"); - } -} +package uk.ac.shef.dcs.sti.core.algorithm.baseline; + +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.model.RelationColumns; +import uk.ac.shef.dcs.sti.core.model.TCellCellRelationAnotation; +import uk.ac.shef.dcs.sti.core.model.TColumnColumnRelationAnnotation; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.core.scorer.RelationScorer; + +import java.util.*; + +/** + * Created by - on 12/04/2016. + */ +public class BaselineRelationScorer implements RelationScorer { + @Override + public List computeElementScores( + List cellcellRelationsOnRow, + Collection output, + int subjectCol, int objectCol, Table table) throws STIException { + + for (TCellCellRelationAnotation cellcellRelationAnnotation : cellcellRelationsOnRow) { + TColumnColumnRelationAnnotation columncolumnRelationAnnotation = null; + for (TColumnColumnRelationAnnotation key : output) { + if (key.getRelationURI().equals(cellcellRelationAnnotation.getRelationURI())) { + columncolumnRelationAnnotation = key; + break; + } + } + + if (columncolumnRelationAnnotation == null) { + columncolumnRelationAnnotation = new TColumnColumnRelationAnnotation( + new RelationColumns(subjectCol, objectCol), + cellcellRelationAnnotation.getRelationURI(), + cellcellRelationAnnotation.getRelationLabel(), 0.0); + output.add(columncolumnRelationAnnotation); + } + + Map scoreElements = columncolumnRelationAnnotation.getScoreElements(); + if (scoreElements == null || scoreElements.size() == 0) { + scoreElements = new HashMap<>(); + scoreElements.put(TColumnColumnRelationAnnotation.SCORE_FINAL, 0.0); + } + + scoreElements.put(TColumnColumnRelationAnnotation.SCORE_FINAL, + scoreElements.get(TColumnColumnRelationAnnotation.SCORE_FINAL) + 1.0); + columncolumnRelationAnnotation.setFinalScore(scoreElements. + get(TColumnColumnRelationAnnotation.SCORE_FINAL)); + + } + return new ArrayList<>(output); + } + + @Override + public List computeREScore(List cellcellRelationAnotations, Collection output, int subjectCol, int objectCol) throws STIException { + throw new STIException("Not supported"); + } + + @Override + public List computeRCScore(Collection candidates, Table table, int column) throws STIException { + throw new STIException("Not supported"); + } + + @Override + public Map computeFinal(TColumnColumnRelationAnnotation relation, int tableRowsTotal) { + return relation.getScoreElements(); + } + + @Override + public double scoreDC(TColumnColumnRelationAnnotation hbr, List domain_representation) throws STIException { + throw new STIException("Not supported"); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineSimilarityClazzScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineSimilarityClazzScorer.java index fd3b8047..8ae95cd0 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineSimilarityClazzScorer.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineSimilarityClazzScorer.java @@ -1,173 +1,173 @@ -package uk.ac.shef.dcs.sti.core.algorithm.baseline; - -import javafx.util.Pair; -import org.simmetrics.StringMetric; -import uk.ac.shef.dcs.sti.STIEnum; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.scorer.ClazzScorer; -import uk.ac.shef.dcs.sti.nlp.Lemmatizer; -import uk.ac.shef.dcs.sti.nlp.NLPTools; -import uk.ac.shef.dcs.kbsearch.model.Clazz; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; -import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; -import uk.ac.shef.dcs.sti.core.model.TColumnHeader; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.util.StringUtils; - -import java.io.IOException; -import java.util.*; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 11/03/14 - * Time: 12:19 - * To change this template use File | Settings | File Templates. - */ -public class BaselineSimilarityClazzScorer implements ClazzScorer { - private static final String SCORE_CTX_IN_HEADER = "score_ctx_header"; - private static final String SUM_CELL_VOTE = "sum_vote"; - private static final String SCORE_CELL_VOTE = "score_vote"; - private Lemmatizer lemmatizer; - private List stopWords; - private StringMetric stringSimilarityMetric; - - public BaselineSimilarityClazzScorer(String nlpResources, List stopWords, - StringMetric stringMetric) throws IOException { - this.lemmatizer = NLPTools.getInstance(nlpResources).getLemmatizer(); - this.stopWords = stopWords; - this.stringSimilarityMetric = stringMetric; - } - - @Override - public Map computeFinal(TColumnHeaderAnnotation ha, int tableRowsTotal) { - Map scoreElements = ha.getScoreElements(); - Double sum_entity_vote = scoreElements.get(SUM_CELL_VOTE); - if(sum_entity_vote==null) sum_entity_vote=0.0; - double score_entity_vote = sum_entity_vote / (double) tableRowsTotal; - scoreElements.put(SCORE_CELL_VOTE, score_entity_vote); - - double finalScore = score_entity_vote; - Double namematch = scoreElements.get(SCORE_CTX_IN_HEADER); - if (namematch != null) { - finalScore = finalScore + namematch; - } - - scoreElements.put(TColumnHeaderAnnotation.SCORE_FINAL, finalScore); - ha.setFinalScore(finalScore); - return scoreElements; - } - - - @Override - public List computeElementScores( - List>> input, - Collection headerAnnotationCandidates, - Table table, List rows, int column) throws STIException { - List candidates = new ArrayList<>(); - for (int row : rows) - candidates = computeCEScore(input, headerAnnotationCandidates, table, row, column); - candidates = computeCCScore(candidates, table, column); - - return candidates; - } - - @Override - public List computeCEScore( - List>> entities, - Collection existingHeaderAnnotations, - Table table, int row, int column) throws STIException { - final Collection candidateHeaderAnnotations = - existingHeaderAnnotations; - //for this row - Entity winningEntity = null; - double winningScore = 0.0; - for (Pair> es : entities) { //each candidate entity in this cell - Entity entity = es.getKey(); - //each assigned type receives a computeElementScores of 1, and the bonus computeElementScores due to disambiguation result - double entityScore = es.getValue().get(TCellAnnotation.SCORE_FINAL); - if (entityScore > winningScore) { - winningScore = entityScore; - winningEntity = entity; - } - } - if (entities.size() == 0 || winningEntity == null) { - return new ArrayList<>(candidateHeaderAnnotations); - } - - Set votedTypes = new HashSet<>(); //each type will receive a max of 1 vote from each cell. If multiple candidates have the same highest computeElementScores and casts same votes, they are counted oly once - for (Pair> es : entities) { - Entity currentEntity = es.getKey(); - double entityScore = es.getValue().get(TCellAnnotation.SCORE_FINAL); - if (entityScore != winningScore) - continue; - - List types = currentEntity.getTypes(); - - //consolidate scores from this cell - for (Clazz type : types) { - if (votedTypes.contains(type.getId())) - continue; - - votedTypes.add(type.getId()); - String headerText = table.getColumnHeader(column).getHeaderText(); - - TColumnHeaderAnnotation hAnnotation = null; - for (TColumnHeaderAnnotation key : candidateHeaderAnnotations) { - if (key.getHeaderText().equals(headerText) && key.getAnnotation().getId().equals(type.getId() - )) { - hAnnotation = key; - break; - } - } - if (hAnnotation == null) { - hAnnotation = new TColumnHeaderAnnotation(headerText, type, 0.0); - candidateHeaderAnnotations.add(hAnnotation); - } - - Map scoreElements = hAnnotation.getScoreElements(); - if (scoreElements == null || scoreElements.size() == 0) { - scoreElements = new HashMap<>(); - scoreElements.put(SUM_CELL_VOTE, 0.0); - } - Double sumCellVote = scoreElements.get(SUM_CELL_VOTE); - if(sumCellVote==null) sumCellVote=0.0; - scoreElements.put(SUM_CELL_VOTE, - sumCellVote + 1.0); - hAnnotation.setScoreElements(scoreElements); - - } - } - - return new ArrayList<>(candidateHeaderAnnotations); - } - - @Override - public List computeCCScore(Collection candidates, Table table, int column) throws STIException { - for (TColumnHeaderAnnotation ha : candidates) { - Double score_ctx_header_text = ha.getScoreElements().get(SCORE_CTX_IN_HEADER); - - if (score_ctx_header_text == null) { - TColumnHeader header = table.getColumnHeader(column); - if (header != null && - header.getHeaderText() != null && - !header.getHeaderText().equals(STIEnum.TABLE_HEADER_UNKNOWN.getValue())) { - //double computeElementScores = CollectionUtils.diceCoefficientOptimized(header.getHeaderText(), ha.getAnnotation_label()); - double score = stringSimilarityMetric.compare( - StringUtils.toAlphaNumericWhitechar(header.getHeaderText()), - StringUtils.toAlphaNumericWhitechar(ha.getAnnotation().getLabel())); - ha.getScoreElements().put(SCORE_CTX_IN_HEADER, score); - } - } - } - - - return new ArrayList<>(candidates); - } - - @Override - public double computeDC(TColumnHeaderAnnotation ha, List domain_representation) throws STIException { - throw new STIException("Not supported"); - } -} +package uk.ac.shef.dcs.sti.core.algorithm.baseline; + +import javafx.util.Pair; +import org.simmetrics.StringMetric; +import uk.ac.shef.dcs.sti.STIEnum; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.scorer.ClazzScorer; +import uk.ac.shef.dcs.sti.nlp.Lemmatizer; +import uk.ac.shef.dcs.sti.nlp.NLPTools; +import uk.ac.shef.dcs.kbsearch.model.Clazz; +import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; +import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; +import uk.ac.shef.dcs.sti.core.model.TColumnHeader; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.util.StringUtils; + +import java.io.IOException; +import java.util.*; + +/** + * Created with IntelliJ IDEA. + * User: zqz + * Date: 11/03/14 + * Time: 12:19 + * To change this template use File | Settings | File Templates. + */ +public class BaselineSimilarityClazzScorer implements ClazzScorer { + private static final String SCORE_CTX_IN_HEADER = "score_ctx_header"; + private static final String SUM_CELL_VOTE = "sum_vote"; + private static final String SCORE_CELL_VOTE = "score_vote"; + private Lemmatizer lemmatizer; + private List stopWords; + private StringMetric stringSimilarityMetric; + + public BaselineSimilarityClazzScorer(String nlpResources, List stopWords, + StringMetric stringMetric) throws IOException { + this.lemmatizer = NLPTools.getInstance(nlpResources).getLemmatizer(); + this.stopWords = stopWords; + this.stringSimilarityMetric = stringMetric; + } + + @Override + public Map computeFinal(TColumnHeaderAnnotation ha, int tableRowsTotal) { + Map scoreElements = ha.getScoreElements(); + Double sum_entity_vote = scoreElements.get(SUM_CELL_VOTE); + if(sum_entity_vote==null) sum_entity_vote=0.0; + double score_entity_vote = sum_entity_vote / (double) tableRowsTotal; + scoreElements.put(SCORE_CELL_VOTE, score_entity_vote); + + double finalScore = score_entity_vote; + Double namematch = scoreElements.get(SCORE_CTX_IN_HEADER); + if (namematch != null) { + finalScore = finalScore + namematch; + } + + scoreElements.put(TColumnHeaderAnnotation.SCORE_FINAL, finalScore); + ha.setFinalScore(finalScore); + return scoreElements; + } + + + @Override + public List computeElementScores( + List>> input, + Collection headerAnnotationCandidates, + Table table, List rows, int column) throws STIException { + List candidates = new ArrayList<>(); + for (int row : rows) + candidates = computeCEScore(input, headerAnnotationCandidates, table, row, column); + candidates = computeCCScore(candidates, table, column); + + return candidates; + } + + @Override + public List computeCEScore( + List>> entities, + Collection existingHeaderAnnotations, + Table table, int row, int column) throws STIException { + final Collection candidateHeaderAnnotations = + existingHeaderAnnotations; + //for this row + Entity winningEntity = null; + double winningScore = 0.0; + for (Pair> es : entities) { //each candidate entity in this cell + Entity entity = es.getKey(); + //each assigned type receives a computeElementScores of 1, and the bonus computeElementScores due to disambiguation result + double entityScore = es.getValue().get(TCellAnnotation.SCORE_FINAL); + if (entityScore > winningScore) { + winningScore = entityScore; + winningEntity = entity; + } + } + if (entities.size() == 0 || winningEntity == null) { + return new ArrayList<>(candidateHeaderAnnotations); + } + + Set votedTypes = new HashSet<>(); //each type will receive a max of 1 vote from each cell. If multiple candidates have the same highest computeElementScores and casts same votes, they are counted oly once + for (Pair> es : entities) { + Entity currentEntity = es.getKey(); + double entityScore = es.getValue().get(TCellAnnotation.SCORE_FINAL); + if (entityScore != winningScore) + continue; + + List types = currentEntity.getTypes(); + + //consolidate scores from this cell + for (Clazz type : types) { + if (votedTypes.contains(type.getId())) + continue; + + votedTypes.add(type.getId()); + String headerText = table.getColumnHeader(column).getHeaderText(); + + TColumnHeaderAnnotation hAnnotation = null; + for (TColumnHeaderAnnotation key : candidateHeaderAnnotations) { + if (key.getHeaderText().equals(headerText) && key.getAnnotation().getId().equals(type.getId() + )) { + hAnnotation = key; + break; + } + } + if (hAnnotation == null) { + hAnnotation = new TColumnHeaderAnnotation(headerText, type, 0.0); + candidateHeaderAnnotations.add(hAnnotation); + } + + Map scoreElements = hAnnotation.getScoreElements(); + if (scoreElements == null || scoreElements.size() == 0) { + scoreElements = new HashMap<>(); + scoreElements.put(SUM_CELL_VOTE, 0.0); + } + Double sumCellVote = scoreElements.get(SUM_CELL_VOTE); + if(sumCellVote==null) sumCellVote=0.0; + scoreElements.put(SUM_CELL_VOTE, + sumCellVote + 1.0); + hAnnotation.setScoreElements(scoreElements); + + } + } + + return new ArrayList<>(candidateHeaderAnnotations); + } + + @Override + public List computeCCScore(Collection candidates, Table table, int column) throws STIException { + for (TColumnHeaderAnnotation ha : candidates) { + Double score_ctx_header_text = ha.getScoreElements().get(SCORE_CTX_IN_HEADER); + + if (score_ctx_header_text == null) { + TColumnHeader header = table.getColumnHeader(column); + if (header != null && + header.getHeaderText() != null && + !header.getHeaderText().equals(STIEnum.TABLE_HEADER_UNKNOWN.getValue())) { + //double computeElementScores = CollectionUtils.diceCoefficientOptimized(header.getHeaderText(), ha.getAnnotation_label()); + double score = stringSimilarityMetric.compare( + StringUtils.toAlphaNumericWhitechar(header.getHeaderText()), + StringUtils.toAlphaNumericWhitechar(ha.getAnnotation().getLabel())); + ha.getScoreElements().put(SCORE_CTX_IN_HEADER, score); + } + } + } + + + return new ArrayList<>(candidates); + } + + @Override + public double computeDC(TColumnHeaderAnnotation ha, List domain_representation) throws STIException { + throw new STIException("Not supported"); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineSimilarityEntityScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineSimilarityEntityScorer.java index 164b5e14..d17e3015 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineSimilarityEntityScorer.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/BaselineSimilarityEntityScorer.java @@ -1,126 +1,126 @@ -package uk.ac.shef.dcs.sti.core.algorithm.baseline; - -import org.simmetrics.Metric; -import org.simmetrics.StringMetric; -import uk.ac.shef.dcs.kbsearch.model.Attribute; -import uk.ac.shef.dcs.sti.STIConstantProperty; -import uk.ac.shef.dcs.sti.core.algorithm.tmp.scorer.TMPEntityScorer; -import uk.ac.shef.dcs.sti.core.scorer.EntityScorer; -import uk.ac.shef.dcs.sti.nlp.Lemmatizer; -import uk.ac.shef.dcs.sti.nlp.NLPTools; -import uk.ac.shef.dcs.sti.util.DataTypeClassifier; -import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.util.CollectionUtils; -import uk.ac.shef.dcs.util.StringUtils; - -import java.io.IOException; -import java.util.*; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 11/03/14 - * Time: 12:18 - * To change this template use File | Settings | File Templates. - */ -public class BaselineSimilarityEntityScorer implements EntityScorer { - private static final String SCORE_NAME_MATCH = "name_string_similarity"; - private List stopWords; - private Lemmatizer lemmatizer; - private StringMetric stringSimilarityMetric; - - /* - context weights: 0-row context; 1-column context; 2-table context - */ - public BaselineSimilarityEntityScorer( - List stopWords, - String nlpResources, - StringMetric stringSimilarityMetric) throws IOException { - if (nlpResources != null) - lemmatizer = NLPTools.getInstance(nlpResources).getLemmatizer(); - - this.stopWords = stopWords; - this.stringSimilarityMetric=stringSimilarityMetric; - } - - - public Map computeElementScores(Entity candidate, - List allCandidates, - int entity_source_column, - int entity_source_row, - List block, - Table table, - Entity... reference_disambiguated_entities) { - Map scoreMap = new HashMap<>(); - String headerText =table.getColumnHeader(entity_source_column).getHeaderText(); - if(block==null||block.size()==0) - block=new ArrayList<>(); - if(!block.contains(entity_source_row)) - block.add(entity_source_row); - - /* BOW OF THE ENTITY*/ - List attributes = candidate.getAttributes(); - List entityBoW = new ArrayList<>(); - for (Attribute f : attributes) { - String value = f.getValue(); - if (!StringUtils.isPath(value)) - entityBoW.addAll(StringUtils.toBagOfWords(value, true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)); - else - entityBoW.add(value); - } - if (lemmatizer != null) - entityBoW = lemmatizer.lemmatize(entityBoW); - entityBoW.removeAll(stopWords); - - /* BOW OF THE Row context*/ - List rowContextBoW = new ArrayList<>(); - for (int row : block) { - for (int col = 0; col < table.getNumCols(); col++) { - if (col == entity_source_column || table.getColumnHeader(col).getTypes().get(0).getType().equals( - DataTypeClassifier.DataType.ORDERED_NUMBER - )) - continue; - TCell tcc = table.getContentCell(row, col); - rowContextBoW.addAll(StringUtils.toBagOfWords(tcc.getText(), true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)); - } - rowContextBoW.addAll(StringUtils.toBagOfWords( - headerText, true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)); - } - if (lemmatizer != null) - rowContextBoW = lemmatizer.lemmatize(rowContextBoW); - rowContextBoW.removeAll(stopWords); - /*rowContextBoW.addAll(StringUtils.toBagOfWords( //also add the column header as the row context of this entity - headerText, true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)); - */ - double contextOverlapScore = CollectionUtils.computeCoverage(entityBoW, rowContextBoW); - scoreMap.put(TMPEntityScorer.SCORE_IN_CTX_ROW, contextOverlapScore); - - String cell_text = table.getContentCell(entity_source_row, entity_source_column).getText(); - cell_text=StringUtils.toAlphaNumericWhitechar(cell_text); - String entity_name = candidate.getLabel(); - entity_name=StringUtils.toAlphaNumericWhitechar(entity_name); - //double stringSim = CollectionUtils.diceCoefficientOptimized(cell_text,entity_name); - double stringSim = stringSimilarityMetric.compare(cell_text, entity_name); - scoreMap.put(SCORE_NAME_MATCH, stringSim); - - return scoreMap; - } - - - @Override - public double computeFinal(Map scoreMap, String cellTextOriginal) { - double sum = 0.0; - for (Map.Entry e : scoreMap.entrySet()) { - if (e.getKey().startsWith("ctx_")) - sum += e.getValue(); - if(e.getKey().equals(SCORE_NAME_MATCH)) - sum+=e.getValue(); - } - - scoreMap.put(TCellAnnotation.SCORE_FINAL, sum); - return sum; - } -} +package uk.ac.shef.dcs.sti.core.algorithm.baseline; + +import org.simmetrics.Metric; +import org.simmetrics.StringMetric; +import uk.ac.shef.dcs.kbsearch.model.Attribute; +import uk.ac.shef.dcs.sti.STIConstantProperty; +import uk.ac.shef.dcs.sti.core.algorithm.tmp.scorer.TMPEntityScorer; +import uk.ac.shef.dcs.sti.core.scorer.EntityScorer; +import uk.ac.shef.dcs.sti.nlp.Lemmatizer; +import uk.ac.shef.dcs.sti.nlp.NLPTools; +import uk.ac.shef.dcs.sti.util.DataTypeClassifier; +import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; +import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.sti.core.model.TCell; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.util.CollectionUtils; +import uk.ac.shef.dcs.util.StringUtils; + +import java.io.IOException; +import java.util.*; + +/** + * Created with IntelliJ IDEA. + * User: zqz + * Date: 11/03/14 + * Time: 12:18 + * To change this template use File | Settings | File Templates. + */ +public class BaselineSimilarityEntityScorer implements EntityScorer { + private static final String SCORE_NAME_MATCH = "name_string_similarity"; + private List stopWords; + private Lemmatizer lemmatizer; + private StringMetric stringSimilarityMetric; + + /* + context weights: 0-row context; 1-column context; 2-table context + */ + public BaselineSimilarityEntityScorer( + List stopWords, + String nlpResources, + StringMetric stringSimilarityMetric) throws IOException { + if (nlpResources != null) + lemmatizer = NLPTools.getInstance(nlpResources).getLemmatizer(); + + this.stopWords = stopWords; + this.stringSimilarityMetric=stringSimilarityMetric; + } + + + public Map computeElementScores(Entity candidate, + List allCandidates, + int entity_source_column, + int entity_source_row, + List block, + Table table, + Entity... reference_disambiguated_entities) { + Map scoreMap = new HashMap<>(); + String headerText =table.getColumnHeader(entity_source_column).getHeaderText(); + if(block==null||block.size()==0) + block=new ArrayList<>(); + if(!block.contains(entity_source_row)) + block.add(entity_source_row); + + /* BOW OF THE ENTITY*/ + List attributes = candidate.getAttributes(); + List entityBoW = new ArrayList<>(); + for (Attribute f : attributes) { + String value = f.getValue(); + if (!StringUtils.isPath(value)) + entityBoW.addAll(StringUtils.toBagOfWords(value, true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)); + else + entityBoW.add(value); + } + if (lemmatizer != null) + entityBoW = lemmatizer.lemmatize(entityBoW); + entityBoW.removeAll(stopWords); + + /* BOW OF THE Row context*/ + List rowContextBoW = new ArrayList<>(); + for (int row : block) { + for (int col = 0; col < table.getNumCols(); col++) { + if (col == entity_source_column || table.getColumnHeader(col).getTypes().get(0).getType().equals( + DataTypeClassifier.DataType.ORDERED_NUMBER + )) + continue; + TCell tcc = table.getContentCell(row, col); + rowContextBoW.addAll(StringUtils.toBagOfWords(tcc.getText(), true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)); + } + rowContextBoW.addAll(StringUtils.toBagOfWords( + headerText, true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)); + } + if (lemmatizer != null) + rowContextBoW = lemmatizer.lemmatize(rowContextBoW); + rowContextBoW.removeAll(stopWords); + /*rowContextBoW.addAll(StringUtils.toBagOfWords( //also add the column header as the row context of this entity + headerText, true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)); + */ + double contextOverlapScore = CollectionUtils.computeCoverage(entityBoW, rowContextBoW); + scoreMap.put(TMPEntityScorer.SCORE_IN_CTX_ROW, contextOverlapScore); + + String cell_text = table.getContentCell(entity_source_row, entity_source_column).getText(); + cell_text=StringUtils.toAlphaNumericWhitechar(cell_text); + String entity_name = candidate.getLabel(); + entity_name=StringUtils.toAlphaNumericWhitechar(entity_name); + //double stringSim = CollectionUtils.diceCoefficientOptimized(cell_text,entity_name); + double stringSim = stringSimilarityMetric.compare(cell_text, entity_name); + scoreMap.put(SCORE_NAME_MATCH, stringSim); + + return scoreMap; + } + + + @Override + public double computeFinal(Map scoreMap, String cellTextOriginal) { + double sum = 0.0; + for (Map.Entry e : scoreMap.entrySet()) { + if (e.getKey().startsWith("ctx_")) + sum += e.getValue(); + if(e.getKey().equals(SCORE_NAME_MATCH)) + sum+=e.getValue(); + } + + scoreMap.put(TCellAnnotation.SCORE_FINAL, sum); + return sum; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguator.java index 74c4f797..3bd6f1f3 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguator.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguator.java @@ -1,141 +1,141 @@ -package uk.ac.shef.dcs.sti.core.algorithm.baseline; - -import javafx.util.Pair; -import uk.ac.shef.dcs.kbsearch.KBSearch; -import uk.ac.shef.dcs.kbsearch.KBSearchException; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; -import uk.ac.shef.dcs.sti.core.model.TAnnotation; -import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; -import uk.ac.shef.dcs.sti.core.model.Table; - -import java.util.*; - -/** - * - */ -public abstract class TCellDisambiguator { - - protected KBSearch kbSearch; - - public TCellDisambiguator( - KBSearch candidateFinder) { - this.kbSearch = candidateFinder; - } - - protected abstract Map>>> disambiguate( - Table table, TAnnotation table_annotation, int column, Integer... skipRows) throws KBSearchException; - - protected void revise(TAnnotation tableAnnotation, - Table table, - Map>>> rowIndex_and_entityScores, - int column) { - List winningColumnClazz = tableAnnotation.getWinningHeaderAnnotations(column); - List types = new ArrayList<>(); - for (TColumnHeaderAnnotation ha : winningColumnClazz) - types.add(ha.getAnnotation().getId()); - - for (Map.Entry>>> e : - rowIndex_and_entityScores.entrySet()) { - - int row = e.getKey(); - List>> entities_for_this_cell_and_scores = e.getValue(); - if (entities_for_this_cell_and_scores.size() == 0) - continue; - - List>> revised = reselect(entities_for_this_cell_and_scores, types); - if (revised.size() != 0) - entities_for_this_cell_and_scores = revised; - - List winningEntities = - generateCellAnnotations(table, - tableAnnotation, row, column, entities_for_this_cell_and_scores - ); //supporting rows are added here, impossible other places - updateColumnClazzSupportingRows(winningEntities, row, column, tableAnnotation); - } - } - - - private List>> reselect( - List>> entity_and_scoreMap, - List types) { - - Iterator>> it = entity_and_scoreMap.iterator(); - List>> original = new ArrayList<>( - entity_and_scoreMap - ); - - while (it.hasNext()) { - Pair> oo = it.next(); - Set entity_types = new HashSet<>(oo.getKey().getTypeIds()); - entity_types.retainAll(types); - if (entity_types.size() == 0) - it.remove(); - } - - if (entity_and_scoreMap.size() == 0) - return original; - - return entity_and_scoreMap; - } - - - private void updateColumnClazzSupportingRows(List winningEntities, - int row, - int column, - TAnnotation table_annotation) { - TColumnHeaderAnnotation[] headers = table_annotation.getHeaderAnnotation(column); - if (headers != null) { - for (TColumnHeaderAnnotation ha : headers) { - for (Entity ec : winningEntities) { - if (ec.getTypeIds().contains(ha.getAnnotation().getId())) { - ha.addSupportingRow(row); - break; - } - } - } - } - } - - - private List generateCellAnnotations( - Table table, - TAnnotation table_annotation, - int table_cell_row, - int table_cell_col, - List>> candidates_and_scores_for_cell) { - - Collections.sort(candidates_and_scores_for_cell, (o1, o2) -> { - Double score1 = o1.getValue().get(TCellAnnotation.SCORE_FINAL); - Double score2 = o2.getValue().get(TCellAnnotation.SCORE_FINAL); - return score2.compareTo(score1); - }); - - double maxScore = candidates_and_scores_for_cell.get(0).getValue().get(TCellAnnotation.SCORE_FINAL); - - List annotations = new ArrayList<>(); - for (Pair> e : candidates_and_scores_for_cell) { - Double score = e.getValue().get(TCellAnnotation.SCORE_FINAL); - if (score == maxScore) { - TCellAnnotation ca = new TCellAnnotation( - table.getContentCell(table_cell_row, table_cell_col).getText(), - e.getKey(), - maxScore, - e.getValue()); - annotations.add(ca); - } else - break; - } - - table_annotation.setContentCellAnnotations(table_cell_row, table_cell_col, - annotations.toArray(new TCellAnnotation[0])); - - List candidates = new ArrayList<>(); - for (int i = 0; i < candidates_and_scores_for_cell.size(); i++) { - Pair> e = candidates_and_scores_for_cell.get(i); - - candidates.add(e.getKey()); - } - return candidates; - } -} +package uk.ac.shef.dcs.sti.core.algorithm.baseline; + +import javafx.util.Pair; +import uk.ac.shef.dcs.kbsearch.KBSearch; +import uk.ac.shef.dcs.kbsearch.KBSearchException; +import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; +import uk.ac.shef.dcs.sti.core.model.TAnnotation; +import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; +import uk.ac.shef.dcs.sti.core.model.Table; + +import java.util.*; + +/** + * + */ +public abstract class TCellDisambiguator { + + protected KBSearch kbSearch; + + public TCellDisambiguator( + KBSearch candidateFinder) { + this.kbSearch = candidateFinder; + } + + protected abstract Map>>> disambiguate( + Table table, TAnnotation table_annotation, int column, Integer... skipRows) throws KBSearchException; + + protected void revise(TAnnotation tableAnnotation, + Table table, + Map>>> rowIndex_and_entityScores, + int column) { + List winningColumnClazz = tableAnnotation.getWinningHeaderAnnotations(column); + List types = new ArrayList<>(); + for (TColumnHeaderAnnotation ha : winningColumnClazz) + types.add(ha.getAnnotation().getId()); + + for (Map.Entry>>> e : + rowIndex_and_entityScores.entrySet()) { + + int row = e.getKey(); + List>> entities_for_this_cell_and_scores = e.getValue(); + if (entities_for_this_cell_and_scores.size() == 0) + continue; + + List>> revised = reselect(entities_for_this_cell_and_scores, types); + if (revised.size() != 0) + entities_for_this_cell_and_scores = revised; + + List winningEntities = + generateCellAnnotations(table, + tableAnnotation, row, column, entities_for_this_cell_and_scores + ); //supporting rows are added here, impossible other places + updateColumnClazzSupportingRows(winningEntities, row, column, tableAnnotation); + } + } + + + private List>> reselect( + List>> entity_and_scoreMap, + List types) { + + Iterator>> it = entity_and_scoreMap.iterator(); + List>> original = new ArrayList<>( + entity_and_scoreMap + ); + + while (it.hasNext()) { + Pair> oo = it.next(); + Set entity_types = new HashSet<>(oo.getKey().getTypeIds()); + entity_types.retainAll(types); + if (entity_types.size() == 0) + it.remove(); + } + + if (entity_and_scoreMap.size() == 0) + return original; + + return entity_and_scoreMap; + } + + + private void updateColumnClazzSupportingRows(List winningEntities, + int row, + int column, + TAnnotation table_annotation) { + TColumnHeaderAnnotation[] headers = table_annotation.getHeaderAnnotation(column); + if (headers != null) { + for (TColumnHeaderAnnotation ha : headers) { + for (Entity ec : winningEntities) { + if (ec.getTypeIds().contains(ha.getAnnotation().getId())) { + ha.addSupportingRow(row); + break; + } + } + } + } + } + + + private List generateCellAnnotations( + Table table, + TAnnotation table_annotation, + int table_cell_row, + int table_cell_col, + List>> candidates_and_scores_for_cell) { + + Collections.sort(candidates_and_scores_for_cell, (o1, o2) -> { + Double score1 = o1.getValue().get(TCellAnnotation.SCORE_FINAL); + Double score2 = o2.getValue().get(TCellAnnotation.SCORE_FINAL); + return score2.compareTo(score1); + }); + + double maxScore = candidates_and_scores_for_cell.get(0).getValue().get(TCellAnnotation.SCORE_FINAL); + + List annotations = new ArrayList<>(); + for (Pair> e : candidates_and_scores_for_cell) { + Double score = e.getValue().get(TCellAnnotation.SCORE_FINAL); + if (score == maxScore) { + TCellAnnotation ca = new TCellAnnotation( + table.getContentCell(table_cell_row, table_cell_col).getText(), + e.getKey(), + maxScore, + e.getValue()); + annotations.add(ca); + } else + break; + } + + table_annotation.setContentCellAnnotations(table_cell_row, table_cell_col, + annotations.toArray(new TCellAnnotation[0])); + + List candidates = new ArrayList<>(); + for (int i = 0; i < candidates_and_scores_for_cell.size(); i++) { + Pair> e = candidates_and_scores_for_cell.get(i); + + candidates.add(e.getKey()); + } + return candidates; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguatorNameMatch.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguatorNameMatch.java index c43871b0..b5fe1226 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguatorNameMatch.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguatorNameMatch.java @@ -1,109 +1,109 @@ -package uk.ac.shef.dcs.sti.core.algorithm.baseline; - -import javafx.util.Pair; -import org.apache.log4j.Logger; -import uk.ac.shef.dcs.kbsearch.KBSearch; -import uk.ac.shef.dcs.kbsearch.KBSearchException; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.sti.core.model.*; - -import java.util.*; -import java.util.List; - -/** - * the default cell disambiguator adopts the name match strategy B_nm - */ -public class TCellDisambiguatorNameMatch extends TCellDisambiguator { - private static final Logger LOG = Logger.getLogger(TCellDisambiguatorNameMatch.class.getName()); - - public TCellDisambiguatorNameMatch( - KBSearch kbSearch) { - super(kbSearch); - } - - protected Map>>> disambiguate( - Table table, TAnnotation table_annotation, int column, Integer... skipRows) throws KBSearchException { - Map>>> rowIndex_and_entities = - new HashMap<>(); - - for (int row_index = 0; row_index < table.getNumRows(); row_index++) { - TCell tcc = table.getContentCell(row_index, column); - LOG.info("\t>> Disambiguation: row=" + row_index + "," + tcc); - - if (tcc.getText().length() < 2) { - LOG.debug("\t\t>> Very short text cell skipped: " + row_index + "," + column + " " + tcc.getText()); - continue; - } - - boolean skip = false; - for (int row : skipRows) { - if (row == row_index) { - skip = true; - break; - } - } - - List>> disambResult; - if (skip) { - collectExistingAnnotations(table_annotation, row_index, column); - } else { - List candidates = kbSearch.findEntityCandidates(tcc.getText()); - disambResult = - disambiguate(candidates, table, row_index, column); - if (disambResult != null && disambResult.size() > 0) { - rowIndex_and_entities.put(row_index, disambResult); - } - } - } - return rowIndex_and_entities; - } - - private List>> collectExistingAnnotations( - TAnnotation tableAnnotation, int row, int column) { - List>> candidates = new ArrayList<>(); - TCellAnnotation[] annotations = tableAnnotation.getContentCellAnnotations(row, column); - for (TCellAnnotation can : annotations) { - Entity ec = can.getAnnotation(); - Map scoreElements = can.getScoreElements(); - scoreElements.put(TCellAnnotation.SCORE_FINAL, can.getFinalScore()); - candidates.add(new Pair<>(ec, scoreElements)); - } - - return candidates; - } - - protected List>> disambiguate(List candidates, Table table, - int entity_row, int entity_column - ) { - //name match: either find the one with identical name, or pick the highest rank (assuming input candidates is sorted) - LOG.info("\t\t>> (disambiguation, position at [" + entity_row + "," + entity_column + "]: " + table.getContentCell(entity_row, entity_column) + - " candidates=" + candidates.size() + ")"); - List>> disambiguationScores = new ArrayList<>(); - if (candidates.size() > 0) { - List candidatesCopy = new ArrayList<>(); - for (Entity ec : candidates) { - TCell tcc = table.getContentCell(entity_row, entity_column); - if (tcc.getText() != null) { - if (ec.getLabel().equalsIgnoreCase(tcc.getText().trim())) - candidatesCopy.add(ec); - } - } - - Map scoreMap = new HashMap<>(); - scoreMap.put(TCellAnnotation.SCORE_FINAL,1.0); - if (candidatesCopy.size() > 0) { - disambiguationScores.add(new Pair<>( - candidatesCopy.get(0), scoreMap - )); - } else { - disambiguationScores.add(new Pair<>( - candidates.get(0), scoreMap - )); - } - - } - return disambiguationScores; - } - - +package uk.ac.shef.dcs.sti.core.algorithm.baseline; + +import javafx.util.Pair; +import org.apache.log4j.Logger; +import uk.ac.shef.dcs.kbsearch.KBSearch; +import uk.ac.shef.dcs.kbsearch.KBSearchException; +import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.sti.core.model.*; + +import java.util.*; +import java.util.List; + +/** + * the default cell disambiguator adopts the name match strategy B_nm + */ +public class TCellDisambiguatorNameMatch extends TCellDisambiguator { + private static final Logger LOG = Logger.getLogger(TCellDisambiguatorNameMatch.class.getName()); + + public TCellDisambiguatorNameMatch( + KBSearch kbSearch) { + super(kbSearch); + } + + protected Map>>> disambiguate( + Table table, TAnnotation table_annotation, int column, Integer... skipRows) throws KBSearchException { + Map>>> rowIndex_and_entities = + new HashMap<>(); + + for (int row_index = 0; row_index < table.getNumRows(); row_index++) { + TCell tcc = table.getContentCell(row_index, column); + LOG.info("\t>> Disambiguation: row=" + row_index + "," + tcc); + + if (tcc.getText().length() < 2) { + LOG.debug("\t\t>> Very short text cell skipped: " + row_index + "," + column + " " + tcc.getText()); + continue; + } + + boolean skip = false; + for (int row : skipRows) { + if (row == row_index) { + skip = true; + break; + } + } + + List>> disambResult; + if (skip) { + collectExistingAnnotations(table_annotation, row_index, column); + } else { + List candidates = kbSearch.findEntityCandidates(tcc.getText()); + disambResult = + disambiguate(candidates, table, row_index, column); + if (disambResult != null && disambResult.size() > 0) { + rowIndex_and_entities.put(row_index, disambResult); + } + } + } + return rowIndex_and_entities; + } + + private List>> collectExistingAnnotations( + TAnnotation tableAnnotation, int row, int column) { + List>> candidates = new ArrayList<>(); + TCellAnnotation[] annotations = tableAnnotation.getContentCellAnnotations(row, column); + for (TCellAnnotation can : annotations) { + Entity ec = can.getAnnotation(); + Map scoreElements = can.getScoreElements(); + scoreElements.put(TCellAnnotation.SCORE_FINAL, can.getFinalScore()); + candidates.add(new Pair<>(ec, scoreElements)); + } + + return candidates; + } + + protected List>> disambiguate(List candidates, Table table, + int entity_row, int entity_column + ) { + //name match: either find the one with identical name, or pick the highest rank (assuming input candidates is sorted) + LOG.info("\t\t>> (disambiguation, position at [" + entity_row + "," + entity_column + "]: " + table.getContentCell(entity_row, entity_column) + + " candidates=" + candidates.size() + ")"); + List>> disambiguationScores = new ArrayList<>(); + if (candidates.size() > 0) { + List candidatesCopy = new ArrayList<>(); + for (Entity ec : candidates) { + TCell tcc = table.getContentCell(entity_row, entity_column); + if (tcc.getText() != null) { + if (ec.getLabel().equalsIgnoreCase(tcc.getText().trim())) + candidatesCopy.add(ec); + } + } + + Map scoreMap = new HashMap<>(); + scoreMap.put(TCellAnnotation.SCORE_FINAL,1.0); + if (candidatesCopy.size() > 0) { + disambiguationScores.add(new Pair<>( + candidatesCopy.get(0), scoreMap + )); + } else { + disambiguationScores.add(new Pair<>( + candidates.get(0), scoreMap + )); + } + + } + return disambiguationScores; + } + + } \ No newline at end of file diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguatorSimilarity.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguatorSimilarity.java index fae82dce..2e0251cc 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguatorSimilarity.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TCellDisambiguatorSimilarity.java @@ -1,45 +1,45 @@ -package uk.ac.shef.dcs.sti.core.algorithm.baseline; - -import javafx.util.Pair; -import org.apache.log4j.Logger; -import uk.ac.shef.dcs.kbsearch.KBSearch; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.sti.core.model.Table; - -import java.util.*; - -/** - * - */ -public class TCellDisambiguatorSimilarity extends TCellDisambiguatorNameMatch { - - private static final Logger LOG = Logger.getLogger(TCellDisambiguatorSimilarity.class.getName()); - private BaselineSimilarityEntityScorer entityScorer; - - public TCellDisambiguatorSimilarity(KBSearch candidateFinder, - BaselineSimilarityEntityScorer entityScorer) { - super(candidateFinder); - this.entityScorer = entityScorer; - } - - protected List>> disambiguate(List candidates, - Table table, - int entity_row, - int entity_column - ) { - LOG.info("\t\t>> (disambiguation, position at [" + entity_row + "," + entity_column + "]: " + table.getContentCell(entity_row, entity_column) + - " candidates=" + candidates.size() + ")"); - List>> disambiguationScores = new ArrayList<>(); - if (candidates.size() > 0) { - for (Entity ec : candidates) { - Map scoreElements - = entityScorer.computeElementScores(ec, candidates, - entity_column, entity_row, Collections.singletonList(entity_row), - table); - entityScorer.computeFinal(scoreElements, table.getContentCell(entity_row, entity_column).getText()); - disambiguationScores.add(new Pair<>(ec, scoreElements)); - } - } - return disambiguationScores; - } -} +package uk.ac.shef.dcs.sti.core.algorithm.baseline; + +import javafx.util.Pair; +import org.apache.log4j.Logger; +import uk.ac.shef.dcs.kbsearch.KBSearch; +import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.sti.core.model.Table; + +import java.util.*; + +/** + * + */ +public class TCellDisambiguatorSimilarity extends TCellDisambiguatorNameMatch { + + private static final Logger LOG = Logger.getLogger(TCellDisambiguatorSimilarity.class.getName()); + private BaselineSimilarityEntityScorer entityScorer; + + public TCellDisambiguatorSimilarity(KBSearch candidateFinder, + BaselineSimilarityEntityScorer entityScorer) { + super(candidateFinder); + this.entityScorer = entityScorer; + } + + protected List>> disambiguate(List candidates, + Table table, + int entity_row, + int entity_column + ) { + LOG.info("\t\t>> (disambiguation, position at [" + entity_row + "," + entity_column + "]: " + table.getContentCell(entity_row, entity_column) + + " candidates=" + candidates.size() + ")"); + List>> disambiguationScores = new ArrayList<>(); + if (candidates.size() > 0) { + for (Entity ec : candidates) { + Map scoreElements + = entityScorer.computeElementScores(ec, candidates, + entity_column, entity_row, Collections.singletonList(entity_row), + table); + entityScorer.computeFinal(scoreElements, table.getContentCell(entity_row, entity_column).getText()); + disambiguationScores.add(new Pair<>(ec, scoreElements)); + } + } + return disambiguationScores; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifier.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifier.java index 103fafa4..ddf5844e 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifier.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifier.java @@ -1,46 +1,46 @@ -package uk.ac.shef.dcs.sti.core.algorithm.baseline; - -import javafx.util.Pair; -import uk.ac.shef.dcs.kbsearch.model.Clazz; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.model.TAnnotation; -import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; -import uk.ac.shef.dcs.sti.core.model.Table; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - * Created by - on 12/04/2016. - */ -public abstract class TColumnClassifier { - - protected abstract void classify(Map>>> rowIndex_and_entities, - Table table, TAnnotation tableAnnotation, - int column) throws STIException; - - //assigns highest scoring column_type_label to the column; - //then disambiguate those rows that contributed to the prediction to column_type_scorings - //WARNING: SUPPORTING ROWS NOT ADDED HERE - protected void generateColumnClazzAnnotations(final Map state, - Table table, - TAnnotation tableAnnotation, - int column) { - List candidates = new ArrayList<>(state.keySet()); - Collections.sort(candidates, (o1, o2) -> state.get(o2).compareTo(state.get(o1))); - //insert column type annotations - TColumnHeaderAnnotation[] finalResult = new TColumnHeaderAnnotation[candidates.size()]; - for (int i = 0; i < candidates.size(); i++){ - Clazz c = candidates.get(i); - TColumnHeaderAnnotation ha = new TColumnHeaderAnnotation( - table.getColumnHeader(column).getHeaderText(),c,state.get(c)); - finalResult[i] = ha; - } - tableAnnotation.setHeaderAnnotation(column, finalResult); - } - - -} +package uk.ac.shef.dcs.sti.core.algorithm.baseline; + +import javafx.util.Pair; +import uk.ac.shef.dcs.kbsearch.model.Clazz; +import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.model.TAnnotation; +import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; +import uk.ac.shef.dcs.sti.core.model.Table; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** + * Created by - on 12/04/2016. + */ +public abstract class TColumnClassifier { + + protected abstract void classify(Map>>> rowIndex_and_entities, + Table table, TAnnotation tableAnnotation, + int column) throws STIException; + + //assigns highest scoring column_type_label to the column; + //then disambiguate those rows that contributed to the prediction to column_type_scorings + //WARNING: SUPPORTING ROWS NOT ADDED HERE + protected void generateColumnClazzAnnotations(final Map state, + Table table, + TAnnotation tableAnnotation, + int column) { + List candidates = new ArrayList<>(state.keySet()); + Collections.sort(candidates, (o1, o2) -> state.get(o2).compareTo(state.get(o1))); + //insert column type annotations + TColumnHeaderAnnotation[] finalResult = new TColumnHeaderAnnotation[candidates.size()]; + for (int i = 0; i < candidates.size(); i++){ + Clazz c = candidates.get(i); + TColumnHeaderAnnotation ha = new TColumnHeaderAnnotation( + table.getColumnHeader(column).getHeaderText(),c,state.get(c)); + finalResult[i] = ha; + } + tableAnnotation.setHeaderAnnotation(column, finalResult); + } + + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifierNameMatch.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifierNameMatch.java index 984eb7af..54107962 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifierNameMatch.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifierNameMatch.java @@ -1,60 +1,60 @@ -package uk.ac.shef.dcs.sti.core.algorithm.baseline; - -import javafx.util.Pair; -import uk.ac.shef.dcs.kbsearch.model.Clazz; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; -import uk.ac.shef.dcs.sti.core.model.TAnnotation; -import uk.ac.shef.dcs.sti.core.model.Table; - -import java.util.*; - -/** - * The default column classifier adopts the simple voting strategy (B_nm) - */ -public class TColumnClassifierNameMatch extends TColumnClassifier{ - - protected void classify(Map>>> rowIndex_and_entities, - Table table, TAnnotation tableAnnotation, - int column){ - Map state = new HashMap<>(); - Map uri_and_clazz = new HashMap<>(); - for (Map.Entry>>> e : rowIndex_and_entities.entrySet()) { - List>> entities = e.getValue(); - if (entities.size() > 0) { - Collections.sort(entities, (o1, o2) -> { - Double score1 = o1.getValue().get(TCellAnnotation.SCORE_FINAL); - Double score2=o2.getValue().get(TCellAnnotation.SCORE_FINAL); - return score2.compareTo(score1); - }); - - double maxScore = entities.get(0).getValue().get(TCellAnnotation.SCORE_FINAL); - for(Pair> p:entities){ - Entity ec=p.getKey(); - Double score = p.getValue().get(TCellAnnotation.SCORE_FINAL); - if(score!=maxScore){ - break; - } - List types = ec.getTypes(); - for (Clazz t : types) { - uri_and_clazz.put(t.getId(), t); - Double prevScore = state.get(t.getId()); - if (prevScore == null) - prevScore = 0.0; - prevScore += 1.0; - state.put(t.getId(), prevScore); - } - } - } - } - - Map clazzScores = new HashMap<>(); - for(Map.Entry e: state.entrySet()){ - Clazz c = uri_and_clazz.get(e.getKey()); - Double score = e.getValue(); - clazzScores.put(c, score); - } - generateColumnClazzAnnotations(clazzScores, table, tableAnnotation, column); //supporting rows not added - } - -} +package uk.ac.shef.dcs.sti.core.algorithm.baseline; + +import javafx.util.Pair; +import uk.ac.shef.dcs.kbsearch.model.Clazz; +import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; +import uk.ac.shef.dcs.sti.core.model.TAnnotation; +import uk.ac.shef.dcs.sti.core.model.Table; + +import java.util.*; + +/** + * The default column classifier adopts the simple voting strategy (B_nm) + */ +public class TColumnClassifierNameMatch extends TColumnClassifier{ + + protected void classify(Map>>> rowIndex_and_entities, + Table table, TAnnotation tableAnnotation, + int column){ + Map state = new HashMap<>(); + Map uri_and_clazz = new HashMap<>(); + for (Map.Entry>>> e : rowIndex_and_entities.entrySet()) { + List>> entities = e.getValue(); + if (entities.size() > 0) { + Collections.sort(entities, (o1, o2) -> { + Double score1 = o1.getValue().get(TCellAnnotation.SCORE_FINAL); + Double score2=o2.getValue().get(TCellAnnotation.SCORE_FINAL); + return score2.compareTo(score1); + }); + + double maxScore = entities.get(0).getValue().get(TCellAnnotation.SCORE_FINAL); + for(Pair> p:entities){ + Entity ec=p.getKey(); + Double score = p.getValue().get(TCellAnnotation.SCORE_FINAL); + if(score!=maxScore){ + break; + } + List types = ec.getTypes(); + for (Clazz t : types) { + uri_and_clazz.put(t.getId(), t); + Double prevScore = state.get(t.getId()); + if (prevScore == null) + prevScore = 0.0; + prevScore += 1.0; + state.put(t.getId(), prevScore); + } + } + } + } + + Map clazzScores = new HashMap<>(); + for(Map.Entry e: state.entrySet()){ + Clazz c = uri_and_clazz.get(e.getKey()); + Double score = e.getValue(); + clazzScores.put(c, score); + } + generateColumnClazzAnnotations(clazzScores, table, tableAnnotation, column); //supporting rows not added + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifierSimilarity.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifierSimilarity.java index 25d11895..e8198c23 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifierSimilarity.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/baseline/TColumnClassifierSimilarity.java @@ -1,47 +1,47 @@ -package uk.ac.shef.dcs.sti.core.algorithm.baseline; - -import javafx.util.Pair; -import uk.ac.shef.dcs.kbsearch.model.Clazz; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.model.TAnnotation; -import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; -import uk.ac.shef.dcs.sti.core.model.Table; - -import java.util.*; - -/** - * - */ -public class TColumnClassifierSimilarity extends TColumnClassifier { - - private BaselineSimilarityClazzScorer clazzScorer; - - public TColumnClassifierSimilarity(BaselineSimilarityClazzScorer clazzScorer){ - this.clazzScorer=clazzScorer; - } - - @Override - protected void classify(Map>>> rowIndex_and_entities, - Table table, - TAnnotation tableAnnotation, - int column) throws STIException { - Map state = new HashMap<>(); - List columnHeaderAnnotations = new ArrayList<>(); - for (Map.Entry>>> e : rowIndex_and_entities.entrySet()) { - List>> entities = e.getValue(); - List blockOfRows = Collections.singletonList(e.getKey()); - - columnHeaderAnnotations= - clazzScorer.computeElementScores(entities,columnHeaderAnnotations, table, - blockOfRows, column); - } - - for(TColumnHeaderAnnotation columnHeaderAnnotation: columnHeaderAnnotations){ - clazzScorer.computeFinal(columnHeaderAnnotation, - table.getNumRows()); - } - generateColumnClazzAnnotations(state, table, tableAnnotation, column); //supporting rows not added - - } -} +package uk.ac.shef.dcs.sti.core.algorithm.baseline; + +import javafx.util.Pair; +import uk.ac.shef.dcs.kbsearch.model.Clazz; +import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.model.TAnnotation; +import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; +import uk.ac.shef.dcs.sti.core.model.Table; + +import java.util.*; + +/** + * + */ +public class TColumnClassifierSimilarity extends TColumnClassifier { + + private BaselineSimilarityClazzScorer clazzScorer; + + public TColumnClassifierSimilarity(BaselineSimilarityClazzScorer clazzScorer){ + this.clazzScorer=clazzScorer; + } + + @Override + protected void classify(Map>>> rowIndex_and_entities, + Table table, + TAnnotation tableAnnotation, + int column) throws STIException { + Map state = new HashMap<>(); + List columnHeaderAnnotations = new ArrayList<>(); + for (Map.Entry>>> e : rowIndex_and_entities.entrySet()) { + List>> entities = e.getValue(); + List blockOfRows = Collections.singletonList(e.getKey()); + + columnHeaderAnnotations= + clazzScorer.computeElementScores(entities,columnHeaderAnnotations, table, + blockOfRows, column); + } + + for(TColumnHeaderAnnotation columnHeaderAnnotation: columnHeaderAnnotations){ + clazzScorer.computeFinal(columnHeaderAnnotation, + table.getNumRows()); + } + generateColumnClazzAnnotations(state, table, tableAnnotation, column); //supporting rows not added + + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateConceptGenerator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateConceptGenerator.java index 81a91b77..8a00cd51 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateConceptGenerator.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateConceptGenerator.java @@ -1,117 +1,117 @@ -package uk.ac.shef.dcs.sti.core.algorithm.ji; - -import javafx.util.Pair; -import org.apache.log4j.Logger; -import uk.ac.shef.dcs.kbsearch.KBSearch; -import uk.ac.shef.dcs.kbsearch.KBSearchException; -import uk.ac.shef.dcs.kbsearch.model.Attribute; -import uk.ac.shef.dcs.kbsearch.model.Clazz; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.algorithm.ji.similarity.EntityAndClazzSimilarityScorer; -import uk.ac.shef.dcs.sti.core.algorithm.ji.similarity.SimilarityComputerManager; -import uk.ac.shef.dcs.sti.core.algorithm.smp.ClazzSpecificityCalculator; -import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; -import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; -import uk.ac.shef.dcs.sti.core.model.Table; - -import java.util.*; - -/** - * - */ -public class CandidateConceptGenerator { - - private static final Logger LOG = Logger.getLogger(CandidateConceptGenerator.class.getName()); - private int threads = 10; - private SimilarityComputerManager simComputer; - private KBSearch kbSearch; - private JIClazzScorer clazzScorer; - private ClazzSpecificityCalculator clazzSpecificityCalculator; - - public CandidateConceptGenerator(KBSearch kbSearch, - JIClazzScorer clazzScorer, - EntityAndClazzSimilarityScorer entityAndConceptScorer, - ClazzSpecificityCalculator clazzSpecificityCalculator, - int threads, - boolean useCache) { - this.kbSearch = kbSearch; - this.clazzScorer = clazzScorer; - this.threads = threads; - this.clazzSpecificityCalculator = clazzSpecificityCalculator; - simComputer = new SimilarityComputerManager(useCache,kbSearch,entityAndConceptScorer); - } - - public void generateInitialColumnAnnotations(TAnnotationJI tableAnnotation, Table table, int col) throws KBSearchException, STIException { - List distinctTypes = new ArrayList<>(); - Map> entityId_and_clazzURLs = new HashMap<>(); - List distinctEntities = new ArrayList<>(); - - List candidates = new ArrayList<>(); - for (int r = 0; r < table.getNumRows(); r++) { - TCellAnnotation[] cellAnnotations = tableAnnotation.getContentCellAnnotations(r, col); - List>> entities = new ArrayList<>(); - for (TCellAnnotation tCellAnnotation : cellAnnotations) { - Entity e = tCellAnnotation.getAnnotation(); - entities.add(new Pair<>(e, tCellAnnotation.getScoreElements())); - if (!distinctEntities.contains(tCellAnnotation.getAnnotation())) - distinctEntities.add(tCellAnnotation.getAnnotation()); - - for (Clazz c : e.getTypes()) { - Set conceptURLs = entityId_and_clazzURLs.get(e.getId()); - if (conceptURLs == null) - conceptURLs = new HashSet<>(); - conceptURLs.add(c.getId()); - entityId_and_clazzURLs.put(e.getId(), conceptURLs); - } - - } - candidates = - clazzScorer.computeElementScores(entities, candidates, table, Collections.singletonList(r), col); - } - - //fetch all concept entities and set attributes - for (TColumnHeaderAnnotation tca : candidates) { - clazzScorer.computeFinal(tca, table.getNumRows()); - Clazz c = tca.getAnnotation(); - LOG.info("\t\t>> retrieving clazz attributes (may involve querying KB) for " + c); - List triples = kbSearch.findAttributesOfClazz(c.getId()); - c.setAttributes(triples); - if (!distinctTypes.contains(c)) - distinctTypes.add(c); - } - - tableAnnotation.setHeaderAnnotation(col, candidates.toArray(new TColumnHeaderAnnotation[candidates.size()])); - - //go thru every entity-concept pair, compute their scores - LOG.info("\t\t>> compute entity-clazz semantic similarity (Ent:" + distinctEntities.size() + " Clz:" + distinctTypes.size() + ")"); - Map simScores = - simComputer.computeSemanticSimilarity(threads, distinctEntities, distinctTypes, true); - for (Entity entity : distinctEntities) { - for (Clazz concept : distinctTypes) { - Double sim = simScores.get(entity.getId() + "," + concept.getId()); - assert sim != null; - tableAnnotation.setScoreEntityAndConceptSimilarity(entity.getId(), concept.getId(), sim); - } - } - - //then update scores for every entity-concept pair where the entity votes for the concept - LOG.info("\t\t>> compute entity-clazz affinity scores, can involve querying KB for computing clazz specificity (Ent:" + distinctEntities.size() + ")"); - int cc = 0; - for (Map.Entry> entry : entityId_and_clazzURLs.entrySet()) { - String entityId = entry.getKey(); - Set conceptIds = entry.getValue(); - for (String conceptId : conceptIds) { - double specificity = clazzSpecificityCalculator.compute(conceptId); - double simScore = tableAnnotation.getScoreEntityAndConceptSimilarity(entityId, conceptId); - tableAnnotation.setScoreEntityAndConceptSimilarity( - entityId, conceptId, simScore + 1.0 + specificity); - } - cc++; - if(cc%10==0) - LOG.debug("\t\t>> compute entity-clazz affinity scores, "+cc+"/"+distinctEntities.size()+" complete"); - } - } - - -} +package uk.ac.shef.dcs.sti.core.algorithm.ji; + +import javafx.util.Pair; +import org.apache.log4j.Logger; +import uk.ac.shef.dcs.kbsearch.KBSearch; +import uk.ac.shef.dcs.kbsearch.KBSearchException; +import uk.ac.shef.dcs.kbsearch.model.Attribute; +import uk.ac.shef.dcs.kbsearch.model.Clazz; +import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.algorithm.ji.similarity.EntityAndClazzSimilarityScorer; +import uk.ac.shef.dcs.sti.core.algorithm.ji.similarity.SimilarityComputerManager; +import uk.ac.shef.dcs.sti.core.algorithm.smp.ClazzSpecificityCalculator; +import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; +import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; +import uk.ac.shef.dcs.sti.core.model.Table; + +import java.util.*; + +/** + * + */ +public class CandidateConceptGenerator { + + private static final Logger LOG = Logger.getLogger(CandidateConceptGenerator.class.getName()); + private int threads = 10; + private SimilarityComputerManager simComputer; + private KBSearch kbSearch; + private JIClazzScorer clazzScorer; + private ClazzSpecificityCalculator clazzSpecificityCalculator; + + public CandidateConceptGenerator(KBSearch kbSearch, + JIClazzScorer clazzScorer, + EntityAndClazzSimilarityScorer entityAndConceptScorer, + ClazzSpecificityCalculator clazzSpecificityCalculator, + int threads, + boolean useCache) { + this.kbSearch = kbSearch; + this.clazzScorer = clazzScorer; + this.threads = threads; + this.clazzSpecificityCalculator = clazzSpecificityCalculator; + simComputer = new SimilarityComputerManager(useCache,kbSearch,entityAndConceptScorer); + } + + public void generateInitialColumnAnnotations(TAnnotationJI tableAnnotation, Table table, int col) throws KBSearchException, STIException { + List distinctTypes = new ArrayList<>(); + Map> entityId_and_clazzURLs = new HashMap<>(); + List distinctEntities = new ArrayList<>(); + + List candidates = new ArrayList<>(); + for (int r = 0; r < table.getNumRows(); r++) { + TCellAnnotation[] cellAnnotations = tableAnnotation.getContentCellAnnotations(r, col); + List>> entities = new ArrayList<>(); + for (TCellAnnotation tCellAnnotation : cellAnnotations) { + Entity e = tCellAnnotation.getAnnotation(); + entities.add(new Pair<>(e, tCellAnnotation.getScoreElements())); + if (!distinctEntities.contains(tCellAnnotation.getAnnotation())) + distinctEntities.add(tCellAnnotation.getAnnotation()); + + for (Clazz c : e.getTypes()) { + Set conceptURLs = entityId_and_clazzURLs.get(e.getId()); + if (conceptURLs == null) + conceptURLs = new HashSet<>(); + conceptURLs.add(c.getId()); + entityId_and_clazzURLs.put(e.getId(), conceptURLs); + } + + } + candidates = + clazzScorer.computeElementScores(entities, candidates, table, Collections.singletonList(r), col); + } + + //fetch all concept entities and set attributes + for (TColumnHeaderAnnotation tca : candidates) { + clazzScorer.computeFinal(tca, table.getNumRows()); + Clazz c = tca.getAnnotation(); + LOG.info("\t\t>> retrieving clazz attributes (may involve querying KB) for " + c); + List triples = kbSearch.findAttributesOfClazz(c.getId()); + c.setAttributes(triples); + if (!distinctTypes.contains(c)) + distinctTypes.add(c); + } + + tableAnnotation.setHeaderAnnotation(col, candidates.toArray(new TColumnHeaderAnnotation[candidates.size()])); + + //go thru every entity-concept pair, compute their scores + LOG.info("\t\t>> compute entity-clazz semantic similarity (Ent:" + distinctEntities.size() + " Clz:" + distinctTypes.size() + ")"); + Map simScores = + simComputer.computeSemanticSimilarity(threads, distinctEntities, distinctTypes, true); + for (Entity entity : distinctEntities) { + for (Clazz concept : distinctTypes) { + Double sim = simScores.get(entity.getId() + "," + concept.getId()); + assert sim != null; + tableAnnotation.setScoreEntityAndConceptSimilarity(entity.getId(), concept.getId(), sim); + } + } + + //then update scores for every entity-concept pair where the entity votes for the concept + LOG.info("\t\t>> compute entity-clazz affinity scores, can involve querying KB for computing clazz specificity (Ent:" + distinctEntities.size() + ")"); + int cc = 0; + for (Map.Entry> entry : entityId_and_clazzURLs.entrySet()) { + String entityId = entry.getKey(); + Set conceptIds = entry.getValue(); + for (String conceptId : conceptIds) { + double specificity = clazzSpecificityCalculator.compute(conceptId); + double simScore = tableAnnotation.getScoreEntityAndConceptSimilarity(entityId, conceptId); + tableAnnotation.setScoreEntityAndConceptSimilarity( + entityId, conceptId, simScore + 1.0 + specificity); + } + cc++; + if(cc%10==0) + LOG.debug("\t\t>> compute entity-clazz affinity scores, "+cc+"/"+distinctEntities.size()+" complete"); + } + } + + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateEntityGenerator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateEntityGenerator.java index 166e7afe..7bb10f76 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateEntityGenerator.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateEntityGenerator.java @@ -1,93 +1,93 @@ -package uk.ac.shef.dcs.sti.core.algorithm.ji; - -import javafx.util.Pair; -import org.apache.log4j.Logger; -import uk.ac.shef.dcs.kbsearch.KBSearch; -import uk.ac.shef.dcs.kbsearch.KBSearchException; -import uk.ac.shef.dcs.kbsearch.model.Attribute; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; -import uk.ac.shef.dcs.sti.core.model.TAnnotation; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.util.StringUtils; - -import java.util.*; - -/** - * Created by zqz on 01/05/2015. - */ -public class CandidateEntityGenerator { - private KBSearch kbSearch; - private JIAdaptedEntityScorer disambScorer; - private static final Logger LOG = Logger.getLogger(CandidateEntityGenerator.class.getName()); - - public CandidateEntityGenerator(KBSearch kbSearch, JIAdaptedEntityScorer disambScorer) { - this.kbSearch = kbSearch; - this.disambScorer = disambScorer; - } - - public void generateInitialCellAnnotations( - TAnnotation tableAnnotations, Table table, - int row, int column - ) throws KBSearchException { - List>> scores = scoreEntities(table, row, column); - List> sorted = new ArrayList<>(); - for (Pair> e : scores) { - double score = e.getValue().get(JIAdaptedEntityScorer.SCORE_FINAL); - sorted.add(new Pair<>(e.getKey(), score)); - } - Collections.sort(sorted, (o1, o2) -> o2.getValue().compareTo(o1.getValue())); - - TCell tcc = table.getContentCell(row, column); - String text = StringUtils.toAlphaNumericWhitechar(tcc.getText().trim()).trim(); - if (text.length() > 2) { - TCellAnnotation[] annotations = new TCellAnnotation[scores.size()]; - int i = 0; - for (Pair> oo : scores) { - TCellAnnotation ca = new TCellAnnotation(tcc.getText(), - oo.getKey(), oo.getValue().get(JIAdaptedEntityScorer.SCORE_FINAL), - oo.getValue()); - annotations[i] = ca; - i++; - } - tableAnnotations.setContentCellAnnotations(row, column, annotations); - } - //return sorted; - } - - private List>> scoreEntities(Table table, - int row, int column - ) throws KBSearchException { - TCell cell = table.getContentCell(row, column); - LOG.info("\t\t>> (generating candidate entities, position at (" + row + "," + column + ") " + - cell+")"); - List candidates = kbSearch.findEntityCandidates(cell.getText()); - List nonDuplicates = new ArrayList<>(); - for (Entity ec : candidates) { - if (!nonDuplicates.contains(ec)) - nonDuplicates.add(ec); - } - candidates = nonDuplicates; - - //each candidate will have a map containing multiple elements of scores. See SMPAdaptedEntityScorer - List>> disambiguationScores = - new ArrayList<>(); - for (Entity entity : candidates) { - //find facts of each entity - if (entity.getAttributes() == null || entity.getAttributes().size() == 0) { - List facts = kbSearch.findAttributesOfEntities(entity); - entity.setAttributes(facts); - } - Map scoreMap = disambScorer. - computeElementScores(entity, candidates, - column, row, Collections.singletonList(row), - table); - disambScorer.computeFinal(scoreMap, cell.getText()); - Pair> entry = new Pair<>(entity, scoreMap); - disambiguationScores.add(entry); - } - return disambiguationScores; - } - -} +package uk.ac.shef.dcs.sti.core.algorithm.ji; + +import javafx.util.Pair; +import org.apache.log4j.Logger; +import uk.ac.shef.dcs.kbsearch.KBSearch; +import uk.ac.shef.dcs.kbsearch.KBSearchException; +import uk.ac.shef.dcs.kbsearch.model.Attribute; +import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.sti.core.model.TCell; +import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; +import uk.ac.shef.dcs.sti.core.model.TAnnotation; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.util.StringUtils; + +import java.util.*; + +/** + * Created by zqz on 01/05/2015. + */ +public class CandidateEntityGenerator { + private KBSearch kbSearch; + private JIAdaptedEntityScorer disambScorer; + private static final Logger LOG = Logger.getLogger(CandidateEntityGenerator.class.getName()); + + public CandidateEntityGenerator(KBSearch kbSearch, JIAdaptedEntityScorer disambScorer) { + this.kbSearch = kbSearch; + this.disambScorer = disambScorer; + } + + public void generateInitialCellAnnotations( + TAnnotation tableAnnotations, Table table, + int row, int column + ) throws KBSearchException { + List>> scores = scoreEntities(table, row, column); + List> sorted = new ArrayList<>(); + for (Pair> e : scores) { + double score = e.getValue().get(JIAdaptedEntityScorer.SCORE_FINAL); + sorted.add(new Pair<>(e.getKey(), score)); + } + Collections.sort(sorted, (o1, o2) -> o2.getValue().compareTo(o1.getValue())); + + TCell tcc = table.getContentCell(row, column); + String text = StringUtils.toAlphaNumericWhitechar(tcc.getText().trim()).trim(); + if (text.length() > 2) { + TCellAnnotation[] annotations = new TCellAnnotation[scores.size()]; + int i = 0; + for (Pair> oo : scores) { + TCellAnnotation ca = new TCellAnnotation(tcc.getText(), + oo.getKey(), oo.getValue().get(JIAdaptedEntityScorer.SCORE_FINAL), + oo.getValue()); + annotations[i] = ca; + i++; + } + tableAnnotations.setContentCellAnnotations(row, column, annotations); + } + //return sorted; + } + + private List>> scoreEntities(Table table, + int row, int column + ) throws KBSearchException { + TCell cell = table.getContentCell(row, column); + LOG.info("\t\t>> (generating candidate entities, position at (" + row + "," + column + ") " + + cell+")"); + List candidates = kbSearch.findEntityCandidates(cell.getText()); + List nonDuplicates = new ArrayList<>(); + for (Entity ec : candidates) { + if (!nonDuplicates.contains(ec)) + nonDuplicates.add(ec); + } + candidates = nonDuplicates; + + //each candidate will have a map containing multiple elements of scores. See SMPAdaptedEntityScorer + List>> disambiguationScores = + new ArrayList<>(); + for (Entity entity : candidates) { + //find facts of each entity + if (entity.getAttributes() == null || entity.getAttributes().size() == 0) { + List facts = kbSearch.findAttributesOfEntities(entity); + entity.setAttributes(facts); + } + Map scoreMap = disambScorer. + computeElementScores(entity, candidates, + column, row, Collections.singletonList(row), + table); + disambScorer.computeFinal(scoreMap, cell.getText()); + Pair> entry = new Pair<>(entity, scoreMap); + disambiguationScores.add(entry); + } + return disambiguationScores; + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateRelationGenerator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateRelationGenerator.java index 4e639922..96893cf2 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateRelationGenerator.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/CandidateRelationGenerator.java @@ -1,287 +1,287 @@ -package uk.ac.shef.dcs.sti.core.algorithm.ji; - -import org.apache.log4j.Logger; -import uk.ac.shef.dcs.kbsearch.KBSearch; -import uk.ac.shef.dcs.kbsearch.KBSearchException; -import uk.ac.shef.dcs.kbsearch.model.Attribute; -import uk.ac.shef.dcs.kbsearch.model.Clazz; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.kbsearch.model.Resource; -import uk.ac.shef.dcs.sti.util.DataTypeClassifier; -import uk.ac.shef.dcs.sti.core.model.*; - -import java.io.IOException; -import java.util.*; -import java.util.List; - -/** - * Created by zqz on 01/05/2015. - */ -public class CandidateRelationGenerator { - private boolean includeCellCellRelations = true; - private JIAdaptedAttributeMatcher matcher; - private KBSearch kbSearch; - - private static final Logger LOG = Logger.getLogger(CandidateRelationGenerator.class.getName()); - - public CandidateRelationGenerator(JIAdaptedAttributeMatcher matcher, - KBSearch kbSearch, - boolean includeCellCellRelations) { - this.matcher = matcher; - this.kbSearch = kbSearch; - this.includeCellCellRelations = includeCellCellRelations; - } - - public void generateInitialColumnColumnRelations(TAnnotationJI tableAnnotations, - Table table, boolean useSubjectColumn, - Collection ignoreColumns) throws IOException, KBSearchException { - //RelationDataStructure result = new RelationDataStructure(); - - //mainColumnIndexes contains indexes of columns that are possible NEs - Map colTypes - = new HashMap<>(); - for (int c = 0; c < table.getNumCols(); c++) { - DataTypeClassifier.DataType type = - table.getColumnHeader(c).getTypes().get(0).getType(); - colTypes.put(c, type); - } - - //candidate relations between any pairs of columns - List subjectColumnsToConsider = new ArrayList<>(); - if (useSubjectColumn) - subjectColumnsToConsider.add(tableAnnotations.getSubjectColumn()); - else { - for (int c = 0; c < table.getNumCols(); c++) { - if (!ignoreColumns.contains(c)) - subjectColumnsToConsider.add(c); - } - } - - if (includeCellCellRelations) { - LOG.info("\t\t>> relations derived from rows"); - addRelationsFromRowEvidence(table, tableAnnotations, subjectColumnsToConsider, ignoreColumns, colTypes); - } - - //using pairs of column headers to compute candidate relations between columns, update tableannotation object - LOG.info("\t\t>> relations derived from column clazz annotations"); - addRelationsFromColumnClazzAnnotations(table, - tableAnnotations, - colTypes, kbSearch, subjectColumnsToConsider, ignoreColumns); - - - LOG.info("\t\t>> update entity-relation affinity scores"); - //further, update entity-relation scores, to account for 1:n relations - updateEntityRelationAffinityScores(table,tableAnnotations,subjectColumnsToConsider,ignoreColumns); - } - - - //relation candidates can come from rows - private void addRelationsFromRowEvidence( - Table table, - TAnnotationJI tableAnnotations, - List subjectColumnsToConsider, - Collection ignoreColumns, - Map colTypes - ) throws IOException { - for (int subjectColumn : subjectColumnsToConsider) { //choose a column to be subject column (must be NE column) - if (!table.getColumnHeader(subjectColumn).getFeature().getMostFrequentDataType().getType().equals(DataTypeClassifier.DataType.NAMED_ENTITY)) - continue; - - for (int objectColumn = 0; objectColumn < table.getNumCols(); objectColumn++) { //choose a column to be object column (any data type) - if (subjectColumn == objectColumn || ignoreColumns.contains(objectColumn)) - continue; - DataTypeClassifier.DataType columnDataType = table.getColumnHeader(objectColumn).getFeature().getMostFrequentDataType().getType(); - if (!columnDataType.equals(DataTypeClassifier.DataType.NAMED_ENTITY)) - continue; - for (int r = 0; r < table.getNumRows(); r++) { - //in JI, all candidate NEs (the disambiguated NE) is needed from each cell to aggregate candidate relation - TCellAnnotation[] subjectCells = tableAnnotations.getContentCellAnnotations(r, subjectColumn); - TCellAnnotation[] objectCells = tableAnnotations.getContentCellAnnotations(r, objectColumn); - //matches obj of facts of subject entities against object cell text and candidate entity labels. - //also create evidence for entity-relation, concept-relation - List matchResults = matcher.matchCellAnnotations( - Arrays.asList(subjectCells), - Arrays.asList(objectCells), - colTypes.get(objectColumn)); - for (JIAdaptedAttributeMatcher.MatchResult mr : matchResults) { - createCandidateAnnotation(tableAnnotations, - r, subjectColumn, objectColumn, - mr.attribute, mr.score, mr.subjectAnnotation, mr.objectAnnotations); - } - } - } - } - - //create columncolumnhrelation objects - for (Map.Entry>> e : - tableAnnotations.getCellcellRelations().entrySet()) { - - //simply create dummy header relation annotations - RelationColumns relationColumns = e.getKey(); //key indicating the directional relationship (subject col, object col) - - Set candidateRelationURLs = new HashSet<>(); - Map> relation_on_rows = e.getValue(); - for (Map.Entry> entry : - relation_on_rows.entrySet()) { - for (TCellCellRelationAnotation cbr : entry.getValue()) { - candidateRelationURLs.add(cbr.getRelationURI()); - } - } - - for (String url : candidateRelationURLs) { - tableAnnotations.addColumnColumnRelation( - new TColumnColumnRelationAnnotation(relationColumns, url, - url, 0.0) - ); - } - } - } - - - private void createCandidateAnnotation(TAnnotationJI tableAnnotation, - int row, int subjectColumn, int objectColumn, - Attribute attribute, - double score, - Resource sbjEntity, - List matchedObjCellCandidates) { - tableAnnotation.addCellCellRelation(new TCellCellRelationAnotation( - new RelationColumns(subjectColumn, objectColumn), row, attribute.getRelationURI(), attribute.getRelationURI(), - new ArrayList<>(), score - )); - //subject entity, its concepts and relation - populateEntityPairAndRelationScore(tableAnnotation, sbjEntity.getId(), - attribute.getRelationURI(), matchedObjCellCandidates, subjectColumn, objectColumn); - populateClazzPairAndRelationScoreFromRows(tableAnnotation, sbjEntity, - row, - attribute.getRelationURI(), matchedObjCellCandidates, subjectColumn, objectColumn, score); - } - - private void populateEntityPairAndRelationScore(TAnnotationJI tableAnnotation, - String entityId, String relationURL, List objEntities, - int relationFrom, int relationTo - ) { - for (Resource obj : objEntities) { - tableAnnotation.setScoreEntityPairAndRelation(entityId, - obj.getId(), - TColumnColumnRelationAnnotation.toStringExpanded( - relationFrom, relationTo, relationURL), 1.0); - } - } - - private void populateClazzPairAndRelationScoreFromRows(TAnnotationJI tableAnnotation, - Resource sbjEntity, - int entityRow, - String relationURL, - List matchedObjCellCandidates, - int relationFrom, int relationTo, - double maxScore) { - //todo: false relation added to highly general types (person, religious_leader_title), maybe use only most specific type of sbj, obj - for (Clazz sbjType : ((Entity) sbjEntity).getTypes()) { - for (Resource obj : matchedObjCellCandidates) { - Entity objEntity = (Entity) obj; - for (Clazz objType : objEntity.getTypes()) { - if (sbjType.getId().equals(objType.getId())) continue; - tableAnnotation.setScoreClazzPairAndRelationFromRows(entityRow, - sbjType.getId(), - TColumnColumnRelationAnnotation.toStringExpanded(relationFrom, relationTo, relationURL), - objType.getId(), - maxScore); - } - } - } - } - - - //relation candidates can come from column clazz annotations - private void addRelationsFromColumnClazzAnnotations(Table table, - TAnnotationJI annotation, - Map colTypes, - KBSearch kbSearch, - Collection subjectColumnsToConsider, - Collection ignoreColumns) throws KBSearchException { - for (int subjectColumn : subjectColumnsToConsider) { //choose a column to be subject column (must be NE column) - if (!table.getColumnHeader(subjectColumn).getFeature().getMostFrequentDataType().getType().equals(DataTypeClassifier.DataType.NAMED_ENTITY)) - continue; - - for (int objectColumn = 0; objectColumn < table.getNumCols(); objectColumn++) { //choose a column to be object column (any data type) - if (subjectColumn == objectColumn || ignoreColumns.contains(objectColumn)) continue; - DataTypeClassifier.DataType columnDataType = table.getColumnHeader(objectColumn).getFeature().getMostFrequentDataType().getType(); - if (!columnDataType.equals(DataTypeClassifier.DataType.NAMED_ENTITY)) continue; - TColumnHeaderAnnotation[] candidates_col1 = annotation.getHeaderAnnotation(subjectColumn); - TColumnHeaderAnnotation[] candidates_col2 = annotation.getHeaderAnnotation(objectColumn); - List matchResults = matcher.matchColumnAnnotations( - Arrays.asList(candidates_col1), - Arrays.asList(candidates_col2), - colTypes.get(objectColumn), - kbSearch); - - for (JIAdaptedAttributeMatcher.MatchResult mr : matchResults) { - createCandidateAnnotation(annotation, - subjectColumn, objectColumn, - mr.attribute, mr.subjectAnnotation, mr.objectAnnotations); - } - } - } - } - - private void createCandidateAnnotation(TAnnotationJI annotation, - int subCol, - int objCol, - Attribute attribute, - Resource subjectClazz, - List objectClazz - ) { - String relation_key = TColumnColumnRelationAnnotation.toStringExpanded(subCol, objCol, attribute.getRelationURI()); - String subClazz = subjectClazz.getId(); - if (objectClazz != null) { - for (Resource oc : objectClazz) { - annotation.setScoreClazzPairAndRelationFromHeaderEvidence(subClazz, relation_key, oc.getId(), 1.0); - } - } - - List candidateRelations = - annotation.getColumncolumnRelations().get( - new RelationColumns(subCol, objCol) - ); - if (candidateRelations == null) candidateRelations = new ArrayList<>(); - boolean contains = false; - for (TColumnColumnRelationAnnotation hbr : candidateRelations) { - if (hbr.getRelationURI().equals(attribute.getRelationURI())) { - contains = true; - break; - } - } - if (!contains) { - annotation.addColumnColumnRelation(new TColumnColumnRelationAnnotation( - new RelationColumns(subCol, objCol), attribute.getRelationURI(), attribute.getRelationURI(), 0.0 - )); - } - } - - private void updateEntityRelationAffinityScores(Table table, TAnnotationJI tableAnnotations, - Collection subjectColumnsToConsider, - Collection ignoreColumns){ - for (int subjectColumn : subjectColumnsToConsider) { //choose a column to be subject column (must be NE column) - if (!table.getColumnHeader(subjectColumn).getFeature().getMostFrequentDataType().getType().equals(DataTypeClassifier.DataType.NAMED_ENTITY)) - continue; - for (int objectColumn = 0; objectColumn < table.getNumCols(); objectColumn++) { //choose a column to be object column (any data type) - if (subjectColumn == objectColumn || ignoreColumns.contains(objectColumn)) continue; - DataTypeClassifier.DataType columnDataType = table.getColumnHeader(objectColumn).getFeature().getMostFrequentDataType().getType(); - if (!columnDataType.equals(DataTypeClassifier.DataType.NAMED_ENTITY)) continue; - for (int r = 0; r < table.getNumRows(); r++) { - //in JI, all candidate NEs (the disambiguated NE) is needed from each cell to aggregate candidate relation - TCellAnnotation[] subjectCells = tableAnnotations.getContentCellAnnotations(r, subjectColumn); - TCellAnnotation[] objectCells = tableAnnotations.getContentCellAnnotations(r, objectColumn); - if (objectCells.length == 0 || subjectCells.length == 0) continue; - //matches obj of facts of subject entities against object cell text and candidate entity labels. - //also create evidence for entity-relation, concept-relation - matcher.matchCellAnnotationAndRelation( - Arrays.asList(subjectCells), - subjectColumn, - objectColumn, - tableAnnotations); - } - } - } - } -} +package uk.ac.shef.dcs.sti.core.algorithm.ji; + +import org.apache.log4j.Logger; +import uk.ac.shef.dcs.kbsearch.KBSearch; +import uk.ac.shef.dcs.kbsearch.KBSearchException; +import uk.ac.shef.dcs.kbsearch.model.Attribute; +import uk.ac.shef.dcs.kbsearch.model.Clazz; +import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.kbsearch.model.Resource; +import uk.ac.shef.dcs.sti.util.DataTypeClassifier; +import uk.ac.shef.dcs.sti.core.model.*; + +import java.io.IOException; +import java.util.*; +import java.util.List; + +/** + * Created by zqz on 01/05/2015. + */ +public class CandidateRelationGenerator { + private boolean includeCellCellRelations = true; + private JIAdaptedAttributeMatcher matcher; + private KBSearch kbSearch; + + private static final Logger LOG = Logger.getLogger(CandidateRelationGenerator.class.getName()); + + public CandidateRelationGenerator(JIAdaptedAttributeMatcher matcher, + KBSearch kbSearch, + boolean includeCellCellRelations) { + this.matcher = matcher; + this.kbSearch = kbSearch; + this.includeCellCellRelations = includeCellCellRelations; + } + + public void generateInitialColumnColumnRelations(TAnnotationJI tableAnnotations, + Table table, boolean useSubjectColumn, + Collection ignoreColumns) throws IOException, KBSearchException { + //RelationDataStructure result = new RelationDataStructure(); + + //mainColumnIndexes contains indexes of columns that are possible NEs + Map colTypes + = new HashMap<>(); + for (int c = 0; c < table.getNumCols(); c++) { + DataTypeClassifier.DataType type = + table.getColumnHeader(c).getTypes().get(0).getType(); + colTypes.put(c, type); + } + + //candidate relations between any pairs of columns + List subjectColumnsToConsider = new ArrayList<>(); + if (useSubjectColumn) + subjectColumnsToConsider.add(tableAnnotations.getSubjectColumn()); + else { + for (int c = 0; c < table.getNumCols(); c++) { + if (!ignoreColumns.contains(c)) + subjectColumnsToConsider.add(c); + } + } + + if (includeCellCellRelations) { + LOG.info("\t\t>> relations derived from rows"); + addRelationsFromRowEvidence(table, tableAnnotations, subjectColumnsToConsider, ignoreColumns, colTypes); + } + + //using pairs of column headers to compute candidate relations between columns, update tableannotation object + LOG.info("\t\t>> relations derived from column clazz annotations"); + addRelationsFromColumnClazzAnnotations(table, + tableAnnotations, + colTypes, kbSearch, subjectColumnsToConsider, ignoreColumns); + + + LOG.info("\t\t>> update entity-relation affinity scores"); + //further, update entity-relation scores, to account for 1:n relations + updateEntityRelationAffinityScores(table,tableAnnotations,subjectColumnsToConsider,ignoreColumns); + } + + + //relation candidates can come from rows + private void addRelationsFromRowEvidence( + Table table, + TAnnotationJI tableAnnotations, + List subjectColumnsToConsider, + Collection ignoreColumns, + Map colTypes + ) throws IOException { + for (int subjectColumn : subjectColumnsToConsider) { //choose a column to be subject column (must be NE column) + if (!table.getColumnHeader(subjectColumn).getFeature().getMostFrequentDataType().getType().equals(DataTypeClassifier.DataType.NAMED_ENTITY)) + continue; + + for (int objectColumn = 0; objectColumn < table.getNumCols(); objectColumn++) { //choose a column to be object column (any data type) + if (subjectColumn == objectColumn || ignoreColumns.contains(objectColumn)) + continue; + DataTypeClassifier.DataType columnDataType = table.getColumnHeader(objectColumn).getFeature().getMostFrequentDataType().getType(); + if (!columnDataType.equals(DataTypeClassifier.DataType.NAMED_ENTITY)) + continue; + for (int r = 0; r < table.getNumRows(); r++) { + //in JI, all candidate NEs (the disambiguated NE) is needed from each cell to aggregate candidate relation + TCellAnnotation[] subjectCells = tableAnnotations.getContentCellAnnotations(r, subjectColumn); + TCellAnnotation[] objectCells = tableAnnotations.getContentCellAnnotations(r, objectColumn); + //matches obj of facts of subject entities against object cell text and candidate entity labels. + //also create evidence for entity-relation, concept-relation + List matchResults = matcher.matchCellAnnotations( + Arrays.asList(subjectCells), + Arrays.asList(objectCells), + colTypes.get(objectColumn)); + for (JIAdaptedAttributeMatcher.MatchResult mr : matchResults) { + createCandidateAnnotation(tableAnnotations, + r, subjectColumn, objectColumn, + mr.attribute, mr.score, mr.subjectAnnotation, mr.objectAnnotations); + } + } + } + } + + //create columncolumnhrelation objects + for (Map.Entry>> e : + tableAnnotations.getCellcellRelations().entrySet()) { + + //simply create dummy header relation annotations + RelationColumns relationColumns = e.getKey(); //key indicating the directional relationship (subject col, object col) + + Set candidateRelationURLs = new HashSet<>(); + Map> relation_on_rows = e.getValue(); + for (Map.Entry> entry : + relation_on_rows.entrySet()) { + for (TCellCellRelationAnotation cbr : entry.getValue()) { + candidateRelationURLs.add(cbr.getRelationURI()); + } + } + + for (String url : candidateRelationURLs) { + tableAnnotations.addColumnColumnRelation( + new TColumnColumnRelationAnnotation(relationColumns, url, + url, 0.0) + ); + } + } + } + + + private void createCandidateAnnotation(TAnnotationJI tableAnnotation, + int row, int subjectColumn, int objectColumn, + Attribute attribute, + double score, + Resource sbjEntity, + List matchedObjCellCandidates) { + tableAnnotation.addCellCellRelation(new TCellCellRelationAnotation( + new RelationColumns(subjectColumn, objectColumn), row, attribute.getRelationURI(), attribute.getRelationURI(), + new ArrayList<>(), score + )); + //subject entity, its concepts and relation + populateEntityPairAndRelationScore(tableAnnotation, sbjEntity.getId(), + attribute.getRelationURI(), matchedObjCellCandidates, subjectColumn, objectColumn); + populateClazzPairAndRelationScoreFromRows(tableAnnotation, sbjEntity, + row, + attribute.getRelationURI(), matchedObjCellCandidates, subjectColumn, objectColumn, score); + } + + private void populateEntityPairAndRelationScore(TAnnotationJI tableAnnotation, + String entityId, String relationURL, List objEntities, + int relationFrom, int relationTo + ) { + for (Resource obj : objEntities) { + tableAnnotation.setScoreEntityPairAndRelation(entityId, + obj.getId(), + TColumnColumnRelationAnnotation.toStringExpanded( + relationFrom, relationTo, relationURL), 1.0); + } + } + + private void populateClazzPairAndRelationScoreFromRows(TAnnotationJI tableAnnotation, + Resource sbjEntity, + int entityRow, + String relationURL, + List matchedObjCellCandidates, + int relationFrom, int relationTo, + double maxScore) { + //todo: false relation added to highly general types (person, religious_leader_title), maybe use only most specific type of sbj, obj + for (Clazz sbjType : ((Entity) sbjEntity).getTypes()) { + for (Resource obj : matchedObjCellCandidates) { + Entity objEntity = (Entity) obj; + for (Clazz objType : objEntity.getTypes()) { + if (sbjType.getId().equals(objType.getId())) continue; + tableAnnotation.setScoreClazzPairAndRelationFromRows(entityRow, + sbjType.getId(), + TColumnColumnRelationAnnotation.toStringExpanded(relationFrom, relationTo, relationURL), + objType.getId(), + maxScore); + } + } + } + } + + + //relation candidates can come from column clazz annotations + private void addRelationsFromColumnClazzAnnotations(Table table, + TAnnotationJI annotation, + Map colTypes, + KBSearch kbSearch, + Collection subjectColumnsToConsider, + Collection ignoreColumns) throws KBSearchException { + for (int subjectColumn : subjectColumnsToConsider) { //choose a column to be subject column (must be NE column) + if (!table.getColumnHeader(subjectColumn).getFeature().getMostFrequentDataType().getType().equals(DataTypeClassifier.DataType.NAMED_ENTITY)) + continue; + + for (int objectColumn = 0; objectColumn < table.getNumCols(); objectColumn++) { //choose a column to be object column (any data type) + if (subjectColumn == objectColumn || ignoreColumns.contains(objectColumn)) continue; + DataTypeClassifier.DataType columnDataType = table.getColumnHeader(objectColumn).getFeature().getMostFrequentDataType().getType(); + if (!columnDataType.equals(DataTypeClassifier.DataType.NAMED_ENTITY)) continue; + TColumnHeaderAnnotation[] candidates_col1 = annotation.getHeaderAnnotation(subjectColumn); + TColumnHeaderAnnotation[] candidates_col2 = annotation.getHeaderAnnotation(objectColumn); + List matchResults = matcher.matchColumnAnnotations( + Arrays.asList(candidates_col1), + Arrays.asList(candidates_col2), + colTypes.get(objectColumn), + kbSearch); + + for (JIAdaptedAttributeMatcher.MatchResult mr : matchResults) { + createCandidateAnnotation(annotation, + subjectColumn, objectColumn, + mr.attribute, mr.subjectAnnotation, mr.objectAnnotations); + } + } + } + } + + private void createCandidateAnnotation(TAnnotationJI annotation, + int subCol, + int objCol, + Attribute attribute, + Resource subjectClazz, + List objectClazz + ) { + String relation_key = TColumnColumnRelationAnnotation.toStringExpanded(subCol, objCol, attribute.getRelationURI()); + String subClazz = subjectClazz.getId(); + if (objectClazz != null) { + for (Resource oc : objectClazz) { + annotation.setScoreClazzPairAndRelationFromHeaderEvidence(subClazz, relation_key, oc.getId(), 1.0); + } + } + + List candidateRelations = + annotation.getColumncolumnRelations().get( + new RelationColumns(subCol, objCol) + ); + if (candidateRelations == null) candidateRelations = new ArrayList<>(); + boolean contains = false; + for (TColumnColumnRelationAnnotation hbr : candidateRelations) { + if (hbr.getRelationURI().equals(attribute.getRelationURI())) { + contains = true; + break; + } + } + if (!contains) { + annotation.addColumnColumnRelation(new TColumnColumnRelationAnnotation( + new RelationColumns(subCol, objCol), attribute.getRelationURI(), attribute.getRelationURI(), 0.0 + )); + } + } + + private void updateEntityRelationAffinityScores(Table table, TAnnotationJI tableAnnotations, + Collection subjectColumnsToConsider, + Collection ignoreColumns){ + for (int subjectColumn : subjectColumnsToConsider) { //choose a column to be subject column (must be NE column) + if (!table.getColumnHeader(subjectColumn).getFeature().getMostFrequentDataType().getType().equals(DataTypeClassifier.DataType.NAMED_ENTITY)) + continue; + for (int objectColumn = 0; objectColumn < table.getNumCols(); objectColumn++) { //choose a column to be object column (any data type) + if (subjectColumn == objectColumn || ignoreColumns.contains(objectColumn)) continue; + DataTypeClassifier.DataType columnDataType = table.getColumnHeader(objectColumn).getFeature().getMostFrequentDataType().getType(); + if (!columnDataType.equals(DataTypeClassifier.DataType.NAMED_ENTITY)) continue; + for (int r = 0; r < table.getNumRows(); r++) { + //in JI, all candidate NEs (the disambiguated NE) is needed from each cell to aggregate candidate relation + TCellAnnotation[] subjectCells = tableAnnotations.getContentCellAnnotations(r, subjectColumn); + TCellAnnotation[] objectCells = tableAnnotations.getContentCellAnnotations(r, objectColumn); + if (objectCells.length == 0 || subjectCells.length == 0) continue; + //matches obj of facts of subject entities against object cell text and candidate entity labels. + //also create evidence for entity-relation, concept-relation + matcher.matchCellAnnotationAndRelation( + Arrays.asList(subjectCells), + subjectColumn, + objectColumn, + tableAnnotations); + } + } + } + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/DebuggingUtil.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/DebuggingUtil.java index 44caba41..e007af97 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/DebuggingUtil.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/DebuggingUtil.java @@ -1,149 +1,149 @@ -package uk.ac.shef.dcs.sti.core.algorithm.ji; - -import cc.mallet.grmm.types.*; -import uk.ac.shef.dcs.sti.core.model.TAnnotation; -import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; - -import java.io.FileNotFoundException; -import java.io.PrintWriter; -import java.util.*; - -/** - * Created by zqz on 14/05/2015. - */ -public class DebuggingUtil { - - public static void debugFactorAndAffinity(Factor f, Map affinity, String tableId) { - Set factorValues = new HashSet(); - AssignmentIterator it = f.assignmentIterator(); - while (it.hasNext()) { - Assignment assignment = it.assignment(); - //assignment.numVariables(); - String[] splits = assignment.dumpToString().trim().split("[\r\n]"); - String indexString = splits[splits.length - 1].trim(); - String[] indexes = indexString.split("\\s+"); - - double score = f.value(assignment); - if (score > 0) { - String line = ""; - for (int v = 0; v < assignment.numVariables(); v++) { - Variable var = assignment.getVariable(v); - //System.out.print(indexes[v]+","); - int idx = 0; - try { - idx = Integer.valueOf(indexes[v]); - } catch (NumberFormatException e) { - System.err.println(assignment.dumpToString() + ">>>>" + indexes[v]); - System.exit(1); - } - //String label = var.getLabelAlphabet().lookupLabel(idx).toString(); - line = line + idx + " "; - } - factorValues.add(line.trim()); - } - it.next(); - } - Set affinityValues = new HashSet(); - for (String k : affinity.keySet()) { - affinityValues.add(k.replaceAll("[^0-9]", " ").trim()); - } - - List factorValuesCopy = new ArrayList(factorValues); - List affinityValuesCopy = new ArrayList(affinityValues); - factorValuesCopy.removeAll(affinityValues); - affinityValuesCopy.removeAll(factorValues); - - Collections.sort(factorValuesCopy); - Collections.sort(affinityValuesCopy); - if (factorValuesCopy.size() != 0) { - //System.err.println(tableId+"-"+f.toString() + " factorValuesRemain:" + factorValuesCopy); - } - if (affinityValuesCopy.size() != 0) { - System.err.println(tableId + "-" + f.toString() + " affinityValuesRemain:" + affinityValuesCopy); - } - } - - protected static Object[] debugAnnotations(TAnnotation annotation){ - Object[] res = new Object[3]; - Map countHeader = new HashMap<>(); - Map countCell = new HashMap<>(); - - for(int col=0; col> variableNonzerooutcome_collectedFromFactor = new HashMap>(); - Iterator it = graph.factorsIterator(); - while (it.hasNext()) { - Factor f = (Factor) it.next(); - AssignmentIterator ait = f.assignmentIterator(); - while (ait.hasNext()) { - Assignment assignment = ait.assignment(); - //assignment.numVariables(); - String[] splits = assignment.dumpToString().trim().split("[\r\n]"); - String indexString = splits[splits.length - 1].trim(); - String[] indexes = indexString.split("\\s+"); - - double score = f.value(assignment); - if (score > 0) { - for (int v = 0; v < assignment.numVariables(); v++) { - Variable var = assignment.getVariable(v); - - int idx = 0; - try { - idx = Integer.valueOf(indexes[v]); - } catch (NumberFormatException e) { - System.err.println(assignment.dumpToString() + ">>>>" + indexes[v]); - System.exit(1); - } - String label = var.getLabelAlphabet().lookupLabel(idx).toString(); - - Set nonzerooutcomes = variableNonzerooutcome_collectedFromFactor.get(var); - if (nonzerooutcomes == null) - nonzerooutcomes = new HashSet<>(); - nonzerooutcomes.add(idx); - variableNonzerooutcome_collectedFromFactor.put(var, nonzerooutcomes); - } - - } - - ait.next(); - } - } - - //compare - for (int i = 0; i < graph.numVariables(); i++) { - Variable v = graph.get(i); - Set allOutcomesOfVariable = new HashSet(); - for (int j = 0; j < v.getNumOutcomes(); j++) - allOutcomesOfVariable.add(j); - - Set nonzerooutcomes = variableNonzerooutcome_collectedFromFactor.get(v); - allOutcomesOfVariable.removeAll(nonzerooutcomes); - if (allOutcomesOfVariable.size() > 0) { - List missing = new ArrayList<>(allOutcomesOfVariable); - Collections.sort(missing); - - for (int m : missing) { - System.err.println("MISSING:" + v.getLabel() + "\t" + v.getLabelAlphabet().lookupLabel(m) + " in " + tableId); - } - } - } - - } -} +package uk.ac.shef.dcs.sti.core.algorithm.ji; + +import cc.mallet.grmm.types.*; +import uk.ac.shef.dcs.sti.core.model.TAnnotation; +import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; + +import java.io.FileNotFoundException; +import java.io.PrintWriter; +import java.util.*; + +/** + * Created by zqz on 14/05/2015. + */ +public class DebuggingUtil { + + public static void debugFactorAndAffinity(Factor f, Map affinity, String tableId) { + Set factorValues = new HashSet(); + AssignmentIterator it = f.assignmentIterator(); + while (it.hasNext()) { + Assignment assignment = it.assignment(); + //assignment.numVariables(); + String[] splits = assignment.dumpToString().trim().split("[\r\n]"); + String indexString = splits[splits.length - 1].trim(); + String[] indexes = indexString.split("\\s+"); + + double score = f.value(assignment); + if (score > 0) { + String line = ""; + for (int v = 0; v < assignment.numVariables(); v++) { + Variable var = assignment.getVariable(v); + //System.out.print(indexes[v]+","); + int idx = 0; + try { + idx = Integer.valueOf(indexes[v]); + } catch (NumberFormatException e) { + System.err.println(assignment.dumpToString() + ">>>>" + indexes[v]); + System.exit(1); + } + //String label = var.getLabelAlphabet().lookupLabel(idx).toString(); + line = line + idx + " "; + } + factorValues.add(line.trim()); + } + it.next(); + } + Set affinityValues = new HashSet(); + for (String k : affinity.keySet()) { + affinityValues.add(k.replaceAll("[^0-9]", " ").trim()); + } + + List factorValuesCopy = new ArrayList(factorValues); + List affinityValuesCopy = new ArrayList(affinityValues); + factorValuesCopy.removeAll(affinityValues); + affinityValuesCopy.removeAll(factorValues); + + Collections.sort(factorValuesCopy); + Collections.sort(affinityValuesCopy); + if (factorValuesCopy.size() != 0) { + //System.err.println(tableId+"-"+f.toString() + " factorValuesRemain:" + factorValuesCopy); + } + if (affinityValuesCopy.size() != 0) { + System.err.println(tableId + "-" + f.toString() + " affinityValuesRemain:" + affinityValuesCopy); + } + } + + protected static Object[] debugAnnotations(TAnnotation annotation){ + Object[] res = new Object[3]; + Map countHeader = new HashMap<>(); + Map countCell = new HashMap<>(); + + for(int col=0; col> variableNonzerooutcome_collectedFromFactor = new HashMap>(); + Iterator it = graph.factorsIterator(); + while (it.hasNext()) { + Factor f = (Factor) it.next(); + AssignmentIterator ait = f.assignmentIterator(); + while (ait.hasNext()) { + Assignment assignment = ait.assignment(); + //assignment.numVariables(); + String[] splits = assignment.dumpToString().trim().split("[\r\n]"); + String indexString = splits[splits.length - 1].trim(); + String[] indexes = indexString.split("\\s+"); + + double score = f.value(assignment); + if (score > 0) { + for (int v = 0; v < assignment.numVariables(); v++) { + Variable var = assignment.getVariable(v); + + int idx = 0; + try { + idx = Integer.valueOf(indexes[v]); + } catch (NumberFormatException e) { + System.err.println(assignment.dumpToString() + ">>>>" + indexes[v]); + System.exit(1); + } + String label = var.getLabelAlphabet().lookupLabel(idx).toString(); + + Set nonzerooutcomes = variableNonzerooutcome_collectedFromFactor.get(var); + if (nonzerooutcomes == null) + nonzerooutcomes = new HashSet<>(); + nonzerooutcomes.add(idx); + variableNonzerooutcome_collectedFromFactor.put(var, nonzerooutcomes); + } + + } + + ait.next(); + } + } + + //compare + for (int i = 0; i < graph.numVariables(); i++) { + Variable v = graph.get(i); + Set allOutcomesOfVariable = new HashSet(); + for (int j = 0; j < v.getNumOutcomes(); j++) + allOutcomesOfVariable.add(j); + + Set nonzerooutcomes = variableNonzerooutcome_collectedFromFactor.get(v); + allOutcomesOfVariable.removeAll(nonzerooutcomes); + if (allOutcomesOfVariable.size() > 0) { + List missing = new ArrayList<>(allOutcomesOfVariable); + Collections.sort(missing); + + for (int m : missing) { + System.err.println("MISSING:" + v.getLabel() + "\t" + v.getLabelAlphabet().lookupLabel(m) + " in " + tableId); + } + } + } + + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedAttributeMatcher.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedAttributeMatcher.java index b7f1e52e..2e43a19c 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedAttributeMatcher.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedAttributeMatcher.java @@ -1,215 +1,215 @@ -package uk.ac.shef.dcs.sti.core.algorithm.ji; - -import org.simmetrics.Metric; -import org.simmetrics.StringMetric; -import uk.ac.shef.dcs.kbsearch.KBSearchException; -import uk.ac.shef.dcs.kbsearch.model.Attribute; -import uk.ac.shef.dcs.kbsearch.KBSearch; -import uk.ac.shef.dcs.kbsearch.model.Resource; -import uk.ac.shef.dcs.sti.core.scorer.AttributeValueMatcher; -import uk.ac.shef.dcs.sti.util.DataTypeClassifier; -import uk.ac.shef.dcs.sti.core.model.*; -import java.util.*; -import java.util.List; - -/** - * Created by zqz on 05/05/2015. - */ -public class JIAdaptedAttributeMatcher extends AttributeValueMatcher { - - public JIAdaptedAttributeMatcher(double minScoreThreshold, List stopWords, - StringMetric stringMetric) { - super(minScoreThreshold, stopWords, stringMetric); - } - - class MatchResult { - public Resource subjectAnnotation; - public List objectAnnotations; - public double score; - public Attribute attribute; - - public MatchResult(Resource subjectAnnotation, - List objectAnnotations, - double score, - Attribute attribute) { - this.subjectAnnotation = subjectAnnotation; - this.objectAnnotations = objectAnnotations; - this.score = score; - this.attribute = attribute; - } - } - - protected List matchCellAnnotations( - List subjectCellAnnotations, - List objectCellAnnotations, - DataTypeClassifier.DataType objectColumnDatatype - ) { - List output = new ArrayList<>(); - - List objectCellEntities = new ArrayList<>(); - for (TCellAnnotation c : objectCellAnnotations) - objectCellEntities.add(c.getAnnotation()); - - if (subjectCellAnnotations.size() != 0 && objectCellAnnotations.size() != 0) { - for (int s = 0; s < subjectCellAnnotations.size(); s++) { //for each candidate subject entity - TCellAnnotation sbjEntity = subjectCellAnnotations.get(s); - List sbjAttributes = sbjEntity.getAnnotation().getAttributes(); //get the facts of that sbj ent - Map sbjAttrValueDatatypes = classifyAttributeValueDataType( - sbjAttributes - ); - - final Map sbjAttrIndex_matchedScores = new HashMap<>(); - //key - index of fact; value- list of candidate entity from the obj cell matched the fact, or null if no candidate entities - Map> sbjAttrIndex_matchedObjCellCandidates = - matchSubjectAttributes(objectColumnDatatype, objectCellEntities, - sbjAttributes, sbjAttrValueDatatypes, sbjAttrIndex_matchedScores); - - - if (sbjAttrIndex_matchedScores.size() == 0) continue; - //go thru all scores and make selection within each subjectEntity-objectEntity pair - - List qualified = new ArrayList<>(sbjAttrIndex_matchedScores.keySet()); - Collections.sort(qualified, (o1, o2) - -> sbjAttrIndex_matchedScores.get(o2).compareTo(sbjAttrIndex_matchedScores.get(o1))); - Double highestScore = sbjAttrIndex_matchedScores.get(qualified.get(0)); - for (Map.Entry e : sbjAttrIndex_matchedScores.entrySet()) { - int index = e.getKey(); - Double score = e.getValue(); - List objects = sbjAttrIndex_matchedObjCellCandidates.get(index); - if (score.equals(highestScore) && objects != null && objects.size() > 0) { - List objEntities = new ArrayList<>(); - for (Resource r : objects) - objEntities.add(r); - Attribute attribute = sbjAttributes.get(index); - output.add(new MatchResult(sbjEntity.getAnnotation(), objEntities, score, attribute)); - - } - } - }// each subjectNE-objectNE pair - }//each subjectNE - return output; - }//if block checking whether the potential subject-object cell pairs are valid - - - protected List matchColumnAnnotations(List subjectColumnClazz, - List objectColumnAnnotations, - DataTypeClassifier.DataType objectColumnDataType, - KBSearch kbSearch) throws KBSearchException { - List output = new ArrayList<>(); - List objectColumnClazz = new ArrayList<>(); - for (TColumnHeaderAnnotation c : objectColumnAnnotations) - objectColumnClazz.add(c.getAnnotation()); - - if (subjectColumnClazz.size() > 0 && objectColumnAnnotations.size() > 0) { - for (int s = 0; s < subjectColumnClazz.size(); s++) { - TColumnHeaderAnnotation sbjColumnAnnotation = subjectColumnClazz.get(s); - List sbjClazzAttributes = kbSearch.findAttributesOfClazz(sbjColumnAnnotation.getAnnotation().getId()); - Map sbjClazzAttrValueDataTypes = classifyAttributeValueDataType( - sbjClazzAttributes - ); - final Map attrIdx_matchedScores = new HashMap<>(); - final Map> - attrIdx_matchedObjClazz = - matchSubjectAttributes( - objectColumnDataType, objectColumnClazz, - sbjClazzAttributes, sbjClazzAttrValueDataTypes, attrIdx_matchedScores); - - - if (attrIdx_matchedScores.size() == 0) continue; - //go thru all scores and make selection within each subjectEntity-objectEntity pair - List qualified = new ArrayList<>(attrIdx_matchedScores.keySet()); - Collections.sort(qualified, (o1, o2) -> attrIdx_matchedScores.get(o2).compareTo(attrIdx_matchedScores.get(o1))); - Double highestScore = attrIdx_matchedScores.get(qualified.get(0)); - for (Map.Entry e : attrIdx_matchedScores.entrySet()) { - int index = e.getKey(); - Double score = e.getValue(); - if (score.equals(highestScore)) { - Attribute attribute = sbjClazzAttributes.get(index); - output.add(new MatchResult(sbjColumnAnnotation.getAnnotation(), attrIdx_matchedObjClazz.get(index), score, attribute)); - } - } - }//each subjectNE - }//if block checking whether the potential subject-object cell pairs are valid - return output; - } - - - private Map> matchSubjectAttributes( - DataTypeClassifier.DataType objectColumnDataType, - List objectCandidates, - List sbjCandidateAttributes, - Map sbjAttrValueDataTypes, - Map attrIdx_matchedScores - ) { - Map> - attrIdx_matchedObjCandidates = new HashMap<>(); - //scoring matches for the cell on the row - for (int index = 0; index < sbjCandidateAttributes.size(); index++) { - DataTypeClassifier.DataType type_of_attr_value = sbjAttrValueDataTypes.get(index); - Attribute attr = sbjCandidateAttributes.get(index); - if (!isValidType(type_of_attr_value)) { - continue; - } - //use only the fact's obj (text) to compare against the header's text - double maxScore = 0.0; - Map> mchScore_objCandidates = new HashMap<>(); - for (int o = 0; o < objectCandidates.size(); o++) { - uk.ac.shef.dcs.kbsearch.model.Resource r = objectCandidates.get(o); - String objCandidateURL = r.getId(); - String objCandidateLabel = r.getLabel(); - - if (objCandidateURL != null) { - double finalScore = - score(objCandidateLabel, objectColumnDataType, attr.getValue(), type_of_attr_value, stopWords); - if (attr.getValueURI() != null) { - double score = objCandidateURL.equals(attr.getValueURI()) ? 1.0 : 0.0; - if (score > finalScore) finalScore = score; - } - List candidates = mchScore_objCandidates.get(finalScore); - if (candidates == null) candidates = new ArrayList<>(); - candidates.add(r); - mchScore_objCandidates.put(finalScore, candidates); - if (maxScore < finalScore) { - maxScore = finalScore; - } - } - } - if (maxScore > 0 && maxScore > minScoreThreshold) { - attrIdx_matchedScores.put(index, maxScore); - attrIdx_matchedObjCandidates. - put(index, mchScore_objCandidates.get(maxScore)); - } - } - return attrIdx_matchedObjCandidates; - } - - - //if any cell's candidate annotation votes for a candidate relation emerging from that cell's column as subject column - //create an affinity link from that cell's candidate annotation and that relation annotation - protected void matchCellAnnotationAndRelation( - List subjectCellAnnotations, - int subjectColumn, int objectColumn, - TAnnotationJI tableAnnotations) { - if (subjectCellAnnotations.size() > 0) { - RelationColumns relationColumns = new RelationColumns(subjectColumn, objectColumn); - List candidateRelations = - tableAnnotations.getColumncolumnRelations().get(relationColumns); - if (candidateRelations != null && candidateRelations.size() > 0) { - for (int s = 0; s < subjectCellAnnotations.size(); s++) { //for each candidate subject entity - TCellAnnotation sbjEntity = subjectCellAnnotations.get(s); - List sbjEntityAttr = sbjEntity.getAnnotation().getAttributes(); //get the facts of that sbj ent - - for (Attribute f : sbjEntityAttr) { - for (TColumnColumnRelationAnnotation hbr : candidateRelations) { - if (f.getRelationURI().equals(hbr.getRelationURI())) { - tableAnnotations.setScoreEntityAndRelation(sbjEntity.getAnnotation().getId(), - TColumnColumnRelationAnnotation.toStringExpanded(relationColumns.getSubjectCol(), relationColumns.getObjectCol(), f.getRelationURI()), 1.0); - break; - } - } - } - } - }// each subjectNE-objectNE pair - }//each subjectNE - }//if block checking whether the potential subject-object cell pairs are valid -} +package uk.ac.shef.dcs.sti.core.algorithm.ji; + +import org.simmetrics.Metric; +import org.simmetrics.StringMetric; +import uk.ac.shef.dcs.kbsearch.KBSearchException; +import uk.ac.shef.dcs.kbsearch.model.Attribute; +import uk.ac.shef.dcs.kbsearch.KBSearch; +import uk.ac.shef.dcs.kbsearch.model.Resource; +import uk.ac.shef.dcs.sti.core.scorer.AttributeValueMatcher; +import uk.ac.shef.dcs.sti.util.DataTypeClassifier; +import uk.ac.shef.dcs.sti.core.model.*; +import java.util.*; +import java.util.List; + +/** + * Created by zqz on 05/05/2015. + */ +public class JIAdaptedAttributeMatcher extends AttributeValueMatcher { + + public JIAdaptedAttributeMatcher(double minScoreThreshold, List stopWords, + StringMetric stringMetric) { + super(minScoreThreshold, stopWords, stringMetric); + } + + class MatchResult { + public Resource subjectAnnotation; + public List objectAnnotations; + public double score; + public Attribute attribute; + + public MatchResult(Resource subjectAnnotation, + List objectAnnotations, + double score, + Attribute attribute) { + this.subjectAnnotation = subjectAnnotation; + this.objectAnnotations = objectAnnotations; + this.score = score; + this.attribute = attribute; + } + } + + protected List matchCellAnnotations( + List subjectCellAnnotations, + List objectCellAnnotations, + DataTypeClassifier.DataType objectColumnDatatype + ) { + List output = new ArrayList<>(); + + List objectCellEntities = new ArrayList<>(); + for (TCellAnnotation c : objectCellAnnotations) + objectCellEntities.add(c.getAnnotation()); + + if (subjectCellAnnotations.size() != 0 && objectCellAnnotations.size() != 0) { + for (int s = 0; s < subjectCellAnnotations.size(); s++) { //for each candidate subject entity + TCellAnnotation sbjEntity = subjectCellAnnotations.get(s); + List sbjAttributes = sbjEntity.getAnnotation().getAttributes(); //get the facts of that sbj ent + Map sbjAttrValueDatatypes = classifyAttributeValueDataType( + sbjAttributes + ); + + final Map sbjAttrIndex_matchedScores = new HashMap<>(); + //key - index of fact; value- list of candidate entity from the obj cell matched the fact, or null if no candidate entities + Map> sbjAttrIndex_matchedObjCellCandidates = + matchSubjectAttributes(objectColumnDatatype, objectCellEntities, + sbjAttributes, sbjAttrValueDatatypes, sbjAttrIndex_matchedScores); + + + if (sbjAttrIndex_matchedScores.size() == 0) continue; + //go thru all scores and make selection within each subjectEntity-objectEntity pair + + List qualified = new ArrayList<>(sbjAttrIndex_matchedScores.keySet()); + Collections.sort(qualified, (o1, o2) + -> sbjAttrIndex_matchedScores.get(o2).compareTo(sbjAttrIndex_matchedScores.get(o1))); + Double highestScore = sbjAttrIndex_matchedScores.get(qualified.get(0)); + for (Map.Entry e : sbjAttrIndex_matchedScores.entrySet()) { + int index = e.getKey(); + Double score = e.getValue(); + List objects = sbjAttrIndex_matchedObjCellCandidates.get(index); + if (score.equals(highestScore) && objects != null && objects.size() > 0) { + List objEntities = new ArrayList<>(); + for (Resource r : objects) + objEntities.add(r); + Attribute attribute = sbjAttributes.get(index); + output.add(new MatchResult(sbjEntity.getAnnotation(), objEntities, score, attribute)); + + } + } + }// each subjectNE-objectNE pair + }//each subjectNE + return output; + }//if block checking whether the potential subject-object cell pairs are valid + + + protected List matchColumnAnnotations(List subjectColumnClazz, + List objectColumnAnnotations, + DataTypeClassifier.DataType objectColumnDataType, + KBSearch kbSearch) throws KBSearchException { + List output = new ArrayList<>(); + List objectColumnClazz = new ArrayList<>(); + for (TColumnHeaderAnnotation c : objectColumnAnnotations) + objectColumnClazz.add(c.getAnnotation()); + + if (subjectColumnClazz.size() > 0 && objectColumnAnnotations.size() > 0) { + for (int s = 0; s < subjectColumnClazz.size(); s++) { + TColumnHeaderAnnotation sbjColumnAnnotation = subjectColumnClazz.get(s); + List sbjClazzAttributes = kbSearch.findAttributesOfClazz(sbjColumnAnnotation.getAnnotation().getId()); + Map sbjClazzAttrValueDataTypes = classifyAttributeValueDataType( + sbjClazzAttributes + ); + final Map attrIdx_matchedScores = new HashMap<>(); + final Map> + attrIdx_matchedObjClazz = + matchSubjectAttributes( + objectColumnDataType, objectColumnClazz, + sbjClazzAttributes, sbjClazzAttrValueDataTypes, attrIdx_matchedScores); + + + if (attrIdx_matchedScores.size() == 0) continue; + //go thru all scores and make selection within each subjectEntity-objectEntity pair + List qualified = new ArrayList<>(attrIdx_matchedScores.keySet()); + Collections.sort(qualified, (o1, o2) -> attrIdx_matchedScores.get(o2).compareTo(attrIdx_matchedScores.get(o1))); + Double highestScore = attrIdx_matchedScores.get(qualified.get(0)); + for (Map.Entry e : attrIdx_matchedScores.entrySet()) { + int index = e.getKey(); + Double score = e.getValue(); + if (score.equals(highestScore)) { + Attribute attribute = sbjClazzAttributes.get(index); + output.add(new MatchResult(sbjColumnAnnotation.getAnnotation(), attrIdx_matchedObjClazz.get(index), score, attribute)); + } + } + }//each subjectNE + }//if block checking whether the potential subject-object cell pairs are valid + return output; + } + + + private Map> matchSubjectAttributes( + DataTypeClassifier.DataType objectColumnDataType, + List objectCandidates, + List sbjCandidateAttributes, + Map sbjAttrValueDataTypes, + Map attrIdx_matchedScores + ) { + Map> + attrIdx_matchedObjCandidates = new HashMap<>(); + //scoring matches for the cell on the row + for (int index = 0; index < sbjCandidateAttributes.size(); index++) { + DataTypeClassifier.DataType type_of_attr_value = sbjAttrValueDataTypes.get(index); + Attribute attr = sbjCandidateAttributes.get(index); + if (!isValidType(type_of_attr_value)) { + continue; + } + //use only the fact's obj (text) to compare against the header's text + double maxScore = 0.0; + Map> mchScore_objCandidates = new HashMap<>(); + for (int o = 0; o < objectCandidates.size(); o++) { + uk.ac.shef.dcs.kbsearch.model.Resource r = objectCandidates.get(o); + String objCandidateURL = r.getId(); + String objCandidateLabel = r.getLabel(); + + if (objCandidateURL != null) { + double finalScore = + score(objCandidateLabel, objectColumnDataType, attr.getValue(), type_of_attr_value, stopWords); + if (attr.getValueURI() != null) { + double score = objCandidateURL.equals(attr.getValueURI()) ? 1.0 : 0.0; + if (score > finalScore) finalScore = score; + } + List candidates = mchScore_objCandidates.get(finalScore); + if (candidates == null) candidates = new ArrayList<>(); + candidates.add(r); + mchScore_objCandidates.put(finalScore, candidates); + if (maxScore < finalScore) { + maxScore = finalScore; + } + } + } + if (maxScore > 0 && maxScore > minScoreThreshold) { + attrIdx_matchedScores.put(index, maxScore); + attrIdx_matchedObjCandidates. + put(index, mchScore_objCandidates.get(maxScore)); + } + } + return attrIdx_matchedObjCandidates; + } + + + //if any cell's candidate annotation votes for a candidate relation emerging from that cell's column as subject column + //create an affinity link from that cell's candidate annotation and that relation annotation + protected void matchCellAnnotationAndRelation( + List subjectCellAnnotations, + int subjectColumn, int objectColumn, + TAnnotationJI tableAnnotations) { + if (subjectCellAnnotations.size() > 0) { + RelationColumns relationColumns = new RelationColumns(subjectColumn, objectColumn); + List candidateRelations = + tableAnnotations.getColumncolumnRelations().get(relationColumns); + if (candidateRelations != null && candidateRelations.size() > 0) { + for (int s = 0; s < subjectCellAnnotations.size(); s++) { //for each candidate subject entity + TCellAnnotation sbjEntity = subjectCellAnnotations.get(s); + List sbjEntityAttr = sbjEntity.getAnnotation().getAttributes(); //get the facts of that sbj ent + + for (Attribute f : sbjEntityAttr) { + for (TColumnColumnRelationAnnotation hbr : candidateRelations) { + if (f.getRelationURI().equals(hbr.getRelationURI())) { + tableAnnotations.setScoreEntityAndRelation(sbjEntity.getAnnotation().getId(), + TColumnColumnRelationAnnotation.toStringExpanded(relationColumns.getSubjectCol(), relationColumns.getObjectCol(), f.getRelationURI()), 1.0); + break; + } + } + } + } + }// each subjectNE-objectNE pair + }//each subjectNE + }//if block checking whether the potential subject-object cell pairs are valid +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedEntityScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedEntityScorer.java index a72c8316..1ecc3dbc 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedEntityScorer.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIAdaptedEntityScorer.java @@ -1,76 +1,76 @@ -package uk.ac.shef.dcs.sti.core.algorithm.ji; - -import org.simmetrics.Metric; -import org.simmetrics.StringMetric; -import org.simmetrics.builders.StringMetricBuilder; -import org.simmetrics.metrics.CosineSimilarity; -import org.simmetrics.metrics.Jaccard; -import org.simmetrics.metrics.Levenshtein; -import org.simmetrics.metrics.StringMetrics; -import org.simmetrics.tokenizers.Tokenizers; -import uk.ac.shef.dcs.sti.core.scorer.EntityScorer; -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.util.StringUtils; - - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - */ -public class JIAdaptedEntityScorer implements EntityScorer { - public static final String SCORE_FINAL = "score_factor_graph-entity"; - public static final String SCORE_LEV = "stringsim_lev"; - public static final String SCORE_JACCARD = "stringsim_jaccard"; - public static final String SCORE_COSINE = "stringsim_cosine"; - - private StringMetric cosine; - private StringMetric jaccard; - private StringMetric lev; - - public JIAdaptedEntityScorer() { - cosine = StringMetrics.cosineSimilarity(); - jaccard = StringMetrics.jaccard(); - lev = StringMetrics.levenshtein(); - } - - @Override - public Map computeElementScores(Entity candidate, - List all_candidates, - int sourceColumnIndex, - int sourceRowIndex, - List otherRows, - Table table, - Entity... referenceEntities) { - - TCell cell = table.getContentCell(sourceRowIndex, sourceColumnIndex); - - String normText = StringUtils.toAlphaNumericWhitechar(cell.getText()); - String normCandidateName = StringUtils.toAlphaNumericWhitechar(candidate.getLabel()); - double levScore = calculateStringSimilarity(normText, normCandidateName, lev); - double jaccardScore = calculateStringSimilarity(normText, normCandidateName, jaccard); - double cosineScore = calculateStringSimilarity(normText, normCandidateName, cosine); - - Map score_elements = new HashMap<>(); - score_elements.put(SCORE_FINAL, levScore + jaccardScore + cosineScore); - score_elements.put(SCORE_COSINE, cosineScore); - score_elements.put(SCORE_JACCARD, jaccardScore); - score_elements.put(SCORE_LEV, levScore); - return score_elements; - } - - private double calculateStringSimilarity(String text, String candidate, StringMetric lev) { - double baseScore = lev.compare(text, candidate); - return baseScore; - } - - @Override - public double computeFinal(Map scoreMap, String cellTextOriginal) { - scoreMap.put(TCellAnnotation.SCORE_FINAL, scoreMap.get(SCORE_FINAL)); - return scoreMap.get(SCORE_FINAL); - } -} +package uk.ac.shef.dcs.sti.core.algorithm.ji; + +import org.simmetrics.Metric; +import org.simmetrics.StringMetric; +import org.simmetrics.builders.StringMetricBuilder; +import org.simmetrics.metrics.CosineSimilarity; +import org.simmetrics.metrics.Jaccard; +import org.simmetrics.metrics.Levenshtein; +import org.simmetrics.metrics.StringMetrics; +import org.simmetrics.tokenizers.Tokenizers; +import uk.ac.shef.dcs.sti.core.scorer.EntityScorer; +import uk.ac.shef.dcs.sti.core.model.TCell; +import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; +import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.util.StringUtils; + + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + */ +public class JIAdaptedEntityScorer implements EntityScorer { + public static final String SCORE_FINAL = "score_factor_graph-entity"; + public static final String SCORE_LEV = "stringsim_lev"; + public static final String SCORE_JACCARD = "stringsim_jaccard"; + public static final String SCORE_COSINE = "stringsim_cosine"; + + private StringMetric cosine; + private StringMetric jaccard; + private StringMetric lev; + + public JIAdaptedEntityScorer() { + cosine = StringMetrics.cosineSimilarity(); + jaccard = StringMetrics.jaccard(); + lev = StringMetrics.levenshtein(); + } + + @Override + public Map computeElementScores(Entity candidate, + List all_candidates, + int sourceColumnIndex, + int sourceRowIndex, + List otherRows, + Table table, + Entity... referenceEntities) { + + TCell cell = table.getContentCell(sourceRowIndex, sourceColumnIndex); + + String normText = StringUtils.toAlphaNumericWhitechar(cell.getText()); + String normCandidateName = StringUtils.toAlphaNumericWhitechar(candidate.getLabel()); + double levScore = calculateStringSimilarity(normText, normCandidateName, lev); + double jaccardScore = calculateStringSimilarity(normText, normCandidateName, jaccard); + double cosineScore = calculateStringSimilarity(normText, normCandidateName, cosine); + + Map score_elements = new HashMap<>(); + score_elements.put(SCORE_FINAL, levScore + jaccardScore + cosineScore); + score_elements.put(SCORE_COSINE, cosineScore); + score_elements.put(SCORE_JACCARD, jaccardScore); + score_elements.put(SCORE_LEV, levScore); + return score_elements; + } + + private double calculateStringSimilarity(String text, String candidate, StringMetric lev) { + double baseScore = lev.compare(text, candidate); + return baseScore; + } + + @Override + public double computeFinal(Map scoreMap, String cellTextOriginal) { + scoreMap.put(TCellAnnotation.SCORE_FINAL, scoreMap.get(SCORE_FINAL)); + return scoreMap.get(SCORE_FINAL); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIClazzScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIClazzScorer.java index 00e4ed03..d2948d78 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIClazzScorer.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIClazzScorer.java @@ -1,125 +1,125 @@ -package uk.ac.shef.dcs.sti.core.algorithm.ji; - -import javafx.util.Pair; -import org.simmetrics.Metric; -import org.simmetrics.StringMetric; -import org.simmetrics.builders.StringMetricBuilder; -import org.simmetrics.metrics.CosineSimilarity; -import org.simmetrics.metrics.Jaccard; -import org.simmetrics.metrics.Levenshtein; -import org.simmetrics.metrics.StringMetrics; -import org.simmetrics.tokenizers.Tokenizers; -import uk.ac.shef.dcs.kbsearch.model.Clazz; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; -import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.core.scorer.ClazzScorer; -import uk.ac.shef.dcs.util.StringUtils; - -import java.util.*; - -/** - * Created by zqz on 01/05/2015. - */ -public class JIClazzScorer implements ClazzScorer { - public static final String SCORE_FINAL = "score_factor_graph-clazz"; - private static final String SCORE_LEV = "stringsim_lev"; - private static final String SCORE_JACCARD = "stringsim_jaccard"; - private static final String SCORE_COSINE = "stringsim_cosine"; - - private StringMetric cosine; - private StringMetric jaccard; - private StringMetric lev; - - public JIClazzScorer() { - cosine = StringMetrics.cosineSimilarity(); - jaccard = StringMetrics.jaccard(); - lev = StringMetrics.levenshtein(); - } - - - private double calculateStringSimilarity(String text, String candidate, StringMetric lev) { - double baseScore = lev.compare(text, candidate); - return baseScore; - } - - - @Override - public Map computeFinal(TColumnHeaderAnnotation ha, int tableRowsTotal) { - Map scoreMap = ha.getScoreElements(); - double finalScore = scoreMap.get(SCORE_FINAL); - scoreMap.put(TCellAnnotation.SCORE_FINAL, finalScore); - ha.setFinalScore(finalScore); - return scoreMap; - } - - @Override - public List computeElementScores(List>> input, - Collection headerAnnotationCandidates, - Table table, - List rows, - int column) throws STIException { - - for (Pair> entity : input) { - Entity e = entity.getKey(); - Map scoreElements = entity.getValue(); - if (scoreElements.get( - JIAdaptedEntityScorer.SCORE_FINAL) == 0.0) { - continue; - } - - for (Clazz c : e.getTypes()) { - TColumnHeaderAnnotation hAnnotation = null; - for (TColumnHeaderAnnotation headerAnnotation : headerAnnotationCandidates) { - if (headerAnnotation.getAnnotation().equals(c)) { - hAnnotation = headerAnnotation; - break; - } - } - - if (hAnnotation == null) { - String headerText = table.getColumnHeader(column).getHeaderText(); - hAnnotation = new TColumnHeaderAnnotation( - headerText, c, 0.0 - ); - - String normText = StringUtils.toAlphaNumericWhitechar(headerText); - String normAnnotationText = StringUtils.toAlphaNumericWhitechar(hAnnotation.getAnnotation().getLabel()); - double levScore = calculateStringSimilarity(normText, normAnnotationText, lev); - double jaccardScore = calculateStringSimilarity(normText, normAnnotationText, jaccard); - double cosineScore = calculateStringSimilarity(normText, normAnnotationText, cosine); - - Map clazz_score_elements = new HashMap<>(); - clazz_score_elements.put(SCORE_FINAL, levScore + jaccardScore + cosineScore); - clazz_score_elements.put(SCORE_COSINE, cosineScore); - clazz_score_elements.put(SCORE_JACCARD, jaccardScore); - clazz_score_elements.put(SCORE_LEV, levScore); - hAnnotation.setScoreElements(clazz_score_elements); - - headerAnnotationCandidates.add(hAnnotation); - } - - } - } - - return new ArrayList<>(headerAnnotationCandidates); - } - - @Override - public List computeCEScore(List>> entities, Collection existingHeaderAnnotations, Table table, int row, int column) throws STIException { - throw new STIException("Not supported"); - } - - @Override - public List computeCCScore(Collection candidates, Table table, int column) throws STIException { - throw new STIException("Not supported"); - } - - @Override - public double computeDC(TColumnHeaderAnnotation ha, List domain_representation) throws STIException { - throw new STIException("Not supported"); - } -} - +package uk.ac.shef.dcs.sti.core.algorithm.ji; + +import javafx.util.Pair; +import org.simmetrics.Metric; +import org.simmetrics.StringMetric; +import org.simmetrics.builders.StringMetricBuilder; +import org.simmetrics.metrics.CosineSimilarity; +import org.simmetrics.metrics.Jaccard; +import org.simmetrics.metrics.Levenshtein; +import org.simmetrics.metrics.StringMetrics; +import org.simmetrics.tokenizers.Tokenizers; +import uk.ac.shef.dcs.kbsearch.model.Clazz; +import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; +import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.core.scorer.ClazzScorer; +import uk.ac.shef.dcs.util.StringUtils; + +import java.util.*; + +/** + * Created by zqz on 01/05/2015. + */ +public class JIClazzScorer implements ClazzScorer { + public static final String SCORE_FINAL = "score_factor_graph-clazz"; + private static final String SCORE_LEV = "stringsim_lev"; + private static final String SCORE_JACCARD = "stringsim_jaccard"; + private static final String SCORE_COSINE = "stringsim_cosine"; + + private StringMetric cosine; + private StringMetric jaccard; + private StringMetric lev; + + public JIClazzScorer() { + cosine = StringMetrics.cosineSimilarity(); + jaccard = StringMetrics.jaccard(); + lev = StringMetrics.levenshtein(); + } + + + private double calculateStringSimilarity(String text, String candidate, StringMetric lev) { + double baseScore = lev.compare(text, candidate); + return baseScore; + } + + + @Override + public Map computeFinal(TColumnHeaderAnnotation ha, int tableRowsTotal) { + Map scoreMap = ha.getScoreElements(); + double finalScore = scoreMap.get(SCORE_FINAL); + scoreMap.put(TCellAnnotation.SCORE_FINAL, finalScore); + ha.setFinalScore(finalScore); + return scoreMap; + } + + @Override + public List computeElementScores(List>> input, + Collection headerAnnotationCandidates, + Table table, + List rows, + int column) throws STIException { + + for (Pair> entity : input) { + Entity e = entity.getKey(); + Map scoreElements = entity.getValue(); + if (scoreElements.get( + JIAdaptedEntityScorer.SCORE_FINAL) == 0.0) { + continue; + } + + for (Clazz c : e.getTypes()) { + TColumnHeaderAnnotation hAnnotation = null; + for (TColumnHeaderAnnotation headerAnnotation : headerAnnotationCandidates) { + if (headerAnnotation.getAnnotation().equals(c)) { + hAnnotation = headerAnnotation; + break; + } + } + + if (hAnnotation == null) { + String headerText = table.getColumnHeader(column).getHeaderText(); + hAnnotation = new TColumnHeaderAnnotation( + headerText, c, 0.0 + ); + + String normText = StringUtils.toAlphaNumericWhitechar(headerText); + String normAnnotationText = StringUtils.toAlphaNumericWhitechar(hAnnotation.getAnnotation().getLabel()); + double levScore = calculateStringSimilarity(normText, normAnnotationText, lev); + double jaccardScore = calculateStringSimilarity(normText, normAnnotationText, jaccard); + double cosineScore = calculateStringSimilarity(normText, normAnnotationText, cosine); + + Map clazz_score_elements = new HashMap<>(); + clazz_score_elements.put(SCORE_FINAL, levScore + jaccardScore + cosineScore); + clazz_score_elements.put(SCORE_COSINE, cosineScore); + clazz_score_elements.put(SCORE_JACCARD, jaccardScore); + clazz_score_elements.put(SCORE_LEV, levScore); + hAnnotation.setScoreElements(clazz_score_elements); + + headerAnnotationCandidates.add(hAnnotation); + } + + } + } + + return new ArrayList<>(headerAnnotationCandidates); + } + + @Override + public List computeCEScore(List>> entities, Collection existingHeaderAnnotations, Table table, int row, int column) throws STIException { + throw new STIException("Not supported"); + } + + @Override + public List computeCCScore(Collection candidates, Table table, int column) throws STIException { + throw new STIException("Not supported"); + } + + @Override + public double computeDC(TColumnHeaderAnnotation ha, List domain_representation) throws STIException { + throw new STIException("Not supported"); + } +} + diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIInterpreter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIInterpreter.java index 5d9f9e25..f67618d8 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIInterpreter.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/JIInterpreter.java @@ -1,357 +1,357 @@ -package uk.ac.shef.dcs.sti.core.algorithm.ji; - -import cc.mallet.grmm.inference.Inferencer; -import cc.mallet.grmm.inference.LoopyBP; -import cc.mallet.grmm.types.AssignmentIterator; -import cc.mallet.grmm.types.Factor; -import cc.mallet.grmm.types.FactorGraph; -import cc.mallet.grmm.types.Variable; -import javafx.util.Pair; -import org.apache.commons.lang.exception.ExceptionUtils; -import org.apache.log4j.Logger; -import uk.ac.shef.dcs.kbsearch.KBSearchException; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.algorithm.SemanticTableInterpreter; -import uk.ac.shef.dcs.sti.core.algorithm.ji.factorgraph.FactorGraphBuilder; -import uk.ac.shef.dcs.sti.core.subjectcol.SubjectColumnDetector; -import uk.ac.shef.dcs.sti.util.DataTypeClassifier; -import uk.ac.shef.dcs.sti.core.model.*; - -import java.io.IOException; -import java.util.*; -import java.util.List; - -/** - * Created by zqz on 01/05/2015. - */ -public class JIInterpreter extends SemanticTableInterpreter { - - private static final Logger LOG = Logger.getLogger(JIInterpreter.class.getName()); - //main column finder is needed to generate data features of each column (e.g., data type in a column), - //even though we do not use it to find the main column in SMP - protected SubjectColumnDetector subjectColumnDetector; - //if there are any columns we want to isValidAttribute - protected int maxIteration; - - protected List invalidCellValues = Arrays.asList("yes", "no", "away", "home"); - - protected boolean useSubjectColumn = false; - protected boolean debugMode = false; - protected CandidateEntityGenerator neGenerator; - protected CandidateConceptGenerator columnClazzClassifier; - protected CandidateRelationGenerator relationGenerator; - private FactorGraphBuilder graphBuilder; - - public JIInterpreter(SubjectColumnDetector subjectColumnDetector, - CandidateEntityGenerator neGenerator, - CandidateConceptGenerator columnClazzClassifier, - CandidateRelationGenerator relationGenerator, - boolean useSubjectColumn, - int[] ignoreColumns, - int[] mustdoColumns, - int maxIteration, - boolean debugMode - ) { - super(ignoreColumns, mustdoColumns); - this.useSubjectColumn = useSubjectColumn; - this.subjectColumnDetector = subjectColumnDetector; - this.graphBuilder = new FactorGraphBuilder(); - this.neGenerator = neGenerator; - this.columnClazzClassifier = columnClazzClassifier; - this.relationGenerator = relationGenerator; - this.maxIteration = maxIteration; - this.debugMode = debugMode; - } - - - public TAnnotation start(Table table, boolean relationLearning) throws STIException { - TAnnotationJI tableAnnotations = new TAnnotationJI(table.getNumRows(), table.getNumCols()); - - //Main col finder finds main column. Although this is not needed by SMP, it also generates important features of - //table data types to be used later - try { - Set ignoreColumnsRevised = collectIgnoreColumns(table); - int[] iignoreColumnsRevisedArray = new int[ignoreColumnsRevised.size()]; - int index = 0; - for (Integer i : ignoreColumnsRevised) { - iignoreColumnsRevisedArray[index] = i; - index++; - } - - LOG.info(">\t COLUMN FEATURE GENERATION AND SUBJECT COLUMN DETECTION (if enabled)..."); - List>> subjectColumnScores = subjectColumnDetector.compute(table, - iignoreColumnsRevisedArray); - tableAnnotations.setSubjectColumn(subjectColumnScores.get(0).getKey()); - - LOG.info(">\t JOINT INFERENCE VARIABLE INIT"); - LOG.info(">\t named entity generator..."); //SMP begins with an initial NE ranker to rank candidate NEs for each cell - boolean graphNonEmpty = generateEntityCandidates(table, tableAnnotations, ignoreColumnsRevised); - - LOG.info(">\t column class generator"); - generateClazzCandidates(tableAnnotations, table, ignoreColumnsRevised); - if (relationLearning) { - LOG.info(">\t column column relation generator"); - generateRelationCandidates(tableAnnotations, table, useSubjectColumn, ignoreColumnsRevised); - } - - - if (graphNonEmpty && hasAnnotation(tableAnnotations)) { - LOG.info(">\t BUILDING FACTOR GRAPH"); - List subGraphs = - graphBuilder.build(tableAnnotations, relationLearning, table.getSourceId()); - LOG.info(">\t\t "+subGraphs.size()+" maximum connected sub-graphs"); - for (int i = 0; i < subGraphs.size(); i++) { - FactorGraph graph = subGraphs.get(i); - if (debugMode) { - DebuggingUtil.debugGraph(graph, i+"th_graph,"+table.getSourceId()); - tableAnnotations.debugAffinity(i + "th_graph,"+table.getSourceId()); - } - - LOG.info(">\t RUNNING INFERENCE"); - Inferencer infResidualBP; - if (maxIteration > 0) - infResidualBP = new LoopyBP(maxIteration); - else - infResidualBP = new LoopyBP(); - - try { - infResidualBP.computeMarginals(graph); - } catch (IndexOutOfBoundsException e) { - if (debugMode) { - LOG.error("\t Graph empty exception, but checking did not catch this. System exists:" + table.getSourceId()); - LOG.error(graph.dumpToString()); - Object[] debuggingResult = DebuggingUtil.debugAnnotations(tableAnnotations); - for (Object o : debuggingResult) { - LOG.info(o.toString()); - } - LOG.warn(ExceptionUtils.getFullStackTrace(e)); - System.exit(1); - } else - LOG.warn(ExceptionUtils.getFullStackTrace(e)); - } - LOG.info(">\t COLLECTING MARGINAL PROB AND FINALIZING ANNOTATIONS"); - boolean success = createAnnotations(graph, graphBuilder, infResidualBP, tableAnnotations); - if (!success) - throw new STIException("Invalid marginals, failed: " + table.getSourceId()); - } - } else { - LOG.warn("EMPTY TABLE:" + table.getSourceId()); - } - return tableAnnotations; - } catch (Exception e) { - throw new STIException(e); - } - } - - private boolean hasAnnotation(TAnnotationJI tabAnnotations) { - for (int col = 0; col < tabAnnotations.getCols(); col++) { - TColumnHeaderAnnotation[] ha = tabAnnotations.getHeaderAnnotation(col); - if (ha.length > 0) - return true; - for (int row = 0; row < tabAnnotations.getRows(); row++) { - if (tabAnnotations.getContentCellAnnotations(row, col).length > 0) - return true; - } - } - if (tabAnnotations.getColumncolumnRelations().size() > 0) - return true; - - return false; - } - - /** - * Cell values like "yes", "no", "home", "away" in some domains have caused problems to JI. - * Ignore these columns if they only contain such values - * - * @param table - * @return - */ - protected Set collectIgnoreColumns(Table table) { - Set ignore = new HashSet<>(); - ignore.addAll(getIgnoreColumns()); - - for (int c = 0; c < table.getNumCols(); c++) { - Set uniqueStrings = new HashSet<>(); - for (int r = 0; r < table.getNumRows(); r++) { - TCell tcc = table.getContentCell(r, c); - String text = tcc.getText().trim().replaceAll("[^a-zA-Z0-9]", ""); - if (text.length() > 1) - uniqueStrings.add(text); - } - if (uniqueStrings.size() < 4 && table.getNumRows() > 4) { - uniqueStrings.removeAll(invalidCellValues); - if (uniqueStrings.size() == 0) ignore.add(c); - } - } - - return ignore; - } - - protected boolean generateEntityCandidates(Table table, - TAnnotation tableAnnotations, - Collection ignoreColumns) throws KBSearchException { - boolean graphNonEmpty = false; - for (int col = 0; col < table.getNumCols(); col++) { - if (getMustdoColumns().contains(col)) { - LOG.info("\t\t>> column=(compulsory)" + col); - for (int r = 0; r < table.getNumRows(); r++) { - neGenerator.generateInitialCellAnnotations(tableAnnotations, table, r, col); - } - graphNonEmpty = true; - } else { - if (ignoreColumns.contains(col)) continue; - if (!table.getColumnHeader(col).getFeature().getMostFrequentDataType().getType().equals(DataTypeClassifier.DataType.NAMED_ENTITY)) - continue; - LOG.info("\t\t>> column=" + col); - for (int r = 0; r < table.getNumRows(); r++) { - neGenerator.generateInitialCellAnnotations(tableAnnotations, table, r, col); - } - graphNonEmpty = true; - } - } - return graphNonEmpty; - } - - protected void generateClazzCandidates(TAnnotationJI tableAnnotations, Table table, - Collection ignoreColumnsLocal) throws KBSearchException, STIException { - // ObjectMatrix1D ccFactors = new SparseObjectMatrix1D(table.getNumCols()); - for (int col = 0; col < table.getNumCols(); col++) { - if (getMustdoColumns().contains(col)) { - LOG.info("\t\t>> column=(compulsory)" + col); - columnClazzClassifier.generateInitialColumnAnnotations(tableAnnotations, table, col); - } else { - if (ignoreColumnsLocal.contains(col)) continue; - if (!table.getColumnHeader(col).getFeature().getMostFrequentDataType().getType().equals(DataTypeClassifier.DataType.NAMED_ENTITY)) - continue; - LOG.info("\t\t>> column=" + col); - columnClazzClassifier.generateInitialColumnAnnotations(tableAnnotations, table, col); - } - } - } - - protected void generateRelationCandidates(TAnnotationJI tabAnnotations, Table table, - boolean useSubjectColumn, - Collection ignoreColumnsLocal) throws IOException, KBSearchException { - relationGenerator.generateInitialColumnColumnRelations(tabAnnotations, table, useSubjectColumn, ignoreColumnsLocal); - } - - protected boolean createAnnotations(FactorGraph graph, - FactorGraphBuilder graphBuilder, - Inferencer infResidualBP, - TAnnotationJI tabAnnotations) { - for (int i = 0; i < graph.numVariables(); i++) { - Variable var = graph.get(i); - Factor ptl = infResidualBP.lookupMarginal(var); - - String varType = graphBuilder.getTypeOfVariable(var); - if (varType == null) - continue; - - if (varType.equals(VariableType.CELL.toString())) { - int[] position = graphBuilder.getCellPosition(var); - if (position == null) - continue; - TCellAnnotation[] candidateCellAnnotations = - tabAnnotations.getContentCellAnnotations(position[0], position[1]); - - for (TCellAnnotation ca : candidateCellAnnotations) { - AssignmentIterator it = ptl.assignmentIterator(); - boolean found = false; - while (it.hasNext()) { - int outcome = it.indexOfCurrentAssn(); - String assignedId = var.getLabelAlphabet().lookupLabel(outcome).toString(); - if (assignedId.equals(ca.getAnnotation().getId())) { - found = true; - double score = ptl.value(it); - if (Double.isNaN(score)) - return false; - ca.setFinalScore(score); - break; - } - it.next(); - } - if (!found) //this should not happen - ca.setFinalScore(0.0); - } - Arrays.sort(candidateCellAnnotations); - tabAnnotations.setContentCellAnnotations(position[0], position[1], candidateCellAnnotations); - } else if (varType.equals(VariableType.HEADER.toString())) { - Integer position = graphBuilder.getHeaderPosition(var); - if (position == null) - continue; - TColumnHeaderAnnotation[] candidateHeaderAnnotations = tabAnnotations.getHeaderAnnotation(position); - for (TColumnHeaderAnnotation ha : candidateHeaderAnnotations) { - AssignmentIterator it = ptl.assignmentIterator(); - boolean found = false; - while (it.hasNext()) { - int outcome = it.indexOfCurrentAssn(); - String assignedId = var.getLabelAlphabet().lookupLabel(outcome).toString(); - if (assignedId.equals(ha.getAnnotation().getId())) { - found = true; - double score = ptl.value(it); - if (Double.isNaN(score)) - return false; - ha.setFinalScore(score); - break; - } - it.next(); - } - if (!found) //this should not happen - ha.setFinalScore(0.0); - } - Arrays.sort(candidateHeaderAnnotations); - tabAnnotations.setHeaderAnnotation(position, candidateHeaderAnnotations); - } else if (varType.equals(VariableType.RELATION.toString())) { - double maxScore = 0.0; - AssignmentIterator it = ptl.assignmentIterator(); - RelationColumns direction = null; - while (it.hasNext()) { - double score = ptl.value(it); - if (Double.isNaN(score)) - return false; - int outcome = it.indexOfCurrentAssn(); - String assignedId = var.getLabelAlphabet().lookupLabel(outcome).toString(); - if (score >= maxScore) { - maxScore = score; - direction = graphBuilder.getRelationDirection(assignedId); - } - it.next(); - } - - List relationCandidates = - tabAnnotations.getColumncolumnRelations().get(direction); - - tabAnnotations.getColumncolumnRelations().remove(new RelationColumns( - direction.getObjectCol(), direction.getSubjectCol() - )); - - for (TColumnColumnRelationAnnotation hbr : relationCandidates) { - AssignmentIterator itr = ptl.assignmentIterator(); - boolean found = false; - while (itr.hasNext()) { - int outcome = itr.indexOfCurrentAssn(); - String assignedId = var.getLabelAlphabet().lookupLabel(outcome).toString(); - if (assignedId.equals(hbr.getRelationURI())) { - found = true; - double score = ptl.value(itr); - if (Double.isNaN(score)) return false; - hbr.setFinalScore(score); - break; - } - itr.next(); - } - if (!found) //this should not happen - hbr.setFinalScore(0.0); - } - tabAnnotations.getColumncolumnRelations().put(direction, - relationCandidates); - //go through again and collection only... - - } else { - continue; - } - } - return true; - } - -} +package uk.ac.shef.dcs.sti.core.algorithm.ji; + +import cc.mallet.grmm.inference.Inferencer; +import cc.mallet.grmm.inference.LoopyBP; +import cc.mallet.grmm.types.AssignmentIterator; +import cc.mallet.grmm.types.Factor; +import cc.mallet.grmm.types.FactorGraph; +import cc.mallet.grmm.types.Variable; +import javafx.util.Pair; +import org.apache.commons.lang.exception.ExceptionUtils; +import org.apache.log4j.Logger; +import uk.ac.shef.dcs.kbsearch.KBSearchException; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.algorithm.SemanticTableInterpreter; +import uk.ac.shef.dcs.sti.core.algorithm.ji.factorgraph.FactorGraphBuilder; +import uk.ac.shef.dcs.sti.core.subjectcol.SubjectColumnDetector; +import uk.ac.shef.dcs.sti.util.DataTypeClassifier; +import uk.ac.shef.dcs.sti.core.model.*; + +import java.io.IOException; +import java.util.*; +import java.util.List; + +/** + * Created by zqz on 01/05/2015. + */ +public class JIInterpreter extends SemanticTableInterpreter { + + private static final Logger LOG = Logger.getLogger(JIInterpreter.class.getName()); + //main column finder is needed to generate data features of each column (e.g., data type in a column), + //even though we do not use it to find the main column in SMP + protected SubjectColumnDetector subjectColumnDetector; + //if there are any columns we want to isValidAttribute + protected int maxIteration; + + protected List invalidCellValues = Arrays.asList("yes", "no", "away", "home"); + + protected boolean useSubjectColumn = false; + protected boolean debugMode = false; + protected CandidateEntityGenerator neGenerator; + protected CandidateConceptGenerator columnClazzClassifier; + protected CandidateRelationGenerator relationGenerator; + private FactorGraphBuilder graphBuilder; + + public JIInterpreter(SubjectColumnDetector subjectColumnDetector, + CandidateEntityGenerator neGenerator, + CandidateConceptGenerator columnClazzClassifier, + CandidateRelationGenerator relationGenerator, + boolean useSubjectColumn, + int[] ignoreColumns, + int[] mustdoColumns, + int maxIteration, + boolean debugMode + ) { + super(ignoreColumns, mustdoColumns); + this.useSubjectColumn = useSubjectColumn; + this.subjectColumnDetector = subjectColumnDetector; + this.graphBuilder = new FactorGraphBuilder(); + this.neGenerator = neGenerator; + this.columnClazzClassifier = columnClazzClassifier; + this.relationGenerator = relationGenerator; + this.maxIteration = maxIteration; + this.debugMode = debugMode; + } + + + public TAnnotation start(Table table, boolean relationLearning) throws STIException { + TAnnotationJI tableAnnotations = new TAnnotationJI(table.getNumRows(), table.getNumCols()); + + //Main col finder finds main column. Although this is not needed by SMP, it also generates important features of + //table data types to be used later + try { + Set ignoreColumnsRevised = collectIgnoreColumns(table); + int[] iignoreColumnsRevisedArray = new int[ignoreColumnsRevised.size()]; + int index = 0; + for (Integer i : ignoreColumnsRevised) { + iignoreColumnsRevisedArray[index] = i; + index++; + } + + LOG.info(">\t COLUMN FEATURE GENERATION AND SUBJECT COLUMN DETECTION (if enabled)..."); + List>> subjectColumnScores = subjectColumnDetector.compute(table, + iignoreColumnsRevisedArray); + tableAnnotations.setSubjectColumn(subjectColumnScores.get(0).getKey()); + + LOG.info(">\t JOINT INFERENCE VARIABLE INIT"); + LOG.info(">\t named entity generator..."); //SMP begins with an initial NE ranker to rank candidate NEs for each cell + boolean graphNonEmpty = generateEntityCandidates(table, tableAnnotations, ignoreColumnsRevised); + + LOG.info(">\t column class generator"); + generateClazzCandidates(tableAnnotations, table, ignoreColumnsRevised); + if (relationLearning) { + LOG.info(">\t column column relation generator"); + generateRelationCandidates(tableAnnotations, table, useSubjectColumn, ignoreColumnsRevised); + } + + + if (graphNonEmpty && hasAnnotation(tableAnnotations)) { + LOG.info(">\t BUILDING FACTOR GRAPH"); + List subGraphs = + graphBuilder.build(tableAnnotations, relationLearning, table.getSourceId()); + LOG.info(">\t\t "+subGraphs.size()+" maximum connected sub-graphs"); + for (int i = 0; i < subGraphs.size(); i++) { + FactorGraph graph = subGraphs.get(i); + if (debugMode) { + DebuggingUtil.debugGraph(graph, i+"th_graph,"+table.getSourceId()); + tableAnnotations.debugAffinity(i + "th_graph,"+table.getSourceId()); + } + + LOG.info(">\t RUNNING INFERENCE"); + Inferencer infResidualBP; + if (maxIteration > 0) + infResidualBP = new LoopyBP(maxIteration); + else + infResidualBP = new LoopyBP(); + + try { + infResidualBP.computeMarginals(graph); + } catch (IndexOutOfBoundsException e) { + if (debugMode) { + LOG.error("\t Graph empty exception, but checking did not catch this. System exists:" + table.getSourceId()); + LOG.error(graph.dumpToString()); + Object[] debuggingResult = DebuggingUtil.debugAnnotations(tableAnnotations); + for (Object o : debuggingResult) { + LOG.info(o.toString()); + } + LOG.warn(ExceptionUtils.getFullStackTrace(e)); + System.exit(1); + } else + LOG.warn(ExceptionUtils.getFullStackTrace(e)); + } + LOG.info(">\t COLLECTING MARGINAL PROB AND FINALIZING ANNOTATIONS"); + boolean success = createAnnotations(graph, graphBuilder, infResidualBP, tableAnnotations); + if (!success) + throw new STIException("Invalid marginals, failed: " + table.getSourceId()); + } + } else { + LOG.warn("EMPTY TABLE:" + table.getSourceId()); + } + return tableAnnotations; + } catch (Exception e) { + throw new STIException(e); + } + } + + private boolean hasAnnotation(TAnnotationJI tabAnnotations) { + for (int col = 0; col < tabAnnotations.getCols(); col++) { + TColumnHeaderAnnotation[] ha = tabAnnotations.getHeaderAnnotation(col); + if (ha.length > 0) + return true; + for (int row = 0; row < tabAnnotations.getRows(); row++) { + if (tabAnnotations.getContentCellAnnotations(row, col).length > 0) + return true; + } + } + if (tabAnnotations.getColumncolumnRelations().size() > 0) + return true; + + return false; + } + + /** + * Cell values like "yes", "no", "home", "away" in some domains have caused problems to JI. + * Ignore these columns if they only contain such values + * + * @param table + * @return + */ + protected Set collectIgnoreColumns(Table table) { + Set ignore = new HashSet<>(); + ignore.addAll(getIgnoreColumns()); + + for (int c = 0; c < table.getNumCols(); c++) { + Set uniqueStrings = new HashSet<>(); + for (int r = 0; r < table.getNumRows(); r++) { + TCell tcc = table.getContentCell(r, c); + String text = tcc.getText().trim().replaceAll("[^a-zA-Z0-9]", ""); + if (text.length() > 1) + uniqueStrings.add(text); + } + if (uniqueStrings.size() < 4 && table.getNumRows() > 4) { + uniqueStrings.removeAll(invalidCellValues); + if (uniqueStrings.size() == 0) ignore.add(c); + } + } + + return ignore; + } + + protected boolean generateEntityCandidates(Table table, + TAnnotation tableAnnotations, + Collection ignoreColumns) throws KBSearchException { + boolean graphNonEmpty = false; + for (int col = 0; col < table.getNumCols(); col++) { + if (getMustdoColumns().contains(col)) { + LOG.info("\t\t>> column=(compulsory)" + col); + for (int r = 0; r < table.getNumRows(); r++) { + neGenerator.generateInitialCellAnnotations(tableAnnotations, table, r, col); + } + graphNonEmpty = true; + } else { + if (ignoreColumns.contains(col)) continue; + if (!table.getColumnHeader(col).getFeature().getMostFrequentDataType().getType().equals(DataTypeClassifier.DataType.NAMED_ENTITY)) + continue; + LOG.info("\t\t>> column=" + col); + for (int r = 0; r < table.getNumRows(); r++) { + neGenerator.generateInitialCellAnnotations(tableAnnotations, table, r, col); + } + graphNonEmpty = true; + } + } + return graphNonEmpty; + } + + protected void generateClazzCandidates(TAnnotationJI tableAnnotations, Table table, + Collection ignoreColumnsLocal) throws KBSearchException, STIException { + // ObjectMatrix1D ccFactors = new SparseObjectMatrix1D(table.getNumCols()); + for (int col = 0; col < table.getNumCols(); col++) { + if (getMustdoColumns().contains(col)) { + LOG.info("\t\t>> column=(compulsory)" + col); + columnClazzClassifier.generateInitialColumnAnnotations(tableAnnotations, table, col); + } else { + if (ignoreColumnsLocal.contains(col)) continue; + if (!table.getColumnHeader(col).getFeature().getMostFrequentDataType().getType().equals(DataTypeClassifier.DataType.NAMED_ENTITY)) + continue; + LOG.info("\t\t>> column=" + col); + columnClazzClassifier.generateInitialColumnAnnotations(tableAnnotations, table, col); + } + } + } + + protected void generateRelationCandidates(TAnnotationJI tabAnnotations, Table table, + boolean useSubjectColumn, + Collection ignoreColumnsLocal) throws IOException, KBSearchException { + relationGenerator.generateInitialColumnColumnRelations(tabAnnotations, table, useSubjectColumn, ignoreColumnsLocal); + } + + protected boolean createAnnotations(FactorGraph graph, + FactorGraphBuilder graphBuilder, + Inferencer infResidualBP, + TAnnotationJI tabAnnotations) { + for (int i = 0; i < graph.numVariables(); i++) { + Variable var = graph.get(i); + Factor ptl = infResidualBP.lookupMarginal(var); + + String varType = graphBuilder.getTypeOfVariable(var); + if (varType == null) + continue; + + if (varType.equals(VariableType.CELL.toString())) { + int[] position = graphBuilder.getCellPosition(var); + if (position == null) + continue; + TCellAnnotation[] candidateCellAnnotations = + tabAnnotations.getContentCellAnnotations(position[0], position[1]); + + for (TCellAnnotation ca : candidateCellAnnotations) { + AssignmentIterator it = ptl.assignmentIterator(); + boolean found = false; + while (it.hasNext()) { + int outcome = it.indexOfCurrentAssn(); + String assignedId = var.getLabelAlphabet().lookupLabel(outcome).toString(); + if (assignedId.equals(ca.getAnnotation().getId())) { + found = true; + double score = ptl.value(it); + if (Double.isNaN(score)) + return false; + ca.setFinalScore(score); + break; + } + it.next(); + } + if (!found) //this should not happen + ca.setFinalScore(0.0); + } + Arrays.sort(candidateCellAnnotations); + tabAnnotations.setContentCellAnnotations(position[0], position[1], candidateCellAnnotations); + } else if (varType.equals(VariableType.HEADER.toString())) { + Integer position = graphBuilder.getHeaderPosition(var); + if (position == null) + continue; + TColumnHeaderAnnotation[] candidateHeaderAnnotations = tabAnnotations.getHeaderAnnotation(position); + for (TColumnHeaderAnnotation ha : candidateHeaderAnnotations) { + AssignmentIterator it = ptl.assignmentIterator(); + boolean found = false; + while (it.hasNext()) { + int outcome = it.indexOfCurrentAssn(); + String assignedId = var.getLabelAlphabet().lookupLabel(outcome).toString(); + if (assignedId.equals(ha.getAnnotation().getId())) { + found = true; + double score = ptl.value(it); + if (Double.isNaN(score)) + return false; + ha.setFinalScore(score); + break; + } + it.next(); + } + if (!found) //this should not happen + ha.setFinalScore(0.0); + } + Arrays.sort(candidateHeaderAnnotations); + tabAnnotations.setHeaderAnnotation(position, candidateHeaderAnnotations); + } else if (varType.equals(VariableType.RELATION.toString())) { + double maxScore = 0.0; + AssignmentIterator it = ptl.assignmentIterator(); + RelationColumns direction = null; + while (it.hasNext()) { + double score = ptl.value(it); + if (Double.isNaN(score)) + return false; + int outcome = it.indexOfCurrentAssn(); + String assignedId = var.getLabelAlphabet().lookupLabel(outcome).toString(); + if (score >= maxScore) { + maxScore = score; + direction = graphBuilder.getRelationDirection(assignedId); + } + it.next(); + } + + List relationCandidates = + tabAnnotations.getColumncolumnRelations().get(direction); + + tabAnnotations.getColumncolumnRelations().remove(new RelationColumns( + direction.getObjectCol(), direction.getSubjectCol() + )); + + for (TColumnColumnRelationAnnotation hbr : relationCandidates) { + AssignmentIterator itr = ptl.assignmentIterator(); + boolean found = false; + while (itr.hasNext()) { + int outcome = itr.indexOfCurrentAssn(); + String assignedId = var.getLabelAlphabet().lookupLabel(outcome).toString(); + if (assignedId.equals(hbr.getRelationURI())) { + found = true; + double score = ptl.value(itr); + if (Double.isNaN(score)) return false; + hbr.setFinalScore(score); + break; + } + itr.next(); + } + if (!found) //this should not happen + hbr.setFinalScore(0.0); + } + tabAnnotations.getColumncolumnRelations().put(direction, + relationCandidates); + //go through again and collection only... + + } else { + continue; + } + } + return true; + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/TAnnotationJI.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/TAnnotationJI.java index 44c2c525..088d902e 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/TAnnotationJI.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/TAnnotationJI.java @@ -1,179 +1,179 @@ -package uk.ac.shef.dcs.sti.core.algorithm.ji; - -import uk.ac.shef.dcs.sti.core.model.TAnnotation; - -import java.util.*; - -/** - * Created by zqz on 01/05/2015. - */ -public class TAnnotationJI extends TAnnotation { - - //==debug purpose - private Set usedKey_score_entityAndClazz = new HashSet<>(); - private Set usedKey_score_entityPairAndRelation = new HashSet<>(); - private Set usedKey_score_entityAndRelation = new HashSet<>(); - private Set usedKey_score_clazzPairAndRelation_rowEvidence = new HashSet<>(); - private Set usedKey_score_clazzPairAndRelation_headerEvidence = new HashSet<>(); - private Set usedKey_scoreContributingRows_clazzPairAndRelation = new HashSet<>(); - //==debug purpose - - private Map score_entityAndConcept = new HashMap<>(); - private Map score_entityPairAndRelation = new HashMap<>(); - private Map score_entityAndRelation = new HashMap<>(); - private Map score_clazzPairAndRelation_rowEvidence = new HashMap<>(); - private Map score_clazzPairAndRelation_headerEvidence = new HashMap<>(); - private Map> scoreContributingRows_clazzPairAndRelation = new HashMap<>(); - - public TAnnotationJI(int rows, int cols) { - super(rows, cols); - } - - public double getScoreEntityAndRelation(String entityId, String relationId) { - usedKey_score_entityAndRelation.add(createKeyPair(entityId, relationId)); - Double v = score_entityAndRelation.get(createKeyPair(entityId, relationId)); - if (v == null) - v = 0.0; - return v; - } - - public void setScoreEntityAndRelation(String entityId, String relationId, double score) { - score_entityAndRelation.put(createKeyPair(entityId, relationId), score); - } - - public double getScoreEntityAndConceptSimilarity(String entityId, String conceptId) { - usedKey_score_entityAndClazz.add(createKeyPair(entityId, conceptId)); - Double v = score_entityAndConcept.get(createKeyPair(entityId, conceptId)); - if (v == null) - v = 0.0; - return v; - } - - public void setScoreEntityAndConceptSimilarity(String entityId, String conceptId, double score) { - score_entityAndConcept.put(createKeyPair(entityId, conceptId), score); - } - - private double getScoreClazzPairAndRelationFromHeaderEvidence(String sbjConceptId, String relationId, String objConceptId) { - usedKey_score_clazzPairAndRelation_headerEvidence.add(createKeyTriple(sbjConceptId, objConceptId, relationId)); - Double v = score_clazzPairAndRelation_headerEvidence.get(createKeyTriple(sbjConceptId, objConceptId, relationId)); - if (v == null) - v = 0.0; - return v; - } - - private double getScoreClazzPairAndRelationFromRowEvidence(String sbjConceptId, String relationId, String objConceptId) { - usedKey_score_clazzPairAndRelation_rowEvidence.add(createKeyTriple(sbjConceptId, objConceptId, relationId)); - Double v = score_clazzPairAndRelation_rowEvidence.get(createKeyTriple(sbjConceptId, objConceptId, relationId)); - if (v == null) - v = 0.0; - return v; - } - - - public double getScoreClazzPairAndRelation(String sbjConceptId, String relationId, String objConceptId, int norm) { - double v = getScoreClazzPairAndRelationFromHeaderEvidence(sbjConceptId, relationId, objConceptId); - - Map cells = scoreContributingRows_clazzPairAndRelation.get( - createKeyTriple(sbjConceptId, objConceptId, relationId)); - usedKey_scoreContributingRows_clazzPairAndRelation.add(createKeyTriple(sbjConceptId, objConceptId, relationId)); - - if (cells != null) - v = v + Math.sqrt(cells.size() / (double) norm); - return v; - } - - - public void setScoreClazzPairAndRelationFromHeaderEvidence(String sbjConceptId, String relationId, String objConceptId, - double score) { - score_clazzPairAndRelation_headerEvidence.put(createKeyTriple(sbjConceptId, objConceptId, relationId), score); - } - - - /** - * @param row the row of cell where an entity has voted for this concept and relation - * @param sbjConceptId - * @param relationId - * @param score - */ - public void setScoreClazzPairAndRelationFromRows(int row, - String sbjConceptId, - String relationId, - String objConceptId, double score) { - String key = createKeyTriple(sbjConceptId, objConceptId, relationId); - Map contributingRows = scoreContributingRows_clazzPairAndRelation.get( - key - ); - if (contributingRows == null) { - contributingRows = new HashMap<>(); - contributingRows.put(String.valueOf(row), score); - score_clazzPairAndRelation_rowEvidence.put(key, score); - scoreContributingRows_clazzPairAndRelation.put(key, contributingRows); - } else { - Double existingScore = contributingRows.get(String.valueOf(row)); - if (existingScore == null) { - contributingRows.put(String.valueOf(row), score); - score_clazzPairAndRelation_rowEvidence.put(key, - score + getScoreClazzPairAndRelationFromRowEvidence(sbjConceptId, relationId, objConceptId)); - scoreContributingRows_clazzPairAndRelation.put(key, contributingRows); - } else if (existingScore < score) { //previously this cell has contributed to a computeElementScores, but that is smaller - //so we need to recalculate the instanceEvidence computeElementScores using the new computeElementScores - contributingRows.put(String.valueOf(row), score); - double diff = score - existingScore; - score_clazzPairAndRelation_rowEvidence.put(key, - diff + getScoreClazzPairAndRelationFromRowEvidence(sbjConceptId, relationId, objConceptId)); - } - } - } - - public double getScoreEntityPairAndRelation(String sbjEntityId, String objEntityId, String relationId) { - usedKey_score_entityPairAndRelation.add(createKeyTriple(sbjEntityId, objEntityId, relationId)); - Double v = score_entityPairAndRelation.get(createKeyTriple(sbjEntityId, objEntityId, relationId)); - if (v == null) - v = 0.0; - return v; - } - - public void setScoreEntityPairAndRelation(String sbjEntityId, String objEntityId, String relationId, double score) { - score_entityPairAndRelation.put(createKeyTriple(sbjEntityId, objEntityId, relationId), score); - } - - private String createKeyTriple(String sbjId, String objId, String relation) { - return sbjId + ">" + objId + "|" + relation; - } - - private String createKeyPair(String s1, String s2) { - return s1 + "|" + s2; - } - - protected void debugAffinity(String tableId) { - List tmp = new ArrayList<>(score_entityAndConcept.keySet()); - tmp.removeAll(usedKey_score_entityAndClazz); - if (tmp.size() > 0) - System.err.println(tableId+"-score_entityAndConcept unused:" + tmp); - - tmp = new ArrayList<>(score_entityPairAndRelation.keySet()); - tmp.removeAll(usedKey_score_entityPairAndRelation); - if (tmp.size() > 0) - System.err.println(tableId+"-score_entityPairAndRelation unused:" + tmp); - - tmp = new ArrayList<>(score_entityAndRelation.keySet()); - tmp.removeAll(usedKey_score_entityAndRelation); - if (tmp.size() > 0) - System.err.println(tableId+"-score_entityAndRelation unused:" + tmp); - - /*tmp = new ArrayList(score_conceptPairAndRelation_instaceEvidence.keySet()); - tmp.removeAll(usedKey_score_conceptPairAndRelation_instaceEvidence); - if (tmp.size() > 0) - System.err.println("score_conceptPairAndRelation_instaceEvidence unused:" + tmp);*/ - - tmp = new ArrayList<>(score_clazzPairAndRelation_headerEvidence.keySet()); - tmp.removeAll(usedKey_score_clazzPairAndRelation_headerEvidence); - if (tmp.size() > 0) - System.err.println(tableId+"-score_conceptPairAndRelation_conceptEvidence unused:" + tmp); - - tmp = new ArrayList<>(scoreContributingRows_clazzPairAndRelation.keySet()); - tmp.removeAll(usedKey_scoreContributingRows_clazzPairAndRelation); - if (tmp.size() > 0) - System.err.println(tableId+"-scoreContributingRows_conceptPairAndRelation unused:" + tmp); - } -} +package uk.ac.shef.dcs.sti.core.algorithm.ji; + +import uk.ac.shef.dcs.sti.core.model.TAnnotation; + +import java.util.*; + +/** + * Created by zqz on 01/05/2015. + */ +public class TAnnotationJI extends TAnnotation { + + //==debug purpose + private Set usedKey_score_entityAndClazz = new HashSet<>(); + private Set usedKey_score_entityPairAndRelation = new HashSet<>(); + private Set usedKey_score_entityAndRelation = new HashSet<>(); + private Set usedKey_score_clazzPairAndRelation_rowEvidence = new HashSet<>(); + private Set usedKey_score_clazzPairAndRelation_headerEvidence = new HashSet<>(); + private Set usedKey_scoreContributingRows_clazzPairAndRelation = new HashSet<>(); + //==debug purpose + + private Map score_entityAndConcept = new HashMap<>(); + private Map score_entityPairAndRelation = new HashMap<>(); + private Map score_entityAndRelation = new HashMap<>(); + private Map score_clazzPairAndRelation_rowEvidence = new HashMap<>(); + private Map score_clazzPairAndRelation_headerEvidence = new HashMap<>(); + private Map> scoreContributingRows_clazzPairAndRelation = new HashMap<>(); + + public TAnnotationJI(int rows, int cols) { + super(rows, cols); + } + + public double getScoreEntityAndRelation(String entityId, String relationId) { + usedKey_score_entityAndRelation.add(createKeyPair(entityId, relationId)); + Double v = score_entityAndRelation.get(createKeyPair(entityId, relationId)); + if (v == null) + v = 0.0; + return v; + } + + public void setScoreEntityAndRelation(String entityId, String relationId, double score) { + score_entityAndRelation.put(createKeyPair(entityId, relationId), score); + } + + public double getScoreEntityAndConceptSimilarity(String entityId, String conceptId) { + usedKey_score_entityAndClazz.add(createKeyPair(entityId, conceptId)); + Double v = score_entityAndConcept.get(createKeyPair(entityId, conceptId)); + if (v == null) + v = 0.0; + return v; + } + + public void setScoreEntityAndConceptSimilarity(String entityId, String conceptId, double score) { + score_entityAndConcept.put(createKeyPair(entityId, conceptId), score); + } + + private double getScoreClazzPairAndRelationFromHeaderEvidence(String sbjConceptId, String relationId, String objConceptId) { + usedKey_score_clazzPairAndRelation_headerEvidence.add(createKeyTriple(sbjConceptId, objConceptId, relationId)); + Double v = score_clazzPairAndRelation_headerEvidence.get(createKeyTriple(sbjConceptId, objConceptId, relationId)); + if (v == null) + v = 0.0; + return v; + } + + private double getScoreClazzPairAndRelationFromRowEvidence(String sbjConceptId, String relationId, String objConceptId) { + usedKey_score_clazzPairAndRelation_rowEvidence.add(createKeyTriple(sbjConceptId, objConceptId, relationId)); + Double v = score_clazzPairAndRelation_rowEvidence.get(createKeyTriple(sbjConceptId, objConceptId, relationId)); + if (v == null) + v = 0.0; + return v; + } + + + public double getScoreClazzPairAndRelation(String sbjConceptId, String relationId, String objConceptId, int norm) { + double v = getScoreClazzPairAndRelationFromHeaderEvidence(sbjConceptId, relationId, objConceptId); + + Map cells = scoreContributingRows_clazzPairAndRelation.get( + createKeyTriple(sbjConceptId, objConceptId, relationId)); + usedKey_scoreContributingRows_clazzPairAndRelation.add(createKeyTriple(sbjConceptId, objConceptId, relationId)); + + if (cells != null) + v = v + Math.sqrt(cells.size() / (double) norm); + return v; + } + + + public void setScoreClazzPairAndRelationFromHeaderEvidence(String sbjConceptId, String relationId, String objConceptId, + double score) { + score_clazzPairAndRelation_headerEvidence.put(createKeyTriple(sbjConceptId, objConceptId, relationId), score); + } + + + /** + * @param row the row of cell where an entity has voted for this concept and relation + * @param sbjConceptId + * @param relationId + * @param score + */ + public void setScoreClazzPairAndRelationFromRows(int row, + String sbjConceptId, + String relationId, + String objConceptId, double score) { + String key = createKeyTriple(sbjConceptId, objConceptId, relationId); + Map contributingRows = scoreContributingRows_clazzPairAndRelation.get( + key + ); + if (contributingRows == null) { + contributingRows = new HashMap<>(); + contributingRows.put(String.valueOf(row), score); + score_clazzPairAndRelation_rowEvidence.put(key, score); + scoreContributingRows_clazzPairAndRelation.put(key, contributingRows); + } else { + Double existingScore = contributingRows.get(String.valueOf(row)); + if (existingScore == null) { + contributingRows.put(String.valueOf(row), score); + score_clazzPairAndRelation_rowEvidence.put(key, + score + getScoreClazzPairAndRelationFromRowEvidence(sbjConceptId, relationId, objConceptId)); + scoreContributingRows_clazzPairAndRelation.put(key, contributingRows); + } else if (existingScore < score) { //previously this cell has contributed to a computeElementScores, but that is smaller + //so we need to recalculate the instanceEvidence computeElementScores using the new computeElementScores + contributingRows.put(String.valueOf(row), score); + double diff = score - existingScore; + score_clazzPairAndRelation_rowEvidence.put(key, + diff + getScoreClazzPairAndRelationFromRowEvidence(sbjConceptId, relationId, objConceptId)); + } + } + } + + public double getScoreEntityPairAndRelation(String sbjEntityId, String objEntityId, String relationId) { + usedKey_score_entityPairAndRelation.add(createKeyTriple(sbjEntityId, objEntityId, relationId)); + Double v = score_entityPairAndRelation.get(createKeyTriple(sbjEntityId, objEntityId, relationId)); + if (v == null) + v = 0.0; + return v; + } + + public void setScoreEntityPairAndRelation(String sbjEntityId, String objEntityId, String relationId, double score) { + score_entityPairAndRelation.put(createKeyTriple(sbjEntityId, objEntityId, relationId), score); + } + + private String createKeyTriple(String sbjId, String objId, String relation) { + return sbjId + ">" + objId + "|" + relation; + } + + private String createKeyPair(String s1, String s2) { + return s1 + "|" + s2; + } + + protected void debugAffinity(String tableId) { + List tmp = new ArrayList<>(score_entityAndConcept.keySet()); + tmp.removeAll(usedKey_score_entityAndClazz); + if (tmp.size() > 0) + System.err.println(tableId+"-score_entityAndConcept unused:" + tmp); + + tmp = new ArrayList<>(score_entityPairAndRelation.keySet()); + tmp.removeAll(usedKey_score_entityPairAndRelation); + if (tmp.size() > 0) + System.err.println(tableId+"-score_entityPairAndRelation unused:" + tmp); + + tmp = new ArrayList<>(score_entityAndRelation.keySet()); + tmp.removeAll(usedKey_score_entityAndRelation); + if (tmp.size() > 0) + System.err.println(tableId+"-score_entityAndRelation unused:" + tmp); + + /*tmp = new ArrayList(score_conceptPairAndRelation_instaceEvidence.keySet()); + tmp.removeAll(usedKey_score_conceptPairAndRelation_instaceEvidence); + if (tmp.size() > 0) + System.err.println("score_conceptPairAndRelation_instaceEvidence unused:" + tmp);*/ + + tmp = new ArrayList<>(score_clazzPairAndRelation_headerEvidence.keySet()); + tmp.removeAll(usedKey_score_clazzPairAndRelation_headerEvidence); + if (tmp.size() > 0) + System.err.println(tableId+"-score_conceptPairAndRelation_conceptEvidence unused:" + tmp); + + tmp = new ArrayList<>(scoreContributingRows_clazzPairAndRelation.keySet()); + tmp.removeAll(usedKey_scoreContributingRows_clazzPairAndRelation); + if (tmp.size() > 0) + System.err.println(tableId+"-scoreContributingRows_conceptPairAndRelation unused:" + tmp); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/VariableType.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/VariableType.java index d59b32cb..6fcb1cd8 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/VariableType.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/VariableType.java @@ -1,20 +1,20 @@ -package uk.ac.shef.dcs.sti.core.algorithm.ji; - -/** - * Created by zqz on 12/05/2015. - */ -public enum VariableType { - - CELL("cell"), - HEADER("header"), - RELATION("relation"); - - private String label; - VariableType(String label){ - this.label=label; - } - public String toString(){ - return label; - } - -} +package uk.ac.shef.dcs.sti.core.algorithm.ji; + +/** + * Created by zqz on 12/05/2015. + */ +public enum VariableType { + + CELL("cell"), + HEADER("header"), + RELATION("relation"); + + private String label; + VariableType(String label){ + this.label=label; + } + public String toString(){ + return label; + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilder.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilder.java index 3d2f4bb5..f5a70f69 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilder.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilder.java @@ -1,118 +1,118 @@ -package uk.ac.shef.dcs.sti.core.algorithm.ji.factorgraph; - -import cc.mallet.grmm.types.Variable; -import cc.mallet.types.LabelAlphabet; - -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -/** - * Created by zqz on 12/05/2015. - */ -abstract class FactorBuilder { - - protected void checkVariableOutcomeUsage(double potential, String key, Map varOutcomeHasNonZeroPotential) { - Boolean hasNonZeroPotential = - varOutcomeHasNonZeroPotential. - get(key); - if (hasNonZeroPotential == null) { - hasNonZeroPotential = false; - varOutcomeHasNonZeroPotential.put(key, hasNonZeroPotential); - } - if (potential > 0) { - if (!hasNonZeroPotential) - varOutcomeHasNonZeroPotential.put(key, true); - } - } - - protected boolean isValidGraphAffinity(double[] potential1, Map affinityValues) { - int countZero = 0; - double min = Double.MAX_VALUE; - for (int i = 0; i < potential1.length; i++) { - if (potential1[i] == 0) - countZero++; - if (potential1[i] < min) - min = potential1[i]; - } - - //System.out.println(note + ":" + countZero + "/" + potential1.length); - if (countZero == potential1.length) - return false; - - if (affinityValues != null && potential1.length - countZero != affinityValues.size()) - return false; - return true; - } - - protected Variable createDummyVariable(String label) { - LabelAlphabet dummyLA = new LabelAlphabet(); - dummyLA.lookupLabel(label); - Variable v = new Variable(dummyLA); - v.setLabel(label); - return v; - } - - /** - * @param affinity_values_between_variable_outcomes in the key, the first element (int) must correspond to the index in cellVar; the second must - * correpsond to the index in headerVar - * @param firstVar - * @param secondVar - * @return - */ - protected double[] computePotential( - Map affinity_values_between_variable_outcomes, - Variable firstVar, - Variable secondVar) { - int dimensionFirstVar = firstVar.getNumOutcomes(); - int dimensionSecondVar = secondVar.getNumOutcomes(); - double[] res = new double[dimensionFirstVar * dimensionSecondVar]; - for (int first = 0; first < dimensionFirstVar; first++) { - for (int second = 0; second < dimensionSecondVar; second++) { - String key = first + "," + second; - Double affinity = affinity_values_between_variable_outcomes.get(key); - - if (affinity == null) - affinity = 0.0; - res[first * dimensionSecondVar + second] = affinity; - } - } - return res; - } - - - /** - * correpsond to the index in headerVar - * - * @param firstHeaderVar - * @param relationVar - * @return - */ - protected double[] computePotential( - Map affinity_values, - Variable firstHeaderVar, - Variable relationVar, - Variable secondHeaderVar, - Map relationIndex_forwardRelation) { - int dimensionFirstHeaderVar = firstHeaderVar.getNumOutcomes(); - int dimensionSecondVar = relationVar.getNumOutcomes(); - int dimensionThirdVar = secondHeaderVar.getNumOutcomes(); - double[] res = new double[dimensionFirstHeaderVar * dimensionSecondVar * dimensionThirdVar]; - Set indexes = new HashSet(); - for (int f = 0; f < dimensionFirstHeaderVar; f++) { - for (int s = 0; s < dimensionSecondVar; s++) { - for (int t = 0; t < dimensionThirdVar; t++) { - Double affinity = affinity_values.get(f + ">" + s + ">" + t); - if (affinity == null) affinity = 0.0; - int index = f * dimensionSecondVar * dimensionThirdVar + - s * dimensionThirdVar + t; - res[index] = affinity; - if (affinity != 0) - indexes.add(index); - } - } - } - //System.out.println(cc); - return res; - } -} +package uk.ac.shef.dcs.sti.core.algorithm.ji.factorgraph; + +import cc.mallet.grmm.types.Variable; +import cc.mallet.types.LabelAlphabet; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * Created by zqz on 12/05/2015. + */ +abstract class FactorBuilder { + + protected void checkVariableOutcomeUsage(double potential, String key, Map varOutcomeHasNonZeroPotential) { + Boolean hasNonZeroPotential = + varOutcomeHasNonZeroPotential. + get(key); + if (hasNonZeroPotential == null) { + hasNonZeroPotential = false; + varOutcomeHasNonZeroPotential.put(key, hasNonZeroPotential); + } + if (potential > 0) { + if (!hasNonZeroPotential) + varOutcomeHasNonZeroPotential.put(key, true); + } + } + + protected boolean isValidGraphAffinity(double[] potential1, Map affinityValues) { + int countZero = 0; + double min = Double.MAX_VALUE; + for (int i = 0; i < potential1.length; i++) { + if (potential1[i] == 0) + countZero++; + if (potential1[i] < min) + min = potential1[i]; + } + + //System.out.println(note + ":" + countZero + "/" + potential1.length); + if (countZero == potential1.length) + return false; + + if (affinityValues != null && potential1.length - countZero != affinityValues.size()) + return false; + return true; + } + + protected Variable createDummyVariable(String label) { + LabelAlphabet dummyLA = new LabelAlphabet(); + dummyLA.lookupLabel(label); + Variable v = new Variable(dummyLA); + v.setLabel(label); + return v; + } + + /** + * @param affinity_values_between_variable_outcomes in the key, the first element (int) must correspond to the index in cellVar; the second must + * correpsond to the index in headerVar + * @param firstVar + * @param secondVar + * @return + */ + protected double[] computePotential( + Map affinity_values_between_variable_outcomes, + Variable firstVar, + Variable secondVar) { + int dimensionFirstVar = firstVar.getNumOutcomes(); + int dimensionSecondVar = secondVar.getNumOutcomes(); + double[] res = new double[dimensionFirstVar * dimensionSecondVar]; + for (int first = 0; first < dimensionFirstVar; first++) { + for (int second = 0; second < dimensionSecondVar; second++) { + String key = first + "," + second; + Double affinity = affinity_values_between_variable_outcomes.get(key); + + if (affinity == null) + affinity = 0.0; + res[first * dimensionSecondVar + second] = affinity; + } + } + return res; + } + + + /** + * correpsond to the index in headerVar + * + * @param firstHeaderVar + * @param relationVar + * @return + */ + protected double[] computePotential( + Map affinity_values, + Variable firstHeaderVar, + Variable relationVar, + Variable secondHeaderVar, + Map relationIndex_forwardRelation) { + int dimensionFirstHeaderVar = firstHeaderVar.getNumOutcomes(); + int dimensionSecondVar = relationVar.getNumOutcomes(); + int dimensionThirdVar = secondHeaderVar.getNumOutcomes(); + double[] res = new double[dimensionFirstHeaderVar * dimensionSecondVar * dimensionThirdVar]; + Set indexes = new HashSet(); + for (int f = 0; f < dimensionFirstHeaderVar; f++) { + for (int s = 0; s < dimensionSecondVar; s++) { + for (int t = 0; t < dimensionThirdVar; t++) { + Double affinity = affinity_values.get(f + ">" + s + ">" + t); + if (affinity == null) affinity = 0.0; + int index = f * dimensionSecondVar * dimensionThirdVar + + s * dimensionThirdVar + t; + res[index] = affinity; + if (affinity != 0) + indexes.add(index); + } + } + } + //System.out.println(cc); + return res; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCell.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCell.java index 7d2ecf78..3241df77 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCell.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCell.java @@ -1,77 +1,77 @@ -package uk.ac.shef.dcs.sti.core.algorithm.ji.factorgraph; - -import cc.mallet.grmm.types.*; -import cc.mallet.types.LabelAlphabet; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.algorithm.ji.JIAdaptedEntityScorer; -import uk.ac.shef.dcs.sti.core.algorithm.ji.VariableType; -import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; -import uk.ac.shef.dcs.sti.core.model.TAnnotation; - -import java.util.*; - -/** - * Created by zqz on 12/05/2015. - */ -class FactorBuilderCell extends FactorBuilder{ - - protected Map cellVarOutcomePosition = new HashMap<>(); - - public Map addFactors(TAnnotation annotation, FactorGraph graph, - Map typeOfVariable, - Set columns - ) throws STIException { - Map variables = new HashMap<>(); - for (int row = 0; row < annotation.getRows(); row++) { - for (int col = 0; col < annotation.getCols(); col++) { - if(columns!=null&&!columns.contains(col)) continue; - Variable dummyCell = createDummyVariable("dummyCell("+row+","+col+")"); - - TCellAnnotation[] candidateEntityAnnotations = annotation.getContentCellAnnotations(row, col); - if (candidateEntityAnnotations.length == 0) - continue; - String cellPosition = String.valueOf(row) + "," + String.valueOf(col); - - LabelAlphabet candidateIndex_cell = new LabelAlphabet(); - List scores=new ArrayList<>(); - - for (int i = 0; i < candidateEntityAnnotations.length; i++) { - TCellAnnotation ca = candidateEntityAnnotations[i]; - double score=ca.getScoreElements().get( - JIAdaptedEntityScorer.SCORE_FINAL); - if(score==0) - continue; - - candidateIndex_cell.lookupIndex(ca.getAnnotation().getId()); - scores.add(score); - } - if(scores.size()==0) - continue; - double[] compatibility = new double[scores.size()]; - for(int i=0; i addFactors(TAnnotation annotation, FactorGraph graph, - Map typeOfVariable - ) throws STIException { - return addFactors(annotation, graph, typeOfVariable, null); - } -} +package uk.ac.shef.dcs.sti.core.algorithm.ji.factorgraph; + +import cc.mallet.grmm.types.*; +import cc.mallet.types.LabelAlphabet; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.algorithm.ji.JIAdaptedEntityScorer; +import uk.ac.shef.dcs.sti.core.algorithm.ji.VariableType; +import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; +import uk.ac.shef.dcs.sti.core.model.TAnnotation; + +import java.util.*; + +/** + * Created by zqz on 12/05/2015. + */ +class FactorBuilderCell extends FactorBuilder{ + + protected Map cellVarOutcomePosition = new HashMap<>(); + + public Map addFactors(TAnnotation annotation, FactorGraph graph, + Map typeOfVariable, + Set columns + ) throws STIException { + Map variables = new HashMap<>(); + for (int row = 0; row < annotation.getRows(); row++) { + for (int col = 0; col < annotation.getCols(); col++) { + if(columns!=null&&!columns.contains(col)) continue; + Variable dummyCell = createDummyVariable("dummyCell("+row+","+col+")"); + + TCellAnnotation[] candidateEntityAnnotations = annotation.getContentCellAnnotations(row, col); + if (candidateEntityAnnotations.length == 0) + continue; + String cellPosition = String.valueOf(row) + "," + String.valueOf(col); + + LabelAlphabet candidateIndex_cell = new LabelAlphabet(); + List scores=new ArrayList<>(); + + for (int i = 0; i < candidateEntityAnnotations.length; i++) { + TCellAnnotation ca = candidateEntityAnnotations[i]; + double score=ca.getScoreElements().get( + JIAdaptedEntityScorer.SCORE_FINAL); + if(score==0) + continue; + + candidateIndex_cell.lookupIndex(ca.getAnnotation().getId()); + scores.add(score); + } + if(scores.size()==0) + continue; + double[] compatibility = new double[scores.size()]; + for(int i=0; i addFactors(TAnnotation annotation, FactorGraph graph, + Map typeOfVariable + ) throws STIException { + return addFactors(annotation, graph, typeOfVariable, null); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCellAndRelation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCellAndRelation.java index f636540d..64b05e06 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCellAndRelation.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderCellAndRelation.java @@ -1,133 +1,133 @@ -package uk.ac.shef.dcs.sti.core.algorithm.ji.factorgraph; - -import cc.mallet.grmm.types.*; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.algorithm.ji.DebuggingUtil; -import uk.ac.shef.dcs.sti.core.algorithm.ji.TAnnotationJI; -import uk.ac.shef.dcs.sti.core.model.RelationColumns; - -import java.util.*; - -/** - * Created by zqz on 12/05/2015. - */ -class FactorBuilderCellAndRelation extends FactorBuilder { - - public void addFactors(Map relationVariables, - Map cellVariables, - TAnnotationJI annotation, - FactorGraph graph, - Map relationVarOutcomeDirection, - String tableId, Set columns) throws STIException { - List processed = new ArrayList<>(); - for (int c1 = 0; c1 < annotation.getCols(); c1++) { - for (int c2 = 0; c2 < annotation.getCols(); c2++) { - if (c1 == c2) continue; - if(columns!=null&& !columns.contains(c1)&&columns.contains(c2)) continue; - - if (processed.contains(c1 + "," + c2) || processed.contains(c2 + "," + c1)) continue; - Variable relation_var = relationVariables.get(c1 + "," + c2); - if (relation_var == null) - relation_var = relationVariables.get(c2 + "," + c1); - if (relation_var != null) { - //there is a relation between c1, c2, go thru each row, to create factor between the cell pair and relation - for (int r = 0; r < annotation.getRows(); r++) { - Variable sbj_cell_var = cellVariables.get(r + "," + c1); - Variable obj_cell_var = cellVariables.get(r + "," + c2); - createCellRelationFactor(sbj_cell_var, obj_cell_var, relation_var, - annotation, graph, relationVarOutcomeDirection, tableId); - } - } - processed.add(c1 + "," + c2); - processed.add(c2 + "," + c1); - } - } - - } - - private void createCellRelationFactor(Variable sbjCellVar, - Variable objCellVar, - Variable relationVar, - TAnnotationJI annotation, - FactorGraph graph, - Map relationVarOutcomeDirection, - String tableId) throws STIException { - if (sbjCellVar != null && objCellVar != null) { - Map affinity_scores = new HashMap<>(); - Map relationIndex_forwardRelation = new HashMap<>(); - for (int s = 0; s < sbjCellVar.getNumOutcomes(); s++) { - String sbj = sbjCellVar.getLabelAlphabet().lookupLabel(s).toString(); - for (int r = 0; r < relationVar.getNumOutcomes(); r++) { - String rel = relationVar.getLabelAlphabet().lookupLabel(r).toString(); - RelationColumns direction = relationVarOutcomeDirection.get(rel); - boolean forwardRelation = true; - if (direction.getObjectCol() < direction.getSubjectCol()) forwardRelation = false; - if (forwardRelation) - relationIndex_forwardRelation.put(r, true); - else - relationIndex_forwardRelation.put(r, false); - - for (int o = 0; o < objCellVar.getNumOutcomes(); o++) { - String obj = objCellVar.getLabelAlphabet().lookupLabel(o).toString(); - double score; - if (forwardRelation) { - score = annotation.getScoreEntityPairAndRelation(sbj, obj, rel); - score = score + annotation.getScoreEntityAndRelation(sbj, rel); - if (score > 0) - updateAffinity(affinity_scores, sbjCellVar, s, objCellVar, o, r, score); - } else { - score = annotation.getScoreEntityPairAndRelation(obj, sbj, rel); - score = score + annotation.getScoreEntityAndRelation(obj, rel); - if (score > 0) - updateAffinity(affinity_scores, sbjCellVar, s, objCellVar, o, r, score); - } - } - } - } - if (affinity_scores.size() > 0) { - double[] compatibility; - if (sbjCellVar.getIndex() < objCellVar.getIndex()) - compatibility = computePotential(affinity_scores, - sbjCellVar, objCellVar, relationVar, relationIndex_forwardRelation); - else - compatibility = computePotential(affinity_scores, - objCellVar, sbjCellVar, relationVar, relationIndex_forwardRelation); - if (isValidGraphAffinity(compatibility, affinity_scores)) { - Variable[] vars; - if(sbjCellVar.getIndex() < objCellVar.getIndex()) - vars= new Variable[]{sbjCellVar, objCellVar, relationVar}; - else - vars= new Variable[]{objCellVar, sbjCellVar, relationVar}; - - TableFactor factor = new TableFactor(vars, compatibility); - DebuggingUtil.debugFactorAndAffinity(factor, affinity_scores, tableId); - graph.addFactor(factor); - } - } - else{ - throw new STIException("Fatal: inconsistency detected on graph, while mapping affinity scores to potentials"); - } - } - } - - private void updateAffinity(Map affinity_scores, - Variable sbjCellVar, int sbjVarOutcomeIndex, - Variable objCellVar, int objVarOutcomeIndex, - int relationVarOutcomeIndex, double score) { - if (sbjCellVar.getIndex() < objCellVar.getIndex()) { - affinity_scores.put(sbjVarOutcomeIndex + ">" + objVarOutcomeIndex + ">" + relationVarOutcomeIndex, score); - } else { - affinity_scores.put(objVarOutcomeIndex + ">" + sbjVarOutcomeIndex + ">" + relationVarOutcomeIndex, score); - } - } - - public void addFactors(Map relationVariables, - Map cellVariables, - TAnnotationJI annotation, - FactorGraph graph, - Map relationVarOutcomeDirection, - String tableId) throws STIException { - addFactors(relationVariables, cellVariables, annotation, graph, - relationVarOutcomeDirection, tableId, null); - } -} +package uk.ac.shef.dcs.sti.core.algorithm.ji.factorgraph; + +import cc.mallet.grmm.types.*; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.algorithm.ji.DebuggingUtil; +import uk.ac.shef.dcs.sti.core.algorithm.ji.TAnnotationJI; +import uk.ac.shef.dcs.sti.core.model.RelationColumns; + +import java.util.*; + +/** + * Created by zqz on 12/05/2015. + */ +class FactorBuilderCellAndRelation extends FactorBuilder { + + public void addFactors(Map relationVariables, + Map cellVariables, + TAnnotationJI annotation, + FactorGraph graph, + Map relationVarOutcomeDirection, + String tableId, Set columns) throws STIException { + List processed = new ArrayList<>(); + for (int c1 = 0; c1 < annotation.getCols(); c1++) { + for (int c2 = 0; c2 < annotation.getCols(); c2++) { + if (c1 == c2) continue; + if(columns!=null&& !columns.contains(c1)&&columns.contains(c2)) continue; + + if (processed.contains(c1 + "," + c2) || processed.contains(c2 + "," + c1)) continue; + Variable relation_var = relationVariables.get(c1 + "," + c2); + if (relation_var == null) + relation_var = relationVariables.get(c2 + "," + c1); + if (relation_var != null) { + //there is a relation between c1, c2, go thru each row, to create factor between the cell pair and relation + for (int r = 0; r < annotation.getRows(); r++) { + Variable sbj_cell_var = cellVariables.get(r + "," + c1); + Variable obj_cell_var = cellVariables.get(r + "," + c2); + createCellRelationFactor(sbj_cell_var, obj_cell_var, relation_var, + annotation, graph, relationVarOutcomeDirection, tableId); + } + } + processed.add(c1 + "," + c2); + processed.add(c2 + "," + c1); + } + } + + } + + private void createCellRelationFactor(Variable sbjCellVar, + Variable objCellVar, + Variable relationVar, + TAnnotationJI annotation, + FactorGraph graph, + Map relationVarOutcomeDirection, + String tableId) throws STIException { + if (sbjCellVar != null && objCellVar != null) { + Map affinity_scores = new HashMap<>(); + Map relationIndex_forwardRelation = new HashMap<>(); + for (int s = 0; s < sbjCellVar.getNumOutcomes(); s++) { + String sbj = sbjCellVar.getLabelAlphabet().lookupLabel(s).toString(); + for (int r = 0; r < relationVar.getNumOutcomes(); r++) { + String rel = relationVar.getLabelAlphabet().lookupLabel(r).toString(); + RelationColumns direction = relationVarOutcomeDirection.get(rel); + boolean forwardRelation = true; + if (direction.getObjectCol() < direction.getSubjectCol()) forwardRelation = false; + if (forwardRelation) + relationIndex_forwardRelation.put(r, true); + else + relationIndex_forwardRelation.put(r, false); + + for (int o = 0; o < objCellVar.getNumOutcomes(); o++) { + String obj = objCellVar.getLabelAlphabet().lookupLabel(o).toString(); + double score; + if (forwardRelation) { + score = annotation.getScoreEntityPairAndRelation(sbj, obj, rel); + score = score + annotation.getScoreEntityAndRelation(sbj, rel); + if (score > 0) + updateAffinity(affinity_scores, sbjCellVar, s, objCellVar, o, r, score); + } else { + score = annotation.getScoreEntityPairAndRelation(obj, sbj, rel); + score = score + annotation.getScoreEntityAndRelation(obj, rel); + if (score > 0) + updateAffinity(affinity_scores, sbjCellVar, s, objCellVar, o, r, score); + } + } + } + } + if (affinity_scores.size() > 0) { + double[] compatibility; + if (sbjCellVar.getIndex() < objCellVar.getIndex()) + compatibility = computePotential(affinity_scores, + sbjCellVar, objCellVar, relationVar, relationIndex_forwardRelation); + else + compatibility = computePotential(affinity_scores, + objCellVar, sbjCellVar, relationVar, relationIndex_forwardRelation); + if (isValidGraphAffinity(compatibility, affinity_scores)) { + Variable[] vars; + if(sbjCellVar.getIndex() < objCellVar.getIndex()) + vars= new Variable[]{sbjCellVar, objCellVar, relationVar}; + else + vars= new Variable[]{objCellVar, sbjCellVar, relationVar}; + + TableFactor factor = new TableFactor(vars, compatibility); + DebuggingUtil.debugFactorAndAffinity(factor, affinity_scores, tableId); + graph.addFactor(factor); + } + } + else{ + throw new STIException("Fatal: inconsistency detected on graph, while mapping affinity scores to potentials"); + } + } + } + + private void updateAffinity(Map affinity_scores, + Variable sbjCellVar, int sbjVarOutcomeIndex, + Variable objCellVar, int objVarOutcomeIndex, + int relationVarOutcomeIndex, double score) { + if (sbjCellVar.getIndex() < objCellVar.getIndex()) { + affinity_scores.put(sbjVarOutcomeIndex + ">" + objVarOutcomeIndex + ">" + relationVarOutcomeIndex, score); + } else { + affinity_scores.put(objVarOutcomeIndex + ">" + sbjVarOutcomeIndex + ">" + relationVarOutcomeIndex, score); + } + } + + public void addFactors(Map relationVariables, + Map cellVariables, + TAnnotationJI annotation, + FactorGraph graph, + Map relationVarOutcomeDirection, + String tableId) throws STIException { + addFactors(relationVariables, cellVariables, annotation, graph, + relationVarOutcomeDirection, tableId, null); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeader.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeader.java index 4704b2ad..54a5b0b1 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeader.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeader.java @@ -1,71 +1,71 @@ -package uk.ac.shef.dcs.sti.core.algorithm.ji.factorgraph; - -import cc.mallet.grmm.types.*; -import cc.mallet.types.LabelAlphabet; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.algorithm.ji.JIClazzScorer; -import uk.ac.shef.dcs.sti.core.algorithm.ji.VariableType; -import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; -import uk.ac.shef.dcs.sti.core.model.TAnnotation; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -/** - * Created by zqz on 12/05/2015. - */ -class FactorBuilderHeader extends FactorBuilder { - - protected Map headerVarOutcomePosition = new HashMap<>(); - - public Map addFactors(TAnnotation annotation, - FactorGraph graph, - Map typeOfVariable, - Set columns) throws STIException { - Map variables = new HashMap<>(); - for (int col = 0; col < annotation.getCols(); col++) { - if(columns!=null && !columns.contains(col)) continue; - Variable dummyHeader = createDummyVariable("dummyHeader("+col+")"); - - TColumnHeaderAnnotation[] candidateClazz_header = annotation.getHeaderAnnotation(col); - if (candidateClazz_header.length == 0) - continue; - - String headerPosition = String.valueOf(col); - LabelAlphabet candidateIndex_header = new LabelAlphabet(); - - double[] compatibility = new double[candidateClazz_header.length]; - for (int i = 0; i < candidateClazz_header.length; i++) { - TColumnHeaderAnnotation ha = candidateClazz_header[i]; - candidateIndex_header.lookupIndex(ha.getAnnotation().getId()); - - compatibility[i] = ha.getScoreElements().get( - JIClazzScorer.SCORE_FINAL - ); - } - Variable variable_header = new Variable(candidateIndex_header); - variable_header.setLabel(VariableType.HEADER.toString() + "." + headerPosition); - typeOfVariable.put(variable_header, VariableType.HEADER.toString()); - headerVarOutcomePosition.put(variable_header, col); - variables.put(col, variable_header); - - if (isValidGraphAffinity(compatibility, null)) { - Variable[] vars = new Variable[]{dummyHeader, variable_header}; - //VarSet varSet = new HashVarSet(new Variable[]{dummyHeader, variable_header}); - TableFactor factor = new TableFactor(vars, compatibility); - graph.addFactor(factor); - } - else{ - throw new STIException("Fatal: inconsistency detected on graph, while mapping affinity scores to potentials"); - } - } - return variables; - } - - public Map addFactors(TAnnotation annotation, - FactorGraph graph, - Map typeOfVariable) throws STIException { - return addFactors(annotation, graph, typeOfVariable, null); - } -} +package uk.ac.shef.dcs.sti.core.algorithm.ji.factorgraph; + +import cc.mallet.grmm.types.*; +import cc.mallet.types.LabelAlphabet; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.algorithm.ji.JIClazzScorer; +import uk.ac.shef.dcs.sti.core.algorithm.ji.VariableType; +import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; +import uk.ac.shef.dcs.sti.core.model.TAnnotation; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +/** + * Created by zqz on 12/05/2015. + */ +class FactorBuilderHeader extends FactorBuilder { + + protected Map headerVarOutcomePosition = new HashMap<>(); + + public Map addFactors(TAnnotation annotation, + FactorGraph graph, + Map typeOfVariable, + Set columns) throws STIException { + Map variables = new HashMap<>(); + for (int col = 0; col < annotation.getCols(); col++) { + if(columns!=null && !columns.contains(col)) continue; + Variable dummyHeader = createDummyVariable("dummyHeader("+col+")"); + + TColumnHeaderAnnotation[] candidateClazz_header = annotation.getHeaderAnnotation(col); + if (candidateClazz_header.length == 0) + continue; + + String headerPosition = String.valueOf(col); + LabelAlphabet candidateIndex_header = new LabelAlphabet(); + + double[] compatibility = new double[candidateClazz_header.length]; + for (int i = 0; i < candidateClazz_header.length; i++) { + TColumnHeaderAnnotation ha = candidateClazz_header[i]; + candidateIndex_header.lookupIndex(ha.getAnnotation().getId()); + + compatibility[i] = ha.getScoreElements().get( + JIClazzScorer.SCORE_FINAL + ); + } + Variable variable_header = new Variable(candidateIndex_header); + variable_header.setLabel(VariableType.HEADER.toString() + "." + headerPosition); + typeOfVariable.put(variable_header, VariableType.HEADER.toString()); + headerVarOutcomePosition.put(variable_header, col); + variables.put(col, variable_header); + + if (isValidGraphAffinity(compatibility, null)) { + Variable[] vars = new Variable[]{dummyHeader, variable_header}; + //VarSet varSet = new HashVarSet(new Variable[]{dummyHeader, variable_header}); + TableFactor factor = new TableFactor(vars, compatibility); + graph.addFactor(factor); + } + else{ + throw new STIException("Fatal: inconsistency detected on graph, while mapping affinity scores to potentials"); + } + } + return variables; + } + + public Map addFactors(TAnnotation annotation, + FactorGraph graph, + Map typeOfVariable) throws STIException { + return addFactors(annotation, graph, typeOfVariable, null); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeaderAndCell.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeaderAndCell.java index f75bf748..1489592b 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeaderAndCell.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeaderAndCell.java @@ -1,80 +1,80 @@ -package uk.ac.shef.dcs.sti.core.algorithm.ji.factorgraph; - -import cc.mallet.grmm.types.*; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.algorithm.ji.DebuggingUtil; -import uk.ac.shef.dcs.sti.core.algorithm.ji.TAnnotationJI; -import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -/** - * Created by zqz on 12/05/2015. - */ -class FactorBuilderHeaderAndCell extends FactorBuilder { - - public void addFactors(Map cellVariables, - Map headerVariables, - TAnnotationJI annotation, - FactorGraph graph, - String tableId, Set columns) throws STIException { - for (int col = 0; col < annotation.getCols(); col++) { - if(columns!=null&& !columns.contains(col)) continue; - - Variable headerVar = headerVariables.get(col); - if (headerVar == null) continue; - - for (int row = 0; row < annotation.getRows(); row++) { - TCellAnnotation[] candidateEntityAnnotations = annotation.getContentCellAnnotations(row, col); - if (candidateEntityAnnotations.length == 0) continue; - Variable cellVar = cellVariables.get(row + "," + col); - if (cellVar == null) continue; - - Map affinity_values_between_variable_outcomes = new HashMap<>(); - //go thru every candidate cell entity - for (TCellAnnotation ca : candidateEntityAnnotations) { - //which concept it has a relation with - String entId = ca.getAnnotation().getId(); - int cellVarOutcomeIndex = cellVar.getLabelAlphabet().lookupIndex(entId, false); - if (cellVarOutcomeIndex < 0) continue; - for (int headerVarOutcomeIndex=0; headerVarOutcomeIndex 0) { - affinity_values_between_variable_outcomes.put( - cellVarOutcomeIndex + "," +headerVarOutcomeIndex , score - ); - } - } - } - - if (affinity_values_between_variable_outcomes.size() > 0) { - double[] compatibility = computePotential(affinity_values_between_variable_outcomes, - cellVar, headerVar); - if (isValidGraphAffinity(compatibility, affinity_values_between_variable_outcomes)) { - Variable[] vars = new Variable[]{cellVar, headerVar}; - //VarSet varSet = new HashVarSet(new Variable[]{cellVar, headerVar}); - TableFactor factor = new TableFactor(vars, compatibility); - DebuggingUtil.debugFactorAndAffinity(factor, affinity_values_between_variable_outcomes, tableId); - graph.addFactor(factor); - } - else{ - throw new STIException("Fatal: inconsistency detected on graph, while mapping affinity scores to potentials"); - } - } - } - } - } - - public void addFactors(Map cellVariables, - Map headerVariables, - TAnnotationJI annotation, - FactorGraph graph, - String tableId) throws STIException { - addFactors(cellVariables, headerVariables, annotation, graph, tableId, null); - } -} +package uk.ac.shef.dcs.sti.core.algorithm.ji.factorgraph; + +import cc.mallet.grmm.types.*; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.algorithm.ji.DebuggingUtil; +import uk.ac.shef.dcs.sti.core.algorithm.ji.TAnnotationJI; +import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +/** + * Created by zqz on 12/05/2015. + */ +class FactorBuilderHeaderAndCell extends FactorBuilder { + + public void addFactors(Map cellVariables, + Map headerVariables, + TAnnotationJI annotation, + FactorGraph graph, + String tableId, Set columns) throws STIException { + for (int col = 0; col < annotation.getCols(); col++) { + if(columns!=null&& !columns.contains(col)) continue; + + Variable headerVar = headerVariables.get(col); + if (headerVar == null) continue; + + for (int row = 0; row < annotation.getRows(); row++) { + TCellAnnotation[] candidateEntityAnnotations = annotation.getContentCellAnnotations(row, col); + if (candidateEntityAnnotations.length == 0) continue; + Variable cellVar = cellVariables.get(row + "," + col); + if (cellVar == null) continue; + + Map affinity_values_between_variable_outcomes = new HashMap<>(); + //go thru every candidate cell entity + for (TCellAnnotation ca : candidateEntityAnnotations) { + //which concept it has a relation with + String entId = ca.getAnnotation().getId(); + int cellVarOutcomeIndex = cellVar.getLabelAlphabet().lookupIndex(entId, false); + if (cellVarOutcomeIndex < 0) continue; + for (int headerVarOutcomeIndex=0; headerVarOutcomeIndex 0) { + affinity_values_between_variable_outcomes.put( + cellVarOutcomeIndex + "," +headerVarOutcomeIndex , score + ); + } + } + } + + if (affinity_values_between_variable_outcomes.size() > 0) { + double[] compatibility = computePotential(affinity_values_between_variable_outcomes, + cellVar, headerVar); + if (isValidGraphAffinity(compatibility, affinity_values_between_variable_outcomes)) { + Variable[] vars = new Variable[]{cellVar, headerVar}; + //VarSet varSet = new HashVarSet(new Variable[]{cellVar, headerVar}); + TableFactor factor = new TableFactor(vars, compatibility); + DebuggingUtil.debugFactorAndAffinity(factor, affinity_values_between_variable_outcomes, tableId); + graph.addFactor(factor); + } + else{ + throw new STIException("Fatal: inconsistency detected on graph, while mapping affinity scores to potentials"); + } + } + } + } + } + + public void addFactors(Map cellVariables, + Map headerVariables, + TAnnotationJI annotation, + FactorGraph graph, + String tableId) throws STIException { + addFactors(cellVariables, headerVariables, annotation, graph, tableId, null); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeaderAndRelation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeaderAndRelation.java index b61a9285..7be34431 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeaderAndRelation.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorBuilderHeaderAndRelation.java @@ -1,149 +1,149 @@ -package uk.ac.shef.dcs.sti.core.algorithm.ji.factorgraph; - -import cc.mallet.grmm.types.*; -import cc.mallet.grmm.types.Variable; -import cc.mallet.types.LabelAlphabet; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.algorithm.ji.DebuggingUtil; -import uk.ac.shef.dcs.sti.core.algorithm.ji.TAnnotationJI; -import uk.ac.shef.dcs.sti.core.algorithm.ji.VariableType; -import uk.ac.shef.dcs.sti.core.model.RelationColumns; -import uk.ac.shef.dcs.sti.core.model.TColumnColumnRelationAnnotation; - -import java.util.*; - -/** - * Created by zqz on 12/05/2015. - */ -class FactorBuilderHeaderAndRelation extends FactorBuilder { - - protected Map relationVarOutcomeDirection = new HashMap<>(); - public Map getRelationVarOutcomeDirection() { - return relationVarOutcomeDirection; - } - - public Map addFactors( - Map columnHeaders, - TAnnotationJI annotation, - FactorGraph graph, - Map typeOfVariable, - String tableId, Set columns) throws STIException { - Map result = new HashMap<>(); //for each pair of col, will only have 1 key stored, both both directional keys are processed - List processed = new ArrayList<>(); - Map> - candidateRelations = annotation.getColumncolumnRelations(); - for (int c1 = 0; c1 < annotation.getCols(); c1++) { - for (int c2 = 0; c2 < annotation.getCols(); c2++) { - if (c1 == c2) continue; - if(columns!=null&& !columns.contains(c1)&&columns.contains(c2)) continue; - - if (processed.contains(c1 + "," + c2) || processed.contains(c2 + "," + c1)) continue; - RelationColumns relation_direction = new RelationColumns(c1, c2); - RelationColumns relation_direction_reverse = new RelationColumns( - c2, c1 - ); - List candidate_relations = candidateRelations.get(relation_direction); - if (candidate_relations == null) { - candidate_relations = new ArrayList<>(); - } - List candidate_relations_reversed = candidateRelations.get(relation_direction_reverse); - if (candidate_relations_reversed != null) candidate_relations.addAll(candidate_relations_reversed); - //assuming that a relation can have only - //1 possible direction. not necessarily true always but reasonable - if (candidate_relations.size() == 0) - continue; - - Map affinity_scores = new HashMap(); - Variable column1_header_variable = columnHeaders.get(relation_direction.getSubjectCol()); - Variable column2_header_variable = columnHeaders.get(relation_direction.getObjectCol()); - if(column1_header_variable==null||column2_header_variable==null) - continue; - - Collections.sort(candidate_relations, (o1, o2) -> o1.getRelationURI().compareTo(o2.getRelationURI())); - LabelAlphabet candidateIndex_relation = new LabelAlphabet(); - - //key- outcome index of a relation var; value-true if relation is forward; false otherwise - Map relationIndex_forwardRelation = new HashMap<>(); - for (TColumnColumnRelationAnnotation hbr : candidate_relations) { - int index_relation = candidateIndex_relation.lookupIndex(hbr.toStringExpanded(), true); - RelationColumns current_rel_direction = hbr.getRelationColumns(); - relationVarOutcomeDirection.put(hbr.toStringExpanded(), current_rel_direction); - - if (column1_header_variable != null && column2_header_variable != null) { - for (int col1_outcome = 0; col1_outcome < column1_header_variable.getNumOutcomes(); col1_outcome++) { - String col1_header_concept_url = column1_header_variable.getLabelAlphabet().lookupLabel(col1_outcome).toString(); - for (int col2_outcome = 0; col2_outcome < column2_header_variable.getNumOutcomes(); col2_outcome++) { - String col2_header_concept_url = column2_header_variable.getLabelAlphabet().lookupLabel(col2_outcome).toString(); - double score = 0.0; - if (current_rel_direction.getSubjectCol() == c1 && current_rel_direction.getObjectCol() == c2) { - score = annotation.getScoreClazzPairAndRelation(col1_header_concept_url, - hbr.toStringExpanded(), col2_header_concept_url, annotation.getRows()); - } else if (current_rel_direction.getObjectCol() == c1 && current_rel_direction.getSubjectCol() == c2) { - - score = annotation.getScoreClazzPairAndRelation(col2_header_concept_url, - hbr.toStringExpanded(), col1_header_concept_url, annotation.getRows()); - } - if (score > 0) { - if (column1_header_variable.getIndex() < column2_header_variable.getIndex()) { - affinity_scores.put(col1_outcome + ">" + col2_outcome + ">" + index_relation, score); - relationIndex_forwardRelation.put(index_relation, true); - } else { - affinity_scores.put(col2_outcome + ">" + col1_outcome + ">" + index_relation, score); - relationIndex_forwardRelation.put(index_relation, false); - } - } - } - } - } - processed.add(c1 + "," + c2); - processed.add(c2 + "," + c1); - } - - Variable relationVariable = new Variable(candidateIndex_relation); - relationVariable.setLabel(VariableType.RELATION.toString() + "." + relation_direction.getSubjectCol() + "," + relation_direction.getObjectCol()); - typeOfVariable.put(relationVariable, VariableType.RELATION.toString()); - result.put(relation_direction.getSubjectCol() + "," + - relation_direction.getObjectCol(), relationVariable); - - //create potentials - double[] compatibility; - if (column1_header_variable.getIndex() < column2_header_variable.getIndex()) { - compatibility = computePotential(affinity_scores, - column1_header_variable, - column2_header_variable, relationVariable, relationIndex_forwardRelation); - } else { - compatibility = computePotential(affinity_scores, - column2_header_variable, - column1_header_variable, relationVariable, relationIndex_forwardRelation); - } - if (isValidGraphAffinity(compatibility, affinity_scores)) { - Variable[] vars = null; - if (column1_header_variable.getIndex() < column2_header_variable.getIndex()) - vars = new Variable[]{column1_header_variable, column2_header_variable, relationVariable}; - else - vars = new Variable[]{column2_header_variable, column1_header_variable, relationVariable}; - - TableFactor factor1 = new TableFactor(vars, compatibility); - DebuggingUtil.debugFactorAndAffinity(factor1, affinity_scores, tableId); - graph.addFactor(factor1); - } - else{ - throw new STIException("Fatal: inconsistency detected on graph, while mapping affinity scores to potentials"); - } - } - - } - return result; - } - - public Map addFactors( - Map columnHeaders, - TAnnotationJI annotation, - FactorGraph graph, - Map typeOfVariable, - String tableId) throws STIException { - return addFactors(columnHeaders, annotation, graph, typeOfVariable, tableId, null); - } - - -} +package uk.ac.shef.dcs.sti.core.algorithm.ji.factorgraph; + +import cc.mallet.grmm.types.*; +import cc.mallet.grmm.types.Variable; +import cc.mallet.types.LabelAlphabet; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.algorithm.ji.DebuggingUtil; +import uk.ac.shef.dcs.sti.core.algorithm.ji.TAnnotationJI; +import uk.ac.shef.dcs.sti.core.algorithm.ji.VariableType; +import uk.ac.shef.dcs.sti.core.model.RelationColumns; +import uk.ac.shef.dcs.sti.core.model.TColumnColumnRelationAnnotation; + +import java.util.*; + +/** + * Created by zqz on 12/05/2015. + */ +class FactorBuilderHeaderAndRelation extends FactorBuilder { + + protected Map relationVarOutcomeDirection = new HashMap<>(); + public Map getRelationVarOutcomeDirection() { + return relationVarOutcomeDirection; + } + + public Map addFactors( + Map columnHeaders, + TAnnotationJI annotation, + FactorGraph graph, + Map typeOfVariable, + String tableId, Set columns) throws STIException { + Map result = new HashMap<>(); //for each pair of col, will only have 1 key stored, both both directional keys are processed + List processed = new ArrayList<>(); + Map> + candidateRelations = annotation.getColumncolumnRelations(); + for (int c1 = 0; c1 < annotation.getCols(); c1++) { + for (int c2 = 0; c2 < annotation.getCols(); c2++) { + if (c1 == c2) continue; + if(columns!=null&& !columns.contains(c1)&&columns.contains(c2)) continue; + + if (processed.contains(c1 + "," + c2) || processed.contains(c2 + "," + c1)) continue; + RelationColumns relation_direction = new RelationColumns(c1, c2); + RelationColumns relation_direction_reverse = new RelationColumns( + c2, c1 + ); + List candidate_relations = candidateRelations.get(relation_direction); + if (candidate_relations == null) { + candidate_relations = new ArrayList<>(); + } + List candidate_relations_reversed = candidateRelations.get(relation_direction_reverse); + if (candidate_relations_reversed != null) candidate_relations.addAll(candidate_relations_reversed); + //assuming that a relation can have only + //1 possible direction. not necessarily true always but reasonable + if (candidate_relations.size() == 0) + continue; + + Map affinity_scores = new HashMap(); + Variable column1_header_variable = columnHeaders.get(relation_direction.getSubjectCol()); + Variable column2_header_variable = columnHeaders.get(relation_direction.getObjectCol()); + if(column1_header_variable==null||column2_header_variable==null) + continue; + + Collections.sort(candidate_relations, (o1, o2) -> o1.getRelationURI().compareTo(o2.getRelationURI())); + LabelAlphabet candidateIndex_relation = new LabelAlphabet(); + + //key- outcome index of a relation var; value-true if relation is forward; false otherwise + Map relationIndex_forwardRelation = new HashMap<>(); + for (TColumnColumnRelationAnnotation hbr : candidate_relations) { + int index_relation = candidateIndex_relation.lookupIndex(hbr.toStringExpanded(), true); + RelationColumns current_rel_direction = hbr.getRelationColumns(); + relationVarOutcomeDirection.put(hbr.toStringExpanded(), current_rel_direction); + + if (column1_header_variable != null && column2_header_variable != null) { + for (int col1_outcome = 0; col1_outcome < column1_header_variable.getNumOutcomes(); col1_outcome++) { + String col1_header_concept_url = column1_header_variable.getLabelAlphabet().lookupLabel(col1_outcome).toString(); + for (int col2_outcome = 0; col2_outcome < column2_header_variable.getNumOutcomes(); col2_outcome++) { + String col2_header_concept_url = column2_header_variable.getLabelAlphabet().lookupLabel(col2_outcome).toString(); + double score = 0.0; + if (current_rel_direction.getSubjectCol() == c1 && current_rel_direction.getObjectCol() == c2) { + score = annotation.getScoreClazzPairAndRelation(col1_header_concept_url, + hbr.toStringExpanded(), col2_header_concept_url, annotation.getRows()); + } else if (current_rel_direction.getObjectCol() == c1 && current_rel_direction.getSubjectCol() == c2) { + + score = annotation.getScoreClazzPairAndRelation(col2_header_concept_url, + hbr.toStringExpanded(), col1_header_concept_url, annotation.getRows()); + } + if (score > 0) { + if (column1_header_variable.getIndex() < column2_header_variable.getIndex()) { + affinity_scores.put(col1_outcome + ">" + col2_outcome + ">" + index_relation, score); + relationIndex_forwardRelation.put(index_relation, true); + } else { + affinity_scores.put(col2_outcome + ">" + col1_outcome + ">" + index_relation, score); + relationIndex_forwardRelation.put(index_relation, false); + } + } + } + } + } + processed.add(c1 + "," + c2); + processed.add(c2 + "," + c1); + } + + Variable relationVariable = new Variable(candidateIndex_relation); + relationVariable.setLabel(VariableType.RELATION.toString() + "." + relation_direction.getSubjectCol() + "," + relation_direction.getObjectCol()); + typeOfVariable.put(relationVariable, VariableType.RELATION.toString()); + result.put(relation_direction.getSubjectCol() + "," + + relation_direction.getObjectCol(), relationVariable); + + //create potentials + double[] compatibility; + if (column1_header_variable.getIndex() < column2_header_variable.getIndex()) { + compatibility = computePotential(affinity_scores, + column1_header_variable, + column2_header_variable, relationVariable, relationIndex_forwardRelation); + } else { + compatibility = computePotential(affinity_scores, + column2_header_variable, + column1_header_variable, relationVariable, relationIndex_forwardRelation); + } + if (isValidGraphAffinity(compatibility, affinity_scores)) { + Variable[] vars = null; + if (column1_header_variable.getIndex() < column2_header_variable.getIndex()) + vars = new Variable[]{column1_header_variable, column2_header_variable, relationVariable}; + else + vars = new Variable[]{column2_header_variable, column1_header_variable, relationVariable}; + + TableFactor factor1 = new TableFactor(vars, compatibility); + DebuggingUtil.debugFactorAndAffinity(factor1, affinity_scores, tableId); + graph.addFactor(factor1); + } + else{ + throw new STIException("Fatal: inconsistency detected on graph, while mapping affinity scores to potentials"); + } + } + + } + return result; + } + + public Map addFactors( + Map columnHeaders, + TAnnotationJI annotation, + FactorGraph graph, + Map typeOfVariable, + String tableId) throws STIException { + return addFactors(columnHeaders, annotation, graph, typeOfVariable, tableId, null); + } + + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorGraphBuilder.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorGraphBuilder.java index 4a15d4e0..dfaa815c 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorGraphBuilder.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/factorgraph/FactorGraphBuilder.java @@ -1,154 +1,154 @@ -package uk.ac.shef.dcs.sti.core.algorithm.ji.factorgraph; - -import cc.mallet.grmm.types.*; -import cc.mallet.grmm.types.Variable; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.algorithm.ji.TAnnotationJI; -import uk.ac.shef.dcs.sti.core.model.RelationColumns; -import uk.ac.shef.dcs.sti.core.model.TAnnotation; - -import java.util.*; - -/** - * Created by zqz on 01/05/2015. - */ -public class FactorGraphBuilder { - - protected FactorBuilderCell factorBuilderCell = new FactorBuilderCell(); - protected FactorBuilderHeader factorBuilderHeader = new FactorBuilderHeader(); - protected FactorBuilderHeaderAndRelation factorBuilderHeaderAndRelation = new FactorBuilderHeaderAndRelation(); - protected FactorBuilderHeaderAndCell factorBuilderHeaderAndCell=new FactorBuilderHeaderAndCell(); - protected FactorBuilderCellAndRelation factorBuilderCellAndRelation = new FactorBuilderCellAndRelation(); - - - protected Map typeOfVariable = new HashMap<>(); - - /** - * the table is firstly split into several maximum connected components (because it is possible - * that some columns do not have relation with other columns, thus forming a disconnected factor graph) - * then one graph is created for each of such maximum connected components - * @param annotation - * @param relationLearning - * @param tableId - * @return - * @throws STIException - */ - public List build(TAnnotationJI annotation, boolean relationLearning, String tableId) throws STIException{ - List out=new ArrayList<>(); - Map> subGraphs=computeDisconnectedTableColumns(annotation, relationLearning); - for(Map.Entry> ent: subGraphs.entrySet()) { - Set columns=ent.getValue(); - FactorGraph graph = new FactorGraph(); - //cell text and entity label - Map cellAnnotations = factorBuilderCell.addFactors(annotation, graph, - typeOfVariable, columns); - //column header and type label - Map columnHeaders = factorBuilderHeader.addFactors(annotation, graph, - typeOfVariable, columns); - //column type and cell entities - factorBuilderHeaderAndCell.addFactors(cellAnnotations, - columnHeaders, - annotation, - graph, tableId, - columns); - //relation and pair of column types - if (relationLearning) { - Map relations = factorBuilderHeaderAndRelation.addFactors( - columnHeaders, - annotation, - graph, - typeOfVariable, tableId, columns - ); - - //relation and entity pairs - factorBuilderCellAndRelation.addFactors( - relations, - cellAnnotations, - annotation, - graph, - factorBuilderHeaderAndRelation.getRelationVarOutcomeDirection(), tableId, columns - ); - } - - out.add(graph); - } - - return out; - } - - public String getTypeOfVariable(Variable variable) { - return typeOfVariable.get(variable); - } - - public int[] getCellPosition(Variable variable) { - return factorBuilderCell.cellVarOutcomePosition.get(variable); - } - - public int getHeaderPosition(Variable variable) { - return factorBuilderHeader.headerVarOutcomePosition.get(variable); - } - - public RelationColumns getRelationDirection(String varOutcomeLabel) { - return factorBuilderHeaderAndRelation.relationVarOutcomeDirection.get(varOutcomeLabel); - } - - - private Map> computeDisconnectedTableColumns(TAnnotation annotation, - boolean relationLearning) { - Map> result = new HashMap<>(); - int counter = 0; - String key = null; - if (relationLearning) { - List relationColumns = new ArrayList<>( - annotation.getColumncolumnRelations().keySet() - ); - if(relationColumns.size()>0) { - Collections.sort(relationColumns, (o1, o2) -> { - int c = Integer.valueOf(o1.getSubjectCol()).compareTo(o2.getSubjectCol()); - if (c == 0) - return Integer.valueOf(o1.getObjectCol()).compareTo(o2.getObjectCol()); - return c; - }); - for (RelationColumns rel : relationColumns) { - Set components = findContainingGraph(result, rel.getSubjectCol(), rel.getObjectCol()); - if (components == null) { - components = new HashSet<>(); - key = "part" + counter; - counter++; - } - components.add(rel.getSubjectCol()); - components.add(rel.getObjectCol()); - - result.put(key, components); - } - }else{//no relation, must be a single column - for (int c = 0; c < annotation.getCols(); c++) { - if (annotation.getHeaderAnnotation(c).length != 0) { - Set cols = new HashSet<>(); - cols.add(c); - result.put(String.valueOf(c), cols); - } - } - } - return result; - } else { - for (int c = 0; c < annotation.getCols(); c++) { - if (annotation.getHeaderAnnotation(c).length != 0) { - Set cols = new HashSet<>(); - cols.add(c); - result.put(String.valueOf(c), cols); - } - } - return result; - } - } - - private Set findContainingGraph(Map> parts, int col1, int col2) { - for (Set values : parts.values()) { - if (values.contains(col1) || values.contains(col2)) - return values; - } - return null; - } -} - +package uk.ac.shef.dcs.sti.core.algorithm.ji.factorgraph; + +import cc.mallet.grmm.types.*; +import cc.mallet.grmm.types.Variable; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.algorithm.ji.TAnnotationJI; +import uk.ac.shef.dcs.sti.core.model.RelationColumns; +import uk.ac.shef.dcs.sti.core.model.TAnnotation; + +import java.util.*; + +/** + * Created by zqz on 01/05/2015. + */ +public class FactorGraphBuilder { + + protected FactorBuilderCell factorBuilderCell = new FactorBuilderCell(); + protected FactorBuilderHeader factorBuilderHeader = new FactorBuilderHeader(); + protected FactorBuilderHeaderAndRelation factorBuilderHeaderAndRelation = new FactorBuilderHeaderAndRelation(); + protected FactorBuilderHeaderAndCell factorBuilderHeaderAndCell=new FactorBuilderHeaderAndCell(); + protected FactorBuilderCellAndRelation factorBuilderCellAndRelation = new FactorBuilderCellAndRelation(); + + + protected Map typeOfVariable = new HashMap<>(); + + /** + * the table is firstly split into several maximum connected components (because it is possible + * that some columns do not have relation with other columns, thus forming a disconnected factor graph) + * then one graph is created for each of such maximum connected components + * @param annotation + * @param relationLearning + * @param tableId + * @return + * @throws STIException + */ + public List build(TAnnotationJI annotation, boolean relationLearning, String tableId) throws STIException{ + List out=new ArrayList<>(); + Map> subGraphs=computeDisconnectedTableColumns(annotation, relationLearning); + for(Map.Entry> ent: subGraphs.entrySet()) { + Set columns=ent.getValue(); + FactorGraph graph = new FactorGraph(); + //cell text and entity label + Map cellAnnotations = factorBuilderCell.addFactors(annotation, graph, + typeOfVariable, columns); + //column header and type label + Map columnHeaders = factorBuilderHeader.addFactors(annotation, graph, + typeOfVariable, columns); + //column type and cell entities + factorBuilderHeaderAndCell.addFactors(cellAnnotations, + columnHeaders, + annotation, + graph, tableId, + columns); + //relation and pair of column types + if (relationLearning) { + Map relations = factorBuilderHeaderAndRelation.addFactors( + columnHeaders, + annotation, + graph, + typeOfVariable, tableId, columns + ); + + //relation and entity pairs + factorBuilderCellAndRelation.addFactors( + relations, + cellAnnotations, + annotation, + graph, + factorBuilderHeaderAndRelation.getRelationVarOutcomeDirection(), tableId, columns + ); + } + + out.add(graph); + } + + return out; + } + + public String getTypeOfVariable(Variable variable) { + return typeOfVariable.get(variable); + } + + public int[] getCellPosition(Variable variable) { + return factorBuilderCell.cellVarOutcomePosition.get(variable); + } + + public int getHeaderPosition(Variable variable) { + return factorBuilderHeader.headerVarOutcomePosition.get(variable); + } + + public RelationColumns getRelationDirection(String varOutcomeLabel) { + return factorBuilderHeaderAndRelation.relationVarOutcomeDirection.get(varOutcomeLabel); + } + + + private Map> computeDisconnectedTableColumns(TAnnotation annotation, + boolean relationLearning) { + Map> result = new HashMap<>(); + int counter = 0; + String key = null; + if (relationLearning) { + List relationColumns = new ArrayList<>( + annotation.getColumncolumnRelations().keySet() + ); + if(relationColumns.size()>0) { + Collections.sort(relationColumns, (o1, o2) -> { + int c = Integer.valueOf(o1.getSubjectCol()).compareTo(o2.getSubjectCol()); + if (c == 0) + return Integer.valueOf(o1.getObjectCol()).compareTo(o2.getObjectCol()); + return c; + }); + for (RelationColumns rel : relationColumns) { + Set components = findContainingGraph(result, rel.getSubjectCol(), rel.getObjectCol()); + if (components == null) { + components = new HashSet<>(); + key = "part" + counter; + counter++; + } + components.add(rel.getSubjectCol()); + components.add(rel.getObjectCol()); + + result.put(key, components); + } + }else{//no relation, must be a single column + for (int c = 0; c < annotation.getCols(); c++) { + if (annotation.getHeaderAnnotation(c).length != 0) { + Set cols = new HashSet<>(); + cols.add(c); + result.put(String.valueOf(c), cols); + } + } + } + return result; + } else { + for (int c = 0; c < annotation.getCols(); c++) { + if (annotation.getHeaderAnnotation(c).length != 0) { + Set cols = new HashSet<>(); + cols.add(c); + result.put(String.valueOf(c), cols); + } + } + return result; + } + } + + private Set findContainingGraph(Map> parts, int col1, int col2) { + for (Set values : parts.values()) { + if (values.contains(col1) || values.contains(col2)) + return values; + } + return null; + } +} + diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/EntityAndClazzSimilarityScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/EntityAndClazzSimilarityScorer.java index 8ab44fc1..4e00ad52 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/EntityAndClazzSimilarityScorer.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/EntityAndClazzSimilarityScorer.java @@ -1,89 +1,89 @@ -package uk.ac.shef.dcs.sti.core.algorithm.ji.similarity; - -import javafx.util.Pair; -import uk.ac.shef.dcs.kbsearch.KBSearchException; -import uk.ac.shef.dcs.kbsearch.model.Attribute; -import uk.ac.shef.dcs.sti.STIConstantProperty; -import uk.ac.shef.dcs.kbsearch.KBSearch; -import uk.ac.shef.dcs.sti.nlp.Lemmatizer; -import uk.ac.shef.dcs.sti.nlp.NLPTools; -import uk.ac.shef.dcs.kbsearch.model.Clazz; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.sti.util.CollectionUtils; -import uk.ac.shef.dcs.util.StringUtils; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -/** - * Created by zqz on 01/05/2015. - */ -public class EntityAndClazzSimilarityScorer { - - private List stopWords; - private Lemmatizer lemmatizer; - - public EntityAndClazzSimilarityScorer(List stopWords, - String nlpResources) throws IOException { - if (nlpResources != null) - lemmatizer = NLPTools.getInstance(nlpResources).getLemmatizer(); - this.stopWords = stopWords; - } - - public Pair computeEntityConceptSimilarity(Entity entity, - Clazz concept, - KBSearch kbSearch, - boolean useCache) throws KBSearchException { - double score = -1; - if (useCache) - score = kbSearch.findEntityClazzSimilarity(entity.getId(), concept.getId()); - boolean fromCache = false; - if (score != -1) - fromCache =true; - if (score == -1.0) { - List entityAttributes = entity.getAttributes(); - /* BOW OF THE ENTITY*/ - List entityBow = new ArrayList<>(); - for (Attribute f : entityAttributes) { - if (!STIConstantProperty.BOW_ENTITY_INCLUDE_INDIRECT_ATTRIBUTE && - !f.isDirect()) - continue; - - String value = f.getValue(); - if (!StringUtils.isPath(value)) - entityBow.addAll(StringUtils.toBagOfWords(value, true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)); - else - entityBow.add(value); - } - if (lemmatizer != null) - entityBow = lemmatizer.lemmatize(entityBow); - entityBow.removeAll(stopWords); - - List clazzAttributes = concept.getAttributes(); - List clazzBow = new ArrayList<>(); - for (Attribute f : clazzAttributes) { - if (!STIConstantProperty.BOW_ENTITY_INCLUDE_INDIRECT_ATTRIBUTE - && !f.isDirect()) - continue; - String value = f.getValue(); - if (!StringUtils.isPath(value)) - clazzBow.addAll(StringUtils.toBagOfWords(value, true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)); - else - clazzBow.add(value); - } - if (lemmatizer != null) - clazzBow = lemmatizer.lemmatize(clazzBow); - clazzBow.removeAll(stopWords); - - double contextOverlapScore = CollectionUtils.computeFrequencyWeightedDice( - entityBow, clazzBow - ); - //kbSearch.cacheEntityConceptSimilarity(entity_id,concept_url,contextOverlapScore,true); - return new Pair<>(contextOverlapScore, fromCache); - } else { - return new Pair<>(score, fromCache); - } - } - -} +package uk.ac.shef.dcs.sti.core.algorithm.ji.similarity; + +import javafx.util.Pair; +import uk.ac.shef.dcs.kbsearch.KBSearchException; +import uk.ac.shef.dcs.kbsearch.model.Attribute; +import uk.ac.shef.dcs.sti.STIConstantProperty; +import uk.ac.shef.dcs.kbsearch.KBSearch; +import uk.ac.shef.dcs.sti.nlp.Lemmatizer; +import uk.ac.shef.dcs.sti.nlp.NLPTools; +import uk.ac.shef.dcs.kbsearch.model.Clazz; +import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.sti.util.CollectionUtils; +import uk.ac.shef.dcs.util.StringUtils; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by zqz on 01/05/2015. + */ +public class EntityAndClazzSimilarityScorer { + + private List stopWords; + private Lemmatizer lemmatizer; + + public EntityAndClazzSimilarityScorer(List stopWords, + String nlpResources) throws IOException { + if (nlpResources != null) + lemmatizer = NLPTools.getInstance(nlpResources).getLemmatizer(); + this.stopWords = stopWords; + } + + public Pair computeEntityConceptSimilarity(Entity entity, + Clazz concept, + KBSearch kbSearch, + boolean useCache) throws KBSearchException { + double score = -1; + if (useCache) + score = kbSearch.findEntityClazzSimilarity(entity.getId(), concept.getId()); + boolean fromCache = false; + if (score != -1) + fromCache =true; + if (score == -1.0) { + List entityAttributes = entity.getAttributes(); + /* BOW OF THE ENTITY*/ + List entityBow = new ArrayList<>(); + for (Attribute f : entityAttributes) { + if (!STIConstantProperty.BOW_ENTITY_INCLUDE_INDIRECT_ATTRIBUTE && + !f.isDirect()) + continue; + + String value = f.getValue(); + if (!StringUtils.isPath(value)) + entityBow.addAll(StringUtils.toBagOfWords(value, true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)); + else + entityBow.add(value); + } + if (lemmatizer != null) + entityBow = lemmatizer.lemmatize(entityBow); + entityBow.removeAll(stopWords); + + List clazzAttributes = concept.getAttributes(); + List clazzBow = new ArrayList<>(); + for (Attribute f : clazzAttributes) { + if (!STIConstantProperty.BOW_ENTITY_INCLUDE_INDIRECT_ATTRIBUTE + && !f.isDirect()) + continue; + String value = f.getValue(); + if (!StringUtils.isPath(value)) + clazzBow.addAll(StringUtils.toBagOfWords(value, true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)); + else + clazzBow.add(value); + } + if (lemmatizer != null) + clazzBow = lemmatizer.lemmatize(clazzBow); + clazzBow.removeAll(stopWords); + + double contextOverlapScore = CollectionUtils.computeFrequencyWeightedDice( + entityBow, clazzBow + ); + //kbSearch.cacheEntityConceptSimilarity(entity_id,concept_url,contextOverlapScore,true); + return new Pair<>(contextOverlapScore, fromCache); + } else { + return new Pair<>(score, fromCache); + } + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/SimilarityComputerManager.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/SimilarityComputerManager.java index df16bff0..ac5cffae 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/SimilarityComputerManager.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/SimilarityComputerManager.java @@ -1,111 +1,111 @@ -package uk.ac.shef.dcs.sti.core.algorithm.ji.similarity; - -import javafx.util.Pair; -import org.apache.log4j.Logger; -import uk.ac.shef.dcs.kbsearch.KBSearch; -import uk.ac.shef.dcs.kbsearch.KBSearchException; -import uk.ac.shef.dcs.kbsearch.model.Clazz; -import uk.ac.shef.dcs.kbsearch.model.Entity; - -import java.util.*; - -/** - * Created by - on 13/04/2016. - */ -public class SimilarityComputerManager { - - - private static final Logger LOG = Logger.getLogger(SimilarityComputerManager.class.getName()); - private KBSearch kbSearch; - private boolean useCache; - private EntityAndClazzSimilarityScorer scorer; - public SimilarityComputerManager(boolean useCache, KBSearch kbSearch, - EntityAndClazzSimilarityScorer scorer){ - - this.useCache=useCache; - this.kbSearch=kbSearch; - this.scorer=scorer; - } - public Map computeSemanticSimilarity(int threads, Collection entities, - Collection concepts, - boolean biDirectional) throws KBSearchException { - Map result = new HashMap<>(); - List> pairs = new ArrayList<>(); - for (Entity e : entities) { - for (Clazz c : concepts) { - pairs.add(new Pair<>(e, c)); - } - } - - Collections.shuffle(pairs); - - List workers = new ArrayList<>(); - int size = pairs.size() / threads; - if (size < 5) { - threads = 1; - size = pairs.size(); - } else { - size = pairs.size() / threads; - int actualThreads = pairs.size() / size; - if (pairs.size() % size > 0) - actualThreads++; - threads = actualThreads; - } - LOG.info("\t\t\t>>" + threads + " threads, each processing " + size + " pairs..."); - for (int t = 0; t < threads; t++) { - int start = t * size; - int end = start + size; - List> selectedPairs = new ArrayList<>(); - for (int j = start; j < end && j < pairs.size(); j++) { - selectedPairs.add(pairs.get(j)); - } - SimilarityComputerThread thread = new SimilarityComputerThread( - useCache, selectedPairs, scorer, kbSearch - ); - workers.add(thread); - } - - //start all workers - for (SimilarityComputerThread w : workers) - w.start(); - - boolean allFinished = false; - while (!allFinished) { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - } - int finished = 0; - for (SimilarityComputerThread w : workers) { - if (w.isFinished()) - finished++; - } - if (finished == workers.size()) - allFinished = true; - } - - //collect results and caching - LOG.info("\t\t\t>> saving similarity scores..."); - boolean doCommit = false; - for (SimilarityComputerThread worker : workers) { - for (Map.Entry e : worker.getScores().entrySet()) { - String[] key = e.getKey(); - if (e.getValue() != -1) { - if (useCache && !key[2].equals("cache")) { - kbSearch.cacheEntityClazzSimilarity(key[0], key[1], e.getValue(), biDirectional, false); - doCommit = true; - } - result.put(key[0] + "," + key[1], e.getValue()); - } - } - } - if (useCache && doCommit) { - try { - kbSearch.commitChanges(); - } catch (Exception e) { - e.printStackTrace(); - } - } - return result; - } -} +package uk.ac.shef.dcs.sti.core.algorithm.ji.similarity; + +import javafx.util.Pair; +import org.apache.log4j.Logger; +import uk.ac.shef.dcs.kbsearch.KBSearch; +import uk.ac.shef.dcs.kbsearch.KBSearchException; +import uk.ac.shef.dcs.kbsearch.model.Clazz; +import uk.ac.shef.dcs.kbsearch.model.Entity; + +import java.util.*; + +/** + * Created by - on 13/04/2016. + */ +public class SimilarityComputerManager { + + + private static final Logger LOG = Logger.getLogger(SimilarityComputerManager.class.getName()); + private KBSearch kbSearch; + private boolean useCache; + private EntityAndClazzSimilarityScorer scorer; + public SimilarityComputerManager(boolean useCache, KBSearch kbSearch, + EntityAndClazzSimilarityScorer scorer){ + + this.useCache=useCache; + this.kbSearch=kbSearch; + this.scorer=scorer; + } + public Map computeSemanticSimilarity(int threads, Collection entities, + Collection concepts, + boolean biDirectional) throws KBSearchException { + Map result = new HashMap<>(); + List> pairs = new ArrayList<>(); + for (Entity e : entities) { + for (Clazz c : concepts) { + pairs.add(new Pair<>(e, c)); + } + } + + Collections.shuffle(pairs); + + List workers = new ArrayList<>(); + int size = pairs.size() / threads; + if (size < 5) { + threads = 1; + size = pairs.size(); + } else { + size = pairs.size() / threads; + int actualThreads = pairs.size() / size; + if (pairs.size() % size > 0) + actualThreads++; + threads = actualThreads; + } + LOG.info("\t\t\t>>" + threads + " threads, each processing " + size + " pairs..."); + for (int t = 0; t < threads; t++) { + int start = t * size; + int end = start + size; + List> selectedPairs = new ArrayList<>(); + for (int j = start; j < end && j < pairs.size(); j++) { + selectedPairs.add(pairs.get(j)); + } + SimilarityComputerThread thread = new SimilarityComputerThread( + useCache, selectedPairs, scorer, kbSearch + ); + workers.add(thread); + } + + //start all workers + for (SimilarityComputerThread w : workers) + w.start(); + + boolean allFinished = false; + while (!allFinished) { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + } + int finished = 0; + for (SimilarityComputerThread w : workers) { + if (w.isFinished()) + finished++; + } + if (finished == workers.size()) + allFinished = true; + } + + //collect results and caching + LOG.info("\t\t\t>> saving similarity scores..."); + boolean doCommit = false; + for (SimilarityComputerThread worker : workers) { + for (Map.Entry e : worker.getScores().entrySet()) { + String[] key = e.getKey(); + if (e.getValue() != -1) { + if (useCache && !key[2].equals("cache")) { + kbSearch.cacheEntityClazzSimilarity(key[0], key[1], e.getValue(), biDirectional, false); + doCommit = true; + } + result.put(key[0] + "," + key[1], e.getValue()); + } + } + } + if (useCache && doCommit) { + try { + kbSearch.commitChanges(); + } catch (Exception e) { + e.printStackTrace(); + } + } + return result; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/SimilarityComputerThread.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/SimilarityComputerThread.java index c23b9653..d85af859 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/SimilarityComputerThread.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/ji/similarity/SimilarityComputerThread.java @@ -1,62 +1,62 @@ -package uk.ac.shef.dcs.sti.core.algorithm.ji.similarity; - -import javafx.util.Pair; -import org.apache.commons.lang.exception.ExceptionUtils; -import org.apache.log4j.Logger; -import uk.ac.shef.dcs.kbsearch.KBSearch; -import uk.ac.shef.dcs.kbsearch.model.Clazz; -import uk.ac.shef.dcs.kbsearch.model.Entity; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Created by zqz on 14/05/2015. - */ -public class SimilarityComputerThread extends Thread{ - - private Map scores; - private List> pairs; - private EntityAndClazzSimilarityScorer simScorer; - private KBSearch kbSearch; - private boolean finished=false; - private boolean useCache; - private static final Logger LOG = Logger.getLogger(SimilarityComputerThread.class.getName()); - - public SimilarityComputerThread( boolean useCache, - List> pairs, EntityAndClazzSimilarityScorer simScorer, - KBSearch kbSearch){ - scores=new HashMap<>(); - this.pairs=pairs; - this.simScorer=simScorer; - this.kbSearch = kbSearch; - this.useCache=useCache; - } - - - @Override - public void run() { - for(Pair pair: pairs){ - Pair score=null; - try { - score = simScorer.computeEntityConceptSimilarity(pair.getKey(), pair.getValue(), kbSearch, useCache); - } catch (Exception e) { - LOG.error("Failed to compute similarity for pair:"+pair); - LOG.error(ExceptionUtils.getFullStackTrace(e)); - } - if(score!=null) { - scores.put(new String[]{pair.getKey().getId(), pair.getValue().getId(), score.getValue().toString()}, score.getKey()); - } - } - finished=true; - } - - public boolean isFinished() { - return this.finished; - } - - public Map getScores(){ - return scores; - } -} +package uk.ac.shef.dcs.sti.core.algorithm.ji.similarity; + +import javafx.util.Pair; +import org.apache.commons.lang.exception.ExceptionUtils; +import org.apache.log4j.Logger; +import uk.ac.shef.dcs.kbsearch.KBSearch; +import uk.ac.shef.dcs.kbsearch.model.Clazz; +import uk.ac.shef.dcs.kbsearch.model.Entity; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Created by zqz on 14/05/2015. + */ +public class SimilarityComputerThread extends Thread{ + + private Map scores; + private List> pairs; + private EntityAndClazzSimilarityScorer simScorer; + private KBSearch kbSearch; + private boolean finished=false; + private boolean useCache; + private static final Logger LOG = Logger.getLogger(SimilarityComputerThread.class.getName()); + + public SimilarityComputerThread( boolean useCache, + List> pairs, EntityAndClazzSimilarityScorer simScorer, + KBSearch kbSearch){ + scores=new HashMap<>(); + this.pairs=pairs; + this.simScorer=simScorer; + this.kbSearch = kbSearch; + this.useCache=useCache; + } + + + @Override + public void run() { + for(Pair pair: pairs){ + Pair score=null; + try { + score = simScorer.computeEntityConceptSimilarity(pair.getKey(), pair.getValue(), kbSearch, useCache); + } catch (Exception e) { + LOG.error("Failed to compute similarity for pair:"+pair); + LOG.error(ExceptionUtils.getFullStackTrace(e)); + } + if(score!=null) { + scores.put(new String[]{pair.getKey().getId(), pair.getValue().getId(), score.getValue().toString()}, score.getKey()); + } + } + finished=true; + } + + public boolean isFinished() { + return this.finished; + } + + public Map getScores(){ + return scores; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/CellAnnotationUpdater.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/CellAnnotationUpdater.java index c621cf01..c8d0d1db 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/CellAnnotationUpdater.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/CellAnnotationUpdater.java @@ -1,258 +1,258 @@ -package uk.ac.shef.dcs.sti.core.algorithm.smp; - -import cern.colt.matrix.ObjectMatrix2D; -import uk.ac.shef.dcs.kbsearch.model.Attribute; -import uk.ac.shef.dcs.sti.core.model.RelationColumns; -import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; -import uk.ac.shef.dcs.sti.core.model.TAnnotation; -import uk.ac.shef.dcs.sti.util.SubsetGenerator; - -import java.util.*; - -/** - * Created by zqz on 23/04/2015. - */ -class CellAnnotationUpdater { - - public int[] update(ObjectMatrix2D messages, TAnnotation tableAnnotation) { - int countUpdateNeeded = 0, countUpdated = 0;// an update is invalid if the message requires the cell to change to - //the same NE that it was already assigned to - //this is possible due to relation messages - //go thru each cell - for (int r = 0; r < messages.rows(); r++) { - for (int c = 0; c < messages.columns(); c++) { - Object container = messages.get(r, c); - if (container == null) - continue; - countUpdateNeeded++; - @SuppressWarnings("unchecked") - List messages_for_cell = (List) container; - if(messages_for_cell.size()==0) - continue; - Collections.sort(messages_for_cell); - //not all messages can be satisfied. compute the preferences of the combinations of messages satisfied - List messagesPreferenceSorted = createSortedPreferenceKeys(messages_for_cell.size()); - - TCellAnnotation[] candidateAnnotations = tableAnnotation.getContentCellAnnotations(r, c); - //key- the index of TCellAnnotation in the TCellAnnotation[] object returned by #tableAnnotation.get...(r, c) - //value- list of indexes (as appearing in messages_for_cell of messages satisfied by the TCellAnnotation identified by 'key' - Map> annotation_satisfies_messages = - computeSatisfiedMessages(r, c, messages_for_cell, tableAnnotation); - //indexes of candidate entity annotation for the cell (r, c) - List bestAnnotations = select(annotation_satisfies_messages, messagesPreferenceSorted, candidateAnnotations); - - //retrieve actual annotation based on their indexes... - if (bestAnnotations.size() > 0) { - boolean isValidUpdate = false; - List currentWinningAnnotations = tableAnnotation.getWinningContentCellAnnotation(r, c); - double currentMaxScore = currentWinningAnnotations.get(0).getFinalScore(); - double arbitraryNewScore = currentMaxScore + 0.000001; - - for (int i = 0; i < candidateAnnotations.length; i++) { - if (bestAnnotations.contains(i)) { - if (candidateAnnotations[i].getFinalScore() != currentMaxScore) //the chosen best annotation tobe updated - //is not already the highest scoring candidate - isValidUpdate = true; - candidateAnnotations[i].setFinalScore(arbitraryNewScore); - } - - } - Arrays.sort(candidateAnnotations); - tableAnnotation.setContentCellAnnotations(r, c, candidateAnnotations); - if(isValidUpdate) - countUpdated++; - else - countUpdateNeeded--; - } - } - } - return new int[]{countUpdated, countUpdateNeeded}; - } - - - - /** - * go thru every candidate cell annotation in cell (r, c), count for each candidate, the ChangeMessage objects that - * can be satisfied and record their index appearing "messages_for_cell" - * - * @param r row id - * @param c column id - * @param messages_for_cell change messages for the cell (r, c) - * @param tableAnnotation - * @return key- the index of TCellAnnotation in the TCellAnnotation[] object returned by #tableAnnotation.get...(r, c) - * value- list of indexes (as appearing in messages_for_cell of messages satisfied by the TCellAnnotation identified by 'key' - */ - private Map> computeSatisfiedMessages(int r, int c, - List messages_for_cell, - TAnnotation tableAnnotation) { - TCellAnnotation[] cellAnnotations = tableAnnotation.getContentCellAnnotations(r, c); - Map> out = new HashMap<>(); - if (cellAnnotations == null || cellAnnotations.length == 0) //possible if message is sent by relation and request a change to its object which is not an NE - return out; - - for (int i = 0; i < cellAnnotations.length; i++) { //go through every candidate annotation for the cell, count # of messages that each candidate satisfies - TCellAnnotation ca = cellAnnotations[i]; - List satisfied_messages = new ArrayList<>(); - - for (int j = 0; j < messages_for_cell.size(); j++) { //go through each message to check against that candidate - ChangeMessage m = messages_for_cell.get(j); - boolean satisfied = checkEntityAgainstMessage(ca, r, c, m, tableAnnotation); - if (satisfied) - satisfied_messages.add(j); - } - if (satisfied_messages.size() > 0) - out.put(i, satisfied_messages); - } - return out; - } - - private boolean checkEntityAgainstMessage(TCellAnnotation ca, int row, int col, ChangeMessage m, TAnnotation tableAnnotation) { - //if the change message is due to relation - if (m instanceof ChangeMessageFromRelation) { - ChangeMessageFromRelation message = (ChangeMessageFromRelation) m; - if (message.getSubobjIndicator() == 0) { //the current cell's NE is the subject in the relation that sends the "change" message - //we need to fetch all facts of a candidate entity annotation, check if any fact uses a relation same as identified - //in the message - List facts = ca.getAnnotation().getAttributes(); - if (containsRelation(facts, message.getLabels())) - return true; - else return false; - } else { //if the current cell's NE is the object in the relation, first we need to - //find the subject TCellAnnotation - for (RelationColumns relation_subobjKey : tableAnnotation.getColumncolumnRelations().keySet()) { - if (relation_subobjKey.getObjectCol() == col) { - TCellAnnotation[] subjectCellAnnotations = tableAnnotation.getContentCellAnnotations(row, relation_subobjKey.getSubjectCol()); - //check if any fact of any candidate subject TCellAnnotation mentions ca - //note that we do not need to fix the candidate subject TCellAnnotation at this stage. - //because another message should have been sent to the cell that corresponds to the subject cell - //and that ensures the subject's cell's annotation will be dealt with separately - for (TCellAnnotation subjectCellAnnotation : subjectCellAnnotations) { - for (Attribute fact : subjectCellAnnotation.getAnnotation().getAttributes()) { - if (fact.getValue().equals(ca.getAnnotation().getId())) { - return true; - } - } - } - } - } - } - } else { //change message sent by header todo at this point, we should re-query freebase to fetch more candidates - List legitHeaderLabels = new ArrayList<>(m.getLabels()); - legitHeaderLabels.retainAll(ca.getAnnotation().getTypeIds()); - if (legitHeaderLabels.size() > 0) - return true; - } - return false; - } - - //key-index of the TCellAnnotation in the list of candidate CellAnnotations for the cell ranked by their scores - //value-list of indexes of satisfied messages by this TCellAnnotation. - private List select(Map> annotation_satisfies_messages, - List messagePreferencesSorted, - TCellAnnotation[] candidateAnnotationsInCell - ) { - int bestPreferenceIndex = Integer.MAX_VALUE; - List bestAnnotations = new ArrayList<>(); - if (annotation_satisfies_messages.size() == 0) - return bestAnnotations; - - //debugging// - /*if(annotation_satisfies_messages.size()>1) - System.out.println();*/ - // - - for (Map.Entry> e : annotation_satisfies_messages.entrySet()) { - List messages_satisfied = e.getValue(); - Collections.sort(messages_satisfied); - - String key = ""; - for (Integer m : messages_satisfied) - key += m + " "; - key = key.substring(0, key.length() - 1).trim(); - - int index = messagePreferencesSorted.indexOf(key); - if (index < bestPreferenceIndex) { - bestPreferenceIndex = index; - } - } - - String bestPreference = messagePreferencesSorted.get(bestPreferenceIndex); - for (Map.Entry> e : annotation_satisfies_messages.entrySet()) { - List messages_satisfied = e.getValue(); - - String key = ""; - for (Integer m : messages_satisfied) - key += m + " "; - key = key.substring(0, key.length() - 1).trim(); - - if (key.equals(bestPreference)) - bestAnnotations.add(e.getKey()); - } - - //prune bestAnnotations, if there are multiple ones chosen by messages, select only the highest scoring ones - double maxScore=0.0; - for(int i: bestAnnotations){ - TCellAnnotation ca = candidateAnnotationsInCell[i]; - if(ca.getFinalScore()>maxScore) - maxScore=ca.getFinalScore(); - } - Iterator it = bestAnnotations.iterator(); - while(it.hasNext()) { - int index=it.next(); - TCellAnnotation ca = candidateAnnotationsInCell[index]; - if(ca.getFinalScore()!=maxScore) - it.remove(); - } - return bestAnnotations; - } - - //to update cell's annotation, we need to select the one that satisfies most "change" messages sent from different - //factors. Here we compute different combinations of satisfied "change" messages ranked by preference (see Mulwad's papge - // on page 12 - /*private List createSortedPreferenceKeys(int totalMessages) { - Set in = new HashSet(totalMessages); - for (int i = 0; i < totalMessages; i++) { - in.add(String.valueOf(i)); - } - List rs = SubsetGenerator.generateSubsets(in); - Collections.sort(rs, new Comparator() { - @Override - public int compare(String o1, String o2) { - Integer length1 = o1.length(); - Integer length2 = o2.length(); - int compare = length2.compareTo(length1); - if (compare == 0) { - return o1.compareTo(o2); - } else - return compare; - } - }); - return rs; - }*/ - - private List createSortedPreferenceKeys(int totalMessages) { - Set in = new HashSet<>(totalMessages); - for (int i = 0; i < totalMessages; i++) { - in.add(i); - } - List rs = SubsetGenerator.generateSubsets(in); - Collections.sort(rs, (o1, o2) -> { - Integer length1 = o1.length(); - Integer length2 = o2.length(); - int compare = length2.compareTo(length1); - if (compare == 0) { - return o1.compareTo(o2); - } else - return compare; - }); - return rs; - } - - private boolean containsRelation(List facts, List labels) { - for (Attribute fact : facts) { - if (labels.contains(fact.getRelationURI())) - return true; - } - return false; - } -} +package uk.ac.shef.dcs.sti.core.algorithm.smp; + +import cern.colt.matrix.ObjectMatrix2D; +import uk.ac.shef.dcs.kbsearch.model.Attribute; +import uk.ac.shef.dcs.sti.core.model.RelationColumns; +import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; +import uk.ac.shef.dcs.sti.core.model.TAnnotation; +import uk.ac.shef.dcs.sti.util.SubsetGenerator; + +import java.util.*; + +/** + * Created by zqz on 23/04/2015. + */ +class CellAnnotationUpdater { + + public int[] update(ObjectMatrix2D messages, TAnnotation tableAnnotation) { + int countUpdateNeeded = 0, countUpdated = 0;// an update is invalid if the message requires the cell to change to + //the same NE that it was already assigned to + //this is possible due to relation messages + //go thru each cell + for (int r = 0; r < messages.rows(); r++) { + for (int c = 0; c < messages.columns(); c++) { + Object container = messages.get(r, c); + if (container == null) + continue; + countUpdateNeeded++; + @SuppressWarnings("unchecked") + List messages_for_cell = (List) container; + if(messages_for_cell.size()==0) + continue; + Collections.sort(messages_for_cell); + //not all messages can be satisfied. compute the preferences of the combinations of messages satisfied + List messagesPreferenceSorted = createSortedPreferenceKeys(messages_for_cell.size()); + + TCellAnnotation[] candidateAnnotations = tableAnnotation.getContentCellAnnotations(r, c); + //key- the index of TCellAnnotation in the TCellAnnotation[] object returned by #tableAnnotation.get...(r, c) + //value- list of indexes (as appearing in messages_for_cell of messages satisfied by the TCellAnnotation identified by 'key' + Map> annotation_satisfies_messages = + computeSatisfiedMessages(r, c, messages_for_cell, tableAnnotation); + //indexes of candidate entity annotation for the cell (r, c) + List bestAnnotations = select(annotation_satisfies_messages, messagesPreferenceSorted, candidateAnnotations); + + //retrieve actual annotation based on their indexes... + if (bestAnnotations.size() > 0) { + boolean isValidUpdate = false; + List currentWinningAnnotations = tableAnnotation.getWinningContentCellAnnotation(r, c); + double currentMaxScore = currentWinningAnnotations.get(0).getFinalScore(); + double arbitraryNewScore = currentMaxScore + 0.000001; + + for (int i = 0; i < candidateAnnotations.length; i++) { + if (bestAnnotations.contains(i)) { + if (candidateAnnotations[i].getFinalScore() != currentMaxScore) //the chosen best annotation tobe updated + //is not already the highest scoring candidate + isValidUpdate = true; + candidateAnnotations[i].setFinalScore(arbitraryNewScore); + } + + } + Arrays.sort(candidateAnnotations); + tableAnnotation.setContentCellAnnotations(r, c, candidateAnnotations); + if(isValidUpdate) + countUpdated++; + else + countUpdateNeeded--; + } + } + } + return new int[]{countUpdated, countUpdateNeeded}; + } + + + + /** + * go thru every candidate cell annotation in cell (r, c), count for each candidate, the ChangeMessage objects that + * can be satisfied and record their index appearing "messages_for_cell" + * + * @param r row id + * @param c column id + * @param messages_for_cell change messages for the cell (r, c) + * @param tableAnnotation + * @return key- the index of TCellAnnotation in the TCellAnnotation[] object returned by #tableAnnotation.get...(r, c) + * value- list of indexes (as appearing in messages_for_cell of messages satisfied by the TCellAnnotation identified by 'key' + */ + private Map> computeSatisfiedMessages(int r, int c, + List messages_for_cell, + TAnnotation tableAnnotation) { + TCellAnnotation[] cellAnnotations = tableAnnotation.getContentCellAnnotations(r, c); + Map> out = new HashMap<>(); + if (cellAnnotations == null || cellAnnotations.length == 0) //possible if message is sent by relation and request a change to its object which is not an NE + return out; + + for (int i = 0; i < cellAnnotations.length; i++) { //go through every candidate annotation for the cell, count # of messages that each candidate satisfies + TCellAnnotation ca = cellAnnotations[i]; + List satisfied_messages = new ArrayList<>(); + + for (int j = 0; j < messages_for_cell.size(); j++) { //go through each message to check against that candidate + ChangeMessage m = messages_for_cell.get(j); + boolean satisfied = checkEntityAgainstMessage(ca, r, c, m, tableAnnotation); + if (satisfied) + satisfied_messages.add(j); + } + if (satisfied_messages.size() > 0) + out.put(i, satisfied_messages); + } + return out; + } + + private boolean checkEntityAgainstMessage(TCellAnnotation ca, int row, int col, ChangeMessage m, TAnnotation tableAnnotation) { + //if the change message is due to relation + if (m instanceof ChangeMessageFromRelation) { + ChangeMessageFromRelation message = (ChangeMessageFromRelation) m; + if (message.getSubobjIndicator() == 0) { //the current cell's NE is the subject in the relation that sends the "change" message + //we need to fetch all facts of a candidate entity annotation, check if any fact uses a relation same as identified + //in the message + List facts = ca.getAnnotation().getAttributes(); + if (containsRelation(facts, message.getLabels())) + return true; + else return false; + } else { //if the current cell's NE is the object in the relation, first we need to + //find the subject TCellAnnotation + for (RelationColumns relation_subobjKey : tableAnnotation.getColumncolumnRelations().keySet()) { + if (relation_subobjKey.getObjectCol() == col) { + TCellAnnotation[] subjectCellAnnotations = tableAnnotation.getContentCellAnnotations(row, relation_subobjKey.getSubjectCol()); + //check if any fact of any candidate subject TCellAnnotation mentions ca + //note that we do not need to fix the candidate subject TCellAnnotation at this stage. + //because another message should have been sent to the cell that corresponds to the subject cell + //and that ensures the subject's cell's annotation will be dealt with separately + for (TCellAnnotation subjectCellAnnotation : subjectCellAnnotations) { + for (Attribute fact : subjectCellAnnotation.getAnnotation().getAttributes()) { + if (fact.getValue().equals(ca.getAnnotation().getId())) { + return true; + } + } + } + } + } + } + } else { //change message sent by header todo at this point, we should re-query freebase to fetch more candidates + List legitHeaderLabels = new ArrayList<>(m.getLabels()); + legitHeaderLabels.retainAll(ca.getAnnotation().getTypeIds()); + if (legitHeaderLabels.size() > 0) + return true; + } + return false; + } + + //key-index of the TCellAnnotation in the list of candidate CellAnnotations for the cell ranked by their scores + //value-list of indexes of satisfied messages by this TCellAnnotation. + private List select(Map> annotation_satisfies_messages, + List messagePreferencesSorted, + TCellAnnotation[] candidateAnnotationsInCell + ) { + int bestPreferenceIndex = Integer.MAX_VALUE; + List bestAnnotations = new ArrayList<>(); + if (annotation_satisfies_messages.size() == 0) + return bestAnnotations; + + //debugging// + /*if(annotation_satisfies_messages.size()>1) + System.out.println();*/ + // + + for (Map.Entry> e : annotation_satisfies_messages.entrySet()) { + List messages_satisfied = e.getValue(); + Collections.sort(messages_satisfied); + + String key = ""; + for (Integer m : messages_satisfied) + key += m + " "; + key = key.substring(0, key.length() - 1).trim(); + + int index = messagePreferencesSorted.indexOf(key); + if (index < bestPreferenceIndex) { + bestPreferenceIndex = index; + } + } + + String bestPreference = messagePreferencesSorted.get(bestPreferenceIndex); + for (Map.Entry> e : annotation_satisfies_messages.entrySet()) { + List messages_satisfied = e.getValue(); + + String key = ""; + for (Integer m : messages_satisfied) + key += m + " "; + key = key.substring(0, key.length() - 1).trim(); + + if (key.equals(bestPreference)) + bestAnnotations.add(e.getKey()); + } + + //prune bestAnnotations, if there are multiple ones chosen by messages, select only the highest scoring ones + double maxScore=0.0; + for(int i: bestAnnotations){ + TCellAnnotation ca = candidateAnnotationsInCell[i]; + if(ca.getFinalScore()>maxScore) + maxScore=ca.getFinalScore(); + } + Iterator it = bestAnnotations.iterator(); + while(it.hasNext()) { + int index=it.next(); + TCellAnnotation ca = candidateAnnotationsInCell[index]; + if(ca.getFinalScore()!=maxScore) + it.remove(); + } + return bestAnnotations; + } + + //to update cell's annotation, we need to select the one that satisfies most "change" messages sent from different + //factors. Here we compute different combinations of satisfied "change" messages ranked by preference (see Mulwad's papge + // on page 12 + /*private List createSortedPreferenceKeys(int totalMessages) { + Set in = new HashSet(totalMessages); + for (int i = 0; i < totalMessages; i++) { + in.add(String.valueOf(i)); + } + List rs = SubsetGenerator.generateSubsets(in); + Collections.sort(rs, new Comparator() { + @Override + public int compare(String o1, String o2) { + Integer length1 = o1.length(); + Integer length2 = o2.length(); + int compare = length2.compareTo(length1); + if (compare == 0) { + return o1.compareTo(o2); + } else + return compare; + } + }); + return rs; + }*/ + + private List createSortedPreferenceKeys(int totalMessages) { + Set in = new HashSet<>(totalMessages); + for (int i = 0; i < totalMessages; i++) { + in.add(i); + } + List rs = SubsetGenerator.generateSubsets(in); + Collections.sort(rs, (o1, o2) -> { + Integer length1 = o1.length(); + Integer length2 = o2.length(); + int compare = length2.compareTo(length1); + if (compare == 0) { + return o1.compareTo(o2); + } else + return compare; + }); + return rs; + } + + private boolean containsRelation(List facts, List labels) { + for (Attribute fact : facts) { + if (labels.contains(fact.getRelationURI())) + return true; + } + return false; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessage.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessage.java index 6a8a2934..0b844290 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessage.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessage.java @@ -1,37 +1,37 @@ -package uk.ac.shef.dcs.sti.core.algorithm.smp; - -import java.util.ArrayList; -import java.util.List; - -/** - * . - */ -class ChangeMessage implements Comparable { - protected double confidence; - protected List labels; //values have OR logic relations - - public ChangeMessage() { - labels = new ArrayList(); - } - - public double getConfidence() { - return confidence; - } - - public void setConfidence(double confidence) { - this.confidence = confidence; - } - - public List getLabels() { - return labels; - } - - public void addLabel(String label) { - this.labels.add(label); - } - - @Override - public int compareTo(ChangeMessage o) { - return Double.valueOf(o.getConfidence()).compareTo(getConfidence()); - } -} +package uk.ac.shef.dcs.sti.core.algorithm.smp; + +import java.util.ArrayList; +import java.util.List; + +/** + * . + */ +class ChangeMessage implements Comparable { + protected double confidence; + protected List labels; //values have OR logic relations + + public ChangeMessage() { + labels = new ArrayList(); + } + + public double getConfidence() { + return confidence; + } + + public void setConfidence(double confidence) { + this.confidence = confidence; + } + + public List getLabels() { + return labels; + } + + public void addLabel(String label) { + this.labels.add(label); + } + + @Override + public int compareTo(ChangeMessage o) { + return Double.valueOf(o.getConfidence()).compareTo(getConfidence()); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageComputer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageComputer.java index c6a4b475..6a68ab0e 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageComputer.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageComputer.java @@ -1,135 +1,135 @@ -package uk.ac.shef.dcs.sti.core.algorithm.smp; - -import cern.colt.matrix.ObjectMatrix2D; -import cern.colt.matrix.impl.SparseObjectMatrix2D; -import uk.ac.shef.dcs.sti.core.model.*; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - * - */ -class ChangeMessageComputer { - - protected double minConfidence = 0.5; - - public ChangeMessageComputer(){} - - public ChangeMessageComputer(double minConfidence){ - this.minConfidence=minConfidence; - } - - public ObjectMatrix2D computeChangeMessages(TAnnotation tableAnnotation, Table table) { - ObjectMatrix2D messages = new SparseObjectMatrix2D(table.getNumRows(), table.getNumCols()); - //messages by column header - for (int col = 0; col < table.getNumCols(); col++) { - List winningColumnClazz = tableAnnotation.getWinningHeaderAnnotations(col); - if (winningColumnClazz.size() == 0) - continue; - - for (int row = 0; row < table.getNumRows(); row++) { - List cellAnnotations = tableAnnotation.getWinningContentCellAnnotation(row, col); - if (cellAnnotations.size() == 0) - continue; - - List headerAnnotationStrings = new ArrayList<>(); - for (TColumnHeaderAnnotation ha : winningColumnClazz) - headerAnnotationStrings.add(ha.getAnnotation().getId()); - boolean sendChange = false; - for (TCellAnnotation best : cellAnnotations) { //this cell can have multiple annotations with the same highest computeElementScores - //we need to check everyone of them. if any one's type does not overlap with the header annotations, it need changing - List copy = new ArrayList<>(headerAnnotationStrings); - copy.retainAll(best.getAnnotation().getTypeIds()); - if (copy.size() == 0) { - sendChange = true; - break; - } - } - if (sendChange) { - for (TColumnHeaderAnnotation ha : winningColumnClazz) { - ChangeMessage m = new ChangeMessage(); - m.setConfidence(ha.getFinalScore()); - m.addLabel(ha.getAnnotation().getId()); - updateMessageForCell(messages, row, col, m); - } - } - } - } - - //messages by relations - Map> relations = tableAnnotation.getColumncolumnRelations(); - //go thru every directional relations - for (Map.Entry> e : relations.entrySet()) { - RelationColumns subobj_col_ids = e.getKey(); //sub-obj key tells us the subject column id, and the obj column id - List relationAnnotations = e.getValue(); - Collections.sort(relationAnnotations); - double maxScore_of_relation_across_columns = relationAnnotations.get(0).getFinalScore(); //what is the top relation's computeElementScores - List highestScoringRelationStrings = new ArrayList<>(); - for (TColumnColumnRelationAnnotation hba : relationAnnotations) { //what are the top scoring relaions. these are the currently assigned relations for the two columns - if (hba.getFinalScore() == maxScore_of_relation_across_columns) - highestScoringRelationStrings.add(hba.getRelationLabel()); - } - //next go thru every row and check if the current top scored relations apply - Map> - relationAnnotations_per_row = tableAnnotation.getCellcellRelations().get(subobj_col_ids); - - List rows_annotated_with_relations = new ArrayList<>(relationAnnotations_per_row.keySet()); - for (int row = 0; row < tableAnnotation.getRows(); row++) { - boolean hasMatch = false; - //do we know if this row is annotated with relations? - if (rows_annotated_with_relations.contains(row)) { - List relations_on_row = relationAnnotations_per_row.get(row); - //if so, take the highest scoring relation for the current row, if it is the same as the one assigned - //for the two columns, we are ok - if (relations_on_row.size() != 0) { - Collections.sort(relations_on_row); - double maxScore = relations_on_row.get(0).getWinningAttributeMatchScore(); - for (TCellCellRelationAnotation cra : relations_on_row) { - if (cra.getWinningAttributeMatchScore() == maxScore && highestScoringRelationStrings.contains(cra.getRelationURI())) { - hasMatch = true; - break; - } - } - } - } - //if for this row no relation is present or no relation matches with the annotations for the two columns, - //we prepare change messages - if (!hasMatch) { - ChangeMessageFromRelation forSubjectCell = new ChangeMessageFromRelation(); - forSubjectCell.setLabels(highestScoringRelationStrings); - forSubjectCell.setConfidence(maxScore_of_relation_across_columns); - forSubjectCell.setSubobjIndicator(0); - updateMessageForCell(messages, row, subobj_col_ids.getSubjectCol(), forSubjectCell); - - ChangeMessageFromRelation forObjectCell = new ChangeMessageFromRelation(); - forObjectCell.setLabels(highestScoringRelationStrings); - forObjectCell.setConfidence(maxScore_of_relation_across_columns); - forObjectCell.setSubobjIndicator(1); - updateMessageForCell(messages, row, subobj_col_ids.getObjectCol(), forObjectCell); - } - } - } - return messages; - } - - @SuppressWarnings("unchecked") - private void updateMessageForCell(ObjectMatrix2D messages, int row, int col, ChangeMessage m) { - if (m.getConfidence() >= minConfidence) { - Object container = messages.get(row, col); - List messages_at_cell; - if (container == null) { - messages_at_cell = new ArrayList<>(); - } else { - messages_at_cell = (List) container; - } - - messages_at_cell.add(m); - messages.set(row, col, messages_at_cell); - } - } - - -} +package uk.ac.shef.dcs.sti.core.algorithm.smp; + +import cern.colt.matrix.ObjectMatrix2D; +import cern.colt.matrix.impl.SparseObjectMatrix2D; +import uk.ac.shef.dcs.sti.core.model.*; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** + * + */ +class ChangeMessageComputer { + + protected double minConfidence = 0.5; + + public ChangeMessageComputer(){} + + public ChangeMessageComputer(double minConfidence){ + this.minConfidence=minConfidence; + } + + public ObjectMatrix2D computeChangeMessages(TAnnotation tableAnnotation, Table table) { + ObjectMatrix2D messages = new SparseObjectMatrix2D(table.getNumRows(), table.getNumCols()); + //messages by column header + for (int col = 0; col < table.getNumCols(); col++) { + List winningColumnClazz = tableAnnotation.getWinningHeaderAnnotations(col); + if (winningColumnClazz.size() == 0) + continue; + + for (int row = 0; row < table.getNumRows(); row++) { + List cellAnnotations = tableAnnotation.getWinningContentCellAnnotation(row, col); + if (cellAnnotations.size() == 0) + continue; + + List headerAnnotationStrings = new ArrayList<>(); + for (TColumnHeaderAnnotation ha : winningColumnClazz) + headerAnnotationStrings.add(ha.getAnnotation().getId()); + boolean sendChange = false; + for (TCellAnnotation best : cellAnnotations) { //this cell can have multiple annotations with the same highest computeElementScores + //we need to check everyone of them. if any one's type does not overlap with the header annotations, it need changing + List copy = new ArrayList<>(headerAnnotationStrings); + copy.retainAll(best.getAnnotation().getTypeIds()); + if (copy.size() == 0) { + sendChange = true; + break; + } + } + if (sendChange) { + for (TColumnHeaderAnnotation ha : winningColumnClazz) { + ChangeMessage m = new ChangeMessage(); + m.setConfidence(ha.getFinalScore()); + m.addLabel(ha.getAnnotation().getId()); + updateMessageForCell(messages, row, col, m); + } + } + } + } + + //messages by relations + Map> relations = tableAnnotation.getColumncolumnRelations(); + //go thru every directional relations + for (Map.Entry> e : relations.entrySet()) { + RelationColumns subobj_col_ids = e.getKey(); //sub-obj key tells us the subject column id, and the obj column id + List relationAnnotations = e.getValue(); + Collections.sort(relationAnnotations); + double maxScore_of_relation_across_columns = relationAnnotations.get(0).getFinalScore(); //what is the top relation's computeElementScores + List highestScoringRelationStrings = new ArrayList<>(); + for (TColumnColumnRelationAnnotation hba : relationAnnotations) { //what are the top scoring relaions. these are the currently assigned relations for the two columns + if (hba.getFinalScore() == maxScore_of_relation_across_columns) + highestScoringRelationStrings.add(hba.getRelationLabel()); + } + //next go thru every row and check if the current top scored relations apply + Map> + relationAnnotations_per_row = tableAnnotation.getCellcellRelations().get(subobj_col_ids); + + List rows_annotated_with_relations = new ArrayList<>(relationAnnotations_per_row.keySet()); + for (int row = 0; row < tableAnnotation.getRows(); row++) { + boolean hasMatch = false; + //do we know if this row is annotated with relations? + if (rows_annotated_with_relations.contains(row)) { + List relations_on_row = relationAnnotations_per_row.get(row); + //if so, take the highest scoring relation for the current row, if it is the same as the one assigned + //for the two columns, we are ok + if (relations_on_row.size() != 0) { + Collections.sort(relations_on_row); + double maxScore = relations_on_row.get(0).getWinningAttributeMatchScore(); + for (TCellCellRelationAnotation cra : relations_on_row) { + if (cra.getWinningAttributeMatchScore() == maxScore && highestScoringRelationStrings.contains(cra.getRelationURI())) { + hasMatch = true; + break; + } + } + } + } + //if for this row no relation is present or no relation matches with the annotations for the two columns, + //we prepare change messages + if (!hasMatch) { + ChangeMessageFromRelation forSubjectCell = new ChangeMessageFromRelation(); + forSubjectCell.setLabels(highestScoringRelationStrings); + forSubjectCell.setConfidence(maxScore_of_relation_across_columns); + forSubjectCell.setSubobjIndicator(0); + updateMessageForCell(messages, row, subobj_col_ids.getSubjectCol(), forSubjectCell); + + ChangeMessageFromRelation forObjectCell = new ChangeMessageFromRelation(); + forObjectCell.setLabels(highestScoringRelationStrings); + forObjectCell.setConfidence(maxScore_of_relation_across_columns); + forObjectCell.setSubobjIndicator(1); + updateMessageForCell(messages, row, subobj_col_ids.getObjectCol(), forObjectCell); + } + } + } + return messages; + } + + @SuppressWarnings("unchecked") + private void updateMessageForCell(ObjectMatrix2D messages, int row, int col, ChangeMessage m) { + if (m.getConfidence() >= minConfidence) { + Object container = messages.get(row, col); + List messages_at_cell; + if (container == null) { + messages_at_cell = new ArrayList<>(); + } else { + messages_at_cell = (List) container; + } + + messages_at_cell.add(m); + messages.set(row, col, messages_at_cell); + } + } + + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageFromRelation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageFromRelation.java index 31948977..925db513 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageFromRelation.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ChangeMessageFromRelation.java @@ -1,27 +1,27 @@ -package uk.ac.shef.dcs.sti.core.algorithm.smp; - -import java.util.List; - -/** - * Created by zqz on 23/04/2015. - */ -class ChangeMessageFromRelation extends ChangeMessage { - private int subobjIndicator; //0 - the cell needs changing is the subject in a relation; 1 - the cell needs changing is the object in a relation - - - public int getSubobjIndicator() { - return subobjIndicator; - } - - public void setSubobjIndicator(int subobjIndicator) { - this.subobjIndicator = subobjIndicator; - } - - public void setLabels(List labels) { - this.labels = labels; - } - - public String toString(){ - return confidence+","+ subobjIndicator +","+labels; - } -} +package uk.ac.shef.dcs.sti.core.algorithm.smp; + +import java.util.List; + +/** + * Created by zqz on 23/04/2015. + */ +class ChangeMessageFromRelation extends ChangeMessage { + private int subobjIndicator; //0 - the cell needs changing is the subject in a relation; 1 - the cell needs changing is the object in a relation + + + public int getSubobjIndicator() { + return subobjIndicator; + } + + public void setSubobjIndicator(int subobjIndicator) { + this.subobjIndicator = subobjIndicator; + } + + public void setLabels(List labels) { + this.labels = labels; + } + + public String toString(){ + return confidence+","+ subobjIndicator +","+labels; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ClazzSpecificityCalculator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ClazzSpecificityCalculator.java index 4227d52b..ae69e63c 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ClazzSpecificityCalculator.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/ClazzSpecificityCalculator.java @@ -1,9 +1,9 @@ -package uk.ac.shef.dcs.sti.core.algorithm.smp; - -/** - * Created by - on 06/04/2016. - */ -public interface ClazzSpecificityCalculator { - - double compute(String clazzURI); -} +package uk.ac.shef.dcs.sti.core.algorithm.smp; + +/** + * Created by - on 06/04/2016. + */ +public interface ClazzSpecificityCalculator { + + double compute(String clazzURI); +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/FreebaseClazzSpecificityCalculator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/FreebaseClazzSpecificityCalculator.java index 32abe9cf..3cf965b0 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/FreebaseClazzSpecificityCalculator.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/FreebaseClazzSpecificityCalculator.java @@ -1,31 +1,31 @@ -package uk.ac.shef.dcs.sti.core.algorithm.smp; - -import uk.ac.shef.dcs.kbsearch.KBSearch; -import uk.ac.shef.dcs.kbsearch.KBSearchException; -import uk.ac.shef.dcs.sti.STIConstantProperty; - -/** - * - */ -public class FreebaseClazzSpecificityCalculator implements ClazzSpecificityCalculator { - - private KBSearch kbSearch; - - public FreebaseClazzSpecificityCalculator(KBSearch kbSearch) { - this.kbSearch = kbSearch; - } - - @Override - public double compute(String clazzURI) { - double conceptGranularity = 0; - try { - conceptGranularity = kbSearch.findGranularityOfClazz(clazzURI); - } catch (KBSearchException e) { - return 0.0; - } - if (conceptGranularity < 0) - return 0.0; - return 1 - Math.sqrt(conceptGranularity / STIConstantProperty.FREEBASE_TOTAL_TOPICS); - - } -} +package uk.ac.shef.dcs.sti.core.algorithm.smp; + +import uk.ac.shef.dcs.kbsearch.KBSearch; +import uk.ac.shef.dcs.kbsearch.KBSearchException; +import uk.ac.shef.dcs.sti.STIConstantProperty; + +/** + * + */ +public class FreebaseClazzSpecificityCalculator implements ClazzSpecificityCalculator { + + private KBSearch kbSearch; + + public FreebaseClazzSpecificityCalculator(KBSearch kbSearch) { + this.kbSearch = kbSearch; + } + + @Override + public double compute(String clazzURI) { + double conceptGranularity = 0; + try { + conceptGranularity = kbSearch.findGranularityOfClazz(clazzURI); + } catch (KBSearchException e) { + return 0.0; + } + if (conceptGranularity < 0) + return 0.0; + return 1 - Math.sqrt(conceptGranularity / STIConstantProperty.FREEBASE_TOTAL_TOPICS); + + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SMPAdaptedEntityScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SMPAdaptedEntityScorer.java index a5b91325..7610bd38 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SMPAdaptedEntityScorer.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SMPAdaptedEntityScorer.java @@ -1,143 +1,143 @@ -package uk.ac.shef.dcs.sti.core.algorithm.smp; - -import org.simmetrics.Metric; -import org.simmetrics.StringMetric; -import org.simmetrics.builders.StringMetricBuilder; -import org.simmetrics.metrics.Dice; -import org.simmetrics.metrics.Levenshtein; -import org.simmetrics.metrics.StringMetrics; -import org.simmetrics.tokenizers.Tokenizers; -import uk.ac.shef.dcs.kbsearch.model.Attribute; -import uk.ac.shef.dcs.sti.STIConstantProperty; -import uk.ac.shef.dcs.sti.nlp.Lemmatizer; -import uk.ac.shef.dcs.sti.nlp.NLPTools; -import uk.ac.shef.dcs.sti.core.scorer.EntityScorer; -import uk.ac.shef.dcs.sti.util.DataTypeClassifier; -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.util.CollectionUtils; -import uk.ac.shef.dcs.util.StringUtils; - -import java.io.IOException; -import java.util.*; - -/** - * An adapted version of the NE ranker (scorer) used in Semantic Message Passing - */ -public class SMPAdaptedEntityScorer implements EntityScorer { - private static final String SMP_SCORE_INDEX = "smp_index"; - private static final String SMP_SCORE_LEV = "smp_stringsim_lev"; - private static final String SMP_SCORE_DICE = "smp_stringsim_dice"; - private static final String SMP_SCORE_CONTEXT = "smp_context"; - - private StringMetric lev; - private StringMetric dice; - private List stopWords; - private Lemmatizer lemmatizer; - - public SMPAdaptedEntityScorer(List stopWords, - String nlpResources) throws IOException { - lev = StringMetrics.levenshtein(); - dice = StringMetrics.dice(); - if (nlpResources != null) - lemmatizer = NLPTools.getInstance(nlpResources).getLemmatizer(); - - this.stopWords = stopWords; - } - - @Override - public Map computeElementScores(Entity candidate, - List all_candidates, - int sourceColumnIndex, - int sourceRowIndex, - List otherRows, - Table table, - Entity... referenceEntities) { - //entity index computeElementScores - double indexScore = 1.0 / all_candidates.size(); - - //lev between NE and cell text - TCell cell = table.getContentCell(sourceRowIndex, sourceColumnIndex); - double levScore = calculateStringSimilarity(cell.getText(), candidate, lev); - //dice between NE and cell text - double diceScore = calculateStringSimilarity(cell.getText(), candidate, dice); - - //column header and row values - /* BOW OF THE ENTITY*/ - List attributes = candidate.getAttributes(); - List entityBoW = new ArrayList<>(); - for (Attribute f : attributes) { - if (!STIConstantProperty.BOW_ENTITY_INCLUDE_INDIRECT_ATTRIBUTE && - !f.isDirect()) - continue; - String value = f.getValue(); - if (!StringUtils.isPath(value)) - entityBoW.addAll(StringUtils.toBagOfWords(value, true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)); - else - entityBoW.add(value); - } - if (lemmatizer != null) - entityBoW = lemmatizer.lemmatize(entityBoW); - entityBoW.removeAll(stopWords); - /* BOW OF THE Row context*/ - //double totalScore = 0.0; - String headerText = table.getColumnHeader(sourceColumnIndex).getHeaderText(); - List contextBoW = new ArrayList<>(); - //context from the row - - for (int col = 0; col < table.getNumCols(); col++) { - if (col == sourceColumnIndex || table.getColumnHeader(col).getTypes().get(0).getType().equals( - DataTypeClassifier.DataType.ORDERED_NUMBER - )) - continue; - TCell tcc = table.getContentCell(sourceRowIndex, col); - contextBoW.addAll(StringUtils.toBagOfWords(tcc.getText(), true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)); - } - - contextBoW.addAll(StringUtils.toBagOfWords( //also add the column header as the row context of this entity - headerText, true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)); - - if (lemmatizer != null) - contextBoW = lemmatizer.lemmatize(contextBoW); - contextBoW.removeAll(stopWords); - double contextOverlapScore = CollectionUtils.computeCoverage(entityBoW, contextBoW); - - Map score_elements = new HashMap<>(); - score_elements.put(SMP_SCORE_INDEX, indexScore); - score_elements.put(SMP_SCORE_LEV, levScore); - score_elements.put(SMP_SCORE_DICE, diceScore); - score_elements.put(SMP_SCORE_CONTEXT, contextOverlapScore); - return score_elements; - } - - private double calculateStringSimilarity(String text, Entity candidate, Metric lev) { - String normText = StringUtils.toAlphaNumericWhitechar(text); - double totalAliases = 1.0, - totalScore = (double) lev.compare( - normText, - StringUtils.toAlphaNumericWhitechar(candidate.getLabel())); - - for (String alias : candidate.getAliases()) { - alias=StringUtils.toAlphaNumericWhitechar(alias); - if (alias.length() > 0) { - double score = lev.compare(normText, alias); - totalScore += score; - totalAliases += 1.0; - } - } - - return totalScore / totalAliases; - } - - @Override - public double computeFinal(Map scoreMap, String cellTextOriginal) { - double total = 0.0; - for (Map.Entry e : scoreMap.entrySet()) { - total += e.getValue(); - } - scoreMap.put(TCellAnnotation.SCORE_FINAL, total); - return total; - } -} +package uk.ac.shef.dcs.sti.core.algorithm.smp; + +import org.simmetrics.Metric; +import org.simmetrics.StringMetric; +import org.simmetrics.builders.StringMetricBuilder; +import org.simmetrics.metrics.Dice; +import org.simmetrics.metrics.Levenshtein; +import org.simmetrics.metrics.StringMetrics; +import org.simmetrics.tokenizers.Tokenizers; +import uk.ac.shef.dcs.kbsearch.model.Attribute; +import uk.ac.shef.dcs.sti.STIConstantProperty; +import uk.ac.shef.dcs.sti.nlp.Lemmatizer; +import uk.ac.shef.dcs.sti.nlp.NLPTools; +import uk.ac.shef.dcs.sti.core.scorer.EntityScorer; +import uk.ac.shef.dcs.sti.util.DataTypeClassifier; +import uk.ac.shef.dcs.sti.core.model.TCell; +import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; +import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.util.CollectionUtils; +import uk.ac.shef.dcs.util.StringUtils; + +import java.io.IOException; +import java.util.*; + +/** + * An adapted version of the NE ranker (scorer) used in Semantic Message Passing + */ +public class SMPAdaptedEntityScorer implements EntityScorer { + private static final String SMP_SCORE_INDEX = "smp_index"; + private static final String SMP_SCORE_LEV = "smp_stringsim_lev"; + private static final String SMP_SCORE_DICE = "smp_stringsim_dice"; + private static final String SMP_SCORE_CONTEXT = "smp_context"; + + private StringMetric lev; + private StringMetric dice; + private List stopWords; + private Lemmatizer lemmatizer; + + public SMPAdaptedEntityScorer(List stopWords, + String nlpResources) throws IOException { + lev = StringMetrics.levenshtein(); + dice = StringMetrics.dice(); + if (nlpResources != null) + lemmatizer = NLPTools.getInstance(nlpResources).getLemmatizer(); + + this.stopWords = stopWords; + } + + @Override + public Map computeElementScores(Entity candidate, + List all_candidates, + int sourceColumnIndex, + int sourceRowIndex, + List otherRows, + Table table, + Entity... referenceEntities) { + //entity index computeElementScores + double indexScore = 1.0 / all_candidates.size(); + + //lev between NE and cell text + TCell cell = table.getContentCell(sourceRowIndex, sourceColumnIndex); + double levScore = calculateStringSimilarity(cell.getText(), candidate, lev); + //dice between NE and cell text + double diceScore = calculateStringSimilarity(cell.getText(), candidate, dice); + + //column header and row values + /* BOW OF THE ENTITY*/ + List attributes = candidate.getAttributes(); + List entityBoW = new ArrayList<>(); + for (Attribute f : attributes) { + if (!STIConstantProperty.BOW_ENTITY_INCLUDE_INDIRECT_ATTRIBUTE && + !f.isDirect()) + continue; + String value = f.getValue(); + if (!StringUtils.isPath(value)) + entityBoW.addAll(StringUtils.toBagOfWords(value, true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)); + else + entityBoW.add(value); + } + if (lemmatizer != null) + entityBoW = lemmatizer.lemmatize(entityBoW); + entityBoW.removeAll(stopWords); + /* BOW OF THE Row context*/ + //double totalScore = 0.0; + String headerText = table.getColumnHeader(sourceColumnIndex).getHeaderText(); + List contextBoW = new ArrayList<>(); + //context from the row + + for (int col = 0; col < table.getNumCols(); col++) { + if (col == sourceColumnIndex || table.getColumnHeader(col).getTypes().get(0).getType().equals( + DataTypeClassifier.DataType.ORDERED_NUMBER + )) + continue; + TCell tcc = table.getContentCell(sourceRowIndex, col); + contextBoW.addAll(StringUtils.toBagOfWords(tcc.getText(), true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)); + } + + contextBoW.addAll(StringUtils.toBagOfWords( //also add the column header as the row context of this entity + headerText, true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)); + + if (lemmatizer != null) + contextBoW = lemmatizer.lemmatize(contextBoW); + contextBoW.removeAll(stopWords); + double contextOverlapScore = CollectionUtils.computeCoverage(entityBoW, contextBoW); + + Map score_elements = new HashMap<>(); + score_elements.put(SMP_SCORE_INDEX, indexScore); + score_elements.put(SMP_SCORE_LEV, levScore); + score_elements.put(SMP_SCORE_DICE, diceScore); + score_elements.put(SMP_SCORE_CONTEXT, contextOverlapScore); + return score_elements; + } + + private double calculateStringSimilarity(String text, Entity candidate, Metric lev) { + String normText = StringUtils.toAlphaNumericWhitechar(text); + double totalAliases = 1.0, + totalScore = (double) lev.compare( + normText, + StringUtils.toAlphaNumericWhitechar(candidate.getLabel())); + + for (String alias : candidate.getAliases()) { + alias=StringUtils.toAlphaNumericWhitechar(alias); + if (alias.length() > 0) { + double score = lev.compare(normText, alias); + totalScore += score; + totalAliases += 1.0; + } + } + + return totalScore / totalAliases; + } + + @Override + public double computeFinal(Map scoreMap, String cellTextOriginal) { + double total = 0.0; + for (Map.Entry e : scoreMap.entrySet()) { + total += e.getValue(); + } + scoreMap.put(TCellAnnotation.SCORE_FINAL, total); + return total; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SMPInterpreter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SMPInterpreter.java index 7814285a..cef3caec 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SMPInterpreter.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SMPInterpreter.java @@ -1,142 +1,142 @@ -package uk.ac.shef.dcs.sti.core.algorithm.smp; - -import cern.colt.matrix.ObjectMatrix2D; -import javafx.util.Pair; -import org.apache.log4j.Logger; -import uk.ac.shef.dcs.kbsearch.KBSearchException; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.algorithm.SemanticTableInterpreter; -import uk.ac.shef.dcs.sti.core.subjectcol.SubjectColumnDetector; -import uk.ac.shef.dcs.sti.util.DataTypeClassifier; -import uk.ac.shef.dcs.sti.core.model.*; - -import java.util.*; -import java.util.List; - -/** - * Created by zqz on 20/04/2015. - */ -public class SMPInterpreter extends SemanticTableInterpreter { - - //main column finder is needed to generate data features of each column (e.g., data type in a column), - //even though we do not use it to find the main column in SMP - private static final Logger LOG = Logger.getLogger(SMPInterpreter.class.getName()); - private SubjectColumnDetector subjectColumnDetector; - private TCellEntityRanker neRanker; - private TColumnClassifier columnClassifier; - private TColumnColumnRelationEnumerator relationLearner; - private SemanticMessagePassing messagePassingCalculator; - - private static final int halting_num_of_iterations_middlepoint = 5; - private static final double min_pc_of_change_messages_for_column_concept_update = 0.0; - private static final double min_pc_of_change_messages_for_relation_update = 0.0; - private static final int halting_num_of_iterations_max = 10; - - public SMPInterpreter(SubjectColumnDetector subjectColumnDetector, - TCellEntityRanker neRanker, - TColumnClassifier columnClassifier, - TColumnColumnRelationEnumerator relationLearner, - SemanticMessagePassing messagePassingCalculator, - int[] ignoreColumns, - int[] mustdoColumns - ) { - super(ignoreColumns, mustdoColumns); - this.subjectColumnDetector = subjectColumnDetector; - this.relationLearner = relationLearner; - this.columnClassifier = columnClassifier; - this.neRanker = neRanker; - this.messagePassingCalculator = messagePassingCalculator; - } - - public TAnnotation start(Table table, boolean relationLearning) throws STIException { - TAnnotation tableAnnotations = - new TAnnotationSMPFreebase(table.getNumRows(), table.getNumCols()); - - //Main col finder finds main column. Although this is not needed by SMP, it also generates important features of - //table data types to be used later - int[] ignoreColumnsArray = new int[getIgnoreColumns().size()]; - - int index = 0; - for (Integer i : getIgnoreColumns()) { - ignoreColumnsArray[index] = i; - index++; - } - try { - LOG.info(">\t COLUMN FEATURE GENERATION AND SUBJECT COLUMN DETECTION (if enabled)..."); - List>> subjectColumnScores = - subjectColumnDetector.compute(table, ignoreColumnsArray); - tableAnnotations.setSubjectColumn(subjectColumnScores.get(0).getKey()); - - LOG.info(">\t NAMED ENTITY RANKER..."); //SMP begins with an initial NE ranker to rank candidate NEs for each cell - for (int col = 0; col < table.getNumCols(); col++) { - /*if(col!=1) - continue;*/ - if (isCompulsoryColumn(col)) { - LOG.info("\t\t>> Column=(compulsory)" + col); - for (int r = 0; r < table.getNumRows(); r++) { - neRanker.rankCandidateNamedEntities(tableAnnotations, table, r, col); - } - } else { - if (getIgnoreColumns().contains(col)) continue; - if (!table.getColumnHeader(col).getFeature().getMostFrequentDataType().getType().equals(DataTypeClassifier.DataType.NAMED_ENTITY)) - continue; - /*if (table.getColumnHeader(col).getFeature().isAcronymColumn()) - continue;*/ - //if (tab_annotations.getRelationAnnotationsBetween(main_subject_column, col) == null) { - LOG.info("\t\t>> Column=" + col); - for (int r = 0; r < table.getNumRows(); r++) { - neRanker.rankCandidateNamedEntities(tableAnnotations, table, r, col); - } - } - } - - LOG.info(">\t COMPUTING Column CLASSIFICATION AND Column-column RELATION"); - columnClassification(columnClassifier, tableAnnotations, table, getMustdoColumns(), getIgnoreColumns()); - if (relationLearning) { - LOG.info("\t> RELATION ENUMERATION"); - relationEnumeration(relationLearner, tableAnnotations, table, tableAnnotations.getSubjectColumn()); - } - - //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - LOG.info(">\t SEMANTIC MESSAGE PASSING"); - if (relationLearning) - messagePassingCalculator.start(table, tableAnnotations, columnClassifier, - relationLearner, getMustdoColumns(),getIgnoreColumns()); - else - messagePassingCalculator.start(table, tableAnnotations, columnClassifier, - null, getMustdoColumns(),getIgnoreColumns()); - - return tableAnnotations; - } catch (Exception e) { - throw new STIException(e); - } - } - - - protected static void columnClassification(TColumnClassifier columnClassifier, - TAnnotation tabAnnotations, Table table, - Collection mustDoColumns, - Collection ignoreColumns) throws KBSearchException { - // ObjectMatrix1D ccFactors = new SparseObjectMatrix1D(table.getNumCols()); - for (int col = 0; col < table.getNumCols(); col++) { - if (mustDoColumns.contains(col)) { - LOG.info("\t\t>> Column=(compulsory)" + col); - columnClassifier.classifyColumns(tabAnnotations, table, col); - } else { - if (ignoreColumns.contains(col)) continue; - if (!table.getColumnHeader(col).getFeature().getMostFrequentDataType().getType().equals(DataTypeClassifier.DataType.NAMED_ENTITY)) - continue; - LOG.info("\t\t>> Column=" + col); - columnClassifier.classifyColumns(tabAnnotations, table, col); - } - } - } - - protected static void relationEnumeration(TColumnColumnRelationEnumerator relationLearner, - TAnnotation tabAnnotations, - Table table, int subjectColumnIndex) throws STIException { - - relationLearner.runRelationEnumeration(tabAnnotations, table, subjectColumnIndex); - } - -} +package uk.ac.shef.dcs.sti.core.algorithm.smp; + +import cern.colt.matrix.ObjectMatrix2D; +import javafx.util.Pair; +import org.apache.log4j.Logger; +import uk.ac.shef.dcs.kbsearch.KBSearchException; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.algorithm.SemanticTableInterpreter; +import uk.ac.shef.dcs.sti.core.subjectcol.SubjectColumnDetector; +import uk.ac.shef.dcs.sti.util.DataTypeClassifier; +import uk.ac.shef.dcs.sti.core.model.*; + +import java.util.*; +import java.util.List; + +/** + * Created by zqz on 20/04/2015. + */ +public class SMPInterpreter extends SemanticTableInterpreter { + + //main column finder is needed to generate data features of each column (e.g., data type in a column), + //even though we do not use it to find the main column in SMP + private static final Logger LOG = Logger.getLogger(SMPInterpreter.class.getName()); + private SubjectColumnDetector subjectColumnDetector; + private TCellEntityRanker neRanker; + private TColumnClassifier columnClassifier; + private TColumnColumnRelationEnumerator relationLearner; + private SemanticMessagePassing messagePassingCalculator; + + private static final int halting_num_of_iterations_middlepoint = 5; + private static final double min_pc_of_change_messages_for_column_concept_update = 0.0; + private static final double min_pc_of_change_messages_for_relation_update = 0.0; + private static final int halting_num_of_iterations_max = 10; + + public SMPInterpreter(SubjectColumnDetector subjectColumnDetector, + TCellEntityRanker neRanker, + TColumnClassifier columnClassifier, + TColumnColumnRelationEnumerator relationLearner, + SemanticMessagePassing messagePassingCalculator, + int[] ignoreColumns, + int[] mustdoColumns + ) { + super(ignoreColumns, mustdoColumns); + this.subjectColumnDetector = subjectColumnDetector; + this.relationLearner = relationLearner; + this.columnClassifier = columnClassifier; + this.neRanker = neRanker; + this.messagePassingCalculator = messagePassingCalculator; + } + + public TAnnotation start(Table table, boolean relationLearning) throws STIException { + TAnnotation tableAnnotations = + new TAnnotationSMPFreebase(table.getNumRows(), table.getNumCols()); + + //Main col finder finds main column. Although this is not needed by SMP, it also generates important features of + //table data types to be used later + int[] ignoreColumnsArray = new int[getIgnoreColumns().size()]; + + int index = 0; + for (Integer i : getIgnoreColumns()) { + ignoreColumnsArray[index] = i; + index++; + } + try { + LOG.info(">\t COLUMN FEATURE GENERATION AND SUBJECT COLUMN DETECTION (if enabled)..."); + List>> subjectColumnScores = + subjectColumnDetector.compute(table, ignoreColumnsArray); + tableAnnotations.setSubjectColumn(subjectColumnScores.get(0).getKey()); + + LOG.info(">\t NAMED ENTITY RANKER..."); //SMP begins with an initial NE ranker to rank candidate NEs for each cell + for (int col = 0; col < table.getNumCols(); col++) { + /*if(col!=1) + continue;*/ + if (isCompulsoryColumn(col)) { + LOG.info("\t\t>> Column=(compulsory)" + col); + for (int r = 0; r < table.getNumRows(); r++) { + neRanker.rankCandidateNamedEntities(tableAnnotations, table, r, col); + } + } else { + if (getIgnoreColumns().contains(col)) continue; + if (!table.getColumnHeader(col).getFeature().getMostFrequentDataType().getType().equals(DataTypeClassifier.DataType.NAMED_ENTITY)) + continue; + /*if (table.getColumnHeader(col).getFeature().isAcronymColumn()) + continue;*/ + //if (tab_annotations.getRelationAnnotationsBetween(main_subject_column, col) == null) { + LOG.info("\t\t>> Column=" + col); + for (int r = 0; r < table.getNumRows(); r++) { + neRanker.rankCandidateNamedEntities(tableAnnotations, table, r, col); + } + } + } + + LOG.info(">\t COMPUTING Column CLASSIFICATION AND Column-column RELATION"); + columnClassification(columnClassifier, tableAnnotations, table, getMustdoColumns(), getIgnoreColumns()); + if (relationLearning) { + LOG.info("\t> RELATION ENUMERATION"); + relationEnumeration(relationLearner, tableAnnotations, table, tableAnnotations.getSubjectColumn()); + } + + //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + LOG.info(">\t SEMANTIC MESSAGE PASSING"); + if (relationLearning) + messagePassingCalculator.start(table, tableAnnotations, columnClassifier, + relationLearner, getMustdoColumns(),getIgnoreColumns()); + else + messagePassingCalculator.start(table, tableAnnotations, columnClassifier, + null, getMustdoColumns(),getIgnoreColumns()); + + return tableAnnotations; + } catch (Exception e) { + throw new STIException(e); + } + } + + + protected static void columnClassification(TColumnClassifier columnClassifier, + TAnnotation tabAnnotations, Table table, + Collection mustDoColumns, + Collection ignoreColumns) throws KBSearchException { + // ObjectMatrix1D ccFactors = new SparseObjectMatrix1D(table.getNumCols()); + for (int col = 0; col < table.getNumCols(); col++) { + if (mustDoColumns.contains(col)) { + LOG.info("\t\t>> Column=(compulsory)" + col); + columnClassifier.classifyColumns(tabAnnotations, table, col); + } else { + if (ignoreColumns.contains(col)) continue; + if (!table.getColumnHeader(col).getFeature().getMostFrequentDataType().getType().equals(DataTypeClassifier.DataType.NAMED_ENTITY)) + continue; + LOG.info("\t\t>> Column=" + col); + columnClassifier.classifyColumns(tabAnnotations, table, col); + } + } + } + + protected static void relationEnumeration(TColumnColumnRelationEnumerator relationLearner, + TAnnotation tabAnnotations, + Table table, int subjectColumnIndex) throws STIException { + + relationLearner.runRelationEnumeration(tabAnnotations, table, subjectColumnIndex); + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SemanticMessagePassing.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SemanticMessagePassing.java index 00cbd45c..5b9ba260 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SemanticMessagePassing.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/SemanticMessagePassing.java @@ -1,138 +1,138 @@ -package uk.ac.shef.dcs.sti.core.algorithm.smp; - -import cern.colt.matrix.ObjectMatrix2D; -import org.apache.log4j.Logger; -import uk.ac.shef.dcs.kbsearch.KBSearchException; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.model.*; - -import java.util.*; -import java.util.List; - -/** - * Created by - on 11/04/2016. - */ -public class SemanticMessagePassing { - - private int haltingMaxIterations=10; - private CellAnnotationUpdater cellAnnotationUpdater; - private ChangeMessageComputer messageComputer; - - private static final Logger LOG = Logger.getLogger(SemanticMessagePassing.class.getName()); - - public SemanticMessagePassing(int haltingMaxIterations, double changeMessageScoreThreshold){ - this.haltingMaxIterations=haltingMaxIterations; - cellAnnotationUpdater = new CellAnnotationUpdater(); - messageComputer = new ChangeMessageComputer(changeMessageScoreThreshold); - } - - protected void start(Table table, TAnnotation tableAnnotations, - TColumnClassifier columnClassifier, - TColumnColumnRelationEnumerator relationLearner, - Collection mustDoColumns, - Collection ignoreColumns) throws STIException, KBSearchException { - TAnnotation copy; - for (int i = 1; i <= haltingMaxIterations; i++) { - LOG.info("\t\t>> [ITERATION] " + i); - copy = new TAnnotation(table.getNumRows(), table.getNumCols()); - TAnnotation.copy(tableAnnotations, copy); - //column concept and relation factors send message to entity factors - LOG.info("\t\t>> computing messages"); - ObjectMatrix2D messages = messageComputer. - computeChangeMessages(tableAnnotations, table); - - //re-compute cell annotations based on messages - LOG.info("\t\t>> cell annotation update"); - int[] updateResult = cellAnnotationUpdater.update(messages, tableAnnotations); - LOG.info("\t\t (requiredForUpdate=" + updateResult[1] + ", updated=" + updateResult[0] + ")"); - - //check stopping condition - boolean stop = haltingConditionReached(i, haltingMaxIterations, copy, tableAnnotations); - if (stop) { - LOG.info("\t> Halting condition reached, iteration=" + i); - break; - } else { - //re-compute header and relation annotations - LOG.info(">\t Halting condition NOT reached, re-compute column and relation annotations based on updated cell annotations: iter=" + i); - resetClassesAndRelations(tableAnnotations); - SMPInterpreter.columnClassification(columnClassifier, tableAnnotations, table,mustDoColumns,ignoreColumns); - if (relationLearner!=null) - SMPInterpreter.relationEnumeration(relationLearner, - tableAnnotations, table, tableAnnotations.getSubjectColumn()); - } - } - } - - private boolean haltingConditionReached(int currentIteration, - int maxIterations, - TAnnotation previous, - TAnnotation current) { - if (currentIteration == maxIterations) - return true; - - //check header annotations - int header_converged_count = 0; - boolean header_converged = false; - for (int c = 0; c < previous.getCols(); c++) { - List header_annotations_prev_iteration = previous.getWinningHeaderAnnotations(c); - List header_annotations_current_iteration = current.getWinningHeaderAnnotations(c); - if (header_annotations_prev_iteration == null && header_annotations_current_iteration == null) { - header_converged_count++; - continue; - } - if (header_annotations_current_iteration.size() == header_annotations_prev_iteration.size()) { - header_annotations_current_iteration.retainAll(header_annotations_prev_iteration); - if (header_annotations_current_iteration.size() == header_annotations_prev_iteration.size()) - header_converged_count++; - else - return false; - } else - return false; - } - if (header_converged_count == previous.getCols()) { - header_converged = true; - } - - //check cell annotations - for (int c = 0; c < previous.getCols(); c++) { - for (int row = 0; row < previous.getRows(); row++) { - List cell_prev_annotations = previous.getWinningContentCellAnnotation(row, c); - List cell_current_annotations = current.getWinningContentCellAnnotation(row, c); - if (cell_current_annotations.size() == cell_prev_annotations.size()) { - cell_current_annotations.retainAll(cell_prev_annotations); - if (cell_current_annotations.size() != cell_prev_annotations.size()) - return false; - } - } - } - - //check relation annotations - int relation_converged_count = 0; - boolean relation_converged = false; - Map> prev_relations = previous.getColumncolumnRelations(); - Map> current_relation = current.getColumncolumnRelations(); - Set tmp_keys = new HashSet<>(prev_relations.keySet()); - tmp_keys.retainAll(current_relation.keySet()); - if (tmp_keys.size() != prev_relations.keySet().size() || tmp_keys.size() != current_relation.keySet().size()) - return false; - for (RelationColumns subobj : tmp_keys) { - List prev_candidates = previous.getWinningRelationAnnotationsBetween(subobj); - List current_candidates = current.getWinningRelationAnnotationsBetween(subobj); - List tmp = new ArrayList<>(prev_candidates); - tmp.retainAll(current_candidates); - if (tmp.size() == prev_candidates.size() && tmp.size() == current_candidates.size()) { - relation_converged_count++; - } - } - if (relation_converged_count == tmp_keys.size()) - relation_converged = true; - - return header_converged && relation_converged; - } - - private void resetClassesAndRelations(TAnnotation tab_annotations) { - tab_annotations.resetHeaderAnnotations(); - tab_annotations.resetRelationAnnotations(); - } - -} +package uk.ac.shef.dcs.sti.core.algorithm.smp; + +import cern.colt.matrix.ObjectMatrix2D; +import org.apache.log4j.Logger; +import uk.ac.shef.dcs.kbsearch.KBSearchException; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.model.*; + +import java.util.*; +import java.util.List; + +/** + * Created by - on 11/04/2016. + */ +public class SemanticMessagePassing { + + private int haltingMaxIterations=10; + private CellAnnotationUpdater cellAnnotationUpdater; + private ChangeMessageComputer messageComputer; + + private static final Logger LOG = Logger.getLogger(SemanticMessagePassing.class.getName()); + + public SemanticMessagePassing(int haltingMaxIterations, double changeMessageScoreThreshold){ + this.haltingMaxIterations=haltingMaxIterations; + cellAnnotationUpdater = new CellAnnotationUpdater(); + messageComputer = new ChangeMessageComputer(changeMessageScoreThreshold); + } + + protected void start(Table table, TAnnotation tableAnnotations, + TColumnClassifier columnClassifier, + TColumnColumnRelationEnumerator relationLearner, + Collection mustDoColumns, + Collection ignoreColumns) throws STIException, KBSearchException { + TAnnotation copy; + for (int i = 1; i <= haltingMaxIterations; i++) { + LOG.info("\t\t>> [ITERATION] " + i); + copy = new TAnnotation(table.getNumRows(), table.getNumCols()); + TAnnotation.copy(tableAnnotations, copy); + //column concept and relation factors send message to entity factors + LOG.info("\t\t>> computing messages"); + ObjectMatrix2D messages = messageComputer. + computeChangeMessages(tableAnnotations, table); + + //re-compute cell annotations based on messages + LOG.info("\t\t>> cell annotation update"); + int[] updateResult = cellAnnotationUpdater.update(messages, tableAnnotations); + LOG.info("\t\t (requiredForUpdate=" + updateResult[1] + ", updated=" + updateResult[0] + ")"); + + //check stopping condition + boolean stop = haltingConditionReached(i, haltingMaxIterations, copy, tableAnnotations); + if (stop) { + LOG.info("\t> Halting condition reached, iteration=" + i); + break; + } else { + //re-compute header and relation annotations + LOG.info(">\t Halting condition NOT reached, re-compute column and relation annotations based on updated cell annotations: iter=" + i); + resetClassesAndRelations(tableAnnotations); + SMPInterpreter.columnClassification(columnClassifier, tableAnnotations, table,mustDoColumns,ignoreColumns); + if (relationLearner!=null) + SMPInterpreter.relationEnumeration(relationLearner, + tableAnnotations, table, tableAnnotations.getSubjectColumn()); + } + } + } + + private boolean haltingConditionReached(int currentIteration, + int maxIterations, + TAnnotation previous, + TAnnotation current) { + if (currentIteration == maxIterations) + return true; + + //check header annotations + int header_converged_count = 0; + boolean header_converged = false; + for (int c = 0; c < previous.getCols(); c++) { + List header_annotations_prev_iteration = previous.getWinningHeaderAnnotations(c); + List header_annotations_current_iteration = current.getWinningHeaderAnnotations(c); + if (header_annotations_prev_iteration == null && header_annotations_current_iteration == null) { + header_converged_count++; + continue; + } + if (header_annotations_current_iteration.size() == header_annotations_prev_iteration.size()) { + header_annotations_current_iteration.retainAll(header_annotations_prev_iteration); + if (header_annotations_current_iteration.size() == header_annotations_prev_iteration.size()) + header_converged_count++; + else + return false; + } else + return false; + } + if (header_converged_count == previous.getCols()) { + header_converged = true; + } + + //check cell annotations + for (int c = 0; c < previous.getCols(); c++) { + for (int row = 0; row < previous.getRows(); row++) { + List cell_prev_annotations = previous.getWinningContentCellAnnotation(row, c); + List cell_current_annotations = current.getWinningContentCellAnnotation(row, c); + if (cell_current_annotations.size() == cell_prev_annotations.size()) { + cell_current_annotations.retainAll(cell_prev_annotations); + if (cell_current_annotations.size() != cell_prev_annotations.size()) + return false; + } + } + } + + //check relation annotations + int relation_converged_count = 0; + boolean relation_converged = false; + Map> prev_relations = previous.getColumncolumnRelations(); + Map> current_relation = current.getColumncolumnRelations(); + Set tmp_keys = new HashSet<>(prev_relations.keySet()); + tmp_keys.retainAll(current_relation.keySet()); + if (tmp_keys.size() != prev_relations.keySet().size() || tmp_keys.size() != current_relation.keySet().size()) + return false; + for (RelationColumns subobj : tmp_keys) { + List prev_candidates = previous.getWinningRelationAnnotationsBetween(subobj); + List current_candidates = current.getWinningRelationAnnotationsBetween(subobj); + List tmp = new ArrayList<>(prev_candidates); + tmp.retainAll(current_candidates); + if (tmp.size() == prev_candidates.size() && tmp.size() == current_candidates.size()) { + relation_converged_count++; + } + } + if (relation_converged_count == tmp_keys.size()) + relation_converged = true; + + return header_converged && relation_converged; + } + + private void resetClassesAndRelations(TAnnotation tab_annotations) { + tab_annotations.resetHeaderAnnotations(); + tab_annotations.resetRelationAnnotations(); + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TAnnotationSMPFreebase.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TAnnotationSMPFreebase.java index a0e0d699..3ed8d4b2 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TAnnotationSMPFreebase.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TAnnotationSMPFreebase.java @@ -1,78 +1,78 @@ -package uk.ac.shef.dcs.sti.core.algorithm.smp; - -import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; -import uk.ac.shef.dcs.sti.core.model.TAnnotation; - -import java.util.*; - -/** - * SMP uses granularity of a concept. In freebase, not every concept has instances. - * some concepts are classified as "topic" and not properly as a concept, and therefore, they have no instances - * Currently #KBSearcher_Freebase simply returns "1" for such concepts, effectively they have the maximum granularity. - * This put other concepts that do have instances (e.g., /location/location) at disadvantage. - * - * This class extends TAnnotation and overwrites method #getWinningHeaderAnnotations to cope with such problems. - * Effectively, the "real" freebase concept that has the smallest number of instances (highest granularity) and any - * "topic-based" concept (/m/*) are both considered the best header annotations - */ -public class TAnnotationSMPFreebase extends TAnnotation { - public TAnnotationSMPFreebase(int rows, int cols) { - super(rows, cols); - } - - public TColumnHeaderAnnotation[] getHeaderAnnotation(int headerCol){ - Object o=headerAnnotations.get(headerCol); - if(o==null) - return new TColumnHeaderAnnotation[0]; - TColumnHeaderAnnotation[] ha = (TColumnHeaderAnnotation[]) o; - Arrays.sort(ha, (o1, o2) -> { - int compared = ((Double) o2.getFinalScore()).compareTo(o1.getFinalScore()); - if (compared == 0) { - Double o1_granularity = o1.getScoreElements().get(TColumnClassifier.SMP_SCORE_GRANULARITY); - Double o2_granularity = o2.getScoreElements().get(TColumnClassifier.SMP_SCORE_GRANULARITY); - return o1_granularity.compareTo(o2_granularity); - } - return compared; - }); - - return ha; - } - - public List getWinningHeaderAnnotations(int headerCol){ - TColumnHeaderAnnotation[] annotations =getHeaderAnnotation(headerCol); - List result = new ArrayList<>(); - if(annotations==null||annotations.length==0) - return result; - - List sorted = Arrays.asList(annotations); - Collections.sort(sorted); - - //container to keep temporarily any concepts that have real instances and computeElementScores the same "entity computeElementScores) - List tmp = new ArrayList(); - double maxScore = sorted.get(0).getFinalScore(); - for(TColumnHeaderAnnotation h: sorted){ - if(h.getFinalScore()==maxScore){ - if(h.getAnnotation().getId().startsWith("/m/")) - result.add(h); - else{ - tmp.add(h); - } - } - } - - if(tmp.size()>1){ - Collections.sort(tmp, (o1, o2) -> o1.getScoreElements().get(TColumnClassifier.SMP_SCORE_GRANULARITY).compareTo( - o2.getScoreElements().get(TColumnClassifier.SMP_SCORE_GRANULARITY) - )); - Double highest_granularity_score = tmp.get(0).getScoreElements().get(TColumnClassifier.SMP_SCORE_GRANULARITY); - for(TColumnHeaderAnnotation ha: tmp){ - if(ha.getScoreElements().get(TColumnClassifier.SMP_SCORE_GRANULARITY)==highest_granularity_score) - result.add(ha); - } - }else{ - result.addAll(tmp); - } - - return result; - } -} +package uk.ac.shef.dcs.sti.core.algorithm.smp; + +import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; +import uk.ac.shef.dcs.sti.core.model.TAnnotation; + +import java.util.*; + +/** + * SMP uses granularity of a concept. In freebase, not every concept has instances. + * some concepts are classified as "topic" and not properly as a concept, and therefore, they have no instances + * Currently #KBSearcher_Freebase simply returns "1" for such concepts, effectively they have the maximum granularity. + * This put other concepts that do have instances (e.g., /location/location) at disadvantage. + * + * This class extends TAnnotation and overwrites method #getWinningHeaderAnnotations to cope with such problems. + * Effectively, the "real" freebase concept that has the smallest number of instances (highest granularity) and any + * "topic-based" concept (/m/*) are both considered the best header annotations + */ +public class TAnnotationSMPFreebase extends TAnnotation { + public TAnnotationSMPFreebase(int rows, int cols) { + super(rows, cols); + } + + public TColumnHeaderAnnotation[] getHeaderAnnotation(int headerCol){ + Object o=headerAnnotations.get(headerCol); + if(o==null) + return new TColumnHeaderAnnotation[0]; + TColumnHeaderAnnotation[] ha = (TColumnHeaderAnnotation[]) o; + Arrays.sort(ha, (o1, o2) -> { + int compared = ((Double) o2.getFinalScore()).compareTo(o1.getFinalScore()); + if (compared == 0) { + Double o1_granularity = o1.getScoreElements().get(TColumnClassifier.SMP_SCORE_GRANULARITY); + Double o2_granularity = o2.getScoreElements().get(TColumnClassifier.SMP_SCORE_GRANULARITY); + return o1_granularity.compareTo(o2_granularity); + } + return compared; + }); + + return ha; + } + + public List getWinningHeaderAnnotations(int headerCol){ + TColumnHeaderAnnotation[] annotations =getHeaderAnnotation(headerCol); + List result = new ArrayList<>(); + if(annotations==null||annotations.length==0) + return result; + + List sorted = Arrays.asList(annotations); + Collections.sort(sorted); + + //container to keep temporarily any concepts that have real instances and computeElementScores the same "entity computeElementScores) + List tmp = new ArrayList(); + double maxScore = sorted.get(0).getFinalScore(); + for(TColumnHeaderAnnotation h: sorted){ + if(h.getFinalScore()==maxScore){ + if(h.getAnnotation().getId().startsWith("/m/")) + result.add(h); + else{ + tmp.add(h); + } + } + } + + if(tmp.size()>1){ + Collections.sort(tmp, (o1, o2) -> o1.getScoreElements().get(TColumnClassifier.SMP_SCORE_GRANULARITY).compareTo( + o2.getScoreElements().get(TColumnClassifier.SMP_SCORE_GRANULARITY) + )); + Double highest_granularity_score = tmp.get(0).getScoreElements().get(TColumnClassifier.SMP_SCORE_GRANULARITY); + for(TColumnHeaderAnnotation ha: tmp){ + if(ha.getScoreElements().get(TColumnClassifier.SMP_SCORE_GRANULARITY)==highest_granularity_score) + result.add(ha); + } + }else{ + result.addAll(tmp); + } + + return result; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TAnnotationWriterSMP.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TAnnotationWriterSMP.java index d0f3952f..9a3d5fff 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TAnnotationWriterSMP.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TAnnotationWriterSMP.java @@ -1,102 +1,102 @@ -package uk.ac.shef.dcs.sti.core.algorithm.smp; - -import uk.ac.shef.dcs.sti.util.TripleGenerator; -import uk.ac.shef.dcs.sti.io.TAnnotationWriter; -import uk.ac.shef.dcs.sti.util.DataTypeClassifier; -import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.core.model.TAnnotation; -import uk.ac.shef.dcs.sti.core.model.TColumnHeader; - -import java.io.FileNotFoundException; -import java.io.PrintWriter; - -/** - * Created by zqz on 29/04/2015. - */ -public class TAnnotationWriterSMP extends TAnnotationWriter { - public TAnnotationWriterSMP(TripleGenerator tripleGenerator) { - super(tripleGenerator); - } - - protected void writeHeaderKeyFile(Table table, TAnnotation table_annotation, String header_key) throws FileNotFoundException { - if (!(table_annotation instanceof TAnnotationSMPFreebase)) - super.writeHeaderKeyFile(table, table_annotation, header_key); - else { - PrintWriter p = new PrintWriter(header_key); - - for (int c = 0; c < table.getNumCols(); c++) { - TColumnHeaderAnnotation[] anns = table_annotation.getHeaderAnnotation(c); - if (anns != null && anns.length > 0) { - StringBuilder s = new StringBuilder(); - s.append(c).append("="); - - double prevScore = 0.0; - double prevGranularity = 0.0; - for (TColumnHeaderAnnotation ha : anns) { - if (prevScore == 0.0) { - s.append(ha.getAnnotation().getId()); - prevScore = ha.getFinalScore(); - prevGranularity = ha.getScoreElements().get(TColumnClassifier.SMP_SCORE_GRANULARITY); - } else { - if (ha.getFinalScore() == prevScore && ha.getScoreElements().get(TColumnClassifier.SMP_SCORE_GRANULARITY)==prevGranularity) { - s.append("=").append(ha.getAnnotation().getId()); - } else - s.append("|").append(ha.getAnnotation().getId()); - } - } - if (table.getColumnHeader(c).getFeature().getMostFrequentDataType().getType().equals( - DataTypeClassifier.DataType.NAMED_ENTITY - )) - s.append("\t\t\t___NE"); - p.println(s.toString()); - } - } - - p.close(); - } - } - - protected String writeHeader(Table table, TAnnotation tab_annotations) { - StringBuilder out = new StringBuilder(); - out.append("
\n"); - for (int col = 0; col < table.getNumCols(); col++) { - TColumnHeader header = table.getColumnHeader(col); - if(header==null) - continue; - out.append("\t\n"); - - //then annotations - out.append("\t-"); - else { - annotation.append(" bgcolor=\"#00FF00\">"); - double best_score = 0.0, best_granularity_score=0.0; - for (int i = 0; i < hAnns.length; i++) { - TColumnHeaderAnnotation hAnn = hAnns[i]; - if (i == 0) { //the winning annotation - annotation.append("
").append(generateHeaderAnnotationString(hAnn)).append("
"); - best_score = hAnn.getFinalScore(); - best_granularity_score=hAnn.getScoreElements().get( - TColumnClassifier.SMP_SCORE_GRANULARITY - ); - } else if (hAnn.getFinalScore() == best_score && - hAnn.getScoreElements().get( - TColumnClassifier.SMP_SCORE_GRANULARITY)==best_granularity_score) { - annotation.append("
").append(generateHeaderAnnotationString(hAnn)).append("
"); - } else if (showLosingCandidates) { //others - annotation.append("
"). - append(generateHeaderAnnotationString(hAnn)).append("
"); - } - } - } - annotation.append("\t\n"); - out.append(annotation); - } - out.append("
\n"); - return out.toString(); - } -} +package uk.ac.shef.dcs.sti.core.algorithm.smp; + +import uk.ac.shef.dcs.sti.util.TripleGenerator; +import uk.ac.shef.dcs.sti.io.TAnnotationWriter; +import uk.ac.shef.dcs.sti.util.DataTypeClassifier; +import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.core.model.TAnnotation; +import uk.ac.shef.dcs.sti.core.model.TColumnHeader; + +import java.io.FileNotFoundException; +import java.io.PrintWriter; + +/** + * Created by zqz on 29/04/2015. + */ +public class TAnnotationWriterSMP extends TAnnotationWriter { + public TAnnotationWriterSMP(TripleGenerator tripleGenerator) { + super(tripleGenerator); + } + + protected void writeHeaderKeyFile(Table table, TAnnotation table_annotation, String header_key) throws FileNotFoundException { + if (!(table_annotation instanceof TAnnotationSMPFreebase)) + super.writeHeaderKeyFile(table, table_annotation, header_key); + else { + PrintWriter p = new PrintWriter(header_key); + + for (int c = 0; c < table.getNumCols(); c++) { + TColumnHeaderAnnotation[] anns = table_annotation.getHeaderAnnotation(c); + if (anns != null && anns.length > 0) { + StringBuilder s = new StringBuilder(); + s.append(c).append("="); + + double prevScore = 0.0; + double prevGranularity = 0.0; + for (TColumnHeaderAnnotation ha : anns) { + if (prevScore == 0.0) { + s.append(ha.getAnnotation().getId()); + prevScore = ha.getFinalScore(); + prevGranularity = ha.getScoreElements().get(TColumnClassifier.SMP_SCORE_GRANULARITY); + } else { + if (ha.getFinalScore() == prevScore && ha.getScoreElements().get(TColumnClassifier.SMP_SCORE_GRANULARITY)==prevGranularity) { + s.append("=").append(ha.getAnnotation().getId()); + } else + s.append("|").append(ha.getAnnotation().getId()); + } + } + if (table.getColumnHeader(c).getFeature().getMostFrequentDataType().getType().equals( + DataTypeClassifier.DataType.NAMED_ENTITY + )) + s.append("\t\t\t___NE"); + p.println(s.toString()); + } + } + + p.close(); + } + } + + protected String writeHeader(Table table, TAnnotation tab_annotations) { + StringBuilder out = new StringBuilder(); + out.append("\n"); + for (int col = 0; col < table.getNumCols(); col++) { + TColumnHeader header = table.getColumnHeader(col); + if(header==null) + continue; + out.append("\t\n"); + + //then annotations + out.append("\t-"); + else { + annotation.append(" bgcolor=\"#00FF00\">"); + double best_score = 0.0, best_granularity_score=0.0; + for (int i = 0; i < hAnns.length; i++) { + TColumnHeaderAnnotation hAnn = hAnns[i]; + if (i == 0) { //the winning annotation + annotation.append("
").append(generateHeaderAnnotationString(hAnn)).append("
"); + best_score = hAnn.getFinalScore(); + best_granularity_score=hAnn.getScoreElements().get( + TColumnClassifier.SMP_SCORE_GRANULARITY + ); + } else if (hAnn.getFinalScore() == best_score && + hAnn.getScoreElements().get( + TColumnClassifier.SMP_SCORE_GRANULARITY)==best_granularity_score) { + annotation.append("
").append(generateHeaderAnnotationString(hAnn)).append("
"); + } else if (showLosingCandidates) { //others + annotation.append("
"). + append(generateHeaderAnnotationString(hAnn)).append("
"); + } + } + } + annotation.append("\t\n"); + out.append(annotation); + } + out.append("
\n"); + return out.toString(); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnClassifier.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnClassifier.java index 2a57c3e0..19985b69 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnClassifier.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnClassifier.java @@ -1,113 +1,113 @@ -package uk.ac.shef.dcs.sti.core.algorithm.smp; - -import javafx.util.Pair; -import org.apache.log4j.Logger; -import uk.ac.shef.dcs.kbsearch.KBSearch; -import uk.ac.shef.dcs.kbsearch.KBSearchException; -import uk.ac.shef.dcs.kbsearch.model.Clazz; -import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; -import uk.ac.shef.dcs.sti.util.DataTypeClassifier; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; -import uk.ac.shef.dcs.sti.core.model.TAnnotation; -import uk.ac.shef.dcs.sti.core.model.Table; - -import java.util.*; - -/** - * - */ -public class TColumnClassifier { - - private static final Logger LOG =Logger.getLogger(TColumnClassifier.class.getName()); - - private KBSearch kbSearch; - private ClazzSpecificityCalculator csCalculator; - - public static final String SMP_SCORE_ENTITY_VOTE = "smp_score_entity_vote"; - public static final String SMP_SCORE_GRANULARITY = "smp_score_granularity"; - - public TColumnClassifier(KBSearch kbSearch, - ClazzSpecificityCalculator csCalculator) { - this.kbSearch = kbSearch; - this.csCalculator=csCalculator; - } - - public void classifyColumns(TAnnotation tableAnnotation, Table table, int col) throws KBSearchException { - int totalNonEmpty = 0; - //Firstly collect votes - Map votes = new HashMap<>(); - for (int r = 0; r < table.getNumRows(); r++) { - //in case multiple NEs have the same computeElementScores, we take them all - if (!table.getContentCell(r, col).getType().equals(DataTypeClassifier.DataType.EMPTY)) - totalNonEmpty++; - List winningCellAnnotations = tableAnnotation.getWinningContentCellAnnotation(r, col); - if (winningCellAnnotations.size() > 0) { - Set distinctTypes = new HashSet<>(); - for (TCellAnnotation ca : winningCellAnnotations) { - Entity e = ca.getAnnotation(); - distinctTypes.addAll(e.getTypeIds()); - } - for (String t : distinctTypes) { - Double v = votes.get(t); - v = v == null ? 1.0 : v; - v += 1.0; - votes.put(t, v); - } - } - } - - //Second, calculate vote score, and concept specificity score - if (votes.size() != 0) { //couuld be 0 if the column has not NE annotations at all - List> voteResult = new ArrayList<>(); - for (Map.Entry e : votes.entrySet()) { - double voteScore = e.getValue() / totalNonEmpty; - voteScore+=csCalculator.compute(e.getKey()); - LOG.info("\t\t>> computing class specificity score (can involve querying the KB...) for "+e.getKey()); - voteResult.add(new Pair<>(e.getKey(), - voteScore)); - } - Collections.sort(voteResult, (o1, o2) -> o2.getValue().compareTo(o1.getValue())); - - //tie breaker based on granularity computeElementScores of concepts - double maxScore = voteResult.get(0).getValue(); - //is there a tie? - int count_same_max_score = 0; - for (Pair oo : voteResult) { - if (oo.getValue() == maxScore) { - count_same_max_score++; - if (count_same_max_score > 1) { - break; - } - } - } - final Map granularityScore = new HashMap<>(); - if (count_same_max_score > 1) { - for (Pair e : voteResult) { - if (e.getValue() == maxScore) { - granularityScore.put(e.getKey(), kbSearch.findGranularityOfClazz(e.getKey())); - } - } - } - - //a header annotation will only have granularity score if there are more than one candidate with the same vote computeElementScores - TColumnHeaderAnnotation[] headerAnnotations = new TColumnHeaderAnnotation[voteResult.size()]; - int i = 0; - for (Pair oo : voteResult) { - TColumnHeaderAnnotation ha = - new TColumnHeaderAnnotation(table.getColumnHeader(col).getHeaderText(), - new Clazz(oo.getKey(), oo.getKey()), oo.getValue()); - ha.getScoreElements().put(SMP_SCORE_ENTITY_VOTE, oo.getValue()); - Double granularity = granularityScore.get(oo.getKey()); - granularity = granularity == null ? 0 : granularity; - ha.getScoreElements().put(SMP_SCORE_GRANULARITY, granularity); - ha.getScoreElements().put(TColumnHeaderAnnotation.SCORE_FINAL, oo.getValue()); - headerAnnotations[i] = ha; - i++; - } - tableAnnotation.setHeaderAnnotation(col, headerAnnotations); - } - } - - -} +package uk.ac.shef.dcs.sti.core.algorithm.smp; + +import javafx.util.Pair; +import org.apache.log4j.Logger; +import uk.ac.shef.dcs.kbsearch.KBSearch; +import uk.ac.shef.dcs.kbsearch.KBSearchException; +import uk.ac.shef.dcs.kbsearch.model.Clazz; +import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; +import uk.ac.shef.dcs.sti.util.DataTypeClassifier; +import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; +import uk.ac.shef.dcs.sti.core.model.TAnnotation; +import uk.ac.shef.dcs.sti.core.model.Table; + +import java.util.*; + +/** + * + */ +public class TColumnClassifier { + + private static final Logger LOG =Logger.getLogger(TColumnClassifier.class.getName()); + + private KBSearch kbSearch; + private ClazzSpecificityCalculator csCalculator; + + public static final String SMP_SCORE_ENTITY_VOTE = "smp_score_entity_vote"; + public static final String SMP_SCORE_GRANULARITY = "smp_score_granularity"; + + public TColumnClassifier(KBSearch kbSearch, + ClazzSpecificityCalculator csCalculator) { + this.kbSearch = kbSearch; + this.csCalculator=csCalculator; + } + + public void classifyColumns(TAnnotation tableAnnotation, Table table, int col) throws KBSearchException { + int totalNonEmpty = 0; + //Firstly collect votes + Map votes = new HashMap<>(); + for (int r = 0; r < table.getNumRows(); r++) { + //in case multiple NEs have the same computeElementScores, we take them all + if (!table.getContentCell(r, col).getType().equals(DataTypeClassifier.DataType.EMPTY)) + totalNonEmpty++; + List winningCellAnnotations = tableAnnotation.getWinningContentCellAnnotation(r, col); + if (winningCellAnnotations.size() > 0) { + Set distinctTypes = new HashSet<>(); + for (TCellAnnotation ca : winningCellAnnotations) { + Entity e = ca.getAnnotation(); + distinctTypes.addAll(e.getTypeIds()); + } + for (String t : distinctTypes) { + Double v = votes.get(t); + v = v == null ? 1.0 : v; + v += 1.0; + votes.put(t, v); + } + } + } + + //Second, calculate vote score, and concept specificity score + if (votes.size() != 0) { //couuld be 0 if the column has not NE annotations at all + List> voteResult = new ArrayList<>(); + for (Map.Entry e : votes.entrySet()) { + double voteScore = e.getValue() / totalNonEmpty; + voteScore+=csCalculator.compute(e.getKey()); + LOG.info("\t\t>> computing class specificity score (can involve querying the KB...) for "+e.getKey()); + voteResult.add(new Pair<>(e.getKey(), + voteScore)); + } + Collections.sort(voteResult, (o1, o2) -> o2.getValue().compareTo(o1.getValue())); + + //tie breaker based on granularity computeElementScores of concepts + double maxScore = voteResult.get(0).getValue(); + //is there a tie? + int count_same_max_score = 0; + for (Pair oo : voteResult) { + if (oo.getValue() == maxScore) { + count_same_max_score++; + if (count_same_max_score > 1) { + break; + } + } + } + final Map granularityScore = new HashMap<>(); + if (count_same_max_score > 1) { + for (Pair e : voteResult) { + if (e.getValue() == maxScore) { + granularityScore.put(e.getKey(), kbSearch.findGranularityOfClazz(e.getKey())); + } + } + } + + //a header annotation will only have granularity score if there are more than one candidate with the same vote computeElementScores + TColumnHeaderAnnotation[] headerAnnotations = new TColumnHeaderAnnotation[voteResult.size()]; + int i = 0; + for (Pair oo : voteResult) { + TColumnHeaderAnnotation ha = + new TColumnHeaderAnnotation(table.getColumnHeader(col).getHeaderText(), + new Clazz(oo.getKey(), oo.getKey()), oo.getValue()); + ha.getScoreElements().put(SMP_SCORE_ENTITY_VOTE, oo.getValue()); + Double granularity = granularityScore.get(oo.getKey()); + granularity = granularity == null ? 0 : granularity; + ha.getScoreElements().put(SMP_SCORE_GRANULARITY, granularity); + ha.getScoreElements().put(TColumnHeaderAnnotation.SCORE_FINAL, oo.getValue()); + headerAnnotations[i] = ha; + i++; + } + tableAnnotation.setHeaderAnnotation(col, headerAnnotations); + } + } + + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnColumnRelationEnumerator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnColumnRelationEnumerator.java index 1891e61d..76f08d5e 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnColumnRelationEnumerator.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/smp/TColumnColumnRelationEnumerator.java @@ -1,228 +1,228 @@ -package uk.ac.shef.dcs.sti.core.algorithm.smp; - -import javafx.util.Pair; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.scorer.AttributeValueMatcher; -import uk.ac.shef.dcs.sti.util.DataTypeClassifier; -import uk.ac.shef.dcs.sti.core.model.*; - -import java.util.*; -import java.util.List; - -/** - * - */ -public class TColumnColumnRelationEnumerator extends uk.ac.shef.dcs.sti.core.algorithm.tmp.TColumnColumnRelationEnumerator { - - private boolean useSubjectColumn; - private Collection ignoreColumns; - - public TColumnColumnRelationEnumerator(AttributeValueMatcher attributeValueMatcher, - Collection ignoreColumns, - boolean useSubjectColumn) { - super(attributeValueMatcher, null); - this.ignoreColumns = ignoreColumns; - this.useSubjectColumn = useSubjectColumn; - } - - public int runRelationEnumeration(TAnnotation annotations, Table table, int subjectCol) throws STIException { - if (useSubjectColumn) - super.generateCellCellRelations(annotations, table, subjectCol); - else { - List subjectColumnsToConsider = new ArrayList<>(); - - for (int c = 0; c < table.getNumCols(); c++) { - if (!ignoreColumns.contains(c)) - subjectColumnsToConsider.add(c); - } - - for (int subjectColumn : subjectColumnsToConsider) { //choose a column to be subject column (must be NE column) - if (!table.getColumnHeader(subjectColumn).getFeature().getMostFrequentDataType().getType().equals(DataTypeClassifier.DataType.NAMED_ENTITY)) - continue; - super.generateCellCellRelations(annotations, table, subjectColumn); - } - } - //aggregate overall scores for relations on each column pairs and populate relation annotation object - aggregate(annotations, table); - - return 0; - } - - private void aggregate( - TAnnotation tableAnnotation, Table table) { - - List processed = new ArrayList<>(); - for (Map.Entry>> e : - tableAnnotation.getCellcellRelations().entrySet()) { - - //firstly, check the directional relation - RelationColumns relationColumns = e.getKey(); //key indicating the directional relationship (subject col, object col) - if (processed.contains(relationColumns)) - continue; - //key: relationURI, value: votes and score - Map> votes = new HashMap<>(); - - processed.add(relationColumns); - //map object where key=row id, value=collection of binary relations between the sub col and obj col on this row - Map> relationsOnRows = e.getValue(); - //among all relations that apply to the direction subcol-objcol, collect votes - collectVotes(relationsOnRows, votes); - List winner = selectWinner(votes, relationColumns); //the highest scoring relation in the direction of subject-object - - //next, reverse the relation direction - votes.clear(); - RelationColumns reverseRelationColumns = - new RelationColumns(relationColumns.getObjectCol(), relationColumns.getSubjectCol()); - relationsOnRows = tableAnnotation.getCellcellRelations().get(reverseRelationColumns); - if (relationsOnRows != null) { - processed.add(reverseRelationColumns); - collectVotes(relationsOnRows, votes); - List winnerReverseDirection = selectWinner(votes, reverseRelationColumns); //the highest scoring relation in the direction of object-subject relation - - createHeaderBinaryRelationAnnotations(winner, winnerReverseDirection, tableAnnotation, table); - } else {//no relation from reverse direction, - createHeaderBinaryRelationAnnotations(winner, null, tableAnnotation, table); - } - } - } - - /** - * @param relations key:row index; value: list of relations between the two columns - * @param votes key: relation uri; value-key: votes, value-value: score - */ - private void collectVotes(Map> relations, - Map> votes - ) { - for (List candidatesOnRow : relations.values()) { //go thru each row - Set distinctRelations = new HashSet<>(); - for (TCellCellRelationAnotation candidate : candidatesOnRow) { //go thru each candidate of each row - String relationCandidate = candidate.getRelationURI(); - distinctRelations.add(relationCandidate); - } - - for (String relation : distinctRelations) { //go thru each candidate of each row - double maxScore = 0.0; - for (TCellCellRelationAnotation candidate : candidatesOnRow) { - if (candidate.getRelationURI().equals(relation) && candidate.getWinningAttributeMatchScore() > maxScore) - maxScore = candidate.getWinningAttributeMatchScore(); - } - - Pair votesAndScore = votes.get(relation); //let's record both votes and scores. so when there is a tie at votes, we resort to scores - if (votesAndScore == null) { - votesAndScore = new Pair<>(0, 0.0); - } else { - votesAndScore = new Pair<>(votesAndScore.getKey() + 1, - votesAndScore.getValue() + maxScore); - } - - votes.put(relation, votesAndScore); - } - } - } - - private List selectWinner(Map> votes, - RelationColumns relationColumnsKey) { - List out = new ArrayList<>(); - for (Map.Entry> e : votes.entrySet()) { - RelationDataTuple rdt = new RelationDataTuple(); - rdt.relationString = e.getKey(); - rdt.relationColumns = relationColumnsKey; - rdt.votes = e.getValue().getKey(); - rdt.score = e.getValue().getValue(); - out.add(rdt); - } - Collections.sort(out); - int maxVote = out.get(0).votes; - double maxScore = out.get(0).score; - Iterator it = out.iterator(); - while (it.hasNext()) { - RelationDataTuple rdt = it.next(); - if (rdt.votes < maxVote) - it.remove(); - else if (rdt.votes == maxVote && rdt.score < maxScore) - it.remove(); - } - return out; - } - - - /** - * need to resolve conflicts. between two directions (sub-ob, or ob-sub, we must choose only 1) - * - * @param winner - * @param winnerReverseDirection - * @param tableAnnotation - * @param table - */ - private void createHeaderBinaryRelationAnnotations( - List winner, - List winnerReverseDirection, - TAnnotation tableAnnotation, - Table table) { - if (winnerReverseDirection != null) - winner.addAll(winnerReverseDirection); - Collections.sort(winner); - - RelationDataTuple finalWinner = winner.get(0); - int maxVote = finalWinner.votes; - double maxScore = finalWinner.score; - RelationColumns relationColumns = finalWinner.relationColumns; - int countNonEmptyRows = 0; - for (int r = 0; r < tableAnnotation.getRows(); r++) { - TCell c1 = table.getContentCell(r, relationColumns.getSubjectCol()); - TCell c2 = table.getContentCell(r, relationColumns.getObjectCol()); - if (!c1.getType().equals(DataTypeClassifier.DataType.EMPTY) && - !c1.getType().equals(DataTypeClassifier.DataType.EMPTY)) - countNonEmptyRows++; - } - - for (RelationDataTuple rdt : winner) { - if (rdt.votes == maxVote && rdt.score == maxScore && - rdt.relationColumns.getSubjectCol() == relationColumns.getSubjectCol() && - rdt.relationColumns.getObjectCol() == relationColumns.getObjectCol()) { - TColumnColumnRelationAnnotation hbr = new TColumnColumnRelationAnnotation(relationColumns, - rdt.relationString, - rdt.relationString, - (double) maxVote / countNonEmptyRows); - tableAnnotation.addColumnColumnRelation(hbr); - - //add supporting rows - Map> - cellcellRelations = tableAnnotation.getRelationAnnotationsBetween(rdt.relationColumns.getSubjectCol(), rdt.relationColumns.getObjectCol()); - for (Map.Entry> e : cellcellRelations.entrySet()) { - for (TCellCellRelationAnotation cbr : e.getValue()) { - if (hbr.getRelationURI().equals(cbr.getRelationURI())) { - hbr.addSupportingRow(e.getKey()); - break; - } - } - } - - } else { - break; - } - } - - - } - - private class RelationDataTuple implements Comparable { - protected String relationString; - protected RelationColumns relationColumns; - protected int votes; - protected double score; - - @Override - public int compareTo(RelationDataTuple o) { - int compare = Integer.valueOf(o.votes).compareTo(votes); - if (compare == 0) { - return Double.valueOf(o.score).compareTo(score); - } - return compare; - } - - public String toString() { - return relationString + "," + votes + "," + score; - } - } -} +package uk.ac.shef.dcs.sti.core.algorithm.smp; + +import javafx.util.Pair; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.scorer.AttributeValueMatcher; +import uk.ac.shef.dcs.sti.util.DataTypeClassifier; +import uk.ac.shef.dcs.sti.core.model.*; + +import java.util.*; +import java.util.List; + +/** + * + */ +public class TColumnColumnRelationEnumerator extends uk.ac.shef.dcs.sti.core.algorithm.tmp.TColumnColumnRelationEnumerator { + + private boolean useSubjectColumn; + private Collection ignoreColumns; + + public TColumnColumnRelationEnumerator(AttributeValueMatcher attributeValueMatcher, + Collection ignoreColumns, + boolean useSubjectColumn) { + super(attributeValueMatcher, null); + this.ignoreColumns = ignoreColumns; + this.useSubjectColumn = useSubjectColumn; + } + + public int runRelationEnumeration(TAnnotation annotations, Table table, int subjectCol) throws STIException { + if (useSubjectColumn) + super.generateCellCellRelations(annotations, table, subjectCol); + else { + List subjectColumnsToConsider = new ArrayList<>(); + + for (int c = 0; c < table.getNumCols(); c++) { + if (!ignoreColumns.contains(c)) + subjectColumnsToConsider.add(c); + } + + for (int subjectColumn : subjectColumnsToConsider) { //choose a column to be subject column (must be NE column) + if (!table.getColumnHeader(subjectColumn).getFeature().getMostFrequentDataType().getType().equals(DataTypeClassifier.DataType.NAMED_ENTITY)) + continue; + super.generateCellCellRelations(annotations, table, subjectColumn); + } + } + //aggregate overall scores for relations on each column pairs and populate relation annotation object + aggregate(annotations, table); + + return 0; + } + + private void aggregate( + TAnnotation tableAnnotation, Table table) { + + List processed = new ArrayList<>(); + for (Map.Entry>> e : + tableAnnotation.getCellcellRelations().entrySet()) { + + //firstly, check the directional relation + RelationColumns relationColumns = e.getKey(); //key indicating the directional relationship (subject col, object col) + if (processed.contains(relationColumns)) + continue; + //key: relationURI, value: votes and score + Map> votes = new HashMap<>(); + + processed.add(relationColumns); + //map object where key=row id, value=collection of binary relations between the sub col and obj col on this row + Map> relationsOnRows = e.getValue(); + //among all relations that apply to the direction subcol-objcol, collect votes + collectVotes(relationsOnRows, votes); + List winner = selectWinner(votes, relationColumns); //the highest scoring relation in the direction of subject-object + + //next, reverse the relation direction + votes.clear(); + RelationColumns reverseRelationColumns = + new RelationColumns(relationColumns.getObjectCol(), relationColumns.getSubjectCol()); + relationsOnRows = tableAnnotation.getCellcellRelations().get(reverseRelationColumns); + if (relationsOnRows != null) { + processed.add(reverseRelationColumns); + collectVotes(relationsOnRows, votes); + List winnerReverseDirection = selectWinner(votes, reverseRelationColumns); //the highest scoring relation in the direction of object-subject relation + + createHeaderBinaryRelationAnnotations(winner, winnerReverseDirection, tableAnnotation, table); + } else {//no relation from reverse direction, + createHeaderBinaryRelationAnnotations(winner, null, tableAnnotation, table); + } + } + } + + /** + * @param relations key:row index; value: list of relations between the two columns + * @param votes key: relation uri; value-key: votes, value-value: score + */ + private void collectVotes(Map> relations, + Map> votes + ) { + for (List candidatesOnRow : relations.values()) { //go thru each row + Set distinctRelations = new HashSet<>(); + for (TCellCellRelationAnotation candidate : candidatesOnRow) { //go thru each candidate of each row + String relationCandidate = candidate.getRelationURI(); + distinctRelations.add(relationCandidate); + } + + for (String relation : distinctRelations) { //go thru each candidate of each row + double maxScore = 0.0; + for (TCellCellRelationAnotation candidate : candidatesOnRow) { + if (candidate.getRelationURI().equals(relation) && candidate.getWinningAttributeMatchScore() > maxScore) + maxScore = candidate.getWinningAttributeMatchScore(); + } + + Pair votesAndScore = votes.get(relation); //let's record both votes and scores. so when there is a tie at votes, we resort to scores + if (votesAndScore == null) { + votesAndScore = new Pair<>(0, 0.0); + } else { + votesAndScore = new Pair<>(votesAndScore.getKey() + 1, + votesAndScore.getValue() + maxScore); + } + + votes.put(relation, votesAndScore); + } + } + } + + private List selectWinner(Map> votes, + RelationColumns relationColumnsKey) { + List out = new ArrayList<>(); + for (Map.Entry> e : votes.entrySet()) { + RelationDataTuple rdt = new RelationDataTuple(); + rdt.relationString = e.getKey(); + rdt.relationColumns = relationColumnsKey; + rdt.votes = e.getValue().getKey(); + rdt.score = e.getValue().getValue(); + out.add(rdt); + } + Collections.sort(out); + int maxVote = out.get(0).votes; + double maxScore = out.get(0).score; + Iterator it = out.iterator(); + while (it.hasNext()) { + RelationDataTuple rdt = it.next(); + if (rdt.votes < maxVote) + it.remove(); + else if (rdt.votes == maxVote && rdt.score < maxScore) + it.remove(); + } + return out; + } + + + /** + * need to resolve conflicts. between two directions (sub-ob, or ob-sub, we must choose only 1) + * + * @param winner + * @param winnerReverseDirection + * @param tableAnnotation + * @param table + */ + private void createHeaderBinaryRelationAnnotations( + List winner, + List winnerReverseDirection, + TAnnotation tableAnnotation, + Table table) { + if (winnerReverseDirection != null) + winner.addAll(winnerReverseDirection); + Collections.sort(winner); + + RelationDataTuple finalWinner = winner.get(0); + int maxVote = finalWinner.votes; + double maxScore = finalWinner.score; + RelationColumns relationColumns = finalWinner.relationColumns; + int countNonEmptyRows = 0; + for (int r = 0; r < tableAnnotation.getRows(); r++) { + TCell c1 = table.getContentCell(r, relationColumns.getSubjectCol()); + TCell c2 = table.getContentCell(r, relationColumns.getObjectCol()); + if (!c1.getType().equals(DataTypeClassifier.DataType.EMPTY) && + !c1.getType().equals(DataTypeClassifier.DataType.EMPTY)) + countNonEmptyRows++; + } + + for (RelationDataTuple rdt : winner) { + if (rdt.votes == maxVote && rdt.score == maxScore && + rdt.relationColumns.getSubjectCol() == relationColumns.getSubjectCol() && + rdt.relationColumns.getObjectCol() == relationColumns.getObjectCol()) { + TColumnColumnRelationAnnotation hbr = new TColumnColumnRelationAnnotation(relationColumns, + rdt.relationString, + rdt.relationString, + (double) maxVote / countNonEmptyRows); + tableAnnotation.addColumnColumnRelation(hbr); + + //add supporting rows + Map> + cellcellRelations = tableAnnotation.getRelationAnnotationsBetween(rdt.relationColumns.getSubjectCol(), rdt.relationColumns.getObjectCol()); + for (Map.Entry> e : cellcellRelations.entrySet()) { + for (TCellCellRelationAnotation cbr : e.getValue()) { + if (hbr.getRelationURI().equals(cbr.getRelationURI())) { + hbr.addSupportingRow(e.getKey()); + break; + } + } + } + + } else { + break; + } + } + + + } + + private class RelationDataTuple implements Comparable { + protected String relationString; + protected RelationColumns relationColumns; + protected int votes; + protected double score; + + @Override + public int compareTo(RelationDataTuple o) { + int compare = Integer.valueOf(o.votes).compareTo(votes); + if (compare == 0) { + return Double.valueOf(o.score).compareTo(score); + } + return compare; + } + + public String toString() { + return relationString + "," + votes + "," + score; + } + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNING.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNING.java deleted file mode 100644 index cebb5f15..00000000 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNING.java +++ /dev/null @@ -1,37 +0,0 @@ -package uk.ac.shef.dcs.sti.core.algorithm.tmp; - -import javafx.util.Pair; -import uk.ac.shef.dcs.kbsearch.KBSearchException; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.model.TAnnotation; -import uk.ac.shef.dcs.sti.core.model.Table; - -import java.util.*; - -/** - * Represents the LEARNING phase, creates preliminary column classification and cell disambiguation - */ -public class LEARNING { - - private LEARNINGPreliminaryColumnClassifier columnTagger; - private LEARNINGPreliminaryDisamb cellTagger; - - - public LEARNING(LEARNINGPreliminaryColumnClassifier columnTagger, LEARNINGPreliminaryDisamb cellTagger) { - this.columnTagger = columnTagger; - this.cellTagger = cellTagger; - } - - public void learn(Table table, TAnnotation tableAnnotation, int column) throws KBSearchException, ClassNotFoundException, STIException { - Pair>> stopPosition = - columnTagger.runPreliminaryColumnClassifier(table, tableAnnotation, column); - - cellTagger.runPreliminaryDisamb( - stopPosition.getKey(), - stopPosition.getValue(), - table, - tableAnnotation, - column); - } - -} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryColumnClassifier.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryColumnClassifier.java deleted file mode 100644 index f8d624e7..00000000 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryColumnClassifier.java +++ /dev/null @@ -1,172 +0,0 @@ -package uk.ac.shef.dcs.sti.core.algorithm.tmp; - -import javafx.util.Pair; -import org.apache.log4j.Logger; -import uk.ac.shef.dcs.kbsearch.KBSearch; -import uk.ac.shef.dcs.kbsearch.KBSearchException; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.algorithm.tmp.sampler.TContentCellRanker; -import uk.ac.shef.dcs.sti.core.algorithm.tmp.stopping.StoppingCriteria; -import uk.ac.shef.dcs.sti.core.algorithm.tmp.stopping.StoppingCriteriaInstantiator; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.sti.core.model.*; - -import java.util.*; -import java.util.List; - -/** - * this class creates preliminary classification and disambiguation on a column - */ - - -public class LEARNINGPreliminaryColumnClassifier { - private TContentCellRanker selector; - private KBSearch kbSearch; - private TCellDisambiguator cellDisambiguator; - private TColumnClassifier columnClassifier; - - private String stopperClassname; - private String[] stopperParams; - private static final Logger LOG = Logger.getLogger(LEARNINGPreliminaryColumnClassifier.class.getName()); - - public LEARNINGPreliminaryColumnClassifier(TContentCellRanker selector, - String stoppingCriteriaClassname, - String[] stoppingCriteriaParams, - KBSearch candidateFinder, - TCellDisambiguator cellDisambiguator, - TColumnClassifier columnClassifier) { - this.selector = selector; - this.kbSearch = candidateFinder; - this.cellDisambiguator = cellDisambiguator; - this.columnClassifier = columnClassifier; - - this.stopperClassname = stoppingCriteriaClassname; - this.stopperParams = stoppingCriteriaParams; - } - - /** - * @param table - * @param tableAnnotation - * @param column - * @param skipRows - * @return pair: key is the index of the cell by which the classification stopped. value is the re-ordered - * indexes of cells based on the sampler - * @throws KBSearchException - */ - public Pair>> runPreliminaryColumnClassifier(Table table, TAnnotation tableAnnotation, int column,Integer... skipRows) throws KBSearchException, ClassNotFoundException, STIException { - StoppingCriteria stopper = StoppingCriteriaInstantiator.instantiate(stopperClassname, stopperParams); - - //1. gather list of strings from this column to be interpreted, rank them (for sampling) - List> ranking = selector.select(table, column, tableAnnotation.getSubjectColumn()); - - //2. computeElementScores column and also disambiguate initial rows in the selected sample - List headerClazzScores = new ArrayList<>(); - - int countProcessed = 0, totalRows = 0; - boolean stopped = false; - Map state = new HashMap<>(); - - LOG.info("\t>> (LEANRING) Preliminary Column Classification begins"); - for (List blockOfRows : ranking) { - countProcessed++; - totalRows += blockOfRows.size(); - //find candidate entities - TCell sample = table.getContentCell(blockOfRows.get(0), column); - if (sample.getText().length() < 2) { - LOG.debug("\t\t>>> Very short text cell skipped: " + blockOfRows + "," + column + " " + sample.getText()); - continue; - } - - LOG.info("\t\t>> cold start disambiguation, row(s) " + blockOfRows + "/"+ranking.size()+"," + sample); - - boolean skip = false; - for (int row : skipRows) { - if (blockOfRows.contains(row)) { - skip = true; - break; - } - } - - List>> entityScoresForBlock; - if (skip) { - entityScoresForBlock = toScoreMap(tableAnnotation, blockOfRows, column); - } else { - List candidates = kbSearch.findEntityCandidates(sample.getText()); - //do cold start disambiguation - entityScoresForBlock = - cellDisambiguator.coldstartDisambiguate( - candidates, table, blockOfRows, column - ); - cellDisambiguator.addCellAnnotation(table, - tableAnnotation, blockOfRows, column, entityScoresForBlock); - } - - //run algorithm to runPreliminaryColumnClassifier column classification; header annotation scores are updated constantly, but supporting rows are not. - Map scores=columnClassifier.generateCandidateClazz( - entityScoresForBlock, headerClazzScores, table, blockOfRows, column, totalRows - ); - headerClazzScores.clear(); - headerClazzScores.addAll(scores.keySet()); - state=new HashMap<>(); - state.putAll(scores); - - boolean stop = stopper.stop(state, table.getNumRows()); - - if (stop) { - LOG.info("\t>> (LEARNING) Preliminary Column Classification converged, rows:" + totalRows+"/"+ranking.size()); - //state is stable. annotate using the type, and disambiguate entities - generatePreliminaryColumnClazz(state, tableAnnotation, column); - stopped = true; - break; //exit loop - } - } - - if (!stopped) { - LOG.info("\t>> Preliminary Column Classification no convergence"); - generatePreliminaryColumnClazz(state, tableAnnotation, column); //supporting rows not added - } - return new Pair<>(countProcessed, ranking); - } - - - // - private List>> toScoreMap(TAnnotation tableAnnotation, - List blockOfRows, - int column) { - List>> candidates = new ArrayList<>(); - for (int row : blockOfRows) { - TCellAnnotation[] annotations = tableAnnotation.getContentCellAnnotations(row, column); - for (TCellAnnotation can : annotations) { - Entity ec = can.getAnnotation(); - Map scoreElements = can.getScoreElements(); - scoreElements.put(TCellAnnotation.SCORE_FINAL, can.getFinalScore()); - candidates.add(new Pair<>(ec, scoreElements)); - } - - } - return candidates; - } - - - //assigns highest scoring clazz to the column; - private void generatePreliminaryColumnClazz(final Map state, - TAnnotation tableAnnotation, - int column) { - if (state.size() > 0) { - List candidateClazz = new ArrayList<>(state.keySet()); - Collections.sort(candidateClazz, (o1, o2) - -> state.get(o2).compareTo(state.get(o1))); - //insert column type annotations - TColumnHeaderAnnotation[] preliminaryRankedCandidateClazz - = new TColumnHeaderAnnotation[candidateClazz.size()]; - for (int i = 0; i < candidateClazz.size(); i++) - preliminaryRankedCandidateClazz[i] = - (TColumnHeaderAnnotation) candidateClazz.get(i); - tableAnnotation.setHeaderAnnotation(column, preliminaryRankedCandidateClazz); - } - } - - - - -} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryDisamb.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryDisamb.java deleted file mode 100644 index aea3a471..00000000 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LEARNINGPreliminaryDisamb.java +++ /dev/null @@ -1,150 +0,0 @@ -package uk.ac.shef.dcs.sti.core.algorithm.tmp; - -import javafx.util.Pair; -import org.apache.log4j.Logger; -import uk.ac.shef.dcs.kbsearch.KBSearch; -import uk.ac.shef.dcs.kbsearch.KBSearchException; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.model.*; - -import java.util.*; -import java.util.List; - -/** - */ -public class LEARNINGPreliminaryDisamb { - - private static final Logger LOG = Logger.getLogger(LEARNINGPreliminaryDisamb.class.getName()); - private TCellDisambiguator disambiguator; - private KBSearch kbSearch; - private TColumnClassifier classifier; - - public LEARNINGPreliminaryDisamb(KBSearch kbSearch, - TCellDisambiguator disambiguator, - TColumnClassifier classifier) { - this.kbSearch = kbSearch; - this.disambiguator = disambiguator; - this.classifier = classifier; - } - - public void runPreliminaryDisamb( - int stopPointByPreColumnClassifier, - List> ranking, - Table table, - TAnnotation tableAnnotation, - int column, - Integer... skipRows) throws KBSearchException, STIException { - - LOG.info("\t>> (LEARNING) Preliminary Disambiguation begins"); - List winningColumnClazz = tableAnnotation.getWinningHeaderAnnotations(column); - Set winningColumnClazzIds = new HashSet<>(); - for (TColumnHeaderAnnotation ha : winningColumnClazz) - winningColumnClazzIds.add(ha.getAnnotation().getId()); - - //for those cells already processed by pre column classification, update their cell annotations - LOG.info("\t\t>> re-annotate cells involved in cold start disambiguation"); - reselect(tableAnnotation, stopPointByPreColumnClassifier, ranking, winningColumnClazzIds, column); - - //for remaining... - LOG.info("\t\t>> constrained cell disambiguation for the rest cells in this column"); - int end = ranking.size(); - - List updated = new ArrayList<>(); - for (int bi = stopPointByPreColumnClassifier; bi < end; bi++) { - List rows = ranking.get(bi); - - boolean skip = false; - for (int i : skipRows) { - if (rows.contains(i)) { - skip = true; - break; - } - } - if (skip) - continue; - - TCell sample = table.getContentCell(rows.get(0), column); - if (sample.getText().length() < 2) { - LOG.debug("\t\t>>> short text cell skipped: " + rows + "," + column + " " + sample.getText()); - continue; - } - - List>> entity_and_scoreMap = - constrainedDisambiguate(sample, - table, - winningColumnClazzIds, - rows, column,ranking.size() - ); - - if (entity_and_scoreMap.size() > 0) { - disambiguator.addCellAnnotation(table, tableAnnotation, rows, column, - entity_and_scoreMap); - updated.addAll(rows); - } - } - - LOG.info("\t\t>> constrained cell disambiguation complete " + updated.size() + "/"+ranking.size()+" rows"); - LOG.info("\t\t>> reset candidate column class annotations"); - classifier.updateColumnClazz(updated, column, tableAnnotation, table,false); - - } - - //for those cells already processed in preliminary column classification, - //preliminary disamb simply reselects entities whose type overlap with winning column clazz annotation - private void reselect(TAnnotation tableAnnotation, - int stopPointByPreColumnClassifier, - List> cellBlockRanking, - Collection winningClazzIds, - int column) { - TColumnHeaderAnnotation[] headers = tableAnnotation.getHeaderAnnotation(column); - for (int index = 0; index < stopPointByPreColumnClassifier; index++) { - List cellBlock = cellBlockRanking.get(index); - for (int row : cellBlock) { - TCellAnnotation[] cellAnnotations = - tableAnnotation.getContentCellAnnotations(row, column); - TCellAnnotation[] revised = - disambiguator.reselect(cellAnnotations, winningClazzIds); - if (revised.length != 0) - tableAnnotation.setContentCellAnnotations(row, column, revised); - - //now update supporting rows for the elected column clazz - if (headers != null) { - for (TColumnHeaderAnnotation ha : headers) { - for (TCellAnnotation tca : revised) { - if (tca.getAnnotation().getTypes().contains(ha.getAnnotation())) { - ha.addSupportingRow(row); - break; - } - } - } - } - } - } - } - - - //search candidates for the cell; - //computeElementScores candidates for the cell; - //create annotation and update supportin header and header computeElementScores (depending on the two params updateHeader_blah - private List>> constrainedDisambiguate(TCell tcc, - Table table, - Set winningColumnClazz, - List rowBlock, - int column, - int totalRowBlocks) throws KBSearchException { - List>> entity_and_scoreMap; - - List candidates = kbSearch.findEntityCandidatesOfTypes(tcc.getText(), winningColumnClazz.toArray(new String[0])); - if (candidates != null && candidates.size() != 0) { - } else - candidates = kbSearch.findEntityCandidatesOfTypes(tcc.getText()); - - //now each candidate is given scores - entity_and_scoreMap = - disambiguator.constrainedDisambiguate - (candidates, table, rowBlock, column,totalRowBlocks, true); - - return entity_and_scoreMap; - } -} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTagger.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTagger.java deleted file mode 100644 index 89e869d1..00000000 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTagger.java +++ /dev/null @@ -1,13 +0,0 @@ -package uk.ac.shef.dcs.sti.core.algorithm.tmp; - -import uk.ac.shef.dcs.kbsearch.KBSearchException; -import uk.ac.shef.dcs.sti.core.model.TAnnotation; -import uk.ac.shef.dcs.sti.core.model.Table; - -/** - */ -public interface LiteralColumnTagger { - void annotate(Table table, TAnnotation annotations, Integer... enColumnIndexes) throws KBSearchException; - - void setIgnoreColumns(int... ignoreCols); -} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTaggerImpl.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTaggerImpl.java deleted file mode 100644 index 1c89316c..00000000 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/LiteralColumnTaggerImpl.java +++ /dev/null @@ -1,89 +0,0 @@ -package uk.ac.shef.dcs.sti.core.algorithm.tmp; - -import org.apache.log4j.Logger; -import uk.ac.shef.dcs.kbsearch.KBSearchException; -import uk.ac.shef.dcs.kbsearch.model.Clazz; -import uk.ac.shef.dcs.sti.core.model.*; - -import java.util.*; -import java.util.List; - -/** - * this simply chooses column type based on relations' expected types - */ -public class LiteralColumnTaggerImpl implements LiteralColumnTagger { - private static final Logger LOG = Logger.getLogger(LiteralColumnTaggerImpl.class.getName()); - private int[] ignoreColumns; - - public LiteralColumnTaggerImpl( - int... ignoreColumns) { - this.ignoreColumns = ignoreColumns; - - } - - public void setIgnoreColumns(int... ignoreCols) { - this.ignoreColumns = ignoreCols; - } - - public void annotate(Table table, TAnnotation annotations, Integer... neColumns) throws KBSearchException { - //for each column that has a relation with the subject column, infer its type - Map>> - relationAnnotations = annotations.getCellcellRelations(); - - //LOG.info("\t>> Annotating literal columns"); - for (Map.Entry>> - e : relationAnnotations.entrySet()) { - RelationColumns subcol_objcol = e.getKey(); - if (ignoreColumn(subcol_objcol.getObjectCol())) continue; - - LOG.info("\t\t>> object column= " + subcol_objcol.getObjectCol()); - boolean skip = false; - - //check if the object column is an ne column, and whether that ne column is already annotated - //if so we do not need to annotate this column, we just need to skip it - for (int i : neColumns) { - boolean isColumn_acronym_or_code = table.getColumnHeader(i).getFeature().isAcronymColumn(); - if (i == subcol_objcol.getObjectCol() && !isColumn_acronym_or_code) { - if (annotations.getHeaderAnnotation(i) != null && - annotations.getHeaderAnnotation(i).length > 0) { - skip = true; - break; - } - } - } - if (skip) { - LOG.debug("\t\t>> skipped object column (possibly NE column) " + subcol_objcol.getObjectCol()); - continue; - } - - List candidates = new ArrayList<>(); - List relations = - annotations.getColumncolumnRelations(). - get(subcol_objcol); //get the relation annotations between subject col and this column - for (TColumnColumnRelationAnnotation relation : relations) { - //we simply create a new clazz using the relation's uri and label - TColumnHeaderAnnotation hAnn = new TColumnHeaderAnnotation(table.getColumnHeader(subcol_objcol.getObjectCol()).getHeaderText(), - new Clazz(relation.getRelationURI(), relation.getRelationLabel()), - relation.getFinalScore()); - if(!candidates.contains(hAnn)) - candidates.add(hAnn); - } - - List sorted = new ArrayList<>(candidates); - Collections.sort(sorted); - annotations.setHeaderAnnotation(subcol_objcol.getObjectCol(), sorted.toArray(new TColumnHeaderAnnotation[0])); - } - - } - - private boolean ignoreColumn(Integer i) { - if (i != null) { - for (int a : ignoreColumns) { - if (a == i) - return true; - } - } - return false; - } - -} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/RELATIONENUMERATION.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/RELATIONENUMERATION.java deleted file mode 100644 index 98785e4f..00000000 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/RELATIONENUMERATION.java +++ /dev/null @@ -1,111 +0,0 @@ -package uk.ac.shef.dcs.sti.core.algorithm.tmp; - -import javafx.util.Pair; -import org.apache.log4j.Logger; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.scorer.RelationScorer; -import uk.ac.shef.dcs.sti.core.subjectcol.TColumnFeature; -import uk.ac.shef.dcs.sti.STIConstantProperty; -import uk.ac.shef.dcs.sti.core.model.*; - -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * Created by - on 02/04/2016. - */ -public class RELATIONENUMERATION { - private static final Logger LOG = Logger.getLogger(RELATIONENUMERATION.class.getName()); - - public void enumerate(List>> subjectColCandidadteScores, - Set ignoreCols, - TColumnColumnRelationEnumerator relationEnumerator, - TAnnotation tableAnnotations, - Table table, - List annotatedColumns, - UPDATE update - ) throws STIException { - double winningSolutionScore = 0; - int subjectCol; - TAnnotation winningSolution = null; - for (Pair> mainCol : subjectColCandidadteScores) { - //tab_annotations = new TAnnotation(table.getNumRows(), table.getNumCols()); - subjectCol = mainCol.getKey(); - if (ignoreCols.contains(subjectCol)) continue; - - LOG.info(">>\t\t Let subject column=" + subjectCol); - int relatedColumns = - relationEnumerator.runRelationEnumeration(tableAnnotations, table, subjectCol); - - boolean interpretable = false; - if (relatedColumns > 0) - interpretable = true; - - if (interpretable) { - tableAnnotations.setSubjectColumn(subjectCol); - break; - } else { - //the current subject column could be wrong, try differently - double overallScore = scoreSolution(tableAnnotations, table, subjectCol); - if (overallScore > winningSolutionScore) { - tableAnnotations.setSubjectColumn(subjectCol); - winningSolution = tableAnnotations; - winningSolutionScore = overallScore; - } - tableAnnotations.resetRelationAnnotations(); - LOG.warn(">>\t\t (this subject column does not form relation with other columns, try the next column)"); - continue; - } - } - if (tableAnnotations == null && winningSolution != null) - tableAnnotations = winningSolution; - - - if (STIConstantProperty.REVISE_RELATION_ANNOTATION_BY_DC && update != null) { - List domain_rep = update.createDomainRep(table, tableAnnotations, annotatedColumns); - reviseColumnColumnRelationAnnotations(tableAnnotations, domain_rep, relationEnumerator.getRelationScorer()); - } - } - - private double scoreSolution(TAnnotation tableAnnotations, Table table, int subjectColumn) { - double entityScores = 0.0; - for (int col = 0; col < table.getNumCols(); col++) { - for (int row = 0; row < table.getNumRows(); row++) { - TCellAnnotation[] cAnns = tableAnnotations.getContentCellAnnotations(row, col); - if (cAnns != null && cAnns.length > 0) { - entityScores += cAnns[0].getFinalScore(); - } - } - } - - double relationScores = 0.0; - for (Map.Entry> entry : tableAnnotations.getColumncolumnRelations().entrySet()) { - RelationColumns key = entry.getKey(); - TColumnColumnRelationAnnotation rel = entry.getValue().get(0); - relationScores += rel.getFinalScore(); - } - TColumnFeature cf = table.getColumnHeader(subjectColumn).getFeature(); - //relationScores = relationScores * cf.getValueDiversity(); - - double diversity = cf.getUniqueCellCount() + cf.getUniqueTokenCount(); - return (entityScores + relationScores) * diversity * ((table.getNumRows() - cf.getEmptyCellCount()) / (double) table.getNumRows()); - } - - private void reviseColumnColumnRelationAnnotations(TAnnotation annotation, - List domain_representation, - RelationScorer relationScorer - ) throws STIException { - for (Map.Entry> - entry : annotation.getColumncolumnRelations().entrySet()) { - - for (TColumnColumnRelationAnnotation relation : entry.getValue()) { - double domain_consensus = relationScorer.scoreDC(relation, domain_representation); - relation.setFinalScore(relation.getFinalScore() + domain_consensus); - } - Collections.sort(entry.getValue()); - } - } - -} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TCellDisambiguator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TCellDisambiguator.java deleted file mode 100644 index 3bea1110..00000000 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TCellDisambiguator.java +++ /dev/null @@ -1,123 +0,0 @@ -package uk.ac.shef.dcs.sti.core.algorithm.tmp; - -import javafx.util.Pair; -import org.apache.commons.collections.CollectionUtils; -import org.apache.log4j.Logger; -import uk.ac.shef.dcs.kbsearch.KBSearch; -import uk.ac.shef.dcs.kbsearch.KBSearchException; -import uk.ac.shef.dcs.kbsearch.model.Attribute; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; -import uk.ac.shef.dcs.sti.core.model.TAnnotation; -import uk.ac.shef.dcs.sti.core.scorer.EntityScorer; -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.Table; - -import java.util.*; - -/** - */ -public class TCellDisambiguator { - - private KBSearch kbSearch; - private EntityScorer disambScorer; - private static final Logger LOG = Logger.getLogger(TCellDisambiguator.class.getName()); - - public TCellDisambiguator(KBSearch kbSearch, EntityScorer disambScorer) { - this.kbSearch = kbSearch; - this.disambScorer = disambScorer; - } - //this method runs cold start disambiguation - public List>> coldstartDisambiguate(List candidates, Table table, - List entity_rows, int entity_column - ) throws KBSearchException { - LOG.info("\t\t>> (cold start disamb), candidates=" + candidates.size()); - return disambiguate(candidates, table,entity_rows,entity_column); - - } - - //reselect cell entities for this cell ensuring their types are contained in the winning clazz for the column - public TCellAnnotation[] reselect( - TCellAnnotation[] existingCellAnnotations, - Collection winningClazzIdsForColumn) { - List selected = new ArrayList<>(); - for(TCellAnnotation tca: existingCellAnnotations){ - int overlap = CollectionUtils.intersection(tca.getAnnotation().getTypeIds(), - winningClazzIdsForColumn).size(); - if(overlap>0) - selected.add(tca); - } - - return selected.toArray(new TCellAnnotation[0]); - } - - public List>> constrainedDisambiguate( - List candidates, - Table table, - List rowBlock, - int column, - int totalRowBlocks, - boolean isLEARNINGPhase - ) throws KBSearchException { - TCell sample_tcc = table.getContentCell(rowBlock.get(0), column); - if (isLEARNINGPhase) - LOG.info("\t\t>> (constrained disambiguation in LEARNING) , position at (" + rowBlock + "/"+totalRowBlocks+"," + column + ") " + sample_tcc + " candidates=" + candidates.size()); - else - LOG.info("\t\t>> (constrained disambiguation in UPDATE), position at (" + rowBlock + "/"+totalRowBlocks+"," + column + ") " + sample_tcc + " (candidates)-" + candidates.size()); - - return disambiguate(candidates, table, rowBlock,column); - } - - public List>> disambiguate(List candidates, Table table, - List entity_rows, int entity_column - ) throws KBSearchException { - //do disambiguation scoring - //LOG.info("\t>> Disambiguation-LEARN, position at (" + entity_row + "," + entity_column + ") candidates=" + candidates.size()); - TCell sample_tcc = table.getContentCell(entity_rows.get(0), entity_column); - List>> disambiguationScores = new ArrayList<>(); - for (Entity c : candidates) { - //find facts of each entity - if (c.getAttributes() == null || c.getAttributes().size() == 0) { - List attributes = kbSearch.findAttributesOfEntities(c); - c.setAttributes(attributes); - } - Map scoreMap = disambScorer. - computeElementScores(c, candidates, - entity_column, - entity_rows.get(0), - entity_rows, table); - disambScorer.computeFinal(scoreMap, sample_tcc.getText()); - Pair> entry = new Pair<>(c, scoreMap); - disambiguationScores.add(entry); - } - return disambiguationScores; - } - - protected void addCellAnnotation( - Table table, - TAnnotation tableAnnotation, - List rowBlock, - int table_cell_col, - List>> entities_and_scoreMap) { - - Collections.sort(entities_and_scoreMap, (o1, o2) -> { - Double o2_score = o2.getValue().get(TCellAnnotation.SCORE_FINAL); - Double o1_score = o1.getValue().get(TCellAnnotation.SCORE_FINAL); - return o2_score.compareTo(o1_score); - }); - - String cellText = table.getContentCell(rowBlock.get(0), table_cell_col).getText(); - for (int row : rowBlock) { - TCellAnnotation[] annotationsForCell = new TCellAnnotation[entities_and_scoreMap.size()]; - for (int i = 0; i < entities_and_scoreMap.size(); i++) { - Pair> e = entities_and_scoreMap.get(i); - double score = e.getValue().get(TCellAnnotation.SCORE_FINAL); - annotationsForCell[i] = new TCellAnnotation(cellText, - e.getKey(), score, e.getValue()); - - } - tableAnnotation.setContentCellAnnotations(row, table_cell_col, annotationsForCell); - } - } - -} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnClassifier.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnClassifier.java deleted file mode 100644 index af32cae7..00000000 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnClassifier.java +++ /dev/null @@ -1,218 +0,0 @@ -package uk.ac.shef.dcs.sti.core.algorithm.tmp; - -import javafx.util.Pair; -import org.apache.log4j.Logger; -import uk.ac.shef.dcs.kbsearch.model.Clazz; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.algorithm.tmp.scorer.TMPClazzScorer; -import uk.ac.shef.dcs.sti.core.model.*; -import uk.ac.shef.dcs.sti.core.scorer.ClazzScorer; - -import java.util.*; -import java.util.List; - -/** - * Created by - on 04/04/2016. - */ -public class TColumnClassifier { - - private ClazzScorer clazzScorer; - private static final Logger LOG = Logger.getLogger(TColumnClassifier.class.getName()); - - public TColumnClassifier(ClazzScorer scorer){ - this.clazzScorer=scorer; - } - - public Map generateCandidateClazz( - List>> entityScoresForBlock, - List existingColumnClazzCandidates, - Table table, - List blockOfRows, - int column - , int tableRowsTotal) throws STIException { - Collection candidateHeaderAnnotations=clazzScorer. - computeElementScores(entityScoresForBlock, existingColumnClazzCandidates, - table, blockOfRows, column); - - LOG.info("\t\t>> update candidate clazz on column, existing="+existingColumnClazzCandidates.size()); - Map state = new HashMap<>(); - for (TColumnHeaderAnnotation ha : candidateHeaderAnnotations) { - //Map scoreElements =ha.getScoreElements(); - clazzScorer.computeFinal(ha, tableRowsTotal); - state.put(ha, ha.getFinalScore()); - } - return state; - } - - /** - * after disamb on the column, go thru the cells that have been newly disambiguated (i.e., in addition to cold start - * disamb) update class annotation for the column due to these new cells - * - * @param rowsUpdated - * @param column - * @param tableAnnotations - * @param table - * @param resetCESums if true, the sum_ce and sum_vote will be set to 0, before the newly disambiguated rows in rowsUpdated are counted - */ - protected void updateColumnClazz(List rowsUpdated, - int column, - TAnnotation tableAnnotations, - Table table, - boolean resetCESums) throws STIException { - List existingColumnClazzAnnotations; - existingColumnClazzAnnotations = tableAnnotations.getHeaderAnnotation(column) == null - ? new ArrayList<>() : new ArrayList<>(Arrays.asList(tableAnnotations.getHeaderAnnotation(column))); - - //supporting rows are added if a header for the type of the cell annotation exists - List toAdd = new ArrayList<>(); - //deal with newly disambiguated cells (that is, in addition to cold start disamb) - for (int row : rowsUpdated) { - List winningEntities = - tableAnnotations.getWinningContentCellAnnotation(row, column); - for (TCellAnnotation ca : winningEntities) { - for (TColumnHeaderAnnotation ha : selectNew(ca, column, table, existingColumnClazzAnnotations)) { - if (!toAdd.contains(ha)) - toAdd.add(ha); - } - } - } - - toAdd.addAll(existingColumnClazzAnnotations); - TColumnHeaderAnnotation[] result = updateColumnClazzAnnotationScores( - rowsUpdated, - column, - table.getNumRows(), - existingColumnClazzAnnotations, - table, - tableAnnotations, - clazzScorer, - resetCESums - ); - tableAnnotations.setHeaderAnnotation(column, result); - } - - - protected void updateClazzScoresByDC(TAnnotation currentAnnotation, List domanRep, - List interpretedColumns) throws STIException { - for (int c : interpretedColumns) { - List headers = new ArrayList<>( - Arrays.asList(currentAnnotation.getHeaderAnnotation(c))); - - for (TColumnHeaderAnnotation ha : headers) { - double dc = clazzScorer.computeDC(ha, domanRep); - ha.setFinalScore(ha.getFinalScore() + dc); - } - - Collections.sort(headers); - currentAnnotation.setHeaderAnnotation(c, headers.toArray(new TColumnHeaderAnnotation[0])); - } - } - - - /** - * given a cell annotation, and existing TColumnHeaderAnnotations on the column, - * go through the types (clazz) of that cell annotation, select the ones that are - * not included in the existing TColumnHeaderAnnotations - * - * @param ca - * @param column - * @param table - * @param existingColumnClazzAnnotations - * @return - */ - private List selectNew(TCellAnnotation ca, int column, - Table table, - Collection existingColumnClazzAnnotations - ) { - - List types = ca.getAnnotation().getTypes(); - - List selected = new ArrayList<>(); - for (int index = 0; index < types.size(); index++) { - boolean found = false; - Clazz type = types.get(index); - for (TColumnHeaderAnnotation ha : existingColumnClazzAnnotations) { - if (type.equals(ha.getAnnotation())) { - found = true; - break; - } - } - if (!found) { - TColumnHeaderAnnotation ha = new TColumnHeaderAnnotation(table.getColumnHeader(column).getHeaderText(), - type, 0.0); - selected.add(ha); - } - } - return selected; - } - - /** - * Used after disamb, to update candidate column clazz annotations on the column - * @param updatedRows - * @param column - * @param totalRows - * @param candidateColumnClazzAnnotations - * @param table - * @param tableAnnotations - * @param clazzScorer - * @param resetCESums if true, the sum_ce and sum_vote will be set to 0, before the newly disambiguated rows in rowsUpdated are counted - * @return - */ - private TColumnHeaderAnnotation[] updateColumnClazzAnnotationScores(Collection updatedRows, - int column, - int totalRows, - Collection candidateColumnClazzAnnotations, - Table table, - TAnnotation tableAnnotations, - ClazzScorer clazzScorer, - boolean resetCESums) throws STIException { - //for the candidate column clazz annotations compute CC score - candidateColumnClazzAnnotations = clazzScorer.computeCCScore(candidateColumnClazzAnnotations,table, column); - - if(resetCESums){ - for (TColumnHeaderAnnotation ha : candidateColumnClazzAnnotations) { - ha.getScoreElements().put(TMPClazzScorer.SUM_CELL_VOTE, 0.0); - ha.getScoreElements().put(TMPClazzScorer.SUM_CE, 0.0); - } - } - - for (int row : updatedRows) { - List winningEntities = tableAnnotations.getWinningContentCellAnnotation(row, column); - Set votedClazzIdsByThisCell = new HashSet<>(); - for (TCellAnnotation ca : winningEntities) { - //go thru each candidate column clazz annotation, check if this winning entity has a type that is this clazz - for (TColumnHeaderAnnotation ha : candidateColumnClazzAnnotations) { - if (ca.getAnnotation().getTypes().contains(ha.getAnnotation())) { - ha.addSupportingRow(row); - if (!votedClazzIdsByThisCell.contains(ha.getAnnotation().getId())) { - //update the CE score elements for this column clazz annotation - Double sum_votes = ha.getScoreElements().get(TMPClazzScorer.SUM_CELL_VOTE); - if(sum_votes==null) sum_votes=0.0; - sum_votes++; - ha.getScoreElements().put(TMPClazzScorer.SUM_CELL_VOTE, sum_votes); - - Double sum_ce = ha.getScoreElements().get(TMPClazzScorer.SUM_CE); - if(sum_ce==null) sum_ce=0.0; - sum_ce += ca.getFinalScore(); - ha.getScoreElements().put(TMPClazzScorer.SUM_CE, sum_ce); - votedClazzIdsByThisCell.add(ha.getAnnotation().getId()); - } - } else if (votedClazzIdsByThisCell.contains(ha.getAnnotation().getId())){} - - } - } - } - - //finally recompute final scores, because CE scores could have changed - List revised = new ArrayList<>(); - for (TColumnHeaderAnnotation ha : candidateColumnClazzAnnotations) { - clazzScorer.computeFinal(ha, totalRows); - revised.add(ha); - } - - Collections.sort(revised); - return revised.toArray(new TColumnHeaderAnnotation[0]); - } - -} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnColumnRelationEnumerator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnColumnRelationEnumerator.java deleted file mode 100644 index c69a5525..00000000 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TColumnColumnRelationEnumerator.java +++ /dev/null @@ -1,139 +0,0 @@ -package uk.ac.shef.dcs.sti.core.algorithm.tmp; - -import javafx.util.Pair; -import uk.ac.shef.dcs.kbsearch.model.Attribute; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.scorer.AttributeValueMatcher; -import uk.ac.shef.dcs.sti.core.scorer.RelationScorer; -import uk.ac.shef.dcs.sti.util.DataTypeClassifier; -import uk.ac.shef.dcs.sti.core.model.*; - -import java.util.*; -import java.util.List; - -/** - */ -public class TColumnColumnRelationEnumerator { - - private AttributeValueMatcher attributeValueMatcher; - private RelationScorer relationScorer; - - public TColumnColumnRelationEnumerator( - AttributeValueMatcher attributeValueMatcher, - RelationScorer scorer) { - this.attributeValueMatcher = attributeValueMatcher; - this.relationScorer = scorer; - } - - public RelationScorer getRelationScorer(){ - return relationScorer; - } - - public int runRelationEnumeration(TAnnotation annotations, Table table, int subjectCol) throws STIException { - generateCellCellRelations(annotations, table, subjectCol); - //now we have created relation annotations per row, consolidate them to create column-column relation - enumerateColumnColumnRelation(annotations, table); - return annotations.getCellcellRelations().size(); - } - - /** - * returns the number of columns that form relation with the subjectCol - *

- * when new relation created, supporting row info is also added - */ - protected void generateCellCellRelations(TAnnotation annotations, Table table, int subjectCol) throws STIException { - //select columns that are likely to form a relation with subject column - Map columnDataTypes - = new HashMap<>(); - for (int c = 0; c < table.getNumCols(); c++) { - DataTypeClassifier.DataType type = - table.getColumnHeader(c).getTypes().get(0).getType(); - if (type.equals(DataTypeClassifier.DataType.ORDERED_NUMBER)) - continue; //ordered numbered columns are not interesting - else - columnDataTypes.put(c, type); - } - - //for each row, get the annotation for that (row, col) - for (int row = 0; row < table.getNumRows(); row++) { - //get the winning annotation for this cell - List winningCellAnnotations = annotations.getWinningContentCellAnnotation(row, subjectCol); - - //collect attributes from where candidate relations are created - List collectedAttributes = new ArrayList<>(); - for (TCellAnnotation cellAnnotation : winningCellAnnotations) { - collectedAttributes.addAll(cellAnnotation.getAnnotation().getAttributes()); - } - - //collect cell values on the same row, from other columns - Map cellValuesToMatch = new HashMap<>(); - for (int col : columnDataTypes.keySet()) { - if (col != subjectCol) { - String cellValue = table.getContentCell(row, col).getText(); - cellValuesToMatch.put(col, cellValue); - } - } - - //perform matching and scoring - //key=col id; value: contains the attr that matched with the highest score against cell in that column - Map>> cellMatchScores = - attributeValueMatcher.match(collectedAttributes, cellValuesToMatch, columnDataTypes); - - for (Map.Entry>> e : cellMatchScores.entrySet()) { - RelationColumns subCol_to_objCol = new RelationColumns(subjectCol, e.getKey()); - - List> matchedAttributes = e.getValue(); - for (Pair entry : matchedAttributes) { - String relationURI = entry.getKey().getRelationURI(); - String relationLabel = ""; //todo:currently we do not get the label!!! - List matchedValues = new ArrayList<>(); - matchedValues.add(entry.getKey()); - TCellCellRelationAnotation cellcellRelation = - new TCellCellRelationAnotation( - subCol_to_objCol, row, relationURI, relationLabel, matchedValues, entry.getValue() - ); - annotations.addCellCellRelation(cellcellRelation); - } - } - } - } - - private void enumerateColumnColumnRelation(TAnnotation annotations, Table table) throws STIException { - for (Map.Entry>> entry : - annotations.getCellcellRelations().entrySet()) { - RelationColumns key = entry.getKey(); //relation's direction - //map containing row and the cellcellrelations for that row - Map> value = entry.getValue(); - - //go through every row, update header binary relation scores - List columnColumnRelationAnnotations = new ArrayList<>(); - for (Map.Entry> e : value.entrySet()) { - columnColumnRelationAnnotations = relationScorer.computeElementScores(e.getValue(), - columnColumnRelationAnnotations, - key.getSubjectCol(), - key.getObjectCol(), - table); - } - - //now collect element scores to create final score, also generate supporting rows - for (TColumnColumnRelationAnnotation relation : columnColumnRelationAnnotations) { - relationScorer.computeFinal(relation, table.getNumRows()); - for (Map.Entry> e : value.entrySet()) { - for (TCellCellRelationAnotation cbr : e.getValue()) { - if (relation.getRelationURI().equals(cbr.getRelationURI())) { - relation.addSupportingRow(e.getKey()); - break; - } - } - } - } - List sorted = - new ArrayList<>(columnColumnRelationAnnotations); - Collections.sort(sorted); - for (TColumnColumnRelationAnnotation hbr : sorted) - annotations.addColumnColumnRelation(hbr); - - } - } - -} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TMPInterpreter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TMPInterpreter.java deleted file mode 100644 index 5193888b..00000000 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/TMPInterpreter.java +++ /dev/null @@ -1,110 +0,0 @@ -package uk.ac.shef.dcs.sti.core.algorithm.tmp; - -import javafx.util.Pair; -import org.apache.log4j.Logger; -import uk.ac.shef.dcs.kbsearch.KBSearchException; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.algorithm.SemanticTableInterpreter; -import uk.ac.shef.dcs.sti.core.scorer.RelationScorer; -import uk.ac.shef.dcs.sti.core.subjectcol.SubjectColumnDetector; -import uk.ac.shef.dcs.sti.util.DataTypeClassifier; -import uk.ac.shef.dcs.sti.core.model.*; -import uk.ac.shef.dcs.websearch.bing.v2.APIKeysDepletedException; - -import java.io.IOException; -import java.util.*; -import java.util.List; - -/** - - */ -public class TMPInterpreter extends SemanticTableInterpreter { - - private SubjectColumnDetector subjectColumnDetector; - private LEARNING learning; - private LiteralColumnTagger literalColumnTagger; - private TColumnColumnRelationEnumerator relationEnumerator; - private UPDATE update; - - private static final Logger LOG = Logger.getLogger(TMPInterpreter.class.getName()); - - public TMPInterpreter(SubjectColumnDetector subjectColumnDetector, - LEARNING learning, - UPDATE update, - TColumnColumnRelationEnumerator relationEnumerator, - LiteralColumnTagger literalColumnTagger, - int[] ignoreColumns, - int[] mustdoColumns - ) { - super(ignoreColumns,mustdoColumns); - this.subjectColumnDetector = subjectColumnDetector; - this.learning = learning; - this.literalColumnTagger = literalColumnTagger; - this.relationEnumerator = relationEnumerator; - - this.update = update; - } - - public TAnnotation start(Table table, boolean relationLearning) throws STIException { - //1. find the main subject column of this table - LOG.info(">\t PHASE: Detecting subject column..."); - int[] ignoreColumnsArray = new int[getIgnoreColumns().size()]; - - int index = 0; - for (Integer i : getIgnoreColumns()) { - ignoreColumnsArray[index] = i; - index++; - } - try { - List>> subjectColumnScores = - subjectColumnDetector.compute(table, ignoreColumnsArray); - - TAnnotation tableAnnotations = new TAnnotation(table.getNumRows(), table.getNumCols()); - tableAnnotations.setSubjectColumn(subjectColumnScores.get(0).getKey()); - - List annotatedColumns = new ArrayList<>(); - LOG.info(">\t PHASE: LEARNING ..."); - for (int col = 0; col < table.getNumCols(); col++) { - /*if(col!=1) - continue;*/ - if (isCompulsoryColumn(col)) { - LOG.info("\t>> Column=(compulsory)" + col); - annotatedColumns.add(col); - learning.learn(table, tableAnnotations, col); - } else { - if (getIgnoreColumns().contains(col)) continue; - if (!table.getColumnHeader(col).getFeature().getMostFrequentDataType().getType().equals(DataTypeClassifier.DataType.NAMED_ENTITY)) - continue; - /*if (table.getColumnHeader(col).getFeature().isAcronymColumn()) - continue;*/ - annotatedColumns.add(col); - - //if (tab_annotations.getRelationAnnotationsBetween(main_subject_column, col) == null) { - LOG.info("\t>> Column=" + col); - learning.learn(table, tableAnnotations, col); - } - } - - if (update != null) { - LOG.info(">\t PHASE: UPDATE phase ..."); - update.update(annotatedColumns, table, tableAnnotations); - } - if (relationLearning) { - LOG.info("\t> PHASE: RELATION ENUMERATION ..."); - new RELATIONENUMERATION().enumerate(subjectColumnScores, - getIgnoreColumns(), relationEnumerator, - tableAnnotations, table, - annotatedColumns, update); - - //4. consolidation-for columns that have relation with main subject column, if the column is - // entity column, do column typing and disambiguation; otherwise, simply create header annotation - LOG.info("\t\t>> Annotate literal-columns in relation with main column"); - literalColumnTagger.annotate(table, tableAnnotations, annotatedColumns.toArray(new Integer[0])); - } - return tableAnnotations; - }catch (Exception e){ - throw new STIException(e); - } - } - -} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/UPDATE.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/UPDATE.java deleted file mode 100644 index dca0ea26..00000000 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/UPDATE.java +++ /dev/null @@ -1,281 +0,0 @@ -package uk.ac.shef.dcs.sti.core.algorithm.tmp; - -import javafx.util.Pair; -import org.apache.log4j.Logger; -import uk.ac.shef.dcs.kbsearch.KBSearch; -import uk.ac.shef.dcs.kbsearch.KBSearchException; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.algorithm.tmp.scorer.TMPClazzScorer; -import uk.ac.shef.dcs.sti.nlp.NLPTools; -import uk.ac.shef.dcs.sti.core.algorithm.tmp.sampler.TContentCellRanker; -import uk.ac.shef.dcs.sti.STIConstantProperty; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.sti.core.model.*; -import uk.ac.shef.dcs.util.StringUtils; - -import java.io.IOException; -import java.util.*; -import java.util.List; - -/** - - */ -public class UPDATE { - - private static final Logger LOG = Logger.getLogger(UPDATE.class.getName()); - private TCellDisambiguator disambiguator; - private KBSearch kbSearch; - private TColumnClassifier classifier; - private String nlpResourcesDir; - private TContentCellRanker selector; - private List stopWords; - - public UPDATE(TContentCellRanker selector, - KBSearch kbSearch, - TCellDisambiguator disambiguator, - TColumnClassifier classifier, - List stopwords, - String nlpResourcesDir) { - this.selector = selector; - this.kbSearch = kbSearch; - this.disambiguator = disambiguator; - this.classifier = classifier; - this.nlpResourcesDir = nlpResourcesDir; - this.stopWords = stopwords; - } - - /** - * start the UPDATE process - * - * @param interpretedColumnIndexes - * @param table - * @param currentAnnotation - * @throws KBSearchException - * @throws STIException - */ - public void update( - List interpretedColumnIndexes, - Table table, - TAnnotation currentAnnotation - ) throws KBSearchException, STIException { - - int currentIteration = 0; - TAnnotation prevAnnotation; - //TAnnotation.copy(currentAnnotation, prevAnnotation); - List domainRep; - Set allEntityIds = new HashSet<>(); - boolean stable; - do { - ///////////////// solution 2: both prev and current iterations' headers will have dc scores added - LOG.info("\t>> UPDATE begins, iteration:" + currentIteration); - allEntityIds.addAll(collectAllEntityCandidateIds(table, currentAnnotation)); - //current iteration annotation header scores does not contain dc scores - - //headers will have dc computeElementScores added - domainRep = createDomainRep(table, currentAnnotation, interpretedColumnIndexes); - //update clazz scores with dc scores - classifier.updateClazzScoresByDC(currentAnnotation, domainRep, interpretedColumnIndexes); - - prevAnnotation = new TAnnotation(currentAnnotation.getRows(), - currentAnnotation.getCols()); - TAnnotation.copy(currentAnnotation, prevAnnotation); - - //scores will be reset, then recalculated. dc scores lost - reviseColumnAndCellAnnotations(allEntityIds, - table, currentAnnotation, interpretedColumnIndexes); - LOG.info("\t>> update iteration " + currentAnnotation + "complete"); - stable = checkStablization(prevAnnotation, currentAnnotation, - table.getNumRows(), interpretedColumnIndexes); - if (!stable) { - //System.out.println("debug"); - } - currentIteration++; - } while (!stable && currentIteration < STIConstantProperty.UPDATE_PHASE_MAX_ITERATIONS); - - if (currentIteration >= STIConstantProperty.UPDATE_PHASE_MAX_ITERATIONS) { - LOG.warn("\t>> UPDATE CANNOT STABILIZE AFTER " + currentIteration + " ITERATIONS, Stopped"); - if (prevAnnotation != null) { - currentAnnotation = new TAnnotation(prevAnnotation.getRows(), - prevAnnotation.getCols()); - TAnnotation.copy(prevAnnotation, - currentAnnotation); - } - } else - LOG.info("\t>> UPDATE STABLIZED AFTER " + currentIteration + " ITERATIONS"); - - } - - private Set collectAllEntityCandidateIds(Table table, TAnnotation prevAnnotation) { - Set ids = new HashSet<>(); - for (int col = 0; col < table.getNumCols(); col++) { - for (int row = 0; row < table.getNumRows(); row++) { - TCellAnnotation[] cas = prevAnnotation.getContentCellAnnotations(row, col); - if (cas == null) - continue; - for (TCellAnnotation ca : cas) { - ids.add(ca.getAnnotation().getId()); - } - } - } - return ids; - } - - public List createDomainRep(Table table, TAnnotation currentAnnotation, List interpretedColumns) { - List domain = new ArrayList<>(); - for (int c : interpretedColumns) { - for (int r = 0; r < table.getNumRows(); r++) { - TCellAnnotation[] annotations = currentAnnotation.getContentCellAnnotations(r, c); - if (annotations != null && annotations.length > 0) { - Entity ec = annotations[0].getAnnotation(); - try { - domain.addAll(createEntityDomainRep(ec)); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } - return domain; - } - - private Collection createEntityDomainRep(Entity ec) throws IOException { - List domain = new ArrayList<>(); - String desc = ec.getDescription(); - String[] sentences = NLPTools.getInstance(nlpResourcesDir).getSentenceSplitter().sentDetect(desc); - String first = sentences.length > 0 ? sentences[0] : ""; - List tokens = StringUtils.toBagOfWords(first, true, true, true); - domain.addAll(tokens); - domain.removeAll(stopWords); - return domain; - } - - - private void reviseColumnAndCellAnnotations( - Set allEntityIds, - Table table, - TAnnotation currentAnnotation, - List interpretedColumns) throws KBSearchException, STIException { - //now revise annotations on each of the interpreted columns - for (int c : interpretedColumns) { - LOG.info("\t\t>> for column " + c); - //sample ranking - List> ranking = selector.select(table, c, currentAnnotation.getSubjectColumn()); - - //get winning header annotation - List winningColumnClazzAnnotations = - currentAnnotation.getWinningHeaderAnnotations(c); - Set columnTypes = new HashSet<>(); - for (TColumnHeaderAnnotation ha : winningColumnClazzAnnotations) - columnTypes.add(ha.getAnnotation().getId()); - - List updated = new ArrayList<>(); - for (int bi = 0; bi < ranking.size(); bi++) { - List rows = ranking.get(bi); - TCell sample = table.getContentCell(rows.get(0), c); - if (sample.getText().length() < 2) { - LOG.info("\t\t>>> short text cell skipped: " + rows + "," + c + " " + sample.getText()); - continue; - } - - //constrained disambiguation - List>> - entity_and_scoreMap = - disambiguate(allEntityIds, - sample, - table, - columnTypes, - rows, c, ranking.size()); - - if (entity_and_scoreMap.size() > 0) { - disambiguator.addCellAnnotation(table, currentAnnotation, rows, c, - entity_and_scoreMap); - updated.addAll(rows); - } - } - - - classifier.updateColumnClazz(updated, c, currentAnnotation, table, true); - //at this point, DC should have been computed. But updateColumnClazz does not add DC to the newly compuetd clazz score. - //we should add DC to the total score here. however we should use existing DC calculated using the previous annotations, - //not to recalculate DC using TColumnClassifier.updateClazzScoresByDC - TColumnHeaderAnnotation[] columnHeaderAnnotations = currentAnnotation.getHeaderAnnotation(c); - - for (TColumnHeaderAnnotation ha : columnHeaderAnnotations) { - Double dc = ha.getScoreElements().get(TMPClazzScorer.SCORE_DOMAIN_CONSENSUS); - if (dc != null) - ha.setFinalScore(ha.getFinalScore() + dc); - } - Arrays.sort(columnHeaderAnnotations); - currentAnnotation.setHeaderAnnotation(c, columnHeaderAnnotations); - } - - } - - - private List>> disambiguate(Set ignoreEntityIds, - TCell tcc, - Table table, - Set constrainedClazz, - List rowBlock, - int table_cell_col, - int totalRowBlocks) throws KBSearchException { - List>> entity_and_scoreMap; - List candidates = kbSearch.findEntityCandidatesOfTypes(tcc.getText(), - constrainedClazz.toArray(new String[0])); - - int ignore = 0; - for (uk.ac.shef.dcs.kbsearch.model.Resource ec : candidates) { - if (ignoreEntityIds.contains(ec.getId())) - ignore++; - } - if (candidates != null && candidates.size() != 0) { - } else { - candidates = kbSearch.findEntityCandidatesOfTypes(tcc.getText()); - } - LOG.debug("\t\t>> Rows=" + rowBlock + "/" + totalRowBlocks + " (Total candidates=" + candidates.size() + ", previously already processed=" + ignore + ")"); - //now each candidate is given scores - entity_and_scoreMap = - disambiguator.constrainedDisambiguate - (candidates, table, rowBlock, table_cell_col, totalRowBlocks, false); - - return entity_and_scoreMap; - } - - - private boolean checkStablization(TAnnotation prev_iteration_annotation, TAnnotation table_annotation, int totalRows, List interpreted_columns) { - //check header annotations - int columnAnnotationStable = 0; - boolean stable = false; - for (int c : interpreted_columns) { - List header_annotations_prev_iteration = prev_iteration_annotation.getWinningHeaderAnnotations(c); - List header_annotations_current_iteration = table_annotation.getWinningHeaderAnnotations(c); - if (header_annotations_current_iteration.size() == header_annotations_prev_iteration.size()) { - header_annotations_current_iteration.retainAll(header_annotations_prev_iteration); - if (header_annotations_current_iteration.size() == header_annotations_prev_iteration.size()) - columnAnnotationStable++; - else - return false; - } else - return false; - } - if (columnAnnotationStable == interpreted_columns.size()) { - stable = true; - } - - //check cell annotations - boolean cellAnnotationStable = true; - for (int c : interpreted_columns) { - for (int row = 0; row < totalRows; row++) { - List cell_prev_annotations = prev_iteration_annotation.getWinningContentCellAnnotation(row, c); - List cell_current_annotations = table_annotation.getWinningContentCellAnnotation(row, c); - if (cell_current_annotations.size() == cell_prev_annotations.size()) { - cell_current_annotations.retainAll(cell_prev_annotations); - if (cell_current_annotations.size() != cell_prev_annotations.size()) - return false; - } - } - } - return stable && cellAnnotationStable; - } - -} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_combined.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_combined.java deleted file mode 100644 index 9196c55c..00000000 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_combined.java +++ /dev/null @@ -1,256 +0,0 @@ -package uk.ac.shef.dcs.sti.core.algorithm.tmp.sampler; - -import uk.ac.shef.dcs.sti.STIConstantProperty; -import uk.ac.shef.dcs.sti.util.DataTypeClassifier; -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.util.StringUtils; - -import java.util.*; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 27/05/14 - * Time: 11:20 - * To change this template use File | Settings | File Templates. - */ -public class OSPD_combined extends TContentCellRanker { - private List stopwords = new ArrayList(); - - public OSPD_combined(List stopwords) { - this.stopwords = stopwords; - } - - @Override - public List> select(Table table, int fromCol, int subCol) { - List> rs = new ArrayList>(); - - if (STIConstantProperty.ENFORCE_OSPD && fromCol != subCol) { - //firstly group by one-sense-per-discourse - Map> grouped = new HashMap>(); - for (int r = 0; r < table.getNumRows(); r++) { - TCell tcc = table.getContentCell(r, fromCol); - String text = tcc.getText(); - if (text.length() > 0) { - List group = grouped.get(text); - if (group == null) - group = new ArrayList(); - group.add(r); - grouped.put(text, group); - } - } - - - final Map, Integer> countNonEmpty = new HashMap, Integer>(); - int max_non_emtpy = 0; - final Map, Integer> countNonStopwords = new HashMap, Integer>(); - int max_non_stopwords = 0; - final Map scores_name_length = new LinkedHashMap(); - int max_name_length = 0; - //then make selection - for (Map.Entry> entry : grouped.entrySet()) { - List rows = entry.getValue(); - - int count_non_emtpy = 0; - int count_non_stopwords = 0; - int count_name_length = 0; - for (int i = 0; i < rows.size(); i++) { - for (int c = 0; c < table.getNumCols(); c++) { - TCell tcc = table.getContentCell(rows.get(i), c); - if (tcc.getType() != null && !tcc.getType().equals(DataTypeClassifier.DataType.UNKNOWN) && - !tcc.getType().equals(DataTypeClassifier.DataType.EMPTY)) - count_non_emtpy++; - else if (tcc.getType() == null) { - String text = tcc.getText().trim(); - if (text.length() > 0) - count_non_emtpy++; - } - - List tokens = StringUtils.splitToAlphaNumericTokens(tcc.getText().trim(), true); - tokens.removeAll(stopwords); - - if (tokens.size() > 0) - count_non_stopwords += tokens.size(); - } - - } - countNonEmpty.put(rows, count_non_emtpy); - if (count_non_emtpy > max_non_emtpy) - max_non_emtpy = count_non_emtpy; - countNonStopwords.put(rows, count_non_stopwords); - if (count_non_stopwords > max_non_stopwords) - max_non_stopwords = count_non_stopwords; - TCell tcc_at_focus = table.getContentCell(rows.get(0), fromCol); - if (tcc_at_focus.getType().equals(DataTypeClassifier.DataType.EMPTY)) { - for (int r : rows) { - scores_name_length.put(r, 0); - } - continue; - } - String text = tcc_at_focus.getText(); - text = text.replaceAll("[\\-_/,]", " ").replace("\\s+", " ").trim(); - count_name_length = text.split("\\s+").length; - if (count_name_length > max_name_length) - max_name_length = count_name_length; - for (int r : rows) { - scores_name_length.put(r, count_name_length); - } - - if (rows.size() > 0) { - rs.add(rows); - } - } - - - final Map, Double> countNonEmpty_normalized = new HashMap, Double>(); - final Map, Double> countNonStopwords_normalized = new HashMap, Double>(); - final Map scores_name_length_normalized = new LinkedHashMap(); - - for (Map.Entry, Integer> e : countNonEmpty.entrySet()) { - double score = max_non_emtpy == 0 ? 0 : (double) e.getValue() / max_non_emtpy; - countNonEmpty_normalized.put(e.getKey(), score); - } - for (Map.Entry, Integer> e : countNonStopwords.entrySet()) { - double score = max_non_stopwords == 0 ? 0 : (double) e.getValue() / max_non_stopwords; - countNonStopwords_normalized.put(e.getKey(), score); - } - for (Map.Entry e : scores_name_length.entrySet()) { - double score = max_name_length == 0 ? 0 : (double) e.getValue() / max_name_length; - scores_name_length_normalized.put(e.getKey(), score); - } - - Collections.sort(rs, new Comparator>() { - @Override - public int compare(List o1, List o2) { - double countnonempty1 = countNonEmpty_normalized.get(o1); - double countnonempty2 = countNonEmpty_normalized.get(o2); - double countnonstopwords1 = countNonStopwords_normalized.get(o1); - double countnonstopwords2 = countNonStopwords_normalized.get(o2); - double countnamelength1 = scores_name_length_normalized.get(o1.get(0)); - double countnamelength2 = scores_name_length_normalized.get(o2.get(0)); - - double score1 = /*countnonempty1 +*/ countnonstopwords1 + countnamelength1; - double score2 = /*countnonempty2 +*/ countnonstopwords2 + countnamelength2; - - return new Double(score2).compareTo(score1); - } - }); - - - } else { - final Map scores_non_empty_cells = new LinkedHashMap(); - int max_non_emtpy = 0; - for (int r = 0; r < table.getNumRows(); r++) { - int count_non_empty = 0; - TCell tcc_at_focus = table.getContentCell(r, fromCol); - if (tcc_at_focus.getType().equals(DataTypeClassifier.DataType.EMPTY)) { - continue; - } - - for (int c = 0; c < table.getNumCols(); c++) { - TCell tcc = table.getContentCell(r, c); - if (tcc.getType() != null && !tcc.getType().equals(DataTypeClassifier.DataType.UNKNOWN) && - !tcc.getType().equals(DataTypeClassifier.DataType.EMPTY)) - count_non_empty++; - else if (tcc.getType() == null) { - String cellText = tcc.getText().trim(); - if (cellText.length() > 0) - count_non_empty++; - } - } - if (count_non_empty > max_non_emtpy) - max_non_emtpy = count_non_empty; - - scores_non_empty_cells.put(r, count_non_empty); - } - - - final Map scores_non_stopwords = new LinkedHashMap(); - int max_non_stopwords = 0; - for (int r = 0; r < table.getNumRows(); r++) { - int count_non_stopwords = 0; - TCell tcc_at_focus = table.getContentCell(r, fromCol); - if (tcc_at_focus.getType().equals(DataTypeClassifier.DataType.EMPTY)) { - continue; - } - - for (int c = 0; c < table.getNumCols(); c++) { - TCell tcc = table.getContentCell(r, c); - - List tokens = StringUtils.splitToAlphaNumericTokens(tcc.getText().trim(), true); - tokens.removeAll(stopwords); - - if (tokens.size() > 0) - count_non_stopwords += tokens.size(); - } - if (count_non_stopwords > max_non_stopwords) - max_non_stopwords = count_non_stopwords; - scores_non_stopwords.put(r, count_non_stopwords); - } - - - final Map scores_name_length = new LinkedHashMap(); - int max_name_length = 0; - for (int r = 0; r < table.getNumRows(); r++) { - int count_name_length = 0; - TCell tcc_at_focus = table.getContentCell(r, fromCol); - if (tcc_at_focus.getType().equals(DataTypeClassifier.DataType.EMPTY)) { - scores_name_length.put(r, 0); - continue; - } - - String text = tcc_at_focus.getText(); - text = text.replaceAll("[\\-_/,]", " ").replace("\\s+", " ").trim(); - count_name_length = text.split("\\s+").length; - scores_name_length.put(r, count_name_length); - if (count_name_length > max_name_length) - max_name_length = count_name_length; - } - - - final Map countNonEmpty_normalized = new HashMap(); - final Map countNonStopwords_normalized = new HashMap(); - final Map scores_name_length_normalized = new LinkedHashMap(); - - for (Map.Entry e : scores_non_empty_cells.entrySet()) { - double score = max_non_emtpy == 0 ? 0 : (double) e.getValue() / max_non_emtpy; - countNonEmpty_normalized.put(e.getKey(), score); - } - for (Map.Entry e : scores_non_stopwords.entrySet()) { - double score = max_non_stopwords == 0 ? 0 : (double) e.getValue() / max_non_stopwords; - countNonStopwords_normalized.put(e.getKey(), score); - } - for (Map.Entry e : scores_name_length.entrySet()) { - double score = max_name_length == 0 ? 0 : (double) e.getValue() / max_name_length; - scores_name_length_normalized.put(e.getKey(), score); - } - - List list = new ArrayList(scores_non_empty_cells.keySet()); - Collections.sort(list, new Comparator() { - @Override - public int compare(Integer o1, Integer o2) { - double countnonempty1 = countNonEmpty_normalized.get(o1); - double countnonempty2 = countNonEmpty_normalized.get(o2); - double countnonstopwords1 = countNonStopwords_normalized.get(o1); - double countnonstopwords2 = countNonStopwords_normalized.get(o2); - double countnamelength1 = scores_name_length_normalized.get(o1); - double countnamelength2 = scores_name_length_normalized.get(o2); - - double score1 = countnonempty1 + countnonstopwords1 + countnamelength1; - double score2 = countnonempty2 + countnonstopwords2 + countnamelength2; - - return new Double(score2).compareTo(score1); - } - }); - - - for (int i = 0; i < list.size(); i++) { - List block = new ArrayList(); - block.add(i); - rs.add(block); - } - } - return rs; - } -} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_contextWords.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_contextWords.java deleted file mode 100644 index 0e57644f..00000000 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_contextWords.java +++ /dev/null @@ -1,117 +0,0 @@ -package uk.ac.shef.dcs.sti.core.algorithm.tmp.sampler; - -import uk.ac.shef.dcs.sti.util.DataTypeClassifier; -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.STIConstantProperty; -import uk.ac.shef.dcs.util.StringUtils; - -import java.util.*; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 27/05/14 - * Time: 10:34 - * To change this template use File | Settings | File Templates. - */ -public class OSPD_contextWords extends TContentCellRanker { - - private List stopwords = new ArrayList(); - - public OSPD_contextWords(List stopwords) { - this.stopwords = stopwords; - } - - @Override - public List> select(Table table, int fromCol, int subCol) { - List> rs = new ArrayList>(); - - if (STIConstantProperty.ENFORCE_OSPD && fromCol != subCol) { - //firstly group by one-sense-per-discourse - Map> grouped = new HashMap>(); - for (int r = 0; r < table.getNumRows(); r++) { - TCell tcc = table.getContentCell(r, fromCol); - String text = tcc.getText(); - if (text.length() > 0) { - List group = grouped.get(text); - if (group == null) - group = new ArrayList(); - group.add(r); - grouped.put(text, group); - } - } - - final Map, Integer> countNonStopwords = new HashMap, Integer>(); - - - //then make selection - for (Map.Entry> entry : grouped.entrySet()) { - List rows = entry.getValue(); - - int count_non_stopwords = 0; - for (int i = 0; i < rows.size(); i++) { - for (int c = 0; c < table.getNumCols(); c++) { - TCell tcc = table.getContentCell(rows.get(i), c); - - List tokens = StringUtils.splitToAlphaNumericTokens(tcc.getText().trim(), true); - tokens.removeAll(stopwords); - - if (tokens.size() > 0) - count_non_stopwords+=tokens.size(); - - } - } - countNonStopwords.put(rows, count_non_stopwords); - if (rows.size() > 0) { - rs.add(rows); - } - - - } - - Collections.sort(rs, new Comparator>() { - @Override - public int compare(List o1, List o2) { - return new Integer(countNonStopwords.get(o2)).compareTo(countNonStopwords.get(o1)); - } - }); - - } else { - final Map scores = new LinkedHashMap(); - for (int r = 0; r < table.getNumRows(); r++) { - int count_non_stopwords = 0; - TCell tcc_at_focus = table.getContentCell(r, fromCol); - if (tcc_at_focus.getType().equals(DataTypeClassifier.DataType.EMPTY)) { - continue; - } - - for (int c = 0; c < table.getNumCols(); c++) { - TCell tcc = table.getContentCell(r, c); - - List tokens = StringUtils.splitToAlphaNumericTokens(tcc.getText().trim(), true); - tokens.removeAll(stopwords); - - if (tokens.size() > 0) - count_non_stopwords+=tokens.size(); - } - scores.put(r, count_non_stopwords); - } - - List list = new ArrayList(scores.keySet()); - Collections.sort(list, new Comparator() { - @Override - public int compare(Integer o1, Integer o2) { - return scores.get(o2).compareTo(scores.get(o1)); - } - }); - - for (int i = 0; i < list.size(); i++) { - List block = new ArrayList(); - block.add(i); - rs.add(block); - } - } - return rs; - } -} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nameLength.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nameLength.java deleted file mode 100644 index ef4352f8..00000000 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nameLength.java +++ /dev/null @@ -1,53 +0,0 @@ -package uk.ac.shef.dcs.sti.core.algorithm.tmp.sampler; - -import uk.ac.shef.dcs.sti.util.DataTypeClassifier; -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.Table; - -import java.util.*; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 27/05/14 - * Time: 11:09 - * To change this template use File | Settings | File Templates. - */ -public class OSPD_nameLength extends TContentCellRanker { - @Override - public List> select(Table table, int fromCol, int subCol) { - List> rs = new ArrayList>(); - - - final Map scores = new LinkedHashMap(); - for (int r = 0; r < table.getNumRows(); r++) { - int count_name_length = 0; - TCell tcc_at_focus = table.getContentCell(r, fromCol); - if (tcc_at_focus.getType().equals(DataTypeClassifier.DataType.EMPTY)) { - scores.put(r, 0); - continue; - } - - String text = tcc_at_focus.getText(); - text = text.replaceAll("[\\-_/,]"," ").replace("\\s+"," ").trim(); - count_name_length=text.split("\\s+").length; - scores.put(r, count_name_length); - } - - List list = new ArrayList(scores.keySet()); - Collections.sort(list, new Comparator() { - @Override - public int compare(Integer o1, Integer o2) { - return scores.get(o2).compareTo(scores.get(o1)); - } - }); - - for (int i = 0; i < list.size(); i++) { - List block = new ArrayList(); - block.add(i); - rs.add(block); - } - - return rs; - } -} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_namelength_merge.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_namelength_merge.java deleted file mode 100644 index 6e7f1dde..00000000 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_namelength_merge.java +++ /dev/null @@ -1,104 +0,0 @@ -package uk.ac.shef.dcs.sti.core.algorithm.tmp.sampler; - -import uk.ac.shef.dcs.sti.STIConstantProperty; -import uk.ac.shef.dcs.sti.util.DataTypeClassifier; -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.Table; - -import java.util.*; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 07/07/14 - * Time: 14:44 - * To change this template use File | Settings | File Templates. - */ -public class OSPD_namelength_merge extends TContentCellRanker { - - - public List> select(Table table, int fromCol, int subCol) { - List> rs = new ArrayList>(); - - if (STIConstantProperty.ENFORCE_OSPD && fromCol != subCol) { - //firstly group by one-sense-per-discourse - Map> grouped = new HashMap>(); - for (int r = 0; r < table.getNumRows(); r++) { - TCell tcc = table.getContentCell(r, fromCol); - String text = tcc.getText(); - if (text.length() > 0) { - List group = grouped.get(text); - if (group == null) - group = new ArrayList(); - group.add(r); - grouped.put(text, group); - } - } - - final Map, Integer> countNameLength = new HashMap, Integer>(); - - - //then make selection - for (Map.Entry> entry : grouped.entrySet()) { - List rows = entry.getValue(); - - TCell tcc = table.getContentCell(rows.get(0), fromCol); - if (tcc.getType().equals(DataTypeClassifier.DataType.EMPTY)) { - countNameLength.put(rows, 0); - continue; - } - - String text = tcc.getText(); - text = text.replaceAll("[\\-_/,]"," ").replace("\\s+"," ").trim(); - int count_name_length=text.split("\\s+").length; - countNameLength.put(rows, count_name_length); - - if (rows.size() > 0) { - rs.add(rows); - } - - } - - Collections.sort(rs, new Comparator>() { - @Override - public int compare(List o1, List o2) { - return new Integer(countNameLength.get(o2)).compareTo(countNameLength.get(o1)); - } - }); - - } else { - final Map scores = new LinkedHashMap(); - for (int r = 0; r < table.getNumRows(); r++) { - int count_name_length = 0; - TCell tcc_at_focus = table.getContentCell(r, fromCol); - if (tcc_at_focus.getType().equals(DataTypeClassifier.DataType.EMPTY)) { - scores.put(r, 0); - continue; - } - - String text = tcc_at_focus.getText(); - text = text.replaceAll("[\\-_/,]"," ").replace("\\s+"," ").trim(); - count_name_length=text.split("\\s+").length; - scores.put(r, count_name_length); - } - - List list = new ArrayList(scores.keySet()); - Collections.sort(list, new Comparator() { - @Override - public int compare(Integer o1, Integer o2) { - return scores.get(o2).compareTo(scores.get(o1)); - } - }); - - for (int i = 0; i < list.size(); i++) { - List block = new ArrayList(); - block.add(i); - rs.add(block); - } - } - return rs; - } - - - -} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nonEmpty.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nonEmpty.java deleted file mode 100644 index 0712f863..00000000 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_nonEmpty.java +++ /dev/null @@ -1,97 +0,0 @@ -package uk.ac.shef.dcs.sti.core.algorithm.tmp.sampler; - -import uk.ac.shef.dcs.sti.util.DataTypeClassifier; -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.STIConstantProperty; - -import java.util.*; - -/** - - */ -public class OSPD_nonEmpty extends TContentCellRanker { - @Override - public List> select(Table table, int fromCol, int subCol) { - List> rs = new ArrayList>(); - - if (STIConstantProperty.ENFORCE_OSPD && fromCol!=subCol) { - //firstly group by one-sense-per-discourse - Map> grouped = new HashMap<>(); - for (int r = 0; r < table.getNumRows(); r++) { - TCell tcc = table.getContentCell(r, fromCol); - String text = tcc.getText(); - if (text.length() > 0) { - List group = grouped.get(text); - if (group == null) - group = new ArrayList<>(); - group.add(r); - grouped.put(text, group); - } - } - - final Map, Integer> countNonEmpty = new HashMap, Integer>(); - //then make selection - for (Map.Entry> entry : grouped.entrySet()) { - List rows = entry.getValue(); - - int count_non_emtpy = 0; - for (int i = 0; i < rows.size(); i++) { - for (int c = 0; c < table.getNumCols(); c++) { - TCell tcc = table.getContentCell(rows.get(i), c); - if (tcc.getType() != null && !tcc.getType().equals(DataTypeClassifier.DataType.UNKNOWN) && - !tcc.getType().equals(DataTypeClassifier.DataType.EMPTY)) - count_non_emtpy++; - else if (tcc.getType() == null) { - String text = tcc.getText().trim(); - if (text.length() > 0) - count_non_emtpy++; - } - } - } - countNonEmpty.put(rows, count_non_emtpy); - if (rows.size() > 0) { - rs.add(rows); - } - - - } - - Collections.sort(rs, (o1, o2) -> new Integer(countNonEmpty.get(o2)).compareTo(countNonEmpty.get(o1))); - - } - else{ - final Map scores = new LinkedHashMap(); - for (int r = 0; r < table.getNumRows(); r++) { - int count_non_empty = 0; - TCell tcc_at_focus = table.getContentCell(r, fromCol); - if(tcc_at_focus.getType().equals(DataTypeClassifier.DataType.EMPTY)){ - continue; - } - - for (int c = 0; c < table.getNumCols(); c++) { - TCell tcc = table.getContentCell(r, c); - if (tcc.getType() != null && !tcc.getType().equals(DataTypeClassifier.DataType.UNKNOWN) && - !tcc.getType().equals(DataTypeClassifier.DataType.EMPTY)) - count_non_empty++; - else if(tcc.getType()==null){ - String cellText = tcc.getText().trim(); - if(cellText.length()>0) - count_non_empty++; - } - } - scores.put(r, count_non_empty); - } - - List list = new ArrayList(scores.keySet()); - Collections.sort(list, (o1, o2) -> scores.get(o2).compareTo(scores.get(o1))); - - for (int i=0; i block = new ArrayList(); - block.add(i); - rs.add(block); - } - } - return rs; - } -} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_random.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_random.java deleted file mode 100644 index 2946e128..00000000 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/OSPD_random.java +++ /dev/null @@ -1,102 +0,0 @@ -package uk.ac.shef.dcs.sti.core.algorithm.tmp.sampler; - -import uk.ac.shef.dcs.sti.util.DataTypeClassifier; -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.STIConstantProperty; - -import java.util.*; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 11/06/14 - * Time: 17:18 - * To change this template use File | Settings | File Templates. - */ -public class OSPD_random extends TContentCellRanker { - @Override - public List> select(Table table, int fromCol, int subCol) { - List> rs = new ArrayList>(); - - if (STIConstantProperty.ENFORCE_OSPD && fromCol!=subCol) { - //firstly group by one-sense-per-discourse - Map> grouped = new HashMap>(); - for (int r = 0; r < table.getNumRows(); r++) { - TCell tcc = table.getContentCell(r, fromCol); - String text = tcc.getText(); - if (text.length() > 0) { - List group = grouped.get(text); - if (group == null) - group = new ArrayList(); - group.add(r); - grouped.put(text, group); - } - } - - final Map, Integer> countNonEmpty = new HashMap, Integer>(); - - //then make selection - for (Map.Entry> entry : grouped.entrySet()) { - List rows = entry.getValue(); - - int count_non_emtpy = 0; - for (int i = 0; i < rows.size(); i++) { - for (int c = 0; c < table.getNumCols(); c++) { - TCell tcc = table.getContentCell(rows.get(i), c); - if (tcc.getType() != null && !tcc.getType().equals(DataTypeClassifier.DataType.UNKNOWN) && - !tcc.getType().equals(DataTypeClassifier.DataType.EMPTY)) - count_non_emtpy++; - else if (tcc.getType() == null) { - String text = tcc.getText().trim(); - if (text.length() > 0) - count_non_emtpy++; - } - } - } - countNonEmpty.put(rows, count_non_emtpy); - if (rows.size() > 0) { - rs.add(rows); - } - - - } - - Collections.shuffle(rs); - - } - else{ - final Map scores = new LinkedHashMap(); - for (int r = 0; r < table.getNumRows(); r++) { - int count_non_empty = 0; - TCell tcc_at_focus = table.getContentCell(r, fromCol); - if(tcc_at_focus.getType().equals(DataTypeClassifier.DataType.EMPTY)){ - continue; - } - - for (int c = 0; c < table.getNumCols(); c++) { - TCell tcc = table.getContentCell(r, c); - if (tcc.getType() != null && !tcc.getType().equals(DataTypeClassifier.DataType.UNKNOWN) && - !tcc.getType().equals(DataTypeClassifier.DataType.EMPTY)) - count_non_empty++; - else if(tcc.getType()==null){ - String cellText = tcc.getText().trim(); - if(cellText.length()>0) - count_non_empty++; - } - } - scores.put(r, count_non_empty); - } - - List list = new ArrayList(scores.keySet()); - Collections.shuffle(list); - - for (int i=0; i block = new ArrayList(); - block.add(i); - rs.add(block); - } - } - return rs; - } -} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/Random.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/Random.java deleted file mode 100644 index 2017911b..00000000 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/Random.java +++ /dev/null @@ -1,53 +0,0 @@ -package uk.ac.shef.dcs.sti.core.algorithm.tmp.sampler; - -import uk.ac.shef.dcs.sti.util.DataTypeClassifier; -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.Table; - -import java.util.*; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 27/05/14 - * Time: 12:27 - * To change this template use File | Settings | File Templates. - */ -public class Random extends TContentCellRanker { - - - public Random() { - } - - @Override - public List> select(Table table, int fromCol, int subCol) { - List> rs = new ArrayList>(); - - - final Map scores = new LinkedHashMap(); - for (int r = 0; r < table.getNumRows(); r++) { - TCell tcc_at_focus = table.getContentCell(r, fromCol); - if (tcc_at_focus.getType().equals(DataTypeClassifier.DataType.EMPTY)) { - continue; - } - - scores.put(r, 1); - } - - List list = new ArrayList(scores.keySet()); - Collections.sort(list, new Comparator() { - @Override - public int compare(Integer o1, Integer o2) { - return scores.get(o2).compareTo(scores.get(o1)); - } - }); - - for (int i = 0; i < list.size(); i++) { - List block = new ArrayList(); - block.add(i); - rs.add(block); - } - - return rs; - } -} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentCellRanker.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentCellRanker.java deleted file mode 100644 index 6f4c5f27..00000000 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentCellRanker.java +++ /dev/null @@ -1,16 +0,0 @@ -package uk.ac.shef.dcs.sti.core.algorithm.tmp.sampler; - -import uk.ac.shef.dcs.sti.core.model.Table; - -import java.util.List; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 20/03/14 - * Time: 12:06 - * To change this template use File | Settings | File Templates. - */ -public abstract class TContentCellRanker { - public abstract List> select(Table table, int fromCol, int subCol); -} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentRowRanker.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentRowRanker.java deleted file mode 100644 index 234ea141..00000000 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentRowRanker.java +++ /dev/null @@ -1,12 +0,0 @@ -package uk.ac.shef.dcs.sti.core.algorithm.tmp.sampler; - -import uk.ac.shef.dcs.sti.core.model.Table; - -/** - */ -public abstract class TContentRowRanker { - - //return ranking of indexes of objects in the passed list object - public abstract int[] select(Table table); - -} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentTContentRowRankerImpl.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentTContentRowRankerImpl.java deleted file mode 100644 index 05db5dc5..00000000 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/sampler/TContentTContentRowRankerImpl.java +++ /dev/null @@ -1,42 +0,0 @@ -package uk.ac.shef.dcs.sti.core.algorithm.tmp.sampler; - -import uk.ac.shef.dcs.sti.util.DataTypeClassifier; -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.Table; - -import java.util.*; - -/** - */ -public class TContentTContentRowRankerImpl extends TContentRowRanker { - @Override - public int[] select(Table table) { - int[] rs = new int[table.getNumRows()]; - - final Map scores = new LinkedHashMap(); - for (int i = 0; i < table.getNumRows(); i++) { - int count_non_empty = 0; - for (int col = 0; col < table.getNumCols(); col++) { - TCell tcc = table.getContentCell(i, col); - if (tcc.getType() != null && !tcc.getType().equals(DataTypeClassifier.DataType.UNKNOWN) && - !tcc.getType().equals(DataTypeClassifier.DataType.EMPTY)) - count_non_empty++; - else if(tcc.getType()==null){ - String cellText = tcc.getText().trim(); - if(cellText.length()>0) - count_non_empty++; - } - } - scores.put(i, count_non_empty); - } - - List list = new ArrayList(scores.keySet()); - Collections.sort(list, (o1, o2) -> scores.get(o2).compareTo(scores.get(o1))); - - for (int i=0; i stopWords; - protected OntologyBasedBoWCreator bowCreator; - private double[] wt; //header text, column, out table ctx: title&caption, out table ctx:other - - public TMPClazzScorer(String nlpResources, OntologyBasedBoWCreator bowCreator, List stopWords, - double[] weights) throws IOException { - this.lemmatizer = NLPTools.getInstance(nlpResources).getLemmatizer(); - this.bowCreator = bowCreator; - this.stopWords = stopWords; - this.wt = weights; - } - - @Override - public List computeElementScores(List>> input, - Collection headerAnnotationCandidates, - Table table, - List rows, int column) { - List candidates = new ArrayList<>(); - for (int row : rows) - candidates = computeCEScore(input, headerAnnotationCandidates, table, row, column); - candidates = computeCCScore(candidates, table, column); - - return candidates; - } - - - /** - * compute concept instance computeElementScores - * - * @param entities - * @param existingHeaderAnnotations - * @param table - * @param row - * @param column - * @return - */ - public List computeCEScore(List>> entities, - Collection existingHeaderAnnotations, - Table table, - int row, int column) { - final List updatedHeaderAnnotations = - new ArrayList<>(existingHeaderAnnotations); - - //for this row - Entity winningEntity = null; - double highestScore = 0.0; - for (Pair> es : entities) { //each candidate entity in this cell - Entity entity = es.getKey(); - //each assigned type receives a computeElementScores of 1, and the bonus computeElementScores due to disambiguation result - double entityCFScore = es.getValue().get(TCellAnnotation.SCORE_FINAL); - if (entityCFScore > highestScore) { - highestScore = entityCFScore; - winningEntity = entity; - } - } - if (entities.size() == 0 || winningEntity == null) { - //this entity has a computeElementScores of 0.0, it should not contribute to the header typing, but we may still keep it as candidate for this cell - LOG.warn("no clazz elected by cell: (" + row + "," + column + ")"); - return updatedHeaderAnnotations; - } - - - for (Pair> es : entities) { - Entity entity = es.getKey(); - double entityCFScore = es.getValue().get(TCellAnnotation.SCORE_FINAL); - if (entityCFScore != highestScore) - continue; - - Set votedClazzByThisCell = new HashSet<>(); //each type will receive a max of 1 vote from each cell. If multiple candidates have the same highest computeElementScores and casts same votes, they are counted oly once - List votedClazzByThisEntity = entity.getTypes(); - - //consolidate scores from this cell - for (Clazz clazz : votedClazzByThisEntity) { - if (votedClazzByThisCell.contains(clazz.getId())) - continue; - - votedClazzByThisCell.add(clazz.getId()); - - String headerText = table.getColumnHeader(column).getHeaderText(); - - //is this clazz (of the winning entity) already put into the collection of header annotations? - TColumnHeaderAnnotation hAnnotation = null; - for (TColumnHeaderAnnotation headerAnnotation : updatedHeaderAnnotations) { - if (headerAnnotation.getHeaderText().equals(headerText) - && headerAnnotation.getAnnotation().equals(clazz)) { - hAnnotation = headerAnnotation; - break; - } - } - if (hAnnotation == null) { - hAnnotation = new TColumnHeaderAnnotation(headerText, clazz, 0.0); - } - Map scoreElements = hAnnotation.getScoreElements(); - if (scoreElements == null || scoreElements.size() == 0) { - scoreElements = new HashMap<>(); - scoreElements.put(SUM_CE, 0.0); - scoreElements.put(SUM_CELL_VOTE, 0.0); - } - Double sumCE=scoreElements.get(SUM_CE); - if(sumCE==null) sumCE=0.0; - scoreElements.put(SUM_CE, - sumCE + highestScore); - Double sumCellVote=scoreElements.get(SUM_CELL_VOTE); - if(sumCellVote==null) sumCellVote=0.0; - scoreElements.put(SUM_CELL_VOTE, - sumCellVote + 1.0); - hAnnotation.setScoreElements(scoreElements); - - if(!updatedHeaderAnnotations.contains(hAnnotation)) - updatedHeaderAnnotations.add(hAnnotation); - } - } - - return updatedHeaderAnnotations; - } - - - /** - * compute concept context computeElementScores - * - * @param candidates - * @param table - * @param column - * @return - */ - public List computeCCScore(Collection candidates, - Table table, int column) { - List bowHeader = null, - bowColumn = null, bowImportantContext = null, bowTrivialContext = null; - for (TColumnHeaderAnnotation ha : candidates) { - Double scoreCtxHeader = ha.getScoreElements().get(SCORE_CTX_IN_HEADER); - Double scoreCtxColumn = ha.getScoreElements().get(SCORE_CTX_IN_COLUMN); - Double scoreCtxOutTable = ha.getScoreElements().get(SCORE_CTX_OUT); - - if (scoreCtxColumn != null && - scoreCtxHeader != null - && scoreCtxOutTable != null) - continue; - - Set clazzBOW = new HashSet<>(createClazzBOW(ha, - true, - STIConstantProperty.BOW_DISCARD_SINGLE_CHAR, - STIConstantProperty.BOW_CLAZZ_INCLUDE_URI)); - - if (scoreCtxHeader == null) { - bowHeader = createHeaderTextBOW(bowHeader, table, column); - double ctx_header_text = - CollectionUtils.computeFrequencyWeightedDice(clazzBOW, bowHeader) * wt[0]; - ha.getScoreElements().put(SCORE_CTX_IN_HEADER, ctx_header_text); - } - - if (scoreCtxColumn == null) { - bowColumn = createColumnBOW(bowColumn, table, column); - double ctx_column = - CollectionUtils.computeFrequencyWeightedDice(clazzBOW, bowColumn) * wt[1]; - //CollectionUtils.computeCoverage(bag_of_words_for_column, new ArrayList(annotation_bow)) * weights[1]; - ha.getScoreElements().put(SCORE_CTX_IN_COLUMN, ctx_column); - } - - if (scoreCtxOutTable == null) { - bowImportantContext = createImportantOutTableCtxBOW(bowImportantContext, table); - double ctx_table_major = - CollectionUtils.computeFrequencyWeightedDice(clazzBOW, bowImportantContext) * wt[2]; - //CollectionUtils.computeCoverage(bag_of_words_for_table_major_context, new ArrayList(annotation_bow)) * weights[3]; - bowTrivialContext = createTrivialOutTableCtxBOW(bowTrivialContext, table); - double ctx_table_other = - CollectionUtils.computeFrequencyWeightedDice(clazzBOW, bowTrivialContext) * wt[3]; - //CollectionUtils.computeCoverage(bag_of_words_for_table_other_context, new ArrayList(annotation_bow)) * weights[2]; - ha.getScoreElements().put(SCORE_CTX_OUT, - ctx_table_major + ctx_table_other); - } - - } - - if(candidates instanceof List) - return (List)candidates; - else - return new ArrayList<>(candidates); - } - - - /*public Map computeFinal(TColumnHeaderAnnotation ha, int tableRowsTotal) { - Map scoreElements = ha.getScoreElements(); - double sum = 0.0; - double score_entity_disamb = - scoreElements.get(TColumnHeaderAnnotation.SUM_CE); - - scoreElements.put(TColumnHeaderAnnotation.SCORE_CE, score_entity_disamb); - - double score_entity_vote = scoreElements.get(TColumnHeaderAnnotation.SUM_ENTITY_VOTE)/(double)tableRowsTotal; - scoreElements.put(TColumnHeaderAnnotation.SCORE_ENTITY_VOTE, score_entity_vote); - - for (Map.Entry e : scoreElements.entrySet()) { - if (e.getKey().equals(TColumnHeaderAnnotation.SUM_CE) || - e.getKey().equals(TColumnHeaderAnnotation.SUM_ENTITY_VOTE) || - e.getKey().equals(TColumnHeaderAnnotation.FINAL)) - continue; - - sum += e.getValue(); - } - scoreElements.put(TColumnHeaderAnnotation.FINAL, sum); - ha.setFinalScore(sum); - return scoreElements; - }*/ - - public Map computeFinal(TColumnHeaderAnnotation ha, int tableRowsTotal) { - Map scoreElements = ha.getScoreElements(); - Double sum_ce =scoreElements.get(SUM_CE); - if(sum_ce==null) sum_ce=0.0; - Double sum_entity_vote = scoreElements.get(SUM_CELL_VOTE); - if(sum_entity_vote==null) sum_entity_vote=0.0; - - double ce = normalize(sum_ce,sum_entity_vote,tableRowsTotal); //sum_entity_vote==0?0:sum_ce / tableRowsTotal; - scoreElements.put(SCORE_CE, ce); - - double score_entity_vote = sum_entity_vote / (double) tableRowsTotal; - scoreElements.put(SCORE_CELL_VOTE, score_entity_vote); - - for (Map.Entry e : scoreElements.entrySet()) { - if (e.getKey().startsWith("ctx")) - ce += e.getValue(); - } - scoreElements.put(TColumnHeaderAnnotation.SCORE_FINAL, ce); - ha.setFinalScore(ce); - return scoreElements; - } - - /** - * compute domain concensus - * - * @param ha - * @param domain_representation - * @return - */ - @Override - public double computeDC(TColumnHeaderAnnotation ha, List domain_representation) throws STIException{ - List annotation_bow = createClazzBOW(ha, - true, - STIConstantProperty.BOW_DISCARD_SINGLE_CHAR, - STIConstantProperty.BOW_CLAZZ_INCLUDE_URI); - double score = CollectionUtils.computeFrequencyWeightedDice(annotation_bow, domain_representation); - score = Math.sqrt(score) * 2; - ha.getScoreElements().put(SCORE_DOMAIN_CONSENSUS, score); - - return score; //To change body of implemented methods use File | Settings | File Templates. - } - - protected List createClazzBOW(TColumnHeaderAnnotation ha, - boolean lowercase, - boolean discard_single_char, - boolean include_url) { - List bow = new ArrayList<>(); - if (include_url) { - bow.addAll(bowCreator.create(ha.getAnnotation().getId())); - } - - String label = StringUtils.toAlphaNumericWhitechar(ha.getAnnotation().getLabel()).trim(); - if (lowercase) - label = label.toLowerCase(); - for (String s : label.split("\\s+")) { - s = s.trim(); - if (s.length() > 0) - bow.add(s); - } - - if (discard_single_char) { - Iterator it = bow.iterator(); - while (it.hasNext()) { - String t = it.next(); - if (t.length() < 2) - it.remove(); - } - } - bow.removeAll(STIConstantProperty.FUNCTIONAL_STOPWORDS); - return bow; - } - - private List createImportantOutTableCtxBOW(List bowOutTableCtx, Table table) { - if (bowOutTableCtx != null) - return bowOutTableCtx; - if (table.getContexts() == null) - return new ArrayList<>(); - - List bow = new ArrayList<>(); - for (int i = 0; i < table.getContexts().size(); i++) { - TContext tx = table.getContexts().get(i); - if (tx.getType().equals(TContext.TableContextType.PAGETITLE) || - tx.getType().equals(TContext.TableContextType.CAPTION)) { - bow.addAll(lemmatizer.lemmatize( - StringUtils.toBagOfWords(tx.getText(), true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)) - ); - } - } - bow.removeAll(stopWords); - return bow; - } - - private List createTrivialOutTableCtxBOW(List bowOutTableCtx, Table table) { - if (bowOutTableCtx != null) - return bowOutTableCtx; - if (table.getContexts() == null) - return new ArrayList<>(); - - List bow = new ArrayList<>(); - for (int i = 0; i < table.getContexts().size(); i++) { - TContext tx = table.getContexts().get(i); - if (!tx.getType().equals(TContext.TableContextType.PAGETITLE) && - !tx.getType().equals(TContext.TableContextType.CAPTION)) { - bow.addAll(lemmatizer.lemmatize( - StringUtils.toBagOfWords(tx.getText(), true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)) - ); - } - } - bow.removeAll(stopWords); - return bow; - } - - private List createColumnBOW(List bag_of_words_for_column, Table table, int column) { - if (bag_of_words_for_column != null) - return bag_of_words_for_column; - List bow = new ArrayList<>(); - for (int row = 0; row < table.getNumRows(); row++) { - TCell tcc = table.getContentCell(row, column); - if (tcc.getText() != null) { - bow.addAll(lemmatizer.lemmatize( - StringUtils.toBagOfWords(tcc.getText(), true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)) - ); - } - } - bow.removeAll(stopWords); - return bow; - } - - private List createHeaderTextBOW(List bowHeaderText, Table table, int column) { - if (bowHeaderText != null) - return bowHeaderText; - List bow = new ArrayList<>(); - - // for (int c = 0; c < table.getNumCols(); c++) { - TColumnHeader header = table.getColumnHeader(column); - if (header != null && - header.getHeaderText() != null && - !header.getHeaderText().equals(STIEnum.TABLE_HEADER_UNKNOWN.getValue())) { - bow.addAll(lemmatizer.lemmatize( - StringUtils.toBagOfWords(header.getHeaderText(), true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)) - ); - } - // } - bow.removeAll(STIConstantProperty.FUNCTIONAL_STOPWORDS); - //also remove special, generic words, like "title", "name" - bow.remove("title"); - bow.remove("name"); - return bow; - } - - - private double normalize(double sum_ce, - double sum_entity_vote, - double total_table_rows) { - if (sum_entity_vote == 0) - return 0.0; - - return sum_ce/total_table_rows; //this is equivalent to the below - - /* double score_entity_vote = sum_entity_vote / total_table_rows; - double base_score = score_entity_vote * (sum_ce / sum_entity_vote); - return base_score;*/ - } -} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPEntityScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPEntityScorer.java deleted file mode 100644 index 909380e4..00000000 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPEntityScorer.java +++ /dev/null @@ -1,227 +0,0 @@ -package uk.ac.shef.dcs.sti.core.algorithm.tmp.scorer; - -import uk.ac.shef.dcs.kbsearch.model.Attribute; -import uk.ac.shef.dcs.sti.STIConstantProperty; -import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; -import uk.ac.shef.dcs.sti.core.scorer.EntityScorer; -import uk.ac.shef.dcs.sti.util.DataTypeClassifier; -import uk.ac.shef.dcs.sti.nlp.Lemmatizer; -import uk.ac.shef.dcs.sti.nlp.NLPTools; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.TContext; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.util.CollectionUtils; -import uk.ac.shef.dcs.util.StringUtils; - -import java.io.IOException; -import java.util.*; - -/** - * scoring based on how much overlap a candidate entity has with its context - */ -public class TMPEntityScorer implements EntityScorer { - - public static final String SCORE_NAME_MATCH="name_match"; - public static final String SCORE_IN_CTX_COLUMN_HEADER ="ctx_column_header"; - public static final String SCORE_IN_CTX_ROW ="ctx_row"; - public static final String SCORE_IN_CTX_COLUMN ="ctx_column"; - public static final String SCORE_OUT_CTX ="ctx_out"; - - private List stopWords; - private double[] wt; //context weights: 0-row context; 1-column context; 2-column header; 3-context (all) - private Lemmatizer lemmatizer; - - public TMPEntityScorer( - List stopWords, - double[] wt, - String nlpResources) throws IOException { - if (nlpResources != null) - lemmatizer = NLPTools.getInstance(nlpResources).getLemmatizer(); - - this.stopWords = stopWords; - this.wt = wt; - } - - - public Map computeElementScores(Entity candidate, - List all_candidates, - int sourceColumnIndex, - int sourceRowIndex, - List block, - Table table, - Entity... referenceEntities) { - /*if(candidate.getName().contains("Republican")) - System.out.println();*/ - Map scoreMap = new HashMap<>(); - String columnHeaderText = table.getColumnHeader(sourceColumnIndex).getHeaderText(); - - /* BOW OF THE ENTITY*/ - Collection bow_of_entity = createEntityBOW(candidate, lemmatizer, stopWords); - - /* BOW OF THE Row context*/ - Collection bow_of_row = createRowBOW(sourceColumnIndex, columnHeaderText, block, table, lemmatizer, stopWords); - double coverageRowCtx = CollectionUtils.computeCoverage(bow_of_entity, bow_of_row) * wt[0]; - - //double contextOverlapScore = scoreOverlap(bag_of_words_for_entity, bag_of_words_for_context); - scoreMap.put(SCORE_IN_CTX_ROW, coverageRowCtx); - - /*BOW OF Column context*/ - Collection bow_of_column = createColumnBow(sourceColumnIndex, block, table, lemmatizer, stopWords); - double coverageColumnCtx = CollectionUtils.computeCoverage(bow_of_entity, bow_of_column) * wt[1]; - scoreMap.put(SCORE_IN_CTX_COLUMN, coverageColumnCtx); - - /*BOW of column header */ - String entityLabel = candidate.getLabel(); - Set bow_of_entityLabel = new HashSet<>(StringUtils.toBagOfWords(entityLabel, true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)); - - Collection bow_of_columnHeader = new HashSet<>( - StringUtils.toBagOfWords(columnHeaderText, true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR) - ); - bow_of_columnHeader = normalize(bow_of_columnHeader, lemmatizer, stopWords); - double nameHeaderCtxScore = CollectionUtils.computeDice(bow_of_entityLabel, bow_of_columnHeader) * wt[2]; - scoreMap.put(SCORE_IN_CTX_COLUMN_HEADER, nameHeaderCtxScore/* + - name_and_col_match_score + name_and_context_match_score*/); - - /*BOW OF out table context (from paragraphs etc)*/ - Collection bow_of_outctx = createOutCtxBow(table, lemmatizer, stopWords); - double fwDice = CollectionUtils.computeFrequencyWeightedDice(bow_of_entity, bow_of_outctx) * wt[3]; - scoreMap.put(SCORE_OUT_CTX, fwDice); - - /*NAME MATCH SCORE */ - String cellText = table.getContentCell(block.get(0), sourceColumnIndex).getText(); - Set bow_of_cellText = new HashSet<>(StringUtils.toBagOfWords(cellText, true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)); - double en_score = CollectionUtils.computeDice(bow_of_cellText, bow_of_entityLabel); - scoreMap.put(SCORE_NAME_MATCH, Math.sqrt(en_score)); - //scoreMap.put("matched_name_tokens", (double) intersection.size()); - - return scoreMap; - } - - public double computeFinal(Map scoreMap, String cellTextOriginal) { - double sum = 0.0, ctx_scores = 0.0, nm_score = 0.0; - cellTextOriginal = StringUtils.toAlphaNumericWhitechar(cellTextOriginal).trim(); - - int length = cellTextOriginal.split("\\s+").length; - - double weight_ctx =/* 1.0/length*/ Math.sqrt(1.0 / length); - double weight_nm = 1.0; - - for (Map.Entry e : scoreMap.entrySet()) { - /*if (e.getKey().startsWith("ctx_")) - ctx_scores += e.getValue(); - if (e.getKey().equals(TCellAnnotation.SCORE_IN_CTX_COLUMN_HEADER)) - sum += e.getValue();*/ - ctx_scores += e.getValue(); - } - Double nameMatch = scoreMap.get(SCORE_NAME_MATCH); - if (nameMatch != null) - nm_score = nameMatch; - - sum = ctx_scores * weight_ctx + nm_score * weight_nm; - - scoreMap.put(TCellAnnotation.SCORE_FINAL, sum); - return sum; - } - - - /** - * create bow of entity - * @param candidate - * @param lemmatizer - * @param stopWords - * @return - */ - protected Collection createEntityBOW(Entity candidate, Lemmatizer lemmatizer, Collection stopWords) { - List attributes = candidate.getAttributes(); - List bow_of_entity = new ArrayList<>(); - for (Attribute f : attributes) { - if (!STIConstantProperty.BOW_ENTITY_INCLUDE_INDIRECT_ATTRIBUTE - && !f.isDirect()) - continue; - String value = f.getValue(); - if (!StringUtils.isPath(value)) - bow_of_entity.addAll(StringUtils.toBagOfWords(value, true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)); - else - bow_of_entity.add(value); - } - return normalize(bow_of_entity, lemmatizer, stopWords); - } - - /** - * create bow of the in-table context based on other columns on the same row - * - * @param sourceColumnIndex - * @param columnHeaderText - * @param block rows where given the current column index, the text in the cell of that row is identical to the source cell - * for the entity candidate - * @param table - * @param lemmatizer - * @param stopWords - * @return - */ - protected Collection createRowBOW(int sourceColumnIndex, - String columnHeaderText, - List block, - Table table, - Lemmatizer lemmatizer, Collection stopWords) { - List bag_of_words_for_context = new ArrayList<>(); - //context from the row - for (int row : block) { - for (int col = 0; col < table.getNumCols(); col++) { - if (col == sourceColumnIndex || table.getColumnHeader(col).getTypes().get(0).getType().equals( - DataTypeClassifier.DataType.ORDERED_NUMBER - )) - continue; - TCell tcc = table.getContentCell(row, col); - bag_of_words_for_context.addAll(StringUtils.toBagOfWords(tcc.getText(), true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)); - } - } - bag_of_words_for_context.addAll(StringUtils.toBagOfWords( //also add the column header as the row context of this entity - columnHeaderText, true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)); - - return normalize(bag_of_words_for_context, lemmatizer, stopWords); - } - - /** - * create bow of the in-table context based on other rows on the same column - * @param sourceColumnIndex - * @param block - * @param table - * @param lemmatizer - * @param stopWords - * @return - */ - protected Collection createColumnBow(int sourceColumnIndex, - List block, - Table table, - Lemmatizer lemmatizer, Collection stopWords){ - List bag_of_words_for_context = new ArrayList<>(); - for (int row = 0; row < table.getNumRows(); row++) { - if (block.contains(row)) - continue; - TCell tcc = table.getContentCell(row, sourceColumnIndex); - bag_of_words_for_context.addAll(StringUtils.toBagOfWords(tcc.getText(), true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)); - } - return normalize(bag_of_words_for_context, lemmatizer, stopWords); - } - - - protected Collection createOutCtxBow( - Table table, - Lemmatizer lemmatizer, Collection stopWords){ - /*BOW OF table table context (from paragraphs etc)*/ - List bag_of_words_for_context = new ArrayList<>(); - for (TContext tc : table.getContexts()) { - bag_of_words_for_context.addAll(StringUtils.toBagOfWords(tc.getText(), true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)); - } - return normalize(bag_of_words_for_context, lemmatizer, stopWords); - } - - protected Collection normalize(Collection input, Lemmatizer lemmatizer, Collection stopWords) { - if (lemmatizer != null) - input = lemmatizer.lemmatize(input); - input.removeAll(stopWords); - return input; - } -} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPRelationScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPRelationScorer.java deleted file mode 100644 index f511c8b8..00000000 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/scorer/TMPRelationScorer.java +++ /dev/null @@ -1,332 +0,0 @@ -package uk.ac.shef.dcs.sti.core.algorithm.tmp.scorer; - -import uk.ac.shef.dcs.sti.STIConstantProperty; -import uk.ac.shef.dcs.sti.STIEnum; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.feature.OntologyBasedBoWCreator; -import uk.ac.shef.dcs.sti.core.scorer.RelationScorer; -import uk.ac.shef.dcs.sti.nlp.Lemmatizer; -import uk.ac.shef.dcs.sti.nlp.NLPTools; -import uk.ac.shef.dcs.sti.core.model.*; -import uk.ac.shef.dcs.sti.util.CollectionUtils; -import uk.ac.shef.dcs.util.StringUtils; - -import java.io.IOException; -import java.util.*; -import java.util.List; - -/** - * - */ -public class TMPRelationScorer implements RelationScorer { - public static final String SUM_RE = "sum_re"; //sum of attr match scores - public static final String SUM_CELL_VOTE = "sum_row_vote"; - public static final String SCORE_RE = "re_score"; - public static final String SCORE_CELL_VOTE = "row_vote"; - public static final String SCORE_CTX_IN_HEADER = "ctx_header_text"; - public static final String SCORE_CTX_IN_COLUMN = "ctx_column_text"; - public static final String SCORE_CTX_OUT = "ctx_out_context"; - public static final String SCORE_DOMAIN_CONSENSUS = "domain_consensus"; - - private Lemmatizer lemmatizer; - private List stopWords; - private OntologyBasedBoWCreator bowCreator; - private double[] wt; //header text, column, title&caption, other - - public TMPRelationScorer(String nlpResources, OntologyBasedBoWCreator bowCreator, List stopWords, - double[] wt) throws IOException { - this.lemmatizer = NLPTools.getInstance(nlpResources).getLemmatizer(); - this.bowCreator = bowCreator; - this.stopWords = stopWords; - this.wt = wt; - } - - @Override - public List computeElementScores(List cellcellRelationsOnRow, - Collection output, - int subjectCol, int objectCol, - Table table) throws STIException { - List candidates; - - candidates = computeREScore(cellcellRelationsOnRow, output, subjectCol, objectCol); - candidates = computeRCScore(candidates, table, objectCol); - - return candidates; - } - - /** - * Compute relation instance score - * - * @param cellcellRelationAnotations - * @param output - * @param subjectCol - * @param objectCol - * @return - */ - public List computeREScore(List cellcellRelationAnotations, - Collection output, - int subjectCol, int objectCol) throws STIException { - - //for this row - TCellCellRelationAnotation winningAnnotation = null; - double winningScore = 0.0; - for (TCellCellRelationAnotation cellcellRelationAnnotation : cellcellRelationAnotations) { //each candidate entity in this cell - double attrMatchScore = cellcellRelationAnnotation.getWinningAttributeMatchScore(); - if (attrMatchScore > winningScore) { - winningScore = attrMatchScore; - winningAnnotation = cellcellRelationAnnotation; - } - } - if (cellcellRelationAnotations.size() == 0 || winningAnnotation == null) - return new ArrayList<>(output); - - Collections.sort(cellcellRelationAnotations); - - //consolidate scores from this cell - for (TCellCellRelationAnotation cellcellRelationAnnotation : cellcellRelationAnotations) { - if (cellcellRelationAnnotation.getWinningAttributeMatchScore() < winningScore) - break; - - TColumnColumnRelationAnnotation columncolumnRelationAnnotation = null; - for (TColumnColumnRelationAnnotation key : output) { - if (key.getRelationURI().equals(cellcellRelationAnnotation.getRelationURI())) { - columncolumnRelationAnnotation = key; - break; - } - } - if (columncolumnRelationAnnotation == null) { - columncolumnRelationAnnotation = new TColumnColumnRelationAnnotation( - new RelationColumns(subjectCol, objectCol), - cellcellRelationAnnotation.getRelationURI(), - cellcellRelationAnnotation.getRelationLabel(), 0.0); - output.add(columncolumnRelationAnnotation); - } - - Map scoreElements = columncolumnRelationAnnotation.getScoreElements(); - if (scoreElements == null || scoreElements.size() == 0) { - scoreElements = new HashMap<>(); - scoreElements.put(SUM_RE, 0.0); - scoreElements.put(SUM_CELL_VOTE, 0.0); - } - Double sumRE = scoreElements.get(SUM_RE); - if (sumRE == null) sumRE = 0.0; - scoreElements.put(SUM_RE, - sumRE + winningScore); - Double sumCellVote = scoreElements.get(SUM_CELL_VOTE); - if (sumCellVote == null) sumCellVote = 0.0; - scoreElements.put(SUM_CELL_VOTE, sumCellVote - + 1.0); - columncolumnRelationAnnotation.setScoreElements(scoreElements); - - //output.add(columncolumnRelationAnnotation); - } - - return new ArrayList<>(output); - } - - /** - * compute relation context score - *

- * context scores are only computed once. The code will check if they already edist for each TColumnColumnRelationAnnotation - * and if so, it will not recompute it. - * - * @param candidates - * @param table - * @param column - * @return - */ - public List computeRCScore( - Collection candidates, - Table table, int column) throws STIException { - Set bowHeader = null; - List bowColumn = null, - bowOutTableImportantCtx = null, bowOutTableTrivialCtx = null; - for (TColumnColumnRelationAnnotation ccRelationAnnotation : candidates) { - Double scoreCtxHeaderText = ccRelationAnnotation.getScoreElements().get(SCORE_CTX_IN_HEADER); - Double scoreCtxColumnText = ccRelationAnnotation.getScoreElements().get(SCORE_CTX_IN_COLUMN); - Double scoreCtxTableContext = ccRelationAnnotation.getScoreElements().get(SCORE_CTX_OUT); - - if (scoreCtxColumnText != null && - scoreCtxHeaderText != null - && scoreCtxTableContext != null) - continue; - - Set relationBOW = - createRelationBOW(ccRelationAnnotation, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR); - - if (scoreCtxHeaderText == null) { - bowHeader = createHeaderTextBOW(bowHeader, table, column); - double ctxScoreHeaderText = - CollectionUtils.computeFrequencyWeightedDice(relationBOW, bowHeader) * wt[0]; - ccRelationAnnotation.getScoreElements().put(SCORE_CTX_IN_HEADER, - ctxScoreHeaderText); - } - - if (scoreCtxColumnText == null) { - bowColumn = createColumnBOW(bowColumn, table, column); - double ctx_column = CollectionUtils.computeFrequencyWeightedDice(relationBOW, bowColumn) * wt[1]; - ccRelationAnnotation.getScoreElements().put(SCORE_CTX_IN_COLUMN, ctx_column); - } - - if (scoreCtxTableContext == null) { - bowOutTableImportantCtx = createImportantOutTableCtxBOW(bowOutTableImportantCtx, table); - double ctx_out_important = CollectionUtils.computeFrequencyWeightedDice(relationBOW, bowOutTableImportantCtx) * wt[2]; - bowOutTableTrivialCtx = createOutTableCtx(bowOutTableTrivialCtx, table); - double ctx_out_trivial = CollectionUtils.computeFrequencyWeightedDice(relationBOW, bowOutTableTrivialCtx) * wt[3]; - ccRelationAnnotation.getScoreElements().put(SCORE_CTX_OUT, - ctx_out_important + ctx_out_trivial); - } - - } - - return new ArrayList<>(candidates); - } - - private Set createRelationBOW(TColumnColumnRelationAnnotation relation, - boolean lowercase, - boolean discard_single_char) { - Set bow = new HashSet<>(); - bow.addAll(bowCreator.create(relation.getRelationURI())); - bow.addAll(StringUtils.toBagOfWords(relation.getRelationLabel(), lowercase, true, discard_single_char)); - bow.removeAll(STIConstantProperty.FUNCTIONAL_STOPWORDS); - return bow; - } - - private Set createHeaderTextBOW(Set bag_of_words_for_header, Table table, int column) { - if (bag_of_words_for_header != null) - return bag_of_words_for_header; - Set bow = new HashSet<>(); - TColumnHeader header = table.getColumnHeader(column); - if (header != null && - header.getHeaderText() != null && - !header.getHeaderText().equals(STIEnum.TABLE_HEADER_UNKNOWN.getValue())) { - bow.addAll(lemmatizer.lemmatize( - StringUtils.toBagOfWords(header.getHeaderText(), true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)) - ); - } - bow.removeAll(STIConstantProperty.FUNCTIONAL_STOPWORDS); - //also remove special, generic words, like "title", "name" - bow.remove("title"); - bow.remove("name"); - return bow; - } - - private List createImportantOutTableCtxBOW( - List bag_of_words_for_table_context, Table table) { - if (bag_of_words_for_table_context != null) - return bag_of_words_for_table_context; - if (table.getContexts() == null) - return new ArrayList<>(); - - List bow = new ArrayList<>(); - for (int i = 0; i < table.getContexts().size(); i++) { - TContext tx = table.getContexts().get(i); - if (tx.getType().equals(TContext.TableContextType.PAGETITLE) || - tx.getType().equals(TContext.TableContextType.CAPTION)) { - bow.addAll(lemmatizer.lemmatize( - StringUtils.toBagOfWords(tx.getText(), true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)) - ); - } - } - bow.removeAll(stopWords); - return bow; - } - - private List createOutTableCtx(List bag_of_words_for_table_context, Table table) { - if (bag_of_words_for_table_context != null) - return bag_of_words_for_table_context; - if (table.getContexts() == null) - return new ArrayList<>(); - - List bow = new ArrayList(); - for (int i = 0; i < table.getContexts().size(); i++) { - TContext tx = table.getContexts().get(i); - if (!tx.getType().equals(TContext.TableContextType.PAGETITLE) && - !tx.getType().equals(TContext.TableContextType.CAPTION)) { - bow.addAll(lemmatizer.lemmatize( - StringUtils.toBagOfWords(tx.getText(), true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)) - ); - } - } - bow.removeAll(stopWords); - return bow; - } - - private List createColumnBOW(List bag_of_words_for_column, Table table, int column) { - if (bag_of_words_for_column != null) - return bag_of_words_for_column; - List bow = new ArrayList<>(); - for (int row = 0; row < table.getNumRows(); row++) { - TCell tcc = table.getContentCell(row, column); - if (tcc.getText() != null) { - bow.addAll(lemmatizer.lemmatize( - StringUtils.toBagOfWords(tcc.getText(), true, true, STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)) - ); - } - } - bow.removeAll(stopWords); - return bow; - } - - - public Map computeFinal(TColumnColumnRelationAnnotation relation, int tableRowsTotal) { - Map scoreElements = relation.getScoreElements(); - Double sumRE = - scoreElements.get(SUM_RE); - if(sumRE==null) sumRE = 0.0; - Double sumCellVote = scoreElements.get(SUM_CELL_VOTE); - if(sumCellVote==null) sumCellVote=0.0; - double scoreRE = sumRE / sumCellVote; - if(sumCellVote==0.0) - scoreRE=0.0; - - scoreElements.put(SCORE_RE, scoreRE); - - scoreElements.put(SUM_RE, sumRE); - - double score_vote = sumCellVote / (double) tableRowsTotal; - scoreElements.put(SCORE_CELL_VOTE, score_vote); - - double base_score = normalize(sumRE, score_vote, - (double) tableRowsTotal); - - for (Map.Entry e : scoreElements.entrySet()) { - if (e.getKey().equals(SUM_RE) || - e.getKey().equals(SUM_CELL_VOTE) || - e.getKey().equals(SCORE_RE) || - e.getKey().equals(SCORE_CELL_VOTE) || - e.getKey().equals(TColumnColumnRelationAnnotation.SCORE_FINAL)) - continue; - - base_score += e.getValue(); - } - scoreElements.put(TColumnHeaderAnnotation.SCORE_FINAL, base_score); - relation.setFinalScore(base_score); - return scoreElements; - } - - private double normalize(double sum_cbr_match, - double sum_cbr_vote, - double total_table_rows) { - if (sum_cbr_vote == 0) - return 0.0; - - return sum_cbr_match / total_table_rows; //this is equivalent to below - - /*double score_cbr_vote = sum_cbr_vote / total_table_rows; - double base_score = score_cbr_vote * (sum_cbr_match / sum_cbr_vote); - return base_score;*/ - } - - public double scoreDC(TColumnColumnRelationAnnotation hbr, List domain_representation) throws STIException { - Set annotation_bow = createRelationBOW(hbr, - true, - STIConstantProperty.BOW_DISCARD_SINGLE_CHAR); - //annotation_bow.removeAll(TableMinerConstants.FUNCTIONAL_STOPWORDS); - double score = CollectionUtils.computeFrequencyWeightedDice(annotation_bow, domain_representation); - score = Math.sqrt(score); - hbr.getScoreElements().put(SCORE_DOMAIN_CONSENSUS, score); - - return score; //To change body of implemented methods use File | Settings | File Templates. - } -} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/FixedNumberOfRows.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/FixedNumberOfRows.java deleted file mode 100644 index 60d2404f..00000000 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/FixedNumberOfRows.java +++ /dev/null @@ -1,25 +0,0 @@ -package uk.ac.shef.dcs.sti.core.algorithm.tmp.stopping; - -import java.util.Map; - -/** - */ -public class FixedNumberOfRows extends StoppingCriteria { - - private int stop_at_row_counter=0; - private int current_iteration; - - public FixedNumberOfRows(int rows){ - stop_at_row_counter=rows; - } - - @Override - public boolean stop(Map state, int max) { - current_iteration++; - - if (current_iteration < stop_at_row_counter) - return false; - - return true; - } -} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/IInf.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/IInf.java deleted file mode 100644 index e750931c..00000000 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/IInf.java +++ /dev/null @@ -1,76 +0,0 @@ -package uk.ac.shef.dcs.sti.core.algorithm.tmp.stopping; - -import org.apache.log4j.Logger; - -import java.util.HashSet; -import java.util.Map; - -/** -MUST BE RE-INSTANTIATED FOR EVERY INTERPRETATION TASK, because class variable "current iteration" and "previous - entropy" does not reset - */ -public class IInf extends StoppingCriteria { - - private double minimum_state_score_sum; - private double previous_iteration_entropy; - private int minimum_iterations; - private int current_iteration; - private double convergence_threshold = 0.01; - - private static final Logger LOG = Logger.getLogger(IInf.class.getName()); - - //minimum # - public IInf(double minimum_state_score_sum, int minimum_iterations, double convergence_threshold) { - this.minimum_state_score_sum = minimum_state_score_sum; - this.minimum_iterations = minimum_iterations; - current_iteration = 0; - this.convergence_threshold = convergence_threshold; - } - - @Override - public boolean stop(Map state, int max) { - current_iteration++; - - //evaluate the state by calculating entropy - double sum = 0.0; - for (Double d : new HashSet<>(state.values())) - sum += d; - double entropy = 0.0; - if (state.size() > 1) { - for (Map.Entry e : state.entrySet()) { - if(e.getValue()==0) - continue; - double p_a = e.getValue() / sum; - double log_p_a = Math.log(p_a); - - entropy = entropy + (0 - p_a * log_p_a); - } - } - //is it converged? - boolean has_converged = false; - - if (previous_iteration_entropy != 0) { - has_converged = Math.abs(entropy - previous_iteration_entropy) < convergence_threshold; - } - previous_iteration_entropy = entropy; - - if (current_iteration < minimum_iterations) - return false; - if (sum < minimum_state_score_sum) - return false; - - if (has_converged){ - LOG.debug("\tConvergence iteration=" + current_iteration + ", potential max=" + max + ", savings=" + ((double) (max - current_iteration) / max)); - /*if(current_iteration>20) - System.out.println();*/ - //previous_iteration_entropy=0.0;//reset - //current_iteration=0; - return true; - } - - if(current_iteration==max) - LOG.debug("\t(negative)Convergence iteration="+current_iteration+", potential max="+max+", savings="+((double)(max-current_iteration)/max)); - - return false; - } -} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/NoStop.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/NoStop.java deleted file mode 100644 index c72c9c64..00000000 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/NoStop.java +++ /dev/null @@ -1,18 +0,0 @@ -package uk.ac.shef.dcs.sti.core.algorithm.tmp.stopping; - -import java.util.Map; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 23/01/14 - * Time: 16:16 - * To change this template use File | Settings | File Templates. - */ -public class NoStop extends StoppingCriteria { - - @Override - public boolean stop(Map state,int max) { - return false; - } -} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/StoppingCriteria.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/StoppingCriteria.java deleted file mode 100644 index b0854671..00000000 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/StoppingCriteria.java +++ /dev/null @@ -1,11 +0,0 @@ -package uk.ac.shef.dcs.sti.core.algorithm.tmp.stopping; - -import java.util.Map; - -/** - */ -public abstract class StoppingCriteria { - - public abstract boolean stop(Map state, int max); - -} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/StoppingCriteriaInstantiator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/StoppingCriteriaInstantiator.java deleted file mode 100644 index 1054cafa..00000000 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/algorithm/tmp/stopping/StoppingCriteriaInstantiator.java +++ /dev/null @@ -1,30 +0,0 @@ -package uk.ac.shef.dcs.sti.core.algorithm.tmp.stopping; - -/** - - */ -public class StoppingCriteriaInstantiator { - - public static StoppingCriteria instantiate(String stopper_class, String[] params) - throws ClassNotFoundException{ - if(stopper_class.equals(IInf.class.getName())){ - return new IInf(Double.valueOf(params[0].trim()), - Integer.valueOf(params[1].trim()), - Double.valueOf(params[2].trim())); - } - - if(stopper_class.equals(NoStop.class.getName())){ - return new NoStop(); - } - /*if(stopper_class.equals(LongtailPatternConfirmation.class.getName())){ - return new LongtailPatternConfirmation(Double.valueOf(params[0]), - Integer.valueOf(params[1])); - }*/ - if(stopper_class.equals(FixedNumberOfRows.class.getName())){ - return new FixedNumberOfRows(Integer.valueOf(params[0].trim())); - } - else{ - throw new ClassNotFoundException("Class:"+stopper_class); - } - } -} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/feature/FreebaseConceptBoWCreator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/feature/FreebaseConceptBoWCreator.java index a877fce2..e20c85ed 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/feature/FreebaseConceptBoWCreator.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/feature/FreebaseConceptBoWCreator.java @@ -1,27 +1,27 @@ -package uk.ac.shef.dcs.sti.core.feature; - -import java.util.ArrayList; -import java.util.List; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 18/02/14 - * Time: 16:42 - * To change this template use File | Settings | File Templates. - */ -public class FreebaseConceptBoWCreator implements OntologyBasedBoWCreator { - @Override - public List create(String uri) { - List bow = new ArrayList<>(); - for(String part: uri.split("/")){ - part=part.trim(); - for(String pp: part.split("_")){ - pp = pp.trim(); - if(pp.length()>0) - bow.add(pp); - } - } - return bow; - } -} +package uk.ac.shef.dcs.sti.core.feature; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created with IntelliJ IDEA. + * User: zqz + * Date: 18/02/14 + * Time: 16:42 + * To change this template use File | Settings | File Templates. + */ +public class FreebaseConceptBoWCreator implements OntologyBasedBoWCreator { + @Override + public List create(String uri) { + List bow = new ArrayList<>(); + for(String part: uri.split("/")){ + part=part.trim(); + for(String pp: part.split("_")){ + pp = pp.trim(); + if(pp.length()>0) + bow.add(pp); + } + } + return bow; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/feature/FreebaseRelationBoWCreator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/feature/FreebaseRelationBoWCreator.java index 558261f8..1efcf572 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/feature/FreebaseRelationBoWCreator.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/feature/FreebaseRelationBoWCreator.java @@ -1,34 +1,34 @@ -package uk.ac.shef.dcs.sti.core.feature; - -import java.util.ArrayList; -import java.util.List; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 27/02/14 - * Time: 12:43 - * To change this template use File | Settings | File Templates. - */ -public class FreebaseRelationBoWCreator implements OntologyBasedBoWCreator { - @Override - public List create(String uri) { - int discardBegin=uri.indexOf("://"); - if(discardBegin!=-1) - uri=uri.substring(discardBegin+4).trim(); - if(!uri.startsWith("/")){ - int discardEnd=uri.indexOf("/"); - uri=uri.substring(discardEnd+1).trim(); - } - List bow = new ArrayList<>(); - for (String part : uri.split("/")) { - part = part.trim(); - for (String pp : part.split("_")) { - pp = pp.trim(); - if (pp.length() > 0) - bow.add(pp); - } - } - return bow; - } -} +package uk.ac.shef.dcs.sti.core.feature; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created with IntelliJ IDEA. + * User: zqz + * Date: 27/02/14 + * Time: 12:43 + * To change this template use File | Settings | File Templates. + */ +public class FreebaseRelationBoWCreator implements OntologyBasedBoWCreator { + @Override + public List create(String uri) { + int discardBegin=uri.indexOf("://"); + if(discardBegin!=-1) + uri=uri.substring(discardBegin+4).trim(); + if(!uri.startsWith("/")){ + int discardEnd=uri.indexOf("/"); + uri=uri.substring(discardEnd+1).trim(); + } + List bow = new ArrayList<>(); + for (String part : uri.split("/")) { + part = part.trim(); + for (String pp : part.split("_")) { + pp = pp.trim(); + if (pp.length() > 0) + bow.add(pp); + } + } + return bow; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/feature/OntologyBasedBoWCreator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/feature/OntologyBasedBoWCreator.java index 23dcbba0..46e8e276 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/feature/OntologyBasedBoWCreator.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/feature/OntologyBasedBoWCreator.java @@ -1,10 +1,10 @@ -package uk.ac.shef.dcs.sti.core.feature; - -import java.util.List; - -/** - */ -public interface OntologyBasedBoWCreator { - - List create(String uri); -} +package uk.ac.shef.dcs.sti.core.feature; + +import java.util.List; + +/** + */ +public interface OntologyBasedBoWCreator { + + List create(String uri); +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/List.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/List.java index 4618d5df..8fb924df 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/List.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/List.java @@ -1,51 +1,51 @@ -package uk.ac.shef.dcs.sti.core.model; - -import java.io.Serializable; -import java.util.ArrayList; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 09/10/12 - * Time: 11:07 - */ -public class List implements Serializable { - private static final long serialVersionUID = -8136725813759687613L; - private String sourceId; - private String listId; - private java.util.List items; - private java.util.List contexts; - - public List(String sourceId, String listId){ - this.sourceId=sourceId; - this.listId=listId; - items=new ArrayList<>(); - contexts=new ArrayList<>(); - } - - public String getSourceId() { - return sourceId; - } - - public String getListId() { - return listId; - } - - public String toString(){ - return getSourceId()+","+getListId(); - } - - public void addItem(ListItem item){ - items.add(item); - } - public java.util.List getItems(){ - return items; - } - - public java.util.List getContexts() { - return contexts; - } - - public void addContext(String ctx) { - this.contexts.add(ctx); - } -} +package uk.ac.shef.dcs.sti.core.model; + +import java.io.Serializable; +import java.util.ArrayList; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 09/10/12 + * Time: 11:07 + */ +public class List implements Serializable { + private static final long serialVersionUID = -8136725813759687613L; + private String sourceId; + private String listId; + private java.util.List items; + private java.util.List contexts; + + public List(String sourceId, String listId){ + this.sourceId=sourceId; + this.listId=listId; + items=new ArrayList<>(); + contexts=new ArrayList<>(); + } + + public String getSourceId() { + return sourceId; + } + + public String getListId() { + return listId; + } + + public String toString(){ + return getSourceId()+","+getListId(); + } + + public void addItem(ListItem item){ + items.add(item); + } + public java.util.List getItems(){ + return items; + } + + public java.util.List getContexts() { + return contexts; + } + + public void addContext(String ctx) { + this.contexts.add(ctx); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/ListItem.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/ListItem.java index 89885ff4..af66dbb2 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/ListItem.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/ListItem.java @@ -1,50 +1,50 @@ -package uk.ac.shef.dcs.sti.core.model; - -import java.io.Serializable; -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 10/10/12 - * Time: 12:25 - */ -public class ListItem implements Serializable { - private static final long serialVersionUID = -8136725546789405913L; - private String text; - private Map valueURIs; - - public ListItem(String text) { - valueURIs = new LinkedHashMap<>(); - this.text = text; - } - - public boolean equals(Object o) { - if (o instanceof ListItem) { - ListItem c = (ListItem) o; - return c.getText().equals(getText()); - } - return false; - } - - public int hashCode() { - return getText().hashCode(); - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - public Map getValuesAndURIs() { - return valueURIs; - } - - public String toString(){ - return text; - } - -} +package uk.ac.shef.dcs.sti.core.model; + +import java.io.Serializable; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 10/10/12 + * Time: 12:25 + */ +public class ListItem implements Serializable { + private static final long serialVersionUID = -8136725546789405913L; + private String text; + private Map valueURIs; + + public ListItem(String text) { + valueURIs = new LinkedHashMap<>(); + this.text = text; + } + + public boolean equals(Object o) { + if (o instanceof ListItem) { + ListItem c = (ListItem) o; + return c.getText().equals(getText()); + } + return false; + } + + public int hashCode() { + return getText().hashCode(); + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public Map getValuesAndURIs() { + return valueURIs; + } + + public String toString(){ + return text; + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/RelationColumns.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/RelationColumns.java index f3ddaf57..fc7a9ff3 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/RelationColumns.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/RelationColumns.java @@ -1,49 +1,49 @@ -package uk.ac.shef.dcs.sti.core.model; - -import java.io.Serializable; - -/** - */ -public class RelationColumns implements Serializable { - private static final long serialVersionUID = -7136525814010415943L; - - private int subjectCol; - private int objectCol; - - public RelationColumns(int subjectCol, int objectCol) { - this.subjectCol=subjectCol; - this.objectCol=objectCol; - } - - public int getSubjectCol() { - return subjectCol; - } - - public void setSubjectCol(int subjectCol) { - this.subjectCol = subjectCol; - } - - public int getObjectCol() { - return objectCol; - } - - public void setObjectCol(int objectCol) { - this.objectCol = objectCol; - } - - public boolean equals(Object o){ - if(o instanceof RelationColumns){ - RelationColumns k = (RelationColumns)o; - return k.getSubjectCol()==getSubjectCol()&& k.getObjectCol()==getObjectCol(); - } - return false; - } - - public int hashCode(){ - return subjectCol*19+objectCol*29; - } - - public String toString(){ - return getSubjectCol()+"-"+getObjectCol(); - } -} +package uk.ac.shef.dcs.sti.core.model; + +import java.io.Serializable; + +/** + */ +public class RelationColumns implements Serializable { + private static final long serialVersionUID = -7136525814010415943L; + + private int subjectCol; + private int objectCol; + + public RelationColumns(int subjectCol, int objectCol) { + this.subjectCol=subjectCol; + this.objectCol=objectCol; + } + + public int getSubjectCol() { + return subjectCol; + } + + public void setSubjectCol(int subjectCol) { + this.subjectCol = subjectCol; + } + + public int getObjectCol() { + return objectCol; + } + + public void setObjectCol(int objectCol) { + this.objectCol = objectCol; + } + + public boolean equals(Object o){ + if(o instanceof RelationColumns){ + RelationColumns k = (RelationColumns)o; + return k.getSubjectCol()==getSubjectCol()&& k.getObjectCol()==getObjectCol(); + } + return false; + } + + public int hashCode(){ + return subjectCol*19+objectCol*29; + } + + public String toString(){ + return getSubjectCol()+"-"+getObjectCol(); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TAnnotation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TAnnotation.java index b08f0b82..284a5fbc 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TAnnotation.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TAnnotation.java @@ -1,243 +1,243 @@ -package uk.ac.shef.dcs.sti.core.model; - -import cern.colt.matrix.ObjectMatrix1D; -import cern.colt.matrix.ObjectMatrix2D; -import cern.colt.matrix.impl.SparseObjectMatrix1D; -import cern.colt.matrix.impl.SparseObjectMatrix2D; -import uk.ac.shef.dcs.sti.STIException; - -import java.util.*; - -/** - */ -public class TAnnotation { - - protected int rows; - protected int cols; - protected int subjectColumn; - protected ObjectMatrix1D headerAnnotations; //each object in the matrix is an array of TColumnHeaderAnnotation - protected ObjectMatrix2D contentAnnotations; //each object in the matrix is an array of TCellAnnotation - protected Map>> - cellcellRelations; //first key being the sub-obj column; second key is the row index - private Map> - columncolumnRelations; - - public TAnnotation(int rows, int cols) { - this.rows = rows; - this.cols = cols; - headerAnnotations = new SparseObjectMatrix1D(cols); - contentAnnotations = new SparseObjectMatrix2D(rows, cols); - cellcellRelations = new HashMap<>(); - columncolumnRelations = new HashMap<>(); - } - - public int getRows() { - return rows; - } - - public int getCols() { - return cols; - } - - public void resetRelationAnnotations() { - cellcellRelations.clear(); - columncolumnRelations.clear(); - } - - public void resetHeaderAnnotations() { - headerAnnotations = new SparseObjectMatrix1D(headerAnnotations.size()); - } - - public void resetCellAnnotations() { - contentAnnotations = new SparseObjectMatrix2D(contentAnnotations.rows(), contentAnnotations.columns()); - } - - /** - * Target and Source must have the same dimension!!! - * - * @param source - * @param target - * @return - */ - public static void copy(TAnnotation source, TAnnotation target) throws STIException { - if (source.getCols() != target.getCols() || source.getRows() != target.rows) - throw new STIException("Source and target table annotation object has different dimensions!"); - - for (int col = 0; col < source.getCols(); col++) { - TColumnHeaderAnnotation[] annotations = source.getHeaderAnnotation(col); - if (annotations == null) - continue; - TColumnHeaderAnnotation[] copy = new TColumnHeaderAnnotation[annotations.length]; - for (int index = 0; index < annotations.length; index++) { - TColumnHeaderAnnotation ann = annotations[index]; - copy[index] = TColumnHeaderAnnotation.copy(ann); - } - target.setHeaderAnnotation(col, copy); - } - - for (int row = 0; row < source.getRows(); row++) { - for (int col = 0; col < source.getCols(); col++) { - TCellAnnotation[] annotations = source.getContentCellAnnotations(row, col); - if (annotations == null) - continue; - TCellAnnotation[] copy = new TCellAnnotation[annotations.length]; - for (int index = 0; index < annotations.length; index++) - copy[index] = TCellAnnotation.copy(annotations[index]); - target.setContentCellAnnotations(row, col, copy); - } - } - target.cellcellRelations = new HashMap<>( - source.getCellcellRelations() - ); - target.columncolumnRelations = new HashMap<>( - source.getColumncolumnRelations() - ); - } - - public void setHeaderAnnotation(int headerCol, TColumnHeaderAnnotation[] annotations) { - Set deduplicateCheck = new HashSet<>(Arrays.asList(annotations)); - assert deduplicateCheck.size() == annotations.length; - //assert System.err.println("duplicate header anntoations " + headerCol + ":" + deduplicateCheck); - - headerAnnotations.set(headerCol, annotations); - } - - public TColumnHeaderAnnotation[] getHeaderAnnotation(int headerCol) { - Object o = headerAnnotations.get(headerCol); - if (o == null) - return new TColumnHeaderAnnotation[0]; - TColumnHeaderAnnotation[] ha = (TColumnHeaderAnnotation[]) o; - Arrays.sort(ha); - - return ha; - } - - public java.util.List getWinningHeaderAnnotations(int headerCol) { - TColumnHeaderAnnotation[] annotations = getHeaderAnnotation(headerCol); - - java.util.List result = new ArrayList<>(); - if (annotations == null || annotations.length == 0) - return result; - double prevScore = 0.0; - for (TColumnHeaderAnnotation h : annotations) { - if (prevScore == 0.0) { - prevScore = h.getFinalScore(); - result.add(h); - continue; - } - if (h.getFinalScore() == prevScore) - result.add(h); - else - break; - } - return result; - } - - public void setContentCellAnnotations(int row, int col, TCellAnnotation[] annotations) { - Set deduplicateCheck = new HashSet<>(Arrays.asList(annotations)); - if (deduplicateCheck.size() != annotations.length) - System.err.println("duplicate cell anntoations " + row + "," + col + ":" + deduplicateCheck); - contentAnnotations.set(row, col, annotations); - } - - public TCellAnnotation[] getContentCellAnnotations(int row, int col) { - Object o = contentAnnotations.get(row, col); - if (o == null) - return new TCellAnnotation[0]; - TCellAnnotation[] ca = (TCellAnnotation[]) o; - Arrays.sort(ca); - return ca; - } - - public java.util.List getWinningContentCellAnnotation(int row, int col) { - TCellAnnotation[] annotations = getContentCellAnnotations(row, col); - - java.util.List result = new ArrayList(); - if (annotations == null || annotations.length == 0) - return result; - double prevScore = 0.0; - for (TCellAnnotation c : annotations) { - if (prevScore == 0.0) { - prevScore = c.getFinalScore(); - result.add(c); - continue; - } - if (c.getFinalScore() == prevScore) - result.add(c); - else - break; - } - return result; - } - - public void addCellCellRelation(TCellCellRelationAnotation toAdd) { - Map> candidates //returns, key: row index; value: list of candidate relations - = cellcellRelations.get(toAdd.getRelationColumns()); - if (candidates == null) - candidates = new HashMap<>(); - //get the list of relations across the two columns already registered on that row - java.util.List candidatesForRow = candidates.get(toAdd.getRow()); - if (candidatesForRow == null) - candidatesForRow = new ArrayList<>(); - - int existingIdentical =candidatesForRow.indexOf(toAdd); - if (existingIdentical!=-1) {//if there is already a cellcellrelation annotation, update its score - double newWinningMatchScore = toAdd.getWinningAttributeMatchScore(); - TCellCellRelationAnotation existing = candidatesForRow.get(existingIdentical); - if (existing.getWinningAttributeMatchScore() < newWinningMatchScore) - existing.setWinningAttributeMatchScore(newWinningMatchScore); - existing.addWinningAttributes(toAdd.getWinningAttributes()); - } else - candidatesForRow.add(toAdd); //container for that row - candidates.put(toAdd.getRow(), candidatesForRow); //container for that column - cellcellRelations.put(toAdd.getRelationColumns(), candidates); - } - - public Map> getRelationAnnotationsBetween(int subjectCol, int objectCol) { - RelationColumns binary_key = new RelationColumns(subjectCol, objectCol); - return cellcellRelations.get(binary_key); - } - - public Map>> getCellcellRelations() { - return cellcellRelations; - } - - public int getSubjectColumn() { - return subjectColumn; - } - - public void setSubjectColumn(int subjectColumn) { - this.subjectColumn = subjectColumn; - } - - public Map> getColumncolumnRelations() { - return columncolumnRelations; - } - - public void addColumnColumnRelation(TColumnColumnRelationAnnotation ra) { - java.util.List annotations_for_columns - = columncolumnRelations.get(ra.getRelationColumns()); - if (annotations_for_columns == null) - annotations_for_columns = new ArrayList<>(); - annotations_for_columns.add(ra); - columncolumnRelations.put(ra.getRelationColumns(), annotations_for_columns); - } - - - public java.util.List getWinningRelationAnnotationsBetween(RelationColumns subobj) { - java.util.List candidates = columncolumnRelations.get(subobj); - Collections.sort(candidates); - - java.util.List result = new ArrayList<>(); - double maxScore = candidates.get(0).getFinalScore(); - for (TColumnColumnRelationAnnotation hbr : candidates) { - if (hbr.getFinalScore() == maxScore) - result.add(hbr); - } - return result; - } - - public void setRows(int rows) { - this.rows = rows; - } -} +package uk.ac.shef.dcs.sti.core.model; + +import cern.colt.matrix.ObjectMatrix1D; +import cern.colt.matrix.ObjectMatrix2D; +import cern.colt.matrix.impl.SparseObjectMatrix1D; +import cern.colt.matrix.impl.SparseObjectMatrix2D; +import uk.ac.shef.dcs.sti.STIException; + +import java.util.*; + +/** + */ +public class TAnnotation { + + protected int rows; + protected int cols; + protected int subjectColumn; + protected ObjectMatrix1D headerAnnotations; //each object in the matrix is an array of TColumnHeaderAnnotation + protected ObjectMatrix2D contentAnnotations; //each object in the matrix is an array of TCellAnnotation + protected Map>> + cellcellRelations; //first key being the sub-obj column; second key is the row index + private Map> + columncolumnRelations; + + public TAnnotation(int rows, int cols) { + this.rows = rows; + this.cols = cols; + headerAnnotations = new SparseObjectMatrix1D(cols); + contentAnnotations = new SparseObjectMatrix2D(rows, cols); + cellcellRelations = new HashMap<>(); + columncolumnRelations = new HashMap<>(); + } + + public int getRows() { + return rows; + } + + public int getCols() { + return cols; + } + + public void resetRelationAnnotations() { + cellcellRelations.clear(); + columncolumnRelations.clear(); + } + + public void resetHeaderAnnotations() { + headerAnnotations = new SparseObjectMatrix1D(headerAnnotations.size()); + } + + public void resetCellAnnotations() { + contentAnnotations = new SparseObjectMatrix2D(contentAnnotations.rows(), contentAnnotations.columns()); + } + + /** + * Target and Source must have the same dimension!!! + * + * @param source + * @param target + * @return + */ + public static void copy(TAnnotation source, TAnnotation target) throws STIException { + if (source.getCols() != target.getCols() || source.getRows() != target.rows) + throw new STIException("Source and target table annotation object has different dimensions!"); + + for (int col = 0; col < source.getCols(); col++) { + TColumnHeaderAnnotation[] annotations = source.getHeaderAnnotation(col); + if (annotations == null) + continue; + TColumnHeaderAnnotation[] copy = new TColumnHeaderAnnotation[annotations.length]; + for (int index = 0; index < annotations.length; index++) { + TColumnHeaderAnnotation ann = annotations[index]; + copy[index] = TColumnHeaderAnnotation.copy(ann); + } + target.setHeaderAnnotation(col, copy); + } + + for (int row = 0; row < source.getRows(); row++) { + for (int col = 0; col < source.getCols(); col++) { + TCellAnnotation[] annotations = source.getContentCellAnnotations(row, col); + if (annotations == null) + continue; + TCellAnnotation[] copy = new TCellAnnotation[annotations.length]; + for (int index = 0; index < annotations.length; index++) + copy[index] = TCellAnnotation.copy(annotations[index]); + target.setContentCellAnnotations(row, col, copy); + } + } + target.cellcellRelations = new HashMap<>( + source.getCellcellRelations() + ); + target.columncolumnRelations = new HashMap<>( + source.getColumncolumnRelations() + ); + } + + public void setHeaderAnnotation(int headerCol, TColumnHeaderAnnotation[] annotations) { + Set deduplicateCheck = new HashSet<>(Arrays.asList(annotations)); + assert deduplicateCheck.size() == annotations.length; + //assert System.err.println("duplicate header anntoations " + headerCol + ":" + deduplicateCheck); + + headerAnnotations.set(headerCol, annotations); + } + + public TColumnHeaderAnnotation[] getHeaderAnnotation(int headerCol) { + Object o = headerAnnotations.get(headerCol); + if (o == null) + return new TColumnHeaderAnnotation[0]; + TColumnHeaderAnnotation[] ha = (TColumnHeaderAnnotation[]) o; + Arrays.sort(ha); + + return ha; + } + + public java.util.List getWinningHeaderAnnotations(int headerCol) { + TColumnHeaderAnnotation[] annotations = getHeaderAnnotation(headerCol); + + java.util.List result = new ArrayList<>(); + if (annotations == null || annotations.length == 0) + return result; + double prevScore = 0.0; + for (TColumnHeaderAnnotation h : annotations) { + if (prevScore == 0.0) { + prevScore = h.getFinalScore(); + result.add(h); + continue; + } + if (h.getFinalScore() == prevScore) + result.add(h); + else + break; + } + return result; + } + + public void setContentCellAnnotations(int row, int col, TCellAnnotation[] annotations) { + Set deduplicateCheck = new HashSet<>(Arrays.asList(annotations)); + if (deduplicateCheck.size() != annotations.length) + System.err.println("duplicate cell anntoations " + row + "," + col + ":" + deduplicateCheck); + contentAnnotations.set(row, col, annotations); + } + + public TCellAnnotation[] getContentCellAnnotations(int row, int col) { + Object o = contentAnnotations.get(row, col); + if (o == null) + return new TCellAnnotation[0]; + TCellAnnotation[] ca = (TCellAnnotation[]) o; + Arrays.sort(ca); + return ca; + } + + public java.util.List getWinningContentCellAnnotation(int row, int col) { + TCellAnnotation[] annotations = getContentCellAnnotations(row, col); + + java.util.List result = new ArrayList(); + if (annotations == null || annotations.length == 0) + return result; + double prevScore = 0.0; + for (TCellAnnotation c : annotations) { + if (prevScore == 0.0) { + prevScore = c.getFinalScore(); + result.add(c); + continue; + } + if (c.getFinalScore() == prevScore) + result.add(c); + else + break; + } + return result; + } + + public void addCellCellRelation(TCellCellRelationAnotation toAdd) { + Map> candidates //returns, key: row index; value: list of candidate relations + = cellcellRelations.get(toAdd.getRelationColumns()); + if (candidates == null) + candidates = new HashMap<>(); + //get the list of relations across the two columns already registered on that row + java.util.List candidatesForRow = candidates.get(toAdd.getRow()); + if (candidatesForRow == null) + candidatesForRow = new ArrayList<>(); + + int existingIdentical =candidatesForRow.indexOf(toAdd); + if (existingIdentical!=-1) {//if there is already a cellcellrelation annotation, update its score + double newWinningMatchScore = toAdd.getWinningAttributeMatchScore(); + TCellCellRelationAnotation existing = candidatesForRow.get(existingIdentical); + if (existing.getWinningAttributeMatchScore() < newWinningMatchScore) + existing.setWinningAttributeMatchScore(newWinningMatchScore); + existing.addWinningAttributes(toAdd.getWinningAttributes()); + } else + candidatesForRow.add(toAdd); //container for that row + candidates.put(toAdd.getRow(), candidatesForRow); //container for that column + cellcellRelations.put(toAdd.getRelationColumns(), candidates); + } + + public Map> getRelationAnnotationsBetween(int subjectCol, int objectCol) { + RelationColumns binary_key = new RelationColumns(subjectCol, objectCol); + return cellcellRelations.get(binary_key); + } + + public Map>> getCellcellRelations() { + return cellcellRelations; + } + + public int getSubjectColumn() { + return subjectColumn; + } + + public void setSubjectColumn(int subjectColumn) { + this.subjectColumn = subjectColumn; + } + + public Map> getColumncolumnRelations() { + return columncolumnRelations; + } + + public void addColumnColumnRelation(TColumnColumnRelationAnnotation ra) { + java.util.List annotations_for_columns + = columncolumnRelations.get(ra.getRelationColumns()); + if (annotations_for_columns == null) + annotations_for_columns = new ArrayList<>(); + annotations_for_columns.add(ra); + columncolumnRelations.put(ra.getRelationColumns(), annotations_for_columns); + } + + + public java.util.List getWinningRelationAnnotationsBetween(RelationColumns subobj) { + java.util.List candidates = columncolumnRelations.get(subobj); + Collections.sort(candidates); + + java.util.List result = new ArrayList<>(); + double maxScore = candidates.get(0).getFinalScore(); + for (TColumnColumnRelationAnnotation hbr : candidates) { + if (hbr.getFinalScore() == maxScore) + result.add(hbr); + } + return result; + } + + public void setRows(int rows) { + this.rows = rows; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TCell.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TCell.java index 2e48a540..d9b7afe7 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TCell.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TCell.java @@ -1,63 +1,63 @@ -package uk.ac.shef.dcs.sti.core.model; - -import uk.ac.shef.dcs.sti.util.DataTypeClassifier; - -import java.io.Serializable; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 01/10/12 - * Time: 15:46 - */ -public class TCell implements Serializable { - - private static final long serialVersionUID = -8136725814000405913L; - - private String text; //the raw text found in the table cell - private String otherText; - private String xPath; //xpath that extracts this value - private DataTypeClassifier.DataType type; - - public TCell(String text){ - this.text=text; - this.type=DataTypeClassifier.DataType.UNKNOWN; - otherText =""; - } - - - public String toString(){ - return "("+getText()+") "+ getType(); - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - public String getxPath() { - return xPath; - } - - public void setxPath(String xPath) { - this.xPath = xPath; - } - - public DataTypeClassifier.DataType getType() { - return type; - } - - public void setType(DataTypeClassifier.DataType type) { - this.type = type; - } - - public String getOtherText() { - return otherText; - } - - public void setOtherText(String otherText) { - this.otherText = otherText; - } -} +package uk.ac.shef.dcs.sti.core.model; + +import uk.ac.shef.dcs.sti.util.DataTypeClassifier; + +import java.io.Serializable; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 01/10/12 + * Time: 15:46 + */ +public class TCell implements Serializable { + + private static final long serialVersionUID = -8136725814000405913L; + + private String text; //the raw text found in the table cell + private String otherText; + private String xPath; //xpath that extracts this value + private DataTypeClassifier.DataType type; + + public TCell(String text){ + this.text=text; + this.type=DataTypeClassifier.DataType.UNKNOWN; + otherText =""; + } + + + public String toString(){ + return "("+getText()+") "+ getType(); + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public String getxPath() { + return xPath; + } + + public void setxPath(String xPath) { + this.xPath = xPath; + } + + public DataTypeClassifier.DataType getType() { + return type; + } + + public void setType(DataTypeClassifier.DataType type) { + this.type = type; + } + + public String getOtherText() { + return otherText; + } + + public void setOtherText(String otherText) { + this.otherText = otherText; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TCellAnnotation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TCellAnnotation.java index 6d4dcac7..dc474a48 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TCellAnnotation.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TCellAnnotation.java @@ -1,85 +1,85 @@ -package uk.ac.shef.dcs.sti.core.model; - -import uk.ac.shef.dcs.kbsearch.model.Entity; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -/** - Annotation for an entity or a concept - */ -public class TCellAnnotation implements Serializable, Comparable{ - - private static final long serialVersionUID = -8136725814000843856L; - - public static final String SCORE_FINAL="final"; - - private String term; - private Entity annotation; - private Map score_element_map; - private double finalScore; - - public TCellAnnotation(String term, Entity annotation, double score, Map score_elements){ - this.term=term; - this.annotation=annotation; - this.finalScore =score; - this.score_element_map=score_elements; - } - - public static TCellAnnotation copy(TCellAnnotation ca){ - TCellAnnotation newCa = new TCellAnnotation(ca.getTerm(), - ca.getAnnotation(), - ca.getFinalScore(), - new HashMap<>(ca.getScoreElements())); - return newCa; - } - - public String getTerm() { - return term; - } - - public void setTerm(String term) { - this.term = term; - } - - public Entity getAnnotation() { - return annotation; - } - - public void setAnnotation(Entity annotation) { - this.annotation = annotation; - } - - public double getFinalScore() { - return finalScore; - } - - public void setFinalScore(double score) { - this.finalScore = score; - } - - public String toString(){ - return getTerm()+","+getAnnotation(); - } - - @Override - public int compareTo(TCellAnnotation o) { - - return new Double(o.getFinalScore()).compareTo(getFinalScore()); - - } - - public Map getScoreElements() { - return score_element_map; - } - - - public boolean equals(Object o){ - if(o instanceof TCellAnnotation){ - TCellAnnotation ca = (TCellAnnotation) o; - return ca.getAnnotation().equals(getAnnotation()) && ca.getTerm().equals(getTerm()); - } - return false; - } -} +package uk.ac.shef.dcs.sti.core.model; + +import uk.ac.shef.dcs.kbsearch.model.Entity; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +/** + Annotation for an entity or a concept + */ +public class TCellAnnotation implements Serializable, Comparable{ + + private static final long serialVersionUID = -8136725814000843856L; + + public static final String SCORE_FINAL="final"; + + private String term; + private Entity annotation; + private Map score_element_map; + private double finalScore; + + public TCellAnnotation(String term, Entity annotation, double score, Map score_elements){ + this.term=term; + this.annotation=annotation; + this.finalScore =score; + this.score_element_map=score_elements; + } + + public static TCellAnnotation copy(TCellAnnotation ca){ + TCellAnnotation newCa = new TCellAnnotation(ca.getTerm(), + ca.getAnnotation(), + ca.getFinalScore(), + new HashMap<>(ca.getScoreElements())); + return newCa; + } + + public String getTerm() { + return term; + } + + public void setTerm(String term) { + this.term = term; + } + + public Entity getAnnotation() { + return annotation; + } + + public void setAnnotation(Entity annotation) { + this.annotation = annotation; + } + + public double getFinalScore() { + return finalScore; + } + + public void setFinalScore(double score) { + this.finalScore = score; + } + + public String toString(){ + return getTerm()+","+getAnnotation(); + } + + @Override + public int compareTo(TCellAnnotation o) { + + return new Double(o.getFinalScore()).compareTo(getFinalScore()); + + } + + public Map getScoreElements() { + return score_element_map; + } + + + public boolean equals(Object o){ + if(o instanceof TCellAnnotation){ + TCellAnnotation ca = (TCellAnnotation) o; + return ca.getAnnotation().equals(getAnnotation()) && ca.getTerm().equals(getTerm()); + } + return false; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TCellCellRelationAnotation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TCellCellRelationAnotation.java index fc1d8f79..a58a583c 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TCellCellRelationAnotation.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TCellCellRelationAnotation.java @@ -1,113 +1,113 @@ -package uk.ac.shef.dcs.sti.core.model; - -import uk.ac.shef.dcs.kbsearch.model.Attribute; - -import java.io.Serializable; -import java.util.List; - -/** - * annotates relation between two cells on the same row. Annotations on multi rows must be aggregated to derive an annotation for - * two columns - */ -public class TCellCellRelationAnotation implements Serializable, Comparable { - - private static final long serialVersionUID = -1208912234750474692L; - private RelationColumns relationColumns; - private int row; - - private String relationURI; - private String relationLabel; - - private List winningAttributes; //multiple winner possible - private double winningAttributeMatchScore; - - //matched_value[]: (0)=property name (1)=the attribute value matched with the objecCol field on this row; (2) id/uri, if any (used for later knowledge base retrieval) - public TCellCellRelationAnotation(RelationColumns key, - int row, - String relation_annotation, - String relation_label, - List winningAttributes, double winningAttributeMatchScore){ - this.relationColumns =key; - this.row=row; - this.relationURI = relation_annotation; - this.relationLabel =relation_label; - this.winningAttributeMatchScore = winningAttributeMatchScore; - this.winningAttributes = winningAttributes; - } - - public double getWinningAttributeMatchScore(){ - return winningAttributeMatchScore; - } - public void setWinningAttributeMatchScore(double winningAttributeMatchScore){ - this.winningAttributeMatchScore = winningAttributeMatchScore; - } - - - - public int getRow(){ - return row; - } - - public String getRelationURI(){ - return relationURI; - } - - public boolean equals(Object o){ - if(o instanceof TCellCellRelationAnotation){ - TCellCellRelationAnotation that = (TCellCellRelationAnotation) o; - return that.getRelationColumns().equals(getRelationColumns()) - &&that.getRow()==getRow() - &&that.getRelationURI().equals(getRelationURI()); - } - return false; - } - - public int hashCode(){ - return getRelationColumns().hashCode()+19*getRow()+29* getRelationURI().hashCode(); - } - - @Override - public int compareTo(TCellCellRelationAnotation o) { - int compared = new Integer(o.getRow()).compareTo(getRow()); - - if(compared==0) - return new Double(o.getWinningAttributeMatchScore()).compareTo(getWinningAttributeMatchScore()); - - return compared; - } - - public RelationColumns getRelationColumns() { - return relationColumns; - } - - public void setRelationColumns(RelationColumns relationColumns) { - this.relationColumns = relationColumns; - } - - public List getWinningAttributes() { - return winningAttributes; - } - - public void setWinningAttributes(List winningAttributes) { - this.winningAttributes = winningAttributes; - } - - public void addWinningAttributes(List toAdd){ - for(Attribute vta: toAdd){ - if(!winningAttributes.contains(vta)) - winningAttributes.add(vta); - } - } - - public String toString(){ - return relationURI; - } - - public String getRelationLabel() { - return relationLabel; - } - - public void setRelationLabel(String relationLabel) { - this.relationLabel = relationLabel; - } -} +package uk.ac.shef.dcs.sti.core.model; + +import uk.ac.shef.dcs.kbsearch.model.Attribute; + +import java.io.Serializable; +import java.util.List; + +/** + * annotates relation between two cells on the same row. Annotations on multi rows must be aggregated to derive an annotation for + * two columns + */ +public class TCellCellRelationAnotation implements Serializable, Comparable { + + private static final long serialVersionUID = -1208912234750474692L; + private RelationColumns relationColumns; + private int row; + + private String relationURI; + private String relationLabel; + + private List winningAttributes; //multiple winner possible + private double winningAttributeMatchScore; + + //matched_value[]: (0)=property name (1)=the attribute value matched with the objecCol field on this row; (2) id/uri, if any (used for later knowledge base retrieval) + public TCellCellRelationAnotation(RelationColumns key, + int row, + String relation_annotation, + String relation_label, + List winningAttributes, double winningAttributeMatchScore){ + this.relationColumns =key; + this.row=row; + this.relationURI = relation_annotation; + this.relationLabel =relation_label; + this.winningAttributeMatchScore = winningAttributeMatchScore; + this.winningAttributes = winningAttributes; + } + + public double getWinningAttributeMatchScore(){ + return winningAttributeMatchScore; + } + public void setWinningAttributeMatchScore(double winningAttributeMatchScore){ + this.winningAttributeMatchScore = winningAttributeMatchScore; + } + + + + public int getRow(){ + return row; + } + + public String getRelationURI(){ + return relationURI; + } + + public boolean equals(Object o){ + if(o instanceof TCellCellRelationAnotation){ + TCellCellRelationAnotation that = (TCellCellRelationAnotation) o; + return that.getRelationColumns().equals(getRelationColumns()) + &&that.getRow()==getRow() + &&that.getRelationURI().equals(getRelationURI()); + } + return false; + } + + public int hashCode(){ + return getRelationColumns().hashCode()+19*getRow()+29* getRelationURI().hashCode(); + } + + @Override + public int compareTo(TCellCellRelationAnotation o) { + int compared = new Integer(o.getRow()).compareTo(getRow()); + + if(compared==0) + return new Double(o.getWinningAttributeMatchScore()).compareTo(getWinningAttributeMatchScore()); + + return compared; + } + + public RelationColumns getRelationColumns() { + return relationColumns; + } + + public void setRelationColumns(RelationColumns relationColumns) { + this.relationColumns = relationColumns; + } + + public List getWinningAttributes() { + return winningAttributes; + } + + public void setWinningAttributes(List winningAttributes) { + this.winningAttributes = winningAttributes; + } + + public void addWinningAttributes(List toAdd){ + for(Attribute vta: toAdd){ + if(!winningAttributes.contains(vta)) + winningAttributes.add(vta); + } + } + + public String toString(){ + return relationURI; + } + + public String getRelationLabel() { + return relationLabel; + } + + public void setRelationLabel(String relationLabel) { + this.relationLabel = relationLabel; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnColumnRelationAnnotation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnColumnRelationAnnotation.java index 9739f8d6..a5ab346d 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnColumnRelationAnnotation.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnColumnRelationAnnotation.java @@ -1,117 +1,117 @@ -package uk.ac.shef.dcs.sti.core.model; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - */ -public class TColumnColumnRelationAnnotation implements Serializable, Comparable { - - private static final long serialVersionUID = -1208912663212074692L; - private RelationColumns relationColumns; - private List supportingRows; - - private String relationURI; - private String relationLabel; - - public static final String SCORE_FINAL ="final"; - - private double finalScore; - private Map scoreElements; - - - //matched_value[]: (0)=property name (1)=the attribute value matched with the objecCol field on this row; (2) id/uri, if any (used for later knowledge base retrieval) - public TColumnColumnRelationAnnotation(RelationColumns key, String relationURI, String relation_label, double score) { - this.relationColumns = key; - this.relationLabel =relation_label; - this.relationURI = relationURI; - this.finalScore = score; - this.scoreElements=new HashMap<>(); - scoreElements=new HashMap<>(); - if(score!=0) - scoreElements.put(SCORE_FINAL, score); - else - scoreElements.put(SCORE_FINAL, 0.0); - this.supportingRows = new ArrayList<>(); - } - - public double getFinalScore() { - return finalScore; - } - - public void setFinalScore(double finalScore) { - this.finalScore = finalScore; - } - - public String getRelationURI() { - return relationURI; - } - - - @Override - public int compareTo(TColumnColumnRelationAnnotation o) { - int compared = new Double(o.getFinalScore()).compareTo(getFinalScore()); - - if (compared == 0) - return new Integer(o.getSupportingRows().size()).compareTo(getSupportingRows().size()); - - return compared; - } - - public RelationColumns getRelationColumns() { - return relationColumns; - } - - public void setRelationColumns(RelationColumns relationColumns) { - this.relationColumns = relationColumns; - } - - - public String toString() { - return relationURI; - } - - public String toStringExpanded(){ - return "("+ getRelationColumns()+")"+ relationURI; - } - public static String toStringExpanded(int fromCol, int toCol, String relationURL){ - return "("+fromCol+"-"+toCol+")"+relationURL; - } - - public List getSupportingRows() { - return supportingRows; - } - - public void addSupportingRow(int row) { - if (!supportingRows.contains(row)) - supportingRows.add(row); - } - - public Map getScoreElements() { - return scoreElements; - } - - public void setScoreElements(Map scoreElements) { - this.scoreElements = scoreElements; - } - - public String getRelationLabel() { - return relationLabel; - } - - public void setRelationLabel(String relationLabel) { - this.relationLabel = relationLabel; - } - - public boolean equals(Object o){ - if(o instanceof TColumnColumnRelationAnnotation){ - TColumnColumnRelationAnnotation hbr = (TColumnColumnRelationAnnotation) o; - return hbr.getRelationColumns().equals(getRelationColumns()) && - hbr.getRelationURI().equals(getRelationURI()); - } - return false; - } -} +package uk.ac.shef.dcs.sti.core.model; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + */ +public class TColumnColumnRelationAnnotation implements Serializable, Comparable { + + private static final long serialVersionUID = -1208912663212074692L; + private RelationColumns relationColumns; + private List supportingRows; + + private String relationURI; + private String relationLabel; + + public static final String SCORE_FINAL ="final"; + + private double finalScore; + private Map scoreElements; + + + //matched_value[]: (0)=property name (1)=the attribute value matched with the objecCol field on this row; (2) id/uri, if any (used for later knowledge base retrieval) + public TColumnColumnRelationAnnotation(RelationColumns key, String relationURI, String relation_label, double score) { + this.relationColumns = key; + this.relationLabel =relation_label; + this.relationURI = relationURI; + this.finalScore = score; + this.scoreElements=new HashMap<>(); + scoreElements=new HashMap<>(); + if(score!=0) + scoreElements.put(SCORE_FINAL, score); + else + scoreElements.put(SCORE_FINAL, 0.0); + this.supportingRows = new ArrayList<>(); + } + + public double getFinalScore() { + return finalScore; + } + + public void setFinalScore(double finalScore) { + this.finalScore = finalScore; + } + + public String getRelationURI() { + return relationURI; + } + + + @Override + public int compareTo(TColumnColumnRelationAnnotation o) { + int compared = new Double(o.getFinalScore()).compareTo(getFinalScore()); + + if (compared == 0) + return new Integer(o.getSupportingRows().size()).compareTo(getSupportingRows().size()); + + return compared; + } + + public RelationColumns getRelationColumns() { + return relationColumns; + } + + public void setRelationColumns(RelationColumns relationColumns) { + this.relationColumns = relationColumns; + } + + + public String toString() { + return relationURI; + } + + public String toStringExpanded(){ + return "("+ getRelationColumns()+")"+ relationURI; + } + public static String toStringExpanded(int fromCol, int toCol, String relationURL){ + return "("+fromCol+"-"+toCol+")"+relationURL; + } + + public List getSupportingRows() { + return supportingRows; + } + + public void addSupportingRow(int row) { + if (!supportingRows.contains(row)) + supportingRows.add(row); + } + + public Map getScoreElements() { + return scoreElements; + } + + public void setScoreElements(Map scoreElements) { + this.scoreElements = scoreElements; + } + + public String getRelationLabel() { + return relationLabel; + } + + public void setRelationLabel(String relationLabel) { + this.relationLabel = relationLabel; + } + + public boolean equals(Object o){ + if(o instanceof TColumnColumnRelationAnnotation){ + TColumnColumnRelationAnnotation hbr = (TColumnColumnRelationAnnotation) o; + return hbr.getRelationColumns().equals(getRelationColumns()) && + hbr.getRelationURI().equals(getRelationURI()); + } + return false; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeader.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeader.java index 03ca70c6..0e60d62a 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeader.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeader.java @@ -1,57 +1,57 @@ -package uk.ac.shef.dcs.sti.core.model; - -import uk.ac.shef.dcs.sti.core.subjectcol.TColumnDataType; -import uk.ac.shef.dcs.sti.core.subjectcol.TColumnFeature; - -import java.io.Serializable; -import java.util.List; - -/** - */ -public class TColumnHeader implements Serializable - -{ - - private static final long serialVersionUID = -1638925814000405913L; - - private String headerText; //the raw text found in the table cell - private String xPath; //xpath that extracts this value - private List type; - private TColumnFeature feature; - - public TColumnHeader(String text){ - this.headerText=text; - } - - public String getHeaderText() { - return headerText; - } - - public void setHeaderText(String text) { - this.headerText = text; - } - - public String getHeaderXPath() { - return xPath; - } - - public void setHeaderXPath(String xPath) { - this.xPath = xPath; - } - - public List getTypes() { - return type; - } - - public void setType(List type) { - this.type = type; - } - - public TColumnFeature getFeature() { - return feature; - } - - public void setFeature(TColumnFeature feature) { - this.feature = feature; - } -} +package uk.ac.shef.dcs.sti.core.model; + +import uk.ac.shef.dcs.sti.core.subjectcol.TColumnDataType; +import uk.ac.shef.dcs.sti.core.subjectcol.TColumnFeature; + +import java.io.Serializable; +import java.util.List; + +/** + */ +public class TColumnHeader implements Serializable + +{ + + private static final long serialVersionUID = -1638925814000405913L; + + private String headerText; //the raw text found in the table cell + private String xPath; //xpath that extracts this value + private List type; + private TColumnFeature feature; + + public TColumnHeader(String text){ + this.headerText=text; + } + + public String getHeaderText() { + return headerText; + } + + public void setHeaderText(String text) { + this.headerText = text; + } + + public String getHeaderXPath() { + return xPath; + } + + public void setHeaderXPath(String xPath) { + this.xPath = xPath; + } + + public List getTypes() { + return type; + } + + public void setType(List type) { + this.type = type; + } + + public TColumnFeature getFeature() { + return feature; + } + + public void setFeature(TColumnFeature feature) { + this.feature = feature; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeaderAnnotation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeaderAnnotation.java index 17b54ca3..f1c9aeb1 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeaderAnnotation.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TColumnHeaderAnnotation.java @@ -1,112 +1,112 @@ -package uk.ac.shef.dcs.sti.core.model; - -import uk.ac.shef.dcs.kbsearch.model.Clazz; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 24/01/14 - * Time: 14:48 - * To change this template use File | Settings | File Templates. - */ -public class TColumnHeaderAnnotation implements Serializable,Comparable { - private static final long serialVersionUID = -6208426814708405913L; - - public static final String SCORE_FINAL ="final"; - - private String headerText; - private Clazz annotation; - private double finalScore; - private Map scoreElements; - private List supportingRows; - - - public TColumnHeaderAnnotation(String headerText, Clazz annotation, double finalScore) { - this.headerText = headerText; - this.annotation=annotation; - this.finalScore = finalScore; - supportingRows = new ArrayList<>(); - scoreElements=new HashMap<>(); - if(finalScore>0) - scoreElements.put(SCORE_FINAL, finalScore); - else - scoreElements.put(SCORE_FINAL, 0.0); - } - - public static TColumnHeaderAnnotation copy(TColumnHeaderAnnotation ha) { - TColumnHeaderAnnotation newHa = - new TColumnHeaderAnnotation(ha.getHeaderText(), ha.getAnnotation(), ha.getFinalScore()); - for (int i : ha.getSupportingRows()) - newHa.addSupportingRow(i); - newHa.setScoreElements(new HashMap<>(ha.getScoreElements())); - return newHa; - } - - public String getHeaderText() { - return headerText; - } - - public void setHeaderText(String headerText) { - this.headerText = headerText; - } - - public double getFinalScore() { - return finalScore; - } - - public void setFinalScore(double finalScore) { - this.finalScore = finalScore; - } - - public List getSupportingRows() { - return supportingRows; - } - - public void addSupportingRow(int rowId) { - if(!supportingRows.contains(rowId)) - supportingRows.add(rowId); - } - - public boolean equals(Object o) { - if (o instanceof TColumnHeaderAnnotation) { - TColumnHeaderAnnotation ha = (TColumnHeaderAnnotation) o; - return ha.getHeaderText().equals(getHeaderText()) && ha.getAnnotation().equals(getAnnotation()); - } - return false; - } - - public int hashCode() { - return getHeaderText().hashCode() + 19 * getAnnotation().getId().hashCode(); - } - - public String toString() { - return headerText + "," + getAnnotation(); - } - - @Override - public int compareTo(TColumnHeaderAnnotation o) { - int compared = ((Double) o.getFinalScore()).compareTo(getFinalScore()); - if (compared == 0) - return new Integer(o.getSupportingRows().size()).compareTo(getSupportingRows().size()); - - return compared; - } - - public Map getScoreElements() { - return scoreElements; - } - - public void setScoreElements(Map scoreElements) { - this.scoreElements = scoreElements; - } - - public Clazz getAnnotation() { - return annotation; - } -} +package uk.ac.shef.dcs.sti.core.model; + +import uk.ac.shef.dcs.kbsearch.model.Clazz; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Created with IntelliJ IDEA. + * User: zqz + * Date: 24/01/14 + * Time: 14:48 + * To change this template use File | Settings | File Templates. + */ +public class TColumnHeaderAnnotation implements Serializable,Comparable { + private static final long serialVersionUID = -6208426814708405913L; + + public static final String SCORE_FINAL ="final"; + + private String headerText; + private Clazz annotation; + private double finalScore; + private Map scoreElements; + private List supportingRows; + + + public TColumnHeaderAnnotation(String headerText, Clazz annotation, double finalScore) { + this.headerText = headerText; + this.annotation=annotation; + this.finalScore = finalScore; + supportingRows = new ArrayList<>(); + scoreElements=new HashMap<>(); + if(finalScore>0) + scoreElements.put(SCORE_FINAL, finalScore); + else + scoreElements.put(SCORE_FINAL, 0.0); + } + + public static TColumnHeaderAnnotation copy(TColumnHeaderAnnotation ha) { + TColumnHeaderAnnotation newHa = + new TColumnHeaderAnnotation(ha.getHeaderText(), ha.getAnnotation(), ha.getFinalScore()); + for (int i : ha.getSupportingRows()) + newHa.addSupportingRow(i); + newHa.setScoreElements(new HashMap<>(ha.getScoreElements())); + return newHa; + } + + public String getHeaderText() { + return headerText; + } + + public void setHeaderText(String headerText) { + this.headerText = headerText; + } + + public double getFinalScore() { + return finalScore; + } + + public void setFinalScore(double finalScore) { + this.finalScore = finalScore; + } + + public List getSupportingRows() { + return supportingRows; + } + + public void addSupportingRow(int rowId) { + if(!supportingRows.contains(rowId)) + supportingRows.add(rowId); + } + + public boolean equals(Object o) { + if (o instanceof TColumnHeaderAnnotation) { + TColumnHeaderAnnotation ha = (TColumnHeaderAnnotation) o; + return ha.getHeaderText().equals(getHeaderText()) && ha.getAnnotation().equals(getAnnotation()); + } + return false; + } + + public int hashCode() { + return getHeaderText().hashCode() + 19 * getAnnotation().getId().hashCode(); + } + + public String toString() { + return headerText + "," + getAnnotation(); + } + + @Override + public int compareTo(TColumnHeaderAnnotation o) { + int compared = ((Double) o.getFinalScore()).compareTo(getFinalScore()); + if (compared == 0) + return new Integer(o.getSupportingRows().size()).compareTo(getSupportingRows().size()); + + return compared; + } + + public Map getScoreElements() { + return scoreElements; + } + + public void setScoreElements(Map scoreElements) { + this.scoreElements = scoreElements; + } + + public Clazz getAnnotation() { + return annotation; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TContext.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TContext.java index aab4c22b..3ca483c2 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TContext.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TContext.java @@ -1,72 +1,72 @@ -package uk.ac.shef.dcs.sti.core.model; - -import java.io.Serializable; - -/** - * An TContext could be any textual content around an Table object. - */ -public class TContext implements Serializable, Comparable{ - private static final long serialVersionUID = -8136777654860405913L; - - private String text; - private double rankScore; //how relevant is this context to the table - private TableContextType type; - - - public TContext(String text, TableContextType type, double score){ - this.text=text; - this.rankScore=score; - this.type=type; - } - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - public double getImportanceScore() { - return rankScore; - } - - public void setRankScore(double rankScore) { - this.rankScore = rankScore; - } - - @Override - public int compareTo(TContext o) { - return new Double(getImportanceScore()).compareTo(o.getImportanceScore()); - } - - public TableContextType getType() { - return type; - } - - public void setType(TableContextType type) { - this.type = type; - } - - public enum TableContextType implements Serializable{ - - CAPTION("Caption"), - PAGETITLE("PageTitle"),//title of the page containing the table - PARAGRAPH_BEFORE("Before"),//context occuring before table - PARAGRAPH_AFTER("After"); //context occurring after table - - - private String type; - - TableContextType(String type) { - this.type = type; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - } -} +package uk.ac.shef.dcs.sti.core.model; + +import java.io.Serializable; + +/** + * An TContext could be any textual content around an Table object. + */ +public class TContext implements Serializable, Comparable{ + private static final long serialVersionUID = -8136777654860405913L; + + private String text; + private double rankScore; //how relevant is this context to the table + private TableContextType type; + + + public TContext(String text, TableContextType type, double score){ + this.text=text; + this.rankScore=score; + this.type=type; + } + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public double getImportanceScore() { + return rankScore; + } + + public void setRankScore(double rankScore) { + this.rankScore = rankScore; + } + + @Override + public int compareTo(TContext o) { + return new Double(getImportanceScore()).compareTo(o.getImportanceScore()); + } + + public TableContextType getType() { + return type; + } + + public void setType(TableContextType type) { + this.type = type; + } + + public enum TableContextType implements Serializable{ + + CAPTION("Caption"), + PAGETITLE("PageTitle"),//title of the page containing the table + PARAGRAPH_BEFORE("Before"),//context occuring before table + PARAGRAPH_AFTER("After"); //context occurring after table + + + private String type; + + TableContextType(String type) { + this.type = type; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/Table.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/Table.java index 9074d63e..be8a4511 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/Table.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/Table.java @@ -1,157 +1,157 @@ -package uk.ac.shef.dcs.sti.core.model; - -import cern.colt.matrix.ObjectMatrix1D; -import cern.colt.matrix.ObjectMatrix2D; -import cern.colt.matrix.impl.SparseObjectMatrix1D; -import cern.colt.matrix.impl.SparseObjectMatrix2D; - -import java.io.Serializable; -import java.util.*; - - -/** - * An Table always has horizontally related columns. First row always headers - * - * - * - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 01/10/12 - * Time: 15:06 - */ -public class Table implements Serializable { - private static final long serialVersionUID = -3422675814777405913L; - private String sourceId; - private String tableId; - - private String tableXPath; - private Map rowXPaths; - - private ObjectMatrix1D headers; //an object can only be a TColumnHeader object - private ObjectMatrix2D contents;//an object can only be a TCell object - - - private int rows; //# of rows in the table (excluding header) - private int cols; //# of columns in the table - - //private List relations = new ArrayList(); - private java.util.List contexts = new ArrayList<>(); - - private TAnnotation tableAnnotations; - - - public Table(String id, String sourceId, int rows, int cols) { - this.tableId = id; - this.sourceId = sourceId; - - this.rows = rows; - this.cols = cols; - contents = new SparseObjectMatrix2D(rows, cols); - headers = new SparseObjectMatrix1D(cols); - - rowXPaths = new LinkedHashMap(); - tableAnnotations = new TAnnotation(rows, cols); - } - - public int getNumRows() { - return rows; - } - - public void setNumRows(int row){ - this.rows=row; - } - - public int getNumCols() { - return cols; - } - public void setNumCols(int col){ - this.cols=col; - } - - //single header/cell - public void setColumnHeader(int c,TColumnHeader header){ - headers.set(c, header); - } - public TColumnHeader getColumnHeader(int c){ - Object o = headers.get(c); - if(o==null) - return null; - - return (TColumnHeader)o; - } - - public void setContentCell(int r, int c, TCell cell) { - contents.set(r, c, cell); - } - - public TCell getContentCell(int r, int c) { - return (TCell)contents.get(r, c); - } - - - //headers and content cells; - - public String getTableId() { - return tableId; - } - - public void setTableId(String tableId) { - this.tableId = tableId; - } - - - public java.util.List getContexts() { - return contexts; - } - - public void addContext(TContext context) { - contexts.add(context); - } - - public boolean equals(Object o) { - if (o instanceof Table) { - Table t = (Table) o; - return t.getTableId().equals(getTableId()) && t.getSourceId().equals(getSourceId()); - } - return false; - } - - public String getSourceId() { - return sourceId; - } - - public void setSourceId(String sourceId) { - this.sourceId = sourceId; - } - - public String toString() { - return getSourceId() + "," + getTableId(); - } - - public String getTableXPath() { - return tableXPath; - } - public void setTableXPath(String tableXPath) { - this.tableXPath = tableXPath; - } - - public Map getRowXPaths() { - return rowXPaths; - } - - - public TAnnotation getTableAnnotations() { - return tableAnnotations; - } - - public void setTableAnnotations(TAnnotation tableAnnotations) { - this.tableAnnotations = tableAnnotations; - } - - public int size(){ - return contents.size(); - } - - public int getNumHeaders() { - return headers.size(); - } -} +package uk.ac.shef.dcs.sti.core.model; + +import cern.colt.matrix.ObjectMatrix1D; +import cern.colt.matrix.ObjectMatrix2D; +import cern.colt.matrix.impl.SparseObjectMatrix1D; +import cern.colt.matrix.impl.SparseObjectMatrix2D; + +import java.io.Serializable; +import java.util.*; + + +/** + * An Table always has horizontally related columns. First row always headers + * + * + * + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 01/10/12 + * Time: 15:06 + */ +public class Table implements Serializable { + private static final long serialVersionUID = -3422675814777405913L; + private String sourceId; + private String tableId; + + private String tableXPath; + private Map rowXPaths; + + private ObjectMatrix1D headers; //an object can only be a TColumnHeader object + private ObjectMatrix2D contents;//an object can only be a TCell object + + + private int rows; //# of rows in the table (excluding header) + private int cols; //# of columns in the table + + //private List relations = new ArrayList(); + private java.util.List contexts = new ArrayList<>(); + + private TAnnotation tableAnnotations; + + + public Table(String id, String sourceId, int rows, int cols) { + this.tableId = id; + this.sourceId = sourceId; + + this.rows = rows; + this.cols = cols; + contents = new SparseObjectMatrix2D(rows, cols); + headers = new SparseObjectMatrix1D(cols); + + rowXPaths = new LinkedHashMap(); + tableAnnotations = new TAnnotation(rows, cols); + } + + public int getNumRows() { + return rows; + } + + public void setNumRows(int row){ + this.rows=row; + } + + public int getNumCols() { + return cols; + } + public void setNumCols(int col){ + this.cols=col; + } + + //single header/cell + public void setColumnHeader(int c,TColumnHeader header){ + headers.set(c, header); + } + public TColumnHeader getColumnHeader(int c){ + Object o = headers.get(c); + if(o==null) + return null; + + return (TColumnHeader)o; + } + + public void setContentCell(int r, int c, TCell cell) { + contents.set(r, c, cell); + } + + public TCell getContentCell(int r, int c) { + return (TCell)contents.get(r, c); + } + + + //headers and content cells; + + public String getTableId() { + return tableId; + } + + public void setTableId(String tableId) { + this.tableId = tableId; + } + + + public java.util.List getContexts() { + return contexts; + } + + public void addContext(TContext context) { + contexts.add(context); + } + + public boolean equals(Object o) { + if (o instanceof Table) { + Table t = (Table) o; + return t.getTableId().equals(getTableId()) && t.getSourceId().equals(getSourceId()); + } + return false; + } + + public String getSourceId() { + return sourceId; + } + + public void setSourceId(String sourceId) { + this.sourceId = sourceId; + } + + public String toString() { + return getSourceId() + "," + getTableId(); + } + + public String getTableXPath() { + return tableXPath; + } + public void setTableXPath(String tableXPath) { + this.tableXPath = tableXPath; + } + + public Map getRowXPaths() { + return rowXPaths; + } + + + public TAnnotation getTableAnnotations() { + return tableAnnotations; + } + + public void setTableAnnotations(TAnnotation tableAnnotations) { + this.tableAnnotations = tableAnnotations; + } + + public int size(){ + return contents.size(); + } + + public int getNumHeaders() { + return headers.size(); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TableTriple.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TableTriple.java index b5b081a8..89bf73c2 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TableTriple.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/model/TableTriple.java @@ -1,73 +1,73 @@ -package uk.ac.shef.dcs.sti.core.model; - -import java.io.Serializable; - -/** - */ -public class TableTriple implements Serializable { - - private static final long serialVersionUID = -813672581122221313L; - private String subject_annotation; - private String subject; - private int[] subject_position; //row, column of table - private String object_annotation; - private String object; - private int[] object_position; - private String relation_annotation; - - public String getSubject_annotation() { - return subject_annotation; - } - - public void setSubject_annotation(String subject_annotation) { - this.subject_annotation = subject_annotation; - } - - public String getSubject() { - return subject; - } - - public void setSubject(String subject) { - this.subject = subject; - } - - public int[] getSubject_position() { - return subject_position; - } - - public void setSubject_position(int[] subject_position) { - this.subject_position = subject_position; - } - - public String getObject_annotation() { - return object_annotation; - } - - public void setObject_annotation(String object_annotation) { - this.object_annotation = object_annotation; - } - - public String getObject() { - return object; - } - - public void setObject(String object) { - this.object = object; - } - - public int[] getObject_position() { - return object_position; - } - - public void setObject_position(int[] object_position) { - this.object_position = object_position; - } - - public String getRelation_annotation() { - return relation_annotation; - } - - public void setRelation_annotation(String relation_annotation) { - this.relation_annotation = relation_annotation; - } -} +package uk.ac.shef.dcs.sti.core.model; + +import java.io.Serializable; + +/** + */ +public class TableTriple implements Serializable { + + private static final long serialVersionUID = -813672581122221313L; + private String subject_annotation; + private String subject; + private int[] subject_position; //row, column of table + private String object_annotation; + private String object; + private int[] object_position; + private String relation_annotation; + + public String getSubject_annotation() { + return subject_annotation; + } + + public void setSubject_annotation(String subject_annotation) { + this.subject_annotation = subject_annotation; + } + + public String getSubject() { + return subject; + } + + public void setSubject(String subject) { + this.subject = subject; + } + + public int[] getSubject_position() { + return subject_position; + } + + public void setSubject_position(int[] subject_position) { + this.subject_position = subject_position; + } + + public String getObject_annotation() { + return object_annotation; + } + + public void setObject_annotation(String object_annotation) { + this.object_annotation = object_annotation; + } + + public String getObject() { + return object; + } + + public void setObject(String object) { + this.object = object; + } + + public int[] getObject_position() { + return object_position; + } + + public void setObject_position(int[] object_position) { + this.object_position = object_position; + } + + public String getRelation_annotation() { + return relation_annotation; + } + + public void setRelation_annotation(String relation_annotation) { + this.relation_annotation = relation_annotation; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/AttributeValueMatcher.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/AttributeValueMatcher.java index 674a91bf..7d5b2b47 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/AttributeValueMatcher.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/AttributeValueMatcher.java @@ -1,195 +1,195 @@ -package uk.ac.shef.dcs.sti.core.scorer; - -import javafx.util.Pair; -import org.simmetrics.Metric; -import org.simmetrics.StringMetric; -import uk.ac.shef.dcs.kbsearch.model.Attribute; -import uk.ac.shef.dcs.sti.STIConstantProperty; -import uk.ac.shef.dcs.sti.util.DataTypeClassifier; -import uk.ac.shef.dcs.sti.util.CollectionUtils; -import uk.ac.shef.dcs.util.StringUtils; - -import java.util.*; - -/** - * Created by - on 02/04/2016. - */ -public class AttributeValueMatcher { - - protected List stopWords; - protected double minScoreThreshold; - protected StringMetric stringMetric; - - public AttributeValueMatcher(double minScoreThreshold, List stopWords, - StringMetric stringMetric) { - this.minScoreThreshold = minScoreThreshold; - this.stopWords = stopWords; - this.stringMetric = stringMetric; - } - - public Map>> match(List attributes, - Map cellTextValues, - Map columnDataTypes) { - Map>> matchedScores = - new HashMap<>(); - - //check the data type of attributes' values - Map attributeValueDataTypes = - classifyAttributeValueDataType(attributes); - - //compute scores for each value on the row - for (Map.Entry e : cellTextValues.entrySet()) { - int column = e.getKey(); - String textValue = e.getValue(); - DataTypeClassifier.DataType cellDataType = columnDataTypes.get(column); - if (cellDataType == null || !isValidType(cellDataType)) - continue; - - double maxScore = 0.0; - Map attrIndex_to_matchScores = new HashMap<>(); - for (int index = 0; index < attributes.size(); index++) { - DataTypeClassifier.DataType dataTypeOfAttrValue = attributeValueDataTypes.get(index); - Attribute attr = attributes.get(index); - if (!isValidType(dataTypeOfAttrValue)) - continue; - - double score = score(textValue, cellDataType, attr.getValue(), dataTypeOfAttrValue, stopWords); - if (score > maxScore) { - maxScore = score; - } - attrIndex_to_matchScores.put(index, score); - } - - - if (maxScore != 0 && maxScore >= minScoreThreshold) { - List> list = new ArrayList<>(); - for (Map.Entry entry : attrIndex_to_matchScores.entrySet()) { - if (entry.getValue() == maxScore) { - Attribute winningAttr = attributes.get(entry.getKey()); - Pair score_obj = new Pair<>(winningAttr, - maxScore); - list.add(score_obj); - } - } - if (list.size() > 0) - matchedScores.put(column, list); - - } - - } - return matchedScores; - } - - protected boolean isValidType(DataTypeClassifier.DataType dataType) { - if (dataType.equals(DataTypeClassifier.DataType.ORDERED_NUMBER)) - return false; - if (dataType.equals(DataTypeClassifier.DataType.EMPTY)) - return false; - if (dataType.equals(DataTypeClassifier.DataType.LONG_TEXT)) - return false; - return true; - } - - /** - * number match scores are computed by matchNumber; text match scores are computed by dice; - * long string (urls) are computed by a string similarity metric - * - * @param string1 - * @param type_of_string1 - * @param string2 - * @param type_of_string2 - * @param stopWords - * @return - */ - protected double score(String string1, - DataTypeClassifier.DataType type_of_string1, - String string2, - DataTypeClassifier.DataType type_of_string2, - Collection stopWords) { - if (type_of_string1.equals(DataTypeClassifier.DataType.NAMED_ENTITY) && - (type_of_string2.equals(DataTypeClassifier.DataType.NUMBER) - || type_of_string2.equals(DataTypeClassifier.DataType.DATE))) - return 0.0; - if (type_of_string2.equals(DataTypeClassifier.DataType.NAMED_ENTITY) && - (type_of_string1.equals(DataTypeClassifier.DataType.NUMBER) - || type_of_string1.equals(DataTypeClassifier.DataType.DATE))) - return 0.0; - //long string like URL - if (type_of_string1.equals(DataTypeClassifier.DataType.LONG_STRING) && - type_of_string2.equals(DataTypeClassifier.DataType.LONG_STRING)) { - string1 = StringUtils.toAlphaNumericWhitechar(string1); - string2 = StringUtils.toAlphaNumericWhitechar(string2); - return stringMetric.compare(string1, string2); - } - if (type_of_string1.equals(DataTypeClassifier.DataType.LONG_STRING) || - type_of_string2.equals(DataTypeClassifier.DataType.LONG_STRING)) - return 0.0; - - //number - double score = -1.0; - if (type_of_string1.equals(DataTypeClassifier.DataType.NUMBER) && - (type_of_string2.equals(DataTypeClassifier.DataType.NUMBER))) { - score = matchNumber(string1, string2); - } - - if (score == -1) { - score = matchText(string1, string2, stopWords); - } - return score == -1.0 ? 0.0 : score; - } - - - protected double matchText(String target, String base, Collection stopWords) { - //method 1, check how much overlap the two texts have - target = StringUtils.toAlphaNumericWhitechar(target); - base = StringUtils.toAlphaNumericWhitechar(base); - Set target_toks = new HashSet<>(StringUtils.toBagOfWords(target, true, true, - STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)); - target_toks.removeAll(stopWords); - Set base_toks = new HashSet<>(StringUtils.toBagOfWords(base, true, true, - STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)); - base_toks.removeAll(stopWords); - - //method 2 - double score = CollectionUtils.computeDice(target_toks, base_toks); - return score; - } - - protected double matchNumber(String string1, String string2) { - try { - double number1 = Double.valueOf(string1); - double number2 = Double.valueOf(string2); - - double max = Math.max(number1, number2); - double maxDiff = max * 0.05; //the maximum difference allowed between the two numbers in order to mean they are equal is 10% of the max number - double diff = Math.abs(number1 - number2); - - if (diff < maxDiff) - return 1.0; - else - return maxDiff / diff; - } catch (Exception e) { - return -1.0; - } - } - - protected Map classifyAttributeValueDataType(List attributes) { - Map dataTypes = new HashMap<>(); - //typing the objects of facts - for (int index = 0; index < attributes.size(); index++) { - Attribute fact = attributes.get(index); - String val = fact.getValue(); - String id_of_val = fact.getValueURI(); - - if (id_of_val != null) - dataTypes.put(index, DataTypeClassifier.DataType.NAMED_ENTITY); - else { - DataTypeClassifier.DataType type = DataTypeClassifier.classify(val); - dataTypes.put(index, type); - } - } - return dataTypes; - - } - -} +package uk.ac.shef.dcs.sti.core.scorer; + +import javafx.util.Pair; +import org.simmetrics.Metric; +import org.simmetrics.StringMetric; +import uk.ac.shef.dcs.kbsearch.model.Attribute; +import uk.ac.shef.dcs.sti.STIConstantProperty; +import uk.ac.shef.dcs.sti.util.DataTypeClassifier; +import uk.ac.shef.dcs.sti.util.CollectionUtils; +import uk.ac.shef.dcs.util.StringUtils; + +import java.util.*; + +/** + * Created by - on 02/04/2016. + */ +public class AttributeValueMatcher { + + protected List stopWords; + protected double minScoreThreshold; + protected StringMetric stringMetric; + + public AttributeValueMatcher(double minScoreThreshold, List stopWords, + StringMetric stringMetric) { + this.minScoreThreshold = minScoreThreshold; + this.stopWords = stopWords; + this.stringMetric = stringMetric; + } + + public Map>> match(List attributes, + Map cellTextValues, + Map columnDataTypes) { + Map>> matchedScores = + new HashMap<>(); + + //check the data type of attributes' values + Map attributeValueDataTypes = + classifyAttributeValueDataType(attributes); + + //compute scores for each value on the row + for (Map.Entry e : cellTextValues.entrySet()) { + int column = e.getKey(); + String textValue = e.getValue(); + DataTypeClassifier.DataType cellDataType = columnDataTypes.get(column); + if (cellDataType == null || !isValidType(cellDataType)) + continue; + + double maxScore = 0.0; + Map attrIndex_to_matchScores = new HashMap<>(); + for (int index = 0; index < attributes.size(); index++) { + DataTypeClassifier.DataType dataTypeOfAttrValue = attributeValueDataTypes.get(index); + Attribute attr = attributes.get(index); + if (!isValidType(dataTypeOfAttrValue)) + continue; + + double score = score(textValue, cellDataType, attr.getValue(), dataTypeOfAttrValue, stopWords); + if (score > maxScore) { + maxScore = score; + } + attrIndex_to_matchScores.put(index, score); + } + + + if (maxScore != 0 && maxScore >= minScoreThreshold) { + List> list = new ArrayList<>(); + for (Map.Entry entry : attrIndex_to_matchScores.entrySet()) { + if (entry.getValue() == maxScore) { + Attribute winningAttr = attributes.get(entry.getKey()); + Pair score_obj = new Pair<>(winningAttr, + maxScore); + list.add(score_obj); + } + } + if (list.size() > 0) + matchedScores.put(column, list); + + } + + } + return matchedScores; + } + + protected boolean isValidType(DataTypeClassifier.DataType dataType) { + if (dataType.equals(DataTypeClassifier.DataType.ORDERED_NUMBER)) + return false; + if (dataType.equals(DataTypeClassifier.DataType.EMPTY)) + return false; + if (dataType.equals(DataTypeClassifier.DataType.LONG_TEXT)) + return false; + return true; + } + + /** + * number match scores are computed by matchNumber; text match scores are computed by dice; + * long string (urls) are computed by a string similarity metric + * + * @param string1 + * @param type_of_string1 + * @param string2 + * @param type_of_string2 + * @param stopWords + * @return + */ + protected double score(String string1, + DataTypeClassifier.DataType type_of_string1, + String string2, + DataTypeClassifier.DataType type_of_string2, + Collection stopWords) { + if (type_of_string1.equals(DataTypeClassifier.DataType.NAMED_ENTITY) && + (type_of_string2.equals(DataTypeClassifier.DataType.NUMBER) + || type_of_string2.equals(DataTypeClassifier.DataType.DATE))) + return 0.0; + if (type_of_string2.equals(DataTypeClassifier.DataType.NAMED_ENTITY) && + (type_of_string1.equals(DataTypeClassifier.DataType.NUMBER) + || type_of_string1.equals(DataTypeClassifier.DataType.DATE))) + return 0.0; + //long string like URL + if (type_of_string1.equals(DataTypeClassifier.DataType.LONG_STRING) && + type_of_string2.equals(DataTypeClassifier.DataType.LONG_STRING)) { + string1 = StringUtils.toAlphaNumericWhitechar(string1); + string2 = StringUtils.toAlphaNumericWhitechar(string2); + return stringMetric.compare(string1, string2); + } + if (type_of_string1.equals(DataTypeClassifier.DataType.LONG_STRING) || + type_of_string2.equals(DataTypeClassifier.DataType.LONG_STRING)) + return 0.0; + + //number + double score = -1.0; + if (type_of_string1.equals(DataTypeClassifier.DataType.NUMBER) && + (type_of_string2.equals(DataTypeClassifier.DataType.NUMBER))) { + score = matchNumber(string1, string2); + } + + if (score == -1) { + score = matchText(string1, string2, stopWords); + } + return score == -1.0 ? 0.0 : score; + } + + + protected double matchText(String target, String base, Collection stopWords) { + //method 1, check how much overlap the two texts have + target = StringUtils.toAlphaNumericWhitechar(target); + base = StringUtils.toAlphaNumericWhitechar(base); + Set target_toks = new HashSet<>(StringUtils.toBagOfWords(target, true, true, + STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)); + target_toks.removeAll(stopWords); + Set base_toks = new HashSet<>(StringUtils.toBagOfWords(base, true, true, + STIConstantProperty.BOW_DISCARD_SINGLE_CHAR)); + base_toks.removeAll(stopWords); + + //method 2 + double score = CollectionUtils.computeDice(target_toks, base_toks); + return score; + } + + protected double matchNumber(String string1, String string2) { + try { + double number1 = Double.valueOf(string1); + double number2 = Double.valueOf(string2); + + double max = Math.max(number1, number2); + double maxDiff = max * 0.05; //the maximum difference allowed between the two numbers in order to mean they are equal is 10% of the max number + double diff = Math.abs(number1 - number2); + + if (diff < maxDiff) + return 1.0; + else + return maxDiff / diff; + } catch (Exception e) { + return -1.0; + } + } + + protected Map classifyAttributeValueDataType(List attributes) { + Map dataTypes = new HashMap<>(); + //typing the objects of facts + for (int index = 0; index < attributes.size(); index++) { + Attribute fact = attributes.get(index); + String val = fact.getValue(); + String id_of_val = fact.getValueURI(); + + if (id_of_val != null) + dataTypes.put(index, DataTypeClassifier.DataType.NAMED_ENTITY); + else { + DataTypeClassifier.DataType type = DataTypeClassifier.classify(val); + dataTypes.put(index, type); + } + } + return dataTypes; + + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/ClazzScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/ClazzScorer.java index 86a14dd1..879c0830 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/ClazzScorer.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/ClazzScorer.java @@ -1,47 +1,47 @@ -package uk.ac.shef.dcs.sti.core.scorer; - -import javafx.util.Pair; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; -import uk.ac.shef.dcs.sti.core.model.Table; - -import java.util.*; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 24/01/14 - * Time: 13:47 - * To change this template use File | Settings | File Templates. - */ -public interface ClazzScorer { - - - //input: key is table row index; value is list of candidate entities and their disambiguation scores for that row - //output: a map representing the state of the solution - Map computeFinal(TColumnHeaderAnnotation ha, int tableRowsTotal); - //intput: list of entities and their preliminary disamb scores on the current row; - List computeElementScores(List>> input, - Collection headerAnnotationCandidates, - Table table, - List rows, int column) throws STIException; - - List computeCEScore(List>> entities, - Collection existingHeaderAnnotations, - Table table, - int row, int column) throws STIException; - - /** - * compute CC scores for column clazz annotation candidates, ONLY IF the CC score is not yet computed - * @param candidates - * @param table - * @param column - * @return - */ - List computeCCScore(Collection candidates, Table table, int column) throws STIException; - - double computeDC(TColumnHeaderAnnotation ha, List domain_representation) throws STIException; - - -} +package uk.ac.shef.dcs.sti.core.scorer; + +import javafx.util.Pair; +import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; +import uk.ac.shef.dcs.sti.core.model.Table; + +import java.util.*; + +/** + * Created with IntelliJ IDEA. + * User: zqz + * Date: 24/01/14 + * Time: 13:47 + * To change this template use File | Settings | File Templates. + */ +public interface ClazzScorer { + + + //input: key is table row index; value is list of candidate entities and their disambiguation scores for that row + //output: a map representing the state of the solution + Map computeFinal(TColumnHeaderAnnotation ha, int tableRowsTotal); + //intput: list of entities and their preliminary disamb scores on the current row; + List computeElementScores(List>> input, + Collection headerAnnotationCandidates, + Table table, + List rows, int column) throws STIException; + + List computeCEScore(List>> entities, + Collection existingHeaderAnnotations, + Table table, + int row, int column) throws STIException; + + /** + * compute CC scores for column clazz annotation candidates, ONLY IF the CC score is not yet computed + * @param candidates + * @param table + * @param column + * @return + */ + List computeCCScore(Collection candidates, Table table, int column) throws STIException; + + double computeDC(TColumnHeaderAnnotation ha, List domain_representation) throws STIException; + + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/EntityScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/EntityScorer.java index 3e87ef41..96bea0cb 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/EntityScorer.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/EntityScorer.java @@ -1,35 +1,35 @@ -package uk.ac.shef.dcs.sti.core.scorer; - -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.sti.core.model.Table; - -import java.util.*; - -/** - * Disambiguate entity names in table - */ -public interface EntityScorer { - - /** - * @param candidate candidate NE to be scored - * @param allCandidates all candidate NEs matching the search - * @param sourceColumnIndex column id of the candidate NE - * @param sourceRowIndex row id of the candidate NE - * @param block rows in this column where the text is the same as the cell identified by - * the row id and column id (including the row-in-question) - * @param table the table object - * @param referenceEntities if the relatedness between this NE and NEs from other cells in the same - * column should be computed, here is the list of NEs from other cells in the same column - * @return a map where key= the name of a disambiguation computeElementScores element; value=computeElementScores - */ - Map computeElementScores(Entity candidate, - List allCandidates, - int sourceColumnIndex, - int sourceRowIndex, - List block, - Table table, - Entity... referenceEntities); - - double computeFinal(Map scoreMap, String cellTextOriginal); - -} +package uk.ac.shef.dcs.sti.core.scorer; + +import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.sti.core.model.Table; + +import java.util.*; + +/** + * Disambiguate entity names in table + */ +public interface EntityScorer { + + /** + * @param candidate candidate NE to be scored + * @param allCandidates all candidate NEs matching the search + * @param sourceColumnIndex column id of the candidate NE + * @param sourceRowIndex row id of the candidate NE + * @param block rows in this column where the text is the same as the cell identified by + * the row id and column id (including the row-in-question) + * @param table the table object + * @param referenceEntities if the relatedness between this NE and NEs from other cells in the same + * column should be computed, here is the list of NEs from other cells in the same column + * @return a map where key= the name of a disambiguation computeElementScores element; value=computeElementScores + */ + Map computeElementScores(Entity candidate, + List allCandidates, + int sourceColumnIndex, + int sourceRowIndex, + List block, + Table table, + Entity... referenceEntities); + + double computeFinal(Map scoreMap, String cellTextOriginal); + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/RelationScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/RelationScorer.java index 485f1497..bcb2a58a 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/RelationScorer.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/scorer/RelationScorer.java @@ -1,31 +1,31 @@ -package uk.ac.shef.dcs.sti.core.scorer; - -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.model.TCellCellRelationAnotation; -import uk.ac.shef.dcs.sti.core.model.TColumnColumnRelationAnnotation; -import uk.ac.shef.dcs.sti.core.model.Table; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - */ -public interface RelationScorer { - - List computeElementScores(List cellcellRelationsOnRow, - Collection output, - int subjectCol, int objectCol, - Table table) throws STIException; - - List computeREScore(List cellcellRelationAnotations, - Collection output, - int subjectCol, int objectCol) throws STIException; - - List computeRCScore(Collection candidates, - Table table, int column) throws STIException; - - Map computeFinal(TColumnColumnRelationAnnotation relation, int tableRowsTotal); - - double scoreDC(TColumnColumnRelationAnnotation hbr, List domain_representation) throws STIException; -} +package uk.ac.shef.dcs.sti.core.scorer; + +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.model.TCellCellRelationAnotation; +import uk.ac.shef.dcs.sti.core.model.TColumnColumnRelationAnnotation; +import uk.ac.shef.dcs.sti.core.model.Table; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + */ +public interface RelationScorer { + + List computeElementScores(List cellcellRelationsOnRow, + Collection output, + int subjectCol, int objectCol, + Table table) throws STIException; + + List computeREScore(List cellcellRelationAnotations, + Collection output, + int subjectCol, int objectCol) throws STIException; + + List computeRCScore(Collection candidates, + Table table, int column) throws STIException; + + Map computeFinal(TColumnColumnRelationAnnotation relation, int tableRowsTotal); + + double scoreDC(TColumnColumnRelationAnnotation hbr, List domain_representation) throws STIException; +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/CMScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/CMScorer.java index 2b19a5ee..ebb0f933 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/CMScorer.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/CMScorer.java @@ -1,143 +1,143 @@ -package uk.ac.shef.dcs.sti.core.subjectcol; - -import javafx.util.Pair; -import uk.ac.shef.dcs.sti.nlp.Lemmatizer; -import uk.ac.shef.dcs.sti.nlp.NLPTools; -import uk.ac.shef.dcs.sti.core.model.TContext; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.util.FileUtils; - -import java.io.File; -import java.io.IOException; -import java.util.*; - -/** - * produces matching statistics of a table's header and its contexts. can only computeElementScores headers that are NOT STOPWORDS - *

- *

- *

- *

- * the scoring algorithm is implemented in this class - */ -class CMScorer { - - private static final double MINIMUM_CONTEXT_SCORE = 0.5; //context blocks with an importance computeElementScores lower than this will not be considered - private static final int MAXIMUM_CONTEXTS_TO_MATCH = 10; //except title, caption, computeElementScores a maximum of 5 context blocks around the table - private static final double SCALAR_MAJOR_CONTEXT_WEIGHT = 2.0; //major context blocks, i.e., titles, captions, plural word matches - // are considered more important. if matched, their scores is multiplied by this factor - private Lemmatizer lemmatizer; - private List stopwords; - - public CMScorer(String nlpResource) throws IOException { - this.lemmatizer = NLPTools.getInstance(nlpResource).getLemmatizer(); - try { - stopwords = FileUtils.readList(nlpResource + File.separator + "stoplist.txt", false); - } catch (IOException e) { - stopwords = new ArrayList<>(); - } - - } - - //returns a map between column index and matching computeElementScores - public Map score(Table table, int... col_indexes) { - Map scores = new HashMap(); - - //learn headers to computeElementScores against - Map> headerKeywords = new HashMap<>(); - for (int col_id : col_indexes) { - List searchWords = new ArrayList<>(); - - String keyword = table.getColumnHeader(col_id).getHeaderText(); - //searchWords.add(lemmatizer.getLemma(keyword, "NN")); - - //then add capitalised, noun-stop words - String[] candidates = keyword.split("\\s+"); - for (int index = 0; index < candidates.length; index++) { - String w = candidates[index]; - /*if (StringUtils.isCapitalized(w)) { - w = lemmatizer.getLemma(w, "NN"); - if (!stopwords.contains(w)) - searchWords.add(w); - }*/ - //if (StringUtils.isCapitalized(w)) { - w = lemmatizer.getLemma(w, "NN"); - if (!stopwords.contains(w)) - searchWords.add(w); - //} - } - headerKeywords.put(col_id, searchWords); - } - - //List stop = new ArrayList(stopwords); - //stop.removeAll(headerKeywords.values()); - - //learn contexts to generate word lookup maps - List contexts = table.getContexts(); - Collections.sort(contexts); - - int countContextBlocks = 0; - double score = 0.0; - for (TContext ctx : contexts) { - if (countContextBlocks == MAXIMUM_CONTEXTS_TO_MATCH) - break; - if (ctx.getImportanceScore() < MINIMUM_CONTEXT_SCORE) - continue; - - //collect distinct words from this context, their frequency, and plural form frequency - Map> wordFreq = new - HashMap<>(); - StringTokenizer tokenizer = new StringTokenizer(ctx.getText()); - while (tokenizer.hasMoreTokens()) { - String tok = tokenizer.nextToken(); - String canonical = lemmatizer.getLemma(tok, "NN"); - - Pair countings = wordFreq.get(canonical); - if (countings == null) { - countings = new Pair<>(0,0); - } - int k = countings.getKey() + 1; - int v = countings.getValue(); - if (!tok.toLowerCase().equals(canonical)) - v=v + 1; - countings = new Pair<>(k,v); - - wordFreq.put(canonical, countings); - } - - //compute matching scores for each header keyword against this context block - for (Map.Entry> headerKey : headerKeywords.entrySet()) { - List words = headerKey.getValue(); - if (words == null) continue; - - //firstly lets try the full header text, i.e., element 1 in "words" - for (String word : words) { - Pair freq = wordFreq.get(word); - if (freq == null) - continue; - - score = score + freq.getKey(); //if header keyword matches this word, its computeElementScores is incremented by its frequency - score = score + freq.getValue();//if the matched word is plural, the computeElementScores is further modified - if (ctx.getType().equals(TContext.TableContextType.CAPTION) - || ctx.getType().equals(TContext.TableContextType.PAGETITLE)) { - score = score * SCALAR_MAJOR_CONTEXT_WEIGHT; - } - Double prevScore = scores.get(headerKey.getKey()); - prevScore = prevScore == null ? 0 : prevScore; - prevScore = prevScore + score; - scores.put(headerKey.getKey(), prevScore); - } - } - - //special context blocks does not count towards the maximum number of context blocks to be considered - if (ctx.getType().equals(TContext.TableContextType.CAPTION) - || ctx.getText().equals(TContext.TableContextType.PAGETITLE)) { - } else { - countContextBlocks++; - } - } - - return scores; - } - - -} +package uk.ac.shef.dcs.sti.core.subjectcol; + +import javafx.util.Pair; +import uk.ac.shef.dcs.sti.nlp.Lemmatizer; +import uk.ac.shef.dcs.sti.nlp.NLPTools; +import uk.ac.shef.dcs.sti.core.model.TContext; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.util.FileUtils; + +import java.io.File; +import java.io.IOException; +import java.util.*; + +/** + * produces matching statistics of a table's header and its contexts. can only computeElementScores headers that are NOT STOPWORDS + *

+ *

+ *

+ *

+ * the scoring algorithm is implemented in this class + */ +class CMScorer { + + private static final double MINIMUM_CONTEXT_SCORE = 0.5; //context blocks with an importance computeElementScores lower than this will not be considered + private static final int MAXIMUM_CONTEXTS_TO_MATCH = 10; //except title, caption, computeElementScores a maximum of 5 context blocks around the table + private static final double SCALAR_MAJOR_CONTEXT_WEIGHT = 2.0; //major context blocks, i.e., titles, captions, plural word matches + // are considered more important. if matched, their scores is multiplied by this factor + private Lemmatizer lemmatizer; + private List stopwords; + + public CMScorer(String nlpResource) throws IOException { + this.lemmatizer = NLPTools.getInstance(nlpResource).getLemmatizer(); + try { + stopwords = FileUtils.readList(nlpResource + File.separator + "stoplist.txt", false); + } catch (IOException e) { + stopwords = new ArrayList<>(); + } + + } + + //returns a map between column index and matching computeElementScores + public Map score(Table table, int... col_indexes) { + Map scores = new HashMap(); + + //learn headers to computeElementScores against + Map> headerKeywords = new HashMap<>(); + for (int col_id : col_indexes) { + List searchWords = new ArrayList<>(); + + String keyword = table.getColumnHeader(col_id).getHeaderText(); + //searchWords.add(lemmatizer.getLemma(keyword, "NN")); + + //then add capitalised, noun-stop words + String[] candidates = keyword.split("\\s+"); + for (int index = 0; index < candidates.length; index++) { + String w = candidates[index]; + /*if (StringUtils.isCapitalized(w)) { + w = lemmatizer.getLemma(w, "NN"); + if (!stopwords.contains(w)) + searchWords.add(w); + }*/ + //if (StringUtils.isCapitalized(w)) { + w = lemmatizer.getLemma(w, "NN"); + if (!stopwords.contains(w)) + searchWords.add(w); + //} + } + headerKeywords.put(col_id, searchWords); + } + + //List stop = new ArrayList(stopwords); + //stop.removeAll(headerKeywords.values()); + + //learn contexts to generate word lookup maps + List contexts = table.getContexts(); + Collections.sort(contexts); + + int countContextBlocks = 0; + double score = 0.0; + for (TContext ctx : contexts) { + if (countContextBlocks == MAXIMUM_CONTEXTS_TO_MATCH) + break; + if (ctx.getImportanceScore() < MINIMUM_CONTEXT_SCORE) + continue; + + //collect distinct words from this context, their frequency, and plural form frequency + Map> wordFreq = new + HashMap<>(); + StringTokenizer tokenizer = new StringTokenizer(ctx.getText()); + while (tokenizer.hasMoreTokens()) { + String tok = tokenizer.nextToken(); + String canonical = lemmatizer.getLemma(tok, "NN"); + + Pair countings = wordFreq.get(canonical); + if (countings == null) { + countings = new Pair<>(0,0); + } + int k = countings.getKey() + 1; + int v = countings.getValue(); + if (!tok.toLowerCase().equals(canonical)) + v=v + 1; + countings = new Pair<>(k,v); + + wordFreq.put(canonical, countings); + } + + //compute matching scores for each header keyword against this context block + for (Map.Entry> headerKey : headerKeywords.entrySet()) { + List words = headerKey.getValue(); + if (words == null) continue; + + //firstly lets try the full header text, i.e., element 1 in "words" + for (String word : words) { + Pair freq = wordFreq.get(word); + if (freq == null) + continue; + + score = score + freq.getKey(); //if header keyword matches this word, its computeElementScores is incremented by its frequency + score = score + freq.getValue();//if the matched word is plural, the computeElementScores is further modified + if (ctx.getType().equals(TContext.TableContextType.CAPTION) + || ctx.getType().equals(TContext.TableContextType.PAGETITLE)) { + score = score * SCALAR_MAJOR_CONTEXT_WEIGHT; + } + Double prevScore = scores.get(headerKey.getKey()); + prevScore = prevScore == null ? 0 : prevScore; + prevScore = prevScore + score; + scores.put(headerKey.getKey(), prevScore); + } + } + + //special context blocks does not count towards the maximum number of context blocks to be considered + if (ctx.getType().equals(TContext.TableContextType.CAPTION) + || ctx.getText().equals(TContext.TableContextType.PAGETITLE)) { + } else { + countContextBlocks++; + } + } + + return scores; + } + + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnDetector.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnDetector.java index 5ced8974..f8fb8a41 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnDetector.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnDetector.java @@ -1,409 +1,409 @@ -package uk.ac.shef.dcs.sti.core.subjectcol; - -import cern.colt.matrix.DoubleMatrix2D; -import javafx.util.Pair; -import org.apache.log4j.Logger; -import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; -import uk.ac.shef.dcs.sti.core.algorithm.tmp.sampler.TContentRowRanker; -import uk.ac.shef.dcs.sti.util.DataTypeClassifier; -import uk.ac.shef.dcs.sti.core.algorithm.tmp.stopping.StoppingCriteriaInstantiator; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.websearch.WebSearchException; -import uk.ac.shef.dcs.websearch.bing.v2.APIKeysDepletedException; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.util.*; - -/** - * This class implements a decision tree logic to infer among all columns in a table, which ONE is likely the main entity - * column - */ -public class SubjectColumnDetector { - - private static Logger LOG = Logger.getLogger(SubjectColumnDetector.class.getName()); - private TColumnFeatureGenerator featureGenerator; - private TContentRowRanker tRowRanker; - private String stoppingCriteriaClassname; - private String[] stoppingCriteriaParams; - private boolean useWS; - - - public SubjectColumnDetector( - TContentRowRanker tRowRanker, - String stoppingCriteriaClassname, - String[] stoppingCriteriaParams, - EmbeddedSolrServer cache, - String nlpResource, - boolean useWS, - List stopwords, - String webSearchPropFile) throws IOException, WebSearchException { - featureGenerator = new TColumnFeatureGenerator(cache, nlpResource, stopwords, - webSearchPropFile); - this.tRowRanker = tRowRanker; - this.stoppingCriteriaClassname = stoppingCriteriaClassname; - this.stoppingCriteriaParams = stoppingCriteriaParams; - this.useWS = useWS; - } - - /** - * The decision tree logic is: - * 1. If col is the only NE likely col in the table, choose the column - * 2. If col is NE likely, and it is the only one having non-empty cells, choose the column - * - * @param table - * @return a list of Pair objects, where first object is the column index; second is a pair - * where the first part is the computeElementScores - * probability that asserts that column being the main column of the table, the second - * part is a boolean indicating whether the column is acronym column. (only NE likely columns can be - * considered main column) - */ - public List>> compute(Table table, int... skipColumns) throws APIKeysDepletedException, IOException, ClassNotFoundException { - List>> rs = new ArrayList<>(); - - //1. initiate all columns' feature objects - List featuresOfAllColumns = new ArrayList<>(table.getNumCols()); - for (int c = 0; c < table.getNumCols(); c++) { - boolean skip = false; - for (int i : skipColumns) { - if (c == i) { - skip = true; - break; - } - } - if (!skip) - featuresOfAllColumns.add(new TColumnFeature(c, table.getNumRows())); - } - - //2. infer column datatype - featureGenerator.setColumnDataTypes(table); - - //3. infer the most frequent datatype, - featureGenerator.setMostFrequentDataTypes(featuresOfAllColumns, table); - - //4. select only NE columns to further learn - List featuresOfNEColumns = selectOnlyNEColumnFeatures(featuresOfAllColumns); - if (featuresOfNEColumns.size() == 0) { - LOG.warn("This table does not contain columns that are likely to contain named entities."); - Pair> oo = new Pair<>(0, new Pair<>(1.0, false)); - rs.add(oo); - attachColumnFeature(table, featuresOfAllColumns); - return rs; - } - - featureGenerator.setEmptyCellCount(featuresOfNEColumns, table); //warning:always count empty cells first!!!!! - featureGenerator.setUniqueValueCount(featuresOfNEColumns, table); - featureGenerator.setAcronymColumnBoolean(featuresOfNEColumns, table); //warning: this must be run after counting empty cells!!! - - //5. is any NE column the only valid NE column in the table? - int onlyNECol = featureGenerator.setOnlyNEColumn(featuresOfNEColumns); - //5 - yes: - if (onlyNECol != -1) { - Pair> oo = new Pair<>(onlyNECol, new Pair<>(1.0, false)); - rs.add(oo); - for (TColumnFeature cf : featuresOfAllColumns) - table.getColumnHeader(cf.getColId()).setFeature(cf); - return rs; - } - - //6. is any NE column the only one that has no empty cells? - int onlyNonEmptyNECol = featureGenerator.setOnlyNonEmptyNEColumn(featuresOfNEColumns); - if (onlyNonEmptyNECol != -1) { - Pair> oo = - new Pair<>(onlyNonEmptyNECol, new Pair<>(1.0, false)); - rs.add(oo); - attachColumnFeature(table, featuresOfAllColumns); - return rs; - } - - //7. is any NE column the only one that has non-duplicate values on every row - // and that it is NOT an acronym column? - int onlyNonDuplicateNECol = featureGenerator.setOnlyNonDuplicateNEColumn(featuresOfNEColumns, table); - //todo: test this. original has the following block, which has no effect on results - /*if (onlyNonDuplicateNECol != -1) { - - Pair> oo = new Pair<>( - onlyNonDuplicateNECol, new Pair<>(1.0, false) - ); - // rs.add(oo); - for (TColumnFeature cf : featuresOfAllColumns) { - table.getColumnHeader(cf.getColId()).setFeature(cf); - } - // return rs; - }*/ - - //7.5 ====== this is a dangerous rule as it MAY overdo (have not checked thou) true positives ====== - List ignoreColumns = new ArrayList<>(); - featureGenerator.setInvalidHeaderTextSyntax(featuresOfNEColumns, table); - for (TColumnFeature cf : featuresOfNEColumns) { - if (cf.isInvalidPOS()) - ignoreColumns.add(cf.getColId()); - } - //if columns to be ignored due to invalid header text is less than total columns - //to be considered,we can isValidAttribute them - //otherwise, if we are told all columns should be ignored, dont isValidAttribute any candidate ne columns - if (ignoreColumns.size()>0&&ignoreColumns.size() != featuresOfNEColumns.size()) { - Iterator it = featuresOfNEColumns.iterator(); - while (it.hasNext()) { - TColumnFeature cf = it.next(); - if (cf.isInvalidPOS()) - it.remove(); - } - } - if (featuresOfNEColumns.size() == 1) { - Pair> oo = new Pair<>( - featuresOfNEColumns.get(0).getColId(), - new Pair<>(1.0, false) - ); - rs.add(oo); - attachColumnFeature(table,featuresOfAllColumns); - return rs; - } - - //8. generate feature - 1st NE column - featureGenerator.setIsFirstNEColumn(featuresOfNEColumns); - - //9. generate features - context computeElementScores - LOG.debug("Computing cm computeElementScores"); //todo more testing required for this - featureGenerator.setCMScores(featuresOfNEColumns, table); - - //10. generate features - web search matcher - if (useWS) { - computeWSScores(table, featuresOfNEColumns); - } - - //added: reset all scores to use relative scoring - normalizeScores(featuresOfNEColumns); - - //12. then let's perform reasoning based on the remaining features: - //diversity computeElementScores; 1st ne column; context computeElementScores; web search computeElementScores - final Map> finalScores = - new SubjectColumnScorerHeuristic().score(featuresOfNEColumns); - List candidates = new ArrayList<>(finalScores.keySet()); - //tiebreaker_reset(allNEColumnCandidates, inferenceScores); - - Collections.sort(candidates, (o1, o2) -> - finalScores.get(o2).getKey().compareTo(finalScores.get(o1).getKey())); - - for (int ci : candidates) { - Pair> oo = new Pair<>(ci, - finalScores.get(ci)); - rs.add(oo); - } - - for (TColumnFeature cf : featuresOfAllColumns) { - table.getColumnHeader(cf.getColId()).setFeature(cf); - } - return rs; - } - - private void computeWSScores(Table table, List featuresOfNEColumns) throws APIKeysDepletedException, IOException, ClassNotFoundException { - LOG.debug("Computing web search matching (total rows " + table.getNumRows()); - - DoubleMatrix2D scores; - if (tRowRanker != null) { - scores = featureGenerator.setWSScores(featuresOfNEColumns, table, - tRowRanker, - StoppingCriteriaInstantiator. - instantiate(stoppingCriteriaClassname, stoppingCriteriaParams), 1); - } else { - scores = featureGenerator.setWSScores(featuresOfNEColumns, table); - } - double total = 0.0; - for (TColumnFeature cf : featuresOfNEColumns) { - for (int row = 0; row < scores.rows(); row++) { - total += scores.get(row, cf.getColId()); - } - cf.setWebSearchScore(total); - total = 0.0; - } - } - - private void attachColumnFeature(Table table, List featuresOfAllColumns) { - for (TColumnFeature cf : featuresOfAllColumns) - table.getColumnHeader(cf.getColId()).setFeature(cf); - } - - //only keep TColumnFeatures that correspond to an NE column - private List selectOnlyNEColumnFeatures(List allColumnFeatures) { - List neColumns = new ArrayList<>(); - for (TColumnFeature cf : allColumnFeatures) { - if (cf.getMostFrequentDataType().getType(). - equals(DataTypeClassifier.DataType.NAMED_ENTITY)) - neColumns.add(cf); - } - //EXCEPTION: what if no NE columns found? Add any columns that are short_text - if (neColumns.size() == 0) { - for (TColumnFeature cf : allColumnFeatures) { - if (cf.getMostFrequentDataType().getType(). - equals(DataTypeClassifier.DataType.SHORT_TEXT)) - neColumns.add(cf); - } - } - return neColumns; - } - - - private void normalizeScores(List allNEColumnCandidates) { - //c. context matcher - Collections.sort(allNEColumnCandidates, (o1, o2) -> new Double(o2.getCMScore()).compareTo(o1.getCMScore())); - double maxCMScore = allNEColumnCandidates.get(0).getCMScore(); - if (maxCMScore > 0) { - for (TColumnFeature cf : allNEColumnCandidates) { - double rel_score = cf.getCMScore() / maxCMScore; - cf.setContextMatchScore(rel_score); - } - } - - //e. vote by search matcher - Collections.sort(allNEColumnCandidates, (o1, o2) -> new Double(o2.getWSScore()).compareTo(o1.getWSScore())); - double maxWSScore = allNEColumnCandidates.get(0).getWSScore(); - if (maxWSScore > 0) { - for (TColumnFeature cf : allNEColumnCandidates) { - double rel_score = cf.getWSScore() / maxWSScore; - cf.setWebSearchScore(rel_score); - } - } - } - - /*private void tiebreaker_reset( - List allNEColumnCandidates, - Map> inferenceScores) { - List ties = new ArrayList(); - double maxScore = 0; - for (Map.Entry> e : inferenceScores.entrySet()) { - if (e.getValue().getMainObject() > maxScore) { - maxScore = e.getValue().getMainObject(); - } - } - for (Map.Entry> e : inferenceScores.entrySet()) { - if (e.getValue().getMainObject() == maxScore) { - ties.add(e.getKey()); - } - } - - if (ties.size() > 1) { - - double max = 0; - int best = 0; - for (int i : ties) { - for (TColumnFeature cf : allNEColumnCandidates) { - if (cf.getColId() == i) { - double sum = cf.getUniqueCellCount() + cf.getCMScore() - + cf.getUniqueTokenCount() + cf.getWSScore() - - (cf.getEmptyCellCount() / (double) cf.getNumRows()); - - if (sum > max) { - max = sum; - best = i; - } - break; - } - } - } - // try { - inferenceScores.get(best).setMainObject( - inferenceScores.get(best).getMainObject() + 1.0 - ); - // } catch (NullPointerException n) { - // System.out.println(); - // } - } - } -*/ - //key: col id; value: computeElementScores - //currently performs following scoring: diversity; context computeElementScores; - // 1st ne column; acronym column checker; search - //results are collected as number of votes by each dimension - private Map> infer_multiFeatures_vote(List allNEColumnCandidates) { - Map> votes = new HashMap<>(); - //a. vote by diversity computeElementScores - Collections.sort(allNEColumnCandidates, new Comparator() { - @Override - public int compare(TColumnFeature o1, TColumnFeature o2) { - int compared = new Double(o2.getUniqueCellCount()).compareTo(o1.getUniqueCellCount()); - if (compared == 0) - return new Double(o2.getUniqueTokenCount()).compareTo(o1.getUniqueTokenCount()); - return compared; - } - }); - double maxDiversityScore = -1.0; - for (TColumnFeature cf : allNEColumnCandidates) { - double diversity = cf.getUniqueTokenCount() + cf.getUniqueCellCount(); - if (diversity >= maxDiversityScore && diversity != 0) { - maxDiversityScore = diversity; - votes.put(cf.getColId(), new Pair<>(1.0, false)); - } else - break; //already sorted, so following this there shouldnt be higher diversity scores - } - - - //b. vote by 1st ne column - for (TColumnFeature cf : allNEColumnCandidates) { - if (cf.isFirstNEColumn()) { - Pair entry = votes.get(cf.getColId()); - entry = entry == null ? new Pair<>(0.0, false) : entry; - Double vts = entry.getKey(); - vts = vts + 1.0; - entry = new Pair<>(vts, entry.getValue()); - votes.put(cf.getColId(), entry); - break; - } - } - //c. vote by context matcher - Collections.sort(allNEColumnCandidates, new Comparator() { - @Override - public int compare(TColumnFeature o1, TColumnFeature o2) { - return new Double(o2.getCMScore()).compareTo(o1.getCMScore()); - } - }); - double maxContextMatchScore = -1.0; - for (TColumnFeature cf : allNEColumnCandidates) { - if (cf.getCMScore() >= maxContextMatchScore && cf.getCMScore() != 0) { - maxContextMatchScore = cf.getCMScore(); - Pair entry = votes.get(cf.getColId()); - entry = entry == null ? new Pair<>(0.0, false) : entry; - Double vts = entry.getKey(); - vts = vts + 1.0; - entry = new Pair<>(vts, entry.getValue()); - votes.put(cf.getColId(), entry); - } else - break; - } - //d. vote by acronym columns - for (TColumnFeature cf : allNEColumnCandidates) { - if (cf.isAcronymColumn()) { - Pair entry = votes.get(cf.getColId()); - entry = entry == null ? new Pair<>(0.0, false) : entry; - Double vts = entry.getKey(); - vts = vts - 1.0; - entry = new Pair<>(vts, true); - votes.put(cf.getColId(), entry); - } - } - - //e. vote by search matcher - Collections.sort(allNEColumnCandidates, (o1, o2) -> new Double(o2.getWSScore()).compareTo(o1.getWSScore())); - double maxSearchMatchScore = -1.0; - for (TColumnFeature cf : allNEColumnCandidates) { - if (cf.getWSScore() >= maxSearchMatchScore && cf.getWSScore() != 0) { - maxSearchMatchScore = cf.getWSScore(); - Pair entry = votes.get(cf.getColId()); - entry = entry == null ? new Pair<>(0.0, false) : entry; - Double vts = entry.getKey(); - vts = vts + 1.0; - entry = new Pair<>(vts, entry.getValue()); - votes.put(cf.getColId(), entry); - } else - break; - } - - for (TColumnFeature cf : allNEColumnCandidates) { - if (votes.containsKey(cf.getColId())) - continue; - votes.put(cf.getColId(), new Pair<>(0.0, false)); - } - return votes; - } - -} +package uk.ac.shef.dcs.sti.core.subjectcol; + +import cern.colt.matrix.DoubleMatrix2D; +import javafx.util.Pair; +import org.apache.log4j.Logger; +import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; +import uk.ac.shef.dcs.sti.core.algorithm.tmp.sampler.TContentRowRanker; +import uk.ac.shef.dcs.sti.util.DataTypeClassifier; +import uk.ac.shef.dcs.sti.core.algorithm.tmp.stopping.StoppingCriteriaInstantiator; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.websearch.WebSearchException; +import uk.ac.shef.dcs.websearch.bing.v2.APIKeysDepletedException; + +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.util.*; + +/** + * This class implements a decision tree logic to infer among all columns in a table, which ONE is likely the main entity + * column + */ +public class SubjectColumnDetector { + + private static Logger LOG = Logger.getLogger(SubjectColumnDetector.class.getName()); + private TColumnFeatureGenerator featureGenerator; + private TContentRowRanker tRowRanker; + private String stoppingCriteriaClassname; + private String[] stoppingCriteriaParams; + private boolean useWS; + + + public SubjectColumnDetector( + TContentRowRanker tRowRanker, + String stoppingCriteriaClassname, + String[] stoppingCriteriaParams, + EmbeddedSolrServer cache, + String nlpResource, + boolean useWS, + List stopwords, + String webSearchPropFile) throws IOException, WebSearchException { + featureGenerator = new TColumnFeatureGenerator(cache, nlpResource, stopwords, + webSearchPropFile); + this.tRowRanker = tRowRanker; + this.stoppingCriteriaClassname = stoppingCriteriaClassname; + this.stoppingCriteriaParams = stoppingCriteriaParams; + this.useWS = useWS; + } + + /** + * The decision tree logic is: + * 1. If col is the only NE likely col in the table, choose the column + * 2. If col is NE likely, and it is the only one having non-empty cells, choose the column + * + * @param table + * @return a list of Pair objects, where first object is the column index; second is a pair + * where the first part is the computeElementScores + * probability that asserts that column being the main column of the table, the second + * part is a boolean indicating whether the column is acronym column. (only NE likely columns can be + * considered main column) + */ + public List>> compute(Table table, int... skipColumns) throws APIKeysDepletedException, IOException, ClassNotFoundException { + List>> rs = new ArrayList<>(); + + //1. initiate all columns' feature objects + List featuresOfAllColumns = new ArrayList<>(table.getNumCols()); + for (int c = 0; c < table.getNumCols(); c++) { + boolean skip = false; + for (int i : skipColumns) { + if (c == i) { + skip = true; + break; + } + } + if (!skip) + featuresOfAllColumns.add(new TColumnFeature(c, table.getNumRows())); + } + + //2. infer column datatype + featureGenerator.setColumnDataTypes(table); + + //3. infer the most frequent datatype, + featureGenerator.setMostFrequentDataTypes(featuresOfAllColumns, table); + + //4. select only NE columns to further learn + List featuresOfNEColumns = selectOnlyNEColumnFeatures(featuresOfAllColumns); + if (featuresOfNEColumns.size() == 0) { + LOG.warn("This table does not contain columns that are likely to contain named entities."); + Pair> oo = new Pair<>(0, new Pair<>(1.0, false)); + rs.add(oo); + attachColumnFeature(table, featuresOfAllColumns); + return rs; + } + + featureGenerator.setEmptyCellCount(featuresOfNEColumns, table); //warning:always count empty cells first!!!!! + featureGenerator.setUniqueValueCount(featuresOfNEColumns, table); + featureGenerator.setAcronymColumnBoolean(featuresOfNEColumns, table); //warning: this must be run after counting empty cells!!! + + //5. is any NE column the only valid NE column in the table? + int onlyNECol = featureGenerator.setOnlyNEColumn(featuresOfNEColumns); + //5 - yes: + if (onlyNECol != -1) { + Pair> oo = new Pair<>(onlyNECol, new Pair<>(1.0, false)); + rs.add(oo); + for (TColumnFeature cf : featuresOfAllColumns) + table.getColumnHeader(cf.getColId()).setFeature(cf); + return rs; + } + + //6. is any NE column the only one that has no empty cells? + int onlyNonEmptyNECol = featureGenerator.setOnlyNonEmptyNEColumn(featuresOfNEColumns); + if (onlyNonEmptyNECol != -1) { + Pair> oo = + new Pair<>(onlyNonEmptyNECol, new Pair<>(1.0, false)); + rs.add(oo); + attachColumnFeature(table, featuresOfAllColumns); + return rs; + } + + //7. is any NE column the only one that has non-duplicate values on every row + // and that it is NOT an acronym column? + int onlyNonDuplicateNECol = featureGenerator.setOnlyNonDuplicateNEColumn(featuresOfNEColumns, table); + //todo: test this. original has the following block, which has no effect on results + /*if (onlyNonDuplicateNECol != -1) { + + Pair> oo = new Pair<>( + onlyNonDuplicateNECol, new Pair<>(1.0, false) + ); + // rs.add(oo); + for (TColumnFeature cf : featuresOfAllColumns) { + table.getColumnHeader(cf.getColId()).setFeature(cf); + } + // return rs; + }*/ + + //7.5 ====== this is a dangerous rule as it MAY overdo (have not checked thou) true positives ====== + List ignoreColumns = new ArrayList<>(); + featureGenerator.setInvalidHeaderTextSyntax(featuresOfNEColumns, table); + for (TColumnFeature cf : featuresOfNEColumns) { + if (cf.isInvalidPOS()) + ignoreColumns.add(cf.getColId()); + } + //if columns to be ignored due to invalid header text is less than total columns + //to be considered,we can isValidAttribute them + //otherwise, if we are told all columns should be ignored, dont isValidAttribute any candidate ne columns + if (ignoreColumns.size()>0&&ignoreColumns.size() != featuresOfNEColumns.size()) { + Iterator it = featuresOfNEColumns.iterator(); + while (it.hasNext()) { + TColumnFeature cf = it.next(); + if (cf.isInvalidPOS()) + it.remove(); + } + } + if (featuresOfNEColumns.size() == 1) { + Pair> oo = new Pair<>( + featuresOfNEColumns.get(0).getColId(), + new Pair<>(1.0, false) + ); + rs.add(oo); + attachColumnFeature(table,featuresOfAllColumns); + return rs; + } + + //8. generate feature - 1st NE column + featureGenerator.setIsFirstNEColumn(featuresOfNEColumns); + + //9. generate features - context computeElementScores + LOG.debug("Computing cm computeElementScores"); //todo more testing required for this + featureGenerator.setCMScores(featuresOfNEColumns, table); + + //10. generate features - web search matcher + if (useWS) { + computeWSScores(table, featuresOfNEColumns); + } + + //added: reset all scores to use relative scoring + normalizeScores(featuresOfNEColumns); + + //12. then let's perform reasoning based on the remaining features: + //diversity computeElementScores; 1st ne column; context computeElementScores; web search computeElementScores + final Map> finalScores = + new SubjectColumnScorerHeuristic().score(featuresOfNEColumns); + List candidates = new ArrayList<>(finalScores.keySet()); + //tiebreaker_reset(allNEColumnCandidates, inferenceScores); + + Collections.sort(candidates, (o1, o2) -> + finalScores.get(o2).getKey().compareTo(finalScores.get(o1).getKey())); + + for (int ci : candidates) { + Pair> oo = new Pair<>(ci, + finalScores.get(ci)); + rs.add(oo); + } + + for (TColumnFeature cf : featuresOfAllColumns) { + table.getColumnHeader(cf.getColId()).setFeature(cf); + } + return rs; + } + + private void computeWSScores(Table table, List featuresOfNEColumns) throws APIKeysDepletedException, IOException, ClassNotFoundException { + LOG.debug("Computing web search matching (total rows " + table.getNumRows()); + + DoubleMatrix2D scores; + if (tRowRanker != null) { + scores = featureGenerator.setWSScores(featuresOfNEColumns, table, + tRowRanker, + StoppingCriteriaInstantiator. + instantiate(stoppingCriteriaClassname, stoppingCriteriaParams), 1); + } else { + scores = featureGenerator.setWSScores(featuresOfNEColumns, table); + } + double total = 0.0; + for (TColumnFeature cf : featuresOfNEColumns) { + for (int row = 0; row < scores.rows(); row++) { + total += scores.get(row, cf.getColId()); + } + cf.setWebSearchScore(total); + total = 0.0; + } + } + + private void attachColumnFeature(Table table, List featuresOfAllColumns) { + for (TColumnFeature cf : featuresOfAllColumns) + table.getColumnHeader(cf.getColId()).setFeature(cf); + } + + //only keep TColumnFeatures that correspond to an NE column + private List selectOnlyNEColumnFeatures(List allColumnFeatures) { + List neColumns = new ArrayList<>(); + for (TColumnFeature cf : allColumnFeatures) { + if (cf.getMostFrequentDataType().getType(). + equals(DataTypeClassifier.DataType.NAMED_ENTITY)) + neColumns.add(cf); + } + //EXCEPTION: what if no NE columns found? Add any columns that are short_text + if (neColumns.size() == 0) { + for (TColumnFeature cf : allColumnFeatures) { + if (cf.getMostFrequentDataType().getType(). + equals(DataTypeClassifier.DataType.SHORT_TEXT)) + neColumns.add(cf); + } + } + return neColumns; + } + + + private void normalizeScores(List allNEColumnCandidates) { + //c. context matcher + Collections.sort(allNEColumnCandidates, (o1, o2) -> new Double(o2.getCMScore()).compareTo(o1.getCMScore())); + double maxCMScore = allNEColumnCandidates.get(0).getCMScore(); + if (maxCMScore > 0) { + for (TColumnFeature cf : allNEColumnCandidates) { + double rel_score = cf.getCMScore() / maxCMScore; + cf.setContextMatchScore(rel_score); + } + } + + //e. vote by search matcher + Collections.sort(allNEColumnCandidates, (o1, o2) -> new Double(o2.getWSScore()).compareTo(o1.getWSScore())); + double maxWSScore = allNEColumnCandidates.get(0).getWSScore(); + if (maxWSScore > 0) { + for (TColumnFeature cf : allNEColumnCandidates) { + double rel_score = cf.getWSScore() / maxWSScore; + cf.setWebSearchScore(rel_score); + } + } + } + + /*private void tiebreaker_reset( + List allNEColumnCandidates, + Map> inferenceScores) { + List ties = new ArrayList(); + double maxScore = 0; + for (Map.Entry> e : inferenceScores.entrySet()) { + if (e.getValue().getMainObject() > maxScore) { + maxScore = e.getValue().getMainObject(); + } + } + for (Map.Entry> e : inferenceScores.entrySet()) { + if (e.getValue().getMainObject() == maxScore) { + ties.add(e.getKey()); + } + } + + if (ties.size() > 1) { + + double max = 0; + int best = 0; + for (int i : ties) { + for (TColumnFeature cf : allNEColumnCandidates) { + if (cf.getColId() == i) { + double sum = cf.getUniqueCellCount() + cf.getCMScore() + + cf.getUniqueTokenCount() + cf.getWSScore() + - (cf.getEmptyCellCount() / (double) cf.getNumRows()); + + if (sum > max) { + max = sum; + best = i; + } + break; + } + } + } + // try { + inferenceScores.get(best).setMainObject( + inferenceScores.get(best).getMainObject() + 1.0 + ); + // } catch (NullPointerException n) { + // System.out.println(); + // } + } + } +*/ + //key: col id; value: computeElementScores + //currently performs following scoring: diversity; context computeElementScores; + // 1st ne column; acronym column checker; search + //results are collected as number of votes by each dimension + private Map> infer_multiFeatures_vote(List allNEColumnCandidates) { + Map> votes = new HashMap<>(); + //a. vote by diversity computeElementScores + Collections.sort(allNEColumnCandidates, new Comparator() { + @Override + public int compare(TColumnFeature o1, TColumnFeature o2) { + int compared = new Double(o2.getUniqueCellCount()).compareTo(o1.getUniqueCellCount()); + if (compared == 0) + return new Double(o2.getUniqueTokenCount()).compareTo(o1.getUniqueTokenCount()); + return compared; + } + }); + double maxDiversityScore = -1.0; + for (TColumnFeature cf : allNEColumnCandidates) { + double diversity = cf.getUniqueTokenCount() + cf.getUniqueCellCount(); + if (diversity >= maxDiversityScore && diversity != 0) { + maxDiversityScore = diversity; + votes.put(cf.getColId(), new Pair<>(1.0, false)); + } else + break; //already sorted, so following this there shouldnt be higher diversity scores + } + + + //b. vote by 1st ne column + for (TColumnFeature cf : allNEColumnCandidates) { + if (cf.isFirstNEColumn()) { + Pair entry = votes.get(cf.getColId()); + entry = entry == null ? new Pair<>(0.0, false) : entry; + Double vts = entry.getKey(); + vts = vts + 1.0; + entry = new Pair<>(vts, entry.getValue()); + votes.put(cf.getColId(), entry); + break; + } + } + //c. vote by context matcher + Collections.sort(allNEColumnCandidates, new Comparator() { + @Override + public int compare(TColumnFeature o1, TColumnFeature o2) { + return new Double(o2.getCMScore()).compareTo(o1.getCMScore()); + } + }); + double maxContextMatchScore = -1.0; + for (TColumnFeature cf : allNEColumnCandidates) { + if (cf.getCMScore() >= maxContextMatchScore && cf.getCMScore() != 0) { + maxContextMatchScore = cf.getCMScore(); + Pair entry = votes.get(cf.getColId()); + entry = entry == null ? new Pair<>(0.0, false) : entry; + Double vts = entry.getKey(); + vts = vts + 1.0; + entry = new Pair<>(vts, entry.getValue()); + votes.put(cf.getColId(), entry); + } else + break; + } + //d. vote by acronym columns + for (TColumnFeature cf : allNEColumnCandidates) { + if (cf.isAcronymColumn()) { + Pair entry = votes.get(cf.getColId()); + entry = entry == null ? new Pair<>(0.0, false) : entry; + Double vts = entry.getKey(); + vts = vts - 1.0; + entry = new Pair<>(vts, true); + votes.put(cf.getColId(), entry); + } + } + + //e. vote by search matcher + Collections.sort(allNEColumnCandidates, (o1, o2) -> new Double(o2.getWSScore()).compareTo(o1.getWSScore())); + double maxSearchMatchScore = -1.0; + for (TColumnFeature cf : allNEColumnCandidates) { + if (cf.getWSScore() >= maxSearchMatchScore && cf.getWSScore() != 0) { + maxSearchMatchScore = cf.getWSScore(); + Pair entry = votes.get(cf.getColId()); + entry = entry == null ? new Pair<>(0.0, false) : entry; + Double vts = entry.getKey(); + vts = vts + 1.0; + entry = new Pair<>(vts, entry.getValue()); + votes.put(cf.getColId(), entry); + } else + break; + } + + for (TColumnFeature cf : allNEColumnCandidates) { + if (votes.containsKey(cf.getColId())) + continue; + votes.put(cf.getColId(), new Pair<>(0.0, false)); + } + return votes; + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorer.java index f7978c6e..e68c698f 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorer.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorer.java @@ -1,14 +1,14 @@ -package uk.ac.shef.dcs.sti.core.subjectcol; - -import javafx.util.Pair; - -import java.util.List; -import java.util.Map; - -/** - * Created by - on 18/03/2016. - */ -abstract class SubjectColumnScorer { - - protected abstract Map> score(List featuresOfNEColumns); -} +package uk.ac.shef.dcs.sti.core.subjectcol; + +import javafx.util.Pair; + +import java.util.List; +import java.util.Map; + +/** + * Created by - on 18/03/2016. + */ +abstract class SubjectColumnScorer { + + protected abstract Map> score(List featuresOfNEColumns); +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorerHeuristic.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorerHeuristic.java index 769bdff2..614cf7b6 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorerHeuristic.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/SubjectColumnScorerHeuristic.java @@ -1,110 +1,110 @@ -package uk.ac.shef.dcs.sti.core.subjectcol; - -import javafx.util.Pair; - -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Created by - on 18/03/2016. - */ - class SubjectColumnScorerHeuristic extends SubjectColumnScorer { - private static final boolean USE_TOKEN_DIVERSITY = false; - private static final boolean USE_MAX_SCORE_BOOST = false; - private static final double CM_WEIGHT = 2.0; //CM computeElementScores weight - private static final boolean NORMAMLIZE_SCORE_BY_DISTANCE_TO_FIRST_COL = true; - - private static final String SCORE_COMPONENT_UC="uc"; - private static final String SCORE_COMPONENT_EMC="emc"; - private static final String SCORE_COMPONENT_AC="ac"; - private static final String SCORE_COMPONENT_DF="df"; - private static final String SCORE_COMPONENT_CM="cm"; - private static final String SCORE_COMPONENT_WS="ws"; - - - @Override - protected Map> score(List featuresOfNEColumns) { - Map> scores = new HashMap<>(); - //sort by column ids - Collections.sort(featuresOfNEColumns, (o1, o2) -> { - int compared = new Integer(o1.getColId()).compareTo(o2.getColId()); - return compared; - }); - - //find max scores to calculate computeElementScores boosters - Map max_scores_for_each_feature = new HashMap<>(); - for (int index = 0; index < featuresOfNEColumns.size(); index++) { - TColumnFeature cf = featuresOfNEColumns.get(index); - double uc = USE_TOKEN_DIVERSITY?cf.getUniqueTokenCount() + cf.getUniqueCellCount(): - cf.getUniqueCellCount(); - double cm = cf.getCMScore(); - double ws = cf.getWSScore(); - - Double max_uc = max_scores_for_each_feature.get(SCORE_COMPONENT_UC); - max_uc = max_uc == null ? 0.0 : max_uc; - if (uc > max_uc) - max_uc = uc; - max_scores_for_each_feature.put(SCORE_COMPONENT_UC, max_uc); - - Double max_cm = max_scores_for_each_feature.get(SCORE_COMPONENT_CM); - max_cm = max_cm == null ? 0.0 : max_cm; - if (cm > max_cm) - max_cm = cm; - max_scores_for_each_feature.put(SCORE_COMPONENT_CM, max_cm); - - Double max_wb = max_scores_for_each_feature.get(SCORE_COMPONENT_WS); - max_wb = max_wb == null ? 0.0 : max_wb; - if (ws > max_wb) - max_wb = ws; - max_scores_for_each_feature.put(SCORE_COMPONENT_WS, max_wb); - } - - //calculating scores - for (int index = 0; index < featuresOfNEColumns.size(); index++) { - TColumnFeature cf = featuresOfNEColumns.get(index); - double sum,uc; - - if (USE_TOKEN_DIVERSITY) - uc = cf.getUniqueTokenCount() + cf.getUniqueCellCount(); - else - uc = cf.getUniqueCellCount(); - double cm = cf.getCMScore() * CM_WEIGHT; - double ws = cf.getWSScore();// * CM_WEIGHT; todo: check this, original code uses booster - double emc = cf.getEmptyCellCount() / (double) cf.getNumRows(); - - int max_component_score_booster = 0; - for (Map.Entry e : max_scores_for_each_feature.entrySet()) { - if (e.getKey().equals(SCORE_COMPONENT_UC) && e.getValue() == uc && uc != 0) - max_component_score_booster++; - if (e.getKey().equals(SCORE_COMPONENT_CM) && e.getValue() == cm && cm != 0) - max_component_score_booster++; - if (e.getKey().equals(SCORE_COMPONENT_WS) && e.getValue() == ws && ws != 0) - max_component_score_booster++; - } - max_component_score_booster = - max_component_score_booster == 0 ? 1 : max_component_score_booster; - - - boolean f = false; - sum = uc + cm + ws - emc; - if (cf.isAcronymColumn()) { - sum = sum - 1.0; - f = true; - } - if (USE_MAX_SCORE_BOOST) - sum = Math.pow(sum, max_component_score_booster); - - - //sum=sum/(index+1); - if (NORMAMLIZE_SCORE_BY_DISTANCE_TO_FIRST_COL) { - sum = sum / Math.sqrt(index + 1); - } - Pair score_object = new Pair<>(sum, f); - scores.put(cf.getColId(), score_object); - } - - return scores; - } -} +package uk.ac.shef.dcs.sti.core.subjectcol; + +import javafx.util.Pair; + +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Created by - on 18/03/2016. + */ + class SubjectColumnScorerHeuristic extends SubjectColumnScorer { + private static final boolean USE_TOKEN_DIVERSITY = false; + private static final boolean USE_MAX_SCORE_BOOST = false; + private static final double CM_WEIGHT = 2.0; //CM computeElementScores weight + private static final boolean NORMAMLIZE_SCORE_BY_DISTANCE_TO_FIRST_COL = true; + + private static final String SCORE_COMPONENT_UC="uc"; + private static final String SCORE_COMPONENT_EMC="emc"; + private static final String SCORE_COMPONENT_AC="ac"; + private static final String SCORE_COMPONENT_DF="df"; + private static final String SCORE_COMPONENT_CM="cm"; + private static final String SCORE_COMPONENT_WS="ws"; + + + @Override + protected Map> score(List featuresOfNEColumns) { + Map> scores = new HashMap<>(); + //sort by column ids + Collections.sort(featuresOfNEColumns, (o1, o2) -> { + int compared = new Integer(o1.getColId()).compareTo(o2.getColId()); + return compared; + }); + + //find max scores to calculate computeElementScores boosters + Map max_scores_for_each_feature = new HashMap<>(); + for (int index = 0; index < featuresOfNEColumns.size(); index++) { + TColumnFeature cf = featuresOfNEColumns.get(index); + double uc = USE_TOKEN_DIVERSITY?cf.getUniqueTokenCount() + cf.getUniqueCellCount(): + cf.getUniqueCellCount(); + double cm = cf.getCMScore(); + double ws = cf.getWSScore(); + + Double max_uc = max_scores_for_each_feature.get(SCORE_COMPONENT_UC); + max_uc = max_uc == null ? 0.0 : max_uc; + if (uc > max_uc) + max_uc = uc; + max_scores_for_each_feature.put(SCORE_COMPONENT_UC, max_uc); + + Double max_cm = max_scores_for_each_feature.get(SCORE_COMPONENT_CM); + max_cm = max_cm == null ? 0.0 : max_cm; + if (cm > max_cm) + max_cm = cm; + max_scores_for_each_feature.put(SCORE_COMPONENT_CM, max_cm); + + Double max_wb = max_scores_for_each_feature.get(SCORE_COMPONENT_WS); + max_wb = max_wb == null ? 0.0 : max_wb; + if (ws > max_wb) + max_wb = ws; + max_scores_for_each_feature.put(SCORE_COMPONENT_WS, max_wb); + } + + //calculating scores + for (int index = 0; index < featuresOfNEColumns.size(); index++) { + TColumnFeature cf = featuresOfNEColumns.get(index); + double sum,uc; + + if (USE_TOKEN_DIVERSITY) + uc = cf.getUniqueTokenCount() + cf.getUniqueCellCount(); + else + uc = cf.getUniqueCellCount(); + double cm = cf.getCMScore() * CM_WEIGHT; + double ws = cf.getWSScore();// * CM_WEIGHT; todo: check this, original code uses booster + double emc = cf.getEmptyCellCount() / (double) cf.getNumRows(); + + int max_component_score_booster = 0; + for (Map.Entry e : max_scores_for_each_feature.entrySet()) { + if (e.getKey().equals(SCORE_COMPONENT_UC) && e.getValue() == uc && uc != 0) + max_component_score_booster++; + if (e.getKey().equals(SCORE_COMPONENT_CM) && e.getValue() == cm && cm != 0) + max_component_score_booster++; + if (e.getKey().equals(SCORE_COMPONENT_WS) && e.getValue() == ws && ws != 0) + max_component_score_booster++; + } + max_component_score_booster = + max_component_score_booster == 0 ? 1 : max_component_score_booster; + + + boolean f = false; + sum = uc + cm + ws - emc; + if (cf.isAcronymColumn()) { + sum = sum - 1.0; + f = true; + } + if (USE_MAX_SCORE_BOOST) + sum = Math.pow(sum, max_component_score_booster); + + + //sum=sum/(index+1); + if (NORMAMLIZE_SCORE_BY_DISTANCE_TO_FIRST_COL) { + sum = sum / Math.sqrt(index + 1); + } + Pair score_object = new Pair<>(sum, f); + scores.put(cf.getColId(), score_object); + } + + return scores; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnDataType.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnDataType.java index 272b086d..dddf8ec6 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnDataType.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnDataType.java @@ -1,57 +1,57 @@ -package uk.ac.shef.dcs.sti.core.subjectcol; - -import uk.ac.shef.dcs.sti.util.DataTypeClassifier; - -import java.io.Serializable; - -/** - */ -public class TColumnDataType implements Serializable, Comparable{ - - private static final long serialVersionUID = -1638925814006765913L; - - private DataTypeClassifier.DataType type; //what is the type of this column - private int supportingRows; //how many rows contain this type of data in this column - - public TColumnDataType(DataTypeClassifier.DataType type, int supportingRows){ - this.type = type; - this.supportingRows = supportingRows; - } - - @Override - public int compareTo(TColumnDataType o) { - if(o.getType().equals(DataTypeClassifier.DataType.EMPTY)&&!getType().equals(DataTypeClassifier.DataType.EMPTY)) - return -1; - else if(getType().equals(DataTypeClassifier.DataType.EMPTY)&&!o.getType().equals(DataTypeClassifier.DataType.EMPTY)) - return 1; - - return new Integer(o.getSupportingRows()).compareTo(getSupportingRows()); - } - - public int getSupportingRows() { - return supportingRows; - } - - public void setSupportingRows(int supportingRows) { - this.supportingRows = supportingRows; - } - - public DataTypeClassifier.DataType getType() { - return type; - } - - public void setType(DataTypeClassifier.DataType type) { - this.type = type; - } - - public boolean equals(Object o){ - if(o instanceof TColumnDataType){ - return ((TColumnDataType) o).getType().equals(getType()); - } - return false; - } - - public String toString(){ - return type +","+ getSupportingRows(); - } -} +package uk.ac.shef.dcs.sti.core.subjectcol; + +import uk.ac.shef.dcs.sti.util.DataTypeClassifier; + +import java.io.Serializable; + +/** + */ +public class TColumnDataType implements Serializable, Comparable{ + + private static final long serialVersionUID = -1638925814006765913L; + + private DataTypeClassifier.DataType type; //what is the type of this column + private int supportingRows; //how many rows contain this type of data in this column + + public TColumnDataType(DataTypeClassifier.DataType type, int supportingRows){ + this.type = type; + this.supportingRows = supportingRows; + } + + @Override + public int compareTo(TColumnDataType o) { + if(o.getType().equals(DataTypeClassifier.DataType.EMPTY)&&!getType().equals(DataTypeClassifier.DataType.EMPTY)) + return -1; + else if(getType().equals(DataTypeClassifier.DataType.EMPTY)&&!o.getType().equals(DataTypeClassifier.DataType.EMPTY)) + return 1; + + return new Integer(o.getSupportingRows()).compareTo(getSupportingRows()); + } + + public int getSupportingRows() { + return supportingRows; + } + + public void setSupportingRows(int supportingRows) { + this.supportingRows = supportingRows; + } + + public DataTypeClassifier.DataType getType() { + return type; + } + + public void setType(DataTypeClassifier.DataType type) { + this.type = type; + } + + public boolean equals(Object o){ + if(o instanceof TColumnDataType){ + return ((TColumnDataType) o).getType().equals(getType()); + } + return false; + } + + public String toString(){ + return type +","+ getSupportingRows(); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeature.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeature.java index 11a3b768..b67b2906 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeature.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeature.java @@ -1,147 +1,147 @@ -package uk.ac.shef.dcs.sti.core.subjectcol; - -import java.io.Serializable; - -/** - */ -public class TColumnFeature implements Serializable { - - private static final long serialVersionUID = -1208225814300474918L; - - private int colId; - private int numRows; - - private TColumnDataType mostFrequentDataType; - private boolean isFirstNEColumn; - private boolean isOnlyNEColumn; - private boolean isOnlyNonEmptyNEColumn; - private boolean isOnlyNonDuplicateNEColumn; - private double cellValueDiversity; - private double tokenValueDiversity; - private double contextMatchScore; - private double webSearchScore; - private int emptyCells; - private boolean isIvalidPOS; - private boolean isCode_or_Acronym; - - public TColumnFeature(int colId, int numRows){ - this.colId=colId; - this.numRows=numRows; - } - - public int getColId() { - return colId; - } - - public void setColId(int colId) { - this.colId = colId; - } - - public int getNumRows() { - return numRows; - } - - public void setNumRows(int numRows) { - this.numRows = numRows; - } - - public TColumnDataType getMostFrequentDataType() { - return mostFrequentDataType; - } - - public void setMostFrequentDataType(TColumnDataType mostFrequentDataType) { - this.mostFrequentDataType = mostFrequentDataType; - } - - public boolean isFirstNEColumn() { - return isFirstNEColumn; - } - - public void setFirstNEColumn(boolean firstNEColumn) { - isFirstNEColumn = firstNEColumn; - } - - public double getUniqueCellCount() { - return cellValueDiversity; - } - - public void setUniqueCellCount(double valueDiversity) { - this.cellValueDiversity = valueDiversity; - } - - public double getCMScore() { - return contextMatchScore; - } - - public void setContextMatchScore(double contextMatchScore) { - this.contextMatchScore = contextMatchScore; - } - - public double getWSScore() { - return webSearchScore; - } - - public void setWebSearchScore(double webSearchScore) { - this.webSearchScore = webSearchScore; - } - - public boolean isOnlyNEColumn() { - return isOnlyNEColumn; - } - - public void setOnlyNEColumn(boolean onlyNEColumn) { - isOnlyNEColumn = onlyNEColumn; - } - - public int getEmptyCellCount() { - return emptyCells; - } - - public void setEmptyCellCount(int emptyCells) { - this.emptyCells = emptyCells; - } - - public boolean isInvalidPOS() { - return isIvalidPOS; - } - - public void setInvalidPOS(boolean ivalidPOS) { - isIvalidPOS = ivalidPOS; - } - - public boolean isAcronymColumn() { - return isCode_or_Acronym; - } - - public void setAcronymColumn(boolean code_or_Acronym) { - isCode_or_Acronym = code_or_Acronym; - } - - public String toString(){ - return String.valueOf(colId); - } - - public double getUniqueTokenCount() { - return tokenValueDiversity; - } - - public void setUniqueTokenCount(double tokenValueDiversity) { - this.tokenValueDiversity = tokenValueDiversity; - } - - public boolean isOnlyNonEmptyNEColumn() { - return isOnlyNonEmptyNEColumn; - } - - public void setIsOnlyNonEmptyNEColumn(boolean isOnlyNonEmptyNEColumn) { - this.isOnlyNonEmptyNEColumn = isOnlyNonEmptyNEColumn; - } - - public boolean isOnlyNonDuplicateNEColumn() { - return isOnlyNonDuplicateNEColumn; - } - - public void setIsOnlyNonDuplicateNEColumn(boolean isOnlyNonDuplicateNEColumn) { - this.isOnlyNonDuplicateNEColumn = isOnlyNonDuplicateNEColumn; - } -} +package uk.ac.shef.dcs.sti.core.subjectcol; + +import java.io.Serializable; + +/** + */ +public class TColumnFeature implements Serializable { + + private static final long serialVersionUID = -1208225814300474918L; + + private int colId; + private int numRows; + + private TColumnDataType mostFrequentDataType; + private boolean isFirstNEColumn; + private boolean isOnlyNEColumn; + private boolean isOnlyNonEmptyNEColumn; + private boolean isOnlyNonDuplicateNEColumn; + private double cellValueDiversity; + private double tokenValueDiversity; + private double contextMatchScore; + private double webSearchScore; + private int emptyCells; + private boolean isIvalidPOS; + private boolean isCode_or_Acronym; + + public TColumnFeature(int colId, int numRows){ + this.colId=colId; + this.numRows=numRows; + } + + public int getColId() { + return colId; + } + + public void setColId(int colId) { + this.colId = colId; + } + + public int getNumRows() { + return numRows; + } + + public void setNumRows(int numRows) { + this.numRows = numRows; + } + + public TColumnDataType getMostFrequentDataType() { + return mostFrequentDataType; + } + + public void setMostFrequentDataType(TColumnDataType mostFrequentDataType) { + this.mostFrequentDataType = mostFrequentDataType; + } + + public boolean isFirstNEColumn() { + return isFirstNEColumn; + } + + public void setFirstNEColumn(boolean firstNEColumn) { + isFirstNEColumn = firstNEColumn; + } + + public double getUniqueCellCount() { + return cellValueDiversity; + } + + public void setUniqueCellCount(double valueDiversity) { + this.cellValueDiversity = valueDiversity; + } + + public double getCMScore() { + return contextMatchScore; + } + + public void setContextMatchScore(double contextMatchScore) { + this.contextMatchScore = contextMatchScore; + } + + public double getWSScore() { + return webSearchScore; + } + + public void setWebSearchScore(double webSearchScore) { + this.webSearchScore = webSearchScore; + } + + public boolean isOnlyNEColumn() { + return isOnlyNEColumn; + } + + public void setOnlyNEColumn(boolean onlyNEColumn) { + isOnlyNEColumn = onlyNEColumn; + } + + public int getEmptyCellCount() { + return emptyCells; + } + + public void setEmptyCellCount(int emptyCells) { + this.emptyCells = emptyCells; + } + + public boolean isInvalidPOS() { + return isIvalidPOS; + } + + public void setInvalidPOS(boolean ivalidPOS) { + isIvalidPOS = ivalidPOS; + } + + public boolean isAcronymColumn() { + return isCode_or_Acronym; + } + + public void setAcronymColumn(boolean code_or_Acronym) { + isCode_or_Acronym = code_or_Acronym; + } + + public String toString(){ + return String.valueOf(colId); + } + + public double getUniqueTokenCount() { + return tokenValueDiversity; + } + + public void setUniqueTokenCount(double tokenValueDiversity) { + this.tokenValueDiversity = tokenValueDiversity; + } + + public boolean isOnlyNonEmptyNEColumn() { + return isOnlyNonEmptyNEColumn; + } + + public void setIsOnlyNonEmptyNEColumn(boolean isOnlyNonEmptyNEColumn) { + this.isOnlyNonEmptyNEColumn = isOnlyNonEmptyNEColumn; + } + + public boolean isOnlyNonDuplicateNEColumn() { + return isOnlyNonDuplicateNEColumn; + } + + public void setIsOnlyNonDuplicateNEColumn(boolean isOnlyNonDuplicateNEColumn) { + this.isOnlyNonDuplicateNEColumn = isOnlyNonDuplicateNEColumn; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeatureGenerator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeatureGenerator.java index 88b53d72..d8084fcf 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeatureGenerator.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/TColumnFeatureGenerator.java @@ -1,423 +1,423 @@ -package uk.ac.shef.dcs.sti.core.subjectcol; - -import cern.colt.matrix.DoubleMatrix2D; -import cern.colt.matrix.impl.SparseDoubleMatrix2D; -import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; -import uk.ac.shef.dcs.sti.core.algorithm.tmp.sampler.TContentRowRanker; -import uk.ac.shef.dcs.sti.nlp.NLPTools; -import uk.ac.shef.dcs.sti.util.DataTypeClassifier; -import uk.ac.shef.dcs.sti.core.algorithm.tmp.stopping.StoppingCriteria; -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.core.model.TColumnHeader; -import uk.ac.shef.dcs.util.SolrCache; -import uk.ac.shef.dcs.util.StringUtils; -import uk.ac.shef.dcs.websearch.WebSearchException; -import uk.ac.shef.dcs.websearch.WebSearchFactory; -import uk.ac.shef.dcs.websearch.bing.v2.APIKeysDepletedException; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.util.*; - -/** - - */ -public class TColumnFeatureGenerator { - private CMScorer cmScorer; - private WSScorer wsScorer; - private NLPTools nlpTools; - - - public TColumnFeatureGenerator(EmbeddedSolrServer cache, - String nlpResource, - List stopWords, - String webSearchPropFile) throws IOException, WebSearchException { - cmScorer = new CMScorer(nlpResource); - wsScorer = new WSScorer(new SolrCache(cache), - new WebSearchFactory().createInstance(webSearchPropFile), - stopWords); - nlpTools = NLPTools.getInstance(nlpResource); - } - - //count number of empty cells in this column - protected void setEmptyCellCount(List features, Table table) { - for (TColumnFeature cf : features) { - int col = cf.getColId(); - - int countEmpty = 0; - for (int r = 0; r < table.getNumRows(); r++) { - String textContent = table.getContentCell(r, col).getText(); - if (textContent == null || textContent.length() == 0) - countEmpty++; - } - cf.setEmptyCellCount(countEmpty); - } - } - - - /** - * work out the ColumnDataTypes for every column in the table. For each column - * a list of candidate ColumnDataTypes is created and attached. The list is UN-sorted - * @param table - */ - public static void setColumnDataTypes(Table table) { - for (int col = 0; col < table.getNumCols(); col++) { - Map - types = new HashMap<>();//list to hold candidate data types - List numbers = new ArrayList<>(); //list to hold numbers that are potentially - //indexes of rows. The list will be then analyze, to decide if it is a continuous - //incremental sequence of numbers. if so this column is assume to be index column - boolean hasParagraph=false; - - for (int row = 0; row < table.getNumRows(); row++) { - TCell tcc = table.getContentCell(row, col); - String textContent = tcc.getText(); - if (textContent != null) { - DataTypeClassifier.DataType dt = DataTypeClassifier.classify(textContent); - tcc.setType(dt); - if (dt.equals(DataTypeClassifier.DataType.NUMBER)) - numbers.add(StringUtils.toAlphaNumericWhitechar(textContent).trim()); - if(dt.equals(DataTypeClassifier.DataType.LONG_TEXT)) - hasParagraph=true; - - TColumnDataType cdt = types.get(dt); - if (cdt == null) - cdt = new TColumnDataType(dt, 0); - cdt.setSupportingRows(cdt.getSupportingRows() + 1); - types.put(dt, cdt); - } - } - - //if any row is PARAGRAPH, it overwrites all other rows - // the column can only te long paragraph - if(hasParagraph){ - types.clear(); - DataTypeClassifier.DataType longText = DataTypeClassifier.DataType.LONG_TEXT; - types.put(longText, new TColumnDataType(longText, numbers.size())); - } - else {//check if the most frequent type is ordered numbers. - List sortedTypes = new ArrayList<>(types.values()); - Collections.sort(sortedTypes); - if (numbers.size() != 0 && sortedTypes.get(0).getType(). - equals(DataTypeClassifier.DataType.NUMBER)) { - boolean ordered = DataTypeClassifier.isOrderedNumber(numbers.toArray(new String[0])); - if (ordered) { - types.clear(); - DataTypeClassifier.DataType orderedNumber = DataTypeClassifier.DataType.ORDERED_NUMBER; - types.put(orderedNumber, new TColumnDataType(orderedNumber, numbers.size())); - } - } - } - table.getColumnHeader(col).setType(new ArrayList<>(types.values())); - } - } - - /** - * for each TColumn in the table, compute the most frequent data type for that column and - * set this value in the TColumnFeature object corresponding to that column - * @param features - * @param table - */ - protected void setMostFrequentDataTypes(List features, Table table) { - for (TColumnFeature cf : features) { - int col = cf.getColId(); - TColumnHeader header = table.getColumnHeader(col); - List types = header.getTypes(); - Collections.sort(types); - cf.setMostFrequentDataType(types.get(0)); - } - } - - //which column is the first NE column - protected void setIsFirstNEColumn(List features) { - for (TColumnFeature cf : features) { - if (cf.getMostFrequentDataType().getType().equals(DataTypeClassifier.DataType.NAMED_ENTITY)) { - cf.setFirstNEColumn(true); - break; - } - } - } - - //is there a column as the only NE column in the table - protected int setOnlyNEColumn(List features) { - List indexes = new ArrayList<>(); - for (int i = 0; i < features.size(); i++) { - if (features.get(i).getMostFrequentDataType().getType().equals(DataTypeClassifier.DataType.NAMED_ENTITY)) { - indexes.add(i); - } - } - if (indexes.size() == 1) { - features.get(indexes.get(0)).setOnlyNEColumn(true); - return features.get(indexes.get(0)).getColId(); - } - return -1; - } - - //if multiple ne columns, is there a column that is the only non-empty one? - protected int setOnlyNonEmptyNEColumn(List features) { - int onlyNonEmptyNECol = -1, num = 0; - for (int index = 0; index < features.size(); index++) { - TColumnFeature cf = features.get(index); - if (cf.getEmptyCellCount() == 0 /*&& !cf.isAcronymColumn()*/) { - num++; - if (onlyNonEmptyNECol == -1) - onlyNonEmptyNECol = index; - else - break; - } - } - if (onlyNonEmptyNECol != -1 && num == 1) { - TColumnFeature f = features.get(onlyNonEmptyNECol); - if (!f.isAcronymColumn()) { - f.setIsOnlyNonEmptyNEColumn(true); - return f.getColId(); - } - } - return -1; - } - - //if multiple ne columns, is there a column that is the only non-empty one? - protected int setOnlyNonDuplicateNEColumn(List features, - Table table) { - int onlyNonDuplicateNECol = -1, - num = 0; - for (int index = 0; index < features.size(); index++) { - TColumnFeature cf = features.get(index); - if (cf.getUniqueCellCount() == 1.0 - && !cf.isAcronymColumn() - && cf.getMostFrequentDataType().getSupportingRows() == table.getNumRows()) { - num++; - if (onlyNonDuplicateNECol == -1) - onlyNonDuplicateNECol = index; - else - break; - } - } - - if (onlyNonDuplicateNECol != -1 && num == 1) { - TColumnFeature f=features.get(onlyNonDuplicateNECol); - if (!f.isAcronymColumn()) { - f.setIsOnlyNonDuplicateNEColumn(true); - return f.getColId(); - } - } - return -1; - } - - //how many unique values do we have in a column - protected void setUniqueValueCount(List features, Table table) { - for (TColumnFeature cf : features) { - int col = cf.getColId(); - Set uniqueValues_onRows = new HashSet<>(); - Set uniqueTokens_onRows = new HashSet<>(); - int totalTokens = 0; - for (int r = 0; r < table.getNumRows(); r++) { - TCell c = table.getContentCell(r, col); - uniqueValues_onRows.add(c.getText()); - - for (String tok : c.getText().split("\\s+")) { - uniqueTokens_onRows.add(tok.trim()); - totalTokens++; - } - } - double diversity_1 = (double) uniqueValues_onRows.size() / table.getNumRows(); - double diversity_2 = (double) uniqueTokens_onRows.size() / table.getNumRows() / ((double) totalTokens / table.getNumRows()); - cf.setUniqueCellCount(diversity_1); - cf.setUniqueTokenCount(diversity_2); - } - } - - //how does each header computeElementScores against the table contexts - protected void setCMScores(List features, Table table) { - int[] cols = new int[features.size()]; - - for (int c = 0; c < features.size(); c++) { - int col = features.get(c).getColId(); - cols[c] = col; - } - - Map scores = cmScorer.score(table, cols); - for (TColumnFeature cf : features) { - Double s = scores.get(cf.getColId()); - s = s == null ? 0 : s; - cf.setContextMatchScore(s); - } - - - } - - //how does each cell on each row computeElementScores against a websearch result? - protected DoubleMatrix2D setWSScores(List features, Table table) throws APIKeysDepletedException, IOException { - DoubleMatrix2D scores = new SparseDoubleMatrix2D(table.getNumRows(), table.getNumCols()); - List searchableCols = new ArrayList();//which columns contain values that are searchable? (numbers ignored, for example) - for (int i = 0; i < features.size(); i++) { - DataTypeClassifier.DataType type = features.get(i).getMostFrequentDataType().getType(); - if (type.equals(DataTypeClassifier.DataType.NAMED_ENTITY) || type.equals(DataTypeClassifier.DataType.SHORT_TEXT)) { - searchableCols.add(features.get(i).getColId()); - } - } - - //then search row-by-row - for (int r = 0; r < table.getNumRows(); r++) { - //prepare search string - String[] values_on_the_row = new String[searchableCols.size()]; - for (int c = 0; c < searchableCols.size(); c++) { - int colId = searchableCols.get(c); - TCell cell = table.getContentCell(r, colId); - values_on_the_row[c] = wsScorer.normalize(cell.getText()); - } - - //perform search and compute matching scores - Map scores_on_the_row = wsScorer.score(values_on_the_row); - - // compute search results against each column in searchableCols - for (int index = 0; index < searchableCols.size(); index++) { - int colId = searchableCols.get(index); - String normalizedCellContent = values_on_the_row[index]; - if (normalizedCellContent.length() < 1) - continue; - - Double search_score = scores_on_the_row.get(normalizedCellContent); - search_score = search_score == null ? 0 : search_score; - scores.set(r, colId, search_score); - } - } - - return scores; - } - - - //since using web search is expensive, we can use data sampling technique to incrementally computeElementScores main column - protected DoubleMatrix2D setWSScores(List features, Table table, - TContentRowRanker sampleSelector, - StoppingCriteria stopper, - int minimumRows) throws APIKeysDepletedException, IOException { - - if (minimumRows > table.getNumRows()) - return setWSScores(features, table); - - DoubleMatrix2D scores = new SparseDoubleMatrix2D(table.getNumRows(), table.getNumCols()); - Map state = new HashMap<>(); - - List searchableCols = new ArrayList<>();//which columns contain values that are searchable? (numbers ignored, for example) - for (TColumnFeature feature : features) { - DataTypeClassifier.DataType type = feature.getMostFrequentDataType().getType(); - if (type.equals(DataTypeClassifier.DataType.NAMED_ENTITY) || type.equals(DataTypeClassifier.DataType.SHORT_TEXT)) { - searchableCols.add(feature.getColId()); - } - } - - - int[] rowRanking = sampleSelector.select(table); - int rows = 0; - //then search row-by-row - for (int r : rowRanking) { - //prepare search string - String[] values_in_the_cell = new String[searchableCols.size()]; - for (int c = 0; c < searchableCols.size(); c++) { - int colId = searchableCols.get(c); - TCell cell = table.getContentCell(r, colId); - values_in_the_cell[c] = wsScorer.normalize(cell.getText()); - } - - //perform search and compute matching scores - Map ws_on_row = wsScorer.score(values_in_the_cell); - - // compute search results against each column in searchableCols - for (int index = 0; index < searchableCols.size(); index++) { - int colId = searchableCols.get(index); - String normalizedCellContent = values_in_the_cell[index]; - if (normalizedCellContent.length() < 1) - continue; - - Double search_score = ws_on_row.get(normalizedCellContent); - search_score = search_score == null ? 0 : search_score; - scores.set(r, colId, search_score); - - //also update State - Double score_in_the_state = state.get(colId); - score_in_the_state = score_in_the_state == null ? 0 : score_in_the_state; - score_in_the_state = score_in_the_state + search_score; - state.put(colId, score_in_the_state); - } - - rows++; - if (/*rows>=minimumRows && */stopper.stop(state, table.getNumRows())) - break; - } - - return scores; - } - - //check the syntactic feature (POS) of the header title. invalid POS include: prep (in theory only noun is valid. but - //that may over-eliminate true pos - protected void setInvalidHeaderTextSyntax(List allNEColumnCandidates, Table table) { - for (TColumnFeature cf : allNEColumnCandidates) { - int col = cf.getColId(); - String headerText = table.getColumnHeader(col).getHeaderText(); - - String[] tags = nlpTools.getPosTagger().tag(headerText.toLowerCase().split("\\s+")); - if (tags[tags.length - 1].equals("IN") || tags[tags.length - 1].equals("TO")) - cf.setInvalidPOS(true); - } - - } - - /** - * make a guess if this column contains only acronym values - * - * if, excluding empty cells, #of cells that are acronyms are more than those that are not, - * a column is then considered to contain only acronym - * @param featuresOfNEColumns - * @param table - */ - protected void setAcronymColumnBoolean(List featuresOfNEColumns, Table table) { - for (TColumnFeature cf : featuresOfNEColumns) { - int col = cf.getColId(); - int countAcronym_or_Code = 0; - for (int r = 0; r < table.getNumRows(); r++) { - String cellContent = table.getContentCell(r, col).getText().replaceAll("\\s+", " ").trim(); - if (cellContent.length() == 0) - continue; - if (cellContent.length() < 15) { - int countWhiteSpace = 0, countLetters = 0, countDigits = 0; - boolean letters_are_all_cap = true; - for (int index = 0; index < cellContent.length(); index++) { - char c = cellContent.charAt(index); - if (Character.isWhitespace(c)) - countWhiteSpace++; - else { - if (Character.isLetter(c)) { - countLetters++; - if (!Character.isUpperCase(c)) - letters_are_all_cap = false; - } else if (Character.isDigit(c)) { - countDigits++; - } - } - } - - //int countSymbols = countNonWhiteSpace - countLetters - countDigits; - if (countWhiteSpace == 0 && countDigits > 0 && countLetters > 0) { //no white space, mixture of letters (whatever case) and digits - countAcronym_or_Code++; - // System.out.println(cellContent+" \tno white space, mixture of letters and digits"); - } else if (countWhiteSpace == 0 && countLetters > 0 && letters_are_all_cap && cellContent.length() < 6) { //no white space, all uppercase letters (total < 6) - countAcronym_or_Code++; - // System.out.println(cellContent+" \tno white space, all uppercase letters (total < 6)"); - } else if (countWhiteSpace == 1 && letters_are_all_cap) { //1 white space, letters must all be uppercase - countAcronym_or_Code++; - // System.out.println(cellContent+" \t1 white space, letters must all be uppercase"); - } - } - - - } - if (countAcronym_or_Code > (table.getNumRows() - cf.getEmptyCellCount() - countAcronym_or_Code)) - cf.setAcronymColumn(true); - } - - } - - -} +package uk.ac.shef.dcs.sti.core.subjectcol; + +import cern.colt.matrix.DoubleMatrix2D; +import cern.colt.matrix.impl.SparseDoubleMatrix2D; +import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; +import uk.ac.shef.dcs.sti.core.algorithm.tmp.sampler.TContentRowRanker; +import uk.ac.shef.dcs.sti.nlp.NLPTools; +import uk.ac.shef.dcs.sti.util.DataTypeClassifier; +import uk.ac.shef.dcs.sti.core.algorithm.tmp.stopping.StoppingCriteria; +import uk.ac.shef.dcs.sti.core.model.TCell; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.core.model.TColumnHeader; +import uk.ac.shef.dcs.util.SolrCache; +import uk.ac.shef.dcs.util.StringUtils; +import uk.ac.shef.dcs.websearch.WebSearchException; +import uk.ac.shef.dcs.websearch.WebSearchFactory; +import uk.ac.shef.dcs.websearch.bing.v2.APIKeysDepletedException; + +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.util.*; + +/** + + */ +public class TColumnFeatureGenerator { + private CMScorer cmScorer; + private WSScorer wsScorer; + private NLPTools nlpTools; + + + public TColumnFeatureGenerator(EmbeddedSolrServer cache, + String nlpResource, + List stopWords, + String webSearchPropFile) throws IOException, WebSearchException { + cmScorer = new CMScorer(nlpResource); + wsScorer = new WSScorer(new SolrCache(cache), + new WebSearchFactory().createInstance(webSearchPropFile), + stopWords); + nlpTools = NLPTools.getInstance(nlpResource); + } + + //count number of empty cells in this column + protected void setEmptyCellCount(List features, Table table) { + for (TColumnFeature cf : features) { + int col = cf.getColId(); + + int countEmpty = 0; + for (int r = 0; r < table.getNumRows(); r++) { + String textContent = table.getContentCell(r, col).getText(); + if (textContent == null || textContent.length() == 0) + countEmpty++; + } + cf.setEmptyCellCount(countEmpty); + } + } + + + /** + * work out the ColumnDataTypes for every column in the table. For each column + * a list of candidate ColumnDataTypes is created and attached. The list is UN-sorted + * @param table + */ + public static void setColumnDataTypes(Table table) { + for (int col = 0; col < table.getNumCols(); col++) { + Map + types = new HashMap<>();//list to hold candidate data types + List numbers = new ArrayList<>(); //list to hold numbers that are potentially + //indexes of rows. The list will be then analyze, to decide if it is a continuous + //incremental sequence of numbers. if so this column is assume to be index column + boolean hasParagraph=false; + + for (int row = 0; row < table.getNumRows(); row++) { + TCell tcc = table.getContentCell(row, col); + String textContent = tcc.getText(); + if (textContent != null) { + DataTypeClassifier.DataType dt = DataTypeClassifier.classify(textContent); + tcc.setType(dt); + if (dt.equals(DataTypeClassifier.DataType.NUMBER)) + numbers.add(StringUtils.toAlphaNumericWhitechar(textContent).trim()); + if(dt.equals(DataTypeClassifier.DataType.LONG_TEXT)) + hasParagraph=true; + + TColumnDataType cdt = types.get(dt); + if (cdt == null) + cdt = new TColumnDataType(dt, 0); + cdt.setSupportingRows(cdt.getSupportingRows() + 1); + types.put(dt, cdt); + } + } + + //if any row is PARAGRAPH, it overwrites all other rows + // the column can only te long paragraph + if(hasParagraph){ + types.clear(); + DataTypeClassifier.DataType longText = DataTypeClassifier.DataType.LONG_TEXT; + types.put(longText, new TColumnDataType(longText, numbers.size())); + } + else {//check if the most frequent type is ordered numbers. + List sortedTypes = new ArrayList<>(types.values()); + Collections.sort(sortedTypes); + if (numbers.size() != 0 && sortedTypes.get(0).getType(). + equals(DataTypeClassifier.DataType.NUMBER)) { + boolean ordered = DataTypeClassifier.isOrderedNumber(numbers.toArray(new String[0])); + if (ordered) { + types.clear(); + DataTypeClassifier.DataType orderedNumber = DataTypeClassifier.DataType.ORDERED_NUMBER; + types.put(orderedNumber, new TColumnDataType(orderedNumber, numbers.size())); + } + } + } + table.getColumnHeader(col).setType(new ArrayList<>(types.values())); + } + } + + /** + * for each TColumn in the table, compute the most frequent data type for that column and + * set this value in the TColumnFeature object corresponding to that column + * @param features + * @param table + */ + protected void setMostFrequentDataTypes(List features, Table table) { + for (TColumnFeature cf : features) { + int col = cf.getColId(); + TColumnHeader header = table.getColumnHeader(col); + List types = header.getTypes(); + Collections.sort(types); + cf.setMostFrequentDataType(types.get(0)); + } + } + + //which column is the first NE column + protected void setIsFirstNEColumn(List features) { + for (TColumnFeature cf : features) { + if (cf.getMostFrequentDataType().getType().equals(DataTypeClassifier.DataType.NAMED_ENTITY)) { + cf.setFirstNEColumn(true); + break; + } + } + } + + //is there a column as the only NE column in the table + protected int setOnlyNEColumn(List features) { + List indexes = new ArrayList<>(); + for (int i = 0; i < features.size(); i++) { + if (features.get(i).getMostFrequentDataType().getType().equals(DataTypeClassifier.DataType.NAMED_ENTITY)) { + indexes.add(i); + } + } + if (indexes.size() == 1) { + features.get(indexes.get(0)).setOnlyNEColumn(true); + return features.get(indexes.get(0)).getColId(); + } + return -1; + } + + //if multiple ne columns, is there a column that is the only non-empty one? + protected int setOnlyNonEmptyNEColumn(List features) { + int onlyNonEmptyNECol = -1, num = 0; + for (int index = 0; index < features.size(); index++) { + TColumnFeature cf = features.get(index); + if (cf.getEmptyCellCount() == 0 /*&& !cf.isAcronymColumn()*/) { + num++; + if (onlyNonEmptyNECol == -1) + onlyNonEmptyNECol = index; + else + break; + } + } + if (onlyNonEmptyNECol != -1 && num == 1) { + TColumnFeature f = features.get(onlyNonEmptyNECol); + if (!f.isAcronymColumn()) { + f.setIsOnlyNonEmptyNEColumn(true); + return f.getColId(); + } + } + return -1; + } + + //if multiple ne columns, is there a column that is the only non-empty one? + protected int setOnlyNonDuplicateNEColumn(List features, + Table table) { + int onlyNonDuplicateNECol = -1, + num = 0; + for (int index = 0; index < features.size(); index++) { + TColumnFeature cf = features.get(index); + if (cf.getUniqueCellCount() == 1.0 + && !cf.isAcronymColumn() + && cf.getMostFrequentDataType().getSupportingRows() == table.getNumRows()) { + num++; + if (onlyNonDuplicateNECol == -1) + onlyNonDuplicateNECol = index; + else + break; + } + } + + if (onlyNonDuplicateNECol != -1 && num == 1) { + TColumnFeature f=features.get(onlyNonDuplicateNECol); + if (!f.isAcronymColumn()) { + f.setIsOnlyNonDuplicateNEColumn(true); + return f.getColId(); + } + } + return -1; + } + + //how many unique values do we have in a column + protected void setUniqueValueCount(List features, Table table) { + for (TColumnFeature cf : features) { + int col = cf.getColId(); + Set uniqueValues_onRows = new HashSet<>(); + Set uniqueTokens_onRows = new HashSet<>(); + int totalTokens = 0; + for (int r = 0; r < table.getNumRows(); r++) { + TCell c = table.getContentCell(r, col); + uniqueValues_onRows.add(c.getText()); + + for (String tok : c.getText().split("\\s+")) { + uniqueTokens_onRows.add(tok.trim()); + totalTokens++; + } + } + double diversity_1 = (double) uniqueValues_onRows.size() / table.getNumRows(); + double diversity_2 = (double) uniqueTokens_onRows.size() / table.getNumRows() / ((double) totalTokens / table.getNumRows()); + cf.setUniqueCellCount(diversity_1); + cf.setUniqueTokenCount(diversity_2); + } + } + + //how does each header computeElementScores against the table contexts + protected void setCMScores(List features, Table table) { + int[] cols = new int[features.size()]; + + for (int c = 0; c < features.size(); c++) { + int col = features.get(c).getColId(); + cols[c] = col; + } + + Map scores = cmScorer.score(table, cols); + for (TColumnFeature cf : features) { + Double s = scores.get(cf.getColId()); + s = s == null ? 0 : s; + cf.setContextMatchScore(s); + } + + + } + + //how does each cell on each row computeElementScores against a websearch result? + protected DoubleMatrix2D setWSScores(List features, Table table) throws APIKeysDepletedException, IOException { + DoubleMatrix2D scores = new SparseDoubleMatrix2D(table.getNumRows(), table.getNumCols()); + List searchableCols = new ArrayList();//which columns contain values that are searchable? (numbers ignored, for example) + for (int i = 0; i < features.size(); i++) { + DataTypeClassifier.DataType type = features.get(i).getMostFrequentDataType().getType(); + if (type.equals(DataTypeClassifier.DataType.NAMED_ENTITY) || type.equals(DataTypeClassifier.DataType.SHORT_TEXT)) { + searchableCols.add(features.get(i).getColId()); + } + } + + //then search row-by-row + for (int r = 0; r < table.getNumRows(); r++) { + //prepare search string + String[] values_on_the_row = new String[searchableCols.size()]; + for (int c = 0; c < searchableCols.size(); c++) { + int colId = searchableCols.get(c); + TCell cell = table.getContentCell(r, colId); + values_on_the_row[c] = wsScorer.normalize(cell.getText()); + } + + //perform search and compute matching scores + Map scores_on_the_row = wsScorer.score(values_on_the_row); + + // compute search results against each column in searchableCols + for (int index = 0; index < searchableCols.size(); index++) { + int colId = searchableCols.get(index); + String normalizedCellContent = values_on_the_row[index]; + if (normalizedCellContent.length() < 1) + continue; + + Double search_score = scores_on_the_row.get(normalizedCellContent); + search_score = search_score == null ? 0 : search_score; + scores.set(r, colId, search_score); + } + } + + return scores; + } + + + //since using web search is expensive, we can use data sampling technique to incrementally computeElementScores main column + protected DoubleMatrix2D setWSScores(List features, Table table, + TContentRowRanker sampleSelector, + StoppingCriteria stopper, + int minimumRows) throws APIKeysDepletedException, IOException { + + if (minimumRows > table.getNumRows()) + return setWSScores(features, table); + + DoubleMatrix2D scores = new SparseDoubleMatrix2D(table.getNumRows(), table.getNumCols()); + Map state = new HashMap<>(); + + List searchableCols = new ArrayList<>();//which columns contain values that are searchable? (numbers ignored, for example) + for (TColumnFeature feature : features) { + DataTypeClassifier.DataType type = feature.getMostFrequentDataType().getType(); + if (type.equals(DataTypeClassifier.DataType.NAMED_ENTITY) || type.equals(DataTypeClassifier.DataType.SHORT_TEXT)) { + searchableCols.add(feature.getColId()); + } + } + + + int[] rowRanking = sampleSelector.select(table); + int rows = 0; + //then search row-by-row + for (int r : rowRanking) { + //prepare search string + String[] values_in_the_cell = new String[searchableCols.size()]; + for (int c = 0; c < searchableCols.size(); c++) { + int colId = searchableCols.get(c); + TCell cell = table.getContentCell(r, colId); + values_in_the_cell[c] = wsScorer.normalize(cell.getText()); + } + + //perform search and compute matching scores + Map ws_on_row = wsScorer.score(values_in_the_cell); + + // compute search results against each column in searchableCols + for (int index = 0; index < searchableCols.size(); index++) { + int colId = searchableCols.get(index); + String normalizedCellContent = values_in_the_cell[index]; + if (normalizedCellContent.length() < 1) + continue; + + Double search_score = ws_on_row.get(normalizedCellContent); + search_score = search_score == null ? 0 : search_score; + scores.set(r, colId, search_score); + + //also update State + Double score_in_the_state = state.get(colId); + score_in_the_state = score_in_the_state == null ? 0 : score_in_the_state; + score_in_the_state = score_in_the_state + search_score; + state.put(colId, score_in_the_state); + } + + rows++; + if (/*rows>=minimumRows && */stopper.stop(state, table.getNumRows())) + break; + } + + return scores; + } + + //check the syntactic feature (POS) of the header title. invalid POS include: prep (in theory only noun is valid. but + //that may over-eliminate true pos + protected void setInvalidHeaderTextSyntax(List allNEColumnCandidates, Table table) { + for (TColumnFeature cf : allNEColumnCandidates) { + int col = cf.getColId(); + String headerText = table.getColumnHeader(col).getHeaderText(); + + String[] tags = nlpTools.getPosTagger().tag(headerText.toLowerCase().split("\\s+")); + if (tags[tags.length - 1].equals("IN") || tags[tags.length - 1].equals("TO")) + cf.setInvalidPOS(true); + } + + } + + /** + * make a guess if this column contains only acronym values + * + * if, excluding empty cells, #of cells that are acronyms are more than those that are not, + * a column is then considered to contain only acronym + * @param featuresOfNEColumns + * @param table + */ + protected void setAcronymColumnBoolean(List featuresOfNEColumns, Table table) { + for (TColumnFeature cf : featuresOfNEColumns) { + int col = cf.getColId(); + int countAcronym_or_Code = 0; + for (int r = 0; r < table.getNumRows(); r++) { + String cellContent = table.getContentCell(r, col).getText().replaceAll("\\s+", " ").trim(); + if (cellContent.length() == 0) + continue; + if (cellContent.length() < 15) { + int countWhiteSpace = 0, countLetters = 0, countDigits = 0; + boolean letters_are_all_cap = true; + for (int index = 0; index < cellContent.length(); index++) { + char c = cellContent.charAt(index); + if (Character.isWhitespace(c)) + countWhiteSpace++; + else { + if (Character.isLetter(c)) { + countLetters++; + if (!Character.isUpperCase(c)) + letters_are_all_cap = false; + } else if (Character.isDigit(c)) { + countDigits++; + } + } + } + + //int countSymbols = countNonWhiteSpace - countLetters - countDigits; + if (countWhiteSpace == 0 && countDigits > 0 && countLetters > 0) { //no white space, mixture of letters (whatever case) and digits + countAcronym_or_Code++; + // System.out.println(cellContent+" \tno white space, mixture of letters and digits"); + } else if (countWhiteSpace == 0 && countLetters > 0 && letters_are_all_cap && cellContent.length() < 6) { //no white space, all uppercase letters (total < 6) + countAcronym_or_Code++; + // System.out.println(cellContent+" \tno white space, all uppercase letters (total < 6)"); + } else if (countWhiteSpace == 1 && letters_are_all_cap) { //1 white space, letters must all be uppercase + countAcronym_or_Code++; + // System.out.println(cellContent+" \t1 white space, letters must all be uppercase"); + } + } + + + } + if (countAcronym_or_Code > (table.getNumRows() - cf.getEmptyCellCount() - countAcronym_or_Code)) + cf.setAcronymColumn(true); + } + + } + + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/WSScorer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/WSScorer.java index 5352a16c..29a33401 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/WSScorer.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/core/subjectcol/WSScorer.java @@ -1,294 +1,294 @@ -package uk.ac.shef.dcs.sti.core.subjectcol; - -import org.apache.log4j.Logger; -import org.apache.solr.client.solrj.SolrServerException; -import uk.ac.shef.dcs.sti.nlp.TermFreqCounter; -import uk.ac.shef.dcs.util.SolrCache; -import uk.ac.shef.dcs.websearch.WebSearch; -import uk.ac.shef.dcs.websearch.bing.v2.APIKeysDepletedException; -import uk.ac.shef.dcs.websearch.WebSearchResultDoc; - -import java.io.IOException; -import java.io.InputStream; -import java.util.*; - -/** - */ -public class WSScorer { - protected SolrCache cache; - protected WebSearch searcher; - protected static final double TITLE_WEIGHT_SCALAR = 2.0; //if a value is found in title of a search result document, it receives higher weight - protected static final boolean WORD_ORDER_MATTERS = false; - protected TermFreqCounter counter = new TermFreqCounter(); - protected List stopWords; - - protected static final Logger LOG = Logger.getLogger(WSScorer.class.getName()); - - - public WSScorer(SolrCache cache, WebSearch searcher, - List stopWords) { - this.cache = cache; - this.searcher = searcher; - this.stopWords = stopWords; - } - - @SuppressWarnings("unchecked") - protected List findInCache(String queryId) throws IOException, ClassNotFoundException, SolrServerException { - return (List)cache.retrieve(queryId); - } - - /** - * Score each string value using WS - * - * @param values - * @return - * @throws APIKeysDepletedException - * @throws IOException - */ - public Map score(String... values) throws APIKeysDepletedException, IOException { - String queryId = createSolrCacheQuery(values); - //1. check cache - List result = null; - try { - result = findInCache(queryId); - } catch (Exception e) { - // e.printStackTrace(); - } - - //2. if not in cache, perform web search, computeElementScores results, and cache results - if (result == null/*||result.size()==0*/) { - Date start = new Date(); - try { - InputStream is = searcher.search(queryId); - List searchResult = searcher.getResultParser().parse(is); - result = searchResult == null ? new ArrayList<>() : searchResult; - - cache.cache(queryId, result, true); - } catch (Exception e) { - LOG.warn("Caching Web Search Results failed: " + e); - } - LOG.debug("\tQueryBing:" + (new Date().getTime() - start.getTime())); - } - - return score(result, values); - } - - //take each normlised value, computeElementScores it against each search result document and sum up the scores - protected Map score(List searchResult, String... normalizedValues) { - Map scores = new HashMap<>(); - - for (WebSearchResultDoc doc : searchResult) { - String title = doc.getTitle(); - score(scores, title, TITLE_WEIGHT_SCALAR, normalizedValues); - String desc = doc.getDescription(); - score(scores, desc, 1.0, normalizedValues); - } - - return scores; - } - - - - private void score(Map scores, String context, double contextWeightScalar, String... normalizedValues) { - context = normalize(context); - - Map> offsets = new HashMap<>(); - for (String v : normalizedValues) { - //v=normalize(v); - if (v.length() < 1) continue; //isValidAttribute 1 char tokens - Set os = counter.countOffsets(v, context); - offsets.put(v, os); - } - - Map> phrase_to_composing_tokens = new HashMap<>(); - Map> composing_token_offsets = new HashMap<>(); - //then the composing tokens for each normalizedValue - for (String v : normalizedValues) { - String[] toks = v.split("\\s+"); - if (toks.length == 1) - continue; - Set composing_toks = new HashSet<>(); - for (String t : toks) { - //t = t.trim(); - if (ignore(t)) continue; - composing_toks.add(t); - if (offsets.get(t) != null) { - composing_token_offsets.put(t, offsets.get(t)); - } else if (composing_token_offsets.get(t) == null) { - Set os = counter.countOffsets(t, context); - composing_token_offsets.put(t, os); - } - } - phrase_to_composing_tokens.put(v, composing_toks); - } - //discount double counting due to string inclusion between cells - for (String a : offsets.keySet()) { - for (String b : offsets.keySet()) { - if (a.equals(b)) continue; - Set offsets_a = offsets.get(a); - Set offsets_b = offsets.get(b); - if (offsets_a.size() == 0 || offsets_b.size() == 0) continue; - if (a.contains(b)) { - removeOverlapOffsets(offsets.get(b), offsets.get(a), a.length()); - //offs ets.get(b).removeAll(offsets.get(a)); //string a contains b, so freq of b should be decreased by the freq of a - } else if (b.contains(a)) { - removeOverlapOffsets(offsets.get(a), offsets.get(b), b.length()); - //offsets.get(a).removeAll(offsets.get(b)); - } - } - } - //discount double counting due to string inclusion between a cell's value and its composing tokens - for (String a : offsets.keySet()) { - for (String b : composing_token_offsets.keySet()) { - if (a.equals(b)) continue; - Set offsets_a = offsets.get(a); - Set offsets_b = composing_token_offsets.get(b); - if (offsets_a.size() == 0 || offsets_b == null || offsets_b.size() == 0) continue; - removeOverlapOffsets(offsets_b, offsets_a, a.length()); - //offs ets.get(b).removeAll(offsets.get(a)); //string a contains b, so freq of b should be decreased by the freq of a - } - } - - //second of all, understand ordering - final Map firstOccurrenceOfPhrase = new HashMap<>(); - for (Map.Entry> entry : offsets.entrySet()) { - if (entry.getValue().size() == 0) - continue; - int min = Integer.MAX_VALUE; - for (Integer i : entry.getValue()) { - if (i < min) - min = i; - } - firstOccurrenceOfPhrase.put(entry.getKey(), min); - } - final Map firstOccurrenceOfComposingTokens = new HashMap<>(); - for (Map.Entry> entry : composing_token_offsets.entrySet()) { - if (entry.getValue().size() == 0) - continue; - int min = Integer.MAX_VALUE; - for (Integer i : entry.getValue()) { - if (i < min) - min = i; - } - firstOccurrenceOfComposingTokens.put(entry.getKey(), min); - } - - List original_phrases = new ArrayList<>(firstOccurrenceOfPhrase.keySet()); - Collections.sort(original_phrases, (o1, o2) - -> new Integer(firstOccurrenceOfPhrase.get(o1)).compareTo(firstOccurrenceOfPhrase.get(o2))); - - List composing_tokens = new ArrayList<>(firstOccurrenceOfComposingTokens.keySet()); - Collections.sort(composing_tokens, (o1, o2) - -> new Integer(firstOccurrenceOfComposingTokens.get(o1)).compareTo(firstOccurrenceOfComposingTokens.get(o2))); - - - //last of all, compute scores - double ordering_multiplier_original = 1.0 / original_phrases.size(); - double order_scalar_composing_tokens = 1.0 / composing_tokens.size(); - - for (int o = 0; o < original_phrases.size(); o++) { - String phrase = original_phrases.get(o); - if (offsets.get(phrase) != null) { - int freq = offsets.get(phrase).size(); - if (freq > 0) { //exact cell value found - //double ordering_weight_multiplier = (original_phrases.size() - o) * ordering_multiplier_original; - double score_to_increment = offsets.get(phrase).size() * /*ordering_weight_multiplier*/1.0 * contextWeightScalar; - - Double score = scores.get(phrase); - score = score == null ? 0.0 : score; - score = score + score_to_increment; - scores.put(phrase, score); - } - } - } - for (int o = 0; o < composing_tokens.size(); o++) { - String candidate = composing_tokens.get(o); - if (composing_token_offsets.get(candidate) != null) { - int freq = composing_token_offsets.get(candidate).size(); - if (freq > 0) { //exact cell value found - double order_weight_scalar = (composing_tokens.size() - o) * order_scalar_composing_tokens; - if(!WORD_ORDER_MATTERS) - order_weight_scalar=1.0; - double score_to_increment = composing_token_offsets.get(candidate).size() - * order_weight_scalar * contextWeightScalar; - - //find corresponding parent cell value - for (Map.Entry> e : phrase_to_composing_tokens.entrySet()) { - if (e.getValue().contains(candidate)) { - score_to_increment = boostScoreByComposingTokens( - score_to_increment, e.getKey() - ); - Double score = scores.get(e.getKey()); - score = score == null ? 0.0 : score; - score = score + score_to_increment; - scores.put(e.getKey(), score); - } - } - } - } - } - - } - - private boolean ignore(String t) { - if (stopWords.contains(t)) - return true; - try { - Long.valueOf(t); //isValidAttribute numbers - return true; - } catch (Exception e) { - } - return false; - } - - - private double boostScoreByComposingTokens( - double score_to_increment_by_component, - String original) { - int length = original.split("\\s+").length; - if (length < 2) return 0; - return score_to_increment_by_component * (1.0 / (length/* * length*/)); - } - - - protected String normalize(String value) { - return value.replaceAll("[^\\p{L}\\s\\d]", " ").replaceAll("\\s+", " ").trim().toLowerCase(); - } - - //remove short phrase's start offsets if it is part of a longer phrase - protected void removeOverlapOffsets(Set shorterPhraseStarts, Set longerPhraseStarts, int longerPhraseLength) { - Iterator it = shorterPhraseStarts.iterator(); - while (it.hasNext()) { - Integer s = it.next(); - for (int st : longerPhraseStarts) { - if (st <= s && s < st + longerPhraseLength) { //the shorter phrase's start is included in the longer phrase boundary - it.remove(); - break; - } - } - } - } - - protected String createSolrCacheQuery(String... values) { - StringBuilder sb = new StringBuilder(); - for (String v : values) - sb.append(v).append(" "); - return sb.toString().trim(); - } - - - /* public static void main(String[] args) throws APIKeysDepletedException, IOException { - String[] accountKeys = new String[]{"fXhmgvVQnz1aLBti87+AZlPYDXcQL0G9L2dVAav+aK0="}; - WSScorer matcher = new WSScorer( - new HeaderWebsearchMatcherCache("D:\\Work\\lodiedata\\tableminer_cache\\solrindex_cache\\zookeeper\\solr", - "collection1"), - new BingSearch(accountKeys), - new ArrayList() - ); - matcher.computeElementScores("House of Cards", "Peter David"); - matcher.computeElementScores("University of Sheffield", "Sheffield", "United Kingdom"); - matcher.computeElementScores("House of Cards", "Peter David"); - matcher.cache.closeConnection(); - }*/ - -} +package uk.ac.shef.dcs.sti.core.subjectcol; + +import org.apache.log4j.Logger; +import org.apache.solr.client.solrj.SolrServerException; +import uk.ac.shef.dcs.sti.nlp.TermFreqCounter; +import uk.ac.shef.dcs.util.SolrCache; +import uk.ac.shef.dcs.websearch.WebSearch; +import uk.ac.shef.dcs.websearch.bing.v2.APIKeysDepletedException; +import uk.ac.shef.dcs.websearch.WebSearchResultDoc; + +import java.io.IOException; +import java.io.InputStream; +import java.util.*; + +/** + */ +public class WSScorer { + protected SolrCache cache; + protected WebSearch searcher; + protected static final double TITLE_WEIGHT_SCALAR = 2.0; //if a value is found in title of a search result document, it receives higher weight + protected static final boolean WORD_ORDER_MATTERS = false; + protected TermFreqCounter counter = new TermFreqCounter(); + protected List stopWords; + + protected static final Logger LOG = Logger.getLogger(WSScorer.class.getName()); + + + public WSScorer(SolrCache cache, WebSearch searcher, + List stopWords) { + this.cache = cache; + this.searcher = searcher; + this.stopWords = stopWords; + } + + @SuppressWarnings("unchecked") + protected List findInCache(String queryId) throws IOException, ClassNotFoundException, SolrServerException { + return (List)cache.retrieve(queryId); + } + + /** + * Score each string value using WS + * + * @param values + * @return + * @throws APIKeysDepletedException + * @throws IOException + */ + public Map score(String... values) throws APIKeysDepletedException, IOException { + String queryId = createSolrCacheQuery(values); + //1. check cache + List result = null; + try { + result = findInCache(queryId); + } catch (Exception e) { + // e.printStackTrace(); + } + + //2. if not in cache, perform web search, computeElementScores results, and cache results + if (result == null/*||result.size()==0*/) { + Date start = new Date(); + try { + InputStream is = searcher.search(queryId); + List searchResult = searcher.getResultParser().parse(is); + result = searchResult == null ? new ArrayList<>() : searchResult; + + cache.cache(queryId, result, true); + } catch (Exception e) { + LOG.warn("Caching Web Search Results failed: " + e); + } + LOG.debug("\tQueryBing:" + (new Date().getTime() - start.getTime())); + } + + return score(result, values); + } + + //take each normlised value, computeElementScores it against each search result document and sum up the scores + protected Map score(List searchResult, String... normalizedValues) { + Map scores = new HashMap<>(); + + for (WebSearchResultDoc doc : searchResult) { + String title = doc.getTitle(); + score(scores, title, TITLE_WEIGHT_SCALAR, normalizedValues); + String desc = doc.getDescription(); + score(scores, desc, 1.0, normalizedValues); + } + + return scores; + } + + + + private void score(Map scores, String context, double contextWeightScalar, String... normalizedValues) { + context = normalize(context); + + Map> offsets = new HashMap<>(); + for (String v : normalizedValues) { + //v=normalize(v); + if (v.length() < 1) continue; //isValidAttribute 1 char tokens + Set os = counter.countOffsets(v, context); + offsets.put(v, os); + } + + Map> phrase_to_composing_tokens = new HashMap<>(); + Map> composing_token_offsets = new HashMap<>(); + //then the composing tokens for each normalizedValue + for (String v : normalizedValues) { + String[] toks = v.split("\\s+"); + if (toks.length == 1) + continue; + Set composing_toks = new HashSet<>(); + for (String t : toks) { + //t = t.trim(); + if (ignore(t)) continue; + composing_toks.add(t); + if (offsets.get(t) != null) { + composing_token_offsets.put(t, offsets.get(t)); + } else if (composing_token_offsets.get(t) == null) { + Set os = counter.countOffsets(t, context); + composing_token_offsets.put(t, os); + } + } + phrase_to_composing_tokens.put(v, composing_toks); + } + //discount double counting due to string inclusion between cells + for (String a : offsets.keySet()) { + for (String b : offsets.keySet()) { + if (a.equals(b)) continue; + Set offsets_a = offsets.get(a); + Set offsets_b = offsets.get(b); + if (offsets_a.size() == 0 || offsets_b.size() == 0) continue; + if (a.contains(b)) { + removeOverlapOffsets(offsets.get(b), offsets.get(a), a.length()); + //offs ets.get(b).removeAll(offsets.get(a)); //string a contains b, so freq of b should be decreased by the freq of a + } else if (b.contains(a)) { + removeOverlapOffsets(offsets.get(a), offsets.get(b), b.length()); + //offsets.get(a).removeAll(offsets.get(b)); + } + } + } + //discount double counting due to string inclusion between a cell's value and its composing tokens + for (String a : offsets.keySet()) { + for (String b : composing_token_offsets.keySet()) { + if (a.equals(b)) continue; + Set offsets_a = offsets.get(a); + Set offsets_b = composing_token_offsets.get(b); + if (offsets_a.size() == 0 || offsets_b == null || offsets_b.size() == 0) continue; + removeOverlapOffsets(offsets_b, offsets_a, a.length()); + //offs ets.get(b).removeAll(offsets.get(a)); //string a contains b, so freq of b should be decreased by the freq of a + } + } + + //second of all, understand ordering + final Map firstOccurrenceOfPhrase = new HashMap<>(); + for (Map.Entry> entry : offsets.entrySet()) { + if (entry.getValue().size() == 0) + continue; + int min = Integer.MAX_VALUE; + for (Integer i : entry.getValue()) { + if (i < min) + min = i; + } + firstOccurrenceOfPhrase.put(entry.getKey(), min); + } + final Map firstOccurrenceOfComposingTokens = new HashMap<>(); + for (Map.Entry> entry : composing_token_offsets.entrySet()) { + if (entry.getValue().size() == 0) + continue; + int min = Integer.MAX_VALUE; + for (Integer i : entry.getValue()) { + if (i < min) + min = i; + } + firstOccurrenceOfComposingTokens.put(entry.getKey(), min); + } + + List original_phrases = new ArrayList<>(firstOccurrenceOfPhrase.keySet()); + Collections.sort(original_phrases, (o1, o2) + -> new Integer(firstOccurrenceOfPhrase.get(o1)).compareTo(firstOccurrenceOfPhrase.get(o2))); + + List composing_tokens = new ArrayList<>(firstOccurrenceOfComposingTokens.keySet()); + Collections.sort(composing_tokens, (o1, o2) + -> new Integer(firstOccurrenceOfComposingTokens.get(o1)).compareTo(firstOccurrenceOfComposingTokens.get(o2))); + + + //last of all, compute scores + double ordering_multiplier_original = 1.0 / original_phrases.size(); + double order_scalar_composing_tokens = 1.0 / composing_tokens.size(); + + for (int o = 0; o < original_phrases.size(); o++) { + String phrase = original_phrases.get(o); + if (offsets.get(phrase) != null) { + int freq = offsets.get(phrase).size(); + if (freq > 0) { //exact cell value found + //double ordering_weight_multiplier = (original_phrases.size() - o) * ordering_multiplier_original; + double score_to_increment = offsets.get(phrase).size() * /*ordering_weight_multiplier*/1.0 * contextWeightScalar; + + Double score = scores.get(phrase); + score = score == null ? 0.0 : score; + score = score + score_to_increment; + scores.put(phrase, score); + } + } + } + for (int o = 0; o < composing_tokens.size(); o++) { + String candidate = composing_tokens.get(o); + if (composing_token_offsets.get(candidate) != null) { + int freq = composing_token_offsets.get(candidate).size(); + if (freq > 0) { //exact cell value found + double order_weight_scalar = (composing_tokens.size() - o) * order_scalar_composing_tokens; + if(!WORD_ORDER_MATTERS) + order_weight_scalar=1.0; + double score_to_increment = composing_token_offsets.get(candidate).size() + * order_weight_scalar * contextWeightScalar; + + //find corresponding parent cell value + for (Map.Entry> e : phrase_to_composing_tokens.entrySet()) { + if (e.getValue().contains(candidate)) { + score_to_increment = boostScoreByComposingTokens( + score_to_increment, e.getKey() + ); + Double score = scores.get(e.getKey()); + score = score == null ? 0.0 : score; + score = score + score_to_increment; + scores.put(e.getKey(), score); + } + } + } + } + } + + } + + private boolean ignore(String t) { + if (stopWords.contains(t)) + return true; + try { + Long.valueOf(t); //isValidAttribute numbers + return true; + } catch (Exception e) { + } + return false; + } + + + private double boostScoreByComposingTokens( + double score_to_increment_by_component, + String original) { + int length = original.split("\\s+").length; + if (length < 2) return 0; + return score_to_increment_by_component * (1.0 / (length/* * length*/)); + } + + + protected String normalize(String value) { + return value.replaceAll("[^\\p{L}\\s\\d]", " ").replaceAll("\\s+", " ").trim().toLowerCase(); + } + + //remove short phrase's start offsets if it is part of a longer phrase + protected void removeOverlapOffsets(Set shorterPhraseStarts, Set longerPhraseStarts, int longerPhraseLength) { + Iterator it = shorterPhraseStarts.iterator(); + while (it.hasNext()) { + Integer s = it.next(); + for (int st : longerPhraseStarts) { + if (st <= s && s < st + longerPhraseLength) { //the shorter phrase's start is included in the longer phrase boundary + it.remove(); + break; + } + } + } + } + + protected String createSolrCacheQuery(String... values) { + StringBuilder sb = new StringBuilder(); + for (String v : values) + sb.append(v).append(" "); + return sb.toString().trim(); + } + + + /* public static void main(String[] args) throws APIKeysDepletedException, IOException { + String[] accountKeys = new String[]{"fXhmgvVQnz1aLBti87+AZlPYDXcQL0G9L2dVAav+aK0="}; + WSScorer matcher = new WSScorer( + new HeaderWebsearchMatcherCache("D:\\Work\\lodiedata\\tableminer_cache\\solrindex_cache\\zookeeper\\solr", + "collection1"), + new BingSearch(accountKeys), + new ArrayList() + ); + matcher.computeElementScores("House of Cards", "Peter David"); + matcher.computeElementScores("University of Sheffield", "Sheffield", "United Kingdom"); + matcher.computeElementScores("House of Cards", "Peter David"); + matcher.cache.closeConnection(); + }*/ + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/JointInferenceBatch.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/JointInferenceBatch.java index 70a4be57..e695135e 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/JointInferenceBatch.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/JointInferenceBatch.java @@ -1,207 +1,207 @@ -package uk.ac.shef.dcs.sti.experiment; - -import org.apache.commons.lang.exception.ExceptionUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.log4j.Logger; -import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; - -import org.simmetrics.metrics.Levenshtein; -import org.simmetrics.metrics.StringMetrics; -import uk.ac.shef.dcs.kbsearch.KBSearch; -import uk.ac.shef.dcs.kbsearch.KBSearchFactory; -import uk.ac.shef.dcs.sti.STIConstantProperty; -import uk.ac.shef.dcs.sti.STIException; - -import uk.ac.shef.dcs.sti.core.algorithm.ji.*; -import uk.ac.shef.dcs.sti.core.algorithm.ji.similarity.EntityAndClazzSimilarityScorer; -import uk.ac.shef.dcs.sti.core.algorithm.smp.ClazzSpecificityCalculator; -import uk.ac.shef.dcs.sti.core.algorithm.tmp.sampler.TContentTContentRowRankerImpl; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.core.subjectcol.SubjectColumnDetector; - -import java.io.File; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.nio.file.Paths; -import java.util.*; - -/** - * - */ -public class JointInferenceBatch extends STIBatch { - private static final Logger LOG = Logger.getLogger(JointInferenceBatch.class.getName()); - private static final String PROPERTY_SIMILARITY_CACHE_CORENAME="similarity"; - private static final String PROPERTY_JI_USE_SUBJECT_COLUMN = "sti.ji.usesubjectcolumn"; - private static final String PROPERTY_JI_MAX_ITERATIONS = "sti.ji.maxiterations"; - private static final String PROPERTY_JI_DEBUG_MODE = "sti.ji.debugmode"; - private static final String PROPERTY_JI_CLAZZ_SPECIFICITY_CALCULATOR = "sti.ji.clazzspecificitycalculator"; - - private EmbeddedSolrServer simlarityServer; - - public JointInferenceBatch(String propertyFile) throws IOException, STIException { - super(propertyFile); - } - - private EmbeddedSolrServer getSolrServerCacheSimilarity() throws STIException { - if (simlarityServer == null) { - String solrHomePath = properties.getProperty(PROPERTY_CACHE_FOLDER); - if (solrHomePath == null || !new File(solrHomePath).exists() || PROPERTY_SIMILARITY_CACHE_CORENAME == null) { - String error = "Cannot proceed: the cache dir is not set or does not exist. " + - PROPERTY_CACHE_FOLDER + "=" + solrHomePath; - LOG.error(error); - throw new STIException(error); - } - if (cores == null) { - simlarityServer = new EmbeddedSolrServer(Paths.get(solrHomePath), PROPERTY_SIMILARITY_CACHE_CORENAME); - cores = simlarityServer.getCoreContainer(); - } else - simlarityServer = new EmbeddedSolrServer(cores.getCore(PROPERTY_SIMILARITY_CACHE_CORENAME)); - } - return simlarityServer; - } - - private ClazzSpecificityCalculator getClazzSpecificityCalculator() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException { - return (ClazzSpecificityCalculator) - Class.forName(properties.getProperty(PROPERTY_JI_CLAZZ_SPECIFICITY_CALCULATOR)) - .getDeclaredConstructor(KBSearch.class) - .newInstance(kbSearch); - } - - @Override - protected void initComponents() throws STIException { - LOG.info("Initializing entity cache..."); - EmbeddedSolrServer kbEntityServer = this.getSolrServerCacheEntity(); - LOG.info("Initializing clazz cache..."); - EmbeddedSolrServer kbClazzServer = this.getSolrServerCacheClazz(); - LOG.info("Initializing property cache..."); - EmbeddedSolrServer kbPropertyServer = this.getSolrServerCacheRelation(); - LOG.info("Initializing similarity cache..."); - EmbeddedSolrServer simServer = this.getSolrServerCacheSimilarity(); - //object to fetch things from KB - - LOG.info("Initializing KBSearch..."); - KBSearchFactory fbf = new KBSearchFactory(); - try { - kbSearch = fbf.createInstance( - getAbsolutePath(PROPERTY_KBSEARCH_PROP_FILE), - kbEntityServer, kbClazzServer, kbPropertyServer,simServer); - } catch (Exception e) { - e.printStackTrace(); - LOG.error(ExceptionUtils.getFullStackTrace(e)); - throw new STIException("Failed initialising KBSearch:" + - getAbsolutePath(PROPERTY_KBSEARCH_PROP_FILE) - , e); - } - - LOG.info("Initializing SUBJECT COLUMN DETECTION components ..."); - SubjectColumnDetector subcolDetector; - try { - subcolDetector = new SubjectColumnDetector( - new TContentTContentRowRankerImpl(), - properties.getProperty(PROPERTY_TMP_IINF_WEBSEARCH_STOPPING_CLASS), - StringUtils.split(properties.getProperty(PROPERTY_TMP_IINF_WEBSEARCH_STOPPING_CLASS_CONSTR_PARAM), - ','), - getSolrServerCacheWebsearch(), - getNLPResourcesDir(), - Boolean.valueOf(properties.getProperty(PROPERTY_TMP_SUBJECT_COLUMN_DETECTION_USE_WEBSEARCH)), - getStopwords(), - getAbsolutePath(PROPERTY_WEBSEARCH_PROP_FILE) - );// dobs - } catch (Exception e) { - e.printStackTrace(); - LOG.error(ExceptionUtils.getFullStackTrace(e)); - throw new STIException("Failed initialising SUBJECT COLUMN DETECTION components:" + properties.getProperty(PROPERTY_WEBSEARCH_PROP_FILE) - , e); - } - - LOG.info("Initializing JI components ..."); - try { - int cores = Runtime.getRuntime().availableProcessors(); - interpreter = new JIInterpreter( - subcolDetector, - new CandidateEntityGenerator(kbSearch, - new JIAdaptedEntityScorer()), - new CandidateConceptGenerator(kbSearch, - new JIClazzScorer(), - new EntityAndClazzSimilarityScorer(getStopwords(), getNLPResourcesDir()), - getClazzSpecificityCalculator(), - cores,true), - new CandidateRelationGenerator( - new JIAdaptedAttributeMatcher(STIConstantProperty.ATTRIBUTE_MATCHER_MIN_SCORE,getStopwords(), - StringMetrics.levenshtein()), - kbSearch,true), - Boolean.valueOf(properties.getProperty(PROPERTY_JI_USE_SUBJECT_COLUMN, "false")), - getIgnoreColumns(), - getMustdoColumns(), - Integer.valueOf(properties.getProperty(PROPERTY_JI_MAX_ITERATIONS,"10")), - Boolean.valueOf(properties.getProperty(PROPERTY_JI_DEBUG_MODE,"false")) - ); - } catch (Exception e) { - e.printStackTrace(); - LOG.error(ExceptionUtils.getFullStackTrace(e)); - throw new STIException("Failed initialising SMP components" - , e); - } - } - - - public static void main(String[] args) throws IOException, STIException { - String inFolder = args[0]; - String outFolder = args[1]; - JointInferenceBatch ji = new JointInferenceBatch(args[2]); - - int count = 0; - List all = Arrays.asList(new File(inFolder).listFiles()); - Collections.sort(all); - LOG.info("Initialization complete. Begin STI. Total input files=" + all.size() + "\n"); - - List previouslyFailed = ji.loadPreviouslyFailed(); - int start = ji.getStartIndex(); - for (File f : all) { - if (f.toString().contains(".DS_Store")) continue; - count++; - - //if a previously failed list of files is given, only learn these. - if (previouslyFailed.size() != 0 && !previouslyFailed.contains(count)) - continue; - - if (count - 1 < start) - continue; - boolean complete; - String inFile = f.toString(); - - try { - String sourceTableFile = inFile; - if (sourceTableFile.startsWith("\"") && sourceTableFile.endsWith("\"")) - sourceTableFile = sourceTableFile.substring(1, sourceTableFile.length() - 1).trim(); - //System.out.println(count + "_" + sourceTableFile + " " + new Date()); - LOG.info("\n<< " + count + "_" + sourceTableFile); - List

").append(header.getHeaderText()).append("
").append(header.getHeaderText()).append("
tables = ji.loadTable(inFile); - if (tables.size() == 0) - ji.recordFailure(count, inFile, inFile); - - for (Table table : tables) { - complete = ji.process( - table, - sourceTableFile, - ji.getTAnnotationWriter(), outFolder, - Boolean.valueOf(ji.properties.getProperty(PROPERTY_PERFORM_RELATION_LEARNING))); - - if (STIConstantProperty.SOLR_COMMIT_PER_FILE) - ji.commitAll(); - if (!complete) { - ji.recordFailure(count, sourceTableFile, inFile); - } - } - //gs annotator - - } catch (Exception e) { - e.printStackTrace(); - ji.recordFailure(count, inFile, inFile); - } - - } - ji.closeAll(); - LOG.info(new Date()); - } -} +package uk.ac.shef.dcs.sti.experiment; + +import org.apache.commons.lang.exception.ExceptionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; + +import org.simmetrics.metrics.Levenshtein; +import org.simmetrics.metrics.StringMetrics; +import uk.ac.shef.dcs.kbsearch.KBSearch; +import uk.ac.shef.dcs.kbsearch.KBSearchFactory; +import uk.ac.shef.dcs.sti.STIConstantProperty; +import uk.ac.shef.dcs.sti.STIException; + +import uk.ac.shef.dcs.sti.core.algorithm.ji.*; +import uk.ac.shef.dcs.sti.core.algorithm.ji.similarity.EntityAndClazzSimilarityScorer; +import uk.ac.shef.dcs.sti.core.algorithm.smp.ClazzSpecificityCalculator; +import uk.ac.shef.dcs.sti.core.algorithm.tmp.sampler.TContentTContentRowRankerImpl; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.core.subjectcol.SubjectColumnDetector; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.nio.file.Paths; +import java.util.*; + +/** + * + */ +public class JointInferenceBatch extends STIBatch { + private static final Logger LOG = Logger.getLogger(JointInferenceBatch.class.getName()); + private static final String PROPERTY_SIMILARITY_CACHE_CORENAME="similarity"; + private static final String PROPERTY_JI_USE_SUBJECT_COLUMN = "sti.ji.usesubjectcolumn"; + private static final String PROPERTY_JI_MAX_ITERATIONS = "sti.ji.maxiterations"; + private static final String PROPERTY_JI_DEBUG_MODE = "sti.ji.debugmode"; + private static final String PROPERTY_JI_CLAZZ_SPECIFICITY_CALCULATOR = "sti.ji.clazzspecificitycalculator"; + + private EmbeddedSolrServer simlarityServer; + + public JointInferenceBatch(String propertyFile) throws IOException, STIException { + super(propertyFile); + } + + private EmbeddedSolrServer getSolrServerCacheSimilarity() throws STIException { + if (simlarityServer == null) { + String solrHomePath = properties.getProperty(PROPERTY_CACHE_FOLDER); + if (solrHomePath == null || !new File(solrHomePath).exists() || PROPERTY_SIMILARITY_CACHE_CORENAME == null) { + String error = "Cannot proceed: the cache dir is not set or does not exist. " + + PROPERTY_CACHE_FOLDER + "=" + solrHomePath; + LOG.error(error); + throw new STIException(error); + } + if (cores == null) { + simlarityServer = new EmbeddedSolrServer(Paths.get(solrHomePath), PROPERTY_SIMILARITY_CACHE_CORENAME); + cores = simlarityServer.getCoreContainer(); + } else + simlarityServer = new EmbeddedSolrServer(cores.getCore(PROPERTY_SIMILARITY_CACHE_CORENAME)); + } + return simlarityServer; + } + + private ClazzSpecificityCalculator getClazzSpecificityCalculator() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException { + return (ClazzSpecificityCalculator) + Class.forName(properties.getProperty(PROPERTY_JI_CLAZZ_SPECIFICITY_CALCULATOR)) + .getDeclaredConstructor(KBSearch.class) + .newInstance(kbSearch); + } + + @Override + protected void initComponents() throws STIException { + LOG.info("Initializing entity cache..."); + EmbeddedSolrServer kbEntityServer = this.getSolrServerCacheEntity(); + LOG.info("Initializing clazz cache..."); + EmbeddedSolrServer kbClazzServer = this.getSolrServerCacheClazz(); + LOG.info("Initializing property cache..."); + EmbeddedSolrServer kbPropertyServer = this.getSolrServerCacheRelation(); + LOG.info("Initializing similarity cache..."); + EmbeddedSolrServer simServer = this.getSolrServerCacheSimilarity(); + //object to fetch things from KB + + LOG.info("Initializing KBSearch..."); + KBSearchFactory fbf = new KBSearchFactory(); + try { + kbSearch = fbf.createInstance( + getAbsolutePath(PROPERTY_KBSEARCH_PROP_FILE), + kbEntityServer, kbClazzServer, kbPropertyServer,simServer); + } catch (Exception e) { + e.printStackTrace(); + LOG.error(ExceptionUtils.getFullStackTrace(e)); + throw new STIException("Failed initialising KBSearch:" + + getAbsolutePath(PROPERTY_KBSEARCH_PROP_FILE) + , e); + } + + LOG.info("Initializing SUBJECT COLUMN DETECTION components ..."); + SubjectColumnDetector subcolDetector; + try { + subcolDetector = new SubjectColumnDetector( + new TContentTContentRowRankerImpl(), + properties.getProperty(PROPERTY_TMP_IINF_WEBSEARCH_STOPPING_CLASS), + StringUtils.split(properties.getProperty(PROPERTY_TMP_IINF_WEBSEARCH_STOPPING_CLASS_CONSTR_PARAM), + ','), + getSolrServerCacheWebsearch(), + getNLPResourcesDir(), + Boolean.valueOf(properties.getProperty(PROPERTY_TMP_SUBJECT_COLUMN_DETECTION_USE_WEBSEARCH)), + getStopwords(), + getAbsolutePath(PROPERTY_WEBSEARCH_PROP_FILE) + );// dobs + } catch (Exception e) { + e.printStackTrace(); + LOG.error(ExceptionUtils.getFullStackTrace(e)); + throw new STIException("Failed initialising SUBJECT COLUMN DETECTION components:" + properties.getProperty(PROPERTY_WEBSEARCH_PROP_FILE) + , e); + } + + LOG.info("Initializing JI components ..."); + try { + int cores = Runtime.getRuntime().availableProcessors(); + interpreter = new JIInterpreter( + subcolDetector, + new CandidateEntityGenerator(kbSearch, + new JIAdaptedEntityScorer()), + new CandidateConceptGenerator(kbSearch, + new JIClazzScorer(), + new EntityAndClazzSimilarityScorer(getStopwords(), getNLPResourcesDir()), + getClazzSpecificityCalculator(), + cores,true), + new CandidateRelationGenerator( + new JIAdaptedAttributeMatcher(STIConstantProperty.ATTRIBUTE_MATCHER_MIN_SCORE,getStopwords(), + StringMetrics.levenshtein()), + kbSearch,true), + Boolean.valueOf(properties.getProperty(PROPERTY_JI_USE_SUBJECT_COLUMN, "false")), + getIgnoreColumns(), + getMustdoColumns(), + Integer.valueOf(properties.getProperty(PROPERTY_JI_MAX_ITERATIONS,"10")), + Boolean.valueOf(properties.getProperty(PROPERTY_JI_DEBUG_MODE,"false")) + ); + } catch (Exception e) { + e.printStackTrace(); + LOG.error(ExceptionUtils.getFullStackTrace(e)); + throw new STIException("Failed initialising SMP components" + , e); + } + } + + + public static void main(String[] args) throws IOException, STIException { + String inFolder = args[0]; + String outFolder = args[1]; + JointInferenceBatch ji = new JointInferenceBatch(args[2]); + + int count = 0; + List all = Arrays.asList(new File(inFolder).listFiles()); + Collections.sort(all); + LOG.info("Initialization complete. Begin STI. Total input files=" + all.size() + "\n"); + + List previouslyFailed = ji.loadPreviouslyFailed(); + int start = ji.getStartIndex(); + for (File f : all) { + if (f.toString().contains(".DS_Store")) continue; + count++; + + //if a previously failed list of files is given, only learn these. + if (previouslyFailed.size() != 0 && !previouslyFailed.contains(count)) + continue; + + if (count - 1 < start) + continue; + boolean complete; + String inFile = f.toString(); + + try { + String sourceTableFile = inFile; + if (sourceTableFile.startsWith("\"") && sourceTableFile.endsWith("\"")) + sourceTableFile = sourceTableFile.substring(1, sourceTableFile.length() - 1).trim(); + //System.out.println(count + "_" + sourceTableFile + " " + new Date()); + LOG.info("\n<< " + count + "_" + sourceTableFile); + List
tables = ji.loadTable(inFile); + if (tables.size() == 0) + ji.recordFailure(count, inFile, inFile); + + for (Table table : tables) { + complete = ji.process( + table, + sourceTableFile, + ji.getTAnnotationWriter(), outFolder, + Boolean.valueOf(ji.properties.getProperty(PROPERTY_PERFORM_RELATION_LEARNING))); + + if (STIConstantProperty.SOLR_COMMIT_PER_FILE) + ji.commitAll(); + if (!complete) { + ji.recordFailure(count, sourceTableFile, inFile); + } + } + //gs annotator + + } catch (Exception e) { + e.printStackTrace(); + ji.recordFailure(count, inFile, inFile); + } + + } + ji.closeAll(); + LOG.info(new Date()); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/STIBatch.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/STIBatch.java index b59183cb..93f84bfe 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/STIBatch.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/STIBatch.java @@ -1,385 +1,385 @@ -package uk.ac.shef.dcs.sti.experiment; - -import com.google.api.client.http.HttpResponseException; -import org.apache.commons.lang3.StringUtils; -import org.apache.log4j.Logger; -import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; -import org.apache.solr.core.CoreContainer; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.kbsearch.KBSearch; -import uk.ac.shef.dcs.sti.core.algorithm.SemanticTableInterpreter; -import uk.ac.shef.dcs.sti.io.TAnnotationWriterJSON; -import uk.ac.shef.dcs.sti.util.TripleGenerator; -import uk.ac.shef.dcs.sti.io.TAnnotationWriter; -import uk.ac.shef.dcs.sti.core.model.TAnnotation; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.util.FileUtils; -import uk.ac.shef.dcs.sti.parser.table.TableParser; - -import java.io.*; -import java.net.SocketTimeoutException; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; - -/** - * - */ -public abstract class STIBatch { - - - private static Logger LOG = Logger.getLogger(STIBatch.class.getName()); - - protected KBSearch kbSearch; - - protected TableParser tableParser; - - protected SemanticTableInterpreter interpreter; - - protected static final String PROPERTY_HOME = "sti.home"; - - protected static final String PROPERTY_WEBSEARCH_PROP_FILE = "sti.websearch.properties"; - - protected static final String PROPERTY_NLP_RESOURCES = "sti.nlp"; - - protected static final String PROPERTY_PERFORM_RELATION_LEARNING = "sti.learning.relation"; - - protected static final String PROPERTY_CACHE_FOLDER = "sti.cache.main.dir"; - - private static final String PROPERTY_ENTITY_CACHE_CORENAME = "entity"; - private static final String PROPERTY_CLAZZ_CACHE_CORENAME = "class"; - private static final String PROPERTY_RELATION_CACHE_CORENAME = "relation"; - private static final String PROPERTY_WEBSEARCH_CACHE_CORENAME = "websearch"; - - protected static final String PROPERTY_START_INDEX = "sti.start"; - protected static final String PROPERTY_SELECT_LIST = "sti.list.select"; - protected static final String PROPERTY_FAILED_LIST = "sti.list.failure"; - - protected static final String PROPERTY_KBSEARCH_PROP_FILE = "sti.kbsearch.propertyfile"; - - protected static final String PROPERTY_IGNORE_COLUMNS = "sti.columns.ignore"; - protected static final String PROPERTY_MUSTDO_COLUMNS = "sti.columns.mustdo"; - - protected static final String PROPERTY_OUTPUT_TRIPLE_KB_NAMESPACE = "sti.output.triple.namespace.kb"; - protected static final String PROPERTY_OUTPUT_TRIPLE_DEFAULT_NAMESPACE = "sti.output.triple.namespace.default"; - - protected static final String PROPERTY_TABLEXTRACTOR_CLASS = "sti.input.parser.class"; - - protected static final String PROPERTY_TMP_SUBJECT_COLUMN_DETECTION_USE_WEBSEARCH = - "sti.subjectcolumndetection.ws"; - protected static final String PROPERTY_TMP_IINF_WEBSEARCH_STOPPING_CLASS = "sti.iinf.websearch.stopping.class"; - protected static final String PROPERTY_TMP_IINF_WEBSEARCH_STOPPING_CLASS_CONSTR_PARAM - = "sti.iinf.websearch.stopping.class.constructor.params"; - - protected Properties properties; - - protected TAnnotationWriter writer; - - protected CoreContainer cores; - private EmbeddedSolrServer entityCache; - private EmbeddedSolrServer conceptCache; - private EmbeddedSolrServer relationCache; - private EmbeddedSolrServer websearchCache; - - public STIBatch(String propertyFile) throws IOException, STIException { - properties = new Properties(); - properties.load(new FileInputStream(propertyFile)); - initComponents(); - /*writer = new TAnnotationWriter(new TripleGenerator( - properties.getProperty(PROPERTY_OUTPUT_TRIPLE_KB_NAMESPACE), properties.getProperty(PROPERTY_OUTPUT_TRIPLE_DEFAULT_NAMESPACE) - ));*/ - } - - /** - * Initialize kbsearchers, websearcher. implementing class to decide which are compulsory and how to - * handle exceptions - */ - protected abstract void initComponents() throws STIException; - - protected List
loadTable(String file) { - try { - return getTableParser().extract(file, file); - } catch (Exception e) { - e.printStackTrace(); - return new ArrayList<>(); - } - } - - protected int getStartIndex() { - String s = properties.get(PROPERTY_START_INDEX).toString(); - if (s == null) - return 0; - return Integer.valueOf(s); - } - - protected TableParser getTableParser() throws ClassNotFoundException, IllegalAccessException, InstantiationException { - if (tableParser == null) { - String clazz = properties.get(PROPERTY_TABLEXTRACTOR_CLASS).toString(); - tableParser = (TableParser) Class.forName(clazz).newInstance(); - } - return tableParser; - } - - protected EmbeddedSolrServer getSolrServerCacheEntity() throws STIException { - if (entityCache == null) { - String solrHomePath = properties.getProperty(PROPERTY_CACHE_FOLDER); - if (solrHomePath == null || !new File(solrHomePath).exists()) { - String error = "Cannot proceed: the cache dir is not set or does not exist. " + - PROPERTY_CACHE_FOLDER + "=" + solrHomePath; - LOG.error(error); - throw new STIException(error); - } - - if (cores == null) { - entityCache = new EmbeddedSolrServer(Paths.get(solrHomePath), PROPERTY_ENTITY_CACHE_CORENAME); - cores = entityCache.getCoreContainer(); - } else - entityCache = new EmbeddedSolrServer(cores.getCore(PROPERTY_ENTITY_CACHE_CORENAME)); - } - return entityCache; - } - - protected EmbeddedSolrServer getSolrServerCacheClazz() throws STIException { - if (conceptCache == null) { - String solrHomePath = properties.getProperty(PROPERTY_CACHE_FOLDER); - if (solrHomePath == null || !new File(solrHomePath).exists() || PROPERTY_CLAZZ_CACHE_CORENAME == null) { - String error = "Cannot proceed: the cache dir is not set or does not exist. " + - PROPERTY_CACHE_FOLDER + "=" + solrHomePath; - LOG.error(error); - throw new STIException(error); - } - if (cores == null) { - conceptCache = new EmbeddedSolrServer(Paths.get(solrHomePath), PROPERTY_CLAZZ_CACHE_CORENAME); - cores = conceptCache.getCoreContainer(); - } else - conceptCache = new EmbeddedSolrServer(cores.getCore(PROPERTY_CLAZZ_CACHE_CORENAME)); - } - return conceptCache; - } - - protected EmbeddedSolrServer getSolrServerCacheRelation() throws STIException { - if (relationCache == null) { - String solrHomePath = properties.getProperty(PROPERTY_CACHE_FOLDER); - if (solrHomePath == null || !new File(solrHomePath).exists() || PROPERTY_RELATION_CACHE_CORENAME == null) { - String error = "Cannot proceed: the cache dir is not set or does not exist. " + - PROPERTY_CACHE_FOLDER + "=" + solrHomePath; - LOG.error(error); - throw new STIException(error); - } - if (cores == null) { - relationCache = new EmbeddedSolrServer(Paths.get(solrHomePath), PROPERTY_RELATION_CACHE_CORENAME); - cores = relationCache.getCoreContainer(); - } else - relationCache = new EmbeddedSolrServer(cores.getCore(PROPERTY_RELATION_CACHE_CORENAME)); - } - return relationCache; - } - - protected EmbeddedSolrServer getSolrServerCacheWebsearch() throws STIException { - if (websearchCache == null) { - String solrHomePath = properties.getProperty(PROPERTY_CACHE_FOLDER); - if (solrHomePath == null || !new File(solrHomePath).exists() || PROPERTY_RELATION_CACHE_CORENAME == null) { - String error = "Cannot proceed: the cache dir is not set or does not exist. " + - PROPERTY_CACHE_FOLDER + "=" + solrHomePath; - LOG.error(error); - throw new STIException(error); - } - if (cores == null) { - websearchCache = new EmbeddedSolrServer(Paths.get(solrHomePath), PROPERTY_WEBSEARCH_CACHE_CORENAME); - cores = websearchCache.getCoreContainer(); - } else - websearchCache = new EmbeddedSolrServer(cores.getCore(PROPERTY_WEBSEARCH_CACHE_CORENAME)); - } - return websearchCache; - } - - protected String getKBSearchPropFile() throws STIException { - String prop = properties.getProperty(PROPERTY_KBSEARCH_PROP_FILE); - if (prop == null || !new File(prop).exists()) { - String error = "Cannot proceed: the property file for your kbsearch module is not set or does not exist. " + - PROPERTY_KBSEARCH_PROP_FILE + "=" + prop; - LOG.error(error); - throw new STIException(error); - } - return prop; - } - - - protected String getNLPResourcesDir() throws STIException { - String prop = getAbsolutePath(PROPERTY_NLP_RESOURCES); - if (prop == null || !new File(prop).exists()) { - String error = "Cannot proceed: nlp resources folder is not set or does not exist. " + - PROPERTY_KBSEARCH_PROP_FILE + "=" + prop; - LOG.error(error); - throw new STIException(error); - } - return prop; - } - - protected List getStopwords() throws STIException, IOException { - return FileUtils.readList(getNLPResourcesDir() + File.separator + "stoplist.txt", true); - } - - protected int[] getIgnoreColumns() { - String ignore = properties.getProperty(PROPERTY_IGNORE_COLUMNS); - String[] splits = StringUtils.split(ignore, ','); - int[] res = new int[splits.length]; - for (int i = 0; i < splits.length; i++) { - res[i] = Integer.valueOf(splits[i].trim()); - } - return res; - } - - protected int[] getMustdoColumns() { - String ignore = properties.getProperty(PROPERTY_MUSTDO_COLUMNS); - String[] splits = StringUtils.split(ignore, ','); - int[] res = new int[0]; - for (int i = 0; i < splits.length; i++) { - res[i] = Integer.valueOf(splits[i].trim()); - } - return res; - } - - protected TAnnotationWriter getTAnnotationWriter() { - if (writer == null) { - /*writer = new TAnnotationWriter( - new TripleGenerator(properties.getProperty(PROPERTY_OUTPUT_TRIPLE_KB_NAMESPACE), - properties.getProperty(PROPERTY_OUTPUT_TRIPLE_DEFAULT_NAMESPACE)));*/ - writer = new TAnnotationWriterJSON( - new TripleGenerator(properties.getProperty(PROPERTY_OUTPUT_TRIPLE_KB_NAMESPACE), - properties.getProperty(PROPERTY_OUTPUT_TRIPLE_DEFAULT_NAMESPACE))); - } - return writer; - } - - protected void commitAll() { - if (entityCache != null) - try { - entityCache.commit(); - } catch (Exception e) { - e.printStackTrace(); - } - if (conceptCache != null) - try { - conceptCache.commit(); - } catch (Exception e) { - e.printStackTrace(); - } - if (relationCache != null) - try { - relationCache.commit(); - } catch (Exception e) { - e.printStackTrace(); - } - if (websearchCache != null) - try { - websearchCache.commit(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - protected void closeAll() { - if (entityCache != null) - try { - entityCache.close(); - } catch (Exception e) { - e.printStackTrace(); - } - if (conceptCache != null) - try { - conceptCache.close(); - } catch (Exception e) { - e.printStackTrace(); - } - if (relationCache != null) - try { - relationCache.close(); - } catch (Exception e) { - e.printStackTrace(); - } - if (websearchCache != null) - try { - websearchCache.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - - protected boolean process(Table table, String sourceTableFile, TAnnotationWriter writer, - String outFolder, - boolean relationLearning) throws Exception { - File outDir = new File(outFolder); - if (!outDir.exists()) - outDir.mkdirs(); - String outFilename = sourceTableFile.replaceAll("\\\\", "/"); - try { - TAnnotation annotations = interpreter.start(table, relationLearning); - - int startIndex = outFilename.lastIndexOf("/"); - if (startIndex != -1) { - outFilename = outFilename.substring(startIndex + 1).trim(); - } - writer.writeHTML(table, annotations, outFolder + "/" + outFilename + ".html"); - - } catch (Exception ste) { - if (ste instanceof SocketTimeoutException || ste instanceof HttpResponseException) { - ste.printStackTrace(); - System.out.println("Remote server timed out, continue 10 seconds. Missed." + outFilename); - try { - Thread.sleep(10000); - } catch (Exception e) { - } - return false; - } else - throw ste; - - } - return true; - } - - protected void recordFailure(int count, String sourceTableFile, String inFile) { - System.out.println("\t\t\t missed: " + count + "_" + sourceTableFile); - PrintWriter missedWriter = null; - try { - missedWriter = new PrintWriter(new FileWriter(properties.getProperty(PROPERTY_FAILED_LIST), true)); - missedWriter.println(count + "," + inFile); - missedWriter.close(); - } catch (IOException e1) { - e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. - } - } - - protected List loadPreviouslyFailed() { - List l = - null; - File f = new File(getAbsolutePath(PROPERTY_SELECT_LIST)); - if (properties.getProperty(PROPERTY_SELECT_LIST) == null - || properties.getProperty(PROPERTY_SELECT_LIST).length() == 0 - || !f.exists()) { - LOG.info("No sub-list of input files provided. All files will be processed. "); - return new ArrayList<>(); - } - try { - l = org.apache.commons.io.FileUtils.readLines( - f); - } catch (IOException e) { - e.printStackTrace(); - } - List selected = new ArrayList<>(); - for (Object o : l) { - String line = o.toString(); - String index = line.split(",")[0].trim(); - if (index.length() > 0) - selected.add(Integer.valueOf(index)); - } - return selected; - } - - protected String getAbsolutePath(String propertyName) { - return properties.getProperty(PROPERTY_HOME) - + File.separator + properties.getProperty(propertyName); - } -} +package uk.ac.shef.dcs.sti.experiment; + +import com.google.api.client.http.HttpResponseException; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; +import org.apache.solr.core.CoreContainer; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.kbsearch.KBSearch; +import uk.ac.shef.dcs.sti.core.algorithm.SemanticTableInterpreter; +import uk.ac.shef.dcs.sti.io.TAnnotationWriterJSON; +import uk.ac.shef.dcs.sti.util.TripleGenerator; +import uk.ac.shef.dcs.sti.io.TAnnotationWriter; +import uk.ac.shef.dcs.sti.core.model.TAnnotation; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.util.FileUtils; +import uk.ac.shef.dcs.sti.parser.table.TableParser; + +import java.io.*; +import java.net.SocketTimeoutException; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +/** + * + */ +public abstract class STIBatch { + + + private static Logger LOG = Logger.getLogger(STIBatch.class.getName()); + + protected KBSearch kbSearch; + + protected TableParser tableParser; + + protected SemanticTableInterpreter interpreter; + + protected static final String PROPERTY_HOME = "sti.home"; + + protected static final String PROPERTY_WEBSEARCH_PROP_FILE = "sti.websearch.properties"; + + protected static final String PROPERTY_NLP_RESOURCES = "sti.nlp"; + + protected static final String PROPERTY_PERFORM_RELATION_LEARNING = "sti.learning.relation"; + + protected static final String PROPERTY_CACHE_FOLDER = "sti.cache.main.dir"; + + private static final String PROPERTY_ENTITY_CACHE_CORENAME = "entity"; + private static final String PROPERTY_CLAZZ_CACHE_CORENAME = "class"; + private static final String PROPERTY_RELATION_CACHE_CORENAME = "relation"; + private static final String PROPERTY_WEBSEARCH_CACHE_CORENAME = "websearch"; + + protected static final String PROPERTY_START_INDEX = "sti.start"; + protected static final String PROPERTY_SELECT_LIST = "sti.list.select"; + protected static final String PROPERTY_FAILED_LIST = "sti.list.failure"; + + protected static final String PROPERTY_KBSEARCH_PROP_FILE = "sti.kbsearch.propertyfile"; + + protected static final String PROPERTY_IGNORE_COLUMNS = "sti.columns.ignore"; + protected static final String PROPERTY_MUSTDO_COLUMNS = "sti.columns.mustdo"; + + protected static final String PROPERTY_OUTPUT_TRIPLE_KB_NAMESPACE = "sti.output.triple.namespace.kb"; + protected static final String PROPERTY_OUTPUT_TRIPLE_DEFAULT_NAMESPACE = "sti.output.triple.namespace.default"; + + protected static final String PROPERTY_TABLEXTRACTOR_CLASS = "sti.input.parser.class"; + + protected static final String PROPERTY_TMP_SUBJECT_COLUMN_DETECTION_USE_WEBSEARCH = + "sti.subjectcolumndetection.ws"; + protected static final String PROPERTY_TMP_IINF_WEBSEARCH_STOPPING_CLASS = "sti.iinf.websearch.stopping.class"; + protected static final String PROPERTY_TMP_IINF_WEBSEARCH_STOPPING_CLASS_CONSTR_PARAM + = "sti.iinf.websearch.stopping.class.constructor.params"; + + protected Properties properties; + + protected TAnnotationWriter writer; + + protected CoreContainer cores; + private EmbeddedSolrServer entityCache; + private EmbeddedSolrServer conceptCache; + private EmbeddedSolrServer relationCache; + private EmbeddedSolrServer websearchCache; + + public STIBatch(String propertyFile) throws IOException, STIException { + properties = new Properties(); + properties.load(new FileInputStream(propertyFile)); + initComponents(); + /*writer = new TAnnotationWriter(new TripleGenerator( + properties.getProperty(PROPERTY_OUTPUT_TRIPLE_KB_NAMESPACE), properties.getProperty(PROPERTY_OUTPUT_TRIPLE_DEFAULT_NAMESPACE) + ));*/ + } + + /** + * Initialize kbsearchers, websearcher. implementing class to decide which are compulsory and how to + * handle exceptions + */ + protected abstract void initComponents() throws STIException; + + protected List
loadTable(String file) { + try { + return getTableParser().extract(file, file); + } catch (Exception e) { + e.printStackTrace(); + return new ArrayList<>(); + } + } + + protected int getStartIndex() { + String s = properties.get(PROPERTY_START_INDEX).toString(); + if (s == null) + return 0; + return Integer.valueOf(s); + } + + protected TableParser getTableParser() throws ClassNotFoundException, IllegalAccessException, InstantiationException { + if (tableParser == null) { + String clazz = properties.get(PROPERTY_TABLEXTRACTOR_CLASS).toString(); + tableParser = (TableParser) Class.forName(clazz).newInstance(); + } + return tableParser; + } + + protected EmbeddedSolrServer getSolrServerCacheEntity() throws STIException { + if (entityCache == null) { + String solrHomePath = properties.getProperty(PROPERTY_CACHE_FOLDER); + if (solrHomePath == null || !new File(solrHomePath).exists()) { + String error = "Cannot proceed: the cache dir is not set or does not exist. " + + PROPERTY_CACHE_FOLDER + "=" + solrHomePath; + LOG.error(error); + throw new STIException(error); + } + + if (cores == null) { + entityCache = new EmbeddedSolrServer(Paths.get(solrHomePath), PROPERTY_ENTITY_CACHE_CORENAME); + cores = entityCache.getCoreContainer(); + } else + entityCache = new EmbeddedSolrServer(cores.getCore(PROPERTY_ENTITY_CACHE_CORENAME)); + } + return entityCache; + } + + protected EmbeddedSolrServer getSolrServerCacheClazz() throws STIException { + if (conceptCache == null) { + String solrHomePath = properties.getProperty(PROPERTY_CACHE_FOLDER); + if (solrHomePath == null || !new File(solrHomePath).exists() || PROPERTY_CLAZZ_CACHE_CORENAME == null) { + String error = "Cannot proceed: the cache dir is not set or does not exist. " + + PROPERTY_CACHE_FOLDER + "=" + solrHomePath; + LOG.error(error); + throw new STIException(error); + } + if (cores == null) { + conceptCache = new EmbeddedSolrServer(Paths.get(solrHomePath), PROPERTY_CLAZZ_CACHE_CORENAME); + cores = conceptCache.getCoreContainer(); + } else + conceptCache = new EmbeddedSolrServer(cores.getCore(PROPERTY_CLAZZ_CACHE_CORENAME)); + } + return conceptCache; + } + + protected EmbeddedSolrServer getSolrServerCacheRelation() throws STIException { + if (relationCache == null) { + String solrHomePath = properties.getProperty(PROPERTY_CACHE_FOLDER); + if (solrHomePath == null || !new File(solrHomePath).exists() || PROPERTY_RELATION_CACHE_CORENAME == null) { + String error = "Cannot proceed: the cache dir is not set or does not exist. " + + PROPERTY_CACHE_FOLDER + "=" + solrHomePath; + LOG.error(error); + throw new STIException(error); + } + if (cores == null) { + relationCache = new EmbeddedSolrServer(Paths.get(solrHomePath), PROPERTY_RELATION_CACHE_CORENAME); + cores = relationCache.getCoreContainer(); + } else + relationCache = new EmbeddedSolrServer(cores.getCore(PROPERTY_RELATION_CACHE_CORENAME)); + } + return relationCache; + } + + protected EmbeddedSolrServer getSolrServerCacheWebsearch() throws STIException { + if (websearchCache == null) { + String solrHomePath = properties.getProperty(PROPERTY_CACHE_FOLDER); + if (solrHomePath == null || !new File(solrHomePath).exists() || PROPERTY_RELATION_CACHE_CORENAME == null) { + String error = "Cannot proceed: the cache dir is not set or does not exist. " + + PROPERTY_CACHE_FOLDER + "=" + solrHomePath; + LOG.error(error); + throw new STIException(error); + } + if (cores == null) { + websearchCache = new EmbeddedSolrServer(Paths.get(solrHomePath), PROPERTY_WEBSEARCH_CACHE_CORENAME); + cores = websearchCache.getCoreContainer(); + } else + websearchCache = new EmbeddedSolrServer(cores.getCore(PROPERTY_WEBSEARCH_CACHE_CORENAME)); + } + return websearchCache; + } + + protected String getKBSearchPropFile() throws STIException { + String prop = properties.getProperty(PROPERTY_KBSEARCH_PROP_FILE); + if (prop == null || !new File(prop).exists()) { + String error = "Cannot proceed: the property file for your kbsearch module is not set or does not exist. " + + PROPERTY_KBSEARCH_PROP_FILE + "=" + prop; + LOG.error(error); + throw new STIException(error); + } + return prop; + } + + + protected String getNLPResourcesDir() throws STIException { + String prop = getAbsolutePath(PROPERTY_NLP_RESOURCES); + if (prop == null || !new File(prop).exists()) { + String error = "Cannot proceed: nlp resources folder is not set or does not exist. " + + PROPERTY_KBSEARCH_PROP_FILE + "=" + prop; + LOG.error(error); + throw new STIException(error); + } + return prop; + } + + protected List getStopwords() throws STIException, IOException { + return FileUtils.readList(getNLPResourcesDir() + File.separator + "stoplist.txt", true); + } + + protected int[] getIgnoreColumns() { + String ignore = properties.getProperty(PROPERTY_IGNORE_COLUMNS); + String[] splits = StringUtils.split(ignore, ','); + int[] res = new int[splits.length]; + for (int i = 0; i < splits.length; i++) { + res[i] = Integer.valueOf(splits[i].trim()); + } + return res; + } + + protected int[] getMustdoColumns() { + String ignore = properties.getProperty(PROPERTY_MUSTDO_COLUMNS); + String[] splits = StringUtils.split(ignore, ','); + int[] res = new int[0]; + for (int i = 0; i < splits.length; i++) { + res[i] = Integer.valueOf(splits[i].trim()); + } + return res; + } + + protected TAnnotationWriter getTAnnotationWriter() { + if (writer == null) { + /*writer = new TAnnotationWriter( + new TripleGenerator(properties.getProperty(PROPERTY_OUTPUT_TRIPLE_KB_NAMESPACE), + properties.getProperty(PROPERTY_OUTPUT_TRIPLE_DEFAULT_NAMESPACE)));*/ + writer = new TAnnotationWriterJSON( + new TripleGenerator(properties.getProperty(PROPERTY_OUTPUT_TRIPLE_KB_NAMESPACE), + properties.getProperty(PROPERTY_OUTPUT_TRIPLE_DEFAULT_NAMESPACE))); + } + return writer; + } + + protected void commitAll() { + if (entityCache != null) + try { + entityCache.commit(); + } catch (Exception e) { + e.printStackTrace(); + } + if (conceptCache != null) + try { + conceptCache.commit(); + } catch (Exception e) { + e.printStackTrace(); + } + if (relationCache != null) + try { + relationCache.commit(); + } catch (Exception e) { + e.printStackTrace(); + } + if (websearchCache != null) + try { + websearchCache.commit(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + protected void closeAll() { + if (entityCache != null) + try { + entityCache.close(); + } catch (Exception e) { + e.printStackTrace(); + } + if (conceptCache != null) + try { + conceptCache.close(); + } catch (Exception e) { + e.printStackTrace(); + } + if (relationCache != null) + try { + relationCache.close(); + } catch (Exception e) { + e.printStackTrace(); + } + if (websearchCache != null) + try { + websearchCache.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + + protected boolean process(Table table, String sourceTableFile, TAnnotationWriter writer, + String outFolder, + boolean relationLearning) throws Exception { + File outDir = new File(outFolder); + if (!outDir.exists()) + outDir.mkdirs(); + String outFilename = sourceTableFile.replaceAll("\\\\", "/"); + try { + TAnnotation annotations = interpreter.start(table, relationLearning); + + int startIndex = outFilename.lastIndexOf("/"); + if (startIndex != -1) { + outFilename = outFilename.substring(startIndex + 1).trim(); + } + writer.writeHTML(table, annotations, outFolder + "/" + outFilename + ".html"); + + } catch (Exception ste) { + if (ste instanceof SocketTimeoutException || ste instanceof HttpResponseException) { + ste.printStackTrace(); + System.out.println("Remote server timed out, continue 10 seconds. Missed." + outFilename); + try { + Thread.sleep(10000); + } catch (Exception e) { + } + return false; + } else + throw ste; + + } + return true; + } + + protected void recordFailure(int count, String sourceTableFile, String inFile) { + System.out.println("\t\t\t missed: " + count + "_" + sourceTableFile); + PrintWriter missedWriter = null; + try { + missedWriter = new PrintWriter(new FileWriter(properties.getProperty(PROPERTY_FAILED_LIST), true)); + missedWriter.println(count + "," + inFile); + missedWriter.close(); + } catch (IOException e1) { + e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } + } + + protected List loadPreviouslyFailed() { + List l = + null; + File f = new File(getAbsolutePath(PROPERTY_SELECT_LIST)); + if (properties.getProperty(PROPERTY_SELECT_LIST) == null + || properties.getProperty(PROPERTY_SELECT_LIST).length() == 0 + || !f.exists()) { + LOG.info("No sub-list of input files provided. All files will be processed. "); + return new ArrayList<>(); + } + try { + l = org.apache.commons.io.FileUtils.readLines( + f); + } catch (IOException e) { + e.printStackTrace(); + } + List selected = new ArrayList<>(); + for (Object o : l) { + String line = o.toString(); + String index = line.split(",")[0].trim(); + if (index.length() > 0) + selected.add(Integer.valueOf(index)); + } + return selected; + } + + protected String getAbsolutePath(String propertyName) { + return properties.getProperty(PROPERTY_HOME) + + File.separator + properties.getProperty(propertyName); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/SemanticMessagePassingBatch.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/SemanticMessagePassingBatch.java index 8f09bcb5..5521474e 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/SemanticMessagePassingBatch.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/experiment/SemanticMessagePassingBatch.java @@ -1,202 +1,202 @@ -package uk.ac.shef.dcs.sti.experiment; - -import org.apache.commons.lang.exception.ExceptionUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.log4j.Logger; -import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; -import org.simmetrics.metrics.StringMetrics; -import uk.ac.shef.dcs.kbsearch.KBSearch; -import uk.ac.shef.dcs.kbsearch.KBSearchFactory; -import uk.ac.shef.dcs.sti.STIConstantProperty; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.algorithm.smp.*; -import uk.ac.shef.dcs.sti.core.algorithm.tmp.sampler.TContentTContentRowRankerImpl; -import uk.ac.shef.dcs.sti.core.algorithm.tmp.scorer.TMPEntityScorer; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.core.scorer.AttributeValueMatcher; -import uk.ac.shef.dcs.sti.core.scorer.EntityScorer; -import uk.ac.shef.dcs.sti.core.subjectcol.SubjectColumnDetector; -import uk.ac.shef.dcs.sti.util.TripleGenerator; - -import java.io.File; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.util.*; - -/** - * Created by - on 06/04/2016. - */ -public class SemanticMessagePassingBatch extends STIBatch { - - private static final Logger LOG = Logger.getLogger(SemanticMessagePassingBatch.class.getName()); - - private static final String PROPERTY_SMP_USE_SUBJECT_COLUMN = "sti.smp.usesubjectcolumn"; - private static final String PROPERTY_SMP_ENTITY_RANKER = "sti.smp.entityranker"; - private static final String PROPERTY_SMP_HALTING_CONFIDTION_MAX_ITERATION = "sti.smp.halting.maxiteration"; - private static final String PROPERTY_SMP_CLAZZ_SPECIFICITY_CALCULATOR = "sti.smp.clazzspecificitycalculator"; - private static final String PROPER_SMP_CHANGE_MESSAGE_SCORE_THRESHOLD = "sti.smp.changemessage.minscore"; - - public SemanticMessagePassingBatch(String propertyFile) throws IOException, STIException { - super(propertyFile); - writer = - new TAnnotationWriterSMP( - new TripleGenerator( - properties.getProperty(PROPERTY_OUTPUT_TRIPLE_KB_NAMESPACE), properties.getProperty(PROPERTY_OUTPUT_TRIPLE_DEFAULT_NAMESPACE) - )); - } - - private ClazzSpecificityCalculator getClazzSpecificityCalculator() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException { - return (ClazzSpecificityCalculator) - Class.forName(properties.getProperty(PROPERTY_SMP_CLAZZ_SPECIFICITY_CALCULATOR)) - .getDeclaredConstructor(KBSearch.class) - .newInstance(kbSearch); - } - - @Override - protected void initComponents() throws STIException { - LOG.info("Initializing entity cache..."); - EmbeddedSolrServer kbEntityServer = this.getSolrServerCacheEntity(); - - LOG.info("Initializing clazz cache..."); - EmbeddedSolrServer kbClazzServer = this.getSolrServerCacheClazz(); - //object to fetch things from KB - - LOG.info("Initializing KBSearch..."); - KBSearchFactory fbf = new KBSearchFactory(); - try { - kbSearch = fbf.createInstance( - getAbsolutePath(PROPERTY_KBSEARCH_PROP_FILE), - kbEntityServer, kbClazzServer, null,null); - } catch (Exception e) { - e.printStackTrace(); - LOG.error(ExceptionUtils.getFullStackTrace(e)); - throw new STIException("Failed initialising KBSearch:" + - getAbsolutePath(PROPERTY_KBSEARCH_PROP_FILE) - , e); - } - - LOG.info("Initializing SUBJECT COLUMN DETECTION components ..."); - SubjectColumnDetector subcolDetector; - try { - subcolDetector = new SubjectColumnDetector( - new TContentTContentRowRankerImpl(), - properties.getProperty(PROPERTY_TMP_IINF_WEBSEARCH_STOPPING_CLASS), - StringUtils.split(properties.getProperty(PROPERTY_TMP_IINF_WEBSEARCH_STOPPING_CLASS_CONSTR_PARAM), - ','), - getSolrServerCacheWebsearch(), - getNLPResourcesDir(), - Boolean.valueOf(properties.getProperty(PROPERTY_TMP_SUBJECT_COLUMN_DETECTION_USE_WEBSEARCH)), - getStopwords(), - getAbsolutePath(PROPERTY_WEBSEARCH_PROP_FILE) - );// dobs - } catch (Exception e) { - e.printStackTrace(); - LOG.error(ExceptionUtils.getFullStackTrace(e)); - throw new STIException("Failed initialising SUBJECT COLUMN DETECTION components:" + properties.getProperty(PROPERTY_WEBSEARCH_PROP_FILE) - , e); - } - - LOG.info("Initializing SMP components ..."); - try { - String neRanker = properties.getProperty(PROPERTY_SMP_ENTITY_RANKER); - EntityScorer entityScorer = null; - if (neRanker != null && neRanker.equalsIgnoreCase("tmp")) { - new TMPEntityScorer( - getStopwords(), - STIConstantProperty.SCORER_ENTITY_CONTEXT_WEIGHT, - getNLPResourcesDir()); - } else if (neRanker != null && neRanker.equalsIgnoreCase("smpfreebase")) - entityScorer = new SMPAdaptedEntityScorer(getStopwords(), getNLPResourcesDir()); - else - throw new STIException(neRanker + " is not a supported option for NE Ranker"); - - Set ignoreColumnSet = new HashSet<>(); - for (int i : getIgnoreColumns()) - ignoreColumnSet.add(i); - SemanticMessagePassing smpAlgorithm = new SemanticMessagePassing( - Integer.valueOf(properties.getProperty(PROPERTY_SMP_HALTING_CONFIDTION_MAX_ITERATION, "10")), - Double.valueOf(properties.getProperty(PROPER_SMP_CHANGE_MESSAGE_SCORE_THRESHOLD, "0.5")) - ); - interpreter = new SMPInterpreter( - subcolDetector, - new TCellEntityRanker(kbSearch, entityScorer), - new TColumnClassifier(kbSearch, getClazzSpecificityCalculator()), - new TColumnColumnRelationEnumerator( - new AttributeValueMatcher( - STIConstantProperty.ATTRIBUTE_MATCHER_MIN_SCORE, - getStopwords(), StringMetrics.levenshtein()), - ignoreColumnSet, - Boolean.valueOf(properties.getProperty(PROPERTY_SMP_USE_SUBJECT_COLUMN, "false"))), - smpAlgorithm, - getIgnoreColumns(), - getMustdoColumns() - ); - } catch (Exception e) { - e.printStackTrace(); - LOG.error(ExceptionUtils.getFullStackTrace(e)); - throw new STIException("Failed initialising SMP components" - , e); - } - - } - - public static void main(String[] args) throws IOException, STIException { - String inFolder = args[0]; - String outFolder = args[1]; - SemanticMessagePassingBatch smp = new SemanticMessagePassingBatch(args[2]); - - int count = 0; - List all = Arrays.asList(new File(inFolder).listFiles()); - Collections.sort(all); - LOG.info("Initialization complete. Begin STI. Total input files=" + all.size() + "\n"); - - List previouslyFailed = smp.loadPreviouslyFailed(); - int start = smp.getStartIndex(); - for (File f : all) { - if (f.toString().contains(".DS_Store")) continue; - count++; - - //if a previously failed list of files is given, only learn these. - if (previouslyFailed.size() != 0 && !previouslyFailed.contains(count)) - continue; - - if (count - 1 < start) - continue; - boolean complete; - String inFile = f.toString(); - - try { - String sourceTableFile = inFile; - if (sourceTableFile.startsWith("\"") && sourceTableFile.endsWith("\"")) - sourceTableFile = sourceTableFile.substring(1, sourceTableFile.length() - 1).trim(); - //System.out.println(count + "_" + sourceTableFile + " " + new Date()); - LOG.info("\n<< " + count + "_" + sourceTableFile); - List
tables = smp.loadTable(inFile); - if (tables.size() == 0) - smp.recordFailure(count, inFile, inFile); - - for (Table table : tables) { - complete = smp.process( - table, - sourceTableFile, - smp.getTAnnotationWriter(), outFolder, - Boolean.valueOf(smp.properties.getProperty(PROPERTY_PERFORM_RELATION_LEARNING))); - - if (STIConstantProperty.SOLR_COMMIT_PER_FILE) - smp.commitAll(); - if (!complete) { - smp.recordFailure(count, sourceTableFile, inFile); - } - } - //gs annotator - - } catch (Exception e) { - e.printStackTrace(); - smp.recordFailure(count, inFile, inFile); - } - - } - smp.closeAll(); - LOG.info(new Date()); - } -} +package uk.ac.shef.dcs.sti.experiment; + +import org.apache.commons.lang.exception.ExceptionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; +import org.simmetrics.metrics.StringMetrics; +import uk.ac.shef.dcs.kbsearch.KBSearch; +import uk.ac.shef.dcs.kbsearch.KBSearchFactory; +import uk.ac.shef.dcs.sti.STIConstantProperty; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.algorithm.smp.*; +import uk.ac.shef.dcs.sti.core.algorithm.tmp.sampler.TContentTContentRowRankerImpl; +import uk.ac.shef.dcs.sti.core.algorithm.tmp.scorer.TMPEntityScorer; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.core.scorer.AttributeValueMatcher; +import uk.ac.shef.dcs.sti.core.scorer.EntityScorer; +import uk.ac.shef.dcs.sti.core.subjectcol.SubjectColumnDetector; +import uk.ac.shef.dcs.sti.util.TripleGenerator; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.util.*; + +/** + * Created by - on 06/04/2016. + */ +public class SemanticMessagePassingBatch extends STIBatch { + + private static final Logger LOG = Logger.getLogger(SemanticMessagePassingBatch.class.getName()); + + private static final String PROPERTY_SMP_USE_SUBJECT_COLUMN = "sti.smp.usesubjectcolumn"; + private static final String PROPERTY_SMP_ENTITY_RANKER = "sti.smp.entityranker"; + private static final String PROPERTY_SMP_HALTING_CONFIDTION_MAX_ITERATION = "sti.smp.halting.maxiteration"; + private static final String PROPERTY_SMP_CLAZZ_SPECIFICITY_CALCULATOR = "sti.smp.clazzspecificitycalculator"; + private static final String PROPER_SMP_CHANGE_MESSAGE_SCORE_THRESHOLD = "sti.smp.changemessage.minscore"; + + public SemanticMessagePassingBatch(String propertyFile) throws IOException, STIException { + super(propertyFile); + writer = + new TAnnotationWriterSMP( + new TripleGenerator( + properties.getProperty(PROPERTY_OUTPUT_TRIPLE_KB_NAMESPACE), properties.getProperty(PROPERTY_OUTPUT_TRIPLE_DEFAULT_NAMESPACE) + )); + } + + private ClazzSpecificityCalculator getClazzSpecificityCalculator() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException { + return (ClazzSpecificityCalculator) + Class.forName(properties.getProperty(PROPERTY_SMP_CLAZZ_SPECIFICITY_CALCULATOR)) + .getDeclaredConstructor(KBSearch.class) + .newInstance(kbSearch); + } + + @Override + protected void initComponents() throws STIException { + LOG.info("Initializing entity cache..."); + EmbeddedSolrServer kbEntityServer = this.getSolrServerCacheEntity(); + + LOG.info("Initializing clazz cache..."); + EmbeddedSolrServer kbClazzServer = this.getSolrServerCacheClazz(); + //object to fetch things from KB + + LOG.info("Initializing KBSearch..."); + KBSearchFactory fbf = new KBSearchFactory(); + try { + kbSearch = fbf.createInstance( + getAbsolutePath(PROPERTY_KBSEARCH_PROP_FILE), + kbEntityServer, kbClazzServer, null,null); + } catch (Exception e) { + e.printStackTrace(); + LOG.error(ExceptionUtils.getFullStackTrace(e)); + throw new STIException("Failed initialising KBSearch:" + + getAbsolutePath(PROPERTY_KBSEARCH_PROP_FILE) + , e); + } + + LOG.info("Initializing SUBJECT COLUMN DETECTION components ..."); + SubjectColumnDetector subcolDetector; + try { + subcolDetector = new SubjectColumnDetector( + new TContentTContentRowRankerImpl(), + properties.getProperty(PROPERTY_TMP_IINF_WEBSEARCH_STOPPING_CLASS), + StringUtils.split(properties.getProperty(PROPERTY_TMP_IINF_WEBSEARCH_STOPPING_CLASS_CONSTR_PARAM), + ','), + getSolrServerCacheWebsearch(), + getNLPResourcesDir(), + Boolean.valueOf(properties.getProperty(PROPERTY_TMP_SUBJECT_COLUMN_DETECTION_USE_WEBSEARCH)), + getStopwords(), + getAbsolutePath(PROPERTY_WEBSEARCH_PROP_FILE) + );// dobs + } catch (Exception e) { + e.printStackTrace(); + LOG.error(ExceptionUtils.getFullStackTrace(e)); + throw new STIException("Failed initialising SUBJECT COLUMN DETECTION components:" + properties.getProperty(PROPERTY_WEBSEARCH_PROP_FILE) + , e); + } + + LOG.info("Initializing SMP components ..."); + try { + String neRanker = properties.getProperty(PROPERTY_SMP_ENTITY_RANKER); + EntityScorer entityScorer = null; + if (neRanker != null && neRanker.equalsIgnoreCase("tmp")) { + new TMPEntityScorer( + getStopwords(), + STIConstantProperty.SCORER_ENTITY_CONTEXT_WEIGHT, + getNLPResourcesDir()); + } else if (neRanker != null && neRanker.equalsIgnoreCase("smpfreebase")) + entityScorer = new SMPAdaptedEntityScorer(getStopwords(), getNLPResourcesDir()); + else + throw new STIException(neRanker + " is not a supported option for NE Ranker"); + + Set ignoreColumnSet = new HashSet<>(); + for (int i : getIgnoreColumns()) + ignoreColumnSet.add(i); + SemanticMessagePassing smpAlgorithm = new SemanticMessagePassing( + Integer.valueOf(properties.getProperty(PROPERTY_SMP_HALTING_CONFIDTION_MAX_ITERATION, "10")), + Double.valueOf(properties.getProperty(PROPER_SMP_CHANGE_MESSAGE_SCORE_THRESHOLD, "0.5")) + ); + interpreter = new SMPInterpreter( + subcolDetector, + new TCellEntityRanker(kbSearch, entityScorer), + new TColumnClassifier(kbSearch, getClazzSpecificityCalculator()), + new TColumnColumnRelationEnumerator( + new AttributeValueMatcher( + STIConstantProperty.ATTRIBUTE_MATCHER_MIN_SCORE, + getStopwords(), StringMetrics.levenshtein()), + ignoreColumnSet, + Boolean.valueOf(properties.getProperty(PROPERTY_SMP_USE_SUBJECT_COLUMN, "false"))), + smpAlgorithm, + getIgnoreColumns(), + getMustdoColumns() + ); + } catch (Exception e) { + e.printStackTrace(); + LOG.error(ExceptionUtils.getFullStackTrace(e)); + throw new STIException("Failed initialising SMP components" + , e); + } + + } + + public static void main(String[] args) throws IOException, STIException { + String inFolder = args[0]; + String outFolder = args[1]; + SemanticMessagePassingBatch smp = new SemanticMessagePassingBatch(args[2]); + + int count = 0; + List all = Arrays.asList(new File(inFolder).listFiles()); + Collections.sort(all); + LOG.info("Initialization complete. Begin STI. Total input files=" + all.size() + "\n"); + + List previouslyFailed = smp.loadPreviouslyFailed(); + int start = smp.getStartIndex(); + for (File f : all) { + if (f.toString().contains(".DS_Store")) continue; + count++; + + //if a previously failed list of files is given, only learn these. + if (previouslyFailed.size() != 0 && !previouslyFailed.contains(count)) + continue; + + if (count - 1 < start) + continue; + boolean complete; + String inFile = f.toString(); + + try { + String sourceTableFile = inFile; + if (sourceTableFile.startsWith("\"") && sourceTableFile.endsWith("\"")) + sourceTableFile = sourceTableFile.substring(1, sourceTableFile.length() - 1).trim(); + //System.out.println(count + "_" + sourceTableFile + " " + new Date()); + LOG.info("\n<< " + count + "_" + sourceTableFile); + List
tables = smp.loadTable(inFile); + if (tables.size() == 0) + smp.recordFailure(count, inFile, inFile); + + for (Table table : tables) { + complete = smp.process( + table, + sourceTableFile, + smp.getTAnnotationWriter(), outFolder, + Boolean.valueOf(smp.properties.getProperty(PROPERTY_PERFORM_RELATION_LEARNING))); + + if (STIConstantProperty.SOLR_COMMIT_PER_FILE) + smp.commitAll(); + if (!complete) { + smp.recordFailure(count, sourceTableFile, inFile); + } + } + //gs annotator + + } catch (Exception e) { + e.printStackTrace(); + smp.recordFailure(count, inFile, inFile); + } + + } + smp.closeAll(); + LOG.info(new Date()); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputCellAnnotation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputCellAnnotation.java index 7a45e53b..043f287e 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputCellAnnotation.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputCellAnnotation.java @@ -1,35 +1,35 @@ -package uk.ac.shef.dcs.sti.io; - -import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -/** - * Created by - on 23/06/2016. - */ -public class JSONOutputCellAnnotation implements Serializable{ - private static final long serialVersionUID = -120841177231274692L; - private int columnIndex; - private int rowIndex; - private String cellText; - private List candidates; - - public JSONOutputCellAnnotation(int rowIndex, int columnIndex, String cellText){ - candidates=new ArrayList<>(); - this.rowIndex=rowIndex; - this.columnIndex=columnIndex; - this.cellText=cellText; - } - - public void add(TCellAnnotation candidate){ - String[] values = new String[3]; - - values[0] = candidate.getAnnotation().getId(); - values[1] = candidate.getAnnotation().getLabel(); - values[2] = String.valueOf(candidate.getFinalScore()); - - candidates.add(values); - } -} +package uk.ac.shef.dcs.sti.io; + +import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by - on 23/06/2016. + */ +public class JSONOutputCellAnnotation implements Serializable{ + private static final long serialVersionUID = -120841177231274692L; + private int columnIndex; + private int rowIndex; + private String cellText; + private List candidates; + + public JSONOutputCellAnnotation(int rowIndex, int columnIndex, String cellText){ + candidates=new ArrayList<>(); + this.rowIndex=rowIndex; + this.columnIndex=columnIndex; + this.cellText=cellText; + } + + public void add(TCellAnnotation candidate){ + String[] values = new String[3]; + + values[0] = candidate.getAnnotation().getId(); + values[1] = candidate.getAnnotation().getLabel(); + values[2] = String.valueOf(candidate.getFinalScore()); + + candidates.add(values); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputColumnAnnotation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputColumnAnnotation.java index 0ca7e8cd..31f54fdc 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputColumnAnnotation.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputColumnAnnotation.java @@ -1,32 +1,32 @@ -package uk.ac.shef.dcs.sti.io; -import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -/** - * Created by - on 23/06/2016. - */ -public class JSONOutputColumnAnnotation implements Serializable { - private static final long serialVersionUID = -120841111410474692L; - private int columnIndex; - private String columnText; - private List candidates; - - public JSONOutputColumnAnnotation(int columnIndex, String columnText){ - this.columnIndex=columnIndex; - candidates=new ArrayList<>(); - this.columnText=columnText; - } - - public void add(TColumnHeaderAnnotation candidate){ - String[] values = new String[3]; - - values[0] = candidate.getAnnotation().getId(); - values[1] = candidate.getAnnotation().getLabel(); - values[2] = String.valueOf(candidate.getFinalScore()); - - candidates.add(values); - } -} +package uk.ac.shef.dcs.sti.io; +import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by - on 23/06/2016. + */ +public class JSONOutputColumnAnnotation implements Serializable { + private static final long serialVersionUID = -120841111410474692L; + private int columnIndex; + private String columnText; + private List candidates; + + public JSONOutputColumnAnnotation(int columnIndex, String columnText){ + this.columnIndex=columnIndex; + candidates=new ArrayList<>(); + this.columnText=columnText; + } + + public void add(TColumnHeaderAnnotation candidate){ + String[] values = new String[3]; + + values[0] = candidate.getAnnotation().getId(); + values[1] = candidate.getAnnotation().getLabel(); + values[2] = String.valueOf(candidate.getFinalScore()); + + candidates.add(values); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotation.java index bc684d1e..30e29912 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotation.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotation.java @@ -1,35 +1,35 @@ -package uk.ac.shef.dcs.sti.io; - -import uk.ac.shef.dcs.sti.core.model.TColumnColumnRelationAnnotation; -import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -/** - * Created by - on 23/06/2016. - */ -public class JSONOutputRelationAnnotation implements Serializable{ - - private static final long serialVersionUID = -120847113231474692L; - private int fromColumnIndex; - private int toColumnIndex; - private List candidates; - - public JSONOutputRelationAnnotation(int fromColumnIndex, int toColumnIndex){ - this.fromColumnIndex=fromColumnIndex; - this.toColumnIndex=toColumnIndex; - candidates=new ArrayList<>(); - } - - public void add(TColumnColumnRelationAnnotation candidate){ - String[] values = new String[3]; - - values[0] = candidate.getRelationURI(); - values[1] = candidate.getRelationLabel(); - values[2] = String.valueOf(candidate.getFinalScore()); - - candidates.add(values); - } -} +package uk.ac.shef.dcs.sti.io; + +import uk.ac.shef.dcs.sti.core.model.TColumnColumnRelationAnnotation; +import uk.ac.shef.dcs.sti.core.model.TColumnHeaderAnnotation; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by - on 23/06/2016. + */ +public class JSONOutputRelationAnnotation implements Serializable{ + + private static final long serialVersionUID = -120847113231474692L; + private int fromColumnIndex; + private int toColumnIndex; + private List candidates; + + public JSONOutputRelationAnnotation(int fromColumnIndex, int toColumnIndex){ + this.fromColumnIndex=fromColumnIndex; + this.toColumnIndex=toColumnIndex; + candidates=new ArrayList<>(); + } + + public void add(TColumnColumnRelationAnnotation candidate){ + String[] values = new String[3]; + + values[0] = candidate.getRelationURI(); + values[1] = candidate.getRelationLabel(); + values[2] = String.valueOf(candidate.getFinalScore()); + + candidates.add(values); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotationPerRow.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotationPerRow.java index b71711a8..3324b527 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotationPerRow.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/JSONOutputRelationAnnotationPerRow.java @@ -1,35 +1,35 @@ -package uk.ac.shef.dcs.sti.io; - -import uk.ac.shef.dcs.sti.core.model.TCellCellRelationAnotation; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -/** - * Created by - on 23/06/2016. - */ -public class JSONOutputRelationAnnotationPerRow implements Serializable{ - private static final long serialVersionUID = -120847113231474692L; - private int fromColumnIndex; - private int toColumnIndex; - private int rowIndex; - private List candidates; - - public JSONOutputRelationAnnotationPerRow(int fromColumnIndex, int toColumnIndex, int rowIndex){ - this.fromColumnIndex=fromColumnIndex; - this.toColumnIndex=toColumnIndex; - this.rowIndex=rowIndex; - candidates=new ArrayList<>(); - } - - public void add(TCellCellRelationAnotation candidate){ - String[] values = new String[3]; - - values[0] = candidate.getRelationURI(); - values[1] = candidate.getRelationLabel(); - values[2] = String.valueOf(candidate.getWinningAttributeMatchScore()); - - candidates.add(values); - } -} +package uk.ac.shef.dcs.sti.io; + +import uk.ac.shef.dcs.sti.core.model.TCellCellRelationAnotation; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by - on 23/06/2016. + */ +public class JSONOutputRelationAnnotationPerRow implements Serializable{ + private static final long serialVersionUID = -120847113231474692L; + private int fromColumnIndex; + private int toColumnIndex; + private int rowIndex; + private List candidates; + + public JSONOutputRelationAnnotationPerRow(int fromColumnIndex, int toColumnIndex, int rowIndex){ + this.fromColumnIndex=fromColumnIndex; + this.toColumnIndex=toColumnIndex; + this.rowIndex=rowIndex; + candidates=new ArrayList<>(); + } + + public void add(TCellCellRelationAnotation candidate){ + String[] values = new String[3]; + + values[0] = candidate.getRelationURI(); + values[1] = candidate.getRelationLabel(); + values[2] = String.valueOf(candidate.getWinningAttributeMatchScore()); + + candidates.add(values); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriter.java index 77033fa0..e7ac96ae 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriter.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriter.java @@ -1,422 +1,422 @@ -package uk.ac.shef.dcs.sti.io; - -import uk.ac.shef.dcs.sti.util.TripleGenerator; -import uk.ac.shef.dcs.sti.util.DataTypeClassifier; -import uk.ac.shef.dcs.sti.core.model.*; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.PrintWriter; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - - */ -public class TAnnotationWriter { - - protected String linkPrefix = "http://www.freebase.com"; - protected boolean showLosingCandidates = true; - protected TripleGenerator tripleGenerator; - - public TAnnotationWriter(TripleGenerator tripleGenerator) { - this.tripleGenerator = tripleGenerator; - } - - - public void writeHTML(Table table, TAnnotation tab_annotations, String outFile) throws FileNotFoundException { - StringBuilder table_sb = new StringBuilder(); - table_sb.append("\n"); - String sourceId = table.getSourceId(); - sourceId = sourceId.replaceAll("\\\\", "/"); - int trimStart = sourceId.lastIndexOf("/"); - int trimEnd = sourceId.lastIndexOf(".htm"); - trimStart = trimStart == -1 ? 0 : trimStart; - trimEnd = trimEnd == -1 ? sourceId.length() : trimEnd; - sourceId = sourceId.substring(trimStart + 1, trimEnd); - - List triples = tripleGenerator.generate_newTriples(tab_annotations, table); - table_sb.append("source:" + sourceId + " with " + triples.size() + " new attributes."); - writeTriples(triples, outFile + ".attributes.html"); - - table_sb.append("

Table column types and entity disambiguation

\n"); - table_sb.append("
"); - table_sb.append(writeHeader(table, tab_annotations)); - table_sb.append(writeCell(table, tab_annotations)); - table_sb.append("
"); - - table_sb.append("

Table subject column and binary relations

"); - table_sb.append(""); - table_sb.append(writeRelation_inHeader(table, tab_annotations)); - table_sb.append(writeRelation_inCell(table, tab_annotations)); - table_sb.append("
\n"); - - table_sb.append(""); - - PrintWriter p = new PrintWriter(outFile); - p.println(table_sb.toString()); - p.close(); - - File f = new File(outFile); - String header_key = f.getPath() + ".header.keys"; - String relation_key = f.getPath() + ".relation.keys"; - String cell_key = f.getPath() + ".cell.keys"; - writeHeaderKeyFile(table, tab_annotations, header_key); - writeRelationKeyFile(tab_annotations, relation_key); - writeCellKeyFile(table, tab_annotations, cell_key); - - } - - protected void writeCellKeyFile(Table table, TAnnotation table_annotation, String cell_key) throws FileNotFoundException { - PrintWriter p = new PrintWriter(cell_key); - for (int r = 0; r < table.getNumRows(); r++) { - for (int c = 0; c < table.getNumCols(); c++) { - TCellAnnotation[] cans = table_annotation.getContentCellAnnotations(r, c); - if (cans != null && cans.length > 0) { - StringBuilder s = new StringBuilder(); - s.append(r).append(",").append(c).append("="); - double prevScore=0.0; - for (TCellAnnotation ca : cans) { - if (prevScore == 0.0) { - - s.append(ca.getAnnotation().getId()); - prevScore=ca.getFinalScore(); - } - else{ - if(ca.getFinalScore()==prevScore){ - s.append("=").append(ca.getAnnotation().getId()); - } - else - s.append("|").append(ca.getAnnotation().getId()); - } - } - p.println(s.toString()); - } - } - } - p.close(); - } - - protected void writeRelationKeyFile(TAnnotation table_annotation, String relation_key) throws FileNotFoundException { - PrintWriter p = new PrintWriter(relation_key); - for (Map.Entry> e : - table_annotation.getColumncolumnRelations().entrySet()) { - int subCol = e.getKey().getSubjectCol(); - int objCol = e.getKey().getObjectCol(); - List relations = e.getValue(); - Collections.sort(relations); - StringBuilder s = new StringBuilder(); - double prevScore=0.0; - for (TColumnColumnRelationAnnotation hr : relations) { - if (prevScore == 0.0) { - - s.append(hr.getRelationURI()); - prevScore=hr.getFinalScore(); - } - else{ - if(hr.getFinalScore()==prevScore){ - s.append("=").append(hr.getRelationURI()); - } - else - s.append("|").append(hr.getRelationURI()); - } - } - p.println(subCol + "," + objCol + "=" + s.toString()); - } - p.close(); - } - - protected void writeHeaderKeyFile(Table table, TAnnotation table_annotation, String header_key) throws FileNotFoundException { - PrintWriter p = new PrintWriter(header_key); - - for (int c = 0; c < table.getNumCols(); c++) { - TColumnHeaderAnnotation[] anns = table_annotation.getHeaderAnnotation(c); - if (anns != null && anns.length > 0) { - StringBuilder s = new StringBuilder(); - s.append(c).append("="); - - double prevScore = 0.0; - for (TColumnHeaderAnnotation ha : anns) { - if (prevScore == 0.0) { - - s.append(ha.getAnnotation().getId()); - prevScore=ha.getFinalScore(); - } - else{ - if(ha.getFinalScore()==prevScore){ - s.append("=").append(ha.getAnnotation().getId()); - } - else - s.append("|").append(ha.getAnnotation().getId()); - } - } - if(table.getColumnHeader(c).getFeature().getMostFrequentDataType().getType().equals( - DataTypeClassifier.DataType.NAMED_ENTITY - )) - s.append("\t\t\t___NE"); - p.println(s.toString()); - } - } - - p.close(); - } - - protected void writeTriples(List triples, String outFile) throws FileNotFoundException { - PrintWriter p = new PrintWriter(outFile); - p.println(""); - for (TableTriple ltt : triples) { - p.println("
<" + ltt.getSubject_annotation() + "," + ltt.getRelation_annotation() + "," + ltt.getObject_annotation() + ">, " + - "(" + ltt.getSubject() + "," + ltt.getObject() + "), " + "[" + ltt.getSubject_position()[0] + "," + ltt.getSubject_position()[1] + "][" + - ltt.getObject_position()[0] + "," + ltt.getObject_position()[1] + "]
"); - } - p.println(""); - p.close(); - } - - protected String writeRelation_inCell(Table table, TAnnotation tab_annotations) { - StringBuilder out = new StringBuilder(); - out.append("\n"); - for (int row = 0; row < table.getNumRows(); row++) { - for (int col = 0; col < table.getNumCols(); col++) { - String color = col == tab_annotations.getSubjectColumn() ? " bgcolor=\"yellow\"" : ""; - TCell cell = table.getContentCell(row, col); - - out.append("\t").append(cell.getText()).append(cell.getOtherText()).append("\n"); - - //then annotations - if (col == tab_annotations.getSubjectColumn()) { - out.append("\t-"); - else { - annotation.append(" bgcolor=\"#00FF00\">"); - for (int i = 0; i < cAnns.length; i++) { - TCellAnnotation cAnn = cAnns[i]; - if (i == 0) { //the winning annotation - annotation.append("
").append(generateCellAnnotationString(cAnn)).append("
"); - } else if (showLosingCandidates) { //others - annotation.append("
"). - append(generateCellAnnotationString(cAnn)).append("
"); - } - } - } - annotation.append("\t\n"); - out.append(annotation); - } else { - out.append("\t> tmp = tab_annotations.getRelationAnnotationsBetween(key.getSubjectCol(), key.getObjectCol()); - if (tmp == null) { - annotation.append(">-"); - annotation.append("\n"); - out.append(annotation); - continue; - } - List crAnns = tmp.get(row); - - if (crAnns == null) - annotation.append(">-"); - else { - Collections.sort(crAnns); - annotation.append(" bgcolor=\"#00FF00\">"); - for (int i = 0; i < crAnns.size(); i++) { - TCellCellRelationAnotation crAnn = crAnns.get(i); - if (i == 0) { //the winning annotation - annotation.append("
").append(generateAcrossCellRelationString(crAnn)).append("
"); - } else if (showLosingCandidates) { //others - annotation.append("
"). - append(generateAcrossCellRelationString(crAnn)).append("
"); - } - } - } - - annotation.append("\t\n"); - out.append(annotation); - } - } - out.append("\n"); - } - return out.toString(); - } - - protected String writeRelation_inHeader(Table table, TAnnotation tab_annotations) { - StringBuilder out = new StringBuilder(); - out.append("\n"); - for (int col = 0; col < table.getNumCols(); col++) { - String color = col == tab_annotations.getSubjectColumn() ? " bgcolor=\"yellow\"" : ""; - TColumnHeader header = table.getColumnHeader(col); - if(header==null) - continue; - out.append("\t").append(header.getHeaderText()).append("\n"); - - //then annotations - if (col == tab_annotations.getSubjectColumn()) { - out.append("\t-"); - else { - annotation.append(" bgcolor=\"#00FF00\">"); - double best_score = 0.0; - for (int i = 0; i < hAnns.length; i++) { - TColumnHeaderAnnotation hAnn = hAnns[i]; - if (i == 0) { //the winning annotation - annotation.append("
").append(generateHeaderAnnotationString(hAnn)).append("
"); - best_score = hAnn.getFinalScore(); - } else if (hAnn.getFinalScore() == best_score) { - annotation.append("
").append(generateHeaderAnnotationString(hAnn)).append("
"); - } else if (showLosingCandidates) { //others - annotation.append("
"). - append(generateHeaderAnnotationString(hAnn)).append("
"); - } - } - } - annotation.append("\t\n"); - out.append(annotation); - } else { - out.append("\t hAnns = tab_annotations.getColumncolumnRelations().get(key); - - if (hAnns == null) - annotation.append(">-"); - else { - Collections.sort(hAnns); - annotation.append(" bgcolor=\"#00FF00\">"); - for (int i = 0; i < hAnns.size(); i++) { - TColumnColumnRelationAnnotation hAnn = hAnns.get(i); - if (i == 0) { //the winning annotation - annotation.append("
").append(generateAcrossHeaderRelationString(hAnn)).append("
"); - } else if (showLosingCandidates) { //others - annotation.append("
"). - append(generateAcrossHeaderRelationString(hAnn)).append("
"); - } - } - } - - annotation.append("\t\n"); - out.append(annotation); - } - } - out.append("\n"); - return out.toString(); - } - - - protected String writeHeader(Table table, TAnnotation tab_annotations) { - StringBuilder out = new StringBuilder(); - out.append("\n"); - for (int col = 0; col < table.getNumCols(); col++) { - TColumnHeader header = table.getColumnHeader(col); - if(header==null) - continue; - out.append("\t").append(header.getHeaderText()).append("\n"); - - //then annotations - out.append("\t-"); - else { - annotation.append(" bgcolor=\"#00FF00\">"); - double best_score = 0.0; - for (int i = 0; i < hAnns.length; i++) { - TColumnHeaderAnnotation hAnn = hAnns[i]; - if (i == 0) { //the winning annotation - annotation.append("
").append(generateHeaderAnnotationString(hAnn)).append("
"); - best_score = hAnn.getFinalScore(); - } else if (hAnn.getFinalScore() == best_score) { - annotation.append("
").append(generateHeaderAnnotationString(hAnn)).append("
"); - } else if (showLosingCandidates) { //others - annotation.append("
"). - append(generateHeaderAnnotationString(hAnn)).append("
"); - } - } - } - annotation.append("\t\n"); - out.append(annotation); - } - out.append("\n"); - return out.toString(); - } - - protected String writeCell(Table table, TAnnotation tab_annotations) { - StringBuilder out = new StringBuilder(); - - for (int row = 0; row < table.getNumRows(); row++) { - out.append("\n"); - for (int col = 0; col < table.getNumCols(); col++) { - TCell tcc = table.getContentCell(row, col); - out.append("\t").append(tcc.getText()).append(tcc.getOtherText()).append("").append(" ["). - append(tcc.getType().getValue()).append("]"). - append("\n"); - - //then annotations - out.append("\t-"); - else { - annotation.append(" bgcolor=\"#00FF00\">"); - for (int i = 0; i < cAnns.length; i++) { - TCellAnnotation cAnn = cAnns[i]; - if (i == 0) { //the winning annotation - annotation.append("
").append(generateCellAnnotationString(cAnn)).append("
"); - } else if (showLosingCandidates) { //others - annotation.append("
"). - append(generateCellAnnotationString(cAnn)).append("
"); - } - } - } - annotation.append("\t\n"); - out.append(annotation); - } - out.append("\n"); - } - return out.toString(); - } - - protected Object generateCellAnnotationString(TCellAnnotation cAnn) { - StringBuilder sb = new StringBuilder(); - sb.append(""). - append(cAnn.getAnnotation().getLabel()).append(""). - append("=").append(Math.round(cAnn.getFinalScore() * 100.0) / 100.0).append(cAnn.getAnnotation().getTypeIds()); - return sb.toString(); - } - - protected String generateHeaderAnnotationString(TColumnHeaderAnnotation ha) { - StringBuilder sb = new StringBuilder(); - sb.append(""). - append(ha.getAnnotation().getId()).append("(").append(ha.getAnnotation().getId()).append(")"). - append("=").append(Math.round(ha.getFinalScore() * 100.0) / 100.0).append(ha.getSupportingRows()); - return sb.toString(); - } - - protected String generateAcrossHeaderRelationString(TColumnColumnRelationAnnotation ha) { - StringBuilder sb = new StringBuilder(); - sb.append(""). - append(ha.getRelationURI()). - append(""). - append("=").append(Math.round(ha.getFinalScore() * 100.0) / 100.0).append(ha.getSupportingRows()); - return sb.toString(); - } - - protected String generateAcrossCellRelationString(TCellCellRelationAnotation ca) { - StringBuilder sb = new StringBuilder(); - sb.append(""). - append(ca.getRelationURI()). - append(""). - append("=").append(Math.round(ca.getWinningAttributeMatchScore() * 100.0) / 100.0); - return sb.toString(); - } -} +package uk.ac.shef.dcs.sti.io; + +import uk.ac.shef.dcs.sti.util.TripleGenerator; +import uk.ac.shef.dcs.sti.util.DataTypeClassifier; +import uk.ac.shef.dcs.sti.core.model.*; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.PrintWriter; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** + + */ +public class TAnnotationWriter { + + protected String linkPrefix = "http://www.freebase.com"; + protected boolean showLosingCandidates = true; + protected TripleGenerator tripleGenerator; + + public TAnnotationWriter(TripleGenerator tripleGenerator) { + this.tripleGenerator = tripleGenerator; + } + + + public void writeHTML(Table table, TAnnotation tab_annotations, String outFile) throws FileNotFoundException { + StringBuilder table_sb = new StringBuilder(); + table_sb.append("\n"); + String sourceId = table.getSourceId(); + sourceId = sourceId.replaceAll("\\\\", "/"); + int trimStart = sourceId.lastIndexOf("/"); + int trimEnd = sourceId.lastIndexOf(".htm"); + trimStart = trimStart == -1 ? 0 : trimStart; + trimEnd = trimEnd == -1 ? sourceId.length() : trimEnd; + sourceId = sourceId.substring(trimStart + 1, trimEnd); + + List triples = tripleGenerator.generate_newTriples(tab_annotations, table); + table_sb.append("source:" + sourceId + " with " + triples.size() + " new attributes."); + writeTriples(triples, outFile + ".attributes.html"); + + table_sb.append("

Table column types and entity disambiguation

\n"); + table_sb.append(""); + table_sb.append(writeHeader(table, tab_annotations)); + table_sb.append(writeCell(table, tab_annotations)); + table_sb.append("
"); + + table_sb.append("

Table subject column and binary relations

"); + table_sb.append(""); + table_sb.append(writeRelation_inHeader(table, tab_annotations)); + table_sb.append(writeRelation_inCell(table, tab_annotations)); + table_sb.append("
\n"); + + table_sb.append(""); + + PrintWriter p = new PrintWriter(outFile); + p.println(table_sb.toString()); + p.close(); + + File f = new File(outFile); + String header_key = f.getPath() + ".header.keys"; + String relation_key = f.getPath() + ".relation.keys"; + String cell_key = f.getPath() + ".cell.keys"; + writeHeaderKeyFile(table, tab_annotations, header_key); + writeRelationKeyFile(tab_annotations, relation_key); + writeCellKeyFile(table, tab_annotations, cell_key); + + } + + protected void writeCellKeyFile(Table table, TAnnotation table_annotation, String cell_key) throws FileNotFoundException { + PrintWriter p = new PrintWriter(cell_key); + for (int r = 0; r < table.getNumRows(); r++) { + for (int c = 0; c < table.getNumCols(); c++) { + TCellAnnotation[] cans = table_annotation.getContentCellAnnotations(r, c); + if (cans != null && cans.length > 0) { + StringBuilder s = new StringBuilder(); + s.append(r).append(",").append(c).append("="); + double prevScore=0.0; + for (TCellAnnotation ca : cans) { + if (prevScore == 0.0) { + + s.append(ca.getAnnotation().getId()); + prevScore=ca.getFinalScore(); + } + else{ + if(ca.getFinalScore()==prevScore){ + s.append("=").append(ca.getAnnotation().getId()); + } + else + s.append("|").append(ca.getAnnotation().getId()); + } + } + p.println(s.toString()); + } + } + } + p.close(); + } + + protected void writeRelationKeyFile(TAnnotation table_annotation, String relation_key) throws FileNotFoundException { + PrintWriter p = new PrintWriter(relation_key); + for (Map.Entry> e : + table_annotation.getColumncolumnRelations().entrySet()) { + int subCol = e.getKey().getSubjectCol(); + int objCol = e.getKey().getObjectCol(); + List relations = e.getValue(); + Collections.sort(relations); + StringBuilder s = new StringBuilder(); + double prevScore=0.0; + for (TColumnColumnRelationAnnotation hr : relations) { + if (prevScore == 0.0) { + + s.append(hr.getRelationURI()); + prevScore=hr.getFinalScore(); + } + else{ + if(hr.getFinalScore()==prevScore){ + s.append("=").append(hr.getRelationURI()); + } + else + s.append("|").append(hr.getRelationURI()); + } + } + p.println(subCol + "," + objCol + "=" + s.toString()); + } + p.close(); + } + + protected void writeHeaderKeyFile(Table table, TAnnotation table_annotation, String header_key) throws FileNotFoundException { + PrintWriter p = new PrintWriter(header_key); + + for (int c = 0; c < table.getNumCols(); c++) { + TColumnHeaderAnnotation[] anns = table_annotation.getHeaderAnnotation(c); + if (anns != null && anns.length > 0) { + StringBuilder s = new StringBuilder(); + s.append(c).append("="); + + double prevScore = 0.0; + for (TColumnHeaderAnnotation ha : anns) { + if (prevScore == 0.0) { + + s.append(ha.getAnnotation().getId()); + prevScore=ha.getFinalScore(); + } + else{ + if(ha.getFinalScore()==prevScore){ + s.append("=").append(ha.getAnnotation().getId()); + } + else + s.append("|").append(ha.getAnnotation().getId()); + } + } + if(table.getColumnHeader(c).getFeature().getMostFrequentDataType().getType().equals( + DataTypeClassifier.DataType.NAMED_ENTITY + )) + s.append("\t\t\t___NE"); + p.println(s.toString()); + } + } + + p.close(); + } + + protected void writeTriples(List triples, String outFile) throws FileNotFoundException { + PrintWriter p = new PrintWriter(outFile); + p.println(""); + for (TableTriple ltt : triples) { + p.println("
<" + ltt.getSubject_annotation() + "," + ltt.getRelation_annotation() + "," + ltt.getObject_annotation() + ">, " + + "(" + ltt.getSubject() + "," + ltt.getObject() + "), " + "[" + ltt.getSubject_position()[0] + "," + ltt.getSubject_position()[1] + "][" + + ltt.getObject_position()[0] + "," + ltt.getObject_position()[1] + "]
"); + } + p.println(""); + p.close(); + } + + protected String writeRelation_inCell(Table table, TAnnotation tab_annotations) { + StringBuilder out = new StringBuilder(); + out.append("\n"); + for (int row = 0; row < table.getNumRows(); row++) { + for (int col = 0; col < table.getNumCols(); col++) { + String color = col == tab_annotations.getSubjectColumn() ? " bgcolor=\"yellow\"" : ""; + TCell cell = table.getContentCell(row, col); + + out.append("\t").append(cell.getText()).append(cell.getOtherText()).append("\n"); + + //then annotations + if (col == tab_annotations.getSubjectColumn()) { + out.append("\t-"); + else { + annotation.append(" bgcolor=\"#00FF00\">"); + for (int i = 0; i < cAnns.length; i++) { + TCellAnnotation cAnn = cAnns[i]; + if (i == 0) { //the winning annotation + annotation.append("
").append(generateCellAnnotationString(cAnn)).append("
"); + } else if (showLosingCandidates) { //others + annotation.append("
"). + append(generateCellAnnotationString(cAnn)).append("
"); + } + } + } + annotation.append("\t\n"); + out.append(annotation); + } else { + out.append("\t> tmp = tab_annotations.getRelationAnnotationsBetween(key.getSubjectCol(), key.getObjectCol()); + if (tmp == null) { + annotation.append(">-"); + annotation.append("\n"); + out.append(annotation); + continue; + } + List crAnns = tmp.get(row); + + if (crAnns == null) + annotation.append(">-"); + else { + Collections.sort(crAnns); + annotation.append(" bgcolor=\"#00FF00\">"); + for (int i = 0; i < crAnns.size(); i++) { + TCellCellRelationAnotation crAnn = crAnns.get(i); + if (i == 0) { //the winning annotation + annotation.append("
").append(generateAcrossCellRelationString(crAnn)).append("
"); + } else if (showLosingCandidates) { //others + annotation.append("
"). + append(generateAcrossCellRelationString(crAnn)).append("
"); + } + } + } + + annotation.append("\t\n"); + out.append(annotation); + } + } + out.append("\n"); + } + return out.toString(); + } + + protected String writeRelation_inHeader(Table table, TAnnotation tab_annotations) { + StringBuilder out = new StringBuilder(); + out.append("\n"); + for (int col = 0; col < table.getNumCols(); col++) { + String color = col == tab_annotations.getSubjectColumn() ? " bgcolor=\"yellow\"" : ""; + TColumnHeader header = table.getColumnHeader(col); + if(header==null) + continue; + out.append("\t").append(header.getHeaderText()).append("\n"); + + //then annotations + if (col == tab_annotations.getSubjectColumn()) { + out.append("\t-"); + else { + annotation.append(" bgcolor=\"#00FF00\">"); + double best_score = 0.0; + for (int i = 0; i < hAnns.length; i++) { + TColumnHeaderAnnotation hAnn = hAnns[i]; + if (i == 0) { //the winning annotation + annotation.append("
").append(generateHeaderAnnotationString(hAnn)).append("
"); + best_score = hAnn.getFinalScore(); + } else if (hAnn.getFinalScore() == best_score) { + annotation.append("
").append(generateHeaderAnnotationString(hAnn)).append("
"); + } else if (showLosingCandidates) { //others + annotation.append("
"). + append(generateHeaderAnnotationString(hAnn)).append("
"); + } + } + } + annotation.append("\t\n"); + out.append(annotation); + } else { + out.append("\t hAnns = tab_annotations.getColumncolumnRelations().get(key); + + if (hAnns == null) + annotation.append(">-"); + else { + Collections.sort(hAnns); + annotation.append(" bgcolor=\"#00FF00\">"); + for (int i = 0; i < hAnns.size(); i++) { + TColumnColumnRelationAnnotation hAnn = hAnns.get(i); + if (i == 0) { //the winning annotation + annotation.append("
").append(generateAcrossHeaderRelationString(hAnn)).append("
"); + } else if (showLosingCandidates) { //others + annotation.append("
"). + append(generateAcrossHeaderRelationString(hAnn)).append("
"); + } + } + } + + annotation.append("\t\n"); + out.append(annotation); + } + } + out.append("\n"); + return out.toString(); + } + + + protected String writeHeader(Table table, TAnnotation tab_annotations) { + StringBuilder out = new StringBuilder(); + out.append("\n"); + for (int col = 0; col < table.getNumCols(); col++) { + TColumnHeader header = table.getColumnHeader(col); + if(header==null) + continue; + out.append("\t").append(header.getHeaderText()).append("\n"); + + //then annotations + out.append("\t-"); + else { + annotation.append(" bgcolor=\"#00FF00\">"); + double best_score = 0.0; + for (int i = 0; i < hAnns.length; i++) { + TColumnHeaderAnnotation hAnn = hAnns[i]; + if (i == 0) { //the winning annotation + annotation.append("
").append(generateHeaderAnnotationString(hAnn)).append("
"); + best_score = hAnn.getFinalScore(); + } else if (hAnn.getFinalScore() == best_score) { + annotation.append("
").append(generateHeaderAnnotationString(hAnn)).append("
"); + } else if (showLosingCandidates) { //others + annotation.append("
"). + append(generateHeaderAnnotationString(hAnn)).append("
"); + } + } + } + annotation.append("\t\n"); + out.append(annotation); + } + out.append("\n"); + return out.toString(); + } + + protected String writeCell(Table table, TAnnotation tab_annotations) { + StringBuilder out = new StringBuilder(); + + for (int row = 0; row < table.getNumRows(); row++) { + out.append("\n"); + for (int col = 0; col < table.getNumCols(); col++) { + TCell tcc = table.getContentCell(row, col); + out.append("\t").append(tcc.getText()).append(tcc.getOtherText()).append("").append(" ["). + append(tcc.getType().getValue()).append("]"). + append("\n"); + + //then annotations + out.append("\t-"); + else { + annotation.append(" bgcolor=\"#00FF00\">"); + for (int i = 0; i < cAnns.length; i++) { + TCellAnnotation cAnn = cAnns[i]; + if (i == 0) { //the winning annotation + annotation.append("
").append(generateCellAnnotationString(cAnn)).append("
"); + } else if (showLosingCandidates) { //others + annotation.append("
"). + append(generateCellAnnotationString(cAnn)).append("
"); + } + } + } + annotation.append("\t\n"); + out.append(annotation); + } + out.append("\n"); + } + return out.toString(); + } + + protected Object generateCellAnnotationString(TCellAnnotation cAnn) { + StringBuilder sb = new StringBuilder(); + sb.append(""). + append(cAnn.getAnnotation().getLabel()).append(""). + append("=").append(Math.round(cAnn.getFinalScore() * 100.0) / 100.0).append(cAnn.getAnnotation().getTypeIds()); + return sb.toString(); + } + + protected String generateHeaderAnnotationString(TColumnHeaderAnnotation ha) { + StringBuilder sb = new StringBuilder(); + sb.append(""). + append(ha.getAnnotation().getId()).append("(").append(ha.getAnnotation().getId()).append(")"). + append("=").append(Math.round(ha.getFinalScore() * 100.0) / 100.0).append(ha.getSupportingRows()); + return sb.toString(); + } + + protected String generateAcrossHeaderRelationString(TColumnColumnRelationAnnotation ha) { + StringBuilder sb = new StringBuilder(); + sb.append(""). + append(ha.getRelationURI()). + append(""). + append("=").append(Math.round(ha.getFinalScore() * 100.0) / 100.0).append(ha.getSupportingRows()); + return sb.toString(); + } + + protected String generateAcrossCellRelationString(TCellCellRelationAnotation ca) { + StringBuilder sb = new StringBuilder(); + sb.append(""). + append(ca.getRelationURI()). + append(""). + append("=").append(Math.round(ca.getWinningAttributeMatchScore() * 100.0) / 100.0); + return sb.toString(); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriterJSON.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriterJSON.java index 3e881f55..2e9a52dc 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriterJSON.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/io/TAnnotationWriterJSON.java @@ -1,129 +1,129 @@ -package uk.ac.shef.dcs.sti.io; - -import com.google.gson.Gson; -import javafx.util.Pair; -import org.apache.jena.reasoner.rulesys.builtins.Print; -import uk.ac.shef.dcs.kbsearch.model.Clazz; -import uk.ac.shef.dcs.sti.core.model.*; -import uk.ac.shef.dcs.sti.util.TripleGenerator; - -import java.io.FileNotFoundException; -import java.io.PrintWriter; -import java.util.*; -import java.util.List; - -/** - * Created by - on 23/06/2016. - */ -public class TAnnotationWriterJSON extends TAnnotationWriter { - protected Gson gson = new Gson(); - - public TAnnotationWriterJSON(TripleGenerator tripleGenerator) { - super(tripleGenerator); - } - - protected void writeCellKeyFile(Table table, TAnnotation table_annotation, String cell_key) throws FileNotFoundException { - PrintWriter p = new PrintWriter(cell_key); - PrintWriter p_cellCllass= new PrintWriter(cell_key+".clazz"); - - List jsonCells = new ArrayList<>(); - List>> cellCandidateEntityAndClass = new ArrayList<>(); - for (int r = 0; r < table.getNumRows(); r++) { - for (int c = 0; c < table.getNumCols(); c++) { - JSONOutputCellAnnotation jc = new JSONOutputCellAnnotation(r, c, table.getContentCell(r,c).getText()); - TCellAnnotation[] cans = table_annotation.getContentCellAnnotations(r, c); - //if (cans != null && cans.length > 0) { - for (TCellAnnotation ca : cans) { - jc.add(ca); - - Set classes = new HashSet<>(); - for(Clazz clazz: ca.getAnnotation().getTypes()) - classes.add(clazz.getId()); - Pair> entityClasses = new Pair<>(ca.getAnnotation().getId(), - classes); - cellCandidateEntityAndClass.add(entityClasses); - } - //} - jsonCells.add(jc); - } - } - - String string = gson.toJson(jsonCells); - p.println(string); - p.close(); - - string=gson.toJson(cellCandidateEntityAndClass); - p_cellCllass.println(string); - p_cellCllass.close(); - } - - protected void writeRelationKeyFile(TAnnotation table_annotation, String relation_key) throws FileNotFoundException { - PrintWriter p = new PrintWriter(relation_key); - PrintWriter pc = new PrintWriter(relation_key+".cell"); - - List jrs = new ArrayList<>(); - for (Map.Entry> e : - table_annotation.getColumncolumnRelations().entrySet()) { - int subCol = e.getKey().getSubjectCol(); - int objCol = e.getKey().getObjectCol(); - JSONOutputRelationAnnotation jr = new JSONOutputRelationAnnotation(subCol, objCol); - java.util.List relations = e.getValue(); - Collections.sort(relations); - for (TColumnColumnRelationAnnotation hr : relations) { - jr.add(hr); - } - jrs.add(jr); - } - String string = gson.toJson(jrs); - p.println(string); - p.close(); - - - List jrcs = new ArrayList<>(); - for (Map.Entry> e : - table_annotation.getColumncolumnRelations().entrySet()) { - int subCol = e.getKey().getSubjectCol(); - int objCol = e.getKey().getObjectCol(); - - Map> rpr= - table_annotation.getRelationAnnotationsBetween(subCol, objCol); - - for(Map.Entry> en: - rpr.entrySet()){ - int row=en.getKey(); - List rprc = en.getValue(); - JSONOutputRelationAnnotationPerRow o = new JSONOutputRelationAnnotationPerRow(subCol,objCol,row); - for(TCellCellRelationAnotation cc: rprc){ - o.add(cc); - } - jrcs.add(o); - } - - } - string = gson.toJson(jrcs); - pc.println(string); - pc.close(); - - - } - - protected void writeHeaderKeyFile(Table table, TAnnotation table_annotation, String header_key) throws FileNotFoundException { - PrintWriter p = new PrintWriter(header_key); - - List jsonColumns = new ArrayList<>(); - for (int c = 0; c < table.getNumCols(); c++) { - TColumnHeaderAnnotation[] anns = table_annotation.getHeaderAnnotation(c); - JSONOutputColumnAnnotation jc = new JSONOutputColumnAnnotation(c, table.getColumnHeader(c).getHeaderText()); - //if (anns != null && anns.length > 0) { - for (TColumnHeaderAnnotation ha : anns) { - jc.add(ha); - } - //} - jsonColumns.add(jc); - } - String string = gson.toJson(jsonColumns); - p.println(string); - p.close(); - - } -} +package uk.ac.shef.dcs.sti.io; + +import com.google.gson.Gson; +import javafx.util.Pair; +import org.apache.jena.reasoner.rulesys.builtins.Print; +import uk.ac.shef.dcs.kbsearch.model.Clazz; +import uk.ac.shef.dcs.sti.core.model.*; +import uk.ac.shef.dcs.sti.util.TripleGenerator; + +import java.io.FileNotFoundException; +import java.io.PrintWriter; +import java.util.*; +import java.util.List; + +/** + * Created by - on 23/06/2016. + */ +public class TAnnotationWriterJSON extends TAnnotationWriter { + protected Gson gson = new Gson(); + + public TAnnotationWriterJSON(TripleGenerator tripleGenerator) { + super(tripleGenerator); + } + + protected void writeCellKeyFile(Table table, TAnnotation table_annotation, String cell_key) throws FileNotFoundException { + PrintWriter p = new PrintWriter(cell_key); + PrintWriter p_cellCllass= new PrintWriter(cell_key+".clazz"); + + List jsonCells = new ArrayList<>(); + List>> cellCandidateEntityAndClass = new ArrayList<>(); + for (int r = 0; r < table.getNumRows(); r++) { + for (int c = 0; c < table.getNumCols(); c++) { + JSONOutputCellAnnotation jc = new JSONOutputCellAnnotation(r, c, table.getContentCell(r,c).getText()); + TCellAnnotation[] cans = table_annotation.getContentCellAnnotations(r, c); + //if (cans != null && cans.length > 0) { + for (TCellAnnotation ca : cans) { + jc.add(ca); + + Set classes = new HashSet<>(); + for(Clazz clazz: ca.getAnnotation().getTypes()) + classes.add(clazz.getId()); + Pair> entityClasses = new Pair<>(ca.getAnnotation().getId(), + classes); + cellCandidateEntityAndClass.add(entityClasses); + } + //} + jsonCells.add(jc); + } + } + + String string = gson.toJson(jsonCells); + p.println(string); + p.close(); + + string=gson.toJson(cellCandidateEntityAndClass); + p_cellCllass.println(string); + p_cellCllass.close(); + } + + protected void writeRelationKeyFile(TAnnotation table_annotation, String relation_key) throws FileNotFoundException { + PrintWriter p = new PrintWriter(relation_key); + PrintWriter pc = new PrintWriter(relation_key+".cell"); + + List jrs = new ArrayList<>(); + for (Map.Entry> e : + table_annotation.getColumncolumnRelations().entrySet()) { + int subCol = e.getKey().getSubjectCol(); + int objCol = e.getKey().getObjectCol(); + JSONOutputRelationAnnotation jr = new JSONOutputRelationAnnotation(subCol, objCol); + java.util.List relations = e.getValue(); + Collections.sort(relations); + for (TColumnColumnRelationAnnotation hr : relations) { + jr.add(hr); + } + jrs.add(jr); + } + String string = gson.toJson(jrs); + p.println(string); + p.close(); + + + List jrcs = new ArrayList<>(); + for (Map.Entry> e : + table_annotation.getColumncolumnRelations().entrySet()) { + int subCol = e.getKey().getSubjectCol(); + int objCol = e.getKey().getObjectCol(); + + Map> rpr= + table_annotation.getRelationAnnotationsBetween(subCol, objCol); + + for(Map.Entry> en: + rpr.entrySet()){ + int row=en.getKey(); + List rprc = en.getValue(); + JSONOutputRelationAnnotationPerRow o = new JSONOutputRelationAnnotationPerRow(subCol,objCol,row); + for(TCellCellRelationAnotation cc: rprc){ + o.add(cc); + } + jrcs.add(o); + } + + } + string = gson.toJson(jrcs); + pc.println(string); + pc.close(); + + + } + + protected void writeHeaderKeyFile(Table table, TAnnotation table_annotation, String header_key) throws FileNotFoundException { + PrintWriter p = new PrintWriter(header_key); + + List jsonColumns = new ArrayList<>(); + for (int c = 0; c < table.getNumCols(); c++) { + TColumnHeaderAnnotation[] anns = table_annotation.getHeaderAnnotation(c); + JSONOutputColumnAnnotation jc = new JSONOutputColumnAnnotation(c, table.getColumnHeader(c).getHeaderText()); + //if (anns != null && anns.length > 0) { + for (TColumnHeaderAnnotation ha : anns) { + jc.add(ha); + } + //} + jsonColumns.add(jc); + } + String string = gson.toJson(jsonColumns); + p.println(string); + p.close(); + + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/nlp/Lemmatizer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/nlp/Lemmatizer.java index 6c55abf1..8f07fe35 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/nlp/Lemmatizer.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/nlp/Lemmatizer.java @@ -1,57 +1,57 @@ -package uk.ac.shef.dcs.sti.nlp; - -import dragon.nlp.tool.lemmatiser.EngLemmatiser; - -import java.util.*; - -/** - */ -public class Lemmatizer { - - private EngLemmatiser lemmatizer; - private Map tagLookUp = new HashMap<>(); - - public Lemmatizer(String dict) { - init(dict); - } - - private void init(String dict) { - lemmatizer = new EngLemmatiser(dict, false, true); - tagLookUp.put("NN", 1); - tagLookUp.put("NNS", 1); - tagLookUp.put("NNP", 1); - tagLookUp.put("NNPS", 1); - tagLookUp.put("VB", 2); - tagLookUp.put("VBG", 2); - tagLookUp.put("VBD", 2); - tagLookUp.put("VBN", 2); - tagLookUp.put("VBP", 2); - tagLookUp.put("VBZ", 2); - tagLookUp.put("JJ", 3); - tagLookUp.put("JJR", 3); - tagLookUp.put("JJS", 3); - tagLookUp.put("RB", 4); - tagLookUp.put("RBR", 4); - tagLookUp.put("RBS", 4); - } - - public String getLemma(String value, String pos) { - int POS = tagLookUp.get(pos); - if (POS == 0) - return lemmatizer.lemmatize(value); - else - return lemmatizer.lemmatize(value, POS); - } - - public List lemmatize(Collection words){ - List lemmas = new ArrayList<>(); - for(String w: words){ - String lem = getLemma(w, "NN"); - if(lem.trim().length()<1) - continue; - lemmas.add(lem); - } - return lemmas; - } - -} +package uk.ac.shef.dcs.sti.nlp; + +import dragon.nlp.tool.lemmatiser.EngLemmatiser; + +import java.util.*; + +/** + */ +public class Lemmatizer { + + private EngLemmatiser lemmatizer; + private Map tagLookUp = new HashMap<>(); + + public Lemmatizer(String dict) { + init(dict); + } + + private void init(String dict) { + lemmatizer = new EngLemmatiser(dict, false, true); + tagLookUp.put("NN", 1); + tagLookUp.put("NNS", 1); + tagLookUp.put("NNP", 1); + tagLookUp.put("NNPS", 1); + tagLookUp.put("VB", 2); + tagLookUp.put("VBG", 2); + tagLookUp.put("VBD", 2); + tagLookUp.put("VBN", 2); + tagLookUp.put("VBP", 2); + tagLookUp.put("VBZ", 2); + tagLookUp.put("JJ", 3); + tagLookUp.put("JJR", 3); + tagLookUp.put("JJS", 3); + tagLookUp.put("RB", 4); + tagLookUp.put("RBR", 4); + tagLookUp.put("RBS", 4); + } + + public String getLemma(String value, String pos) { + int POS = tagLookUp.get(pos); + if (POS == 0) + return lemmatizer.lemmatize(value); + else + return lemmatizer.lemmatize(value, POS); + } + + public List lemmatize(Collection words){ + List lemmas = new ArrayList<>(); + for(String w: words){ + String lem = getLemma(w, "NN"); + if(lem.trim().length()<1) + continue; + lemmas.add(lem); + } + return lemmas; + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/nlp/NLPTools.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/nlp/NLPTools.java index 7dc0fdcc..f6892eea 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/nlp/NLPTools.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/nlp/NLPTools.java @@ -1,78 +1,78 @@ -package uk.ac.shef.dcs.sti.nlp; - -import opennlp.tools.chunker.Chunker; -import opennlp.tools.chunker.ChunkerME; -import opennlp.tools.chunker.ChunkerModel; -import opennlp.tools.postag.POSModel; -import opennlp.tools.postag.POSTagger; -import opennlp.tools.postag.POSTaggerME; -import opennlp.tools.sentdetect.SentenceDetector; -import opennlp.tools.sentdetect.SentenceDetectorME; -import opennlp.tools.sentdetect.SentenceModel; -import opennlp.tools.tokenize.Tokenizer; -import opennlp.tools.tokenize.TokenizerME; -import opennlp.tools.tokenize.TokenizerModel; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; - -/** - - */ -public class NLPTools { - private static NLPTools _ref; - private POSTagger _posTagger; - private Chunker _npChunker; - private SentenceDetector _sentDetect; - private Tokenizer _tokenizer; - private Lemmatizer _lemmatizer; - - private NLPTools(String nlpResources) throws IOException { - _lemmatizer=new Lemmatizer(nlpResources + File.separator + "lemmatizer"); - POSModel posModel = new POSModel(new FileInputStream(nlpResources+"/en-pos-maxent.bin")); - _posTagger = new POSTaggerME(posModel); - - ChunkerModel chunkerModel = new ChunkerModel(new FileInputStream(nlpResources+"/en-chunker.bin")); - _npChunker = new ChunkerME(chunkerModel); - - TokenizerModel tokenizerModel = new TokenizerModel(new FileInputStream(nlpResources+"/en-token.bin")); - _tokenizer = new TokenizerME(tokenizerModel); - - SentenceModel sentModel = new SentenceModel(new FileInputStream(nlpResources+"/en-sent.bin")); - _sentDetect = new SentenceDetectorME(sentModel); - } - - public static NLPTools getInstance(String nlpResources) throws IOException { - if(_ref ==null) _ref=new NLPTools(nlpResources); - return _ref; - } - - public Object clone() throws CloneNotSupportedException { - throw new CloneNotSupportedException(); - } - - public POSTagger getPosTagger() { - return _posTagger; - } - - public Chunker getPhraseChunker() { - return _npChunker; - } - - public SentenceDetector getSentenceSplitter() { - return _sentDetect; - } - - public Tokenizer getTokeniser() { - return _tokenizer; - } - - public Lemmatizer getLemmatizer() { - return _lemmatizer; - } - - public void setLemmatizer(Lemmatizer _lemmatizer) { - this._lemmatizer = _lemmatizer; - } -} +package uk.ac.shef.dcs.sti.nlp; + +import opennlp.tools.chunker.Chunker; +import opennlp.tools.chunker.ChunkerME; +import opennlp.tools.chunker.ChunkerModel; +import opennlp.tools.postag.POSModel; +import opennlp.tools.postag.POSTagger; +import opennlp.tools.postag.POSTaggerME; +import opennlp.tools.sentdetect.SentenceDetector; +import opennlp.tools.sentdetect.SentenceDetectorME; +import opennlp.tools.sentdetect.SentenceModel; +import opennlp.tools.tokenize.Tokenizer; +import opennlp.tools.tokenize.TokenizerME; +import opennlp.tools.tokenize.TokenizerModel; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; + +/** + + */ +public class NLPTools { + private static NLPTools _ref; + private POSTagger _posTagger; + private Chunker _npChunker; + private SentenceDetector _sentDetect; + private Tokenizer _tokenizer; + private Lemmatizer _lemmatizer; + + private NLPTools(String nlpResources) throws IOException { + _lemmatizer=new Lemmatizer(nlpResources + File.separator + "lemmatizer"); + POSModel posModel = new POSModel(new FileInputStream(nlpResources+"/en-pos-maxent.bin")); + _posTagger = new POSTaggerME(posModel); + + ChunkerModel chunkerModel = new ChunkerModel(new FileInputStream(nlpResources+"/en-chunker.bin")); + _npChunker = new ChunkerME(chunkerModel); + + TokenizerModel tokenizerModel = new TokenizerModel(new FileInputStream(nlpResources+"/en-token.bin")); + _tokenizer = new TokenizerME(tokenizerModel); + + SentenceModel sentModel = new SentenceModel(new FileInputStream(nlpResources+"/en-sent.bin")); + _sentDetect = new SentenceDetectorME(sentModel); + } + + public static NLPTools getInstance(String nlpResources) throws IOException { + if(_ref ==null) _ref=new NLPTools(nlpResources); + return _ref; + } + + public Object clone() throws CloneNotSupportedException { + throw new CloneNotSupportedException(); + } + + public POSTagger getPosTagger() { + return _posTagger; + } + + public Chunker getPhraseChunker() { + return _npChunker; + } + + public SentenceDetector getSentenceSplitter() { + return _sentDetect; + } + + public Tokenizer getTokeniser() { + return _tokenizer; + } + + public Lemmatizer getLemmatizer() { + return _lemmatizer; + } + + public void setLemmatizer(Lemmatizer _lemmatizer) { + this._lemmatizer = _lemmatizer; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/nlp/TermFreqCounter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/nlp/TermFreqCounter.java index 44555ea9..3534902e 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/nlp/TermFreqCounter.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/nlp/TermFreqCounter.java @@ -1,39 +1,39 @@ -package uk.ac.shef.dcs.sti.nlp; - -import java.util.HashSet; -import java.util.Set; - -/** - */ -public class TermFreqCounter { - - /** - * Count number of occurrences of a string in a context. - * - * @param noun the string to be counted - * @param context the text in which the string can be found - * @return int array which contains offsets of occurrences in the text. - */ - public Set countOffsets(String noun, String context) { - Set offsets = new HashSet(); - int next; - int start = 0; - while (start <= context.length()) { - next = context.indexOf(noun, start); - char prefix = next - 1 < 0 ? ' ' : context.charAt(next - 1); - char suffix = next + noun.length() >= context.length() ? ' ' : context.charAt(next + noun.length()); - if (next != -1 && isValidChar(prefix) && isValidChar(suffix)) { - offsets.add(next); - } - if (next == -1) break; - start = next + noun.length(); - } - - - return offsets; - } - - private boolean isValidChar(char c) { - return !Character.isLetter(c) && !Character.isDigit(c); - } -} +package uk.ac.shef.dcs.sti.nlp; + +import java.util.HashSet; +import java.util.Set; + +/** + */ +public class TermFreqCounter { + + /** + * Count number of occurrences of a string in a context. + * + * @param noun the string to be counted + * @param context the text in which the string can be found + * @return int array which contains offsets of occurrences in the text. + */ + public Set countOffsets(String noun, String context) { + Set offsets = new HashSet(); + int next; + int start = 0; + while (start <= context.length()) { + next = context.indexOf(noun, start); + char prefix = next - 1 < 0 ? ' ' : context.charAt(next - 1); + char suffix = next + noun.length() >= context.length() ? ' ' : context.charAt(next + noun.length()); + if (next != -1 && isValidChar(prefix) && isValidChar(suffix)) { + offsets.add(next); + } + if (next == -1) break; + start = next + noun.length(); + } + + + return offsets; + } + + private boolean isValidChar(char c) { + return !Character.isLetter(c) && !Character.isDigit(c); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/ContentValidator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/ContentValidator.java index 73e48ec9..19e54a56 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/ContentValidator.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/ContentValidator.java @@ -1,76 +1,76 @@ -package uk.ac.shef.dcs.sti.parser; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 10/10/12 - * Time: 15:50 - */ -public abstract class ContentValidator { - - protected static final String[] ORDINALS = {"first", "1st", "second", "2nd", "third", "3rd", "fourth", "4th", - "fifth", "5th", "sixth", "6th", "seventh", "7th", "eighth", "8th", "ninth", "9th", "tenth", "10th", - "eleventh", "11th", "twelfth", "12th", "teenth", "13th", "tieth"}; - - - /** - * @param tc - * @return true if phrase contains >50% numeric tokens (including ordinals) - */ - public static boolean isNumericContent(String tc) { - String[] parts = tc.toLowerCase().split("\\s+"); - int countNumericParts = 0; - for (String p : parts) { - boolean isPartNumeric = false; - for (String ord : ORDINALS) { - if (p.endsWith(ord)) { - countNumericParts++; - isPartNumeric = true; - break; - } - } - if (!isPartNumeric) { - boolean skip = false; - int countDigits = 0; - for (int i = 0; i < p.length(); i++) { - if (Character.isDigit(tc.charAt(i))) { - countDigits++; - } - if (Character.isLetter(tc.charAt(i))) { - skip = true; - break; - } - } - if (!skip && countDigits > tc.length() * 0.5) - countNumericParts++; - } - } - - return countNumericParts > parts.length * 0.5; - } - - public static boolean isEmptyString(String string) { - string = string.replaceAll("[^a-zA-Z0-9]", ""); //only consider english - return string.length() == 0; - } - - public static boolean isEmptyMediaWikiString(String string) { - if (string.startsWith("{{") && string.endsWith("}}")) - return true; - return isEmptyString(string); - } - - public static boolean isWikiInternalLink(String uri) { - if (uri == null) - return false; - if (uri.startsWith("/")) //pointing to a wikipedia article - return true; - else if (uri.startsWith("http") || uri.startsWith("www")) { - if (uri.indexOf("en.wikipedia") != -1) - return true; - return false; - } - return false; - } - - -} +package uk.ac.shef.dcs.sti.parser; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 10/10/12 + * Time: 15:50 + */ +public abstract class ContentValidator { + + protected static final String[] ORDINALS = {"first", "1st", "second", "2nd", "third", "3rd", "fourth", "4th", + "fifth", "5th", "sixth", "6th", "seventh", "7th", "eighth", "8th", "ninth", "9th", "tenth", "10th", + "eleventh", "11th", "twelfth", "12th", "teenth", "13th", "tieth"}; + + + /** + * @param tc + * @return true if phrase contains >50% numeric tokens (including ordinals) + */ + public static boolean isNumericContent(String tc) { + String[] parts = tc.toLowerCase().split("\\s+"); + int countNumericParts = 0; + for (String p : parts) { + boolean isPartNumeric = false; + for (String ord : ORDINALS) { + if (p.endsWith(ord)) { + countNumericParts++; + isPartNumeric = true; + break; + } + } + if (!isPartNumeric) { + boolean skip = false; + int countDigits = 0; + for (int i = 0; i < p.length(); i++) { + if (Character.isDigit(tc.charAt(i))) { + countDigits++; + } + if (Character.isLetter(tc.charAt(i))) { + skip = true; + break; + } + } + if (!skip && countDigits > tc.length() * 0.5) + countNumericParts++; + } + } + + return countNumericParts > parts.length * 0.5; + } + + public static boolean isEmptyString(String string) { + string = string.replaceAll("[^a-zA-Z0-9]", ""); //only consider english + return string.length() == 0; + } + + public static boolean isEmptyMediaWikiString(String string) { + if (string.startsWith("{{") && string.endsWith("}}")) + return true; + return isEmptyString(string); + } + + public static boolean isWikiInternalLink(String uri) { + if (uri == null) + return false; + if (uri.startsWith("/")) //pointing to a wikipedia article + return true; + else if (uri.startsWith("http") || uri.startsWith("www")) { + if (uri.indexOf("en.wikipedia") != -1) + return true; + return false; + } + return false; + } + + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractor.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractor.java index f4b68df9..fe7d96af 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractor.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractor.java @@ -1,88 +1,88 @@ -package uk.ac.shef.dcs.sti.parser.list; - -import org.apache.any23.extractor.html.TagSoupParser; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import uk.ac.shef.dcs.sti.core.model.List; -import uk.ac.shef.dcs.sti.core.model.ListItem; -import uk.ac.shef.dcs.sti.parser.list.splitter.ListItemSplitter; -import uk.ac.shef.dcs.sti.parser.list.validator.ListValidator; - -import java.io.*; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 09/10/12 - * Time: 11:06 - */ -public abstract class ListXtractor { - - private ListItemSplitter tokenizer; - protected ListValidator[] validators; - protected TagSoupParser parser; - - public ListXtractor(ListItemSplitter tokenizer, ListValidator... validators) { - this.validators = validators; - this.tokenizer = tokenizer; - } - - public abstract java.util.List extract(String input, String sourceId) throws IOException; - - /** - * ONLY extracts IMMEDIATE children - * - * @param listElement - * @param listId - * @param sourceId - * @param contexts - * @return - */ - protected List extractList(Node listElement, String listId, String sourceId, String... contexts) { - /*if (sourceId.startsWith("Anarchism")) - System.out.print("");*/ - List list = new List(sourceId, listId); - for (String ctx : contexts) - list.addContext(ctx); - - NodeList it = listElement.getChildNodes(); - for (int i = 0; i < it.getLength(); i++) { - Node liElement = it.item(i); - if(liElement.getNodeType()==3) - continue; - ListItem li = tokenizer.tokenize(liElement); - if (li != null) - list.addItem(li); - } - - for (ListValidator v : validators) { - if (!v.isValid(list)) - return null; - } - return list; - } - - public static void serialize(List list, String targetDir) throws IOException { - File dir = new File(targetDir); - if (!dir.exists()) - dir.mkdirs(); - String filename = targetDir + File.separator + list.getSourceId().replaceAll("[^\\d\\w]", "_") + "_" + list.getListId(); - - FileOutputStream fileOut = - new FileOutputStream(filename); - ObjectOutputStream out = - new ObjectOutputStream(fileOut); - out.writeObject(list); - out.close(); - fileOut.close(); - } - - public static List deserialize(String filename) throws IOException, ClassNotFoundException { - FileInputStream fileIn = - new FileInputStream(filename); - ObjectInputStream in = new ObjectInputStream(fileIn); - List list = (List) in.readObject(); - in.close(); - fileIn.close(); - return list; - } -} +package uk.ac.shef.dcs.sti.parser.list; + +import org.apache.any23.extractor.html.TagSoupParser; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import uk.ac.shef.dcs.sti.core.model.List; +import uk.ac.shef.dcs.sti.core.model.ListItem; +import uk.ac.shef.dcs.sti.parser.list.splitter.ListItemSplitter; +import uk.ac.shef.dcs.sti.parser.list.validator.ListValidator; + +import java.io.*; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 09/10/12 + * Time: 11:06 + */ +public abstract class ListXtractor { + + private ListItemSplitter tokenizer; + protected ListValidator[] validators; + protected TagSoupParser parser; + + public ListXtractor(ListItemSplitter tokenizer, ListValidator... validators) { + this.validators = validators; + this.tokenizer = tokenizer; + } + + public abstract java.util.List extract(String input, String sourceId) throws IOException; + + /** + * ONLY extracts IMMEDIATE children + * + * @param listElement + * @param listId + * @param sourceId + * @param contexts + * @return + */ + protected List extractList(Node listElement, String listId, String sourceId, String... contexts) { + /*if (sourceId.startsWith("Anarchism")) + System.out.print("");*/ + List list = new List(sourceId, listId); + for (String ctx : contexts) + list.addContext(ctx); + + NodeList it = listElement.getChildNodes(); + for (int i = 0; i < it.getLength(); i++) { + Node liElement = it.item(i); + if(liElement.getNodeType()==3) + continue; + ListItem li = tokenizer.tokenize(liElement); + if (li != null) + list.addItem(li); + } + + for (ListValidator v : validators) { + if (!v.isValid(list)) + return null; + } + return list; + } + + public static void serialize(List list, String targetDir) throws IOException { + File dir = new File(targetDir); + if (!dir.exists()) + dir.mkdirs(); + String filename = targetDir + File.separator + list.getSourceId().replaceAll("[^\\d\\w]", "_") + "_" + list.getListId(); + + FileOutputStream fileOut = + new FileOutputStream(filename); + ObjectOutputStream out = + new ObjectOutputStream(fileOut); + out.writeObject(list); + out.close(); + fileOut.close(); + } + + public static List deserialize(String filename) throws IOException, ClassNotFoundException { + FileInputStream fileIn = + new FileInputStream(filename); + ObjectInputStream in = new ObjectInputStream(fileIn); + List list = (List) in.readObject(); + in.close(); + fileIn.close(); + return list; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorHTML.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorHTML.java index 7bfd47bf..0d63cc15 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorHTML.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorHTML.java @@ -1,72 +1,72 @@ -package uk.ac.shef.dcs.sti.parser.list; - -import org.apache.any23.extractor.html.DomUtils; -import org.apache.any23.extractor.html.TagSoupParser; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import uk.ac.shef.dcs.sti.core.model.List; -import uk.ac.shef.dcs.sti.parser.list.splitter.ListItemSplitter; -import uk.ac.shef.dcs.sti.parser.list.validator.ListValidator; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.util.ArrayList; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 10/10/12 - * Time: 12:57 - */ -public class ListXtractorHTML extends ListXtractor { - private String[] listTagSelectors; - - - public ListXtractorHTML(ListItemSplitter tokenizer, ListValidator... validator) { - super(tokenizer, validator); - listTagSelectors = new String[]{"UL","OL"}; - } - - @SuppressWarnings("unchecked") - @Override - public java.util.List extract(String input, String sourceId) throws IOException { - /*if (sourceId.startsWith("Altruism")) - System.out.println();*/ - java.util.List rs = new ArrayList(); - - parser = new TagSoupParser(new ByteArrayInputStream(input.getBytes()), sourceId); - Document doc = null; - try { - doc = parser.getDOM(); - } catch (IOException e) { - return rs; - } - - int listCount = 0; - for (String selectTag : listTagSelectors) { - java.util.List lists=DomUtils.findAllByTag(doc, selectTag); - - for(Node n: lists){ - listCount++; - - if (!isValidPosition(n)) - continue; - //todo: extract context for list - String[] contexts = new String[0]; - - List list = extractList(n, String.valueOf(listCount), - sourceId, contexts); - if (list != null) - rs.add(list); - } - - } - return rs; - } - - protected boolean isValidPosition(Node ulElement) { - Node par = ulElement.getParentNode(); - if (par != null && !par.getNodeName().equalsIgnoreCase("body")) - return false; - return true; - } -} +package uk.ac.shef.dcs.sti.parser.list; + +import org.apache.any23.extractor.html.DomUtils; +import org.apache.any23.extractor.html.TagSoupParser; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import uk.ac.shef.dcs.sti.core.model.List; +import uk.ac.shef.dcs.sti.parser.list.splitter.ListItemSplitter; +import uk.ac.shef.dcs.sti.parser.list.validator.ListValidator; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.ArrayList; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 10/10/12 + * Time: 12:57 + */ +public class ListXtractorHTML extends ListXtractor { + private String[] listTagSelectors; + + + public ListXtractorHTML(ListItemSplitter tokenizer, ListValidator... validator) { + super(tokenizer, validator); + listTagSelectors = new String[]{"UL","OL"}; + } + + @SuppressWarnings("unchecked") + @Override + public java.util.List extract(String input, String sourceId) throws IOException { + /*if (sourceId.startsWith("Altruism")) + System.out.println();*/ + java.util.List rs = new ArrayList(); + + parser = new TagSoupParser(new ByteArrayInputStream(input.getBytes()), sourceId); + Document doc = null; + try { + doc = parser.getDOM(); + } catch (IOException e) { + return rs; + } + + int listCount = 0; + for (String selectTag : listTagSelectors) { + java.util.List lists=DomUtils.findAllByTag(doc, selectTag); + + for(Node n: lists){ + listCount++; + + if (!isValidPosition(n)) + continue; + //todo: extract context for list + String[] contexts = new String[0]; + + List list = extractList(n, String.valueOf(listCount), + sourceId, contexts); + if (list != null) + rs.add(list); + } + + } + return rs; + } + + protected boolean isValidPosition(Node ulElement) { + Node par = ulElement.getParentNode(); + if (par != null && !par.getNodeName().equalsIgnoreCase("body")) + return false; + return true; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorWikipedia.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorWikipedia.java index 1866076a..a7bbbfb7 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorWikipedia.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/ListXtractorWikipedia.java @@ -1,56 +1,56 @@ -package uk.ac.shef.dcs.sti.parser.list; - -import info.bliki.wiki.model.WikiModel; -import org.w3c.dom.Node; -import uk.ac.shef.dcs.sti.parser.list.splitter.ListItemSplitter; -import uk.ac.shef.dcs.sti.parser.list.validator.ListValidator; - -import java.io.IOException; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 09/10/12 - * Time: 11:19 - *

- * selects - */ -public class ListXtractorWikipedia extends ListXtractorHTML { - private WikiModel model; - - private final String[] STOP_HEADINGS = {"see also", - "external links", "further readings", "other readings"}; //a list of headings that if found for a list, the list should be discarded - - public ListXtractorWikipedia(ListItemSplitter tokenizer, ListValidator... validators) { - super(tokenizer, validators); - model = new WikiModel("/${image}", "/${title}"); - } - - @Override - public java.util.List extract(String input, String sourceId) throws IOException { - String html = model.render(input); - return super.extract(html, sourceId); - } - - @Override - protected boolean isValidPosition(Node ulElement) { - Node par = ulElement.getParentNode(); - if (par != null && !par.getNodeName().equalsIgnoreCase("body")) - return false; - - Node previousSibling = ulElement.getPreviousSibling(); - while (previousSibling != null) { - if (previousSibling.getNodeName().toLowerCase().startsWith("h")) { - String headerText = previousSibling.getTextContent(); - for(String stopHeading: STOP_HEADINGS){ - if(headerText.equalsIgnoreCase(stopHeading)) - return false; - } - return true; - } else - previousSibling = previousSibling.getPreviousSibling(); - } - - return true; - } - -} +package uk.ac.shef.dcs.sti.parser.list; + +import info.bliki.wiki.model.WikiModel; +import org.w3c.dom.Node; +import uk.ac.shef.dcs.sti.parser.list.splitter.ListItemSplitter; +import uk.ac.shef.dcs.sti.parser.list.validator.ListValidator; + +import java.io.IOException; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 09/10/12 + * Time: 11:19 + *

+ * selects + */ +public class ListXtractorWikipedia extends ListXtractorHTML { + private WikiModel model; + + private final String[] STOP_HEADINGS = {"see also", + "external links", "further readings", "other readings"}; //a list of headings that if found for a list, the list should be discarded + + public ListXtractorWikipedia(ListItemSplitter tokenizer, ListValidator... validators) { + super(tokenizer, validators); + model = new WikiModel("/${image}", "/${title}"); + } + + @Override + public java.util.List extract(String input, String sourceId) throws IOException { + String html = model.render(input); + return super.extract(html, sourceId); + } + + @Override + protected boolean isValidPosition(Node ulElement) { + Node par = ulElement.getParentNode(); + if (par != null && !par.getNodeName().equalsIgnoreCase("body")) + return false; + + Node previousSibling = ulElement.getPreviousSibling(); + while (previousSibling != null) { + if (previousSibling.getNodeName().toLowerCase().startsWith("h")) { + String headerText = previousSibling.getTextContent(); + for(String stopHeading: STOP_HEADINGS){ + if(headerText.equalsIgnoreCase(stopHeading)) + return false; + } + return true; + } else + previousSibling = previousSibling.getPreviousSibling(); + } + + return true; + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitter.java index 6b30f0a0..d1164bf8 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitter.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitter.java @@ -1,14 +1,14 @@ -package uk.ac.shef.dcs.sti.parser.list.splitter; - -import org.w3c.dom.Node; -import uk.ac.shef.dcs.sti.core.model.ListItem; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 10/10/12 - * Time: 14:49 - */ -public interface ListItemSplitter { - - ListItem tokenize(Node liElementJSoup); -} +package uk.ac.shef.dcs.sti.parser.list.splitter; + +import org.w3c.dom.Node; +import uk.ac.shef.dcs.sti.core.model.ListItem; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 10/10/12 + * Time: 14:49 + */ +public interface ListItemSplitter { + + ListItem tokenize(Node liElementJSoup); +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitterByURL.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitterByURL.java index 43bbe4c4..86f76361 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitterByURL.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/splitter/ListItemSplitterByURL.java @@ -1,36 +1,36 @@ -package uk.ac.shef.dcs.sti.parser.list.splitter; - -import org.apache.any23.extractor.html.DomUtils; -import org.w3c.dom.Node; -import uk.ac.shef.dcs.sti.core.model.ListItem; - -import java.util.List; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 10/10/12 - * Time: 14:50 - */ -public class ListItemSplitterByURL implements ListItemSplitter { - @Override - public ListItem tokenize(Node liElement) { - String fulltext = liElement.getTextContent(); - ListItem li = new ListItem(fulltext); - - List it = DomUtils.findAllByTag(liElement, "A"); - for (Node n : it) { - - if (n.getParentNode().getNodeName().equalsIgnoreCase("sub") || n.getParentNode().getNodeName().equalsIgnoreCase("sup")) - continue; - String uri = n.getAttributes().getNamedItem("href").getTextContent(); - String text = n.getTextContent(); - if (text.length() == 0) - continue; - li.getValuesAndURIs().put(text, uri); - } - - if (fulltext.length() > 0 || li.getValuesAndURIs().size() > 0) - return li; - return null; - } -} +package uk.ac.shef.dcs.sti.parser.list.splitter; + +import org.apache.any23.extractor.html.DomUtils; +import org.w3c.dom.Node; +import uk.ac.shef.dcs.sti.core.model.ListItem; + +import java.util.List; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 10/10/12 + * Time: 14:50 + */ +public class ListItemSplitterByURL implements ListItemSplitter { + @Override + public ListItem tokenize(Node liElement) { + String fulltext = liElement.getTextContent(); + ListItem li = new ListItem(fulltext); + + List it = DomUtils.findAllByTag(liElement, "A"); + for (Node n : it) { + + if (n.getParentNode().getNodeName().equalsIgnoreCase("sub") || n.getParentNode().getNodeName().equalsIgnoreCase("sup")) + continue; + String uri = n.getAttributes().getNamedItem("href").getTextContent(); + String text = n.getTextContent(); + if (text.length() == 0) + continue; + li.getValuesAndURIs().put(text, uri); + } + + if (fulltext.length() > 0 || li.getValuesAndURIs().size() > 0) + return li; + return null; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListVaildatorLanient.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListVaildatorLanient.java index a21883cd..e19e96ac 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListVaildatorLanient.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/list/validator/ListVaildatorLanient.java @@ -1,79 +1,79 @@ -package uk.ac.shef.dcs.sti.parser.list.validator; - -import uk.ac.shef.dcs.sti.core.model.List; -import uk.ac.shef.dcs.sti.core.model.ListItem; -import uk.ac.shef.dcs.sti.parser.ContentValidator; - -import java.util.Map; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 10/10/12 - * Time: 15:02 - *

- * Implements the following rules: - *

- * - must contain at least 5 PROPER items - * \t an item is proper if: 1)it has some texts 2)it is not lengthy - * \t - * \t an item is lengthy if: 1)over x% of values (multi-valued item) in the list item has over Y tokens - * \t 2)there are over X values (multi-valued item) in the item - * - must not contain more than X% lengthy items - * - must not be a list of numeric values (beyond X% of items) - * - must not contain too many empty items (beyond x% of items) - * - must not contain an item that begins with ["list of"] - */ -public class ListVaildatorLanient extends ContentValidator implements ListValidator { - - protected final static int THRESHOLD_MIN_PROPERITEMS=5; - protected final static int THRESHOLD_MAX_TOKENS_PER_VALUEINITEM = 5; //above this value, this value in the item is "lengthy", as a result, the item is lengthy - protected final static int THRESHOLD_MAX_VALUES_PER_ITEM = 3; //above this value, this list item is "lengthy" - - protected final static double THRESHOLD_TOOMANY_LENGTHYITEM = 0.2; //% of lengthy items allowed in a list - protected final static double THRESHOLD_TOOMANY_NUMERICITEMS = 0.2; - protected final static double THRESHOLD_TOOMANY_EMPTYTEMS = 0.2; - - @Override - public boolean isValid(List list) { - int countEmpty = 0, countLengthy = 0, numericItems = 0; - - for (ListItem li : list.getItems()) { - String fulltext = li.getText(); - - if(fulltext.toLowerCase().startsWith("list of")) - return false; - if (isEmptyMediaWikiString(fulltext)) - countEmpty++; - if (isNumericContent(fulltext)) - numericItems++; - if(li.getValuesAndURIs().size()>THRESHOLD_MAX_VALUES_PER_ITEM) - countLengthy++; - for(Map.Entry e: li.getValuesAndURIs().entrySet()){ - String text = e.getKey(); - int length = text.split("\\s+").length; - if(length>THRESHOLD_MAX_TOKENS_PER_VALUEINITEM){ - countLengthy++; - break; - } - } - - int fulltextLength = fulltext.split("\\s+").length; - int maxLengthAllowed = li.getValuesAndURIs().size()*THRESHOLD_MAX_TOKENS_PER_VALUEINITEM; - if(fulltextLength>maxLengthAllowed) - countLengthy++; - } - - if(countEmpty>list.getItems().size()*THRESHOLD_TOOMANY_EMPTYTEMS) - return false; - if(numericItems>list.getItems().size()*THRESHOLD_TOOMANY_NUMERICITEMS) - return false; - if(countLengthy>list.getItems().size()*THRESHOLD_TOOMANY_LENGTHYITEM) - return false; - if(list.getItems().size()-countEmpty-countLengthy-numericItems + * Implements the following rules: + *

+ * - must contain at least 5 PROPER items + * \t an item is proper if: 1)it has some texts 2)it is not lengthy + * \t + * \t an item is lengthy if: 1)over x% of values (multi-valued item) in the list item has over Y tokens + * \t 2)there are over X values (multi-valued item) in the item + * - must not contain more than X% lengthy items + * - must not be a list of numeric values (beyond X% of items) + * - must not contain too many empty items (beyond x% of items) + * - must not contain an item that begins with ["list of"] + */ +public class ListVaildatorLanient extends ContentValidator implements ListValidator { + + protected final static int THRESHOLD_MIN_PROPERITEMS=5; + protected final static int THRESHOLD_MAX_TOKENS_PER_VALUEINITEM = 5; //above this value, this value in the item is "lengthy", as a result, the item is lengthy + protected final static int THRESHOLD_MAX_VALUES_PER_ITEM = 3; //above this value, this list item is "lengthy" + + protected final static double THRESHOLD_TOOMANY_LENGTHYITEM = 0.2; //% of lengthy items allowed in a list + protected final static double THRESHOLD_TOOMANY_NUMERICITEMS = 0.2; + protected final static double THRESHOLD_TOOMANY_EMPTYTEMS = 0.2; + + @Override + public boolean isValid(List list) { + int countEmpty = 0, countLengthy = 0, numericItems = 0; + + for (ListItem li : list.getItems()) { + String fulltext = li.getText(); + + if(fulltext.toLowerCase().startsWith("list of")) + return false; + if (isEmptyMediaWikiString(fulltext)) + countEmpty++; + if (isNumericContent(fulltext)) + numericItems++; + if(li.getValuesAndURIs().size()>THRESHOLD_MAX_VALUES_PER_ITEM) + countLengthy++; + for(Map.Entry e: li.getValuesAndURIs().entrySet()){ + String text = e.getKey(); + int length = text.split("\\s+").length; + if(length>THRESHOLD_MAX_TOKENS_PER_VALUEINITEM){ + countLengthy++; + break; + } + } + + int fulltextLength = fulltext.split("\\s+").length; + int maxLengthAllowed = li.getValuesAndURIs().size()*THRESHOLD_MAX_TOKENS_PER_VALUEINITEM; + if(fulltextLength>maxLengthAllowed) + countLengthy++; + } + + if(countEmpty>list.getItems().size()*THRESHOLD_TOOMANY_EMPTYTEMS) + return false; + if(numericItems>list.getItems().size()*THRESHOLD_TOOMANY_NUMERICITEMS) + return false; + if(countLengthy>list.getItems().size()*THRESHOLD_TOOMANY_LENGTHYITEM) + return false; + if(list.getItems().size()-countEmpty-countLengthy-numericItems - *

- * Implements the following rules: - *

- * - must contain at least 5 PROPER items - * - must not contain lengthy items (multi-valued item not allowed) - * - must not contain numeric items - * - must not contain empty items - * - must not contain an item that begins with ["list of"] - * - must contain at least 60% and a minimum of 5 items-with-uris (gold standard) - */ -public class ListValidatorStrict extends ContentValidator implements ListValidator { - - protected final double THRESHOLD_FRACTION_ITEMSWITHURIS = 0.6; - - - public ListValidatorStrict() { - } - - - @Override - public boolean isValid(List list) { - if (list.getItems().size() < ListVaildatorLanient.THRESHOLD_MIN_PROPERITEMS) - return false; - - int countGSWithURIs = 0; - for (ListItem li : list.getItems()) { - if (li.getValuesAndURIs().size() > 1) - return false; - if (li.getValuesAndURIs().size() > 0) { - String uri = li.getValuesAndURIs().values().iterator().next(); - if (isWikiInternalLink(uri)) { - countGSWithURIs++; - } - } - - String fulltext = li.getText(); - int fulltextLength = fulltext.split("\\s+").length; - if (fulltextLength > ListVaildatorLanient.THRESHOLD_MAX_TOKENS_PER_VALUEINITEM) - return false; - - if (fulltext.toLowerCase().startsWith("list of")) - return false; - if (isEmptyMediaWikiString(fulltext)) - return false; - if (isNumericContent(fulltext)) - return false; - for (Map.Entry e : li.getValuesAndURIs().entrySet()) { - String text = e.getKey(); - int length = text.split("\\s+").length; - if (length > ListVaildatorLanient.THRESHOLD_MAX_TOKENS_PER_VALUEINITEM) { - return false; - } - } - } - - if (countGSWithURIs < 5 || countGSWithURIs < list.getItems().size() * THRESHOLD_FRACTION_ITEMSWITHURIS) - return false; - - return true; - } -} +package uk.ac.shef.dcs.sti.parser.list.validator; + +import uk.ac.shef.dcs.sti.core.model.List; +import uk.ac.shef.dcs.sti.core.model.ListItem; +import uk.ac.shef.dcs.sti.parser.ContentValidator; + +import java.util.Map; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 11/10/12 + * Time: 12:53 + *

+ *

+ * Implements the following rules: + *

+ * - must contain at least 5 PROPER items + * - must not contain lengthy items (multi-valued item not allowed) + * - must not contain numeric items + * - must not contain empty items + * - must not contain an item that begins with ["list of"] + * - must contain at least 60% and a minimum of 5 items-with-uris (gold standard) + */ +public class ListValidatorStrict extends ContentValidator implements ListValidator { + + protected final double THRESHOLD_FRACTION_ITEMSWITHURIS = 0.6; + + + public ListValidatorStrict() { + } + + + @Override + public boolean isValid(List list) { + if (list.getItems().size() < ListVaildatorLanient.THRESHOLD_MIN_PROPERITEMS) + return false; + + int countGSWithURIs = 0; + for (ListItem li : list.getItems()) { + if (li.getValuesAndURIs().size() > 1) + return false; + if (li.getValuesAndURIs().size() > 0) { + String uri = li.getValuesAndURIs().values().iterator().next(); + if (isWikiInternalLink(uri)) { + countGSWithURIs++; + } + } + + String fulltext = li.getText(); + int fulltextLength = fulltext.split("\\s+").length; + if (fulltextLength > ListVaildatorLanient.THRESHOLD_MAX_TOKENS_PER_VALUEINITEM) + return false; + + if (fulltext.toLowerCase().startsWith("list of")) + return false; + if (isEmptyMediaWikiString(fulltext)) + return false; + if (isNumericContent(fulltext)) + return false; + for (Map.Entry e : li.getValuesAndURIs().entrySet()) { + String text = e.getKey(); + int length = text.split("\\s+").length; + if (length > ListVaildatorLanient.THRESHOLD_MAX_TOKENS_PER_VALUEINITEM) { + return false; + } + } + } + + if (countGSWithURIs < 5 || countGSWithURIs < list.getItems().size() * THRESHOLD_FRACTION_ITEMSWITHURIS) + return false; + + return true; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParser.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParser.java index 6908646a..aecdf6df 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParser.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParser.java @@ -1,100 +1,100 @@ -package uk.ac.shef.dcs.sti.parser.table; - -import cern.colt.matrix.ObjectMatrix2D; -import org.apache.any23.extractor.html.TagSoupParser; -import org.w3c.dom.Node; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.core.model.TContext; -import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetector; -import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizer; -import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreator; -import uk.ac.shef.dcs.sti.parser.table.validator.TableValidator; - -import java.io.*; -import java.util.List; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 03/10/12 - * Time: 12:05 - *

- * interface for extracting tables from certain RAW input strings - * - * WARNING: this class should not be used to READ serialised Table objects. but learn raw input to create them - */ -public abstract class TableParser { - protected TableNormalizer normalizer; - protected TableHODetector hoDetector; - protected TableObjCreator creator; - protected TableValidator[] validators; - - protected TagSoupParser parser; - - public TableParser(TableNormalizer normalizer, - TableHODetector detector, TableObjCreator creator, - TableValidator... validators) { - this.normalizer = normalizer; - this.hoDetector = detector; - this.creator = creator; - this.validators = validators; - } - - public abstract List extract(String input, String sourceId) throws STIException, IOException; - - /** - * Processes table elements following the basic principles: - * 1. normalize a table element (Jsoup) into a regular n x m table - * 2. find header and orientation of the table - * 3. extract text values in each table cell - * 4. validate the extracted tables - *

- * (examples of tables that will be discarded by this method include(inaddition to the tablevalidator rules): - * tables only contain images but no texts; - * tables only have "tr" which has no "td" - * - * @param tableNode must be the

element - * @param sourceId - * @return null if no valid tables are extracted; Table object if otherwise - */ - public Table extractTable(Node tableNode, String tableId, String sourceId, TContext... contexts) { - /*if (sourceId.startsWith("List of U.S. state songs")) - System.out.println();*/ - List> norm = normalizer.normalize(tableNode); - if (norm.size() == 0) - return null; - ObjectMatrix2D preTable = hoDetector.detect(norm); - Table table = creator.create(preTable, tableId, sourceId, contexts); - for (TableValidator tv : validators) { - if (!tv.validate(table)) - return null; - } - return table; - } - - - public static void serialize(Table table, String targetDir) throws IOException { - File dir = new File(targetDir); - if (!dir.exists()) - dir.mkdirs(); - String filename = targetDir + File.separator + table.getSourceId().replaceAll("[^\\d\\w]", "_") + "_" + table.getTableId(); - - FileOutputStream fileOut = - new FileOutputStream(filename); - ObjectOutputStream out = - new ObjectOutputStream(fileOut); - out.writeObject(table); - out.close(); - fileOut.close(); - } - - public static Table deserialize(String filename) throws IOException, ClassNotFoundException { - FileInputStream fileIn = - new FileInputStream(filename); - ObjectInputStream in = new ObjectInputStream(fileIn); - Table table = (Table) in.readObject(); - in.close(); - fileIn.close(); - return table; - } -} +package uk.ac.shef.dcs.sti.parser.table; + +import cern.colt.matrix.ObjectMatrix2D; +import org.apache.any23.extractor.html.TagSoupParser; +import org.w3c.dom.Node; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.core.model.TContext; +import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetector; +import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizer; +import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreator; +import uk.ac.shef.dcs.sti.parser.table.validator.TableValidator; + +import java.io.*; +import java.util.List; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 03/10/12 + * Time: 12:05 + *

+ * interface for extracting tables from certain RAW input strings + * + * WARNING: this class should not be used to READ serialised Table objects. but learn raw input to create them + */ +public abstract class TableParser { + protected TableNormalizer normalizer; + protected TableHODetector hoDetector; + protected TableObjCreator creator; + protected TableValidator[] validators; + + protected TagSoupParser parser; + + public TableParser(TableNormalizer normalizer, + TableHODetector detector, TableObjCreator creator, + TableValidator... validators) { + this.normalizer = normalizer; + this.hoDetector = detector; + this.creator = creator; + this.validators = validators; + } + + public abstract List

extract(String input, String sourceId) throws STIException, IOException; + + /** + * Processes table elements following the basic principles: + * 1. normalize a table element (Jsoup) into a regular n x m table + * 2. find header and orientation of the table + * 3. extract text values in each table cell + * 4. validate the extracted tables + *

+ * (examples of tables that will be discarded by this method include(inaddition to the tablevalidator rules): + * tables only contain images but no texts; + * tables only have "tr" which has no "td" + * + * @param tableNode must be the

element + * @param sourceId + * @return null if no valid tables are extracted; Table object if otherwise + */ + public Table extractTable(Node tableNode, String tableId, String sourceId, TContext... contexts) { + /*if (sourceId.startsWith("List of U.S. state songs")) + System.out.println();*/ + List> norm = normalizer.normalize(tableNode); + if (norm.size() == 0) + return null; + ObjectMatrix2D preTable = hoDetector.detect(norm); + Table table = creator.create(preTable, tableId, sourceId, contexts); + for (TableValidator tv : validators) { + if (!tv.validate(table)) + return null; + } + return table; + } + + + public static void serialize(Table table, String targetDir) throws IOException { + File dir = new File(targetDir); + if (!dir.exists()) + dir.mkdirs(); + String filename = targetDir + File.separator + table.getSourceId().replaceAll("[^\\d\\w]", "_") + "_" + table.getTableId(); + + FileOutputStream fileOut = + new FileOutputStream(filename); + ObjectOutputStream out = + new ObjectOutputStream(fileOut); + out.writeObject(table); + out.close(); + fileOut.close(); + } + + public static Table deserialize(String filename) throws IOException, ClassNotFoundException { + FileInputStream fileIn = + new FileInputStream(filename); + ObjectInputStream in = new ObjectInputStream(fileIn); + Table table = (Table) in.readObject(); + in.close(); + fileIn.close(); + return table; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserGoodreads.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserGoodreads.java index c9ea9587..d6c0f765 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserGoodreads.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserGoodreads.java @@ -1,75 +1,75 @@ -package uk.ac.shef.dcs.sti.parser.table; - -import org.apache.any23.extractor.html.DomUtils; -import org.apache.any23.extractor.html.TagSoupParser; -import org.apache.commons.io.FileUtils; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.model.TContext; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetector; -import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizer; -import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreator; -import uk.ac.shef.dcs.sti.parser.table.context.TableContextExtractorGeneric; -import uk.ac.shef.dcs.sti.parser.table.validator.TableValidator; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 31/03/14 - * Time: 15:21 - * To change this template use File | Settings | File Templates. - */ -public class TableParserGoodreads extends TableParser { - public TableParserGoodreads(TableNormalizer normalizer, TableHODetector detector, TableObjCreator creator, TableValidator... validators) { - super(normalizer, detector, creator, validators); - } - - @Override - public List
extract(String inFile, String sourceId) throws STIException { - String input; - try { - input = FileUtils.readFileToString(new File(inFile)); - } catch (IOException e) { - throw new STIException(e); - } - List
rs = new ArrayList<>(); - - parser = new TagSoupParser(new ByteArrayInputStream(input.getBytes()), sourceId,"UTF-8"); - Document doc = null; - try { - doc = parser.getDOM(); - } catch (IOException e) { - return rs; - } - - List tables = DomUtils.findAll(doc, "//TABLE[@class='stacked tableList']"); - List contexts = new ArrayList<>(); - try { - contexts = new TableContextExtractorGeneric().extract(new File(sourceId), doc); - } catch (STIException e) { - e.printStackTrace(); - } - int tableCount = 0; - for (Node n : tables) { - tableCount++; - - TContext[] contexts_array = new TContext[contexts.size()]; - for (int i = 0; i < contexts.size(); i++) - contexts_array[i] = contexts.get(i); - Table table = extractTable(n, String.valueOf(tableCount), - sourceId, contexts_array); - if (table != null) - rs.add(table); - - } - return rs; - } -} +package uk.ac.shef.dcs.sti.parser.table; + +import org.apache.any23.extractor.html.DomUtils; +import org.apache.any23.extractor.html.TagSoupParser; +import org.apache.commons.io.FileUtils; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.model.TContext; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetector; +import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizer; +import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreator; +import uk.ac.shef.dcs.sti.parser.table.context.TableContextExtractorGeneric; +import uk.ac.shef.dcs.sti.parser.table.validator.TableValidator; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * Created with IntelliJ IDEA. + * User: zqz + * Date: 31/03/14 + * Time: 15:21 + * To change this template use File | Settings | File Templates. + */ +public class TableParserGoodreads extends TableParser { + public TableParserGoodreads(TableNormalizer normalizer, TableHODetector detector, TableObjCreator creator, TableValidator... validators) { + super(normalizer, detector, creator, validators); + } + + @Override + public List
extract(String inFile, String sourceId) throws STIException { + String input; + try { + input = FileUtils.readFileToString(new File(inFile)); + } catch (IOException e) { + throw new STIException(e); + } + List
rs = new ArrayList<>(); + + parser = new TagSoupParser(new ByteArrayInputStream(input.getBytes()), sourceId,"UTF-8"); + Document doc = null; + try { + doc = parser.getDOM(); + } catch (IOException e) { + return rs; + } + + List tables = DomUtils.findAll(doc, "//TABLE[@class='stacked tableList']"); + List contexts = new ArrayList<>(); + try { + contexts = new TableContextExtractorGeneric().extract(new File(sourceId), doc); + } catch (STIException e) { + e.printStackTrace(); + } + int tableCount = 0; + for (Node n : tables) { + tableCount++; + + TContext[] contexts_array = new TContext[contexts.size()]; + for (int i = 0; i < contexts.size(); i++) + contexts_array[i] = contexts.get(i); + Table table = extractTable(n, String.valueOf(tableCount), + sourceId, contexts_array); + if (table != null) + rs.add(table); + + } + return rs; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserHTML.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserHTML.java index d02beb20..e2255589 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserHTML.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserHTML.java @@ -1,68 +1,68 @@ -package uk.ac.shef.dcs.sti.parser.table; - -import org.apache.any23.extractor.html.DomUtils; -import org.apache.any23.extractor.html.TagSoupParser; -import org.apache.commons.io.FileUtils; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.model.TContext; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetector; -import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizer; -import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreator; -import uk.ac.shef.dcs.sti.parser.table.validator.TableValidator; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 03/10/12 - * Time: 12:07 - */ -public class TableParserHTML extends TableParser { - - - public TableParserHTML(TableNormalizer normalizer, TableHODetector detector, TableObjCreator creator, TableValidator... validators) { - super(normalizer, detector, creator,validators); - } - - - @Override - public List
extract(String inFile, String sourceId) throws STIException { - String input; - try { - input = FileUtils.readFileToString(new File(inFile)); - } catch (IOException e) { - throw new STIException(e); - } - - List
rs = new ArrayList<>(); - parser = new TagSoupParser(new ByteArrayInputStream(input.getBytes()), sourceId,"UTF-8"); - Document doc = null; try { - doc = parser.getDOM(); - } catch (IOException e) { - return rs; - } - - List tables = DomUtils.findAll(doc, "//TABLE"); - - int tableCount=0; - for(Node n: tables){ - tableCount++; - //todo: extract contexts for table - TContext[] contexts = new TContext[0]; - Table table =extractTable(n, String.valueOf(tableCount), - sourceId,contexts); - if(table!=null) - rs.add(table); - } - return rs; - } - - -} +package uk.ac.shef.dcs.sti.parser.table; + +import org.apache.any23.extractor.html.DomUtils; +import org.apache.any23.extractor.html.TagSoupParser; +import org.apache.commons.io.FileUtils; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.model.TContext; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetector; +import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizer; +import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreator; +import uk.ac.shef.dcs.sti.parser.table.validator.TableValidator; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 03/10/12 + * Time: 12:07 + */ +public class TableParserHTML extends TableParser { + + + public TableParserHTML(TableNormalizer normalizer, TableHODetector detector, TableObjCreator creator, TableValidator... validators) { + super(normalizer, detector, creator,validators); + } + + + @Override + public List
extract(String inFile, String sourceId) throws STIException { + String input; + try { + input = FileUtils.readFileToString(new File(inFile)); + } catch (IOException e) { + throw new STIException(e); + } + + List
rs = new ArrayList<>(); + parser = new TagSoupParser(new ByteArrayInputStream(input.getBytes()), sourceId,"UTF-8"); + Document doc = null; try { + doc = parser.getDOM(); + } catch (IOException e) { + return rs; + } + + List tables = DomUtils.findAll(doc, "//TABLE"); + + int tableCount=0; + for(Node n: tables){ + tableCount++; + //todo: extract contexts for table + TContext[] contexts = new TContext[0]; + Table table =extractTable(n, String.valueOf(tableCount), + sourceId,contexts); + if(table!=null) + rs.add(table); + } + return rs; + } + + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserIMDB.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserIMDB.java index 04f51062..0c157bb3 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserIMDB.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserIMDB.java @@ -1,89 +1,89 @@ -package uk.ac.shef.dcs.sti.parser.table; - -import org.apache.any23.extractor.html.DomUtils; -import org.apache.any23.extractor.html.TagSoupParser; -import org.apache.commons.io.FileUtils; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.core.model.TContext; -import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreatorIMDB; -import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetector; -import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetectorByHTMLTag; -import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizer; -import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreator; -import uk.ac.shef.dcs.sti.parser.table.context.TableContextExtractorIMDB; -import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizerDiscardIrregularRows; -import uk.ac.shef.dcs.sti.parser.table.validator.TableValidatorGeneric; -import uk.ac.shef.dcs.sti.parser.table.validator.TableValidator; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 17/02/14 - * Time: 11:56 - * To change this template use File | Settings | File Templates. - */ -public class TableParserIMDB extends TableParser { - - public TableParserIMDB(){ - super(new TableNormalizerDiscardIrregularRows(true), - new TableHODetectorByHTMLTag(), - new TableObjCreatorIMDB(), - new TableValidatorGeneric()); - } - - public TableParserIMDB(TableNormalizer normalizer, TableHODetector detector, TableObjCreator creator, TableValidator... validators) { - super(normalizer, detector, creator, validators); - } - - @Override - public List
extract(String inFile, String sourceId) throws STIException { - String input; - try { - input = FileUtils.readFileToString(new File(inFile)); - } catch (IOException e) { - throw new STIException(e); - } - - List
rs = new ArrayList<>(); - parser = new TagSoupParser(new ByteArrayInputStream(input.getBytes()), sourceId,"UTF-8"); - Document doc = null; - try { - doc = parser.getDOM(); - } catch (IOException e) { - return rs; - } - - List tables = DomUtils.findAll(doc, "//TABLE[@class='cast_list']"); - List contexts = new ArrayList<>(); - try { - contexts = new TableContextExtractorIMDB().extract(new File(sourceId), doc); - } catch (STIException e) { - e.printStackTrace(); - } - int tableCount = 0; - for (Node n : tables) { - tableCount++; - - TContext[] contexts_array = new TContext[contexts.size()]; - for (int i = 0; i < contexts.size(); i++) - contexts_array[i] = contexts.get(i); - Table table = extractTable(n, String.valueOf(tableCount), - sourceId, contexts_array); - if (table != null) - rs.add(table); - - } - return rs; - } - - -} +package uk.ac.shef.dcs.sti.parser.table; + +import org.apache.any23.extractor.html.DomUtils; +import org.apache.any23.extractor.html.TagSoupParser; +import org.apache.commons.io.FileUtils; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.core.model.TContext; +import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreatorIMDB; +import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetector; +import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetectorByHTMLTag; +import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizer; +import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreator; +import uk.ac.shef.dcs.sti.parser.table.context.TableContextExtractorIMDB; +import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizerDiscardIrregularRows; +import uk.ac.shef.dcs.sti.parser.table.validator.TableValidatorGeneric; +import uk.ac.shef.dcs.sti.parser.table.validator.TableValidator; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * Created with IntelliJ IDEA. + * User: zqz + * Date: 17/02/14 + * Time: 11:56 + * To change this template use File | Settings | File Templates. + */ +public class TableParserIMDB extends TableParser { + + public TableParserIMDB(){ + super(new TableNormalizerDiscardIrregularRows(true), + new TableHODetectorByHTMLTag(), + new TableObjCreatorIMDB(), + new TableValidatorGeneric()); + } + + public TableParserIMDB(TableNormalizer normalizer, TableHODetector detector, TableObjCreator creator, TableValidator... validators) { + super(normalizer, detector, creator, validators); + } + + @Override + public List
extract(String inFile, String sourceId) throws STIException { + String input; + try { + input = FileUtils.readFileToString(new File(inFile)); + } catch (IOException e) { + throw new STIException(e); + } + + List
rs = new ArrayList<>(); + parser = new TagSoupParser(new ByteArrayInputStream(input.getBytes()), sourceId,"UTF-8"); + Document doc = null; + try { + doc = parser.getDOM(); + } catch (IOException e) { + return rs; + } + + List tables = DomUtils.findAll(doc, "//TABLE[@class='cast_list']"); + List contexts = new ArrayList<>(); + try { + contexts = new TableContextExtractorIMDB().extract(new File(sourceId), doc); + } catch (STIException e) { + e.printStackTrace(); + } + int tableCount = 0; + for (Node n : tables) { + tableCount++; + + TContext[] contexts_array = new TContext[contexts.size()]; + for (int i = 0; i < contexts.size(); i++) + contexts_array[i] = contexts.get(i); + Table table = extractTable(n, String.valueOf(tableCount), + sourceId, contexts_array); + if (table != null) + rs.add(table); + + } + return rs; + } + + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserLimayeDataset.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserLimayeDataset.java index a352bcd5..e4c9d5bc 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserLimayeDataset.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserLimayeDataset.java @@ -1,262 +1,262 @@ -package uk.ac.shef.dcs.sti.parser.table; - -import org.apache.any23.extractor.html.DomUtils; -import org.apache.commons.lang3.StringEscapeUtils; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import uk.ac.shef.dcs.kbsearch.model.Clazz; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.sti.STIEnum; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.model.*; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -/** - * Created by - on 04/04/2016. - */ -public class TableParserLimayeDataset extends TableParser { - - private String htmlRepository; - /** - * this class does not need normalizer, detector, creator or validators. simply pass null - - */ - public TableParserLimayeDataset() { - super(null, null, null); - } - - public TableParserLimayeDataset(String htmlRepository){ - this(); - this.htmlRepository=htmlRepository; - } - @Override - public List
extract(String tableFilename, String tableAnnotationFilename) throws STIException{ - List
out = new ArrayList<>(); - try { - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - - DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); - Document domCleanTable = docBuilder.parse(tableFilename); - - //read the table content - List tableContent = DomUtils.findAll(domCleanTable, "//logicalTable/content"); - if (tableContent == null || tableContent.size() == 0) - return null; - boolean firstRowHeader = false; - List rows = new ArrayList<>(); - NodeList rowNodes = tableContent.get(0).getChildNodes(); - - for (int i = 0; i < rowNodes.getLength(); i++) { - Node row = rowNodes.item(i); - if (row.getNodeName().equals("#text")) - continue; - if (row.getNodeName().equals("header")) { - firstRowHeader = true; - } - - List columns = DomUtils.findAll(row, "cell"); - String[] cells = new String[columns.size()]; - for (int j = 0; j < columns.size(); j++) { - Node cell = columns.get(j); - List html = DomUtils.findAll(cell, "html"); - String textContent = ""; - if (html != null && html.size() > 0) { - textContent = extractTextContentFromHtml(html); - } - - if (textContent.equals("")) { - List text = DomUtils.findAll(cell, "text"); - - if (text != null && text.size() > 0) { - textContent = text.get(0).getTextContent(); - } - } - cells[j] = textContent; - } - rows.add(cells); - } - - int totalCol = 0; - for (String[] row : rows) { - if (row.length > totalCol) - totalCol = row.length; - } - - Table table = null; - int rowModifier = 0; - if (firstRowHeader) { - table = new Table(String.valueOf(tableFilename.hashCode()), tableFilename, rows.size() - 1, totalCol); - rowModifier = 1; - if (rows.get(0).length < totalCol) { - System.err.println("WARNING:Artificial header added, check manually. " + tableFilename); - String[] headers = rows.get(0); - String[] modified = new String[totalCol]; - for (int i = 0; i < modified.length; i++) { - if (i < headers.length) - modified[i] = headers[i]; - else - modified[i] = STIEnum.TABLE_HEADER_UNKNOWN.getValue(); - } - rows.set(0, modified); - } - for (int j = 0; j < totalCol; j++) { - TColumnHeader header = new TColumnHeader(rows.get(0)[j]); - table.setColumnHeader(j, header); - } - } else {//no header, need to add false headers - table = new Table(String.valueOf(tableFilename.hashCode()), tableFilename, rows.size(), totalCol); - for (int j = 0; j < totalCol; j++) { - TColumnHeader header = new TColumnHeader(STIEnum.TABLE_HEADER_UNKNOWN.getValue()); - table.setColumnHeader(j, header); - } - } - - for (int r = rowModifier; r < rows.size(); r++) { - String[] cells = rows.get(r); - for (int c = 0; c < cells.length; c++) { - TCell cell = new TCell(cells[c]); - table.setContentCell(r - rowModifier, c, cell); - } - } - - - //read the table context - List tableContext = DomUtils.findAll(domCleanTable, "//logicalTable/tableContext"); - if (tableContext != null || tableContext.size() != 0) { - Node ctxParentNode = tableContext.get(0); - NodeList contexts = ctxParentNode.getChildNodes(); - for (int i = 0; i < contexts.getLength(); i++) { - - Node n = contexts.item(i); - if (n.getNodeName().equals("#text")) - continue; - List textNode = DomUtils.findAllByTag(n, "text"); - if (textNode != null && textNode.size() > 0) { - String context = textNode.get(0).getTextContent(); - if (context != null) { - TContext ctx = null; - if (i == 1) - ctx = new TContext(context, TContext.TableContextType.PAGETITLE, 1.0); - else ctx = new TContext(context, TContext.TableContextType.PARAGRAPH_BEFORE, 1.0); - - table.addContext(ctx); - } - } - } - } - if (table.getContexts().size() > 1) - table.getContexts().remove(1); //always isValidAttribute the 2nd context as it is the header of the table - - //dump the original html snippet to a human readable html format - if (htmlRepository != null) { - List htmlSnippet = DomUtils.findAll(domCleanTable, "//htmlSnippet"); - if (htmlSnippet != null && htmlSnippet.size() != 0) - dumpHTMLContent(htmlSnippet.get(0), htmlRepository, tableFilename); - } - if (tableAnnotationFilename == null) { - out.add(table); - return out; - } - - - if (new File(tableAnnotationFilename).exists()) { - Document domAnnotatedTable = docBuilder.parse(tableAnnotationFilename); - - //read the header annotations - List headerAnnotations = DomUtils.findAll(domAnnotatedTable, "//columnAnnotations/colAnnos"); - for (int i = 0; i < headerAnnotations.size(); i++) { - Node header = headerAnnotations.get(i); - int col = Integer.valueOf(header.getAttributes().getNamedItem("col").getTextContent()); - //TCell headerCell = table.getHeaderForColumn(col); - NodeList annotations = header.getChildNodes(); - List hAnnotations = new ArrayList<>(); - for (int j = 0; j < annotations.getLength(); j++) { - Node n = annotations.item(j); - if (n.getNodeName().equals("anno")) { - TColumnHeaderAnnotation a = new TColumnHeaderAnnotation(table.getColumnHeader(col).getHeaderText(), - new Clazz(n.getAttributes().getNamedItem("name").getTextContent(), - n.getAttributes().getNamedItem("name").getTextContent()), - Double.valueOf(n.getAttributes().getNamedItem("value").getTextContent().trim())); - - hAnnotations.add(a); - } - } - table.getTableAnnotations().setHeaderAnnotation(col, hAnnotations.toArray(new TColumnHeaderAnnotation[0])); - } - //read the data rows annotations - List dataRowAnnotations = DomUtils.findAll(domAnnotatedTable, "//cellAnnotatoons/row"); - for (int i = 0; i < dataRowAnnotations.size(); i++) { - Node row = dataRowAnnotations.get(i); - List cols = DomUtils.findAll(row, "entity"); - for (int j = 0; j < cols.size(); j++) { - Node htmlCell = cols.get(j); - if (htmlCell.getTextContent() == null || htmlCell.getTextContent().length() == 0) { - continue; - } - TCellAnnotation cellAnnotation = new TCellAnnotation( - table.getContentCell(i, j).getText(), new Entity(htmlCell.getTextContent(), htmlCell.getTextContent()), 1.0, new HashMap() - ); - - table.getTableAnnotations().setContentCellAnnotations( - i, j, new TCellAnnotation[]{cellAnnotation} - ); - } - - } - } - - out.add(table); - return out; - } - catch (Exception e){ - throw new STIException(e); - } - } - - private String extractTextContentFromHtml(List html) { - String content = html.get(0).getTextContent(); - int start=content.indexOf(""); - if(start!=-1){ - content=content.substring(start+4); - int end = content.indexOf(""); - if(end==-1) - end=content.indexOf(""); - if(end==-1) - end=content.indexOf(""); - if(end!=-1) - content=content.substring(0,end).trim(); - } - content= StringEscapeUtils.unescapeHtml4(content); - return content; - } - - private void dumpHTMLContent(Node htmlSnippetNode, String htmlRepository, String filePath) throws FileNotFoundException { - String content = htmlSnippetNode.getTextContent(); - int begin = content.indexOf("CDATA["); - begin = begin == -1 ? 0 : begin + 7; - int end = content.lastIndexOf("]]>"); - end = end == -1 ? content.length() : end; - content = content.substring(begin, end).trim(); - - PrintWriter p = new PrintWriter(htmlRepository + File.separator + new File(filePath).getName() + "_" + filePath.hashCode() + ".html"); - p.println("

"); - p.println(filePath); - p.println("

"); - p.println(content); - p.println(""); - p.close(); - } -} +package uk.ac.shef.dcs.sti.parser.table; + +import org.apache.any23.extractor.html.DomUtils; +import org.apache.commons.lang3.StringEscapeUtils; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import uk.ac.shef.dcs.kbsearch.model.Clazz; +import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.sti.STIEnum; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.model.*; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +/** + * Created by - on 04/04/2016. + */ +public class TableParserLimayeDataset extends TableParser { + + private String htmlRepository; + /** + * this class does not need normalizer, detector, creator or validators. simply pass null + + */ + public TableParserLimayeDataset() { + super(null, null, null); + } + + public TableParserLimayeDataset(String htmlRepository){ + this(); + this.htmlRepository=htmlRepository; + } + @Override + public List
"); - if(start==-1) - start=content.indexOf(""); - if(start==-1) - start=content.indexOf("
extract(String tableFilename, String tableAnnotationFilename) throws STIException{ + List
out = new ArrayList<>(); + try { + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + + DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); + Document domCleanTable = docBuilder.parse(tableFilename); + + //read the table content + List tableContent = DomUtils.findAll(domCleanTable, "//logicalTable/content"); + if (tableContent == null || tableContent.size() == 0) + return null; + boolean firstRowHeader = false; + List rows = new ArrayList<>(); + NodeList rowNodes = tableContent.get(0).getChildNodes(); + + for (int i = 0; i < rowNodes.getLength(); i++) { + Node row = rowNodes.item(i); + if (row.getNodeName().equals("#text")) + continue; + if (row.getNodeName().equals("header")) { + firstRowHeader = true; + } + + List columns = DomUtils.findAll(row, "cell"); + String[] cells = new String[columns.size()]; + for (int j = 0; j < columns.size(); j++) { + Node cell = columns.get(j); + List html = DomUtils.findAll(cell, "html"); + String textContent = ""; + if (html != null && html.size() > 0) { + textContent = extractTextContentFromHtml(html); + } + + if (textContent.equals("")) { + List text = DomUtils.findAll(cell, "text"); + + if (text != null && text.size() > 0) { + textContent = text.get(0).getTextContent(); + } + } + cells[j] = textContent; + } + rows.add(cells); + } + + int totalCol = 0; + for (String[] row : rows) { + if (row.length > totalCol) + totalCol = row.length; + } + + Table table = null; + int rowModifier = 0; + if (firstRowHeader) { + table = new Table(String.valueOf(tableFilename.hashCode()), tableFilename, rows.size() - 1, totalCol); + rowModifier = 1; + if (rows.get(0).length < totalCol) { + System.err.println("WARNING:Artificial header added, check manually. " + tableFilename); + String[] headers = rows.get(0); + String[] modified = new String[totalCol]; + for (int i = 0; i < modified.length; i++) { + if (i < headers.length) + modified[i] = headers[i]; + else + modified[i] = STIEnum.TABLE_HEADER_UNKNOWN.getValue(); + } + rows.set(0, modified); + } + for (int j = 0; j < totalCol; j++) { + TColumnHeader header = new TColumnHeader(rows.get(0)[j]); + table.setColumnHeader(j, header); + } + } else {//no header, need to add false headers + table = new Table(String.valueOf(tableFilename.hashCode()), tableFilename, rows.size(), totalCol); + for (int j = 0; j < totalCol; j++) { + TColumnHeader header = new TColumnHeader(STIEnum.TABLE_HEADER_UNKNOWN.getValue()); + table.setColumnHeader(j, header); + } + } + + for (int r = rowModifier; r < rows.size(); r++) { + String[] cells = rows.get(r); + for (int c = 0; c < cells.length; c++) { + TCell cell = new TCell(cells[c]); + table.setContentCell(r - rowModifier, c, cell); + } + } + + + //read the table context + List tableContext = DomUtils.findAll(domCleanTable, "//logicalTable/tableContext"); + if (tableContext != null || tableContext.size() != 0) { + Node ctxParentNode = tableContext.get(0); + NodeList contexts = ctxParentNode.getChildNodes(); + for (int i = 0; i < contexts.getLength(); i++) { + + Node n = contexts.item(i); + if (n.getNodeName().equals("#text")) + continue; + List textNode = DomUtils.findAllByTag(n, "text"); + if (textNode != null && textNode.size() > 0) { + String context = textNode.get(0).getTextContent(); + if (context != null) { + TContext ctx = null; + if (i == 1) + ctx = new TContext(context, TContext.TableContextType.PAGETITLE, 1.0); + else ctx = new TContext(context, TContext.TableContextType.PARAGRAPH_BEFORE, 1.0); + + table.addContext(ctx); + } + } + } + } + if (table.getContexts().size() > 1) + table.getContexts().remove(1); //always isValidAttribute the 2nd context as it is the header of the table + + //dump the original html snippet to a human readable html format + if (htmlRepository != null) { + List htmlSnippet = DomUtils.findAll(domCleanTable, "//htmlSnippet"); + if (htmlSnippet != null && htmlSnippet.size() != 0) + dumpHTMLContent(htmlSnippet.get(0), htmlRepository, tableFilename); + } + if (tableAnnotationFilename == null) { + out.add(table); + return out; + } + + + if (new File(tableAnnotationFilename).exists()) { + Document domAnnotatedTable = docBuilder.parse(tableAnnotationFilename); + + //read the header annotations + List headerAnnotations = DomUtils.findAll(domAnnotatedTable, "//columnAnnotations/colAnnos"); + for (int i = 0; i < headerAnnotations.size(); i++) { + Node header = headerAnnotations.get(i); + int col = Integer.valueOf(header.getAttributes().getNamedItem("col").getTextContent()); + //TCell headerCell = table.getHeaderForColumn(col); + NodeList annotations = header.getChildNodes(); + List hAnnotations = new ArrayList<>(); + for (int j = 0; j < annotations.getLength(); j++) { + Node n = annotations.item(j); + if (n.getNodeName().equals("anno")) { + TColumnHeaderAnnotation a = new TColumnHeaderAnnotation(table.getColumnHeader(col).getHeaderText(), + new Clazz(n.getAttributes().getNamedItem("name").getTextContent(), + n.getAttributes().getNamedItem("name").getTextContent()), + Double.valueOf(n.getAttributes().getNamedItem("value").getTextContent().trim())); + + hAnnotations.add(a); + } + } + table.getTableAnnotations().setHeaderAnnotation(col, hAnnotations.toArray(new TColumnHeaderAnnotation[0])); + } + //read the data rows annotations + List dataRowAnnotations = DomUtils.findAll(domAnnotatedTable, "//cellAnnotatoons/row"); + for (int i = 0; i < dataRowAnnotations.size(); i++) { + Node row = dataRowAnnotations.get(i); + List cols = DomUtils.findAll(row, "entity"); + for (int j = 0; j < cols.size(); j++) { + Node htmlCell = cols.get(j); + if (htmlCell.getTextContent() == null || htmlCell.getTextContent().length() == 0) { + continue; + } + TCellAnnotation cellAnnotation = new TCellAnnotation( + table.getContentCell(i, j).getText(), new Entity(htmlCell.getTextContent(), htmlCell.getTextContent()), 1.0, new HashMap() + ); + + table.getTableAnnotations().setContentCellAnnotations( + i, j, new TCellAnnotation[]{cellAnnotation} + ); + } + + } + } + + out.add(table); + return out; + } + catch (Exception e){ + throw new STIException(e); + } + } + + private String extractTextContentFromHtml(List html) { + String content = html.get(0).getTextContent(); + int start=content.indexOf(""); + if(start!=-1){ + content=content.substring(start+4); + int end = content.indexOf(""); + if(end==-1) + end=content.indexOf(""); + if(end==-1) + end=content.indexOf(""); + if(end!=-1) + content=content.substring(0,end).trim(); + } + content= StringEscapeUtils.unescapeHtml4(content); + return content; + } + + private void dumpHTMLContent(Node htmlSnippetNode, String htmlRepository, String filePath) throws FileNotFoundException { + String content = htmlSnippetNode.getTextContent(); + int begin = content.indexOf("CDATA["); + begin = begin == -1 ? 0 : begin + 7; + int end = content.lastIndexOf("]]>"); + end = end == -1 ? content.length() : end; + content = content.substring(begin, end).trim(); + + PrintWriter p = new PrintWriter(htmlRepository + File.separator + new File(filePath).getName() + "_" + filePath.hashCode() + ".html"); + p.println("

"); + p.println(filePath); + p.println("

"); + p.println(content); + p.println(""); + p.close(); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserMusicBrainz.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserMusicBrainz.java index 62b5e4b9..a22eca66 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserMusicBrainz.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserMusicBrainz.java @@ -1,87 +1,87 @@ -package uk.ac.shef.dcs.sti.parser.table; - -import org.apache.any23.extractor.html.DomUtils; -import org.apache.any23.extractor.html.TagSoupParser; -import org.apache.commons.io.FileUtils; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.model.TContext; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreatorMusicBrainz; -import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetector; -import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetectorByHTMLTag; -import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizer; -import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreator; -import uk.ac.shef.dcs.sti.parser.table.context.TableContextExtractorMusicBrainz; -import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizerSimple; -import uk.ac.shef.dcs.sti.parser.table.validator.TableValidatorGeneric; -import uk.ac.shef.dcs.sti.parser.table.validator.TableValidator; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 20/02/14 - * Time: 17:28 - * To change this template use File | Settings | File Templates. - */ -public class TableParserMusicBrainz extends TableParser { - - public TableParserMusicBrainz(){ - super(new TableNormalizerSimple(), - new TableHODetectorByHTMLTag(), - new TableObjCreatorMusicBrainz(), - new TableValidatorGeneric()); - } - - public TableParserMusicBrainz(TableNormalizer normalizer, TableHODetector detector, TableObjCreator creator, TableValidator... validators) { - super(normalizer, detector, creator, validators); - } - - @Override - public List
"); + if(start==-1) + start=content.indexOf(""); + if(start==-1) + start=content.indexOf("
extract(String inFile, String sourceId) throws STIException { - - String input; - try { - input = FileUtils.readFileToString(new File(inFile)); - } catch (IOException e) { - throw new STIException(e); - } - List
rs = new ArrayList<>(); - parser = new TagSoupParser(new ByteArrayInputStream(input.getBytes()), sourceId,"UTF-8"); - Document doc = null; - try { - doc = parser.getDOM(); - } catch (IOException e) { - return rs; - } - - List tables = DomUtils.findAll(doc, "//TABLE[@class='tbl']"); - List contexts = new ArrayList<>(); - try { - contexts = new TableContextExtractorMusicBrainz().extract(new File(sourceId), doc); - } catch (STIException e) { - e.printStackTrace(); - } - int tableCount = 0; - for (Node n : tables) { - tableCount++; - - TContext[] contexts_array = new TContext[contexts.size()]; - for (int i = 0; i < contexts.size(); i++) - contexts_array[i] = contexts.get(i); - Table table = extractTable(n, String.valueOf(tableCount), - sourceId, contexts_array); - if (table != null) - rs.add(table); - - } - return rs; - } -} +package uk.ac.shef.dcs.sti.parser.table; + +import org.apache.any23.extractor.html.DomUtils; +import org.apache.any23.extractor.html.TagSoupParser; +import org.apache.commons.io.FileUtils; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.model.TContext; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreatorMusicBrainz; +import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetector; +import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetectorByHTMLTag; +import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizer; +import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreator; +import uk.ac.shef.dcs.sti.parser.table.context.TableContextExtractorMusicBrainz; +import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizerSimple; +import uk.ac.shef.dcs.sti.parser.table.validator.TableValidatorGeneric; +import uk.ac.shef.dcs.sti.parser.table.validator.TableValidator; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * Created with IntelliJ IDEA. + * User: zqz + * Date: 20/02/14 + * Time: 17:28 + * To change this template use File | Settings | File Templates. + */ +public class TableParserMusicBrainz extends TableParser { + + public TableParserMusicBrainz(){ + super(new TableNormalizerSimple(), + new TableHODetectorByHTMLTag(), + new TableObjCreatorMusicBrainz(), + new TableValidatorGeneric()); + } + + public TableParserMusicBrainz(TableNormalizer normalizer, TableHODetector detector, TableObjCreator creator, TableValidator... validators) { + super(normalizer, detector, creator, validators); + } + + @Override + public List
extract(String inFile, String sourceId) throws STIException { + + String input; + try { + input = FileUtils.readFileToString(new File(inFile)); + } catch (IOException e) { + throw new STIException(e); + } + List
rs = new ArrayList<>(); + parser = new TagSoupParser(new ByteArrayInputStream(input.getBytes()), sourceId,"UTF-8"); + Document doc = null; + try { + doc = parser.getDOM(); + } catch (IOException e) { + return rs; + } + + List tables = DomUtils.findAll(doc, "//TABLE[@class='tbl']"); + List contexts = new ArrayList<>(); + try { + contexts = new TableContextExtractorMusicBrainz().extract(new File(sourceId), doc); + } catch (STIException e) { + e.printStackTrace(); + } + int tableCount = 0; + for (Node n : tables) { + tableCount++; + + TContext[] contexts_array = new TContext[contexts.size()]; + for (int i = 0; i < contexts.size(); i++) + contexts_array[i] = contexts.get(i); + Table table = extractTable(n, String.valueOf(tableCount), + sourceId, contexts_array); + if (table != null) + rs.add(table); + + } + return rs; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserReverbnation.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserReverbnation.java index df2f9965..776c1148 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserReverbnation.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserReverbnation.java @@ -1,86 +1,86 @@ -package uk.ac.shef.dcs.sti.parser.table; - -import org.apache.any23.extractor.html.DomUtils; -import org.apache.any23.extractor.html.TagSoupParser; -import org.apache.commons.io.FileUtils; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.core.model.TContext; -import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreatorReverbnationList; -import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetector; -import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetectorByHTMLTag; -import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizer; -import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreator; -import uk.ac.shef.dcs.sti.parser.table.context.TableContextExtractorGeneric; -import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizerListTransformer; -import uk.ac.shef.dcs.sti.parser.table.validator.TableValidatorGeneric; -import uk.ac.shef.dcs.sti.parser.table.validator.TableValidator; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 31/03/14 - * Time: 15:21 - * To change this template use File | Settings | File Templates. - */ -public class TableParserReverbnation extends TableParser { - public TableParserReverbnation() { - super(new TableNormalizerListTransformer(), - new TableHODetectorByHTMLTag(), - new TableObjCreatorReverbnationList(), - new TableValidatorGeneric()); - } - - public TableParserReverbnation(TableNormalizer normalizer, TableHODetector detector, TableObjCreator creator, TableValidator... validators) { - super(normalizer, detector, creator, validators); - } - - @Override - public List
extract(String inFile, String sourceId) throws STIException { - String input; - try { - input = FileUtils.readFileToString(new File(inFile)); - } catch (IOException e) { - throw new STIException(e); - } - - List
rs = new ArrayList<>(); - parser = new TagSoupParser(new ByteArrayInputStream(input.getBytes()), sourceId,"UTF-8"); - Document doc = null; - try { - doc = parser.getDOM(); - } catch (IOException e) { - return rs; - } - - List tables = DomUtils.findAll(doc, "//UL[@class='profile_songs_container']"); - List contexts = new ArrayList<>(); - try { - contexts = new TableContextExtractorGeneric().extract(new File(sourceId), doc); - } catch (STIException e) { - e.printStackTrace(); - } - int tableCount = 0; - for (Node n : tables) { - tableCount++; - - TContext[] contexts_array = new TContext[contexts.size()]; - for (int i = 0; i < contexts.size(); i++) - contexts_array[i] = contexts.get(i); - Table table = extractTable(n, String.valueOf(tableCount), - sourceId, contexts_array); - if (table != null) - rs.add(table); - - } - return rs; - } -} +package uk.ac.shef.dcs.sti.parser.table; + +import org.apache.any23.extractor.html.DomUtils; +import org.apache.any23.extractor.html.TagSoupParser; +import org.apache.commons.io.FileUtils; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.core.model.TContext; +import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreatorReverbnationList; +import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetector; +import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetectorByHTMLTag; +import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizer; +import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreator; +import uk.ac.shef.dcs.sti.parser.table.context.TableContextExtractorGeneric; +import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizerListTransformer; +import uk.ac.shef.dcs.sti.parser.table.validator.TableValidatorGeneric; +import uk.ac.shef.dcs.sti.parser.table.validator.TableValidator; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * Created with IntelliJ IDEA. + * User: zqz + * Date: 31/03/14 + * Time: 15:21 + * To change this template use File | Settings | File Templates. + */ +public class TableParserReverbnation extends TableParser { + public TableParserReverbnation() { + super(new TableNormalizerListTransformer(), + new TableHODetectorByHTMLTag(), + new TableObjCreatorReverbnationList(), + new TableValidatorGeneric()); + } + + public TableParserReverbnation(TableNormalizer normalizer, TableHODetector detector, TableObjCreator creator, TableValidator... validators) { + super(normalizer, detector, creator, validators); + } + + @Override + public List
extract(String inFile, String sourceId) throws STIException { + String input; + try { + input = FileUtils.readFileToString(new File(inFile)); + } catch (IOException e) { + throw new STIException(e); + } + + List
rs = new ArrayList<>(); + parser = new TagSoupParser(new ByteArrayInputStream(input.getBytes()), sourceId,"UTF-8"); + Document doc = null; + try { + doc = parser.getDOM(); + } catch (IOException e) { + return rs; + } + + List tables = DomUtils.findAll(doc, "//UL[@class='profile_songs_container']"); + List contexts = new ArrayList<>(); + try { + contexts = new TableContextExtractorGeneric().extract(new File(sourceId), doc); + } catch (STIException e) { + e.printStackTrace(); + } + int tableCount = 0; + for (Node n : tables) { + tableCount++; + + TContext[] contexts_array = new TContext[contexts.size()]; + for (int i = 0; i < contexts.size(); i++) + contexts_array[i] = contexts.get(i); + Table table = extractTable(n, String.valueOf(tableCount), + sourceId, contexts_array); + if (table != null) + rs.add(table); + + } + return rs; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserRottenTomato.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserRottenTomato.java index 4dfa2e6f..50325dac 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserRottenTomato.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserRottenTomato.java @@ -1,119 +1,119 @@ -package uk.ac.shef.dcs.sti.parser.table; - -import org.apache.any23.extractor.html.DomUtils; -import org.apache.any23.extractor.html.TagSoupParser; -import org.apache.commons.io.FileUtils; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import uk.ac.shef.dcs.sti.STIEnum; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.TColumnHeader; -import uk.ac.shef.dcs.sti.core.model.TContext; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreatorGoodreads; -import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetector; -import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetectorByHTMLTag; -import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizer; -import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreator; -import uk.ac.shef.dcs.sti.parser.table.context.TableContextExtractorGeneric; -import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizerDiscardIrregularRows; -import uk.ac.shef.dcs.sti.parser.table.validator.TableValidatorGeneric; -import uk.ac.shef.dcs.sti.parser.table.validator.TableValidator; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 13/06/14 - * Time: 11:22 - * To change this template use File | Settings | File Templates. - */ -public class TableParserRottenTomato extends TableParser { - - public TableParserRottenTomato(){ - super(new TableNormalizerDiscardIrregularRows(true), - new TableHODetectorByHTMLTag(), - new TableObjCreatorGoodreads(), - new TableValidatorGeneric()); - } - - public TableParserRottenTomato(TableNormalizer normalizer, TableHODetector detector, TableObjCreator creator, TableValidator... validators) { - super(normalizer, detector, creator, validators); - } - - @Override - public List
extract(String inFile, String sourceId) throws STIException { - String input; - try { - input = FileUtils.readFileToString(new File(inFile)); - } catch (IOException e) { - throw new STIException(e); - } - - List
rs = new ArrayList<>(); - parser = new TagSoupParser(new ByteArrayInputStream(input.getBytes()), sourceId, "UTF-8"); - Document doc = null; - try { - doc = parser.getDOM(); - } catch (IOException e) { - return rs; - } - - List tables = DomUtils.findAll(doc, "//DIV[@id='cast-info']"); - if (tables.size() > 0) { - List contexts=new ArrayList<>(); - try { - contexts = new TableContextExtractorGeneric().extract(new File(sourceId), doc); - } catch (STIException e) { - e.printStackTrace(); - } - int tableCount = 0; - for (Node n : tables) { - tableCount++; - - Node ul = null; - NodeList list = n.getChildNodes(); - for (int i = 0; i < list.getLength(); i++) { - Node nn = list.item(i); - if (nn.getNodeName().equals("UL")) { - ul = nn; - break; - } - } - - if (ul == null) - continue; - - List items = DomUtils.findAll(ul, "LI"); - Table table = new Table(sourceId, sourceId, items.size(), 1); - for (TContext ltc : contexts) - table.addContext(ltc); - - table.setColumnHeader(0, new TColumnHeader(STIEnum.TABLE_HEADER_UNKNOWN.getValue())); - int i=0; - for(Node it: items){ - String content=""; - try{ - content=DomUtils.findAll(it, "DIV/A").get(0).getTextContent(); - }catch (NullPointerException npe){} - - TCell ltc = new TCell(content); - table.setContentCell(i, 0, ltc); - i++; - } - - if (table != null) - rs.add(table); - - } - } - return rs; - } -} +package uk.ac.shef.dcs.sti.parser.table; + +import org.apache.any23.extractor.html.DomUtils; +import org.apache.any23.extractor.html.TagSoupParser; +import org.apache.commons.io.FileUtils; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import uk.ac.shef.dcs.sti.STIEnum; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.model.TCell; +import uk.ac.shef.dcs.sti.core.model.TColumnHeader; +import uk.ac.shef.dcs.sti.core.model.TContext; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreatorGoodreads; +import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetector; +import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetectorByHTMLTag; +import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizer; +import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreator; +import uk.ac.shef.dcs.sti.parser.table.context.TableContextExtractorGeneric; +import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizerDiscardIrregularRows; +import uk.ac.shef.dcs.sti.parser.table.validator.TableValidatorGeneric; +import uk.ac.shef.dcs.sti.parser.table.validator.TableValidator; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * Created with IntelliJ IDEA. + * User: zqz + * Date: 13/06/14 + * Time: 11:22 + * To change this template use File | Settings | File Templates. + */ +public class TableParserRottenTomato extends TableParser { + + public TableParserRottenTomato(){ + super(new TableNormalizerDiscardIrregularRows(true), + new TableHODetectorByHTMLTag(), + new TableObjCreatorGoodreads(), + new TableValidatorGeneric()); + } + + public TableParserRottenTomato(TableNormalizer normalizer, TableHODetector detector, TableObjCreator creator, TableValidator... validators) { + super(normalizer, detector, creator, validators); + } + + @Override + public List
extract(String inFile, String sourceId) throws STIException { + String input; + try { + input = FileUtils.readFileToString(new File(inFile)); + } catch (IOException e) { + throw new STIException(e); + } + + List
rs = new ArrayList<>(); + parser = new TagSoupParser(new ByteArrayInputStream(input.getBytes()), sourceId, "UTF-8"); + Document doc = null; + try { + doc = parser.getDOM(); + } catch (IOException e) { + return rs; + } + + List tables = DomUtils.findAll(doc, "//DIV[@id='cast-info']"); + if (tables.size() > 0) { + List contexts=new ArrayList<>(); + try { + contexts = new TableContextExtractorGeneric().extract(new File(sourceId), doc); + } catch (STIException e) { + e.printStackTrace(); + } + int tableCount = 0; + for (Node n : tables) { + tableCount++; + + Node ul = null; + NodeList list = n.getChildNodes(); + for (int i = 0; i < list.getLength(); i++) { + Node nn = list.item(i); + if (nn.getNodeName().equals("UL")) { + ul = nn; + break; + } + } + + if (ul == null) + continue; + + List items = DomUtils.findAll(ul, "LI"); + Table table = new Table(sourceId, sourceId, items.size(), 1); + for (TContext ltc : contexts) + table.addContext(ltc); + + table.setColumnHeader(0, new TColumnHeader(STIEnum.TABLE_HEADER_UNKNOWN.getValue())); + int i=0; + for(Node it: items){ + String content=""; + try{ + content=DomUtils.findAll(it, "DIV/A").get(0).getTextContent(); + }catch (NullPointerException npe){} + + TCell ltc = new TCell(content); + table.setContentCell(i, 0, ltc); + i++; + } + + if (table != null) + rs.add(table); + + } + } + return rs; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserWikipedia.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserWikipedia.java index 4f4f97cb..1790727f 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserWikipedia.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/TableParserWikipedia.java @@ -1,77 +1,77 @@ -package uk.ac.shef.dcs.sti.parser.table; - -import info.bliki.wiki.model.WikiModel; -import org.apache.any23.extractor.html.DomUtils; -import org.apache.any23.extractor.html.TagSoupParser; -import org.apache.commons.io.FileUtils; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.core.model.TContext; -import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetector; -import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizer; -import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreator; -import uk.ac.shef.dcs.sti.parser.table.validator.TableValidator; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 03/10/12 - * Time: 12:08 - */ -public class TableParserWikipedia extends TableParser { - private WikiModel model; - - public TableParserWikipedia(TableNormalizer normalizer, TableHODetector detector, TableObjCreator creator, - TableValidator... validators) { - super(normalizer, detector, creator, validators); - model = new WikiModel("/${image}", "/${title}"); - } - - - @Override - public List
extract(String inFile, String sourceId) throws STIException, IOException { - String input; - try { - input = FileUtils.readFileToString(new File(inFile)); - } catch (IOException e) { - throw new STIException(e); - } - - String html = model.render(input); - List
rs = new ArrayList<>(); - - parser = new TagSoupParser(new ByteArrayInputStream(html.getBytes()), sourceId); - Document doc = null; - try { - doc = parser.getDOM(); - } catch (IOException e) { - return rs; - } - - int tableCount = 0; - List tables = DomUtils.findAll(doc, "//TABLE[@class='wikitable']"); - for (Node tableElement : tables) { - tableCount++; - - //todo: extract contexts for wikitable - TContext[] contexts = new TContext[0]; - - Table table = extractTable(tableElement, String.valueOf(tableCount), - sourceId, contexts); - if (table != null) - rs.add(table); - - - } - return rs; - } - - -} +package uk.ac.shef.dcs.sti.parser.table; + +import info.bliki.wiki.model.WikiModel; +import org.apache.any23.extractor.html.DomUtils; +import org.apache.any23.extractor.html.TagSoupParser; +import org.apache.commons.io.FileUtils; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.core.model.TContext; +import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetector; +import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizer; +import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreator; +import uk.ac.shef.dcs.sti.parser.table.validator.TableValidator; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 03/10/12 + * Time: 12:08 + */ +public class TableParserWikipedia extends TableParser { + private WikiModel model; + + public TableParserWikipedia(TableNormalizer normalizer, TableHODetector detector, TableObjCreator creator, + TableValidator... validators) { + super(normalizer, detector, creator, validators); + model = new WikiModel("/${image}", "/${title}"); + } + + + @Override + public List
extract(String inFile, String sourceId) throws STIException, IOException { + String input; + try { + input = FileUtils.readFileToString(new File(inFile)); + } catch (IOException e) { + throw new STIException(e); + } + + String html = model.render(input); + List
rs = new ArrayList<>(); + + parser = new TagSoupParser(new ByteArrayInputStream(html.getBytes()), sourceId); + Document doc = null; + try { + doc = parser.getDOM(); + } catch (IOException e) { + return rs; + } + + int tableCount = 0; + List tables = DomUtils.findAll(doc, "//TABLE[@class='wikitable']"); + for (Node tableElement : tables) { + tableCount++; + + //todo: extract contexts for wikitable + TContext[] contexts = new TContext[0]; + + Table table = extractTable(tableElement, String.valueOf(tableCount), + sourceId, contexts); + if (table != null) + rs.add(table); + + + } + return rs; + } + + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractor.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractor.java index df2b7003..d141d69e 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractor.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractor.java @@ -1,16 +1,16 @@ -package uk.ac.shef.dcs.sti.parser.table.context; - -import org.w3c.dom.Document; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.model.TContext; - -import java.io.File; -import java.util.List; - -/** - * Created by - on 04/04/2016. - */ -public interface TableContextExtractor { - - List extract(File file, Document doc) throws STIException; -} +package uk.ac.shef.dcs.sti.parser.table.context; + +import org.w3c.dom.Document; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.model.TContext; + +import java.io.File; +import java.util.List; + +/** + * Created by - on 04/04/2016. + */ +public interface TableContextExtractor { + + List extract(File file, Document doc) throws STIException; +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorGeneric.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorGeneric.java index 6c97e4e1..e9a333a5 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorGeneric.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorGeneric.java @@ -1,46 +1,46 @@ -package uk.ac.shef.dcs.sti.parser.table.context; - -import org.apache.any23.extractor.html.DomUtils; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.model.TContext; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -/** - * - */ -public class TableContextExtractorGeneric implements TableContextExtractor{ - public List extract(File file, Document doc) throws STIException{ - List contexts = new ArrayList<>(); - - //paragraph contexts - List paragraphs = DomUtils.findAll(doc, "//P"); - List paragraphs2 = DomUtils.findAll(doc, "P"); - if(paragraphs.size() titles = DomUtils.findAll(doc, "//TITLE"); - for(Node n: titles){ - String text =n.getTextContent().trim(); - if(text.length()<1) - continue; - TContext ltc = new TContext(text, - TContext.TableContextType.PAGETITLE,1.0); - contexts.add(ltc); - } - return contexts; - } - -} +package uk.ac.shef.dcs.sti.parser.table.context; + +import org.apache.any23.extractor.html.DomUtils; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.model.TContext; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** + * + */ +public class TableContextExtractorGeneric implements TableContextExtractor{ + public List extract(File file, Document doc) throws STIException{ + List contexts = new ArrayList<>(); + + //paragraph contexts + List paragraphs = DomUtils.findAll(doc, "//P"); + List paragraphs2 = DomUtils.findAll(doc, "P"); + if(paragraphs.size() titles = DomUtils.findAll(doc, "//TITLE"); + for(Node n: titles){ + String text =n.getTextContent().trim(); + if(text.length()<1) + continue; + TContext ltc = new TContext(text, + TContext.TableContextType.PAGETITLE,1.0); + contexts.add(ltc); + } + return contexts; + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorIMDB.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorIMDB.java index 033ecdc0..be4a1b37 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorIMDB.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorIMDB.java @@ -1,81 +1,81 @@ -package uk.ac.shef.dcs.sti.parser.table.context; - -import org.apache.any23.extractor.html.DomUtils; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.any23.Any23Xtractor; -import uk.ac.shef.dcs.sti.core.model.TContext; -import uk.ac.shef.oak.any23.extension.extractor.LTriple; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -/** - */ -public class TableContextExtractorIMDB implements TableContextExtractor{ - - - public List extract(File file, Document doc) throws STIException { - List triples = Any23Xtractor.extract(file); - - //triple contexts - List contexts = new ArrayList<>(); - for (LTriple lt : triples) { - if (lt.getsXPath() != null && lt.getsXPath().toLowerCase().contains("table")) - continue; - if (lt.getoXPath() != null && lt.getoXPath().toLowerCase().contains("table")) - continue; - if (lt.getpXPath() != null && lt.getpXPath().toLowerCase().contains("table")) - continue; - - String obj_string_value = lt.getTriple().getObject().stringValue(); - if (obj_string_value.startsWith("node") || obj_string_value.startsWith("file:/")) - continue; - - TContext ltc = new TContext(lt.getTriple().getObject().stringValue(), - TContext.TableContextType.CAPTION, 1.0); - contexts.add(ltc); - } - - contexts.addAll(extractOtherContexts(doc)); - - return contexts; - } - - private List extractOtherContexts(Document doc) throws STIException { - List contexts = new ArrayList<>(); - - //paragraph contexts - List paragraphs = DomUtils.findAll(doc, "//DIV[@class='txt-block']"); - //List paragraphs2 = DomUtils.findAll(doc, "P"); - for (Node n : paragraphs) { - NodeList children = n.getChildNodes(); - String text = ""; - for (int i = 0; i < children.getLength(); i++) { - text += children.item(i).getTextContent().trim()+" "; - } - text=text.trim(); - if (text.length() < 1) - continue; - TContext ltc = new TContext(text, - TContext.TableContextType.PARAGRAPH_BEFORE, 1.0); - - contexts.add(ltc); - } - - List titles = DomUtils.findAll(doc, "//TITLE"); - for (Node n : titles) { - String text = n.getTextContent().trim(); - if (text.length() < 1) - continue; - TContext ltc = new TContext(text, - TContext.TableContextType.PAGETITLE, 1.0); - contexts.add(ltc); - } - - return contexts; - } -} +package uk.ac.shef.dcs.sti.parser.table.context; + +import org.apache.any23.extractor.html.DomUtils; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.any23.Any23Xtractor; +import uk.ac.shef.dcs.sti.core.model.TContext; +import uk.ac.shef.oak.any23.extension.extractor.LTriple; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** + */ +public class TableContextExtractorIMDB implements TableContextExtractor{ + + + public List extract(File file, Document doc) throws STIException { + List triples = Any23Xtractor.extract(file); + + //triple contexts + List contexts = new ArrayList<>(); + for (LTriple lt : triples) { + if (lt.getsXPath() != null && lt.getsXPath().toLowerCase().contains("table")) + continue; + if (lt.getoXPath() != null && lt.getoXPath().toLowerCase().contains("table")) + continue; + if (lt.getpXPath() != null && lt.getpXPath().toLowerCase().contains("table")) + continue; + + String obj_string_value = lt.getTriple().getObject().stringValue(); + if (obj_string_value.startsWith("node") || obj_string_value.startsWith("file:/")) + continue; + + TContext ltc = new TContext(lt.getTriple().getObject().stringValue(), + TContext.TableContextType.CAPTION, 1.0); + contexts.add(ltc); + } + + contexts.addAll(extractOtherContexts(doc)); + + return contexts; + } + + private List extractOtherContexts(Document doc) throws STIException { + List contexts = new ArrayList<>(); + + //paragraph contexts + List paragraphs = DomUtils.findAll(doc, "//DIV[@class='txt-block']"); + //List paragraphs2 = DomUtils.findAll(doc, "P"); + for (Node n : paragraphs) { + NodeList children = n.getChildNodes(); + String text = ""; + for (int i = 0; i < children.getLength(); i++) { + text += children.item(i).getTextContent().trim()+" "; + } + text=text.trim(); + if (text.length() < 1) + continue; + TContext ltc = new TContext(text, + TContext.TableContextType.PARAGRAPH_BEFORE, 1.0); + + contexts.add(ltc); + } + + List titles = DomUtils.findAll(doc, "//TITLE"); + for (Node n : titles) { + String text = n.getTextContent().trim(); + if (text.length() < 1) + continue; + TContext ltc = new TContext(text, + TContext.TableContextType.PAGETITLE, 1.0); + contexts.add(ltc); + } + + return contexts; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorMusicBrainz.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorMusicBrainz.java index ab3964c2..3bfc59e4 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorMusicBrainz.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/context/TableContextExtractorMusicBrainz.java @@ -1,68 +1,68 @@ -package uk.ac.shef.dcs.sti.parser.table.context; - -import org.apache.any23.extractor.html.DomUtils; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.any23.Any23Xtractor; -import uk.ac.shef.dcs.sti.core.model.TContext; -import uk.ac.shef.oak.any23.extension.extractor.LTriple; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -/** - * - */ -public class TableContextExtractorMusicBrainz implements TableContextExtractor { - - public List extract(File file, Document doc) throws STIException { - List triples = Any23Xtractor.extract(file); - - //triple contexts - List contexts = new ArrayList<>(); - for(LTriple lt : triples){ - if(lt.getsXPath()!=null&& lt.getsXPath().toLowerCase().contains("table")) - continue; - if(lt.getoXPath()!=null&& lt.getoXPath().toLowerCase().contains("table")) - continue; - if(lt.getpXPath()!=null&& lt.getpXPath().toLowerCase().contains("table")) - continue; - - String obj_string_value = lt.getTriple().getObject().stringValue(); - if(obj_string_value.startsWith("node")||obj_string_value.startsWith("file:/")||obj_string_value.startsWith("http://")) - continue; - - TContext ltc = new TContext(lt.getTriple().getObject().stringValue(), - TContext.TableContextType.CAPTION, 1.0); - contexts.add(ltc); - } - - //paragraph contexts - List paragraphs = DomUtils.findAll(doc, "//P"); - List paragraphs2 = DomUtils.findAll(doc, "P"); - if(paragraphs.size() titles = DomUtils.findAll(doc, "//TITLE"); - for(Node n: titles){ - String text =n.getTextContent().trim(); - if(text.length()<1) - continue; - TContext ltc = new TContext(text, - TContext.TableContextType.PAGETITLE,1.0); - contexts.add(ltc); - } - - return contexts; - } -} +package uk.ac.shef.dcs.sti.parser.table.context; + +import org.apache.any23.extractor.html.DomUtils; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.any23.Any23Xtractor; +import uk.ac.shef.dcs.sti.core.model.TContext; +import uk.ac.shef.oak.any23.extension.extractor.LTriple; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** + * + */ +public class TableContextExtractorMusicBrainz implements TableContextExtractor { + + public List extract(File file, Document doc) throws STIException { + List triples = Any23Xtractor.extract(file); + + //triple contexts + List contexts = new ArrayList<>(); + for(LTriple lt : triples){ + if(lt.getsXPath()!=null&& lt.getsXPath().toLowerCase().contains("table")) + continue; + if(lt.getoXPath()!=null&& lt.getoXPath().toLowerCase().contains("table")) + continue; + if(lt.getpXPath()!=null&& lt.getpXPath().toLowerCase().contains("table")) + continue; + + String obj_string_value = lt.getTriple().getObject().stringValue(); + if(obj_string_value.startsWith("node")||obj_string_value.startsWith("file:/")||obj_string_value.startsWith("http://")) + continue; + + TContext ltc = new TContext(lt.getTriple().getObject().stringValue(), + TContext.TableContextType.CAPTION, 1.0); + contexts.add(ltc); + } + + //paragraph contexts + List paragraphs = DomUtils.findAll(doc, "//P"); + List paragraphs2 = DomUtils.findAll(doc, "P"); + if(paragraphs.size() titles = DomUtils.findAll(doc, "//TITLE"); + for(Node n: titles){ + String text =n.getTextContent().trim(); + if(text.length()<1) + continue; + TContext ltc = new TContext(text, + TContext.TableContextType.PAGETITLE,1.0); + contexts.add(ltc); + } + + return contexts; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreator.java index 473df3c9..f4109afd 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreator.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreator.java @@ -1,18 +1,18 @@ -package uk.ac.shef.dcs.sti.parser.table.creator; - -import cern.colt.matrix.ObjectMatrix2D; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.core.model.TContext; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 05/10/12 - * Time: 15:40 - * - * Takes the result from TableHODector and parses it into a Table object - * - * Must deal with at least: - */ -public interface TableObjCreator { - Table create(ObjectMatrix2D preTable, String tableId, String sourceId, TContext... contexts); -} +package uk.ac.shef.dcs.sti.parser.table.creator; + +import cern.colt.matrix.ObjectMatrix2D; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.core.model.TContext; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 05/10/12 + * Time: 15:40 + * + * Takes the result from TableHODector and parses it into a Table object + * + * Must deal with at least: + */ +public interface TableObjCreator { + Table create(ObjectMatrix2D preTable, String tableId, String sourceId, TContext... contexts); +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorGoodreads.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorGoodreads.java index 2092d3c3..5a0e41bc 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorGoodreads.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorGoodreads.java @@ -1,104 +1,104 @@ -package uk.ac.shef.dcs.sti.parser.table.creator; - -import cern.colt.matrix.ObjectMatrix2D; -import org.apache.any23.extractor.html.DomUtils; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import uk.ac.shef.dcs.sti.STIEnum; -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.TContext; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.core.model.TColumnHeader; -import uk.ac.shef.dcs.sti.util.XPathUtils; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 31/03/14 - * Time: 15:25 - * To change this template use File | Settings | File Templates. - */ -public class TableObjCreatorGoodreads implements TableObjCreator { - @Override - public Table create(ObjectMatrix2D preTable, String tableId, String sourceId, TContext... contexts) { - Table table = new Table(tableId, sourceId, preTable.rows() - 1, preTable.columns()); - for (TContext ctx : contexts) - table.addContext(ctx); - - //firstly add the header row - for (int c = 0; c < preTable.columns(); c++) { - Object o = preTable.get(0, c); - if (o == null) { //a null value will be inserted by TableHODetector if no user defined header was found - //todo: header column type - TColumnHeader header = new TColumnHeader(STIEnum.TABLE_HEADER_UNKNOWN.getValue()); - table.setColumnHeader(c, header); - - } else { - //todo: header column type - Node e = (Node) o; - String text = e.getTextContent(); - String xPath = DomUtils.getXPathForNode(e); - - TColumnHeader header = new TColumnHeader(text); - header.setHeaderXPath(xPath); - table.setColumnHeader(c, header); - } - } - - //then go thru each other rows - for (int r = 1; r < preTable.rows(); r++) { - for (int c = 0; c < preTable.columns(); c++) { - //get url - Node e = (Node) preTable.get(r, c); - String text = ""; - String xPath = ""; - if (c == 1) { - NodeList nl = e.getChildNodes(); - for (int i = 0; i < nl.getLength(); i++) { - Node an = nl.item(i); - if (an.getNodeName().equalsIgnoreCase("A")) { - String linkClass = an.getAttributes().getNamedItem("class").getTextContent(); - if (linkClass.equals("bookTitle")) { - text = an.getTextContent().trim(); - xPath = DomUtils.getXPathForNode(an); - } - - break; - } - } - } else { - e = (Node) preTable.get(r, c); - text = e.getTextContent().trim(); - xPath = DomUtils.getXPathForNode(e); - } - - - TCell cell = new TCell(text); - cell.setText(text); - - table.setContentCell(r - 1, c, cell); - - //handle the table row once - if (c == 0 && xPath != null) { - String rowXPath = XPathUtils.trimXPathLastTag("TR", xPath); - table.getRowXPaths().put(r, rowXPath); - } - } - } - - if (table.getRowXPaths().size() > 0) { - String rowXPath = table.getRowXPaths().get(0); - if (rowXPath == null && table.getRowXPaths().size() > 1) - rowXPath = table.getRowXPaths().get(1); - if (rowXPath == null) { - } - //System.out.println(); - else { - String tableXPath = XPathUtils.trimXPathLastTag("TABLE", rowXPath); - table.setTableXPath(tableXPath); - } - } - - return table; - } -} +package uk.ac.shef.dcs.sti.parser.table.creator; + +import cern.colt.matrix.ObjectMatrix2D; +import org.apache.any23.extractor.html.DomUtils; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import uk.ac.shef.dcs.sti.STIEnum; +import uk.ac.shef.dcs.sti.core.model.TCell; +import uk.ac.shef.dcs.sti.core.model.TContext; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.core.model.TColumnHeader; +import uk.ac.shef.dcs.sti.util.XPathUtils; + +/** + * Created with IntelliJ IDEA. + * User: zqz + * Date: 31/03/14 + * Time: 15:25 + * To change this template use File | Settings | File Templates. + */ +public class TableObjCreatorGoodreads implements TableObjCreator { + @Override + public Table create(ObjectMatrix2D preTable, String tableId, String sourceId, TContext... contexts) { + Table table = new Table(tableId, sourceId, preTable.rows() - 1, preTable.columns()); + for (TContext ctx : contexts) + table.addContext(ctx); + + //firstly add the header row + for (int c = 0; c < preTable.columns(); c++) { + Object o = preTable.get(0, c); + if (o == null) { //a null value will be inserted by TableHODetector if no user defined header was found + //todo: header column type + TColumnHeader header = new TColumnHeader(STIEnum.TABLE_HEADER_UNKNOWN.getValue()); + table.setColumnHeader(c, header); + + } else { + //todo: header column type + Node e = (Node) o; + String text = e.getTextContent(); + String xPath = DomUtils.getXPathForNode(e); + + TColumnHeader header = new TColumnHeader(text); + header.setHeaderXPath(xPath); + table.setColumnHeader(c, header); + } + } + + //then go thru each other rows + for (int r = 1; r < preTable.rows(); r++) { + for (int c = 0; c < preTable.columns(); c++) { + //get url + Node e = (Node) preTable.get(r, c); + String text = ""; + String xPath = ""; + if (c == 1) { + NodeList nl = e.getChildNodes(); + for (int i = 0; i < nl.getLength(); i++) { + Node an = nl.item(i); + if (an.getNodeName().equalsIgnoreCase("A")) { + String linkClass = an.getAttributes().getNamedItem("class").getTextContent(); + if (linkClass.equals("bookTitle")) { + text = an.getTextContent().trim(); + xPath = DomUtils.getXPathForNode(an); + } + + break; + } + } + } else { + e = (Node) preTable.get(r, c); + text = e.getTextContent().trim(); + xPath = DomUtils.getXPathForNode(e); + } + + + TCell cell = new TCell(text); + cell.setText(text); + + table.setContentCell(r - 1, c, cell); + + //handle the table row once + if (c == 0 && xPath != null) { + String rowXPath = XPathUtils.trimXPathLastTag("TR", xPath); + table.getRowXPaths().put(r, rowXPath); + } + } + } + + if (table.getRowXPaths().size() > 0) { + String rowXPath = table.getRowXPaths().get(0); + if (rowXPath == null && table.getRowXPaths().size() > 1) + rowXPath = table.getRowXPaths().get(1); + if (rowXPath == null) { + } + //System.out.println(); + else { + String tableXPath = XPathUtils.trimXPathLastTag("TABLE", rowXPath); + table.setTableXPath(tableXPath); + } + } + + return table; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorHTML.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorHTML.java index ff4db446..a2cacdad 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorHTML.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorHTML.java @@ -1,82 +1,82 @@ -package uk.ac.shef.dcs.sti.parser.table.creator; - -import cern.colt.matrix.ObjectMatrix2D; -import org.apache.any23.extractor.html.DomUtils; -import org.w3c.dom.Node; -import uk.ac.shef.dcs.sti.STIEnum; -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.TContext; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.core.model.TColumnHeader; -import uk.ac.shef.dcs.sti.util.XPathUtils; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 26/10/12 - * Time: 10:35 - */ -public class TableObjCreatorHTML implements TableObjCreator { - - @Override - public Table create(ObjectMatrix2D preTable, String tableId, String sourceId, TContext... context) { - Table table = new Table(tableId, sourceId, preTable.rows()-1, preTable.columns()); - for (TContext ctx : context) - table.addContext(ctx); - - //firstly add the header row - for (int c = 0; c < preTable.columns(); c++) { - Object o = preTable.get(0, c); - if (o == null) { //a null value will be inserted by TableHODetector if no user defined header was found - //todo: header column type - TColumnHeader header = new TColumnHeader(STIEnum.TABLE_HEADER_UNKNOWN.getValue()); - table.setColumnHeader(c,header); - - } else { - //todo: header column type - Node e = (Node) o; - String text = e.getTextContent(); - String xPath= DomUtils.getXPathForNode(e); - - TColumnHeader header = new TColumnHeader(text); - header.setHeaderXPath(xPath); - table.setColumnHeader(c,header); - } - } - - //then go thru each other rows - for (int r = 1; r < preTable.rows(); r++) { - for (int c = 0; c < preTable.columns(); c++) { - Node e = (Node) preTable.get(r, c); - String text = e.getTextContent(); - String xPath= DomUtils.getXPathForNode(e); - - TCell cell = new TCell(text); - cell.setText(text); - cell.setxPath(xPath); - //todo: content cell type - - table.setContentCell(r-1,c,cell); - - //handle the table row once - if (c == 0 && xPath!=null) { - String rowXPath = XPathUtils.trimXPathLastTag("TR", xPath); - table.getRowXPaths().put(r,rowXPath); - } - } - } - - if(table.getRowXPaths().size()>0){ - String rowXPath=table.getRowXPaths().get(0); - if(rowXPath==null && table.getRowXPaths().size()>1) - rowXPath = table.getRowXPaths().get(1); - if(rowXPath!=null) { - //System.out.println(); - String tableXPath = XPathUtils.trimXPathLastTag("TABLE", rowXPath); - table.setTableXPath(tableXPath); - } - } - - return table; - } - -} +package uk.ac.shef.dcs.sti.parser.table.creator; + +import cern.colt.matrix.ObjectMatrix2D; +import org.apache.any23.extractor.html.DomUtils; +import org.w3c.dom.Node; +import uk.ac.shef.dcs.sti.STIEnum; +import uk.ac.shef.dcs.sti.core.model.TCell; +import uk.ac.shef.dcs.sti.core.model.TContext; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.core.model.TColumnHeader; +import uk.ac.shef.dcs.sti.util.XPathUtils; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 26/10/12 + * Time: 10:35 + */ +public class TableObjCreatorHTML implements TableObjCreator { + + @Override + public Table create(ObjectMatrix2D preTable, String tableId, String sourceId, TContext... context) { + Table table = new Table(tableId, sourceId, preTable.rows()-1, preTable.columns()); + for (TContext ctx : context) + table.addContext(ctx); + + //firstly add the header row + for (int c = 0; c < preTable.columns(); c++) { + Object o = preTable.get(0, c); + if (o == null) { //a null value will be inserted by TableHODetector if no user defined header was found + //todo: header column type + TColumnHeader header = new TColumnHeader(STIEnum.TABLE_HEADER_UNKNOWN.getValue()); + table.setColumnHeader(c,header); + + } else { + //todo: header column type + Node e = (Node) o; + String text = e.getTextContent(); + String xPath= DomUtils.getXPathForNode(e); + + TColumnHeader header = new TColumnHeader(text); + header.setHeaderXPath(xPath); + table.setColumnHeader(c,header); + } + } + + //then go thru each other rows + for (int r = 1; r < preTable.rows(); r++) { + for (int c = 0; c < preTable.columns(); c++) { + Node e = (Node) preTable.get(r, c); + String text = e.getTextContent(); + String xPath= DomUtils.getXPathForNode(e); + + TCell cell = new TCell(text); + cell.setText(text); + cell.setxPath(xPath); + //todo: content cell type + + table.setContentCell(r-1,c,cell); + + //handle the table row once + if (c == 0 && xPath!=null) { + String rowXPath = XPathUtils.trimXPathLastTag("TR", xPath); + table.getRowXPaths().put(r,rowXPath); + } + } + } + + if(table.getRowXPaths().size()>0){ + String rowXPath=table.getRowXPaths().get(0); + if(rowXPath==null && table.getRowXPaths().size()>1) + rowXPath = table.getRowXPaths().get(1); + if(rowXPath!=null) { + //System.out.println(); + String tableXPath = XPathUtils.trimXPathLastTag("TABLE", rowXPath); + table.setTableXPath(tableXPath); + } + } + + return table; + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorIMDB.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorIMDB.java index 592faf15..17a3e808 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorIMDB.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorIMDB.java @@ -1,96 +1,96 @@ -package uk.ac.shef.dcs.sti.parser.table.creator; - -import cern.colt.matrix.ObjectMatrix2D; -import org.apache.any23.extractor.html.DomUtils; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import uk.ac.shef.dcs.sti.STIEnum; -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.TContext; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.core.model.TColumnHeader; -import uk.ac.shef.dcs.sti.util.XPathUtils; - -/** - - */ -public class TableObjCreatorIMDB implements TableObjCreator { - @Override - public Table create(ObjectMatrix2D preTable, String tableId, String sourceId, TContext... contexts) { - Table table = new Table(tableId, sourceId, preTable.rows() - 1, preTable.columns()); - for (TContext ctx : contexts) - table.addContext(ctx); - - //firstly add the header row - for (int c = 0; c < preTable.columns(); c++) { - Object o = preTable.get(0, c); - if (o == null) { //a null value will be inserted by TableHODetector if no user defined header was found - //todo: header column type - TColumnHeader header = new TColumnHeader(STIEnum.TABLE_HEADER_UNKNOWN.getValue()); - table.setColumnHeader(c, header); - - } else { - //todo: header column type - Node e = (Node) o; - String text = e.getTextContent(); - String xPath = DomUtils.getXPathForNode(e); - - TColumnHeader header = new TColumnHeader(text); - header.setHeaderXPath(xPath); - table.setColumnHeader(c, header); - } - } - - //then go thru each other rows - for (int r = 1; r < preTable.rows(); r++) { - for (int c = 0; c < preTable.columns(); c++) { - //get url - Node e = (Node) preTable.get(r, c); - String text = ""; - String xPath = ""; - if (c == 0) { - NodeList nl = e.getChildNodes(); - for (int i = 0; i < nl.getLength(); i++) { - Node an = nl.item(i); - if (an.getNodeName().equalsIgnoreCase("A")) { - String link = an.getAttributes().getNamedItem("href").getTextContent(); - text = "http://www.imdb.com" + link; - xPath = DomUtils.getXPathForNode(an); - break; - } - } - } else { - e = (Node) preTable.get(r, c); - text = e.getTextContent().trim(); - xPath = DomUtils.getXPathForNode(e); - } - - - TCell cell = new TCell(text); - cell.setText(text); - - table.setContentCell(r - 1, c, cell); - - //handle the table row once - if (c == 0 && xPath != null) { - String rowXPath = XPathUtils.trimXPathLastTag("TR", xPath); - table.getRowXPaths().put(r, rowXPath); - } - } - } - - if (table.getRowXPaths().size() > 0) { - String rowXPath = table.getRowXPaths().get(0); - if (rowXPath == null && table.getRowXPaths().size() > 1) - rowXPath = table.getRowXPaths().get(1); - if (rowXPath == null){} - //System.out.println(); - else { - String tableXPath = XPathUtils.trimXPathLastTag("TABLE", rowXPath); - table.setTableXPath(tableXPath); - } - } - - return table; - } -} +package uk.ac.shef.dcs.sti.parser.table.creator; + +import cern.colt.matrix.ObjectMatrix2D; +import org.apache.any23.extractor.html.DomUtils; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import uk.ac.shef.dcs.sti.STIEnum; +import uk.ac.shef.dcs.sti.core.model.TCell; +import uk.ac.shef.dcs.sti.core.model.TContext; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.core.model.TColumnHeader; +import uk.ac.shef.dcs.sti.util.XPathUtils; + +/** + + */ +public class TableObjCreatorIMDB implements TableObjCreator { + @Override + public Table create(ObjectMatrix2D preTable, String tableId, String sourceId, TContext... contexts) { + Table table = new Table(tableId, sourceId, preTable.rows() - 1, preTable.columns()); + for (TContext ctx : contexts) + table.addContext(ctx); + + //firstly add the header row + for (int c = 0; c < preTable.columns(); c++) { + Object o = preTable.get(0, c); + if (o == null) { //a null value will be inserted by TableHODetector if no user defined header was found + //todo: header column type + TColumnHeader header = new TColumnHeader(STIEnum.TABLE_HEADER_UNKNOWN.getValue()); + table.setColumnHeader(c, header); + + } else { + //todo: header column type + Node e = (Node) o; + String text = e.getTextContent(); + String xPath = DomUtils.getXPathForNode(e); + + TColumnHeader header = new TColumnHeader(text); + header.setHeaderXPath(xPath); + table.setColumnHeader(c, header); + } + } + + //then go thru each other rows + for (int r = 1; r < preTable.rows(); r++) { + for (int c = 0; c < preTable.columns(); c++) { + //get url + Node e = (Node) preTable.get(r, c); + String text = ""; + String xPath = ""; + if (c == 0) { + NodeList nl = e.getChildNodes(); + for (int i = 0; i < nl.getLength(); i++) { + Node an = nl.item(i); + if (an.getNodeName().equalsIgnoreCase("A")) { + String link = an.getAttributes().getNamedItem("href").getTextContent(); + text = "http://www.imdb.com" + link; + xPath = DomUtils.getXPathForNode(an); + break; + } + } + } else { + e = (Node) preTable.get(r, c); + text = e.getTextContent().trim(); + xPath = DomUtils.getXPathForNode(e); + } + + + TCell cell = new TCell(text); + cell.setText(text); + + table.setContentCell(r - 1, c, cell); + + //handle the table row once + if (c == 0 && xPath != null) { + String rowXPath = XPathUtils.trimXPathLastTag("TR", xPath); + table.getRowXPaths().put(r, rowXPath); + } + } + } + + if (table.getRowXPaths().size() > 0) { + String rowXPath = table.getRowXPaths().get(0); + if (rowXPath == null && table.getRowXPaths().size() > 1) + rowXPath = table.getRowXPaths().get(1); + if (rowXPath == null){} + //System.out.println(); + else { + String tableXPath = XPathUtils.trimXPathLastTag("TABLE", rowXPath); + table.setTableXPath(tableXPath); + } + } + + return table; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorMusicBrainz.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorMusicBrainz.java index db6e9764..265d3476 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorMusicBrainz.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorMusicBrainz.java @@ -1,104 +1,104 @@ -package uk.ac.shef.dcs.sti.parser.table.creator; - -import cern.colt.matrix.ObjectMatrix2D; -import org.apache.any23.extractor.html.DomUtils; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import uk.ac.shef.dcs.sti.STIEnum; -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.TContext; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.core.model.TColumnHeader; -import uk.ac.shef.dcs.sti.util.XPathUtils; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 20/02/14 - * Time: 17:19 - * To change this template use File | Settings | File Templates. - */ -public class TableObjCreatorMusicBrainz implements TableObjCreator { - - @Override - public Table create(ObjectMatrix2D preTable, String tableId, String sourceId, TContext... contexts) { - Table table = new Table(tableId, sourceId, preTable.rows() - 1, preTable.columns()); - for (TContext ctx : contexts) - table.addContext(ctx); - - //firstly add the header row - for (int c = 0; c < preTable.columns(); c++) { - Object o = preTable.get(0, c); - if (o == null) { //a null value will be inserted by TableHODetector if no user defined header was found - //todo: header column type - TColumnHeader header = new TColumnHeader(STIEnum.TABLE_HEADER_UNKNOWN.getValue()); - table.setColumnHeader(c, header); - - } else { - //todo: header column type - Node e = (Node) o; - String text = e.getTextContent(); - String xPath = DomUtils.getXPathForNode(e); - - TColumnHeader header = new TColumnHeader(text); - header.setHeaderXPath(xPath); - table.setColumnHeader(c, header); - } - } - - //then go thru each other rows - for (int r = 1; r < preTable.rows(); r++) { - for (int c = 0; c < preTable.columns(); c++) { - //get url - Node e = (Node) preTable.get(r, c); - String text = ""; - String xPath = ""; - String other_text="."; - - NodeList nl = e.getChildNodes(); - for (int i = 0; i < nl.getLength(); i++) { - Node an = nl.item(i); - if (an.getNodeName().equalsIgnoreCase("A")) { - String link = an.getAttributes().getNamedItem("href").getTextContent(); - other_text+=link; - text = an.getTextContent().trim(); - xPath = DomUtils.getXPathForNode(an); - break; - } - else{ - text=e.getTextContent().trim(); - xPath=DomUtils.getXPathForNode(e); - } - - } - - - TCell cell = new TCell(text); - cell.setText(text); - cell.setOtherText(other_text); - - table.setContentCell(r - 1, c, cell); - - //handle the table row once - if (c == 0 && xPath != null) { - String rowXPath = XPathUtils.trimXPathLastTag("TR", xPath); - table.getRowXPaths().put(r, rowXPath); - } - } - } - - if (table.getRowXPaths().size() > 0) { - String rowXPath = table.getRowXPaths().get(0); - if (rowXPath == null && table.getRowXPaths().size() > 1) - rowXPath = table.getRowXPaths().get(1); - if (rowXPath == null){} - //System.out.println(); - else { - String tableXPath = XPathUtils.trimXPathLastTag("TABLE", rowXPath); - table.setTableXPath(tableXPath); - } - } - - return table; - } -} +package uk.ac.shef.dcs.sti.parser.table.creator; + +import cern.colt.matrix.ObjectMatrix2D; +import org.apache.any23.extractor.html.DomUtils; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import uk.ac.shef.dcs.sti.STIEnum; +import uk.ac.shef.dcs.sti.core.model.TCell; +import uk.ac.shef.dcs.sti.core.model.TContext; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.core.model.TColumnHeader; +import uk.ac.shef.dcs.sti.util.XPathUtils; + +/** + * Created with IntelliJ IDEA. + * User: zqz + * Date: 20/02/14 + * Time: 17:19 + * To change this template use File | Settings | File Templates. + */ +public class TableObjCreatorMusicBrainz implements TableObjCreator { + + @Override + public Table create(ObjectMatrix2D preTable, String tableId, String sourceId, TContext... contexts) { + Table table = new Table(tableId, sourceId, preTable.rows() - 1, preTable.columns()); + for (TContext ctx : contexts) + table.addContext(ctx); + + //firstly add the header row + for (int c = 0; c < preTable.columns(); c++) { + Object o = preTable.get(0, c); + if (o == null) { //a null value will be inserted by TableHODetector if no user defined header was found + //todo: header column type + TColumnHeader header = new TColumnHeader(STIEnum.TABLE_HEADER_UNKNOWN.getValue()); + table.setColumnHeader(c, header); + + } else { + //todo: header column type + Node e = (Node) o; + String text = e.getTextContent(); + String xPath = DomUtils.getXPathForNode(e); + + TColumnHeader header = new TColumnHeader(text); + header.setHeaderXPath(xPath); + table.setColumnHeader(c, header); + } + } + + //then go thru each other rows + for (int r = 1; r < preTable.rows(); r++) { + for (int c = 0; c < preTable.columns(); c++) { + //get url + Node e = (Node) preTable.get(r, c); + String text = ""; + String xPath = ""; + String other_text="."; + + NodeList nl = e.getChildNodes(); + for (int i = 0; i < nl.getLength(); i++) { + Node an = nl.item(i); + if (an.getNodeName().equalsIgnoreCase("A")) { + String link = an.getAttributes().getNamedItem("href").getTextContent(); + other_text+=link; + text = an.getTextContent().trim(); + xPath = DomUtils.getXPathForNode(an); + break; + } + else{ + text=e.getTextContent().trim(); + xPath=DomUtils.getXPathForNode(e); + } + + } + + + TCell cell = new TCell(text); + cell.setText(text); + cell.setOtherText(other_text); + + table.setContentCell(r - 1, c, cell); + + //handle the table row once + if (c == 0 && xPath != null) { + String rowXPath = XPathUtils.trimXPathLastTag("TR", xPath); + table.getRowXPaths().put(r, rowXPath); + } + } + } + + if (table.getRowXPaths().size() > 0) { + String rowXPath = table.getRowXPaths().get(0); + if (rowXPath == null && table.getRowXPaths().size() > 1) + rowXPath = table.getRowXPaths().get(1); + if (rowXPath == null){} + //System.out.println(); + else { + String tableXPath = XPathUtils.trimXPathLastTag("TABLE", rowXPath); + table.setTableXPath(tableXPath); + } + } + + return table; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorReverbnationList.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorReverbnationList.java index 3bf37d4d..ed66c8a2 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorReverbnationList.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/creator/TableObjCreatorReverbnationList.java @@ -1,112 +1,112 @@ -package uk.ac.shef.dcs.sti.parser.table.creator; - -import cern.colt.matrix.ObjectMatrix2D; -import org.apache.any23.extractor.html.DomUtils; -import org.w3c.dom.Node; -import uk.ac.shef.dcs.sti.STIEnum; -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.TColumnHeader; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.core.model.TContext; -import uk.ac.shef.dcs.sti.util.XPathUtils; - -/** - * - */ -public class TableObjCreatorReverbnationList implements TableObjCreator { - @Override - public Table create(ObjectMatrix2D preTable, String tableId, String sourceId, TContext... contexts) { - Table table = new Table(tableId, sourceId, preTable.rows() - 1, preTable.columns()); - for (TContext ctx : contexts) - table.addContext(ctx); - - //firstly add the header row - for (int c = 0; c < preTable.columns(); c++) { - Object o = preTable.get(0, c); - if (o == null) { //a null value will be inserted by TableHODetector if no user defined header was found - //todo: header column type - TColumnHeader header = new TColumnHeader(STIEnum.TABLE_HEADER_UNKNOWN.getValue()); - table.setColumnHeader(c, header); - - } else { - //todo: header column type - Node e = (Node) o; - String text = e.getTextContent(); - String xPath = DomUtils.getXPathForNode(e); - - TColumnHeader header = new TColumnHeader(text); - header.setHeaderXPath(xPath); - table.setColumnHeader(c, header); - } - } - - //then go thru each other rows - for (int r = 1; r < preTable.rows(); r++) { - for (int c = 0; c < preTable.columns(); c++) { - //get url - Node e = (Node) preTable.get(r, c); - String song = findSongNode(e); - if(song!=null){ - TCell cell = new TCell(song); - - table.setContentCell(r - 1, c, cell); - } - } - } - - if (table.getRowXPaths().size() > 0) { - String rowXPath = table.getRowXPaths().get(0); - if (rowXPath == null && table.getRowXPaths().size() > 1) - rowXPath = table.getRowXPaths().get(1); - if (rowXPath == null) { - } - //System.out.println(); - else { - String tableXPath = XPathUtils.trimXPathLastTag("TABLE", rowXPath); - table.setTableXPath(tableXPath); - } - } - - return table; - } - - private String findSongNode(Node e) { - Node div =null; - for(int i=0; i< e.getChildNodes().getLength(); i++){ - Node n = e.getChildNodes().item(i); - if(n.getNodeName().equals("DIV")){ - div=n; - break; - } - } - if(div==null) return null; - Node song =null; - for(int i=0; i 0) { + String rowXPath = table.getRowXPaths().get(0); + if (rowXPath == null && table.getRowXPaths().size() > 1) + rowXPath = table.getRowXPaths().get(1); + if (rowXPath == null) { + } + //System.out.println(); + else { + String tableXPath = XPathUtils.trimXPathLastTag("TABLE", rowXPath); + table.setTableXPath(tableXPath); + } + } + + return table; + } + + private String findSongNode(Node e) { + Node div =null; + for(int i=0; i< e.getChildNodes().getLength(); i++){ + Node n = e.getChildNodes().item(i); + if(n.getNodeName().equals("DIV")){ + div=n; + break; + } + } + if(div==null) return null; + Node song =null; + for(int i=0; i - * todo: xpaths for table cells not extracted by this class - * todo: debug this class - */ -public class TableObjCreatorWikipediaGS implements TableObjCreator { - - private boolean only_take_first_link_in_list_like_cell = false; - - public TableObjCreatorWikipediaGS(boolean only_take_first_link_in_list_like_cell) { - this.only_take_first_link_in_list_like_cell = only_take_first_link_in_list_like_cell; - } - - @Override - public Table create(ObjectMatrix2D preTable, String tableId, String sourceId, TContext... context) { - Table table = new Table(tableId, sourceId, preTable.rows() - 1, preTable.columns()); - - for (TContext ctx : context) - table.addContext(ctx); - - //firstly add the header row - for (int c = 0; c < preTable.columns(); c++) { - Object o = preTable.get(0, c); - if (o == null) { //a null value will be inserted by TableHODetector if no user defined header was found - //todo:header type - TColumnHeader header = new TColumnHeader(STIEnum.TABLE_HEADER_UNKNOWN.getValue()); - table.setColumnHeader(c, header); - } else { - Node e = (Node) o; - String text = e.getTextContent(); - String xPath = DomUtils.getXPathForNode(e); - - TColumnHeader header = new TColumnHeader(text); - header.setHeaderXPath(xPath); - - //set header text - table.setColumnHeader(c, header); - - //now check if for this header there are any annotations (i.e., links) - List annotations = new ArrayList(); - List it = DomUtils.findAllByTag(e, "A"); - if (it.size() > 0) { - for (Node ahref : it) { - if (ahref.getParentNode().getNodeName().equalsIgnoreCase("sub") || ahref.getParentNode().getNodeName().equalsIgnoreCase("sup")) - continue; - String uri = null; - try { - uri = ahref.getAttributes().getNamedItem("href").getNodeValue(); - } catch (NullPointerException n) { - } - ; - - String linkText = ahref.getTextContent(); - if (linkText.length() == 0) - continue; - - annotations.add(new TColumnHeaderAnnotation(linkText, new Clazz(uri, uri), 1.0)); - } - } - //set header annotation - table.getTableAnnotations().setHeaderAnnotation(c, annotations.toArray(new TColumnHeaderAnnotation[0])); - } - - } - - //then go thru each other rows to extract content cells - for (int r = 1; r < preTable.rows(); r++) { - for (int c = 0; c < preTable.columns(); c++) { - Node e = (Node) preTable.get(r, c); - extract(e, r, c, table); - } - } - - return table; - } - - - private void extract(Node tableCell, int r, int c, Table table) { - //todo: cell type - String cellText = getCellTextOfNode_by_links(tableCell); - - String edited = ""; - for (int i = 0; i < cellText.length(); i++) { - if (cellText.charAt(i) == 8211) { - edited += "-"; - } else { - edited += cellText.charAt(i); - } - } - cellText = edited; - - - TCell cell = new TCell(cellText); - r = r - 1; - table.setContentCell(r, c, cell); - - LinkedHashSet wikiAnnotations = new LinkedHashSet(); - //firstly always add the entire text string in this cell - List it = DomUtils.findAllByTag(tableCell, "A"); - if (it.size() > 0) { - for (Node ahref : it) { - if (ahref.getParentNode().getNodeName().equalsIgnoreCase("sub") || ahref.getParentNode().getNodeName().equalsIgnoreCase("sup")) - continue; - String uri = null; - try { - uri = ahref.getAttributes().getNamedItem("href").getNodeValue(); - } catch (NullPointerException n) { - } - ; - - String text = ahref.getTextContent(); - if (text.length() == 0) - continue; - - wikiAnnotations.add(new TCellAnnotation - (text, new Entity(uri, uri), 1.0, new HashMap())); - if (only_take_first_link_in_list_like_cell) - break; - - } - - } - - /* it = DomUtils.findAllByTag(tableCell,"LI"); - if (it.size()>0) { - for(Node listItem: it) { - String value = listItem.getTextContent(); - if(value.trim().length()>0) - texts.add(value.trim()); - } - }*/ - - table.getTableAnnotations().setContentCellAnnotations(r, c, wikiAnnotations.toArray(new TCellAnnotation[0])); - - } - - private String getCellTextOfNode_by_links(Node tableCell) { - NodeList nl = tableCell.getChildNodes(); - String concatenated_content = ""; - int multiLink = 0; - for (int i = 0; i < nl.getLength(); i++) { - Node n = nl.item(i); - if (n.getNodeName() != null && n.getNodeName().equalsIgnoreCase("A")) { - concatenated_content = concatenated_content + n.getTextContent() + "|"; - multiLink++; - }/*else if(n.getNodeName()!=null &&n.getNodeName().equalsIgnoreCase("SPAN")){ - try{ - String cl=n.getAttributes().getNamedItem("class").getTextContent(); - if(cl.equals("sortkey")){} - else - concatenated_content = n.getTextContent(); - }catch (Exception e){}; - }*/ - } - if (concatenated_content.length() == 0) { - for (int i = 0; i < nl.getLength(); i++) { - Node n = nl.item(i); - if (n.getNodeName() != null && !n.getNodeName().equalsIgnoreCase("SUP") && !n.getNodeName().equalsIgnoreCase("SUB")) { - if (n.getNodeName() != null && n.getNodeName().equalsIgnoreCase("SPAN")) { - try { - String cl = n.getAttributes().getNamedItem("class").getTextContent(); - if (cl.equals("sortkey")) { - } else - concatenated_content = n.getTextContent(); - } catch (Exception e) { - } - ; - } else { - concatenated_content = concatenated_content + n.getTextContent() + "|"; - } - } - } - } - - if (concatenated_content.endsWith("|")) - concatenated_content = concatenated_content.substring(0, concatenated_content.length() - 1).trim(); - - if (only_take_first_link_in_list_like_cell && multiLink > 1) { - //test if link structure - String cellText = tableCell.getTextContent().replaceAll("\\|", " "); -// String concatenated = concatenated_content; - String extractedText = StringUtils.toAlphaNumericWhitechar(concatenated_content); - List cellTextTokens = new ArrayList(Arrays.asList(StringUtils.toAlphaNumericWhitechar(cellText).split("\\s+"))); - List extractedTextTokens = new ArrayList(Arrays.asList(extractedText.split("\\s+"))); - extractedTextTokens.retainAll(cellTextTokens); - if (extractedTextTokens.size() / (double) cellTextTokens.size() > 0.9) { - return concatenated_content.split("\\|")[0].trim(); - } - } - - return concatenated_content.replaceAll("\\|", ", "); - } - -} +package uk.ac.shef.dcs.sti.parser.table.creator; + +import cern.colt.matrix.ObjectMatrix2D; +import org.apache.any23.extractor.html.DomUtils; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import uk.ac.shef.dcs.kbsearch.model.Clazz; +import uk.ac.shef.dcs.sti.STIEnum; +import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.sti.core.model.*; +import uk.ac.shef.dcs.util.StringUtils; + +import java.util.*; +import java.util.List; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 05/10/12 + * Time: 15:41 + *

+ * todo: xpaths for table cells not extracted by this class + * todo: debug this class + */ +public class TableObjCreatorWikipediaGS implements TableObjCreator { + + private boolean only_take_first_link_in_list_like_cell = false; + + public TableObjCreatorWikipediaGS(boolean only_take_first_link_in_list_like_cell) { + this.only_take_first_link_in_list_like_cell = only_take_first_link_in_list_like_cell; + } + + @Override + public Table create(ObjectMatrix2D preTable, String tableId, String sourceId, TContext... context) { + Table table = new Table(tableId, sourceId, preTable.rows() - 1, preTable.columns()); + + for (TContext ctx : context) + table.addContext(ctx); + + //firstly add the header row + for (int c = 0; c < preTable.columns(); c++) { + Object o = preTable.get(0, c); + if (o == null) { //a null value will be inserted by TableHODetector if no user defined header was found + //todo:header type + TColumnHeader header = new TColumnHeader(STIEnum.TABLE_HEADER_UNKNOWN.getValue()); + table.setColumnHeader(c, header); + } else { + Node e = (Node) o; + String text = e.getTextContent(); + String xPath = DomUtils.getXPathForNode(e); + + TColumnHeader header = new TColumnHeader(text); + header.setHeaderXPath(xPath); + + //set header text + table.setColumnHeader(c, header); + + //now check if for this header there are any annotations (i.e., links) + List annotations = new ArrayList(); + List it = DomUtils.findAllByTag(e, "A"); + if (it.size() > 0) { + for (Node ahref : it) { + if (ahref.getParentNode().getNodeName().equalsIgnoreCase("sub") || ahref.getParentNode().getNodeName().equalsIgnoreCase("sup")) + continue; + String uri = null; + try { + uri = ahref.getAttributes().getNamedItem("href").getNodeValue(); + } catch (NullPointerException n) { + } + ; + + String linkText = ahref.getTextContent(); + if (linkText.length() == 0) + continue; + + annotations.add(new TColumnHeaderAnnotation(linkText, new Clazz(uri, uri), 1.0)); + } + } + //set header annotation + table.getTableAnnotations().setHeaderAnnotation(c, annotations.toArray(new TColumnHeaderAnnotation[0])); + } + + } + + //then go thru each other rows to extract content cells + for (int r = 1; r < preTable.rows(); r++) { + for (int c = 0; c < preTable.columns(); c++) { + Node e = (Node) preTable.get(r, c); + extract(e, r, c, table); + } + } + + return table; + } + + + private void extract(Node tableCell, int r, int c, Table table) { + //todo: cell type + String cellText = getCellTextOfNode_by_links(tableCell); + + String edited = ""; + for (int i = 0; i < cellText.length(); i++) { + if (cellText.charAt(i) == 8211) { + edited += "-"; + } else { + edited += cellText.charAt(i); + } + } + cellText = edited; + + + TCell cell = new TCell(cellText); + r = r - 1; + table.setContentCell(r, c, cell); + + LinkedHashSet wikiAnnotations = new LinkedHashSet(); + //firstly always add the entire text string in this cell + List it = DomUtils.findAllByTag(tableCell, "A"); + if (it.size() > 0) { + for (Node ahref : it) { + if (ahref.getParentNode().getNodeName().equalsIgnoreCase("sub") || ahref.getParentNode().getNodeName().equalsIgnoreCase("sup")) + continue; + String uri = null; + try { + uri = ahref.getAttributes().getNamedItem("href").getNodeValue(); + } catch (NullPointerException n) { + } + ; + + String text = ahref.getTextContent(); + if (text.length() == 0) + continue; + + wikiAnnotations.add(new TCellAnnotation + (text, new Entity(uri, uri), 1.0, new HashMap())); + if (only_take_first_link_in_list_like_cell) + break; + + } + + } + + /* it = DomUtils.findAllByTag(tableCell,"LI"); + if (it.size()>0) { + for(Node listItem: it) { + String value = listItem.getTextContent(); + if(value.trim().length()>0) + texts.add(value.trim()); + } + }*/ + + table.getTableAnnotations().setContentCellAnnotations(r, c, wikiAnnotations.toArray(new TCellAnnotation[0])); + + } + + private String getCellTextOfNode_by_links(Node tableCell) { + NodeList nl = tableCell.getChildNodes(); + String concatenated_content = ""; + int multiLink = 0; + for (int i = 0; i < nl.getLength(); i++) { + Node n = nl.item(i); + if (n.getNodeName() != null && n.getNodeName().equalsIgnoreCase("A")) { + concatenated_content = concatenated_content + n.getTextContent() + "|"; + multiLink++; + }/*else if(n.getNodeName()!=null &&n.getNodeName().equalsIgnoreCase("SPAN")){ + try{ + String cl=n.getAttributes().getNamedItem("class").getTextContent(); + if(cl.equals("sortkey")){} + else + concatenated_content = n.getTextContent(); + }catch (Exception e){}; + }*/ + } + if (concatenated_content.length() == 0) { + for (int i = 0; i < nl.getLength(); i++) { + Node n = nl.item(i); + if (n.getNodeName() != null && !n.getNodeName().equalsIgnoreCase("SUP") && !n.getNodeName().equalsIgnoreCase("SUB")) { + if (n.getNodeName() != null && n.getNodeName().equalsIgnoreCase("SPAN")) { + try { + String cl = n.getAttributes().getNamedItem("class").getTextContent(); + if (cl.equals("sortkey")) { + } else + concatenated_content = n.getTextContent(); + } catch (Exception e) { + } + ; + } else { + concatenated_content = concatenated_content + n.getTextContent() + "|"; + } + } + } + } + + if (concatenated_content.endsWith("|")) + concatenated_content = concatenated_content.substring(0, concatenated_content.length() - 1).trim(); + + if (only_take_first_link_in_list_like_cell && multiLink > 1) { + //test if link structure + String cellText = tableCell.getTextContent().replaceAll("\\|", " "); +// String concatenated = concatenated_content; + String extractedText = StringUtils.toAlphaNumericWhitechar(concatenated_content); + List cellTextTokens = new ArrayList(Arrays.asList(StringUtils.toAlphaNumericWhitechar(cellText).split("\\s+"))); + List extractedTextTokens = new ArrayList(Arrays.asList(extractedText.split("\\s+"))); + extractedTextTokens.retainAll(cellTextTokens); + if (extractedTextTokens.size() / (double) cellTextTokens.size() > 0.9) { + return concatenated_content.split("\\|")[0].trim(); + } + } + + return concatenated_content.replaceAll("\\|", ", "); + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/hodetector/TableHODetector.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/hodetector/TableHODetector.java index 75da19a7..b4e4e0d5 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/hodetector/TableHODetector.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/hodetector/TableHODetector.java @@ -1,23 +1,23 @@ -package uk.ac.shef.dcs.sti.parser.table.hodetector; - -import cern.colt.matrix.ObjectMatrix2D; -import org.w3c.dom.Node; - -import java.util.List; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 05/10/12 - * Time: 11:56 - * - * detect table orientation and header. If table has vertical headers, transpose the table - * to create a horizontal table; if the table has no headers, create false header row and add it - * to the table elements. - * - * The algorithms for orientation and header are implemented - * together in this class because usually they are dependent - */ -public interface TableHODetector { - - ObjectMatrix2D detect(List> elements); -} +package uk.ac.shef.dcs.sti.parser.table.hodetector; + +import cern.colt.matrix.ObjectMatrix2D; +import org.w3c.dom.Node; + +import java.util.List; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 05/10/12 + * Time: 11:56 + * + * detect table orientation and header. If table has vertical headers, transpose the table + * to create a horizontal table; if the table has no headers, create false header row and add it + * to the table elements. + * + * The algorithms for orientation and header are implemented + * together in this class because usually they are dependent + */ +public interface TableHODetector { + + ObjectMatrix2D detect(List> elements); +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/hodetector/TableHODetectorByHTMLTag.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/hodetector/TableHODetectorByHTMLTag.java index aa19854a..7684b192 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/hodetector/TableHODetectorByHTMLTag.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/hodetector/TableHODetectorByHTMLTag.java @@ -1,111 +1,111 @@ -package uk.ac.shef.dcs.sti.parser.table.hodetector; - -import cern.colt.matrix.ObjectMatrix2D; -import cern.colt.matrix.impl.SparseObjectMatrix2D; -import org.w3c.dom.Node; - -import java.util.List; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 05/10/12 - * Time: 11:59 - *

- * The simplest approach that detects orientation and headers by searching for the "th" html tags in rows/columns - */ -public class TableHODetectorByHTMLTag implements TableHODetector { - - /** - * @param elements, holds Element (Jsoup) objects in its cells - * @return an ObjectMatrix2D representation of a HORIZONTAL table (vertical tables will have been transposed. - * Object in cells will be Jsoup Element. If no header row is found for this table, the first row in matrix - * will have null values in all cells - */ - @Override - public ObjectMatrix2D detect(List> elements) { - int thR = -1, thC = -1; - boolean foundTH = false; - for (int i = 0; i < elements.size(); i++) { - List row = elements.get(i); - for (int j = 0; j < row.size(); j++) { - Node cell = row.get(j); - if (!foundTH && (cell.getNodeName().equalsIgnoreCase("th")||cell.getNodeName().equalsIgnoreCase("thead"))) { - thR = i; - thC = j; - foundTH = true; - break; - } - } - if (foundTH) - break; - } - - boolean horizontalHeader = true; - - //count #of

on the thR row and the thC column - if (thR != -1 && thC != -1) { - List thRow = elements.get(thR); - int countRowTh = 0; //th on the row - for (Node e : thRow) { - if (e.getNodeName().equalsIgnoreCase("TH")||e.getNodeName().equalsIgnoreCase("THead")) - countRowTh++; - } - - int countColTh = 0; //th on the column - for (List row : elements) { - if (row.get(thC).getNodeName().equalsIgnoreCase("TH")||row.get(thC).getNodeName().equalsIgnoreCase("THead")) - countColTh++; - } - - //when there are both th in row and column - // see http://en.wikipedia.org/wiki/Italy, the determination learn is as follows: - /* - if(countRowTh == row length) - choose horizontal - */ - if (countRowTh == elements.get(0).size()) { //in rare occasions (mostly because of ill-used html tags - //you can get obscure tags in a row and # of this tags wont computeElementScores - } else if (countRowTh < countColTh) - horizontalHeader = false; - - int startRow = thR == -1 ||(countRowTh==1&& elements.get(0).size()>1)? 0 : thR; //if no th row found, or only 1 th found in the row that has more than 1 elements (likely a mis use of th) - int startCol = thC == -1 ||(countColTh==1&& elements.size()>1)? 0 : thC; - - /*if(countRowTh==1&& elements.get(0).size()>1) - System.out.print(""); - if(countColTh==1&& elements.size()>1) - System.out.print("");*/ - - ObjectMatrix2D table; - if (horizontalHeader) - table = new SparseObjectMatrix2D(elements.size() - startRow, elements.get(0).size() - startCol); - else - table = new SparseObjectMatrix2D(elements.get(0).size() - startCol, elements.size() - startRow); - - - for (int r = startRow; r < elements.size(); r++) { - for (int c = startCol; c < elements.get(0).size(); c++) { - if (horizontalHeader) - table.setQuick(r-startRow, c-startCol, elements.get(r).get(c)); - else - table.setQuick(c-startCol, r-startRow, elements.get(r).get(c)); - } - } - return table; - } else {//no "th" found, simply assume horizontal header and add a "false" header row - ObjectMatrix2D table = - new SparseObjectMatrix2D(elements.size() + 1, elements.get(0).size()); - - for (int r = 0; r < elements.size()+1; r++) { - for (int c = 0; c < elements.get(0).size(); c++) { - if (r == 0) - table.setQuick(r, c, null); - else - table.setQuick(r, c, elements.get(r-1).get(c)); - } - } - return table; - } - } - -} +package uk.ac.shef.dcs.sti.parser.table.hodetector; + +import cern.colt.matrix.ObjectMatrix2D; +import cern.colt.matrix.impl.SparseObjectMatrix2D; +import org.w3c.dom.Node; + +import java.util.List; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 05/10/12 + * Time: 11:59 + *

+ * The simplest approach that detects orientation and headers by searching for the "th" html tags in rows/columns + */ +public class TableHODetectorByHTMLTag implements TableHODetector { + + /** + * @param elements, holds Element (Jsoup) objects in its cells + * @return an ObjectMatrix2D representation of a HORIZONTAL table (vertical tables will have been transposed. + * Object in cells will be Jsoup Element. If no header row is found for this table, the first row in matrix + * will have null values in all cells + */ + @Override + public ObjectMatrix2D detect(List> elements) { + int thR = -1, thC = -1; + boolean foundTH = false; + for (int i = 0; i < elements.size(); i++) { + List row = elements.get(i); + for (int j = 0; j < row.size(); j++) { + Node cell = row.get(j); + if (!foundTH && (cell.getNodeName().equalsIgnoreCase("th")||cell.getNodeName().equalsIgnoreCase("thead"))) { + thR = i; + thC = j; + foundTH = true; + break; + } + } + if (foundTH) + break; + } + + boolean horizontalHeader = true; + + //count #of

on the thR row and the thC column + if (thR != -1 && thC != -1) { + List thRow = elements.get(thR); + int countRowTh = 0; //th on the row + for (Node e : thRow) { + if (e.getNodeName().equalsIgnoreCase("TH")||e.getNodeName().equalsIgnoreCase("THead")) + countRowTh++; + } + + int countColTh = 0; //th on the column + for (List row : elements) { + if (row.get(thC).getNodeName().equalsIgnoreCase("TH")||row.get(thC).getNodeName().equalsIgnoreCase("THead")) + countColTh++; + } + + //when there are both th in row and column + // see http://en.wikipedia.org/wiki/Italy, the determination learn is as follows: + /* + if(countRowTh == row length) + choose horizontal + */ + if (countRowTh == elements.get(0).size()) { //in rare occasions (mostly because of ill-used html tags + //you can get obscure tags in a row and # of this tags wont computeElementScores + } else if (countRowTh < countColTh) + horizontalHeader = false; + + int startRow = thR == -1 ||(countRowTh==1&& elements.get(0).size()>1)? 0 : thR; //if no th row found, or only 1 th found in the row that has more than 1 elements (likely a mis use of th) + int startCol = thC == -1 ||(countColTh==1&& elements.size()>1)? 0 : thC; + + /*if(countRowTh==1&& elements.get(0).size()>1) + System.out.print(""); + if(countColTh==1&& elements.size()>1) + System.out.print("");*/ + + ObjectMatrix2D table; + if (horizontalHeader) + table = new SparseObjectMatrix2D(elements.size() - startRow, elements.get(0).size() - startCol); + else + table = new SparseObjectMatrix2D(elements.get(0).size() - startCol, elements.size() - startRow); + + + for (int r = startRow; r < elements.size(); r++) { + for (int c = startCol; c < elements.get(0).size(); c++) { + if (horizontalHeader) + table.setQuick(r-startRow, c-startCol, elements.get(r).get(c)); + else + table.setQuick(c-startCol, r-startRow, elements.get(r).get(c)); + } + } + return table; + } else {//no "th" found, simply assume horizontal header and add a "false" header row + ObjectMatrix2D table = + new SparseObjectMatrix2D(elements.size() + 1, elements.get(0).size()); + + for (int r = 0; r < elements.size()+1; r++) { + for (int c = 0; c < elements.get(0).size(); c++) { + if (r == 0) + table.setQuick(r, c, null); + else + table.setQuick(r, c, elements.get(r-1).get(c)); + } + } + return table; + } + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizer.java index f1fd8fcd..f0b0f3f7 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizer.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizer.java @@ -1,20 +1,20 @@ -package uk.ac.shef.dcs.sti.parser.table.normalizer; - -import org.w3c.dom.Node; - -import java.util.List; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 05/10/12 - * Time: 11:05 - * - * Normalizes a <table> Element (Jsoup) to a regular n x m table stored by a matrix of Elements - * (e.g., deletes spanned cols/rows) - * - */ -public interface TableNormalizer{ - - List> normalize(Node tableNode); - -} +package uk.ac.shef.dcs.sti.parser.table.normalizer; + +import org.w3c.dom.Node; + +import java.util.List; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 05/10/12 + * Time: 11:05 + * + * Normalizes a <table> Element (Jsoup) to a regular n x m table stored by a matrix of Elements + * (e.g., deletes spanned cols/rows) + * + */ +public interface TableNormalizer{ + + List> normalize(Node tableNode); + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerDiscardIrregularRows.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerDiscardIrregularRows.java index 31287aea..fcf8ac22 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerDiscardIrregularRows.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerDiscardIrregularRows.java @@ -1,119 +1,119 @@ -package uk.ac.shef.dcs.sti.parser.table.normalizer; - -import org.apache.any23.extractor.html.DomUtils; -import org.w3c.dom.Node; - -import java.util.*; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 05/10/12 - * Time: 11:31 - *

- * - if a row begins/ends with empty cells, the beginning/ending empty cells are discarded - * - if a row contains cells with rowspan/colspan, the row is discarded - * - record # of cells in rows in a row-length table - * - keep only rows that are the longest; any rows that have less than so many cells are dropped - */ -public class TableNormalizerDiscardIrregularRows implements TableNormalizer { - - private boolean validateNonSpanCells = true; - - public TableNormalizerDiscardIrregularRows(boolean validateNonSpanCells) { - this.validateNonSpanCells = validateNonSpanCells; - } - - @Override - public List> normalize(Node tableNode) { - Map numCells2Freq = new HashMap<>(); - List> elements = new ArrayList<>(); - - List rows = DomUtils.findAllByTag(tableNode, "TR"); - - for (Node element : rows) { //loop thru each row - if (element.getTextContent().length() > 0) { //if this row has content, go ahead - List row = new ArrayList<>(); - List cells = DomUtils.findAllByTag(element, "TH"); - if (cells == null || cells.size() == 0) - cells = DomUtils.findAllByTag(element, "THEAD"); - if (cells.size() == 0) - cells = DomUtils.findAllByTag(element, "TD"); - //boolean started = false; //true if the first non-empty cell is found - boolean invalid = false; //true if there is a rowspan/colspan - for (Node td : cells) { - /* if (!started && td.getTextContent().length() > 0) { //start from the first non-empty cell - started = true; - } - if (started) {*/ - if (isValidCell(td)) - row.add(td); //add this cell on this row - else { - invalid = true; - break; - } - // } - } - if (invalid) - continue; - - //add this row - if (row.size() > 0) { - elements.add(row); - Integer freq = numCells2Freq.get(row.size()); - freq = freq == null ? 0 : freq; - freq = freq + 1; - numCells2Freq.put(row.size(), freq); - } - } - } - - //find max row-length; if there is a tie, the first encountered frequency by the map iterator is selected - int maxFreq = 0, length = 0; - for (Map.Entry e : numCells2Freq.entrySet()) { - if (e.getValue() > maxFreq) { - maxFreq = e.getValue(); - length = e.getKey(); - } - } - - //filter to keep only the rows with the longest length (the length varable above) - Iterator> it = elements.iterator(); - while (it.hasNext()) { - List row = it.next(); - if (row.size() != length) - it.remove(); - } - - return elements; - } - - //check for col span or row span - public boolean isValidCell(Node cell) { - if (!validateNonSpanCells) - return true; - String colspan = null; - try { - colspan = cell.getAttributes().getNamedItem("colspan").getTextContent(); - } catch (NullPointerException n) { - } - - String rowspan = null; - try { - rowspan = cell.getAttributes().getNamedItem("rowspan").getTextContent(); - } catch (NullPointerException n) { - } - - if (colspan != null) { - if (colspan.equals("1") || colspan.equals("")) - return true; - else - return false; - } else if (rowspan != null) { - if (rowspan.equals("1") || rowspan.equals("")) - return true; - else - return false; - } else - return true; - } -} +package uk.ac.shef.dcs.sti.parser.table.normalizer; + +import org.apache.any23.extractor.html.DomUtils; +import org.w3c.dom.Node; + +import java.util.*; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 05/10/12 + * Time: 11:31 + *

+ * - if a row begins/ends with empty cells, the beginning/ending empty cells are discarded + * - if a row contains cells with rowspan/colspan, the row is discarded + * - record # of cells in rows in a row-length table + * - keep only rows that are the longest; any rows that have less than so many cells are dropped + */ +public class TableNormalizerDiscardIrregularRows implements TableNormalizer { + + private boolean validateNonSpanCells = true; + + public TableNormalizerDiscardIrregularRows(boolean validateNonSpanCells) { + this.validateNonSpanCells = validateNonSpanCells; + } + + @Override + public List> normalize(Node tableNode) { + Map numCells2Freq = new HashMap<>(); + List> elements = new ArrayList<>(); + + List rows = DomUtils.findAllByTag(tableNode, "TR"); + + for (Node element : rows) { //loop thru each row + if (element.getTextContent().length() > 0) { //if this row has content, go ahead + List row = new ArrayList<>(); + List cells = DomUtils.findAllByTag(element, "TH"); + if (cells == null || cells.size() == 0) + cells = DomUtils.findAllByTag(element, "THEAD"); + if (cells.size() == 0) + cells = DomUtils.findAllByTag(element, "TD"); + //boolean started = false; //true if the first non-empty cell is found + boolean invalid = false; //true if there is a rowspan/colspan + for (Node td : cells) { + /* if (!started && td.getTextContent().length() > 0) { //start from the first non-empty cell + started = true; + } + if (started) {*/ + if (isValidCell(td)) + row.add(td); //add this cell on this row + else { + invalid = true; + break; + } + // } + } + if (invalid) + continue; + + //add this row + if (row.size() > 0) { + elements.add(row); + Integer freq = numCells2Freq.get(row.size()); + freq = freq == null ? 0 : freq; + freq = freq + 1; + numCells2Freq.put(row.size(), freq); + } + } + } + + //find max row-length; if there is a tie, the first encountered frequency by the map iterator is selected + int maxFreq = 0, length = 0; + for (Map.Entry e : numCells2Freq.entrySet()) { + if (e.getValue() > maxFreq) { + maxFreq = e.getValue(); + length = e.getKey(); + } + } + + //filter to keep only the rows with the longest length (the length varable above) + Iterator> it = elements.iterator(); + while (it.hasNext()) { + List row = it.next(); + if (row.size() != length) + it.remove(); + } + + return elements; + } + + //check for col span or row span + public boolean isValidCell(Node cell) { + if (!validateNonSpanCells) + return true; + String colspan = null; + try { + colspan = cell.getAttributes().getNamedItem("colspan").getTextContent(); + } catch (NullPointerException n) { + } + + String rowspan = null; + try { + rowspan = cell.getAttributes().getNamedItem("rowspan").getTextContent(); + } catch (NullPointerException n) { + } + + if (colspan != null) { + if (colspan.equals("1") || colspan.equals("")) + return true; + else + return false; + } else if (rowspan != null) { + if (rowspan.equals("1") || rowspan.equals("")) + return true; + else + return false; + } else + return true; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerListTransformer.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerListTransformer.java index 840dd9d0..687b49fc 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerListTransformer.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerListTransformer.java @@ -1,30 +1,30 @@ -package uk.ac.shef.dcs.sti.parser.table.normalizer; - -import org.apache.any23.extractor.html.DomUtils; -import org.w3c.dom.Node; - -import java.util.ArrayList; -import java.util.List; - -/** - * transforms a Node that embeds a list structure to a representation of table structure - */ -public class TableNormalizerListTransformer implements TableNormalizer { - - @Override - public List> normalize(Node listNode) { - List> elements = new ArrayList<>(); - - List lis = DomUtils.findAllByTag(listNode, "LI"); - - for (Node element : lis) { //loop thru each row - if (element.getTextContent().length() > 0) { //if this row has content, go ahead - List row = new ArrayList<>(); - row.add(element); - elements.add(row); - boolean hasTH = false; - } - } - return elements; - } -} +package uk.ac.shef.dcs.sti.parser.table.normalizer; + +import org.apache.any23.extractor.html.DomUtils; +import org.w3c.dom.Node; + +import java.util.ArrayList; +import java.util.List; + +/** + * transforms a Node that embeds a list structure to a representation of table structure + */ +public class TableNormalizerListTransformer implements TableNormalizer { + + @Override + public List> normalize(Node listNode) { + List> elements = new ArrayList<>(); + + List lis = DomUtils.findAllByTag(listNode, "LI"); + + for (Node element : lis) { //loop thru each row + if (element.getTextContent().length() > 0) { //if this row has content, go ahead + List row = new ArrayList<>(); + row.add(element); + elements.add(row); + boolean hasTH = false; + } + } + return elements; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerSimple.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerSimple.java index d139b2d7..56ee015b 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerSimple.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/normalizer/TableNormalizerSimple.java @@ -1,80 +1,80 @@ -package uk.ac.shef.dcs.sti.parser.table.normalizer; - -import org.apache.any23.extractor.html.DomUtils; -import org.w3c.dom.Node; - -import java.util.*; - -/** - * simply transforms a table structure Node to a representation required - */ -public class TableNormalizerSimple implements TableNormalizer { - @Override - public List> normalize(Node tableNode) { - List> elements = new ArrayList<>(); - - List rows = DomUtils.findAllByTag(tableNode, "TR"); - - for (Node element : rows) { //loop thru each row - if (element.getTextContent().length() > 0) { //if this row has content, go ahead - List row = new ArrayList<>(); - List cells = DomUtils.findAllByTag(element, "TH"); - if (cells == null || cells.size() == 0) - cells = DomUtils.findAllByTag(element, "THEAD"); - if (cells.size() == 0) - cells = DomUtils.findAllByTag(element, "TD"); - - boolean started = false; //true if the first non-empty cell is found - boolean invalid = false; //true if there is a rowspan/colspan - for (Node td : cells) { - if (!started && td.getTextContent().length() > 0) { //start from the first non-empty cell - started = true; - } - if (started) { - if (isValidCell(td)) - row.add(td); //add this cell on this row - else { - invalid = true; - break; - } - } - } - if (invalid) - continue; - - //add this row - if (row.size() > 0) { - elements.add(row); - } - } - } - return elements; - } - - public static boolean isValidCell(Node cell) { - String colspan = null; - try { - colspan = cell.getAttributes().getNamedItem("colspan").getTextContent(); - } catch (NullPointerException n) { - } - - String rowspan = null; - try { - rowspan = cell.getAttributes().getNamedItem("rowspan").getTextContent(); - } catch (NullPointerException n) { - } - - if (colspan != null) { - if (colspan.equals("1") || colspan.equals("")) - return true; - else - return false; - } else if (rowspan != null) { - if (rowspan.equals("1") || rowspan.equals("")) - return true; - else - return false; - } else - return true; - } -} +package uk.ac.shef.dcs.sti.parser.table.normalizer; + +import org.apache.any23.extractor.html.DomUtils; +import org.w3c.dom.Node; + +import java.util.*; + +/** + * simply transforms a table structure Node to a representation required + */ +public class TableNormalizerSimple implements TableNormalizer { + @Override + public List> normalize(Node tableNode) { + List> elements = new ArrayList<>(); + + List rows = DomUtils.findAllByTag(tableNode, "TR"); + + for (Node element : rows) { //loop thru each row + if (element.getTextContent().length() > 0) { //if this row has content, go ahead + List row = new ArrayList<>(); + List cells = DomUtils.findAllByTag(element, "TH"); + if (cells == null || cells.size() == 0) + cells = DomUtils.findAllByTag(element, "THEAD"); + if (cells.size() == 0) + cells = DomUtils.findAllByTag(element, "TD"); + + boolean started = false; //true if the first non-empty cell is found + boolean invalid = false; //true if there is a rowspan/colspan + for (Node td : cells) { + if (!started && td.getTextContent().length() > 0) { //start from the first non-empty cell + started = true; + } + if (started) { + if (isValidCell(td)) + row.add(td); //add this cell on this row + else { + invalid = true; + break; + } + } + } + if (invalid) + continue; + + //add this row + if (row.size() > 0) { + elements.add(row); + } + } + } + return elements; + } + + public static boolean isValidCell(Node cell) { + String colspan = null; + try { + colspan = cell.getAttributes().getNamedItem("colspan").getTextContent(); + } catch (NullPointerException n) { + } + + String rowspan = null; + try { + rowspan = cell.getAttributes().getNamedItem("rowspan").getTextContent(); + } catch (NullPointerException n) { + } + + if (colspan != null) { + if (colspan.equals("1") || colspan.equals("")) + return true; + else + return false; + } else if (rowspan != null) { + if (rowspan.equals("1") || rowspan.equals("")) + return true; + else + return false; + } else + return true; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidator.java index 952bb8d3..de401c5f 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidator.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidator.java @@ -1,13 +1,13 @@ -package uk.ac.shef.dcs.sti.parser.table.validator; - -import uk.ac.shef.dcs.sti.core.model.Table; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 08/10/12 - * Time: 13:10 - */ -public interface TableValidator { - - boolean validate(Table table); -} +package uk.ac.shef.dcs.sti.parser.table.validator; + +import uk.ac.shef.dcs.sti.core.model.Table; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 08/10/12 + * Time: 13:10 + */ +public interface TableValidator { + + boolean validate(Table table); +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorForWikipediaGSLanient.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorForWikipediaGSLanient.java index e36f42f8..630f27df 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorForWikipediaGSLanient.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorForWikipediaGSLanient.java @@ -1,81 +1,81 @@ -package uk.ac.shef.dcs.sti.parser.table.validator; - -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.Table; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 08/10/12 - * Time: 13:23 - *

- * Lanient rules: - *

- * -min rows rule: at least X data rows (excl. header) - * -min colums rule: at least X columns - * -empty cell rule: more than X% of cells must be NON-empty - * \t a cell is empty if: the text within has length 0 - * \t the text is embedded by {{}}, a MediaWiki syntax meaning empty or undefined - * \t the text has no english letter or numbers - * -proper data columns rule: at least X columns are "proper" data - * \t a cell is a "proper" data cell if it is NOT lengthy or numeric - * \t a column is a proper column if over X% of cells are not lengthy or numeric - * \t a cell is lengthy if: 1)for multi-valued cell, there are more than X value items - * \t 2)>50% of each single value in the multi-valued-cell has more than X tokens - * \t 3)the extracted text from the cell is longer than the max allowed, which is calculated as - * \t #of-items-in-multivalued-cell * max-allowed-tokens-per-item (see above, 2) - * \t a cell is numeric if: 1)the text has no letter and 2)over 50% of chars in the text (excl. white space) are digits - * -non-lengthy-table rule: (apart from the above), no more than X% of cells are "lengthy" - * Additionally, a warning is issued when a multi-valued cell is found - */ -public class TableValidatorForWikipediaGSLanient extends TableValidatorGeneric { - - protected final static int THRESHOLD_MIN_ROWS = 3; - protected final static int THRESHOLD_MIN_COLS = 2; - - protected final static double THRESHOLD_MAX_EMPTY_CELLS_IN_COLUMNS = 0.5; - - protected final static int THRESHOLD_MIN_PROPER_DATA_COLUMNS = 2;//minimum # of "proper" data columns to keep a table - protected final static double THRESHOLD_MAX_LENGTHY_CELLS_IN_COLUMN = 0.5; //50% of all elements in a column are "lengthy" then this column is lengthy - protected final static double THRESHOLD_MAX_NUMERIC_CELLS_IN_COLUMN = 0.5; //similar as above - - protected final static double THRESHOLD_MAX_LENGHTY_CELLS_IN_TABLE = 0.5; //% of lengthy cells allowed in a "valid" table - - - - @Override - public boolean validate(Table table) { - int countEmpty = 0, countLengthy = 0; - int countLengthyColumns = 0, countNumericColumns = 0; - - for (int c = 0; c < table.getNumCols(); c++) { - for (int r = 0; r < table.getNumRows(); r++) { - TCell ltc =table.getContentCell(r, c); - String tcText = ltc.getText(); - if (isEmptyMediaWikiString(tcText)) - countEmpty++; - } - - } - if (table.getNumRows() < THRESHOLD_MIN_ROWS) - return false; - if (table.getNumCols() < THRESHOLD_MIN_COLS) - return false; - if (countEmpty > table.size() * THRESHOLD_MAX_LENGHTY_CELLS_IN_TABLE) - return false; - - if (table.getNumCols() - (countLengthyColumns + countNumericColumns) < THRESHOLD_MIN_PROPER_DATA_COLUMNS) - return false; - - if (countLengthy > table.size() * THRESHOLD_MAX_LENGHTY_CELLS_IN_TABLE) - return false; - return true; - } - - protected boolean isLengthyCell(TCell tc) { - int textLength = tc.getText().split("\\s+").length; - return textLength > THRESHOLD_LENGTHY_CELL_MAXSINGLEVALUELENGTH; - } - - - -} +package uk.ac.shef.dcs.sti.parser.table.validator; + +import uk.ac.shef.dcs.sti.core.model.TCell; +import uk.ac.shef.dcs.sti.core.model.Table; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 08/10/12 + * Time: 13:23 + *

+ * Lanient rules: + *

+ * -min rows rule: at least X data rows (excl. header) + * -min colums rule: at least X columns + * -empty cell rule: more than X% of cells must be NON-empty + * \t a cell is empty if: the text within has length 0 + * \t the text is embedded by {{}}, a MediaWiki syntax meaning empty or undefined + * \t the text has no english letter or numbers + * -proper data columns rule: at least X columns are "proper" data + * \t a cell is a "proper" data cell if it is NOT lengthy or numeric + * \t a column is a proper column if over X% of cells are not lengthy or numeric + * \t a cell is lengthy if: 1)for multi-valued cell, there are more than X value items + * \t 2)>50% of each single value in the multi-valued-cell has more than X tokens + * \t 3)the extracted text from the cell is longer than the max allowed, which is calculated as + * \t #of-items-in-multivalued-cell * max-allowed-tokens-per-item (see above, 2) + * \t a cell is numeric if: 1)the text has no letter and 2)over 50% of chars in the text (excl. white space) are digits + * -non-lengthy-table rule: (apart from the above), no more than X% of cells are "lengthy" + * Additionally, a warning is issued when a multi-valued cell is found + */ +public class TableValidatorForWikipediaGSLanient extends TableValidatorGeneric { + + protected final static int THRESHOLD_MIN_ROWS = 3; + protected final static int THRESHOLD_MIN_COLS = 2; + + protected final static double THRESHOLD_MAX_EMPTY_CELLS_IN_COLUMNS = 0.5; + + protected final static int THRESHOLD_MIN_PROPER_DATA_COLUMNS = 2;//minimum # of "proper" data columns to keep a table + protected final static double THRESHOLD_MAX_LENGTHY_CELLS_IN_COLUMN = 0.5; //50% of all elements in a column are "lengthy" then this column is lengthy + protected final static double THRESHOLD_MAX_NUMERIC_CELLS_IN_COLUMN = 0.5; //similar as above + + protected final static double THRESHOLD_MAX_LENGHTY_CELLS_IN_TABLE = 0.5; //% of lengthy cells allowed in a "valid" table + + + + @Override + public boolean validate(Table table) { + int countEmpty = 0, countLengthy = 0; + int countLengthyColumns = 0, countNumericColumns = 0; + + for (int c = 0; c < table.getNumCols(); c++) { + for (int r = 0; r < table.getNumRows(); r++) { + TCell ltc =table.getContentCell(r, c); + String tcText = ltc.getText(); + if (isEmptyMediaWikiString(tcText)) + countEmpty++; + } + + } + if (table.getNumRows() < THRESHOLD_MIN_ROWS) + return false; + if (table.getNumCols() < THRESHOLD_MIN_COLS) + return false; + if (countEmpty > table.size() * THRESHOLD_MAX_LENGHTY_CELLS_IN_TABLE) + return false; + + if (table.getNumCols() - (countLengthyColumns + countNumericColumns) < THRESHOLD_MIN_PROPER_DATA_COLUMNS) + return false; + + if (countLengthy > table.size() * THRESHOLD_MAX_LENGHTY_CELLS_IN_TABLE) + return false; + return true; + } + + protected boolean isLengthyCell(TCell tc) { + int textLength = tc.getText().split("\\s+").length; + return textLength > THRESHOLD_LENGTHY_CELL_MAXSINGLEVALUELENGTH; + } + + + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorForWikipediaGSStrict.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorForWikipediaGSStrict.java index a8f6f8e5..8d0e3095 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorForWikipediaGSStrict.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorForWikipediaGSStrict.java @@ -1,104 +1,104 @@ -package uk.ac.shef.dcs.sti.parser.table.validator; - -import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.Table; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 10/10/12 - * Time: 12:06 - *

- * implements following policies: - * - Must have no more than 1 empty columns (a column is empty if over 20% of cells are empty) - * - Must have no more than 1 lengthy columns (a column is lengthy if it has more than 10% cells lengthy(more than 5 words, or a multi-valued item)) - * - Must have at least two columns that have over 50% with URIs - * - Must have at least 2 columns and over 50% of columns satisfying all above conditions (excl. numeric columns) - * - Must have at least 3 data rows - */ -public class TableValidatorForWikipediaGSStrict extends TableValidatorGeneric { - protected static final int THRESHOLD_MIN_COLUMNS_WITH_URIS = 2; - protected static final double THRESHOLD_MIN_FRAC_URICOLUMNS = 0.4; - - protected static final int THRESHOLD_MIN_PROPER_DATA_COLUMNS = 2; - protected static final double THRESHOLD_MIN_PROPER_DATA_COLUMNS_FRAC = 0.5; - protected static final int THRESHOLD_MIN_PROPER_DATA_ROWS = 3; - - - public TableValidatorForWikipediaGSStrict() { - } - - - @Override - public boolean validate(Table table) { - int countEmptyColumns = 0, countLengthyColumns = 0, countNumericColumns = 0, countURIGSColumns = 0; - - - if (table.getNumRows() < THRESHOLD_MIN_PROPER_DATA_ROWS) - return false; - - for (int c = 0; c < table.getNumCols(); c++) { - int countLengthyPerCol = 0, countNumericPerCol = 0, countEmptyPerCol = 0, countURIGSPerCol = 0; - - for (int r = 0; r < table.getNumRows(); r++) { - TCell ltc = (TCell) table.getContentCell(r, c); - String tcText = ltc.getText(); - TCellAnnotation[] annotations = table.getTableAnnotations().getContentCellAnnotations(r, c); - if (annotations.length > 0) { - String uri = annotations[0].getAnnotation().getId(); - if (isWikiInternalLink(uri)) { - - countURIGSPerCol++; - } - } - - if (isEmptyMediaWikiString(tcText)) { - countEmptyPerCol++; - } - if (isLengthyCell(ltc)) { - countLengthyPerCol++; - } - - if (isNumericContent(tcText)) { - countNumericPerCol++; - } - } - - /*if (countEmptyPerCol > matrix.rows() * THRESHOLD_MAX_ALLOWED_EMPTY_CELLS_IN_COLUMN) { - countEmptyColumns++; - table.setColumnDataType(Table.TColumnDataType.EMPTY, c); - } - if (countLengthyPerCol > matrix.rows() * THRESHOLD_MAX_ALLOWED_LENGTHY_CELLS_IN_COLUMN) { - countLengthyColumns++; - table.setColumnDataType(Table.TColumnDataType.LONGTEXT, c); - } - if (countNumericPerCol > matrix.rows() * THRESHOLD_MAX_ALLOWED_NUMERIC_CELLS_IN_COLUMN) { - countNumericColumns++; - table.setColumnDataType(Table.TColumnDataType.NUMERIC, c); - } - if (countURIGSPerCol > matrix.rows() * THRESHOLD_MIN_FRAC_CELLS_WITH_URIS_IN_COLUMN) { - countURIGSColumns++; - table.setColumnDataType(Table.TColumnDataType.LINK, c); - }*/ - - } - int properDataColumns = table.getNumCols() - (countLengthyColumns + countNumericColumns + countEmptyColumns); - if (countURIGSColumns < THRESHOLD_MIN_COLUMNS_WITH_URIS || - countURIGSColumns < THRESHOLD_MIN_FRAC_URICOLUMNS * table.getNumCols()) - return false; - - if (properDataColumns < THRESHOLD_MIN_PROPER_DATA_COLUMNS) - return false; - if (properDataColumns < table.getNumRows() * THRESHOLD_MIN_PROPER_DATA_COLUMNS_FRAC) - return false; - if (properDataColumns < countLengthyColumns || properDataColumns < countNumericColumns || properDataColumns < countEmptyColumns) - return false; //too many lengthy/numeric/empty columns wrt proper columns - if (countEmptyColumns > 1) - return false; - if (countLengthyColumns > 1) - return false; - - return true; - } - -} +package uk.ac.shef.dcs.sti.parser.table.validator; + +import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; +import uk.ac.shef.dcs.sti.core.model.TCell; +import uk.ac.shef.dcs.sti.core.model.Table; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 10/10/12 + * Time: 12:06 + *

+ * implements following policies: + * - Must have no more than 1 empty columns (a column is empty if over 20% of cells are empty) + * - Must have no more than 1 lengthy columns (a column is lengthy if it has more than 10% cells lengthy(more than 5 words, or a multi-valued item)) + * - Must have at least two columns that have over 50% with URIs + * - Must have at least 2 columns and over 50% of columns satisfying all above conditions (excl. numeric columns) + * - Must have at least 3 data rows + */ +public class TableValidatorForWikipediaGSStrict extends TableValidatorGeneric { + protected static final int THRESHOLD_MIN_COLUMNS_WITH_URIS = 2; + protected static final double THRESHOLD_MIN_FRAC_URICOLUMNS = 0.4; + + protected static final int THRESHOLD_MIN_PROPER_DATA_COLUMNS = 2; + protected static final double THRESHOLD_MIN_PROPER_DATA_COLUMNS_FRAC = 0.5; + protected static final int THRESHOLD_MIN_PROPER_DATA_ROWS = 3; + + + public TableValidatorForWikipediaGSStrict() { + } + + + @Override + public boolean validate(Table table) { + int countEmptyColumns = 0, countLengthyColumns = 0, countNumericColumns = 0, countURIGSColumns = 0; + + + if (table.getNumRows() < THRESHOLD_MIN_PROPER_DATA_ROWS) + return false; + + for (int c = 0; c < table.getNumCols(); c++) { + int countLengthyPerCol = 0, countNumericPerCol = 0, countEmptyPerCol = 0, countURIGSPerCol = 0; + + for (int r = 0; r < table.getNumRows(); r++) { + TCell ltc = (TCell) table.getContentCell(r, c); + String tcText = ltc.getText(); + TCellAnnotation[] annotations = table.getTableAnnotations().getContentCellAnnotations(r, c); + if (annotations.length > 0) { + String uri = annotations[0].getAnnotation().getId(); + if (isWikiInternalLink(uri)) { + + countURIGSPerCol++; + } + } + + if (isEmptyMediaWikiString(tcText)) { + countEmptyPerCol++; + } + if (isLengthyCell(ltc)) { + countLengthyPerCol++; + } + + if (isNumericContent(tcText)) { + countNumericPerCol++; + } + } + + /*if (countEmptyPerCol > matrix.rows() * THRESHOLD_MAX_ALLOWED_EMPTY_CELLS_IN_COLUMN) { + countEmptyColumns++; + table.setColumnDataType(Table.TColumnDataType.EMPTY, c); + } + if (countLengthyPerCol > matrix.rows() * THRESHOLD_MAX_ALLOWED_LENGTHY_CELLS_IN_COLUMN) { + countLengthyColumns++; + table.setColumnDataType(Table.TColumnDataType.LONGTEXT, c); + } + if (countNumericPerCol > matrix.rows() * THRESHOLD_MAX_ALLOWED_NUMERIC_CELLS_IN_COLUMN) { + countNumericColumns++; + table.setColumnDataType(Table.TColumnDataType.NUMERIC, c); + } + if (countURIGSPerCol > matrix.rows() * THRESHOLD_MIN_FRAC_CELLS_WITH_URIS_IN_COLUMN) { + countURIGSColumns++; + table.setColumnDataType(Table.TColumnDataType.LINK, c); + }*/ + + } + int properDataColumns = table.getNumCols() - (countLengthyColumns + countNumericColumns + countEmptyColumns); + if (countURIGSColumns < THRESHOLD_MIN_COLUMNS_WITH_URIS || + countURIGSColumns < THRESHOLD_MIN_FRAC_URICOLUMNS * table.getNumCols()) + return false; + + if (properDataColumns < THRESHOLD_MIN_PROPER_DATA_COLUMNS) + return false; + if (properDataColumns < table.getNumRows() * THRESHOLD_MIN_PROPER_DATA_COLUMNS_FRAC) + return false; + if (properDataColumns < countLengthyColumns || properDataColumns < countNumericColumns || properDataColumns < countEmptyColumns) + return false; //too many lengthy/numeric/empty columns wrt proper columns + if (countEmptyColumns > 1) + return false; + if (countLengthyColumns > 1) + return false; + + return true; + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorGeneric.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorGeneric.java index 79eb5592..939b6872 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorGeneric.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/parser/table/validator/TableValidatorGeneric.java @@ -1,107 +1,107 @@ -package uk.ac.shef.dcs.sti.parser.table.validator; - -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.parser.ContentValidator; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 26/10/12 - * Time: 10:47 - * implements following policies: - * - Must have no more than 1 empty columns (a column is empty if over 20% of cells are empty) - * - Must have no more than 1 lengthy columns (a column is lengthy if it has more than 10% cells lengthy(more than 5 words, or a multi-valued item)) - * - Must have no more than 1 link columns - * - Must have at least 2 columns and over 50% of columns satisfying all above conditions (excl. numeric columns) - * - Must have at least 3 data rows - */ -public class TableValidatorGeneric extends ContentValidator implements TableValidator { - protected static final double THRESHOLD_MAX_ALLOWED_EMPTY_CELLS_IN_COLUMN = 0.2; - protected static final double THRESHOLD_MAX_ALLOWED_LENGTHY_CELLS_IN_COLUMN = 0.1; - protected static final double THRESHOLD_MAX_ALLOWED_NUMERIC_CELLS_IN_COLUMN = 0.1; - - protected static final int THRESHOLD_MIN_PROPER_DATA_ROWS = 3; - - protected static final double THRESHOLD_MAX_ALLOWED_LINK_CELLS_IN_COLUMN = 0.1; - - protected static final int THRESHOLD_LENGTHY_CELL_MAXSINGLEVALUELENGTH = 5; //max # of tokens in a single cell VALUE (ie. - // if there are multi. links/lists in a cell, this is for each of them AND the entire text cell length cannot be - // longer than [# of links] * this value - - public TableValidatorGeneric() { - } - - - @Override - public boolean validate(Table table) { - - if (table.getNumRows() < THRESHOLD_MIN_PROPER_DATA_ROWS) - return false; - - return true; - } - - protected boolean isLengthyCell(TCell tc) { - int textLength = tc.getText().split("\\s+").length; - return textLength > TableValidatorForWikipediaGSLanient.THRESHOLD_LENGTHY_CELL_MAXSINGLEVALUELENGTH; - } - - protected boolean tooManyLengthyCellsInColumn(TCell[] cells) { - int countLengthyPerCol = 0; - for (TCell ltc : cells) { - if (isLengthyCell(ltc)) { - countLengthyPerCol++; - } - } - return countLengthyPerCol > cells.length * THRESHOLD_MAX_ALLOWED_LENGTHY_CELLS_IN_COLUMN; - } - - protected boolean hasLengthyCellsInColumn(TCell[] cells) { - for (TCell ltc : cells) { - if (isLengthyCell(ltc)) { - return true; - } - } - return false; - } - - protected boolean tooManyEmptyCellsInColumn(TCell[] cells) { - int countEmptyPerCol = 0; - for (TCell ltc : cells) { - if (isEmptyString(ltc.getText())) { - countEmptyPerCol++; - } - } - return countEmptyPerCol > cells.length * THRESHOLD_MAX_ALLOWED_EMPTY_CELLS_IN_COLUMN; - } - - protected boolean hasEmptyCellsInColumn(TCell[] cells) { - - for (TCell ltc : cells) { - if (isEmptyString(ltc.getText())) { - return true; - } - } - return false; - } - - protected boolean tooManyNumericCellsInColumn(TCell[] cells) { - int countNumericPerCol = 0; - for (TCell ltc : cells) { - if (isNumericContent(ltc.getText())) { - countNumericPerCol++; - } - } - return countNumericPerCol > cells.length * THRESHOLD_MAX_ALLOWED_NUMERIC_CELLS_IN_COLUMN; - } - - protected boolean hasNumericCellsInColumn(TCell[] cells) { - for (TCell ltc : cells) { - if (isNumericContent(ltc.getText())) { - return true; - } - } - return false; - } - -} +package uk.ac.shef.dcs.sti.parser.table.validator; + +import uk.ac.shef.dcs.sti.core.model.TCell; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.parser.ContentValidator; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 26/10/12 + * Time: 10:47 + * implements following policies: + * - Must have no more than 1 empty columns (a column is empty if over 20% of cells are empty) + * - Must have no more than 1 lengthy columns (a column is lengthy if it has more than 10% cells lengthy(more than 5 words, or a multi-valued item)) + * - Must have no more than 1 link columns + * - Must have at least 2 columns and over 50% of columns satisfying all above conditions (excl. numeric columns) + * - Must have at least 3 data rows + */ +public class TableValidatorGeneric extends ContentValidator implements TableValidator { + protected static final double THRESHOLD_MAX_ALLOWED_EMPTY_CELLS_IN_COLUMN = 0.2; + protected static final double THRESHOLD_MAX_ALLOWED_LENGTHY_CELLS_IN_COLUMN = 0.1; + protected static final double THRESHOLD_MAX_ALLOWED_NUMERIC_CELLS_IN_COLUMN = 0.1; + + protected static final int THRESHOLD_MIN_PROPER_DATA_ROWS = 3; + + protected static final double THRESHOLD_MAX_ALLOWED_LINK_CELLS_IN_COLUMN = 0.1; + + protected static final int THRESHOLD_LENGTHY_CELL_MAXSINGLEVALUELENGTH = 5; //max # of tokens in a single cell VALUE (ie. + // if there are multi. links/lists in a cell, this is for each of them AND the entire text cell length cannot be + // longer than [# of links] * this value + + public TableValidatorGeneric() { + } + + + @Override + public boolean validate(Table table) { + + if (table.getNumRows() < THRESHOLD_MIN_PROPER_DATA_ROWS) + return false; + + return true; + } + + protected boolean isLengthyCell(TCell tc) { + int textLength = tc.getText().split("\\s+").length; + return textLength > TableValidatorForWikipediaGSLanient.THRESHOLD_LENGTHY_CELL_MAXSINGLEVALUELENGTH; + } + + protected boolean tooManyLengthyCellsInColumn(TCell[] cells) { + int countLengthyPerCol = 0; + for (TCell ltc : cells) { + if (isLengthyCell(ltc)) { + countLengthyPerCol++; + } + } + return countLengthyPerCol > cells.length * THRESHOLD_MAX_ALLOWED_LENGTHY_CELLS_IN_COLUMN; + } + + protected boolean hasLengthyCellsInColumn(TCell[] cells) { + for (TCell ltc : cells) { + if (isLengthyCell(ltc)) { + return true; + } + } + return false; + } + + protected boolean tooManyEmptyCellsInColumn(TCell[] cells) { + int countEmptyPerCol = 0; + for (TCell ltc : cells) { + if (isEmptyString(ltc.getText())) { + countEmptyPerCol++; + } + } + return countEmptyPerCol > cells.length * THRESHOLD_MAX_ALLOWED_EMPTY_CELLS_IN_COLUMN; + } + + protected boolean hasEmptyCellsInColumn(TCell[] cells) { + + for (TCell ltc : cells) { + if (isEmptyString(ltc.getText())) { + return true; + } + } + return false; + } + + protected boolean tooManyNumericCellsInColumn(TCell[] cells) { + int countNumericPerCol = 0; + for (TCell ltc : cells) { + if (isNumericContent(ltc.getText())) { + countNumericPerCol++; + } + } + return countNumericPerCol > cells.length * THRESHOLD_MAX_ALLOWED_NUMERIC_CELLS_IN_COLUMN; + } + + protected boolean hasNumericCellsInColumn(TCell[] cells) { + for (TCell ltc : cells) { + if (isNumericContent(ltc.getText())) { + return true; + } + } + return false; + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/TAnnotationKeyFileReader.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/TAnnotationKeyFileReader.java index 366612b3..439ee4a2 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/TAnnotationKeyFileReader.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/TAnnotationKeyFileReader.java @@ -1,228 +1,228 @@ -package uk.ac.shef.dcs.sti.todo; - -import uk.ac.shef.dcs.sti.util.FileUtils; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - */ -public class TAnnotationKeyFileReader { - public static Map>> readHeaderAnnotation(String keyfile, boolean isGS, boolean gs_NE_only) throws IOException { - Map>> result = new HashMap>>(); - if (!new File(keyfile).exists()) - return result; - - List lines = FileUtils.readList(keyfile, false); - for (String l : lines) { - if (l.contains("|") && isGS) - System.err.println("error line:" + l); - if (isGS && gs_NE_only && !l.endsWith("___NE")) - continue; - - if (l.endsWith("___NE")) { - l = l.substring(0, l.indexOf("___NE")).trim(); - } - String[] col_annotations = l.split("=", 2); - if (col_annotations.length < 2) - continue; - - int col = Integer.valueOf(col_annotations[0]); - String annotations = col_annotations[1]; - List> anns = new ArrayList>(); - String[] parts; - if (isGS) - parts = annotations.split("\t"); - else - parts = annotations.split("\\|"); - for (String a : parts) { - a = a.trim(); - if (a.length() > 0 && !a.startsWith("/")) - System.out.println(); - if (a.startsWith("//")) - System.out.println(); - if (a.length() > 0) { - if (a.indexOf("=") == -1) { - List list = new ArrayList(); - list.add(a); - anns.add(list); - } else { - List equal_weights = new ArrayList(); - for (String e : a.split("=")) { - e = e.trim(); - if (e.split("/").length > 5) - System.out.println(); - if (e.length() > 0 && !e.startsWith("/")) - System.out.println(); - if (e.length() > 0) - equal_weights.add(e); - } - anns.add(equal_weights); - } - } - } - result.put(col, anns); - } - return result; - } - - - public static Map>> readColumnBinaryRelationAnnotation_GS(String keyfile, - List main, - List tolerant) throws IOException { - Map>> result = new HashMap>>(); - if (!new File(keyfile).exists()) - return result; - - List lines = FileUtils.readList(keyfile, false); - for (String l : lines) { - String[] pos_annotations = l.split("=", 2); - if (pos_annotations.length < 2) - continue; - - String pos = pos_annotations[0].trim(); - if (pos.contains(";")) { - String[] parts = pos.split(";"); - String first = parts[0].trim(); - if(first.startsWith("-")){ - first=first.substring(1).trim(); - tolerant.add(first); - }else{ - main.add(first); - } - pos=first; - } - else{ - main.add(pos); - } - - String[] pos_ = pos.split(","); - if (pos_.length < 2) continue; - int mainCol = Integer.valueOf(pos_[0].trim()); - int otherCol = Integer.valueOf(pos_[1].trim()); - - String annotations = pos_annotations[1]; - List> anns = new ArrayList>(); - String[] parts = null; - - parts = annotations.split("\t"); - - for (String a : parts) { - a = a.trim(); - if (a.length() > 0 && !a.startsWith("/")) - System.out.println(); - if (a.startsWith("//")) - System.out.println(); - - if (a.length() > 0) { - if (a.indexOf("=") == -1) { - List list = new ArrayList(); - list.add(a); - anns.add(list); - } else { - List equal_weights = new ArrayList(); - for (String e : a.split("=")) { - e = e.trim(); - if (e.split("/").length > 4) - System.out.println(); - if (e.length() > 0 && !e.startsWith("/")) - System.out.println(); - if (e.length() > 0) - equal_weights.add(e); - } - anns.add(equal_weights); - } - } - } - result.put(new int[]{mainCol, otherCol}, anns); - } - return result; - } - - public static Map>> readColumnBinaryRelationAnnotation_CP(String keyfile) throws IOException { - Map>> result = new HashMap>>(); - if (!new File(keyfile).exists()) - return result; - - List lines = FileUtils.readList(keyfile, false); - for (String l : lines) { - String[] pos_annotations = l.split("=", 2); - if (pos_annotations.length < 2) - continue; - - String pos = pos_annotations[0]; - String[] pos_ = pos.split(","); - if (pos_.length < 2) continue; - int mainCol = Integer.valueOf(pos_[0].trim()); - int otherCol = Integer.valueOf(pos_[1].trim()); - - String annotations = pos_annotations[1]; - List> anns = new ArrayList>(); - String[] parts= annotations.split("\\|"); - for (String a : parts) { - a = a.trim(); - if (a.length() > 0) { - if (a.indexOf("=") == -1) { - List list = new ArrayList(); - list.add(a); - anns.add(list); - } else { - List equal_weights = new ArrayList(); - for (String e : a.split("=")) { - e = e.trim(); - if (e.length() > 0) - equal_weights.add(e); - } - anns.add(equal_weights); - } - } - } - result.put(new int[]{mainCol, otherCol}, anns); - } - return result; - } - - public static Map>> readCellAnnotation(String keyfile) throws IOException { - Map>> result = new HashMap>>(); - if (!new File(keyfile).exists()) - return result; - - List lines = FileUtils.readList(keyfile, false); - for (String l : lines) { - String[] pos_annotations = l.split("=", 2); - if (pos_annotations.length < 2) - continue; - - String pos = pos_annotations[0]; - String[] pos_ = pos.split(","); - if (pos_.length < 2) continue; - int row = Integer.valueOf(pos_[0].trim()); - int col = Integer.valueOf(pos_[1].trim()); - - String annotations = pos_annotations[1]; - List> anns = new ArrayList>(); - for (String a : annotations.split("\\|")) { - a = a.trim(); - if (a.indexOf("=") == -1) { - List list = new ArrayList(); - list.add(a); - anns.add(list); - } else { - List equal_weights = new ArrayList(); - for (String e : a.split("=")) { - e = e.trim(); - if (e.length() > 0) - equal_weights.add(e); - } - anns.add(equal_weights); - } - } - result.put(new int[]{row, col}, anns); - } - return result; - } -} +package uk.ac.shef.dcs.sti.todo; + +import uk.ac.shef.dcs.sti.util.FileUtils; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + */ +public class TAnnotationKeyFileReader { + public static Map>> readHeaderAnnotation(String keyfile, boolean isGS, boolean gs_NE_only) throws IOException { + Map>> result = new HashMap>>(); + if (!new File(keyfile).exists()) + return result; + + List lines = FileUtils.readList(keyfile, false); + for (String l : lines) { + if (l.contains("|") && isGS) + System.err.println("error line:" + l); + if (isGS && gs_NE_only && !l.endsWith("___NE")) + continue; + + if (l.endsWith("___NE")) { + l = l.substring(0, l.indexOf("___NE")).trim(); + } + String[] col_annotations = l.split("=", 2); + if (col_annotations.length < 2) + continue; + + int col = Integer.valueOf(col_annotations[0]); + String annotations = col_annotations[1]; + List> anns = new ArrayList>(); + String[] parts; + if (isGS) + parts = annotations.split("\t"); + else + parts = annotations.split("\\|"); + for (String a : parts) { + a = a.trim(); + if (a.length() > 0 && !a.startsWith("/")) + System.out.println(); + if (a.startsWith("//")) + System.out.println(); + if (a.length() > 0) { + if (a.indexOf("=") == -1) { + List list = new ArrayList(); + list.add(a); + anns.add(list); + } else { + List equal_weights = new ArrayList(); + for (String e : a.split("=")) { + e = e.trim(); + if (e.split("/").length > 5) + System.out.println(); + if (e.length() > 0 && !e.startsWith("/")) + System.out.println(); + if (e.length() > 0) + equal_weights.add(e); + } + anns.add(equal_weights); + } + } + } + result.put(col, anns); + } + return result; + } + + + public static Map>> readColumnBinaryRelationAnnotation_GS(String keyfile, + List main, + List tolerant) throws IOException { + Map>> result = new HashMap>>(); + if (!new File(keyfile).exists()) + return result; + + List lines = FileUtils.readList(keyfile, false); + for (String l : lines) { + String[] pos_annotations = l.split("=", 2); + if (pos_annotations.length < 2) + continue; + + String pos = pos_annotations[0].trim(); + if (pos.contains(";")) { + String[] parts = pos.split(";"); + String first = parts[0].trim(); + if(first.startsWith("-")){ + first=first.substring(1).trim(); + tolerant.add(first); + }else{ + main.add(first); + } + pos=first; + } + else{ + main.add(pos); + } + + String[] pos_ = pos.split(","); + if (pos_.length < 2) continue; + int mainCol = Integer.valueOf(pos_[0].trim()); + int otherCol = Integer.valueOf(pos_[1].trim()); + + String annotations = pos_annotations[1]; + List> anns = new ArrayList>(); + String[] parts = null; + + parts = annotations.split("\t"); + + for (String a : parts) { + a = a.trim(); + if (a.length() > 0 && !a.startsWith("/")) + System.out.println(); + if (a.startsWith("//")) + System.out.println(); + + if (a.length() > 0) { + if (a.indexOf("=") == -1) { + List list = new ArrayList(); + list.add(a); + anns.add(list); + } else { + List equal_weights = new ArrayList(); + for (String e : a.split("=")) { + e = e.trim(); + if (e.split("/").length > 4) + System.out.println(); + if (e.length() > 0 && !e.startsWith("/")) + System.out.println(); + if (e.length() > 0) + equal_weights.add(e); + } + anns.add(equal_weights); + } + } + } + result.put(new int[]{mainCol, otherCol}, anns); + } + return result; + } + + public static Map>> readColumnBinaryRelationAnnotation_CP(String keyfile) throws IOException { + Map>> result = new HashMap>>(); + if (!new File(keyfile).exists()) + return result; + + List lines = FileUtils.readList(keyfile, false); + for (String l : lines) { + String[] pos_annotations = l.split("=", 2); + if (pos_annotations.length < 2) + continue; + + String pos = pos_annotations[0]; + String[] pos_ = pos.split(","); + if (pos_.length < 2) continue; + int mainCol = Integer.valueOf(pos_[0].trim()); + int otherCol = Integer.valueOf(pos_[1].trim()); + + String annotations = pos_annotations[1]; + List> anns = new ArrayList>(); + String[] parts= annotations.split("\\|"); + for (String a : parts) { + a = a.trim(); + if (a.length() > 0) { + if (a.indexOf("=") == -1) { + List list = new ArrayList(); + list.add(a); + anns.add(list); + } else { + List equal_weights = new ArrayList(); + for (String e : a.split("=")) { + e = e.trim(); + if (e.length() > 0) + equal_weights.add(e); + } + anns.add(equal_weights); + } + } + } + result.put(new int[]{mainCol, otherCol}, anns); + } + return result; + } + + public static Map>> readCellAnnotation(String keyfile) throws IOException { + Map>> result = new HashMap>>(); + if (!new File(keyfile).exists()) + return result; + + List lines = FileUtils.readList(keyfile, false); + for (String l : lines) { + String[] pos_annotations = l.split("=", 2); + if (pos_annotations.length < 2) + continue; + + String pos = pos_annotations[0]; + String[] pos_ = pos.split(","); + if (pos_.length < 2) continue; + int row = Integer.valueOf(pos_[0].trim()); + int col = Integer.valueOf(pos_[1].trim()); + + String annotations = pos_annotations[1]; + List> anns = new ArrayList>(); + for (String a : annotations.split("\\|")) { + a = a.trim(); + if (a.indexOf("=") == -1) { + List list = new ArrayList(); + list.add(a); + anns.add(list); + } else { + List equal_weights = new ArrayList(); + for (String e : a.split("=")) { + e = e.trim(); + if (e.length() > 0) + equal_weights.add(e); + } + anns.add(equal_weights); + } + } + result.put(new int[]{row, col}, anns); + } + return result; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/TestGRMM.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/TestGRMM.java index 2843795c..acb2d2d6 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/TestGRMM.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/TestGRMM.java @@ -1,150 +1,150 @@ -package uk.ac.shef.dcs.sti.todo; - -import cc.mallet.grmm.inference.Inferencer; -import cc.mallet.grmm.inference.LoopyBP; -import cc.mallet.grmm.types.*; -import cc.mallet.types.LabelAlphabet; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 26/09/12 - * Time: 11:42 - */ -public class TestGRMM { - - /* - Table - - f f - | | - (v)City --f-- R --f-- (v)Mayor - | | - f f - | | - f --(v)sheffield --f-- R --f-- (v)personA-- f - - - - f --(v)new york --f-- R --f-- (v)personB-- f - - */ - public static void main(String[] args) { - FactorGraph mdl = new FactorGraph(); - - LabelAlphabet header_city = new LabelAlphabet(); - //two possible values - header_city.lookupIndex("dbpedia-owl:City"); - header_city.lookupIndex("dbpedia-owl:Citi_group"); - //create a variable that takes the two possible values - Variable var_header_city = new Variable(header_city); //0 - /*prior prob of seeing each value of varHeaderCity in the KB*/ - double[] potential1 = new double[]{0, 0}; //meaning prob of seeing the first value (city) is 0.65; prob of the 2nd (citi_group) is0.35 - TableFactor f1 = new TableFactor(var_header_city, potential1); - mdl.addFactor(f1); - - LabelAlphabet header_mayor = new LabelAlphabet(); - header_mayor.lookupIndex("dbpedia-owl:Mayor"); - header_mayor.lookupIndex("dbpedia-owl:Mayor_Surname"); - Variable var_header_mayor = new Variable(header_mayor); //1 - double[] potential2 = new double[]{1.75, 0}; - TableFactor f2 = new TableFactor(var_header_mayor, potential2); - mdl.addFactor(f2); - - LabelAlphabet cell_city1 = new LabelAlphabet(); - cell_city1.lookupIndex("dbpedia-owl:shefielduk"); - cell_city1.lookupIndex("dbpedia-owl:shefieldus"); - cell_city1.lookupIndex("dbpedia-owl:shefieldukaustralia"); - Variable var_cell_city1 = new Variable(cell_city1); //2 - double[] potential3 = new double[]{0.5, 2.15, 0.35}; - TableFactor f3 = new TableFactor(var_cell_city1, potential3); - mdl.addFactor(f3); - - LabelAlphabet cell_City2 = new LabelAlphabet(); - cell_City2.lookupIndex("dbpedia-owl:newyorkUS"); - cell_City2.lookupIndex("dbpedia-owl:newyorkNewsPaper"); - cell_City2.lookupIndex("dbpedia-owl:newyorkMovie"); - Variable var_cell_city2 = new Variable(cell_City2); //3 - double[] potential4 = new double[]{0.8, 1.05, 0.15}; - TableFactor f4 = new TableFactor(var_cell_city2, potential4); - mdl.addFactor(f4); - - LabelAlphabet cell_mayor1 = new LabelAlphabet(); - cell_mayor1.lookupIndex("dbpedia-owl:personA_1"); - cell_mayor1.lookupIndex("dbpedia-owl:personA_2"); - Variable var_cell_mayor1 = new Variable(cell_mayor1); //4 - double[] potential5 = new double[]{1.5, 1.5}; - TableFactor f5 = new TableFactor(var_cell_mayor1, potential5); - mdl.addFactor(f5); - - LabelAlphabet cell_mayor2 = new LabelAlphabet(); - cell_mayor2.lookupIndex("dbpedia-owl:personB_1"); - cell_mayor2.lookupIndex("dbpedia-owl:personB_2"); - cell_mayor2.lookupIndex("dbpedia-owl:personB_3"); - cell_mayor2.lookupIndex("dbpedia-owl:personB_4"); - Variable var_cell_mayor2 = new Variable(cell_mayor2); //5 - double[] potential6 = new double[]{2.3, 2.25, 2.25, 1.2}; - TableFactor f6 = new TableFactor(var_cell_mayor2, potential6); - mdl.addFactor(f6); - - LabelAlphabet relation = new LabelAlphabet(); - relation.lookupIndex("dbpp:manage"); - relation.lookupIndex("dbpp:liveIn"); - relation.lookupIndex("dbpp:hometown"); - relation.lookupIndex("dbpp:famousPerson"); - Variable var_relation = new Variable(relation); //5 - double[] potential_headerCity_relation = new double[]{3, 0, 1, 0, 2, 0,1,0}; - VarSet varSet17 = new HashVarSet(new Variable[]{var_header_city, var_relation}); - TableFactor f17 = new TableFactor(varSet17, potential_headerCity_relation); - mdl.addFactor(f17); - - double[] potential_headerMayor_relation = new double[]{2, 0, 1, 0, 1, 0,0,0}; - VarSet varSet27 = new HashVarSet(new Variable[]{var_header_mayor, var_relation}); - TableFactor f27 = new TableFactor(varSet27, potential_headerMayor_relation); - mdl.addFactor(f27); - - double[] potential_headerCity_cellCity1 = new double[]{0.9, 0.85, 0.91, 0.01, 0.005, 0.11}; - VarSet varSet13 = new HashVarSet(new Variable[]{var_header_city, var_cell_city1}); - TableFactor f13 = new TableFactor(varSet13, potential_headerCity_cellCity1); - mdl.addFactor(f13); - - double[] potential_headerCity_cellCity2 = new double[]{0.9, 0.12, 0.23, 0.56, 0.775, 0.01}; - VarSet varSet14 = new HashVarSet(new Variable[]{var_header_city, var_cell_city2}); - TableFactor f14 = new TableFactor(varSet14, potential_headerCity_cellCity2); - mdl.addFactor(f14); - - double[] potential_headerMayor_cellMayor1 = new double[]{0.35, 0.77, 0.55, 0.1}; - VarSet varSet25 = new HashVarSet(new Variable[]{var_header_mayor, var_cell_mayor1}); - TableFactor f25 = new TableFactor(varSet25, potential_headerMayor_cellMayor1); - mdl.addFactor(f25); - - double[] potential_headerMayor_cellMayor2 = new double[]{0.8, 0.25, 0.7, 0.01, 0.001, 0.002, 0.32, 0.01}; - VarSet varSet26 = new HashVarSet(new Variable[]{var_header_mayor, var_cell_mayor2}); - TableFactor f26 = new TableFactor(varSet26, potential_headerMayor_cellMayor2); - mdl.addFactor(f26); - - mdl.dump(); - - Inferencer infLoopyBP = new LoopyBP(); - //Inferencer infResidualBP = new ResidualBP(); - - infLoopyBP.computeMarginals(mdl); - // infResidualBP.computeMarginals(mdl); - - for(int i=0; i stopWords = FileUtils.readList(nlpResources + "/stoplist.txt", true); - File configFile = new File(cacheFolder + File.separator + "solr.xml"); - - //todo: this class will not work, the following code must be resumed and corrected - /*CoreContainer container = new CoreContainer(cacheFolder, - configFile); - SolrServer server = new EmbeddedSolrServer(container, "collection1"); - SubjectColumnDetector finder = new SubjectColumnDetector(new TContentTContentRowRankerImpl(), - IInf.class.getName(), - new String[]{"0.0", "1", "0.01"}, - server, - nlpResources, true, stopWords, - MultiKeyStringSplitter.split(properties.getProperty("BING_API_KEYS")) //lodie - - );*/ - - EmbeddedSolrServer server=null; - SubjectColumnDetector finder=null; - - /* List tasks= - FileUtils.readList("E:\\Data\\table annotation\\corpus_analysis\\90_tables/" + - "90_tables_for_studying_subject_columns_(noise_removed).csv",false); - PrintWriter p = new PrintWriter("E:\\Data\\table annotation\\corpus_analysis\\90_tables" + - "/evaluate_subject_column_finder.csv"); - int count=0; - for(String task: tasks){ - count++; - *//*if(count==1||count==57) - System.out.println();*//* - - int lastComma = task.lastIndexOf(","); - String sourceTableFile = task.substring(0, lastComma).trim(); - if(sourceTableFile.startsWith("\"") &&sourceTableFile.endsWith("\"")) - sourceTableFile = sourceTableFile.substring(1, sourceTableFile.length()-1).trim(); - System.out.println(count+"_"+sourceTableFile); - - String groundTruth = task.substring(lastComma+1).trim(); - - Table table = LimayeDatasetLoader.readTable(sourceTableFile, null, null); - - List>> result = finder.compute(table); - - StringBuilder sb = new StringBuilder(); - sb.append("\"").append(sourceTableFile).append("\",").append(groundTruth).append(",").append(result.get(0).getMainObject()+1); - p.println(sb.toString()); - } - p.close(); - - server.closeConnection(); - System.exit(0);*/ - //String inFolder="E:\\Data\\table annotation\\corpus_analysis\\100_tables\\100_tables"; - TableParserMusicBrainz xtractor = new TableParserMusicBrainz(new TableNormalizerSimple(), - new TableHODetectorByHTMLTag(), - new TableObjCreatorMusicBrainz(), - new TableValidatorGeneric()); - PrintWriter p = new PrintWriter(outFile); - int count = 0; - /*TableXtractorMusicBrainz xtractor = new TableXtractorMusicBrainz(new TableNormalizerDummy(), - new TableHODetectorByHTMLTag(), - new TableObjCreatorMusicBrainz(), - new TabValGeneric());*/ - - List sorted = new ArrayList(Arrays.asList(new File(inFolder).listFiles())); - Collections.sort(sorted); - for (File f : sorted) { - - count++; - String task = f.toString(); - /*if(!task.contains("Atlantis")) - continue;*/ - System.out.println(count + "_" + f); - - /*if(count==1||count==57) - System.out.println();*/ - - - String fileContent = org.apache.any23.util.FileUtils.readFileContent(f); - List tables = xtractor.extract(fileContent, f.toString()); - if (tables.size() == 0) - continue; - - Table table = tables.get(0); - - //Table table = LimayeDatasetLoader.readTable(task, null, null); - // String fileContent = org.apache.any23.util.FileUtils.readFileContent(f); - //List
tables = xtractor.extract(fileContent, task); - /* if(tables.size()<1) - continue;*/ - // Table table = tables.get(0); - try { - List>> result = finder.compute(table); - - p.println("\"" + f + "\"," + result.get(0).getKey() + "," + result.get(0).getValue().getValue()); - } catch (Exception e) { - System.err.println("FAILED:" + f); - } - - } - p.close(); - - server.close(); - System.exit(0); - } - - public static void which_table_has_no_acronym_columns(String logFile) throws IOException { - - boolean newFile = false; - boolean hasAcronym = false; - for (String l : FileUtils.readList(logFile, false)) { - if (l.contains("_E:")) { - if (newFile && !hasAcronym) - System.out.println(l); - - hasAcronym = false; - newFile = true; - continue; - } else { - hasAcronym = true; - } - - } - } - - public static void gs_rewrite(String inGsFile, String outGsFile) throws IOException { - List lines = FileUtils.readList(inGsFile, false); - List newGs = new ArrayList(); - for (String l : lines) { - String originalLine = l; - - int split = l.lastIndexOf(","); - String path = l.substring(0, split).trim(); - path = path.replaceAll("\\\\", "/"); - split = path.lastIndexOf("/"); - path = path.substring(split + 1).trim(); - if (path.endsWith("\"")) - path = path.substring(0, path.length() - 1).trim(); - newGs.add("\"" + path + "\"," + originalLine.substring(originalLine.lastIndexOf(",") + 1).trim()); - } - Collections.sort(newGs); - PrintWriter p = new PrintWriter(outGsFile); - for (String l : newGs) - p.println(l); - p.close(); - } -} +package uk.ac.shef.dcs.sti.todo; + +import javafx.util.Pair; +import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; +import org.xml.sax.SAXException; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.subjectcol.SubjectColumnDetector; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.parser.table.TableParserMusicBrainz; +import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizerSimple; +import uk.ac.shef.dcs.sti.parser.table.validator.TableValidatorGeneric; +import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetectorByHTMLTag; +import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreatorMusicBrainz; +import uk.ac.shef.dcs.sti.util.FileUtils; + +import javax.xml.parsers.ParserConfigurationException; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.*; + +/** + */ +public class TestSubjectColumnDetector { + public static void main(String[] args) throws IOException, SAXException, ParserConfigurationException, STIException { + /*which_table_has_no_acronym_columns("E:\\Data\\table annotation\\freebase_crawl\\music_record_label/tmp.txt"); + System.exit(0);*/ + + /* gs_rewrite("E:\\Data\\table annotation\\corpus_analysis\\90_tables/90_tables_for_studying_subject_columns_(noise_removed).csv", + "E:\\Data\\table annotation\\corpus_analysis\\90_tables\\91_tables_subcol_gs.csv"); + System.exit(0);*/ + String inFolder = args[0]; + String outFile = args[1]; + String nlpResources = args[2]; + String cacheFolder = args[3]; + Properties properties = new Properties(); + properties.load(new FileInputStream(args[4])); + List stopWords = FileUtils.readList(nlpResources + "/stoplist.txt", true); + File configFile = new File(cacheFolder + File.separator + "solr.xml"); + + //todo: this class will not work, the following code must be resumed and corrected + /*CoreContainer container = new CoreContainer(cacheFolder, + configFile); + SolrServer server = new EmbeddedSolrServer(container, "collection1"); + SubjectColumnDetector finder = new SubjectColumnDetector(new TContentTContentRowRankerImpl(), + IInf.class.getName(), + new String[]{"0.0", "1", "0.01"}, + server, + nlpResources, true, stopWords, + MultiKeyStringSplitter.split(properties.getProperty("BING_API_KEYS")) //lodie + + );*/ + + EmbeddedSolrServer server=null; + SubjectColumnDetector finder=null; + + /* List tasks= + FileUtils.readList("E:\\Data\\table annotation\\corpus_analysis\\90_tables/" + + "90_tables_for_studying_subject_columns_(noise_removed).csv",false); + PrintWriter p = new PrintWriter("E:\\Data\\table annotation\\corpus_analysis\\90_tables" + + "/evaluate_subject_column_finder.csv"); + int count=0; + for(String task: tasks){ + count++; + *//*if(count==1||count==57) + System.out.println();*//* + + int lastComma = task.lastIndexOf(","); + String sourceTableFile = task.substring(0, lastComma).trim(); + if(sourceTableFile.startsWith("\"") &&sourceTableFile.endsWith("\"")) + sourceTableFile = sourceTableFile.substring(1, sourceTableFile.length()-1).trim(); + System.out.println(count+"_"+sourceTableFile); + + String groundTruth = task.substring(lastComma+1).trim(); + + Table table = LimayeDatasetLoader.readTable(sourceTableFile, null, null); + + List>> result = finder.compute(table); + + StringBuilder sb = new StringBuilder(); + sb.append("\"").append(sourceTableFile).append("\",").append(groundTruth).append(",").append(result.get(0).getMainObject()+1); + p.println(sb.toString()); + } + p.close(); + + server.closeConnection(); + System.exit(0);*/ + //String inFolder="E:\\Data\\table annotation\\corpus_analysis\\100_tables\\100_tables"; + TableParserMusicBrainz xtractor = new TableParserMusicBrainz(new TableNormalizerSimple(), + new TableHODetectorByHTMLTag(), + new TableObjCreatorMusicBrainz(), + new TableValidatorGeneric()); + PrintWriter p = new PrintWriter(outFile); + int count = 0; + /*TableXtractorMusicBrainz xtractor = new TableXtractorMusicBrainz(new TableNormalizerDummy(), + new TableHODetectorByHTMLTag(), + new TableObjCreatorMusicBrainz(), + new TabValGeneric());*/ + + List sorted = new ArrayList(Arrays.asList(new File(inFolder).listFiles())); + Collections.sort(sorted); + for (File f : sorted) { + + count++; + String task = f.toString(); + /*if(!task.contains("Atlantis")) + continue;*/ + System.out.println(count + "_" + f); + + /*if(count==1||count==57) + System.out.println();*/ + + + String fileContent = org.apache.any23.util.FileUtils.readFileContent(f); + List
tables = xtractor.extract(fileContent, f.toString()); + if (tables.size() == 0) + continue; + + Table table = tables.get(0); + + //Table table = LimayeDatasetLoader.readTable(task, null, null); + // String fileContent = org.apache.any23.util.FileUtils.readFileContent(f); + //List
tables = xtractor.extract(fileContent, task); + /* if(tables.size()<1) + continue;*/ + // Table table = tables.get(0); + try { + List>> result = finder.compute(table); + + p.println("\"" + f + "\"," + result.get(0).getKey() + "," + result.get(0).getValue().getValue()); + } catch (Exception e) { + System.err.println("FAILED:" + f); + } + + } + p.close(); + + server.close(); + System.exit(0); + } + + public static void which_table_has_no_acronym_columns(String logFile) throws IOException { + + boolean newFile = false; + boolean hasAcronym = false; + for (String l : FileUtils.readList(logFile, false)) { + if (l.contains("_E:")) { + if (newFile && !hasAcronym) + System.out.println(l); + + hasAcronym = false; + newFile = true; + continue; + } else { + hasAcronym = true; + } + + } + } + + public static void gs_rewrite(String inGsFile, String outGsFile) throws IOException { + List lines = FileUtils.readList(inGsFile, false); + List newGs = new ArrayList(); + for (String l : lines) { + String originalLine = l; + + int split = l.lastIndexOf(","); + String path = l.substring(0, split).trim(); + path = path.replaceAll("\\\\", "/"); + split = path.lastIndexOf("/"); + path = path.substring(split + 1).trim(); + if (path.endsWith("\"")) + path = path.substring(0, path.length() - 1).trim(); + newGs.add("\"" + path + "\"," + originalLine.substring(originalLine.lastIndexOf(",") + 1).trim()); + } + Collections.sort(newGs); + PrintWriter p = new PrintWriter(outGsFile); + for (String l : newGs) + p.println(l); + p.close(); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats.java index 40a2ab7c..6085f339 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats.java @@ -1,683 +1,683 @@ -package uk.ac.shef.dcs.sti.todo.evaluation; - -import uk.ac.shef.dcs.sti.util.FileUtils; - -import java.io.IOException; -import java.io.PrintWriter; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 23/02/14 - * Time: 21:45 - * To change this template use File | Settings | File Templates. - */ -public class DataStats { - - public static void main(String[] args) throws IOException { - /*calculate_average_query_time("D:\\Work\\lodie/lodie.LOG"); - System.exit(0);*/ - - /////////////////////////////////////////////// BING SEARCH CONVERGENCE //////////////////////////////////////////////////////////// - /*calculate_ws_converge("E:\\Data\\table_annotation\\efficiency_analysis_data\\SUBCOL_FINAL_limaye200_convergence.txt", - "D:\\Work\\lodie\\tmp_result/convergence_ws_limaye200.csv"); - calculate_ws_converge("E:\\Data\\table_annotation\\efficiency_analysis_data\\SUBCOL_FINAL_limayeall_convergence.txt", - "D:\\Work\\lodie\\tmp_result/convergence_ws_limayeall.csv"); - calculate_ws_converge("E:\\Data\\table_annotation\\efficiency_analysis_data\\SUBCOL_FINAL_musicbrainz_convergence.txt", - "D:\\Work\\lodie\\tmp_result/convergence_ws_musicbrainz.csv"); - - System.exit(0);*/ - - ///////////////////////////////////////////////---DONE--- i-inf CONVERGENCE in column interpretation//////////////////////////////////////////////////////////// - /*calculate_converge_column_interpretation( - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\raw", - "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200/random_nostop.LOG", - "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200/random_nostop.csv"); - calculate_converge_column_interpretation( - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\raw", - "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200/nonempty.LOG", - "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200/nonempty.csv"); - calculate_converge_column_interpretation( - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\raw", - "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200/tokens.LOG", - "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200/tokens.csv"); - calculate_converge_column_interpretation( - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\raw", - "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200/namelength.LOG", - "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200/namelength.csv"); - calculate_converge_column_interpretation( - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\raw", - "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200/random.LOG", - "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200/random.csv"); - calculate_converge_column_interpretation( - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\raw", - "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200/ospd_random.LOG", - "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200/ospd_random.csv"); - System.exit(0); - - - calculate_converge_column_interpretation( - "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200", - "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200/random.LOG", - "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200/random.csv"); - calculate_converge_column_interpretation( - "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200", - "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200/nonempty.LOG", - "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200/nonempty.csv"); - calculate_converge_column_interpretation( - "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200", - "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200/tokens.LOG", - "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200/tokens.csv"); - calculate_converge_column_interpretation( - "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200", - "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200/namelength.LOG", - "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200/namelength.csv"); - calculate_converge_column_interpretation( - "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200", - "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200/combined.LOG", - "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200/combined.csv"); - calculate_converge_column_interpretation( - "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200", - "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200/ospd_random.LOG", - "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200/ospd_random.csv"); - System.exit(0); - - - - calculate_converge_column_interpretation( - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen", - "E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_limaye200_tm_sysout.txt", - "D:\\Work\\lodie\\tmp_result/learning_phase_converengece-limaye200-tm.csv"); - calculate_converge_column_interpretation( - "limaye/all", - "E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_limayeall_tm_sysout.LOG", - "D:\\Work\\lodie\\tmp_result/learning_phase_converengece-limayeall-tm.csv"); - calculate_converge_column_interpretation( - "musicbrainz_raw/", - "E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_mb_tm_sysout.LOG", - "D:\\Work\\lodie\\tmp_result/learning_phase_converengece-musicbrainz-tm.csv"); - calculate_converge_column_interpretation( - "imdb_raw/", - "E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_imdb_tm_sysout.LOG", - "D:\\Work\\lodie\\tmp_result/learning_phase_converengece-imdb-tm.csv"); - System.exit(0);*/ - - - /////////////////////////////////////////////// ---done--- Candidate counting (overall, runPreliminaryColumnClassifier-consolidate only, new entity at update, all entity at update) //////////////////////////////////////////////////////////// - calculate_entity_candidate_savings( - "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200\\random_nostop.LOG", - "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200\\candidate_savings_random_nostop.csv"); - calculate_entity_candidate_savings( - "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200\\random.LOG", - "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200\\candidate_savings_random.csv"); - calculate_entity_candidate_savings( - "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200\\ospd_random.LOG", - "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200\\candidate_savings_ospd_random.csv"); - calculate_entity_candidate_savings( - "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200\\nonempty.LOG", - "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200\\candidate_savings_nonempty.csv"); - calculate_entity_candidate_savings( - "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200\\tokens.LOG", - "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200\\candidate_savings_tokens.csv"); - calculate_entity_candidate_savings( - "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200\\namelength.LOG", - "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200\\candidate_savings_namelength.csv"); - - - - System.exit(0); - - - calculate_entity_candidate_savings( - "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_limaye200_tm_sysout.txt", - "D:\\Work\\lodie\\tmp_result\\entity_reduction_overall-limaye200-tm.csv"); - calculate_entity_candidate_savings_update_only( - "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_limaye200_tm_sysout.txt", - "D:\\Work\\lodie\\tmp_result\\entity_reduction_learning_consol-limaye200-tm.csv"); - calculate_new_entity_candidate_at_update( - "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_limaye200_tm_sysout.txt", - "D:\\Work\\lodie\\tmp_result/entity_new_in_update-limaye200-tm.csv" - ); - calculate_old_entity_candidate_at_update( - "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_limaye200_tm_sysout.txt", - "D:\\Work\\lodie\\tmp_result/entity_old_in_update-limaye200-tm.csv" - ); - - calculate_entity_candidate_savings( - "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_limayeall_tm_sysout.txt", - "D:\\Work\\lodie\\tmp_result\\entity_reduction_overall-limayeall-tm.csv"); - calculate_entity_candidate_savings_update_only( - "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_limayeall_tm_sysout.txt", - "D:\\Work\\lodie\\tmp_result\\entity_reduction_learning_consol-limayeall-tm.csv"); - calculate_new_entity_candidate_at_update( - "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_limayeall_tm_sysout.txt", - "D:\\Work\\lodie\\tmp_result/entity_new_in_update-limayeall-tm.csv" - ); - calculate_old_entity_candidate_at_update( - "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_limayeall_tm_sysout.txt", - "D:\\Work\\lodie\\tmp_result/entity_old_in_update-limayeall-tm.csv" - ); - - calculate_entity_candidate_savings( - "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_imdb_tm_sysout.txt", - "D:\\Work\\lodie\\tmp_result\\entity_reduction_overall-imdb-tm.csv"); - calculate_entity_candidate_savings_update_only( - "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_imdb_tm_sysout.txt", - "D:\\Work\\lodie\\tmp_result\\entity_reduction_learning_consol-imdb-tm.csv"); - calculate_new_entity_candidate_at_update( - "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_imdb_tm_sysout.txt", - "D:\\Work\\lodie\\tmp_result/entity_new_in_update-imdb-tm.csv" - ); - calculate_old_entity_candidate_at_update( - "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_imdb_tm_sysout.txt", - "D:\\Work\\lodie\\tmp_result/entity_old_in_update-imdb-tm.csv" - ); - - calculate_entity_candidate_savings( - "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_mb_tm_sysout.txt", - "D:\\Work\\lodie\\tmp_result\\entity_reduction_overall-musicbrainz-tm.csv"); - calculate_entity_candidate_savings_update_only( - "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_mb_tm_sysout.txt", - "D:\\Work\\lodie\\tmp_result\\entity_reduction_learning_consol-musicbrainz-tm.csv"); - calculate_new_entity_candidate_at_update( - "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_mb_tm_sysout.txt", - "D:\\Work\\lodie\\tmp_result/entity_new_in_update-musicbrainz-tm.csv" - ); - calculate_old_entity_candidate_at_update( - "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_mb_tm_sysout.txt", - "D:\\Work\\lodie\\tmp_result/entity_old_in_update-musicbrainz-tm.csv" - ); - System.exit(0); - - - /////////////////////////////////////////// -----------done ------------- candidate counting baseline ////////////////////////////////// - /*calculate_entity_candidate_savings_baseline("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_limaye200_bs_sl_sysout.txt", - "D:\\Work\\lodie\\tmp_result/candidate_entity_limaye200_bs_sl.csv"); - calculate_entity_candidate_savings_baseline("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_limayeall_bs_sl_sysout.txt", - "D:\\Work\\lodie\\tmp_result/candidate_entity_limayeall_bs_sl.csv"); - calculate_entity_candidate_savings_baseline("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_imdb_bs_sl_sysout.txt", - "D:\\Work\\lodie\\tmp_result/candidate_entity_imdb_bs_sl.csv"); - calculate_entity_candidate_savings_baseline("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_mb_bs_sl_sysout.txt", - "D:\\Work\\lodie\\tmp_result/candidate_entity_mb_bs_sl.csv"); - System.exit(0);*/ - - /////////////////////////////////////////// UNIQUE ENTITIES processed - /*calculate_entity_candidate_unique_for_calculating_running_time - ("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_limaye200_bs_sl_sysout.txt"); - calculate_entity_candidate_unique_for_calculating_running_time - ("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_limaye200_tm_sysout.txt");*/ - calculate_entity_candidate_unique_for_calculating_running_time - ("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_limayeall_bs_sl_sysout.txt"); - /*calculate_entity_candidate_unique_for_calculating_running_time - ("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_limayeall_tm_sysout.txt"); - calculate_entity_candidate_unique_for_calculating_running_time - ("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_mb_tm_sysout.txt"); - calculate_entity_candidate_unique_for_calculating_running_time - ("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_mb_base_sl_sysout.txt"); - calculate_entity_candidate_unique_for_calculating_running_time - ("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_imdb_tm_sysout.txt"); - calculate_entity_candidate_unique_for_calculating_running_time - ("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_imdb_base_sl_sysout.txt");*/ - System.exit(0); - - - /////////////////////////////////////////// ----- done ----- iterations at update - calculate_iterations_in_update("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_limaye200_tm_sysout.txt", - "D:\\Work\\lodie\\tmp_result/iterations_in_update-limaye200-tm.csv"); - calculate_iterations_in_update("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_limayeall_tm_sysout.txt", - "D:\\Work\\lodie\\tmp_result/iterations_in_update-limayeall-tm.csv"); - calculate_iterations_in_update("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_imdb_tm_sysout.txt", - "D:\\Work\\lodie\\tmp_result/iterations_in_update-imdb-tm.csv"); - calculate_iterations_in_update("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_mb_tm_sysout.txt", - "D:\\Work\\lodie\\tmp_result/iterations_in_update-musicbrainz-tm.csv"); - - System.exit(0); - - - } - - private static void count_NE_cells(String in_system_out_file) throws IOException { - List lines = FileUtils.readList(in_system_out_file, false); - boolean stopCounting = false; - - int count = 0; - - int currentCol = -1; - int totalCol = 0; - int maxRow = 0; - for (String l : lines) { - - if (l.contains("_E:\\")) { - //System.out.println(l); - System.out.println(totalCol + "," + maxRow + "," + totalCol * maxRow); - - currentCol = -1; - totalCol = 0; - maxRow = 0; - //consolidate numbers - } - - if (l.contains(">> Column=")) { - String col = l.split("=")[1].trim(); - int c = Integer.valueOf(col) + 1; - if (c != currentCol) - totalCol++; - } - if (l.contains(" position at ")) { - int start_pos = l.indexOf("("); - String nl = l.substring(start_pos + 1); - int row = Integer.valueOf(nl.split(",")[0].trim()); - if (row > maxRow) - maxRow = row; - } - - if (l.contains("UPDATE ITERATION ")) - stopCounting = true; - if (l.contains("UPDATE STABLIZED AFTER")) - stopCounting = false; - - if (!stopCounting) { - if (l.contains(" position at (")) - count++; - } - } - System.out.println(totalCol + "," + maxRow + "," + totalCol * maxRow); - System.out.println(count); - } - - private static void calculate_new_entity_candidate_at_update(String tableminer_convergence_log, - String outfile) throws IOException { - PrintWriter p = new PrintWriter(outfile); - p.println("Initial, Reduced to"); - - List lines = FileUtils.readList(tableminer_convergence_log, false); - - boolean count = false; - - int initial = 0, reduced = 0; - for (String l : lines) { - if (l.contains("BACKWARD UPDATE...")) { - count = true; - continue; - } - if (l.contains("FORWARD LEARNING")) { - count = false; - continue; - } - - if (count && l.contains("(QUERY_KB:")) { - String[] parts = l.trim().split(":"); - String value = parts[1].trim(); - String[] vs = value.split("\\s+"); - initial = Integer.valueOf(vs[0].trim()); - reduced = Integer.valueOf(vs[2].trim()); - if (reduced == 0) { - initial = 0; - } - - continue; - } - - if (count && l.contains("ALREADY BUILT FOR")) { - String[] parts = l.trim().split("="); - int already = Integer.valueOf(parts[1].trim()); - int todo = reduced - already; - if (todo != 0) { - p.println(todo); - } - initial = 0; - reduced = 0; - } - } - - - p.close(); - } - - private static void calculate_old_entity_candidate_at_update(String tableminer_convergence_log, - String outfile) throws IOException { - PrintWriter p = new PrintWriter(outfile); - p.println("Initial, Reduced to"); - - List lines = FileUtils.readList(tableminer_convergence_log, false); - - boolean count = false; - - int initial = 0, reduced = 0; - for (String l : lines) { - if (l.contains("BACKWARD UPDATE...")) { - count = true; - continue; - } - if (l.contains("FORWARD LEARNING")) { - count = false; - continue; - } - - if (count && l.contains("(QUERY_KB:")) { - String[] parts = l.trim().split(":"); - String value = parts[1].trim(); - String[] vs = value.split("\\s+"); - initial = Integer.valueOf(vs[0].trim()); - reduced = Integer.valueOf(vs[2].trim()); - if (reduced == 0) { - continue; - } - p.println(reduced); - continue; - } - } - - - p.close(); - } - - private static void calculate_entity_candidate_savings(String tableminer_convergence_log, - String outfile) throws IOException { - PrintWriter p = new PrintWriter(outfile); - p.println("Initial, Reduced to"); - - List lines = FileUtils.readList(tableminer_convergence_log, false); - - boolean count = false; - int countline=-1; - for (String l : lines) { - countline++; - if (l.contains("BACKWARD UPDATE...")) { - count = false; - continue; - } - if (l.contains("FORWARD LEARNING")) { - count = true; - continue; - } - - if (count && l.contains("(QUERY_KB:")) { - String[] parts = l.trim().split(":"); - String value = parts[1].trim(); - String[] vs = value.split("\\s+"); - String initial = vs[0].trim(); - String reduced = vs[2].trim(); - if(reduced.contains("|")) - reduced=reduced.split("\\|",2)[0].trim(); - if (reduced.equals("0")) - continue; - - String nextline = lines.get(countline+1); - int repeat=1; - if(nextline.contains(">> Disambiguation")&&nextline.contains("position at")){ - int start= nextline.indexOf("([")+2; - int end = nextline.indexOf("],"); - nextline=nextline.substring(start,end).trim(); - repeat=nextline.split(",").length; - } - - // for(int i=0; i lines = FileUtils.readList(tableminer_convergence_log, false); - - - for (String l : lines) { - - - if (l.contains("(QUERY_KB:")) { - String[] parts = l.trim().split(":"); - String value = parts[1].trim(); - String[] vs = value.split("\\s+"); - String initial = vs[0].trim(); - String reduced = vs[2].trim(); - if (reduced.equals("0")) - continue; - - p.println(initial + "," + reduced); - } - } - - - p.close(); - } - - - private static void calculate_entity_candidate_unique_for_calculating_running_time(String tableminer_convergence_log) throws IOException { - - List lines = FileUtils.readList(tableminer_convergence_log, false); - - Set all = new HashSet(); - for (String l : lines) { - - - if (l.contains("(QUERY_KB:")) { - String[] parts = l.trim().split(":"); - String value = parts[1].trim(); - String[] vs = value.split("\\s+"); - String initial = vs[0].trim(); - String reduced = vs[2].trim(); - if (reduced.equals("0")) - continue; - - if (reduced.contains("|")) { - try { - String ids = reduced.split("\\|")[1].trim(); - for (String id : ids.split(",")) { - if (id.trim().length() > 0) - all.add(id.trim()); - } - } catch (Exception e) { - continue; - } - } - //p.println(initial + "," + reduced); - } - } - System.out.println(all.size()); - } - - private static void calculate_entity_candidate_savings_update_only(String tableminer_convergence_log, - String outfile) throws IOException { - PrintWriter p = new PrintWriter(outfile); - p.println("Initial, Reduced to"); - - List lines = FileUtils.readList(tableminer_convergence_log, false); - - boolean count = false; - for (String l : lines) { - if (l.contains("BACKWARD UPDATE...")) { - count = false; - continue; - } - if (l.contains("LEARN (Consolidate) begins")) { - count = true; - continue; - } - - if (count && l.contains("(QUERY_KB:")) { - String[] parts = l.trim().split(":"); - String value = parts[1].trim(); - String[] vs = value.split("\\s+"); - String initial = vs[0].trim(); - String reduced = vs[2].trim(); - if (reduced.equals("0")) - continue; - - p.println(initial + "," + reduced); - } - } - - - p.close(); - } - - private static void calculate_average_query_time(String logfile) throws IOException { - List lines = FileUtils.readList(logfile, false); - long totalTime = 0; - int countQueries = 0; - for(String l: lines){ - if(l.contains("QueryFreebase")){ - int start =l.lastIndexOf(":")+1; - long time = Long.valueOf(l.substring(start).trim()); - totalTime=totalTime+time; - countQueries++; - } - } - System.out.println(totalTime+","+countQueries); - } - - private static void calculate_iterations_in_update(String tableminer_convergence_log, - String outfile) throws IOException { - PrintWriter p = new PrintWriter(outfile); - - List lines = FileUtils.readList(tableminer_convergence_log, false); - - boolean count = false; - for (String l : lines) { - if (l.contains("UPDATE STABLIZED AFTER")) { - String[] tokens = l.trim().split("\\s+"); - int index = 0; - for (int i = 0; i < tokens.length; i++) { - if (tokens[i].equals("AFTER")) - index = i + 1; - } - String itr = tokens[index].trim(); - p.println(Integer.valueOf(itr)); - } - } - p.close(); - - } - - private static void calculate_converge_column_interpretation - (String dataset, - String tableminer_convergence_log, - String outfile) throws IOException { - PrintWriter p = new PrintWriter(outfile); - p.println("convergence, max, savings"); - - List lines = FileUtils.readList(tableminer_convergence_log, false); - boolean started = false; - for (String l : lines) { - if (l.contains(dataset)) { - //new file - started = false; - continue; - } - if (l.contains("FORWARD LEARNING...")) { - started = true; - continue; - } - - if (started) { - if (l.contains("Convergence iteration")) { - String[] parts = l.trim().split(","); - String append = ""; - for (String value : parts) { - value = value.trim(); - if (value.length() == 0 || value.indexOf("=") == -1) continue; - String split = value.split("=")[1]; - append += split + ","; - } - p.println(append); - } - } - } - - - p.close(); - } - - public static int calculate_total_queries_issued_baseline(String sysoutFile) throws IOException { - int sum = 0; - List lines = FileUtils.readList(sysoutFile, false); - for (String l : lines) { - if (l.contains("(QUERY_KB:")) { - sum++; - int index = l.indexOf("=>"); - l = l.substring(index + 2).trim(); - int candidates = Integer.valueOf(l); - sum = sum + candidates; - } - } - System.out.println(sum); - return sum; - } - - public static int calculate_total_queries_issued_tableminer(String sysoutFile) throws IOException { - int sum = 0; - List lines = FileUtils.readList(sysoutFile, false); - - boolean count = false; - for (String l : lines) { - if (l.contains("FORWARD LEARNING")) { - count = true; - continue; - } - - if (count && l.contains("(QUERY_KB:")) { - sum++; - int index = l.indexOf("=>"); - l = l.substring(index + 2).trim(); - int candidates = Integer.valueOf(l); - sum = sum + candidates; - } - } - System.out.println(sum); - return sum; - } - - - //convergence time - public static void calculate_ws_converge(String logFile, String outFile) throws IOException { - PrintWriter p = new PrintWriter(outFile); - p.println("convergence, max, savings"); - List lines = FileUtils.readList(logFile, false); - for (String l : lines) { - if (l.contains("Convergence iteration")) { - String[] parts = l.trim().split(","); - String append = ""; - for (String value : parts) { - value = value.trim(); - if (value.length() == 0 || value.indexOf("=") == -1) continue; - String split = value.split("=")[1]; - append += split + ","; - } - p.println(append); - } - } - p.close(); - } - - /* public static void calcuate_update_stats_until_convergence(String logFile, String outputFile) throws IOException { - PrintWriter p = new PrintWriter(outputFile); - List lines = FileUtils.readList(logFile, false); - - String text_to_search = "UPDATE STABLIZED AFTER "; - for (String l : lines) { - if (l.contains(text_to_search)) { - int start = l.indexOf(text_to_search) + text_to_search.length(); - l = l.substring(start).trim(); - String iterations = l.split("\\s+")[0].trim(); - p.println(iterations); - } - } - p.close(); - - - }*/ - - -} +package uk.ac.shef.dcs.sti.todo.evaluation; + +import uk.ac.shef.dcs.sti.util.FileUtils; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * Created with IntelliJ IDEA. + * User: zqz + * Date: 23/02/14 + * Time: 21:45 + * To change this template use File | Settings | File Templates. + */ +public class DataStats { + + public static void main(String[] args) throws IOException { + /*calculate_average_query_time("D:\\Work\\lodie/lodie.LOG"); + System.exit(0);*/ + + /////////////////////////////////////////////// BING SEARCH CONVERGENCE //////////////////////////////////////////////////////////// + /*calculate_ws_converge("E:\\Data\\table_annotation\\efficiency_analysis_data\\SUBCOL_FINAL_limaye200_convergence.txt", + "D:\\Work\\lodie\\tmp_result/convergence_ws_limaye200.csv"); + calculate_ws_converge("E:\\Data\\table_annotation\\efficiency_analysis_data\\SUBCOL_FINAL_limayeall_convergence.txt", + "D:\\Work\\lodie\\tmp_result/convergence_ws_limayeall.csv"); + calculate_ws_converge("E:\\Data\\table_annotation\\efficiency_analysis_data\\SUBCOL_FINAL_musicbrainz_convergence.txt", + "D:\\Work\\lodie\\tmp_result/convergence_ws_musicbrainz.csv"); + + System.exit(0);*/ + + ///////////////////////////////////////////////---DONE--- i-inf CONVERGENCE in column interpretation//////////////////////////////////////////////////////////// + /*calculate_converge_column_interpretation( + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\raw", + "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200/random_nostop.LOG", + "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200/random_nostop.csv"); + calculate_converge_column_interpretation( + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\raw", + "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200/nonempty.LOG", + "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200/nonempty.csv"); + calculate_converge_column_interpretation( + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\raw", + "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200/tokens.LOG", + "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200/tokens.csv"); + calculate_converge_column_interpretation( + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\raw", + "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200/namelength.LOG", + "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200/namelength.csv"); + calculate_converge_column_interpretation( + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\raw", + "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200/random.LOG", + "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200/random.csv"); + calculate_converge_column_interpretation( + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\raw", + "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200/ospd_random.LOG", + "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200/ospd_random.csv"); + System.exit(0); + + + calculate_converge_column_interpretation( + "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200", + "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200/random.LOG", + "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200/random.csv"); + calculate_converge_column_interpretation( + "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200", + "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200/nonempty.LOG", + "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200/nonempty.csv"); + calculate_converge_column_interpretation( + "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200", + "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200/tokens.LOG", + "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200/tokens.csv"); + calculate_converge_column_interpretation( + "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200", + "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200/namelength.LOG", + "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200/namelength.csv"); + calculate_converge_column_interpretation( + "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200", + "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200/combined.LOG", + "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200/combined.csv"); + calculate_converge_column_interpretation( + "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200", + "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200/ospd_random.LOG", + "D:\\Work\\lodie\\tmp_result\\ospd_baseline\\limaye200/ospd_random.csv"); + System.exit(0); + + + + calculate_converge_column_interpretation( + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen", + "E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_limaye200_tm_sysout.txt", + "D:\\Work\\lodie\\tmp_result/learning_phase_converengece-limaye200-tm.csv"); + calculate_converge_column_interpretation( + "limaye/all", + "E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_limayeall_tm_sysout.LOG", + "D:\\Work\\lodie\\tmp_result/learning_phase_converengece-limayeall-tm.csv"); + calculate_converge_column_interpretation( + "musicbrainz_raw/", + "E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_mb_tm_sysout.LOG", + "D:\\Work\\lodie\\tmp_result/learning_phase_converengece-musicbrainz-tm.csv"); + calculate_converge_column_interpretation( + "imdb_raw/", + "E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_imdb_tm_sysout.LOG", + "D:\\Work\\lodie\\tmp_result/learning_phase_converengece-imdb-tm.csv"); + System.exit(0);*/ + + + /////////////////////////////////////////////// ---done--- Candidate counting (overall, runPreliminaryColumnClassifier-consolidate only, new entity at update, all entity at update) //////////////////////////////////////////////////////////// + calculate_entity_candidate_savings( + "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200\\random_nostop.LOG", + "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200\\candidate_savings_random_nostop.csv"); + calculate_entity_candidate_savings( + "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200\\random.LOG", + "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200\\candidate_savings_random.csv"); + calculate_entity_candidate_savings( + "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200\\ospd_random.LOG", + "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200\\candidate_savings_ospd_random.csv"); + calculate_entity_candidate_savings( + "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200\\nonempty.LOG", + "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200\\candidate_savings_nonempty.csv"); + calculate_entity_candidate_savings( + "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200\\tokens.LOG", + "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200\\candidate_savings_tokens.csv"); + calculate_entity_candidate_savings( + "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200\\namelength.LOG", + "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200\\candidate_savings_namelength.csv"); + + + + System.exit(0); + + + calculate_entity_candidate_savings( + "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_limaye200_tm_sysout.txt", + "D:\\Work\\lodie\\tmp_result\\entity_reduction_overall-limaye200-tm.csv"); + calculate_entity_candidate_savings_update_only( + "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_limaye200_tm_sysout.txt", + "D:\\Work\\lodie\\tmp_result\\entity_reduction_learning_consol-limaye200-tm.csv"); + calculate_new_entity_candidate_at_update( + "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_limaye200_tm_sysout.txt", + "D:\\Work\\lodie\\tmp_result/entity_new_in_update-limaye200-tm.csv" + ); + calculate_old_entity_candidate_at_update( + "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_limaye200_tm_sysout.txt", + "D:\\Work\\lodie\\tmp_result/entity_old_in_update-limaye200-tm.csv" + ); + + calculate_entity_candidate_savings( + "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_limayeall_tm_sysout.txt", + "D:\\Work\\lodie\\tmp_result\\entity_reduction_overall-limayeall-tm.csv"); + calculate_entity_candidate_savings_update_only( + "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_limayeall_tm_sysout.txt", + "D:\\Work\\lodie\\tmp_result\\entity_reduction_learning_consol-limayeall-tm.csv"); + calculate_new_entity_candidate_at_update( + "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_limayeall_tm_sysout.txt", + "D:\\Work\\lodie\\tmp_result/entity_new_in_update-limayeall-tm.csv" + ); + calculate_old_entity_candidate_at_update( + "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_limayeall_tm_sysout.txt", + "D:\\Work\\lodie\\tmp_result/entity_old_in_update-limayeall-tm.csv" + ); + + calculate_entity_candidate_savings( + "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_imdb_tm_sysout.txt", + "D:\\Work\\lodie\\tmp_result\\entity_reduction_overall-imdb-tm.csv"); + calculate_entity_candidate_savings_update_only( + "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_imdb_tm_sysout.txt", + "D:\\Work\\lodie\\tmp_result\\entity_reduction_learning_consol-imdb-tm.csv"); + calculate_new_entity_candidate_at_update( + "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_imdb_tm_sysout.txt", + "D:\\Work\\lodie\\tmp_result/entity_new_in_update-imdb-tm.csv" + ); + calculate_old_entity_candidate_at_update( + "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_imdb_tm_sysout.txt", + "D:\\Work\\lodie\\tmp_result/entity_old_in_update-imdb-tm.csv" + ); + + calculate_entity_candidate_savings( + "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_mb_tm_sysout.txt", + "D:\\Work\\lodie\\tmp_result\\entity_reduction_overall-musicbrainz-tm.csv"); + calculate_entity_candidate_savings_update_only( + "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_mb_tm_sysout.txt", + "D:\\Work\\lodie\\tmp_result\\entity_reduction_learning_consol-musicbrainz-tm.csv"); + calculate_new_entity_candidate_at_update( + "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_mb_tm_sysout.txt", + "D:\\Work\\lodie\\tmp_result/entity_new_in_update-musicbrainz-tm.csv" + ); + calculate_old_entity_candidate_at_update( + "E:\\Data\\table_annotation\\efficiency_analysis_data\\FINAL_mb_tm_sysout.txt", + "D:\\Work\\lodie\\tmp_result/entity_old_in_update-musicbrainz-tm.csv" + ); + System.exit(0); + + + /////////////////////////////////////////// -----------done ------------- candidate counting baseline ////////////////////////////////// + /*calculate_entity_candidate_savings_baseline("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_limaye200_bs_sl_sysout.txt", + "D:\\Work\\lodie\\tmp_result/candidate_entity_limaye200_bs_sl.csv"); + calculate_entity_candidate_savings_baseline("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_limayeall_bs_sl_sysout.txt", + "D:\\Work\\lodie\\tmp_result/candidate_entity_limayeall_bs_sl.csv"); + calculate_entity_candidate_savings_baseline("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_imdb_bs_sl_sysout.txt", + "D:\\Work\\lodie\\tmp_result/candidate_entity_imdb_bs_sl.csv"); + calculate_entity_candidate_savings_baseline("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_mb_bs_sl_sysout.txt", + "D:\\Work\\lodie\\tmp_result/candidate_entity_mb_bs_sl.csv"); + System.exit(0);*/ + + /////////////////////////////////////////// UNIQUE ENTITIES processed + /*calculate_entity_candidate_unique_for_calculating_running_time + ("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_limaye200_bs_sl_sysout.txt"); + calculate_entity_candidate_unique_for_calculating_running_time + ("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_limaye200_tm_sysout.txt");*/ + calculate_entity_candidate_unique_for_calculating_running_time + ("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_limayeall_bs_sl_sysout.txt"); + /*calculate_entity_candidate_unique_for_calculating_running_time + ("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_limayeall_tm_sysout.txt"); + calculate_entity_candidate_unique_for_calculating_running_time + ("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_mb_tm_sysout.txt"); + calculate_entity_candidate_unique_for_calculating_running_time + ("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_mb_base_sl_sysout.txt"); + calculate_entity_candidate_unique_for_calculating_running_time + ("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_imdb_tm_sysout.txt"); + calculate_entity_candidate_unique_for_calculating_running_time + ("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_imdb_base_sl_sysout.txt");*/ + System.exit(0); + + + /////////////////////////////////////////// ----- done ----- iterations at update + calculate_iterations_in_update("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_limaye200_tm_sysout.txt", + "D:\\Work\\lodie\\tmp_result/iterations_in_update-limaye200-tm.csv"); + calculate_iterations_in_update("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_limayeall_tm_sysout.txt", + "D:\\Work\\lodie\\tmp_result/iterations_in_update-limayeall-tm.csv"); + calculate_iterations_in_update("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_imdb_tm_sysout.txt", + "D:\\Work\\lodie\\tmp_result/iterations_in_update-imdb-tm.csv"); + calculate_iterations_in_update("E:\\Data\\table_annotation\\efficiency_analysis_data/FINAL_mb_tm_sysout.txt", + "D:\\Work\\lodie\\tmp_result/iterations_in_update-musicbrainz-tm.csv"); + + System.exit(0); + + + } + + private static void count_NE_cells(String in_system_out_file) throws IOException { + List lines = FileUtils.readList(in_system_out_file, false); + boolean stopCounting = false; + + int count = 0; + + int currentCol = -1; + int totalCol = 0; + int maxRow = 0; + for (String l : lines) { + + if (l.contains("_E:\\")) { + //System.out.println(l); + System.out.println(totalCol + "," + maxRow + "," + totalCol * maxRow); + + currentCol = -1; + totalCol = 0; + maxRow = 0; + //consolidate numbers + } + + if (l.contains(">> Column=")) { + String col = l.split("=")[1].trim(); + int c = Integer.valueOf(col) + 1; + if (c != currentCol) + totalCol++; + } + if (l.contains(" position at ")) { + int start_pos = l.indexOf("("); + String nl = l.substring(start_pos + 1); + int row = Integer.valueOf(nl.split(",")[0].trim()); + if (row > maxRow) + maxRow = row; + } + + if (l.contains("UPDATE ITERATION ")) + stopCounting = true; + if (l.contains("UPDATE STABLIZED AFTER")) + stopCounting = false; + + if (!stopCounting) { + if (l.contains(" position at (")) + count++; + } + } + System.out.println(totalCol + "," + maxRow + "," + totalCol * maxRow); + System.out.println(count); + } + + private static void calculate_new_entity_candidate_at_update(String tableminer_convergence_log, + String outfile) throws IOException { + PrintWriter p = new PrintWriter(outfile); + p.println("Initial, Reduced to"); + + List lines = FileUtils.readList(tableminer_convergence_log, false); + + boolean count = false; + + int initial = 0, reduced = 0; + for (String l : lines) { + if (l.contains("BACKWARD UPDATE...")) { + count = true; + continue; + } + if (l.contains("FORWARD LEARNING")) { + count = false; + continue; + } + + if (count && l.contains("(QUERY_KB:")) { + String[] parts = l.trim().split(":"); + String value = parts[1].trim(); + String[] vs = value.split("\\s+"); + initial = Integer.valueOf(vs[0].trim()); + reduced = Integer.valueOf(vs[2].trim()); + if (reduced == 0) { + initial = 0; + } + + continue; + } + + if (count && l.contains("ALREADY BUILT FOR")) { + String[] parts = l.trim().split("="); + int already = Integer.valueOf(parts[1].trim()); + int todo = reduced - already; + if (todo != 0) { + p.println(todo); + } + initial = 0; + reduced = 0; + } + } + + + p.close(); + } + + private static void calculate_old_entity_candidate_at_update(String tableminer_convergence_log, + String outfile) throws IOException { + PrintWriter p = new PrintWriter(outfile); + p.println("Initial, Reduced to"); + + List lines = FileUtils.readList(tableminer_convergence_log, false); + + boolean count = false; + + int initial = 0, reduced = 0; + for (String l : lines) { + if (l.contains("BACKWARD UPDATE...")) { + count = true; + continue; + } + if (l.contains("FORWARD LEARNING")) { + count = false; + continue; + } + + if (count && l.contains("(QUERY_KB:")) { + String[] parts = l.trim().split(":"); + String value = parts[1].trim(); + String[] vs = value.split("\\s+"); + initial = Integer.valueOf(vs[0].trim()); + reduced = Integer.valueOf(vs[2].trim()); + if (reduced == 0) { + continue; + } + p.println(reduced); + continue; + } + } + + + p.close(); + } + + private static void calculate_entity_candidate_savings(String tableminer_convergence_log, + String outfile) throws IOException { + PrintWriter p = new PrintWriter(outfile); + p.println("Initial, Reduced to"); + + List lines = FileUtils.readList(tableminer_convergence_log, false); + + boolean count = false; + int countline=-1; + for (String l : lines) { + countline++; + if (l.contains("BACKWARD UPDATE...")) { + count = false; + continue; + } + if (l.contains("FORWARD LEARNING")) { + count = true; + continue; + } + + if (count && l.contains("(QUERY_KB:")) { + String[] parts = l.trim().split(":"); + String value = parts[1].trim(); + String[] vs = value.split("\\s+"); + String initial = vs[0].trim(); + String reduced = vs[2].trim(); + if(reduced.contains("|")) + reduced=reduced.split("\\|",2)[0].trim(); + if (reduced.equals("0")) + continue; + + String nextline = lines.get(countline+1); + int repeat=1; + if(nextline.contains(">> Disambiguation")&&nextline.contains("position at")){ + int start= nextline.indexOf("([")+2; + int end = nextline.indexOf("],"); + nextline=nextline.substring(start,end).trim(); + repeat=nextline.split(",").length; + } + + // for(int i=0; i lines = FileUtils.readList(tableminer_convergence_log, false); + + + for (String l : lines) { + + + if (l.contains("(QUERY_KB:")) { + String[] parts = l.trim().split(":"); + String value = parts[1].trim(); + String[] vs = value.split("\\s+"); + String initial = vs[0].trim(); + String reduced = vs[2].trim(); + if (reduced.equals("0")) + continue; + + p.println(initial + "," + reduced); + } + } + + + p.close(); + } + + + private static void calculate_entity_candidate_unique_for_calculating_running_time(String tableminer_convergence_log) throws IOException { + + List lines = FileUtils.readList(tableminer_convergence_log, false); + + Set all = new HashSet(); + for (String l : lines) { + + + if (l.contains("(QUERY_KB:")) { + String[] parts = l.trim().split(":"); + String value = parts[1].trim(); + String[] vs = value.split("\\s+"); + String initial = vs[0].trim(); + String reduced = vs[2].trim(); + if (reduced.equals("0")) + continue; + + if (reduced.contains("|")) { + try { + String ids = reduced.split("\\|")[1].trim(); + for (String id : ids.split(",")) { + if (id.trim().length() > 0) + all.add(id.trim()); + } + } catch (Exception e) { + continue; + } + } + //p.println(initial + "," + reduced); + } + } + System.out.println(all.size()); + } + + private static void calculate_entity_candidate_savings_update_only(String tableminer_convergence_log, + String outfile) throws IOException { + PrintWriter p = new PrintWriter(outfile); + p.println("Initial, Reduced to"); + + List lines = FileUtils.readList(tableminer_convergence_log, false); + + boolean count = false; + for (String l : lines) { + if (l.contains("BACKWARD UPDATE...")) { + count = false; + continue; + } + if (l.contains("LEARN (Consolidate) begins")) { + count = true; + continue; + } + + if (count && l.contains("(QUERY_KB:")) { + String[] parts = l.trim().split(":"); + String value = parts[1].trim(); + String[] vs = value.split("\\s+"); + String initial = vs[0].trim(); + String reduced = vs[2].trim(); + if (reduced.equals("0")) + continue; + + p.println(initial + "," + reduced); + } + } + + + p.close(); + } + + private static void calculate_average_query_time(String logfile) throws IOException { + List lines = FileUtils.readList(logfile, false); + long totalTime = 0; + int countQueries = 0; + for(String l: lines){ + if(l.contains("QueryFreebase")){ + int start =l.lastIndexOf(":")+1; + long time = Long.valueOf(l.substring(start).trim()); + totalTime=totalTime+time; + countQueries++; + } + } + System.out.println(totalTime+","+countQueries); + } + + private static void calculate_iterations_in_update(String tableminer_convergence_log, + String outfile) throws IOException { + PrintWriter p = new PrintWriter(outfile); + + List lines = FileUtils.readList(tableminer_convergence_log, false); + + boolean count = false; + for (String l : lines) { + if (l.contains("UPDATE STABLIZED AFTER")) { + String[] tokens = l.trim().split("\\s+"); + int index = 0; + for (int i = 0; i < tokens.length; i++) { + if (tokens[i].equals("AFTER")) + index = i + 1; + } + String itr = tokens[index].trim(); + p.println(Integer.valueOf(itr)); + } + } + p.close(); + + } + + private static void calculate_converge_column_interpretation + (String dataset, + String tableminer_convergence_log, + String outfile) throws IOException { + PrintWriter p = new PrintWriter(outfile); + p.println("convergence, max, savings"); + + List lines = FileUtils.readList(tableminer_convergence_log, false); + boolean started = false; + for (String l : lines) { + if (l.contains(dataset)) { + //new file + started = false; + continue; + } + if (l.contains("FORWARD LEARNING...")) { + started = true; + continue; + } + + if (started) { + if (l.contains("Convergence iteration")) { + String[] parts = l.trim().split(","); + String append = ""; + for (String value : parts) { + value = value.trim(); + if (value.length() == 0 || value.indexOf("=") == -1) continue; + String split = value.split("=")[1]; + append += split + ","; + } + p.println(append); + } + } + } + + + p.close(); + } + + public static int calculate_total_queries_issued_baseline(String sysoutFile) throws IOException { + int sum = 0; + List lines = FileUtils.readList(sysoutFile, false); + for (String l : lines) { + if (l.contains("(QUERY_KB:")) { + sum++; + int index = l.indexOf("=>"); + l = l.substring(index + 2).trim(); + int candidates = Integer.valueOf(l); + sum = sum + candidates; + } + } + System.out.println(sum); + return sum; + } + + public static int calculate_total_queries_issued_tableminer(String sysoutFile) throws IOException { + int sum = 0; + List lines = FileUtils.readList(sysoutFile, false); + + boolean count = false; + for (String l : lines) { + if (l.contains("FORWARD LEARNING")) { + count = true; + continue; + } + + if (count && l.contains("(QUERY_KB:")) { + sum++; + int index = l.indexOf("=>"); + l = l.substring(index + 2).trim(); + int candidates = Integer.valueOf(l); + sum = sum + candidates; + } + } + System.out.println(sum); + return sum; + } + + + //convergence time + public static void calculate_ws_converge(String logFile, String outFile) throws IOException { + PrintWriter p = new PrintWriter(outFile); + p.println("convergence, max, savings"); + List lines = FileUtils.readList(logFile, false); + for (String l : lines) { + if (l.contains("Convergence iteration")) { + String[] parts = l.trim().split(","); + String append = ""; + for (String value : parts) { + value = value.trim(); + if (value.length() == 0 || value.indexOf("=") == -1) continue; + String split = value.split("=")[1]; + append += split + ","; + } + p.println(append); + } + } + p.close(); + } + + /* public static void calcuate_update_stats_until_convergence(String logFile, String outputFile) throws IOException { + PrintWriter p = new PrintWriter(outputFile); + List lines = FileUtils.readList(logFile, false); + + String text_to_search = "UPDATE STABLIZED AFTER "; + for (String l : lines) { + if (l.contains(text_to_search)) { + int start = l.indexOf(text_to_search) + text_to_search.length(); + l = l.substring(start).trim(); + String iterations = l.split("\\s+")[0].trim(); + p.println(iterations); + } + } + p.close(); + + + }*/ + + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_LimayeNew.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_LimayeNew.java index 1fa161a8..d3589432 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_LimayeNew.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_LimayeNew.java @@ -1,250 +1,250 @@ -package uk.ac.shef.dcs.sti.todo.evaluation; - -import org.apache.any23.extractor.html.DomUtils; -import org.apache.any23.util.FileUtils; -import org.apache.commons.io.filefilter.SuffixFileFilter; -import org.apache.commons.lang3.StringEscapeUtils; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; -import uk.ac.shef.dcs.sti.STIEnum; -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.TColumnHeader; -import uk.ac.shef.dcs.sti.core.model.Table; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import java.io.*; -import java.util.*; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 29/04/14 - * Time: 12:09 - * To change this template use File | Settings | File Templates. - */ -public class DataStats_TableSize_NameLength_Analysis_LimayeNew { - public static void main(String[] args) throws IOException, SAXException, ParserConfigurationException { - - /////////////limayeall - String cleanTableRepos = // "E:\\Data\\table_annotation\\limaye\\all_tables_raw(regen)"; - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\raw"; - String annotationRepos = "E:\\Data\\table_annotation\\limaye\\all_tables_groundtruth_freebase(regen)"; - - File[] files = FileUtils.listFilesRecursively(new File(cleanTableRepos), new SuffixFileFilter(".xml")); - int count = 0; - for (File clean : files) { - String path = clean.getAbsolutePath().replaceAll("\\\\", "/"); - String relative = path.substring(cleanTableRepos.length()); - - String annotated = annotationRepos + relative + ".cell.keys"; - if (!(new File(annotated)).exists()) { - //System.err.println("annotated file does not exist: " + annotated); - continue; - } - - count++; - System.out.println(count); - - PrintWriter p = new PrintWriter(new FileWriter("D:\\Work\\lodie\\tmp_result/out.csv", true)); - PrintWriter p2 = new PrintWriter(new FileWriter("D:\\Work\\lodie\\tmp_result/out_name.csv", true)); - try{ - checkGroundTruth(clean.toString(), annotated, p, p2); - }catch(Exception e){ - e.printStackTrace(); - } - p.close(); - p2.close(); - } - - /*Table table = readTable("E:\\data\\table annotation\\tablesForAnnotation\\wikitables\\c3\\r12\\y\\e\\l/Yellowknife.html_0.xml", - "E:\\data\\table annotation\\workspace\\WWT_GroundTruth\\annotation\\wikitables\\c3\\r12\\y\\e\\l/Yellowknife.html_0.xml", - "D:\\work\\lodiedata\\limayetable");*/ - System.out.println(); - } - - //tableAnnotationFileanem and htmlRepository can both be null, then they are ignored - public static Table checkGroundTruth(String tableFilename, String tableAnnotationFilename, PrintWriter p, - PrintWriter p2) throws IOException, ParserConfigurationException, SAXException { - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - - DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); - Document domCleanTable = docBuilder.parse(tableFilename); - - //read the table content - List tableContent = DomUtils.findAll(domCleanTable, "//logicalTable/content"); - if (tableContent == null || tableContent.size() == 0) - return null; - boolean firstRowHeader = false; - List rows = new ArrayList(); - List rows_with_other_text = new ArrayList(); - NodeList rowNodes = tableContent.get(0).getChildNodes(); - - for (int i = 0; i < rowNodes.getLength(); i++) { - Node row = rowNodes.item(i); - if (row.getNodeName().equals("#text")) - continue; - if (row.getNodeName().equals("header")) { - firstRowHeader = true; - } - - List columns = DomUtils.findAll(row, "cell"); - String[] cells = new String[columns.size()]; - String[] cells_other_text = new String[columns.size()]; - for (int j = 0; j < columns.size(); j++) { - Node cell = columns.get(j); - List html = DomUtils.findAll(cell, "html"); - String textContent = ""; - if (html != null && html.size() > 0) { - textContent = extract_text_content_from_html(html); - } - - if (textContent.equals("")) { - List text = DomUtils.findAll(cell, "text"); - - if (text != null && text.size() > 0) { - textContent = text.get(0).getTextContent(); - } - } - - List other_text = DomUtils.findAll(cell, "wikipedia"); - if (other_text != null && other_text.size() > 0) { - String othertextContent = extract_text_content_from_html(other_text); - cells_other_text[j] = othertextContent; - } - cells[j] = textContent; - } - rows.add(cells); - rows_with_other_text.add(cells_other_text); - } - - int totalCol = 0; - for (String[] row : rows) { - if (row.length > totalCol) - totalCol = row.length; - } - - Table table = null; - int rowModifier = 0; - if (firstRowHeader) { - table = new Table(String.valueOf(tableFilename.hashCode()), tableFilename, rows.size() - 1, totalCol); - rowModifier = 1; - if (rows.get(0).length < totalCol) { - System.err.println("WARNING:Artificial header added, check manually. " + tableFilename); - String[] headers = rows.get(0); - String[] modified = new String[totalCol]; - for (int i = 0; i < modified.length; i++) { - if (i < headers.length) - modified[i] = headers[i]; - else - modified[i] = STIEnum.TABLE_HEADER_UNKNOWN.getValue(); - } - rows.set(0, modified); - } - for (int j = 0; j < totalCol; j++) { - TColumnHeader header = new TColumnHeader(rows.get(0)[j]); - table.setColumnHeader(j, header); - } - } else {//no header, need to add false headers - table = new Table(String.valueOf(tableFilename.hashCode()), tableFilename, rows.size(), totalCol); - for (int j = 0; j < totalCol; j++) { - TColumnHeader header = new TColumnHeader(STIEnum.TABLE_HEADER_UNKNOWN.getValue()); - table.setColumnHeader(j, header); - } - } - - for (int r = rowModifier; r < rows.size(); r++) { - String[] cells = rows.get(r); - String[] cells_other_text = rows_with_other_text.get(r); - for (int c = 0; c < cells.length; c++) { - TCell cell = new TCell(cells[c]); - String other = cells_other_text[c]; - if(other!=null&&other.length()>0) - cell.setOtherText(other); - table.setContentCell(r - rowModifier, c, cell); - } - } - - if (tableAnnotationFilename == null) - return table; - - - if (new File(tableAnnotationFilename).exists()) { - String[] entity_annotations = FileUtils.readFileLines(new File(tableAnnotationFilename)); - - Set columns_with_annotations = new HashSet(); - Set rows_with_annotations = new HashSet(); - for (String l : entity_annotations) { - if (l.trim().length() < 1) - continue; - String position = l.split("=")[0].trim(); - int i = Integer.valueOf(position.split(",")[0].trim()); - int j = Integer.valueOf(position.split(",")[1].trim()); - columns_with_annotations.add(j); - rows_with_annotations.add(i); - String textContent = table.getContentCell(i, j).getText(); - int length = 0; - if (textContent.length() > 20 && !textContent.contains(" ") && textContent.contains("/")) { - length = 0; //url, long string - } else { - textContent = textContent.replaceAll("[\\-_]"," ").trim(); - - ////////////////////////printing average name length ///////////////////////// - length = textContent.split("\\s+").length; - if (length > 10) { - textContent = table.getContentCell(i, j).getOtherText(); - textContent = textContent.replaceAll("[\\-_]"," ").trim(); - - if (textContent.length() > 0) { - length = textContent.split("\\s+").length; - if (length != 0) - System.out.print("."); - } - } - } - - p2.println(length); - if (length > 10) - System.out.println(">10:" + tableFilename); - if (length > 20) - System.out.println(">20:" + tableFilename); - if (length > 120) - System.out.println(">120:" + tableFilename); - } - - //printing num of rows, and columns that have entity annotations - if (columns_with_annotations.size() > 6) - System.out.println("c>6:" + tableFilename); - if (columns_with_annotations.size() > 10) - System.out.println("c>6:" + tableFilename); - p.println(rows_with_annotations.size() + "," + columns_with_annotations.size()); - } - return table; - } - - private static String extract_text_content_from_html(List html) { - String content = html.get(0).getTextContent(); - int start = content.indexOf(""); - if (start != -1) { - content = content.substring(start + 4); - int end = content.indexOf(""); - if (end == -1) - end = content.indexOf(""); - if (end == -1) - end = content.indexOf(""); - if (end != -1) - content = content.substring(0, end).trim(); - } - content = StringEscapeUtils.unescapeHtml4(content); - return content; - } - - -} +package uk.ac.shef.dcs.sti.todo.evaluation; + +import org.apache.any23.extractor.html.DomUtils; +import org.apache.any23.util.FileUtils; +import org.apache.commons.io.filefilter.SuffixFileFilter; +import org.apache.commons.lang3.StringEscapeUtils; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; +import uk.ac.shef.dcs.sti.STIEnum; +import uk.ac.shef.dcs.sti.core.model.TCell; +import uk.ac.shef.dcs.sti.core.model.TColumnHeader; +import uk.ac.shef.dcs.sti.core.model.Table; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import java.io.*; +import java.util.*; + +/** + * Created with IntelliJ IDEA. + * User: zqz + * Date: 29/04/14 + * Time: 12:09 + * To change this template use File | Settings | File Templates. + */ +public class DataStats_TableSize_NameLength_Analysis_LimayeNew { + public static void main(String[] args) throws IOException, SAXException, ParserConfigurationException { + + /////////////limayeall + String cleanTableRepos = // "E:\\Data\\table_annotation\\limaye\\all_tables_raw(regen)"; + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\raw"; + String annotationRepos = "E:\\Data\\table_annotation\\limaye\\all_tables_groundtruth_freebase(regen)"; + + File[] files = FileUtils.listFilesRecursively(new File(cleanTableRepos), new SuffixFileFilter(".xml")); + int count = 0; + for (File clean : files) { + String path = clean.getAbsolutePath().replaceAll("\\\\", "/"); + String relative = path.substring(cleanTableRepos.length()); + + String annotated = annotationRepos + relative + ".cell.keys"; + if (!(new File(annotated)).exists()) { + //System.err.println("annotated file does not exist: " + annotated); + continue; + } + + count++; + System.out.println(count); + + PrintWriter p = new PrintWriter(new FileWriter("D:\\Work\\lodie\\tmp_result/out.csv", true)); + PrintWriter p2 = new PrintWriter(new FileWriter("D:\\Work\\lodie\\tmp_result/out_name.csv", true)); + try{ + checkGroundTruth(clean.toString(), annotated, p, p2); + }catch(Exception e){ + e.printStackTrace(); + } + p.close(); + p2.close(); + } + + /*Table table = readTable("E:\\data\\table annotation\\tablesForAnnotation\\wikitables\\c3\\r12\\y\\e\\l/Yellowknife.html_0.xml", + "E:\\data\\table annotation\\workspace\\WWT_GroundTruth\\annotation\\wikitables\\c3\\r12\\y\\e\\l/Yellowknife.html_0.xml", + "D:\\work\\lodiedata\\limayetable");*/ + System.out.println(); + } + + //tableAnnotationFileanem and htmlRepository can both be null, then they are ignored + public static Table checkGroundTruth(String tableFilename, String tableAnnotationFilename, PrintWriter p, + PrintWriter p2) throws IOException, ParserConfigurationException, SAXException { + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + + DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); + Document domCleanTable = docBuilder.parse(tableFilename); + + //read the table content + List tableContent = DomUtils.findAll(domCleanTable, "//logicalTable/content"); + if (tableContent == null || tableContent.size() == 0) + return null; + boolean firstRowHeader = false; + List rows = new ArrayList(); + List rows_with_other_text = new ArrayList(); + NodeList rowNodes = tableContent.get(0).getChildNodes(); + + for (int i = 0; i < rowNodes.getLength(); i++) { + Node row = rowNodes.item(i); + if (row.getNodeName().equals("#text")) + continue; + if (row.getNodeName().equals("header")) { + firstRowHeader = true; + } + + List columns = DomUtils.findAll(row, "cell"); + String[] cells = new String[columns.size()]; + String[] cells_other_text = new String[columns.size()]; + for (int j = 0; j < columns.size(); j++) { + Node cell = columns.get(j); + List html = DomUtils.findAll(cell, "html"); + String textContent = ""; + if (html != null && html.size() > 0) { + textContent = extract_text_content_from_html(html); + } + + if (textContent.equals("")) { + List text = DomUtils.findAll(cell, "text"); + + if (text != null && text.size() > 0) { + textContent = text.get(0).getTextContent(); + } + } + + List other_text = DomUtils.findAll(cell, "wikipedia"); + if (other_text != null && other_text.size() > 0) { + String othertextContent = extract_text_content_from_html(other_text); + cells_other_text[j] = othertextContent; + } + cells[j] = textContent; + } + rows.add(cells); + rows_with_other_text.add(cells_other_text); + } + + int totalCol = 0; + for (String[] row : rows) { + if (row.length > totalCol) + totalCol = row.length; + } + + Table table = null; + int rowModifier = 0; + if (firstRowHeader) { + table = new Table(String.valueOf(tableFilename.hashCode()), tableFilename, rows.size() - 1, totalCol); + rowModifier = 1; + if (rows.get(0).length < totalCol) { + System.err.println("WARNING:Artificial header added, check manually. " + tableFilename); + String[] headers = rows.get(0); + String[] modified = new String[totalCol]; + for (int i = 0; i < modified.length; i++) { + if (i < headers.length) + modified[i] = headers[i]; + else + modified[i] = STIEnum.TABLE_HEADER_UNKNOWN.getValue(); + } + rows.set(0, modified); + } + for (int j = 0; j < totalCol; j++) { + TColumnHeader header = new TColumnHeader(rows.get(0)[j]); + table.setColumnHeader(j, header); + } + } else {//no header, need to add false headers + table = new Table(String.valueOf(tableFilename.hashCode()), tableFilename, rows.size(), totalCol); + for (int j = 0; j < totalCol; j++) { + TColumnHeader header = new TColumnHeader(STIEnum.TABLE_HEADER_UNKNOWN.getValue()); + table.setColumnHeader(j, header); + } + } + + for (int r = rowModifier; r < rows.size(); r++) { + String[] cells = rows.get(r); + String[] cells_other_text = rows_with_other_text.get(r); + for (int c = 0; c < cells.length; c++) { + TCell cell = new TCell(cells[c]); + String other = cells_other_text[c]; + if(other!=null&&other.length()>0) + cell.setOtherText(other); + table.setContentCell(r - rowModifier, c, cell); + } + } + + if (tableAnnotationFilename == null) + return table; + + + if (new File(tableAnnotationFilename).exists()) { + String[] entity_annotations = FileUtils.readFileLines(new File(tableAnnotationFilename)); + + Set columns_with_annotations = new HashSet(); + Set rows_with_annotations = new HashSet(); + for (String l : entity_annotations) { + if (l.trim().length() < 1) + continue; + String position = l.split("=")[0].trim(); + int i = Integer.valueOf(position.split(",")[0].trim()); + int j = Integer.valueOf(position.split(",")[1].trim()); + columns_with_annotations.add(j); + rows_with_annotations.add(i); + String textContent = table.getContentCell(i, j).getText(); + int length = 0; + if (textContent.length() > 20 && !textContent.contains(" ") && textContent.contains("/")) { + length = 0; //url, long string + } else { + textContent = textContent.replaceAll("[\\-_]"," ").trim(); + + ////////////////////////printing average name length ///////////////////////// + length = textContent.split("\\s+").length; + if (length > 10) { + textContent = table.getContentCell(i, j).getOtherText(); + textContent = textContent.replaceAll("[\\-_]"," ").trim(); + + if (textContent.length() > 0) { + length = textContent.split("\\s+").length; + if (length != 0) + System.out.print("."); + } + } + } + + p2.println(length); + if (length > 10) + System.out.println(">10:" + tableFilename); + if (length > 20) + System.out.println(">20:" + tableFilename); + if (length > 120) + System.out.println(">120:" + tableFilename); + } + + //printing num of rows, and columns that have entity annotations + if (columns_with_annotations.size() > 6) + System.out.println("c>6:" + tableFilename); + if (columns_with_annotations.size() > 10) + System.out.println("c>6:" + tableFilename); + p.println(rows_with_annotations.size() + "," + columns_with_annotations.size()); + } + return table; + } + + private static String extract_text_content_from_html(List html) { + String content = html.get(0).getTextContent(); + int start = content.indexOf(""); + if (start != -1) { + content = content.substring(start + 4); + int end = content.indexOf(""); + if (end == -1) + end = content.indexOf(""); + if (end == -1) + end = content.indexOf(""); + if (end != -1) + content = content.substring(0, end).trim(); + } + content = StringEscapeUtils.unescapeHtml4(content); + return content; + } + + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_MB_IMDB.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_MB_IMDB.java index adf72692..244ff16d 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_MB_IMDB.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Analysis_MB_IMDB.java @@ -1,160 +1,160 @@ -package uk.ac.shef.dcs.sti.todo.evaluation; - -import org.apache.any23.util.FileUtils; -import org.apache.commons.lang3.StringEscapeUtils; -import org.w3c.dom.Node; -import org.xml.sax.SAXException; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.parser.table.TableParser; -import uk.ac.shef.dcs.sti.parser.table.TableParserMusicBrainz; -import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreatorMusicBrainz; -import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetectorByHTMLTag; -import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizerSimple; -import uk.ac.shef.dcs.sti.parser.table.validator.TableValidatorGeneric; - -import javax.xml.parsers.ParserConfigurationException; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 29/04/14 - * Time: 12:37 - * To change this template use File | Settings | File Templates. - */ -public class DataStats_TableSize_NameLength_Analysis_MB_IMDB { - - private static TableParser xtractor; - - public static void main(String[] args) throws IOException, SAXException, ParserConfigurationException, STIException { - - /////////////imdb - /*String cleanTableRepos = "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\raw\\imdb_raw"; - String annotationRepos = "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs\\imdb_gs(entity)_reformatted"; - xtractor = new TableXtractorIMDB(new TableNormalizerFrequentRowLength(true), - new TableHODetectorByHTMLTag(), - new TableObjCreatorIMDB(), - new TabValGeneric());*/ - - //////////////musicbrainz - String cleanTableRepos = "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\raw"; - String annotationRepos = "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs\\musicbrainz_gs(entity)_reformatted"; - xtractor = new TableParserMusicBrainz(new TableNormalizerSimple(), - new TableHODetectorByHTMLTag(), - new TableObjCreatorMusicBrainz(), - new TableValidatorGeneric()); - - - File[] files = new File(cleanTableRepos).listFiles(); - int count = 0; - for (File clean : files) { - String path = clean.getAbsolutePath().replaceAll("\\\\", "/"); - String relative = path.substring(cleanTableRepos.length()); - - String annotated = annotationRepos + relative + ".keys"; - if (!(new File(annotated)).exists()) { - //System.err.println("annotated file does not exist: " + annotated); - continue; - } - - count++; - System.out.println(count); - - PrintWriter p = new PrintWriter(new FileWriter("D:\\Work\\lodie\\tmp_result/out.csv", true)); - PrintWriter p2 = new PrintWriter(new FileWriter("D:\\Work\\lodie\\tmp_result/out_name.csv", true)); - checkGroundTruth(clean.toString(), annotated, p, p2); - p.close(); - p2.close(); - } - - /*Table table = readTable("E:\\data\\table annotation\\tablesForAnnotation\\wikitables\\c3\\r12\\y\\e\\l/Yellowknife.html_0.xml", - "E:\\data\\table annotation\\workspace\\WWT_GroundTruth\\annotation\\wikitables\\c3\\r12\\y\\e\\l/Yellowknife.html_0.xml", - "D:\\work\\lodiedata\\limayetable");*/ - System.out.println(); - } - - //tableAnnotationFileanem and htmlRepository can both be null, then they are ignored - public static Table checkGroundTruth(String tableFilename, String tableAnnotationFilename, PrintWriter p, - PrintWriter p2) throws IOException, ParserConfigurationException, SAXException, STIException { - - Table table = null; - String fileContent = FileUtils.readFileContent(new File(tableFilename)); - List
"); - if (start == -1) - start = content.indexOf(""); - if (start == -1) - start = content.indexOf("
"); + if (start == -1) + start = content.indexOf(""); + if (start == -1) + start = content.indexOf("
tables = xtractor.extract(fileContent, tableFilename); - if (tables.size() > 0) { - table = tables.get(0); - - - if (tableAnnotationFilename == null) - return table; - - - if (new File(tableAnnotationFilename).exists()) { - String[] entity_annotations = FileUtils.readFileLines(new File(tableAnnotationFilename)); - - Set columns_with_annotations = new HashSet(); - Set rows_with_annotations = new HashSet(); - for (String l : entity_annotations) { - if (l.trim().length() < 1) - continue; - String position = l.split("=")[0].trim(); - int i = Integer.valueOf(position.split(",")[0].trim()); - int j = Integer.valueOf(position.split(",")[1].trim()); - columns_with_annotations.add(j); - rows_with_annotations.add(i); - String textContent = table.getContentCell(i, j).getText(); - textContent = textContent.replaceAll("[\\-_]"," ").trim(); - - ////////////////////////printing average name length ///////////////////////// - int length =textContent.split("\\s+").length; - p2.println(length); - - if (length > 10) - System.out.println(">10:" + tableFilename); - if (length > 20) - System.out.println(">20:" + tableFilename); - if (length > 120) - System.out.println(">120:" + tableFilename); - } - - //printing num of rows, and columns that have entity annotations - p.println(rows_with_annotations.size() + "," + columns_with_annotations.size()); - if (columns_with_annotations.size() > 6) - System.out.println("c>6:" + tableFilename); - if (columns_with_annotations.size() > 10) - System.out.println("c>6:" + tableFilename); - //p.println(rows_with_annotations.size() + "," + columns_with_annotations.size()); - } - return table; - } - return null; - } - - private static String extract_text_content_from_html(List html) { - String content = html.get(0).getTextContent(); - int start = content.indexOf(""); - if (start != -1) { - content = content.substring(start + 4); - int end = content.indexOf(""); - if (end == -1) - end = content.indexOf(""); - if (end == -1) - end = content.indexOf(""); - if (end != -1) - content = content.substring(0, end).trim(); - } - content = StringEscapeUtils.unescapeHtml4(content); - return content; - } - -} +package uk.ac.shef.dcs.sti.todo.evaluation; + +import org.apache.any23.util.FileUtils; +import org.apache.commons.lang3.StringEscapeUtils; +import org.w3c.dom.Node; +import org.xml.sax.SAXException; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.parser.table.TableParser; +import uk.ac.shef.dcs.sti.parser.table.TableParserMusicBrainz; +import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreatorMusicBrainz; +import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetectorByHTMLTag; +import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizerSimple; +import uk.ac.shef.dcs.sti.parser.table.validator.TableValidatorGeneric; + +import javax.xml.parsers.ParserConfigurationException; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * Created with IntelliJ IDEA. + * User: zqz + * Date: 29/04/14 + * Time: 12:37 + * To change this template use File | Settings | File Templates. + */ +public class DataStats_TableSize_NameLength_Analysis_MB_IMDB { + + private static TableParser xtractor; + + public static void main(String[] args) throws IOException, SAXException, ParserConfigurationException, STIException { + + /////////////imdb + /*String cleanTableRepos = "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\raw\\imdb_raw"; + String annotationRepos = "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs\\imdb_gs(entity)_reformatted"; + xtractor = new TableXtractorIMDB(new TableNormalizerFrequentRowLength(true), + new TableHODetectorByHTMLTag(), + new TableObjCreatorIMDB(), + new TabValGeneric());*/ + + //////////////musicbrainz + String cleanTableRepos = "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\raw"; + String annotationRepos = "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs\\musicbrainz_gs(entity)_reformatted"; + xtractor = new TableParserMusicBrainz(new TableNormalizerSimple(), + new TableHODetectorByHTMLTag(), + new TableObjCreatorMusicBrainz(), + new TableValidatorGeneric()); + + + File[] files = new File(cleanTableRepos).listFiles(); + int count = 0; + for (File clean : files) { + String path = clean.getAbsolutePath().replaceAll("\\\\", "/"); + String relative = path.substring(cleanTableRepos.length()); + + String annotated = annotationRepos + relative + ".keys"; + if (!(new File(annotated)).exists()) { + //System.err.println("annotated file does not exist: " + annotated); + continue; + } + + count++; + System.out.println(count); + + PrintWriter p = new PrintWriter(new FileWriter("D:\\Work\\lodie\\tmp_result/out.csv", true)); + PrintWriter p2 = new PrintWriter(new FileWriter("D:\\Work\\lodie\\tmp_result/out_name.csv", true)); + checkGroundTruth(clean.toString(), annotated, p, p2); + p.close(); + p2.close(); + } + + /*Table table = readTable("E:\\data\\table annotation\\tablesForAnnotation\\wikitables\\c3\\r12\\y\\e\\l/Yellowknife.html_0.xml", + "E:\\data\\table annotation\\workspace\\WWT_GroundTruth\\annotation\\wikitables\\c3\\r12\\y\\e\\l/Yellowknife.html_0.xml", + "D:\\work\\lodiedata\\limayetable");*/ + System.out.println(); + } + + //tableAnnotationFileanem and htmlRepository can both be null, then they are ignored + public static Table checkGroundTruth(String tableFilename, String tableAnnotationFilename, PrintWriter p, + PrintWriter p2) throws IOException, ParserConfigurationException, SAXException, STIException { + + Table table = null; + String fileContent = FileUtils.readFileContent(new File(tableFilename)); + List
"); - if (start == -1) - start = content.indexOf(""); - if (start == -1) - start = content.indexOf("
tables = xtractor.extract(fileContent, tableFilename); + if (tables.size() > 0) { + table = tables.get(0); + + + if (tableAnnotationFilename == null) + return table; + + + if (new File(tableAnnotationFilename).exists()) { + String[] entity_annotations = FileUtils.readFileLines(new File(tableAnnotationFilename)); + + Set columns_with_annotations = new HashSet(); + Set rows_with_annotations = new HashSet(); + for (String l : entity_annotations) { + if (l.trim().length() < 1) + continue; + String position = l.split("=")[0].trim(); + int i = Integer.valueOf(position.split(",")[0].trim()); + int j = Integer.valueOf(position.split(",")[1].trim()); + columns_with_annotations.add(j); + rows_with_annotations.add(i); + String textContent = table.getContentCell(i, j).getText(); + textContent = textContent.replaceAll("[\\-_]"," ").trim(); + + ////////////////////////printing average name length ///////////////////////// + int length =textContent.split("\\s+").length; + p2.println(length); + + if (length > 10) + System.out.println(">10:" + tableFilename); + if (length > 20) + System.out.println(">20:" + tableFilename); + if (length > 120) + System.out.println(">120:" + tableFilename); + } + + //printing num of rows, and columns that have entity annotations + p.println(rows_with_annotations.size() + "," + columns_with_annotations.size()); + if (columns_with_annotations.size() > 6) + System.out.println("c>6:" + tableFilename); + if (columns_with_annotations.size() > 10) + System.out.println("c>6:" + tableFilename); + //p.println(rows_with_annotations.size() + "," + columns_with_annotations.size()); + } + return table; + } + return null; + } + + private static String extract_text_content_from_html(List html) { + String content = html.get(0).getTextContent(); + int start = content.indexOf(""); + if (start != -1) { + content = content.substring(start + 4); + int end = content.indexOf(""); + if (end == -1) + end = content.indexOf(""); + if (end == -1) + end = content.indexOf(""); + if (end != -1) + content = content.substring(0, end).trim(); + } + content = StringEscapeUtils.unescapeHtml4(content); + return content; + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Anaylsis_LimayeOld.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Anaylsis_LimayeOld.java index 749bb2d4..985eb5fc 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Anaylsis_LimayeOld.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/DataStats_TableSize_NameLength_Anaylsis_LimayeOld.java @@ -1,288 +1,288 @@ -package uk.ac.shef.dcs.sti.todo.evaluation; - -import org.apache.any23.extractor.html.DomUtils; -import org.apache.any23.util.FileUtils; -import org.apache.commons.io.filefilter.SuffixFileFilter; -import org.apache.commons.lang3.StringEscapeUtils; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; -import uk.ac.shef.dcs.kbsearch.model.Clazz; -import uk.ac.shef.dcs.sti.STIEnum; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.sti.core.model.*; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.*; -import java.util.List; - -/** - */ -public class DataStats_TableSize_NameLength_Anaylsis_LimayeOld { - - public static void main(String[] args) throws IOException, SAXException, ParserConfigurationException { - String cleanTableRepos = "E:\\Data\\table_annotation\\limaye\\all_tables_raw(limaye_original)"; - String annotationRepos = "E:\\Data\\table_annotation\\limaye\\all_tables_groundtruth_xml(limaye_original)"; - - PrintWriter nlPrinter = new PrintWriter("D:\\Work\\lodie\\tmp_result/nl.csv"); - PrintWriter rows_col_with_ne_Printer = new PrintWriter("D:\\Work\\lodie\\tmp_result/rows_cols.csv"); - - File[] files = FileUtils.listFilesRecursively(new File(cleanTableRepos), new SuffixFileFilter(".xml")); - for (File clean : files) { - String path = clean.getAbsolutePath().replaceAll("\\\\", "/"); - String relative = path.substring(cleanTableRepos.length()); - - String annotated = annotationRepos + relative; - if (!(new File(annotated)).exists()) { - System.err.println("annotated file does not exist: " + annotated); - continue; - } - - System.out.println(annotated); - - checkGroundTruthLimaye(clean.toString(), annotated, nlPrinter, rows_col_with_ne_Printer); - } - - /*Table table = readTable("E:\\data\\table annotation\\tablesForAnnotation\\wikitables\\c3\\r12\\y\\e\\l/Yellowknife.html_0.xml", - "E:\\data\\table annotation\\workspace\\WWT_GroundTruth\\annotation\\wikitables\\c3\\r12\\y\\e\\l/Yellowknife.html_0.xml", - "D:\\work\\lodiedata\\limayetable");*/ - System.out.println(); - nlPrinter.close(); - rows_col_with_ne_Printer.close(); - } - - //tableAnnotationFileanem and htmlRepository can both be null, then they are ignored - public static Table checkGroundTruthLimaye(String tableFilename, String tableAnnotationFilename, - PrintWriter nlPrinter, - PrintWriter rows_col_with_ne_Printer) throws IOException, ParserConfigurationException, SAXException { - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - - DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); - Document domCleanTable = docBuilder.parse(tableFilename); - - //read the table content - List tableContent = DomUtils.findAll(domCleanTable, "//logicalTable/content"); - if (tableContent == null || tableContent.size() == 0) - return null; - boolean firstRowHeader = false; - List rows = new ArrayList(); - NodeList rowNodes = tableContent.get(0).getChildNodes(); - - for (int i = 0; i < rowNodes.getLength(); i++) { - Node row = rowNodes.item(i); - if (row.getNodeName().equals("#text")) - continue; - if (row.getNodeName().equals("header")) { - firstRowHeader = true; - } - - List columns = DomUtils.findAll(row, "cell"); - String[] cells = new String[columns.size()]; - for (int j = 0; j < columns.size(); j++) { - Node cell = columns.get(j); - List html = DomUtils.findAll(cell, "html"); - String textContent = ""; - if (html != null && html.size() > 0) { - textContent=extract_text_content_from_html(html); - } - - if(textContent.equals("")){ - List text = DomUtils.findAll(cell, "text"); - - if (text != null && text.size() > 0) { - textContent = text.get(0).getTextContent(); - } - } - cells[j] = textContent; - } - rows.add(cells); - } - - int totalCol = 0; - for (String[] row : rows) { - if (row.length > totalCol) - totalCol = row.length; - } - - Table table = null; - int rowModifier = 0; - if (firstRowHeader) { - table = new Table(String.valueOf(tableFilename.hashCode()), tableFilename, rows.size() - 1, totalCol); - rowModifier = 1; - if (rows.get(0).length < totalCol){ - System.err.println("WARNING:Artificial header added, check manually. "+tableFilename); - String[] headers = rows.get(0); - String[] modified = new String[totalCol]; - for(int i=0; i tableContext = DomUtils.findAll(domCleanTable, "//logicalTable/tableContext"); - if (tableContext != null || tableContext.size() != 0) { - Node ctxParentNode = tableContext.get(0); - NodeList contexts = ctxParentNode.getChildNodes(); - for (int i = 0; i < contexts.getLength(); i++) { - - Node n = contexts.item(i); - if (n.getNodeName().equals("#text")) - continue; - List textNode = DomUtils.findAllByTag(n, "text"); - if (textNode != null && textNode.size() > 0) { - String context = textNode.get(0).getTextContent(); - if (context != null) { - TContext ctx = null; - if (i == 1) - ctx = new TContext(context, TContext.TableContextType.PAGETITLE, 1.0); - else ctx = new TContext(context, TContext.TableContextType.PARAGRAPH_BEFORE, 1.0); - - table.addContext(ctx); - } - } - } - } - if (table.getContexts().size() > 1) - table.getContexts().remove(1); //always isValidAttribute the 2nd context as it is the header of the table - - if (tableAnnotationFilename == null) - return table; - - - if(new File(tableAnnotationFilename).exists()){ - Document domAnnotatedTable = docBuilder.parse(tableAnnotationFilename); - - //read the header annotations - List headerAnnotations = DomUtils.findAll(domAnnotatedTable, "//columnAnnotations/colAnnos"); - for (int i = 0; i < headerAnnotations.size(); i++) { - Node header = headerAnnotations.get(i); - int col = Integer.valueOf(header.getAttributes().getNamedItem("col").getTextContent()); - //TCell headerCell = table.getHeaderForColumn(col); - NodeList annotations = header.getChildNodes(); - List hAnnotations = new ArrayList(); - for (int j = 0; j < annotations.getLength(); j++) { - Node n = annotations.item(j); - if (n.getNodeName().equals("anno")) { - TColumnHeaderAnnotation a = new TColumnHeaderAnnotation(table.getColumnHeader(col).getHeaderText(), - new Clazz(n.getAttributes().getNamedItem("name").getTextContent(), - n.getAttributes().getNamedItem("name").getTextContent()), - Double.valueOf(n.getAttributes().getNamedItem("value").getTextContent().trim())); - - hAnnotations.add(a); - } - } - table.getTableAnnotations().setHeaderAnnotation(col, hAnnotations.toArray(new TColumnHeaderAnnotation[0])); - } - //read the data rows annotations - List dataRowAnnotations = DomUtils.findAll(domAnnotatedTable, "//cellAnnotatoons/row"); - Set columns_with_annotated_entities = new HashSet(); - for (int i = 0; i < dataRowAnnotations.size(); i++) { - Node row = dataRowAnnotations.get(i); - List cols = DomUtils.findAll(row, "entity"); - for (int j = 0; j < cols.size(); j++) { - Node htmlCell = cols.get(j); - if (htmlCell.getTextContent() == null || htmlCell.getTextContent().length() == 0) { - continue; - } - String textContent=table.getContentCell(i, j).getText(); - TCellAnnotation cellAnnotation = new TCellAnnotation( - textContent, new Entity(htmlCell.getTextContent(), htmlCell.getTextContent()), 1.0, new HashMap() - ); - - int length=0; - if (textContent.length() > 20 && !textContent.contains(" ") && textContent.contains("/")) { - length = 0; //url, long string - } else { - textContent = textContent.replaceAll("[\\-_]"," ").trim(); - length = textContent.split("\\s+").length; - } - - ////////////////////////printing average name length ///////////////////////// - nlPrinter.println(length); - - table.getTableAnnotations().setContentCellAnnotations( - i, j, new TCellAnnotation[]{cellAnnotation} - ); - columns_with_annotated_entities.add(j); - } - - } - - //printing num of rows, and columns that have entity annotations - rows_col_with_ne_Printer.println - (dataRowAnnotations.size()+","+columns_with_annotated_entities.size()); - } - - return table; - } - - private static String extract_text_content_from_html(List html) { - String content = html.get(0).getTextContent(); - int start=content.indexOf(""); - if(start!=-1){ - content=content.substring(start+4); - int end = content.indexOf(""); - if(end==-1) - end=content.indexOf(""); - if(end==-1) - end=content.indexOf(""); - if(end!=-1) - content=content.substring(0,end).trim(); - } - content= StringEscapeUtils.unescapeHtml4(content); - return content; - } - - private static void dumpHTMLContent(Node htmlSnippetNode, String htmlRepository, String filePath) throws FileNotFoundException { - String content = htmlSnippetNode.getTextContent(); - int begin = content.indexOf("CDATA["); - begin = begin == -1 ? 0 : begin + 7; - int end = content.lastIndexOf("]]>"); - end = end == -1 ? content.length() : end; - content = content.substring(begin, end).trim(); - - PrintWriter p = new PrintWriter(htmlRepository + File.separator + new File(filePath).getName() + "_" + filePath.hashCode() + ".html"); - p.println("

"); - p.println(filePath); - p.println("

"); - p.println(content); - p.println(""); - p.close(); - } - -} +package uk.ac.shef.dcs.sti.todo.evaluation; + +import org.apache.any23.extractor.html.DomUtils; +import org.apache.any23.util.FileUtils; +import org.apache.commons.io.filefilter.SuffixFileFilter; +import org.apache.commons.lang3.StringEscapeUtils; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; +import uk.ac.shef.dcs.kbsearch.model.Clazz; +import uk.ac.shef.dcs.sti.STIEnum; +import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.sti.core.model.*; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.*; +import java.util.List; + +/** + */ +public class DataStats_TableSize_NameLength_Anaylsis_LimayeOld { + + public static void main(String[] args) throws IOException, SAXException, ParserConfigurationException { + String cleanTableRepos = "E:\\Data\\table_annotation\\limaye\\all_tables_raw(limaye_original)"; + String annotationRepos = "E:\\Data\\table_annotation\\limaye\\all_tables_groundtruth_xml(limaye_original)"; + + PrintWriter nlPrinter = new PrintWriter("D:\\Work\\lodie\\tmp_result/nl.csv"); + PrintWriter rows_col_with_ne_Printer = new PrintWriter("D:\\Work\\lodie\\tmp_result/rows_cols.csv"); + + File[] files = FileUtils.listFilesRecursively(new File(cleanTableRepos), new SuffixFileFilter(".xml")); + for (File clean : files) { + String path = clean.getAbsolutePath().replaceAll("\\\\", "/"); + String relative = path.substring(cleanTableRepos.length()); + + String annotated = annotationRepos + relative; + if (!(new File(annotated)).exists()) { + System.err.println("annotated file does not exist: " + annotated); + continue; + } + + System.out.println(annotated); + + checkGroundTruthLimaye(clean.toString(), annotated, nlPrinter, rows_col_with_ne_Printer); + } + + /*Table table = readTable("E:\\data\\table annotation\\tablesForAnnotation\\wikitables\\c3\\r12\\y\\e\\l/Yellowknife.html_0.xml", + "E:\\data\\table annotation\\workspace\\WWT_GroundTruth\\annotation\\wikitables\\c3\\r12\\y\\e\\l/Yellowknife.html_0.xml", + "D:\\work\\lodiedata\\limayetable");*/ + System.out.println(); + nlPrinter.close(); + rows_col_with_ne_Printer.close(); + } + + //tableAnnotationFileanem and htmlRepository can both be null, then they are ignored + public static Table checkGroundTruthLimaye(String tableFilename, String tableAnnotationFilename, + PrintWriter nlPrinter, + PrintWriter rows_col_with_ne_Printer) throws IOException, ParserConfigurationException, SAXException { + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + + DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); + Document domCleanTable = docBuilder.parse(tableFilename); + + //read the table content + List tableContent = DomUtils.findAll(domCleanTable, "//logicalTable/content"); + if (tableContent == null || tableContent.size() == 0) + return null; + boolean firstRowHeader = false; + List rows = new ArrayList(); + NodeList rowNodes = tableContent.get(0).getChildNodes(); + + for (int i = 0; i < rowNodes.getLength(); i++) { + Node row = rowNodes.item(i); + if (row.getNodeName().equals("#text")) + continue; + if (row.getNodeName().equals("header")) { + firstRowHeader = true; + } + + List columns = DomUtils.findAll(row, "cell"); + String[] cells = new String[columns.size()]; + for (int j = 0; j < columns.size(); j++) { + Node cell = columns.get(j); + List html = DomUtils.findAll(cell, "html"); + String textContent = ""; + if (html != null && html.size() > 0) { + textContent=extract_text_content_from_html(html); + } + + if(textContent.equals("")){ + List text = DomUtils.findAll(cell, "text"); + + if (text != null && text.size() > 0) { + textContent = text.get(0).getTextContent(); + } + } + cells[j] = textContent; + } + rows.add(cells); + } + + int totalCol = 0; + for (String[] row : rows) { + if (row.length > totalCol) + totalCol = row.length; + } + + Table table = null; + int rowModifier = 0; + if (firstRowHeader) { + table = new Table(String.valueOf(tableFilename.hashCode()), tableFilename, rows.size() - 1, totalCol); + rowModifier = 1; + if (rows.get(0).length < totalCol){ + System.err.println("WARNING:Artificial header added, check manually. "+tableFilename); + String[] headers = rows.get(0); + String[] modified = new String[totalCol]; + for(int i=0; i tableContext = DomUtils.findAll(domCleanTable, "//logicalTable/tableContext"); + if (tableContext != null || tableContext.size() != 0) { + Node ctxParentNode = tableContext.get(0); + NodeList contexts = ctxParentNode.getChildNodes(); + for (int i = 0; i < contexts.getLength(); i++) { + + Node n = contexts.item(i); + if (n.getNodeName().equals("#text")) + continue; + List textNode = DomUtils.findAllByTag(n, "text"); + if (textNode != null && textNode.size() > 0) { + String context = textNode.get(0).getTextContent(); + if (context != null) { + TContext ctx = null; + if (i == 1) + ctx = new TContext(context, TContext.TableContextType.PAGETITLE, 1.0); + else ctx = new TContext(context, TContext.TableContextType.PARAGRAPH_BEFORE, 1.0); + + table.addContext(ctx); + } + } + } + } + if (table.getContexts().size() > 1) + table.getContexts().remove(1); //always isValidAttribute the 2nd context as it is the header of the table + + if (tableAnnotationFilename == null) + return table; + + + if(new File(tableAnnotationFilename).exists()){ + Document domAnnotatedTable = docBuilder.parse(tableAnnotationFilename); + + //read the header annotations + List headerAnnotations = DomUtils.findAll(domAnnotatedTable, "//columnAnnotations/colAnnos"); + for (int i = 0; i < headerAnnotations.size(); i++) { + Node header = headerAnnotations.get(i); + int col = Integer.valueOf(header.getAttributes().getNamedItem("col").getTextContent()); + //TCell headerCell = table.getHeaderForColumn(col); + NodeList annotations = header.getChildNodes(); + List hAnnotations = new ArrayList(); + for (int j = 0; j < annotations.getLength(); j++) { + Node n = annotations.item(j); + if (n.getNodeName().equals("anno")) { + TColumnHeaderAnnotation a = new TColumnHeaderAnnotation(table.getColumnHeader(col).getHeaderText(), + new Clazz(n.getAttributes().getNamedItem("name").getTextContent(), + n.getAttributes().getNamedItem("name").getTextContent()), + Double.valueOf(n.getAttributes().getNamedItem("value").getTextContent().trim())); + + hAnnotations.add(a); + } + } + table.getTableAnnotations().setHeaderAnnotation(col, hAnnotations.toArray(new TColumnHeaderAnnotation[0])); + } + //read the data rows annotations + List dataRowAnnotations = DomUtils.findAll(domAnnotatedTable, "//cellAnnotatoons/row"); + Set columns_with_annotated_entities = new HashSet(); + for (int i = 0; i < dataRowAnnotations.size(); i++) { + Node row = dataRowAnnotations.get(i); + List cols = DomUtils.findAll(row, "entity"); + for (int j = 0; j < cols.size(); j++) { + Node htmlCell = cols.get(j); + if (htmlCell.getTextContent() == null || htmlCell.getTextContent().length() == 0) { + continue; + } + String textContent=table.getContentCell(i, j).getText(); + TCellAnnotation cellAnnotation = new TCellAnnotation( + textContent, new Entity(htmlCell.getTextContent(), htmlCell.getTextContent()), 1.0, new HashMap() + ); + + int length=0; + if (textContent.length() > 20 && !textContent.contains(" ") && textContent.contains("/")) { + length = 0; //url, long string + } else { + textContent = textContent.replaceAll("[\\-_]"," ").trim(); + length = textContent.split("\\s+").length; + } + + ////////////////////////printing average name length ///////////////////////// + nlPrinter.println(length); + + table.getTableAnnotations().setContentCellAnnotations( + i, j, new TCellAnnotation[]{cellAnnotation} + ); + columns_with_annotated_entities.add(j); + } + + } + + //printing num of rows, and columns that have entity annotations + rows_col_with_ne_Printer.println + (dataRowAnnotations.size()+","+columns_with_annotated_entities.size()); + } + + return table; + } + + private static String extract_text_content_from_html(List html) { + String content = html.get(0).getTextContent(); + int start=content.indexOf(""); + if(start!=-1){ + content=content.substring(start+4); + int end = content.indexOf(""); + if(end==-1) + end=content.indexOf(""); + if(end==-1) + end=content.indexOf(""); + if(end!=-1) + content=content.substring(0,end).trim(); + } + content= StringEscapeUtils.unescapeHtml4(content); + return content; + } + + private static void dumpHTMLContent(Node htmlSnippetNode, String htmlRepository, String filePath) throws FileNotFoundException { + String content = htmlSnippetNode.getTextContent(); + int begin = content.indexOf("CDATA["); + begin = begin == -1 ? 0 : begin + 7; + int end = content.lastIndexOf("]]>"); + end = end == -1 ? content.length() : end; + content = content.substring(begin, end).trim(); + + PrintWriter p = new PrintWriter(htmlRepository + File.separator + new File(filePath).getName() + "_" + filePath.hashCode() + ".html"); + p.println("

"); + p.println(filePath); + p.println("

"); + p.println(content); + p.println(""); + p.close(); + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_IMDB.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_IMDB.java index 8740cebd..d29d5ef5 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_IMDB.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_IMDB.java @@ -1,144 +1,144 @@ -package uk.ac.shef.dcs.sti.todo.evaluation; - -import java.io.IOException; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 01/04/14 - * Time: 15:50 - * To change this template use File | Settings | File Templates. - */ -public class Evaluator_AllInOne_IMDB { - public static void main(String[] args) throws IOException { - Evaluator_EntityOnly ent_evaluator = new Evaluator_EntityOnly(); - Evaluator_ClassOnly_IMDB_MusicBrainz cls_evaluator = new Evaluator_ClassOnly_IMDB_MusicBrainz(); - //Evaluator_RelationOnly rel_evaluator = new Evaluator_RelationOnly(); - /************************************************ - FORY limaye200 - *************************************************/ - String method = "smp"; - - - if (method.equals("nm")) { - ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_base_nm", - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs\\imdb_gs(entity)_reformatted", - "tmp_result/imdb_entity_base_nm.csv", - "tmp_result/imdb_entity_base_nm_missed.csv", - false - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_base_nm", - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs/imdb.header.keys", - "tmp_result/imdb_header_base_nm.csv", - "tmp_result/imdb_header_base_nm_missed.csv", true - ); - - } else if (method.equals("cos")) { - ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_base_sl_cos", - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs\\imdb_gs(entity)_reformatted", - "tmp_result/imdb_entity_base_cos.csv", - "tmp_result/imdb_entity_base_cos_missed.csv", - false - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_base_sl_cos", - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs/imdb.header.keys", - "tmp_result/imdb_header_base_cos.csv", - "tmp_result/imdb_header_base_cos_missed.csv", true - ); - - } else if (method.equals("lev")) { - ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_base_sl_lev", - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs\\imdb_gs(entity)_reformatted", - "tmp_result/imdb_entity_base_lev.csv", - "tmp_result/imdb_entity_base_lev_missed.csv", - false - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_base_sl_lev", - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs/imdb.header.keys", - "tmp_result/imdb_header_base_lev.csv", - "tmp_result/imdb_header_base_lev_missed.csv", true - - ); - } else if (method.equals("dice")) { - ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_base_sl_dice", - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs\\imdb_gs(entity)_reformatted", - "tmp_result/imdb_entity_base_dice.csv", - "tmp_result/imdb_entity_base_dice_missed.csv", - false - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_base_sl_dice", - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs/imdb.header.keys", - "tmp_result/imdb_header_base_dice.csv", - "tmp_result/imdb_header_base_dice_missed.csv", true - ); - - } else if (method.equals("tm_ospd")) { - ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_tm_ospd", - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs\\imdb_gs(entity)_reformatted", - "tmp_result/imdb_entity_tm_ospd.csv", - "tmp_result/imdb_entity_tm_ospd_missed.csv", - false - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_tm_ospd", - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs/imdb.header.keys", - "tmp_result/imdb_header_tm_ospd.csv", - "tmp_result/imdb_header_tm_ospd_missed.csv", true - ); - - } else if (method.equals("tm_ospd_nsc")) { - ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\tableminer_slim\\imdb_computed", - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs\\imdb_gs(entity)_reformatted", - "tmp_result/imdb_entity_tm_ospd_nsc.csv", - "tmp_result/imdb_entity_tm_ospd_nsc_missed.csv", - false - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\tableminer_slim\\imdb_computed", - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs/imdb.header.keys", - "tmp_result/imdb_header_tm_ospd_nsc.csv", - "tmp_result/imdb_header_tm_ospd_nsc_missed.csv", true - ); - - }else if (method.equals("smp")) { - ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\ti_imdb_smp_tm+granularity\\imdb_computed_smp", - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs\\imdb_gs(entity)_reformatted", - "tmp_result/imdb_entity_smp-tm+grn.csv", - "tmp_result/imdb_entity_smp-tm+grn_missed.csv", - false - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\ti_imdb_smp_tm+granularity\\imdb_computed_smp", - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs/imdb.header.keys", - "tmp_result/imdb_header_smp-tm+grn.csv", - "tmp_result/imdb_header_smp-tm+grn_missed.csv", true - ); - }else if (method.equals("ji")) { - ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\ti_imdb_ji\\imdb_computed_smp", - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs\\imdb_gs(entity)_reformatted", - "tmp_result/imdb_entity_ji.csv", - "tmp_result/imdb_entity_ji_missed.csv", - false - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\ti_imdb_ji\\imdb_computed_smp", - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs/imdb.header.keys", - "tmp_result/imdb_header_ji.csv", - "tmp_result/imdb_header_ji_missed.csv", true - ); - } - System.exit(0); - } -} +package uk.ac.shef.dcs.sti.todo.evaluation; + +import java.io.IOException; + +/** + * Created with IntelliJ IDEA. + * User: zqz + * Date: 01/04/14 + * Time: 15:50 + * To change this template use File | Settings | File Templates. + */ +public class Evaluator_AllInOne_IMDB { + public static void main(String[] args) throws IOException { + Evaluator_EntityOnly ent_evaluator = new Evaluator_EntityOnly(); + Evaluator_ClassOnly_IMDB_MusicBrainz cls_evaluator = new Evaluator_ClassOnly_IMDB_MusicBrainz(); + //Evaluator_RelationOnly rel_evaluator = new Evaluator_RelationOnly(); + /************************************************ + FORY limaye200 + *************************************************/ + String method = "smp"; + + + if (method.equals("nm")) { + ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_base_nm", + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs\\imdb_gs(entity)_reformatted", + "tmp_result/imdb_entity_base_nm.csv", + "tmp_result/imdb_entity_base_nm_missed.csv", + false + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_base_nm", + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs/imdb.header.keys", + "tmp_result/imdb_header_base_nm.csv", + "tmp_result/imdb_header_base_nm_missed.csv", true + ); + + } else if (method.equals("cos")) { + ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_base_sl_cos", + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs\\imdb_gs(entity)_reformatted", + "tmp_result/imdb_entity_base_cos.csv", + "tmp_result/imdb_entity_base_cos_missed.csv", + false + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_base_sl_cos", + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs/imdb.header.keys", + "tmp_result/imdb_header_base_cos.csv", + "tmp_result/imdb_header_base_cos_missed.csv", true + ); + + } else if (method.equals("lev")) { + ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_base_sl_lev", + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs\\imdb_gs(entity)_reformatted", + "tmp_result/imdb_entity_base_lev.csv", + "tmp_result/imdb_entity_base_lev_missed.csv", + false + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_base_sl_lev", + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs/imdb.header.keys", + "tmp_result/imdb_header_base_lev.csv", + "tmp_result/imdb_header_base_lev_missed.csv", true + + ); + } else if (method.equals("dice")) { + ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_base_sl_dice", + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs\\imdb_gs(entity)_reformatted", + "tmp_result/imdb_entity_base_dice.csv", + "tmp_result/imdb_entity_base_dice_missed.csv", + false + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_base_sl_dice", + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs/imdb.header.keys", + "tmp_result/imdb_header_base_dice.csv", + "tmp_result/imdb_header_base_dice_missed.csv", true + ); + + } else if (method.equals("tm_ospd")) { + ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_tm_ospd", + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs\\imdb_gs(entity)_reformatted", + "tmp_result/imdb_entity_tm_ospd.csv", + "tmp_result/imdb_entity_tm_ospd_missed.csv", + false + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_tm_ospd", + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs/imdb.header.keys", + "tmp_result/imdb_header_tm_ospd.csv", + "tmp_result/imdb_header_tm_ospd_missed.csv", true + ); + + } else if (method.equals("tm_ospd_nsc")) { + ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\tableminer_slim\\imdb_computed", + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs\\imdb_gs(entity)_reformatted", + "tmp_result/imdb_entity_tm_ospd_nsc.csv", + "tmp_result/imdb_entity_tm_ospd_nsc_missed.csv", + false + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\tableminer_slim\\imdb_computed", + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs/imdb.header.keys", + "tmp_result/imdb_header_tm_ospd_nsc.csv", + "tmp_result/imdb_header_tm_ospd_nsc_missed.csv", true + ); + + }else if (method.equals("smp")) { + ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\ti_imdb_smp_tm+granularity\\imdb_computed_smp", + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs\\imdb_gs(entity)_reformatted", + "tmp_result/imdb_entity_smp-tm+grn.csv", + "tmp_result/imdb_entity_smp-tm+grn_missed.csv", + false + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\ti_imdb_smp_tm+granularity\\imdb_computed_smp", + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs/imdb.header.keys", + "tmp_result/imdb_header_smp-tm+grn.csv", + "tmp_result/imdb_header_smp-tm+grn_missed.csv", true + ); + }else if (method.equals("ji")) { + ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\ti_imdb_ji\\imdb_computed_smp", + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs\\imdb_gs(entity)_reformatted", + "tmp_result/imdb_entity_ji.csv", + "tmp_result/imdb_entity_ji_missed.csv", + false + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\ti_imdb_ji\\imdb_computed_smp", + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs/imdb.header.keys", + "tmp_result/imdb_header_ji.csv", + "tmp_result/imdb_header_ji_missed.csv", true + ); + } + System.exit(0); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_Limaye.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_Limaye.java index d6bc9ae4..4e302b23 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_Limaye.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_Limaye.java @@ -1,330 +1,330 @@ -package uk.ac.shef.dcs.sti.todo.evaluation; - -import java.io.IOException; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 01/04/14 - * Time: 15:22 - * To change this template use File | Settings | File Templates. - */ -public class Evaluator_AllInOne_Limaye { - public static void main(String[] args) throws IOException { - Evaluator_EntityOnly ent_evaluator = new Evaluator_EntityOnly(); - Evaluator_ClassOnly cls_evaluator = new Evaluator_ClassOnly(); - Evaluator_RelationOnly rel_evaluator = new Evaluator_RelationOnly(); - /************************************************ - FORY limaye200 - *************************************************/ - String method = "smp"; - - if (method.equals("nm")) { - ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_nm+first(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\entity", - "tmp_result/limaye_entity_bs_nm.csv", - "tmp_result/limaye_entity_bs_nm_missed.csv", - true - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_nm+first(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_header_bs_nm-all.csv", - "tmp_result/limaye_header_bs_nm-all_missed.csv", false - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_nm+first(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_header_bs_nm-ne.csv", - "tmp_result/limaye_header_bs_nm-ne_missed.csv", true - ); - rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_nm+first(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_rel_bs_nm-ne.csv", - "tmp_result/limaye_rel_bs_nm_missed-ne.csv",true,true - ); - rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_nm+first(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_rel_bs_nm-all.csv", - "tmp_result/limaye_rel_bs_nm_missed-all.csv",true,false - ); - - } else if (method.equals("cos")) { - ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_cos(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\entity", - "tmp_result/limaye_entity_bs_cos.csv", - "tmp_result/limaye_entity_bs_cos_missed.csv", - true - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_cos(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_header_bs_cos-ne.csv", - "tmp_result/limaye_header_bs_cos-ne_missed.csv", true - - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_cos(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_header_bs_cos-all.csv", - "tmp_result/limaye_header_bs_cos-all_missed.csv", false - ); - rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_cos(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_rel_bs_cos-all.csv", - "tmp_result/limaye_rel_bs_cos_missed-all.csv",true,false - ); - rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_cos(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_rel_bs_cos-ne.csv", - "tmp_result/limaye_rel_bs_cos_missed-ne.csv",true,true - ); - } else if (method.equals("lev")) { - ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_lev(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\entity", - "tmp_result/limaye_entity_bs_sl_lev.csv", - "tmp_result/limaye_entity_bs_sl_lev_missed.csv", - true - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_lev(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_header_bs_sl_lev-all.csv", - "tmp_result/limaye_header_bs_sl_lev-all_missed.csv", false - - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_lev(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_header_bs_sl_lev-ne.csv", - "tmp_result/limaye_header_bs_sl_lev-ne_missed.csv", true - ); - rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_lev(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_rel_bs_lev-all.csv", - "tmp_result/limaye_rel_bs_lev_missed-all.csv",true,false - ); - rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_lev(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_rel_bs_lev-ne.csv", - "tmp_result/limaye_rel_bs_lev_missed-ne.csv",true,true - ); - } else if (method.equals("dice")) { - ent_evaluator.evaluate( - - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_dice(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\entity", - "tmp_result/limaye_entity_bs_sl_dice.csv", - "tmp_result/limaye_entity_bs_sl_dice_missed.csv", - true - - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_dice(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_header_bs_sl_dice-all.csv", - "tmp_result/limaye_header_bs_sl_dice-all_missed.csv", false - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_dice(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_header_bs_sl_dice-ne.csv", - "tmp_result/limaye_header_bs_sl_dice-ne_missed.csv", true - ); - rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_dice(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_rel_bs_dice-all.csv", - "tmp_result/limaye_rel_bs_dice_missed-all.csv",true,false - ); - rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_dice(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_rel_bs_dice-ne.csv", - "tmp_result/limaye_rel_bs_dice_missed-ne.csv",true,true - ); - - } else if (method.equals("tm_ospd")) { - ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\entity", - "tmp_result/limaye_entity_tm_ospd.csv", - "tmp_result/limaye_entity_tm_ospd_missed.csv", - true - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_header_tm_ospd-all.csv", - "tmp_result/limaye_header_tm_ospd-all_missed.csv", false - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_header_tm_ospd-ne.csv", - "tmp_result/limaye_header_tm_ospd-ne_missed.csv", true - - ); - rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_rel_tm_ospd-all.csv", - "tmp_result/limaye_rel_tm_ospd_missed-all.csv",true,false - ); - rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_rel_tm_ospd-ne.csv", - "tmp_result/limaye_rel_tm_ospd_missed-ne.csv",true,true - ); - } else if (method.equals("tm_ospd_nsc")) { - /*ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\output\\datafiltering_tmsimple_2combined", - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\entity", - "tmp_result/limaye_entity_tm_ospd_nsc.csv", - "tmp_result/limaye_entity_tm_ospd_nsc_missed.csv", - true - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\output\\datafiltering_tmsimple_2combined", - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_header_tm_ospd_nsc-ne.csv", - "tmp_result/limaye_header_tm_ospd_nsc-ne_missed.csv", true - );*/ - - ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\output\\datafiltering_tmsimple_2combined", - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\entity", - "tmp_result/limaye_entity_tm_ospd_nsc.csv", - "tmp_result/limaye_entity_tm_ospd_nsc_missed.csv", - true - ); - cls_evaluator.evaluate_with_filter( - "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200/combined.LOG", - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\output\\datafiltering_tmsimple_2combined", - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_header_tm_ospd_nsc-ne.csv", - "tmp_result/limaye_header_tm_ospd_nsc-ne_missed.csv", true - ); - /*cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\output\\datafiltering_tmsimple_random", - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_header_tm_ospd_nsc-all.csv", - "tmp_result/limaye_header_tm_ospd_nsc-all_missed.csv", false - ); - rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\output\\datafiltering_tmsimple_random", - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_rel_tm_ospd_nsc-all.csv", - "tmp_result/limaye_rel_tm_ospd_nsc_missed-all.csv",true,false - ); - rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\output\\datafiltering_tmsimple_random", - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_rel_tm_ospd_nsc-ne.csv", - "tmp_result/limaye_rel_tm_ospd_nsc_missed-ne.csv",true,true - );*/ - } - else if (method.equals("smp")) { - ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\SMP_output_tableminer-limaye200", - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\entity", - "tmp_result/limaye_entity_smp-tableminer.csv", - "tmp_result/limaye_entity_smp-tableminer_missed.csv", - true - ); - /*ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\ti_limaye_smp-tableminer\\limaye_smp_computed", - "E:\\Data\\table_annotation\\limayeall\\all_tables_groundtruth_freebase(regen)", - "tmp_result/limaye_entity_smp-tableminer.csv", - "tmp_result/limaye_entity_smp-tableminer_missed.csv", - true - );*/ - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\SMP_output_tableminer-limaye200", - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_header_smp-all-tableminer.csv", - "tmp_result/limaye_header_tm_smp-all-tableminer_missed.csv", false - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\SMP_output_tableminer-limaye200", - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_header_smp-ne-tableminer.csv", - "tmp_result/limaye_header_smp-ne-tableminer_missed.csv", true - - ); - rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\SMP_output_tableminer-limaye200", - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_rel_smp-all-tableminer.csv", - "tmp_result/limaye_rel_smp_missed-all-tableminer.csv", true, false - ); - rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\SMP_output_tableminer-limaye200", - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_rel_smp-ne-tableminer.csv", - "tmp_result/limaye_rel_smp_missed-ne-tableminer.csv", true, true - ); - } - else if (method.equals("ji")) { - ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\limaye_ji_computed_200", - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\entity", - "tmp_result/limaye_entity_ji.csv", - "tmp_result/limaye_entity_ji_missed.csv", - true - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\limaye_ji_computed_200", - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_header_ji-all.csv", - "tmp_result/limaye_header_ji-all_missed.csv", false - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\limaye_ji_computed_200", - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_header_ji-ne.csv", - "tmp_result/limaye_header_ji-ne_missed.csv", true - - ); - /*rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\JI_limaye200_multithread_NE-Header only", - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_rel_ji-all.csv", - "tmp_result/limaye_rel_ji_missed-all.csv", true, false - ); - rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\JI_limaye200_multithread_NE-Header only", - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_rel_ji-ne.csv", - "tmp_result/limaye_rel_ji_missed-ne.csv", true, true - );*/ - } - System.exit(0); - } -} +package uk.ac.shef.dcs.sti.todo.evaluation; + +import java.io.IOException; + +/** + * Created with IntelliJ IDEA. + * User: zqz + * Date: 01/04/14 + * Time: 15:22 + * To change this template use File | Settings | File Templates. + */ +public class Evaluator_AllInOne_Limaye { + public static void main(String[] args) throws IOException { + Evaluator_EntityOnly ent_evaluator = new Evaluator_EntityOnly(); + Evaluator_ClassOnly cls_evaluator = new Evaluator_ClassOnly(); + Evaluator_RelationOnly rel_evaluator = new Evaluator_RelationOnly(); + /************************************************ + FORY limaye200 + *************************************************/ + String method = "smp"; + + if (method.equals("nm")) { + ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_nm+first(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\entity", + "tmp_result/limaye_entity_bs_nm.csv", + "tmp_result/limaye_entity_bs_nm_missed.csv", + true + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_nm+first(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_header_bs_nm-all.csv", + "tmp_result/limaye_header_bs_nm-all_missed.csv", false + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_nm+first(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_header_bs_nm-ne.csv", + "tmp_result/limaye_header_bs_nm-ne_missed.csv", true + ); + rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_nm+first(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_rel_bs_nm-ne.csv", + "tmp_result/limaye_rel_bs_nm_missed-ne.csv",true,true + ); + rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_nm+first(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_rel_bs_nm-all.csv", + "tmp_result/limaye_rel_bs_nm_missed-all.csv",true,false + ); + + } else if (method.equals("cos")) { + ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_cos(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\entity", + "tmp_result/limaye_entity_bs_cos.csv", + "tmp_result/limaye_entity_bs_cos_missed.csv", + true + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_cos(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_header_bs_cos-ne.csv", + "tmp_result/limaye_header_bs_cos-ne_missed.csv", true + + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_cos(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_header_bs_cos-all.csv", + "tmp_result/limaye_header_bs_cos-all_missed.csv", false + ); + rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_cos(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_rel_bs_cos-all.csv", + "tmp_result/limaye_rel_bs_cos_missed-all.csv",true,false + ); + rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_cos(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_rel_bs_cos-ne.csv", + "tmp_result/limaye_rel_bs_cos_missed-ne.csv",true,true + ); + } else if (method.equals("lev")) { + ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_lev(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\entity", + "tmp_result/limaye_entity_bs_sl_lev.csv", + "tmp_result/limaye_entity_bs_sl_lev_missed.csv", + true + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_lev(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_header_bs_sl_lev-all.csv", + "tmp_result/limaye_header_bs_sl_lev-all_missed.csv", false + + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_lev(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_header_bs_sl_lev-ne.csv", + "tmp_result/limaye_header_bs_sl_lev-ne_missed.csv", true + ); + rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_lev(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_rel_bs_lev-all.csv", + "tmp_result/limaye_rel_bs_lev_missed-all.csv",true,false + ); + rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_lev(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_rel_bs_lev-ne.csv", + "tmp_result/limaye_rel_bs_lev_missed-ne.csv",true,true + ); + } else if (method.equals("dice")) { + ent_evaluator.evaluate( + + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_dice(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\entity", + "tmp_result/limaye_entity_bs_sl_dice.csv", + "tmp_result/limaye_entity_bs_sl_dice_missed.csv", + true + + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_dice(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_header_bs_sl_dice-all.csv", + "tmp_result/limaye_header_bs_sl_dice-all_missed.csv", false + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_dice(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_header_bs_sl_dice-ne.csv", + "tmp_result/limaye_header_bs_sl_dice-ne_missed.csv", true + ); + rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_dice(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_rel_bs_dice-all.csv", + "tmp_result/limaye_rel_bs_dice_missed-all.csv",true,false + ); + rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_dice(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_rel_bs_dice-ne.csv", + "tmp_result/limaye_rel_bs_dice_missed-ne.csv",true,true + ); + + } else if (method.equals("tm_ospd")) { + ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\entity", + "tmp_result/limaye_entity_tm_ospd.csv", + "tmp_result/limaye_entity_tm_ospd_missed.csv", + true + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_header_tm_ospd-all.csv", + "tmp_result/limaye_header_tm_ospd-all_missed.csv", false + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_header_tm_ospd-ne.csv", + "tmp_result/limaye_header_tm_ospd-ne_missed.csv", true + + ); + rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_rel_tm_ospd-all.csv", + "tmp_result/limaye_rel_tm_ospd_missed-all.csv",true,false + ); + rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_rel_tm_ospd-ne.csv", + "tmp_result/limaye_rel_tm_ospd_missed-ne.csv",true,true + ); + } else if (method.equals("tm_ospd_nsc")) { + /*ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\output\\datafiltering_tmsimple_2combined", + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\entity", + "tmp_result/limaye_entity_tm_ospd_nsc.csv", + "tmp_result/limaye_entity_tm_ospd_nsc_missed.csv", + true + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\output\\datafiltering_tmsimple_2combined", + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_header_tm_ospd_nsc-ne.csv", + "tmp_result/limaye_header_tm_ospd_nsc-ne_missed.csv", true + );*/ + + ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\output\\datafiltering_tmsimple_2combined", + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\entity", + "tmp_result/limaye_entity_tm_ospd_nsc.csv", + "tmp_result/limaye_entity_tm_ospd_nsc_missed.csv", + true + ); + cls_evaluator.evaluate_with_filter( + "D:\\Work\\lodie\\tmp_result\\ospd_tm_iswc\\limaye200/combined.LOG", + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\output\\datafiltering_tmsimple_2combined", + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_header_tm_ospd_nsc-ne.csv", + "tmp_result/limaye_header_tm_ospd_nsc-ne_missed.csv", true + ); + /*cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\output\\datafiltering_tmsimple_random", + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_header_tm_ospd_nsc-all.csv", + "tmp_result/limaye_header_tm_ospd_nsc-all_missed.csv", false + ); + rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\output\\datafiltering_tmsimple_random", + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_rel_tm_ospd_nsc-all.csv", + "tmp_result/limaye_rel_tm_ospd_nsc_missed-all.csv",true,false + ); + rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\output\\datafiltering_tmsimple_random", + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_rel_tm_ospd_nsc-ne.csv", + "tmp_result/limaye_rel_tm_ospd_nsc_missed-ne.csv",true,true + );*/ + } + else if (method.equals("smp")) { + ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\SMP_output_tableminer-limaye200", + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\entity", + "tmp_result/limaye_entity_smp-tableminer.csv", + "tmp_result/limaye_entity_smp-tableminer_missed.csv", + true + ); + /*ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\ti_limaye_smp-tableminer\\limaye_smp_computed", + "E:\\Data\\table_annotation\\limayeall\\all_tables_groundtruth_freebase(regen)", + "tmp_result/limaye_entity_smp-tableminer.csv", + "tmp_result/limaye_entity_smp-tableminer_missed.csv", + true + );*/ + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\SMP_output_tableminer-limaye200", + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_header_smp-all-tableminer.csv", + "tmp_result/limaye_header_tm_smp-all-tableminer_missed.csv", false + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\SMP_output_tableminer-limaye200", + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_header_smp-ne-tableminer.csv", + "tmp_result/limaye_header_smp-ne-tableminer_missed.csv", true + + ); + rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\SMP_output_tableminer-limaye200", + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_rel_smp-all-tableminer.csv", + "tmp_result/limaye_rel_smp_missed-all-tableminer.csv", true, false + ); + rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\SMP_output_tableminer-limaye200", + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_rel_smp-ne-tableminer.csv", + "tmp_result/limaye_rel_smp_missed-ne-tableminer.csv", true, true + ); + } + else if (method.equals("ji")) { + ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\limaye_ji_computed_200", + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\entity", + "tmp_result/limaye_entity_ji.csv", + "tmp_result/limaye_entity_ji_missed.csv", + true + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\limaye_ji_computed_200", + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_header_ji-all.csv", + "tmp_result/limaye_header_ji-all_missed.csv", false + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\limaye_ji_computed_200", + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_header_ji-ne.csv", + "tmp_result/limaye_header_ji-ne_missed.csv", true + + ); + /*rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\JI_limaye200_multithread_NE-Header only", + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_rel_ji-all.csv", + "tmp_result/limaye_rel_ji_missed-all.csv", true, false + ); + rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\JI_limaye200_multithread_NE-Header only", + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye200\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_rel_ji-ne.csv", + "tmp_result/limaye_rel_ji_missed-ne.csv", true, true + );*/ + } + System.exit(0); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_MB.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_MB.java index c713a55d..9834295c 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_MB.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_AllInOne_MB.java @@ -1,303 +1,303 @@ -package uk.ac.shef.dcs.sti.todo.evaluation; - -import java.io.IOException; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 01/04/14 - * Time: 16:04 - * To change this template use File | Settings | File Templates. - */ -public class Evaluator_AllInOne_MB { - public static void main(String[] args) throws IOException { - Evaluator_EntityOnly ent_evaluator = new Evaluator_EntityOnly(); - Evaluator_ClassOnly_IMDB_MusicBrainz cls_evaluator = new Evaluator_ClassOnly_IMDB_MusicBrainz(); - Evaluator_RelationOnly_IMDB_MusicBrainz rel_evaluator = new Evaluator_RelationOnly_IMDB_MusicBrainz(); - /************************************************ - FORY limaye200 - *************************************************/ - String method = "smp"; - - if (method.equals("nm")) { - ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_nm", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs\\musicbrainz_gs(entity)_reformatted", - "tmp_result/mb_entity_base_nm.csv", - "tmp_result/mb_entity_base_nm_missed.csv", - false - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_nm", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_header_base_nm-all.csv", - "tmp_result/mb_header_base_nm_missed-all.csv", false - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_nm", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_header_base_nm-ne.csv", - "tmp_result/mb_header_base_nm_missed-ne.csv", true - ); - rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_nm", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_nm_rel-all.csv", - "tmp_result/mb_nm_rel_missed-all.csv",false,false - ); - rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_nm", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_nm_rel-ne.csv", - "tmp_result/mb_nm_rel_missed-ne.csv",false,true - ); - - } else if (method.equals("cos")) { - ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_cos", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs\\musicbrainz_gs(entity)_reformatted", - "tmp_result/mb_entity_base_cos.csv", - "tmp_result/mb_entity_base_cos_missed.csv", - false - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_cos", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_header_base_cos-all.csv", - "tmp_result/mb_header_base_cos_missed-all.csv", false - - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_cos", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_header_base_cos-ne.csv", - "tmp_result/mb_header_base_cos_missed-ne.csv", true - ); - rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_cos", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_cos_rel-all.csv", - "tmp_result/mb_cos_rel_missed-all.csv",false,false - ); - rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_cos", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_cos_rel-ne.csv", - "tmp_result/mb_cos_rel_missed-ne.csv",false,true - ); - } else if (method.equals("lev")) { - ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_lev", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs\\musicbrainz_gs(entity)_reformatted", - "tmp_result/mb_entity_base_lev.csv", - "tmp_result/mb_entity_base_lev_missed.csv", - false - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_lev", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_header_base_lev-all.csv", - "tmp_result/mb_header_base_lev_missed-all.csv", false - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_lev", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_header_base_lev-ne.csv", - "tmp_result/mb_header_base_lev_missed-ne.csv", true - ); - rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_lev", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_lev_rel-ne.csv", - "tmp_result/mb_lev_rel_missed-ne.csv",false,true - ); - rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_lev", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_lev_rel-all.csv", - "tmp_result/mb_lev_rel_missed-all.csv",false,false - ); - } else if (method.equals("dice")) { - ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_dice", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs\\musicbrainz_gs(entity)_reformatted", - "tmp_result/mb_entity_base_dice.csv", - "tmp_result/mb_entity_base_dice_missed.csv", - false - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_dice", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_header_base_dice-all.csv", - "tmp_result/mb_header_base_dice_missed-all.csv", false - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_dice", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_header_base_dice-ne.csv", - "tmp_result/mb_header_base_dice_missed-ne.csv", true - ); - rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_dice", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_dice_rel-all.csv", - "tmp_result/mb_dice_rel_missed-all.csv",false,false - ); - rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_dice", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_dice_rel-ne.csv", - "tmp_result/mb_dice_rel_missed-ne.csv",false,true - ); - - } else if (method.equals("tm_ospd")) { - ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_tm_ospd", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs\\musicbrainz_gs(entity)_reformatted", - "tmp_result/mb_entity_tm_ospd.csv", - "tmp_result/mb_entity_tm_ospd_missed.csv", - false - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_tm_ospd", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_header_tm_ospd-all.csv", - "tmp_result/mb_header_tm_ospd_missed-all.csv", false - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_tm_ospd", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_header_tm_ospd-ne.csv", - "tmp_result/mb_header_tm_ospd_missed-ne.csv", true - - ); - rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_tm_ospd", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_tm_ospd_rel-ne.csv", - "tmp_result/mb_tm_ospd_rel_missed-ne.csv",false,true - ); - rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_tm_ospd", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_tm_ospd_rel-all.csv", - "tmp_result/mb_tm_ospd_rel_missed-all.csv",false,false - ); - } else if (method.equals("tm_ospd_nsc")) { - ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\tableminer_df\\mb_df_combined", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs\\musicbrainz_gs(entity)_reformatted", - "tmp_result/mb_entity_tm_ospd-nsc.csv", - "tmp_result/mb_entity_tm_ospd_missed-nsc.csv", - false - ); - /*cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\tableminer_df\\mb_df_random", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_header_tm_ospd_nsc-all.csv", - "tmp_result/mb_header_tm_ospd_missed_nsc-all.csv", false - );*/ - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\tableminer_df\\mb_df_combined", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "D:\\Work\\sti\\core\\tmp_result/mb_header_tm_ospd_nsc-ne.csv", - "D:\\Work\\sti\\core\\tmp_result/mb_header_tm_ospd_missed_nsc-ne.csv", true - ); - /*rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\tableminer_df\\mb_df_random", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_tm_ospd-nsc_rel-ne.csv", - "tmp_result/mb_tm_ospd-nsc_rel_missed-ne.csv",false,true - ); - rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\tableminer_df\\mb_df_randomd", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_tm_ospd-nsc_rel-all.csv", - "tmp_result/mb_tm_ospd-nsc_rel_missed-all.csv",false,false - );*/ - }else if (method.equals("smp")) { - ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\ti_mb_smp_tm+granularity\\musicbrainz_computed_smp", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs\\musicbrainz_gs(entity)_reformatted", - "D:\\Work\\sti\\core\\tmp_result/mb_entity_smp-tm+grn.csv", - "D:\\Work\\sti\\core\\tmp_result/mb_entity_smp-tm+grn_missed.csv", - false - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\ti_mb_smp_tm+granularity\\musicbrainz_computed_smp", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "D:\\Work\\sti\\core\\tmp_result/mb_header_smp-tm+grn-all.csv", - "D:\\Work\\sti\\core\\tmp_result/mb_header_smp-tm+grn-missed-all.csv", false - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\ti_mb_smp_tm+granularity\\musicbrainz_computed_smp", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "D:\\Work\\sti\\core\\tmp_result/mb_header_smp-tm+grn-ne.csv", - "D:\\Work\\sti\\core\\tmp_result/mb_header_smp-tm+grn-missed-ne.csv", true - ); - rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\ti_mb_smp_tm+granularity\\musicbrainz_computed_smp", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "D:\\Work\\sti\\core\\tmp_result/mb_rel_smp-tm+grn-ne.csv", - "D:\\Work\\sti\\core\\tmp_result/mb_rel_smp-tm+grn-ne_missed.csv",false,true - ); - rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\ti_mb_smp_tm+granularity\\musicbrainz_computed_smp", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "D:\\Work\\sti\\core\\tmp_result/mb_rel_smp-tm+grn-all.csv", - "D:\\Work\\sti\\core\\tmp_result/mb_rel_smp-tm+grn_missed-all.csv",false,false - ); - } - else if (method.equals("ji")) { - ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\ti_mb_ji\\musicbrainz_computed_smp", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs\\musicbrainz_gs(entity)_reformatted", - "D:\\Work\\sti\\core\\tmp_result/mb_entity_ji.csv", - "D:\\Work\\sti\\core\\tmp_result/mb_entity_ji_missed.csv", - false - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\ti_mb_ji\\musicbrainz_computed_smp", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "D:\\Work\\sti\\core\\tmp_result/mb_header_ji-all.csv", - "D:\\Work\\sti\\core\\tmp_result/mb_header_ji-missed-all.csv", false - ); - cls_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\ti_mb_ji\\musicbrainz_computed_smp", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "D:\\Work\\sti\\core\\tmp_result/mb_header_ji-ne.csv", - "D:\\Work\\sti\\core\\tmp_result/mb_header_ji-missed-ne.csv", true - ); - /*rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\ti_mb_smp_tableminer\\musicbrainz_computed_smp", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "D:\\Work\\sti\\core\\tmp_result/mb_rel_smp-tm-ne.csv", - "D:\\Work\\sti\\core\\tmp_result/mb_rel_smp-tm_missed-ne.csv",false,true - ); - rel_evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\ti_mb_smp_tableminer\\musicbrainz_computed_smp", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "D:\\Work\\sti\\core\\tmp_result/mb_rel_smp-tm-all.csv", - "D:\\Work\\sti\\core\\tmp_result/mb_rel_smp-tm_missed-all.csv",false,false - );*/ - } - - System.exit(0); - } -} +package uk.ac.shef.dcs.sti.todo.evaluation; + +import java.io.IOException; + +/** + * Created with IntelliJ IDEA. + * User: zqz + * Date: 01/04/14 + * Time: 16:04 + * To change this template use File | Settings | File Templates. + */ +public class Evaluator_AllInOne_MB { + public static void main(String[] args) throws IOException { + Evaluator_EntityOnly ent_evaluator = new Evaluator_EntityOnly(); + Evaluator_ClassOnly_IMDB_MusicBrainz cls_evaluator = new Evaluator_ClassOnly_IMDB_MusicBrainz(); + Evaluator_RelationOnly_IMDB_MusicBrainz rel_evaluator = new Evaluator_RelationOnly_IMDB_MusicBrainz(); + /************************************************ + FORY limaye200 + *************************************************/ + String method = "smp"; + + if (method.equals("nm")) { + ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_nm", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs\\musicbrainz_gs(entity)_reformatted", + "tmp_result/mb_entity_base_nm.csv", + "tmp_result/mb_entity_base_nm_missed.csv", + false + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_nm", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_header_base_nm-all.csv", + "tmp_result/mb_header_base_nm_missed-all.csv", false + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_nm", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_header_base_nm-ne.csv", + "tmp_result/mb_header_base_nm_missed-ne.csv", true + ); + rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_nm", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_nm_rel-all.csv", + "tmp_result/mb_nm_rel_missed-all.csv",false,false + ); + rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_nm", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_nm_rel-ne.csv", + "tmp_result/mb_nm_rel_missed-ne.csv",false,true + ); + + } else if (method.equals("cos")) { + ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_cos", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs\\musicbrainz_gs(entity)_reformatted", + "tmp_result/mb_entity_base_cos.csv", + "tmp_result/mb_entity_base_cos_missed.csv", + false + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_cos", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_header_base_cos-all.csv", + "tmp_result/mb_header_base_cos_missed-all.csv", false + + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_cos", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_header_base_cos-ne.csv", + "tmp_result/mb_header_base_cos_missed-ne.csv", true + ); + rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_cos", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_cos_rel-all.csv", + "tmp_result/mb_cos_rel_missed-all.csv",false,false + ); + rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_cos", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_cos_rel-ne.csv", + "tmp_result/mb_cos_rel_missed-ne.csv",false,true + ); + } else if (method.equals("lev")) { + ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_lev", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs\\musicbrainz_gs(entity)_reformatted", + "tmp_result/mb_entity_base_lev.csv", + "tmp_result/mb_entity_base_lev_missed.csv", + false + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_lev", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_header_base_lev-all.csv", + "tmp_result/mb_header_base_lev_missed-all.csv", false + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_lev", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_header_base_lev-ne.csv", + "tmp_result/mb_header_base_lev_missed-ne.csv", true + ); + rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_lev", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_lev_rel-ne.csv", + "tmp_result/mb_lev_rel_missed-ne.csv",false,true + ); + rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_lev", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_lev_rel-all.csv", + "tmp_result/mb_lev_rel_missed-all.csv",false,false + ); + } else if (method.equals("dice")) { + ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_dice", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs\\musicbrainz_gs(entity)_reformatted", + "tmp_result/mb_entity_base_dice.csv", + "tmp_result/mb_entity_base_dice_missed.csv", + false + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_dice", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_header_base_dice-all.csv", + "tmp_result/mb_header_base_dice_missed-all.csv", false + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_dice", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_header_base_dice-ne.csv", + "tmp_result/mb_header_base_dice_missed-ne.csv", true + ); + rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_dice", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_dice_rel-all.csv", + "tmp_result/mb_dice_rel_missed-all.csv",false,false + ); + rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_dice", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_dice_rel-ne.csv", + "tmp_result/mb_dice_rel_missed-ne.csv",false,true + ); + + } else if (method.equals("tm_ospd")) { + ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_tm_ospd", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs\\musicbrainz_gs(entity)_reformatted", + "tmp_result/mb_entity_tm_ospd.csv", + "tmp_result/mb_entity_tm_ospd_missed.csv", + false + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_tm_ospd", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_header_tm_ospd-all.csv", + "tmp_result/mb_header_tm_ospd_missed-all.csv", false + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_tm_ospd", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_header_tm_ospd-ne.csv", + "tmp_result/mb_header_tm_ospd_missed-ne.csv", true + + ); + rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_tm_ospd", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_tm_ospd_rel-ne.csv", + "tmp_result/mb_tm_ospd_rel_missed-ne.csv",false,true + ); + rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_tm_ospd", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_tm_ospd_rel-all.csv", + "tmp_result/mb_tm_ospd_rel_missed-all.csv",false,false + ); + } else if (method.equals("tm_ospd_nsc")) { + ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\tableminer_df\\mb_df_combined", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs\\musicbrainz_gs(entity)_reformatted", + "tmp_result/mb_entity_tm_ospd-nsc.csv", + "tmp_result/mb_entity_tm_ospd_missed-nsc.csv", + false + ); + /*cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\tableminer_df\\mb_df_random", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_header_tm_ospd_nsc-all.csv", + "tmp_result/mb_header_tm_ospd_missed_nsc-all.csv", false + );*/ + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\tableminer_df\\mb_df_combined", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "D:\\Work\\sti\\core\\tmp_result/mb_header_tm_ospd_nsc-ne.csv", + "D:\\Work\\sti\\core\\tmp_result/mb_header_tm_ospd_missed_nsc-ne.csv", true + ); + /*rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\tableminer_df\\mb_df_random", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_tm_ospd-nsc_rel-ne.csv", + "tmp_result/mb_tm_ospd-nsc_rel_missed-ne.csv",false,true + ); + rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\tableminer_df\\mb_df_randomd", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_tm_ospd-nsc_rel-all.csv", + "tmp_result/mb_tm_ospd-nsc_rel_missed-all.csv",false,false + );*/ + }else if (method.equals("smp")) { + ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\ti_mb_smp_tm+granularity\\musicbrainz_computed_smp", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs\\musicbrainz_gs(entity)_reformatted", + "D:\\Work\\sti\\core\\tmp_result/mb_entity_smp-tm+grn.csv", + "D:\\Work\\sti\\core\\tmp_result/mb_entity_smp-tm+grn_missed.csv", + false + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\ti_mb_smp_tm+granularity\\musicbrainz_computed_smp", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "D:\\Work\\sti\\core\\tmp_result/mb_header_smp-tm+grn-all.csv", + "D:\\Work\\sti\\core\\tmp_result/mb_header_smp-tm+grn-missed-all.csv", false + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\ti_mb_smp_tm+granularity\\musicbrainz_computed_smp", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "D:\\Work\\sti\\core\\tmp_result/mb_header_smp-tm+grn-ne.csv", + "D:\\Work\\sti\\core\\tmp_result/mb_header_smp-tm+grn-missed-ne.csv", true + ); + rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\ti_mb_smp_tm+granularity\\musicbrainz_computed_smp", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "D:\\Work\\sti\\core\\tmp_result/mb_rel_smp-tm+grn-ne.csv", + "D:\\Work\\sti\\core\\tmp_result/mb_rel_smp-tm+grn-ne_missed.csv",false,true + ); + rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\ti_mb_smp_tm+granularity\\musicbrainz_computed_smp", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "D:\\Work\\sti\\core\\tmp_result/mb_rel_smp-tm+grn-all.csv", + "D:\\Work\\sti\\core\\tmp_result/mb_rel_smp-tm+grn_missed-all.csv",false,false + ); + } + else if (method.equals("ji")) { + ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\ti_mb_ji\\musicbrainz_computed_smp", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs\\musicbrainz_gs(entity)_reformatted", + "D:\\Work\\sti\\core\\tmp_result/mb_entity_ji.csv", + "D:\\Work\\sti\\core\\tmp_result/mb_entity_ji_missed.csv", + false + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\ti_mb_ji\\musicbrainz_computed_smp", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "D:\\Work\\sti\\core\\tmp_result/mb_header_ji-all.csv", + "D:\\Work\\sti\\core\\tmp_result/mb_header_ji-missed-all.csv", false + ); + cls_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\ti_mb_ji\\musicbrainz_computed_smp", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "D:\\Work\\sti\\core\\tmp_result/mb_header_ji-ne.csv", + "D:\\Work\\sti\\core\\tmp_result/mb_header_ji-missed-ne.csv", true + ); + /*rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\ti_mb_smp_tableminer\\musicbrainz_computed_smp", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "D:\\Work\\sti\\core\\tmp_result/mb_rel_smp-tm-ne.csv", + "D:\\Work\\sti\\core\\tmp_result/mb_rel_smp-tm_missed-ne.csv",false,true + ); + rel_evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\ti_mb_smp_tableminer\\musicbrainz_computed_smp", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "D:\\Work\\sti\\core\\tmp_result/mb_rel_smp-tm-all.csv", + "D:\\Work\\sti\\core\\tmp_result/mb_rel_smp-tm_missed-all.csv",false,false + );*/ + } + + System.exit(0); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly.java index 53abe6ed..14c6ce82 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly.java @@ -1,482 +1,482 @@ -package uk.ac.shef.dcs.sti.todo.evaluation; - -import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; -import uk.ac.shef.dcs.sti.util.FileUtils; - -import java.io.File; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.*; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 26/02/14 - * Time: 14:14 - * To change this template use File | Settings | File Templates. - */ -public class Evaluator_ClassOnly { - - protected static boolean PREDICTION_ONE_CORRECT_COUNTS_ALL = false; //if prediction has multiple labels while gs has 1, if prediction covers gs, should it be 1 correct (true) or not (false) - - - public static void main(String[] args) throws IOException { - - /*Evaluator_Generic evaluator = new Evaluator_Generic(); - evaluator.evaluate( - "E:\\Data\\table annotation\\corpus_analysis\\100_tables\\100_tables_annotated(disamb=0)", - "E:\\Data\\table annotation\\corpus_analysis\\100_tables\\100_tables_gs", - "eval.csv", - "missed.csv" - );*/ - Evaluator_ClassOnly evaluator = new Evaluator_ClassOnly(); - evaluator.evaluate( - /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_cos(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_header_bs_cos-all.csv", - "tmp_result/limaye_header_bs_cos-all_missed.csv", false*/ - "E:\\Data\\table_annotation\\limaye_sample\\112_tables\\tableminer\\tableminer_swj", - "E:\\Data\\table_annotation\\limaye_sample\\112_tables\\gs\\112_tables_gs(aclshort-changed-iswc)", - "tmp_result/limaye_100_bs.csv", - "tmp_result/limaye_100_bs_missed.csv", true - - /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_nm+first(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_header_bs_nm-all.csv", - "tmp_result/limaye_header_bs_nm-all_missed.csv", false*/ - /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_nm+first(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_header_bs_nm-ne.csv", - "tmp_result/limaye_header_bs_nm-ne_missed.csv", true*/ - - /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_dice(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_header_bs_sl_dice-all.csv", - "tmp_result/limaye_header_bs_sl_dice-all_missed.csv", false*/ - - /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_dice(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_header_bs_sl_dice-ne.csv", - "tmp_result/limaye_header_bs_sl_dice-ne_missed.csv", true*/ - - /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_lev(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_header_bs_sl_lev-all.csv", - "tmp_result/limaye_header_bs_sl_lev-all_missed.csv", false*/ - - /* "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_lev(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_header_bs_sl_lev-ne.csv", - "tmp_result/limaye_header_bs_sl_lev-ne_missed.csv", true - */ - /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_header_tm_ospd-all.csv", - "tmp_result/limaye_header_tm_ospd-all_missed.csv", false*/ - - /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_header_tm_ospd-ne.csv", - "tmp_result/limaye_header_tm_ospd-ne_missed.csv", true*/ - - /* "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd_nsc", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_header_tm_ospd_nsc-all.csv", - "tmp_result/limaye_header_tm_ospd_nsc-all_missed.csv", false*/ - - /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd_nsc", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_header_tm_ospd_nsc-ne.csv", - "tmp_result/limaye_header_tm_ospd_nsc-ne_missed.csv", true*/ - ); - - } - - public void evaluate(String in_computed_folder, - String in_gs_folder, - String out_result_file, - String out_missed_file, boolean gs_NE_only) throws IOException { - PrintWriter p = new PrintWriter(out_result_file); - p.println("File,HEADER(0)_cp_y, gs_y, cp_n, p,r,f," + - "HEADER(1)_cp_y, gs_y, cp_n, p,r,f"); - - - PrintWriter out_missed_writer = new PrintWriter(out_missed_file); - Set processed = new HashSet(); - for (File gsFile : new File(in_gs_folder).listFiles()) { - - Map>> gs_headers = null; - - String filename = gsFile.getName(); - if (processed.contains(filename)) - continue; - - if (filename.endsWith(".keys")) { - int dothtml = filename.lastIndexOf(".html"); - if (dothtml == -1) - dothtml = filename.lastIndexOf(".htm"); - if (dothtml == -1) { - System.err.println(filename); - continue; - } - int end = dothtml + 5; - - filename = filename.substring(0, end).trim(); - System.out.println(filename); - /* if(filename.contains("Wisden")) - System.out.println();*/ - //if (!filename.contains(".attributes") && !filename.contains(".keys") && !processed.contains(filename)) { - String entity_gs = gsFile.getParent() + "/" + filename + ".cell.keys"; - processed.add(entity_gs); - String header_gs = gsFile.getParent() + "/" + filename + ".header.keys"; - processed.add(header_gs); - String binary = gsFile.getParent() + "/" + filename + ".relation.keys"; - processed.add(binary); - - gs_headers = TAnnotationKeyFileReader.readHeaderAnnotation(header_gs, true, gs_NE_only); - processed.add(filename); - - } else { - continue; - } - if (gs_headers == null) { - System.err.println(filename); - continue; - } - - boolean found = false; - - for (File cpFile : new File(in_computed_folder).listFiles()) { - if (cpFile.getName().startsWith(filename)) { - found = true; - - String cpFile_name = cpFile.toString(); - if (processed.contains(cpFile_name) || !cpFile_name.endsWith("keys")) - continue; - - String entity_cp = cpFile.getParent() + "/" + filename + ".cell.keys"; - processed.add(entity_cp); - String header_cp = cpFile.getParent() + "/" + filename + ".header.keys"; - processed.add(header_cp); - String binary_cp = cpFile.getParent() + "/" + filename + ".relation.keys"; - processed.add(binary_cp); - - StringBuilder line = new StringBuilder("\"" + cpFile.getPath() + "\","); - - Map>> cp_headers = - TAnnotationKeyFileReader.readHeaderAnnotation(header_cp, false, gs_NE_only); - - - double[] header_data_mode_0 = Evaluator_ClassOnly.compute_prf_header(gs_headers, cp_headers, 0); - line.append(appendResult(header_data_mode_0)); - - double[] header_data_mode_1 = Evaluator_ClassOnly.compute_prf_header(gs_headers, cp_headers, 1); - line.append(appendResult(header_data_mode_1)); - - p.println(line.toString()); - break; - } - } - if (!found) { - out_missed_writer.println(gsFile); - } - } - out_missed_writer.close(); - p.close(); - } - - public void evaluate_with_filter( - String log_file_as_filter, - String in_computed_folder, - String in_gs_folder, - String out_result_file, - String out_missed_file, boolean gs_NE_only) throws IOException { - - Set keepFiles = create_filter_with_log_file(log_file_as_filter); - PrintWriter p = new PrintWriter(out_result_file); - p.println("File,HEADER(0)_cp_y, gs_y, cp_n, p,r,f," + - "HEADER(1)_cp_y, gs_y, cp_n, p,r,f"); - - - PrintWriter out_missed_writer = new PrintWriter(out_missed_file); - Set processed = new HashSet(); - for (File gsFile : new File(in_gs_folder).listFiles()) { - if (!keepFiles.contains(gsFile.getName())) - continue; - - Map>> gs_headers = null; - - String filename = gsFile.getName(); - if (processed.contains(filename)) - continue; - - if (filename.endsWith(".keys")) { - int dothtml = filename.lastIndexOf(".html"); - if (dothtml == -1) - dothtml = filename.lastIndexOf(".htm"); - if (dothtml == -1) { - System.err.println(filename); - continue; - } - int end = dothtml + 5; - - filename = filename.substring(0, end).trim(); - System.out.println(filename); - /* if(filename.contains("Wisden")) - System.out.println();*/ - //if (!filename.contains(".attributes") && !filename.contains(".keys") && !processed.contains(filename)) { - String entity_gs = gsFile.getParent() + "/" + filename + ".cell.keys"; - processed.add(entity_gs); - String header_gs = gsFile.getParent() + "/" + filename + ".header.keys"; - processed.add(header_gs); - String binary = gsFile.getParent() + "/" + filename + ".relation.keys"; - processed.add(binary); - - gs_headers = TAnnotationKeyFileReader.readHeaderAnnotation(header_gs, true, gs_NE_only); - processed.add(filename); - - } else { - continue; - } - if (gs_headers == null) { - System.err.println(filename); - continue; - } - - boolean found = false; - - for (File cpFile : new File(in_computed_folder).listFiles()) { - if (cpFile.getName().startsWith(filename)) { - found = true; - - String cpFile_name = cpFile.toString(); - if (processed.contains(cpFile_name) || !cpFile_name.endsWith("keys")) - continue; - - String entity_cp = cpFile.getParent() + "/" + filename + ".cell.keys"; - processed.add(entity_cp); - String header_cp = cpFile.getParent() + "/" + filename + ".header.keys"; - processed.add(header_cp); - String binary_cp = cpFile.getParent() + "/" + filename + ".relation.keys"; - processed.add(binary_cp); - - StringBuilder line = new StringBuilder("\"" + cpFile.getPath() + "\","); - - Map>> cp_headers = - TAnnotationKeyFileReader.readHeaderAnnotation(header_cp, false, gs_NE_only); - - - double[] header_data_mode_0 = Evaluator_ClassOnly.compute_prf_header(gs_headers, cp_headers, 0); - line.append(appendResult(header_data_mode_0)); - - double[] header_data_mode_1 = Evaluator_ClassOnly.compute_prf_header(gs_headers, cp_headers, 1); - line.append(appendResult(header_data_mode_1)); - - p.println(line.toString()); - break; - } - } - if (!found) { - out_missed_writer.println(gsFile); - } - } - out_missed_writer.close(); - p.close(); - } - - private Set create_filter_with_log_file(String log_file_as_filter) throws IOException { - List lines = FileUtils.readList(log_file_as_filter, false); - Set rs = new HashSet(); - boolean next_new_file = false; - String next_new_file_name = ""; - boolean converged = false; - boolean learning_block = false; - - for (String l : lines) { - next_new_file = false; - String[] parts = l.split("_", 2); - if (parts.length > 1) { - try { - Integer.valueOf(parts[0].trim()); - //if(parts[1].trim().startsWith("E:")){ - next_new_file = true; - learning_block = false; - String filePath = parts[1].trim(); - int end = filePath.indexOf(".xml"); - filePath = filePath.substring(0, end + 4).trim(); - next_new_file_name = new File(filePath).getName(); - - //} - } catch (Exception e) { - } - } - - - if (l.contains("FORWARD LEARNING")) - learning_block = true; - else { - if (learning_block == true && l.contains("Convergence iteration=")) { - //converged=true; - rs.add(next_new_file_name); - } - } - - } - - - return rs; //To change body of created methods use File | Settings | File Templates. - } - - public static double[] compute_prf_header(Map>> gs, - Map>> cp, int mode) { - double total_correct_by_cp = 0.0, total_wrong_by_cp = 0.0, total_correct_by_gs = 0.0; - - for (Map.Entry>> e : gs.entrySet()) { - int col = e.getKey(); - List> gs_annotations = e.getValue(); - List gs_vital = gs_annotations.size() > 0 ? gs_annotations.get(0) : new ArrayList(); - List> cp_annotations = cp.get(col); - if (cp_annotations == null) { - cp_annotations = new ArrayList>(); - } - List cp_first = cp_annotations.size() > 0 ? cp_annotations.get(0) : new ArrayList(); - if (cp_first.size() == 0) { - total_correct_by_gs++; - continue; - } - - if (mode == 0) { - double correct_by_gs = 1.0; - double correct_by_cp = 0, wrong_by_cp = 0; - - List intersection = new ArrayList(cp_first); - intersection.retainAll(gs_vital); - - if (intersection.size() > 0) { - if (PREDICTION_ONE_CORRECT_COUNTS_ALL) - correct_by_cp++; //lanient mode. if cp predicts multi labels, as long as one correct, its ok - else { - correct_by_cp += (double) intersection.size() / cp_first.size(); //strict mode. if cp predicts multi labels, must all be correct, otherwise suffers penalty - wrong_by_cp = 1.0 - correct_by_cp; - } - } else { - wrong_by_cp++; - } - // } - total_correct_by_cp += correct_by_cp; - total_correct_by_gs += correct_by_gs; - total_wrong_by_cp += wrong_by_cp; - } else { - int correct_by_gs = 1; - - double correct_by_cp = 0.0, wrong_by_cp = 0.0; - List intersection_vital = new ArrayList(cp_first); - List intersection_ok = new ArrayList(cp_first); - List gs_ok = gs_annotations.size() == 2 ? gs_annotations.get(1) : new ArrayList(); - - intersection_vital.retainAll(gs_vital); - intersection_ok.retainAll(gs_ok); - - double total_correct = intersection_vital.size() + 0.5 * intersection_ok.size(); - correct_by_cp = total_correct / (double) cp_first.size(); - wrong_by_cp = 1.0 - correct_by_cp; - - total_correct_by_cp += correct_by_cp; - total_correct_by_gs += correct_by_gs; - total_wrong_by_cp += wrong_by_cp; - } - } - return new double[]{total_correct_by_cp, total_correct_by_gs, total_wrong_by_cp}; - } - - @Deprecated - public static double[] compute_prf_relation_or_entity(Map>> gs, - Map>> cp, int mode) { - double total_correct_by_cp = 0.0, total_wrong_by_cp = 0.0, total_correct_by_gs = 0.0; - - for (Map.Entry>> e : gs.entrySet()) { - int[] col = e.getKey(); - List> gs_annotations = e.getValue(); - List gs_vital = gs_annotations.size() > 0 ? gs_annotations.get(0) : new ArrayList(); - List> cp_annotations = new ArrayList>(); - - for (Map.Entry>> f : cp.entrySet()) { - int[] col_cp = f.getKey(); - if (col[0] == col_cp[0] && col[1] == col_cp[1]) { - cp_annotations = f.getValue(); - break; - } - } - List cp_first = cp_annotations.size() > 0 ? cp_annotations.get(0) : new ArrayList(); - if (cp_first.size() == 0) { - total_correct_by_gs++; - continue; - } - - - if (mode == 0) { - double correct_by_gs = 1.0; - double correct_by_cp = 0, wrong_by_cp = 0; - - List intersection = new ArrayList(cp_first); - intersection.retainAll(gs_vital); - - if (intersection.size() > 0) { - if (PREDICTION_ONE_CORRECT_COUNTS_ALL) - correct_by_cp++; //lanient mode. if cp predicts multi labels, as long as one correct, its ok - else { - correct_by_cp += (double) intersection.size() / cp_first.size(); //strict mode. if cp predicts multi labels, must all be correct, otherwise suffers penalty - wrong_by_cp = 1.0 - correct_by_cp; - } - } else { - wrong_by_cp++; - } - // } - total_correct_by_cp += correct_by_cp; - total_correct_by_gs += correct_by_gs; - total_wrong_by_cp += wrong_by_cp; - } else { - int correct_by_gs = 1; - - double correct_by_cp = 0.0, wrong_by_cp = 0.0; - List intersection_vital = new ArrayList(cp_first); - List intersection_ok = new ArrayList(cp_first); - List gs_ok = gs_annotations.size() == 2 ? gs_annotations.get(1) : new ArrayList(); - - intersection_vital.retainAll(gs_vital); - intersection_ok.retainAll(gs_ok); - - double total_correct = intersection_vital.size() + 0.5 * intersection_ok.size(); - correct_by_cp = total_correct / (double) cp_first.size(); - wrong_by_cp = cp_first.size() - correct_by_cp; - - total_correct_by_cp += correct_by_cp; - total_correct_by_gs += correct_by_gs; - total_wrong_by_cp += wrong_by_cp; - } - } - return new double[]{total_correct_by_cp, total_correct_by_gs, total_wrong_by_cp}; - } - - - private String appendResult(double[] values) { - StringBuilder sb = new StringBuilder(); - sb.append(values[0]).append(",") - .append(values[1]).append(",") - .append(values[2]).append(","); - double p = values[0] / (values[0] + values[2]); - p = values[0] == 0 ? 0.0 : p; - - double r = values[0] / (values[1]); - r = values[0] == 0 ? 0 : r; - double f = 2 * p * r / (p + r); - f = r == 0.0 || p == 0.0 ? 0.0 : f; - - sb.append(p).append(",") - .append(r).append(",") - .append(f).append(","); - return sb.toString(); - - } - -} +package uk.ac.shef.dcs.sti.todo.evaluation; + +import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; +import uk.ac.shef.dcs.sti.util.FileUtils; + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.*; + +/** + * Created with IntelliJ IDEA. + * User: zqz + * Date: 26/02/14 + * Time: 14:14 + * To change this template use File | Settings | File Templates. + */ +public class Evaluator_ClassOnly { + + protected static boolean PREDICTION_ONE_CORRECT_COUNTS_ALL = false; //if prediction has multiple labels while gs has 1, if prediction covers gs, should it be 1 correct (true) or not (false) + + + public static void main(String[] args) throws IOException { + + /*Evaluator_Generic evaluator = new Evaluator_Generic(); + evaluator.evaluate( + "E:\\Data\\table annotation\\corpus_analysis\\100_tables\\100_tables_annotated(disamb=0)", + "E:\\Data\\table annotation\\corpus_analysis\\100_tables\\100_tables_gs", + "eval.csv", + "missed.csv" + );*/ + Evaluator_ClassOnly evaluator = new Evaluator_ClassOnly(); + evaluator.evaluate( + /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_cos(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_header_bs_cos-all.csv", + "tmp_result/limaye_header_bs_cos-all_missed.csv", false*/ + "E:\\Data\\table_annotation\\limaye_sample\\112_tables\\tableminer\\tableminer_swj", + "E:\\Data\\table_annotation\\limaye_sample\\112_tables\\gs\\112_tables_gs(aclshort-changed-iswc)", + "tmp_result/limaye_100_bs.csv", + "tmp_result/limaye_100_bs_missed.csv", true + + /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_nm+first(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_header_bs_nm-all.csv", + "tmp_result/limaye_header_bs_nm-all_missed.csv", false*/ + /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_nm+first(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_header_bs_nm-ne.csv", + "tmp_result/limaye_header_bs_nm-ne_missed.csv", true*/ + + /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_dice(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_header_bs_sl_dice-all.csv", + "tmp_result/limaye_header_bs_sl_dice-all_missed.csv", false*/ + + /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_dice(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_header_bs_sl_dice-ne.csv", + "tmp_result/limaye_header_bs_sl_dice-ne_missed.csv", true*/ + + /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_lev(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_header_bs_sl_lev-all.csv", + "tmp_result/limaye_header_bs_sl_lev-all_missed.csv", false*/ + + /* "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_lev(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_header_bs_sl_lev-ne.csv", + "tmp_result/limaye_header_bs_sl_lev-ne_missed.csv", true + */ + /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_header_tm_ospd-all.csv", + "tmp_result/limaye_header_tm_ospd-all_missed.csv", false*/ + + /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_header_tm_ospd-ne.csv", + "tmp_result/limaye_header_tm_ospd-ne_missed.csv", true*/ + + /* "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd_nsc", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_header_tm_ospd_nsc-all.csv", + "tmp_result/limaye_header_tm_ospd_nsc-all_missed.csv", false*/ + + /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd_nsc", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_header_tm_ospd_nsc-ne.csv", + "tmp_result/limaye_header_tm_ospd_nsc-ne_missed.csv", true*/ + ); + + } + + public void evaluate(String in_computed_folder, + String in_gs_folder, + String out_result_file, + String out_missed_file, boolean gs_NE_only) throws IOException { + PrintWriter p = new PrintWriter(out_result_file); + p.println("File,HEADER(0)_cp_y, gs_y, cp_n, p,r,f," + + "HEADER(1)_cp_y, gs_y, cp_n, p,r,f"); + + + PrintWriter out_missed_writer = new PrintWriter(out_missed_file); + Set processed = new HashSet(); + for (File gsFile : new File(in_gs_folder).listFiles()) { + + Map>> gs_headers = null; + + String filename = gsFile.getName(); + if (processed.contains(filename)) + continue; + + if (filename.endsWith(".keys")) { + int dothtml = filename.lastIndexOf(".html"); + if (dothtml == -1) + dothtml = filename.lastIndexOf(".htm"); + if (dothtml == -1) { + System.err.println(filename); + continue; + } + int end = dothtml + 5; + + filename = filename.substring(0, end).trim(); + System.out.println(filename); + /* if(filename.contains("Wisden")) + System.out.println();*/ + //if (!filename.contains(".attributes") && !filename.contains(".keys") && !processed.contains(filename)) { + String entity_gs = gsFile.getParent() + "/" + filename + ".cell.keys"; + processed.add(entity_gs); + String header_gs = gsFile.getParent() + "/" + filename + ".header.keys"; + processed.add(header_gs); + String binary = gsFile.getParent() + "/" + filename + ".relation.keys"; + processed.add(binary); + + gs_headers = TAnnotationKeyFileReader.readHeaderAnnotation(header_gs, true, gs_NE_only); + processed.add(filename); + + } else { + continue; + } + if (gs_headers == null) { + System.err.println(filename); + continue; + } + + boolean found = false; + + for (File cpFile : new File(in_computed_folder).listFiles()) { + if (cpFile.getName().startsWith(filename)) { + found = true; + + String cpFile_name = cpFile.toString(); + if (processed.contains(cpFile_name) || !cpFile_name.endsWith("keys")) + continue; + + String entity_cp = cpFile.getParent() + "/" + filename + ".cell.keys"; + processed.add(entity_cp); + String header_cp = cpFile.getParent() + "/" + filename + ".header.keys"; + processed.add(header_cp); + String binary_cp = cpFile.getParent() + "/" + filename + ".relation.keys"; + processed.add(binary_cp); + + StringBuilder line = new StringBuilder("\"" + cpFile.getPath() + "\","); + + Map>> cp_headers = + TAnnotationKeyFileReader.readHeaderAnnotation(header_cp, false, gs_NE_only); + + + double[] header_data_mode_0 = Evaluator_ClassOnly.compute_prf_header(gs_headers, cp_headers, 0); + line.append(appendResult(header_data_mode_0)); + + double[] header_data_mode_1 = Evaluator_ClassOnly.compute_prf_header(gs_headers, cp_headers, 1); + line.append(appendResult(header_data_mode_1)); + + p.println(line.toString()); + break; + } + } + if (!found) { + out_missed_writer.println(gsFile); + } + } + out_missed_writer.close(); + p.close(); + } + + public void evaluate_with_filter( + String log_file_as_filter, + String in_computed_folder, + String in_gs_folder, + String out_result_file, + String out_missed_file, boolean gs_NE_only) throws IOException { + + Set keepFiles = create_filter_with_log_file(log_file_as_filter); + PrintWriter p = new PrintWriter(out_result_file); + p.println("File,HEADER(0)_cp_y, gs_y, cp_n, p,r,f," + + "HEADER(1)_cp_y, gs_y, cp_n, p,r,f"); + + + PrintWriter out_missed_writer = new PrintWriter(out_missed_file); + Set processed = new HashSet(); + for (File gsFile : new File(in_gs_folder).listFiles()) { + if (!keepFiles.contains(gsFile.getName())) + continue; + + Map>> gs_headers = null; + + String filename = gsFile.getName(); + if (processed.contains(filename)) + continue; + + if (filename.endsWith(".keys")) { + int dothtml = filename.lastIndexOf(".html"); + if (dothtml == -1) + dothtml = filename.lastIndexOf(".htm"); + if (dothtml == -1) { + System.err.println(filename); + continue; + } + int end = dothtml + 5; + + filename = filename.substring(0, end).trim(); + System.out.println(filename); + /* if(filename.contains("Wisden")) + System.out.println();*/ + //if (!filename.contains(".attributes") && !filename.contains(".keys") && !processed.contains(filename)) { + String entity_gs = gsFile.getParent() + "/" + filename + ".cell.keys"; + processed.add(entity_gs); + String header_gs = gsFile.getParent() + "/" + filename + ".header.keys"; + processed.add(header_gs); + String binary = gsFile.getParent() + "/" + filename + ".relation.keys"; + processed.add(binary); + + gs_headers = TAnnotationKeyFileReader.readHeaderAnnotation(header_gs, true, gs_NE_only); + processed.add(filename); + + } else { + continue; + } + if (gs_headers == null) { + System.err.println(filename); + continue; + } + + boolean found = false; + + for (File cpFile : new File(in_computed_folder).listFiles()) { + if (cpFile.getName().startsWith(filename)) { + found = true; + + String cpFile_name = cpFile.toString(); + if (processed.contains(cpFile_name) || !cpFile_name.endsWith("keys")) + continue; + + String entity_cp = cpFile.getParent() + "/" + filename + ".cell.keys"; + processed.add(entity_cp); + String header_cp = cpFile.getParent() + "/" + filename + ".header.keys"; + processed.add(header_cp); + String binary_cp = cpFile.getParent() + "/" + filename + ".relation.keys"; + processed.add(binary_cp); + + StringBuilder line = new StringBuilder("\"" + cpFile.getPath() + "\","); + + Map>> cp_headers = + TAnnotationKeyFileReader.readHeaderAnnotation(header_cp, false, gs_NE_only); + + + double[] header_data_mode_0 = Evaluator_ClassOnly.compute_prf_header(gs_headers, cp_headers, 0); + line.append(appendResult(header_data_mode_0)); + + double[] header_data_mode_1 = Evaluator_ClassOnly.compute_prf_header(gs_headers, cp_headers, 1); + line.append(appendResult(header_data_mode_1)); + + p.println(line.toString()); + break; + } + } + if (!found) { + out_missed_writer.println(gsFile); + } + } + out_missed_writer.close(); + p.close(); + } + + private Set create_filter_with_log_file(String log_file_as_filter) throws IOException { + List lines = FileUtils.readList(log_file_as_filter, false); + Set rs = new HashSet(); + boolean next_new_file = false; + String next_new_file_name = ""; + boolean converged = false; + boolean learning_block = false; + + for (String l : lines) { + next_new_file = false; + String[] parts = l.split("_", 2); + if (parts.length > 1) { + try { + Integer.valueOf(parts[0].trim()); + //if(parts[1].trim().startsWith("E:")){ + next_new_file = true; + learning_block = false; + String filePath = parts[1].trim(); + int end = filePath.indexOf(".xml"); + filePath = filePath.substring(0, end + 4).trim(); + next_new_file_name = new File(filePath).getName(); + + //} + } catch (Exception e) { + } + } + + + if (l.contains("FORWARD LEARNING")) + learning_block = true; + else { + if (learning_block == true && l.contains("Convergence iteration=")) { + //converged=true; + rs.add(next_new_file_name); + } + } + + } + + + return rs; //To change body of created methods use File | Settings | File Templates. + } + + public static double[] compute_prf_header(Map>> gs, + Map>> cp, int mode) { + double total_correct_by_cp = 0.0, total_wrong_by_cp = 0.0, total_correct_by_gs = 0.0; + + for (Map.Entry>> e : gs.entrySet()) { + int col = e.getKey(); + List> gs_annotations = e.getValue(); + List gs_vital = gs_annotations.size() > 0 ? gs_annotations.get(0) : new ArrayList(); + List> cp_annotations = cp.get(col); + if (cp_annotations == null) { + cp_annotations = new ArrayList>(); + } + List cp_first = cp_annotations.size() > 0 ? cp_annotations.get(0) : new ArrayList(); + if (cp_first.size() == 0) { + total_correct_by_gs++; + continue; + } + + if (mode == 0) { + double correct_by_gs = 1.0; + double correct_by_cp = 0, wrong_by_cp = 0; + + List intersection = new ArrayList(cp_first); + intersection.retainAll(gs_vital); + + if (intersection.size() > 0) { + if (PREDICTION_ONE_CORRECT_COUNTS_ALL) + correct_by_cp++; //lanient mode. if cp predicts multi labels, as long as one correct, its ok + else { + correct_by_cp += (double) intersection.size() / cp_first.size(); //strict mode. if cp predicts multi labels, must all be correct, otherwise suffers penalty + wrong_by_cp = 1.0 - correct_by_cp; + } + } else { + wrong_by_cp++; + } + // } + total_correct_by_cp += correct_by_cp; + total_correct_by_gs += correct_by_gs; + total_wrong_by_cp += wrong_by_cp; + } else { + int correct_by_gs = 1; + + double correct_by_cp = 0.0, wrong_by_cp = 0.0; + List intersection_vital = new ArrayList(cp_first); + List intersection_ok = new ArrayList(cp_first); + List gs_ok = gs_annotations.size() == 2 ? gs_annotations.get(1) : new ArrayList(); + + intersection_vital.retainAll(gs_vital); + intersection_ok.retainAll(gs_ok); + + double total_correct = intersection_vital.size() + 0.5 * intersection_ok.size(); + correct_by_cp = total_correct / (double) cp_first.size(); + wrong_by_cp = 1.0 - correct_by_cp; + + total_correct_by_cp += correct_by_cp; + total_correct_by_gs += correct_by_gs; + total_wrong_by_cp += wrong_by_cp; + } + } + return new double[]{total_correct_by_cp, total_correct_by_gs, total_wrong_by_cp}; + } + + @Deprecated + public static double[] compute_prf_relation_or_entity(Map>> gs, + Map>> cp, int mode) { + double total_correct_by_cp = 0.0, total_wrong_by_cp = 0.0, total_correct_by_gs = 0.0; + + for (Map.Entry>> e : gs.entrySet()) { + int[] col = e.getKey(); + List> gs_annotations = e.getValue(); + List gs_vital = gs_annotations.size() > 0 ? gs_annotations.get(0) : new ArrayList(); + List> cp_annotations = new ArrayList>(); + + for (Map.Entry>> f : cp.entrySet()) { + int[] col_cp = f.getKey(); + if (col[0] == col_cp[0] && col[1] == col_cp[1]) { + cp_annotations = f.getValue(); + break; + } + } + List cp_first = cp_annotations.size() > 0 ? cp_annotations.get(0) : new ArrayList(); + if (cp_first.size() == 0) { + total_correct_by_gs++; + continue; + } + + + if (mode == 0) { + double correct_by_gs = 1.0; + double correct_by_cp = 0, wrong_by_cp = 0; + + List intersection = new ArrayList(cp_first); + intersection.retainAll(gs_vital); + + if (intersection.size() > 0) { + if (PREDICTION_ONE_CORRECT_COUNTS_ALL) + correct_by_cp++; //lanient mode. if cp predicts multi labels, as long as one correct, its ok + else { + correct_by_cp += (double) intersection.size() / cp_first.size(); //strict mode. if cp predicts multi labels, must all be correct, otherwise suffers penalty + wrong_by_cp = 1.0 - correct_by_cp; + } + } else { + wrong_by_cp++; + } + // } + total_correct_by_cp += correct_by_cp; + total_correct_by_gs += correct_by_gs; + total_wrong_by_cp += wrong_by_cp; + } else { + int correct_by_gs = 1; + + double correct_by_cp = 0.0, wrong_by_cp = 0.0; + List intersection_vital = new ArrayList(cp_first); + List intersection_ok = new ArrayList(cp_first); + List gs_ok = gs_annotations.size() == 2 ? gs_annotations.get(1) : new ArrayList(); + + intersection_vital.retainAll(gs_vital); + intersection_ok.retainAll(gs_ok); + + double total_correct = intersection_vital.size() + 0.5 * intersection_ok.size(); + correct_by_cp = total_correct / (double) cp_first.size(); + wrong_by_cp = cp_first.size() - correct_by_cp; + + total_correct_by_cp += correct_by_cp; + total_correct_by_gs += correct_by_gs; + total_wrong_by_cp += wrong_by_cp; + } + } + return new double[]{total_correct_by_cp, total_correct_by_gs, total_wrong_by_cp}; + } + + + private String appendResult(double[] values) { + StringBuilder sb = new StringBuilder(); + sb.append(values[0]).append(",") + .append(values[1]).append(",") + .append(values[2]).append(","); + double p = values[0] / (values[0] + values[2]); + p = values[0] == 0 ? 0.0 : p; + + double r = values[0] / (values[1]); + r = values[0] == 0 ? 0 : r; + double f = 2 * p * r / (p + r); + f = r == 0.0 || p == 0.0 ? 0.0 : f; + + sb.append(p).append(",") + .append(r).append(",") + .append(f).append(","); + return sb.toString(); + + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly_IMDB_MusicBrainz.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly_IMDB_MusicBrainz.java index f633492a..025a7ebe 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly_IMDB_MusicBrainz.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ClassOnly_IMDB_MusicBrainz.java @@ -1,228 +1,228 @@ -package uk.ac.shef.dcs.sti.todo.evaluation; - -import uk.ac.shef.dcs.kbsearch.freebase.FreebaseQueryProxy; -import uk.ac.shef.dcs.kbsearch.model.Attribute; -import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; - -import java.io.File; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.*; - -/** - * - */ -public class Evaluator_ClassOnly_IMDB_MusicBrainz { - - - public static void main(String[] args) throws IOException { - - - /*Evaluator_Generic evaluator = new Evaluator_Generic(); - evaluator.evaluate( - "E:\\Data\\table annotation\\corpus_analysis\\100_tables\\100_tables_annotated(disamb=0)", - "E:\\Data\\table annotation\\corpus_analysis\\100_tables\\100_tables_gs", - "eval.csv", - "missed.csv" - );*/ - Evaluator_ClassOnly_IMDB_MusicBrainz evaluator = new Evaluator_ClassOnly_IMDB_MusicBrainz(); - /*evaluator.evaluate( - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_base_nm", - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs/imdb.header.keys", - "tmp_result/imdb_header_base_nm.csv", - "tmp_result/imdb_header_base_nm_missed.csv", true*//* - - *//**//*"E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_base_sl_lev", - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs/imdb.header.keys", - "tmp_result/imdb_header_base_lev.csv", - "tmp_result/imdb_header_base_lev_missed.csv", true*//**//* - - *//**//*"E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_tm_ospd", - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs/imdb.header.keys", - "tmp_result/imdb_header_tm_ospd.csv", - "tmp_result/imdb_header_tm_ospd_missed.csv", true*//**//* - - *//**//* "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_tm_ospd_nsc", - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs/imdb.header.keys", - "tmp_result/imdb_header_tm_ospd_nsc.csv", - "tmp_result/imdb_header_tm_ospd_nsc_missed.csv", true*//**//* - - *//**//*"E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_base_sl_dice", - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs/imdb.header.keys", - "tmp_result/imdb_header_base_dice.csv", - "tmp_result/imdb_header_base_dice_missed.csv", true*//* - ); - System.exit(0);*/ - - evaluator.evaluate( - /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_nm", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_header_base_nm-all.csv", - "tmp_result/mb_header_base_nm_missed-all.csv", false*/ - - /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_nm", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_header_base_nm-ne.csv", - "tmp_result/mb_header_base_nm_missed-ne.csv", true*/ - - /* "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_dice", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_header_base_dice-all.csv", - "tmp_result/mb_header_base_dice_missed-all.csv", false*/ - - /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_dice", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_header_base_dice-ne.csv", - "tmp_result/mb_header_base_dice_missed-ne.csv", true*/ - - /* "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_lev", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_header_base_lev-all.csv", - "tmp_result/mb_header_base_lev_missed-all.csv", false -*/ - /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_lev", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_header_base_lev-ne.csv", - "tmp_result/mb_header_base_lev_missed-ne.csv", true*/ - - /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_tm_ospd", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_header_tm_ospd-all.csv", - "tmp_result/mb_header_tm_ospd_missed-all.csv", false*/ - - /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_tm_ospd", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_header_tm_ospd-ne.csv", - "tmp_result/mb_header_tm_ospd_missed-ne.csv", true*/ - "E:\\dataset>\\dataset>\\datasets\\IEmanualDataset\\film\\boxoffice_2000", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_header_tm_ospd_nsc-all.csv", - "tmp_result/mb_header_tm_ospd_missed_nsc-all.csv", false - - ); - - } - - public void evaluate(String in_computed_folder, - String in_gs_file, - String out_result_file, - String out_missed_file, boolean gs_NE_only) throws IOException { - //todo: this will not work - FreebaseQueryProxy fb = null;//new FreebaseQueryProxy("D:\\Work\\sti\\dist/sti.properties"); - PrintWriter p = new PrintWriter(out_result_file); - p.println("File,HEADER(0)_cp_y, gs_y, cp_n, p,r,f," + - "HEADER(1)_cp_y, gs_y, cp_n, p,r,f"); - - - PrintWriter out_missed_writer = new PrintWriter(out_missed_file); - Set processed = new HashSet(); - Map>> gs_headers = TAnnotationKeyFileReader.readHeaderAnnotation(in_gs_file, true, gs_NE_only); - - Map> unique_urls = new HashMap>(); - - int count = 0; - for (File cpFile : new File(in_computed_folder).listFiles()) { - - String filename = cpFile.getName(); - if (processed.contains(filename)) - continue; - - if (filename.contains(".header.keys")) { - int dothtml = filename.lastIndexOf(".html"); - if (dothtml == -1) - dothtml = filename.lastIndexOf(".htm"); - if (dothtml == -1) { - System.err.println(filename); - continue; - } - int end = dothtml + 5; - - count++; - filename = filename.substring(0, end).trim(); - System.out.println(count + "_" + filename); - - processed.add(filename); - String header_cp = cpFile.getParent() + "/" + filename + ".header.keys"; - processed.add(header_cp); - - StringBuilder line = new StringBuilder("\"" + cpFile.getPath() + "\","); - - Map>> cp_headers = - TAnnotationKeyFileReader.readHeaderAnnotation(header_cp, false, gs_NE_only); - for (Integer i : cp_headers.keySet()) { - List> ll = cp_headers.get(i); - Set unique = unique_urls.get(i); - unique = unique == null ? new HashSet() : unique; - for (List l : ll) - unique.addAll(l); - /* if(unique.contains("/m/0174nj")) - System.out.println();*/ - unique_urls.put(i, unique); - } - - - double[] header_data_mode_0 = Evaluator_ClassOnly.compute_prf_header(gs_headers, cp_headers, 0); - line.append(appendResult(header_data_mode_0)); - - double[] header_data_mode_1 = Evaluator_ClassOnly.compute_prf_header(gs_headers, cp_headers, 1); - line.append(appendResult(header_data_mode_1)); - - p.println(line.toString()); - //break; - - } else { - continue; - } - - - } - out_missed_writer.close(); - p.close(); - - for (Integer i : unique_urls.keySet()) { - - List unique_sorted = new ArrayList(unique_urls.get(i)); - Collections.sort(unique_sorted); - System.out.println(">>>" + i); - for (String s : unique_sorted) { - if (s.startsWith("/m/")) { - try { - List facts = fb.topicapi_getAttributesOfTopicID(s, "/type/object/name"); - ; - if (facts.size() > 0) - s = s + ":" + facts.get(0).getValue(); - } catch (Exception e) { - - } - } - System.out.println(s); - } - } - } - - - private String appendResult(double[] values) { - StringBuilder sb = new StringBuilder(); - sb.append(values[0]).append(",") - .append(values[1]).append(",") - .append(values[2]).append(","); - double p = values[0] / (values[0] + values[2]); - p = values[0] == 0 ? 0.0 : p; - - double r = values[0] / (values[1]); - r = values[0] == 0 ? 0 : r; - double f = 2 * p * r / (p + r); - f = r == 0.0 || p == 0.0 ? 0.0 : f; - - sb.append(p).append(",") - .append(r).append(",") - .append(f).append(","); - return sb.toString(); - - } - - - //return double[] 0-correct by cp; 1-correct by gs; 2-wrong by cp (i.e., missed) - - -} +package uk.ac.shef.dcs.sti.todo.evaluation; + +import uk.ac.shef.dcs.kbsearch.freebase.FreebaseQueryProxy; +import uk.ac.shef.dcs.kbsearch.model.Attribute; +import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.*; + +/** + * + */ +public class Evaluator_ClassOnly_IMDB_MusicBrainz { + + + public static void main(String[] args) throws IOException { + + + /*Evaluator_Generic evaluator = new Evaluator_Generic(); + evaluator.evaluate( + "E:\\Data\\table annotation\\corpus_analysis\\100_tables\\100_tables_annotated(disamb=0)", + "E:\\Data\\table annotation\\corpus_analysis\\100_tables\\100_tables_gs", + "eval.csv", + "missed.csv" + );*/ + Evaluator_ClassOnly_IMDB_MusicBrainz evaluator = new Evaluator_ClassOnly_IMDB_MusicBrainz(); + /*evaluator.evaluate( + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_base_nm", + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs/imdb.header.keys", + "tmp_result/imdb_header_base_nm.csv", + "tmp_result/imdb_header_base_nm_missed.csv", true*//* + + *//**//*"E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_base_sl_lev", + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs/imdb.header.keys", + "tmp_result/imdb_header_base_lev.csv", + "tmp_result/imdb_header_base_lev_missed.csv", true*//**//* + + *//**//*"E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_tm_ospd", + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs/imdb.header.keys", + "tmp_result/imdb_header_tm_ospd.csv", + "tmp_result/imdb_header_tm_ospd_missed.csv", true*//**//* + + *//**//* "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_tm_ospd_nsc", + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs/imdb.header.keys", + "tmp_result/imdb_header_tm_ospd_nsc.csv", + "tmp_result/imdb_header_tm_ospd_nsc_missed.csv", true*//**//* + + *//**//*"E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_base_sl_dice", + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs/imdb.header.keys", + "tmp_result/imdb_header_base_dice.csv", + "tmp_result/imdb_header_base_dice_missed.csv", true*//* + ); + System.exit(0);*/ + + evaluator.evaluate( + /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_nm", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_header_base_nm-all.csv", + "tmp_result/mb_header_base_nm_missed-all.csv", false*/ + + /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_nm", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_header_base_nm-ne.csv", + "tmp_result/mb_header_base_nm_missed-ne.csv", true*/ + + /* "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_dice", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_header_base_dice-all.csv", + "tmp_result/mb_header_base_dice_missed-all.csv", false*/ + + /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_dice", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_header_base_dice-ne.csv", + "tmp_result/mb_header_base_dice_missed-ne.csv", true*/ + + /* "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_lev", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_header_base_lev-all.csv", + "tmp_result/mb_header_base_lev_missed-all.csv", false +*/ + /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_lev", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_header_base_lev-ne.csv", + "tmp_result/mb_header_base_lev_missed-ne.csv", true*/ + + /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_tm_ospd", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_header_tm_ospd-all.csv", + "tmp_result/mb_header_tm_ospd_missed-all.csv", false*/ + + /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_tm_ospd", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_header_tm_ospd-ne.csv", + "tmp_result/mb_header_tm_ospd_missed-ne.csv", true*/ + "E:\\dataset>\\dataset>\\datasets\\IEmanualDataset\\film\\boxoffice_2000", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_header_tm_ospd_nsc-all.csv", + "tmp_result/mb_header_tm_ospd_missed_nsc-all.csv", false + + ); + + } + + public void evaluate(String in_computed_folder, + String in_gs_file, + String out_result_file, + String out_missed_file, boolean gs_NE_only) throws IOException { + //todo: this will not work + FreebaseQueryProxy fb = null;//new FreebaseQueryProxy("D:\\Work\\sti\\dist/sti.properties"); + PrintWriter p = new PrintWriter(out_result_file); + p.println("File,HEADER(0)_cp_y, gs_y, cp_n, p,r,f," + + "HEADER(1)_cp_y, gs_y, cp_n, p,r,f"); + + + PrintWriter out_missed_writer = new PrintWriter(out_missed_file); + Set processed = new HashSet(); + Map>> gs_headers = TAnnotationKeyFileReader.readHeaderAnnotation(in_gs_file, true, gs_NE_only); + + Map> unique_urls = new HashMap>(); + + int count = 0; + for (File cpFile : new File(in_computed_folder).listFiles()) { + + String filename = cpFile.getName(); + if (processed.contains(filename)) + continue; + + if (filename.contains(".header.keys")) { + int dothtml = filename.lastIndexOf(".html"); + if (dothtml == -1) + dothtml = filename.lastIndexOf(".htm"); + if (dothtml == -1) { + System.err.println(filename); + continue; + } + int end = dothtml + 5; + + count++; + filename = filename.substring(0, end).trim(); + System.out.println(count + "_" + filename); + + processed.add(filename); + String header_cp = cpFile.getParent() + "/" + filename + ".header.keys"; + processed.add(header_cp); + + StringBuilder line = new StringBuilder("\"" + cpFile.getPath() + "\","); + + Map>> cp_headers = + TAnnotationKeyFileReader.readHeaderAnnotation(header_cp, false, gs_NE_only); + for (Integer i : cp_headers.keySet()) { + List> ll = cp_headers.get(i); + Set unique = unique_urls.get(i); + unique = unique == null ? new HashSet() : unique; + for (List l : ll) + unique.addAll(l); + /* if(unique.contains("/m/0174nj")) + System.out.println();*/ + unique_urls.put(i, unique); + } + + + double[] header_data_mode_0 = Evaluator_ClassOnly.compute_prf_header(gs_headers, cp_headers, 0); + line.append(appendResult(header_data_mode_0)); + + double[] header_data_mode_1 = Evaluator_ClassOnly.compute_prf_header(gs_headers, cp_headers, 1); + line.append(appendResult(header_data_mode_1)); + + p.println(line.toString()); + //break; + + } else { + continue; + } + + + } + out_missed_writer.close(); + p.close(); + + for (Integer i : unique_urls.keySet()) { + + List unique_sorted = new ArrayList(unique_urls.get(i)); + Collections.sort(unique_sorted); + System.out.println(">>>" + i); + for (String s : unique_sorted) { + if (s.startsWith("/m/")) { + try { + List facts = fb.topicapi_getAttributesOfTopicID(s, "/type/object/name"); + ; + if (facts.size() > 0) + s = s + ":" + facts.get(0).getValue(); + } catch (Exception e) { + + } + } + System.out.println(s); + } + } + } + + + private String appendResult(double[] values) { + StringBuilder sb = new StringBuilder(); + sb.append(values[0]).append(",") + .append(values[1]).append(",") + .append(values[2]).append(","); + double p = values[0] / (values[0] + values[2]); + p = values[0] == 0 ? 0.0 : p; + + double r = values[0] / (values[1]); + r = values[0] == 0 ? 0 : r; + double f = 2 * p * r / (p + r); + f = r == 0.0 || p == 0.0 ? 0.0 : f; + + sb.append(p).append(",") + .append(r).append(",") + .append(f).append(","); + return sb.toString(); + + } + + + //return double[] 0-correct by cp; 1-correct by gs; 2-wrong by cp (i.e., missed) + + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_EntityOnly.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_EntityOnly.java index d82e3159..c1f007c7 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_EntityOnly.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_EntityOnly.java @@ -1,280 +1,280 @@ -package uk.ac.shef.dcs.sti.todo.evaluation; - -import java.io.File; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.*; - -import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; - -/** - - */ -public class Evaluator_EntityOnly { - protected static boolean PREDICTION_ONE_CORRECT_COUNTS_ALL = false; //if prediction has multiple labels while gs has 1, if prediction covers gs, should it be 1 correct (true) or not (false) - protected static List filter_files = new ArrayList(); - - - public static void main(String[] args) throws IOException { - /*String only_files_from = "E:\\Data\\table_annotation\\limaye_sample\\112_tables\\raw\\112_tables"; - if (only_files_from.length() > 0) { - for (File f : new File(only_files_from).listFiles()) { - filter_files.add(f.getName()); - } - }*/ - - Evaluator_EntityOnly evaluator = new Evaluator_EntityOnly(); - /************************************************ - FORY limaye200 - *************************************************/ - evaluator.evaluate( - /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\entity", - "tmp_result/limaye_entity_tm_ospd.csv", - "tmp_result/limaye_entity_tm_ospd_missed.csv", - true*//* - - *//*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd_nsc", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\entity", - "tmp_result/limaye_entity_tm_ospd_nsc.csv", - "tmp_result/limaye_entity_tm_ospd_nsc_missed.csv", - true*//* - - *//*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_lev(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\entity", - "tmp_result/limaye_entity_bs_sl_lev.csv", - "tmp_result/limaye_entity_bs_sl_lev_missed.csv", - true*//* - - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_dice(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\entity", - "tmp_result/limaye_entity_bs_sl_dice.csv", - "tmp_result/limaye_entity_bs_sl_dice_missed.csv", - true - - */ - /* "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_nm+first(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\entity", - "tmp_result/limaye_entity_bs_nm.csv", - "tmp_result/limaye_entity_bs_nm_missed.csv", - true*/ - - "E:\\Data\\table_annotation\\freebase_crawl\\ti_limaye_smp-tableminer\\limaye_smp_computed", - "E:\\Data\\table_annotation\\limayeall\\all_tables_groundtruth_freebase(regen)", - "tmp_result/limaye_entity_smp-tableminer.csv", - "tmp_result/limaye_entity_smp-tableminer_missed.csv", - true - - ); - System.exit(0); - - /************************************************ - FORY imdb or musicbrainz - *************************************************/ - evaluator.evaluate( - /* "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_base_nm", - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs\\imdb_gs(entity)_reformatted", - "tmp_result/imdb_entity_base_nm.csv", - "tmp_result/imdb_entity_base_nm_missed.csv", - false*/ - - /*"E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_base_sl_lev", - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs\\imdb_gs(entity)_reformatted", - "tmp_result/imdb_entity_base_lev.csv", - "tmp_result/imdb_entity_base_lev_missed.csv", - false*/ - - /*"E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_tm_ospd", - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs\\imdb_gs(entity)_reformatted", - "tmp_result/imdb_entity_tm_ospd.csv", - "tmp_result/imdb_entity_tm_ospd_missed.csv", - false*/ - - /*"E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_tm_ospd_nsc", - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs\\imdb_gs(entity)_reformatted", - "tmp_result/imdb_entity_tm_ospd_nsc.csv", - "tmp_result/imdb_entity_tm_ospd_nsc_missed.csv", - false*/ - - /*"E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_base_sl_dice", - "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs\\imdb_gs(entity)_reformatted", - "tmp_result/imdb_entity_base_dice.csv", - "tmp_result/imdb_entity_base_dice_missed.csv", - false*/ - - /* - */ - - - /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_nm", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs\\musicbrainz_gs(entity)_reformatted", - "tmp_result/mb_entity_base_nm.csv", - "tmp_result/mb_entity_base_nm_missed.csv", - false*/ - - /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_dice", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs\\musicbrainz_gs(entity)_reformatted", - "tmp_result/mb_entity_base_dice.csv", - "tmp_result/mb_entity_base_dice_missed.csv", - false*/ - - /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_lev", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs\\musicbrainz_gs(entity)_reformatted", - "tmp_result/mb_entity_base_lev.csv", - "tmp_result/mb_entity_base_lev_missed.csv", - false*/ - - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_tm_ospd_nsc", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs\\musicbrainz_gs(entity)_reformatted", - "tmp_result/mb_entity_tm_ospd-nsc.csv", - "tmp_result/mb_entity_tm_ospd_missed-nsc.csv", - false - - - ); - System.exit(0); - - /* Evaluator_EntityOnly evaluator = new Evaluator_EntityOnly(); - evaluator.evaluate( - "E:\\Data\\table annotation\\freebase_crawl\\film_film\\imdb_computed_(no_ref_ent)", - "E:\\Data\\table annotation\\freebase_crawl\\film_film\\imdb_gs_reformatted", - "tm_eval.csv", - "missed.csv" - ); - System.exit(0); - evaluator.evaluate( - "E:\\Data\\table annotation\\freebase_crawl\\music_record_label\\musicbrainz_computed", - "E:\\Data\\table annotation\\freebase_crawl\\music_record_label\\musicbrainz_gs_reformatted", - "tm_eval.csv", - "missed.csv" - );*/ - /*Evaluator_EntityOnly evaluator = new Evaluator_EntityOnly(); - evaluator.evaluate( - "E:\\Data\\table annotation\\freebase_crawl\\film_film\\imdb_computed_base", - "E:\\Data\\table annotation\\freebase_crawl\\film_film\\imdb_gs_reformatted", - "eval.csv", - "missed.csv" - );*/ - /*Evaluator_Generic evaluator = new Evaluator_Generic(); - evaluator.evaluate( - "E:\\Data\\table annotation\\corpus_analysis\\100_tables\\100_tables_annotated(baseline)", - "E:\\Data\\table annotation\\corpus_analysis\\100_tables\\100_tables_gs", - "eval.csv", - "missed.csv" - );*/ - - } - - public void evaluate(String in_computed_folder, - String in_gs_folder, - String out_result_file, - String out_missed_file, - boolean limaye) throws IOException { - PrintWriter p = new PrintWriter(out_result_file); - p.println("File,ENT(0)_cp_y,gs_y,cp_n,p,r,f," + - "ENT(1)_cp_y,gs_y,cp_n,p,r,f"); - - - PrintWriter out_missed_writer = new PrintWriter(out_missed_file); - Set processed = new HashSet(); - int count = 0; - for (File gsFile : new File(in_gs_folder).listFiles()) { - Map>> gs_cells = null; - String filename = gsFile.getName(); - - boolean include = false; - if (filename.endsWith(".keys")) { - if (filter_files.size() > 0) { - for (String f : filter_files) { - if (filename.startsWith(f)) { - include = true; - break; - } - } - } else { - include = true; - } - - String entity_gs = gsFile.toString(); - gs_cells = TAnnotationKeyFileReader.readCellAnnotation(entity_gs); - processed.add(filename); - } else { - continue; - } - if (gs_cells == null) { - System.err.println(filename); - continue; - } - if (!include) { - continue; - } - - count++; - System.out.println(count+"_"+filename); - - boolean found = false; - String gsName_revised = gsFile.getName(); - //int start= gsName.indexOf(".entity.keys"); //for musicbrainz - if (!limaye) { - int start = gsName_revised.indexOf(".keys"); //for imdb - gsName_revised = start == -1 ? gsName_revised : gsName_revised.substring(0, start).trim(); - gsName_revised = gsName_revised + ".html.cell.keys"; - } else{ - int start = gsName_revised.indexOf(".cell.keys"); //for imdb - gsName_revised = start == -1 ? gsName_revised : gsName_revised.substring(0, start).trim(); - gsName_revised = gsName_revised + ".html.cell.keys"; - } - - for (File cpFile : new File(in_computed_folder).listFiles()) { - if (gsName_revised.equals(cpFile.getName())) { - found = true; - - String cpFile_name = cpFile.toString(); - StringBuilder line = new StringBuilder("\"" + cpFile.getPath() + "\","); - - Map>> cp_cells = - TAnnotationKeyFileReader.readCellAnnotation(cpFile_name); - - @SuppressWarnings("deprecation") - double[] cell_data_mode_0 = Evaluator_ClassOnly.compute_prf_relation_or_entity(gs_cells, cp_cells, 0); - line.append(appendResult(cell_data_mode_0)); - - @SuppressWarnings("deprecation") - double[] cell_data_mode_1 = Evaluator_ClassOnly.compute_prf_relation_or_entity(gs_cells, cp_cells, 1); - line.append(appendResult(cell_data_mode_1)); - - p.println(line.toString()); - break; - } - } - if (!found) { - out_missed_writer.println(gsFile); - } - } - out_missed_writer.close(); - p.close(); - System.out.println(count); - } - - - private String appendResult(double[] values) { - StringBuilder sb = new StringBuilder(); - sb.append(values[0]).append(",") - .append(values[1]).append(",") - .append(values[2]).append(","); - double p = values[0] / (values[0] + values[2]); - p = values[0] == 0 ? 0.0 : p; - - double r = values[0] / (values[1]); - r = values[0] == 0 ? 0 : r; - double f = 2 * p * r / (p + r); - f = r == 0.0 || p == 0.0 ? 0.0 : f; - - sb.append(p).append(",") - .append(r).append(",") - .append(f).append(","); - return sb.toString(); - - } - -} +package uk.ac.shef.dcs.sti.todo.evaluation; + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.*; + +import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; + +/** + + */ +public class Evaluator_EntityOnly { + protected static boolean PREDICTION_ONE_CORRECT_COUNTS_ALL = false; //if prediction has multiple labels while gs has 1, if prediction covers gs, should it be 1 correct (true) or not (false) + protected static List filter_files = new ArrayList(); + + + public static void main(String[] args) throws IOException { + /*String only_files_from = "E:\\Data\\table_annotation\\limaye_sample\\112_tables\\raw\\112_tables"; + if (only_files_from.length() > 0) { + for (File f : new File(only_files_from).listFiles()) { + filter_files.add(f.getName()); + } + }*/ + + Evaluator_EntityOnly evaluator = new Evaluator_EntityOnly(); + /************************************************ + FORY limaye200 + *************************************************/ + evaluator.evaluate( + /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\entity", + "tmp_result/limaye_entity_tm_ospd.csv", + "tmp_result/limaye_entity_tm_ospd_missed.csv", + true*//* + + *//*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd_nsc", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\entity", + "tmp_result/limaye_entity_tm_ospd_nsc.csv", + "tmp_result/limaye_entity_tm_ospd_nsc_missed.csv", + true*//* + + *//*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_lev(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\entity", + "tmp_result/limaye_entity_bs_sl_lev.csv", + "tmp_result/limaye_entity_bs_sl_lev_missed.csv", + true*//* + + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_dice(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\entity", + "tmp_result/limaye_entity_bs_sl_dice.csv", + "tmp_result/limaye_entity_bs_sl_dice_missed.csv", + true + + */ + /* "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_nm+first(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\entity", + "tmp_result/limaye_entity_bs_nm.csv", + "tmp_result/limaye_entity_bs_nm_missed.csv", + true*/ + + "E:\\Data\\table_annotation\\freebase_crawl\\ti_limaye_smp-tableminer\\limaye_smp_computed", + "E:\\Data\\table_annotation\\limayeall\\all_tables_groundtruth_freebase(regen)", + "tmp_result/limaye_entity_smp-tableminer.csv", + "tmp_result/limaye_entity_smp-tableminer_missed.csv", + true + + ); + System.exit(0); + + /************************************************ + FORY imdb or musicbrainz + *************************************************/ + evaluator.evaluate( + /* "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_base_nm", + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs\\imdb_gs(entity)_reformatted", + "tmp_result/imdb_entity_base_nm.csv", + "tmp_result/imdb_entity_base_nm_missed.csv", + false*/ + + /*"E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_base_sl_lev", + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs\\imdb_gs(entity)_reformatted", + "tmp_result/imdb_entity_base_lev.csv", + "tmp_result/imdb_entity_base_lev_missed.csv", + false*/ + + /*"E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_tm_ospd", + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs\\imdb_gs(entity)_reformatted", + "tmp_result/imdb_entity_tm_ospd.csv", + "tmp_result/imdb_entity_tm_ospd_missed.csv", + false*/ + + /*"E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_tm_ospd_nsc", + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs\\imdb_gs(entity)_reformatted", + "tmp_result/imdb_entity_tm_ospd_nsc.csv", + "tmp_result/imdb_entity_tm_ospd_nsc_missed.csv", + false*/ + + /*"E:\\Data\\table_annotation\\freebase_crawl\\film_film\\output\\imdb_base_sl_dice", + "E:\\Data\\table_annotation\\freebase_crawl\\film_film\\gs\\imdb_gs(entity)_reformatted", + "tmp_result/imdb_entity_base_dice.csv", + "tmp_result/imdb_entity_base_dice_missed.csv", + false*/ + + /* + */ + + + /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_nm", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs\\musicbrainz_gs(entity)_reformatted", + "tmp_result/mb_entity_base_nm.csv", + "tmp_result/mb_entity_base_nm_missed.csv", + false*/ + + /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_dice", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs\\musicbrainz_gs(entity)_reformatted", + "tmp_result/mb_entity_base_dice.csv", + "tmp_result/mb_entity_base_dice_missed.csv", + false*/ + + /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_lev", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs\\musicbrainz_gs(entity)_reformatted", + "tmp_result/mb_entity_base_lev.csv", + "tmp_result/mb_entity_base_lev_missed.csv", + false*/ + + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_tm_ospd_nsc", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs\\musicbrainz_gs(entity)_reformatted", + "tmp_result/mb_entity_tm_ospd-nsc.csv", + "tmp_result/mb_entity_tm_ospd_missed-nsc.csv", + false + + + ); + System.exit(0); + + /* Evaluator_EntityOnly evaluator = new Evaluator_EntityOnly(); + evaluator.evaluate( + "E:\\Data\\table annotation\\freebase_crawl\\film_film\\imdb_computed_(no_ref_ent)", + "E:\\Data\\table annotation\\freebase_crawl\\film_film\\imdb_gs_reformatted", + "tm_eval.csv", + "missed.csv" + ); + System.exit(0); + evaluator.evaluate( + "E:\\Data\\table annotation\\freebase_crawl\\music_record_label\\musicbrainz_computed", + "E:\\Data\\table annotation\\freebase_crawl\\music_record_label\\musicbrainz_gs_reformatted", + "tm_eval.csv", + "missed.csv" + );*/ + /*Evaluator_EntityOnly evaluator = new Evaluator_EntityOnly(); + evaluator.evaluate( + "E:\\Data\\table annotation\\freebase_crawl\\film_film\\imdb_computed_base", + "E:\\Data\\table annotation\\freebase_crawl\\film_film\\imdb_gs_reformatted", + "eval.csv", + "missed.csv" + );*/ + /*Evaluator_Generic evaluator = new Evaluator_Generic(); + evaluator.evaluate( + "E:\\Data\\table annotation\\corpus_analysis\\100_tables\\100_tables_annotated(baseline)", + "E:\\Data\\table annotation\\corpus_analysis\\100_tables\\100_tables_gs", + "eval.csv", + "missed.csv" + );*/ + + } + + public void evaluate(String in_computed_folder, + String in_gs_folder, + String out_result_file, + String out_missed_file, + boolean limaye) throws IOException { + PrintWriter p = new PrintWriter(out_result_file); + p.println("File,ENT(0)_cp_y,gs_y,cp_n,p,r,f," + + "ENT(1)_cp_y,gs_y,cp_n,p,r,f"); + + + PrintWriter out_missed_writer = new PrintWriter(out_missed_file); + Set processed = new HashSet(); + int count = 0; + for (File gsFile : new File(in_gs_folder).listFiles()) { + Map>> gs_cells = null; + String filename = gsFile.getName(); + + boolean include = false; + if (filename.endsWith(".keys")) { + if (filter_files.size() > 0) { + for (String f : filter_files) { + if (filename.startsWith(f)) { + include = true; + break; + } + } + } else { + include = true; + } + + String entity_gs = gsFile.toString(); + gs_cells = TAnnotationKeyFileReader.readCellAnnotation(entity_gs); + processed.add(filename); + } else { + continue; + } + if (gs_cells == null) { + System.err.println(filename); + continue; + } + if (!include) { + continue; + } + + count++; + System.out.println(count+"_"+filename); + + boolean found = false; + String gsName_revised = gsFile.getName(); + //int start= gsName.indexOf(".entity.keys"); //for musicbrainz + if (!limaye) { + int start = gsName_revised.indexOf(".keys"); //for imdb + gsName_revised = start == -1 ? gsName_revised : gsName_revised.substring(0, start).trim(); + gsName_revised = gsName_revised + ".html.cell.keys"; + } else{ + int start = gsName_revised.indexOf(".cell.keys"); //for imdb + gsName_revised = start == -1 ? gsName_revised : gsName_revised.substring(0, start).trim(); + gsName_revised = gsName_revised + ".html.cell.keys"; + } + + for (File cpFile : new File(in_computed_folder).listFiles()) { + if (gsName_revised.equals(cpFile.getName())) { + found = true; + + String cpFile_name = cpFile.toString(); + StringBuilder line = new StringBuilder("\"" + cpFile.getPath() + "\","); + + Map>> cp_cells = + TAnnotationKeyFileReader.readCellAnnotation(cpFile_name); + + @SuppressWarnings("deprecation") + double[] cell_data_mode_0 = Evaluator_ClassOnly.compute_prf_relation_or_entity(gs_cells, cp_cells, 0); + line.append(appendResult(cell_data_mode_0)); + + @SuppressWarnings("deprecation") + double[] cell_data_mode_1 = Evaluator_ClassOnly.compute_prf_relation_or_entity(gs_cells, cp_cells, 1); + line.append(appendResult(cell_data_mode_1)); + + p.println(line.toString()); + break; + } + } + if (!found) { + out_missed_writer.println(gsFile); + } + } + out_missed_writer.close(); + p.close(); + System.out.println(count); + } + + + private String appendResult(double[] values) { + StringBuilder sb = new StringBuilder(); + sb.append(values[0]).append(",") + .append(values[1]).append(",") + .append(values[2]).append(","); + double p = values[0] / (values[0] + values[2]); + p = values[0] == 0 ? 0.0 : p; + + double r = values[0] / (values[1]); + r = values[0] == 0 ? 0 : r; + double f = 2 * p * r / (p + r); + f = r == 0.0 || p == 0.0 ? 0.0 : f; + + sb.append(p).append(",") + .append(r).append(",") + .append(f).append(","); + return sb.toString(); + + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Generic_Classification_ignoreUpdateIterations.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Generic_Classification_ignoreUpdateIterations.java index 49d88603..1facd31e 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Generic_Classification_ignoreUpdateIterations.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Generic_Classification_ignoreUpdateIterations.java @@ -1,136 +1,136 @@ -package uk.ac.shef.dcs.sti.todo.evaluation; - -import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; -import uk.ac.shef.dcs.sti.util.FileUtils; - -import java.io.File; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.*; - -/** - */ -public class Evaluator_Generic_Classification_ignoreUpdateIterations { - public static void main(String[] args) throws IOException { - Evaluator_Generic_Classification_ignoreUpdateIterations evaluator = new Evaluator_Generic_Classification_ignoreUpdateIterations(); - evaluator.evaluate( - "check list file", - "E:\\Data\\table annotation\\test_evaluator\\cp", - "E:\\Data\\table annotation\\test_evaluator\\gs", - "eval.csv", - "missed.csv", - true - - ); - } - - private Map> readCheckListFile(String file) throws IOException { - List lines = FileUtils.readList(file, false); - Map> rs = new HashMap>(); - for (String l : lines) { - String[] parts = l.split("\\|"); - String thefile = parts[0].trim(); - if (thefile.startsWith("\"")) - thefile = thefile.substring(1).trim(); - if (thefile.endsWith("\"")) - thefile = thefile.substring(0, thefile.length() - 1).trim(); - - String[] cols = parts[1].trim().split(","); - List columns = new ArrayList(); - for (String c : cols) { - c = c.trim(); - if (c.length() < 1) continue; - columns.add(Integer.valueOf(c)); - } - rs.put(thefile, columns); - } - return rs; - } - - public void evaluate(String checklist_file, - String in_header_computed_folder, - String in_header_gs_folder, - String out_result_file, - String out_missed_file, boolean gs_NE_only) throws IOException { - PrintWriter p = new PrintWriter(out_result_file); - p.println("File,HEADER(0)_cp_y, gs_y, cp_n, p,r,f," + - "HEADER(1)_cp_y, gs_y, cp_n, p,r,f"); - - Map> checklist = readCheckListFile(checklist_file); - - PrintWriter out_missed_writer = new PrintWriter(out_missed_file); - Set processed = new HashSet(); - for (File gsFile : new File(in_header_gs_folder).listFiles()) { - Map>> gs_headers = null; - - String filename = gsFile.getName(); - if (filename.endsWith(".htm") || filename.endsWith(".html")) { - if (!filename.contains(".attributes") && !filename.contains(".keys") && !processed.contains(filename)) { - String header_gs = gsFile.toString() + ".header.keys"; - - gs_headers = TAnnotationKeyFileReader.readHeaderAnnotation(header_gs, true, gs_NE_only); - - processed.add(filename); - } else - continue; - } else { - continue; - } - if (gs_headers == null) { - System.err.println(filename); - continue; - } - - boolean found = false; - - for (File cpFile : new File(in_header_computed_folder).listFiles()) { - if (gsFile.getName().equals(cpFile.getName())) { - found = true; - - String cpFile_name = cpFile.toString(); - StringBuilder line = new StringBuilder("\"" + cpFile.getPath() + "\","); - - Map>> cp_headers = - TAnnotationKeyFileReader.readHeaderAnnotation(cpFile_name + ".header.keys", false, gs_NE_only); - - - double[] header_data_mode_0 = - Evaluator_ClassOnly.compute_prf_header(gs_headers, cp_headers, 0); - line.append(appendResult(header_data_mode_0)); - double[] header_data_mode_1 = - Evaluator_ClassOnly.compute_prf_header(gs_headers, cp_headers, 1); - line.append(appendResult(header_data_mode_1)); - - p.println(line.toString()); - break; - } - } - if (!found) { - out_missed_writer.println(gsFile); - } - } - out_missed_writer.close(); - p.close(); - } - - //values - 0-cp correct; 1-gs correct; 2-cp wrong - private String appendResult(double[] values) { - StringBuilder sb = new StringBuilder(); - sb.append(values[0]).append(",") - .append(values[1]).append(",") - .append(values[2]).append(","); - double p = values[0] / (values[0] + values[2]); - p = values[0] == 0 ? 0.0 : p; - - double r = values[0] / (values[1]); - double f = 2 * p * r / (p + r); - f = r == 0.0 || p == 0.0 ? 0.0 : f; - - sb.append(p).append(",") - .append(r).append(",") - .append(f).append(","); - return sb.toString(); - - } - -} +package uk.ac.shef.dcs.sti.todo.evaluation; + +import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; +import uk.ac.shef.dcs.sti.util.FileUtils; + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.*; + +/** + */ +public class Evaluator_Generic_Classification_ignoreUpdateIterations { + public static void main(String[] args) throws IOException { + Evaluator_Generic_Classification_ignoreUpdateIterations evaluator = new Evaluator_Generic_Classification_ignoreUpdateIterations(); + evaluator.evaluate( + "check list file", + "E:\\Data\\table annotation\\test_evaluator\\cp", + "E:\\Data\\table annotation\\test_evaluator\\gs", + "eval.csv", + "missed.csv", + true + + ); + } + + private Map> readCheckListFile(String file) throws IOException { + List lines = FileUtils.readList(file, false); + Map> rs = new HashMap>(); + for (String l : lines) { + String[] parts = l.split("\\|"); + String thefile = parts[0].trim(); + if (thefile.startsWith("\"")) + thefile = thefile.substring(1).trim(); + if (thefile.endsWith("\"")) + thefile = thefile.substring(0, thefile.length() - 1).trim(); + + String[] cols = parts[1].trim().split(","); + List columns = new ArrayList(); + for (String c : cols) { + c = c.trim(); + if (c.length() < 1) continue; + columns.add(Integer.valueOf(c)); + } + rs.put(thefile, columns); + } + return rs; + } + + public void evaluate(String checklist_file, + String in_header_computed_folder, + String in_header_gs_folder, + String out_result_file, + String out_missed_file, boolean gs_NE_only) throws IOException { + PrintWriter p = new PrintWriter(out_result_file); + p.println("File,HEADER(0)_cp_y, gs_y, cp_n, p,r,f," + + "HEADER(1)_cp_y, gs_y, cp_n, p,r,f"); + + Map> checklist = readCheckListFile(checklist_file); + + PrintWriter out_missed_writer = new PrintWriter(out_missed_file); + Set processed = new HashSet(); + for (File gsFile : new File(in_header_gs_folder).listFiles()) { + Map>> gs_headers = null; + + String filename = gsFile.getName(); + if (filename.endsWith(".htm") || filename.endsWith(".html")) { + if (!filename.contains(".attributes") && !filename.contains(".keys") && !processed.contains(filename)) { + String header_gs = gsFile.toString() + ".header.keys"; + + gs_headers = TAnnotationKeyFileReader.readHeaderAnnotation(header_gs, true, gs_NE_only); + + processed.add(filename); + } else + continue; + } else { + continue; + } + if (gs_headers == null) { + System.err.println(filename); + continue; + } + + boolean found = false; + + for (File cpFile : new File(in_header_computed_folder).listFiles()) { + if (gsFile.getName().equals(cpFile.getName())) { + found = true; + + String cpFile_name = cpFile.toString(); + StringBuilder line = new StringBuilder("\"" + cpFile.getPath() + "\","); + + Map>> cp_headers = + TAnnotationKeyFileReader.readHeaderAnnotation(cpFile_name + ".header.keys", false, gs_NE_only); + + + double[] header_data_mode_0 = + Evaluator_ClassOnly.compute_prf_header(gs_headers, cp_headers, 0); + line.append(appendResult(header_data_mode_0)); + double[] header_data_mode_1 = + Evaluator_ClassOnly.compute_prf_header(gs_headers, cp_headers, 1); + line.append(appendResult(header_data_mode_1)); + + p.println(line.toString()); + break; + } + } + if (!found) { + out_missed_writer.println(gsFile); + } + } + out_missed_writer.close(); + p.close(); + } + + //values - 0-cp correct; 1-gs correct; 2-cp wrong + private String appendResult(double[] values) { + StringBuilder sb = new StringBuilder(); + sb.append(values[0]).append(",") + .append(values[1]).append(",") + .append(values[2]).append(","); + double p = values[0] / (values[0] + values[2]); + p = values[0] == 0 ? 0.0 : p; + + double r = values[0] / (values[1]); + double f = 2 * p * r / (p + r); + f = r == 0.0 || p == 0.0 ? 0.0 : f; + + sb.append(p).append(",") + .append(r).append(",") + .append(f).append(","); + return sb.toString(); + + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ISWC_Helper_ClassOnly.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ISWC_Helper_ClassOnly.java index cbd6e527..5ddbfd2f 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ISWC_Helper_ClassOnly.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_ISWC_Helper_ClassOnly.java @@ -1,161 +1,161 @@ -package uk.ac.shef.dcs.sti.todo.evaluation; - -import uk.ac.shef.dcs.kbsearch.model.Attribute; -import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; -import uk.ac.shef.dcs.kbsearch.freebase.FreebaseQueryProxy; - -import java.io.File; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.*; - -/** - * - */ -public class Evaluator_ISWC_Helper_ClassOnly { - - - public static void main(String[] args) throws IOException { - - Evaluator_ISWC_Helper_ClassOnly evaluator = new Evaluator_ISWC_Helper_ClassOnly(); - /*evaluator.evaluate( - "E:\\Data\\lodie_corpus_consolidated\\iswc_output_selected\\goodreads-test-3000", - "E:\\Data\\lodie_corpus_consolidated\\iswc_output_selected/goodreads.header.keys", - "tmp_result/mb_header_tm_ospd_nsc-all.csv", - "tmp_result/mb_header_tm_ospd_missed_nsc-all.csv", false - - ); -*/ - evaluator.evaluate( - "E:\\Data\\lodie_corpus_consolidated\\LODIE_data\\ISWCdataset\\COMPUTED\\priority_2_music_reverbnation\\reverbnation-test-1216", - "E:\\Data\\lodie_corpus_consolidated\\iswc_output_selected/goodreads.header.keys", - "tmp_result/mb_header_tm_ospd_nsc-all.csv", - "tmp_result/mb_header_tm_ospd_missed_nsc-all.csv", false - - ); - - } - - public void evaluate(String in_computed_folder, - String in_gs_file, - String out_result_file, - String out_missed_file, boolean gs_NE_only) throws IOException { - //todo:this will not work! - FreebaseQueryProxy fb = null;//new FreebaseQueryProxy("D:\\Work\\lodiecrawler\\src\\main\\java/freebase.properties"); - PrintWriter p = new PrintWriter(out_result_file); - p.println("File,HEADER(0)_cp_y, gs_y, cp_n, p,r,f," + - "HEADER(1)_cp_y, gs_y, cp_n, p,r,f"); - - - PrintWriter out_missed_writer = new PrintWriter(out_missed_file); - Set processed = new HashSet(); - Map>> gs_headers = TAnnotationKeyFileReader.readHeaderAnnotation(in_gs_file, true, gs_NE_only); - - Map> unique_urls = new HashMap>(); - - int count = 0; - for (File cpFile : new File(in_computed_folder).listFiles()) { - - String filename = cpFile.getName(); - if (processed.contains(filename)) - continue; - - if (filename.contains(".header.keys")) { - int dothtml = filename.lastIndexOf(".html"); - if (dothtml == -1) - dothtml = filename.lastIndexOf(".htm"); - if (dothtml == -1) { - System.err.println(filename); - continue; - } - int end = dothtml + 5; - - count++; - filename = filename.substring(0, end).trim(); - System.out.println(count + "_" + filename); - - processed.add(filename); - String header_cp = cpFile.getParent() + "/" + filename + ".header.keys"; - processed.add(header_cp); - - StringBuilder line = new StringBuilder("\"" + cpFile.getPath() + "\","); - - Map>> cp_headers = - TAnnotationKeyFileReader.readHeaderAnnotation(header_cp, false, gs_NE_only); - for (Integer i : cp_headers.keySet()) { - List> ll = cp_headers.get(i); - Set unique = unique_urls.get(i); - unique = unique == null ? new HashSet() : unique; - for (List l : ll) - unique.addAll(l); - /* if(unique.contains("/m/0174nj")) - System.out.println();*/ - unique_urls.put(i, unique); - } - - - double[] header_data_mode_0 = Evaluator_ClassOnly.compute_prf_header(gs_headers, cp_headers, 0); - line.append(appendResult(header_data_mode_0)); - - double[] header_data_mode_1 = Evaluator_ClassOnly.compute_prf_header(gs_headers, cp_headers, 1); - line.append(appendResult(header_data_mode_1)); - - p.println(line.toString()); - //break; - - } else { - continue; - } - - - } - out_missed_writer.close(); - p.close(); - - for (Integer i : unique_urls.keySet()) { - - List unique_sorted = new ArrayList(unique_urls.get(i)); - Collections.sort(unique_sorted); - System.out.println(">>>" + i); - for (String s : unique_sorted) { - if (s.startsWith("/m/")) { - try { - List facts = fb.topicapi_getAttributesOfTopicID(s, "/type/object/name"); - ; - if (facts.size() > 0) - s = s + ":" + facts.get(0).getValue(); - } catch (Exception e) { - - } - } - System.out.println(s); - } - } - } - - - private String appendResult(double[] values) { - StringBuilder sb = new StringBuilder(); - sb.append(values[0]).append(",") - .append(values[1]).append(",") - .append(values[2]).append(","); - double p = values[0] / (values[0] + values[2]); - p = values[0] == 0 ? 0.0 : p; - - double r = values[0] / (values[1]); - r = values[0] == 0 ? 0 : r; - double f = 2 * p * r / (p + r); - f = r == 0.0 || p == 0.0 ? 0.0 : f; - - sb.append(p).append(",") - .append(r).append(",") - .append(f).append(","); - return sb.toString(); - - } - - - //return double[] 0-correct by cp; 1-correct by gs; 2-wrong by cp (i.e., missed) - - -} +package uk.ac.shef.dcs.sti.todo.evaluation; + +import uk.ac.shef.dcs.kbsearch.model.Attribute; +import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; +import uk.ac.shef.dcs.kbsearch.freebase.FreebaseQueryProxy; + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.*; + +/** + * + */ +public class Evaluator_ISWC_Helper_ClassOnly { + + + public static void main(String[] args) throws IOException { + + Evaluator_ISWC_Helper_ClassOnly evaluator = new Evaluator_ISWC_Helper_ClassOnly(); + /*evaluator.evaluate( + "E:\\Data\\lodie_corpus_consolidated\\iswc_output_selected\\goodreads-test-3000", + "E:\\Data\\lodie_corpus_consolidated\\iswc_output_selected/goodreads.header.keys", + "tmp_result/mb_header_tm_ospd_nsc-all.csv", + "tmp_result/mb_header_tm_ospd_missed_nsc-all.csv", false + + ); +*/ + evaluator.evaluate( + "E:\\Data\\lodie_corpus_consolidated\\LODIE_data\\ISWCdataset\\COMPUTED\\priority_2_music_reverbnation\\reverbnation-test-1216", + "E:\\Data\\lodie_corpus_consolidated\\iswc_output_selected/goodreads.header.keys", + "tmp_result/mb_header_tm_ospd_nsc-all.csv", + "tmp_result/mb_header_tm_ospd_missed_nsc-all.csv", false + + ); + + } + + public void evaluate(String in_computed_folder, + String in_gs_file, + String out_result_file, + String out_missed_file, boolean gs_NE_only) throws IOException { + //todo:this will not work! + FreebaseQueryProxy fb = null;//new FreebaseQueryProxy("D:\\Work\\lodiecrawler\\src\\main\\java/freebase.properties"); + PrintWriter p = new PrintWriter(out_result_file); + p.println("File,HEADER(0)_cp_y, gs_y, cp_n, p,r,f," + + "HEADER(1)_cp_y, gs_y, cp_n, p,r,f"); + + + PrintWriter out_missed_writer = new PrintWriter(out_missed_file); + Set processed = new HashSet(); + Map>> gs_headers = TAnnotationKeyFileReader.readHeaderAnnotation(in_gs_file, true, gs_NE_only); + + Map> unique_urls = new HashMap>(); + + int count = 0; + for (File cpFile : new File(in_computed_folder).listFiles()) { + + String filename = cpFile.getName(); + if (processed.contains(filename)) + continue; + + if (filename.contains(".header.keys")) { + int dothtml = filename.lastIndexOf(".html"); + if (dothtml == -1) + dothtml = filename.lastIndexOf(".htm"); + if (dothtml == -1) { + System.err.println(filename); + continue; + } + int end = dothtml + 5; + + count++; + filename = filename.substring(0, end).trim(); + System.out.println(count + "_" + filename); + + processed.add(filename); + String header_cp = cpFile.getParent() + "/" + filename + ".header.keys"; + processed.add(header_cp); + + StringBuilder line = new StringBuilder("\"" + cpFile.getPath() + "\","); + + Map>> cp_headers = + TAnnotationKeyFileReader.readHeaderAnnotation(header_cp, false, gs_NE_only); + for (Integer i : cp_headers.keySet()) { + List> ll = cp_headers.get(i); + Set unique = unique_urls.get(i); + unique = unique == null ? new HashSet() : unique; + for (List l : ll) + unique.addAll(l); + /* if(unique.contains("/m/0174nj")) + System.out.println();*/ + unique_urls.put(i, unique); + } + + + double[] header_data_mode_0 = Evaluator_ClassOnly.compute_prf_header(gs_headers, cp_headers, 0); + line.append(appendResult(header_data_mode_0)); + + double[] header_data_mode_1 = Evaluator_ClassOnly.compute_prf_header(gs_headers, cp_headers, 1); + line.append(appendResult(header_data_mode_1)); + + p.println(line.toString()); + //break; + + } else { + continue; + } + + + } + out_missed_writer.close(); + p.close(); + + for (Integer i : unique_urls.keySet()) { + + List unique_sorted = new ArrayList(unique_urls.get(i)); + Collections.sort(unique_sorted); + System.out.println(">>>" + i); + for (String s : unique_sorted) { + if (s.startsWith("/m/")) { + try { + List facts = fb.topicapi_getAttributesOfTopicID(s, "/type/object/name"); + ; + if (facts.size() > 0) + s = s + ":" + facts.get(0).getValue(); + } catch (Exception e) { + + } + } + System.out.println(s); + } + } + } + + + private String appendResult(double[] values) { + StringBuilder sb = new StringBuilder(); + sb.append(values[0]).append(",") + .append(values[1]).append(",") + .append(values[2]).append(","); + double p = values[0] / (values[0] + values[2]); + p = values[0] == 0 ? 0.0 : p; + + double r = values[0] / (values[1]); + r = values[0] == 0 ? 0 : r; + double f = 2 * p * r / (p + r); + f = r == 0.0 || p == 0.0 ? 0.0 : f; + + sb.append(p).append(",") + .append(r).append(",") + .append(f).append(","); + return sb.toString(); + + } + + + //return double[] 0-correct by cp; 1-correct by gs; 2-wrong by cp (i.e., missed) + + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Limaye_Entity_Only.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Limaye_Entity_Only.java index 65151be2..ffbb8ea1 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Limaye_Entity_Only.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_Limaye_Entity_Only.java @@ -1,103 +1,103 @@ -package uk.ac.shef.dcs.sti.todo.evaluation; - -import java.io.IOException; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 01/04/14 - * Time: 15:22 - * To change this template use File | Settings | File Templates. - */ -public class Evaluator_Limaye_Entity_Only { - public static void main(String[] args) throws IOException { - Evaluator_EntityOnly ent_evaluator = new Evaluator_EntityOnly(); - Evaluator_ClassOnly cls_evaluator = new Evaluator_ClassOnly(); - Evaluator_RelationOnly rel_evaluator = new Evaluator_RelationOnly(); - /************************************************ - FORY limaye200 - *************************************************/ - String method = "smp"; - - - if (method.equals("nm")) { - ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye_sample\\all\\baseline_nm+first(RI)", - "E:\\Data\\table_annotation\\limaye\\all_tables_groundtruth_freebase(regen)", - //"E:\\Data\\table_annotation\\limaye\\all_tables_groundtruth_freebase(limaye_original)", - "tmp_result/limaye_entity_bs_nm.csv", - "tmp_result/limaye_entity_bs_nm_missed.csv", - true - ); - } else if (method.equals("cos")) { - ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye_sample\\all\\old_baseline_sl_cos(RI)", - "E:\\Data\\table_annotation\\limaye\\all_tables_groundtruth_freebase(limaye_original)", - "tmp_result/limaye_entity_bs_cos.csv", - "tmp_result/limaye_entity_bs_cos_missed.csv", - true - ); - - } else if (method.equals("lev")) { - ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye_sample\\all\\old_baseline_sl_lev(RI)", - "E:\\Data\\table_annotation\\limaye\\all_tables_groundtruth_freebase(limaye_original)", - "tmp_result/limaye_entity_bs_lev.csv", - "tmp_result/limaye_entity_bs_lev_missed.csv", - true - ); - } else if (method.equals("dice")) { - ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye_sample\\all\\old_baseline_sl_dice(RI)", - "E:\\Data\\table_annotation\\limaye\\all_tables_groundtruth_freebase(limaye_original)", - "tmp_result/limaye_entity_bs_dice.csv", - "tmp_result/limaye_entity_bs_dice_missed.csv", - true - ); - - } else if (method.equals("tm_ospd")) { - ent_evaluator.evaluate( - "E:\\Data\\table_annotation\\limaye_sample\\all\\tm_dc_ri_ospd", - "E:\\Data\\table_annotation\\limaye\\all_tables_groundtruth_freebase(regen)", - "tmp_result/limaye_entity_tm_ospd.csv", - "tmp_result/limaye_entity_tm_ospd_missed.csv", - true - ); - - } else if (method.equals("tm_ospd_nsc")) { - ent_evaluator.evaluate( - //"E:\\Data\\table_annotation\\limaye_sample\\all\\old_tm_dc_ri_ospd_nsc(sqrtx2,ctxu1,normI)", - //"E:\\Data\\table_annotation\\limaye\\all_tables_groundtruth_freebase(limaye_original)", - - "E:\\Data\\table_annotation\\tableminer_df\\limayeall\\baseline\\limaye_df_random_ospd", - "E:\\Data\\table_annotation\\limayeall\\all_tables_groundtruth_freebase(regen)", - "tmp_result/limaye_entity_tm_ospd_nsc.csv", - "tmp_result/limaye_entity_tm_ospd_nsc_missed.csv", - true - ); - - } else if (method.equals("smp")) { - ent_evaluator.evaluate( - //"E:\\Data\\table_annotation\\limaye_sample\\all\\old_tm_dc_ri_ospd_nsc(sqrtx2,ctxu1,normI)", - //"E:\\Data\\table_annotation\\limaye\\all_tables_groundtruth_freebase(limaye_original)", - - "E:\\Data\\table_annotation\\freebase_crawl\\ti_limaye_smp-tableminer+grn\\limaye_smp_computed", - "E:\\Data\\table_annotation\\limayeall\\all_tables_groundtruth_freebase(regen)", - "tmp_result/limaye_entity_smp-tm+grn.csv", - "tmp_result/limaye_entity_smp-tm+grn_missed.csv", - true - ); - System.exit(0); - } else if (method.equals("ji")) { - ent_evaluator.evaluate( - //"E:\\Data\\table_annotation\\limaye_sample\\all\\old_tm_dc_ri_ospd_nsc(sqrtx2,ctxu1,normI)", - //"E:\\Data\\table_annotation\\limaye\\all_tables_groundtruth_freebase(limaye_original)", - - "E:\\Data\\table_annotation\\freebase_crawl\\ti_limaye_ji\\limaye_smp_computed", - "E:\\Data\\table_annotation\\limayeall\\all_tables_groundtruth_freebase(regen)", - "tmp_result/limaye_entity_ji.csv", - "tmp_result/limaye_entity_ji_missed.csv", - true - );} - } -} +package uk.ac.shef.dcs.sti.todo.evaluation; + +import java.io.IOException; + +/** + * Created with IntelliJ IDEA. + * User: zqz + * Date: 01/04/14 + * Time: 15:22 + * To change this template use File | Settings | File Templates. + */ +public class Evaluator_Limaye_Entity_Only { + public static void main(String[] args) throws IOException { + Evaluator_EntityOnly ent_evaluator = new Evaluator_EntityOnly(); + Evaluator_ClassOnly cls_evaluator = new Evaluator_ClassOnly(); + Evaluator_RelationOnly rel_evaluator = new Evaluator_RelationOnly(); + /************************************************ + FORY limaye200 + *************************************************/ + String method = "smp"; + + + if (method.equals("nm")) { + ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye_sample\\all\\baseline_nm+first(RI)", + "E:\\Data\\table_annotation\\limaye\\all_tables_groundtruth_freebase(regen)", + //"E:\\Data\\table_annotation\\limaye\\all_tables_groundtruth_freebase(limaye_original)", + "tmp_result/limaye_entity_bs_nm.csv", + "tmp_result/limaye_entity_bs_nm_missed.csv", + true + ); + } else if (method.equals("cos")) { + ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye_sample\\all\\old_baseline_sl_cos(RI)", + "E:\\Data\\table_annotation\\limaye\\all_tables_groundtruth_freebase(limaye_original)", + "tmp_result/limaye_entity_bs_cos.csv", + "tmp_result/limaye_entity_bs_cos_missed.csv", + true + ); + + } else if (method.equals("lev")) { + ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye_sample\\all\\old_baseline_sl_lev(RI)", + "E:\\Data\\table_annotation\\limaye\\all_tables_groundtruth_freebase(limaye_original)", + "tmp_result/limaye_entity_bs_lev.csv", + "tmp_result/limaye_entity_bs_lev_missed.csv", + true + ); + } else if (method.equals("dice")) { + ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye_sample\\all\\old_baseline_sl_dice(RI)", + "E:\\Data\\table_annotation\\limaye\\all_tables_groundtruth_freebase(limaye_original)", + "tmp_result/limaye_entity_bs_dice.csv", + "tmp_result/limaye_entity_bs_dice_missed.csv", + true + ); + + } else if (method.equals("tm_ospd")) { + ent_evaluator.evaluate( + "E:\\Data\\table_annotation\\limaye_sample\\all\\tm_dc_ri_ospd", + "E:\\Data\\table_annotation\\limaye\\all_tables_groundtruth_freebase(regen)", + "tmp_result/limaye_entity_tm_ospd.csv", + "tmp_result/limaye_entity_tm_ospd_missed.csv", + true + ); + + } else if (method.equals("tm_ospd_nsc")) { + ent_evaluator.evaluate( + //"E:\\Data\\table_annotation\\limaye_sample\\all\\old_tm_dc_ri_ospd_nsc(sqrtx2,ctxu1,normI)", + //"E:\\Data\\table_annotation\\limaye\\all_tables_groundtruth_freebase(limaye_original)", + + "E:\\Data\\table_annotation\\tableminer_df\\limayeall\\baseline\\limaye_df_random_ospd", + "E:\\Data\\table_annotation\\limayeall\\all_tables_groundtruth_freebase(regen)", + "tmp_result/limaye_entity_tm_ospd_nsc.csv", + "tmp_result/limaye_entity_tm_ospd_nsc_missed.csv", + true + ); + + } else if (method.equals("smp")) { + ent_evaluator.evaluate( + //"E:\\Data\\table_annotation\\limaye_sample\\all\\old_tm_dc_ri_ospd_nsc(sqrtx2,ctxu1,normI)", + //"E:\\Data\\table_annotation\\limaye\\all_tables_groundtruth_freebase(limaye_original)", + + "E:\\Data\\table_annotation\\freebase_crawl\\ti_limaye_smp-tableminer+grn\\limaye_smp_computed", + "E:\\Data\\table_annotation\\limayeall\\all_tables_groundtruth_freebase(regen)", + "tmp_result/limaye_entity_smp-tm+grn.csv", + "tmp_result/limaye_entity_smp-tm+grn_missed.csv", + true + ); + System.exit(0); + } else if (method.equals("ji")) { + ent_evaluator.evaluate( + //"E:\\Data\\table_annotation\\limaye_sample\\all\\old_tm_dc_ri_ospd_nsc(sqrtx2,ctxu1,normI)", + //"E:\\Data\\table_annotation\\limaye\\all_tables_groundtruth_freebase(limaye_original)", + + "E:\\Data\\table_annotation\\freebase_crawl\\ti_limaye_ji\\limaye_smp_computed", + "E:\\Data\\table_annotation\\limayeall\\all_tables_groundtruth_freebase(regen)", + "tmp_result/limaye_entity_ji.csv", + "tmp_result/limaye_entity_ji_missed.csv", + true + );} + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly.java index 80722917..fcb20251 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly.java @@ -1,310 +1,310 @@ -package uk.ac.shef.dcs.sti.todo.evaluation; - -import java.io.File; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.*; - -import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 26/02/14 - * Time: 14:14 - * To change this template use File | Settings | File Templates. - */ -public class Evaluator_RelationOnly { - - protected static boolean PREDICTION_ONE_CORRECT_COUNTS_ALL = false; //if prediction has multiple labels while gs has 1, if prediction covers gs, should it be 1 correct (true) or not (false) - - - public static void main(String[] args) throws IOException { - - /*Evaluator_Generic evaluator = new Evaluator_Generic(); - evaluator.evaluate( - "E:\\Data\\table annotation\\corpus_analysis\\100_tables\\100_tables_annotated(disamb=0)", - "E:\\Data\\table annotation\\corpus_analysis\\100_tables\\100_tables_gs", - "eval.csv", - "missed.csv" - );*/ - Evaluator_RelationOnly evaluator = new Evaluator_RelationOnly(); - evaluator.evaluate( - /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_cos(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_rel_bs_cos-all.csv", - "tmp_result/limaye_rel_bs_cos_missed-all.csv",true,false*/ - - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_cos(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_rel_bs_cos-ne.csv", - "tmp_result/limaye_rel_bs_cos_missed-ne.csv",true,true - - /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_nm+first(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_rel_bs_nm-all.csv", - "tmp_result/limaye_rel_bs_nm_missed-all.csv",true,false -*/ - /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_nm+first(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_rel_bs_nm-ne.csv", - "tmp_result/limaye_rel_bs_nm_missed-ne.csv",true,true*/ - - /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_dice(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_rel_bs_dice-all.csv", - "tmp_result/limaye_rel_bs_dice_missed-all.csv",true,false*/ - /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_dice(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_rel_bs_dice-ne.csv", - "tmp_result/limaye_rel_bs_dice_missed-ne.csv",true,true*/ - - /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_lev(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_rel_bs_lev-all.csv", - "tmp_result/limaye_rel_bs_lev_missed-all.csv",true,false*/ - - /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_lev(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_rel_bs_lev-ne.csv", - "tmp_result/limaye_rel_bs_lev_missed-ne.csv",true,true*/ - - /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_rel_tm_ospd-all.csv", - "tmp_result/limaye_rel_tm_ospd_missed-all.csv",true,false*/ - - /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_rel_tm_ospd-ne.csv", - "tmp_result/limaye_rel_tm_ospd_missed-ne.csv",true,true*/ - - /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd_nsc", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_rel_tm_ospd_nsc-all.csv", - "tmp_result/limaye_rel_tm_ospd_nsc_missed-all.csv",true,false*/ - - /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd_nsc", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tmp_result/limaye_rel_tm_ospd_nsc-ne.csv", - "tmp_result/limaye_rel_tm_ospd_nsc_missed-ne.csv",true,true*/ - ); - - } - - public void evaluate(String in_computed_folder, - String in_gs_folder, - String in_header_gs_folder, - String out_result_file, - String out_missed_file, boolean tolerant_mode,boolean ne_relation_only) throws IOException { - PrintWriter p = new PrintWriter(out_result_file); - p.println("File,REL(0)_cp_y, gs_y, cp_n, p,r,f," + - "REL(1)_cp_y, gs_y, cp_n, p,r,f"); - - - PrintWriter out_missed_writer = new PrintWriter(out_missed_file); - Set processed = new HashSet(); - for (File gsFile : new File(in_gs_folder).listFiles()) { - - Map>>gs_binaryRels = null; - Map>> gs_header=null; - - List main = new ArrayList(); - List tolerant = new ArrayList(); - - String filename = gsFile.getName(); - if(processed.contains(filename)) - continue; - - if (filename.endsWith(".keys")) { - int dothtml = filename.lastIndexOf(".html"); - if(dothtml==-1) - dothtml=filename.lastIndexOf(".htm"); - if(dothtml==-1){ - System.err.println(filename); - continue; - } - int end = dothtml+5; - - filename = filename.substring(0, end).trim(); - System.out.println(filename); - /* if(filename.contains("Wisden")) - System.out.println();*/ - //if (!filename.contains(".attributes") && !filename.contains(".keys") && !processed.contains(filename)) { - - String binary = gsFile.getParent()+"/"+filename + ".relation.keys"; - processed.add(binary); - String header = in_header_gs_folder+"/"+filename+".header.keys"; - gs_header= TAnnotationKeyFileReader.readHeaderAnnotation(header, true, true); - - gs_binaryRels = TAnnotationKeyFileReader.readColumnBinaryRelationAnnotation_GS(binary, main, tolerant); - - processed.add(filename); - - } else { - continue; - } - if (gs_binaryRels == null) { - System.err.println(filename); - continue; - } - - boolean found = false; - - for (File cpFile : new File(in_computed_folder).listFiles()) { - if (cpFile.getName().startsWith(filename)) { - found = true; - - String cpFile_name = cpFile.toString(); - if(processed.contains(cpFile_name)||!cpFile_name.endsWith("keys")) - continue; - - String entity_cp = cpFile.getParent()+"/"+filename + ".cell.keys"; - processed.add(entity_cp); - String header_cp = cpFile.getParent()+"/"+filename + ".header.keys"; - processed.add(header_cp); - String binary_cp = cpFile.getParent()+"/"+filename + ".relation.keys"; - processed.add(binary_cp); - - StringBuilder line = new StringBuilder("\"" + cpFile.getPath() + "\","); - - Map>> cp_binaryRels = - TAnnotationKeyFileReader.readColumnBinaryRelationAnnotation_CP(binary_cp); - - double[] relation_data_mode_0 = compute_prf_relation(gs_binaryRels, cp_binaryRels, main, gs_header,0,ne_relation_only); - line.append(appendResult(relation_data_mode_0)); - - double[] relation_data_mode_1 = compute_prf_relation(gs_binaryRels, cp_binaryRels, main,gs_header, 1,ne_relation_only); - line.append(appendResult(relation_data_mode_1)); - - p.println(line.toString()); - break; - } - } - if (!found) { - out_missed_writer.println(gsFile); - } - } - out_missed_writer.close(); - p.close(); - } - - //warning: only works for relations between subcol and other cols. if in predicated relation files there are m:n relations this will fail!!! - public static double[] compute_prf_relation(Map>> gs, - Map>> cp, - List main, - Map>> gs_header, - int mode, - boolean ne_relation_only) { - double total_correct_by_cp = 0.0, total_wrong_by_cp = 0.0, total_correct_by_gs = 0.0; - - for (Map.Entry>> e : gs.entrySet()) { - int[] col = e.getKey(); - - if(ne_relation_only){ - if(!gs_header.containsKey(col[0])||!gs_header.containsKey(col[1])) - continue; - } - - String key = col[0]+","+col[1]; - - boolean isMain=false; - if(main.contains(key)) { //only the main entry is incremented. for every tolerant gs answer, there must be a main answer - total_correct_by_gs++; - isMain=true; - } - - List> gs_annotations = e.getValue(); - List gs_vital = gs_annotations.size() > 0 ? gs_annotations.get(0) : new ArrayList(); - List> cp_annotations = new ArrayList>(); - - for (Map.Entry>> f : cp.entrySet()) { - int[] col_cp = f.getKey(); - if (col[0] == col_cp[0] && col[1] == col_cp[1]) { - cp_annotations = f.getValue(); - break; - } - } - List cp_first = cp_annotations.size() > 0 ? cp_annotations.get(0) : new ArrayList(); - if (cp_first.size() == 0) { - continue; - } - - if (mode == 0 &&isMain) { - List intersection = new ArrayList(cp_first); - intersection.retainAll(gs_vital); - - double correct_by_cp=0; - if (intersection.size() > 0) { - if (PREDICTION_ONE_CORRECT_COUNTS_ALL){ - correct_by_cp=1; - } - else { - double increment = (double) intersection.size() / cp_first.size(); - correct_by_cp = increment; //strict mode. if cp predicts multi labels, must all be correct, otherwise suffers penalty - } - } else { - } - // } - total_correct_by_cp += correct_by_cp; - total_wrong_by_cp += 1.0-correct_by_cp; - } else if(mode==1){ - double multiplier=isMain?1.0:0.5; - double correct_by_cp = 0.0; - List intersection_vital = new ArrayList(cp_first); - List intersection_ok = new ArrayList(cp_first); - List gs_ok = gs_annotations.size() == 2 ? gs_annotations.get(1) : new ArrayList(); - - intersection_vital.retainAll(gs_vital); - intersection_ok.retainAll(gs_ok); - - double total_correct = intersection_vital.size() + 0.5 * intersection_ok.size(); - correct_by_cp = total_correct / (double) cp_first.size(); - correct_by_cp=correct_by_cp*multiplier; - - total_correct_by_cp += correct_by_cp; - total_wrong_by_cp+=multiplier-correct_by_cp; - } - } - // total_wrong_by_cp=total_correct_by_gs-total_correct_by_cp; - if(total_wrong_by_cp<0){ - System.err.println("this should not happen, total wrong<0"); - total_wrong_by_cp=0; - } - return new double[]{total_correct_by_cp, total_correct_by_gs, total_wrong_by_cp}; - } - - - private String appendResult(double[] values) { - StringBuilder sb = new StringBuilder(); - sb.append(values[0]).append(",") - .append(values[1]).append(",") - .append(values[2]).append(","); - double p = values[0] / (values[0] + values[2]); - p = values[0] == 0 ? 0.0 : p; - - double r = values[0] / (values[1]); - r = values[0] == 0 ? 0 : r; - double f = 2 * p * r / (p + r); - f = r == 0.0 || p == 0.0 ? 0.0 : f; - - sb.append(p).append(",") - .append(r).append(",") - .append(f).append(","); - return sb.toString(); - - } - -} +package uk.ac.shef.dcs.sti.todo.evaluation; + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.*; + +import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; + +/** + * Created with IntelliJ IDEA. + * User: zqz + * Date: 26/02/14 + * Time: 14:14 + * To change this template use File | Settings | File Templates. + */ +public class Evaluator_RelationOnly { + + protected static boolean PREDICTION_ONE_CORRECT_COUNTS_ALL = false; //if prediction has multiple labels while gs has 1, if prediction covers gs, should it be 1 correct (true) or not (false) + + + public static void main(String[] args) throws IOException { + + /*Evaluator_Generic evaluator = new Evaluator_Generic(); + evaluator.evaluate( + "E:\\Data\\table annotation\\corpus_analysis\\100_tables\\100_tables_annotated(disamb=0)", + "E:\\Data\\table annotation\\corpus_analysis\\100_tables\\100_tables_gs", + "eval.csv", + "missed.csv" + );*/ + Evaluator_RelationOnly evaluator = new Evaluator_RelationOnly(); + evaluator.evaluate( + /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_cos(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_rel_bs_cos-all.csv", + "tmp_result/limaye_rel_bs_cos_missed-all.csv",true,false*/ + + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_cos(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_rel_bs_cos-ne.csv", + "tmp_result/limaye_rel_bs_cos_missed-ne.csv",true,true + + /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_nm+first(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_rel_bs_nm-all.csv", + "tmp_result/limaye_rel_bs_nm_missed-all.csv",true,false +*/ + /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_nm+first(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_rel_bs_nm-ne.csv", + "tmp_result/limaye_rel_bs_nm_missed-ne.csv",true,true*/ + + /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_dice(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_rel_bs_dice-all.csv", + "tmp_result/limaye_rel_bs_dice_missed-all.csv",true,false*/ + /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_dice(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_rel_bs_dice-ne.csv", + "tmp_result/limaye_rel_bs_dice_missed-ne.csv",true,true*/ + + /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_lev(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_rel_bs_lev-all.csv", + "tmp_result/limaye_rel_bs_lev_missed-all.csv",true,false*/ + + /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\baseline_sl_lev(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_rel_bs_lev-ne.csv", + "tmp_result/limaye_rel_bs_lev_missed-ne.csv",true,true*/ + + /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_rel_tm_ospd-all.csv", + "tmp_result/limaye_rel_tm_ospd_missed-all.csv",true,false*/ + + /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_rel_tm_ospd-ne.csv", + "tmp_result/limaye_rel_tm_ospd_missed-ne.csv",true,true*/ + + /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd_nsc", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_rel_tm_ospd_nsc-all.csv", + "tmp_result/limaye_rel_tm_ospd_nsc_missed-all.csv",true,false*/ + + /*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\output\\tm_dc_ri_ospd_nsc", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tmp_result/limaye_rel_tm_ospd_nsc-ne.csv", + "tmp_result/limaye_rel_tm_ospd_nsc_missed-ne.csv",true,true*/ + ); + + } + + public void evaluate(String in_computed_folder, + String in_gs_folder, + String in_header_gs_folder, + String out_result_file, + String out_missed_file, boolean tolerant_mode,boolean ne_relation_only) throws IOException { + PrintWriter p = new PrintWriter(out_result_file); + p.println("File,REL(0)_cp_y, gs_y, cp_n, p,r,f," + + "REL(1)_cp_y, gs_y, cp_n, p,r,f"); + + + PrintWriter out_missed_writer = new PrintWriter(out_missed_file); + Set processed = new HashSet(); + for (File gsFile : new File(in_gs_folder).listFiles()) { + + Map>>gs_binaryRels = null; + Map>> gs_header=null; + + List main = new ArrayList(); + List tolerant = new ArrayList(); + + String filename = gsFile.getName(); + if(processed.contains(filename)) + continue; + + if (filename.endsWith(".keys")) { + int dothtml = filename.lastIndexOf(".html"); + if(dothtml==-1) + dothtml=filename.lastIndexOf(".htm"); + if(dothtml==-1){ + System.err.println(filename); + continue; + } + int end = dothtml+5; + + filename = filename.substring(0, end).trim(); + System.out.println(filename); + /* if(filename.contains("Wisden")) + System.out.println();*/ + //if (!filename.contains(".attributes") && !filename.contains(".keys") && !processed.contains(filename)) { + + String binary = gsFile.getParent()+"/"+filename + ".relation.keys"; + processed.add(binary); + String header = in_header_gs_folder+"/"+filename+".header.keys"; + gs_header= TAnnotationKeyFileReader.readHeaderAnnotation(header, true, true); + + gs_binaryRels = TAnnotationKeyFileReader.readColumnBinaryRelationAnnotation_GS(binary, main, tolerant); + + processed.add(filename); + + } else { + continue; + } + if (gs_binaryRels == null) { + System.err.println(filename); + continue; + } + + boolean found = false; + + for (File cpFile : new File(in_computed_folder).listFiles()) { + if (cpFile.getName().startsWith(filename)) { + found = true; + + String cpFile_name = cpFile.toString(); + if(processed.contains(cpFile_name)||!cpFile_name.endsWith("keys")) + continue; + + String entity_cp = cpFile.getParent()+"/"+filename + ".cell.keys"; + processed.add(entity_cp); + String header_cp = cpFile.getParent()+"/"+filename + ".header.keys"; + processed.add(header_cp); + String binary_cp = cpFile.getParent()+"/"+filename + ".relation.keys"; + processed.add(binary_cp); + + StringBuilder line = new StringBuilder("\"" + cpFile.getPath() + "\","); + + Map>> cp_binaryRels = + TAnnotationKeyFileReader.readColumnBinaryRelationAnnotation_CP(binary_cp); + + double[] relation_data_mode_0 = compute_prf_relation(gs_binaryRels, cp_binaryRels, main, gs_header,0,ne_relation_only); + line.append(appendResult(relation_data_mode_0)); + + double[] relation_data_mode_1 = compute_prf_relation(gs_binaryRels, cp_binaryRels, main,gs_header, 1,ne_relation_only); + line.append(appendResult(relation_data_mode_1)); + + p.println(line.toString()); + break; + } + } + if (!found) { + out_missed_writer.println(gsFile); + } + } + out_missed_writer.close(); + p.close(); + } + + //warning: only works for relations between subcol and other cols. if in predicated relation files there are m:n relations this will fail!!! + public static double[] compute_prf_relation(Map>> gs, + Map>> cp, + List main, + Map>> gs_header, + int mode, + boolean ne_relation_only) { + double total_correct_by_cp = 0.0, total_wrong_by_cp = 0.0, total_correct_by_gs = 0.0; + + for (Map.Entry>> e : gs.entrySet()) { + int[] col = e.getKey(); + + if(ne_relation_only){ + if(!gs_header.containsKey(col[0])||!gs_header.containsKey(col[1])) + continue; + } + + String key = col[0]+","+col[1]; + + boolean isMain=false; + if(main.contains(key)) { //only the main entry is incremented. for every tolerant gs answer, there must be a main answer + total_correct_by_gs++; + isMain=true; + } + + List> gs_annotations = e.getValue(); + List gs_vital = gs_annotations.size() > 0 ? gs_annotations.get(0) : new ArrayList(); + List> cp_annotations = new ArrayList>(); + + for (Map.Entry>> f : cp.entrySet()) { + int[] col_cp = f.getKey(); + if (col[0] == col_cp[0] && col[1] == col_cp[1]) { + cp_annotations = f.getValue(); + break; + } + } + List cp_first = cp_annotations.size() > 0 ? cp_annotations.get(0) : new ArrayList(); + if (cp_first.size() == 0) { + continue; + } + + if (mode == 0 &&isMain) { + List intersection = new ArrayList(cp_first); + intersection.retainAll(gs_vital); + + double correct_by_cp=0; + if (intersection.size() > 0) { + if (PREDICTION_ONE_CORRECT_COUNTS_ALL){ + correct_by_cp=1; + } + else { + double increment = (double) intersection.size() / cp_first.size(); + correct_by_cp = increment; //strict mode. if cp predicts multi labels, must all be correct, otherwise suffers penalty + } + } else { + } + // } + total_correct_by_cp += correct_by_cp; + total_wrong_by_cp += 1.0-correct_by_cp; + } else if(mode==1){ + double multiplier=isMain?1.0:0.5; + double correct_by_cp = 0.0; + List intersection_vital = new ArrayList(cp_first); + List intersection_ok = new ArrayList(cp_first); + List gs_ok = gs_annotations.size() == 2 ? gs_annotations.get(1) : new ArrayList(); + + intersection_vital.retainAll(gs_vital); + intersection_ok.retainAll(gs_ok); + + double total_correct = intersection_vital.size() + 0.5 * intersection_ok.size(); + correct_by_cp = total_correct / (double) cp_first.size(); + correct_by_cp=correct_by_cp*multiplier; + + total_correct_by_cp += correct_by_cp; + total_wrong_by_cp+=multiplier-correct_by_cp; + } + } + // total_wrong_by_cp=total_correct_by_gs-total_correct_by_cp; + if(total_wrong_by_cp<0){ + System.err.println("this should not happen, total wrong<0"); + total_wrong_by_cp=0; + } + return new double[]{total_correct_by_cp, total_correct_by_gs, total_wrong_by_cp}; + } + + + private String appendResult(double[] values) { + StringBuilder sb = new StringBuilder(); + sb.append(values[0]).append(",") + .append(values[1]).append(",") + .append(values[2]).append(","); + double p = values[0] / (values[0] + values[2]); + p = values[0] == 0 ? 0.0 : p; + + double r = values[0] / (values[1]); + r = values[0] == 0 ? 0 : r; + double f = 2 * p * r / (p + r); + f = r == 0.0 || p == 0.0 ? 0.0 : f; + + sb.append(p).append(",") + .append(r).append(",") + .append(f).append(","); + return sb.toString(); + + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly_IMDB_MusicBrainz.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly_IMDB_MusicBrainz.java index e45f3cef..9ceae661 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly_IMDB_MusicBrainz.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/Evaluator_RelationOnly_IMDB_MusicBrainz.java @@ -1,222 +1,222 @@ -package uk.ac.shef.dcs.sti.todo.evaluation; - -import uk.ac.shef.dcs.kbsearch.freebase.FreebaseQueryProxy; -import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; - -import java.io.File; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.*; - -/** - - */ -public class Evaluator_RelationOnly_IMDB_MusicBrainz { - public static void main(String[] args) throws IOException { - - /*Evaluator_Generic evaluator = new Evaluator_Generic(); - evaluator.evaluate( - "E:\\Data\\table annotation\\corpus_analysis\\100_tables\\100_tables_annotated(disamb=0)", - "E:\\Data\\table annotation\\corpus_analysis\\100_tables\\100_tables_gs", - "eval.csv", - "missed.csv" - );*/ - /*Evaluator_RelationOnly_IMDB_MusicBrainz evaluator = new Evaluator_RelationOnly_IMDB_MusicBrainz(); - evaluator.evaluate( - *//*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\tableminer\\tm_dc_ri", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "tm_limaye_rel.csv", - "tm_limaye_rel_missed.csv",false,true*//* - *//* "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\baseline\\baseline_nm+first(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", - "bs_limaye_rel.csv", - "bs_limaye_rel_missed.csv",false*//* - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\baseline\\baseline_nm+first(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "bs_nm_limaye_rel.csv", - "bs_nm_limaye_rel_missed.csv", false, true - *//*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\baseline\\baseline_sl(RI)", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", - "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", - "bs_sl_limaye_rel.csv", - "bs_sl_limaye_rel_missed.csv",false,true*//* - );*/ - - - Evaluator_RelationOnly_IMDB_MusicBrainz evaluator = new Evaluator_RelationOnly_IMDB_MusicBrainz(); - evaluator.evaluate( - /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_nm", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_nm_rel-all.csv", - "tmp_result/mb_nm_rel_missed-all.csv",false,false*/ - - /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_nm", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_nm_rel-ne.csv", - "tmp_result/mb_nm_rel_missed-ne.csv",false,true*/ - - /* "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_dice", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_dice_rel-all.csv", - "tmp_result/mb_dice_rel_missed-all.csv",false,false*/ - - /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_dice", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_dice_rel-ne.csv", - "tmp_result/mb_dice_rel_missed-ne.csv",false,true -*/ - - /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_lev", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_lev_rel-all.csv", - "tmp_result/mb_lev_rel_missed-all.csv",false,false*/ - - /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_lev", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_lev_rel-ne.csv", - "tmp_result/mb_lev_rel_missed-ne.csv",false,true*/ - - /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_tm_ospd", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_tm_ospd_rel-all.csv", - "tmp_result/mb_tm_ospd_rel_missed-all.csv",false,false*/ - - /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_tm_ospd", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_tm_ospd_rel-ne.csv", - "tmp_result/mb_tm_ospd_rel_missed-ne.csv",false,true*/ - - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_tm_ospd_nsc", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_tm_ospd-nsc_rel-all.csv", - "tmp_result/mb_tm_ospd-nsc_rel_missed-all.csv",false,false - - /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_tm_ospd_nsc", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", - "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", - "tmp_result/mb_tm_ospd-nsc_rel-ne.csv", - "tmp_result/mb_tm_ospd-nsc_rel_missed-ne.csv",false,true*/ - - ); - - } - - public void evaluate(String in_computed_folder, - String in_gs_relation_file, - String in_gs_header_file, - String out_result_file, - String out_missed_file, boolean tolerant_mode, boolean ne_relation_only) throws IOException { - PrintWriter p = new PrintWriter(out_result_file); - p.println("File,REL(0)_cp_y, gs_y, cp_n, p,r,f," + - "REL(1)_cp_y, gs_y, cp_n, p,r,f"); - //todo: this will not work - FreebaseQueryProxy fb = null;//new FreebaseQueryProxy("D:\\Work\\lodiecrawler\\src\\main\\java/freebase.properties"); - - PrintWriter out_missed_writer = new PrintWriter(out_missed_file); - Set processed = new HashSet(); - List main = new ArrayList(); - List tolerant = new ArrayList(); - Map>> gs_binaryRels = - TAnnotationKeyFileReader.readColumnBinaryRelationAnnotation_GS(in_gs_relation_file, main, tolerant); - Map>> gs_header = - TAnnotationKeyFileReader.readHeaderAnnotation(in_gs_header_file, true, true); - - Map> unique_urls = new HashMap>(); - - int count=0; - for (File cpFile : new File(in_computed_folder).listFiles()) { - if (cpFile.getName().contains("relation.keys")) { - - String cpFile_name = cpFile.toString(); - if (processed.contains(cpFile_name)) - continue; - - count++; - System.out.println(count + "_" + cpFile_name); - - processed.add(cpFile_name); - - StringBuilder line = new StringBuilder("\"" + cpFile.getPath() + "\","); - - Map>> cp_binaryRels = - TAnnotationKeyFileReader.readColumnBinaryRelationAnnotation_CP(cpFile_name); - - for (int[] i : cp_binaryRels.keySet()) { - List> ll = cp_binaryRels.get(i); - Set unique = unique_urls.get(i); - unique = unique == null ? new HashSet() : unique; - for (List l : ll) - unique.addAll(l); - String key =i[0]+","+i[1]; - unique_urls.put(key, unique); - } - double[] relation_data_mode_0 = - Evaluator_RelationOnly.compute_prf_relation(gs_binaryRels, cp_binaryRels, main, gs_header, 0, ne_relation_only); - line.append(appendResult(relation_data_mode_0)); - - double[] relation_data_mode_1 = - Evaluator_RelationOnly.compute_prf_relation(gs_binaryRels, cp_binaryRels, main, gs_header, 1, ne_relation_only); - line.append(appendResult(relation_data_mode_1)); - - p.println(line.toString()); - } - } - - - out_missed_writer.close(); - p.close(); - - /*for (String i : unique_urls.keySet()) { - - List unique_sorted = new ArrayList(unique_urls.get(i)); - Collections.sort(unique_sorted); - System.out.println(">>>" + i); - for (String s : unique_sorted) { - if (s.startsWith("/m/")) { - try { - List facts = fb.topicapi_getAttributesOfTopicID(s, "/type/object/name"); - ; - if (facts.size() > 0) - s = s + ":" + facts.get(0)[1]; - } catch (Exception e) { - - } - } - System.out.println(s); - } - }*/ - } - - - private String appendResult(double[] values) { - StringBuilder sb = new StringBuilder(); - sb.append(values[0]).append(",") - .append(values[1]).append(",") - .append(values[2]).append(","); - double p = values[0] / (values[0] + values[2]); - p = values[0] == 0 ? 0.0 : p; - - double r = values[0] / (values[1]); - r = values[0] == 0 ? 0 : r; - double f = 2 * p * r / (p + r); - f = r == 0.0 || p == 0.0 ? 0.0 : f; - - sb.append(p).append(",") - .append(r).append(",") - .append(f).append(","); - return sb.toString(); - - } - -} +package uk.ac.shef.dcs.sti.todo.evaluation; + +import uk.ac.shef.dcs.kbsearch.freebase.FreebaseQueryProxy; +import uk.ac.shef.dcs.sti.todo.TAnnotationKeyFileReader; + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.*; + +/** + + */ +public class Evaluator_RelationOnly_IMDB_MusicBrainz { + public static void main(String[] args) throws IOException { + + /*Evaluator_Generic evaluator = new Evaluator_Generic(); + evaluator.evaluate( + "E:\\Data\\table annotation\\corpus_analysis\\100_tables\\100_tables_annotated(disamb=0)", + "E:\\Data\\table annotation\\corpus_analysis\\100_tables\\100_tables_gs", + "eval.csv", + "missed.csv" + );*/ + /*Evaluator_RelationOnly_IMDB_MusicBrainz evaluator = new Evaluator_RelationOnly_IMDB_MusicBrainz(); + evaluator.evaluate( + *//*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\tableminer\\tm_dc_ri", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "tm_limaye_rel.csv", + "tm_limaye_rel_missed.csv",false,true*//* + *//* "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\baseline\\baseline_nm+first(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", + "bs_limaye_rel.csv", + "bs_limaye_rel_missed.csv",false*//* + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\baseline\\baseline_nm+first(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "bs_nm_limaye_rel.csv", + "bs_nm_limaye_rel_missed.csv", false, true + *//*"E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\baseline\\baseline_sl(RI)", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\relation", + "E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ne+prop", + "bs_sl_limaye_rel.csv", + "bs_sl_limaye_rel_missed.csv",false,true*//* + );*/ + + + Evaluator_RelationOnly_IMDB_MusicBrainz evaluator = new Evaluator_RelationOnly_IMDB_MusicBrainz(); + evaluator.evaluate( + /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_nm", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_nm_rel-all.csv", + "tmp_result/mb_nm_rel_missed-all.csv",false,false*/ + + /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_nm", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_nm_rel-ne.csv", + "tmp_result/mb_nm_rel_missed-ne.csv",false,true*/ + + /* "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_dice", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_dice_rel-all.csv", + "tmp_result/mb_dice_rel_missed-all.csv",false,false*/ + + /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_dice", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_dice_rel-ne.csv", + "tmp_result/mb_dice_rel_missed-ne.csv",false,true +*/ + + /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_lev", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_lev_rel-all.csv", + "tmp_result/mb_lev_rel_missed-all.csv",false,false*/ + + /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_base_sl_lev", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_lev_rel-ne.csv", + "tmp_result/mb_lev_rel_missed-ne.csv",false,true*/ + + /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_tm_ospd", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_tm_ospd_rel-all.csv", + "tmp_result/mb_tm_ospd_rel_missed-all.csv",false,false*/ + + /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_tm_ospd", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_tm_ospd_rel-ne.csv", + "tmp_result/mb_tm_ospd_rel_missed-ne.csv",false,true*/ + + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_tm_ospd_nsc", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_tm_ospd-nsc_rel-all.csv", + "tmp_result/mb_tm_ospd-nsc_rel_missed-all.csv",false,false + + /*"E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\output\\musicbrainz_tm_ospd_nsc", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.relation.keys", + "E:\\Data\\table_annotation\\freebase_crawl\\music_record_label\\gs/musicbrainz.header.keys", + "tmp_result/mb_tm_ospd-nsc_rel-ne.csv", + "tmp_result/mb_tm_ospd-nsc_rel_missed-ne.csv",false,true*/ + + ); + + } + + public void evaluate(String in_computed_folder, + String in_gs_relation_file, + String in_gs_header_file, + String out_result_file, + String out_missed_file, boolean tolerant_mode, boolean ne_relation_only) throws IOException { + PrintWriter p = new PrintWriter(out_result_file); + p.println("File,REL(0)_cp_y, gs_y, cp_n, p,r,f," + + "REL(1)_cp_y, gs_y, cp_n, p,r,f"); + //todo: this will not work + FreebaseQueryProxy fb = null;//new FreebaseQueryProxy("D:\\Work\\lodiecrawler\\src\\main\\java/freebase.properties"); + + PrintWriter out_missed_writer = new PrintWriter(out_missed_file); + Set processed = new HashSet(); + List main = new ArrayList(); + List tolerant = new ArrayList(); + Map>> gs_binaryRels = + TAnnotationKeyFileReader.readColumnBinaryRelationAnnotation_GS(in_gs_relation_file, main, tolerant); + Map>> gs_header = + TAnnotationKeyFileReader.readHeaderAnnotation(in_gs_header_file, true, true); + + Map> unique_urls = new HashMap>(); + + int count=0; + for (File cpFile : new File(in_computed_folder).listFiles()) { + if (cpFile.getName().contains("relation.keys")) { + + String cpFile_name = cpFile.toString(); + if (processed.contains(cpFile_name)) + continue; + + count++; + System.out.println(count + "_" + cpFile_name); + + processed.add(cpFile_name); + + StringBuilder line = new StringBuilder("\"" + cpFile.getPath() + "\","); + + Map>> cp_binaryRels = + TAnnotationKeyFileReader.readColumnBinaryRelationAnnotation_CP(cpFile_name); + + for (int[] i : cp_binaryRels.keySet()) { + List> ll = cp_binaryRels.get(i); + Set unique = unique_urls.get(i); + unique = unique == null ? new HashSet() : unique; + for (List l : ll) + unique.addAll(l); + String key =i[0]+","+i[1]; + unique_urls.put(key, unique); + } + double[] relation_data_mode_0 = + Evaluator_RelationOnly.compute_prf_relation(gs_binaryRels, cp_binaryRels, main, gs_header, 0, ne_relation_only); + line.append(appendResult(relation_data_mode_0)); + + double[] relation_data_mode_1 = + Evaluator_RelationOnly.compute_prf_relation(gs_binaryRels, cp_binaryRels, main, gs_header, 1, ne_relation_only); + line.append(appendResult(relation_data_mode_1)); + + p.println(line.toString()); + } + } + + + out_missed_writer.close(); + p.close(); + + /*for (String i : unique_urls.keySet()) { + + List unique_sorted = new ArrayList(unique_urls.get(i)); + Collections.sort(unique_sorted); + System.out.println(">>>" + i); + for (String s : unique_sorted) { + if (s.startsWith("/m/")) { + try { + List facts = fb.topicapi_getAttributesOfTopicID(s, "/type/object/name"); + ; + if (facts.size() > 0) + s = s + ":" + facts.get(0)[1]; + } catch (Exception e) { + + } + } + System.out.println(s); + } + }*/ + } + + + private String appendResult(double[] values) { + StringBuilder sb = new StringBuilder(); + sb.append(values[0]).append(",") + .append(values[1]).append(",") + .append(values[2]).append(","); + double p = values[0] / (values[0] + values[2]); + p = values[0] == 0 ? 0.0 : p; + + double r = values[0] / (values[1]); + r = values[0] == 0 ? 0 : r; + double f = 2 * p * r / (p + r); + f = r == 0.0 || p == 0.0 ? 0.0 : f; + + sb.append(p).append(",") + .append(r).append(",") + .append(f).append(","); + return sb.toString(); + + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/KeyFileGenerator_from_HTMLOutput.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/KeyFileGenerator_from_HTMLOutput.java index 71d7aca7..0becbd26 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/KeyFileGenerator_from_HTMLOutput.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/evaluation/KeyFileGenerator_from_HTMLOutput.java @@ -1,239 +1,239 @@ -package uk.ac.shef.dcs.sti.todo.evaluation; - -import org.apache.any23.extractor.html.DomUtils; -import org.apache.any23.extractor.html.TagSoupParser; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import java.io.*; -import java.util.List; - -/** - */ -public class KeyFileGenerator_from_HTMLOutput { - protected TagSoupParser parser; - - public static void main(String[] args) throws FileNotFoundException { - KeyFileGenerator_from_HTMLOutput generator = new KeyFileGenerator_from_HTMLOutput(); - String inFolder = "E:\\Data\\table annotation\\freebase_crawl\\music_record_label\\musicbrainz_computed"; - String outFolder = "E:\\Data\\table annotation\\freebase_crawl\\music_record_label\\musicbrainz_computed_reformatted"; - //String inFolder = "E:\\Data\\table annotation\\freebase_crawl\\film_film\\imdb_computed"; - //String outFolder = "E:\\Data\\table annotation\\freebase_crawl\\film_film\\imdb_compted_reformatted"; - for (File f : new File(inFolder).listFiles()) { - if (f.toString().endsWith("attributes.html")) - continue; - generator.createKeyFiles(f.toString(), outFolder); - } - } - - public void createKeyFiles(String inFile, String outFolder) throws FileNotFoundException { - parser = new TagSoupParser(new FileInputStream(inFile), inFile); - Document doc = null; - try { - doc = parser.getDOM(); - } catch (IOException e) { - e.printStackTrace(); - } - - File f = new File(inFile); - System.out.println(f); - String name = f.getName(); - if (name.endsWith("htm.html")) - name = name.substring(0, name.indexOf(".html")).trim(); - String file_header_annotation = outFolder + File.separator + name + ".header.keys"; - String file_relation_annotation = outFolder + File.separator + name + ".relation.keys"; - String file_entity_annotation = outFolder + File.separator + name + ".entity.keys"; - - List table = DomUtils.findAll(doc, "//TABLE"); - Node firstTable = table.get(0); - Node secondTable = table.get(1); - - generateEntity_annotationKeys(firstTable, file_entity_annotation); - generateHeader_annotationKeys(firstTable, file_header_annotation); - generateRelation_annotationKeys(secondTable, file_relation_annotation); - } - - public void generateEntity_annotationKeys(Node table, String outFile) throws FileNotFoundException { - PrintWriter p = new PrintWriter(outFile); - List first_table_rows = DomUtils.findAll(table, "//TR"); - int count_row = -2; - boolean prevTableFound = false; - boolean tableEnds = false; - for (Node row : first_table_rows) { - count_row++; - Node current_row = row; - - if (current_row.getChildNodes().item(1).getNodeName().equalsIgnoreCase("th")) { - if (!prevTableFound) { - prevTableFound = true; - continue; - } else { - break; - } - } - - //DomUtils.findAll(current_row,"/TH") - - NodeList rowElements = current_row.getChildNodes(); - int count_column = -1, count_white_columns = 0; - String cellText = null, cellAnnotation = null; - - for (int i = 0; i < rowElements.getLength(); i++) { - Node cell = rowElements.item(i); - if (cell.getNodeType() == 3 || !cell.getNodeName().equals("TD")) - continue; - - Node color = cell.getAttributes() == null ? null : cell.getAttributes().getNamedItem("bgcolor"); - if (color == null) { - //this is the text column - if (cell.getNodeName().equals("TD")) { - count_column++; - cellText = cell.getTextContent(); - if (cellText.indexOf("[") != -1 && cellText.indexOf("]") != -1) - count_white_columns++; - } - } else { - //this is the annotation column - if (cell.getNodeName().equals("TD")) { - count_column++; - Node linkNode = null; - try { - linkNode = cell.getChildNodes().item(1).getChildNodes().item(0); - } catch (NullPointerException npe) { - } - - if (linkNode != null) { - String link = linkNode.getAttributes() == null ? null : linkNode.getAttributes().getNamedItem("href").getTextContent(); - cellAnnotation = link; - cellAnnotation = cellAnnotation.substring(23); - } - - int revised_column = count_column - count_white_columns; - if (cellAnnotation != null) - p.println(count_row + "," + revised_column + "=" + cellAnnotation); - } - } - } - - if (tableEnds) - break; - } - p.close(); - } - - public int generateRelation_annotationKeys(Node table, String outFile) throws FileNotFoundException { - PrintWriter p = new PrintWriter(outFile); - List table_rows = DomUtils.findAll(table, "//TR"); - int mainCol = -1; - int startRow = -1; - - for (int nodeIndex = 0; nodeIndex < table_rows.size(); nodeIndex++) { - Node row = table_rows.get(nodeIndex); - NodeList cells = row.getChildNodes(); - - int count_col = -1, count_white_col=0; - for (int i = 0; i < cells.getLength(); i++) { - Node cell = cells.item(i); - if (!cell.getNodeName().equals("TH")) - continue; - count_col++; - - Node color = cell.getAttributes() == null ? null : cell.getAttributes().getNamedItem("bgcolor"); - if (color == null){ - String headerText = cell.getTextContent().trim(); - if (!headerText.equals("-")) - count_white_col++; - continue; - } - String colorCode = color.getTextContent(); - if (colorCode.equals("yellow")) { - mainCol = count_col-count_white_col; - startRow = nodeIndex; - break; - } - } - - if (mainCol != -1) - break; - } - Node second_table_header = table_rows.get(startRow); - NodeList - headerElements = second_table_header.getChildNodes(); - int count_header_col = -1, count_white_col = 0; - String headerText = null, headerAnnotation = null; - for (int i = 0; i < headerElements.getLength(); i++) { - Node header = headerElements.item(i); - if (!header.getNodeName().equals("TH")) - continue; - count_header_col++; - - Node color = header.getAttributes() == null ? null : header.getAttributes().getNamedItem("bgcolor"); - if (color == null) { - //this is the text column - headerText = header.getTextContent().trim(); - if (!headerText.equals("-")) - count_white_col++; - } else { - if(color.getTextContent().equals("yellow")){ - count_header_col--; - continue; - } - - //this is the annotation column - headerAnnotation = header.getTextContent(); - - headerAnnotation = exractAnnotation(headerAnnotation); - int revisedCol =count_header_col-count_white_col; - p.println(mainCol + "," + revisedCol + "=" + headerAnnotation); - - } - } - p.close(); - return mainCol; - } - - public void generateHeader_annotationKeys(Node table, String outFile) throws FileNotFoundException { - PrintWriter p = new PrintWriter(outFile); - List first_table_rows = DomUtils.findAll(table, "//TR"); - Node first_table_header = first_table_rows.get(0); - - NodeList headerElements = first_table_header.getChildNodes(); - int count_header_col = -1, count_white_col = 0; - String headerText = null, headerAnnotation = null; - for (int i = 0; i < headerElements.getLength(); i++) { - Node header = headerElements.item(i); - if (!header.getNodeName().equalsIgnoreCase("th")) - continue; - - count_header_col++; - - Node color = header.getAttributes() == null ? null : header.getAttributes().getNamedItem("bgcolor"); - if (color == null) { - //this is the text column - headerText = header.getTextContent(); - if (!headerText.trim().equals("-")) - count_white_col++; - - } else { - //this is the annotation column - headerAnnotation = header.getTextContent(); - - int current_real_col = count_header_col - count_white_col; - headerAnnotation = exractAnnotation(headerAnnotation); - p.println(current_real_col + "=" + headerAnnotation); - - } - } - p.close(); - } - - private String exractAnnotation(String cellText) { - String value = cellText.split("=")[0].trim(); - int end = value.indexOf("("); - end=end==-1?value.length():end; - value = value.substring(0, end).trim(); - return value; - } - -} +package uk.ac.shef.dcs.sti.todo.evaluation; + +import org.apache.any23.extractor.html.DomUtils; +import org.apache.any23.extractor.html.TagSoupParser; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import java.io.*; +import java.util.List; + +/** + */ +public class KeyFileGenerator_from_HTMLOutput { + protected TagSoupParser parser; + + public static void main(String[] args) throws FileNotFoundException { + KeyFileGenerator_from_HTMLOutput generator = new KeyFileGenerator_from_HTMLOutput(); + String inFolder = "E:\\Data\\table annotation\\freebase_crawl\\music_record_label\\musicbrainz_computed"; + String outFolder = "E:\\Data\\table annotation\\freebase_crawl\\music_record_label\\musicbrainz_computed_reformatted"; + //String inFolder = "E:\\Data\\table annotation\\freebase_crawl\\film_film\\imdb_computed"; + //String outFolder = "E:\\Data\\table annotation\\freebase_crawl\\film_film\\imdb_compted_reformatted"; + for (File f : new File(inFolder).listFiles()) { + if (f.toString().endsWith("attributes.html")) + continue; + generator.createKeyFiles(f.toString(), outFolder); + } + } + + public void createKeyFiles(String inFile, String outFolder) throws FileNotFoundException { + parser = new TagSoupParser(new FileInputStream(inFile), inFile); + Document doc = null; + try { + doc = parser.getDOM(); + } catch (IOException e) { + e.printStackTrace(); + } + + File f = new File(inFile); + System.out.println(f); + String name = f.getName(); + if (name.endsWith("htm.html")) + name = name.substring(0, name.indexOf(".html")).trim(); + String file_header_annotation = outFolder + File.separator + name + ".header.keys"; + String file_relation_annotation = outFolder + File.separator + name + ".relation.keys"; + String file_entity_annotation = outFolder + File.separator + name + ".entity.keys"; + + List table = DomUtils.findAll(doc, "//TABLE"); + Node firstTable = table.get(0); + Node secondTable = table.get(1); + + generateEntity_annotationKeys(firstTable, file_entity_annotation); + generateHeader_annotationKeys(firstTable, file_header_annotation); + generateRelation_annotationKeys(secondTable, file_relation_annotation); + } + + public void generateEntity_annotationKeys(Node table, String outFile) throws FileNotFoundException { + PrintWriter p = new PrintWriter(outFile); + List first_table_rows = DomUtils.findAll(table, "//TR"); + int count_row = -2; + boolean prevTableFound = false; + boolean tableEnds = false; + for (Node row : first_table_rows) { + count_row++; + Node current_row = row; + + if (current_row.getChildNodes().item(1).getNodeName().equalsIgnoreCase("th")) { + if (!prevTableFound) { + prevTableFound = true; + continue; + } else { + break; + } + } + + //DomUtils.findAll(current_row,"/TH") + + NodeList rowElements = current_row.getChildNodes(); + int count_column = -1, count_white_columns = 0; + String cellText = null, cellAnnotation = null; + + for (int i = 0; i < rowElements.getLength(); i++) { + Node cell = rowElements.item(i); + if (cell.getNodeType() == 3 || !cell.getNodeName().equals("TD")) + continue; + + Node color = cell.getAttributes() == null ? null : cell.getAttributes().getNamedItem("bgcolor"); + if (color == null) { + //this is the text column + if (cell.getNodeName().equals("TD")) { + count_column++; + cellText = cell.getTextContent(); + if (cellText.indexOf("[") != -1 && cellText.indexOf("]") != -1) + count_white_columns++; + } + } else { + //this is the annotation column + if (cell.getNodeName().equals("TD")) { + count_column++; + Node linkNode = null; + try { + linkNode = cell.getChildNodes().item(1).getChildNodes().item(0); + } catch (NullPointerException npe) { + } + + if (linkNode != null) { + String link = linkNode.getAttributes() == null ? null : linkNode.getAttributes().getNamedItem("href").getTextContent(); + cellAnnotation = link; + cellAnnotation = cellAnnotation.substring(23); + } + + int revised_column = count_column - count_white_columns; + if (cellAnnotation != null) + p.println(count_row + "," + revised_column + "=" + cellAnnotation); + } + } + } + + if (tableEnds) + break; + } + p.close(); + } + + public int generateRelation_annotationKeys(Node table, String outFile) throws FileNotFoundException { + PrintWriter p = new PrintWriter(outFile); + List table_rows = DomUtils.findAll(table, "//TR"); + int mainCol = -1; + int startRow = -1; + + for (int nodeIndex = 0; nodeIndex < table_rows.size(); nodeIndex++) { + Node row = table_rows.get(nodeIndex); + NodeList cells = row.getChildNodes(); + + int count_col = -1, count_white_col=0; + for (int i = 0; i < cells.getLength(); i++) { + Node cell = cells.item(i); + if (!cell.getNodeName().equals("TH")) + continue; + count_col++; + + Node color = cell.getAttributes() == null ? null : cell.getAttributes().getNamedItem("bgcolor"); + if (color == null){ + String headerText = cell.getTextContent().trim(); + if (!headerText.equals("-")) + count_white_col++; + continue; + } + String colorCode = color.getTextContent(); + if (colorCode.equals("yellow")) { + mainCol = count_col-count_white_col; + startRow = nodeIndex; + break; + } + } + + if (mainCol != -1) + break; + } + Node second_table_header = table_rows.get(startRow); + NodeList + headerElements = second_table_header.getChildNodes(); + int count_header_col = -1, count_white_col = 0; + String headerText = null, headerAnnotation = null; + for (int i = 0; i < headerElements.getLength(); i++) { + Node header = headerElements.item(i); + if (!header.getNodeName().equals("TH")) + continue; + count_header_col++; + + Node color = header.getAttributes() == null ? null : header.getAttributes().getNamedItem("bgcolor"); + if (color == null) { + //this is the text column + headerText = header.getTextContent().trim(); + if (!headerText.equals("-")) + count_white_col++; + } else { + if(color.getTextContent().equals("yellow")){ + count_header_col--; + continue; + } + + //this is the annotation column + headerAnnotation = header.getTextContent(); + + headerAnnotation = exractAnnotation(headerAnnotation); + int revisedCol =count_header_col-count_white_col; + p.println(mainCol + "," + revisedCol + "=" + headerAnnotation); + + } + } + p.close(); + return mainCol; + } + + public void generateHeader_annotationKeys(Node table, String outFile) throws FileNotFoundException { + PrintWriter p = new PrintWriter(outFile); + List first_table_rows = DomUtils.findAll(table, "//TR"); + Node first_table_header = first_table_rows.get(0); + + NodeList headerElements = first_table_header.getChildNodes(); + int count_header_col = -1, count_white_col = 0; + String headerText = null, headerAnnotation = null; + for (int i = 0; i < headerElements.getLength(); i++) { + Node header = headerElements.item(i); + if (!header.getNodeName().equalsIgnoreCase("th")) + continue; + + count_header_col++; + + Node color = header.getAttributes() == null ? null : header.getAttributes().getNamedItem("bgcolor"); + if (color == null) { + //this is the text column + headerText = header.getTextContent(); + if (!headerText.trim().equals("-")) + count_white_col++; + + } else { + //this is the annotation column + headerAnnotation = header.getTextContent(); + + int current_real_col = count_header_col - count_white_col; + headerAnnotation = exractAnnotation(headerAnnotation); + p.println(current_real_col + "=" + headerAnnotation); + + } + } + p.close(); + } + + private String exractAnnotation(String cellText) { + String value = cellText.split("=")[0].trim(); + int end = value.indexOf("("); + end=end==-1?value.length():end; + value = value.substring(0, end).trim(); + return value; + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_IMDB.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_IMDB.java index 2607e494..2425b1d5 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_IMDB.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_IMDB.java @@ -1,134 +1,134 @@ -package uk.ac.shef.dcs.sti.todo.gs; - -import org.apache.any23.util.FileUtils; -import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; -import uk.ac.shef.dcs.sti.util.TripleGenerator; -import uk.ac.shef.dcs.sti.io.TAnnotationWriter; -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.TAnnotation; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.parser.table.validator.TableValidatorGeneric; -import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetectorByHTMLTag; -import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizerDiscardIrregularRows; -import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreatorIMDB; -import uk.ac.shef.dcs.sti.parser.table.TableParserIMDB; -import uk.ac.shef.dcs.kbsearch.freebase.FreebaseTopic; -import uk.ac.shef.dcs.kbsearch.freebase.FreebaseQueryProxy; - -import java.io.*; -import java.util.HashMap; -import java.util.List; - -/** - - */ -public class GSBuilder_IMDB { - - public static void main(String[] args) throws IOException { - GSBuilder_IMDB gsBuilder = new GSBuilder_IMDB(); - //todo:this will not work - FreebaseQueryProxy queryHelper = null; //new FreebaseQueryProxy(args[2]); - TAnnotationWriter writer = new TAnnotationWriter(new TripleGenerator("http://www.freebase.com", "http://dcs.shef.ac.uk")); - String inFolder = args[0]; - String outFolder = args[1]; - //read imdb page, create table object - - TableParserIMDB xtractor = new TableParserIMDB(new TableNormalizerDiscardIrregularRows(true), - new TableHODetectorByHTMLTag(), - new TableObjCreatorIMDB(), - new TableValidatorGeneric()); - int count = 0; - File[] all = new File(inFolder).listFiles(); - System.out.println(all.length); - for (File f : all) { - - count++; - System.out.println(count); - String inFile = f.toString(); - try { - String fileContent = FileUtils.readFileContent(new File(inFile)); - List
"); + if (start == -1) + start = content.indexOf(""); + if (start == -1) + start = content.indexOf("
"); - if(start==-1) - start=content.indexOf(""); - if(start==-1) - start=content.indexOf("
"); + if(start==-1) + start=content.indexOf(""); + if(start==-1) + start=content.indexOf("
tables = xtractor.extract(fileContent, inFile); - - if (tables.size() == 0) - continue; - - Table table = tables.get(0); - //gs annotator - System.out.println(f+", with rows: "+table.getNumRows()); - TAnnotation annotations = gsBuilder.annotate(table, queryHelper); - if (annotations != null) { - int count_annotations = 0; - for (int row = 0; row < table.getNumRows(); row++) { - for (int col = 0; col < table.getNumCols(); col++) { - TCellAnnotation[] cas = annotations.getContentCellAnnotations(row, col); - if (cas != null && cas.length > 0) - count_annotations++; - } - } - - if (count_annotations > 0) { - gsBuilder.save(table, annotations, outFolder, writer); - } - } - } catch (Exception e) { - e.printStackTrace(); - PrintWriter missedWriter = null; - try { - missedWriter = new PrintWriter(new FileWriter("missed.csv", true)); - } catch (IOException e1) { - e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. - } - missedWriter.println(inFile); - missedWriter.close(); - } - - } - } - - public TAnnotation annotate(Table table, FreebaseQueryProxy queryHelper) throws IOException { - TAnnotation tableAnnotation = new TAnnotation(table.getNumRows(), table.getNumCols()); - for (int row = 0; row < table.getNumRows(); row++) { - TCell ltc = table.getContentCell(row, 0); - String text = ltc.getText(); - int start = text.indexOf("/name/"); - if (start == -1) - continue; - else - start = start + 6; - int end = text.lastIndexOf("/"); - if (end == -1) - continue; - - String imdb_id = text.substring(start, end).trim(); - List list = queryHelper.searchapi_getTopicsByNameAndType(imdb_id, "any", false, 5); - if (list == null || list.size() == 0) - continue; - TCellAnnotation[] cas = new TCellAnnotation[1]; - cas[0] = new TCellAnnotation(text, list.get(0), 1.0, new HashMap()); - tableAnnotation.setContentCellAnnotations(row, 1, cas); - } - return tableAnnotation; - } - - - public void save(Table table, TAnnotation annotations, String outFolder, TAnnotationWriter writer) throws FileNotFoundException { - String fileId = table.getSourceId(); - fileId = fileId.replaceAll("\\\\","/"); - int trim = fileId.lastIndexOf("/"); - if(trim!=-1) - fileId=fileId.substring(trim+1).trim(); - writer.writeHTML(table, annotations, outFolder + File.separator + fileId); - String annotation_keys = outFolder + File.separator + fileId + ".keys"; - PrintWriter p = new PrintWriter(annotation_keys); - for (int row = 0; row < table.getNumRows(); row++) { - for (int col = 0; col < table.getNumCols(); col++) { - TCellAnnotation[] anns = annotations.getContentCellAnnotations(row, col); - if (anns != null && anns.length > 0) { - p.println(row + "," + col + "," + anns[0].getAnnotation().getId()); - } - } - } - p.close(); - } - -} +package uk.ac.shef.dcs.sti.todo.gs; + +import org.apache.any23.util.FileUtils; +import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; +import uk.ac.shef.dcs.sti.util.TripleGenerator; +import uk.ac.shef.dcs.sti.io.TAnnotationWriter; +import uk.ac.shef.dcs.sti.core.model.TCell; +import uk.ac.shef.dcs.sti.core.model.TAnnotation; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.parser.table.validator.TableValidatorGeneric; +import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetectorByHTMLTag; +import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizerDiscardIrregularRows; +import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreatorIMDB; +import uk.ac.shef.dcs.sti.parser.table.TableParserIMDB; +import uk.ac.shef.dcs.kbsearch.freebase.FreebaseTopic; +import uk.ac.shef.dcs.kbsearch.freebase.FreebaseQueryProxy; + +import java.io.*; +import java.util.HashMap; +import java.util.List; + +/** + + */ +public class GSBuilder_IMDB { + + public static void main(String[] args) throws IOException { + GSBuilder_IMDB gsBuilder = new GSBuilder_IMDB(); + //todo:this will not work + FreebaseQueryProxy queryHelper = null; //new FreebaseQueryProxy(args[2]); + TAnnotationWriter writer = new TAnnotationWriter(new TripleGenerator("http://www.freebase.com", "http://dcs.shef.ac.uk")); + String inFolder = args[0]; + String outFolder = args[1]; + //read imdb page, create table object + + TableParserIMDB xtractor = new TableParserIMDB(new TableNormalizerDiscardIrregularRows(true), + new TableHODetectorByHTMLTag(), + new TableObjCreatorIMDB(), + new TableValidatorGeneric()); + int count = 0; + File[] all = new File(inFolder).listFiles(); + System.out.println(all.length); + for (File f : all) { + + count++; + System.out.println(count); + String inFile = f.toString(); + try { + String fileContent = FileUtils.readFileContent(new File(inFile)); + List
tables = xtractor.extract(fileContent, inFile); + + if (tables.size() == 0) + continue; + + Table table = tables.get(0); + //gs annotator + System.out.println(f+", with rows: "+table.getNumRows()); + TAnnotation annotations = gsBuilder.annotate(table, queryHelper); + if (annotations != null) { + int count_annotations = 0; + for (int row = 0; row < table.getNumRows(); row++) { + for (int col = 0; col < table.getNumCols(); col++) { + TCellAnnotation[] cas = annotations.getContentCellAnnotations(row, col); + if (cas != null && cas.length > 0) + count_annotations++; + } + } + + if (count_annotations > 0) { + gsBuilder.save(table, annotations, outFolder, writer); + } + } + } catch (Exception e) { + e.printStackTrace(); + PrintWriter missedWriter = null; + try { + missedWriter = new PrintWriter(new FileWriter("missed.csv", true)); + } catch (IOException e1) { + e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } + missedWriter.println(inFile); + missedWriter.close(); + } + + } + } + + public TAnnotation annotate(Table table, FreebaseQueryProxy queryHelper) throws IOException { + TAnnotation tableAnnotation = new TAnnotation(table.getNumRows(), table.getNumCols()); + for (int row = 0; row < table.getNumRows(); row++) { + TCell ltc = table.getContentCell(row, 0); + String text = ltc.getText(); + int start = text.indexOf("/name/"); + if (start == -1) + continue; + else + start = start + 6; + int end = text.lastIndexOf("/"); + if (end == -1) + continue; + + String imdb_id = text.substring(start, end).trim(); + List list = queryHelper.searchapi_getTopicsByNameAndType(imdb_id, "any", false, 5); + if (list == null || list.size() == 0) + continue; + TCellAnnotation[] cas = new TCellAnnotation[1]; + cas[0] = new TCellAnnotation(text, list.get(0), 1.0, new HashMap()); + tableAnnotation.setContentCellAnnotations(row, 1, cas); + } + return tableAnnotation; + } + + + public void save(Table table, TAnnotation annotations, String outFolder, TAnnotationWriter writer) throws FileNotFoundException { + String fileId = table.getSourceId(); + fileId = fileId.replaceAll("\\\\","/"); + int trim = fileId.lastIndexOf("/"); + if(trim!=-1) + fileId=fileId.substring(trim+1).trim(); + writer.writeHTML(table, annotations, outFolder + File.separator + fileId); + String annotation_keys = outFolder + File.separator + fileId + ".keys"; + PrintWriter p = new PrintWriter(annotation_keys); + for (int row = 0; row < table.getNumRows(); row++) { + for (int col = 0; col < table.getNumCols(); col++) { + TCellAnnotation[] anns = annotations.getContentCellAnnotations(row, col); + if (anns != null && anns.length > 0) { + p.println(row + "," + col + "," + anns[0].getAnnotation().getId()); + } + } + } + p.close(); + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye.java index 513416a7..1333f978 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye.java @@ -1,258 +1,258 @@ -package uk.ac.shef.dcs.sti.todo.gs; - -import org.apache.any23.extractor.html.DomUtils; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.xml.sax.SAXException; -import uk.ac.shef.dcs.kbsearch.freebase.FreebaseQueryProxy; -import uk.ac.shef.dcs.sti.util.TripleGenerator; -import uk.ac.shef.dcs.sti.io.TAnnotationWriter; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.core.model.TAnnotation; -import uk.ac.shef.dcs.sti.util.FileUtils; -import uk.ac.shef.dcs.sti.parser.table.TableParserLimayeDataset; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import java.io.*; -import java.net.URL; -import java.net.URLConnection; -import java.util.*; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 09/03/14 - * Time: 15:13 - * To change this template use File | Settings | File Templates. - */ -public class GSBuilder_Limaye { - - private FreebaseQueryProxy queryHelper; - - public GSBuilder_Limaye(FreebaseQueryProxy queryHelper) { - this.queryHelper = queryHelper; - } - - public static void main(String[] args) throws IOException, SAXException, ParserConfigurationException { - find_missed_files_by_folder("E:\\Data\\table_annotation\\limaye\\all_tables_freebase_groundtruth", - "E:\\Data\\table_annotation\\limaye\\all_tables_groundtruth_xml_only", - "E:\\Data\\table_annotation\\limaye/gs_limaye_empty.missed"); - System.exit(0); - - /* find_missed_files("E:\\Data\\table annotation\\limaye/gs_limaye.e8031313", "E:\\Data\\table annotation\\limaye/gs_limaye.missed"); - System.exit(0);*/ - - - //todo:this will not work - FreebaseQueryProxy queryHelper = null;//new FreebaseQueryProxy(args[3]); - TAnnotationWriter writer = new TAnnotationWriter(new TripleGenerator("http://www.freebase.com", "http://dcs.shef.ac.uk")); - String in_raw_file_folder = args[0]; - String in_gs_file_folder = args[1]; - String outFolder = args[2]; - int startfrom = new Integer(args[4]); - List missedFile = new ArrayList(); - if (args.length == 6) { - missedFile = FileUtils.readList(args[5], true); - } - - GSBuilder_Limaye gsBuilder = new GSBuilder_Limaye(queryHelper); - int count = 0; - File[] all = new File(in_gs_file_folder).listFiles(); - List sorted = new ArrayList(Arrays.asList(all)); - System.out.println(all.length); - for (File f : sorted) { - try { - File raw_file = new File(in_raw_file_folder + "/" + f.getName()); - if (!raw_file.exists()) { - System.out.println("no gs for: " + f); - continue; - } - - if (missedFile.size() > 0) { - boolean missed = false; - for (String mf : missedFile) { - String fp = f.toString().replaceAll("\\\\", "/").toLowerCase(); - if (fp.endsWith(mf)) { - missed = true; - break; - } - } - if (!missed) - continue; - } - - count++; - if (startfrom > count) - continue; - - String inFile = f.toString(); - System.out.println(count + "_" + inFile + " " + new Date()); - Table table = new TableParserLimayeDataset().extract(raw_file.toString(), null).get(0); - TAnnotation annotations = gsBuilder.readTableAnnotation(inFile, table); - gsBuilder.save(table, annotations, outFolder, writer); - } catch (Exception e) { - System.err.println("ERROR:" + f); - e.printStackTrace(); - } - } - } - - public void save(Table table, TAnnotation annotations, String outFolder, TAnnotationWriter writer) throws FileNotFoundException { - String fileId = table.getSourceId(); - fileId = fileId.replaceAll("\\\\", "/"); - int trim = fileId.lastIndexOf("/"); - if (trim != -1) - fileId = fileId.substring(trim + 1).trim(); - writer.writeHTML(table, annotations, outFolder + File.separator + fileId); - String annotation_keys = outFolder + File.separator + fileId + ".keys"; - PrintWriter p = new PrintWriter(annotation_keys); - for (int row = 0; row < table.getNumRows(); row++) { - for (int col = 0; col < table.getNumCols(); col++) { - TCellAnnotation[] anns = annotations.getContentCellAnnotations(row, col); - if (anns != null && anns.length > 0) { - p.println(row + "," + col + "," + anns[0].getAnnotation().getId()); - } - } - } - p.close(); - } - - public TAnnotation readTableAnnotation(String tableAnnotationFilename, - Table table) throws IOException, ParserConfigurationException, SAXException { - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - - DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); - - Document domAnnotatedTable = docBuilder.parse(tableAnnotationFilename); - - //read the data rows annotations - List dataRowAnnotations = DomUtils.findAll(domAnnotatedTable, "//cellAnnotatoons/row"); - int total_columns = 0; - for (int i = 0; i < dataRowAnnotations.size(); i++) { - Node row = dataRowAnnotations.get(i); - List cols = DomUtils.findAll(row, "entity"); - int columns = 0; - for (int j = 0; j < cols.size(); j++) { - Node htmlCell = cols.get(j); - if (htmlCell.getTextContent() == null || htmlCell.getTextContent().length() == 0) { - continue; - } - columns++; - } - if (columns > total_columns) - total_columns = columns; - } - - TAnnotation annotations = new TAnnotation(table.getNumRows(), table.getNumCols()); - for (int i = 0; i < dataRowAnnotations.size(); i++) { - Node row = dataRowAnnotations.get(i); - List cols = DomUtils.findAll(row, "entity"); - for (int j = 0; j < cols.size(); j++) { - Node htmlCell = cols.get(j); - if (htmlCell.getTextContent() == null || htmlCell.getTextContent().length() == 0) { - continue; - } - String wikipedia_title = htmlCell.getTextContent().trim(); - try { - TCellAnnotation[] cellAnnotations = createCellAnnotation(wikipedia_title); - System.out.println("\t row=" + i + ",col=" + j); - if (cellAnnotations != null) - annotations.setContentCellAnnotations(i, j, cellAnnotations); - else { - System.out.println(); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - return annotations; - } - - public TCellAnnotation[] createCellAnnotation(String wikipedia_title) throws IOException { - String wiki_page_id = queryWikipediaPageId(wikipedia_title); - List list = queryHelper.mqlapi_topic_mids_with_wikipedia_pageid(wiki_page_id); - if (list == null || list.size() == 0) - return null; - - Entity ec = new Entity(list.get(0), wikipedia_title); - TCellAnnotation ca = new TCellAnnotation(wikipedia_title, ec, 1.0, new HashMap()); - return new TCellAnnotation[]{ca}; - } - - private static String queryWikipediaPageId(String wikipedia_title) throws IOException { - String query = "https://en.wikipedia.org/w/api.php?action=query&titles=" + wikipedia_title; - URL u = new URL(query); - URLConnection connection = u.openConnection(); - BufferedReader in = new BufferedReader( - new InputStreamReader( - connection.getInputStream())); - - StringBuilder response = new StringBuilder(); - String inputLine; - - while ((inputLine = in.readLine()) != null) - response.append(inputLine); - - in.close(); - - String result = response.toString(); - - int start = result.indexOf("page pageid="); - if (start != -1) { - String pageIdLine = result.substring(start); - int firstQuote = pageIdLine.indexOf("""); - if (firstQuote != -1) { - pageIdLine = pageIdLine.substring(firstQuote + 6); - int secondQuote = pageIdLine.indexOf("""); - if (secondQuote != -1) { - pageIdLine = pageIdLine.substring(0, secondQuote).trim(); - try { - return String.valueOf(Long.valueOf(pageIdLine)); - } catch (Exception e) { - } - } - } - } - - return null; - } - - public static void find_missed_files(String inLogFile, String outListFile) throws IOException { - - - PrintWriter p = new PrintWriter(outListFile); - for (String l : FileUtils.readList(inLogFile, false)) { - if (l.startsWith("ERROR:")) { - int start = l.indexOf(":"); - l = l.substring(start + 1).trim(); - p.println(l); - } - } - p.close(); - - } - - public static void find_missed_files_by_folder(String inFolder_with_annotations, String inFolder_raw, String out_missed_file) throws IOException { - - PrintWriter p = new PrintWriter(out_missed_file); - List annotated = new ArrayList(); - for (File f : new File(inFolder_with_annotations).listFiles()) { - annotated.add(f.getName()); - } - - for (File f : new File(inFolder_raw).listFiles()) { - if (annotated.contains(f.getName()+".cell.keys")) - continue; - else - p.println(f.getName()); - } - - p.close(); - } -} +package uk.ac.shef.dcs.sti.todo.gs; + +import org.apache.any23.extractor.html.DomUtils; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.xml.sax.SAXException; +import uk.ac.shef.dcs.kbsearch.freebase.FreebaseQueryProxy; +import uk.ac.shef.dcs.sti.util.TripleGenerator; +import uk.ac.shef.dcs.sti.io.TAnnotationWriter; +import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.core.model.TAnnotation; +import uk.ac.shef.dcs.sti.util.FileUtils; +import uk.ac.shef.dcs.sti.parser.table.TableParserLimayeDataset; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import java.io.*; +import java.net.URL; +import java.net.URLConnection; +import java.util.*; + +/** + * Created with IntelliJ IDEA. + * User: zqz + * Date: 09/03/14 + * Time: 15:13 + * To change this template use File | Settings | File Templates. + */ +public class GSBuilder_Limaye { + + private FreebaseQueryProxy queryHelper; + + public GSBuilder_Limaye(FreebaseQueryProxy queryHelper) { + this.queryHelper = queryHelper; + } + + public static void main(String[] args) throws IOException, SAXException, ParserConfigurationException { + find_missed_files_by_folder("E:\\Data\\table_annotation\\limaye\\all_tables_freebase_groundtruth", + "E:\\Data\\table_annotation\\limaye\\all_tables_groundtruth_xml_only", + "E:\\Data\\table_annotation\\limaye/gs_limaye_empty.missed"); + System.exit(0); + + /* find_missed_files("E:\\Data\\table annotation\\limaye/gs_limaye.e8031313", "E:\\Data\\table annotation\\limaye/gs_limaye.missed"); + System.exit(0);*/ + + + //todo:this will not work + FreebaseQueryProxy queryHelper = null;//new FreebaseQueryProxy(args[3]); + TAnnotationWriter writer = new TAnnotationWriter(new TripleGenerator("http://www.freebase.com", "http://dcs.shef.ac.uk")); + String in_raw_file_folder = args[0]; + String in_gs_file_folder = args[1]; + String outFolder = args[2]; + int startfrom = new Integer(args[4]); + List missedFile = new ArrayList(); + if (args.length == 6) { + missedFile = FileUtils.readList(args[5], true); + } + + GSBuilder_Limaye gsBuilder = new GSBuilder_Limaye(queryHelper); + int count = 0; + File[] all = new File(in_gs_file_folder).listFiles(); + List sorted = new ArrayList(Arrays.asList(all)); + System.out.println(all.length); + for (File f : sorted) { + try { + File raw_file = new File(in_raw_file_folder + "/" + f.getName()); + if (!raw_file.exists()) { + System.out.println("no gs for: " + f); + continue; + } + + if (missedFile.size() > 0) { + boolean missed = false; + for (String mf : missedFile) { + String fp = f.toString().replaceAll("\\\\", "/").toLowerCase(); + if (fp.endsWith(mf)) { + missed = true; + break; + } + } + if (!missed) + continue; + } + + count++; + if (startfrom > count) + continue; + + String inFile = f.toString(); + System.out.println(count + "_" + inFile + " " + new Date()); + Table table = new TableParserLimayeDataset().extract(raw_file.toString(), null).get(0); + TAnnotation annotations = gsBuilder.readTableAnnotation(inFile, table); + gsBuilder.save(table, annotations, outFolder, writer); + } catch (Exception e) { + System.err.println("ERROR:" + f); + e.printStackTrace(); + } + } + } + + public void save(Table table, TAnnotation annotations, String outFolder, TAnnotationWriter writer) throws FileNotFoundException { + String fileId = table.getSourceId(); + fileId = fileId.replaceAll("\\\\", "/"); + int trim = fileId.lastIndexOf("/"); + if (trim != -1) + fileId = fileId.substring(trim + 1).trim(); + writer.writeHTML(table, annotations, outFolder + File.separator + fileId); + String annotation_keys = outFolder + File.separator + fileId + ".keys"; + PrintWriter p = new PrintWriter(annotation_keys); + for (int row = 0; row < table.getNumRows(); row++) { + for (int col = 0; col < table.getNumCols(); col++) { + TCellAnnotation[] anns = annotations.getContentCellAnnotations(row, col); + if (anns != null && anns.length > 0) { + p.println(row + "," + col + "," + anns[0].getAnnotation().getId()); + } + } + } + p.close(); + } + + public TAnnotation readTableAnnotation(String tableAnnotationFilename, + Table table) throws IOException, ParserConfigurationException, SAXException { + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + + DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); + + Document domAnnotatedTable = docBuilder.parse(tableAnnotationFilename); + + //read the data rows annotations + List dataRowAnnotations = DomUtils.findAll(domAnnotatedTable, "//cellAnnotatoons/row"); + int total_columns = 0; + for (int i = 0; i < dataRowAnnotations.size(); i++) { + Node row = dataRowAnnotations.get(i); + List cols = DomUtils.findAll(row, "entity"); + int columns = 0; + for (int j = 0; j < cols.size(); j++) { + Node htmlCell = cols.get(j); + if (htmlCell.getTextContent() == null || htmlCell.getTextContent().length() == 0) { + continue; + } + columns++; + } + if (columns > total_columns) + total_columns = columns; + } + + TAnnotation annotations = new TAnnotation(table.getNumRows(), table.getNumCols()); + for (int i = 0; i < dataRowAnnotations.size(); i++) { + Node row = dataRowAnnotations.get(i); + List cols = DomUtils.findAll(row, "entity"); + for (int j = 0; j < cols.size(); j++) { + Node htmlCell = cols.get(j); + if (htmlCell.getTextContent() == null || htmlCell.getTextContent().length() == 0) { + continue; + } + String wikipedia_title = htmlCell.getTextContent().trim(); + try { + TCellAnnotation[] cellAnnotations = createCellAnnotation(wikipedia_title); + System.out.println("\t row=" + i + ",col=" + j); + if (cellAnnotations != null) + annotations.setContentCellAnnotations(i, j, cellAnnotations); + else { + System.out.println(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + return annotations; + } + + public TCellAnnotation[] createCellAnnotation(String wikipedia_title) throws IOException { + String wiki_page_id = queryWikipediaPageId(wikipedia_title); + List list = queryHelper.mqlapi_topic_mids_with_wikipedia_pageid(wiki_page_id); + if (list == null || list.size() == 0) + return null; + + Entity ec = new Entity(list.get(0), wikipedia_title); + TCellAnnotation ca = new TCellAnnotation(wikipedia_title, ec, 1.0, new HashMap()); + return new TCellAnnotation[]{ca}; + } + + private static String queryWikipediaPageId(String wikipedia_title) throws IOException { + String query = "https://en.wikipedia.org/w/api.php?action=query&titles=" + wikipedia_title; + URL u = new URL(query); + URLConnection connection = u.openConnection(); + BufferedReader in = new BufferedReader( + new InputStreamReader( + connection.getInputStream())); + + StringBuilder response = new StringBuilder(); + String inputLine; + + while ((inputLine = in.readLine()) != null) + response.append(inputLine); + + in.close(); + + String result = response.toString(); + + int start = result.indexOf("page pageid="); + if (start != -1) { + String pageIdLine = result.substring(start); + int firstQuote = pageIdLine.indexOf("""); + if (firstQuote != -1) { + pageIdLine = pageIdLine.substring(firstQuote + 6); + int secondQuote = pageIdLine.indexOf("""); + if (secondQuote != -1) { + pageIdLine = pageIdLine.substring(0, secondQuote).trim(); + try { + return String.valueOf(Long.valueOf(pageIdLine)); + } catch (Exception e) { + } + } + } + } + + return null; + } + + public static void find_missed_files(String inLogFile, String outListFile) throws IOException { + + + PrintWriter p = new PrintWriter(outListFile); + for (String l : FileUtils.readList(inLogFile, false)) { + if (l.startsWith("ERROR:")) { + int start = l.indexOf(":"); + l = l.substring(start + 1).trim(); + p.println(l); + } + } + p.close(); + + } + + public static void find_missed_files_by_folder(String inFolder_with_annotations, String inFolder_raw, String out_missed_file) throws IOException { + + PrintWriter p = new PrintWriter(out_missed_file); + List annotated = new ArrayList(); + for (File f : new File(inFolder_with_annotations).listFiles()) { + annotated.add(f.getName()); + } + + for (File f : new File(inFolder_raw).listFiles()) { + if (annotated.contains(f.getName()+".cell.keys")) + continue; + else + p.println(f.getName()); + } + + p.close(); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables.java index f1c98c2d..9677f982 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables.java @@ -1,913 +1,913 @@ -package uk.ac.shef.dcs.sti.todo.gs; - -import org.apache.any23.extractor.html.DomUtils; -import org.apache.any23.extractor.html.TagSoupParser; -import org.apache.commons.lang3.StringEscapeUtils; -import org.apache.solr.client.solrj.SolrServerException; -import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; -import org.apache.tika.io.IOUtils; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.xml.sax.SAXException; -import uk.ac.shef.dcs.kbsearch.freebase.FreebaseQueryProxy; -import uk.ac.shef.dcs.sti.STIEnum; -import uk.ac.shef.dcs.sti.core.subjectcol.TColumnFeatureGenerator; -import uk.ac.shef.dcs.sti.util.DataTypeClassifier; -import uk.ac.shef.dcs.sti.core.model.*; -import uk.ac.shef.dcs.sti.parser.table.TableParserLimayeDataset; -import uk.ac.shef.dcs.sti.parser.table.TableParserWikipedia; -import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizerDiscardIrregularRows; -import uk.ac.shef.dcs.util.SolrCache; -import uk.ac.shef.dcs.sti.parser.table.validator.TableValidatorGeneric; -import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetectorByHTMLTag; -import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreatorWikipediaGS; -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.sti.util.CollectionUtils; -import uk.ac.shef.dcs.sti.util.FileUtils; -import uk.ac.shef.dcs.websearch.WebSearch; -import uk.ac.shef.dcs.websearch.WebSearchFactory; -import uk.ac.shef.dcs.websearch.bing.v2.BingSearchResultParser; -import uk.ac.shef.dcs.websearch.WebSearchResultDoc; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; -import java.io.*; -import java.net.URISyntaxException; -import java.net.URL; -import java.net.URLConnection; -import java.util.*; -import java.util.List; -import java.util.logging.Logger; - -/** - */ -public class GSBuilder_Limaye_Wikitables { - protected FreebaseQueryProxy queryHelper; - protected SolrCache solrCache; - protected TableParserWikipedia xtractor; - protected WebSearch searcher; - protected BingSearchResultParser parser; - protected static String wikipediaURL = "http://en.wikipedia.org/wiki/"; - protected static int maxRows = 200; - - protected static Logger log = Logger.getLogger(GSBuilder_Limaye_Wikitables.class.getName()); - - public GSBuilder_Limaye_Wikitables(FreebaseQueryProxy queryHelper, - SolrCache cache_solr, - TableParserWikipedia xtractor, - String propertyFile) throws IOException { - this.queryHelper = queryHelper; - this.solrCache = cache_solr; - this.xtractor = xtractor; - this.queryHelper = queryHelper; - this.solrCache = cache_solr; - this.xtractor = xtractor; - try { - searcher = new WebSearchFactory().createInstance( - propertyFile); - } catch (Exception e) { - e.printStackTrace(); - } - parser = new BingSearchResultParser(); - parser = new BingSearchResultParser(); - } - - public GSBuilder_Limaye_Wikitables() { - } - - public static void main(String[] args) throws IOException, SAXException, ParserConfigurationException { -/* - find_missed_files_by_folder("E:\\Data\\table annotation\\limaye\\all_tables_freebase_groundtruth", - "E:\\Data\\table annotation\\limaye\\all_tables_groundtruth_xml_only", - "E:\\Data\\table annotation\\limaye/gs_limaye_empty.missed"); - System.exit(0);*/ - - /* find_missed_files("E:\\Data\\table annotation\\limaye/gs_limaye.e8031313", "E:\\Data\\table annotation\\limaye/gs_limaye.missed"); - System.exit(0);*/ - -//todo: this will not work - FreebaseQueryProxy queryHelper = null; //new FreebaseQueryProxy(args[3]); - String in_original_limaye_folder = args[0]; - String in_original_limaye_annotation_folder = args[1]; - String out_gs_folder = args[2]; - String solrCache = args[4]; - int startfrom = new Integer(args[5]); - Map missedFile = new HashMap(); - - if (args.length == 7) { - for (String l : FileUtils.readList(args[6], false)) { - String[] parts = l.split("\t\t\t"); - missedFile.put(parts[0].trim().replaceAll(":", "~"), parts[1].trim()); - } - } - - //todo: this will not work - /*File configFile = new File(solrCache + File.separator + "solr.xml"); - CoreContainer container = new CoreContainer(solrCache, - configFile);*/ - EmbeddedSolrServer server = null; //new EmbeddedSolrServer(container, "collection1"); - SolrCache cache = new SolrCache(server); - - TableParserWikipedia xtractor = new TableParserWikipedia(new TableNormalizerDiscardIrregularRows(true), - new TableHODetectorByHTMLTag(), - new TableObjCreatorWikipediaGS(true), - new TableValidatorGeneric()); - - GSBuilder_Limaye_Wikitables gsBuilder = new GSBuilder_Limaye_Wikitables(queryHelper, - cache, xtractor, - "8Yr8amTvrm5SM4XK3vM3KrLqOCT/ZhkwCfLEDtslE7o="); - - int count = 0; - File[] all = new File(in_original_limaye_folder).listFiles(); - List sorted = new ArrayList(Arrays.asList(all)); - Collections.sort(sorted); - System.out.println(all.length); - for (File f : sorted) { - try { - count++; - if (startfrom > count) - continue; - if (f.getName().startsWith("file")) { - System.err.println("ERROR:SKIPPED_NON_WIKI:" + f.getName()); - continue; - } - - if (missedFile.size() > 0) { - boolean found = false; - for (String mf : missedFile.keySet()) { - if (f.toString().endsWith(mf)) { - found = true; - break; - } - } - if (!found - ) - continue; //Éric Cantona - } - - System.out.println(count + "_" + f); - /* if (f.toString().contains("Portal~")) - System.out.println();*/ - Table original = new TableParserLimayeDataset().extract(f.toString(), in_original_limaye_annotation_folder + "/" + f.getName()).get(0); - - - String wikiPage = null; - if (missedFile.size() > 0) { - for (String mf : missedFile.keySet()) { - if (f.toString().endsWith(mf)) { - wikiPage = fetchWikipediaWebpage(missedFile.get(mf)); - break; - } - } - if (wikiPage == null) - continue; //Éric Cantona - } else { //MUST REGEN GS FOR 112 TABLES!!! - //multiword - //what is corresponding wikipedia title - int dot_html = f.getName().indexOf(".htm"); - if (dot_html == -1) - dot_html = f.getName().length(); - String wikiTitle = f.getName().substring(0, dot_html); - - try { - wikiPage = fetchWikipediaWebpage(wikipediaURL + wikiTitle); - } catch (Exception e) { - wikiTitle = parseToWikipediaTitle(f.toString()); - try { - wikiPage = fetchWikipediaWebpage(wikipediaURL + wikiTitle); - } catch (Exception ee) { - if (wikiTitle.indexOf("~") != -1) { - System.err.println("ERROR:~REPLACED_NO_MATCH:" + f.getName()); - continue; - } - } - } - if (wikiPage == null || wikiPage.length() == 0) { - wikiPage = gsBuilder.tryWebSearch(wikiTitle); - if (wikiPage == null) { - System.err.println("ERROR:NO_WIKIPAGE:" + f.getName()); - continue; - } - } - } - //wikiPage = StringUtils.stripAccents(wikiPage); - //wikiPage=wikiPage.replaceAll("–", "-"); - Map> allLinkMap = extractLinksFromWikipediaPage(wikiPage, f.toURI().toString()); - List candidates = extractWikiTables(wikiPage, f.toURI().toString()); - Node theOne = findMatchingTable(original, candidates); - // boolean split_large_table=false; - if (theOne == null) { - boolean fuzzy = gsBuilder.annotateTable_fuzzy(original, allLinkMap, out_gs_folder + "/" + f.getName() + ".cell.keys"); - if (fuzzy) { - System.err.println("WARNING:NO_TABLE:" + f.getName()); - gsBuilder.saveAsLimaye(original, out_gs_folder + "/" + f.getName()); - } else System.err.println("ERROR:NO_TABLE:" + f.getName()); - continue; - } - Table wikitable = gsBuilder. - process_wikitable(theOne, f.toURI().toString(), f.toURI().toString(), original.getContexts().toArray(new TContext[0])); - - if (wikitable == null) { - boolean fuzzy = gsBuilder.annotateTable_fuzzy(original, allLinkMap, out_gs_folder + "/" + f.getName() + ".cell.keys"); - if (fuzzy) { - System.err.println("WARNING:IRREGULAR_TABLE:" + f.getName()); - gsBuilder.saveAsLimaye(original, out_gs_folder + "/" + f.getName()); - } else System.err.println("ERROR:IRREGULAR_TABLE:" + f.getName()); - continue; - } - if (wikitable.getNumCols() == 1 && original.getNumCols() > 0) { - boolean fuzzy = gsBuilder.annotateTable_fuzzy(original, allLinkMap, out_gs_folder + "/" + f.getName() + ".cell.keys"); - if (fuzzy) { - System.err.println("WARNING:NO_TABLE(only 1 column):" + f.getName()); - gsBuilder.saveAsLimaye(original, out_gs_folder + "/" + f.getName()); - } else System.err.println("ERROR:NO_TABLE(only 1 column):" + f.getName()); - continue; - } - if (wikitable.getNumRows() > maxRows) { - boolean fuzzy = gsBuilder.annotateTable_fuzzy(original, allLinkMap, out_gs_folder + "/" + f.getName() + ".cell.keys"); - if (fuzzy) { - System.err.println("WARNING:TOO_LARGE:" + f.getName()); - gsBuilder.saveAsLimaye(original, out_gs_folder + "/" + f.getName()); - } else System.err.println("ERROR:TOO_LARGE:" + f.getName()); - continue; - } - boolean noHeader = false; - for (int j = 0; j < wikitable.getNumCols(); j++) { - TColumnHeader h = wikitable.getColumnHeader(j); - if (h.getHeaderText().equals(STIEnum.TABLE_HEADER_UNKNOWN.getValue())) - noHeader = true; - } - if (noHeader) { - boolean fuzzy = gsBuilder.annotateTable_fuzzy(original, allLinkMap, out_gs_folder + "/" + f.getName() + ".cell.keys"); - if (fuzzy) { - System.err.println("WARNING:NO_HEADER:" + f.getName()); - gsBuilder.saveAsLimaye(original, out_gs_folder + "/" + f.getName()); - } else System.err.println("ERROR:NO_HEADER:" + f.getName()); - continue; - } - - - boolean annotated = gsBuilder.annotateTable(wikitable, - out_gs_folder + "/" + f.getName() + ".cell.keys", maxRows); - //if(annotated) - gsBuilder.saveAsLimaye(wikitable, out_gs_folder + "/" + f.getName()); - // else - // System.err.println("ERROR:FEWER_THAN_ORIGINAL_ANNOTATIONS_CREATED,SKIPPED:"+f.getName()); - - - } catch (Exception e) { - System.err.println("ERROR:UNKNOWN:" + f.getName()); - e.printStackTrace(); - } - } - server.close(); - System.exit(0); - } - - protected String tryWebSearch(String wikiTitle) throws Exception { - wikiTitle = wikiTitle.replaceAll("[^a-zA-Z0-9]", " ").trim(); - if (wikiTitle.startsWith("/")) - wikiTitle = wikiTitle.substring(1).trim(); - String url = ""; - try { - Object o = solrCache.retrieve("websearch_" + wikiTitle); - if (o != null) - url = o.toString(); - } catch (Exception e) { - } - - if (url.equals("")) { - List docs = parser.parse(searcher.search(wikiTitle + " wikipedia")); - for (WebSearchResultDoc d : docs) { - String title = d.getTitle().replaceAll("[^a-zA-Z0-9]", " ").trim(); - if (d.getUrl().indexOf("wikipedia.org/wiki") == -1) - continue; - if (title.startsWith(wikiTitle)) { - url = d.getUrl(); - break; - } - } - if (url.equals("")) { - int best = 0, bestindex = -1; - List wikiTitle_tokens = new ArrayList(); - for (String t : wikiTitle.split("\\s+")) { - t = t.trim(); - if (t.length() > 0) - wikiTitle_tokens.add(t); - } - for (int i = 0; i < docs.size(); i++) { - String candidateTitle = docs.get(i).getTitle().replaceAll("_", " ").trim(); - if (candidateTitle.indexOf("Wikipedia") == -1) - continue; - List candidate_tokens = new ArrayList(); - for (String t : candidateTitle.split("\\s+")) { - t = t.trim(); - if (t.length() > 0) { - candidate_tokens.add(t); - } - } - candidate_tokens.retainAll(wikiTitle_tokens); - if (candidate_tokens.size() > best) { - best = candidate_tokens.size(); - bestindex = i; - } - } - if (bestindex != -1) { - url = docs.get(bestindex).getUrl(); - } - } - - try { - solrCache.cache("websearch_" + wikiTitle, url, true); - } catch (SolrServerException e) { - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. - } - } - - if (url.equals("")) - return null; //To change body of created methods use File | Settings | File Templates. - -/* int trimStart = url.lastIndexOf("/wiki/"); - if (trimStart != -1) { - url = url.substring(trimStart + 6); - }*/ - if (!url.contains("en.wikipedia")) - return null; - return fetchWikipediaWebpage(url); - } - - - //Communes_of_the_Haute-Vienne_department_a209.html_0.xml - protected static String parseToWikipediaTitle(String limaye_data_file_name) { - limaye_data_file_name = limaye_data_file_name.replaceAll("\\\\", "/"); - int dot_html = limaye_data_file_name.indexOf(".htm"); - if (dot_html == -1) - return null; - int begin = limaye_data_file_name.lastIndexOf("/"); - begin = begin == -1 ? 0 : begin + 1; - limaye_data_file_name = limaye_data_file_name.substring(begin, dot_html); - int arbitrary_id = limaye_data_file_name.lastIndexOf("_"); - arbitrary_id = arbitrary_id == -1 ? limaye_data_file_name.length() : arbitrary_id; - limaye_data_file_name = limaye_data_file_name.substring(0, arbitrary_id).trim(); - - if (limaye_data_file_name.indexOf("~") != -1) { - limaye_data_file_name = limaye_data_file_name.replaceAll("~", ":"); - } - return limaye_data_file_name; - } - - - protected static String fetchWikipediaWebpage(String wikipediaurl) throws IOException, URISyntaxException { - - URL u = new URL(wikipediaurl); - URLConnection uc = u.openConnection(); - BufferedReader in = new BufferedReader( - new InputStreamReader( - uc.getInputStream())); - - StringBuilder response = new StringBuilder(); - String inputLine; - - while ((inputLine = in.readLine()) != null) - response.append(inputLine); - - in.close(); - - String wikiPage = response.toString(); - - return wikiPage; - } - - - protected static String toString_LTable(Table table) { - StringBuilder sb = new StringBuilder(); - for (int j = 0; j < table.getNumCols(); j++) { - TColumnHeader header = table.getColumnHeader(j); - if (header == null || header.getHeaderText() == null || header.getHeaderText().equals(STIEnum.TABLE_HEADER_UNKNOWN)) - continue; - sb.append(header.getHeaderText()).append(" "); - } - for (int i = 0; i < table.getNumRows(); i++) { - for (int j = 0; j < table.getNumCols(); j++) { - TCell tcc = table.getContentCell(i, j); - if (tcc != null && tcc.getText() != null) { - sb.append(tcc.getText()).append(" "); - } - } - } - return sb.toString().trim(); - } - - - protected void saveAsLimaye(Table table, String outFile) throws TransformerException, ParserConfigurationException { - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); - - // root elements - Document doc = docBuilder.newDocument(); - Element rootElement = doc.createElement("entity"); - doc.appendChild(rootElement); - // logicaltable elements - Element logicalTable = doc.createElement("logicalTable"); - - //content element - Element content = doc.createElement("content"); - Element context = doc.createElement("tableContext"); - - //write header cells - Element headerElement = doc.createElement("header"); - for (int j = 0; j < table.getNumCols(); j++) { - Element he = doc.createElement("cell"); - String text = ""; - String wikilink = ""; - TColumnHeader h = table.getColumnHeader(j); - if (h != null && !h.getHeaderText().equals(STIEnum.TABLE_HEADER_UNKNOWN)) { - text = h.getHeaderText(); - } - Element textElement = doc.createElement("html"); - text = StringEscapeUtils.escapeHtml4(text); - text = text.replaceAll(" ", " ").trim(); - textElement.appendChild(doc.createTextNode(text)); - Element wikiElement = doc.createElement("wikipedia"); - wikiElement.appendChild(doc.createTextNode(wikilink)); - he.appendChild(textElement); - he.appendChild(wikiElement); - headerElement.appendChild(he); - } - content.appendChild(headerElement); - - //write table cells - - for (int r = 0; r < table.getNumRows(); r++) { - Element rowElement = doc.createElement("row"); - for (int c = 0; c < table.getNumCols(); c++) { - Element cell = doc.createElement("cell"); - String text = ""; - String wikilink = ""; - TCell tcc = table.getContentCell(r, c); - if (tcc != null && tcc.getText() != null) { - text = tcc.getText(); - } - //table.getTableAnnotations().getContentCellAnnotations(r, c); - - TCellAnnotation[] annotations = table.getTableAnnotations().getContentCellAnnotations(r, c); - if (annotations != null && annotations.length > 0) { - TCellAnnotation ca = annotations[0]; - wikilink = ca.getAnnotation().getId(); - if (wikilink.startsWith("/wiki/")) - wikilink = wikilink.substring(6).trim(); - } - - Element textElement = doc.createElement("html"); - text = StringEscapeUtils.escapeHtml4(text); - text = text.replaceAll(" ", " ").trim(); - textElement.appendChild(doc.createTextNode(text)); - Element wikiElement = doc.createElement("wikipedia"); - wikiElement.appendChild(doc.createTextNode(wikilink)); - cell.appendChild(textElement); - cell.appendChild(wikiElement); - rowElement.appendChild(cell); - } - content.appendChild(rowElement); - } - - - //write table contexts - for (TContext ltc : table.getContexts()) { - Element context_child = doc.createElement("context"); - Element context_score = doc.createElement("computeElementScores"); - context_score.appendChild(doc.createTextNode(String.valueOf(ltc.getImportanceScore()))); - Element context_text = doc.createElement("text"); - context_text.appendChild(doc.createTextNode(ltc.getText())); - context_child.appendChild(context_score); - context_child.appendChild(context_text); - context.appendChild(context_child); - } - - logicalTable.appendChild(content); - - logicalTable.appendChild(context); - rootElement.appendChild(logicalTable); - - // write the content into xml file - TransformerFactory transformerFactory = TransformerFactory.newInstance(); - Transformer transformer = transformerFactory.newTransformer(); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.setOutputProperty(OutputKeys.METHOD, "xml"); - transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); - DOMSource source = new DOMSource(doc); - StreamResult result = new StreamResult(new File(outFile)); - - // Output to console for testing - // StreamResult result = new StreamResult(System.out); - - transformer.transform(source, result); - } - - private boolean annotateTable(Table originalTable, String annotationFile, int maxRows) throws IOException, TransformerException, ParserConfigurationException { - //saveAsLimaye(table, rawFile); - TColumnFeatureGenerator.setColumnDataTypes(originalTable); - - StringBuilder annotation = new StringBuilder(); - - int totalAnnotations = 0; - for (int r = 0; r < originalTable.getNumRows(); r++) { - if (r >= maxRows) - break; - for (int c = 0; c < originalTable.getNumCols(); c++) { - DataTypeClassifier.DataType type = originalTable.getColumnHeader(c).getTypes().get(0).getType(); - if (type.equals(DataTypeClassifier.DataType.NUMBER) || type.equals(DataTypeClassifier.DataType.DATE) || - type.equals(DataTypeClassifier.DataType.ORDERED_NUMBER) || - type.equals(DataTypeClassifier.DataType.LONG_TEXT) || - type.equals(DataTypeClassifier.DataType.LONG_STRING)) - continue; - - System.out.println("\t\tr=" + r + ",c=" + c); - TCell tcc = originalTable.getContentCell(r, c); - if (tcc != null) { - TCellAnnotation[] annotations = originalTable.getTableAnnotations().getContentCellAnnotations(r, c); - String wikiTitle = ""; - if (annotations != null && annotations.length > 0) { - TCellAnnotation ca = annotations[0]; - wikiTitle = ca.getAnnotation().getId(); - if (wikiTitle.startsWith("/wiki/")) { - wikiTitle = wikiTitle.substring(6).trim(); - totalAnnotations++; - } - } - - if (wikiTitle.length() > 0) { - String pageid = queryWikipediaPageid(wikiTitle, solrCache); - if (pageid != null) { - String fb_id = createCellAnnotation(pageid, solrCache); - if (fb_id != null && fb_id.length() > 0) { - annotation.append(r + "," + c + "=").append(fb_id).append("\n"); - } - } - } - } - } - } - - //boolean output = false; - int count_original_annotations = 0; - if (originalTable.getTableAnnotations() != null) { - for (int r = 0; r < originalTable.getNumRows(); r++) { - for (int c = 0; c < originalTable.getNumCols(); c++) { - TCellAnnotation[] annotations = originalTable.getTableAnnotations().getContentCellAnnotations(r, c); - if (annotations != null && annotations.length > 0) - count_original_annotations++; - } - } - if (totalAnnotations >= count_original_annotations) { - //output = true; - } - } - //if (output) { - PrintWriter p = new PrintWriter(annotationFile); - p.println(annotation); - p.close(); - // } - return true; - } - - protected Table process_wikitable(Node tableNode, String tableId, String sourceId, TContext... contexts) { - Table table = xtractor.extractTable(tableNode, tableId, sourceId, contexts); - return table; - } - - private static String toString_Node(Node n) { - String text = ""; - if (n.hasChildNodes()) { - for (int i = 0; i < n.getChildNodes().getLength(); i++) { - Node child = n.getChildNodes().item(i); - text += toString_Node(child); - } - } else { - text = n.getTextContent() + " "; - } - return text; - } - - protected static double computeOverlap(String string1, String string2) { - List tokens1 = new ArrayList(Arrays.asList(string1.split("\\s+"))); - List tokens2 = new ArrayList(Arrays.asList(string2.split("\\s+"))); - - return CollectionUtils.computeFrequencyWeightedDice(tokens1, tokens2); - } - - protected static Node findMatchingTable(Table limaye_original_table, List candidates) { - double maxScore = 0.0; - Node theOne = null; - String table = toString_LTable(limaye_original_table); - for (Node n : candidates) { - String nodeContent = toString_Node(n); - double overlap = computeOverlap(table, nodeContent); - if (overlap > maxScore) { - maxScore = overlap; - theOne = n; - } - } - - int theOne_rows = 0; - int theOne_max_cols = 0; - if (theOne != null) { - List children = DomUtils.findAll(theOne, "//TR"); - if (children != null) - theOne_rows = children.size(); - for (Node n : children) { - { - if (n.getChildNodes().getLength() > theOne_max_cols) - theOne_max_cols = n.getChildNodes().getLength(); - } - } - } - - if (theOne == null || (maxScore < 1.0 && theOne_rows < limaye_original_table.getNumRows()) || - (theOne_max_cols == 1 && limaye_original_table.getNumCols() > 1)) { - System.err.println("(candidate table too small, likely to be incorrect so skipped)"); - return null; - } - return theOne; - } - - protected static List extractWikiTables(String wikiPageContentString, String documentURI) { - List tableNodes = new ArrayList(); - TagSoupParser parser = new TagSoupParser(IOUtils.toInputStream(wikiPageContentString), documentURI, "UTF-8"); - Document doc = null; - try { - doc = parser.getDOM(); - } catch (IOException e) { - return tableNodes; - } - - int tableCount = 0; - List tables = DomUtils.findAll(doc, /*"//TABLE[@class='wikitable']"*/"//TABLE"); - if (tables.size() > 0) - tableNodes.addAll(tables); - /* if (tables.size() > 0) - tableNodes.addAll(tables);*/ - - return tableNodes; - } - - public static String queryWikipediaPageid(String wikipedia_title, SolrCache cache) throws IOException { - Date startTime = new Date(); - - String query = "https://en.wikipedia.org/w/api.php?action=query&titles=" + wikipedia_title; - String pageid = null; - try { - Object o = cache.retrieve(query); - if (o == null) { - pageid = null; - } else - pageid = o.toString(); - } catch (Exception e) { - e.printStackTrace(); - } - - if (pageid == null) { - URL u = new URL(query); - URLConnection connection = u.openConnection(); - BufferedReader in = new BufferedReader( - new InputStreamReader( - connection.getInputStream())); - - StringBuilder response = new StringBuilder(); - String inputLine; - - while ((inputLine = in.readLine()) != null) - response.append(inputLine); - - in.close(); - - String result = response.toString(); - - int start = result.indexOf("page pageid="); - if (start != -1) { - String pageIdLine = result.substring(start); - int firstQuote = pageIdLine.indexOf("""); - if (firstQuote != -1) { - pageIdLine = pageIdLine.substring(firstQuote + 6); - int secondQuote = pageIdLine.indexOf("""); - if (secondQuote != -1) { - pageIdLine = pageIdLine.substring(0, secondQuote).trim(); - try { - pageid = String.valueOf(Long.valueOf(pageIdLine)); - } catch (Exception e) { - pageid = ""; - } - } - } - } - - if (pageid != null) { - try { - cache.cache(query, pageid, true); - } catch (SolrServerException e) { - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. - } - } - - } - - Date endTime = new Date(); - log.info("queryWikipedia:" + (endTime.getTime() - startTime.getTime())); - - if (pageid != null && pageid.length() > 0) - return pageid; - return null; - - - } - - public String createCellAnnotation(String pageid, SolrCache cache) throws IOException { - String freebase_id = null; - try { - Object o = cache.retrieve(pageid); - if (o != null) { - freebase_id = o.toString(); - } - } catch (SolrServerException e) { - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. - } catch (ClassNotFoundException e) { - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. - } - - if (freebase_id == null) { - - List list = queryHelper.mqlapi_topic_mids_with_wikipedia_pageid(pageid); - if (list == null || list.size() == 0) - freebase_id = ""; - else { - freebase_id = list.get(0); - } - try { - cache.cache(pageid, freebase_id, true); - } catch (SolrServerException e) { - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. - } - } - - if (freebase_id == null) - return null; - - - if (freebase_id.equals("")) - return null; - else { - return freebase_id; - } - } - - - public static void find_missed_files(String inLogFile, String outListFile) throws IOException { - - - PrintWriter p = new PrintWriter(outListFile); - for (String l : FileUtils.readList(inLogFile, false)) { - if (l.startsWith("ERROR:")) { - int start = l.indexOf(":"); - l = l.substring(start + 1).trim(); - p.println(l); - } - } - p.close(); - - } - - public static void find_missed_files_by_folder(String inFolder_with_annotations, String inFolder_raw, String out_missed_file) throws IOException { - - PrintWriter p = new PrintWriter(out_missed_file); - List annotated = new ArrayList(); - for (File f : new File(inFolder_with_annotations).listFiles()) { - annotated.add(f.getName()); - } - - for (File f : new File(inFolder_raw).listFiles()) { - if (annotated.contains(f.getName() + ".cell.keys")) - continue; - else - p.println(f.getName()); - } - - p.close(); - } - - public static Map> extractLinksFromWikipediaPage(String content, String documentURI) { - TagSoupParser parser = new TagSoupParser(IOUtils.toInputStream(content), documentURI, "UTF-8"); - Document doc = null; - try { - doc = parser.getDOM(); - } catch (IOException e) { - return null; - } - - int tableCount = 0; - List links = DomUtils.findAll(doc, /*"//TABLE[@class='wikitable']"*/"//A"); - Map> linkMap = new HashMap>(); - for (Node n : links) { - String text = n.getTextContent(); - if (text.trim().length() < 1) - continue; - String link = ""; - try { - link = n.getAttributes().getNamedItem("href").getTextContent(); - } catch (Exception e) { - } - if (text != null && text.length() > 0 && link.length() > 0) { - Set theLinks = linkMap.get(text); - theLinks = theLinks == null ? new HashSet() : theLinks; - theLinks.add(link); - linkMap.put(text, theLinks); - } - - } - - return linkMap; - } - - private boolean annotateTable_fuzzy(Table originalTable, Map> linkMap, String annotationFile - ) throws IOException, TransformerException, ParserConfigurationException { - //saveAsLimaye(table, rawFile); - TColumnFeatureGenerator.setColumnDataTypes(originalTable); - int count_original_annotations = 0; - if (originalTable.getTableAnnotations() != null) { - for (int r = 0; r < originalTable.getNumRows(); r++) { - for (int c = 0; c < originalTable.getNumCols(); c++) { - TCellAnnotation[] annotations = originalTable.getTableAnnotations().getContentCellAnnotations(r, c); - if (annotations != null && annotations.length > 0) { - count_original_annotations++; - originalTable.getTableAnnotations().setContentCellAnnotations(r, c,new TCellAnnotation[0]); - } - } - } - } - - - StringBuilder annotation = new StringBuilder(); - int totalAnnotations = 0; - for (int r = 0; r < originalTable.getNumRows(); r++) { - for (int c = 0; c < originalTable.getNumCols(); c++) { - DataTypeClassifier.DataType type = originalTable.getColumnHeader(c).getTypes().get(0).getType(); - if (type.equals(DataTypeClassifier.DataType.NUMBER) || type.equals(DataTypeClassifier.DataType.DATE) || - type.equals(DataTypeClassifier.DataType.ORDERED_NUMBER) || - type.equals(DataTypeClassifier.DataType.LONG_TEXT) || - type.equals(DataTypeClassifier.DataType.LONG_STRING)) - continue; - - System.out.println("\t\tr=" + r + ",c=" + c); - TCell tcc = originalTable.getContentCell(r, c); - if (tcc != null) { - String text = tcc.getText().trim(); - Set links = linkMap.get(text); - String wikiTitle = ""; - if (links != null && links.size() == 1) { - wikiTitle = links.iterator().next(); - if (wikiTitle.startsWith("/wiki/")) { - wikiTitle = wikiTitle.substring(6).trim(); - totalAnnotations++; - } - } - - if (wikiTitle.length() > 0) { - String pageid = queryWikipediaPageid(wikiTitle, solrCache); - if (pageid != null) { - String fb_id = createCellAnnotation(pageid, solrCache); - if (fb_id != null && fb_id.length() > 0) { - annotation.append(r + "," + c + "=").append(fb_id).append("\n"); - } - TCellAnnotation ca = - new TCellAnnotation(tcc.getText(), new Entity(wikiTitle, wikiTitle), 1.0, new HashMap()); - originalTable.getTableAnnotations().setContentCellAnnotations( - r, c, new TCellAnnotation[]{ca} - ); - } - } - } - } - } - - boolean output = false; - //System.err.println(totalAnnotations+","+count_original_annotations); - if (totalAnnotations >= count_original_annotations) - output = true; - - if (output) { - PrintWriter p = new PrintWriter(annotationFile); - p.println(annotation); - p.close(); - } - return output; - } - - -} +package uk.ac.shef.dcs.sti.todo.gs; + +import org.apache.any23.extractor.html.DomUtils; +import org.apache.any23.extractor.html.TagSoupParser; +import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.solr.client.solrj.SolrServerException; +import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; +import org.apache.tika.io.IOUtils; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.xml.sax.SAXException; +import uk.ac.shef.dcs.kbsearch.freebase.FreebaseQueryProxy; +import uk.ac.shef.dcs.sti.STIEnum; +import uk.ac.shef.dcs.sti.core.subjectcol.TColumnFeatureGenerator; +import uk.ac.shef.dcs.sti.util.DataTypeClassifier; +import uk.ac.shef.dcs.sti.core.model.*; +import uk.ac.shef.dcs.sti.parser.table.TableParserLimayeDataset; +import uk.ac.shef.dcs.sti.parser.table.TableParserWikipedia; +import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizerDiscardIrregularRows; +import uk.ac.shef.dcs.util.SolrCache; +import uk.ac.shef.dcs.sti.parser.table.validator.TableValidatorGeneric; +import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetectorByHTMLTag; +import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreatorWikipediaGS; +import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.sti.util.CollectionUtils; +import uk.ac.shef.dcs.sti.util.FileUtils; +import uk.ac.shef.dcs.websearch.WebSearch; +import uk.ac.shef.dcs.websearch.WebSearchFactory; +import uk.ac.shef.dcs.websearch.bing.v2.BingSearchResultParser; +import uk.ac.shef.dcs.websearch.WebSearchResultDoc; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import java.io.*; +import java.net.URISyntaxException; +import java.net.URL; +import java.net.URLConnection; +import java.util.*; +import java.util.List; +import java.util.logging.Logger; + +/** + */ +public class GSBuilder_Limaye_Wikitables { + protected FreebaseQueryProxy queryHelper; + protected SolrCache solrCache; + protected TableParserWikipedia xtractor; + protected WebSearch searcher; + protected BingSearchResultParser parser; + protected static String wikipediaURL = "http://en.wikipedia.org/wiki/"; + protected static int maxRows = 200; + + protected static Logger log = Logger.getLogger(GSBuilder_Limaye_Wikitables.class.getName()); + + public GSBuilder_Limaye_Wikitables(FreebaseQueryProxy queryHelper, + SolrCache cache_solr, + TableParserWikipedia xtractor, + String propertyFile) throws IOException { + this.queryHelper = queryHelper; + this.solrCache = cache_solr; + this.xtractor = xtractor; + this.queryHelper = queryHelper; + this.solrCache = cache_solr; + this.xtractor = xtractor; + try { + searcher = new WebSearchFactory().createInstance( + propertyFile); + } catch (Exception e) { + e.printStackTrace(); + } + parser = new BingSearchResultParser(); + parser = new BingSearchResultParser(); + } + + public GSBuilder_Limaye_Wikitables() { + } + + public static void main(String[] args) throws IOException, SAXException, ParserConfigurationException { +/* + find_missed_files_by_folder("E:\\Data\\table annotation\\limaye\\all_tables_freebase_groundtruth", + "E:\\Data\\table annotation\\limaye\\all_tables_groundtruth_xml_only", + "E:\\Data\\table annotation\\limaye/gs_limaye_empty.missed"); + System.exit(0);*/ + + /* find_missed_files("E:\\Data\\table annotation\\limaye/gs_limaye.e8031313", "E:\\Data\\table annotation\\limaye/gs_limaye.missed"); + System.exit(0);*/ + +//todo: this will not work + FreebaseQueryProxy queryHelper = null; //new FreebaseQueryProxy(args[3]); + String in_original_limaye_folder = args[0]; + String in_original_limaye_annotation_folder = args[1]; + String out_gs_folder = args[2]; + String solrCache = args[4]; + int startfrom = new Integer(args[5]); + Map missedFile = new HashMap(); + + if (args.length == 7) { + for (String l : FileUtils.readList(args[6], false)) { + String[] parts = l.split("\t\t\t"); + missedFile.put(parts[0].trim().replaceAll(":", "~"), parts[1].trim()); + } + } + + //todo: this will not work + /*File configFile = new File(solrCache + File.separator + "solr.xml"); + CoreContainer container = new CoreContainer(solrCache, + configFile);*/ + EmbeddedSolrServer server = null; //new EmbeddedSolrServer(container, "collection1"); + SolrCache cache = new SolrCache(server); + + TableParserWikipedia xtractor = new TableParserWikipedia(new TableNormalizerDiscardIrregularRows(true), + new TableHODetectorByHTMLTag(), + new TableObjCreatorWikipediaGS(true), + new TableValidatorGeneric()); + + GSBuilder_Limaye_Wikitables gsBuilder = new GSBuilder_Limaye_Wikitables(queryHelper, + cache, xtractor, + "8Yr8amTvrm5SM4XK3vM3KrLqOCT/ZhkwCfLEDtslE7o="); + + int count = 0; + File[] all = new File(in_original_limaye_folder).listFiles(); + List sorted = new ArrayList(Arrays.asList(all)); + Collections.sort(sorted); + System.out.println(all.length); + for (File f : sorted) { + try { + count++; + if (startfrom > count) + continue; + if (f.getName().startsWith("file")) { + System.err.println("ERROR:SKIPPED_NON_WIKI:" + f.getName()); + continue; + } + + if (missedFile.size() > 0) { + boolean found = false; + for (String mf : missedFile.keySet()) { + if (f.toString().endsWith(mf)) { + found = true; + break; + } + } + if (!found + ) + continue; //Éric Cantona + } + + System.out.println(count + "_" + f); + /* if (f.toString().contains("Portal~")) + System.out.println();*/ + Table original = new TableParserLimayeDataset().extract(f.toString(), in_original_limaye_annotation_folder + "/" + f.getName()).get(0); + + + String wikiPage = null; + if (missedFile.size() > 0) { + for (String mf : missedFile.keySet()) { + if (f.toString().endsWith(mf)) { + wikiPage = fetchWikipediaWebpage(missedFile.get(mf)); + break; + } + } + if (wikiPage == null) + continue; //Éric Cantona + } else { //MUST REGEN GS FOR 112 TABLES!!! + //multiword + //what is corresponding wikipedia title + int dot_html = f.getName().indexOf(".htm"); + if (dot_html == -1) + dot_html = f.getName().length(); + String wikiTitle = f.getName().substring(0, dot_html); + + try { + wikiPage = fetchWikipediaWebpage(wikipediaURL + wikiTitle); + } catch (Exception e) { + wikiTitle = parseToWikipediaTitle(f.toString()); + try { + wikiPage = fetchWikipediaWebpage(wikipediaURL + wikiTitle); + } catch (Exception ee) { + if (wikiTitle.indexOf("~") != -1) { + System.err.println("ERROR:~REPLACED_NO_MATCH:" + f.getName()); + continue; + } + } + } + if (wikiPage == null || wikiPage.length() == 0) { + wikiPage = gsBuilder.tryWebSearch(wikiTitle); + if (wikiPage == null) { + System.err.println("ERROR:NO_WIKIPAGE:" + f.getName()); + continue; + } + } + } + //wikiPage = StringUtils.stripAccents(wikiPage); + //wikiPage=wikiPage.replaceAll("–", "-"); + Map> allLinkMap = extractLinksFromWikipediaPage(wikiPage, f.toURI().toString()); + List candidates = extractWikiTables(wikiPage, f.toURI().toString()); + Node theOne = findMatchingTable(original, candidates); + // boolean split_large_table=false; + if (theOne == null) { + boolean fuzzy = gsBuilder.annotateTable_fuzzy(original, allLinkMap, out_gs_folder + "/" + f.getName() + ".cell.keys"); + if (fuzzy) { + System.err.println("WARNING:NO_TABLE:" + f.getName()); + gsBuilder.saveAsLimaye(original, out_gs_folder + "/" + f.getName()); + } else System.err.println("ERROR:NO_TABLE:" + f.getName()); + continue; + } + Table wikitable = gsBuilder. + process_wikitable(theOne, f.toURI().toString(), f.toURI().toString(), original.getContexts().toArray(new TContext[0])); + + if (wikitable == null) { + boolean fuzzy = gsBuilder.annotateTable_fuzzy(original, allLinkMap, out_gs_folder + "/" + f.getName() + ".cell.keys"); + if (fuzzy) { + System.err.println("WARNING:IRREGULAR_TABLE:" + f.getName()); + gsBuilder.saveAsLimaye(original, out_gs_folder + "/" + f.getName()); + } else System.err.println("ERROR:IRREGULAR_TABLE:" + f.getName()); + continue; + } + if (wikitable.getNumCols() == 1 && original.getNumCols() > 0) { + boolean fuzzy = gsBuilder.annotateTable_fuzzy(original, allLinkMap, out_gs_folder + "/" + f.getName() + ".cell.keys"); + if (fuzzy) { + System.err.println("WARNING:NO_TABLE(only 1 column):" + f.getName()); + gsBuilder.saveAsLimaye(original, out_gs_folder + "/" + f.getName()); + } else System.err.println("ERROR:NO_TABLE(only 1 column):" + f.getName()); + continue; + } + if (wikitable.getNumRows() > maxRows) { + boolean fuzzy = gsBuilder.annotateTable_fuzzy(original, allLinkMap, out_gs_folder + "/" + f.getName() + ".cell.keys"); + if (fuzzy) { + System.err.println("WARNING:TOO_LARGE:" + f.getName()); + gsBuilder.saveAsLimaye(original, out_gs_folder + "/" + f.getName()); + } else System.err.println("ERROR:TOO_LARGE:" + f.getName()); + continue; + } + boolean noHeader = false; + for (int j = 0; j < wikitable.getNumCols(); j++) { + TColumnHeader h = wikitable.getColumnHeader(j); + if (h.getHeaderText().equals(STIEnum.TABLE_HEADER_UNKNOWN.getValue())) + noHeader = true; + } + if (noHeader) { + boolean fuzzy = gsBuilder.annotateTable_fuzzy(original, allLinkMap, out_gs_folder + "/" + f.getName() + ".cell.keys"); + if (fuzzy) { + System.err.println("WARNING:NO_HEADER:" + f.getName()); + gsBuilder.saveAsLimaye(original, out_gs_folder + "/" + f.getName()); + } else System.err.println("ERROR:NO_HEADER:" + f.getName()); + continue; + } + + + boolean annotated = gsBuilder.annotateTable(wikitable, + out_gs_folder + "/" + f.getName() + ".cell.keys", maxRows); + //if(annotated) + gsBuilder.saveAsLimaye(wikitable, out_gs_folder + "/" + f.getName()); + // else + // System.err.println("ERROR:FEWER_THAN_ORIGINAL_ANNOTATIONS_CREATED,SKIPPED:"+f.getName()); + + + } catch (Exception e) { + System.err.println("ERROR:UNKNOWN:" + f.getName()); + e.printStackTrace(); + } + } + server.close(); + System.exit(0); + } + + protected String tryWebSearch(String wikiTitle) throws Exception { + wikiTitle = wikiTitle.replaceAll("[^a-zA-Z0-9]", " ").trim(); + if (wikiTitle.startsWith("/")) + wikiTitle = wikiTitle.substring(1).trim(); + String url = ""; + try { + Object o = solrCache.retrieve("websearch_" + wikiTitle); + if (o != null) + url = o.toString(); + } catch (Exception e) { + } + + if (url.equals("")) { + List docs = parser.parse(searcher.search(wikiTitle + " wikipedia")); + for (WebSearchResultDoc d : docs) { + String title = d.getTitle().replaceAll("[^a-zA-Z0-9]", " ").trim(); + if (d.getUrl().indexOf("wikipedia.org/wiki") == -1) + continue; + if (title.startsWith(wikiTitle)) { + url = d.getUrl(); + break; + } + } + if (url.equals("")) { + int best = 0, bestindex = -1; + List wikiTitle_tokens = new ArrayList(); + for (String t : wikiTitle.split("\\s+")) { + t = t.trim(); + if (t.length() > 0) + wikiTitle_tokens.add(t); + } + for (int i = 0; i < docs.size(); i++) { + String candidateTitle = docs.get(i).getTitle().replaceAll("_", " ").trim(); + if (candidateTitle.indexOf("Wikipedia") == -1) + continue; + List candidate_tokens = new ArrayList(); + for (String t : candidateTitle.split("\\s+")) { + t = t.trim(); + if (t.length() > 0) { + candidate_tokens.add(t); + } + } + candidate_tokens.retainAll(wikiTitle_tokens); + if (candidate_tokens.size() > best) { + best = candidate_tokens.size(); + bestindex = i; + } + } + if (bestindex != -1) { + url = docs.get(bestindex).getUrl(); + } + } + + try { + solrCache.cache("websearch_" + wikiTitle, url, true); + } catch (SolrServerException e) { + e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } + } + + if (url.equals("")) + return null; //To change body of created methods use File | Settings | File Templates. + +/* int trimStart = url.lastIndexOf("/wiki/"); + if (trimStart != -1) { + url = url.substring(trimStart + 6); + }*/ + if (!url.contains("en.wikipedia")) + return null; + return fetchWikipediaWebpage(url); + } + + + //Communes_of_the_Haute-Vienne_department_a209.html_0.xml + protected static String parseToWikipediaTitle(String limaye_data_file_name) { + limaye_data_file_name = limaye_data_file_name.replaceAll("\\\\", "/"); + int dot_html = limaye_data_file_name.indexOf(".htm"); + if (dot_html == -1) + return null; + int begin = limaye_data_file_name.lastIndexOf("/"); + begin = begin == -1 ? 0 : begin + 1; + limaye_data_file_name = limaye_data_file_name.substring(begin, dot_html); + int arbitrary_id = limaye_data_file_name.lastIndexOf("_"); + arbitrary_id = arbitrary_id == -1 ? limaye_data_file_name.length() : arbitrary_id; + limaye_data_file_name = limaye_data_file_name.substring(0, arbitrary_id).trim(); + + if (limaye_data_file_name.indexOf("~") != -1) { + limaye_data_file_name = limaye_data_file_name.replaceAll("~", ":"); + } + return limaye_data_file_name; + } + + + protected static String fetchWikipediaWebpage(String wikipediaurl) throws IOException, URISyntaxException { + + URL u = new URL(wikipediaurl); + URLConnection uc = u.openConnection(); + BufferedReader in = new BufferedReader( + new InputStreamReader( + uc.getInputStream())); + + StringBuilder response = new StringBuilder(); + String inputLine; + + while ((inputLine = in.readLine()) != null) + response.append(inputLine); + + in.close(); + + String wikiPage = response.toString(); + + return wikiPage; + } + + + protected static String toString_LTable(Table table) { + StringBuilder sb = new StringBuilder(); + for (int j = 0; j < table.getNumCols(); j++) { + TColumnHeader header = table.getColumnHeader(j); + if (header == null || header.getHeaderText() == null || header.getHeaderText().equals(STIEnum.TABLE_HEADER_UNKNOWN)) + continue; + sb.append(header.getHeaderText()).append(" "); + } + for (int i = 0; i < table.getNumRows(); i++) { + for (int j = 0; j < table.getNumCols(); j++) { + TCell tcc = table.getContentCell(i, j); + if (tcc != null && tcc.getText() != null) { + sb.append(tcc.getText()).append(" "); + } + } + } + return sb.toString().trim(); + } + + + protected void saveAsLimaye(Table table, String outFile) throws TransformerException, ParserConfigurationException { + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); + + // root elements + Document doc = docBuilder.newDocument(); + Element rootElement = doc.createElement("entity"); + doc.appendChild(rootElement); + // logicaltable elements + Element logicalTable = doc.createElement("logicalTable"); + + //content element + Element content = doc.createElement("content"); + Element context = doc.createElement("tableContext"); + + //write header cells + Element headerElement = doc.createElement("header"); + for (int j = 0; j < table.getNumCols(); j++) { + Element he = doc.createElement("cell"); + String text = ""; + String wikilink = ""; + TColumnHeader h = table.getColumnHeader(j); + if (h != null && !h.getHeaderText().equals(STIEnum.TABLE_HEADER_UNKNOWN)) { + text = h.getHeaderText(); + } + Element textElement = doc.createElement("html"); + text = StringEscapeUtils.escapeHtml4(text); + text = text.replaceAll(" ", " ").trim(); + textElement.appendChild(doc.createTextNode(text)); + Element wikiElement = doc.createElement("wikipedia"); + wikiElement.appendChild(doc.createTextNode(wikilink)); + he.appendChild(textElement); + he.appendChild(wikiElement); + headerElement.appendChild(he); + } + content.appendChild(headerElement); + + //write table cells + + for (int r = 0; r < table.getNumRows(); r++) { + Element rowElement = doc.createElement("row"); + for (int c = 0; c < table.getNumCols(); c++) { + Element cell = doc.createElement("cell"); + String text = ""; + String wikilink = ""; + TCell tcc = table.getContentCell(r, c); + if (tcc != null && tcc.getText() != null) { + text = tcc.getText(); + } + //table.getTableAnnotations().getContentCellAnnotations(r, c); + + TCellAnnotation[] annotations = table.getTableAnnotations().getContentCellAnnotations(r, c); + if (annotations != null && annotations.length > 0) { + TCellAnnotation ca = annotations[0]; + wikilink = ca.getAnnotation().getId(); + if (wikilink.startsWith("/wiki/")) + wikilink = wikilink.substring(6).trim(); + } + + Element textElement = doc.createElement("html"); + text = StringEscapeUtils.escapeHtml4(text); + text = text.replaceAll(" ", " ").trim(); + textElement.appendChild(doc.createTextNode(text)); + Element wikiElement = doc.createElement("wikipedia"); + wikiElement.appendChild(doc.createTextNode(wikilink)); + cell.appendChild(textElement); + cell.appendChild(wikiElement); + rowElement.appendChild(cell); + } + content.appendChild(rowElement); + } + + + //write table contexts + for (TContext ltc : table.getContexts()) { + Element context_child = doc.createElement("context"); + Element context_score = doc.createElement("computeElementScores"); + context_score.appendChild(doc.createTextNode(String.valueOf(ltc.getImportanceScore()))); + Element context_text = doc.createElement("text"); + context_text.appendChild(doc.createTextNode(ltc.getText())); + context_child.appendChild(context_score); + context_child.appendChild(context_text); + context.appendChild(context_child); + } + + logicalTable.appendChild(content); + + logicalTable.appendChild(context); + rootElement.appendChild(logicalTable); + + // write the content into xml file + TransformerFactory transformerFactory = TransformerFactory.newInstance(); + Transformer transformer = transformerFactory.newTransformer(); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.setOutputProperty(OutputKeys.METHOD, "xml"); + transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); + DOMSource source = new DOMSource(doc); + StreamResult result = new StreamResult(new File(outFile)); + + // Output to console for testing + // StreamResult result = new StreamResult(System.out); + + transformer.transform(source, result); + } + + private boolean annotateTable(Table originalTable, String annotationFile, int maxRows) throws IOException, TransformerException, ParserConfigurationException { + //saveAsLimaye(table, rawFile); + TColumnFeatureGenerator.setColumnDataTypes(originalTable); + + StringBuilder annotation = new StringBuilder(); + + int totalAnnotations = 0; + for (int r = 0; r < originalTable.getNumRows(); r++) { + if (r >= maxRows) + break; + for (int c = 0; c < originalTable.getNumCols(); c++) { + DataTypeClassifier.DataType type = originalTable.getColumnHeader(c).getTypes().get(0).getType(); + if (type.equals(DataTypeClassifier.DataType.NUMBER) || type.equals(DataTypeClassifier.DataType.DATE) || + type.equals(DataTypeClassifier.DataType.ORDERED_NUMBER) || + type.equals(DataTypeClassifier.DataType.LONG_TEXT) || + type.equals(DataTypeClassifier.DataType.LONG_STRING)) + continue; + + System.out.println("\t\tr=" + r + ",c=" + c); + TCell tcc = originalTable.getContentCell(r, c); + if (tcc != null) { + TCellAnnotation[] annotations = originalTable.getTableAnnotations().getContentCellAnnotations(r, c); + String wikiTitle = ""; + if (annotations != null && annotations.length > 0) { + TCellAnnotation ca = annotations[0]; + wikiTitle = ca.getAnnotation().getId(); + if (wikiTitle.startsWith("/wiki/")) { + wikiTitle = wikiTitle.substring(6).trim(); + totalAnnotations++; + } + } + + if (wikiTitle.length() > 0) { + String pageid = queryWikipediaPageid(wikiTitle, solrCache); + if (pageid != null) { + String fb_id = createCellAnnotation(pageid, solrCache); + if (fb_id != null && fb_id.length() > 0) { + annotation.append(r + "," + c + "=").append(fb_id).append("\n"); + } + } + } + } + } + } + + //boolean output = false; + int count_original_annotations = 0; + if (originalTable.getTableAnnotations() != null) { + for (int r = 0; r < originalTable.getNumRows(); r++) { + for (int c = 0; c < originalTable.getNumCols(); c++) { + TCellAnnotation[] annotations = originalTable.getTableAnnotations().getContentCellAnnotations(r, c); + if (annotations != null && annotations.length > 0) + count_original_annotations++; + } + } + if (totalAnnotations >= count_original_annotations) { + //output = true; + } + } + //if (output) { + PrintWriter p = new PrintWriter(annotationFile); + p.println(annotation); + p.close(); + // } + return true; + } + + protected Table process_wikitable(Node tableNode, String tableId, String sourceId, TContext... contexts) { + Table table = xtractor.extractTable(tableNode, tableId, sourceId, contexts); + return table; + } + + private static String toString_Node(Node n) { + String text = ""; + if (n.hasChildNodes()) { + for (int i = 0; i < n.getChildNodes().getLength(); i++) { + Node child = n.getChildNodes().item(i); + text += toString_Node(child); + } + } else { + text = n.getTextContent() + " "; + } + return text; + } + + protected static double computeOverlap(String string1, String string2) { + List tokens1 = new ArrayList(Arrays.asList(string1.split("\\s+"))); + List tokens2 = new ArrayList(Arrays.asList(string2.split("\\s+"))); + + return CollectionUtils.computeFrequencyWeightedDice(tokens1, tokens2); + } + + protected static Node findMatchingTable(Table limaye_original_table, List candidates) { + double maxScore = 0.0; + Node theOne = null; + String table = toString_LTable(limaye_original_table); + for (Node n : candidates) { + String nodeContent = toString_Node(n); + double overlap = computeOverlap(table, nodeContent); + if (overlap > maxScore) { + maxScore = overlap; + theOne = n; + } + } + + int theOne_rows = 0; + int theOne_max_cols = 0; + if (theOne != null) { + List children = DomUtils.findAll(theOne, "//TR"); + if (children != null) + theOne_rows = children.size(); + for (Node n : children) { + { + if (n.getChildNodes().getLength() > theOne_max_cols) + theOne_max_cols = n.getChildNodes().getLength(); + } + } + } + + if (theOne == null || (maxScore < 1.0 && theOne_rows < limaye_original_table.getNumRows()) || + (theOne_max_cols == 1 && limaye_original_table.getNumCols() > 1)) { + System.err.println("(candidate table too small, likely to be incorrect so skipped)"); + return null; + } + return theOne; + } + + protected static List extractWikiTables(String wikiPageContentString, String documentURI) { + List tableNodes = new ArrayList(); + TagSoupParser parser = new TagSoupParser(IOUtils.toInputStream(wikiPageContentString), documentURI, "UTF-8"); + Document doc = null; + try { + doc = parser.getDOM(); + } catch (IOException e) { + return tableNodes; + } + + int tableCount = 0; + List tables = DomUtils.findAll(doc, /*"//TABLE[@class='wikitable']"*/"//TABLE"); + if (tables.size() > 0) + tableNodes.addAll(tables); + /* if (tables.size() > 0) + tableNodes.addAll(tables);*/ + + return tableNodes; + } + + public static String queryWikipediaPageid(String wikipedia_title, SolrCache cache) throws IOException { + Date startTime = new Date(); + + String query = "https://en.wikipedia.org/w/api.php?action=query&titles=" + wikipedia_title; + String pageid = null; + try { + Object o = cache.retrieve(query); + if (o == null) { + pageid = null; + } else + pageid = o.toString(); + } catch (Exception e) { + e.printStackTrace(); + } + + if (pageid == null) { + URL u = new URL(query); + URLConnection connection = u.openConnection(); + BufferedReader in = new BufferedReader( + new InputStreamReader( + connection.getInputStream())); + + StringBuilder response = new StringBuilder(); + String inputLine; + + while ((inputLine = in.readLine()) != null) + response.append(inputLine); + + in.close(); + + String result = response.toString(); + + int start = result.indexOf("page pageid="); + if (start != -1) { + String pageIdLine = result.substring(start); + int firstQuote = pageIdLine.indexOf("""); + if (firstQuote != -1) { + pageIdLine = pageIdLine.substring(firstQuote + 6); + int secondQuote = pageIdLine.indexOf("""); + if (secondQuote != -1) { + pageIdLine = pageIdLine.substring(0, secondQuote).trim(); + try { + pageid = String.valueOf(Long.valueOf(pageIdLine)); + } catch (Exception e) { + pageid = ""; + } + } + } + } + + if (pageid != null) { + try { + cache.cache(query, pageid, true); + } catch (SolrServerException e) { + e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } + } + + } + + Date endTime = new Date(); + log.info("queryWikipedia:" + (endTime.getTime() - startTime.getTime())); + + if (pageid != null && pageid.length() > 0) + return pageid; + return null; + + + } + + public String createCellAnnotation(String pageid, SolrCache cache) throws IOException { + String freebase_id = null; + try { + Object o = cache.retrieve(pageid); + if (o != null) { + freebase_id = o.toString(); + } + } catch (SolrServerException e) { + e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } catch (ClassNotFoundException e) { + e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } + + if (freebase_id == null) { + + List list = queryHelper.mqlapi_topic_mids_with_wikipedia_pageid(pageid); + if (list == null || list.size() == 0) + freebase_id = ""; + else { + freebase_id = list.get(0); + } + try { + cache.cache(pageid, freebase_id, true); + } catch (SolrServerException e) { + e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } + } + + if (freebase_id == null) + return null; + + + if (freebase_id.equals("")) + return null; + else { + return freebase_id; + } + } + + + public static void find_missed_files(String inLogFile, String outListFile) throws IOException { + + + PrintWriter p = new PrintWriter(outListFile); + for (String l : FileUtils.readList(inLogFile, false)) { + if (l.startsWith("ERROR:")) { + int start = l.indexOf(":"); + l = l.substring(start + 1).trim(); + p.println(l); + } + } + p.close(); + + } + + public static void find_missed_files_by_folder(String inFolder_with_annotations, String inFolder_raw, String out_missed_file) throws IOException { + + PrintWriter p = new PrintWriter(out_missed_file); + List annotated = new ArrayList(); + for (File f : new File(inFolder_with_annotations).listFiles()) { + annotated.add(f.getName()); + } + + for (File f : new File(inFolder_raw).listFiles()) { + if (annotated.contains(f.getName() + ".cell.keys")) + continue; + else + p.println(f.getName()); + } + + p.close(); + } + + public static Map> extractLinksFromWikipediaPage(String content, String documentURI) { + TagSoupParser parser = new TagSoupParser(IOUtils.toInputStream(content), documentURI, "UTF-8"); + Document doc = null; + try { + doc = parser.getDOM(); + } catch (IOException e) { + return null; + } + + int tableCount = 0; + List links = DomUtils.findAll(doc, /*"//TABLE[@class='wikitable']"*/"//A"); + Map> linkMap = new HashMap>(); + for (Node n : links) { + String text = n.getTextContent(); + if (text.trim().length() < 1) + continue; + String link = ""; + try { + link = n.getAttributes().getNamedItem("href").getTextContent(); + } catch (Exception e) { + } + if (text != null && text.length() > 0 && link.length() > 0) { + Set theLinks = linkMap.get(text); + theLinks = theLinks == null ? new HashSet() : theLinks; + theLinks.add(link); + linkMap.put(text, theLinks); + } + + } + + return linkMap; + } + + private boolean annotateTable_fuzzy(Table originalTable, Map> linkMap, String annotationFile + ) throws IOException, TransformerException, ParserConfigurationException { + //saveAsLimaye(table, rawFile); + TColumnFeatureGenerator.setColumnDataTypes(originalTable); + int count_original_annotations = 0; + if (originalTable.getTableAnnotations() != null) { + for (int r = 0; r < originalTable.getNumRows(); r++) { + for (int c = 0; c < originalTable.getNumCols(); c++) { + TCellAnnotation[] annotations = originalTable.getTableAnnotations().getContentCellAnnotations(r, c); + if (annotations != null && annotations.length > 0) { + count_original_annotations++; + originalTable.getTableAnnotations().setContentCellAnnotations(r, c,new TCellAnnotation[0]); + } + } + } + } + + + StringBuilder annotation = new StringBuilder(); + int totalAnnotations = 0; + for (int r = 0; r < originalTable.getNumRows(); r++) { + for (int c = 0; c < originalTable.getNumCols(); c++) { + DataTypeClassifier.DataType type = originalTable.getColumnHeader(c).getTypes().get(0).getType(); + if (type.equals(DataTypeClassifier.DataType.NUMBER) || type.equals(DataTypeClassifier.DataType.DATE) || + type.equals(DataTypeClassifier.DataType.ORDERED_NUMBER) || + type.equals(DataTypeClassifier.DataType.LONG_TEXT) || + type.equals(DataTypeClassifier.DataType.LONG_STRING)) + continue; + + System.out.println("\t\tr=" + r + ",c=" + c); + TCell tcc = originalTable.getContentCell(r, c); + if (tcc != null) { + String text = tcc.getText().trim(); + Set links = linkMap.get(text); + String wikiTitle = ""; + if (links != null && links.size() == 1) { + wikiTitle = links.iterator().next(); + if (wikiTitle.startsWith("/wiki/")) { + wikiTitle = wikiTitle.substring(6).trim(); + totalAnnotations++; + } + } + + if (wikiTitle.length() > 0) { + String pageid = queryWikipediaPageid(wikiTitle, solrCache); + if (pageid != null) { + String fb_id = createCellAnnotation(pageid, solrCache); + if (fb_id != null && fb_id.length() > 0) { + annotation.append(r + "," + c + "=").append(fb_id).append("\n"); + } + TCellAnnotation ca = + new TCellAnnotation(tcc.getText(), new Entity(wikiTitle, wikiTitle), 1.0, new HashMap()); + originalTable.getTableAnnotations().setContentCellAnnotations( + r, c, new TCellAnnotation[]{ca} + ); + } + } + } + } + } + + boolean output = false; + //System.err.println(totalAnnotations+","+count_original_annotations); + if (totalAnnotations >= count_original_annotations) + output = true; + + if (output) { + PrintWriter p = new PrintWriter(annotationFile); + p.println(annotation); + p.close(); + } + return output; + } + + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_consolidate.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_consolidate.java index 43c115ab..27accd9b 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_consolidate.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_consolidate.java @@ -1,112 +1,112 @@ -package uk.ac.shef.dcs.sti.todo.gs; - -import info.aduna.io.FileUtil; -import uk.ac.shef.dcs.sti.util.FileUtils; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * Created with IntelliJ IDEA. - * User: zqz - * Date: 15/03/14 - * Time: 10:32 - * To change this template use File | Settings | File Templates. - */ -public class GSBuilder_Limaye_Wikitables_consolidate { - - public static void main(String[] args) throws IOException { - sort_error_by_types("E:\\Data\\table_annotation\\limaye/limaye_regen_log.txt"); - //create_missed_file_tilt("E:\\Data\\table_annotation\\limaye/limaye_regen_log.txt"); - } - - public static void create_missed_file_tilt(String logFile) throws IOException { - for (String l : FileUtils.readList(logFile, false)) { - if (l.contains("~")&&l.startsWith("ERROR")) { - String[] parts = processLogLine(l); - String file = parts[1].replaceAll("~",":"); - String url = file; - int trim =url.indexOf(".htm"); - url=url.substring(0,trim).trim(); - trim=url.lastIndexOf("_"); - url = url.substring(0, trim).trim(); - System.out.println(file+"\t\t\t"+url); - } - } - - } - - public static void sort_error_by_types(String logFile) throws IOException { - - List errors = new ArrayList(); - for (String l : FileUtils.readList(logFile, false)) { - if(l.contains("~")&&l.startsWith("ERROR")) - continue; - String[] parts = processLogLine(l); - if (parts == null){ - if (l.contains("WARN")) { - errors.add(l); - continue; - } - else - continue; - } - if (parts.length != 2) { - if (l.contains("WARN")) { - errors.add(l.trim()); - continue; - } else { - System.err.println(l); - continue; - } - } - - errors.add("ERROR:"+parts[0] + ":" + parts[1]); - } - - Collections.sort(errors); - for (String l : errors) - System.out.println(l); - } - - public static void copy_missed_files(String logFile, - String inFolder_original_raw, - String outFolder_new_raw, - String inFolder_original_gs, - String outFolder_new_gs) throws IOException { - - - for (String l : FileUtils.readList(logFile, false)) { - String[] parts = processLogLine(l); - if (parts != null) { - String file = parts[1].trim(); - File original_raw = new File(inFolder_original_raw + "/" + file); - if (!original_raw.exists()) { - System.err.println("raw file does not exist:" + original_raw); - continue; - } - File original_gs = new File(inFolder_original_gs + "/" + file); - if (!original_gs.exists()) { - System.err.println("gs file does not exist:" + original_gs); - continue; - } - - FileUtil.copyFile(original_raw, new File(outFolder_new_raw + "/" + file)); - FileUtil.copyFile(original_gs, new File(outFolder_new_gs + "/" + file)); - } - } - } - - public static String[] processLogLine(String line) { - if (line.startsWith("ERROR:")) { - line = line.substring(6).trim(); - String[] parts = line.split(":", 2); - if (parts.length == 2) - return parts; - } - return null; - } -} +package uk.ac.shef.dcs.sti.todo.gs; + +import info.aduna.io.FileUtil; +import uk.ac.shef.dcs.sti.util.FileUtils; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * Created with IntelliJ IDEA. + * User: zqz + * Date: 15/03/14 + * Time: 10:32 + * To change this template use File | Settings | File Templates. + */ +public class GSBuilder_Limaye_Wikitables_consolidate { + + public static void main(String[] args) throws IOException { + sort_error_by_types("E:\\Data\\table_annotation\\limaye/limaye_regen_log.txt"); + //create_missed_file_tilt("E:\\Data\\table_annotation\\limaye/limaye_regen_log.txt"); + } + + public static void create_missed_file_tilt(String logFile) throws IOException { + for (String l : FileUtils.readList(logFile, false)) { + if (l.contains("~")&&l.startsWith("ERROR")) { + String[] parts = processLogLine(l); + String file = parts[1].replaceAll("~",":"); + String url = file; + int trim =url.indexOf(".htm"); + url=url.substring(0,trim).trim(); + trim=url.lastIndexOf("_"); + url = url.substring(0, trim).trim(); + System.out.println(file+"\t\t\t"+url); + } + } + + } + + public static void sort_error_by_types(String logFile) throws IOException { + + List errors = new ArrayList(); + for (String l : FileUtils.readList(logFile, false)) { + if(l.contains("~")&&l.startsWith("ERROR")) + continue; + String[] parts = processLogLine(l); + if (parts == null){ + if (l.contains("WARN")) { + errors.add(l); + continue; + } + else + continue; + } + if (parts.length != 2) { + if (l.contains("WARN")) { + errors.add(l.trim()); + continue; + } else { + System.err.println(l); + continue; + } + } + + errors.add("ERROR:"+parts[0] + ":" + parts[1]); + } + + Collections.sort(errors); + for (String l : errors) + System.out.println(l); + } + + public static void copy_missed_files(String logFile, + String inFolder_original_raw, + String outFolder_new_raw, + String inFolder_original_gs, + String outFolder_new_gs) throws IOException { + + + for (String l : FileUtils.readList(logFile, false)) { + String[] parts = processLogLine(l); + if (parts != null) { + String file = parts[1].trim(); + File original_raw = new File(inFolder_original_raw + "/" + file); + if (!original_raw.exists()) { + System.err.println("raw file does not exist:" + original_raw); + continue; + } + File original_gs = new File(inFolder_original_gs + "/" + file); + if (!original_gs.exists()) { + System.err.println("gs file does not exist:" + original_gs); + continue; + } + + FileUtil.copyFile(original_raw, new File(outFolder_new_raw + "/" + file)); + FileUtil.copyFile(original_gs, new File(outFolder_new_gs + "/" + file)); + } + } + } + + public static String[] processLogLine(String line) { + if (line.startsWith("ERROR:")) { + line = line.substring(6).trim(); + String[] parts = line.split(":", 2); + if (parts.length == 2) + return parts; + } + return null; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_with_Ref.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_with_Ref.java index ab32bad1..e29a8177 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_with_Ref.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_Limaye_Wikitables_with_Ref.java @@ -1,290 +1,290 @@ -package uk.ac.shef.dcs.sti.todo.gs; - -import org.apache.commons.lang3.StringUtils; -import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; -import org.simmetrics.StringMetric; -import org.simmetrics.metrics.Levenshtein; -import org.simmetrics.metrics.StringMetrics; -import org.w3c.dom.Node; -import org.xml.sax.SAXException; -import uk.ac.shef.dcs.kbsearch.freebase.FreebaseQueryProxy; -import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; -import uk.ac.shef.dcs.sti.core.subjectcol.TColumnFeatureGenerator; -import uk.ac.shef.dcs.sti.util.DataTypeClassifier; -import uk.ac.shef.dcs.sti.core.model.TContext; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.parser.table.TableParserLimayeDataset; -import uk.ac.shef.dcs.util.SolrCache; -import uk.ac.shef.dcs.sti.parser.table.validator.TableValidatorGeneric; -import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetectorByHTMLTag; -import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizerDiscardIrregularRows; -import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreatorWikipediaGS; -import uk.ac.shef.dcs.sti.parser.table.TableParserWikipedia; -import uk.ac.shef.dcs.sti.util.FileUtils; -import uk.ac.shef.dcs.websearch.WebSearchFactory; -import uk.ac.shef.dcs.websearch.bing.v2.BingSearchResultParser; - - -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.TransformerException; -import java.io.*; -import java.util.*; - -/** - * for each table in Limaye dataset, try to computeElementScores columns with corresponding tables in the most up-to-date wikipedia page table; - * then each cell is searched in the column, if a cell text matches a link text in any cell in the column, it is assigned the link - */ -public class GSBuilder_Limaye_Wikitables_with_Ref extends GSBuilder_Limaye_Wikitables { - private StringMetric stringSim = StringMetrics.levenshtein(); - - public GSBuilder_Limaye_Wikitables_with_Ref(FreebaseQueryProxy queryHelper, - SolrCache cache_solr, - TableParserWikipedia xtractor, - String propertyFile) { - this.queryHelper = queryHelper; - this.solrCache = cache_solr; - this.xtractor = xtractor; - try { - searcher = new WebSearchFactory().createInstance( - propertyFile); - } catch (Exception e) { - e.printStackTrace(); - } - parser = new BingSearchResultParser(); - } - - public static void main(String[] args) throws IOException, SAXException, ParserConfigurationException { -/* - find_missed_files_by_folder("E:\\Data\\table annotation\\limaye\\all_tables_freebase_groundtruth", - "E:\\Data\\table annotation\\limaye\\all_tables_groundtruth_xml_only", - "E:\\Data\\table annotation\\limaye/gs_limaye_empty.missed"); - System.exit(0);*/ - - /* find_missed_files("E:\\Data\\table annotation\\limaye/gs_limaye.e8031313", "E:\\Data\\table annotation\\limaye/gs_limaye.missed"); - System.exit(0);*/ - -//todo: this will not work! - FreebaseQueryProxy queryHelper =null; //= new FreebaseQueryProxy(args[2]); - String in_original_limaye_folder = args[0]; - String out_gs_folder = args[1]; - String solrCache = args[3]; - int startfrom = new Integer(args[4]); - Map missedFile = new HashMap(); - - if (args.length == 6) { - for (String l : FileUtils.readList(args[5], false)) { - String[] parts = l.split("\t\t\t"); - missedFile.put(parts[0].trim(), parts[1].trim()); - } - } - - //todo: this will not work. - /*File configFile = new File(solrCache + File.separator + "solr.xml"); - CoreContainer container = new CoreContainer(solrCache, - configFile);*/ - EmbeddedSolrServer server = null;// new EmbeddedSolrServer(container, "collection1"); - SolrCache cache = new SolrCache(server); - - TableParserWikipedia xtractor = new TableParserWikipedia(new TableNormalizerDiscardIrregularRows(true), - new TableHODetectorByHTMLTag(), - new TableObjCreatorWikipediaGS(false), - new TableValidatorGeneric()); - - GSBuilder_Limaye_Wikitables_with_Ref gsBuilder = new GSBuilder_Limaye_Wikitables_with_Ref(queryHelper, - cache, xtractor, - "nKegYOqCMXV0rjUHzKADJinbJ9NrkMyBMqm9h3X9vAo"); - - int count = 0; - File[] all = new File(in_original_limaye_folder).listFiles(); - List sorted = new ArrayList(Arrays.asList(all)); - Collections.sort(sorted); - System.out.println(all.length); - for (File f : sorted) { - try { - count++; - if (startfrom > count) - continue; - if (f.getName().startsWith("file")) { - System.err.println("ERROR:SKIPPED_NON_WIKI:" + f.getName()); - continue; - } - - System.out.println(count + "_" + f); - Table limaye_table = new TableParserLimayeDataset().extract(f.toString(), null).get(0); - - String wikiPage = null; - if (missedFile.size() > 0) { - for (String mf : missedFile.keySet()) { - if (f.toString().endsWith(mf)) { - wikiPage = fetchWikipediaWebpage(missedFile.get(mf)); - break; - } - } - if (wikiPage == null) - continue; //Éric Cantona - } else { //MUST REGEN GS FOR 112 TABLES!!! - //multiword - //what is corresponding wikipedia title - int dot_html = f.getName().indexOf(".htm"); - if (dot_html == -1) - dot_html = f.getName().length(); - String wikiTitle = f.getName().substring(0, dot_html); - - if (wikiTitle.indexOf("~") != -1) { - System.err.println("ERROR:~DETECTED:" + f.getName()); - continue; - } - - try { - wikiPage = fetchWikipediaWebpage(wikipediaURL + wikiTitle); - } catch (Exception e) { - wikiTitle = parseToWikipediaTitle(f.toString()); - try { - wikiPage = fetchWikipediaWebpage(wikipediaURL + wikiTitle); - } catch (Exception ee) { - } - } - if (wikiPage == null || wikiPage.length() == 0) { - wikiPage = gsBuilder.tryWebSearch(wikiTitle); - if (wikiPage == null) { - System.err.println("ERROR:NO_WIKIPAGE:" + f.getName()); - continue; - } - } - } - wikiPage = StringUtils.stripAccents(wikiPage); - - List candidates = extractWikiTables(wikiPage, f.toURI().toString()); - Node theOne = findMatchingTable(limaye_table, candidates); - if (theOne == null) { - System.err.println("ERROR:NO_TABLE:" + f.getName()); - continue; - } - Table wikitable = gsBuilder. - process_wikitable(theOne, f.toURI().toString(), f.toURI().toString(), limaye_table.getContexts().toArray(new TContext[0])); - if (wikitable == null) { - System.err.println("ERROR:IRREGULAR_TABLE:" + f.getName()); - continue; - } - - gsBuilder.annotateTable(wikitable, limaye_table, - out_gs_folder + "/" + f.getName() + ".cell.keys"); - gsBuilder.saveAsLimaye(wikitable, out_gs_folder + "/" + f.getName()); - - - } catch (Exception e) { - System.err.println("ERROR:UNKNOWN:" + f.getName()); - e.printStackTrace(); - } - } - server.close(); - System.exit(0); - } - - - private void annotateTable(Table wikitable, Table limaye_table, - String annotationFile) throws IOException, TransformerException, ParserConfigurationException { - //saveAsLimaye(table, rawFile); - StringBuilder annotation = new StringBuilder(); - TColumnFeatureGenerator.setColumnDataTypes(limaye_table); - - for (int c = 0; c < limaye_table.getNumCols(); c++) { - DataTypeClassifier.DataType type = limaye_table.getColumnHeader(c).getTypes().get(0).getType(); - if (type.equals(DataTypeClassifier.DataType.NUMBER) || type.equals(DataTypeClassifier.DataType.DATE) || - type.equals(DataTypeClassifier.DataType.ORDERED_NUMBER) || - type.equals(DataTypeClassifier.DataType.LONG_TEXT) || - type.equals(DataTypeClassifier.DataType.LONG_STRING)) - continue; - - //find matching column from wikitable - int matchedCol = findMatchingColumn(limaye_table, c, wikitable); - if (matchedCol == -1) { - System.err.println("\tERROR:no matching column=" + c + "," + limaye_table.getColumnHeader(c).getHeaderText()); - continue; - } - //annotate - for (int r = 0; r < limaye_table.getNumRows(); r++) { - String limaye_cell_text = limaye_table.getContentCell(r, c).getText(); - limaye_cell_text=StringUtils.stripAccents(limaye_cell_text); - - double bestScore = 0.0; - TCellAnnotation bestAnnotation = null; - for (int wr = 0; wr < wikitable.getNumRows(); wr++) { - TCellAnnotation[] annotations = wikitable.getTableAnnotations().getContentCellAnnotations(wr, matchedCol); - for (TCellAnnotation ca : annotations) { - double matched_score = stringSim.compare(limaye_cell_text, - ca.getTerm()); - if (matched_score > bestScore) { - bestScore = matched_score; - bestAnnotation = ca; - } - } - } - - if (bestScore > 0.9) { - if (bestScore != 1.0) { - System.out.println("\t\t\tNoPerfectMatch:" + limaye_cell_text + "(limaye)," + bestAnnotation.getTerm() + "(wiki)"); - } - - String wikiTitle = bestAnnotation.getAnnotation().getId(); - if (wikiTitle.startsWith("/wiki/")) - wikiTitle = wikiTitle.substring(6).trim(); - String pageid = queryWikipediaPageid(wikiTitle, solrCache); - if (pageid != null) { - String fb_id = createCellAnnotation(pageid, solrCache); - if (fb_id != null && fb_id.length() > 0) { - annotation.append(r + "," + c + "=").append(fb_id).append("\n"); - } - } - } - } - } - - PrintWriter p = new PrintWriter(annotationFile); - p.println(annotation); - p.close(); - } - - private int findMatchingColumn(Table limaye_table, int c, Table wikitable) { - double maxScore = 0.0; - int theOne = -1; - String column = toString_Column(limaye_table, c); - column=StringUtils.stripAccents(column); - for (int wc = 0; wc < wikitable.getNumCols(); wc++) { - String columnContent = toString_Column_Annotation(wikitable, wc); - double overlap = computeOverlap(column, columnContent); - if (overlap > maxScore) { - - maxScore = overlap; - theOne = wc; - } - } - - return theOne; - } - - - private String toString_Column(Table table, int c) { - String text = ""; - - for (int r = 0; r < table.getNumRows(); r++) { - TCell tcc = table.getContentCell(r, c); - text += tcc.getText() + " "; - } - return text; - } - - private String toString_Column_Annotation(Table table, int c) { - String text = ""; - - for (int r = 0; r < table.getNumRows(); r++) { - TCellAnnotation[] annotations = table.getTableAnnotations().getContentCellAnnotations(r, c); - for (TCellAnnotation ca : annotations) { - text += ca.getTerm() + " "; - } - } - return text; - } - -} +package uk.ac.shef.dcs.sti.todo.gs; + +import org.apache.commons.lang3.StringUtils; +import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; +import org.simmetrics.StringMetric; +import org.simmetrics.metrics.Levenshtein; +import org.simmetrics.metrics.StringMetrics; +import org.w3c.dom.Node; +import org.xml.sax.SAXException; +import uk.ac.shef.dcs.kbsearch.freebase.FreebaseQueryProxy; +import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; +import uk.ac.shef.dcs.sti.core.subjectcol.TColumnFeatureGenerator; +import uk.ac.shef.dcs.sti.util.DataTypeClassifier; +import uk.ac.shef.dcs.sti.core.model.TContext; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.core.model.TCell; +import uk.ac.shef.dcs.sti.parser.table.TableParserLimayeDataset; +import uk.ac.shef.dcs.util.SolrCache; +import uk.ac.shef.dcs.sti.parser.table.validator.TableValidatorGeneric; +import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetectorByHTMLTag; +import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizerDiscardIrregularRows; +import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreatorWikipediaGS; +import uk.ac.shef.dcs.sti.parser.table.TableParserWikipedia; +import uk.ac.shef.dcs.sti.util.FileUtils; +import uk.ac.shef.dcs.websearch.WebSearchFactory; +import uk.ac.shef.dcs.websearch.bing.v2.BingSearchResultParser; + + +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.TransformerException; +import java.io.*; +import java.util.*; + +/** + * for each table in Limaye dataset, try to computeElementScores columns with corresponding tables in the most up-to-date wikipedia page table; + * then each cell is searched in the column, if a cell text matches a link text in any cell in the column, it is assigned the link + */ +public class GSBuilder_Limaye_Wikitables_with_Ref extends GSBuilder_Limaye_Wikitables { + private StringMetric stringSim = StringMetrics.levenshtein(); + + public GSBuilder_Limaye_Wikitables_with_Ref(FreebaseQueryProxy queryHelper, + SolrCache cache_solr, + TableParserWikipedia xtractor, + String propertyFile) { + this.queryHelper = queryHelper; + this.solrCache = cache_solr; + this.xtractor = xtractor; + try { + searcher = new WebSearchFactory().createInstance( + propertyFile); + } catch (Exception e) { + e.printStackTrace(); + } + parser = new BingSearchResultParser(); + } + + public static void main(String[] args) throws IOException, SAXException, ParserConfigurationException { +/* + find_missed_files_by_folder("E:\\Data\\table annotation\\limaye\\all_tables_freebase_groundtruth", + "E:\\Data\\table annotation\\limaye\\all_tables_groundtruth_xml_only", + "E:\\Data\\table annotation\\limaye/gs_limaye_empty.missed"); + System.exit(0);*/ + + /* find_missed_files("E:\\Data\\table annotation\\limaye/gs_limaye.e8031313", "E:\\Data\\table annotation\\limaye/gs_limaye.missed"); + System.exit(0);*/ + +//todo: this will not work! + FreebaseQueryProxy queryHelper =null; //= new FreebaseQueryProxy(args[2]); + String in_original_limaye_folder = args[0]; + String out_gs_folder = args[1]; + String solrCache = args[3]; + int startfrom = new Integer(args[4]); + Map missedFile = new HashMap(); + + if (args.length == 6) { + for (String l : FileUtils.readList(args[5], false)) { + String[] parts = l.split("\t\t\t"); + missedFile.put(parts[0].trim(), parts[1].trim()); + } + } + + //todo: this will not work. + /*File configFile = new File(solrCache + File.separator + "solr.xml"); + CoreContainer container = new CoreContainer(solrCache, + configFile);*/ + EmbeddedSolrServer server = null;// new EmbeddedSolrServer(container, "collection1"); + SolrCache cache = new SolrCache(server); + + TableParserWikipedia xtractor = new TableParserWikipedia(new TableNormalizerDiscardIrregularRows(true), + new TableHODetectorByHTMLTag(), + new TableObjCreatorWikipediaGS(false), + new TableValidatorGeneric()); + + GSBuilder_Limaye_Wikitables_with_Ref gsBuilder = new GSBuilder_Limaye_Wikitables_with_Ref(queryHelper, + cache, xtractor, + "nKegYOqCMXV0rjUHzKADJinbJ9NrkMyBMqm9h3X9vAo"); + + int count = 0; + File[] all = new File(in_original_limaye_folder).listFiles(); + List sorted = new ArrayList(Arrays.asList(all)); + Collections.sort(sorted); + System.out.println(all.length); + for (File f : sorted) { + try { + count++; + if (startfrom > count) + continue; + if (f.getName().startsWith("file")) { + System.err.println("ERROR:SKIPPED_NON_WIKI:" + f.getName()); + continue; + } + + System.out.println(count + "_" + f); + Table limaye_table = new TableParserLimayeDataset().extract(f.toString(), null).get(0); + + String wikiPage = null; + if (missedFile.size() > 0) { + for (String mf : missedFile.keySet()) { + if (f.toString().endsWith(mf)) { + wikiPage = fetchWikipediaWebpage(missedFile.get(mf)); + break; + } + } + if (wikiPage == null) + continue; //Éric Cantona + } else { //MUST REGEN GS FOR 112 TABLES!!! + //multiword + //what is corresponding wikipedia title + int dot_html = f.getName().indexOf(".htm"); + if (dot_html == -1) + dot_html = f.getName().length(); + String wikiTitle = f.getName().substring(0, dot_html); + + if (wikiTitle.indexOf("~") != -1) { + System.err.println("ERROR:~DETECTED:" + f.getName()); + continue; + } + + try { + wikiPage = fetchWikipediaWebpage(wikipediaURL + wikiTitle); + } catch (Exception e) { + wikiTitle = parseToWikipediaTitle(f.toString()); + try { + wikiPage = fetchWikipediaWebpage(wikipediaURL + wikiTitle); + } catch (Exception ee) { + } + } + if (wikiPage == null || wikiPage.length() == 0) { + wikiPage = gsBuilder.tryWebSearch(wikiTitle); + if (wikiPage == null) { + System.err.println("ERROR:NO_WIKIPAGE:" + f.getName()); + continue; + } + } + } + wikiPage = StringUtils.stripAccents(wikiPage); + + List candidates = extractWikiTables(wikiPage, f.toURI().toString()); + Node theOne = findMatchingTable(limaye_table, candidates); + if (theOne == null) { + System.err.println("ERROR:NO_TABLE:" + f.getName()); + continue; + } + Table wikitable = gsBuilder. + process_wikitable(theOne, f.toURI().toString(), f.toURI().toString(), limaye_table.getContexts().toArray(new TContext[0])); + if (wikitable == null) { + System.err.println("ERROR:IRREGULAR_TABLE:" + f.getName()); + continue; + } + + gsBuilder.annotateTable(wikitable, limaye_table, + out_gs_folder + "/" + f.getName() + ".cell.keys"); + gsBuilder.saveAsLimaye(wikitable, out_gs_folder + "/" + f.getName()); + + + } catch (Exception e) { + System.err.println("ERROR:UNKNOWN:" + f.getName()); + e.printStackTrace(); + } + } + server.close(); + System.exit(0); + } + + + private void annotateTable(Table wikitable, Table limaye_table, + String annotationFile) throws IOException, TransformerException, ParserConfigurationException { + //saveAsLimaye(table, rawFile); + StringBuilder annotation = new StringBuilder(); + TColumnFeatureGenerator.setColumnDataTypes(limaye_table); + + for (int c = 0; c < limaye_table.getNumCols(); c++) { + DataTypeClassifier.DataType type = limaye_table.getColumnHeader(c).getTypes().get(0).getType(); + if (type.equals(DataTypeClassifier.DataType.NUMBER) || type.equals(DataTypeClassifier.DataType.DATE) || + type.equals(DataTypeClassifier.DataType.ORDERED_NUMBER) || + type.equals(DataTypeClassifier.DataType.LONG_TEXT) || + type.equals(DataTypeClassifier.DataType.LONG_STRING)) + continue; + + //find matching column from wikitable + int matchedCol = findMatchingColumn(limaye_table, c, wikitable); + if (matchedCol == -1) { + System.err.println("\tERROR:no matching column=" + c + "," + limaye_table.getColumnHeader(c).getHeaderText()); + continue; + } + //annotate + for (int r = 0; r < limaye_table.getNumRows(); r++) { + String limaye_cell_text = limaye_table.getContentCell(r, c).getText(); + limaye_cell_text=StringUtils.stripAccents(limaye_cell_text); + + double bestScore = 0.0; + TCellAnnotation bestAnnotation = null; + for (int wr = 0; wr < wikitable.getNumRows(); wr++) { + TCellAnnotation[] annotations = wikitable.getTableAnnotations().getContentCellAnnotations(wr, matchedCol); + for (TCellAnnotation ca : annotations) { + double matched_score = stringSim.compare(limaye_cell_text, + ca.getTerm()); + if (matched_score > bestScore) { + bestScore = matched_score; + bestAnnotation = ca; + } + } + } + + if (bestScore > 0.9) { + if (bestScore != 1.0) { + System.out.println("\t\t\tNoPerfectMatch:" + limaye_cell_text + "(limaye)," + bestAnnotation.getTerm() + "(wiki)"); + } + + String wikiTitle = bestAnnotation.getAnnotation().getId(); + if (wikiTitle.startsWith("/wiki/")) + wikiTitle = wikiTitle.substring(6).trim(); + String pageid = queryWikipediaPageid(wikiTitle, solrCache); + if (pageid != null) { + String fb_id = createCellAnnotation(pageid, solrCache); + if (fb_id != null && fb_id.length() > 0) { + annotation.append(r + "," + c + "=").append(fb_id).append("\n"); + } + } + } + } + } + + PrintWriter p = new PrintWriter(annotationFile); + p.println(annotation); + p.close(); + } + + private int findMatchingColumn(Table limaye_table, int c, Table wikitable) { + double maxScore = 0.0; + int theOne = -1; + String column = toString_Column(limaye_table, c); + column=StringUtils.stripAccents(column); + for (int wc = 0; wc < wikitable.getNumCols(); wc++) { + String columnContent = toString_Column_Annotation(wikitable, wc); + double overlap = computeOverlap(column, columnContent); + if (overlap > maxScore) { + + maxScore = overlap; + theOne = wc; + } + } + + return theOne; + } + + + private String toString_Column(Table table, int c) { + String text = ""; + + for (int r = 0; r < table.getNumRows(); r++) { + TCell tcc = table.getContentCell(r, c); + text += tcc.getText() + " "; + } + return text; + } + + private String toString_Column_Annotation(Table table, int c) { + String text = ""; + + for (int r = 0; r < table.getNumRows(); r++) { + TCellAnnotation[] annotations = table.getTableAnnotations().getContentCellAnnotations(r, c); + for (TCellAnnotation ca : annotations) { + text += ca.getTerm() + " "; + } + } + return text; + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_MusicBrainz.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_MusicBrainz.java index ea6e3dcf..418e9238 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_MusicBrainz.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSBuilder_MusicBrainz.java @@ -1,160 +1,160 @@ -package uk.ac.shef.dcs.sti.todo.gs; - -import org.apache.any23.util.FileUtils; -import uk.ac.shef.dcs.kbsearch.freebase.FreebaseQueryProxy; -import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; -import uk.ac.shef.dcs.sti.util.TripleGenerator; -import uk.ac.shef.dcs.sti.io.TAnnotationWriter; -import uk.ac.shef.dcs.sti.core.model.TCell; -import uk.ac.shef.dcs.sti.core.model.TAnnotation; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.parser.table.TableParserMusicBrainz; -import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetectorByHTMLTag; -import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizerSimple; -import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreatorMusicBrainz; -import uk.ac.shef.dcs.sti.parser.table.validator.TableValidatorGeneric; -import uk.ac.shef.dcs.kbsearch.freebase.FreebaseTopic; - -import java.io.*; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - */ -public class GSBuilder_MusicBrainz { - - public static void main(String[] args) throws IOException { - GSBuilder_MusicBrainz gsBuilder = new GSBuilder_MusicBrainz(); - //todo:this willn ot work - FreebaseQueryProxy queryHelper = null;//new FreebaseQueryProxy(args[2]); - TAnnotationWriter writer = new TAnnotationWriter(new TripleGenerator("http://www.musicbrainz.org", "http://dcs.shef.ac.uk")); - String inFolder = args[0]; - String outFolder = args[1]; - //read imdb page, create table object - - TableParserMusicBrainz xtractor = new TableParserMusicBrainz(new TableNormalizerSimple(), - new TableHODetectorByHTMLTag(), - new TableObjCreatorMusicBrainz(), - new TableValidatorGeneric()); - int count = 0; - File[] all = new File(inFolder).listFiles(); - System.out.println(all.length); - for (File f : all) { - - count++; - System.out.println(count); - String inFile = f.toString(); - try { - String fileContent = FileUtils.readFileContent(new File(inFile)); - List
tables = xtractor.extract(fileContent, inFile); - - if (tables.size() == 0) - continue; - - Table table = tables.get(0); - //gs annotator - System.out.println(f + ", with rows: " + table.getNumRows()); - TAnnotation annotations = gsBuilder.annotate(table, queryHelper); - if (annotations != null) { - int count_annotations = 0; - for (int row = 0; row < table.getNumRows(); row++) { - for (int col = 0; col < table.getNumCols(); col++) { - TCellAnnotation[] cas = annotations.getContentCellAnnotations(row, col); - if (cas != null && cas.length > 0) - count_annotations++; - } - } - - if (count_annotations > 0) { - gsBuilder.save(table, annotations, outFolder, writer); - } - } - } catch (Exception e) { - e.printStackTrace(); - PrintWriter missedWriter = null; - try { - missedWriter = new PrintWriter(new FileWriter("missed.csv", true)); - } catch (IOException e1) { - e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. - } - missedWriter.println(inFile); - missedWriter.close(); - } - - } - } - - public TAnnotation annotate(Table table, FreebaseQueryProxy queryHelper) throws IOException { - Map> cache_for_table = new HashMap>(); - - TAnnotation tableAnnotation = new TAnnotation(table.getNumRows(), table.getNumCols()); - for (int row = 0; row < table.getNumRows(); row++) { - for (int col = 0; col < table.getNumCols(); col++) { - /* if(col==1) - System.out.println();*/ - TCell ltc = table.getContentCell(row, col); - String text = ltc.getText(); - String url = ltc.getOtherText(); - - int start = -1, end = -1; - if (url != null) { - start = url.lastIndexOf("/"); - if (start == -1) - continue; - else - start = start + 1; - end = url.length(); - if (end == -1) - continue; - } - - if (start > -1 && end > -1) { - String music_brainz_id = ""; - try { - music_brainz_id = url.substring(start, end).trim(); - } catch (StringIndexOutOfBoundsException e) { - e.printStackTrace(); - System.out.println(); - } - - List list = cache_for_table.get(music_brainz_id); - if (list == null) { - list = queryHelper.searchapi_getTopicsByNameAndType(music_brainz_id, "any", false, 5); - if (list == null) - list = new ArrayList(); - cache_for_table.put(music_brainz_id, list); - } - if (list.size() == 0) - continue; - TCellAnnotation[] cas = new TCellAnnotation[1]; - cas[0] = new TCellAnnotation(text, list.get(0), 1.0, new HashMap()); - tableAnnotation.setContentCellAnnotations(row, col, cas); - } - } - } - return tableAnnotation; - } - - - public void save(Table table, TAnnotation annotations, String outFolder, TAnnotationWriter writer) throws FileNotFoundException { - String fileId = table.getSourceId(); - fileId = fileId.replaceAll("\\\\", "/"); - int trim = fileId.lastIndexOf("/"); - if (trim != -1) - fileId = fileId.substring(trim + 1).trim(); - writer.writeHTML(table, annotations, outFolder + File.separator + fileId); - String annotation_keys = outFolder + File.separator + fileId + ".keys"; - PrintWriter p = new PrintWriter(annotation_keys); - for (int row = 0; row < table.getNumRows(); row++) { - for (int col = 0; col < table.getNumCols(); col++) { - TCellAnnotation[] anns = annotations.getContentCellAnnotations(row, col); - if (anns != null && anns.length > 0) { - p.println(row + "," + col + "," + anns[0].getAnnotation().getId()); - } - } - } - p.close(); - } -} +package uk.ac.shef.dcs.sti.todo.gs; + +import org.apache.any23.util.FileUtils; +import uk.ac.shef.dcs.kbsearch.freebase.FreebaseQueryProxy; +import uk.ac.shef.dcs.sti.core.model.TCellAnnotation; +import uk.ac.shef.dcs.sti.util.TripleGenerator; +import uk.ac.shef.dcs.sti.io.TAnnotationWriter; +import uk.ac.shef.dcs.sti.core.model.TCell; +import uk.ac.shef.dcs.sti.core.model.TAnnotation; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.parser.table.TableParserMusicBrainz; +import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetectorByHTMLTag; +import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizerSimple; +import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreatorMusicBrainz; +import uk.ac.shef.dcs.sti.parser.table.validator.TableValidatorGeneric; +import uk.ac.shef.dcs.kbsearch.freebase.FreebaseTopic; + +import java.io.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + */ +public class GSBuilder_MusicBrainz { + + public static void main(String[] args) throws IOException { + GSBuilder_MusicBrainz gsBuilder = new GSBuilder_MusicBrainz(); + //todo:this willn ot work + FreebaseQueryProxy queryHelper = null;//new FreebaseQueryProxy(args[2]); + TAnnotationWriter writer = new TAnnotationWriter(new TripleGenerator("http://www.musicbrainz.org", "http://dcs.shef.ac.uk")); + String inFolder = args[0]; + String outFolder = args[1]; + //read imdb page, create table object + + TableParserMusicBrainz xtractor = new TableParserMusicBrainz(new TableNormalizerSimple(), + new TableHODetectorByHTMLTag(), + new TableObjCreatorMusicBrainz(), + new TableValidatorGeneric()); + int count = 0; + File[] all = new File(inFolder).listFiles(); + System.out.println(all.length); + for (File f : all) { + + count++; + System.out.println(count); + String inFile = f.toString(); + try { + String fileContent = FileUtils.readFileContent(new File(inFile)); + List
tables = xtractor.extract(fileContent, inFile); + + if (tables.size() == 0) + continue; + + Table table = tables.get(0); + //gs annotator + System.out.println(f + ", with rows: " + table.getNumRows()); + TAnnotation annotations = gsBuilder.annotate(table, queryHelper); + if (annotations != null) { + int count_annotations = 0; + for (int row = 0; row < table.getNumRows(); row++) { + for (int col = 0; col < table.getNumCols(); col++) { + TCellAnnotation[] cas = annotations.getContentCellAnnotations(row, col); + if (cas != null && cas.length > 0) + count_annotations++; + } + } + + if (count_annotations > 0) { + gsBuilder.save(table, annotations, outFolder, writer); + } + } + } catch (Exception e) { + e.printStackTrace(); + PrintWriter missedWriter = null; + try { + missedWriter = new PrintWriter(new FileWriter("missed.csv", true)); + } catch (IOException e1) { + e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } + missedWriter.println(inFile); + missedWriter.close(); + } + + } + } + + public TAnnotation annotate(Table table, FreebaseQueryProxy queryHelper) throws IOException { + Map> cache_for_table = new HashMap>(); + + TAnnotation tableAnnotation = new TAnnotation(table.getNumRows(), table.getNumCols()); + for (int row = 0; row < table.getNumRows(); row++) { + for (int col = 0; col < table.getNumCols(); col++) { + /* if(col==1) + System.out.println();*/ + TCell ltc = table.getContentCell(row, col); + String text = ltc.getText(); + String url = ltc.getOtherText(); + + int start = -1, end = -1; + if (url != null) { + start = url.lastIndexOf("/"); + if (start == -1) + continue; + else + start = start + 1; + end = url.length(); + if (end == -1) + continue; + } + + if (start > -1 && end > -1) { + String music_brainz_id = ""; + try { + music_brainz_id = url.substring(start, end).trim(); + } catch (StringIndexOutOfBoundsException e) { + e.printStackTrace(); + System.out.println(); + } + + List list = cache_for_table.get(music_brainz_id); + if (list == null) { + list = queryHelper.searchapi_getTopicsByNameAndType(music_brainz_id, "any", false, 5); + if (list == null) + list = new ArrayList(); + cache_for_table.put(music_brainz_id, list); + } + if (list.size() == 0) + continue; + TCellAnnotation[] cas = new TCellAnnotation[1]; + cas[0] = new TCellAnnotation(text, list.get(0), 1.0, new HashMap()); + tableAnnotation.setContentCellAnnotations(row, col, cas); + } + } + } + return tableAnnotation; + } + + + public void save(Table table, TAnnotation annotations, String outFolder, TAnnotationWriter writer) throws FileNotFoundException { + String fileId = table.getSourceId(); + fileId = fileId.replaceAll("\\\\", "/"); + int trim = fileId.lastIndexOf("/"); + if (trim != -1) + fileId = fileId.substring(trim + 1).trim(); + writer.writeHTML(table, annotations, outFolder + File.separator + fileId); + String annotation_keys = outFolder + File.separator + fileId + ".keys"; + PrintWriter p = new PrintWriter(annotation_keys); + for (int row = 0; row < table.getNumRows(); row++) { + for (int col = 0; col < table.getNumCols(); col++) { + TCellAnnotation[] anns = annotations.getContentCellAnnotations(row, col); + if (anns != null && anns.length > 0) { + p.println(row + "," + col + "," + anns[0].getAnnotation().getId()); + } + } + } + p.close(); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSFile_Rewriter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSFile_Rewriter.java index c4110f77..2d5fddb5 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSFile_Rewriter.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GSFile_Rewriter.java @@ -1,43 +1,43 @@ -package uk.ac.shef.dcs.sti.todo.gs; - -import uk.ac.shef.dcs.sti.util.FileUtils; - -import java.io.File; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.List; - -/** - * Created with IntelliJ IDEA. - */ -public class GSFile_Rewriter { - public static void main(String[] args) throws IOException { - //String inFolder= "E:\\Data\\table annotation\\freebase_crawl\\music_record_label\\musicbrainz_gs"; - //String outFolder= "E:\\Data\\table annotation\\freebase_crawl\\music_record_label\\musicbrainz_gs_reformatted"; - String inFolder= "E:\\Data\\table annotation\\freebase_crawl\\film_film\\imdb_gs"; - String outFolder= "E:\\Data\\table annotation\\freebase_crawl\\film_film\\imdb_gs_reformatted"; - - for(File f: new File(inFolder).listFiles()){ - if(!f.toString().endsWith("keys")) - continue; - String out = outFolder+File.separator+f.getName(); - PrintWriter p = new PrintWriter(out); - List lines = FileUtils.readList(f.toString(),false); - for(String l: lines){ - String[] parts = l.split(","); - if(parts.length<3) - System.err.println("wrong:"+l); - String pos = parts[0]+","+parts[1]+"="; - for(int i = 2; i lines = FileUtils.readList(f.toString(),false); + for(String l: lines){ + String[] parts = l.split(","); + if(parts.length<3) + System.err.println("wrong:"+l); + String pos = parts[0]+","+parts[1]+"="; + for(int i = 2; i sourcefolders = new ArrayList(); - /*sourcefolders.add("E:\\Data\\table_annotation\\limaye_sample\\88_tables_regen\\baseline\\baseline_nm+first(no_RI)"); - sourcefolders.add("E:\\Data\\table_annotation\\limaye_sample\\88_tables_regen\\tableminer\\tableminer_journal(no_RI,nm_changed)");*/ - - sourcefolders.add("E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\baseline\\baseline_sl(RI)"); - sourcefolders.add("E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\baseline\\baseline_nm+first(RI)"); - sourcefolders.add("E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\tableminer\\tm_dc_ri"); - - - Set files = new HashSet(); - for(String source: sourcefolders){ - for(File f: new File(source).listFiles()){ - if(f.toString().contains("header.keys")||f.toString().contains("relation.keys")) - files.add(f.getName()); - } - } - - - - for(String f: files){ - Map> candidates = new HashMap>(); - PrintWriter p = new PrintWriter("E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ri/"+f); - /* if(!f.contains("Aeropuertos")) - continue; -*/ - for(String source: sourcefolders){ - File found=null; - for(File sf: new File(source).listFiles()){ - if(sf.getName().equals(f)){ - found=sf; - break; - } - } - if(found!=null){ - update(found, candidates); - } - } - - List keys = new ArrayList(candidates.keySet()); - Collections.sort(keys); - for(String k: keys){ - List cands = candidates.get(k); - Collections.sort(cands); - String line = ""; - for(String c: cands){ - line=line+"|"+c; - } - line=line.trim(); - if(line.startsWith("|")) - line=line.substring(1); - p.println(k+"="+line); - } - p.close(); - } - } - - private static void update(File found, Map> candidates) throws IOException { - List lines = FileUtils.readList(found.toString(), false); - for(String l: lines){ - String[] parts = l.split("=",2); - String key = parts[0].trim(); - List cands = candidates.get(key); - cands=cands==null?new ArrayList():cands; - - String values = parts[1].trim(); - String[] value_entries = values.split("[\\|=\t+]"); - for(String v: value_entries){ - v=v.trim(); - if(v.length()>0&&!cands.contains(v)) - cands.add(v); - } - - candidates.put(key, cands); - } - } -} +package uk.ac.shef.dcs.sti.todo.gs; + +import uk.ac.shef.dcs.sti.util.FileUtils; + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.*; + +/** + */ +public class GS_Class_Relation_Consolidation_Helper { + public static void main(String[] args) throws IOException { + List sourcefolders = new ArrayList(); + /*sourcefolders.add("E:\\Data\\table_annotation\\limaye_sample\\88_tables_regen\\baseline\\baseline_nm+first(no_RI)"); + sourcefolders.add("E:\\Data\\table_annotation\\limaye_sample\\88_tables_regen\\tableminer\\tableminer_journal(no_RI,nm_changed)");*/ + + sourcefolders.add("E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\baseline\\baseline_sl(RI)"); + sourcefolders.add("E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\baseline\\baseline_nm+first(RI)"); + sourcefolders.add("E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\tableminer\\tm_dc_ri"); + + + Set files = new HashSet(); + for(String source: sourcefolders){ + for(File f: new File(source).listFiles()){ + if(f.toString().contains("header.keys")||f.toString().contains("relation.keys")) + files.add(f.getName()); + } + } + + + + for(String f: files){ + Map> candidates = new HashMap>(); + PrintWriter p = new PrintWriter("E:\\Data\\table_annotation\\limaye_sample\\200_tables_regen\\gs\\header_ri/"+f); + /* if(!f.contains("Aeropuertos")) + continue; +*/ + for(String source: sourcefolders){ + File found=null; + for(File sf: new File(source).listFiles()){ + if(sf.getName().equals(f)){ + found=sf; + break; + } + } + if(found!=null){ + update(found, candidates); + } + } + + List keys = new ArrayList(candidates.keySet()); + Collections.sort(keys); + for(String k: keys){ + List cands = candidates.get(k); + Collections.sort(cands); + String line = ""; + for(String c: cands){ + line=line+"|"+c; + } + line=line.trim(); + if(line.startsWith("|")) + line=line.substring(1); + p.println(k+"="+line); + } + p.close(); + } + } + + private static void update(File found, Map> candidates) throws IOException { + List lines = FileUtils.readList(found.toString(), false); + for(String l: lines){ + String[] parts = l.split("=",2); + String key = parts[0].trim(); + List cands = candidates.get(key); + cands=cands==null?new ArrayList():cands; + + String values = parts[1].trim(); + String[] value_entries = values.split("[\\|=\t+]"); + for(String v: value_entries){ + v=v.trim(); + if(v.length()>0&&!cands.contains(v)) + cands.add(v); + } + + candidates.put(key, cands); + } + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Stats_Limaye.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Stats_Limaye.java index 6b90b5c5..dcd59394 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Stats_Limaye.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/GS_Stats_Limaye.java @@ -1,211 +1,211 @@ -package uk.ac.shef.dcs.sti.todo.gs; - -import org.apache.any23.extractor.html.DomUtils; -import org.apache.any23.util.FileUtils; -import org.apache.commons.io.filefilter.SuffixFileFilter; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; -import uk.ac.shef.dcs.kbsearch.model.Clazz; -import uk.ac.shef.dcs.sti.STIEnum; -import uk.ac.shef.dcs.sti.core.model.*; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.List; - -/** - - */ -public class GS_Stats_Limaye { - - public static void main(String[] args) throws IOException, SAXException, ParserConfigurationException { - String cleanTableRepos = args[0]; - String annotationRepos = args[1].replaceAll("\\\\", "/"); - - File[] files = FileUtils.listFilesRecursively(new File(cleanTableRepos), new SuffixFileFilter(".xml")); - for (File clean : files) { - String path = clean.getAbsolutePath().replaceAll("\\\\", "/"); - String relative = path.substring(cleanTableRepos.length()); - - String annotated = annotationRepos + relative; - if (!(new File(annotated)).exists()) { - System.err.println("clean file for annotation does not exist: " + annotated); - continue; - } - - System.out.println(clean); - - readTable(clean.toString(), annotated.toString(),"E:\\Data\\table annotation\\workspace\\WWT_GroundTruth\\annotation/stats.csv"); - } - - /*Table table = readTable("E:\\data\\table annotation\\tablesForAnnotation\\wikitables\\c3\\r12\\y\\e\\l/Yellowknife.html_0.xml", - "E:\\data\\table annotation\\workspace\\WWT_GroundTruth\\annotation\\wikitables\\c3\\r12\\y\\e\\l/Yellowknife.html_0.xml", - "D:\\work\\lodiedata\\limayetable");*/ - System.out.println(); - } - - public static Table readTable(String tableFilename, String tableAnnotationFilename, - String stats_file) throws IOException, ParserConfigurationException, SAXException { - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - - DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); - Document domCleanTable = docBuilder.parse(tableFilename); - - //read the table content - List tableContent = DomUtils.findAll(domCleanTable, "//logicalTable/content"); - if (tableContent == null || tableContent.size() == 0) - return null; - boolean firstRowHeader = false; - List rows = new ArrayList(); - NodeList rowNodes = tableContent.get(0).getChildNodes(); - - for (int i = 0; i < rowNodes.getLength(); i++) { - Node row = rowNodes.item(i); - if (row.getNodeName().equals("#text")) - continue; - if (row.getNodeName().equals("header")) { - firstRowHeader = true; - } - - List columns = DomUtils.findAll(row, "cell"); - String[] cells = new String[columns.size()]; - for (int j = 0; j < columns.size(); j++) { - Node cell = columns.get(j); - List text = DomUtils.findAll(cell, "text"); - String textContent = ""; - if (text != null && text.size() > 0) { - textContent = text.get(0).getTextContent(); - } - cells[j] = textContent; - } - rows.add(cells); - } - - int totalCol = 0; - for (String[] row : rows) { - if (row.length > totalCol) - totalCol = row.length; - } - - Table table = null; - int rowModifier = 0; - if (firstRowHeader) { - table = new Table(String.valueOf(tableFilename.hashCode()), tableFilename, rows.size() - 1, totalCol); - rowModifier = 1; - for (int j = 0; j < totalCol; j++) { - TColumnHeader header = new TColumnHeader(rows.get(0)[j]); - table.setColumnHeader(j, header); - } - } else {//no header, need to add false headers - table = new Table(String.valueOf(tableFilename.hashCode()), tableFilename, rows.size(), totalCol); - for (int j = 0; j < totalCol; j++) { - TColumnHeader header = new TColumnHeader(STIEnum.TABLE_HEADER_UNKNOWN.getValue()); - table.setColumnHeader(j, header); - } - } - - for (int r = rowModifier; r < rows.size(); r++) { - String[] cells = rows.get(r); - for (int c = 0; c < cells.length; c++) { - TCell cell = new TCell(cells[c]); - table.setContentCell(r - rowModifier, c, cell); - } - } - - - //read the table context - List tableContext = DomUtils.findAll(domCleanTable, "//logicalTable/tableContext"); - if (tableContext != null || tableContext.size() != 0) { - Node ctxParentNode = tableContext.get(0); - NodeList contexts = ctxParentNode.getChildNodes(); - for (int i = 0; i < contexts.getLength(); i++) { - - Node n = contexts.item(i); - if (n.getNodeName().equals("#text")) - continue; - List textNode = DomUtils.findAllByTag(n, "text"); - if (textNode != null && textNode.size() > 0) { - String context = textNode.get(0).getTextContent(); - if (context != null){ - TContext ctx=null; - if(i==1) - ctx=new TContext(context, TContext.TableContextType.PAGETITLE,1.0); - else ctx=new TContext(context, TContext.TableContextType.PARAGRAPH_BEFORE, 1.0); - - table.addContext(ctx); - } - } - } - } - if(table.getContexts().size()>1) - table.getContexts().remove(1); //always isValidAttribute the 2nd context as it is the header of the table - - //dump the original html snippet to a human readable html format - - if(tableAnnotationFilename==null) - return table; - - Document domAnnotatedTable = docBuilder.parse(tableAnnotationFilename); - - //read the header annotations - List headerAnnotations = DomUtils.findAll(domAnnotatedTable, "//columnAnnotations/colAnnos"); - String line=""; - line=String.valueOf(headerAnnotations.size())+","; - for (int i = 0; i < headerAnnotations.size(); i++) { - Node header = headerAnnotations.get(i); - int col = Integer.valueOf(header.getAttributes().getNamedItem("col").getTextContent()); - //TCell headerCell = table.getHeaderForColumn(col); - NodeList annotations = header.getChildNodes(); - List hAnnotations = new ArrayList(); - for (int j = 0; j < annotations.getLength(); j++) { - Node n = annotations.item(j); - if (n.getNodeName().equals("anno")) { - TColumnHeaderAnnotation a = new TColumnHeaderAnnotation(table.getColumnHeader(col).getHeaderText(), - new Clazz(n.getAttributes().getNamedItem("name").getTextContent(), - n.getAttributes().getNamedItem("name").getTextContent()), - Double.valueOf(n.getAttributes().getNamedItem("value").getTextContent().trim())); - - hAnnotations.add(a); - } - } - table.getTableAnnotations().setHeaderAnnotation(col, hAnnotations.toArray(new TColumnHeaderAnnotation[0])); - } - //read the data rows annotations - List dataRowAnnotations = DomUtils.findAll(domAnnotatedTable, "//cellAnnotatoons/row"); - int countCellAnnotations=0; - for (int i = 0; i < dataRowAnnotations.size(); i++) { - Node row = dataRowAnnotations.get(i); - List cols = DomUtils.findAll(row, "entity"); - for (int j = 0; j < cols.size(); j++) { - Node htmlCell = cols.get(j); - if (htmlCell.getTextContent() == null || htmlCell.getTextContent().length() == 0) { - continue; - } - /*TCellAnnotation cellAnnotation = new TCellAnnotation( - table.getContentCell(i + 1, j).getText(), new EntityCandidate(htmlCell.getTextContent(), htmlCell.getTextContent()), 1.0,new HashMap() - );*/ - - countCellAnnotations++; - /*table.getTableAnnotations().setContentCellAnnotations( - i + 1, j, new TCellAnnotation[]{cellAnnotation} - );*/ - } - } - - line=line+countCellAnnotations; - PrintWriter p =new PrintWriter(new FileWriter(stats_file,true)); - p.println(line); - p.close(); - - - return table; - } -} +package uk.ac.shef.dcs.sti.todo.gs; + +import org.apache.any23.extractor.html.DomUtils; +import org.apache.any23.util.FileUtils; +import org.apache.commons.io.filefilter.SuffixFileFilter; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; +import uk.ac.shef.dcs.kbsearch.model.Clazz; +import uk.ac.shef.dcs.sti.STIEnum; +import uk.ac.shef.dcs.sti.core.model.*; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.List; + +/** + + */ +public class GS_Stats_Limaye { + + public static void main(String[] args) throws IOException, SAXException, ParserConfigurationException { + String cleanTableRepos = args[0]; + String annotationRepos = args[1].replaceAll("\\\\", "/"); + + File[] files = FileUtils.listFilesRecursively(new File(cleanTableRepos), new SuffixFileFilter(".xml")); + for (File clean : files) { + String path = clean.getAbsolutePath().replaceAll("\\\\", "/"); + String relative = path.substring(cleanTableRepos.length()); + + String annotated = annotationRepos + relative; + if (!(new File(annotated)).exists()) { + System.err.println("clean file for annotation does not exist: " + annotated); + continue; + } + + System.out.println(clean); + + readTable(clean.toString(), annotated.toString(),"E:\\Data\\table annotation\\workspace\\WWT_GroundTruth\\annotation/stats.csv"); + } + + /*Table table = readTable("E:\\data\\table annotation\\tablesForAnnotation\\wikitables\\c3\\r12\\y\\e\\l/Yellowknife.html_0.xml", + "E:\\data\\table annotation\\workspace\\WWT_GroundTruth\\annotation\\wikitables\\c3\\r12\\y\\e\\l/Yellowknife.html_0.xml", + "D:\\work\\lodiedata\\limayetable");*/ + System.out.println(); + } + + public static Table readTable(String tableFilename, String tableAnnotationFilename, + String stats_file) throws IOException, ParserConfigurationException, SAXException { + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + + DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); + Document domCleanTable = docBuilder.parse(tableFilename); + + //read the table content + List tableContent = DomUtils.findAll(domCleanTable, "//logicalTable/content"); + if (tableContent == null || tableContent.size() == 0) + return null; + boolean firstRowHeader = false; + List rows = new ArrayList(); + NodeList rowNodes = tableContent.get(0).getChildNodes(); + + for (int i = 0; i < rowNodes.getLength(); i++) { + Node row = rowNodes.item(i); + if (row.getNodeName().equals("#text")) + continue; + if (row.getNodeName().equals("header")) { + firstRowHeader = true; + } + + List columns = DomUtils.findAll(row, "cell"); + String[] cells = new String[columns.size()]; + for (int j = 0; j < columns.size(); j++) { + Node cell = columns.get(j); + List text = DomUtils.findAll(cell, "text"); + String textContent = ""; + if (text != null && text.size() > 0) { + textContent = text.get(0).getTextContent(); + } + cells[j] = textContent; + } + rows.add(cells); + } + + int totalCol = 0; + for (String[] row : rows) { + if (row.length > totalCol) + totalCol = row.length; + } + + Table table = null; + int rowModifier = 0; + if (firstRowHeader) { + table = new Table(String.valueOf(tableFilename.hashCode()), tableFilename, rows.size() - 1, totalCol); + rowModifier = 1; + for (int j = 0; j < totalCol; j++) { + TColumnHeader header = new TColumnHeader(rows.get(0)[j]); + table.setColumnHeader(j, header); + } + } else {//no header, need to add false headers + table = new Table(String.valueOf(tableFilename.hashCode()), tableFilename, rows.size(), totalCol); + for (int j = 0; j < totalCol; j++) { + TColumnHeader header = new TColumnHeader(STIEnum.TABLE_HEADER_UNKNOWN.getValue()); + table.setColumnHeader(j, header); + } + } + + for (int r = rowModifier; r < rows.size(); r++) { + String[] cells = rows.get(r); + for (int c = 0; c < cells.length; c++) { + TCell cell = new TCell(cells[c]); + table.setContentCell(r - rowModifier, c, cell); + } + } + + + //read the table context + List tableContext = DomUtils.findAll(domCleanTable, "//logicalTable/tableContext"); + if (tableContext != null || tableContext.size() != 0) { + Node ctxParentNode = tableContext.get(0); + NodeList contexts = ctxParentNode.getChildNodes(); + for (int i = 0; i < contexts.getLength(); i++) { + + Node n = contexts.item(i); + if (n.getNodeName().equals("#text")) + continue; + List textNode = DomUtils.findAllByTag(n, "text"); + if (textNode != null && textNode.size() > 0) { + String context = textNode.get(0).getTextContent(); + if (context != null){ + TContext ctx=null; + if(i==1) + ctx=new TContext(context, TContext.TableContextType.PAGETITLE,1.0); + else ctx=new TContext(context, TContext.TableContextType.PARAGRAPH_BEFORE, 1.0); + + table.addContext(ctx); + } + } + } + } + if(table.getContexts().size()>1) + table.getContexts().remove(1); //always isValidAttribute the 2nd context as it is the header of the table + + //dump the original html snippet to a human readable html format + + if(tableAnnotationFilename==null) + return table; + + Document domAnnotatedTable = docBuilder.parse(tableAnnotationFilename); + + //read the header annotations + List headerAnnotations = DomUtils.findAll(domAnnotatedTable, "//columnAnnotations/colAnnos"); + String line=""; + line=String.valueOf(headerAnnotations.size())+","; + for (int i = 0; i < headerAnnotations.size(); i++) { + Node header = headerAnnotations.get(i); + int col = Integer.valueOf(header.getAttributes().getNamedItem("col").getTextContent()); + //TCell headerCell = table.getHeaderForColumn(col); + NodeList annotations = header.getChildNodes(); + List hAnnotations = new ArrayList(); + for (int j = 0; j < annotations.getLength(); j++) { + Node n = annotations.item(j); + if (n.getNodeName().equals("anno")) { + TColumnHeaderAnnotation a = new TColumnHeaderAnnotation(table.getColumnHeader(col).getHeaderText(), + new Clazz(n.getAttributes().getNamedItem("name").getTextContent(), + n.getAttributes().getNamedItem("name").getTextContent()), + Double.valueOf(n.getAttributes().getNamedItem("value").getTextContent().trim())); + + hAnnotations.add(a); + } + } + table.getTableAnnotations().setHeaderAnnotation(col, hAnnotations.toArray(new TColumnHeaderAnnotation[0])); + } + //read the data rows annotations + List dataRowAnnotations = DomUtils.findAll(domAnnotatedTable, "//cellAnnotatoons/row"); + int countCellAnnotations=0; + for (int i = 0; i < dataRowAnnotations.size(); i++) { + Node row = dataRowAnnotations.get(i); + List cols = DomUtils.findAll(row, "entity"); + for (int j = 0; j < cols.size(); j++) { + Node htmlCell = cols.get(j); + if (htmlCell.getTextContent() == null || htmlCell.getTextContent().length() == 0) { + continue; + } + /*TCellAnnotation cellAnnotation = new TCellAnnotation( + table.getContentCell(i + 1, j).getText(), new EntityCandidate(htmlCell.getTextContent(), htmlCell.getTextContent()), 1.0,new HashMap() + );*/ + + countCellAnnotations++; + /*table.getTableAnnotations().setContentCellAnnotations( + i + 1, j, new TCellAnnotation[]{cellAnnotation} + );*/ + } + } + + line=line+countCellAnnotations; + PrintWriter p =new PrintWriter(new FileWriter(stats_file,true)); + p.println(line); + p.close(); + + + return table; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass1.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass1.java index 8728557e..203c6a4d 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass1.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass1.java @@ -1,93 +1,93 @@ -package uk.ac.shef.dcs.sti.todo.gs; - -import info.bliki.wiki.dump.WikiXMLParser; -import org.xml.sax.SAXException; -import uk.ac.shef.dcs.sti.parser.list.splitter.ListItemSplitterByURL; -import uk.ac.shef.dcs.sti.parser.list.validator.ListVaildatorLanient; -import uk.ac.shef.dcs.sti.parser.list.ListXtractorWikipedia; -import uk.ac.shef.dcs.sti.parser.table.TableParserWikipedia; -import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreatorWikipediaGS; -import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetectorByHTMLTag; -import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizerDiscardIrregularRows; -import uk.ac.shef.dcs.sti.parser.table.validator.TableValidatorForWikipediaGSLanient; - -import java.io.FileInputStream; -import java.io.IOException; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 01/10/12 - * Time: 15:05 - * - * Pass1: - * -extracts tables, lists, filter them by "lanient" rules. These tables should be filtered a second time - * by pass2 - */ -public class WikipediaTL_GSCreator_Pass1 { - - - public static void parse(String inputWikib2zFile, String outputTableDir, String outputListDir) throws IOException, SAXException { - try(FileInputStream stream = new FileInputStream(inputWikib2zFile)) { - - WikiXMLParser parser = new WikiXMLParser(stream, - new WikipediaTableListPageFilter( - new TableParserWikipedia(new TableNormalizerDiscardIrregularRows(true), - new TableHODetectorByHTMLTag(), - new TableObjCreatorWikipediaGS(false), - new TableValidatorForWikipediaGSLanient()), - outputTableDir, - new ListXtractorWikipedia(new ListItemSplitterByURL(), - new ListVaildatorLanient()), - outputListDir - )); - - parser.parse(); - } - } - - - public static void main(String[] args) throws IOException, SAXException { - - /*TableXtractor xtractor=new TableXtractorHTML(new TableNormalizerFrequentRowLength(), - new TableHODetectorByHTMLTag(), - new TableObjCreatorWikipediaGS(new TableCellElementXtractorByURLnList()), - new TabValWikipediaGSLanient()); - URL url = new URL("http://staffwww.dcs.shef.ac.uk/people/Z.Zhang/resources/textrdfa_annotated_doc.html" - ); - - url.openStream(); - BufferedReader in = new BufferedReader(new InputStreamReader( - url.openStream())); - StringBuilder content = new StringBuilder(); - String inputLine; - while ((inputLine = in.readLine()) != null) { - content.append(inputLine); - } - in.close(); - - xtractor.extract(content.toString(),"this");*/ - /*DatabaseConfiguration dbConfig = new DatabaseConfiguration(); - dbConfig.setHost("localhost"); - dbConfig.setDatabase("wikipedia20120502"); - dbConfig.setUser("root"); - dbConfig.setPassword("RedShip"); - dbConfig.setLanguage(WikiConstants.Language.english); - Wikipedia wiki = new Wikipedia(dbConfig); - - Page p = wiki.getPage("China"); - - TableXtractorWikipedia xtractor = new TableXtractorWikipedia( - new TableNormalizerFrequentRowLength(), - new TableHODetectorByHTMLTag(), - new TableObjCreatorWikipediaGS() - ); - - List
tables = xtractor.extract(p.getText(), p.getTitle().getPlainTitle()); - - System.out.println(tables);*/ - - parse(args[0], args[1], args[2]); - - - } -} +package uk.ac.shef.dcs.sti.todo.gs; + +import info.bliki.wiki.dump.WikiXMLParser; +import org.xml.sax.SAXException; +import uk.ac.shef.dcs.sti.parser.list.splitter.ListItemSplitterByURL; +import uk.ac.shef.dcs.sti.parser.list.validator.ListVaildatorLanient; +import uk.ac.shef.dcs.sti.parser.list.ListXtractorWikipedia; +import uk.ac.shef.dcs.sti.parser.table.TableParserWikipedia; +import uk.ac.shef.dcs.sti.parser.table.creator.TableObjCreatorWikipediaGS; +import uk.ac.shef.dcs.sti.parser.table.hodetector.TableHODetectorByHTMLTag; +import uk.ac.shef.dcs.sti.parser.table.normalizer.TableNormalizerDiscardIrregularRows; +import uk.ac.shef.dcs.sti.parser.table.validator.TableValidatorForWikipediaGSLanient; + +import java.io.FileInputStream; +import java.io.IOException; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 01/10/12 + * Time: 15:05 + * + * Pass1: + * -extracts tables, lists, filter them by "lanient" rules. These tables should be filtered a second time + * by pass2 + */ +public class WikipediaTL_GSCreator_Pass1 { + + + public static void parse(String inputWikib2zFile, String outputTableDir, String outputListDir) throws IOException, SAXException { + try(FileInputStream stream = new FileInputStream(inputWikib2zFile)) { + + WikiXMLParser parser = new WikiXMLParser(stream, + new WikipediaTableListPageFilter( + new TableParserWikipedia(new TableNormalizerDiscardIrregularRows(true), + new TableHODetectorByHTMLTag(), + new TableObjCreatorWikipediaGS(false), + new TableValidatorForWikipediaGSLanient()), + outputTableDir, + new ListXtractorWikipedia(new ListItemSplitterByURL(), + new ListVaildatorLanient()), + outputListDir + )); + + parser.parse(); + } + } + + + public static void main(String[] args) throws IOException, SAXException { + + /*TableXtractor xtractor=new TableXtractorHTML(new TableNormalizerFrequentRowLength(), + new TableHODetectorByHTMLTag(), + new TableObjCreatorWikipediaGS(new TableCellElementXtractorByURLnList()), + new TabValWikipediaGSLanient()); + URL url = new URL("http://staffwww.dcs.shef.ac.uk/people/Z.Zhang/resources/textrdfa_annotated_doc.html" + ); + + url.openStream(); + BufferedReader in = new BufferedReader(new InputStreamReader( + url.openStream())); + StringBuilder content = new StringBuilder(); + String inputLine; + while ((inputLine = in.readLine()) != null) { + content.append(inputLine); + } + in.close(); + + xtractor.extract(content.toString(),"this");*/ + /*DatabaseConfiguration dbConfig = new DatabaseConfiguration(); + dbConfig.setHost("localhost"); + dbConfig.setDatabase("wikipedia20120502"); + dbConfig.setUser("root"); + dbConfig.setPassword("RedShip"); + dbConfig.setLanguage(WikiConstants.Language.english); + Wikipedia wiki = new Wikipedia(dbConfig); + + Page p = wiki.getPage("China"); + + TableXtractorWikipedia xtractor = new TableXtractorWikipedia( + new TableNormalizerFrequentRowLength(), + new TableHODetectorByHTMLTag(), + new TableObjCreatorWikipediaGS() + ); + + List
tables = xtractor.extract(p.getText(), p.getTitle().getPlainTitle()); + + System.out.println(tables);*/ + + parse(args[0], args[1], args[2]); + + + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass2.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass2.java index 7884a018..a05b1ca5 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass2.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTL_GSCreator_Pass2.java @@ -1,86 +1,86 @@ -package uk.ac.shef.dcs.sti.todo.gs; - -import uk.ac.shef.dcs.sti.core.model.List; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.parser.list.validator.ListValidator; -import uk.ac.shef.dcs.sti.parser.list.validator.ListValidatorStrict; -import uk.ac.shef.dcs.sti.parser.table.TableParser; -import uk.ac.shef.dcs.sti.parser.table.validator.TableValidatorForWikipediaGSStrict; -import uk.ac.shef.dcs.sti.parser.table.validator.TableValidator; -import uk.ac.shef.dcs.sti.parser.list.ListXtractor; - -import java.io.File; -import java.util.logging.Logger; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 10/10/12 - * Time: 11:08 - */ -public class WikipediaTL_GSCreator_Pass2 { - - private static Logger logger = Logger.getLogger(WikipediaTL_GSCreator_Pass2.class.getName()); - - public static void process(String tableOutPass1Dir, String tableOutFinalDir, String listOutPass1Dir, - String listOutFinalDir) { - int countTables = 0, countTableDirs = 0, countLists = 0, countListDirs = 0; - final int tablesPerDir = 5000; - final int listsPerDir = 5000; - - //WikipediaAPIHelper helper = new WikipediaAPIHelper(); - TableValidator tValidator = new TableValidatorForWikipediaGSStrict(); - - File[] sub = new File(tableOutPass1Dir).listFiles(); - for (File dir : sub) { - File[] files = dir.listFiles(); - for (File file : files) { - try { - Table table = TableParser.deserialize(file.getPath()); - if (tValidator.validate(table)) {//todo: if selected - TableParser.serialize(table, tableOutFinalDir + File.separator + countTableDirs); - countTables++; - if (countTables != 0 && countTables % tablesPerDir == 0) { - logger.info("Done " + countTables + " for tables"); - countTableDirs++; - } - } else - System.out.print("."); - - } catch (Exception e) { - logger.warning("Cannot deserialize object: " + file); - e.printStackTrace(); - } - } - } - - ListValidator lValidator = new ListValidatorStrict(); - - File[] subL = new File(listOutPass1Dir).listFiles(); - for (File dir : subL) { - File[] files = dir.listFiles(); - for (File file : files) { - try { - List list = ListXtractor.deserialize(file.getPath()); - if (lValidator.isValid(list)) {//todo: if selected - ListXtractor.serialize(list, listOutFinalDir + File.separator + countListDirs); - countLists++; - if (countLists != 0 && countLists % listsPerDir == 0) { - countListDirs++; - logger.info("Done " + countLists + " for lists"); - } - } else - System.out.print("."); - - } catch (Exception e) { - logger.warning("Cannot deserialize object: " + file); - e.printStackTrace(); - } - } - } - - } - - public static void main(String[] args) { - process(args[0], args[1], args[2], args[3]); - } -} +package uk.ac.shef.dcs.sti.todo.gs; + +import uk.ac.shef.dcs.sti.core.model.List; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.parser.list.validator.ListValidator; +import uk.ac.shef.dcs.sti.parser.list.validator.ListValidatorStrict; +import uk.ac.shef.dcs.sti.parser.table.TableParser; +import uk.ac.shef.dcs.sti.parser.table.validator.TableValidatorForWikipediaGSStrict; +import uk.ac.shef.dcs.sti.parser.table.validator.TableValidator; +import uk.ac.shef.dcs.sti.parser.list.ListXtractor; + +import java.io.File; +import java.util.logging.Logger; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 10/10/12 + * Time: 11:08 + */ +public class WikipediaTL_GSCreator_Pass2 { + + private static Logger logger = Logger.getLogger(WikipediaTL_GSCreator_Pass2.class.getName()); + + public static void process(String tableOutPass1Dir, String tableOutFinalDir, String listOutPass1Dir, + String listOutFinalDir) { + int countTables = 0, countTableDirs = 0, countLists = 0, countListDirs = 0; + final int tablesPerDir = 5000; + final int listsPerDir = 5000; + + //WikipediaAPIHelper helper = new WikipediaAPIHelper(); + TableValidator tValidator = new TableValidatorForWikipediaGSStrict(); + + File[] sub = new File(tableOutPass1Dir).listFiles(); + for (File dir : sub) { + File[] files = dir.listFiles(); + for (File file : files) { + try { + Table table = TableParser.deserialize(file.getPath()); + if (tValidator.validate(table)) {//todo: if selected + TableParser.serialize(table, tableOutFinalDir + File.separator + countTableDirs); + countTables++; + if (countTables != 0 && countTables % tablesPerDir == 0) { + logger.info("Done " + countTables + " for tables"); + countTableDirs++; + } + } else + System.out.print("."); + + } catch (Exception e) { + logger.warning("Cannot deserialize object: " + file); + e.printStackTrace(); + } + } + } + + ListValidator lValidator = new ListValidatorStrict(); + + File[] subL = new File(listOutPass1Dir).listFiles(); + for (File dir : subL) { + File[] files = dir.listFiles(); + for (File file : files) { + try { + List list = ListXtractor.deserialize(file.getPath()); + if (lValidator.isValid(list)) {//todo: if selected + ListXtractor.serialize(list, listOutFinalDir + File.separator + countListDirs); + countLists++; + if (countLists != 0 && countLists % listsPerDir == 0) { + countListDirs++; + logger.info("Done " + countLists + " for lists"); + } + } else + System.out.print("."); + + } catch (Exception e) { + logger.warning("Cannot deserialize object: " + file); + e.printStackTrace(); + } + } + } + + } + + public static void main(String[] args) { + process(args[0], args[1], args[2], args[3]); + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTableListPageFilter.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTableListPageFilter.java index 57dc7789..57164b8c 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTableListPageFilter.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/todo/gs/WikipediaTableListPageFilter.java @@ -1,100 +1,100 @@ -package uk.ac.shef.dcs.sti.todo.gs; - -import info.bliki.wiki.dump.IArticleFilter; -import info.bliki.wiki.dump.Siteinfo; -import info.bliki.wiki.dump.WikiArticle; -import org.xml.sax.SAXException; -import uk.ac.shef.dcs.sti.STIException; -import uk.ac.shef.dcs.sti.core.model.List; -import uk.ac.shef.dcs.sti.core.model.Table; -import uk.ac.shef.dcs.sti.parser.list.ListXtractor; -import uk.ac.shef.dcs.sti.parser.table.TableParser; - -import java.io.File; -import java.io.IOException; -import java.util.logging.Logger; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 09/10/12 - * Time: 09:59 - *

- * implements IArticleFilter of gwtwiki library to parse wikipedia dump articles that contain - * a "wikitable" or "* " (i.e., possible list) elements and store as objects on a file system - */ -public class WikipediaTableListPageFilter implements IArticleFilter { - - private TableParser tXtractor; - private String targetTableDir; - private ListXtractor lXtractor; - private String targetListDir; - - private int countMainPages; - private int countTables; - private int countLists; - - private int countTableDirs; - private int countListDirs; - private final int tablesPerDir = 5000; - private final int listsPerDir = 5000; - - private static Logger logger = Logger.getLogger(WikipediaTableListPageFilter.class.getName()); - - public WikipediaTableListPageFilter(TableParser tXtractor, String targetTableDir, - ListXtractor lXtractor, String targetListDir) { - this.tXtractor = tXtractor; - this.targetTableDir = targetTableDir; - this.lXtractor = lXtractor; - this.targetListDir = targetListDir; - - } - - @SuppressWarnings("unchecked") - @Override - public void process(WikiArticle page, Siteinfo siteinfo) throws IOException { - if (countMainPages % 200 == 0) { - logger.info("Pages processed: " + countMainPages + ", tables " + countTables + ", lists " + countLists); - } - - if (page.isMain()&&page.getText()!=null) { - countMainPages++; - String textLowerCase = page.getText().toLowerCase(); - if (textLowerCase.indexOf("wikitable") != -1) { //it likely contains tables or lists - java.util.List

tables = null; - try { - tables = tXtractor.extract(page.getText(), - page.getTitle() + "_" + page.getId()); - } catch (STIException e) { - e.printStackTrace(); - } - for (Table t : tables) { - try { - TableParser.serialize(t, targetTableDir + File.separator + countTableDirs); - countTables++; - } catch (IOException ioe) { - logger.warning("Serialization failed for table " + t.toString()); - } - - if (countTables != 0 && countTables % tablesPerDir == 0) - countTableDirs++; - } - } - if (textLowerCase.indexOf("* ") != -1) { - java.util.List lists = lXtractor.extract(page.getText(), - page.getTitle() + "_" + page.getId()); - - for (List l : lists) { - try { - ListXtractor.serialize(l, targetListDir + File.separator + countListDirs); - countLists++; - } catch (IOException ioe) { - logger.warning("Serialization failed for list " + l.toString()); - } - - if (countLists != 0 && countLists % listsPerDir == 0) - countListDirs++; - } - } - } - } -} +package uk.ac.shef.dcs.sti.todo.gs; + +import info.bliki.wiki.dump.IArticleFilter; +import info.bliki.wiki.dump.Siteinfo; +import info.bliki.wiki.dump.WikiArticle; +import org.xml.sax.SAXException; +import uk.ac.shef.dcs.sti.STIException; +import uk.ac.shef.dcs.sti.core.model.List; +import uk.ac.shef.dcs.sti.core.model.Table; +import uk.ac.shef.dcs.sti.parser.list.ListXtractor; +import uk.ac.shef.dcs.sti.parser.table.TableParser; + +import java.io.File; +import java.io.IOException; +import java.util.logging.Logger; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 09/10/12 + * Time: 09:59 + *

+ * implements IArticleFilter of gwtwiki library to parse wikipedia dump articles that contain + * a "wikitable" or "* " (i.e., possible list) elements and store as objects on a file system + */ +public class WikipediaTableListPageFilter implements IArticleFilter { + + private TableParser tXtractor; + private String targetTableDir; + private ListXtractor lXtractor; + private String targetListDir; + + private int countMainPages; + private int countTables; + private int countLists; + + private int countTableDirs; + private int countListDirs; + private final int tablesPerDir = 5000; + private final int listsPerDir = 5000; + + private static Logger logger = Logger.getLogger(WikipediaTableListPageFilter.class.getName()); + + public WikipediaTableListPageFilter(TableParser tXtractor, String targetTableDir, + ListXtractor lXtractor, String targetListDir) { + this.tXtractor = tXtractor; + this.targetTableDir = targetTableDir; + this.lXtractor = lXtractor; + this.targetListDir = targetListDir; + + } + + @SuppressWarnings("unchecked") + @Override + public void process(WikiArticle page, Siteinfo siteinfo) throws IOException { + if (countMainPages % 200 == 0) { + logger.info("Pages processed: " + countMainPages + ", tables " + countTables + ", lists " + countLists); + } + + if (page.isMain()&&page.getText()!=null) { + countMainPages++; + String textLowerCase = page.getText().toLowerCase(); + if (textLowerCase.indexOf("wikitable") != -1) { //it likely contains tables or lists + java.util.List

tables = null; + try { + tables = tXtractor.extract(page.getText(), + page.getTitle() + "_" + page.getId()); + } catch (STIException e) { + e.printStackTrace(); + } + for (Table t : tables) { + try { + TableParser.serialize(t, targetTableDir + File.separator + countTableDirs); + countTables++; + } catch (IOException ioe) { + logger.warning("Serialization failed for table " + t.toString()); + } + + if (countTables != 0 && countTables % tablesPerDir == 0) + countTableDirs++; + } + } + if (textLowerCase.indexOf("* ") != -1) { + java.util.List lists = lXtractor.extract(page.getText(), + page.getTitle() + "_" + page.getId()); + + for (List l : lists) { + try { + ListXtractor.serialize(l, targetListDir + File.separator + countListDirs); + countLists++; + } catch (IOException ioe) { + logger.warning("Serialization failed for list " + l.toString()); + } + + if (countLists != 0 && countLists % listsPerDir == 0) + countListDirs++; + } + } + } + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/CollectionUtils.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/CollectionUtils.java index 0fc33aef..2d53339d 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/CollectionUtils.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/CollectionUtils.java @@ -1,59 +1,59 @@ -package uk.ac.shef.dcs.sti.util; - -import javafx.util.Pair; - -import java.util.*; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 07/05/13 - * Time: 16:38 - */ -public class CollectionUtils { - - public static double computeDice(Collection c1, Collection c2) { - Set intersection = new HashSet<>(c1); - intersection.retainAll(c1); - intersection.retainAll(c2); - - if (intersection.size() == 0) - return 0.0; - double score = 2 * (double) intersection.size() / (c1.size() + c2.size()); - return score; - - } - - //entity //context - - /** - * how much of b does a cover - * @param a - * @param b - * @return - */ - public static double computeCoverage(Collection a, Collection b) { - List c = new ArrayList<>(b); - c.retainAll(a); - if(c.size()==0) - return 0.0; - double score = (double) c.size() / b.size(); - return score; - } - - public static double computeFrequencyWeightedDice(Collection c1, Collection c2) { - List union = new ArrayList<>(); - union.addAll(c1); - union.addAll(c2); - - List intersection = new ArrayList<>(union); - intersection.retainAll(c1); - intersection.retainAll(c2); - - if (intersection.size() == 0) - return 0.0; - double score = 2 * (double) intersection.size() / (c1.size() + c2.size()); - return score; - - } - -} +package uk.ac.shef.dcs.sti.util; + +import javafx.util.Pair; + +import java.util.*; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 07/05/13 + * Time: 16:38 + */ +public class CollectionUtils { + + public static double computeDice(Collection c1, Collection c2) { + Set intersection = new HashSet<>(c1); + intersection.retainAll(c1); + intersection.retainAll(c2); + + if (intersection.size() == 0) + return 0.0; + double score = 2 * (double) intersection.size() / (c1.size() + c2.size()); + return score; + + } + + //entity //context + + /** + * how much of b does a cover + * @param a + * @param b + * @return + */ + public static double computeCoverage(Collection a, Collection b) { + List c = new ArrayList<>(b); + c.retainAll(a); + if(c.size()==0) + return 0.0; + double score = (double) c.size() / b.size(); + return score; + } + + public static double computeFrequencyWeightedDice(Collection c1, Collection c2) { + List union = new ArrayList<>(); + union.addAll(c1); + union.addAll(c2); + + List intersection = new ArrayList<>(union); + intersection.retainAll(c1); + intersection.retainAll(c2); + + if (intersection.size() == 0) + return 0.0; + double score = 2 * (double) intersection.size() / (c1.size() + c2.size()); + return score; + + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/DataTypeClassifier.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/DataTypeClassifier.java index fca9d9b3..ff337be6 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/DataTypeClassifier.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/DataTypeClassifier.java @@ -1,226 +1,226 @@ -package uk.ac.shef.dcs.sti.util; - -import uk.ac.shef.dcs.util.StringUtils; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.regex.Pattern; - -/** - */ -public class DataTypeClassifier implements Serializable { - private static List MONTHS = new ArrayList( - Arrays.asList("january", "jan", - "february", "feb", - "march", "mar", - "april", "apr", - "may", - "june", "jun", - "july", "jul", - "august", "aug", - "september", "sep", - "october", "oct", - "november", "nov", - "december", "dec")); - private static Pattern[] DATES = new Pattern[]{ - /*german, / - no .*/ //Pattern.compile("^(?ni:(?=\\d)((?'year'((1[6-9])|([2-9]\\d))\\d\\d)(?'sep'[/.-])(?'month'0?[1-9]|1[012])\\2(?'day'((?((0?[1-9]|1[012])(:[0-5]\\d){0,2}(\\x20[AP]M))|([01]\\d|2[0-3])(:[0-5]\\d){1,2}))?)$"), //german - Pattern.compile("([0-9]{4})[\\.\\/\\-]([0-9]{1,2})[\\.\\/\\-]([0-9]{1,2})"), - /*uk, / - no .*/ Pattern.compile("^(?=\\d)(?:(?!(?:(?:0?[5-9]|1[0-4])(?:\\.|-|\\/)10(?:\\.|-|\\/)(?:1582))|(?:(?:0?[3-9]|1[0-3])(?:\\.|-|\\/)0?9(?:\\.|-|\\/)(?:1752)))(31(?!(?:\\.|-|\\/)(?:0?[2469]|11))|30(?!(?:\\.|-|\\/)0?2)|(?:29(?:(?!(?:\\.|-|\\/)0?2(?:\\.|-|\\/))|(?=\\D0?2\\D(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:(?:\\d\\d)(?:[02468][048]|[13579][26])(?!\\x20BC))|(?:00(?:42|3[0369]|2[147]|1[258]|09)\\x20BC))))))|2[0-8]|1\\d|0?[1-9])([-.\\/])(1[012]|(?:0?[1-9]))\\2((?=(?:00(?:4[0-5]|[0-3]?\\d)\\x20BC)|(?:\\d{4}(?:$|(?=\\x20\\d)\\x20)))\\d{4}(?:\\x20BC)?)(?:$|(?=\\x20\\d)\\x20))?((?:(?:0?[1-9]|1[012])(?::[0-5]\\d){0,2}(?:\\x20[aApP][mM]))|(?:[01]\\d|2[0-3])(?::[0-5]\\d){1,2})?$"), //uk - /*yy/.-mm/.-dd*/ Pattern.compile("^(?:(?:(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(\\/|-|\\.)(?:0?2\\1(?:29)))|(?:(?:(?:1[6-9]|[2-9]\\d)?\\d{2})(\\/|-|\\.)(?:(?:(?:0?[13578]|1[02])\\2(?:31))|(?:(?:0?[1,3-9]|1[0-2])\\2(29|30))|(?:(?:0?[1-9])|(?:1[0-2]))\\2(?:0?[1-9]|1\\d|2[0-8]))))$"), - /*29.2.04 | 29/02-2004 | 3.4.05*/ Pattern.compile("^(((0?[1-9]|[12]\\d|3[01])[\\.\\-\\/](0?[13578]|1[02])[\\.\\-\\/]((1[6-9]|[2-9]\\d)?\\d{2}))|((0?[1-9]|[12]\\d|30)[\\.\\-\\/](0?[13456789]|1[012])[\\.\\-\\/]((1[6-9]|[2-9]\\d)?\\d{2}))|((0?[1-9]|1\\d|2[0-8])[\\.\\-\\/]0?2[\\.\\-\\/]((1[6-9]|[2-9]\\d)?\\d{2}))|(29[\\.\\-\\/]0?2[\\.\\-\\/]((1[6-9]|[2-9]\\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00)))$"), - /*mm/dd/yyyy*/Pattern.compile("^([0]?[1-9]|[1][0-2])[./-]([0]?[1-9]|[1|2][0-9]|[3][0|1])[./-]([0-9]{4}|[0-9]{2})$") - }; - - - //a helper method to determine if an array of values are likely to be a series of ordered numbers - //input must be only alpha numeric characters - public static boolean isOrderedNumber(String... alphanumValues) { - int count_errors = 0; - - int prev = Integer.MIN_VALUE; - for (String v : alphanumValues) { - if (v.length() == 0) - continue; - try { - int n = Integer.valueOf(v); - if (prev == Integer.MIN_VALUE) { - prev = n; - continue; - } else { - if (n != prev + 1 && n != prev) { - count_errors++; - } - prev = n; - } - } catch (NumberFormatException nfe) { - return false; - } - } - - int tolerance = (int) (0.2 * alphanumValues.length); - tolerance = tolerance < 2 ? tolerance = 2 : tolerance; - if (count_errors > tolerance || count_errors > (alphanumValues.length * 0.5)) - return false; - return true; - } - - //input must be alpha numeric characters only - public static DataType classify(String text) { - //is it a date? - String original = text; - text = text.trim(); - for (Pattern p : DATES) { - if (p.matcher(text).matches()) - return DataType.DATE; - } - - //is it a single, long string? - String[] tokens = text.split("\\s+"); - if (tokens.length == 1 && tokens[0].length() > 25) { - return DataType.LONG_STRING; - } - text = StringUtils.toAlphaNumericWhitechar(text).trim(); - - //is it empty - if (text.length() < 1) - return DataType.EMPTY; - tokens = /*StringUtils.splitToAlphaNumericTokens(text,false).toArray(new String[0]);//*/text.split("\\s+"); - - //is it date (we do not use regex, but only looks for months terms) - int countMonthTerms = 0; - for (String t : tokens) { - if (MONTHS.contains(t.toLowerCase())) - countMonthTerms++; - } - if (countMonthTerms > tokens.length * 0.2) //the phrase has n tokens and months is at least 1/5 of all tokens - return DataType.DATE; - - //is it numeric - boolean isNumeric = StringUtils.isNumericArray(tokens); - if (isNumeric) { - for (String tok : tokens) { - if (tok.equals("AD") || tok.equals("BC") || tok.equals("A.D.") || tok.equals("B.C.")) - return DataType.DATE; - } - try { - Integer i = Integer.valueOf(text.trim()); - if (i >= 1800 && i < 2050) { - return DataType.DATE; - } - } catch (NumberFormatException nfe) { - } - - return DataType.NUMBER; - } - /* int countOrdinal=0; - for(String tok: tokens){ - if(StringUtils.isOrdinalNumber(tok.toLowerCase())) - countOrdinal++; - } - if(countOrdinal>= (tokens.length-countOrdinal) ) - return DataType.NUMBER;*/ - - - //is it short text - if (tokens.length < 10) { - //is it NE - int countCap = 0, countLower = 0; - for (int i = 0; i < tokens.length; i++) { - if (StringUtils.isCapitalized(tokens[i])) - countCap++; - else if (Character.isLowerCase(tokens[i].charAt(0))) { - countLower++; - } - } - //must start with a capitalised token (ignoring digits at beginning) - boolean capStart = false, capEnd = false; - //if (tokens.length == 1) { - if (StringUtils.isCapitalized(tokens[0])) - capStart = true; - else { - if (isCapitalizedIDString(tokens[0])) - capStart = true; - } - //} - if (StringUtils.isCapitalized(tokens[tokens.length - 1])) - capEnd = true; - else { - if (isCapitalizedIDString(tokens[tokens.length - 1])) - capEnd = true; - } - - //then must have more capitalised tokens than otherwise - if (capStart && countCap >= (tokens.length - countCap)) - return DataType.NAMED_ENTITY; - else if (capStart && capEnd) - return DataType.NAMED_ENTITY; - - if (!isLikelySentence(original)) - return DataType.SHORT_TEXT; - else - return DataType.LONG_TEXT; - } - - - //is it long text - if (tokens.length >= 15 || (tokens.length >= 5 && isLikelySentence(original))) - return DataType.LONG_TEXT; - return DataType.UNKNOWN; - } - - private static boolean isLikelySentence(String text) { - return text.endsWith(".") || text.endsWith("?") - || text.endsWith("!"); - } - - public static boolean isCapitalizedIDString(String text) { - boolean allAlphabetCapped = true; //every character in this token must be cap'ed, e.g., "1927F3I5LM" - int countAlphabetic = 0; - for (int i = 0; i < text.length(); i++) { - if (Character.isAlphabetic(text.charAt(i))) { - countAlphabetic++; - if (!Character.isUpperCase(text.charAt(i))) { - allAlphabetCapped = false; - break; - } - } - } - if (countAlphabetic > 0) - return allAlphabetCapped; - return false; - } - - - public enum DataType implements Serializable { - - UNKNOWN("unknown"), - EMPTY("empty"), - ORDERED_NUMBER("onumber"), //like ranking - NUMBER("number"), //any numeric values - DATE("date"), //any date-like values - SHORT_TEXT("stext"), //string of less than 10 tokens - LONG_TEXT("ltext"), //paragraphs of texts - LONG_STRING("lstring"), //a single string that is very long (longer than 25 characters) - NAMED_ENTITY("ne"); //strings likely to be named entities - - private String value; - private static final long serialVersionUID = -1208425578110405913L; - - DataType(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - - } - -} +package uk.ac.shef.dcs.sti.util; + +import uk.ac.shef.dcs.util.StringUtils; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.regex.Pattern; + +/** + */ +public class DataTypeClassifier implements Serializable { + private static List MONTHS = new ArrayList( + Arrays.asList("january", "jan", + "february", "feb", + "march", "mar", + "april", "apr", + "may", + "june", "jun", + "july", "jul", + "august", "aug", + "september", "sep", + "october", "oct", + "november", "nov", + "december", "dec")); + private static Pattern[] DATES = new Pattern[]{ + /*german, / - no .*/ //Pattern.compile("^(?ni:(?=\\d)((?'year'((1[6-9])|([2-9]\\d))\\d\\d)(?'sep'[/.-])(?'month'0?[1-9]|1[012])\\2(?'day'((?((0?[1-9]|1[012])(:[0-5]\\d){0,2}(\\x20[AP]M))|([01]\\d|2[0-3])(:[0-5]\\d){1,2}))?)$"), //german + Pattern.compile("([0-9]{4})[\\.\\/\\-]([0-9]{1,2})[\\.\\/\\-]([0-9]{1,2})"), + /*uk, / - no .*/ Pattern.compile("^(?=\\d)(?:(?!(?:(?:0?[5-9]|1[0-4])(?:\\.|-|\\/)10(?:\\.|-|\\/)(?:1582))|(?:(?:0?[3-9]|1[0-3])(?:\\.|-|\\/)0?9(?:\\.|-|\\/)(?:1752)))(31(?!(?:\\.|-|\\/)(?:0?[2469]|11))|30(?!(?:\\.|-|\\/)0?2)|(?:29(?:(?!(?:\\.|-|\\/)0?2(?:\\.|-|\\/))|(?=\\D0?2\\D(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:(?:\\d\\d)(?:[02468][048]|[13579][26])(?!\\x20BC))|(?:00(?:42|3[0369]|2[147]|1[258]|09)\\x20BC))))))|2[0-8]|1\\d|0?[1-9])([-.\\/])(1[012]|(?:0?[1-9]))\\2((?=(?:00(?:4[0-5]|[0-3]?\\d)\\x20BC)|(?:\\d{4}(?:$|(?=\\x20\\d)\\x20)))\\d{4}(?:\\x20BC)?)(?:$|(?=\\x20\\d)\\x20))?((?:(?:0?[1-9]|1[012])(?::[0-5]\\d){0,2}(?:\\x20[aApP][mM]))|(?:[01]\\d|2[0-3])(?::[0-5]\\d){1,2})?$"), //uk + /*yy/.-mm/.-dd*/ Pattern.compile("^(?:(?:(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(\\/|-|\\.)(?:0?2\\1(?:29)))|(?:(?:(?:1[6-9]|[2-9]\\d)?\\d{2})(\\/|-|\\.)(?:(?:(?:0?[13578]|1[02])\\2(?:31))|(?:(?:0?[1,3-9]|1[0-2])\\2(29|30))|(?:(?:0?[1-9])|(?:1[0-2]))\\2(?:0?[1-9]|1\\d|2[0-8]))))$"), + /*29.2.04 | 29/02-2004 | 3.4.05*/ Pattern.compile("^(((0?[1-9]|[12]\\d|3[01])[\\.\\-\\/](0?[13578]|1[02])[\\.\\-\\/]((1[6-9]|[2-9]\\d)?\\d{2}))|((0?[1-9]|[12]\\d|30)[\\.\\-\\/](0?[13456789]|1[012])[\\.\\-\\/]((1[6-9]|[2-9]\\d)?\\d{2}))|((0?[1-9]|1\\d|2[0-8])[\\.\\-\\/]0?2[\\.\\-\\/]((1[6-9]|[2-9]\\d)?\\d{2}))|(29[\\.\\-\\/]0?2[\\.\\-\\/]((1[6-9]|[2-9]\\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00)))$"), + /*mm/dd/yyyy*/Pattern.compile("^([0]?[1-9]|[1][0-2])[./-]([0]?[1-9]|[1|2][0-9]|[3][0|1])[./-]([0-9]{4}|[0-9]{2})$") + }; + + + //a helper method to determine if an array of values are likely to be a series of ordered numbers + //input must be only alpha numeric characters + public static boolean isOrderedNumber(String... alphanumValues) { + int count_errors = 0; + + int prev = Integer.MIN_VALUE; + for (String v : alphanumValues) { + if (v.length() == 0) + continue; + try { + int n = Integer.valueOf(v); + if (prev == Integer.MIN_VALUE) { + prev = n; + continue; + } else { + if (n != prev + 1 && n != prev) { + count_errors++; + } + prev = n; + } + } catch (NumberFormatException nfe) { + return false; + } + } + + int tolerance = (int) (0.2 * alphanumValues.length); + tolerance = tolerance < 2 ? tolerance = 2 : tolerance; + if (count_errors > tolerance || count_errors > (alphanumValues.length * 0.5)) + return false; + return true; + } + + //input must be alpha numeric characters only + public static DataType classify(String text) { + //is it a date? + String original = text; + text = text.trim(); + for (Pattern p : DATES) { + if (p.matcher(text).matches()) + return DataType.DATE; + } + + //is it a single, long string? + String[] tokens = text.split("\\s+"); + if (tokens.length == 1 && tokens[0].length() > 25) { + return DataType.LONG_STRING; + } + text = StringUtils.toAlphaNumericWhitechar(text).trim(); + + //is it empty + if (text.length() < 1) + return DataType.EMPTY; + tokens = /*StringUtils.splitToAlphaNumericTokens(text,false).toArray(new String[0]);//*/text.split("\\s+"); + + //is it date (we do not use regex, but only looks for months terms) + int countMonthTerms = 0; + for (String t : tokens) { + if (MONTHS.contains(t.toLowerCase())) + countMonthTerms++; + } + if (countMonthTerms > tokens.length * 0.2) //the phrase has n tokens and months is at least 1/5 of all tokens + return DataType.DATE; + + //is it numeric + boolean isNumeric = StringUtils.isNumericArray(tokens); + if (isNumeric) { + for (String tok : tokens) { + if (tok.equals("AD") || tok.equals("BC") || tok.equals("A.D.") || tok.equals("B.C.")) + return DataType.DATE; + } + try { + Integer i = Integer.valueOf(text.trim()); + if (i >= 1800 && i < 2050) { + return DataType.DATE; + } + } catch (NumberFormatException nfe) { + } + + return DataType.NUMBER; + } + /* int countOrdinal=0; + for(String tok: tokens){ + if(StringUtils.isOrdinalNumber(tok.toLowerCase())) + countOrdinal++; + } + if(countOrdinal>= (tokens.length-countOrdinal) ) + return DataType.NUMBER;*/ + + + //is it short text + if (tokens.length < 10) { + //is it NE + int countCap = 0, countLower = 0; + for (int i = 0; i < tokens.length; i++) { + if (StringUtils.isCapitalized(tokens[i])) + countCap++; + else if (Character.isLowerCase(tokens[i].charAt(0))) { + countLower++; + } + } + //must start with a capitalised token (ignoring digits at beginning) + boolean capStart = false, capEnd = false; + //if (tokens.length == 1) { + if (StringUtils.isCapitalized(tokens[0])) + capStart = true; + else { + if (isCapitalizedIDString(tokens[0])) + capStart = true; + } + //} + if (StringUtils.isCapitalized(tokens[tokens.length - 1])) + capEnd = true; + else { + if (isCapitalizedIDString(tokens[tokens.length - 1])) + capEnd = true; + } + + //then must have more capitalised tokens than otherwise + if (capStart && countCap >= (tokens.length - countCap)) + return DataType.NAMED_ENTITY; + else if (capStart && capEnd) + return DataType.NAMED_ENTITY; + + if (!isLikelySentence(original)) + return DataType.SHORT_TEXT; + else + return DataType.LONG_TEXT; + } + + + //is it long text + if (tokens.length >= 15 || (tokens.length >= 5 && isLikelySentence(original))) + return DataType.LONG_TEXT; + return DataType.UNKNOWN; + } + + private static boolean isLikelySentence(String text) { + return text.endsWith(".") || text.endsWith("?") + || text.endsWith("!"); + } + + public static boolean isCapitalizedIDString(String text) { + boolean allAlphabetCapped = true; //every character in this token must be cap'ed, e.g., "1927F3I5LM" + int countAlphabetic = 0; + for (int i = 0; i < text.length(); i++) { + if (Character.isAlphabetic(text.charAt(i))) { + countAlphabetic++; + if (!Character.isUpperCase(text.charAt(i))) { + allAlphabetCapped = false; + break; + } + } + } + if (countAlphabetic > 0) + return allAlphabetCapped; + return false; + } + + + public enum DataType implements Serializable { + + UNKNOWN("unknown"), + EMPTY("empty"), + ORDERED_NUMBER("onumber"), //like ranking + NUMBER("number"), //any numeric values + DATE("date"), //any date-like values + SHORT_TEXT("stext"), //string of less than 10 tokens + LONG_TEXT("ltext"), //paragraphs of texts + LONG_STRING("lstring"), //a single string that is very long (longer than 25 characters) + NAMED_ENTITY("ne"); //strings likely to be named entities + + private String value; + private static final long serialVersionUID = -1208425578110405913L; + + DataType(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + + } + +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/FileUtils.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/FileUtils.java index 233b245d..018af860 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/FileUtils.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/FileUtils.java @@ -1,55 +1,55 @@ -package uk.ac.shef.dcs.sti.util; - -import org.apache.commons.io.LineIterator; - -import java.io.*; -import java.util.*; - -/** - * Several utility methods related to files. - * - * @author Ziqi Zhang - */ -public class FileUtils { - - - /** - * Read input raw text file as a list - * - * @param path input file path - * @param lowercase whether to convert input string to lowercase - * @return - * @throws IOException - */ - public static List readList(final String path, final boolean lowercase) throws IOException { - List res = new ArrayList<>(); - LineIterator it = org.apache.commons.io.FileUtils.lineIterator(new File(path)); - while(it.hasNext()){ - String line=it.nextLine().trim(); - if (line.equals("")) continue; - if (lowercase) res.add(line.toLowerCase()); - else res.add(line); - } - - return res; - } - - public static List readList(final String path, final boolean lowercase, final String charset) throws IOException { - List res = new ArrayList<>(); - final InputStreamReader ir = new InputStreamReader(new FileInputStream(path), charset); - - final BufferedReader reader = new BufferedReader(ir); - String line; - while ((line = reader.readLine()) != null) { - line = line.trim(); - if (line.equals("")) continue; - if (lowercase) res.add(line.toLowerCase()); - else res.add(line); - } - - reader.close(); - return res; - } - -} - +package uk.ac.shef.dcs.sti.util; + +import org.apache.commons.io.LineIterator; + +import java.io.*; +import java.util.*; + +/** + * Several utility methods related to files. + * + * @author Ziqi Zhang + */ +public class FileUtils { + + + /** + * Read input raw text file as a list + * + * @param path input file path + * @param lowercase whether to convert input string to lowercase + * @return + * @throws IOException + */ + public static List readList(final String path, final boolean lowercase) throws IOException { + List res = new ArrayList<>(); + LineIterator it = org.apache.commons.io.FileUtils.lineIterator(new File(path)); + while(it.hasNext()){ + String line=it.nextLine().trim(); + if (line.equals("")) continue; + if (lowercase) res.add(line.toLowerCase()); + else res.add(line); + } + + return res; + } + + public static List readList(final String path, final boolean lowercase, final String charset) throws IOException { + List res = new ArrayList<>(); + final InputStreamReader ir = new InputStreamReader(new FileInputStream(path), charset); + + final BufferedReader reader = new BufferedReader(ir); + String line; + while ((line = reader.readLine()) != null) { + line = line.trim(); + if (line.equals("")) continue; + if (lowercase) res.add(line.toLowerCase()); + else res.add(line); + } + + reader.close(); + return res; + } + +} + diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/SubsetGenerator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/SubsetGenerator.java index 2c5b879d..53392880 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/SubsetGenerator.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/SubsetGenerator.java @@ -1,30 +1,30 @@ -package uk.ac.shef.dcs.sti.util; - -import com.google.common.collect.Sets; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Set; - -/** - * Created by zqz on 29/04/2015. - */ -public class SubsetGenerator { - - public static List generateSubsets(Set words){ - Set> subsets = Sets.powerSet(words); - List result = new ArrayList<>(); - for(Set sub: subsets){ - List ordered = new ArrayList<>(sub); - Collections.sort(ordered); - String string = ""; - for(Integer a: ordered){ - string+=a+" "; - } - result.add(string.trim()); - } - result.remove(""); - return result; - } -} +package uk.ac.shef.dcs.sti.util; + +import com.google.common.collect.Sets; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; + +/** + * Created by zqz on 29/04/2015. + */ +public class SubsetGenerator { + + public static List generateSubsets(Set words){ + Set> subsets = Sets.powerSet(words); + List result = new ArrayList<>(); + for(Set sub: subsets){ + List ordered = new ArrayList<>(sub); + Collections.sort(ordered); + String string = ""; + for(Integer a: ordered){ + string+=a+" "; + } + result.add(string.trim()); + } + result.remove(""); + return result; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/TripleGenerator.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/TripleGenerator.java index dc852f18..1c9b985e 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/TripleGenerator.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/TripleGenerator.java @@ -1,147 +1,147 @@ -package uk.ac.shef.dcs.sti.util; - -import uk.ac.shef.dcs.kbsearch.model.Entity; -import uk.ac.shef.dcs.sti.core.model.*; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - */ -public class TripleGenerator { - - private String kbNamespace; - private String defaultNamespace; - - public TripleGenerator(String kbNamespace, String dummyNamespace) { - this.kbNamespace = kbNamespace; - this.defaultNamespace = dummyNamespace; - } - - public List generate_newTriples(TAnnotation tab_annotation, Table table) { - List result = new ArrayList<>(); - - //column typing instances - for (int col = 0; col < table.getNumCols(); col++) { - TColumnHeader header = table.getColumnHeader(col); - - List bestHeaderAnnotations = tab_annotation.getWinningHeaderAnnotations(col); - if (bestHeaderAnnotations.size() == 0) - continue; - - - for (int row = 0; row < table.getNumRows(); row++) { - for (TColumnHeaderAnnotation final_type_for_the_column : bestHeaderAnnotations) { - - /*if (final_type_for_the_column.getSupportingRows().contains(row)) - continue;*/ - TCell tcc = table.getContentCell(row, col); - TCellAnnotation[] cell_annotations = tab_annotation.getContentCellAnnotations(row, col); - if (cell_annotations == null || cell_annotations.length == 0) //no entity found for this cell - continue; - - TCellAnnotation final_cell_annotation = cell_annotations[0]; - Entity entity = final_cell_annotation.getAnnotation(); - - //new triple - TableTriple ltt = new TableTriple(); - ltt.setSubject_position(new int[]{row, col}); - ltt.setSubject(tcc.getText()); - ltt.setSubject_annotation(kbNamespace + entity.getId()); - ltt.setObject(header.getHeaderText()); - ltt.setObject_annotation(kbNamespace + final_type_for_the_column.getAnnotation().getId()); - ltt.setObject_position(new int[]{-1, -1}); - ltt.setRelation_annotation("rdf:type"); - result.add(ltt); - } - } - } - - //across column relations at each row - List related_columns_with_subject = new ArrayList(); - int main_subject_column = 0; - Map> - relations_across_columns = tab_annotation.getColumncolumnRelations(); - for (Map.Entry> entry : - relations_across_columns.entrySet()) { - RelationColumns the_two_columns = entry.getKey(); - int subCol = the_two_columns.getSubjectCol(); - int objCol = the_two_columns.getObjectCol(); - related_columns_with_subject.add(objCol); - main_subject_column = subCol; - - Collections.sort(entry.getValue()); - TColumnColumnRelationAnnotation relation_annotation = entry.getValue().get(0); - - for (int row = 0; row < table.getNumRows(); row++) { - if (relation_annotation.getSupportingRows().contains(row)) - continue; - - TCell subject_cell = table.getContentCell(row, subCol); - TCell object_cell = table.getContentCell(row, objCol); - TCellAnnotation[] subject_cell_annotations = tab_annotation.getContentCellAnnotations(row, subCol); - if (subject_cell_annotations == null || subject_cell_annotations.length == 0) - continue; - TCellAnnotation final_subject_cell_annotation = subject_cell_annotations[0]; - TCellAnnotation[] object_cell_annotations = tab_annotation.getContentCellAnnotations(row, objCol); - TCellAnnotation final_object_cell_annotation = object_cell_annotations == null || object_cell_annotations.length == 0 ? null : object_cell_annotations[0]; - - TableTriple triple = new TableTriple(); - triple.setSubject_position(new int[]{row, subCol}); - triple.setSubject(final_subject_cell_annotation.getTerm()); - triple.setSubject_annotation(kbNamespace + final_subject_cell_annotation.getAnnotation().getId()); - - triple.setObject_position(new int[]{row, objCol}); - if (final_object_cell_annotation != null) { - triple.setObject_annotation(kbNamespace + final_object_cell_annotation.getAnnotation().getId()); - triple.setObject(final_object_cell_annotation.getTerm()); - } else { - triple.setObject_annotation("'" + object_cell.getText() + "'"); - triple.setObject(object_cell.getText()); - } - triple.setRelation_annotation(kbNamespace + relation_annotation.getRelationURI()); - result.add(triple); - - } - } - - //remaining columns with subject column create dummy relations - for (int col = 0; col < table.getNumCols(); col++) { - if (col == main_subject_column || related_columns_with_subject.contains(col)) - continue; - - TColumnHeader header = table.getColumnHeader(col); - if (header!=null&&header.getTypes() != null) { - if (header.getTypes().get(0).getType().equals(DataTypeClassifier.DataType.ORDERED_NUMBER)) - continue; - } - else{ - continue; - } - - for (int row = 0; row < table.getNumRows(); row++) { - TCell subject_cell = table.getContentCell(row, main_subject_column); - TCell object_cell = table.getContentCell(row, col); - TCellAnnotation[] subject_cell_annotations = tab_annotation.getContentCellAnnotations(row, main_subject_column); - if (subject_cell_annotations == null || subject_cell_annotations.length == 0) - continue; - TCellAnnotation final_subject_cell_annotation = subject_cell_annotations[0]; - - TableTriple triple = new TableTriple(); - triple.setSubject_position(new int[]{row, main_subject_column}); - triple.setSubject(final_subject_cell_annotation.getTerm()); - triple.setSubject_annotation(kbNamespace + final_subject_cell_annotation.getAnnotation().getId()); - - triple.setObject_position(new int[]{row, col}); - triple.setObject(object_cell.getText()); - triple.setObject_annotation("'" + object_cell.getText() + "'"); - triple.setRelation_annotation(defaultNamespace + "/" + header.getHeaderText()); - result.add(triple); - } - } - - return result; - } -} +package uk.ac.shef.dcs.sti.util; + +import uk.ac.shef.dcs.kbsearch.model.Entity; +import uk.ac.shef.dcs.sti.core.model.*; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** + */ +public class TripleGenerator { + + private String kbNamespace; + private String defaultNamespace; + + public TripleGenerator(String kbNamespace, String dummyNamespace) { + this.kbNamespace = kbNamespace; + this.defaultNamespace = dummyNamespace; + } + + public List generate_newTriples(TAnnotation tab_annotation, Table table) { + List result = new ArrayList<>(); + + //column typing instances + for (int col = 0; col < table.getNumCols(); col++) { + TColumnHeader header = table.getColumnHeader(col); + + List bestHeaderAnnotations = tab_annotation.getWinningHeaderAnnotations(col); + if (bestHeaderAnnotations.size() == 0) + continue; + + + for (int row = 0; row < table.getNumRows(); row++) { + for (TColumnHeaderAnnotation final_type_for_the_column : bestHeaderAnnotations) { + + /*if (final_type_for_the_column.getSupportingRows().contains(row)) + continue;*/ + TCell tcc = table.getContentCell(row, col); + TCellAnnotation[] cell_annotations = tab_annotation.getContentCellAnnotations(row, col); + if (cell_annotations == null || cell_annotations.length == 0) //no entity found for this cell + continue; + + TCellAnnotation final_cell_annotation = cell_annotations[0]; + Entity entity = final_cell_annotation.getAnnotation(); + + //new triple + TableTriple ltt = new TableTriple(); + ltt.setSubject_position(new int[]{row, col}); + ltt.setSubject(tcc.getText()); + ltt.setSubject_annotation(kbNamespace + entity.getId()); + ltt.setObject(header.getHeaderText()); + ltt.setObject_annotation(kbNamespace + final_type_for_the_column.getAnnotation().getId()); + ltt.setObject_position(new int[]{-1, -1}); + ltt.setRelation_annotation("rdf:type"); + result.add(ltt); + } + } + } + + //across column relations at each row + List related_columns_with_subject = new ArrayList(); + int main_subject_column = 0; + Map> + relations_across_columns = tab_annotation.getColumncolumnRelations(); + for (Map.Entry> entry : + relations_across_columns.entrySet()) { + RelationColumns the_two_columns = entry.getKey(); + int subCol = the_two_columns.getSubjectCol(); + int objCol = the_two_columns.getObjectCol(); + related_columns_with_subject.add(objCol); + main_subject_column = subCol; + + Collections.sort(entry.getValue()); + TColumnColumnRelationAnnotation relation_annotation = entry.getValue().get(0); + + for (int row = 0; row < table.getNumRows(); row++) { + if (relation_annotation.getSupportingRows().contains(row)) + continue; + + TCell subject_cell = table.getContentCell(row, subCol); + TCell object_cell = table.getContentCell(row, objCol); + TCellAnnotation[] subject_cell_annotations = tab_annotation.getContentCellAnnotations(row, subCol); + if (subject_cell_annotations == null || subject_cell_annotations.length == 0) + continue; + TCellAnnotation final_subject_cell_annotation = subject_cell_annotations[0]; + TCellAnnotation[] object_cell_annotations = tab_annotation.getContentCellAnnotations(row, objCol); + TCellAnnotation final_object_cell_annotation = object_cell_annotations == null || object_cell_annotations.length == 0 ? null : object_cell_annotations[0]; + + TableTriple triple = new TableTriple(); + triple.setSubject_position(new int[]{row, subCol}); + triple.setSubject(final_subject_cell_annotation.getTerm()); + triple.setSubject_annotation(kbNamespace + final_subject_cell_annotation.getAnnotation().getId()); + + triple.setObject_position(new int[]{row, objCol}); + if (final_object_cell_annotation != null) { + triple.setObject_annotation(kbNamespace + final_object_cell_annotation.getAnnotation().getId()); + triple.setObject(final_object_cell_annotation.getTerm()); + } else { + triple.setObject_annotation("'" + object_cell.getText() + "'"); + triple.setObject(object_cell.getText()); + } + triple.setRelation_annotation(kbNamespace + relation_annotation.getRelationURI()); + result.add(triple); + + } + } + + //remaining columns with subject column create dummy relations + for (int col = 0; col < table.getNumCols(); col++) { + if (col == main_subject_column || related_columns_with_subject.contains(col)) + continue; + + TColumnHeader header = table.getColumnHeader(col); + if (header!=null&&header.getTypes() != null) { + if (header.getTypes().get(0).getType().equals(DataTypeClassifier.DataType.ORDERED_NUMBER)) + continue; + } + else{ + continue; + } + + for (int row = 0; row < table.getNumRows(); row++) { + TCell subject_cell = table.getContentCell(row, main_subject_column); + TCell object_cell = table.getContentCell(row, col); + TCellAnnotation[] subject_cell_annotations = tab_annotation.getContentCellAnnotations(row, main_subject_column); + if (subject_cell_annotations == null || subject_cell_annotations.length == 0) + continue; + TCellAnnotation final_subject_cell_annotation = subject_cell_annotations[0]; + + TableTriple triple = new TableTriple(); + triple.setSubject_position(new int[]{row, main_subject_column}); + triple.setSubject(final_subject_cell_annotation.getTerm()); + triple.setSubject_annotation(kbNamespace + final_subject_cell_annotation.getAnnotation().getId()); + + triple.setObject_position(new int[]{row, col}); + triple.setObject(object_cell.getText()); + triple.setObject_annotation("'" + object_cell.getText() + "'"); + triple.setRelation_annotation(defaultNamespace + "/" + header.getHeaderText()); + result.add(triple); + } + } + + return result; + } +} diff --git a/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/XPathUtils.java b/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/XPathUtils.java index 8fb22ba5..18ba25d8 100644 --- a/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/XPathUtils.java +++ b/sti-main/src/main/java/uk/ac/shef/dcs/sti/util/XPathUtils.java @@ -1,31 +1,31 @@ -package uk.ac.shef.dcs.sti.util; - -import java.util.ArrayList; -import java.util.List; - -/** - * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) - * Date: 31/10/12 - * Time: 21:29 - */ -public class XPathUtils { - - /** - * @param tag e.g., tr - * @param xpath e.g., /html/body/table[1]/tr[2]/td[2] - * @return /html/body/table[1]/tr[2] - */ - public static String trimXPathLastTag(String tag, String xpath) { - int lastTagIndex = xpath.lastIndexOf(tag); - if (lastTagIndex != -1) { - int end = xpath.indexOf("/", lastTagIndex); - if (end == -1) { - return xpath; - } - return xpath.substring(0, end); - } - return null; - } - - -} +package uk.ac.shef.dcs.sti.util; + +import java.util.ArrayList; +import java.util.List; + +/** + * Author: Ziqi Zhang (z.zhang@dcs.shef.ac.uk) + * Date: 31/10/12 + * Time: 21:29 + */ +public class XPathUtils { + + /** + * @param tag e.g., tr + * @param xpath e.g., /html/body/table[1]/tr[2]/td[2] + * @return /html/body/table[1]/tr[2] + */ + public static String trimXPathLastTag(String tag, String xpath) { + int lastTagIndex = xpath.lastIndexOf(tag); + if (lastTagIndex != -1) { + int end = xpath.indexOf("/", lastTagIndex); + if (end == -1) { + return xpath; + } + return xpath.substring(0, end); + } + return null; + } + + +} diff --git a/sti-websearch/src/uk/ac/shef/dcs/websearch/SearchResultParser.java b/sti-websearch/src/uk/ac/shef/dcs/websearch/SearchResultParser.java index bcc87321..456c7299 100644 --- a/sti-websearch/src/uk/ac/shef/dcs/websearch/SearchResultParser.java +++ b/sti-websearch/src/uk/ac/shef/dcs/websearch/SearchResultParser.java @@ -1,12 +1,12 @@ -package uk.ac.shef.dcs.websearch; - -import java.io.IOException; -import java.io.InputStream; -import java.util.List; - -/** - * Created by - on 17/03/2016. - */ -public abstract class SearchResultParser { - public abstract List parse(InputStream is) throws IOException; -} +package uk.ac.shef.dcs.websearch; + +import java.io.IOException; +import java.io.InputStream; +import java.util.List; + +/** + * Created by - on 17/03/2016. + */ +public abstract class SearchResultParser { + public abstract List parse(InputStream is) throws IOException; +} diff --git a/sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearch.java b/sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearch.java index a3db33c5..8aa18d88 100644 --- a/sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearch.java +++ b/sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearch.java @@ -1,27 +1,27 @@ -package uk.ac.shef.dcs.websearch; - -import javax.rmi.PortableRemoteObject; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.*; - -/** - * Created by - on 17/03/2016. - */ -public abstract class WebSearch { - - protected static final String WEB_SEARCH_CLASS = "web.search.class"; - - protected Properties properties; - - - public WebSearch(Properties properties) throws IOException { - this.properties=properties; - } - - public abstract InputStream search(String s) throws Exception; - - public abstract SearchResultParser getResultParser(); -} +package uk.ac.shef.dcs.websearch; + +import javax.rmi.PortableRemoteObject; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.*; + +/** + * Created by - on 17/03/2016. + */ +public abstract class WebSearch { + + protected static final String WEB_SEARCH_CLASS = "web.search.class"; + + protected Properties properties; + + + public WebSearch(Properties properties) throws IOException { + this.properties=properties; + } + + public abstract InputStream search(String s) throws Exception; + + public abstract SearchResultParser getResultParser(); +} diff --git a/sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearchException.java b/sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearchException.java index f16f9a69..a9cd4632 100644 --- a/sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearchException.java +++ b/sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearchException.java @@ -1,14 +1,14 @@ -package uk.ac.shef.dcs.websearch; - -/** - * Created by - on 07/04/2016. - */ -public class WebSearchException extends Exception { - public WebSearchException(Exception e){ - super(e); - } - - public WebSearchException(String e){ - super(e); - } -} +package uk.ac.shef.dcs.websearch; + +/** + * Created by - on 07/04/2016. + */ +public class WebSearchException extends Exception { + public WebSearchException(Exception e){ + super(e); + } + + public WebSearchException(String e){ + super(e); + } +} diff --git a/sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearchFactory.java b/sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearchFactory.java index 2c58daaa..5da5d6da 100644 --- a/sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearchFactory.java +++ b/sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearchFactory.java @@ -1,33 +1,33 @@ -package uk.ac.shef.dcs.websearch; - -import uk.ac.shef.dcs.websearch.bing.v2.BingSearch; - -import java.io.FileInputStream; -import java.io.InputStream; -import java.lang.reflect.InvocationTargetException; -import java.util.Properties; - -/** - * Created by - on 17/03/2016. - */ -public class WebSearchFactory { - public WebSearch createInstance( - String propertyFile) throws WebSearchException { - Properties properties = new Properties(); - - try { - properties.load(new FileInputStream(propertyFile)); - String className = properties.getProperty(WebSearch.WEB_SEARCH_CLASS); - if (className.equals(BingSearch.class.getName())) { - return (WebSearch) Class.forName(className). - getDeclaredConstructor(Properties.class).newInstance(properties - ); - } - else { - throw new WebSearchException("Class: "+className+" not supported"); - } - }catch (Exception e){ - throw new WebSearchException(e); - } - } -} +package uk.ac.shef.dcs.websearch; + +import uk.ac.shef.dcs.websearch.bing.v2.BingSearch; + +import java.io.FileInputStream; +import java.io.InputStream; +import java.lang.reflect.InvocationTargetException; +import java.util.Properties; + +/** + * Created by - on 17/03/2016. + */ +public class WebSearchFactory { + public WebSearch createInstance( + String propertyFile) throws WebSearchException { + Properties properties = new Properties(); + + try { + properties.load(new FileInputStream(propertyFile)); + String className = properties.getProperty(WebSearch.WEB_SEARCH_CLASS); + if (className.equals(BingSearch.class.getName())) { + return (WebSearch) Class.forName(className). + getDeclaredConstructor(Properties.class).newInstance(properties + ); + } + else { + throw new WebSearchException("Class: "+className+" not supported"); + } + }catch (Exception e){ + throw new WebSearchException(e); + } + } +} diff --git a/sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearchResultDoc.java b/sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearchResultDoc.java index 73986a2e..29e3cf41 100644 --- a/sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearchResultDoc.java +++ b/sti-websearch/src/uk/ac/shef/dcs/websearch/WebSearchResultDoc.java @@ -1,56 +1,56 @@ -package uk.ac.shef.dcs.websearch; - -import java.io.Serializable; - -/** - */ -public class WebSearchResultDoc implements Serializable { - - private static final long serialVersionUID = -1208625714080495013L; - - private String id; - private String title; - private String description; - private String url; - private double score; - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public double getScore() { - return score; - } - - public void setScore(double score) { - this.score = score; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } -} +package uk.ac.shef.dcs.websearch; + +import java.io.Serializable; + +/** + */ +public class WebSearchResultDoc implements Serializable { + + private static final long serialVersionUID = -1208625714080495013L; + + private String id; + private String title; + private String description; + private String url; + private double score; + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public double getScore() { + return score; + } + + public void setScore(double score) { + this.score = score; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} diff --git a/sti-websearch/src/uk/ac/shef/dcs/websearch/bing/v2/APIKeysDepletedException.java b/sti-websearch/src/uk/ac/shef/dcs/websearch/bing/v2/APIKeysDepletedException.java index 4f776a3f..024c2a8f 100644 --- a/sti-websearch/src/uk/ac/shef/dcs/websearch/bing/v2/APIKeysDepletedException.java +++ b/sti-websearch/src/uk/ac/shef/dcs/websearch/bing/v2/APIKeysDepletedException.java @@ -1,9 +1,9 @@ -package uk.ac.shef.dcs.websearch.bing.v2; - -/** - */ -public class APIKeysDepletedException extends Exception { - public APIKeysDepletedException(){ - super("All API keys have outdated, search cannot continue."); - } -} +package uk.ac.shef.dcs.websearch.bing.v2; + +/** + */ +public class APIKeysDepletedException extends Exception { + public APIKeysDepletedException(){ + super("All API keys have outdated, search cannot continue."); + } +} diff --git a/sti-websearch/src/uk/ac/shef/dcs/websearch/bing/v2/BingSearch.java b/sti-websearch/src/uk/ac/shef/dcs/websearch/bing/v2/BingSearch.java index 00491a8e..904cca70 100644 --- a/sti-websearch/src/uk/ac/shef/dcs/websearch/bing/v2/BingSearch.java +++ b/sti-websearch/src/uk/ac/shef/dcs/websearch/bing/v2/BingSearch.java @@ -1,102 +1,102 @@ -package uk.ac.shef.dcs.websearch.bing.v2; - -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.lang.StringUtils; -import uk.ac.shef.dcs.websearch.SearchResultParser; -import uk.ac.shef.dcs.websearch.WebSearch; - -import java.io.IOException; -import java.io.InputStream; -import java.lang.String; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.util.*; - -/** - */ -public class BingSearch extends WebSearch{ - - protected static final String BING_BASE_URL="bing.url"; - protected static final String BING_KEYS="bing.keys"; - protected SearchResultParser parser; - - protected List accountKeyPool; - protected Map obsoleteAccountKeys; - protected String baseURL;// = "https://api.datamarket.azure.com/Bing/Search/Web?Query="; - - public BingSearch(Properties properties) throws IOException { - super(properties); - - obsoleteAccountKeys = new HashMap<>(); - this.accountKeyPool = new ArrayList<>(); - for (String k : StringUtils.split( - this.properties.getProperty(BING_KEYS),',' - )) { - k = k.trim(); - if(k.length()>0) - accountKeyPool.add(k); - } - this.baseURL = this.properties.getProperty(BING_BASE_URL); - } - - public InputStream search(String query) throws IOException, APIKeysDepletedException { - query = "'" + query + "'"; - query = URLEncoder.encode(query, "UTF-8"); - query = baseURL + query + "&$format=json&$top=20"; - - if (accountKeyPool.size() == obsoleteAccountKeys.size()) { - throw new APIKeysDepletedException(); - } - - for (String k : accountKeyPool) { - if (obsoleteAccountKeys.get(k) != null) - continue; - - URL url = new URL(query); - URLConnection urlConnection = url.openConnection(); - byte[] accountKeyBytes = Base64.encodeBase64((k + ":" + k).getBytes()); //first k being username; second k being password. - String accountKeyEnc = new String(accountKeyBytes); - urlConnection.setRequestProperty("Authorization", "Basic " + accountKeyEnc); - - InputStream is = null; - boolean keyInvalid = false; - try { - //fXhmgvVQnz1aLBti87+AZlPYDXcQL0G9L2dVAav+aK0= - is = urlConnection.getInputStream(); - } catch (IOException ioe) { - System.err.println("> Bing search exception. Apps built on top may produce incorrect results."); - if (ioe.getMessage().contains("Server returned HTTP response code: 401") || ioe.getMessage().contains("Server returned HTTP response code: 503")) { - keyInvalid = true; - ioe.printStackTrace(); - } else - throw ioe; - } - if (keyInvalid) { - obsoleteAccountKeys.put(k, new Date()); - continue; - } - return is; - } - return null; - } - - @Override - public SearchResultParser getResultParser() { - if(parser==null) - parser=new BingSearchResultParser(); - return parser; - } - - /*public static void main(String[] args) throws IOException, APIKeysDepletedException { - String[] accountKeys = new String[]{ - "8Yr8amTvrm5SM4XK3vM3KrLqOCT/ZhkwCfLEDtslE7o="}; - BingSearch searcher = new BingSearch(accountKeys); - - InputStream is = searcher.search("Sheffield University Sheffield"); - BingSearchResultParser parser = new BingSearchResultParser(); - List docs = parser.parse(is); - - - }*/ -} +package uk.ac.shef.dcs.websearch.bing.v2; + +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang.StringUtils; +import uk.ac.shef.dcs.websearch.SearchResultParser; +import uk.ac.shef.dcs.websearch.WebSearch; + +import java.io.IOException; +import java.io.InputStream; +import java.lang.String; +import java.net.URL; +import java.net.URLConnection; +import java.net.URLEncoder; +import java.util.*; + +/** + */ +public class BingSearch extends WebSearch{ + + protected static final String BING_BASE_URL="bing.url"; + protected static final String BING_KEYS="bing.keys"; + protected SearchResultParser parser; + + protected List accountKeyPool; + protected Map obsoleteAccountKeys; + protected String baseURL;// = "https://api.datamarket.azure.com/Bing/Search/Web?Query="; + + public BingSearch(Properties properties) throws IOException { + super(properties); + + obsoleteAccountKeys = new HashMap<>(); + this.accountKeyPool = new ArrayList<>(); + for (String k : StringUtils.split( + this.properties.getProperty(BING_KEYS),',' + )) { + k = k.trim(); + if(k.length()>0) + accountKeyPool.add(k); + } + this.baseURL = this.properties.getProperty(BING_BASE_URL); + } + + public InputStream search(String query) throws IOException, APIKeysDepletedException { + query = "'" + query + "'"; + query = URLEncoder.encode(query, "UTF-8"); + query = baseURL + query + "&$format=json&$top=20"; + + if (accountKeyPool.size() == obsoleteAccountKeys.size()) { + throw new APIKeysDepletedException(); + } + + for (String k : accountKeyPool) { + if (obsoleteAccountKeys.get(k) != null) + continue; + + URL url = new URL(query); + URLConnection urlConnection = url.openConnection(); + byte[] accountKeyBytes = Base64.encodeBase64((k + ":" + k).getBytes()); //first k being username; second k being password. + String accountKeyEnc = new String(accountKeyBytes); + urlConnection.setRequestProperty("Authorization", "Basic " + accountKeyEnc); + + InputStream is = null; + boolean keyInvalid = false; + try { + //fXhmgvVQnz1aLBti87+AZlPYDXcQL0G9L2dVAav+aK0= + is = urlConnection.getInputStream(); + } catch (IOException ioe) { + System.err.println("> Bing search exception. Apps built on top may produce incorrect results."); + if (ioe.getMessage().contains("Server returned HTTP response code: 401") || ioe.getMessage().contains("Server returned HTTP response code: 503")) { + keyInvalid = true; + ioe.printStackTrace(); + } else + throw ioe; + } + if (keyInvalid) { + obsoleteAccountKeys.put(k, new Date()); + continue; + } + return is; + } + return null; + } + + @Override + public SearchResultParser getResultParser() { + if(parser==null) + parser=new BingSearchResultParser(); + return parser; + } + + /*public static void main(String[] args) throws IOException, APIKeysDepletedException { + String[] accountKeys = new String[]{ + "8Yr8amTvrm5SM4XK3vM3KrLqOCT/ZhkwCfLEDtslE7o="}; + BingSearch searcher = new BingSearch(accountKeys); + + InputStream is = searcher.search("Sheffield University Sheffield"); + BingSearchResultParser parser = new BingSearchResultParser(); + List docs = parser.parse(is); + + + }*/ +} diff --git a/sti-websearch/src/uk/ac/shef/dcs/websearch/bing/v2/BingSearchResultParser.java b/sti-websearch/src/uk/ac/shef/dcs/websearch/bing/v2/BingSearchResultParser.java index 1d206f63..4578d137 100644 --- a/sti-websearch/src/uk/ac/shef/dcs/websearch/bing/v2/BingSearchResultParser.java +++ b/sti-websearch/src/uk/ac/shef/dcs/websearch/bing/v2/BingSearchResultParser.java @@ -1,96 +1,96 @@ -package uk.ac.shef.dcs.websearch.bing.v2; - -import uk.ac.shef.dcs.websearch.SearchResultParser; -import uk.ac.shef.dcs.websearch.WebSearchResultDoc; - -import javax.json.Json; -import javax.json.stream.JsonParser; - -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.StringReader; -import java.util.ArrayList; -import java.util.List; - -/** - */ - -public class BingSearchResultParser extends SearchResultParser { - public List parse(InputStream is) throws IOException { - List result = new ArrayList<>(); - if(is==null) - return result; - InputStreamReader isr = new InputStreamReader(is); - - int numCharsRead; - char[] charArray = new char[1024]; - StringBuilder sb = new StringBuilder(); - while ((numCharsRead = isr.read(charArray)) > 0) { - sb.append(charArray, 0, numCharsRead); - } - JsonParser parser = Json.createParser(new StringReader(sb.toString())); - - boolean newDocId=false, newDocTitle=false, newDocDesc=false, newDocURL=false; - WebSearchResultDoc doc=null; - while (parser.hasNext()) { - JsonParser.Event event = parser.next(); - switch(event) { - /*case START_ARRAY: - case END_ARRAY: - case START_OBJECT: - case END_OBJECT: - case VALUE_FALSE: - case VALUE_NULL: - case VALUE_TRUE: - System.out.println(event.toString()); - break;*/ - case KEY_NAME: - /*System.out.print(event.toString() + " " + - parser.getString() + " - ");*/ - String key = parser.getString(); - if(key.equals("ID")){ - //finish the previous object - if(doc!=null){ - result.add(doc); - newDocId=false; - newDocTitle=false; - newDocDesc=false; - newDocURL=false; - } - - //create new object - newDocId=true; - doc=new WebSearchResultDoc(); - }else if(key.equals("Title")){ - newDocTitle = true; - }else if(key.equals("Description")){ - newDocDesc = true; - }else if(key.equals("Url")){ - newDocURL = true; - } - break; - case VALUE_STRING: - case VALUE_NUMBER: - String value = parser.getString(); - if(newDocId){ - doc.setId(value); - newDocId=false; - }else if(newDocTitle){ - doc.setTitle(value); - newDocTitle=false; - }else if(newDocDesc){ - doc.setDescription(value); - newDocDesc=false; - }else if(newDocURL){ - doc.setUrl(value); - newDocURL=false; - } - break; - } - } - if(doc!=null) - result.add(doc); - return result; - } -} +package uk.ac.shef.dcs.websearch.bing.v2; + +import uk.ac.shef.dcs.websearch.SearchResultParser; +import uk.ac.shef.dcs.websearch.WebSearchResultDoc; + +import javax.json.Json; +import javax.json.stream.JsonParser; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.StringReader; +import java.util.ArrayList; +import java.util.List; + +/** + */ + +public class BingSearchResultParser extends SearchResultParser { + public List parse(InputStream is) throws IOException { + List result = new ArrayList<>(); + if(is==null) + return result; + InputStreamReader isr = new InputStreamReader(is); + + int numCharsRead; + char[] charArray = new char[1024]; + StringBuilder sb = new StringBuilder(); + while ((numCharsRead = isr.read(charArray)) > 0) { + sb.append(charArray, 0, numCharsRead); + } + JsonParser parser = Json.createParser(new StringReader(sb.toString())); + + boolean newDocId=false, newDocTitle=false, newDocDesc=false, newDocURL=false; + WebSearchResultDoc doc=null; + while (parser.hasNext()) { + JsonParser.Event event = parser.next(); + switch(event) { + /*case START_ARRAY: + case END_ARRAY: + case START_OBJECT: + case END_OBJECT: + case VALUE_FALSE: + case VALUE_NULL: + case VALUE_TRUE: + System.out.println(event.toString()); + break;*/ + case KEY_NAME: + /*System.out.print(event.toString() + " " + + parser.getString() + " - ");*/ + String key = parser.getString(); + if(key.equals("ID")){ + //finish the previous object + if(doc!=null){ + result.add(doc); + newDocId=false; + newDocTitle=false; + newDocDesc=false; + newDocURL=false; + } + + //create new object + newDocId=true; + doc=new WebSearchResultDoc(); + }else if(key.equals("Title")){ + newDocTitle = true; + }else if(key.equals("Description")){ + newDocDesc = true; + }else if(key.equals("Url")){ + newDocURL = true; + } + break; + case VALUE_STRING: + case VALUE_NUMBER: + String value = parser.getString(); + if(newDocId){ + doc.setId(value); + newDocId=false; + }else if(newDocTitle){ + doc.setTitle(value); + newDocTitle=false; + }else if(newDocDesc){ + doc.setDescription(value); + newDocDesc=false; + }else if(newDocURL){ + doc.setUrl(value); + newDocURL=false; + } + break; + } + } + if(doc!=null) + result.add(doc); + return result; + } +} diff --git a/ui/README.md b/ui/README.md index a7ad6512..30f77152 100644 --- a/ui/README.md +++ b/ui/README.md @@ -1,33 +1,33 @@ -# STI GUI (Still under construction) -This application provides a UI interface to interact with STI and visualize results. It is implemented based on Node.js. - -### Installation -- Download STI -- Install Node.js on your computer (see https://nodejs.org/en/download/) -- You need to ensure you have the following Node modules: `express` and `socket.io`. By default, these are included in the download (/node_modules) -- Build STI. `cd` into the parent folder of this folder, run `mvn clean install`. If build is successful, you should see a `sti-[version]-jar-with-dependencies.jar` file in `target` folder -- `cd ui` into the root folder. Edit `config.json` following descriptions below. -- Start the serer by `node main.js` -- Open a browser and point your address to `http://localhost:3000/` - -### Configuration `config.json` -This file configures the UI application. It links to other files used to configure TableMiner+. The following fields are defined. If you do not need email notification when a task completes, you do not need to change anything. Otherwise, as minimum, you must change **emaillogin, emailpass, emailhost, emailport, emailfrom** to configure your own email account. - -- **lib**: should point to the jars required to run TableMiner+. By default, this is '../target/*', where your maven build will place a `sti-[version]-jar-with-dependencies.jar` -- **cache**: should point to the folder containing the Solr index caches. By default this is '../resources/cache' -- **tablePrevClass**: a class used to download the webpage specified by user and preview its content before annotating the contained tables. This should be `uk.ac.shef.dcs.sti.ui.InputfilePreview` -- **stiMainClass**: the main class to run the TableMiner+ task. This should be `uk.ac.shef.dcs.sti.ui.TableMinerPlusSingle` -- **tmp**: a system required folder to keep intermediary files -- **error**: an error webpage to display when things go wrong -- **output**: a system required folder to contain output files -- **log4j**: the log4j configuration file. You must set this correctly to see the progress logs. By default this is '../config/log4j.properties' -- **stiprofile**: the configuration file for running TableMiner+. By default this is '../config/sti.properties'. You will be able to chanage the settings through the UI. Detailed instructions are included in the file. -- **stiwebprofile**: the configuration file for Web search used by TableMiner+. By default this is '../config/websearch.properties'. You will be able to chanage the settings through the UI. Detailed instructions are included in the file. -- **stikbprofile**: the configuration file for knowledge base search used by TableMiner+. By default this is '../config/kbsearch.properties'. You will be able to chanage the settings through the UI. Detailed instructions are included in the file. -- **server**: the server address. -- **emaillogin**: TableMiner+ emails you when a task is complete. To do this it uses an email account. This is the login email address for that account. If not provided, you will not receive email notification. -- **emailpass**: The password to log into the above email account. -- **emailhost**: The host of the email account -- **emailport**: Port number of the email host -- **emailfrom**: Sender of the email +# STI GUI (Still under construction) +This application provides a UI interface to interact with STI and visualize results. It is implemented based on Node.js. + +### Installation +- Download STI +- Install Node.js on your computer (see https://nodejs.org/en/download/) +- You need to ensure you have the following Node modules: `express` and `socket.io`. By default, these are included in the download (/node_modules) +- Build STI. `cd` into the parent folder of this folder, run `mvn clean install`. If build is successful, you should see a `sti-[version]-jar-with-dependencies.jar` file in `target` folder +- `cd ui` into the root folder. Edit `config.json` following descriptions below. +- Start the serer by `node main.js` +- Open a browser and point your address to `http://localhost:3000/` + +### Configuration `config.json` +This file configures the UI application. It links to other files used to configure TableMiner+. The following fields are defined. If you do not need email notification when a task completes, you do not need to change anything. Otherwise, as minimum, you must change **emaillogin, emailpass, emailhost, emailport, emailfrom** to configure your own email account. + +- **lib**: should point to the jars required to run TableMiner+. By default, this is '../target/*', where your maven build will place a `sti-[version]-jar-with-dependencies.jar` +- **cache**: should point to the folder containing the Solr index caches. By default this is '../resources/cache' +- **tablePrevClass**: a class used to download the webpage specified by user and preview its content before annotating the contained tables. This should be `uk.ac.shef.dcs.sti.ui.InputfilePreview` +- **stiMainClass**: the main class to run the TableMiner+ task. This should be `uk.ac.shef.dcs.sti.ui.TableMinerPlusSingle` +- **tmp**: a system required folder to keep intermediary files +- **error**: an error webpage to display when things go wrong +- **output**: a system required folder to contain output files +- **log4j**: the log4j configuration file. You must set this correctly to see the progress logs. By default this is '../config/log4j.properties' +- **stiprofile**: the configuration file for running TableMiner+. By default this is '../config/sti.properties'. You will be able to chanage the settings through the UI. Detailed instructions are included in the file. +- **stiwebprofile**: the configuration file for Web search used by TableMiner+. By default this is '../config/websearch.properties'. You will be able to chanage the settings through the UI. Detailed instructions are included in the file. +- **stikbprofile**: the configuration file for knowledge base search used by TableMiner+. By default this is '../config/kbsearch.properties'. You will be able to chanage the settings through the UI. Detailed instructions are included in the file. +- **server**: the server address. +- **emaillogin**: TableMiner+ emails you when a task is complete. To do this it uses an email account. This is the login email address for that account. If not provided, you will not receive email notification. +- **emailpass**: The password to log into the above email account. +- **emailhost**: The host of the email account +- **emailport**: Port number of the email host +- **emailfrom**: Sender of the email - **tableParsers**: input files (e.g., Webpages) must be preprocessed to extract the `HTML
` elements from the Webpage and these `
` must be represented as an internal Java object. A table parser is responsible for this job. Depending on different Webpages, you may encounter different `
` templates that require different processing. Hence Website-specific table parsers may have to be implemented from time to time. Currently there are four table parsers implemented, that can be found in the `uk.ac.shef.dcs.sti.parser.table` package. To support new Webpages, you need to create a new implementation of `TableParser`, which must implement `Browsable` if you want it to support Webpage preview in the UI. Then add that class into this JSON property. \ No newline at end of file diff --git a/ui/config.json b/ui/config.json old mode 100755 new mode 100644 index 95baa6a5..60c01e26 --- a/ui/config.json +++ b/ui/config.json @@ -1,25 +1,25 @@ -{ - "lib": "../target/*", - "cache":"../resources/cache", - "tablePrevClass":"uk.ac.shef.dcs.sti.ui.InputFilePreview", - "stiMainClass":"uk.ac.shef.dcs.sti.ui.TableMinerPlusSingle", - "tmp":"tmp", - "error":"error.html", - "output":"output", - "log4j":"../config/log4j.properties", - "stipropfile":"../config/sti.properties", - "stiwebpropfile":"../config/websearch.properties", - "stikbpropfile":"../config/kbsearch.properties", - "server":"http://localhost:3000/", - "emaillogin":"", - "emailpass":"", - "emailhost":"smtp.googlemail.com", - "emailport":"465", - "emailfrom":"", - "tableParsers":{ - "uk.ac.shef.dcs.sti.parser.table.TableParserIMDB": "IMDB cast table of movie webpages.", - "uk.ac.shef.dcs.sti.parser.table.TableParserMusicBrainz": "MusicBrainz label table of producers.", - "uk.ac.shef.dcs.sti.parser.table.TableParserWikipedia": "Wikipedia tables.", - "uk.ac.shef.dcs.sti.parser.table.TableParserLimayeDataset": "XML format used by Limaye et al. 2010." - } +{ + "lib": "../target/*", + "cache":"../resources/cache", + "tablePrevClass":"uk.ac.shef.dcs.sti.ui.InputFilePreview", + "stiMainClass":"uk.ac.shef.dcs.sti.ui.TableMinerPlusSingle", + "tmp":"tmp", + "error":"error.html", + "output":"output", + "log4j":"../config/log4j.properties", + "stipropfile":"../config/sti.properties", + "stiwebpropfile":"../config/websearch.properties", + "stikbpropfile":"../config/kbsearch.properties", + "server":"http://localhost:3000/", + "emaillogin":"", + "emailpass":"", + "emailhost":"smtp.googlemail.com", + "emailport":"465", + "emailfrom":"", + "tableParsers":{ + "uk.ac.shef.dcs.sti.parser.table.TableParserIMDB": "IMDB cast table of movie webpages.", + "uk.ac.shef.dcs.sti.parser.table.TableParserMusicBrainz": "MusicBrainz label table of producers.", + "uk.ac.shef.dcs.sti.parser.table.TableParserWikipedia": "Wikipedia tables.", + "uk.ac.shef.dcs.sti.parser.table.TableParserLimayeDataset": "XML format used by Limaye et al. 2010." + } } \ No newline at end of file diff --git a/ui/main.js b/ui/main.js index f0c3f628..4680e763 100644 --- a/ui/main.js +++ b/ui/main.js @@ -1,245 +1,245 @@ -var express = require('express'); -var app = express(); -var server = require('http').Server(app); -var io = require('socket.io')(server); -var fs = require('fs'); -var path = require('path'); - -var config = JSON.parse(fs.readFileSync('config.json', 'utf8')); - -var userTmpFolderMap={}; -var userCounter=1; - - -//$.getJSON( "/config.json", function( data ) { -var STI_LOG4J=config.log4j -var STI_LIB=config.lib; -var STI_CACHE=config.cache; -var STI_TABLE_FILE_PREVIEW_CLASS=config.tablePrevClass; -var STI_TMP_FOLDER=config.tmp; -var STI_ERROR_PAGE=config.error; -var STI_PROPERTY=config.stipropfile; -var STI_KB_PROPERTY=config.stikbpropfile; -var STI_WEB_PROPERTY=config.stiwebpropfile; -var STI_OUTPUT_FOLDER=config.output; -var STI_MAIN_CLASS=config.stiMainClass; -var STI_TABLE_PARSER_OPTIONS=config.tableParsers; -var SERVER_ADDRESS=config.server; -//}); - -function lock(userid){ - fd = fs.openSync(STI_CACHE+'/'+userid+'.lock', 'w'); -} - -function unlock(userid){ - fd = fs.unlinkSync(STI_CACHE+'/'+userid+'.lock'); -} - -function existLock(){ - var files = fs.readdirSync(STI_CACHE); - var foundFile='null'; - for(var i in files) { - if(path.extname(files[i]) === '.lock') { - return true; - } - } - return false; -} - -function getLocalUserId(socketId){ - return userTmpFolderMap[socketId]; -} -function addLocalUserId(socketId){ - userTmpFolderMap[socketId]='user'+userCounter; - userCounter++; -} - -function replaceAll(word, text, newWord){ - var pos = text.indexOf(word); - if(pos === -1) - return text; - var str1 = text.substr(0, pos); - var str2 = replaceAll(word, text.substr(pos+word.length), newWord); - return str1+newWord+str2; - } - -function writePreviewErrorPage(subfolder, errMsg){ - data='\n\n\n

Preview encountered problem, please contact your admin

\n' - +'

'+errMsg+'

'; - console.log("java_preview encoutered error, preparing error page..."); - fs.writeFileSync(subfolder+'/error.html', data); -} - -function javaPreview(userid, targetUrl, parserclass, fn){ - var spawn = require('child_process').spawn; - var subfolder=STI_TMP_FOLDER+'/'+userid; - var java = spawn('java', ['-Dlog4j.configuration=file:'+STI_LOG4J, '-cp', STI_LIB, STI_TABLE_FILE_PREVIEW_CLASS, targetUrl, subfolder, parserclass]); - - var error=''; - - java.stdout.on('data', function(data){ - console.log('stdout: %s', data); - error=error+"
"+replaceAll('\n',data.toString(),'
'); - }); - - java.stderr.on('data', function(data){ - console.log('stderr: %s',data); - error=error+"
"+replaceAll('\n',data.toString(),'
'); - }); - - var result; - java.on('close', function(code){ - var returnWebpage=subfolder+'/'+STI_ERROR_PAGE; - console.log('java process exited with code %s', code); - if(code==='1'){ - writePreviewErrorPage(subfolder, error); - }else{ - console.log('now find the file'); - var files = fs.readdirSync(subfolder); - var foundFile='null'; - for(var i in files) { - if(path.extname(files[i]) === '.html') { - foundFile=files[i]; - //console.log(foundFile.name); - break; - } - } - - if(foundFile!=='null'){ - returnWebpage=subfolder+'/'+foundFile.toString(); - } - } - //var xpaths = JSON.parse(fs.readFileSync(subfolder+'/xpaths.json', 'utf8')); - var xpathFile=subfolder+'/xpaths.json'; - if (!fs.existsSync(xpathFile)) - xpathFile=''; - result = [error,returnWebpage, xpathFile]; - - fn(result); - }); - -} - - -function javaSTI(userid, email, targetUrl, parserclass, selectedTableIndex, socket, fn){ - var spawn = require('child_process').spawn; - var java = spawn('java', ['-cp', STI_LIB, STI_MAIN_CLASS, userid, email, targetUrl, STI_OUTPUT_FOLDER, parserclass, selectedTableIndex, STI_PROPERTY, 'config.json', SERVER_ADDRESS]); - - var error=''; - - java.stdout.on('data', function(data){ - var txt=replaceAll('\n',data.toString(),'
')+'
'; - socket.emit('sti_info', {msg:txt}); - }); - - java.stderr.on('data', function(data){ - var txt=replaceAll('\n',data.toString(),'
')+'
'; - socket.emit('sti_err', {msg:txt}); - }); - - var result; - java.on('close', function(code){ - console.log('java process exited with code %s', code); - socket.emit('sti_complete', {msg:SERVER_ADDRESS+userid+"/index.htm"}); - fn(userid); - }); - -} - - -app.use(express.static('public')); -app.use('/tmp',express.static('tmp')); -app.use('/output',express.static('output')); - -app.get('/', function (req, res) { - res.sendFile("public/" + "index.html" ); -}); - - -io.of('/').on('connection', function(socket){ - socket.emit('filltableparseroptions',{options:STI_TABLE_PARSER_OPTIONS}); - - if(existLock()){ - socket.emit('warn_existingProcess', {msg:"TableMiner+ is already processing a task. If you start another task now it may corrupt its cache. This is because TableMiner+ caches remote query results locally and currently does not support concurrent access to the cache."}); - } - - addLocalUserId(socket.id); - var localUserId=getLocalUserId(socket.id); - - console.log('%s (localId=%s) is connected',socket.id, localUserId); - - function onPrevComplete(result){ - console.log(result); - socket.emit('java_preview_complete', {error: result[0], page: result[1], xpaths: result[2]}); - } - - socket.on('java_preview', function(data){ - console.log('%s preview request, %s, %s', localUserId, data.url, data.tableparserClass); - var result=javaPreview(localUserId, data.url, data.tableparserClass, onPrevComplete//see http://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call - ); - //console.log('$s preview response: %s', localUserId, result[0]); - //if result has error message, emit error - //else ... - }); - - function onSTIComplete(userid){ - console.log("%s task completed", userid); - unlock(userid); - } - - socket.on('java_sti', function(data){ - console.log('%s sti request, %s, %s, %s, tableIndexes[%s]', localUserId, data.url, data.email, - data.tableparserClass, data.tableIndexes); - lock(localUserId); - - //spawn the sti java process - javaSTI(localUserId, data.email, data.url, data.tableparserClass, data.tableIndexes, socket, onSTIComplete); - - }); - - socket.on('setting_tmp', function(data){ - //read config file - var fileContent = fs.readFileSync(STI_PROPERTY, "utf8"); - //send back result - this.emit('setting_tmp_content',{data:fileContent}); - }); - socket.on('setting_web', function(data){ - //read config file - var fileContent = fs.readFileSync(STI_WEB_PROPERTY, "utf8"); - //send back result - this.emit('setting_web_content',{data:fileContent}); - }); - socket.on('setting_kb', function(data){ - //read config file - var fileContent = fs.readFileSync(STI_KB_PROPERTY, "utf8"); - //send back result - this.emit('setting_kb_content',{data:fileContent}); - }); - - socket.on('configSave', function(data){ - //read config file - var fileContent = data.data; - var type=data.type; - //send back result - if(type==='tmp'){ - fs.writeFileSync(STI_PROPERTY,fileContent); - } - else if(type==='web'){ - fs.writeFileSync(STI_WEB_PROPERTY,fileContent); - }else if(type==='kb'){ - fs.writeFileSync(STI_KB_PROPERTY,fileContent); - } - }); -}); - - -server.listen(3000, function () { - console.log("Server started..."); - var host = server.address().address; - var port = server.address().port; - - console.log("Listening at http://%s:%s", host, port); - - -}); - +var express = require('express'); +var app = express(); +var server = require('http').Server(app); +var io = require('socket.io')(server); +var fs = require('fs'); +var path = require('path'); + +var config = JSON.parse(fs.readFileSync('config.json', 'utf8')); + +var userTmpFolderMap={}; +var userCounter=1; + + +//$.getJSON( "/config.json", function( data ) { +var STI_LOG4J=config.log4j +var STI_LIB=config.lib; +var STI_CACHE=config.cache; +var STI_TABLE_FILE_PREVIEW_CLASS=config.tablePrevClass; +var STI_TMP_FOLDER=config.tmp; +var STI_ERROR_PAGE=config.error; +var STI_PROPERTY=config.stipropfile; +var STI_KB_PROPERTY=config.stikbpropfile; +var STI_WEB_PROPERTY=config.stiwebpropfile; +var STI_OUTPUT_FOLDER=config.output; +var STI_MAIN_CLASS=config.stiMainClass; +var STI_TABLE_PARSER_OPTIONS=config.tableParsers; +var SERVER_ADDRESS=config.server; +//}); + +function lock(userid){ + fd = fs.openSync(STI_CACHE+'/'+userid+'.lock', 'w'); +} + +function unlock(userid){ + fd = fs.unlinkSync(STI_CACHE+'/'+userid+'.lock'); +} + +function existLock(){ + var files = fs.readdirSync(STI_CACHE); + var foundFile='null'; + for(var i in files) { + if(path.extname(files[i]) === '.lock') { + return true; + } + } + return false; +} + +function getLocalUserId(socketId){ + return userTmpFolderMap[socketId]; +} +function addLocalUserId(socketId){ + userTmpFolderMap[socketId]='user'+userCounter; + userCounter++; +} + +function replaceAll(word, text, newWord){ + var pos = text.indexOf(word); + if(pos === -1) + return text; + var str1 = text.substr(0, pos); + var str2 = replaceAll(word, text.substr(pos+word.length), newWord); + return str1+newWord+str2; + } + +function writePreviewErrorPage(subfolder, errMsg){ + data='\n\n\n

Preview encountered problem, please contact your admin

\n' + +'

'+errMsg+'

'; + console.log("java_preview encoutered error, preparing error page..."); + fs.writeFileSync(subfolder+'/error.html', data); +} + +function javaPreview(userid, targetUrl, parserclass, fn){ + var spawn = require('child_process').spawn; + var subfolder=STI_TMP_FOLDER+'/'+userid; + var java = spawn('java', ['-Dlog4j.configuration=file:'+STI_LOG4J, '-cp', STI_LIB, STI_TABLE_FILE_PREVIEW_CLASS, targetUrl, subfolder, parserclass]); + + var error=''; + + java.stdout.on('data', function(data){ + console.log('stdout: %s', data); + error=error+"
"+replaceAll('\n',data.toString(),'
'); + }); + + java.stderr.on('data', function(data){ + console.log('stderr: %s',data); + error=error+"
"+replaceAll('\n',data.toString(),'
'); + }); + + var result; + java.on('close', function(code){ + var returnWebpage=subfolder+'/'+STI_ERROR_PAGE; + console.log('java process exited with code %s', code); + if(code==='1'){ + writePreviewErrorPage(subfolder, error); + }else{ + console.log('now find the file'); + var files = fs.readdirSync(subfolder); + var foundFile='null'; + for(var i in files) { + if(path.extname(files[i]) === '.html') { + foundFile=files[i]; + //console.log(foundFile.name); + break; + } + } + + if(foundFile!=='null'){ + returnWebpage=subfolder+'/'+foundFile.toString(); + } + } + //var xpaths = JSON.parse(fs.readFileSync(subfolder+'/xpaths.json', 'utf8')); + var xpathFile=subfolder+'/xpaths.json'; + if (!fs.existsSync(xpathFile)) + xpathFile=''; + result = [error,returnWebpage, xpathFile]; + + fn(result); + }); + +} + + +function javaSTI(userid, email, targetUrl, parserclass, selectedTableIndex, socket, fn){ + var spawn = require('child_process').spawn; + var java = spawn('java', ['-cp', STI_LIB, STI_MAIN_CLASS, userid, email, targetUrl, STI_OUTPUT_FOLDER, parserclass, selectedTableIndex, STI_PROPERTY, 'config.json', SERVER_ADDRESS]); + + var error=''; + + java.stdout.on('data', function(data){ + var txt=replaceAll('\n',data.toString(),'
')+'
'; + socket.emit('sti_info', {msg:txt}); + }); + + java.stderr.on('data', function(data){ + var txt=replaceAll('\n',data.toString(),'
')+'
'; + socket.emit('sti_err', {msg:txt}); + }); + + var result; + java.on('close', function(code){ + console.log('java process exited with code %s', code); + socket.emit('sti_complete', {msg:SERVER_ADDRESS+userid+"/index.htm"}); + fn(userid); + }); + +} + + +app.use(express.static('public')); +app.use('/tmp',express.static('tmp')); +app.use('/output',express.static('output')); + +app.get('/', function (req, res) { + res.sendFile("public/" + "index.html" ); +}); + + +io.of('/').on('connection', function(socket){ + socket.emit('filltableparseroptions',{options:STI_TABLE_PARSER_OPTIONS}); + + if(existLock()){ + socket.emit('warn_existingProcess', {msg:"TableMiner+ is already processing a task. If you start another task now it may corrupt its cache. This is because TableMiner+ caches remote query results locally and currently does not support concurrent access to the cache."}); + } + + addLocalUserId(socket.id); + var localUserId=getLocalUserId(socket.id); + + console.log('%s (localId=%s) is connected',socket.id, localUserId); + + function onPrevComplete(result){ + console.log(result); + socket.emit('java_preview_complete', {error: result[0], page: result[1], xpaths: result[2]}); + } + + socket.on('java_preview', function(data){ + console.log('%s preview request, %s, %s', localUserId, data.url, data.tableparserClass); + var result=javaPreview(localUserId, data.url, data.tableparserClass, onPrevComplete//see http://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call + ); + //console.log('$s preview response: %s', localUserId, result[0]); + //if result has error message, emit error + //else ... + }); + + function onSTIComplete(userid){ + console.log("%s task completed", userid); + unlock(userid); + } + + socket.on('java_sti', function(data){ + console.log('%s sti request, %s, %s, %s, tableIndexes[%s]', localUserId, data.url, data.email, + data.tableparserClass, data.tableIndexes); + lock(localUserId); + + //spawn the sti java process + javaSTI(localUserId, data.email, data.url, data.tableparserClass, data.tableIndexes, socket, onSTIComplete); + + }); + + socket.on('setting_tmp', function(data){ + //read config file + var fileContent = fs.readFileSync(STI_PROPERTY, "utf8"); + //send back result + this.emit('setting_tmp_content',{data:fileContent}); + }); + socket.on('setting_web', function(data){ + //read config file + var fileContent = fs.readFileSync(STI_WEB_PROPERTY, "utf8"); + //send back result + this.emit('setting_web_content',{data:fileContent}); + }); + socket.on('setting_kb', function(data){ + //read config file + var fileContent = fs.readFileSync(STI_KB_PROPERTY, "utf8"); + //send back result + this.emit('setting_kb_content',{data:fileContent}); + }); + + socket.on('configSave', function(data){ + //read config file + var fileContent = data.data; + var type=data.type; + //send back result + if(type==='tmp'){ + fs.writeFileSync(STI_PROPERTY,fileContent); + } + else if(type==='web'){ + fs.writeFileSync(STI_WEB_PROPERTY,fileContent); + }else if(type==='kb'){ + fs.writeFileSync(STI_KB_PROPERTY,fileContent); + } + }); +}); + + +server.listen(3000, function () { + console.log("Server started..."); + var host = server.address().address; + var port = server.address().port; + + console.log("Listening at http://%s:%s", host, port); + + +}); + diff --git a/ui/nbproject/project.properties b/ui/nbproject/project.properties index 9ae72e53..481436ef 100644 --- a/ui/nbproject/project.properties +++ b/ui/nbproject/project.properties @@ -1,6 +1,6 @@ -auxiliary.org-netbeans-modules-javascript-nodejs.enabled=true -auxiliary.org-netbeans-modules-javascript-nodejs.start_2e_file=main.js -file.reference.ui-public=public -files.encoding=UTF-8 -site.root.folder=${file.reference.ui-public} -source.folder= +auxiliary.org-netbeans-modules-javascript-nodejs.enabled=true +auxiliary.org-netbeans-modules-javascript-nodejs.start_2e_file=main.js +file.reference.ui-public=public +files.encoding=UTF-8 +site.root.folder=${file.reference.ui-public} +source.folder= diff --git a/ui/nbproject/project.xml b/ui/nbproject/project.xml index 2a3ec5c3..fa58e633 100644 --- a/ui/nbproject/project.xml +++ b/ui/nbproject/project.xml @@ -1,9 +1,9 @@ - - - org.netbeans.modules.web.clientproject - - - ui - - - + + + org.netbeans.modules.web.clientproject + + + ui + + + diff --git a/ui/node_modules/express/History.md b/ui/node_modules/express/History.md index 1e7b14c2..40a5ed7e 100644 --- a/ui/node_modules/express/History.md +++ b/ui/node_modules/express/History.md @@ -1,3142 +1,3142 @@ -4.14.0 / 2016-06-16 -=================== - - * Add `acceptRanges` option to `res.sendFile`/`res.sendfile` - * Add `cacheControl` option to `res.sendFile`/`res.sendfile` - * Add `options` argument to `req.range` - - Includes the `combine` option - * Encode URL in `res.location`/`res.redirect` if not already encoded - * Fix some redirect handling in `res.sendFile`/`res.sendfile` - * Fix Windows absolute path check using forward slashes - * Improve error with invalid arguments to `req.get()` - * Improve performance for `res.json`/`res.jsonp` in most cases - * Improve `Range` header handling in `res.sendFile`/`res.sendfile` - * deps: accepts@~1.3.3 - - Fix including type extensions in parameters in `Accept` parsing - - Fix parsing `Accept` parameters with quoted equals - - Fix parsing `Accept` parameters with quoted semicolons - - Many performance improvments - - deps: mime-types@~2.1.11 - - deps: negotiator@0.6.1 - * deps: content-type@~1.0.2 - - perf: enable strict mode - * deps: cookie@0.3.1 - - Add `sameSite` option - - Fix cookie `Max-Age` to never be a floating point number - - Improve error message when `encode` is not a function - - Improve error message when `expires` is not a `Date` - - Throw better error for invalid argument to parse - - Throw on invalid values provided to `serialize` - - perf: enable strict mode - - perf: hoist regular expression - - perf: use for loop in parse - - perf: use string concatination for serialization - * deps: finalhandler@0.5.0 - - Change invalid or non-numeric status code to 500 - - Overwrite status message to match set status code - - Prefer `err.statusCode` if `err.status` is invalid - - Set response headers from `err.headers` object - - Use `statuses` instead of `http` module for status messages - * deps: proxy-addr@~1.1.2 - - Fix accepting various invalid netmasks - - Fix IPv6-mapped IPv4 validation edge cases - - IPv4 netmasks must be contingous - - IPv6 addresses cannot be used as a netmask - - deps: ipaddr.js@1.1.1 - * deps: qs@6.2.0 - - Add `decoder` option in `parse` function - * deps: range-parser@~1.2.0 - - Add `combine` option to combine overlapping ranges - - Fix incorrectly returning -1 when there is at least one valid range - - perf: remove internal function - * deps: send@0.14.1 - - Add `acceptRanges` option - - Add `cacheControl` option - - Attempt to combine multiple ranges into single range - - Correctly inherit from `Stream` class - - Fix `Content-Range` header in 416 responses when using `start`/`end` options - - Fix `Content-Range` header missing from default 416 responses - - Fix redirect error when `path` contains raw non-URL characters - - Fix redirect when `path` starts with multiple forward slashes - - Ignore non-byte `Range` headers - - deps: http-errors@~1.5.0 - - deps: range-parser@~1.2.0 - - deps: statuses@~1.3.0 - - perf: remove argument reassignment - * deps: serve-static@~1.11.1 - - Add `acceptRanges` option - - Add `cacheControl` option - - Attempt to combine multiple ranges into single range - - Fix redirect error when `req.url` contains raw non-URL characters - - Ignore non-byte `Range` headers - - Use status code 301 for redirects - - deps: send@0.14.1 - * deps: type-is@~1.6.13 - - Fix type error when given invalid type to match against - - deps: mime-types@~2.1.11 - * deps: vary@~1.1.0 - - Only accept valid field names in the `field` argument - * perf: use strict equality when possible - -4.13.4 / 2016-01-21 -=================== - - * deps: content-disposition@0.5.1 - - perf: enable strict mode - * deps: cookie@0.1.5 - - Throw on invalid values provided to `serialize` - * deps: depd@~1.1.0 - - Support web browser loading - - perf: enable strict mode - * deps: escape-html@~1.0.3 - - perf: enable strict mode - - perf: optimize string replacement - - perf: use faster string coercion - * deps: finalhandler@0.4.1 - - deps: escape-html@~1.0.3 - * deps: merge-descriptors@1.0.1 - - perf: enable strict mode - * deps: methods@~1.1.2 - - perf: enable strict mode - * deps: parseurl@~1.3.1 - - perf: enable strict mode - * deps: proxy-addr@~1.0.10 - - deps: ipaddr.js@1.0.5 - - perf: enable strict mode - * deps: range-parser@~1.0.3 - - perf: enable strict mode - * deps: send@0.13.1 - - deps: depd@~1.1.0 - - deps: destroy@~1.0.4 - - deps: escape-html@~1.0.3 - - deps: range-parser@~1.0.3 - * deps: serve-static@~1.10.2 - - deps: escape-html@~1.0.3 - - deps: parseurl@~1.3.0 - - deps: send@0.13.1 - -4.13.3 / 2015-08-02 -=================== - - * Fix infinite loop condition using `mergeParams: true` - * Fix inner numeric indices incorrectly altering parent `req.params` - -4.13.2 / 2015-07-31 -=================== - - * deps: accepts@~1.2.12 - - deps: mime-types@~2.1.4 - * deps: array-flatten@1.1.1 - - perf: enable strict mode - * deps: path-to-regexp@0.1.7 - - Fix regression with escaped round brackets and matching groups - * deps: type-is@~1.6.6 - - deps: mime-types@~2.1.4 - -4.13.1 / 2015-07-05 -=================== - - * deps: accepts@~1.2.10 - - deps: mime-types@~2.1.2 - * deps: qs@4.0.0 - - Fix dropping parameters like `hasOwnProperty` - - Fix various parsing edge cases - * deps: type-is@~1.6.4 - - deps: mime-types@~2.1.2 - - perf: enable strict mode - - perf: remove argument reassignment - -4.13.0 / 2015-06-20 -=================== - - * Add settings to debug output - * Fix `res.format` error when only `default` provided - * Fix issue where `next('route')` in `app.param` would incorrectly skip values - * Fix hiding platform issues with `decodeURIComponent` - - Only `URIError`s are a 400 - * Fix using `*` before params in routes - * Fix using capture groups before params in routes - * Simplify `res.cookie` to call `res.append` - * Use `array-flatten` module for flattening arrays - * deps: accepts@~1.2.9 - - deps: mime-types@~2.1.1 - - perf: avoid argument reassignment & argument slice - - perf: avoid negotiator recursive construction - - perf: enable strict mode - - perf: remove unnecessary bitwise operator - * deps: cookie@0.1.3 - - perf: deduce the scope of try-catch deopt - - perf: remove argument reassignments - * deps: escape-html@1.0.2 - * deps: etag@~1.7.0 - - Always include entity length in ETags for hash length extensions - - Generate non-Stats ETags using MD5 only (no longer CRC32) - - Improve stat performance by removing hashing - - Improve support for JXcore - - Remove base64 padding in ETags to shorten - - Support "fake" stats objects in environments without fs - - Use MD5 instead of MD4 in weak ETags over 1KB - * deps: finalhandler@0.4.0 - - Fix a false-positive when unpiping in Node.js 0.8 - - Support `statusCode` property on `Error` objects - - Use `unpipe` module for unpiping requests - - deps: escape-html@1.0.2 - - deps: on-finished@~2.3.0 - - perf: enable strict mode - - perf: remove argument reassignment - * deps: fresh@0.3.0 - - Add weak `ETag` matching support - * deps: on-finished@~2.3.0 - - Add defined behavior for HTTP `CONNECT` requests - - Add defined behavior for HTTP `Upgrade` requests - - deps: ee-first@1.1.1 - * deps: path-to-regexp@0.1.6 - * deps: send@0.13.0 - - Allow Node.js HTTP server to set `Date` response header - - Fix incorrectly removing `Content-Location` on 304 response - - Improve the default redirect response headers - - Send appropriate headers on default error response - - Use `http-errors` for standard emitted errors - - Use `statuses` instead of `http` module for status messages - - deps: escape-html@1.0.2 - - deps: etag@~1.7.0 - - deps: fresh@0.3.0 - - deps: on-finished@~2.3.0 - - perf: enable strict mode - - perf: remove unnecessary array allocations - * deps: serve-static@~1.10.0 - - Add `fallthrough` option - - Fix reading options from options prototype - - Improve the default redirect response headers - - Malformed URLs now `next()` instead of 400 - - deps: escape-html@1.0.2 - - deps: send@0.13.0 - - perf: enable strict mode - - perf: remove argument reassignment - * deps: type-is@~1.6.3 - - deps: mime-types@~2.1.1 - - perf: reduce try block size - - perf: remove bitwise operations - * perf: enable strict mode - * perf: isolate `app.render` try block - * perf: remove argument reassignments in application - * perf: remove argument reassignments in request prototype - * perf: remove argument reassignments in response prototype - * perf: remove argument reassignments in routing - * perf: remove argument reassignments in `View` - * perf: skip attempting to decode zero length string - * perf: use saved reference to `http.STATUS_CODES` - -4.12.4 / 2015-05-17 -=================== - - * deps: accepts@~1.2.7 - - deps: mime-types@~2.0.11 - - deps: negotiator@0.5.3 - * deps: debug@~2.2.0 - - deps: ms@0.7.1 - * deps: depd@~1.0.1 - * deps: etag@~1.6.0 - - Improve support for JXcore - - Support "fake" stats objects in environments without `fs` - * deps: finalhandler@0.3.6 - - deps: debug@~2.2.0 - - deps: on-finished@~2.2.1 - * deps: on-finished@~2.2.1 - - Fix `isFinished(req)` when data buffered - * deps: proxy-addr@~1.0.8 - - deps: ipaddr.js@1.0.1 - * deps: qs@2.4.2 - - Fix allowing parameters like `constructor` - * deps: send@0.12.3 - - deps: debug@~2.2.0 - - deps: depd@~1.0.1 - - deps: etag@~1.6.0 - - deps: ms@0.7.1 - - deps: on-finished@~2.2.1 - * deps: serve-static@~1.9.3 - - deps: send@0.12.3 - * deps: type-is@~1.6.2 - - deps: mime-types@~2.0.11 - -4.12.3 / 2015-03-17 -=================== - - * deps: accepts@~1.2.5 - - deps: mime-types@~2.0.10 - * deps: debug@~2.1.3 - - Fix high intensity foreground color for bold - - deps: ms@0.7.0 - * deps: finalhandler@0.3.4 - - deps: debug@~2.1.3 - * deps: proxy-addr@~1.0.7 - - deps: ipaddr.js@0.1.9 - * deps: qs@2.4.1 - - Fix error when parameter `hasOwnProperty` is present - * deps: send@0.12.2 - - Throw errors early for invalid `extensions` or `index` options - - deps: debug@~2.1.3 - * deps: serve-static@~1.9.2 - - deps: send@0.12.2 - * deps: type-is@~1.6.1 - - deps: mime-types@~2.0.10 - -4.12.2 / 2015-03-02 -=================== - - * Fix regression where `"Request aborted"` is logged using `res.sendFile` - -4.12.1 / 2015-03-01 -=================== - - * Fix constructing application with non-configurable prototype properties - * Fix `ECONNRESET` errors from `res.sendFile` usage - * Fix `req.host` when using "trust proxy" hops count - * Fix `req.protocol`/`req.secure` when using "trust proxy" hops count - * Fix wrong `code` on aborted connections from `res.sendFile` - * deps: merge-descriptors@1.0.0 - -4.12.0 / 2015-02-23 -=================== - - * Fix `"trust proxy"` setting to inherit when app is mounted - * Generate `ETag`s for all request responses - - No longer restricted to only responses for `GET` and `HEAD` requests - * Use `content-type` to parse `Content-Type` headers - * deps: accepts@~1.2.4 - - Fix preference sorting to be stable for long acceptable lists - - deps: mime-types@~2.0.9 - - deps: negotiator@0.5.1 - * deps: cookie-signature@1.0.6 - * deps: send@0.12.1 - - Always read the stat size from the file - - Fix mutating passed-in `options` - - deps: mime@1.3.4 - * deps: serve-static@~1.9.1 - - deps: send@0.12.1 - * deps: type-is@~1.6.0 - - fix argument reassignment - - fix false-positives in `hasBody` `Transfer-Encoding` check - - support wildcard for both type and subtype (`*/*`) - - deps: mime-types@~2.0.9 - -4.11.2 / 2015-02-01 -=================== - - * Fix `res.redirect` double-calling `res.end` for `HEAD` requests - * deps: accepts@~1.2.3 - - deps: mime-types@~2.0.8 - * deps: proxy-addr@~1.0.6 - - deps: ipaddr.js@0.1.8 - * deps: type-is@~1.5.6 - - deps: mime-types@~2.0.8 - -4.11.1 / 2015-01-20 -=================== - - * deps: send@0.11.1 - - Fix root path disclosure - * deps: serve-static@~1.8.1 - - Fix redirect loop in Node.js 0.11.14 - - Fix root path disclosure - - deps: send@0.11.1 - -4.11.0 / 2015-01-13 -=================== - - * Add `res.append(field, val)` to append headers - * Deprecate leading `:` in `name` for `app.param(name, fn)` - * Deprecate `req.param()` -- use `req.params`, `req.body`, or `req.query` instead - * Deprecate `app.param(fn)` - * Fix `OPTIONS` responses to include the `HEAD` method properly - * Fix `res.sendFile` not always detecting aborted connection - * Match routes iteratively to prevent stack overflows - * deps: accepts@~1.2.2 - - deps: mime-types@~2.0.7 - - deps: negotiator@0.5.0 - * deps: send@0.11.0 - - deps: debug@~2.1.1 - - deps: etag@~1.5.1 - - deps: ms@0.7.0 - - deps: on-finished@~2.2.0 - * deps: serve-static@~1.8.0 - - deps: send@0.11.0 - -4.10.8 / 2015-01-13 -=================== - - * Fix crash from error within `OPTIONS` response handler - * deps: proxy-addr@~1.0.5 - - deps: ipaddr.js@0.1.6 - -4.10.7 / 2015-01-04 -=================== - - * Fix `Allow` header for `OPTIONS` to not contain duplicate methods - * Fix incorrect "Request aborted" for `res.sendFile` when `HEAD` or 304 - * deps: debug@~2.1.1 - * deps: finalhandler@0.3.3 - - deps: debug@~2.1.1 - - deps: on-finished@~2.2.0 - * deps: methods@~1.1.1 - * deps: on-finished@~2.2.0 - * deps: serve-static@~1.7.2 - - Fix potential open redirect when mounted at root - * deps: type-is@~1.5.5 - - deps: mime-types@~2.0.7 - -4.10.6 / 2014-12-12 -=================== - - * Fix exception in `req.fresh`/`req.stale` without response headers - -4.10.5 / 2014-12-10 -=================== - - * Fix `res.send` double-calling `res.end` for `HEAD` requests - * deps: accepts@~1.1.4 - - deps: mime-types@~2.0.4 - * deps: type-is@~1.5.4 - - deps: mime-types@~2.0.4 - -4.10.4 / 2014-11-24 -=================== - - * Fix `res.sendfile` logging standard write errors - -4.10.3 / 2014-11-23 -=================== - - * Fix `res.sendFile` logging standard write errors - * deps: etag@~1.5.1 - * deps: proxy-addr@~1.0.4 - - deps: ipaddr.js@0.1.5 - * deps: qs@2.3.3 - - Fix `arrayLimit` behavior - -4.10.2 / 2014-11-09 -=================== - - * Correctly invoke async router callback asynchronously - * deps: accepts@~1.1.3 - - deps: mime-types@~2.0.3 - * deps: type-is@~1.5.3 - - deps: mime-types@~2.0.3 - -4.10.1 / 2014-10-28 -=================== - - * Fix handling of URLs containing `://` in the path - * deps: qs@2.3.2 - - Fix parsing of mixed objects and values - -4.10.0 / 2014-10-23 -=================== - - * Add support for `app.set('views', array)` - - Views are looked up in sequence in array of directories - * Fix `res.send(status)` to mention `res.sendStatus(status)` - * Fix handling of invalid empty URLs - * Use `content-disposition` module for `res.attachment`/`res.download` - - Sends standards-compliant `Content-Disposition` header - - Full Unicode support - * Use `path.resolve` in view lookup - * deps: debug@~2.1.0 - - Implement `DEBUG_FD` env variable support - * deps: depd@~1.0.0 - * deps: etag@~1.5.0 - - Improve string performance - - Slightly improve speed for weak ETags over 1KB - * deps: finalhandler@0.3.2 - - Terminate in progress response only on error - - Use `on-finished` to determine request status - - deps: debug@~2.1.0 - - deps: on-finished@~2.1.1 - * deps: on-finished@~2.1.1 - - Fix handling of pipelined requests - * deps: qs@2.3.0 - - Fix parsing of mixed implicit and explicit arrays - * deps: send@0.10.1 - - deps: debug@~2.1.0 - - deps: depd@~1.0.0 - - deps: etag@~1.5.0 - - deps: on-finished@~2.1.1 - * deps: serve-static@~1.7.1 - - deps: send@0.10.1 - -4.9.8 / 2014-10-17 -================== - - * Fix `res.redirect` body when redirect status specified - * deps: accepts@~1.1.2 - - Fix error when media type has invalid parameter - - deps: negotiator@0.4.9 - -4.9.7 / 2014-10-10 -================== - - * Fix using same param name in array of paths - -4.9.6 / 2014-10-08 -================== - - * deps: accepts@~1.1.1 - - deps: mime-types@~2.0.2 - - deps: negotiator@0.4.8 - * deps: serve-static@~1.6.4 - - Fix redirect loop when index file serving disabled - * deps: type-is@~1.5.2 - - deps: mime-types@~2.0.2 - -4.9.5 / 2014-09-24 -================== - - * deps: etag@~1.4.0 - * deps: proxy-addr@~1.0.3 - - Use `forwarded` npm module - * deps: send@0.9.3 - - deps: etag@~1.4.0 - * deps: serve-static@~1.6.3 - - deps: send@0.9.3 - -4.9.4 / 2014-09-19 -================== - - * deps: qs@2.2.4 - - Fix issue with object keys starting with numbers truncated - -4.9.3 / 2014-09-18 -================== - - * deps: proxy-addr@~1.0.2 - - Fix a global leak when multiple subnets are trusted - - deps: ipaddr.js@0.1.3 - -4.9.2 / 2014-09-17 -================== - - * Fix regression for empty string `path` in `app.use` - * Fix `router.use` to accept array of middleware without path - * Improve error message for bad `app.use` arguments - -4.9.1 / 2014-09-16 -================== - - * Fix `app.use` to accept array of middleware without path - * deps: depd@0.4.5 - * deps: etag@~1.3.1 - * deps: send@0.9.2 - - deps: depd@0.4.5 - - deps: etag@~1.3.1 - - deps: range-parser@~1.0.2 - * deps: serve-static@~1.6.2 - - deps: send@0.9.2 - -4.9.0 / 2014-09-08 -================== - - * Add `res.sendStatus` - * Invoke callback for sendfile when client aborts - - Applies to `res.sendFile`, `res.sendfile`, and `res.download` - - `err` will be populated with request aborted error - * Support IP address host in `req.subdomains` - * Use `etag` to generate `ETag` headers - * deps: accepts@~1.1.0 - - update `mime-types` - * deps: cookie-signature@1.0.5 - * deps: debug@~2.0.0 - * deps: finalhandler@0.2.0 - - Set `X-Content-Type-Options: nosniff` header - - deps: debug@~2.0.0 - * deps: fresh@0.2.4 - * deps: media-typer@0.3.0 - - Throw error when parameter format invalid on parse - * deps: qs@2.2.3 - - Fix issue where first empty value in array is discarded - * deps: range-parser@~1.0.2 - * deps: send@0.9.1 - - Add `lastModified` option - - Use `etag` to generate `ETag` header - - deps: debug@~2.0.0 - - deps: fresh@0.2.4 - * deps: serve-static@~1.6.1 - - Add `lastModified` option - - deps: send@0.9.1 - * deps: type-is@~1.5.1 - - fix `hasbody` to be true for `content-length: 0` - - deps: media-typer@0.3.0 - - deps: mime-types@~2.0.1 - * deps: vary@~1.0.0 - - Accept valid `Vary` header string as `field` - -4.8.8 / 2014-09-04 -================== - - * deps: send@0.8.5 - - Fix a path traversal issue when using `root` - - Fix malicious path detection for empty string path - * deps: serve-static@~1.5.4 - - deps: send@0.8.5 - -4.8.7 / 2014-08-29 -================== - - * deps: qs@2.2.2 - - Remove unnecessary cloning - -4.8.6 / 2014-08-27 -================== - - * deps: qs@2.2.0 - - Array parsing fix - - Performance improvements - -4.8.5 / 2014-08-18 -================== - - * deps: send@0.8.3 - - deps: destroy@1.0.3 - - deps: on-finished@2.1.0 - * deps: serve-static@~1.5.3 - - deps: send@0.8.3 - -4.8.4 / 2014-08-14 -================== - - * deps: qs@1.2.2 - * deps: send@0.8.2 - - Work around `fd` leak in Node.js 0.10 for `fs.ReadStream` - * deps: serve-static@~1.5.2 - - deps: send@0.8.2 - -4.8.3 / 2014-08-10 -================== - - * deps: parseurl@~1.3.0 - * deps: qs@1.2.1 - * deps: serve-static@~1.5.1 - - Fix parsing of weird `req.originalUrl` values - - deps: parseurl@~1.3.0 - - deps: utils-merge@1.0.0 - -4.8.2 / 2014-08-07 -================== - - * deps: qs@1.2.0 - - Fix parsing array of objects - -4.8.1 / 2014-08-06 -================== - - * fix incorrect deprecation warnings on `res.download` - * deps: qs@1.1.0 - - Accept urlencoded square brackets - - Accept empty values in implicit array notation - -4.8.0 / 2014-08-05 -================== - - * add `res.sendFile` - - accepts a file system path instead of a URL - - requires an absolute path or `root` option specified - * deprecate `res.sendfile` -- use `res.sendFile` instead - * support mounted app as any argument to `app.use()` - * deps: qs@1.0.2 - - Complete rewrite - - Limits array length to 20 - - Limits object depth to 5 - - Limits parameters to 1,000 - * deps: send@0.8.1 - - Add `extensions` option - * deps: serve-static@~1.5.0 - - Add `extensions` option - - deps: send@0.8.1 - -4.7.4 / 2014-08-04 -================== - - * fix `res.sendfile` regression for serving directory index files - * deps: send@0.7.4 - - Fix incorrect 403 on Windows and Node.js 0.11 - - Fix serving index files without root dir - * deps: serve-static@~1.4.4 - - deps: send@0.7.4 - -4.7.3 / 2014-08-04 -================== - - * deps: send@0.7.3 - - Fix incorrect 403 on Windows and Node.js 0.11 - * deps: serve-static@~1.4.3 - - Fix incorrect 403 on Windows and Node.js 0.11 - - deps: send@0.7.3 - -4.7.2 / 2014-07-27 -================== - - * deps: depd@0.4.4 - - Work-around v8 generating empty stack traces - * deps: send@0.7.2 - - deps: depd@0.4.4 - * deps: serve-static@~1.4.2 - -4.7.1 / 2014-07-26 -================== - - * deps: depd@0.4.3 - - Fix exception when global `Error.stackTraceLimit` is too low - * deps: send@0.7.1 - - deps: depd@0.4.3 - * deps: serve-static@~1.4.1 - -4.7.0 / 2014-07-25 -================== - - * fix `req.protocol` for proxy-direct connections - * configurable query parser with `app.set('query parser', parser)` - - `app.set('query parser', 'extended')` parse with "qs" module - - `app.set('query parser', 'simple')` parse with "querystring" core module - - `app.set('query parser', false)` disable query string parsing - - `app.set('query parser', true)` enable simple parsing - * deprecate `res.json(status, obj)` -- use `res.status(status).json(obj)` instead - * deprecate `res.jsonp(status, obj)` -- use `res.status(status).jsonp(obj)` instead - * deprecate `res.send(status, body)` -- use `res.status(status).send(body)` instead - * deps: debug@1.0.4 - * deps: depd@0.4.2 - - Add `TRACE_DEPRECATION` environment variable - - Remove non-standard grey color from color output - - Support `--no-deprecation` argument - - Support `--trace-deprecation` argument - * deps: finalhandler@0.1.0 - - Respond after request fully read - - deps: debug@1.0.4 - * deps: parseurl@~1.2.0 - - Cache URLs based on original value - - Remove no-longer-needed URL mis-parse work-around - - Simplify the "fast-path" `RegExp` - * deps: send@0.7.0 - - Add `dotfiles` option - - Cap `maxAge` value to 1 year - - deps: debug@1.0.4 - - deps: depd@0.4.2 - * deps: serve-static@~1.4.0 - - deps: parseurl@~1.2.0 - - deps: send@0.7.0 - * perf: prevent multiple `Buffer` creation in `res.send` - -4.6.1 / 2014-07-12 -================== - - * fix `subapp.mountpath` regression for `app.use(subapp)` - -4.6.0 / 2014-07-11 -================== - - * accept multiple callbacks to `app.use()` - * add explicit "Rosetta Flash JSONP abuse" protection - - previous versions are not vulnerable; this is just explicit protection - * catch errors in multiple `req.param(name, fn)` handlers - * deprecate `res.redirect(url, status)` -- use `res.redirect(status, url)` instead - * fix `res.send(status, num)` to send `num` as json (not error) - * remove unnecessary escaping when `res.jsonp` returns JSON response - * support non-string `path` in `app.use(path, fn)` - - supports array of paths - - supports `RegExp` - * router: fix optimization on router exit - * router: refactor location of `try` blocks - * router: speed up standard `app.use(fn)` - * deps: debug@1.0.3 - - Add support for multiple wildcards in namespaces - * deps: finalhandler@0.0.3 - - deps: debug@1.0.3 - * deps: methods@1.1.0 - - add `CONNECT` - * deps: parseurl@~1.1.3 - - faster parsing of href-only URLs - * deps: path-to-regexp@0.1.3 - * deps: send@0.6.0 - - deps: debug@1.0.3 - * deps: serve-static@~1.3.2 - - deps: parseurl@~1.1.3 - - deps: send@0.6.0 - * perf: fix arguments reassign deopt in some `res` methods - -4.5.1 / 2014-07-06 -================== - - * fix routing regression when altering `req.method` - -4.5.0 / 2014-07-04 -================== - - * add deprecation message to non-plural `req.accepts*` - * add deprecation message to `res.send(body, status)` - * add deprecation message to `res.vary()` - * add `headers` option to `res.sendfile` - - use to set headers on successful file transfer - * add `mergeParams` option to `Router` - - merges `req.params` from parent routes - * add `req.hostname` -- correct name for what `req.host` returns - * deprecate things with `depd` module - * deprecate `req.host` -- use `req.hostname` instead - * fix behavior when handling request without routes - * fix handling when `route.all` is only route - * invoke `router.param()` only when route matches - * restore `req.params` after invoking router - * use `finalhandler` for final response handling - * use `media-typer` to alter content-type charset - * deps: accepts@~1.0.7 - * deps: send@0.5.0 - - Accept string for `maxage` (converted by `ms`) - - Include link in default redirect response - * deps: serve-static@~1.3.0 - - Accept string for `maxAge` (converted by `ms`) - - Add `setHeaders` option - - Include HTML link in redirect response - - deps: send@0.5.0 - * deps: type-is@~1.3.2 - -4.4.5 / 2014-06-26 -================== - - * deps: cookie-signature@1.0.4 - - fix for timing attacks - -4.4.4 / 2014-06-20 -================== - - * fix `res.attachment` Unicode filenames in Safari - * fix "trim prefix" debug message in `express:router` - * deps: accepts@~1.0.5 - * deps: buffer-crc32@0.2.3 - -4.4.3 / 2014-06-11 -================== - - * fix persistence of modified `req.params[name]` from `app.param()` - * deps: accepts@1.0.3 - - deps: negotiator@0.4.6 - * deps: debug@1.0.2 - * deps: send@0.4.3 - - Do not throw un-catchable error on file open race condition - - Use `escape-html` for HTML escaping - - deps: debug@1.0.2 - - deps: finished@1.2.2 - - deps: fresh@0.2.2 - * deps: serve-static@1.2.3 - - Do not throw un-catchable error on file open race condition - - deps: send@0.4.3 - -4.4.2 / 2014-06-09 -================== - - * fix catching errors from top-level handlers - * use `vary` module for `res.vary` - * deps: debug@1.0.1 - * deps: proxy-addr@1.0.1 - * deps: send@0.4.2 - - fix "event emitter leak" warnings - - deps: debug@1.0.1 - - deps: finished@1.2.1 - * deps: serve-static@1.2.2 - - fix "event emitter leak" warnings - - deps: send@0.4.2 - * deps: type-is@1.2.1 - -4.4.1 / 2014-06-02 -================== - - * deps: methods@1.0.1 - * deps: send@0.4.1 - - Send `max-age` in `Cache-Control` in correct format - * deps: serve-static@1.2.1 - - use `escape-html` for escaping - - deps: send@0.4.1 - -4.4.0 / 2014-05-30 -================== - - * custom etag control with `app.set('etag', val)` - - `app.set('etag', function(body, encoding){ return '"etag"' })` custom etag generation - - `app.set('etag', 'weak')` weak tag - - `app.set('etag', 'strong')` strong etag - - `app.set('etag', false)` turn off - - `app.set('etag', true)` standard etag - * mark `res.send` ETag as weak and reduce collisions - * update accepts to 1.0.2 - - Fix interpretation when header not in request - * update send to 0.4.0 - - Calculate ETag with md5 for reduced collisions - - Ignore stream errors after request ends - - deps: debug@0.8.1 - * update serve-static to 1.2.0 - - Calculate ETag with md5 for reduced collisions - - Ignore stream errors after request ends - - deps: send@0.4.0 - -4.3.2 / 2014-05-28 -================== - - * fix handling of errors from `router.param()` callbacks - -4.3.1 / 2014-05-23 -================== - - * revert "fix behavior of multiple `app.VERB` for the same path" - - this caused a regression in the order of route execution - -4.3.0 / 2014-05-21 -================== - - * add `req.baseUrl` to access the path stripped from `req.url` in routes - * fix behavior of multiple `app.VERB` for the same path - * fix issue routing requests among sub routers - * invoke `router.param()` only when necessary instead of every match - * proper proxy trust with `app.set('trust proxy', trust)` - - `app.set('trust proxy', 1)` trust first hop - - `app.set('trust proxy', 'loopback')` trust loopback addresses - - `app.set('trust proxy', '10.0.0.1')` trust single IP - - `app.set('trust proxy', '10.0.0.1/16')` trust subnet - - `app.set('trust proxy', '10.0.0.1, 10.0.0.2')` trust list - - `app.set('trust proxy', false)` turn off - - `app.set('trust proxy', true)` trust everything - * set proper `charset` in `Content-Type` for `res.send` - * update type-is to 1.2.0 - - support suffix matching - -4.2.0 / 2014-05-11 -================== - - * deprecate `app.del()` -- use `app.delete()` instead - * deprecate `res.json(obj, status)` -- use `res.json(status, obj)` instead - - the edge-case `res.json(status, num)` requires `res.status(status).json(num)` - * deprecate `res.jsonp(obj, status)` -- use `res.jsonp(status, obj)` instead - - the edge-case `res.jsonp(status, num)` requires `res.status(status).jsonp(num)` - * fix `req.next` when inside router instance - * include `ETag` header in `HEAD` requests - * keep previous `Content-Type` for `res.jsonp` - * support PURGE method - - add `app.purge` - - add `router.purge` - - include PURGE in `app.all` - * update debug to 0.8.0 - - add `enable()` method - - change from stderr to stdout - * update methods to 1.0.0 - - add PURGE - -4.1.2 / 2014-05-08 -================== - - * fix `req.host` for IPv6 literals - * fix `res.jsonp` error if callback param is object - -4.1.1 / 2014-04-27 -================== - - * fix package.json to reflect supported node version - -4.1.0 / 2014-04-24 -================== - - * pass options from `res.sendfile` to `send` - * preserve casing of headers in `res.header` and `res.set` - * support unicode file names in `res.attachment` and `res.download` - * update accepts to 1.0.1 - - deps: negotiator@0.4.0 - * update cookie to 0.1.2 - - Fix for maxAge == 0 - - made compat with expires field - * update send to 0.3.0 - - Accept API options in options object - - Coerce option types - - Control whether to generate etags - - Default directory access to 403 when index disabled - - Fix sending files with dots without root set - - Include file path in etag - - Make "Can't set headers after they are sent." catchable - - Send full entity-body for multi range requests - - Set etags to "weak" - - Support "If-Range" header - - Support multiple index paths - - deps: mime@1.2.11 - * update serve-static to 1.1.0 - - Accept options directly to `send` module - - Resolve relative paths at middleware setup - - Use parseurl to parse the URL from request - - deps: send@0.3.0 - * update type-is to 1.1.0 - - add non-array values support - - add `multipart` as a shorthand - -4.0.0 / 2014-04-09 -================== - - * remove: - - node 0.8 support - - connect and connect's patches except for charset handling - - express(1) - moved to [express-generator](https://github.com/expressjs/generator) - - `express.createServer()` - it has been deprecated for a long time. Use `express()` - - `app.configure` - use logic in your own app code - - `app.router` - is removed - - `req.auth` - use `basic-auth` instead - - `req.accepted*` - use `req.accepts*()` instead - - `res.location` - relative URL resolution is removed - - `res.charset` - include the charset in the content type when using `res.set()` - - all bundled middleware except `static` - * change: - - `app.route` -> `app.mountpath` when mounting an express app in another express app - - `json spaces` no longer enabled by default in development - - `req.accepts*` -> `req.accepts*s` - i.e. `req.acceptsEncoding` -> `req.acceptsEncodings` - - `req.params` is now an object instead of an array - - `res.locals` is no longer a function. It is a plain js object. Treat it as such. - - `res.headerSent` -> `res.headersSent` to match node.js ServerResponse object - * refactor: - - `req.accepts*` with [accepts](https://github.com/expressjs/accepts) - - `req.is` with [type-is](https://github.com/expressjs/type-is) - - [path-to-regexp](https://github.com/component/path-to-regexp) - * add: - - `app.router()` - returns the app Router instance - - `app.route()` - Proxy to the app's `Router#route()` method to create a new route - - Router & Route - public API - -3.21.2 / 2015-07-31 -=================== - - * deps: connect@2.30.2 - - deps: body-parser@~1.13.3 - - deps: compression@~1.5.2 - - deps: errorhandler@~1.4.2 - - deps: method-override@~2.3.5 - - deps: serve-index@~1.7.2 - - deps: type-is@~1.6.6 - - deps: vhost@~3.0.1 - * deps: vary@~1.0.1 - - Fix setting empty header from empty `field` - - perf: enable strict mode - - perf: remove argument reassignments - -3.21.1 / 2015-07-05 -=================== - - * deps: basic-auth@~1.0.3 - * deps: connect@2.30.1 - - deps: body-parser@~1.13.2 - - deps: compression@~1.5.1 - - deps: errorhandler@~1.4.1 - - deps: morgan@~1.6.1 - - deps: pause@0.1.0 - - deps: qs@4.0.0 - - deps: serve-index@~1.7.1 - - deps: type-is@~1.6.4 - -3.21.0 / 2015-06-18 -=================== - - * deps: basic-auth@1.0.2 - - perf: enable strict mode - - perf: hoist regular expression - - perf: parse with regular expressions - - perf: remove argument reassignment - * deps: connect@2.30.0 - - deps: body-parser@~1.13.1 - - deps: bytes@2.1.0 - - deps: compression@~1.5.0 - - deps: cookie@0.1.3 - - deps: cookie-parser@~1.3.5 - - deps: csurf@~1.8.3 - - deps: errorhandler@~1.4.0 - - deps: express-session@~1.11.3 - - deps: finalhandler@0.4.0 - - deps: fresh@0.3.0 - - deps: morgan@~1.6.0 - - deps: serve-favicon@~2.3.0 - - deps: serve-index@~1.7.0 - - deps: serve-static@~1.10.0 - - deps: type-is@~1.6.3 - * deps: cookie@0.1.3 - - perf: deduce the scope of try-catch deopt - - perf: remove argument reassignments - * deps: escape-html@1.0.2 - * deps: etag@~1.7.0 - - Always include entity length in ETags for hash length extensions - - Generate non-Stats ETags using MD5 only (no longer CRC32) - - Improve stat performance by removing hashing - - Improve support for JXcore - - Remove base64 padding in ETags to shorten - - Support "fake" stats objects in environments without fs - - Use MD5 instead of MD4 in weak ETags over 1KB - * deps: fresh@0.3.0 - - Add weak `ETag` matching support - * deps: mkdirp@0.5.1 - - Work in global strict mode - * deps: send@0.13.0 - - Allow Node.js HTTP server to set `Date` response header - - Fix incorrectly removing `Content-Location` on 304 response - - Improve the default redirect response headers - - Send appropriate headers on default error response - - Use `http-errors` for standard emitted errors - - Use `statuses` instead of `http` module for status messages - - deps: escape-html@1.0.2 - - deps: etag@~1.7.0 - - deps: fresh@0.3.0 - - deps: on-finished@~2.3.0 - - perf: enable strict mode - - perf: remove unnecessary array allocations - -3.20.3 / 2015-05-17 -=================== - - * deps: connect@2.29.2 - - deps: body-parser@~1.12.4 - - deps: compression@~1.4.4 - - deps: connect-timeout@~1.6.2 - - deps: debug@~2.2.0 - - deps: depd@~1.0.1 - - deps: errorhandler@~1.3.6 - - deps: finalhandler@0.3.6 - - deps: method-override@~2.3.3 - - deps: morgan@~1.5.3 - - deps: qs@2.4.2 - - deps: response-time@~2.3.1 - - deps: serve-favicon@~2.2.1 - - deps: serve-index@~1.6.4 - - deps: serve-static@~1.9.3 - - deps: type-is@~1.6.2 - * deps: debug@~2.2.0 - - deps: ms@0.7.1 - * deps: depd@~1.0.1 - * deps: proxy-addr@~1.0.8 - - deps: ipaddr.js@1.0.1 - * deps: send@0.12.3 - - deps: debug@~2.2.0 - - deps: depd@~1.0.1 - - deps: etag@~1.6.0 - - deps: ms@0.7.1 - - deps: on-finished@~2.2.1 - -3.20.2 / 2015-03-16 -=================== - - * deps: connect@2.29.1 - - deps: body-parser@~1.12.2 - - deps: compression@~1.4.3 - - deps: connect-timeout@~1.6.1 - - deps: debug@~2.1.3 - - deps: errorhandler@~1.3.5 - - deps: express-session@~1.10.4 - - deps: finalhandler@0.3.4 - - deps: method-override@~2.3.2 - - deps: morgan@~1.5.2 - - deps: qs@2.4.1 - - deps: serve-index@~1.6.3 - - deps: serve-static@~1.9.2 - - deps: type-is@~1.6.1 - * deps: debug@~2.1.3 - - Fix high intensity foreground color for bold - - deps: ms@0.7.0 - * deps: merge-descriptors@1.0.0 - * deps: proxy-addr@~1.0.7 - - deps: ipaddr.js@0.1.9 - * deps: send@0.12.2 - - Throw errors early for invalid `extensions` or `index` options - - deps: debug@~2.1.3 - -3.20.1 / 2015-02-28 -=================== - - * Fix `req.host` when using "trust proxy" hops count - * Fix `req.protocol`/`req.secure` when using "trust proxy" hops count - -3.20.0 / 2015-02-18 -=================== - - * Fix `"trust proxy"` setting to inherit when app is mounted - * Generate `ETag`s for all request responses - - No longer restricted to only responses for `GET` and `HEAD` requests - * Use `content-type` to parse `Content-Type` headers - * deps: connect@2.29.0 - - Use `content-type` to parse `Content-Type` headers - - deps: body-parser@~1.12.0 - - deps: compression@~1.4.1 - - deps: connect-timeout@~1.6.0 - - deps: cookie-parser@~1.3.4 - - deps: cookie-signature@1.0.6 - - deps: csurf@~1.7.0 - - deps: errorhandler@~1.3.4 - - deps: express-session@~1.10.3 - - deps: http-errors@~1.3.1 - - deps: response-time@~2.3.0 - - deps: serve-index@~1.6.2 - - deps: serve-static@~1.9.1 - - deps: type-is@~1.6.0 - * deps: cookie-signature@1.0.6 - * deps: send@0.12.1 - - Always read the stat size from the file - - Fix mutating passed-in `options` - - deps: mime@1.3.4 - -3.19.2 / 2015-02-01 -=================== - - * deps: connect@2.28.3 - - deps: compression@~1.3.1 - - deps: csurf@~1.6.6 - - deps: errorhandler@~1.3.3 - - deps: express-session@~1.10.2 - - deps: serve-index@~1.6.1 - - deps: type-is@~1.5.6 - * deps: proxy-addr@~1.0.6 - - deps: ipaddr.js@0.1.8 - -3.19.1 / 2015-01-20 -=================== - - * deps: connect@2.28.2 - - deps: body-parser@~1.10.2 - - deps: serve-static@~1.8.1 - * deps: send@0.11.1 - - Fix root path disclosure - -3.19.0 / 2015-01-09 -=================== - - * Fix `OPTIONS` responses to include the `HEAD` method property - * Use `readline` for prompt in `express(1)` - * deps: commander@2.6.0 - * deps: connect@2.28.1 - - deps: body-parser@~1.10.1 - - deps: compression@~1.3.0 - - deps: connect-timeout@~1.5.0 - - deps: csurf@~1.6.4 - - deps: debug@~2.1.1 - - deps: errorhandler@~1.3.2 - - deps: express-session@~1.10.1 - - deps: finalhandler@0.3.3 - - deps: method-override@~2.3.1 - - deps: morgan@~1.5.1 - - deps: serve-favicon@~2.2.0 - - deps: serve-index@~1.6.0 - - deps: serve-static@~1.8.0 - - deps: type-is@~1.5.5 - * deps: debug@~2.1.1 - * deps: methods@~1.1.1 - * deps: proxy-addr@~1.0.5 - - deps: ipaddr.js@0.1.6 - * deps: send@0.11.0 - - deps: debug@~2.1.1 - - deps: etag@~1.5.1 - - deps: ms@0.7.0 - - deps: on-finished@~2.2.0 - -3.18.6 / 2014-12-12 -=================== - - * Fix exception in `req.fresh`/`req.stale` without response headers - -3.18.5 / 2014-12-11 -=================== - - * deps: connect@2.27.6 - - deps: compression@~1.2.2 - - deps: express-session@~1.9.3 - - deps: http-errors@~1.2.8 - - deps: serve-index@~1.5.3 - - deps: type-is@~1.5.4 - -3.18.4 / 2014-11-23 -=================== - - * deps: connect@2.27.4 - - deps: body-parser@~1.9.3 - - deps: compression@~1.2.1 - - deps: errorhandler@~1.2.3 - - deps: express-session@~1.9.2 - - deps: qs@2.3.3 - - deps: serve-favicon@~2.1.7 - - deps: serve-static@~1.5.1 - - deps: type-is@~1.5.3 - * deps: etag@~1.5.1 - * deps: proxy-addr@~1.0.4 - - deps: ipaddr.js@0.1.5 - -3.18.3 / 2014-11-09 -=================== - - * deps: connect@2.27.3 - - Correctly invoke async callback asynchronously - - deps: csurf@~1.6.3 - -3.18.2 / 2014-10-28 -=================== - - * deps: connect@2.27.2 - - Fix handling of URLs containing `://` in the path - - deps: body-parser@~1.9.2 - - deps: qs@2.3.2 - -3.18.1 / 2014-10-22 -=================== - - * Fix internal `utils.merge` deprecation warnings - * deps: connect@2.27.1 - - deps: body-parser@~1.9.1 - - deps: express-session@~1.9.1 - - deps: finalhandler@0.3.2 - - deps: morgan@~1.4.1 - - deps: qs@2.3.0 - - deps: serve-static@~1.7.1 - * deps: send@0.10.1 - - deps: on-finished@~2.1.1 - -3.18.0 / 2014-10-17 -=================== - - * Use `content-disposition` module for `res.attachment`/`res.download` - - Sends standards-compliant `Content-Disposition` header - - Full Unicode support - * Use `etag` module to generate `ETag` headers - * deps: connect@2.27.0 - - Use `http-errors` module for creating errors - - Use `utils-merge` module for merging objects - - deps: body-parser@~1.9.0 - - deps: compression@~1.2.0 - - deps: connect-timeout@~1.4.0 - - deps: debug@~2.1.0 - - deps: depd@~1.0.0 - - deps: express-session@~1.9.0 - - deps: finalhandler@0.3.1 - - deps: method-override@~2.3.0 - - deps: morgan@~1.4.0 - - deps: response-time@~2.2.0 - - deps: serve-favicon@~2.1.6 - - deps: serve-index@~1.5.0 - - deps: serve-static@~1.7.0 - * deps: debug@~2.1.0 - - Implement `DEBUG_FD` env variable support - * deps: depd@~1.0.0 - * deps: send@0.10.0 - - deps: debug@~2.1.0 - - deps: depd@~1.0.0 - - deps: etag@~1.5.0 - -3.17.8 / 2014-10-15 -=================== - - * deps: connect@2.26.6 - - deps: compression@~1.1.2 - - deps: csurf@~1.6.2 - - deps: errorhandler@~1.2.2 - -3.17.7 / 2014-10-08 -=================== - - * deps: connect@2.26.5 - - Fix accepting non-object arguments to `logger` - - deps: serve-static@~1.6.4 - -3.17.6 / 2014-10-02 -=================== - - * deps: connect@2.26.4 - - deps: morgan@~1.3.2 - - deps: type-is@~1.5.2 - -3.17.5 / 2014-09-24 -=================== - - * deps: connect@2.26.3 - - deps: body-parser@~1.8.4 - - deps: serve-favicon@~2.1.5 - - deps: serve-static@~1.6.3 - * deps: proxy-addr@~1.0.3 - - Use `forwarded` npm module - * deps: send@0.9.3 - - deps: etag@~1.4.0 - -3.17.4 / 2014-09-19 -=================== - - * deps: connect@2.26.2 - - deps: body-parser@~1.8.3 - - deps: qs@2.2.4 - -3.17.3 / 2014-09-18 -=================== - - * deps: proxy-addr@~1.0.2 - - Fix a global leak when multiple subnets are trusted - - deps: ipaddr.js@0.1.3 - -3.17.2 / 2014-09-15 -=================== - - * Use `crc` instead of `buffer-crc32` for speed - * deps: connect@2.26.1 - - deps: body-parser@~1.8.2 - - deps: depd@0.4.5 - - deps: express-session@~1.8.2 - - deps: morgan@~1.3.1 - - deps: serve-favicon@~2.1.3 - - deps: serve-static@~1.6.2 - * deps: depd@0.4.5 - * deps: send@0.9.2 - - deps: depd@0.4.5 - - deps: etag@~1.3.1 - - deps: range-parser@~1.0.2 - -3.17.1 / 2014-09-08 -=================== - - * Fix error in `req.subdomains` on empty host - -3.17.0 / 2014-09-08 -=================== - - * Support `X-Forwarded-Host` in `req.subdomains` - * Support IP address host in `req.subdomains` - * deps: connect@2.26.0 - - deps: body-parser@~1.8.1 - - deps: compression@~1.1.0 - - deps: connect-timeout@~1.3.0 - - deps: cookie-parser@~1.3.3 - - deps: cookie-signature@1.0.5 - - deps: csurf@~1.6.1 - - deps: debug@~2.0.0 - - deps: errorhandler@~1.2.0 - - deps: express-session@~1.8.1 - - deps: finalhandler@0.2.0 - - deps: fresh@0.2.4 - - deps: media-typer@0.3.0 - - deps: method-override@~2.2.0 - - deps: morgan@~1.3.0 - - deps: qs@2.2.3 - - deps: serve-favicon@~2.1.3 - - deps: serve-index@~1.2.1 - - deps: serve-static@~1.6.1 - - deps: type-is@~1.5.1 - - deps: vhost@~3.0.0 - * deps: cookie-signature@1.0.5 - * deps: debug@~2.0.0 - * deps: fresh@0.2.4 - * deps: media-typer@0.3.0 - - Throw error when parameter format invalid on parse - * deps: range-parser@~1.0.2 - * deps: send@0.9.1 - - Add `lastModified` option - - Use `etag` to generate `ETag` header - - deps: debug@~2.0.0 - - deps: fresh@0.2.4 - * deps: vary@~1.0.0 - - Accept valid `Vary` header string as `field` - -3.16.10 / 2014-09-04 -==================== - - * deps: connect@2.25.10 - - deps: serve-static@~1.5.4 - * deps: send@0.8.5 - - Fix a path traversal issue when using `root` - - Fix malicious path detection for empty string path - -3.16.9 / 2014-08-29 -=================== - - * deps: connect@2.25.9 - - deps: body-parser@~1.6.7 - - deps: qs@2.2.2 - -3.16.8 / 2014-08-27 -=================== - - * deps: connect@2.25.8 - - deps: body-parser@~1.6.6 - - deps: csurf@~1.4.1 - - deps: qs@2.2.0 - -3.16.7 / 2014-08-18 -=================== - - * deps: connect@2.25.7 - - deps: body-parser@~1.6.5 - - deps: express-session@~1.7.6 - - deps: morgan@~1.2.3 - - deps: serve-static@~1.5.3 - * deps: send@0.8.3 - - deps: destroy@1.0.3 - - deps: on-finished@2.1.0 - -3.16.6 / 2014-08-14 -=================== - - * deps: connect@2.25.6 - - deps: body-parser@~1.6.4 - - deps: qs@1.2.2 - - deps: serve-static@~1.5.2 - * deps: send@0.8.2 - - Work around `fd` leak in Node.js 0.10 for `fs.ReadStream` - -3.16.5 / 2014-08-11 -=================== - - * deps: connect@2.25.5 - - Fix backwards compatibility in `logger` - -3.16.4 / 2014-08-10 -=================== - - * Fix original URL parsing in `res.location` - * deps: connect@2.25.4 - - Fix `query` middleware breaking with argument - - deps: body-parser@~1.6.3 - - deps: compression@~1.0.11 - - deps: connect-timeout@~1.2.2 - - deps: express-session@~1.7.5 - - deps: method-override@~2.1.3 - - deps: on-headers@~1.0.0 - - deps: parseurl@~1.3.0 - - deps: qs@1.2.1 - - deps: response-time@~2.0.1 - - deps: serve-index@~1.1.6 - - deps: serve-static@~1.5.1 - * deps: parseurl@~1.3.0 - -3.16.3 / 2014-08-07 -=================== - - * deps: connect@2.25.3 - - deps: multiparty@3.3.2 - -3.16.2 / 2014-08-07 -=================== - - * deps: connect@2.25.2 - - deps: body-parser@~1.6.2 - - deps: qs@1.2.0 - -3.16.1 / 2014-08-06 -=================== - - * deps: connect@2.25.1 - - deps: body-parser@~1.6.1 - - deps: qs@1.1.0 - -3.16.0 / 2014-08-05 -=================== - - * deps: connect@2.25.0 - - deps: body-parser@~1.6.0 - - deps: compression@~1.0.10 - - deps: csurf@~1.4.0 - - deps: express-session@~1.7.4 - - deps: qs@1.0.2 - - deps: serve-static@~1.5.0 - * deps: send@0.8.1 - - Add `extensions` option - -3.15.3 / 2014-08-04 -=================== - - * fix `res.sendfile` regression for serving directory index files - * deps: connect@2.24.3 - - deps: serve-index@~1.1.5 - - deps: serve-static@~1.4.4 - * deps: send@0.7.4 - - Fix incorrect 403 on Windows and Node.js 0.11 - - Fix serving index files without root dir - -3.15.2 / 2014-07-27 -=================== - - * deps: connect@2.24.2 - - deps: body-parser@~1.5.2 - - deps: depd@0.4.4 - - deps: express-session@~1.7.2 - - deps: morgan@~1.2.2 - - deps: serve-static@~1.4.2 - * deps: depd@0.4.4 - - Work-around v8 generating empty stack traces - * deps: send@0.7.2 - - deps: depd@0.4.4 - -3.15.1 / 2014-07-26 -=================== - - * deps: connect@2.24.1 - - deps: body-parser@~1.5.1 - - deps: depd@0.4.3 - - deps: express-session@~1.7.1 - - deps: morgan@~1.2.1 - - deps: serve-index@~1.1.4 - - deps: serve-static@~1.4.1 - * deps: depd@0.4.3 - - Fix exception when global `Error.stackTraceLimit` is too low - * deps: send@0.7.1 - - deps: depd@0.4.3 - -3.15.0 / 2014-07-22 -=================== - - * Fix `req.protocol` for proxy-direct connections - * Pass options from `res.sendfile` to `send` - * deps: connect@2.24.0 - - deps: body-parser@~1.5.0 - - deps: compression@~1.0.9 - - deps: connect-timeout@~1.2.1 - - deps: debug@1.0.4 - - deps: depd@0.4.2 - - deps: express-session@~1.7.0 - - deps: finalhandler@0.1.0 - - deps: method-override@~2.1.2 - - deps: morgan@~1.2.0 - - deps: multiparty@3.3.1 - - deps: parseurl@~1.2.0 - - deps: serve-static@~1.4.0 - * deps: debug@1.0.4 - * deps: depd@0.4.2 - - Add `TRACE_DEPRECATION` environment variable - - Remove non-standard grey color from color output - - Support `--no-deprecation` argument - - Support `--trace-deprecation` argument - * deps: parseurl@~1.2.0 - - Cache URLs based on original value - - Remove no-longer-needed URL mis-parse work-around - - Simplify the "fast-path" `RegExp` - * deps: send@0.7.0 - - Add `dotfiles` option - - Cap `maxAge` value to 1 year - - deps: debug@1.0.4 - - deps: depd@0.4.2 - -3.14.0 / 2014-07-11 -=================== - - * add explicit "Rosetta Flash JSONP abuse" protection - - previous versions are not vulnerable; this is just explicit protection - * deprecate `res.redirect(url, status)` -- use `res.redirect(status, url)` instead - * fix `res.send(status, num)` to send `num` as json (not error) - * remove unnecessary escaping when `res.jsonp` returns JSON response - * deps: basic-auth@1.0.0 - - support empty password - - support empty username - * deps: connect@2.23.0 - - deps: debug@1.0.3 - - deps: express-session@~1.6.4 - - deps: method-override@~2.1.0 - - deps: parseurl@~1.1.3 - - deps: serve-static@~1.3.1 - * deps: debug@1.0.3 - - Add support for multiple wildcards in namespaces - * deps: methods@1.1.0 - - add `CONNECT` - * deps: parseurl@~1.1.3 - - faster parsing of href-only URLs - -3.13.0 / 2014-07-03 -=================== - - * add deprecation message to `app.configure` - * add deprecation message to `req.auth` - * use `basic-auth` to parse `Authorization` header - * deps: connect@2.22.0 - - deps: csurf@~1.3.0 - - deps: express-session@~1.6.1 - - deps: multiparty@3.3.0 - - deps: serve-static@~1.3.0 - * deps: send@0.5.0 - - Accept string for `maxage` (converted by `ms`) - - Include link in default redirect response - -3.12.1 / 2014-06-26 -=================== - - * deps: connect@2.21.1 - - deps: cookie-parser@1.3.2 - - deps: cookie-signature@1.0.4 - - deps: express-session@~1.5.2 - - deps: type-is@~1.3.2 - * deps: cookie-signature@1.0.4 - - fix for timing attacks - -3.12.0 / 2014-06-21 -=================== - - * use `media-typer` to alter content-type charset - * deps: connect@2.21.0 - - deprecate `connect(middleware)` -- use `app.use(middleware)` instead - - deprecate `connect.createServer()` -- use `connect()` instead - - fix `res.setHeader()` patch to work with with get -> append -> set pattern - - deps: compression@~1.0.8 - - deps: errorhandler@~1.1.1 - - deps: express-session@~1.5.0 - - deps: serve-index@~1.1.3 - -3.11.0 / 2014-06-19 -=================== - - * deprecate things with `depd` module - * deps: buffer-crc32@0.2.3 - * deps: connect@2.20.2 - - deprecate `verify` option to `json` -- use `body-parser` npm module instead - - deprecate `verify` option to `urlencoded` -- use `body-parser` npm module instead - - deprecate things with `depd` module - - use `finalhandler` for final response handling - - use `media-typer` to parse `content-type` for charset - - deps: body-parser@1.4.3 - - deps: connect-timeout@1.1.1 - - deps: cookie-parser@1.3.1 - - deps: csurf@1.2.2 - - deps: errorhandler@1.1.0 - - deps: express-session@1.4.0 - - deps: multiparty@3.2.9 - - deps: serve-index@1.1.2 - - deps: type-is@1.3.1 - - deps: vhost@2.0.0 - -3.10.5 / 2014-06-11 -=================== - - * deps: connect@2.19.6 - - deps: body-parser@1.3.1 - - deps: compression@1.0.7 - - deps: debug@1.0.2 - - deps: serve-index@1.1.1 - - deps: serve-static@1.2.3 - * deps: debug@1.0.2 - * deps: send@0.4.3 - - Do not throw un-catchable error on file open race condition - - Use `escape-html` for HTML escaping - - deps: debug@1.0.2 - - deps: finished@1.2.2 - - deps: fresh@0.2.2 - -3.10.4 / 2014-06-09 -=================== - - * deps: connect@2.19.5 - - fix "event emitter leak" warnings - - deps: csurf@1.2.1 - - deps: debug@1.0.1 - - deps: serve-static@1.2.2 - - deps: type-is@1.2.1 - * deps: debug@1.0.1 - * deps: send@0.4.2 - - fix "event emitter leak" warnings - - deps: finished@1.2.1 - - deps: debug@1.0.1 - -3.10.3 / 2014-06-05 -=================== - - * use `vary` module for `res.vary` - * deps: connect@2.19.4 - - deps: errorhandler@1.0.2 - - deps: method-override@2.0.2 - - deps: serve-favicon@2.0.1 - * deps: debug@1.0.0 - -3.10.2 / 2014-06-03 -=================== - - * deps: connect@2.19.3 - - deps: compression@1.0.6 - -3.10.1 / 2014-06-03 -=================== - - * deps: connect@2.19.2 - - deps: compression@1.0.4 - * deps: proxy-addr@1.0.1 - -3.10.0 / 2014-06-02 -=================== - - * deps: connect@2.19.1 - - deprecate `methodOverride()` -- use `method-override` npm module instead - - deps: body-parser@1.3.0 - - deps: method-override@2.0.1 - - deps: multiparty@3.2.8 - - deps: response-time@2.0.0 - - deps: serve-static@1.2.1 - * deps: methods@1.0.1 - * deps: send@0.4.1 - - Send `max-age` in `Cache-Control` in correct format - -3.9.0 / 2014-05-30 -================== - - * custom etag control with `app.set('etag', val)` - - `app.set('etag', function(body, encoding){ return '"etag"' })` custom etag generation - - `app.set('etag', 'weak')` weak tag - - `app.set('etag', 'strong')` strong etag - - `app.set('etag', false)` turn off - - `app.set('etag', true)` standard etag - * Include ETag in HEAD requests - * mark `res.send` ETag as weak and reduce collisions - * update connect to 2.18.0 - - deps: compression@1.0.3 - - deps: serve-index@1.1.0 - - deps: serve-static@1.2.0 - * update send to 0.4.0 - - Calculate ETag with md5 for reduced collisions - - Ignore stream errors after request ends - - deps: debug@0.8.1 - -3.8.1 / 2014-05-27 -================== - - * update connect to 2.17.3 - - deps: body-parser@1.2.2 - - deps: express-session@1.2.1 - - deps: method-override@1.0.2 - -3.8.0 / 2014-05-21 -================== - - * keep previous `Content-Type` for `res.jsonp` - * set proper `charset` in `Content-Type` for `res.send` - * update connect to 2.17.1 - - fix `res.charset` appending charset when `content-type` has one - - deps: express-session@1.2.0 - - deps: morgan@1.1.1 - - deps: serve-index@1.0.3 - -3.7.0 / 2014-05-18 -================== - - * proper proxy trust with `app.set('trust proxy', trust)` - - `app.set('trust proxy', 1)` trust first hop - - `app.set('trust proxy', 'loopback')` trust loopback addresses - - `app.set('trust proxy', '10.0.0.1')` trust single IP - - `app.set('trust proxy', '10.0.0.1/16')` trust subnet - - `app.set('trust proxy', '10.0.0.1, 10.0.0.2')` trust list - - `app.set('trust proxy', false)` turn off - - `app.set('trust proxy', true)` trust everything - * update connect to 2.16.2 - - deprecate `res.headerSent` -- use `res.headersSent` - - deprecate `res.on("header")` -- use on-headers module instead - - fix edge-case in `res.appendHeader` that would append in wrong order - - json: use body-parser - - urlencoded: use body-parser - - dep: bytes@1.0.0 - - dep: cookie-parser@1.1.0 - - dep: csurf@1.2.0 - - dep: express-session@1.1.0 - - dep: method-override@1.0.1 - -3.6.0 / 2014-05-09 -================== - - * deprecate `app.del()` -- use `app.delete()` instead - * deprecate `res.json(obj, status)` -- use `res.json(status, obj)` instead - - the edge-case `res.json(status, num)` requires `res.status(status).json(num)` - * deprecate `res.jsonp(obj, status)` -- use `res.jsonp(status, obj)` instead - - the edge-case `res.jsonp(status, num)` requires `res.status(status).jsonp(num)` - * support PURGE method - - add `app.purge` - - add `router.purge` - - include PURGE in `app.all` - * update connect to 2.15.0 - * Add `res.appendHeader` - * Call error stack even when response has been sent - * Patch `res.headerSent` to return Boolean - * Patch `res.headersSent` for node.js 0.8 - * Prevent default 404 handler after response sent - * dep: compression@1.0.2 - * dep: connect-timeout@1.1.0 - * dep: debug@^0.8.0 - * dep: errorhandler@1.0.1 - * dep: express-session@1.0.4 - * dep: morgan@1.0.1 - * dep: serve-favicon@2.0.0 - * dep: serve-index@1.0.2 - * update debug to 0.8.0 - * add `enable()` method - * change from stderr to stdout - * update methods to 1.0.0 - - add PURGE - * update mkdirp to 0.5.0 - -3.5.3 / 2014-05-08 -================== - - * fix `req.host` for IPv6 literals - * fix `res.jsonp` error if callback param is object - -3.5.2 / 2014-04-24 -================== - - * update connect to 2.14.5 - * update cookie to 0.1.2 - * update mkdirp to 0.4.0 - * update send to 0.3.0 - -3.5.1 / 2014-03-25 -================== - - * pin less-middleware in generated app - -3.5.0 / 2014-03-06 -================== - - * bump deps - -3.4.8 / 2014-01-13 -================== - - * prevent incorrect automatic OPTIONS responses #1868 @dpatti - * update binary and examples for jade 1.0 #1876 @yossi, #1877 @reqshark, #1892 @matheusazzi - * throw 400 in case of malformed paths @rlidwka - -3.4.7 / 2013-12-10 -================== - - * update connect - -3.4.6 / 2013-12-01 -================== - - * update connect (raw-body) - -3.4.5 / 2013-11-27 -================== - - * update connect - * res.location: remove leading ./ #1802 @kapouer - * res.redirect: fix `res.redirect('toString') #1829 @michaelficarra - * res.send: always send ETag when content-length > 0 - * router: add Router.all() method - -3.4.4 / 2013-10-29 -================== - - * update connect - * update supertest - * update methods - * express(1): replace bodyParser() with urlencoded() and json() #1795 @chirag04 - -3.4.3 / 2013-10-23 -================== - - * update connect - -3.4.2 / 2013-10-18 -================== - - * update connect - * downgrade commander - -3.4.1 / 2013-10-15 -================== - - * update connect - * update commander - * jsonp: check if callback is a function - * router: wrap encodeURIComponent in a try/catch #1735 (@lxe) - * res.format: now includes charset @1747 (@sorribas) - * res.links: allow multiple calls @1746 (@sorribas) - -3.4.0 / 2013-09-07 -================== - - * add res.vary(). Closes #1682 - * update connect - -3.3.8 / 2013-09-02 -================== - - * update connect - -3.3.7 / 2013-08-28 -================== - - * update connect - -3.3.6 / 2013-08-27 -================== - - * Revert "remove charset from json responses. Closes #1631" (causes issues in some clients) - * add: req.accepts take an argument list - -3.3.4 / 2013-07-08 -================== - - * update send and connect - -3.3.3 / 2013-07-04 -================== - - * update connect - -3.3.2 / 2013-07-03 -================== - - * update connect - * update send - * remove .version export - -3.3.1 / 2013-06-27 -================== - - * update connect - -3.3.0 / 2013-06-26 -================== - - * update connect - * add support for multiple X-Forwarded-Proto values. Closes #1646 - * change: remove charset from json responses. Closes #1631 - * change: return actual booleans from req.accept* functions - * fix jsonp callback array throw - -3.2.6 / 2013-06-02 -================== - - * update connect - -3.2.5 / 2013-05-21 -================== - - * update connect - * update node-cookie - * add: throw a meaningful error when there is no default engine - * change generation of ETags with res.send() to GET requests only. Closes #1619 - -3.2.4 / 2013-05-09 -================== - - * fix `req.subdomains` when no Host is present - * fix `req.host` when no Host is present, return undefined - -3.2.3 / 2013-05-07 -================== - - * update connect / qs - -3.2.2 / 2013-05-03 -================== - - * update qs - -3.2.1 / 2013-04-29 -================== - - * add app.VERB() paths array deprecation warning - * update connect - * update qs and remove all ~ semver crap - * fix: accept number as value of Signed Cookie - -3.2.0 / 2013-04-15 -================== - - * add "view" constructor setting to override view behaviour - * add req.acceptsEncoding(name) - * add req.acceptedEncodings - * revert cookie signature change causing session race conditions - * fix sorting of Accept values of the same quality - -3.1.2 / 2013-04-12 -================== - - * add support for custom Accept parameters - * update cookie-signature - -3.1.1 / 2013-04-01 -================== - - * add X-Forwarded-Host support to `req.host` - * fix relative redirects - * update mkdirp - * update buffer-crc32 - * remove legacy app.configure() method from app template. - -3.1.0 / 2013-01-25 -================== - - * add support for leading "." in "view engine" setting - * add array support to `res.set()` - * add node 0.8.x to travis.yml - * add "subdomain offset" setting for tweaking `req.subdomains` - * add `res.location(url)` implementing `res.redirect()`-like setting of Location - * use app.get() for x-powered-by setting for inheritance - * fix colons in passwords for `req.auth` - -3.0.6 / 2013-01-04 -================== - - * add http verb methods to Router - * update connect - * fix mangling of the `res.cookie()` options object - * fix jsonp whitespace escape. Closes #1132 - -3.0.5 / 2012-12-19 -================== - - * add throwing when a non-function is passed to a route - * fix: explicitly remove Transfer-Encoding header from 204 and 304 responses - * revert "add 'etag' option" - -3.0.4 / 2012-12-05 -================== - - * add 'etag' option to disable `res.send()` Etags - * add escaping of urls in text/plain in `res.redirect()` - for old browsers interpreting as html - * change crc32 module for a more liberal license - * update connect - -3.0.3 / 2012-11-13 -================== - - * update connect - * update cookie module - * fix cookie max-age - -3.0.2 / 2012-11-08 -================== - - * add OPTIONS to cors example. Closes #1398 - * fix route chaining regression. Closes #1397 - -3.0.1 / 2012-11-01 -================== - - * update connect - -3.0.0 / 2012-10-23 -================== - - * add `make clean` - * add "Basic" check to req.auth - * add `req.auth` test coverage - * add cb && cb(payload) to `res.jsonp()`. Closes #1374 - * add backwards compat for `res.redirect()` status. Closes #1336 - * add support for `res.json()` to retain previously defined Content-Types. Closes #1349 - * update connect - * change `res.redirect()` to utilize a pathname-relative Location again. Closes #1382 - * remove non-primitive string support for `res.send()` - * fix view-locals example. Closes #1370 - * fix route-separation example - -3.0.0rc5 / 2012-09-18 -================== - - * update connect - * add redis search example - * add static-files example - * add "x-powered-by" setting (`app.disable('x-powered-by')`) - * add "application/octet-stream" redirect Accept test case. Closes #1317 - -3.0.0rc4 / 2012-08-30 -================== - - * add `res.jsonp()`. Closes #1307 - * add "verbose errors" option to error-pages example - * add another route example to express(1) so people are not so confused - * add redis online user activity tracking example - * update connect dep - * fix etag quoting. Closes #1310 - * fix error-pages 404 status - * fix jsonp callback char restrictions - * remove old OPTIONS default response - -3.0.0rc3 / 2012-08-13 -================== - - * update connect dep - * fix signed cookies to work with `connect.cookieParser()` ("s:" prefix was missing) [tnydwrds] - * fix `res.render()` clobbering of "locals" - -3.0.0rc2 / 2012-08-03 -================== - - * add CORS example - * update connect dep - * deprecate `.createServer()` & remove old stale examples - * fix: escape `res.redirect()` link - * fix vhost example - -3.0.0rc1 / 2012-07-24 -================== - - * add more examples to view-locals - * add scheme-relative redirects (`res.redirect("//foo.com")`) support - * update cookie dep - * update connect dep - * update send dep - * fix `express(1)` -h flag, use -H for hogan. Closes #1245 - * fix `res.sendfile()` socket error handling regression - -3.0.0beta7 / 2012-07-16 -================== - - * update connect dep for `send()` root normalization regression - -3.0.0beta6 / 2012-07-13 -================== - - * add `err.view` property for view errors. Closes #1226 - * add "jsonp callback name" setting - * add support for "/foo/:bar*" non-greedy matches - * change `res.sendfile()` to use `send()` module - * change `res.send` to use "response-send" module - * remove `app.locals.use` and `res.locals.use`, use regular middleware - -3.0.0beta5 / 2012-07-03 -================== - - * add "make check" support - * add route-map example - * add `res.json(obj, status)` support back for BC - * add "methods" dep, remove internal methods module - * update connect dep - * update auth example to utilize cores pbkdf2 - * updated tests to use "supertest" - -3.0.0beta4 / 2012-06-25 -================== - - * Added `req.auth` - * Added `req.range(size)` - * Added `res.links(obj)` - * Added `res.send(body, status)` support back for backwards compat - * Added `.default()` support to `res.format()` - * Added 2xx / 304 check to `req.fresh` - * Revert "Added + support to the router" - * Fixed `res.send()` freshness check, respect res.statusCode - -3.0.0beta3 / 2012-06-15 -================== - - * Added hogan `--hjs` to express(1) [nullfirm] - * Added another example to content-negotiation - * Added `fresh` dep - * Changed: `res.send()` always checks freshness - * Fixed: expose connects mime module. Closes #1165 - -3.0.0beta2 / 2012-06-06 -================== - - * Added `+` support to the router - * Added `req.host` - * Changed `req.param()` to check route first - * Update connect dep - -3.0.0beta1 / 2012-06-01 -================== - - * Added `res.format()` callback to override default 406 behaviour - * Fixed `res.redirect()` 406. Closes #1154 - -3.0.0alpha5 / 2012-05-30 -================== - - * Added `req.ip` - * Added `{ signed: true }` option to `res.cookie()` - * Removed `res.signedCookie()` - * Changed: dont reverse `req.ips` - * Fixed "trust proxy" setting check for `req.ips` - -3.0.0alpha4 / 2012-05-09 -================== - - * Added: allow `[]` in jsonp callback. Closes #1128 - * Added `PORT` env var support in generated template. Closes #1118 [benatkin] - * Updated: connect 2.2.2 - -3.0.0alpha3 / 2012-05-04 -================== - - * Added public `app.routes`. Closes #887 - * Added _view-locals_ example - * Added _mvc_ example - * Added `res.locals.use()`. Closes #1120 - * Added conditional-GET support to `res.send()` - * Added: coerce `res.set()` values to strings - * Changed: moved `static()` in generated apps below router - * Changed: `res.send()` only set ETag when not previously set - * Changed connect 2.2.1 dep - * Changed: `make test` now runs unit / acceptance tests - * Fixed req/res proto inheritance - -3.0.0alpha2 / 2012-04-26 -================== - - * Added `make benchmark` back - * Added `res.send()` support for `String` objects - * Added client-side data exposing example - * Added `res.header()` and `req.header()` aliases for BC - * Added `express.createServer()` for BC - * Perf: memoize parsed urls - * Perf: connect 2.2.0 dep - * Changed: make `expressInit()` middleware self-aware - * Fixed: use app.get() for all core settings - * Fixed redis session example - * Fixed session example. Closes #1105 - * Fixed generated express dep. Closes #1078 - -3.0.0alpha1 / 2012-04-15 -================== - - * Added `app.locals.use(callback)` - * Added `app.locals` object - * Added `app.locals(obj)` - * Added `res.locals` object - * Added `res.locals(obj)` - * Added `res.format()` for content-negotiation - * Added `app.engine()` - * Added `res.cookie()` JSON cookie support - * Added "trust proxy" setting - * Added `req.subdomains` - * Added `req.protocol` - * Added `req.secure` - * Added `req.path` - * Added `req.ips` - * Added `req.fresh` - * Added `req.stale` - * Added comma-delimited / array support for `req.accepts()` - * Added debug instrumentation - * Added `res.set(obj)` - * Added `res.set(field, value)` - * Added `res.get(field)` - * Added `app.get(setting)`. Closes #842 - * Added `req.acceptsLanguage()` - * Added `req.acceptsCharset()` - * Added `req.accepted` - * Added `req.acceptedLanguages` - * Added `req.acceptedCharsets` - * Added "json replacer" setting - * Added "json spaces" setting - * Added X-Forwarded-Proto support to `res.redirect()`. Closes #92 - * Added `--less` support to express(1) - * Added `express.response` prototype - * Added `express.request` prototype - * Added `express.application` prototype - * Added `app.path()` - * Added `app.render()` - * Added `res.type()` to replace `res.contentType()` - * Changed: `res.redirect()` to add relative support - * Changed: enable "jsonp callback" by default - * Changed: renamed "case sensitive routes" to "case sensitive routing" - * Rewrite of all tests with mocha - * Removed "root" setting - * Removed `res.redirect('home')` support - * Removed `req.notify()` - * Removed `app.register()` - * Removed `app.redirect()` - * Removed `app.is()` - * Removed `app.helpers()` - * Removed `app.dynamicHelpers()` - * Fixed `res.sendfile()` with non-GET. Closes #723 - * Fixed express(1) public dir for windows. Closes #866 - -2.5.9/ 2012-04-02 -================== - - * Added support for PURGE request method [pbuyle] - * Fixed `express(1)` generated app `app.address()` before `listening` [mmalecki] - -2.5.8 / 2012-02-08 -================== - - * Update mkdirp dep. Closes #991 - -2.5.7 / 2012-02-06 -================== - - * Fixed `app.all` duplicate DELETE requests [mscdex] - -2.5.6 / 2012-01-13 -================== - - * Updated hamljs dev dep. Closes #953 - -2.5.5 / 2012-01-08 -================== - - * Fixed: set `filename` on cached templates [matthewleon] - -2.5.4 / 2012-01-02 -================== - - * Fixed `express(1)` eol on 0.4.x. Closes #947 - -2.5.3 / 2011-12-30 -================== - - * Fixed `req.is()` when a charset is present - -2.5.2 / 2011-12-10 -================== - - * Fixed: express(1) LF -> CRLF for windows - -2.5.1 / 2011-11-17 -================== - - * Changed: updated connect to 1.8.x - * Removed sass.js support from express(1) - -2.5.0 / 2011-10-24 -================== - - * Added ./routes dir for generated app by default - * Added npm install reminder to express(1) app gen - * Added 0.5.x support - * Removed `make test-cov` since it wont work with node 0.5.x - * Fixed express(1) public dir for windows. Closes #866 - -2.4.7 / 2011-10-05 -================== - - * Added mkdirp to express(1). Closes #795 - * Added simple _json-config_ example - * Added shorthand for the parsed request's pathname via `req.path` - * Changed connect dep to 1.7.x to fix npm issue... - * Fixed `res.redirect()` __HEAD__ support. [reported by xerox] - * Fixed `req.flash()`, only escape args - * Fixed absolute path checking on windows. Closes #829 [reported by andrewpmckenzie] - -2.4.6 / 2011-08-22 -================== - - * Fixed multiple param callback regression. Closes #824 [reported by TroyGoode] - -2.4.5 / 2011-08-19 -================== - - * Added support for routes to handle errors. Closes #809 - * Added `app.routes.all()`. Closes #803 - * Added "basepath" setting to work in conjunction with reverse proxies etc. - * Refactored `Route` to use a single array of callbacks - * Added support for multiple callbacks for `app.param()`. Closes #801 -Closes #805 - * Changed: removed .call(self) for route callbacks - * Dependency: `qs >= 0.3.1` - * Fixed `res.redirect()` on windows due to `join()` usage. Closes #808 - -2.4.4 / 2011-08-05 -================== - - * Fixed `res.header()` intention of a set, even when `undefined` - * Fixed `*`, value no longer required - * Fixed `res.send(204)` support. Closes #771 - -2.4.3 / 2011-07-14 -================== - - * Added docs for `status` option special-case. Closes #739 - * Fixed `options.filename`, exposing the view path to template engines - -2.4.2. / 2011-07-06 -================== - - * Revert "removed jsonp stripping" for XSS - -2.4.1 / 2011-07-06 -================== - - * Added `res.json()` JSONP support. Closes #737 - * Added _extending-templates_ example. Closes #730 - * Added "strict routing" setting for trailing slashes - * Added support for multiple envs in `app.configure()` calls. Closes #735 - * Changed: `res.send()` using `res.json()` - * Changed: when cookie `path === null` don't default it - * Changed; default cookie path to "home" setting. Closes #731 - * Removed _pids/logs_ creation from express(1) - -2.4.0 / 2011-06-28 -================== - - * Added chainable `res.status(code)` - * Added `res.json()`, an explicit version of `res.send(obj)` - * Added simple web-service example - -2.3.12 / 2011-06-22 -================== - - * \#express is now on freenode! come join! - * Added `req.get(field, param)` - * Added links to Japanese documentation, thanks @hideyukisaito! - * Added; the `express(1)` generated app outputs the env - * Added `content-negotiation` example - * Dependency: connect >= 1.5.1 < 2.0.0 - * Fixed view layout bug. Closes #720 - * Fixed; ignore body on 304. Closes #701 - -2.3.11 / 2011-06-04 -================== - - * Added `npm test` - * Removed generation of dummy test file from `express(1)` - * Fixed; `express(1)` adds express as a dep - * Fixed; prune on `prepublish` - -2.3.10 / 2011-05-27 -================== - - * Added `req.route`, exposing the current route - * Added _package.json_ generation support to `express(1)` - * Fixed call to `app.param()` function for optional params. Closes #682 - -2.3.9 / 2011-05-25 -================== - - * Fixed bug-ish with `../' in `res.partial()` calls - -2.3.8 / 2011-05-24 -================== - - * Fixed `app.options()` - -2.3.7 / 2011-05-23 -================== - - * Added route `Collection`, ex: `app.get('/user/:id').remove();` - * Added support for `app.param(fn)` to define param logic - * Removed `app.param()` support for callback with return value - * Removed module.parent check from express(1) generated app. Closes #670 - * Refactored router. Closes #639 - -2.3.6 / 2011-05-20 -================== - - * Changed; using devDependencies instead of git submodules - * Fixed redis session example - * Fixed markdown example - * Fixed view caching, should not be enabled in development - -2.3.5 / 2011-05-20 -================== - - * Added export `.view` as alias for `.View` - -2.3.4 / 2011-05-08 -================== - - * Added `./examples/say` - * Fixed `res.sendfile()` bug preventing the transfer of files with spaces - -2.3.3 / 2011-05-03 -================== - - * Added "case sensitive routes" option. - * Changed; split methods supported per rfc [slaskis] - * Fixed route-specific middleware when using the same callback function several times - -2.3.2 / 2011-04-27 -================== - - * Fixed view hints - -2.3.1 / 2011-04-26 -================== - - * Added `app.match()` as `app.match.all()` - * Added `app.lookup()` as `app.lookup.all()` - * Added `app.remove()` for `app.remove.all()` - * Added `app.remove.VERB()` - * Fixed template caching collision issue. Closes #644 - * Moved router over from connect and started refactor - -2.3.0 / 2011-04-25 -================== - - * Added options support to `res.clearCookie()` - * Added `res.helpers()` as alias of `res.locals()` - * Added; json defaults to UTF-8 with `res.send()`. Closes #632. [Daniel * Dependency `connect >= 1.4.0` - * Changed; auto set Content-Type in res.attachement [Aaron Heckmann] - * Renamed "cache views" to "view cache". Closes #628 - * Fixed caching of views when using several apps. Closes #637 - * Fixed gotcha invoking `app.param()` callbacks once per route middleware. -Closes #638 - * Fixed partial lookup precedence. Closes #631 -Shaw] - -2.2.2 / 2011-04-12 -================== - - * Added second callback support for `res.download()` connection errors - * Fixed `filename` option passing to template engine - -2.2.1 / 2011-04-04 -================== - - * Added `layout(path)` helper to change the layout within a view. Closes #610 - * Fixed `partial()` collection object support. - Previously only anything with `.length` would work. - When `.length` is present one must still be aware of holes, - however now `{ collection: {foo: 'bar'}}` is valid, exposes - `keyInCollection` and `keysInCollection`. - - * Performance improved with better view caching - * Removed `request` and `response` locals - * Changed; errorHandler page title is now `Express` instead of `Connect` - -2.2.0 / 2011-03-30 -================== - - * Added `app.lookup.VERB()`, ex `app.lookup.put('/user/:id')`. Closes #606 - * Added `app.match.VERB()`, ex `app.match.put('/user/12')`. Closes #606 - * Added `app.VERB(path)` as alias of `app.lookup.VERB()`. - * Dependency `connect >= 1.2.0` - -2.1.1 / 2011-03-29 -================== - - * Added; expose `err.view` object when failing to locate a view - * Fixed `res.partial()` call `next(err)` when no callback is given [reported by aheckmann] - * Fixed; `res.send(undefined)` responds with 204 [aheckmann] - -2.1.0 / 2011-03-24 -================== - - * Added `/_?` partial lookup support. Closes #447 - * Added `request`, `response`, and `app` local variables - * Added `settings` local variable, containing the app's settings - * Added `req.flash()` exception if `req.session` is not available - * Added `res.send(bool)` support (json response) - * Fixed stylus example for latest version - * Fixed; wrap try/catch around `res.render()` - -2.0.0 / 2011-03-17 -================== - - * Fixed up index view path alternative. - * Changed; `res.locals()` without object returns the locals - -2.0.0rc3 / 2011-03-17 -================== - - * Added `res.locals(obj)` to compliment `res.local(key, val)` - * Added `res.partial()` callback support - * Fixed recursive error reporting issue in `res.render()` - -2.0.0rc2 / 2011-03-17 -================== - - * Changed; `partial()` "locals" are now optional - * Fixed `SlowBuffer` support. Closes #584 [reported by tyrda01] - * Fixed .filename view engine option [reported by drudge] - * Fixed blog example - * Fixed `{req,res}.app` reference when mounting [Ben Weaver] - -2.0.0rc / 2011-03-14 -================== - - * Fixed; expose `HTTPSServer` constructor - * Fixed express(1) default test charset. Closes #579 [reported by secoif] - * Fixed; default charset to utf-8 instead of utf8 for lame IE [reported by NickP] - -2.0.0beta3 / 2011-03-09 -================== - - * Added support for `res.contentType()` literal - The original `res.contentType('.json')`, - `res.contentType('application/json')`, and `res.contentType('json')` - will work now. - * Added `res.render()` status option support back - * Added charset option for `res.render()` - * Added `.charset` support (via connect 1.0.4) - * Added view resolution hints when in development and a lookup fails - * Added layout lookup support relative to the page view. - For example while rendering `./views/user/index.jade` if you create - `./views/user/layout.jade` it will be used in favour of the root layout. - * Fixed `res.redirect()`. RFC states absolute url [reported by unlink] - * Fixed; default `res.send()` string charset to utf8 - * Removed `Partial` constructor (not currently used) - -2.0.0beta2 / 2011-03-07 -================== - - * Added res.render() `.locals` support back to aid in migration process - * Fixed flash example - -2.0.0beta / 2011-03-03 -================== - - * Added HTTPS support - * Added `res.cookie()` maxAge support - * Added `req.header()` _Referrer_ / _Referer_ special-case, either works - * Added mount support for `res.redirect()`, now respects the mount-point - * Added `union()` util, taking place of `merge(clone())` combo - * Added stylus support to express(1) generated app - * Added secret to session middleware used in examples and generated app - * Added `res.local(name, val)` for progressive view locals - * Added default param support to `req.param(name, default)` - * Added `app.disabled()` and `app.enabled()` - * Added `app.register()` support for omitting leading ".", either works - * Added `res.partial()`, using the same interface as `partial()` within a view. Closes #539 - * Added `app.param()` to map route params to async/sync logic - * Added; aliased `app.helpers()` as `app.locals()`. Closes #481 - * Added extname with no leading "." support to `res.contentType()` - * Added `cache views` setting, defaulting to enabled in "production" env - * Added index file partial resolution, eg: partial('user') may try _views/user/index.jade_. - * Added `req.accepts()` support for extensions - * Changed; `res.download()` and `res.sendfile()` now utilize Connect's - static file server `connect.static.send()`. - * Changed; replaced `connect.utils.mime()` with npm _mime_ module - * Changed; allow `req.query` to be pre-defined (via middleware or other parent - * Changed view partial resolution, now relative to parent view - * Changed view engine signature. no longer `engine.render(str, options, callback)`, now `engine.compile(str, options) -> Function`, the returned function accepts `fn(locals)`. - * Fixed `req.param()` bug returning Array.prototype methods. Closes #552 - * Fixed; using `Stream#pipe()` instead of `sys.pump()` in `res.sendfile()` - * Fixed; using _qs_ module instead of _querystring_ - * Fixed; strip unsafe chars from jsonp callbacks - * Removed "stream threshold" setting - -1.0.8 / 2011-03-01 -================== - - * Allow `req.query` to be pre-defined (via middleware or other parent app) - * "connect": ">= 0.5.0 < 1.0.0". Closes #547 - * Removed the long deprecated __EXPRESS_ENV__ support - -1.0.7 / 2011-02-07 -================== - - * Fixed `render()` setting inheritance. - Mounted apps would not inherit "view engine" - -1.0.6 / 2011-02-07 -================== - - * Fixed `view engine` setting bug when period is in dirname - -1.0.5 / 2011-02-05 -================== - - * Added secret to generated app `session()` call - -1.0.4 / 2011-02-05 -================== - - * Added `qs` dependency to _package.json_ - * Fixed namespaced `require()`s for latest connect support - -1.0.3 / 2011-01-13 -================== - - * Remove unsafe characters from JSONP callback names [Ryan Grove] - -1.0.2 / 2011-01-10 -================== - - * Removed nested require, using `connect.router` - -1.0.1 / 2010-12-29 -================== - - * Fixed for middleware stacked via `createServer()` - previously the `foo` middleware passed to `createServer(foo)` - would not have access to Express methods such as `res.send()` - or props like `req.query` etc. - -1.0.0 / 2010-11-16 -================== - - * Added; deduce partial object names from the last segment. - For example by default `partial('forum/post', postObject)` will - give you the _post_ object, providing a meaningful default. - * Added http status code string representation to `res.redirect()` body - * Added; `res.redirect()` supporting _text/plain_ and _text/html_ via __Accept__. - * Added `req.is()` to aid in content negotiation - * Added partial local inheritance [suggested by masylum]. Closes #102 - providing access to parent template locals. - * Added _-s, --session[s]_ flag to express(1) to add session related middleware - * Added _--template_ flag to express(1) to specify the - template engine to use. - * Added _--css_ flag to express(1) to specify the - stylesheet engine to use (or just plain css by default). - * Added `app.all()` support [thanks aheckmann] - * Added partial direct object support. - You may now `partial('user', user)` providing the "user" local, - vs previously `partial('user', { object: user })`. - * Added _route-separation_ example since many people question ways - to do this with CommonJS modules. Also view the _blog_ example for - an alternative. - * Performance; caching view path derived partial object names - * Fixed partial local inheritance precedence. [reported by Nick Poulden] Closes #454 - * Fixed jsonp support; _text/javascript_ as per mailinglist discussion - -1.0.0rc4 / 2010-10-14 -================== - - * Added _NODE_ENV_ support, _EXPRESS_ENV_ is deprecated and will be removed in 1.0.0 - * Added route-middleware support (very helpful, see the [docs](http://expressjs.com/guide.html#Route-Middleware)) - * Added _jsonp callback_ setting to enable/disable jsonp autowrapping [Dav Glass] - * Added callback query check on response.send to autowrap JSON objects for simple webservice implementations [Dav Glass] - * Added `partial()` support for array-like collections. Closes #434 - * Added support for swappable querystring parsers - * Added session usage docs. Closes #443 - * Added dynamic helper caching. Closes #439 [suggested by maritz] - * Added authentication example - * Added basic Range support to `res.sendfile()` (and `res.download()` etc) - * Changed; `express(1)` generated app using 2 spaces instead of 4 - * Default env to "development" again [aheckmann] - * Removed _context_ option is no more, use "scope" - * Fixed; exposing _./support_ libs to examples so they can run without installs - * Fixed mvc example - -1.0.0rc3 / 2010-09-20 -================== - - * Added confirmation for `express(1)` app generation. Closes #391 - * Added extending of flash formatters via `app.flashFormatters` - * Added flash formatter support. Closes #411 - * Added streaming support to `res.sendfile()` using `sys.pump()` when >= "stream threshold" - * Added _stream threshold_ setting for `res.sendfile()` - * Added `res.send()` __HEAD__ support - * Added `res.clearCookie()` - * Added `res.cookie()` - * Added `res.render()` headers option - * Added `res.redirect()` response bodies - * Added `res.render()` status option support. Closes #425 [thanks aheckmann] - * Fixed `res.sendfile()` responding with 403 on malicious path - * Fixed `res.download()` bug; when an error occurs remove _Content-Disposition_ - * Fixed; mounted apps settings now inherit from parent app [aheckmann] - * Fixed; stripping Content-Length / Content-Type when 204 - * Fixed `res.send()` 204. Closes #419 - * Fixed multiple _Set-Cookie_ headers via `res.header()`. Closes #402 - * Fixed bug messing with error handlers when `listenFD()` is called instead of `listen()`. [thanks guillermo] - - -1.0.0rc2 / 2010-08-17 -================== - - * Added `app.register()` for template engine mapping. Closes #390 - * Added `res.render()` callback support as second argument (no options) - * Added callback support to `res.download()` - * Added callback support for `res.sendfile()` - * Added support for middleware access via `express.middlewareName()` vs `connect.middlewareName()` - * Added "partials" setting to docs - * Added default expresso tests to `express(1)` generated app. Closes #384 - * Fixed `res.sendfile()` error handling, defer via `next()` - * Fixed `res.render()` callback when a layout is used [thanks guillermo] - * Fixed; `make install` creating ~/.node_libraries when not present - * Fixed issue preventing error handlers from being defined anywhere. Closes #387 - -1.0.0rc / 2010-07-28 -================== - - * Added mounted hook. Closes #369 - * Added connect dependency to _package.json_ - - * Removed "reload views" setting and support code - development env never caches, production always caches. - - * Removed _param_ in route callbacks, signature is now - simply (req, res, next), previously (req, res, params, next). - Use _req.params_ for path captures, _req.query_ for GET params. - - * Fixed "home" setting - * Fixed middleware/router precedence issue. Closes #366 - * Fixed; _configure()_ callbacks called immediately. Closes #368 - -1.0.0beta2 / 2010-07-23 -================== - - * Added more examples - * Added; exporting `Server` constructor - * Added `Server#helpers()` for view locals - * Added `Server#dynamicHelpers()` for dynamic view locals. Closes #349 - * Added support for absolute view paths - * Added; _home_ setting defaults to `Server#route` for mounted apps. Closes #363 - * Added Guillermo Rauch to the contributor list - * Added support for "as" for non-collection partials. Closes #341 - * Fixed _install.sh_, ensuring _~/.node_libraries_ exists. Closes #362 [thanks jf] - * Fixed `res.render()` exceptions, now passed to `next()` when no callback is given [thanks guillermo] - * Fixed instanceof `Array` checks, now `Array.isArray()` - * Fixed express(1) expansion of public dirs. Closes #348 - * Fixed middleware precedence. Closes #345 - * Fixed view watcher, now async [thanks aheckmann] - -1.0.0beta / 2010-07-15 -================== - - * Re-write - - much faster - - much lighter - - Check [ExpressJS.com](http://expressjs.com) for migration guide and updated docs - -0.14.0 / 2010-06-15 -================== - - * Utilize relative requires - * Added Static bufferSize option [aheckmann] - * Fixed caching of view and partial subdirectories [aheckmann] - * Fixed mime.type() comments now that ".ext" is not supported - * Updated haml submodule - * Updated class submodule - * Removed bin/express - -0.13.0 / 2010-06-01 -================== - - * Added node v0.1.97 compatibility - * Added support for deleting cookies via Request#cookie('key', null) - * Updated haml submodule - * Fixed not-found page, now using using charset utf-8 - * Fixed show-exceptions page, now using using charset utf-8 - * Fixed view support due to fs.readFile Buffers - * Changed; mime.type() no longer accepts ".type" due to node extname() changes - -0.12.0 / 2010-05-22 -================== - - * Added node v0.1.96 compatibility - * Added view `helpers` export which act as additional local variables - * Updated haml submodule - * Changed ETag; removed inode, modified time only - * Fixed LF to CRLF for setting multiple cookies - * Fixed cookie complation; values are now urlencoded - * Fixed cookies parsing; accepts quoted values and url escaped cookies - -0.11.0 / 2010-05-06 -================== - - * Added support for layouts using different engines - - this.render('page.html.haml', { layout: 'super-cool-layout.html.ejs' }) - - this.render('page.html.haml', { layout: 'foo' }) // assumes 'foo.html.haml' - - this.render('page.html.haml', { layout: false }) // no layout - * Updated ext submodule - * Updated haml submodule - * Fixed EJS partial support by passing along the context. Issue #307 - -0.10.1 / 2010-05-03 -================== - - * Fixed binary uploads. - -0.10.0 / 2010-04-30 -================== - - * Added charset support via Request#charset (automatically assigned to 'UTF-8' when respond()'s - encoding is set to 'utf8' or 'utf-8'. - * Added "encoding" option to Request#render(). Closes #299 - * Added "dump exceptions" setting, which is enabled by default. - * Added simple ejs template engine support - * Added error response support for text/plain, application/json. Closes #297 - * Added callback function param to Request#error() - * Added Request#sendHead() - * Added Request#stream() - * Added support for Request#respond(304, null) for empty response bodies - * Added ETag support to Request#sendfile() - * Added options to Request#sendfile(), passed to fs.createReadStream() - * Added filename arg to Request#download() - * Performance enhanced due to pre-reversing plugins so that plugins.reverse() is not called on each request - * Performance enhanced by preventing several calls to toLowerCase() in Router#match() - * Changed; Request#sendfile() now streams - * Changed; Renamed Request#halt() to Request#respond(). Closes #289 - * Changed; Using sys.inspect() instead of JSON.encode() for error output - * Changed; run() returns the http.Server instance. Closes #298 - * Changed; Defaulting Server#host to null (INADDR_ANY) - * Changed; Logger "common" format scale of 0.4f - * Removed Logger "request" format - * Fixed; Catching ENOENT in view caching, preventing error when "views/partials" is not found - * Fixed several issues with http client - * Fixed Logger Content-Length output - * Fixed bug preventing Opera from retaining the generated session id. Closes #292 - -0.9.0 / 2010-04-14 -================== - - * Added DSL level error() route support - * Added DSL level notFound() route support - * Added Request#error() - * Added Request#notFound() - * Added Request#render() callback function. Closes #258 - * Added "max upload size" setting - * Added "magic" variables to collection partials (\_\_index\_\_, \_\_length\_\_, \_\_isFirst\_\_, \_\_isLast\_\_). Closes #254 - * Added [haml.js](http://github.com/visionmedia/haml.js) submodule; removed haml-js - * Added callback function support to Request#halt() as 3rd/4th arg - * Added preprocessing of route param wildcards using param(). Closes #251 - * Added view partial support (with collections etc) - * Fixed bug preventing falsey params (such as ?page=0). Closes #286 - * Fixed setting of multiple cookies. Closes #199 - * Changed; view naming convention is now NAME.TYPE.ENGINE (for example page.html.haml) - * Changed; session cookie is now httpOnly - * Changed; Request is no longer global - * Changed; Event is no longer global - * Changed; "sys" module is no longer global - * Changed; moved Request#download to Static plugin where it belongs - * Changed; Request instance created before body parsing. Closes #262 - * Changed; Pre-caching views in memory when "cache view contents" is enabled. Closes #253 - * Changed; Pre-caching view partials in memory when "cache view partials" is enabled - * Updated support to node --version 0.1.90 - * Updated dependencies - * Removed set("session cookie") in favour of use(Session, { cookie: { ... }}) - * Removed utils.mixin(); use Object#mergeDeep() - -0.8.0 / 2010-03-19 -================== - - * Added coffeescript example app. Closes #242 - * Changed; cache api now async friendly. Closes #240 - * Removed deprecated 'express/static' support. Use 'express/plugins/static' - -0.7.6 / 2010-03-19 -================== - - * Added Request#isXHR. Closes #229 - * Added `make install` (for the executable) - * Added `express` executable for setting up simple app templates - * Added "GET /public/*" to Static plugin, defaulting to /public - * Added Static plugin - * Fixed; Request#render() only calls cache.get() once - * Fixed; Namespacing View caches with "view:" - * Fixed; Namespacing Static caches with "static:" - * Fixed; Both example apps now use the Static plugin - * Fixed set("views"). Closes #239 - * Fixed missing space for combined log format - * Deprecated Request#sendfile() and 'express/static' - * Removed Server#running - -0.7.5 / 2010-03-16 -================== - - * Added Request#flash() support without args, now returns all flashes - * Updated ext submodule - -0.7.4 / 2010-03-16 -================== - - * Fixed session reaper - * Changed; class.js replacing js-oo Class implementation (quite a bit faster, no browser cruft) - -0.7.3 / 2010-03-16 -================== - - * Added package.json - * Fixed requiring of haml / sass due to kiwi removal - -0.7.2 / 2010-03-16 -================== - - * Fixed GIT submodules (HAH!) - -0.7.1 / 2010-03-16 -================== - - * Changed; Express now using submodules again until a PM is adopted - * Changed; chat example using millisecond conversions from ext - -0.7.0 / 2010-03-15 -================== - - * Added Request#pass() support (finds the next matching route, or the given path) - * Added Logger plugin (default "common" format replaces CommonLogger) - * Removed Profiler plugin - * Removed CommonLogger plugin - -0.6.0 / 2010-03-11 -================== - - * Added seed.yml for kiwi package management support - * Added HTTP client query string support when method is GET. Closes #205 - - * Added support for arbitrary view engines. - For example "foo.engine.html" will now require('engine'), - the exports from this module are cached after the first require(). - - * Added async plugin support - - * Removed usage of RESTful route funcs as http client - get() etc, use http.get() and friends - - * Removed custom exceptions - -0.5.0 / 2010-03-10 -================== - - * Added ext dependency (library of js extensions) - * Removed extname() / basename() utils. Use path module - * Removed toArray() util. Use arguments.values - * Removed escapeRegexp() util. Use RegExp.escape() - * Removed process.mixin() dependency. Use utils.mixin() - * Removed Collection - * Removed ElementCollection - * Shameless self promotion of ebook "Advanced JavaScript" (http://dev-mag.com) ;) - -0.4.0 / 2010-02-11 -================== - - * Added flash() example to sample upload app - * Added high level restful http client module (express/http) - * Changed; RESTful route functions double as HTTP clients. Closes #69 - * Changed; throwing error when routes are added at runtime - * Changed; defaulting render() context to the current Request. Closes #197 - * Updated haml submodule - -0.3.0 / 2010-02-11 -================== - - * Updated haml / sass submodules. Closes #200 - * Added flash message support. Closes #64 - * Added accepts() now allows multiple args. fixes #117 - * Added support for plugins to halt. Closes #189 - * Added alternate layout support. Closes #119 - * Removed Route#run(). Closes #188 - * Fixed broken specs due to use(Cookie) missing - -0.2.1 / 2010-02-05 -================== - - * Added "plot" format option for Profiler (for gnuplot processing) - * Added request number to Profiler plugin - * Fixed binary encoding for multi-part file uploads, was previously defaulting to UTF8 - * Fixed issue with routes not firing when not files are present. Closes #184 - * Fixed process.Promise -> events.Promise - -0.2.0 / 2010-02-03 -================== - - * Added parseParam() support for name[] etc. (allows for file inputs with "multiple" attr) Closes #180 - * Added Both Cache and Session option "reapInterval" may be "reapEvery". Closes #174 - * Added expiration support to cache api with reaper. Closes #133 - * Added cache Store.Memory#reap() - * Added Cache; cache api now uses first class Cache instances - * Added abstract session Store. Closes #172 - * Changed; cache Memory.Store#get() utilizing Collection - * Renamed MemoryStore -> Store.Memory - * Fixed use() of the same plugin several time will always use latest options. Closes #176 - -0.1.0 / 2010-02-03 -================== - - * Changed; Hooks (before / after) pass request as arg as well as evaluated in their context - * Updated node support to 0.1.27 Closes #169 - * Updated dirname(__filename) -> __dirname - * Updated libxmljs support to v0.2.0 - * Added session support with memory store / reaping - * Added quick uid() helper - * Added multi-part upload support - * Added Sass.js support / submodule - * Added production env caching view contents and static files - * Added static file caching. Closes #136 - * Added cache plugin with memory stores - * Added support to StaticFile so that it works with non-textual files. - * Removed dirname() helper - * Removed several globals (now their modules must be required) - -0.0.2 / 2010-01-10 -================== - - * Added view benchmarks; currently haml vs ejs - * Added Request#attachment() specs. Closes #116 - * Added use of node's parseQuery() util. Closes #123 - * Added `make init` for submodules - * Updated Haml - * Updated sample chat app to show messages on load - * Updated libxmljs parseString -> parseHtmlString - * Fixed `make init` to work with older versions of git - * Fixed specs can now run independent specs for those who cant build deps. Closes #127 - * Fixed issues introduced by the node url module changes. Closes 126. - * Fixed two assertions failing due to Collection#keys() returning strings - * Fixed faulty Collection#toArray() spec due to keys() returning strings - * Fixed `make test` now builds libxmljs.node before testing - -0.0.1 / 2010-01-03 -================== - - * Initial release +4.14.0 / 2016-06-16 +=================== + + * Add `acceptRanges` option to `res.sendFile`/`res.sendfile` + * Add `cacheControl` option to `res.sendFile`/`res.sendfile` + * Add `options` argument to `req.range` + - Includes the `combine` option + * Encode URL in `res.location`/`res.redirect` if not already encoded + * Fix some redirect handling in `res.sendFile`/`res.sendfile` + * Fix Windows absolute path check using forward slashes + * Improve error with invalid arguments to `req.get()` + * Improve performance for `res.json`/`res.jsonp` in most cases + * Improve `Range` header handling in `res.sendFile`/`res.sendfile` + * deps: accepts@~1.3.3 + - Fix including type extensions in parameters in `Accept` parsing + - Fix parsing `Accept` parameters with quoted equals + - Fix parsing `Accept` parameters with quoted semicolons + - Many performance improvments + - deps: mime-types@~2.1.11 + - deps: negotiator@0.6.1 + * deps: content-type@~1.0.2 + - perf: enable strict mode + * deps: cookie@0.3.1 + - Add `sameSite` option + - Fix cookie `Max-Age` to never be a floating point number + - Improve error message when `encode` is not a function + - Improve error message when `expires` is not a `Date` + - Throw better error for invalid argument to parse + - Throw on invalid values provided to `serialize` + - perf: enable strict mode + - perf: hoist regular expression + - perf: use for loop in parse + - perf: use string concatination for serialization + * deps: finalhandler@0.5.0 + - Change invalid or non-numeric status code to 500 + - Overwrite status message to match set status code + - Prefer `err.statusCode` if `err.status` is invalid + - Set response headers from `err.headers` object + - Use `statuses` instead of `http` module for status messages + * deps: proxy-addr@~1.1.2 + - Fix accepting various invalid netmasks + - Fix IPv6-mapped IPv4 validation edge cases + - IPv4 netmasks must be contingous + - IPv6 addresses cannot be used as a netmask + - deps: ipaddr.js@1.1.1 + * deps: qs@6.2.0 + - Add `decoder` option in `parse` function + * deps: range-parser@~1.2.0 + - Add `combine` option to combine overlapping ranges + - Fix incorrectly returning -1 when there is at least one valid range + - perf: remove internal function + * deps: send@0.14.1 + - Add `acceptRanges` option + - Add `cacheControl` option + - Attempt to combine multiple ranges into single range + - Correctly inherit from `Stream` class + - Fix `Content-Range` header in 416 responses when using `start`/`end` options + - Fix `Content-Range` header missing from default 416 responses + - Fix redirect error when `path` contains raw non-URL characters + - Fix redirect when `path` starts with multiple forward slashes + - Ignore non-byte `Range` headers + - deps: http-errors@~1.5.0 + - deps: range-parser@~1.2.0 + - deps: statuses@~1.3.0 + - perf: remove argument reassignment + * deps: serve-static@~1.11.1 + - Add `acceptRanges` option + - Add `cacheControl` option + - Attempt to combine multiple ranges into single range + - Fix redirect error when `req.url` contains raw non-URL characters + - Ignore non-byte `Range` headers + - Use status code 301 for redirects + - deps: send@0.14.1 + * deps: type-is@~1.6.13 + - Fix type error when given invalid type to match against + - deps: mime-types@~2.1.11 + * deps: vary@~1.1.0 + - Only accept valid field names in the `field` argument + * perf: use strict equality when possible + +4.13.4 / 2016-01-21 +=================== + + * deps: content-disposition@0.5.1 + - perf: enable strict mode + * deps: cookie@0.1.5 + - Throw on invalid values provided to `serialize` + * deps: depd@~1.1.0 + - Support web browser loading + - perf: enable strict mode + * deps: escape-html@~1.0.3 + - perf: enable strict mode + - perf: optimize string replacement + - perf: use faster string coercion + * deps: finalhandler@0.4.1 + - deps: escape-html@~1.0.3 + * deps: merge-descriptors@1.0.1 + - perf: enable strict mode + * deps: methods@~1.1.2 + - perf: enable strict mode + * deps: parseurl@~1.3.1 + - perf: enable strict mode + * deps: proxy-addr@~1.0.10 + - deps: ipaddr.js@1.0.5 + - perf: enable strict mode + * deps: range-parser@~1.0.3 + - perf: enable strict mode + * deps: send@0.13.1 + - deps: depd@~1.1.0 + - deps: destroy@~1.0.4 + - deps: escape-html@~1.0.3 + - deps: range-parser@~1.0.3 + * deps: serve-static@~1.10.2 + - deps: escape-html@~1.0.3 + - deps: parseurl@~1.3.0 + - deps: send@0.13.1 + +4.13.3 / 2015-08-02 +=================== + + * Fix infinite loop condition using `mergeParams: true` + * Fix inner numeric indices incorrectly altering parent `req.params` + +4.13.2 / 2015-07-31 +=================== + + * deps: accepts@~1.2.12 + - deps: mime-types@~2.1.4 + * deps: array-flatten@1.1.1 + - perf: enable strict mode + * deps: path-to-regexp@0.1.7 + - Fix regression with escaped round brackets and matching groups + * deps: type-is@~1.6.6 + - deps: mime-types@~2.1.4 + +4.13.1 / 2015-07-05 +=================== + + * deps: accepts@~1.2.10 + - deps: mime-types@~2.1.2 + * deps: qs@4.0.0 + - Fix dropping parameters like `hasOwnProperty` + - Fix various parsing edge cases + * deps: type-is@~1.6.4 + - deps: mime-types@~2.1.2 + - perf: enable strict mode + - perf: remove argument reassignment + +4.13.0 / 2015-06-20 +=================== + + * Add settings to debug output + * Fix `res.format` error when only `default` provided + * Fix issue where `next('route')` in `app.param` would incorrectly skip values + * Fix hiding platform issues with `decodeURIComponent` + - Only `URIError`s are a 400 + * Fix using `*` before params in routes + * Fix using capture groups before params in routes + * Simplify `res.cookie` to call `res.append` + * Use `array-flatten` module for flattening arrays + * deps: accepts@~1.2.9 + - deps: mime-types@~2.1.1 + - perf: avoid argument reassignment & argument slice + - perf: avoid negotiator recursive construction + - perf: enable strict mode + - perf: remove unnecessary bitwise operator + * deps: cookie@0.1.3 + - perf: deduce the scope of try-catch deopt + - perf: remove argument reassignments + * deps: escape-html@1.0.2 + * deps: etag@~1.7.0 + - Always include entity length in ETags for hash length extensions + - Generate non-Stats ETags using MD5 only (no longer CRC32) + - Improve stat performance by removing hashing + - Improve support for JXcore + - Remove base64 padding in ETags to shorten + - Support "fake" stats objects in environments without fs + - Use MD5 instead of MD4 in weak ETags over 1KB + * deps: finalhandler@0.4.0 + - Fix a false-positive when unpiping in Node.js 0.8 + - Support `statusCode` property on `Error` objects + - Use `unpipe` module for unpiping requests + - deps: escape-html@1.0.2 + - deps: on-finished@~2.3.0 + - perf: enable strict mode + - perf: remove argument reassignment + * deps: fresh@0.3.0 + - Add weak `ETag` matching support + * deps: on-finished@~2.3.0 + - Add defined behavior for HTTP `CONNECT` requests + - Add defined behavior for HTTP `Upgrade` requests + - deps: ee-first@1.1.1 + * deps: path-to-regexp@0.1.6 + * deps: send@0.13.0 + - Allow Node.js HTTP server to set `Date` response header + - Fix incorrectly removing `Content-Location` on 304 response + - Improve the default redirect response headers + - Send appropriate headers on default error response + - Use `http-errors` for standard emitted errors + - Use `statuses` instead of `http` module for status messages + - deps: escape-html@1.0.2 + - deps: etag@~1.7.0 + - deps: fresh@0.3.0 + - deps: on-finished@~2.3.0 + - perf: enable strict mode + - perf: remove unnecessary array allocations + * deps: serve-static@~1.10.0 + - Add `fallthrough` option + - Fix reading options from options prototype + - Improve the default redirect response headers + - Malformed URLs now `next()` instead of 400 + - deps: escape-html@1.0.2 + - deps: send@0.13.0 + - perf: enable strict mode + - perf: remove argument reassignment + * deps: type-is@~1.6.3 + - deps: mime-types@~2.1.1 + - perf: reduce try block size + - perf: remove bitwise operations + * perf: enable strict mode + * perf: isolate `app.render` try block + * perf: remove argument reassignments in application + * perf: remove argument reassignments in request prototype + * perf: remove argument reassignments in response prototype + * perf: remove argument reassignments in routing + * perf: remove argument reassignments in `View` + * perf: skip attempting to decode zero length string + * perf: use saved reference to `http.STATUS_CODES` + +4.12.4 / 2015-05-17 +=================== + + * deps: accepts@~1.2.7 + - deps: mime-types@~2.0.11 + - deps: negotiator@0.5.3 + * deps: debug@~2.2.0 + - deps: ms@0.7.1 + * deps: depd@~1.0.1 + * deps: etag@~1.6.0 + - Improve support for JXcore + - Support "fake" stats objects in environments without `fs` + * deps: finalhandler@0.3.6 + - deps: debug@~2.2.0 + - deps: on-finished@~2.2.1 + * deps: on-finished@~2.2.1 + - Fix `isFinished(req)` when data buffered + * deps: proxy-addr@~1.0.8 + - deps: ipaddr.js@1.0.1 + * deps: qs@2.4.2 + - Fix allowing parameters like `constructor` + * deps: send@0.12.3 + - deps: debug@~2.2.0 + - deps: depd@~1.0.1 + - deps: etag@~1.6.0 + - deps: ms@0.7.1 + - deps: on-finished@~2.2.1 + * deps: serve-static@~1.9.3 + - deps: send@0.12.3 + * deps: type-is@~1.6.2 + - deps: mime-types@~2.0.11 + +4.12.3 / 2015-03-17 +=================== + + * deps: accepts@~1.2.5 + - deps: mime-types@~2.0.10 + * deps: debug@~2.1.3 + - Fix high intensity foreground color for bold + - deps: ms@0.7.0 + * deps: finalhandler@0.3.4 + - deps: debug@~2.1.3 + * deps: proxy-addr@~1.0.7 + - deps: ipaddr.js@0.1.9 + * deps: qs@2.4.1 + - Fix error when parameter `hasOwnProperty` is present + * deps: send@0.12.2 + - Throw errors early for invalid `extensions` or `index` options + - deps: debug@~2.1.3 + * deps: serve-static@~1.9.2 + - deps: send@0.12.2 + * deps: type-is@~1.6.1 + - deps: mime-types@~2.0.10 + +4.12.2 / 2015-03-02 +=================== + + * Fix regression where `"Request aborted"` is logged using `res.sendFile` + +4.12.1 / 2015-03-01 +=================== + + * Fix constructing application with non-configurable prototype properties + * Fix `ECONNRESET` errors from `res.sendFile` usage + * Fix `req.host` when using "trust proxy" hops count + * Fix `req.protocol`/`req.secure` when using "trust proxy" hops count + * Fix wrong `code` on aborted connections from `res.sendFile` + * deps: merge-descriptors@1.0.0 + +4.12.0 / 2015-02-23 +=================== + + * Fix `"trust proxy"` setting to inherit when app is mounted + * Generate `ETag`s for all request responses + - No longer restricted to only responses for `GET` and `HEAD` requests + * Use `content-type` to parse `Content-Type` headers + * deps: accepts@~1.2.4 + - Fix preference sorting to be stable for long acceptable lists + - deps: mime-types@~2.0.9 + - deps: negotiator@0.5.1 + * deps: cookie-signature@1.0.6 + * deps: send@0.12.1 + - Always read the stat size from the file + - Fix mutating passed-in `options` + - deps: mime@1.3.4 + * deps: serve-static@~1.9.1 + - deps: send@0.12.1 + * deps: type-is@~1.6.0 + - fix argument reassignment + - fix false-positives in `hasBody` `Transfer-Encoding` check + - support wildcard for both type and subtype (`*/*`) + - deps: mime-types@~2.0.9 + +4.11.2 / 2015-02-01 +=================== + + * Fix `res.redirect` double-calling `res.end` for `HEAD` requests + * deps: accepts@~1.2.3 + - deps: mime-types@~2.0.8 + * deps: proxy-addr@~1.0.6 + - deps: ipaddr.js@0.1.8 + * deps: type-is@~1.5.6 + - deps: mime-types@~2.0.8 + +4.11.1 / 2015-01-20 +=================== + + * deps: send@0.11.1 + - Fix root path disclosure + * deps: serve-static@~1.8.1 + - Fix redirect loop in Node.js 0.11.14 + - Fix root path disclosure + - deps: send@0.11.1 + +4.11.0 / 2015-01-13 +=================== + + * Add `res.append(field, val)` to append headers + * Deprecate leading `:` in `name` for `app.param(name, fn)` + * Deprecate `req.param()` -- use `req.params`, `req.body`, or `req.query` instead + * Deprecate `app.param(fn)` + * Fix `OPTIONS` responses to include the `HEAD` method properly + * Fix `res.sendFile` not always detecting aborted connection + * Match routes iteratively to prevent stack overflows + * deps: accepts@~1.2.2 + - deps: mime-types@~2.0.7 + - deps: negotiator@0.5.0 + * deps: send@0.11.0 + - deps: debug@~2.1.1 + - deps: etag@~1.5.1 + - deps: ms@0.7.0 + - deps: on-finished@~2.2.0 + * deps: serve-static@~1.8.0 + - deps: send@0.11.0 + +4.10.8 / 2015-01-13 +=================== + + * Fix crash from error within `OPTIONS` response handler + * deps: proxy-addr@~1.0.5 + - deps: ipaddr.js@0.1.6 + +4.10.7 / 2015-01-04 +=================== + + * Fix `Allow` header for `OPTIONS` to not contain duplicate methods + * Fix incorrect "Request aborted" for `res.sendFile` when `HEAD` or 304 + * deps: debug@~2.1.1 + * deps: finalhandler@0.3.3 + - deps: debug@~2.1.1 + - deps: on-finished@~2.2.0 + * deps: methods@~1.1.1 + * deps: on-finished@~2.2.0 + * deps: serve-static@~1.7.2 + - Fix potential open redirect when mounted at root + * deps: type-is@~1.5.5 + - deps: mime-types@~2.0.7 + +4.10.6 / 2014-12-12 +=================== + + * Fix exception in `req.fresh`/`req.stale` without response headers + +4.10.5 / 2014-12-10 +=================== + + * Fix `res.send` double-calling `res.end` for `HEAD` requests + * deps: accepts@~1.1.4 + - deps: mime-types@~2.0.4 + * deps: type-is@~1.5.4 + - deps: mime-types@~2.0.4 + +4.10.4 / 2014-11-24 +=================== + + * Fix `res.sendfile` logging standard write errors + +4.10.3 / 2014-11-23 +=================== + + * Fix `res.sendFile` logging standard write errors + * deps: etag@~1.5.1 + * deps: proxy-addr@~1.0.4 + - deps: ipaddr.js@0.1.5 + * deps: qs@2.3.3 + - Fix `arrayLimit` behavior + +4.10.2 / 2014-11-09 +=================== + + * Correctly invoke async router callback asynchronously + * deps: accepts@~1.1.3 + - deps: mime-types@~2.0.3 + * deps: type-is@~1.5.3 + - deps: mime-types@~2.0.3 + +4.10.1 / 2014-10-28 +=================== + + * Fix handling of URLs containing `://` in the path + * deps: qs@2.3.2 + - Fix parsing of mixed objects and values + +4.10.0 / 2014-10-23 +=================== + + * Add support for `app.set('views', array)` + - Views are looked up in sequence in array of directories + * Fix `res.send(status)` to mention `res.sendStatus(status)` + * Fix handling of invalid empty URLs + * Use `content-disposition` module for `res.attachment`/`res.download` + - Sends standards-compliant `Content-Disposition` header + - Full Unicode support + * Use `path.resolve` in view lookup + * deps: debug@~2.1.0 + - Implement `DEBUG_FD` env variable support + * deps: depd@~1.0.0 + * deps: etag@~1.5.0 + - Improve string performance + - Slightly improve speed for weak ETags over 1KB + * deps: finalhandler@0.3.2 + - Terminate in progress response only on error + - Use `on-finished` to determine request status + - deps: debug@~2.1.0 + - deps: on-finished@~2.1.1 + * deps: on-finished@~2.1.1 + - Fix handling of pipelined requests + * deps: qs@2.3.0 + - Fix parsing of mixed implicit and explicit arrays + * deps: send@0.10.1 + - deps: debug@~2.1.0 + - deps: depd@~1.0.0 + - deps: etag@~1.5.0 + - deps: on-finished@~2.1.1 + * deps: serve-static@~1.7.1 + - deps: send@0.10.1 + +4.9.8 / 2014-10-17 +================== + + * Fix `res.redirect` body when redirect status specified + * deps: accepts@~1.1.2 + - Fix error when media type has invalid parameter + - deps: negotiator@0.4.9 + +4.9.7 / 2014-10-10 +================== + + * Fix using same param name in array of paths + +4.9.6 / 2014-10-08 +================== + + * deps: accepts@~1.1.1 + - deps: mime-types@~2.0.2 + - deps: negotiator@0.4.8 + * deps: serve-static@~1.6.4 + - Fix redirect loop when index file serving disabled + * deps: type-is@~1.5.2 + - deps: mime-types@~2.0.2 + +4.9.5 / 2014-09-24 +================== + + * deps: etag@~1.4.0 + * deps: proxy-addr@~1.0.3 + - Use `forwarded` npm module + * deps: send@0.9.3 + - deps: etag@~1.4.0 + * deps: serve-static@~1.6.3 + - deps: send@0.9.3 + +4.9.4 / 2014-09-19 +================== + + * deps: qs@2.2.4 + - Fix issue with object keys starting with numbers truncated + +4.9.3 / 2014-09-18 +================== + + * deps: proxy-addr@~1.0.2 + - Fix a global leak when multiple subnets are trusted + - deps: ipaddr.js@0.1.3 + +4.9.2 / 2014-09-17 +================== + + * Fix regression for empty string `path` in `app.use` + * Fix `router.use` to accept array of middleware without path + * Improve error message for bad `app.use` arguments + +4.9.1 / 2014-09-16 +================== + + * Fix `app.use` to accept array of middleware without path + * deps: depd@0.4.5 + * deps: etag@~1.3.1 + * deps: send@0.9.2 + - deps: depd@0.4.5 + - deps: etag@~1.3.1 + - deps: range-parser@~1.0.2 + * deps: serve-static@~1.6.2 + - deps: send@0.9.2 + +4.9.0 / 2014-09-08 +================== + + * Add `res.sendStatus` + * Invoke callback for sendfile when client aborts + - Applies to `res.sendFile`, `res.sendfile`, and `res.download` + - `err` will be populated with request aborted error + * Support IP address host in `req.subdomains` + * Use `etag` to generate `ETag` headers + * deps: accepts@~1.1.0 + - update `mime-types` + * deps: cookie-signature@1.0.5 + * deps: debug@~2.0.0 + * deps: finalhandler@0.2.0 + - Set `X-Content-Type-Options: nosniff` header + - deps: debug@~2.0.0 + * deps: fresh@0.2.4 + * deps: media-typer@0.3.0 + - Throw error when parameter format invalid on parse + * deps: qs@2.2.3 + - Fix issue where first empty value in array is discarded + * deps: range-parser@~1.0.2 + * deps: send@0.9.1 + - Add `lastModified` option + - Use `etag` to generate `ETag` header + - deps: debug@~2.0.0 + - deps: fresh@0.2.4 + * deps: serve-static@~1.6.1 + - Add `lastModified` option + - deps: send@0.9.1 + * deps: type-is@~1.5.1 + - fix `hasbody` to be true for `content-length: 0` + - deps: media-typer@0.3.0 + - deps: mime-types@~2.0.1 + * deps: vary@~1.0.0 + - Accept valid `Vary` header string as `field` + +4.8.8 / 2014-09-04 +================== + + * deps: send@0.8.5 + - Fix a path traversal issue when using `root` + - Fix malicious path detection for empty string path + * deps: serve-static@~1.5.4 + - deps: send@0.8.5 + +4.8.7 / 2014-08-29 +================== + + * deps: qs@2.2.2 + - Remove unnecessary cloning + +4.8.6 / 2014-08-27 +================== + + * deps: qs@2.2.0 + - Array parsing fix + - Performance improvements + +4.8.5 / 2014-08-18 +================== + + * deps: send@0.8.3 + - deps: destroy@1.0.3 + - deps: on-finished@2.1.0 + * deps: serve-static@~1.5.3 + - deps: send@0.8.3 + +4.8.4 / 2014-08-14 +================== + + * deps: qs@1.2.2 + * deps: send@0.8.2 + - Work around `fd` leak in Node.js 0.10 for `fs.ReadStream` + * deps: serve-static@~1.5.2 + - deps: send@0.8.2 + +4.8.3 / 2014-08-10 +================== + + * deps: parseurl@~1.3.0 + * deps: qs@1.2.1 + * deps: serve-static@~1.5.1 + - Fix parsing of weird `req.originalUrl` values + - deps: parseurl@~1.3.0 + - deps: utils-merge@1.0.0 + +4.8.2 / 2014-08-07 +================== + + * deps: qs@1.2.0 + - Fix parsing array of objects + +4.8.1 / 2014-08-06 +================== + + * fix incorrect deprecation warnings on `res.download` + * deps: qs@1.1.0 + - Accept urlencoded square brackets + - Accept empty values in implicit array notation + +4.8.0 / 2014-08-05 +================== + + * add `res.sendFile` + - accepts a file system path instead of a URL + - requires an absolute path or `root` option specified + * deprecate `res.sendfile` -- use `res.sendFile` instead + * support mounted app as any argument to `app.use()` + * deps: qs@1.0.2 + - Complete rewrite + - Limits array length to 20 + - Limits object depth to 5 + - Limits parameters to 1,000 + * deps: send@0.8.1 + - Add `extensions` option + * deps: serve-static@~1.5.0 + - Add `extensions` option + - deps: send@0.8.1 + +4.7.4 / 2014-08-04 +================== + + * fix `res.sendfile` regression for serving directory index files + * deps: send@0.7.4 + - Fix incorrect 403 on Windows and Node.js 0.11 + - Fix serving index files without root dir + * deps: serve-static@~1.4.4 + - deps: send@0.7.4 + +4.7.3 / 2014-08-04 +================== + + * deps: send@0.7.3 + - Fix incorrect 403 on Windows and Node.js 0.11 + * deps: serve-static@~1.4.3 + - Fix incorrect 403 on Windows and Node.js 0.11 + - deps: send@0.7.3 + +4.7.2 / 2014-07-27 +================== + + * deps: depd@0.4.4 + - Work-around v8 generating empty stack traces + * deps: send@0.7.2 + - deps: depd@0.4.4 + * deps: serve-static@~1.4.2 + +4.7.1 / 2014-07-26 +================== + + * deps: depd@0.4.3 + - Fix exception when global `Error.stackTraceLimit` is too low + * deps: send@0.7.1 + - deps: depd@0.4.3 + * deps: serve-static@~1.4.1 + +4.7.0 / 2014-07-25 +================== + + * fix `req.protocol` for proxy-direct connections + * configurable query parser with `app.set('query parser', parser)` + - `app.set('query parser', 'extended')` parse with "qs" module + - `app.set('query parser', 'simple')` parse with "querystring" core module + - `app.set('query parser', false)` disable query string parsing + - `app.set('query parser', true)` enable simple parsing + * deprecate `res.json(status, obj)` -- use `res.status(status).json(obj)` instead + * deprecate `res.jsonp(status, obj)` -- use `res.status(status).jsonp(obj)` instead + * deprecate `res.send(status, body)` -- use `res.status(status).send(body)` instead + * deps: debug@1.0.4 + * deps: depd@0.4.2 + - Add `TRACE_DEPRECATION` environment variable + - Remove non-standard grey color from color output + - Support `--no-deprecation` argument + - Support `--trace-deprecation` argument + * deps: finalhandler@0.1.0 + - Respond after request fully read + - deps: debug@1.0.4 + * deps: parseurl@~1.2.0 + - Cache URLs based on original value + - Remove no-longer-needed URL mis-parse work-around + - Simplify the "fast-path" `RegExp` + * deps: send@0.7.0 + - Add `dotfiles` option + - Cap `maxAge` value to 1 year + - deps: debug@1.0.4 + - deps: depd@0.4.2 + * deps: serve-static@~1.4.0 + - deps: parseurl@~1.2.0 + - deps: send@0.7.0 + * perf: prevent multiple `Buffer` creation in `res.send` + +4.6.1 / 2014-07-12 +================== + + * fix `subapp.mountpath` regression for `app.use(subapp)` + +4.6.0 / 2014-07-11 +================== + + * accept multiple callbacks to `app.use()` + * add explicit "Rosetta Flash JSONP abuse" protection + - previous versions are not vulnerable; this is just explicit protection + * catch errors in multiple `req.param(name, fn)` handlers + * deprecate `res.redirect(url, status)` -- use `res.redirect(status, url)` instead + * fix `res.send(status, num)` to send `num` as json (not error) + * remove unnecessary escaping when `res.jsonp` returns JSON response + * support non-string `path` in `app.use(path, fn)` + - supports array of paths + - supports `RegExp` + * router: fix optimization on router exit + * router: refactor location of `try` blocks + * router: speed up standard `app.use(fn)` + * deps: debug@1.0.3 + - Add support for multiple wildcards in namespaces + * deps: finalhandler@0.0.3 + - deps: debug@1.0.3 + * deps: methods@1.1.0 + - add `CONNECT` + * deps: parseurl@~1.1.3 + - faster parsing of href-only URLs + * deps: path-to-regexp@0.1.3 + * deps: send@0.6.0 + - deps: debug@1.0.3 + * deps: serve-static@~1.3.2 + - deps: parseurl@~1.1.3 + - deps: send@0.6.0 + * perf: fix arguments reassign deopt in some `res` methods + +4.5.1 / 2014-07-06 +================== + + * fix routing regression when altering `req.method` + +4.5.0 / 2014-07-04 +================== + + * add deprecation message to non-plural `req.accepts*` + * add deprecation message to `res.send(body, status)` + * add deprecation message to `res.vary()` + * add `headers` option to `res.sendfile` + - use to set headers on successful file transfer + * add `mergeParams` option to `Router` + - merges `req.params` from parent routes + * add `req.hostname` -- correct name for what `req.host` returns + * deprecate things with `depd` module + * deprecate `req.host` -- use `req.hostname` instead + * fix behavior when handling request without routes + * fix handling when `route.all` is only route + * invoke `router.param()` only when route matches + * restore `req.params` after invoking router + * use `finalhandler` for final response handling + * use `media-typer` to alter content-type charset + * deps: accepts@~1.0.7 + * deps: send@0.5.0 + - Accept string for `maxage` (converted by `ms`) + - Include link in default redirect response + * deps: serve-static@~1.3.0 + - Accept string for `maxAge` (converted by `ms`) + - Add `setHeaders` option + - Include HTML link in redirect response + - deps: send@0.5.0 + * deps: type-is@~1.3.2 + +4.4.5 / 2014-06-26 +================== + + * deps: cookie-signature@1.0.4 + - fix for timing attacks + +4.4.4 / 2014-06-20 +================== + + * fix `res.attachment` Unicode filenames in Safari + * fix "trim prefix" debug message in `express:router` + * deps: accepts@~1.0.5 + * deps: buffer-crc32@0.2.3 + +4.4.3 / 2014-06-11 +================== + + * fix persistence of modified `req.params[name]` from `app.param()` + * deps: accepts@1.0.3 + - deps: negotiator@0.4.6 + * deps: debug@1.0.2 + * deps: send@0.4.3 + - Do not throw un-catchable error on file open race condition + - Use `escape-html` for HTML escaping + - deps: debug@1.0.2 + - deps: finished@1.2.2 + - deps: fresh@0.2.2 + * deps: serve-static@1.2.3 + - Do not throw un-catchable error on file open race condition + - deps: send@0.4.3 + +4.4.2 / 2014-06-09 +================== + + * fix catching errors from top-level handlers + * use `vary` module for `res.vary` + * deps: debug@1.0.1 + * deps: proxy-addr@1.0.1 + * deps: send@0.4.2 + - fix "event emitter leak" warnings + - deps: debug@1.0.1 + - deps: finished@1.2.1 + * deps: serve-static@1.2.2 + - fix "event emitter leak" warnings + - deps: send@0.4.2 + * deps: type-is@1.2.1 + +4.4.1 / 2014-06-02 +================== + + * deps: methods@1.0.1 + * deps: send@0.4.1 + - Send `max-age` in `Cache-Control` in correct format + * deps: serve-static@1.2.1 + - use `escape-html` for escaping + - deps: send@0.4.1 + +4.4.0 / 2014-05-30 +================== + + * custom etag control with `app.set('etag', val)` + - `app.set('etag', function(body, encoding){ return '"etag"' })` custom etag generation + - `app.set('etag', 'weak')` weak tag + - `app.set('etag', 'strong')` strong etag + - `app.set('etag', false)` turn off + - `app.set('etag', true)` standard etag + * mark `res.send` ETag as weak and reduce collisions + * update accepts to 1.0.2 + - Fix interpretation when header not in request + * update send to 0.4.0 + - Calculate ETag with md5 for reduced collisions + - Ignore stream errors after request ends + - deps: debug@0.8.1 + * update serve-static to 1.2.0 + - Calculate ETag with md5 for reduced collisions + - Ignore stream errors after request ends + - deps: send@0.4.0 + +4.3.2 / 2014-05-28 +================== + + * fix handling of errors from `router.param()` callbacks + +4.3.1 / 2014-05-23 +================== + + * revert "fix behavior of multiple `app.VERB` for the same path" + - this caused a regression in the order of route execution + +4.3.0 / 2014-05-21 +================== + + * add `req.baseUrl` to access the path stripped from `req.url` in routes + * fix behavior of multiple `app.VERB` for the same path + * fix issue routing requests among sub routers + * invoke `router.param()` only when necessary instead of every match + * proper proxy trust with `app.set('trust proxy', trust)` + - `app.set('trust proxy', 1)` trust first hop + - `app.set('trust proxy', 'loopback')` trust loopback addresses + - `app.set('trust proxy', '10.0.0.1')` trust single IP + - `app.set('trust proxy', '10.0.0.1/16')` trust subnet + - `app.set('trust proxy', '10.0.0.1, 10.0.0.2')` trust list + - `app.set('trust proxy', false)` turn off + - `app.set('trust proxy', true)` trust everything + * set proper `charset` in `Content-Type` for `res.send` + * update type-is to 1.2.0 + - support suffix matching + +4.2.0 / 2014-05-11 +================== + + * deprecate `app.del()` -- use `app.delete()` instead + * deprecate `res.json(obj, status)` -- use `res.json(status, obj)` instead + - the edge-case `res.json(status, num)` requires `res.status(status).json(num)` + * deprecate `res.jsonp(obj, status)` -- use `res.jsonp(status, obj)` instead + - the edge-case `res.jsonp(status, num)` requires `res.status(status).jsonp(num)` + * fix `req.next` when inside router instance + * include `ETag` header in `HEAD` requests + * keep previous `Content-Type` for `res.jsonp` + * support PURGE method + - add `app.purge` + - add `router.purge` + - include PURGE in `app.all` + * update debug to 0.8.0 + - add `enable()` method + - change from stderr to stdout + * update methods to 1.0.0 + - add PURGE + +4.1.2 / 2014-05-08 +================== + + * fix `req.host` for IPv6 literals + * fix `res.jsonp` error if callback param is object + +4.1.1 / 2014-04-27 +================== + + * fix package.json to reflect supported node version + +4.1.0 / 2014-04-24 +================== + + * pass options from `res.sendfile` to `send` + * preserve casing of headers in `res.header` and `res.set` + * support unicode file names in `res.attachment` and `res.download` + * update accepts to 1.0.1 + - deps: negotiator@0.4.0 + * update cookie to 0.1.2 + - Fix for maxAge == 0 + - made compat with expires field + * update send to 0.3.0 + - Accept API options in options object + - Coerce option types + - Control whether to generate etags + - Default directory access to 403 when index disabled + - Fix sending files with dots without root set + - Include file path in etag + - Make "Can't set headers after they are sent." catchable + - Send full entity-body for multi range requests + - Set etags to "weak" + - Support "If-Range" header + - Support multiple index paths + - deps: mime@1.2.11 + * update serve-static to 1.1.0 + - Accept options directly to `send` module + - Resolve relative paths at middleware setup + - Use parseurl to parse the URL from request + - deps: send@0.3.0 + * update type-is to 1.1.0 + - add non-array values support + - add `multipart` as a shorthand + +4.0.0 / 2014-04-09 +================== + + * remove: + - node 0.8 support + - connect and connect's patches except for charset handling + - express(1) - moved to [express-generator](https://github.com/expressjs/generator) + - `express.createServer()` - it has been deprecated for a long time. Use `express()` + - `app.configure` - use logic in your own app code + - `app.router` - is removed + - `req.auth` - use `basic-auth` instead + - `req.accepted*` - use `req.accepts*()` instead + - `res.location` - relative URL resolution is removed + - `res.charset` - include the charset in the content type when using `res.set()` + - all bundled middleware except `static` + * change: + - `app.route` -> `app.mountpath` when mounting an express app in another express app + - `json spaces` no longer enabled by default in development + - `req.accepts*` -> `req.accepts*s` - i.e. `req.acceptsEncoding` -> `req.acceptsEncodings` + - `req.params` is now an object instead of an array + - `res.locals` is no longer a function. It is a plain js object. Treat it as such. + - `res.headerSent` -> `res.headersSent` to match node.js ServerResponse object + * refactor: + - `req.accepts*` with [accepts](https://github.com/expressjs/accepts) + - `req.is` with [type-is](https://github.com/expressjs/type-is) + - [path-to-regexp](https://github.com/component/path-to-regexp) + * add: + - `app.router()` - returns the app Router instance + - `app.route()` - Proxy to the app's `Router#route()` method to create a new route + - Router & Route - public API + +3.21.2 / 2015-07-31 +=================== + + * deps: connect@2.30.2 + - deps: body-parser@~1.13.3 + - deps: compression@~1.5.2 + - deps: errorhandler@~1.4.2 + - deps: method-override@~2.3.5 + - deps: serve-index@~1.7.2 + - deps: type-is@~1.6.6 + - deps: vhost@~3.0.1 + * deps: vary@~1.0.1 + - Fix setting empty header from empty `field` + - perf: enable strict mode + - perf: remove argument reassignments + +3.21.1 / 2015-07-05 +=================== + + * deps: basic-auth@~1.0.3 + * deps: connect@2.30.1 + - deps: body-parser@~1.13.2 + - deps: compression@~1.5.1 + - deps: errorhandler@~1.4.1 + - deps: morgan@~1.6.1 + - deps: pause@0.1.0 + - deps: qs@4.0.0 + - deps: serve-index@~1.7.1 + - deps: type-is@~1.6.4 + +3.21.0 / 2015-06-18 +=================== + + * deps: basic-auth@1.0.2 + - perf: enable strict mode + - perf: hoist regular expression + - perf: parse with regular expressions + - perf: remove argument reassignment + * deps: connect@2.30.0 + - deps: body-parser@~1.13.1 + - deps: bytes@2.1.0 + - deps: compression@~1.5.0 + - deps: cookie@0.1.3 + - deps: cookie-parser@~1.3.5 + - deps: csurf@~1.8.3 + - deps: errorhandler@~1.4.0 + - deps: express-session@~1.11.3 + - deps: finalhandler@0.4.0 + - deps: fresh@0.3.0 + - deps: morgan@~1.6.0 + - deps: serve-favicon@~2.3.0 + - deps: serve-index@~1.7.0 + - deps: serve-static@~1.10.0 + - deps: type-is@~1.6.3 + * deps: cookie@0.1.3 + - perf: deduce the scope of try-catch deopt + - perf: remove argument reassignments + * deps: escape-html@1.0.2 + * deps: etag@~1.7.0 + - Always include entity length in ETags for hash length extensions + - Generate non-Stats ETags using MD5 only (no longer CRC32) + - Improve stat performance by removing hashing + - Improve support for JXcore + - Remove base64 padding in ETags to shorten + - Support "fake" stats objects in environments without fs + - Use MD5 instead of MD4 in weak ETags over 1KB + * deps: fresh@0.3.0 + - Add weak `ETag` matching support + * deps: mkdirp@0.5.1 + - Work in global strict mode + * deps: send@0.13.0 + - Allow Node.js HTTP server to set `Date` response header + - Fix incorrectly removing `Content-Location` on 304 response + - Improve the default redirect response headers + - Send appropriate headers on default error response + - Use `http-errors` for standard emitted errors + - Use `statuses` instead of `http` module for status messages + - deps: escape-html@1.0.2 + - deps: etag@~1.7.0 + - deps: fresh@0.3.0 + - deps: on-finished@~2.3.0 + - perf: enable strict mode + - perf: remove unnecessary array allocations + +3.20.3 / 2015-05-17 +=================== + + * deps: connect@2.29.2 + - deps: body-parser@~1.12.4 + - deps: compression@~1.4.4 + - deps: connect-timeout@~1.6.2 + - deps: debug@~2.2.0 + - deps: depd@~1.0.1 + - deps: errorhandler@~1.3.6 + - deps: finalhandler@0.3.6 + - deps: method-override@~2.3.3 + - deps: morgan@~1.5.3 + - deps: qs@2.4.2 + - deps: response-time@~2.3.1 + - deps: serve-favicon@~2.2.1 + - deps: serve-index@~1.6.4 + - deps: serve-static@~1.9.3 + - deps: type-is@~1.6.2 + * deps: debug@~2.2.0 + - deps: ms@0.7.1 + * deps: depd@~1.0.1 + * deps: proxy-addr@~1.0.8 + - deps: ipaddr.js@1.0.1 + * deps: send@0.12.3 + - deps: debug@~2.2.0 + - deps: depd@~1.0.1 + - deps: etag@~1.6.0 + - deps: ms@0.7.1 + - deps: on-finished@~2.2.1 + +3.20.2 / 2015-03-16 +=================== + + * deps: connect@2.29.1 + - deps: body-parser@~1.12.2 + - deps: compression@~1.4.3 + - deps: connect-timeout@~1.6.1 + - deps: debug@~2.1.3 + - deps: errorhandler@~1.3.5 + - deps: express-session@~1.10.4 + - deps: finalhandler@0.3.4 + - deps: method-override@~2.3.2 + - deps: morgan@~1.5.2 + - deps: qs@2.4.1 + - deps: serve-index@~1.6.3 + - deps: serve-static@~1.9.2 + - deps: type-is@~1.6.1 + * deps: debug@~2.1.3 + - Fix high intensity foreground color for bold + - deps: ms@0.7.0 + * deps: merge-descriptors@1.0.0 + * deps: proxy-addr@~1.0.7 + - deps: ipaddr.js@0.1.9 + * deps: send@0.12.2 + - Throw errors early for invalid `extensions` or `index` options + - deps: debug@~2.1.3 + +3.20.1 / 2015-02-28 +=================== + + * Fix `req.host` when using "trust proxy" hops count + * Fix `req.protocol`/`req.secure` when using "trust proxy" hops count + +3.20.0 / 2015-02-18 +=================== + + * Fix `"trust proxy"` setting to inherit when app is mounted + * Generate `ETag`s for all request responses + - No longer restricted to only responses for `GET` and `HEAD` requests + * Use `content-type` to parse `Content-Type` headers + * deps: connect@2.29.0 + - Use `content-type` to parse `Content-Type` headers + - deps: body-parser@~1.12.0 + - deps: compression@~1.4.1 + - deps: connect-timeout@~1.6.0 + - deps: cookie-parser@~1.3.4 + - deps: cookie-signature@1.0.6 + - deps: csurf@~1.7.0 + - deps: errorhandler@~1.3.4 + - deps: express-session@~1.10.3 + - deps: http-errors@~1.3.1 + - deps: response-time@~2.3.0 + - deps: serve-index@~1.6.2 + - deps: serve-static@~1.9.1 + - deps: type-is@~1.6.0 + * deps: cookie-signature@1.0.6 + * deps: send@0.12.1 + - Always read the stat size from the file + - Fix mutating passed-in `options` + - deps: mime@1.3.4 + +3.19.2 / 2015-02-01 +=================== + + * deps: connect@2.28.3 + - deps: compression@~1.3.1 + - deps: csurf@~1.6.6 + - deps: errorhandler@~1.3.3 + - deps: express-session@~1.10.2 + - deps: serve-index@~1.6.1 + - deps: type-is@~1.5.6 + * deps: proxy-addr@~1.0.6 + - deps: ipaddr.js@0.1.8 + +3.19.1 / 2015-01-20 +=================== + + * deps: connect@2.28.2 + - deps: body-parser@~1.10.2 + - deps: serve-static@~1.8.1 + * deps: send@0.11.1 + - Fix root path disclosure + +3.19.0 / 2015-01-09 +=================== + + * Fix `OPTIONS` responses to include the `HEAD` method property + * Use `readline` for prompt in `express(1)` + * deps: commander@2.6.0 + * deps: connect@2.28.1 + - deps: body-parser@~1.10.1 + - deps: compression@~1.3.0 + - deps: connect-timeout@~1.5.0 + - deps: csurf@~1.6.4 + - deps: debug@~2.1.1 + - deps: errorhandler@~1.3.2 + - deps: express-session@~1.10.1 + - deps: finalhandler@0.3.3 + - deps: method-override@~2.3.1 + - deps: morgan@~1.5.1 + - deps: serve-favicon@~2.2.0 + - deps: serve-index@~1.6.0 + - deps: serve-static@~1.8.0 + - deps: type-is@~1.5.5 + * deps: debug@~2.1.1 + * deps: methods@~1.1.1 + * deps: proxy-addr@~1.0.5 + - deps: ipaddr.js@0.1.6 + * deps: send@0.11.0 + - deps: debug@~2.1.1 + - deps: etag@~1.5.1 + - deps: ms@0.7.0 + - deps: on-finished@~2.2.0 + +3.18.6 / 2014-12-12 +=================== + + * Fix exception in `req.fresh`/`req.stale` without response headers + +3.18.5 / 2014-12-11 +=================== + + * deps: connect@2.27.6 + - deps: compression@~1.2.2 + - deps: express-session@~1.9.3 + - deps: http-errors@~1.2.8 + - deps: serve-index@~1.5.3 + - deps: type-is@~1.5.4 + +3.18.4 / 2014-11-23 +=================== + + * deps: connect@2.27.4 + - deps: body-parser@~1.9.3 + - deps: compression@~1.2.1 + - deps: errorhandler@~1.2.3 + - deps: express-session@~1.9.2 + - deps: qs@2.3.3 + - deps: serve-favicon@~2.1.7 + - deps: serve-static@~1.5.1 + - deps: type-is@~1.5.3 + * deps: etag@~1.5.1 + * deps: proxy-addr@~1.0.4 + - deps: ipaddr.js@0.1.5 + +3.18.3 / 2014-11-09 +=================== + + * deps: connect@2.27.3 + - Correctly invoke async callback asynchronously + - deps: csurf@~1.6.3 + +3.18.2 / 2014-10-28 +=================== + + * deps: connect@2.27.2 + - Fix handling of URLs containing `://` in the path + - deps: body-parser@~1.9.2 + - deps: qs@2.3.2 + +3.18.1 / 2014-10-22 +=================== + + * Fix internal `utils.merge` deprecation warnings + * deps: connect@2.27.1 + - deps: body-parser@~1.9.1 + - deps: express-session@~1.9.1 + - deps: finalhandler@0.3.2 + - deps: morgan@~1.4.1 + - deps: qs@2.3.0 + - deps: serve-static@~1.7.1 + * deps: send@0.10.1 + - deps: on-finished@~2.1.1 + +3.18.0 / 2014-10-17 +=================== + + * Use `content-disposition` module for `res.attachment`/`res.download` + - Sends standards-compliant `Content-Disposition` header + - Full Unicode support + * Use `etag` module to generate `ETag` headers + * deps: connect@2.27.0 + - Use `http-errors` module for creating errors + - Use `utils-merge` module for merging objects + - deps: body-parser@~1.9.0 + - deps: compression@~1.2.0 + - deps: connect-timeout@~1.4.0 + - deps: debug@~2.1.0 + - deps: depd@~1.0.0 + - deps: express-session@~1.9.0 + - deps: finalhandler@0.3.1 + - deps: method-override@~2.3.0 + - deps: morgan@~1.4.0 + - deps: response-time@~2.2.0 + - deps: serve-favicon@~2.1.6 + - deps: serve-index@~1.5.0 + - deps: serve-static@~1.7.0 + * deps: debug@~2.1.0 + - Implement `DEBUG_FD` env variable support + * deps: depd@~1.0.0 + * deps: send@0.10.0 + - deps: debug@~2.1.0 + - deps: depd@~1.0.0 + - deps: etag@~1.5.0 + +3.17.8 / 2014-10-15 +=================== + + * deps: connect@2.26.6 + - deps: compression@~1.1.2 + - deps: csurf@~1.6.2 + - deps: errorhandler@~1.2.2 + +3.17.7 / 2014-10-08 +=================== + + * deps: connect@2.26.5 + - Fix accepting non-object arguments to `logger` + - deps: serve-static@~1.6.4 + +3.17.6 / 2014-10-02 +=================== + + * deps: connect@2.26.4 + - deps: morgan@~1.3.2 + - deps: type-is@~1.5.2 + +3.17.5 / 2014-09-24 +=================== + + * deps: connect@2.26.3 + - deps: body-parser@~1.8.4 + - deps: serve-favicon@~2.1.5 + - deps: serve-static@~1.6.3 + * deps: proxy-addr@~1.0.3 + - Use `forwarded` npm module + * deps: send@0.9.3 + - deps: etag@~1.4.0 + +3.17.4 / 2014-09-19 +=================== + + * deps: connect@2.26.2 + - deps: body-parser@~1.8.3 + - deps: qs@2.2.4 + +3.17.3 / 2014-09-18 +=================== + + * deps: proxy-addr@~1.0.2 + - Fix a global leak when multiple subnets are trusted + - deps: ipaddr.js@0.1.3 + +3.17.2 / 2014-09-15 +=================== + + * Use `crc` instead of `buffer-crc32` for speed + * deps: connect@2.26.1 + - deps: body-parser@~1.8.2 + - deps: depd@0.4.5 + - deps: express-session@~1.8.2 + - deps: morgan@~1.3.1 + - deps: serve-favicon@~2.1.3 + - deps: serve-static@~1.6.2 + * deps: depd@0.4.5 + * deps: send@0.9.2 + - deps: depd@0.4.5 + - deps: etag@~1.3.1 + - deps: range-parser@~1.0.2 + +3.17.1 / 2014-09-08 +=================== + + * Fix error in `req.subdomains` on empty host + +3.17.0 / 2014-09-08 +=================== + + * Support `X-Forwarded-Host` in `req.subdomains` + * Support IP address host in `req.subdomains` + * deps: connect@2.26.0 + - deps: body-parser@~1.8.1 + - deps: compression@~1.1.0 + - deps: connect-timeout@~1.3.0 + - deps: cookie-parser@~1.3.3 + - deps: cookie-signature@1.0.5 + - deps: csurf@~1.6.1 + - deps: debug@~2.0.0 + - deps: errorhandler@~1.2.0 + - deps: express-session@~1.8.1 + - deps: finalhandler@0.2.0 + - deps: fresh@0.2.4 + - deps: media-typer@0.3.0 + - deps: method-override@~2.2.0 + - deps: morgan@~1.3.0 + - deps: qs@2.2.3 + - deps: serve-favicon@~2.1.3 + - deps: serve-index@~1.2.1 + - deps: serve-static@~1.6.1 + - deps: type-is@~1.5.1 + - deps: vhost@~3.0.0 + * deps: cookie-signature@1.0.5 + * deps: debug@~2.0.0 + * deps: fresh@0.2.4 + * deps: media-typer@0.3.0 + - Throw error when parameter format invalid on parse + * deps: range-parser@~1.0.2 + * deps: send@0.9.1 + - Add `lastModified` option + - Use `etag` to generate `ETag` header + - deps: debug@~2.0.0 + - deps: fresh@0.2.4 + * deps: vary@~1.0.0 + - Accept valid `Vary` header string as `field` + +3.16.10 / 2014-09-04 +==================== + + * deps: connect@2.25.10 + - deps: serve-static@~1.5.4 + * deps: send@0.8.5 + - Fix a path traversal issue when using `root` + - Fix malicious path detection for empty string path + +3.16.9 / 2014-08-29 +=================== + + * deps: connect@2.25.9 + - deps: body-parser@~1.6.7 + - deps: qs@2.2.2 + +3.16.8 / 2014-08-27 +=================== + + * deps: connect@2.25.8 + - deps: body-parser@~1.6.6 + - deps: csurf@~1.4.1 + - deps: qs@2.2.0 + +3.16.7 / 2014-08-18 +=================== + + * deps: connect@2.25.7 + - deps: body-parser@~1.6.5 + - deps: express-session@~1.7.6 + - deps: morgan@~1.2.3 + - deps: serve-static@~1.5.3 + * deps: send@0.8.3 + - deps: destroy@1.0.3 + - deps: on-finished@2.1.0 + +3.16.6 / 2014-08-14 +=================== + + * deps: connect@2.25.6 + - deps: body-parser@~1.6.4 + - deps: qs@1.2.2 + - deps: serve-static@~1.5.2 + * deps: send@0.8.2 + - Work around `fd` leak in Node.js 0.10 for `fs.ReadStream` + +3.16.5 / 2014-08-11 +=================== + + * deps: connect@2.25.5 + - Fix backwards compatibility in `logger` + +3.16.4 / 2014-08-10 +=================== + + * Fix original URL parsing in `res.location` + * deps: connect@2.25.4 + - Fix `query` middleware breaking with argument + - deps: body-parser@~1.6.3 + - deps: compression@~1.0.11 + - deps: connect-timeout@~1.2.2 + - deps: express-session@~1.7.5 + - deps: method-override@~2.1.3 + - deps: on-headers@~1.0.0 + - deps: parseurl@~1.3.0 + - deps: qs@1.2.1 + - deps: response-time@~2.0.1 + - deps: serve-index@~1.1.6 + - deps: serve-static@~1.5.1 + * deps: parseurl@~1.3.0 + +3.16.3 / 2014-08-07 +=================== + + * deps: connect@2.25.3 + - deps: multiparty@3.3.2 + +3.16.2 / 2014-08-07 +=================== + + * deps: connect@2.25.2 + - deps: body-parser@~1.6.2 + - deps: qs@1.2.0 + +3.16.1 / 2014-08-06 +=================== + + * deps: connect@2.25.1 + - deps: body-parser@~1.6.1 + - deps: qs@1.1.0 + +3.16.0 / 2014-08-05 +=================== + + * deps: connect@2.25.0 + - deps: body-parser@~1.6.0 + - deps: compression@~1.0.10 + - deps: csurf@~1.4.0 + - deps: express-session@~1.7.4 + - deps: qs@1.0.2 + - deps: serve-static@~1.5.0 + * deps: send@0.8.1 + - Add `extensions` option + +3.15.3 / 2014-08-04 +=================== + + * fix `res.sendfile` regression for serving directory index files + * deps: connect@2.24.3 + - deps: serve-index@~1.1.5 + - deps: serve-static@~1.4.4 + * deps: send@0.7.4 + - Fix incorrect 403 on Windows and Node.js 0.11 + - Fix serving index files without root dir + +3.15.2 / 2014-07-27 +=================== + + * deps: connect@2.24.2 + - deps: body-parser@~1.5.2 + - deps: depd@0.4.4 + - deps: express-session@~1.7.2 + - deps: morgan@~1.2.2 + - deps: serve-static@~1.4.2 + * deps: depd@0.4.4 + - Work-around v8 generating empty stack traces + * deps: send@0.7.2 + - deps: depd@0.4.4 + +3.15.1 / 2014-07-26 +=================== + + * deps: connect@2.24.1 + - deps: body-parser@~1.5.1 + - deps: depd@0.4.3 + - deps: express-session@~1.7.1 + - deps: morgan@~1.2.1 + - deps: serve-index@~1.1.4 + - deps: serve-static@~1.4.1 + * deps: depd@0.4.3 + - Fix exception when global `Error.stackTraceLimit` is too low + * deps: send@0.7.1 + - deps: depd@0.4.3 + +3.15.0 / 2014-07-22 +=================== + + * Fix `req.protocol` for proxy-direct connections + * Pass options from `res.sendfile` to `send` + * deps: connect@2.24.0 + - deps: body-parser@~1.5.0 + - deps: compression@~1.0.9 + - deps: connect-timeout@~1.2.1 + - deps: debug@1.0.4 + - deps: depd@0.4.2 + - deps: express-session@~1.7.0 + - deps: finalhandler@0.1.0 + - deps: method-override@~2.1.2 + - deps: morgan@~1.2.0 + - deps: multiparty@3.3.1 + - deps: parseurl@~1.2.0 + - deps: serve-static@~1.4.0 + * deps: debug@1.0.4 + * deps: depd@0.4.2 + - Add `TRACE_DEPRECATION` environment variable + - Remove non-standard grey color from color output + - Support `--no-deprecation` argument + - Support `--trace-deprecation` argument + * deps: parseurl@~1.2.0 + - Cache URLs based on original value + - Remove no-longer-needed URL mis-parse work-around + - Simplify the "fast-path" `RegExp` + * deps: send@0.7.0 + - Add `dotfiles` option + - Cap `maxAge` value to 1 year + - deps: debug@1.0.4 + - deps: depd@0.4.2 + +3.14.0 / 2014-07-11 +=================== + + * add explicit "Rosetta Flash JSONP abuse" protection + - previous versions are not vulnerable; this is just explicit protection + * deprecate `res.redirect(url, status)` -- use `res.redirect(status, url)` instead + * fix `res.send(status, num)` to send `num` as json (not error) + * remove unnecessary escaping when `res.jsonp` returns JSON response + * deps: basic-auth@1.0.0 + - support empty password + - support empty username + * deps: connect@2.23.0 + - deps: debug@1.0.3 + - deps: express-session@~1.6.4 + - deps: method-override@~2.1.0 + - deps: parseurl@~1.1.3 + - deps: serve-static@~1.3.1 + * deps: debug@1.0.3 + - Add support for multiple wildcards in namespaces + * deps: methods@1.1.0 + - add `CONNECT` + * deps: parseurl@~1.1.3 + - faster parsing of href-only URLs + +3.13.0 / 2014-07-03 +=================== + + * add deprecation message to `app.configure` + * add deprecation message to `req.auth` + * use `basic-auth` to parse `Authorization` header + * deps: connect@2.22.0 + - deps: csurf@~1.3.0 + - deps: express-session@~1.6.1 + - deps: multiparty@3.3.0 + - deps: serve-static@~1.3.0 + * deps: send@0.5.0 + - Accept string for `maxage` (converted by `ms`) + - Include link in default redirect response + +3.12.1 / 2014-06-26 +=================== + + * deps: connect@2.21.1 + - deps: cookie-parser@1.3.2 + - deps: cookie-signature@1.0.4 + - deps: express-session@~1.5.2 + - deps: type-is@~1.3.2 + * deps: cookie-signature@1.0.4 + - fix for timing attacks + +3.12.0 / 2014-06-21 +=================== + + * use `media-typer` to alter content-type charset + * deps: connect@2.21.0 + - deprecate `connect(middleware)` -- use `app.use(middleware)` instead + - deprecate `connect.createServer()` -- use `connect()` instead + - fix `res.setHeader()` patch to work with with get -> append -> set pattern + - deps: compression@~1.0.8 + - deps: errorhandler@~1.1.1 + - deps: express-session@~1.5.0 + - deps: serve-index@~1.1.3 + +3.11.0 / 2014-06-19 +=================== + + * deprecate things with `depd` module + * deps: buffer-crc32@0.2.3 + * deps: connect@2.20.2 + - deprecate `verify` option to `json` -- use `body-parser` npm module instead + - deprecate `verify` option to `urlencoded` -- use `body-parser` npm module instead + - deprecate things with `depd` module + - use `finalhandler` for final response handling + - use `media-typer` to parse `content-type` for charset + - deps: body-parser@1.4.3 + - deps: connect-timeout@1.1.1 + - deps: cookie-parser@1.3.1 + - deps: csurf@1.2.2 + - deps: errorhandler@1.1.0 + - deps: express-session@1.4.0 + - deps: multiparty@3.2.9 + - deps: serve-index@1.1.2 + - deps: type-is@1.3.1 + - deps: vhost@2.0.0 + +3.10.5 / 2014-06-11 +=================== + + * deps: connect@2.19.6 + - deps: body-parser@1.3.1 + - deps: compression@1.0.7 + - deps: debug@1.0.2 + - deps: serve-index@1.1.1 + - deps: serve-static@1.2.3 + * deps: debug@1.0.2 + * deps: send@0.4.3 + - Do not throw un-catchable error on file open race condition + - Use `escape-html` for HTML escaping + - deps: debug@1.0.2 + - deps: finished@1.2.2 + - deps: fresh@0.2.2 + +3.10.4 / 2014-06-09 +=================== + + * deps: connect@2.19.5 + - fix "event emitter leak" warnings + - deps: csurf@1.2.1 + - deps: debug@1.0.1 + - deps: serve-static@1.2.2 + - deps: type-is@1.2.1 + * deps: debug@1.0.1 + * deps: send@0.4.2 + - fix "event emitter leak" warnings + - deps: finished@1.2.1 + - deps: debug@1.0.1 + +3.10.3 / 2014-06-05 +=================== + + * use `vary` module for `res.vary` + * deps: connect@2.19.4 + - deps: errorhandler@1.0.2 + - deps: method-override@2.0.2 + - deps: serve-favicon@2.0.1 + * deps: debug@1.0.0 + +3.10.2 / 2014-06-03 +=================== + + * deps: connect@2.19.3 + - deps: compression@1.0.6 + +3.10.1 / 2014-06-03 +=================== + + * deps: connect@2.19.2 + - deps: compression@1.0.4 + * deps: proxy-addr@1.0.1 + +3.10.0 / 2014-06-02 +=================== + + * deps: connect@2.19.1 + - deprecate `methodOverride()` -- use `method-override` npm module instead + - deps: body-parser@1.3.0 + - deps: method-override@2.0.1 + - deps: multiparty@3.2.8 + - deps: response-time@2.0.0 + - deps: serve-static@1.2.1 + * deps: methods@1.0.1 + * deps: send@0.4.1 + - Send `max-age` in `Cache-Control` in correct format + +3.9.0 / 2014-05-30 +================== + + * custom etag control with `app.set('etag', val)` + - `app.set('etag', function(body, encoding){ return '"etag"' })` custom etag generation + - `app.set('etag', 'weak')` weak tag + - `app.set('etag', 'strong')` strong etag + - `app.set('etag', false)` turn off + - `app.set('etag', true)` standard etag + * Include ETag in HEAD requests + * mark `res.send` ETag as weak and reduce collisions + * update connect to 2.18.0 + - deps: compression@1.0.3 + - deps: serve-index@1.1.0 + - deps: serve-static@1.2.0 + * update send to 0.4.0 + - Calculate ETag with md5 for reduced collisions + - Ignore stream errors after request ends + - deps: debug@0.8.1 + +3.8.1 / 2014-05-27 +================== + + * update connect to 2.17.3 + - deps: body-parser@1.2.2 + - deps: express-session@1.2.1 + - deps: method-override@1.0.2 + +3.8.0 / 2014-05-21 +================== + + * keep previous `Content-Type` for `res.jsonp` + * set proper `charset` in `Content-Type` for `res.send` + * update connect to 2.17.1 + - fix `res.charset` appending charset when `content-type` has one + - deps: express-session@1.2.0 + - deps: morgan@1.1.1 + - deps: serve-index@1.0.3 + +3.7.0 / 2014-05-18 +================== + + * proper proxy trust with `app.set('trust proxy', trust)` + - `app.set('trust proxy', 1)` trust first hop + - `app.set('trust proxy', 'loopback')` trust loopback addresses + - `app.set('trust proxy', '10.0.0.1')` trust single IP + - `app.set('trust proxy', '10.0.0.1/16')` trust subnet + - `app.set('trust proxy', '10.0.0.1, 10.0.0.2')` trust list + - `app.set('trust proxy', false)` turn off + - `app.set('trust proxy', true)` trust everything + * update connect to 2.16.2 + - deprecate `res.headerSent` -- use `res.headersSent` + - deprecate `res.on("header")` -- use on-headers module instead + - fix edge-case in `res.appendHeader` that would append in wrong order + - json: use body-parser + - urlencoded: use body-parser + - dep: bytes@1.0.0 + - dep: cookie-parser@1.1.0 + - dep: csurf@1.2.0 + - dep: express-session@1.1.0 + - dep: method-override@1.0.1 + +3.6.0 / 2014-05-09 +================== + + * deprecate `app.del()` -- use `app.delete()` instead + * deprecate `res.json(obj, status)` -- use `res.json(status, obj)` instead + - the edge-case `res.json(status, num)` requires `res.status(status).json(num)` + * deprecate `res.jsonp(obj, status)` -- use `res.jsonp(status, obj)` instead + - the edge-case `res.jsonp(status, num)` requires `res.status(status).jsonp(num)` + * support PURGE method + - add `app.purge` + - add `router.purge` + - include PURGE in `app.all` + * update connect to 2.15.0 + * Add `res.appendHeader` + * Call error stack even when response has been sent + * Patch `res.headerSent` to return Boolean + * Patch `res.headersSent` for node.js 0.8 + * Prevent default 404 handler after response sent + * dep: compression@1.0.2 + * dep: connect-timeout@1.1.0 + * dep: debug@^0.8.0 + * dep: errorhandler@1.0.1 + * dep: express-session@1.0.4 + * dep: morgan@1.0.1 + * dep: serve-favicon@2.0.0 + * dep: serve-index@1.0.2 + * update debug to 0.8.0 + * add `enable()` method + * change from stderr to stdout + * update methods to 1.0.0 + - add PURGE + * update mkdirp to 0.5.0 + +3.5.3 / 2014-05-08 +================== + + * fix `req.host` for IPv6 literals + * fix `res.jsonp` error if callback param is object + +3.5.2 / 2014-04-24 +================== + + * update connect to 2.14.5 + * update cookie to 0.1.2 + * update mkdirp to 0.4.0 + * update send to 0.3.0 + +3.5.1 / 2014-03-25 +================== + + * pin less-middleware in generated app + +3.5.0 / 2014-03-06 +================== + + * bump deps + +3.4.8 / 2014-01-13 +================== + + * prevent incorrect automatic OPTIONS responses #1868 @dpatti + * update binary and examples for jade 1.0 #1876 @yossi, #1877 @reqshark, #1892 @matheusazzi + * throw 400 in case of malformed paths @rlidwka + +3.4.7 / 2013-12-10 +================== + + * update connect + +3.4.6 / 2013-12-01 +================== + + * update connect (raw-body) + +3.4.5 / 2013-11-27 +================== + + * update connect + * res.location: remove leading ./ #1802 @kapouer + * res.redirect: fix `res.redirect('toString') #1829 @michaelficarra + * res.send: always send ETag when content-length > 0 + * router: add Router.all() method + +3.4.4 / 2013-10-29 +================== + + * update connect + * update supertest + * update methods + * express(1): replace bodyParser() with urlencoded() and json() #1795 @chirag04 + +3.4.3 / 2013-10-23 +================== + + * update connect + +3.4.2 / 2013-10-18 +================== + + * update connect + * downgrade commander + +3.4.1 / 2013-10-15 +================== + + * update connect + * update commander + * jsonp: check if callback is a function + * router: wrap encodeURIComponent in a try/catch #1735 (@lxe) + * res.format: now includes charset @1747 (@sorribas) + * res.links: allow multiple calls @1746 (@sorribas) + +3.4.0 / 2013-09-07 +================== + + * add res.vary(). Closes #1682 + * update connect + +3.3.8 / 2013-09-02 +================== + + * update connect + +3.3.7 / 2013-08-28 +================== + + * update connect + +3.3.6 / 2013-08-27 +================== + + * Revert "remove charset from json responses. Closes #1631" (causes issues in some clients) + * add: req.accepts take an argument list + +3.3.4 / 2013-07-08 +================== + + * update send and connect + +3.3.3 / 2013-07-04 +================== + + * update connect + +3.3.2 / 2013-07-03 +================== + + * update connect + * update send + * remove .version export + +3.3.1 / 2013-06-27 +================== + + * update connect + +3.3.0 / 2013-06-26 +================== + + * update connect + * add support for multiple X-Forwarded-Proto values. Closes #1646 + * change: remove charset from json responses. Closes #1631 + * change: return actual booleans from req.accept* functions + * fix jsonp callback array throw + +3.2.6 / 2013-06-02 +================== + + * update connect + +3.2.5 / 2013-05-21 +================== + + * update connect + * update node-cookie + * add: throw a meaningful error when there is no default engine + * change generation of ETags with res.send() to GET requests only. Closes #1619 + +3.2.4 / 2013-05-09 +================== + + * fix `req.subdomains` when no Host is present + * fix `req.host` when no Host is present, return undefined + +3.2.3 / 2013-05-07 +================== + + * update connect / qs + +3.2.2 / 2013-05-03 +================== + + * update qs + +3.2.1 / 2013-04-29 +================== + + * add app.VERB() paths array deprecation warning + * update connect + * update qs and remove all ~ semver crap + * fix: accept number as value of Signed Cookie + +3.2.0 / 2013-04-15 +================== + + * add "view" constructor setting to override view behaviour + * add req.acceptsEncoding(name) + * add req.acceptedEncodings + * revert cookie signature change causing session race conditions + * fix sorting of Accept values of the same quality + +3.1.2 / 2013-04-12 +================== + + * add support for custom Accept parameters + * update cookie-signature + +3.1.1 / 2013-04-01 +================== + + * add X-Forwarded-Host support to `req.host` + * fix relative redirects + * update mkdirp + * update buffer-crc32 + * remove legacy app.configure() method from app template. + +3.1.0 / 2013-01-25 +================== + + * add support for leading "." in "view engine" setting + * add array support to `res.set()` + * add node 0.8.x to travis.yml + * add "subdomain offset" setting for tweaking `req.subdomains` + * add `res.location(url)` implementing `res.redirect()`-like setting of Location + * use app.get() for x-powered-by setting for inheritance + * fix colons in passwords for `req.auth` + +3.0.6 / 2013-01-04 +================== + + * add http verb methods to Router + * update connect + * fix mangling of the `res.cookie()` options object + * fix jsonp whitespace escape. Closes #1132 + +3.0.5 / 2012-12-19 +================== + + * add throwing when a non-function is passed to a route + * fix: explicitly remove Transfer-Encoding header from 204 and 304 responses + * revert "add 'etag' option" + +3.0.4 / 2012-12-05 +================== + + * add 'etag' option to disable `res.send()` Etags + * add escaping of urls in text/plain in `res.redirect()` + for old browsers interpreting as html + * change crc32 module for a more liberal license + * update connect + +3.0.3 / 2012-11-13 +================== + + * update connect + * update cookie module + * fix cookie max-age + +3.0.2 / 2012-11-08 +================== + + * add OPTIONS to cors example. Closes #1398 + * fix route chaining regression. Closes #1397 + +3.0.1 / 2012-11-01 +================== + + * update connect + +3.0.0 / 2012-10-23 +================== + + * add `make clean` + * add "Basic" check to req.auth + * add `req.auth` test coverage + * add cb && cb(payload) to `res.jsonp()`. Closes #1374 + * add backwards compat for `res.redirect()` status. Closes #1336 + * add support for `res.json()` to retain previously defined Content-Types. Closes #1349 + * update connect + * change `res.redirect()` to utilize a pathname-relative Location again. Closes #1382 + * remove non-primitive string support for `res.send()` + * fix view-locals example. Closes #1370 + * fix route-separation example + +3.0.0rc5 / 2012-09-18 +================== + + * update connect + * add redis search example + * add static-files example + * add "x-powered-by" setting (`app.disable('x-powered-by')`) + * add "application/octet-stream" redirect Accept test case. Closes #1317 + +3.0.0rc4 / 2012-08-30 +================== + + * add `res.jsonp()`. Closes #1307 + * add "verbose errors" option to error-pages example + * add another route example to express(1) so people are not so confused + * add redis online user activity tracking example + * update connect dep + * fix etag quoting. Closes #1310 + * fix error-pages 404 status + * fix jsonp callback char restrictions + * remove old OPTIONS default response + +3.0.0rc3 / 2012-08-13 +================== + + * update connect dep + * fix signed cookies to work with `connect.cookieParser()` ("s:" prefix was missing) [tnydwrds] + * fix `res.render()` clobbering of "locals" + +3.0.0rc2 / 2012-08-03 +================== + + * add CORS example + * update connect dep + * deprecate `.createServer()` & remove old stale examples + * fix: escape `res.redirect()` link + * fix vhost example + +3.0.0rc1 / 2012-07-24 +================== + + * add more examples to view-locals + * add scheme-relative redirects (`res.redirect("//foo.com")`) support + * update cookie dep + * update connect dep + * update send dep + * fix `express(1)` -h flag, use -H for hogan. Closes #1245 + * fix `res.sendfile()` socket error handling regression + +3.0.0beta7 / 2012-07-16 +================== + + * update connect dep for `send()` root normalization regression + +3.0.0beta6 / 2012-07-13 +================== + + * add `err.view` property for view errors. Closes #1226 + * add "jsonp callback name" setting + * add support for "/foo/:bar*" non-greedy matches + * change `res.sendfile()` to use `send()` module + * change `res.send` to use "response-send" module + * remove `app.locals.use` and `res.locals.use`, use regular middleware + +3.0.0beta5 / 2012-07-03 +================== + + * add "make check" support + * add route-map example + * add `res.json(obj, status)` support back for BC + * add "methods" dep, remove internal methods module + * update connect dep + * update auth example to utilize cores pbkdf2 + * updated tests to use "supertest" + +3.0.0beta4 / 2012-06-25 +================== + + * Added `req.auth` + * Added `req.range(size)` + * Added `res.links(obj)` + * Added `res.send(body, status)` support back for backwards compat + * Added `.default()` support to `res.format()` + * Added 2xx / 304 check to `req.fresh` + * Revert "Added + support to the router" + * Fixed `res.send()` freshness check, respect res.statusCode + +3.0.0beta3 / 2012-06-15 +================== + + * Added hogan `--hjs` to express(1) [nullfirm] + * Added another example to content-negotiation + * Added `fresh` dep + * Changed: `res.send()` always checks freshness + * Fixed: expose connects mime module. Closes #1165 + +3.0.0beta2 / 2012-06-06 +================== + + * Added `+` support to the router + * Added `req.host` + * Changed `req.param()` to check route first + * Update connect dep + +3.0.0beta1 / 2012-06-01 +================== + + * Added `res.format()` callback to override default 406 behaviour + * Fixed `res.redirect()` 406. Closes #1154 + +3.0.0alpha5 / 2012-05-30 +================== + + * Added `req.ip` + * Added `{ signed: true }` option to `res.cookie()` + * Removed `res.signedCookie()` + * Changed: dont reverse `req.ips` + * Fixed "trust proxy" setting check for `req.ips` + +3.0.0alpha4 / 2012-05-09 +================== + + * Added: allow `[]` in jsonp callback. Closes #1128 + * Added `PORT` env var support in generated template. Closes #1118 [benatkin] + * Updated: connect 2.2.2 + +3.0.0alpha3 / 2012-05-04 +================== + + * Added public `app.routes`. Closes #887 + * Added _view-locals_ example + * Added _mvc_ example + * Added `res.locals.use()`. Closes #1120 + * Added conditional-GET support to `res.send()` + * Added: coerce `res.set()` values to strings + * Changed: moved `static()` in generated apps below router + * Changed: `res.send()` only set ETag when not previously set + * Changed connect 2.2.1 dep + * Changed: `make test` now runs unit / acceptance tests + * Fixed req/res proto inheritance + +3.0.0alpha2 / 2012-04-26 +================== + + * Added `make benchmark` back + * Added `res.send()` support for `String` objects + * Added client-side data exposing example + * Added `res.header()` and `req.header()` aliases for BC + * Added `express.createServer()` for BC + * Perf: memoize parsed urls + * Perf: connect 2.2.0 dep + * Changed: make `expressInit()` middleware self-aware + * Fixed: use app.get() for all core settings + * Fixed redis session example + * Fixed session example. Closes #1105 + * Fixed generated express dep. Closes #1078 + +3.0.0alpha1 / 2012-04-15 +================== + + * Added `app.locals.use(callback)` + * Added `app.locals` object + * Added `app.locals(obj)` + * Added `res.locals` object + * Added `res.locals(obj)` + * Added `res.format()` for content-negotiation + * Added `app.engine()` + * Added `res.cookie()` JSON cookie support + * Added "trust proxy" setting + * Added `req.subdomains` + * Added `req.protocol` + * Added `req.secure` + * Added `req.path` + * Added `req.ips` + * Added `req.fresh` + * Added `req.stale` + * Added comma-delimited / array support for `req.accepts()` + * Added debug instrumentation + * Added `res.set(obj)` + * Added `res.set(field, value)` + * Added `res.get(field)` + * Added `app.get(setting)`. Closes #842 + * Added `req.acceptsLanguage()` + * Added `req.acceptsCharset()` + * Added `req.accepted` + * Added `req.acceptedLanguages` + * Added `req.acceptedCharsets` + * Added "json replacer" setting + * Added "json spaces" setting + * Added X-Forwarded-Proto support to `res.redirect()`. Closes #92 + * Added `--less` support to express(1) + * Added `express.response` prototype + * Added `express.request` prototype + * Added `express.application` prototype + * Added `app.path()` + * Added `app.render()` + * Added `res.type()` to replace `res.contentType()` + * Changed: `res.redirect()` to add relative support + * Changed: enable "jsonp callback" by default + * Changed: renamed "case sensitive routes" to "case sensitive routing" + * Rewrite of all tests with mocha + * Removed "root" setting + * Removed `res.redirect('home')` support + * Removed `req.notify()` + * Removed `app.register()` + * Removed `app.redirect()` + * Removed `app.is()` + * Removed `app.helpers()` + * Removed `app.dynamicHelpers()` + * Fixed `res.sendfile()` with non-GET. Closes #723 + * Fixed express(1) public dir for windows. Closes #866 + +2.5.9/ 2012-04-02 +================== + + * Added support for PURGE request method [pbuyle] + * Fixed `express(1)` generated app `app.address()` before `listening` [mmalecki] + +2.5.8 / 2012-02-08 +================== + + * Update mkdirp dep. Closes #991 + +2.5.7 / 2012-02-06 +================== + + * Fixed `app.all` duplicate DELETE requests [mscdex] + +2.5.6 / 2012-01-13 +================== + + * Updated hamljs dev dep. Closes #953 + +2.5.5 / 2012-01-08 +================== + + * Fixed: set `filename` on cached templates [matthewleon] + +2.5.4 / 2012-01-02 +================== + + * Fixed `express(1)` eol on 0.4.x. Closes #947 + +2.5.3 / 2011-12-30 +================== + + * Fixed `req.is()` when a charset is present + +2.5.2 / 2011-12-10 +================== + + * Fixed: express(1) LF -> CRLF for windows + +2.5.1 / 2011-11-17 +================== + + * Changed: updated connect to 1.8.x + * Removed sass.js support from express(1) + +2.5.0 / 2011-10-24 +================== + + * Added ./routes dir for generated app by default + * Added npm install reminder to express(1) app gen + * Added 0.5.x support + * Removed `make test-cov` since it wont work with node 0.5.x + * Fixed express(1) public dir for windows. Closes #866 + +2.4.7 / 2011-10-05 +================== + + * Added mkdirp to express(1). Closes #795 + * Added simple _json-config_ example + * Added shorthand for the parsed request's pathname via `req.path` + * Changed connect dep to 1.7.x to fix npm issue... + * Fixed `res.redirect()` __HEAD__ support. [reported by xerox] + * Fixed `req.flash()`, only escape args + * Fixed absolute path checking on windows. Closes #829 [reported by andrewpmckenzie] + +2.4.6 / 2011-08-22 +================== + + * Fixed multiple param callback regression. Closes #824 [reported by TroyGoode] + +2.4.5 / 2011-08-19 +================== + + * Added support for routes to handle errors. Closes #809 + * Added `app.routes.all()`. Closes #803 + * Added "basepath" setting to work in conjunction with reverse proxies etc. + * Refactored `Route` to use a single array of callbacks + * Added support for multiple callbacks for `app.param()`. Closes #801 +Closes #805 + * Changed: removed .call(self) for route callbacks + * Dependency: `qs >= 0.3.1` + * Fixed `res.redirect()` on windows due to `join()` usage. Closes #808 + +2.4.4 / 2011-08-05 +================== + + * Fixed `res.header()` intention of a set, even when `undefined` + * Fixed `*`, value no longer required + * Fixed `res.send(204)` support. Closes #771 + +2.4.3 / 2011-07-14 +================== + + * Added docs for `status` option special-case. Closes #739 + * Fixed `options.filename`, exposing the view path to template engines + +2.4.2. / 2011-07-06 +================== + + * Revert "removed jsonp stripping" for XSS + +2.4.1 / 2011-07-06 +================== + + * Added `res.json()` JSONP support. Closes #737 + * Added _extending-templates_ example. Closes #730 + * Added "strict routing" setting for trailing slashes + * Added support for multiple envs in `app.configure()` calls. Closes #735 + * Changed: `res.send()` using `res.json()` + * Changed: when cookie `path === null` don't default it + * Changed; default cookie path to "home" setting. Closes #731 + * Removed _pids/logs_ creation from express(1) + +2.4.0 / 2011-06-28 +================== + + * Added chainable `res.status(code)` + * Added `res.json()`, an explicit version of `res.send(obj)` + * Added simple web-service example + +2.3.12 / 2011-06-22 +================== + + * \#express is now on freenode! come join! + * Added `req.get(field, param)` + * Added links to Japanese documentation, thanks @hideyukisaito! + * Added; the `express(1)` generated app outputs the env + * Added `content-negotiation` example + * Dependency: connect >= 1.5.1 < 2.0.0 + * Fixed view layout bug. Closes #720 + * Fixed; ignore body on 304. Closes #701 + +2.3.11 / 2011-06-04 +================== + + * Added `npm test` + * Removed generation of dummy test file from `express(1)` + * Fixed; `express(1)` adds express as a dep + * Fixed; prune on `prepublish` + +2.3.10 / 2011-05-27 +================== + + * Added `req.route`, exposing the current route + * Added _package.json_ generation support to `express(1)` + * Fixed call to `app.param()` function for optional params. Closes #682 + +2.3.9 / 2011-05-25 +================== + + * Fixed bug-ish with `../' in `res.partial()` calls + +2.3.8 / 2011-05-24 +================== + + * Fixed `app.options()` + +2.3.7 / 2011-05-23 +================== + + * Added route `Collection`, ex: `app.get('/user/:id').remove();` + * Added support for `app.param(fn)` to define param logic + * Removed `app.param()` support for callback with return value + * Removed module.parent check from express(1) generated app. Closes #670 + * Refactored router. Closes #639 + +2.3.6 / 2011-05-20 +================== + + * Changed; using devDependencies instead of git submodules + * Fixed redis session example + * Fixed markdown example + * Fixed view caching, should not be enabled in development + +2.3.5 / 2011-05-20 +================== + + * Added export `.view` as alias for `.View` + +2.3.4 / 2011-05-08 +================== + + * Added `./examples/say` + * Fixed `res.sendfile()` bug preventing the transfer of files with spaces + +2.3.3 / 2011-05-03 +================== + + * Added "case sensitive routes" option. + * Changed; split methods supported per rfc [slaskis] + * Fixed route-specific middleware when using the same callback function several times + +2.3.2 / 2011-04-27 +================== + + * Fixed view hints + +2.3.1 / 2011-04-26 +================== + + * Added `app.match()` as `app.match.all()` + * Added `app.lookup()` as `app.lookup.all()` + * Added `app.remove()` for `app.remove.all()` + * Added `app.remove.VERB()` + * Fixed template caching collision issue. Closes #644 + * Moved router over from connect and started refactor + +2.3.0 / 2011-04-25 +================== + + * Added options support to `res.clearCookie()` + * Added `res.helpers()` as alias of `res.locals()` + * Added; json defaults to UTF-8 with `res.send()`. Closes #632. [Daniel * Dependency `connect >= 1.4.0` + * Changed; auto set Content-Type in res.attachement [Aaron Heckmann] + * Renamed "cache views" to "view cache". Closes #628 + * Fixed caching of views when using several apps. Closes #637 + * Fixed gotcha invoking `app.param()` callbacks once per route middleware. +Closes #638 + * Fixed partial lookup precedence. Closes #631 +Shaw] + +2.2.2 / 2011-04-12 +================== + + * Added second callback support for `res.download()` connection errors + * Fixed `filename` option passing to template engine + +2.2.1 / 2011-04-04 +================== + + * Added `layout(path)` helper to change the layout within a view. Closes #610 + * Fixed `partial()` collection object support. + Previously only anything with `.length` would work. + When `.length` is present one must still be aware of holes, + however now `{ collection: {foo: 'bar'}}` is valid, exposes + `keyInCollection` and `keysInCollection`. + + * Performance improved with better view caching + * Removed `request` and `response` locals + * Changed; errorHandler page title is now `Express` instead of `Connect` + +2.2.0 / 2011-03-30 +================== + + * Added `app.lookup.VERB()`, ex `app.lookup.put('/user/:id')`. Closes #606 + * Added `app.match.VERB()`, ex `app.match.put('/user/12')`. Closes #606 + * Added `app.VERB(path)` as alias of `app.lookup.VERB()`. + * Dependency `connect >= 1.2.0` + +2.1.1 / 2011-03-29 +================== + + * Added; expose `err.view` object when failing to locate a view + * Fixed `res.partial()` call `next(err)` when no callback is given [reported by aheckmann] + * Fixed; `res.send(undefined)` responds with 204 [aheckmann] + +2.1.0 / 2011-03-24 +================== + + * Added `/_?` partial lookup support. Closes #447 + * Added `request`, `response`, and `app` local variables + * Added `settings` local variable, containing the app's settings + * Added `req.flash()` exception if `req.session` is not available + * Added `res.send(bool)` support (json response) + * Fixed stylus example for latest version + * Fixed; wrap try/catch around `res.render()` + +2.0.0 / 2011-03-17 +================== + + * Fixed up index view path alternative. + * Changed; `res.locals()` without object returns the locals + +2.0.0rc3 / 2011-03-17 +================== + + * Added `res.locals(obj)` to compliment `res.local(key, val)` + * Added `res.partial()` callback support + * Fixed recursive error reporting issue in `res.render()` + +2.0.0rc2 / 2011-03-17 +================== + + * Changed; `partial()` "locals" are now optional + * Fixed `SlowBuffer` support. Closes #584 [reported by tyrda01] + * Fixed .filename view engine option [reported by drudge] + * Fixed blog example + * Fixed `{req,res}.app` reference when mounting [Ben Weaver] + +2.0.0rc / 2011-03-14 +================== + + * Fixed; expose `HTTPSServer` constructor + * Fixed express(1) default test charset. Closes #579 [reported by secoif] + * Fixed; default charset to utf-8 instead of utf8 for lame IE [reported by NickP] + +2.0.0beta3 / 2011-03-09 +================== + + * Added support for `res.contentType()` literal + The original `res.contentType('.json')`, + `res.contentType('application/json')`, and `res.contentType('json')` + will work now. + * Added `res.render()` status option support back + * Added charset option for `res.render()` + * Added `.charset` support (via connect 1.0.4) + * Added view resolution hints when in development and a lookup fails + * Added layout lookup support relative to the page view. + For example while rendering `./views/user/index.jade` if you create + `./views/user/layout.jade` it will be used in favour of the root layout. + * Fixed `res.redirect()`. RFC states absolute url [reported by unlink] + * Fixed; default `res.send()` string charset to utf8 + * Removed `Partial` constructor (not currently used) + +2.0.0beta2 / 2011-03-07 +================== + + * Added res.render() `.locals` support back to aid in migration process + * Fixed flash example + +2.0.0beta / 2011-03-03 +================== + + * Added HTTPS support + * Added `res.cookie()` maxAge support + * Added `req.header()` _Referrer_ / _Referer_ special-case, either works + * Added mount support for `res.redirect()`, now respects the mount-point + * Added `union()` util, taking place of `merge(clone())` combo + * Added stylus support to express(1) generated app + * Added secret to session middleware used in examples and generated app + * Added `res.local(name, val)` for progressive view locals + * Added default param support to `req.param(name, default)` + * Added `app.disabled()` and `app.enabled()` + * Added `app.register()` support for omitting leading ".", either works + * Added `res.partial()`, using the same interface as `partial()` within a view. Closes #539 + * Added `app.param()` to map route params to async/sync logic + * Added; aliased `app.helpers()` as `app.locals()`. Closes #481 + * Added extname with no leading "." support to `res.contentType()` + * Added `cache views` setting, defaulting to enabled in "production" env + * Added index file partial resolution, eg: partial('user') may try _views/user/index.jade_. + * Added `req.accepts()` support for extensions + * Changed; `res.download()` and `res.sendfile()` now utilize Connect's + static file server `connect.static.send()`. + * Changed; replaced `connect.utils.mime()` with npm _mime_ module + * Changed; allow `req.query` to be pre-defined (via middleware or other parent + * Changed view partial resolution, now relative to parent view + * Changed view engine signature. no longer `engine.render(str, options, callback)`, now `engine.compile(str, options) -> Function`, the returned function accepts `fn(locals)`. + * Fixed `req.param()` bug returning Array.prototype methods. Closes #552 + * Fixed; using `Stream#pipe()` instead of `sys.pump()` in `res.sendfile()` + * Fixed; using _qs_ module instead of _querystring_ + * Fixed; strip unsafe chars from jsonp callbacks + * Removed "stream threshold" setting + +1.0.8 / 2011-03-01 +================== + + * Allow `req.query` to be pre-defined (via middleware or other parent app) + * "connect": ">= 0.5.0 < 1.0.0". Closes #547 + * Removed the long deprecated __EXPRESS_ENV__ support + +1.0.7 / 2011-02-07 +================== + + * Fixed `render()` setting inheritance. + Mounted apps would not inherit "view engine" + +1.0.6 / 2011-02-07 +================== + + * Fixed `view engine` setting bug when period is in dirname + +1.0.5 / 2011-02-05 +================== + + * Added secret to generated app `session()` call + +1.0.4 / 2011-02-05 +================== + + * Added `qs` dependency to _package.json_ + * Fixed namespaced `require()`s for latest connect support + +1.0.3 / 2011-01-13 +================== + + * Remove unsafe characters from JSONP callback names [Ryan Grove] + +1.0.2 / 2011-01-10 +================== + + * Removed nested require, using `connect.router` + +1.0.1 / 2010-12-29 +================== + + * Fixed for middleware stacked via `createServer()` + previously the `foo` middleware passed to `createServer(foo)` + would not have access to Express methods such as `res.send()` + or props like `req.query` etc. + +1.0.0 / 2010-11-16 +================== + + * Added; deduce partial object names from the last segment. + For example by default `partial('forum/post', postObject)` will + give you the _post_ object, providing a meaningful default. + * Added http status code string representation to `res.redirect()` body + * Added; `res.redirect()` supporting _text/plain_ and _text/html_ via __Accept__. + * Added `req.is()` to aid in content negotiation + * Added partial local inheritance [suggested by masylum]. Closes #102 + providing access to parent template locals. + * Added _-s, --session[s]_ flag to express(1) to add session related middleware + * Added _--template_ flag to express(1) to specify the + template engine to use. + * Added _--css_ flag to express(1) to specify the + stylesheet engine to use (or just plain css by default). + * Added `app.all()` support [thanks aheckmann] + * Added partial direct object support. + You may now `partial('user', user)` providing the "user" local, + vs previously `partial('user', { object: user })`. + * Added _route-separation_ example since many people question ways + to do this with CommonJS modules. Also view the _blog_ example for + an alternative. + * Performance; caching view path derived partial object names + * Fixed partial local inheritance precedence. [reported by Nick Poulden] Closes #454 + * Fixed jsonp support; _text/javascript_ as per mailinglist discussion + +1.0.0rc4 / 2010-10-14 +================== + + * Added _NODE_ENV_ support, _EXPRESS_ENV_ is deprecated and will be removed in 1.0.0 + * Added route-middleware support (very helpful, see the [docs](http://expressjs.com/guide.html#Route-Middleware)) + * Added _jsonp callback_ setting to enable/disable jsonp autowrapping [Dav Glass] + * Added callback query check on response.send to autowrap JSON objects for simple webservice implementations [Dav Glass] + * Added `partial()` support for array-like collections. Closes #434 + * Added support for swappable querystring parsers + * Added session usage docs. Closes #443 + * Added dynamic helper caching. Closes #439 [suggested by maritz] + * Added authentication example + * Added basic Range support to `res.sendfile()` (and `res.download()` etc) + * Changed; `express(1)` generated app using 2 spaces instead of 4 + * Default env to "development" again [aheckmann] + * Removed _context_ option is no more, use "scope" + * Fixed; exposing _./support_ libs to examples so they can run without installs + * Fixed mvc example + +1.0.0rc3 / 2010-09-20 +================== + + * Added confirmation for `express(1)` app generation. Closes #391 + * Added extending of flash formatters via `app.flashFormatters` + * Added flash formatter support. Closes #411 + * Added streaming support to `res.sendfile()` using `sys.pump()` when >= "stream threshold" + * Added _stream threshold_ setting for `res.sendfile()` + * Added `res.send()` __HEAD__ support + * Added `res.clearCookie()` + * Added `res.cookie()` + * Added `res.render()` headers option + * Added `res.redirect()` response bodies + * Added `res.render()` status option support. Closes #425 [thanks aheckmann] + * Fixed `res.sendfile()` responding with 403 on malicious path + * Fixed `res.download()` bug; when an error occurs remove _Content-Disposition_ + * Fixed; mounted apps settings now inherit from parent app [aheckmann] + * Fixed; stripping Content-Length / Content-Type when 204 + * Fixed `res.send()` 204. Closes #419 + * Fixed multiple _Set-Cookie_ headers via `res.header()`. Closes #402 + * Fixed bug messing with error handlers when `listenFD()` is called instead of `listen()`. [thanks guillermo] + + +1.0.0rc2 / 2010-08-17 +================== + + * Added `app.register()` for template engine mapping. Closes #390 + * Added `res.render()` callback support as second argument (no options) + * Added callback support to `res.download()` + * Added callback support for `res.sendfile()` + * Added support for middleware access via `express.middlewareName()` vs `connect.middlewareName()` + * Added "partials" setting to docs + * Added default expresso tests to `express(1)` generated app. Closes #384 + * Fixed `res.sendfile()` error handling, defer via `next()` + * Fixed `res.render()` callback when a layout is used [thanks guillermo] + * Fixed; `make install` creating ~/.node_libraries when not present + * Fixed issue preventing error handlers from being defined anywhere. Closes #387 + +1.0.0rc / 2010-07-28 +================== + + * Added mounted hook. Closes #369 + * Added connect dependency to _package.json_ + + * Removed "reload views" setting and support code + development env never caches, production always caches. + + * Removed _param_ in route callbacks, signature is now + simply (req, res, next), previously (req, res, params, next). + Use _req.params_ for path captures, _req.query_ for GET params. + + * Fixed "home" setting + * Fixed middleware/router precedence issue. Closes #366 + * Fixed; _configure()_ callbacks called immediately. Closes #368 + +1.0.0beta2 / 2010-07-23 +================== + + * Added more examples + * Added; exporting `Server` constructor + * Added `Server#helpers()` for view locals + * Added `Server#dynamicHelpers()` for dynamic view locals. Closes #349 + * Added support for absolute view paths + * Added; _home_ setting defaults to `Server#route` for mounted apps. Closes #363 + * Added Guillermo Rauch to the contributor list + * Added support for "as" for non-collection partials. Closes #341 + * Fixed _install.sh_, ensuring _~/.node_libraries_ exists. Closes #362 [thanks jf] + * Fixed `res.render()` exceptions, now passed to `next()` when no callback is given [thanks guillermo] + * Fixed instanceof `Array` checks, now `Array.isArray()` + * Fixed express(1) expansion of public dirs. Closes #348 + * Fixed middleware precedence. Closes #345 + * Fixed view watcher, now async [thanks aheckmann] + +1.0.0beta / 2010-07-15 +================== + + * Re-write + - much faster + - much lighter + - Check [ExpressJS.com](http://expressjs.com) for migration guide and updated docs + +0.14.0 / 2010-06-15 +================== + + * Utilize relative requires + * Added Static bufferSize option [aheckmann] + * Fixed caching of view and partial subdirectories [aheckmann] + * Fixed mime.type() comments now that ".ext" is not supported + * Updated haml submodule + * Updated class submodule + * Removed bin/express + +0.13.0 / 2010-06-01 +================== + + * Added node v0.1.97 compatibility + * Added support for deleting cookies via Request#cookie('key', null) + * Updated haml submodule + * Fixed not-found page, now using using charset utf-8 + * Fixed show-exceptions page, now using using charset utf-8 + * Fixed view support due to fs.readFile Buffers + * Changed; mime.type() no longer accepts ".type" due to node extname() changes + +0.12.0 / 2010-05-22 +================== + + * Added node v0.1.96 compatibility + * Added view `helpers` export which act as additional local variables + * Updated haml submodule + * Changed ETag; removed inode, modified time only + * Fixed LF to CRLF for setting multiple cookies + * Fixed cookie complation; values are now urlencoded + * Fixed cookies parsing; accepts quoted values and url escaped cookies + +0.11.0 / 2010-05-06 +================== + + * Added support for layouts using different engines + - this.render('page.html.haml', { layout: 'super-cool-layout.html.ejs' }) + - this.render('page.html.haml', { layout: 'foo' }) // assumes 'foo.html.haml' + - this.render('page.html.haml', { layout: false }) // no layout + * Updated ext submodule + * Updated haml submodule + * Fixed EJS partial support by passing along the context. Issue #307 + +0.10.1 / 2010-05-03 +================== + + * Fixed binary uploads. + +0.10.0 / 2010-04-30 +================== + + * Added charset support via Request#charset (automatically assigned to 'UTF-8' when respond()'s + encoding is set to 'utf8' or 'utf-8'. + * Added "encoding" option to Request#render(). Closes #299 + * Added "dump exceptions" setting, which is enabled by default. + * Added simple ejs template engine support + * Added error response support for text/plain, application/json. Closes #297 + * Added callback function param to Request#error() + * Added Request#sendHead() + * Added Request#stream() + * Added support for Request#respond(304, null) for empty response bodies + * Added ETag support to Request#sendfile() + * Added options to Request#sendfile(), passed to fs.createReadStream() + * Added filename arg to Request#download() + * Performance enhanced due to pre-reversing plugins so that plugins.reverse() is not called on each request + * Performance enhanced by preventing several calls to toLowerCase() in Router#match() + * Changed; Request#sendfile() now streams + * Changed; Renamed Request#halt() to Request#respond(). Closes #289 + * Changed; Using sys.inspect() instead of JSON.encode() for error output + * Changed; run() returns the http.Server instance. Closes #298 + * Changed; Defaulting Server#host to null (INADDR_ANY) + * Changed; Logger "common" format scale of 0.4f + * Removed Logger "request" format + * Fixed; Catching ENOENT in view caching, preventing error when "views/partials" is not found + * Fixed several issues with http client + * Fixed Logger Content-Length output + * Fixed bug preventing Opera from retaining the generated session id. Closes #292 + +0.9.0 / 2010-04-14 +================== + + * Added DSL level error() route support + * Added DSL level notFound() route support + * Added Request#error() + * Added Request#notFound() + * Added Request#render() callback function. Closes #258 + * Added "max upload size" setting + * Added "magic" variables to collection partials (\_\_index\_\_, \_\_length\_\_, \_\_isFirst\_\_, \_\_isLast\_\_). Closes #254 + * Added [haml.js](http://github.com/visionmedia/haml.js) submodule; removed haml-js + * Added callback function support to Request#halt() as 3rd/4th arg + * Added preprocessing of route param wildcards using param(). Closes #251 + * Added view partial support (with collections etc) + * Fixed bug preventing falsey params (such as ?page=0). Closes #286 + * Fixed setting of multiple cookies. Closes #199 + * Changed; view naming convention is now NAME.TYPE.ENGINE (for example page.html.haml) + * Changed; session cookie is now httpOnly + * Changed; Request is no longer global + * Changed; Event is no longer global + * Changed; "sys" module is no longer global + * Changed; moved Request#download to Static plugin where it belongs + * Changed; Request instance created before body parsing. Closes #262 + * Changed; Pre-caching views in memory when "cache view contents" is enabled. Closes #253 + * Changed; Pre-caching view partials in memory when "cache view partials" is enabled + * Updated support to node --version 0.1.90 + * Updated dependencies + * Removed set("session cookie") in favour of use(Session, { cookie: { ... }}) + * Removed utils.mixin(); use Object#mergeDeep() + +0.8.0 / 2010-03-19 +================== + + * Added coffeescript example app. Closes #242 + * Changed; cache api now async friendly. Closes #240 + * Removed deprecated 'express/static' support. Use 'express/plugins/static' + +0.7.6 / 2010-03-19 +================== + + * Added Request#isXHR. Closes #229 + * Added `make install` (for the executable) + * Added `express` executable for setting up simple app templates + * Added "GET /public/*" to Static plugin, defaulting to /public + * Added Static plugin + * Fixed; Request#render() only calls cache.get() once + * Fixed; Namespacing View caches with "view:" + * Fixed; Namespacing Static caches with "static:" + * Fixed; Both example apps now use the Static plugin + * Fixed set("views"). Closes #239 + * Fixed missing space for combined log format + * Deprecated Request#sendfile() and 'express/static' + * Removed Server#running + +0.7.5 / 2010-03-16 +================== + + * Added Request#flash() support without args, now returns all flashes + * Updated ext submodule + +0.7.4 / 2010-03-16 +================== + + * Fixed session reaper + * Changed; class.js replacing js-oo Class implementation (quite a bit faster, no browser cruft) + +0.7.3 / 2010-03-16 +================== + + * Added package.json + * Fixed requiring of haml / sass due to kiwi removal + +0.7.2 / 2010-03-16 +================== + + * Fixed GIT submodules (HAH!) + +0.7.1 / 2010-03-16 +================== + + * Changed; Express now using submodules again until a PM is adopted + * Changed; chat example using millisecond conversions from ext + +0.7.0 / 2010-03-15 +================== + + * Added Request#pass() support (finds the next matching route, or the given path) + * Added Logger plugin (default "common" format replaces CommonLogger) + * Removed Profiler plugin + * Removed CommonLogger plugin + +0.6.0 / 2010-03-11 +================== + + * Added seed.yml for kiwi package management support + * Added HTTP client query string support when method is GET. Closes #205 + + * Added support for arbitrary view engines. + For example "foo.engine.html" will now require('engine'), + the exports from this module are cached after the first require(). + + * Added async plugin support + + * Removed usage of RESTful route funcs as http client + get() etc, use http.get() and friends + + * Removed custom exceptions + +0.5.0 / 2010-03-10 +================== + + * Added ext dependency (library of js extensions) + * Removed extname() / basename() utils. Use path module + * Removed toArray() util. Use arguments.values + * Removed escapeRegexp() util. Use RegExp.escape() + * Removed process.mixin() dependency. Use utils.mixin() + * Removed Collection + * Removed ElementCollection + * Shameless self promotion of ebook "Advanced JavaScript" (http://dev-mag.com) ;) + +0.4.0 / 2010-02-11 +================== + + * Added flash() example to sample upload app + * Added high level restful http client module (express/http) + * Changed; RESTful route functions double as HTTP clients. Closes #69 + * Changed; throwing error when routes are added at runtime + * Changed; defaulting render() context to the current Request. Closes #197 + * Updated haml submodule + +0.3.0 / 2010-02-11 +================== + + * Updated haml / sass submodules. Closes #200 + * Added flash message support. Closes #64 + * Added accepts() now allows multiple args. fixes #117 + * Added support for plugins to halt. Closes #189 + * Added alternate layout support. Closes #119 + * Removed Route#run(). Closes #188 + * Fixed broken specs due to use(Cookie) missing + +0.2.1 / 2010-02-05 +================== + + * Added "plot" format option for Profiler (for gnuplot processing) + * Added request number to Profiler plugin + * Fixed binary encoding for multi-part file uploads, was previously defaulting to UTF8 + * Fixed issue with routes not firing when not files are present. Closes #184 + * Fixed process.Promise -> events.Promise + +0.2.0 / 2010-02-03 +================== + + * Added parseParam() support for name[] etc. (allows for file inputs with "multiple" attr) Closes #180 + * Added Both Cache and Session option "reapInterval" may be "reapEvery". Closes #174 + * Added expiration support to cache api with reaper. Closes #133 + * Added cache Store.Memory#reap() + * Added Cache; cache api now uses first class Cache instances + * Added abstract session Store. Closes #172 + * Changed; cache Memory.Store#get() utilizing Collection + * Renamed MemoryStore -> Store.Memory + * Fixed use() of the same plugin several time will always use latest options. Closes #176 + +0.1.0 / 2010-02-03 +================== + + * Changed; Hooks (before / after) pass request as arg as well as evaluated in their context + * Updated node support to 0.1.27 Closes #169 + * Updated dirname(__filename) -> __dirname + * Updated libxmljs support to v0.2.0 + * Added session support with memory store / reaping + * Added quick uid() helper + * Added multi-part upload support + * Added Sass.js support / submodule + * Added production env caching view contents and static files + * Added static file caching. Closes #136 + * Added cache plugin with memory stores + * Added support to StaticFile so that it works with non-textual files. + * Removed dirname() helper + * Removed several globals (now their modules must be required) + +0.0.2 / 2010-01-10 +================== + + * Added view benchmarks; currently haml vs ejs + * Added Request#attachment() specs. Closes #116 + * Added use of node's parseQuery() util. Closes #123 + * Added `make init` for submodules + * Updated Haml + * Updated sample chat app to show messages on load + * Updated libxmljs parseString -> parseHtmlString + * Fixed `make init` to work with older versions of git + * Fixed specs can now run independent specs for those who cant build deps. Closes #127 + * Fixed issues introduced by the node url module changes. Closes 126. + * Fixed two assertions failing due to Collection#keys() returning strings + * Fixed faulty Collection#toArray() spec due to keys() returning strings + * Fixed `make test` now builds libxmljs.node before testing + +0.0.1 / 2010-01-03 +================== + + * Initial release diff --git a/ui/node_modules/express/LICENSE b/ui/node_modules/express/LICENSE index aeebfcca..aa927e44 100644 --- a/ui/node_modules/express/LICENSE +++ b/ui/node_modules/express/LICENSE @@ -1,24 +1,24 @@ -(The MIT License) - -Copyright (c) 2009-2014 TJ Holowaychuk -Copyright (c) 2013-2014 Roman Shtylman -Copyright (c) 2014-2015 Douglas Christopher Wilson - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2009-2014 TJ Holowaychuk +Copyright (c) 2013-2014 Roman Shtylman +Copyright (c) 2014-2015 Douglas Christopher Wilson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/express/Readme.md b/ui/node_modules/express/Readme.md index 1bd2ef53..e9bfaeba 100644 --- a/ui/node_modules/express/Readme.md +++ b/ui/node_modules/express/Readme.md @@ -1,142 +1,142 @@ -[![Express Logo](https://i.cloudup.com/zfY6lL7eFa-3000x3000.png)](http://expressjs.com/) - - Fast, unopinionated, minimalist web framework for [node](http://nodejs.org). - - [![NPM Version][npm-image]][npm-url] - [![NPM Downloads][downloads-image]][downloads-url] - [![Linux Build][travis-image]][travis-url] - [![Windows Build][appveyor-image]][appveyor-url] - [![Test Coverage][coveralls-image]][coveralls-url] - -```js -var express = require('express') -var app = express() - -app.get('/', function (req, res) { - res.send('Hello World') -}) - -app.listen(3000) -``` - -## Installation - -```bash -$ npm install express -``` - -## Features - - * Robust routing - * Focus on high performance - * Super-high test coverage - * HTTP helpers (redirection, caching, etc) - * View system supporting 14+ template engines - * Content negotiation - * Executable for generating applications quickly - -## Docs & Community - - * [Website and Documentation](http://expressjs.com/) - [[website repo](https://github.com/strongloop/expressjs.com)] - * [#express](https://webchat.freenode.net/?channels=express) on freenode IRC - * [Github Organization](https://github.com/expressjs) for Official Middleware & Modules - * Visit the [Wiki](https://github.com/expressjs/express/wiki) - * [Google Group](https://groups.google.com/group/express-js) for discussion - * [Gitter](https://gitter.im/expressjs/express) for support and discussion - * [Русскоязычная документация](http://jsman.ru/express/) - -**PROTIP** Be sure to read [Migrating from 3.x to 4.x](https://github.com/expressjs/express/wiki/Migrating-from-3.x-to-4.x) as well as [New features in 4.x](https://github.com/expressjs/express/wiki/New-features-in-4.x). - -###Security Issues - -If you discover a security vulnerability in Express, please see [Security Policies and Procedures](Security.md). - -## Quick Start - - The quickest way to get started with express is to utilize the executable [`express(1)`](https://github.com/expressjs/generator) to generate an application as shown below: - - Install the executable. The executable's major version will match Express's: - -```bash -$ npm install -g express-generator@4 -``` - - Create the app: - -```bash -$ express /tmp/foo && cd /tmp/foo -``` - - Install dependencies: - -```bash -$ npm install -``` - - Start the server: - -```bash -$ npm start -``` - -## Philosophy - - The Express philosophy is to provide small, robust tooling for HTTP servers, making - it a great solution for single page applications, web sites, hybrids, or public - HTTP APIs. - - Express does not force you to use any specific ORM or template engine. With support for over - 14 template engines via [Consolidate.js](https://github.com/tj/consolidate.js), - you can quickly craft your perfect framework. - -## Examples - - To view the examples, clone the Express repo and install the dependencies: - -```bash -$ git clone git://github.com/expressjs/express.git --depth 1 -$ cd express -$ npm install -``` - - Then run whichever example you want: - -```bash -$ node examples/content-negotiation -``` - -## Tests - - To run the test suite, first install the dependencies, then run `npm test`: - -```bash -$ npm install -$ npm test -``` - -## People - -The original author of Express is [TJ Holowaychuk](https://github.com/tj) [![TJ's Gratipay][gratipay-image-visionmedia]][gratipay-url-visionmedia] - -The current lead maintainer is [Douglas Christopher Wilson](https://github.com/dougwilson) [![Doug's Gratipay][gratipay-image-dougwilson]][gratipay-url-dougwilson] - -[List of all contributors](https://github.com/expressjs/express/graphs/contributors) - -## License - - [MIT](LICENSE) - -[npm-image]: https://img.shields.io/npm/v/express.svg -[npm-url]: https://npmjs.org/package/express -[downloads-image]: https://img.shields.io/npm/dm/express.svg -[downloads-url]: https://npmjs.org/package/express -[travis-image]: https://img.shields.io/travis/expressjs/express/master.svg?label=linux -[travis-url]: https://travis-ci.org/expressjs/express -[appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/express/master.svg?label=windows -[appveyor-url]: https://ci.appveyor.com/project/dougwilson/express -[coveralls-image]: https://img.shields.io/coveralls/expressjs/express/master.svg -[coveralls-url]: https://coveralls.io/r/expressjs/express?branch=master -[gratipay-image-visionmedia]: https://img.shields.io/gratipay/visionmedia.svg -[gratipay-url-visionmedia]: https://gratipay.com/visionmedia/ -[gratipay-image-dougwilson]: https://img.shields.io/gratipay/dougwilson.svg -[gratipay-url-dougwilson]: https://gratipay.com/dougwilson/ +[![Express Logo](https://i.cloudup.com/zfY6lL7eFa-3000x3000.png)](http://expressjs.com/) + + Fast, unopinionated, minimalist web framework for [node](http://nodejs.org). + + [![NPM Version][npm-image]][npm-url] + [![NPM Downloads][downloads-image]][downloads-url] + [![Linux Build][travis-image]][travis-url] + [![Windows Build][appveyor-image]][appveyor-url] + [![Test Coverage][coveralls-image]][coveralls-url] + +```js +var express = require('express') +var app = express() + +app.get('/', function (req, res) { + res.send('Hello World') +}) + +app.listen(3000) +``` + +## Installation + +```bash +$ npm install express +``` + +## Features + + * Robust routing + * Focus on high performance + * Super-high test coverage + * HTTP helpers (redirection, caching, etc) + * View system supporting 14+ template engines + * Content negotiation + * Executable for generating applications quickly + +## Docs & Community + + * [Website and Documentation](http://expressjs.com/) - [[website repo](https://github.com/strongloop/expressjs.com)] + * [#express](https://webchat.freenode.net/?channels=express) on freenode IRC + * [Github Organization](https://github.com/expressjs) for Official Middleware & Modules + * Visit the [Wiki](https://github.com/expressjs/express/wiki) + * [Google Group](https://groups.google.com/group/express-js) for discussion + * [Gitter](https://gitter.im/expressjs/express) for support and discussion + * [Русскоязычная документация](http://jsman.ru/express/) + +**PROTIP** Be sure to read [Migrating from 3.x to 4.x](https://github.com/expressjs/express/wiki/Migrating-from-3.x-to-4.x) as well as [New features in 4.x](https://github.com/expressjs/express/wiki/New-features-in-4.x). + +###Security Issues + +If you discover a security vulnerability in Express, please see [Security Policies and Procedures](Security.md). + +## Quick Start + + The quickest way to get started with express is to utilize the executable [`express(1)`](https://github.com/expressjs/generator) to generate an application as shown below: + + Install the executable. The executable's major version will match Express's: + +```bash +$ npm install -g express-generator@4 +``` + + Create the app: + +```bash +$ express /tmp/foo && cd /tmp/foo +``` + + Install dependencies: + +```bash +$ npm install +``` + + Start the server: + +```bash +$ npm start +``` + +## Philosophy + + The Express philosophy is to provide small, robust tooling for HTTP servers, making + it a great solution for single page applications, web sites, hybrids, or public + HTTP APIs. + + Express does not force you to use any specific ORM or template engine. With support for over + 14 template engines via [Consolidate.js](https://github.com/tj/consolidate.js), + you can quickly craft your perfect framework. + +## Examples + + To view the examples, clone the Express repo and install the dependencies: + +```bash +$ git clone git://github.com/expressjs/express.git --depth 1 +$ cd express +$ npm install +``` + + Then run whichever example you want: + +```bash +$ node examples/content-negotiation +``` + +## Tests + + To run the test suite, first install the dependencies, then run `npm test`: + +```bash +$ npm install +$ npm test +``` + +## People + +The original author of Express is [TJ Holowaychuk](https://github.com/tj) [![TJ's Gratipay][gratipay-image-visionmedia]][gratipay-url-visionmedia] + +The current lead maintainer is [Douglas Christopher Wilson](https://github.com/dougwilson) [![Doug's Gratipay][gratipay-image-dougwilson]][gratipay-url-dougwilson] + +[List of all contributors](https://github.com/expressjs/express/graphs/contributors) + +## License + + [MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/express.svg +[npm-url]: https://npmjs.org/package/express +[downloads-image]: https://img.shields.io/npm/dm/express.svg +[downloads-url]: https://npmjs.org/package/express +[travis-image]: https://img.shields.io/travis/expressjs/express/master.svg?label=linux +[travis-url]: https://travis-ci.org/expressjs/express +[appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/express/master.svg?label=windows +[appveyor-url]: https://ci.appveyor.com/project/dougwilson/express +[coveralls-image]: https://img.shields.io/coveralls/expressjs/express/master.svg +[coveralls-url]: https://coveralls.io/r/expressjs/express?branch=master +[gratipay-image-visionmedia]: https://img.shields.io/gratipay/visionmedia.svg +[gratipay-url-visionmedia]: https://gratipay.com/visionmedia/ +[gratipay-image-dougwilson]: https://img.shields.io/gratipay/dougwilson.svg +[gratipay-url-dougwilson]: https://gratipay.com/dougwilson/ diff --git a/ui/node_modules/express/index.js b/ui/node_modules/express/index.js index b3673af6..d219b0c8 100644 --- a/ui/node_modules/express/index.js +++ b/ui/node_modules/express/index.js @@ -1,11 +1,11 @@ -/*! - * express - * Copyright(c) 2009-2013 TJ Holowaychuk - * Copyright(c) 2013 Roman Shtylman - * Copyright(c) 2014-2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict'; - -module.exports = require('./lib/express'); +/*! + * express + * Copyright(c) 2009-2013 TJ Holowaychuk + * Copyright(c) 2013 Roman Shtylman + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict'; + +module.exports = require('./lib/express'); diff --git a/ui/node_modules/express/lib/application.js b/ui/node_modules/express/lib/application.js index f1889636..0ee4def3 100644 --- a/ui/node_modules/express/lib/application.js +++ b/ui/node_modules/express/lib/application.js @@ -1,643 +1,643 @@ -/*! - * express - * Copyright(c) 2009-2013 TJ Holowaychuk - * Copyright(c) 2013 Roman Shtylman - * Copyright(c) 2014-2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict'; - -/** - * Module dependencies. - * @private - */ - -var finalhandler = require('finalhandler'); -var Router = require('./router'); -var methods = require('methods'); -var middleware = require('./middleware/init'); -var query = require('./middleware/query'); -var debug = require('debug')('express:application'); -var View = require('./view'); -var http = require('http'); -var compileETag = require('./utils').compileETag; -var compileQueryParser = require('./utils').compileQueryParser; -var compileTrust = require('./utils').compileTrust; -var deprecate = require('depd')('express'); -var flatten = require('array-flatten'); -var merge = require('utils-merge'); -var resolve = require('path').resolve; -var slice = Array.prototype.slice; - -/** - * Application prototype. - */ - -var app = exports = module.exports = {}; - -/** - * Variable for trust proxy inheritance back-compat - * @private - */ - -var trustProxyDefaultSymbol = '@@symbol:trust_proxy_default'; - -/** - * Initialize the server. - * - * - setup default configuration - * - setup default middleware - * - setup route reflection methods - * - * @private - */ - -app.init = function init() { - this.cache = {}; - this.engines = {}; - this.settings = {}; - - this.defaultConfiguration(); -}; - -/** - * Initialize application configuration. - * @private - */ - -app.defaultConfiguration = function defaultConfiguration() { - var env = process.env.NODE_ENV || 'development'; - - // default settings - this.enable('x-powered-by'); - this.set('etag', 'weak'); - this.set('env', env); - this.set('query parser', 'extended'); - this.set('subdomain offset', 2); - this.set('trust proxy', false); - - // trust proxy inherit back-compat - Object.defineProperty(this.settings, trustProxyDefaultSymbol, { - configurable: true, - value: true - }); - - debug('booting in %s mode', env); - - this.on('mount', function onmount(parent) { - // inherit trust proxy - if (this.settings[trustProxyDefaultSymbol] === true - && typeof parent.settings['trust proxy fn'] === 'function') { - delete this.settings['trust proxy']; - delete this.settings['trust proxy fn']; - } - - // inherit protos - this.request.__proto__ = parent.request; - this.response.__proto__ = parent.response; - this.engines.__proto__ = parent.engines; - this.settings.__proto__ = parent.settings; - }); - - // setup locals - this.locals = Object.create(null); - - // top-most app is mounted at / - this.mountpath = '/'; - - // default locals - this.locals.settings = this.settings; - - // default configuration - this.set('view', View); - this.set('views', resolve('views')); - this.set('jsonp callback name', 'callback'); - - if (env === 'production') { - this.enable('view cache'); - } - - Object.defineProperty(this, 'router', { - get: function() { - throw new Error('\'app.router\' is deprecated!\nPlease see the 3.x to 4.x migration guide for details on how to update your app.'); - } - }); -}; - -/** - * lazily adds the base router if it has not yet been added. - * - * We cannot add the base router in the defaultConfiguration because - * it reads app settings which might be set after that has run. - * - * @private - */ -app.lazyrouter = function lazyrouter() { - if (!this._router) { - this._router = new Router({ - caseSensitive: this.enabled('case sensitive routing'), - strict: this.enabled('strict routing') - }); - - this._router.use(query(this.get('query parser fn'))); - this._router.use(middleware.init(this)); - } -}; - -/** - * Dispatch a req, res pair into the application. Starts pipeline processing. - * - * If no callback is provided, then default error handlers will respond - * in the event of an error bubbling through the stack. - * - * @private - */ - -app.handle = function handle(req, res, callback) { - var router = this._router; - - // final handler - var done = callback || finalhandler(req, res, { - env: this.get('env'), - onerror: logerror.bind(this) - }); - - // no routes - if (!router) { - debug('no routes defined on app'); - done(); - return; - } - - router.handle(req, res, done); -}; - -/** - * Proxy `Router#use()` to add middleware to the app router. - * See Router#use() documentation for details. - * - * If the _fn_ parameter is an express app, then it will be - * mounted at the _route_ specified. - * - * @public - */ - -app.use = function use(fn) { - var offset = 0; - var path = '/'; - - // default path to '/' - // disambiguate app.use([fn]) - if (typeof fn !== 'function') { - var arg = fn; - - while (Array.isArray(arg) && arg.length !== 0) { - arg = arg[0]; - } - - // first arg is the path - if (typeof arg !== 'function') { - offset = 1; - path = fn; - } - } - - var fns = flatten(slice.call(arguments, offset)); - - if (fns.length === 0) { - throw new TypeError('app.use() requires middleware functions'); - } - - // setup router - this.lazyrouter(); - var router = this._router; - - fns.forEach(function (fn) { - // non-express app - if (!fn || !fn.handle || !fn.set) { - return router.use(path, fn); - } - - debug('.use app under %s', path); - fn.mountpath = path; - fn.parent = this; - - // restore .app property on req and res - router.use(path, function mounted_app(req, res, next) { - var orig = req.app; - fn.handle(req, res, function (err) { - req.__proto__ = orig.request; - res.__proto__ = orig.response; - next(err); - }); - }); - - // mounted an app - fn.emit('mount', this); - }, this); - - return this; -}; - -/** - * Proxy to the app `Router#route()` - * Returns a new `Route` instance for the _path_. - * - * Routes are isolated middleware stacks for specific paths. - * See the Route api docs for details. - * - * @public - */ - -app.route = function route(path) { - this.lazyrouter(); - return this._router.route(path); -}; - -/** - * Register the given template engine callback `fn` - * as `ext`. - * - * By default will `require()` the engine based on the - * file extension. For example if you try to render - * a "foo.jade" file Express will invoke the following internally: - * - * app.engine('jade', require('jade').__express); - * - * For engines that do not provide `.__express` out of the box, - * or if you wish to "map" a different extension to the template engine - * you may use this method. For example mapping the EJS template engine to - * ".html" files: - * - * app.engine('html', require('ejs').renderFile); - * - * In this case EJS provides a `.renderFile()` method with - * the same signature that Express expects: `(path, options, callback)`, - * though note that it aliases this method as `ejs.__express` internally - * so if you're using ".ejs" extensions you dont need to do anything. - * - * Some template engines do not follow this convention, the - * [Consolidate.js](https://github.com/tj/consolidate.js) - * library was created to map all of node's popular template - * engines to follow this convention, thus allowing them to - * work seamlessly within Express. - * - * @param {String} ext - * @param {Function} fn - * @return {app} for chaining - * @public - */ - -app.engine = function engine(ext, fn) { - if (typeof fn !== 'function') { - throw new Error('callback function required'); - } - - // get file extension - var extension = ext[0] !== '.' - ? '.' + ext - : ext; - - // store engine - this.engines[extension] = fn; - - return this; -}; - -/** - * Proxy to `Router#param()` with one added api feature. The _name_ parameter - * can be an array of names. - * - * See the Router#param() docs for more details. - * - * @param {String|Array} name - * @param {Function} fn - * @return {app} for chaining - * @public - */ - -app.param = function param(name, fn) { - this.lazyrouter(); - - if (Array.isArray(name)) { - for (var i = 0; i < name.length; i++) { - this.param(name[i], fn); - } - - return this; - } - - this._router.param(name, fn); - - return this; -}; - -/** - * Assign `setting` to `val`, or return `setting`'s value. - * - * app.set('foo', 'bar'); - * app.get('foo'); - * // => "bar" - * - * Mounted servers inherit their parent server's settings. - * - * @param {String} setting - * @param {*} [val] - * @return {Server} for chaining - * @public - */ - -app.set = function set(setting, val) { - if (arguments.length === 1) { - // app.get(setting) - return this.settings[setting]; - } - - debug('set "%s" to %o', setting, val); - - // set value - this.settings[setting] = val; - - // trigger matched settings - switch (setting) { - case 'etag': - this.set('etag fn', compileETag(val)); - break; - case 'query parser': - this.set('query parser fn', compileQueryParser(val)); - break; - case 'trust proxy': - this.set('trust proxy fn', compileTrust(val)); - - // trust proxy inherit back-compat - Object.defineProperty(this.settings, trustProxyDefaultSymbol, { - configurable: true, - value: false - }); - - break; - } - - return this; -}; - -/** - * Return the app's absolute pathname - * based on the parent(s) that have - * mounted it. - * - * For example if the application was - * mounted as "/admin", which itself - * was mounted as "/blog" then the - * return value would be "/blog/admin". - * - * @return {String} - * @private - */ - -app.path = function path() { - return this.parent - ? this.parent.path() + this.mountpath - : ''; -}; - -/** - * Check if `setting` is enabled (truthy). - * - * app.enabled('foo') - * // => false - * - * app.enable('foo') - * app.enabled('foo') - * // => true - * - * @param {String} setting - * @return {Boolean} - * @public - */ - -app.enabled = function enabled(setting) { - return Boolean(this.set(setting)); -}; - -/** - * Check if `setting` is disabled. - * - * app.disabled('foo') - * // => true - * - * app.enable('foo') - * app.disabled('foo') - * // => false - * - * @param {String} setting - * @return {Boolean} - * @public - */ - -app.disabled = function disabled(setting) { - return !this.set(setting); -}; - -/** - * Enable `setting`. - * - * @param {String} setting - * @return {app} for chaining - * @public - */ - -app.enable = function enable(setting) { - return this.set(setting, true); -}; - -/** - * Disable `setting`. - * - * @param {String} setting - * @return {app} for chaining - * @public - */ - -app.disable = function disable(setting) { - return this.set(setting, false); -}; - -/** - * Delegate `.VERB(...)` calls to `router.VERB(...)`. - */ - -methods.forEach(function(method){ - app[method] = function(path){ - if (method === 'get' && arguments.length === 1) { - // app.get(setting) - return this.set(path); - } - - this.lazyrouter(); - - var route = this._router.route(path); - route[method].apply(route, slice.call(arguments, 1)); - return this; - }; -}); - -/** - * Special-cased "all" method, applying the given route `path`, - * middleware, and callback to _every_ HTTP method. - * - * @param {String} path - * @param {Function} ... - * @return {app} for chaining - * @public - */ - -app.all = function all(path) { - this.lazyrouter(); - - var route = this._router.route(path); - var args = slice.call(arguments, 1); - - for (var i = 0; i < methods.length; i++) { - route[methods[i]].apply(route, args); - } - - return this; -}; - -// del -> delete alias - -app.del = deprecate.function(app.delete, 'app.del: Use app.delete instead'); - -/** - * Render the given view `name` name with `options` - * and a callback accepting an error and the - * rendered template string. - * - * Example: - * - * app.render('email', { name: 'Tobi' }, function(err, html){ - * // ... - * }) - * - * @param {String} name - * @param {Object|Function} options or fn - * @param {Function} callback - * @public - */ - -app.render = function render(name, options, callback) { - var cache = this.cache; - var done = callback; - var engines = this.engines; - var opts = options; - var renderOptions = {}; - var view; - - // support callback function as second arg - if (typeof options === 'function') { - done = options; - opts = {}; - } - - // merge app.locals - merge(renderOptions, this.locals); - - // merge options._locals - if (opts._locals) { - merge(renderOptions, opts._locals); - } - - // merge options - merge(renderOptions, opts); - - // set .cache unless explicitly provided - if (renderOptions.cache == null) { - renderOptions.cache = this.enabled('view cache'); - } - - // primed cache - if (renderOptions.cache) { - view = cache[name]; - } - - // view - if (!view) { - var View = this.get('view'); - - view = new View(name, { - defaultEngine: this.get('view engine'), - root: this.get('views'), - engines: engines - }); - - if (!view.path) { - var dirs = Array.isArray(view.root) && view.root.length > 1 - ? 'directories "' + view.root.slice(0, -1).join('", "') + '" or "' + view.root[view.root.length - 1] + '"' - : 'directory "' + view.root + '"' - var err = new Error('Failed to lookup view "' + name + '" in views ' + dirs); - err.view = view; - return done(err); - } - - // prime the cache - if (renderOptions.cache) { - cache[name] = view; - } - } - - // render - tryRender(view, renderOptions, done); -}; - -/** - * Listen for connections. - * - * A node `http.Server` is returned, with this - * application (which is a `Function`) as its - * callback. If you wish to create both an HTTP - * and HTTPS server you may do so with the "http" - * and "https" modules as shown here: - * - * var http = require('http') - * , https = require('https') - * , express = require('express') - * , app = express(); - * - * http.createServer(app).listen(80); - * https.createServer({ ... }, app).listen(443); - * - * @return {http.Server} - * @public - */ - -app.listen = function listen() { - var server = http.createServer(this); - return server.listen.apply(server, arguments); -}; - -/** - * Log error using console.error. - * - * @param {Error} err - * @private - */ - -function logerror(err) { - /* istanbul ignore next */ - if (this.get('env') !== 'test') console.error(err.stack || err.toString()); -} - -/** - * Try rendering a view. - * @private - */ - -function tryRender(view, options, callback) { - try { - view.render(options, callback); - } catch (err) { - callback(err); - } -} +/*! + * express + * Copyright(c) 2009-2013 TJ Holowaychuk + * Copyright(c) 2013 Roman Shtylman + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict'; + +/** + * Module dependencies. + * @private + */ + +var finalhandler = require('finalhandler'); +var Router = require('./router'); +var methods = require('methods'); +var middleware = require('./middleware/init'); +var query = require('./middleware/query'); +var debug = require('debug')('express:application'); +var View = require('./view'); +var http = require('http'); +var compileETag = require('./utils').compileETag; +var compileQueryParser = require('./utils').compileQueryParser; +var compileTrust = require('./utils').compileTrust; +var deprecate = require('depd')('express'); +var flatten = require('array-flatten'); +var merge = require('utils-merge'); +var resolve = require('path').resolve; +var slice = Array.prototype.slice; + +/** + * Application prototype. + */ + +var app = exports = module.exports = {}; + +/** + * Variable for trust proxy inheritance back-compat + * @private + */ + +var trustProxyDefaultSymbol = '@@symbol:trust_proxy_default'; + +/** + * Initialize the server. + * + * - setup default configuration + * - setup default middleware + * - setup route reflection methods + * + * @private + */ + +app.init = function init() { + this.cache = {}; + this.engines = {}; + this.settings = {}; + + this.defaultConfiguration(); +}; + +/** + * Initialize application configuration. + * @private + */ + +app.defaultConfiguration = function defaultConfiguration() { + var env = process.env.NODE_ENV || 'development'; + + // default settings + this.enable('x-powered-by'); + this.set('etag', 'weak'); + this.set('env', env); + this.set('query parser', 'extended'); + this.set('subdomain offset', 2); + this.set('trust proxy', false); + + // trust proxy inherit back-compat + Object.defineProperty(this.settings, trustProxyDefaultSymbol, { + configurable: true, + value: true + }); + + debug('booting in %s mode', env); + + this.on('mount', function onmount(parent) { + // inherit trust proxy + if (this.settings[trustProxyDefaultSymbol] === true + && typeof parent.settings['trust proxy fn'] === 'function') { + delete this.settings['trust proxy']; + delete this.settings['trust proxy fn']; + } + + // inherit protos + this.request.__proto__ = parent.request; + this.response.__proto__ = parent.response; + this.engines.__proto__ = parent.engines; + this.settings.__proto__ = parent.settings; + }); + + // setup locals + this.locals = Object.create(null); + + // top-most app is mounted at / + this.mountpath = '/'; + + // default locals + this.locals.settings = this.settings; + + // default configuration + this.set('view', View); + this.set('views', resolve('views')); + this.set('jsonp callback name', 'callback'); + + if (env === 'production') { + this.enable('view cache'); + } + + Object.defineProperty(this, 'router', { + get: function() { + throw new Error('\'app.router\' is deprecated!\nPlease see the 3.x to 4.x migration guide for details on how to update your app.'); + } + }); +}; + +/** + * lazily adds the base router if it has not yet been added. + * + * We cannot add the base router in the defaultConfiguration because + * it reads app settings which might be set after that has run. + * + * @private + */ +app.lazyrouter = function lazyrouter() { + if (!this._router) { + this._router = new Router({ + caseSensitive: this.enabled('case sensitive routing'), + strict: this.enabled('strict routing') + }); + + this._router.use(query(this.get('query parser fn'))); + this._router.use(middleware.init(this)); + } +}; + +/** + * Dispatch a req, res pair into the application. Starts pipeline processing. + * + * If no callback is provided, then default error handlers will respond + * in the event of an error bubbling through the stack. + * + * @private + */ + +app.handle = function handle(req, res, callback) { + var router = this._router; + + // final handler + var done = callback || finalhandler(req, res, { + env: this.get('env'), + onerror: logerror.bind(this) + }); + + // no routes + if (!router) { + debug('no routes defined on app'); + done(); + return; + } + + router.handle(req, res, done); +}; + +/** + * Proxy `Router#use()` to add middleware to the app router. + * See Router#use() documentation for details. + * + * If the _fn_ parameter is an express app, then it will be + * mounted at the _route_ specified. + * + * @public + */ + +app.use = function use(fn) { + var offset = 0; + var path = '/'; + + // default path to '/' + // disambiguate app.use([fn]) + if (typeof fn !== 'function') { + var arg = fn; + + while (Array.isArray(arg) && arg.length !== 0) { + arg = arg[0]; + } + + // first arg is the path + if (typeof arg !== 'function') { + offset = 1; + path = fn; + } + } + + var fns = flatten(slice.call(arguments, offset)); + + if (fns.length === 0) { + throw new TypeError('app.use() requires middleware functions'); + } + + // setup router + this.lazyrouter(); + var router = this._router; + + fns.forEach(function (fn) { + // non-express app + if (!fn || !fn.handle || !fn.set) { + return router.use(path, fn); + } + + debug('.use app under %s', path); + fn.mountpath = path; + fn.parent = this; + + // restore .app property on req and res + router.use(path, function mounted_app(req, res, next) { + var orig = req.app; + fn.handle(req, res, function (err) { + req.__proto__ = orig.request; + res.__proto__ = orig.response; + next(err); + }); + }); + + // mounted an app + fn.emit('mount', this); + }, this); + + return this; +}; + +/** + * Proxy to the app `Router#route()` + * Returns a new `Route` instance for the _path_. + * + * Routes are isolated middleware stacks for specific paths. + * See the Route api docs for details. + * + * @public + */ + +app.route = function route(path) { + this.lazyrouter(); + return this._router.route(path); +}; + +/** + * Register the given template engine callback `fn` + * as `ext`. + * + * By default will `require()` the engine based on the + * file extension. For example if you try to render + * a "foo.jade" file Express will invoke the following internally: + * + * app.engine('jade', require('jade').__express); + * + * For engines that do not provide `.__express` out of the box, + * or if you wish to "map" a different extension to the template engine + * you may use this method. For example mapping the EJS template engine to + * ".html" files: + * + * app.engine('html', require('ejs').renderFile); + * + * In this case EJS provides a `.renderFile()` method with + * the same signature that Express expects: `(path, options, callback)`, + * though note that it aliases this method as `ejs.__express` internally + * so if you're using ".ejs" extensions you dont need to do anything. + * + * Some template engines do not follow this convention, the + * [Consolidate.js](https://github.com/tj/consolidate.js) + * library was created to map all of node's popular template + * engines to follow this convention, thus allowing them to + * work seamlessly within Express. + * + * @param {String} ext + * @param {Function} fn + * @return {app} for chaining + * @public + */ + +app.engine = function engine(ext, fn) { + if (typeof fn !== 'function') { + throw new Error('callback function required'); + } + + // get file extension + var extension = ext[0] !== '.' + ? '.' + ext + : ext; + + // store engine + this.engines[extension] = fn; + + return this; +}; + +/** + * Proxy to `Router#param()` with one added api feature. The _name_ parameter + * can be an array of names. + * + * See the Router#param() docs for more details. + * + * @param {String|Array} name + * @param {Function} fn + * @return {app} for chaining + * @public + */ + +app.param = function param(name, fn) { + this.lazyrouter(); + + if (Array.isArray(name)) { + for (var i = 0; i < name.length; i++) { + this.param(name[i], fn); + } + + return this; + } + + this._router.param(name, fn); + + return this; +}; + +/** + * Assign `setting` to `val`, or return `setting`'s value. + * + * app.set('foo', 'bar'); + * app.get('foo'); + * // => "bar" + * + * Mounted servers inherit their parent server's settings. + * + * @param {String} setting + * @param {*} [val] + * @return {Server} for chaining + * @public + */ + +app.set = function set(setting, val) { + if (arguments.length === 1) { + // app.get(setting) + return this.settings[setting]; + } + + debug('set "%s" to %o', setting, val); + + // set value + this.settings[setting] = val; + + // trigger matched settings + switch (setting) { + case 'etag': + this.set('etag fn', compileETag(val)); + break; + case 'query parser': + this.set('query parser fn', compileQueryParser(val)); + break; + case 'trust proxy': + this.set('trust proxy fn', compileTrust(val)); + + // trust proxy inherit back-compat + Object.defineProperty(this.settings, trustProxyDefaultSymbol, { + configurable: true, + value: false + }); + + break; + } + + return this; +}; + +/** + * Return the app's absolute pathname + * based on the parent(s) that have + * mounted it. + * + * For example if the application was + * mounted as "/admin", which itself + * was mounted as "/blog" then the + * return value would be "/blog/admin". + * + * @return {String} + * @private + */ + +app.path = function path() { + return this.parent + ? this.parent.path() + this.mountpath + : ''; +}; + +/** + * Check if `setting` is enabled (truthy). + * + * app.enabled('foo') + * // => false + * + * app.enable('foo') + * app.enabled('foo') + * // => true + * + * @param {String} setting + * @return {Boolean} + * @public + */ + +app.enabled = function enabled(setting) { + return Boolean(this.set(setting)); +}; + +/** + * Check if `setting` is disabled. + * + * app.disabled('foo') + * // => true + * + * app.enable('foo') + * app.disabled('foo') + * // => false + * + * @param {String} setting + * @return {Boolean} + * @public + */ + +app.disabled = function disabled(setting) { + return !this.set(setting); +}; + +/** + * Enable `setting`. + * + * @param {String} setting + * @return {app} for chaining + * @public + */ + +app.enable = function enable(setting) { + return this.set(setting, true); +}; + +/** + * Disable `setting`. + * + * @param {String} setting + * @return {app} for chaining + * @public + */ + +app.disable = function disable(setting) { + return this.set(setting, false); +}; + +/** + * Delegate `.VERB(...)` calls to `router.VERB(...)`. + */ + +methods.forEach(function(method){ + app[method] = function(path){ + if (method === 'get' && arguments.length === 1) { + // app.get(setting) + return this.set(path); + } + + this.lazyrouter(); + + var route = this._router.route(path); + route[method].apply(route, slice.call(arguments, 1)); + return this; + }; +}); + +/** + * Special-cased "all" method, applying the given route `path`, + * middleware, and callback to _every_ HTTP method. + * + * @param {String} path + * @param {Function} ... + * @return {app} for chaining + * @public + */ + +app.all = function all(path) { + this.lazyrouter(); + + var route = this._router.route(path); + var args = slice.call(arguments, 1); + + for (var i = 0; i < methods.length; i++) { + route[methods[i]].apply(route, args); + } + + return this; +}; + +// del -> delete alias + +app.del = deprecate.function(app.delete, 'app.del: Use app.delete instead'); + +/** + * Render the given view `name` name with `options` + * and a callback accepting an error and the + * rendered template string. + * + * Example: + * + * app.render('email', { name: 'Tobi' }, function(err, html){ + * // ... + * }) + * + * @param {String} name + * @param {Object|Function} options or fn + * @param {Function} callback + * @public + */ + +app.render = function render(name, options, callback) { + var cache = this.cache; + var done = callback; + var engines = this.engines; + var opts = options; + var renderOptions = {}; + var view; + + // support callback function as second arg + if (typeof options === 'function') { + done = options; + opts = {}; + } + + // merge app.locals + merge(renderOptions, this.locals); + + // merge options._locals + if (opts._locals) { + merge(renderOptions, opts._locals); + } + + // merge options + merge(renderOptions, opts); + + // set .cache unless explicitly provided + if (renderOptions.cache == null) { + renderOptions.cache = this.enabled('view cache'); + } + + // primed cache + if (renderOptions.cache) { + view = cache[name]; + } + + // view + if (!view) { + var View = this.get('view'); + + view = new View(name, { + defaultEngine: this.get('view engine'), + root: this.get('views'), + engines: engines + }); + + if (!view.path) { + var dirs = Array.isArray(view.root) && view.root.length > 1 + ? 'directories "' + view.root.slice(0, -1).join('", "') + '" or "' + view.root[view.root.length - 1] + '"' + : 'directory "' + view.root + '"' + var err = new Error('Failed to lookup view "' + name + '" in views ' + dirs); + err.view = view; + return done(err); + } + + // prime the cache + if (renderOptions.cache) { + cache[name] = view; + } + } + + // render + tryRender(view, renderOptions, done); +}; + +/** + * Listen for connections. + * + * A node `http.Server` is returned, with this + * application (which is a `Function`) as its + * callback. If you wish to create both an HTTP + * and HTTPS server you may do so with the "http" + * and "https" modules as shown here: + * + * var http = require('http') + * , https = require('https') + * , express = require('express') + * , app = express(); + * + * http.createServer(app).listen(80); + * https.createServer({ ... }, app).listen(443); + * + * @return {http.Server} + * @public + */ + +app.listen = function listen() { + var server = http.createServer(this); + return server.listen.apply(server, arguments); +}; + +/** + * Log error using console.error. + * + * @param {Error} err + * @private + */ + +function logerror(err) { + /* istanbul ignore next */ + if (this.get('env') !== 'test') console.error(err.stack || err.toString()); +} + +/** + * Try rendering a view. + * @private + */ + +function tryRender(view, options, callback) { + try { + view.render(options, callback); + } catch (err) { + callback(err); + } +} diff --git a/ui/node_modules/express/lib/express.js b/ui/node_modules/express/lib/express.js index c20caff8..540c8be6 100644 --- a/ui/node_modules/express/lib/express.js +++ b/ui/node_modules/express/lib/express.js @@ -1,103 +1,103 @@ -/*! - * express - * Copyright(c) 2009-2013 TJ Holowaychuk - * Copyright(c) 2013 Roman Shtylman - * Copyright(c) 2014-2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict'; - -/** - * Module dependencies. - */ - -var EventEmitter = require('events').EventEmitter; -var mixin = require('merge-descriptors'); -var proto = require('./application'); -var Route = require('./router/route'); -var Router = require('./router'); -var req = require('./request'); -var res = require('./response'); - -/** - * Expose `createApplication()`. - */ - -exports = module.exports = createApplication; - -/** - * Create an express application. - * - * @return {Function} - * @api public - */ - -function createApplication() { - var app = function(req, res, next) { - app.handle(req, res, next); - }; - - mixin(app, EventEmitter.prototype, false); - mixin(app, proto, false); - - app.request = { __proto__: req, app: app }; - app.response = { __proto__: res, app: app }; - app.init(); - return app; -} - -/** - * Expose the prototypes. - */ - -exports.application = proto; -exports.request = req; -exports.response = res; - -/** - * Expose constructors. - */ - -exports.Route = Route; -exports.Router = Router; - -/** - * Expose middleware - */ - -exports.query = require('./middleware/query'); -exports.static = require('serve-static'); - -/** - * Replace removed middleware with an appropriate error message. - */ - -[ - 'json', - 'urlencoded', - 'bodyParser', - 'compress', - 'cookieSession', - 'session', - 'logger', - 'cookieParser', - 'favicon', - 'responseTime', - 'errorHandler', - 'timeout', - 'methodOverride', - 'vhost', - 'csrf', - 'directory', - 'limit', - 'multipart', - 'staticCache', -].forEach(function (name) { - Object.defineProperty(exports, name, { - get: function () { - throw new Error('Most middleware (like ' + name + ') is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware.'); - }, - configurable: true - }); -}); +/*! + * express + * Copyright(c) 2009-2013 TJ Holowaychuk + * Copyright(c) 2013 Roman Shtylman + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict'; + +/** + * Module dependencies. + */ + +var EventEmitter = require('events').EventEmitter; +var mixin = require('merge-descriptors'); +var proto = require('./application'); +var Route = require('./router/route'); +var Router = require('./router'); +var req = require('./request'); +var res = require('./response'); + +/** + * Expose `createApplication()`. + */ + +exports = module.exports = createApplication; + +/** + * Create an express application. + * + * @return {Function} + * @api public + */ + +function createApplication() { + var app = function(req, res, next) { + app.handle(req, res, next); + }; + + mixin(app, EventEmitter.prototype, false); + mixin(app, proto, false); + + app.request = { __proto__: req, app: app }; + app.response = { __proto__: res, app: app }; + app.init(); + return app; +} + +/** + * Expose the prototypes. + */ + +exports.application = proto; +exports.request = req; +exports.response = res; + +/** + * Expose constructors. + */ + +exports.Route = Route; +exports.Router = Router; + +/** + * Expose middleware + */ + +exports.query = require('./middleware/query'); +exports.static = require('serve-static'); + +/** + * Replace removed middleware with an appropriate error message. + */ + +[ + 'json', + 'urlencoded', + 'bodyParser', + 'compress', + 'cookieSession', + 'session', + 'logger', + 'cookieParser', + 'favicon', + 'responseTime', + 'errorHandler', + 'timeout', + 'methodOverride', + 'vhost', + 'csrf', + 'directory', + 'limit', + 'multipart', + 'staticCache', +].forEach(function (name) { + Object.defineProperty(exports, name, { + get: function () { + throw new Error('Most middleware (like ' + name + ') is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware.'); + }, + configurable: true + }); +}); diff --git a/ui/node_modules/express/lib/middleware/init.js b/ui/node_modules/express/lib/middleware/init.js index 3a7f2c4d..f3119ed3 100644 --- a/ui/node_modules/express/lib/middleware/init.js +++ b/ui/node_modules/express/lib/middleware/init.js @@ -1,36 +1,36 @@ -/*! - * express - * Copyright(c) 2009-2013 TJ Holowaychuk - * Copyright(c) 2013 Roman Shtylman - * Copyright(c) 2014-2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict'; - -/** - * Initialization middleware, exposing the - * request and response to each other, as well - * as defaulting the X-Powered-By header field. - * - * @param {Function} app - * @return {Function} - * @api private - */ - -exports.init = function(app){ - return function expressInit(req, res, next){ - if (app.enabled('x-powered-by')) res.setHeader('X-Powered-By', 'Express'); - req.res = res; - res.req = req; - req.next = next; - - req.__proto__ = app.request; - res.__proto__ = app.response; - - res.locals = res.locals || Object.create(null); - - next(); - }; -}; - +/*! + * express + * Copyright(c) 2009-2013 TJ Holowaychuk + * Copyright(c) 2013 Roman Shtylman + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict'; + +/** + * Initialization middleware, exposing the + * request and response to each other, as well + * as defaulting the X-Powered-By header field. + * + * @param {Function} app + * @return {Function} + * @api private + */ + +exports.init = function(app){ + return function expressInit(req, res, next){ + if (app.enabled('x-powered-by')) res.setHeader('X-Powered-By', 'Express'); + req.res = res; + res.req = req; + req.next = next; + + req.__proto__ = app.request; + res.__proto__ = app.response; + + res.locals = res.locals || Object.create(null); + + next(); + }; +}; + diff --git a/ui/node_modules/express/lib/middleware/query.js b/ui/node_modules/express/lib/middleware/query.js index 6fd2f95d..5f76f845 100644 --- a/ui/node_modules/express/lib/middleware/query.js +++ b/ui/node_modules/express/lib/middleware/query.js @@ -1,46 +1,46 @@ -/*! - * express - * Copyright(c) 2009-2013 TJ Holowaychuk - * Copyright(c) 2013 Roman Shtylman - * Copyright(c) 2014-2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict'; - -/** - * Module dependencies. - */ - -var parseUrl = require('parseurl'); -var qs = require('qs'); - -/** - * @param {Object} options - * @return {Function} - * @api public - */ - -module.exports = function query(options) { - var opts = Object.create(options || null); - var queryparse = qs.parse; - - if (typeof options === 'function') { - queryparse = options; - opts = undefined; - } - - if (opts !== undefined && opts.allowPrototypes === undefined) { - // back-compat for qs module - opts.allowPrototypes = true; - } - - return function query(req, res, next){ - if (!req.query) { - var val = parseUrl(req).query; - req.query = queryparse(val, opts); - } - - next(); - }; -}; +/*! + * express + * Copyright(c) 2009-2013 TJ Holowaychuk + * Copyright(c) 2013 Roman Shtylman + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict'; + +/** + * Module dependencies. + */ + +var parseUrl = require('parseurl'); +var qs = require('qs'); + +/** + * @param {Object} options + * @return {Function} + * @api public + */ + +module.exports = function query(options) { + var opts = Object.create(options || null); + var queryparse = qs.parse; + + if (typeof options === 'function') { + queryparse = options; + opts = undefined; + } + + if (opts !== undefined && opts.allowPrototypes === undefined) { + // back-compat for qs module + opts.allowPrototypes = true; + } + + return function query(req, res, next){ + if (!req.query) { + var val = parseUrl(req).query; + req.query = queryparse(val, opts); + } + + next(); + }; +}; diff --git a/ui/node_modules/express/lib/request.js b/ui/node_modules/express/lib/request.js index 45aafb3b..557d050f 100644 --- a/ui/node_modules/express/lib/request.js +++ b/ui/node_modules/express/lib/request.js @@ -1,502 +1,502 @@ -/*! - * express - * Copyright(c) 2009-2013 TJ Holowaychuk - * Copyright(c) 2013 Roman Shtylman - * Copyright(c) 2014-2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict'; - -/** - * Module dependencies. - * @private - */ - -var accepts = require('accepts'); -var deprecate = require('depd')('express'); -var isIP = require('net').isIP; -var typeis = require('type-is'); -var http = require('http'); -var fresh = require('fresh'); -var parseRange = require('range-parser'); -var parse = require('parseurl'); -var proxyaddr = require('proxy-addr'); - -/** - * Request prototype. - */ - -var req = exports = module.exports = { - __proto__: http.IncomingMessage.prototype -}; - -/** - * Return request header. - * - * The `Referrer` header field is special-cased, - * both `Referrer` and `Referer` are interchangeable. - * - * Examples: - * - * req.get('Content-Type'); - * // => "text/plain" - * - * req.get('content-type'); - * // => "text/plain" - * - * req.get('Something'); - * // => undefined - * - * Aliased as `req.header()`. - * - * @param {String} name - * @return {String} - * @public - */ - -req.get = -req.header = function header(name) { - if (!name) { - throw new TypeError('name argument is required to req.get'); - } - - if (typeof name !== 'string') { - throw new TypeError('name must be a string to req.get'); - } - - var lc = name.toLowerCase(); - - switch (lc) { - case 'referer': - case 'referrer': - return this.headers.referrer - || this.headers.referer; - default: - return this.headers[lc]; - } -}; - -/** - * To do: update docs. - * - * Check if the given `type(s)` is acceptable, returning - * the best match when true, otherwise `undefined`, in which - * case you should respond with 406 "Not Acceptable". - * - * The `type` value may be a single MIME type string - * such as "application/json", an extension name - * such as "json", a comma-delimited list such as "json, html, text/plain", - * an argument list such as `"json", "html", "text/plain"`, - * or an array `["json", "html", "text/plain"]`. When a list - * or array is given, the _best_ match, if any is returned. - * - * Examples: - * - * // Accept: text/html - * req.accepts('html'); - * // => "html" - * - * // Accept: text/*, application/json - * req.accepts('html'); - * // => "html" - * req.accepts('text/html'); - * // => "text/html" - * req.accepts('json, text'); - * // => "json" - * req.accepts('application/json'); - * // => "application/json" - * - * // Accept: text/*, application/json - * req.accepts('image/png'); - * req.accepts('png'); - * // => undefined - * - * // Accept: text/*;q=.5, application/json - * req.accepts(['html', 'json']); - * req.accepts('html', 'json'); - * req.accepts('html, json'); - * // => "json" - * - * @param {String|Array} type(s) - * @return {String|Array|Boolean} - * @public - */ - -req.accepts = function(){ - var accept = accepts(this); - return accept.types.apply(accept, arguments); -}; - -/** - * Check if the given `encoding`s are accepted. - * - * @param {String} ...encoding - * @return {String|Array} - * @public - */ - -req.acceptsEncodings = function(){ - var accept = accepts(this); - return accept.encodings.apply(accept, arguments); -}; - -req.acceptsEncoding = deprecate.function(req.acceptsEncodings, - 'req.acceptsEncoding: Use acceptsEncodings instead'); - -/** - * Check if the given `charset`s are acceptable, - * otherwise you should respond with 406 "Not Acceptable". - * - * @param {String} ...charset - * @return {String|Array} - * @public - */ - -req.acceptsCharsets = function(){ - var accept = accepts(this); - return accept.charsets.apply(accept, arguments); -}; - -req.acceptsCharset = deprecate.function(req.acceptsCharsets, - 'req.acceptsCharset: Use acceptsCharsets instead'); - -/** - * Check if the given `lang`s are acceptable, - * otherwise you should respond with 406 "Not Acceptable". - * - * @param {String} ...lang - * @return {String|Array} - * @public - */ - -req.acceptsLanguages = function(){ - var accept = accepts(this); - return accept.languages.apply(accept, arguments); -}; - -req.acceptsLanguage = deprecate.function(req.acceptsLanguages, - 'req.acceptsLanguage: Use acceptsLanguages instead'); - -/** - * Parse Range header field, capping to the given `size`. - * - * Unspecified ranges such as "0-" require knowledge of your resource length. In - * the case of a byte range this is of course the total number of bytes. If the - * Range header field is not given `undefined` is returned, `-1` when unsatisfiable, - * and `-2` when syntactically invalid. - * - * When ranges are returned, the array has a "type" property which is the type of - * range that is required (most commonly, "bytes"). Each array element is an object - * with a "start" and "end" property for the portion of the range. - * - * The "combine" option can be set to `true` and overlapping & adjacent ranges - * will be combined into a single range. - * - * NOTE: remember that ranges are inclusive, so for example "Range: users=0-3" - * should respond with 4 users when available, not 3. - * - * @param {number} size - * @param {object} [options] - * @param {boolean} [options.combine=false] - * @return {number|array} - * @public - */ - -req.range = function range(size, options) { - var range = this.get('Range'); - if (!range) return; - return parseRange(size, range, options); -}; - -/** - * Return the value of param `name` when present or `defaultValue`. - * - * - Checks route placeholders, ex: _/user/:id_ - * - Checks body params, ex: id=12, {"id":12} - * - Checks query string params, ex: ?id=12 - * - * To utilize request bodies, `req.body` - * should be an object. This can be done by using - * the `bodyParser()` middleware. - * - * @param {String} name - * @param {Mixed} [defaultValue] - * @return {String} - * @public - */ - -req.param = function param(name, defaultValue) { - var params = this.params || {}; - var body = this.body || {}; - var query = this.query || {}; - - var args = arguments.length === 1 - ? 'name' - : 'name, default'; - deprecate('req.param(' + args + '): Use req.params, req.body, or req.query instead'); - - if (null != params[name] && params.hasOwnProperty(name)) return params[name]; - if (null != body[name]) return body[name]; - if (null != query[name]) return query[name]; - - return defaultValue; -}; - -/** - * Check if the incoming request contains the "Content-Type" - * header field, and it contains the give mime `type`. - * - * Examples: - * - * // With Content-Type: text/html; charset=utf-8 - * req.is('html'); - * req.is('text/html'); - * req.is('text/*'); - * // => true - * - * // When Content-Type is application/json - * req.is('json'); - * req.is('application/json'); - * req.is('application/*'); - * // => true - * - * req.is('html'); - * // => false - * - * @param {String|Array} types... - * @return {String|false|null} - * @public - */ - -req.is = function is(types) { - var arr = types; - - // support flattened arguments - if (!Array.isArray(types)) { - arr = new Array(arguments.length); - for (var i = 0; i < arr.length; i++) { - arr[i] = arguments[i]; - } - } - - return typeis(this, arr); -}; - -/** - * Return the protocol string "http" or "https" - * when requested with TLS. When the "trust proxy" - * setting trusts the socket address, the - * "X-Forwarded-Proto" header field will be trusted - * and used if present. - * - * If you're running behind a reverse proxy that - * supplies https for you this may be enabled. - * - * @return {String} - * @public - */ - -defineGetter(req, 'protocol', function protocol(){ - var proto = this.connection.encrypted - ? 'https' - : 'http'; - var trust = this.app.get('trust proxy fn'); - - if (!trust(this.connection.remoteAddress, 0)) { - return proto; - } - - // Note: X-Forwarded-Proto is normally only ever a - // single value, but this is to be safe. - proto = this.get('X-Forwarded-Proto') || proto; - return proto.split(/\s*,\s*/)[0]; -}); - -/** - * Short-hand for: - * - * req.protocol === 'https' - * - * @return {Boolean} - * @public - */ - -defineGetter(req, 'secure', function secure(){ - return this.protocol === 'https'; -}); - -/** - * Return the remote address from the trusted proxy. - * - * The is the remote address on the socket unless - * "trust proxy" is set. - * - * @return {String} - * @public - */ - -defineGetter(req, 'ip', function ip(){ - var trust = this.app.get('trust proxy fn'); - return proxyaddr(this, trust); -}); - -/** - * When "trust proxy" is set, trusted proxy addresses + client. - * - * For example if the value were "client, proxy1, proxy2" - * you would receive the array `["client", "proxy1", "proxy2"]` - * where "proxy2" is the furthest down-stream and "proxy1" and - * "proxy2" were trusted. - * - * @return {Array} - * @public - */ - -defineGetter(req, 'ips', function ips() { - var trust = this.app.get('trust proxy fn'); - var addrs = proxyaddr.all(this, trust); - return addrs.slice(1).reverse(); -}); - -/** - * Return subdomains as an array. - * - * Subdomains are the dot-separated parts of the host before the main domain of - * the app. By default, the domain of the app is assumed to be the last two - * parts of the host. This can be changed by setting "subdomain offset". - * - * For example, if the domain is "tobi.ferrets.example.com": - * If "subdomain offset" is not set, req.subdomains is `["ferrets", "tobi"]`. - * If "subdomain offset" is 3, req.subdomains is `["tobi"]`. - * - * @return {Array} - * @public - */ - -defineGetter(req, 'subdomains', function subdomains() { - var hostname = this.hostname; - - if (!hostname) return []; - - var offset = this.app.get('subdomain offset'); - var subdomains = !isIP(hostname) - ? hostname.split('.').reverse() - : [hostname]; - - return subdomains.slice(offset); -}); - -/** - * Short-hand for `url.parse(req.url).pathname`. - * - * @return {String} - * @public - */ - -defineGetter(req, 'path', function path() { - return parse(this).pathname; -}); - -/** - * Parse the "Host" header field to a hostname. - * - * When the "trust proxy" setting trusts the socket - * address, the "X-Forwarded-Host" header field will - * be trusted. - * - * @return {String} - * @public - */ - -defineGetter(req, 'hostname', function hostname(){ - var trust = this.app.get('trust proxy fn'); - var host = this.get('X-Forwarded-Host'); - - if (!host || !trust(this.connection.remoteAddress, 0)) { - host = this.get('Host'); - } - - if (!host) return; - - // IPv6 literal support - var offset = host[0] === '[' - ? host.indexOf(']') + 1 - : 0; - var index = host.indexOf(':', offset); - - return index !== -1 - ? host.substring(0, index) - : host; -}); - -// TODO: change req.host to return host in next major - -defineGetter(req, 'host', deprecate.function(function host(){ - return this.hostname; -}, 'req.host: Use req.hostname instead')); - -/** - * Check if the request is fresh, aka - * Last-Modified and/or the ETag - * still match. - * - * @return {Boolean} - * @public - */ - -defineGetter(req, 'fresh', function(){ - var method = this.method; - var s = this.res.statusCode; - - // GET or HEAD for weak freshness validation only - if ('GET' !== method && 'HEAD' !== method) return false; - - // 2xx or 304 as per rfc2616 14.26 - if ((s >= 200 && s < 300) || 304 === s) { - return fresh(this.headers, (this.res._headers || {})); - } - - return false; -}); - -/** - * Check if the request is stale, aka - * "Last-Modified" and / or the "ETag" for the - * resource has changed. - * - * @return {Boolean} - * @public - */ - -defineGetter(req, 'stale', function stale(){ - return !this.fresh; -}); - -/** - * Check if the request was an _XMLHttpRequest_. - * - * @return {Boolean} - * @public - */ - -defineGetter(req, 'xhr', function xhr(){ - var val = this.get('X-Requested-With') || ''; - return val.toLowerCase() === 'xmlhttprequest'; -}); - -/** - * Helper function for creating a getter on an object. - * - * @param {Object} obj - * @param {String} name - * @param {Function} getter - * @private - */ -function defineGetter(obj, name, getter) { - Object.defineProperty(obj, name, { - configurable: true, - enumerable: true, - get: getter - }); -}; +/*! + * express + * Copyright(c) 2009-2013 TJ Holowaychuk + * Copyright(c) 2013 Roman Shtylman + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict'; + +/** + * Module dependencies. + * @private + */ + +var accepts = require('accepts'); +var deprecate = require('depd')('express'); +var isIP = require('net').isIP; +var typeis = require('type-is'); +var http = require('http'); +var fresh = require('fresh'); +var parseRange = require('range-parser'); +var parse = require('parseurl'); +var proxyaddr = require('proxy-addr'); + +/** + * Request prototype. + */ + +var req = exports = module.exports = { + __proto__: http.IncomingMessage.prototype +}; + +/** + * Return request header. + * + * The `Referrer` header field is special-cased, + * both `Referrer` and `Referer` are interchangeable. + * + * Examples: + * + * req.get('Content-Type'); + * // => "text/plain" + * + * req.get('content-type'); + * // => "text/plain" + * + * req.get('Something'); + * // => undefined + * + * Aliased as `req.header()`. + * + * @param {String} name + * @return {String} + * @public + */ + +req.get = +req.header = function header(name) { + if (!name) { + throw new TypeError('name argument is required to req.get'); + } + + if (typeof name !== 'string') { + throw new TypeError('name must be a string to req.get'); + } + + var lc = name.toLowerCase(); + + switch (lc) { + case 'referer': + case 'referrer': + return this.headers.referrer + || this.headers.referer; + default: + return this.headers[lc]; + } +}; + +/** + * To do: update docs. + * + * Check if the given `type(s)` is acceptable, returning + * the best match when true, otherwise `undefined`, in which + * case you should respond with 406 "Not Acceptable". + * + * The `type` value may be a single MIME type string + * such as "application/json", an extension name + * such as "json", a comma-delimited list such as "json, html, text/plain", + * an argument list such as `"json", "html", "text/plain"`, + * or an array `["json", "html", "text/plain"]`. When a list + * or array is given, the _best_ match, if any is returned. + * + * Examples: + * + * // Accept: text/html + * req.accepts('html'); + * // => "html" + * + * // Accept: text/*, application/json + * req.accepts('html'); + * // => "html" + * req.accepts('text/html'); + * // => "text/html" + * req.accepts('json, text'); + * // => "json" + * req.accepts('application/json'); + * // => "application/json" + * + * // Accept: text/*, application/json + * req.accepts('image/png'); + * req.accepts('png'); + * // => undefined + * + * // Accept: text/*;q=.5, application/json + * req.accepts(['html', 'json']); + * req.accepts('html', 'json'); + * req.accepts('html, json'); + * // => "json" + * + * @param {String|Array} type(s) + * @return {String|Array|Boolean} + * @public + */ + +req.accepts = function(){ + var accept = accepts(this); + return accept.types.apply(accept, arguments); +}; + +/** + * Check if the given `encoding`s are accepted. + * + * @param {String} ...encoding + * @return {String|Array} + * @public + */ + +req.acceptsEncodings = function(){ + var accept = accepts(this); + return accept.encodings.apply(accept, arguments); +}; + +req.acceptsEncoding = deprecate.function(req.acceptsEncodings, + 'req.acceptsEncoding: Use acceptsEncodings instead'); + +/** + * Check if the given `charset`s are acceptable, + * otherwise you should respond with 406 "Not Acceptable". + * + * @param {String} ...charset + * @return {String|Array} + * @public + */ + +req.acceptsCharsets = function(){ + var accept = accepts(this); + return accept.charsets.apply(accept, arguments); +}; + +req.acceptsCharset = deprecate.function(req.acceptsCharsets, + 'req.acceptsCharset: Use acceptsCharsets instead'); + +/** + * Check if the given `lang`s are acceptable, + * otherwise you should respond with 406 "Not Acceptable". + * + * @param {String} ...lang + * @return {String|Array} + * @public + */ + +req.acceptsLanguages = function(){ + var accept = accepts(this); + return accept.languages.apply(accept, arguments); +}; + +req.acceptsLanguage = deprecate.function(req.acceptsLanguages, + 'req.acceptsLanguage: Use acceptsLanguages instead'); + +/** + * Parse Range header field, capping to the given `size`. + * + * Unspecified ranges such as "0-" require knowledge of your resource length. In + * the case of a byte range this is of course the total number of bytes. If the + * Range header field is not given `undefined` is returned, `-1` when unsatisfiable, + * and `-2` when syntactically invalid. + * + * When ranges are returned, the array has a "type" property which is the type of + * range that is required (most commonly, "bytes"). Each array element is an object + * with a "start" and "end" property for the portion of the range. + * + * The "combine" option can be set to `true` and overlapping & adjacent ranges + * will be combined into a single range. + * + * NOTE: remember that ranges are inclusive, so for example "Range: users=0-3" + * should respond with 4 users when available, not 3. + * + * @param {number} size + * @param {object} [options] + * @param {boolean} [options.combine=false] + * @return {number|array} + * @public + */ + +req.range = function range(size, options) { + var range = this.get('Range'); + if (!range) return; + return parseRange(size, range, options); +}; + +/** + * Return the value of param `name` when present or `defaultValue`. + * + * - Checks route placeholders, ex: _/user/:id_ + * - Checks body params, ex: id=12, {"id":12} + * - Checks query string params, ex: ?id=12 + * + * To utilize request bodies, `req.body` + * should be an object. This can be done by using + * the `bodyParser()` middleware. + * + * @param {String} name + * @param {Mixed} [defaultValue] + * @return {String} + * @public + */ + +req.param = function param(name, defaultValue) { + var params = this.params || {}; + var body = this.body || {}; + var query = this.query || {}; + + var args = arguments.length === 1 + ? 'name' + : 'name, default'; + deprecate('req.param(' + args + '): Use req.params, req.body, or req.query instead'); + + if (null != params[name] && params.hasOwnProperty(name)) return params[name]; + if (null != body[name]) return body[name]; + if (null != query[name]) return query[name]; + + return defaultValue; +}; + +/** + * Check if the incoming request contains the "Content-Type" + * header field, and it contains the give mime `type`. + * + * Examples: + * + * // With Content-Type: text/html; charset=utf-8 + * req.is('html'); + * req.is('text/html'); + * req.is('text/*'); + * // => true + * + * // When Content-Type is application/json + * req.is('json'); + * req.is('application/json'); + * req.is('application/*'); + * // => true + * + * req.is('html'); + * // => false + * + * @param {String|Array} types... + * @return {String|false|null} + * @public + */ + +req.is = function is(types) { + var arr = types; + + // support flattened arguments + if (!Array.isArray(types)) { + arr = new Array(arguments.length); + for (var i = 0; i < arr.length; i++) { + arr[i] = arguments[i]; + } + } + + return typeis(this, arr); +}; + +/** + * Return the protocol string "http" or "https" + * when requested with TLS. When the "trust proxy" + * setting trusts the socket address, the + * "X-Forwarded-Proto" header field will be trusted + * and used if present. + * + * If you're running behind a reverse proxy that + * supplies https for you this may be enabled. + * + * @return {String} + * @public + */ + +defineGetter(req, 'protocol', function protocol(){ + var proto = this.connection.encrypted + ? 'https' + : 'http'; + var trust = this.app.get('trust proxy fn'); + + if (!trust(this.connection.remoteAddress, 0)) { + return proto; + } + + // Note: X-Forwarded-Proto is normally only ever a + // single value, but this is to be safe. + proto = this.get('X-Forwarded-Proto') || proto; + return proto.split(/\s*,\s*/)[0]; +}); + +/** + * Short-hand for: + * + * req.protocol === 'https' + * + * @return {Boolean} + * @public + */ + +defineGetter(req, 'secure', function secure(){ + return this.protocol === 'https'; +}); + +/** + * Return the remote address from the trusted proxy. + * + * The is the remote address on the socket unless + * "trust proxy" is set. + * + * @return {String} + * @public + */ + +defineGetter(req, 'ip', function ip(){ + var trust = this.app.get('trust proxy fn'); + return proxyaddr(this, trust); +}); + +/** + * When "trust proxy" is set, trusted proxy addresses + client. + * + * For example if the value were "client, proxy1, proxy2" + * you would receive the array `["client", "proxy1", "proxy2"]` + * where "proxy2" is the furthest down-stream and "proxy1" and + * "proxy2" were trusted. + * + * @return {Array} + * @public + */ + +defineGetter(req, 'ips', function ips() { + var trust = this.app.get('trust proxy fn'); + var addrs = proxyaddr.all(this, trust); + return addrs.slice(1).reverse(); +}); + +/** + * Return subdomains as an array. + * + * Subdomains are the dot-separated parts of the host before the main domain of + * the app. By default, the domain of the app is assumed to be the last two + * parts of the host. This can be changed by setting "subdomain offset". + * + * For example, if the domain is "tobi.ferrets.example.com": + * If "subdomain offset" is not set, req.subdomains is `["ferrets", "tobi"]`. + * If "subdomain offset" is 3, req.subdomains is `["tobi"]`. + * + * @return {Array} + * @public + */ + +defineGetter(req, 'subdomains', function subdomains() { + var hostname = this.hostname; + + if (!hostname) return []; + + var offset = this.app.get('subdomain offset'); + var subdomains = !isIP(hostname) + ? hostname.split('.').reverse() + : [hostname]; + + return subdomains.slice(offset); +}); + +/** + * Short-hand for `url.parse(req.url).pathname`. + * + * @return {String} + * @public + */ + +defineGetter(req, 'path', function path() { + return parse(this).pathname; +}); + +/** + * Parse the "Host" header field to a hostname. + * + * When the "trust proxy" setting trusts the socket + * address, the "X-Forwarded-Host" header field will + * be trusted. + * + * @return {String} + * @public + */ + +defineGetter(req, 'hostname', function hostname(){ + var trust = this.app.get('trust proxy fn'); + var host = this.get('X-Forwarded-Host'); + + if (!host || !trust(this.connection.remoteAddress, 0)) { + host = this.get('Host'); + } + + if (!host) return; + + // IPv6 literal support + var offset = host[0] === '[' + ? host.indexOf(']') + 1 + : 0; + var index = host.indexOf(':', offset); + + return index !== -1 + ? host.substring(0, index) + : host; +}); + +// TODO: change req.host to return host in next major + +defineGetter(req, 'host', deprecate.function(function host(){ + return this.hostname; +}, 'req.host: Use req.hostname instead')); + +/** + * Check if the request is fresh, aka + * Last-Modified and/or the ETag + * still match. + * + * @return {Boolean} + * @public + */ + +defineGetter(req, 'fresh', function(){ + var method = this.method; + var s = this.res.statusCode; + + // GET or HEAD for weak freshness validation only + if ('GET' !== method && 'HEAD' !== method) return false; + + // 2xx or 304 as per rfc2616 14.26 + if ((s >= 200 && s < 300) || 304 === s) { + return fresh(this.headers, (this.res._headers || {})); + } + + return false; +}); + +/** + * Check if the request is stale, aka + * "Last-Modified" and / or the "ETag" for the + * resource has changed. + * + * @return {Boolean} + * @public + */ + +defineGetter(req, 'stale', function stale(){ + return !this.fresh; +}); + +/** + * Check if the request was an _XMLHttpRequest_. + * + * @return {Boolean} + * @public + */ + +defineGetter(req, 'xhr', function xhr(){ + var val = this.get('X-Requested-With') || ''; + return val.toLowerCase() === 'xmlhttprequest'; +}); + +/** + * Helper function for creating a getter on an object. + * + * @param {Object} obj + * @param {String} name + * @param {Function} getter + * @private + */ +function defineGetter(obj, name, getter) { + Object.defineProperty(obj, name, { + configurable: true, + enumerable: true, + get: getter + }); +}; diff --git a/ui/node_modules/express/lib/response.js b/ui/node_modules/express/lib/response.js index db5c9945..6128f450 100644 --- a/ui/node_modules/express/lib/response.js +++ b/ui/node_modules/express/lib/response.js @@ -1,1065 +1,1065 @@ -/*! - * express - * Copyright(c) 2009-2013 TJ Holowaychuk - * Copyright(c) 2014-2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict'; - -/** - * Module dependencies. - * @private - */ - -var contentDisposition = require('content-disposition'); -var deprecate = require('depd')('express'); -var encodeUrl = require('encodeurl'); -var escapeHtml = require('escape-html'); -var http = require('http'); -var isAbsolute = require('./utils').isAbsolute; -var onFinished = require('on-finished'); -var path = require('path'); -var merge = require('utils-merge'); -var sign = require('cookie-signature').sign; -var normalizeType = require('./utils').normalizeType; -var normalizeTypes = require('./utils').normalizeTypes; -var setCharset = require('./utils').setCharset; -var statusCodes = http.STATUS_CODES; -var cookie = require('cookie'); -var send = require('send'); -var extname = path.extname; -var mime = send.mime; -var resolve = path.resolve; -var vary = require('vary'); - -/** - * Response prototype. - */ - -var res = module.exports = { - __proto__: http.ServerResponse.prototype -}; - -/** - * Module variables. - * @private - */ - -var charsetRegExp = /;\s*charset\s*=/; - -/** - * Set status `code`. - * - * @param {Number} code - * @return {ServerResponse} - * @public - */ - -res.status = function status(code) { - this.statusCode = code; - return this; -}; - -/** - * Set Link header field with the given `links`. - * - * Examples: - * - * res.links({ - * next: 'http://api.example.com/users?page=2', - * last: 'http://api.example.com/users?page=5' - * }); - * - * @param {Object} links - * @return {ServerResponse} - * @public - */ - -res.links = function(links){ - var link = this.get('Link') || ''; - if (link) link += ', '; - return this.set('Link', link + Object.keys(links).map(function(rel){ - return '<' + links[rel] + '>; rel="' + rel + '"'; - }).join(', ')); -}; - -/** - * Send a response. - * - * Examples: - * - * res.send(new Buffer('wahoo')); - * res.send({ some: 'json' }); - * res.send('

some html

'); - * - * @param {string|number|boolean|object|Buffer} body - * @public - */ - -res.send = function send(body) { - var chunk = body; - var encoding; - var len; - var req = this.req; - var type; - - // settings - var app = this.app; - - // allow status / body - if (arguments.length === 2) { - // res.send(body, status) backwards compat - if (typeof arguments[0] !== 'number' && typeof arguments[1] === 'number') { - deprecate('res.send(body, status): Use res.status(status).send(body) instead'); - this.statusCode = arguments[1]; - } else { - deprecate('res.send(status, body): Use res.status(status).send(body) instead'); - this.statusCode = arguments[0]; - chunk = arguments[1]; - } - } - - // disambiguate res.send(status) and res.send(status, num) - if (typeof chunk === 'number' && arguments.length === 1) { - // res.send(status) will set status message as text string - if (!this.get('Content-Type')) { - this.type('txt'); - } - - deprecate('res.send(status): Use res.sendStatus(status) instead'); - this.statusCode = chunk; - chunk = statusCodes[chunk]; - } - - switch (typeof chunk) { - // string defaulting to html - case 'string': - if (!this.get('Content-Type')) { - this.type('html'); - } - break; - case 'boolean': - case 'number': - case 'object': - if (chunk === null) { - chunk = ''; - } else if (Buffer.isBuffer(chunk)) { - if (!this.get('Content-Type')) { - this.type('bin'); - } - } else { - return this.json(chunk); - } - break; - } - - // write strings in utf-8 - if (typeof chunk === 'string') { - encoding = 'utf8'; - type = this.get('Content-Type'); - - // reflect this in content-type - if (typeof type === 'string') { - this.set('Content-Type', setCharset(type, 'utf-8')); - } - } - - // populate Content-Length - if (chunk !== undefined) { - if (!Buffer.isBuffer(chunk)) { - // convert chunk to Buffer; saves later double conversions - chunk = new Buffer(chunk, encoding); - encoding = undefined; - } - - len = chunk.length; - this.set('Content-Length', len); - } - - // populate ETag - var etag; - var generateETag = len !== undefined && app.get('etag fn'); - if (typeof generateETag === 'function' && !this.get('ETag')) { - if ((etag = generateETag(chunk, encoding))) { - this.set('ETag', etag); - } - } - - // freshness - if (req.fresh) this.statusCode = 304; - - // strip irrelevant headers - if (204 === this.statusCode || 304 === this.statusCode) { - this.removeHeader('Content-Type'); - this.removeHeader('Content-Length'); - this.removeHeader('Transfer-Encoding'); - chunk = ''; - } - - if (req.method === 'HEAD') { - // skip body for HEAD - this.end(); - } else { - // respond - this.end(chunk, encoding); - } - - return this; -}; - -/** - * Send JSON response. - * - * Examples: - * - * res.json(null); - * res.json({ user: 'tj' }); - * - * @param {string|number|boolean|object} obj - * @public - */ - -res.json = function json(obj) { - var val = obj; - - // allow status / body - if (arguments.length === 2) { - // res.json(body, status) backwards compat - if (typeof arguments[1] === 'number') { - deprecate('res.json(obj, status): Use res.status(status).json(obj) instead'); - this.statusCode = arguments[1]; - } else { - deprecate('res.json(status, obj): Use res.status(status).json(obj) instead'); - this.statusCode = arguments[0]; - val = arguments[1]; - } - } - - // settings - var app = this.app; - var replacer = app.get('json replacer'); - var spaces = app.get('json spaces'); - var body = stringify(val, replacer, spaces); - - // content-type - if (!this.get('Content-Type')) { - this.set('Content-Type', 'application/json'); - } - - return this.send(body); -}; - -/** - * Send JSON response with JSONP callback support. - * - * Examples: - * - * res.jsonp(null); - * res.jsonp({ user: 'tj' }); - * - * @param {string|number|boolean|object} obj - * @public - */ - -res.jsonp = function jsonp(obj) { - var val = obj; - - // allow status / body - if (arguments.length === 2) { - // res.json(body, status) backwards compat - if (typeof arguments[1] === 'number') { - deprecate('res.jsonp(obj, status): Use res.status(status).json(obj) instead'); - this.statusCode = arguments[1]; - } else { - deprecate('res.jsonp(status, obj): Use res.status(status).jsonp(obj) instead'); - this.statusCode = arguments[0]; - val = arguments[1]; - } - } - - // settings - var app = this.app; - var replacer = app.get('json replacer'); - var spaces = app.get('json spaces'); - var body = stringify(val, replacer, spaces); - var callback = this.req.query[app.get('jsonp callback name')]; - - // content-type - if (!this.get('Content-Type')) { - this.set('X-Content-Type-Options', 'nosniff'); - this.set('Content-Type', 'application/json'); - } - - // fixup callback - if (Array.isArray(callback)) { - callback = callback[0]; - } - - // jsonp - if (typeof callback === 'string' && callback.length !== 0) { - this.charset = 'utf-8'; - this.set('X-Content-Type-Options', 'nosniff'); - this.set('Content-Type', 'text/javascript'); - - // restrict callback charset - callback = callback.replace(/[^\[\]\w$.]/g, ''); - - // replace chars not allowed in JavaScript that are in JSON - body = body - .replace(/\u2028/g, '\\u2028') - .replace(/\u2029/g, '\\u2029'); - - // the /**/ is a specific security mitigation for "Rosetta Flash JSONP abuse" - // the typeof check is just to reduce client error noise - body = '/**/ typeof ' + callback + ' === \'function\' && ' + callback + '(' + body + ');'; - } - - return this.send(body); -}; - -/** - * Send given HTTP status code. - * - * Sets the response status to `statusCode` and the body of the - * response to the standard description from node's http.STATUS_CODES - * or the statusCode number if no description. - * - * Examples: - * - * res.sendStatus(200); - * - * @param {number} statusCode - * @public - */ - -res.sendStatus = function sendStatus(statusCode) { - var body = statusCodes[statusCode] || String(statusCode); - - this.statusCode = statusCode; - this.type('txt'); - - return this.send(body); -}; - -/** - * Transfer the file at the given `path`. - * - * Automatically sets the _Content-Type_ response header field. - * The callback `callback(err)` is invoked when the transfer is complete - * or when an error occurs. Be sure to check `res.sentHeader` - * if you wish to attempt responding, as the header and some data - * may have already been transferred. - * - * Options: - * - * - `maxAge` defaulting to 0 (can be string converted by `ms`) - * - `root` root directory for relative filenames - * - `headers` object of headers to serve with file - * - `dotfiles` serve dotfiles, defaulting to false; can be `"allow"` to send them - * - * Other options are passed along to `send`. - * - * Examples: - * - * The following example illustrates how `res.sendFile()` may - * be used as an alternative for the `static()` middleware for - * dynamic situations. The code backing `res.sendFile()` is actually - * the same code, so HTTP cache support etc is identical. - * - * app.get('/user/:uid/photos/:file', function(req, res){ - * var uid = req.params.uid - * , file = req.params.file; - * - * req.user.mayViewFilesFrom(uid, function(yes){ - * if (yes) { - * res.sendFile('/uploads/' + uid + '/' + file); - * } else { - * res.send(403, 'Sorry! you cant see that.'); - * } - * }); - * }); - * - * @public - */ - -res.sendFile = function sendFile(path, options, callback) { - var done = callback; - var req = this.req; - var res = this; - var next = req.next; - var opts = options || {}; - - if (!path) { - throw new TypeError('path argument is required to res.sendFile'); - } - - // support function as second arg - if (typeof options === 'function') { - done = options; - opts = {}; - } - - if (!opts.root && !isAbsolute(path)) { - throw new TypeError('path must be absolute or specify root to res.sendFile'); - } - - // create file stream - var pathname = encodeURI(path); - var file = send(req, pathname, opts); - - // transfer - sendfile(res, file, opts, function (err) { - if (done) return done(err); - if (err && err.code === 'EISDIR') return next(); - - // next() all but write errors - if (err && err.code !== 'ECONNABORTED' && err.syscall !== 'write') { - next(err); - } - }); -}; - -/** - * Transfer the file at the given `path`. - * - * Automatically sets the _Content-Type_ response header field. - * The callback `callback(err)` is invoked when the transfer is complete - * or when an error occurs. Be sure to check `res.sentHeader` - * if you wish to attempt responding, as the header and some data - * may have already been transferred. - * - * Options: - * - * - `maxAge` defaulting to 0 (can be string converted by `ms`) - * - `root` root directory for relative filenames - * - `headers` object of headers to serve with file - * - `dotfiles` serve dotfiles, defaulting to false; can be `"allow"` to send them - * - * Other options are passed along to `send`. - * - * Examples: - * - * The following example illustrates how `res.sendfile()` may - * be used as an alternative for the `static()` middleware for - * dynamic situations. The code backing `res.sendfile()` is actually - * the same code, so HTTP cache support etc is identical. - * - * app.get('/user/:uid/photos/:file', function(req, res){ - * var uid = req.params.uid - * , file = req.params.file; - * - * req.user.mayViewFilesFrom(uid, function(yes){ - * if (yes) { - * res.sendfile('/uploads/' + uid + '/' + file); - * } else { - * res.send(403, 'Sorry! you cant see that.'); - * } - * }); - * }); - * - * @public - */ - -res.sendfile = function (path, options, callback) { - var done = callback; - var req = this.req; - var res = this; - var next = req.next; - var opts = options || {}; - - // support function as second arg - if (typeof options === 'function') { - done = options; - opts = {}; - } - - // create file stream - var file = send(req, path, opts); - - // transfer - sendfile(res, file, opts, function (err) { - if (done) return done(err); - if (err && err.code === 'EISDIR') return next(); - - // next() all but write errors - if (err && err.code !== 'ECONNABORT' && err.syscall !== 'write') { - next(err); - } - }); -}; - -res.sendfile = deprecate.function(res.sendfile, - 'res.sendfile: Use res.sendFile instead'); - -/** - * Transfer the file at the given `path` as an attachment. - * - * Optionally providing an alternate attachment `filename`, - * and optional callback `callback(err)`. The callback is invoked - * when the data transfer is complete, or when an error has - * ocurred. Be sure to check `res.headersSent` if you plan to respond. - * - * This method uses `res.sendfile()`. - * - * @public - */ - -res.download = function download(path, filename, callback) { - var done = callback; - var name = filename; - - // support function as second arg - if (typeof filename === 'function') { - done = filename; - name = null; - } - - // set Content-Disposition when file is sent - var headers = { - 'Content-Disposition': contentDisposition(name || path) - }; - - // Resolve the full path for sendFile - var fullPath = resolve(path); - - return this.sendFile(fullPath, { headers: headers }, done); -}; - -/** - * Set _Content-Type_ response header with `type` through `mime.lookup()` - * when it does not contain "/", or set the Content-Type to `type` otherwise. - * - * Examples: - * - * res.type('.html'); - * res.type('html'); - * res.type('json'); - * res.type('application/json'); - * res.type('png'); - * - * @param {String} type - * @return {ServerResponse} for chaining - * @public - */ - -res.contentType = -res.type = function contentType(type) { - var ct = type.indexOf('/') === -1 - ? mime.lookup(type) - : type; - - return this.set('Content-Type', ct); -}; - -/** - * Respond to the Acceptable formats using an `obj` - * of mime-type callbacks. - * - * This method uses `req.accepted`, an array of - * acceptable types ordered by their quality values. - * When "Accept" is not present the _first_ callback - * is invoked, otherwise the first match is used. When - * no match is performed the server responds with - * 406 "Not Acceptable". - * - * Content-Type is set for you, however if you choose - * you may alter this within the callback using `res.type()` - * or `res.set('Content-Type', ...)`. - * - * res.format({ - * 'text/plain': function(){ - * res.send('hey'); - * }, - * - * 'text/html': function(){ - * res.send('

hey

'); - * }, - * - * 'appliation/json': function(){ - * res.send({ message: 'hey' }); - * } - * }); - * - * In addition to canonicalized MIME types you may - * also use extnames mapped to these types: - * - * res.format({ - * text: function(){ - * res.send('hey'); - * }, - * - * html: function(){ - * res.send('

hey

'); - * }, - * - * json: function(){ - * res.send({ message: 'hey' }); - * } - * }); - * - * By default Express passes an `Error` - * with a `.status` of 406 to `next(err)` - * if a match is not made. If you provide - * a `.default` callback it will be invoked - * instead. - * - * @param {Object} obj - * @return {ServerResponse} for chaining - * @public - */ - -res.format = function(obj){ - var req = this.req; - var next = req.next; - - var fn = obj.default; - if (fn) delete obj.default; - var keys = Object.keys(obj); - - var key = keys.length > 0 - ? req.accepts(keys) - : false; - - this.vary("Accept"); - - if (key) { - this.set('Content-Type', normalizeType(key).value); - obj[key](req, this, next); - } else if (fn) { - fn(); - } else { - var err = new Error('Not Acceptable'); - err.status = err.statusCode = 406; - err.types = normalizeTypes(keys).map(function(o){ return o.value }); - next(err); - } - - return this; -}; - -/** - * Set _Content-Disposition_ header to _attachment_ with optional `filename`. - * - * @param {String} filename - * @return {ServerResponse} - * @public - */ - -res.attachment = function attachment(filename) { - if (filename) { - this.type(extname(filename)); - } - - this.set('Content-Disposition', contentDisposition(filename)); - - return this; -}; - -/** - * Append additional header `field` with value `val`. - * - * Example: - * - * res.append('Link', ['', '']); - * res.append('Set-Cookie', 'foo=bar; Path=/; HttpOnly'); - * res.append('Warning', '199 Miscellaneous warning'); - * - * @param {String} field - * @param {String|Array} val - * @return {ServerResponse} for chaining - * @public - */ - -res.append = function append(field, val) { - var prev = this.get(field); - var value = val; - - if (prev) { - // concat the new and prev vals - value = Array.isArray(prev) ? prev.concat(val) - : Array.isArray(val) ? [prev].concat(val) - : [prev, val]; - } - - return this.set(field, value); -}; - -/** - * Set header `field` to `val`, or pass - * an object of header fields. - * - * Examples: - * - * res.set('Foo', ['bar', 'baz']); - * res.set('Accept', 'application/json'); - * res.set({ Accept: 'text/plain', 'X-API-Key': 'tobi' }); - * - * Aliased as `res.header()`. - * - * @param {String|Object} field - * @param {String|Array} val - * @return {ServerResponse} for chaining - * @public - */ - -res.set = -res.header = function header(field, val) { - if (arguments.length === 2) { - var value = Array.isArray(val) - ? val.map(String) - : String(val); - - // add charset to content-type - if (field.toLowerCase() === 'content-type' && !charsetRegExp.test(value)) { - var charset = mime.charsets.lookup(value.split(';')[0]); - if (charset) value += '; charset=' + charset.toLowerCase(); - } - - this.setHeader(field, value); - } else { - for (var key in field) { - this.set(key, field[key]); - } - } - return this; -}; - -/** - * Get value for header `field`. - * - * @param {String} field - * @return {String} - * @public - */ - -res.get = function(field){ - return this.getHeader(field); -}; - -/** - * Clear cookie `name`. - * - * @param {String} name - * @param {Object} [options] - * @return {ServerResponse} for chaining - * @public - */ - -res.clearCookie = function clearCookie(name, options) { - var opts = merge({ expires: new Date(1), path: '/' }, options); - - return this.cookie(name, '', opts); -}; - -/** - * Set cookie `name` to `value`, with the given `options`. - * - * Options: - * - * - `maxAge` max-age in milliseconds, converted to `expires` - * - `signed` sign the cookie - * - `path` defaults to "/" - * - * Examples: - * - * // "Remember Me" for 15 minutes - * res.cookie('rememberme', '1', { expires: new Date(Date.now() + 900000), httpOnly: true }); - * - * // save as above - * res.cookie('rememberme', '1', { maxAge: 900000, httpOnly: true }) - * - * @param {String} name - * @param {String|Object} value - * @param {Options} options - * @return {ServerResponse} for chaining - * @public - */ - -res.cookie = function (name, value, options) { - var opts = merge({}, options); - var secret = this.req.secret; - var signed = opts.signed; - - if (signed && !secret) { - throw new Error('cookieParser("secret") required for signed cookies'); - } - - var val = typeof value === 'object' - ? 'j:' + JSON.stringify(value) - : String(value); - - if (signed) { - val = 's:' + sign(val, secret); - } - - if ('maxAge' in opts) { - opts.expires = new Date(Date.now() + opts.maxAge); - opts.maxAge /= 1000; - } - - if (opts.path == null) { - opts.path = '/'; - } - - this.append('Set-Cookie', cookie.serialize(name, String(val), opts)); - - return this; -}; - -/** - * Set the location header to `url`. - * - * The given `url` can also be "back", which redirects - * to the _Referrer_ or _Referer_ headers or "/". - * - * Examples: - * - * res.location('/foo/bar').; - * res.location('http://example.com'); - * res.location('../login'); - * - * @param {String} url - * @return {ServerResponse} for chaining - * @public - */ - -res.location = function location(url) { - var loc = url; - - // "back" is an alias for the referrer - if (url === 'back') { - loc = this.req.get('Referrer') || '/'; - } - - // set location - return this.set('Location', encodeUrl(loc)); -}; - -/** - * Redirect to the given `url` with optional response `status` - * defaulting to 302. - * - * The resulting `url` is determined by `res.location()`, so - * it will play nicely with mounted apps, relative paths, - * `"back"` etc. - * - * Examples: - * - * res.redirect('/foo/bar'); - * res.redirect('http://example.com'); - * res.redirect(301, 'http://example.com'); - * res.redirect('../login'); // /blog/post/1 -> /blog/login - * - * @public - */ - -res.redirect = function redirect(url) { - var address = url; - var body; - var status = 302; - - // allow status / url - if (arguments.length === 2) { - if (typeof arguments[0] === 'number') { - status = arguments[0]; - address = arguments[1]; - } else { - deprecate('res.redirect(url, status): Use res.redirect(status, url) instead'); - status = arguments[1]; - } - } - - // Set location header - address = this.location(address).get('Location'); - - // Support text/{plain,html} by default - this.format({ - text: function(){ - body = statusCodes[status] + '. Redirecting to ' + address; - }, - - html: function(){ - var u = escapeHtml(address); - body = '

' + statusCodes[status] + '. Redirecting to ' + u + '

'; - }, - - default: function(){ - body = ''; - } - }); - - // Respond - this.statusCode = status; - this.set('Content-Length', Buffer.byteLength(body)); - - if (this.req.method === 'HEAD') { - this.end(); - } else { - this.end(body); - } -}; - -/** - * Add `field` to Vary. If already present in the Vary set, then - * this call is simply ignored. - * - * @param {Array|String} field - * @return {ServerResponse} for chaining - * @public - */ - -res.vary = function(field){ - // checks for back-compat - if (!field || (Array.isArray(field) && !field.length)) { - deprecate('res.vary(): Provide a field name'); - return this; - } - - vary(this, field); - - return this; -}; - -/** - * Render `view` with the given `options` and optional callback `fn`. - * When a callback function is given a response will _not_ be made - * automatically, otherwise a response of _200_ and _text/html_ is given. - * - * Options: - * - * - `cache` boolean hinting to the engine it should cache - * - `filename` filename of the view being rendered - * - * @public - */ - -res.render = function render(view, options, callback) { - var app = this.req.app; - var done = callback; - var opts = options || {}; - var req = this.req; - var self = this; - - // support callback function as second arg - if (typeof options === 'function') { - done = options; - opts = {}; - } - - // merge res.locals - opts._locals = self.locals; - - // default callback to respond - done = done || function (err, str) { - if (err) return req.next(err); - self.send(str); - }; - - // render - app.render(view, opts, done); -}; - -// pipe the send file stream -function sendfile(res, file, options, callback) { - var done = false; - var streaming; - - // request aborted - function onaborted() { - if (done) return; - done = true; - - var err = new Error('Request aborted'); - err.code = 'ECONNABORTED'; - callback(err); - } - - // directory - function ondirectory() { - if (done) return; - done = true; - - var err = new Error('EISDIR, read'); - err.code = 'EISDIR'; - callback(err); - } - - // errors - function onerror(err) { - if (done) return; - done = true; - callback(err); - } - - // ended - function onend() { - if (done) return; - done = true; - callback(); - } - - // file - function onfile() { - streaming = false; - } - - // finished - function onfinish(err) { - if (err && err.code === 'ECONNRESET') return onaborted(); - if (err) return onerror(err); - if (done) return; - - setImmediate(function () { - if (streaming !== false && !done) { - onaborted(); - return; - } - - if (done) return; - done = true; - callback(); - }); - } - - // streaming - function onstream() { - streaming = true; - } - - file.on('directory', ondirectory); - file.on('end', onend); - file.on('error', onerror); - file.on('file', onfile); - file.on('stream', onstream); - onFinished(res, onfinish); - - if (options.headers) { - // set headers on successful transfer - file.on('headers', function headers(res) { - var obj = options.headers; - var keys = Object.keys(obj); - - for (var i = 0; i < keys.length; i++) { - var k = keys[i]; - res.setHeader(k, obj[k]); - } - }); - } - - // pipe - file.pipe(res); -} - -/** - * Stringify JSON, like JSON.stringify, but v8 optimized. - * @private - */ - -function stringify(value, replacer, spaces) { - // v8 checks arguments.length for optimizing simple call - // https://bugs.chromium.org/p/v8/issues/detail?id=4730 - return replacer || spaces - ? JSON.stringify(value, replacer, spaces) - : JSON.stringify(value); -} +/*! + * express + * Copyright(c) 2009-2013 TJ Holowaychuk + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict'; + +/** + * Module dependencies. + * @private + */ + +var contentDisposition = require('content-disposition'); +var deprecate = require('depd')('express'); +var encodeUrl = require('encodeurl'); +var escapeHtml = require('escape-html'); +var http = require('http'); +var isAbsolute = require('./utils').isAbsolute; +var onFinished = require('on-finished'); +var path = require('path'); +var merge = require('utils-merge'); +var sign = require('cookie-signature').sign; +var normalizeType = require('./utils').normalizeType; +var normalizeTypes = require('./utils').normalizeTypes; +var setCharset = require('./utils').setCharset; +var statusCodes = http.STATUS_CODES; +var cookie = require('cookie'); +var send = require('send'); +var extname = path.extname; +var mime = send.mime; +var resolve = path.resolve; +var vary = require('vary'); + +/** + * Response prototype. + */ + +var res = module.exports = { + __proto__: http.ServerResponse.prototype +}; + +/** + * Module variables. + * @private + */ + +var charsetRegExp = /;\s*charset\s*=/; + +/** + * Set status `code`. + * + * @param {Number} code + * @return {ServerResponse} + * @public + */ + +res.status = function status(code) { + this.statusCode = code; + return this; +}; + +/** + * Set Link header field with the given `links`. + * + * Examples: + * + * res.links({ + * next: 'http://api.example.com/users?page=2', + * last: 'http://api.example.com/users?page=5' + * }); + * + * @param {Object} links + * @return {ServerResponse} + * @public + */ + +res.links = function(links){ + var link = this.get('Link') || ''; + if (link) link += ', '; + return this.set('Link', link + Object.keys(links).map(function(rel){ + return '<' + links[rel] + '>; rel="' + rel + '"'; + }).join(', ')); +}; + +/** + * Send a response. + * + * Examples: + * + * res.send(new Buffer('wahoo')); + * res.send({ some: 'json' }); + * res.send('

some html

'); + * + * @param {string|number|boolean|object|Buffer} body + * @public + */ + +res.send = function send(body) { + var chunk = body; + var encoding; + var len; + var req = this.req; + var type; + + // settings + var app = this.app; + + // allow status / body + if (arguments.length === 2) { + // res.send(body, status) backwards compat + if (typeof arguments[0] !== 'number' && typeof arguments[1] === 'number') { + deprecate('res.send(body, status): Use res.status(status).send(body) instead'); + this.statusCode = arguments[1]; + } else { + deprecate('res.send(status, body): Use res.status(status).send(body) instead'); + this.statusCode = arguments[0]; + chunk = arguments[1]; + } + } + + // disambiguate res.send(status) and res.send(status, num) + if (typeof chunk === 'number' && arguments.length === 1) { + // res.send(status) will set status message as text string + if (!this.get('Content-Type')) { + this.type('txt'); + } + + deprecate('res.send(status): Use res.sendStatus(status) instead'); + this.statusCode = chunk; + chunk = statusCodes[chunk]; + } + + switch (typeof chunk) { + // string defaulting to html + case 'string': + if (!this.get('Content-Type')) { + this.type('html'); + } + break; + case 'boolean': + case 'number': + case 'object': + if (chunk === null) { + chunk = ''; + } else if (Buffer.isBuffer(chunk)) { + if (!this.get('Content-Type')) { + this.type('bin'); + } + } else { + return this.json(chunk); + } + break; + } + + // write strings in utf-8 + if (typeof chunk === 'string') { + encoding = 'utf8'; + type = this.get('Content-Type'); + + // reflect this in content-type + if (typeof type === 'string') { + this.set('Content-Type', setCharset(type, 'utf-8')); + } + } + + // populate Content-Length + if (chunk !== undefined) { + if (!Buffer.isBuffer(chunk)) { + // convert chunk to Buffer; saves later double conversions + chunk = new Buffer(chunk, encoding); + encoding = undefined; + } + + len = chunk.length; + this.set('Content-Length', len); + } + + // populate ETag + var etag; + var generateETag = len !== undefined && app.get('etag fn'); + if (typeof generateETag === 'function' && !this.get('ETag')) { + if ((etag = generateETag(chunk, encoding))) { + this.set('ETag', etag); + } + } + + // freshness + if (req.fresh) this.statusCode = 304; + + // strip irrelevant headers + if (204 === this.statusCode || 304 === this.statusCode) { + this.removeHeader('Content-Type'); + this.removeHeader('Content-Length'); + this.removeHeader('Transfer-Encoding'); + chunk = ''; + } + + if (req.method === 'HEAD') { + // skip body for HEAD + this.end(); + } else { + // respond + this.end(chunk, encoding); + } + + return this; +}; + +/** + * Send JSON response. + * + * Examples: + * + * res.json(null); + * res.json({ user: 'tj' }); + * + * @param {string|number|boolean|object} obj + * @public + */ + +res.json = function json(obj) { + var val = obj; + + // allow status / body + if (arguments.length === 2) { + // res.json(body, status) backwards compat + if (typeof arguments[1] === 'number') { + deprecate('res.json(obj, status): Use res.status(status).json(obj) instead'); + this.statusCode = arguments[1]; + } else { + deprecate('res.json(status, obj): Use res.status(status).json(obj) instead'); + this.statusCode = arguments[0]; + val = arguments[1]; + } + } + + // settings + var app = this.app; + var replacer = app.get('json replacer'); + var spaces = app.get('json spaces'); + var body = stringify(val, replacer, spaces); + + // content-type + if (!this.get('Content-Type')) { + this.set('Content-Type', 'application/json'); + } + + return this.send(body); +}; + +/** + * Send JSON response with JSONP callback support. + * + * Examples: + * + * res.jsonp(null); + * res.jsonp({ user: 'tj' }); + * + * @param {string|number|boolean|object} obj + * @public + */ + +res.jsonp = function jsonp(obj) { + var val = obj; + + // allow status / body + if (arguments.length === 2) { + // res.json(body, status) backwards compat + if (typeof arguments[1] === 'number') { + deprecate('res.jsonp(obj, status): Use res.status(status).json(obj) instead'); + this.statusCode = arguments[1]; + } else { + deprecate('res.jsonp(status, obj): Use res.status(status).jsonp(obj) instead'); + this.statusCode = arguments[0]; + val = arguments[1]; + } + } + + // settings + var app = this.app; + var replacer = app.get('json replacer'); + var spaces = app.get('json spaces'); + var body = stringify(val, replacer, spaces); + var callback = this.req.query[app.get('jsonp callback name')]; + + // content-type + if (!this.get('Content-Type')) { + this.set('X-Content-Type-Options', 'nosniff'); + this.set('Content-Type', 'application/json'); + } + + // fixup callback + if (Array.isArray(callback)) { + callback = callback[0]; + } + + // jsonp + if (typeof callback === 'string' && callback.length !== 0) { + this.charset = 'utf-8'; + this.set('X-Content-Type-Options', 'nosniff'); + this.set('Content-Type', 'text/javascript'); + + // restrict callback charset + callback = callback.replace(/[^\[\]\w$.]/g, ''); + + // replace chars not allowed in JavaScript that are in JSON + body = body + .replace(/\u2028/g, '\\u2028') + .replace(/\u2029/g, '\\u2029'); + + // the /**/ is a specific security mitigation for "Rosetta Flash JSONP abuse" + // the typeof check is just to reduce client error noise + body = '/**/ typeof ' + callback + ' === \'function\' && ' + callback + '(' + body + ');'; + } + + return this.send(body); +}; + +/** + * Send given HTTP status code. + * + * Sets the response status to `statusCode` and the body of the + * response to the standard description from node's http.STATUS_CODES + * or the statusCode number if no description. + * + * Examples: + * + * res.sendStatus(200); + * + * @param {number} statusCode + * @public + */ + +res.sendStatus = function sendStatus(statusCode) { + var body = statusCodes[statusCode] || String(statusCode); + + this.statusCode = statusCode; + this.type('txt'); + + return this.send(body); +}; + +/** + * Transfer the file at the given `path`. + * + * Automatically sets the _Content-Type_ response header field. + * The callback `callback(err)` is invoked when the transfer is complete + * or when an error occurs. Be sure to check `res.sentHeader` + * if you wish to attempt responding, as the header and some data + * may have already been transferred. + * + * Options: + * + * - `maxAge` defaulting to 0 (can be string converted by `ms`) + * - `root` root directory for relative filenames + * - `headers` object of headers to serve with file + * - `dotfiles` serve dotfiles, defaulting to false; can be `"allow"` to send them + * + * Other options are passed along to `send`. + * + * Examples: + * + * The following example illustrates how `res.sendFile()` may + * be used as an alternative for the `static()` middleware for + * dynamic situations. The code backing `res.sendFile()` is actually + * the same code, so HTTP cache support etc is identical. + * + * app.get('/user/:uid/photos/:file', function(req, res){ + * var uid = req.params.uid + * , file = req.params.file; + * + * req.user.mayViewFilesFrom(uid, function(yes){ + * if (yes) { + * res.sendFile('/uploads/' + uid + '/' + file); + * } else { + * res.send(403, 'Sorry! you cant see that.'); + * } + * }); + * }); + * + * @public + */ + +res.sendFile = function sendFile(path, options, callback) { + var done = callback; + var req = this.req; + var res = this; + var next = req.next; + var opts = options || {}; + + if (!path) { + throw new TypeError('path argument is required to res.sendFile'); + } + + // support function as second arg + if (typeof options === 'function') { + done = options; + opts = {}; + } + + if (!opts.root && !isAbsolute(path)) { + throw new TypeError('path must be absolute or specify root to res.sendFile'); + } + + // create file stream + var pathname = encodeURI(path); + var file = send(req, pathname, opts); + + // transfer + sendfile(res, file, opts, function (err) { + if (done) return done(err); + if (err && err.code === 'EISDIR') return next(); + + // next() all but write errors + if (err && err.code !== 'ECONNABORTED' && err.syscall !== 'write') { + next(err); + } + }); +}; + +/** + * Transfer the file at the given `path`. + * + * Automatically sets the _Content-Type_ response header field. + * The callback `callback(err)` is invoked when the transfer is complete + * or when an error occurs. Be sure to check `res.sentHeader` + * if you wish to attempt responding, as the header and some data + * may have already been transferred. + * + * Options: + * + * - `maxAge` defaulting to 0 (can be string converted by `ms`) + * - `root` root directory for relative filenames + * - `headers` object of headers to serve with file + * - `dotfiles` serve dotfiles, defaulting to false; can be `"allow"` to send them + * + * Other options are passed along to `send`. + * + * Examples: + * + * The following example illustrates how `res.sendfile()` may + * be used as an alternative for the `static()` middleware for + * dynamic situations. The code backing `res.sendfile()` is actually + * the same code, so HTTP cache support etc is identical. + * + * app.get('/user/:uid/photos/:file', function(req, res){ + * var uid = req.params.uid + * , file = req.params.file; + * + * req.user.mayViewFilesFrom(uid, function(yes){ + * if (yes) { + * res.sendfile('/uploads/' + uid + '/' + file); + * } else { + * res.send(403, 'Sorry! you cant see that.'); + * } + * }); + * }); + * + * @public + */ + +res.sendfile = function (path, options, callback) { + var done = callback; + var req = this.req; + var res = this; + var next = req.next; + var opts = options || {}; + + // support function as second arg + if (typeof options === 'function') { + done = options; + opts = {}; + } + + // create file stream + var file = send(req, path, opts); + + // transfer + sendfile(res, file, opts, function (err) { + if (done) return done(err); + if (err && err.code === 'EISDIR') return next(); + + // next() all but write errors + if (err && err.code !== 'ECONNABORT' && err.syscall !== 'write') { + next(err); + } + }); +}; + +res.sendfile = deprecate.function(res.sendfile, + 'res.sendfile: Use res.sendFile instead'); + +/** + * Transfer the file at the given `path` as an attachment. + * + * Optionally providing an alternate attachment `filename`, + * and optional callback `callback(err)`. The callback is invoked + * when the data transfer is complete, or when an error has + * ocurred. Be sure to check `res.headersSent` if you plan to respond. + * + * This method uses `res.sendfile()`. + * + * @public + */ + +res.download = function download(path, filename, callback) { + var done = callback; + var name = filename; + + // support function as second arg + if (typeof filename === 'function') { + done = filename; + name = null; + } + + // set Content-Disposition when file is sent + var headers = { + 'Content-Disposition': contentDisposition(name || path) + }; + + // Resolve the full path for sendFile + var fullPath = resolve(path); + + return this.sendFile(fullPath, { headers: headers }, done); +}; + +/** + * Set _Content-Type_ response header with `type` through `mime.lookup()` + * when it does not contain "/", or set the Content-Type to `type` otherwise. + * + * Examples: + * + * res.type('.html'); + * res.type('html'); + * res.type('json'); + * res.type('application/json'); + * res.type('png'); + * + * @param {String} type + * @return {ServerResponse} for chaining + * @public + */ + +res.contentType = +res.type = function contentType(type) { + var ct = type.indexOf('/') === -1 + ? mime.lookup(type) + : type; + + return this.set('Content-Type', ct); +}; + +/** + * Respond to the Acceptable formats using an `obj` + * of mime-type callbacks. + * + * This method uses `req.accepted`, an array of + * acceptable types ordered by their quality values. + * When "Accept" is not present the _first_ callback + * is invoked, otherwise the first match is used. When + * no match is performed the server responds with + * 406 "Not Acceptable". + * + * Content-Type is set for you, however if you choose + * you may alter this within the callback using `res.type()` + * or `res.set('Content-Type', ...)`. + * + * res.format({ + * 'text/plain': function(){ + * res.send('hey'); + * }, + * + * 'text/html': function(){ + * res.send('

hey

'); + * }, + * + * 'appliation/json': function(){ + * res.send({ message: 'hey' }); + * } + * }); + * + * In addition to canonicalized MIME types you may + * also use extnames mapped to these types: + * + * res.format({ + * text: function(){ + * res.send('hey'); + * }, + * + * html: function(){ + * res.send('

hey

'); + * }, + * + * json: function(){ + * res.send({ message: 'hey' }); + * } + * }); + * + * By default Express passes an `Error` + * with a `.status` of 406 to `next(err)` + * if a match is not made. If you provide + * a `.default` callback it will be invoked + * instead. + * + * @param {Object} obj + * @return {ServerResponse} for chaining + * @public + */ + +res.format = function(obj){ + var req = this.req; + var next = req.next; + + var fn = obj.default; + if (fn) delete obj.default; + var keys = Object.keys(obj); + + var key = keys.length > 0 + ? req.accepts(keys) + : false; + + this.vary("Accept"); + + if (key) { + this.set('Content-Type', normalizeType(key).value); + obj[key](req, this, next); + } else if (fn) { + fn(); + } else { + var err = new Error('Not Acceptable'); + err.status = err.statusCode = 406; + err.types = normalizeTypes(keys).map(function(o){ return o.value }); + next(err); + } + + return this; +}; + +/** + * Set _Content-Disposition_ header to _attachment_ with optional `filename`. + * + * @param {String} filename + * @return {ServerResponse} + * @public + */ + +res.attachment = function attachment(filename) { + if (filename) { + this.type(extname(filename)); + } + + this.set('Content-Disposition', contentDisposition(filename)); + + return this; +}; + +/** + * Append additional header `field` with value `val`. + * + * Example: + * + * res.append('Link', ['', '']); + * res.append('Set-Cookie', 'foo=bar; Path=/; HttpOnly'); + * res.append('Warning', '199 Miscellaneous warning'); + * + * @param {String} field + * @param {String|Array} val + * @return {ServerResponse} for chaining + * @public + */ + +res.append = function append(field, val) { + var prev = this.get(field); + var value = val; + + if (prev) { + // concat the new and prev vals + value = Array.isArray(prev) ? prev.concat(val) + : Array.isArray(val) ? [prev].concat(val) + : [prev, val]; + } + + return this.set(field, value); +}; + +/** + * Set header `field` to `val`, or pass + * an object of header fields. + * + * Examples: + * + * res.set('Foo', ['bar', 'baz']); + * res.set('Accept', 'application/json'); + * res.set({ Accept: 'text/plain', 'X-API-Key': 'tobi' }); + * + * Aliased as `res.header()`. + * + * @param {String|Object} field + * @param {String|Array} val + * @return {ServerResponse} for chaining + * @public + */ + +res.set = +res.header = function header(field, val) { + if (arguments.length === 2) { + var value = Array.isArray(val) + ? val.map(String) + : String(val); + + // add charset to content-type + if (field.toLowerCase() === 'content-type' && !charsetRegExp.test(value)) { + var charset = mime.charsets.lookup(value.split(';')[0]); + if (charset) value += '; charset=' + charset.toLowerCase(); + } + + this.setHeader(field, value); + } else { + for (var key in field) { + this.set(key, field[key]); + } + } + return this; +}; + +/** + * Get value for header `field`. + * + * @param {String} field + * @return {String} + * @public + */ + +res.get = function(field){ + return this.getHeader(field); +}; + +/** + * Clear cookie `name`. + * + * @param {String} name + * @param {Object} [options] + * @return {ServerResponse} for chaining + * @public + */ + +res.clearCookie = function clearCookie(name, options) { + var opts = merge({ expires: new Date(1), path: '/' }, options); + + return this.cookie(name, '', opts); +}; + +/** + * Set cookie `name` to `value`, with the given `options`. + * + * Options: + * + * - `maxAge` max-age in milliseconds, converted to `expires` + * - `signed` sign the cookie + * - `path` defaults to "/" + * + * Examples: + * + * // "Remember Me" for 15 minutes + * res.cookie('rememberme', '1', { expires: new Date(Date.now() + 900000), httpOnly: true }); + * + * // save as above + * res.cookie('rememberme', '1', { maxAge: 900000, httpOnly: true }) + * + * @param {String} name + * @param {String|Object} value + * @param {Options} options + * @return {ServerResponse} for chaining + * @public + */ + +res.cookie = function (name, value, options) { + var opts = merge({}, options); + var secret = this.req.secret; + var signed = opts.signed; + + if (signed && !secret) { + throw new Error('cookieParser("secret") required for signed cookies'); + } + + var val = typeof value === 'object' + ? 'j:' + JSON.stringify(value) + : String(value); + + if (signed) { + val = 's:' + sign(val, secret); + } + + if ('maxAge' in opts) { + opts.expires = new Date(Date.now() + opts.maxAge); + opts.maxAge /= 1000; + } + + if (opts.path == null) { + opts.path = '/'; + } + + this.append('Set-Cookie', cookie.serialize(name, String(val), opts)); + + return this; +}; + +/** + * Set the location header to `url`. + * + * The given `url` can also be "back", which redirects + * to the _Referrer_ or _Referer_ headers or "/". + * + * Examples: + * + * res.location('/foo/bar').; + * res.location('http://example.com'); + * res.location('../login'); + * + * @param {String} url + * @return {ServerResponse} for chaining + * @public + */ + +res.location = function location(url) { + var loc = url; + + // "back" is an alias for the referrer + if (url === 'back') { + loc = this.req.get('Referrer') || '/'; + } + + // set location + return this.set('Location', encodeUrl(loc)); +}; + +/** + * Redirect to the given `url` with optional response `status` + * defaulting to 302. + * + * The resulting `url` is determined by `res.location()`, so + * it will play nicely with mounted apps, relative paths, + * `"back"` etc. + * + * Examples: + * + * res.redirect('/foo/bar'); + * res.redirect('http://example.com'); + * res.redirect(301, 'http://example.com'); + * res.redirect('../login'); // /blog/post/1 -> /blog/login + * + * @public + */ + +res.redirect = function redirect(url) { + var address = url; + var body; + var status = 302; + + // allow status / url + if (arguments.length === 2) { + if (typeof arguments[0] === 'number') { + status = arguments[0]; + address = arguments[1]; + } else { + deprecate('res.redirect(url, status): Use res.redirect(status, url) instead'); + status = arguments[1]; + } + } + + // Set location header + address = this.location(address).get('Location'); + + // Support text/{plain,html} by default + this.format({ + text: function(){ + body = statusCodes[status] + '. Redirecting to ' + address; + }, + + html: function(){ + var u = escapeHtml(address); + body = '

' + statusCodes[status] + '. Redirecting to ' + u + '

'; + }, + + default: function(){ + body = ''; + } + }); + + // Respond + this.statusCode = status; + this.set('Content-Length', Buffer.byteLength(body)); + + if (this.req.method === 'HEAD') { + this.end(); + } else { + this.end(body); + } +}; + +/** + * Add `field` to Vary. If already present in the Vary set, then + * this call is simply ignored. + * + * @param {Array|String} field + * @return {ServerResponse} for chaining + * @public + */ + +res.vary = function(field){ + // checks for back-compat + if (!field || (Array.isArray(field) && !field.length)) { + deprecate('res.vary(): Provide a field name'); + return this; + } + + vary(this, field); + + return this; +}; + +/** + * Render `view` with the given `options` and optional callback `fn`. + * When a callback function is given a response will _not_ be made + * automatically, otherwise a response of _200_ and _text/html_ is given. + * + * Options: + * + * - `cache` boolean hinting to the engine it should cache + * - `filename` filename of the view being rendered + * + * @public + */ + +res.render = function render(view, options, callback) { + var app = this.req.app; + var done = callback; + var opts = options || {}; + var req = this.req; + var self = this; + + // support callback function as second arg + if (typeof options === 'function') { + done = options; + opts = {}; + } + + // merge res.locals + opts._locals = self.locals; + + // default callback to respond + done = done || function (err, str) { + if (err) return req.next(err); + self.send(str); + }; + + // render + app.render(view, opts, done); +}; + +// pipe the send file stream +function sendfile(res, file, options, callback) { + var done = false; + var streaming; + + // request aborted + function onaborted() { + if (done) return; + done = true; + + var err = new Error('Request aborted'); + err.code = 'ECONNABORTED'; + callback(err); + } + + // directory + function ondirectory() { + if (done) return; + done = true; + + var err = new Error('EISDIR, read'); + err.code = 'EISDIR'; + callback(err); + } + + // errors + function onerror(err) { + if (done) return; + done = true; + callback(err); + } + + // ended + function onend() { + if (done) return; + done = true; + callback(); + } + + // file + function onfile() { + streaming = false; + } + + // finished + function onfinish(err) { + if (err && err.code === 'ECONNRESET') return onaborted(); + if (err) return onerror(err); + if (done) return; + + setImmediate(function () { + if (streaming !== false && !done) { + onaborted(); + return; + } + + if (done) return; + done = true; + callback(); + }); + } + + // streaming + function onstream() { + streaming = true; + } + + file.on('directory', ondirectory); + file.on('end', onend); + file.on('error', onerror); + file.on('file', onfile); + file.on('stream', onstream); + onFinished(res, onfinish); + + if (options.headers) { + // set headers on successful transfer + file.on('headers', function headers(res) { + var obj = options.headers; + var keys = Object.keys(obj); + + for (var i = 0; i < keys.length; i++) { + var k = keys[i]; + res.setHeader(k, obj[k]); + } + }); + } + + // pipe + file.pipe(res); +} + +/** + * Stringify JSON, like JSON.stringify, but v8 optimized. + * @private + */ + +function stringify(value, replacer, spaces) { + // v8 checks arguments.length for optimizing simple call + // https://bugs.chromium.org/p/v8/issues/detail?id=4730 + return replacer || spaces + ? JSON.stringify(value, replacer, spaces) + : JSON.stringify(value); +} diff --git a/ui/node_modules/express/lib/router/index.js b/ui/node_modules/express/lib/router/index.js index f7157fd8..dac25148 100644 --- a/ui/node_modules/express/lib/router/index.js +++ b/ui/node_modules/express/lib/router/index.js @@ -1,645 +1,645 @@ -/*! - * express - * Copyright(c) 2009-2013 TJ Holowaychuk - * Copyright(c) 2013 Roman Shtylman - * Copyright(c) 2014-2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict'; - -/** - * Module dependencies. - * @private - */ - -var Route = require('./route'); -var Layer = require('./layer'); -var methods = require('methods'); -var mixin = require('utils-merge'); -var debug = require('debug')('express:router'); -var deprecate = require('depd')('express'); -var flatten = require('array-flatten'); -var parseUrl = require('parseurl'); - -/** - * Module variables. - * @private - */ - -var objectRegExp = /^\[object (\S+)\]$/; -var slice = Array.prototype.slice; -var toString = Object.prototype.toString; - -/** - * Initialize a new `Router` with the given `options`. - * - * @param {Object} options - * @return {Router} which is an callable function - * @public - */ - -var proto = module.exports = function(options) { - var opts = options || {}; - - function router(req, res, next) { - router.handle(req, res, next); - } - - // mixin Router class functions - router.__proto__ = proto; - - router.params = {}; - router._params = []; - router.caseSensitive = opts.caseSensitive; - router.mergeParams = opts.mergeParams; - router.strict = opts.strict; - router.stack = []; - - return router; -}; - -/** - * Map the given param placeholder `name`(s) to the given callback. - * - * Parameter mapping is used to provide pre-conditions to routes - * which use normalized placeholders. For example a _:user_id_ parameter - * could automatically load a user's information from the database without - * any additional code, - * - * The callback uses the same signature as middleware, the only difference - * being that the value of the placeholder is passed, in this case the _id_ - * of the user. Once the `next()` function is invoked, just like middleware - * it will continue on to execute the route, or subsequent parameter functions. - * - * Just like in middleware, you must either respond to the request or call next - * to avoid stalling the request. - * - * app.param('user_id', function(req, res, next, id){ - * User.find(id, function(err, user){ - * if (err) { - * return next(err); - * } else if (!user) { - * return next(new Error('failed to load user')); - * } - * req.user = user; - * next(); - * }); - * }); - * - * @param {String} name - * @param {Function} fn - * @return {app} for chaining - * @public - */ - -proto.param = function param(name, fn) { - // param logic - if (typeof name === 'function') { - deprecate('router.param(fn): Refactor to use path params'); - this._params.push(name); - return; - } - - // apply param functions - var params = this._params; - var len = params.length; - var ret; - - if (name[0] === ':') { - deprecate('router.param(' + JSON.stringify(name) + ', fn): Use router.param(' + JSON.stringify(name.substr(1)) + ', fn) instead'); - name = name.substr(1); - } - - for (var i = 0; i < len; ++i) { - if (ret = params[i](name, fn)) { - fn = ret; - } - } - - // ensure we end up with a - // middleware function - if ('function' !== typeof fn) { - throw new Error('invalid param() call for ' + name + ', got ' + fn); - } - - (this.params[name] = this.params[name] || []).push(fn); - return this; -}; - -/** - * Dispatch a req, res into the router. - * @private - */ - -proto.handle = function handle(req, res, out) { - var self = this; - - debug('dispatching %s %s', req.method, req.url); - - var search = 1 + req.url.indexOf('?'); - var pathlength = search ? search - 1 : req.url.length; - var fqdn = req.url[0] !== '/' && 1 + req.url.substr(0, pathlength).indexOf('://'); - var protohost = fqdn ? req.url.substr(0, req.url.indexOf('/', 2 + fqdn)) : ''; - var idx = 0; - var removed = ''; - var slashAdded = false; - var paramcalled = {}; - - // store options for OPTIONS request - // only used if OPTIONS request - var options = []; - - // middleware and routes - var stack = self.stack; - - // manage inter-router variables - var parentParams = req.params; - var parentUrl = req.baseUrl || ''; - var done = restore(out, req, 'baseUrl', 'next', 'params'); - - // setup next layer - req.next = next; - - // for options requests, respond with a default if nothing else responds - if (req.method === 'OPTIONS') { - done = wrap(done, function(old, err) { - if (err || options.length === 0) return old(err); - sendOptionsResponse(res, options, old); - }); - } - - // setup basic req values - req.baseUrl = parentUrl; - req.originalUrl = req.originalUrl || req.url; - - next(); - - function next(err) { - var layerError = err === 'route' - ? null - : err; - - // remove added slash - if (slashAdded) { - req.url = req.url.substr(1); - slashAdded = false; - } - - // restore altered req.url - if (removed.length !== 0) { - req.baseUrl = parentUrl; - req.url = protohost + removed + req.url.substr(protohost.length); - removed = ''; - } - - // no more matching layers - if (idx >= stack.length) { - setImmediate(done, layerError); - return; - } - - // get pathname of request - var path = getPathname(req); - - if (path == null) { - return done(layerError); - } - - // find next matching layer - var layer; - var match; - var route; - - while (match !== true && idx < stack.length) { - layer = stack[idx++]; - match = matchLayer(layer, path); - route = layer.route; - - if (typeof match !== 'boolean') { - // hold on to layerError - layerError = layerError || match; - } - - if (match !== true) { - continue; - } - - if (!route) { - // process non-route handlers normally - continue; - } - - if (layerError) { - // routes do not match with a pending error - match = false; - continue; - } - - var method = req.method; - var has_method = route._handles_method(method); - - // build up automatic options response - if (!has_method && method === 'OPTIONS') { - appendMethods(options, route._options()); - } - - // don't even bother matching route - if (!has_method && method !== 'HEAD') { - match = false; - continue; - } - } - - // no match - if (match !== true) { - return done(layerError); - } - - // store route for dispatch on change - if (route) { - req.route = route; - } - - // Capture one-time layer values - req.params = self.mergeParams - ? mergeParams(layer.params, parentParams) - : layer.params; - var layerPath = layer.path; - - // this should be done for the layer - self.process_params(layer, paramcalled, req, res, function (err) { - if (err) { - return next(layerError || err); - } - - if (route) { - return layer.handle_request(req, res, next); - } - - trim_prefix(layer, layerError, layerPath, path); - }); - } - - function trim_prefix(layer, layerError, layerPath, path) { - var c = path[layerPath.length]; - if (c && '/' !== c && '.' !== c) return next(layerError); - - // Trim off the part of the url that matches the route - // middleware (.use stuff) needs to have the path stripped - if (layerPath.length !== 0) { - debug('trim prefix (%s) from url %s', layerPath, req.url); - removed = layerPath; - req.url = protohost + req.url.substr(protohost.length + removed.length); - - // Ensure leading slash - if (!fqdn && req.url[0] !== '/') { - req.url = '/' + req.url; - slashAdded = true; - } - - // Setup base URL (no trailing slash) - req.baseUrl = parentUrl + (removed[removed.length - 1] === '/' - ? removed.substring(0, removed.length - 1) - : removed); - } - - debug('%s %s : %s', layer.name, layerPath, req.originalUrl); - - if (layerError) { - layer.handle_error(layerError, req, res, next); - } else { - layer.handle_request(req, res, next); - } - } -}; - -/** - * Process any parameters for the layer. - * @private - */ - -proto.process_params = function process_params(layer, called, req, res, done) { - var params = this.params; - - // captured parameters from the layer, keys and values - var keys = layer.keys; - - // fast track - if (!keys || keys.length === 0) { - return done(); - } - - var i = 0; - var name; - var paramIndex = 0; - var key; - var paramVal; - var paramCallbacks; - var paramCalled; - - // process params in order - // param callbacks can be async - function param(err) { - if (err) { - return done(err); - } - - if (i >= keys.length ) { - return done(); - } - - paramIndex = 0; - key = keys[i++]; - - if (!key) { - return done(); - } - - name = key.name; - paramVal = req.params[name]; - paramCallbacks = params[name]; - paramCalled = called[name]; - - if (paramVal === undefined || !paramCallbacks) { - return param(); - } - - // param previously called with same value or error occurred - if (paramCalled && (paramCalled.match === paramVal - || (paramCalled.error && paramCalled.error !== 'route'))) { - // restore value - req.params[name] = paramCalled.value; - - // next param - return param(paramCalled.error); - } - - called[name] = paramCalled = { - error: null, - match: paramVal, - value: paramVal - }; - - paramCallback(); - } - - // single param callbacks - function paramCallback(err) { - var fn = paramCallbacks[paramIndex++]; - - // store updated value - paramCalled.value = req.params[key.name]; - - if (err) { - // store error - paramCalled.error = err; - param(err); - return; - } - - if (!fn) return param(); - - try { - fn(req, res, paramCallback, paramVal, key.name); - } catch (e) { - paramCallback(e); - } - } - - param(); -}; - -/** - * Use the given middleware function, with optional path, defaulting to "/". - * - * Use (like `.all`) will run for any http METHOD, but it will not add - * handlers for those methods so OPTIONS requests will not consider `.use` - * functions even if they could respond. - * - * The other difference is that _route_ path is stripped and not visible - * to the handler function. The main effect of this feature is that mounted - * handlers can operate without any code changes regardless of the "prefix" - * pathname. - * - * @public - */ - -proto.use = function use(fn) { - var offset = 0; - var path = '/'; - - // default path to '/' - // disambiguate router.use([fn]) - if (typeof fn !== 'function') { - var arg = fn; - - while (Array.isArray(arg) && arg.length !== 0) { - arg = arg[0]; - } - - // first arg is the path - if (typeof arg !== 'function') { - offset = 1; - path = fn; - } - } - - var callbacks = flatten(slice.call(arguments, offset)); - - if (callbacks.length === 0) { - throw new TypeError('Router.use() requires middleware functions'); - } - - for (var i = 0; i < callbacks.length; i++) { - var fn = callbacks[i]; - - if (typeof fn !== 'function') { - throw new TypeError('Router.use() requires middleware function but got a ' + gettype(fn)); - } - - // add the middleware - debug('use %s %s', path, fn.name || ''); - - var layer = new Layer(path, { - sensitive: this.caseSensitive, - strict: false, - end: false - }, fn); - - layer.route = undefined; - - this.stack.push(layer); - } - - return this; -}; - -/** - * Create a new Route for the given path. - * - * Each route contains a separate middleware stack and VERB handlers. - * - * See the Route api documentation for details on adding handlers - * and middleware to routes. - * - * @param {String} path - * @return {Route} - * @public - */ - -proto.route = function route(path) { - var route = new Route(path); - - var layer = new Layer(path, { - sensitive: this.caseSensitive, - strict: this.strict, - end: true - }, route.dispatch.bind(route)); - - layer.route = route; - - this.stack.push(layer); - return route; -}; - -// create Router#VERB functions -methods.concat('all').forEach(function(method){ - proto[method] = function(path){ - var route = this.route(path) - route[method].apply(route, slice.call(arguments, 1)); - return this; - }; -}); - -// append methods to a list of methods -function appendMethods(list, addition) { - for (var i = 0; i < addition.length; i++) { - var method = addition[i]; - if (list.indexOf(method) === -1) { - list.push(method); - } - } -} - -// get pathname of request -function getPathname(req) { - try { - return parseUrl(req).pathname; - } catch (err) { - return undefined; - } -} - -// get type for error message -function gettype(obj) { - var type = typeof obj; - - if (type !== 'object') { - return type; - } - - // inspect [[Class]] for objects - return toString.call(obj) - .replace(objectRegExp, '$1'); -} - -/** - * Match path to a layer. - * - * @param {Layer} layer - * @param {string} path - * @private - */ - -function matchLayer(layer, path) { - try { - return layer.match(path); - } catch (err) { - return err; - } -} - -// merge params with parent params -function mergeParams(params, parent) { - if (typeof parent !== 'object' || !parent) { - return params; - } - - // make copy of parent for base - var obj = mixin({}, parent); - - // simple non-numeric merging - if (!(0 in params) || !(0 in parent)) { - return mixin(obj, params); - } - - var i = 0; - var o = 0; - - // determine numeric gaps - while (i in params) { - i++; - } - - while (o in parent) { - o++; - } - - // offset numeric indices in params before merge - for (i--; i >= 0; i--) { - params[i + o] = params[i]; - - // create holes for the merge when necessary - if (i < o) { - delete params[i]; - } - } - - return mixin(obj, params); -} - -// restore obj props after function -function restore(fn, obj) { - var props = new Array(arguments.length - 2); - var vals = new Array(arguments.length - 2); - - for (var i = 0; i < props.length; i++) { - props[i] = arguments[i + 2]; - vals[i] = obj[props[i]]; - } - - return function(err){ - // restore vals - for (var i = 0; i < props.length; i++) { - obj[props[i]] = vals[i]; - } - - return fn.apply(this, arguments); - }; -} - -// send an OPTIONS response -function sendOptionsResponse(res, options, next) { - try { - var body = options.join(','); - res.set('Allow', body); - res.send(body); - } catch (err) { - next(err); - } -} - -// wrap a function -function wrap(old, fn) { - return function proxy() { - var args = new Array(arguments.length + 1); - - args[0] = old; - for (var i = 0, len = arguments.length; i < len; i++) { - args[i + 1] = arguments[i]; - } - - fn.apply(this, args); - }; -} +/*! + * express + * Copyright(c) 2009-2013 TJ Holowaychuk + * Copyright(c) 2013 Roman Shtylman + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict'; + +/** + * Module dependencies. + * @private + */ + +var Route = require('./route'); +var Layer = require('./layer'); +var methods = require('methods'); +var mixin = require('utils-merge'); +var debug = require('debug')('express:router'); +var deprecate = require('depd')('express'); +var flatten = require('array-flatten'); +var parseUrl = require('parseurl'); + +/** + * Module variables. + * @private + */ + +var objectRegExp = /^\[object (\S+)\]$/; +var slice = Array.prototype.slice; +var toString = Object.prototype.toString; + +/** + * Initialize a new `Router` with the given `options`. + * + * @param {Object} options + * @return {Router} which is an callable function + * @public + */ + +var proto = module.exports = function(options) { + var opts = options || {}; + + function router(req, res, next) { + router.handle(req, res, next); + } + + // mixin Router class functions + router.__proto__ = proto; + + router.params = {}; + router._params = []; + router.caseSensitive = opts.caseSensitive; + router.mergeParams = opts.mergeParams; + router.strict = opts.strict; + router.stack = []; + + return router; +}; + +/** + * Map the given param placeholder `name`(s) to the given callback. + * + * Parameter mapping is used to provide pre-conditions to routes + * which use normalized placeholders. For example a _:user_id_ parameter + * could automatically load a user's information from the database without + * any additional code, + * + * The callback uses the same signature as middleware, the only difference + * being that the value of the placeholder is passed, in this case the _id_ + * of the user. Once the `next()` function is invoked, just like middleware + * it will continue on to execute the route, or subsequent parameter functions. + * + * Just like in middleware, you must either respond to the request or call next + * to avoid stalling the request. + * + * app.param('user_id', function(req, res, next, id){ + * User.find(id, function(err, user){ + * if (err) { + * return next(err); + * } else if (!user) { + * return next(new Error('failed to load user')); + * } + * req.user = user; + * next(); + * }); + * }); + * + * @param {String} name + * @param {Function} fn + * @return {app} for chaining + * @public + */ + +proto.param = function param(name, fn) { + // param logic + if (typeof name === 'function') { + deprecate('router.param(fn): Refactor to use path params'); + this._params.push(name); + return; + } + + // apply param functions + var params = this._params; + var len = params.length; + var ret; + + if (name[0] === ':') { + deprecate('router.param(' + JSON.stringify(name) + ', fn): Use router.param(' + JSON.stringify(name.substr(1)) + ', fn) instead'); + name = name.substr(1); + } + + for (var i = 0; i < len; ++i) { + if (ret = params[i](name, fn)) { + fn = ret; + } + } + + // ensure we end up with a + // middleware function + if ('function' !== typeof fn) { + throw new Error('invalid param() call for ' + name + ', got ' + fn); + } + + (this.params[name] = this.params[name] || []).push(fn); + return this; +}; + +/** + * Dispatch a req, res into the router. + * @private + */ + +proto.handle = function handle(req, res, out) { + var self = this; + + debug('dispatching %s %s', req.method, req.url); + + var search = 1 + req.url.indexOf('?'); + var pathlength = search ? search - 1 : req.url.length; + var fqdn = req.url[0] !== '/' && 1 + req.url.substr(0, pathlength).indexOf('://'); + var protohost = fqdn ? req.url.substr(0, req.url.indexOf('/', 2 + fqdn)) : ''; + var idx = 0; + var removed = ''; + var slashAdded = false; + var paramcalled = {}; + + // store options for OPTIONS request + // only used if OPTIONS request + var options = []; + + // middleware and routes + var stack = self.stack; + + // manage inter-router variables + var parentParams = req.params; + var parentUrl = req.baseUrl || ''; + var done = restore(out, req, 'baseUrl', 'next', 'params'); + + // setup next layer + req.next = next; + + // for options requests, respond with a default if nothing else responds + if (req.method === 'OPTIONS') { + done = wrap(done, function(old, err) { + if (err || options.length === 0) return old(err); + sendOptionsResponse(res, options, old); + }); + } + + // setup basic req values + req.baseUrl = parentUrl; + req.originalUrl = req.originalUrl || req.url; + + next(); + + function next(err) { + var layerError = err === 'route' + ? null + : err; + + // remove added slash + if (slashAdded) { + req.url = req.url.substr(1); + slashAdded = false; + } + + // restore altered req.url + if (removed.length !== 0) { + req.baseUrl = parentUrl; + req.url = protohost + removed + req.url.substr(protohost.length); + removed = ''; + } + + // no more matching layers + if (idx >= stack.length) { + setImmediate(done, layerError); + return; + } + + // get pathname of request + var path = getPathname(req); + + if (path == null) { + return done(layerError); + } + + // find next matching layer + var layer; + var match; + var route; + + while (match !== true && idx < stack.length) { + layer = stack[idx++]; + match = matchLayer(layer, path); + route = layer.route; + + if (typeof match !== 'boolean') { + // hold on to layerError + layerError = layerError || match; + } + + if (match !== true) { + continue; + } + + if (!route) { + // process non-route handlers normally + continue; + } + + if (layerError) { + // routes do not match with a pending error + match = false; + continue; + } + + var method = req.method; + var has_method = route._handles_method(method); + + // build up automatic options response + if (!has_method && method === 'OPTIONS') { + appendMethods(options, route._options()); + } + + // don't even bother matching route + if (!has_method && method !== 'HEAD') { + match = false; + continue; + } + } + + // no match + if (match !== true) { + return done(layerError); + } + + // store route for dispatch on change + if (route) { + req.route = route; + } + + // Capture one-time layer values + req.params = self.mergeParams + ? mergeParams(layer.params, parentParams) + : layer.params; + var layerPath = layer.path; + + // this should be done for the layer + self.process_params(layer, paramcalled, req, res, function (err) { + if (err) { + return next(layerError || err); + } + + if (route) { + return layer.handle_request(req, res, next); + } + + trim_prefix(layer, layerError, layerPath, path); + }); + } + + function trim_prefix(layer, layerError, layerPath, path) { + var c = path[layerPath.length]; + if (c && '/' !== c && '.' !== c) return next(layerError); + + // Trim off the part of the url that matches the route + // middleware (.use stuff) needs to have the path stripped + if (layerPath.length !== 0) { + debug('trim prefix (%s) from url %s', layerPath, req.url); + removed = layerPath; + req.url = protohost + req.url.substr(protohost.length + removed.length); + + // Ensure leading slash + if (!fqdn && req.url[0] !== '/') { + req.url = '/' + req.url; + slashAdded = true; + } + + // Setup base URL (no trailing slash) + req.baseUrl = parentUrl + (removed[removed.length - 1] === '/' + ? removed.substring(0, removed.length - 1) + : removed); + } + + debug('%s %s : %s', layer.name, layerPath, req.originalUrl); + + if (layerError) { + layer.handle_error(layerError, req, res, next); + } else { + layer.handle_request(req, res, next); + } + } +}; + +/** + * Process any parameters for the layer. + * @private + */ + +proto.process_params = function process_params(layer, called, req, res, done) { + var params = this.params; + + // captured parameters from the layer, keys and values + var keys = layer.keys; + + // fast track + if (!keys || keys.length === 0) { + return done(); + } + + var i = 0; + var name; + var paramIndex = 0; + var key; + var paramVal; + var paramCallbacks; + var paramCalled; + + // process params in order + // param callbacks can be async + function param(err) { + if (err) { + return done(err); + } + + if (i >= keys.length ) { + return done(); + } + + paramIndex = 0; + key = keys[i++]; + + if (!key) { + return done(); + } + + name = key.name; + paramVal = req.params[name]; + paramCallbacks = params[name]; + paramCalled = called[name]; + + if (paramVal === undefined || !paramCallbacks) { + return param(); + } + + // param previously called with same value or error occurred + if (paramCalled && (paramCalled.match === paramVal + || (paramCalled.error && paramCalled.error !== 'route'))) { + // restore value + req.params[name] = paramCalled.value; + + // next param + return param(paramCalled.error); + } + + called[name] = paramCalled = { + error: null, + match: paramVal, + value: paramVal + }; + + paramCallback(); + } + + // single param callbacks + function paramCallback(err) { + var fn = paramCallbacks[paramIndex++]; + + // store updated value + paramCalled.value = req.params[key.name]; + + if (err) { + // store error + paramCalled.error = err; + param(err); + return; + } + + if (!fn) return param(); + + try { + fn(req, res, paramCallback, paramVal, key.name); + } catch (e) { + paramCallback(e); + } + } + + param(); +}; + +/** + * Use the given middleware function, with optional path, defaulting to "/". + * + * Use (like `.all`) will run for any http METHOD, but it will not add + * handlers for those methods so OPTIONS requests will not consider `.use` + * functions even if they could respond. + * + * The other difference is that _route_ path is stripped and not visible + * to the handler function. The main effect of this feature is that mounted + * handlers can operate without any code changes regardless of the "prefix" + * pathname. + * + * @public + */ + +proto.use = function use(fn) { + var offset = 0; + var path = '/'; + + // default path to '/' + // disambiguate router.use([fn]) + if (typeof fn !== 'function') { + var arg = fn; + + while (Array.isArray(arg) && arg.length !== 0) { + arg = arg[0]; + } + + // first arg is the path + if (typeof arg !== 'function') { + offset = 1; + path = fn; + } + } + + var callbacks = flatten(slice.call(arguments, offset)); + + if (callbacks.length === 0) { + throw new TypeError('Router.use() requires middleware functions'); + } + + for (var i = 0; i < callbacks.length; i++) { + var fn = callbacks[i]; + + if (typeof fn !== 'function') { + throw new TypeError('Router.use() requires middleware function but got a ' + gettype(fn)); + } + + // add the middleware + debug('use %s %s', path, fn.name || ''); + + var layer = new Layer(path, { + sensitive: this.caseSensitive, + strict: false, + end: false + }, fn); + + layer.route = undefined; + + this.stack.push(layer); + } + + return this; +}; + +/** + * Create a new Route for the given path. + * + * Each route contains a separate middleware stack and VERB handlers. + * + * See the Route api documentation for details on adding handlers + * and middleware to routes. + * + * @param {String} path + * @return {Route} + * @public + */ + +proto.route = function route(path) { + var route = new Route(path); + + var layer = new Layer(path, { + sensitive: this.caseSensitive, + strict: this.strict, + end: true + }, route.dispatch.bind(route)); + + layer.route = route; + + this.stack.push(layer); + return route; +}; + +// create Router#VERB functions +methods.concat('all').forEach(function(method){ + proto[method] = function(path){ + var route = this.route(path) + route[method].apply(route, slice.call(arguments, 1)); + return this; + }; +}); + +// append methods to a list of methods +function appendMethods(list, addition) { + for (var i = 0; i < addition.length; i++) { + var method = addition[i]; + if (list.indexOf(method) === -1) { + list.push(method); + } + } +} + +// get pathname of request +function getPathname(req) { + try { + return parseUrl(req).pathname; + } catch (err) { + return undefined; + } +} + +// get type for error message +function gettype(obj) { + var type = typeof obj; + + if (type !== 'object') { + return type; + } + + // inspect [[Class]] for objects + return toString.call(obj) + .replace(objectRegExp, '$1'); +} + +/** + * Match path to a layer. + * + * @param {Layer} layer + * @param {string} path + * @private + */ + +function matchLayer(layer, path) { + try { + return layer.match(path); + } catch (err) { + return err; + } +} + +// merge params with parent params +function mergeParams(params, parent) { + if (typeof parent !== 'object' || !parent) { + return params; + } + + // make copy of parent for base + var obj = mixin({}, parent); + + // simple non-numeric merging + if (!(0 in params) || !(0 in parent)) { + return mixin(obj, params); + } + + var i = 0; + var o = 0; + + // determine numeric gaps + while (i in params) { + i++; + } + + while (o in parent) { + o++; + } + + // offset numeric indices in params before merge + for (i--; i >= 0; i--) { + params[i + o] = params[i]; + + // create holes for the merge when necessary + if (i < o) { + delete params[i]; + } + } + + return mixin(obj, params); +} + +// restore obj props after function +function restore(fn, obj) { + var props = new Array(arguments.length - 2); + var vals = new Array(arguments.length - 2); + + for (var i = 0; i < props.length; i++) { + props[i] = arguments[i + 2]; + vals[i] = obj[props[i]]; + } + + return function(err){ + // restore vals + for (var i = 0; i < props.length; i++) { + obj[props[i]] = vals[i]; + } + + return fn.apply(this, arguments); + }; +} + +// send an OPTIONS response +function sendOptionsResponse(res, options, next) { + try { + var body = options.join(','); + res.set('Allow', body); + res.send(body); + } catch (err) { + next(err); + } +} + +// wrap a function +function wrap(old, fn) { + return function proxy() { + var args = new Array(arguments.length + 1); + + args[0] = old; + for (var i = 0, len = arguments.length; i < len; i++) { + args[i + 1] = arguments[i]; + } + + fn.apply(this, args); + }; +} diff --git a/ui/node_modules/express/lib/router/layer.js b/ui/node_modules/express/lib/router/layer.js index c3809b9d..fe9210cb 100644 --- a/ui/node_modules/express/lib/router/layer.js +++ b/ui/node_modules/express/lib/router/layer.js @@ -1,176 +1,176 @@ -/*! - * express - * Copyright(c) 2009-2013 TJ Holowaychuk - * Copyright(c) 2013 Roman Shtylman - * Copyright(c) 2014-2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict'; - -/** - * Module dependencies. - * @private - */ - -var pathRegexp = require('path-to-regexp'); -var debug = require('debug')('express:router:layer'); - -/** - * Module variables. - * @private - */ - -var hasOwnProperty = Object.prototype.hasOwnProperty; - -/** - * Module exports. - * @public - */ - -module.exports = Layer; - -function Layer(path, options, fn) { - if (!(this instanceof Layer)) { - return new Layer(path, options, fn); - } - - debug('new %s', path); - var opts = options || {}; - - this.handle = fn; - this.name = fn.name || ''; - this.params = undefined; - this.path = undefined; - this.regexp = pathRegexp(path, this.keys = [], opts); - - if (path === '/' && opts.end === false) { - this.regexp.fast_slash = true; - } -} - -/** - * Handle the error for the layer. - * - * @param {Error} error - * @param {Request} req - * @param {Response} res - * @param {function} next - * @api private - */ - -Layer.prototype.handle_error = function handle_error(error, req, res, next) { - var fn = this.handle; - - if (fn.length !== 4) { - // not a standard error handler - return next(error); - } - - try { - fn(error, req, res, next); - } catch (err) { - next(err); - } -}; - -/** - * Handle the request for the layer. - * - * @param {Request} req - * @param {Response} res - * @param {function} next - * @api private - */ - -Layer.prototype.handle_request = function handle(req, res, next) { - var fn = this.handle; - - if (fn.length > 3) { - // not a standard request handler - return next(); - } - - try { - fn(req, res, next); - } catch (err) { - next(err); - } -}; - -/** - * Check if this route matches `path`, if so - * populate `.params`. - * - * @param {String} path - * @return {Boolean} - * @api private - */ - -Layer.prototype.match = function match(path) { - if (path == null) { - // no path, nothing matches - this.params = undefined; - this.path = undefined; - return false; - } - - if (this.regexp.fast_slash) { - // fast path non-ending match for / (everything matches) - this.params = {}; - this.path = ''; - return true; - } - - var m = this.regexp.exec(path); - - if (!m) { - this.params = undefined; - this.path = undefined; - return false; - } - - // store values - this.params = {}; - this.path = m[0]; - - var keys = this.keys; - var params = this.params; - - for (var i = 1; i < m.length; i++) { - var key = keys[i - 1]; - var prop = key.name; - var val = decode_param(m[i]); - - if (val !== undefined || !(hasOwnProperty.call(params, prop))) { - params[prop] = val; - } - } - - return true; -}; - -/** - * Decode param value. - * - * @param {string} val - * @return {string} - * @private - */ - -function decode_param(val) { - if (typeof val !== 'string' || val.length === 0) { - return val; - } - - try { - return decodeURIComponent(val); - } catch (err) { - if (err instanceof URIError) { - err.message = 'Failed to decode param \'' + val + '\''; - err.status = err.statusCode = 400; - } - - throw err; - } -} +/*! + * express + * Copyright(c) 2009-2013 TJ Holowaychuk + * Copyright(c) 2013 Roman Shtylman + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict'; + +/** + * Module dependencies. + * @private + */ + +var pathRegexp = require('path-to-regexp'); +var debug = require('debug')('express:router:layer'); + +/** + * Module variables. + * @private + */ + +var hasOwnProperty = Object.prototype.hasOwnProperty; + +/** + * Module exports. + * @public + */ + +module.exports = Layer; + +function Layer(path, options, fn) { + if (!(this instanceof Layer)) { + return new Layer(path, options, fn); + } + + debug('new %s', path); + var opts = options || {}; + + this.handle = fn; + this.name = fn.name || ''; + this.params = undefined; + this.path = undefined; + this.regexp = pathRegexp(path, this.keys = [], opts); + + if (path === '/' && opts.end === false) { + this.regexp.fast_slash = true; + } +} + +/** + * Handle the error for the layer. + * + * @param {Error} error + * @param {Request} req + * @param {Response} res + * @param {function} next + * @api private + */ + +Layer.prototype.handle_error = function handle_error(error, req, res, next) { + var fn = this.handle; + + if (fn.length !== 4) { + // not a standard error handler + return next(error); + } + + try { + fn(error, req, res, next); + } catch (err) { + next(err); + } +}; + +/** + * Handle the request for the layer. + * + * @param {Request} req + * @param {Response} res + * @param {function} next + * @api private + */ + +Layer.prototype.handle_request = function handle(req, res, next) { + var fn = this.handle; + + if (fn.length > 3) { + // not a standard request handler + return next(); + } + + try { + fn(req, res, next); + } catch (err) { + next(err); + } +}; + +/** + * Check if this route matches `path`, if so + * populate `.params`. + * + * @param {String} path + * @return {Boolean} + * @api private + */ + +Layer.prototype.match = function match(path) { + if (path == null) { + // no path, nothing matches + this.params = undefined; + this.path = undefined; + return false; + } + + if (this.regexp.fast_slash) { + // fast path non-ending match for / (everything matches) + this.params = {}; + this.path = ''; + return true; + } + + var m = this.regexp.exec(path); + + if (!m) { + this.params = undefined; + this.path = undefined; + return false; + } + + // store values + this.params = {}; + this.path = m[0]; + + var keys = this.keys; + var params = this.params; + + for (var i = 1; i < m.length; i++) { + var key = keys[i - 1]; + var prop = key.name; + var val = decode_param(m[i]); + + if (val !== undefined || !(hasOwnProperty.call(params, prop))) { + params[prop] = val; + } + } + + return true; +}; + +/** + * Decode param value. + * + * @param {string} val + * @return {string} + * @private + */ + +function decode_param(val) { + if (typeof val !== 'string' || val.length === 0) { + return val; + } + + try { + return decodeURIComponent(val); + } catch (err) { + if (err instanceof URIError) { + err.message = 'Failed to decode param \'' + val + '\''; + err.status = err.statusCode = 400; + } + + throw err; + } +} diff --git a/ui/node_modules/express/lib/router/route.js b/ui/node_modules/express/lib/router/route.js index 88cf4907..2788d7b7 100644 --- a/ui/node_modules/express/lib/router/route.js +++ b/ui/node_modules/express/lib/router/route.js @@ -1,210 +1,210 @@ -/*! - * express - * Copyright(c) 2009-2013 TJ Holowaychuk - * Copyright(c) 2013 Roman Shtylman - * Copyright(c) 2014-2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict'; - -/** - * Module dependencies. - * @private - */ - -var debug = require('debug')('express:router:route'); -var flatten = require('array-flatten'); -var Layer = require('./layer'); -var methods = require('methods'); - -/** - * Module variables. - * @private - */ - -var slice = Array.prototype.slice; -var toString = Object.prototype.toString; - -/** - * Module exports. - * @public - */ - -module.exports = Route; - -/** - * Initialize `Route` with the given `path`, - * - * @param {String} path - * @public - */ - -function Route(path) { - this.path = path; - this.stack = []; - - debug('new %s', path); - - // route handlers for various http methods - this.methods = {}; -} - -/** - * Determine if the route handles a given method. - * @private - */ - -Route.prototype._handles_method = function _handles_method(method) { - if (this.methods._all) { - return true; - } - - var name = method.toLowerCase(); - - if (name === 'head' && !this.methods['head']) { - name = 'get'; - } - - return Boolean(this.methods[name]); -}; - -/** - * @return {Array} supported HTTP methods - * @private - */ - -Route.prototype._options = function _options() { - var methods = Object.keys(this.methods); - - // append automatic head - if (this.methods.get && !this.methods.head) { - methods.push('head'); - } - - for (var i = 0; i < methods.length; i++) { - // make upper case - methods[i] = methods[i].toUpperCase(); - } - - return methods; -}; - -/** - * dispatch req, res into this route - * @private - */ - -Route.prototype.dispatch = function dispatch(req, res, done) { - var idx = 0; - var stack = this.stack; - if (stack.length === 0) { - return done(); - } - - var method = req.method.toLowerCase(); - if (method === 'head' && !this.methods['head']) { - method = 'get'; - } - - req.route = this; - - next(); - - function next(err) { - if (err && err === 'route') { - return done(); - } - - var layer = stack[idx++]; - if (!layer) { - return done(err); - } - - if (layer.method && layer.method !== method) { - return next(err); - } - - if (err) { - layer.handle_error(err, req, res, next); - } else { - layer.handle_request(req, res, next); - } - } -}; - -/** - * Add a handler for all HTTP verbs to this route. - * - * Behaves just like middleware and can respond or call `next` - * to continue processing. - * - * You can use multiple `.all` call to add multiple handlers. - * - * function check_something(req, res, next){ - * next(); - * }; - * - * function validate_user(req, res, next){ - * next(); - * }; - * - * route - * .all(validate_user) - * .all(check_something) - * .get(function(req, res, next){ - * res.send('hello world'); - * }); - * - * @param {function} handler - * @return {Route} for chaining - * @api public - */ - -Route.prototype.all = function all() { - var handles = flatten(slice.call(arguments)); - - for (var i = 0; i < handles.length; i++) { - var handle = handles[i]; - - if (typeof handle !== 'function') { - var type = toString.call(handle); - var msg = 'Route.all() requires callback functions but got a ' + type; - throw new TypeError(msg); - } - - var layer = Layer('/', {}, handle); - layer.method = undefined; - - this.methods._all = true; - this.stack.push(layer); - } - - return this; -}; - -methods.forEach(function(method){ - Route.prototype[method] = function(){ - var handles = flatten(slice.call(arguments)); - - for (var i = 0; i < handles.length; i++) { - var handle = handles[i]; - - if (typeof handle !== 'function') { - var type = toString.call(handle); - var msg = 'Route.' + method + '() requires callback functions but got a ' + type; - throw new Error(msg); - } - - debug('%s %s', method, this.path); - - var layer = Layer('/', {}, handle); - layer.method = method; - - this.methods[method] = true; - this.stack.push(layer); - } - - return this; - }; -}); +/*! + * express + * Copyright(c) 2009-2013 TJ Holowaychuk + * Copyright(c) 2013 Roman Shtylman + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict'; + +/** + * Module dependencies. + * @private + */ + +var debug = require('debug')('express:router:route'); +var flatten = require('array-flatten'); +var Layer = require('./layer'); +var methods = require('methods'); + +/** + * Module variables. + * @private + */ + +var slice = Array.prototype.slice; +var toString = Object.prototype.toString; + +/** + * Module exports. + * @public + */ + +module.exports = Route; + +/** + * Initialize `Route` with the given `path`, + * + * @param {String} path + * @public + */ + +function Route(path) { + this.path = path; + this.stack = []; + + debug('new %s', path); + + // route handlers for various http methods + this.methods = {}; +} + +/** + * Determine if the route handles a given method. + * @private + */ + +Route.prototype._handles_method = function _handles_method(method) { + if (this.methods._all) { + return true; + } + + var name = method.toLowerCase(); + + if (name === 'head' && !this.methods['head']) { + name = 'get'; + } + + return Boolean(this.methods[name]); +}; + +/** + * @return {Array} supported HTTP methods + * @private + */ + +Route.prototype._options = function _options() { + var methods = Object.keys(this.methods); + + // append automatic head + if (this.methods.get && !this.methods.head) { + methods.push('head'); + } + + for (var i = 0; i < methods.length; i++) { + // make upper case + methods[i] = methods[i].toUpperCase(); + } + + return methods; +}; + +/** + * dispatch req, res into this route + * @private + */ + +Route.prototype.dispatch = function dispatch(req, res, done) { + var idx = 0; + var stack = this.stack; + if (stack.length === 0) { + return done(); + } + + var method = req.method.toLowerCase(); + if (method === 'head' && !this.methods['head']) { + method = 'get'; + } + + req.route = this; + + next(); + + function next(err) { + if (err && err === 'route') { + return done(); + } + + var layer = stack[idx++]; + if (!layer) { + return done(err); + } + + if (layer.method && layer.method !== method) { + return next(err); + } + + if (err) { + layer.handle_error(err, req, res, next); + } else { + layer.handle_request(req, res, next); + } + } +}; + +/** + * Add a handler for all HTTP verbs to this route. + * + * Behaves just like middleware and can respond or call `next` + * to continue processing. + * + * You can use multiple `.all` call to add multiple handlers. + * + * function check_something(req, res, next){ + * next(); + * }; + * + * function validate_user(req, res, next){ + * next(); + * }; + * + * route + * .all(validate_user) + * .all(check_something) + * .get(function(req, res, next){ + * res.send('hello world'); + * }); + * + * @param {function} handler + * @return {Route} for chaining + * @api public + */ + +Route.prototype.all = function all() { + var handles = flatten(slice.call(arguments)); + + for (var i = 0; i < handles.length; i++) { + var handle = handles[i]; + + if (typeof handle !== 'function') { + var type = toString.call(handle); + var msg = 'Route.all() requires callback functions but got a ' + type; + throw new TypeError(msg); + } + + var layer = Layer('/', {}, handle); + layer.method = undefined; + + this.methods._all = true; + this.stack.push(layer); + } + + return this; +}; + +methods.forEach(function(method){ + Route.prototype[method] = function(){ + var handles = flatten(slice.call(arguments)); + + for (var i = 0; i < handles.length; i++) { + var handle = handles[i]; + + if (typeof handle !== 'function') { + var type = toString.call(handle); + var msg = 'Route.' + method + '() requires callback functions but got a ' + type; + throw new Error(msg); + } + + debug('%s %s', method, this.path); + + var layer = Layer('/', {}, handle); + layer.method = method; + + this.methods[method] = true; + this.stack.push(layer); + } + + return this; + }; +}); diff --git a/ui/node_modules/express/lib/utils.js b/ui/node_modules/express/lib/utils.js index ce22b306..f418c580 100644 --- a/ui/node_modules/express/lib/utils.js +++ b/ui/node_modules/express/lib/utils.js @@ -1,299 +1,299 @@ -/*! - * express - * Copyright(c) 2009-2013 TJ Holowaychuk - * Copyright(c) 2014-2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict'; - -/** - * Module dependencies. - * @api private - */ - -var contentDisposition = require('content-disposition'); -var contentType = require('content-type'); -var deprecate = require('depd')('express'); -var flatten = require('array-flatten'); -var mime = require('send').mime; -var basename = require('path').basename; -var etag = require('etag'); -var proxyaddr = require('proxy-addr'); -var qs = require('qs'); -var querystring = require('querystring'); - -/** - * Return strong ETag for `body`. - * - * @param {String|Buffer} body - * @param {String} [encoding] - * @return {String} - * @api private - */ - -exports.etag = function (body, encoding) { - var buf = !Buffer.isBuffer(body) - ? new Buffer(body, encoding) - : body; - - return etag(buf, {weak: false}); -}; - -/** - * Return weak ETag for `body`. - * - * @param {String|Buffer} body - * @param {String} [encoding] - * @return {String} - * @api private - */ - -exports.wetag = function wetag(body, encoding){ - var buf = !Buffer.isBuffer(body) - ? new Buffer(body, encoding) - : body; - - return etag(buf, {weak: true}); -}; - -/** - * Check if `path` looks absolute. - * - * @param {String} path - * @return {Boolean} - * @api private - */ - -exports.isAbsolute = function(path){ - if ('/' === path[0]) return true; - if (':' === path[1] && ('\\' === path[2] || '/' === path[2])) return true; // Windows device path - if ('\\\\' === path.substring(0, 2)) return true; // Microsoft Azure absolute path -}; - -/** - * Flatten the given `arr`. - * - * @param {Array} arr - * @return {Array} - * @api private - */ - -exports.flatten = deprecate.function(flatten, - 'utils.flatten: use array-flatten npm module instead'); - -/** - * Normalize the given `type`, for example "html" becomes "text/html". - * - * @param {String} type - * @return {Object} - * @api private - */ - -exports.normalizeType = function(type){ - return ~type.indexOf('/') - ? acceptParams(type) - : { value: mime.lookup(type), params: {} }; -}; - -/** - * Normalize `types`, for example "html" becomes "text/html". - * - * @param {Array} types - * @return {Array} - * @api private - */ - -exports.normalizeTypes = function(types){ - var ret = []; - - for (var i = 0; i < types.length; ++i) { - ret.push(exports.normalizeType(types[i])); - } - - return ret; -}; - -/** - * Generate Content-Disposition header appropriate for the filename. - * non-ascii filenames are urlencoded and a filename* parameter is added - * - * @param {String} filename - * @return {String} - * @api private - */ - -exports.contentDisposition = deprecate.function(contentDisposition, - 'utils.contentDisposition: use content-disposition npm module instead'); - -/** - * Parse accept params `str` returning an - * object with `.value`, `.quality` and `.params`. - * also includes `.originalIndex` for stable sorting - * - * @param {String} str - * @return {Object} - * @api private - */ - -function acceptParams(str, index) { - var parts = str.split(/ *; */); - var ret = { value: parts[0], quality: 1, params: {}, originalIndex: index }; - - for (var i = 1; i < parts.length; ++i) { - var pms = parts[i].split(/ *= */); - if ('q' === pms[0]) { - ret.quality = parseFloat(pms[1]); - } else { - ret.params[pms[0]] = pms[1]; - } - } - - return ret; -} - -/** - * Compile "etag" value to function. - * - * @param {Boolean|String|Function} val - * @return {Function} - * @api private - */ - -exports.compileETag = function(val) { - var fn; - - if (typeof val === 'function') { - return val; - } - - switch (val) { - case true: - fn = exports.wetag; - break; - case false: - break; - case 'strong': - fn = exports.etag; - break; - case 'weak': - fn = exports.wetag; - break; - default: - throw new TypeError('unknown value for etag function: ' + val); - } - - return fn; -} - -/** - * Compile "query parser" value to function. - * - * @param {String|Function} val - * @return {Function} - * @api private - */ - -exports.compileQueryParser = function compileQueryParser(val) { - var fn; - - if (typeof val === 'function') { - return val; - } - - switch (val) { - case true: - fn = querystring.parse; - break; - case false: - fn = newObject; - break; - case 'extended': - fn = parseExtendedQueryString; - break; - case 'simple': - fn = querystring.parse; - break; - default: - throw new TypeError('unknown value for query parser function: ' + val); - } - - return fn; -} - -/** - * Compile "proxy trust" value to function. - * - * @param {Boolean|String|Number|Array|Function} val - * @return {Function} - * @api private - */ - -exports.compileTrust = function(val) { - if (typeof val === 'function') return val; - - if (val === true) { - // Support plain true/false - return function(){ return true }; - } - - if (typeof val === 'number') { - // Support trusting hop count - return function(a, i){ return i < val }; - } - - if (typeof val === 'string') { - // Support comma-separated values - val = val.split(/ *, */); - } - - return proxyaddr.compile(val || []); -} - -/** - * Set the charset in a given Content-Type string. - * - * @param {String} type - * @param {String} charset - * @return {String} - * @api private - */ - -exports.setCharset = function setCharset(type, charset) { - if (!type || !charset) { - return type; - } - - // parse type - var parsed = contentType.parse(type); - - // set charset - parsed.parameters.charset = charset; - - // format type - return contentType.format(parsed); -}; - -/** - * Parse an extended query string with qs. - * - * @return {Object} - * @private - */ - -function parseExtendedQueryString(str) { - return qs.parse(str, { - allowPrototypes: true - }); -} - -/** - * Return new empty object. - * - * @return {Object} - * @api private - */ - -function newObject() { - return {}; -} +/*! + * express + * Copyright(c) 2009-2013 TJ Holowaychuk + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict'; + +/** + * Module dependencies. + * @api private + */ + +var contentDisposition = require('content-disposition'); +var contentType = require('content-type'); +var deprecate = require('depd')('express'); +var flatten = require('array-flatten'); +var mime = require('send').mime; +var basename = require('path').basename; +var etag = require('etag'); +var proxyaddr = require('proxy-addr'); +var qs = require('qs'); +var querystring = require('querystring'); + +/** + * Return strong ETag for `body`. + * + * @param {String|Buffer} body + * @param {String} [encoding] + * @return {String} + * @api private + */ + +exports.etag = function (body, encoding) { + var buf = !Buffer.isBuffer(body) + ? new Buffer(body, encoding) + : body; + + return etag(buf, {weak: false}); +}; + +/** + * Return weak ETag for `body`. + * + * @param {String|Buffer} body + * @param {String} [encoding] + * @return {String} + * @api private + */ + +exports.wetag = function wetag(body, encoding){ + var buf = !Buffer.isBuffer(body) + ? new Buffer(body, encoding) + : body; + + return etag(buf, {weak: true}); +}; + +/** + * Check if `path` looks absolute. + * + * @param {String} path + * @return {Boolean} + * @api private + */ + +exports.isAbsolute = function(path){ + if ('/' === path[0]) return true; + if (':' === path[1] && ('\\' === path[2] || '/' === path[2])) return true; // Windows device path + if ('\\\\' === path.substring(0, 2)) return true; // Microsoft Azure absolute path +}; + +/** + * Flatten the given `arr`. + * + * @param {Array} arr + * @return {Array} + * @api private + */ + +exports.flatten = deprecate.function(flatten, + 'utils.flatten: use array-flatten npm module instead'); + +/** + * Normalize the given `type`, for example "html" becomes "text/html". + * + * @param {String} type + * @return {Object} + * @api private + */ + +exports.normalizeType = function(type){ + return ~type.indexOf('/') + ? acceptParams(type) + : { value: mime.lookup(type), params: {} }; +}; + +/** + * Normalize `types`, for example "html" becomes "text/html". + * + * @param {Array} types + * @return {Array} + * @api private + */ + +exports.normalizeTypes = function(types){ + var ret = []; + + for (var i = 0; i < types.length; ++i) { + ret.push(exports.normalizeType(types[i])); + } + + return ret; +}; + +/** + * Generate Content-Disposition header appropriate for the filename. + * non-ascii filenames are urlencoded and a filename* parameter is added + * + * @param {String} filename + * @return {String} + * @api private + */ + +exports.contentDisposition = deprecate.function(contentDisposition, + 'utils.contentDisposition: use content-disposition npm module instead'); + +/** + * Parse accept params `str` returning an + * object with `.value`, `.quality` and `.params`. + * also includes `.originalIndex` for stable sorting + * + * @param {String} str + * @return {Object} + * @api private + */ + +function acceptParams(str, index) { + var parts = str.split(/ *; */); + var ret = { value: parts[0], quality: 1, params: {}, originalIndex: index }; + + for (var i = 1; i < parts.length; ++i) { + var pms = parts[i].split(/ *= */); + if ('q' === pms[0]) { + ret.quality = parseFloat(pms[1]); + } else { + ret.params[pms[0]] = pms[1]; + } + } + + return ret; +} + +/** + * Compile "etag" value to function. + * + * @param {Boolean|String|Function} val + * @return {Function} + * @api private + */ + +exports.compileETag = function(val) { + var fn; + + if (typeof val === 'function') { + return val; + } + + switch (val) { + case true: + fn = exports.wetag; + break; + case false: + break; + case 'strong': + fn = exports.etag; + break; + case 'weak': + fn = exports.wetag; + break; + default: + throw new TypeError('unknown value for etag function: ' + val); + } + + return fn; +} + +/** + * Compile "query parser" value to function. + * + * @param {String|Function} val + * @return {Function} + * @api private + */ + +exports.compileQueryParser = function compileQueryParser(val) { + var fn; + + if (typeof val === 'function') { + return val; + } + + switch (val) { + case true: + fn = querystring.parse; + break; + case false: + fn = newObject; + break; + case 'extended': + fn = parseExtendedQueryString; + break; + case 'simple': + fn = querystring.parse; + break; + default: + throw new TypeError('unknown value for query parser function: ' + val); + } + + return fn; +} + +/** + * Compile "proxy trust" value to function. + * + * @param {Boolean|String|Number|Array|Function} val + * @return {Function} + * @api private + */ + +exports.compileTrust = function(val) { + if (typeof val === 'function') return val; + + if (val === true) { + // Support plain true/false + return function(){ return true }; + } + + if (typeof val === 'number') { + // Support trusting hop count + return function(a, i){ return i < val }; + } + + if (typeof val === 'string') { + // Support comma-separated values + val = val.split(/ *, */); + } + + return proxyaddr.compile(val || []); +} + +/** + * Set the charset in a given Content-Type string. + * + * @param {String} type + * @param {String} charset + * @return {String} + * @api private + */ + +exports.setCharset = function setCharset(type, charset) { + if (!type || !charset) { + return type; + } + + // parse type + var parsed = contentType.parse(type); + + // set charset + parsed.parameters.charset = charset; + + // format type + return contentType.format(parsed); +}; + +/** + * Parse an extended query string with qs. + * + * @return {Object} + * @private + */ + +function parseExtendedQueryString(str) { + return qs.parse(str, { + allowPrototypes: true + }); +} + +/** + * Return new empty object. + * + * @return {Object} + * @api private + */ + +function newObject() { + return {}; +} diff --git a/ui/node_modules/express/lib/view.js b/ui/node_modules/express/lib/view.js index f6db4d8b..52415d4c 100644 --- a/ui/node_modules/express/lib/view.js +++ b/ui/node_modules/express/lib/view.js @@ -1,173 +1,173 @@ -/*! - * express - * Copyright(c) 2009-2013 TJ Holowaychuk - * Copyright(c) 2013 Roman Shtylman - * Copyright(c) 2014-2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict'; - -/** - * Module dependencies. - * @private - */ - -var debug = require('debug')('express:view'); -var path = require('path'); -var fs = require('fs'); -var utils = require('./utils'); - -/** - * Module variables. - * @private - */ - -var dirname = path.dirname; -var basename = path.basename; -var extname = path.extname; -var join = path.join; -var resolve = path.resolve; - -/** - * Module exports. - * @public - */ - -module.exports = View; - -/** - * Initialize a new `View` with the given `name`. - * - * Options: - * - * - `defaultEngine` the default template engine name - * - `engines` template engine require() cache - * - `root` root path for view lookup - * - * @param {string} name - * @param {object} options - * @public - */ - -function View(name, options) { - var opts = options || {}; - - this.defaultEngine = opts.defaultEngine; - this.ext = extname(name); - this.name = name; - this.root = opts.root; - - if (!this.ext && !this.defaultEngine) { - throw new Error('No default engine was specified and no extension was provided.'); - } - - var fileName = name; - - if (!this.ext) { - // get extension from default engine name - this.ext = this.defaultEngine[0] !== '.' - ? '.' + this.defaultEngine - : this.defaultEngine; - - fileName += this.ext; - } - - if (!opts.engines[this.ext]) { - // load engine - opts.engines[this.ext] = require(this.ext.substr(1)).__express; - } - - // store loaded engine - this.engine = opts.engines[this.ext]; - - // lookup path - this.path = this.lookup(fileName); -} - -/** - * Lookup view by the given `name` - * - * @param {string} name - * @private - */ - -View.prototype.lookup = function lookup(name) { - var path; - var roots = [].concat(this.root); - - debug('lookup "%s"', name); - - for (var i = 0; i < roots.length && !path; i++) { - var root = roots[i]; - - // resolve the path - var loc = resolve(root, name); - var dir = dirname(loc); - var file = basename(loc); - - // resolve the file - path = this.resolve(dir, file); - } - - return path; -}; - -/** - * Render with the given options. - * - * @param {object} options - * @param {function} callback - * @private - */ - -View.prototype.render = function render(options, callback) { - debug('render "%s"', this.path); - this.engine(this.path, options, callback); -}; - -/** - * Resolve the file within the given directory. - * - * @param {string} dir - * @param {string} file - * @private - */ - -View.prototype.resolve = function resolve(dir, file) { - var ext = this.ext; - - // . - var path = join(dir, file); - var stat = tryStat(path); - - if (stat && stat.isFile()) { - return path; - } - - // /index. - path = join(dir, basename(file, ext), 'index' + ext); - stat = tryStat(path); - - if (stat && stat.isFile()) { - return path; - } -}; - -/** - * Return a stat, maybe. - * - * @param {string} path - * @return {fs.Stats} - * @private - */ - -function tryStat(path) { - debug('stat "%s"', path); - - try { - return fs.statSync(path); - } catch (e) { - return undefined; - } -} +/*! + * express + * Copyright(c) 2009-2013 TJ Holowaychuk + * Copyright(c) 2013 Roman Shtylman + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict'; + +/** + * Module dependencies. + * @private + */ + +var debug = require('debug')('express:view'); +var path = require('path'); +var fs = require('fs'); +var utils = require('./utils'); + +/** + * Module variables. + * @private + */ + +var dirname = path.dirname; +var basename = path.basename; +var extname = path.extname; +var join = path.join; +var resolve = path.resolve; + +/** + * Module exports. + * @public + */ + +module.exports = View; + +/** + * Initialize a new `View` with the given `name`. + * + * Options: + * + * - `defaultEngine` the default template engine name + * - `engines` template engine require() cache + * - `root` root path for view lookup + * + * @param {string} name + * @param {object} options + * @public + */ + +function View(name, options) { + var opts = options || {}; + + this.defaultEngine = opts.defaultEngine; + this.ext = extname(name); + this.name = name; + this.root = opts.root; + + if (!this.ext && !this.defaultEngine) { + throw new Error('No default engine was specified and no extension was provided.'); + } + + var fileName = name; + + if (!this.ext) { + // get extension from default engine name + this.ext = this.defaultEngine[0] !== '.' + ? '.' + this.defaultEngine + : this.defaultEngine; + + fileName += this.ext; + } + + if (!opts.engines[this.ext]) { + // load engine + opts.engines[this.ext] = require(this.ext.substr(1)).__express; + } + + // store loaded engine + this.engine = opts.engines[this.ext]; + + // lookup path + this.path = this.lookup(fileName); +} + +/** + * Lookup view by the given `name` + * + * @param {string} name + * @private + */ + +View.prototype.lookup = function lookup(name) { + var path; + var roots = [].concat(this.root); + + debug('lookup "%s"', name); + + for (var i = 0; i < roots.length && !path; i++) { + var root = roots[i]; + + // resolve the path + var loc = resolve(root, name); + var dir = dirname(loc); + var file = basename(loc); + + // resolve the file + path = this.resolve(dir, file); + } + + return path; +}; + +/** + * Render with the given options. + * + * @param {object} options + * @param {function} callback + * @private + */ + +View.prototype.render = function render(options, callback) { + debug('render "%s"', this.path); + this.engine(this.path, options, callback); +}; + +/** + * Resolve the file within the given directory. + * + * @param {string} dir + * @param {string} file + * @private + */ + +View.prototype.resolve = function resolve(dir, file) { + var ext = this.ext; + + // . + var path = join(dir, file); + var stat = tryStat(path); + + if (stat && stat.isFile()) { + return path; + } + + // /index. + path = join(dir, basename(file, ext), 'index' + ext); + stat = tryStat(path); + + if (stat && stat.isFile()) { + return path; + } +}; + +/** + * Return a stat, maybe. + * + * @param {string} path + * @return {fs.Stats} + * @private + */ + +function tryStat(path) { + debug('stat "%s"', path); + + try { + return fs.statSync(path); + } catch (e) { + return undefined; + } +} diff --git a/ui/node_modules/express/node_modules/accepts/HISTORY.md b/ui/node_modules/express/node_modules/accepts/HISTORY.md index bea49a8f..0477ed71 100644 --- a/ui/node_modules/express/node_modules/accepts/HISTORY.md +++ b/ui/node_modules/express/node_modules/accepts/HISTORY.md @@ -1,212 +1,212 @@ -1.3.3 / 2016-05-02 -================== - - * deps: mime-types@~2.1.11 - - deps: mime-db@~1.23.0 - * deps: negotiator@0.6.1 - - perf: improve `Accept` parsing speed - - perf: improve `Accept-Charset` parsing speed - - perf: improve `Accept-Encoding` parsing speed - - perf: improve `Accept-Language` parsing speed - -1.3.2 / 2016-03-08 -================== - - * deps: mime-types@~2.1.10 - - Fix extension of `application/dash+xml` - - Update primary extension for `audio/mp4` - - deps: mime-db@~1.22.0 - -1.3.1 / 2016-01-19 -================== - - * deps: mime-types@~2.1.9 - - deps: mime-db@~1.21.0 - -1.3.0 / 2015-09-29 -================== - - * deps: mime-types@~2.1.7 - - deps: mime-db@~1.19.0 - * deps: negotiator@0.6.0 - - Fix including type extensions in parameters in `Accept` parsing - - Fix parsing `Accept` parameters with quoted equals - - Fix parsing `Accept` parameters with quoted semicolons - - Lazy-load modules from main entry point - - perf: delay type concatenation until needed - - perf: enable strict mode - - perf: hoist regular expressions - - perf: remove closures getting spec properties - - perf: remove a closure from media type parsing - - perf: remove property delete from media type parsing - -1.2.13 / 2015-09-06 -=================== - - * deps: mime-types@~2.1.6 - - deps: mime-db@~1.18.0 - -1.2.12 / 2015-07-30 -=================== - - * deps: mime-types@~2.1.4 - - deps: mime-db@~1.16.0 - -1.2.11 / 2015-07-16 -=================== - - * deps: mime-types@~2.1.3 - - deps: mime-db@~1.15.0 - -1.2.10 / 2015-07-01 -=================== - - * deps: mime-types@~2.1.2 - - deps: mime-db@~1.14.0 - -1.2.9 / 2015-06-08 -================== - - * deps: mime-types@~2.1.1 - - perf: fix deopt during mapping - -1.2.8 / 2015-06-07 -================== - - * deps: mime-types@~2.1.0 - - deps: mime-db@~1.13.0 - * perf: avoid argument reassignment & argument slice - * perf: avoid negotiator recursive construction - * perf: enable strict mode - * perf: remove unnecessary bitwise operator - -1.2.7 / 2015-05-10 -================== - - * deps: negotiator@0.5.3 - - Fix media type parameter matching to be case-insensitive - -1.2.6 / 2015-05-07 -================== - - * deps: mime-types@~2.0.11 - - deps: mime-db@~1.9.1 - * deps: negotiator@0.5.2 - - Fix comparing media types with quoted values - - Fix splitting media types with quoted commas - -1.2.5 / 2015-03-13 -================== - - * deps: mime-types@~2.0.10 - - deps: mime-db@~1.8.0 - -1.2.4 / 2015-02-14 -================== - - * Support Node.js 0.6 - * deps: mime-types@~2.0.9 - - deps: mime-db@~1.7.0 - * deps: negotiator@0.5.1 - - Fix preference sorting to be stable for long acceptable lists - -1.2.3 / 2015-01-31 -================== - - * deps: mime-types@~2.0.8 - - deps: mime-db@~1.6.0 - -1.2.2 / 2014-12-30 -================== - - * deps: mime-types@~2.0.7 - - deps: mime-db@~1.5.0 - -1.2.1 / 2014-12-30 -================== - - * deps: mime-types@~2.0.5 - - deps: mime-db@~1.3.1 - -1.2.0 / 2014-12-19 -================== - - * deps: negotiator@0.5.0 - - Fix list return order when large accepted list - - Fix missing identity encoding when q=0 exists - - Remove dynamic building of Negotiator class - -1.1.4 / 2014-12-10 -================== - - * deps: mime-types@~2.0.4 - - deps: mime-db@~1.3.0 - -1.1.3 / 2014-11-09 -================== - - * deps: mime-types@~2.0.3 - - deps: mime-db@~1.2.0 - -1.1.2 / 2014-10-14 -================== - - * deps: negotiator@0.4.9 - - Fix error when media type has invalid parameter - -1.1.1 / 2014-09-28 -================== - - * deps: mime-types@~2.0.2 - - deps: mime-db@~1.1.0 - * deps: negotiator@0.4.8 - - Fix all negotiations to be case-insensitive - - Stable sort preferences of same quality according to client order - -1.1.0 / 2014-09-02 -================== - - * update `mime-types` - -1.0.7 / 2014-07-04 -================== - - * Fix wrong type returned from `type` when match after unknown extension - -1.0.6 / 2014-06-24 -================== - - * deps: negotiator@0.4.7 - -1.0.5 / 2014-06-20 -================== - - * fix crash when unknown extension given - -1.0.4 / 2014-06-19 -================== - - * use `mime-types` - -1.0.3 / 2014-06-11 -================== - - * deps: negotiator@0.4.6 - - Order by specificity when quality is the same - -1.0.2 / 2014-05-29 -================== - - * Fix interpretation when header not in request - * deps: pin negotiator@0.4.5 - -1.0.1 / 2014-01-18 -================== - - * Identity encoding isn't always acceptable - * deps: negotiator@~0.4.0 - -1.0.0 / 2013-12-27 -================== - - * Genesis +1.3.3 / 2016-05-02 +================== + + * deps: mime-types@~2.1.11 + - deps: mime-db@~1.23.0 + * deps: negotiator@0.6.1 + - perf: improve `Accept` parsing speed + - perf: improve `Accept-Charset` parsing speed + - perf: improve `Accept-Encoding` parsing speed + - perf: improve `Accept-Language` parsing speed + +1.3.2 / 2016-03-08 +================== + + * deps: mime-types@~2.1.10 + - Fix extension of `application/dash+xml` + - Update primary extension for `audio/mp4` + - deps: mime-db@~1.22.0 + +1.3.1 / 2016-01-19 +================== + + * deps: mime-types@~2.1.9 + - deps: mime-db@~1.21.0 + +1.3.0 / 2015-09-29 +================== + + * deps: mime-types@~2.1.7 + - deps: mime-db@~1.19.0 + * deps: negotiator@0.6.0 + - Fix including type extensions in parameters in `Accept` parsing + - Fix parsing `Accept` parameters with quoted equals + - Fix parsing `Accept` parameters with quoted semicolons + - Lazy-load modules from main entry point + - perf: delay type concatenation until needed + - perf: enable strict mode + - perf: hoist regular expressions + - perf: remove closures getting spec properties + - perf: remove a closure from media type parsing + - perf: remove property delete from media type parsing + +1.2.13 / 2015-09-06 +=================== + + * deps: mime-types@~2.1.6 + - deps: mime-db@~1.18.0 + +1.2.12 / 2015-07-30 +=================== + + * deps: mime-types@~2.1.4 + - deps: mime-db@~1.16.0 + +1.2.11 / 2015-07-16 +=================== + + * deps: mime-types@~2.1.3 + - deps: mime-db@~1.15.0 + +1.2.10 / 2015-07-01 +=================== + + * deps: mime-types@~2.1.2 + - deps: mime-db@~1.14.0 + +1.2.9 / 2015-06-08 +================== + + * deps: mime-types@~2.1.1 + - perf: fix deopt during mapping + +1.2.8 / 2015-06-07 +================== + + * deps: mime-types@~2.1.0 + - deps: mime-db@~1.13.0 + * perf: avoid argument reassignment & argument slice + * perf: avoid negotiator recursive construction + * perf: enable strict mode + * perf: remove unnecessary bitwise operator + +1.2.7 / 2015-05-10 +================== + + * deps: negotiator@0.5.3 + - Fix media type parameter matching to be case-insensitive + +1.2.6 / 2015-05-07 +================== + + * deps: mime-types@~2.0.11 + - deps: mime-db@~1.9.1 + * deps: negotiator@0.5.2 + - Fix comparing media types with quoted values + - Fix splitting media types with quoted commas + +1.2.5 / 2015-03-13 +================== + + * deps: mime-types@~2.0.10 + - deps: mime-db@~1.8.0 + +1.2.4 / 2015-02-14 +================== + + * Support Node.js 0.6 + * deps: mime-types@~2.0.9 + - deps: mime-db@~1.7.0 + * deps: negotiator@0.5.1 + - Fix preference sorting to be stable for long acceptable lists + +1.2.3 / 2015-01-31 +================== + + * deps: mime-types@~2.0.8 + - deps: mime-db@~1.6.0 + +1.2.2 / 2014-12-30 +================== + + * deps: mime-types@~2.0.7 + - deps: mime-db@~1.5.0 + +1.2.1 / 2014-12-30 +================== + + * deps: mime-types@~2.0.5 + - deps: mime-db@~1.3.1 + +1.2.0 / 2014-12-19 +================== + + * deps: negotiator@0.5.0 + - Fix list return order when large accepted list + - Fix missing identity encoding when q=0 exists + - Remove dynamic building of Negotiator class + +1.1.4 / 2014-12-10 +================== + + * deps: mime-types@~2.0.4 + - deps: mime-db@~1.3.0 + +1.1.3 / 2014-11-09 +================== + + * deps: mime-types@~2.0.3 + - deps: mime-db@~1.2.0 + +1.1.2 / 2014-10-14 +================== + + * deps: negotiator@0.4.9 + - Fix error when media type has invalid parameter + +1.1.1 / 2014-09-28 +================== + + * deps: mime-types@~2.0.2 + - deps: mime-db@~1.1.0 + * deps: negotiator@0.4.8 + - Fix all negotiations to be case-insensitive + - Stable sort preferences of same quality according to client order + +1.1.0 / 2014-09-02 +================== + + * update `mime-types` + +1.0.7 / 2014-07-04 +================== + + * Fix wrong type returned from `type` when match after unknown extension + +1.0.6 / 2014-06-24 +================== + + * deps: negotiator@0.4.7 + +1.0.5 / 2014-06-20 +================== + + * fix crash when unknown extension given + +1.0.4 / 2014-06-19 +================== + + * use `mime-types` + +1.0.3 / 2014-06-11 +================== + + * deps: negotiator@0.4.6 + - Order by specificity when quality is the same + +1.0.2 / 2014-05-29 +================== + + * Fix interpretation when header not in request + * deps: pin negotiator@0.4.5 + +1.0.1 / 2014-01-18 +================== + + * Identity encoding isn't always acceptable + * deps: negotiator@~0.4.0 + +1.0.0 / 2013-12-27 +================== + + * Genesis diff --git a/ui/node_modules/express/node_modules/accepts/LICENSE b/ui/node_modules/express/node_modules/accepts/LICENSE index 9bc6a2f9..06166077 100644 --- a/ui/node_modules/express/node_modules/accepts/LICENSE +++ b/ui/node_modules/express/node_modules/accepts/LICENSE @@ -1,23 +1,23 @@ -(The MIT License) - -Copyright (c) 2014 Jonathan Ong -Copyright (c) 2015 Douglas Christopher Wilson - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2014 Jonathan Ong +Copyright (c) 2015 Douglas Christopher Wilson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/accepts/README.md b/ui/node_modules/express/node_modules/accepts/README.md index 3856a0d6..ae36676f 100644 --- a/ui/node_modules/express/node_modules/accepts/README.md +++ b/ui/node_modules/express/node_modules/accepts/README.md @@ -1,135 +1,135 @@ -# accepts - -[![NPM Version][npm-image]][npm-url] -[![NPM Downloads][downloads-image]][downloads-url] -[![Node.js Version][node-version-image]][node-version-url] -[![Build Status][travis-image]][travis-url] -[![Test Coverage][coveralls-image]][coveralls-url] - -Higher level content negotiation based on [negotiator](https://www.npmjs.com/package/negotiator). Extracted from [koa](https://www.npmjs.com/package/koa) for general use. - -In addition to negotiator, it allows: - -- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])` as well as `('text/html', 'application/json')`. -- Allows type shorthands such as `json`. -- Returns `false` when no types match -- Treats non-existent headers as `*` - -## Installation - -```sh -npm install accepts -``` - -## API - -```js -var accepts = require('accepts') -``` - -### accepts(req) - -Create a new `Accepts` object for the given `req`. - -#### .charset(charsets) - -Return the first accepted charset. If nothing in `charsets` is accepted, -then `false` is returned. - -#### .charsets() - -Return the charsets that the request accepts, in the order of the client's -preference (most preferred first). - -#### .encoding(encodings) - -Return the first accepted encoding. If nothing in `encodings` is accepted, -then `false` is returned. - -#### .encodings() - -Return the encodings that the request accepts, in the order of the client's -preference (most preferred first). - -#### .language(languages) - -Return the first accepted language. If nothing in `languages` is accepted, -then `false` is returned. - -#### .languages() - -Return the languages that the request accepts, in the order of the client's -preference (most preferred first). - -#### .type(types) - -Return the first accepted type (and it is returned as the same text as what -appears in the `types` array). If nothing in `types` is accepted, then `false` -is returned. - -The `types` array can contain full MIME types or file extensions. Any value -that is not a full MIME types is passed to `require('mime-types').lookup`. - -#### .types() - -Return the types that the request accepts, in the order of the client's -preference (most preferred first). - -## Examples - -### Simple type negotiation - -This simple example shows how to use `accepts` to return a different typed -respond body based on what the client wants to accept. The server lists it's -preferences in order and will get back the best match between the client and -server. - -```js -var accepts = require('accepts') -var http = require('http') - -function app(req, res) { - var accept = accepts(req) - - // the order of this list is significant; should be server preferred order - switch(accept.type(['json', 'html'])) { - case 'json': - res.setHeader('Content-Type', 'application/json') - res.write('{"hello":"world!"}') - break - case 'html': - res.setHeader('Content-Type', 'text/html') - res.write('hello, world!') - break - default: - // the fallback is text/plain, so no need to specify it above - res.setHeader('Content-Type', 'text/plain') - res.write('hello, world!') - break - } - - res.end() -} - -http.createServer(app).listen(3000) -``` - -You can test this out with the cURL program: -```sh -curl -I -H'Accept: text/html' http://localhost:3000/ -``` - -## License - -[MIT](LICENSE) - -[npm-image]: https://img.shields.io/npm/v/accepts.svg -[npm-url]: https://npmjs.org/package/accepts -[node-version-image]: https://img.shields.io/node/v/accepts.svg -[node-version-url]: http://nodejs.org/download/ -[travis-image]: https://img.shields.io/travis/jshttp/accepts/master.svg -[travis-url]: https://travis-ci.org/jshttp/accepts -[coveralls-image]: https://img.shields.io/coveralls/jshttp/accepts/master.svg -[coveralls-url]: https://coveralls.io/r/jshttp/accepts -[downloads-image]: https://img.shields.io/npm/dm/accepts.svg -[downloads-url]: https://npmjs.org/package/accepts +# accepts + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-version-image]][node-version-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +Higher level content negotiation based on [negotiator](https://www.npmjs.com/package/negotiator). Extracted from [koa](https://www.npmjs.com/package/koa) for general use. + +In addition to negotiator, it allows: + +- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])` as well as `('text/html', 'application/json')`. +- Allows type shorthands such as `json`. +- Returns `false` when no types match +- Treats non-existent headers as `*` + +## Installation + +```sh +npm install accepts +``` + +## API + +```js +var accepts = require('accepts') +``` + +### accepts(req) + +Create a new `Accepts` object for the given `req`. + +#### .charset(charsets) + +Return the first accepted charset. If nothing in `charsets` is accepted, +then `false` is returned. + +#### .charsets() + +Return the charsets that the request accepts, in the order of the client's +preference (most preferred first). + +#### .encoding(encodings) + +Return the first accepted encoding. If nothing in `encodings` is accepted, +then `false` is returned. + +#### .encodings() + +Return the encodings that the request accepts, in the order of the client's +preference (most preferred first). + +#### .language(languages) + +Return the first accepted language. If nothing in `languages` is accepted, +then `false` is returned. + +#### .languages() + +Return the languages that the request accepts, in the order of the client's +preference (most preferred first). + +#### .type(types) + +Return the first accepted type (and it is returned as the same text as what +appears in the `types` array). If nothing in `types` is accepted, then `false` +is returned. + +The `types` array can contain full MIME types or file extensions. Any value +that is not a full MIME types is passed to `require('mime-types').lookup`. + +#### .types() + +Return the types that the request accepts, in the order of the client's +preference (most preferred first). + +## Examples + +### Simple type negotiation + +This simple example shows how to use `accepts` to return a different typed +respond body based on what the client wants to accept. The server lists it's +preferences in order and will get back the best match between the client and +server. + +```js +var accepts = require('accepts') +var http = require('http') + +function app(req, res) { + var accept = accepts(req) + + // the order of this list is significant; should be server preferred order + switch(accept.type(['json', 'html'])) { + case 'json': + res.setHeader('Content-Type', 'application/json') + res.write('{"hello":"world!"}') + break + case 'html': + res.setHeader('Content-Type', 'text/html') + res.write('hello, world!') + break + default: + // the fallback is text/plain, so no need to specify it above + res.setHeader('Content-Type', 'text/plain') + res.write('hello, world!') + break + } + + res.end() +} + +http.createServer(app).listen(3000) +``` + +You can test this out with the cURL program: +```sh +curl -I -H'Accept: text/html' http://localhost:3000/ +``` + +## License + +[MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/accepts.svg +[npm-url]: https://npmjs.org/package/accepts +[node-version-image]: https://img.shields.io/node/v/accepts.svg +[node-version-url]: http://nodejs.org/download/ +[travis-image]: https://img.shields.io/travis/jshttp/accepts/master.svg +[travis-url]: https://travis-ci.org/jshttp/accepts +[coveralls-image]: https://img.shields.io/coveralls/jshttp/accepts/master.svg +[coveralls-url]: https://coveralls.io/r/jshttp/accepts +[downloads-image]: https://img.shields.io/npm/dm/accepts.svg +[downloads-url]: https://npmjs.org/package/accepts diff --git a/ui/node_modules/express/node_modules/accepts/index.js b/ui/node_modules/express/node_modules/accepts/index.js index 625c2d43..e80192ab 100644 --- a/ui/node_modules/express/node_modules/accepts/index.js +++ b/ui/node_modules/express/node_modules/accepts/index.js @@ -1,231 +1,231 @@ -/*! - * accepts - * Copyright(c) 2014 Jonathan Ong - * Copyright(c) 2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict' - -/** - * Module dependencies. - * @private - */ - -var Negotiator = require('negotiator') -var mime = require('mime-types') - -/** - * Module exports. - * @public - */ - -module.exports = Accepts - -/** - * Create a new Accepts object for the given req. - * - * @param {object} req - * @public - */ - -function Accepts(req) { - if (!(this instanceof Accepts)) - return new Accepts(req) - - this.headers = req.headers - this.negotiator = new Negotiator(req) -} - -/** - * Check if the given `type(s)` is acceptable, returning - * the best match when true, otherwise `undefined`, in which - * case you should respond with 406 "Not Acceptable". - * - * The `type` value may be a single mime type string - * such as "application/json", the extension name - * such as "json" or an array `["json", "html", "text/plain"]`. When a list - * or array is given the _best_ match, if any is returned. - * - * Examples: - * - * // Accept: text/html - * this.types('html'); - * // => "html" - * - * // Accept: text/*, application/json - * this.types('html'); - * // => "html" - * this.types('text/html'); - * // => "text/html" - * this.types('json', 'text'); - * // => "json" - * this.types('application/json'); - * // => "application/json" - * - * // Accept: text/*, application/json - * this.types('image/png'); - * this.types('png'); - * // => undefined - * - * // Accept: text/*;q=.5, application/json - * this.types(['html', 'json']); - * this.types('html', 'json'); - * // => "json" - * - * @param {String|Array} types... - * @return {String|Array|Boolean} - * @public - */ - -Accepts.prototype.type = -Accepts.prototype.types = function (types_) { - var types = types_ - - // support flattened arguments - if (types && !Array.isArray(types)) { - types = new Array(arguments.length) - for (var i = 0; i < types.length; i++) { - types[i] = arguments[i] - } - } - - // no types, return all requested types - if (!types || types.length === 0) { - return this.negotiator.mediaTypes() - } - - if (!this.headers.accept) return types[0]; - var mimes = types.map(extToMime); - var accepts = this.negotiator.mediaTypes(mimes.filter(validMime)); - var first = accepts[0]; - if (!first) return false; - return types[mimes.indexOf(first)]; -} - -/** - * Return accepted encodings or best fit based on `encodings`. - * - * Given `Accept-Encoding: gzip, deflate` - * an array sorted by quality is returned: - * - * ['gzip', 'deflate'] - * - * @param {String|Array} encodings... - * @return {String|Array} - * @public - */ - -Accepts.prototype.encoding = -Accepts.prototype.encodings = function (encodings_) { - var encodings = encodings_ - - // support flattened arguments - if (encodings && !Array.isArray(encodings)) { - encodings = new Array(arguments.length) - for (var i = 0; i < encodings.length; i++) { - encodings[i] = arguments[i] - } - } - - // no encodings, return all requested encodings - if (!encodings || encodings.length === 0) { - return this.negotiator.encodings() - } - - return this.negotiator.encodings(encodings)[0] || false -} - -/** - * Return accepted charsets or best fit based on `charsets`. - * - * Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5` - * an array sorted by quality is returned: - * - * ['utf-8', 'utf-7', 'iso-8859-1'] - * - * @param {String|Array} charsets... - * @return {String|Array} - * @public - */ - -Accepts.prototype.charset = -Accepts.prototype.charsets = function (charsets_) { - var charsets = charsets_ - - // support flattened arguments - if (charsets && !Array.isArray(charsets)) { - charsets = new Array(arguments.length) - for (var i = 0; i < charsets.length; i++) { - charsets[i] = arguments[i] - } - } - - // no charsets, return all requested charsets - if (!charsets || charsets.length === 0) { - return this.negotiator.charsets() - } - - return this.negotiator.charsets(charsets)[0] || false -} - -/** - * Return accepted languages or best fit based on `langs`. - * - * Given `Accept-Language: en;q=0.8, es, pt` - * an array sorted by quality is returned: - * - * ['es', 'pt', 'en'] - * - * @param {String|Array} langs... - * @return {Array|String} - * @public - */ - -Accepts.prototype.lang = -Accepts.prototype.langs = -Accepts.prototype.language = -Accepts.prototype.languages = function (languages_) { - var languages = languages_ - - // support flattened arguments - if (languages && !Array.isArray(languages)) { - languages = new Array(arguments.length) - for (var i = 0; i < languages.length; i++) { - languages[i] = arguments[i] - } - } - - // no languages, return all requested languages - if (!languages || languages.length === 0) { - return this.negotiator.languages() - } - - return this.negotiator.languages(languages)[0] || false -} - -/** - * Convert extnames to mime. - * - * @param {String} type - * @return {String} - * @private - */ - -function extToMime(type) { - return type.indexOf('/') === -1 - ? mime.lookup(type) - : type -} - -/** - * Check if mime is valid. - * - * @param {String} type - * @return {String} - * @private - */ - -function validMime(type) { - return typeof type === 'string'; -} +/*! + * accepts + * Copyright(c) 2014 Jonathan Ong + * Copyright(c) 2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module dependencies. + * @private + */ + +var Negotiator = require('negotiator') +var mime = require('mime-types') + +/** + * Module exports. + * @public + */ + +module.exports = Accepts + +/** + * Create a new Accepts object for the given req. + * + * @param {object} req + * @public + */ + +function Accepts(req) { + if (!(this instanceof Accepts)) + return new Accepts(req) + + this.headers = req.headers + this.negotiator = new Negotiator(req) +} + +/** + * Check if the given `type(s)` is acceptable, returning + * the best match when true, otherwise `undefined`, in which + * case you should respond with 406 "Not Acceptable". + * + * The `type` value may be a single mime type string + * such as "application/json", the extension name + * such as "json" or an array `["json", "html", "text/plain"]`. When a list + * or array is given the _best_ match, if any is returned. + * + * Examples: + * + * // Accept: text/html + * this.types('html'); + * // => "html" + * + * // Accept: text/*, application/json + * this.types('html'); + * // => "html" + * this.types('text/html'); + * // => "text/html" + * this.types('json', 'text'); + * // => "json" + * this.types('application/json'); + * // => "application/json" + * + * // Accept: text/*, application/json + * this.types('image/png'); + * this.types('png'); + * // => undefined + * + * // Accept: text/*;q=.5, application/json + * this.types(['html', 'json']); + * this.types('html', 'json'); + * // => "json" + * + * @param {String|Array} types... + * @return {String|Array|Boolean} + * @public + */ + +Accepts.prototype.type = +Accepts.prototype.types = function (types_) { + var types = types_ + + // support flattened arguments + if (types && !Array.isArray(types)) { + types = new Array(arguments.length) + for (var i = 0; i < types.length; i++) { + types[i] = arguments[i] + } + } + + // no types, return all requested types + if (!types || types.length === 0) { + return this.negotiator.mediaTypes() + } + + if (!this.headers.accept) return types[0]; + var mimes = types.map(extToMime); + var accepts = this.negotiator.mediaTypes(mimes.filter(validMime)); + var first = accepts[0]; + if (!first) return false; + return types[mimes.indexOf(first)]; +} + +/** + * Return accepted encodings or best fit based on `encodings`. + * + * Given `Accept-Encoding: gzip, deflate` + * an array sorted by quality is returned: + * + * ['gzip', 'deflate'] + * + * @param {String|Array} encodings... + * @return {String|Array} + * @public + */ + +Accepts.prototype.encoding = +Accepts.prototype.encodings = function (encodings_) { + var encodings = encodings_ + + // support flattened arguments + if (encodings && !Array.isArray(encodings)) { + encodings = new Array(arguments.length) + for (var i = 0; i < encodings.length; i++) { + encodings[i] = arguments[i] + } + } + + // no encodings, return all requested encodings + if (!encodings || encodings.length === 0) { + return this.negotiator.encodings() + } + + return this.negotiator.encodings(encodings)[0] || false +} + +/** + * Return accepted charsets or best fit based on `charsets`. + * + * Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5` + * an array sorted by quality is returned: + * + * ['utf-8', 'utf-7', 'iso-8859-1'] + * + * @param {String|Array} charsets... + * @return {String|Array} + * @public + */ + +Accepts.prototype.charset = +Accepts.prototype.charsets = function (charsets_) { + var charsets = charsets_ + + // support flattened arguments + if (charsets && !Array.isArray(charsets)) { + charsets = new Array(arguments.length) + for (var i = 0; i < charsets.length; i++) { + charsets[i] = arguments[i] + } + } + + // no charsets, return all requested charsets + if (!charsets || charsets.length === 0) { + return this.negotiator.charsets() + } + + return this.negotiator.charsets(charsets)[0] || false +} + +/** + * Return accepted languages or best fit based on `langs`. + * + * Given `Accept-Language: en;q=0.8, es, pt` + * an array sorted by quality is returned: + * + * ['es', 'pt', 'en'] + * + * @param {String|Array} langs... + * @return {Array|String} + * @public + */ + +Accepts.prototype.lang = +Accepts.prototype.langs = +Accepts.prototype.language = +Accepts.prototype.languages = function (languages_) { + var languages = languages_ + + // support flattened arguments + if (languages && !Array.isArray(languages)) { + languages = new Array(arguments.length) + for (var i = 0; i < languages.length; i++) { + languages[i] = arguments[i] + } + } + + // no languages, return all requested languages + if (!languages || languages.length === 0) { + return this.negotiator.languages() + } + + return this.negotiator.languages(languages)[0] || false +} + +/** + * Convert extnames to mime. + * + * @param {String} type + * @return {String} + * @private + */ + +function extToMime(type) { + return type.indexOf('/') === -1 + ? mime.lookup(type) + : type +} + +/** + * Check if mime is valid. + * + * @param {String} type + * @return {String} + * @private + */ + +function validMime(type) { + return typeof type === 'string'; +} diff --git a/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/HISTORY.md b/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/HISTORY.md index 5a848496..63bd4ea0 100644 --- a/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/HISTORY.md +++ b/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/HISTORY.md @@ -1,197 +1,197 @@ -2.1.11 / 2016-05-01 -=================== - - * deps: mime-db@~1.23.0 - - Add new mime types - -2.1.10 / 2016-02-15 -=================== - - * deps: mime-db@~1.22.0 - - Add new mime types - - Fix extension of `application/dash+xml` - - Update primary extension for `audio/mp4` - -2.1.9 / 2016-01-06 -================== - - * deps: mime-db@~1.21.0 - - Add new mime types - -2.1.8 / 2015-11-30 -================== - - * deps: mime-db@~1.20.0 - - Add new mime types - -2.1.7 / 2015-09-20 -================== - - * deps: mime-db@~1.19.0 - - Add new mime types - -2.1.6 / 2015-09-03 -================== - - * deps: mime-db@~1.18.0 - - Add new mime types - -2.1.5 / 2015-08-20 -================== - - * deps: mime-db@~1.17.0 - - Add new mime types - -2.1.4 / 2015-07-30 -================== - - * deps: mime-db@~1.16.0 - - Add new mime types - -2.1.3 / 2015-07-13 -================== - - * deps: mime-db@~1.15.0 - - Add new mime types - -2.1.2 / 2015-06-25 -================== - - * deps: mime-db@~1.14.0 - - Add new mime types - -2.1.1 / 2015-06-08 -================== - - * perf: fix deopt during mapping - -2.1.0 / 2015-06-07 -================== - - * Fix incorrectly treating extension-less file name as extension - - i.e. `'path/to/json'` will no longer return `application/json` - * Fix `.charset(type)` to accept parameters - * Fix `.charset(type)` to match case-insensitive - * Improve generation of extension to MIME mapping - * Refactor internals for readability and no argument reassignment - * Prefer `application/*` MIME types from the same source - * Prefer any type over `application/octet-stream` - * deps: mime-db@~1.13.0 - - Add nginx as a source - - Add new mime types - -2.0.14 / 2015-06-06 -=================== - - * deps: mime-db@~1.12.0 - - Add new mime types - -2.0.13 / 2015-05-31 -=================== - - * deps: mime-db@~1.11.0 - - Add new mime types - -2.0.12 / 2015-05-19 -=================== - - * deps: mime-db@~1.10.0 - - Add new mime types - -2.0.11 / 2015-05-05 -=================== - - * deps: mime-db@~1.9.1 - - Add new mime types - -2.0.10 / 2015-03-13 -=================== - - * deps: mime-db@~1.8.0 - - Add new mime types - -2.0.9 / 2015-02-09 -================== - - * deps: mime-db@~1.7.0 - - Add new mime types - - Community extensions ownership transferred from `node-mime` - -2.0.8 / 2015-01-29 -================== - - * deps: mime-db@~1.6.0 - - Add new mime types - -2.0.7 / 2014-12-30 -================== - - * deps: mime-db@~1.5.0 - - Add new mime types - - Fix various invalid MIME type entries - -2.0.6 / 2014-12-30 -================== - - * deps: mime-db@~1.4.0 - - Add new mime types - - Fix various invalid MIME type entries - - Remove example template MIME types - -2.0.5 / 2014-12-29 -================== - - * deps: mime-db@~1.3.1 - - Fix missing extensions - -2.0.4 / 2014-12-10 -================== - - * deps: mime-db@~1.3.0 - - Add new mime types - -2.0.3 / 2014-11-09 -================== - - * deps: mime-db@~1.2.0 - - Add new mime types - -2.0.2 / 2014-09-28 -================== - - * deps: mime-db@~1.1.0 - - Add new mime types - - Add additional compressible - - Update charsets - -2.0.1 / 2014-09-07 -================== - - * Support Node.js 0.6 - -2.0.0 / 2014-09-02 -================== - - * Use `mime-db` - * Remove `.define()` - -1.0.2 / 2014-08-04 -================== - - * Set charset=utf-8 for `text/javascript` - -1.0.1 / 2014-06-24 -================== - - * Add `text/jsx` type - -1.0.0 / 2014-05-12 -================== - - * Return `false` for unknown types - * Set charset=utf-8 for `application/json` - -0.1.0 / 2014-05-02 -================== - - * Initial release +2.1.11 / 2016-05-01 +=================== + + * deps: mime-db@~1.23.0 + - Add new mime types + +2.1.10 / 2016-02-15 +=================== + + * deps: mime-db@~1.22.0 + - Add new mime types + - Fix extension of `application/dash+xml` + - Update primary extension for `audio/mp4` + +2.1.9 / 2016-01-06 +================== + + * deps: mime-db@~1.21.0 + - Add new mime types + +2.1.8 / 2015-11-30 +================== + + * deps: mime-db@~1.20.0 + - Add new mime types + +2.1.7 / 2015-09-20 +================== + + * deps: mime-db@~1.19.0 + - Add new mime types + +2.1.6 / 2015-09-03 +================== + + * deps: mime-db@~1.18.0 + - Add new mime types + +2.1.5 / 2015-08-20 +================== + + * deps: mime-db@~1.17.0 + - Add new mime types + +2.1.4 / 2015-07-30 +================== + + * deps: mime-db@~1.16.0 + - Add new mime types + +2.1.3 / 2015-07-13 +================== + + * deps: mime-db@~1.15.0 + - Add new mime types + +2.1.2 / 2015-06-25 +================== + + * deps: mime-db@~1.14.0 + - Add new mime types + +2.1.1 / 2015-06-08 +================== + + * perf: fix deopt during mapping + +2.1.0 / 2015-06-07 +================== + + * Fix incorrectly treating extension-less file name as extension + - i.e. `'path/to/json'` will no longer return `application/json` + * Fix `.charset(type)` to accept parameters + * Fix `.charset(type)` to match case-insensitive + * Improve generation of extension to MIME mapping + * Refactor internals for readability and no argument reassignment + * Prefer `application/*` MIME types from the same source + * Prefer any type over `application/octet-stream` + * deps: mime-db@~1.13.0 + - Add nginx as a source + - Add new mime types + +2.0.14 / 2015-06-06 +=================== + + * deps: mime-db@~1.12.0 + - Add new mime types + +2.0.13 / 2015-05-31 +=================== + + * deps: mime-db@~1.11.0 + - Add new mime types + +2.0.12 / 2015-05-19 +=================== + + * deps: mime-db@~1.10.0 + - Add new mime types + +2.0.11 / 2015-05-05 +=================== + + * deps: mime-db@~1.9.1 + - Add new mime types + +2.0.10 / 2015-03-13 +=================== + + * deps: mime-db@~1.8.0 + - Add new mime types + +2.0.9 / 2015-02-09 +================== + + * deps: mime-db@~1.7.0 + - Add new mime types + - Community extensions ownership transferred from `node-mime` + +2.0.8 / 2015-01-29 +================== + + * deps: mime-db@~1.6.0 + - Add new mime types + +2.0.7 / 2014-12-30 +================== + + * deps: mime-db@~1.5.0 + - Add new mime types + - Fix various invalid MIME type entries + +2.0.6 / 2014-12-30 +================== + + * deps: mime-db@~1.4.0 + - Add new mime types + - Fix various invalid MIME type entries + - Remove example template MIME types + +2.0.5 / 2014-12-29 +================== + + * deps: mime-db@~1.3.1 + - Fix missing extensions + +2.0.4 / 2014-12-10 +================== + + * deps: mime-db@~1.3.0 + - Add new mime types + +2.0.3 / 2014-11-09 +================== + + * deps: mime-db@~1.2.0 + - Add new mime types + +2.0.2 / 2014-09-28 +================== + + * deps: mime-db@~1.1.0 + - Add new mime types + - Add additional compressible + - Update charsets + +2.0.1 / 2014-09-07 +================== + + * Support Node.js 0.6 + +2.0.0 / 2014-09-02 +================== + + * Use `mime-db` + * Remove `.define()` + +1.0.2 / 2014-08-04 +================== + + * Set charset=utf-8 for `text/javascript` + +1.0.1 / 2014-06-24 +================== + + * Add `text/jsx` type + +1.0.0 / 2014-05-12 +================== + + * Return `false` for unknown types + * Set charset=utf-8 for `application/json` + +0.1.0 / 2014-05-02 +================== + + * Initial release diff --git a/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/LICENSE b/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/LICENSE index 9bc6a2f9..06166077 100644 --- a/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/LICENSE +++ b/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/LICENSE @@ -1,23 +1,23 @@ -(The MIT License) - -Copyright (c) 2014 Jonathan Ong -Copyright (c) 2015 Douglas Christopher Wilson - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2014 Jonathan Ong +Copyright (c) 2015 Douglas Christopher Wilson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/README.md b/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/README.md index 38c11cc6..e77d615d 100644 --- a/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/README.md +++ b/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/README.md @@ -1,103 +1,103 @@ -# mime-types - -[![NPM Version][npm-image]][npm-url] -[![NPM Downloads][downloads-image]][downloads-url] -[![Node.js Version][node-version-image]][node-version-url] -[![Build Status][travis-image]][travis-url] -[![Test Coverage][coveralls-image]][coveralls-url] - -The ultimate javascript content-type utility. - -Similar to [node-mime](https://github.com/broofa/node-mime), except: - -- __No fallbacks.__ Instead of naively returning the first available type, `mime-types` simply returns `false`, - so do `var type = mime.lookup('unrecognized') || 'application/octet-stream'`. -- No `new Mime()` business, so you could do `var lookup = require('mime-types').lookup`. -- Additional mime types are added such as jade and stylus via [mime-db](https://github.com/jshttp/mime-db) -- No `.define()` functionality - -Otherwise, the API is compatible. - -## Install - -```sh -$ npm install mime-types -``` - -## Adding Types - -All mime types are based on [mime-db](https://github.com/jshttp/mime-db), -so open a PR there if you'd like to add mime types. - -## API - -```js -var mime = require('mime-types') -``` - -All functions return `false` if input is invalid or not found. - -### mime.lookup(path) - -Lookup the content-type associated with a file. - -```js -mime.lookup('json') // 'application/json' -mime.lookup('.md') // 'text/x-markdown' -mime.lookup('file.html') // 'text/html' -mime.lookup('folder/file.js') // 'application/javascript' -mime.lookup('folder/.htaccess') // false - -mime.lookup('cats') // false -``` - -### mime.contentType(type) - -Create a full content-type header given a content-type or extension. - -```js -mime.contentType('markdown') // 'text/x-markdown; charset=utf-8' -mime.contentType('file.json') // 'application/json; charset=utf-8' - -// from a full path -mime.contentType(path.extname('/path/to/file.json')) // 'application/json; charset=utf-8' -``` - -### mime.extension(type) - -Get the default extension for a content-type. - -```js -mime.extension('application/octet-stream') // 'bin' -``` - -### mime.charset(type) - -Lookup the implied default charset of a content-type. - -```js -mime.charset('text/x-markdown') // 'UTF-8' -``` - -### var type = mime.types[extension] - -A map of content-types by extension. - -### [extensions...] = mime.extensions[type] - -A map of extensions by content-type. - -## License - -[MIT](LICENSE) - -[npm-image]: https://img.shields.io/npm/v/mime-types.svg -[npm-url]: https://npmjs.org/package/mime-types -[node-version-image]: https://img.shields.io/node/v/mime-types.svg -[node-version-url]: https://nodejs.org/en/download/ -[travis-image]: https://img.shields.io/travis/jshttp/mime-types/master.svg -[travis-url]: https://travis-ci.org/jshttp/mime-types -[coveralls-image]: https://img.shields.io/coveralls/jshttp/mime-types/master.svg -[coveralls-url]: https://coveralls.io/r/jshttp/mime-types -[downloads-image]: https://img.shields.io/npm/dm/mime-types.svg -[downloads-url]: https://npmjs.org/package/mime-types +# mime-types + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-version-image]][node-version-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +The ultimate javascript content-type utility. + +Similar to [node-mime](https://github.com/broofa/node-mime), except: + +- __No fallbacks.__ Instead of naively returning the first available type, `mime-types` simply returns `false`, + so do `var type = mime.lookup('unrecognized') || 'application/octet-stream'`. +- No `new Mime()` business, so you could do `var lookup = require('mime-types').lookup`. +- Additional mime types are added such as jade and stylus via [mime-db](https://github.com/jshttp/mime-db) +- No `.define()` functionality + +Otherwise, the API is compatible. + +## Install + +```sh +$ npm install mime-types +``` + +## Adding Types + +All mime types are based on [mime-db](https://github.com/jshttp/mime-db), +so open a PR there if you'd like to add mime types. + +## API + +```js +var mime = require('mime-types') +``` + +All functions return `false` if input is invalid or not found. + +### mime.lookup(path) + +Lookup the content-type associated with a file. + +```js +mime.lookup('json') // 'application/json' +mime.lookup('.md') // 'text/x-markdown' +mime.lookup('file.html') // 'text/html' +mime.lookup('folder/file.js') // 'application/javascript' +mime.lookup('folder/.htaccess') // false + +mime.lookup('cats') // false +``` + +### mime.contentType(type) + +Create a full content-type header given a content-type or extension. + +```js +mime.contentType('markdown') // 'text/x-markdown; charset=utf-8' +mime.contentType('file.json') // 'application/json; charset=utf-8' + +// from a full path +mime.contentType(path.extname('/path/to/file.json')) // 'application/json; charset=utf-8' +``` + +### mime.extension(type) + +Get the default extension for a content-type. + +```js +mime.extension('application/octet-stream') // 'bin' +``` + +### mime.charset(type) + +Lookup the implied default charset of a content-type. + +```js +mime.charset('text/x-markdown') // 'UTF-8' +``` + +### var type = mime.types[extension] + +A map of content-types by extension. + +### [extensions...] = mime.extensions[type] + +A map of extensions by content-type. + +## License + +[MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/mime-types.svg +[npm-url]: https://npmjs.org/package/mime-types +[node-version-image]: https://img.shields.io/node/v/mime-types.svg +[node-version-url]: https://nodejs.org/en/download/ +[travis-image]: https://img.shields.io/travis/jshttp/mime-types/master.svg +[travis-url]: https://travis-ci.org/jshttp/mime-types +[coveralls-image]: https://img.shields.io/coveralls/jshttp/mime-types/master.svg +[coveralls-url]: https://coveralls.io/r/jshttp/mime-types +[downloads-image]: https://img.shields.io/npm/dm/mime-types.svg +[downloads-url]: https://npmjs.org/package/mime-types diff --git a/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/index.js b/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/index.js index ac47d8d8..f7008b24 100644 --- a/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/index.js +++ b/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/index.js @@ -1,188 +1,188 @@ -/*! - * mime-types - * Copyright(c) 2014 Jonathan Ong - * Copyright(c) 2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict' - -/** - * Module dependencies. - * @private - */ - -var db = require('mime-db') -var extname = require('path').extname - -/** - * Module variables. - * @private - */ - -var extractTypeRegExp = /^\s*([^;\s]*)(?:;|\s|$)/ -var textTypeRegExp = /^text\//i - -/** - * Module exports. - * @public - */ - -exports.charset = charset -exports.charsets = { lookup: charset } -exports.contentType = contentType -exports.extension = extension -exports.extensions = Object.create(null) -exports.lookup = lookup -exports.types = Object.create(null) - -// Populate the extensions/types maps -populateMaps(exports.extensions, exports.types) - -/** - * Get the default charset for a MIME type. - * - * @param {string} type - * @return {boolean|string} - */ - -function charset(type) { - if (!type || typeof type !== 'string') { - return false - } - - // TODO: use media-typer - var match = extractTypeRegExp.exec(type) - var mime = match && db[match[1].toLowerCase()] - - if (mime && mime.charset) { - return mime.charset - } - - // default text/* to utf-8 - if (match && textTypeRegExp.test(match[1])) { - return 'UTF-8' - } - - return false -} - -/** - * Create a full Content-Type header given a MIME type or extension. - * - * @param {string} str - * @return {boolean|string} - */ - -function contentType(str) { - // TODO: should this even be in this module? - if (!str || typeof str !== 'string') { - return false - } - - var mime = str.indexOf('/') === -1 - ? exports.lookup(str) - : str - - if (!mime) { - return false - } - - // TODO: use content-type or other module - if (mime.indexOf('charset') === -1) { - var charset = exports.charset(mime) - if (charset) mime += '; charset=' + charset.toLowerCase() - } - - return mime -} - -/** - * Get the default extension for a MIME type. - * - * @param {string} type - * @return {boolean|string} - */ - -function extension(type) { - if (!type || typeof type !== 'string') { - return false - } - - // TODO: use media-typer - var match = extractTypeRegExp.exec(type) - - // get extensions - var exts = match && exports.extensions[match[1].toLowerCase()] - - if (!exts || !exts.length) { - return false - } - - return exts[0] -} - -/** - * Lookup the MIME type for a file path/extension. - * - * @param {string} path - * @return {boolean|string} - */ - -function lookup(path) { - if (!path || typeof path !== 'string') { - return false - } - - // get the extension ("ext" or ".ext" or full path) - var extension = extname('x.' + path) - .toLowerCase() - .substr(1) - - if (!extension) { - return false - } - - return exports.types[extension] || false -} - -/** - * Populate the extensions and types maps. - * @private - */ - -function populateMaps(extensions, types) { - // source preference (least -> most) - var preference = ['nginx', 'apache', undefined, 'iana'] - - Object.keys(db).forEach(function forEachMimeType(type) { - var mime = db[type] - var exts = mime.extensions - - if (!exts || !exts.length) { - return - } - - // mime -> extensions - extensions[type] = exts - - // extension -> mime - for (var i = 0; i < exts.length; i++) { - var extension = exts[i] - - if (types[extension]) { - var from = preference.indexOf(db[types[extension]].source) - var to = preference.indexOf(mime.source) - - if (types[extension] !== 'application/octet-stream' - && from > to || (from === to && types[extension].substr(0, 12) === 'application/')) { - // skip the remapping - continue - } - } - - // set the extension -> mime - types[extension] = type - } - }) -} +/*! + * mime-types + * Copyright(c) 2014 Jonathan Ong + * Copyright(c) 2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module dependencies. + * @private + */ + +var db = require('mime-db') +var extname = require('path').extname + +/** + * Module variables. + * @private + */ + +var extractTypeRegExp = /^\s*([^;\s]*)(?:;|\s|$)/ +var textTypeRegExp = /^text\//i + +/** + * Module exports. + * @public + */ + +exports.charset = charset +exports.charsets = { lookup: charset } +exports.contentType = contentType +exports.extension = extension +exports.extensions = Object.create(null) +exports.lookup = lookup +exports.types = Object.create(null) + +// Populate the extensions/types maps +populateMaps(exports.extensions, exports.types) + +/** + * Get the default charset for a MIME type. + * + * @param {string} type + * @return {boolean|string} + */ + +function charset(type) { + if (!type || typeof type !== 'string') { + return false + } + + // TODO: use media-typer + var match = extractTypeRegExp.exec(type) + var mime = match && db[match[1].toLowerCase()] + + if (mime && mime.charset) { + return mime.charset + } + + // default text/* to utf-8 + if (match && textTypeRegExp.test(match[1])) { + return 'UTF-8' + } + + return false +} + +/** + * Create a full Content-Type header given a MIME type or extension. + * + * @param {string} str + * @return {boolean|string} + */ + +function contentType(str) { + // TODO: should this even be in this module? + if (!str || typeof str !== 'string') { + return false + } + + var mime = str.indexOf('/') === -1 + ? exports.lookup(str) + : str + + if (!mime) { + return false + } + + // TODO: use content-type or other module + if (mime.indexOf('charset') === -1) { + var charset = exports.charset(mime) + if (charset) mime += '; charset=' + charset.toLowerCase() + } + + return mime +} + +/** + * Get the default extension for a MIME type. + * + * @param {string} type + * @return {boolean|string} + */ + +function extension(type) { + if (!type || typeof type !== 'string') { + return false + } + + // TODO: use media-typer + var match = extractTypeRegExp.exec(type) + + // get extensions + var exts = match && exports.extensions[match[1].toLowerCase()] + + if (!exts || !exts.length) { + return false + } + + return exts[0] +} + +/** + * Lookup the MIME type for a file path/extension. + * + * @param {string} path + * @return {boolean|string} + */ + +function lookup(path) { + if (!path || typeof path !== 'string') { + return false + } + + // get the extension ("ext" or ".ext" or full path) + var extension = extname('x.' + path) + .toLowerCase() + .substr(1) + + if (!extension) { + return false + } + + return exports.types[extension] || false +} + +/** + * Populate the extensions and types maps. + * @private + */ + +function populateMaps(extensions, types) { + // source preference (least -> most) + var preference = ['nginx', 'apache', undefined, 'iana'] + + Object.keys(db).forEach(function forEachMimeType(type) { + var mime = db[type] + var exts = mime.extensions + + if (!exts || !exts.length) { + return + } + + // mime -> extensions + extensions[type] = exts + + // extension -> mime + for (var i = 0; i < exts.length; i++) { + var extension = exts[i] + + if (types[extension]) { + var from = preference.indexOf(db[types[extension]].source) + var to = preference.indexOf(mime.source) + + if (types[extension] !== 'application/octet-stream' + && from > to || (from === to && types[extension].substr(0, 12) === 'application/')) { + // skip the remapping + continue + } + } + + // set the extension -> mime + types[extension] = type + } + }) +} diff --git a/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/HISTORY.md b/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/HISTORY.md index 5dc6326a..d6705ac8 100644 --- a/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/HISTORY.md +++ b/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/HISTORY.md @@ -1,341 +1,341 @@ -1.23.0 / 2016-05-01 -=================== - - * Add `application/efi` - * Add `application/vnd.3gpp.sms+xml` - * Add `application/vnd.3lightssoftware.imagescal` - * Add `application/vnd.coreos.ignition+json` - * Add `application/vnd.desmume.movie` - * Add `application/vnd.onepager` - * Add `application/vnd.vel+json` - * Add `text/prs.prop.logic` - * Add `video/encaprtp` - * Add `video/h265` - * Add `video/iso.segment` - * Add `video/raptorfec` - * Add `video/rtploopback` - * Add `video/vnd.radgamettools.bink` - * Add `video/vnd.radgamettools.smacker` - * Add `video/vp8` - * Add extension `.3gpp` to `audio/3gpp` - -1.22.0 / 2016-02-15 -=================== - - * Add `application/ppsp-tracker+json` - * Add `application/problem+json` - * Add `application/problem+xml` - * Add `application/vnd.hdt` - * Add `application/vnd.ms-printschematicket+xml` - * Add `model/vnd.rosette.annotated-data-model` - * Add `text/slim` - * Add extension `.rng` to `application/xml` - * Fix extension of `application/dash+xml` to be `.mpd` - * Update primary extension to `.m4a` for `audio/mp4` - -1.21.0 / 2016-01-06 -=================== - - * Add `application/emergencycalldata.comment+xml` - * Add `application/emergencycalldata.deviceinfo+xml` - * Add `application/emergencycalldata.providerinfo+xml` - * Add `application/emergencycalldata.serviceinfo+xml` - * Add `application/emergencycalldata.subscriberinfo+xml` - * Add `application/vnd.filmit.zfc` - * Add `application/vnd.google-apps.document` - * Add `application/vnd.google-apps.presentation` - * Add `application/vnd.google-apps.spreadsheet` - * Add `application/vnd.mapbox-vector-tile` - * Add `application/vnd.ms-printdevicecapabilities+xml` - * Add `application/vnd.ms-windows.devicepairing` - * Add `application/vnd.ms-windows.nwprinting.oob` - * Add `application/vnd.tml` - * Add `audio/evs` - -1.20.0 / 2015-11-10 -=================== - - * Add `application/cdni` - * Add `application/csvm+json` - * Add `application/rfc+xml` - * Add `application/vnd.3gpp.access-transfer-events+xml` - * Add `application/vnd.3gpp.srvcc-ext+xml` - * Add `application/vnd.ms-windows.wsd.oob` - * Add `application/vnd.oxli.countgraph` - * Add `application/vnd.pagerduty+json` - * Add `text/x-suse-ymp` - -1.19.0 / 2015-09-17 -=================== - - * Add `application/vnd.3gpp-prose-pc3ch+xml` - * Add `application/vnd.3gpp.srvcc-info+xml` - * Add `application/vnd.apple.pkpass` - * Add `application/vnd.drive+json` - -1.18.0 / 2015-09-03 -=================== - - * Add `application/pkcs12` - * Add `application/vnd.3gpp-prose+xml` - * Add `application/vnd.3gpp.mid-call+xml` - * Add `application/vnd.3gpp.state-and-event-info+xml` - * Add `application/vnd.anki` - * Add `application/vnd.firemonkeys.cloudcell` - * Add `application/vnd.openblox.game+xml` - * Add `application/vnd.openblox.game-binary` - -1.17.0 / 2015-08-13 -=================== - - * Add `application/x-msdos-program` - * Add `audio/g711-0` - * Add `image/vnd.mozilla.apng` - * Add extension `.exe` to `application/x-msdos-program` - -1.16.0 / 2015-07-29 -=================== - - * Add `application/vnd.uri-map` - -1.15.0 / 2015-07-13 -=================== - - * Add `application/x-httpd-php` - -1.14.0 / 2015-06-25 -=================== - - * Add `application/scim+json` - * Add `application/vnd.3gpp.ussd+xml` - * Add `application/vnd.biopax.rdf+xml` - * Add `text/x-processing` - -1.13.0 / 2015-06-07 -=================== - - * Add nginx as a source - * Add `application/x-cocoa` - * Add `application/x-java-archive-diff` - * Add `application/x-makeself` - * Add `application/x-perl` - * Add `application/x-pilot` - * Add `application/x-redhat-package-manager` - * Add `application/x-sea` - * Add `audio/x-m4a` - * Add `audio/x-realaudio` - * Add `image/x-jng` - * Add `text/mathml` - -1.12.0 / 2015-06-05 -=================== - - * Add `application/bdoc` - * Add `application/vnd.hyperdrive+json` - * Add `application/x-bdoc` - * Add extension `.rtf` to `text/rtf` - -1.11.0 / 2015-05-31 -=================== - - * Add `audio/wav` - * Add `audio/wave` - * Add extension `.litcoffee` to `text/coffeescript` - * Add extension `.sfd-hdstx` to `application/vnd.hydrostatix.sof-data` - * Add extension `.n-gage` to `application/vnd.nokia.n-gage.symbian.install` - -1.10.0 / 2015-05-19 -=================== - - * Add `application/vnd.balsamiq.bmpr` - * Add `application/vnd.microsoft.portable-executable` - * Add `application/x-ns-proxy-autoconfig` - -1.9.1 / 2015-04-19 -================== - - * Remove `.json` extension from `application/manifest+json` - - This is causing bugs downstream - -1.9.0 / 2015-04-19 -================== - - * Add `application/manifest+json` - * Add `application/vnd.micro+json` - * Add `image/vnd.zbrush.pcx` - * Add `image/x-ms-bmp` - -1.8.0 / 2015-03-13 -================== - - * Add `application/vnd.citationstyles.style+xml` - * Add `application/vnd.fastcopy-disk-image` - * Add `application/vnd.gov.sk.xmldatacontainer+xml` - * Add extension `.jsonld` to `application/ld+json` - -1.7.0 / 2015-02-08 -================== - - * Add `application/vnd.gerber` - * Add `application/vnd.msa-disk-image` - -1.6.1 / 2015-02-05 -================== - - * Community extensions ownership transferred from `node-mime` - -1.6.0 / 2015-01-29 -================== - - * Add `application/jose` - * Add `application/jose+json` - * Add `application/json-seq` - * Add `application/jwk+json` - * Add `application/jwk-set+json` - * Add `application/jwt` - * Add `application/rdap+json` - * Add `application/vnd.gov.sk.e-form+xml` - * Add `application/vnd.ims.imsccv1p3` - -1.5.0 / 2014-12-30 -================== - - * Add `application/vnd.oracle.resource+json` - * Fix various invalid MIME type entries - - `application/mbox+xml` - - `application/oscp-response` - - `application/vwg-multiplexed` - - `audio/g721` - -1.4.0 / 2014-12-21 -================== - - * Add `application/vnd.ims.imsccv1p2` - * Fix various invalid MIME type entries - - `application/vnd-acucobol` - - `application/vnd-curl` - - `application/vnd-dart` - - `application/vnd-dxr` - - `application/vnd-fdf` - - `application/vnd-mif` - - `application/vnd-sema` - - `application/vnd-wap-wmlc` - - `application/vnd.adobe.flash-movie` - - `application/vnd.dece-zip` - - `application/vnd.dvb_service` - - `application/vnd.micrografx-igx` - - `application/vnd.sealed-doc` - - `application/vnd.sealed-eml` - - `application/vnd.sealed-mht` - - `application/vnd.sealed-ppt` - - `application/vnd.sealed-tiff` - - `application/vnd.sealed-xls` - - `application/vnd.sealedmedia.softseal-html` - - `application/vnd.sealedmedia.softseal-pdf` - - `application/vnd.wap-slc` - - `application/vnd.wap-wbxml` - - `audio/vnd.sealedmedia.softseal-mpeg` - - `image/vnd-djvu` - - `image/vnd-svf` - - `image/vnd-wap-wbmp` - - `image/vnd.sealed-png` - - `image/vnd.sealedmedia.softseal-gif` - - `image/vnd.sealedmedia.softseal-jpg` - - `model/vnd-dwf` - - `model/vnd.parasolid.transmit-binary` - - `model/vnd.parasolid.transmit-text` - - `text/vnd-a` - - `text/vnd-curl` - - `text/vnd.wap-wml` - * Remove example template MIME types - - `application/example` - - `audio/example` - - `image/example` - - `message/example` - - `model/example` - - `multipart/example` - - `text/example` - - `video/example` - -1.3.1 / 2014-12-16 -================== - - * Fix missing extensions - - `application/json5` - - `text/hjson` - -1.3.0 / 2014-12-07 -================== - - * Add `application/a2l` - * Add `application/aml` - * Add `application/atfx` - * Add `application/atxml` - * Add `application/cdfx+xml` - * Add `application/dii` - * Add `application/json5` - * Add `application/lxf` - * Add `application/mf4` - * Add `application/vnd.apache.thrift.compact` - * Add `application/vnd.apache.thrift.json` - * Add `application/vnd.coffeescript` - * Add `application/vnd.enphase.envoy` - * Add `application/vnd.ims.imsccv1p1` - * Add `text/csv-schema` - * Add `text/hjson` - * Add `text/markdown` - * Add `text/yaml` - -1.2.0 / 2014-11-09 -================== - - * Add `application/cea` - * Add `application/dit` - * Add `application/vnd.gov.sk.e-form+zip` - * Add `application/vnd.tmd.mediaflex.api+xml` - * Type `application/epub+zip` is now IANA-registered - -1.1.2 / 2014-10-23 -================== - - * Rebuild database for `application/x-www-form-urlencoded` change - -1.1.1 / 2014-10-20 -================== - - * Mark `application/x-www-form-urlencoded` as compressible. - -1.1.0 / 2014-09-28 -================== - - * Add `application/font-woff2` - -1.0.3 / 2014-09-25 -================== - - * Fix engine requirement in package - -1.0.2 / 2014-09-25 -================== - - * Add `application/coap-group+json` - * Add `application/dcd` - * Add `application/vnd.apache.thrift.binary` - * Add `image/vnd.tencent.tap` - * Mark all JSON-derived types as compressible - * Update `text/vtt` data - -1.0.1 / 2014-08-30 -================== - - * Fix extension ordering - -1.0.0 / 2014-08-30 -================== - - * Add `application/atf` - * Add `application/merge-patch+json` - * Add `multipart/x-mixed-replace` - * Add `source: 'apache'` metadata - * Add `source: 'iana'` metadata - * Remove badly-assumed charset data +1.23.0 / 2016-05-01 +=================== + + * Add `application/efi` + * Add `application/vnd.3gpp.sms+xml` + * Add `application/vnd.3lightssoftware.imagescal` + * Add `application/vnd.coreos.ignition+json` + * Add `application/vnd.desmume.movie` + * Add `application/vnd.onepager` + * Add `application/vnd.vel+json` + * Add `text/prs.prop.logic` + * Add `video/encaprtp` + * Add `video/h265` + * Add `video/iso.segment` + * Add `video/raptorfec` + * Add `video/rtploopback` + * Add `video/vnd.radgamettools.bink` + * Add `video/vnd.radgamettools.smacker` + * Add `video/vp8` + * Add extension `.3gpp` to `audio/3gpp` + +1.22.0 / 2016-02-15 +=================== + + * Add `application/ppsp-tracker+json` + * Add `application/problem+json` + * Add `application/problem+xml` + * Add `application/vnd.hdt` + * Add `application/vnd.ms-printschematicket+xml` + * Add `model/vnd.rosette.annotated-data-model` + * Add `text/slim` + * Add extension `.rng` to `application/xml` + * Fix extension of `application/dash+xml` to be `.mpd` + * Update primary extension to `.m4a` for `audio/mp4` + +1.21.0 / 2016-01-06 +=================== + + * Add `application/emergencycalldata.comment+xml` + * Add `application/emergencycalldata.deviceinfo+xml` + * Add `application/emergencycalldata.providerinfo+xml` + * Add `application/emergencycalldata.serviceinfo+xml` + * Add `application/emergencycalldata.subscriberinfo+xml` + * Add `application/vnd.filmit.zfc` + * Add `application/vnd.google-apps.document` + * Add `application/vnd.google-apps.presentation` + * Add `application/vnd.google-apps.spreadsheet` + * Add `application/vnd.mapbox-vector-tile` + * Add `application/vnd.ms-printdevicecapabilities+xml` + * Add `application/vnd.ms-windows.devicepairing` + * Add `application/vnd.ms-windows.nwprinting.oob` + * Add `application/vnd.tml` + * Add `audio/evs` + +1.20.0 / 2015-11-10 +=================== + + * Add `application/cdni` + * Add `application/csvm+json` + * Add `application/rfc+xml` + * Add `application/vnd.3gpp.access-transfer-events+xml` + * Add `application/vnd.3gpp.srvcc-ext+xml` + * Add `application/vnd.ms-windows.wsd.oob` + * Add `application/vnd.oxli.countgraph` + * Add `application/vnd.pagerduty+json` + * Add `text/x-suse-ymp` + +1.19.0 / 2015-09-17 +=================== + + * Add `application/vnd.3gpp-prose-pc3ch+xml` + * Add `application/vnd.3gpp.srvcc-info+xml` + * Add `application/vnd.apple.pkpass` + * Add `application/vnd.drive+json` + +1.18.0 / 2015-09-03 +=================== + + * Add `application/pkcs12` + * Add `application/vnd.3gpp-prose+xml` + * Add `application/vnd.3gpp.mid-call+xml` + * Add `application/vnd.3gpp.state-and-event-info+xml` + * Add `application/vnd.anki` + * Add `application/vnd.firemonkeys.cloudcell` + * Add `application/vnd.openblox.game+xml` + * Add `application/vnd.openblox.game-binary` + +1.17.0 / 2015-08-13 +=================== + + * Add `application/x-msdos-program` + * Add `audio/g711-0` + * Add `image/vnd.mozilla.apng` + * Add extension `.exe` to `application/x-msdos-program` + +1.16.0 / 2015-07-29 +=================== + + * Add `application/vnd.uri-map` + +1.15.0 / 2015-07-13 +=================== + + * Add `application/x-httpd-php` + +1.14.0 / 2015-06-25 +=================== + + * Add `application/scim+json` + * Add `application/vnd.3gpp.ussd+xml` + * Add `application/vnd.biopax.rdf+xml` + * Add `text/x-processing` + +1.13.0 / 2015-06-07 +=================== + + * Add nginx as a source + * Add `application/x-cocoa` + * Add `application/x-java-archive-diff` + * Add `application/x-makeself` + * Add `application/x-perl` + * Add `application/x-pilot` + * Add `application/x-redhat-package-manager` + * Add `application/x-sea` + * Add `audio/x-m4a` + * Add `audio/x-realaudio` + * Add `image/x-jng` + * Add `text/mathml` + +1.12.0 / 2015-06-05 +=================== + + * Add `application/bdoc` + * Add `application/vnd.hyperdrive+json` + * Add `application/x-bdoc` + * Add extension `.rtf` to `text/rtf` + +1.11.0 / 2015-05-31 +=================== + + * Add `audio/wav` + * Add `audio/wave` + * Add extension `.litcoffee` to `text/coffeescript` + * Add extension `.sfd-hdstx` to `application/vnd.hydrostatix.sof-data` + * Add extension `.n-gage` to `application/vnd.nokia.n-gage.symbian.install` + +1.10.0 / 2015-05-19 +=================== + + * Add `application/vnd.balsamiq.bmpr` + * Add `application/vnd.microsoft.portable-executable` + * Add `application/x-ns-proxy-autoconfig` + +1.9.1 / 2015-04-19 +================== + + * Remove `.json` extension from `application/manifest+json` + - This is causing bugs downstream + +1.9.0 / 2015-04-19 +================== + + * Add `application/manifest+json` + * Add `application/vnd.micro+json` + * Add `image/vnd.zbrush.pcx` + * Add `image/x-ms-bmp` + +1.8.0 / 2015-03-13 +================== + + * Add `application/vnd.citationstyles.style+xml` + * Add `application/vnd.fastcopy-disk-image` + * Add `application/vnd.gov.sk.xmldatacontainer+xml` + * Add extension `.jsonld` to `application/ld+json` + +1.7.0 / 2015-02-08 +================== + + * Add `application/vnd.gerber` + * Add `application/vnd.msa-disk-image` + +1.6.1 / 2015-02-05 +================== + + * Community extensions ownership transferred from `node-mime` + +1.6.0 / 2015-01-29 +================== + + * Add `application/jose` + * Add `application/jose+json` + * Add `application/json-seq` + * Add `application/jwk+json` + * Add `application/jwk-set+json` + * Add `application/jwt` + * Add `application/rdap+json` + * Add `application/vnd.gov.sk.e-form+xml` + * Add `application/vnd.ims.imsccv1p3` + +1.5.0 / 2014-12-30 +================== + + * Add `application/vnd.oracle.resource+json` + * Fix various invalid MIME type entries + - `application/mbox+xml` + - `application/oscp-response` + - `application/vwg-multiplexed` + - `audio/g721` + +1.4.0 / 2014-12-21 +================== + + * Add `application/vnd.ims.imsccv1p2` + * Fix various invalid MIME type entries + - `application/vnd-acucobol` + - `application/vnd-curl` + - `application/vnd-dart` + - `application/vnd-dxr` + - `application/vnd-fdf` + - `application/vnd-mif` + - `application/vnd-sema` + - `application/vnd-wap-wmlc` + - `application/vnd.adobe.flash-movie` + - `application/vnd.dece-zip` + - `application/vnd.dvb_service` + - `application/vnd.micrografx-igx` + - `application/vnd.sealed-doc` + - `application/vnd.sealed-eml` + - `application/vnd.sealed-mht` + - `application/vnd.sealed-ppt` + - `application/vnd.sealed-tiff` + - `application/vnd.sealed-xls` + - `application/vnd.sealedmedia.softseal-html` + - `application/vnd.sealedmedia.softseal-pdf` + - `application/vnd.wap-slc` + - `application/vnd.wap-wbxml` + - `audio/vnd.sealedmedia.softseal-mpeg` + - `image/vnd-djvu` + - `image/vnd-svf` + - `image/vnd-wap-wbmp` + - `image/vnd.sealed-png` + - `image/vnd.sealedmedia.softseal-gif` + - `image/vnd.sealedmedia.softseal-jpg` + - `model/vnd-dwf` + - `model/vnd.parasolid.transmit-binary` + - `model/vnd.parasolid.transmit-text` + - `text/vnd-a` + - `text/vnd-curl` + - `text/vnd.wap-wml` + * Remove example template MIME types + - `application/example` + - `audio/example` + - `image/example` + - `message/example` + - `model/example` + - `multipart/example` + - `text/example` + - `video/example` + +1.3.1 / 2014-12-16 +================== + + * Fix missing extensions + - `application/json5` + - `text/hjson` + +1.3.0 / 2014-12-07 +================== + + * Add `application/a2l` + * Add `application/aml` + * Add `application/atfx` + * Add `application/atxml` + * Add `application/cdfx+xml` + * Add `application/dii` + * Add `application/json5` + * Add `application/lxf` + * Add `application/mf4` + * Add `application/vnd.apache.thrift.compact` + * Add `application/vnd.apache.thrift.json` + * Add `application/vnd.coffeescript` + * Add `application/vnd.enphase.envoy` + * Add `application/vnd.ims.imsccv1p1` + * Add `text/csv-schema` + * Add `text/hjson` + * Add `text/markdown` + * Add `text/yaml` + +1.2.0 / 2014-11-09 +================== + + * Add `application/cea` + * Add `application/dit` + * Add `application/vnd.gov.sk.e-form+zip` + * Add `application/vnd.tmd.mediaflex.api+xml` + * Type `application/epub+zip` is now IANA-registered + +1.1.2 / 2014-10-23 +================== + + * Rebuild database for `application/x-www-form-urlencoded` change + +1.1.1 / 2014-10-20 +================== + + * Mark `application/x-www-form-urlencoded` as compressible. + +1.1.0 / 2014-09-28 +================== + + * Add `application/font-woff2` + +1.0.3 / 2014-09-25 +================== + + * Fix engine requirement in package + +1.0.2 / 2014-09-25 +================== + + * Add `application/coap-group+json` + * Add `application/dcd` + * Add `application/vnd.apache.thrift.binary` + * Add `image/vnd.tencent.tap` + * Mark all JSON-derived types as compressible + * Update `text/vtt` data + +1.0.1 / 2014-08-30 +================== + + * Fix extension ordering + +1.0.0 / 2014-08-30 +================== + + * Add `application/atf` + * Add `application/merge-patch+json` + * Add `multipart/x-mixed-replace` + * Add `source: 'apache'` metadata + * Add `source: 'iana'` metadata + * Remove badly-assumed charset data diff --git a/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/LICENSE b/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/LICENSE index c1b15a1d..a7ae8ee9 100644 --- a/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/LICENSE +++ b/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/LICENSE @@ -1,22 +1,22 @@ - -The MIT License (MIT) - -Copyright (c) 2014 Jonathan Ong me@jongleberry.com - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. + +The MIT License (MIT) + +Copyright (c) 2014 Jonathan Ong me@jongleberry.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/README.md b/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/README.md index 48c419fc..7662440b 100644 --- a/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/README.md +++ b/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/README.md @@ -1,82 +1,82 @@ -# mime-db - -[![NPM Version][npm-version-image]][npm-url] -[![NPM Downloads][npm-downloads-image]][npm-url] -[![Node.js Version][node-image]][node-url] -[![Build Status][travis-image]][travis-url] -[![Coverage Status][coveralls-image]][coveralls-url] - -This is a database of all mime types. -It consists of a single, public JSON file and does not include any logic, -allowing it to remain as un-opinionated as possible with an API. -It aggregates data from the following sources: - -- http://www.iana.org/assignments/media-types/media-types.xhtml -- http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types -- http://hg.nginx.org/nginx/raw-file/default/conf/mime.types - -## Installation - -```bash -npm install mime-db -``` - -### Database Download - -If you're crazy enough to use this in the browser, you can just grab the -JSON file using [RawGit](https://rawgit.com/). It is recommended to replace -`master` with [a release tag](https://github.com/jshttp/mime-db/tags) as the -JSON format may change in the future. - -``` -https://cdn.rawgit.com/jshttp/mime-db/master/db.json -``` - -## Usage - -```js -var db = require('mime-db'); - -// grab data on .js files -var data = db['application/javascript']; -``` - -## Data Structure - -The JSON file is a map lookup for lowercased mime types. -Each mime type has the following properties: - -- `.source` - where the mime type is defined. - If not set, it's probably a custom media type. - - `apache` - [Apache common media types](http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types) - - `iana` - [IANA-defined media types](http://www.iana.org/assignments/media-types/media-types.xhtml) - - `nginx` - [nginx media types](http://hg.nginx.org/nginx/raw-file/default/conf/mime.types) -- `.extensions[]` - known extensions associated with this mime type. -- `.compressible` - whether a file of this type can be gzipped. -- `.charset` - the default charset associated with this type, if any. - -If unknown, every property could be `undefined`. - -## Contributing - -To edit the database, only make PRs against `src/custom.json` or -`src/custom-suffix.json`. - -To update the build, run `npm run build`. - -## Adding Custom Media Types - -The best way to get new media types included in this library is to register -them with the IANA. The community registration procedure is outlined in -[RFC 6838 section 5](http://tools.ietf.org/html/rfc6838#section-5). Types -registered with the IANA are automatically pulled into this library. - -[npm-version-image]: https://img.shields.io/npm/v/mime-db.svg -[npm-downloads-image]: https://img.shields.io/npm/dm/mime-db.svg -[npm-url]: https://npmjs.org/package/mime-db -[travis-image]: https://img.shields.io/travis/jshttp/mime-db/master.svg -[travis-url]: https://travis-ci.org/jshttp/mime-db -[coveralls-image]: https://img.shields.io/coveralls/jshttp/mime-db/master.svg -[coveralls-url]: https://coveralls.io/r/jshttp/mime-db?branch=master -[node-image]: https://img.shields.io/node/v/mime-db.svg -[node-url]: http://nodejs.org/download/ +# mime-db + +[![NPM Version][npm-version-image]][npm-url] +[![NPM Downloads][npm-downloads-image]][npm-url] +[![Node.js Version][node-image]][node-url] +[![Build Status][travis-image]][travis-url] +[![Coverage Status][coveralls-image]][coveralls-url] + +This is a database of all mime types. +It consists of a single, public JSON file and does not include any logic, +allowing it to remain as un-opinionated as possible with an API. +It aggregates data from the following sources: + +- http://www.iana.org/assignments/media-types/media-types.xhtml +- http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types +- http://hg.nginx.org/nginx/raw-file/default/conf/mime.types + +## Installation + +```bash +npm install mime-db +``` + +### Database Download + +If you're crazy enough to use this in the browser, you can just grab the +JSON file using [RawGit](https://rawgit.com/). It is recommended to replace +`master` with [a release tag](https://github.com/jshttp/mime-db/tags) as the +JSON format may change in the future. + +``` +https://cdn.rawgit.com/jshttp/mime-db/master/db.json +``` + +## Usage + +```js +var db = require('mime-db'); + +// grab data on .js files +var data = db['application/javascript']; +``` + +## Data Structure + +The JSON file is a map lookup for lowercased mime types. +Each mime type has the following properties: + +- `.source` - where the mime type is defined. + If not set, it's probably a custom media type. + - `apache` - [Apache common media types](http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types) + - `iana` - [IANA-defined media types](http://www.iana.org/assignments/media-types/media-types.xhtml) + - `nginx` - [nginx media types](http://hg.nginx.org/nginx/raw-file/default/conf/mime.types) +- `.extensions[]` - known extensions associated with this mime type. +- `.compressible` - whether a file of this type can be gzipped. +- `.charset` - the default charset associated with this type, if any. + +If unknown, every property could be `undefined`. + +## Contributing + +To edit the database, only make PRs against `src/custom.json` or +`src/custom-suffix.json`. + +To update the build, run `npm run build`. + +## Adding Custom Media Types + +The best way to get new media types included in this library is to register +them with the IANA. The community registration procedure is outlined in +[RFC 6838 section 5](http://tools.ietf.org/html/rfc6838#section-5). Types +registered with the IANA are automatically pulled into this library. + +[npm-version-image]: https://img.shields.io/npm/v/mime-db.svg +[npm-downloads-image]: https://img.shields.io/npm/dm/mime-db.svg +[npm-url]: https://npmjs.org/package/mime-db +[travis-image]: https://img.shields.io/travis/jshttp/mime-db/master.svg +[travis-url]: https://travis-ci.org/jshttp/mime-db +[coveralls-image]: https://img.shields.io/coveralls/jshttp/mime-db/master.svg +[coveralls-url]: https://coveralls.io/r/jshttp/mime-db?branch=master +[node-image]: https://img.shields.io/node/v/mime-db.svg +[node-url]: http://nodejs.org/download/ diff --git a/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/db.json b/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/db.json index 8202792e..0a5a8a7b 100644 --- a/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/db.json +++ b/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/db.json @@ -1,6627 +1,6627 @@ -{ - "application/1d-interleaved-parityfec": { - "source": "iana" - }, - "application/3gpdash-qoe-report+xml": { - "source": "iana" - }, - "application/3gpp-ims+xml": { - "source": "iana" - }, - "application/a2l": { - "source": "iana" - }, - "application/activemessage": { - "source": "iana" - }, - "application/alto-costmap+json": { - "source": "iana", - "compressible": true - }, - "application/alto-costmapfilter+json": { - "source": "iana", - "compressible": true - }, - "application/alto-directory+json": { - "source": "iana", - "compressible": true - }, - "application/alto-endpointcost+json": { - "source": "iana", - "compressible": true - }, - "application/alto-endpointcostparams+json": { - "source": "iana", - "compressible": true - }, - "application/alto-endpointprop+json": { - "source": "iana", - "compressible": true - }, - "application/alto-endpointpropparams+json": { - "source": "iana", - "compressible": true - }, - "application/alto-error+json": { - "source": "iana", - "compressible": true - }, - "application/alto-networkmap+json": { - "source": "iana", - "compressible": true - }, - "application/alto-networkmapfilter+json": { - "source": "iana", - "compressible": true - }, - "application/aml": { - "source": "iana" - }, - "application/andrew-inset": { - "source": "iana", - "extensions": ["ez"] - }, - "application/applefile": { - "source": "iana" - }, - "application/applixware": { - "source": "apache", - "extensions": ["aw"] - }, - "application/atf": { - "source": "iana" - }, - "application/atfx": { - "source": "iana" - }, - "application/atom+xml": { - "source": "iana", - "compressible": true, - "extensions": ["atom"] - }, - "application/atomcat+xml": { - "source": "iana", - "extensions": ["atomcat"] - }, - "application/atomdeleted+xml": { - "source": "iana" - }, - "application/atomicmail": { - "source": "iana" - }, - "application/atomsvc+xml": { - "source": "iana", - "extensions": ["atomsvc"] - }, - "application/atxml": { - "source": "iana" - }, - "application/auth-policy+xml": { - "source": "iana" - }, - "application/bacnet-xdd+zip": { - "source": "iana" - }, - "application/batch-smtp": { - "source": "iana" - }, - "application/bdoc": { - "compressible": false, - "extensions": ["bdoc"] - }, - "application/beep+xml": { - "source": "iana" - }, - "application/calendar+json": { - "source": "iana", - "compressible": true - }, - "application/calendar+xml": { - "source": "iana" - }, - "application/call-completion": { - "source": "iana" - }, - "application/cals-1840": { - "source": "iana" - }, - "application/cbor": { - "source": "iana" - }, - "application/ccmp+xml": { - "source": "iana" - }, - "application/ccxml+xml": { - "source": "iana", - "extensions": ["ccxml"] - }, - "application/cdfx+xml": { - "source": "iana" - }, - "application/cdmi-capability": { - "source": "iana", - "extensions": ["cdmia"] - }, - "application/cdmi-container": { - "source": "iana", - "extensions": ["cdmic"] - }, - "application/cdmi-domain": { - "source": "iana", - "extensions": ["cdmid"] - }, - "application/cdmi-object": { - "source": "iana", - "extensions": ["cdmio"] - }, - "application/cdmi-queue": { - "source": "iana", - "extensions": ["cdmiq"] - }, - "application/cdni": { - "source": "iana" - }, - "application/cea": { - "source": "iana" - }, - "application/cea-2018+xml": { - "source": "iana" - }, - "application/cellml+xml": { - "source": "iana" - }, - "application/cfw": { - "source": "iana" - }, - "application/cms": { - "source": "iana" - }, - "application/cnrp+xml": { - "source": "iana" - }, - "application/coap-group+json": { - "source": "iana", - "compressible": true - }, - "application/commonground": { - "source": "iana" - }, - "application/conference-info+xml": { - "source": "iana" - }, - "application/cpl+xml": { - "source": "iana" - }, - "application/csrattrs": { - "source": "iana" - }, - "application/csta+xml": { - "source": "iana" - }, - "application/cstadata+xml": { - "source": "iana" - }, - "application/csvm+json": { - "source": "iana", - "compressible": true - }, - "application/cu-seeme": { - "source": "apache", - "extensions": ["cu"] - }, - "application/cybercash": { - "source": "iana" - }, - "application/dart": { - "compressible": true - }, - "application/dash+xml": { - "source": "iana", - "extensions": ["mpd"] - }, - "application/dashdelta": { - "source": "iana" - }, - "application/davmount+xml": { - "source": "iana", - "extensions": ["davmount"] - }, - "application/dca-rft": { - "source": "iana" - }, - "application/dcd": { - "source": "iana" - }, - "application/dec-dx": { - "source": "iana" - }, - "application/dialog-info+xml": { - "source": "iana" - }, - "application/dicom": { - "source": "iana" - }, - "application/dii": { - "source": "iana" - }, - "application/dit": { - "source": "iana" - }, - "application/dns": { - "source": "iana" - }, - "application/docbook+xml": { - "source": "apache", - "extensions": ["dbk"] - }, - "application/dskpp+xml": { - "source": "iana" - }, - "application/dssc+der": { - "source": "iana", - "extensions": ["dssc"] - }, - "application/dssc+xml": { - "source": "iana", - "extensions": ["xdssc"] - }, - "application/dvcs": { - "source": "iana" - }, - "application/ecmascript": { - "source": "iana", - "compressible": true, - "extensions": ["ecma"] - }, - "application/edi-consent": { - "source": "iana" - }, - "application/edi-x12": { - "source": "iana", - "compressible": false - }, - "application/edifact": { - "source": "iana", - "compressible": false - }, - "application/efi": { - "source": "iana" - }, - "application/emergencycalldata.comment+xml": { - "source": "iana" - }, - "application/emergencycalldata.deviceinfo+xml": { - "source": "iana" - }, - "application/emergencycalldata.providerinfo+xml": { - "source": "iana" - }, - "application/emergencycalldata.serviceinfo+xml": { - "source": "iana" - }, - "application/emergencycalldata.subscriberinfo+xml": { - "source": "iana" - }, - "application/emma+xml": { - "source": "iana", - "extensions": ["emma"] - }, - "application/emotionml+xml": { - "source": "iana" - }, - "application/encaprtp": { - "source": "iana" - }, - "application/epp+xml": { - "source": "iana" - }, - "application/epub+zip": { - "source": "iana", - "extensions": ["epub"] - }, - "application/eshop": { - "source": "iana" - }, - "application/exi": { - "source": "iana", - "extensions": ["exi"] - }, - "application/fastinfoset": { - "source": "iana" - }, - "application/fastsoap": { - "source": "iana" - }, - "application/fdt+xml": { - "source": "iana" - }, - "application/fits": { - "source": "iana" - }, - "application/font-sfnt": { - "source": "iana" - }, - "application/font-tdpfr": { - "source": "iana", - "extensions": ["pfr"] - }, - "application/font-woff": { - "source": "iana", - "compressible": false, - "extensions": ["woff"] - }, - "application/font-woff2": { - "compressible": false, - "extensions": ["woff2"] - }, - "application/framework-attributes+xml": { - "source": "iana" - }, - "application/gml+xml": { - "source": "apache", - "extensions": ["gml"] - }, - "application/gpx+xml": { - "source": "apache", - "extensions": ["gpx"] - }, - "application/gxf": { - "source": "apache", - "extensions": ["gxf"] - }, - "application/gzip": { - "source": "iana", - "compressible": false - }, - "application/h224": { - "source": "iana" - }, - "application/held+xml": { - "source": "iana" - }, - "application/http": { - "source": "iana" - }, - "application/hyperstudio": { - "source": "iana", - "extensions": ["stk"] - }, - "application/ibe-key-request+xml": { - "source": "iana" - }, - "application/ibe-pkg-reply+xml": { - "source": "iana" - }, - "application/ibe-pp-data": { - "source": "iana" - }, - "application/iges": { - "source": "iana" - }, - "application/im-iscomposing+xml": { - "source": "iana" - }, - "application/index": { - "source": "iana" - }, - "application/index.cmd": { - "source": "iana" - }, - "application/index.obj": { - "source": "iana" - }, - "application/index.response": { - "source": "iana" - }, - "application/index.vnd": { - "source": "iana" - }, - "application/inkml+xml": { - "source": "iana", - "extensions": ["ink","inkml"] - }, - "application/iotp": { - "source": "iana" - }, - "application/ipfix": { - "source": "iana", - "extensions": ["ipfix"] - }, - "application/ipp": { - "source": "iana" - }, - "application/isup": { - "source": "iana" - }, - "application/its+xml": { - "source": "iana" - }, - "application/java-archive": { - "source": "apache", - "compressible": false, - "extensions": ["jar","war","ear"] - }, - "application/java-serialized-object": { - "source": "apache", - "compressible": false, - "extensions": ["ser"] - }, - "application/java-vm": { - "source": "apache", - "compressible": false, - "extensions": ["class"] - }, - "application/javascript": { - "source": "iana", - "charset": "UTF-8", - "compressible": true, - "extensions": ["js"] - }, - "application/jose": { - "source": "iana" - }, - "application/jose+json": { - "source": "iana", - "compressible": true - }, - "application/jrd+json": { - "source": "iana", - "compressible": true - }, - "application/json": { - "source": "iana", - "charset": "UTF-8", - "compressible": true, - "extensions": ["json","map"] - }, - "application/json-patch+json": { - "source": "iana", - "compressible": true - }, - "application/json-seq": { - "source": "iana" - }, - "application/json5": { - "extensions": ["json5"] - }, - "application/jsonml+json": { - "source": "apache", - "compressible": true, - "extensions": ["jsonml"] - }, - "application/jwk+json": { - "source": "iana", - "compressible": true - }, - "application/jwk-set+json": { - "source": "iana", - "compressible": true - }, - "application/jwt": { - "source": "iana" - }, - "application/kpml-request+xml": { - "source": "iana" - }, - "application/kpml-response+xml": { - "source": "iana" - }, - "application/ld+json": { - "source": "iana", - "compressible": true, - "extensions": ["jsonld"] - }, - "application/link-format": { - "source": "iana" - }, - "application/load-control+xml": { - "source": "iana" - }, - "application/lost+xml": { - "source": "iana", - "extensions": ["lostxml"] - }, - "application/lostsync+xml": { - "source": "iana" - }, - "application/lxf": { - "source": "iana" - }, - "application/mac-binhex40": { - "source": "iana", - "extensions": ["hqx"] - }, - "application/mac-compactpro": { - "source": "apache", - "extensions": ["cpt"] - }, - "application/macwriteii": { - "source": "iana" - }, - "application/mads+xml": { - "source": "iana", - "extensions": ["mads"] - }, - "application/manifest+json": { - "charset": "UTF-8", - "compressible": true, - "extensions": ["webmanifest"] - }, - "application/marc": { - "source": "iana", - "extensions": ["mrc"] - }, - "application/marcxml+xml": { - "source": "iana", - "extensions": ["mrcx"] - }, - "application/mathematica": { - "source": "iana", - "extensions": ["ma","nb","mb"] - }, - "application/mathml+xml": { - "source": "iana", - "extensions": ["mathml"] - }, - "application/mathml-content+xml": { - "source": "iana" - }, - "application/mathml-presentation+xml": { - "source": "iana" - }, - "application/mbms-associated-procedure-description+xml": { - "source": "iana" - }, - "application/mbms-deregister+xml": { - "source": "iana" - }, - "application/mbms-envelope+xml": { - "source": "iana" - }, - "application/mbms-msk+xml": { - "source": "iana" - }, - "application/mbms-msk-response+xml": { - "source": "iana" - }, - "application/mbms-protection-description+xml": { - "source": "iana" - }, - "application/mbms-reception-report+xml": { - "source": "iana" - }, - "application/mbms-register+xml": { - "source": "iana" - }, - "application/mbms-register-response+xml": { - "source": "iana" - }, - "application/mbms-schedule+xml": { - "source": "iana" - }, - "application/mbms-user-service-description+xml": { - "source": "iana" - }, - "application/mbox": { - "source": "iana", - "extensions": ["mbox"] - }, - "application/media-policy-dataset+xml": { - "source": "iana" - }, - "application/media_control+xml": { - "source": "iana" - }, - "application/mediaservercontrol+xml": { - "source": "iana", - "extensions": ["mscml"] - }, - "application/merge-patch+json": { - "source": "iana", - "compressible": true - }, - "application/metalink+xml": { - "source": "apache", - "extensions": ["metalink"] - }, - "application/metalink4+xml": { - "source": "iana", - "extensions": ["meta4"] - }, - "application/mets+xml": { - "source": "iana", - "extensions": ["mets"] - }, - "application/mf4": { - "source": "iana" - }, - "application/mikey": { - "source": "iana" - }, - "application/mods+xml": { - "source": "iana", - "extensions": ["mods"] - }, - "application/moss-keys": { - "source": "iana" - }, - "application/moss-signature": { - "source": "iana" - }, - "application/mosskey-data": { - "source": "iana" - }, - "application/mosskey-request": { - "source": "iana" - }, - "application/mp21": { - "source": "iana", - "extensions": ["m21","mp21"] - }, - "application/mp4": { - "source": "iana", - "extensions": ["mp4s","m4p"] - }, - "application/mpeg4-generic": { - "source": "iana" - }, - "application/mpeg4-iod": { - "source": "iana" - }, - "application/mpeg4-iod-xmt": { - "source": "iana" - }, - "application/mrb-consumer+xml": { - "source": "iana" - }, - "application/mrb-publish+xml": { - "source": "iana" - }, - "application/msc-ivr+xml": { - "source": "iana" - }, - "application/msc-mixer+xml": { - "source": "iana" - }, - "application/msword": { - "source": "iana", - "compressible": false, - "extensions": ["doc","dot"] - }, - "application/mxf": { - "source": "iana", - "extensions": ["mxf"] - }, - "application/nasdata": { - "source": "iana" - }, - "application/news-checkgroups": { - "source": "iana" - }, - "application/news-groupinfo": { - "source": "iana" - }, - "application/news-transmission": { - "source": "iana" - }, - "application/nlsml+xml": { - "source": "iana" - }, - "application/nss": { - "source": "iana" - }, - "application/ocsp-request": { - "source": "iana" - }, - "application/ocsp-response": { - "source": "iana" - }, - "application/octet-stream": { - "source": "iana", - "compressible": false, - "extensions": ["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"] - }, - "application/oda": { - "source": "iana", - "extensions": ["oda"] - }, - "application/odx": { - "source": "iana" - }, - "application/oebps-package+xml": { - "source": "iana", - "extensions": ["opf"] - }, - "application/ogg": { - "source": "iana", - "compressible": false, - "extensions": ["ogx"] - }, - "application/omdoc+xml": { - "source": "apache", - "extensions": ["omdoc"] - }, - "application/onenote": { - "source": "apache", - "extensions": ["onetoc","onetoc2","onetmp","onepkg"] - }, - "application/oxps": { - "source": "iana", - "extensions": ["oxps"] - }, - "application/p2p-overlay+xml": { - "source": "iana" - }, - "application/parityfec": { - "source": "iana" - }, - "application/patch-ops-error+xml": { - "source": "iana", - "extensions": ["xer"] - }, - "application/pdf": { - "source": "iana", - "compressible": false, - "extensions": ["pdf"] - }, - "application/pdx": { - "source": "iana" - }, - "application/pgp-encrypted": { - "source": "iana", - "compressible": false, - "extensions": ["pgp"] - }, - "application/pgp-keys": { - "source": "iana" - }, - "application/pgp-signature": { - "source": "iana", - "extensions": ["asc","sig"] - }, - "application/pics-rules": { - "source": "apache", - "extensions": ["prf"] - }, - "application/pidf+xml": { - "source": "iana" - }, - "application/pidf-diff+xml": { - "source": "iana" - }, - "application/pkcs10": { - "source": "iana", - "extensions": ["p10"] - }, - "application/pkcs12": { - "source": "iana" - }, - "application/pkcs7-mime": { - "source": "iana", - "extensions": ["p7m","p7c"] - }, - "application/pkcs7-signature": { - "source": "iana", - "extensions": ["p7s"] - }, - "application/pkcs8": { - "source": "iana", - "extensions": ["p8"] - }, - "application/pkix-attr-cert": { - "source": "iana", - "extensions": ["ac"] - }, - "application/pkix-cert": { - "source": "iana", - "extensions": ["cer"] - }, - "application/pkix-crl": { - "source": "iana", - "extensions": ["crl"] - }, - "application/pkix-pkipath": { - "source": "iana", - "extensions": ["pkipath"] - }, - "application/pkixcmp": { - "source": "iana", - "extensions": ["pki"] - }, - "application/pls+xml": { - "source": "iana", - "extensions": ["pls"] - }, - "application/poc-settings+xml": { - "source": "iana" - }, - "application/postscript": { - "source": "iana", - "compressible": true, - "extensions": ["ai","eps","ps"] - }, - "application/ppsp-tracker+json": { - "source": "iana", - "compressible": true - }, - "application/problem+json": { - "source": "iana", - "compressible": true - }, - "application/problem+xml": { - "source": "iana" - }, - "application/provenance+xml": { - "source": "iana" - }, - "application/prs.alvestrand.titrax-sheet": { - "source": "iana" - }, - "application/prs.cww": { - "source": "iana", - "extensions": ["cww"] - }, - "application/prs.hpub+zip": { - "source": "iana" - }, - "application/prs.nprend": { - "source": "iana" - }, - "application/prs.plucker": { - "source": "iana" - }, - "application/prs.rdf-xml-crypt": { - "source": "iana" - }, - "application/prs.xsf+xml": { - "source": "iana" - }, - "application/pskc+xml": { - "source": "iana", - "extensions": ["pskcxml"] - }, - "application/qsig": { - "source": "iana" - }, - "application/raptorfec": { - "source": "iana" - }, - "application/rdap+json": { - "source": "iana", - "compressible": true - }, - "application/rdf+xml": { - "source": "iana", - "compressible": true, - "extensions": ["rdf"] - }, - "application/reginfo+xml": { - "source": "iana", - "extensions": ["rif"] - }, - "application/relax-ng-compact-syntax": { - "source": "iana", - "extensions": ["rnc"] - }, - "application/remote-printing": { - "source": "iana" - }, - "application/reputon+json": { - "source": "iana", - "compressible": true - }, - "application/resource-lists+xml": { - "source": "iana", - "extensions": ["rl"] - }, - "application/resource-lists-diff+xml": { - "source": "iana", - "extensions": ["rld"] - }, - "application/rfc+xml": { - "source": "iana" - }, - "application/riscos": { - "source": "iana" - }, - "application/rlmi+xml": { - "source": "iana" - }, - "application/rls-services+xml": { - "source": "iana", - "extensions": ["rs"] - }, - "application/rpki-ghostbusters": { - "source": "iana", - "extensions": ["gbr"] - }, - "application/rpki-manifest": { - "source": "iana", - "extensions": ["mft"] - }, - "application/rpki-roa": { - "source": "iana", - "extensions": ["roa"] - }, - "application/rpki-updown": { - "source": "iana" - }, - "application/rsd+xml": { - "source": "apache", - "extensions": ["rsd"] - }, - "application/rss+xml": { - "source": "apache", - "compressible": true, - "extensions": ["rss"] - }, - "application/rtf": { - "source": "iana", - "compressible": true, - "extensions": ["rtf"] - }, - "application/rtploopback": { - "source": "iana" - }, - "application/rtx": { - "source": "iana" - }, - "application/samlassertion+xml": { - "source": "iana" - }, - "application/samlmetadata+xml": { - "source": "iana" - }, - "application/sbml+xml": { - "source": "iana", - "extensions": ["sbml"] - }, - "application/scaip+xml": { - "source": "iana" - }, - "application/scim+json": { - "source": "iana", - "compressible": true - }, - "application/scvp-cv-request": { - "source": "iana", - "extensions": ["scq"] - }, - "application/scvp-cv-response": { - "source": "iana", - "extensions": ["scs"] - }, - "application/scvp-vp-request": { - "source": "iana", - "extensions": ["spq"] - }, - "application/scvp-vp-response": { - "source": "iana", - "extensions": ["spp"] - }, - "application/sdp": { - "source": "iana", - "extensions": ["sdp"] - }, - "application/sep+xml": { - "source": "iana" - }, - "application/sep-exi": { - "source": "iana" - }, - "application/session-info": { - "source": "iana" - }, - "application/set-payment": { - "source": "iana" - }, - "application/set-payment-initiation": { - "source": "iana", - "extensions": ["setpay"] - }, - "application/set-registration": { - "source": "iana" - }, - "application/set-registration-initiation": { - "source": "iana", - "extensions": ["setreg"] - }, - "application/sgml": { - "source": "iana" - }, - "application/sgml-open-catalog": { - "source": "iana" - }, - "application/shf+xml": { - "source": "iana", - "extensions": ["shf"] - }, - "application/sieve": { - "source": "iana" - }, - "application/simple-filter+xml": { - "source": "iana" - }, - "application/simple-message-summary": { - "source": "iana" - }, - "application/simplesymbolcontainer": { - "source": "iana" - }, - "application/slate": { - "source": "iana" - }, - "application/smil": { - "source": "iana" - }, - "application/smil+xml": { - "source": "iana", - "extensions": ["smi","smil"] - }, - "application/smpte336m": { - "source": "iana" - }, - "application/soap+fastinfoset": { - "source": "iana" - }, - "application/soap+xml": { - "source": "iana", - "compressible": true - }, - "application/sparql-query": { - "source": "iana", - "extensions": ["rq"] - }, - "application/sparql-results+xml": { - "source": "iana", - "extensions": ["srx"] - }, - "application/spirits-event+xml": { - "source": "iana" - }, - "application/sql": { - "source": "iana" - }, - "application/srgs": { - "source": "iana", - "extensions": ["gram"] - }, - "application/srgs+xml": { - "source": "iana", - "extensions": ["grxml"] - }, - "application/sru+xml": { - "source": "iana", - "extensions": ["sru"] - }, - "application/ssdl+xml": { - "source": "apache", - "extensions": ["ssdl"] - }, - "application/ssml+xml": { - "source": "iana", - "extensions": ["ssml"] - }, - "application/tamp-apex-update": { - "source": "iana" - }, - "application/tamp-apex-update-confirm": { - "source": "iana" - }, - "application/tamp-community-update": { - "source": "iana" - }, - "application/tamp-community-update-confirm": { - "source": "iana" - }, - "application/tamp-error": { - "source": "iana" - }, - "application/tamp-sequence-adjust": { - "source": "iana" - }, - "application/tamp-sequence-adjust-confirm": { - "source": "iana" - }, - "application/tamp-status-query": { - "source": "iana" - }, - "application/tamp-status-response": { - "source": "iana" - }, - "application/tamp-update": { - "source": "iana" - }, - "application/tamp-update-confirm": { - "source": "iana" - }, - "application/tar": { - "compressible": true - }, - "application/tei+xml": { - "source": "iana", - "extensions": ["tei","teicorpus"] - }, - "application/thraud+xml": { - "source": "iana", - "extensions": ["tfi"] - }, - "application/timestamp-query": { - "source": "iana" - }, - "application/timestamp-reply": { - "source": "iana" - }, - "application/timestamped-data": { - "source": "iana", - "extensions": ["tsd"] - }, - "application/ttml+xml": { - "source": "iana" - }, - "application/tve-trigger": { - "source": "iana" - }, - "application/ulpfec": { - "source": "iana" - }, - "application/urc-grpsheet+xml": { - "source": "iana" - }, - "application/urc-ressheet+xml": { - "source": "iana" - }, - "application/urc-targetdesc+xml": { - "source": "iana" - }, - "application/urc-uisocketdesc+xml": { - "source": "iana" - }, - "application/vcard+json": { - "source": "iana", - "compressible": true - }, - "application/vcard+xml": { - "source": "iana" - }, - "application/vemmi": { - "source": "iana" - }, - "application/vividence.scriptfile": { - "source": "apache" - }, - "application/vnd.3gpp-prose+xml": { - "source": "iana" - }, - "application/vnd.3gpp-prose-pc3ch+xml": { - "source": "iana" - }, - "application/vnd.3gpp.access-transfer-events+xml": { - "source": "iana" - }, - "application/vnd.3gpp.bsf+xml": { - "source": "iana" - }, - "application/vnd.3gpp.mid-call+xml": { - "source": "iana" - }, - "application/vnd.3gpp.pic-bw-large": { - "source": "iana", - "extensions": ["plb"] - }, - "application/vnd.3gpp.pic-bw-small": { - "source": "iana", - "extensions": ["psb"] - }, - "application/vnd.3gpp.pic-bw-var": { - "source": "iana", - "extensions": ["pvb"] - }, - "application/vnd.3gpp.sms": { - "source": "iana" - }, - "application/vnd.3gpp.sms+xml": { - "source": "iana" - }, - "application/vnd.3gpp.srvcc-ext+xml": { - "source": "iana" - }, - "application/vnd.3gpp.srvcc-info+xml": { - "source": "iana" - }, - "application/vnd.3gpp.state-and-event-info+xml": { - "source": "iana" - }, - "application/vnd.3gpp.ussd+xml": { - "source": "iana" - }, - "application/vnd.3gpp2.bcmcsinfo+xml": { - "source": "iana" - }, - "application/vnd.3gpp2.sms": { - "source": "iana" - }, - "application/vnd.3gpp2.tcap": { - "source": "iana", - "extensions": ["tcap"] - }, - "application/vnd.3lightssoftware.imagescal": { - "source": "iana" - }, - "application/vnd.3m.post-it-notes": { - "source": "iana", - "extensions": ["pwn"] - }, - "application/vnd.accpac.simply.aso": { - "source": "iana", - "extensions": ["aso"] - }, - "application/vnd.accpac.simply.imp": { - "source": "iana", - "extensions": ["imp"] - }, - "application/vnd.acucobol": { - "source": "iana", - "extensions": ["acu"] - }, - "application/vnd.acucorp": { - "source": "iana", - "extensions": ["atc","acutc"] - }, - "application/vnd.adobe.air-application-installer-package+zip": { - "source": "apache", - "extensions": ["air"] - }, - "application/vnd.adobe.flash.movie": { - "source": "iana" - }, - "application/vnd.adobe.formscentral.fcdt": { - "source": "iana", - "extensions": ["fcdt"] - }, - "application/vnd.adobe.fxp": { - "source": "iana", - "extensions": ["fxp","fxpl"] - }, - "application/vnd.adobe.partial-upload": { - "source": "iana" - }, - "application/vnd.adobe.xdp+xml": { - "source": "iana", - "extensions": ["xdp"] - }, - "application/vnd.adobe.xfdf": { - "source": "iana", - "extensions": ["xfdf"] - }, - "application/vnd.aether.imp": { - "source": "iana" - }, - "application/vnd.ah-barcode": { - "source": "iana" - }, - "application/vnd.ahead.space": { - "source": "iana", - "extensions": ["ahead"] - }, - "application/vnd.airzip.filesecure.azf": { - "source": "iana", - "extensions": ["azf"] - }, - "application/vnd.airzip.filesecure.azs": { - "source": "iana", - "extensions": ["azs"] - }, - "application/vnd.amazon.ebook": { - "source": "apache", - "extensions": ["azw"] - }, - "application/vnd.americandynamics.acc": { - "source": "iana", - "extensions": ["acc"] - }, - "application/vnd.amiga.ami": { - "source": "iana", - "extensions": ["ami"] - }, - "application/vnd.amundsen.maze+xml": { - "source": "iana" - }, - "application/vnd.android.package-archive": { - "source": "apache", - "compressible": false, - "extensions": ["apk"] - }, - "application/vnd.anki": { - "source": "iana" - }, - "application/vnd.anser-web-certificate-issue-initiation": { - "source": "iana", - "extensions": ["cii"] - }, - "application/vnd.anser-web-funds-transfer-initiation": { - "source": "apache", - "extensions": ["fti"] - }, - "application/vnd.antix.game-component": { - "source": "iana", - "extensions": ["atx"] - }, - "application/vnd.apache.thrift.binary": { - "source": "iana" - }, - "application/vnd.apache.thrift.compact": { - "source": "iana" - }, - "application/vnd.apache.thrift.json": { - "source": "iana" - }, - "application/vnd.api+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.apple.installer+xml": { - "source": "iana", - "extensions": ["mpkg"] - }, - "application/vnd.apple.mpegurl": { - "source": "iana", - "extensions": ["m3u8"] - }, - "application/vnd.apple.pkpass": { - "compressible": false, - "extensions": ["pkpass"] - }, - "application/vnd.arastra.swi": { - "source": "iana" - }, - "application/vnd.aristanetworks.swi": { - "source": "iana", - "extensions": ["swi"] - }, - "application/vnd.artsquare": { - "source": "iana" - }, - "application/vnd.astraea-software.iota": { - "source": "iana", - "extensions": ["iota"] - }, - "application/vnd.audiograph": { - "source": "iana", - "extensions": ["aep"] - }, - "application/vnd.autopackage": { - "source": "iana" - }, - "application/vnd.avistar+xml": { - "source": "iana" - }, - "application/vnd.balsamiq.bmml+xml": { - "source": "iana" - }, - "application/vnd.balsamiq.bmpr": { - "source": "iana" - }, - "application/vnd.bekitzur-stech+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.biopax.rdf+xml": { - "source": "iana" - }, - "application/vnd.blueice.multipass": { - "source": "iana", - "extensions": ["mpm"] - }, - "application/vnd.bluetooth.ep.oob": { - "source": "iana" - }, - "application/vnd.bluetooth.le.oob": { - "source": "iana" - }, - "application/vnd.bmi": { - "source": "iana", - "extensions": ["bmi"] - }, - "application/vnd.businessobjects": { - "source": "iana", - "extensions": ["rep"] - }, - "application/vnd.cab-jscript": { - "source": "iana" - }, - "application/vnd.canon-cpdl": { - "source": "iana" - }, - "application/vnd.canon-lips": { - "source": "iana" - }, - "application/vnd.cendio.thinlinc.clientconf": { - "source": "iana" - }, - "application/vnd.century-systems.tcp_stream": { - "source": "iana" - }, - "application/vnd.chemdraw+xml": { - "source": "iana", - "extensions": ["cdxml"] - }, - "application/vnd.chipnuts.karaoke-mmd": { - "source": "iana", - "extensions": ["mmd"] - }, - "application/vnd.cinderella": { - "source": "iana", - "extensions": ["cdy"] - }, - "application/vnd.cirpack.isdn-ext": { - "source": "iana" - }, - "application/vnd.citationstyles.style+xml": { - "source": "iana" - }, - "application/vnd.claymore": { - "source": "iana", - "extensions": ["cla"] - }, - "application/vnd.cloanto.rp9": { - "source": "iana", - "extensions": ["rp9"] - }, - "application/vnd.clonk.c4group": { - "source": "iana", - "extensions": ["c4g","c4d","c4f","c4p","c4u"] - }, - "application/vnd.cluetrust.cartomobile-config": { - "source": "iana", - "extensions": ["c11amc"] - }, - "application/vnd.cluetrust.cartomobile-config-pkg": { - "source": "iana", - "extensions": ["c11amz"] - }, - "application/vnd.coffeescript": { - "source": "iana" - }, - "application/vnd.collection+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.collection.doc+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.collection.next+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.commerce-battelle": { - "source": "iana" - }, - "application/vnd.commonspace": { - "source": "iana", - "extensions": ["csp"] - }, - "application/vnd.contact.cmsg": { - "source": "iana", - "extensions": ["cdbcmsg"] - }, - "application/vnd.coreos.ignition+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.cosmocaller": { - "source": "iana", - "extensions": ["cmc"] - }, - "application/vnd.crick.clicker": { - "source": "iana", - "extensions": ["clkx"] - }, - "application/vnd.crick.clicker.keyboard": { - "source": "iana", - "extensions": ["clkk"] - }, - "application/vnd.crick.clicker.palette": { - "source": "iana", - "extensions": ["clkp"] - }, - "application/vnd.crick.clicker.template": { - "source": "iana", - "extensions": ["clkt"] - }, - "application/vnd.crick.clicker.wordbank": { - "source": "iana", - "extensions": ["clkw"] - }, - "application/vnd.criticaltools.wbs+xml": { - "source": "iana", - "extensions": ["wbs"] - }, - "application/vnd.ctc-posml": { - "source": "iana", - "extensions": ["pml"] - }, - "application/vnd.ctct.ws+xml": { - "source": "iana" - }, - "application/vnd.cups-pdf": { - "source": "iana" - }, - "application/vnd.cups-postscript": { - "source": "iana" - }, - "application/vnd.cups-ppd": { - "source": "iana", - "extensions": ["ppd"] - }, - "application/vnd.cups-raster": { - "source": "iana" - }, - "application/vnd.cups-raw": { - "source": "iana" - }, - "application/vnd.curl": { - "source": "iana" - }, - "application/vnd.curl.car": { - "source": "apache", - "extensions": ["car"] - }, - "application/vnd.curl.pcurl": { - "source": "apache", - "extensions": ["pcurl"] - }, - "application/vnd.cyan.dean.root+xml": { - "source": "iana" - }, - "application/vnd.cybank": { - "source": "iana" - }, - "application/vnd.dart": { - "source": "iana", - "compressible": true, - "extensions": ["dart"] - }, - "application/vnd.data-vision.rdz": { - "source": "iana", - "extensions": ["rdz"] - }, - "application/vnd.debian.binary-package": { - "source": "iana" - }, - "application/vnd.dece.data": { - "source": "iana", - "extensions": ["uvf","uvvf","uvd","uvvd"] - }, - "application/vnd.dece.ttml+xml": { - "source": "iana", - "extensions": ["uvt","uvvt"] - }, - "application/vnd.dece.unspecified": { - "source": "iana", - "extensions": ["uvx","uvvx"] - }, - "application/vnd.dece.zip": { - "source": "iana", - "extensions": ["uvz","uvvz"] - }, - "application/vnd.denovo.fcselayout-link": { - "source": "iana", - "extensions": ["fe_launch"] - }, - "application/vnd.desmume-movie": { - "source": "iana" - }, - "application/vnd.desmume.movie": { - "source": "apache" - }, - "application/vnd.dir-bi.plate-dl-nosuffix": { - "source": "iana" - }, - "application/vnd.dm.delegation+xml": { - "source": "iana" - }, - "application/vnd.dna": { - "source": "iana", - "extensions": ["dna"] - }, - "application/vnd.document+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.dolby.mlp": { - "source": "apache", - "extensions": ["mlp"] - }, - "application/vnd.dolby.mobile.1": { - "source": "iana" - }, - "application/vnd.dolby.mobile.2": { - "source": "iana" - }, - "application/vnd.doremir.scorecloud-binary-document": { - "source": "iana" - }, - "application/vnd.dpgraph": { - "source": "iana", - "extensions": ["dpg"] - }, - "application/vnd.dreamfactory": { - "source": "iana", - "extensions": ["dfac"] - }, - "application/vnd.drive+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.ds-keypoint": { - "source": "apache", - "extensions": ["kpxx"] - }, - "application/vnd.dtg.local": { - "source": "iana" - }, - "application/vnd.dtg.local.flash": { - "source": "iana" - }, - "application/vnd.dtg.local.html": { - "source": "iana" - }, - "application/vnd.dvb.ait": { - "source": "iana", - "extensions": ["ait"] - }, - "application/vnd.dvb.dvbj": { - "source": "iana" - }, - "application/vnd.dvb.esgcontainer": { - "source": "iana" - }, - "application/vnd.dvb.ipdcdftnotifaccess": { - "source": "iana" - }, - "application/vnd.dvb.ipdcesgaccess": { - "source": "iana" - }, - "application/vnd.dvb.ipdcesgaccess2": { - "source": "iana" - }, - "application/vnd.dvb.ipdcesgpdd": { - "source": "iana" - }, - "application/vnd.dvb.ipdcroaming": { - "source": "iana" - }, - "application/vnd.dvb.iptv.alfec-base": { - "source": "iana" - }, - "application/vnd.dvb.iptv.alfec-enhancement": { - "source": "iana" - }, - "application/vnd.dvb.notif-aggregate-root+xml": { - "source": "iana" - }, - "application/vnd.dvb.notif-container+xml": { - "source": "iana" - }, - "application/vnd.dvb.notif-generic+xml": { - "source": "iana" - }, - "application/vnd.dvb.notif-ia-msglist+xml": { - "source": "iana" - }, - "application/vnd.dvb.notif-ia-registration-request+xml": { - "source": "iana" - }, - "application/vnd.dvb.notif-ia-registration-response+xml": { - "source": "iana" - }, - "application/vnd.dvb.notif-init+xml": { - "source": "iana" - }, - "application/vnd.dvb.pfr": { - "source": "iana" - }, - "application/vnd.dvb.service": { - "source": "iana", - "extensions": ["svc"] - }, - "application/vnd.dxr": { - "source": "iana" - }, - "application/vnd.dynageo": { - "source": "iana", - "extensions": ["geo"] - }, - "application/vnd.dzr": { - "source": "iana" - }, - "application/vnd.easykaraoke.cdgdownload": { - "source": "iana" - }, - "application/vnd.ecdis-update": { - "source": "iana" - }, - "application/vnd.ecowin.chart": { - "source": "iana", - "extensions": ["mag"] - }, - "application/vnd.ecowin.filerequest": { - "source": "iana" - }, - "application/vnd.ecowin.fileupdate": { - "source": "iana" - }, - "application/vnd.ecowin.series": { - "source": "iana" - }, - "application/vnd.ecowin.seriesrequest": { - "source": "iana" - }, - "application/vnd.ecowin.seriesupdate": { - "source": "iana" - }, - "application/vnd.emclient.accessrequest+xml": { - "source": "iana" - }, - "application/vnd.enliven": { - "source": "iana", - "extensions": ["nml"] - }, - "application/vnd.enphase.envoy": { - "source": "iana" - }, - "application/vnd.eprints.data+xml": { - "source": "iana" - }, - "application/vnd.epson.esf": { - "source": "iana", - "extensions": ["esf"] - }, - "application/vnd.epson.msf": { - "source": "iana", - "extensions": ["msf"] - }, - "application/vnd.epson.quickanime": { - "source": "iana", - "extensions": ["qam"] - }, - "application/vnd.epson.salt": { - "source": "iana", - "extensions": ["slt"] - }, - "application/vnd.epson.ssf": { - "source": "iana", - "extensions": ["ssf"] - }, - "application/vnd.ericsson.quickcall": { - "source": "iana" - }, - "application/vnd.eszigno3+xml": { - "source": "iana", - "extensions": ["es3","et3"] - }, - "application/vnd.etsi.aoc+xml": { - "source": "iana" - }, - "application/vnd.etsi.asic-e+zip": { - "source": "iana" - }, - "application/vnd.etsi.asic-s+zip": { - "source": "iana" - }, - "application/vnd.etsi.cug+xml": { - "source": "iana" - }, - "application/vnd.etsi.iptvcommand+xml": { - "source": "iana" - }, - "application/vnd.etsi.iptvdiscovery+xml": { - "source": "iana" - }, - "application/vnd.etsi.iptvprofile+xml": { - "source": "iana" - }, - "application/vnd.etsi.iptvsad-bc+xml": { - "source": "iana" - }, - "application/vnd.etsi.iptvsad-cod+xml": { - "source": "iana" - }, - "application/vnd.etsi.iptvsad-npvr+xml": { - "source": "iana" - }, - "application/vnd.etsi.iptvservice+xml": { - "source": "iana" - }, - "application/vnd.etsi.iptvsync+xml": { - "source": "iana" - }, - "application/vnd.etsi.iptvueprofile+xml": { - "source": "iana" - }, - "application/vnd.etsi.mcid+xml": { - "source": "iana" - }, - "application/vnd.etsi.mheg5": { - "source": "iana" - }, - "application/vnd.etsi.overload-control-policy-dataset+xml": { - "source": "iana" - }, - "application/vnd.etsi.pstn+xml": { - "source": "iana" - }, - "application/vnd.etsi.sci+xml": { - "source": "iana" - }, - "application/vnd.etsi.simservs+xml": { - "source": "iana" - }, - "application/vnd.etsi.timestamp-token": { - "source": "iana" - }, - "application/vnd.etsi.tsl+xml": { - "source": "iana" - }, - "application/vnd.etsi.tsl.der": { - "source": "iana" - }, - "application/vnd.eudora.data": { - "source": "iana" - }, - "application/vnd.ezpix-album": { - "source": "iana", - "extensions": ["ez2"] - }, - "application/vnd.ezpix-package": { - "source": "iana", - "extensions": ["ez3"] - }, - "application/vnd.f-secure.mobile": { - "source": "iana" - }, - "application/vnd.fastcopy-disk-image": { - "source": "iana" - }, - "application/vnd.fdf": { - "source": "iana", - "extensions": ["fdf"] - }, - "application/vnd.fdsn.mseed": { - "source": "iana", - "extensions": ["mseed"] - }, - "application/vnd.fdsn.seed": { - "source": "iana", - "extensions": ["seed","dataless"] - }, - "application/vnd.ffsns": { - "source": "iana" - }, - "application/vnd.filmit.zfc": { - "source": "iana" - }, - "application/vnd.fints": { - "source": "iana" - }, - "application/vnd.firemonkeys.cloudcell": { - "source": "iana" - }, - "application/vnd.flographit": { - "source": "iana", - "extensions": ["gph"] - }, - "application/vnd.fluxtime.clip": { - "source": "iana", - "extensions": ["ftc"] - }, - "application/vnd.font-fontforge-sfd": { - "source": "iana" - }, - "application/vnd.framemaker": { - "source": "iana", - "extensions": ["fm","frame","maker","book"] - }, - "application/vnd.frogans.fnc": { - "source": "iana", - "extensions": ["fnc"] - }, - "application/vnd.frogans.ltf": { - "source": "iana", - "extensions": ["ltf"] - }, - "application/vnd.fsc.weblaunch": { - "source": "iana", - "extensions": ["fsc"] - }, - "application/vnd.fujitsu.oasys": { - "source": "iana", - "extensions": ["oas"] - }, - "application/vnd.fujitsu.oasys2": { - "source": "iana", - "extensions": ["oa2"] - }, - "application/vnd.fujitsu.oasys3": { - "source": "iana", - "extensions": ["oa3"] - }, - "application/vnd.fujitsu.oasysgp": { - "source": "iana", - "extensions": ["fg5"] - }, - "application/vnd.fujitsu.oasysprs": { - "source": "iana", - "extensions": ["bh2"] - }, - "application/vnd.fujixerox.art-ex": { - "source": "iana" - }, - "application/vnd.fujixerox.art4": { - "source": "iana" - }, - "application/vnd.fujixerox.ddd": { - "source": "iana", - "extensions": ["ddd"] - }, - "application/vnd.fujixerox.docuworks": { - "source": "iana", - "extensions": ["xdw"] - }, - "application/vnd.fujixerox.docuworks.binder": { - "source": "iana", - "extensions": ["xbd"] - }, - "application/vnd.fujixerox.docuworks.container": { - "source": "iana" - }, - "application/vnd.fujixerox.hbpl": { - "source": "iana" - }, - "application/vnd.fut-misnet": { - "source": "iana" - }, - "application/vnd.fuzzysheet": { - "source": "iana", - "extensions": ["fzs"] - }, - "application/vnd.genomatix.tuxedo": { - "source": "iana", - "extensions": ["txd"] - }, - "application/vnd.geo+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.geocube+xml": { - "source": "iana" - }, - "application/vnd.geogebra.file": { - "source": "iana", - "extensions": ["ggb"] - }, - "application/vnd.geogebra.tool": { - "source": "iana", - "extensions": ["ggt"] - }, - "application/vnd.geometry-explorer": { - "source": "iana", - "extensions": ["gex","gre"] - }, - "application/vnd.geonext": { - "source": "iana", - "extensions": ["gxt"] - }, - "application/vnd.geoplan": { - "source": "iana", - "extensions": ["g2w"] - }, - "application/vnd.geospace": { - "source": "iana", - "extensions": ["g3w"] - }, - "application/vnd.gerber": { - "source": "iana" - }, - "application/vnd.globalplatform.card-content-mgt": { - "source": "iana" - }, - "application/vnd.globalplatform.card-content-mgt-response": { - "source": "iana" - }, - "application/vnd.gmx": { - "source": "iana", - "extensions": ["gmx"] - }, - "application/vnd.google-apps.document": { - "compressible": false, - "extensions": ["gdoc"] - }, - "application/vnd.google-apps.presentation": { - "compressible": false, - "extensions": ["gslides"] - }, - "application/vnd.google-apps.spreadsheet": { - "compressible": false, - "extensions": ["gsheet"] - }, - "application/vnd.google-earth.kml+xml": { - "source": "iana", - "compressible": true, - "extensions": ["kml"] - }, - "application/vnd.google-earth.kmz": { - "source": "iana", - "compressible": false, - "extensions": ["kmz"] - }, - "application/vnd.gov.sk.e-form+xml": { - "source": "iana" - }, - "application/vnd.gov.sk.e-form+zip": { - "source": "iana" - }, - "application/vnd.gov.sk.xmldatacontainer+xml": { - "source": "iana" - }, - "application/vnd.grafeq": { - "source": "iana", - "extensions": ["gqf","gqs"] - }, - "application/vnd.gridmp": { - "source": "iana" - }, - "application/vnd.groove-account": { - "source": "iana", - "extensions": ["gac"] - }, - "application/vnd.groove-help": { - "source": "iana", - "extensions": ["ghf"] - }, - "application/vnd.groove-identity-message": { - "source": "iana", - "extensions": ["gim"] - }, - "application/vnd.groove-injector": { - "source": "iana", - "extensions": ["grv"] - }, - "application/vnd.groove-tool-message": { - "source": "iana", - "extensions": ["gtm"] - }, - "application/vnd.groove-tool-template": { - "source": "iana", - "extensions": ["tpl"] - }, - "application/vnd.groove-vcard": { - "source": "iana", - "extensions": ["vcg"] - }, - "application/vnd.hal+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.hal+xml": { - "source": "iana", - "extensions": ["hal"] - }, - "application/vnd.handheld-entertainment+xml": { - "source": "iana", - "extensions": ["zmm"] - }, - "application/vnd.hbci": { - "source": "iana", - "extensions": ["hbci"] - }, - "application/vnd.hcl-bireports": { - "source": "iana" - }, - "application/vnd.hdt": { - "source": "iana" - }, - "application/vnd.heroku+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.hhe.lesson-player": { - "source": "iana", - "extensions": ["les"] - }, - "application/vnd.hp-hpgl": { - "source": "iana", - "extensions": ["hpgl"] - }, - "application/vnd.hp-hpid": { - "source": "iana", - "extensions": ["hpid"] - }, - "application/vnd.hp-hps": { - "source": "iana", - "extensions": ["hps"] - }, - "application/vnd.hp-jlyt": { - "source": "iana", - "extensions": ["jlt"] - }, - "application/vnd.hp-pcl": { - "source": "iana", - "extensions": ["pcl"] - }, - "application/vnd.hp-pclxl": { - "source": "iana", - "extensions": ["pclxl"] - }, - "application/vnd.httphone": { - "source": "iana" - }, - "application/vnd.hydrostatix.sof-data": { - "source": "iana", - "extensions": ["sfd-hdstx"] - }, - "application/vnd.hyperdrive+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.hzn-3d-crossword": { - "source": "iana" - }, - "application/vnd.ibm.afplinedata": { - "source": "iana" - }, - "application/vnd.ibm.electronic-media": { - "source": "iana" - }, - "application/vnd.ibm.minipay": { - "source": "iana", - "extensions": ["mpy"] - }, - "application/vnd.ibm.modcap": { - "source": "iana", - "extensions": ["afp","listafp","list3820"] - }, - "application/vnd.ibm.rights-management": { - "source": "iana", - "extensions": ["irm"] - }, - "application/vnd.ibm.secure-container": { - "source": "iana", - "extensions": ["sc"] - }, - "application/vnd.iccprofile": { - "source": "iana", - "extensions": ["icc","icm"] - }, - "application/vnd.ieee.1905": { - "source": "iana" - }, - "application/vnd.igloader": { - "source": "iana", - "extensions": ["igl"] - }, - "application/vnd.immervision-ivp": { - "source": "iana", - "extensions": ["ivp"] - }, - "application/vnd.immervision-ivu": { - "source": "iana", - "extensions": ["ivu"] - }, - "application/vnd.ims.imsccv1p1": { - "source": "iana" - }, - "application/vnd.ims.imsccv1p2": { - "source": "iana" - }, - "application/vnd.ims.imsccv1p3": { - "source": "iana" - }, - "application/vnd.ims.lis.v2.result+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.ims.lti.v2.toolconsumerprofile+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.ims.lti.v2.toolproxy+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.ims.lti.v2.toolproxy.id+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.ims.lti.v2.toolsettings+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.ims.lti.v2.toolsettings.simple+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.informedcontrol.rms+xml": { - "source": "iana" - }, - "application/vnd.informix-visionary": { - "source": "iana" - }, - "application/vnd.infotech.project": { - "source": "iana" - }, - "application/vnd.infotech.project+xml": { - "source": "iana" - }, - "application/vnd.innopath.wamp.notification": { - "source": "iana" - }, - "application/vnd.insors.igm": { - "source": "iana", - "extensions": ["igm"] - }, - "application/vnd.intercon.formnet": { - "source": "iana", - "extensions": ["xpw","xpx"] - }, - "application/vnd.intergeo": { - "source": "iana", - "extensions": ["i2g"] - }, - "application/vnd.intertrust.digibox": { - "source": "iana" - }, - "application/vnd.intertrust.nncp": { - "source": "iana" - }, - "application/vnd.intu.qbo": { - "source": "iana", - "extensions": ["qbo"] - }, - "application/vnd.intu.qfx": { - "source": "iana", - "extensions": ["qfx"] - }, - "application/vnd.iptc.g2.catalogitem+xml": { - "source": "iana" - }, - "application/vnd.iptc.g2.conceptitem+xml": { - "source": "iana" - }, - "application/vnd.iptc.g2.knowledgeitem+xml": { - "source": "iana" - }, - "application/vnd.iptc.g2.newsitem+xml": { - "source": "iana" - }, - "application/vnd.iptc.g2.newsmessage+xml": { - "source": "iana" - }, - "application/vnd.iptc.g2.packageitem+xml": { - "source": "iana" - }, - "application/vnd.iptc.g2.planningitem+xml": { - "source": "iana" - }, - "application/vnd.ipunplugged.rcprofile": { - "source": "iana", - "extensions": ["rcprofile"] - }, - "application/vnd.irepository.package+xml": { - "source": "iana", - "extensions": ["irp"] - }, - "application/vnd.is-xpr": { - "source": "iana", - "extensions": ["xpr"] - }, - "application/vnd.isac.fcs": { - "source": "iana", - "extensions": ["fcs"] - }, - "application/vnd.jam": { - "source": "iana", - "extensions": ["jam"] - }, - "application/vnd.japannet-directory-service": { - "source": "iana" - }, - "application/vnd.japannet-jpnstore-wakeup": { - "source": "iana" - }, - "application/vnd.japannet-payment-wakeup": { - "source": "iana" - }, - "application/vnd.japannet-registration": { - "source": "iana" - }, - "application/vnd.japannet-registration-wakeup": { - "source": "iana" - }, - "application/vnd.japannet-setstore-wakeup": { - "source": "iana" - }, - "application/vnd.japannet-verification": { - "source": "iana" - }, - "application/vnd.japannet-verification-wakeup": { - "source": "iana" - }, - "application/vnd.jcp.javame.midlet-rms": { - "source": "iana", - "extensions": ["rms"] - }, - "application/vnd.jisp": { - "source": "iana", - "extensions": ["jisp"] - }, - "application/vnd.joost.joda-archive": { - "source": "iana", - "extensions": ["joda"] - }, - "application/vnd.jsk.isdn-ngn": { - "source": "iana" - }, - "application/vnd.kahootz": { - "source": "iana", - "extensions": ["ktz","ktr"] - }, - "application/vnd.kde.karbon": { - "source": "iana", - "extensions": ["karbon"] - }, - "application/vnd.kde.kchart": { - "source": "iana", - "extensions": ["chrt"] - }, - "application/vnd.kde.kformula": { - "source": "iana", - "extensions": ["kfo"] - }, - "application/vnd.kde.kivio": { - "source": "iana", - "extensions": ["flw"] - }, - "application/vnd.kde.kontour": { - "source": "iana", - "extensions": ["kon"] - }, - "application/vnd.kde.kpresenter": { - "source": "iana", - "extensions": ["kpr","kpt"] - }, - "application/vnd.kde.kspread": { - "source": "iana", - "extensions": ["ksp"] - }, - "application/vnd.kde.kword": { - "source": "iana", - "extensions": ["kwd","kwt"] - }, - "application/vnd.kenameaapp": { - "source": "iana", - "extensions": ["htke"] - }, - "application/vnd.kidspiration": { - "source": "iana", - "extensions": ["kia"] - }, - "application/vnd.kinar": { - "source": "iana", - "extensions": ["kne","knp"] - }, - "application/vnd.koan": { - "source": "iana", - "extensions": ["skp","skd","skt","skm"] - }, - "application/vnd.kodak-descriptor": { - "source": "iana", - "extensions": ["sse"] - }, - "application/vnd.las.las+xml": { - "source": "iana", - "extensions": ["lasxml"] - }, - "application/vnd.liberty-request+xml": { - "source": "iana" - }, - "application/vnd.llamagraphics.life-balance.desktop": { - "source": "iana", - "extensions": ["lbd"] - }, - "application/vnd.llamagraphics.life-balance.exchange+xml": { - "source": "iana", - "extensions": ["lbe"] - }, - "application/vnd.lotus-1-2-3": { - "source": "iana", - "extensions": ["123"] - }, - "application/vnd.lotus-approach": { - "source": "iana", - "extensions": ["apr"] - }, - "application/vnd.lotus-freelance": { - "source": "iana", - "extensions": ["pre"] - }, - "application/vnd.lotus-notes": { - "source": "iana", - "extensions": ["nsf"] - }, - "application/vnd.lotus-organizer": { - "source": "iana", - "extensions": ["org"] - }, - "application/vnd.lotus-screencam": { - "source": "iana", - "extensions": ["scm"] - }, - "application/vnd.lotus-wordpro": { - "source": "iana", - "extensions": ["lwp"] - }, - "application/vnd.macports.portpkg": { - "source": "iana", - "extensions": ["portpkg"] - }, - "application/vnd.mapbox-vector-tile": { - "source": "iana" - }, - "application/vnd.marlin.drm.actiontoken+xml": { - "source": "iana" - }, - "application/vnd.marlin.drm.conftoken+xml": { - "source": "iana" - }, - "application/vnd.marlin.drm.license+xml": { - "source": "iana" - }, - "application/vnd.marlin.drm.mdcf": { - "source": "iana" - }, - "application/vnd.mason+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.maxmind.maxmind-db": { - "source": "iana" - }, - "application/vnd.mcd": { - "source": "iana", - "extensions": ["mcd"] - }, - "application/vnd.medcalcdata": { - "source": "iana", - "extensions": ["mc1"] - }, - "application/vnd.mediastation.cdkey": { - "source": "iana", - "extensions": ["cdkey"] - }, - "application/vnd.meridian-slingshot": { - "source": "iana" - }, - "application/vnd.mfer": { - "source": "iana", - "extensions": ["mwf"] - }, - "application/vnd.mfmp": { - "source": "iana", - "extensions": ["mfm"] - }, - "application/vnd.micro+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.micrografx.flo": { - "source": "iana", - "extensions": ["flo"] - }, - "application/vnd.micrografx.igx": { - "source": "iana", - "extensions": ["igx"] - }, - "application/vnd.microsoft.portable-executable": { - "source": "iana" - }, - "application/vnd.miele+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.mif": { - "source": "iana", - "extensions": ["mif"] - }, - "application/vnd.minisoft-hp3000-save": { - "source": "iana" - }, - "application/vnd.mitsubishi.misty-guard.trustweb": { - "source": "iana" - }, - "application/vnd.mobius.daf": { - "source": "iana", - "extensions": ["daf"] - }, - "application/vnd.mobius.dis": { - "source": "iana", - "extensions": ["dis"] - }, - "application/vnd.mobius.mbk": { - "source": "iana", - "extensions": ["mbk"] - }, - "application/vnd.mobius.mqy": { - "source": "iana", - "extensions": ["mqy"] - }, - "application/vnd.mobius.msl": { - "source": "iana", - "extensions": ["msl"] - }, - "application/vnd.mobius.plc": { - "source": "iana", - "extensions": ["plc"] - }, - "application/vnd.mobius.txf": { - "source": "iana", - "extensions": ["txf"] - }, - "application/vnd.mophun.application": { - "source": "iana", - "extensions": ["mpn"] - }, - "application/vnd.mophun.certificate": { - "source": "iana", - "extensions": ["mpc"] - }, - "application/vnd.motorola.flexsuite": { - "source": "iana" - }, - "application/vnd.motorola.flexsuite.adsi": { - "source": "iana" - }, - "application/vnd.motorola.flexsuite.fis": { - "source": "iana" - }, - "application/vnd.motorola.flexsuite.gotap": { - "source": "iana" - }, - "application/vnd.motorola.flexsuite.kmr": { - "source": "iana" - }, - "application/vnd.motorola.flexsuite.ttc": { - "source": "iana" - }, - "application/vnd.motorola.flexsuite.wem": { - "source": "iana" - }, - "application/vnd.motorola.iprm": { - "source": "iana" - }, - "application/vnd.mozilla.xul+xml": { - "source": "iana", - "compressible": true, - "extensions": ["xul"] - }, - "application/vnd.ms-3mfdocument": { - "source": "iana" - }, - "application/vnd.ms-artgalry": { - "source": "iana", - "extensions": ["cil"] - }, - "application/vnd.ms-asf": { - "source": "iana" - }, - "application/vnd.ms-cab-compressed": { - "source": "iana", - "extensions": ["cab"] - }, - "application/vnd.ms-color.iccprofile": { - "source": "apache" - }, - "application/vnd.ms-excel": { - "source": "iana", - "compressible": false, - "extensions": ["xls","xlm","xla","xlc","xlt","xlw"] - }, - "application/vnd.ms-excel.addin.macroenabled.12": { - "source": "iana", - "extensions": ["xlam"] - }, - "application/vnd.ms-excel.sheet.binary.macroenabled.12": { - "source": "iana", - "extensions": ["xlsb"] - }, - "application/vnd.ms-excel.sheet.macroenabled.12": { - "source": "iana", - "extensions": ["xlsm"] - }, - "application/vnd.ms-excel.template.macroenabled.12": { - "source": "iana", - "extensions": ["xltm"] - }, - "application/vnd.ms-fontobject": { - "source": "iana", - "compressible": true, - "extensions": ["eot"] - }, - "application/vnd.ms-htmlhelp": { - "source": "iana", - "extensions": ["chm"] - }, - "application/vnd.ms-ims": { - "source": "iana", - "extensions": ["ims"] - }, - "application/vnd.ms-lrm": { - "source": "iana", - "extensions": ["lrm"] - }, - "application/vnd.ms-office.activex+xml": { - "source": "iana" - }, - "application/vnd.ms-officetheme": { - "source": "iana", - "extensions": ["thmx"] - }, - "application/vnd.ms-opentype": { - "source": "apache", - "compressible": true - }, - "application/vnd.ms-package.obfuscated-opentype": { - "source": "apache" - }, - "application/vnd.ms-pki.seccat": { - "source": "apache", - "extensions": ["cat"] - }, - "application/vnd.ms-pki.stl": { - "source": "apache", - "extensions": ["stl"] - }, - "application/vnd.ms-playready.initiator+xml": { - "source": "iana" - }, - "application/vnd.ms-powerpoint": { - "source": "iana", - "compressible": false, - "extensions": ["ppt","pps","pot"] - }, - "application/vnd.ms-powerpoint.addin.macroenabled.12": { - "source": "iana", - "extensions": ["ppam"] - }, - "application/vnd.ms-powerpoint.presentation.macroenabled.12": { - "source": "iana", - "extensions": ["pptm"] - }, - "application/vnd.ms-powerpoint.slide.macroenabled.12": { - "source": "iana", - "extensions": ["sldm"] - }, - "application/vnd.ms-powerpoint.slideshow.macroenabled.12": { - "source": "iana", - "extensions": ["ppsm"] - }, - "application/vnd.ms-powerpoint.template.macroenabled.12": { - "source": "iana", - "extensions": ["potm"] - }, - "application/vnd.ms-printdevicecapabilities+xml": { - "source": "iana" - }, - "application/vnd.ms-printing.printticket+xml": { - "source": "apache" - }, - "application/vnd.ms-printschematicket+xml": { - "source": "iana" - }, - "application/vnd.ms-project": { - "source": "iana", - "extensions": ["mpp","mpt"] - }, - "application/vnd.ms-tnef": { - "source": "iana" - }, - "application/vnd.ms-windows.devicepairing": { - "source": "iana" - }, - "application/vnd.ms-windows.nwprinting.oob": { - "source": "iana" - }, - "application/vnd.ms-windows.printerpairing": { - "source": "iana" - }, - "application/vnd.ms-windows.wsd.oob": { - "source": "iana" - }, - "application/vnd.ms-wmdrm.lic-chlg-req": { - "source": "iana" - }, - "application/vnd.ms-wmdrm.lic-resp": { - "source": "iana" - }, - "application/vnd.ms-wmdrm.meter-chlg-req": { - "source": "iana" - }, - "application/vnd.ms-wmdrm.meter-resp": { - "source": "iana" - }, - "application/vnd.ms-word.document.macroenabled.12": { - "source": "iana", - "extensions": ["docm"] - }, - "application/vnd.ms-word.template.macroenabled.12": { - "source": "iana", - "extensions": ["dotm"] - }, - "application/vnd.ms-works": { - "source": "iana", - "extensions": ["wps","wks","wcm","wdb"] - }, - "application/vnd.ms-wpl": { - "source": "iana", - "extensions": ["wpl"] - }, - "application/vnd.ms-xpsdocument": { - "source": "iana", - "compressible": false, - "extensions": ["xps"] - }, - "application/vnd.msa-disk-image": { - "source": "iana" - }, - "application/vnd.mseq": { - "source": "iana", - "extensions": ["mseq"] - }, - "application/vnd.msign": { - "source": "iana" - }, - "application/vnd.multiad.creator": { - "source": "iana" - }, - "application/vnd.multiad.creator.cif": { - "source": "iana" - }, - "application/vnd.music-niff": { - "source": "iana" - }, - "application/vnd.musician": { - "source": "iana", - "extensions": ["mus"] - }, - "application/vnd.muvee.style": { - "source": "iana", - "extensions": ["msty"] - }, - "application/vnd.mynfc": { - "source": "iana", - "extensions": ["taglet"] - }, - "application/vnd.ncd.control": { - "source": "iana" - }, - "application/vnd.ncd.reference": { - "source": "iana" - }, - "application/vnd.nervana": { - "source": "iana" - }, - "application/vnd.netfpx": { - "source": "iana" - }, - "application/vnd.neurolanguage.nlu": { - "source": "iana", - "extensions": ["nlu"] - }, - "application/vnd.nintendo.nitro.rom": { - "source": "iana" - }, - "application/vnd.nintendo.snes.rom": { - "source": "iana" - }, - "application/vnd.nitf": { - "source": "iana", - "extensions": ["ntf","nitf"] - }, - "application/vnd.noblenet-directory": { - "source": "iana", - "extensions": ["nnd"] - }, - "application/vnd.noblenet-sealer": { - "source": "iana", - "extensions": ["nns"] - }, - "application/vnd.noblenet-web": { - "source": "iana", - "extensions": ["nnw"] - }, - "application/vnd.nokia.catalogs": { - "source": "iana" - }, - "application/vnd.nokia.conml+wbxml": { - "source": "iana" - }, - "application/vnd.nokia.conml+xml": { - "source": "iana" - }, - "application/vnd.nokia.iptv.config+xml": { - "source": "iana" - }, - "application/vnd.nokia.isds-radio-presets": { - "source": "iana" - }, - "application/vnd.nokia.landmark+wbxml": { - "source": "iana" - }, - "application/vnd.nokia.landmark+xml": { - "source": "iana" - }, - "application/vnd.nokia.landmarkcollection+xml": { - "source": "iana" - }, - "application/vnd.nokia.n-gage.ac+xml": { - "source": "iana" - }, - "application/vnd.nokia.n-gage.data": { - "source": "iana", - "extensions": ["ngdat"] - }, - "application/vnd.nokia.n-gage.symbian.install": { - "source": "iana", - "extensions": ["n-gage"] - }, - "application/vnd.nokia.ncd": { - "source": "iana" - }, - "application/vnd.nokia.pcd+wbxml": { - "source": "iana" - }, - "application/vnd.nokia.pcd+xml": { - "source": "iana" - }, - "application/vnd.nokia.radio-preset": { - "source": "iana", - "extensions": ["rpst"] - }, - "application/vnd.nokia.radio-presets": { - "source": "iana", - "extensions": ["rpss"] - }, - "application/vnd.novadigm.edm": { - "source": "iana", - "extensions": ["edm"] - }, - "application/vnd.novadigm.edx": { - "source": "iana", - "extensions": ["edx"] - }, - "application/vnd.novadigm.ext": { - "source": "iana", - "extensions": ["ext"] - }, - "application/vnd.ntt-local.content-share": { - "source": "iana" - }, - "application/vnd.ntt-local.file-transfer": { - "source": "iana" - }, - "application/vnd.ntt-local.ogw_remote-access": { - "source": "iana" - }, - "application/vnd.ntt-local.sip-ta_remote": { - "source": "iana" - }, - "application/vnd.ntt-local.sip-ta_tcp_stream": { - "source": "iana" - }, - "application/vnd.oasis.opendocument.chart": { - "source": "iana", - "extensions": ["odc"] - }, - "application/vnd.oasis.opendocument.chart-template": { - "source": "iana", - "extensions": ["otc"] - }, - "application/vnd.oasis.opendocument.database": { - "source": "iana", - "extensions": ["odb"] - }, - "application/vnd.oasis.opendocument.formula": { - "source": "iana", - "extensions": ["odf"] - }, - "application/vnd.oasis.opendocument.formula-template": { - "source": "iana", - "extensions": ["odft"] - }, - "application/vnd.oasis.opendocument.graphics": { - "source": "iana", - "compressible": false, - "extensions": ["odg"] - }, - "application/vnd.oasis.opendocument.graphics-template": { - "source": "iana", - "extensions": ["otg"] - }, - "application/vnd.oasis.opendocument.image": { - "source": "iana", - "extensions": ["odi"] - }, - "application/vnd.oasis.opendocument.image-template": { - "source": "iana", - "extensions": ["oti"] - }, - "application/vnd.oasis.opendocument.presentation": { - "source": "iana", - "compressible": false, - "extensions": ["odp"] - }, - "application/vnd.oasis.opendocument.presentation-template": { - "source": "iana", - "extensions": ["otp"] - }, - "application/vnd.oasis.opendocument.spreadsheet": { - "source": "iana", - "compressible": false, - "extensions": ["ods"] - }, - "application/vnd.oasis.opendocument.spreadsheet-template": { - "source": "iana", - "extensions": ["ots"] - }, - "application/vnd.oasis.opendocument.text": { - "source": "iana", - "compressible": false, - "extensions": ["odt"] - }, - "application/vnd.oasis.opendocument.text-master": { - "source": "iana", - "extensions": ["odm"] - }, - "application/vnd.oasis.opendocument.text-template": { - "source": "iana", - "extensions": ["ott"] - }, - "application/vnd.oasis.opendocument.text-web": { - "source": "iana", - "extensions": ["oth"] - }, - "application/vnd.obn": { - "source": "iana" - }, - "application/vnd.oftn.l10n+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.oipf.contentaccessdownload+xml": { - "source": "iana" - }, - "application/vnd.oipf.contentaccessstreaming+xml": { - "source": "iana" - }, - "application/vnd.oipf.cspg-hexbinary": { - "source": "iana" - }, - "application/vnd.oipf.dae.svg+xml": { - "source": "iana" - }, - "application/vnd.oipf.dae.xhtml+xml": { - "source": "iana" - }, - "application/vnd.oipf.mippvcontrolmessage+xml": { - "source": "iana" - }, - "application/vnd.oipf.pae.gem": { - "source": "iana" - }, - "application/vnd.oipf.spdiscovery+xml": { - "source": "iana" - }, - "application/vnd.oipf.spdlist+xml": { - "source": "iana" - }, - "application/vnd.oipf.ueprofile+xml": { - "source": "iana" - }, - "application/vnd.oipf.userprofile+xml": { - "source": "iana" - }, - "application/vnd.olpc-sugar": { - "source": "iana", - "extensions": ["xo"] - }, - "application/vnd.oma-scws-config": { - "source": "iana" - }, - "application/vnd.oma-scws-http-request": { - "source": "iana" - }, - "application/vnd.oma-scws-http-response": { - "source": "iana" - }, - "application/vnd.oma.bcast.associated-procedure-parameter+xml": { - "source": "iana" - }, - "application/vnd.oma.bcast.drm-trigger+xml": { - "source": "iana" - }, - "application/vnd.oma.bcast.imd+xml": { - "source": "iana" - }, - "application/vnd.oma.bcast.ltkm": { - "source": "iana" - }, - "application/vnd.oma.bcast.notification+xml": { - "source": "iana" - }, - "application/vnd.oma.bcast.provisioningtrigger": { - "source": "iana" - }, - "application/vnd.oma.bcast.sgboot": { - "source": "iana" - }, - "application/vnd.oma.bcast.sgdd+xml": { - "source": "iana" - }, - "application/vnd.oma.bcast.sgdu": { - "source": "iana" - }, - "application/vnd.oma.bcast.simple-symbol-container": { - "source": "iana" - }, - "application/vnd.oma.bcast.smartcard-trigger+xml": { - "source": "iana" - }, - "application/vnd.oma.bcast.sprov+xml": { - "source": "iana" - }, - "application/vnd.oma.bcast.stkm": { - "source": "iana" - }, - "application/vnd.oma.cab-address-book+xml": { - "source": "iana" - }, - "application/vnd.oma.cab-feature-handler+xml": { - "source": "iana" - }, - "application/vnd.oma.cab-pcc+xml": { - "source": "iana" - }, - "application/vnd.oma.cab-subs-invite+xml": { - "source": "iana" - }, - "application/vnd.oma.cab-user-prefs+xml": { - "source": "iana" - }, - "application/vnd.oma.dcd": { - "source": "iana" - }, - "application/vnd.oma.dcdc": { - "source": "iana" - }, - "application/vnd.oma.dd2+xml": { - "source": "iana", - "extensions": ["dd2"] - }, - "application/vnd.oma.drm.risd+xml": { - "source": "iana" - }, - "application/vnd.oma.group-usage-list+xml": { - "source": "iana" - }, - "application/vnd.oma.pal+xml": { - "source": "iana" - }, - "application/vnd.oma.poc.detailed-progress-report+xml": { - "source": "iana" - }, - "application/vnd.oma.poc.final-report+xml": { - "source": "iana" - }, - "application/vnd.oma.poc.groups+xml": { - "source": "iana" - }, - "application/vnd.oma.poc.invocation-descriptor+xml": { - "source": "iana" - }, - "application/vnd.oma.poc.optimized-progress-report+xml": { - "source": "iana" - }, - "application/vnd.oma.push": { - "source": "iana" - }, - "application/vnd.oma.scidm.messages+xml": { - "source": "iana" - }, - "application/vnd.oma.xcap-directory+xml": { - "source": "iana" - }, - "application/vnd.omads-email+xml": { - "source": "iana" - }, - "application/vnd.omads-file+xml": { - "source": "iana" - }, - "application/vnd.omads-folder+xml": { - "source": "iana" - }, - "application/vnd.omaloc-supl-init": { - "source": "iana" - }, - "application/vnd.onepager": { - "source": "iana" - }, - "application/vnd.openblox.game+xml": { - "source": "iana" - }, - "application/vnd.openblox.game-binary": { - "source": "iana" - }, - "application/vnd.openeye.oeb": { - "source": "iana" - }, - "application/vnd.openofficeorg.extension": { - "source": "apache", - "extensions": ["oxt"] - }, - "application/vnd.openxmlformats-officedocument.custom-properties+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.customxmlproperties+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.drawing+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.drawingml.chart+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.drawingml.diagramcolors+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.drawingml.diagramdata+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.drawingml.diagramlayout+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.drawingml.diagramstyle+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.extended-properties+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml-template": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.commentauthors+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.comments+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.handoutmaster+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.notesmaster+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.notesslide+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.presentation": { - "source": "iana", - "compressible": false, - "extensions": ["pptx"] - }, - "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.presprops+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.slide": { - "source": "iana", - "extensions": ["sldx"] - }, - "application/vnd.openxmlformats-officedocument.presentationml.slide+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.slidelayout+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.slidemaster+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.slideshow": { - "source": "iana", - "extensions": ["ppsx"] - }, - "application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.slideupdateinfo+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.tablestyles+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.tags+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.template": { - "source": "apache", - "extensions": ["potx"] - }, - "application/vnd.openxmlformats-officedocument.presentationml.template.main+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.viewprops+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml-template": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.calcchain+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.externallink+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcachedefinition+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcacherecords+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.pivottable+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.querytable+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.revisionheaders+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.revisionlog+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedstrings+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": { - "source": "iana", - "compressible": false, - "extensions": ["xlsx"] - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheetmetadata+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.tablesinglecells+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.template": { - "source": "apache", - "extensions": ["xltx"] - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.usernames+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.volatiledependencies+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.theme+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.themeoverride+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.vmldrawing": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml-template": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml.document": { - "source": "iana", - "compressible": false, - "extensions": ["docx"] - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml.fonttable+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml.template": { - "source": "apache", - "extensions": ["dotx"] - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml.websettings+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-package.core-properties+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-package.relationships+xml": { - "source": "iana" - }, - "application/vnd.oracle.resource+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.orange.indata": { - "source": "iana" - }, - "application/vnd.osa.netdeploy": { - "source": "iana" - }, - "application/vnd.osgeo.mapguide.package": { - "source": "iana", - "extensions": ["mgp"] - }, - "application/vnd.osgi.bundle": { - "source": "iana" - }, - "application/vnd.osgi.dp": { - "source": "iana", - "extensions": ["dp"] - }, - "application/vnd.osgi.subsystem": { - "source": "iana", - "extensions": ["esa"] - }, - "application/vnd.otps.ct-kip+xml": { - "source": "iana" - }, - "application/vnd.oxli.countgraph": { - "source": "iana" - }, - "application/vnd.pagerduty+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.palm": { - "source": "iana", - "extensions": ["pdb","pqa","oprc"] - }, - "application/vnd.panoply": { - "source": "iana" - }, - "application/vnd.paos+xml": { - "source": "iana" - }, - "application/vnd.paos.xml": { - "source": "apache" - }, - "application/vnd.pawaafile": { - "source": "iana", - "extensions": ["paw"] - }, - "application/vnd.pcos": { - "source": "iana" - }, - "application/vnd.pg.format": { - "source": "iana", - "extensions": ["str"] - }, - "application/vnd.pg.osasli": { - "source": "iana", - "extensions": ["ei6"] - }, - "application/vnd.piaccess.application-licence": { - "source": "iana" - }, - "application/vnd.picsel": { - "source": "iana", - "extensions": ["efif"] - }, - "application/vnd.pmi.widget": { - "source": "iana", - "extensions": ["wg"] - }, - "application/vnd.poc.group-advertisement+xml": { - "source": "iana" - }, - "application/vnd.pocketlearn": { - "source": "iana", - "extensions": ["plf"] - }, - "application/vnd.powerbuilder6": { - "source": "iana", - "extensions": ["pbd"] - }, - "application/vnd.powerbuilder6-s": { - "source": "iana" - }, - "application/vnd.powerbuilder7": { - "source": "iana" - }, - "application/vnd.powerbuilder7-s": { - "source": "iana" - }, - "application/vnd.powerbuilder75": { - "source": "iana" - }, - "application/vnd.powerbuilder75-s": { - "source": "iana" - }, - "application/vnd.preminet": { - "source": "iana" - }, - "application/vnd.previewsystems.box": { - "source": "iana", - "extensions": ["box"] - }, - "application/vnd.proteus.magazine": { - "source": "iana", - "extensions": ["mgz"] - }, - "application/vnd.publishare-delta-tree": { - "source": "iana", - "extensions": ["qps"] - }, - "application/vnd.pvi.ptid1": { - "source": "iana", - "extensions": ["ptid"] - }, - "application/vnd.pwg-multiplexed": { - "source": "iana" - }, - "application/vnd.pwg-xhtml-print+xml": { - "source": "iana" - }, - "application/vnd.qualcomm.brew-app-res": { - "source": "iana" - }, - "application/vnd.quark.quarkxpress": { - "source": "iana", - "extensions": ["qxd","qxt","qwd","qwt","qxl","qxb"] - }, - "application/vnd.quobject-quoxdocument": { - "source": "iana" - }, - "application/vnd.radisys.moml+xml": { - "source": "iana" - }, - "application/vnd.radisys.msml+xml": { - "source": "iana" - }, - "application/vnd.radisys.msml-audit+xml": { - "source": "iana" - }, - "application/vnd.radisys.msml-audit-conf+xml": { - "source": "iana" - }, - "application/vnd.radisys.msml-audit-conn+xml": { - "source": "iana" - }, - "application/vnd.radisys.msml-audit-dialog+xml": { - "source": "iana" - }, - "application/vnd.radisys.msml-audit-stream+xml": { - "source": "iana" - }, - "application/vnd.radisys.msml-conf+xml": { - "source": "iana" - }, - "application/vnd.radisys.msml-dialog+xml": { - "source": "iana" - }, - "application/vnd.radisys.msml-dialog-base+xml": { - "source": "iana" - }, - "application/vnd.radisys.msml-dialog-fax-detect+xml": { - "source": "iana" - }, - "application/vnd.radisys.msml-dialog-fax-sendrecv+xml": { - "source": "iana" - }, - "application/vnd.radisys.msml-dialog-group+xml": { - "source": "iana" - }, - "application/vnd.radisys.msml-dialog-speech+xml": { - "source": "iana" - }, - "application/vnd.radisys.msml-dialog-transform+xml": { - "source": "iana" - }, - "application/vnd.rainstor.data": { - "source": "iana" - }, - "application/vnd.rapid": { - "source": "iana" - }, - "application/vnd.realvnc.bed": { - "source": "iana", - "extensions": ["bed"] - }, - "application/vnd.recordare.musicxml": { - "source": "iana", - "extensions": ["mxl"] - }, - "application/vnd.recordare.musicxml+xml": { - "source": "iana", - "extensions": ["musicxml"] - }, - "application/vnd.renlearn.rlprint": { - "source": "iana" - }, - "application/vnd.rig.cryptonote": { - "source": "iana", - "extensions": ["cryptonote"] - }, - "application/vnd.rim.cod": { - "source": "apache", - "extensions": ["cod"] - }, - "application/vnd.rn-realmedia": { - "source": "apache", - "extensions": ["rm"] - }, - "application/vnd.rn-realmedia-vbr": { - "source": "apache", - "extensions": ["rmvb"] - }, - "application/vnd.route66.link66+xml": { - "source": "iana", - "extensions": ["link66"] - }, - "application/vnd.rs-274x": { - "source": "iana" - }, - "application/vnd.ruckus.download": { - "source": "iana" - }, - "application/vnd.s3sms": { - "source": "iana" - }, - "application/vnd.sailingtracker.track": { - "source": "iana", - "extensions": ["st"] - }, - "application/vnd.sbm.cid": { - "source": "iana" - }, - "application/vnd.sbm.mid2": { - "source": "iana" - }, - "application/vnd.scribus": { - "source": "iana" - }, - "application/vnd.sealed.3df": { - "source": "iana" - }, - "application/vnd.sealed.csf": { - "source": "iana" - }, - "application/vnd.sealed.doc": { - "source": "iana" - }, - "application/vnd.sealed.eml": { - "source": "iana" - }, - "application/vnd.sealed.mht": { - "source": "iana" - }, - "application/vnd.sealed.net": { - "source": "iana" - }, - "application/vnd.sealed.ppt": { - "source": "iana" - }, - "application/vnd.sealed.tiff": { - "source": "iana" - }, - "application/vnd.sealed.xls": { - "source": "iana" - }, - "application/vnd.sealedmedia.softseal.html": { - "source": "iana" - }, - "application/vnd.sealedmedia.softseal.pdf": { - "source": "iana" - }, - "application/vnd.seemail": { - "source": "iana", - "extensions": ["see"] - }, - "application/vnd.sema": { - "source": "iana", - "extensions": ["sema"] - }, - "application/vnd.semd": { - "source": "iana", - "extensions": ["semd"] - }, - "application/vnd.semf": { - "source": "iana", - "extensions": ["semf"] - }, - "application/vnd.shana.informed.formdata": { - "source": "iana", - "extensions": ["ifm"] - }, - "application/vnd.shana.informed.formtemplate": { - "source": "iana", - "extensions": ["itp"] - }, - "application/vnd.shana.informed.interchange": { - "source": "iana", - "extensions": ["iif"] - }, - "application/vnd.shana.informed.package": { - "source": "iana", - "extensions": ["ipk"] - }, - "application/vnd.simtech-mindmapper": { - "source": "iana", - "extensions": ["twd","twds"] - }, - "application/vnd.siren+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.smaf": { - "source": "iana", - "extensions": ["mmf"] - }, - "application/vnd.smart.notebook": { - "source": "iana" - }, - "application/vnd.smart.teacher": { - "source": "iana", - "extensions": ["teacher"] - }, - "application/vnd.software602.filler.form+xml": { - "source": "iana" - }, - "application/vnd.software602.filler.form-xml-zip": { - "source": "iana" - }, - "application/vnd.solent.sdkm+xml": { - "source": "iana", - "extensions": ["sdkm","sdkd"] - }, - "application/vnd.spotfire.dxp": { - "source": "iana", - "extensions": ["dxp"] - }, - "application/vnd.spotfire.sfs": { - "source": "iana", - "extensions": ["sfs"] - }, - "application/vnd.sss-cod": { - "source": "iana" - }, - "application/vnd.sss-dtf": { - "source": "iana" - }, - "application/vnd.sss-ntf": { - "source": "iana" - }, - "application/vnd.stardivision.calc": { - "source": "apache", - "extensions": ["sdc"] - }, - "application/vnd.stardivision.draw": { - "source": "apache", - "extensions": ["sda"] - }, - "application/vnd.stardivision.impress": { - "source": "apache", - "extensions": ["sdd"] - }, - "application/vnd.stardivision.math": { - "source": "apache", - "extensions": ["smf"] - }, - "application/vnd.stardivision.writer": { - "source": "apache", - "extensions": ["sdw","vor"] - }, - "application/vnd.stardivision.writer-global": { - "source": "apache", - "extensions": ["sgl"] - }, - "application/vnd.stepmania.package": { - "source": "iana", - "extensions": ["smzip"] - }, - "application/vnd.stepmania.stepchart": { - "source": "iana", - "extensions": ["sm"] - }, - "application/vnd.street-stream": { - "source": "iana" - }, - "application/vnd.sun.wadl+xml": { - "source": "iana" - }, - "application/vnd.sun.xml.calc": { - "source": "apache", - "extensions": ["sxc"] - }, - "application/vnd.sun.xml.calc.template": { - "source": "apache", - "extensions": ["stc"] - }, - "application/vnd.sun.xml.draw": { - "source": "apache", - "extensions": ["sxd"] - }, - "application/vnd.sun.xml.draw.template": { - "source": "apache", - "extensions": ["std"] - }, - "application/vnd.sun.xml.impress": { - "source": "apache", - "extensions": ["sxi"] - }, - "application/vnd.sun.xml.impress.template": { - "source": "apache", - "extensions": ["sti"] - }, - "application/vnd.sun.xml.math": { - "source": "apache", - "extensions": ["sxm"] - }, - "application/vnd.sun.xml.writer": { - "source": "apache", - "extensions": ["sxw"] - }, - "application/vnd.sun.xml.writer.global": { - "source": "apache", - "extensions": ["sxg"] - }, - "application/vnd.sun.xml.writer.template": { - "source": "apache", - "extensions": ["stw"] - }, - "application/vnd.sus-calendar": { - "source": "iana", - "extensions": ["sus","susp"] - }, - "application/vnd.svd": { - "source": "iana", - "extensions": ["svd"] - }, - "application/vnd.swiftview-ics": { - "source": "iana" - }, - "application/vnd.symbian.install": { - "source": "apache", - "extensions": ["sis","sisx"] - }, - "application/vnd.syncml+xml": { - "source": "iana", - "extensions": ["xsm"] - }, - "application/vnd.syncml.dm+wbxml": { - "source": "iana", - "extensions": ["bdm"] - }, - "application/vnd.syncml.dm+xml": { - "source": "iana", - "extensions": ["xdm"] - }, - "application/vnd.syncml.dm.notification": { - "source": "iana" - }, - "application/vnd.syncml.dmddf+wbxml": { - "source": "iana" - }, - "application/vnd.syncml.dmddf+xml": { - "source": "iana" - }, - "application/vnd.syncml.dmtnds+wbxml": { - "source": "iana" - }, - "application/vnd.syncml.dmtnds+xml": { - "source": "iana" - }, - "application/vnd.syncml.ds.notification": { - "source": "iana" - }, - "application/vnd.tao.intent-module-archive": { - "source": "iana", - "extensions": ["tao"] - }, - "application/vnd.tcpdump.pcap": { - "source": "iana", - "extensions": ["pcap","cap","dmp"] - }, - "application/vnd.tmd.mediaflex.api+xml": { - "source": "iana" - }, - "application/vnd.tml": { - "source": "iana" - }, - "application/vnd.tmobile-livetv": { - "source": "iana", - "extensions": ["tmo"] - }, - "application/vnd.trid.tpt": { - "source": "iana", - "extensions": ["tpt"] - }, - "application/vnd.triscape.mxs": { - "source": "iana", - "extensions": ["mxs"] - }, - "application/vnd.trueapp": { - "source": "iana", - "extensions": ["tra"] - }, - "application/vnd.truedoc": { - "source": "iana" - }, - "application/vnd.ubisoft.webplayer": { - "source": "iana" - }, - "application/vnd.ufdl": { - "source": "iana", - "extensions": ["ufd","ufdl"] - }, - "application/vnd.uiq.theme": { - "source": "iana", - "extensions": ["utz"] - }, - "application/vnd.umajin": { - "source": "iana", - "extensions": ["umj"] - }, - "application/vnd.unity": { - "source": "iana", - "extensions": ["unityweb"] - }, - "application/vnd.uoml+xml": { - "source": "iana", - "extensions": ["uoml"] - }, - "application/vnd.uplanet.alert": { - "source": "iana" - }, - "application/vnd.uplanet.alert-wbxml": { - "source": "iana" - }, - "application/vnd.uplanet.bearer-choice": { - "source": "iana" - }, - "application/vnd.uplanet.bearer-choice-wbxml": { - "source": "iana" - }, - "application/vnd.uplanet.cacheop": { - "source": "iana" - }, - "application/vnd.uplanet.cacheop-wbxml": { - "source": "iana" - }, - "application/vnd.uplanet.channel": { - "source": "iana" - }, - "application/vnd.uplanet.channel-wbxml": { - "source": "iana" - }, - "application/vnd.uplanet.list": { - "source": "iana" - }, - "application/vnd.uplanet.list-wbxml": { - "source": "iana" - }, - "application/vnd.uplanet.listcmd": { - "source": "iana" - }, - "application/vnd.uplanet.listcmd-wbxml": { - "source": "iana" - }, - "application/vnd.uplanet.signal": { - "source": "iana" - }, - "application/vnd.uri-map": { - "source": "iana" - }, - "application/vnd.valve.source.material": { - "source": "iana" - }, - "application/vnd.vcx": { - "source": "iana", - "extensions": ["vcx"] - }, - "application/vnd.vd-study": { - "source": "iana" - }, - "application/vnd.vectorworks": { - "source": "iana" - }, - "application/vnd.vel+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.verimatrix.vcas": { - "source": "iana" - }, - "application/vnd.vidsoft.vidconference": { - "source": "iana" - }, - "application/vnd.visio": { - "source": "iana", - "extensions": ["vsd","vst","vss","vsw"] - }, - "application/vnd.visionary": { - "source": "iana", - "extensions": ["vis"] - }, - "application/vnd.vividence.scriptfile": { - "source": "iana" - }, - "application/vnd.vsf": { - "source": "iana", - "extensions": ["vsf"] - }, - "application/vnd.wap.sic": { - "source": "iana" - }, - "application/vnd.wap.slc": { - "source": "iana" - }, - "application/vnd.wap.wbxml": { - "source": "iana", - "extensions": ["wbxml"] - }, - "application/vnd.wap.wmlc": { - "source": "iana", - "extensions": ["wmlc"] - }, - "application/vnd.wap.wmlscriptc": { - "source": "iana", - "extensions": ["wmlsc"] - }, - "application/vnd.webturbo": { - "source": "iana", - "extensions": ["wtb"] - }, - "application/vnd.wfa.p2p": { - "source": "iana" - }, - "application/vnd.wfa.wsc": { - "source": "iana" - }, - "application/vnd.windows.devicepairing": { - "source": "iana" - }, - "application/vnd.wmc": { - "source": "iana" - }, - "application/vnd.wmf.bootstrap": { - "source": "iana" - }, - "application/vnd.wolfram.mathematica": { - "source": "iana" - }, - "application/vnd.wolfram.mathematica.package": { - "source": "iana" - }, - "application/vnd.wolfram.player": { - "source": "iana", - "extensions": ["nbp"] - }, - "application/vnd.wordperfect": { - "source": "iana", - "extensions": ["wpd"] - }, - "application/vnd.wqd": { - "source": "iana", - "extensions": ["wqd"] - }, - "application/vnd.wrq-hp3000-labelled": { - "source": "iana" - }, - "application/vnd.wt.stf": { - "source": "iana", - "extensions": ["stf"] - }, - "application/vnd.wv.csp+wbxml": { - "source": "iana" - }, - "application/vnd.wv.csp+xml": { - "source": "iana" - }, - "application/vnd.wv.ssp+xml": { - "source": "iana" - }, - "application/vnd.xacml+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.xara": { - "source": "iana", - "extensions": ["xar"] - }, - "application/vnd.xfdl": { - "source": "iana", - "extensions": ["xfdl"] - }, - "application/vnd.xfdl.webform": { - "source": "iana" - }, - "application/vnd.xmi+xml": { - "source": "iana" - }, - "application/vnd.xmpie.cpkg": { - "source": "iana" - }, - "application/vnd.xmpie.dpkg": { - "source": "iana" - }, - "application/vnd.xmpie.plan": { - "source": "iana" - }, - "application/vnd.xmpie.ppkg": { - "source": "iana" - }, - "application/vnd.xmpie.xlim": { - "source": "iana" - }, - "application/vnd.yamaha.hv-dic": { - "source": "iana", - "extensions": ["hvd"] - }, - "application/vnd.yamaha.hv-script": { - "source": "iana", - "extensions": ["hvs"] - }, - "application/vnd.yamaha.hv-voice": { - "source": "iana", - "extensions": ["hvp"] - }, - "application/vnd.yamaha.openscoreformat": { - "source": "iana", - "extensions": ["osf"] - }, - "application/vnd.yamaha.openscoreformat.osfpvg+xml": { - "source": "iana", - "extensions": ["osfpvg"] - }, - "application/vnd.yamaha.remote-setup": { - "source": "iana" - }, - "application/vnd.yamaha.smaf-audio": { - "source": "iana", - "extensions": ["saf"] - }, - "application/vnd.yamaha.smaf-phrase": { - "source": "iana", - "extensions": ["spf"] - }, - "application/vnd.yamaha.through-ngn": { - "source": "iana" - }, - "application/vnd.yamaha.tunnel-udpencap": { - "source": "iana" - }, - "application/vnd.yaoweme": { - "source": "iana" - }, - "application/vnd.yellowriver-custom-menu": { - "source": "iana", - "extensions": ["cmp"] - }, - "application/vnd.zul": { - "source": "iana", - "extensions": ["zir","zirz"] - }, - "application/vnd.zzazz.deck+xml": { - "source": "iana", - "extensions": ["zaz"] - }, - "application/voicexml+xml": { - "source": "iana", - "extensions": ["vxml"] - }, - "application/vq-rtcpxr": { - "source": "iana" - }, - "application/watcherinfo+xml": { - "source": "iana" - }, - "application/whoispp-query": { - "source": "iana" - }, - "application/whoispp-response": { - "source": "iana" - }, - "application/widget": { - "source": "iana", - "extensions": ["wgt"] - }, - "application/winhlp": { - "source": "apache", - "extensions": ["hlp"] - }, - "application/wita": { - "source": "iana" - }, - "application/wordperfect5.1": { - "source": "iana" - }, - "application/wsdl+xml": { - "source": "iana", - "extensions": ["wsdl"] - }, - "application/wspolicy+xml": { - "source": "iana", - "extensions": ["wspolicy"] - }, - "application/x-7z-compressed": { - "source": "apache", - "compressible": false, - "extensions": ["7z"] - }, - "application/x-abiword": { - "source": "apache", - "extensions": ["abw"] - }, - "application/x-ace-compressed": { - "source": "apache", - "extensions": ["ace"] - }, - "application/x-amf": { - "source": "apache" - }, - "application/x-apple-diskimage": { - "source": "apache", - "extensions": ["dmg"] - }, - "application/x-authorware-bin": { - "source": "apache", - "extensions": ["aab","x32","u32","vox"] - }, - "application/x-authorware-map": { - "source": "apache", - "extensions": ["aam"] - }, - "application/x-authorware-seg": { - "source": "apache", - "extensions": ["aas"] - }, - "application/x-bcpio": { - "source": "apache", - "extensions": ["bcpio"] - }, - "application/x-bdoc": { - "compressible": false, - "extensions": ["bdoc"] - }, - "application/x-bittorrent": { - "source": "apache", - "extensions": ["torrent"] - }, - "application/x-blorb": { - "source": "apache", - "extensions": ["blb","blorb"] - }, - "application/x-bzip": { - "source": "apache", - "compressible": false, - "extensions": ["bz"] - }, - "application/x-bzip2": { - "source": "apache", - "compressible": false, - "extensions": ["bz2","boz"] - }, - "application/x-cbr": { - "source": "apache", - "extensions": ["cbr","cba","cbt","cbz","cb7"] - }, - "application/x-cdlink": { - "source": "apache", - "extensions": ["vcd"] - }, - "application/x-cfs-compressed": { - "source": "apache", - "extensions": ["cfs"] - }, - "application/x-chat": { - "source": "apache", - "extensions": ["chat"] - }, - "application/x-chess-pgn": { - "source": "apache", - "extensions": ["pgn"] - }, - "application/x-chrome-extension": { - "extensions": ["crx"] - }, - "application/x-cocoa": { - "source": "nginx", - "extensions": ["cco"] - }, - "application/x-compress": { - "source": "apache" - }, - "application/x-conference": { - "source": "apache", - "extensions": ["nsc"] - }, - "application/x-cpio": { - "source": "apache", - "extensions": ["cpio"] - }, - "application/x-csh": { - "source": "apache", - "extensions": ["csh"] - }, - "application/x-deb": { - "compressible": false - }, - "application/x-debian-package": { - "source": "apache", - "extensions": ["deb","udeb"] - }, - "application/x-dgc-compressed": { - "source": "apache", - "extensions": ["dgc"] - }, - "application/x-director": { - "source": "apache", - "extensions": ["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"] - }, - "application/x-doom": { - "source": "apache", - "extensions": ["wad"] - }, - "application/x-dtbncx+xml": { - "source": "apache", - "extensions": ["ncx"] - }, - "application/x-dtbook+xml": { - "source": "apache", - "extensions": ["dtb"] - }, - "application/x-dtbresource+xml": { - "source": "apache", - "extensions": ["res"] - }, - "application/x-dvi": { - "source": "apache", - "compressible": false, - "extensions": ["dvi"] - }, - "application/x-envoy": { - "source": "apache", - "extensions": ["evy"] - }, - "application/x-eva": { - "source": "apache", - "extensions": ["eva"] - }, - "application/x-font-bdf": { - "source": "apache", - "extensions": ["bdf"] - }, - "application/x-font-dos": { - "source": "apache" - }, - "application/x-font-framemaker": { - "source": "apache" - }, - "application/x-font-ghostscript": { - "source": "apache", - "extensions": ["gsf"] - }, - "application/x-font-libgrx": { - "source": "apache" - }, - "application/x-font-linux-psf": { - "source": "apache", - "extensions": ["psf"] - }, - "application/x-font-otf": { - "source": "apache", - "compressible": true, - "extensions": ["otf"] - }, - "application/x-font-pcf": { - "source": "apache", - "extensions": ["pcf"] - }, - "application/x-font-snf": { - "source": "apache", - "extensions": ["snf"] - }, - "application/x-font-speedo": { - "source": "apache" - }, - "application/x-font-sunos-news": { - "source": "apache" - }, - "application/x-font-ttf": { - "source": "apache", - "compressible": true, - "extensions": ["ttf","ttc"] - }, - "application/x-font-type1": { - "source": "apache", - "extensions": ["pfa","pfb","pfm","afm"] - }, - "application/x-font-vfont": { - "source": "apache" - }, - "application/x-freearc": { - "source": "apache", - "extensions": ["arc"] - }, - "application/x-futuresplash": { - "source": "apache", - "extensions": ["spl"] - }, - "application/x-gca-compressed": { - "source": "apache", - "extensions": ["gca"] - }, - "application/x-glulx": { - "source": "apache", - "extensions": ["ulx"] - }, - "application/x-gnumeric": { - "source": "apache", - "extensions": ["gnumeric"] - }, - "application/x-gramps-xml": { - "source": "apache", - "extensions": ["gramps"] - }, - "application/x-gtar": { - "source": "apache", - "extensions": ["gtar"] - }, - "application/x-gzip": { - "source": "apache" - }, - "application/x-hdf": { - "source": "apache", - "extensions": ["hdf"] - }, - "application/x-httpd-php": { - "compressible": true, - "extensions": ["php"] - }, - "application/x-install-instructions": { - "source": "apache", - "extensions": ["install"] - }, - "application/x-iso9660-image": { - "source": "apache", - "extensions": ["iso"] - }, - "application/x-java-archive-diff": { - "source": "nginx", - "extensions": ["jardiff"] - }, - "application/x-java-jnlp-file": { - "source": "apache", - "compressible": false, - "extensions": ["jnlp"] - }, - "application/x-javascript": { - "compressible": true - }, - "application/x-latex": { - "source": "apache", - "compressible": false, - "extensions": ["latex"] - }, - "application/x-lua-bytecode": { - "extensions": ["luac"] - }, - "application/x-lzh-compressed": { - "source": "apache", - "extensions": ["lzh","lha"] - }, - "application/x-makeself": { - "source": "nginx", - "extensions": ["run"] - }, - "application/x-mie": { - "source": "apache", - "extensions": ["mie"] - }, - "application/x-mobipocket-ebook": { - "source": "apache", - "extensions": ["prc","mobi"] - }, - "application/x-mpegurl": { - "compressible": false - }, - "application/x-ms-application": { - "source": "apache", - "extensions": ["application"] - }, - "application/x-ms-shortcut": { - "source": "apache", - "extensions": ["lnk"] - }, - "application/x-ms-wmd": { - "source": "apache", - "extensions": ["wmd"] - }, - "application/x-ms-wmz": { - "source": "apache", - "extensions": ["wmz"] - }, - "application/x-ms-xbap": { - "source": "apache", - "extensions": ["xbap"] - }, - "application/x-msaccess": { - "source": "apache", - "extensions": ["mdb"] - }, - "application/x-msbinder": { - "source": "apache", - "extensions": ["obd"] - }, - "application/x-mscardfile": { - "source": "apache", - "extensions": ["crd"] - }, - "application/x-msclip": { - "source": "apache", - "extensions": ["clp"] - }, - "application/x-msdos-program": { - "extensions": ["exe"] - }, - "application/x-msdownload": { - "source": "apache", - "extensions": ["exe","dll","com","bat","msi"] - }, - "application/x-msmediaview": { - "source": "apache", - "extensions": ["mvb","m13","m14"] - }, - "application/x-msmetafile": { - "source": "apache", - "extensions": ["wmf","wmz","emf","emz"] - }, - "application/x-msmoney": { - "source": "apache", - "extensions": ["mny"] - }, - "application/x-mspublisher": { - "source": "apache", - "extensions": ["pub"] - }, - "application/x-msschedule": { - "source": "apache", - "extensions": ["scd"] - }, - "application/x-msterminal": { - "source": "apache", - "extensions": ["trm"] - }, - "application/x-mswrite": { - "source": "apache", - "extensions": ["wri"] - }, - "application/x-netcdf": { - "source": "apache", - "extensions": ["nc","cdf"] - }, - "application/x-ns-proxy-autoconfig": { - "compressible": true, - "extensions": ["pac"] - }, - "application/x-nzb": { - "source": "apache", - "extensions": ["nzb"] - }, - "application/x-perl": { - "source": "nginx", - "extensions": ["pl","pm"] - }, - "application/x-pilot": { - "source": "nginx", - "extensions": ["prc","pdb"] - }, - "application/x-pkcs12": { - "source": "apache", - "compressible": false, - "extensions": ["p12","pfx"] - }, - "application/x-pkcs7-certificates": { - "source": "apache", - "extensions": ["p7b","spc"] - }, - "application/x-pkcs7-certreqresp": { - "source": "apache", - "extensions": ["p7r"] - }, - "application/x-rar-compressed": { - "source": "apache", - "compressible": false, - "extensions": ["rar"] - }, - "application/x-redhat-package-manager": { - "source": "nginx", - "extensions": ["rpm"] - }, - "application/x-research-info-systems": { - "source": "apache", - "extensions": ["ris"] - }, - "application/x-sea": { - "source": "nginx", - "extensions": ["sea"] - }, - "application/x-sh": { - "source": "apache", - "compressible": true, - "extensions": ["sh"] - }, - "application/x-shar": { - "source": "apache", - "extensions": ["shar"] - }, - "application/x-shockwave-flash": { - "source": "apache", - "compressible": false, - "extensions": ["swf"] - }, - "application/x-silverlight-app": { - "source": "apache", - "extensions": ["xap"] - }, - "application/x-sql": { - "source": "apache", - "extensions": ["sql"] - }, - "application/x-stuffit": { - "source": "apache", - "compressible": false, - "extensions": ["sit"] - }, - "application/x-stuffitx": { - "source": "apache", - "extensions": ["sitx"] - }, - "application/x-subrip": { - "source": "apache", - "extensions": ["srt"] - }, - "application/x-sv4cpio": { - "source": "apache", - "extensions": ["sv4cpio"] - }, - "application/x-sv4crc": { - "source": "apache", - "extensions": ["sv4crc"] - }, - "application/x-t3vm-image": { - "source": "apache", - "extensions": ["t3"] - }, - "application/x-tads": { - "source": "apache", - "extensions": ["gam"] - }, - "application/x-tar": { - "source": "apache", - "compressible": true, - "extensions": ["tar"] - }, - "application/x-tcl": { - "source": "apache", - "extensions": ["tcl","tk"] - }, - "application/x-tex": { - "source": "apache", - "extensions": ["tex"] - }, - "application/x-tex-tfm": { - "source": "apache", - "extensions": ["tfm"] - }, - "application/x-texinfo": { - "source": "apache", - "extensions": ["texinfo","texi"] - }, - "application/x-tgif": { - "source": "apache", - "extensions": ["obj"] - }, - "application/x-ustar": { - "source": "apache", - "extensions": ["ustar"] - }, - "application/x-wais-source": { - "source": "apache", - "extensions": ["src"] - }, - "application/x-web-app-manifest+json": { - "compressible": true, - "extensions": ["webapp"] - }, - "application/x-www-form-urlencoded": { - "source": "iana", - "compressible": true - }, - "application/x-x509-ca-cert": { - "source": "apache", - "extensions": ["der","crt","pem"] - }, - "application/x-xfig": { - "source": "apache", - "extensions": ["fig"] - }, - "application/x-xliff+xml": { - "source": "apache", - "extensions": ["xlf"] - }, - "application/x-xpinstall": { - "source": "apache", - "compressible": false, - "extensions": ["xpi"] - }, - "application/x-xz": { - "source": "apache", - "extensions": ["xz"] - }, - "application/x-zmachine": { - "source": "apache", - "extensions": ["z1","z2","z3","z4","z5","z6","z7","z8"] - }, - "application/x400-bp": { - "source": "iana" - }, - "application/xacml+xml": { - "source": "iana" - }, - "application/xaml+xml": { - "source": "apache", - "extensions": ["xaml"] - }, - "application/xcap-att+xml": { - "source": "iana" - }, - "application/xcap-caps+xml": { - "source": "iana" - }, - "application/xcap-diff+xml": { - "source": "iana", - "extensions": ["xdf"] - }, - "application/xcap-el+xml": { - "source": "iana" - }, - "application/xcap-error+xml": { - "source": "iana" - }, - "application/xcap-ns+xml": { - "source": "iana" - }, - "application/xcon-conference-info+xml": { - "source": "iana" - }, - "application/xcon-conference-info-diff+xml": { - "source": "iana" - }, - "application/xenc+xml": { - "source": "iana", - "extensions": ["xenc"] - }, - "application/xhtml+xml": { - "source": "iana", - "compressible": true, - "extensions": ["xhtml","xht"] - }, - "application/xhtml-voice+xml": { - "source": "apache" - }, - "application/xml": { - "source": "iana", - "compressible": true, - "extensions": ["xml","xsl","xsd","rng"] - }, - "application/xml-dtd": { - "source": "iana", - "compressible": true, - "extensions": ["dtd"] - }, - "application/xml-external-parsed-entity": { - "source": "iana" - }, - "application/xml-patch+xml": { - "source": "iana" - }, - "application/xmpp+xml": { - "source": "iana" - }, - "application/xop+xml": { - "source": "iana", - "compressible": true, - "extensions": ["xop"] - }, - "application/xproc+xml": { - "source": "apache", - "extensions": ["xpl"] - }, - "application/xslt+xml": { - "source": "iana", - "extensions": ["xslt"] - }, - "application/xspf+xml": { - "source": "apache", - "extensions": ["xspf"] - }, - "application/xv+xml": { - "source": "iana", - "extensions": ["mxml","xhvml","xvml","xvm"] - }, - "application/yang": { - "source": "iana", - "extensions": ["yang"] - }, - "application/yin+xml": { - "source": "iana", - "extensions": ["yin"] - }, - "application/zip": { - "source": "iana", - "compressible": false, - "extensions": ["zip"] - }, - "application/zlib": { - "source": "iana" - }, - "audio/1d-interleaved-parityfec": { - "source": "iana" - }, - "audio/32kadpcm": { - "source": "iana" - }, - "audio/3gpp": { - "source": "iana", - "compressible": false, - "extensions": ["3gpp"] - }, - "audio/3gpp2": { - "source": "iana" - }, - "audio/ac3": { - "source": "iana" - }, - "audio/adpcm": { - "source": "apache", - "extensions": ["adp"] - }, - "audio/amr": { - "source": "iana" - }, - "audio/amr-wb": { - "source": "iana" - }, - "audio/amr-wb+": { - "source": "iana" - }, - "audio/aptx": { - "source": "iana" - }, - "audio/asc": { - "source": "iana" - }, - "audio/atrac-advanced-lossless": { - "source": "iana" - }, - "audio/atrac-x": { - "source": "iana" - }, - "audio/atrac3": { - "source": "iana" - }, - "audio/basic": { - "source": "iana", - "compressible": false, - "extensions": ["au","snd"] - }, - "audio/bv16": { - "source": "iana" - }, - "audio/bv32": { - "source": "iana" - }, - "audio/clearmode": { - "source": "iana" - }, - "audio/cn": { - "source": "iana" - }, - "audio/dat12": { - "source": "iana" - }, - "audio/dls": { - "source": "iana" - }, - "audio/dsr-es201108": { - "source": "iana" - }, - "audio/dsr-es202050": { - "source": "iana" - }, - "audio/dsr-es202211": { - "source": "iana" - }, - "audio/dsr-es202212": { - "source": "iana" - }, - "audio/dv": { - "source": "iana" - }, - "audio/dvi4": { - "source": "iana" - }, - "audio/eac3": { - "source": "iana" - }, - "audio/encaprtp": { - "source": "iana" - }, - "audio/evrc": { - "source": "iana" - }, - "audio/evrc-qcp": { - "source": "iana" - }, - "audio/evrc0": { - "source": "iana" - }, - "audio/evrc1": { - "source": "iana" - }, - "audio/evrcb": { - "source": "iana" - }, - "audio/evrcb0": { - "source": "iana" - }, - "audio/evrcb1": { - "source": "iana" - }, - "audio/evrcnw": { - "source": "iana" - }, - "audio/evrcnw0": { - "source": "iana" - }, - "audio/evrcnw1": { - "source": "iana" - }, - "audio/evrcwb": { - "source": "iana" - }, - "audio/evrcwb0": { - "source": "iana" - }, - "audio/evrcwb1": { - "source": "iana" - }, - "audio/evs": { - "source": "iana" - }, - "audio/fwdred": { - "source": "iana" - }, - "audio/g711-0": { - "source": "iana" - }, - "audio/g719": { - "source": "iana" - }, - "audio/g722": { - "source": "iana" - }, - "audio/g7221": { - "source": "iana" - }, - "audio/g723": { - "source": "iana" - }, - "audio/g726-16": { - "source": "iana" - }, - "audio/g726-24": { - "source": "iana" - }, - "audio/g726-32": { - "source": "iana" - }, - "audio/g726-40": { - "source": "iana" - }, - "audio/g728": { - "source": "iana" - }, - "audio/g729": { - "source": "iana" - }, - "audio/g7291": { - "source": "iana" - }, - "audio/g729d": { - "source": "iana" - }, - "audio/g729e": { - "source": "iana" - }, - "audio/gsm": { - "source": "iana" - }, - "audio/gsm-efr": { - "source": "iana" - }, - "audio/gsm-hr-08": { - "source": "iana" - }, - "audio/ilbc": { - "source": "iana" - }, - "audio/ip-mr_v2.5": { - "source": "iana" - }, - "audio/isac": { - "source": "apache" - }, - "audio/l16": { - "source": "iana" - }, - "audio/l20": { - "source": "iana" - }, - "audio/l24": { - "source": "iana", - "compressible": false - }, - "audio/l8": { - "source": "iana" - }, - "audio/lpc": { - "source": "iana" - }, - "audio/midi": { - "source": "apache", - "extensions": ["mid","midi","kar","rmi"] - }, - "audio/mobile-xmf": { - "source": "iana" - }, - "audio/mp4": { - "source": "iana", - "compressible": false, - "extensions": ["m4a","mp4a"] - }, - "audio/mp4a-latm": { - "source": "iana" - }, - "audio/mpa": { - "source": "iana" - }, - "audio/mpa-robust": { - "source": "iana" - }, - "audio/mpeg": { - "source": "iana", - "compressible": false, - "extensions": ["mpga","mp2","mp2a","mp3","m2a","m3a"] - }, - "audio/mpeg4-generic": { - "source": "iana" - }, - "audio/musepack": { - "source": "apache" - }, - "audio/ogg": { - "source": "iana", - "compressible": false, - "extensions": ["oga","ogg","spx"] - }, - "audio/opus": { - "source": "iana" - }, - "audio/parityfec": { - "source": "iana" - }, - "audio/pcma": { - "source": "iana" - }, - "audio/pcma-wb": { - "source": "iana" - }, - "audio/pcmu": { - "source": "iana" - }, - "audio/pcmu-wb": { - "source": "iana" - }, - "audio/prs.sid": { - "source": "iana" - }, - "audio/qcelp": { - "source": "iana" - }, - "audio/raptorfec": { - "source": "iana" - }, - "audio/red": { - "source": "iana" - }, - "audio/rtp-enc-aescm128": { - "source": "iana" - }, - "audio/rtp-midi": { - "source": "iana" - }, - "audio/rtploopback": { - "source": "iana" - }, - "audio/rtx": { - "source": "iana" - }, - "audio/s3m": { - "source": "apache", - "extensions": ["s3m"] - }, - "audio/silk": { - "source": "apache", - "extensions": ["sil"] - }, - "audio/smv": { - "source": "iana" - }, - "audio/smv-qcp": { - "source": "iana" - }, - "audio/smv0": { - "source": "iana" - }, - "audio/sp-midi": { - "source": "iana" - }, - "audio/speex": { - "source": "iana" - }, - "audio/t140c": { - "source": "iana" - }, - "audio/t38": { - "source": "iana" - }, - "audio/telephone-event": { - "source": "iana" - }, - "audio/tone": { - "source": "iana" - }, - "audio/uemclip": { - "source": "iana" - }, - "audio/ulpfec": { - "source": "iana" - }, - "audio/vdvi": { - "source": "iana" - }, - "audio/vmr-wb": { - "source": "iana" - }, - "audio/vnd.3gpp.iufp": { - "source": "iana" - }, - "audio/vnd.4sb": { - "source": "iana" - }, - "audio/vnd.audiokoz": { - "source": "iana" - }, - "audio/vnd.celp": { - "source": "iana" - }, - "audio/vnd.cisco.nse": { - "source": "iana" - }, - "audio/vnd.cmles.radio-events": { - "source": "iana" - }, - "audio/vnd.cns.anp1": { - "source": "iana" - }, - "audio/vnd.cns.inf1": { - "source": "iana" - }, - "audio/vnd.dece.audio": { - "source": "iana", - "extensions": ["uva","uvva"] - }, - "audio/vnd.digital-winds": { - "source": "iana", - "extensions": ["eol"] - }, - "audio/vnd.dlna.adts": { - "source": "iana" - }, - "audio/vnd.dolby.heaac.1": { - "source": "iana" - }, - "audio/vnd.dolby.heaac.2": { - "source": "iana" - }, - "audio/vnd.dolby.mlp": { - "source": "iana" - }, - "audio/vnd.dolby.mps": { - "source": "iana" - }, - "audio/vnd.dolby.pl2": { - "source": "iana" - }, - "audio/vnd.dolby.pl2x": { - "source": "iana" - }, - "audio/vnd.dolby.pl2z": { - "source": "iana" - }, - "audio/vnd.dolby.pulse.1": { - "source": "iana" - }, - "audio/vnd.dra": { - "source": "iana", - "extensions": ["dra"] - }, - "audio/vnd.dts": { - "source": "iana", - "extensions": ["dts"] - }, - "audio/vnd.dts.hd": { - "source": "iana", - "extensions": ["dtshd"] - }, - "audio/vnd.dvb.file": { - "source": "iana" - }, - "audio/vnd.everad.plj": { - "source": "iana" - }, - "audio/vnd.hns.audio": { - "source": "iana" - }, - "audio/vnd.lucent.voice": { - "source": "iana", - "extensions": ["lvp"] - }, - "audio/vnd.ms-playready.media.pya": { - "source": "iana", - "extensions": ["pya"] - }, - "audio/vnd.nokia.mobile-xmf": { - "source": "iana" - }, - "audio/vnd.nortel.vbk": { - "source": "iana" - }, - "audio/vnd.nuera.ecelp4800": { - "source": "iana", - "extensions": ["ecelp4800"] - }, - "audio/vnd.nuera.ecelp7470": { - "source": "iana", - "extensions": ["ecelp7470"] - }, - "audio/vnd.nuera.ecelp9600": { - "source": "iana", - "extensions": ["ecelp9600"] - }, - "audio/vnd.octel.sbc": { - "source": "iana" - }, - "audio/vnd.qcelp": { - "source": "iana" - }, - "audio/vnd.rhetorex.32kadpcm": { - "source": "iana" - }, - "audio/vnd.rip": { - "source": "iana", - "extensions": ["rip"] - }, - "audio/vnd.rn-realaudio": { - "compressible": false - }, - "audio/vnd.sealedmedia.softseal.mpeg": { - "source": "iana" - }, - "audio/vnd.vmx.cvsd": { - "source": "iana" - }, - "audio/vnd.wave": { - "compressible": false - }, - "audio/vorbis": { - "source": "iana", - "compressible": false - }, - "audio/vorbis-config": { - "source": "iana" - }, - "audio/wav": { - "compressible": false, - "extensions": ["wav"] - }, - "audio/wave": { - "compressible": false, - "extensions": ["wav"] - }, - "audio/webm": { - "source": "apache", - "compressible": false, - "extensions": ["weba"] - }, - "audio/x-aac": { - "source": "apache", - "compressible": false, - "extensions": ["aac"] - }, - "audio/x-aiff": { - "source": "apache", - "extensions": ["aif","aiff","aifc"] - }, - "audio/x-caf": { - "source": "apache", - "compressible": false, - "extensions": ["caf"] - }, - "audio/x-flac": { - "source": "apache", - "extensions": ["flac"] - }, - "audio/x-m4a": { - "source": "nginx", - "extensions": ["m4a"] - }, - "audio/x-matroska": { - "source": "apache", - "extensions": ["mka"] - }, - "audio/x-mpegurl": { - "source": "apache", - "extensions": ["m3u"] - }, - "audio/x-ms-wax": { - "source": "apache", - "extensions": ["wax"] - }, - "audio/x-ms-wma": { - "source": "apache", - "extensions": ["wma"] - }, - "audio/x-pn-realaudio": { - "source": "apache", - "extensions": ["ram","ra"] - }, - "audio/x-pn-realaudio-plugin": { - "source": "apache", - "extensions": ["rmp"] - }, - "audio/x-realaudio": { - "source": "nginx", - "extensions": ["ra"] - }, - "audio/x-tta": { - "source": "apache" - }, - "audio/x-wav": { - "source": "apache", - "extensions": ["wav"] - }, - "audio/xm": { - "source": "apache", - "extensions": ["xm"] - }, - "chemical/x-cdx": { - "source": "apache", - "extensions": ["cdx"] - }, - "chemical/x-cif": { - "source": "apache", - "extensions": ["cif"] - }, - "chemical/x-cmdf": { - "source": "apache", - "extensions": ["cmdf"] - }, - "chemical/x-cml": { - "source": "apache", - "extensions": ["cml"] - }, - "chemical/x-csml": { - "source": "apache", - "extensions": ["csml"] - }, - "chemical/x-pdb": { - "source": "apache" - }, - "chemical/x-xyz": { - "source": "apache", - "extensions": ["xyz"] - }, - "font/opentype": { - "compressible": true, - "extensions": ["otf"] - }, - "image/bmp": { - "source": "apache", - "compressible": true, - "extensions": ["bmp"] - }, - "image/cgm": { - "source": "iana", - "extensions": ["cgm"] - }, - "image/fits": { - "source": "iana" - }, - "image/g3fax": { - "source": "iana", - "extensions": ["g3"] - }, - "image/gif": { - "source": "iana", - "compressible": false, - "extensions": ["gif"] - }, - "image/ief": { - "source": "iana", - "extensions": ["ief"] - }, - "image/jp2": { - "source": "iana" - }, - "image/jpeg": { - "source": "iana", - "compressible": false, - "extensions": ["jpeg","jpg","jpe"] - }, - "image/jpm": { - "source": "iana" - }, - "image/jpx": { - "source": "iana" - }, - "image/ktx": { - "source": "iana", - "extensions": ["ktx"] - }, - "image/naplps": { - "source": "iana" - }, - "image/pjpeg": { - "compressible": false - }, - "image/png": { - "source": "iana", - "compressible": false, - "extensions": ["png"] - }, - "image/prs.btif": { - "source": "iana", - "extensions": ["btif"] - }, - "image/prs.pti": { - "source": "iana" - }, - "image/pwg-raster": { - "source": "iana" - }, - "image/sgi": { - "source": "apache", - "extensions": ["sgi"] - }, - "image/svg+xml": { - "source": "iana", - "compressible": true, - "extensions": ["svg","svgz"] - }, - "image/t38": { - "source": "iana" - }, - "image/tiff": { - "source": "iana", - "compressible": false, - "extensions": ["tiff","tif"] - }, - "image/tiff-fx": { - "source": "iana" - }, - "image/vnd.adobe.photoshop": { - "source": "iana", - "compressible": true, - "extensions": ["psd"] - }, - "image/vnd.airzip.accelerator.azv": { - "source": "iana" - }, - "image/vnd.cns.inf2": { - "source": "iana" - }, - "image/vnd.dece.graphic": { - "source": "iana", - "extensions": ["uvi","uvvi","uvg","uvvg"] - }, - "image/vnd.djvu": { - "source": "iana", - "extensions": ["djvu","djv"] - }, - "image/vnd.dvb.subtitle": { - "source": "iana", - "extensions": ["sub"] - }, - "image/vnd.dwg": { - "source": "iana", - "extensions": ["dwg"] - }, - "image/vnd.dxf": { - "source": "iana", - "extensions": ["dxf"] - }, - "image/vnd.fastbidsheet": { - "source": "iana", - "extensions": ["fbs"] - }, - "image/vnd.fpx": { - "source": "iana", - "extensions": ["fpx"] - }, - "image/vnd.fst": { - "source": "iana", - "extensions": ["fst"] - }, - "image/vnd.fujixerox.edmics-mmr": { - "source": "iana", - "extensions": ["mmr"] - }, - "image/vnd.fujixerox.edmics-rlc": { - "source": "iana", - "extensions": ["rlc"] - }, - "image/vnd.globalgraphics.pgb": { - "source": "iana" - }, - "image/vnd.microsoft.icon": { - "source": "iana" - }, - "image/vnd.mix": { - "source": "iana" - }, - "image/vnd.mozilla.apng": { - "source": "iana" - }, - "image/vnd.ms-modi": { - "source": "iana", - "extensions": ["mdi"] - }, - "image/vnd.ms-photo": { - "source": "apache", - "extensions": ["wdp"] - }, - "image/vnd.net-fpx": { - "source": "iana", - "extensions": ["npx"] - }, - "image/vnd.radiance": { - "source": "iana" - }, - "image/vnd.sealed.png": { - "source": "iana" - }, - "image/vnd.sealedmedia.softseal.gif": { - "source": "iana" - }, - "image/vnd.sealedmedia.softseal.jpg": { - "source": "iana" - }, - "image/vnd.svf": { - "source": "iana" - }, - "image/vnd.tencent.tap": { - "source": "iana" - }, - "image/vnd.valve.source.texture": { - "source": "iana" - }, - "image/vnd.wap.wbmp": { - "source": "iana", - "extensions": ["wbmp"] - }, - "image/vnd.xiff": { - "source": "iana", - "extensions": ["xif"] - }, - "image/vnd.zbrush.pcx": { - "source": "iana" - }, - "image/webp": { - "source": "apache", - "extensions": ["webp"] - }, - "image/x-3ds": { - "source": "apache", - "extensions": ["3ds"] - }, - "image/x-cmu-raster": { - "source": "apache", - "extensions": ["ras"] - }, - "image/x-cmx": { - "source": "apache", - "extensions": ["cmx"] - }, - "image/x-freehand": { - "source": "apache", - "extensions": ["fh","fhc","fh4","fh5","fh7"] - }, - "image/x-icon": { - "source": "apache", - "compressible": true, - "extensions": ["ico"] - }, - "image/x-jng": { - "source": "nginx", - "extensions": ["jng"] - }, - "image/x-mrsid-image": { - "source": "apache", - "extensions": ["sid"] - }, - "image/x-ms-bmp": { - "source": "nginx", - "compressible": true, - "extensions": ["bmp"] - }, - "image/x-pcx": { - "source": "apache", - "extensions": ["pcx"] - }, - "image/x-pict": { - "source": "apache", - "extensions": ["pic","pct"] - }, - "image/x-portable-anymap": { - "source": "apache", - "extensions": ["pnm"] - }, - "image/x-portable-bitmap": { - "source": "apache", - "extensions": ["pbm"] - }, - "image/x-portable-graymap": { - "source": "apache", - "extensions": ["pgm"] - }, - "image/x-portable-pixmap": { - "source": "apache", - "extensions": ["ppm"] - }, - "image/x-rgb": { - "source": "apache", - "extensions": ["rgb"] - }, - "image/x-tga": { - "source": "apache", - "extensions": ["tga"] - }, - "image/x-xbitmap": { - "source": "apache", - "extensions": ["xbm"] - }, - "image/x-xcf": { - "compressible": false - }, - "image/x-xpixmap": { - "source": "apache", - "extensions": ["xpm"] - }, - "image/x-xwindowdump": { - "source": "apache", - "extensions": ["xwd"] - }, - "message/cpim": { - "source": "iana" - }, - "message/delivery-status": { - "source": "iana" - }, - "message/disposition-notification": { - "source": "iana" - }, - "message/external-body": { - "source": "iana" - }, - "message/feedback-report": { - "source": "iana" - }, - "message/global": { - "source": "iana" - }, - "message/global-delivery-status": { - "source": "iana" - }, - "message/global-disposition-notification": { - "source": "iana" - }, - "message/global-headers": { - "source": "iana" - }, - "message/http": { - "source": "iana", - "compressible": false - }, - "message/imdn+xml": { - "source": "iana", - "compressible": true - }, - "message/news": { - "source": "iana" - }, - "message/partial": { - "source": "iana", - "compressible": false - }, - "message/rfc822": { - "source": "iana", - "compressible": true, - "extensions": ["eml","mime"] - }, - "message/s-http": { - "source": "iana" - }, - "message/sip": { - "source": "iana" - }, - "message/sipfrag": { - "source": "iana" - }, - "message/tracking-status": { - "source": "iana" - }, - "message/vnd.si.simp": { - "source": "iana" - }, - "message/vnd.wfa.wsc": { - "source": "iana" - }, - "model/iges": { - "source": "iana", - "compressible": false, - "extensions": ["igs","iges"] - }, - "model/mesh": { - "source": "iana", - "compressible": false, - "extensions": ["msh","mesh","silo"] - }, - "model/vnd.collada+xml": { - "source": "iana", - "extensions": ["dae"] - }, - "model/vnd.dwf": { - "source": "iana", - "extensions": ["dwf"] - }, - "model/vnd.flatland.3dml": { - "source": "iana" - }, - "model/vnd.gdl": { - "source": "iana", - "extensions": ["gdl"] - }, - "model/vnd.gs-gdl": { - "source": "apache" - }, - "model/vnd.gs.gdl": { - "source": "iana" - }, - "model/vnd.gtw": { - "source": "iana", - "extensions": ["gtw"] - }, - "model/vnd.moml+xml": { - "source": "iana" - }, - "model/vnd.mts": { - "source": "iana", - "extensions": ["mts"] - }, - "model/vnd.opengex": { - "source": "iana" - }, - "model/vnd.parasolid.transmit.binary": { - "source": "iana" - }, - "model/vnd.parasolid.transmit.text": { - "source": "iana" - }, - "model/vnd.rosette.annotated-data-model": { - "source": "iana" - }, - "model/vnd.valve.source.compiled-map": { - "source": "iana" - }, - "model/vnd.vtu": { - "source": "iana", - "extensions": ["vtu"] - }, - "model/vrml": { - "source": "iana", - "compressible": false, - "extensions": ["wrl","vrml"] - }, - "model/x3d+binary": { - "source": "apache", - "compressible": false, - "extensions": ["x3db","x3dbz"] - }, - "model/x3d+fastinfoset": { - "source": "iana" - }, - "model/x3d+vrml": { - "source": "apache", - "compressible": false, - "extensions": ["x3dv","x3dvz"] - }, - "model/x3d+xml": { - "source": "iana", - "compressible": true, - "extensions": ["x3d","x3dz"] - }, - "model/x3d-vrml": { - "source": "iana" - }, - "multipart/alternative": { - "source": "iana", - "compressible": false - }, - "multipart/appledouble": { - "source": "iana" - }, - "multipart/byteranges": { - "source": "iana" - }, - "multipart/digest": { - "source": "iana" - }, - "multipart/encrypted": { - "source": "iana", - "compressible": false - }, - "multipart/form-data": { - "source": "iana", - "compressible": false - }, - "multipart/header-set": { - "source": "iana" - }, - "multipart/mixed": { - "source": "iana", - "compressible": false - }, - "multipart/parallel": { - "source": "iana" - }, - "multipart/related": { - "source": "iana", - "compressible": false - }, - "multipart/report": { - "source": "iana" - }, - "multipart/signed": { - "source": "iana", - "compressible": false - }, - "multipart/voice-message": { - "source": "iana" - }, - "multipart/x-mixed-replace": { - "source": "iana" - }, - "text/1d-interleaved-parityfec": { - "source": "iana" - }, - "text/cache-manifest": { - "source": "iana", - "compressible": true, - "extensions": ["appcache","manifest"] - }, - "text/calendar": { - "source": "iana", - "extensions": ["ics","ifb"] - }, - "text/calender": { - "compressible": true - }, - "text/cmd": { - "compressible": true - }, - "text/coffeescript": { - "extensions": ["coffee","litcoffee"] - }, - "text/css": { - "source": "iana", - "compressible": true, - "extensions": ["css"] - }, - "text/csv": { - "source": "iana", - "compressible": true, - "extensions": ["csv"] - }, - "text/csv-schema": { - "source": "iana" - }, - "text/directory": { - "source": "iana" - }, - "text/dns": { - "source": "iana" - }, - "text/ecmascript": { - "source": "iana" - }, - "text/encaprtp": { - "source": "iana" - }, - "text/enriched": { - "source": "iana" - }, - "text/fwdred": { - "source": "iana" - }, - "text/grammar-ref-list": { - "source": "iana" - }, - "text/hjson": { - "extensions": ["hjson"] - }, - "text/html": { - "source": "iana", - "compressible": true, - "extensions": ["html","htm","shtml"] - }, - "text/jade": { - "extensions": ["jade"] - }, - "text/javascript": { - "source": "iana", - "compressible": true - }, - "text/jcr-cnd": { - "source": "iana" - }, - "text/jsx": { - "compressible": true, - "extensions": ["jsx"] - }, - "text/less": { - "extensions": ["less"] - }, - "text/markdown": { - "source": "iana" - }, - "text/mathml": { - "source": "nginx", - "extensions": ["mml"] - }, - "text/mizar": { - "source": "iana" - }, - "text/n3": { - "source": "iana", - "compressible": true, - "extensions": ["n3"] - }, - "text/parameters": { - "source": "iana" - }, - "text/parityfec": { - "source": "iana" - }, - "text/plain": { - "source": "iana", - "compressible": true, - "extensions": ["txt","text","conf","def","list","log","in","ini"] - }, - "text/provenance-notation": { - "source": "iana" - }, - "text/prs.fallenstein.rst": { - "source": "iana" - }, - "text/prs.lines.tag": { - "source": "iana", - "extensions": ["dsc"] - }, - "text/prs.prop.logic": { - "source": "iana" - }, - "text/raptorfec": { - "source": "iana" - }, - "text/red": { - "source": "iana" - }, - "text/rfc822-headers": { - "source": "iana" - }, - "text/richtext": { - "source": "iana", - "compressible": true, - "extensions": ["rtx"] - }, - "text/rtf": { - "source": "iana", - "compressible": true, - "extensions": ["rtf"] - }, - "text/rtp-enc-aescm128": { - "source": "iana" - }, - "text/rtploopback": { - "source": "iana" - }, - "text/rtx": { - "source": "iana" - }, - "text/sgml": { - "source": "iana", - "extensions": ["sgml","sgm"] - }, - "text/slim": { - "extensions": ["slim","slm"] - }, - "text/stylus": { - "extensions": ["stylus","styl"] - }, - "text/t140": { - "source": "iana" - }, - "text/tab-separated-values": { - "source": "iana", - "compressible": true, - "extensions": ["tsv"] - }, - "text/troff": { - "source": "iana", - "extensions": ["t","tr","roff","man","me","ms"] - }, - "text/turtle": { - "source": "iana", - "extensions": ["ttl"] - }, - "text/ulpfec": { - "source": "iana" - }, - "text/uri-list": { - "source": "iana", - "compressible": true, - "extensions": ["uri","uris","urls"] - }, - "text/vcard": { - "source": "iana", - "compressible": true, - "extensions": ["vcard"] - }, - "text/vnd.a": { - "source": "iana" - }, - "text/vnd.abc": { - "source": "iana" - }, - "text/vnd.curl": { - "source": "iana", - "extensions": ["curl"] - }, - "text/vnd.curl.dcurl": { - "source": "apache", - "extensions": ["dcurl"] - }, - "text/vnd.curl.mcurl": { - "source": "apache", - "extensions": ["mcurl"] - }, - "text/vnd.curl.scurl": { - "source": "apache", - "extensions": ["scurl"] - }, - "text/vnd.debian.copyright": { - "source": "iana" - }, - "text/vnd.dmclientscript": { - "source": "iana" - }, - "text/vnd.dvb.subtitle": { - "source": "iana", - "extensions": ["sub"] - }, - "text/vnd.esmertec.theme-descriptor": { - "source": "iana" - }, - "text/vnd.fly": { - "source": "iana", - "extensions": ["fly"] - }, - "text/vnd.fmi.flexstor": { - "source": "iana", - "extensions": ["flx"] - }, - "text/vnd.graphviz": { - "source": "iana", - "extensions": ["gv"] - }, - "text/vnd.in3d.3dml": { - "source": "iana", - "extensions": ["3dml"] - }, - "text/vnd.in3d.spot": { - "source": "iana", - "extensions": ["spot"] - }, - "text/vnd.iptc.newsml": { - "source": "iana" - }, - "text/vnd.iptc.nitf": { - "source": "iana" - }, - "text/vnd.latex-z": { - "source": "iana" - }, - "text/vnd.motorola.reflex": { - "source": "iana" - }, - "text/vnd.ms-mediapackage": { - "source": "iana" - }, - "text/vnd.net2phone.commcenter.command": { - "source": "iana" - }, - "text/vnd.radisys.msml-basic-layout": { - "source": "iana" - }, - "text/vnd.si.uricatalogue": { - "source": "iana" - }, - "text/vnd.sun.j2me.app-descriptor": { - "source": "iana", - "extensions": ["jad"] - }, - "text/vnd.trolltech.linguist": { - "source": "iana" - }, - "text/vnd.wap.si": { - "source": "iana" - }, - "text/vnd.wap.sl": { - "source": "iana" - }, - "text/vnd.wap.wml": { - "source": "iana", - "extensions": ["wml"] - }, - "text/vnd.wap.wmlscript": { - "source": "iana", - "extensions": ["wmls"] - }, - "text/vtt": { - "charset": "UTF-8", - "compressible": true, - "extensions": ["vtt"] - }, - "text/x-asm": { - "source": "apache", - "extensions": ["s","asm"] - }, - "text/x-c": { - "source": "apache", - "extensions": ["c","cc","cxx","cpp","h","hh","dic"] - }, - "text/x-component": { - "source": "nginx", - "extensions": ["htc"] - }, - "text/x-fortran": { - "source": "apache", - "extensions": ["f","for","f77","f90"] - }, - "text/x-gwt-rpc": { - "compressible": true - }, - "text/x-handlebars-template": { - "extensions": ["hbs"] - }, - "text/x-java-source": { - "source": "apache", - "extensions": ["java"] - }, - "text/x-jquery-tmpl": { - "compressible": true - }, - "text/x-lua": { - "extensions": ["lua"] - }, - "text/x-markdown": { - "compressible": true, - "extensions": ["markdown","md","mkd"] - }, - "text/x-nfo": { - "source": "apache", - "extensions": ["nfo"] - }, - "text/x-opml": { - "source": "apache", - "extensions": ["opml"] - }, - "text/x-pascal": { - "source": "apache", - "extensions": ["p","pas"] - }, - "text/x-processing": { - "compressible": true, - "extensions": ["pde"] - }, - "text/x-sass": { - "extensions": ["sass"] - }, - "text/x-scss": { - "extensions": ["scss"] - }, - "text/x-setext": { - "source": "apache", - "extensions": ["etx"] - }, - "text/x-sfv": { - "source": "apache", - "extensions": ["sfv"] - }, - "text/x-suse-ymp": { - "compressible": true, - "extensions": ["ymp"] - }, - "text/x-uuencode": { - "source": "apache", - "extensions": ["uu"] - }, - "text/x-vcalendar": { - "source": "apache", - "extensions": ["vcs"] - }, - "text/x-vcard": { - "source": "apache", - "extensions": ["vcf"] - }, - "text/xml": { - "source": "iana", - "compressible": true, - "extensions": ["xml"] - }, - "text/xml-external-parsed-entity": { - "source": "iana" - }, - "text/yaml": { - "extensions": ["yaml","yml"] - }, - "video/1d-interleaved-parityfec": { - "source": "apache" - }, - "video/3gpp": { - "source": "apache", - "extensions": ["3gp","3gpp"] - }, - "video/3gpp-tt": { - "source": "apache" - }, - "video/3gpp2": { - "source": "apache", - "extensions": ["3g2"] - }, - "video/bmpeg": { - "source": "apache" - }, - "video/bt656": { - "source": "apache" - }, - "video/celb": { - "source": "apache" - }, - "video/dv": { - "source": "apache" - }, - "video/encaprtp": { - "source": "apache" - }, - "video/h261": { - "source": "apache", - "extensions": ["h261"] - }, - "video/h263": { - "source": "apache", - "extensions": ["h263"] - }, - "video/h263-1998": { - "source": "apache" - }, - "video/h263-2000": { - "source": "apache" - }, - "video/h264": { - "source": "apache", - "extensions": ["h264"] - }, - "video/h264-rcdo": { - "source": "apache" - }, - "video/h264-svc": { - "source": "apache" - }, - "video/h265": { - "source": "apache" - }, - "video/iso.segment": { - "source": "apache" - }, - "video/jpeg": { - "source": "apache", - "extensions": ["jpgv"] - }, - "video/jpeg2000": { - "source": "apache" - }, - "video/jpm": { - "source": "apache", - "extensions": ["jpm","jpgm"] - }, - "video/mj2": { - "source": "apache", - "extensions": ["mj2","mjp2"] - }, - "video/mp1s": { - "source": "apache" - }, - "video/mp2p": { - "source": "apache" - }, - "video/mp2t": { - "source": "apache", - "extensions": ["ts"] - }, - "video/mp4": { - "source": "apache", - "compressible": false, - "extensions": ["mp4","mp4v","mpg4"] - }, - "video/mp4v-es": { - "source": "apache" - }, - "video/mpeg": { - "source": "apache", - "compressible": false, - "extensions": ["mpeg","mpg","mpe","m1v","m2v"] - }, - "video/mpeg4-generic": { - "source": "apache" - }, - "video/mpv": { - "source": "apache" - }, - "video/nv": { - "source": "apache" - }, - "video/ogg": { - "source": "apache", - "compressible": false, - "extensions": ["ogv"] - }, - "video/parityfec": { - "source": "apache" - }, - "video/pointer": { - "source": "apache" - }, - "video/quicktime": { - "source": "apache", - "compressible": false, - "extensions": ["qt","mov"] - }, - "video/raptorfec": { - "source": "apache" - }, - "video/raw": { - "source": "apache" - }, - "video/rtp-enc-aescm128": { - "source": "apache" - }, - "video/rtploopback": { - "source": "apache" - }, - "video/rtx": { - "source": "apache" - }, - "video/smpte292m": { - "source": "apache" - }, - "video/ulpfec": { - "source": "apache" - }, - "video/vc1": { - "source": "apache" - }, - "video/vnd.cctv": { - "source": "apache" - }, - "video/vnd.dece.hd": { - "source": "apache", - "extensions": ["uvh","uvvh"] - }, - "video/vnd.dece.mobile": { - "source": "apache", - "extensions": ["uvm","uvvm"] - }, - "video/vnd.dece.mp4": { - "source": "apache" - }, - "video/vnd.dece.pd": { - "source": "apache", - "extensions": ["uvp","uvvp"] - }, - "video/vnd.dece.sd": { - "source": "apache", - "extensions": ["uvs","uvvs"] - }, - "video/vnd.dece.video": { - "source": "apache", - "extensions": ["uvv","uvvv"] - }, - "video/vnd.directv.mpeg": { - "source": "apache" - }, - "video/vnd.directv.mpeg-tts": { - "source": "apache" - }, - "video/vnd.dlna.mpeg-tts": { - "source": "apache" - }, - "video/vnd.dvb.file": { - "source": "apache", - "extensions": ["dvb"] - }, - "video/vnd.fvt": { - "source": "apache", - "extensions": ["fvt"] - }, - "video/vnd.hns.video": { - "source": "apache" - }, - "video/vnd.iptvforum.1dparityfec-1010": { - "source": "apache" - }, - "video/vnd.iptvforum.1dparityfec-2005": { - "source": "apache" - }, - "video/vnd.iptvforum.2dparityfec-1010": { - "source": "apache" - }, - "video/vnd.iptvforum.2dparityfec-2005": { - "source": "apache" - }, - "video/vnd.iptvforum.ttsavc": { - "source": "apache" - }, - "video/vnd.iptvforum.ttsmpeg2": { - "source": "apache" - }, - "video/vnd.motorola.video": { - "source": "apache" - }, - "video/vnd.motorola.videop": { - "source": "apache" - }, - "video/vnd.mpegurl": { - "source": "apache", - "extensions": ["mxu","m4u"] - }, - "video/vnd.ms-playready.media.pyv": { - "source": "apache", - "extensions": ["pyv"] - }, - "video/vnd.nokia.interleaved-multimedia": { - "source": "apache" - }, - "video/vnd.nokia.videovoip": { - "source": "apache" - }, - "video/vnd.objectvideo": { - "source": "apache" - }, - "video/vnd.radgamettools.bink": { - "source": "apache" - }, - "video/vnd.radgamettools.smacker": { - "source": "apache" - }, - "video/vnd.sealed.mpeg1": { - "source": "apache" - }, - "video/vnd.sealed.mpeg4": { - "source": "apache" - }, - "video/vnd.sealed.swf": { - "source": "apache" - }, - "video/vnd.sealedmedia.softseal.mov": { - "source": "apache" - }, - "video/vnd.uvvu.mp4": { - "source": "apache", - "extensions": ["uvu","uvvu"] - }, - "video/vnd.vivo": { - "source": "apache", - "extensions": ["viv"] - }, - "video/vp8": { - "source": "apache" - }, - "video/webm": { - "source": "apache", - "compressible": false, - "extensions": ["webm"] - }, - "video/x-f4v": { - "source": "apache", - "extensions": ["f4v"] - }, - "video/x-fli": { - "source": "apache", - "extensions": ["fli"] - }, - "video/x-flv": { - "source": "apache", - "compressible": false, - "extensions": ["flv"] - }, - "video/x-m4v": { - "source": "apache", - "extensions": ["m4v"] - }, - "video/x-matroska": { - "source": "apache", - "compressible": false, - "extensions": ["mkv","mk3d","mks"] - }, - "video/x-mng": { - "source": "apache", - "extensions": ["mng"] - }, - "video/x-ms-asf": { - "source": "apache", - "extensions": ["asf","asx"] - }, - "video/x-ms-vob": { - "source": "apache", - "extensions": ["vob"] - }, - "video/x-ms-wm": { - "source": "apache", - "extensions": ["wm"] - }, - "video/x-ms-wmv": { - "source": "apache", - "compressible": false, - "extensions": ["wmv"] - }, - "video/x-ms-wmx": { - "source": "apache", - "extensions": ["wmx"] - }, - "video/x-ms-wvx": { - "source": "apache", - "extensions": ["wvx"] - }, - "video/x-msvideo": { - "source": "apache", - "extensions": ["avi"] - }, - "video/x-sgi-movie": { - "source": "apache", - "extensions": ["movie"] - }, - "video/x-smv": { - "source": "apache", - "extensions": ["smv"] - }, - "x-conference/x-cooltalk": { - "source": "apache", - "extensions": ["ice"] - }, - "x-shader/x-fragment": { - "compressible": true - }, - "x-shader/x-vertex": { - "compressible": true - } -} +{ + "application/1d-interleaved-parityfec": { + "source": "iana" + }, + "application/3gpdash-qoe-report+xml": { + "source": "iana" + }, + "application/3gpp-ims+xml": { + "source": "iana" + }, + "application/a2l": { + "source": "iana" + }, + "application/activemessage": { + "source": "iana" + }, + "application/alto-costmap+json": { + "source": "iana", + "compressible": true + }, + "application/alto-costmapfilter+json": { + "source": "iana", + "compressible": true + }, + "application/alto-directory+json": { + "source": "iana", + "compressible": true + }, + "application/alto-endpointcost+json": { + "source": "iana", + "compressible": true + }, + "application/alto-endpointcostparams+json": { + "source": "iana", + "compressible": true + }, + "application/alto-endpointprop+json": { + "source": "iana", + "compressible": true + }, + "application/alto-endpointpropparams+json": { + "source": "iana", + "compressible": true + }, + "application/alto-error+json": { + "source": "iana", + "compressible": true + }, + "application/alto-networkmap+json": { + "source": "iana", + "compressible": true + }, + "application/alto-networkmapfilter+json": { + "source": "iana", + "compressible": true + }, + "application/aml": { + "source": "iana" + }, + "application/andrew-inset": { + "source": "iana", + "extensions": ["ez"] + }, + "application/applefile": { + "source": "iana" + }, + "application/applixware": { + "source": "apache", + "extensions": ["aw"] + }, + "application/atf": { + "source": "iana" + }, + "application/atfx": { + "source": "iana" + }, + "application/atom+xml": { + "source": "iana", + "compressible": true, + "extensions": ["atom"] + }, + "application/atomcat+xml": { + "source": "iana", + "extensions": ["atomcat"] + }, + "application/atomdeleted+xml": { + "source": "iana" + }, + "application/atomicmail": { + "source": "iana" + }, + "application/atomsvc+xml": { + "source": "iana", + "extensions": ["atomsvc"] + }, + "application/atxml": { + "source": "iana" + }, + "application/auth-policy+xml": { + "source": "iana" + }, + "application/bacnet-xdd+zip": { + "source": "iana" + }, + "application/batch-smtp": { + "source": "iana" + }, + "application/bdoc": { + "compressible": false, + "extensions": ["bdoc"] + }, + "application/beep+xml": { + "source": "iana" + }, + "application/calendar+json": { + "source": "iana", + "compressible": true + }, + "application/calendar+xml": { + "source": "iana" + }, + "application/call-completion": { + "source": "iana" + }, + "application/cals-1840": { + "source": "iana" + }, + "application/cbor": { + "source": "iana" + }, + "application/ccmp+xml": { + "source": "iana" + }, + "application/ccxml+xml": { + "source": "iana", + "extensions": ["ccxml"] + }, + "application/cdfx+xml": { + "source": "iana" + }, + "application/cdmi-capability": { + "source": "iana", + "extensions": ["cdmia"] + }, + "application/cdmi-container": { + "source": "iana", + "extensions": ["cdmic"] + }, + "application/cdmi-domain": { + "source": "iana", + "extensions": ["cdmid"] + }, + "application/cdmi-object": { + "source": "iana", + "extensions": ["cdmio"] + }, + "application/cdmi-queue": { + "source": "iana", + "extensions": ["cdmiq"] + }, + "application/cdni": { + "source": "iana" + }, + "application/cea": { + "source": "iana" + }, + "application/cea-2018+xml": { + "source": "iana" + }, + "application/cellml+xml": { + "source": "iana" + }, + "application/cfw": { + "source": "iana" + }, + "application/cms": { + "source": "iana" + }, + "application/cnrp+xml": { + "source": "iana" + }, + "application/coap-group+json": { + "source": "iana", + "compressible": true + }, + "application/commonground": { + "source": "iana" + }, + "application/conference-info+xml": { + "source": "iana" + }, + "application/cpl+xml": { + "source": "iana" + }, + "application/csrattrs": { + "source": "iana" + }, + "application/csta+xml": { + "source": "iana" + }, + "application/cstadata+xml": { + "source": "iana" + }, + "application/csvm+json": { + "source": "iana", + "compressible": true + }, + "application/cu-seeme": { + "source": "apache", + "extensions": ["cu"] + }, + "application/cybercash": { + "source": "iana" + }, + "application/dart": { + "compressible": true + }, + "application/dash+xml": { + "source": "iana", + "extensions": ["mpd"] + }, + "application/dashdelta": { + "source": "iana" + }, + "application/davmount+xml": { + "source": "iana", + "extensions": ["davmount"] + }, + "application/dca-rft": { + "source": "iana" + }, + "application/dcd": { + "source": "iana" + }, + "application/dec-dx": { + "source": "iana" + }, + "application/dialog-info+xml": { + "source": "iana" + }, + "application/dicom": { + "source": "iana" + }, + "application/dii": { + "source": "iana" + }, + "application/dit": { + "source": "iana" + }, + "application/dns": { + "source": "iana" + }, + "application/docbook+xml": { + "source": "apache", + "extensions": ["dbk"] + }, + "application/dskpp+xml": { + "source": "iana" + }, + "application/dssc+der": { + "source": "iana", + "extensions": ["dssc"] + }, + "application/dssc+xml": { + "source": "iana", + "extensions": ["xdssc"] + }, + "application/dvcs": { + "source": "iana" + }, + "application/ecmascript": { + "source": "iana", + "compressible": true, + "extensions": ["ecma"] + }, + "application/edi-consent": { + "source": "iana" + }, + "application/edi-x12": { + "source": "iana", + "compressible": false + }, + "application/edifact": { + "source": "iana", + "compressible": false + }, + "application/efi": { + "source": "iana" + }, + "application/emergencycalldata.comment+xml": { + "source": "iana" + }, + "application/emergencycalldata.deviceinfo+xml": { + "source": "iana" + }, + "application/emergencycalldata.providerinfo+xml": { + "source": "iana" + }, + "application/emergencycalldata.serviceinfo+xml": { + "source": "iana" + }, + "application/emergencycalldata.subscriberinfo+xml": { + "source": "iana" + }, + "application/emma+xml": { + "source": "iana", + "extensions": ["emma"] + }, + "application/emotionml+xml": { + "source": "iana" + }, + "application/encaprtp": { + "source": "iana" + }, + "application/epp+xml": { + "source": "iana" + }, + "application/epub+zip": { + "source": "iana", + "extensions": ["epub"] + }, + "application/eshop": { + "source": "iana" + }, + "application/exi": { + "source": "iana", + "extensions": ["exi"] + }, + "application/fastinfoset": { + "source": "iana" + }, + "application/fastsoap": { + "source": "iana" + }, + "application/fdt+xml": { + "source": "iana" + }, + "application/fits": { + "source": "iana" + }, + "application/font-sfnt": { + "source": "iana" + }, + "application/font-tdpfr": { + "source": "iana", + "extensions": ["pfr"] + }, + "application/font-woff": { + "source": "iana", + "compressible": false, + "extensions": ["woff"] + }, + "application/font-woff2": { + "compressible": false, + "extensions": ["woff2"] + }, + "application/framework-attributes+xml": { + "source": "iana" + }, + "application/gml+xml": { + "source": "apache", + "extensions": ["gml"] + }, + "application/gpx+xml": { + "source": "apache", + "extensions": ["gpx"] + }, + "application/gxf": { + "source": "apache", + "extensions": ["gxf"] + }, + "application/gzip": { + "source": "iana", + "compressible": false + }, + "application/h224": { + "source": "iana" + }, + "application/held+xml": { + "source": "iana" + }, + "application/http": { + "source": "iana" + }, + "application/hyperstudio": { + "source": "iana", + "extensions": ["stk"] + }, + "application/ibe-key-request+xml": { + "source": "iana" + }, + "application/ibe-pkg-reply+xml": { + "source": "iana" + }, + "application/ibe-pp-data": { + "source": "iana" + }, + "application/iges": { + "source": "iana" + }, + "application/im-iscomposing+xml": { + "source": "iana" + }, + "application/index": { + "source": "iana" + }, + "application/index.cmd": { + "source": "iana" + }, + "application/index.obj": { + "source": "iana" + }, + "application/index.response": { + "source": "iana" + }, + "application/index.vnd": { + "source": "iana" + }, + "application/inkml+xml": { + "source": "iana", + "extensions": ["ink","inkml"] + }, + "application/iotp": { + "source": "iana" + }, + "application/ipfix": { + "source": "iana", + "extensions": ["ipfix"] + }, + "application/ipp": { + "source": "iana" + }, + "application/isup": { + "source": "iana" + }, + "application/its+xml": { + "source": "iana" + }, + "application/java-archive": { + "source": "apache", + "compressible": false, + "extensions": ["jar","war","ear"] + }, + "application/java-serialized-object": { + "source": "apache", + "compressible": false, + "extensions": ["ser"] + }, + "application/java-vm": { + "source": "apache", + "compressible": false, + "extensions": ["class"] + }, + "application/javascript": { + "source": "iana", + "charset": "UTF-8", + "compressible": true, + "extensions": ["js"] + }, + "application/jose": { + "source": "iana" + }, + "application/jose+json": { + "source": "iana", + "compressible": true + }, + "application/jrd+json": { + "source": "iana", + "compressible": true + }, + "application/json": { + "source": "iana", + "charset": "UTF-8", + "compressible": true, + "extensions": ["json","map"] + }, + "application/json-patch+json": { + "source": "iana", + "compressible": true + }, + "application/json-seq": { + "source": "iana" + }, + "application/json5": { + "extensions": ["json5"] + }, + "application/jsonml+json": { + "source": "apache", + "compressible": true, + "extensions": ["jsonml"] + }, + "application/jwk+json": { + "source": "iana", + "compressible": true + }, + "application/jwk-set+json": { + "source": "iana", + "compressible": true + }, + "application/jwt": { + "source": "iana" + }, + "application/kpml-request+xml": { + "source": "iana" + }, + "application/kpml-response+xml": { + "source": "iana" + }, + "application/ld+json": { + "source": "iana", + "compressible": true, + "extensions": ["jsonld"] + }, + "application/link-format": { + "source": "iana" + }, + "application/load-control+xml": { + "source": "iana" + }, + "application/lost+xml": { + "source": "iana", + "extensions": ["lostxml"] + }, + "application/lostsync+xml": { + "source": "iana" + }, + "application/lxf": { + "source": "iana" + }, + "application/mac-binhex40": { + "source": "iana", + "extensions": ["hqx"] + }, + "application/mac-compactpro": { + "source": "apache", + "extensions": ["cpt"] + }, + "application/macwriteii": { + "source": "iana" + }, + "application/mads+xml": { + "source": "iana", + "extensions": ["mads"] + }, + "application/manifest+json": { + "charset": "UTF-8", + "compressible": true, + "extensions": ["webmanifest"] + }, + "application/marc": { + "source": "iana", + "extensions": ["mrc"] + }, + "application/marcxml+xml": { + "source": "iana", + "extensions": ["mrcx"] + }, + "application/mathematica": { + "source": "iana", + "extensions": ["ma","nb","mb"] + }, + "application/mathml+xml": { + "source": "iana", + "extensions": ["mathml"] + }, + "application/mathml-content+xml": { + "source": "iana" + }, + "application/mathml-presentation+xml": { + "source": "iana" + }, + "application/mbms-associated-procedure-description+xml": { + "source": "iana" + }, + "application/mbms-deregister+xml": { + "source": "iana" + }, + "application/mbms-envelope+xml": { + "source": "iana" + }, + "application/mbms-msk+xml": { + "source": "iana" + }, + "application/mbms-msk-response+xml": { + "source": "iana" + }, + "application/mbms-protection-description+xml": { + "source": "iana" + }, + "application/mbms-reception-report+xml": { + "source": "iana" + }, + "application/mbms-register+xml": { + "source": "iana" + }, + "application/mbms-register-response+xml": { + "source": "iana" + }, + "application/mbms-schedule+xml": { + "source": "iana" + }, + "application/mbms-user-service-description+xml": { + "source": "iana" + }, + "application/mbox": { + "source": "iana", + "extensions": ["mbox"] + }, + "application/media-policy-dataset+xml": { + "source": "iana" + }, + "application/media_control+xml": { + "source": "iana" + }, + "application/mediaservercontrol+xml": { + "source": "iana", + "extensions": ["mscml"] + }, + "application/merge-patch+json": { + "source": "iana", + "compressible": true + }, + "application/metalink+xml": { + "source": "apache", + "extensions": ["metalink"] + }, + "application/metalink4+xml": { + "source": "iana", + "extensions": ["meta4"] + }, + "application/mets+xml": { + "source": "iana", + "extensions": ["mets"] + }, + "application/mf4": { + "source": "iana" + }, + "application/mikey": { + "source": "iana" + }, + "application/mods+xml": { + "source": "iana", + "extensions": ["mods"] + }, + "application/moss-keys": { + "source": "iana" + }, + "application/moss-signature": { + "source": "iana" + }, + "application/mosskey-data": { + "source": "iana" + }, + "application/mosskey-request": { + "source": "iana" + }, + "application/mp21": { + "source": "iana", + "extensions": ["m21","mp21"] + }, + "application/mp4": { + "source": "iana", + "extensions": ["mp4s","m4p"] + }, + "application/mpeg4-generic": { + "source": "iana" + }, + "application/mpeg4-iod": { + "source": "iana" + }, + "application/mpeg4-iod-xmt": { + "source": "iana" + }, + "application/mrb-consumer+xml": { + "source": "iana" + }, + "application/mrb-publish+xml": { + "source": "iana" + }, + "application/msc-ivr+xml": { + "source": "iana" + }, + "application/msc-mixer+xml": { + "source": "iana" + }, + "application/msword": { + "source": "iana", + "compressible": false, + "extensions": ["doc","dot"] + }, + "application/mxf": { + "source": "iana", + "extensions": ["mxf"] + }, + "application/nasdata": { + "source": "iana" + }, + "application/news-checkgroups": { + "source": "iana" + }, + "application/news-groupinfo": { + "source": "iana" + }, + "application/news-transmission": { + "source": "iana" + }, + "application/nlsml+xml": { + "source": "iana" + }, + "application/nss": { + "source": "iana" + }, + "application/ocsp-request": { + "source": "iana" + }, + "application/ocsp-response": { + "source": "iana" + }, + "application/octet-stream": { + "source": "iana", + "compressible": false, + "extensions": ["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"] + }, + "application/oda": { + "source": "iana", + "extensions": ["oda"] + }, + "application/odx": { + "source": "iana" + }, + "application/oebps-package+xml": { + "source": "iana", + "extensions": ["opf"] + }, + "application/ogg": { + "source": "iana", + "compressible": false, + "extensions": ["ogx"] + }, + "application/omdoc+xml": { + "source": "apache", + "extensions": ["omdoc"] + }, + "application/onenote": { + "source": "apache", + "extensions": ["onetoc","onetoc2","onetmp","onepkg"] + }, + "application/oxps": { + "source": "iana", + "extensions": ["oxps"] + }, + "application/p2p-overlay+xml": { + "source": "iana" + }, + "application/parityfec": { + "source": "iana" + }, + "application/patch-ops-error+xml": { + "source": "iana", + "extensions": ["xer"] + }, + "application/pdf": { + "source": "iana", + "compressible": false, + "extensions": ["pdf"] + }, + "application/pdx": { + "source": "iana" + }, + "application/pgp-encrypted": { + "source": "iana", + "compressible": false, + "extensions": ["pgp"] + }, + "application/pgp-keys": { + "source": "iana" + }, + "application/pgp-signature": { + "source": "iana", + "extensions": ["asc","sig"] + }, + "application/pics-rules": { + "source": "apache", + "extensions": ["prf"] + }, + "application/pidf+xml": { + "source": "iana" + }, + "application/pidf-diff+xml": { + "source": "iana" + }, + "application/pkcs10": { + "source": "iana", + "extensions": ["p10"] + }, + "application/pkcs12": { + "source": "iana" + }, + "application/pkcs7-mime": { + "source": "iana", + "extensions": ["p7m","p7c"] + }, + "application/pkcs7-signature": { + "source": "iana", + "extensions": ["p7s"] + }, + "application/pkcs8": { + "source": "iana", + "extensions": ["p8"] + }, + "application/pkix-attr-cert": { + "source": "iana", + "extensions": ["ac"] + }, + "application/pkix-cert": { + "source": "iana", + "extensions": ["cer"] + }, + "application/pkix-crl": { + "source": "iana", + "extensions": ["crl"] + }, + "application/pkix-pkipath": { + "source": "iana", + "extensions": ["pkipath"] + }, + "application/pkixcmp": { + "source": "iana", + "extensions": ["pki"] + }, + "application/pls+xml": { + "source": "iana", + "extensions": ["pls"] + }, + "application/poc-settings+xml": { + "source": "iana" + }, + "application/postscript": { + "source": "iana", + "compressible": true, + "extensions": ["ai","eps","ps"] + }, + "application/ppsp-tracker+json": { + "source": "iana", + "compressible": true + }, + "application/problem+json": { + "source": "iana", + "compressible": true + }, + "application/problem+xml": { + "source": "iana" + }, + "application/provenance+xml": { + "source": "iana" + }, + "application/prs.alvestrand.titrax-sheet": { + "source": "iana" + }, + "application/prs.cww": { + "source": "iana", + "extensions": ["cww"] + }, + "application/prs.hpub+zip": { + "source": "iana" + }, + "application/prs.nprend": { + "source": "iana" + }, + "application/prs.plucker": { + "source": "iana" + }, + "application/prs.rdf-xml-crypt": { + "source": "iana" + }, + "application/prs.xsf+xml": { + "source": "iana" + }, + "application/pskc+xml": { + "source": "iana", + "extensions": ["pskcxml"] + }, + "application/qsig": { + "source": "iana" + }, + "application/raptorfec": { + "source": "iana" + }, + "application/rdap+json": { + "source": "iana", + "compressible": true + }, + "application/rdf+xml": { + "source": "iana", + "compressible": true, + "extensions": ["rdf"] + }, + "application/reginfo+xml": { + "source": "iana", + "extensions": ["rif"] + }, + "application/relax-ng-compact-syntax": { + "source": "iana", + "extensions": ["rnc"] + }, + "application/remote-printing": { + "source": "iana" + }, + "application/reputon+json": { + "source": "iana", + "compressible": true + }, + "application/resource-lists+xml": { + "source": "iana", + "extensions": ["rl"] + }, + "application/resource-lists-diff+xml": { + "source": "iana", + "extensions": ["rld"] + }, + "application/rfc+xml": { + "source": "iana" + }, + "application/riscos": { + "source": "iana" + }, + "application/rlmi+xml": { + "source": "iana" + }, + "application/rls-services+xml": { + "source": "iana", + "extensions": ["rs"] + }, + "application/rpki-ghostbusters": { + "source": "iana", + "extensions": ["gbr"] + }, + "application/rpki-manifest": { + "source": "iana", + "extensions": ["mft"] + }, + "application/rpki-roa": { + "source": "iana", + "extensions": ["roa"] + }, + "application/rpki-updown": { + "source": "iana" + }, + "application/rsd+xml": { + "source": "apache", + "extensions": ["rsd"] + }, + "application/rss+xml": { + "source": "apache", + "compressible": true, + "extensions": ["rss"] + }, + "application/rtf": { + "source": "iana", + "compressible": true, + "extensions": ["rtf"] + }, + "application/rtploopback": { + "source": "iana" + }, + "application/rtx": { + "source": "iana" + }, + "application/samlassertion+xml": { + "source": "iana" + }, + "application/samlmetadata+xml": { + "source": "iana" + }, + "application/sbml+xml": { + "source": "iana", + "extensions": ["sbml"] + }, + "application/scaip+xml": { + "source": "iana" + }, + "application/scim+json": { + "source": "iana", + "compressible": true + }, + "application/scvp-cv-request": { + "source": "iana", + "extensions": ["scq"] + }, + "application/scvp-cv-response": { + "source": "iana", + "extensions": ["scs"] + }, + "application/scvp-vp-request": { + "source": "iana", + "extensions": ["spq"] + }, + "application/scvp-vp-response": { + "source": "iana", + "extensions": ["spp"] + }, + "application/sdp": { + "source": "iana", + "extensions": ["sdp"] + }, + "application/sep+xml": { + "source": "iana" + }, + "application/sep-exi": { + "source": "iana" + }, + "application/session-info": { + "source": "iana" + }, + "application/set-payment": { + "source": "iana" + }, + "application/set-payment-initiation": { + "source": "iana", + "extensions": ["setpay"] + }, + "application/set-registration": { + "source": "iana" + }, + "application/set-registration-initiation": { + "source": "iana", + "extensions": ["setreg"] + }, + "application/sgml": { + "source": "iana" + }, + "application/sgml-open-catalog": { + "source": "iana" + }, + "application/shf+xml": { + "source": "iana", + "extensions": ["shf"] + }, + "application/sieve": { + "source": "iana" + }, + "application/simple-filter+xml": { + "source": "iana" + }, + "application/simple-message-summary": { + "source": "iana" + }, + "application/simplesymbolcontainer": { + "source": "iana" + }, + "application/slate": { + "source": "iana" + }, + "application/smil": { + "source": "iana" + }, + "application/smil+xml": { + "source": "iana", + "extensions": ["smi","smil"] + }, + "application/smpte336m": { + "source": "iana" + }, + "application/soap+fastinfoset": { + "source": "iana" + }, + "application/soap+xml": { + "source": "iana", + "compressible": true + }, + "application/sparql-query": { + "source": "iana", + "extensions": ["rq"] + }, + "application/sparql-results+xml": { + "source": "iana", + "extensions": ["srx"] + }, + "application/spirits-event+xml": { + "source": "iana" + }, + "application/sql": { + "source": "iana" + }, + "application/srgs": { + "source": "iana", + "extensions": ["gram"] + }, + "application/srgs+xml": { + "source": "iana", + "extensions": ["grxml"] + }, + "application/sru+xml": { + "source": "iana", + "extensions": ["sru"] + }, + "application/ssdl+xml": { + "source": "apache", + "extensions": ["ssdl"] + }, + "application/ssml+xml": { + "source": "iana", + "extensions": ["ssml"] + }, + "application/tamp-apex-update": { + "source": "iana" + }, + "application/tamp-apex-update-confirm": { + "source": "iana" + }, + "application/tamp-community-update": { + "source": "iana" + }, + "application/tamp-community-update-confirm": { + "source": "iana" + }, + "application/tamp-error": { + "source": "iana" + }, + "application/tamp-sequence-adjust": { + "source": "iana" + }, + "application/tamp-sequence-adjust-confirm": { + "source": "iana" + }, + "application/tamp-status-query": { + "source": "iana" + }, + "application/tamp-status-response": { + "source": "iana" + }, + "application/tamp-update": { + "source": "iana" + }, + "application/tamp-update-confirm": { + "source": "iana" + }, + "application/tar": { + "compressible": true + }, + "application/tei+xml": { + "source": "iana", + "extensions": ["tei","teicorpus"] + }, + "application/thraud+xml": { + "source": "iana", + "extensions": ["tfi"] + }, + "application/timestamp-query": { + "source": "iana" + }, + "application/timestamp-reply": { + "source": "iana" + }, + "application/timestamped-data": { + "source": "iana", + "extensions": ["tsd"] + }, + "application/ttml+xml": { + "source": "iana" + }, + "application/tve-trigger": { + "source": "iana" + }, + "application/ulpfec": { + "source": "iana" + }, + "application/urc-grpsheet+xml": { + "source": "iana" + }, + "application/urc-ressheet+xml": { + "source": "iana" + }, + "application/urc-targetdesc+xml": { + "source": "iana" + }, + "application/urc-uisocketdesc+xml": { + "source": "iana" + }, + "application/vcard+json": { + "source": "iana", + "compressible": true + }, + "application/vcard+xml": { + "source": "iana" + }, + "application/vemmi": { + "source": "iana" + }, + "application/vividence.scriptfile": { + "source": "apache" + }, + "application/vnd.3gpp-prose+xml": { + "source": "iana" + }, + "application/vnd.3gpp-prose-pc3ch+xml": { + "source": "iana" + }, + "application/vnd.3gpp.access-transfer-events+xml": { + "source": "iana" + }, + "application/vnd.3gpp.bsf+xml": { + "source": "iana" + }, + "application/vnd.3gpp.mid-call+xml": { + "source": "iana" + }, + "application/vnd.3gpp.pic-bw-large": { + "source": "iana", + "extensions": ["plb"] + }, + "application/vnd.3gpp.pic-bw-small": { + "source": "iana", + "extensions": ["psb"] + }, + "application/vnd.3gpp.pic-bw-var": { + "source": "iana", + "extensions": ["pvb"] + }, + "application/vnd.3gpp.sms": { + "source": "iana" + }, + "application/vnd.3gpp.sms+xml": { + "source": "iana" + }, + "application/vnd.3gpp.srvcc-ext+xml": { + "source": "iana" + }, + "application/vnd.3gpp.srvcc-info+xml": { + "source": "iana" + }, + "application/vnd.3gpp.state-and-event-info+xml": { + "source": "iana" + }, + "application/vnd.3gpp.ussd+xml": { + "source": "iana" + }, + "application/vnd.3gpp2.bcmcsinfo+xml": { + "source": "iana" + }, + "application/vnd.3gpp2.sms": { + "source": "iana" + }, + "application/vnd.3gpp2.tcap": { + "source": "iana", + "extensions": ["tcap"] + }, + "application/vnd.3lightssoftware.imagescal": { + "source": "iana" + }, + "application/vnd.3m.post-it-notes": { + "source": "iana", + "extensions": ["pwn"] + }, + "application/vnd.accpac.simply.aso": { + "source": "iana", + "extensions": ["aso"] + }, + "application/vnd.accpac.simply.imp": { + "source": "iana", + "extensions": ["imp"] + }, + "application/vnd.acucobol": { + "source": "iana", + "extensions": ["acu"] + }, + "application/vnd.acucorp": { + "source": "iana", + "extensions": ["atc","acutc"] + }, + "application/vnd.adobe.air-application-installer-package+zip": { + "source": "apache", + "extensions": ["air"] + }, + "application/vnd.adobe.flash.movie": { + "source": "iana" + }, + "application/vnd.adobe.formscentral.fcdt": { + "source": "iana", + "extensions": ["fcdt"] + }, + "application/vnd.adobe.fxp": { + "source": "iana", + "extensions": ["fxp","fxpl"] + }, + "application/vnd.adobe.partial-upload": { + "source": "iana" + }, + "application/vnd.adobe.xdp+xml": { + "source": "iana", + "extensions": ["xdp"] + }, + "application/vnd.adobe.xfdf": { + "source": "iana", + "extensions": ["xfdf"] + }, + "application/vnd.aether.imp": { + "source": "iana" + }, + "application/vnd.ah-barcode": { + "source": "iana" + }, + "application/vnd.ahead.space": { + "source": "iana", + "extensions": ["ahead"] + }, + "application/vnd.airzip.filesecure.azf": { + "source": "iana", + "extensions": ["azf"] + }, + "application/vnd.airzip.filesecure.azs": { + "source": "iana", + "extensions": ["azs"] + }, + "application/vnd.amazon.ebook": { + "source": "apache", + "extensions": ["azw"] + }, + "application/vnd.americandynamics.acc": { + "source": "iana", + "extensions": ["acc"] + }, + "application/vnd.amiga.ami": { + "source": "iana", + "extensions": ["ami"] + }, + "application/vnd.amundsen.maze+xml": { + "source": "iana" + }, + "application/vnd.android.package-archive": { + "source": "apache", + "compressible": false, + "extensions": ["apk"] + }, + "application/vnd.anki": { + "source": "iana" + }, + "application/vnd.anser-web-certificate-issue-initiation": { + "source": "iana", + "extensions": ["cii"] + }, + "application/vnd.anser-web-funds-transfer-initiation": { + "source": "apache", + "extensions": ["fti"] + }, + "application/vnd.antix.game-component": { + "source": "iana", + "extensions": ["atx"] + }, + "application/vnd.apache.thrift.binary": { + "source": "iana" + }, + "application/vnd.apache.thrift.compact": { + "source": "iana" + }, + "application/vnd.apache.thrift.json": { + "source": "iana" + }, + "application/vnd.api+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.apple.installer+xml": { + "source": "iana", + "extensions": ["mpkg"] + }, + "application/vnd.apple.mpegurl": { + "source": "iana", + "extensions": ["m3u8"] + }, + "application/vnd.apple.pkpass": { + "compressible": false, + "extensions": ["pkpass"] + }, + "application/vnd.arastra.swi": { + "source": "iana" + }, + "application/vnd.aristanetworks.swi": { + "source": "iana", + "extensions": ["swi"] + }, + "application/vnd.artsquare": { + "source": "iana" + }, + "application/vnd.astraea-software.iota": { + "source": "iana", + "extensions": ["iota"] + }, + "application/vnd.audiograph": { + "source": "iana", + "extensions": ["aep"] + }, + "application/vnd.autopackage": { + "source": "iana" + }, + "application/vnd.avistar+xml": { + "source": "iana" + }, + "application/vnd.balsamiq.bmml+xml": { + "source": "iana" + }, + "application/vnd.balsamiq.bmpr": { + "source": "iana" + }, + "application/vnd.bekitzur-stech+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.biopax.rdf+xml": { + "source": "iana" + }, + "application/vnd.blueice.multipass": { + "source": "iana", + "extensions": ["mpm"] + }, + "application/vnd.bluetooth.ep.oob": { + "source": "iana" + }, + "application/vnd.bluetooth.le.oob": { + "source": "iana" + }, + "application/vnd.bmi": { + "source": "iana", + "extensions": ["bmi"] + }, + "application/vnd.businessobjects": { + "source": "iana", + "extensions": ["rep"] + }, + "application/vnd.cab-jscript": { + "source": "iana" + }, + "application/vnd.canon-cpdl": { + "source": "iana" + }, + "application/vnd.canon-lips": { + "source": "iana" + }, + "application/vnd.cendio.thinlinc.clientconf": { + "source": "iana" + }, + "application/vnd.century-systems.tcp_stream": { + "source": "iana" + }, + "application/vnd.chemdraw+xml": { + "source": "iana", + "extensions": ["cdxml"] + }, + "application/vnd.chipnuts.karaoke-mmd": { + "source": "iana", + "extensions": ["mmd"] + }, + "application/vnd.cinderella": { + "source": "iana", + "extensions": ["cdy"] + }, + "application/vnd.cirpack.isdn-ext": { + "source": "iana" + }, + "application/vnd.citationstyles.style+xml": { + "source": "iana" + }, + "application/vnd.claymore": { + "source": "iana", + "extensions": ["cla"] + }, + "application/vnd.cloanto.rp9": { + "source": "iana", + "extensions": ["rp9"] + }, + "application/vnd.clonk.c4group": { + "source": "iana", + "extensions": ["c4g","c4d","c4f","c4p","c4u"] + }, + "application/vnd.cluetrust.cartomobile-config": { + "source": "iana", + "extensions": ["c11amc"] + }, + "application/vnd.cluetrust.cartomobile-config-pkg": { + "source": "iana", + "extensions": ["c11amz"] + }, + "application/vnd.coffeescript": { + "source": "iana" + }, + "application/vnd.collection+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.collection.doc+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.collection.next+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.commerce-battelle": { + "source": "iana" + }, + "application/vnd.commonspace": { + "source": "iana", + "extensions": ["csp"] + }, + "application/vnd.contact.cmsg": { + "source": "iana", + "extensions": ["cdbcmsg"] + }, + "application/vnd.coreos.ignition+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.cosmocaller": { + "source": "iana", + "extensions": ["cmc"] + }, + "application/vnd.crick.clicker": { + "source": "iana", + "extensions": ["clkx"] + }, + "application/vnd.crick.clicker.keyboard": { + "source": "iana", + "extensions": ["clkk"] + }, + "application/vnd.crick.clicker.palette": { + "source": "iana", + "extensions": ["clkp"] + }, + "application/vnd.crick.clicker.template": { + "source": "iana", + "extensions": ["clkt"] + }, + "application/vnd.crick.clicker.wordbank": { + "source": "iana", + "extensions": ["clkw"] + }, + "application/vnd.criticaltools.wbs+xml": { + "source": "iana", + "extensions": ["wbs"] + }, + "application/vnd.ctc-posml": { + "source": "iana", + "extensions": ["pml"] + }, + "application/vnd.ctct.ws+xml": { + "source": "iana" + }, + "application/vnd.cups-pdf": { + "source": "iana" + }, + "application/vnd.cups-postscript": { + "source": "iana" + }, + "application/vnd.cups-ppd": { + "source": "iana", + "extensions": ["ppd"] + }, + "application/vnd.cups-raster": { + "source": "iana" + }, + "application/vnd.cups-raw": { + "source": "iana" + }, + "application/vnd.curl": { + "source": "iana" + }, + "application/vnd.curl.car": { + "source": "apache", + "extensions": ["car"] + }, + "application/vnd.curl.pcurl": { + "source": "apache", + "extensions": ["pcurl"] + }, + "application/vnd.cyan.dean.root+xml": { + "source": "iana" + }, + "application/vnd.cybank": { + "source": "iana" + }, + "application/vnd.dart": { + "source": "iana", + "compressible": true, + "extensions": ["dart"] + }, + "application/vnd.data-vision.rdz": { + "source": "iana", + "extensions": ["rdz"] + }, + "application/vnd.debian.binary-package": { + "source": "iana" + }, + "application/vnd.dece.data": { + "source": "iana", + "extensions": ["uvf","uvvf","uvd","uvvd"] + }, + "application/vnd.dece.ttml+xml": { + "source": "iana", + "extensions": ["uvt","uvvt"] + }, + "application/vnd.dece.unspecified": { + "source": "iana", + "extensions": ["uvx","uvvx"] + }, + "application/vnd.dece.zip": { + "source": "iana", + "extensions": ["uvz","uvvz"] + }, + "application/vnd.denovo.fcselayout-link": { + "source": "iana", + "extensions": ["fe_launch"] + }, + "application/vnd.desmume-movie": { + "source": "iana" + }, + "application/vnd.desmume.movie": { + "source": "apache" + }, + "application/vnd.dir-bi.plate-dl-nosuffix": { + "source": "iana" + }, + "application/vnd.dm.delegation+xml": { + "source": "iana" + }, + "application/vnd.dna": { + "source": "iana", + "extensions": ["dna"] + }, + "application/vnd.document+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.dolby.mlp": { + "source": "apache", + "extensions": ["mlp"] + }, + "application/vnd.dolby.mobile.1": { + "source": "iana" + }, + "application/vnd.dolby.mobile.2": { + "source": "iana" + }, + "application/vnd.doremir.scorecloud-binary-document": { + "source": "iana" + }, + "application/vnd.dpgraph": { + "source": "iana", + "extensions": ["dpg"] + }, + "application/vnd.dreamfactory": { + "source": "iana", + "extensions": ["dfac"] + }, + "application/vnd.drive+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.ds-keypoint": { + "source": "apache", + "extensions": ["kpxx"] + }, + "application/vnd.dtg.local": { + "source": "iana" + }, + "application/vnd.dtg.local.flash": { + "source": "iana" + }, + "application/vnd.dtg.local.html": { + "source": "iana" + }, + "application/vnd.dvb.ait": { + "source": "iana", + "extensions": ["ait"] + }, + "application/vnd.dvb.dvbj": { + "source": "iana" + }, + "application/vnd.dvb.esgcontainer": { + "source": "iana" + }, + "application/vnd.dvb.ipdcdftnotifaccess": { + "source": "iana" + }, + "application/vnd.dvb.ipdcesgaccess": { + "source": "iana" + }, + "application/vnd.dvb.ipdcesgaccess2": { + "source": "iana" + }, + "application/vnd.dvb.ipdcesgpdd": { + "source": "iana" + }, + "application/vnd.dvb.ipdcroaming": { + "source": "iana" + }, + "application/vnd.dvb.iptv.alfec-base": { + "source": "iana" + }, + "application/vnd.dvb.iptv.alfec-enhancement": { + "source": "iana" + }, + "application/vnd.dvb.notif-aggregate-root+xml": { + "source": "iana" + }, + "application/vnd.dvb.notif-container+xml": { + "source": "iana" + }, + "application/vnd.dvb.notif-generic+xml": { + "source": "iana" + }, + "application/vnd.dvb.notif-ia-msglist+xml": { + "source": "iana" + }, + "application/vnd.dvb.notif-ia-registration-request+xml": { + "source": "iana" + }, + "application/vnd.dvb.notif-ia-registration-response+xml": { + "source": "iana" + }, + "application/vnd.dvb.notif-init+xml": { + "source": "iana" + }, + "application/vnd.dvb.pfr": { + "source": "iana" + }, + "application/vnd.dvb.service": { + "source": "iana", + "extensions": ["svc"] + }, + "application/vnd.dxr": { + "source": "iana" + }, + "application/vnd.dynageo": { + "source": "iana", + "extensions": ["geo"] + }, + "application/vnd.dzr": { + "source": "iana" + }, + "application/vnd.easykaraoke.cdgdownload": { + "source": "iana" + }, + "application/vnd.ecdis-update": { + "source": "iana" + }, + "application/vnd.ecowin.chart": { + "source": "iana", + "extensions": ["mag"] + }, + "application/vnd.ecowin.filerequest": { + "source": "iana" + }, + "application/vnd.ecowin.fileupdate": { + "source": "iana" + }, + "application/vnd.ecowin.series": { + "source": "iana" + }, + "application/vnd.ecowin.seriesrequest": { + "source": "iana" + }, + "application/vnd.ecowin.seriesupdate": { + "source": "iana" + }, + "application/vnd.emclient.accessrequest+xml": { + "source": "iana" + }, + "application/vnd.enliven": { + "source": "iana", + "extensions": ["nml"] + }, + "application/vnd.enphase.envoy": { + "source": "iana" + }, + "application/vnd.eprints.data+xml": { + "source": "iana" + }, + "application/vnd.epson.esf": { + "source": "iana", + "extensions": ["esf"] + }, + "application/vnd.epson.msf": { + "source": "iana", + "extensions": ["msf"] + }, + "application/vnd.epson.quickanime": { + "source": "iana", + "extensions": ["qam"] + }, + "application/vnd.epson.salt": { + "source": "iana", + "extensions": ["slt"] + }, + "application/vnd.epson.ssf": { + "source": "iana", + "extensions": ["ssf"] + }, + "application/vnd.ericsson.quickcall": { + "source": "iana" + }, + "application/vnd.eszigno3+xml": { + "source": "iana", + "extensions": ["es3","et3"] + }, + "application/vnd.etsi.aoc+xml": { + "source": "iana" + }, + "application/vnd.etsi.asic-e+zip": { + "source": "iana" + }, + "application/vnd.etsi.asic-s+zip": { + "source": "iana" + }, + "application/vnd.etsi.cug+xml": { + "source": "iana" + }, + "application/vnd.etsi.iptvcommand+xml": { + "source": "iana" + }, + "application/vnd.etsi.iptvdiscovery+xml": { + "source": "iana" + }, + "application/vnd.etsi.iptvprofile+xml": { + "source": "iana" + }, + "application/vnd.etsi.iptvsad-bc+xml": { + "source": "iana" + }, + "application/vnd.etsi.iptvsad-cod+xml": { + "source": "iana" + }, + "application/vnd.etsi.iptvsad-npvr+xml": { + "source": "iana" + }, + "application/vnd.etsi.iptvservice+xml": { + "source": "iana" + }, + "application/vnd.etsi.iptvsync+xml": { + "source": "iana" + }, + "application/vnd.etsi.iptvueprofile+xml": { + "source": "iana" + }, + "application/vnd.etsi.mcid+xml": { + "source": "iana" + }, + "application/vnd.etsi.mheg5": { + "source": "iana" + }, + "application/vnd.etsi.overload-control-policy-dataset+xml": { + "source": "iana" + }, + "application/vnd.etsi.pstn+xml": { + "source": "iana" + }, + "application/vnd.etsi.sci+xml": { + "source": "iana" + }, + "application/vnd.etsi.simservs+xml": { + "source": "iana" + }, + "application/vnd.etsi.timestamp-token": { + "source": "iana" + }, + "application/vnd.etsi.tsl+xml": { + "source": "iana" + }, + "application/vnd.etsi.tsl.der": { + "source": "iana" + }, + "application/vnd.eudora.data": { + "source": "iana" + }, + "application/vnd.ezpix-album": { + "source": "iana", + "extensions": ["ez2"] + }, + "application/vnd.ezpix-package": { + "source": "iana", + "extensions": ["ez3"] + }, + "application/vnd.f-secure.mobile": { + "source": "iana" + }, + "application/vnd.fastcopy-disk-image": { + "source": "iana" + }, + "application/vnd.fdf": { + "source": "iana", + "extensions": ["fdf"] + }, + "application/vnd.fdsn.mseed": { + "source": "iana", + "extensions": ["mseed"] + }, + "application/vnd.fdsn.seed": { + "source": "iana", + "extensions": ["seed","dataless"] + }, + "application/vnd.ffsns": { + "source": "iana" + }, + "application/vnd.filmit.zfc": { + "source": "iana" + }, + "application/vnd.fints": { + "source": "iana" + }, + "application/vnd.firemonkeys.cloudcell": { + "source": "iana" + }, + "application/vnd.flographit": { + "source": "iana", + "extensions": ["gph"] + }, + "application/vnd.fluxtime.clip": { + "source": "iana", + "extensions": ["ftc"] + }, + "application/vnd.font-fontforge-sfd": { + "source": "iana" + }, + "application/vnd.framemaker": { + "source": "iana", + "extensions": ["fm","frame","maker","book"] + }, + "application/vnd.frogans.fnc": { + "source": "iana", + "extensions": ["fnc"] + }, + "application/vnd.frogans.ltf": { + "source": "iana", + "extensions": ["ltf"] + }, + "application/vnd.fsc.weblaunch": { + "source": "iana", + "extensions": ["fsc"] + }, + "application/vnd.fujitsu.oasys": { + "source": "iana", + "extensions": ["oas"] + }, + "application/vnd.fujitsu.oasys2": { + "source": "iana", + "extensions": ["oa2"] + }, + "application/vnd.fujitsu.oasys3": { + "source": "iana", + "extensions": ["oa3"] + }, + "application/vnd.fujitsu.oasysgp": { + "source": "iana", + "extensions": ["fg5"] + }, + "application/vnd.fujitsu.oasysprs": { + "source": "iana", + "extensions": ["bh2"] + }, + "application/vnd.fujixerox.art-ex": { + "source": "iana" + }, + "application/vnd.fujixerox.art4": { + "source": "iana" + }, + "application/vnd.fujixerox.ddd": { + "source": "iana", + "extensions": ["ddd"] + }, + "application/vnd.fujixerox.docuworks": { + "source": "iana", + "extensions": ["xdw"] + }, + "application/vnd.fujixerox.docuworks.binder": { + "source": "iana", + "extensions": ["xbd"] + }, + "application/vnd.fujixerox.docuworks.container": { + "source": "iana" + }, + "application/vnd.fujixerox.hbpl": { + "source": "iana" + }, + "application/vnd.fut-misnet": { + "source": "iana" + }, + "application/vnd.fuzzysheet": { + "source": "iana", + "extensions": ["fzs"] + }, + "application/vnd.genomatix.tuxedo": { + "source": "iana", + "extensions": ["txd"] + }, + "application/vnd.geo+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.geocube+xml": { + "source": "iana" + }, + "application/vnd.geogebra.file": { + "source": "iana", + "extensions": ["ggb"] + }, + "application/vnd.geogebra.tool": { + "source": "iana", + "extensions": ["ggt"] + }, + "application/vnd.geometry-explorer": { + "source": "iana", + "extensions": ["gex","gre"] + }, + "application/vnd.geonext": { + "source": "iana", + "extensions": ["gxt"] + }, + "application/vnd.geoplan": { + "source": "iana", + "extensions": ["g2w"] + }, + "application/vnd.geospace": { + "source": "iana", + "extensions": ["g3w"] + }, + "application/vnd.gerber": { + "source": "iana" + }, + "application/vnd.globalplatform.card-content-mgt": { + "source": "iana" + }, + "application/vnd.globalplatform.card-content-mgt-response": { + "source": "iana" + }, + "application/vnd.gmx": { + "source": "iana", + "extensions": ["gmx"] + }, + "application/vnd.google-apps.document": { + "compressible": false, + "extensions": ["gdoc"] + }, + "application/vnd.google-apps.presentation": { + "compressible": false, + "extensions": ["gslides"] + }, + "application/vnd.google-apps.spreadsheet": { + "compressible": false, + "extensions": ["gsheet"] + }, + "application/vnd.google-earth.kml+xml": { + "source": "iana", + "compressible": true, + "extensions": ["kml"] + }, + "application/vnd.google-earth.kmz": { + "source": "iana", + "compressible": false, + "extensions": ["kmz"] + }, + "application/vnd.gov.sk.e-form+xml": { + "source": "iana" + }, + "application/vnd.gov.sk.e-form+zip": { + "source": "iana" + }, + "application/vnd.gov.sk.xmldatacontainer+xml": { + "source": "iana" + }, + "application/vnd.grafeq": { + "source": "iana", + "extensions": ["gqf","gqs"] + }, + "application/vnd.gridmp": { + "source": "iana" + }, + "application/vnd.groove-account": { + "source": "iana", + "extensions": ["gac"] + }, + "application/vnd.groove-help": { + "source": "iana", + "extensions": ["ghf"] + }, + "application/vnd.groove-identity-message": { + "source": "iana", + "extensions": ["gim"] + }, + "application/vnd.groove-injector": { + "source": "iana", + "extensions": ["grv"] + }, + "application/vnd.groove-tool-message": { + "source": "iana", + "extensions": ["gtm"] + }, + "application/vnd.groove-tool-template": { + "source": "iana", + "extensions": ["tpl"] + }, + "application/vnd.groove-vcard": { + "source": "iana", + "extensions": ["vcg"] + }, + "application/vnd.hal+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.hal+xml": { + "source": "iana", + "extensions": ["hal"] + }, + "application/vnd.handheld-entertainment+xml": { + "source": "iana", + "extensions": ["zmm"] + }, + "application/vnd.hbci": { + "source": "iana", + "extensions": ["hbci"] + }, + "application/vnd.hcl-bireports": { + "source": "iana" + }, + "application/vnd.hdt": { + "source": "iana" + }, + "application/vnd.heroku+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.hhe.lesson-player": { + "source": "iana", + "extensions": ["les"] + }, + "application/vnd.hp-hpgl": { + "source": "iana", + "extensions": ["hpgl"] + }, + "application/vnd.hp-hpid": { + "source": "iana", + "extensions": ["hpid"] + }, + "application/vnd.hp-hps": { + "source": "iana", + "extensions": ["hps"] + }, + "application/vnd.hp-jlyt": { + "source": "iana", + "extensions": ["jlt"] + }, + "application/vnd.hp-pcl": { + "source": "iana", + "extensions": ["pcl"] + }, + "application/vnd.hp-pclxl": { + "source": "iana", + "extensions": ["pclxl"] + }, + "application/vnd.httphone": { + "source": "iana" + }, + "application/vnd.hydrostatix.sof-data": { + "source": "iana", + "extensions": ["sfd-hdstx"] + }, + "application/vnd.hyperdrive+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.hzn-3d-crossword": { + "source": "iana" + }, + "application/vnd.ibm.afplinedata": { + "source": "iana" + }, + "application/vnd.ibm.electronic-media": { + "source": "iana" + }, + "application/vnd.ibm.minipay": { + "source": "iana", + "extensions": ["mpy"] + }, + "application/vnd.ibm.modcap": { + "source": "iana", + "extensions": ["afp","listafp","list3820"] + }, + "application/vnd.ibm.rights-management": { + "source": "iana", + "extensions": ["irm"] + }, + "application/vnd.ibm.secure-container": { + "source": "iana", + "extensions": ["sc"] + }, + "application/vnd.iccprofile": { + "source": "iana", + "extensions": ["icc","icm"] + }, + "application/vnd.ieee.1905": { + "source": "iana" + }, + "application/vnd.igloader": { + "source": "iana", + "extensions": ["igl"] + }, + "application/vnd.immervision-ivp": { + "source": "iana", + "extensions": ["ivp"] + }, + "application/vnd.immervision-ivu": { + "source": "iana", + "extensions": ["ivu"] + }, + "application/vnd.ims.imsccv1p1": { + "source": "iana" + }, + "application/vnd.ims.imsccv1p2": { + "source": "iana" + }, + "application/vnd.ims.imsccv1p3": { + "source": "iana" + }, + "application/vnd.ims.lis.v2.result+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.ims.lti.v2.toolconsumerprofile+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.ims.lti.v2.toolproxy+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.ims.lti.v2.toolproxy.id+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.ims.lti.v2.toolsettings+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.ims.lti.v2.toolsettings.simple+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.informedcontrol.rms+xml": { + "source": "iana" + }, + "application/vnd.informix-visionary": { + "source": "iana" + }, + "application/vnd.infotech.project": { + "source": "iana" + }, + "application/vnd.infotech.project+xml": { + "source": "iana" + }, + "application/vnd.innopath.wamp.notification": { + "source": "iana" + }, + "application/vnd.insors.igm": { + "source": "iana", + "extensions": ["igm"] + }, + "application/vnd.intercon.formnet": { + "source": "iana", + "extensions": ["xpw","xpx"] + }, + "application/vnd.intergeo": { + "source": "iana", + "extensions": ["i2g"] + }, + "application/vnd.intertrust.digibox": { + "source": "iana" + }, + "application/vnd.intertrust.nncp": { + "source": "iana" + }, + "application/vnd.intu.qbo": { + "source": "iana", + "extensions": ["qbo"] + }, + "application/vnd.intu.qfx": { + "source": "iana", + "extensions": ["qfx"] + }, + "application/vnd.iptc.g2.catalogitem+xml": { + "source": "iana" + }, + "application/vnd.iptc.g2.conceptitem+xml": { + "source": "iana" + }, + "application/vnd.iptc.g2.knowledgeitem+xml": { + "source": "iana" + }, + "application/vnd.iptc.g2.newsitem+xml": { + "source": "iana" + }, + "application/vnd.iptc.g2.newsmessage+xml": { + "source": "iana" + }, + "application/vnd.iptc.g2.packageitem+xml": { + "source": "iana" + }, + "application/vnd.iptc.g2.planningitem+xml": { + "source": "iana" + }, + "application/vnd.ipunplugged.rcprofile": { + "source": "iana", + "extensions": ["rcprofile"] + }, + "application/vnd.irepository.package+xml": { + "source": "iana", + "extensions": ["irp"] + }, + "application/vnd.is-xpr": { + "source": "iana", + "extensions": ["xpr"] + }, + "application/vnd.isac.fcs": { + "source": "iana", + "extensions": ["fcs"] + }, + "application/vnd.jam": { + "source": "iana", + "extensions": ["jam"] + }, + "application/vnd.japannet-directory-service": { + "source": "iana" + }, + "application/vnd.japannet-jpnstore-wakeup": { + "source": "iana" + }, + "application/vnd.japannet-payment-wakeup": { + "source": "iana" + }, + "application/vnd.japannet-registration": { + "source": "iana" + }, + "application/vnd.japannet-registration-wakeup": { + "source": "iana" + }, + "application/vnd.japannet-setstore-wakeup": { + "source": "iana" + }, + "application/vnd.japannet-verification": { + "source": "iana" + }, + "application/vnd.japannet-verification-wakeup": { + "source": "iana" + }, + "application/vnd.jcp.javame.midlet-rms": { + "source": "iana", + "extensions": ["rms"] + }, + "application/vnd.jisp": { + "source": "iana", + "extensions": ["jisp"] + }, + "application/vnd.joost.joda-archive": { + "source": "iana", + "extensions": ["joda"] + }, + "application/vnd.jsk.isdn-ngn": { + "source": "iana" + }, + "application/vnd.kahootz": { + "source": "iana", + "extensions": ["ktz","ktr"] + }, + "application/vnd.kde.karbon": { + "source": "iana", + "extensions": ["karbon"] + }, + "application/vnd.kde.kchart": { + "source": "iana", + "extensions": ["chrt"] + }, + "application/vnd.kde.kformula": { + "source": "iana", + "extensions": ["kfo"] + }, + "application/vnd.kde.kivio": { + "source": "iana", + "extensions": ["flw"] + }, + "application/vnd.kde.kontour": { + "source": "iana", + "extensions": ["kon"] + }, + "application/vnd.kde.kpresenter": { + "source": "iana", + "extensions": ["kpr","kpt"] + }, + "application/vnd.kde.kspread": { + "source": "iana", + "extensions": ["ksp"] + }, + "application/vnd.kde.kword": { + "source": "iana", + "extensions": ["kwd","kwt"] + }, + "application/vnd.kenameaapp": { + "source": "iana", + "extensions": ["htke"] + }, + "application/vnd.kidspiration": { + "source": "iana", + "extensions": ["kia"] + }, + "application/vnd.kinar": { + "source": "iana", + "extensions": ["kne","knp"] + }, + "application/vnd.koan": { + "source": "iana", + "extensions": ["skp","skd","skt","skm"] + }, + "application/vnd.kodak-descriptor": { + "source": "iana", + "extensions": ["sse"] + }, + "application/vnd.las.las+xml": { + "source": "iana", + "extensions": ["lasxml"] + }, + "application/vnd.liberty-request+xml": { + "source": "iana" + }, + "application/vnd.llamagraphics.life-balance.desktop": { + "source": "iana", + "extensions": ["lbd"] + }, + "application/vnd.llamagraphics.life-balance.exchange+xml": { + "source": "iana", + "extensions": ["lbe"] + }, + "application/vnd.lotus-1-2-3": { + "source": "iana", + "extensions": ["123"] + }, + "application/vnd.lotus-approach": { + "source": "iana", + "extensions": ["apr"] + }, + "application/vnd.lotus-freelance": { + "source": "iana", + "extensions": ["pre"] + }, + "application/vnd.lotus-notes": { + "source": "iana", + "extensions": ["nsf"] + }, + "application/vnd.lotus-organizer": { + "source": "iana", + "extensions": ["org"] + }, + "application/vnd.lotus-screencam": { + "source": "iana", + "extensions": ["scm"] + }, + "application/vnd.lotus-wordpro": { + "source": "iana", + "extensions": ["lwp"] + }, + "application/vnd.macports.portpkg": { + "source": "iana", + "extensions": ["portpkg"] + }, + "application/vnd.mapbox-vector-tile": { + "source": "iana" + }, + "application/vnd.marlin.drm.actiontoken+xml": { + "source": "iana" + }, + "application/vnd.marlin.drm.conftoken+xml": { + "source": "iana" + }, + "application/vnd.marlin.drm.license+xml": { + "source": "iana" + }, + "application/vnd.marlin.drm.mdcf": { + "source": "iana" + }, + "application/vnd.mason+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.maxmind.maxmind-db": { + "source": "iana" + }, + "application/vnd.mcd": { + "source": "iana", + "extensions": ["mcd"] + }, + "application/vnd.medcalcdata": { + "source": "iana", + "extensions": ["mc1"] + }, + "application/vnd.mediastation.cdkey": { + "source": "iana", + "extensions": ["cdkey"] + }, + "application/vnd.meridian-slingshot": { + "source": "iana" + }, + "application/vnd.mfer": { + "source": "iana", + "extensions": ["mwf"] + }, + "application/vnd.mfmp": { + "source": "iana", + "extensions": ["mfm"] + }, + "application/vnd.micro+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.micrografx.flo": { + "source": "iana", + "extensions": ["flo"] + }, + "application/vnd.micrografx.igx": { + "source": "iana", + "extensions": ["igx"] + }, + "application/vnd.microsoft.portable-executable": { + "source": "iana" + }, + "application/vnd.miele+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.mif": { + "source": "iana", + "extensions": ["mif"] + }, + "application/vnd.minisoft-hp3000-save": { + "source": "iana" + }, + "application/vnd.mitsubishi.misty-guard.trustweb": { + "source": "iana" + }, + "application/vnd.mobius.daf": { + "source": "iana", + "extensions": ["daf"] + }, + "application/vnd.mobius.dis": { + "source": "iana", + "extensions": ["dis"] + }, + "application/vnd.mobius.mbk": { + "source": "iana", + "extensions": ["mbk"] + }, + "application/vnd.mobius.mqy": { + "source": "iana", + "extensions": ["mqy"] + }, + "application/vnd.mobius.msl": { + "source": "iana", + "extensions": ["msl"] + }, + "application/vnd.mobius.plc": { + "source": "iana", + "extensions": ["plc"] + }, + "application/vnd.mobius.txf": { + "source": "iana", + "extensions": ["txf"] + }, + "application/vnd.mophun.application": { + "source": "iana", + "extensions": ["mpn"] + }, + "application/vnd.mophun.certificate": { + "source": "iana", + "extensions": ["mpc"] + }, + "application/vnd.motorola.flexsuite": { + "source": "iana" + }, + "application/vnd.motorola.flexsuite.adsi": { + "source": "iana" + }, + "application/vnd.motorola.flexsuite.fis": { + "source": "iana" + }, + "application/vnd.motorola.flexsuite.gotap": { + "source": "iana" + }, + "application/vnd.motorola.flexsuite.kmr": { + "source": "iana" + }, + "application/vnd.motorola.flexsuite.ttc": { + "source": "iana" + }, + "application/vnd.motorola.flexsuite.wem": { + "source": "iana" + }, + "application/vnd.motorola.iprm": { + "source": "iana" + }, + "application/vnd.mozilla.xul+xml": { + "source": "iana", + "compressible": true, + "extensions": ["xul"] + }, + "application/vnd.ms-3mfdocument": { + "source": "iana" + }, + "application/vnd.ms-artgalry": { + "source": "iana", + "extensions": ["cil"] + }, + "application/vnd.ms-asf": { + "source": "iana" + }, + "application/vnd.ms-cab-compressed": { + "source": "iana", + "extensions": ["cab"] + }, + "application/vnd.ms-color.iccprofile": { + "source": "apache" + }, + "application/vnd.ms-excel": { + "source": "iana", + "compressible": false, + "extensions": ["xls","xlm","xla","xlc","xlt","xlw"] + }, + "application/vnd.ms-excel.addin.macroenabled.12": { + "source": "iana", + "extensions": ["xlam"] + }, + "application/vnd.ms-excel.sheet.binary.macroenabled.12": { + "source": "iana", + "extensions": ["xlsb"] + }, + "application/vnd.ms-excel.sheet.macroenabled.12": { + "source": "iana", + "extensions": ["xlsm"] + }, + "application/vnd.ms-excel.template.macroenabled.12": { + "source": "iana", + "extensions": ["xltm"] + }, + "application/vnd.ms-fontobject": { + "source": "iana", + "compressible": true, + "extensions": ["eot"] + }, + "application/vnd.ms-htmlhelp": { + "source": "iana", + "extensions": ["chm"] + }, + "application/vnd.ms-ims": { + "source": "iana", + "extensions": ["ims"] + }, + "application/vnd.ms-lrm": { + "source": "iana", + "extensions": ["lrm"] + }, + "application/vnd.ms-office.activex+xml": { + "source": "iana" + }, + "application/vnd.ms-officetheme": { + "source": "iana", + "extensions": ["thmx"] + }, + "application/vnd.ms-opentype": { + "source": "apache", + "compressible": true + }, + "application/vnd.ms-package.obfuscated-opentype": { + "source": "apache" + }, + "application/vnd.ms-pki.seccat": { + "source": "apache", + "extensions": ["cat"] + }, + "application/vnd.ms-pki.stl": { + "source": "apache", + "extensions": ["stl"] + }, + "application/vnd.ms-playready.initiator+xml": { + "source": "iana" + }, + "application/vnd.ms-powerpoint": { + "source": "iana", + "compressible": false, + "extensions": ["ppt","pps","pot"] + }, + "application/vnd.ms-powerpoint.addin.macroenabled.12": { + "source": "iana", + "extensions": ["ppam"] + }, + "application/vnd.ms-powerpoint.presentation.macroenabled.12": { + "source": "iana", + "extensions": ["pptm"] + }, + "application/vnd.ms-powerpoint.slide.macroenabled.12": { + "source": "iana", + "extensions": ["sldm"] + }, + "application/vnd.ms-powerpoint.slideshow.macroenabled.12": { + "source": "iana", + "extensions": ["ppsm"] + }, + "application/vnd.ms-powerpoint.template.macroenabled.12": { + "source": "iana", + "extensions": ["potm"] + }, + "application/vnd.ms-printdevicecapabilities+xml": { + "source": "iana" + }, + "application/vnd.ms-printing.printticket+xml": { + "source": "apache" + }, + "application/vnd.ms-printschematicket+xml": { + "source": "iana" + }, + "application/vnd.ms-project": { + "source": "iana", + "extensions": ["mpp","mpt"] + }, + "application/vnd.ms-tnef": { + "source": "iana" + }, + "application/vnd.ms-windows.devicepairing": { + "source": "iana" + }, + "application/vnd.ms-windows.nwprinting.oob": { + "source": "iana" + }, + "application/vnd.ms-windows.printerpairing": { + "source": "iana" + }, + "application/vnd.ms-windows.wsd.oob": { + "source": "iana" + }, + "application/vnd.ms-wmdrm.lic-chlg-req": { + "source": "iana" + }, + "application/vnd.ms-wmdrm.lic-resp": { + "source": "iana" + }, + "application/vnd.ms-wmdrm.meter-chlg-req": { + "source": "iana" + }, + "application/vnd.ms-wmdrm.meter-resp": { + "source": "iana" + }, + "application/vnd.ms-word.document.macroenabled.12": { + "source": "iana", + "extensions": ["docm"] + }, + "application/vnd.ms-word.template.macroenabled.12": { + "source": "iana", + "extensions": ["dotm"] + }, + "application/vnd.ms-works": { + "source": "iana", + "extensions": ["wps","wks","wcm","wdb"] + }, + "application/vnd.ms-wpl": { + "source": "iana", + "extensions": ["wpl"] + }, + "application/vnd.ms-xpsdocument": { + "source": "iana", + "compressible": false, + "extensions": ["xps"] + }, + "application/vnd.msa-disk-image": { + "source": "iana" + }, + "application/vnd.mseq": { + "source": "iana", + "extensions": ["mseq"] + }, + "application/vnd.msign": { + "source": "iana" + }, + "application/vnd.multiad.creator": { + "source": "iana" + }, + "application/vnd.multiad.creator.cif": { + "source": "iana" + }, + "application/vnd.music-niff": { + "source": "iana" + }, + "application/vnd.musician": { + "source": "iana", + "extensions": ["mus"] + }, + "application/vnd.muvee.style": { + "source": "iana", + "extensions": ["msty"] + }, + "application/vnd.mynfc": { + "source": "iana", + "extensions": ["taglet"] + }, + "application/vnd.ncd.control": { + "source": "iana" + }, + "application/vnd.ncd.reference": { + "source": "iana" + }, + "application/vnd.nervana": { + "source": "iana" + }, + "application/vnd.netfpx": { + "source": "iana" + }, + "application/vnd.neurolanguage.nlu": { + "source": "iana", + "extensions": ["nlu"] + }, + "application/vnd.nintendo.nitro.rom": { + "source": "iana" + }, + "application/vnd.nintendo.snes.rom": { + "source": "iana" + }, + "application/vnd.nitf": { + "source": "iana", + "extensions": ["ntf","nitf"] + }, + "application/vnd.noblenet-directory": { + "source": "iana", + "extensions": ["nnd"] + }, + "application/vnd.noblenet-sealer": { + "source": "iana", + "extensions": ["nns"] + }, + "application/vnd.noblenet-web": { + "source": "iana", + "extensions": ["nnw"] + }, + "application/vnd.nokia.catalogs": { + "source": "iana" + }, + "application/vnd.nokia.conml+wbxml": { + "source": "iana" + }, + "application/vnd.nokia.conml+xml": { + "source": "iana" + }, + "application/vnd.nokia.iptv.config+xml": { + "source": "iana" + }, + "application/vnd.nokia.isds-radio-presets": { + "source": "iana" + }, + "application/vnd.nokia.landmark+wbxml": { + "source": "iana" + }, + "application/vnd.nokia.landmark+xml": { + "source": "iana" + }, + "application/vnd.nokia.landmarkcollection+xml": { + "source": "iana" + }, + "application/vnd.nokia.n-gage.ac+xml": { + "source": "iana" + }, + "application/vnd.nokia.n-gage.data": { + "source": "iana", + "extensions": ["ngdat"] + }, + "application/vnd.nokia.n-gage.symbian.install": { + "source": "iana", + "extensions": ["n-gage"] + }, + "application/vnd.nokia.ncd": { + "source": "iana" + }, + "application/vnd.nokia.pcd+wbxml": { + "source": "iana" + }, + "application/vnd.nokia.pcd+xml": { + "source": "iana" + }, + "application/vnd.nokia.radio-preset": { + "source": "iana", + "extensions": ["rpst"] + }, + "application/vnd.nokia.radio-presets": { + "source": "iana", + "extensions": ["rpss"] + }, + "application/vnd.novadigm.edm": { + "source": "iana", + "extensions": ["edm"] + }, + "application/vnd.novadigm.edx": { + "source": "iana", + "extensions": ["edx"] + }, + "application/vnd.novadigm.ext": { + "source": "iana", + "extensions": ["ext"] + }, + "application/vnd.ntt-local.content-share": { + "source": "iana" + }, + "application/vnd.ntt-local.file-transfer": { + "source": "iana" + }, + "application/vnd.ntt-local.ogw_remote-access": { + "source": "iana" + }, + "application/vnd.ntt-local.sip-ta_remote": { + "source": "iana" + }, + "application/vnd.ntt-local.sip-ta_tcp_stream": { + "source": "iana" + }, + "application/vnd.oasis.opendocument.chart": { + "source": "iana", + "extensions": ["odc"] + }, + "application/vnd.oasis.opendocument.chart-template": { + "source": "iana", + "extensions": ["otc"] + }, + "application/vnd.oasis.opendocument.database": { + "source": "iana", + "extensions": ["odb"] + }, + "application/vnd.oasis.opendocument.formula": { + "source": "iana", + "extensions": ["odf"] + }, + "application/vnd.oasis.opendocument.formula-template": { + "source": "iana", + "extensions": ["odft"] + }, + "application/vnd.oasis.opendocument.graphics": { + "source": "iana", + "compressible": false, + "extensions": ["odg"] + }, + "application/vnd.oasis.opendocument.graphics-template": { + "source": "iana", + "extensions": ["otg"] + }, + "application/vnd.oasis.opendocument.image": { + "source": "iana", + "extensions": ["odi"] + }, + "application/vnd.oasis.opendocument.image-template": { + "source": "iana", + "extensions": ["oti"] + }, + "application/vnd.oasis.opendocument.presentation": { + "source": "iana", + "compressible": false, + "extensions": ["odp"] + }, + "application/vnd.oasis.opendocument.presentation-template": { + "source": "iana", + "extensions": ["otp"] + }, + "application/vnd.oasis.opendocument.spreadsheet": { + "source": "iana", + "compressible": false, + "extensions": ["ods"] + }, + "application/vnd.oasis.opendocument.spreadsheet-template": { + "source": "iana", + "extensions": ["ots"] + }, + "application/vnd.oasis.opendocument.text": { + "source": "iana", + "compressible": false, + "extensions": ["odt"] + }, + "application/vnd.oasis.opendocument.text-master": { + "source": "iana", + "extensions": ["odm"] + }, + "application/vnd.oasis.opendocument.text-template": { + "source": "iana", + "extensions": ["ott"] + }, + "application/vnd.oasis.opendocument.text-web": { + "source": "iana", + "extensions": ["oth"] + }, + "application/vnd.obn": { + "source": "iana" + }, + "application/vnd.oftn.l10n+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.oipf.contentaccessdownload+xml": { + "source": "iana" + }, + "application/vnd.oipf.contentaccessstreaming+xml": { + "source": "iana" + }, + "application/vnd.oipf.cspg-hexbinary": { + "source": "iana" + }, + "application/vnd.oipf.dae.svg+xml": { + "source": "iana" + }, + "application/vnd.oipf.dae.xhtml+xml": { + "source": "iana" + }, + "application/vnd.oipf.mippvcontrolmessage+xml": { + "source": "iana" + }, + "application/vnd.oipf.pae.gem": { + "source": "iana" + }, + "application/vnd.oipf.spdiscovery+xml": { + "source": "iana" + }, + "application/vnd.oipf.spdlist+xml": { + "source": "iana" + }, + "application/vnd.oipf.ueprofile+xml": { + "source": "iana" + }, + "application/vnd.oipf.userprofile+xml": { + "source": "iana" + }, + "application/vnd.olpc-sugar": { + "source": "iana", + "extensions": ["xo"] + }, + "application/vnd.oma-scws-config": { + "source": "iana" + }, + "application/vnd.oma-scws-http-request": { + "source": "iana" + }, + "application/vnd.oma-scws-http-response": { + "source": "iana" + }, + "application/vnd.oma.bcast.associated-procedure-parameter+xml": { + "source": "iana" + }, + "application/vnd.oma.bcast.drm-trigger+xml": { + "source": "iana" + }, + "application/vnd.oma.bcast.imd+xml": { + "source": "iana" + }, + "application/vnd.oma.bcast.ltkm": { + "source": "iana" + }, + "application/vnd.oma.bcast.notification+xml": { + "source": "iana" + }, + "application/vnd.oma.bcast.provisioningtrigger": { + "source": "iana" + }, + "application/vnd.oma.bcast.sgboot": { + "source": "iana" + }, + "application/vnd.oma.bcast.sgdd+xml": { + "source": "iana" + }, + "application/vnd.oma.bcast.sgdu": { + "source": "iana" + }, + "application/vnd.oma.bcast.simple-symbol-container": { + "source": "iana" + }, + "application/vnd.oma.bcast.smartcard-trigger+xml": { + "source": "iana" + }, + "application/vnd.oma.bcast.sprov+xml": { + "source": "iana" + }, + "application/vnd.oma.bcast.stkm": { + "source": "iana" + }, + "application/vnd.oma.cab-address-book+xml": { + "source": "iana" + }, + "application/vnd.oma.cab-feature-handler+xml": { + "source": "iana" + }, + "application/vnd.oma.cab-pcc+xml": { + "source": "iana" + }, + "application/vnd.oma.cab-subs-invite+xml": { + "source": "iana" + }, + "application/vnd.oma.cab-user-prefs+xml": { + "source": "iana" + }, + "application/vnd.oma.dcd": { + "source": "iana" + }, + "application/vnd.oma.dcdc": { + "source": "iana" + }, + "application/vnd.oma.dd2+xml": { + "source": "iana", + "extensions": ["dd2"] + }, + "application/vnd.oma.drm.risd+xml": { + "source": "iana" + }, + "application/vnd.oma.group-usage-list+xml": { + "source": "iana" + }, + "application/vnd.oma.pal+xml": { + "source": "iana" + }, + "application/vnd.oma.poc.detailed-progress-report+xml": { + "source": "iana" + }, + "application/vnd.oma.poc.final-report+xml": { + "source": "iana" + }, + "application/vnd.oma.poc.groups+xml": { + "source": "iana" + }, + "application/vnd.oma.poc.invocation-descriptor+xml": { + "source": "iana" + }, + "application/vnd.oma.poc.optimized-progress-report+xml": { + "source": "iana" + }, + "application/vnd.oma.push": { + "source": "iana" + }, + "application/vnd.oma.scidm.messages+xml": { + "source": "iana" + }, + "application/vnd.oma.xcap-directory+xml": { + "source": "iana" + }, + "application/vnd.omads-email+xml": { + "source": "iana" + }, + "application/vnd.omads-file+xml": { + "source": "iana" + }, + "application/vnd.omads-folder+xml": { + "source": "iana" + }, + "application/vnd.omaloc-supl-init": { + "source": "iana" + }, + "application/vnd.onepager": { + "source": "iana" + }, + "application/vnd.openblox.game+xml": { + "source": "iana" + }, + "application/vnd.openblox.game-binary": { + "source": "iana" + }, + "application/vnd.openeye.oeb": { + "source": "iana" + }, + "application/vnd.openofficeorg.extension": { + "source": "apache", + "extensions": ["oxt"] + }, + "application/vnd.openxmlformats-officedocument.custom-properties+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.customxmlproperties+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.drawing+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.drawingml.chart+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.drawingml.diagramcolors+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.drawingml.diagramdata+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.drawingml.diagramlayout+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.drawingml.diagramstyle+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.extended-properties+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml-template": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.commentauthors+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.comments+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.handoutmaster+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.notesmaster+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.notesslide+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.presentation": { + "source": "iana", + "compressible": false, + "extensions": ["pptx"] + }, + "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.presprops+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.slide": { + "source": "iana", + "extensions": ["sldx"] + }, + "application/vnd.openxmlformats-officedocument.presentationml.slide+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.slidelayout+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.slidemaster+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.slideshow": { + "source": "iana", + "extensions": ["ppsx"] + }, + "application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.slideupdateinfo+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.tablestyles+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.tags+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.template": { + "source": "apache", + "extensions": ["potx"] + }, + "application/vnd.openxmlformats-officedocument.presentationml.template.main+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.viewprops+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml-template": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.calcchain+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.externallink+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcachedefinition+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcacherecords+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.pivottable+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.querytable+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.revisionheaders+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.revisionlog+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedstrings+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": { + "source": "iana", + "compressible": false, + "extensions": ["xlsx"] + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheetmetadata+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.tablesinglecells+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.template": { + "source": "apache", + "extensions": ["xltx"] + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.usernames+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.volatiledependencies+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.theme+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.themeoverride+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.vmldrawing": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml-template": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.document": { + "source": "iana", + "compressible": false, + "extensions": ["docx"] + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.fonttable+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.template": { + "source": "apache", + "extensions": ["dotx"] + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.websettings+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-package.core-properties+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-package.relationships+xml": { + "source": "iana" + }, + "application/vnd.oracle.resource+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.orange.indata": { + "source": "iana" + }, + "application/vnd.osa.netdeploy": { + "source": "iana" + }, + "application/vnd.osgeo.mapguide.package": { + "source": "iana", + "extensions": ["mgp"] + }, + "application/vnd.osgi.bundle": { + "source": "iana" + }, + "application/vnd.osgi.dp": { + "source": "iana", + "extensions": ["dp"] + }, + "application/vnd.osgi.subsystem": { + "source": "iana", + "extensions": ["esa"] + }, + "application/vnd.otps.ct-kip+xml": { + "source": "iana" + }, + "application/vnd.oxli.countgraph": { + "source": "iana" + }, + "application/vnd.pagerduty+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.palm": { + "source": "iana", + "extensions": ["pdb","pqa","oprc"] + }, + "application/vnd.panoply": { + "source": "iana" + }, + "application/vnd.paos+xml": { + "source": "iana" + }, + "application/vnd.paos.xml": { + "source": "apache" + }, + "application/vnd.pawaafile": { + "source": "iana", + "extensions": ["paw"] + }, + "application/vnd.pcos": { + "source": "iana" + }, + "application/vnd.pg.format": { + "source": "iana", + "extensions": ["str"] + }, + "application/vnd.pg.osasli": { + "source": "iana", + "extensions": ["ei6"] + }, + "application/vnd.piaccess.application-licence": { + "source": "iana" + }, + "application/vnd.picsel": { + "source": "iana", + "extensions": ["efif"] + }, + "application/vnd.pmi.widget": { + "source": "iana", + "extensions": ["wg"] + }, + "application/vnd.poc.group-advertisement+xml": { + "source": "iana" + }, + "application/vnd.pocketlearn": { + "source": "iana", + "extensions": ["plf"] + }, + "application/vnd.powerbuilder6": { + "source": "iana", + "extensions": ["pbd"] + }, + "application/vnd.powerbuilder6-s": { + "source": "iana" + }, + "application/vnd.powerbuilder7": { + "source": "iana" + }, + "application/vnd.powerbuilder7-s": { + "source": "iana" + }, + "application/vnd.powerbuilder75": { + "source": "iana" + }, + "application/vnd.powerbuilder75-s": { + "source": "iana" + }, + "application/vnd.preminet": { + "source": "iana" + }, + "application/vnd.previewsystems.box": { + "source": "iana", + "extensions": ["box"] + }, + "application/vnd.proteus.magazine": { + "source": "iana", + "extensions": ["mgz"] + }, + "application/vnd.publishare-delta-tree": { + "source": "iana", + "extensions": ["qps"] + }, + "application/vnd.pvi.ptid1": { + "source": "iana", + "extensions": ["ptid"] + }, + "application/vnd.pwg-multiplexed": { + "source": "iana" + }, + "application/vnd.pwg-xhtml-print+xml": { + "source": "iana" + }, + "application/vnd.qualcomm.brew-app-res": { + "source": "iana" + }, + "application/vnd.quark.quarkxpress": { + "source": "iana", + "extensions": ["qxd","qxt","qwd","qwt","qxl","qxb"] + }, + "application/vnd.quobject-quoxdocument": { + "source": "iana" + }, + "application/vnd.radisys.moml+xml": { + "source": "iana" + }, + "application/vnd.radisys.msml+xml": { + "source": "iana" + }, + "application/vnd.radisys.msml-audit+xml": { + "source": "iana" + }, + "application/vnd.radisys.msml-audit-conf+xml": { + "source": "iana" + }, + "application/vnd.radisys.msml-audit-conn+xml": { + "source": "iana" + }, + "application/vnd.radisys.msml-audit-dialog+xml": { + "source": "iana" + }, + "application/vnd.radisys.msml-audit-stream+xml": { + "source": "iana" + }, + "application/vnd.radisys.msml-conf+xml": { + "source": "iana" + }, + "application/vnd.radisys.msml-dialog+xml": { + "source": "iana" + }, + "application/vnd.radisys.msml-dialog-base+xml": { + "source": "iana" + }, + "application/vnd.radisys.msml-dialog-fax-detect+xml": { + "source": "iana" + }, + "application/vnd.radisys.msml-dialog-fax-sendrecv+xml": { + "source": "iana" + }, + "application/vnd.radisys.msml-dialog-group+xml": { + "source": "iana" + }, + "application/vnd.radisys.msml-dialog-speech+xml": { + "source": "iana" + }, + "application/vnd.radisys.msml-dialog-transform+xml": { + "source": "iana" + }, + "application/vnd.rainstor.data": { + "source": "iana" + }, + "application/vnd.rapid": { + "source": "iana" + }, + "application/vnd.realvnc.bed": { + "source": "iana", + "extensions": ["bed"] + }, + "application/vnd.recordare.musicxml": { + "source": "iana", + "extensions": ["mxl"] + }, + "application/vnd.recordare.musicxml+xml": { + "source": "iana", + "extensions": ["musicxml"] + }, + "application/vnd.renlearn.rlprint": { + "source": "iana" + }, + "application/vnd.rig.cryptonote": { + "source": "iana", + "extensions": ["cryptonote"] + }, + "application/vnd.rim.cod": { + "source": "apache", + "extensions": ["cod"] + }, + "application/vnd.rn-realmedia": { + "source": "apache", + "extensions": ["rm"] + }, + "application/vnd.rn-realmedia-vbr": { + "source": "apache", + "extensions": ["rmvb"] + }, + "application/vnd.route66.link66+xml": { + "source": "iana", + "extensions": ["link66"] + }, + "application/vnd.rs-274x": { + "source": "iana" + }, + "application/vnd.ruckus.download": { + "source": "iana" + }, + "application/vnd.s3sms": { + "source": "iana" + }, + "application/vnd.sailingtracker.track": { + "source": "iana", + "extensions": ["st"] + }, + "application/vnd.sbm.cid": { + "source": "iana" + }, + "application/vnd.sbm.mid2": { + "source": "iana" + }, + "application/vnd.scribus": { + "source": "iana" + }, + "application/vnd.sealed.3df": { + "source": "iana" + }, + "application/vnd.sealed.csf": { + "source": "iana" + }, + "application/vnd.sealed.doc": { + "source": "iana" + }, + "application/vnd.sealed.eml": { + "source": "iana" + }, + "application/vnd.sealed.mht": { + "source": "iana" + }, + "application/vnd.sealed.net": { + "source": "iana" + }, + "application/vnd.sealed.ppt": { + "source": "iana" + }, + "application/vnd.sealed.tiff": { + "source": "iana" + }, + "application/vnd.sealed.xls": { + "source": "iana" + }, + "application/vnd.sealedmedia.softseal.html": { + "source": "iana" + }, + "application/vnd.sealedmedia.softseal.pdf": { + "source": "iana" + }, + "application/vnd.seemail": { + "source": "iana", + "extensions": ["see"] + }, + "application/vnd.sema": { + "source": "iana", + "extensions": ["sema"] + }, + "application/vnd.semd": { + "source": "iana", + "extensions": ["semd"] + }, + "application/vnd.semf": { + "source": "iana", + "extensions": ["semf"] + }, + "application/vnd.shana.informed.formdata": { + "source": "iana", + "extensions": ["ifm"] + }, + "application/vnd.shana.informed.formtemplate": { + "source": "iana", + "extensions": ["itp"] + }, + "application/vnd.shana.informed.interchange": { + "source": "iana", + "extensions": ["iif"] + }, + "application/vnd.shana.informed.package": { + "source": "iana", + "extensions": ["ipk"] + }, + "application/vnd.simtech-mindmapper": { + "source": "iana", + "extensions": ["twd","twds"] + }, + "application/vnd.siren+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.smaf": { + "source": "iana", + "extensions": ["mmf"] + }, + "application/vnd.smart.notebook": { + "source": "iana" + }, + "application/vnd.smart.teacher": { + "source": "iana", + "extensions": ["teacher"] + }, + "application/vnd.software602.filler.form+xml": { + "source": "iana" + }, + "application/vnd.software602.filler.form-xml-zip": { + "source": "iana" + }, + "application/vnd.solent.sdkm+xml": { + "source": "iana", + "extensions": ["sdkm","sdkd"] + }, + "application/vnd.spotfire.dxp": { + "source": "iana", + "extensions": ["dxp"] + }, + "application/vnd.spotfire.sfs": { + "source": "iana", + "extensions": ["sfs"] + }, + "application/vnd.sss-cod": { + "source": "iana" + }, + "application/vnd.sss-dtf": { + "source": "iana" + }, + "application/vnd.sss-ntf": { + "source": "iana" + }, + "application/vnd.stardivision.calc": { + "source": "apache", + "extensions": ["sdc"] + }, + "application/vnd.stardivision.draw": { + "source": "apache", + "extensions": ["sda"] + }, + "application/vnd.stardivision.impress": { + "source": "apache", + "extensions": ["sdd"] + }, + "application/vnd.stardivision.math": { + "source": "apache", + "extensions": ["smf"] + }, + "application/vnd.stardivision.writer": { + "source": "apache", + "extensions": ["sdw","vor"] + }, + "application/vnd.stardivision.writer-global": { + "source": "apache", + "extensions": ["sgl"] + }, + "application/vnd.stepmania.package": { + "source": "iana", + "extensions": ["smzip"] + }, + "application/vnd.stepmania.stepchart": { + "source": "iana", + "extensions": ["sm"] + }, + "application/vnd.street-stream": { + "source": "iana" + }, + "application/vnd.sun.wadl+xml": { + "source": "iana" + }, + "application/vnd.sun.xml.calc": { + "source": "apache", + "extensions": ["sxc"] + }, + "application/vnd.sun.xml.calc.template": { + "source": "apache", + "extensions": ["stc"] + }, + "application/vnd.sun.xml.draw": { + "source": "apache", + "extensions": ["sxd"] + }, + "application/vnd.sun.xml.draw.template": { + "source": "apache", + "extensions": ["std"] + }, + "application/vnd.sun.xml.impress": { + "source": "apache", + "extensions": ["sxi"] + }, + "application/vnd.sun.xml.impress.template": { + "source": "apache", + "extensions": ["sti"] + }, + "application/vnd.sun.xml.math": { + "source": "apache", + "extensions": ["sxm"] + }, + "application/vnd.sun.xml.writer": { + "source": "apache", + "extensions": ["sxw"] + }, + "application/vnd.sun.xml.writer.global": { + "source": "apache", + "extensions": ["sxg"] + }, + "application/vnd.sun.xml.writer.template": { + "source": "apache", + "extensions": ["stw"] + }, + "application/vnd.sus-calendar": { + "source": "iana", + "extensions": ["sus","susp"] + }, + "application/vnd.svd": { + "source": "iana", + "extensions": ["svd"] + }, + "application/vnd.swiftview-ics": { + "source": "iana" + }, + "application/vnd.symbian.install": { + "source": "apache", + "extensions": ["sis","sisx"] + }, + "application/vnd.syncml+xml": { + "source": "iana", + "extensions": ["xsm"] + }, + "application/vnd.syncml.dm+wbxml": { + "source": "iana", + "extensions": ["bdm"] + }, + "application/vnd.syncml.dm+xml": { + "source": "iana", + "extensions": ["xdm"] + }, + "application/vnd.syncml.dm.notification": { + "source": "iana" + }, + "application/vnd.syncml.dmddf+wbxml": { + "source": "iana" + }, + "application/vnd.syncml.dmddf+xml": { + "source": "iana" + }, + "application/vnd.syncml.dmtnds+wbxml": { + "source": "iana" + }, + "application/vnd.syncml.dmtnds+xml": { + "source": "iana" + }, + "application/vnd.syncml.ds.notification": { + "source": "iana" + }, + "application/vnd.tao.intent-module-archive": { + "source": "iana", + "extensions": ["tao"] + }, + "application/vnd.tcpdump.pcap": { + "source": "iana", + "extensions": ["pcap","cap","dmp"] + }, + "application/vnd.tmd.mediaflex.api+xml": { + "source": "iana" + }, + "application/vnd.tml": { + "source": "iana" + }, + "application/vnd.tmobile-livetv": { + "source": "iana", + "extensions": ["tmo"] + }, + "application/vnd.trid.tpt": { + "source": "iana", + "extensions": ["tpt"] + }, + "application/vnd.triscape.mxs": { + "source": "iana", + "extensions": ["mxs"] + }, + "application/vnd.trueapp": { + "source": "iana", + "extensions": ["tra"] + }, + "application/vnd.truedoc": { + "source": "iana" + }, + "application/vnd.ubisoft.webplayer": { + "source": "iana" + }, + "application/vnd.ufdl": { + "source": "iana", + "extensions": ["ufd","ufdl"] + }, + "application/vnd.uiq.theme": { + "source": "iana", + "extensions": ["utz"] + }, + "application/vnd.umajin": { + "source": "iana", + "extensions": ["umj"] + }, + "application/vnd.unity": { + "source": "iana", + "extensions": ["unityweb"] + }, + "application/vnd.uoml+xml": { + "source": "iana", + "extensions": ["uoml"] + }, + "application/vnd.uplanet.alert": { + "source": "iana" + }, + "application/vnd.uplanet.alert-wbxml": { + "source": "iana" + }, + "application/vnd.uplanet.bearer-choice": { + "source": "iana" + }, + "application/vnd.uplanet.bearer-choice-wbxml": { + "source": "iana" + }, + "application/vnd.uplanet.cacheop": { + "source": "iana" + }, + "application/vnd.uplanet.cacheop-wbxml": { + "source": "iana" + }, + "application/vnd.uplanet.channel": { + "source": "iana" + }, + "application/vnd.uplanet.channel-wbxml": { + "source": "iana" + }, + "application/vnd.uplanet.list": { + "source": "iana" + }, + "application/vnd.uplanet.list-wbxml": { + "source": "iana" + }, + "application/vnd.uplanet.listcmd": { + "source": "iana" + }, + "application/vnd.uplanet.listcmd-wbxml": { + "source": "iana" + }, + "application/vnd.uplanet.signal": { + "source": "iana" + }, + "application/vnd.uri-map": { + "source": "iana" + }, + "application/vnd.valve.source.material": { + "source": "iana" + }, + "application/vnd.vcx": { + "source": "iana", + "extensions": ["vcx"] + }, + "application/vnd.vd-study": { + "source": "iana" + }, + "application/vnd.vectorworks": { + "source": "iana" + }, + "application/vnd.vel+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.verimatrix.vcas": { + "source": "iana" + }, + "application/vnd.vidsoft.vidconference": { + "source": "iana" + }, + "application/vnd.visio": { + "source": "iana", + "extensions": ["vsd","vst","vss","vsw"] + }, + "application/vnd.visionary": { + "source": "iana", + "extensions": ["vis"] + }, + "application/vnd.vividence.scriptfile": { + "source": "iana" + }, + "application/vnd.vsf": { + "source": "iana", + "extensions": ["vsf"] + }, + "application/vnd.wap.sic": { + "source": "iana" + }, + "application/vnd.wap.slc": { + "source": "iana" + }, + "application/vnd.wap.wbxml": { + "source": "iana", + "extensions": ["wbxml"] + }, + "application/vnd.wap.wmlc": { + "source": "iana", + "extensions": ["wmlc"] + }, + "application/vnd.wap.wmlscriptc": { + "source": "iana", + "extensions": ["wmlsc"] + }, + "application/vnd.webturbo": { + "source": "iana", + "extensions": ["wtb"] + }, + "application/vnd.wfa.p2p": { + "source": "iana" + }, + "application/vnd.wfa.wsc": { + "source": "iana" + }, + "application/vnd.windows.devicepairing": { + "source": "iana" + }, + "application/vnd.wmc": { + "source": "iana" + }, + "application/vnd.wmf.bootstrap": { + "source": "iana" + }, + "application/vnd.wolfram.mathematica": { + "source": "iana" + }, + "application/vnd.wolfram.mathematica.package": { + "source": "iana" + }, + "application/vnd.wolfram.player": { + "source": "iana", + "extensions": ["nbp"] + }, + "application/vnd.wordperfect": { + "source": "iana", + "extensions": ["wpd"] + }, + "application/vnd.wqd": { + "source": "iana", + "extensions": ["wqd"] + }, + "application/vnd.wrq-hp3000-labelled": { + "source": "iana" + }, + "application/vnd.wt.stf": { + "source": "iana", + "extensions": ["stf"] + }, + "application/vnd.wv.csp+wbxml": { + "source": "iana" + }, + "application/vnd.wv.csp+xml": { + "source": "iana" + }, + "application/vnd.wv.ssp+xml": { + "source": "iana" + }, + "application/vnd.xacml+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.xara": { + "source": "iana", + "extensions": ["xar"] + }, + "application/vnd.xfdl": { + "source": "iana", + "extensions": ["xfdl"] + }, + "application/vnd.xfdl.webform": { + "source": "iana" + }, + "application/vnd.xmi+xml": { + "source": "iana" + }, + "application/vnd.xmpie.cpkg": { + "source": "iana" + }, + "application/vnd.xmpie.dpkg": { + "source": "iana" + }, + "application/vnd.xmpie.plan": { + "source": "iana" + }, + "application/vnd.xmpie.ppkg": { + "source": "iana" + }, + "application/vnd.xmpie.xlim": { + "source": "iana" + }, + "application/vnd.yamaha.hv-dic": { + "source": "iana", + "extensions": ["hvd"] + }, + "application/vnd.yamaha.hv-script": { + "source": "iana", + "extensions": ["hvs"] + }, + "application/vnd.yamaha.hv-voice": { + "source": "iana", + "extensions": ["hvp"] + }, + "application/vnd.yamaha.openscoreformat": { + "source": "iana", + "extensions": ["osf"] + }, + "application/vnd.yamaha.openscoreformat.osfpvg+xml": { + "source": "iana", + "extensions": ["osfpvg"] + }, + "application/vnd.yamaha.remote-setup": { + "source": "iana" + }, + "application/vnd.yamaha.smaf-audio": { + "source": "iana", + "extensions": ["saf"] + }, + "application/vnd.yamaha.smaf-phrase": { + "source": "iana", + "extensions": ["spf"] + }, + "application/vnd.yamaha.through-ngn": { + "source": "iana" + }, + "application/vnd.yamaha.tunnel-udpencap": { + "source": "iana" + }, + "application/vnd.yaoweme": { + "source": "iana" + }, + "application/vnd.yellowriver-custom-menu": { + "source": "iana", + "extensions": ["cmp"] + }, + "application/vnd.zul": { + "source": "iana", + "extensions": ["zir","zirz"] + }, + "application/vnd.zzazz.deck+xml": { + "source": "iana", + "extensions": ["zaz"] + }, + "application/voicexml+xml": { + "source": "iana", + "extensions": ["vxml"] + }, + "application/vq-rtcpxr": { + "source": "iana" + }, + "application/watcherinfo+xml": { + "source": "iana" + }, + "application/whoispp-query": { + "source": "iana" + }, + "application/whoispp-response": { + "source": "iana" + }, + "application/widget": { + "source": "iana", + "extensions": ["wgt"] + }, + "application/winhlp": { + "source": "apache", + "extensions": ["hlp"] + }, + "application/wita": { + "source": "iana" + }, + "application/wordperfect5.1": { + "source": "iana" + }, + "application/wsdl+xml": { + "source": "iana", + "extensions": ["wsdl"] + }, + "application/wspolicy+xml": { + "source": "iana", + "extensions": ["wspolicy"] + }, + "application/x-7z-compressed": { + "source": "apache", + "compressible": false, + "extensions": ["7z"] + }, + "application/x-abiword": { + "source": "apache", + "extensions": ["abw"] + }, + "application/x-ace-compressed": { + "source": "apache", + "extensions": ["ace"] + }, + "application/x-amf": { + "source": "apache" + }, + "application/x-apple-diskimage": { + "source": "apache", + "extensions": ["dmg"] + }, + "application/x-authorware-bin": { + "source": "apache", + "extensions": ["aab","x32","u32","vox"] + }, + "application/x-authorware-map": { + "source": "apache", + "extensions": ["aam"] + }, + "application/x-authorware-seg": { + "source": "apache", + "extensions": ["aas"] + }, + "application/x-bcpio": { + "source": "apache", + "extensions": ["bcpio"] + }, + "application/x-bdoc": { + "compressible": false, + "extensions": ["bdoc"] + }, + "application/x-bittorrent": { + "source": "apache", + "extensions": ["torrent"] + }, + "application/x-blorb": { + "source": "apache", + "extensions": ["blb","blorb"] + }, + "application/x-bzip": { + "source": "apache", + "compressible": false, + "extensions": ["bz"] + }, + "application/x-bzip2": { + "source": "apache", + "compressible": false, + "extensions": ["bz2","boz"] + }, + "application/x-cbr": { + "source": "apache", + "extensions": ["cbr","cba","cbt","cbz","cb7"] + }, + "application/x-cdlink": { + "source": "apache", + "extensions": ["vcd"] + }, + "application/x-cfs-compressed": { + "source": "apache", + "extensions": ["cfs"] + }, + "application/x-chat": { + "source": "apache", + "extensions": ["chat"] + }, + "application/x-chess-pgn": { + "source": "apache", + "extensions": ["pgn"] + }, + "application/x-chrome-extension": { + "extensions": ["crx"] + }, + "application/x-cocoa": { + "source": "nginx", + "extensions": ["cco"] + }, + "application/x-compress": { + "source": "apache" + }, + "application/x-conference": { + "source": "apache", + "extensions": ["nsc"] + }, + "application/x-cpio": { + "source": "apache", + "extensions": ["cpio"] + }, + "application/x-csh": { + "source": "apache", + "extensions": ["csh"] + }, + "application/x-deb": { + "compressible": false + }, + "application/x-debian-package": { + "source": "apache", + "extensions": ["deb","udeb"] + }, + "application/x-dgc-compressed": { + "source": "apache", + "extensions": ["dgc"] + }, + "application/x-director": { + "source": "apache", + "extensions": ["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"] + }, + "application/x-doom": { + "source": "apache", + "extensions": ["wad"] + }, + "application/x-dtbncx+xml": { + "source": "apache", + "extensions": ["ncx"] + }, + "application/x-dtbook+xml": { + "source": "apache", + "extensions": ["dtb"] + }, + "application/x-dtbresource+xml": { + "source": "apache", + "extensions": ["res"] + }, + "application/x-dvi": { + "source": "apache", + "compressible": false, + "extensions": ["dvi"] + }, + "application/x-envoy": { + "source": "apache", + "extensions": ["evy"] + }, + "application/x-eva": { + "source": "apache", + "extensions": ["eva"] + }, + "application/x-font-bdf": { + "source": "apache", + "extensions": ["bdf"] + }, + "application/x-font-dos": { + "source": "apache" + }, + "application/x-font-framemaker": { + "source": "apache" + }, + "application/x-font-ghostscript": { + "source": "apache", + "extensions": ["gsf"] + }, + "application/x-font-libgrx": { + "source": "apache" + }, + "application/x-font-linux-psf": { + "source": "apache", + "extensions": ["psf"] + }, + "application/x-font-otf": { + "source": "apache", + "compressible": true, + "extensions": ["otf"] + }, + "application/x-font-pcf": { + "source": "apache", + "extensions": ["pcf"] + }, + "application/x-font-snf": { + "source": "apache", + "extensions": ["snf"] + }, + "application/x-font-speedo": { + "source": "apache" + }, + "application/x-font-sunos-news": { + "source": "apache" + }, + "application/x-font-ttf": { + "source": "apache", + "compressible": true, + "extensions": ["ttf","ttc"] + }, + "application/x-font-type1": { + "source": "apache", + "extensions": ["pfa","pfb","pfm","afm"] + }, + "application/x-font-vfont": { + "source": "apache" + }, + "application/x-freearc": { + "source": "apache", + "extensions": ["arc"] + }, + "application/x-futuresplash": { + "source": "apache", + "extensions": ["spl"] + }, + "application/x-gca-compressed": { + "source": "apache", + "extensions": ["gca"] + }, + "application/x-glulx": { + "source": "apache", + "extensions": ["ulx"] + }, + "application/x-gnumeric": { + "source": "apache", + "extensions": ["gnumeric"] + }, + "application/x-gramps-xml": { + "source": "apache", + "extensions": ["gramps"] + }, + "application/x-gtar": { + "source": "apache", + "extensions": ["gtar"] + }, + "application/x-gzip": { + "source": "apache" + }, + "application/x-hdf": { + "source": "apache", + "extensions": ["hdf"] + }, + "application/x-httpd-php": { + "compressible": true, + "extensions": ["php"] + }, + "application/x-install-instructions": { + "source": "apache", + "extensions": ["install"] + }, + "application/x-iso9660-image": { + "source": "apache", + "extensions": ["iso"] + }, + "application/x-java-archive-diff": { + "source": "nginx", + "extensions": ["jardiff"] + }, + "application/x-java-jnlp-file": { + "source": "apache", + "compressible": false, + "extensions": ["jnlp"] + }, + "application/x-javascript": { + "compressible": true + }, + "application/x-latex": { + "source": "apache", + "compressible": false, + "extensions": ["latex"] + }, + "application/x-lua-bytecode": { + "extensions": ["luac"] + }, + "application/x-lzh-compressed": { + "source": "apache", + "extensions": ["lzh","lha"] + }, + "application/x-makeself": { + "source": "nginx", + "extensions": ["run"] + }, + "application/x-mie": { + "source": "apache", + "extensions": ["mie"] + }, + "application/x-mobipocket-ebook": { + "source": "apache", + "extensions": ["prc","mobi"] + }, + "application/x-mpegurl": { + "compressible": false + }, + "application/x-ms-application": { + "source": "apache", + "extensions": ["application"] + }, + "application/x-ms-shortcut": { + "source": "apache", + "extensions": ["lnk"] + }, + "application/x-ms-wmd": { + "source": "apache", + "extensions": ["wmd"] + }, + "application/x-ms-wmz": { + "source": "apache", + "extensions": ["wmz"] + }, + "application/x-ms-xbap": { + "source": "apache", + "extensions": ["xbap"] + }, + "application/x-msaccess": { + "source": "apache", + "extensions": ["mdb"] + }, + "application/x-msbinder": { + "source": "apache", + "extensions": ["obd"] + }, + "application/x-mscardfile": { + "source": "apache", + "extensions": ["crd"] + }, + "application/x-msclip": { + "source": "apache", + "extensions": ["clp"] + }, + "application/x-msdos-program": { + "extensions": ["exe"] + }, + "application/x-msdownload": { + "source": "apache", + "extensions": ["exe","dll","com","bat","msi"] + }, + "application/x-msmediaview": { + "source": "apache", + "extensions": ["mvb","m13","m14"] + }, + "application/x-msmetafile": { + "source": "apache", + "extensions": ["wmf","wmz","emf","emz"] + }, + "application/x-msmoney": { + "source": "apache", + "extensions": ["mny"] + }, + "application/x-mspublisher": { + "source": "apache", + "extensions": ["pub"] + }, + "application/x-msschedule": { + "source": "apache", + "extensions": ["scd"] + }, + "application/x-msterminal": { + "source": "apache", + "extensions": ["trm"] + }, + "application/x-mswrite": { + "source": "apache", + "extensions": ["wri"] + }, + "application/x-netcdf": { + "source": "apache", + "extensions": ["nc","cdf"] + }, + "application/x-ns-proxy-autoconfig": { + "compressible": true, + "extensions": ["pac"] + }, + "application/x-nzb": { + "source": "apache", + "extensions": ["nzb"] + }, + "application/x-perl": { + "source": "nginx", + "extensions": ["pl","pm"] + }, + "application/x-pilot": { + "source": "nginx", + "extensions": ["prc","pdb"] + }, + "application/x-pkcs12": { + "source": "apache", + "compressible": false, + "extensions": ["p12","pfx"] + }, + "application/x-pkcs7-certificates": { + "source": "apache", + "extensions": ["p7b","spc"] + }, + "application/x-pkcs7-certreqresp": { + "source": "apache", + "extensions": ["p7r"] + }, + "application/x-rar-compressed": { + "source": "apache", + "compressible": false, + "extensions": ["rar"] + }, + "application/x-redhat-package-manager": { + "source": "nginx", + "extensions": ["rpm"] + }, + "application/x-research-info-systems": { + "source": "apache", + "extensions": ["ris"] + }, + "application/x-sea": { + "source": "nginx", + "extensions": ["sea"] + }, + "application/x-sh": { + "source": "apache", + "compressible": true, + "extensions": ["sh"] + }, + "application/x-shar": { + "source": "apache", + "extensions": ["shar"] + }, + "application/x-shockwave-flash": { + "source": "apache", + "compressible": false, + "extensions": ["swf"] + }, + "application/x-silverlight-app": { + "source": "apache", + "extensions": ["xap"] + }, + "application/x-sql": { + "source": "apache", + "extensions": ["sql"] + }, + "application/x-stuffit": { + "source": "apache", + "compressible": false, + "extensions": ["sit"] + }, + "application/x-stuffitx": { + "source": "apache", + "extensions": ["sitx"] + }, + "application/x-subrip": { + "source": "apache", + "extensions": ["srt"] + }, + "application/x-sv4cpio": { + "source": "apache", + "extensions": ["sv4cpio"] + }, + "application/x-sv4crc": { + "source": "apache", + "extensions": ["sv4crc"] + }, + "application/x-t3vm-image": { + "source": "apache", + "extensions": ["t3"] + }, + "application/x-tads": { + "source": "apache", + "extensions": ["gam"] + }, + "application/x-tar": { + "source": "apache", + "compressible": true, + "extensions": ["tar"] + }, + "application/x-tcl": { + "source": "apache", + "extensions": ["tcl","tk"] + }, + "application/x-tex": { + "source": "apache", + "extensions": ["tex"] + }, + "application/x-tex-tfm": { + "source": "apache", + "extensions": ["tfm"] + }, + "application/x-texinfo": { + "source": "apache", + "extensions": ["texinfo","texi"] + }, + "application/x-tgif": { + "source": "apache", + "extensions": ["obj"] + }, + "application/x-ustar": { + "source": "apache", + "extensions": ["ustar"] + }, + "application/x-wais-source": { + "source": "apache", + "extensions": ["src"] + }, + "application/x-web-app-manifest+json": { + "compressible": true, + "extensions": ["webapp"] + }, + "application/x-www-form-urlencoded": { + "source": "iana", + "compressible": true + }, + "application/x-x509-ca-cert": { + "source": "apache", + "extensions": ["der","crt","pem"] + }, + "application/x-xfig": { + "source": "apache", + "extensions": ["fig"] + }, + "application/x-xliff+xml": { + "source": "apache", + "extensions": ["xlf"] + }, + "application/x-xpinstall": { + "source": "apache", + "compressible": false, + "extensions": ["xpi"] + }, + "application/x-xz": { + "source": "apache", + "extensions": ["xz"] + }, + "application/x-zmachine": { + "source": "apache", + "extensions": ["z1","z2","z3","z4","z5","z6","z7","z8"] + }, + "application/x400-bp": { + "source": "iana" + }, + "application/xacml+xml": { + "source": "iana" + }, + "application/xaml+xml": { + "source": "apache", + "extensions": ["xaml"] + }, + "application/xcap-att+xml": { + "source": "iana" + }, + "application/xcap-caps+xml": { + "source": "iana" + }, + "application/xcap-diff+xml": { + "source": "iana", + "extensions": ["xdf"] + }, + "application/xcap-el+xml": { + "source": "iana" + }, + "application/xcap-error+xml": { + "source": "iana" + }, + "application/xcap-ns+xml": { + "source": "iana" + }, + "application/xcon-conference-info+xml": { + "source": "iana" + }, + "application/xcon-conference-info-diff+xml": { + "source": "iana" + }, + "application/xenc+xml": { + "source": "iana", + "extensions": ["xenc"] + }, + "application/xhtml+xml": { + "source": "iana", + "compressible": true, + "extensions": ["xhtml","xht"] + }, + "application/xhtml-voice+xml": { + "source": "apache" + }, + "application/xml": { + "source": "iana", + "compressible": true, + "extensions": ["xml","xsl","xsd","rng"] + }, + "application/xml-dtd": { + "source": "iana", + "compressible": true, + "extensions": ["dtd"] + }, + "application/xml-external-parsed-entity": { + "source": "iana" + }, + "application/xml-patch+xml": { + "source": "iana" + }, + "application/xmpp+xml": { + "source": "iana" + }, + "application/xop+xml": { + "source": "iana", + "compressible": true, + "extensions": ["xop"] + }, + "application/xproc+xml": { + "source": "apache", + "extensions": ["xpl"] + }, + "application/xslt+xml": { + "source": "iana", + "extensions": ["xslt"] + }, + "application/xspf+xml": { + "source": "apache", + "extensions": ["xspf"] + }, + "application/xv+xml": { + "source": "iana", + "extensions": ["mxml","xhvml","xvml","xvm"] + }, + "application/yang": { + "source": "iana", + "extensions": ["yang"] + }, + "application/yin+xml": { + "source": "iana", + "extensions": ["yin"] + }, + "application/zip": { + "source": "iana", + "compressible": false, + "extensions": ["zip"] + }, + "application/zlib": { + "source": "iana" + }, + "audio/1d-interleaved-parityfec": { + "source": "iana" + }, + "audio/32kadpcm": { + "source": "iana" + }, + "audio/3gpp": { + "source": "iana", + "compressible": false, + "extensions": ["3gpp"] + }, + "audio/3gpp2": { + "source": "iana" + }, + "audio/ac3": { + "source": "iana" + }, + "audio/adpcm": { + "source": "apache", + "extensions": ["adp"] + }, + "audio/amr": { + "source": "iana" + }, + "audio/amr-wb": { + "source": "iana" + }, + "audio/amr-wb+": { + "source": "iana" + }, + "audio/aptx": { + "source": "iana" + }, + "audio/asc": { + "source": "iana" + }, + "audio/atrac-advanced-lossless": { + "source": "iana" + }, + "audio/atrac-x": { + "source": "iana" + }, + "audio/atrac3": { + "source": "iana" + }, + "audio/basic": { + "source": "iana", + "compressible": false, + "extensions": ["au","snd"] + }, + "audio/bv16": { + "source": "iana" + }, + "audio/bv32": { + "source": "iana" + }, + "audio/clearmode": { + "source": "iana" + }, + "audio/cn": { + "source": "iana" + }, + "audio/dat12": { + "source": "iana" + }, + "audio/dls": { + "source": "iana" + }, + "audio/dsr-es201108": { + "source": "iana" + }, + "audio/dsr-es202050": { + "source": "iana" + }, + "audio/dsr-es202211": { + "source": "iana" + }, + "audio/dsr-es202212": { + "source": "iana" + }, + "audio/dv": { + "source": "iana" + }, + "audio/dvi4": { + "source": "iana" + }, + "audio/eac3": { + "source": "iana" + }, + "audio/encaprtp": { + "source": "iana" + }, + "audio/evrc": { + "source": "iana" + }, + "audio/evrc-qcp": { + "source": "iana" + }, + "audio/evrc0": { + "source": "iana" + }, + "audio/evrc1": { + "source": "iana" + }, + "audio/evrcb": { + "source": "iana" + }, + "audio/evrcb0": { + "source": "iana" + }, + "audio/evrcb1": { + "source": "iana" + }, + "audio/evrcnw": { + "source": "iana" + }, + "audio/evrcnw0": { + "source": "iana" + }, + "audio/evrcnw1": { + "source": "iana" + }, + "audio/evrcwb": { + "source": "iana" + }, + "audio/evrcwb0": { + "source": "iana" + }, + "audio/evrcwb1": { + "source": "iana" + }, + "audio/evs": { + "source": "iana" + }, + "audio/fwdred": { + "source": "iana" + }, + "audio/g711-0": { + "source": "iana" + }, + "audio/g719": { + "source": "iana" + }, + "audio/g722": { + "source": "iana" + }, + "audio/g7221": { + "source": "iana" + }, + "audio/g723": { + "source": "iana" + }, + "audio/g726-16": { + "source": "iana" + }, + "audio/g726-24": { + "source": "iana" + }, + "audio/g726-32": { + "source": "iana" + }, + "audio/g726-40": { + "source": "iana" + }, + "audio/g728": { + "source": "iana" + }, + "audio/g729": { + "source": "iana" + }, + "audio/g7291": { + "source": "iana" + }, + "audio/g729d": { + "source": "iana" + }, + "audio/g729e": { + "source": "iana" + }, + "audio/gsm": { + "source": "iana" + }, + "audio/gsm-efr": { + "source": "iana" + }, + "audio/gsm-hr-08": { + "source": "iana" + }, + "audio/ilbc": { + "source": "iana" + }, + "audio/ip-mr_v2.5": { + "source": "iana" + }, + "audio/isac": { + "source": "apache" + }, + "audio/l16": { + "source": "iana" + }, + "audio/l20": { + "source": "iana" + }, + "audio/l24": { + "source": "iana", + "compressible": false + }, + "audio/l8": { + "source": "iana" + }, + "audio/lpc": { + "source": "iana" + }, + "audio/midi": { + "source": "apache", + "extensions": ["mid","midi","kar","rmi"] + }, + "audio/mobile-xmf": { + "source": "iana" + }, + "audio/mp4": { + "source": "iana", + "compressible": false, + "extensions": ["m4a","mp4a"] + }, + "audio/mp4a-latm": { + "source": "iana" + }, + "audio/mpa": { + "source": "iana" + }, + "audio/mpa-robust": { + "source": "iana" + }, + "audio/mpeg": { + "source": "iana", + "compressible": false, + "extensions": ["mpga","mp2","mp2a","mp3","m2a","m3a"] + }, + "audio/mpeg4-generic": { + "source": "iana" + }, + "audio/musepack": { + "source": "apache" + }, + "audio/ogg": { + "source": "iana", + "compressible": false, + "extensions": ["oga","ogg","spx"] + }, + "audio/opus": { + "source": "iana" + }, + "audio/parityfec": { + "source": "iana" + }, + "audio/pcma": { + "source": "iana" + }, + "audio/pcma-wb": { + "source": "iana" + }, + "audio/pcmu": { + "source": "iana" + }, + "audio/pcmu-wb": { + "source": "iana" + }, + "audio/prs.sid": { + "source": "iana" + }, + "audio/qcelp": { + "source": "iana" + }, + "audio/raptorfec": { + "source": "iana" + }, + "audio/red": { + "source": "iana" + }, + "audio/rtp-enc-aescm128": { + "source": "iana" + }, + "audio/rtp-midi": { + "source": "iana" + }, + "audio/rtploopback": { + "source": "iana" + }, + "audio/rtx": { + "source": "iana" + }, + "audio/s3m": { + "source": "apache", + "extensions": ["s3m"] + }, + "audio/silk": { + "source": "apache", + "extensions": ["sil"] + }, + "audio/smv": { + "source": "iana" + }, + "audio/smv-qcp": { + "source": "iana" + }, + "audio/smv0": { + "source": "iana" + }, + "audio/sp-midi": { + "source": "iana" + }, + "audio/speex": { + "source": "iana" + }, + "audio/t140c": { + "source": "iana" + }, + "audio/t38": { + "source": "iana" + }, + "audio/telephone-event": { + "source": "iana" + }, + "audio/tone": { + "source": "iana" + }, + "audio/uemclip": { + "source": "iana" + }, + "audio/ulpfec": { + "source": "iana" + }, + "audio/vdvi": { + "source": "iana" + }, + "audio/vmr-wb": { + "source": "iana" + }, + "audio/vnd.3gpp.iufp": { + "source": "iana" + }, + "audio/vnd.4sb": { + "source": "iana" + }, + "audio/vnd.audiokoz": { + "source": "iana" + }, + "audio/vnd.celp": { + "source": "iana" + }, + "audio/vnd.cisco.nse": { + "source": "iana" + }, + "audio/vnd.cmles.radio-events": { + "source": "iana" + }, + "audio/vnd.cns.anp1": { + "source": "iana" + }, + "audio/vnd.cns.inf1": { + "source": "iana" + }, + "audio/vnd.dece.audio": { + "source": "iana", + "extensions": ["uva","uvva"] + }, + "audio/vnd.digital-winds": { + "source": "iana", + "extensions": ["eol"] + }, + "audio/vnd.dlna.adts": { + "source": "iana" + }, + "audio/vnd.dolby.heaac.1": { + "source": "iana" + }, + "audio/vnd.dolby.heaac.2": { + "source": "iana" + }, + "audio/vnd.dolby.mlp": { + "source": "iana" + }, + "audio/vnd.dolby.mps": { + "source": "iana" + }, + "audio/vnd.dolby.pl2": { + "source": "iana" + }, + "audio/vnd.dolby.pl2x": { + "source": "iana" + }, + "audio/vnd.dolby.pl2z": { + "source": "iana" + }, + "audio/vnd.dolby.pulse.1": { + "source": "iana" + }, + "audio/vnd.dra": { + "source": "iana", + "extensions": ["dra"] + }, + "audio/vnd.dts": { + "source": "iana", + "extensions": ["dts"] + }, + "audio/vnd.dts.hd": { + "source": "iana", + "extensions": ["dtshd"] + }, + "audio/vnd.dvb.file": { + "source": "iana" + }, + "audio/vnd.everad.plj": { + "source": "iana" + }, + "audio/vnd.hns.audio": { + "source": "iana" + }, + "audio/vnd.lucent.voice": { + "source": "iana", + "extensions": ["lvp"] + }, + "audio/vnd.ms-playready.media.pya": { + "source": "iana", + "extensions": ["pya"] + }, + "audio/vnd.nokia.mobile-xmf": { + "source": "iana" + }, + "audio/vnd.nortel.vbk": { + "source": "iana" + }, + "audio/vnd.nuera.ecelp4800": { + "source": "iana", + "extensions": ["ecelp4800"] + }, + "audio/vnd.nuera.ecelp7470": { + "source": "iana", + "extensions": ["ecelp7470"] + }, + "audio/vnd.nuera.ecelp9600": { + "source": "iana", + "extensions": ["ecelp9600"] + }, + "audio/vnd.octel.sbc": { + "source": "iana" + }, + "audio/vnd.qcelp": { + "source": "iana" + }, + "audio/vnd.rhetorex.32kadpcm": { + "source": "iana" + }, + "audio/vnd.rip": { + "source": "iana", + "extensions": ["rip"] + }, + "audio/vnd.rn-realaudio": { + "compressible": false + }, + "audio/vnd.sealedmedia.softseal.mpeg": { + "source": "iana" + }, + "audio/vnd.vmx.cvsd": { + "source": "iana" + }, + "audio/vnd.wave": { + "compressible": false + }, + "audio/vorbis": { + "source": "iana", + "compressible": false + }, + "audio/vorbis-config": { + "source": "iana" + }, + "audio/wav": { + "compressible": false, + "extensions": ["wav"] + }, + "audio/wave": { + "compressible": false, + "extensions": ["wav"] + }, + "audio/webm": { + "source": "apache", + "compressible": false, + "extensions": ["weba"] + }, + "audio/x-aac": { + "source": "apache", + "compressible": false, + "extensions": ["aac"] + }, + "audio/x-aiff": { + "source": "apache", + "extensions": ["aif","aiff","aifc"] + }, + "audio/x-caf": { + "source": "apache", + "compressible": false, + "extensions": ["caf"] + }, + "audio/x-flac": { + "source": "apache", + "extensions": ["flac"] + }, + "audio/x-m4a": { + "source": "nginx", + "extensions": ["m4a"] + }, + "audio/x-matroska": { + "source": "apache", + "extensions": ["mka"] + }, + "audio/x-mpegurl": { + "source": "apache", + "extensions": ["m3u"] + }, + "audio/x-ms-wax": { + "source": "apache", + "extensions": ["wax"] + }, + "audio/x-ms-wma": { + "source": "apache", + "extensions": ["wma"] + }, + "audio/x-pn-realaudio": { + "source": "apache", + "extensions": ["ram","ra"] + }, + "audio/x-pn-realaudio-plugin": { + "source": "apache", + "extensions": ["rmp"] + }, + "audio/x-realaudio": { + "source": "nginx", + "extensions": ["ra"] + }, + "audio/x-tta": { + "source": "apache" + }, + "audio/x-wav": { + "source": "apache", + "extensions": ["wav"] + }, + "audio/xm": { + "source": "apache", + "extensions": ["xm"] + }, + "chemical/x-cdx": { + "source": "apache", + "extensions": ["cdx"] + }, + "chemical/x-cif": { + "source": "apache", + "extensions": ["cif"] + }, + "chemical/x-cmdf": { + "source": "apache", + "extensions": ["cmdf"] + }, + "chemical/x-cml": { + "source": "apache", + "extensions": ["cml"] + }, + "chemical/x-csml": { + "source": "apache", + "extensions": ["csml"] + }, + "chemical/x-pdb": { + "source": "apache" + }, + "chemical/x-xyz": { + "source": "apache", + "extensions": ["xyz"] + }, + "font/opentype": { + "compressible": true, + "extensions": ["otf"] + }, + "image/bmp": { + "source": "apache", + "compressible": true, + "extensions": ["bmp"] + }, + "image/cgm": { + "source": "iana", + "extensions": ["cgm"] + }, + "image/fits": { + "source": "iana" + }, + "image/g3fax": { + "source": "iana", + "extensions": ["g3"] + }, + "image/gif": { + "source": "iana", + "compressible": false, + "extensions": ["gif"] + }, + "image/ief": { + "source": "iana", + "extensions": ["ief"] + }, + "image/jp2": { + "source": "iana" + }, + "image/jpeg": { + "source": "iana", + "compressible": false, + "extensions": ["jpeg","jpg","jpe"] + }, + "image/jpm": { + "source": "iana" + }, + "image/jpx": { + "source": "iana" + }, + "image/ktx": { + "source": "iana", + "extensions": ["ktx"] + }, + "image/naplps": { + "source": "iana" + }, + "image/pjpeg": { + "compressible": false + }, + "image/png": { + "source": "iana", + "compressible": false, + "extensions": ["png"] + }, + "image/prs.btif": { + "source": "iana", + "extensions": ["btif"] + }, + "image/prs.pti": { + "source": "iana" + }, + "image/pwg-raster": { + "source": "iana" + }, + "image/sgi": { + "source": "apache", + "extensions": ["sgi"] + }, + "image/svg+xml": { + "source": "iana", + "compressible": true, + "extensions": ["svg","svgz"] + }, + "image/t38": { + "source": "iana" + }, + "image/tiff": { + "source": "iana", + "compressible": false, + "extensions": ["tiff","tif"] + }, + "image/tiff-fx": { + "source": "iana" + }, + "image/vnd.adobe.photoshop": { + "source": "iana", + "compressible": true, + "extensions": ["psd"] + }, + "image/vnd.airzip.accelerator.azv": { + "source": "iana" + }, + "image/vnd.cns.inf2": { + "source": "iana" + }, + "image/vnd.dece.graphic": { + "source": "iana", + "extensions": ["uvi","uvvi","uvg","uvvg"] + }, + "image/vnd.djvu": { + "source": "iana", + "extensions": ["djvu","djv"] + }, + "image/vnd.dvb.subtitle": { + "source": "iana", + "extensions": ["sub"] + }, + "image/vnd.dwg": { + "source": "iana", + "extensions": ["dwg"] + }, + "image/vnd.dxf": { + "source": "iana", + "extensions": ["dxf"] + }, + "image/vnd.fastbidsheet": { + "source": "iana", + "extensions": ["fbs"] + }, + "image/vnd.fpx": { + "source": "iana", + "extensions": ["fpx"] + }, + "image/vnd.fst": { + "source": "iana", + "extensions": ["fst"] + }, + "image/vnd.fujixerox.edmics-mmr": { + "source": "iana", + "extensions": ["mmr"] + }, + "image/vnd.fujixerox.edmics-rlc": { + "source": "iana", + "extensions": ["rlc"] + }, + "image/vnd.globalgraphics.pgb": { + "source": "iana" + }, + "image/vnd.microsoft.icon": { + "source": "iana" + }, + "image/vnd.mix": { + "source": "iana" + }, + "image/vnd.mozilla.apng": { + "source": "iana" + }, + "image/vnd.ms-modi": { + "source": "iana", + "extensions": ["mdi"] + }, + "image/vnd.ms-photo": { + "source": "apache", + "extensions": ["wdp"] + }, + "image/vnd.net-fpx": { + "source": "iana", + "extensions": ["npx"] + }, + "image/vnd.radiance": { + "source": "iana" + }, + "image/vnd.sealed.png": { + "source": "iana" + }, + "image/vnd.sealedmedia.softseal.gif": { + "source": "iana" + }, + "image/vnd.sealedmedia.softseal.jpg": { + "source": "iana" + }, + "image/vnd.svf": { + "source": "iana" + }, + "image/vnd.tencent.tap": { + "source": "iana" + }, + "image/vnd.valve.source.texture": { + "source": "iana" + }, + "image/vnd.wap.wbmp": { + "source": "iana", + "extensions": ["wbmp"] + }, + "image/vnd.xiff": { + "source": "iana", + "extensions": ["xif"] + }, + "image/vnd.zbrush.pcx": { + "source": "iana" + }, + "image/webp": { + "source": "apache", + "extensions": ["webp"] + }, + "image/x-3ds": { + "source": "apache", + "extensions": ["3ds"] + }, + "image/x-cmu-raster": { + "source": "apache", + "extensions": ["ras"] + }, + "image/x-cmx": { + "source": "apache", + "extensions": ["cmx"] + }, + "image/x-freehand": { + "source": "apache", + "extensions": ["fh","fhc","fh4","fh5","fh7"] + }, + "image/x-icon": { + "source": "apache", + "compressible": true, + "extensions": ["ico"] + }, + "image/x-jng": { + "source": "nginx", + "extensions": ["jng"] + }, + "image/x-mrsid-image": { + "source": "apache", + "extensions": ["sid"] + }, + "image/x-ms-bmp": { + "source": "nginx", + "compressible": true, + "extensions": ["bmp"] + }, + "image/x-pcx": { + "source": "apache", + "extensions": ["pcx"] + }, + "image/x-pict": { + "source": "apache", + "extensions": ["pic","pct"] + }, + "image/x-portable-anymap": { + "source": "apache", + "extensions": ["pnm"] + }, + "image/x-portable-bitmap": { + "source": "apache", + "extensions": ["pbm"] + }, + "image/x-portable-graymap": { + "source": "apache", + "extensions": ["pgm"] + }, + "image/x-portable-pixmap": { + "source": "apache", + "extensions": ["ppm"] + }, + "image/x-rgb": { + "source": "apache", + "extensions": ["rgb"] + }, + "image/x-tga": { + "source": "apache", + "extensions": ["tga"] + }, + "image/x-xbitmap": { + "source": "apache", + "extensions": ["xbm"] + }, + "image/x-xcf": { + "compressible": false + }, + "image/x-xpixmap": { + "source": "apache", + "extensions": ["xpm"] + }, + "image/x-xwindowdump": { + "source": "apache", + "extensions": ["xwd"] + }, + "message/cpim": { + "source": "iana" + }, + "message/delivery-status": { + "source": "iana" + }, + "message/disposition-notification": { + "source": "iana" + }, + "message/external-body": { + "source": "iana" + }, + "message/feedback-report": { + "source": "iana" + }, + "message/global": { + "source": "iana" + }, + "message/global-delivery-status": { + "source": "iana" + }, + "message/global-disposition-notification": { + "source": "iana" + }, + "message/global-headers": { + "source": "iana" + }, + "message/http": { + "source": "iana", + "compressible": false + }, + "message/imdn+xml": { + "source": "iana", + "compressible": true + }, + "message/news": { + "source": "iana" + }, + "message/partial": { + "source": "iana", + "compressible": false + }, + "message/rfc822": { + "source": "iana", + "compressible": true, + "extensions": ["eml","mime"] + }, + "message/s-http": { + "source": "iana" + }, + "message/sip": { + "source": "iana" + }, + "message/sipfrag": { + "source": "iana" + }, + "message/tracking-status": { + "source": "iana" + }, + "message/vnd.si.simp": { + "source": "iana" + }, + "message/vnd.wfa.wsc": { + "source": "iana" + }, + "model/iges": { + "source": "iana", + "compressible": false, + "extensions": ["igs","iges"] + }, + "model/mesh": { + "source": "iana", + "compressible": false, + "extensions": ["msh","mesh","silo"] + }, + "model/vnd.collada+xml": { + "source": "iana", + "extensions": ["dae"] + }, + "model/vnd.dwf": { + "source": "iana", + "extensions": ["dwf"] + }, + "model/vnd.flatland.3dml": { + "source": "iana" + }, + "model/vnd.gdl": { + "source": "iana", + "extensions": ["gdl"] + }, + "model/vnd.gs-gdl": { + "source": "apache" + }, + "model/vnd.gs.gdl": { + "source": "iana" + }, + "model/vnd.gtw": { + "source": "iana", + "extensions": ["gtw"] + }, + "model/vnd.moml+xml": { + "source": "iana" + }, + "model/vnd.mts": { + "source": "iana", + "extensions": ["mts"] + }, + "model/vnd.opengex": { + "source": "iana" + }, + "model/vnd.parasolid.transmit.binary": { + "source": "iana" + }, + "model/vnd.parasolid.transmit.text": { + "source": "iana" + }, + "model/vnd.rosette.annotated-data-model": { + "source": "iana" + }, + "model/vnd.valve.source.compiled-map": { + "source": "iana" + }, + "model/vnd.vtu": { + "source": "iana", + "extensions": ["vtu"] + }, + "model/vrml": { + "source": "iana", + "compressible": false, + "extensions": ["wrl","vrml"] + }, + "model/x3d+binary": { + "source": "apache", + "compressible": false, + "extensions": ["x3db","x3dbz"] + }, + "model/x3d+fastinfoset": { + "source": "iana" + }, + "model/x3d+vrml": { + "source": "apache", + "compressible": false, + "extensions": ["x3dv","x3dvz"] + }, + "model/x3d+xml": { + "source": "iana", + "compressible": true, + "extensions": ["x3d","x3dz"] + }, + "model/x3d-vrml": { + "source": "iana" + }, + "multipart/alternative": { + "source": "iana", + "compressible": false + }, + "multipart/appledouble": { + "source": "iana" + }, + "multipart/byteranges": { + "source": "iana" + }, + "multipart/digest": { + "source": "iana" + }, + "multipart/encrypted": { + "source": "iana", + "compressible": false + }, + "multipart/form-data": { + "source": "iana", + "compressible": false + }, + "multipart/header-set": { + "source": "iana" + }, + "multipart/mixed": { + "source": "iana", + "compressible": false + }, + "multipart/parallel": { + "source": "iana" + }, + "multipart/related": { + "source": "iana", + "compressible": false + }, + "multipart/report": { + "source": "iana" + }, + "multipart/signed": { + "source": "iana", + "compressible": false + }, + "multipart/voice-message": { + "source": "iana" + }, + "multipart/x-mixed-replace": { + "source": "iana" + }, + "text/1d-interleaved-parityfec": { + "source": "iana" + }, + "text/cache-manifest": { + "source": "iana", + "compressible": true, + "extensions": ["appcache","manifest"] + }, + "text/calendar": { + "source": "iana", + "extensions": ["ics","ifb"] + }, + "text/calender": { + "compressible": true + }, + "text/cmd": { + "compressible": true + }, + "text/coffeescript": { + "extensions": ["coffee","litcoffee"] + }, + "text/css": { + "source": "iana", + "compressible": true, + "extensions": ["css"] + }, + "text/csv": { + "source": "iana", + "compressible": true, + "extensions": ["csv"] + }, + "text/csv-schema": { + "source": "iana" + }, + "text/directory": { + "source": "iana" + }, + "text/dns": { + "source": "iana" + }, + "text/ecmascript": { + "source": "iana" + }, + "text/encaprtp": { + "source": "iana" + }, + "text/enriched": { + "source": "iana" + }, + "text/fwdred": { + "source": "iana" + }, + "text/grammar-ref-list": { + "source": "iana" + }, + "text/hjson": { + "extensions": ["hjson"] + }, + "text/html": { + "source": "iana", + "compressible": true, + "extensions": ["html","htm","shtml"] + }, + "text/jade": { + "extensions": ["jade"] + }, + "text/javascript": { + "source": "iana", + "compressible": true + }, + "text/jcr-cnd": { + "source": "iana" + }, + "text/jsx": { + "compressible": true, + "extensions": ["jsx"] + }, + "text/less": { + "extensions": ["less"] + }, + "text/markdown": { + "source": "iana" + }, + "text/mathml": { + "source": "nginx", + "extensions": ["mml"] + }, + "text/mizar": { + "source": "iana" + }, + "text/n3": { + "source": "iana", + "compressible": true, + "extensions": ["n3"] + }, + "text/parameters": { + "source": "iana" + }, + "text/parityfec": { + "source": "iana" + }, + "text/plain": { + "source": "iana", + "compressible": true, + "extensions": ["txt","text","conf","def","list","log","in","ini"] + }, + "text/provenance-notation": { + "source": "iana" + }, + "text/prs.fallenstein.rst": { + "source": "iana" + }, + "text/prs.lines.tag": { + "source": "iana", + "extensions": ["dsc"] + }, + "text/prs.prop.logic": { + "source": "iana" + }, + "text/raptorfec": { + "source": "iana" + }, + "text/red": { + "source": "iana" + }, + "text/rfc822-headers": { + "source": "iana" + }, + "text/richtext": { + "source": "iana", + "compressible": true, + "extensions": ["rtx"] + }, + "text/rtf": { + "source": "iana", + "compressible": true, + "extensions": ["rtf"] + }, + "text/rtp-enc-aescm128": { + "source": "iana" + }, + "text/rtploopback": { + "source": "iana" + }, + "text/rtx": { + "source": "iana" + }, + "text/sgml": { + "source": "iana", + "extensions": ["sgml","sgm"] + }, + "text/slim": { + "extensions": ["slim","slm"] + }, + "text/stylus": { + "extensions": ["stylus","styl"] + }, + "text/t140": { + "source": "iana" + }, + "text/tab-separated-values": { + "source": "iana", + "compressible": true, + "extensions": ["tsv"] + }, + "text/troff": { + "source": "iana", + "extensions": ["t","tr","roff","man","me","ms"] + }, + "text/turtle": { + "source": "iana", + "extensions": ["ttl"] + }, + "text/ulpfec": { + "source": "iana" + }, + "text/uri-list": { + "source": "iana", + "compressible": true, + "extensions": ["uri","uris","urls"] + }, + "text/vcard": { + "source": "iana", + "compressible": true, + "extensions": ["vcard"] + }, + "text/vnd.a": { + "source": "iana" + }, + "text/vnd.abc": { + "source": "iana" + }, + "text/vnd.curl": { + "source": "iana", + "extensions": ["curl"] + }, + "text/vnd.curl.dcurl": { + "source": "apache", + "extensions": ["dcurl"] + }, + "text/vnd.curl.mcurl": { + "source": "apache", + "extensions": ["mcurl"] + }, + "text/vnd.curl.scurl": { + "source": "apache", + "extensions": ["scurl"] + }, + "text/vnd.debian.copyright": { + "source": "iana" + }, + "text/vnd.dmclientscript": { + "source": "iana" + }, + "text/vnd.dvb.subtitle": { + "source": "iana", + "extensions": ["sub"] + }, + "text/vnd.esmertec.theme-descriptor": { + "source": "iana" + }, + "text/vnd.fly": { + "source": "iana", + "extensions": ["fly"] + }, + "text/vnd.fmi.flexstor": { + "source": "iana", + "extensions": ["flx"] + }, + "text/vnd.graphviz": { + "source": "iana", + "extensions": ["gv"] + }, + "text/vnd.in3d.3dml": { + "source": "iana", + "extensions": ["3dml"] + }, + "text/vnd.in3d.spot": { + "source": "iana", + "extensions": ["spot"] + }, + "text/vnd.iptc.newsml": { + "source": "iana" + }, + "text/vnd.iptc.nitf": { + "source": "iana" + }, + "text/vnd.latex-z": { + "source": "iana" + }, + "text/vnd.motorola.reflex": { + "source": "iana" + }, + "text/vnd.ms-mediapackage": { + "source": "iana" + }, + "text/vnd.net2phone.commcenter.command": { + "source": "iana" + }, + "text/vnd.radisys.msml-basic-layout": { + "source": "iana" + }, + "text/vnd.si.uricatalogue": { + "source": "iana" + }, + "text/vnd.sun.j2me.app-descriptor": { + "source": "iana", + "extensions": ["jad"] + }, + "text/vnd.trolltech.linguist": { + "source": "iana" + }, + "text/vnd.wap.si": { + "source": "iana" + }, + "text/vnd.wap.sl": { + "source": "iana" + }, + "text/vnd.wap.wml": { + "source": "iana", + "extensions": ["wml"] + }, + "text/vnd.wap.wmlscript": { + "source": "iana", + "extensions": ["wmls"] + }, + "text/vtt": { + "charset": "UTF-8", + "compressible": true, + "extensions": ["vtt"] + }, + "text/x-asm": { + "source": "apache", + "extensions": ["s","asm"] + }, + "text/x-c": { + "source": "apache", + "extensions": ["c","cc","cxx","cpp","h","hh","dic"] + }, + "text/x-component": { + "source": "nginx", + "extensions": ["htc"] + }, + "text/x-fortran": { + "source": "apache", + "extensions": ["f","for","f77","f90"] + }, + "text/x-gwt-rpc": { + "compressible": true + }, + "text/x-handlebars-template": { + "extensions": ["hbs"] + }, + "text/x-java-source": { + "source": "apache", + "extensions": ["java"] + }, + "text/x-jquery-tmpl": { + "compressible": true + }, + "text/x-lua": { + "extensions": ["lua"] + }, + "text/x-markdown": { + "compressible": true, + "extensions": ["markdown","md","mkd"] + }, + "text/x-nfo": { + "source": "apache", + "extensions": ["nfo"] + }, + "text/x-opml": { + "source": "apache", + "extensions": ["opml"] + }, + "text/x-pascal": { + "source": "apache", + "extensions": ["p","pas"] + }, + "text/x-processing": { + "compressible": true, + "extensions": ["pde"] + }, + "text/x-sass": { + "extensions": ["sass"] + }, + "text/x-scss": { + "extensions": ["scss"] + }, + "text/x-setext": { + "source": "apache", + "extensions": ["etx"] + }, + "text/x-sfv": { + "source": "apache", + "extensions": ["sfv"] + }, + "text/x-suse-ymp": { + "compressible": true, + "extensions": ["ymp"] + }, + "text/x-uuencode": { + "source": "apache", + "extensions": ["uu"] + }, + "text/x-vcalendar": { + "source": "apache", + "extensions": ["vcs"] + }, + "text/x-vcard": { + "source": "apache", + "extensions": ["vcf"] + }, + "text/xml": { + "source": "iana", + "compressible": true, + "extensions": ["xml"] + }, + "text/xml-external-parsed-entity": { + "source": "iana" + }, + "text/yaml": { + "extensions": ["yaml","yml"] + }, + "video/1d-interleaved-parityfec": { + "source": "apache" + }, + "video/3gpp": { + "source": "apache", + "extensions": ["3gp","3gpp"] + }, + "video/3gpp-tt": { + "source": "apache" + }, + "video/3gpp2": { + "source": "apache", + "extensions": ["3g2"] + }, + "video/bmpeg": { + "source": "apache" + }, + "video/bt656": { + "source": "apache" + }, + "video/celb": { + "source": "apache" + }, + "video/dv": { + "source": "apache" + }, + "video/encaprtp": { + "source": "apache" + }, + "video/h261": { + "source": "apache", + "extensions": ["h261"] + }, + "video/h263": { + "source": "apache", + "extensions": ["h263"] + }, + "video/h263-1998": { + "source": "apache" + }, + "video/h263-2000": { + "source": "apache" + }, + "video/h264": { + "source": "apache", + "extensions": ["h264"] + }, + "video/h264-rcdo": { + "source": "apache" + }, + "video/h264-svc": { + "source": "apache" + }, + "video/h265": { + "source": "apache" + }, + "video/iso.segment": { + "source": "apache" + }, + "video/jpeg": { + "source": "apache", + "extensions": ["jpgv"] + }, + "video/jpeg2000": { + "source": "apache" + }, + "video/jpm": { + "source": "apache", + "extensions": ["jpm","jpgm"] + }, + "video/mj2": { + "source": "apache", + "extensions": ["mj2","mjp2"] + }, + "video/mp1s": { + "source": "apache" + }, + "video/mp2p": { + "source": "apache" + }, + "video/mp2t": { + "source": "apache", + "extensions": ["ts"] + }, + "video/mp4": { + "source": "apache", + "compressible": false, + "extensions": ["mp4","mp4v","mpg4"] + }, + "video/mp4v-es": { + "source": "apache" + }, + "video/mpeg": { + "source": "apache", + "compressible": false, + "extensions": ["mpeg","mpg","mpe","m1v","m2v"] + }, + "video/mpeg4-generic": { + "source": "apache" + }, + "video/mpv": { + "source": "apache" + }, + "video/nv": { + "source": "apache" + }, + "video/ogg": { + "source": "apache", + "compressible": false, + "extensions": ["ogv"] + }, + "video/parityfec": { + "source": "apache" + }, + "video/pointer": { + "source": "apache" + }, + "video/quicktime": { + "source": "apache", + "compressible": false, + "extensions": ["qt","mov"] + }, + "video/raptorfec": { + "source": "apache" + }, + "video/raw": { + "source": "apache" + }, + "video/rtp-enc-aescm128": { + "source": "apache" + }, + "video/rtploopback": { + "source": "apache" + }, + "video/rtx": { + "source": "apache" + }, + "video/smpte292m": { + "source": "apache" + }, + "video/ulpfec": { + "source": "apache" + }, + "video/vc1": { + "source": "apache" + }, + "video/vnd.cctv": { + "source": "apache" + }, + "video/vnd.dece.hd": { + "source": "apache", + "extensions": ["uvh","uvvh"] + }, + "video/vnd.dece.mobile": { + "source": "apache", + "extensions": ["uvm","uvvm"] + }, + "video/vnd.dece.mp4": { + "source": "apache" + }, + "video/vnd.dece.pd": { + "source": "apache", + "extensions": ["uvp","uvvp"] + }, + "video/vnd.dece.sd": { + "source": "apache", + "extensions": ["uvs","uvvs"] + }, + "video/vnd.dece.video": { + "source": "apache", + "extensions": ["uvv","uvvv"] + }, + "video/vnd.directv.mpeg": { + "source": "apache" + }, + "video/vnd.directv.mpeg-tts": { + "source": "apache" + }, + "video/vnd.dlna.mpeg-tts": { + "source": "apache" + }, + "video/vnd.dvb.file": { + "source": "apache", + "extensions": ["dvb"] + }, + "video/vnd.fvt": { + "source": "apache", + "extensions": ["fvt"] + }, + "video/vnd.hns.video": { + "source": "apache" + }, + "video/vnd.iptvforum.1dparityfec-1010": { + "source": "apache" + }, + "video/vnd.iptvforum.1dparityfec-2005": { + "source": "apache" + }, + "video/vnd.iptvforum.2dparityfec-1010": { + "source": "apache" + }, + "video/vnd.iptvforum.2dparityfec-2005": { + "source": "apache" + }, + "video/vnd.iptvforum.ttsavc": { + "source": "apache" + }, + "video/vnd.iptvforum.ttsmpeg2": { + "source": "apache" + }, + "video/vnd.motorola.video": { + "source": "apache" + }, + "video/vnd.motorola.videop": { + "source": "apache" + }, + "video/vnd.mpegurl": { + "source": "apache", + "extensions": ["mxu","m4u"] + }, + "video/vnd.ms-playready.media.pyv": { + "source": "apache", + "extensions": ["pyv"] + }, + "video/vnd.nokia.interleaved-multimedia": { + "source": "apache" + }, + "video/vnd.nokia.videovoip": { + "source": "apache" + }, + "video/vnd.objectvideo": { + "source": "apache" + }, + "video/vnd.radgamettools.bink": { + "source": "apache" + }, + "video/vnd.radgamettools.smacker": { + "source": "apache" + }, + "video/vnd.sealed.mpeg1": { + "source": "apache" + }, + "video/vnd.sealed.mpeg4": { + "source": "apache" + }, + "video/vnd.sealed.swf": { + "source": "apache" + }, + "video/vnd.sealedmedia.softseal.mov": { + "source": "apache" + }, + "video/vnd.uvvu.mp4": { + "source": "apache", + "extensions": ["uvu","uvvu"] + }, + "video/vnd.vivo": { + "source": "apache", + "extensions": ["viv"] + }, + "video/vp8": { + "source": "apache" + }, + "video/webm": { + "source": "apache", + "compressible": false, + "extensions": ["webm"] + }, + "video/x-f4v": { + "source": "apache", + "extensions": ["f4v"] + }, + "video/x-fli": { + "source": "apache", + "extensions": ["fli"] + }, + "video/x-flv": { + "source": "apache", + "compressible": false, + "extensions": ["flv"] + }, + "video/x-m4v": { + "source": "apache", + "extensions": ["m4v"] + }, + "video/x-matroska": { + "source": "apache", + "compressible": false, + "extensions": ["mkv","mk3d","mks"] + }, + "video/x-mng": { + "source": "apache", + "extensions": ["mng"] + }, + "video/x-ms-asf": { + "source": "apache", + "extensions": ["asf","asx"] + }, + "video/x-ms-vob": { + "source": "apache", + "extensions": ["vob"] + }, + "video/x-ms-wm": { + "source": "apache", + "extensions": ["wm"] + }, + "video/x-ms-wmv": { + "source": "apache", + "compressible": false, + "extensions": ["wmv"] + }, + "video/x-ms-wmx": { + "source": "apache", + "extensions": ["wmx"] + }, + "video/x-ms-wvx": { + "source": "apache", + "extensions": ["wvx"] + }, + "video/x-msvideo": { + "source": "apache", + "extensions": ["avi"] + }, + "video/x-sgi-movie": { + "source": "apache", + "extensions": ["movie"] + }, + "video/x-smv": { + "source": "apache", + "extensions": ["smv"] + }, + "x-conference/x-cooltalk": { + "source": "apache", + "extensions": ["ice"] + }, + "x-shader/x-fragment": { + "compressible": true + }, + "x-shader/x-vertex": { + "compressible": true + } +} diff --git a/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/index.js b/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/index.js index d6c75569..551031f6 100644 --- a/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/index.js +++ b/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/index.js @@ -1,11 +1,11 @@ -/*! - * mime-db - * Copyright(c) 2014 Jonathan Ong - * MIT Licensed - */ - -/** - * Module exports. - */ - -module.exports = require('./db.json') +/*! + * mime-db + * Copyright(c) 2014 Jonathan Ong + * MIT Licensed + */ + +/** + * Module exports. + */ + +module.exports = require('./db.json') diff --git a/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/package.json b/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/package.json index 6fa9da44..d1af1d09 100644 --- a/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/package.json +++ b/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/package.json @@ -1,99 +1,99 @@ -{ - "name": "mime-db", - "description": "Media Type Database", - "version": "1.23.0", - "contributors": [ - { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "Jonathan Ong", - "email": "me@jongleberry.com", - "url": "http://jongleberry.com" - }, - { - "name": "Robert Kieffer", - "email": "robert@broofa.com", - "url": "http://github.com/broofa" - } - ], - "license": "MIT", - "keywords": [ - "mime", - "db", - "type", - "types", - "database", - "charset", - "charsets" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/mime-db.git" - }, - "devDependencies": { - "bluebird": "3.3.5", - "co": "4.6.0", - "cogent": "1.0.1", - "csv-parse": "1.1.0", - "gnode": "0.1.2", - "istanbul": "0.4.3", - "mocha": "1.21.5", - "raw-body": "2.1.6", - "stream-to-array": "2.3.0" - }, - "files": [ - "HISTORY.md", - "LICENSE", - "README.md", - "db.json", - "index.js" - ], - "engines": { - "node": ">= 0.6" - }, - "scripts": { - "build": "node scripts/build", - "fetch": "gnode scripts/fetch-apache && gnode scripts/fetch-iana && gnode scripts/fetch-nginx", - "test": "mocha --reporter spec --bail --check-leaks test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", - "update": "npm run fetch && npm run build" - }, - "gitHead": "ba0d99fd05b3bfdc2ebcd78f858c25cb7db6af41", - "bugs": { - "url": "https://github.com/jshttp/mime-db/issues" - }, - "homepage": "https://github.com/jshttp/mime-db#readme", - "_id": "mime-db@1.23.0", - "_shasum": "a31b4070adaea27d732ea333740a64d0ec9a6659", - "_from": "mime-db@>=1.23.0 <1.24.0", - "_npmVersion": "2.15.1", - "_nodeVersion": "4.4.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "a31b4070adaea27d732ea333740a64d0ec9a6659", - "tarball": "https://registry.npmjs.org/mime-db/-/mime-db-1.23.0.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/mime-db-1.23.0.tgz_1462163798086_0.43938886746764183" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.23.0.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "mime-db", + "description": "Media Type Database", + "version": "1.23.0", + "contributors": [ + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "Jonathan Ong", + "email": "me@jongleberry.com", + "url": "http://jongleberry.com" + }, + { + "name": "Robert Kieffer", + "email": "robert@broofa.com", + "url": "http://github.com/broofa" + } + ], + "license": "MIT", + "keywords": [ + "mime", + "db", + "type", + "types", + "database", + "charset", + "charsets" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/mime-db.git" + }, + "devDependencies": { + "bluebird": "3.3.5", + "co": "4.6.0", + "cogent": "1.0.1", + "csv-parse": "1.1.0", + "gnode": "0.1.2", + "istanbul": "0.4.3", + "mocha": "1.21.5", + "raw-body": "2.1.6", + "stream-to-array": "2.3.0" + }, + "files": [ + "HISTORY.md", + "LICENSE", + "README.md", + "db.json", + "index.js" + ], + "engines": { + "node": ">= 0.6" + }, + "scripts": { + "build": "node scripts/build", + "fetch": "gnode scripts/fetch-apache && gnode scripts/fetch-iana && gnode scripts/fetch-nginx", + "test": "mocha --reporter spec --bail --check-leaks test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", + "update": "npm run fetch && npm run build" + }, + "gitHead": "ba0d99fd05b3bfdc2ebcd78f858c25cb7db6af41", + "bugs": { + "url": "https://github.com/jshttp/mime-db/issues" + }, + "homepage": "https://github.com/jshttp/mime-db#readme", + "_id": "mime-db@1.23.0", + "_shasum": "a31b4070adaea27d732ea333740a64d0ec9a6659", + "_from": "mime-db@>=1.23.0 <1.24.0", + "_npmVersion": "2.15.1", + "_nodeVersion": "4.4.3", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "dist": { + "shasum": "a31b4070adaea27d732ea333740a64d0ec9a6659", + "tarball": "https://registry.npmjs.org/mime-db/-/mime-db-1.23.0.tgz" + }, + "maintainers": [ + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "jongleberry", + "email": "jonathanrichardong@gmail.com" + } + ], + "_npmOperationalInternal": { + "host": "packages-16-east.internal.npmjs.com", + "tmp": "tmp/mime-db-1.23.0.tgz_1462163798086_0.43938886746764183" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.23.0.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/package.json b/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/package.json index e941c289..a69300b6 100644 --- a/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/package.json +++ b/ui/node_modules/express/node_modules/accepts/node_modules/mime-types/package.json @@ -1,89 +1,89 @@ -{ - "name": "mime-types", - "description": "The ultimate javascript content-type utility.", - "version": "2.1.11", - "contributors": [ - { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "Jeremiah Senkpiel", - "email": "fishrock123@rocketmail.com", - "url": "https://searchbeam.jit.su" - }, - { - "name": "Jonathan Ong", - "email": "me@jongleberry.com", - "url": "http://jongleberry.com" - } - ], - "license": "MIT", - "keywords": [ - "mime", - "types" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/mime-types.git" - }, - "dependencies": { - "mime-db": "~1.23.0" - }, - "devDependencies": { - "istanbul": "0.4.3", - "mocha": "1.21.5" - }, - "files": [ - "HISTORY.md", - "LICENSE", - "index.js" - ], - "engines": { - "node": ">= 0.6" - }, - "scripts": { - "test": "mocha --reporter spec test/test.js", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot test/test.js", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot test/test.js" - }, - "gitHead": "298ffcf490a5d6e60edea7bf7a69036df04846b1", - "bugs": { - "url": "https://github.com/jshttp/mime-types/issues" - }, - "homepage": "https://github.com/jshttp/mime-types#readme", - "_id": "mime-types@2.1.11", - "_shasum": "c259c471bda808a85d6cd193b430a5fae4473b3c", - "_from": "mime-types@>=2.1.11 <2.2.0", - "_npmVersion": "2.15.1", - "_nodeVersion": "4.4.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "c259c471bda808a85d6cd193b430a5fae4473b3c", - "tarball": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.11.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "fishrock123", - "email": "fishrock123@rocketmail.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/mime-types-2.1.11.tgz_1462165365027_0.7217204745393246" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.11.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "mime-types", + "description": "The ultimate javascript content-type utility.", + "version": "2.1.11", + "contributors": [ + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "Jeremiah Senkpiel", + "email": "fishrock123@rocketmail.com", + "url": "https://searchbeam.jit.su" + }, + { + "name": "Jonathan Ong", + "email": "me@jongleberry.com", + "url": "http://jongleberry.com" + } + ], + "license": "MIT", + "keywords": [ + "mime", + "types" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/mime-types.git" + }, + "dependencies": { + "mime-db": "~1.23.0" + }, + "devDependencies": { + "istanbul": "0.4.3", + "mocha": "1.21.5" + }, + "files": [ + "HISTORY.md", + "LICENSE", + "index.js" + ], + "engines": { + "node": ">= 0.6" + }, + "scripts": { + "test": "mocha --reporter spec test/test.js", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot test/test.js", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot test/test.js" + }, + "gitHead": "298ffcf490a5d6e60edea7bf7a69036df04846b1", + "bugs": { + "url": "https://github.com/jshttp/mime-types/issues" + }, + "homepage": "https://github.com/jshttp/mime-types#readme", + "_id": "mime-types@2.1.11", + "_shasum": "c259c471bda808a85d6cd193b430a5fae4473b3c", + "_from": "mime-types@>=2.1.11 <2.2.0", + "_npmVersion": "2.15.1", + "_nodeVersion": "4.4.3", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "dist": { + "shasum": "c259c471bda808a85d6cd193b430a5fae4473b3c", + "tarball": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.11.tgz" + }, + "maintainers": [ + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "fishrock123", + "email": "fishrock123@rocketmail.com" + }, + { + "name": "jongleberry", + "email": "jonathanrichardong@gmail.com" + } + ], + "_npmOperationalInternal": { + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/mime-types-2.1.11.tgz_1462165365027_0.7217204745393246" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.11.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/HISTORY.md b/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/HISTORY.md index 983d5032..10b69179 100644 --- a/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/HISTORY.md +++ b/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/HISTORY.md @@ -1,98 +1,98 @@ -0.6.1 / 2016-05-02 -================== - - * perf: improve `Accept` parsing speed - * perf: improve `Accept-Charset` parsing speed - * perf: improve `Accept-Encoding` parsing speed - * perf: improve `Accept-Language` parsing speed - -0.6.0 / 2015-09-29 -================== - - * Fix including type extensions in parameters in `Accept` parsing - * Fix parsing `Accept` parameters with quoted equals - * Fix parsing `Accept` parameters with quoted semicolons - * Lazy-load modules from main entry point - * perf: delay type concatenation until needed - * perf: enable strict mode - * perf: hoist regular expressions - * perf: remove closures getting spec properties - * perf: remove a closure from media type parsing - * perf: remove property delete from media type parsing - -0.5.3 / 2015-05-10 -================== - - * Fix media type parameter matching to be case-insensitive - -0.5.2 / 2015-05-06 -================== - - * Fix comparing media types with quoted values - * Fix splitting media types with quoted commas - -0.5.1 / 2015-02-14 -================== - - * Fix preference sorting to be stable for long acceptable lists - -0.5.0 / 2014-12-18 -================== - - * Fix list return order when large accepted list - * Fix missing identity encoding when q=0 exists - * Remove dynamic building of Negotiator class - -0.4.9 / 2014-10-14 -================== - - * Fix error when media type has invalid parameter - -0.4.8 / 2014-09-28 -================== - - * Fix all negotiations to be case-insensitive - * Stable sort preferences of same quality according to client order - * Support Node.js 0.6 - -0.4.7 / 2014-06-24 -================== - - * Handle invalid provided languages - * Handle invalid provided media types - -0.4.6 / 2014-06-11 -================== - - * Order by specificity when quality is the same - -0.4.5 / 2014-05-29 -================== - - * Fix regression in empty header handling - -0.4.4 / 2014-05-29 -================== - - * Fix behaviors when headers are not present - -0.4.3 / 2014-04-16 -================== - - * Handle slashes on media params correctly - -0.4.2 / 2014-02-28 -================== - - * Fix media type sorting - * Handle media types params strictly - -0.4.1 / 2014-01-16 -================== - - * Use most specific matches - -0.4.0 / 2014-01-09 -================== - - * Remove preferred prefix from methods +0.6.1 / 2016-05-02 +================== + + * perf: improve `Accept` parsing speed + * perf: improve `Accept-Charset` parsing speed + * perf: improve `Accept-Encoding` parsing speed + * perf: improve `Accept-Language` parsing speed + +0.6.0 / 2015-09-29 +================== + + * Fix including type extensions in parameters in `Accept` parsing + * Fix parsing `Accept` parameters with quoted equals + * Fix parsing `Accept` parameters with quoted semicolons + * Lazy-load modules from main entry point + * perf: delay type concatenation until needed + * perf: enable strict mode + * perf: hoist regular expressions + * perf: remove closures getting spec properties + * perf: remove a closure from media type parsing + * perf: remove property delete from media type parsing + +0.5.3 / 2015-05-10 +================== + + * Fix media type parameter matching to be case-insensitive + +0.5.2 / 2015-05-06 +================== + + * Fix comparing media types with quoted values + * Fix splitting media types with quoted commas + +0.5.1 / 2015-02-14 +================== + + * Fix preference sorting to be stable for long acceptable lists + +0.5.0 / 2014-12-18 +================== + + * Fix list return order when large accepted list + * Fix missing identity encoding when q=0 exists + * Remove dynamic building of Negotiator class + +0.4.9 / 2014-10-14 +================== + + * Fix error when media type has invalid parameter + +0.4.8 / 2014-09-28 +================== + + * Fix all negotiations to be case-insensitive + * Stable sort preferences of same quality according to client order + * Support Node.js 0.6 + +0.4.7 / 2014-06-24 +================== + + * Handle invalid provided languages + * Handle invalid provided media types + +0.4.6 / 2014-06-11 +================== + + * Order by specificity when quality is the same + +0.4.5 / 2014-05-29 +================== + + * Fix regression in empty header handling + +0.4.4 / 2014-05-29 +================== + + * Fix behaviors when headers are not present + +0.4.3 / 2014-04-16 +================== + + * Handle slashes on media params correctly + +0.4.2 / 2014-02-28 +================== + + * Fix media type sorting + * Handle media types params strictly + +0.4.1 / 2014-01-16 +================== + + * Use most specific matches + +0.4.0 / 2014-01-09 +================== + + * Remove preferred prefix from methods diff --git a/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/LICENSE b/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/LICENSE index 94c52627..ea6b9e2e 100644 --- a/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/LICENSE +++ b/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/LICENSE @@ -1,24 +1,24 @@ -(The MIT License) - -Copyright (c) 2012-2014 Federico Romero -Copyright (c) 2012-2014 Isaac Z. Schlueter -Copyright (c) 2014-2015 Douglas Christopher Wilson - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2012-2014 Federico Romero +Copyright (c) 2012-2014 Isaac Z. Schlueter +Copyright (c) 2014-2015 Douglas Christopher Wilson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/README.md b/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/README.md index d7f1b0bc..04a67ff7 100644 --- a/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/README.md +++ b/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/README.md @@ -1,203 +1,203 @@ -# negotiator - -[![NPM Version][npm-image]][npm-url] -[![NPM Downloads][downloads-image]][downloads-url] -[![Node.js Version][node-version-image]][node-version-url] -[![Build Status][travis-image]][travis-url] -[![Test Coverage][coveralls-image]][coveralls-url] - -An HTTP content negotiator for Node.js - -## Installation - -```sh -$ npm install negotiator -``` - -## API - -```js -var Negotiator = require('negotiator') -``` - -### Accept Negotiation - -```js -availableMediaTypes = ['text/html', 'text/plain', 'application/json'] - -// The negotiator constructor receives a request object -negotiator = new Negotiator(request) - -// Let's say Accept header is 'text/html, application/*;q=0.2, image/jpeg;q=0.8' - -negotiator.mediaTypes() -// -> ['text/html', 'image/jpeg', 'application/*'] - -negotiator.mediaTypes(availableMediaTypes) -// -> ['text/html', 'application/json'] - -negotiator.mediaType(availableMediaTypes) -// -> 'text/html' -``` - -You can check a working example at `examples/accept.js`. - -#### Methods - -##### mediaType() - -Returns the most preferred media type from the client. - -##### mediaType(availableMediaType) - -Returns the most preferred media type from a list of available media types. - -##### mediaTypes() - -Returns an array of preferred media types ordered by the client preference. - -##### mediaTypes(availableMediaTypes) - -Returns an array of preferred media types ordered by priority from a list of -available media types. - -### Accept-Language Negotiation - -```js -negotiator = new Negotiator(request) - -availableLanguages = ['en', 'es', 'fr'] - -// Let's say Accept-Language header is 'en;q=0.8, es, pt' - -negotiator.languages() -// -> ['es', 'pt', 'en'] - -negotiator.languages(availableLanguages) -// -> ['es', 'en'] - -language = negotiator.language(availableLanguages) -// -> 'es' -``` - -You can check a working example at `examples/language.js`. - -#### Methods - -##### language() - -Returns the most preferred language from the client. - -##### language(availableLanguages) - -Returns the most preferred language from a list of available languages. - -##### languages() - -Returns an array of preferred languages ordered by the client preference. - -##### languages(availableLanguages) - -Returns an array of preferred languages ordered by priority from a list of -available languages. - -### Accept-Charset Negotiation - -```js -availableCharsets = ['utf-8', 'iso-8859-1', 'iso-8859-5'] - -negotiator = new Negotiator(request) - -// Let's say Accept-Charset header is 'utf-8, iso-8859-1;q=0.8, utf-7;q=0.2' - -negotiator.charsets() -// -> ['utf-8', 'iso-8859-1', 'utf-7'] - -negotiator.charsets(availableCharsets) -// -> ['utf-8', 'iso-8859-1'] - -negotiator.charset(availableCharsets) -// -> 'utf-8' -``` - -You can check a working example at `examples/charset.js`. - -#### Methods - -##### charset() - -Returns the most preferred charset from the client. - -##### charset(availableCharsets) - -Returns the most preferred charset from a list of available charsets. - -##### charsets() - -Returns an array of preferred charsets ordered by the client preference. - -##### charsets(availableCharsets) - -Returns an array of preferred charsets ordered by priority from a list of -available charsets. - -### Accept-Encoding Negotiation - -```js -availableEncodings = ['identity', 'gzip'] - -negotiator = new Negotiator(request) - -// Let's say Accept-Encoding header is 'gzip, compress;q=0.2, identity;q=0.5' - -negotiator.encodings() -// -> ['gzip', 'identity', 'compress'] - -negotiator.encodings(availableEncodings) -// -> ['gzip', 'identity'] - -negotiator.encoding(availableEncodings) -// -> 'gzip' -``` - -You can check a working example at `examples/encoding.js`. - -#### Methods - -##### encoding() - -Returns the most preferred encoding from the client. - -##### encoding(availableEncodings) - -Returns the most preferred encoding from a list of available encodings. - -##### encodings() - -Returns an array of preferred encodings ordered by the client preference. - -##### encodings(availableEncodings) - -Returns an array of preferred encodings ordered by priority from a list of -available encodings. - -## See Also - -The [accepts](https://npmjs.org/package/accepts#readme) module builds on -this module and provides an alternative interface, mime type validation, -and more. - -## License - -[MIT](LICENSE) - -[npm-image]: https://img.shields.io/npm/v/negotiator.svg -[npm-url]: https://npmjs.org/package/negotiator -[node-version-image]: https://img.shields.io/node/v/negotiator.svg -[node-version-url]: https://nodejs.org/en/download/ -[travis-image]: https://img.shields.io/travis/jshttp/negotiator/master.svg -[travis-url]: https://travis-ci.org/jshttp/negotiator -[coveralls-image]: https://img.shields.io/coveralls/jshttp/negotiator/master.svg -[coveralls-url]: https://coveralls.io/r/jshttp/negotiator?branch=master -[downloads-image]: https://img.shields.io/npm/dm/negotiator.svg -[downloads-url]: https://npmjs.org/package/negotiator +# negotiator + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-version-image]][node-version-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +An HTTP content negotiator for Node.js + +## Installation + +```sh +$ npm install negotiator +``` + +## API + +```js +var Negotiator = require('negotiator') +``` + +### Accept Negotiation + +```js +availableMediaTypes = ['text/html', 'text/plain', 'application/json'] + +// The negotiator constructor receives a request object +negotiator = new Negotiator(request) + +// Let's say Accept header is 'text/html, application/*;q=0.2, image/jpeg;q=0.8' + +negotiator.mediaTypes() +// -> ['text/html', 'image/jpeg', 'application/*'] + +negotiator.mediaTypes(availableMediaTypes) +// -> ['text/html', 'application/json'] + +negotiator.mediaType(availableMediaTypes) +// -> 'text/html' +``` + +You can check a working example at `examples/accept.js`. + +#### Methods + +##### mediaType() + +Returns the most preferred media type from the client. + +##### mediaType(availableMediaType) + +Returns the most preferred media type from a list of available media types. + +##### mediaTypes() + +Returns an array of preferred media types ordered by the client preference. + +##### mediaTypes(availableMediaTypes) + +Returns an array of preferred media types ordered by priority from a list of +available media types. + +### Accept-Language Negotiation + +```js +negotiator = new Negotiator(request) + +availableLanguages = ['en', 'es', 'fr'] + +// Let's say Accept-Language header is 'en;q=0.8, es, pt' + +negotiator.languages() +// -> ['es', 'pt', 'en'] + +negotiator.languages(availableLanguages) +// -> ['es', 'en'] + +language = negotiator.language(availableLanguages) +// -> 'es' +``` + +You can check a working example at `examples/language.js`. + +#### Methods + +##### language() + +Returns the most preferred language from the client. + +##### language(availableLanguages) + +Returns the most preferred language from a list of available languages. + +##### languages() + +Returns an array of preferred languages ordered by the client preference. + +##### languages(availableLanguages) + +Returns an array of preferred languages ordered by priority from a list of +available languages. + +### Accept-Charset Negotiation + +```js +availableCharsets = ['utf-8', 'iso-8859-1', 'iso-8859-5'] + +negotiator = new Negotiator(request) + +// Let's say Accept-Charset header is 'utf-8, iso-8859-1;q=0.8, utf-7;q=0.2' + +negotiator.charsets() +// -> ['utf-8', 'iso-8859-1', 'utf-7'] + +negotiator.charsets(availableCharsets) +// -> ['utf-8', 'iso-8859-1'] + +negotiator.charset(availableCharsets) +// -> 'utf-8' +``` + +You can check a working example at `examples/charset.js`. + +#### Methods + +##### charset() + +Returns the most preferred charset from the client. + +##### charset(availableCharsets) + +Returns the most preferred charset from a list of available charsets. + +##### charsets() + +Returns an array of preferred charsets ordered by the client preference. + +##### charsets(availableCharsets) + +Returns an array of preferred charsets ordered by priority from a list of +available charsets. + +### Accept-Encoding Negotiation + +```js +availableEncodings = ['identity', 'gzip'] + +negotiator = new Negotiator(request) + +// Let's say Accept-Encoding header is 'gzip, compress;q=0.2, identity;q=0.5' + +negotiator.encodings() +// -> ['gzip', 'identity', 'compress'] + +negotiator.encodings(availableEncodings) +// -> ['gzip', 'identity'] + +negotiator.encoding(availableEncodings) +// -> 'gzip' +``` + +You can check a working example at `examples/encoding.js`. + +#### Methods + +##### encoding() + +Returns the most preferred encoding from the client. + +##### encoding(availableEncodings) + +Returns the most preferred encoding from a list of available encodings. + +##### encodings() + +Returns an array of preferred encodings ordered by the client preference. + +##### encodings(availableEncodings) + +Returns an array of preferred encodings ordered by priority from a list of +available encodings. + +## See Also + +The [accepts](https://npmjs.org/package/accepts#readme) module builds on +this module and provides an alternative interface, mime type validation, +and more. + +## License + +[MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/negotiator.svg +[npm-url]: https://npmjs.org/package/negotiator +[node-version-image]: https://img.shields.io/node/v/negotiator.svg +[node-version-url]: https://nodejs.org/en/download/ +[travis-image]: https://img.shields.io/travis/jshttp/negotiator/master.svg +[travis-url]: https://travis-ci.org/jshttp/negotiator +[coveralls-image]: https://img.shields.io/coveralls/jshttp/negotiator/master.svg +[coveralls-url]: https://coveralls.io/r/jshttp/negotiator?branch=master +[downloads-image]: https://img.shields.io/npm/dm/negotiator.svg +[downloads-url]: https://npmjs.org/package/negotiator diff --git a/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/index.js b/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/index.js index 3a736984..8d4f6a22 100644 --- a/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/index.js +++ b/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/index.js @@ -1,124 +1,124 @@ -/*! - * negotiator - * Copyright(c) 2012 Federico Romero - * Copyright(c) 2012-2014 Isaac Z. Schlueter - * Copyright(c) 2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict'; - -/** - * Cached loaded submodules. - * @private - */ - -var modules = Object.create(null); - -/** - * Module exports. - * @public - */ - -module.exports = Negotiator; -module.exports.Negotiator = Negotiator; - -/** - * Create a Negotiator instance from a request. - * @param {object} request - * @public - */ - -function Negotiator(request) { - if (!(this instanceof Negotiator)) { - return new Negotiator(request); - } - - this.request = request; -} - -Negotiator.prototype.charset = function charset(available) { - var set = this.charsets(available); - return set && set[0]; -}; - -Negotiator.prototype.charsets = function charsets(available) { - var preferredCharsets = loadModule('charset').preferredCharsets; - return preferredCharsets(this.request.headers['accept-charset'], available); -}; - -Negotiator.prototype.encoding = function encoding(available) { - var set = this.encodings(available); - return set && set[0]; -}; - -Negotiator.prototype.encodings = function encodings(available) { - var preferredEncodings = loadModule('encoding').preferredEncodings; - return preferredEncodings(this.request.headers['accept-encoding'], available); -}; - -Negotiator.prototype.language = function language(available) { - var set = this.languages(available); - return set && set[0]; -}; - -Negotiator.prototype.languages = function languages(available) { - var preferredLanguages = loadModule('language').preferredLanguages; - return preferredLanguages(this.request.headers['accept-language'], available); -}; - -Negotiator.prototype.mediaType = function mediaType(available) { - var set = this.mediaTypes(available); - return set && set[0]; -}; - -Negotiator.prototype.mediaTypes = function mediaTypes(available) { - var preferredMediaTypes = loadModule('mediaType').preferredMediaTypes; - return preferredMediaTypes(this.request.headers.accept, available); -}; - -// Backwards compatibility -Negotiator.prototype.preferredCharset = Negotiator.prototype.charset; -Negotiator.prototype.preferredCharsets = Negotiator.prototype.charsets; -Negotiator.prototype.preferredEncoding = Negotiator.prototype.encoding; -Negotiator.prototype.preferredEncodings = Negotiator.prototype.encodings; -Negotiator.prototype.preferredLanguage = Negotiator.prototype.language; -Negotiator.prototype.preferredLanguages = Negotiator.prototype.languages; -Negotiator.prototype.preferredMediaType = Negotiator.prototype.mediaType; -Negotiator.prototype.preferredMediaTypes = Negotiator.prototype.mediaTypes; - -/** - * Load the given module. - * @private - */ - -function loadModule(moduleName) { - var module = modules[moduleName]; - - if (module !== undefined) { - return module; - } - - // This uses a switch for static require analysis - switch (moduleName) { - case 'charset': - module = require('./lib/charset'); - break; - case 'encoding': - module = require('./lib/encoding'); - break; - case 'language': - module = require('./lib/language'); - break; - case 'mediaType': - module = require('./lib/mediaType'); - break; - default: - throw new Error('Cannot find module \'' + moduleName + '\''); - } - - // Store to prevent invoking require() - modules[moduleName] = module; - - return module; -} +/*! + * negotiator + * Copyright(c) 2012 Federico Romero + * Copyright(c) 2012-2014 Isaac Z. Schlueter + * Copyright(c) 2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict'; + +/** + * Cached loaded submodules. + * @private + */ + +var modules = Object.create(null); + +/** + * Module exports. + * @public + */ + +module.exports = Negotiator; +module.exports.Negotiator = Negotiator; + +/** + * Create a Negotiator instance from a request. + * @param {object} request + * @public + */ + +function Negotiator(request) { + if (!(this instanceof Negotiator)) { + return new Negotiator(request); + } + + this.request = request; +} + +Negotiator.prototype.charset = function charset(available) { + var set = this.charsets(available); + return set && set[0]; +}; + +Negotiator.prototype.charsets = function charsets(available) { + var preferredCharsets = loadModule('charset').preferredCharsets; + return preferredCharsets(this.request.headers['accept-charset'], available); +}; + +Negotiator.prototype.encoding = function encoding(available) { + var set = this.encodings(available); + return set && set[0]; +}; + +Negotiator.prototype.encodings = function encodings(available) { + var preferredEncodings = loadModule('encoding').preferredEncodings; + return preferredEncodings(this.request.headers['accept-encoding'], available); +}; + +Negotiator.prototype.language = function language(available) { + var set = this.languages(available); + return set && set[0]; +}; + +Negotiator.prototype.languages = function languages(available) { + var preferredLanguages = loadModule('language').preferredLanguages; + return preferredLanguages(this.request.headers['accept-language'], available); +}; + +Negotiator.prototype.mediaType = function mediaType(available) { + var set = this.mediaTypes(available); + return set && set[0]; +}; + +Negotiator.prototype.mediaTypes = function mediaTypes(available) { + var preferredMediaTypes = loadModule('mediaType').preferredMediaTypes; + return preferredMediaTypes(this.request.headers.accept, available); +}; + +// Backwards compatibility +Negotiator.prototype.preferredCharset = Negotiator.prototype.charset; +Negotiator.prototype.preferredCharsets = Negotiator.prototype.charsets; +Negotiator.prototype.preferredEncoding = Negotiator.prototype.encoding; +Negotiator.prototype.preferredEncodings = Negotiator.prototype.encodings; +Negotiator.prototype.preferredLanguage = Negotiator.prototype.language; +Negotiator.prototype.preferredLanguages = Negotiator.prototype.languages; +Negotiator.prototype.preferredMediaType = Negotiator.prototype.mediaType; +Negotiator.prototype.preferredMediaTypes = Negotiator.prototype.mediaTypes; + +/** + * Load the given module. + * @private + */ + +function loadModule(moduleName) { + var module = modules[moduleName]; + + if (module !== undefined) { + return module; + } + + // This uses a switch for static require analysis + switch (moduleName) { + case 'charset': + module = require('./lib/charset'); + break; + case 'encoding': + module = require('./lib/encoding'); + break; + case 'language': + module = require('./lib/language'); + break; + case 'mediaType': + module = require('./lib/mediaType'); + break; + default: + throw new Error('Cannot find module \'' + moduleName + '\''); + } + + // Store to prevent invoking require() + modules[moduleName] = module; + + return module; +} diff --git a/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/charset.js b/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/charset.js index ce683af5..ac4217b4 100644 --- a/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/charset.js +++ b/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/charset.js @@ -1,169 +1,169 @@ -/** - * negotiator - * Copyright(c) 2012 Isaac Z. Schlueter - * Copyright(c) 2014 Federico Romero - * Copyright(c) 2014-2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict'; - -/** - * Module exports. - * @public - */ - -module.exports = preferredCharsets; -module.exports.preferredCharsets = preferredCharsets; - -/** - * Module variables. - * @private - */ - -var simpleCharsetRegExp = /^\s*([^\s;]+)\s*(?:;(.*))?$/; - -/** - * Parse the Accept-Charset header. - * @private - */ - -function parseAcceptCharset(accept) { - var accepts = accept.split(','); - - for (var i = 0, j = 0; i < accepts.length; i++) { - var charset = parseCharset(accepts[i].trim(), i); - - if (charset) { - accepts[j++] = charset; - } - } - - // trim accepts - accepts.length = j; - - return accepts; -} - -/** - * Parse a charset from the Accept-Charset header. - * @private - */ - -function parseCharset(str, i) { - var match = simpleCharsetRegExp.exec(str); - if (!match) return null; - - var charset = match[1]; - var q = 1; - if (match[2]) { - var params = match[2].split(';') - for (var i = 0; i < params.length; i ++) { - var p = params[i].trim().split('='); - if (p[0] === 'q') { - q = parseFloat(p[1]); - break; - } - } - } - - return { - charset: charset, - q: q, - i: i - }; -} - -/** - * Get the priority of a charset. - * @private - */ - -function getCharsetPriority(charset, accepted, index) { - var priority = {o: -1, q: 0, s: 0}; - - for (var i = 0; i < accepted.length; i++) { - var spec = specify(charset, accepted[i], index); - - if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) { - priority = spec; - } - } - - return priority; -} - -/** - * Get the specificity of the charset. - * @private - */ - -function specify(charset, spec, index) { - var s = 0; - if(spec.charset.toLowerCase() === charset.toLowerCase()){ - s |= 1; - } else if (spec.charset !== '*' ) { - return null - } - - return { - i: index, - o: spec.i, - q: spec.q, - s: s - } -} - -/** - * Get the preferred charsets from an Accept-Charset header. - * @public - */ - -function preferredCharsets(accept, provided) { - // RFC 2616 sec 14.2: no header = * - var accepts = parseAcceptCharset(accept === undefined ? '*' : accept || ''); - - if (!provided) { - // sorted list of all charsets - return accepts - .filter(isQuality) - .sort(compareSpecs) - .map(getFullCharset); - } - - var priorities = provided.map(function getPriority(type, index) { - return getCharsetPriority(type, accepts, index); - }); - - // sorted list of accepted charsets - return priorities.filter(isQuality).sort(compareSpecs).map(function getCharset(priority) { - return provided[priorities.indexOf(priority)]; - }); -} - -/** - * Compare two specs. - * @private - */ - -function compareSpecs(a, b) { - return (b.q - a.q) || (b.s - a.s) || (a.o - b.o) || (a.i - b.i) || 0; -} - -/** - * Get full charset string. - * @private - */ - -function getFullCharset(spec) { - return spec.charset; -} - -/** - * Check if a spec has any quality. - * @private - */ - -function isQuality(spec) { - return spec.q > 0; -} +/** + * negotiator + * Copyright(c) 2012 Isaac Z. Schlueter + * Copyright(c) 2014 Federico Romero + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict'; + +/** + * Module exports. + * @public + */ + +module.exports = preferredCharsets; +module.exports.preferredCharsets = preferredCharsets; + +/** + * Module variables. + * @private + */ + +var simpleCharsetRegExp = /^\s*([^\s;]+)\s*(?:;(.*))?$/; + +/** + * Parse the Accept-Charset header. + * @private + */ + +function parseAcceptCharset(accept) { + var accepts = accept.split(','); + + for (var i = 0, j = 0; i < accepts.length; i++) { + var charset = parseCharset(accepts[i].trim(), i); + + if (charset) { + accepts[j++] = charset; + } + } + + // trim accepts + accepts.length = j; + + return accepts; +} + +/** + * Parse a charset from the Accept-Charset header. + * @private + */ + +function parseCharset(str, i) { + var match = simpleCharsetRegExp.exec(str); + if (!match) return null; + + var charset = match[1]; + var q = 1; + if (match[2]) { + var params = match[2].split(';') + for (var i = 0; i < params.length; i ++) { + var p = params[i].trim().split('='); + if (p[0] === 'q') { + q = parseFloat(p[1]); + break; + } + } + } + + return { + charset: charset, + q: q, + i: i + }; +} + +/** + * Get the priority of a charset. + * @private + */ + +function getCharsetPriority(charset, accepted, index) { + var priority = {o: -1, q: 0, s: 0}; + + for (var i = 0; i < accepted.length; i++) { + var spec = specify(charset, accepted[i], index); + + if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) { + priority = spec; + } + } + + return priority; +} + +/** + * Get the specificity of the charset. + * @private + */ + +function specify(charset, spec, index) { + var s = 0; + if(spec.charset.toLowerCase() === charset.toLowerCase()){ + s |= 1; + } else if (spec.charset !== '*' ) { + return null + } + + return { + i: index, + o: spec.i, + q: spec.q, + s: s + } +} + +/** + * Get the preferred charsets from an Accept-Charset header. + * @public + */ + +function preferredCharsets(accept, provided) { + // RFC 2616 sec 14.2: no header = * + var accepts = parseAcceptCharset(accept === undefined ? '*' : accept || ''); + + if (!provided) { + // sorted list of all charsets + return accepts + .filter(isQuality) + .sort(compareSpecs) + .map(getFullCharset); + } + + var priorities = provided.map(function getPriority(type, index) { + return getCharsetPriority(type, accepts, index); + }); + + // sorted list of accepted charsets + return priorities.filter(isQuality).sort(compareSpecs).map(function getCharset(priority) { + return provided[priorities.indexOf(priority)]; + }); +} + +/** + * Compare two specs. + * @private + */ + +function compareSpecs(a, b) { + return (b.q - a.q) || (b.s - a.s) || (a.o - b.o) || (a.i - b.i) || 0; +} + +/** + * Get full charset string. + * @private + */ + +function getFullCharset(spec) { + return spec.charset; +} + +/** + * Check if a spec has any quality. + * @private + */ + +function isQuality(spec) { + return spec.q > 0; +} diff --git a/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/encoding.js b/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/encoding.js index 1e9f4860..70ac3de6 100644 --- a/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/encoding.js +++ b/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/encoding.js @@ -1,184 +1,184 @@ -/** - * negotiator - * Copyright(c) 2012 Isaac Z. Schlueter - * Copyright(c) 2014 Federico Romero - * Copyright(c) 2014-2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict'; - -/** - * Module exports. - * @public - */ - -module.exports = preferredEncodings; -module.exports.preferredEncodings = preferredEncodings; - -/** - * Module variables. - * @private - */ - -var simpleEncodingRegExp = /^\s*([^\s;]+)\s*(?:;(.*))?$/; - -/** - * Parse the Accept-Encoding header. - * @private - */ - -function parseAcceptEncoding(accept) { - var accepts = accept.split(','); - var hasIdentity = false; - var minQuality = 1; - - for (var i = 0, j = 0; i < accepts.length; i++) { - var encoding = parseEncoding(accepts[i].trim(), i); - - if (encoding) { - accepts[j++] = encoding; - hasIdentity = hasIdentity || specify('identity', encoding); - minQuality = Math.min(minQuality, encoding.q || 1); - } - } - - if (!hasIdentity) { - /* - * If identity doesn't explicitly appear in the accept-encoding header, - * it's added to the list of acceptable encoding with the lowest q - */ - accepts[j++] = { - encoding: 'identity', - q: minQuality, - i: i - }; - } - - // trim accepts - accepts.length = j; - - return accepts; -} - -/** - * Parse an encoding from the Accept-Encoding header. - * @private - */ - -function parseEncoding(str, i) { - var match = simpleEncodingRegExp.exec(str); - if (!match) return null; - - var encoding = match[1]; - var q = 1; - if (match[2]) { - var params = match[2].split(';'); - for (var i = 0; i < params.length; i ++) { - var p = params[i].trim().split('='); - if (p[0] === 'q') { - q = parseFloat(p[1]); - break; - } - } - } - - return { - encoding: encoding, - q: q, - i: i - }; -} - -/** - * Get the priority of an encoding. - * @private - */ - -function getEncodingPriority(encoding, accepted, index) { - var priority = {o: -1, q: 0, s: 0}; - - for (var i = 0; i < accepted.length; i++) { - var spec = specify(encoding, accepted[i], index); - - if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) { - priority = spec; - } - } - - return priority; -} - -/** - * Get the specificity of the encoding. - * @private - */ - -function specify(encoding, spec, index) { - var s = 0; - if(spec.encoding.toLowerCase() === encoding.toLowerCase()){ - s |= 1; - } else if (spec.encoding !== '*' ) { - return null - } - - return { - i: index, - o: spec.i, - q: spec.q, - s: s - } -}; - -/** - * Get the preferred encodings from an Accept-Encoding header. - * @public - */ - -function preferredEncodings(accept, provided) { - var accepts = parseAcceptEncoding(accept || ''); - - if (!provided) { - // sorted list of all encodings - return accepts - .filter(isQuality) - .sort(compareSpecs) - .map(getFullEncoding); - } - - var priorities = provided.map(function getPriority(type, index) { - return getEncodingPriority(type, accepts, index); - }); - - // sorted list of accepted encodings - return priorities.filter(isQuality).sort(compareSpecs).map(function getEncoding(priority) { - return provided[priorities.indexOf(priority)]; - }); -} - -/** - * Compare two specs. - * @private - */ - -function compareSpecs(a, b) { - return (b.q - a.q) || (b.s - a.s) || (a.o - b.o) || (a.i - b.i) || 0; -} - -/** - * Get full encoding string. - * @private - */ - -function getFullEncoding(spec) { - return spec.encoding; -} - -/** - * Check if a spec has any quality. - * @private - */ - -function isQuality(spec) { - return spec.q > 0; -} +/** + * negotiator + * Copyright(c) 2012 Isaac Z. Schlueter + * Copyright(c) 2014 Federico Romero + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict'; + +/** + * Module exports. + * @public + */ + +module.exports = preferredEncodings; +module.exports.preferredEncodings = preferredEncodings; + +/** + * Module variables. + * @private + */ + +var simpleEncodingRegExp = /^\s*([^\s;]+)\s*(?:;(.*))?$/; + +/** + * Parse the Accept-Encoding header. + * @private + */ + +function parseAcceptEncoding(accept) { + var accepts = accept.split(','); + var hasIdentity = false; + var minQuality = 1; + + for (var i = 0, j = 0; i < accepts.length; i++) { + var encoding = parseEncoding(accepts[i].trim(), i); + + if (encoding) { + accepts[j++] = encoding; + hasIdentity = hasIdentity || specify('identity', encoding); + minQuality = Math.min(minQuality, encoding.q || 1); + } + } + + if (!hasIdentity) { + /* + * If identity doesn't explicitly appear in the accept-encoding header, + * it's added to the list of acceptable encoding with the lowest q + */ + accepts[j++] = { + encoding: 'identity', + q: minQuality, + i: i + }; + } + + // trim accepts + accepts.length = j; + + return accepts; +} + +/** + * Parse an encoding from the Accept-Encoding header. + * @private + */ + +function parseEncoding(str, i) { + var match = simpleEncodingRegExp.exec(str); + if (!match) return null; + + var encoding = match[1]; + var q = 1; + if (match[2]) { + var params = match[2].split(';'); + for (var i = 0; i < params.length; i ++) { + var p = params[i].trim().split('='); + if (p[0] === 'q') { + q = parseFloat(p[1]); + break; + } + } + } + + return { + encoding: encoding, + q: q, + i: i + }; +} + +/** + * Get the priority of an encoding. + * @private + */ + +function getEncodingPriority(encoding, accepted, index) { + var priority = {o: -1, q: 0, s: 0}; + + for (var i = 0; i < accepted.length; i++) { + var spec = specify(encoding, accepted[i], index); + + if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) { + priority = spec; + } + } + + return priority; +} + +/** + * Get the specificity of the encoding. + * @private + */ + +function specify(encoding, spec, index) { + var s = 0; + if(spec.encoding.toLowerCase() === encoding.toLowerCase()){ + s |= 1; + } else if (spec.encoding !== '*' ) { + return null + } + + return { + i: index, + o: spec.i, + q: spec.q, + s: s + } +}; + +/** + * Get the preferred encodings from an Accept-Encoding header. + * @public + */ + +function preferredEncodings(accept, provided) { + var accepts = parseAcceptEncoding(accept || ''); + + if (!provided) { + // sorted list of all encodings + return accepts + .filter(isQuality) + .sort(compareSpecs) + .map(getFullEncoding); + } + + var priorities = provided.map(function getPriority(type, index) { + return getEncodingPriority(type, accepts, index); + }); + + // sorted list of accepted encodings + return priorities.filter(isQuality).sort(compareSpecs).map(function getEncoding(priority) { + return provided[priorities.indexOf(priority)]; + }); +} + +/** + * Compare two specs. + * @private + */ + +function compareSpecs(a, b) { + return (b.q - a.q) || (b.s - a.s) || (a.o - b.o) || (a.i - b.i) || 0; +} + +/** + * Get full encoding string. + * @private + */ + +function getFullEncoding(spec) { + return spec.encoding; +} + +/** + * Check if a spec has any quality. + * @private + */ + +function isQuality(spec) { + return spec.q > 0; +} diff --git a/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/language.js b/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/language.js index e2c11ff7..1bd2d0e1 100644 --- a/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/language.js +++ b/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/language.js @@ -1,179 +1,179 @@ -/** - * negotiator - * Copyright(c) 2012 Isaac Z. Schlueter - * Copyright(c) 2014 Federico Romero - * Copyright(c) 2014-2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict'; - -/** - * Module exports. - * @public - */ - -module.exports = preferredLanguages; -module.exports.preferredLanguages = preferredLanguages; - -/** - * Module variables. - * @private - */ - -var simpleLanguageRegExp = /^\s*([^\s\-;]+)(?:-([^\s;]+))?\s*(?:;(.*))?$/; - -/** - * Parse the Accept-Language header. - * @private - */ - -function parseAcceptLanguage(accept) { - var accepts = accept.split(','); - - for (var i = 0, j = 0; i < accepts.length; i++) { - var langauge = parseLanguage(accepts[i].trim(), i); - - if (langauge) { - accepts[j++] = langauge; - } - } - - // trim accepts - accepts.length = j; - - return accepts; -} - -/** - * Parse a language from the Accept-Language header. - * @private - */ - -function parseLanguage(str, i) { - var match = simpleLanguageRegExp.exec(str); - if (!match) return null; - - var prefix = match[1], - suffix = match[2], - full = prefix; - - if (suffix) full += "-" + suffix; - - var q = 1; - if (match[3]) { - var params = match[3].split(';') - for (var i = 0; i < params.length; i ++) { - var p = params[i].split('='); - if (p[0] === 'q') q = parseFloat(p[1]); - } - } - - return { - prefix: prefix, - suffix: suffix, - q: q, - i: i, - full: full - }; -} - -/** - * Get the priority of a language. - * @private - */ - -function getLanguagePriority(language, accepted, index) { - var priority = {o: -1, q: 0, s: 0}; - - for (var i = 0; i < accepted.length; i++) { - var spec = specify(language, accepted[i], index); - - if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) { - priority = spec; - } - } - - return priority; -} - -/** - * Get the specificity of the language. - * @private - */ - -function specify(language, spec, index) { - var p = parseLanguage(language) - if (!p) return null; - var s = 0; - if(spec.full.toLowerCase() === p.full.toLowerCase()){ - s |= 4; - } else if (spec.prefix.toLowerCase() === p.full.toLowerCase()) { - s |= 2; - } else if (spec.full.toLowerCase() === p.prefix.toLowerCase()) { - s |= 1; - } else if (spec.full !== '*' ) { - return null - } - - return { - i: index, - o: spec.i, - q: spec.q, - s: s - } -}; - -/** - * Get the preferred languages from an Accept-Language header. - * @public - */ - -function preferredLanguages(accept, provided) { - // RFC 2616 sec 14.4: no header = * - var accepts = parseAcceptLanguage(accept === undefined ? '*' : accept || ''); - - if (!provided) { - // sorted list of all languages - return accepts - .filter(isQuality) - .sort(compareSpecs) - .map(getFullLanguage); - } - - var priorities = provided.map(function getPriority(type, index) { - return getLanguagePriority(type, accepts, index); - }); - - // sorted list of accepted languages - return priorities.filter(isQuality).sort(compareSpecs).map(function getLanguage(priority) { - return provided[priorities.indexOf(priority)]; - }); -} - -/** - * Compare two specs. - * @private - */ - -function compareSpecs(a, b) { - return (b.q - a.q) || (b.s - a.s) || (a.o - b.o) || (a.i - b.i) || 0; -} - -/** - * Get full language string. - * @private - */ - -function getFullLanguage(spec) { - return spec.full; -} - -/** - * Check if a spec has any quality. - * @private - */ - -function isQuality(spec) { - return spec.q > 0; -} +/** + * negotiator + * Copyright(c) 2012 Isaac Z. Schlueter + * Copyright(c) 2014 Federico Romero + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict'; + +/** + * Module exports. + * @public + */ + +module.exports = preferredLanguages; +module.exports.preferredLanguages = preferredLanguages; + +/** + * Module variables. + * @private + */ + +var simpleLanguageRegExp = /^\s*([^\s\-;]+)(?:-([^\s;]+))?\s*(?:;(.*))?$/; + +/** + * Parse the Accept-Language header. + * @private + */ + +function parseAcceptLanguage(accept) { + var accepts = accept.split(','); + + for (var i = 0, j = 0; i < accepts.length; i++) { + var langauge = parseLanguage(accepts[i].trim(), i); + + if (langauge) { + accepts[j++] = langauge; + } + } + + // trim accepts + accepts.length = j; + + return accepts; +} + +/** + * Parse a language from the Accept-Language header. + * @private + */ + +function parseLanguage(str, i) { + var match = simpleLanguageRegExp.exec(str); + if (!match) return null; + + var prefix = match[1], + suffix = match[2], + full = prefix; + + if (suffix) full += "-" + suffix; + + var q = 1; + if (match[3]) { + var params = match[3].split(';') + for (var i = 0; i < params.length; i ++) { + var p = params[i].split('='); + if (p[0] === 'q') q = parseFloat(p[1]); + } + } + + return { + prefix: prefix, + suffix: suffix, + q: q, + i: i, + full: full + }; +} + +/** + * Get the priority of a language. + * @private + */ + +function getLanguagePriority(language, accepted, index) { + var priority = {o: -1, q: 0, s: 0}; + + for (var i = 0; i < accepted.length; i++) { + var spec = specify(language, accepted[i], index); + + if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) { + priority = spec; + } + } + + return priority; +} + +/** + * Get the specificity of the language. + * @private + */ + +function specify(language, spec, index) { + var p = parseLanguage(language) + if (!p) return null; + var s = 0; + if(spec.full.toLowerCase() === p.full.toLowerCase()){ + s |= 4; + } else if (spec.prefix.toLowerCase() === p.full.toLowerCase()) { + s |= 2; + } else if (spec.full.toLowerCase() === p.prefix.toLowerCase()) { + s |= 1; + } else if (spec.full !== '*' ) { + return null + } + + return { + i: index, + o: spec.i, + q: spec.q, + s: s + } +}; + +/** + * Get the preferred languages from an Accept-Language header. + * @public + */ + +function preferredLanguages(accept, provided) { + // RFC 2616 sec 14.4: no header = * + var accepts = parseAcceptLanguage(accept === undefined ? '*' : accept || ''); + + if (!provided) { + // sorted list of all languages + return accepts + .filter(isQuality) + .sort(compareSpecs) + .map(getFullLanguage); + } + + var priorities = provided.map(function getPriority(type, index) { + return getLanguagePriority(type, accepts, index); + }); + + // sorted list of accepted languages + return priorities.filter(isQuality).sort(compareSpecs).map(function getLanguage(priority) { + return provided[priorities.indexOf(priority)]; + }); +} + +/** + * Compare two specs. + * @private + */ + +function compareSpecs(a, b) { + return (b.q - a.q) || (b.s - a.s) || (a.o - b.o) || (a.i - b.i) || 0; +} + +/** + * Get full language string. + * @private + */ + +function getFullLanguage(spec) { + return spec.full; +} + +/** + * Check if a spec has any quality. + * @private + */ + +function isQuality(spec) { + return spec.q > 0; +} diff --git a/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/mediaType.js b/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/mediaType.js index ee4be46b..67309dd7 100644 --- a/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/mediaType.js +++ b/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/mediaType.js @@ -1,294 +1,294 @@ -/** - * negotiator - * Copyright(c) 2012 Isaac Z. Schlueter - * Copyright(c) 2014 Federico Romero - * Copyright(c) 2014-2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict'; - -/** - * Module exports. - * @public - */ - -module.exports = preferredMediaTypes; -module.exports.preferredMediaTypes = preferredMediaTypes; - -/** - * Module variables. - * @private - */ - -var simpleMediaTypeRegExp = /^\s*([^\s\/;]+)\/([^;\s]+)\s*(?:;(.*))?$/; - -/** - * Parse the Accept header. - * @private - */ - -function parseAccept(accept) { - var accepts = splitMediaTypes(accept); - - for (var i = 0, j = 0; i < accepts.length; i++) { - var mediaType = parseMediaType(accepts[i].trim(), i); - - if (mediaType) { - accepts[j++] = mediaType; - } - } - - // trim accepts - accepts.length = j; - - return accepts; -} - -/** - * Parse a media type from the Accept header. - * @private - */ - -function parseMediaType(str, i) { - var match = simpleMediaTypeRegExp.exec(str); - if (!match) return null; - - var params = Object.create(null); - var q = 1; - var subtype = match[2]; - var type = match[1]; - - if (match[3]) { - var kvps = splitParameters(match[3]).map(splitKeyValuePair); - - for (var j = 0; j < kvps.length; j++) { - var pair = kvps[j]; - var key = pair[0].toLowerCase(); - var val = pair[1]; - - // get the value, unwrapping quotes - var value = val && val[0] === '"' && val[val.length - 1] === '"' - ? val.substr(1, val.length - 2) - : val; - - if (key === 'q') { - q = parseFloat(value); - break; - } - - // store parameter - params[key] = value; - } - } - - return { - type: type, - subtype: subtype, - params: params, - q: q, - i: i - }; -} - -/** - * Get the priority of a media type. - * @private - */ - -function getMediaTypePriority(type, accepted, index) { - var priority = {o: -1, q: 0, s: 0}; - - for (var i = 0; i < accepted.length; i++) { - var spec = specify(type, accepted[i], index); - - if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) { - priority = spec; - } - } - - return priority; -} - -/** - * Get the specificity of the media type. - * @private - */ - -function specify(type, spec, index) { - var p = parseMediaType(type); - var s = 0; - - if (!p) { - return null; - } - - if(spec.type.toLowerCase() == p.type.toLowerCase()) { - s |= 4 - } else if(spec.type != '*') { - return null; - } - - if(spec.subtype.toLowerCase() == p.subtype.toLowerCase()) { - s |= 2 - } else if(spec.subtype != '*') { - return null; - } - - var keys = Object.keys(spec.params); - if (keys.length > 0) { - if (keys.every(function (k) { - return spec.params[k] == '*' || (spec.params[k] || '').toLowerCase() == (p.params[k] || '').toLowerCase(); - })) { - s |= 1 - } else { - return null - } - } - - return { - i: index, - o: spec.i, - q: spec.q, - s: s, - } -} - -/** - * Get the preferred media types from an Accept header. - * @public - */ - -function preferredMediaTypes(accept, provided) { - // RFC 2616 sec 14.2: no header = */* - var accepts = parseAccept(accept === undefined ? '*/*' : accept || ''); - - if (!provided) { - // sorted list of all types - return accepts - .filter(isQuality) - .sort(compareSpecs) - .map(getFullType); - } - - var priorities = provided.map(function getPriority(type, index) { - return getMediaTypePriority(type, accepts, index); - }); - - // sorted list of accepted types - return priorities.filter(isQuality).sort(compareSpecs).map(function getType(priority) { - return provided[priorities.indexOf(priority)]; - }); -} - -/** - * Compare two specs. - * @private - */ - -function compareSpecs(a, b) { - return (b.q - a.q) || (b.s - a.s) || (a.o - b.o) || (a.i - b.i) || 0; -} - -/** - * Get full type string. - * @private - */ - -function getFullType(spec) { - return spec.type + '/' + spec.subtype; -} - -/** - * Check if a spec has any quality. - * @private - */ - -function isQuality(spec) { - return spec.q > 0; -} - -/** - * Count the number of quotes in a string. - * @private - */ - -function quoteCount(string) { - var count = 0; - var index = 0; - - while ((index = string.indexOf('"', index)) !== -1) { - count++; - index++; - } - - return count; -} - -/** - * Split a key value pair. - * @private - */ - -function splitKeyValuePair(str) { - var index = str.indexOf('='); - var key; - var val; - - if (index === -1) { - key = str; - } else { - key = str.substr(0, index); - val = str.substr(index + 1); - } - - return [key, val]; -} - -/** - * Split an Accept header into media types. - * @private - */ - -function splitMediaTypes(accept) { - var accepts = accept.split(','); - - for (var i = 1, j = 0; i < accepts.length; i++) { - if (quoteCount(accepts[j]) % 2 == 0) { - accepts[++j] = accepts[i]; - } else { - accepts[j] += ',' + accepts[i]; - } - } - - // trim accepts - accepts.length = j + 1; - - return accepts; -} - -/** - * Split a string of parameters. - * @private - */ - -function splitParameters(str) { - var parameters = str.split(';'); - - for (var i = 1, j = 0; i < parameters.length; i++) { - if (quoteCount(parameters[j]) % 2 == 0) { - parameters[++j] = parameters[i]; - } else { - parameters[j] += ';' + parameters[i]; - } - } - - // trim parameters - parameters.length = j + 1; - - for (var i = 0; i < parameters.length; i++) { - parameters[i] = parameters[i].trim(); - } - - return parameters; -} +/** + * negotiator + * Copyright(c) 2012 Isaac Z. Schlueter + * Copyright(c) 2014 Federico Romero + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict'; + +/** + * Module exports. + * @public + */ + +module.exports = preferredMediaTypes; +module.exports.preferredMediaTypes = preferredMediaTypes; + +/** + * Module variables. + * @private + */ + +var simpleMediaTypeRegExp = /^\s*([^\s\/;]+)\/([^;\s]+)\s*(?:;(.*))?$/; + +/** + * Parse the Accept header. + * @private + */ + +function parseAccept(accept) { + var accepts = splitMediaTypes(accept); + + for (var i = 0, j = 0; i < accepts.length; i++) { + var mediaType = parseMediaType(accepts[i].trim(), i); + + if (mediaType) { + accepts[j++] = mediaType; + } + } + + // trim accepts + accepts.length = j; + + return accepts; +} + +/** + * Parse a media type from the Accept header. + * @private + */ + +function parseMediaType(str, i) { + var match = simpleMediaTypeRegExp.exec(str); + if (!match) return null; + + var params = Object.create(null); + var q = 1; + var subtype = match[2]; + var type = match[1]; + + if (match[3]) { + var kvps = splitParameters(match[3]).map(splitKeyValuePair); + + for (var j = 0; j < kvps.length; j++) { + var pair = kvps[j]; + var key = pair[0].toLowerCase(); + var val = pair[1]; + + // get the value, unwrapping quotes + var value = val && val[0] === '"' && val[val.length - 1] === '"' + ? val.substr(1, val.length - 2) + : val; + + if (key === 'q') { + q = parseFloat(value); + break; + } + + // store parameter + params[key] = value; + } + } + + return { + type: type, + subtype: subtype, + params: params, + q: q, + i: i + }; +} + +/** + * Get the priority of a media type. + * @private + */ + +function getMediaTypePriority(type, accepted, index) { + var priority = {o: -1, q: 0, s: 0}; + + for (var i = 0; i < accepted.length; i++) { + var spec = specify(type, accepted[i], index); + + if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) { + priority = spec; + } + } + + return priority; +} + +/** + * Get the specificity of the media type. + * @private + */ + +function specify(type, spec, index) { + var p = parseMediaType(type); + var s = 0; + + if (!p) { + return null; + } + + if(spec.type.toLowerCase() == p.type.toLowerCase()) { + s |= 4 + } else if(spec.type != '*') { + return null; + } + + if(spec.subtype.toLowerCase() == p.subtype.toLowerCase()) { + s |= 2 + } else if(spec.subtype != '*') { + return null; + } + + var keys = Object.keys(spec.params); + if (keys.length > 0) { + if (keys.every(function (k) { + return spec.params[k] == '*' || (spec.params[k] || '').toLowerCase() == (p.params[k] || '').toLowerCase(); + })) { + s |= 1 + } else { + return null + } + } + + return { + i: index, + o: spec.i, + q: spec.q, + s: s, + } +} + +/** + * Get the preferred media types from an Accept header. + * @public + */ + +function preferredMediaTypes(accept, provided) { + // RFC 2616 sec 14.2: no header = */* + var accepts = parseAccept(accept === undefined ? '*/*' : accept || ''); + + if (!provided) { + // sorted list of all types + return accepts + .filter(isQuality) + .sort(compareSpecs) + .map(getFullType); + } + + var priorities = provided.map(function getPriority(type, index) { + return getMediaTypePriority(type, accepts, index); + }); + + // sorted list of accepted types + return priorities.filter(isQuality).sort(compareSpecs).map(function getType(priority) { + return provided[priorities.indexOf(priority)]; + }); +} + +/** + * Compare two specs. + * @private + */ + +function compareSpecs(a, b) { + return (b.q - a.q) || (b.s - a.s) || (a.o - b.o) || (a.i - b.i) || 0; +} + +/** + * Get full type string. + * @private + */ + +function getFullType(spec) { + return spec.type + '/' + spec.subtype; +} + +/** + * Check if a spec has any quality. + * @private + */ + +function isQuality(spec) { + return spec.q > 0; +} + +/** + * Count the number of quotes in a string. + * @private + */ + +function quoteCount(string) { + var count = 0; + var index = 0; + + while ((index = string.indexOf('"', index)) !== -1) { + count++; + index++; + } + + return count; +} + +/** + * Split a key value pair. + * @private + */ + +function splitKeyValuePair(str) { + var index = str.indexOf('='); + var key; + var val; + + if (index === -1) { + key = str; + } else { + key = str.substr(0, index); + val = str.substr(index + 1); + } + + return [key, val]; +} + +/** + * Split an Accept header into media types. + * @private + */ + +function splitMediaTypes(accept) { + var accepts = accept.split(','); + + for (var i = 1, j = 0; i < accepts.length; i++) { + if (quoteCount(accepts[j]) % 2 == 0) { + accepts[++j] = accepts[i]; + } else { + accepts[j] += ',' + accepts[i]; + } + } + + // trim accepts + accepts.length = j + 1; + + return accepts; +} + +/** + * Split a string of parameters. + * @private + */ + +function splitParameters(str) { + var parameters = str.split(';'); + + for (var i = 1, j = 0; i < parameters.length; i++) { + if (quoteCount(parameters[j]) % 2 == 0) { + parameters[++j] = parameters[i]; + } else { + parameters[j] += ';' + parameters[i]; + } + } + + // trim parameters + parameters.length = j + 1; + + for (var i = 0; i < parameters.length; i++) { + parameters[i] = parameters[i].trim(); + } + + return parameters; +} diff --git a/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/package.json b/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/package.json index 9be88101..a7c2c2a1 100644 --- a/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/package.json +++ b/ui/node_modules/express/node_modules/accepts/node_modules/negotiator/package.json @@ -1,91 +1,91 @@ -{ - "name": "negotiator", - "description": "HTTP content negotiation", - "version": "0.6.1", - "contributors": [ - { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "Federico Romero", - "email": "federico.romero@outboxlabs.com" - }, - { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "http://blog.izs.me/" - } - ], - "license": "MIT", - "keywords": [ - "http", - "content negotiation", - "accept", - "accept-language", - "accept-encoding", - "accept-charset" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/negotiator.git" - }, - "devDependencies": { - "istanbul": "0.4.3", - "mocha": "~1.21.5" - }, - "files": [ - "lib/", - "HISTORY.md", - "LICENSE", - "index.js", - "README.md" - ], - "engines": { - "node": ">= 0.6" - }, - "scripts": { - "test": "mocha --reporter spec --check-leaks --bail test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" - }, - "gitHead": "751c381c32707f238143cd65d78520e16f4ef9e5", - "bugs": { - "url": "https://github.com/jshttp/negotiator/issues" - }, - "homepage": "https://github.com/jshttp/negotiator#readme", - "_id": "negotiator@0.6.1", - "_shasum": "2b327184e8992101177b28563fb5e7102acd0ca9", - "_from": "negotiator@0.6.1", - "_npmVersion": "2.15.1", - "_nodeVersion": "4.4.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "2b327184e8992101177b28563fb5e7102acd0ca9", - "tarball": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "federomero", - "email": "federomero@gmail.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/negotiator-0.6.1.tgz_1462250848695_0.027451182017102838" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "negotiator", + "description": "HTTP content negotiation", + "version": "0.6.1", + "contributors": [ + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "Federico Romero", + "email": "federico.romero@outboxlabs.com" + }, + { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me/" + } + ], + "license": "MIT", + "keywords": [ + "http", + "content negotiation", + "accept", + "accept-language", + "accept-encoding", + "accept-charset" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/negotiator.git" + }, + "devDependencies": { + "istanbul": "0.4.3", + "mocha": "~1.21.5" + }, + "files": [ + "lib/", + "HISTORY.md", + "LICENSE", + "index.js", + "README.md" + ], + "engines": { + "node": ">= 0.6" + }, + "scripts": { + "test": "mocha --reporter spec --check-leaks --bail test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" + }, + "gitHead": "751c381c32707f238143cd65d78520e16f4ef9e5", + "bugs": { + "url": "https://github.com/jshttp/negotiator/issues" + }, + "homepage": "https://github.com/jshttp/negotiator#readme", + "_id": "negotiator@0.6.1", + "_shasum": "2b327184e8992101177b28563fb5e7102acd0ca9", + "_from": "negotiator@0.6.1", + "_npmVersion": "2.15.1", + "_nodeVersion": "4.4.3", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "dist": { + "shasum": "2b327184e8992101177b28563fb5e7102acd0ca9", + "tarball": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz" + }, + "maintainers": [ + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "federomero", + "email": "federomero@gmail.com" + }, + { + "name": "jongleberry", + "email": "jonathanrichardong@gmail.com" + } + ], + "_npmOperationalInternal": { + "host": "packages-16-east.internal.npmjs.com", + "tmp": "tmp/negotiator-0.6.1.tgz_1462250848695_0.027451182017102838" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/accepts/package.json b/ui/node_modules/express/node_modules/accepts/package.json index 02d3441c..6bff56f4 100644 --- a/ui/node_modules/express/node_modules/accepts/package.json +++ b/ui/node_modules/express/node_modules/accepts/package.json @@ -1,79 +1,79 @@ -{ - "name": "accepts", - "description": "Higher-level content negotiation", - "version": "1.3.3", - "contributors": [ - { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "Jonathan Ong", - "email": "me@jongleberry.com", - "url": "http://jongleberry.com" - } - ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/accepts.git" - }, - "dependencies": { - "mime-types": "~2.1.11", - "negotiator": "0.6.1" - }, - "devDependencies": { - "istanbul": "0.4.3", - "mocha": "~1.21.5" - }, - "files": [ - "LICENSE", - "HISTORY.md", - "index.js" - ], - "engines": { - "node": ">= 0.6" - }, - "scripts": { - "test": "mocha --reporter spec --check-leaks --bail test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" - }, - "keywords": [ - "content", - "negotiation", - "accept", - "accepts" - ], - "gitHead": "3e925b1e65ed7da2798849683d49814680dfa426", - "bugs": { - "url": "https://github.com/jshttp/accepts/issues" - }, - "homepage": "https://github.com/jshttp/accepts#readme", - "_id": "accepts@1.3.3", - "_shasum": "c3ca7434938648c3e0d9c1e328dd68b622c284ca", - "_from": "accepts@>=1.3.3 <1.4.0", - "_npmVersion": "2.15.1", - "_nodeVersion": "4.4.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "c3ca7434938648c3e0d9c1e328dd68b622c284ca", - "tarball": "https://registry.npmjs.org/accepts/-/accepts-1.3.3.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/accepts-1.3.3.tgz_1462251932032_0.7092335098423064" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.3.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "accepts", + "description": "Higher-level content negotiation", + "version": "1.3.3", + "contributors": [ + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "Jonathan Ong", + "email": "me@jongleberry.com", + "url": "http://jongleberry.com" + } + ], + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/accepts.git" + }, + "dependencies": { + "mime-types": "~2.1.11", + "negotiator": "0.6.1" + }, + "devDependencies": { + "istanbul": "0.4.3", + "mocha": "~1.21.5" + }, + "files": [ + "LICENSE", + "HISTORY.md", + "index.js" + ], + "engines": { + "node": ">= 0.6" + }, + "scripts": { + "test": "mocha --reporter spec --check-leaks --bail test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" + }, + "keywords": [ + "content", + "negotiation", + "accept", + "accepts" + ], + "gitHead": "3e925b1e65ed7da2798849683d49814680dfa426", + "bugs": { + "url": "https://github.com/jshttp/accepts/issues" + }, + "homepage": "https://github.com/jshttp/accepts#readme", + "_id": "accepts@1.3.3", + "_shasum": "c3ca7434938648c3e0d9c1e328dd68b622c284ca", + "_from": "accepts@>=1.3.3 <1.4.0", + "_npmVersion": "2.15.1", + "_nodeVersion": "4.4.3", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "dist": { + "shasum": "c3ca7434938648c3e0d9c1e328dd68b622c284ca", + "tarball": "https://registry.npmjs.org/accepts/-/accepts-1.3.3.tgz" + }, + "maintainers": [ + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + } + ], + "_npmOperationalInternal": { + "host": "packages-16-east.internal.npmjs.com", + "tmp": "tmp/accepts-1.3.3.tgz_1462251932032_0.7092335098423064" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.3.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/array-flatten/LICENSE b/ui/node_modules/express/node_modules/array-flatten/LICENSE index 154c9f2a..983fbe8a 100644 --- a/ui/node_modules/express/node_modules/array-flatten/LICENSE +++ b/ui/node_modules/express/node_modules/array-flatten/LICENSE @@ -1,21 +1,21 @@ -The MIT License (MIT) - -Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. +The MIT License (MIT) + +Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/array-flatten/README.md b/ui/node_modules/express/node_modules/array-flatten/README.md index 0331e957..91fa5b63 100644 --- a/ui/node_modules/express/node_modules/array-flatten/README.md +++ b/ui/node_modules/express/node_modules/array-flatten/README.md @@ -1,43 +1,43 @@ -# Array Flatten - -[![NPM version][npm-image]][npm-url] -[![NPM downloads][downloads-image]][downloads-url] -[![Build status][travis-image]][travis-url] -[![Test coverage][coveralls-image]][coveralls-url] - -> Flatten an array of nested arrays into a single flat array. Accepts an optional depth. - -## Installation - -``` -npm install array-flatten --save -``` - -## Usage - -```javascript -var flatten = require('array-flatten') - -flatten([1, [2, [3, [4, [5], 6], 7], 8], 9]) -//=> [1, 2, 3, 4, 5, 6, 7, 8, 9] - -flatten([1, [2, [3, [4, [5], 6], 7], 8], 9], 2) -//=> [1, 2, 3, [4, [5], 6], 7, 8, 9] - -(function () { - flatten(arguments) //=> [1, 2, 3] -})(1, [2, 3]) -``` - -## License - -MIT - -[npm-image]: https://img.shields.io/npm/v/array-flatten.svg?style=flat -[npm-url]: https://npmjs.org/package/array-flatten -[downloads-image]: https://img.shields.io/npm/dm/array-flatten.svg?style=flat -[downloads-url]: https://npmjs.org/package/array-flatten -[travis-image]: https://img.shields.io/travis/blakeembrey/array-flatten.svg?style=flat -[travis-url]: https://travis-ci.org/blakeembrey/array-flatten -[coveralls-image]: https://img.shields.io/coveralls/blakeembrey/array-flatten.svg?style=flat -[coveralls-url]: https://coveralls.io/r/blakeembrey/array-flatten?branch=master +# Array Flatten + +[![NPM version][npm-image]][npm-url] +[![NPM downloads][downloads-image]][downloads-url] +[![Build status][travis-image]][travis-url] +[![Test coverage][coveralls-image]][coveralls-url] + +> Flatten an array of nested arrays into a single flat array. Accepts an optional depth. + +## Installation + +``` +npm install array-flatten --save +``` + +## Usage + +```javascript +var flatten = require('array-flatten') + +flatten([1, [2, [3, [4, [5], 6], 7], 8], 9]) +//=> [1, 2, 3, 4, 5, 6, 7, 8, 9] + +flatten([1, [2, [3, [4, [5], 6], 7], 8], 9], 2) +//=> [1, 2, 3, [4, [5], 6], 7, 8, 9] + +(function () { + flatten(arguments) //=> [1, 2, 3] +})(1, [2, 3]) +``` + +## License + +MIT + +[npm-image]: https://img.shields.io/npm/v/array-flatten.svg?style=flat +[npm-url]: https://npmjs.org/package/array-flatten +[downloads-image]: https://img.shields.io/npm/dm/array-flatten.svg?style=flat +[downloads-url]: https://npmjs.org/package/array-flatten +[travis-image]: https://img.shields.io/travis/blakeembrey/array-flatten.svg?style=flat +[travis-url]: https://travis-ci.org/blakeembrey/array-flatten +[coveralls-image]: https://img.shields.io/coveralls/blakeembrey/array-flatten.svg?style=flat +[coveralls-url]: https://coveralls.io/r/blakeembrey/array-flatten?branch=master diff --git a/ui/node_modules/express/node_modules/array-flatten/array-flatten.js b/ui/node_modules/express/node_modules/array-flatten/array-flatten.js index 0a3a8eb3..089117b3 100644 --- a/ui/node_modules/express/node_modules/array-flatten/array-flatten.js +++ b/ui/node_modules/express/node_modules/array-flatten/array-flatten.js @@ -1,64 +1,64 @@ -'use strict' - -/** - * Expose `arrayFlatten`. - */ -module.exports = arrayFlatten - -/** - * Recursive flatten function with depth. - * - * @param {Array} array - * @param {Array} result - * @param {Number} depth - * @return {Array} - */ -function flattenWithDepth (array, result, depth) { - for (var i = 0; i < array.length; i++) { - var value = array[i] - - if (depth > 0 && Array.isArray(value)) { - flattenWithDepth(value, result, depth - 1) - } else { - result.push(value) - } - } - - return result -} - -/** - * Recursive flatten function. Omitting depth is slightly faster. - * - * @param {Array} array - * @param {Array} result - * @return {Array} - */ -function flattenForever (array, result) { - for (var i = 0; i < array.length; i++) { - var value = array[i] - - if (Array.isArray(value)) { - flattenForever(value, result) - } else { - result.push(value) - } - } - - return result -} - -/** - * Flatten an array, with the ability to define a depth. - * - * @param {Array} array - * @param {Number} depth - * @return {Array} - */ -function arrayFlatten (array, depth) { - if (depth == null) { - return flattenForever(array, []) - } - - return flattenWithDepth(array, [], depth) -} +'use strict' + +/** + * Expose `arrayFlatten`. + */ +module.exports = arrayFlatten + +/** + * Recursive flatten function with depth. + * + * @param {Array} array + * @param {Array} result + * @param {Number} depth + * @return {Array} + */ +function flattenWithDepth (array, result, depth) { + for (var i = 0; i < array.length; i++) { + var value = array[i] + + if (depth > 0 && Array.isArray(value)) { + flattenWithDepth(value, result, depth - 1) + } else { + result.push(value) + } + } + + return result +} + +/** + * Recursive flatten function. Omitting depth is slightly faster. + * + * @param {Array} array + * @param {Array} result + * @return {Array} + */ +function flattenForever (array, result) { + for (var i = 0; i < array.length; i++) { + var value = array[i] + + if (Array.isArray(value)) { + flattenForever(value, result) + } else { + result.push(value) + } + } + + return result +} + +/** + * Flatten an array, with the ability to define a depth. + * + * @param {Array} array + * @param {Number} depth + * @return {Array} + */ +function arrayFlatten (array, depth) { + if (depth == null) { + return flattenForever(array, []) + } + + return flattenWithDepth(array, [], depth) +} diff --git a/ui/node_modules/express/node_modules/array-flatten/package.json b/ui/node_modules/express/node_modules/array-flatten/package.json index f36484cc..b1636eea 100644 --- a/ui/node_modules/express/node_modules/array-flatten/package.json +++ b/ui/node_modules/express/node_modules/array-flatten/package.json @@ -1,62 +1,62 @@ -{ - "name": "array-flatten", - "version": "1.1.1", - "description": "Flatten an array of nested arrays into a single flat array", - "main": "array-flatten.js", - "files": [ - "array-flatten.js", - "LICENSE" - ], - "scripts": { - "test": "istanbul cover _mocha -- -R spec" - }, - "repository": { - "type": "git", - "url": "git://github.com/blakeembrey/array-flatten.git" - }, - "keywords": [ - "array", - "flatten", - "arguments", - "depth" - ], - "author": { - "name": "Blake Embrey", - "email": "hello@blakeembrey.com", - "url": "http://blakeembrey.me" - }, - "license": "MIT", - "bugs": { - "url": "https://github.com/blakeembrey/array-flatten/issues" - }, - "homepage": "https://github.com/blakeembrey/array-flatten", - "devDependencies": { - "istanbul": "^0.3.13", - "mocha": "^2.2.4", - "pre-commit": "^1.0.7", - "standard": "^3.7.3" - }, - "gitHead": "1963a9189229d408e1e8f585a00c8be9edbd1803", - "_id": "array-flatten@1.1.1", - "_shasum": "9a5f699051b1e7073328f2a008968b64ea2955d2", - "_from": "array-flatten@1.1.1", - "_npmVersion": "2.11.3", - "_nodeVersion": "2.3.3", - "_npmUser": { - "name": "blakeembrey", - "email": "hello@blakeembrey.com" - }, - "maintainers": [ - { - "name": "blakeembrey", - "email": "hello@blakeembrey.com" - } - ], - "dist": { - "shasum": "9a5f699051b1e7073328f2a008968b64ea2955d2", - "tarball": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "array-flatten", + "version": "1.1.1", + "description": "Flatten an array of nested arrays into a single flat array", + "main": "array-flatten.js", + "files": [ + "array-flatten.js", + "LICENSE" + ], + "scripts": { + "test": "istanbul cover _mocha -- -R spec" + }, + "repository": { + "type": "git", + "url": "git://github.com/blakeembrey/array-flatten.git" + }, + "keywords": [ + "array", + "flatten", + "arguments", + "depth" + ], + "author": { + "name": "Blake Embrey", + "email": "hello@blakeembrey.com", + "url": "http://blakeembrey.me" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/blakeembrey/array-flatten/issues" + }, + "homepage": "https://github.com/blakeembrey/array-flatten", + "devDependencies": { + "istanbul": "^0.3.13", + "mocha": "^2.2.4", + "pre-commit": "^1.0.7", + "standard": "^3.7.3" + }, + "gitHead": "1963a9189229d408e1e8f585a00c8be9edbd1803", + "_id": "array-flatten@1.1.1", + "_shasum": "9a5f699051b1e7073328f2a008968b64ea2955d2", + "_from": "array-flatten@1.1.1", + "_npmVersion": "2.11.3", + "_nodeVersion": "2.3.3", + "_npmUser": { + "name": "blakeembrey", + "email": "hello@blakeembrey.com" + }, + "maintainers": [ + { + "name": "blakeembrey", + "email": "hello@blakeembrey.com" + } + ], + "dist": { + "shasum": "9a5f699051b1e7073328f2a008968b64ea2955d2", + "tarball": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/content-disposition/HISTORY.md b/ui/node_modules/express/node_modules/content-disposition/HISTORY.md index be8c6faa..76d494c6 100644 --- a/ui/node_modules/express/node_modules/content-disposition/HISTORY.md +++ b/ui/node_modules/express/node_modules/content-disposition/HISTORY.md @@ -1,45 +1,45 @@ -0.5.1 / 2016-01-17 -================== - - * perf: enable strict mode - -0.5.0 / 2014-10-11 -================== - - * Add `parse` function - -0.4.0 / 2014-09-21 -================== - - * Expand non-Unicode `filename` to the full ISO-8859-1 charset - -0.3.0 / 2014-09-20 -================== - - * Add `fallback` option - * Add `type` option - -0.2.0 / 2014-09-19 -================== - - * Reduce ambiguity of file names with hex escape in buggy browsers - -0.1.2 / 2014-09-19 -================== - - * Fix periodic invalid Unicode filename header - -0.1.1 / 2014-09-19 -================== - - * Fix invalid characters appearing in `filename*` parameter - -0.1.0 / 2014-09-18 -================== - - * Make the `filename` argument optional - -0.0.0 / 2014-09-18 -================== - - * Initial release +0.5.1 / 2016-01-17 +================== + + * perf: enable strict mode + +0.5.0 / 2014-10-11 +================== + + * Add `parse` function + +0.4.0 / 2014-09-21 +================== + + * Expand non-Unicode `filename` to the full ISO-8859-1 charset + +0.3.0 / 2014-09-20 +================== + + * Add `fallback` option + * Add `type` option + +0.2.0 / 2014-09-19 +================== + + * Reduce ambiguity of file names with hex escape in buggy browsers + +0.1.2 / 2014-09-19 +================== + + * Fix periodic invalid Unicode filename header + +0.1.1 / 2014-09-19 +================== + + * Fix invalid characters appearing in `filename*` parameter + +0.1.0 / 2014-09-18 +================== + + * Make the `filename` argument optional + +0.0.0 / 2014-09-18 +================== + + * Initial release diff --git a/ui/node_modules/express/node_modules/content-disposition/LICENSE b/ui/node_modules/express/node_modules/content-disposition/LICENSE index 69313376..b7dce6cf 100644 --- a/ui/node_modules/express/node_modules/content-disposition/LICENSE +++ b/ui/node_modules/express/node_modules/content-disposition/LICENSE @@ -1,22 +1,22 @@ -(The MIT License) - -Copyright (c) 2014 Douglas Christopher Wilson - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2014 Douglas Christopher Wilson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/content-disposition/README.md b/ui/node_modules/express/node_modules/content-disposition/README.md index 919427d1..5cebce49 100644 --- a/ui/node_modules/express/node_modules/content-disposition/README.md +++ b/ui/node_modules/express/node_modules/content-disposition/README.md @@ -1,141 +1,141 @@ -# content-disposition - -[![NPM Version][npm-image]][npm-url] -[![NPM Downloads][downloads-image]][downloads-url] -[![Node.js Version][node-version-image]][node-version-url] -[![Build Status][travis-image]][travis-url] -[![Test Coverage][coveralls-image]][coveralls-url] - -Create and parse HTTP `Content-Disposition` header - -## Installation - -```sh -$ npm install content-disposition -``` - -## API - -```js -var contentDisposition = require('content-disposition') -``` - -### contentDisposition(filename, options) - -Create an attachment `Content-Disposition` header value using the given file name, -if supplied. The `filename` is optional and if no file name is desired, but you -want to specify `options`, set `filename` to `undefined`. - -```js -res.setHeader('Content-Disposition', contentDisposition('∫ maths.pdf')) -``` - -**note** HTTP headers are of the ISO-8859-1 character set. If you are writing this -header through a means different from `setHeader` in Node.js, you'll want to specify -the `'binary'` encoding in Node.js. - -#### Options - -`contentDisposition` accepts these properties in the options object. - -##### fallback - -If the `filename` option is outside ISO-8859-1, then the file name is actually -stored in a supplemental field for clients that support Unicode file names and -a ISO-8859-1 version of the file name is automatically generated. - -This specifies the ISO-8859-1 file name to override the automatic generation or -disables the generation all together, defaults to `true`. - - - A string will specify the ISO-8859-1 file name to use in place of automatic - generation. - - `false` will disable including a ISO-8859-1 file name and only include the - Unicode version (unless the file name is already ISO-8859-1). - - `true` will enable automatic generation if the file name is outside ISO-8859-1. - -If the `filename` option is ISO-8859-1 and this option is specified and has a -different value, then the `filename` option is encoded in the extended field -and this set as the fallback field, even though they are both ISO-8859-1. - -##### type - -Specifies the disposition type, defaults to `"attachment"`. This can also be -`"inline"`, or any other value (all values except inline are treated like -`attachment`, but can convey additional information if both parties agree to -it). The type is normalized to lower-case. - -### contentDisposition.parse(string) - -```js -var disposition = contentDisposition.parse('attachment; filename="EURO rates.txt"; filename*=UTF-8\'\'%e2%82%ac%20rates.txt'); -``` - -Parse a `Content-Disposition` header string. This automatically handles extended -("Unicode") parameters by decoding them and providing them under the standard -parameter name. This will return an object with the following properties (examples -are shown for the string `'attachment; filename="EURO rates.txt"; filename*=UTF-8\'\'%e2%82%ac%20rates.txt'`): - - - `type`: The disposition type (always lower case). Example: `'attachment'` - - - `parameters`: An object of the parameters in the disposition (name of parameter - always lower case and extended versions replace non-extended versions). Example: - `{filename: "€ rates.txt"}` - -## Examples - -### Send a file for download - -```js -var contentDisposition = require('content-disposition') -var destroy = require('destroy') -var http = require('http') -var onFinished = require('on-finished') - -var filePath = '/path/to/public/plans.pdf' - -http.createServer(function onRequest(req, res) { - // set headers - res.setHeader('Content-Type', 'application/pdf') - res.setHeader('Content-Disposition', contentDisposition(filePath)) - - // send file - var stream = fs.createReadStream(filePath) - stream.pipe(res) - onFinished(res, function (err) { - destroy(stream) - }) -}) -``` - -## Testing - -```sh -$ npm test -``` - -## References - -- [RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1][rfc-2616] -- [RFC 5987: Character Set and Language Encoding for Hypertext Transfer Protocol (HTTP) Header Field Parameters][rfc-5987] -- [RFC 6266: Use of the Content-Disposition Header Field in the Hypertext Transfer Protocol (HTTP)][rfc-6266] -- [Test Cases for HTTP Content-Disposition header field (RFC 6266) and the Encodings defined in RFCs 2047, 2231 and 5987][tc-2231] - -[rfc-2616]: https://tools.ietf.org/html/rfc2616 -[rfc-5987]: https://tools.ietf.org/html/rfc5987 -[rfc-6266]: https://tools.ietf.org/html/rfc6266 -[tc-2231]: http://greenbytes.de/tech/tc2231/ - -## License - -[MIT](LICENSE) - -[npm-image]: https://img.shields.io/npm/v/content-disposition.svg?style=flat -[npm-url]: https://npmjs.org/package/content-disposition -[node-version-image]: https://img.shields.io/node/v/content-disposition.svg?style=flat -[node-version-url]: http://nodejs.org/download/ -[travis-image]: https://img.shields.io/travis/jshttp/content-disposition.svg?style=flat -[travis-url]: https://travis-ci.org/jshttp/content-disposition -[coveralls-image]: https://img.shields.io/coveralls/jshttp/content-disposition.svg?style=flat -[coveralls-url]: https://coveralls.io/r/jshttp/content-disposition?branch=master -[downloads-image]: https://img.shields.io/npm/dm/content-disposition.svg?style=flat -[downloads-url]: https://npmjs.org/package/content-disposition +# content-disposition + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-version-image]][node-version-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +Create and parse HTTP `Content-Disposition` header + +## Installation + +```sh +$ npm install content-disposition +``` + +## API + +```js +var contentDisposition = require('content-disposition') +``` + +### contentDisposition(filename, options) + +Create an attachment `Content-Disposition` header value using the given file name, +if supplied. The `filename` is optional and if no file name is desired, but you +want to specify `options`, set `filename` to `undefined`. + +```js +res.setHeader('Content-Disposition', contentDisposition('∫ maths.pdf')) +``` + +**note** HTTP headers are of the ISO-8859-1 character set. If you are writing this +header through a means different from `setHeader` in Node.js, you'll want to specify +the `'binary'` encoding in Node.js. + +#### Options + +`contentDisposition` accepts these properties in the options object. + +##### fallback + +If the `filename` option is outside ISO-8859-1, then the file name is actually +stored in a supplemental field for clients that support Unicode file names and +a ISO-8859-1 version of the file name is automatically generated. + +This specifies the ISO-8859-1 file name to override the automatic generation or +disables the generation all together, defaults to `true`. + + - A string will specify the ISO-8859-1 file name to use in place of automatic + generation. + - `false` will disable including a ISO-8859-1 file name and only include the + Unicode version (unless the file name is already ISO-8859-1). + - `true` will enable automatic generation if the file name is outside ISO-8859-1. + +If the `filename` option is ISO-8859-1 and this option is specified and has a +different value, then the `filename` option is encoded in the extended field +and this set as the fallback field, even though they are both ISO-8859-1. + +##### type + +Specifies the disposition type, defaults to `"attachment"`. This can also be +`"inline"`, or any other value (all values except inline are treated like +`attachment`, but can convey additional information if both parties agree to +it). The type is normalized to lower-case. + +### contentDisposition.parse(string) + +```js +var disposition = contentDisposition.parse('attachment; filename="EURO rates.txt"; filename*=UTF-8\'\'%e2%82%ac%20rates.txt'); +``` + +Parse a `Content-Disposition` header string. This automatically handles extended +("Unicode") parameters by decoding them and providing them under the standard +parameter name. This will return an object with the following properties (examples +are shown for the string `'attachment; filename="EURO rates.txt"; filename*=UTF-8\'\'%e2%82%ac%20rates.txt'`): + + - `type`: The disposition type (always lower case). Example: `'attachment'` + + - `parameters`: An object of the parameters in the disposition (name of parameter + always lower case and extended versions replace non-extended versions). Example: + `{filename: "€ rates.txt"}` + +## Examples + +### Send a file for download + +```js +var contentDisposition = require('content-disposition') +var destroy = require('destroy') +var http = require('http') +var onFinished = require('on-finished') + +var filePath = '/path/to/public/plans.pdf' + +http.createServer(function onRequest(req, res) { + // set headers + res.setHeader('Content-Type', 'application/pdf') + res.setHeader('Content-Disposition', contentDisposition(filePath)) + + // send file + var stream = fs.createReadStream(filePath) + stream.pipe(res) + onFinished(res, function (err) { + destroy(stream) + }) +}) +``` + +## Testing + +```sh +$ npm test +``` + +## References + +- [RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1][rfc-2616] +- [RFC 5987: Character Set and Language Encoding for Hypertext Transfer Protocol (HTTP) Header Field Parameters][rfc-5987] +- [RFC 6266: Use of the Content-Disposition Header Field in the Hypertext Transfer Protocol (HTTP)][rfc-6266] +- [Test Cases for HTTP Content-Disposition header field (RFC 6266) and the Encodings defined in RFCs 2047, 2231 and 5987][tc-2231] + +[rfc-2616]: https://tools.ietf.org/html/rfc2616 +[rfc-5987]: https://tools.ietf.org/html/rfc5987 +[rfc-6266]: https://tools.ietf.org/html/rfc6266 +[tc-2231]: http://greenbytes.de/tech/tc2231/ + +## License + +[MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/content-disposition.svg?style=flat +[npm-url]: https://npmjs.org/package/content-disposition +[node-version-image]: https://img.shields.io/node/v/content-disposition.svg?style=flat +[node-version-url]: http://nodejs.org/download/ +[travis-image]: https://img.shields.io/travis/jshttp/content-disposition.svg?style=flat +[travis-url]: https://travis-ci.org/jshttp/content-disposition +[coveralls-image]: https://img.shields.io/coveralls/jshttp/content-disposition.svg?style=flat +[coveralls-url]: https://coveralls.io/r/jshttp/content-disposition?branch=master +[downloads-image]: https://img.shields.io/npm/dm/content-disposition.svg?style=flat +[downloads-url]: https://npmjs.org/package/content-disposition diff --git a/ui/node_modules/express/node_modules/content-disposition/index.js b/ui/node_modules/express/node_modules/content-disposition/index.js index 2d4060dd..4a352dc8 100644 --- a/ui/node_modules/express/node_modules/content-disposition/index.js +++ b/ui/node_modules/express/node_modules/content-disposition/index.js @@ -1,445 +1,445 @@ -/*! - * content-disposition - * Copyright(c) 2014 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict' - -/** - * Module exports. - */ - -module.exports = contentDisposition -module.exports.parse = parse - -/** - * Module dependencies. - */ - -var basename = require('path').basename - -/** - * RegExp to match non attr-char, *after* encodeURIComponent (i.e. not including "%") - */ - -var encodeUriAttrCharRegExp = /[\x00-\x20"'\(\)*,\/:;<=>?@\[\\\]\{\}\x7f]/g - -/** - * RegExp to match percent encoding escape. - */ - -var hexEscapeRegExp = /%[0-9A-Fa-f]{2}/ -var hexEscapeReplaceRegExp = /%([0-9A-Fa-f]{2})/g - -/** - * RegExp to match non-latin1 characters. - */ - -var nonLatin1RegExp = /[^\x20-\x7e\xa0-\xff]/g - -/** - * RegExp to match quoted-pair in RFC 2616 - * - * quoted-pair = "\" CHAR - * CHAR = - */ - -var qescRegExp = /\\([\u0000-\u007f])/g; - -/** - * RegExp to match chars that must be quoted-pair in RFC 2616 - */ - -var quoteRegExp = /([\\"])/g - -/** - * RegExp for various RFC 2616 grammar - * - * parameter = token "=" ( token | quoted-string ) - * token = 1* - * separators = "(" | ")" | "<" | ">" | "@" - * | "," | ";" | ":" | "\" | <"> - * | "/" | "[" | "]" | "?" | "=" - * | "{" | "}" | SP | HT - * quoted-string = ( <"> *(qdtext | quoted-pair ) <"> ) - * qdtext = > - * quoted-pair = "\" CHAR - * CHAR = - * TEXT = - * LWS = [CRLF] 1*( SP | HT ) - * CRLF = CR LF - * CR = - * LF = - * SP = - * HT = - * CTL = - * OCTET = - */ - -var paramRegExp = /; *([!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) *= *("(?:[ !\x23-\x5b\x5d-\x7e\x80-\xff]|\\[\x20-\x7e])*"|[!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) */g -var textRegExp = /^[\x20-\x7e\x80-\xff]+$/ -var tokenRegExp = /^[!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+$/ - -/** - * RegExp for various RFC 5987 grammar - * - * ext-value = charset "'" [ language ] "'" value-chars - * charset = "UTF-8" / "ISO-8859-1" / mime-charset - * mime-charset = 1*mime-charsetc - * mime-charsetc = ALPHA / DIGIT - * / "!" / "#" / "$" / "%" / "&" - * / "+" / "-" / "^" / "_" / "`" - * / "{" / "}" / "~" - * language = ( 2*3ALPHA [ extlang ] ) - * / 4ALPHA - * / 5*8ALPHA - * extlang = *3( "-" 3ALPHA ) - * value-chars = *( pct-encoded / attr-char ) - * pct-encoded = "%" HEXDIG HEXDIG - * attr-char = ALPHA / DIGIT - * / "!" / "#" / "$" / "&" / "+" / "-" / "." - * / "^" / "_" / "`" / "|" / "~" - */ - -var extValueRegExp = /^([A-Za-z0-9!#$%&+\-^_`{}~]+)'(?:[A-Za-z]{2,3}(?:-[A-Za-z]{3}){0,3}|[A-Za-z]{4,8}|)'((?:%[0-9A-Fa-f]{2}|[A-Za-z0-9!#$&+\-\.^_`|~])+)$/ - -/** - * RegExp for various RFC 6266 grammar - * - * disposition-type = "inline" | "attachment" | disp-ext-type - * disp-ext-type = token - * disposition-parm = filename-parm | disp-ext-parm - * filename-parm = "filename" "=" value - * | "filename*" "=" ext-value - * disp-ext-parm = token "=" value - * | ext-token "=" ext-value - * ext-token = - */ - -var dispositionTypeRegExp = /^([!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) *(?:$|;)/ - -/** - * Create an attachment Content-Disposition header. - * - * @param {string} [filename] - * @param {object} [options] - * @param {string} [options.type=attachment] - * @param {string|boolean} [options.fallback=true] - * @return {string} - * @api public - */ - -function contentDisposition(filename, options) { - var opts = options || {} - - // get type - var type = opts.type || 'attachment' - - // get parameters - var params = createparams(filename, opts.fallback) - - // format into string - return format(new ContentDisposition(type, params)) -} - -/** - * Create parameters object from filename and fallback. - * - * @param {string} [filename] - * @param {string|boolean} [fallback=true] - * @return {object} - * @api private - */ - -function createparams(filename, fallback) { - if (filename === undefined) { - return - } - - var params = {} - - if (typeof filename !== 'string') { - throw new TypeError('filename must be a string') - } - - // fallback defaults to true - if (fallback === undefined) { - fallback = true - } - - if (typeof fallback !== 'string' && typeof fallback !== 'boolean') { - throw new TypeError('fallback must be a string or boolean') - } - - if (typeof fallback === 'string' && nonLatin1RegExp.test(fallback)) { - throw new TypeError('fallback must be ISO-8859-1 string') - } - - // restrict to file base name - var name = basename(filename) - - // determine if name is suitable for quoted string - var isQuotedString = textRegExp.test(name) - - // generate fallback name - var fallbackName = typeof fallback !== 'string' - ? fallback && getlatin1(name) - : basename(fallback) - var hasFallback = typeof fallbackName === 'string' && fallbackName !== name - - // set extended filename parameter - if (hasFallback || !isQuotedString || hexEscapeRegExp.test(name)) { - params['filename*'] = name - } - - // set filename parameter - if (isQuotedString || hasFallback) { - params.filename = hasFallback - ? fallbackName - : name - } - - return params -} - -/** - * Format object to Content-Disposition header. - * - * @param {object} obj - * @param {string} obj.type - * @param {object} [obj.parameters] - * @return {string} - * @api private - */ - -function format(obj) { - var parameters = obj.parameters - var type = obj.type - - if (!type || typeof type !== 'string' || !tokenRegExp.test(type)) { - throw new TypeError('invalid type') - } - - // start with normalized type - var string = String(type).toLowerCase() - - // append parameters - if (parameters && typeof parameters === 'object') { - var param - var params = Object.keys(parameters).sort() - - for (var i = 0; i < params.length; i++) { - param = params[i] - - var val = param.substr(-1) === '*' - ? ustring(parameters[param]) - : qstring(parameters[param]) - - string += '; ' + param + '=' + val - } - } - - return string -} - -/** - * Decode a RFC 6987 field value (gracefully). - * - * @param {string} str - * @return {string} - * @api private - */ - -function decodefield(str) { - var match = extValueRegExp.exec(str) - - if (!match) { - throw new TypeError('invalid extended field value') - } - - var charset = match[1].toLowerCase() - var encoded = match[2] - var value - - // to binary string - var binary = encoded.replace(hexEscapeReplaceRegExp, pdecode) - - switch (charset) { - case 'iso-8859-1': - value = getlatin1(binary) - break - case 'utf-8': - value = new Buffer(binary, 'binary').toString('utf8') - break - default: - throw new TypeError('unsupported charset in extended field') - } - - return value -} - -/** - * Get ISO-8859-1 version of string. - * - * @param {string} val - * @return {string} - * @api private - */ - -function getlatin1(val) { - // simple Unicode -> ISO-8859-1 transformation - return String(val).replace(nonLatin1RegExp, '?') -} - -/** - * Parse Content-Disposition header string. - * - * @param {string} string - * @return {object} - * @api private - */ - -function parse(string) { - if (!string || typeof string !== 'string') { - throw new TypeError('argument string is required') - } - - var match = dispositionTypeRegExp.exec(string) - - if (!match) { - throw new TypeError('invalid type format') - } - - // normalize type - var index = match[0].length - var type = match[1].toLowerCase() - - var key - var names = [] - var params = {} - var value - - // calculate index to start at - index = paramRegExp.lastIndex = match[0].substr(-1) === ';' - ? index - 1 - : index - - // match parameters - while (match = paramRegExp.exec(string)) { - if (match.index !== index) { - throw new TypeError('invalid parameter format') - } - - index += match[0].length - key = match[1].toLowerCase() - value = match[2] - - if (names.indexOf(key) !== -1) { - throw new TypeError('invalid duplicate parameter') - } - - names.push(key) - - if (key.indexOf('*') + 1 === key.length) { - // decode extended value - key = key.slice(0, -1) - value = decodefield(value) - - // overwrite existing value - params[key] = value - continue - } - - if (typeof params[key] === 'string') { - continue - } - - if (value[0] === '"') { - // remove quotes and escapes - value = value - .substr(1, value.length - 2) - .replace(qescRegExp, '$1') - } - - params[key] = value - } - - if (index !== -1 && index !== string.length) { - throw new TypeError('invalid parameter format') - } - - return new ContentDisposition(type, params) -} - -/** - * Percent decode a single character. - * - * @param {string} str - * @param {string} hex - * @return {string} - * @api private - */ - -function pdecode(str, hex) { - return String.fromCharCode(parseInt(hex, 16)) -} - -/** - * Percent encode a single character. - * - * @param {string} char - * @return {string} - * @api private - */ - -function pencode(char) { - var hex = String(char) - .charCodeAt(0) - .toString(16) - .toUpperCase() - return hex.length === 1 - ? '%0' + hex - : '%' + hex -} - -/** - * Quote a string for HTTP. - * - * @param {string} val - * @return {string} - * @api private - */ - -function qstring(val) { - var str = String(val) - - return '"' + str.replace(quoteRegExp, '\\$1') + '"' -} - -/** - * Encode a Unicode string for HTTP (RFC 5987). - * - * @param {string} val - * @return {string} - * @api private - */ - -function ustring(val) { - var str = String(val) - - // percent encode as UTF-8 - var encoded = encodeURIComponent(str) - .replace(encodeUriAttrCharRegExp, pencode) - - return 'UTF-8\'\'' + encoded -} - -/** - * Class for parsed Content-Disposition header for v8 optimization - */ - -function ContentDisposition(type, parameters) { - this.type = type - this.parameters = parameters -} +/*! + * content-disposition + * Copyright(c) 2014 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module exports. + */ + +module.exports = contentDisposition +module.exports.parse = parse + +/** + * Module dependencies. + */ + +var basename = require('path').basename + +/** + * RegExp to match non attr-char, *after* encodeURIComponent (i.e. not including "%") + */ + +var encodeUriAttrCharRegExp = /[\x00-\x20"'\(\)*,\/:;<=>?@\[\\\]\{\}\x7f]/g + +/** + * RegExp to match percent encoding escape. + */ + +var hexEscapeRegExp = /%[0-9A-Fa-f]{2}/ +var hexEscapeReplaceRegExp = /%([0-9A-Fa-f]{2})/g + +/** + * RegExp to match non-latin1 characters. + */ + +var nonLatin1RegExp = /[^\x20-\x7e\xa0-\xff]/g + +/** + * RegExp to match quoted-pair in RFC 2616 + * + * quoted-pair = "\" CHAR + * CHAR = + */ + +var qescRegExp = /\\([\u0000-\u007f])/g; + +/** + * RegExp to match chars that must be quoted-pair in RFC 2616 + */ + +var quoteRegExp = /([\\"])/g + +/** + * RegExp for various RFC 2616 grammar + * + * parameter = token "=" ( token | quoted-string ) + * token = 1* + * separators = "(" | ")" | "<" | ">" | "@" + * | "," | ";" | ":" | "\" | <"> + * | "/" | "[" | "]" | "?" | "=" + * | "{" | "}" | SP | HT + * quoted-string = ( <"> *(qdtext | quoted-pair ) <"> ) + * qdtext = > + * quoted-pair = "\" CHAR + * CHAR = + * TEXT = + * LWS = [CRLF] 1*( SP | HT ) + * CRLF = CR LF + * CR = + * LF = + * SP = + * HT = + * CTL = + * OCTET = + */ + +var paramRegExp = /; *([!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) *= *("(?:[ !\x23-\x5b\x5d-\x7e\x80-\xff]|\\[\x20-\x7e])*"|[!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) */g +var textRegExp = /^[\x20-\x7e\x80-\xff]+$/ +var tokenRegExp = /^[!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+$/ + +/** + * RegExp for various RFC 5987 grammar + * + * ext-value = charset "'" [ language ] "'" value-chars + * charset = "UTF-8" / "ISO-8859-1" / mime-charset + * mime-charset = 1*mime-charsetc + * mime-charsetc = ALPHA / DIGIT + * / "!" / "#" / "$" / "%" / "&" + * / "+" / "-" / "^" / "_" / "`" + * / "{" / "}" / "~" + * language = ( 2*3ALPHA [ extlang ] ) + * / 4ALPHA + * / 5*8ALPHA + * extlang = *3( "-" 3ALPHA ) + * value-chars = *( pct-encoded / attr-char ) + * pct-encoded = "%" HEXDIG HEXDIG + * attr-char = ALPHA / DIGIT + * / "!" / "#" / "$" / "&" / "+" / "-" / "." + * / "^" / "_" / "`" / "|" / "~" + */ + +var extValueRegExp = /^([A-Za-z0-9!#$%&+\-^_`{}~]+)'(?:[A-Za-z]{2,3}(?:-[A-Za-z]{3}){0,3}|[A-Za-z]{4,8}|)'((?:%[0-9A-Fa-f]{2}|[A-Za-z0-9!#$&+\-\.^_`|~])+)$/ + +/** + * RegExp for various RFC 6266 grammar + * + * disposition-type = "inline" | "attachment" | disp-ext-type + * disp-ext-type = token + * disposition-parm = filename-parm | disp-ext-parm + * filename-parm = "filename" "=" value + * | "filename*" "=" ext-value + * disp-ext-parm = token "=" value + * | ext-token "=" ext-value + * ext-token = + */ + +var dispositionTypeRegExp = /^([!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) *(?:$|;)/ + +/** + * Create an attachment Content-Disposition header. + * + * @param {string} [filename] + * @param {object} [options] + * @param {string} [options.type=attachment] + * @param {string|boolean} [options.fallback=true] + * @return {string} + * @api public + */ + +function contentDisposition(filename, options) { + var opts = options || {} + + // get type + var type = opts.type || 'attachment' + + // get parameters + var params = createparams(filename, opts.fallback) + + // format into string + return format(new ContentDisposition(type, params)) +} + +/** + * Create parameters object from filename and fallback. + * + * @param {string} [filename] + * @param {string|boolean} [fallback=true] + * @return {object} + * @api private + */ + +function createparams(filename, fallback) { + if (filename === undefined) { + return + } + + var params = {} + + if (typeof filename !== 'string') { + throw new TypeError('filename must be a string') + } + + // fallback defaults to true + if (fallback === undefined) { + fallback = true + } + + if (typeof fallback !== 'string' && typeof fallback !== 'boolean') { + throw new TypeError('fallback must be a string or boolean') + } + + if (typeof fallback === 'string' && nonLatin1RegExp.test(fallback)) { + throw new TypeError('fallback must be ISO-8859-1 string') + } + + // restrict to file base name + var name = basename(filename) + + // determine if name is suitable for quoted string + var isQuotedString = textRegExp.test(name) + + // generate fallback name + var fallbackName = typeof fallback !== 'string' + ? fallback && getlatin1(name) + : basename(fallback) + var hasFallback = typeof fallbackName === 'string' && fallbackName !== name + + // set extended filename parameter + if (hasFallback || !isQuotedString || hexEscapeRegExp.test(name)) { + params['filename*'] = name + } + + // set filename parameter + if (isQuotedString || hasFallback) { + params.filename = hasFallback + ? fallbackName + : name + } + + return params +} + +/** + * Format object to Content-Disposition header. + * + * @param {object} obj + * @param {string} obj.type + * @param {object} [obj.parameters] + * @return {string} + * @api private + */ + +function format(obj) { + var parameters = obj.parameters + var type = obj.type + + if (!type || typeof type !== 'string' || !tokenRegExp.test(type)) { + throw new TypeError('invalid type') + } + + // start with normalized type + var string = String(type).toLowerCase() + + // append parameters + if (parameters && typeof parameters === 'object') { + var param + var params = Object.keys(parameters).sort() + + for (var i = 0; i < params.length; i++) { + param = params[i] + + var val = param.substr(-1) === '*' + ? ustring(parameters[param]) + : qstring(parameters[param]) + + string += '; ' + param + '=' + val + } + } + + return string +} + +/** + * Decode a RFC 6987 field value (gracefully). + * + * @param {string} str + * @return {string} + * @api private + */ + +function decodefield(str) { + var match = extValueRegExp.exec(str) + + if (!match) { + throw new TypeError('invalid extended field value') + } + + var charset = match[1].toLowerCase() + var encoded = match[2] + var value + + // to binary string + var binary = encoded.replace(hexEscapeReplaceRegExp, pdecode) + + switch (charset) { + case 'iso-8859-1': + value = getlatin1(binary) + break + case 'utf-8': + value = new Buffer(binary, 'binary').toString('utf8') + break + default: + throw new TypeError('unsupported charset in extended field') + } + + return value +} + +/** + * Get ISO-8859-1 version of string. + * + * @param {string} val + * @return {string} + * @api private + */ + +function getlatin1(val) { + // simple Unicode -> ISO-8859-1 transformation + return String(val).replace(nonLatin1RegExp, '?') +} + +/** + * Parse Content-Disposition header string. + * + * @param {string} string + * @return {object} + * @api private + */ + +function parse(string) { + if (!string || typeof string !== 'string') { + throw new TypeError('argument string is required') + } + + var match = dispositionTypeRegExp.exec(string) + + if (!match) { + throw new TypeError('invalid type format') + } + + // normalize type + var index = match[0].length + var type = match[1].toLowerCase() + + var key + var names = [] + var params = {} + var value + + // calculate index to start at + index = paramRegExp.lastIndex = match[0].substr(-1) === ';' + ? index - 1 + : index + + // match parameters + while (match = paramRegExp.exec(string)) { + if (match.index !== index) { + throw new TypeError('invalid parameter format') + } + + index += match[0].length + key = match[1].toLowerCase() + value = match[2] + + if (names.indexOf(key) !== -1) { + throw new TypeError('invalid duplicate parameter') + } + + names.push(key) + + if (key.indexOf('*') + 1 === key.length) { + // decode extended value + key = key.slice(0, -1) + value = decodefield(value) + + // overwrite existing value + params[key] = value + continue + } + + if (typeof params[key] === 'string') { + continue + } + + if (value[0] === '"') { + // remove quotes and escapes + value = value + .substr(1, value.length - 2) + .replace(qescRegExp, '$1') + } + + params[key] = value + } + + if (index !== -1 && index !== string.length) { + throw new TypeError('invalid parameter format') + } + + return new ContentDisposition(type, params) +} + +/** + * Percent decode a single character. + * + * @param {string} str + * @param {string} hex + * @return {string} + * @api private + */ + +function pdecode(str, hex) { + return String.fromCharCode(parseInt(hex, 16)) +} + +/** + * Percent encode a single character. + * + * @param {string} char + * @return {string} + * @api private + */ + +function pencode(char) { + var hex = String(char) + .charCodeAt(0) + .toString(16) + .toUpperCase() + return hex.length === 1 + ? '%0' + hex + : '%' + hex +} + +/** + * Quote a string for HTTP. + * + * @param {string} val + * @return {string} + * @api private + */ + +function qstring(val) { + var str = String(val) + + return '"' + str.replace(quoteRegExp, '\\$1') + '"' +} + +/** + * Encode a Unicode string for HTTP (RFC 5987). + * + * @param {string} val + * @return {string} + * @api private + */ + +function ustring(val) { + var str = String(val) + + // percent encode as UTF-8 + var encoded = encodeURIComponent(str) + .replace(encodeUriAttrCharRegExp, pencode) + + return 'UTF-8\'\'' + encoded +} + +/** + * Class for parsed Content-Disposition header for v8 optimization + */ + +function ContentDisposition(type, parameters) { + this.type = type + this.parameters = parameters +} diff --git a/ui/node_modules/express/node_modules/content-disposition/package.json b/ui/node_modules/express/node_modules/content-disposition/package.json index 80ec2782..ef77d51e 100644 --- a/ui/node_modules/express/node_modules/content-disposition/package.json +++ b/ui/node_modules/express/node_modules/content-disposition/package.json @@ -1,66 +1,66 @@ -{ - "name": "content-disposition", - "description": "Create and parse Content-Disposition header", - "version": "0.5.1", - "contributors": [ - { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - } - ], - "license": "MIT", - "keywords": [ - "content-disposition", - "http", - "rfc6266", - "res" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/content-disposition.git" - }, - "devDependencies": { - "istanbul": "0.4.2", - "mocha": "1.21.5" - }, - "files": [ - "LICENSE", - "HISTORY.md", - "README.md", - "index.js" - ], - "engines": { - "node": ">= 0.6" - }, - "scripts": { - "test": "mocha --reporter spec --bail --check-leaks test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" - }, - "gitHead": "7b391db3af5629d4c698f1de21802940bb9f22a5", - "bugs": { - "url": "https://github.com/jshttp/content-disposition/issues" - }, - "homepage": "https://github.com/jshttp/content-disposition", - "_id": "content-disposition@0.5.1", - "_shasum": "87476c6a67c8daa87e32e87616df883ba7fb071b", - "_from": "content-disposition@0.5.1", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "87476c6a67c8daa87e32e87616df883ba7fb071b", - "tarball": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.1.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.1.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "content-disposition", + "description": "Create and parse Content-Disposition header", + "version": "0.5.1", + "contributors": [ + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + } + ], + "license": "MIT", + "keywords": [ + "content-disposition", + "http", + "rfc6266", + "res" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/content-disposition.git" + }, + "devDependencies": { + "istanbul": "0.4.2", + "mocha": "1.21.5" + }, + "files": [ + "LICENSE", + "HISTORY.md", + "README.md", + "index.js" + ], + "engines": { + "node": ">= 0.6" + }, + "scripts": { + "test": "mocha --reporter spec --bail --check-leaks test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" + }, + "gitHead": "7b391db3af5629d4c698f1de21802940bb9f22a5", + "bugs": { + "url": "https://github.com/jshttp/content-disposition/issues" + }, + "homepage": "https://github.com/jshttp/content-disposition", + "_id": "content-disposition@0.5.1", + "_shasum": "87476c6a67c8daa87e32e87616df883ba7fb071b", + "_from": "content-disposition@0.5.1", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "maintainers": [ + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + } + ], + "dist": { + "shasum": "87476c6a67c8daa87e32e87616df883ba7fb071b", + "tarball": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.1.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.1.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/content-type/HISTORY.md b/ui/node_modules/express/node_modules/content-type/HISTORY.md index 42323cc3..01652ff4 100644 --- a/ui/node_modules/express/node_modules/content-type/HISTORY.md +++ b/ui/node_modules/express/node_modules/content-type/HISTORY.md @@ -1,14 +1,14 @@ -1.0.2 / 2016-05-09 -================== - - * perf: enable strict mode - -1.0.1 / 2015-02-13 -================== - - * Improve missing `Content-Type` header error message - -1.0.0 / 2015-02-01 -================== - - * Initial implementation, derived from `media-typer@0.3.0` +1.0.2 / 2016-05-09 +================== + + * perf: enable strict mode + +1.0.1 / 2015-02-13 +================== + + * Improve missing `Content-Type` header error message + +1.0.0 / 2015-02-01 +================== + + * Initial implementation, derived from `media-typer@0.3.0` diff --git a/ui/node_modules/express/node_modules/content-type/LICENSE b/ui/node_modules/express/node_modules/content-type/LICENSE index d09070c4..34b1a2de 100644 --- a/ui/node_modules/express/node_modules/content-type/LICENSE +++ b/ui/node_modules/express/node_modules/content-type/LICENSE @@ -1,22 +1,22 @@ -(The MIT License) - -Copyright (c) 2015 Douglas Christopher Wilson - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2015 Douglas Christopher Wilson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/content-type/README.md b/ui/node_modules/express/node_modules/content-type/README.md index c40521aa..3ed67413 100644 --- a/ui/node_modules/express/node_modules/content-type/README.md +++ b/ui/node_modules/express/node_modules/content-type/README.md @@ -1,92 +1,92 @@ -# content-type - -[![NPM Version][npm-image]][npm-url] -[![NPM Downloads][downloads-image]][downloads-url] -[![Node.js Version][node-version-image]][node-version-url] -[![Build Status][travis-image]][travis-url] -[![Test Coverage][coveralls-image]][coveralls-url] - -Create and parse HTTP Content-Type header according to RFC 7231 - -## Installation - -```sh -$ npm install content-type -``` - -## API - -```js -var contentType = require('content-type') -``` - -### contentType.parse(string) - -```js -var obj = contentType.parse('image/svg+xml; charset=utf-8') -``` - -Parse a content type string. This will return an object with the following -properties (examples are shown for the string `'image/svg+xml; charset=utf-8'`): - - - `type`: The media type (the type and subtype, always lower case). - Example: `'image/svg+xml'` - - - `parameters`: An object of the parameters in the media type (name of parameter - always lower case). Example: `{charset: 'utf-8'}` - -Throws a `TypeError` if the string is missing or invalid. - -### contentType.parse(req) - -```js -var obj = contentType.parse(req) -``` - -Parse the `content-type` header from the given `req`. Short-cut for -`contentType.parse(req.headers['content-type'])`. - -Throws a `TypeError` if the `Content-Type` header is missing or invalid. - -### contentType.parse(res) - -```js -var obj = contentType.parse(res) -``` - -Parse the `content-type` header set on the given `res`. Short-cut for -`contentType.parse(res.getHeader('content-type'))`. - -Throws a `TypeError` if the `Content-Type` header is missing or invalid. - -### contentType.format(obj) - -```js -var str = contentType.format({type: 'image/svg+xml'}) -``` - -Format an object into a content type string. This will return a string of the -content type for the given object with the following properties (examples are -shown that produce the string `'image/svg+xml; charset=utf-8'`): - - - `type`: The media type (will be lower-cased). Example: `'image/svg+xml'` - - - `parameters`: An object of the parameters in the media type (name of the - parameter will be lower-cased). Example: `{charset: 'utf-8'}` - -Throws a `TypeError` if the object contains an invalid type or parameter names. - -## License - -[MIT](LICENSE) - -[npm-image]: https://img.shields.io/npm/v/content-type.svg -[npm-url]: https://npmjs.org/package/content-type -[node-version-image]: https://img.shields.io/node/v/content-type.svg -[node-version-url]: http://nodejs.org/download/ -[travis-image]: https://img.shields.io/travis/jshttp/content-type/master.svg -[travis-url]: https://travis-ci.org/jshttp/content-type -[coveralls-image]: https://img.shields.io/coveralls/jshttp/content-type/master.svg -[coveralls-url]: https://coveralls.io/r/jshttp/content-type -[downloads-image]: https://img.shields.io/npm/dm/content-type.svg -[downloads-url]: https://npmjs.org/package/content-type +# content-type + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-version-image]][node-version-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +Create and parse HTTP Content-Type header according to RFC 7231 + +## Installation + +```sh +$ npm install content-type +``` + +## API + +```js +var contentType = require('content-type') +``` + +### contentType.parse(string) + +```js +var obj = contentType.parse('image/svg+xml; charset=utf-8') +``` + +Parse a content type string. This will return an object with the following +properties (examples are shown for the string `'image/svg+xml; charset=utf-8'`): + + - `type`: The media type (the type and subtype, always lower case). + Example: `'image/svg+xml'` + + - `parameters`: An object of the parameters in the media type (name of parameter + always lower case). Example: `{charset: 'utf-8'}` + +Throws a `TypeError` if the string is missing or invalid. + +### contentType.parse(req) + +```js +var obj = contentType.parse(req) +``` + +Parse the `content-type` header from the given `req`. Short-cut for +`contentType.parse(req.headers['content-type'])`. + +Throws a `TypeError` if the `Content-Type` header is missing or invalid. + +### contentType.parse(res) + +```js +var obj = contentType.parse(res) +``` + +Parse the `content-type` header set on the given `res`. Short-cut for +`contentType.parse(res.getHeader('content-type'))`. + +Throws a `TypeError` if the `Content-Type` header is missing or invalid. + +### contentType.format(obj) + +```js +var str = contentType.format({type: 'image/svg+xml'}) +``` + +Format an object into a content type string. This will return a string of the +content type for the given object with the following properties (examples are +shown that produce the string `'image/svg+xml; charset=utf-8'`): + + - `type`: The media type (will be lower-cased). Example: `'image/svg+xml'` + + - `parameters`: An object of the parameters in the media type (name of the + parameter will be lower-cased). Example: `{charset: 'utf-8'}` + +Throws a `TypeError` if the object contains an invalid type or parameter names. + +## License + +[MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/content-type.svg +[npm-url]: https://npmjs.org/package/content-type +[node-version-image]: https://img.shields.io/node/v/content-type.svg +[node-version-url]: http://nodejs.org/download/ +[travis-image]: https://img.shields.io/travis/jshttp/content-type/master.svg +[travis-url]: https://travis-ci.org/jshttp/content-type +[coveralls-image]: https://img.shields.io/coveralls/jshttp/content-type/master.svg +[coveralls-url]: https://coveralls.io/r/jshttp/content-type +[downloads-image]: https://img.shields.io/npm/dm/content-type.svg +[downloads-url]: https://npmjs.org/package/content-type diff --git a/ui/node_modules/express/node_modules/content-type/index.js b/ui/node_modules/express/node_modules/content-type/index.js index 83797bae..61ba6b5a 100644 --- a/ui/node_modules/express/node_modules/content-type/index.js +++ b/ui/node_modules/express/node_modules/content-type/index.js @@ -1,216 +1,216 @@ -/*! - * content-type - * Copyright(c) 2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict' - -/** - * RegExp to match *( ";" parameter ) in RFC 7231 sec 3.1.1.1 - * - * parameter = token "=" ( token / quoted-string ) - * token = 1*tchar - * tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" - * / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~" - * / DIGIT / ALPHA - * ; any VCHAR, except delimiters - * quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE - * qdtext = HTAB / SP / %x21 / %x23-5B / %x5D-7E / obs-text - * obs-text = %x80-FF - * quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text ) - */ -var paramRegExp = /; *([!#$%&'\*\+\-\.\^_`\|~0-9A-Za-z]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'\*\+\-\.\^_`\|~0-9A-Za-z]+) */g -var textRegExp = /^[\u000b\u0020-\u007e\u0080-\u00ff]+$/ -var tokenRegExp = /^[!#$%&'\*\+\-\.\^_`\|~0-9A-Za-z]+$/ - -/** - * RegExp to match quoted-pair in RFC 7230 sec 3.2.6 - * - * quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text ) - * obs-text = %x80-FF - */ -var qescRegExp = /\\([\u000b\u0020-\u00ff])/g - -/** - * RegExp to match chars that must be quoted-pair in RFC 7230 sec 3.2.6 - */ -var quoteRegExp = /([\\"])/g - -/** - * RegExp to match type in RFC 6838 - * - * media-type = type "/" subtype - * type = token - * subtype = token - */ -var typeRegExp = /^[!#$%&'\*\+\-\.\^_`\|~0-9A-Za-z]+\/[!#$%&'\*\+\-\.\^_`\|~0-9A-Za-z]+$/ - -/** - * Module exports. - * @public - */ - -exports.format = format -exports.parse = parse - -/** - * Format object to media type. - * - * @param {object} obj - * @return {string} - * @public - */ - -function format(obj) { - if (!obj || typeof obj !== 'object') { - throw new TypeError('argument obj is required') - } - - var parameters = obj.parameters - var type = obj.type - - if (!type || !typeRegExp.test(type)) { - throw new TypeError('invalid type') - } - - var string = type - - // append parameters - if (parameters && typeof parameters === 'object') { - var param - var params = Object.keys(parameters).sort() - - for (var i = 0; i < params.length; i++) { - param = params[i] - - if (!tokenRegExp.test(param)) { - throw new TypeError('invalid parameter name') - } - - string += '; ' + param + '=' + qstring(parameters[param]) - } - } - - return string -} - -/** - * Parse media type to object. - * - * @param {string|object} string - * @return {Object} - * @public - */ - -function parse(string) { - if (!string) { - throw new TypeError('argument string is required') - } - - if (typeof string === 'object') { - // support req/res-like objects as argument - string = getcontenttype(string) - - if (typeof string !== 'string') { - throw new TypeError('content-type header is missing from object'); - } - } - - if (typeof string !== 'string') { - throw new TypeError('argument string is required to be a string') - } - - var index = string.indexOf(';') - var type = index !== -1 - ? string.substr(0, index).trim() - : string.trim() - - if (!typeRegExp.test(type)) { - throw new TypeError('invalid media type') - } - - var key - var match - var obj = new ContentType(type.toLowerCase()) - var value - - paramRegExp.lastIndex = index - - while (match = paramRegExp.exec(string)) { - if (match.index !== index) { - throw new TypeError('invalid parameter format') - } - - index += match[0].length - key = match[1].toLowerCase() - value = match[2] - - if (value[0] === '"') { - // remove quotes and escapes - value = value - .substr(1, value.length - 2) - .replace(qescRegExp, '$1') - } - - obj.parameters[key] = value - } - - if (index !== -1 && index !== string.length) { - throw new TypeError('invalid parameter format') - } - - return obj -} - -/** - * Get content-type from req/res objects. - * - * @param {object} - * @return {Object} - * @private - */ - -function getcontenttype(obj) { - if (typeof obj.getHeader === 'function') { - // res-like - return obj.getHeader('content-type') - } - - if (typeof obj.headers === 'object') { - // req-like - return obj.headers && obj.headers['content-type'] - } -} - -/** - * Quote a string if necessary. - * - * @param {string} val - * @return {string} - * @private - */ - -function qstring(val) { - var str = String(val) - - // no need to quote tokens - if (tokenRegExp.test(str)) { - return str - } - - if (str.length > 0 && !textRegExp.test(str)) { - throw new TypeError('invalid parameter value') - } - - return '"' + str.replace(quoteRegExp, '\\$1') + '"' -} - -/** - * Class to represent a content type. - * @private - */ -function ContentType(type) { - this.parameters = Object.create(null) - this.type = type -} +/*! + * content-type + * Copyright(c) 2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * RegExp to match *( ";" parameter ) in RFC 7231 sec 3.1.1.1 + * + * parameter = token "=" ( token / quoted-string ) + * token = 1*tchar + * tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" + * / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~" + * / DIGIT / ALPHA + * ; any VCHAR, except delimiters + * quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE + * qdtext = HTAB / SP / %x21 / %x23-5B / %x5D-7E / obs-text + * obs-text = %x80-FF + * quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text ) + */ +var paramRegExp = /; *([!#$%&'\*\+\-\.\^_`\|~0-9A-Za-z]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'\*\+\-\.\^_`\|~0-9A-Za-z]+) */g +var textRegExp = /^[\u000b\u0020-\u007e\u0080-\u00ff]+$/ +var tokenRegExp = /^[!#$%&'\*\+\-\.\^_`\|~0-9A-Za-z]+$/ + +/** + * RegExp to match quoted-pair in RFC 7230 sec 3.2.6 + * + * quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text ) + * obs-text = %x80-FF + */ +var qescRegExp = /\\([\u000b\u0020-\u00ff])/g + +/** + * RegExp to match chars that must be quoted-pair in RFC 7230 sec 3.2.6 + */ +var quoteRegExp = /([\\"])/g + +/** + * RegExp to match type in RFC 6838 + * + * media-type = type "/" subtype + * type = token + * subtype = token + */ +var typeRegExp = /^[!#$%&'\*\+\-\.\^_`\|~0-9A-Za-z]+\/[!#$%&'\*\+\-\.\^_`\|~0-9A-Za-z]+$/ + +/** + * Module exports. + * @public + */ + +exports.format = format +exports.parse = parse + +/** + * Format object to media type. + * + * @param {object} obj + * @return {string} + * @public + */ + +function format(obj) { + if (!obj || typeof obj !== 'object') { + throw new TypeError('argument obj is required') + } + + var parameters = obj.parameters + var type = obj.type + + if (!type || !typeRegExp.test(type)) { + throw new TypeError('invalid type') + } + + var string = type + + // append parameters + if (parameters && typeof parameters === 'object') { + var param + var params = Object.keys(parameters).sort() + + for (var i = 0; i < params.length; i++) { + param = params[i] + + if (!tokenRegExp.test(param)) { + throw new TypeError('invalid parameter name') + } + + string += '; ' + param + '=' + qstring(parameters[param]) + } + } + + return string +} + +/** + * Parse media type to object. + * + * @param {string|object} string + * @return {Object} + * @public + */ + +function parse(string) { + if (!string) { + throw new TypeError('argument string is required') + } + + if (typeof string === 'object') { + // support req/res-like objects as argument + string = getcontenttype(string) + + if (typeof string !== 'string') { + throw new TypeError('content-type header is missing from object'); + } + } + + if (typeof string !== 'string') { + throw new TypeError('argument string is required to be a string') + } + + var index = string.indexOf(';') + var type = index !== -1 + ? string.substr(0, index).trim() + : string.trim() + + if (!typeRegExp.test(type)) { + throw new TypeError('invalid media type') + } + + var key + var match + var obj = new ContentType(type.toLowerCase()) + var value + + paramRegExp.lastIndex = index + + while (match = paramRegExp.exec(string)) { + if (match.index !== index) { + throw new TypeError('invalid parameter format') + } + + index += match[0].length + key = match[1].toLowerCase() + value = match[2] + + if (value[0] === '"') { + // remove quotes and escapes + value = value + .substr(1, value.length - 2) + .replace(qescRegExp, '$1') + } + + obj.parameters[key] = value + } + + if (index !== -1 && index !== string.length) { + throw new TypeError('invalid parameter format') + } + + return obj +} + +/** + * Get content-type from req/res objects. + * + * @param {object} + * @return {Object} + * @private + */ + +function getcontenttype(obj) { + if (typeof obj.getHeader === 'function') { + // res-like + return obj.getHeader('content-type') + } + + if (typeof obj.headers === 'object') { + // req-like + return obj.headers && obj.headers['content-type'] + } +} + +/** + * Quote a string if necessary. + * + * @param {string} val + * @return {string} + * @private + */ + +function qstring(val) { + var str = String(val) + + // no need to quote tokens + if (tokenRegExp.test(str)) { + return str + } + + if (str.length > 0 && !textRegExp.test(str)) { + throw new TypeError('invalid parameter value') + } + + return '"' + str.replace(quoteRegExp, '\\$1') + '"' +} + +/** + * Class to represent a content type. + * @private + */ +function ContentType(type) { + this.parameters = Object.create(null) + this.type = type +} diff --git a/ui/node_modules/express/node_modules/content-type/package.json b/ui/node_modules/express/node_modules/content-type/package.json index b72fad00..9f110914 100644 --- a/ui/node_modules/express/node_modules/content-type/package.json +++ b/ui/node_modules/express/node_modules/content-type/package.json @@ -1,70 +1,70 @@ -{ - "name": "content-type", - "description": "Create and parse HTTP Content-Type header", - "version": "1.0.2", - "author": { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - }, - "license": "MIT", - "keywords": [ - "content-type", - "http", - "req", - "res", - "rfc7231" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/content-type.git" - }, - "devDependencies": { - "istanbul": "0.4.3", - "mocha": "~1.21.5" - }, - "files": [ - "LICENSE", - "HISTORY.md", - "README.md", - "index.js" - ], - "engines": { - "node": ">= 0.6" - }, - "scripts": { - "test": "mocha --reporter spec --check-leaks --bail test/", - "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/" - }, - "gitHead": "8118763adfbbac80cf1254191889330aec8b8be7", - "bugs": { - "url": "https://github.com/jshttp/content-type/issues" - }, - "homepage": "https://github.com/jshttp/content-type#readme", - "_id": "content-type@1.0.2", - "_shasum": "b7d113aee7a8dd27bd21133c4dc2529df1721eed", - "_from": "content-type@>=1.0.2 <1.1.0", - "_npmVersion": "2.15.1", - "_nodeVersion": "4.4.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "b7d113aee7a8dd27bd21133c4dc2529df1721eed", - "tarball": "https://registry.npmjs.org/content-type/-/content-type-1.0.2.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/content-type-1.0.2.tgz_1462852785748_0.5491233412176371" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.2.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "content-type", + "description": "Create and parse HTTP Content-Type header", + "version": "1.0.2", + "author": { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + }, + "license": "MIT", + "keywords": [ + "content-type", + "http", + "req", + "res", + "rfc7231" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/content-type.git" + }, + "devDependencies": { + "istanbul": "0.4.3", + "mocha": "~1.21.5" + }, + "files": [ + "LICENSE", + "HISTORY.md", + "README.md", + "index.js" + ], + "engines": { + "node": ">= 0.6" + }, + "scripts": { + "test": "mocha --reporter spec --check-leaks --bail test/", + "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/" + }, + "gitHead": "8118763adfbbac80cf1254191889330aec8b8be7", + "bugs": { + "url": "https://github.com/jshttp/content-type/issues" + }, + "homepage": "https://github.com/jshttp/content-type#readme", + "_id": "content-type@1.0.2", + "_shasum": "b7d113aee7a8dd27bd21133c4dc2529df1721eed", + "_from": "content-type@>=1.0.2 <1.1.0", + "_npmVersion": "2.15.1", + "_nodeVersion": "4.4.3", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "dist": { + "shasum": "b7d113aee7a8dd27bd21133c4dc2529df1721eed", + "tarball": "https://registry.npmjs.org/content-type/-/content-type-1.0.2.tgz" + }, + "maintainers": [ + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + } + ], + "_npmOperationalInternal": { + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/content-type-1.0.2.tgz_1462852785748_0.5491233412176371" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.2.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/cookie-signature/.npmignore b/ui/node_modules/express/node_modules/cookie-signature/.npmignore index 47c4a951..f1250e58 100644 --- a/ui/node_modules/express/node_modules/cookie-signature/.npmignore +++ b/ui/node_modules/express/node_modules/cookie-signature/.npmignore @@ -1,4 +1,4 @@ -support -test -examples -*.sock +support +test +examples +*.sock diff --git a/ui/node_modules/express/node_modules/cookie-signature/History.md b/ui/node_modules/express/node_modules/cookie-signature/History.md index 03e4e6a5..78513cc3 100644 --- a/ui/node_modules/express/node_modules/cookie-signature/History.md +++ b/ui/node_modules/express/node_modules/cookie-signature/History.md @@ -1,38 +1,38 @@ -1.0.6 / 2015-02-03 -================== - -* use `npm test` instead of `make test` to run tests -* clearer assertion messages when checking input - - -1.0.5 / 2014-09-05 -================== - -* add license to package.json - -1.0.4 / 2014-06-25 -================== - - * corrected avoidance of timing attacks (thanks @tenbits!) - -1.0.3 / 2014-01-28 -================== - - * [incorrect] fix for timing attacks - -1.0.2 / 2014-01-28 -================== - - * fix missing repository warning - * fix typo in test - -1.0.1 / 2013-04-15 -================== - - * Revert "Changed underlying HMAC algo. to sha512." - * Revert "Fix for timing attacks on MAC verification." - -0.0.1 / 2010-01-03 -================== - - * Initial release +1.0.6 / 2015-02-03 +================== + +* use `npm test` instead of `make test` to run tests +* clearer assertion messages when checking input + + +1.0.5 / 2014-09-05 +================== + +* add license to package.json + +1.0.4 / 2014-06-25 +================== + + * corrected avoidance of timing attacks (thanks @tenbits!) + +1.0.3 / 2014-01-28 +================== + + * [incorrect] fix for timing attacks + +1.0.2 / 2014-01-28 +================== + + * fix missing repository warning + * fix typo in test + +1.0.1 / 2013-04-15 +================== + + * Revert "Changed underlying HMAC algo. to sha512." + * Revert "Fix for timing attacks on MAC verification." + +0.0.1 / 2010-01-03 +================== + + * Initial release diff --git a/ui/node_modules/express/node_modules/cookie-signature/Readme.md b/ui/node_modules/express/node_modules/cookie-signature/Readme.md index 88d3e899..2559e841 100644 --- a/ui/node_modules/express/node_modules/cookie-signature/Readme.md +++ b/ui/node_modules/express/node_modules/cookie-signature/Readme.md @@ -1,42 +1,42 @@ - -# cookie-signature - - Sign and unsign cookies. - -## Example - -```js -var cookie = require('cookie-signature'); - -var val = cookie.sign('hello', 'tobiiscool'); -val.should.equal('hello.DGDUkGlIkCzPz+C0B064FNgHdEjox7ch8tOBGslZ5QI'); - -var val = cookie.sign('hello', 'tobiiscool'); -cookie.unsign(val, 'tobiiscool').should.equal('hello'); -cookie.unsign(val, 'luna').should.be.false; -``` - -## License - -(The MIT License) - -Copyright (c) 2012 LearnBoost <tj@learnboost.com> - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + +# cookie-signature + + Sign and unsign cookies. + +## Example + +```js +var cookie = require('cookie-signature'); + +var val = cookie.sign('hello', 'tobiiscool'); +val.should.equal('hello.DGDUkGlIkCzPz+C0B064FNgHdEjox7ch8tOBGslZ5QI'); + +var val = cookie.sign('hello', 'tobiiscool'); +cookie.unsign(val, 'tobiiscool').should.equal('hello'); +cookie.unsign(val, 'luna').should.be.false; +``` + +## License + +(The MIT License) + +Copyright (c) 2012 LearnBoost <tj@learnboost.com> + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/ui/node_modules/express/node_modules/cookie-signature/index.js b/ui/node_modules/express/node_modules/cookie-signature/index.js index 1f2a1f4f..b8c9463a 100644 --- a/ui/node_modules/express/node_modules/cookie-signature/index.js +++ b/ui/node_modules/express/node_modules/cookie-signature/index.js @@ -1,51 +1,51 @@ -/** - * Module dependencies. - */ - -var crypto = require('crypto'); - -/** - * Sign the given `val` with `secret`. - * - * @param {String} val - * @param {String} secret - * @return {String} - * @api private - */ - -exports.sign = function(val, secret){ - if ('string' != typeof val) throw new TypeError("Cookie value must be provided as a string."); - if ('string' != typeof secret) throw new TypeError("Secret string must be provided."); - return val + '.' + crypto - .createHmac('sha256', secret) - .update(val) - .digest('base64') - .replace(/\=+$/, ''); -}; - -/** - * Unsign and decode the given `val` with `secret`, - * returning `false` if the signature is invalid. - * - * @param {String} val - * @param {String} secret - * @return {String|Boolean} - * @api private - */ - -exports.unsign = function(val, secret){ - if ('string' != typeof val) throw new TypeError("Signed cookie string must be provided."); - if ('string' != typeof secret) throw new TypeError("Secret string must be provided."); - var str = val.slice(0, val.lastIndexOf('.')) - , mac = exports.sign(str, secret); - - return sha1(mac) == sha1(val) ? str : false; -}; - -/** - * Private - */ - -function sha1(str){ - return crypto.createHash('sha1').update(str).digest('hex'); -} +/** + * Module dependencies. + */ + +var crypto = require('crypto'); + +/** + * Sign the given `val` with `secret`. + * + * @param {String} val + * @param {String} secret + * @return {String} + * @api private + */ + +exports.sign = function(val, secret){ + if ('string' != typeof val) throw new TypeError("Cookie value must be provided as a string."); + if ('string' != typeof secret) throw new TypeError("Secret string must be provided."); + return val + '.' + crypto + .createHmac('sha256', secret) + .update(val) + .digest('base64') + .replace(/\=+$/, ''); +}; + +/** + * Unsign and decode the given `val` with `secret`, + * returning `false` if the signature is invalid. + * + * @param {String} val + * @param {String} secret + * @return {String|Boolean} + * @api private + */ + +exports.unsign = function(val, secret){ + if ('string' != typeof val) throw new TypeError("Signed cookie string must be provided."); + if ('string' != typeof secret) throw new TypeError("Secret string must be provided."); + var str = val.slice(0, val.lastIndexOf('.')) + , mac = exports.sign(str, secret); + + return sha1(mac) == sha1(val) ? str : false; +}; + +/** + * Private + */ + +function sha1(str){ + return crypto.createHash('sha1').update(str).digest('hex'); +} diff --git a/ui/node_modules/express/node_modules/cookie-signature/package.json b/ui/node_modules/express/node_modules/cookie-signature/package.json index 65a333d6..f564ea54 100644 --- a/ui/node_modules/express/node_modules/cookie-signature/package.json +++ b/ui/node_modules/express/node_modules/cookie-signature/package.json @@ -1,59 +1,59 @@ -{ - "name": "cookie-signature", - "version": "1.0.6", - "description": "Sign and unsign cookies", - "keywords": [ - "cookie", - "sign", - "unsign" - ], - "author": { - "name": "TJ Holowaychuk", - "email": "tj@learnboost.com" - }, - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/visionmedia/node-cookie-signature.git" - }, - "dependencies": {}, - "devDependencies": { - "mocha": "*", - "should": "*" - }, - "scripts": { - "test": "mocha --require should --reporter spec" - }, - "main": "index", - "gitHead": "391b56cf44d88c493491b7e3fc53208cfb976d2a", - "bugs": { - "url": "https://github.com/visionmedia/node-cookie-signature/issues" - }, - "homepage": "https://github.com/visionmedia/node-cookie-signature", - "_id": "cookie-signature@1.0.6", - "_shasum": "e303a882b342cc3ee8ca513a79999734dab3ae2c", - "_from": "cookie-signature@1.0.6", - "_npmVersion": "2.3.0", - "_nodeVersion": "0.10.36", - "_npmUser": { - "name": "natevw", - "email": "natevw@yahoo.com" - }, - "maintainers": [ - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - { - "name": "natevw", - "email": "natevw@yahoo.com" - } - ], - "dist": { - "shasum": "e303a882b342cc3ee8ca513a79999734dab3ae2c", - "tarball": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "cookie-signature", + "version": "1.0.6", + "description": "Sign and unsign cookies", + "keywords": [ + "cookie", + "sign", + "unsign" + ], + "author": { + "name": "TJ Holowaychuk", + "email": "tj@learnboost.com" + }, + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/visionmedia/node-cookie-signature.git" + }, + "dependencies": {}, + "devDependencies": { + "mocha": "*", + "should": "*" + }, + "scripts": { + "test": "mocha --require should --reporter spec" + }, + "main": "index", + "gitHead": "391b56cf44d88c493491b7e3fc53208cfb976d2a", + "bugs": { + "url": "https://github.com/visionmedia/node-cookie-signature/issues" + }, + "homepage": "https://github.com/visionmedia/node-cookie-signature", + "_id": "cookie-signature@1.0.6", + "_shasum": "e303a882b342cc3ee8ca513a79999734dab3ae2c", + "_from": "cookie-signature@1.0.6", + "_npmVersion": "2.3.0", + "_nodeVersion": "0.10.36", + "_npmUser": { + "name": "natevw", + "email": "natevw@yahoo.com" + }, + "maintainers": [ + { + "name": "tjholowaychuk", + "email": "tj@vision-media.ca" + }, + { + "name": "natevw", + "email": "natevw@yahoo.com" + } + ], + "dist": { + "shasum": "e303a882b342cc3ee8ca513a79999734dab3ae2c", + "tarball": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/cookie/HISTORY.md b/ui/node_modules/express/node_modules/cookie/HISTORY.md index 9863f7df..5bd64854 100644 --- a/ui/node_modules/express/node_modules/cookie/HISTORY.md +++ b/ui/node_modules/express/node_modules/cookie/HISTORY.md @@ -1,118 +1,118 @@ -0.3.1 / 2016-05-26 -================== - - * Fix `sameSite: true` to work with draft-7 clients - - `true` now sends `SameSite=Strict` instead of `SameSite` - -0.3.0 / 2016-05-26 -================== - - * Add `sameSite` option - - Replaces `firstPartyOnly` option, never implemented by browsers - * Improve error message when `encode` is not a function - * Improve error message when `expires` is not a `Date` - -0.2.4 / 2016-05-20 -================== - - * perf: enable strict mode - * perf: use for loop in parse - * perf: use string concatination for serialization - -0.2.3 / 2015-10-25 -================== - - * Fix cookie `Max-Age` to never be a floating point number - -0.2.2 / 2015-09-17 -================== - - * Fix regression when setting empty cookie value - - Ease the new restriction, which is just basic header-level validation - * Fix typo in invalid value errors - -0.2.1 / 2015-09-17 -================== - - * Throw on invalid values provided to `serialize` - - Ensures the resulting string is a valid HTTP header value - -0.2.0 / 2015-08-13 -================== - - * Add `firstPartyOnly` option - * Throw better error for invalid argument to parse - * perf: hoist regular expression - -0.1.5 / 2015-09-17 -================== - - * Fix regression when setting empty cookie value - - Ease the new restriction, which is just basic header-level validation - * Fix typo in invalid value errors - -0.1.4 / 2015-09-17 -================== - - * Throw better error for invalid argument to parse - * Throw on invalid values provided to `serialize` - - Ensures the resulting string is a valid HTTP header value - -0.1.3 / 2015-05-19 -================== - - * Reduce the scope of try-catch deopt - * Remove argument reassignments - -0.1.2 / 2014-04-16 -================== - - * Remove unnecessary files from npm package - -0.1.1 / 2014-02-23 -================== - - * Fix bad parse when cookie value contained a comma - * Fix support for `maxAge` of `0` - -0.1.0 / 2013-05-01 -================== - - * Add `decode` option - * Add `encode` option - -0.0.6 / 2013-04-08 -================== - - * Ignore cookie parts missing `=` - -0.0.5 / 2012-10-29 -================== - - * Return raw cookie value if value unescape errors - -0.0.4 / 2012-06-21 -================== - - * Use encode/decodeURIComponent for cookie encoding/decoding - - Improve server/client interoperability - -0.0.3 / 2012-06-06 -================== - - * Only escape special characters per the cookie RFC - -0.0.2 / 2012-06-01 -================== - - * Fix `maxAge` option to not throw error - -0.0.1 / 2012-05-28 -================== - - * Add more tests - -0.0.0 / 2012-05-28 -================== - - * Initial release +0.3.1 / 2016-05-26 +================== + + * Fix `sameSite: true` to work with draft-7 clients + - `true` now sends `SameSite=Strict` instead of `SameSite` + +0.3.0 / 2016-05-26 +================== + + * Add `sameSite` option + - Replaces `firstPartyOnly` option, never implemented by browsers + * Improve error message when `encode` is not a function + * Improve error message when `expires` is not a `Date` + +0.2.4 / 2016-05-20 +================== + + * perf: enable strict mode + * perf: use for loop in parse + * perf: use string concatination for serialization + +0.2.3 / 2015-10-25 +================== + + * Fix cookie `Max-Age` to never be a floating point number + +0.2.2 / 2015-09-17 +================== + + * Fix regression when setting empty cookie value + - Ease the new restriction, which is just basic header-level validation + * Fix typo in invalid value errors + +0.2.1 / 2015-09-17 +================== + + * Throw on invalid values provided to `serialize` + - Ensures the resulting string is a valid HTTP header value + +0.2.0 / 2015-08-13 +================== + + * Add `firstPartyOnly` option + * Throw better error for invalid argument to parse + * perf: hoist regular expression + +0.1.5 / 2015-09-17 +================== + + * Fix regression when setting empty cookie value + - Ease the new restriction, which is just basic header-level validation + * Fix typo in invalid value errors + +0.1.4 / 2015-09-17 +================== + + * Throw better error for invalid argument to parse + * Throw on invalid values provided to `serialize` + - Ensures the resulting string is a valid HTTP header value + +0.1.3 / 2015-05-19 +================== + + * Reduce the scope of try-catch deopt + * Remove argument reassignments + +0.1.2 / 2014-04-16 +================== + + * Remove unnecessary files from npm package + +0.1.1 / 2014-02-23 +================== + + * Fix bad parse when cookie value contained a comma + * Fix support for `maxAge` of `0` + +0.1.0 / 2013-05-01 +================== + + * Add `decode` option + * Add `encode` option + +0.0.6 / 2013-04-08 +================== + + * Ignore cookie parts missing `=` + +0.0.5 / 2012-10-29 +================== + + * Return raw cookie value if value unescape errors + +0.0.4 / 2012-06-21 +================== + + * Use encode/decodeURIComponent for cookie encoding/decoding + - Improve server/client interoperability + +0.0.3 / 2012-06-06 +================== + + * Only escape special characters per the cookie RFC + +0.0.2 / 2012-06-01 +================== + + * Fix `maxAge` option to not throw error + +0.0.1 / 2012-05-28 +================== + + * Add more tests + +0.0.0 / 2012-05-28 +================== + + * Initial release diff --git a/ui/node_modules/express/node_modules/cookie/LICENSE b/ui/node_modules/express/node_modules/cookie/LICENSE index e8494959..058b6b4e 100644 --- a/ui/node_modules/express/node_modules/cookie/LICENSE +++ b/ui/node_modules/express/node_modules/cookie/LICENSE @@ -1,24 +1,24 @@ -(The MIT License) - -Copyright (c) 2012-2014 Roman Shtylman -Copyright (c) 2015 Douglas Christopher Wilson - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +(The MIT License) + +Copyright (c) 2012-2014 Roman Shtylman +Copyright (c) 2015 Douglas Christopher Wilson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/ui/node_modules/express/node_modules/cookie/README.md b/ui/node_modules/express/node_modules/cookie/README.md index 75b6056d..db0d0782 100644 --- a/ui/node_modules/express/node_modules/cookie/README.md +++ b/ui/node_modules/express/node_modules/cookie/README.md @@ -1,220 +1,220 @@ -# cookie - -[![NPM Version][npm-image]][npm-url] -[![NPM Downloads][downloads-image]][downloads-url] -[![Node.js Version][node-version-image]][node-version-url] -[![Build Status][travis-image]][travis-url] -[![Test Coverage][coveralls-image]][coveralls-url] - -Basic HTTP cookie parser and serializer for HTTP servers. - -## Installation - -```sh -$ npm install cookie -``` - -## API - -```js -var cookie = require('cookie'); -``` - -### cookie.parse(str, options) - -Parse an HTTP `Cookie` header string and returning an object of all cookie name-value pairs. -The `str` argument is the string representing a `Cookie` header value and `options` is an -optional object containing additional parsing options. - -```js -var cookies = cookie.parse('foo=bar; equation=E%3Dmc%5E2'); -// { foo: 'bar', equation: 'E=mc^2' } -``` - -#### Options - -`cookie.parse` accepts these properties in the options object. - -##### decode - -Specifies a function that will be used to decode a cookie's value. Since the value of a cookie -has a limited character set (and must be a simple string), this function can be used to decode -a previously-encoded cookie value into a JavaScript string or other object. - -The default function is the global `decodeURIComponent`, which will decode any URL-encoded -sequences into their byte representations. - -**note** if an error is thrown from this function, the original, non-decoded cookie value will -be returned as the cookie's value. - -### cookie.serialize(name, value, options) - -Serialize a cookie name-value pair into a `Set-Cookie` header string. The `name` argument is the -name for the cookie, the `value` argument is the value to set the cookie to, and the `options` -argument is an optional object containing additional serialization options. - -```js -var setCookie = cookie.serialize('foo', 'bar'); -// foo=bar -``` - -#### Options - -`cookie.serialize` accepts these properties in the options object. - -##### domain - -Specifies the value for the [`Domain` `Set-Cookie` attribute][rfc-6266-5.2.3]. By default, no -domain is set, and most clients will consider the cookie to apply to only the current domain. - -##### encode - -Specifies a function that will be used to encode a cookie's value. Since value of a cookie -has a limited character set (and must be a simple string), this function can be used to encode -a value into a string suited for a cookie's value. - -The default function is the global `ecodeURIComponent`, which will encode a JavaScript string -into UTF-8 byte sequences and then URL-encode any that fall outside of the cookie range. - -##### expires - -Specifies the `Date` object to be the value for the [`Expires` `Set-Cookie` attribute][rfc-6266-5.2.1]. -By default, no expiration is set, and most clients will consider this a "non-persistent cookie" and -will delete it on a condition like exiting a web browser application. - -**note** the [cookie storage model specification][rfc-6266-5.3] states that if both `expires` and -`magAge` are set, then `maxAge` takes precedence, but it is possiblke not all clients by obey this, -so if both are set, they should point to the same date and time. - -##### httpOnly - -Specifies the `boolean` value for the [`HttpOnly` `Set-Cookie` attribute][rfc-6266-5.2.6]. When truthy, -the `HttpOnly` attribute is set, otherwise it is not. By default, the `HttpOnly` attribute is not set. - -**note** be careful when setting this to `true`, as compliant clients will not allow client-side -JavaScript to see the cookie in `document.cookie`. - -##### maxAge - -Specifies the `number` (in seconds) to be the value for the [`Max-Age` `Set-Cookie` attribute][rfc-6266-5.2.2]. -The given number will be converted to an integer by rounding down. By default, no maximum age is set. - -**note** the [cookie storage model specification][rfc-6266-5.3] states that if both `expires` and -`magAge` are set, then `maxAge` takes precedence, but it is possiblke not all clients by obey this, -so if both are set, they should point to the same date and time. - -##### path - -Specifies the value for the [`Path` `Set-Cookie` attribute][rfc-6266-5.2.4]. By default, the path -is considered the ["default path"][rfc-6266-5.1.4]. By default, no maximum age is set, and most -clients will consider this a "non-persistent cookie" and will delete it on a condition like exiting -a web browser application. - -##### sameSite - -Specifies the `boolean` or `string` to be the value for the [`SameSite` `Set-Cookie` attribute][draft-west-first-party-cookies-07]. - - - `true` will set the `SameSite` attribute to `Strict` for strict same site enforcement. - - `false` will not set the `SameSite` attribute. - - `'lax'` will set the `SameSite` attribute to `Lax` for lax same site enforcement. - - `'strict'` will set the `SameSite` attribute to `Strict` for strict same site enforcement. - -More information about the different enforcement levels can be found in the specification -https://tools.ietf.org/html/draft-west-first-party-cookies-07#section-4.1.1 - -**note** This is an attribute that has not yet been fully standardized, and may change in the future. -This also means many clients may ignore this attribute until they understand it. - -##### secure - -Specifies the `boolean` value for the [`Secure` `Set-Cookie` attribute][rfc-6266-5.2.5]. When truthy, -the `Secure` attribute is set, otherwise it is not. By default, the `Secure` attribute is not set. - -**note** be careful when setting this to `true`, as compliant clients will not send the cookie back to -the server in the future if the browser does not have an HTTPS connection. - -## Example - -The following example uses this module in conjunction with the Node.js core HTTP server -to prompt a user for their name and display it back on future visits. - -```js -var cookie = require('cookie'); -var escapeHtml = require('escape-html'); -var http = require('http'); -var url = require('url'); - -function onRequest(req, res) { - // Parse the query string - var query = url.parse(req.url, true, true).query; - - if (query && query.name) { - // Set a new cookie with the name - res.setHeader('Set-Cookie', cookie.serialize('name', String(query.name), { - httpOnly: true, - maxAge: 60 * 60 * 24 * 7 // 1 week - })); - - // Redirect back after setting cookie - res.statusCode = 302; - res.setHeader('Location', req.headers.referer || '/'); - res.end(); - return; - } - - // Parse the cookies on the request - var cookies = cookie.parse(req.headers.cookie || ''); - - // Get the visitor name set in the cookie - var name = cookies.name; - - res.setHeader('Content-Type', 'text/html; charset=UTF-8'); - - if (name) { - res.write('

Welcome back, ' + escapeHtml(name) + '!

'); - } else { - res.write('

Hello, new visitor!

'); - } - - res.write('
'); - res.write(' '); - res.end('Welcome back, ' + escapeHtml(name) + '!

'); + } else { + res.write('

Hello, new visitor!

'); + } + + res.write(''); + res.write(' '); + res.end(' values - * - * @param {string} str - * @param {object} [options] - * @return {object} - * @public - */ - -function parse(str, options) { - if (typeof str !== 'string') { - throw new TypeError('argument str must be a string'); - } - - var obj = {} - var opt = options || {}; - var pairs = str.split(pairSplitRegExp); - var dec = opt.decode || decode; - - for (var i = 0; i < pairs.length; i++) { - var pair = pairs[i]; - var eq_idx = pair.indexOf('='); - - // skip things that don't look like key=value - if (eq_idx < 0) { - continue; - } - - var key = pair.substr(0, eq_idx).trim() - var val = pair.substr(++eq_idx, pair.length).trim(); - - // quoted values - if ('"' == val[0]) { - val = val.slice(1, -1); - } - - // only assign once - if (undefined == obj[key]) { - obj[key] = tryDecode(val, dec); - } - } - - return obj; -} - -/** - * Serialize data into a cookie header. - * - * Serialize the a name value pair into a cookie string suitable for - * http headers. An optional options object specified cookie parameters. - * - * serialize('foo', 'bar', { httpOnly: true }) - * => "foo=bar; httpOnly" - * - * @param {string} name - * @param {string} val - * @param {object} [options] - * @return {string} - * @public - */ - -function serialize(name, val, options) { - var opt = options || {}; - var enc = opt.encode || encode; - - if (typeof enc !== 'function') { - throw new TypeError('option encode is invalid'); - } - - if (!fieldContentRegExp.test(name)) { - throw new TypeError('argument name is invalid'); - } - - var value = enc(val); - - if (value && !fieldContentRegExp.test(value)) { - throw new TypeError('argument val is invalid'); - } - - var str = name + '=' + value; - - if (null != opt.maxAge) { - var maxAge = opt.maxAge - 0; - if (isNaN(maxAge)) throw new Error('maxAge should be a Number'); - str += '; Max-Age=' + Math.floor(maxAge); - } - - if (opt.domain) { - if (!fieldContentRegExp.test(opt.domain)) { - throw new TypeError('option domain is invalid'); - } - - str += '; Domain=' + opt.domain; - } - - if (opt.path) { - if (!fieldContentRegExp.test(opt.path)) { - throw new TypeError('option path is invalid'); - } - - str += '; Path=' + opt.path; - } - - if (opt.expires) { - if (typeof opt.expires.toUTCString !== 'function') { - throw new TypeError('option expires is invalid'); - } - - str += '; Expires=' + opt.expires.toUTCString(); - } - - if (opt.httpOnly) { - str += '; HttpOnly'; - } - - if (opt.secure) { - str += '; Secure'; - } - - if (opt.sameSite) { - var sameSite = typeof opt.sameSite === 'string' - ? opt.sameSite.toLowerCase() : opt.sameSite; - - switch (sameSite) { - case true: - str += '; SameSite=Strict'; - break; - case 'lax': - str += '; SameSite=Lax'; - break; - case 'strict': - str += '; SameSite=Strict'; - break; - default: - throw new TypeError('option sameSite is invalid'); - } - } - - return str; -} - -/** - * Try decoding a string using a decoding function. - * - * @param {string} str - * @param {function} decode - * @private - */ - -function tryDecode(str, decode) { - try { - return decode(str); - } catch (e) { - return str; - } -} +/*! + * cookie + * Copyright(c) 2012-2014 Roman Shtylman + * Copyright(c) 2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict'; + +/** + * Module exports. + * @public + */ + +exports.parse = parse; +exports.serialize = serialize; + +/** + * Module variables. + * @private + */ + +var decode = decodeURIComponent; +var encode = encodeURIComponent; +var pairSplitRegExp = /; */; + +/** + * RegExp to match field-content in RFC 7230 sec 3.2 + * + * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] + * field-vchar = VCHAR / obs-text + * obs-text = %x80-FF + */ + +var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/; + +/** + * Parse a cookie header. + * + * Parse the given cookie header string into an object + * The object has the various cookies as keys(names) => values + * + * @param {string} str + * @param {object} [options] + * @return {object} + * @public + */ + +function parse(str, options) { + if (typeof str !== 'string') { + throw new TypeError('argument str must be a string'); + } + + var obj = {} + var opt = options || {}; + var pairs = str.split(pairSplitRegExp); + var dec = opt.decode || decode; + + for (var i = 0; i < pairs.length; i++) { + var pair = pairs[i]; + var eq_idx = pair.indexOf('='); + + // skip things that don't look like key=value + if (eq_idx < 0) { + continue; + } + + var key = pair.substr(0, eq_idx).trim() + var val = pair.substr(++eq_idx, pair.length).trim(); + + // quoted values + if ('"' == val[0]) { + val = val.slice(1, -1); + } + + // only assign once + if (undefined == obj[key]) { + obj[key] = tryDecode(val, dec); + } + } + + return obj; +} + +/** + * Serialize data into a cookie header. + * + * Serialize the a name value pair into a cookie string suitable for + * http headers. An optional options object specified cookie parameters. + * + * serialize('foo', 'bar', { httpOnly: true }) + * => "foo=bar; httpOnly" + * + * @param {string} name + * @param {string} val + * @param {object} [options] + * @return {string} + * @public + */ + +function serialize(name, val, options) { + var opt = options || {}; + var enc = opt.encode || encode; + + if (typeof enc !== 'function') { + throw new TypeError('option encode is invalid'); + } + + if (!fieldContentRegExp.test(name)) { + throw new TypeError('argument name is invalid'); + } + + var value = enc(val); + + if (value && !fieldContentRegExp.test(value)) { + throw new TypeError('argument val is invalid'); + } + + var str = name + '=' + value; + + if (null != opt.maxAge) { + var maxAge = opt.maxAge - 0; + if (isNaN(maxAge)) throw new Error('maxAge should be a Number'); + str += '; Max-Age=' + Math.floor(maxAge); + } + + if (opt.domain) { + if (!fieldContentRegExp.test(opt.domain)) { + throw new TypeError('option domain is invalid'); + } + + str += '; Domain=' + opt.domain; + } + + if (opt.path) { + if (!fieldContentRegExp.test(opt.path)) { + throw new TypeError('option path is invalid'); + } + + str += '; Path=' + opt.path; + } + + if (opt.expires) { + if (typeof opt.expires.toUTCString !== 'function') { + throw new TypeError('option expires is invalid'); + } + + str += '; Expires=' + opt.expires.toUTCString(); + } + + if (opt.httpOnly) { + str += '; HttpOnly'; + } + + if (opt.secure) { + str += '; Secure'; + } + + if (opt.sameSite) { + var sameSite = typeof opt.sameSite === 'string' + ? opt.sameSite.toLowerCase() : opt.sameSite; + + switch (sameSite) { + case true: + str += '; SameSite=Strict'; + break; + case 'lax': + str += '; SameSite=Lax'; + break; + case 'strict': + str += '; SameSite=Strict'; + break; + default: + throw new TypeError('option sameSite is invalid'); + } + } + + return str; +} + +/** + * Try decoding a string using a decoding function. + * + * @param {string} str + * @param {function} decode + * @private + */ + +function tryDecode(str, decode) { + try { + return decode(str); + } catch (e) { + return str; + } +} diff --git a/ui/node_modules/express/node_modules/cookie/package.json b/ui/node_modules/express/node_modules/cookie/package.json index 091326e8..bb3556a5 100644 --- a/ui/node_modules/express/node_modules/cookie/package.json +++ b/ui/node_modules/express/node_modules/cookie/package.json @@ -1,72 +1,72 @@ -{ - "name": "cookie", - "description": "HTTP server cookie parsing and serialization", - "version": "0.3.1", - "author": { - "name": "Roman Shtylman", - "email": "shtylman@gmail.com" - }, - "contributors": [ - { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - } - ], - "license": "MIT", - "keywords": [ - "cookie", - "cookies" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/cookie.git" - }, - "devDependencies": { - "istanbul": "0.4.3", - "mocha": "1.21.5" - }, - "files": [ - "HISTORY.md", - "LICENSE", - "README.md", - "index.js" - ], - "engines": { - "node": ">= 0.6" - }, - "scripts": { - "test": "mocha --reporter spec --bail --check-leaks test/", - "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/" - }, - "gitHead": "e3c77d497d66c8b8d4b677b8954c1b192a09f0b3", - "bugs": { - "url": "https://github.com/jshttp/cookie/issues" - }, - "homepage": "https://github.com/jshttp/cookie", - "_id": "cookie@0.3.1", - "_shasum": "e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb", - "_from": "cookie@0.3.1", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb", - "tarball": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz" - }, - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/cookie-0.3.1.tgz_1464323556714_0.6435900838114321" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "cookie", + "description": "HTTP server cookie parsing and serialization", + "version": "0.3.1", + "author": { + "name": "Roman Shtylman", + "email": "shtylman@gmail.com" + }, + "contributors": [ + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + } + ], + "license": "MIT", + "keywords": [ + "cookie", + "cookies" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/cookie.git" + }, + "devDependencies": { + "istanbul": "0.4.3", + "mocha": "1.21.5" + }, + "files": [ + "HISTORY.md", + "LICENSE", + "README.md", + "index.js" + ], + "engines": { + "node": ">= 0.6" + }, + "scripts": { + "test": "mocha --reporter spec --bail --check-leaks test/", + "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/" + }, + "gitHead": "e3c77d497d66c8b8d4b677b8954c1b192a09f0b3", + "bugs": { + "url": "https://github.com/jshttp/cookie/issues" + }, + "homepage": "https://github.com/jshttp/cookie", + "_id": "cookie@0.3.1", + "_shasum": "e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb", + "_from": "cookie@0.3.1", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "maintainers": [ + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + } + ], + "dist": { + "shasum": "e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb", + "tarball": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz" + }, + "_npmOperationalInternal": { + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/cookie-0.3.1.tgz_1464323556714_0.6435900838114321" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/debug/.jshintrc b/ui/node_modules/express/node_modules/debug/.jshintrc index cf343ce0..299877f2 100644 --- a/ui/node_modules/express/node_modules/debug/.jshintrc +++ b/ui/node_modules/express/node_modules/debug/.jshintrc @@ -1,3 +1,3 @@ -{ - "laxbreak": true -} +{ + "laxbreak": true +} diff --git a/ui/node_modules/express/node_modules/debug/.npmignore b/ui/node_modules/express/node_modules/debug/.npmignore index 71f1cedc..7e6163db 100644 --- a/ui/node_modules/express/node_modules/debug/.npmignore +++ b/ui/node_modules/express/node_modules/debug/.npmignore @@ -1,6 +1,6 @@ -support -test -examples -example -*.sock -dist +support +test +examples +example +*.sock +dist diff --git a/ui/node_modules/express/node_modules/debug/History.md b/ui/node_modules/express/node_modules/debug/History.md index cc4a66ed..854c9711 100644 --- a/ui/node_modules/express/node_modules/debug/History.md +++ b/ui/node_modules/express/node_modules/debug/History.md @@ -1,195 +1,195 @@ - -2.2.0 / 2015-05-09 -================== - - * package: update "ms" to v0.7.1 (#202, @dougwilson) - * README: add logging to file example (#193, @DanielOchoa) - * README: fixed a typo (#191, @amir-s) - * browser: expose `storage` (#190, @stephenmathieson) - * Makefile: add a `distclean` target (#189, @stephenmathieson) - -2.1.3 / 2015-03-13 -================== - - * Updated stdout/stderr example (#186) - * Updated example/stdout.js to match debug current behaviour - * Renamed example/stderr.js to stdout.js - * Update Readme.md (#184) - * replace high intensity foreground color for bold (#182, #183) - -2.1.2 / 2015-03-01 -================== - - * dist: recompile - * update "ms" to v0.7.0 - * package: update "browserify" to v9.0.3 - * component: fix "ms.js" repo location - * changed bower package name - * updated documentation about using debug in a browser - * fix: security error on safari (#167, #168, @yields) - -2.1.1 / 2014-12-29 -================== - - * browser: use `typeof` to check for `console` existence - * browser: check for `console.log` truthiness (fix IE 8/9) - * browser: add support for Chrome apps - * Readme: added Windows usage remarks - * Add `bower.json` to properly support bower install - -2.1.0 / 2014-10-15 -================== - - * node: implement `DEBUG_FD` env variable support - * package: update "browserify" to v6.1.0 - * package: add "license" field to package.json (#135, @panuhorsmalahti) - -2.0.0 / 2014-09-01 -================== - - * package: update "browserify" to v5.11.0 - * node: use stderr rather than stdout for logging (#29, @stephenmathieson) - -1.0.4 / 2014-07-15 -================== - - * dist: recompile - * example: remove `console.info()` log usage - * example: add "Content-Type" UTF-8 header to browser example - * browser: place %c marker after the space character - * browser: reset the "content" color via `color: inherit` - * browser: add colors support for Firefox >= v31 - * debug: prefer an instance `log()` function over the global one (#119) - * Readme: update documentation about styled console logs for FF v31 (#116, @wryk) - -1.0.3 / 2014-07-09 -================== - - * Add support for multiple wildcards in namespaces (#122, @seegno) - * browser: fix lint - -1.0.2 / 2014-06-10 -================== - - * browser: update color palette (#113, @gscottolson) - * common: make console logging function configurable (#108, @timoxley) - * node: fix %o colors on old node <= 0.8.x - * Makefile: find node path using shell/which (#109, @timoxley) - -1.0.1 / 2014-06-06 -================== - - * browser: use `removeItem()` to clear localStorage - * browser, node: don't set DEBUG if namespaces is undefined (#107, @leedm777) - * package: add "contributors" section - * node: fix comment typo - * README: list authors - -1.0.0 / 2014-06-04 -================== - - * make ms diff be global, not be scope - * debug: ignore empty strings in enable() - * node: make DEBUG_COLORS able to disable coloring - * *: export the `colors` array - * npmignore: don't publish the `dist` dir - * Makefile: refactor to use browserify - * package: add "browserify" as a dev dependency - * Readme: add Web Inspector Colors section - * node: reset terminal color for the debug content - * node: map "%o" to `util.inspect()` - * browser: map "%j" to `JSON.stringify()` - * debug: add custom "formatters" - * debug: use "ms" module for humanizing the diff - * Readme: add "bash" syntax highlighting - * browser: add Firebug color support - * browser: add colors for WebKit browsers - * node: apply log to `console` - * rewrite: abstract common logic for Node & browsers - * add .jshintrc file - -0.8.1 / 2014-04-14 -================== - - * package: re-add the "component" section - -0.8.0 / 2014-03-30 -================== - - * add `enable()` method for nodejs. Closes #27 - * change from stderr to stdout - * remove unnecessary index.js file - -0.7.4 / 2013-11-13 -================== - - * remove "browserify" key from package.json (fixes something in browserify) - -0.7.3 / 2013-10-30 -================== - - * fix: catch localStorage security error when cookies are blocked (Chrome) - * add debug(err) support. Closes #46 - * add .browser prop to package.json. Closes #42 - -0.7.2 / 2013-02-06 -================== - - * fix package.json - * fix: Mobile Safari (private mode) is broken with debug - * fix: Use unicode to send escape character to shell instead of octal to work with strict mode javascript - -0.7.1 / 2013-02-05 -================== - - * add repository URL to package.json - * add DEBUG_COLORED to force colored output - * add browserify support - * fix component. Closes #24 - -0.7.0 / 2012-05-04 -================== - - * Added .component to package.json - * Added debug.component.js build - -0.6.0 / 2012-03-16 -================== - - * Added support for "-" prefix in DEBUG [Vinay Pulim] - * Added `.enabled` flag to the node version [TooTallNate] - -0.5.0 / 2012-02-02 -================== - - * Added: humanize diffs. Closes #8 - * Added `debug.disable()` to the CS variant - * Removed padding. Closes #10 - * Fixed: persist client-side variant again. Closes #9 - -0.4.0 / 2012-02-01 -================== - - * Added browser variant support for older browsers [TooTallNate] - * Added `debug.enable('project:*')` to browser variant [TooTallNate] - * Added padding to diff (moved it to the right) - -0.3.0 / 2012-01-26 -================== - - * Added millisecond diff when isatty, otherwise UTC string - -0.2.0 / 2012-01-22 -================== - - * Added wildcard support - -0.1.0 / 2011-12-02 -================== - - * Added: remove colors unless stderr isatty [TooTallNate] - -0.0.1 / 2010-01-03 -================== - - * Initial release + +2.2.0 / 2015-05-09 +================== + + * package: update "ms" to v0.7.1 (#202, @dougwilson) + * README: add logging to file example (#193, @DanielOchoa) + * README: fixed a typo (#191, @amir-s) + * browser: expose `storage` (#190, @stephenmathieson) + * Makefile: add a `distclean` target (#189, @stephenmathieson) + +2.1.3 / 2015-03-13 +================== + + * Updated stdout/stderr example (#186) + * Updated example/stdout.js to match debug current behaviour + * Renamed example/stderr.js to stdout.js + * Update Readme.md (#184) + * replace high intensity foreground color for bold (#182, #183) + +2.1.2 / 2015-03-01 +================== + + * dist: recompile + * update "ms" to v0.7.0 + * package: update "browserify" to v9.0.3 + * component: fix "ms.js" repo location + * changed bower package name + * updated documentation about using debug in a browser + * fix: security error on safari (#167, #168, @yields) + +2.1.1 / 2014-12-29 +================== + + * browser: use `typeof` to check for `console` existence + * browser: check for `console.log` truthiness (fix IE 8/9) + * browser: add support for Chrome apps + * Readme: added Windows usage remarks + * Add `bower.json` to properly support bower install + +2.1.0 / 2014-10-15 +================== + + * node: implement `DEBUG_FD` env variable support + * package: update "browserify" to v6.1.0 + * package: add "license" field to package.json (#135, @panuhorsmalahti) + +2.0.0 / 2014-09-01 +================== + + * package: update "browserify" to v5.11.0 + * node: use stderr rather than stdout for logging (#29, @stephenmathieson) + +1.0.4 / 2014-07-15 +================== + + * dist: recompile + * example: remove `console.info()` log usage + * example: add "Content-Type" UTF-8 header to browser example + * browser: place %c marker after the space character + * browser: reset the "content" color via `color: inherit` + * browser: add colors support for Firefox >= v31 + * debug: prefer an instance `log()` function over the global one (#119) + * Readme: update documentation about styled console logs for FF v31 (#116, @wryk) + +1.0.3 / 2014-07-09 +================== + + * Add support for multiple wildcards in namespaces (#122, @seegno) + * browser: fix lint + +1.0.2 / 2014-06-10 +================== + + * browser: update color palette (#113, @gscottolson) + * common: make console logging function configurable (#108, @timoxley) + * node: fix %o colors on old node <= 0.8.x + * Makefile: find node path using shell/which (#109, @timoxley) + +1.0.1 / 2014-06-06 +================== + + * browser: use `removeItem()` to clear localStorage + * browser, node: don't set DEBUG if namespaces is undefined (#107, @leedm777) + * package: add "contributors" section + * node: fix comment typo + * README: list authors + +1.0.0 / 2014-06-04 +================== + + * make ms diff be global, not be scope + * debug: ignore empty strings in enable() + * node: make DEBUG_COLORS able to disable coloring + * *: export the `colors` array + * npmignore: don't publish the `dist` dir + * Makefile: refactor to use browserify + * package: add "browserify" as a dev dependency + * Readme: add Web Inspector Colors section + * node: reset terminal color for the debug content + * node: map "%o" to `util.inspect()` + * browser: map "%j" to `JSON.stringify()` + * debug: add custom "formatters" + * debug: use "ms" module for humanizing the diff + * Readme: add "bash" syntax highlighting + * browser: add Firebug color support + * browser: add colors for WebKit browsers + * node: apply log to `console` + * rewrite: abstract common logic for Node & browsers + * add .jshintrc file + +0.8.1 / 2014-04-14 +================== + + * package: re-add the "component" section + +0.8.0 / 2014-03-30 +================== + + * add `enable()` method for nodejs. Closes #27 + * change from stderr to stdout + * remove unnecessary index.js file + +0.7.4 / 2013-11-13 +================== + + * remove "browserify" key from package.json (fixes something in browserify) + +0.7.3 / 2013-10-30 +================== + + * fix: catch localStorage security error when cookies are blocked (Chrome) + * add debug(err) support. Closes #46 + * add .browser prop to package.json. Closes #42 + +0.7.2 / 2013-02-06 +================== + + * fix package.json + * fix: Mobile Safari (private mode) is broken with debug + * fix: Use unicode to send escape character to shell instead of octal to work with strict mode javascript + +0.7.1 / 2013-02-05 +================== + + * add repository URL to package.json + * add DEBUG_COLORED to force colored output + * add browserify support + * fix component. Closes #24 + +0.7.0 / 2012-05-04 +================== + + * Added .component to package.json + * Added debug.component.js build + +0.6.0 / 2012-03-16 +================== + + * Added support for "-" prefix in DEBUG [Vinay Pulim] + * Added `.enabled` flag to the node version [TooTallNate] + +0.5.0 / 2012-02-02 +================== + + * Added: humanize diffs. Closes #8 + * Added `debug.disable()` to the CS variant + * Removed padding. Closes #10 + * Fixed: persist client-side variant again. Closes #9 + +0.4.0 / 2012-02-01 +================== + + * Added browser variant support for older browsers [TooTallNate] + * Added `debug.enable('project:*')` to browser variant [TooTallNate] + * Added padding to diff (moved it to the right) + +0.3.0 / 2012-01-26 +================== + + * Added millisecond diff when isatty, otherwise UTC string + +0.2.0 / 2012-01-22 +================== + + * Added wildcard support + +0.1.0 / 2011-12-02 +================== + + * Added: remove colors unless stderr isatty [TooTallNate] + +0.0.1 / 2010-01-03 +================== + + * Initial release diff --git a/ui/node_modules/express/node_modules/debug/Makefile b/ui/node_modules/express/node_modules/debug/Makefile index 7f0b731f..5cf4a596 100644 --- a/ui/node_modules/express/node_modules/debug/Makefile +++ b/ui/node_modules/express/node_modules/debug/Makefile @@ -1,36 +1,36 @@ - -# get Makefile directory name: http://stackoverflow.com/a/5982798/376773 -THIS_MAKEFILE_PATH:=$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) -THIS_DIR:=$(shell cd $(dir $(THIS_MAKEFILE_PATH));pwd) - -# BIN directory -BIN := $(THIS_DIR)/node_modules/.bin - -# applications -NODE ?= $(shell which node) -NPM ?= $(NODE) $(shell which npm) -BROWSERIFY ?= $(NODE) $(BIN)/browserify - -all: dist/debug.js - -install: node_modules - -clean: - @rm -rf dist - -dist: - @mkdir -p $@ - -dist/debug.js: node_modules browser.js debug.js dist - @$(BROWSERIFY) \ - --standalone debug \ - . > $@ - -distclean: clean - @rm -rf node_modules - -node_modules: package.json - @NODE_ENV= $(NPM) install - @touch node_modules - -.PHONY: all install clean distclean + +# get Makefile directory name: http://stackoverflow.com/a/5982798/376773 +THIS_MAKEFILE_PATH:=$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) +THIS_DIR:=$(shell cd $(dir $(THIS_MAKEFILE_PATH));pwd) + +# BIN directory +BIN := $(THIS_DIR)/node_modules/.bin + +# applications +NODE ?= $(shell which node) +NPM ?= $(NODE) $(shell which npm) +BROWSERIFY ?= $(NODE) $(BIN)/browserify + +all: dist/debug.js + +install: node_modules + +clean: + @rm -rf dist + +dist: + @mkdir -p $@ + +dist/debug.js: node_modules browser.js debug.js dist + @$(BROWSERIFY) \ + --standalone debug \ + . > $@ + +distclean: clean + @rm -rf node_modules + +node_modules: package.json + @NODE_ENV= $(NPM) install + @touch node_modules + +.PHONY: all install clean distclean diff --git a/ui/node_modules/express/node_modules/debug/Readme.md b/ui/node_modules/express/node_modules/debug/Readme.md index 9327d73e..b4f45e3c 100644 --- a/ui/node_modules/express/node_modules/debug/Readme.md +++ b/ui/node_modules/express/node_modules/debug/Readme.md @@ -1,188 +1,188 @@ -# debug - - tiny node.js debugging utility modelled after node core's debugging technique. - -## Installation - -```bash -$ npm install debug -``` - -## Usage - - With `debug` you simply invoke the exported function to generate your debug function, passing it a name which will determine if a noop function is returned, or a decorated `console.error`, so all of the `console` format string goodies you're used to work fine. A unique color is selected per-function for visibility. - -Example _app.js_: - -```js -var debug = require('debug')('http') - , http = require('http') - , name = 'My App'; - -// fake app - -debug('booting %s', name); - -http.createServer(function(req, res){ - debug(req.method + ' ' + req.url); - res.end('hello\n'); -}).listen(3000, function(){ - debug('listening'); -}); - -// fake worker of some kind - -require('./worker'); -``` - -Example _worker.js_: - -```js -var debug = require('debug')('worker'); - -setInterval(function(){ - debug('doing some work'); -}, 1000); -``` - - The __DEBUG__ environment variable is then used to enable these based on space or comma-delimited names. Here are some examples: - - ![debug http and worker](http://f.cl.ly/items/18471z1H402O24072r1J/Screenshot.png) - - ![debug worker](http://f.cl.ly/items/1X413v1a3M0d3C2c1E0i/Screenshot.png) - -#### Windows note - - On Windows the environment variable is set using the `set` command. - - ```cmd - set DEBUG=*,-not_this - ``` - -Then, run the program to be debugged as usual. - -## Millisecond diff - - When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls. - - ![](http://f.cl.ly/items/2i3h1d3t121M2Z1A3Q0N/Screenshot.png) - - When stdout is not a TTY, `Date#toUTCString()` is used, making it more useful for logging the debug information as shown below: - - ![](http://f.cl.ly/items/112H3i0e0o0P0a2Q2r11/Screenshot.png) - -## Conventions - - If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". - -## Wildcards - - The `*` character may be used as a wildcard. Suppose for example your library has debuggers named "connect:bodyParser", "connect:compress", "connect:session", instead of listing all three with `DEBUG=connect:bodyParser,connect:compress,connect:session`, you may simply do `DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`. - - You can also exclude specific debuggers by prefixing them with a "-" character. For example, `DEBUG=*,-connect:*` would include all debuggers except those starting with "connect:". - -## Browser support - - Debug works in the browser as well, currently persisted by `localStorage`. Consider the situation shown below where you have `worker:a` and `worker:b`, and wish to debug both. Somewhere in the code on your page, include: - -```js -window.myDebug = require("debug"); -``` - - ("debug" is a global object in the browser so we give this object a different name.) When your page is open in the browser, type the following in the console: - -```js -myDebug.enable("worker:*") -``` - - Refresh the page. Debug output will continue to be sent to the console until it is disabled by typing `myDebug.disable()` in the console. - -```js -a = debug('worker:a'); -b = debug('worker:b'); - -setInterval(function(){ - a('doing some work'); -}, 1000); - -setInterval(function(){ - b('doing some work'); -}, 1200); -``` - -#### Web Inspector Colors - - Colors are also enabled on "Web Inspectors" that understand the `%c` formatting - option. These are WebKit web inspectors, Firefox ([since version - 31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/)) - and the Firebug plugin for Firefox (any version). - - Colored output looks something like: - - ![](https://cloud.githubusercontent.com/assets/71256/3139768/b98c5fd8-e8ef-11e3-862a-f7253b6f47c6.png) - -### stderr vs stdout - -You can set an alternative logging method per-namespace by overriding the `log` method on a per-namespace or globally: - -Example _stdout.js_: - -```js -var debug = require('debug'); -var error = debug('app:error'); - -// by default stderr is used -error('goes to stderr!'); - -var log = debug('app:log'); -// set this namespace to log via console.log -log.log = console.log.bind(console); // don't forget to bind to console! -log('goes to stdout'); -error('still goes to stderr!'); - -// set all output to go via console.info -// overrides all per-namespace log settings -debug.log = console.info.bind(console); -error('now goes to stdout via console.info'); -log('still goes to stdout, but via console.info now'); -``` - -### Save debug output to a file - -You can save all debug statements to a file by piping them. - -Example: - -```bash -$ DEBUG_FD=3 node your-app.js 3> whatever.log -``` - -## Authors - - - TJ Holowaychuk - - Nathan Rajlich - -## License - -(The MIT License) - -Copyright (c) 2014 TJ Holowaychuk <tj@vision-media.ca> - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# debug + + tiny node.js debugging utility modelled after node core's debugging technique. + +## Installation + +```bash +$ npm install debug +``` + +## Usage + + With `debug` you simply invoke the exported function to generate your debug function, passing it a name which will determine if a noop function is returned, or a decorated `console.error`, so all of the `console` format string goodies you're used to work fine. A unique color is selected per-function for visibility. + +Example _app.js_: + +```js +var debug = require('debug')('http') + , http = require('http') + , name = 'My App'; + +// fake app + +debug('booting %s', name); + +http.createServer(function(req, res){ + debug(req.method + ' ' + req.url); + res.end('hello\n'); +}).listen(3000, function(){ + debug('listening'); +}); + +// fake worker of some kind + +require('./worker'); +``` + +Example _worker.js_: + +```js +var debug = require('debug')('worker'); + +setInterval(function(){ + debug('doing some work'); +}, 1000); +``` + + The __DEBUG__ environment variable is then used to enable these based on space or comma-delimited names. Here are some examples: + + ![debug http and worker](http://f.cl.ly/items/18471z1H402O24072r1J/Screenshot.png) + + ![debug worker](http://f.cl.ly/items/1X413v1a3M0d3C2c1E0i/Screenshot.png) + +#### Windows note + + On Windows the environment variable is set using the `set` command. + + ```cmd + set DEBUG=*,-not_this + ``` + +Then, run the program to be debugged as usual. + +## Millisecond diff + + When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls. + + ![](http://f.cl.ly/items/2i3h1d3t121M2Z1A3Q0N/Screenshot.png) + + When stdout is not a TTY, `Date#toUTCString()` is used, making it more useful for logging the debug information as shown below: + + ![](http://f.cl.ly/items/112H3i0e0o0P0a2Q2r11/Screenshot.png) + +## Conventions + + If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". + +## Wildcards + + The `*` character may be used as a wildcard. Suppose for example your library has debuggers named "connect:bodyParser", "connect:compress", "connect:session", instead of listing all three with `DEBUG=connect:bodyParser,connect:compress,connect:session`, you may simply do `DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`. + + You can also exclude specific debuggers by prefixing them with a "-" character. For example, `DEBUG=*,-connect:*` would include all debuggers except those starting with "connect:". + +## Browser support + + Debug works in the browser as well, currently persisted by `localStorage`. Consider the situation shown below where you have `worker:a` and `worker:b`, and wish to debug both. Somewhere in the code on your page, include: + +```js +window.myDebug = require("debug"); +``` + + ("debug" is a global object in the browser so we give this object a different name.) When your page is open in the browser, type the following in the console: + +```js +myDebug.enable("worker:*") +``` + + Refresh the page. Debug output will continue to be sent to the console until it is disabled by typing `myDebug.disable()` in the console. + +```js +a = debug('worker:a'); +b = debug('worker:b'); + +setInterval(function(){ + a('doing some work'); +}, 1000); + +setInterval(function(){ + b('doing some work'); +}, 1200); +``` + +#### Web Inspector Colors + + Colors are also enabled on "Web Inspectors" that understand the `%c` formatting + option. These are WebKit web inspectors, Firefox ([since version + 31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/)) + and the Firebug plugin for Firefox (any version). + + Colored output looks something like: + + ![](https://cloud.githubusercontent.com/assets/71256/3139768/b98c5fd8-e8ef-11e3-862a-f7253b6f47c6.png) + +### stderr vs stdout + +You can set an alternative logging method per-namespace by overriding the `log` method on a per-namespace or globally: + +Example _stdout.js_: + +```js +var debug = require('debug'); +var error = debug('app:error'); + +// by default stderr is used +error('goes to stderr!'); + +var log = debug('app:log'); +// set this namespace to log via console.log +log.log = console.log.bind(console); // don't forget to bind to console! +log('goes to stdout'); +error('still goes to stderr!'); + +// set all output to go via console.info +// overrides all per-namespace log settings +debug.log = console.info.bind(console); +error('now goes to stdout via console.info'); +log('still goes to stdout, but via console.info now'); +``` + +### Save debug output to a file + +You can save all debug statements to a file by piping them. + +Example: + +```bash +$ DEBUG_FD=3 node your-app.js 3> whatever.log +``` + +## Authors + + - TJ Holowaychuk + - Nathan Rajlich + +## License + +(The MIT License) + +Copyright (c) 2014 TJ Holowaychuk <tj@vision-media.ca> + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/debug/bower.json b/ui/node_modules/express/node_modules/debug/bower.json index e3aa7138..6af573ff 100644 --- a/ui/node_modules/express/node_modules/debug/bower.json +++ b/ui/node_modules/express/node_modules/debug/bower.json @@ -1,28 +1,28 @@ -{ - "name": "visionmedia-debug", - "main": "dist/debug.js", - "version": "2.2.0", - "homepage": "https://github.com/visionmedia/debug", - "authors": [ - "TJ Holowaychuk " - ], - "description": "visionmedia-debug", - "moduleType": [ - "amd", - "es6", - "globals", - "node" - ], - "keywords": [ - "visionmedia", - "debug" - ], - "license": "MIT", - "ignore": [ - "**/.*", - "node_modules", - "bower_components", - "test", - "tests" - ] -} +{ + "name": "visionmedia-debug", + "main": "dist/debug.js", + "version": "2.2.0", + "homepage": "https://github.com/visionmedia/debug", + "authors": [ + "TJ Holowaychuk " + ], + "description": "visionmedia-debug", + "moduleType": [ + "amd", + "es6", + "globals", + "node" + ], + "keywords": [ + "visionmedia", + "debug" + ], + "license": "MIT", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ] +} diff --git a/ui/node_modules/express/node_modules/debug/browser.js b/ui/node_modules/express/node_modules/debug/browser.js index afe80edd..7c764522 100644 --- a/ui/node_modules/express/node_modules/debug/browser.js +++ b/ui/node_modules/express/node_modules/debug/browser.js @@ -1,168 +1,168 @@ - -/** - * This is the web browser implementation of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = require('./debug'); -exports.log = log; -exports.formatArgs = formatArgs; -exports.save = save; -exports.load = load; -exports.useColors = useColors; -exports.storage = 'undefined' != typeof chrome - && 'undefined' != typeof chrome.storage - ? chrome.storage.local - : localstorage(); - -/** - * Colors. - */ - -exports.colors = [ - 'lightseagreen', - 'forestgreen', - 'goldenrod', - 'dodgerblue', - 'darkorchid', - 'crimson' -]; - -/** - * Currently only WebKit-based Web Inspectors, Firefox >= v31, - * and the Firebug extension (any Firefox version) are known - * to support "%c" CSS customizations. - * - * TODO: add a `localStorage` variable to explicitly enable/disable colors - */ - -function useColors() { - // is webkit? http://stackoverflow.com/a/16459606/376773 - return ('WebkitAppearance' in document.documentElement.style) || - // is firebug? http://stackoverflow.com/a/398120/376773 - (window.console && (console.firebug || (console.exception && console.table))) || - // is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31); -} - -/** - * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. - */ - -exports.formatters.j = function(v) { - return JSON.stringify(v); -}; - - -/** - * Colorize log arguments if enabled. - * - * @api public - */ - -function formatArgs() { - var args = arguments; - var useColors = this.useColors; - - args[0] = (useColors ? '%c' : '') - + this.namespace - + (useColors ? ' %c' : ' ') - + args[0] - + (useColors ? '%c ' : ' ') - + '+' + exports.humanize(this.diff); - - if (!useColors) return args; - - var c = 'color: ' + this.color; - args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1)); - - // the final "%c" is somewhat tricky, because there could be other - // arguments passed either before or after the %c, so we need to - // figure out the correct index to insert the CSS into - var index = 0; - var lastC = 0; - args[0].replace(/%[a-z%]/g, function(match) { - if ('%%' === match) return; - index++; - if ('%c' === match) { - // we only are interested in the *last* %c - // (the user may have provided their own) - lastC = index; - } - }); - - args.splice(lastC, 0, c); - return args; -} - -/** - * Invokes `console.log()` when available. - * No-op when `console.log` is not a "function". - * - * @api public - */ - -function log() { - // this hackery is required for IE8/9, where - // the `console.log` function doesn't have 'apply' - return 'object' === typeof console - && console.log - && Function.prototype.apply.call(console.log, console, arguments); -} - -/** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ - -function save(namespaces) { - try { - if (null == namespaces) { - exports.storage.removeItem('debug'); - } else { - exports.storage.debug = namespaces; - } - } catch(e) {} -} - -/** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ - -function load() { - var r; - try { - r = exports.storage.debug; - } catch(e) {} - return r; -} - -/** - * Enable namespaces listed in `localStorage.debug` initially. - */ - -exports.enable(load()); - -/** - * Localstorage attempts to return the localstorage. - * - * This is necessary because safari throws - * when a user disables cookies/localstorage - * and you attempt to access it. - * - * @return {LocalStorage} - * @api private - */ - -function localstorage(){ - try { - return window.localStorage; - } catch (e) {} -} + +/** + * This is the web browser implementation of `debug()`. + * + * Expose `debug()` as the module. + */ + +exports = module.exports = require('./debug'); +exports.log = log; +exports.formatArgs = formatArgs; +exports.save = save; +exports.load = load; +exports.useColors = useColors; +exports.storage = 'undefined' != typeof chrome + && 'undefined' != typeof chrome.storage + ? chrome.storage.local + : localstorage(); + +/** + * Colors. + */ + +exports.colors = [ + 'lightseagreen', + 'forestgreen', + 'goldenrod', + 'dodgerblue', + 'darkorchid', + 'crimson' +]; + +/** + * Currently only WebKit-based Web Inspectors, Firefox >= v31, + * and the Firebug extension (any Firefox version) are known + * to support "%c" CSS customizations. + * + * TODO: add a `localStorage` variable to explicitly enable/disable colors + */ + +function useColors() { + // is webkit? http://stackoverflow.com/a/16459606/376773 + return ('WebkitAppearance' in document.documentElement.style) || + // is firebug? http://stackoverflow.com/a/398120/376773 + (window.console && (console.firebug || (console.exception && console.table))) || + // is firefox >= v31? + // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages + (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31); +} + +/** + * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. + */ + +exports.formatters.j = function(v) { + return JSON.stringify(v); +}; + + +/** + * Colorize log arguments if enabled. + * + * @api public + */ + +function formatArgs() { + var args = arguments; + var useColors = this.useColors; + + args[0] = (useColors ? '%c' : '') + + this.namespace + + (useColors ? ' %c' : ' ') + + args[0] + + (useColors ? '%c ' : ' ') + + '+' + exports.humanize(this.diff); + + if (!useColors) return args; + + var c = 'color: ' + this.color; + args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1)); + + // the final "%c" is somewhat tricky, because there could be other + // arguments passed either before or after the %c, so we need to + // figure out the correct index to insert the CSS into + var index = 0; + var lastC = 0; + args[0].replace(/%[a-z%]/g, function(match) { + if ('%%' === match) return; + index++; + if ('%c' === match) { + // we only are interested in the *last* %c + // (the user may have provided their own) + lastC = index; + } + }); + + args.splice(lastC, 0, c); + return args; +} + +/** + * Invokes `console.log()` when available. + * No-op when `console.log` is not a "function". + * + * @api public + */ + +function log() { + // this hackery is required for IE8/9, where + // the `console.log` function doesn't have 'apply' + return 'object' === typeof console + && console.log + && Function.prototype.apply.call(console.log, console, arguments); +} + +/** + * Save `namespaces`. + * + * @param {String} namespaces + * @api private + */ + +function save(namespaces) { + try { + if (null == namespaces) { + exports.storage.removeItem('debug'); + } else { + exports.storage.debug = namespaces; + } + } catch(e) {} +} + +/** + * Load `namespaces`. + * + * @return {String} returns the previously persisted debug modes + * @api private + */ + +function load() { + var r; + try { + r = exports.storage.debug; + } catch(e) {} + return r; +} + +/** + * Enable namespaces listed in `localStorage.debug` initially. + */ + +exports.enable(load()); + +/** + * Localstorage attempts to return the localstorage. + * + * This is necessary because safari throws + * when a user disables cookies/localstorage + * and you attempt to access it. + * + * @return {LocalStorage} + * @api private + */ + +function localstorage(){ + try { + return window.localStorage; + } catch (e) {} +} diff --git a/ui/node_modules/express/node_modules/debug/component.json b/ui/node_modules/express/node_modules/debug/component.json index 139846b1..ca106372 100644 --- a/ui/node_modules/express/node_modules/debug/component.json +++ b/ui/node_modules/express/node_modules/debug/component.json @@ -1,19 +1,19 @@ -{ - "name": "debug", - "repo": "visionmedia/debug", - "description": "small debugging utility", - "version": "2.2.0", - "keywords": [ - "debug", - "log", - "debugger" - ], - "main": "browser.js", - "scripts": [ - "browser.js", - "debug.js" - ], - "dependencies": { - "rauchg/ms.js": "0.7.1" - } -} +{ + "name": "debug", + "repo": "visionmedia/debug", + "description": "small debugging utility", + "version": "2.2.0", + "keywords": [ + "debug", + "log", + "debugger" + ], + "main": "browser.js", + "scripts": [ + "browser.js", + "debug.js" + ], + "dependencies": { + "rauchg/ms.js": "0.7.1" + } +} diff --git a/ui/node_modules/express/node_modules/debug/debug.js b/ui/node_modules/express/node_modules/debug/debug.js index 801b417b..7571a860 100644 --- a/ui/node_modules/express/node_modules/debug/debug.js +++ b/ui/node_modules/express/node_modules/debug/debug.js @@ -1,197 +1,197 @@ - -/** - * This is the common logic for both the Node.js and web browser - * implementations of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = debug; -exports.coerce = coerce; -exports.disable = disable; -exports.enable = enable; -exports.enabled = enabled; -exports.humanize = require('ms'); - -/** - * The currently active debug mode names, and names to skip. - */ - -exports.names = []; -exports.skips = []; - -/** - * Map of special "%n" handling functions, for the debug "format" argument. - * - * Valid key names are a single, lowercased letter, i.e. "n". - */ - -exports.formatters = {}; - -/** - * Previously assigned color. - */ - -var prevColor = 0; - -/** - * Previous log timestamp. - */ - -var prevTime; - -/** - * Select a color. - * - * @return {Number} - * @api private - */ - -function selectColor() { - return exports.colors[prevColor++ % exports.colors.length]; -} - -/** - * Create a debugger with the given `namespace`. - * - * @param {String} namespace - * @return {Function} - * @api public - */ - -function debug(namespace) { - - // define the `disabled` version - function disabled() { - } - disabled.enabled = false; - - // define the `enabled` version - function enabled() { - - var self = enabled; - - // set `diff` timestamp - var curr = +new Date(); - var ms = curr - (prevTime || curr); - self.diff = ms; - self.prev = prevTime; - self.curr = curr; - prevTime = curr; - - // add the `color` if not set - if (null == self.useColors) self.useColors = exports.useColors(); - if (null == self.color && self.useColors) self.color = selectColor(); - - var args = Array.prototype.slice.call(arguments); - - args[0] = exports.coerce(args[0]); - - if ('string' !== typeof args[0]) { - // anything else let's inspect with %o - args = ['%o'].concat(args); - } - - // apply any `formatters` transformations - var index = 0; - args[0] = args[0].replace(/%([a-z%])/g, function(match, format) { - // if we encounter an escaped % then don't increase the array index - if (match === '%%') return match; - index++; - var formatter = exports.formatters[format]; - if ('function' === typeof formatter) { - var val = args[index]; - match = formatter.call(self, val); - - // now we need to remove `args[index]` since it's inlined in the `format` - args.splice(index, 1); - index--; - } - return match; - }); - - if ('function' === typeof exports.formatArgs) { - args = exports.formatArgs.apply(self, args); - } - var logFn = enabled.log || exports.log || console.log.bind(console); - logFn.apply(self, args); - } - enabled.enabled = true; - - var fn = exports.enabled(namespace) ? enabled : disabled; - - fn.namespace = namespace; - - return fn; -} - -/** - * Enables a debug mode by namespaces. This can include modes - * separated by a colon and wildcards. - * - * @param {String} namespaces - * @api public - */ - -function enable(namespaces) { - exports.save(namespaces); - - var split = (namespaces || '').split(/[\s,]+/); - var len = split.length; - - for (var i = 0; i < len; i++) { - if (!split[i]) continue; // ignore empty strings - namespaces = split[i].replace(/\*/g, '.*?'); - if (namespaces[0] === '-') { - exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); - } else { - exports.names.push(new RegExp('^' + namespaces + '$')); - } - } -} - -/** - * Disable debug output. - * - * @api public - */ - -function disable() { - exports.enable(''); -} - -/** - * Returns true if the given mode name is enabled, false otherwise. - * - * @param {String} name - * @return {Boolean} - * @api public - */ - -function enabled(name) { - var i, len; - for (i = 0, len = exports.skips.length; i < len; i++) { - if (exports.skips[i].test(name)) { - return false; - } - } - for (i = 0, len = exports.names.length; i < len; i++) { - if (exports.names[i].test(name)) { - return true; - } - } - return false; -} - -/** - * Coerce `val`. - * - * @param {Mixed} val - * @return {Mixed} - * @api private - */ - -function coerce(val) { - if (val instanceof Error) return val.stack || val.message; - return val; -} + +/** + * This is the common logic for both the Node.js and web browser + * implementations of `debug()`. + * + * Expose `debug()` as the module. + */ + +exports = module.exports = debug; +exports.coerce = coerce; +exports.disable = disable; +exports.enable = enable; +exports.enabled = enabled; +exports.humanize = require('ms'); + +/** + * The currently active debug mode names, and names to skip. + */ + +exports.names = []; +exports.skips = []; + +/** + * Map of special "%n" handling functions, for the debug "format" argument. + * + * Valid key names are a single, lowercased letter, i.e. "n". + */ + +exports.formatters = {}; + +/** + * Previously assigned color. + */ + +var prevColor = 0; + +/** + * Previous log timestamp. + */ + +var prevTime; + +/** + * Select a color. + * + * @return {Number} + * @api private + */ + +function selectColor() { + return exports.colors[prevColor++ % exports.colors.length]; +} + +/** + * Create a debugger with the given `namespace`. + * + * @param {String} namespace + * @return {Function} + * @api public + */ + +function debug(namespace) { + + // define the `disabled` version + function disabled() { + } + disabled.enabled = false; + + // define the `enabled` version + function enabled() { + + var self = enabled; + + // set `diff` timestamp + var curr = +new Date(); + var ms = curr - (prevTime || curr); + self.diff = ms; + self.prev = prevTime; + self.curr = curr; + prevTime = curr; + + // add the `color` if not set + if (null == self.useColors) self.useColors = exports.useColors(); + if (null == self.color && self.useColors) self.color = selectColor(); + + var args = Array.prototype.slice.call(arguments); + + args[0] = exports.coerce(args[0]); + + if ('string' !== typeof args[0]) { + // anything else let's inspect with %o + args = ['%o'].concat(args); + } + + // apply any `formatters` transformations + var index = 0; + args[0] = args[0].replace(/%([a-z%])/g, function(match, format) { + // if we encounter an escaped % then don't increase the array index + if (match === '%%') return match; + index++; + var formatter = exports.formatters[format]; + if ('function' === typeof formatter) { + var val = args[index]; + match = formatter.call(self, val); + + // now we need to remove `args[index]` since it's inlined in the `format` + args.splice(index, 1); + index--; + } + return match; + }); + + if ('function' === typeof exports.formatArgs) { + args = exports.formatArgs.apply(self, args); + } + var logFn = enabled.log || exports.log || console.log.bind(console); + logFn.apply(self, args); + } + enabled.enabled = true; + + var fn = exports.enabled(namespace) ? enabled : disabled; + + fn.namespace = namespace; + + return fn; +} + +/** + * Enables a debug mode by namespaces. This can include modes + * separated by a colon and wildcards. + * + * @param {String} namespaces + * @api public + */ + +function enable(namespaces) { + exports.save(namespaces); + + var split = (namespaces || '').split(/[\s,]+/); + var len = split.length; + + for (var i = 0; i < len; i++) { + if (!split[i]) continue; // ignore empty strings + namespaces = split[i].replace(/\*/g, '.*?'); + if (namespaces[0] === '-') { + exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); + } else { + exports.names.push(new RegExp('^' + namespaces + '$')); + } + } +} + +/** + * Disable debug output. + * + * @api public + */ + +function disable() { + exports.enable(''); +} + +/** + * Returns true if the given mode name is enabled, false otherwise. + * + * @param {String} name + * @return {Boolean} + * @api public + */ + +function enabled(name) { + var i, len; + for (i = 0, len = exports.skips.length; i < len; i++) { + if (exports.skips[i].test(name)) { + return false; + } + } + for (i = 0, len = exports.names.length; i < len; i++) { + if (exports.names[i].test(name)) { + return true; + } + } + return false; +} + +/** + * Coerce `val`. + * + * @param {Mixed} val + * @return {Mixed} + * @api private + */ + +function coerce(val) { + if (val instanceof Error) return val.stack || val.message; + return val; +} diff --git a/ui/node_modules/express/node_modules/debug/node.js b/ui/node_modules/express/node_modules/debug/node.js index b246d603..1d392a81 100644 --- a/ui/node_modules/express/node_modules/debug/node.js +++ b/ui/node_modules/express/node_modules/debug/node.js @@ -1,209 +1,209 @@ - -/** - * Module dependencies. - */ - -var tty = require('tty'); -var util = require('util'); - -/** - * This is the Node.js implementation of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = require('./debug'); -exports.log = log; -exports.formatArgs = formatArgs; -exports.save = save; -exports.load = load; -exports.useColors = useColors; - -/** - * Colors. - */ - -exports.colors = [6, 2, 3, 4, 5, 1]; - -/** - * The file descriptor to write the `debug()` calls to. - * Set the `DEBUG_FD` env variable to override with another value. i.e.: - * - * $ DEBUG_FD=3 node script.js 3>debug.log - */ - -var fd = parseInt(process.env.DEBUG_FD, 10) || 2; -var stream = 1 === fd ? process.stdout : - 2 === fd ? process.stderr : - createWritableStdioStream(fd); - -/** - * Is stdout a TTY? Colored output is enabled when `true`. - */ - -function useColors() { - var debugColors = (process.env.DEBUG_COLORS || '').trim().toLowerCase(); - if (0 === debugColors.length) { - return tty.isatty(fd); - } else { - return '0' !== debugColors - && 'no' !== debugColors - && 'false' !== debugColors - && 'disabled' !== debugColors; - } -} - -/** - * Map %o to `util.inspect()`, since Node doesn't do that out of the box. - */ - -var inspect = (4 === util.inspect.length ? - // node <= 0.8.x - function (v, colors) { - return util.inspect(v, void 0, void 0, colors); - } : - // node > 0.8.x - function (v, colors) { - return util.inspect(v, { colors: colors }); - } -); - -exports.formatters.o = function(v) { - return inspect(v, this.useColors) - .replace(/\s*\n\s*/g, ' '); -}; - -/** - * Adds ANSI color escape codes if enabled. - * - * @api public - */ - -function formatArgs() { - var args = arguments; - var useColors = this.useColors; - var name = this.namespace; - - if (useColors) { - var c = this.color; - - args[0] = ' \u001b[3' + c + ';1m' + name + ' ' - + '\u001b[0m' - + args[0] + '\u001b[3' + c + 'm' - + ' +' + exports.humanize(this.diff) + '\u001b[0m'; - } else { - args[0] = new Date().toUTCString() - + ' ' + name + ' ' + args[0]; - } - return args; -} - -/** - * Invokes `console.error()` with the specified arguments. - */ - -function log() { - return stream.write(util.format.apply(this, arguments) + '\n'); -} - -/** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ - -function save(namespaces) { - if (null == namespaces) { - // If you set a process.env field to null or undefined, it gets cast to the - // string 'null' or 'undefined'. Just delete instead. - delete process.env.DEBUG; - } else { - process.env.DEBUG = namespaces; - } -} - -/** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ - -function load() { - return process.env.DEBUG; -} - -/** - * Copied from `node/src/node.js`. - * - * XXX: It's lame that node doesn't expose this API out-of-the-box. It also - * relies on the undocumented `tty_wrap.guessHandleType()` which is also lame. - */ - -function createWritableStdioStream (fd) { - var stream; - var tty_wrap = process.binding('tty_wrap'); - - // Note stream._type is used for test-module-load-list.js - - switch (tty_wrap.guessHandleType(fd)) { - case 'TTY': - stream = new tty.WriteStream(fd); - stream._type = 'tty'; - - // Hack to have stream not keep the event loop alive. - // See https://github.com/joyent/node/issues/1726 - if (stream._handle && stream._handle.unref) { - stream._handle.unref(); - } - break; - - case 'FILE': - var fs = require('fs'); - stream = new fs.SyncWriteStream(fd, { autoClose: false }); - stream._type = 'fs'; - break; - - case 'PIPE': - case 'TCP': - var net = require('net'); - stream = new net.Socket({ - fd: fd, - readable: false, - writable: true - }); - - // FIXME Should probably have an option in net.Socket to create a - // stream from an existing fd which is writable only. But for now - // we'll just add this hack and set the `readable` member to false. - // Test: ./node test/fixtures/echo.js < /etc/passwd - stream.readable = false; - stream.read = null; - stream._type = 'pipe'; - - // FIXME Hack to have stream not keep the event loop alive. - // See https://github.com/joyent/node/issues/1726 - if (stream._handle && stream._handle.unref) { - stream._handle.unref(); - } - break; - - default: - // Probably an error on in uv_guess_handle() - throw new Error('Implement me. Unknown stream file type!'); - } - - // For supporting legacy API we put the FD here. - stream.fd = fd; - - stream._isStdio = true; - - return stream; -} - -/** - * Enable namespaces listed in `process.env.DEBUG` initially. - */ - -exports.enable(load()); + +/** + * Module dependencies. + */ + +var tty = require('tty'); +var util = require('util'); + +/** + * This is the Node.js implementation of `debug()`. + * + * Expose `debug()` as the module. + */ + +exports = module.exports = require('./debug'); +exports.log = log; +exports.formatArgs = formatArgs; +exports.save = save; +exports.load = load; +exports.useColors = useColors; + +/** + * Colors. + */ + +exports.colors = [6, 2, 3, 4, 5, 1]; + +/** + * The file descriptor to write the `debug()` calls to. + * Set the `DEBUG_FD` env variable to override with another value. i.e.: + * + * $ DEBUG_FD=3 node script.js 3>debug.log + */ + +var fd = parseInt(process.env.DEBUG_FD, 10) || 2; +var stream = 1 === fd ? process.stdout : + 2 === fd ? process.stderr : + createWritableStdioStream(fd); + +/** + * Is stdout a TTY? Colored output is enabled when `true`. + */ + +function useColors() { + var debugColors = (process.env.DEBUG_COLORS || '').trim().toLowerCase(); + if (0 === debugColors.length) { + return tty.isatty(fd); + } else { + return '0' !== debugColors + && 'no' !== debugColors + && 'false' !== debugColors + && 'disabled' !== debugColors; + } +} + +/** + * Map %o to `util.inspect()`, since Node doesn't do that out of the box. + */ + +var inspect = (4 === util.inspect.length ? + // node <= 0.8.x + function (v, colors) { + return util.inspect(v, void 0, void 0, colors); + } : + // node > 0.8.x + function (v, colors) { + return util.inspect(v, { colors: colors }); + } +); + +exports.formatters.o = function(v) { + return inspect(v, this.useColors) + .replace(/\s*\n\s*/g, ' '); +}; + +/** + * Adds ANSI color escape codes if enabled. + * + * @api public + */ + +function formatArgs() { + var args = arguments; + var useColors = this.useColors; + var name = this.namespace; + + if (useColors) { + var c = this.color; + + args[0] = ' \u001b[3' + c + ';1m' + name + ' ' + + '\u001b[0m' + + args[0] + '\u001b[3' + c + 'm' + + ' +' + exports.humanize(this.diff) + '\u001b[0m'; + } else { + args[0] = new Date().toUTCString() + + ' ' + name + ' ' + args[0]; + } + return args; +} + +/** + * Invokes `console.error()` with the specified arguments. + */ + +function log() { + return stream.write(util.format.apply(this, arguments) + '\n'); +} + +/** + * Save `namespaces`. + * + * @param {String} namespaces + * @api private + */ + +function save(namespaces) { + if (null == namespaces) { + // If you set a process.env field to null or undefined, it gets cast to the + // string 'null' or 'undefined'. Just delete instead. + delete process.env.DEBUG; + } else { + process.env.DEBUG = namespaces; + } +} + +/** + * Load `namespaces`. + * + * @return {String} returns the previously persisted debug modes + * @api private + */ + +function load() { + return process.env.DEBUG; +} + +/** + * Copied from `node/src/node.js`. + * + * XXX: It's lame that node doesn't expose this API out-of-the-box. It also + * relies on the undocumented `tty_wrap.guessHandleType()` which is also lame. + */ + +function createWritableStdioStream (fd) { + var stream; + var tty_wrap = process.binding('tty_wrap'); + + // Note stream._type is used for test-module-load-list.js + + switch (tty_wrap.guessHandleType(fd)) { + case 'TTY': + stream = new tty.WriteStream(fd); + stream._type = 'tty'; + + // Hack to have stream not keep the event loop alive. + // See https://github.com/joyent/node/issues/1726 + if (stream._handle && stream._handle.unref) { + stream._handle.unref(); + } + break; + + case 'FILE': + var fs = require('fs'); + stream = new fs.SyncWriteStream(fd, { autoClose: false }); + stream._type = 'fs'; + break; + + case 'PIPE': + case 'TCP': + var net = require('net'); + stream = new net.Socket({ + fd: fd, + readable: false, + writable: true + }); + + // FIXME Should probably have an option in net.Socket to create a + // stream from an existing fd which is writable only. But for now + // we'll just add this hack and set the `readable` member to false. + // Test: ./node test/fixtures/echo.js < /etc/passwd + stream.readable = false; + stream.read = null; + stream._type = 'pipe'; + + // FIXME Hack to have stream not keep the event loop alive. + // See https://github.com/joyent/node/issues/1726 + if (stream._handle && stream._handle.unref) { + stream._handle.unref(); + } + break; + + default: + // Probably an error on in uv_guess_handle() + throw new Error('Implement me. Unknown stream file type!'); + } + + // For supporting legacy API we put the FD here. + stream.fd = fd; + + stream._isStdio = true; + + return stream; +} + +/** + * Enable namespaces listed in `process.env.DEBUG` initially. + */ + +exports.enable(load()); diff --git a/ui/node_modules/express/node_modules/debug/node_modules/ms/.npmignore b/ui/node_modules/express/node_modules/debug/node_modules/ms/.npmignore index 93216885..d1aa0ce4 100644 --- a/ui/node_modules/express/node_modules/debug/node_modules/ms/.npmignore +++ b/ui/node_modules/express/node_modules/debug/node_modules/ms/.npmignore @@ -1,5 +1,5 @@ -node_modules -test -History.md -Makefile -component.json +node_modules +test +History.md +Makefile +component.json diff --git a/ui/node_modules/express/node_modules/debug/node_modules/ms/History.md b/ui/node_modules/express/node_modules/debug/node_modules/ms/History.md index c9715f87..32fdfc17 100644 --- a/ui/node_modules/express/node_modules/debug/node_modules/ms/History.md +++ b/ui/node_modules/express/node_modules/debug/node_modules/ms/History.md @@ -1,66 +1,66 @@ - -0.7.1 / 2015-04-20 -================== - - * prevent extraordinary long inputs (@evilpacket) - * Fixed broken readme link - -0.7.0 / 2014-11-24 -================== - - * add time abbreviations, updated tests and readme for the new units - * fix example in the readme. - * add LICENSE file - -0.6.2 / 2013-12-05 -================== - - * Adding repository section to package.json to suppress warning from NPM. - -0.6.1 / 2013-05-10 -================== - - * fix singularization [visionmedia] - -0.6.0 / 2013-03-15 -================== - - * fix minutes - -0.5.1 / 2013-02-24 -================== - - * add component namespace - -0.5.0 / 2012-11-09 -================== - - * add short formatting as default and .long option - * add .license property to component.json - * add version to component.json - -0.4.0 / 2012-10-22 -================== - - * add rounding to fix crazy decimals - -0.3.0 / 2012-09-07 -================== - - * fix `ms()` [visionmedia] - -0.2.0 / 2012-09-03 -================== - - * add component.json [visionmedia] - * add days support [visionmedia] - * add hours support [visionmedia] - * add minutes support [visionmedia] - * add seconds support [visionmedia] - * add ms string support [visionmedia] - * refactor tests to facilitate ms(number) [visionmedia] - -0.1.0 / 2012-03-07 -================== - - * Initial release + +0.7.1 / 2015-04-20 +================== + + * prevent extraordinary long inputs (@evilpacket) + * Fixed broken readme link + +0.7.0 / 2014-11-24 +================== + + * add time abbreviations, updated tests and readme for the new units + * fix example in the readme. + * add LICENSE file + +0.6.2 / 2013-12-05 +================== + + * Adding repository section to package.json to suppress warning from NPM. + +0.6.1 / 2013-05-10 +================== + + * fix singularization [visionmedia] + +0.6.0 / 2013-03-15 +================== + + * fix minutes + +0.5.1 / 2013-02-24 +================== + + * add component namespace + +0.5.0 / 2012-11-09 +================== + + * add short formatting as default and .long option + * add .license property to component.json + * add version to component.json + +0.4.0 / 2012-10-22 +================== + + * add rounding to fix crazy decimals + +0.3.0 / 2012-09-07 +================== + + * fix `ms()` [visionmedia] + +0.2.0 / 2012-09-03 +================== + + * add component.json [visionmedia] + * add days support [visionmedia] + * add hours support [visionmedia] + * add minutes support [visionmedia] + * add seconds support [visionmedia] + * add ms string support [visionmedia] + * refactor tests to facilitate ms(number) [visionmedia] + +0.1.0 / 2012-03-07 +================== + + * Initial release diff --git a/ui/node_modules/express/node_modules/debug/node_modules/ms/LICENSE b/ui/node_modules/express/node_modules/debug/node_modules/ms/LICENSE index 5b078ede..6c07561b 100644 --- a/ui/node_modules/express/node_modules/debug/node_modules/ms/LICENSE +++ b/ui/node_modules/express/node_modules/debug/node_modules/ms/LICENSE @@ -1,20 +1,20 @@ -(The MIT License) - -Copyright (c) 2014 Guillermo Rauch - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2014 Guillermo Rauch + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/debug/node_modules/ms/README.md b/ui/node_modules/express/node_modules/debug/node_modules/ms/README.md index 7e3e27f9..9b4fd035 100644 --- a/ui/node_modules/express/node_modules/debug/node_modules/ms/README.md +++ b/ui/node_modules/express/node_modules/debug/node_modules/ms/README.md @@ -1,35 +1,35 @@ -# ms.js: miliseconds conversion utility - -```js -ms('2 days') // 172800000 -ms('1d') // 86400000 -ms('10h') // 36000000 -ms('2.5 hrs') // 9000000 -ms('2h') // 7200000 -ms('1m') // 60000 -ms('5s') // 5000 -ms('100') // 100 -``` - -```js -ms(60000) // "1m" -ms(2 * 60000) // "2m" -ms(ms('10 hours')) // "10h" -``` - -```js -ms(60000, { long: true }) // "1 minute" -ms(2 * 60000, { long: true }) // "2 minutes" -ms(ms('10 hours'), { long: true }) // "10 hours" -``` - -- Node/Browser compatible. Published as [`ms`](https://www.npmjs.org/package/ms) in [NPM](http://nodejs.org/download). -- If a number is supplied to `ms`, a string with a unit is returned. -- If a string that contains the number is supplied, it returns it as -a number (e.g: it returns `100` for `'100'`). -- If you pass a string with a number and a valid unit, the number of -equivalent ms is returned. - -## License - -MIT +# ms.js: miliseconds conversion utility + +```js +ms('2 days') // 172800000 +ms('1d') // 86400000 +ms('10h') // 36000000 +ms('2.5 hrs') // 9000000 +ms('2h') // 7200000 +ms('1m') // 60000 +ms('5s') // 5000 +ms('100') // 100 +``` + +```js +ms(60000) // "1m" +ms(2 * 60000) // "2m" +ms(ms('10 hours')) // "10h" +``` + +```js +ms(60000, { long: true }) // "1 minute" +ms(2 * 60000, { long: true }) // "2 minutes" +ms(ms('10 hours'), { long: true }) // "10 hours" +``` + +- Node/Browser compatible. Published as [`ms`](https://www.npmjs.org/package/ms) in [NPM](http://nodejs.org/download). +- If a number is supplied to `ms`, a string with a unit is returned. +- If a string that contains the number is supplied, it returns it as +a number (e.g: it returns `100` for `'100'`). +- If you pass a string with a number and a valid unit, the number of +equivalent ms is returned. + +## License + +MIT diff --git a/ui/node_modules/express/node_modules/debug/node_modules/ms/index.js b/ui/node_modules/express/node_modules/debug/node_modules/ms/index.js index dd9a4607..4f927716 100644 --- a/ui/node_modules/express/node_modules/debug/node_modules/ms/index.js +++ b/ui/node_modules/express/node_modules/debug/node_modules/ms/index.js @@ -1,125 +1,125 @@ -/** - * Helpers. - */ - -var s = 1000; -var m = s * 60; -var h = m * 60; -var d = h * 24; -var y = d * 365.25; - -/** - * Parse or format the given `val`. - * - * Options: - * - * - `long` verbose formatting [false] - * - * @param {String|Number} val - * @param {Object} options - * @return {String|Number} - * @api public - */ - -module.exports = function(val, options){ - options = options || {}; - if ('string' == typeof val) return parse(val); - return options.long - ? long(val) - : short(val); -}; - -/** - * Parse the given `str` and return milliseconds. - * - * @param {String} str - * @return {Number} - * @api private - */ - -function parse(str) { - str = '' + str; - if (str.length > 10000) return; - var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str); - if (!match) return; - var n = parseFloat(match[1]); - var type = (match[2] || 'ms').toLowerCase(); - switch (type) { - case 'years': - case 'year': - case 'yrs': - case 'yr': - case 'y': - return n * y; - case 'days': - case 'day': - case 'd': - return n * d; - case 'hours': - case 'hour': - case 'hrs': - case 'hr': - case 'h': - return n * h; - case 'minutes': - case 'minute': - case 'mins': - case 'min': - case 'm': - return n * m; - case 'seconds': - case 'second': - case 'secs': - case 'sec': - case 's': - return n * s; - case 'milliseconds': - case 'millisecond': - case 'msecs': - case 'msec': - case 'ms': - return n; - } -} - -/** - * Short format for `ms`. - * - * @param {Number} ms - * @return {String} - * @api private - */ - -function short(ms) { - if (ms >= d) return Math.round(ms / d) + 'd'; - if (ms >= h) return Math.round(ms / h) + 'h'; - if (ms >= m) return Math.round(ms / m) + 'm'; - if (ms >= s) return Math.round(ms / s) + 's'; - return ms + 'ms'; -} - -/** - * Long format for `ms`. - * - * @param {Number} ms - * @return {String} - * @api private - */ - -function long(ms) { - return plural(ms, d, 'day') - || plural(ms, h, 'hour') - || plural(ms, m, 'minute') - || plural(ms, s, 'second') - || ms + ' ms'; -} - -/** - * Pluralization helper. - */ - -function plural(ms, n, name) { - if (ms < n) return; - if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name; - return Math.ceil(ms / n) + ' ' + name + 's'; -} +/** + * Helpers. + */ + +var s = 1000; +var m = s * 60; +var h = m * 60; +var d = h * 24; +var y = d * 365.25; + +/** + * Parse or format the given `val`. + * + * Options: + * + * - `long` verbose formatting [false] + * + * @param {String|Number} val + * @param {Object} options + * @return {String|Number} + * @api public + */ + +module.exports = function(val, options){ + options = options || {}; + if ('string' == typeof val) return parse(val); + return options.long + ? long(val) + : short(val); +}; + +/** + * Parse the given `str` and return milliseconds. + * + * @param {String} str + * @return {Number} + * @api private + */ + +function parse(str) { + str = '' + str; + if (str.length > 10000) return; + var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str); + if (!match) return; + var n = parseFloat(match[1]); + var type = (match[2] || 'ms').toLowerCase(); + switch (type) { + case 'years': + case 'year': + case 'yrs': + case 'yr': + case 'y': + return n * y; + case 'days': + case 'day': + case 'd': + return n * d; + case 'hours': + case 'hour': + case 'hrs': + case 'hr': + case 'h': + return n * h; + case 'minutes': + case 'minute': + case 'mins': + case 'min': + case 'm': + return n * m; + case 'seconds': + case 'second': + case 'secs': + case 'sec': + case 's': + return n * s; + case 'milliseconds': + case 'millisecond': + case 'msecs': + case 'msec': + case 'ms': + return n; + } +} + +/** + * Short format for `ms`. + * + * @param {Number} ms + * @return {String} + * @api private + */ + +function short(ms) { + if (ms >= d) return Math.round(ms / d) + 'd'; + if (ms >= h) return Math.round(ms / h) + 'h'; + if (ms >= m) return Math.round(ms / m) + 'm'; + if (ms >= s) return Math.round(ms / s) + 's'; + return ms + 'ms'; +} + +/** + * Long format for `ms`. + * + * @param {Number} ms + * @return {String} + * @api private + */ + +function long(ms) { + return plural(ms, d, 'day') + || plural(ms, h, 'hour') + || plural(ms, m, 'minute') + || plural(ms, s, 'second') + || ms + ' ms'; +} + +/** + * Pluralization helper. + */ + +function plural(ms, n, name) { + if (ms < n) return; + if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name; + return Math.ceil(ms / n) + ' ' + name + 's'; +} diff --git a/ui/node_modules/express/node_modules/debug/node_modules/ms/package.json b/ui/node_modules/express/node_modules/debug/node_modules/ms/package.json index 5a896a3a..e36489ef 100644 --- a/ui/node_modules/express/node_modules/debug/node_modules/ms/package.json +++ b/ui/node_modules/express/node_modules/debug/node_modules/ms/package.json @@ -1,48 +1,48 @@ -{ - "name": "ms", - "version": "0.7.1", - "description": "Tiny ms conversion utility", - "repository": { - "type": "git", - "url": "git://github.com/guille/ms.js.git" - }, - "main": "./index", - "devDependencies": { - "mocha": "*", - "expect.js": "*", - "serve": "*" - }, - "component": { - "scripts": { - "ms/index.js": "index.js" - } - }, - "gitHead": "713dcf26d9e6fd9dbc95affe7eff9783b7f1b909", - "bugs": { - "url": "https://github.com/guille/ms.js/issues" - }, - "homepage": "https://github.com/guille/ms.js", - "_id": "ms@0.7.1", - "scripts": {}, - "_shasum": "9cd13c03adbff25b65effde7ce864ee952017098", - "_from": "ms@0.7.1", - "_npmVersion": "2.7.5", - "_nodeVersion": "0.12.2", - "_npmUser": { - "name": "rauchg", - "email": "rauchg@gmail.com" - }, - "maintainers": [ - { - "name": "rauchg", - "email": "rauchg@gmail.com" - } - ], - "dist": { - "shasum": "9cd13c03adbff25b65effde7ce864ee952017098", - "tarball": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "ms", + "version": "0.7.1", + "description": "Tiny ms conversion utility", + "repository": { + "type": "git", + "url": "git://github.com/guille/ms.js.git" + }, + "main": "./index", + "devDependencies": { + "mocha": "*", + "expect.js": "*", + "serve": "*" + }, + "component": { + "scripts": { + "ms/index.js": "index.js" + } + }, + "gitHead": "713dcf26d9e6fd9dbc95affe7eff9783b7f1b909", + "bugs": { + "url": "https://github.com/guille/ms.js/issues" + }, + "homepage": "https://github.com/guille/ms.js", + "_id": "ms@0.7.1", + "scripts": {}, + "_shasum": "9cd13c03adbff25b65effde7ce864ee952017098", + "_from": "ms@0.7.1", + "_npmVersion": "2.7.5", + "_nodeVersion": "0.12.2", + "_npmUser": { + "name": "rauchg", + "email": "rauchg@gmail.com" + }, + "maintainers": [ + { + "name": "rauchg", + "email": "rauchg@gmail.com" + } + ], + "dist": { + "shasum": "9cd13c03adbff25b65effde7ce864ee952017098", + "tarball": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/debug/package.json b/ui/node_modules/express/node_modules/debug/package.json index 0062a0bd..f2148c9e 100644 --- a/ui/node_modules/express/node_modules/debug/package.json +++ b/ui/node_modules/express/node_modules/debug/package.json @@ -1,73 +1,73 @@ -{ - "name": "debug", - "version": "2.2.0", - "repository": { - "type": "git", - "url": "git://github.com/visionmedia/debug.git" - }, - "description": "small debugging utility", - "keywords": [ - "debug", - "log", - "debugger" - ], - "author": { - "name": "TJ Holowaychuk", - "email": "tj@vision-media.ca" - }, - "contributors": [ - { - "name": "Nathan Rajlich", - "email": "nathan@tootallnate.net", - "url": "http://n8.io" - } - ], - "license": "MIT", - "dependencies": { - "ms": "0.7.1" - }, - "devDependencies": { - "browserify": "9.0.3", - "mocha": "*" - }, - "main": "./node.js", - "browser": "./browser.js", - "component": { - "scripts": { - "debug/index.js": "browser.js", - "debug/debug.js": "debug.js" - } - }, - "gitHead": "b38458422b5aa8aa6d286b10dfe427e8a67e2b35", - "bugs": { - "url": "https://github.com/visionmedia/debug/issues" - }, - "homepage": "https://github.com/visionmedia/debug", - "_id": "debug@2.2.0", - "scripts": {}, - "_shasum": "f87057e995b1a1f6ae6a4960664137bc56f039da", - "_from": "debug@>=2.2.0 <2.3.0", - "_npmVersion": "2.7.4", - "_nodeVersion": "0.12.2", - "_npmUser": { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - }, - "maintainers": [ - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - } - ], - "dist": { - "shasum": "f87057e995b1a1f6ae6a4960664137bc56f039da", - "tarball": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "debug", + "version": "2.2.0", + "repository": { + "type": "git", + "url": "git://github.com/visionmedia/debug.git" + }, + "description": "small debugging utility", + "keywords": [ + "debug", + "log", + "debugger" + ], + "author": { + "name": "TJ Holowaychuk", + "email": "tj@vision-media.ca" + }, + "contributors": [ + { + "name": "Nathan Rajlich", + "email": "nathan@tootallnate.net", + "url": "http://n8.io" + } + ], + "license": "MIT", + "dependencies": { + "ms": "0.7.1" + }, + "devDependencies": { + "browserify": "9.0.3", + "mocha": "*" + }, + "main": "./node.js", + "browser": "./browser.js", + "component": { + "scripts": { + "debug/index.js": "browser.js", + "debug/debug.js": "debug.js" + } + }, + "gitHead": "b38458422b5aa8aa6d286b10dfe427e8a67e2b35", + "bugs": { + "url": "https://github.com/visionmedia/debug/issues" + }, + "homepage": "https://github.com/visionmedia/debug", + "_id": "debug@2.2.0", + "scripts": {}, + "_shasum": "f87057e995b1a1f6ae6a4960664137bc56f039da", + "_from": "debug@>=2.2.0 <2.3.0", + "_npmVersion": "2.7.4", + "_nodeVersion": "0.12.2", + "_npmUser": { + "name": "tootallnate", + "email": "nathan@tootallnate.net" + }, + "maintainers": [ + { + "name": "tjholowaychuk", + "email": "tj@vision-media.ca" + }, + { + "name": "tootallnate", + "email": "nathan@tootallnate.net" + } + ], + "dist": { + "shasum": "f87057e995b1a1f6ae6a4960664137bc56f039da", + "tarball": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/depd/History.md b/ui/node_modules/express/node_modules/depd/History.md index 29c6c98c..ace11715 100644 --- a/ui/node_modules/express/node_modules/depd/History.md +++ b/ui/node_modules/express/node_modules/depd/History.md @@ -1,84 +1,84 @@ -1.1.0 / 2015-09-14 -================== - - * Enable strict mode in more places - * Support io.js 3.x - * Support io.js 2.x - * Support web browser loading - - Requires bundler like Browserify or webpack - -1.0.1 / 2015-04-07 -================== - - * Fix `TypeError`s when under `'use strict'` code - * Fix useless type name on auto-generated messages - * Support io.js 1.x - * Support Node.js 0.12 - -1.0.0 / 2014-09-17 -================== - - * No changes - -0.4.5 / 2014-09-09 -================== - - * Improve call speed to functions using the function wrapper - * Support Node.js 0.6 - -0.4.4 / 2014-07-27 -================== - - * Work-around v8 generating empty stack traces - -0.4.3 / 2014-07-26 -================== - - * Fix exception when global `Error.stackTraceLimit` is too low - -0.4.2 / 2014-07-19 -================== - - * Correct call site for wrapped functions and properties - -0.4.1 / 2014-07-19 -================== - - * Improve automatic message generation for function properties - -0.4.0 / 2014-07-19 -================== - - * Add `TRACE_DEPRECATION` environment variable - * Remove non-standard grey color from color output - * Support `--no-deprecation` argument - * Support `--trace-deprecation` argument - * Support `deprecate.property(fn, prop, message)` - -0.3.0 / 2014-06-16 -================== - - * Add `NO_DEPRECATION` environment variable - -0.2.0 / 2014-06-15 -================== - - * Add `deprecate.property(obj, prop, message)` - * Remove `supports-color` dependency for node.js 0.8 - -0.1.0 / 2014-06-15 -================== - - * Add `deprecate.function(fn, message)` - * Add `process.on('deprecation', fn)` emitter - * Automatically generate message when omitted from `deprecate()` - -0.0.1 / 2014-06-15 -================== - - * Fix warning for dynamic calls at singe call site - -0.0.0 / 2014-06-15 -================== - - * Initial implementation +1.1.0 / 2015-09-14 +================== + + * Enable strict mode in more places + * Support io.js 3.x + * Support io.js 2.x + * Support web browser loading + - Requires bundler like Browserify or webpack + +1.0.1 / 2015-04-07 +================== + + * Fix `TypeError`s when under `'use strict'` code + * Fix useless type name on auto-generated messages + * Support io.js 1.x + * Support Node.js 0.12 + +1.0.0 / 2014-09-17 +================== + + * No changes + +0.4.5 / 2014-09-09 +================== + + * Improve call speed to functions using the function wrapper + * Support Node.js 0.6 + +0.4.4 / 2014-07-27 +================== + + * Work-around v8 generating empty stack traces + +0.4.3 / 2014-07-26 +================== + + * Fix exception when global `Error.stackTraceLimit` is too low + +0.4.2 / 2014-07-19 +================== + + * Correct call site for wrapped functions and properties + +0.4.1 / 2014-07-19 +================== + + * Improve automatic message generation for function properties + +0.4.0 / 2014-07-19 +================== + + * Add `TRACE_DEPRECATION` environment variable + * Remove non-standard grey color from color output + * Support `--no-deprecation` argument + * Support `--trace-deprecation` argument + * Support `deprecate.property(fn, prop, message)` + +0.3.0 / 2014-06-16 +================== + + * Add `NO_DEPRECATION` environment variable + +0.2.0 / 2014-06-15 +================== + + * Add `deprecate.property(obj, prop, message)` + * Remove `supports-color` dependency for node.js 0.8 + +0.1.0 / 2014-06-15 +================== + + * Add `deprecate.function(fn, message)` + * Add `process.on('deprecation', fn)` emitter + * Automatically generate message when omitted from `deprecate()` + +0.0.1 / 2014-06-15 +================== + + * Fix warning for dynamic calls at singe call site + +0.0.0 / 2014-06-15 +================== + + * Initial implementation diff --git a/ui/node_modules/express/node_modules/depd/LICENSE b/ui/node_modules/express/node_modules/depd/LICENSE index a35fc45b..142ede38 100644 --- a/ui/node_modules/express/node_modules/depd/LICENSE +++ b/ui/node_modules/express/node_modules/depd/LICENSE @@ -1,22 +1,22 @@ -(The MIT License) - -Copyright (c) 2014-2015 Douglas Christopher Wilson - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2014-2015 Douglas Christopher Wilson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/depd/Readme.md b/ui/node_modules/express/node_modules/depd/Readme.md index c55857b0..09bb9799 100644 --- a/ui/node_modules/express/node_modules/depd/Readme.md +++ b/ui/node_modules/express/node_modules/depd/Readme.md @@ -1,281 +1,281 @@ -# depd - -[![NPM Version][npm-version-image]][npm-url] -[![NPM Downloads][npm-downloads-image]][npm-url] -[![Node.js Version][node-image]][node-url] -[![Linux Build][travis-image]][travis-url] -[![Windows Build][appveyor-image]][appveyor-url] -[![Coverage Status][coveralls-image]][coveralls-url] -[![Gratipay][gratipay-image]][gratipay-url] - -Deprecate all the things - -> With great modules comes great responsibility; mark things deprecated! - -## Install - -This module is installed directly using `npm`: - -```sh -$ npm install depd -``` - -This module can also be bundled with systems like -[Browserify](http://browserify.org/) or [webpack](https://webpack.github.io/), -though by default this module will alter it's API to no longer display or -track deprecations. - -## API - -```js -var deprecate = require('depd')('my-module') -``` - -This library allows you to display deprecation messages to your users. -This library goes above and beyond with deprecation warnings by -introspection of the call stack (but only the bits that it is interested -in). - -Instead of just warning on the first invocation of a deprecated -function and never again, this module will warn on the first invocation -of a deprecated function per unique call site, making it ideal to alert -users of all deprecated uses across the code base, rather than just -whatever happens to execute first. - -The deprecation warnings from this module also include the file and line -information for the call into the module that the deprecated function was -in. - -**NOTE** this library has a similar interface to the `debug` module, and -this module uses the calling file to get the boundary for the call stacks, -so you should always create a new `deprecate` object in each file and not -within some central file. - -### depd(namespace) - -Create a new deprecate function that uses the given namespace name in the -messages and will display the call site prior to the stack entering the -file this function was called from. It is highly suggested you use the -name of your module as the namespace. - -### deprecate(message) - -Call this function from deprecated code to display a deprecation message. -This message will appear once per unique caller site. Caller site is the -first call site in the stack in a different file from the caller of this -function. - -If the message is omitted, a message is generated for you based on the site -of the `deprecate()` call and will display the name of the function called, -similar to the name displayed in a stack trace. - -### deprecate.function(fn, message) - -Call this function to wrap a given function in a deprecation message on any -call to the function. An optional message can be supplied to provide a custom -message. - -### deprecate.property(obj, prop, message) - -Call this function to wrap a given property on object in a deprecation message -on any accessing or setting of the property. An optional message can be supplied -to provide a custom message. - -The method must be called on the object where the property belongs (not -inherited from the prototype). - -If the property is a data descriptor, it will be converted to an accessor -descriptor in order to display the deprecation message. - -### process.on('deprecation', fn) - -This module will allow easy capturing of deprecation errors by emitting the -errors as the type "deprecation" on the global `process`. If there are no -listeners for this type, the errors are written to STDERR as normal, but if -there are any listeners, nothing will be written to STDERR and instead only -emitted. From there, you can write the errors in a different format or to a -logging source. - -The error represents the deprecation and is emitted only once with the same -rules as writing to STDERR. The error has the following properties: - - - `message` - This is the message given by the library - - `name` - This is always `'DeprecationError'` - - `namespace` - This is the namespace the deprecation came from - - `stack` - This is the stack of the call to the deprecated thing - -Example `error.stack` output: - -``` -DeprecationError: my-cool-module deprecated oldfunction - at Object. ([eval]-wrapper:6:22) - at Module._compile (module.js:456:26) - at evalScript (node.js:532:25) - at startup (node.js:80:7) - at node.js:902:3 -``` - -### process.env.NO_DEPRECATION - -As a user of modules that are deprecated, the environment variable `NO_DEPRECATION` -is provided as a quick solution to silencing deprecation warnings from being -output. The format of this is similar to that of `DEBUG`: - -```sh -$ NO_DEPRECATION=my-module,othermod node app.js -``` - -This will suppress deprecations from being output for "my-module" and "othermod". -The value is a list of comma-separated namespaces. To suppress every warning -across all namespaces, use the value `*` for a namespace. - -Providing the argument `--no-deprecation` to the `node` executable will suppress -all deprecations (only available in Node.js 0.8 or higher). - -**NOTE** This will not suppress the deperecations given to any "deprecation" -event listeners, just the output to STDERR. - -### process.env.TRACE_DEPRECATION - -As a user of modules that are deprecated, the environment variable `TRACE_DEPRECATION` -is provided as a solution to getting more detailed location information in deprecation -warnings by including the entire stack trace. The format of this is the same as -`NO_DEPRECATION`: - -```sh -$ TRACE_DEPRECATION=my-module,othermod node app.js -``` - -This will include stack traces for deprecations being output for "my-module" and -"othermod". The value is a list of comma-separated namespaces. To trace every -warning across all namespaces, use the value `*` for a namespace. - -Providing the argument `--trace-deprecation` to the `node` executable will trace -all deprecations (only available in Node.js 0.8 or higher). - -**NOTE** This will not trace the deperecations silenced by `NO_DEPRECATION`. - -## Display - -![message](files/message.png) - -When a user calls a function in your library that you mark deprecated, they -will see the following written to STDERR (in the given colors, similar colors -and layout to the `debug` module): - -``` -bright cyan bright yellow -| | reset cyan -| | | | -▼ ▼ ▼ ▼ -my-cool-module deprecated oldfunction [eval]-wrapper:6:22 -▲ ▲ ▲ ▲ -| | | | -namespace | | location of mycoolmod.oldfunction() call - | deprecation message - the word "deprecated" -``` - -If the user redirects their STDERR to a file or somewhere that does not support -colors, they see (similar layout to the `debug` module): - -``` -Sun, 15 Jun 2014 05:21:37 GMT my-cool-module deprecated oldfunction at [eval]-wrapper:6:22 -▲ ▲ ▲ ▲ ▲ -| | | | | -timestamp of message namespace | | location of mycoolmod.oldfunction() call - | deprecation message - the word "deprecated" -``` - -## Examples - -### Deprecating all calls to a function - -This will display a deprecated message about "oldfunction" being deprecated -from "my-module" on STDERR. - -```js -var deprecate = require('depd')('my-cool-module') - -// message automatically derived from function name -// Object.oldfunction -exports.oldfunction = deprecate.function(function oldfunction() { - // all calls to function are deprecated -}) - -// specific message -exports.oldfunction = deprecate.function(function () { - // all calls to function are deprecated -}, 'oldfunction') -``` - -### Conditionally deprecating a function call - -This will display a deprecated message about "weirdfunction" being deprecated -from "my-module" on STDERR when called with less than 2 arguments. - -```js -var deprecate = require('depd')('my-cool-module') - -exports.weirdfunction = function () { - if (arguments.length < 2) { - // calls with 0 or 1 args are deprecated - deprecate('weirdfunction args < 2') - } -} -``` - -When calling `deprecate` as a function, the warning is counted per call site -within your own module, so you can display different deprecations depending -on different situations and the users will still get all the warnings: - -```js -var deprecate = require('depd')('my-cool-module') - -exports.weirdfunction = function () { - if (arguments.length < 2) { - // calls with 0 or 1 args are deprecated - deprecate('weirdfunction args < 2') - } else if (typeof arguments[0] !== 'string') { - // calls with non-string first argument are deprecated - deprecate('weirdfunction non-string first arg') - } -} -``` - -### Deprecating property access - -This will display a deprecated message about "oldprop" being deprecated -from "my-module" on STDERR when accessed. A deprecation will be displayed -when setting the value and when getting the value. - -```js -var deprecate = require('depd')('my-cool-module') - -exports.oldprop = 'something' - -// message automatically derives from property name -deprecate.property(exports, 'oldprop') - -// explicit message -deprecate.property(exports, 'oldprop', 'oldprop >= 0.10') -``` - -## License - -[MIT](LICENSE) - -[npm-version-image]: https://img.shields.io/npm/v/depd.svg -[npm-downloads-image]: https://img.shields.io/npm/dm/depd.svg -[npm-url]: https://npmjs.org/package/depd -[travis-image]: https://img.shields.io/travis/dougwilson/nodejs-depd/master.svg?label=linux -[travis-url]: https://travis-ci.org/dougwilson/nodejs-depd -[appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/nodejs-depd/master.svg?label=windows -[appveyor-url]: https://ci.appveyor.com/project/dougwilson/nodejs-depd -[coveralls-image]: https://img.shields.io/coveralls/dougwilson/nodejs-depd/master.svg -[coveralls-url]: https://coveralls.io/r/dougwilson/nodejs-depd?branch=master -[node-image]: https://img.shields.io/node/v/depd.svg -[node-url]: http://nodejs.org/download/ -[gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg -[gratipay-url]: https://www.gratipay.com/dougwilson/ +# depd + +[![NPM Version][npm-version-image]][npm-url] +[![NPM Downloads][npm-downloads-image]][npm-url] +[![Node.js Version][node-image]][node-url] +[![Linux Build][travis-image]][travis-url] +[![Windows Build][appveyor-image]][appveyor-url] +[![Coverage Status][coveralls-image]][coveralls-url] +[![Gratipay][gratipay-image]][gratipay-url] + +Deprecate all the things + +> With great modules comes great responsibility; mark things deprecated! + +## Install + +This module is installed directly using `npm`: + +```sh +$ npm install depd +``` + +This module can also be bundled with systems like +[Browserify](http://browserify.org/) or [webpack](https://webpack.github.io/), +though by default this module will alter it's API to no longer display or +track deprecations. + +## API + +```js +var deprecate = require('depd')('my-module') +``` + +This library allows you to display deprecation messages to your users. +This library goes above and beyond with deprecation warnings by +introspection of the call stack (but only the bits that it is interested +in). + +Instead of just warning on the first invocation of a deprecated +function and never again, this module will warn on the first invocation +of a deprecated function per unique call site, making it ideal to alert +users of all deprecated uses across the code base, rather than just +whatever happens to execute first. + +The deprecation warnings from this module also include the file and line +information for the call into the module that the deprecated function was +in. + +**NOTE** this library has a similar interface to the `debug` module, and +this module uses the calling file to get the boundary for the call stacks, +so you should always create a new `deprecate` object in each file and not +within some central file. + +### depd(namespace) + +Create a new deprecate function that uses the given namespace name in the +messages and will display the call site prior to the stack entering the +file this function was called from. It is highly suggested you use the +name of your module as the namespace. + +### deprecate(message) + +Call this function from deprecated code to display a deprecation message. +This message will appear once per unique caller site. Caller site is the +first call site in the stack in a different file from the caller of this +function. + +If the message is omitted, a message is generated for you based on the site +of the `deprecate()` call and will display the name of the function called, +similar to the name displayed in a stack trace. + +### deprecate.function(fn, message) + +Call this function to wrap a given function in a deprecation message on any +call to the function. An optional message can be supplied to provide a custom +message. + +### deprecate.property(obj, prop, message) + +Call this function to wrap a given property on object in a deprecation message +on any accessing or setting of the property. An optional message can be supplied +to provide a custom message. + +The method must be called on the object where the property belongs (not +inherited from the prototype). + +If the property is a data descriptor, it will be converted to an accessor +descriptor in order to display the deprecation message. + +### process.on('deprecation', fn) + +This module will allow easy capturing of deprecation errors by emitting the +errors as the type "deprecation" on the global `process`. If there are no +listeners for this type, the errors are written to STDERR as normal, but if +there are any listeners, nothing will be written to STDERR and instead only +emitted. From there, you can write the errors in a different format or to a +logging source. + +The error represents the deprecation and is emitted only once with the same +rules as writing to STDERR. The error has the following properties: + + - `message` - This is the message given by the library + - `name` - This is always `'DeprecationError'` + - `namespace` - This is the namespace the deprecation came from + - `stack` - This is the stack of the call to the deprecated thing + +Example `error.stack` output: + +``` +DeprecationError: my-cool-module deprecated oldfunction + at Object. ([eval]-wrapper:6:22) + at Module._compile (module.js:456:26) + at evalScript (node.js:532:25) + at startup (node.js:80:7) + at node.js:902:3 +``` + +### process.env.NO_DEPRECATION + +As a user of modules that are deprecated, the environment variable `NO_DEPRECATION` +is provided as a quick solution to silencing deprecation warnings from being +output. The format of this is similar to that of `DEBUG`: + +```sh +$ NO_DEPRECATION=my-module,othermod node app.js +``` + +This will suppress deprecations from being output for "my-module" and "othermod". +The value is a list of comma-separated namespaces. To suppress every warning +across all namespaces, use the value `*` for a namespace. + +Providing the argument `--no-deprecation` to the `node` executable will suppress +all deprecations (only available in Node.js 0.8 or higher). + +**NOTE** This will not suppress the deperecations given to any "deprecation" +event listeners, just the output to STDERR. + +### process.env.TRACE_DEPRECATION + +As a user of modules that are deprecated, the environment variable `TRACE_DEPRECATION` +is provided as a solution to getting more detailed location information in deprecation +warnings by including the entire stack trace. The format of this is the same as +`NO_DEPRECATION`: + +```sh +$ TRACE_DEPRECATION=my-module,othermod node app.js +``` + +This will include stack traces for deprecations being output for "my-module" and +"othermod". The value is a list of comma-separated namespaces. To trace every +warning across all namespaces, use the value `*` for a namespace. + +Providing the argument `--trace-deprecation` to the `node` executable will trace +all deprecations (only available in Node.js 0.8 or higher). + +**NOTE** This will not trace the deperecations silenced by `NO_DEPRECATION`. + +## Display + +![message](files/message.png) + +When a user calls a function in your library that you mark deprecated, they +will see the following written to STDERR (in the given colors, similar colors +and layout to the `debug` module): + +``` +bright cyan bright yellow +| | reset cyan +| | | | +▼ ▼ ▼ ▼ +my-cool-module deprecated oldfunction [eval]-wrapper:6:22 +▲ ▲ ▲ ▲ +| | | | +namespace | | location of mycoolmod.oldfunction() call + | deprecation message + the word "deprecated" +``` + +If the user redirects their STDERR to a file or somewhere that does not support +colors, they see (similar layout to the `debug` module): + +``` +Sun, 15 Jun 2014 05:21:37 GMT my-cool-module deprecated oldfunction at [eval]-wrapper:6:22 +▲ ▲ ▲ ▲ ▲ +| | | | | +timestamp of message namespace | | location of mycoolmod.oldfunction() call + | deprecation message + the word "deprecated" +``` + +## Examples + +### Deprecating all calls to a function + +This will display a deprecated message about "oldfunction" being deprecated +from "my-module" on STDERR. + +```js +var deprecate = require('depd')('my-cool-module') + +// message automatically derived from function name +// Object.oldfunction +exports.oldfunction = deprecate.function(function oldfunction() { + // all calls to function are deprecated +}) + +// specific message +exports.oldfunction = deprecate.function(function () { + // all calls to function are deprecated +}, 'oldfunction') +``` + +### Conditionally deprecating a function call + +This will display a deprecated message about "weirdfunction" being deprecated +from "my-module" on STDERR when called with less than 2 arguments. + +```js +var deprecate = require('depd')('my-cool-module') + +exports.weirdfunction = function () { + if (arguments.length < 2) { + // calls with 0 or 1 args are deprecated + deprecate('weirdfunction args < 2') + } +} +``` + +When calling `deprecate` as a function, the warning is counted per call site +within your own module, so you can display different deprecations depending +on different situations and the users will still get all the warnings: + +```js +var deprecate = require('depd')('my-cool-module') + +exports.weirdfunction = function () { + if (arguments.length < 2) { + // calls with 0 or 1 args are deprecated + deprecate('weirdfunction args < 2') + } else if (typeof arguments[0] !== 'string') { + // calls with non-string first argument are deprecated + deprecate('weirdfunction non-string first arg') + } +} +``` + +### Deprecating property access + +This will display a deprecated message about "oldprop" being deprecated +from "my-module" on STDERR when accessed. A deprecation will be displayed +when setting the value and when getting the value. + +```js +var deprecate = require('depd')('my-cool-module') + +exports.oldprop = 'something' + +// message automatically derives from property name +deprecate.property(exports, 'oldprop') + +// explicit message +deprecate.property(exports, 'oldprop', 'oldprop >= 0.10') +``` + +## License + +[MIT](LICENSE) + +[npm-version-image]: https://img.shields.io/npm/v/depd.svg +[npm-downloads-image]: https://img.shields.io/npm/dm/depd.svg +[npm-url]: https://npmjs.org/package/depd +[travis-image]: https://img.shields.io/travis/dougwilson/nodejs-depd/master.svg?label=linux +[travis-url]: https://travis-ci.org/dougwilson/nodejs-depd +[appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/nodejs-depd/master.svg?label=windows +[appveyor-url]: https://ci.appveyor.com/project/dougwilson/nodejs-depd +[coveralls-image]: https://img.shields.io/coveralls/dougwilson/nodejs-depd/master.svg +[coveralls-url]: https://coveralls.io/r/dougwilson/nodejs-depd?branch=master +[node-image]: https://img.shields.io/node/v/depd.svg +[node-url]: http://nodejs.org/download/ +[gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg +[gratipay-url]: https://www.gratipay.com/dougwilson/ diff --git a/ui/node_modules/express/node_modules/depd/index.js b/ui/node_modules/express/node_modules/depd/index.js index d1ee5cad..fddcae87 100644 --- a/ui/node_modules/express/node_modules/depd/index.js +++ b/ui/node_modules/express/node_modules/depd/index.js @@ -1,521 +1,521 @@ -/*! - * depd - * Copyright(c) 2014-2015 Douglas Christopher Wilson - * MIT Licensed - */ - -/** - * Module dependencies. - */ - -var callSiteToString = require('./lib/compat').callSiteToString -var eventListenerCount = require('./lib/compat').eventListenerCount -var relative = require('path').relative - -/** - * Module exports. - */ - -module.exports = depd - -/** - * Get the path to base files on. - */ - -var basePath = process.cwd() - -/** - * Determine if namespace is contained in the string. - */ - -function containsNamespace(str, namespace) { - var val = str.split(/[ ,]+/) - - namespace = String(namespace).toLowerCase() - - for (var i = 0 ; i < val.length; i++) { - if (!(str = val[i])) continue; - - // namespace contained - if (str === '*' || str.toLowerCase() === namespace) { - return true - } - } - - return false -} - -/** - * Convert a data descriptor to accessor descriptor. - */ - -function convertDataDescriptorToAccessor(obj, prop, message) { - var descriptor = Object.getOwnPropertyDescriptor(obj, prop) - var value = descriptor.value - - descriptor.get = function getter() { return value } - - if (descriptor.writable) { - descriptor.set = function setter(val) { return value = val } - } - - delete descriptor.value - delete descriptor.writable - - Object.defineProperty(obj, prop, descriptor) - - return descriptor -} - -/** - * Create arguments string to keep arity. - */ - -function createArgumentsString(arity) { - var str = '' - - for (var i = 0; i < arity; i++) { - str += ', arg' + i - } - - return str.substr(2) -} - -/** - * Create stack string from stack. - */ - -function createStackString(stack) { - var str = this.name + ': ' + this.namespace - - if (this.message) { - str += ' deprecated ' + this.message - } - - for (var i = 0; i < stack.length; i++) { - str += '\n at ' + callSiteToString(stack[i]) - } - - return str -} - -/** - * Create deprecate for namespace in caller. - */ - -function depd(namespace) { - if (!namespace) { - throw new TypeError('argument namespace is required') - } - - var stack = getStack() - var site = callSiteLocation(stack[1]) - var file = site[0] - - function deprecate(message) { - // call to self as log - log.call(deprecate, message) - } - - deprecate._file = file - deprecate._ignored = isignored(namespace) - deprecate._namespace = namespace - deprecate._traced = istraced(namespace) - deprecate._warned = Object.create(null) - - deprecate.function = wrapfunction - deprecate.property = wrapproperty - - return deprecate -} - -/** - * Determine if namespace is ignored. - */ - -function isignored(namespace) { - /* istanbul ignore next: tested in a child processs */ - if (process.noDeprecation) { - // --no-deprecation support - return true - } - - var str = process.env.NO_DEPRECATION || '' - - // namespace ignored - return containsNamespace(str, namespace) -} - -/** - * Determine if namespace is traced. - */ - -function istraced(namespace) { - /* istanbul ignore next: tested in a child processs */ - if (process.traceDeprecation) { - // --trace-deprecation support - return true - } - - var str = process.env.TRACE_DEPRECATION || '' - - // namespace traced - return containsNamespace(str, namespace) -} - -/** - * Display deprecation message. - */ - -function log(message, site) { - var haslisteners = eventListenerCount(process, 'deprecation') !== 0 - - // abort early if no destination - if (!haslisteners && this._ignored) { - return - } - - var caller - var callFile - var callSite - var i = 0 - var seen = false - var stack = getStack() - var file = this._file - - if (site) { - // provided site - callSite = callSiteLocation(stack[1]) - callSite.name = site.name - file = callSite[0] - } else { - // get call site - i = 2 - site = callSiteLocation(stack[i]) - callSite = site - } - - // get caller of deprecated thing in relation to file - for (; i < stack.length; i++) { - caller = callSiteLocation(stack[i]) - callFile = caller[0] - - if (callFile === file) { - seen = true - } else if (callFile === this._file) { - file = this._file - } else if (seen) { - break - } - } - - var key = caller - ? site.join(':') + '__' + caller.join(':') - : undefined - - if (key !== undefined && key in this._warned) { - // already warned - return - } - - this._warned[key] = true - - // generate automatic message from call site - if (!message) { - message = callSite === site || !callSite.name - ? defaultMessage(site) - : defaultMessage(callSite) - } - - // emit deprecation if listeners exist - if (haslisteners) { - var err = DeprecationError(this._namespace, message, stack.slice(i)) - process.emit('deprecation', err) - return - } - - // format and write message - var format = process.stderr.isTTY - ? formatColor - : formatPlain - var msg = format.call(this, message, caller, stack.slice(i)) - process.stderr.write(msg + '\n', 'utf8') - - return -} - -/** - * Get call site location as array. - */ - -function callSiteLocation(callSite) { - var file = callSite.getFileName() || '' - var line = callSite.getLineNumber() - var colm = callSite.getColumnNumber() - - if (callSite.isEval()) { - file = callSite.getEvalOrigin() + ', ' + file - } - - var site = [file, line, colm] - - site.callSite = callSite - site.name = callSite.getFunctionName() - - return site -} - -/** - * Generate a default message from the site. - */ - -function defaultMessage(site) { - var callSite = site.callSite - var funcName = site.name - - // make useful anonymous name - if (!funcName) { - funcName = '' - } - - var context = callSite.getThis() - var typeName = context && callSite.getTypeName() - - // ignore useless type name - if (typeName === 'Object') { - typeName = undefined - } - - // make useful type name - if (typeName === 'Function') { - typeName = context.name || typeName - } - - return typeName && callSite.getMethodName() - ? typeName + '.' + funcName - : funcName -} - -/** - * Format deprecation message without color. - */ - -function formatPlain(msg, caller, stack) { - var timestamp = new Date().toUTCString() - - var formatted = timestamp - + ' ' + this._namespace - + ' deprecated ' + msg - - // add stack trace - if (this._traced) { - for (var i = 0; i < stack.length; i++) { - formatted += '\n at ' + callSiteToString(stack[i]) - } - - return formatted - } - - if (caller) { - formatted += ' at ' + formatLocation(caller) - } - - return formatted -} - -/** - * Format deprecation message with color. - */ - -function formatColor(msg, caller, stack) { - var formatted = '\x1b[36;1m' + this._namespace + '\x1b[22;39m' // bold cyan - + ' \x1b[33;1mdeprecated\x1b[22;39m' // bold yellow - + ' \x1b[0m' + msg + '\x1b[39m' // reset - - // add stack trace - if (this._traced) { - for (var i = 0; i < stack.length; i++) { - formatted += '\n \x1b[36mat ' + callSiteToString(stack[i]) + '\x1b[39m' // cyan - } - - return formatted - } - - if (caller) { - formatted += ' \x1b[36m' + formatLocation(caller) + '\x1b[39m' // cyan - } - - return formatted -} - -/** - * Format call site location. - */ - -function formatLocation(callSite) { - return relative(basePath, callSite[0]) - + ':' + callSite[1] - + ':' + callSite[2] -} - -/** - * Get the stack as array of call sites. - */ - -function getStack() { - var limit = Error.stackTraceLimit - var obj = {} - var prep = Error.prepareStackTrace - - Error.prepareStackTrace = prepareObjectStackTrace - Error.stackTraceLimit = Math.max(10, limit) - - // capture the stack - Error.captureStackTrace(obj) - - // slice this function off the top - var stack = obj.stack.slice(1) - - Error.prepareStackTrace = prep - Error.stackTraceLimit = limit - - return stack -} - -/** - * Capture call site stack from v8. - */ - -function prepareObjectStackTrace(obj, stack) { - return stack -} - -/** - * Return a wrapped function in a deprecation message. - */ - -function wrapfunction(fn, message) { - if (typeof fn !== 'function') { - throw new TypeError('argument fn must be a function') - } - - var args = createArgumentsString(fn.length) - var deprecate = this - var stack = getStack() - var site = callSiteLocation(stack[1]) - - site.name = fn.name - - var deprecatedfn = eval('(function (' + args + ') {\n' - + '"use strict"\n' - + 'log.call(deprecate, message, site)\n' - + 'return fn.apply(this, arguments)\n' - + '})') - - return deprecatedfn -} - -/** - * Wrap property in a deprecation message. - */ - -function wrapproperty(obj, prop, message) { - if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) { - throw new TypeError('argument obj must be object') - } - - var descriptor = Object.getOwnPropertyDescriptor(obj, prop) - - if (!descriptor) { - throw new TypeError('must call property on owner object') - } - - if (!descriptor.configurable) { - throw new TypeError('property must be configurable') - } - - var deprecate = this - var stack = getStack() - var site = callSiteLocation(stack[1]) - - // set site name - site.name = prop - - // convert data descriptor - if ('value' in descriptor) { - descriptor = convertDataDescriptorToAccessor(obj, prop, message) - } - - var get = descriptor.get - var set = descriptor.set - - // wrap getter - if (typeof get === 'function') { - descriptor.get = function getter() { - log.call(deprecate, message, site) - return get.apply(this, arguments) - } - } - - // wrap setter - if (typeof set === 'function') { - descriptor.set = function setter() { - log.call(deprecate, message, site) - return set.apply(this, arguments) - } - } - - Object.defineProperty(obj, prop, descriptor) -} - -/** - * Create DeprecationError for deprecation - */ - -function DeprecationError(namespace, message, stack) { - var error = new Error() - var stackString - - Object.defineProperty(error, 'constructor', { - value: DeprecationError - }) - - Object.defineProperty(error, 'message', { - configurable: true, - enumerable: false, - value: message, - writable: true - }) - - Object.defineProperty(error, 'name', { - enumerable: false, - configurable: true, - value: 'DeprecationError', - writable: true - }) - - Object.defineProperty(error, 'namespace', { - configurable: true, - enumerable: false, - value: namespace, - writable: true - }) - - Object.defineProperty(error, 'stack', { - configurable: true, - enumerable: false, - get: function () { - if (stackString !== undefined) { - return stackString - } - - // prepare stack trace - return stackString = createStackString.call(this, stack) - }, - set: function setter(val) { - stackString = val - } - }) - - return error -} +/*! + * depd + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var callSiteToString = require('./lib/compat').callSiteToString +var eventListenerCount = require('./lib/compat').eventListenerCount +var relative = require('path').relative + +/** + * Module exports. + */ + +module.exports = depd + +/** + * Get the path to base files on. + */ + +var basePath = process.cwd() + +/** + * Determine if namespace is contained in the string. + */ + +function containsNamespace(str, namespace) { + var val = str.split(/[ ,]+/) + + namespace = String(namespace).toLowerCase() + + for (var i = 0 ; i < val.length; i++) { + if (!(str = val[i])) continue; + + // namespace contained + if (str === '*' || str.toLowerCase() === namespace) { + return true + } + } + + return false +} + +/** + * Convert a data descriptor to accessor descriptor. + */ + +function convertDataDescriptorToAccessor(obj, prop, message) { + var descriptor = Object.getOwnPropertyDescriptor(obj, prop) + var value = descriptor.value + + descriptor.get = function getter() { return value } + + if (descriptor.writable) { + descriptor.set = function setter(val) { return value = val } + } + + delete descriptor.value + delete descriptor.writable + + Object.defineProperty(obj, prop, descriptor) + + return descriptor +} + +/** + * Create arguments string to keep arity. + */ + +function createArgumentsString(arity) { + var str = '' + + for (var i = 0; i < arity; i++) { + str += ', arg' + i + } + + return str.substr(2) +} + +/** + * Create stack string from stack. + */ + +function createStackString(stack) { + var str = this.name + ': ' + this.namespace + + if (this.message) { + str += ' deprecated ' + this.message + } + + for (var i = 0; i < stack.length; i++) { + str += '\n at ' + callSiteToString(stack[i]) + } + + return str +} + +/** + * Create deprecate for namespace in caller. + */ + +function depd(namespace) { + if (!namespace) { + throw new TypeError('argument namespace is required') + } + + var stack = getStack() + var site = callSiteLocation(stack[1]) + var file = site[0] + + function deprecate(message) { + // call to self as log + log.call(deprecate, message) + } + + deprecate._file = file + deprecate._ignored = isignored(namespace) + deprecate._namespace = namespace + deprecate._traced = istraced(namespace) + deprecate._warned = Object.create(null) + + deprecate.function = wrapfunction + deprecate.property = wrapproperty + + return deprecate +} + +/** + * Determine if namespace is ignored. + */ + +function isignored(namespace) { + /* istanbul ignore next: tested in a child processs */ + if (process.noDeprecation) { + // --no-deprecation support + return true + } + + var str = process.env.NO_DEPRECATION || '' + + // namespace ignored + return containsNamespace(str, namespace) +} + +/** + * Determine if namespace is traced. + */ + +function istraced(namespace) { + /* istanbul ignore next: tested in a child processs */ + if (process.traceDeprecation) { + // --trace-deprecation support + return true + } + + var str = process.env.TRACE_DEPRECATION || '' + + // namespace traced + return containsNamespace(str, namespace) +} + +/** + * Display deprecation message. + */ + +function log(message, site) { + var haslisteners = eventListenerCount(process, 'deprecation') !== 0 + + // abort early if no destination + if (!haslisteners && this._ignored) { + return + } + + var caller + var callFile + var callSite + var i = 0 + var seen = false + var stack = getStack() + var file = this._file + + if (site) { + // provided site + callSite = callSiteLocation(stack[1]) + callSite.name = site.name + file = callSite[0] + } else { + // get call site + i = 2 + site = callSiteLocation(stack[i]) + callSite = site + } + + // get caller of deprecated thing in relation to file + for (; i < stack.length; i++) { + caller = callSiteLocation(stack[i]) + callFile = caller[0] + + if (callFile === file) { + seen = true + } else if (callFile === this._file) { + file = this._file + } else if (seen) { + break + } + } + + var key = caller + ? site.join(':') + '__' + caller.join(':') + : undefined + + if (key !== undefined && key in this._warned) { + // already warned + return + } + + this._warned[key] = true + + // generate automatic message from call site + if (!message) { + message = callSite === site || !callSite.name + ? defaultMessage(site) + : defaultMessage(callSite) + } + + // emit deprecation if listeners exist + if (haslisteners) { + var err = DeprecationError(this._namespace, message, stack.slice(i)) + process.emit('deprecation', err) + return + } + + // format and write message + var format = process.stderr.isTTY + ? formatColor + : formatPlain + var msg = format.call(this, message, caller, stack.slice(i)) + process.stderr.write(msg + '\n', 'utf8') + + return +} + +/** + * Get call site location as array. + */ + +function callSiteLocation(callSite) { + var file = callSite.getFileName() || '' + var line = callSite.getLineNumber() + var colm = callSite.getColumnNumber() + + if (callSite.isEval()) { + file = callSite.getEvalOrigin() + ', ' + file + } + + var site = [file, line, colm] + + site.callSite = callSite + site.name = callSite.getFunctionName() + + return site +} + +/** + * Generate a default message from the site. + */ + +function defaultMessage(site) { + var callSite = site.callSite + var funcName = site.name + + // make useful anonymous name + if (!funcName) { + funcName = '' + } + + var context = callSite.getThis() + var typeName = context && callSite.getTypeName() + + // ignore useless type name + if (typeName === 'Object') { + typeName = undefined + } + + // make useful type name + if (typeName === 'Function') { + typeName = context.name || typeName + } + + return typeName && callSite.getMethodName() + ? typeName + '.' + funcName + : funcName +} + +/** + * Format deprecation message without color. + */ + +function formatPlain(msg, caller, stack) { + var timestamp = new Date().toUTCString() + + var formatted = timestamp + + ' ' + this._namespace + + ' deprecated ' + msg + + // add stack trace + if (this._traced) { + for (var i = 0; i < stack.length; i++) { + formatted += '\n at ' + callSiteToString(stack[i]) + } + + return formatted + } + + if (caller) { + formatted += ' at ' + formatLocation(caller) + } + + return formatted +} + +/** + * Format deprecation message with color. + */ + +function formatColor(msg, caller, stack) { + var formatted = '\x1b[36;1m' + this._namespace + '\x1b[22;39m' // bold cyan + + ' \x1b[33;1mdeprecated\x1b[22;39m' // bold yellow + + ' \x1b[0m' + msg + '\x1b[39m' // reset + + // add stack trace + if (this._traced) { + for (var i = 0; i < stack.length; i++) { + formatted += '\n \x1b[36mat ' + callSiteToString(stack[i]) + '\x1b[39m' // cyan + } + + return formatted + } + + if (caller) { + formatted += ' \x1b[36m' + formatLocation(caller) + '\x1b[39m' // cyan + } + + return formatted +} + +/** + * Format call site location. + */ + +function formatLocation(callSite) { + return relative(basePath, callSite[0]) + + ':' + callSite[1] + + ':' + callSite[2] +} + +/** + * Get the stack as array of call sites. + */ + +function getStack() { + var limit = Error.stackTraceLimit + var obj = {} + var prep = Error.prepareStackTrace + + Error.prepareStackTrace = prepareObjectStackTrace + Error.stackTraceLimit = Math.max(10, limit) + + // capture the stack + Error.captureStackTrace(obj) + + // slice this function off the top + var stack = obj.stack.slice(1) + + Error.prepareStackTrace = prep + Error.stackTraceLimit = limit + + return stack +} + +/** + * Capture call site stack from v8. + */ + +function prepareObjectStackTrace(obj, stack) { + return stack +} + +/** + * Return a wrapped function in a deprecation message. + */ + +function wrapfunction(fn, message) { + if (typeof fn !== 'function') { + throw new TypeError('argument fn must be a function') + } + + var args = createArgumentsString(fn.length) + var deprecate = this + var stack = getStack() + var site = callSiteLocation(stack[1]) + + site.name = fn.name + + var deprecatedfn = eval('(function (' + args + ') {\n' + + '"use strict"\n' + + 'log.call(deprecate, message, site)\n' + + 'return fn.apply(this, arguments)\n' + + '})') + + return deprecatedfn +} + +/** + * Wrap property in a deprecation message. + */ + +function wrapproperty(obj, prop, message) { + if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) { + throw new TypeError('argument obj must be object') + } + + var descriptor = Object.getOwnPropertyDescriptor(obj, prop) + + if (!descriptor) { + throw new TypeError('must call property on owner object') + } + + if (!descriptor.configurable) { + throw new TypeError('property must be configurable') + } + + var deprecate = this + var stack = getStack() + var site = callSiteLocation(stack[1]) + + // set site name + site.name = prop + + // convert data descriptor + if ('value' in descriptor) { + descriptor = convertDataDescriptorToAccessor(obj, prop, message) + } + + var get = descriptor.get + var set = descriptor.set + + // wrap getter + if (typeof get === 'function') { + descriptor.get = function getter() { + log.call(deprecate, message, site) + return get.apply(this, arguments) + } + } + + // wrap setter + if (typeof set === 'function') { + descriptor.set = function setter() { + log.call(deprecate, message, site) + return set.apply(this, arguments) + } + } + + Object.defineProperty(obj, prop, descriptor) +} + +/** + * Create DeprecationError for deprecation + */ + +function DeprecationError(namespace, message, stack) { + var error = new Error() + var stackString + + Object.defineProperty(error, 'constructor', { + value: DeprecationError + }) + + Object.defineProperty(error, 'message', { + configurable: true, + enumerable: false, + value: message, + writable: true + }) + + Object.defineProperty(error, 'name', { + enumerable: false, + configurable: true, + value: 'DeprecationError', + writable: true + }) + + Object.defineProperty(error, 'namespace', { + configurable: true, + enumerable: false, + value: namespace, + writable: true + }) + + Object.defineProperty(error, 'stack', { + configurable: true, + enumerable: false, + get: function () { + if (stackString !== undefined) { + return stackString + } + + // prepare stack trace + return stackString = createStackString.call(this, stack) + }, + set: function setter(val) { + stackString = val + } + }) + + return error +} diff --git a/ui/node_modules/express/node_modules/depd/lib/browser/index.js b/ui/node_modules/express/node_modules/depd/lib/browser/index.js index b00b0412..f464e052 100644 --- a/ui/node_modules/express/node_modules/depd/lib/browser/index.js +++ b/ui/node_modules/express/node_modules/depd/lib/browser/index.js @@ -1,79 +1,79 @@ -/*! - * depd - * Copyright(c) 2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict' - -/** - * Module exports. - * @public - */ - -module.exports = depd - -/** - * Create deprecate for namespace in caller. - */ - -function depd(namespace) { - if (!namespace) { - throw new TypeError('argument namespace is required') - } - - function deprecate(message) { - // no-op in browser - } - - deprecate._file = undefined - deprecate._ignored = true - deprecate._namespace = namespace - deprecate._traced = false - deprecate._warned = Object.create(null) - - deprecate.function = wrapfunction - deprecate.property = wrapproperty - - return deprecate -} - -/** - * Return a wrapped function in a deprecation message. - * - * This is a no-op version of the wrapper, which does nothing but call - * validation. - */ - -function wrapfunction(fn, message) { - if (typeof fn !== 'function') { - throw new TypeError('argument fn must be a function') - } - - return fn -} - -/** - * Wrap property in a deprecation message. - * - * This is a no-op version of the wrapper, which does nothing but call - * validation. - */ - -function wrapproperty(obj, prop, message) { - if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) { - throw new TypeError('argument obj must be object') - } - - var descriptor = Object.getOwnPropertyDescriptor(obj, prop) - - if (!descriptor) { - throw new TypeError('must call property on owner object') - } - - if (!descriptor.configurable) { - throw new TypeError('property must be configurable') - } - - return -} +/*! + * depd + * Copyright(c) 2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module exports. + * @public + */ + +module.exports = depd + +/** + * Create deprecate for namespace in caller. + */ + +function depd(namespace) { + if (!namespace) { + throw new TypeError('argument namespace is required') + } + + function deprecate(message) { + // no-op in browser + } + + deprecate._file = undefined + deprecate._ignored = true + deprecate._namespace = namespace + deprecate._traced = false + deprecate._warned = Object.create(null) + + deprecate.function = wrapfunction + deprecate.property = wrapproperty + + return deprecate +} + +/** + * Return a wrapped function in a deprecation message. + * + * This is a no-op version of the wrapper, which does nothing but call + * validation. + */ + +function wrapfunction(fn, message) { + if (typeof fn !== 'function') { + throw new TypeError('argument fn must be a function') + } + + return fn +} + +/** + * Wrap property in a deprecation message. + * + * This is a no-op version of the wrapper, which does nothing but call + * validation. + */ + +function wrapproperty(obj, prop, message) { + if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) { + throw new TypeError('argument obj must be object') + } + + var descriptor = Object.getOwnPropertyDescriptor(obj, prop) + + if (!descriptor) { + throw new TypeError('must call property on owner object') + } + + if (!descriptor.configurable) { + throw new TypeError('property must be configurable') + } + + return +} diff --git a/ui/node_modules/express/node_modules/depd/lib/compat/buffer-concat.js b/ui/node_modules/express/node_modules/depd/lib/compat/buffer-concat.js index 5191f175..4b733810 100644 --- a/ui/node_modules/express/node_modules/depd/lib/compat/buffer-concat.js +++ b/ui/node_modules/express/node_modules/depd/lib/compat/buffer-concat.js @@ -1,35 +1,35 @@ -/*! - * depd - * Copyright(c) 2014 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict' - -/** - * Module exports. - */ - -module.exports = bufferConcat - -/** - * Concatenate an array of Buffers. - */ - -function bufferConcat(bufs) { - var length = 0 - - for (var i = 0, len = bufs.length; i < len; i++) { - length += bufs[i].length - } - - var buf = new Buffer(length) - var pos = 0 - - for (var i = 0, len = bufs.length; i < len; i++) { - bufs[i].copy(buf, pos) - pos += bufs[i].length - } - - return buf -} +/*! + * depd + * Copyright(c) 2014 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module exports. + */ + +module.exports = bufferConcat + +/** + * Concatenate an array of Buffers. + */ + +function bufferConcat(bufs) { + var length = 0 + + for (var i = 0, len = bufs.length; i < len; i++) { + length += bufs[i].length + } + + var buf = new Buffer(length) + var pos = 0 + + for (var i = 0, len = bufs.length; i < len; i++) { + bufs[i].copy(buf, pos) + pos += bufs[i].length + } + + return buf +} diff --git a/ui/node_modules/express/node_modules/depd/lib/compat/callsite-tostring.js b/ui/node_modules/express/node_modules/depd/lib/compat/callsite-tostring.js index 5b49ee4a..9ecef346 100644 --- a/ui/node_modules/express/node_modules/depd/lib/compat/callsite-tostring.js +++ b/ui/node_modules/express/node_modules/depd/lib/compat/callsite-tostring.js @@ -1,103 +1,103 @@ -/*! - * depd - * Copyright(c) 2014 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict' - -/** - * Module exports. - */ - -module.exports = callSiteToString - -/** - * Format a CallSite file location to a string. - */ - -function callSiteFileLocation(callSite) { - var fileName - var fileLocation = '' - - if (callSite.isNative()) { - fileLocation = 'native' - } else if (callSite.isEval()) { - fileName = callSite.getScriptNameOrSourceURL() - if (!fileName) { - fileLocation = callSite.getEvalOrigin() - } - } else { - fileName = callSite.getFileName() - } - - if (fileName) { - fileLocation += fileName - - var lineNumber = callSite.getLineNumber() - if (lineNumber != null) { - fileLocation += ':' + lineNumber - - var columnNumber = callSite.getColumnNumber() - if (columnNumber) { - fileLocation += ':' + columnNumber - } - } - } - - return fileLocation || 'unknown source' -} - -/** - * Format a CallSite to a string. - */ - -function callSiteToString(callSite) { - var addSuffix = true - var fileLocation = callSiteFileLocation(callSite) - var functionName = callSite.getFunctionName() - var isConstructor = callSite.isConstructor() - var isMethodCall = !(callSite.isToplevel() || isConstructor) - var line = '' - - if (isMethodCall) { - var methodName = callSite.getMethodName() - var typeName = getConstructorName(callSite) - - if (functionName) { - if (typeName && functionName.indexOf(typeName) !== 0) { - line += typeName + '.' - } - - line += functionName - - if (methodName && functionName.lastIndexOf('.' + methodName) !== functionName.length - methodName.length - 1) { - line += ' [as ' + methodName + ']' - } - } else { - line += typeName + '.' + (methodName || '') - } - } else if (isConstructor) { - line += 'new ' + (functionName || '') - } else if (functionName) { - line += functionName - } else { - addSuffix = false - line += fileLocation - } - - if (addSuffix) { - line += ' (' + fileLocation + ')' - } - - return line -} - -/** - * Get constructor name of reviver. - */ - -function getConstructorName(obj) { - var receiver = obj.receiver - return (receiver.constructor && receiver.constructor.name) || null -} +/*! + * depd + * Copyright(c) 2014 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module exports. + */ + +module.exports = callSiteToString + +/** + * Format a CallSite file location to a string. + */ + +function callSiteFileLocation(callSite) { + var fileName + var fileLocation = '' + + if (callSite.isNative()) { + fileLocation = 'native' + } else if (callSite.isEval()) { + fileName = callSite.getScriptNameOrSourceURL() + if (!fileName) { + fileLocation = callSite.getEvalOrigin() + } + } else { + fileName = callSite.getFileName() + } + + if (fileName) { + fileLocation += fileName + + var lineNumber = callSite.getLineNumber() + if (lineNumber != null) { + fileLocation += ':' + lineNumber + + var columnNumber = callSite.getColumnNumber() + if (columnNumber) { + fileLocation += ':' + columnNumber + } + } + } + + return fileLocation || 'unknown source' +} + +/** + * Format a CallSite to a string. + */ + +function callSiteToString(callSite) { + var addSuffix = true + var fileLocation = callSiteFileLocation(callSite) + var functionName = callSite.getFunctionName() + var isConstructor = callSite.isConstructor() + var isMethodCall = !(callSite.isToplevel() || isConstructor) + var line = '' + + if (isMethodCall) { + var methodName = callSite.getMethodName() + var typeName = getConstructorName(callSite) + + if (functionName) { + if (typeName && functionName.indexOf(typeName) !== 0) { + line += typeName + '.' + } + + line += functionName + + if (methodName && functionName.lastIndexOf('.' + methodName) !== functionName.length - methodName.length - 1) { + line += ' [as ' + methodName + ']' + } + } else { + line += typeName + '.' + (methodName || '') + } + } else if (isConstructor) { + line += 'new ' + (functionName || '') + } else if (functionName) { + line += functionName + } else { + addSuffix = false + line += fileLocation + } + + if (addSuffix) { + line += ' (' + fileLocation + ')' + } + + return line +} + +/** + * Get constructor name of reviver. + */ + +function getConstructorName(obj) { + var receiver = obj.receiver + return (receiver.constructor && receiver.constructor.name) || null +} diff --git a/ui/node_modules/express/node_modules/depd/lib/compat/event-listener-count.js b/ui/node_modules/express/node_modules/depd/lib/compat/event-listener-count.js index a0fc61e7..a05fceb7 100644 --- a/ui/node_modules/express/node_modules/depd/lib/compat/event-listener-count.js +++ b/ui/node_modules/express/node_modules/depd/lib/compat/event-listener-count.js @@ -1,22 +1,22 @@ -/*! - * depd - * Copyright(c) 2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict' - -/** - * Module exports. - * @public - */ - -module.exports = eventListenerCount - -/** - * Get the count of listeners on an event emitter of a specific type. - */ - -function eventListenerCount(emitter, type) { - return emitter.listeners(type).length -} +/*! + * depd + * Copyright(c) 2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module exports. + * @public + */ + +module.exports = eventListenerCount + +/** + * Get the count of listeners on an event emitter of a specific type. + */ + +function eventListenerCount(emitter, type) { + return emitter.listeners(type).length +} diff --git a/ui/node_modules/express/node_modules/depd/lib/compat/index.js b/ui/node_modules/express/node_modules/depd/lib/compat/index.js index b1fdb26a..aa3c1de4 100644 --- a/ui/node_modules/express/node_modules/depd/lib/compat/index.js +++ b/ui/node_modules/express/node_modules/depd/lib/compat/index.js @@ -1,84 +1,84 @@ -/*! - * depd - * Copyright(c) 2014-2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict' - -/** - * Module dependencies. - * @private - */ - -var Buffer = require('buffer') -var EventEmitter = require('events').EventEmitter - -/** - * Module exports. - * @public - */ - -lazyProperty(module.exports, 'bufferConcat', function bufferConcat() { - return Buffer.concat || require('./buffer-concat') -}) - -lazyProperty(module.exports, 'callSiteToString', function callSiteToString() { - var limit = Error.stackTraceLimit - var obj = {} - var prep = Error.prepareStackTrace - - function prepareObjectStackTrace(obj, stack) { - return stack - } - - Error.prepareStackTrace = prepareObjectStackTrace - Error.stackTraceLimit = 2 - - // capture the stack - Error.captureStackTrace(obj) - - // slice the stack - var stack = obj.stack.slice() - - Error.prepareStackTrace = prep - Error.stackTraceLimit = limit - - return stack[0].toString ? toString : require('./callsite-tostring') -}) - -lazyProperty(module.exports, 'eventListenerCount', function eventListenerCount() { - return EventEmitter.listenerCount || require('./event-listener-count') -}) - -/** - * Define a lazy property. - */ - -function lazyProperty(obj, prop, getter) { - function get() { - var val = getter() - - Object.defineProperty(obj, prop, { - configurable: true, - enumerable: true, - value: val - }) - - return val - } - - Object.defineProperty(obj, prop, { - configurable: true, - enumerable: true, - get: get - }) -} - -/** - * Call toString() on the obj - */ - -function toString(obj) { - return obj.toString() -} +/*! + * depd + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module dependencies. + * @private + */ + +var Buffer = require('buffer') +var EventEmitter = require('events').EventEmitter + +/** + * Module exports. + * @public + */ + +lazyProperty(module.exports, 'bufferConcat', function bufferConcat() { + return Buffer.concat || require('./buffer-concat') +}) + +lazyProperty(module.exports, 'callSiteToString', function callSiteToString() { + var limit = Error.stackTraceLimit + var obj = {} + var prep = Error.prepareStackTrace + + function prepareObjectStackTrace(obj, stack) { + return stack + } + + Error.prepareStackTrace = prepareObjectStackTrace + Error.stackTraceLimit = 2 + + // capture the stack + Error.captureStackTrace(obj) + + // slice the stack + var stack = obj.stack.slice() + + Error.prepareStackTrace = prep + Error.stackTraceLimit = limit + + return stack[0].toString ? toString : require('./callsite-tostring') +}) + +lazyProperty(module.exports, 'eventListenerCount', function eventListenerCount() { + return EventEmitter.listenerCount || require('./event-listener-count') +}) + +/** + * Define a lazy property. + */ + +function lazyProperty(obj, prop, getter) { + function get() { + var val = getter() + + Object.defineProperty(obj, prop, { + configurable: true, + enumerable: true, + value: val + }) + + return val + } + + Object.defineProperty(obj, prop, { + configurable: true, + enumerable: true, + get: get + }) +} + +/** + * Call toString() on the obj + */ + +function toString(obj) { + return obj.toString() +} diff --git a/ui/node_modules/express/node_modules/depd/package.json b/ui/node_modules/express/node_modules/depd/package.json index 1cbc6448..edfc0b2a 100644 --- a/ui/node_modules/express/node_modules/depd/package.json +++ b/ui/node_modules/express/node_modules/depd/package.json @@ -1,67 +1,67 @@ -{ - "name": "depd", - "description": "Deprecate all the things", - "version": "1.1.0", - "author": { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - }, - "license": "MIT", - "keywords": [ - "deprecate", - "deprecated" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/dougwilson/nodejs-depd.git" - }, - "browser": "lib/browser/index.js", - "devDependencies": { - "benchmark": "1.0.0", - "beautify-benchmark": "0.2.4", - "istanbul": "0.3.5", - "mocha": "~1.21.5" - }, - "files": [ - "lib/", - "History.md", - "LICENSE", - "index.js", - "Readme.md" - ], - "engines": { - "node": ">= 0.6" - }, - "scripts": { - "bench": "node benchmark/index.js", - "test": "mocha --reporter spec --bail test/", - "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --no-exit test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot test/" - }, - "gitHead": "78c659de20283e3a6bee92bda455e6daff01686a", - "bugs": { - "url": "https://github.com/dougwilson/nodejs-depd/issues" - }, - "homepage": "https://github.com/dougwilson/nodejs-depd", - "_id": "depd@1.1.0", - "_shasum": "e1bd82c6aab6ced965b97b88b17ed3e528ca18c3", - "_from": "depd@>=1.1.0 <1.2.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "e1bd82c6aab6ced965b97b88b17ed3e528ca18c3", - "tarball": "https://registry.npmjs.org/depd/-/depd-1.1.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/depd/-/depd-1.1.0.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "depd", + "description": "Deprecate all the things", + "version": "1.1.0", + "author": { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + }, + "license": "MIT", + "keywords": [ + "deprecate", + "deprecated" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/dougwilson/nodejs-depd.git" + }, + "browser": "lib/browser/index.js", + "devDependencies": { + "benchmark": "1.0.0", + "beautify-benchmark": "0.2.4", + "istanbul": "0.3.5", + "mocha": "~1.21.5" + }, + "files": [ + "lib/", + "History.md", + "LICENSE", + "index.js", + "Readme.md" + ], + "engines": { + "node": ">= 0.6" + }, + "scripts": { + "bench": "node benchmark/index.js", + "test": "mocha --reporter spec --bail test/", + "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --no-exit test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot test/" + }, + "gitHead": "78c659de20283e3a6bee92bda455e6daff01686a", + "bugs": { + "url": "https://github.com/dougwilson/nodejs-depd/issues" + }, + "homepage": "https://github.com/dougwilson/nodejs-depd", + "_id": "depd@1.1.0", + "_shasum": "e1bd82c6aab6ced965b97b88b17ed3e528ca18c3", + "_from": "depd@>=1.1.0 <1.2.0", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "maintainers": [ + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + } + ], + "dist": { + "shasum": "e1bd82c6aab6ced965b97b88b17ed3e528ca18c3", + "tarball": "https://registry.npmjs.org/depd/-/depd-1.1.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/depd/-/depd-1.1.0.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/encodeurl/HISTORY.md b/ui/node_modules/express/node_modules/encodeurl/HISTORY.md index 1a68ad70..06d34a5a 100644 --- a/ui/node_modules/express/node_modules/encodeurl/HISTORY.md +++ b/ui/node_modules/express/node_modules/encodeurl/HISTORY.md @@ -1,9 +1,9 @@ -1.0.1 / 2016-06-09 -================== - - * Fix encoding unpaired surrogates at start/end of string - -1.0.0 / 2016-06-08 -================== - - * Initial release +1.0.1 / 2016-06-09 +================== + + * Fix encoding unpaired surrogates at start/end of string + +1.0.0 / 2016-06-08 +================== + + * Initial release diff --git a/ui/node_modules/express/node_modules/encodeurl/LICENSE b/ui/node_modules/express/node_modules/encodeurl/LICENSE index b0826868..8812229b 100644 --- a/ui/node_modules/express/node_modules/encodeurl/LICENSE +++ b/ui/node_modules/express/node_modules/encodeurl/LICENSE @@ -1,22 +1,22 @@ -(The MIT License) - -Copyright (c) 2016 Douglas Christopher Wilson - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2016 Douglas Christopher Wilson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/encodeurl/README.md b/ui/node_modules/express/node_modules/encodeurl/README.md index 00fcf745..b086133c 100644 --- a/ui/node_modules/express/node_modules/encodeurl/README.md +++ b/ui/node_modules/express/node_modules/encodeurl/README.md @@ -1,124 +1,124 @@ -# encodeurl - -[![NPM Version][npm-image]][npm-url] -[![NPM Downloads][downloads-image]][downloads-url] -[![Node.js Version][node-version-image]][node-version-url] -[![Build Status][travis-image]][travis-url] -[![Test Coverage][coveralls-image]][coveralls-url] - -Encode a URL to a percent-encoded form, excluding already-encoded sequences - -## Installation - -```sh -$ npm install encodeurl -``` - -## API - -```js -var encodeUrl = require('encodeurl') -``` - -### encodeUrl(url) - -Encode a URL to a percent-encoded form, excluding already-encoded sequences. - -This function will take an already-encoded URL and encode all the non-URL -code points (as UTF-8 byte sequences). This function will not encode the -"%" character unless it is not part of a valid sequence (`%20` will be -left as-is, but `%foo` will be encoded as `%25foo`). - -This encode is meant to be "safe" and does not throw errors. It will try as -hard as it can to properly encode the given URL, including replacing any raw, -unpaired surrogate pairs with the Unicode replacement character prior to -encoding. - -This function is _similar_ to the intrinsic function `encodeURI`, except it -will not encode the `%` character if that is part of a valid sequence, will -not encode `[` and `]` (for IPv6 hostnames) and will replace raw, unpaired -surrogate pairs with the Unicode replacement character (instead of throwing). - -## Examples - -### Encode a URL containing user-controled data - -```js -var encodeUrl = require('encodeurl') -var escapeHtml = require('escape-html') - -http.createServer(function onRequest (req, res) { - // get encoded form of inbound url - var url = encodeUrl(req.url) - - // create html message - var body = '

Location ' + escapeHtml(url) + ' not found

' - - // send a 404 - res.statusCode = 404 - res.setHeader('Content-Type', 'text/html; charset=UTF-8') - res.setHeader('Content-Length', String(Buffer.byteLength(body, 'utf-8'))) - res.end(body, 'utf-8') -}) -``` - -### Encode a URL for use in a header field - -```js -var encodeUrl = require('encodeurl') -var escapeHtml = require('escape-html') -var url = require('url') - -http.createServer(function onRequest (req, res) { - // parse inbound url - var href = url.parse(req) - - // set new host for redirect - href.host = 'localhost' - href.protocol = 'https:' - href.slashes = true - - // create location header - var location = encodeUrl(url.format(href)) - - // create html message - var body = '

Redirecting to new site: ' + escapeHtml(location) + '

' - - // send a 301 - res.statusCode = 301 - res.setHeader('Content-Type', 'text/html; charset=UTF-8') - res.setHeader('Content-Length', String(Buffer.byteLength(body, 'utf-8'))) - res.setHeader('Location', location) - res.end(body, 'utf-8') -}) -``` - -## Testing - -```sh -$ npm test -$ npm run lint -``` - -## References - -- [RFC 3986: Uniform Resource Identifier (URI): Generic Syntax][rfc-3986] -- [WHATWG URL Living Standard][whatwg-url] - -[rfc-3986]: https://tools.ietf.org/html/rfc3986 -[whatwg-url]: https://url.spec.whatwg.org/ - -## License - -[MIT](LICENSE) - -[npm-image]: https://img.shields.io/npm/v/encodeurl.svg -[npm-url]: https://npmjs.org/package/encodeurl -[node-version-image]: https://img.shields.io/node/v/encodeurl.svg -[node-version-url]: https://nodejs.org/en/download -[travis-image]: https://img.shields.io/travis/pillarjs/encodeurl.svg -[travis-url]: https://travis-ci.org/pillarjs/encodeurl -[coveralls-image]: https://img.shields.io/coveralls/pillarjs/encodeurl.svg -[coveralls-url]: https://coveralls.io/r/pillarjs/encodeurl?branch=master -[downloads-image]: https://img.shields.io/npm/dm/encodeurl.svg -[downloads-url]: https://npmjs.org/package/encodeurl +# encodeurl + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-version-image]][node-version-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +Encode a URL to a percent-encoded form, excluding already-encoded sequences + +## Installation + +```sh +$ npm install encodeurl +``` + +## API + +```js +var encodeUrl = require('encodeurl') +``` + +### encodeUrl(url) + +Encode a URL to a percent-encoded form, excluding already-encoded sequences. + +This function will take an already-encoded URL and encode all the non-URL +code points (as UTF-8 byte sequences). This function will not encode the +"%" character unless it is not part of a valid sequence (`%20` will be +left as-is, but `%foo` will be encoded as `%25foo`). + +This encode is meant to be "safe" and does not throw errors. It will try as +hard as it can to properly encode the given URL, including replacing any raw, +unpaired surrogate pairs with the Unicode replacement character prior to +encoding. + +This function is _similar_ to the intrinsic function `encodeURI`, except it +will not encode the `%` character if that is part of a valid sequence, will +not encode `[` and `]` (for IPv6 hostnames) and will replace raw, unpaired +surrogate pairs with the Unicode replacement character (instead of throwing). + +## Examples + +### Encode a URL containing user-controled data + +```js +var encodeUrl = require('encodeurl') +var escapeHtml = require('escape-html') + +http.createServer(function onRequest (req, res) { + // get encoded form of inbound url + var url = encodeUrl(req.url) + + // create html message + var body = '

Location ' + escapeHtml(url) + ' not found

' + + // send a 404 + res.statusCode = 404 + res.setHeader('Content-Type', 'text/html; charset=UTF-8') + res.setHeader('Content-Length', String(Buffer.byteLength(body, 'utf-8'))) + res.end(body, 'utf-8') +}) +``` + +### Encode a URL for use in a header field + +```js +var encodeUrl = require('encodeurl') +var escapeHtml = require('escape-html') +var url = require('url') + +http.createServer(function onRequest (req, res) { + // parse inbound url + var href = url.parse(req) + + // set new host for redirect + href.host = 'localhost' + href.protocol = 'https:' + href.slashes = true + + // create location header + var location = encodeUrl(url.format(href)) + + // create html message + var body = '

Redirecting to new site: ' + escapeHtml(location) + '

' + + // send a 301 + res.statusCode = 301 + res.setHeader('Content-Type', 'text/html; charset=UTF-8') + res.setHeader('Content-Length', String(Buffer.byteLength(body, 'utf-8'))) + res.setHeader('Location', location) + res.end(body, 'utf-8') +}) +``` + +## Testing + +```sh +$ npm test +$ npm run lint +``` + +## References + +- [RFC 3986: Uniform Resource Identifier (URI): Generic Syntax][rfc-3986] +- [WHATWG URL Living Standard][whatwg-url] + +[rfc-3986]: https://tools.ietf.org/html/rfc3986 +[whatwg-url]: https://url.spec.whatwg.org/ + +## License + +[MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/encodeurl.svg +[npm-url]: https://npmjs.org/package/encodeurl +[node-version-image]: https://img.shields.io/node/v/encodeurl.svg +[node-version-url]: https://nodejs.org/en/download +[travis-image]: https://img.shields.io/travis/pillarjs/encodeurl.svg +[travis-url]: https://travis-ci.org/pillarjs/encodeurl +[coveralls-image]: https://img.shields.io/coveralls/pillarjs/encodeurl.svg +[coveralls-url]: https://coveralls.io/r/pillarjs/encodeurl?branch=master +[downloads-image]: https://img.shields.io/npm/dm/encodeurl.svg +[downloads-url]: https://npmjs.org/package/encodeurl diff --git a/ui/node_modules/express/node_modules/encodeurl/index.js b/ui/node_modules/express/node_modules/encodeurl/index.js index 25963927..ae77cc94 100644 --- a/ui/node_modules/express/node_modules/encodeurl/index.js +++ b/ui/node_modules/express/node_modules/encodeurl/index.js @@ -1,60 +1,60 @@ -/*! - * encodeurl - * Copyright(c) 2016 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict' - -/** - * Module exports. - * @public - */ - -module.exports = encodeUrl - -/** - * RegExp to match non-URL code points, *after* encoding (i.e. not including "%") - * and including invalid escape sequences. - * @private - */ - -var ENCODE_CHARS_REGEXP = /(?:[^\x21\x25\x26-\x3B\x3D\x3F-\x5B\x5D\x5F\x61-\x7A\x7E]|%(?:[^0-9A-Fa-f]|[0-9A-Fa-f][^0-9A-Fa-f]))+/g - -/** - * RegExp to match unmatched surrogate pair. - * @private - */ - -var UNMATCHED_SURROGATE_PAIR_REGEXP = /(^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF]([^\uDC00-\uDFFF]|$)/g - -/** - * String to replace unmatched surrogate pair with. - * @private - */ - -var UNMATCHED_SURROGATE_PAIR_REPLACE = '$1\uFFFD$2' - -/** - * Encode a URL to a percent-encoded form, excluding already-encoded sequences. - * - * This function will take an already-encoded URL and encode all the non-URL - * code points. This function will not encode the "%" character unless it is - * not part of a valid sequence (`%20` will be left as-is, but `%foo` will - * be encoded as `%25foo`). - * - * This encode is meant to be "safe" and does not throw errors. It will try as - * hard as it can to properly encode the given URL, including replacing any raw, - * unpaired surrogate pairs with the Unicode replacement character prior to - * encoding. - * - * @param {string} url - * @return {string} - * @public - */ - -function encodeUrl (url) { - return String(url) - .replace(UNMATCHED_SURROGATE_PAIR_REGEXP, UNMATCHED_SURROGATE_PAIR_REPLACE) - .replace(ENCODE_CHARS_REGEXP, encodeURI) -} +/*! + * encodeurl + * Copyright(c) 2016 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module exports. + * @public + */ + +module.exports = encodeUrl + +/** + * RegExp to match non-URL code points, *after* encoding (i.e. not including "%") + * and including invalid escape sequences. + * @private + */ + +var ENCODE_CHARS_REGEXP = /(?:[^\x21\x25\x26-\x3B\x3D\x3F-\x5B\x5D\x5F\x61-\x7A\x7E]|%(?:[^0-9A-Fa-f]|[0-9A-Fa-f][^0-9A-Fa-f]))+/g + +/** + * RegExp to match unmatched surrogate pair. + * @private + */ + +var UNMATCHED_SURROGATE_PAIR_REGEXP = /(^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF]([^\uDC00-\uDFFF]|$)/g + +/** + * String to replace unmatched surrogate pair with. + * @private + */ + +var UNMATCHED_SURROGATE_PAIR_REPLACE = '$1\uFFFD$2' + +/** + * Encode a URL to a percent-encoded form, excluding already-encoded sequences. + * + * This function will take an already-encoded URL and encode all the non-URL + * code points. This function will not encode the "%" character unless it is + * not part of a valid sequence (`%20` will be left as-is, but `%foo` will + * be encoded as `%25foo`). + * + * This encode is meant to be "safe" and does not throw errors. It will try as + * hard as it can to properly encode the given URL, including replacing any raw, + * unpaired surrogate pairs with the Unicode replacement character prior to + * encoding. + * + * @param {string} url + * @return {string} + * @public + */ + +function encodeUrl (url) { + return String(url) + .replace(UNMATCHED_SURROGATE_PAIR_REGEXP, UNMATCHED_SURROGATE_PAIR_REPLACE) + .replace(ENCODE_CHARS_REGEXP, encodeURI) +} diff --git a/ui/node_modules/express/node_modules/encodeurl/package.json b/ui/node_modules/express/node_modules/encodeurl/package.json index 8641acc2..b9a2d11c 100644 --- a/ui/node_modules/express/node_modules/encodeurl/package.json +++ b/ui/node_modules/express/node_modules/encodeurl/package.json @@ -1,75 +1,75 @@ -{ - "name": "encodeurl", - "description": "Encode a URL to a percent-encoded form, excluding already-encoded sequences", - "version": "1.0.1", - "contributors": [ - { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - } - ], - "license": "MIT", - "keywords": [ - "encode", - "encodeurl", - "url" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/pillarjs/encodeurl.git" - }, - "devDependencies": { - "eslint": "2.11.1", - "eslint-config-standard": "5.3.1", - "eslint-plugin-promise": "1.3.2", - "eslint-plugin-standard": "1.3.2", - "istanbul": "0.4.3", - "mocha": "2.5.3" - }, - "files": [ - "LICENSE", - "HISTORY.md", - "README.md", - "index.js" - ], - "engines": { - "node": ">= 0.8" - }, - "scripts": { - "lint": "eslint **/*.js", - "test": "mocha --reporter spec --bail --check-leaks test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" - }, - "gitHead": "39ed0c235fed4cea7d012038fd6bb0480561d226", - "bugs": { - "url": "https://github.com/pillarjs/encodeurl/issues" - }, - "homepage": "https://github.com/pillarjs/encodeurl#readme", - "_id": "encodeurl@1.0.1", - "_shasum": "79e3d58655346909fe6f0f45a5de68103b294d20", - "_from": "encodeurl@>=1.0.1 <1.1.0", - "_npmVersion": "2.15.1", - "_nodeVersion": "4.4.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "79e3d58655346909fe6f0f45a5de68103b294d20", - "tarball": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/encodeurl-1.0.1.tgz_1465519736251_0.09314409433864057" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "encodeurl", + "description": "Encode a URL to a percent-encoded form, excluding already-encoded sequences", + "version": "1.0.1", + "contributors": [ + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + } + ], + "license": "MIT", + "keywords": [ + "encode", + "encodeurl", + "url" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/pillarjs/encodeurl.git" + }, + "devDependencies": { + "eslint": "2.11.1", + "eslint-config-standard": "5.3.1", + "eslint-plugin-promise": "1.3.2", + "eslint-plugin-standard": "1.3.2", + "istanbul": "0.4.3", + "mocha": "2.5.3" + }, + "files": [ + "LICENSE", + "HISTORY.md", + "README.md", + "index.js" + ], + "engines": { + "node": ">= 0.8" + }, + "scripts": { + "lint": "eslint **/*.js", + "test": "mocha --reporter spec --bail --check-leaks test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" + }, + "gitHead": "39ed0c235fed4cea7d012038fd6bb0480561d226", + "bugs": { + "url": "https://github.com/pillarjs/encodeurl/issues" + }, + "homepage": "https://github.com/pillarjs/encodeurl#readme", + "_id": "encodeurl@1.0.1", + "_shasum": "79e3d58655346909fe6f0f45a5de68103b294d20", + "_from": "encodeurl@>=1.0.1 <1.1.0", + "_npmVersion": "2.15.1", + "_nodeVersion": "4.4.3", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "dist": { + "shasum": "79e3d58655346909fe6f0f45a5de68103b294d20", + "tarball": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz" + }, + "maintainers": [ + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + } + ], + "_npmOperationalInternal": { + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/encodeurl-1.0.1.tgz_1465519736251_0.09314409433864057" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/escape-html/LICENSE b/ui/node_modules/express/node_modules/escape-html/LICENSE index a6e7ce18..2e70de97 100644 --- a/ui/node_modules/express/node_modules/escape-html/LICENSE +++ b/ui/node_modules/express/node_modules/escape-html/LICENSE @@ -1,24 +1,24 @@ -(The MIT License) - -Copyright (c) 2012-2013 TJ Holowaychuk -Copyright (c) 2015 Andreas Lubbe -Copyright (c) 2015 Tiancheng "Timothy" Gu - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2012-2013 TJ Holowaychuk +Copyright (c) 2015 Andreas Lubbe +Copyright (c) 2015 Tiancheng "Timothy" Gu + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/escape-html/Readme.md b/ui/node_modules/express/node_modules/escape-html/Readme.md index b1816789..653d9eaa 100644 --- a/ui/node_modules/express/node_modules/escape-html/Readme.md +++ b/ui/node_modules/express/node_modules/escape-html/Readme.md @@ -1,43 +1,43 @@ - -# escape-html - - Escape string for use in HTML - -## Example - -```js -var escape = require('escape-html'); -var html = escape('foo & bar'); -// -> foo & bar -``` - -## Benchmark - -``` -$ npm run-script bench - -> escape-html@1.0.3 bench nodejs-escape-html -> node benchmark/index.js - - - http_parser@1.0 - node@0.10.33 - v8@3.14.5.9 - ares@1.9.0-DEV - uv@0.10.29 - zlib@1.2.3 - modules@11 - openssl@1.0.1j - - 1 test completed. - 2 tests completed. - 3 tests completed. - - no special characters x 19,435,271 ops/sec ±0.85% (187 runs sampled) - single special character x 6,132,421 ops/sec ±0.67% (194 runs sampled) - many special characters x 3,175,826 ops/sec ±0.65% (193 runs sampled) -``` - -## License - + +# escape-html + + Escape string for use in HTML + +## Example + +```js +var escape = require('escape-html'); +var html = escape('foo & bar'); +// -> foo & bar +``` + +## Benchmark + +``` +$ npm run-script bench + +> escape-html@1.0.3 bench nodejs-escape-html +> node benchmark/index.js + + + http_parser@1.0 + node@0.10.33 + v8@3.14.5.9 + ares@1.9.0-DEV + uv@0.10.29 + zlib@1.2.3 + modules@11 + openssl@1.0.1j + + 1 test completed. + 2 tests completed. + 3 tests completed. + + no special characters x 19,435,271 ops/sec ±0.85% (187 runs sampled) + single special character x 6,132,421 ops/sec ±0.67% (194 runs sampled) + many special characters x 3,175,826 ops/sec ±0.65% (193 runs sampled) +``` + +## License + MIT \ No newline at end of file diff --git a/ui/node_modules/express/node_modules/escape-html/index.js b/ui/node_modules/express/node_modules/escape-html/index.js index 375aab12..bf9e226f 100644 --- a/ui/node_modules/express/node_modules/escape-html/index.js +++ b/ui/node_modules/express/node_modules/escape-html/index.js @@ -1,78 +1,78 @@ -/*! - * escape-html - * Copyright(c) 2012-2013 TJ Holowaychuk - * Copyright(c) 2015 Andreas Lubbe - * Copyright(c) 2015 Tiancheng "Timothy" Gu - * MIT Licensed - */ - -'use strict'; - -/** - * Module variables. - * @private - */ - -var matchHtmlRegExp = /["'&<>]/; - -/** - * Module exports. - * @public - */ - -module.exports = escapeHtml; - -/** - * Escape special characters in the given string of html. - * - * @param {string} string The string to escape for inserting into HTML - * @return {string} - * @public - */ - -function escapeHtml(string) { - var str = '' + string; - var match = matchHtmlRegExp.exec(str); - - if (!match) { - return str; - } - - var escape; - var html = ''; - var index = 0; - var lastIndex = 0; - - for (index = match.index; index < str.length; index++) { - switch (str.charCodeAt(index)) { - case 34: // " - escape = '"'; - break; - case 38: // & - escape = '&'; - break; - case 39: // ' - escape = '''; - break; - case 60: // < - escape = '<'; - break; - case 62: // > - escape = '>'; - break; - default: - continue; - } - - if (lastIndex !== index) { - html += str.substring(lastIndex, index); - } - - lastIndex = index + 1; - html += escape; - } - - return lastIndex !== index - ? html + str.substring(lastIndex, index) - : html; -} +/*! + * escape-html + * Copyright(c) 2012-2013 TJ Holowaychuk + * Copyright(c) 2015 Andreas Lubbe + * Copyright(c) 2015 Tiancheng "Timothy" Gu + * MIT Licensed + */ + +'use strict'; + +/** + * Module variables. + * @private + */ + +var matchHtmlRegExp = /["'&<>]/; + +/** + * Module exports. + * @public + */ + +module.exports = escapeHtml; + +/** + * Escape special characters in the given string of html. + * + * @param {string} string The string to escape for inserting into HTML + * @return {string} + * @public + */ + +function escapeHtml(string) { + var str = '' + string; + var match = matchHtmlRegExp.exec(str); + + if (!match) { + return str; + } + + var escape; + var html = ''; + var index = 0; + var lastIndex = 0; + + for (index = match.index; index < str.length; index++) { + switch (str.charCodeAt(index)) { + case 34: // " + escape = '"'; + break; + case 38: // & + escape = '&'; + break; + case 39: // ' + escape = '''; + break; + case 60: // < + escape = '<'; + break; + case 62: // > + escape = '>'; + break; + default: + continue; + } + + if (lastIndex !== index) { + html += str.substring(lastIndex, index); + } + + lastIndex = index + 1; + html += escape; + } + + return lastIndex !== index + ? html + str.substring(lastIndex, index) + : html; +} diff --git a/ui/node_modules/express/node_modules/escape-html/package.json b/ui/node_modules/express/node_modules/escape-html/package.json index 9652dc7b..3f418d6d 100644 --- a/ui/node_modules/express/node_modules/escape-html/package.json +++ b/ui/node_modules/express/node_modules/escape-html/package.json @@ -1,57 +1,57 @@ -{ - "name": "escape-html", - "description": "Escape string for use in HTML", - "version": "1.0.3", - "license": "MIT", - "keywords": [ - "escape", - "html", - "utility" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/component/escape-html.git" - }, - "devDependencies": { - "benchmark": "1.0.0", - "beautify-benchmark": "0.2.4" - }, - "files": [ - "LICENSE", - "Readme.md", - "index.js" - ], - "scripts": { - "bench": "node benchmark/index.js" - }, - "gitHead": "7ac2ea3977fcac3d4c5be8d2a037812820c65f28", - "bugs": { - "url": "https://github.com/component/escape-html/issues" - }, - "homepage": "https://github.com/component/escape-html", - "_id": "escape-html@1.0.3", - "_shasum": "0258eae4d3d0c0974de1c169188ef0051d1d1988", - "_from": "escape-html@>=1.0.3 <1.1.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "0258eae4d3d0c0974de1c169188ef0051d1d1988", - "tarball": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "escape-html", + "description": "Escape string for use in HTML", + "version": "1.0.3", + "license": "MIT", + "keywords": [ + "escape", + "html", + "utility" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/component/escape-html.git" + }, + "devDependencies": { + "benchmark": "1.0.0", + "beautify-benchmark": "0.2.4" + }, + "files": [ + "LICENSE", + "Readme.md", + "index.js" + ], + "scripts": { + "bench": "node benchmark/index.js" + }, + "gitHead": "7ac2ea3977fcac3d4c5be8d2a037812820c65f28", + "bugs": { + "url": "https://github.com/component/escape-html/issues" + }, + "homepage": "https://github.com/component/escape-html", + "_id": "escape-html@1.0.3", + "_shasum": "0258eae4d3d0c0974de1c169188ef0051d1d1988", + "_from": "escape-html@>=1.0.3 <1.1.0", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "maintainers": [ + { + "name": "tjholowaychuk", + "email": "tj@vision-media.ca" + }, + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + } + ], + "dist": { + "shasum": "0258eae4d3d0c0974de1c169188ef0051d1d1988", + "tarball": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/etag/HISTORY.md b/ui/node_modules/express/node_modules/etag/HISTORY.md index 90684c08..bd0f26df 100644 --- a/ui/node_modules/express/node_modules/etag/HISTORY.md +++ b/ui/node_modules/express/node_modules/etag/HISTORY.md @@ -1,71 +1,71 @@ -1.7.0 / 2015-06-08 -================== - - * Always include entity length in ETags for hash length extensions - * Generate non-Stats ETags using MD5 only (no longer CRC32) - * Improve stat performance by removing hashing - * Remove base64 padding in ETags to shorten - * Use MD5 instead of MD4 in weak ETags over 1KB - -1.6.0 / 2015-05-10 -================== - - * Improve support for JXcore - * Remove requirement of `atime` in the stats object - * Support "fake" stats objects in environments without `fs` - -1.5.1 / 2014-11-19 -================== - - * deps: crc@3.2.1 - - Minor fixes - -1.5.0 / 2014-10-14 -================== - - * Improve string performance - * Slightly improve speed for weak ETags over 1KB - -1.4.0 / 2014-09-21 -================== - - * Support "fake" stats objects - * Support Node.js 0.6 - -1.3.1 / 2014-09-14 -================== - - * Use the (new and improved) `crc` for crc32 - -1.3.0 / 2014-08-29 -================== - - * Default strings to strong ETags - * Improve speed for weak ETags over 1KB - -1.2.1 / 2014-08-29 -================== - - * Use the (much faster) `buffer-crc32` for crc32 - -1.2.0 / 2014-08-24 -================== - - * Add support for file stat objects - -1.1.0 / 2014-08-24 -================== - - * Add fast-path for empty entity - * Add weak ETag generation - * Shrink size of generated ETags - -1.0.1 / 2014-08-24 -================== - - * Fix behavior of string containing Unicode - -1.0.0 / 2014-05-18 -================== - - * Initial release +1.7.0 / 2015-06-08 +================== + + * Always include entity length in ETags for hash length extensions + * Generate non-Stats ETags using MD5 only (no longer CRC32) + * Improve stat performance by removing hashing + * Remove base64 padding in ETags to shorten + * Use MD5 instead of MD4 in weak ETags over 1KB + +1.6.0 / 2015-05-10 +================== + + * Improve support for JXcore + * Remove requirement of `atime` in the stats object + * Support "fake" stats objects in environments without `fs` + +1.5.1 / 2014-11-19 +================== + + * deps: crc@3.2.1 + - Minor fixes + +1.5.0 / 2014-10-14 +================== + + * Improve string performance + * Slightly improve speed for weak ETags over 1KB + +1.4.0 / 2014-09-21 +================== + + * Support "fake" stats objects + * Support Node.js 0.6 + +1.3.1 / 2014-09-14 +================== + + * Use the (new and improved) `crc` for crc32 + +1.3.0 / 2014-08-29 +================== + + * Default strings to strong ETags + * Improve speed for weak ETags over 1KB + +1.2.1 / 2014-08-29 +================== + + * Use the (much faster) `buffer-crc32` for crc32 + +1.2.0 / 2014-08-24 +================== + + * Add support for file stat objects + +1.1.0 / 2014-08-24 +================== + + * Add fast-path for empty entity + * Add weak ETag generation + * Shrink size of generated ETags + +1.0.1 / 2014-08-24 +================== + + * Fix behavior of string containing Unicode + +1.0.0 / 2014-05-18 +================== + + * Initial release diff --git a/ui/node_modules/express/node_modules/etag/LICENSE b/ui/node_modules/express/node_modules/etag/LICENSE index a35fc45b..142ede38 100644 --- a/ui/node_modules/express/node_modules/etag/LICENSE +++ b/ui/node_modules/express/node_modules/etag/LICENSE @@ -1,22 +1,22 @@ -(The MIT License) - -Copyright (c) 2014-2015 Douglas Christopher Wilson - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2014-2015 Douglas Christopher Wilson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/etag/README.md b/ui/node_modules/express/node_modules/etag/README.md index ce78ab7f..8da9e059 100644 --- a/ui/node_modules/express/node_modules/etag/README.md +++ b/ui/node_modules/express/node_modules/etag/README.md @@ -1,165 +1,165 @@ -# etag - -[![NPM Version][npm-image]][npm-url] -[![NPM Downloads][downloads-image]][downloads-url] -[![Node.js Version][node-version-image]][node-version-url] -[![Build Status][travis-image]][travis-url] -[![Test Coverage][coveralls-image]][coveralls-url] - -Create simple ETags - -## Installation - -```sh -$ npm install etag -``` - -## API - -```js -var etag = require('etag') -``` - -### etag(entity, [options]) - -Generate a strong ETag for the given entity. This should be the complete -body of the entity. Strings, `Buffer`s, and `fs.Stats` are accepted. By -default, a strong ETag is generated except for `fs.Stats`, which will -generate a weak ETag (this can be overwritten by `options.weak`). - -```js -res.setHeader('ETag', etag(body)) -``` - -#### Options - -`etag` accepts these properties in the options object. - -##### weak - -Specifies if the generated ETag will include the weak validator mark (that -is, the leading `W/`). The actual entity tag is the same. The default value -is `false`, unless the `entity` is `fs.Stats`, in which case it is `true`. - -## Testing - -```sh -$ npm test -``` - -## Benchmark - -```bash -$ npm run-script bench - -> etag@1.6.0 bench nodejs-etag -> node benchmark/index.js - - http_parser@1.0 - node@0.10.33 - v8@3.14.5.9 - ares@1.9.0-DEV - uv@0.10.29 - zlib@1.2.3 - modules@11 - openssl@1.0.1j - -> node benchmark/body0-100b.js - - 100B body - - 1 test completed. - 2 tests completed. - 3 tests completed. - 4 tests completed. - -* buffer - strong x 289,198 ops/sec ±1.09% (190 runs sampled) -* buffer - weak x 287,838 ops/sec ±0.91% (189 runs sampled) -* string - strong x 284,586 ops/sec ±1.05% (192 runs sampled) -* string - weak x 287,439 ops/sec ±0.82% (192 runs sampled) - -> node benchmark/body1-1kb.js - - 1KB body - - 1 test completed. - 2 tests completed. - 3 tests completed. - 4 tests completed. - -* buffer - strong x 212,423 ops/sec ±0.75% (193 runs sampled) -* buffer - weak x 211,871 ops/sec ±0.74% (194 runs sampled) - string - strong x 205,291 ops/sec ±0.86% (194 runs sampled) - string - weak x 208,463 ops/sec ±0.79% (192 runs sampled) - -> node benchmark/body2-5kb.js - - 5KB body - - 1 test completed. - 2 tests completed. - 3 tests completed. - 4 tests completed. - -* buffer - strong x 92,901 ops/sec ±0.58% (195 runs sampled) -* buffer - weak x 93,045 ops/sec ±0.65% (192 runs sampled) - string - strong x 89,621 ops/sec ±0.68% (194 runs sampled) - string - weak x 90,070 ops/sec ±0.70% (196 runs sampled) - -> node benchmark/body3-10kb.js - - 10KB body - - 1 test completed. - 2 tests completed. - 3 tests completed. - 4 tests completed. - -* buffer - strong x 54,220 ops/sec ±0.85% (192 runs sampled) -* buffer - weak x 54,069 ops/sec ±0.83% (191 runs sampled) - string - strong x 53,078 ops/sec ±0.53% (194 runs sampled) - string - weak x 53,849 ops/sec ±0.47% (197 runs sampled) - -> node benchmark/body4-100kb.js - - 100KB body - - 1 test completed. - 2 tests completed. - 3 tests completed. - 4 tests completed. - -* buffer - strong x 6,673 ops/sec ±0.15% (197 runs sampled) -* buffer - weak x 6,716 ops/sec ±0.12% (198 runs sampled) - string - strong x 6,357 ops/sec ±0.14% (197 runs sampled) - string - weak x 6,344 ops/sec ±0.21% (197 runs sampled) - -> node benchmark/stats.js - - stats - - 1 test completed. - 2 tests completed. - 3 tests completed. - 4 tests completed. - -* real - strong x 1,671,989 ops/sec ±0.13% (197 runs sampled) -* real - weak x 1,681,297 ops/sec ±0.12% (198 runs sampled) - fake - strong x 927,063 ops/sec ±0.14% (198 runs sampled) - fake - weak x 914,461 ops/sec ±0.41% (191 runs sampled) -``` - -## License - -[MIT](LICENSE) - -[npm-image]: https://img.shields.io/npm/v/etag.svg -[npm-url]: https://npmjs.org/package/etag -[node-version-image]: https://img.shields.io/node/v/etag.svg -[node-version-url]: http://nodejs.org/download/ -[travis-image]: https://img.shields.io/travis/jshttp/etag/master.svg -[travis-url]: https://travis-ci.org/jshttp/etag -[coveralls-image]: https://img.shields.io/coveralls/jshttp/etag/master.svg -[coveralls-url]: https://coveralls.io/r/jshttp/etag?branch=master -[downloads-image]: https://img.shields.io/npm/dm/etag.svg -[downloads-url]: https://npmjs.org/package/etag +# etag + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-version-image]][node-version-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +Create simple ETags + +## Installation + +```sh +$ npm install etag +``` + +## API + +```js +var etag = require('etag') +``` + +### etag(entity, [options]) + +Generate a strong ETag for the given entity. This should be the complete +body of the entity. Strings, `Buffer`s, and `fs.Stats` are accepted. By +default, a strong ETag is generated except for `fs.Stats`, which will +generate a weak ETag (this can be overwritten by `options.weak`). + +```js +res.setHeader('ETag', etag(body)) +``` + +#### Options + +`etag` accepts these properties in the options object. + +##### weak + +Specifies if the generated ETag will include the weak validator mark (that +is, the leading `W/`). The actual entity tag is the same. The default value +is `false`, unless the `entity` is `fs.Stats`, in which case it is `true`. + +## Testing + +```sh +$ npm test +``` + +## Benchmark + +```bash +$ npm run-script bench + +> etag@1.6.0 bench nodejs-etag +> node benchmark/index.js + + http_parser@1.0 + node@0.10.33 + v8@3.14.5.9 + ares@1.9.0-DEV + uv@0.10.29 + zlib@1.2.3 + modules@11 + openssl@1.0.1j + +> node benchmark/body0-100b.js + + 100B body + + 1 test completed. + 2 tests completed. + 3 tests completed. + 4 tests completed. + +* buffer - strong x 289,198 ops/sec ±1.09% (190 runs sampled) +* buffer - weak x 287,838 ops/sec ±0.91% (189 runs sampled) +* string - strong x 284,586 ops/sec ±1.05% (192 runs sampled) +* string - weak x 287,439 ops/sec ±0.82% (192 runs sampled) + +> node benchmark/body1-1kb.js + + 1KB body + + 1 test completed. + 2 tests completed. + 3 tests completed. + 4 tests completed. + +* buffer - strong x 212,423 ops/sec ±0.75% (193 runs sampled) +* buffer - weak x 211,871 ops/sec ±0.74% (194 runs sampled) + string - strong x 205,291 ops/sec ±0.86% (194 runs sampled) + string - weak x 208,463 ops/sec ±0.79% (192 runs sampled) + +> node benchmark/body2-5kb.js + + 5KB body + + 1 test completed. + 2 tests completed. + 3 tests completed. + 4 tests completed. + +* buffer - strong x 92,901 ops/sec ±0.58% (195 runs sampled) +* buffer - weak x 93,045 ops/sec ±0.65% (192 runs sampled) + string - strong x 89,621 ops/sec ±0.68% (194 runs sampled) + string - weak x 90,070 ops/sec ±0.70% (196 runs sampled) + +> node benchmark/body3-10kb.js + + 10KB body + + 1 test completed. + 2 tests completed. + 3 tests completed. + 4 tests completed. + +* buffer - strong x 54,220 ops/sec ±0.85% (192 runs sampled) +* buffer - weak x 54,069 ops/sec ±0.83% (191 runs sampled) + string - strong x 53,078 ops/sec ±0.53% (194 runs sampled) + string - weak x 53,849 ops/sec ±0.47% (197 runs sampled) + +> node benchmark/body4-100kb.js + + 100KB body + + 1 test completed. + 2 tests completed. + 3 tests completed. + 4 tests completed. + +* buffer - strong x 6,673 ops/sec ±0.15% (197 runs sampled) +* buffer - weak x 6,716 ops/sec ±0.12% (198 runs sampled) + string - strong x 6,357 ops/sec ±0.14% (197 runs sampled) + string - weak x 6,344 ops/sec ±0.21% (197 runs sampled) + +> node benchmark/stats.js + + stats + + 1 test completed. + 2 tests completed. + 3 tests completed. + 4 tests completed. + +* real - strong x 1,671,989 ops/sec ±0.13% (197 runs sampled) +* real - weak x 1,681,297 ops/sec ±0.12% (198 runs sampled) + fake - strong x 927,063 ops/sec ±0.14% (198 runs sampled) + fake - weak x 914,461 ops/sec ±0.41% (191 runs sampled) +``` + +## License + +[MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/etag.svg +[npm-url]: https://npmjs.org/package/etag +[node-version-image]: https://img.shields.io/node/v/etag.svg +[node-version-url]: http://nodejs.org/download/ +[travis-image]: https://img.shields.io/travis/jshttp/etag/master.svg +[travis-url]: https://travis-ci.org/jshttp/etag +[coveralls-image]: https://img.shields.io/coveralls/jshttp/etag/master.svg +[coveralls-url]: https://coveralls.io/r/jshttp/etag?branch=master +[downloads-image]: https://img.shields.io/npm/dm/etag.svg +[downloads-url]: https://npmjs.org/package/etag diff --git a/ui/node_modules/express/node_modules/etag/index.js b/ui/node_modules/express/node_modules/etag/index.js index 402807a3..b582c84c 100644 --- a/ui/node_modules/express/node_modules/etag/index.js +++ b/ui/node_modules/express/node_modules/etag/index.js @@ -1,132 +1,132 @@ -/*! - * etag - * Copyright(c) 2014-2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict' - -/** - * Module exports. - * @public - */ - -module.exports = etag - -/** - * Module dependencies. - * @private - */ - -var crypto = require('crypto') -var Stats = require('fs').Stats - -/** - * Module variables. - * @private - */ - -var base64PadCharRegExp = /=+$/ -var toString = Object.prototype.toString - -/** - * Generate an entity tag. - * - * @param {Buffer|string} entity - * @return {string} - * @private - */ - -function entitytag(entity) { - if (entity.length === 0) { - // fast-path empty - return '"0-1B2M2Y8AsgTpgAmY7PhCfg"' - } - - // compute hash of entity - var hash = crypto - .createHash('md5') - .update(entity, 'utf8') - .digest('base64') - .replace(base64PadCharRegExp, '') - - // compute length of entity - var len = typeof entity === 'string' - ? Buffer.byteLength(entity, 'utf8') - : entity.length - - return '"' + len.toString(16) + '-' + hash + '"' -} - -/** - * Create a simple ETag. - * - * @param {string|Buffer|Stats} entity - * @param {object} [options] - * @param {boolean} [options.weak] - * @return {String} - * @public - */ - -function etag(entity, options) { - if (entity == null) { - throw new TypeError('argument entity is required') - } - - // support fs.Stats object - var isStats = isstats(entity) - var weak = options && typeof options.weak === 'boolean' - ? options.weak - : isStats - - // validate argument - if (!isStats && typeof entity !== 'string' && !Buffer.isBuffer(entity)) { - throw new TypeError('argument entity must be string, Buffer, or fs.Stats') - } - - // generate entity tag - var tag = isStats - ? stattag(entity) - : entitytag(entity) - - return weak - ? 'W/' + tag - : tag -} - -/** - * Determine if object is a Stats object. - * - * @param {object} obj - * @return {boolean} - * @api private - */ - -function isstats(obj) { - // genuine fs.Stats - if (typeof Stats === 'function' && obj instanceof Stats) { - return true - } - - // quack quack - return obj && typeof obj === 'object' - && 'ctime' in obj && toString.call(obj.ctime) === '[object Date]' - && 'mtime' in obj && toString.call(obj.mtime) === '[object Date]' - && 'ino' in obj && typeof obj.ino === 'number' - && 'size' in obj && typeof obj.size === 'number' -} - -/** - * Generate a tag for a stat. - * - * @param {object} stat - * @return {string} - * @private - */ - -function stattag(stat) { - var mtime = stat.mtime.getTime().toString(16) - var size = stat.size.toString(16) - - return '"' + size + '-' + mtime + '"' -} +/*! + * etag + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module exports. + * @public + */ + +module.exports = etag + +/** + * Module dependencies. + * @private + */ + +var crypto = require('crypto') +var Stats = require('fs').Stats + +/** + * Module variables. + * @private + */ + +var base64PadCharRegExp = /=+$/ +var toString = Object.prototype.toString + +/** + * Generate an entity tag. + * + * @param {Buffer|string} entity + * @return {string} + * @private + */ + +function entitytag(entity) { + if (entity.length === 0) { + // fast-path empty + return '"0-1B2M2Y8AsgTpgAmY7PhCfg"' + } + + // compute hash of entity + var hash = crypto + .createHash('md5') + .update(entity, 'utf8') + .digest('base64') + .replace(base64PadCharRegExp, '') + + // compute length of entity + var len = typeof entity === 'string' + ? Buffer.byteLength(entity, 'utf8') + : entity.length + + return '"' + len.toString(16) + '-' + hash + '"' +} + +/** + * Create a simple ETag. + * + * @param {string|Buffer|Stats} entity + * @param {object} [options] + * @param {boolean} [options.weak] + * @return {String} + * @public + */ + +function etag(entity, options) { + if (entity == null) { + throw new TypeError('argument entity is required') + } + + // support fs.Stats object + var isStats = isstats(entity) + var weak = options && typeof options.weak === 'boolean' + ? options.weak + : isStats + + // validate argument + if (!isStats && typeof entity !== 'string' && !Buffer.isBuffer(entity)) { + throw new TypeError('argument entity must be string, Buffer, or fs.Stats') + } + + // generate entity tag + var tag = isStats + ? stattag(entity) + : entitytag(entity) + + return weak + ? 'W/' + tag + : tag +} + +/** + * Determine if object is a Stats object. + * + * @param {object} obj + * @return {boolean} + * @api private + */ + +function isstats(obj) { + // genuine fs.Stats + if (typeof Stats === 'function' && obj instanceof Stats) { + return true + } + + // quack quack + return obj && typeof obj === 'object' + && 'ctime' in obj && toString.call(obj.ctime) === '[object Date]' + && 'mtime' in obj && toString.call(obj.mtime) === '[object Date]' + && 'ino' in obj && typeof obj.ino === 'number' + && 'size' in obj && typeof obj.size === 'number' +} + +/** + * Generate a tag for a stat. + * + * @param {object} stat + * @return {string} + * @private + */ + +function stattag(stat) { + var mtime = stat.mtime.getTime().toString(16) + var size = stat.size.toString(16) + + return '"' + size + '-' + mtime + '"' +} diff --git a/ui/node_modules/express/node_modules/etag/package.json b/ui/node_modules/express/node_modules/etag/package.json index b61eb01c..b1b5d225 100644 --- a/ui/node_modules/express/node_modules/etag/package.json +++ b/ui/node_modules/express/node_modules/etag/package.json @@ -1,73 +1,73 @@ -{ - "name": "etag", - "description": "Create simple ETags", - "version": "1.7.0", - "contributors": [ - { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "David Björklund", - "email": "david.bjorklund@gmail.com" - } - ], - "license": "MIT", - "keywords": [ - "etag", - "http", - "res" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/etag.git" - }, - "devDependencies": { - "benchmark": "1.0.0", - "beautify-benchmark": "0.2.4", - "istanbul": "0.3.14", - "mocha": "~1.21.4", - "seedrandom": "2.3.11" - }, - "files": [ - "LICENSE", - "HISTORY.md", - "README.md", - "index.js" - ], - "engines": { - "node": ">= 0.6" - }, - "scripts": { - "bench": "node benchmark/index.js", - "test": "mocha --reporter spec --bail --check-leaks test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" - }, - "gitHead": "a511f5c8c930fd9546dbd88acb080f96bc788cfc", - "bugs": { - "url": "https://github.com/jshttp/etag/issues" - }, - "homepage": "https://github.com/jshttp/etag", - "_id": "etag@1.7.0", - "_shasum": "03d30b5f67dd6e632d2945d30d6652731a34d5d8", - "_from": "etag@>=1.7.0 <1.8.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "03d30b5f67dd6e632d2945d30d6652731a34d5d8", - "tarball": "https://registry.npmjs.org/etag/-/etag-1.7.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/etag/-/etag-1.7.0.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "etag", + "description": "Create simple ETags", + "version": "1.7.0", + "contributors": [ + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "David Björklund", + "email": "david.bjorklund@gmail.com" + } + ], + "license": "MIT", + "keywords": [ + "etag", + "http", + "res" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/etag.git" + }, + "devDependencies": { + "benchmark": "1.0.0", + "beautify-benchmark": "0.2.4", + "istanbul": "0.3.14", + "mocha": "~1.21.4", + "seedrandom": "2.3.11" + }, + "files": [ + "LICENSE", + "HISTORY.md", + "README.md", + "index.js" + ], + "engines": { + "node": ">= 0.6" + }, + "scripts": { + "bench": "node benchmark/index.js", + "test": "mocha --reporter spec --bail --check-leaks test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" + }, + "gitHead": "a511f5c8c930fd9546dbd88acb080f96bc788cfc", + "bugs": { + "url": "https://github.com/jshttp/etag/issues" + }, + "homepage": "https://github.com/jshttp/etag", + "_id": "etag@1.7.0", + "_shasum": "03d30b5f67dd6e632d2945d30d6652731a34d5d8", + "_from": "etag@>=1.7.0 <1.8.0", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "maintainers": [ + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + } + ], + "dist": { + "shasum": "03d30b5f67dd6e632d2945d30d6652731a34d5d8", + "tarball": "https://registry.npmjs.org/etag/-/etag-1.7.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/etag/-/etag-1.7.0.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/finalhandler/HISTORY.md b/ui/node_modules/express/node_modules/finalhandler/HISTORY.md index c48ff479..e7e144c6 100644 --- a/ui/node_modules/express/node_modules/finalhandler/HISTORY.md +++ b/ui/node_modules/express/node_modules/finalhandler/HISTORY.md @@ -1,108 +1,108 @@ -0.5.0 / 2016-06-15 -================== - - * Change invalid or non-numeric status code to 500 - * Overwrite status message to match set status code - * Prefer `err.statusCode` if `err.status` is invalid - * Set response headers from `err.headers` object - * Use `statuses` instead of `http` module for status messages - - Includes all defined status messages - -0.4.1 / 2015-12-02 -================== - - * deps: escape-html@~1.0.3 - - perf: enable strict mode - - perf: optimize string replacement - - perf: use faster string coercion - -0.4.0 / 2015-06-14 -================== - - * Fix a false-positive when unpiping in Node.js 0.8 - * Support `statusCode` property on `Error` objects - * Use `unpipe` module for unpiping requests - * deps: escape-html@1.0.2 - * deps: on-finished@~2.3.0 - - Add defined behavior for HTTP `CONNECT` requests - - Add defined behavior for HTTP `Upgrade` requests - - deps: ee-first@1.1.1 - * perf: enable strict mode - * perf: remove argument reassignment - -0.3.6 / 2015-05-11 -================== - - * deps: debug@~2.2.0 - - deps: ms@0.7.1 - -0.3.5 / 2015-04-22 -================== - - * deps: on-finished@~2.2.1 - - Fix `isFinished(req)` when data buffered - -0.3.4 / 2015-03-15 -================== - - * deps: debug@~2.1.3 - - Fix high intensity foreground color for bold - - deps: ms@0.7.0 - -0.3.3 / 2015-01-01 -================== - - * deps: debug@~2.1.1 - * deps: on-finished@~2.2.0 - -0.3.2 / 2014-10-22 -================== - - * deps: on-finished@~2.1.1 - - Fix handling of pipelined requests - -0.3.1 / 2014-10-16 -================== - - * deps: debug@~2.1.0 - - Implement `DEBUG_FD` env variable support - -0.3.0 / 2014-09-17 -================== - - * Terminate in progress response only on error - * Use `on-finished` to determine request status - -0.2.0 / 2014-09-03 -================== - - * Set `X-Content-Type-Options: nosniff` header - * deps: debug@~2.0.0 - -0.1.0 / 2014-07-16 -================== - - * Respond after request fully read - - prevents hung responses and socket hang ups - * deps: debug@1.0.4 - -0.0.3 / 2014-07-11 -================== - - * deps: debug@1.0.3 - - Add support for multiple wildcards in namespaces - -0.0.2 / 2014-06-19 -================== - - * Handle invalid status codes - -0.0.1 / 2014-06-05 -================== - - * deps: debug@1.0.2 - -0.0.0 / 2014-06-05 -================== - - * Extracted from connect/express +0.5.0 / 2016-06-15 +================== + + * Change invalid or non-numeric status code to 500 + * Overwrite status message to match set status code + * Prefer `err.statusCode` if `err.status` is invalid + * Set response headers from `err.headers` object + * Use `statuses` instead of `http` module for status messages + - Includes all defined status messages + +0.4.1 / 2015-12-02 +================== + + * deps: escape-html@~1.0.3 + - perf: enable strict mode + - perf: optimize string replacement + - perf: use faster string coercion + +0.4.0 / 2015-06-14 +================== + + * Fix a false-positive when unpiping in Node.js 0.8 + * Support `statusCode` property on `Error` objects + * Use `unpipe` module for unpiping requests + * deps: escape-html@1.0.2 + * deps: on-finished@~2.3.0 + - Add defined behavior for HTTP `CONNECT` requests + - Add defined behavior for HTTP `Upgrade` requests + - deps: ee-first@1.1.1 + * perf: enable strict mode + * perf: remove argument reassignment + +0.3.6 / 2015-05-11 +================== + + * deps: debug@~2.2.0 + - deps: ms@0.7.1 + +0.3.5 / 2015-04-22 +================== + + * deps: on-finished@~2.2.1 + - Fix `isFinished(req)` when data buffered + +0.3.4 / 2015-03-15 +================== + + * deps: debug@~2.1.3 + - Fix high intensity foreground color for bold + - deps: ms@0.7.0 + +0.3.3 / 2015-01-01 +================== + + * deps: debug@~2.1.1 + * deps: on-finished@~2.2.0 + +0.3.2 / 2014-10-22 +================== + + * deps: on-finished@~2.1.1 + - Fix handling of pipelined requests + +0.3.1 / 2014-10-16 +================== + + * deps: debug@~2.1.0 + - Implement `DEBUG_FD` env variable support + +0.3.0 / 2014-09-17 +================== + + * Terminate in progress response only on error + * Use `on-finished` to determine request status + +0.2.0 / 2014-09-03 +================== + + * Set `X-Content-Type-Options: nosniff` header + * deps: debug@~2.0.0 + +0.1.0 / 2014-07-16 +================== + + * Respond after request fully read + - prevents hung responses and socket hang ups + * deps: debug@1.0.4 + +0.0.3 / 2014-07-11 +================== + + * deps: debug@1.0.3 + - Add support for multiple wildcards in namespaces + +0.0.2 / 2014-06-19 +================== + + * Handle invalid status codes + +0.0.1 / 2014-06-05 +================== + + * deps: debug@1.0.2 + +0.0.0 / 2014-06-05 +================== + + * Extracted from connect/express diff --git a/ui/node_modules/express/node_modules/finalhandler/LICENSE b/ui/node_modules/express/node_modules/finalhandler/LICENSE index c2ef573b..b60a5adf 100644 --- a/ui/node_modules/express/node_modules/finalhandler/LICENSE +++ b/ui/node_modules/express/node_modules/finalhandler/LICENSE @@ -1,22 +1,22 @@ -(The MIT License) - -Copyright (c) 2014-2015 Douglas Christopher Wilson - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2014-2015 Douglas Christopher Wilson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/finalhandler/README.md b/ui/node_modules/express/node_modules/finalhandler/README.md index 317f89f3..58bf7201 100644 --- a/ui/node_modules/express/node_modules/finalhandler/README.md +++ b/ui/node_modules/express/node_modules/finalhandler/README.md @@ -1,142 +1,142 @@ -# finalhandler - -[![NPM Version][npm-image]][npm-url] -[![NPM Downloads][downloads-image]][downloads-url] -[![Node.js Version][node-image]][node-url] -[![Build Status][travis-image]][travis-url] -[![Test Coverage][coveralls-image]][coveralls-url] - -Node.js function to invoke as the final step to respond to HTTP request. - -## Installation - -```sh -$ npm install finalhandler -``` - -## API - -```js -var finalhandler = require('finalhandler') -``` - -### finalhandler(req, res, [options]) - -Returns function to be invoked as the final step for the given `req` and `res`. -This function is to be invoked as `fn(err)`. If `err` is falsy, the handler will -write out a 404 response to the `res`. If it is truthy, an error response will -be written out to the `res`. - -When an error is written, the following information is added to the response: - - * The `res.statusCode` is set from `err.status` (or `err.statusCode`). If - this value is outside the 4xx or 5xx range, it will be set to 500. - * The `res.statusMessage` is set according to the status code. - * The body will be the HTML of the status code message if `env` is - `'production'`, otherwise will be `err.stack`. - * Any headers specified in an `err.headers` object. - -The final handler will also unpipe anything from `req` when it is invoked. - -#### options.env - -By default, the environment is determined by `NODE_ENV` variable, but it can be -overridden by this option. - -#### options.onerror - -Provide a function to be called with the `err` when it exists. Can be used for -writing errors to a central location without excessive function generation. Called -as `onerror(err, req, res)`. - -## Examples - -### always 404 - -```js -var finalhandler = require('finalhandler') -var http = require('http') - -var server = http.createServer(function (req, res) { - var done = finalhandler(req, res) - done() -}) - -server.listen(3000) -``` - -### perform simple action - -```js -var finalhandler = require('finalhandler') -var fs = require('fs') -var http = require('http') - -var server = http.createServer(function (req, res) { - var done = finalhandler(req, res) - - fs.readFile('index.html', function (err, buf) { - if (err) return done(err) - res.setHeader('Content-Type', 'text/html') - res.end(buf) - }) -}) - -server.listen(3000) -``` - -### use with middleware-style functions - -```js -var finalhandler = require('finalhandler') -var http = require('http') -var serveStatic = require('serve-static') - -var serve = serveStatic('public') - -var server = http.createServer(function (req, res) { - var done = finalhandler(req, res) - serve(req, res, done) -}) - -server.listen(3000) -``` - -### keep log of all errors - -```js -var finalhandler = require('finalhandler') -var fs = require('fs') -var http = require('http') - -var server = http.createServer(function (req, res) { - var done = finalhandler(req, res, {onerror: logerror}) - - fs.readFile('index.html', function (err, buf) { - if (err) return done(err) - res.setHeader('Content-Type', 'text/html') - res.end(buf) - }) -}) - -server.listen(3000) - -function logerror(err) { - console.error(err.stack || err.toString()) -} -``` - -## License - -[MIT](LICENSE) - -[npm-image]: https://img.shields.io/npm/v/finalhandler.svg -[npm-url]: https://npmjs.org/package/finalhandler -[node-image]: https://img.shields.io/node/v/finalhandler.svg -[node-url]: https://nodejs.org/en/download -[travis-image]: https://img.shields.io/travis/pillarjs/finalhandler.svg -[travis-url]: https://travis-ci.org/pillarjs/finalhandler -[coveralls-image]: https://img.shields.io/coveralls/pillarjs/finalhandler.svg -[coveralls-url]: https://coveralls.io/r/pillarjs/finalhandler?branch=master -[downloads-image]: https://img.shields.io/npm/dm/finalhandler.svg -[downloads-url]: https://npmjs.org/package/finalhandler +# finalhandler + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-image]][node-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +Node.js function to invoke as the final step to respond to HTTP request. + +## Installation + +```sh +$ npm install finalhandler +``` + +## API + +```js +var finalhandler = require('finalhandler') +``` + +### finalhandler(req, res, [options]) + +Returns function to be invoked as the final step for the given `req` and `res`. +This function is to be invoked as `fn(err)`. If `err` is falsy, the handler will +write out a 404 response to the `res`. If it is truthy, an error response will +be written out to the `res`. + +When an error is written, the following information is added to the response: + + * The `res.statusCode` is set from `err.status` (or `err.statusCode`). If + this value is outside the 4xx or 5xx range, it will be set to 500. + * The `res.statusMessage` is set according to the status code. + * The body will be the HTML of the status code message if `env` is + `'production'`, otherwise will be `err.stack`. + * Any headers specified in an `err.headers` object. + +The final handler will also unpipe anything from `req` when it is invoked. + +#### options.env + +By default, the environment is determined by `NODE_ENV` variable, but it can be +overridden by this option. + +#### options.onerror + +Provide a function to be called with the `err` when it exists. Can be used for +writing errors to a central location without excessive function generation. Called +as `onerror(err, req, res)`. + +## Examples + +### always 404 + +```js +var finalhandler = require('finalhandler') +var http = require('http') + +var server = http.createServer(function (req, res) { + var done = finalhandler(req, res) + done() +}) + +server.listen(3000) +``` + +### perform simple action + +```js +var finalhandler = require('finalhandler') +var fs = require('fs') +var http = require('http') + +var server = http.createServer(function (req, res) { + var done = finalhandler(req, res) + + fs.readFile('index.html', function (err, buf) { + if (err) return done(err) + res.setHeader('Content-Type', 'text/html') + res.end(buf) + }) +}) + +server.listen(3000) +``` + +### use with middleware-style functions + +```js +var finalhandler = require('finalhandler') +var http = require('http') +var serveStatic = require('serve-static') + +var serve = serveStatic('public') + +var server = http.createServer(function (req, res) { + var done = finalhandler(req, res) + serve(req, res, done) +}) + +server.listen(3000) +``` + +### keep log of all errors + +```js +var finalhandler = require('finalhandler') +var fs = require('fs') +var http = require('http') + +var server = http.createServer(function (req, res) { + var done = finalhandler(req, res, {onerror: logerror}) + + fs.readFile('index.html', function (err, buf) { + if (err) return done(err) + res.setHeader('Content-Type', 'text/html') + res.end(buf) + }) +}) + +server.listen(3000) + +function logerror(err) { + console.error(err.stack || err.toString()) +} +``` + +## License + +[MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/finalhandler.svg +[npm-url]: https://npmjs.org/package/finalhandler +[node-image]: https://img.shields.io/node/v/finalhandler.svg +[node-url]: https://nodejs.org/en/download +[travis-image]: https://img.shields.io/travis/pillarjs/finalhandler.svg +[travis-url]: https://travis-ci.org/pillarjs/finalhandler +[coveralls-image]: https://img.shields.io/coveralls/pillarjs/finalhandler.svg +[coveralls-url]: https://coveralls.io/r/pillarjs/finalhandler?branch=master +[downloads-image]: https://img.shields.io/npm/dm/finalhandler.svg +[downloads-url]: https://npmjs.org/package/finalhandler diff --git a/ui/node_modules/express/node_modules/finalhandler/index.js b/ui/node_modules/express/node_modules/finalhandler/index.js index b161d382..884d8024 100644 --- a/ui/node_modules/express/node_modules/finalhandler/index.js +++ b/ui/node_modules/express/node_modules/finalhandler/index.js @@ -1,189 +1,189 @@ -/*! - * finalhandler - * Copyright(c) 2014-2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict' - -/** - * Module dependencies. - * @private - */ - -var debug = require('debug')('finalhandler') -var escapeHtml = require('escape-html') -var onFinished = require('on-finished') -var statuses = require('statuses') -var unpipe = require('unpipe') - -/** - * Module variables. - * @private - */ - -/* istanbul ignore next */ -var defer = typeof setImmediate === 'function' - ? setImmediate - : function (fn) { process.nextTick(fn.bind.apply(fn, arguments)) } -var isFinished = onFinished.isFinished - -/** - * Module exports. - * @public - */ - -module.exports = finalhandler - -/** - * Create a function to handle the final response. - * - * @param {Request} req - * @param {Response} res - * @param {Object} [options] - * @return {Function} - * @public - */ - -function finalhandler (req, res, options) { - var opts = options || {} - - // get environment - var env = opts.env || process.env.NODE_ENV || 'development' - - // get error callback - var onerror = opts.onerror - - return function (err) { - var headers = Object.create(null) - var status - - // ignore 404 on in-flight response - if (!err && res._header) { - debug('cannot 404 after headers sent') - return - } - - // unhandled error - if (err) { - // respect status code from error - status = getErrorStatusCode(err) || res.statusCode - - // default status code to 500 if outside valid range - if (typeof status !== 'number' || status < 400 || status > 599) { - status = 500 - } - - // respect err.headers - if (err.headers && (err.status === status || err.statusCode === status)) { - var keys = Object.keys(err.headers) - for (var i = 0; i < keys.length; i++) { - var key = keys[i] - headers[key] = err.headers[key] - } - } - - // production gets a basic error message - var msg = env === 'production' - ? statuses[status] - : err.stack || err.toString() - msg = escapeHtml(msg) - .replace(/\n/g, '
') - .replace(/\x20{2}/g, '  ') + '\n' - } else { - status = 404 - msg = 'Cannot ' + escapeHtml(req.method) + ' ' + escapeHtml(req.originalUrl || req.url) + '\n' - } - - debug('default %s', status) - - // schedule onerror callback - if (err && onerror) { - defer(onerror, err, req, res) - } - - // cannot actually respond - if (res._header) { - debug('cannot %d after headers sent', status) - req.socket.destroy() - return - } - - // send response - send(req, res, status, headers, msg) - } -} - -/** - * Get status code from Error object. - * - * @param {Error} err - * @return {number} - * @private - */ - -function getErrorStatusCode (err) { - // check err.status - if (typeof err.status === 'number' && err.status >= 400 && err.status < 600) { - return err.status - } - - // check err.statusCode - if (typeof err.statusCode === 'number' && err.statusCode >= 400 && err.statusCode < 600) { - return err.statusCode - } - - return undefined -} - -/** - * Send response. - * - * @param {IncomingMessage} req - * @param {OutgoingMessage} res - * @param {number} status - * @param {object} headers - * @param {string} body - * @private - */ - -function send (req, res, status, headers, body) { - function write () { - // response status - res.statusCode = status - res.statusMessage = statuses[status] - - // response headers - var keys = Object.keys(headers) - for (var i = 0; i < keys.length; i++) { - var key = keys[i] - res.setHeader(key, headers[key]) - } - - // security header for content sniffing - res.setHeader('X-Content-Type-Options', 'nosniff') - - // standard headers - res.setHeader('Content-Type', 'text/html; charset=utf-8') - res.setHeader('Content-Length', Buffer.byteLength(body, 'utf8')) - - if (req.method === 'HEAD') { - res.end() - return - } - - res.end(body, 'utf8') - } - - if (isFinished(req)) { - write() - return - } - - // unpipe everything from the request - unpipe(req) - - // flush the request - onFinished(req, write) - req.resume() -} +/*! + * finalhandler + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module dependencies. + * @private + */ + +var debug = require('debug')('finalhandler') +var escapeHtml = require('escape-html') +var onFinished = require('on-finished') +var statuses = require('statuses') +var unpipe = require('unpipe') + +/** + * Module variables. + * @private + */ + +/* istanbul ignore next */ +var defer = typeof setImmediate === 'function' + ? setImmediate + : function (fn) { process.nextTick(fn.bind.apply(fn, arguments)) } +var isFinished = onFinished.isFinished + +/** + * Module exports. + * @public + */ + +module.exports = finalhandler + +/** + * Create a function to handle the final response. + * + * @param {Request} req + * @param {Response} res + * @param {Object} [options] + * @return {Function} + * @public + */ + +function finalhandler (req, res, options) { + var opts = options || {} + + // get environment + var env = opts.env || process.env.NODE_ENV || 'development' + + // get error callback + var onerror = opts.onerror + + return function (err) { + var headers = Object.create(null) + var status + + // ignore 404 on in-flight response + if (!err && res._header) { + debug('cannot 404 after headers sent') + return + } + + // unhandled error + if (err) { + // respect status code from error + status = getErrorStatusCode(err) || res.statusCode + + // default status code to 500 if outside valid range + if (typeof status !== 'number' || status < 400 || status > 599) { + status = 500 + } + + // respect err.headers + if (err.headers && (err.status === status || err.statusCode === status)) { + var keys = Object.keys(err.headers) + for (var i = 0; i < keys.length; i++) { + var key = keys[i] + headers[key] = err.headers[key] + } + } + + // production gets a basic error message + var msg = env === 'production' + ? statuses[status] + : err.stack || err.toString() + msg = escapeHtml(msg) + .replace(/\n/g, '
') + .replace(/\x20{2}/g, '  ') + '\n' + } else { + status = 404 + msg = 'Cannot ' + escapeHtml(req.method) + ' ' + escapeHtml(req.originalUrl || req.url) + '\n' + } + + debug('default %s', status) + + // schedule onerror callback + if (err && onerror) { + defer(onerror, err, req, res) + } + + // cannot actually respond + if (res._header) { + debug('cannot %d after headers sent', status) + req.socket.destroy() + return + } + + // send response + send(req, res, status, headers, msg) + } +} + +/** + * Get status code from Error object. + * + * @param {Error} err + * @return {number} + * @private + */ + +function getErrorStatusCode (err) { + // check err.status + if (typeof err.status === 'number' && err.status >= 400 && err.status < 600) { + return err.status + } + + // check err.statusCode + if (typeof err.statusCode === 'number' && err.statusCode >= 400 && err.statusCode < 600) { + return err.statusCode + } + + return undefined +} + +/** + * Send response. + * + * @param {IncomingMessage} req + * @param {OutgoingMessage} res + * @param {number} status + * @param {object} headers + * @param {string} body + * @private + */ + +function send (req, res, status, headers, body) { + function write () { + // response status + res.statusCode = status + res.statusMessage = statuses[status] + + // response headers + var keys = Object.keys(headers) + for (var i = 0; i < keys.length; i++) { + var key = keys[i] + res.setHeader(key, headers[key]) + } + + // security header for content sniffing + res.setHeader('X-Content-Type-Options', 'nosniff') + + // standard headers + res.setHeader('Content-Type', 'text/html; charset=utf-8') + res.setHeader('Content-Length', Buffer.byteLength(body, 'utf8')) + + if (req.method === 'HEAD') { + res.end() + return + } + + res.end(body, 'utf8') + } + + if (isFinished(req)) { + write() + return + } + + // unpipe everything from the request + unpipe(req) + + // flush the request + onFinished(req, write) + req.resume() +} diff --git a/ui/node_modules/express/node_modules/finalhandler/node_modules/statuses/HISTORY.md b/ui/node_modules/express/node_modules/finalhandler/node_modules/statuses/HISTORY.md index 063b4bc9..b175575c 100644 --- a/ui/node_modules/express/node_modules/finalhandler/node_modules/statuses/HISTORY.md +++ b/ui/node_modules/express/node_modules/finalhandler/node_modules/statuses/HISTORY.md @@ -1,50 +1,50 @@ -1.3.0 / 2016-05-17 -================== - - * Add `421 Misdirected Request` - * perf: enable strict mode - -1.2.1 / 2015-02-01 -================== - - * Fix message for status 451 - - `451 Unavailable For Legal Reasons` - -1.2.0 / 2014-09-28 -================== - - * Add `208 Already Repored` - * Add `226 IM Used` - * Add `306 (Unused)` - * Add `415 Unable For Legal Reasons` - * Add `508 Loop Detected` - -1.1.1 / 2014-09-24 -================== - - * Add missing 308 to `codes.json` - -1.1.0 / 2014-09-21 -================== - - * Add `codes.json` for universal support - -1.0.4 / 2014-08-20 -================== - - * Package cleanup - -1.0.3 / 2014-06-08 -================== - - * Add 308 to `.redirect` category - -1.0.2 / 2014-03-13 -================== - - * Add `.retry` category - -1.0.1 / 2014-03-12 -================== - - * Initial release +1.3.0 / 2016-05-17 +================== + + * Add `421 Misdirected Request` + * perf: enable strict mode + +1.2.1 / 2015-02-01 +================== + + * Fix message for status 451 + - `451 Unavailable For Legal Reasons` + +1.2.0 / 2014-09-28 +================== + + * Add `208 Already Repored` + * Add `226 IM Used` + * Add `306 (Unused)` + * Add `415 Unable For Legal Reasons` + * Add `508 Loop Detected` + +1.1.1 / 2014-09-24 +================== + + * Add missing 308 to `codes.json` + +1.1.0 / 2014-09-21 +================== + + * Add `codes.json` for universal support + +1.0.4 / 2014-08-20 +================== + + * Package cleanup + +1.0.3 / 2014-06-08 +================== + + * Add 308 to `.redirect` category + +1.0.2 / 2014-03-13 +================== + + * Add `.retry` category + +1.0.1 / 2014-03-12 +================== + + * Initial release diff --git a/ui/node_modules/express/node_modules/finalhandler/node_modules/statuses/LICENSE b/ui/node_modules/express/node_modules/finalhandler/node_modules/statuses/LICENSE index c232b56f..82af4df5 100644 --- a/ui/node_modules/express/node_modules/finalhandler/node_modules/statuses/LICENSE +++ b/ui/node_modules/express/node_modules/finalhandler/node_modules/statuses/LICENSE @@ -1,23 +1,23 @@ - -The MIT License (MIT) - -Copyright (c) 2014 Jonathan Ong me@jongleberry.com -Copyright (c) 2016 Douglas Christopher Wilson doug@somethingdoug.com - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. + +The MIT License (MIT) + +Copyright (c) 2014 Jonathan Ong me@jongleberry.com +Copyright (c) 2016 Douglas Christopher Wilson doug@somethingdoug.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/finalhandler/node_modules/statuses/README.md b/ui/node_modules/express/node_modules/finalhandler/node_modules/statuses/README.md index 7868753e..1a699da0 100644 --- a/ui/node_modules/express/node_modules/finalhandler/node_modules/statuses/README.md +++ b/ui/node_modules/express/node_modules/finalhandler/node_modules/statuses/README.md @@ -1,114 +1,114 @@ -# Statuses - -[![NPM Version][npm-image]][npm-url] -[![NPM Downloads][downloads-image]][downloads-url] -[![Node.js Version][node-version-image]][node-version-url] -[![Build Status][travis-image]][travis-url] -[![Test Coverage][coveralls-image]][coveralls-url] - -HTTP status utility for node. - -## API - -```js -var status = require('statuses') -``` - -### var code = status(Integer || String) - -If `Integer` or `String` is a valid HTTP code or status message, then the appropriate `code` will be returned. Otherwise, an error will be thrown. - -```js -status(403) // => 403 -status('403') // => 403 -status('forbidden') // => 403 -status('Forbidden') // => 403 -status(306) // throws, as it's not supported by node.js -``` - -### status.codes - -Returns an array of all the status codes as `Integer`s. - -### var msg = status[code] - -Map of `code` to `status message`. `undefined` for invalid `code`s. - -```js -status[404] // => 'Not Found' -``` - -### var code = status[msg] - -Map of `status message` to `code`. `msg` can either be title-cased or lower-cased. `undefined` for invalid `status message`s. - -```js -status['not found'] // => 404 -status['Not Found'] // => 404 -``` - -### status.redirect[code] - -Returns `true` if a status code is a valid redirect status. - -```js -status.redirect[200] // => undefined -status.redirect[301] // => true -``` - -### status.empty[code] - -Returns `true` if a status code expects an empty body. - -```js -status.empty[200] // => undefined -status.empty[204] // => true -status.empty[304] // => true -``` - -### status.retry[code] - -Returns `true` if you should retry the rest. - -```js -status.retry[501] // => undefined -status.retry[503] // => true -``` - -### statuses/codes.json - -```js -var codes = require('statuses/codes.json') -``` - -This is a JSON file of the status codes -taken from `require('http').STATUS_CODES`. -This is saved so that codes are consistent even in older node.js versions. -For example, `308` will be added in v0.12. - -## Adding Status Codes - -The status codes are primarily sourced from http://www.iana.org/assignments/http-status-codes/http-status-codes-1.csv. -Additionally, custom codes are added from http://en.wikipedia.org/wiki/List_of_HTTP_status_codes. -These are added manually in the `lib/*.json` files. -If you would like to add a status code, add it to the appropriate JSON file. - -To rebuild `codes.json`, run the following: - -```bash -# update src/iana.json -npm run fetch -# build codes.json -npm run build -``` - -[npm-image]: https://img.shields.io/npm/v/statuses.svg -[npm-url]: https://npmjs.org/package/statuses -[node-version-image]: https://img.shields.io/badge/node.js-%3E%3D_0.6-brightgreen.svg -[node-version-url]: https://nodejs.org/en/download -[travis-image]: https://img.shields.io/travis/jshttp/statuses.svg -[travis-url]: https://travis-ci.org/jshttp/statuses -[coveralls-image]: https://img.shields.io/coveralls/jshttp/statuses.svg -[coveralls-url]: https://coveralls.io/r/jshttp/statuses?branch=master -[downloads-image]: https://img.shields.io/npm/dm/statuses.svg -[downloads-url]: https://npmjs.org/package/statuses +# Statuses + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-version-image]][node-version-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +HTTP status utility for node. + +## API + +```js +var status = require('statuses') +``` + +### var code = status(Integer || String) + +If `Integer` or `String` is a valid HTTP code or status message, then the appropriate `code` will be returned. Otherwise, an error will be thrown. + +```js +status(403) // => 403 +status('403') // => 403 +status('forbidden') // => 403 +status('Forbidden') // => 403 +status(306) // throws, as it's not supported by node.js +``` + +### status.codes + +Returns an array of all the status codes as `Integer`s. + +### var msg = status[code] + +Map of `code` to `status message`. `undefined` for invalid `code`s. + +```js +status[404] // => 'Not Found' +``` + +### var code = status[msg] + +Map of `status message` to `code`. `msg` can either be title-cased or lower-cased. `undefined` for invalid `status message`s. + +```js +status['not found'] // => 404 +status['Not Found'] // => 404 +``` + +### status.redirect[code] + +Returns `true` if a status code is a valid redirect status. + +```js +status.redirect[200] // => undefined +status.redirect[301] // => true +``` + +### status.empty[code] + +Returns `true` if a status code expects an empty body. + +```js +status.empty[200] // => undefined +status.empty[204] // => true +status.empty[304] // => true +``` + +### status.retry[code] + +Returns `true` if you should retry the rest. + +```js +status.retry[501] // => undefined +status.retry[503] // => true +``` + +### statuses/codes.json + +```js +var codes = require('statuses/codes.json') +``` + +This is a JSON file of the status codes +taken from `require('http').STATUS_CODES`. +This is saved so that codes are consistent even in older node.js versions. +For example, `308` will be added in v0.12. + +## Adding Status Codes + +The status codes are primarily sourced from http://www.iana.org/assignments/http-status-codes/http-status-codes-1.csv. +Additionally, custom codes are added from http://en.wikipedia.org/wiki/List_of_HTTP_status_codes. +These are added manually in the `lib/*.json` files. +If you would like to add a status code, add it to the appropriate JSON file. + +To rebuild `codes.json`, run the following: + +```bash +# update src/iana.json +npm run fetch +# build codes.json +npm run build +``` + +[npm-image]: https://img.shields.io/npm/v/statuses.svg +[npm-url]: https://npmjs.org/package/statuses +[node-version-image]: https://img.shields.io/badge/node.js-%3E%3D_0.6-brightgreen.svg +[node-version-url]: https://nodejs.org/en/download +[travis-image]: https://img.shields.io/travis/jshttp/statuses.svg +[travis-url]: https://travis-ci.org/jshttp/statuses +[coveralls-image]: https://img.shields.io/coveralls/jshttp/statuses.svg +[coveralls-url]: https://coveralls.io/r/jshttp/statuses?branch=master +[downloads-image]: https://img.shields.io/npm/dm/statuses.svg +[downloads-url]: https://npmjs.org/package/statuses diff --git a/ui/node_modules/express/node_modules/finalhandler/node_modules/statuses/codes.json b/ui/node_modules/express/node_modules/finalhandler/node_modules/statuses/codes.json index 89e43eac..e7651233 100644 --- a/ui/node_modules/express/node_modules/finalhandler/node_modules/statuses/codes.json +++ b/ui/node_modules/express/node_modules/finalhandler/node_modules/statuses/codes.json @@ -1,65 +1,65 @@ -{ - "100": "Continue", - "101": "Switching Protocols", - "102": "Processing", - "200": "OK", - "201": "Created", - "202": "Accepted", - "203": "Non-Authoritative Information", - "204": "No Content", - "205": "Reset Content", - "206": "Partial Content", - "207": "Multi-Status", - "208": "Already Reported", - "226": "IM Used", - "300": "Multiple Choices", - "301": "Moved Permanently", - "302": "Found", - "303": "See Other", - "304": "Not Modified", - "305": "Use Proxy", - "306": "(Unused)", - "307": "Temporary Redirect", - "308": "Permanent Redirect", - "400": "Bad Request", - "401": "Unauthorized", - "402": "Payment Required", - "403": "Forbidden", - "404": "Not Found", - "405": "Method Not Allowed", - "406": "Not Acceptable", - "407": "Proxy Authentication Required", - "408": "Request Timeout", - "409": "Conflict", - "410": "Gone", - "411": "Length Required", - "412": "Precondition Failed", - "413": "Payload Too Large", - "414": "URI Too Long", - "415": "Unsupported Media Type", - "416": "Range Not Satisfiable", - "417": "Expectation Failed", - "418": "I'm a teapot", - "421": "Misdirected Request", - "422": "Unprocessable Entity", - "423": "Locked", - "424": "Failed Dependency", - "425": "Unordered Collection", - "426": "Upgrade Required", - "428": "Precondition Required", - "429": "Too Many Requests", - "431": "Request Header Fields Too Large", - "451": "Unavailable For Legal Reasons", - "500": "Internal Server Error", - "501": "Not Implemented", - "502": "Bad Gateway", - "503": "Service Unavailable", - "504": "Gateway Timeout", - "505": "HTTP Version Not Supported", - "506": "Variant Also Negotiates", - "507": "Insufficient Storage", - "508": "Loop Detected", - "509": "Bandwidth Limit Exceeded", - "510": "Not Extended", - "511": "Network Authentication Required" +{ + "100": "Continue", + "101": "Switching Protocols", + "102": "Processing", + "200": "OK", + "201": "Created", + "202": "Accepted", + "203": "Non-Authoritative Information", + "204": "No Content", + "205": "Reset Content", + "206": "Partial Content", + "207": "Multi-Status", + "208": "Already Reported", + "226": "IM Used", + "300": "Multiple Choices", + "301": "Moved Permanently", + "302": "Found", + "303": "See Other", + "304": "Not Modified", + "305": "Use Proxy", + "306": "(Unused)", + "307": "Temporary Redirect", + "308": "Permanent Redirect", + "400": "Bad Request", + "401": "Unauthorized", + "402": "Payment Required", + "403": "Forbidden", + "404": "Not Found", + "405": "Method Not Allowed", + "406": "Not Acceptable", + "407": "Proxy Authentication Required", + "408": "Request Timeout", + "409": "Conflict", + "410": "Gone", + "411": "Length Required", + "412": "Precondition Failed", + "413": "Payload Too Large", + "414": "URI Too Long", + "415": "Unsupported Media Type", + "416": "Range Not Satisfiable", + "417": "Expectation Failed", + "418": "I'm a teapot", + "421": "Misdirected Request", + "422": "Unprocessable Entity", + "423": "Locked", + "424": "Failed Dependency", + "425": "Unordered Collection", + "426": "Upgrade Required", + "428": "Precondition Required", + "429": "Too Many Requests", + "431": "Request Header Fields Too Large", + "451": "Unavailable For Legal Reasons", + "500": "Internal Server Error", + "501": "Not Implemented", + "502": "Bad Gateway", + "503": "Service Unavailable", + "504": "Gateway Timeout", + "505": "HTTP Version Not Supported", + "506": "Variant Also Negotiates", + "507": "Insufficient Storage", + "508": "Loop Detected", + "509": "Bandwidth Limit Exceeded", + "510": "Not Extended", + "511": "Network Authentication Required" } \ No newline at end of file diff --git a/ui/node_modules/express/node_modules/finalhandler/node_modules/statuses/index.js b/ui/node_modules/express/node_modules/finalhandler/node_modules/statuses/index.js index 63aa6cee..c2b555a2 100644 --- a/ui/node_modules/express/node_modules/finalhandler/node_modules/statuses/index.js +++ b/ui/node_modules/express/node_modules/finalhandler/node_modules/statuses/index.js @@ -1,110 +1,110 @@ -/*! - * statuses - * Copyright(c) 2014 Jonathan Ong - * Copyright(c) 2016 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict' - -/** - * Module dependencies. - * @private - */ - -var codes = require('./codes.json') - -/** - * Module exports. - * @public - */ - -module.exports = status - -// array of status codes -status.codes = populateStatusesMap(status, codes) - -// status codes for redirects -status.redirect = { - 300: true, - 301: true, - 302: true, - 303: true, - 305: true, - 307: true, - 308: true -} - -// status codes for empty bodies -status.empty = { - 204: true, - 205: true, - 304: true -} - -// status codes for when you should retry the request -status.retry = { - 502: true, - 503: true, - 504: true -} - -/** - * Populate the statuses map for given codes. - * @private - */ - -function populateStatusesMap (statuses, codes) { - var arr = [] - - Object.keys(codes).forEach(function forEachCode (code) { - var message = codes[code] - var status = Number(code) - - // Populate properties - statuses[status] = message - statuses[message] = status - statuses[message.toLowerCase()] = status - - // Add to array - arr.push(status) - }) - - return arr -} - -/** - * Get the status code. - * - * Given a number, this will throw if it is not a known status - * code, otherwise the code will be returned. Given a string, - * the string will be parsed for a number and return the code - * if valid, otherwise will lookup the code assuming this is - * the status message. - * - * @param {string|number} code - * @returns {string} - * @public - */ - -function status (code) { - if (typeof code === 'number') { - if (!status[code]) throw new Error('invalid status code: ' + code) - return code - } - - if (typeof code !== 'string') { - throw new TypeError('code must be a number or string') - } - - // '403' - var n = parseInt(code, 10) - if (!isNaN(n)) { - if (!status[n]) throw new Error('invalid status code: ' + n) - return n - } - - n = status[code.toLowerCase()] - if (!n) throw new Error('invalid status message: "' + code + '"') - return n -} +/*! + * statuses + * Copyright(c) 2014 Jonathan Ong + * Copyright(c) 2016 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module dependencies. + * @private + */ + +var codes = require('./codes.json') + +/** + * Module exports. + * @public + */ + +module.exports = status + +// array of status codes +status.codes = populateStatusesMap(status, codes) + +// status codes for redirects +status.redirect = { + 300: true, + 301: true, + 302: true, + 303: true, + 305: true, + 307: true, + 308: true +} + +// status codes for empty bodies +status.empty = { + 204: true, + 205: true, + 304: true +} + +// status codes for when you should retry the request +status.retry = { + 502: true, + 503: true, + 504: true +} + +/** + * Populate the statuses map for given codes. + * @private + */ + +function populateStatusesMap (statuses, codes) { + var arr = [] + + Object.keys(codes).forEach(function forEachCode (code) { + var message = codes[code] + var status = Number(code) + + // Populate properties + statuses[status] = message + statuses[message] = status + statuses[message.toLowerCase()] = status + + // Add to array + arr.push(status) + }) + + return arr +} + +/** + * Get the status code. + * + * Given a number, this will throw if it is not a known status + * code, otherwise the code will be returned. Given a string, + * the string will be parsed for a number and return the code + * if valid, otherwise will lookup the code assuming this is + * the status message. + * + * @param {string|number} code + * @returns {string} + * @public + */ + +function status (code) { + if (typeof code === 'number') { + if (!status[code]) throw new Error('invalid status code: ' + code) + return code + } + + if (typeof code !== 'string') { + throw new TypeError('code must be a number or string') + } + + // '403' + var n = parseInt(code, 10) + if (!isNaN(n)) { + if (!status[n]) throw new Error('invalid status code: ' + n) + return n + } + + n = status[code.toLowerCase()] + if (!n) throw new Error('invalid status message: "' + code + '"') + return n +} diff --git a/ui/node_modules/express/node_modules/finalhandler/node_modules/statuses/package.json b/ui/node_modules/express/node_modules/finalhandler/node_modules/statuses/package.json index 349925d9..450531a4 100644 --- a/ui/node_modules/express/node_modules/finalhandler/node_modules/statuses/package.json +++ b/ui/node_modules/express/node_modules/finalhandler/node_modules/statuses/package.json @@ -1,104 +1,104 @@ -{ - "name": "statuses", - "description": "HTTP status utility", - "version": "1.3.0", - "contributors": [ - { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "Jonathan Ong", - "email": "me@jongleberry.com", - "url": "http://jongleberry.com" - } - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/statuses.git" - }, - "license": "MIT", - "keywords": [ - "http", - "status", - "code" - ], - "files": [ - "HISTORY.md", - "index.js", - "codes.json", - "LICENSE" - ], - "devDependencies": { - "csv-parse": "1.0.1", - "eslint": "2.10.2", - "eslint-config-standard": "5.3.1", - "eslint-plugin-promise": "1.1.0", - "eslint-plugin-standard": "1.3.2", - "istanbul": "0.4.3", - "mocha": "1.21.5", - "stream-to-array": "2.2.0" - }, - "engines": { - "node": ">= 0.6" - }, - "scripts": { - "build": "node scripts/build.js", - "fetch": "node scripts/fetch.js", - "lint": "eslint **/*.js", - "test": "mocha --reporter spec --check-leaks --bail test/", - "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", - "update": "npm run fetch && npm run build" - }, - "gitHead": "b3e31e8c32dd8107e898b44b8c0b2dfff3cba495", - "bugs": { - "url": "https://github.com/jshttp/statuses/issues" - }, - "homepage": "https://github.com/jshttp/statuses", - "_id": "statuses@1.3.0", - "_shasum": "8e55758cb20e7682c1f4fce8dcab30bf01d1e07a", - "_from": "statuses@>=1.3.0 <1.4.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "defunctzombie", - "email": "shtylman@gmail.com" - }, - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "fishrock123", - "email": "fishrock123@rocketmail.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "mscdex", - "email": "mscdex@mscdex.net" - }, - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - } - ], - "dist": { - "shasum": "8e55758cb20e7682c1f4fce8dcab30bf01d1e07a", - "tarball": "https://registry.npmjs.org/statuses/-/statuses-1.3.0.tgz" - }, - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/statuses-1.3.0.tgz_1463517875633_0.19560232176445425" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.0.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "statuses", + "description": "HTTP status utility", + "version": "1.3.0", + "contributors": [ + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "Jonathan Ong", + "email": "me@jongleberry.com", + "url": "http://jongleberry.com" + } + ], + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/statuses.git" + }, + "license": "MIT", + "keywords": [ + "http", + "status", + "code" + ], + "files": [ + "HISTORY.md", + "index.js", + "codes.json", + "LICENSE" + ], + "devDependencies": { + "csv-parse": "1.0.1", + "eslint": "2.10.2", + "eslint-config-standard": "5.3.1", + "eslint-plugin-promise": "1.1.0", + "eslint-plugin-standard": "1.3.2", + "istanbul": "0.4.3", + "mocha": "1.21.5", + "stream-to-array": "2.2.0" + }, + "engines": { + "node": ">= 0.6" + }, + "scripts": { + "build": "node scripts/build.js", + "fetch": "node scripts/fetch.js", + "lint": "eslint **/*.js", + "test": "mocha --reporter spec --check-leaks --bail test/", + "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "update": "npm run fetch && npm run build" + }, + "gitHead": "b3e31e8c32dd8107e898b44b8c0b2dfff3cba495", + "bugs": { + "url": "https://github.com/jshttp/statuses/issues" + }, + "homepage": "https://github.com/jshttp/statuses", + "_id": "statuses@1.3.0", + "_shasum": "8e55758cb20e7682c1f4fce8dcab30bf01d1e07a", + "_from": "statuses@>=1.3.0 <1.4.0", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "maintainers": [ + { + "name": "defunctzombie", + "email": "shtylman@gmail.com" + }, + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "fishrock123", + "email": "fishrock123@rocketmail.com" + }, + { + "name": "jongleberry", + "email": "jonathanrichardong@gmail.com" + }, + { + "name": "mscdex", + "email": "mscdex@mscdex.net" + }, + { + "name": "tjholowaychuk", + "email": "tj@vision-media.ca" + } + ], + "dist": { + "shasum": "8e55758cb20e7682c1f4fce8dcab30bf01d1e07a", + "tarball": "https://registry.npmjs.org/statuses/-/statuses-1.3.0.tgz" + }, + "_npmOperationalInternal": { + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/statuses-1.3.0.tgz_1463517875633_0.19560232176445425" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.0.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/finalhandler/node_modules/unpipe/HISTORY.md b/ui/node_modules/express/node_modules/finalhandler/node_modules/unpipe/HISTORY.md index c52c70ca..85e0f8d7 100644 --- a/ui/node_modules/express/node_modules/finalhandler/node_modules/unpipe/HISTORY.md +++ b/ui/node_modules/express/node_modules/finalhandler/node_modules/unpipe/HISTORY.md @@ -1,4 +1,4 @@ -1.0.0 / 2015-06-14 -================== - - * Initial release +1.0.0 / 2015-06-14 +================== + + * Initial release diff --git a/ui/node_modules/express/node_modules/finalhandler/node_modules/unpipe/LICENSE b/ui/node_modules/express/node_modules/finalhandler/node_modules/unpipe/LICENSE index f3521aee..aed01382 100644 --- a/ui/node_modules/express/node_modules/finalhandler/node_modules/unpipe/LICENSE +++ b/ui/node_modules/express/node_modules/finalhandler/node_modules/unpipe/LICENSE @@ -1,22 +1,22 @@ -(The MIT License) - -Copyright (c) 2015 Douglas Christopher Wilson - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2015 Douglas Christopher Wilson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/finalhandler/node_modules/unpipe/README.md b/ui/node_modules/express/node_modules/finalhandler/node_modules/unpipe/README.md index 5bb214c8..e536ad2c 100644 --- a/ui/node_modules/express/node_modules/finalhandler/node_modules/unpipe/README.md +++ b/ui/node_modules/express/node_modules/finalhandler/node_modules/unpipe/README.md @@ -1,43 +1,43 @@ -# unpipe - -[![NPM Version][npm-image]][npm-url] -[![NPM Downloads][downloads-image]][downloads-url] -[![Node.js Version][node-image]][node-url] -[![Build Status][travis-image]][travis-url] -[![Test Coverage][coveralls-image]][coveralls-url] - -Unpipe a stream from all destinations. - -## Installation - -```sh -$ npm install unpipe -``` - -## API - -```js -var unpipe = require('unpipe') -``` - -### unpipe(stream) - -Unpipes all destinations from a given stream. With stream 2+, this is -equivalent to `stream.unpipe()`. When used with streams 1 style streams -(typically Node.js 0.8 and below), this module attempts to undo the -actions done in `stream.pipe(dest)`. - -## License - -[MIT](LICENSE) - -[npm-image]: https://img.shields.io/npm/v/unpipe.svg -[npm-url]: https://npmjs.org/package/unpipe -[node-image]: https://img.shields.io/node/v/unpipe.svg -[node-url]: http://nodejs.org/download/ -[travis-image]: https://img.shields.io/travis/stream-utils/unpipe.svg -[travis-url]: https://travis-ci.org/stream-utils/unpipe -[coveralls-image]: https://img.shields.io/coveralls/stream-utils/unpipe.svg -[coveralls-url]: https://coveralls.io/r/stream-utils/unpipe?branch=master -[downloads-image]: https://img.shields.io/npm/dm/unpipe.svg -[downloads-url]: https://npmjs.org/package/unpipe +# unpipe + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-image]][node-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +Unpipe a stream from all destinations. + +## Installation + +```sh +$ npm install unpipe +``` + +## API + +```js +var unpipe = require('unpipe') +``` + +### unpipe(stream) + +Unpipes all destinations from a given stream. With stream 2+, this is +equivalent to `stream.unpipe()`. When used with streams 1 style streams +(typically Node.js 0.8 and below), this module attempts to undo the +actions done in `stream.pipe(dest)`. + +## License + +[MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/unpipe.svg +[npm-url]: https://npmjs.org/package/unpipe +[node-image]: https://img.shields.io/node/v/unpipe.svg +[node-url]: http://nodejs.org/download/ +[travis-image]: https://img.shields.io/travis/stream-utils/unpipe.svg +[travis-url]: https://travis-ci.org/stream-utils/unpipe +[coveralls-image]: https://img.shields.io/coveralls/stream-utils/unpipe.svg +[coveralls-url]: https://coveralls.io/r/stream-utils/unpipe?branch=master +[downloads-image]: https://img.shields.io/npm/dm/unpipe.svg +[downloads-url]: https://npmjs.org/package/unpipe diff --git a/ui/node_modules/express/node_modules/finalhandler/node_modules/unpipe/index.js b/ui/node_modules/express/node_modules/finalhandler/node_modules/unpipe/index.js index 0dfb808d..15c3d97a 100644 --- a/ui/node_modules/express/node_modules/finalhandler/node_modules/unpipe/index.js +++ b/ui/node_modules/express/node_modules/finalhandler/node_modules/unpipe/index.js @@ -1,69 +1,69 @@ -/*! - * unpipe - * Copyright(c) 2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict' - -/** - * Module exports. - * @public - */ - -module.exports = unpipe - -/** - * Determine if there are Node.js pipe-like data listeners. - * @private - */ - -function hasPipeDataListeners(stream) { - var listeners = stream.listeners('data') - - for (var i = 0; i < listeners.length; i++) { - if (listeners[i].name === 'ondata') { - return true - } - } - - return false -} - -/** - * Unpipe a stream from all destinations. - * - * @param {object} stream - * @public - */ - -function unpipe(stream) { - if (!stream) { - throw new TypeError('argument stream is required') - } - - if (typeof stream.unpipe === 'function') { - // new-style - stream.unpipe() - return - } - - // Node.js 0.8 hack - if (!hasPipeDataListeners(stream)) { - return - } - - var listener - var listeners = stream.listeners('close') - - for (var i = 0; i < listeners.length; i++) { - listener = listeners[i] - - if (listener.name !== 'cleanup' && listener.name !== 'onclose') { - continue - } - - // invoke the listener - listener.call(stream) - } -} +/*! + * unpipe + * Copyright(c) 2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module exports. + * @public + */ + +module.exports = unpipe + +/** + * Determine if there are Node.js pipe-like data listeners. + * @private + */ + +function hasPipeDataListeners(stream) { + var listeners = stream.listeners('data') + + for (var i = 0; i < listeners.length; i++) { + if (listeners[i].name === 'ondata') { + return true + } + } + + return false +} + +/** + * Unpipe a stream from all destinations. + * + * @param {object} stream + * @public + */ + +function unpipe(stream) { + if (!stream) { + throw new TypeError('argument stream is required') + } + + if (typeof stream.unpipe === 'function') { + // new-style + stream.unpipe() + return + } + + // Node.js 0.8 hack + if (!hasPipeDataListeners(stream)) { + return + } + + var listener + var listeners = stream.listeners('close') + + for (var i = 0; i < listeners.length; i++) { + listener = listeners[i] + + if (listener.name !== 'cleanup' && listener.name !== 'onclose') { + continue + } + + // invoke the listener + listener.call(stream) + } +} diff --git a/ui/node_modules/express/node_modules/finalhandler/node_modules/unpipe/package.json b/ui/node_modules/express/node_modules/finalhandler/node_modules/unpipe/package.json index 7fa82d4a..dc61177a 100644 --- a/ui/node_modules/express/node_modules/finalhandler/node_modules/unpipe/package.json +++ b/ui/node_modules/express/node_modules/finalhandler/node_modules/unpipe/package.json @@ -1,59 +1,59 @@ -{ - "name": "unpipe", - "description": "Unpipe a stream from all destinations", - "version": "1.0.0", - "author": { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - }, - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/stream-utils/unpipe.git" - }, - "devDependencies": { - "istanbul": "0.3.15", - "mocha": "2.2.5", - "readable-stream": "1.1.13" - }, - "files": [ - "HISTORY.md", - "LICENSE", - "README.md", - "index.js" - ], - "engines": { - "node": ">= 0.8" - }, - "scripts": { - "test": "mocha --reporter spec --bail --check-leaks test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" - }, - "gitHead": "d2df901c06487430e78dca62b6edb8bb2fc5e99d", - "bugs": { - "url": "https://github.com/stream-utils/unpipe/issues" - }, - "homepage": "https://github.com/stream-utils/unpipe", - "_id": "unpipe@1.0.0", - "_shasum": "b2bf4ee8514aae6165b4817829d21b2ef49904ec", - "_from": "unpipe@>=1.0.0 <1.1.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "b2bf4ee8514aae6165b4817829d21b2ef49904ec", - "tarball": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "unpipe", + "description": "Unpipe a stream from all destinations", + "version": "1.0.0", + "author": { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + }, + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/stream-utils/unpipe.git" + }, + "devDependencies": { + "istanbul": "0.3.15", + "mocha": "2.2.5", + "readable-stream": "1.1.13" + }, + "files": [ + "HISTORY.md", + "LICENSE", + "README.md", + "index.js" + ], + "engines": { + "node": ">= 0.8" + }, + "scripts": { + "test": "mocha --reporter spec --bail --check-leaks test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" + }, + "gitHead": "d2df901c06487430e78dca62b6edb8bb2fc5e99d", + "bugs": { + "url": "https://github.com/stream-utils/unpipe/issues" + }, + "homepage": "https://github.com/stream-utils/unpipe", + "_id": "unpipe@1.0.0", + "_shasum": "b2bf4ee8514aae6165b4817829d21b2ef49904ec", + "_from": "unpipe@>=1.0.0 <1.1.0", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "maintainers": [ + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + } + ], + "dist": { + "shasum": "b2bf4ee8514aae6165b4817829d21b2ef49904ec", + "tarball": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/finalhandler/package.json b/ui/node_modules/express/node_modules/finalhandler/package.json index 1ed4fe60..19267d27 100644 --- a/ui/node_modules/express/node_modules/finalhandler/package.json +++ b/ui/node_modules/express/node_modules/finalhandler/package.json @@ -1,75 +1,75 @@ -{ - "name": "finalhandler", - "description": "Node.js final http responder", - "version": "0.5.0", - "author": { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - }, - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/pillarjs/finalhandler.git" - }, - "dependencies": { - "debug": "~2.2.0", - "escape-html": "~1.0.3", - "on-finished": "~2.3.0", - "statuses": "~1.3.0", - "unpipe": "~1.0.0" - }, - "devDependencies": { - "eslint": "2.12.0", - "eslint-config-standard": "5.3.1", - "eslint-plugin-promise": "1.3.2", - "eslint-plugin-standard": "1.3.2", - "istanbul": "0.4.3", - "mocha": "2.5.3", - "readable-stream": "2.1.2", - "supertest": "1.1.0" - }, - "files": [ - "LICENSE", - "HISTORY.md", - "index.js" - ], - "engines": { - "node": ">= 0.8" - }, - "scripts": { - "lint": "eslint **/*.js", - "test": "mocha --reporter spec --bail --check-leaks test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" - }, - "gitHead": "15cc543eb87dd0e2f29e931d86816a6eb348c573", - "bugs": { - "url": "https://github.com/pillarjs/finalhandler/issues" - }, - "homepage": "https://github.com/pillarjs/finalhandler", - "_id": "finalhandler@0.5.0", - "_shasum": "e9508abece9b6dba871a6942a1d7911b91911ac7", - "_from": "finalhandler@0.5.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "e9508abece9b6dba871a6942a1d7911b91911ac7", - "tarball": "https://registry.npmjs.org/finalhandler/-/finalhandler-0.5.0.tgz" - }, - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/finalhandler-0.5.0.tgz_1466028655505_0.19758180482313037" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-0.5.0.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "finalhandler", + "description": "Node.js final http responder", + "version": "0.5.0", + "author": { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + }, + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/pillarjs/finalhandler.git" + }, + "dependencies": { + "debug": "~2.2.0", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "statuses": "~1.3.0", + "unpipe": "~1.0.0" + }, + "devDependencies": { + "eslint": "2.12.0", + "eslint-config-standard": "5.3.1", + "eslint-plugin-promise": "1.3.2", + "eslint-plugin-standard": "1.3.2", + "istanbul": "0.4.3", + "mocha": "2.5.3", + "readable-stream": "2.1.2", + "supertest": "1.1.0" + }, + "files": [ + "LICENSE", + "HISTORY.md", + "index.js" + ], + "engines": { + "node": ">= 0.8" + }, + "scripts": { + "lint": "eslint **/*.js", + "test": "mocha --reporter spec --bail --check-leaks test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" + }, + "gitHead": "15cc543eb87dd0e2f29e931d86816a6eb348c573", + "bugs": { + "url": "https://github.com/pillarjs/finalhandler/issues" + }, + "homepage": "https://github.com/pillarjs/finalhandler", + "_id": "finalhandler@0.5.0", + "_shasum": "e9508abece9b6dba871a6942a1d7911b91911ac7", + "_from": "finalhandler@0.5.0", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "maintainers": [ + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + } + ], + "dist": { + "shasum": "e9508abece9b6dba871a6942a1d7911b91911ac7", + "tarball": "https://registry.npmjs.org/finalhandler/-/finalhandler-0.5.0.tgz" + }, + "_npmOperationalInternal": { + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/finalhandler-0.5.0.tgz_1466028655505_0.19758180482313037" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-0.5.0.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/fresh/HISTORY.md b/ui/node_modules/express/node_modules/fresh/HISTORY.md index 58a3e87c..3c95fbb9 100644 --- a/ui/node_modules/express/node_modules/fresh/HISTORY.md +++ b/ui/node_modules/express/node_modules/fresh/HISTORY.md @@ -1,38 +1,38 @@ -0.3.0 / 2015-05-12 -================== - - * Add weak `ETag` matching support - -0.2.4 / 2014-09-07 -================== - - * Support Node.js 0.6 - -0.2.3 / 2014-09-07 -================== - - * Move repository to jshttp - -0.2.2 / 2014-02-19 -================== - - * Revert "Fix for blank page on Safari reload" - -0.2.1 / 2014-01-29 -================== - - * Fix for blank page on Safari reload - -0.2.0 / 2013-08-11 -================== - - * Return stale for `Cache-Control: no-cache` - -0.1.0 / 2012-06-15 -================== - * Add `If-None-Match: *` support - -0.0.1 / 2012-06-10 -================== - - * Initial release +0.3.0 / 2015-05-12 +================== + + * Add weak `ETag` matching support + +0.2.4 / 2014-09-07 +================== + + * Support Node.js 0.6 + +0.2.3 / 2014-09-07 +================== + + * Move repository to jshttp + +0.2.2 / 2014-02-19 +================== + + * Revert "Fix for blank page on Safari reload" + +0.2.1 / 2014-01-29 +================== + + * Fix for blank page on Safari reload + +0.2.0 / 2013-08-11 +================== + + * Return stale for `Cache-Control: no-cache` + +0.1.0 / 2012-06-15 +================== + * Add `If-None-Match: *` support + +0.0.1 / 2012-06-10 +================== + + * Initial release diff --git a/ui/node_modules/express/node_modules/fresh/LICENSE b/ui/node_modules/express/node_modules/fresh/LICENSE index 0035cfc0..f5273943 100644 --- a/ui/node_modules/express/node_modules/fresh/LICENSE +++ b/ui/node_modules/express/node_modules/fresh/LICENSE @@ -1,22 +1,22 @@ -(The MIT License) - -Copyright (c) 2012 TJ Holowaychuk - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2012 TJ Holowaychuk + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/fresh/README.md b/ui/node_modules/express/node_modules/fresh/README.md index 199de012..0813e309 100644 --- a/ui/node_modules/express/node_modules/fresh/README.md +++ b/ui/node_modules/express/node_modules/fresh/README.md @@ -1,58 +1,58 @@ -# fresh - -[![NPM Version][npm-image]][npm-url] -[![NPM Downloads][downloads-image]][downloads-url] -[![Node.js Version][node-version-image]][node-version-url] -[![Build Status][travis-image]][travis-url] -[![Test Coverage][coveralls-image]][coveralls-url] - -HTTP response freshness testing - -## Installation - -``` -$ npm install fresh -``` - -## API - -```js -var fresh = require('fresh') -``` - -### fresh(req, res) - - Check freshness of `req` and `res` headers. - - When the cache is "fresh" __true__ is returned, - otherwise __false__ is returned to indicate that - the cache is now stale. - -## Example - -```js -var req = { 'if-none-match': 'tobi' }; -var res = { 'etag': 'luna' }; -fresh(req, res); -// => false - -var req = { 'if-none-match': 'tobi' }; -var res = { 'etag': 'tobi' }; -fresh(req, res); -// => true -``` - -## License - -[MIT](LICENSE) - -[npm-image]: https://img.shields.io/npm/v/fresh.svg -[npm-url]: https://npmjs.org/package/fresh -[node-version-image]: https://img.shields.io/node/v/fresh.svg -[node-version-url]: http://nodejs.org/download/ -[travis-image]: https://img.shields.io/travis/jshttp/fresh/master.svg -[travis-url]: https://travis-ci.org/jshttp/fresh -[coveralls-image]: https://img.shields.io/coveralls/jshttp/fresh/master.svg -[coveralls-url]: https://coveralls.io/r/jshttp/fresh?branch=master -[downloads-image]: https://img.shields.io/npm/dm/fresh.svg -[downloads-url]: https://npmjs.org/package/fresh +# fresh + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-version-image]][node-version-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +HTTP response freshness testing + +## Installation + +``` +$ npm install fresh +``` + +## API + +```js +var fresh = require('fresh') +``` + +### fresh(req, res) + + Check freshness of `req` and `res` headers. + + When the cache is "fresh" __true__ is returned, + otherwise __false__ is returned to indicate that + the cache is now stale. + +## Example + +```js +var req = { 'if-none-match': 'tobi' }; +var res = { 'etag': 'luna' }; +fresh(req, res); +// => false + +var req = { 'if-none-match': 'tobi' }; +var res = { 'etag': 'tobi' }; +fresh(req, res); +// => true +``` + +## License + +[MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/fresh.svg +[npm-url]: https://npmjs.org/package/fresh +[node-version-image]: https://img.shields.io/node/v/fresh.svg +[node-version-url]: http://nodejs.org/download/ +[travis-image]: https://img.shields.io/travis/jshttp/fresh/master.svg +[travis-url]: https://travis-ci.org/jshttp/fresh +[coveralls-image]: https://img.shields.io/coveralls/jshttp/fresh/master.svg +[coveralls-url]: https://coveralls.io/r/jshttp/fresh?branch=master +[downloads-image]: https://img.shields.io/npm/dm/fresh.svg +[downloads-url]: https://npmjs.org/package/fresh diff --git a/ui/node_modules/express/node_modules/fresh/index.js b/ui/node_modules/express/node_modules/fresh/index.js index 90852956..a9008736 100644 --- a/ui/node_modules/express/node_modules/fresh/index.js +++ b/ui/node_modules/express/node_modules/fresh/index.js @@ -1,57 +1,57 @@ - -/** - * Expose `fresh()`. - */ - -module.exports = fresh; - -/** - * Check freshness of `req` and `res` headers. - * - * When the cache is "fresh" __true__ is returned, - * otherwise __false__ is returned to indicate that - * the cache is now stale. - * - * @param {Object} req - * @param {Object} res - * @return {Boolean} - * @api public - */ - -function fresh(req, res) { - // defaults - var etagMatches = true; - var notModified = true; - - // fields - var modifiedSince = req['if-modified-since']; - var noneMatch = req['if-none-match']; - var lastModified = res['last-modified']; - var etag = res['etag']; - var cc = req['cache-control']; - - // unconditional request - if (!modifiedSince && !noneMatch) return false; - - // check for no-cache cache request directive - if (cc && cc.indexOf('no-cache') !== -1) return false; - - // parse if-none-match - if (noneMatch) noneMatch = noneMatch.split(/ *, */); - - // if-none-match - if (noneMatch) { - etagMatches = noneMatch.some(function (match) { - return match === '*' || match === etag || match === 'W/' + etag; - }); - } - - // if-modified-since - if (modifiedSince) { - modifiedSince = new Date(modifiedSince); - lastModified = new Date(lastModified); - notModified = lastModified <= modifiedSince; - } - - return !! (etagMatches && notModified); -} + +/** + * Expose `fresh()`. + */ + +module.exports = fresh; + +/** + * Check freshness of `req` and `res` headers. + * + * When the cache is "fresh" __true__ is returned, + * otherwise __false__ is returned to indicate that + * the cache is now stale. + * + * @param {Object} req + * @param {Object} res + * @return {Boolean} + * @api public + */ + +function fresh(req, res) { + // defaults + var etagMatches = true; + var notModified = true; + + // fields + var modifiedSince = req['if-modified-since']; + var noneMatch = req['if-none-match']; + var lastModified = res['last-modified']; + var etag = res['etag']; + var cc = req['cache-control']; + + // unconditional request + if (!modifiedSince && !noneMatch) return false; + + // check for no-cache cache request directive + if (cc && cc.indexOf('no-cache') !== -1) return false; + + // parse if-none-match + if (noneMatch) noneMatch = noneMatch.split(/ *, */); + + // if-none-match + if (noneMatch) { + etagMatches = noneMatch.some(function (match) { + return match === '*' || match === etag || match === 'W/' + etag; + }); + } + + // if-modified-since + if (modifiedSince) { + modifiedSince = new Date(modifiedSince); + lastModified = new Date(lastModified); + notModified = lastModified <= modifiedSince; + } + + return !! (etagMatches && notModified); +} diff --git a/ui/node_modules/express/node_modules/fresh/package.json b/ui/node_modules/express/node_modules/fresh/package.json index c6995c92..c0fc6222 100644 --- a/ui/node_modules/express/node_modules/fresh/package.json +++ b/ui/node_modules/express/node_modules/fresh/package.json @@ -1,87 +1,87 @@ -{ - "name": "fresh", - "description": "HTTP response freshness testing", - "version": "0.3.0", - "author": { - "name": "TJ Holowaychuk", - "email": "tj@vision-media.ca", - "url": "http://tjholowaychuk.com" - }, - "contributors": [ - { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "Jonathan Ong", - "email": "me@jongleberry.com", - "url": "http://jongleberry.com" - } - ], - "license": "MIT", - "keywords": [ - "fresh", - "http", - "conditional", - "cache" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/fresh.git" - }, - "devDependencies": { - "istanbul": "0.3.9", - "mocha": "1.21.5" - }, - "files": [ - "HISTORY.md", - "LICENSE", - "index.js" - ], - "engines": { - "node": ">= 0.6" - }, - "scripts": { - "test": "mocha --reporter spec --bail --check-leaks test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" - }, - "gitHead": "14616c9748368ca08cd6a955dd88ab659b778634", - "bugs": { - "url": "https://github.com/jshttp/fresh/issues" - }, - "homepage": "https://github.com/jshttp/fresh", - "_id": "fresh@0.3.0", - "_shasum": "651f838e22424e7566de161d8358caa199f83d4f", - "_from": "fresh@0.3.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - { - "name": "jonathanong", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - } - ], - "dist": { - "shasum": "651f838e22424e7566de161d8358caa199f83d4f", - "tarball": "https://registry.npmjs.org/fresh/-/fresh-0.3.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/fresh/-/fresh-0.3.0.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "fresh", + "description": "HTTP response freshness testing", + "version": "0.3.0", + "author": { + "name": "TJ Holowaychuk", + "email": "tj@vision-media.ca", + "url": "http://tjholowaychuk.com" + }, + "contributors": [ + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "Jonathan Ong", + "email": "me@jongleberry.com", + "url": "http://jongleberry.com" + } + ], + "license": "MIT", + "keywords": [ + "fresh", + "http", + "conditional", + "cache" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/fresh.git" + }, + "devDependencies": { + "istanbul": "0.3.9", + "mocha": "1.21.5" + }, + "files": [ + "HISTORY.md", + "LICENSE", + "index.js" + ], + "engines": { + "node": ">= 0.6" + }, + "scripts": { + "test": "mocha --reporter spec --bail --check-leaks test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" + }, + "gitHead": "14616c9748368ca08cd6a955dd88ab659b778634", + "bugs": { + "url": "https://github.com/jshttp/fresh/issues" + }, + "homepage": "https://github.com/jshttp/fresh", + "_id": "fresh@0.3.0", + "_shasum": "651f838e22424e7566de161d8358caa199f83d4f", + "_from": "fresh@0.3.0", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "maintainers": [ + { + "name": "tjholowaychuk", + "email": "tj@vision-media.ca" + }, + { + "name": "jonathanong", + "email": "jonathanrichardong@gmail.com" + }, + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "jongleberry", + "email": "jonathanrichardong@gmail.com" + } + ], + "dist": { + "shasum": "651f838e22424e7566de161d8358caa199f83d4f", + "tarball": "https://registry.npmjs.org/fresh/-/fresh-0.3.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/fresh/-/fresh-0.3.0.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/merge-descriptors/HISTORY.md b/ui/node_modules/express/node_modules/merge-descriptors/HISTORY.md index cb4e62c7..486771f0 100644 --- a/ui/node_modules/express/node_modules/merge-descriptors/HISTORY.md +++ b/ui/node_modules/express/node_modules/merge-descriptors/HISTORY.md @@ -1,21 +1,21 @@ -1.0.1 / 2016-01-17 -================== - - * perf: enable strict mode - -1.0.0 / 2015-03-01 -================== - - * Add option to only add new descriptors - * Add simple argument validation - * Add jsdoc to source file - -0.0.2 / 2013-12-14 -================== - - * Move repository to `component` organization - -0.0.1 / 2013-10-29 -================== - - * Initial release +1.0.1 / 2016-01-17 +================== + + * perf: enable strict mode + +1.0.0 / 2015-03-01 +================== + + * Add option to only add new descriptors + * Add simple argument validation + * Add jsdoc to source file + +0.0.2 / 2013-12-14 +================== + + * Move repository to `component` organization + +0.0.1 / 2013-10-29 +================== + + * Initial release diff --git a/ui/node_modules/express/node_modules/merge-descriptors/LICENSE b/ui/node_modules/express/node_modules/merge-descriptors/LICENSE index b3ac78ac..274bfd82 100644 --- a/ui/node_modules/express/node_modules/merge-descriptors/LICENSE +++ b/ui/node_modules/express/node_modules/merge-descriptors/LICENSE @@ -1,23 +1,23 @@ -(The MIT License) - -Copyright (c) 2013 Jonathan Ong -Copyright (c) 2015 Douglas Christopher Wilson - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2013 Jonathan Ong +Copyright (c) 2015 Douglas Christopher Wilson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/merge-descriptors/README.md b/ui/node_modules/express/node_modules/merge-descriptors/README.md index a9247922..d593c0eb 100644 --- a/ui/node_modules/express/node_modules/merge-descriptors/README.md +++ b/ui/node_modules/express/node_modules/merge-descriptors/README.md @@ -1,48 +1,48 @@ -# Merge Descriptors - -[![NPM Version][npm-image]][npm-url] -[![NPM Downloads][downloads-image]][downloads-url] -[![Build Status][travis-image]][travis-url] -[![Test Coverage][coveralls-image]][coveralls-url] - -Merge objects using descriptors. - -```js -var thing = { - get name() { - return 'jon' - } -} - -var animal = { - -} - -merge(animal, thing) - -animal.name === 'jon' -``` - -## API - -### merge(destination, source) - -Redefines `destination`'s descriptors with `source`'s. - -### merge(destination, source, false) - -Defines `source`'s descriptors on `destination` if `destination` does not have -a descriptor by the same name. - -## License - -[MIT](LICENSE) - -[npm-image]: https://img.shields.io/npm/v/merge-descriptors.svg -[npm-url]: https://npmjs.org/package/merge-descriptors -[travis-image]: https://img.shields.io/travis/component/merge-descriptors/master.svg -[travis-url]: https://travis-ci.org/component/merge-descriptors -[coveralls-image]: https://img.shields.io/coveralls/component/merge-descriptors/master.svg -[coveralls-url]: https://coveralls.io/r/component/merge-descriptors?branch=master -[downloads-image]: https://img.shields.io/npm/dm/merge-descriptors.svg -[downloads-url]: https://npmjs.org/package/merge-descriptors +# Merge Descriptors + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +Merge objects using descriptors. + +```js +var thing = { + get name() { + return 'jon' + } +} + +var animal = { + +} + +merge(animal, thing) + +animal.name === 'jon' +``` + +## API + +### merge(destination, source) + +Redefines `destination`'s descriptors with `source`'s. + +### merge(destination, source, false) + +Defines `source`'s descriptors on `destination` if `destination` does not have +a descriptor by the same name. + +## License + +[MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/merge-descriptors.svg +[npm-url]: https://npmjs.org/package/merge-descriptors +[travis-image]: https://img.shields.io/travis/component/merge-descriptors/master.svg +[travis-url]: https://travis-ci.org/component/merge-descriptors +[coveralls-image]: https://img.shields.io/coveralls/component/merge-descriptors/master.svg +[coveralls-url]: https://coveralls.io/r/component/merge-descriptors?branch=master +[downloads-image]: https://img.shields.io/npm/dm/merge-descriptors.svg +[downloads-url]: https://npmjs.org/package/merge-descriptors diff --git a/ui/node_modules/express/node_modules/merge-descriptors/index.js b/ui/node_modules/express/node_modules/merge-descriptors/index.js index 9f1ed9f8..573b132e 100644 --- a/ui/node_modules/express/node_modules/merge-descriptors/index.js +++ b/ui/node_modules/express/node_modules/merge-descriptors/index.js @@ -1,60 +1,60 @@ -/*! - * merge-descriptors - * Copyright(c) 2014 Jonathan Ong - * Copyright(c) 2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict' - -/** - * Module exports. - * @public - */ - -module.exports = merge - -/** - * Module variables. - * @private - */ - -var hasOwnProperty = Object.prototype.hasOwnProperty - -/** - * Merge the property descriptors of `src` into `dest` - * - * @param {object} dest Object to add descriptors to - * @param {object} src Object to clone descriptors from - * @param {boolean} [redefine=true] Redefine `dest` properties with `src` properties - * @returns {object} Reference to dest - * @public - */ - -function merge(dest, src, redefine) { - if (!dest) { - throw new TypeError('argument dest is required') - } - - if (!src) { - throw new TypeError('argument src is required') - } - - if (redefine === undefined) { - // Default to true - redefine = true - } - - Object.getOwnPropertyNames(src).forEach(function forEachOwnPropertyName(name) { - if (!redefine && hasOwnProperty.call(dest, name)) { - // Skip desriptor - return - } - - // Copy descriptor - var descriptor = Object.getOwnPropertyDescriptor(src, name) - Object.defineProperty(dest, name, descriptor) - }) - - return dest -} +/*! + * merge-descriptors + * Copyright(c) 2014 Jonathan Ong + * Copyright(c) 2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module exports. + * @public + */ + +module.exports = merge + +/** + * Module variables. + * @private + */ + +var hasOwnProperty = Object.prototype.hasOwnProperty + +/** + * Merge the property descriptors of `src` into `dest` + * + * @param {object} dest Object to add descriptors to + * @param {object} src Object to clone descriptors from + * @param {boolean} [redefine=true] Redefine `dest` properties with `src` properties + * @returns {object} Reference to dest + * @public + */ + +function merge(dest, src, redefine) { + if (!dest) { + throw new TypeError('argument dest is required') + } + + if (!src) { + throw new TypeError('argument src is required') + } + + if (redefine === undefined) { + // Default to true + redefine = true + } + + Object.getOwnPropertyNames(src).forEach(function forEachOwnPropertyName(name) { + if (!redefine && hasOwnProperty.call(dest, name)) { + // Skip desriptor + return + } + + // Copy descriptor + var descriptor = Object.getOwnPropertyDescriptor(src, name) + Object.defineProperty(dest, name, descriptor) + }) + + return dest +} diff --git a/ui/node_modules/express/node_modules/merge-descriptors/package.json b/ui/node_modules/express/node_modules/merge-descriptors/package.json index 64537c0f..e2cde776 100644 --- a/ui/node_modules/express/node_modules/merge-descriptors/package.json +++ b/ui/node_modules/express/node_modules/merge-descriptors/package.json @@ -1,138 +1,138 @@ -{ - "name": "merge-descriptors", - "description": "Merge objects using descriptors", - "version": "1.0.1", - "author": { - "name": "Jonathan Ong", - "email": "me@jongleberry.com", - "url": "http://jongleberry.com" - }, - "contributors": [ - { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "Mike Grabowski", - "email": "grabbou@gmail.com" - } - ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/component/merge-descriptors.git" - }, - "devDependencies": { - "istanbul": "0.4.1", - "mocha": "1.21.5" - }, - "files": [ - "HISTORY.md", - "LICENSE", - "README.md", - "index.js" - ], - "scripts": { - "test": "mocha --reporter spec --bail --check-leaks test/", - "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/" - }, - "gitHead": "f26c49c3b423b0b2ac31f6e32a84e1632f2d7ac2", - "bugs": { - "url": "https://github.com/component/merge-descriptors/issues" - }, - "homepage": "https://github.com/component/merge-descriptors", - "_id": "merge-descriptors@1.0.1", - "_shasum": "b00aaa556dd8b44568150ec9d1b953f3f90cbb61", - "_from": "merge-descriptors@1.0.1", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "anthonyshort", - "email": "antshort@gmail.com" - }, - { - "name": "clintwood", - "email": "clint@anotherway.co.za" - }, - { - "name": "dfcreative", - "email": "df.creative@gmail.com" - }, - { - "name": "dominicbarnes", - "email": "dominic@dbarnes.info" - }, - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "ianstormtaylor", - "email": "ian@ianstormtaylor.com" - }, - { - "name": "jonathanong", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "juliangruber", - "email": "julian@juliangruber.com" - }, - { - "name": "mattmueller", - "email": "mattmuelle@gmail.com" - }, - { - "name": "queckezz", - "email": "fabian.eichenberger@gmail.com" - }, - { - "name": "stephenmathieson", - "email": "me@stephenmathieson.com" - }, - { - "name": "thehydroimpulse", - "email": "dnfagnan@gmail.com" - }, - { - "name": "timaschew", - "email": "timaschew@gmail.com" - }, - { - "name": "timoxley", - "email": "secoif@gmail.com" - }, - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - }, - { - "name": "trevorgerhardt", - "email": "trevorgerhardt@gmail.com" - }, - { - "name": "yields", - "email": "yields@icloud.com" - } - ], - "dist": { - "shasum": "b00aaa556dd8b44568150ec9d1b953f3f90cbb61", - "tarball": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "merge-descriptors", + "description": "Merge objects using descriptors", + "version": "1.0.1", + "author": { + "name": "Jonathan Ong", + "email": "me@jongleberry.com", + "url": "http://jongleberry.com" + }, + "contributors": [ + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "Mike Grabowski", + "email": "grabbou@gmail.com" + } + ], + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/component/merge-descriptors.git" + }, + "devDependencies": { + "istanbul": "0.4.1", + "mocha": "1.21.5" + }, + "files": [ + "HISTORY.md", + "LICENSE", + "README.md", + "index.js" + ], + "scripts": { + "test": "mocha --reporter spec --bail --check-leaks test/", + "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/" + }, + "gitHead": "f26c49c3b423b0b2ac31f6e32a84e1632f2d7ac2", + "bugs": { + "url": "https://github.com/component/merge-descriptors/issues" + }, + "homepage": "https://github.com/component/merge-descriptors", + "_id": "merge-descriptors@1.0.1", + "_shasum": "b00aaa556dd8b44568150ec9d1b953f3f90cbb61", + "_from": "merge-descriptors@1.0.1", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "maintainers": [ + { + "name": "anthonyshort", + "email": "antshort@gmail.com" + }, + { + "name": "clintwood", + "email": "clint@anotherway.co.za" + }, + { + "name": "dfcreative", + "email": "df.creative@gmail.com" + }, + { + "name": "dominicbarnes", + "email": "dominic@dbarnes.info" + }, + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "ianstormtaylor", + "email": "ian@ianstormtaylor.com" + }, + { + "name": "jonathanong", + "email": "jonathanrichardong@gmail.com" + }, + { + "name": "jongleberry", + "email": "jonathanrichardong@gmail.com" + }, + { + "name": "juliangruber", + "email": "julian@juliangruber.com" + }, + { + "name": "mattmueller", + "email": "mattmuelle@gmail.com" + }, + { + "name": "queckezz", + "email": "fabian.eichenberger@gmail.com" + }, + { + "name": "stephenmathieson", + "email": "me@stephenmathieson.com" + }, + { + "name": "thehydroimpulse", + "email": "dnfagnan@gmail.com" + }, + { + "name": "timaschew", + "email": "timaschew@gmail.com" + }, + { + "name": "timoxley", + "email": "secoif@gmail.com" + }, + { + "name": "tjholowaychuk", + "email": "tj@vision-media.ca" + }, + { + "name": "tootallnate", + "email": "nathan@tootallnate.net" + }, + { + "name": "trevorgerhardt", + "email": "trevorgerhardt@gmail.com" + }, + { + "name": "yields", + "email": "yields@icloud.com" + } + ], + "dist": { + "shasum": "b00aaa556dd8b44568150ec9d1b953f3f90cbb61", + "tarball": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/methods/HISTORY.md b/ui/node_modules/express/node_modules/methods/HISTORY.md index e0e05b57..c0ecf072 100644 --- a/ui/node_modules/express/node_modules/methods/HISTORY.md +++ b/ui/node_modules/express/node_modules/methods/HISTORY.md @@ -1,29 +1,29 @@ -1.1.2 / 2016-01-17 -================== - - * perf: enable strict mode - -1.1.1 / 2014-12-30 -================== - - * Improve `browserify` support - -1.1.0 / 2014-07-05 -================== - - * Add `CONNECT` method - -1.0.1 / 2014-06-02 -================== - - * Fix module to work with harmony transform - -1.0.0 / 2014-05-08 -================== - - * Add `PURGE` method - -0.1.0 / 2013-10-28 -================== - - * Add `http.METHODS` support +1.1.2 / 2016-01-17 +================== + + * perf: enable strict mode + +1.1.1 / 2014-12-30 +================== + + * Improve `browserify` support + +1.1.0 / 2014-07-05 +================== + + * Add `CONNECT` method + +1.0.1 / 2014-06-02 +================== + + * Fix module to work with harmony transform + +1.0.0 / 2014-05-08 +================== + + * Add `PURGE` method + +0.1.0 / 2013-10-28 +================== + + * Add `http.METHODS` support diff --git a/ui/node_modules/express/node_modules/methods/LICENSE b/ui/node_modules/express/node_modules/methods/LICENSE index 24169a49..220dc1a2 100644 --- a/ui/node_modules/express/node_modules/methods/LICENSE +++ b/ui/node_modules/express/node_modules/methods/LICENSE @@ -1,24 +1,24 @@ -(The MIT License) - -Copyright (c) 2013-2014 TJ Holowaychuk -Copyright (c) 2015-2016 Douglas Christopher Wilson - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +(The MIT License) + +Copyright (c) 2013-2014 TJ Holowaychuk +Copyright (c) 2015-2016 Douglas Christopher Wilson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/ui/node_modules/express/node_modules/methods/README.md b/ui/node_modules/express/node_modules/methods/README.md index b1bc5b73..672a32bf 100644 --- a/ui/node_modules/express/node_modules/methods/README.md +++ b/ui/node_modules/express/node_modules/methods/README.md @@ -1,51 +1,51 @@ -# Methods - -[![NPM Version][npm-image]][npm-url] -[![NPM Downloads][downloads-image]][downloads-url] -[![Node.js Version][node-version-image]][node-version-url] -[![Build Status][travis-image]][travis-url] -[![Test Coverage][coveralls-image]][coveralls-url] - -HTTP verbs that Node.js core's HTTP parser supports. - -This module provides an export that is just like `http.METHODS` from Node.js core, -with the following differences: - - * All method names are lower-cased. - * Contains a fallback list of methods for Node.js versions that do not have a - `http.METHODS` export (0.10 and lower). - * Provides the fallback list when using tools like `browserify` without pulling - in the `http` shim module. - -## Install - -```bash -$ npm install methods -``` - -## API - -```js -var methods = require('methods') -``` - -### methods - -This is an array of lower-cased method names that Node.js supports. If Node.js -provides the `http.METHODS` export, then this is the same array lower-cased, -otherwise it is a snapshot of the verbs from Node.js 0.10. - -## License - -[MIT](LICENSE) - -[npm-image]: https://img.shields.io/npm/v/methods.svg?style=flat -[npm-url]: https://npmjs.org/package/methods -[node-version-image]: https://img.shields.io/node/v/methods.svg?style=flat -[node-version-url]: https://nodejs.org/en/download/ -[travis-image]: https://img.shields.io/travis/jshttp/methods.svg?style=flat -[travis-url]: https://travis-ci.org/jshttp/methods -[coveralls-image]: https://img.shields.io/coveralls/jshttp/methods.svg?style=flat -[coveralls-url]: https://coveralls.io/r/jshttp/methods?branch=master -[downloads-image]: https://img.shields.io/npm/dm/methods.svg?style=flat -[downloads-url]: https://npmjs.org/package/methods +# Methods + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-version-image]][node-version-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +HTTP verbs that Node.js core's HTTP parser supports. + +This module provides an export that is just like `http.METHODS` from Node.js core, +with the following differences: + + * All method names are lower-cased. + * Contains a fallback list of methods for Node.js versions that do not have a + `http.METHODS` export (0.10 and lower). + * Provides the fallback list when using tools like `browserify` without pulling + in the `http` shim module. + +## Install + +```bash +$ npm install methods +``` + +## API + +```js +var methods = require('methods') +``` + +### methods + +This is an array of lower-cased method names that Node.js supports. If Node.js +provides the `http.METHODS` export, then this is the same array lower-cased, +otherwise it is a snapshot of the verbs from Node.js 0.10. + +## License + +[MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/methods.svg?style=flat +[npm-url]: https://npmjs.org/package/methods +[node-version-image]: https://img.shields.io/node/v/methods.svg?style=flat +[node-version-url]: https://nodejs.org/en/download/ +[travis-image]: https://img.shields.io/travis/jshttp/methods.svg?style=flat +[travis-url]: https://travis-ci.org/jshttp/methods +[coveralls-image]: https://img.shields.io/coveralls/jshttp/methods.svg?style=flat +[coveralls-url]: https://coveralls.io/r/jshttp/methods?branch=master +[downloads-image]: https://img.shields.io/npm/dm/methods.svg?style=flat +[downloads-url]: https://npmjs.org/package/methods diff --git a/ui/node_modules/express/node_modules/methods/index.js b/ui/node_modules/express/node_modules/methods/index.js index bdf363d0..667a50bd 100644 --- a/ui/node_modules/express/node_modules/methods/index.js +++ b/ui/node_modules/express/node_modules/methods/index.js @@ -1,69 +1,69 @@ -/*! - * methods - * Copyright(c) 2013-2014 TJ Holowaychuk - * Copyright(c) 2015-2016 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict'; - -/** - * Module dependencies. - * @private - */ - -var http = require('http'); - -/** - * Module exports. - * @public - */ - -module.exports = getCurrentNodeMethods() || getBasicNodeMethods(); - -/** - * Get the current Node.js methods. - * @private - */ - -function getCurrentNodeMethods() { - return http.METHODS && http.METHODS.map(function lowerCaseMethod(method) { - return method.toLowerCase(); - }); -} - -/** - * Get the "basic" Node.js methods, a snapshot from Node.js 0.10. - * @private - */ - -function getBasicNodeMethods() { - return [ - 'get', - 'post', - 'put', - 'head', - 'delete', - 'options', - 'trace', - 'copy', - 'lock', - 'mkcol', - 'move', - 'purge', - 'propfind', - 'proppatch', - 'unlock', - 'report', - 'mkactivity', - 'checkout', - 'merge', - 'm-search', - 'notify', - 'subscribe', - 'unsubscribe', - 'patch', - 'search', - 'connect' - ]; -} +/*! + * methods + * Copyright(c) 2013-2014 TJ Holowaychuk + * Copyright(c) 2015-2016 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict'; + +/** + * Module dependencies. + * @private + */ + +var http = require('http'); + +/** + * Module exports. + * @public + */ + +module.exports = getCurrentNodeMethods() || getBasicNodeMethods(); + +/** + * Get the current Node.js methods. + * @private + */ + +function getCurrentNodeMethods() { + return http.METHODS && http.METHODS.map(function lowerCaseMethod(method) { + return method.toLowerCase(); + }); +} + +/** + * Get the "basic" Node.js methods, a snapshot from Node.js 0.10. + * @private + */ + +function getBasicNodeMethods() { + return [ + 'get', + 'post', + 'put', + 'head', + 'delete', + 'options', + 'trace', + 'copy', + 'lock', + 'mkcol', + 'move', + 'purge', + 'propfind', + 'proppatch', + 'unlock', + 'report', + 'mkactivity', + 'checkout', + 'merge', + 'm-search', + 'notify', + 'subscribe', + 'unsubscribe', + 'patch', + 'search', + 'connect' + ]; +} diff --git a/ui/node_modules/express/node_modules/methods/package.json b/ui/node_modules/express/node_modules/methods/package.json index 2aeab146..09ed8878 100644 --- a/ui/node_modules/express/node_modules/methods/package.json +++ b/ui/node_modules/express/node_modules/methods/package.json @@ -1,88 +1,88 @@ -{ - "name": "methods", - "description": "HTTP methods that node supports", - "version": "1.1.2", - "contributors": [ - { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "Jonathan Ong", - "email": "me@jongleberry.com", - "url": "http://jongleberry.com" - }, - { - "name": "TJ Holowaychuk", - "email": "tj@vision-media.ca", - "url": "http://tjholowaychuk.com" - } - ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/methods.git" - }, - "devDependencies": { - "istanbul": "0.4.1", - "mocha": "1.21.5" - }, - "files": [ - "index.js", - "HISTORY.md", - "LICENSE" - ], - "engines": { - "node": ">= 0.6" - }, - "scripts": { - "test": "mocha --reporter spec --bail --check-leaks test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" - }, - "browser": { - "http": false - }, - "keywords": [ - "http", - "methods" - ], - "gitHead": "25d257d913f1b94bd2d73581521ff72c81469140", - "bugs": { - "url": "https://github.com/jshttp/methods/issues" - }, - "homepage": "https://github.com/jshttp/methods", - "_id": "methods@1.1.2", - "_shasum": "5529a4d67654134edcc5266656835b0f851afcee", - "_from": "methods@>=1.1.2 <1.2.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - { - "name": "jonathanong", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "5529a4d67654134edcc5266656835b0f851afcee", - "tarball": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "methods", + "description": "HTTP methods that node supports", + "version": "1.1.2", + "contributors": [ + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "Jonathan Ong", + "email": "me@jongleberry.com", + "url": "http://jongleberry.com" + }, + { + "name": "TJ Holowaychuk", + "email": "tj@vision-media.ca", + "url": "http://tjholowaychuk.com" + } + ], + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/methods.git" + }, + "devDependencies": { + "istanbul": "0.4.1", + "mocha": "1.21.5" + }, + "files": [ + "index.js", + "HISTORY.md", + "LICENSE" + ], + "engines": { + "node": ">= 0.6" + }, + "scripts": { + "test": "mocha --reporter spec --bail --check-leaks test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" + }, + "browser": { + "http": false + }, + "keywords": [ + "http", + "methods" + ], + "gitHead": "25d257d913f1b94bd2d73581521ff72c81469140", + "bugs": { + "url": "https://github.com/jshttp/methods/issues" + }, + "homepage": "https://github.com/jshttp/methods", + "_id": "methods@1.1.2", + "_shasum": "5529a4d67654134edcc5266656835b0f851afcee", + "_from": "methods@>=1.1.2 <1.2.0", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "maintainers": [ + { + "name": "tjholowaychuk", + "email": "tj@vision-media.ca" + }, + { + "name": "jonathanong", + "email": "jonathanrichardong@gmail.com" + }, + { + "name": "jongleberry", + "email": "jonathanrichardong@gmail.com" + }, + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + } + ], + "dist": { + "shasum": "5529a4d67654134edcc5266656835b0f851afcee", + "tarball": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/on-finished/HISTORY.md b/ui/node_modules/express/node_modules/on-finished/HISTORY.md index 59fb0347..98ff0e99 100644 --- a/ui/node_modules/express/node_modules/on-finished/HISTORY.md +++ b/ui/node_modules/express/node_modules/on-finished/HISTORY.md @@ -1,88 +1,88 @@ -2.3.0 / 2015-05-26 -================== - - * Add defined behavior for HTTP `CONNECT` requests - * Add defined behavior for HTTP `Upgrade` requests - * deps: ee-first@1.1.1 - -2.2.1 / 2015-04-22 -================== - - * Fix `isFinished(req)` when data buffered - -2.2.0 / 2014-12-22 -================== - - * Add message object to callback arguments - -2.1.1 / 2014-10-22 -================== - - * Fix handling of pipelined requests - -2.1.0 / 2014-08-16 -================== - - * Check if `socket` is detached - * Return `undefined` for `isFinished` if state unknown - -2.0.0 / 2014-08-16 -================== - - * Add `isFinished` function - * Move to `jshttp` organization - * Remove support for plain socket argument - * Rename to `on-finished` - * Support both `req` and `res` as arguments - * deps: ee-first@1.0.5 - -1.2.2 / 2014-06-10 -================== - - * Reduce listeners added to emitters - - avoids "event emitter leak" warnings when used multiple times on same request - -1.2.1 / 2014-06-08 -================== - - * Fix returned value when already finished - -1.2.0 / 2014-06-05 -================== - - * Call callback when called on already-finished socket - -1.1.4 / 2014-05-27 -================== - - * Support node.js 0.8 - -1.1.3 / 2014-04-30 -================== - - * Make sure errors passed as instanceof `Error` - -1.1.2 / 2014-04-18 -================== - - * Default the `socket` to passed-in object - -1.1.1 / 2014-01-16 -================== - - * Rename module to `finished` - -1.1.0 / 2013-12-25 -================== - - * Call callback when called on already-errored socket - -1.0.1 / 2013-12-20 -================== - - * Actually pass the error to the callback - -1.0.0 / 2013-12-20 -================== - - * Initial release +2.3.0 / 2015-05-26 +================== + + * Add defined behavior for HTTP `CONNECT` requests + * Add defined behavior for HTTP `Upgrade` requests + * deps: ee-first@1.1.1 + +2.2.1 / 2015-04-22 +================== + + * Fix `isFinished(req)` when data buffered + +2.2.0 / 2014-12-22 +================== + + * Add message object to callback arguments + +2.1.1 / 2014-10-22 +================== + + * Fix handling of pipelined requests + +2.1.0 / 2014-08-16 +================== + + * Check if `socket` is detached + * Return `undefined` for `isFinished` if state unknown + +2.0.0 / 2014-08-16 +================== + + * Add `isFinished` function + * Move to `jshttp` organization + * Remove support for plain socket argument + * Rename to `on-finished` + * Support both `req` and `res` as arguments + * deps: ee-first@1.0.5 + +1.2.2 / 2014-06-10 +================== + + * Reduce listeners added to emitters + - avoids "event emitter leak" warnings when used multiple times on same request + +1.2.1 / 2014-06-08 +================== + + * Fix returned value when already finished + +1.2.0 / 2014-06-05 +================== + + * Call callback when called on already-finished socket + +1.1.4 / 2014-05-27 +================== + + * Support node.js 0.8 + +1.1.3 / 2014-04-30 +================== + + * Make sure errors passed as instanceof `Error` + +1.1.2 / 2014-04-18 +================== + + * Default the `socket` to passed-in object + +1.1.1 / 2014-01-16 +================== + + * Rename module to `finished` + +1.1.0 / 2013-12-25 +================== + + * Call callback when called on already-errored socket + +1.0.1 / 2013-12-20 +================== + + * Actually pass the error to the callback + +1.0.0 / 2013-12-20 +================== + + * Initial release diff --git a/ui/node_modules/express/node_modules/on-finished/LICENSE b/ui/node_modules/express/node_modules/on-finished/LICENSE index a7c945ba..5931fd23 100644 --- a/ui/node_modules/express/node_modules/on-finished/LICENSE +++ b/ui/node_modules/express/node_modules/on-finished/LICENSE @@ -1,23 +1,23 @@ -(The MIT License) - -Copyright (c) 2013 Jonathan Ong -Copyright (c) 2014 Douglas Christopher Wilson - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2013 Jonathan Ong +Copyright (c) 2014 Douglas Christopher Wilson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/on-finished/README.md b/ui/node_modules/express/node_modules/on-finished/README.md index 4e3c9626..a0e11574 100644 --- a/ui/node_modules/express/node_modules/on-finished/README.md +++ b/ui/node_modules/express/node_modules/on-finished/README.md @@ -1,154 +1,154 @@ -# on-finished - -[![NPM Version][npm-image]][npm-url] -[![NPM Downloads][downloads-image]][downloads-url] -[![Node.js Version][node-version-image]][node-version-url] -[![Build Status][travis-image]][travis-url] -[![Test Coverage][coveralls-image]][coveralls-url] - -Execute a callback when a HTTP request closes, finishes, or errors. - -## Install - -```sh -$ npm install on-finished -``` - -## API - -```js -var onFinished = require('on-finished') -``` - -### onFinished(res, listener) - -Attach a listener to listen for the response to finish. The listener will -be invoked only once when the response finished. If the response finished -to an error, the first argument will contain the error. If the response -has already finished, the listener will be invoked. - -Listening to the end of a response would be used to close things associated -with the response, like open files. - -Listener is invoked as `listener(err, res)`. - -```js -onFinished(res, function (err, res) { - // clean up open fds, etc. - // err contains the error is request error'd -}) -``` - -### onFinished(req, listener) - -Attach a listener to listen for the request to finish. The listener will -be invoked only once when the request finished. If the request finished -to an error, the first argument will contain the error. If the request -has already finished, the listener will be invoked. - -Listening to the end of a request would be used to know when to continue -after reading the data. - -Listener is invoked as `listener(err, req)`. - -```js -var data = '' - -req.setEncoding('utf8') -res.on('data', function (str) { - data += str -}) - -onFinished(req, function (err, req) { - // data is read unless there is err -}) -``` - -### onFinished.isFinished(res) - -Determine if `res` is already finished. This would be useful to check and -not even start certain operations if the response has already finished. - -### onFinished.isFinished(req) - -Determine if `req` is already finished. This would be useful to check and -not even start certain operations if the request has already finished. - -## Special Node.js requests - -### HTTP CONNECT method - -The meaning of the `CONNECT` method from RFC 7231, section 4.3.6: - -> The CONNECT method requests that the recipient establish a tunnel to -> the destination origin server identified by the request-target and, -> if successful, thereafter restrict its behavior to blind forwarding -> of packets, in both directions, until the tunnel is closed. Tunnels -> are commonly used to create an end-to-end virtual connection, through -> one or more proxies, which can then be secured using TLS (Transport -> Layer Security, [RFC5246]). - -In Node.js, these request objects come from the `'connect'` event on -the HTTP server. - -When this module is used on a HTTP `CONNECT` request, the request is -considered "finished" immediately, **due to limitations in the Node.js -interface**. This means if the `CONNECT` request contains a request entity, -the request will be considered "finished" even before it has been read. - -There is no such thing as a response object to a `CONNECT` request in -Node.js, so there is no support for for one. - -### HTTP Upgrade request - -The meaning of the `Upgrade` header from RFC 7230, section 6.1: - -> The "Upgrade" header field is intended to provide a simple mechanism -> for transitioning from HTTP/1.1 to some other protocol on the same -> connection. - -In Node.js, these request objects come from the `'upgrade'` event on -the HTTP server. - -When this module is used on a HTTP request with an `Upgrade` header, the -request is considered "finished" immediately, **due to limitations in the -Node.js interface**. This means if the `Upgrade` request contains a request -entity, the request will be considered "finished" even before it has been -read. - -There is no such thing as a response object to a `Upgrade` request in -Node.js, so there is no support for for one. - -## Example - -The following code ensures that file descriptors are always closed -once the response finishes. - -```js -var destroy = require('destroy') -var http = require('http') -var onFinished = require('on-finished') - -http.createServer(function onRequest(req, res) { - var stream = fs.createReadStream('package.json') - stream.pipe(res) - onFinished(res, function (err) { - destroy(stream) - }) -}) -``` - -## License - -[MIT](LICENSE) - -[npm-image]: https://img.shields.io/npm/v/on-finished.svg -[npm-url]: https://npmjs.org/package/on-finished -[node-version-image]: https://img.shields.io/node/v/on-finished.svg -[node-version-url]: http://nodejs.org/download/ -[travis-image]: https://img.shields.io/travis/jshttp/on-finished/master.svg -[travis-url]: https://travis-ci.org/jshttp/on-finished -[coveralls-image]: https://img.shields.io/coveralls/jshttp/on-finished/master.svg -[coveralls-url]: https://coveralls.io/r/jshttp/on-finished?branch=master -[downloads-image]: https://img.shields.io/npm/dm/on-finished.svg -[downloads-url]: https://npmjs.org/package/on-finished +# on-finished + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-version-image]][node-version-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +Execute a callback when a HTTP request closes, finishes, or errors. + +## Install + +```sh +$ npm install on-finished +``` + +## API + +```js +var onFinished = require('on-finished') +``` + +### onFinished(res, listener) + +Attach a listener to listen for the response to finish. The listener will +be invoked only once when the response finished. If the response finished +to an error, the first argument will contain the error. If the response +has already finished, the listener will be invoked. + +Listening to the end of a response would be used to close things associated +with the response, like open files. + +Listener is invoked as `listener(err, res)`. + +```js +onFinished(res, function (err, res) { + // clean up open fds, etc. + // err contains the error is request error'd +}) +``` + +### onFinished(req, listener) + +Attach a listener to listen for the request to finish. The listener will +be invoked only once when the request finished. If the request finished +to an error, the first argument will contain the error. If the request +has already finished, the listener will be invoked. + +Listening to the end of a request would be used to know when to continue +after reading the data. + +Listener is invoked as `listener(err, req)`. + +```js +var data = '' + +req.setEncoding('utf8') +res.on('data', function (str) { + data += str +}) + +onFinished(req, function (err, req) { + // data is read unless there is err +}) +``` + +### onFinished.isFinished(res) + +Determine if `res` is already finished. This would be useful to check and +not even start certain operations if the response has already finished. + +### onFinished.isFinished(req) + +Determine if `req` is already finished. This would be useful to check and +not even start certain operations if the request has already finished. + +## Special Node.js requests + +### HTTP CONNECT method + +The meaning of the `CONNECT` method from RFC 7231, section 4.3.6: + +> The CONNECT method requests that the recipient establish a tunnel to +> the destination origin server identified by the request-target and, +> if successful, thereafter restrict its behavior to blind forwarding +> of packets, in both directions, until the tunnel is closed. Tunnels +> are commonly used to create an end-to-end virtual connection, through +> one or more proxies, which can then be secured using TLS (Transport +> Layer Security, [RFC5246]). + +In Node.js, these request objects come from the `'connect'` event on +the HTTP server. + +When this module is used on a HTTP `CONNECT` request, the request is +considered "finished" immediately, **due to limitations in the Node.js +interface**. This means if the `CONNECT` request contains a request entity, +the request will be considered "finished" even before it has been read. + +There is no such thing as a response object to a `CONNECT` request in +Node.js, so there is no support for for one. + +### HTTP Upgrade request + +The meaning of the `Upgrade` header from RFC 7230, section 6.1: + +> The "Upgrade" header field is intended to provide a simple mechanism +> for transitioning from HTTP/1.1 to some other protocol on the same +> connection. + +In Node.js, these request objects come from the `'upgrade'` event on +the HTTP server. + +When this module is used on a HTTP request with an `Upgrade` header, the +request is considered "finished" immediately, **due to limitations in the +Node.js interface**. This means if the `Upgrade` request contains a request +entity, the request will be considered "finished" even before it has been +read. + +There is no such thing as a response object to a `Upgrade` request in +Node.js, so there is no support for for one. + +## Example + +The following code ensures that file descriptors are always closed +once the response finishes. + +```js +var destroy = require('destroy') +var http = require('http') +var onFinished = require('on-finished') + +http.createServer(function onRequest(req, res) { + var stream = fs.createReadStream('package.json') + stream.pipe(res) + onFinished(res, function (err) { + destroy(stream) + }) +}) +``` + +## License + +[MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/on-finished.svg +[npm-url]: https://npmjs.org/package/on-finished +[node-version-image]: https://img.shields.io/node/v/on-finished.svg +[node-version-url]: http://nodejs.org/download/ +[travis-image]: https://img.shields.io/travis/jshttp/on-finished/master.svg +[travis-url]: https://travis-ci.org/jshttp/on-finished +[coveralls-image]: https://img.shields.io/coveralls/jshttp/on-finished/master.svg +[coveralls-url]: https://coveralls.io/r/jshttp/on-finished?branch=master +[downloads-image]: https://img.shields.io/npm/dm/on-finished.svg +[downloads-url]: https://npmjs.org/package/on-finished diff --git a/ui/node_modules/express/node_modules/on-finished/index.js b/ui/node_modules/express/node_modules/on-finished/index.js index f652aaef..9abd98f9 100644 --- a/ui/node_modules/express/node_modules/on-finished/index.js +++ b/ui/node_modules/express/node_modules/on-finished/index.js @@ -1,196 +1,196 @@ -/*! - * on-finished - * Copyright(c) 2013 Jonathan Ong - * Copyright(c) 2014 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict' - -/** - * Module exports. - * @public - */ - -module.exports = onFinished -module.exports.isFinished = isFinished - -/** - * Module dependencies. - * @private - */ - -var first = require('ee-first') - -/** - * Variables. - * @private - */ - -/* istanbul ignore next */ -var defer = typeof setImmediate === 'function' - ? setImmediate - : function(fn){ process.nextTick(fn.bind.apply(fn, arguments)) } - -/** - * Invoke callback when the response has finished, useful for - * cleaning up resources afterwards. - * - * @param {object} msg - * @param {function} listener - * @return {object} - * @public - */ - -function onFinished(msg, listener) { - if (isFinished(msg) !== false) { - defer(listener, null, msg) - return msg - } - - // attach the listener to the message - attachListener(msg, listener) - - return msg -} - -/** - * Determine if message is already finished. - * - * @param {object} msg - * @return {boolean} - * @public - */ - -function isFinished(msg) { - var socket = msg.socket - - if (typeof msg.finished === 'boolean') { - // OutgoingMessage - return Boolean(msg.finished || (socket && !socket.writable)) - } - - if (typeof msg.complete === 'boolean') { - // IncomingMessage - return Boolean(msg.upgrade || !socket || !socket.readable || (msg.complete && !msg.readable)) - } - - // don't know - return undefined -} - -/** - * Attach a finished listener to the message. - * - * @param {object} msg - * @param {function} callback - * @private - */ - -function attachFinishedListener(msg, callback) { - var eeMsg - var eeSocket - var finished = false - - function onFinish(error) { - eeMsg.cancel() - eeSocket.cancel() - - finished = true - callback(error) - } - - // finished on first message event - eeMsg = eeSocket = first([[msg, 'end', 'finish']], onFinish) - - function onSocket(socket) { - // remove listener - msg.removeListener('socket', onSocket) - - if (finished) return - if (eeMsg !== eeSocket) return - - // finished on first socket event - eeSocket = first([[socket, 'error', 'close']], onFinish) - } - - if (msg.socket) { - // socket already assigned - onSocket(msg.socket) - return - } - - // wait for socket to be assigned - msg.on('socket', onSocket) - - if (msg.socket === undefined) { - // node.js 0.8 patch - patchAssignSocket(msg, onSocket) - } -} - -/** - * Attach the listener to the message. - * - * @param {object} msg - * @return {function} - * @private - */ - -function attachListener(msg, listener) { - var attached = msg.__onFinished - - // create a private single listener with queue - if (!attached || !attached.queue) { - attached = msg.__onFinished = createListener(msg) - attachFinishedListener(msg, attached) - } - - attached.queue.push(listener) -} - -/** - * Create listener on message. - * - * @param {object} msg - * @return {function} - * @private - */ - -function createListener(msg) { - function listener(err) { - if (msg.__onFinished === listener) msg.__onFinished = null - if (!listener.queue) return - - var queue = listener.queue - listener.queue = null - - for (var i = 0; i < queue.length; i++) { - queue[i](err, msg) - } - } - - listener.queue = [] - - return listener -} - -/** - * Patch ServerResponse.prototype.assignSocket for node.js 0.8. - * - * @param {ServerResponse} res - * @param {function} callback - * @private - */ - -function patchAssignSocket(res, callback) { - var assignSocket = res.assignSocket - - if (typeof assignSocket !== 'function') return - - // res.on('socket', callback) is broken in 0.8 - res.assignSocket = function _assignSocket(socket) { - assignSocket.call(this, socket) - callback(socket) - } -} +/*! + * on-finished + * Copyright(c) 2013 Jonathan Ong + * Copyright(c) 2014 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module exports. + * @public + */ + +module.exports = onFinished +module.exports.isFinished = isFinished + +/** + * Module dependencies. + * @private + */ + +var first = require('ee-first') + +/** + * Variables. + * @private + */ + +/* istanbul ignore next */ +var defer = typeof setImmediate === 'function' + ? setImmediate + : function(fn){ process.nextTick(fn.bind.apply(fn, arguments)) } + +/** + * Invoke callback when the response has finished, useful for + * cleaning up resources afterwards. + * + * @param {object} msg + * @param {function} listener + * @return {object} + * @public + */ + +function onFinished(msg, listener) { + if (isFinished(msg) !== false) { + defer(listener, null, msg) + return msg + } + + // attach the listener to the message + attachListener(msg, listener) + + return msg +} + +/** + * Determine if message is already finished. + * + * @param {object} msg + * @return {boolean} + * @public + */ + +function isFinished(msg) { + var socket = msg.socket + + if (typeof msg.finished === 'boolean') { + // OutgoingMessage + return Boolean(msg.finished || (socket && !socket.writable)) + } + + if (typeof msg.complete === 'boolean') { + // IncomingMessage + return Boolean(msg.upgrade || !socket || !socket.readable || (msg.complete && !msg.readable)) + } + + // don't know + return undefined +} + +/** + * Attach a finished listener to the message. + * + * @param {object} msg + * @param {function} callback + * @private + */ + +function attachFinishedListener(msg, callback) { + var eeMsg + var eeSocket + var finished = false + + function onFinish(error) { + eeMsg.cancel() + eeSocket.cancel() + + finished = true + callback(error) + } + + // finished on first message event + eeMsg = eeSocket = first([[msg, 'end', 'finish']], onFinish) + + function onSocket(socket) { + // remove listener + msg.removeListener('socket', onSocket) + + if (finished) return + if (eeMsg !== eeSocket) return + + // finished on first socket event + eeSocket = first([[socket, 'error', 'close']], onFinish) + } + + if (msg.socket) { + // socket already assigned + onSocket(msg.socket) + return + } + + // wait for socket to be assigned + msg.on('socket', onSocket) + + if (msg.socket === undefined) { + // node.js 0.8 patch + patchAssignSocket(msg, onSocket) + } +} + +/** + * Attach the listener to the message. + * + * @param {object} msg + * @return {function} + * @private + */ + +function attachListener(msg, listener) { + var attached = msg.__onFinished + + // create a private single listener with queue + if (!attached || !attached.queue) { + attached = msg.__onFinished = createListener(msg) + attachFinishedListener(msg, attached) + } + + attached.queue.push(listener) +} + +/** + * Create listener on message. + * + * @param {object} msg + * @return {function} + * @private + */ + +function createListener(msg) { + function listener(err) { + if (msg.__onFinished === listener) msg.__onFinished = null + if (!listener.queue) return + + var queue = listener.queue + listener.queue = null + + for (var i = 0; i < queue.length; i++) { + queue[i](err, msg) + } + } + + listener.queue = [] + + return listener +} + +/** + * Patch ServerResponse.prototype.assignSocket for node.js 0.8. + * + * @param {ServerResponse} res + * @param {function} callback + * @private + */ + +function patchAssignSocket(res, callback) { + var assignSocket = res.assignSocket + + if (typeof assignSocket !== 'function') return + + // res.on('socket', callback) is broken in 0.8 + res.assignSocket = function _assignSocket(socket) { + assignSocket.call(this, socket) + callback(socket) + } +} diff --git a/ui/node_modules/express/node_modules/on-finished/node_modules/ee-first/LICENSE b/ui/node_modules/express/node_modules/on-finished/node_modules/ee-first/LICENSE index c1b15a1d..a7ae8ee9 100644 --- a/ui/node_modules/express/node_modules/on-finished/node_modules/ee-first/LICENSE +++ b/ui/node_modules/express/node_modules/on-finished/node_modules/ee-first/LICENSE @@ -1,22 +1,22 @@ - -The MIT License (MIT) - -Copyright (c) 2014 Jonathan Ong me@jongleberry.com - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. + +The MIT License (MIT) + +Copyright (c) 2014 Jonathan Ong me@jongleberry.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/on-finished/node_modules/ee-first/README.md b/ui/node_modules/express/node_modules/on-finished/node_modules/ee-first/README.md index bb16aabe..cbd2478b 100644 --- a/ui/node_modules/express/node_modules/on-finished/node_modules/ee-first/README.md +++ b/ui/node_modules/express/node_modules/on-finished/node_modules/ee-first/README.md @@ -1,80 +1,80 @@ -# EE First - -[![NPM version][npm-image]][npm-url] -[![Build status][travis-image]][travis-url] -[![Test coverage][coveralls-image]][coveralls-url] -[![License][license-image]][license-url] -[![Downloads][downloads-image]][downloads-url] -[![Gittip][gittip-image]][gittip-url] - -Get the first event in a set of event emitters and event pairs, -then clean up after itself. - -## Install - -```sh -$ npm install ee-first -``` - -## API - -```js -var first = require('ee-first') -``` - -### first(arr, listener) - -Invoke `listener` on the first event from the list specified in `arr`. `arr` is -an array of arrays, with each array in the format `[ee, ...event]`. `listener` -will be called only once, the first time any of the given events are emitted. If -`error` is one of the listened events, then if that fires first, the `listener` -will be given the `err` argument. - -The `listener` is invoked as `listener(err, ee, event, args)`, where `err` is the -first argument emitted from an `error` event, if applicable; `ee` is the event -emitter that fired; `event` is the string event name that fired; and `args` is an -array of the arguments that were emitted on the event. - -```js -var ee1 = new EventEmitter() -var ee2 = new EventEmitter() - -first([ - [ee1, 'close', 'end', 'error'], - [ee2, 'error'] -], function (err, ee, event, args) { - // listener invoked -}) -``` - -#### .cancel() - -The group of listeners can be cancelled before being invoked and have all the event -listeners removed from the underlying event emitters. - -```js -var thunk = first([ - [ee1, 'close', 'end', 'error'], - [ee2, 'error'] -], function (err, ee, event, args) { - // listener invoked -}) - -// cancel and clean up -thunk.cancel() -``` - -[npm-image]: https://img.shields.io/npm/v/ee-first.svg?style=flat-square -[npm-url]: https://npmjs.org/package/ee-first -[github-tag]: http://img.shields.io/github/tag/jonathanong/ee-first.svg?style=flat-square -[github-url]: https://github.com/jonathanong/ee-first/tags -[travis-image]: https://img.shields.io/travis/jonathanong/ee-first.svg?style=flat-square -[travis-url]: https://travis-ci.org/jonathanong/ee-first -[coveralls-image]: https://img.shields.io/coveralls/jonathanong/ee-first.svg?style=flat-square -[coveralls-url]: https://coveralls.io/r/jonathanong/ee-first?branch=master -[license-image]: http://img.shields.io/npm/l/ee-first.svg?style=flat-square -[license-url]: LICENSE.md -[downloads-image]: http://img.shields.io/npm/dm/ee-first.svg?style=flat-square -[downloads-url]: https://npmjs.org/package/ee-first -[gittip-image]: https://img.shields.io/gittip/jonathanong.svg?style=flat-square -[gittip-url]: https://www.gittip.com/jonathanong/ +# EE First + +[![NPM version][npm-image]][npm-url] +[![Build status][travis-image]][travis-url] +[![Test coverage][coveralls-image]][coveralls-url] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] +[![Gittip][gittip-image]][gittip-url] + +Get the first event in a set of event emitters and event pairs, +then clean up after itself. + +## Install + +```sh +$ npm install ee-first +``` + +## API + +```js +var first = require('ee-first') +``` + +### first(arr, listener) + +Invoke `listener` on the first event from the list specified in `arr`. `arr` is +an array of arrays, with each array in the format `[ee, ...event]`. `listener` +will be called only once, the first time any of the given events are emitted. If +`error` is one of the listened events, then if that fires first, the `listener` +will be given the `err` argument. + +The `listener` is invoked as `listener(err, ee, event, args)`, where `err` is the +first argument emitted from an `error` event, if applicable; `ee` is the event +emitter that fired; `event` is the string event name that fired; and `args` is an +array of the arguments that were emitted on the event. + +```js +var ee1 = new EventEmitter() +var ee2 = new EventEmitter() + +first([ + [ee1, 'close', 'end', 'error'], + [ee2, 'error'] +], function (err, ee, event, args) { + // listener invoked +}) +``` + +#### .cancel() + +The group of listeners can be cancelled before being invoked and have all the event +listeners removed from the underlying event emitters. + +```js +var thunk = first([ + [ee1, 'close', 'end', 'error'], + [ee2, 'error'] +], function (err, ee, event, args) { + // listener invoked +}) + +// cancel and clean up +thunk.cancel() +``` + +[npm-image]: https://img.shields.io/npm/v/ee-first.svg?style=flat-square +[npm-url]: https://npmjs.org/package/ee-first +[github-tag]: http://img.shields.io/github/tag/jonathanong/ee-first.svg?style=flat-square +[github-url]: https://github.com/jonathanong/ee-first/tags +[travis-image]: https://img.shields.io/travis/jonathanong/ee-first.svg?style=flat-square +[travis-url]: https://travis-ci.org/jonathanong/ee-first +[coveralls-image]: https://img.shields.io/coveralls/jonathanong/ee-first.svg?style=flat-square +[coveralls-url]: https://coveralls.io/r/jonathanong/ee-first?branch=master +[license-image]: http://img.shields.io/npm/l/ee-first.svg?style=flat-square +[license-url]: LICENSE.md +[downloads-image]: http://img.shields.io/npm/dm/ee-first.svg?style=flat-square +[downloads-url]: https://npmjs.org/package/ee-first +[gittip-image]: https://img.shields.io/gittip/jonathanong.svg?style=flat-square +[gittip-url]: https://www.gittip.com/jonathanong/ diff --git a/ui/node_modules/express/node_modules/on-finished/node_modules/ee-first/index.js b/ui/node_modules/express/node_modules/on-finished/node_modules/ee-first/index.js index 43e50390..501287cd 100644 --- a/ui/node_modules/express/node_modules/on-finished/node_modules/ee-first/index.js +++ b/ui/node_modules/express/node_modules/on-finished/node_modules/ee-first/index.js @@ -1,95 +1,95 @@ -/*! - * ee-first - * Copyright(c) 2014 Jonathan Ong - * MIT Licensed - */ - -'use strict' - -/** - * Module exports. - * @public - */ - -module.exports = first - -/** - * Get the first event in a set of event emitters and event pairs. - * - * @param {array} stuff - * @param {function} done - * @public - */ - -function first(stuff, done) { - if (!Array.isArray(stuff)) - throw new TypeError('arg must be an array of [ee, events...] arrays') - - var cleanups = [] - - for (var i = 0; i < stuff.length; i++) { - var arr = stuff[i] - - if (!Array.isArray(arr) || arr.length < 2) - throw new TypeError('each array member must be [ee, events...]') - - var ee = arr[0] - - for (var j = 1; j < arr.length; j++) { - var event = arr[j] - var fn = listener(event, callback) - - // listen to the event - ee.on(event, fn) - // push this listener to the list of cleanups - cleanups.push({ - ee: ee, - event: event, - fn: fn, - }) - } - } - - function callback() { - cleanup() - done.apply(null, arguments) - } - - function cleanup() { - var x - for (var i = 0; i < cleanups.length; i++) { - x = cleanups[i] - x.ee.removeListener(x.event, x.fn) - } - } - - function thunk(fn) { - done = fn - } - - thunk.cancel = cleanup - - return thunk -} - -/** - * Create the event listener. - * @private - */ - -function listener(event, done) { - return function onevent(arg1) { - var args = new Array(arguments.length) - var ee = this - var err = event === 'error' - ? arg1 - : null - - // copy args to prevent arguments escaping scope - for (var i = 0; i < args.length; i++) { - args[i] = arguments[i] - } - - done(err, ee, event, args) - } -} +/*! + * ee-first + * Copyright(c) 2014 Jonathan Ong + * MIT Licensed + */ + +'use strict' + +/** + * Module exports. + * @public + */ + +module.exports = first + +/** + * Get the first event in a set of event emitters and event pairs. + * + * @param {array} stuff + * @param {function} done + * @public + */ + +function first(stuff, done) { + if (!Array.isArray(stuff)) + throw new TypeError('arg must be an array of [ee, events...] arrays') + + var cleanups = [] + + for (var i = 0; i < stuff.length; i++) { + var arr = stuff[i] + + if (!Array.isArray(arr) || arr.length < 2) + throw new TypeError('each array member must be [ee, events...]') + + var ee = arr[0] + + for (var j = 1; j < arr.length; j++) { + var event = arr[j] + var fn = listener(event, callback) + + // listen to the event + ee.on(event, fn) + // push this listener to the list of cleanups + cleanups.push({ + ee: ee, + event: event, + fn: fn, + }) + } + } + + function callback() { + cleanup() + done.apply(null, arguments) + } + + function cleanup() { + var x + for (var i = 0; i < cleanups.length; i++) { + x = cleanups[i] + x.ee.removeListener(x.event, x.fn) + } + } + + function thunk(fn) { + done = fn + } + + thunk.cancel = cleanup + + return thunk +} + +/** + * Create the event listener. + * @private + */ + +function listener(event, done) { + return function onevent(arg1) { + var args = new Array(arguments.length) + var ee = this + var err = event === 'error' + ? arg1 + : null + + // copy args to prevent arguments escaping scope + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i] + } + + done(err, ee, event, args) + } +} diff --git a/ui/node_modules/express/node_modules/on-finished/node_modules/ee-first/package.json b/ui/node_modules/express/node_modules/on-finished/node_modules/ee-first/package.json index 868a32b1..c67faf17 100644 --- a/ui/node_modules/express/node_modules/on-finished/node_modules/ee-first/package.json +++ b/ui/node_modules/express/node_modules/on-finished/node_modules/ee-first/package.json @@ -1,64 +1,64 @@ -{ - "name": "ee-first", - "description": "return the first event in a set of ee/event pairs", - "version": "1.1.1", - "author": { - "name": "Jonathan Ong", - "email": "me@jongleberry.com", - "url": "http://jongleberry.com" - }, - "contributors": [ - { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - } - ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/jonathanong/ee-first.git" - }, - "devDependencies": { - "istanbul": "0.3.9", - "mocha": "2.2.5" - }, - "files": [ - "index.js", - "LICENSE" - ], - "scripts": { - "test": "mocha --reporter spec --bail --check-leaks test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" - }, - "gitHead": "512e0ce4cc3643f603708f965a97b61b1a9c0441", - "bugs": { - "url": "https://github.com/jonathanong/ee-first/issues" - }, - "homepage": "https://github.com/jonathanong/ee-first", - "_id": "ee-first@1.1.1", - "_shasum": "590c61156b0ae2f4f0255732a158b266bc56b21d", - "_from": "ee-first@1.1.1", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "590c61156b0ae2f4f0255732a158b266bc56b21d", - "tarball": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "ee-first", + "description": "return the first event in a set of ee/event pairs", + "version": "1.1.1", + "author": { + "name": "Jonathan Ong", + "email": "me@jongleberry.com", + "url": "http://jongleberry.com" + }, + "contributors": [ + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + } + ], + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/jonathanong/ee-first.git" + }, + "devDependencies": { + "istanbul": "0.3.9", + "mocha": "2.2.5" + }, + "files": [ + "index.js", + "LICENSE" + ], + "scripts": { + "test": "mocha --reporter spec --bail --check-leaks test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" + }, + "gitHead": "512e0ce4cc3643f603708f965a97b61b1a9c0441", + "bugs": { + "url": "https://github.com/jonathanong/ee-first/issues" + }, + "homepage": "https://github.com/jonathanong/ee-first", + "_id": "ee-first@1.1.1", + "_shasum": "590c61156b0ae2f4f0255732a158b266bc56b21d", + "_from": "ee-first@1.1.1", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "maintainers": [ + { + "name": "jongleberry", + "email": "jonathanrichardong@gmail.com" + }, + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + } + ], + "dist": { + "shasum": "590c61156b0ae2f4f0255732a158b266bc56b21d", + "tarball": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/on-finished/package.json b/ui/node_modules/express/node_modules/on-finished/package.json index 50c8917b..97a5680b 100644 --- a/ui/node_modules/express/node_modules/on-finished/package.json +++ b/ui/node_modules/express/node_modules/on-finished/package.json @@ -1,71 +1,71 @@ -{ - "name": "on-finished", - "description": "Execute a callback when a request closes, finishes, or errors", - "version": "2.3.0", - "contributors": [ - { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "Jonathan Ong", - "email": "me@jongleberry.com", - "url": "http://jongleberry.com" - } - ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/on-finished.git" - }, - "dependencies": { - "ee-first": "1.1.1" - }, - "devDependencies": { - "istanbul": "0.3.9", - "mocha": "2.2.5" - }, - "engines": { - "node": ">= 0.8" - }, - "files": [ - "HISTORY.md", - "LICENSE", - "index.js" - ], - "scripts": { - "test": "mocha --reporter spec --bail --check-leaks test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" - }, - "gitHead": "34babcb58126a416fcf5205768204f2e12699dda", - "bugs": { - "url": "https://github.com/jshttp/on-finished/issues" - }, - "homepage": "https://github.com/jshttp/on-finished", - "_id": "on-finished@2.3.0", - "_shasum": "20f1336481b083cd75337992a16971aa2d906947", - "_from": "on-finished@>=2.3.0 <2.4.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - } - ], - "dist": { - "shasum": "20f1336481b083cd75337992a16971aa2d906947", - "tarball": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "on-finished", + "description": "Execute a callback when a request closes, finishes, or errors", + "version": "2.3.0", + "contributors": [ + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "Jonathan Ong", + "email": "me@jongleberry.com", + "url": "http://jongleberry.com" + } + ], + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/on-finished.git" + }, + "dependencies": { + "ee-first": "1.1.1" + }, + "devDependencies": { + "istanbul": "0.3.9", + "mocha": "2.2.5" + }, + "engines": { + "node": ">= 0.8" + }, + "files": [ + "HISTORY.md", + "LICENSE", + "index.js" + ], + "scripts": { + "test": "mocha --reporter spec --bail --check-leaks test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" + }, + "gitHead": "34babcb58126a416fcf5205768204f2e12699dda", + "bugs": { + "url": "https://github.com/jshttp/on-finished/issues" + }, + "homepage": "https://github.com/jshttp/on-finished", + "_id": "on-finished@2.3.0", + "_shasum": "20f1336481b083cd75337992a16971aa2d906947", + "_from": "on-finished@>=2.3.0 <2.4.0", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "maintainers": [ + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "jongleberry", + "email": "jonathanrichardong@gmail.com" + } + ], + "dist": { + "shasum": "20f1336481b083cd75337992a16971aa2d906947", + "tarball": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/parseurl/HISTORY.md b/ui/node_modules/express/node_modules/parseurl/HISTORY.md index 0daf064e..395041ee 100644 --- a/ui/node_modules/express/node_modules/parseurl/HISTORY.md +++ b/ui/node_modules/express/node_modules/parseurl/HISTORY.md @@ -1,47 +1,47 @@ -1.3.1 / 2016-01-17 -================== - - * perf: enable strict mode - -1.3.0 / 2014-08-09 -================== - - * Add `parseurl.original` for parsing `req.originalUrl` with fallback - * Return `undefined` if `req.url` is `undefined` - -1.2.0 / 2014-07-21 -================== - - * Cache URLs based on original value - * Remove no-longer-needed URL mis-parse work-around - * Simplify the "fast-path" `RegExp` - -1.1.3 / 2014-07-08 -================== - - * Fix typo - -1.1.2 / 2014-07-08 -================== - - * Seriously fix Node.js 0.8 compatibility - -1.1.1 / 2014-07-08 -================== - - * Fix Node.js 0.8 compatibility - -1.1.0 / 2014-07-08 -================== - - * Incorporate URL href-only parse fast-path - -1.0.1 / 2014-03-08 -================== - - * Add missing `require` - -1.0.0 / 2014-03-08 -================== - - * Genesis from `connect` +1.3.1 / 2016-01-17 +================== + + * perf: enable strict mode + +1.3.0 / 2014-08-09 +================== + + * Add `parseurl.original` for parsing `req.originalUrl` with fallback + * Return `undefined` if `req.url` is `undefined` + +1.2.0 / 2014-07-21 +================== + + * Cache URLs based on original value + * Remove no-longer-needed URL mis-parse work-around + * Simplify the "fast-path" `RegExp` + +1.1.3 / 2014-07-08 +================== + + * Fix typo + +1.1.2 / 2014-07-08 +================== + + * Seriously fix Node.js 0.8 compatibility + +1.1.1 / 2014-07-08 +================== + + * Fix Node.js 0.8 compatibility + +1.1.0 / 2014-07-08 +================== + + * Incorporate URL href-only parse fast-path + +1.0.1 / 2014-03-08 +================== + + * Add missing `require` + +1.0.0 / 2014-03-08 +================== + + * Genesis from `connect` diff --git a/ui/node_modules/express/node_modules/parseurl/LICENSE b/ui/node_modules/express/node_modules/parseurl/LICENSE index 09258638..ec7dfe7b 100644 --- a/ui/node_modules/express/node_modules/parseurl/LICENSE +++ b/ui/node_modules/express/node_modules/parseurl/LICENSE @@ -1,24 +1,24 @@ - -(The MIT License) - -Copyright (c) 2014 Jonathan Ong -Copyright (c) 2014 Douglas Christopher Wilson - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(The MIT License) + +Copyright (c) 2014 Jonathan Ong +Copyright (c) 2014 Douglas Christopher Wilson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/parseurl/README.md b/ui/node_modules/express/node_modules/parseurl/README.md index 48c8ba1a..f4796ebb 100644 --- a/ui/node_modules/express/node_modules/parseurl/README.md +++ b/ui/node_modules/express/node_modules/parseurl/README.md @@ -1,120 +1,120 @@ -# parseurl - -[![NPM Version][npm-image]][npm-url] -[![NPM Downloads][downloads-image]][downloads-url] -[![Node.js Version][node-version-image]][node-version-url] -[![Build Status][travis-image]][travis-url] -[![Test Coverage][coveralls-image]][coveralls-url] - -Parse a URL with memoization. - -## Install - -```bash -$ npm install parseurl -``` - -## API - -```js -var parseurl = require('parseurl') -``` - -### parseurl(req) - -Parse the URL of the given request object (looks at the `req.url` property) -and return the result. The result is the same as `url.parse` in Node.js core. -Calling this function multiple times on the same `req` where `req.url` does -not change will return a cached parsed object, rather than parsing again. - -### parseurl.original(req) - -Parse the original URL of the given request object and return the result. -This works by trying to parse `req.originalUrl` if it is a string, otherwise -parses `req.url`. The result is the same as `url.parse` in Node.js core. -Calling this function multiple times on the same `req` where `req.originalUrl` -does not change will return a cached parsed object, rather than parsing again. - -## Benchmark - -```bash -$ npm run-script bench - -> parseurl@1.3.1 bench nodejs-parseurl -> node benchmark/index.js - -> node benchmark/fullurl.js - - Parsing URL "http://localhost:8888/foo/bar?user=tj&pet=fluffy" - - 1 test completed. - 2 tests completed. - 3 tests completed. - - fasturl x 1,290,780 ops/sec ±0.46% (195 runs sampled) - nativeurl x 56,401 ops/sec ±0.22% (196 runs sampled) - parseurl x 55,231 ops/sec ±0.22% (194 runs sampled) - -> node benchmark/pathquery.js - - Parsing URL "/foo/bar?user=tj&pet=fluffy" - - 1 test completed. - 2 tests completed. - 3 tests completed. - - fasturl x 1,986,668 ops/sec ±0.27% (190 runs sampled) - nativeurl x 98,740 ops/sec ±0.21% (195 runs sampled) - parseurl x 2,628,171 ops/sec ±0.36% (195 runs sampled) - -> node benchmark/samerequest.js - - Parsing URL "/foo/bar?user=tj&pet=fluffy" on same request object - - 1 test completed. - 2 tests completed. - 3 tests completed. - - fasturl x 2,184,468 ops/sec ±0.40% (194 runs sampled) - nativeurl x 99,437 ops/sec ±0.71% (194 runs sampled) - parseurl x 10,498,005 ops/sec ±0.61% (186 runs sampled) - -> node benchmark/simplepath.js - - Parsing URL "/foo/bar" - - 1 test completed. - 2 tests completed. - 3 tests completed. - - fasturl x 4,535,825 ops/sec ±0.27% (191 runs sampled) - nativeurl x 98,769 ops/sec ±0.54% (191 runs sampled) - parseurl x 4,164,865 ops/sec ±0.34% (192 runs sampled) - -> node benchmark/slash.js - - Parsing URL "/" - - 1 test completed. - 2 tests completed. - 3 tests completed. - - fasturl x 4,908,405 ops/sec ±0.42% (191 runs sampled) - nativeurl x 100,945 ops/sec ±0.59% (188 runs sampled) - parseurl x 4,333,208 ops/sec ±0.27% (194 runs sampled) -``` - -## License - - [MIT](LICENSE) - -[npm-image]: https://img.shields.io/npm/v/parseurl.svg -[npm-url]: https://npmjs.org/package/parseurl -[node-version-image]: https://img.shields.io/node/v/parseurl.svg -[node-version-url]: http://nodejs.org/download/ -[travis-image]: https://img.shields.io/travis/pillarjs/parseurl/master.svg -[travis-url]: https://travis-ci.org/pillarjs/parseurl -[coveralls-image]: https://img.shields.io/coveralls/pillarjs/parseurl/master.svg -[coveralls-url]: https://coveralls.io/r/pillarjs/parseurl?branch=master -[downloads-image]: https://img.shields.io/npm/dm/parseurl.svg -[downloads-url]: https://npmjs.org/package/parseurl +# parseurl + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-version-image]][node-version-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +Parse a URL with memoization. + +## Install + +```bash +$ npm install parseurl +``` + +## API + +```js +var parseurl = require('parseurl') +``` + +### parseurl(req) + +Parse the URL of the given request object (looks at the `req.url` property) +and return the result. The result is the same as `url.parse` in Node.js core. +Calling this function multiple times on the same `req` where `req.url` does +not change will return a cached parsed object, rather than parsing again. + +### parseurl.original(req) + +Parse the original URL of the given request object and return the result. +This works by trying to parse `req.originalUrl` if it is a string, otherwise +parses `req.url`. The result is the same as `url.parse` in Node.js core. +Calling this function multiple times on the same `req` where `req.originalUrl` +does not change will return a cached parsed object, rather than parsing again. + +## Benchmark + +```bash +$ npm run-script bench + +> parseurl@1.3.1 bench nodejs-parseurl +> node benchmark/index.js + +> node benchmark/fullurl.js + + Parsing URL "http://localhost:8888/foo/bar?user=tj&pet=fluffy" + + 1 test completed. + 2 tests completed. + 3 tests completed. + + fasturl x 1,290,780 ops/sec ±0.46% (195 runs sampled) + nativeurl x 56,401 ops/sec ±0.22% (196 runs sampled) + parseurl x 55,231 ops/sec ±0.22% (194 runs sampled) + +> node benchmark/pathquery.js + + Parsing URL "/foo/bar?user=tj&pet=fluffy" + + 1 test completed. + 2 tests completed. + 3 tests completed. + + fasturl x 1,986,668 ops/sec ±0.27% (190 runs sampled) + nativeurl x 98,740 ops/sec ±0.21% (195 runs sampled) + parseurl x 2,628,171 ops/sec ±0.36% (195 runs sampled) + +> node benchmark/samerequest.js + + Parsing URL "/foo/bar?user=tj&pet=fluffy" on same request object + + 1 test completed. + 2 tests completed. + 3 tests completed. + + fasturl x 2,184,468 ops/sec ±0.40% (194 runs sampled) + nativeurl x 99,437 ops/sec ±0.71% (194 runs sampled) + parseurl x 10,498,005 ops/sec ±0.61% (186 runs sampled) + +> node benchmark/simplepath.js + + Parsing URL "/foo/bar" + + 1 test completed. + 2 tests completed. + 3 tests completed. + + fasturl x 4,535,825 ops/sec ±0.27% (191 runs sampled) + nativeurl x 98,769 ops/sec ±0.54% (191 runs sampled) + parseurl x 4,164,865 ops/sec ±0.34% (192 runs sampled) + +> node benchmark/slash.js + + Parsing URL "/" + + 1 test completed. + 2 tests completed. + 3 tests completed. + + fasturl x 4,908,405 ops/sec ±0.42% (191 runs sampled) + nativeurl x 100,945 ops/sec ±0.59% (188 runs sampled) + parseurl x 4,333,208 ops/sec ±0.27% (194 runs sampled) +``` + +## License + + [MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/parseurl.svg +[npm-url]: https://npmjs.org/package/parseurl +[node-version-image]: https://img.shields.io/node/v/parseurl.svg +[node-version-url]: http://nodejs.org/download/ +[travis-image]: https://img.shields.io/travis/pillarjs/parseurl/master.svg +[travis-url]: https://travis-ci.org/pillarjs/parseurl +[coveralls-image]: https://img.shields.io/coveralls/pillarjs/parseurl/master.svg +[coveralls-url]: https://coveralls.io/r/pillarjs/parseurl?branch=master +[downloads-image]: https://img.shields.io/npm/dm/parseurl.svg +[downloads-url]: https://npmjs.org/package/parseurl diff --git a/ui/node_modules/express/node_modules/parseurl/index.js b/ui/node_modules/express/node_modules/parseurl/index.js index f22fdfd5..56cc6ec7 100644 --- a/ui/node_modules/express/node_modules/parseurl/index.js +++ b/ui/node_modules/express/node_modules/parseurl/index.js @@ -1,138 +1,138 @@ -/*! - * parseurl - * Copyright(c) 2014 Jonathan Ong - * Copyright(c) 2014 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict' - -/** - * Module dependencies. - */ - -var url = require('url') -var parse = url.parse -var Url = url.Url - -/** - * Pattern for a simple path case. - * See: https://github.com/joyent/node/pull/7878 - */ - -var simplePathRegExp = /^(\/\/?(?!\/)[^\?#\s]*)(\?[^#\s]*)?$/ - -/** - * Exports. - */ - -module.exports = parseurl -module.exports.original = originalurl - -/** - * Parse the `req` url with memoization. - * - * @param {ServerRequest} req - * @return {Object} - * @api public - */ - -function parseurl(req) { - var url = req.url - - if (url === undefined) { - // URL is undefined - return undefined - } - - var parsed = req._parsedUrl - - if (fresh(url, parsed)) { - // Return cached URL parse - return parsed - } - - // Parse the URL - parsed = fastparse(url) - parsed._raw = url - - return req._parsedUrl = parsed -}; - -/** - * Parse the `req` original url with fallback and memoization. - * - * @param {ServerRequest} req - * @return {Object} - * @api public - */ - -function originalurl(req) { - var url = req.originalUrl - - if (typeof url !== 'string') { - // Fallback - return parseurl(req) - } - - var parsed = req._parsedOriginalUrl - - if (fresh(url, parsed)) { - // Return cached URL parse - return parsed - } - - // Parse the URL - parsed = fastparse(url) - parsed._raw = url - - return req._parsedOriginalUrl = parsed -}; - -/** - * Parse the `str` url with fast-path short-cut. - * - * @param {string} str - * @return {Object} - * @api private - */ - -function fastparse(str) { - // Try fast path regexp - // See: https://github.com/joyent/node/pull/7878 - var simplePath = typeof str === 'string' && simplePathRegExp.exec(str) - - // Construct simple URL - if (simplePath) { - var pathname = simplePath[1] - var search = simplePath[2] || null - var url = Url !== undefined - ? new Url() - : {} - url.path = str - url.href = str - url.pathname = pathname - url.search = search - url.query = search && search.substr(1) - - return url - } - - return parse(str) -} - -/** - * Determine if parsed is still fresh for url. - * - * @param {string} url - * @param {object} parsedUrl - * @return {boolean} - * @api private - */ - -function fresh(url, parsedUrl) { - return typeof parsedUrl === 'object' - && parsedUrl !== null - && (Url === undefined || parsedUrl instanceof Url) - && parsedUrl._raw === url -} +/*! + * parseurl + * Copyright(c) 2014 Jonathan Ong + * Copyright(c) 2014 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module dependencies. + */ + +var url = require('url') +var parse = url.parse +var Url = url.Url + +/** + * Pattern for a simple path case. + * See: https://github.com/joyent/node/pull/7878 + */ + +var simplePathRegExp = /^(\/\/?(?!\/)[^\?#\s]*)(\?[^#\s]*)?$/ + +/** + * Exports. + */ + +module.exports = parseurl +module.exports.original = originalurl + +/** + * Parse the `req` url with memoization. + * + * @param {ServerRequest} req + * @return {Object} + * @api public + */ + +function parseurl(req) { + var url = req.url + + if (url === undefined) { + // URL is undefined + return undefined + } + + var parsed = req._parsedUrl + + if (fresh(url, parsed)) { + // Return cached URL parse + return parsed + } + + // Parse the URL + parsed = fastparse(url) + parsed._raw = url + + return req._parsedUrl = parsed +}; + +/** + * Parse the `req` original url with fallback and memoization. + * + * @param {ServerRequest} req + * @return {Object} + * @api public + */ + +function originalurl(req) { + var url = req.originalUrl + + if (typeof url !== 'string') { + // Fallback + return parseurl(req) + } + + var parsed = req._parsedOriginalUrl + + if (fresh(url, parsed)) { + // Return cached URL parse + return parsed + } + + // Parse the URL + parsed = fastparse(url) + parsed._raw = url + + return req._parsedOriginalUrl = parsed +}; + +/** + * Parse the `str` url with fast-path short-cut. + * + * @param {string} str + * @return {Object} + * @api private + */ + +function fastparse(str) { + // Try fast path regexp + // See: https://github.com/joyent/node/pull/7878 + var simplePath = typeof str === 'string' && simplePathRegExp.exec(str) + + // Construct simple URL + if (simplePath) { + var pathname = simplePath[1] + var search = simplePath[2] || null + var url = Url !== undefined + ? new Url() + : {} + url.path = str + url.href = str + url.pathname = pathname + url.search = search + url.query = search && search.substr(1) + + return url + } + + return parse(str) +} + +/** + * Determine if parsed is still fresh for url. + * + * @param {string} url + * @param {object} parsedUrl + * @return {boolean} + * @api private + */ + +function fresh(url, parsedUrl) { + return typeof parsedUrl === 'object' + && parsedUrl !== null + && (Url === undefined || parsedUrl instanceof Url) + && parsedUrl._raw === url +} diff --git a/ui/node_modules/express/node_modules/parseurl/package.json b/ui/node_modules/express/node_modules/parseurl/package.json index e919e908..7f57caaf 100644 --- a/ui/node_modules/express/node_modules/parseurl/package.json +++ b/ui/node_modules/express/node_modules/parseurl/package.json @@ -1,89 +1,89 @@ -{ - "name": "parseurl", - "description": "parse a url with memoization", - "version": "1.3.1", - "author": { - "name": "Jonathan Ong", - "email": "me@jongleberry.com", - "url": "http://jongleberry.com" - }, - "contributors": [ - { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - } - ], - "repository": { - "type": "git", - "url": "git+https://github.com/pillarjs/parseurl.git" - }, - "license": "MIT", - "devDependencies": { - "benchmark": "2.0.0", - "beautify-benchmark": "0.2.4", - "fast-url-parser": "1.1.3", - "istanbul": "0.4.2", - "mocha": "~1.21.5" - }, - "files": [ - "LICENSE", - "HISTORY.md", - "README.md", - "index.js" - ], - "engines": { - "node": ">= 0.8" - }, - "scripts": { - "bench": "node benchmark/index.js", - "test": "mocha --check-leaks --bail --reporter spec test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --check-leaks --reporter dot test/", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --check-leaks --reporter spec test/" - }, - "gitHead": "6d22d376d75b927ab2b5347ce3a1d6735133dd43", - "bugs": { - "url": "https://github.com/pillarjs/parseurl/issues" - }, - "homepage": "https://github.com/pillarjs/parseurl", - "_id": "parseurl@1.3.1", - "_shasum": "c8ab8c9223ba34888aa64a297b28853bec18da56", - "_from": "parseurl@>=1.3.1 <1.4.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - { - "name": "mscdex", - "email": "mscdex@mscdex.net" - }, - { - "name": "fishrock123", - "email": "fishrock123@rocketmail.com" - }, - { - "name": "defunctzombie", - "email": "shtylman@gmail.com" - } - ], - "dist": { - "shasum": "c8ab8c9223ba34888aa64a297b28853bec18da56", - "tarball": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.1.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.1.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "parseurl", + "description": "parse a url with memoization", + "version": "1.3.1", + "author": { + "name": "Jonathan Ong", + "email": "me@jongleberry.com", + "url": "http://jongleberry.com" + }, + "contributors": [ + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + } + ], + "repository": { + "type": "git", + "url": "git+https://github.com/pillarjs/parseurl.git" + }, + "license": "MIT", + "devDependencies": { + "benchmark": "2.0.0", + "beautify-benchmark": "0.2.4", + "fast-url-parser": "1.1.3", + "istanbul": "0.4.2", + "mocha": "~1.21.5" + }, + "files": [ + "LICENSE", + "HISTORY.md", + "README.md", + "index.js" + ], + "engines": { + "node": ">= 0.8" + }, + "scripts": { + "bench": "node benchmark/index.js", + "test": "mocha --check-leaks --bail --reporter spec test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --check-leaks --reporter dot test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --check-leaks --reporter spec test/" + }, + "gitHead": "6d22d376d75b927ab2b5347ce3a1d6735133dd43", + "bugs": { + "url": "https://github.com/pillarjs/parseurl/issues" + }, + "homepage": "https://github.com/pillarjs/parseurl", + "_id": "parseurl@1.3.1", + "_shasum": "c8ab8c9223ba34888aa64a297b28853bec18da56", + "_from": "parseurl@>=1.3.1 <1.4.0", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "maintainers": [ + { + "name": "jongleberry", + "email": "jonathanrichardong@gmail.com" + }, + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "tjholowaychuk", + "email": "tj@vision-media.ca" + }, + { + "name": "mscdex", + "email": "mscdex@mscdex.net" + }, + { + "name": "fishrock123", + "email": "fishrock123@rocketmail.com" + }, + { + "name": "defunctzombie", + "email": "shtylman@gmail.com" + } + ], + "dist": { + "shasum": "c8ab8c9223ba34888aa64a297b28853bec18da56", + "tarball": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.1.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.1.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/path-to-regexp/History.md b/ui/node_modules/express/node_modules/path-to-regexp/History.md index 8f2a7278..7f658784 100644 --- a/ui/node_modules/express/node_modules/path-to-regexp/History.md +++ b/ui/node_modules/express/node_modules/path-to-regexp/History.md @@ -1,36 +1,36 @@ -0.1.7 / 2015-07-28 -================== - - * Fixed regression with escaped round brackets and matching groups. - -0.1.6 / 2015-06-19 -================== - - * Replace `index` feature by outputting all parameters, unnamed and named. - -0.1.5 / 2015-05-08 -================== - - * Add an index property for position in match result. - -0.1.4 / 2015-03-05 -================== - - * Add license information - -0.1.3 / 2014-07-06 -================== - - * Better array support - * Improved support for trailing slash in non-ending mode - -0.1.0 / 2014-03-06 -================== - - * add options.end - -0.0.2 / 2013-02-10 -================== - - * Update to match current express - * add .license property to component.json +0.1.7 / 2015-07-28 +================== + + * Fixed regression with escaped round brackets and matching groups. + +0.1.6 / 2015-06-19 +================== + + * Replace `index` feature by outputting all parameters, unnamed and named. + +0.1.5 / 2015-05-08 +================== + + * Add an index property for position in match result. + +0.1.4 / 2015-03-05 +================== + + * Add license information + +0.1.3 / 2014-07-06 +================== + + * Better array support + * Improved support for trailing slash in non-ending mode + +0.1.0 / 2014-03-06 +================== + + * add options.end + +0.0.2 / 2013-02-10 +================== + + * Update to match current express + * add .license property to component.json diff --git a/ui/node_modules/express/node_modules/path-to-regexp/LICENSE b/ui/node_modules/express/node_modules/path-to-regexp/LICENSE index 154c9f2a..983fbe8a 100644 --- a/ui/node_modules/express/node_modules/path-to-regexp/LICENSE +++ b/ui/node_modules/express/node_modules/path-to-regexp/LICENSE @@ -1,21 +1,21 @@ -The MIT License (MIT) - -Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. +The MIT License (MIT) + +Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/path-to-regexp/Readme.md b/ui/node_modules/express/node_modules/path-to-regexp/Readme.md index c867dc0a..95452a6e 100644 --- a/ui/node_modules/express/node_modules/path-to-regexp/Readme.md +++ b/ui/node_modules/express/node_modules/path-to-regexp/Readme.md @@ -1,35 +1,35 @@ -# Path-to-RegExp - -Turn an Express-style path string such as `/user/:name` into a regular expression. - -**Note:** This is a legacy branch. You should upgrade to `1.x`. - -## Usage - -```javascript -var pathToRegexp = require('path-to-regexp'); -``` - -### pathToRegexp(path, keys, options) - - - **path** A string in the express format, an array of such strings, or a regular expression - - **keys** An array to be populated with the keys present in the url. Once the function completes, this will be an array of strings. - - **options** - - **options.sensitive** Defaults to false, set this to true to make routes case sensitive - - **options.strict** Defaults to false, set this to true to make the trailing slash matter. - - **options.end** Defaults to true, set this to false to only match the prefix of the URL. - -```javascript -var keys = []; -var exp = pathToRegexp('/foo/:bar', keys); -//keys = ['bar'] -//exp = /^\/foo\/(?:([^\/]+?))\/?$/i -``` - -## Live Demo - -You can see a live demo of this library in use at [express-route-tester](http://forbeslindesay.github.com/express-route-tester/). - -## License - - MIT +# Path-to-RegExp + +Turn an Express-style path string such as `/user/:name` into a regular expression. + +**Note:** This is a legacy branch. You should upgrade to `1.x`. + +## Usage + +```javascript +var pathToRegexp = require('path-to-regexp'); +``` + +### pathToRegexp(path, keys, options) + + - **path** A string in the express format, an array of such strings, or a regular expression + - **keys** An array to be populated with the keys present in the url. Once the function completes, this will be an array of strings. + - **options** + - **options.sensitive** Defaults to false, set this to true to make routes case sensitive + - **options.strict** Defaults to false, set this to true to make the trailing slash matter. + - **options.end** Defaults to true, set this to false to only match the prefix of the URL. + +```javascript +var keys = []; +var exp = pathToRegexp('/foo/:bar', keys); +//keys = ['bar'] +//exp = /^\/foo\/(?:([^\/]+?))\/?$/i +``` + +## Live Demo + +You can see a live demo of this library in use at [express-route-tester](http://forbeslindesay.github.com/express-route-tester/). + +## License + + MIT diff --git a/ui/node_modules/express/node_modules/path-to-regexp/index.js b/ui/node_modules/express/node_modules/path-to-regexp/index.js index d39c9b5f..500d1dad 100644 --- a/ui/node_modules/express/node_modules/path-to-regexp/index.js +++ b/ui/node_modules/express/node_modules/path-to-regexp/index.js @@ -1,129 +1,129 @@ -/** - * Expose `pathtoRegexp`. - */ - -module.exports = pathtoRegexp; - -/** - * Match matching groups in a regular expression. - */ -var MATCHING_GROUP_REGEXP = /\((?!\?)/g; - -/** - * Normalize the given path string, - * returning a regular expression. - * - * An empty array should be passed, - * which will contain the placeholder - * key names. For example "/user/:id" will - * then contain ["id"]. - * - * @param {String|RegExp|Array} path - * @param {Array} keys - * @param {Object} options - * @return {RegExp} - * @api private - */ - -function pathtoRegexp(path, keys, options) { - options = options || {}; - keys = keys || []; - var strict = options.strict; - var end = options.end !== false; - var flags = options.sensitive ? '' : 'i'; - var extraOffset = 0; - var keysOffset = keys.length; - var i = 0; - var name = 0; - var m; - - if (path instanceof RegExp) { - while (m = MATCHING_GROUP_REGEXP.exec(path.source)) { - keys.push({ - name: name++, - optional: false, - offset: m.index - }); - } - - return path; - } - - if (Array.isArray(path)) { - // Map array parts into regexps and return their source. We also pass - // the same keys and options instance into every generation to get - // consistent matching groups before we join the sources together. - path = path.map(function (value) { - return pathtoRegexp(value, keys, options).source; - }); - - return new RegExp('(?:' + path.join('|') + ')', flags); - } - - path = ('^' + path + (strict ? '' : path[path.length - 1] === '/' ? '?' : '/?')) - .replace(/\/\(/g, '/(?:') - .replace(/([\/\.])/g, '\\$1') - .replace(/(\\\/)?(\\\.)?:(\w+)(\(.*?\))?(\*)?(\?)?/g, function (match, slash, format, key, capture, star, optional, offset) { - slash = slash || ''; - format = format || ''; - capture = capture || '([^\\/' + format + ']+?)'; - optional = optional || ''; - - keys.push({ - name: key, - optional: !!optional, - offset: offset + extraOffset - }); - - var result = '' - + (optional ? '' : slash) - + '(?:' - + format + (optional ? slash : '') + capture - + (star ? '((?:[\\/' + format + '].+?)?)' : '') - + ')' - + optional; - - extraOffset += result.length - match.length; - - return result; - }) - .replace(/\*/g, function (star, index) { - var len = keys.length - - while (len-- > keysOffset && keys[len].offset > index) { - keys[len].offset += 3; // Replacement length minus asterisk length. - } - - return '(.*)'; - }); - - // This is a workaround for handling unnamed matching groups. - while (m = MATCHING_GROUP_REGEXP.exec(path)) { - var escapeCount = 0; - var index = m.index; - - while (path.charAt(--index) === '\\') { - escapeCount++; - } - - // It's possible to escape the bracket. - if (escapeCount % 2 === 1) { - continue; - } - - if (keysOffset + i === keys.length || keys[keysOffset + i].offset > m.index) { - keys.splice(keysOffset + i, 0, { - name: name++, // Unnamed matching groups must be consistently linear. - optional: false, - offset: m.index - }); - } - - i++; - } - - // If the path is non-ending, match until the end or a slash. - path += (end ? '$' : (path[path.length - 1] === '/' ? '' : '(?=\\/|$)')); - - return new RegExp(path, flags); -}; +/** + * Expose `pathtoRegexp`. + */ + +module.exports = pathtoRegexp; + +/** + * Match matching groups in a regular expression. + */ +var MATCHING_GROUP_REGEXP = /\((?!\?)/g; + +/** + * Normalize the given path string, + * returning a regular expression. + * + * An empty array should be passed, + * which will contain the placeholder + * key names. For example "/user/:id" will + * then contain ["id"]. + * + * @param {String|RegExp|Array} path + * @param {Array} keys + * @param {Object} options + * @return {RegExp} + * @api private + */ + +function pathtoRegexp(path, keys, options) { + options = options || {}; + keys = keys || []; + var strict = options.strict; + var end = options.end !== false; + var flags = options.sensitive ? '' : 'i'; + var extraOffset = 0; + var keysOffset = keys.length; + var i = 0; + var name = 0; + var m; + + if (path instanceof RegExp) { + while (m = MATCHING_GROUP_REGEXP.exec(path.source)) { + keys.push({ + name: name++, + optional: false, + offset: m.index + }); + } + + return path; + } + + if (Array.isArray(path)) { + // Map array parts into regexps and return their source. We also pass + // the same keys and options instance into every generation to get + // consistent matching groups before we join the sources together. + path = path.map(function (value) { + return pathtoRegexp(value, keys, options).source; + }); + + return new RegExp('(?:' + path.join('|') + ')', flags); + } + + path = ('^' + path + (strict ? '' : path[path.length - 1] === '/' ? '?' : '/?')) + .replace(/\/\(/g, '/(?:') + .replace(/([\/\.])/g, '\\$1') + .replace(/(\\\/)?(\\\.)?:(\w+)(\(.*?\))?(\*)?(\?)?/g, function (match, slash, format, key, capture, star, optional, offset) { + slash = slash || ''; + format = format || ''; + capture = capture || '([^\\/' + format + ']+?)'; + optional = optional || ''; + + keys.push({ + name: key, + optional: !!optional, + offset: offset + extraOffset + }); + + var result = '' + + (optional ? '' : slash) + + '(?:' + + format + (optional ? slash : '') + capture + + (star ? '((?:[\\/' + format + '].+?)?)' : '') + + ')' + + optional; + + extraOffset += result.length - match.length; + + return result; + }) + .replace(/\*/g, function (star, index) { + var len = keys.length + + while (len-- > keysOffset && keys[len].offset > index) { + keys[len].offset += 3; // Replacement length minus asterisk length. + } + + return '(.*)'; + }); + + // This is a workaround for handling unnamed matching groups. + while (m = MATCHING_GROUP_REGEXP.exec(path)) { + var escapeCount = 0; + var index = m.index; + + while (path.charAt(--index) === '\\') { + escapeCount++; + } + + // It's possible to escape the bracket. + if (escapeCount % 2 === 1) { + continue; + } + + if (keysOffset + i === keys.length || keys[keysOffset + i].offset > m.index) { + keys.splice(keysOffset + i, 0, { + name: name++, // Unnamed matching groups must be consistently linear. + optional: false, + offset: m.index + }); + } + + i++; + } + + // If the path is non-ending, match until the end or a slash. + path += (end ? '$' : (path[path.length - 1] === '/' ? '' : '(?=\\/|$)')); + + return new RegExp(path, flags); +}; diff --git a/ui/node_modules/express/node_modules/path-to-regexp/package.json b/ui/node_modules/express/node_modules/path-to-regexp/package.json index 49d67f47..042586a5 100644 --- a/ui/node_modules/express/node_modules/path-to-regexp/package.json +++ b/ui/node_modules/express/node_modules/path-to-regexp/package.json @@ -1,185 +1,185 @@ -{ - "name": "path-to-regexp", - "description": "Express style path to RegExp utility", - "version": "0.1.7", - "files": [ - "index.js", - "LICENSE" - ], - "scripts": { - "test": "istanbul cover _mocha -- -R spec" - }, - "keywords": [ - "express", - "regexp" - ], - "component": { - "scripts": { - "path-to-regexp": "index.js" - } - }, - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/component/path-to-regexp.git" - }, - "devDependencies": { - "mocha": "^1.17.1", - "istanbul": "^0.2.6" - }, - "gitHead": "039118d6c3c186d3f176c73935ca887a32a33d93", - "bugs": { - "url": "https://github.com/component/path-to-regexp/issues" - }, - "homepage": "https://github.com/component/path-to-regexp#readme", - "_id": "path-to-regexp@0.1.7", - "_shasum": "df604178005f522f15eb4490e7247a1bfaa67f8c", - "_from": "path-to-regexp@0.1.7", - "_npmVersion": "2.13.2", - "_nodeVersion": "2.3.3", - "_npmUser": { - "name": "blakeembrey", - "email": "hello@blakeembrey.com" - }, - "maintainers": [ - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - { - "name": "hughsk", - "email": "hughskennedy@gmail.com" - }, - { - "name": "timaschew", - "email": "timaschew@gmail.com" - }, - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "dominicbarnes", - "email": "dominic@dbarnes.info" - }, - { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - }, - { - "name": "rauchg", - "email": "rauchg@gmail.com" - }, - { - "name": "retrofox", - "email": "rdsuarez@gmail.com" - }, - { - "name": "coreh", - "email": "thecoreh@gmail.com" - }, - { - "name": "forbeslindesay", - "email": "forbes@lindesay.co.uk" - }, - { - "name": "kelonye", - "email": "kelonyemitchel@gmail.com" - }, - { - "name": "mattmueller", - "email": "mattmuelle@gmail.com" - }, - { - "name": "yields", - "email": "yields@icloud.com" - }, - { - "name": "anthonyshort", - "email": "antshort@gmail.com" - }, - { - "name": "ianstormtaylor", - "email": "ian@ianstormtaylor.com" - }, - { - "name": "cristiandouce", - "email": "cristian@gravityonmars.com" - }, - { - "name": "swatinem", - "email": "arpad.borsos@googlemail.com" - }, - { - "name": "stagas", - "email": "gstagas@gmail.com" - }, - { - "name": "amasad", - "email": "amjad.masad@gmail.com" - }, - { - "name": "juliangruber", - "email": "julian@juliangruber.com" - }, - { - "name": "calvinfo", - "email": "calvin@calv.info" - }, - { - "name": "blakeembrey", - "email": "hello@blakeembrey.com" - }, - { - "name": "timoxley", - "email": "secoif@gmail.com" - }, - { - "name": "jonathanong", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "queckezz", - "email": "fabian.eichenberger@gmail.com" - }, - { - "name": "nami-doc", - "email": "vendethiel@hotmail.fr" - }, - { - "name": "clintwood", - "email": "clint@anotherway.co.za" - }, - { - "name": "thehydroimpulse", - "email": "dnfagnan@gmail.com" - }, - { - "name": "stephenmathieson", - "email": "me@stephenmathieson.com" - }, - { - "name": "trevorgerhardt", - "email": "trevorgerhardt@gmail.com" - }, - { - "name": "dfcreative", - "email": "df.creative@gmail.com" - }, - { - "name": "defunctzombie", - "email": "shtylman@gmail.com" - } - ], - "dist": { - "shasum": "df604178005f522f15eb4490e7247a1bfaa67f8c", - "tarball": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "path-to-regexp", + "description": "Express style path to RegExp utility", + "version": "0.1.7", + "files": [ + "index.js", + "LICENSE" + ], + "scripts": { + "test": "istanbul cover _mocha -- -R spec" + }, + "keywords": [ + "express", + "regexp" + ], + "component": { + "scripts": { + "path-to-regexp": "index.js" + } + }, + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/component/path-to-regexp.git" + }, + "devDependencies": { + "mocha": "^1.17.1", + "istanbul": "^0.2.6" + }, + "gitHead": "039118d6c3c186d3f176c73935ca887a32a33d93", + "bugs": { + "url": "https://github.com/component/path-to-regexp/issues" + }, + "homepage": "https://github.com/component/path-to-regexp#readme", + "_id": "path-to-regexp@0.1.7", + "_shasum": "df604178005f522f15eb4490e7247a1bfaa67f8c", + "_from": "path-to-regexp@0.1.7", + "_npmVersion": "2.13.2", + "_nodeVersion": "2.3.3", + "_npmUser": { + "name": "blakeembrey", + "email": "hello@blakeembrey.com" + }, + "maintainers": [ + { + "name": "tjholowaychuk", + "email": "tj@vision-media.ca" + }, + { + "name": "hughsk", + "email": "hughskennedy@gmail.com" + }, + { + "name": "timaschew", + "email": "timaschew@gmail.com" + }, + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "jongleberry", + "email": "jonathanrichardong@gmail.com" + }, + { + "name": "dominicbarnes", + "email": "dominic@dbarnes.info" + }, + { + "name": "tootallnate", + "email": "nathan@tootallnate.net" + }, + { + "name": "rauchg", + "email": "rauchg@gmail.com" + }, + { + "name": "retrofox", + "email": "rdsuarez@gmail.com" + }, + { + "name": "coreh", + "email": "thecoreh@gmail.com" + }, + { + "name": "forbeslindesay", + "email": "forbes@lindesay.co.uk" + }, + { + "name": "kelonye", + "email": "kelonyemitchel@gmail.com" + }, + { + "name": "mattmueller", + "email": "mattmuelle@gmail.com" + }, + { + "name": "yields", + "email": "yields@icloud.com" + }, + { + "name": "anthonyshort", + "email": "antshort@gmail.com" + }, + { + "name": "ianstormtaylor", + "email": "ian@ianstormtaylor.com" + }, + { + "name": "cristiandouce", + "email": "cristian@gravityonmars.com" + }, + { + "name": "swatinem", + "email": "arpad.borsos@googlemail.com" + }, + { + "name": "stagas", + "email": "gstagas@gmail.com" + }, + { + "name": "amasad", + "email": "amjad.masad@gmail.com" + }, + { + "name": "juliangruber", + "email": "julian@juliangruber.com" + }, + { + "name": "calvinfo", + "email": "calvin@calv.info" + }, + { + "name": "blakeembrey", + "email": "hello@blakeembrey.com" + }, + { + "name": "timoxley", + "email": "secoif@gmail.com" + }, + { + "name": "jonathanong", + "email": "jonathanrichardong@gmail.com" + }, + { + "name": "queckezz", + "email": "fabian.eichenberger@gmail.com" + }, + { + "name": "nami-doc", + "email": "vendethiel@hotmail.fr" + }, + { + "name": "clintwood", + "email": "clint@anotherway.co.za" + }, + { + "name": "thehydroimpulse", + "email": "dnfagnan@gmail.com" + }, + { + "name": "stephenmathieson", + "email": "me@stephenmathieson.com" + }, + { + "name": "trevorgerhardt", + "email": "trevorgerhardt@gmail.com" + }, + { + "name": "dfcreative", + "email": "df.creative@gmail.com" + }, + { + "name": "defunctzombie", + "email": "shtylman@gmail.com" + } + ], + "dist": { + "shasum": "df604178005f522f15eb4490e7247a1bfaa67f8c", + "tarball": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/proxy-addr/HISTORY.md b/ui/node_modules/express/node_modules/proxy-addr/HISTORY.md index 23867c43..a7389db2 100644 --- a/ui/node_modules/express/node_modules/proxy-addr/HISTORY.md +++ b/ui/node_modules/express/node_modules/proxy-addr/HISTORY.md @@ -1,99 +1,99 @@ -1.1.2 / 2016-05-29 -================== - - * deps: ipaddr.js@1.1.1 - - Fix IPv6-mapped IPv4 validation edge cases - -1.1.1 / 2016-05-03 -================== - - * Fix regression matching mixed versions against multiple subnets - -1.1.0 / 2016-05-01 -================== - - * Fix accepting various invalid netmasks - - IPv4 netmasks must be contingous - - IPv6 addresses cannot be used as a netmask - * deps: ipaddr.js@1.1.0 - -1.0.10 / 2015-12-09 -=================== - - * deps: ipaddr.js@1.0.5 - - Fix regression in `isValid` with non-string arguments - -1.0.9 / 2015-12-01 -================== - - * deps: ipaddr.js@1.0.4 - - Fix accepting some invalid IPv6 addresses - - Reject CIDRs with negative or overlong masks - * perf: enable strict mode - -1.0.8 / 2015-05-10 -================== - - * deps: ipaddr.js@1.0.1 - -1.0.7 / 2015-03-16 -================== - - * deps: ipaddr.js@0.1.9 - - Fix OOM on certain inputs to `isValid` - -1.0.6 / 2015-02-01 -================== - - * deps: ipaddr.js@0.1.8 - -1.0.5 / 2015-01-08 -================== - - * deps: ipaddr.js@0.1.6 - -1.0.4 / 2014-11-23 -================== - - * deps: ipaddr.js@0.1.5 - - Fix edge cases with `isValid` - -1.0.3 / 2014-09-21 -================== - - * Use `forwarded` npm module - -1.0.2 / 2014-09-18 -================== - - * Fix a global leak when multiple subnets are trusted - * Support Node.js 0.6 - * deps: ipaddr.js@0.1.3 - -1.0.1 / 2014-06-03 -================== - - * Fix links in npm package - -1.0.0 / 2014-05-08 -================== - - * Add `trust` argument to determine proxy trust on - * Accepts custom function - * Accepts IPv4/IPv6 address(es) - * Accepts subnets - * Accepts pre-defined names - * Add optional `trust` argument to `proxyaddr.all` to - stop at first untrusted - * Add `proxyaddr.compile` to pre-compile `trust` function - to make subsequent calls faster - -0.0.1 / 2014-05-04 -================== - - * Fix bad npm publish - -0.0.0 / 2014-05-04 -================== - - * Initial release +1.1.2 / 2016-05-29 +================== + + * deps: ipaddr.js@1.1.1 + - Fix IPv6-mapped IPv4 validation edge cases + +1.1.1 / 2016-05-03 +================== + + * Fix regression matching mixed versions against multiple subnets + +1.1.0 / 2016-05-01 +================== + + * Fix accepting various invalid netmasks + - IPv4 netmasks must be contingous + - IPv6 addresses cannot be used as a netmask + * deps: ipaddr.js@1.1.0 + +1.0.10 / 2015-12-09 +=================== + + * deps: ipaddr.js@1.0.5 + - Fix regression in `isValid` with non-string arguments + +1.0.9 / 2015-12-01 +================== + + * deps: ipaddr.js@1.0.4 + - Fix accepting some invalid IPv6 addresses + - Reject CIDRs with negative or overlong masks + * perf: enable strict mode + +1.0.8 / 2015-05-10 +================== + + * deps: ipaddr.js@1.0.1 + +1.0.7 / 2015-03-16 +================== + + * deps: ipaddr.js@0.1.9 + - Fix OOM on certain inputs to `isValid` + +1.0.6 / 2015-02-01 +================== + + * deps: ipaddr.js@0.1.8 + +1.0.5 / 2015-01-08 +================== + + * deps: ipaddr.js@0.1.6 + +1.0.4 / 2014-11-23 +================== + + * deps: ipaddr.js@0.1.5 + - Fix edge cases with `isValid` + +1.0.3 / 2014-09-21 +================== + + * Use `forwarded` npm module + +1.0.2 / 2014-09-18 +================== + + * Fix a global leak when multiple subnets are trusted + * Support Node.js 0.6 + * deps: ipaddr.js@0.1.3 + +1.0.1 / 2014-06-03 +================== + + * Fix links in npm package + +1.0.0 / 2014-05-08 +================== + + * Add `trust` argument to determine proxy trust on + * Accepts custom function + * Accepts IPv4/IPv6 address(es) + * Accepts subnets + * Accepts pre-defined names + * Add optional `trust` argument to `proxyaddr.all` to + stop at first untrusted + * Add `proxyaddr.compile` to pre-compile `trust` function + to make subsequent calls faster + +0.0.1 / 2014-05-04 +================== + + * Fix bad npm publish + +0.0.0 / 2014-05-04 +================== + + * Initial release diff --git a/ui/node_modules/express/node_modules/proxy-addr/LICENSE b/ui/node_modules/express/node_modules/proxy-addr/LICENSE index 6ee5eb79..cab251c2 100644 --- a/ui/node_modules/express/node_modules/proxy-addr/LICENSE +++ b/ui/node_modules/express/node_modules/proxy-addr/LICENSE @@ -1,22 +1,22 @@ -(The MIT License) - -Copyright (c) 2014-2016 Douglas Christopher Wilson - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2014-2016 Douglas Christopher Wilson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/proxy-addr/README.md b/ui/node_modules/express/node_modules/proxy-addr/README.md index a9b0abe9..1bffc764 100644 --- a/ui/node_modules/express/node_modules/proxy-addr/README.md +++ b/ui/node_modules/express/node_modules/proxy-addr/README.md @@ -1,136 +1,136 @@ -# proxy-addr - -[![NPM Version][npm-image]][npm-url] -[![NPM Downloads][downloads-image]][downloads-url] -[![Node.js Version][node-version-image]][node-version-url] -[![Build Status][travis-image]][travis-url] -[![Test Coverage][coveralls-image]][coveralls-url] - -Determine address of proxied request - -## Install - -```sh -$ npm install proxy-addr -``` - -## API - -```js -var proxyaddr = require('proxy-addr') -``` - -### proxyaddr(req, trust) - -Return the address of the request, using the given `trust` parameter. - -The `trust` argument is a function that returns `true` if you trust -the address, `false` if you don't. The closest untrusted address is -returned. - -```js -proxyaddr(req, function(addr){ return addr === '127.0.0.1' }) -proxyaddr(req, function(addr, i){ return i < 1 }) -``` - -The `trust` arugment may also be a single IP address string or an -array of trusted addresses, as plain IP addresses, CIDR-formatted -strings, or IP/netmask strings. - -```js -proxyaddr(req, '127.0.0.1') -proxyaddr(req, ['127.0.0.0/8', '10.0.0.0/8']) -proxyaddr(req, ['127.0.0.0/255.0.0.0', '192.168.0.0/255.255.0.0']) -``` - -This module also supports IPv6. Your IPv6 addresses will be normalized -automatically (i.e. `fe80::00ed:1` equals `fe80:0:0:0:0:0:ed:1`). - -```js -proxyaddr(req, '::1') -proxyaddr(req, ['::1/128', 'fe80::/10']) -``` - -This module will automatically work with IPv4-mapped IPv6 addresses -as well to support node.js in IPv6-only mode. This means that you do -not have to specify both `::ffff:a00:1` and `10.0.0.1`. - -As a convenience, this module also takes certain pre-defined names -in addition to IP addresses, which expand into IP addresses: - -```js -proxyaddr(req, 'loopback') -proxyaddr(req, ['loopback', 'fc00:ac:1ab5:fff::1/64']) -``` - - * `loopback`: IPv4 and IPv6 loopback addresses (like `::1` and - `127.0.0.1`). - * `linklocal`: IPv4 and IPv6 link-local addresses (like - `fe80::1:1:1:1` and `169.254.0.1`). - * `uniquelocal`: IPv4 private addresses and IPv6 unique-local - addresses (like `fc00:ac:1ab5:fff::1` and `192.168.0.1`). - -When `trust` is specified as a function, it will be called for each -address to determine if it is a trusted address. The function is -given two arguments: `addr` and `i`, where `addr` is a string of -the address to check and `i` is a number that represents the distance -from the socket address. - -### proxyaddr.all(req, [trust]) - -Return all the addresses of the request, optionally stopping at the -first untrusted. This array is ordered from closest to furthest -(i.e. `arr[0] === req.connection.remoteAddress`). - -```js -proxyaddr.all(req) -``` - -The optional `trust` argument takes the same arguments as `trust` -does in `proxyaddr(req, trust)`. - -```js -proxyaddr.all(req, 'loopback') -``` - -### proxyaddr.compile(val) - -Compiles argument `val` into a `trust` function. This function takes -the same arguments as `trust` does in `proxyaddr(req, trust)` and -returns a function suitable for `proxyaddr(req, trust)`. - -```js -var trust = proxyaddr.compile('localhost') -var addr = proxyaddr(req, trust) -``` - -This function is meant to be optimized for use against every request. -It is recommend to compile a trust function up-front for the trusted -configuration and pass that to `proxyaddr(req, trust)` for each request. - -## Testing - -```sh -$ npm test -``` - -## Benchmarks - -```sh -$ npm run-script bench -``` - -## License - -[MIT](LICENSE) - -[npm-image]: https://img.shields.io/npm/v/proxy-addr.svg -[npm-url]: https://npmjs.org/package/proxy-addr -[node-version-image]: https://img.shields.io/node/v/proxy-addr.svg -[node-version-url]: http://nodejs.org/download/ -[travis-image]: https://img.shields.io/travis/jshttp/proxy-addr/master.svg -[travis-url]: https://travis-ci.org/jshttp/proxy-addr -[coveralls-image]: https://img.shields.io/coveralls/jshttp/proxy-addr/master.svg -[coveralls-url]: https://coveralls.io/r/jshttp/proxy-addr?branch=master -[downloads-image]: https://img.shields.io/npm/dm/proxy-addr.svg -[downloads-url]: https://npmjs.org/package/proxy-addr +# proxy-addr + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-version-image]][node-version-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +Determine address of proxied request + +## Install + +```sh +$ npm install proxy-addr +``` + +## API + +```js +var proxyaddr = require('proxy-addr') +``` + +### proxyaddr(req, trust) + +Return the address of the request, using the given `trust` parameter. + +The `trust` argument is a function that returns `true` if you trust +the address, `false` if you don't. The closest untrusted address is +returned. + +```js +proxyaddr(req, function(addr){ return addr === '127.0.0.1' }) +proxyaddr(req, function(addr, i){ return i < 1 }) +``` + +The `trust` arugment may also be a single IP address string or an +array of trusted addresses, as plain IP addresses, CIDR-formatted +strings, or IP/netmask strings. + +```js +proxyaddr(req, '127.0.0.1') +proxyaddr(req, ['127.0.0.0/8', '10.0.0.0/8']) +proxyaddr(req, ['127.0.0.0/255.0.0.0', '192.168.0.0/255.255.0.0']) +``` + +This module also supports IPv6. Your IPv6 addresses will be normalized +automatically (i.e. `fe80::00ed:1` equals `fe80:0:0:0:0:0:ed:1`). + +```js +proxyaddr(req, '::1') +proxyaddr(req, ['::1/128', 'fe80::/10']) +``` + +This module will automatically work with IPv4-mapped IPv6 addresses +as well to support node.js in IPv6-only mode. This means that you do +not have to specify both `::ffff:a00:1` and `10.0.0.1`. + +As a convenience, this module also takes certain pre-defined names +in addition to IP addresses, which expand into IP addresses: + +```js +proxyaddr(req, 'loopback') +proxyaddr(req, ['loopback', 'fc00:ac:1ab5:fff::1/64']) +``` + + * `loopback`: IPv4 and IPv6 loopback addresses (like `::1` and + `127.0.0.1`). + * `linklocal`: IPv4 and IPv6 link-local addresses (like + `fe80::1:1:1:1` and `169.254.0.1`). + * `uniquelocal`: IPv4 private addresses and IPv6 unique-local + addresses (like `fc00:ac:1ab5:fff::1` and `192.168.0.1`). + +When `trust` is specified as a function, it will be called for each +address to determine if it is a trusted address. The function is +given two arguments: `addr` and `i`, where `addr` is a string of +the address to check and `i` is a number that represents the distance +from the socket address. + +### proxyaddr.all(req, [trust]) + +Return all the addresses of the request, optionally stopping at the +first untrusted. This array is ordered from closest to furthest +(i.e. `arr[0] === req.connection.remoteAddress`). + +```js +proxyaddr.all(req) +``` + +The optional `trust` argument takes the same arguments as `trust` +does in `proxyaddr(req, trust)`. + +```js +proxyaddr.all(req, 'loopback') +``` + +### proxyaddr.compile(val) + +Compiles argument `val` into a `trust` function. This function takes +the same arguments as `trust` does in `proxyaddr(req, trust)` and +returns a function suitable for `proxyaddr(req, trust)`. + +```js +var trust = proxyaddr.compile('localhost') +var addr = proxyaddr(req, trust) +``` + +This function is meant to be optimized for use against every request. +It is recommend to compile a trust function up-front for the trusted +configuration and pass that to `proxyaddr(req, trust)` for each request. + +## Testing + +```sh +$ npm test +``` + +## Benchmarks + +```sh +$ npm run-script bench +``` + +## License + +[MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/proxy-addr.svg +[npm-url]: https://npmjs.org/package/proxy-addr +[node-version-image]: https://img.shields.io/node/v/proxy-addr.svg +[node-version-url]: http://nodejs.org/download/ +[travis-image]: https://img.shields.io/travis/jshttp/proxy-addr/master.svg +[travis-url]: https://travis-ci.org/jshttp/proxy-addr +[coveralls-image]: https://img.shields.io/coveralls/jshttp/proxy-addr/master.svg +[coveralls-url]: https://coveralls.io/r/jshttp/proxy-addr?branch=master +[downloads-image]: https://img.shields.io/npm/dm/proxy-addr.svg +[downloads-url]: https://npmjs.org/package/proxy-addr diff --git a/ui/node_modules/express/node_modules/proxy-addr/index.js b/ui/node_modules/express/node_modules/proxy-addr/index.js index b9a5b288..0b3cf0b2 100644 --- a/ui/node_modules/express/node_modules/proxy-addr/index.js +++ b/ui/node_modules/express/node_modules/proxy-addr/index.js @@ -1,321 +1,321 @@ -/*! - * proxy-addr - * Copyright(c) 2014-2016 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict' - -/** - * Module exports. - */ - -module.exports = proxyaddr; -module.exports.all = alladdrs; -module.exports.compile = compile; - -/** - * Module dependencies. - */ - -var forwarded = require('forwarded'); -var ipaddr = require('ipaddr.js'); - -/** - * Variables. - */ - -var digitre = /^[0-9]+$/; -var isip = ipaddr.isValid; -var parseip = ipaddr.parse; - -/** - * Pre-defined IP ranges. - */ - -var ipranges = { - linklocal: ['169.254.0.0/16', 'fe80::/10'], - loopback: ['127.0.0.1/8', '::1/128'], - uniquelocal: ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', 'fc00::/7'] -}; - -/** - * Get all addresses in the request, optionally stopping - * at the first untrusted. - * - * @param {Object} request - * @param {Function|Array|String} [trust] - * @api public - */ - -function alladdrs(req, trust) { - // get addresses - var addrs = forwarded(req); - - if (!trust) { - // Return all addresses - return addrs; - } - - if (typeof trust !== 'function') { - trust = compile(trust); - } - - for (var i = 0; i < addrs.length - 1; i++) { - if (trust(addrs[i], i)) continue; - - addrs.length = i + 1; - } - - return addrs; -} - -/** - * Compile argument into trust function. - * - * @param {Array|String} val - * @api private - */ - -function compile(val) { - if (!val) { - throw new TypeError('argument is required'); - } - - var trust = typeof val === 'string' - ? [val] - : val; - - if (!Array.isArray(trust)) { - throw new TypeError('unsupported trust argument'); - } - - for (var i = 0; i < trust.length; i++) { - val = trust[i]; - - if (!ipranges.hasOwnProperty(val)) { - continue; - } - - // Splice in pre-defined range - val = ipranges[val]; - trust.splice.apply(trust, [i, 1].concat(val)); - i += val.length - 1; - } - - return compileTrust(compileRangeSubnets(trust)); -} - -/** - * Compile `arr` elements into range subnets. - * - * @param {Array} arr - * @api private - */ - -function compileRangeSubnets(arr) { - var rangeSubnets = new Array(arr.length); - - for (var i = 0; i < arr.length; i++) { - rangeSubnets[i] = parseipNotation(arr[i]); - } - - return rangeSubnets; -} - -/** - * Compile range subnet array into trust function. - * - * @param {Array} rangeSubnets - * @api private - */ - -function compileTrust(rangeSubnets) { - // Return optimized function based on length - var len = rangeSubnets.length; - return len === 0 - ? trustNone - : len === 1 - ? trustSingle(rangeSubnets[0]) - : trustMulti(rangeSubnets); -} - -/** - * Parse IP notation string into range subnet. - * - * @param {String} note - * @api private - */ - -function parseipNotation(note) { - var pos = note.lastIndexOf('/'); - var str = pos !== -1 - ? note.substring(0, pos) - : note; - - if (!isip(str)) { - throw new TypeError('invalid IP address: ' + str); - } - - var ip = parseip(str); - - if (pos === -1 && ip.kind() === 'ipv6' && ip.isIPv4MappedAddress()) { - // Store as IPv4 - ip = ip.toIPv4Address(); - } - - var max = ip.kind() === 'ipv6' - ? 128 - : 32; - - var range = pos !== -1 - ? note.substring(pos + 1, note.length) - : null; - - if (range === null) { - range = max; - } else if (digitre.test(range)) { - range = parseInt(range, 10); - } else if (ip.kind() === 'ipv4' && isip(range)) { - range = parseNetmask(range); - } else { - range = null; - } - - if (range <= 0 || range > max) { - throw new TypeError('invalid range on address: ' + note); - } - - return [ip, range]; -} - -/** - * Parse netmask string into CIDR range. - * - * @param {String} netmask - * @api private - */ - -function parseNetmask(netmask) { - var ip = parseip(netmask); - var kind = ip.kind(); - - return kind === 'ipv4' - ? ip.prefixLengthFromSubnetMask() - : null; -} - -/** - * Determine address of proxied request. - * - * @param {Object} request - * @param {Function|Array|String} trust - * @api public - */ - -function proxyaddr(req, trust) { - if (!req) { - throw new TypeError('req argument is required'); - } - - if (!trust) { - throw new TypeError('trust argument is required'); - } - - var addrs = alladdrs(req, trust); - var addr = addrs[addrs.length - 1]; - - return addr; -} - -/** - * Static trust function to trust nothing. - * - * @api private - */ - -function trustNone() { - return false; -} - -/** - * Compile trust function for multiple subnets. - * - * @param {Array} subnets - * @api private - */ - -function trustMulti(subnets) { - return function trust(addr) { - if (!isip(addr)) return false; - - var ip = parseip(addr); - var ipconv; - var kind = ip.kind(); - - for (var i = 0; i < subnets.length; i++) { - var subnet = subnets[i]; - var subnetip = subnet[0]; - var subnetkind = subnetip.kind(); - var subnetrange = subnet[1]; - var trusted = ip; - - if (kind !== subnetkind) { - if (subnetkind === 'ipv4' && !ip.isIPv4MappedAddress()) { - // Incompatible IP addresses - continue; - } - - if (!ipconv) { - // Convert IP to match subnet IP kind - ipconv = subnetkind === 'ipv4' - ? ip.toIPv4Address() - : ip.toIPv4MappedAddress(); - } - - trusted = ipconv; - } - - if (trusted.match(subnetip, subnetrange)) { - return true; - } - } - - return false; - }; -} - -/** - * Compile trust function for single subnet. - * - * @param {Object} subnet - * @api private - */ - -function trustSingle(subnet) { - var subnetip = subnet[0]; - var subnetkind = subnetip.kind(); - var subnetisipv4 = subnetkind === 'ipv4'; - var subnetrange = subnet[1]; - - return function trust(addr) { - if (!isip(addr)) return false; - - var ip = parseip(addr); - var kind = ip.kind(); - - if (kind !== subnetkind) { - if (subnetisipv4 && !ip.isIPv4MappedAddress()) { - // Incompatible IP addresses - return false; - } - - // Convert IP to match subnet IP kind - ip = subnetisipv4 - ? ip.toIPv4Address() - : ip.toIPv4MappedAddress(); - } - - return ip.match(subnetip, subnetrange); - }; -} +/*! + * proxy-addr + * Copyright(c) 2014-2016 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module exports. + */ + +module.exports = proxyaddr; +module.exports.all = alladdrs; +module.exports.compile = compile; + +/** + * Module dependencies. + */ + +var forwarded = require('forwarded'); +var ipaddr = require('ipaddr.js'); + +/** + * Variables. + */ + +var digitre = /^[0-9]+$/; +var isip = ipaddr.isValid; +var parseip = ipaddr.parse; + +/** + * Pre-defined IP ranges. + */ + +var ipranges = { + linklocal: ['169.254.0.0/16', 'fe80::/10'], + loopback: ['127.0.0.1/8', '::1/128'], + uniquelocal: ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', 'fc00::/7'] +}; + +/** + * Get all addresses in the request, optionally stopping + * at the first untrusted. + * + * @param {Object} request + * @param {Function|Array|String} [trust] + * @api public + */ + +function alladdrs(req, trust) { + // get addresses + var addrs = forwarded(req); + + if (!trust) { + // Return all addresses + return addrs; + } + + if (typeof trust !== 'function') { + trust = compile(trust); + } + + for (var i = 0; i < addrs.length - 1; i++) { + if (trust(addrs[i], i)) continue; + + addrs.length = i + 1; + } + + return addrs; +} + +/** + * Compile argument into trust function. + * + * @param {Array|String} val + * @api private + */ + +function compile(val) { + if (!val) { + throw new TypeError('argument is required'); + } + + var trust = typeof val === 'string' + ? [val] + : val; + + if (!Array.isArray(trust)) { + throw new TypeError('unsupported trust argument'); + } + + for (var i = 0; i < trust.length; i++) { + val = trust[i]; + + if (!ipranges.hasOwnProperty(val)) { + continue; + } + + // Splice in pre-defined range + val = ipranges[val]; + trust.splice.apply(trust, [i, 1].concat(val)); + i += val.length - 1; + } + + return compileTrust(compileRangeSubnets(trust)); +} + +/** + * Compile `arr` elements into range subnets. + * + * @param {Array} arr + * @api private + */ + +function compileRangeSubnets(arr) { + var rangeSubnets = new Array(arr.length); + + for (var i = 0; i < arr.length; i++) { + rangeSubnets[i] = parseipNotation(arr[i]); + } + + return rangeSubnets; +} + +/** + * Compile range subnet array into trust function. + * + * @param {Array} rangeSubnets + * @api private + */ + +function compileTrust(rangeSubnets) { + // Return optimized function based on length + var len = rangeSubnets.length; + return len === 0 + ? trustNone + : len === 1 + ? trustSingle(rangeSubnets[0]) + : trustMulti(rangeSubnets); +} + +/** + * Parse IP notation string into range subnet. + * + * @param {String} note + * @api private + */ + +function parseipNotation(note) { + var pos = note.lastIndexOf('/'); + var str = pos !== -1 + ? note.substring(0, pos) + : note; + + if (!isip(str)) { + throw new TypeError('invalid IP address: ' + str); + } + + var ip = parseip(str); + + if (pos === -1 && ip.kind() === 'ipv6' && ip.isIPv4MappedAddress()) { + // Store as IPv4 + ip = ip.toIPv4Address(); + } + + var max = ip.kind() === 'ipv6' + ? 128 + : 32; + + var range = pos !== -1 + ? note.substring(pos + 1, note.length) + : null; + + if (range === null) { + range = max; + } else if (digitre.test(range)) { + range = parseInt(range, 10); + } else if (ip.kind() === 'ipv4' && isip(range)) { + range = parseNetmask(range); + } else { + range = null; + } + + if (range <= 0 || range > max) { + throw new TypeError('invalid range on address: ' + note); + } + + return [ip, range]; +} + +/** + * Parse netmask string into CIDR range. + * + * @param {String} netmask + * @api private + */ + +function parseNetmask(netmask) { + var ip = parseip(netmask); + var kind = ip.kind(); + + return kind === 'ipv4' + ? ip.prefixLengthFromSubnetMask() + : null; +} + +/** + * Determine address of proxied request. + * + * @param {Object} request + * @param {Function|Array|String} trust + * @api public + */ + +function proxyaddr(req, trust) { + if (!req) { + throw new TypeError('req argument is required'); + } + + if (!trust) { + throw new TypeError('trust argument is required'); + } + + var addrs = alladdrs(req, trust); + var addr = addrs[addrs.length - 1]; + + return addr; +} + +/** + * Static trust function to trust nothing. + * + * @api private + */ + +function trustNone() { + return false; +} + +/** + * Compile trust function for multiple subnets. + * + * @param {Array} subnets + * @api private + */ + +function trustMulti(subnets) { + return function trust(addr) { + if (!isip(addr)) return false; + + var ip = parseip(addr); + var ipconv; + var kind = ip.kind(); + + for (var i = 0; i < subnets.length; i++) { + var subnet = subnets[i]; + var subnetip = subnet[0]; + var subnetkind = subnetip.kind(); + var subnetrange = subnet[1]; + var trusted = ip; + + if (kind !== subnetkind) { + if (subnetkind === 'ipv4' && !ip.isIPv4MappedAddress()) { + // Incompatible IP addresses + continue; + } + + if (!ipconv) { + // Convert IP to match subnet IP kind + ipconv = subnetkind === 'ipv4' + ? ip.toIPv4Address() + : ip.toIPv4MappedAddress(); + } + + trusted = ipconv; + } + + if (trusted.match(subnetip, subnetrange)) { + return true; + } + } + + return false; + }; +} + +/** + * Compile trust function for single subnet. + * + * @param {Object} subnet + * @api private + */ + +function trustSingle(subnet) { + var subnetip = subnet[0]; + var subnetkind = subnetip.kind(); + var subnetisipv4 = subnetkind === 'ipv4'; + var subnetrange = subnet[1]; + + return function trust(addr) { + if (!isip(addr)) return false; + + var ip = parseip(addr); + var kind = ip.kind(); + + if (kind !== subnetkind) { + if (subnetisipv4 && !ip.isIPv4MappedAddress()) { + // Incompatible IP addresses + return false; + } + + // Convert IP to match subnet IP kind + ip = subnetisipv4 + ? ip.toIPv4Address() + : ip.toIPv4MappedAddress(); + } + + return ip.match(subnetip, subnetrange); + }; +} diff --git a/ui/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/HISTORY.md b/ui/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/HISTORY.md index 96f5d5dd..97fa1d10 100644 --- a/ui/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/HISTORY.md +++ b/ui/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/HISTORY.md @@ -1,4 +1,4 @@ -0.1.0 / 2014-09-21 -================== - - * Initial release +0.1.0 / 2014-09-21 +================== + + * Initial release diff --git a/ui/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/LICENSE b/ui/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/LICENSE index 69313376..b7dce6cf 100644 --- a/ui/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/LICENSE +++ b/ui/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/LICENSE @@ -1,22 +1,22 @@ -(The MIT License) - -Copyright (c) 2014 Douglas Christopher Wilson - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2014 Douglas Christopher Wilson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/README.md b/ui/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/README.md index 520e166a..2b4988fa 100644 --- a/ui/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/README.md +++ b/ui/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/README.md @@ -1,53 +1,53 @@ -# forwarded - -[![NPM Version][npm-image]][npm-url] -[![NPM Downloads][downloads-image]][downloads-url] -[![Node.js Version][node-version-image]][node-version-url] -[![Build Status][travis-image]][travis-url] -[![Test Coverage][coveralls-image]][coveralls-url] - -Parse HTTP X-Forwarded-For header - -## Installation - -```sh -$ npm install forwarded -``` - -## API - -```js -var forwarded = require('forwarded') -``` - -### forwarded(req) - -```js -var addresses = forwarded(req) -``` - -Parse the `X-Forwarded-For` header from the request. Returns an array -of the addresses, including the socket address for the `req`. In reverse -order (i.e. index `0` is the socket address and the last index is the -furthest address, typically the end-user). - -## Testing - -```sh -$ npm test -``` - -## License - -[MIT](LICENSE) - -[npm-image]: https://img.shields.io/npm/v/forwarded.svg?style=flat -[npm-url]: https://npmjs.org/package/forwarded -[node-version-image]: https://img.shields.io/node/v/forwarded.svg?style=flat -[node-version-url]: http://nodejs.org/download/ -[travis-image]: https://img.shields.io/travis/jshttp/forwarded.svg?style=flat -[travis-url]: https://travis-ci.org/jshttp/forwarded -[coveralls-image]: https://img.shields.io/coveralls/jshttp/forwarded.svg?style=flat -[coveralls-url]: https://coveralls.io/r/jshttp/forwarded?branch=master -[downloads-image]: https://img.shields.io/npm/dm/forwarded.svg?style=flat -[downloads-url]: https://npmjs.org/package/forwarded +# forwarded + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-version-image]][node-version-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +Parse HTTP X-Forwarded-For header + +## Installation + +```sh +$ npm install forwarded +``` + +## API + +```js +var forwarded = require('forwarded') +``` + +### forwarded(req) + +```js +var addresses = forwarded(req) +``` + +Parse the `X-Forwarded-For` header from the request. Returns an array +of the addresses, including the socket address for the `req`. In reverse +order (i.e. index `0` is the socket address and the last index is the +furthest address, typically the end-user). + +## Testing + +```sh +$ npm test +``` + +## License + +[MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/forwarded.svg?style=flat +[npm-url]: https://npmjs.org/package/forwarded +[node-version-image]: https://img.shields.io/node/v/forwarded.svg?style=flat +[node-version-url]: http://nodejs.org/download/ +[travis-image]: https://img.shields.io/travis/jshttp/forwarded.svg?style=flat +[travis-url]: https://travis-ci.org/jshttp/forwarded +[coveralls-image]: https://img.shields.io/coveralls/jshttp/forwarded.svg?style=flat +[coveralls-url]: https://coveralls.io/r/jshttp/forwarded?branch=master +[downloads-image]: https://img.shields.io/npm/dm/forwarded.svg?style=flat +[downloads-url]: https://npmjs.org/package/forwarded diff --git a/ui/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/index.js b/ui/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/index.js index c5e1c052..2f5c3408 100644 --- a/ui/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/index.js +++ b/ui/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/index.js @@ -1,35 +1,35 @@ -/*! - * forwarded - * Copyright(c) 2014 Douglas Christopher Wilson - * MIT Licensed - */ - -/** - * Module exports. - */ - -module.exports = forwarded - -/** - * Get all addresses in the request, using the `X-Forwarded-For` header. - * - * @param {Object} req - * @api public - */ - -function forwarded(req) { - if (!req) { - throw new TypeError('argument req is required') - } - - // simple header parsing - var proxyAddrs = (req.headers['x-forwarded-for'] || '') - .split(/ *, */) - .filter(Boolean) - .reverse() - var socketAddr = req.connection.remoteAddress - var addrs = [socketAddr].concat(proxyAddrs) - - // return all addresses - return addrs -} +/*! + * forwarded + * Copyright(c) 2014 Douglas Christopher Wilson + * MIT Licensed + */ + +/** + * Module exports. + */ + +module.exports = forwarded + +/** + * Get all addresses in the request, using the `X-Forwarded-For` header. + * + * @param {Object} req + * @api public + */ + +function forwarded(req) { + if (!req) { + throw new TypeError('argument req is required') + } + + // simple header parsing + var proxyAddrs = (req.headers['x-forwarded-for'] || '') + .split(/ *, */) + .filter(Boolean) + .reverse() + var socketAddr = req.connection.remoteAddress + var addrs = [socketAddr].concat(proxyAddrs) + + // return all addresses + return addrs +} diff --git a/ui/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/package.json b/ui/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/package.json index 79579f50..35297a6c 100644 --- a/ui/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/package.json +++ b/ui/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/package.json @@ -1,65 +1,65 @@ -{ - "name": "forwarded", - "description": "Parse HTTP X-Forwarded-For header", - "version": "0.1.0", - "contributors": [ - { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - } - ], - "license": "MIT", - "keywords": [ - "x-forwarded-for", - "http", - "req" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/forwarded.git" - }, - "devDependencies": { - "istanbul": "0.3.2", - "mocha": "~1.21.4" - }, - "files": [ - "LICENSE", - "HISTORY.md", - "README.md", - "index.js" - ], - "engines": { - "node": ">= 0.6" - }, - "scripts": { - "test": "mocha --reporter spec --bail --check-leaks test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" - }, - "gitHead": "e9a9faeb3cfaadf40eb57d144fff26bca9b818e8", - "bugs": { - "url": "https://github.com/jshttp/forwarded/issues" - }, - "homepage": "https://github.com/jshttp/forwarded", - "_id": "forwarded@0.1.0", - "_shasum": "19ef9874c4ae1c297bcf078fde63a09b66a84363", - "_from": "forwarded@>=0.1.0 <0.2.0", - "_npmVersion": "1.4.21", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "19ef9874c4ae1c297bcf078fde63a09b66a84363", - "tarball": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.0.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "forwarded", + "description": "Parse HTTP X-Forwarded-For header", + "version": "0.1.0", + "contributors": [ + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + } + ], + "license": "MIT", + "keywords": [ + "x-forwarded-for", + "http", + "req" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/forwarded.git" + }, + "devDependencies": { + "istanbul": "0.3.2", + "mocha": "~1.21.4" + }, + "files": [ + "LICENSE", + "HISTORY.md", + "README.md", + "index.js" + ], + "engines": { + "node": ">= 0.6" + }, + "scripts": { + "test": "mocha --reporter spec --bail --check-leaks test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" + }, + "gitHead": "e9a9faeb3cfaadf40eb57d144fff26bca9b818e8", + "bugs": { + "url": "https://github.com/jshttp/forwarded/issues" + }, + "homepage": "https://github.com/jshttp/forwarded", + "_id": "forwarded@0.1.0", + "_shasum": "19ef9874c4ae1c297bcf078fde63a09b66a84363", + "_from": "forwarded@>=0.1.0 <0.2.0", + "_npmVersion": "1.4.21", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "maintainers": [ + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + } + ], + "dist": { + "shasum": "19ef9874c4ae1c297bcf078fde63a09b66a84363", + "tarball": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.0.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/.npmignore b/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/.npmignore index 47627371..7a1537ba 100644 --- a/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/.npmignore +++ b/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/.npmignore @@ -1,2 +1,2 @@ -.idea -node_modules +.idea +node_modules diff --git a/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/.travis.yml b/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/.travis.yml index b023149a..aa3d14ac 100644 --- a/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/.travis.yml +++ b/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/.travis.yml @@ -1,10 +1,10 @@ -language: node_js - -node_js: - - "0.10" - - "0.11" - - "0.12" - - "4.0" - - "4.1" - - "4.2" - - "5" +language: node_js + +node_js: + - "0.10" + - "0.11" + - "0.12" + - "4.0" + - "4.1" + - "4.2" + - "5" diff --git a/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/Cakefile b/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/Cakefile index 547f0270..7fd355a7 100644 --- a/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/Cakefile +++ b/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/Cakefile @@ -1,18 +1,18 @@ -fs = require 'fs' -CoffeeScript = require 'coffee-script' -nodeunit = require 'nodeunit' -UglifyJS = require 'uglify-js' - -task 'build', 'build the JavaScript files from CoffeeScript source', build = (cb) -> - source = fs.readFileSync 'src/ipaddr.coffee' - fs.writeFileSync 'lib/ipaddr.js', CoffeeScript.compile source.toString() - - invoke 'test' - invoke 'compress' - -task 'test', 'run the bundled tests', (cb) -> - nodeunit.reporters.default.run ['test'] - -task 'compress', 'uglify the resulting javascript', (cb) -> - result = UglifyJS.minify('lib/ipaddr.js') - fs.writeFileSync('ipaddr.min.js', result.code) +fs = require 'fs' +CoffeeScript = require 'coffee-script' +nodeunit = require 'nodeunit' +UglifyJS = require 'uglify-js' + +task 'build', 'build the JavaScript files from CoffeeScript source', build = (cb) -> + source = fs.readFileSync 'src/ipaddr.coffee' + fs.writeFileSync 'lib/ipaddr.js', CoffeeScript.compile source.toString() + + invoke 'test' + invoke 'compress' + +task 'test', 'run the bundled tests', (cb) -> + nodeunit.reporters.default.run ['test'] + +task 'compress', 'uglify the resulting javascript', (cb) -> + result = UglifyJS.minify('lib/ipaddr.js') + fs.writeFileSync('ipaddr.min.js', result.code) diff --git a/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/LICENSE b/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/LICENSE index fbb72598..3493f0df 100644 --- a/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/LICENSE +++ b/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/LICENSE @@ -1,19 +1,19 @@ -Copyright (C) 2011 Peter Zotov - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +Copyright (C) 2011 Peter Zotov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/README.md b/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/README.md index f9c3934c..bfcb1c98 100644 --- a/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/README.md +++ b/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/README.md @@ -1,209 +1,209 @@ -# ipaddr.js — an IPv6 and IPv4 address manipulation library [![Build Status](https://travis-ci.org/whitequark/ipaddr.js.svg)](https://travis-ci.org/whitequark/ipaddr.js) - -ipaddr.js is a small (1.9K minified and gzipped) library for manipulating -IP addresses in JavaScript environments. It runs on both CommonJS runtimes -(e.g. [nodejs]) and in a web browser. - -ipaddr.js allows you to verify and parse string representation of an IP -address, match it against a CIDR range or range list, determine if it falls -into some reserved ranges (examples include loopback and private ranges), -and convert between IPv4 and IPv4-mapped IPv6 addresses. - -[nodejs]: http://nodejs.org - -## Installation - -`npm install ipaddr.js` - -or - -`bower install ipaddr.js` - -## API - -ipaddr.js defines one object in the global scope: `ipaddr`. In CommonJS, -it is exported from the module: - -```js -var ipaddr = require('ipaddr.js'); -``` - -The API consists of several global methods and two classes: ipaddr.IPv6 and ipaddr.IPv4. - -### Global methods - -There are three global methods defined: `ipaddr.isValid`, `ipaddr.parse` and -`ipaddr.process`. All of them receive a string as a single parameter. - -The `ipaddr.isValid` method returns `true` if the address is a valid IPv4 or -IPv6 address, and `false` otherwise. It does not throw any exceptions. - -The `ipaddr.parse` method returns an object representing the IP address, -or throws an `Error` if the passed string is not a valid representation of an -IP address. - -The `ipaddr.process` method works just like the `ipaddr.parse` one, but it -automatically converts IPv4-mapped IPv6 addresses to their IPv4 couterparts -before returning. It is useful when you have a Node.js instance listening -on an IPv6 socket, and the `net.ivp6.bindv6only` sysctl parameter (or its -equivalent on non-Linux OS) is set to 0. In this case, you can accept IPv4 -connections on your IPv6-only socket, but the remote address will be mangled. -Use `ipaddr.process` method to automatically demangle it. - -### Object representation - -Parsing methods return an object which descends from `ipaddr.IPv6` or -`ipaddr.IPv4`. These objects share some properties, but most of them differ. - -#### Shared properties - -One can determine the type of address by calling `addr.kind()`. It will return -either `"ipv6"` or `"ipv4"`. - -An address can be converted back to its string representation with `addr.toString()`. -Note that this method: - * does not return the original string used to create the object (in fact, there is - no way of getting that string) - * returns a compact representation (when it is applicable) - -A `match(range, bits)` method can be used to check if the address falls into a -certain CIDR range. -Note that an address can be (obviously) matched only against an address of the same type. - -For example: - -```js -var addr = ipaddr.parse("2001:db8:1234::1"); -var range = ipaddr.parse("2001:db8::"); - -addr.match(range, 32); // => true -``` - -Alternatively, `match` can also be called as `match([range, bits])`. In this way, -it can be used together with the `parseCIDR(string)` method, which parses an IP -address together with a CIDR range. - -For example: - -```js -var addr = ipaddr.parse("2001:db8:1234::1"); - -addr.match(ipaddr.parseCIDR("2001:db8::/32")); // => true -``` - -A `range()` method returns one of predefined names for several special ranges defined -by IP protocols. The exact names (and their respective CIDR ranges) can be looked up -in the source: [IPv6 ranges] and [IPv4 ranges]. Some common ones include `"unicast"` -(the default one) and `"reserved"`. - -You can match against your own range list by using -`ipaddr.subnetMatch(address, rangeList, defaultName)` method. It can work with both -IPv6 and IPv4 addresses, and accepts a name-to-subnet map as the range list. For example: - -```js -var rangeList = { - documentationOnly: [ ipaddr.parse('2001:db8::'), 32 ], - tunnelProviders: [ - [ ipaddr.parse('2001:470::'), 32 ], // he.net - [ ipaddr.parse('2001:5c0::'), 32 ] // freenet6 - ] -}; -ipaddr.subnetMatch(ipaddr.parse('2001:470:8:66::1'), rangeList, 'unknown'); // => "he.net" -``` - -The addresses can be converted to their byte representation with `toByteArray()`. -(Actually, JavaScript mostly does not know about byte buffers. They are emulated with -arrays of numbers, each in range of 0..255.) - -```js -var bytes = ipaddr.parse('2a00:1450:8007::68').toByteArray(); // ipv6.google.com -bytes // => [42, 0x00, 0x14, 0x50, 0x80, 0x07, 0x00, , 0x00, 0x68 ] -``` - -The `ipaddr.IPv4` and `ipaddr.IPv6` objects have some methods defined, too. All of them -have the same interface for both protocols, and are similar to global methods. - -`ipaddr.IPvX.isValid(string)` can be used to check if the string is a valid address -for particular protocol, and `ipaddr.IPvX.parse(string)` is the error-throwing parser. - -[IPv6 ranges]: https://github.com/whitequark/ipaddr.js/blob/master/src/ipaddr.coffee#L186 -[IPv4 ranges]: https://github.com/whitequark/ipaddr.js/blob/master/src/ipaddr.coffee#L71 - -#### IPv6 properties - -Sometimes you will want to convert IPv6 not to a compact string representation (with -the `::` substitution); the `toNormalizedString()` method will return an address where -all zeroes are explicit. - -For example: - -```js -var addr = ipaddr.parse("2001:0db8::0001"); -addr.toString(); // => "2001:db8::1" -addr.toNormalizedString(); // => "2001:db8:0:0:0:0:0:1" -``` - -The `isIPv4MappedAddress()` method will return `true` if this address is an IPv4-mapped -one, and `toIPv4Address()` will return an IPv4 object address. - -To access the underlying binary representation of the address, use `addr.parts`. - -```js -var addr = ipaddr.parse("2001:db8:10::1234:DEAD"); -addr.parts // => [0x2001, 0xdb8, 0x10, 0, 0, 0, 0x1234, 0xdead] -``` - -#### IPv4 properties - -`toIPv4MappedAddress()` will return a corresponding IPv4-mapped IPv6 address. - -To access the underlying representation of the address, use `addr.octets`. - -```js -var addr = ipaddr.parse("192.168.1.1"); -addr.octets // => [192, 168, 1, 1] -``` - -`prefixLengthFromSubnetMask()` will return a CIDR prefix length for a valid IPv4 netmask or -false if the netmask is not valid. - -```js -ipaddr.IPv4.parse('255.255.255.240').prefixLengthFromSubnetMask() == 28 -ipaddr.IPv4.parse('255.192.164.0').prefixLengthFromSubnetMask() == null -``` - -#### Conversion - -IPv4 and IPv6 can be converted bidirectionally to and from network byte order (MSB) byte arrays. - -The `fromByteArray()` method will take an array and create an appropriate IPv4 or IPv6 object -if the input satisfies the requirements. For IPv4 it has to be an array of four 8-bit values, -while for IPv6 it has to be an array of sixteen 8-bit values. - -For example: -```js -var addr = ipaddr.fromByteArray([0x7f, 0, 0, 1]); -addr.toString(); // => "127.0.0.1" -``` - -or - -```js -var addr = ipaddr.fromByteArray([0x20, 1, 0xd, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) -addr.toString(); // => "2001:db8::1" -``` - -Both objects also offer a `toByteArray()` method, which returns an array in network byte order (MSB). - -For example: -```js -var addr = ipaddr.parse("127.0.0.1"); -addr.toByteArray(); // => [0x7f, 0, 0, 1] -``` - -or - -```js -var addr = ipaddr.parse("2001:db8::1"); -addr.toByteArray(); // => [0x20, 1, 0xd, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1] -``` +# ipaddr.js — an IPv6 and IPv4 address manipulation library [![Build Status](https://travis-ci.org/whitequark/ipaddr.js.svg)](https://travis-ci.org/whitequark/ipaddr.js) + +ipaddr.js is a small (1.9K minified and gzipped) library for manipulating +IP addresses in JavaScript environments. It runs on both CommonJS runtimes +(e.g. [nodejs]) and in a web browser. + +ipaddr.js allows you to verify and parse string representation of an IP +address, match it against a CIDR range or range list, determine if it falls +into some reserved ranges (examples include loopback and private ranges), +and convert between IPv4 and IPv4-mapped IPv6 addresses. + +[nodejs]: http://nodejs.org + +## Installation + +`npm install ipaddr.js` + +or + +`bower install ipaddr.js` + +## API + +ipaddr.js defines one object in the global scope: `ipaddr`. In CommonJS, +it is exported from the module: + +```js +var ipaddr = require('ipaddr.js'); +``` + +The API consists of several global methods and two classes: ipaddr.IPv6 and ipaddr.IPv4. + +### Global methods + +There are three global methods defined: `ipaddr.isValid`, `ipaddr.parse` and +`ipaddr.process`. All of them receive a string as a single parameter. + +The `ipaddr.isValid` method returns `true` if the address is a valid IPv4 or +IPv6 address, and `false` otherwise. It does not throw any exceptions. + +The `ipaddr.parse` method returns an object representing the IP address, +or throws an `Error` if the passed string is not a valid representation of an +IP address. + +The `ipaddr.process` method works just like the `ipaddr.parse` one, but it +automatically converts IPv4-mapped IPv6 addresses to their IPv4 couterparts +before returning. It is useful when you have a Node.js instance listening +on an IPv6 socket, and the `net.ivp6.bindv6only` sysctl parameter (or its +equivalent on non-Linux OS) is set to 0. In this case, you can accept IPv4 +connections on your IPv6-only socket, but the remote address will be mangled. +Use `ipaddr.process` method to automatically demangle it. + +### Object representation + +Parsing methods return an object which descends from `ipaddr.IPv6` or +`ipaddr.IPv4`. These objects share some properties, but most of them differ. + +#### Shared properties + +One can determine the type of address by calling `addr.kind()`. It will return +either `"ipv6"` or `"ipv4"`. + +An address can be converted back to its string representation with `addr.toString()`. +Note that this method: + * does not return the original string used to create the object (in fact, there is + no way of getting that string) + * returns a compact representation (when it is applicable) + +A `match(range, bits)` method can be used to check if the address falls into a +certain CIDR range. +Note that an address can be (obviously) matched only against an address of the same type. + +For example: + +```js +var addr = ipaddr.parse("2001:db8:1234::1"); +var range = ipaddr.parse("2001:db8::"); + +addr.match(range, 32); // => true +``` + +Alternatively, `match` can also be called as `match([range, bits])`. In this way, +it can be used together with the `parseCIDR(string)` method, which parses an IP +address together with a CIDR range. + +For example: + +```js +var addr = ipaddr.parse("2001:db8:1234::1"); + +addr.match(ipaddr.parseCIDR("2001:db8::/32")); // => true +``` + +A `range()` method returns one of predefined names for several special ranges defined +by IP protocols. The exact names (and their respective CIDR ranges) can be looked up +in the source: [IPv6 ranges] and [IPv4 ranges]. Some common ones include `"unicast"` +(the default one) and `"reserved"`. + +You can match against your own range list by using +`ipaddr.subnetMatch(address, rangeList, defaultName)` method. It can work with both +IPv6 and IPv4 addresses, and accepts a name-to-subnet map as the range list. For example: + +```js +var rangeList = { + documentationOnly: [ ipaddr.parse('2001:db8::'), 32 ], + tunnelProviders: [ + [ ipaddr.parse('2001:470::'), 32 ], // he.net + [ ipaddr.parse('2001:5c0::'), 32 ] // freenet6 + ] +}; +ipaddr.subnetMatch(ipaddr.parse('2001:470:8:66::1'), rangeList, 'unknown'); // => "he.net" +``` + +The addresses can be converted to their byte representation with `toByteArray()`. +(Actually, JavaScript mostly does not know about byte buffers. They are emulated with +arrays of numbers, each in range of 0..255.) + +```js +var bytes = ipaddr.parse('2a00:1450:8007::68').toByteArray(); // ipv6.google.com +bytes // => [42, 0x00, 0x14, 0x50, 0x80, 0x07, 0x00, , 0x00, 0x68 ] +``` + +The `ipaddr.IPv4` and `ipaddr.IPv6` objects have some methods defined, too. All of them +have the same interface for both protocols, and are similar to global methods. + +`ipaddr.IPvX.isValid(string)` can be used to check if the string is a valid address +for particular protocol, and `ipaddr.IPvX.parse(string)` is the error-throwing parser. + +[IPv6 ranges]: https://github.com/whitequark/ipaddr.js/blob/master/src/ipaddr.coffee#L186 +[IPv4 ranges]: https://github.com/whitequark/ipaddr.js/blob/master/src/ipaddr.coffee#L71 + +#### IPv6 properties + +Sometimes you will want to convert IPv6 not to a compact string representation (with +the `::` substitution); the `toNormalizedString()` method will return an address where +all zeroes are explicit. + +For example: + +```js +var addr = ipaddr.parse("2001:0db8::0001"); +addr.toString(); // => "2001:db8::1" +addr.toNormalizedString(); // => "2001:db8:0:0:0:0:0:1" +``` + +The `isIPv4MappedAddress()` method will return `true` if this address is an IPv4-mapped +one, and `toIPv4Address()` will return an IPv4 object address. + +To access the underlying binary representation of the address, use `addr.parts`. + +```js +var addr = ipaddr.parse("2001:db8:10::1234:DEAD"); +addr.parts // => [0x2001, 0xdb8, 0x10, 0, 0, 0, 0x1234, 0xdead] +``` + +#### IPv4 properties + +`toIPv4MappedAddress()` will return a corresponding IPv4-mapped IPv6 address. + +To access the underlying representation of the address, use `addr.octets`. + +```js +var addr = ipaddr.parse("192.168.1.1"); +addr.octets // => [192, 168, 1, 1] +``` + +`prefixLengthFromSubnetMask()` will return a CIDR prefix length for a valid IPv4 netmask or +false if the netmask is not valid. + +```js +ipaddr.IPv4.parse('255.255.255.240').prefixLengthFromSubnetMask() == 28 +ipaddr.IPv4.parse('255.192.164.0').prefixLengthFromSubnetMask() == null +``` + +#### Conversion + +IPv4 and IPv6 can be converted bidirectionally to and from network byte order (MSB) byte arrays. + +The `fromByteArray()` method will take an array and create an appropriate IPv4 or IPv6 object +if the input satisfies the requirements. For IPv4 it has to be an array of four 8-bit values, +while for IPv6 it has to be an array of sixteen 8-bit values. + +For example: +```js +var addr = ipaddr.fromByteArray([0x7f, 0, 0, 1]); +addr.toString(); // => "127.0.0.1" +``` + +or + +```js +var addr = ipaddr.fromByteArray([0x20, 1, 0xd, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) +addr.toString(); // => "2001:db8::1" +``` + +Both objects also offer a `toByteArray()` method, which returns an array in network byte order (MSB). + +For example: +```js +var addr = ipaddr.parse("127.0.0.1"); +addr.toByteArray(); // => [0x7f, 0, 0, 1] +``` + +or + +```js +var addr = ipaddr.parse("2001:db8::1"); +addr.toByteArray(); // => [0x20, 1, 0xd, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1] +``` diff --git a/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/bower.json b/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/bower.json index 1123e4ef..e494f972 100644 --- a/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/bower.json +++ b/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/bower.json @@ -1,29 +1,29 @@ -{ - "name": "ipaddr.js", - "version": "1.1.1", - "homepage": "https://github.com/whitequark/ipaddr.js", - "authors": [ - "whitequark " - ], - "description": "IP address manipulation library in JavaScript (CoffeeScript, actually)", - "main": "lib/ipaddr.js", - "moduleType": [ - "globals", - "node" - ], - "keywords": [ - "javscript", - "ip", - "address", - "ipv4", - "ipv6" - ], - "license": "MIT", - "ignore": [ - "**/.*", - "node_modules", - "bower_components", - "test", - "tests" - ] -} +{ + "name": "ipaddr.js", + "version": "1.1.1", + "homepage": "https://github.com/whitequark/ipaddr.js", + "authors": [ + "whitequark " + ], + "description": "IP address manipulation library in JavaScript (CoffeeScript, actually)", + "main": "lib/ipaddr.js", + "moduleType": [ + "globals", + "node" + ], + "keywords": [ + "javscript", + "ip", + "address", + "ipv4", + "ipv6" + ], + "license": "MIT", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ] +} diff --git a/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/lib/ipaddr.js b/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/lib/ipaddr.js index d5f16743..36774e79 100644 --- a/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/lib/ipaddr.js +++ b/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/lib/ipaddr.js @@ -1,526 +1,526 @@ -(function() { - var expandIPv6, ipaddr, ipv4Part, ipv4Regexes, ipv6Part, ipv6Regexes, matchCIDR, root; - - ipaddr = {}; - - root = this; - - if ((typeof module !== "undefined" && module !== null) && module.exports) { - module.exports = ipaddr; - } else { - root['ipaddr'] = ipaddr; - } - - matchCIDR = function(first, second, partSize, cidrBits) { - var part, shift; - if (first.length !== second.length) { - throw new Error("ipaddr: cannot match CIDR for objects with different lengths"); - } - part = 0; - while (cidrBits > 0) { - shift = partSize - cidrBits; - if (shift < 0) { - shift = 0; - } - if (first[part] >> shift !== second[part] >> shift) { - return false; - } - cidrBits -= partSize; - part += 1; - } - return true; - }; - - ipaddr.subnetMatch = function(address, rangeList, defaultName) { - var rangeName, rangeSubnets, subnet, _i, _len; - if (defaultName == null) { - defaultName = 'unicast'; - } - for (rangeName in rangeList) { - rangeSubnets = rangeList[rangeName]; - if (rangeSubnets[0] && !(rangeSubnets[0] instanceof Array)) { - rangeSubnets = [rangeSubnets]; - } - for (_i = 0, _len = rangeSubnets.length; _i < _len; _i++) { - subnet = rangeSubnets[_i]; - if (address.match.apply(address, subnet)) { - return rangeName; - } - } - } - return defaultName; - }; - - ipaddr.IPv4 = (function() { - function IPv4(octets) { - var octet, _i, _len; - if (octets.length !== 4) { - throw new Error("ipaddr: ipv4 octet count should be 4"); - } - for (_i = 0, _len = octets.length; _i < _len; _i++) { - octet = octets[_i]; - if (!((0 <= octet && octet <= 255))) { - throw new Error("ipaddr: ipv4 octet should fit in 8 bits"); - } - } - this.octets = octets; - } - - IPv4.prototype.kind = function() { - return 'ipv4'; - }; - - IPv4.prototype.toString = function() { - return this.octets.join("."); - }; - - IPv4.prototype.toByteArray = function() { - return this.octets.slice(0); - }; - - IPv4.prototype.match = function(other, cidrRange) { - var _ref; - if (cidrRange === void 0) { - _ref = other, other = _ref[0], cidrRange = _ref[1]; - } - if (other.kind() !== 'ipv4') { - throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one"); - } - return matchCIDR(this.octets, other.octets, 8, cidrRange); - }; - - IPv4.prototype.SpecialRanges = { - unspecified: [[new IPv4([0, 0, 0, 0]), 8]], - broadcast: [[new IPv4([255, 255, 255, 255]), 32]], - multicast: [[new IPv4([224, 0, 0, 0]), 4]], - linkLocal: [[new IPv4([169, 254, 0, 0]), 16]], - loopback: [[new IPv4([127, 0, 0, 0]), 8]], - "private": [[new IPv4([10, 0, 0, 0]), 8], [new IPv4([172, 16, 0, 0]), 12], [new IPv4([192, 168, 0, 0]), 16]], - reserved: [[new IPv4([192, 0, 0, 0]), 24], [new IPv4([192, 0, 2, 0]), 24], [new IPv4([192, 88, 99, 0]), 24], [new IPv4([198, 51, 100, 0]), 24], [new IPv4([203, 0, 113, 0]), 24], [new IPv4([240, 0, 0, 0]), 4]] - }; - - IPv4.prototype.range = function() { - return ipaddr.subnetMatch(this, this.SpecialRanges); - }; - - IPv4.prototype.toIPv4MappedAddress = function() { - return ipaddr.IPv6.parse("::ffff:" + (this.toString())); - }; - - IPv4.prototype.prefixLengthFromSubnetMask = function() { - var cidr, i, octet, stop, zeros, zerotable, _i; - zerotable = { - 0: 8, - 128: 7, - 192: 6, - 224: 5, - 240: 4, - 248: 3, - 252: 2, - 254: 1, - 255: 0 - }; - cidr = 0; - stop = false; - for (i = _i = 3; _i >= 0; i = _i += -1) { - octet = this.octets[i]; - if (octet in zerotable) { - zeros = zerotable[octet]; - if (stop && zeros !== 0) { - return null; - } - if (zeros !== 8) { - stop = true; - } - cidr += zeros; - } else { - return null; - } - } - return 32 - cidr; - }; - - return IPv4; - - })(); - - ipv4Part = "(0?\\d+|0x[a-f0-9]+)"; - - ipv4Regexes = { - fourOctet: new RegExp("^" + ipv4Part + "\\." + ipv4Part + "\\." + ipv4Part + "\\." + ipv4Part + "$", 'i'), - longValue: new RegExp("^" + ipv4Part + "$", 'i') - }; - - ipaddr.IPv4.parser = function(string) { - var match, parseIntAuto, part, shift, value; - parseIntAuto = function(string) { - if (string[0] === "0" && string[1] !== "x") { - return parseInt(string, 8); - } else { - return parseInt(string); - } - }; - if (match = string.match(ipv4Regexes.fourOctet)) { - return (function() { - var _i, _len, _ref, _results; - _ref = match.slice(1, 6); - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - part = _ref[_i]; - _results.push(parseIntAuto(part)); - } - return _results; - })(); - } else if (match = string.match(ipv4Regexes.longValue)) { - value = parseIntAuto(match[1]); - if (value > 0xffffffff || value < 0) { - throw new Error("ipaddr: address outside defined range"); - } - return ((function() { - var _i, _results; - _results = []; - for (shift = _i = 0; _i <= 24; shift = _i += 8) { - _results.push((value >> shift) & 0xff); - } - return _results; - })()).reverse(); - } else { - return null; - } - }; - - ipaddr.IPv6 = (function() { - function IPv6(parts) { - var i, part, _i, _j, _len, _ref; - if (parts.length === 16) { - this.parts = []; - for (i = _i = 0; _i <= 14; i = _i += 2) { - this.parts.push((parts[i] << 8) | parts[i + 1]); - } - } else if (parts.length === 8) { - this.parts = parts; - } else { - throw new Error("ipaddr: ipv6 part count should be 8 or 16"); - } - _ref = this.parts; - for (_j = 0, _len = _ref.length; _j < _len; _j++) { - part = _ref[_j]; - if (!((0 <= part && part <= 0xffff))) { - throw new Error("ipaddr: ipv6 part should fit in 16 bits"); - } - } - } - - IPv6.prototype.kind = function() { - return 'ipv6'; - }; - - IPv6.prototype.toString = function() { - var compactStringParts, part, pushPart, state, stringParts, _i, _len; - stringParts = (function() { - var _i, _len, _ref, _results; - _ref = this.parts; - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - part = _ref[_i]; - _results.push(part.toString(16)); - } - return _results; - }).call(this); - compactStringParts = []; - pushPart = function(part) { - return compactStringParts.push(part); - }; - state = 0; - for (_i = 0, _len = stringParts.length; _i < _len; _i++) { - part = stringParts[_i]; - switch (state) { - case 0: - if (part === '0') { - pushPart(''); - } else { - pushPart(part); - } - state = 1; - break; - case 1: - if (part === '0') { - state = 2; - } else { - pushPart(part); - } - break; - case 2: - if (part !== '0') { - pushPart(''); - pushPart(part); - state = 3; - } - break; - case 3: - pushPart(part); - } - } - if (state === 2) { - pushPart(''); - pushPart(''); - } - return compactStringParts.join(":"); - }; - - IPv6.prototype.toByteArray = function() { - var bytes, part, _i, _len, _ref; - bytes = []; - _ref = this.parts; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - part = _ref[_i]; - bytes.push(part >> 8); - bytes.push(part & 0xff); - } - return bytes; - }; - - IPv6.prototype.toNormalizedString = function() { - var part; - return ((function() { - var _i, _len, _ref, _results; - _ref = this.parts; - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - part = _ref[_i]; - _results.push(part.toString(16)); - } - return _results; - }).call(this)).join(":"); - }; - - IPv6.prototype.match = function(other, cidrRange) { - var _ref; - if (cidrRange === void 0) { - _ref = other, other = _ref[0], cidrRange = _ref[1]; - } - if (other.kind() !== 'ipv6') { - throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one"); - } - return matchCIDR(this.parts, other.parts, 16, cidrRange); - }; - - IPv6.prototype.SpecialRanges = { - unspecified: [new IPv6([0, 0, 0, 0, 0, 0, 0, 0]), 128], - linkLocal: [new IPv6([0xfe80, 0, 0, 0, 0, 0, 0, 0]), 10], - multicast: [new IPv6([0xff00, 0, 0, 0, 0, 0, 0, 0]), 8], - loopback: [new IPv6([0, 0, 0, 0, 0, 0, 0, 1]), 128], - uniqueLocal: [new IPv6([0xfc00, 0, 0, 0, 0, 0, 0, 0]), 7], - ipv4Mapped: [new IPv6([0, 0, 0, 0, 0, 0xffff, 0, 0]), 96], - rfc6145: [new IPv6([0, 0, 0, 0, 0xffff, 0, 0, 0]), 96], - rfc6052: [new IPv6([0x64, 0xff9b, 0, 0, 0, 0, 0, 0]), 96], - '6to4': [new IPv6([0x2002, 0, 0, 0, 0, 0, 0, 0]), 16], - teredo: [new IPv6([0x2001, 0, 0, 0, 0, 0, 0, 0]), 32], - reserved: [[new IPv6([0x2001, 0xdb8, 0, 0, 0, 0, 0, 0]), 32]] - }; - - IPv6.prototype.range = function() { - return ipaddr.subnetMatch(this, this.SpecialRanges); - }; - - IPv6.prototype.isIPv4MappedAddress = function() { - return this.range() === 'ipv4Mapped'; - }; - - IPv6.prototype.toIPv4Address = function() { - var high, low, _ref; - if (!this.isIPv4MappedAddress()) { - throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4"); - } - _ref = this.parts.slice(-2), high = _ref[0], low = _ref[1]; - return new ipaddr.IPv4([high >> 8, high & 0xff, low >> 8, low & 0xff]); - }; - - return IPv6; - - })(); - - ipv6Part = "(?:[0-9a-f]+::?)+"; - - ipv6Regexes = { - "native": new RegExp("^(::)?(" + ipv6Part + ")?([0-9a-f]+)?(::)?$", 'i'), - transitional: new RegExp(("^((?:" + ipv6Part + ")|(?:::)(?:" + ipv6Part + ")?)") + ("" + ipv4Part + "\\." + ipv4Part + "\\." + ipv4Part + "\\." + ipv4Part + "$"), 'i') - }; - - expandIPv6 = function(string, parts) { - var colonCount, lastColon, part, replacement, replacementCount; - if (string.indexOf('::') !== string.lastIndexOf('::')) { - return null; - } - colonCount = 0; - lastColon = -1; - while ((lastColon = string.indexOf(':', lastColon + 1)) >= 0) { - colonCount++; - } - if (string.substr(0, 2) === '::') { - colonCount--; - } - if (string.substr(-2, 2) === '::') { - colonCount--; - } - if (colonCount > parts) { - return null; - } - replacementCount = parts - colonCount; - replacement = ':'; - while (replacementCount--) { - replacement += '0:'; - } - string = string.replace('::', replacement); - if (string[0] === ':') { - string = string.slice(1); - } - if (string[string.length - 1] === ':') { - string = string.slice(0, -1); - } - return (function() { - var _i, _len, _ref, _results; - _ref = string.split(":"); - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - part = _ref[_i]; - _results.push(parseInt(part, 16)); - } - return _results; - })(); - }; - - ipaddr.IPv6.parser = function(string) { - var match, octet, octets, parts, _i, _len; - if (string.match(ipv6Regexes['native'])) { - return expandIPv6(string, 8); - } else if (match = string.match(ipv6Regexes['transitional'])) { - parts = expandIPv6(match[1].slice(0, -1), 6); - if (parts) { - octets = [parseInt(match[2]), parseInt(match[3]), parseInt(match[4]), parseInt(match[5])]; - for (_i = 0, _len = octets.length; _i < _len; _i++) { - octet = octets[_i]; - if (!((0 <= octet && octet <= 255))) { - return null; - } - } - parts.push(octets[0] << 8 | octets[1]); - parts.push(octets[2] << 8 | octets[3]); - return parts; - } - } - return null; - }; - - ipaddr.IPv4.isIPv4 = ipaddr.IPv6.isIPv6 = function(string) { - return this.parser(string) !== null; - }; - - ipaddr.IPv4.isValid = function(string) { - var e; - try { - new this(this.parser(string)); - return true; - } catch (_error) { - e = _error; - return false; - } - }; - - ipaddr.IPv6.isValid = function(string) { - var e; - if (typeof string === "string" && string.indexOf(":") === -1) { - return false; - } - try { - new this(this.parser(string)); - return true; - } catch (_error) { - e = _error; - return false; - } - }; - - ipaddr.IPv4.parse = ipaddr.IPv6.parse = function(string) { - var parts; - parts = this.parser(string); - if (parts === null) { - throw new Error("ipaddr: string is not formatted like ip address"); - } - return new this(parts); - }; - - ipaddr.IPv4.parseCIDR = function(string) { - var maskLength, match; - if (match = string.match(/^(.+)\/(\d+)$/)) { - maskLength = parseInt(match[2]); - if (maskLength >= 0 && maskLength <= 32) { - return [this.parse(match[1]), maskLength]; - } - } - throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range"); - }; - - ipaddr.IPv6.parseCIDR = function(string) { - var maskLength, match; - if (match = string.match(/^(.+)\/(\d+)$/)) { - maskLength = parseInt(match[2]); - if (maskLength >= 0 && maskLength <= 128) { - return [this.parse(match[1]), maskLength]; - } - } - throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range"); - }; - - ipaddr.isValid = function(string) { - return ipaddr.IPv6.isValid(string) || ipaddr.IPv4.isValid(string); - }; - - ipaddr.parse = function(string) { - if (ipaddr.IPv6.isValid(string)) { - return ipaddr.IPv6.parse(string); - } else if (ipaddr.IPv4.isValid(string)) { - return ipaddr.IPv4.parse(string); - } else { - throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format"); - } - }; - - ipaddr.parseCIDR = function(string) { - var e; - try { - return ipaddr.IPv6.parseCIDR(string); - } catch (_error) { - e = _error; - try { - return ipaddr.IPv4.parseCIDR(string); - } catch (_error) { - e = _error; - throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format"); - } - } - }; - - ipaddr.fromByteArray = function(bytes) { - var length; - length = bytes.length; - if (length === 4) { - return new ipaddr.IPv4(bytes); - } else if (length === 16) { - return new ipaddr.IPv6(bytes); - } else { - throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address"); - } - }; - - ipaddr.process = function(string) { - var addr; - addr = this.parse(string); - if (addr.kind() === 'ipv6' && addr.isIPv4MappedAddress()) { - return addr.toIPv4Address(); - } else { - return addr; - } - }; - -}).call(this); +(function() { + var expandIPv6, ipaddr, ipv4Part, ipv4Regexes, ipv6Part, ipv6Regexes, matchCIDR, root; + + ipaddr = {}; + + root = this; + + if ((typeof module !== "undefined" && module !== null) && module.exports) { + module.exports = ipaddr; + } else { + root['ipaddr'] = ipaddr; + } + + matchCIDR = function(first, second, partSize, cidrBits) { + var part, shift; + if (first.length !== second.length) { + throw new Error("ipaddr: cannot match CIDR for objects with different lengths"); + } + part = 0; + while (cidrBits > 0) { + shift = partSize - cidrBits; + if (shift < 0) { + shift = 0; + } + if (first[part] >> shift !== second[part] >> shift) { + return false; + } + cidrBits -= partSize; + part += 1; + } + return true; + }; + + ipaddr.subnetMatch = function(address, rangeList, defaultName) { + var rangeName, rangeSubnets, subnet, _i, _len; + if (defaultName == null) { + defaultName = 'unicast'; + } + for (rangeName in rangeList) { + rangeSubnets = rangeList[rangeName]; + if (rangeSubnets[0] && !(rangeSubnets[0] instanceof Array)) { + rangeSubnets = [rangeSubnets]; + } + for (_i = 0, _len = rangeSubnets.length; _i < _len; _i++) { + subnet = rangeSubnets[_i]; + if (address.match.apply(address, subnet)) { + return rangeName; + } + } + } + return defaultName; + }; + + ipaddr.IPv4 = (function() { + function IPv4(octets) { + var octet, _i, _len; + if (octets.length !== 4) { + throw new Error("ipaddr: ipv4 octet count should be 4"); + } + for (_i = 0, _len = octets.length; _i < _len; _i++) { + octet = octets[_i]; + if (!((0 <= octet && octet <= 255))) { + throw new Error("ipaddr: ipv4 octet should fit in 8 bits"); + } + } + this.octets = octets; + } + + IPv4.prototype.kind = function() { + return 'ipv4'; + }; + + IPv4.prototype.toString = function() { + return this.octets.join("."); + }; + + IPv4.prototype.toByteArray = function() { + return this.octets.slice(0); + }; + + IPv4.prototype.match = function(other, cidrRange) { + var _ref; + if (cidrRange === void 0) { + _ref = other, other = _ref[0], cidrRange = _ref[1]; + } + if (other.kind() !== 'ipv4') { + throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one"); + } + return matchCIDR(this.octets, other.octets, 8, cidrRange); + }; + + IPv4.prototype.SpecialRanges = { + unspecified: [[new IPv4([0, 0, 0, 0]), 8]], + broadcast: [[new IPv4([255, 255, 255, 255]), 32]], + multicast: [[new IPv4([224, 0, 0, 0]), 4]], + linkLocal: [[new IPv4([169, 254, 0, 0]), 16]], + loopback: [[new IPv4([127, 0, 0, 0]), 8]], + "private": [[new IPv4([10, 0, 0, 0]), 8], [new IPv4([172, 16, 0, 0]), 12], [new IPv4([192, 168, 0, 0]), 16]], + reserved: [[new IPv4([192, 0, 0, 0]), 24], [new IPv4([192, 0, 2, 0]), 24], [new IPv4([192, 88, 99, 0]), 24], [new IPv4([198, 51, 100, 0]), 24], [new IPv4([203, 0, 113, 0]), 24], [new IPv4([240, 0, 0, 0]), 4]] + }; + + IPv4.prototype.range = function() { + return ipaddr.subnetMatch(this, this.SpecialRanges); + }; + + IPv4.prototype.toIPv4MappedAddress = function() { + return ipaddr.IPv6.parse("::ffff:" + (this.toString())); + }; + + IPv4.prototype.prefixLengthFromSubnetMask = function() { + var cidr, i, octet, stop, zeros, zerotable, _i; + zerotable = { + 0: 8, + 128: 7, + 192: 6, + 224: 5, + 240: 4, + 248: 3, + 252: 2, + 254: 1, + 255: 0 + }; + cidr = 0; + stop = false; + for (i = _i = 3; _i >= 0; i = _i += -1) { + octet = this.octets[i]; + if (octet in zerotable) { + zeros = zerotable[octet]; + if (stop && zeros !== 0) { + return null; + } + if (zeros !== 8) { + stop = true; + } + cidr += zeros; + } else { + return null; + } + } + return 32 - cidr; + }; + + return IPv4; + + })(); + + ipv4Part = "(0?\\d+|0x[a-f0-9]+)"; + + ipv4Regexes = { + fourOctet: new RegExp("^" + ipv4Part + "\\." + ipv4Part + "\\." + ipv4Part + "\\." + ipv4Part + "$", 'i'), + longValue: new RegExp("^" + ipv4Part + "$", 'i') + }; + + ipaddr.IPv4.parser = function(string) { + var match, parseIntAuto, part, shift, value; + parseIntAuto = function(string) { + if (string[0] === "0" && string[1] !== "x") { + return parseInt(string, 8); + } else { + return parseInt(string); + } + }; + if (match = string.match(ipv4Regexes.fourOctet)) { + return (function() { + var _i, _len, _ref, _results; + _ref = match.slice(1, 6); + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + part = _ref[_i]; + _results.push(parseIntAuto(part)); + } + return _results; + })(); + } else if (match = string.match(ipv4Regexes.longValue)) { + value = parseIntAuto(match[1]); + if (value > 0xffffffff || value < 0) { + throw new Error("ipaddr: address outside defined range"); + } + return ((function() { + var _i, _results; + _results = []; + for (shift = _i = 0; _i <= 24; shift = _i += 8) { + _results.push((value >> shift) & 0xff); + } + return _results; + })()).reverse(); + } else { + return null; + } + }; + + ipaddr.IPv6 = (function() { + function IPv6(parts) { + var i, part, _i, _j, _len, _ref; + if (parts.length === 16) { + this.parts = []; + for (i = _i = 0; _i <= 14; i = _i += 2) { + this.parts.push((parts[i] << 8) | parts[i + 1]); + } + } else if (parts.length === 8) { + this.parts = parts; + } else { + throw new Error("ipaddr: ipv6 part count should be 8 or 16"); + } + _ref = this.parts; + for (_j = 0, _len = _ref.length; _j < _len; _j++) { + part = _ref[_j]; + if (!((0 <= part && part <= 0xffff))) { + throw new Error("ipaddr: ipv6 part should fit in 16 bits"); + } + } + } + + IPv6.prototype.kind = function() { + return 'ipv6'; + }; + + IPv6.prototype.toString = function() { + var compactStringParts, part, pushPart, state, stringParts, _i, _len; + stringParts = (function() { + var _i, _len, _ref, _results; + _ref = this.parts; + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + part = _ref[_i]; + _results.push(part.toString(16)); + } + return _results; + }).call(this); + compactStringParts = []; + pushPart = function(part) { + return compactStringParts.push(part); + }; + state = 0; + for (_i = 0, _len = stringParts.length; _i < _len; _i++) { + part = stringParts[_i]; + switch (state) { + case 0: + if (part === '0') { + pushPart(''); + } else { + pushPart(part); + } + state = 1; + break; + case 1: + if (part === '0') { + state = 2; + } else { + pushPart(part); + } + break; + case 2: + if (part !== '0') { + pushPart(''); + pushPart(part); + state = 3; + } + break; + case 3: + pushPart(part); + } + } + if (state === 2) { + pushPart(''); + pushPart(''); + } + return compactStringParts.join(":"); + }; + + IPv6.prototype.toByteArray = function() { + var bytes, part, _i, _len, _ref; + bytes = []; + _ref = this.parts; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + part = _ref[_i]; + bytes.push(part >> 8); + bytes.push(part & 0xff); + } + return bytes; + }; + + IPv6.prototype.toNormalizedString = function() { + var part; + return ((function() { + var _i, _len, _ref, _results; + _ref = this.parts; + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + part = _ref[_i]; + _results.push(part.toString(16)); + } + return _results; + }).call(this)).join(":"); + }; + + IPv6.prototype.match = function(other, cidrRange) { + var _ref; + if (cidrRange === void 0) { + _ref = other, other = _ref[0], cidrRange = _ref[1]; + } + if (other.kind() !== 'ipv6') { + throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one"); + } + return matchCIDR(this.parts, other.parts, 16, cidrRange); + }; + + IPv6.prototype.SpecialRanges = { + unspecified: [new IPv6([0, 0, 0, 0, 0, 0, 0, 0]), 128], + linkLocal: [new IPv6([0xfe80, 0, 0, 0, 0, 0, 0, 0]), 10], + multicast: [new IPv6([0xff00, 0, 0, 0, 0, 0, 0, 0]), 8], + loopback: [new IPv6([0, 0, 0, 0, 0, 0, 0, 1]), 128], + uniqueLocal: [new IPv6([0xfc00, 0, 0, 0, 0, 0, 0, 0]), 7], + ipv4Mapped: [new IPv6([0, 0, 0, 0, 0, 0xffff, 0, 0]), 96], + rfc6145: [new IPv6([0, 0, 0, 0, 0xffff, 0, 0, 0]), 96], + rfc6052: [new IPv6([0x64, 0xff9b, 0, 0, 0, 0, 0, 0]), 96], + '6to4': [new IPv6([0x2002, 0, 0, 0, 0, 0, 0, 0]), 16], + teredo: [new IPv6([0x2001, 0, 0, 0, 0, 0, 0, 0]), 32], + reserved: [[new IPv6([0x2001, 0xdb8, 0, 0, 0, 0, 0, 0]), 32]] + }; + + IPv6.prototype.range = function() { + return ipaddr.subnetMatch(this, this.SpecialRanges); + }; + + IPv6.prototype.isIPv4MappedAddress = function() { + return this.range() === 'ipv4Mapped'; + }; + + IPv6.prototype.toIPv4Address = function() { + var high, low, _ref; + if (!this.isIPv4MappedAddress()) { + throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4"); + } + _ref = this.parts.slice(-2), high = _ref[0], low = _ref[1]; + return new ipaddr.IPv4([high >> 8, high & 0xff, low >> 8, low & 0xff]); + }; + + return IPv6; + + })(); + + ipv6Part = "(?:[0-9a-f]+::?)+"; + + ipv6Regexes = { + "native": new RegExp("^(::)?(" + ipv6Part + ")?([0-9a-f]+)?(::)?$", 'i'), + transitional: new RegExp(("^((?:" + ipv6Part + ")|(?:::)(?:" + ipv6Part + ")?)") + ("" + ipv4Part + "\\." + ipv4Part + "\\." + ipv4Part + "\\." + ipv4Part + "$"), 'i') + }; + + expandIPv6 = function(string, parts) { + var colonCount, lastColon, part, replacement, replacementCount; + if (string.indexOf('::') !== string.lastIndexOf('::')) { + return null; + } + colonCount = 0; + lastColon = -1; + while ((lastColon = string.indexOf(':', lastColon + 1)) >= 0) { + colonCount++; + } + if (string.substr(0, 2) === '::') { + colonCount--; + } + if (string.substr(-2, 2) === '::') { + colonCount--; + } + if (colonCount > parts) { + return null; + } + replacementCount = parts - colonCount; + replacement = ':'; + while (replacementCount--) { + replacement += '0:'; + } + string = string.replace('::', replacement); + if (string[0] === ':') { + string = string.slice(1); + } + if (string[string.length - 1] === ':') { + string = string.slice(0, -1); + } + return (function() { + var _i, _len, _ref, _results; + _ref = string.split(":"); + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + part = _ref[_i]; + _results.push(parseInt(part, 16)); + } + return _results; + })(); + }; + + ipaddr.IPv6.parser = function(string) { + var match, octet, octets, parts, _i, _len; + if (string.match(ipv6Regexes['native'])) { + return expandIPv6(string, 8); + } else if (match = string.match(ipv6Regexes['transitional'])) { + parts = expandIPv6(match[1].slice(0, -1), 6); + if (parts) { + octets = [parseInt(match[2]), parseInt(match[3]), parseInt(match[4]), parseInt(match[5])]; + for (_i = 0, _len = octets.length; _i < _len; _i++) { + octet = octets[_i]; + if (!((0 <= octet && octet <= 255))) { + return null; + } + } + parts.push(octets[0] << 8 | octets[1]); + parts.push(octets[2] << 8 | octets[3]); + return parts; + } + } + return null; + }; + + ipaddr.IPv4.isIPv4 = ipaddr.IPv6.isIPv6 = function(string) { + return this.parser(string) !== null; + }; + + ipaddr.IPv4.isValid = function(string) { + var e; + try { + new this(this.parser(string)); + return true; + } catch (_error) { + e = _error; + return false; + } + }; + + ipaddr.IPv6.isValid = function(string) { + var e; + if (typeof string === "string" && string.indexOf(":") === -1) { + return false; + } + try { + new this(this.parser(string)); + return true; + } catch (_error) { + e = _error; + return false; + } + }; + + ipaddr.IPv4.parse = ipaddr.IPv6.parse = function(string) { + var parts; + parts = this.parser(string); + if (parts === null) { + throw new Error("ipaddr: string is not formatted like ip address"); + } + return new this(parts); + }; + + ipaddr.IPv4.parseCIDR = function(string) { + var maskLength, match; + if (match = string.match(/^(.+)\/(\d+)$/)) { + maskLength = parseInt(match[2]); + if (maskLength >= 0 && maskLength <= 32) { + return [this.parse(match[1]), maskLength]; + } + } + throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range"); + }; + + ipaddr.IPv6.parseCIDR = function(string) { + var maskLength, match; + if (match = string.match(/^(.+)\/(\d+)$/)) { + maskLength = parseInt(match[2]); + if (maskLength >= 0 && maskLength <= 128) { + return [this.parse(match[1]), maskLength]; + } + } + throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range"); + }; + + ipaddr.isValid = function(string) { + return ipaddr.IPv6.isValid(string) || ipaddr.IPv4.isValid(string); + }; + + ipaddr.parse = function(string) { + if (ipaddr.IPv6.isValid(string)) { + return ipaddr.IPv6.parse(string); + } else if (ipaddr.IPv4.isValid(string)) { + return ipaddr.IPv4.parse(string); + } else { + throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format"); + } + }; + + ipaddr.parseCIDR = function(string) { + var e; + try { + return ipaddr.IPv6.parseCIDR(string); + } catch (_error) { + e = _error; + try { + return ipaddr.IPv4.parseCIDR(string); + } catch (_error) { + e = _error; + throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format"); + } + } + }; + + ipaddr.fromByteArray = function(bytes) { + var length; + length = bytes.length; + if (length === 4) { + return new ipaddr.IPv4(bytes); + } else if (length === 16) { + return new ipaddr.IPv6(bytes); + } else { + throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address"); + } + }; + + ipaddr.process = function(string) { + var addr; + addr = this.parse(string); + if (addr.kind() === 'ipv6' && addr.isIPv4MappedAddress()) { + return addr.toIPv4Address(); + } else { + return addr; + } + }; + +}).call(this); diff --git a/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/package.json b/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/package.json index 013e7f1c..91ed27fc 100644 --- a/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/package.json +++ b/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/package.json @@ -1,64 +1,64 @@ -{ - "name": "ipaddr.js", - "description": "A library for manipulating IPv4 and IPv6 addresses in JavaScript.", - "version": "1.1.1", - "author": { - "name": "whitequark", - "email": "whitequark@whitequark.org" - }, - "directories": { - "lib": "./lib" - }, - "dependencies": {}, - "devDependencies": { - "coffee-script": "~1.6", - "nodeunit": ">=0.8.2 <0.8.7", - "uglify-js": "latest" - }, - "scripts": { - "test": "cake build test" - }, - "keywords": [ - "ip", - "ipv4", - "ipv6" - ], - "repository": { - "type": "git", - "url": "git://github.com/whitequark/ipaddr.js.git" - }, - "main": "./lib/ipaddr", - "engines": { - "node": ">= 0.10" - }, - "license": "MIT", - "gitHead": "dbc7d98bc0d8fff68a894be0c60721566807e2fc", - "bugs": { - "url": "https://github.com/whitequark/ipaddr.js/issues" - }, - "_id": "ipaddr.js@1.1.1", - "_shasum": "c791d95f52b29c1247d5df80ada39b8a73647230", - "_from": "ipaddr.js@1.1.1", - "_npmVersion": "1.4.21", - "_npmUser": { - "name": "whitequark", - "email": "whitequark@whitequark.org" - }, - "maintainers": [ - { - "name": "whitequark", - "email": "whitequark@whitequark.org" - } - ], - "dist": { - "shasum": "c791d95f52b29c1247d5df80ada39b8a73647230", - "tarball": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.1.1.tgz" - }, - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/ipaddr.js-1.1.1.tgz_1464074293475_0.6683731523808092" - }, - "_resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.1.1.tgz", - "readme": "ERROR: No README data found!", - "homepage": "https://github.com/whitequark/ipaddr.js#readme" -} +{ + "name": "ipaddr.js", + "description": "A library for manipulating IPv4 and IPv6 addresses in JavaScript.", + "version": "1.1.1", + "author": { + "name": "whitequark", + "email": "whitequark@whitequark.org" + }, + "directories": { + "lib": "./lib" + }, + "dependencies": {}, + "devDependencies": { + "coffee-script": "~1.6", + "nodeunit": ">=0.8.2 <0.8.7", + "uglify-js": "latest" + }, + "scripts": { + "test": "cake build test" + }, + "keywords": [ + "ip", + "ipv4", + "ipv6" + ], + "repository": { + "type": "git", + "url": "git://github.com/whitequark/ipaddr.js.git" + }, + "main": "./lib/ipaddr", + "engines": { + "node": ">= 0.10" + }, + "license": "MIT", + "gitHead": "dbc7d98bc0d8fff68a894be0c60721566807e2fc", + "bugs": { + "url": "https://github.com/whitequark/ipaddr.js/issues" + }, + "_id": "ipaddr.js@1.1.1", + "_shasum": "c791d95f52b29c1247d5df80ada39b8a73647230", + "_from": "ipaddr.js@1.1.1", + "_npmVersion": "1.4.21", + "_npmUser": { + "name": "whitequark", + "email": "whitequark@whitequark.org" + }, + "maintainers": [ + { + "name": "whitequark", + "email": "whitequark@whitequark.org" + } + ], + "dist": { + "shasum": "c791d95f52b29c1247d5df80ada39b8a73647230", + "tarball": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.1.1.tgz" + }, + "_npmOperationalInternal": { + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/ipaddr.js-1.1.1.tgz_1464074293475_0.6683731523808092" + }, + "_resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.1.1.tgz", + "readme": "ERROR: No README data found!", + "homepage": "https://github.com/whitequark/ipaddr.js#readme" +} diff --git a/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/src/ipaddr.coffee b/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/src/ipaddr.coffee index c86e5bc8..d2abf91f 100644 --- a/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/src/ipaddr.coffee +++ b/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/src/ipaddr.coffee @@ -1,450 +1,450 @@ -# Define the main object -ipaddr = {} - -root = this - -# Export for both the CommonJS and browser-like environment -if module? && module.exports - module.exports = ipaddr -else - root['ipaddr'] = ipaddr - -# A generic CIDR (Classless Inter-Domain Routing) RFC1518 range matcher. -matchCIDR = (first, second, partSize, cidrBits) -> - if first.length != second.length - throw new Error "ipaddr: cannot match CIDR for objects with different lengths" - - part = 0 - while cidrBits > 0 - shift = partSize - cidrBits - shift = 0 if shift < 0 - - if first[part] >> shift != second[part] >> shift - return false - - cidrBits -= partSize - part += 1 - - return true - -# An utility function to ease named range matching. See examples below. -ipaddr.subnetMatch = (address, rangeList, defaultName='unicast') -> - for rangeName, rangeSubnets of rangeList - # ECMA5 Array.isArray isn't available everywhere - if rangeSubnets[0] && !(rangeSubnets[0] instanceof Array) - rangeSubnets = [ rangeSubnets ] - - for subnet in rangeSubnets - return rangeName if address.match.apply(address, subnet) - - return defaultName - -# An IPv4 address (RFC791). -class ipaddr.IPv4 - # Constructs a new IPv4 address from an array of four octets - # in network order (MSB first) - # Verifies the input. - constructor: (octets) -> - if octets.length != 4 - throw new Error "ipaddr: ipv4 octet count should be 4" - - for octet in octets - if !(0 <= octet <= 255) - throw new Error "ipaddr: ipv4 octet should fit in 8 bits" - - @octets = octets - - # The 'kind' method exists on both IPv4 and IPv6 classes. - kind: -> - return 'ipv4' - - # Returns the address in convenient, decimal-dotted format. - toString: -> - return @octets.join "." - - # Returns an array of byte-sized values in network order (MSB first) - toByteArray: -> - return @octets.slice(0) # octets.clone - - # Checks if this address matches other one within given CIDR range. - match: (other, cidrRange) -> - if cidrRange == undefined - [other, cidrRange] = other - - if other.kind() != 'ipv4' - throw new Error "ipaddr: cannot match ipv4 address with non-ipv4 one" - - return matchCIDR(this.octets, other.octets, 8, cidrRange) - - # Special IPv4 address ranges. - SpecialRanges: - unspecified: [ - [ new IPv4([0, 0, 0, 0]), 8 ] - ] - broadcast: [ - [ new IPv4([255, 255, 255, 255]), 32 ] - ] - multicast: [ # RFC3171 - [ new IPv4([224, 0, 0, 0]), 4 ] - ] - linkLocal: [ # RFC3927 - [ new IPv4([169, 254, 0, 0]), 16 ] - ] - loopback: [ # RFC5735 - [ new IPv4([127, 0, 0, 0]), 8 ] - ] - private: [ # RFC1918 - [ new IPv4([10, 0, 0, 0]), 8 ] - [ new IPv4([172, 16, 0, 0]), 12 ] - [ new IPv4([192, 168, 0, 0]), 16 ] - ] - reserved: [ # Reserved and testing-only ranges; RFCs 5735, 5737, 2544, 1700 - [ new IPv4([192, 0, 0, 0]), 24 ] - [ new IPv4([192, 0, 2, 0]), 24 ] - [ new IPv4([192, 88, 99, 0]), 24 ] - [ new IPv4([198, 51, 100, 0]), 24 ] - [ new IPv4([203, 0, 113, 0]), 24 ] - [ new IPv4([240, 0, 0, 0]), 4 ] - ] - - # Checks if the address corresponds to one of the special ranges. - range: -> - return ipaddr.subnetMatch(this, @SpecialRanges) - - # Convrets this IPv4 address to an IPv4-mapped IPv6 address. - toIPv4MappedAddress: -> - return ipaddr.IPv6.parse "::ffff:#{@toString()}" - - # returns a number of leading ones in IPv4 address, making sure that - # the rest is a solid sequence of 0's (valid netmask) - # returns either the CIDR length or null if mask is not valid - prefixLengthFromSubnetMask: -> - # number of zeroes in octet - zerotable = - 0: 8 - 128: 7 - 192: 6 - 224: 5 - 240: 4 - 248: 3 - 252: 2 - 254: 1 - 255: 0 - - cidr = 0 - # non-zero encountered stop scanning for zeroes - stop = false - for i in [3..0] by -1 - octet = @octets[i] - if octet of zerotable - zeros = zerotable[octet] - if stop and zeros != 0 - return null - unless zeros == 8 - stop = true - cidr += zeros - else - return null - return 32 - cidr - -# A list of regular expressions that match arbitrary IPv4 addresses, -# for which a number of weird notations exist. -# Note that an address like 0010.0xa5.1.1 is considered legal. -ipv4Part = "(0?\\d+|0x[a-f0-9]+)" -ipv4Regexes = - fourOctet: new RegExp "^#{ipv4Part}\\.#{ipv4Part}\\.#{ipv4Part}\\.#{ipv4Part}$", 'i' - longValue: new RegExp "^#{ipv4Part}$", 'i' - -# Classful variants (like a.b, where a is an octet, and b is a 24-bit -# value representing last three octets; this corresponds to a class C -# address) are omitted due to classless nature of modern Internet. -ipaddr.IPv4.parser = (string) -> - parseIntAuto = (string) -> - if string[0] == "0" && string[1] != "x" - parseInt(string, 8) - else - parseInt(string) - - # parseInt recognizes all that octal & hexadecimal weirdness for us - if match = string.match(ipv4Regexes.fourOctet) - return (parseIntAuto(part) for part in match[1..5]) - else if match = string.match(ipv4Regexes.longValue) - value = parseIntAuto(match[1]) - if value > 0xffffffff || value < 0 - throw new Error "ipaddr: address outside defined range" - return ((value >> shift) & 0xff for shift in [0..24] by 8).reverse() - else - return null - -# An IPv6 address (RFC2460) -class ipaddr.IPv6 - # Constructs an IPv6 address from an array of eight 16-bit parts - # or sixteen 8-bit parts in network order (MSB first). - # Throws an error if the input is invalid. - constructor: (parts) -> - if parts.length == 16 - @parts = [] - for i in [0..14] by 2 - @parts.push((parts[i] << 8) | parts[i + 1]) - else if parts.length == 8 - @parts = parts - else - throw new Error "ipaddr: ipv6 part count should be 8 or 16" - - for part in @parts - if !(0 <= part <= 0xffff) - throw new Error "ipaddr: ipv6 part should fit in 16 bits" - - # The 'kind' method exists on both IPv4 and IPv6 classes. - kind: -> - return 'ipv6' - - # Returns the address in compact, human-readable format like - # 2001:db8:8:66::1 - toString: -> - stringParts = (part.toString(16) for part in @parts) - - compactStringParts = [] - pushPart = (part) -> compactStringParts.push part - - state = 0 - for part in stringParts - switch state - when 0 - if part == '0' - pushPart('') - else - pushPart(part) - - state = 1 - when 1 - if part == '0' - state = 2 - else - pushPart(part) - when 2 - unless part == '0' - pushPart('') - pushPart(part) - state = 3 - when 3 - pushPart(part) - - if state == 2 - pushPart('') - pushPart('') - - return compactStringParts.join ":" - - # Returns an array of byte-sized values in network order (MSB first) - toByteArray: -> - bytes = [] - for part in @parts - bytes.push(part >> 8) - bytes.push(part & 0xff) - - return bytes - - # Returns the address in expanded format with all zeroes included, like - # 2001:db8:8:66:0:0:0:1 - toNormalizedString: -> - return (part.toString(16) for part in @parts).join ":" - - # Checks if this address matches other one within given CIDR range. - match: (other, cidrRange) -> - if cidrRange == undefined - [other, cidrRange] = other - - if other.kind() != 'ipv6' - throw new Error "ipaddr: cannot match ipv6 address with non-ipv6 one" - - return matchCIDR(this.parts, other.parts, 16, cidrRange) - - # Special IPv6 ranges - SpecialRanges: - unspecified: [ new IPv6([0, 0, 0, 0, 0, 0, 0, 0]), 128 ] # RFC4291, here and after - linkLocal: [ new IPv6([0xfe80, 0, 0, 0, 0, 0, 0, 0]), 10 ] - multicast: [ new IPv6([0xff00, 0, 0, 0, 0, 0, 0, 0]), 8 ] - loopback: [ new IPv6([0, 0, 0, 0, 0, 0, 0, 1]), 128 ] - uniqueLocal: [ new IPv6([0xfc00, 0, 0, 0, 0, 0, 0, 0]), 7 ] - ipv4Mapped: [ new IPv6([0, 0, 0, 0, 0, 0xffff, 0, 0]), 96 ] - rfc6145: [ new IPv6([0, 0, 0, 0, 0xffff, 0, 0, 0]), 96 ] # RFC6145 - rfc6052: [ new IPv6([0x64, 0xff9b, 0, 0, 0, 0, 0, 0]), 96 ] # RFC6052 - '6to4': [ new IPv6([0x2002, 0, 0, 0, 0, 0, 0, 0]), 16 ] # RFC3056 - teredo: [ new IPv6([0x2001, 0, 0, 0, 0, 0, 0, 0]), 32 ] # RFC6052, RFC6146 - reserved: [ - [ new IPv6([ 0x2001, 0xdb8, 0, 0, 0, 0, 0, 0]), 32 ] # RFC4291 - ] - - # Checks if the address corresponds to one of the special ranges. - range: -> - return ipaddr.subnetMatch(this, @SpecialRanges) - - # Checks if this address is an IPv4-mapped IPv6 address. - isIPv4MappedAddress: -> - return @range() == 'ipv4Mapped' - - # Converts this address to IPv4 address if it is an IPv4-mapped IPv6 address. - # Throws an error otherwise. - toIPv4Address: -> - unless @isIPv4MappedAddress() - throw new Error "ipaddr: trying to convert a generic ipv6 address to ipv4" - - [high, low] = @parts[-2..-1] - - return new ipaddr.IPv4([high >> 8, high & 0xff, low >> 8, low & 0xff]) - -# IPv6-matching regular expressions. -# For IPv6, the task is simpler: it is enough to match the colon-delimited -# hexadecimal IPv6 and a transitional variant with dotted-decimal IPv4 at -# the end. -ipv6Part = "(?:[0-9a-f]+::?)+" -ipv6Regexes = - native: new RegExp "^(::)?(#{ipv6Part})?([0-9a-f]+)?(::)?$", 'i' - transitional: new RegExp "^((?:#{ipv6Part})|(?:::)(?:#{ipv6Part})?)" + - "#{ipv4Part}\\.#{ipv4Part}\\.#{ipv4Part}\\.#{ipv4Part}$", 'i' - -# Expand :: in an IPv6 address or address part consisting of `parts` groups. -expandIPv6 = (string, parts) -> - # More than one '::' means invalid adddress - if string.indexOf('::') != string.lastIndexOf('::') - return null - - # How many parts do we already have? - colonCount = 0 - lastColon = -1 - while (lastColon = string.indexOf(':', lastColon + 1)) >= 0 - colonCount++ - - # 0::0 is two parts more than :: - colonCount-- if string.substr(0, 2) == '::' - colonCount-- if string.substr(-2, 2) == '::' - - # The following loop would hang if colonCount > parts - if colonCount > parts - return null - - # replacement = ':' + '0:' * (parts - colonCount) - replacementCount = parts - colonCount - replacement = ':' - while replacementCount-- - replacement += '0:' - - # Insert the missing zeroes - string = string.replace('::', replacement) - - # Trim any garbage which may be hanging around if :: was at the edge in - # the source string - string = string[1..-1] if string[0] == ':' - string = string[0..-2] if string[string.length-1] == ':' - - return (parseInt(part, 16) for part in string.split(":")) - -# Parse an IPv6 address. -ipaddr.IPv6.parser = (string) -> - if string.match(ipv6Regexes['native']) - return expandIPv6(string, 8) - - else if match = string.match(ipv6Regexes['transitional']) - parts = expandIPv6(match[1][0..-2], 6) - if parts - octets = [parseInt(match[2]), parseInt(match[3]), - parseInt(match[4]), parseInt(match[5])] - for octet in octets - if !(0 <= octet <= 255) - return null - - parts.push(octets[0] << 8 | octets[1]) - parts.push(octets[2] << 8 | octets[3]) - return parts - - return null - -# Checks if a given string is formatted like IPv4/IPv6 address. -ipaddr.IPv4.isIPv4 = ipaddr.IPv6.isIPv6 = (string) -> - return @parser(string) != null - -# Checks if a given string is a valid IPv4/IPv6 address. -ipaddr.IPv4.isValid = (string) -> - try - new this(@parser(string)) - return true - catch e - return false - -ipaddr.IPv6.isValid = (string) -> - # Since IPv6.isValid is always called first, this shortcut - # provides a substantial performance gain. - if typeof string == "string" and string.indexOf(":") == -1 - return false - - try - new this(@parser(string)) - return true - catch e - return false - -# Tries to parse and validate a string with IPv4/IPv6 address. -# Throws an error if it fails. -ipaddr.IPv4.parse = ipaddr.IPv6.parse = (string) -> - parts = @parser(string) - if parts == null - throw new Error "ipaddr: string is not formatted like ip address" - - return new this(parts) - -ipaddr.IPv4.parseCIDR = (string) -> - if match = string.match(/^(.+)\/(\d+)$/) - maskLength = parseInt(match[2]) - if maskLength >= 0 and maskLength <= 32 - return [@parse(match[1]), maskLength] - - throw new Error "ipaddr: string is not formatted like an IPv4 CIDR range" - -ipaddr.IPv6.parseCIDR = (string) -> - if match = string.match(/^(.+)\/(\d+)$/) - maskLength = parseInt(match[2]) - if maskLength >= 0 and maskLength <= 128 - return [@parse(match[1]), maskLength] - - throw new Error "ipaddr: string is not formatted like an IPv6 CIDR range" - -# Checks if the address is valid IP address -ipaddr.isValid = (string) -> - return ipaddr.IPv6.isValid(string) || ipaddr.IPv4.isValid(string) - -# Try to parse an address and throw an error if it is impossible -ipaddr.parse = (string) -> - if ipaddr.IPv6.isValid(string) - return ipaddr.IPv6.parse(string) - else if ipaddr.IPv4.isValid(string) - return ipaddr.IPv4.parse(string) - else - throw new Error "ipaddr: the address has neither IPv6 nor IPv4 format" - -ipaddr.parseCIDR = (string) -> - try - return ipaddr.IPv6.parseCIDR(string) - catch e - try - return ipaddr.IPv4.parseCIDR(string) - catch e - throw new Error "ipaddr: the address has neither IPv6 nor IPv4 CIDR format" - -# Try to parse an array in network order (MSB first) for IPv4 and IPv6 -ipaddr.fromByteArray = (bytes) -> - length = bytes.length - if length == 4 - return new ipaddr.IPv4(bytes) - else if length == 16 - return new ipaddr.IPv6(bytes) - else - throw new Error "ipaddr: the binary input is neither an IPv6 nor IPv4 address" - -# Parse an address and return plain IPv4 address if it is an IPv4-mapped address -ipaddr.process = (string) -> - addr = @parse(string) - if addr.kind() == 'ipv6' && addr.isIPv4MappedAddress() - return addr.toIPv4Address() - else - return addr +# Define the main object +ipaddr = {} + +root = this + +# Export for both the CommonJS and browser-like environment +if module? && module.exports + module.exports = ipaddr +else + root['ipaddr'] = ipaddr + +# A generic CIDR (Classless Inter-Domain Routing) RFC1518 range matcher. +matchCIDR = (first, second, partSize, cidrBits) -> + if first.length != second.length + throw new Error "ipaddr: cannot match CIDR for objects with different lengths" + + part = 0 + while cidrBits > 0 + shift = partSize - cidrBits + shift = 0 if shift < 0 + + if first[part] >> shift != second[part] >> shift + return false + + cidrBits -= partSize + part += 1 + + return true + +# An utility function to ease named range matching. See examples below. +ipaddr.subnetMatch = (address, rangeList, defaultName='unicast') -> + for rangeName, rangeSubnets of rangeList + # ECMA5 Array.isArray isn't available everywhere + if rangeSubnets[0] && !(rangeSubnets[0] instanceof Array) + rangeSubnets = [ rangeSubnets ] + + for subnet in rangeSubnets + return rangeName if address.match.apply(address, subnet) + + return defaultName + +# An IPv4 address (RFC791). +class ipaddr.IPv4 + # Constructs a new IPv4 address from an array of four octets + # in network order (MSB first) + # Verifies the input. + constructor: (octets) -> + if octets.length != 4 + throw new Error "ipaddr: ipv4 octet count should be 4" + + for octet in octets + if !(0 <= octet <= 255) + throw new Error "ipaddr: ipv4 octet should fit in 8 bits" + + @octets = octets + + # The 'kind' method exists on both IPv4 and IPv6 classes. + kind: -> + return 'ipv4' + + # Returns the address in convenient, decimal-dotted format. + toString: -> + return @octets.join "." + + # Returns an array of byte-sized values in network order (MSB first) + toByteArray: -> + return @octets.slice(0) # octets.clone + + # Checks if this address matches other one within given CIDR range. + match: (other, cidrRange) -> + if cidrRange == undefined + [other, cidrRange] = other + + if other.kind() != 'ipv4' + throw new Error "ipaddr: cannot match ipv4 address with non-ipv4 one" + + return matchCIDR(this.octets, other.octets, 8, cidrRange) + + # Special IPv4 address ranges. + SpecialRanges: + unspecified: [ + [ new IPv4([0, 0, 0, 0]), 8 ] + ] + broadcast: [ + [ new IPv4([255, 255, 255, 255]), 32 ] + ] + multicast: [ # RFC3171 + [ new IPv4([224, 0, 0, 0]), 4 ] + ] + linkLocal: [ # RFC3927 + [ new IPv4([169, 254, 0, 0]), 16 ] + ] + loopback: [ # RFC5735 + [ new IPv4([127, 0, 0, 0]), 8 ] + ] + private: [ # RFC1918 + [ new IPv4([10, 0, 0, 0]), 8 ] + [ new IPv4([172, 16, 0, 0]), 12 ] + [ new IPv4([192, 168, 0, 0]), 16 ] + ] + reserved: [ # Reserved and testing-only ranges; RFCs 5735, 5737, 2544, 1700 + [ new IPv4([192, 0, 0, 0]), 24 ] + [ new IPv4([192, 0, 2, 0]), 24 ] + [ new IPv4([192, 88, 99, 0]), 24 ] + [ new IPv4([198, 51, 100, 0]), 24 ] + [ new IPv4([203, 0, 113, 0]), 24 ] + [ new IPv4([240, 0, 0, 0]), 4 ] + ] + + # Checks if the address corresponds to one of the special ranges. + range: -> + return ipaddr.subnetMatch(this, @SpecialRanges) + + # Convrets this IPv4 address to an IPv4-mapped IPv6 address. + toIPv4MappedAddress: -> + return ipaddr.IPv6.parse "::ffff:#{@toString()}" + + # returns a number of leading ones in IPv4 address, making sure that + # the rest is a solid sequence of 0's (valid netmask) + # returns either the CIDR length or null if mask is not valid + prefixLengthFromSubnetMask: -> + # number of zeroes in octet + zerotable = + 0: 8 + 128: 7 + 192: 6 + 224: 5 + 240: 4 + 248: 3 + 252: 2 + 254: 1 + 255: 0 + + cidr = 0 + # non-zero encountered stop scanning for zeroes + stop = false + for i in [3..0] by -1 + octet = @octets[i] + if octet of zerotable + zeros = zerotable[octet] + if stop and zeros != 0 + return null + unless zeros == 8 + stop = true + cidr += zeros + else + return null + return 32 - cidr + +# A list of regular expressions that match arbitrary IPv4 addresses, +# for which a number of weird notations exist. +# Note that an address like 0010.0xa5.1.1 is considered legal. +ipv4Part = "(0?\\d+|0x[a-f0-9]+)" +ipv4Regexes = + fourOctet: new RegExp "^#{ipv4Part}\\.#{ipv4Part}\\.#{ipv4Part}\\.#{ipv4Part}$", 'i' + longValue: new RegExp "^#{ipv4Part}$", 'i' + +# Classful variants (like a.b, where a is an octet, and b is a 24-bit +# value representing last three octets; this corresponds to a class C +# address) are omitted due to classless nature of modern Internet. +ipaddr.IPv4.parser = (string) -> + parseIntAuto = (string) -> + if string[0] == "0" && string[1] != "x" + parseInt(string, 8) + else + parseInt(string) + + # parseInt recognizes all that octal & hexadecimal weirdness for us + if match = string.match(ipv4Regexes.fourOctet) + return (parseIntAuto(part) for part in match[1..5]) + else if match = string.match(ipv4Regexes.longValue) + value = parseIntAuto(match[1]) + if value > 0xffffffff || value < 0 + throw new Error "ipaddr: address outside defined range" + return ((value >> shift) & 0xff for shift in [0..24] by 8).reverse() + else + return null + +# An IPv6 address (RFC2460) +class ipaddr.IPv6 + # Constructs an IPv6 address from an array of eight 16-bit parts + # or sixteen 8-bit parts in network order (MSB first). + # Throws an error if the input is invalid. + constructor: (parts) -> + if parts.length == 16 + @parts = [] + for i in [0..14] by 2 + @parts.push((parts[i] << 8) | parts[i + 1]) + else if parts.length == 8 + @parts = parts + else + throw new Error "ipaddr: ipv6 part count should be 8 or 16" + + for part in @parts + if !(0 <= part <= 0xffff) + throw new Error "ipaddr: ipv6 part should fit in 16 bits" + + # The 'kind' method exists on both IPv4 and IPv6 classes. + kind: -> + return 'ipv6' + + # Returns the address in compact, human-readable format like + # 2001:db8:8:66::1 + toString: -> + stringParts = (part.toString(16) for part in @parts) + + compactStringParts = [] + pushPart = (part) -> compactStringParts.push part + + state = 0 + for part in stringParts + switch state + when 0 + if part == '0' + pushPart('') + else + pushPart(part) + + state = 1 + when 1 + if part == '0' + state = 2 + else + pushPart(part) + when 2 + unless part == '0' + pushPart('') + pushPart(part) + state = 3 + when 3 + pushPart(part) + + if state == 2 + pushPart('') + pushPart('') + + return compactStringParts.join ":" + + # Returns an array of byte-sized values in network order (MSB first) + toByteArray: -> + bytes = [] + for part in @parts + bytes.push(part >> 8) + bytes.push(part & 0xff) + + return bytes + + # Returns the address in expanded format with all zeroes included, like + # 2001:db8:8:66:0:0:0:1 + toNormalizedString: -> + return (part.toString(16) for part in @parts).join ":" + + # Checks if this address matches other one within given CIDR range. + match: (other, cidrRange) -> + if cidrRange == undefined + [other, cidrRange] = other + + if other.kind() != 'ipv6' + throw new Error "ipaddr: cannot match ipv6 address with non-ipv6 one" + + return matchCIDR(this.parts, other.parts, 16, cidrRange) + + # Special IPv6 ranges + SpecialRanges: + unspecified: [ new IPv6([0, 0, 0, 0, 0, 0, 0, 0]), 128 ] # RFC4291, here and after + linkLocal: [ new IPv6([0xfe80, 0, 0, 0, 0, 0, 0, 0]), 10 ] + multicast: [ new IPv6([0xff00, 0, 0, 0, 0, 0, 0, 0]), 8 ] + loopback: [ new IPv6([0, 0, 0, 0, 0, 0, 0, 1]), 128 ] + uniqueLocal: [ new IPv6([0xfc00, 0, 0, 0, 0, 0, 0, 0]), 7 ] + ipv4Mapped: [ new IPv6([0, 0, 0, 0, 0, 0xffff, 0, 0]), 96 ] + rfc6145: [ new IPv6([0, 0, 0, 0, 0xffff, 0, 0, 0]), 96 ] # RFC6145 + rfc6052: [ new IPv6([0x64, 0xff9b, 0, 0, 0, 0, 0, 0]), 96 ] # RFC6052 + '6to4': [ new IPv6([0x2002, 0, 0, 0, 0, 0, 0, 0]), 16 ] # RFC3056 + teredo: [ new IPv6([0x2001, 0, 0, 0, 0, 0, 0, 0]), 32 ] # RFC6052, RFC6146 + reserved: [ + [ new IPv6([ 0x2001, 0xdb8, 0, 0, 0, 0, 0, 0]), 32 ] # RFC4291 + ] + + # Checks if the address corresponds to one of the special ranges. + range: -> + return ipaddr.subnetMatch(this, @SpecialRanges) + + # Checks if this address is an IPv4-mapped IPv6 address. + isIPv4MappedAddress: -> + return @range() == 'ipv4Mapped' + + # Converts this address to IPv4 address if it is an IPv4-mapped IPv6 address. + # Throws an error otherwise. + toIPv4Address: -> + unless @isIPv4MappedAddress() + throw new Error "ipaddr: trying to convert a generic ipv6 address to ipv4" + + [high, low] = @parts[-2..-1] + + return new ipaddr.IPv4([high >> 8, high & 0xff, low >> 8, low & 0xff]) + +# IPv6-matching regular expressions. +# For IPv6, the task is simpler: it is enough to match the colon-delimited +# hexadecimal IPv6 and a transitional variant with dotted-decimal IPv4 at +# the end. +ipv6Part = "(?:[0-9a-f]+::?)+" +ipv6Regexes = + native: new RegExp "^(::)?(#{ipv6Part})?([0-9a-f]+)?(::)?$", 'i' + transitional: new RegExp "^((?:#{ipv6Part})|(?:::)(?:#{ipv6Part})?)" + + "#{ipv4Part}\\.#{ipv4Part}\\.#{ipv4Part}\\.#{ipv4Part}$", 'i' + +# Expand :: in an IPv6 address or address part consisting of `parts` groups. +expandIPv6 = (string, parts) -> + # More than one '::' means invalid adddress + if string.indexOf('::') != string.lastIndexOf('::') + return null + + # How many parts do we already have? + colonCount = 0 + lastColon = -1 + while (lastColon = string.indexOf(':', lastColon + 1)) >= 0 + colonCount++ + + # 0::0 is two parts more than :: + colonCount-- if string.substr(0, 2) == '::' + colonCount-- if string.substr(-2, 2) == '::' + + # The following loop would hang if colonCount > parts + if colonCount > parts + return null + + # replacement = ':' + '0:' * (parts - colonCount) + replacementCount = parts - colonCount + replacement = ':' + while replacementCount-- + replacement += '0:' + + # Insert the missing zeroes + string = string.replace('::', replacement) + + # Trim any garbage which may be hanging around if :: was at the edge in + # the source string + string = string[1..-1] if string[0] == ':' + string = string[0..-2] if string[string.length-1] == ':' + + return (parseInt(part, 16) for part in string.split(":")) + +# Parse an IPv6 address. +ipaddr.IPv6.parser = (string) -> + if string.match(ipv6Regexes['native']) + return expandIPv6(string, 8) + + else if match = string.match(ipv6Regexes['transitional']) + parts = expandIPv6(match[1][0..-2], 6) + if parts + octets = [parseInt(match[2]), parseInt(match[3]), + parseInt(match[4]), parseInt(match[5])] + for octet in octets + if !(0 <= octet <= 255) + return null + + parts.push(octets[0] << 8 | octets[1]) + parts.push(octets[2] << 8 | octets[3]) + return parts + + return null + +# Checks if a given string is formatted like IPv4/IPv6 address. +ipaddr.IPv4.isIPv4 = ipaddr.IPv6.isIPv6 = (string) -> + return @parser(string) != null + +# Checks if a given string is a valid IPv4/IPv6 address. +ipaddr.IPv4.isValid = (string) -> + try + new this(@parser(string)) + return true + catch e + return false + +ipaddr.IPv6.isValid = (string) -> + # Since IPv6.isValid is always called first, this shortcut + # provides a substantial performance gain. + if typeof string == "string" and string.indexOf(":") == -1 + return false + + try + new this(@parser(string)) + return true + catch e + return false + +# Tries to parse and validate a string with IPv4/IPv6 address. +# Throws an error if it fails. +ipaddr.IPv4.parse = ipaddr.IPv6.parse = (string) -> + parts = @parser(string) + if parts == null + throw new Error "ipaddr: string is not formatted like ip address" + + return new this(parts) + +ipaddr.IPv4.parseCIDR = (string) -> + if match = string.match(/^(.+)\/(\d+)$/) + maskLength = parseInt(match[2]) + if maskLength >= 0 and maskLength <= 32 + return [@parse(match[1]), maskLength] + + throw new Error "ipaddr: string is not formatted like an IPv4 CIDR range" + +ipaddr.IPv6.parseCIDR = (string) -> + if match = string.match(/^(.+)\/(\d+)$/) + maskLength = parseInt(match[2]) + if maskLength >= 0 and maskLength <= 128 + return [@parse(match[1]), maskLength] + + throw new Error "ipaddr: string is not formatted like an IPv6 CIDR range" + +# Checks if the address is valid IP address +ipaddr.isValid = (string) -> + return ipaddr.IPv6.isValid(string) || ipaddr.IPv4.isValid(string) + +# Try to parse an address and throw an error if it is impossible +ipaddr.parse = (string) -> + if ipaddr.IPv6.isValid(string) + return ipaddr.IPv6.parse(string) + else if ipaddr.IPv4.isValid(string) + return ipaddr.IPv4.parse(string) + else + throw new Error "ipaddr: the address has neither IPv6 nor IPv4 format" + +ipaddr.parseCIDR = (string) -> + try + return ipaddr.IPv6.parseCIDR(string) + catch e + try + return ipaddr.IPv4.parseCIDR(string) + catch e + throw new Error "ipaddr: the address has neither IPv6 nor IPv4 CIDR format" + +# Try to parse an array in network order (MSB first) for IPv4 and IPv6 +ipaddr.fromByteArray = (bytes) -> + length = bytes.length + if length == 4 + return new ipaddr.IPv4(bytes) + else if length == 16 + return new ipaddr.IPv6(bytes) + else + throw new Error "ipaddr: the binary input is neither an IPv6 nor IPv4 address" + +# Parse an address and return plain IPv4 address if it is an IPv4-mapped address +ipaddr.process = (string) -> + addr = @parse(string) + if addr.kind() == 'ipv6' && addr.isIPv4MappedAddress() + return addr.toIPv4Address() + else + return addr diff --git a/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/test/ipaddr.test.coffee b/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/test/ipaddr.test.coffee index 3f79d86a..5f07526a 100644 --- a/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/test/ipaddr.test.coffee +++ b/ui/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/test/ipaddr.test.coffee @@ -1,339 +1,339 @@ -ipaddr = require '../lib/ipaddr' - -module.exports = - 'should define main classes': (test) -> - test.ok(ipaddr.IPv4?, 'defines IPv4 class') - test.ok(ipaddr.IPv6?, 'defines IPv6 class') - test.done() - - 'can construct IPv4 from octets': (test) -> - test.doesNotThrow -> - new ipaddr.IPv4([192, 168, 1, 2]) - test.done() - - 'refuses to construct invalid IPv4': (test) -> - test.throws -> - new ipaddr.IPv4([300, 1, 2, 3]) - test.throws -> - new ipaddr.IPv4([8, 8, 8]) - test.done() - - 'converts IPv4 to string correctly': (test) -> - addr = new ipaddr.IPv4([192, 168, 1, 1]) - test.equal(addr.toString(), '192.168.1.1') - test.done() - - 'returns correct kind for IPv4': (test) -> - addr = new ipaddr.IPv4([1, 2, 3, 4]) - test.equal(addr.kind(), 'ipv4') - test.done() - - 'allows to access IPv4 octets': (test) -> - addr = new ipaddr.IPv4([42, 0, 0, 0]) - test.equal(addr.octets[0], 42) - test.done() - - 'checks IPv4 address format': (test) -> - test.equal(ipaddr.IPv4.isIPv4('192.168.007.0xa'), true) - test.equal(ipaddr.IPv4.isIPv4('1024.0.0.1'), true) - test.equal(ipaddr.IPv4.isIPv4('8.0xa.wtf.6'), false) - test.done() - - 'validates IPv4 addresses': (test) -> - test.equal(ipaddr.IPv4.isValid('192.168.007.0xa'), true) - test.equal(ipaddr.IPv4.isValid('1024.0.0.1'), false) - test.equal(ipaddr.IPv4.isValid('8.0xa.wtf.6'), false) - test.done() - - 'parses IPv4 in several weird formats': (test) -> - test.deepEqual(ipaddr.IPv4.parse('192.168.1.1').octets, [192, 168, 1, 1]) - test.deepEqual(ipaddr.IPv4.parse('0xc0.168.1.1').octets, [192, 168, 1, 1]) - test.deepEqual(ipaddr.IPv4.parse('192.0250.1.1').octets, [192, 168, 1, 1]) - test.deepEqual(ipaddr.IPv4.parse('0xc0a80101').octets, [192, 168, 1, 1]) - test.deepEqual(ipaddr.IPv4.parse('030052000401').octets, [192, 168, 1, 1]) - test.deepEqual(ipaddr.IPv4.parse('3232235777').octets, [192, 168, 1, 1]) - test.done() - - 'barfs at invalid IPv4': (test) -> - test.throws -> - ipaddr.IPv4.parse('10.0.0.wtf') - test.done() - - 'matches IPv4 CIDR correctly': (test) -> - addr = new ipaddr.IPv4([10, 5, 0, 1]) - test.equal(addr.match(ipaddr.IPv4.parse('0.0.0.0'), 0), true) - test.equal(addr.match(ipaddr.IPv4.parse('11.0.0.0'), 8), false) - test.equal(addr.match(ipaddr.IPv4.parse('10.0.0.0'), 8), true) - test.equal(addr.match(ipaddr.IPv4.parse('10.0.0.1'), 8), true) - test.equal(addr.match(ipaddr.IPv4.parse('10.0.0.10'), 8), true) - test.equal(addr.match(ipaddr.IPv4.parse('10.5.5.0'), 16), true) - test.equal(addr.match(ipaddr.IPv4.parse('10.4.5.0'), 16), false) - test.equal(addr.match(ipaddr.IPv4.parse('10.4.5.0'), 15), true) - test.equal(addr.match(ipaddr.IPv4.parse('10.5.0.2'), 32), false) - test.equal(addr.match(addr, 32), true) - test.done() - - 'parses IPv4 CIDR correctly': (test) -> - addr = new ipaddr.IPv4([10, 5, 0, 1]) - test.equal(addr.match(ipaddr.IPv4.parseCIDR('0.0.0.0/0')), true) - test.equal(addr.match(ipaddr.IPv4.parseCIDR('11.0.0.0/8')), false) - test.equal(addr.match(ipaddr.IPv4.parseCIDR('10.0.0.0/8')), true) - test.equal(addr.match(ipaddr.IPv4.parseCIDR('10.0.0.1/8')), true) - test.equal(addr.match(ipaddr.IPv4.parseCIDR('10.0.0.10/8')), true) - test.equal(addr.match(ipaddr.IPv4.parseCIDR('10.5.5.0/16')), true) - test.equal(addr.match(ipaddr.IPv4.parseCIDR('10.4.5.0/16')), false) - test.equal(addr.match(ipaddr.IPv4.parseCIDR('10.4.5.0/15')), true) - test.equal(addr.match(ipaddr.IPv4.parseCIDR('10.5.0.2/32')), false) - test.equal(addr.match(ipaddr.IPv4.parseCIDR('10.5.0.1/32')), true) - test.throws -> - ipaddr.IPv4.parseCIDR('10.5.0.1') - test.throws -> - ipaddr.IPv4.parseCIDR('0.0.0.0/-1') - test.throws -> - ipaddr.IPv4.parseCIDR('0.0.0.0/33') - test.done() - - 'detects reserved IPv4 networks': (test) -> - test.equal(ipaddr.IPv4.parse('0.0.0.0').range(), 'unspecified') - test.equal(ipaddr.IPv4.parse('0.1.0.0').range(), 'unspecified') - test.equal(ipaddr.IPv4.parse('10.1.0.1').range(), 'private') - test.equal(ipaddr.IPv4.parse('192.168.2.1').range(), 'private') - test.equal(ipaddr.IPv4.parse('224.100.0.1').range(), 'multicast') - test.equal(ipaddr.IPv4.parse('169.254.15.0').range(), 'linkLocal') - test.equal(ipaddr.IPv4.parse('127.1.1.1').range(), 'loopback') - test.equal(ipaddr.IPv4.parse('255.255.255.255').range(), 'broadcast') - test.equal(ipaddr.IPv4.parse('240.1.2.3').range(), 'reserved') - test.equal(ipaddr.IPv4.parse('8.8.8.8').range(), 'unicast') - test.done() - - 'can construct IPv6 from 16bit parts': (test) -> - test.doesNotThrow -> - new ipaddr.IPv6([0x2001, 0xdb8, 0xf53a, 0, 0, 0, 0, 1]) - test.done() - - 'can construct IPv6 from 8bit parts': (test) -> - test.doesNotThrow -> - new ipaddr.IPv6([0x20, 0x01, 0xd, 0xb8, 0xf5, 0x3a, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) - test.deepEqual(new ipaddr.IPv6([0x20, 0x01, 0xd, 0xb8, 0xf5, 0x3a, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), - new ipaddr.IPv6([0x2001, 0xdb8, 0xf53a, 0, 0, 0, 0, 1])) - test.done() - - 'refuses to construct invalid IPv6': (test) -> - test.throws -> - new ipaddr.IPv6([0xfffff, 0, 0, 0, 0, 0, 0, 1]) - test.throws -> - new ipaddr.IPv6([0xfffff, 0, 0, 0, 0, 0, 1]) - test.throws -> - new ipaddr.IPv6([0xffff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) - test.done() - - 'converts IPv6 to string correctly': (test) -> - addr = new ipaddr.IPv6([0x2001, 0xdb8, 0xf53a, 0, 0, 0, 0, 1]) - test.equal(addr.toNormalizedString(), '2001:db8:f53a:0:0:0:0:1') - test.equal(addr.toString(), '2001:db8:f53a::1') - test.equal(new ipaddr.IPv6([0, 0, 0, 0, 0, 0, 0, 1]).toString(), '::1') - test.equal(new ipaddr.IPv6([0x2001, 0xdb8, 0, 0, 0, 0, 0, 0]).toString(), '2001:db8::') - test.done() - - 'returns correct kind for IPv6': (test) -> - addr = new ipaddr.IPv6([0x2001, 0xdb8, 0xf53a, 0, 0, 0, 0, 1]) - test.equal(addr.kind(), 'ipv6') - test.done() - - 'allows to access IPv6 address parts': (test) -> - addr = new ipaddr.IPv6([0x2001, 0xdb8, 0xf53a, 0, 0, 42, 0, 1]) - test.equal(addr.parts[5], 42) - test.done() - - 'checks IPv6 address format': (test) -> - test.equal(ipaddr.IPv6.isIPv6('2001:db8:F53A::1'), true) - test.equal(ipaddr.IPv6.isIPv6('200001::1'), true) - test.equal(ipaddr.IPv6.isIPv6('::ffff:192.168.1.1'), true) - test.equal(ipaddr.IPv6.isIPv6('::ffff:300.168.1.1'), false) - test.equal(ipaddr.IPv6.isIPv6('::ffff:300.168.1.1:0'), false) - test.equal(ipaddr.IPv6.isIPv6('fe80::wtf'), false) - test.done() - - 'validates IPv6 addresses': (test) -> - test.equal(ipaddr.IPv6.isValid('2001:db8:F53A::1'), true) - test.equal(ipaddr.IPv6.isValid('200001::1'), false) - test.equal(ipaddr.IPv6.isValid('::ffff:192.168.1.1'), true) - test.equal(ipaddr.IPv6.isValid('::ffff:300.168.1.1'), false) - test.equal(ipaddr.IPv6.isValid('::ffff:300.168.1.1:0'), false) - test.equal(ipaddr.IPv6.isValid('::ffff:222.1.41.9000'), false) - test.equal(ipaddr.IPv6.isValid('2001:db8::F53A::1'), false) - test.equal(ipaddr.IPv6.isValid('fe80::wtf'), false) - test.equal(ipaddr.IPv6.isValid('2002::2:'), false) - test.equal(ipaddr.IPv6.isValid(undefined), false) - test.done() - - 'parses IPv6 in different formats': (test) -> - test.deepEqual(ipaddr.IPv6.parse('2001:db8:F53A:0:0:0:0:1').parts, [0x2001, 0xdb8, 0xf53a, 0, 0, 0, 0, 1]) - test.deepEqual(ipaddr.IPv6.parse('fe80::10').parts, [0xfe80, 0, 0, 0, 0, 0, 0, 0x10]) - test.deepEqual(ipaddr.IPv6.parse('2001:db8:F53A::').parts, [0x2001, 0xdb8, 0xf53a, 0, 0, 0, 0, 0]) - test.deepEqual(ipaddr.IPv6.parse('::1').parts, [0, 0, 0, 0, 0, 0, 0, 1]) - test.deepEqual(ipaddr.IPv6.parse('::').parts, [0, 0, 0, 0, 0, 0, 0, 0]) - test.done() - - 'barfs at invalid IPv6': (test) -> - test.throws -> - ipaddr.IPv6.parse('fe80::0::1') - test.done() - - 'matches IPv6 CIDR correctly': (test) -> - addr = ipaddr.IPv6.parse('2001:db8:f53a::1') - test.equal(addr.match(ipaddr.IPv6.parse('::'), 0), true) - test.equal(addr.match(ipaddr.IPv6.parse('2001:db8:f53a::1:1'), 64), true) - test.equal(addr.match(ipaddr.IPv6.parse('2001:db8:f53b::1:1'), 48), false) - test.equal(addr.match(ipaddr.IPv6.parse('2001:db8:f531::1:1'), 44), true) - test.equal(addr.match(ipaddr.IPv6.parse('2001:db8:f500::1'), 40), true) - test.equal(addr.match(ipaddr.IPv6.parse('2001:db9:f500::1'), 40), false) - test.equal(addr.match(addr, 128), true) - test.done() - - 'parses IPv6 CIDR correctly': (test) -> - addr = ipaddr.IPv6.parse('2001:db8:f53a::1') - test.equal(addr.match(ipaddr.IPv6.parseCIDR('::/0')), true) - test.equal(addr.match(ipaddr.IPv6.parseCIDR('2001:db8:f53a::1:1/64')), true) - test.equal(addr.match(ipaddr.IPv6.parseCIDR('2001:db8:f53b::1:1/48')), false) - test.equal(addr.match(ipaddr.IPv6.parseCIDR('2001:db8:f531::1:1/44')), true) - test.equal(addr.match(ipaddr.IPv6.parseCIDR('2001:db8:f500::1/40')), true) - test.equal(addr.match(ipaddr.IPv6.parseCIDR('2001:db9:f500::1/40')), false) - test.equal(addr.match(ipaddr.IPv6.parseCIDR('2001:db8:f53a::1/128')), true) - test.throws -> - ipaddr.IPv6.parseCIDR('2001:db8:f53a::1') - test.throws -> - ipaddr.IPv6.parseCIDR('2001:db8:f53a::1/-1') - test.throws -> - ipaddr.IPv6.parseCIDR('2001:db8:f53a::1/129') - test.done() - - 'converts between IPv4-mapped IPv6 addresses and IPv4 addresses': (test) -> - addr = ipaddr.IPv4.parse('77.88.21.11') - mapped = addr.toIPv4MappedAddress() - test.deepEqual(mapped.parts, [0, 0, 0, 0, 0, 0xffff, 0x4d58, 0x150b]) - test.deepEqual(mapped.toIPv4Address().octets, addr.octets) - test.done() - - 'refuses to convert non-IPv4-mapped IPv6 address to IPv4 address': (test) -> - test.throws -> - ipaddr.IPv6.parse('2001:db8::1').toIPv4Address() - test.done() - - 'detects reserved IPv6 networks': (test) -> - test.equal(ipaddr.IPv6.parse('::').range(), 'unspecified') - test.equal(ipaddr.IPv6.parse('fe80::1234:5678:abcd:0123').range(), 'linkLocal') - test.equal(ipaddr.IPv6.parse('ff00::1234').range(), 'multicast') - test.equal(ipaddr.IPv6.parse('::1').range(), 'loopback') - test.equal(ipaddr.IPv6.parse('fc00::').range(), 'uniqueLocal') - test.equal(ipaddr.IPv6.parse('::ffff:192.168.1.10').range(), 'ipv4Mapped') - test.equal(ipaddr.IPv6.parse('::ffff:0:192.168.1.10').range(), 'rfc6145') - test.equal(ipaddr.IPv6.parse('64:ff9b::1234').range(), 'rfc6052') - test.equal(ipaddr.IPv6.parse('2002:1f63:45e8::1').range(), '6to4') - test.equal(ipaddr.IPv6.parse('2001::4242').range(), 'teredo') - test.equal(ipaddr.IPv6.parse('2001:db8::3210').range(), 'reserved') - test.equal(ipaddr.IPv6.parse('2001:470:8:66::1').range(), 'unicast') - test.done() - - 'is able to determine IP address type': (test) -> - test.equal(ipaddr.parse('8.8.8.8').kind(), 'ipv4') - test.equal(ipaddr.parse('2001:db8:3312::1').kind(), 'ipv6') - test.done() - - 'throws an error if tried to parse an invalid address': (test) -> - test.throws -> - ipaddr.parse('::some.nonsense') - test.done() - - 'correctly processes IPv4-mapped addresses': (test) -> - test.equal(ipaddr.process('8.8.8.8').kind(), 'ipv4') - test.equal(ipaddr.process('2001:db8:3312::1').kind(), 'ipv6') - test.equal(ipaddr.process('::ffff:192.168.1.1').kind(), 'ipv4') - test.done() - - 'correctly converts IPv6 and IPv4 addresses to byte arrays': (test) -> - test.deepEqual(ipaddr.parse('1.2.3.4').toByteArray(), - [0x1, 0x2, 0x3, 0x4]); - # Fuck yeah. The first byte of Google's IPv6 address is 42. 42! - test.deepEqual(ipaddr.parse('2a00:1450:8007::68').toByteArray(), - [42, 0x00, 0x14, 0x50, 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68 ]) - test.done() - - 'correctly parses 1 as an IPv4 address': (test) -> - test.equal(ipaddr.IPv6.isValid('1'), false) - test.equal(ipaddr.IPv4.isValid('1'), true) - test.deepEqual(new ipaddr.IPv4([0, 0, 0, 1]), ipaddr.parse('1')) - test.done() - - 'correctly detects IPv4 and IPv6 CIDR addresses': (test) -> - test.deepEqual([ipaddr.IPv6.parse('fc00::'), 64], - ipaddr.parseCIDR('fc00::/64')) - test.deepEqual([ipaddr.IPv4.parse('1.2.3.4'), 5], - ipaddr.parseCIDR('1.2.3.4/5')) - test.done() - - 'does not consider a very large or very small number a valid IP address': (test) -> - test.equal(ipaddr.isValid('4999999999'), false) - test.equal(ipaddr.isValid('-1'), false) - test.done() - - 'does not hang on ::8:8:8:8:8:8:8:8:8': (test) -> - test.equal(ipaddr.IPv6.isValid('::8:8:8:8:8:8:8:8:8'), false) - test.done() - - 'subnetMatch does not fail on empty range': (test) -> - ipaddr.subnetMatch(new ipaddr.IPv4([1,2,3,4]), {}, false) - ipaddr.subnetMatch(new ipaddr.IPv4([1,2,3,4]), {subnet: []}, false) - test.done() - - 'subnetMatch returns default subnet on empty range': (test) -> - test.equal(ipaddr.subnetMatch(new ipaddr.IPv4([1,2,3,4]), {}, false), false) - test.equal(ipaddr.subnetMatch(new ipaddr.IPv4([1,2,3,4]), {subnet: []}, false), false) - test.done() - - 'is able to determine IP address type from byte array input': (test) -> - test.equal(ipaddr.fromByteArray([0x7f, 0, 0, 1]).kind(), 'ipv4') - test.equal(ipaddr.fromByteArray([0x20, 0x01, 0xd, 0xb8, 0xf5, 0x3a, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]).kind(), 'ipv6') - test.throws -> - ipaddr.fromByteArray([1]) - test.done() - - 'prefixLengthFromSubnetMask returns proper CIDR notation for standard IPv4 masks': (test) -> - test.equal(ipaddr.IPv4.parse('255.255.255.255').prefixLengthFromSubnetMask(), 32) - test.equal(ipaddr.IPv4.parse('255.255.255.254').prefixLengthFromSubnetMask(), 31) - test.equal(ipaddr.IPv4.parse('255.255.255.252').prefixLengthFromSubnetMask(), 30) - test.equal(ipaddr.IPv4.parse('255.255.255.248').prefixLengthFromSubnetMask(), 29) - test.equal(ipaddr.IPv4.parse('255.255.255.240').prefixLengthFromSubnetMask(), 28) - test.equal(ipaddr.IPv4.parse('255.255.255.224').prefixLengthFromSubnetMask(), 27) - test.equal(ipaddr.IPv4.parse('255.255.255.192').prefixLengthFromSubnetMask(), 26) - test.equal(ipaddr.IPv4.parse('255.255.255.128').prefixLengthFromSubnetMask(), 25) - test.equal(ipaddr.IPv4.parse('255.255.255.0').prefixLengthFromSubnetMask(), 24) - test.equal(ipaddr.IPv4.parse('255.255.254.0').prefixLengthFromSubnetMask(), 23) - test.equal(ipaddr.IPv4.parse('255.255.252.0').prefixLengthFromSubnetMask(), 22) - test.equal(ipaddr.IPv4.parse('255.255.248.0').prefixLengthFromSubnetMask(), 21) - test.equal(ipaddr.IPv4.parse('255.255.240.0').prefixLengthFromSubnetMask(), 20) - test.equal(ipaddr.IPv4.parse('255.255.224.0').prefixLengthFromSubnetMask(), 19) - test.equal(ipaddr.IPv4.parse('255.255.192.0').prefixLengthFromSubnetMask(), 18) - test.equal(ipaddr.IPv4.parse('255.255.128.0').prefixLengthFromSubnetMask(), 17) - test.equal(ipaddr.IPv4.parse('255.255.0.0').prefixLengthFromSubnetMask(), 16) - test.equal(ipaddr.IPv4.parse('255.254.0.0').prefixLengthFromSubnetMask(), 15) - test.equal(ipaddr.IPv4.parse('255.252.0.0').prefixLengthFromSubnetMask(), 14) - test.equal(ipaddr.IPv4.parse('255.248.0.0').prefixLengthFromSubnetMask(), 13) - test.equal(ipaddr.IPv4.parse('255.240.0.0').prefixLengthFromSubnetMask(), 12) - test.equal(ipaddr.IPv4.parse('255.224.0.0').prefixLengthFromSubnetMask(), 11) - test.equal(ipaddr.IPv4.parse('255.192.0.0').prefixLengthFromSubnetMask(), 10) - test.equal(ipaddr.IPv4.parse('255.128.0.0').prefixLengthFromSubnetMask(), 9) - test.equal(ipaddr.IPv4.parse('255.0.0.0').prefixLengthFromSubnetMask(), 8) - test.equal(ipaddr.IPv4.parse('254.0.0.0').prefixLengthFromSubnetMask(), 7) - test.equal(ipaddr.IPv4.parse('252.0.0.0').prefixLengthFromSubnetMask(), 6) - test.equal(ipaddr.IPv4.parse('248.0.0.0').prefixLengthFromSubnetMask(), 5) - test.equal(ipaddr.IPv4.parse('240.0.0.0').prefixLengthFromSubnetMask(), 4) - test.equal(ipaddr.IPv4.parse('224.0.0.0').prefixLengthFromSubnetMask(), 3) - test.equal(ipaddr.IPv4.parse('192.0.0.0').prefixLengthFromSubnetMask(), 2) - test.equal(ipaddr.IPv4.parse('128.0.0.0').prefixLengthFromSubnetMask(), 1) - test.equal(ipaddr.IPv4.parse('0.0.0.0').prefixLengthFromSubnetMask(), 0) - # negative cases - test.equal(ipaddr.IPv4.parse('192.168.255.0').prefixLengthFromSubnetMask(), null) - test.equal(ipaddr.IPv4.parse('255.0.255.0').prefixLengthFromSubnetMask(), null) - test.done() - +ipaddr = require '../lib/ipaddr' + +module.exports = + 'should define main classes': (test) -> + test.ok(ipaddr.IPv4?, 'defines IPv4 class') + test.ok(ipaddr.IPv6?, 'defines IPv6 class') + test.done() + + 'can construct IPv4 from octets': (test) -> + test.doesNotThrow -> + new ipaddr.IPv4([192, 168, 1, 2]) + test.done() + + 'refuses to construct invalid IPv4': (test) -> + test.throws -> + new ipaddr.IPv4([300, 1, 2, 3]) + test.throws -> + new ipaddr.IPv4([8, 8, 8]) + test.done() + + 'converts IPv4 to string correctly': (test) -> + addr = new ipaddr.IPv4([192, 168, 1, 1]) + test.equal(addr.toString(), '192.168.1.1') + test.done() + + 'returns correct kind for IPv4': (test) -> + addr = new ipaddr.IPv4([1, 2, 3, 4]) + test.equal(addr.kind(), 'ipv4') + test.done() + + 'allows to access IPv4 octets': (test) -> + addr = new ipaddr.IPv4([42, 0, 0, 0]) + test.equal(addr.octets[0], 42) + test.done() + + 'checks IPv4 address format': (test) -> + test.equal(ipaddr.IPv4.isIPv4('192.168.007.0xa'), true) + test.equal(ipaddr.IPv4.isIPv4('1024.0.0.1'), true) + test.equal(ipaddr.IPv4.isIPv4('8.0xa.wtf.6'), false) + test.done() + + 'validates IPv4 addresses': (test) -> + test.equal(ipaddr.IPv4.isValid('192.168.007.0xa'), true) + test.equal(ipaddr.IPv4.isValid('1024.0.0.1'), false) + test.equal(ipaddr.IPv4.isValid('8.0xa.wtf.6'), false) + test.done() + + 'parses IPv4 in several weird formats': (test) -> + test.deepEqual(ipaddr.IPv4.parse('192.168.1.1').octets, [192, 168, 1, 1]) + test.deepEqual(ipaddr.IPv4.parse('0xc0.168.1.1').octets, [192, 168, 1, 1]) + test.deepEqual(ipaddr.IPv4.parse('192.0250.1.1').octets, [192, 168, 1, 1]) + test.deepEqual(ipaddr.IPv4.parse('0xc0a80101').octets, [192, 168, 1, 1]) + test.deepEqual(ipaddr.IPv4.parse('030052000401').octets, [192, 168, 1, 1]) + test.deepEqual(ipaddr.IPv4.parse('3232235777').octets, [192, 168, 1, 1]) + test.done() + + 'barfs at invalid IPv4': (test) -> + test.throws -> + ipaddr.IPv4.parse('10.0.0.wtf') + test.done() + + 'matches IPv4 CIDR correctly': (test) -> + addr = new ipaddr.IPv4([10, 5, 0, 1]) + test.equal(addr.match(ipaddr.IPv4.parse('0.0.0.0'), 0), true) + test.equal(addr.match(ipaddr.IPv4.parse('11.0.0.0'), 8), false) + test.equal(addr.match(ipaddr.IPv4.parse('10.0.0.0'), 8), true) + test.equal(addr.match(ipaddr.IPv4.parse('10.0.0.1'), 8), true) + test.equal(addr.match(ipaddr.IPv4.parse('10.0.0.10'), 8), true) + test.equal(addr.match(ipaddr.IPv4.parse('10.5.5.0'), 16), true) + test.equal(addr.match(ipaddr.IPv4.parse('10.4.5.0'), 16), false) + test.equal(addr.match(ipaddr.IPv4.parse('10.4.5.0'), 15), true) + test.equal(addr.match(ipaddr.IPv4.parse('10.5.0.2'), 32), false) + test.equal(addr.match(addr, 32), true) + test.done() + + 'parses IPv4 CIDR correctly': (test) -> + addr = new ipaddr.IPv4([10, 5, 0, 1]) + test.equal(addr.match(ipaddr.IPv4.parseCIDR('0.0.0.0/0')), true) + test.equal(addr.match(ipaddr.IPv4.parseCIDR('11.0.0.0/8')), false) + test.equal(addr.match(ipaddr.IPv4.parseCIDR('10.0.0.0/8')), true) + test.equal(addr.match(ipaddr.IPv4.parseCIDR('10.0.0.1/8')), true) + test.equal(addr.match(ipaddr.IPv4.parseCIDR('10.0.0.10/8')), true) + test.equal(addr.match(ipaddr.IPv4.parseCIDR('10.5.5.0/16')), true) + test.equal(addr.match(ipaddr.IPv4.parseCIDR('10.4.5.0/16')), false) + test.equal(addr.match(ipaddr.IPv4.parseCIDR('10.4.5.0/15')), true) + test.equal(addr.match(ipaddr.IPv4.parseCIDR('10.5.0.2/32')), false) + test.equal(addr.match(ipaddr.IPv4.parseCIDR('10.5.0.1/32')), true) + test.throws -> + ipaddr.IPv4.parseCIDR('10.5.0.1') + test.throws -> + ipaddr.IPv4.parseCIDR('0.0.0.0/-1') + test.throws -> + ipaddr.IPv4.parseCIDR('0.0.0.0/33') + test.done() + + 'detects reserved IPv4 networks': (test) -> + test.equal(ipaddr.IPv4.parse('0.0.0.0').range(), 'unspecified') + test.equal(ipaddr.IPv4.parse('0.1.0.0').range(), 'unspecified') + test.equal(ipaddr.IPv4.parse('10.1.0.1').range(), 'private') + test.equal(ipaddr.IPv4.parse('192.168.2.1').range(), 'private') + test.equal(ipaddr.IPv4.parse('224.100.0.1').range(), 'multicast') + test.equal(ipaddr.IPv4.parse('169.254.15.0').range(), 'linkLocal') + test.equal(ipaddr.IPv4.parse('127.1.1.1').range(), 'loopback') + test.equal(ipaddr.IPv4.parse('255.255.255.255').range(), 'broadcast') + test.equal(ipaddr.IPv4.parse('240.1.2.3').range(), 'reserved') + test.equal(ipaddr.IPv4.parse('8.8.8.8').range(), 'unicast') + test.done() + + 'can construct IPv6 from 16bit parts': (test) -> + test.doesNotThrow -> + new ipaddr.IPv6([0x2001, 0xdb8, 0xf53a, 0, 0, 0, 0, 1]) + test.done() + + 'can construct IPv6 from 8bit parts': (test) -> + test.doesNotThrow -> + new ipaddr.IPv6([0x20, 0x01, 0xd, 0xb8, 0xf5, 0x3a, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) + test.deepEqual(new ipaddr.IPv6([0x20, 0x01, 0xd, 0xb8, 0xf5, 0x3a, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), + new ipaddr.IPv6([0x2001, 0xdb8, 0xf53a, 0, 0, 0, 0, 1])) + test.done() + + 'refuses to construct invalid IPv6': (test) -> + test.throws -> + new ipaddr.IPv6([0xfffff, 0, 0, 0, 0, 0, 0, 1]) + test.throws -> + new ipaddr.IPv6([0xfffff, 0, 0, 0, 0, 0, 1]) + test.throws -> + new ipaddr.IPv6([0xffff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) + test.done() + + 'converts IPv6 to string correctly': (test) -> + addr = new ipaddr.IPv6([0x2001, 0xdb8, 0xf53a, 0, 0, 0, 0, 1]) + test.equal(addr.toNormalizedString(), '2001:db8:f53a:0:0:0:0:1') + test.equal(addr.toString(), '2001:db8:f53a::1') + test.equal(new ipaddr.IPv6([0, 0, 0, 0, 0, 0, 0, 1]).toString(), '::1') + test.equal(new ipaddr.IPv6([0x2001, 0xdb8, 0, 0, 0, 0, 0, 0]).toString(), '2001:db8::') + test.done() + + 'returns correct kind for IPv6': (test) -> + addr = new ipaddr.IPv6([0x2001, 0xdb8, 0xf53a, 0, 0, 0, 0, 1]) + test.equal(addr.kind(), 'ipv6') + test.done() + + 'allows to access IPv6 address parts': (test) -> + addr = new ipaddr.IPv6([0x2001, 0xdb8, 0xf53a, 0, 0, 42, 0, 1]) + test.equal(addr.parts[5], 42) + test.done() + + 'checks IPv6 address format': (test) -> + test.equal(ipaddr.IPv6.isIPv6('2001:db8:F53A::1'), true) + test.equal(ipaddr.IPv6.isIPv6('200001::1'), true) + test.equal(ipaddr.IPv6.isIPv6('::ffff:192.168.1.1'), true) + test.equal(ipaddr.IPv6.isIPv6('::ffff:300.168.1.1'), false) + test.equal(ipaddr.IPv6.isIPv6('::ffff:300.168.1.1:0'), false) + test.equal(ipaddr.IPv6.isIPv6('fe80::wtf'), false) + test.done() + + 'validates IPv6 addresses': (test) -> + test.equal(ipaddr.IPv6.isValid('2001:db8:F53A::1'), true) + test.equal(ipaddr.IPv6.isValid('200001::1'), false) + test.equal(ipaddr.IPv6.isValid('::ffff:192.168.1.1'), true) + test.equal(ipaddr.IPv6.isValid('::ffff:300.168.1.1'), false) + test.equal(ipaddr.IPv6.isValid('::ffff:300.168.1.1:0'), false) + test.equal(ipaddr.IPv6.isValid('::ffff:222.1.41.9000'), false) + test.equal(ipaddr.IPv6.isValid('2001:db8::F53A::1'), false) + test.equal(ipaddr.IPv6.isValid('fe80::wtf'), false) + test.equal(ipaddr.IPv6.isValid('2002::2:'), false) + test.equal(ipaddr.IPv6.isValid(undefined), false) + test.done() + + 'parses IPv6 in different formats': (test) -> + test.deepEqual(ipaddr.IPv6.parse('2001:db8:F53A:0:0:0:0:1').parts, [0x2001, 0xdb8, 0xf53a, 0, 0, 0, 0, 1]) + test.deepEqual(ipaddr.IPv6.parse('fe80::10').parts, [0xfe80, 0, 0, 0, 0, 0, 0, 0x10]) + test.deepEqual(ipaddr.IPv6.parse('2001:db8:F53A::').parts, [0x2001, 0xdb8, 0xf53a, 0, 0, 0, 0, 0]) + test.deepEqual(ipaddr.IPv6.parse('::1').parts, [0, 0, 0, 0, 0, 0, 0, 1]) + test.deepEqual(ipaddr.IPv6.parse('::').parts, [0, 0, 0, 0, 0, 0, 0, 0]) + test.done() + + 'barfs at invalid IPv6': (test) -> + test.throws -> + ipaddr.IPv6.parse('fe80::0::1') + test.done() + + 'matches IPv6 CIDR correctly': (test) -> + addr = ipaddr.IPv6.parse('2001:db8:f53a::1') + test.equal(addr.match(ipaddr.IPv6.parse('::'), 0), true) + test.equal(addr.match(ipaddr.IPv6.parse('2001:db8:f53a::1:1'), 64), true) + test.equal(addr.match(ipaddr.IPv6.parse('2001:db8:f53b::1:1'), 48), false) + test.equal(addr.match(ipaddr.IPv6.parse('2001:db8:f531::1:1'), 44), true) + test.equal(addr.match(ipaddr.IPv6.parse('2001:db8:f500::1'), 40), true) + test.equal(addr.match(ipaddr.IPv6.parse('2001:db9:f500::1'), 40), false) + test.equal(addr.match(addr, 128), true) + test.done() + + 'parses IPv6 CIDR correctly': (test) -> + addr = ipaddr.IPv6.parse('2001:db8:f53a::1') + test.equal(addr.match(ipaddr.IPv6.parseCIDR('::/0')), true) + test.equal(addr.match(ipaddr.IPv6.parseCIDR('2001:db8:f53a::1:1/64')), true) + test.equal(addr.match(ipaddr.IPv6.parseCIDR('2001:db8:f53b::1:1/48')), false) + test.equal(addr.match(ipaddr.IPv6.parseCIDR('2001:db8:f531::1:1/44')), true) + test.equal(addr.match(ipaddr.IPv6.parseCIDR('2001:db8:f500::1/40')), true) + test.equal(addr.match(ipaddr.IPv6.parseCIDR('2001:db9:f500::1/40')), false) + test.equal(addr.match(ipaddr.IPv6.parseCIDR('2001:db8:f53a::1/128')), true) + test.throws -> + ipaddr.IPv6.parseCIDR('2001:db8:f53a::1') + test.throws -> + ipaddr.IPv6.parseCIDR('2001:db8:f53a::1/-1') + test.throws -> + ipaddr.IPv6.parseCIDR('2001:db8:f53a::1/129') + test.done() + + 'converts between IPv4-mapped IPv6 addresses and IPv4 addresses': (test) -> + addr = ipaddr.IPv4.parse('77.88.21.11') + mapped = addr.toIPv4MappedAddress() + test.deepEqual(mapped.parts, [0, 0, 0, 0, 0, 0xffff, 0x4d58, 0x150b]) + test.deepEqual(mapped.toIPv4Address().octets, addr.octets) + test.done() + + 'refuses to convert non-IPv4-mapped IPv6 address to IPv4 address': (test) -> + test.throws -> + ipaddr.IPv6.parse('2001:db8::1').toIPv4Address() + test.done() + + 'detects reserved IPv6 networks': (test) -> + test.equal(ipaddr.IPv6.parse('::').range(), 'unspecified') + test.equal(ipaddr.IPv6.parse('fe80::1234:5678:abcd:0123').range(), 'linkLocal') + test.equal(ipaddr.IPv6.parse('ff00::1234').range(), 'multicast') + test.equal(ipaddr.IPv6.parse('::1').range(), 'loopback') + test.equal(ipaddr.IPv6.parse('fc00::').range(), 'uniqueLocal') + test.equal(ipaddr.IPv6.parse('::ffff:192.168.1.10').range(), 'ipv4Mapped') + test.equal(ipaddr.IPv6.parse('::ffff:0:192.168.1.10').range(), 'rfc6145') + test.equal(ipaddr.IPv6.parse('64:ff9b::1234').range(), 'rfc6052') + test.equal(ipaddr.IPv6.parse('2002:1f63:45e8::1').range(), '6to4') + test.equal(ipaddr.IPv6.parse('2001::4242').range(), 'teredo') + test.equal(ipaddr.IPv6.parse('2001:db8::3210').range(), 'reserved') + test.equal(ipaddr.IPv6.parse('2001:470:8:66::1').range(), 'unicast') + test.done() + + 'is able to determine IP address type': (test) -> + test.equal(ipaddr.parse('8.8.8.8').kind(), 'ipv4') + test.equal(ipaddr.parse('2001:db8:3312::1').kind(), 'ipv6') + test.done() + + 'throws an error if tried to parse an invalid address': (test) -> + test.throws -> + ipaddr.parse('::some.nonsense') + test.done() + + 'correctly processes IPv4-mapped addresses': (test) -> + test.equal(ipaddr.process('8.8.8.8').kind(), 'ipv4') + test.equal(ipaddr.process('2001:db8:3312::1').kind(), 'ipv6') + test.equal(ipaddr.process('::ffff:192.168.1.1').kind(), 'ipv4') + test.done() + + 'correctly converts IPv6 and IPv4 addresses to byte arrays': (test) -> + test.deepEqual(ipaddr.parse('1.2.3.4').toByteArray(), + [0x1, 0x2, 0x3, 0x4]); + # Fuck yeah. The first byte of Google's IPv6 address is 42. 42! + test.deepEqual(ipaddr.parse('2a00:1450:8007::68').toByteArray(), + [42, 0x00, 0x14, 0x50, 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68 ]) + test.done() + + 'correctly parses 1 as an IPv4 address': (test) -> + test.equal(ipaddr.IPv6.isValid('1'), false) + test.equal(ipaddr.IPv4.isValid('1'), true) + test.deepEqual(new ipaddr.IPv4([0, 0, 0, 1]), ipaddr.parse('1')) + test.done() + + 'correctly detects IPv4 and IPv6 CIDR addresses': (test) -> + test.deepEqual([ipaddr.IPv6.parse('fc00::'), 64], + ipaddr.parseCIDR('fc00::/64')) + test.deepEqual([ipaddr.IPv4.parse('1.2.3.4'), 5], + ipaddr.parseCIDR('1.2.3.4/5')) + test.done() + + 'does not consider a very large or very small number a valid IP address': (test) -> + test.equal(ipaddr.isValid('4999999999'), false) + test.equal(ipaddr.isValid('-1'), false) + test.done() + + 'does not hang on ::8:8:8:8:8:8:8:8:8': (test) -> + test.equal(ipaddr.IPv6.isValid('::8:8:8:8:8:8:8:8:8'), false) + test.done() + + 'subnetMatch does not fail on empty range': (test) -> + ipaddr.subnetMatch(new ipaddr.IPv4([1,2,3,4]), {}, false) + ipaddr.subnetMatch(new ipaddr.IPv4([1,2,3,4]), {subnet: []}, false) + test.done() + + 'subnetMatch returns default subnet on empty range': (test) -> + test.equal(ipaddr.subnetMatch(new ipaddr.IPv4([1,2,3,4]), {}, false), false) + test.equal(ipaddr.subnetMatch(new ipaddr.IPv4([1,2,3,4]), {subnet: []}, false), false) + test.done() + + 'is able to determine IP address type from byte array input': (test) -> + test.equal(ipaddr.fromByteArray([0x7f, 0, 0, 1]).kind(), 'ipv4') + test.equal(ipaddr.fromByteArray([0x20, 0x01, 0xd, 0xb8, 0xf5, 0x3a, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]).kind(), 'ipv6') + test.throws -> + ipaddr.fromByteArray([1]) + test.done() + + 'prefixLengthFromSubnetMask returns proper CIDR notation for standard IPv4 masks': (test) -> + test.equal(ipaddr.IPv4.parse('255.255.255.255').prefixLengthFromSubnetMask(), 32) + test.equal(ipaddr.IPv4.parse('255.255.255.254').prefixLengthFromSubnetMask(), 31) + test.equal(ipaddr.IPv4.parse('255.255.255.252').prefixLengthFromSubnetMask(), 30) + test.equal(ipaddr.IPv4.parse('255.255.255.248').prefixLengthFromSubnetMask(), 29) + test.equal(ipaddr.IPv4.parse('255.255.255.240').prefixLengthFromSubnetMask(), 28) + test.equal(ipaddr.IPv4.parse('255.255.255.224').prefixLengthFromSubnetMask(), 27) + test.equal(ipaddr.IPv4.parse('255.255.255.192').prefixLengthFromSubnetMask(), 26) + test.equal(ipaddr.IPv4.parse('255.255.255.128').prefixLengthFromSubnetMask(), 25) + test.equal(ipaddr.IPv4.parse('255.255.255.0').prefixLengthFromSubnetMask(), 24) + test.equal(ipaddr.IPv4.parse('255.255.254.0').prefixLengthFromSubnetMask(), 23) + test.equal(ipaddr.IPv4.parse('255.255.252.0').prefixLengthFromSubnetMask(), 22) + test.equal(ipaddr.IPv4.parse('255.255.248.0').prefixLengthFromSubnetMask(), 21) + test.equal(ipaddr.IPv4.parse('255.255.240.0').prefixLengthFromSubnetMask(), 20) + test.equal(ipaddr.IPv4.parse('255.255.224.0').prefixLengthFromSubnetMask(), 19) + test.equal(ipaddr.IPv4.parse('255.255.192.0').prefixLengthFromSubnetMask(), 18) + test.equal(ipaddr.IPv4.parse('255.255.128.0').prefixLengthFromSubnetMask(), 17) + test.equal(ipaddr.IPv4.parse('255.255.0.0').prefixLengthFromSubnetMask(), 16) + test.equal(ipaddr.IPv4.parse('255.254.0.0').prefixLengthFromSubnetMask(), 15) + test.equal(ipaddr.IPv4.parse('255.252.0.0').prefixLengthFromSubnetMask(), 14) + test.equal(ipaddr.IPv4.parse('255.248.0.0').prefixLengthFromSubnetMask(), 13) + test.equal(ipaddr.IPv4.parse('255.240.0.0').prefixLengthFromSubnetMask(), 12) + test.equal(ipaddr.IPv4.parse('255.224.0.0').prefixLengthFromSubnetMask(), 11) + test.equal(ipaddr.IPv4.parse('255.192.0.0').prefixLengthFromSubnetMask(), 10) + test.equal(ipaddr.IPv4.parse('255.128.0.0').prefixLengthFromSubnetMask(), 9) + test.equal(ipaddr.IPv4.parse('255.0.0.0').prefixLengthFromSubnetMask(), 8) + test.equal(ipaddr.IPv4.parse('254.0.0.0').prefixLengthFromSubnetMask(), 7) + test.equal(ipaddr.IPv4.parse('252.0.0.0').prefixLengthFromSubnetMask(), 6) + test.equal(ipaddr.IPv4.parse('248.0.0.0').prefixLengthFromSubnetMask(), 5) + test.equal(ipaddr.IPv4.parse('240.0.0.0').prefixLengthFromSubnetMask(), 4) + test.equal(ipaddr.IPv4.parse('224.0.0.0').prefixLengthFromSubnetMask(), 3) + test.equal(ipaddr.IPv4.parse('192.0.0.0').prefixLengthFromSubnetMask(), 2) + test.equal(ipaddr.IPv4.parse('128.0.0.0').prefixLengthFromSubnetMask(), 1) + test.equal(ipaddr.IPv4.parse('0.0.0.0').prefixLengthFromSubnetMask(), 0) + # negative cases + test.equal(ipaddr.IPv4.parse('192.168.255.0').prefixLengthFromSubnetMask(), null) + test.equal(ipaddr.IPv4.parse('255.0.255.0').prefixLengthFromSubnetMask(), null) + test.done() + diff --git a/ui/node_modules/express/node_modules/proxy-addr/package.json b/ui/node_modules/express/node_modules/proxy-addr/package.json index c67f5024..89b8708e 100644 --- a/ui/node_modules/express/node_modules/proxy-addr/package.json +++ b/ui/node_modules/express/node_modules/proxy-addr/package.json @@ -1,75 +1,75 @@ -{ - "name": "proxy-addr", - "description": "Determine address of proxied request", - "version": "1.1.2", - "author": { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - }, - "license": "MIT", - "keywords": [ - "ip", - "proxy", - "x-forwarded-for" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/proxy-addr.git" - }, - "dependencies": { - "forwarded": "~0.1.0", - "ipaddr.js": "1.1.1" - }, - "devDependencies": { - "benchmark": "2.1.0", - "beautify-benchmark": "0.2.4", - "istanbul": "0.4.3", - "mocha": "~1.21.5" - }, - "files": [ - "LICENSE", - "HISTORY.md", - "README.md", - "index.js" - ], - "engines": { - "node": ">= 0.6" - }, - "scripts": { - "bench": "node benchmark/index.js", - "test": "mocha --reporter spec --bail --check-leaks test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" - }, - "gitHead": "28c34525632884a6d5e69a9165d7420b3f972d8b", - "bugs": { - "url": "https://github.com/jshttp/proxy-addr/issues" - }, - "homepage": "https://github.com/jshttp/proxy-addr#readme", - "_id": "proxy-addr@1.1.2", - "_shasum": "b4cc5f22610d9535824c123aef9d3cf73c40ba37", - "_from": "proxy-addr@>=1.1.2 <1.2.0", - "_npmVersion": "2.15.1", - "_nodeVersion": "4.4.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "b4cc5f22610d9535824c123aef9d3cf73c40ba37", - "tarball": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-1.1.2.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/proxy-addr-1.1.2.tgz_1464573376704_0.6896329398732632" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-1.1.2.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "proxy-addr", + "description": "Determine address of proxied request", + "version": "1.1.2", + "author": { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + }, + "license": "MIT", + "keywords": [ + "ip", + "proxy", + "x-forwarded-for" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/proxy-addr.git" + }, + "dependencies": { + "forwarded": "~0.1.0", + "ipaddr.js": "1.1.1" + }, + "devDependencies": { + "benchmark": "2.1.0", + "beautify-benchmark": "0.2.4", + "istanbul": "0.4.3", + "mocha": "~1.21.5" + }, + "files": [ + "LICENSE", + "HISTORY.md", + "README.md", + "index.js" + ], + "engines": { + "node": ">= 0.6" + }, + "scripts": { + "bench": "node benchmark/index.js", + "test": "mocha --reporter spec --bail --check-leaks test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" + }, + "gitHead": "28c34525632884a6d5e69a9165d7420b3f972d8b", + "bugs": { + "url": "https://github.com/jshttp/proxy-addr/issues" + }, + "homepage": "https://github.com/jshttp/proxy-addr#readme", + "_id": "proxy-addr@1.1.2", + "_shasum": "b4cc5f22610d9535824c123aef9d3cf73c40ba37", + "_from": "proxy-addr@>=1.1.2 <1.2.0", + "_npmVersion": "2.15.1", + "_nodeVersion": "4.4.3", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "dist": { + "shasum": "b4cc5f22610d9535824c123aef9d3cf73c40ba37", + "tarball": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-1.1.2.tgz" + }, + "maintainers": [ + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + } + ], + "_npmOperationalInternal": { + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/proxy-addr-1.1.2.tgz_1464573376704_0.6896329398732632" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-1.1.2.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/qs/.eslintignore b/ui/node_modules/express/node_modules/qs/.eslintignore index 6fc7bee6..1521c8b7 100644 --- a/ui/node_modules/express/node_modules/qs/.eslintignore +++ b/ui/node_modules/express/node_modules/qs/.eslintignore @@ -1 +1 @@ -dist +dist diff --git a/ui/node_modules/express/node_modules/qs/.eslintrc b/ui/node_modules/express/node_modules/qs/.eslintrc index 185afdc3..1faac273 100644 --- a/ui/node_modules/express/node_modules/qs/.eslintrc +++ b/ui/node_modules/express/node_modules/qs/.eslintrc @@ -1,19 +1,19 @@ -{ - "root": true, - - "extends": "@ljharb", - - "rules": { - "complexity": [2, 22], - "consistent-return": [1], - "id-length": [2, { "min": 1, "max": 25, "properties": "never" }], - "indent": [2, 4], - "max-params": [2, 9], - "max-statements": [2, 36], - "no-extra-parens": [1], - "no-continue": [1], - "no-magic-numbers": 0, - "no-restricted-syntax": [2, "BreakStatement", "DebuggerStatement", "ForInStatement", "LabeledStatement", "WithStatement"], - "operator-linebreak": 1 - } -} +{ + "root": true, + + "extends": "@ljharb", + + "rules": { + "complexity": [2, 22], + "consistent-return": [1], + "id-length": [2, { "min": 1, "max": 25, "properties": "never" }], + "indent": [2, 4], + "max-params": [2, 9], + "max-statements": [2, 36], + "no-extra-parens": [1], + "no-continue": [1], + "no-magic-numbers": 0, + "no-restricted-syntax": [2, "BreakStatement", "DebuggerStatement", "ForInStatement", "LabeledStatement", "WithStatement"], + "operator-linebreak": 1 + } +} diff --git a/ui/node_modules/express/node_modules/qs/.jscs.json b/ui/node_modules/express/node_modules/qs/.jscs.json index 0070ed72..3d099c4b 100644 --- a/ui/node_modules/express/node_modules/qs/.jscs.json +++ b/ui/node_modules/express/node_modules/qs/.jscs.json @@ -1,176 +1,176 @@ -{ - "es3": true, - - "additionalRules": [], - - "requireSemicolons": true, - - "disallowMultipleSpaces": true, - - "disallowIdentifierNames": [], - - "requireCurlyBraces": { - "allExcept": [], - "keywords": ["if", "else", "for", "while", "do", "try", "catch"] - }, - - "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"], - - "disallowSpaceAfterKeywords": [], - - "disallowSpaceBeforeComma": true, - "disallowSpaceAfterComma": false, - "disallowSpaceBeforeSemicolon": true, - - "disallowNodeTypes": [ - "DebuggerStatement", - "ForInStatement", - "LabeledStatement", - "SwitchCase", - "SwitchStatement", - "WithStatement" - ], - - "requireObjectKeysOnNewLine": { "allExcept": ["sameLine"] }, - - "requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true }, - "requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true }, - "disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true }, - "requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true }, - "disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true }, - - "requireSpaceBetweenArguments": true, - - "disallowSpacesInsideParentheses": true, - - "disallowSpacesInsideArrayBrackets": true, - - "disallowQuotedKeysInObjects": { "allExcept": ["reserved"] }, - - "disallowSpaceAfterObjectKeys": true, - - "requireCommaBeforeLineBreak": true, - - "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], - "requireSpaceAfterPrefixUnaryOperators": [], - - "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], - "requireSpaceBeforePostfixUnaryOperators": [], - - "disallowSpaceBeforeBinaryOperators": [], - "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], - - "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], - "disallowSpaceAfterBinaryOperators": [], - - "disallowImplicitTypeConversion": ["binary", "string"], - - "disallowKeywords": ["with", "eval"], - - "requireKeywordsOnNewLine": [], - "disallowKeywordsOnNewLine": ["else"], - - "requireLineFeedAtFileEnd": true, - - "disallowTrailingWhitespace": true, - - "disallowTrailingComma": true, - - "excludeFiles": ["node_modules/**", "vendor/**"], - - "disallowMultipleLineStrings": true, - - "requireDotNotation": { "allExcept": ["keywords"] }, - - "requireParenthesesAroundIIFE": true, - - "validateLineBreaks": "LF", - - "validateQuoteMarks": { - "escape": true, - "mark": "'" - }, - - "disallowOperatorBeforeLineBreak": [], - - "requireSpaceBeforeKeywords": [ - "do", - "for", - "if", - "else", - "switch", - "case", - "try", - "catch", - "finally", - "while", - "with", - "return" - ], - - "validateAlignedFunctionParameters": { - "lineBreakAfterOpeningBraces": true, - "lineBreakBeforeClosingBraces": true - }, - - "requirePaddingNewLinesBeforeExport": true, - - "validateNewlineAfterArrayElements": { - "maximum": 1 - }, - - "requirePaddingNewLinesAfterUseStrict": true, - - "disallowArrowFunctions": true, - - "disallowMultiLineTernary": true, - - "validateOrderInObjectKeys": "asc-insensitive", - - "disallowIdenticalDestructuringNames": true, - - "disallowNestedTernaries": { "maxLevel": 1 }, - - "requireSpaceAfterComma": { "allExcept": ["trailing"] }, - "requireAlignedMultilineParams": false, - - "requireSpacesInGenerator": { - "afterStar": true - }, - - "disallowSpacesInGenerator": { - "beforeStar": true - }, - - "disallowVar": false, - - "requireArrayDestructuring": false, - - "requireEnhancedObjectLiterals": false, - - "requireObjectDestructuring": false, - - "requireEarlyReturn": false, - - "requireCapitalizedConstructorsNew": { - "allExcept": ["Function", "String", "Object", "Symbol", "Number", "Date", "RegExp", "Error", "Boolean", "Array"] - }, - - "requireImportAlphabetized": false, - - "requireSpaceBeforeObjectValues": true, - "requireSpaceBeforeDestructuredValues": true, - - "disallowSpacesInsideTemplateStringPlaceholders": true, - - "disallowArrayDestructuringReturn": false, - - "requireNewlineBeforeSingleStatementsInIf": false, - - "disallowUnusedVariables": true, - - "requireSpacesInsideImportedObjectBraces": true, - - "requireUseStrict": true -} - +{ + "es3": true, + + "additionalRules": [], + + "requireSemicolons": true, + + "disallowMultipleSpaces": true, + + "disallowIdentifierNames": [], + + "requireCurlyBraces": { + "allExcept": [], + "keywords": ["if", "else", "for", "while", "do", "try", "catch"] + }, + + "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"], + + "disallowSpaceAfterKeywords": [], + + "disallowSpaceBeforeComma": true, + "disallowSpaceAfterComma": false, + "disallowSpaceBeforeSemicolon": true, + + "disallowNodeTypes": [ + "DebuggerStatement", + "ForInStatement", + "LabeledStatement", + "SwitchCase", + "SwitchStatement", + "WithStatement" + ], + + "requireObjectKeysOnNewLine": { "allExcept": ["sameLine"] }, + + "requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true }, + "requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true }, + "requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true }, + + "requireSpaceBetweenArguments": true, + + "disallowSpacesInsideParentheses": true, + + "disallowSpacesInsideArrayBrackets": true, + + "disallowQuotedKeysInObjects": { "allExcept": ["reserved"] }, + + "disallowSpaceAfterObjectKeys": true, + + "requireCommaBeforeLineBreak": true, + + "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], + "requireSpaceAfterPrefixUnaryOperators": [], + + "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], + "requireSpaceBeforePostfixUnaryOperators": [], + + "disallowSpaceBeforeBinaryOperators": [], + "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + + "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + "disallowSpaceAfterBinaryOperators": [], + + "disallowImplicitTypeConversion": ["binary", "string"], + + "disallowKeywords": ["with", "eval"], + + "requireKeywordsOnNewLine": [], + "disallowKeywordsOnNewLine": ["else"], + + "requireLineFeedAtFileEnd": true, + + "disallowTrailingWhitespace": true, + + "disallowTrailingComma": true, + + "excludeFiles": ["node_modules/**", "vendor/**"], + + "disallowMultipleLineStrings": true, + + "requireDotNotation": { "allExcept": ["keywords"] }, + + "requireParenthesesAroundIIFE": true, + + "validateLineBreaks": "LF", + + "validateQuoteMarks": { + "escape": true, + "mark": "'" + }, + + "disallowOperatorBeforeLineBreak": [], + + "requireSpaceBeforeKeywords": [ + "do", + "for", + "if", + "else", + "switch", + "case", + "try", + "catch", + "finally", + "while", + "with", + "return" + ], + + "validateAlignedFunctionParameters": { + "lineBreakAfterOpeningBraces": true, + "lineBreakBeforeClosingBraces": true + }, + + "requirePaddingNewLinesBeforeExport": true, + + "validateNewlineAfterArrayElements": { + "maximum": 1 + }, + + "requirePaddingNewLinesAfterUseStrict": true, + + "disallowArrowFunctions": true, + + "disallowMultiLineTernary": true, + + "validateOrderInObjectKeys": "asc-insensitive", + + "disallowIdenticalDestructuringNames": true, + + "disallowNestedTernaries": { "maxLevel": 1 }, + + "requireSpaceAfterComma": { "allExcept": ["trailing"] }, + "requireAlignedMultilineParams": false, + + "requireSpacesInGenerator": { + "afterStar": true + }, + + "disallowSpacesInGenerator": { + "beforeStar": true + }, + + "disallowVar": false, + + "requireArrayDestructuring": false, + + "requireEnhancedObjectLiterals": false, + + "requireObjectDestructuring": false, + + "requireEarlyReturn": false, + + "requireCapitalizedConstructorsNew": { + "allExcept": ["Function", "String", "Object", "Symbol", "Number", "Date", "RegExp", "Error", "Boolean", "Array"] + }, + + "requireImportAlphabetized": false, + + "requireSpaceBeforeObjectValues": true, + "requireSpaceBeforeDestructuredValues": true, + + "disallowSpacesInsideTemplateStringPlaceholders": true, + + "disallowArrayDestructuringReturn": false, + + "requireNewlineBeforeSingleStatementsInIf": false, + + "disallowUnusedVariables": true, + + "requireSpacesInsideImportedObjectBraces": true, + + "requireUseStrict": true +} + diff --git a/ui/node_modules/express/node_modules/qs/CHANGELOG.md b/ui/node_modules/express/node_modules/qs/CHANGELOG.md index 74704112..e318a054 100644 --- a/ui/node_modules/express/node_modules/qs/CHANGELOG.md +++ b/ui/node_modules/express/node_modules/qs/CHANGELOG.md @@ -1,120 +1,120 @@ -## [**6.2.0**](https://github.com/ljharb/qs/issues?milestone=36&state=closed) -- [New] pass Buffers to the encoder/decoder directly (#161) -- [New] add "encoder" and "decoder" options, for custom param encoding/decoding (#160) -- [Fix] fix compacting of nested sparse arrays (#150) - -## [**6.1.0**](https://github.com/ljharb/qs/issues?milestone=35&state=closed) -- [New] allowDots option for `stringify` (#151) -- [Fix] "sort" option should work at a depth of 3 or more (#151) -- [Fix] Restore `dist` directory; will be removed in v7 (#148) - -## [**6.0.2**](https://github.com/ljharb/qs/issues?milestone=33&state=closed) -- Revert ES6 requirement and restore support for node down to v0.8. - -## [**6.0.1**](https://github.com/ljharb/qs/issues?milestone=32&state=closed) -- [**#127**](https://github.com/ljharb/qs/pull/127) Fix engines definition in package.json - -## [**6.0.0**](https://github.com/ljharb/qs/issues?milestone=31&state=closed) -- [**#124**](https://github.com/ljharb/qs/issues/124) Use ES6 and drop support for node < v4 - -## [**5.2.0**](https://github.com/ljharb/qs/issues?milestone=30&state=closed) -- [**#64**](https://github.com/ljharb/qs/issues/64) Add option to sort object keys in the query string - -## [**5.1.0**](https://github.com/ljharb/qs/issues?milestone=29&state=closed) -- [**#117**](https://github.com/ljharb/qs/issues/117) make URI encoding stringified results optional -- [**#106**](https://github.com/ljharb/qs/issues/106) Add flag `skipNulls` to optionally skip null values in stringify - -## [**5.0.0**](https://github.com/ljharb/qs/issues?milestone=28&state=closed) -- [**#114**](https://github.com/ljharb/qs/issues/114) default allowDots to false -- [**#100**](https://github.com/ljharb/qs/issues/100) include dist to npm - -## [**4.0.0**](https://github.com/ljharb/qs/issues?milestone=26&state=closed) -- [**#98**](https://github.com/ljharb/qs/issues/98) make returning plain objects and allowing prototype overwriting properties optional - -## [**3.1.0**](https://github.com/ljharb/qs/issues?milestone=24&state=closed) -- [**#89**](https://github.com/ljharb/qs/issues/89) Add option to disable "Transform dot notation to bracket notation" - -## [**3.0.0**](https://github.com/ljharb/qs/issues?milestone=23&state=closed) -- [**#80**](https://github.com/ljharb/qs/issues/80) qs.parse silently drops properties -- [**#77**](https://github.com/ljharb/qs/issues/77) Perf boost -- [**#60**](https://github.com/ljharb/qs/issues/60) Add explicit option to disable array parsing -- [**#74**](https://github.com/ljharb/qs/issues/74) Bad parse when turning array into object -- [**#81**](https://github.com/ljharb/qs/issues/81) Add a `filter` option -- [**#68**](https://github.com/ljharb/qs/issues/68) Fixed issue with recursion and passing strings into objects. -- [**#66**](https://github.com/ljharb/qs/issues/66) Add mixed array and object dot notation support Closes: #47 -- [**#76**](https://github.com/ljharb/qs/issues/76) RFC 3986 -- [**#85**](https://github.com/ljharb/qs/issues/85) No equal sign -- [**#84**](https://github.com/ljharb/qs/issues/84) update license attribute - -## [**2.4.1**](https://github.com/ljharb/qs/issues?milestone=20&state=closed) -- [**#73**](https://github.com/ljharb/qs/issues/73) Property 'hasOwnProperty' of object # is not a function - -## [**2.4.0**](https://github.com/ljharb/qs/issues?milestone=19&state=closed) -- [**#70**](https://github.com/ljharb/qs/issues/70) Add arrayFormat option - -## [**2.3.3**](https://github.com/ljharb/qs/issues?milestone=18&state=closed) -- [**#59**](https://github.com/ljharb/qs/issues/59) make sure array indexes are >= 0, closes #57 -- [**#58**](https://github.com/ljharb/qs/issues/58) make qs usable for browser loader - -## [**2.3.2**](https://github.com/ljharb/qs/issues?milestone=17&state=closed) -- [**#55**](https://github.com/ljharb/qs/issues/55) allow merging a string into an object - -## [**2.3.1**](https://github.com/ljharb/qs/issues?milestone=16&state=closed) -- [**#52**](https://github.com/ljharb/qs/issues/52) Return "undefined" and "false" instead of throwing "TypeError". - -## [**2.3.0**](https://github.com/ljharb/qs/issues?milestone=15&state=closed) -- [**#50**](https://github.com/ljharb/qs/issues/50) add option to omit array indices, closes #46 - -## [**2.2.5**](https://github.com/ljharb/qs/issues?milestone=14&state=closed) -- [**#39**](https://github.com/ljharb/qs/issues/39) Is there an alternative to Buffer.isBuffer? -- [**#49**](https://github.com/ljharb/qs/issues/49) refactor utils.merge, fixes #45 -- [**#41**](https://github.com/ljharb/qs/issues/41) avoid browserifying Buffer, for #39 - -## [**2.2.4**](https://github.com/ljharb/qs/issues?milestone=13&state=closed) -- [**#38**](https://github.com/ljharb/qs/issues/38) how to handle object keys beginning with a number - -## [**2.2.3**](https://github.com/ljharb/qs/issues?milestone=12&state=closed) -- [**#37**](https://github.com/ljharb/qs/issues/37) parser discards first empty value in array -- [**#36**](https://github.com/ljharb/qs/issues/36) Update to lab 4.x - -## [**2.2.2**](https://github.com/ljharb/qs/issues?milestone=11&state=closed) -- [**#33**](https://github.com/ljharb/qs/issues/33) Error when plain object in a value -- [**#34**](https://github.com/ljharb/qs/issues/34) use Object.prototype.hasOwnProperty.call instead of obj.hasOwnProperty -- [**#24**](https://github.com/ljharb/qs/issues/24) Changelog? Semver? - -## [**2.2.1**](https://github.com/ljharb/qs/issues?milestone=10&state=closed) -- [**#32**](https://github.com/ljharb/qs/issues/32) account for circular references properly, closes #31 -- [**#31**](https://github.com/ljharb/qs/issues/31) qs.parse stackoverflow on circular objects - -## [**2.2.0**](https://github.com/ljharb/qs/issues?milestone=9&state=closed) -- [**#26**](https://github.com/ljharb/qs/issues/26) Don't use Buffer global if it's not present -- [**#30**](https://github.com/ljharb/qs/issues/30) Bug when merging non-object values into arrays -- [**#29**](https://github.com/ljharb/qs/issues/29) Don't call Utils.clone at the top of Utils.merge -- [**#23**](https://github.com/ljharb/qs/issues/23) Ability to not limit parameters? - -## [**2.1.0**](https://github.com/ljharb/qs/issues?milestone=8&state=closed) -- [**#22**](https://github.com/ljharb/qs/issues/22) Enable using a RegExp as delimiter - -## [**2.0.0**](https://github.com/ljharb/qs/issues?milestone=7&state=closed) -- [**#18**](https://github.com/ljharb/qs/issues/18) Why is there arrayLimit? -- [**#20**](https://github.com/ljharb/qs/issues/20) Configurable parametersLimit -- [**#21**](https://github.com/ljharb/qs/issues/21) make all limits optional, for #18, for #20 - -## [**1.2.2**](https://github.com/ljharb/qs/issues?milestone=6&state=closed) -- [**#19**](https://github.com/ljharb/qs/issues/19) Don't overwrite null values - -## [**1.2.1**](https://github.com/ljharb/qs/issues?milestone=5&state=closed) -- [**#16**](https://github.com/ljharb/qs/issues/16) ignore non-string delimiters -- [**#15**](https://github.com/ljharb/qs/issues/15) Close code block - -## [**1.2.0**](https://github.com/ljharb/qs/issues?milestone=4&state=closed) -- [**#12**](https://github.com/ljharb/qs/issues/12) Add optional delim argument -- [**#13**](https://github.com/ljharb/qs/issues/13) fix #11: flattened keys in array are now correctly parsed - -## [**1.1.0**](https://github.com/ljharb/qs/issues?milestone=3&state=closed) -- [**#7**](https://github.com/ljharb/qs/issues/7) Empty values of a POST array disappear after being submitted -- [**#9**](https://github.com/ljharb/qs/issues/9) Should not omit equals signs (=) when value is null -- [**#6**](https://github.com/ljharb/qs/issues/6) Minor grammar fix in README - -## [**1.0.2**](https://github.com/ljharb/qs/issues?milestone=2&state=closed) -- [**#5**](https://github.com/ljharb/qs/issues/5) array holes incorrectly copied into object on large index +## [**6.2.0**](https://github.com/ljharb/qs/issues?milestone=36&state=closed) +- [New] pass Buffers to the encoder/decoder directly (#161) +- [New] add "encoder" and "decoder" options, for custom param encoding/decoding (#160) +- [Fix] fix compacting of nested sparse arrays (#150) + +## [**6.1.0**](https://github.com/ljharb/qs/issues?milestone=35&state=closed) +- [New] allowDots option for `stringify` (#151) +- [Fix] "sort" option should work at a depth of 3 or more (#151) +- [Fix] Restore `dist` directory; will be removed in v7 (#148) + +## [**6.0.2**](https://github.com/ljharb/qs/issues?milestone=33&state=closed) +- Revert ES6 requirement and restore support for node down to v0.8. + +## [**6.0.1**](https://github.com/ljharb/qs/issues?milestone=32&state=closed) +- [**#127**](https://github.com/ljharb/qs/pull/127) Fix engines definition in package.json + +## [**6.0.0**](https://github.com/ljharb/qs/issues?milestone=31&state=closed) +- [**#124**](https://github.com/ljharb/qs/issues/124) Use ES6 and drop support for node < v4 + +## [**5.2.0**](https://github.com/ljharb/qs/issues?milestone=30&state=closed) +- [**#64**](https://github.com/ljharb/qs/issues/64) Add option to sort object keys in the query string + +## [**5.1.0**](https://github.com/ljharb/qs/issues?milestone=29&state=closed) +- [**#117**](https://github.com/ljharb/qs/issues/117) make URI encoding stringified results optional +- [**#106**](https://github.com/ljharb/qs/issues/106) Add flag `skipNulls` to optionally skip null values in stringify + +## [**5.0.0**](https://github.com/ljharb/qs/issues?milestone=28&state=closed) +- [**#114**](https://github.com/ljharb/qs/issues/114) default allowDots to false +- [**#100**](https://github.com/ljharb/qs/issues/100) include dist to npm + +## [**4.0.0**](https://github.com/ljharb/qs/issues?milestone=26&state=closed) +- [**#98**](https://github.com/ljharb/qs/issues/98) make returning plain objects and allowing prototype overwriting properties optional + +## [**3.1.0**](https://github.com/ljharb/qs/issues?milestone=24&state=closed) +- [**#89**](https://github.com/ljharb/qs/issues/89) Add option to disable "Transform dot notation to bracket notation" + +## [**3.0.0**](https://github.com/ljharb/qs/issues?milestone=23&state=closed) +- [**#80**](https://github.com/ljharb/qs/issues/80) qs.parse silently drops properties +- [**#77**](https://github.com/ljharb/qs/issues/77) Perf boost +- [**#60**](https://github.com/ljharb/qs/issues/60) Add explicit option to disable array parsing +- [**#74**](https://github.com/ljharb/qs/issues/74) Bad parse when turning array into object +- [**#81**](https://github.com/ljharb/qs/issues/81) Add a `filter` option +- [**#68**](https://github.com/ljharb/qs/issues/68) Fixed issue with recursion and passing strings into objects. +- [**#66**](https://github.com/ljharb/qs/issues/66) Add mixed array and object dot notation support Closes: #47 +- [**#76**](https://github.com/ljharb/qs/issues/76) RFC 3986 +- [**#85**](https://github.com/ljharb/qs/issues/85) No equal sign +- [**#84**](https://github.com/ljharb/qs/issues/84) update license attribute + +## [**2.4.1**](https://github.com/ljharb/qs/issues?milestone=20&state=closed) +- [**#73**](https://github.com/ljharb/qs/issues/73) Property 'hasOwnProperty' of object # is not a function + +## [**2.4.0**](https://github.com/ljharb/qs/issues?milestone=19&state=closed) +- [**#70**](https://github.com/ljharb/qs/issues/70) Add arrayFormat option + +## [**2.3.3**](https://github.com/ljharb/qs/issues?milestone=18&state=closed) +- [**#59**](https://github.com/ljharb/qs/issues/59) make sure array indexes are >= 0, closes #57 +- [**#58**](https://github.com/ljharb/qs/issues/58) make qs usable for browser loader + +## [**2.3.2**](https://github.com/ljharb/qs/issues?milestone=17&state=closed) +- [**#55**](https://github.com/ljharb/qs/issues/55) allow merging a string into an object + +## [**2.3.1**](https://github.com/ljharb/qs/issues?milestone=16&state=closed) +- [**#52**](https://github.com/ljharb/qs/issues/52) Return "undefined" and "false" instead of throwing "TypeError". + +## [**2.3.0**](https://github.com/ljharb/qs/issues?milestone=15&state=closed) +- [**#50**](https://github.com/ljharb/qs/issues/50) add option to omit array indices, closes #46 + +## [**2.2.5**](https://github.com/ljharb/qs/issues?milestone=14&state=closed) +- [**#39**](https://github.com/ljharb/qs/issues/39) Is there an alternative to Buffer.isBuffer? +- [**#49**](https://github.com/ljharb/qs/issues/49) refactor utils.merge, fixes #45 +- [**#41**](https://github.com/ljharb/qs/issues/41) avoid browserifying Buffer, for #39 + +## [**2.2.4**](https://github.com/ljharb/qs/issues?milestone=13&state=closed) +- [**#38**](https://github.com/ljharb/qs/issues/38) how to handle object keys beginning with a number + +## [**2.2.3**](https://github.com/ljharb/qs/issues?milestone=12&state=closed) +- [**#37**](https://github.com/ljharb/qs/issues/37) parser discards first empty value in array +- [**#36**](https://github.com/ljharb/qs/issues/36) Update to lab 4.x + +## [**2.2.2**](https://github.com/ljharb/qs/issues?milestone=11&state=closed) +- [**#33**](https://github.com/ljharb/qs/issues/33) Error when plain object in a value +- [**#34**](https://github.com/ljharb/qs/issues/34) use Object.prototype.hasOwnProperty.call instead of obj.hasOwnProperty +- [**#24**](https://github.com/ljharb/qs/issues/24) Changelog? Semver? + +## [**2.2.1**](https://github.com/ljharb/qs/issues?milestone=10&state=closed) +- [**#32**](https://github.com/ljharb/qs/issues/32) account for circular references properly, closes #31 +- [**#31**](https://github.com/ljharb/qs/issues/31) qs.parse stackoverflow on circular objects + +## [**2.2.0**](https://github.com/ljharb/qs/issues?milestone=9&state=closed) +- [**#26**](https://github.com/ljharb/qs/issues/26) Don't use Buffer global if it's not present +- [**#30**](https://github.com/ljharb/qs/issues/30) Bug when merging non-object values into arrays +- [**#29**](https://github.com/ljharb/qs/issues/29) Don't call Utils.clone at the top of Utils.merge +- [**#23**](https://github.com/ljharb/qs/issues/23) Ability to not limit parameters? + +## [**2.1.0**](https://github.com/ljharb/qs/issues?milestone=8&state=closed) +- [**#22**](https://github.com/ljharb/qs/issues/22) Enable using a RegExp as delimiter + +## [**2.0.0**](https://github.com/ljharb/qs/issues?milestone=7&state=closed) +- [**#18**](https://github.com/ljharb/qs/issues/18) Why is there arrayLimit? +- [**#20**](https://github.com/ljharb/qs/issues/20) Configurable parametersLimit +- [**#21**](https://github.com/ljharb/qs/issues/21) make all limits optional, for #18, for #20 + +## [**1.2.2**](https://github.com/ljharb/qs/issues?milestone=6&state=closed) +- [**#19**](https://github.com/ljharb/qs/issues/19) Don't overwrite null values + +## [**1.2.1**](https://github.com/ljharb/qs/issues?milestone=5&state=closed) +- [**#16**](https://github.com/ljharb/qs/issues/16) ignore non-string delimiters +- [**#15**](https://github.com/ljharb/qs/issues/15) Close code block + +## [**1.2.0**](https://github.com/ljharb/qs/issues?milestone=4&state=closed) +- [**#12**](https://github.com/ljharb/qs/issues/12) Add optional delim argument +- [**#13**](https://github.com/ljharb/qs/issues/13) fix #11: flattened keys in array are now correctly parsed + +## [**1.1.0**](https://github.com/ljharb/qs/issues?milestone=3&state=closed) +- [**#7**](https://github.com/ljharb/qs/issues/7) Empty values of a POST array disappear after being submitted +- [**#9**](https://github.com/ljharb/qs/issues/9) Should not omit equals signs (=) when value is null +- [**#6**](https://github.com/ljharb/qs/issues/6) Minor grammar fix in README + +## [**1.0.2**](https://github.com/ljharb/qs/issues?milestone=2&state=closed) +- [**#5**](https://github.com/ljharb/qs/issues/5) array holes incorrectly copied into object on large index diff --git a/ui/node_modules/express/node_modules/qs/CONTRIBUTING.md b/ui/node_modules/express/node_modules/qs/CONTRIBUTING.md index 44009afb..89283615 100644 --- a/ui/node_modules/express/node_modules/qs/CONTRIBUTING.md +++ b/ui/node_modules/express/node_modules/qs/CONTRIBUTING.md @@ -1 +1 @@ -Please view our [hapijs contributing guide](https://github.com/hapijs/hapi/blob/master/CONTRIBUTING.md). +Please view our [hapijs contributing guide](https://github.com/hapijs/hapi/blob/master/CONTRIBUTING.md). diff --git a/ui/node_modules/express/node_modules/qs/LICENSE b/ui/node_modules/express/node_modules/qs/LICENSE index 7d5d7adf..d4569487 100644 --- a/ui/node_modules/express/node_modules/qs/LICENSE +++ b/ui/node_modules/express/node_modules/qs/LICENSE @@ -1,28 +1,28 @@ -Copyright (c) 2014 Nathan LaFreniere and other contributors. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * The names of any contributors may not be used to endorse or promote - products derived from this software without specific prior written - permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - * * * - -The complete list of contributors can be found at: https://github.com/hapijs/qs/graphs/contributors +Copyright (c) 2014 Nathan LaFreniere and other contributors. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * The names of any contributors may not be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + * * * + +The complete list of contributors can be found at: https://github.com/hapijs/qs/graphs/contributors diff --git a/ui/node_modules/express/node_modules/qs/dist/qs.js b/ui/node_modules/express/node_modules/qs/dist/qs.js index 8d170bb8..4cc6f306 100644 --- a/ui/node_modules/express/node_modules/qs/dist/qs.js +++ b/ui/node_modules/express/node_modules/qs/dist/qs.js @@ -1,487 +1,487 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Qs = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o= 0 && - (options.parseArrays && index <= options.arrayLimit) - ) { - obj = []; - obj[index] = parseObject(chain, val, options); - } else { - obj[cleanRoot] = parseObject(chain, val, options); - } - } - - return obj; -}; - -var parseKeys = function parseKeys(givenKey, val, options) { - if (!givenKey) { - return; - } - - // Transform dot notation to bracket notation - var key = options.allowDots ? givenKey.replace(/\.([^\.\[]+)/g, '[$1]') : givenKey; - - // The regex chunks - - var parent = /^([^\[\]]*)/; - var child = /(\[[^\[\]]*\])/g; - - // Get the parent - - var segment = parent.exec(key); - - // Stash the parent if it exists - - var keys = []; - if (segment[1]) { - // If we aren't using plain objects, optionally prefix keys - // that would overwrite object prototype properties - if (!options.plainObjects && Object.prototype.hasOwnProperty(segment[1])) { - if (!options.allowPrototypes) { - return; - } - } - - keys.push(segment[1]); - } - - // Loop through children appending to the array until we hit depth - - var i = 0; - while ((segment = child.exec(key)) !== null && i < options.depth) { - i += 1; - if (!options.plainObjects && Object.prototype.hasOwnProperty(segment[1].replace(/\[|\]/g, ''))) { - if (!options.allowPrototypes) { - continue; - } - } - keys.push(segment[1]); - } - - // If there's a remainder, just add whatever is left - - if (segment) { - keys.push('[' + key.slice(segment.index) + ']'); - } - - return parseObject(keys, val, options); -}; - -module.exports = function (str, opts) { - var options = opts || {}; - - if (options.decoder !== null && options.decoder !== undefined && typeof options.decoder !== 'function') { - throw new TypeError('Decoder has to be a function.'); - } - - options.delimiter = typeof options.delimiter === 'string' || Utils.isRegExp(options.delimiter) ? options.delimiter : defaults.delimiter; - options.depth = typeof options.depth === 'number' ? options.depth : defaults.depth; - options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : defaults.arrayLimit; - options.parseArrays = options.parseArrays !== false; - options.decoder = typeof options.decoder === 'function' ? options.decoder : defaults.decoder; - options.allowDots = typeof options.allowDots === 'boolean' ? options.allowDots : defaults.allowDots; - options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : defaults.plainObjects; - options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : defaults.allowPrototypes; - options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : defaults.parameterLimit; - options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling; - - if (str === '' || str === null || typeof str === 'undefined') { - return options.plainObjects ? Object.create(null) : {}; - } - - var tempObj = typeof str === 'string' ? parseValues(str, options) : str; - var obj = options.plainObjects ? Object.create(null) : {}; - - // Iterate over the keys and setup the new object - - var keys = Object.keys(tempObj); - for (var i = 0; i < keys.length; ++i) { - var key = keys[i]; - var newObj = parseKeys(key, tempObj[key], options); - obj = Utils.merge(obj, newObj, options); - } - - return Utils.compact(obj); -}; - -},{"./utils":4}],3:[function(require,module,exports){ -'use strict'; - -var Utils = require('./utils'); - -var arrayPrefixGenerators = { - brackets: function brackets(prefix) { - return prefix + '[]'; - }, - indices: function indices(prefix, key) { - return prefix + '[' + key + ']'; - }, - repeat: function repeat(prefix) { - return prefix; - } -}; - -var defaults = { - delimiter: '&', - strictNullHandling: false, - skipNulls: false, - encode: true, - encoder: Utils.encode -}; - -var stringify = function stringify(object, prefix, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots) { - var obj = object; - if (typeof filter === 'function') { - obj = filter(prefix, obj); - } else if (obj instanceof Date) { - obj = obj.toISOString(); - } else if (obj === null) { - if (strictNullHandling) { - return encoder ? encoder(prefix) : prefix; - } - - obj = ''; - } - - if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || Utils.isBuffer(obj)) { - if (encoder) { - return [encoder(prefix) + '=' + encoder(obj)]; - } - return [prefix + '=' + String(obj)]; - } - - var values = []; - - if (typeof obj === 'undefined') { - return values; - } - - var objKeys; - if (Array.isArray(filter)) { - objKeys = filter; - } else { - var keys = Object.keys(obj); - objKeys = sort ? keys.sort(sort) : keys; - } - - for (var i = 0; i < objKeys.length; ++i) { - var key = objKeys[i]; - - if (skipNulls && obj[key] === null) { - continue; - } - - if (Array.isArray(obj)) { - values = values.concat(stringify(obj[key], generateArrayPrefix(prefix, key), generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots)); - } else { - values = values.concat(stringify(obj[key], prefix + (allowDots ? '.' + key : '[' + key + ']'), generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots)); - } - } - - return values; -}; - -module.exports = function (object, opts) { - var obj = object; - var options = opts || {}; - var delimiter = typeof options.delimiter === 'undefined' ? defaults.delimiter : options.delimiter; - var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling; - var skipNulls = typeof options.skipNulls === 'boolean' ? options.skipNulls : defaults.skipNulls; - var encode = typeof options.encode === 'boolean' ? options.encode : defaults.encode; - var encoder = encode ? (typeof options.encoder === 'function' ? options.encoder : defaults.encoder) : null; - var sort = typeof options.sort === 'function' ? options.sort : null; - var allowDots = typeof options.allowDots === 'undefined' ? false : options.allowDots; - var objKeys; - var filter; - - if (options.encoder !== null && options.encoder !== undefined && typeof options.encoder !== 'function') { - throw new TypeError('Encoder has to be a function.'); - } - - if (typeof options.filter === 'function') { - filter = options.filter; - obj = filter('', obj); - } else if (Array.isArray(options.filter)) { - objKeys = filter = options.filter; - } - - var keys = []; - - if (typeof obj !== 'object' || obj === null) { - return ''; - } - - var arrayFormat; - if (options.arrayFormat in arrayPrefixGenerators) { - arrayFormat = options.arrayFormat; - } else if ('indices' in options) { - arrayFormat = options.indices ? 'indices' : 'repeat'; - } else { - arrayFormat = 'indices'; - } - - var generateArrayPrefix = arrayPrefixGenerators[arrayFormat]; - - if (!objKeys) { - objKeys = Object.keys(obj); - } - - if (sort) { - objKeys.sort(sort); - } - - for (var i = 0; i < objKeys.length; ++i) { - var key = objKeys[i]; - - if (skipNulls && obj[key] === null) { - continue; - } - - keys = keys.concat(stringify(obj[key], key, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots)); - } - - return keys.join(delimiter); -}; - -},{"./utils":4}],4:[function(require,module,exports){ -'use strict'; - -var hexTable = (function () { - var array = new Array(256); - for (var i = 0; i < 256; ++i) { - array[i] = '%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase(); - } - - return array; -}()); - -exports.arrayToObject = function (source, options) { - var obj = options.plainObjects ? Object.create(null) : {}; - for (var i = 0; i < source.length; ++i) { - if (typeof source[i] !== 'undefined') { - obj[i] = source[i]; - } - } - - return obj; -}; - -exports.merge = function (target, source, options) { - if (!source) { - return target; - } - - if (typeof source !== 'object') { - if (Array.isArray(target)) { - target.push(source); - } else if (typeof target === 'object') { - target[source] = true; - } else { - return [target, source]; - } - - return target; - } - - if (typeof target !== 'object') { - return [target].concat(source); - } - - var mergeTarget = target; - if (Array.isArray(target) && !Array.isArray(source)) { - mergeTarget = exports.arrayToObject(target, options); - } - - return Object.keys(source).reduce(function (acc, key) { - var value = source[key]; - - if (Object.prototype.hasOwnProperty.call(acc, key)) { - acc[key] = exports.merge(acc[key], value, options); - } else { - acc[key] = value; - } - return acc; - }, mergeTarget); -}; - -exports.decode = function (str) { - try { - return decodeURIComponent(str.replace(/\+/g, ' ')); - } catch (e) { - return str; - } -}; - -exports.encode = function (str) { - // This code was originally written by Brian White (mscdex) for the io.js core querystring library. - // It has been adapted here for stricter adherence to RFC 3986 - if (str.length === 0) { - return str; - } - - var string = typeof str === 'string' ? str : String(str); - - var out = ''; - for (var i = 0; i < string.length; ++i) { - var c = string.charCodeAt(i); - - if ( - c === 0x2D || // - - c === 0x2E || // . - c === 0x5F || // _ - c === 0x7E || // ~ - (c >= 0x30 && c <= 0x39) || // 0-9 - (c >= 0x41 && c <= 0x5A) || // a-z - (c >= 0x61 && c <= 0x7A) // A-Z - ) { - out += string.charAt(i); - continue; - } - - if (c < 0x80) { - out = out + hexTable[c]; - continue; - } - - if (c < 0x800) { - out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]); - continue; - } - - if (c < 0xD800 || c >= 0xE000) { - out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]); - continue; - } - - i += 1; - c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF)); - out += hexTable[0xF0 | (c >> 18)] + hexTable[0x80 | ((c >> 12) & 0x3F)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]; - } - - return out; -}; - -exports.compact = function (obj, references) { - if (typeof obj !== 'object' || obj === null) { - return obj; - } - - var refs = references || []; - var lookup = refs.indexOf(obj); - if (lookup !== -1) { - return refs[lookup]; - } - - refs.push(obj); - - if (Array.isArray(obj)) { - var compacted = []; - - for (var i = 0; i < obj.length; ++i) { - if (obj[i] && typeof obj[i] === 'object') { - compacted.push(exports.compact(obj[i], refs)); - } else if (typeof obj[i] !== 'undefined') { - compacted.push(obj[i]); - } - } - - return compacted; - } - - var keys = Object.keys(obj); - for (var j = 0; j < keys.length; ++j) { - var key = keys[j]; - obj[key] = exports.compact(obj[key], refs); - } - - return obj; -}; - -exports.isRegExp = function (obj) { - return Object.prototype.toString.call(obj) === '[object RegExp]'; -}; - -exports.isBuffer = function (obj) { - if (obj === null || typeof obj === 'undefined') { - return false; - } - - return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj)); -}; - -},{}]},{},[1])(1) +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Qs = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o= 0 && + (options.parseArrays && index <= options.arrayLimit) + ) { + obj = []; + obj[index] = parseObject(chain, val, options); + } else { + obj[cleanRoot] = parseObject(chain, val, options); + } + } + + return obj; +}; + +var parseKeys = function parseKeys(givenKey, val, options) { + if (!givenKey) { + return; + } + + // Transform dot notation to bracket notation + var key = options.allowDots ? givenKey.replace(/\.([^\.\[]+)/g, '[$1]') : givenKey; + + // The regex chunks + + var parent = /^([^\[\]]*)/; + var child = /(\[[^\[\]]*\])/g; + + // Get the parent + + var segment = parent.exec(key); + + // Stash the parent if it exists + + var keys = []; + if (segment[1]) { + // If we aren't using plain objects, optionally prefix keys + // that would overwrite object prototype properties + if (!options.plainObjects && Object.prototype.hasOwnProperty(segment[1])) { + if (!options.allowPrototypes) { + return; + } + } + + keys.push(segment[1]); + } + + // Loop through children appending to the array until we hit depth + + var i = 0; + while ((segment = child.exec(key)) !== null && i < options.depth) { + i += 1; + if (!options.plainObjects && Object.prototype.hasOwnProperty(segment[1].replace(/\[|\]/g, ''))) { + if (!options.allowPrototypes) { + continue; + } + } + keys.push(segment[1]); + } + + // If there's a remainder, just add whatever is left + + if (segment) { + keys.push('[' + key.slice(segment.index) + ']'); + } + + return parseObject(keys, val, options); +}; + +module.exports = function (str, opts) { + var options = opts || {}; + + if (options.decoder !== null && options.decoder !== undefined && typeof options.decoder !== 'function') { + throw new TypeError('Decoder has to be a function.'); + } + + options.delimiter = typeof options.delimiter === 'string' || Utils.isRegExp(options.delimiter) ? options.delimiter : defaults.delimiter; + options.depth = typeof options.depth === 'number' ? options.depth : defaults.depth; + options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : defaults.arrayLimit; + options.parseArrays = options.parseArrays !== false; + options.decoder = typeof options.decoder === 'function' ? options.decoder : defaults.decoder; + options.allowDots = typeof options.allowDots === 'boolean' ? options.allowDots : defaults.allowDots; + options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : defaults.plainObjects; + options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : defaults.allowPrototypes; + options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : defaults.parameterLimit; + options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling; + + if (str === '' || str === null || typeof str === 'undefined') { + return options.plainObjects ? Object.create(null) : {}; + } + + var tempObj = typeof str === 'string' ? parseValues(str, options) : str; + var obj = options.plainObjects ? Object.create(null) : {}; + + // Iterate over the keys and setup the new object + + var keys = Object.keys(tempObj); + for (var i = 0; i < keys.length; ++i) { + var key = keys[i]; + var newObj = parseKeys(key, tempObj[key], options); + obj = Utils.merge(obj, newObj, options); + } + + return Utils.compact(obj); +}; + +},{"./utils":4}],3:[function(require,module,exports){ +'use strict'; + +var Utils = require('./utils'); + +var arrayPrefixGenerators = { + brackets: function brackets(prefix) { + return prefix + '[]'; + }, + indices: function indices(prefix, key) { + return prefix + '[' + key + ']'; + }, + repeat: function repeat(prefix) { + return prefix; + } +}; + +var defaults = { + delimiter: '&', + strictNullHandling: false, + skipNulls: false, + encode: true, + encoder: Utils.encode +}; + +var stringify = function stringify(object, prefix, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots) { + var obj = object; + if (typeof filter === 'function') { + obj = filter(prefix, obj); + } else if (obj instanceof Date) { + obj = obj.toISOString(); + } else if (obj === null) { + if (strictNullHandling) { + return encoder ? encoder(prefix) : prefix; + } + + obj = ''; + } + + if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || Utils.isBuffer(obj)) { + if (encoder) { + return [encoder(prefix) + '=' + encoder(obj)]; + } + return [prefix + '=' + String(obj)]; + } + + var values = []; + + if (typeof obj === 'undefined') { + return values; + } + + var objKeys; + if (Array.isArray(filter)) { + objKeys = filter; + } else { + var keys = Object.keys(obj); + objKeys = sort ? keys.sort(sort) : keys; + } + + for (var i = 0; i < objKeys.length; ++i) { + var key = objKeys[i]; + + if (skipNulls && obj[key] === null) { + continue; + } + + if (Array.isArray(obj)) { + values = values.concat(stringify(obj[key], generateArrayPrefix(prefix, key), generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots)); + } else { + values = values.concat(stringify(obj[key], prefix + (allowDots ? '.' + key : '[' + key + ']'), generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots)); + } + } + + return values; +}; + +module.exports = function (object, opts) { + var obj = object; + var options = opts || {}; + var delimiter = typeof options.delimiter === 'undefined' ? defaults.delimiter : options.delimiter; + var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling; + var skipNulls = typeof options.skipNulls === 'boolean' ? options.skipNulls : defaults.skipNulls; + var encode = typeof options.encode === 'boolean' ? options.encode : defaults.encode; + var encoder = encode ? (typeof options.encoder === 'function' ? options.encoder : defaults.encoder) : null; + var sort = typeof options.sort === 'function' ? options.sort : null; + var allowDots = typeof options.allowDots === 'undefined' ? false : options.allowDots; + var objKeys; + var filter; + + if (options.encoder !== null && options.encoder !== undefined && typeof options.encoder !== 'function') { + throw new TypeError('Encoder has to be a function.'); + } + + if (typeof options.filter === 'function') { + filter = options.filter; + obj = filter('', obj); + } else if (Array.isArray(options.filter)) { + objKeys = filter = options.filter; + } + + var keys = []; + + if (typeof obj !== 'object' || obj === null) { + return ''; + } + + var arrayFormat; + if (options.arrayFormat in arrayPrefixGenerators) { + arrayFormat = options.arrayFormat; + } else if ('indices' in options) { + arrayFormat = options.indices ? 'indices' : 'repeat'; + } else { + arrayFormat = 'indices'; + } + + var generateArrayPrefix = arrayPrefixGenerators[arrayFormat]; + + if (!objKeys) { + objKeys = Object.keys(obj); + } + + if (sort) { + objKeys.sort(sort); + } + + for (var i = 0; i < objKeys.length; ++i) { + var key = objKeys[i]; + + if (skipNulls && obj[key] === null) { + continue; + } + + keys = keys.concat(stringify(obj[key], key, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots)); + } + + return keys.join(delimiter); +}; + +},{"./utils":4}],4:[function(require,module,exports){ +'use strict'; + +var hexTable = (function () { + var array = new Array(256); + for (var i = 0; i < 256; ++i) { + array[i] = '%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase(); + } + + return array; +}()); + +exports.arrayToObject = function (source, options) { + var obj = options.plainObjects ? Object.create(null) : {}; + for (var i = 0; i < source.length; ++i) { + if (typeof source[i] !== 'undefined') { + obj[i] = source[i]; + } + } + + return obj; +}; + +exports.merge = function (target, source, options) { + if (!source) { + return target; + } + + if (typeof source !== 'object') { + if (Array.isArray(target)) { + target.push(source); + } else if (typeof target === 'object') { + target[source] = true; + } else { + return [target, source]; + } + + return target; + } + + if (typeof target !== 'object') { + return [target].concat(source); + } + + var mergeTarget = target; + if (Array.isArray(target) && !Array.isArray(source)) { + mergeTarget = exports.arrayToObject(target, options); + } + + return Object.keys(source).reduce(function (acc, key) { + var value = source[key]; + + if (Object.prototype.hasOwnProperty.call(acc, key)) { + acc[key] = exports.merge(acc[key], value, options); + } else { + acc[key] = value; + } + return acc; + }, mergeTarget); +}; + +exports.decode = function (str) { + try { + return decodeURIComponent(str.replace(/\+/g, ' ')); + } catch (e) { + return str; + } +}; + +exports.encode = function (str) { + // This code was originally written by Brian White (mscdex) for the io.js core querystring library. + // It has been adapted here for stricter adherence to RFC 3986 + if (str.length === 0) { + return str; + } + + var string = typeof str === 'string' ? str : String(str); + + var out = ''; + for (var i = 0; i < string.length; ++i) { + var c = string.charCodeAt(i); + + if ( + c === 0x2D || // - + c === 0x2E || // . + c === 0x5F || // _ + c === 0x7E || // ~ + (c >= 0x30 && c <= 0x39) || // 0-9 + (c >= 0x41 && c <= 0x5A) || // a-z + (c >= 0x61 && c <= 0x7A) // A-Z + ) { + out += string.charAt(i); + continue; + } + + if (c < 0x80) { + out = out + hexTable[c]; + continue; + } + + if (c < 0x800) { + out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]); + continue; + } + + if (c < 0xD800 || c >= 0xE000) { + out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]); + continue; + } + + i += 1; + c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF)); + out += hexTable[0xF0 | (c >> 18)] + hexTable[0x80 | ((c >> 12) & 0x3F)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]; + } + + return out; +}; + +exports.compact = function (obj, references) { + if (typeof obj !== 'object' || obj === null) { + return obj; + } + + var refs = references || []; + var lookup = refs.indexOf(obj); + if (lookup !== -1) { + return refs[lookup]; + } + + refs.push(obj); + + if (Array.isArray(obj)) { + var compacted = []; + + for (var i = 0; i < obj.length; ++i) { + if (obj[i] && typeof obj[i] === 'object') { + compacted.push(exports.compact(obj[i], refs)); + } else if (typeof obj[i] !== 'undefined') { + compacted.push(obj[i]); + } + } + + return compacted; + } + + var keys = Object.keys(obj); + for (var j = 0; j < keys.length; ++j) { + var key = keys[j]; + obj[key] = exports.compact(obj[key], refs); + } + + return obj; +}; + +exports.isRegExp = function (obj) { + return Object.prototype.toString.call(obj) === '[object RegExp]'; +}; + +exports.isBuffer = function (obj) { + if (obj === null || typeof obj === 'undefined') { + return false; + } + + return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj)); +}; + +},{}]},{},[1])(1) }); \ No newline at end of file diff --git a/ui/node_modules/express/node_modules/qs/lib/index.js b/ui/node_modules/express/node_modules/qs/lib/index.js old mode 100755 new mode 100644 index fd0c0e69..19019590 --- a/ui/node_modules/express/node_modules/qs/lib/index.js +++ b/ui/node_modules/express/node_modules/qs/lib/index.js @@ -1,9 +1,9 @@ -'use strict'; - -var Stringify = require('./stringify'); -var Parse = require('./parse'); - -module.exports = { - stringify: Stringify, - parse: Parse -}; +'use strict'; + +var Stringify = require('./stringify'); +var Parse = require('./parse'); + +module.exports = { + stringify: Stringify, + parse: Parse +}; diff --git a/ui/node_modules/express/node_modules/qs/lib/parse.js b/ui/node_modules/express/node_modules/qs/lib/parse.js old mode 100755 new mode 100644 index dc8899cc..bf70fd8d --- a/ui/node_modules/express/node_modules/qs/lib/parse.js +++ b/ui/node_modules/express/node_modules/qs/lib/parse.js @@ -1,167 +1,167 @@ -'use strict'; - -var Utils = require('./utils'); - -var defaults = { - delimiter: '&', - depth: 5, - arrayLimit: 20, - parameterLimit: 1000, - strictNullHandling: false, - plainObjects: false, - allowPrototypes: false, - allowDots: false, - decoder: Utils.decode -}; - -var parseValues = function parseValues(str, options) { - var obj = {}; - var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit); - - for (var i = 0; i < parts.length; ++i) { - var part = parts[i]; - var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1; - - if (pos === -1) { - obj[options.decoder(part)] = ''; - - if (options.strictNullHandling) { - obj[options.decoder(part)] = null; - } - } else { - var key = options.decoder(part.slice(0, pos)); - var val = options.decoder(part.slice(pos + 1)); - - if (Object.prototype.hasOwnProperty.call(obj, key)) { - obj[key] = [].concat(obj[key]).concat(val); - } else { - obj[key] = val; - } - } - } - - return obj; -}; - -var parseObject = function parseObject(chain, val, options) { - if (!chain.length) { - return val; - } - - var root = chain.shift(); - - var obj; - if (root === '[]') { - obj = []; - obj = obj.concat(parseObject(chain, val, options)); - } else { - obj = options.plainObjects ? Object.create(null) : {}; - var cleanRoot = root[0] === '[' && root[root.length - 1] === ']' ? root.slice(1, root.length - 1) : root; - var index = parseInt(cleanRoot, 10); - if ( - !isNaN(index) && - root !== cleanRoot && - String(index) === cleanRoot && - index >= 0 && - (options.parseArrays && index <= options.arrayLimit) - ) { - obj = []; - obj[index] = parseObject(chain, val, options); - } else { - obj[cleanRoot] = parseObject(chain, val, options); - } - } - - return obj; -}; - -var parseKeys = function parseKeys(givenKey, val, options) { - if (!givenKey) { - return; - } - - // Transform dot notation to bracket notation - var key = options.allowDots ? givenKey.replace(/\.([^\.\[]+)/g, '[$1]') : givenKey; - - // The regex chunks - - var parent = /^([^\[\]]*)/; - var child = /(\[[^\[\]]*\])/g; - - // Get the parent - - var segment = parent.exec(key); - - // Stash the parent if it exists - - var keys = []; - if (segment[1]) { - // If we aren't using plain objects, optionally prefix keys - // that would overwrite object prototype properties - if (!options.plainObjects && Object.prototype.hasOwnProperty(segment[1])) { - if (!options.allowPrototypes) { - return; - } - } - - keys.push(segment[1]); - } - - // Loop through children appending to the array until we hit depth - - var i = 0; - while ((segment = child.exec(key)) !== null && i < options.depth) { - i += 1; - if (!options.plainObjects && Object.prototype.hasOwnProperty(segment[1].replace(/\[|\]/g, ''))) { - if (!options.allowPrototypes) { - continue; - } - } - keys.push(segment[1]); - } - - // If there's a remainder, just add whatever is left - - if (segment) { - keys.push('[' + key.slice(segment.index) + ']'); - } - - return parseObject(keys, val, options); -}; - -module.exports = function (str, opts) { - var options = opts || {}; - - if (options.decoder !== null && options.decoder !== undefined && typeof options.decoder !== 'function') { - throw new TypeError('Decoder has to be a function.'); - } - - options.delimiter = typeof options.delimiter === 'string' || Utils.isRegExp(options.delimiter) ? options.delimiter : defaults.delimiter; - options.depth = typeof options.depth === 'number' ? options.depth : defaults.depth; - options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : defaults.arrayLimit; - options.parseArrays = options.parseArrays !== false; - options.decoder = typeof options.decoder === 'function' ? options.decoder : defaults.decoder; - options.allowDots = typeof options.allowDots === 'boolean' ? options.allowDots : defaults.allowDots; - options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : defaults.plainObjects; - options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : defaults.allowPrototypes; - options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : defaults.parameterLimit; - options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling; - - if (str === '' || str === null || typeof str === 'undefined') { - return options.plainObjects ? Object.create(null) : {}; - } - - var tempObj = typeof str === 'string' ? parseValues(str, options) : str; - var obj = options.plainObjects ? Object.create(null) : {}; - - // Iterate over the keys and setup the new object - - var keys = Object.keys(tempObj); - for (var i = 0; i < keys.length; ++i) { - var key = keys[i]; - var newObj = parseKeys(key, tempObj[key], options); - obj = Utils.merge(obj, newObj, options); - } - - return Utils.compact(obj); -}; +'use strict'; + +var Utils = require('./utils'); + +var defaults = { + delimiter: '&', + depth: 5, + arrayLimit: 20, + parameterLimit: 1000, + strictNullHandling: false, + plainObjects: false, + allowPrototypes: false, + allowDots: false, + decoder: Utils.decode +}; + +var parseValues = function parseValues(str, options) { + var obj = {}; + var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit); + + for (var i = 0; i < parts.length; ++i) { + var part = parts[i]; + var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1; + + if (pos === -1) { + obj[options.decoder(part)] = ''; + + if (options.strictNullHandling) { + obj[options.decoder(part)] = null; + } + } else { + var key = options.decoder(part.slice(0, pos)); + var val = options.decoder(part.slice(pos + 1)); + + if (Object.prototype.hasOwnProperty.call(obj, key)) { + obj[key] = [].concat(obj[key]).concat(val); + } else { + obj[key] = val; + } + } + } + + return obj; +}; + +var parseObject = function parseObject(chain, val, options) { + if (!chain.length) { + return val; + } + + var root = chain.shift(); + + var obj; + if (root === '[]') { + obj = []; + obj = obj.concat(parseObject(chain, val, options)); + } else { + obj = options.plainObjects ? Object.create(null) : {}; + var cleanRoot = root[0] === '[' && root[root.length - 1] === ']' ? root.slice(1, root.length - 1) : root; + var index = parseInt(cleanRoot, 10); + if ( + !isNaN(index) && + root !== cleanRoot && + String(index) === cleanRoot && + index >= 0 && + (options.parseArrays && index <= options.arrayLimit) + ) { + obj = []; + obj[index] = parseObject(chain, val, options); + } else { + obj[cleanRoot] = parseObject(chain, val, options); + } + } + + return obj; +}; + +var parseKeys = function parseKeys(givenKey, val, options) { + if (!givenKey) { + return; + } + + // Transform dot notation to bracket notation + var key = options.allowDots ? givenKey.replace(/\.([^\.\[]+)/g, '[$1]') : givenKey; + + // The regex chunks + + var parent = /^([^\[\]]*)/; + var child = /(\[[^\[\]]*\])/g; + + // Get the parent + + var segment = parent.exec(key); + + // Stash the parent if it exists + + var keys = []; + if (segment[1]) { + // If we aren't using plain objects, optionally prefix keys + // that would overwrite object prototype properties + if (!options.plainObjects && Object.prototype.hasOwnProperty(segment[1])) { + if (!options.allowPrototypes) { + return; + } + } + + keys.push(segment[1]); + } + + // Loop through children appending to the array until we hit depth + + var i = 0; + while ((segment = child.exec(key)) !== null && i < options.depth) { + i += 1; + if (!options.plainObjects && Object.prototype.hasOwnProperty(segment[1].replace(/\[|\]/g, ''))) { + if (!options.allowPrototypes) { + continue; + } + } + keys.push(segment[1]); + } + + // If there's a remainder, just add whatever is left + + if (segment) { + keys.push('[' + key.slice(segment.index) + ']'); + } + + return parseObject(keys, val, options); +}; + +module.exports = function (str, opts) { + var options = opts || {}; + + if (options.decoder !== null && options.decoder !== undefined && typeof options.decoder !== 'function') { + throw new TypeError('Decoder has to be a function.'); + } + + options.delimiter = typeof options.delimiter === 'string' || Utils.isRegExp(options.delimiter) ? options.delimiter : defaults.delimiter; + options.depth = typeof options.depth === 'number' ? options.depth : defaults.depth; + options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : defaults.arrayLimit; + options.parseArrays = options.parseArrays !== false; + options.decoder = typeof options.decoder === 'function' ? options.decoder : defaults.decoder; + options.allowDots = typeof options.allowDots === 'boolean' ? options.allowDots : defaults.allowDots; + options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : defaults.plainObjects; + options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : defaults.allowPrototypes; + options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : defaults.parameterLimit; + options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling; + + if (str === '' || str === null || typeof str === 'undefined') { + return options.plainObjects ? Object.create(null) : {}; + } + + var tempObj = typeof str === 'string' ? parseValues(str, options) : str; + var obj = options.plainObjects ? Object.create(null) : {}; + + // Iterate over the keys and setup the new object + + var keys = Object.keys(tempObj); + for (var i = 0; i < keys.length; ++i) { + var key = keys[i]; + var newObj = parseKeys(key, tempObj[key], options); + obj = Utils.merge(obj, newObj, options); + } + + return Utils.compact(obj); +}; diff --git a/ui/node_modules/express/node_modules/qs/lib/stringify.js b/ui/node_modules/express/node_modules/qs/lib/stringify.js old mode 100755 new mode 100644 index 505899a5..6e1c9a26 --- a/ui/node_modules/express/node_modules/qs/lib/stringify.js +++ b/ui/node_modules/express/node_modules/qs/lib/stringify.js @@ -1,137 +1,137 @@ -'use strict'; - -var Utils = require('./utils'); - -var arrayPrefixGenerators = { - brackets: function brackets(prefix) { - return prefix + '[]'; - }, - indices: function indices(prefix, key) { - return prefix + '[' + key + ']'; - }, - repeat: function repeat(prefix) { - return prefix; - } -}; - -var defaults = { - delimiter: '&', - strictNullHandling: false, - skipNulls: false, - encode: true, - encoder: Utils.encode -}; - -var stringify = function stringify(object, prefix, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots) { - var obj = object; - if (typeof filter === 'function') { - obj = filter(prefix, obj); - } else if (obj instanceof Date) { - obj = obj.toISOString(); - } else if (obj === null) { - if (strictNullHandling) { - return encoder ? encoder(prefix) : prefix; - } - - obj = ''; - } - - if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || Utils.isBuffer(obj)) { - if (encoder) { - return [encoder(prefix) + '=' + encoder(obj)]; - } - return [prefix + '=' + String(obj)]; - } - - var values = []; - - if (typeof obj === 'undefined') { - return values; - } - - var objKeys; - if (Array.isArray(filter)) { - objKeys = filter; - } else { - var keys = Object.keys(obj); - objKeys = sort ? keys.sort(sort) : keys; - } - - for (var i = 0; i < objKeys.length; ++i) { - var key = objKeys[i]; - - if (skipNulls && obj[key] === null) { - continue; - } - - if (Array.isArray(obj)) { - values = values.concat(stringify(obj[key], generateArrayPrefix(prefix, key), generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots)); - } else { - values = values.concat(stringify(obj[key], prefix + (allowDots ? '.' + key : '[' + key + ']'), generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots)); - } - } - - return values; -}; - -module.exports = function (object, opts) { - var obj = object; - var options = opts || {}; - var delimiter = typeof options.delimiter === 'undefined' ? defaults.delimiter : options.delimiter; - var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling; - var skipNulls = typeof options.skipNulls === 'boolean' ? options.skipNulls : defaults.skipNulls; - var encode = typeof options.encode === 'boolean' ? options.encode : defaults.encode; - var encoder = encode ? (typeof options.encoder === 'function' ? options.encoder : defaults.encoder) : null; - var sort = typeof options.sort === 'function' ? options.sort : null; - var allowDots = typeof options.allowDots === 'undefined' ? false : options.allowDots; - var objKeys; - var filter; - - if (options.encoder !== null && options.encoder !== undefined && typeof options.encoder !== 'function') { - throw new TypeError('Encoder has to be a function.'); - } - - if (typeof options.filter === 'function') { - filter = options.filter; - obj = filter('', obj); - } else if (Array.isArray(options.filter)) { - objKeys = filter = options.filter; - } - - var keys = []; - - if (typeof obj !== 'object' || obj === null) { - return ''; - } - - var arrayFormat; - if (options.arrayFormat in arrayPrefixGenerators) { - arrayFormat = options.arrayFormat; - } else if ('indices' in options) { - arrayFormat = options.indices ? 'indices' : 'repeat'; - } else { - arrayFormat = 'indices'; - } - - var generateArrayPrefix = arrayPrefixGenerators[arrayFormat]; - - if (!objKeys) { - objKeys = Object.keys(obj); - } - - if (sort) { - objKeys.sort(sort); - } - - for (var i = 0; i < objKeys.length; ++i) { - var key = objKeys[i]; - - if (skipNulls && obj[key] === null) { - continue; - } - - keys = keys.concat(stringify(obj[key], key, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots)); - } - - return keys.join(delimiter); -}; +'use strict'; + +var Utils = require('./utils'); + +var arrayPrefixGenerators = { + brackets: function brackets(prefix) { + return prefix + '[]'; + }, + indices: function indices(prefix, key) { + return prefix + '[' + key + ']'; + }, + repeat: function repeat(prefix) { + return prefix; + } +}; + +var defaults = { + delimiter: '&', + strictNullHandling: false, + skipNulls: false, + encode: true, + encoder: Utils.encode +}; + +var stringify = function stringify(object, prefix, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots) { + var obj = object; + if (typeof filter === 'function') { + obj = filter(prefix, obj); + } else if (obj instanceof Date) { + obj = obj.toISOString(); + } else if (obj === null) { + if (strictNullHandling) { + return encoder ? encoder(prefix) : prefix; + } + + obj = ''; + } + + if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || Utils.isBuffer(obj)) { + if (encoder) { + return [encoder(prefix) + '=' + encoder(obj)]; + } + return [prefix + '=' + String(obj)]; + } + + var values = []; + + if (typeof obj === 'undefined') { + return values; + } + + var objKeys; + if (Array.isArray(filter)) { + objKeys = filter; + } else { + var keys = Object.keys(obj); + objKeys = sort ? keys.sort(sort) : keys; + } + + for (var i = 0; i < objKeys.length; ++i) { + var key = objKeys[i]; + + if (skipNulls && obj[key] === null) { + continue; + } + + if (Array.isArray(obj)) { + values = values.concat(stringify(obj[key], generateArrayPrefix(prefix, key), generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots)); + } else { + values = values.concat(stringify(obj[key], prefix + (allowDots ? '.' + key : '[' + key + ']'), generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots)); + } + } + + return values; +}; + +module.exports = function (object, opts) { + var obj = object; + var options = opts || {}; + var delimiter = typeof options.delimiter === 'undefined' ? defaults.delimiter : options.delimiter; + var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling; + var skipNulls = typeof options.skipNulls === 'boolean' ? options.skipNulls : defaults.skipNulls; + var encode = typeof options.encode === 'boolean' ? options.encode : defaults.encode; + var encoder = encode ? (typeof options.encoder === 'function' ? options.encoder : defaults.encoder) : null; + var sort = typeof options.sort === 'function' ? options.sort : null; + var allowDots = typeof options.allowDots === 'undefined' ? false : options.allowDots; + var objKeys; + var filter; + + if (options.encoder !== null && options.encoder !== undefined && typeof options.encoder !== 'function') { + throw new TypeError('Encoder has to be a function.'); + } + + if (typeof options.filter === 'function') { + filter = options.filter; + obj = filter('', obj); + } else if (Array.isArray(options.filter)) { + objKeys = filter = options.filter; + } + + var keys = []; + + if (typeof obj !== 'object' || obj === null) { + return ''; + } + + var arrayFormat; + if (options.arrayFormat in arrayPrefixGenerators) { + arrayFormat = options.arrayFormat; + } else if ('indices' in options) { + arrayFormat = options.indices ? 'indices' : 'repeat'; + } else { + arrayFormat = 'indices'; + } + + var generateArrayPrefix = arrayPrefixGenerators[arrayFormat]; + + if (!objKeys) { + objKeys = Object.keys(obj); + } + + if (sort) { + objKeys.sort(sort); + } + + for (var i = 0; i < objKeys.length; ++i) { + var key = objKeys[i]; + + if (skipNulls && obj[key] === null) { + continue; + } + + keys = keys.concat(stringify(obj[key], key, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots)); + } + + return keys.join(delimiter); +}; diff --git a/ui/node_modules/express/node_modules/qs/lib/utils.js b/ui/node_modules/express/node_modules/qs/lib/utils.js old mode 100755 new mode 100644 index 8cd18679..2c5c8ee5 --- a/ui/node_modules/express/node_modules/qs/lib/utils.js +++ b/ui/node_modules/express/node_modules/qs/lib/utils.js @@ -1,164 +1,164 @@ -'use strict'; - -var hexTable = (function () { - var array = new Array(256); - for (var i = 0; i < 256; ++i) { - array[i] = '%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase(); - } - - return array; -}()); - -exports.arrayToObject = function (source, options) { - var obj = options.plainObjects ? Object.create(null) : {}; - for (var i = 0; i < source.length; ++i) { - if (typeof source[i] !== 'undefined') { - obj[i] = source[i]; - } - } - - return obj; -}; - -exports.merge = function (target, source, options) { - if (!source) { - return target; - } - - if (typeof source !== 'object') { - if (Array.isArray(target)) { - target.push(source); - } else if (typeof target === 'object') { - target[source] = true; - } else { - return [target, source]; - } - - return target; - } - - if (typeof target !== 'object') { - return [target].concat(source); - } - - var mergeTarget = target; - if (Array.isArray(target) && !Array.isArray(source)) { - mergeTarget = exports.arrayToObject(target, options); - } - - return Object.keys(source).reduce(function (acc, key) { - var value = source[key]; - - if (Object.prototype.hasOwnProperty.call(acc, key)) { - acc[key] = exports.merge(acc[key], value, options); - } else { - acc[key] = value; - } - return acc; - }, mergeTarget); -}; - -exports.decode = function (str) { - try { - return decodeURIComponent(str.replace(/\+/g, ' ')); - } catch (e) { - return str; - } -}; - -exports.encode = function (str) { - // This code was originally written by Brian White (mscdex) for the io.js core querystring library. - // It has been adapted here for stricter adherence to RFC 3986 - if (str.length === 0) { - return str; - } - - var string = typeof str === 'string' ? str : String(str); - - var out = ''; - for (var i = 0; i < string.length; ++i) { - var c = string.charCodeAt(i); - - if ( - c === 0x2D || // - - c === 0x2E || // . - c === 0x5F || // _ - c === 0x7E || // ~ - (c >= 0x30 && c <= 0x39) || // 0-9 - (c >= 0x41 && c <= 0x5A) || // a-z - (c >= 0x61 && c <= 0x7A) // A-Z - ) { - out += string.charAt(i); - continue; - } - - if (c < 0x80) { - out = out + hexTable[c]; - continue; - } - - if (c < 0x800) { - out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]); - continue; - } - - if (c < 0xD800 || c >= 0xE000) { - out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]); - continue; - } - - i += 1; - c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF)); - out += hexTable[0xF0 | (c >> 18)] + hexTable[0x80 | ((c >> 12) & 0x3F)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]; - } - - return out; -}; - -exports.compact = function (obj, references) { - if (typeof obj !== 'object' || obj === null) { - return obj; - } - - var refs = references || []; - var lookup = refs.indexOf(obj); - if (lookup !== -1) { - return refs[lookup]; - } - - refs.push(obj); - - if (Array.isArray(obj)) { - var compacted = []; - - for (var i = 0; i < obj.length; ++i) { - if (obj[i] && typeof obj[i] === 'object') { - compacted.push(exports.compact(obj[i], refs)); - } else if (typeof obj[i] !== 'undefined') { - compacted.push(obj[i]); - } - } - - return compacted; - } - - var keys = Object.keys(obj); - for (var j = 0; j < keys.length; ++j) { - var key = keys[j]; - obj[key] = exports.compact(obj[key], refs); - } - - return obj; -}; - -exports.isRegExp = function (obj) { - return Object.prototype.toString.call(obj) === '[object RegExp]'; -}; - -exports.isBuffer = function (obj) { - if (obj === null || typeof obj === 'undefined') { - return false; - } - - return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj)); -}; +'use strict'; + +var hexTable = (function () { + var array = new Array(256); + for (var i = 0; i < 256; ++i) { + array[i] = '%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase(); + } + + return array; +}()); + +exports.arrayToObject = function (source, options) { + var obj = options.plainObjects ? Object.create(null) : {}; + for (var i = 0; i < source.length; ++i) { + if (typeof source[i] !== 'undefined') { + obj[i] = source[i]; + } + } + + return obj; +}; + +exports.merge = function (target, source, options) { + if (!source) { + return target; + } + + if (typeof source !== 'object') { + if (Array.isArray(target)) { + target.push(source); + } else if (typeof target === 'object') { + target[source] = true; + } else { + return [target, source]; + } + + return target; + } + + if (typeof target !== 'object') { + return [target].concat(source); + } + + var mergeTarget = target; + if (Array.isArray(target) && !Array.isArray(source)) { + mergeTarget = exports.arrayToObject(target, options); + } + + return Object.keys(source).reduce(function (acc, key) { + var value = source[key]; + + if (Object.prototype.hasOwnProperty.call(acc, key)) { + acc[key] = exports.merge(acc[key], value, options); + } else { + acc[key] = value; + } + return acc; + }, mergeTarget); +}; + +exports.decode = function (str) { + try { + return decodeURIComponent(str.replace(/\+/g, ' ')); + } catch (e) { + return str; + } +}; + +exports.encode = function (str) { + // This code was originally written by Brian White (mscdex) for the io.js core querystring library. + // It has been adapted here for stricter adherence to RFC 3986 + if (str.length === 0) { + return str; + } + + var string = typeof str === 'string' ? str : String(str); + + var out = ''; + for (var i = 0; i < string.length; ++i) { + var c = string.charCodeAt(i); + + if ( + c === 0x2D || // - + c === 0x2E || // . + c === 0x5F || // _ + c === 0x7E || // ~ + (c >= 0x30 && c <= 0x39) || // 0-9 + (c >= 0x41 && c <= 0x5A) || // a-z + (c >= 0x61 && c <= 0x7A) // A-Z + ) { + out += string.charAt(i); + continue; + } + + if (c < 0x80) { + out = out + hexTable[c]; + continue; + } + + if (c < 0x800) { + out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]); + continue; + } + + if (c < 0xD800 || c >= 0xE000) { + out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]); + continue; + } + + i += 1; + c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF)); + out += hexTable[0xF0 | (c >> 18)] + hexTable[0x80 | ((c >> 12) & 0x3F)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]; + } + + return out; +}; + +exports.compact = function (obj, references) { + if (typeof obj !== 'object' || obj === null) { + return obj; + } + + var refs = references || []; + var lookup = refs.indexOf(obj); + if (lookup !== -1) { + return refs[lookup]; + } + + refs.push(obj); + + if (Array.isArray(obj)) { + var compacted = []; + + for (var i = 0; i < obj.length; ++i) { + if (obj[i] && typeof obj[i] === 'object') { + compacted.push(exports.compact(obj[i], refs)); + } else if (typeof obj[i] !== 'undefined') { + compacted.push(obj[i]); + } + } + + return compacted; + } + + var keys = Object.keys(obj); + for (var j = 0; j < keys.length; ++j) { + var key = keys[j]; + obj[key] = exports.compact(obj[key], refs); + } + + return obj; +}; + +exports.isRegExp = function (obj) { + return Object.prototype.toString.call(obj) === '[object RegExp]'; +}; + +exports.isBuffer = function (obj) { + if (obj === null || typeof obj === 'undefined') { + return false; + } + + return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj)); +}; diff --git a/ui/node_modules/express/node_modules/qs/package.json b/ui/node_modules/express/node_modules/qs/package.json index 13d0c5b6..265c1721 100644 --- a/ui/node_modules/express/node_modules/qs/package.json +++ b/ui/node_modules/express/node_modules/qs/package.json @@ -1,86 +1,86 @@ -{ - "name": "qs", - "description": "A querystring parser that supports nesting and arrays, with a depth limit", - "homepage": "https://github.com/ljharb/qs", - "version": "6.2.0", - "repository": { - "type": "git", - "url": "git+https://github.com/ljharb/qs.git" - }, - "main": "lib/index.js", - "contributors": [ - { - "name": "Jordan Harband", - "email": "ljharb@gmail.com", - "url": "http://ljharb.codes" - } - ], - "keywords": [ - "querystring", - "qs" - ], - "engines": { - "node": ">=0.6" - }, - "dependencies": {}, - "devDependencies": { - "browserify": "^13.0.1", - "tape": "^4.5.1", - "covert": "^1.1.0", - "mkdirp": "^0.5.1", - "eslint": "^2.9.0", - "@ljharb/eslint-config": "^4.0.0", - "parallelshell": "^2.0.0", - "iconv-lite": "^0.4.13", - "evalmd": "^0.0.17" - }, - "scripts": { - "pretest": "parallelshell 'npm run --silent readme' 'npm run --silent lint'", - "test": "npm run --silent coverage", - "tests-only": "node test", - "readme": "evalmd README.md", - "lint": "eslint lib/*.js text/*.js", - "coverage": "covert test", - "dist": "mkdirp dist && browserify --standalone Qs lib/index.js > dist/qs.js", - "prepublish": "npm run dist" - }, - "license": "BSD-3-Clause", - "gitHead": "d67d315b606c6bb809fedcbeebbbdb7f863852aa", - "bugs": { - "url": "https://github.com/ljharb/qs/issues" - }, - "_id": "qs@6.2.0", - "_shasum": "3b7848c03c2dece69a9522b0fae8c4126d745f3b", - "_from": "qs@6.2.0", - "_npmVersion": "3.8.6", - "_nodeVersion": "6.1.0", - "_npmUser": { - "name": "ljharb", - "email": "ljharb@gmail.com" - }, - "dist": { - "shasum": "3b7848c03c2dece69a9522b0fae8c4126d745f3b", - "tarball": "https://registry.npmjs.org/qs/-/qs-6.2.0.tgz" - }, - "maintainers": [ - { - "name": "hueniverse", - "email": "eran@hammer.io" - }, - { - "name": "ljharb", - "email": "ljharb@gmail.com" - }, - { - "name": "nlf", - "email": "quitlahok@gmail.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/qs-6.2.0.tgz_1462749349998_0.03372702235355973" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/qs/-/qs-6.2.0.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "qs", + "description": "A querystring parser that supports nesting and arrays, with a depth limit", + "homepage": "https://github.com/ljharb/qs", + "version": "6.2.0", + "repository": { + "type": "git", + "url": "git+https://github.com/ljharb/qs.git" + }, + "main": "lib/index.js", + "contributors": [ + { + "name": "Jordan Harband", + "email": "ljharb@gmail.com", + "url": "http://ljharb.codes" + } + ], + "keywords": [ + "querystring", + "qs" + ], + "engines": { + "node": ">=0.6" + }, + "dependencies": {}, + "devDependencies": { + "browserify": "^13.0.1", + "tape": "^4.5.1", + "covert": "^1.1.0", + "mkdirp": "^0.5.1", + "eslint": "^2.9.0", + "@ljharb/eslint-config": "^4.0.0", + "parallelshell": "^2.0.0", + "iconv-lite": "^0.4.13", + "evalmd": "^0.0.17" + }, + "scripts": { + "pretest": "parallelshell 'npm run --silent readme' 'npm run --silent lint'", + "test": "npm run --silent coverage", + "tests-only": "node test", + "readme": "evalmd README.md", + "lint": "eslint lib/*.js text/*.js", + "coverage": "covert test", + "dist": "mkdirp dist && browserify --standalone Qs lib/index.js > dist/qs.js", + "prepublish": "npm run dist" + }, + "license": "BSD-3-Clause", + "gitHead": "d67d315b606c6bb809fedcbeebbbdb7f863852aa", + "bugs": { + "url": "https://github.com/ljharb/qs/issues" + }, + "_id": "qs@6.2.0", + "_shasum": "3b7848c03c2dece69a9522b0fae8c4126d745f3b", + "_from": "qs@6.2.0", + "_npmVersion": "3.8.6", + "_nodeVersion": "6.1.0", + "_npmUser": { + "name": "ljharb", + "email": "ljharb@gmail.com" + }, + "dist": { + "shasum": "3b7848c03c2dece69a9522b0fae8c4126d745f3b", + "tarball": "https://registry.npmjs.org/qs/-/qs-6.2.0.tgz" + }, + "maintainers": [ + { + "name": "hueniverse", + "email": "eran@hammer.io" + }, + { + "name": "ljharb", + "email": "ljharb@gmail.com" + }, + { + "name": "nlf", + "email": "quitlahok@gmail.com" + } + ], + "_npmOperationalInternal": { + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/qs-6.2.0.tgz_1462749349998_0.03372702235355973" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/qs/-/qs-6.2.0.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/qs/test/index.js b/ui/node_modules/express/node_modules/qs/test/index.js index 6d2de9db..b6a7d952 100644 --- a/ui/node_modules/express/node_modules/qs/test/index.js +++ b/ui/node_modules/express/node_modules/qs/test/index.js @@ -1,5 +1,5 @@ -require('./parse'); - -require('./stringify'); - -require('./utils'); +require('./parse'); + +require('./stringify'); + +require('./utils'); diff --git a/ui/node_modules/express/node_modules/qs/test/parse.js b/ui/node_modules/express/node_modules/qs/test/parse.js old mode 100755 new mode 100644 index 097ba4db..1b79daf5 --- a/ui/node_modules/express/node_modules/qs/test/parse.js +++ b/ui/node_modules/express/node_modules/qs/test/parse.js @@ -1,423 +1,423 @@ -'use strict'; - -var test = require('tape'); -var qs = require('../'); -var iconv = require('iconv-lite'); - -test('parse()', function (t) { - t.test('parses a simple string', function (st) { - st.deepEqual(qs.parse('0=foo'), { '0': 'foo' }); - st.deepEqual(qs.parse('foo=c++'), { foo: 'c ' }); - st.deepEqual(qs.parse('a[>=]=23'), { a: { '>=': '23' } }); - st.deepEqual(qs.parse('a[<=>]==23'), { a: { '<=>': '=23' } }); - st.deepEqual(qs.parse('a[==]=23'), { a: { '==': '23' } }); - st.deepEqual(qs.parse('foo', { strictNullHandling: true }), { foo: null }); - st.deepEqual(qs.parse('foo'), { foo: '' }); - st.deepEqual(qs.parse('foo='), { foo: '' }); - st.deepEqual(qs.parse('foo=bar'), { foo: 'bar' }); - st.deepEqual(qs.parse(' foo = bar = baz '), { ' foo ': ' bar = baz ' }); - st.deepEqual(qs.parse('foo=bar=baz'), { foo: 'bar=baz' }); - st.deepEqual(qs.parse('foo=bar&bar=baz'), { foo: 'bar', bar: 'baz' }); - st.deepEqual(qs.parse('foo2=bar2&baz2='), { foo2: 'bar2', baz2: '' }); - st.deepEqual(qs.parse('foo=bar&baz', { strictNullHandling: true }), { foo: 'bar', baz: null }); - st.deepEqual(qs.parse('foo=bar&baz'), { foo: 'bar', baz: '' }); - st.deepEqual(qs.parse('cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World'), { - cht: 'p3', - chd: 't:60,40', - chs: '250x100', - chl: 'Hello|World' - }); - st.end(); - }); - - t.test('allows enabling dot notation', function (st) { - st.deepEqual(qs.parse('a.b=c'), { 'a.b': 'c' }); - st.deepEqual(qs.parse('a.b=c', { allowDots: true }), { a: { b: 'c' } }); - st.end(); - }); - - t.deepEqual(qs.parse('a[b]=c'), { a: { b: 'c' } }, 'parses a single nested string'); - t.deepEqual(qs.parse('a[b][c]=d'), { a: { b: { c: 'd' } } }, 'parses a double nested string'); - t.deepEqual( - qs.parse('a[b][c][d][e][f][g][h]=i'), - { a: { b: { c: { d: { e: { f: { '[g][h]': 'i' } } } } } } }, - 'defaults to a depth of 5' - ); - - t.test('only parses one level when depth = 1', function (st) { - st.deepEqual(qs.parse('a[b][c]=d', { depth: 1 }), { a: { b: { '[c]': 'd' } } }); - st.deepEqual(qs.parse('a[b][c][d]=e', { depth: 1 }), { a: { b: { '[c][d]': 'e' } } }); - st.end(); - }); - - t.deepEqual(qs.parse('a=b&a=c'), { a: ['b', 'c'] }, 'parses a simple array'); - - t.test('parses an explicit array', function (st) { - st.deepEqual(qs.parse('a[]=b'), { a: ['b'] }); - st.deepEqual(qs.parse('a[]=b&a[]=c'), { a: ['b', 'c'] }); - st.deepEqual(qs.parse('a[]=b&a[]=c&a[]=d'), { a: ['b', 'c', 'd'] }); - st.end(); - }); - - t.test('parses a mix of simple and explicit arrays', function (st) { - st.deepEqual(qs.parse('a=b&a[]=c'), { a: ['b', 'c'] }); - st.deepEqual(qs.parse('a[]=b&a=c'), { a: ['b', 'c'] }); - st.deepEqual(qs.parse('a[0]=b&a=c'), { a: ['b', 'c'] }); - st.deepEqual(qs.parse('a=b&a[0]=c'), { a: ['b', 'c'] }); - st.deepEqual(qs.parse('a[1]=b&a=c'), { a: ['b', 'c'] }); - st.deepEqual(qs.parse('a=b&a[1]=c'), { a: ['b', 'c'] }); - st.end(); - }); - - t.test('parses a nested array', function (st) { - st.deepEqual(qs.parse('a[b][]=c&a[b][]=d'), { a: { b: ['c', 'd'] } }); - st.deepEqual(qs.parse('a[>=]=25'), { a: { '>=': '25' } }); - st.end(); - }); - - t.test('allows to specify array indices', function (st) { - st.deepEqual(qs.parse('a[1]=c&a[0]=b&a[2]=d'), { a: ['b', 'c', 'd'] }); - st.deepEqual(qs.parse('a[1]=c&a[0]=b'), { a: ['b', 'c'] }); - st.deepEqual(qs.parse('a[1]=c'), { a: ['c'] }); - st.end(); - }); - - t.test('limits specific array indices to 20', function (st) { - st.deepEqual(qs.parse('a[20]=a'), { a: ['a'] }); - st.deepEqual(qs.parse('a[21]=a'), { a: { '21': 'a' } }); - st.end(); - }); - - t.deepEqual(qs.parse('a[12b]=c'), { a: { '12b': 'c' } }, 'supports keys that begin with a number'); - - t.test('supports encoded = signs', function (st) { - st.deepEqual(qs.parse('he%3Dllo=th%3Dere'), { 'he=llo': 'th=ere' }); - st.end(); - }); - - t.test('is ok with url encoded strings', function (st) { - st.deepEqual(qs.parse('a[b%20c]=d'), { a: { 'b c': 'd' } }); - st.deepEqual(qs.parse('a[b]=c%20d'), { a: { b: 'c d' } }); - st.end(); - }); - - t.test('allows brackets in the value', function (st) { - st.deepEqual(qs.parse('pets=["tobi"]'), { pets: '["tobi"]' }); - st.deepEqual(qs.parse('operators=[">=", "<="]'), { operators: '[">=", "<="]' }); - st.end(); - }); - - t.test('allows empty values', function (st) { - st.deepEqual(qs.parse(''), {}); - st.deepEqual(qs.parse(null), {}); - st.deepEqual(qs.parse(undefined), {}); - st.end(); - }); - - t.test('transforms arrays to objects', function (st) { - st.deepEqual(qs.parse('foo[0]=bar&foo[bad]=baz'), { foo: { '0': 'bar', bad: 'baz' } }); - st.deepEqual(qs.parse('foo[bad]=baz&foo[0]=bar'), { foo: { bad: 'baz', '0': 'bar' } }); - st.deepEqual(qs.parse('foo[bad]=baz&foo[]=bar'), { foo: { bad: 'baz', '0': 'bar' } }); - st.deepEqual(qs.parse('foo[]=bar&foo[bad]=baz'), { foo: { '0': 'bar', bad: 'baz' } }); - st.deepEqual(qs.parse('foo[bad]=baz&foo[]=bar&foo[]=foo'), { foo: { bad: 'baz', '0': 'bar', '1': 'foo' } }); - st.deepEqual(qs.parse('foo[0][a]=a&foo[0][b]=b&foo[1][a]=aa&foo[1][b]=bb'), { foo: [{ a: 'a', b: 'b' }, { a: 'aa', b: 'bb' }] }); - st.deepEqual(qs.parse('a[]=b&a[t]=u&a[hasOwnProperty]=c'), { a: { '0': 'b', t: 'u', c: true } }); - st.deepEqual(qs.parse('a[]=b&a[hasOwnProperty]=c&a[x]=y'), { a: { '0': 'b', '1': 'c', x: 'y' } }); - st.end(); - }); - - t.test('transforms arrays to objects (dot notation)', function (st) { - st.deepEqual(qs.parse('foo[0].baz=bar&fool.bad=baz', { allowDots: true }), { foo: [{ baz: 'bar' }], fool: { bad: 'baz' } }); - st.deepEqual(qs.parse('foo[0].baz=bar&fool.bad.boo=baz', { allowDots: true }), { foo: [{ baz: 'bar' }], fool: { bad: { boo: 'baz' } } }); - st.deepEqual(qs.parse('foo[0][0].baz=bar&fool.bad=baz', { allowDots: true }), { foo: [[{ baz: 'bar' }]], fool: { bad: 'baz' } }); - st.deepEqual(qs.parse('foo[0].baz[0]=15&foo[0].bar=2', { allowDots: true }), { foo: [{ baz: ['15'], bar: '2' }] }); - st.deepEqual(qs.parse('foo[0].baz[0]=15&foo[0].baz[1]=16&foo[0].bar=2', { allowDots: true }), { foo: [{ baz: ['15', '16'], bar: '2' }] }); - st.deepEqual(qs.parse('foo.bad=baz&foo[0]=bar', { allowDots: true }), { foo: { bad: 'baz', '0': 'bar' } }); - st.deepEqual(qs.parse('foo.bad=baz&foo[]=bar', { allowDots: true }), { foo: { bad: 'baz', '0': 'bar' } }); - st.deepEqual(qs.parse('foo[]=bar&foo.bad=baz', { allowDots: true }), { foo: { '0': 'bar', bad: 'baz' } }); - st.deepEqual(qs.parse('foo.bad=baz&foo[]=bar&foo[]=foo', { allowDots: true }), { foo: { bad: 'baz', '0': 'bar', '1': 'foo' } }); - st.deepEqual(qs.parse('foo[0].a=a&foo[0].b=b&foo[1].a=aa&foo[1].b=bb', { allowDots: true }), { foo: [{ a: 'a', b: 'b' }, { a: 'aa', b: 'bb' }] }); - st.end(); - }); - - t.deepEqual(qs.parse('a[b]=c&a=d'), { a: { b: 'c', d: true } }, 'can add keys to objects'); - - t.test('correctly prunes undefined values when converting an array to an object', function (st) { - st.deepEqual(qs.parse('a[2]=b&a[99999999]=c'), { a: { '2': 'b', '99999999': 'c' } }); - st.end(); - }); - - t.test('supports malformed uri characters', function (st) { - st.deepEqual(qs.parse('{%:%}', { strictNullHandling: true }), { '{%:%}': null }); - st.deepEqual(qs.parse('{%:%}='), { '{%:%}': '' }); - st.deepEqual(qs.parse('foo=%:%}'), { foo: '%:%}' }); - st.end(); - }); - - t.test('doesn\'t produce empty keys', function (st) { - st.deepEqual(qs.parse('_r=1&'), { '_r': '1' }); - st.end(); - }); - - t.test('cannot access Object prototype', function (st) { - qs.parse('constructor[prototype][bad]=bad'); - qs.parse('bad[constructor][prototype][bad]=bad'); - st.equal(typeof Object.prototype.bad, 'undefined'); - st.end(); - }); - - t.test('parses arrays of objects', function (st) { - st.deepEqual(qs.parse('a[][b]=c'), { a: [{ b: 'c' }] }); - st.deepEqual(qs.parse('a[0][b]=c'), { a: [{ b: 'c' }] }); - st.end(); - }); - - t.test('allows for empty strings in arrays', function (st) { - st.deepEqual(qs.parse('a[]=b&a[]=&a[]=c'), { a: ['b', '', 'c'] }); - st.deepEqual(qs.parse('a[0]=b&a[1]&a[2]=c&a[19]=', { strictNullHandling: true }), { a: ['b', null, 'c', ''] }); - st.deepEqual(qs.parse('a[0]=b&a[1]=&a[2]=c&a[19]', { strictNullHandling: true }), { a: ['b', '', 'c', null] }); - st.deepEqual(qs.parse('a[]=&a[]=b&a[]=c'), { a: ['', 'b', 'c'] }); - st.end(); - }); - - t.test('compacts sparse arrays', function (st) { - st.deepEqual(qs.parse('a[10]=1&a[2]=2'), { a: ['2', '1'] }); - st.deepEqual(qs.parse('a[1][b][2][c]=1'), { a: [{ b: [{ c: '1' }] }] }); - st.deepEqual(qs.parse('a[1][2][3][c]=1'), { a: [[[{ c: '1' }]]] }); - st.deepEqual(qs.parse('a[1][2][3][c][1]=1'), { a: [[[{ c: ['1'] }]]] }); - st.end(); - }); - - t.test('parses semi-parsed strings', function (st) { - st.deepEqual(qs.parse({ 'a[b]': 'c' }), { a: { b: 'c' } }); - st.deepEqual(qs.parse({ 'a[b]': 'c', 'a[d]': 'e' }), { a: { b: 'c', d: 'e' } }); - st.end(); - }); - - t.test('parses buffers correctly', function (st) { - var b = new Buffer('test'); - st.deepEqual(qs.parse({ a: b }), { a: b }); - st.end(); - }); - - t.test('continues parsing when no parent is found', function (st) { - st.deepEqual(qs.parse('[]=&a=b'), { '0': '', a: 'b' }); - st.deepEqual(qs.parse('[]&a=b', { strictNullHandling: true }), { '0': null, a: 'b' }); - st.deepEqual(qs.parse('[foo]=bar'), { foo: 'bar' }); - st.end(); - }); - - t.test('does not error when parsing a very long array', function (st) { - var str = 'a[]=a'; - while (Buffer.byteLength(str) < 128 * 1024) { - str = str + '&' + str; - } - - st.doesNotThrow(function () { qs.parse(str); }); - - st.end(); - }); - - t.test('should not throw when a native prototype has an enumerable property', { parallel: false }, function (st) { - Object.prototype.crash = ''; - Array.prototype.crash = ''; - st.doesNotThrow(qs.parse.bind(null, 'a=b')); - st.deepEqual(qs.parse('a=b'), { a: 'b' }); - st.doesNotThrow(qs.parse.bind(null, 'a[][b]=c')); - st.deepEqual(qs.parse('a[][b]=c'), { a: [{ b: 'c' }] }); - delete Object.prototype.crash; - delete Array.prototype.crash; - st.end(); - }); - - t.test('parses a string with an alternative string delimiter', function (st) { - st.deepEqual(qs.parse('a=b;c=d', { delimiter: ';' }), { a: 'b', c: 'd' }); - st.end(); - }); - - t.test('parses a string with an alternative RegExp delimiter', function (st) { - st.deepEqual(qs.parse('a=b; c=d', { delimiter: /[;,] */ }), { a: 'b', c: 'd' }); - st.end(); - }); - - t.test('does not use non-splittable objects as delimiters', function (st) { - st.deepEqual(qs.parse('a=b&c=d', { delimiter: true }), { a: 'b', c: 'd' }); - st.end(); - }); - - t.test('allows overriding parameter limit', function (st) { - st.deepEqual(qs.parse('a=b&c=d', { parameterLimit: 1 }), { a: 'b' }); - st.end(); - }); - - t.test('allows setting the parameter limit to Infinity', function (st) { - st.deepEqual(qs.parse('a=b&c=d', { parameterLimit: Infinity }), { a: 'b', c: 'd' }); - st.end(); - }); - - t.test('allows overriding array limit', function (st) { - st.deepEqual(qs.parse('a[0]=b', { arrayLimit: -1 }), { a: { '0': 'b' } }); - st.deepEqual(qs.parse('a[-1]=b', { arrayLimit: -1 }), { a: { '-1': 'b' } }); - st.deepEqual(qs.parse('a[0]=b&a[1]=c', { arrayLimit: 0 }), { a: { '0': 'b', '1': 'c' } }); - st.end(); - }); - - t.test('allows disabling array parsing', function (st) { - st.deepEqual(qs.parse('a[0]=b&a[1]=c', { parseArrays: false }), { a: { '0': 'b', '1': 'c' } }); - st.end(); - }); - - t.test('parses an object', function (st) { - var input = { - 'user[name]': { 'pop[bob]': 3 }, - 'user[email]': null - }; - - var expected = { - user: { - name: { 'pop[bob]': 3 }, - email: null - } - }; - - var result = qs.parse(input); - - st.deepEqual(result, expected); - st.end(); - }); - - t.test('parses an object in dot notation', function (st) { - var input = { - 'user.name': { 'pop[bob]': 3 }, - 'user.email.': null - }; - - var expected = { - user: { - name: { 'pop[bob]': 3 }, - email: null - } - }; - - var result = qs.parse(input, { allowDots: true }); - - st.deepEqual(result, expected); - st.end(); - }); - - t.test('parses an object and not child values', function (st) { - var input = { - 'user[name]': { 'pop[bob]': { 'test': 3 } }, - 'user[email]': null - }; - - var expected = { - user: { - name: { 'pop[bob]': { 'test': 3 } }, - email: null - } - }; - - var result = qs.parse(input); - - st.deepEqual(result, expected); - st.end(); - }); - - t.test('does not blow up when Buffer global is missing', function (st) { - var tempBuffer = global.Buffer; - delete global.Buffer; - var result = qs.parse('a=b&c=d'); - global.Buffer = tempBuffer; - st.deepEqual(result, { a: 'b', c: 'd' }); - st.end(); - }); - - t.test('does not crash when parsing circular references', function (st) { - var a = {}; - a.b = a; - - var parsed; - - st.doesNotThrow(function () { - parsed = qs.parse({ 'foo[bar]': 'baz', 'foo[baz]': a }); - }); - - st.equal('foo' in parsed, true, 'parsed has "foo" property'); - st.equal('bar' in parsed.foo, true); - st.equal('baz' in parsed.foo, true); - st.equal(parsed.foo.bar, 'baz'); - st.deepEqual(parsed.foo.baz, a); - st.end(); - }); - - t.test('parses plain objects correctly', function (st) { - var a = Object.create(null); - a.b = 'c'; - - st.deepEqual(qs.parse(a), { b: 'c' }); - var result = qs.parse({ a: a }); - st.equal('a' in result, true, 'result has "a" property'); - st.deepEqual(result.a, a); - st.end(); - }); - - t.test('parses dates correctly', function (st) { - var now = new Date(); - st.deepEqual(qs.parse({ a: now }), { a: now }); - st.end(); - }); - - t.test('parses regular expressions correctly', function (st) { - var re = /^test$/; - st.deepEqual(qs.parse({ a: re }), { a: re }); - st.end(); - }); - - t.test('can allow overwriting prototype properties', function (st) { - st.deepEqual(qs.parse('a[hasOwnProperty]=b', { allowPrototypes: true }), { a: { hasOwnProperty: 'b' } }, { prototype: false }); - st.deepEqual(qs.parse('hasOwnProperty=b', { allowPrototypes: true }), { hasOwnProperty: 'b' }, { prototype: false }); - st.end(); - }); - - t.test('can return plain objects', function (st) { - var expected = Object.create(null); - expected.a = Object.create(null); - expected.a.b = 'c'; - expected.a.hasOwnProperty = 'd'; - st.deepEqual(qs.parse('a[b]=c&a[hasOwnProperty]=d', { plainObjects: true }), expected); - st.deepEqual(qs.parse(null, { plainObjects: true }), Object.create(null)); - var expectedArray = Object.create(null); - expectedArray.a = Object.create(null); - expectedArray.a['0'] = 'b'; - expectedArray.a.c = 'd'; - st.deepEqual(qs.parse('a[]=b&a[c]=d', { plainObjects: true }), expectedArray); - st.end(); - }); - - t.test('can parse with custom encoding', function (st) { - st.deepEqual(qs.parse('%8c%a7=%91%e5%8d%e3%95%7b', { - decoder: function (str) { - var reg = /\%([0-9A-F]{2})/ig; - var result = []; - var parts; - var last = 0; - while (parts = reg.exec(str)) { - result.push(parseInt(parts[1], 16)); - last = parts.index + parts[0].length; - } - return iconv.decode(new Buffer(result), 'shift_jis').toString(); - } - }), { 県: '大阪府' }); - st.end(); - }); - - t.test('throws error with wrong decoder', function (st) { - st.throws(function () { - qs.parse({}, { - decoder: 'string' - }); - }, new TypeError('Decoder has to be a function.')); - st.end(); - }); -}); +'use strict'; + +var test = require('tape'); +var qs = require('../'); +var iconv = require('iconv-lite'); + +test('parse()', function (t) { + t.test('parses a simple string', function (st) { + st.deepEqual(qs.parse('0=foo'), { '0': 'foo' }); + st.deepEqual(qs.parse('foo=c++'), { foo: 'c ' }); + st.deepEqual(qs.parse('a[>=]=23'), { a: { '>=': '23' } }); + st.deepEqual(qs.parse('a[<=>]==23'), { a: { '<=>': '=23' } }); + st.deepEqual(qs.parse('a[==]=23'), { a: { '==': '23' } }); + st.deepEqual(qs.parse('foo', { strictNullHandling: true }), { foo: null }); + st.deepEqual(qs.parse('foo'), { foo: '' }); + st.deepEqual(qs.parse('foo='), { foo: '' }); + st.deepEqual(qs.parse('foo=bar'), { foo: 'bar' }); + st.deepEqual(qs.parse(' foo = bar = baz '), { ' foo ': ' bar = baz ' }); + st.deepEqual(qs.parse('foo=bar=baz'), { foo: 'bar=baz' }); + st.deepEqual(qs.parse('foo=bar&bar=baz'), { foo: 'bar', bar: 'baz' }); + st.deepEqual(qs.parse('foo2=bar2&baz2='), { foo2: 'bar2', baz2: '' }); + st.deepEqual(qs.parse('foo=bar&baz', { strictNullHandling: true }), { foo: 'bar', baz: null }); + st.deepEqual(qs.parse('foo=bar&baz'), { foo: 'bar', baz: '' }); + st.deepEqual(qs.parse('cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World'), { + cht: 'p3', + chd: 't:60,40', + chs: '250x100', + chl: 'Hello|World' + }); + st.end(); + }); + + t.test('allows enabling dot notation', function (st) { + st.deepEqual(qs.parse('a.b=c'), { 'a.b': 'c' }); + st.deepEqual(qs.parse('a.b=c', { allowDots: true }), { a: { b: 'c' } }); + st.end(); + }); + + t.deepEqual(qs.parse('a[b]=c'), { a: { b: 'c' } }, 'parses a single nested string'); + t.deepEqual(qs.parse('a[b][c]=d'), { a: { b: { c: 'd' } } }, 'parses a double nested string'); + t.deepEqual( + qs.parse('a[b][c][d][e][f][g][h]=i'), + { a: { b: { c: { d: { e: { f: { '[g][h]': 'i' } } } } } } }, + 'defaults to a depth of 5' + ); + + t.test('only parses one level when depth = 1', function (st) { + st.deepEqual(qs.parse('a[b][c]=d', { depth: 1 }), { a: { b: { '[c]': 'd' } } }); + st.deepEqual(qs.parse('a[b][c][d]=e', { depth: 1 }), { a: { b: { '[c][d]': 'e' } } }); + st.end(); + }); + + t.deepEqual(qs.parse('a=b&a=c'), { a: ['b', 'c'] }, 'parses a simple array'); + + t.test('parses an explicit array', function (st) { + st.deepEqual(qs.parse('a[]=b'), { a: ['b'] }); + st.deepEqual(qs.parse('a[]=b&a[]=c'), { a: ['b', 'c'] }); + st.deepEqual(qs.parse('a[]=b&a[]=c&a[]=d'), { a: ['b', 'c', 'd'] }); + st.end(); + }); + + t.test('parses a mix of simple and explicit arrays', function (st) { + st.deepEqual(qs.parse('a=b&a[]=c'), { a: ['b', 'c'] }); + st.deepEqual(qs.parse('a[]=b&a=c'), { a: ['b', 'c'] }); + st.deepEqual(qs.parse('a[0]=b&a=c'), { a: ['b', 'c'] }); + st.deepEqual(qs.parse('a=b&a[0]=c'), { a: ['b', 'c'] }); + st.deepEqual(qs.parse('a[1]=b&a=c'), { a: ['b', 'c'] }); + st.deepEqual(qs.parse('a=b&a[1]=c'), { a: ['b', 'c'] }); + st.end(); + }); + + t.test('parses a nested array', function (st) { + st.deepEqual(qs.parse('a[b][]=c&a[b][]=d'), { a: { b: ['c', 'd'] } }); + st.deepEqual(qs.parse('a[>=]=25'), { a: { '>=': '25' } }); + st.end(); + }); + + t.test('allows to specify array indices', function (st) { + st.deepEqual(qs.parse('a[1]=c&a[0]=b&a[2]=d'), { a: ['b', 'c', 'd'] }); + st.deepEqual(qs.parse('a[1]=c&a[0]=b'), { a: ['b', 'c'] }); + st.deepEqual(qs.parse('a[1]=c'), { a: ['c'] }); + st.end(); + }); + + t.test('limits specific array indices to 20', function (st) { + st.deepEqual(qs.parse('a[20]=a'), { a: ['a'] }); + st.deepEqual(qs.parse('a[21]=a'), { a: { '21': 'a' } }); + st.end(); + }); + + t.deepEqual(qs.parse('a[12b]=c'), { a: { '12b': 'c' } }, 'supports keys that begin with a number'); + + t.test('supports encoded = signs', function (st) { + st.deepEqual(qs.parse('he%3Dllo=th%3Dere'), { 'he=llo': 'th=ere' }); + st.end(); + }); + + t.test('is ok with url encoded strings', function (st) { + st.deepEqual(qs.parse('a[b%20c]=d'), { a: { 'b c': 'd' } }); + st.deepEqual(qs.parse('a[b]=c%20d'), { a: { b: 'c d' } }); + st.end(); + }); + + t.test('allows brackets in the value', function (st) { + st.deepEqual(qs.parse('pets=["tobi"]'), { pets: '["tobi"]' }); + st.deepEqual(qs.parse('operators=[">=", "<="]'), { operators: '[">=", "<="]' }); + st.end(); + }); + + t.test('allows empty values', function (st) { + st.deepEqual(qs.parse(''), {}); + st.deepEqual(qs.parse(null), {}); + st.deepEqual(qs.parse(undefined), {}); + st.end(); + }); + + t.test('transforms arrays to objects', function (st) { + st.deepEqual(qs.parse('foo[0]=bar&foo[bad]=baz'), { foo: { '0': 'bar', bad: 'baz' } }); + st.deepEqual(qs.parse('foo[bad]=baz&foo[0]=bar'), { foo: { bad: 'baz', '0': 'bar' } }); + st.deepEqual(qs.parse('foo[bad]=baz&foo[]=bar'), { foo: { bad: 'baz', '0': 'bar' } }); + st.deepEqual(qs.parse('foo[]=bar&foo[bad]=baz'), { foo: { '0': 'bar', bad: 'baz' } }); + st.deepEqual(qs.parse('foo[bad]=baz&foo[]=bar&foo[]=foo'), { foo: { bad: 'baz', '0': 'bar', '1': 'foo' } }); + st.deepEqual(qs.parse('foo[0][a]=a&foo[0][b]=b&foo[1][a]=aa&foo[1][b]=bb'), { foo: [{ a: 'a', b: 'b' }, { a: 'aa', b: 'bb' }] }); + st.deepEqual(qs.parse('a[]=b&a[t]=u&a[hasOwnProperty]=c'), { a: { '0': 'b', t: 'u', c: true } }); + st.deepEqual(qs.parse('a[]=b&a[hasOwnProperty]=c&a[x]=y'), { a: { '0': 'b', '1': 'c', x: 'y' } }); + st.end(); + }); + + t.test('transforms arrays to objects (dot notation)', function (st) { + st.deepEqual(qs.parse('foo[0].baz=bar&fool.bad=baz', { allowDots: true }), { foo: [{ baz: 'bar' }], fool: { bad: 'baz' } }); + st.deepEqual(qs.parse('foo[0].baz=bar&fool.bad.boo=baz', { allowDots: true }), { foo: [{ baz: 'bar' }], fool: { bad: { boo: 'baz' } } }); + st.deepEqual(qs.parse('foo[0][0].baz=bar&fool.bad=baz', { allowDots: true }), { foo: [[{ baz: 'bar' }]], fool: { bad: 'baz' } }); + st.deepEqual(qs.parse('foo[0].baz[0]=15&foo[0].bar=2', { allowDots: true }), { foo: [{ baz: ['15'], bar: '2' }] }); + st.deepEqual(qs.parse('foo[0].baz[0]=15&foo[0].baz[1]=16&foo[0].bar=2', { allowDots: true }), { foo: [{ baz: ['15', '16'], bar: '2' }] }); + st.deepEqual(qs.parse('foo.bad=baz&foo[0]=bar', { allowDots: true }), { foo: { bad: 'baz', '0': 'bar' } }); + st.deepEqual(qs.parse('foo.bad=baz&foo[]=bar', { allowDots: true }), { foo: { bad: 'baz', '0': 'bar' } }); + st.deepEqual(qs.parse('foo[]=bar&foo.bad=baz', { allowDots: true }), { foo: { '0': 'bar', bad: 'baz' } }); + st.deepEqual(qs.parse('foo.bad=baz&foo[]=bar&foo[]=foo', { allowDots: true }), { foo: { bad: 'baz', '0': 'bar', '1': 'foo' } }); + st.deepEqual(qs.parse('foo[0].a=a&foo[0].b=b&foo[1].a=aa&foo[1].b=bb', { allowDots: true }), { foo: [{ a: 'a', b: 'b' }, { a: 'aa', b: 'bb' }] }); + st.end(); + }); + + t.deepEqual(qs.parse('a[b]=c&a=d'), { a: { b: 'c', d: true } }, 'can add keys to objects'); + + t.test('correctly prunes undefined values when converting an array to an object', function (st) { + st.deepEqual(qs.parse('a[2]=b&a[99999999]=c'), { a: { '2': 'b', '99999999': 'c' } }); + st.end(); + }); + + t.test('supports malformed uri characters', function (st) { + st.deepEqual(qs.parse('{%:%}', { strictNullHandling: true }), { '{%:%}': null }); + st.deepEqual(qs.parse('{%:%}='), { '{%:%}': '' }); + st.deepEqual(qs.parse('foo=%:%}'), { foo: '%:%}' }); + st.end(); + }); + + t.test('doesn\'t produce empty keys', function (st) { + st.deepEqual(qs.parse('_r=1&'), { '_r': '1' }); + st.end(); + }); + + t.test('cannot access Object prototype', function (st) { + qs.parse('constructor[prototype][bad]=bad'); + qs.parse('bad[constructor][prototype][bad]=bad'); + st.equal(typeof Object.prototype.bad, 'undefined'); + st.end(); + }); + + t.test('parses arrays of objects', function (st) { + st.deepEqual(qs.parse('a[][b]=c'), { a: [{ b: 'c' }] }); + st.deepEqual(qs.parse('a[0][b]=c'), { a: [{ b: 'c' }] }); + st.end(); + }); + + t.test('allows for empty strings in arrays', function (st) { + st.deepEqual(qs.parse('a[]=b&a[]=&a[]=c'), { a: ['b', '', 'c'] }); + st.deepEqual(qs.parse('a[0]=b&a[1]&a[2]=c&a[19]=', { strictNullHandling: true }), { a: ['b', null, 'c', ''] }); + st.deepEqual(qs.parse('a[0]=b&a[1]=&a[2]=c&a[19]', { strictNullHandling: true }), { a: ['b', '', 'c', null] }); + st.deepEqual(qs.parse('a[]=&a[]=b&a[]=c'), { a: ['', 'b', 'c'] }); + st.end(); + }); + + t.test('compacts sparse arrays', function (st) { + st.deepEqual(qs.parse('a[10]=1&a[2]=2'), { a: ['2', '1'] }); + st.deepEqual(qs.parse('a[1][b][2][c]=1'), { a: [{ b: [{ c: '1' }] }] }); + st.deepEqual(qs.parse('a[1][2][3][c]=1'), { a: [[[{ c: '1' }]]] }); + st.deepEqual(qs.parse('a[1][2][3][c][1]=1'), { a: [[[{ c: ['1'] }]]] }); + st.end(); + }); + + t.test('parses semi-parsed strings', function (st) { + st.deepEqual(qs.parse({ 'a[b]': 'c' }), { a: { b: 'c' } }); + st.deepEqual(qs.parse({ 'a[b]': 'c', 'a[d]': 'e' }), { a: { b: 'c', d: 'e' } }); + st.end(); + }); + + t.test('parses buffers correctly', function (st) { + var b = new Buffer('test'); + st.deepEqual(qs.parse({ a: b }), { a: b }); + st.end(); + }); + + t.test('continues parsing when no parent is found', function (st) { + st.deepEqual(qs.parse('[]=&a=b'), { '0': '', a: 'b' }); + st.deepEqual(qs.parse('[]&a=b', { strictNullHandling: true }), { '0': null, a: 'b' }); + st.deepEqual(qs.parse('[foo]=bar'), { foo: 'bar' }); + st.end(); + }); + + t.test('does not error when parsing a very long array', function (st) { + var str = 'a[]=a'; + while (Buffer.byteLength(str) < 128 * 1024) { + str = str + '&' + str; + } + + st.doesNotThrow(function () { qs.parse(str); }); + + st.end(); + }); + + t.test('should not throw when a native prototype has an enumerable property', { parallel: false }, function (st) { + Object.prototype.crash = ''; + Array.prototype.crash = ''; + st.doesNotThrow(qs.parse.bind(null, 'a=b')); + st.deepEqual(qs.parse('a=b'), { a: 'b' }); + st.doesNotThrow(qs.parse.bind(null, 'a[][b]=c')); + st.deepEqual(qs.parse('a[][b]=c'), { a: [{ b: 'c' }] }); + delete Object.prototype.crash; + delete Array.prototype.crash; + st.end(); + }); + + t.test('parses a string with an alternative string delimiter', function (st) { + st.deepEqual(qs.parse('a=b;c=d', { delimiter: ';' }), { a: 'b', c: 'd' }); + st.end(); + }); + + t.test('parses a string with an alternative RegExp delimiter', function (st) { + st.deepEqual(qs.parse('a=b; c=d', { delimiter: /[;,] */ }), { a: 'b', c: 'd' }); + st.end(); + }); + + t.test('does not use non-splittable objects as delimiters', function (st) { + st.deepEqual(qs.parse('a=b&c=d', { delimiter: true }), { a: 'b', c: 'd' }); + st.end(); + }); + + t.test('allows overriding parameter limit', function (st) { + st.deepEqual(qs.parse('a=b&c=d', { parameterLimit: 1 }), { a: 'b' }); + st.end(); + }); + + t.test('allows setting the parameter limit to Infinity', function (st) { + st.deepEqual(qs.parse('a=b&c=d', { parameterLimit: Infinity }), { a: 'b', c: 'd' }); + st.end(); + }); + + t.test('allows overriding array limit', function (st) { + st.deepEqual(qs.parse('a[0]=b', { arrayLimit: -1 }), { a: { '0': 'b' } }); + st.deepEqual(qs.parse('a[-1]=b', { arrayLimit: -1 }), { a: { '-1': 'b' } }); + st.deepEqual(qs.parse('a[0]=b&a[1]=c', { arrayLimit: 0 }), { a: { '0': 'b', '1': 'c' } }); + st.end(); + }); + + t.test('allows disabling array parsing', function (st) { + st.deepEqual(qs.parse('a[0]=b&a[1]=c', { parseArrays: false }), { a: { '0': 'b', '1': 'c' } }); + st.end(); + }); + + t.test('parses an object', function (st) { + var input = { + 'user[name]': { 'pop[bob]': 3 }, + 'user[email]': null + }; + + var expected = { + user: { + name: { 'pop[bob]': 3 }, + email: null + } + }; + + var result = qs.parse(input); + + st.deepEqual(result, expected); + st.end(); + }); + + t.test('parses an object in dot notation', function (st) { + var input = { + 'user.name': { 'pop[bob]': 3 }, + 'user.email.': null + }; + + var expected = { + user: { + name: { 'pop[bob]': 3 }, + email: null + } + }; + + var result = qs.parse(input, { allowDots: true }); + + st.deepEqual(result, expected); + st.end(); + }); + + t.test('parses an object and not child values', function (st) { + var input = { + 'user[name]': { 'pop[bob]': { 'test': 3 } }, + 'user[email]': null + }; + + var expected = { + user: { + name: { 'pop[bob]': { 'test': 3 } }, + email: null + } + }; + + var result = qs.parse(input); + + st.deepEqual(result, expected); + st.end(); + }); + + t.test('does not blow up when Buffer global is missing', function (st) { + var tempBuffer = global.Buffer; + delete global.Buffer; + var result = qs.parse('a=b&c=d'); + global.Buffer = tempBuffer; + st.deepEqual(result, { a: 'b', c: 'd' }); + st.end(); + }); + + t.test('does not crash when parsing circular references', function (st) { + var a = {}; + a.b = a; + + var parsed; + + st.doesNotThrow(function () { + parsed = qs.parse({ 'foo[bar]': 'baz', 'foo[baz]': a }); + }); + + st.equal('foo' in parsed, true, 'parsed has "foo" property'); + st.equal('bar' in parsed.foo, true); + st.equal('baz' in parsed.foo, true); + st.equal(parsed.foo.bar, 'baz'); + st.deepEqual(parsed.foo.baz, a); + st.end(); + }); + + t.test('parses plain objects correctly', function (st) { + var a = Object.create(null); + a.b = 'c'; + + st.deepEqual(qs.parse(a), { b: 'c' }); + var result = qs.parse({ a: a }); + st.equal('a' in result, true, 'result has "a" property'); + st.deepEqual(result.a, a); + st.end(); + }); + + t.test('parses dates correctly', function (st) { + var now = new Date(); + st.deepEqual(qs.parse({ a: now }), { a: now }); + st.end(); + }); + + t.test('parses regular expressions correctly', function (st) { + var re = /^test$/; + st.deepEqual(qs.parse({ a: re }), { a: re }); + st.end(); + }); + + t.test('can allow overwriting prototype properties', function (st) { + st.deepEqual(qs.parse('a[hasOwnProperty]=b', { allowPrototypes: true }), { a: { hasOwnProperty: 'b' } }, { prototype: false }); + st.deepEqual(qs.parse('hasOwnProperty=b', { allowPrototypes: true }), { hasOwnProperty: 'b' }, { prototype: false }); + st.end(); + }); + + t.test('can return plain objects', function (st) { + var expected = Object.create(null); + expected.a = Object.create(null); + expected.a.b = 'c'; + expected.a.hasOwnProperty = 'd'; + st.deepEqual(qs.parse('a[b]=c&a[hasOwnProperty]=d', { plainObjects: true }), expected); + st.deepEqual(qs.parse(null, { plainObjects: true }), Object.create(null)); + var expectedArray = Object.create(null); + expectedArray.a = Object.create(null); + expectedArray.a['0'] = 'b'; + expectedArray.a.c = 'd'; + st.deepEqual(qs.parse('a[]=b&a[c]=d', { plainObjects: true }), expectedArray); + st.end(); + }); + + t.test('can parse with custom encoding', function (st) { + st.deepEqual(qs.parse('%8c%a7=%91%e5%8d%e3%95%7b', { + decoder: function (str) { + var reg = /\%([0-9A-F]{2})/ig; + var result = []; + var parts; + var last = 0; + while (parts = reg.exec(str)) { + result.push(parseInt(parts[1], 16)); + last = parts.index + parts[0].length; + } + return iconv.decode(new Buffer(result), 'shift_jis').toString(); + } + }), { 県: '大阪府' }); + st.end(); + }); + + t.test('throws error with wrong decoder', function (st) { + st.throws(function () { + qs.parse({}, { + decoder: 'string' + }); + }, new TypeError('Decoder has to be a function.')); + st.end(); + }); +}); diff --git a/ui/node_modules/express/node_modules/qs/test/stringify.js b/ui/node_modules/express/node_modules/qs/test/stringify.js old mode 100755 new mode 100644 index b8fed5a3..699397e3 --- a/ui/node_modules/express/node_modules/qs/test/stringify.js +++ b/ui/node_modules/express/node_modules/qs/test/stringify.js @@ -1,305 +1,305 @@ -'use strict'; - -var test = require('tape'); -var qs = require('../'); -var iconv = require('iconv-lite'); - -test('stringify()', function (t) { - t.test('stringifies a querystring object', function (st) { - st.equal(qs.stringify({ a: 'b' }), 'a=b'); - st.equal(qs.stringify({ a: 1 }), 'a=1'); - st.equal(qs.stringify({ a: 1, b: 2 }), 'a=1&b=2'); - st.equal(qs.stringify({ a: 'A_Z' }), 'a=A_Z'); - st.equal(qs.stringify({ a: '€' }), 'a=%E2%82%AC'); - st.equal(qs.stringify({ a: '' }), 'a=%EE%80%80'); - st.equal(qs.stringify({ a: 'א' }), 'a=%D7%90'); - st.equal(qs.stringify({ a: '𐐷' }), 'a=%F0%90%90%B7'); - st.end(); - }); - - t.test('stringifies a nested object', function (st) { - st.equal(qs.stringify({ a: { b: 'c' } }), 'a%5Bb%5D=c'); - st.equal(qs.stringify({ a: { b: { c: { d: 'e' } } } }), 'a%5Bb%5D%5Bc%5D%5Bd%5D=e'); - st.end(); - }); - - t.test('stringifies a nested object with dots notation', function (st) { - st.equal(qs.stringify({ a: { b: 'c' } }, { allowDots: true }), 'a.b=c'); - st.equal(qs.stringify({ a: { b: { c: { d: 'e' } } } }, { allowDots: true }), 'a.b.c.d=e'); - st.end(); - }); - - t.test('stringifies an array value', function (st) { - st.equal(qs.stringify({ a: ['b', 'c', 'd'] }), 'a%5B0%5D=b&a%5B1%5D=c&a%5B2%5D=d'); - st.end(); - }); - - t.test('omits nulls when asked', function (st) { - st.equal(qs.stringify({ a: 'b', c: null }, { skipNulls: true }), 'a=b'); - st.end(); - }); - - - t.test('omits nested nulls when asked', function (st) { - st.equal(qs.stringify({ a: { b: 'c', d: null } }, { skipNulls: true }), 'a%5Bb%5D=c'); - st.end(); - }); - - t.test('omits array indices when asked', function (st) { - st.equal(qs.stringify({ a: ['b', 'c', 'd'] }, { indices: false }), 'a=b&a=c&a=d'); - st.end(); - }); - - t.test('stringifies a nested array value', function (st) { - st.equal(qs.stringify({ a: { b: ['c', 'd'] } }), 'a%5Bb%5D%5B0%5D=c&a%5Bb%5D%5B1%5D=d'); - st.end(); - }); - - t.test('stringifies a nested array value with dots notation', function (st) { - st.equal(qs.stringify({ a: { b: ['c', 'd'] } }, { allowDots: true, encode: false }), 'a.b[0]=c&a.b[1]=d'); - st.end(); - }); - - t.test('stringifies an object inside an array', function (st) { - st.equal(qs.stringify({ a: [{ b: 'c' }] }), 'a%5B0%5D%5Bb%5D=c'); - st.equal(qs.stringify({ a: [{ b: { c: [1] } }] }), 'a%5B0%5D%5Bb%5D%5Bc%5D%5B0%5D=1'); - st.end(); - }); - - t.test('stringifies an array with mixed objects and primitives', function (st) { - st.equal(qs.stringify({ a: [{ b: 1 }, 2, 3] }, { encode: false }), 'a[0][b]=1&a[1]=2&a[2]=3'); - st.end(); - }); - - t.test('stringifies an object inside an array with dots notation', function (st) { - st.equal(qs.stringify({ a: [{ b: 'c' }] }, { allowDots: true, encode: false }), 'a[0].b=c'); - st.equal(qs.stringify({ a: [{ b: { c: [1] } }] }, { allowDots: true, encode: false }), 'a[0].b.c[0]=1'); - st.end(); - }); - - t.test('does not omit object keys when indices = false', function (st) { - st.equal(qs.stringify({ a: [{ b: 'c' }] }, { indices: false }), 'a%5Bb%5D=c'); - st.end(); - }); - - t.test('uses indices notation for arrays when indices=true', function (st) { - st.equal(qs.stringify({ a: ['b', 'c'] }, { indices: true }), 'a%5B0%5D=b&a%5B1%5D=c'); - st.end(); - }); - - t.test('uses indices notation for arrays when no arrayFormat is specified', function (st) { - st.equal(qs.stringify({ a: ['b', 'c'] }), 'a%5B0%5D=b&a%5B1%5D=c'); - st.end(); - }); - - t.test('uses indices notation for arrays when no arrayFormat=indices', function (st) { - st.equal(qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'indices' }), 'a%5B0%5D=b&a%5B1%5D=c'); - st.end(); - }); - - t.test('uses repeat notation for arrays when no arrayFormat=repeat', function (st) { - st.equal(qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'repeat' }), 'a=b&a=c'); - st.end(); - }); - - t.test('uses brackets notation for arrays when no arrayFormat=brackets', function (st) { - st.equal(qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'brackets' }), 'a%5B%5D=b&a%5B%5D=c'); - st.end(); - }); - - t.test('stringifies a complicated object', function (st) { - st.equal(qs.stringify({ a: { b: 'c', d: 'e' } }), 'a%5Bb%5D=c&a%5Bd%5D=e'); - st.end(); - }); - - t.test('stringifies an empty value', function (st) { - st.equal(qs.stringify({ a: '' }), 'a='); - st.equal(qs.stringify({ a: null }, { strictNullHandling: true }), 'a'); - - st.equal(qs.stringify({ a: '', b: '' }), 'a=&b='); - st.equal(qs.stringify({ a: null, b: '' }, { strictNullHandling: true }), 'a&b='); - - st.equal(qs.stringify({ a: { b: '' } }), 'a%5Bb%5D='); - st.equal(qs.stringify({ a: { b: null } }, { strictNullHandling: true }), 'a%5Bb%5D'); - st.equal(qs.stringify({ a: { b: null } }, { strictNullHandling: false }), 'a%5Bb%5D='); - - st.end(); - }); - - t.test('stringifies an empty object', function (st) { - var obj = Object.create(null); - obj.a = 'b'; - st.equal(qs.stringify(obj), 'a=b'); - st.end(); - }); - - t.test('returns an empty string for invalid input', function (st) { - st.equal(qs.stringify(undefined), ''); - st.equal(qs.stringify(false), ''); - st.equal(qs.stringify(null), ''); - st.equal(qs.stringify(''), ''); - st.end(); - }); - - t.test('stringifies an object with an empty object as a child', function (st) { - var obj = { - a: Object.create(null) - }; - - obj.a.b = 'c'; - st.equal(qs.stringify(obj), 'a%5Bb%5D=c'); - st.end(); - }); - - t.test('drops keys with a value of undefined', function (st) { - st.equal(qs.stringify({ a: undefined }), ''); - - st.equal(qs.stringify({ a: { b: undefined, c: null } }, { strictNullHandling: true }), 'a%5Bc%5D'); - st.equal(qs.stringify({ a: { b: undefined, c: null } }, { strictNullHandling: false }), 'a%5Bc%5D='); - st.equal(qs.stringify({ a: { b: undefined, c: '' } }), 'a%5Bc%5D='); - st.end(); - }); - - t.test('url encodes values', function (st) { - st.equal(qs.stringify({ a: 'b c' }), 'a=b%20c'); - st.end(); - }); - - t.test('stringifies a date', function (st) { - var now = new Date(); - var str = 'a=' + encodeURIComponent(now.toISOString()); - st.equal(qs.stringify({ a: now }), str); - st.end(); - }); - - t.test('stringifies the weird object from qs', function (st) { - st.equal(qs.stringify({ 'my weird field': '~q1!2"\'w$5&7/z8)?' }), 'my%20weird%20field=~q1%212%22%27w%245%267%2Fz8%29%3F'); - st.end(); - }); - - t.test('skips properties that are part of the object prototype', function (st) { - Object.prototype.crash = 'test'; - st.equal(qs.stringify({ a: 'b' }), 'a=b'); - st.equal(qs.stringify({ a: { b: 'c' } }), 'a%5Bb%5D=c'); - delete Object.prototype.crash; - st.end(); - }); - - t.test('stringifies boolean values', function (st) { - st.equal(qs.stringify({ a: true }), 'a=true'); - st.equal(qs.stringify({ a: { b: true } }), 'a%5Bb%5D=true'); - st.equal(qs.stringify({ b: false }), 'b=false'); - st.equal(qs.stringify({ b: { c: false } }), 'b%5Bc%5D=false'); - st.end(); - }); - - t.test('stringifies buffer values', function (st) { - st.equal(qs.stringify({ a: new Buffer('test') }), 'a=test'); - st.equal(qs.stringify({ a: { b: new Buffer('test') } }), 'a%5Bb%5D=test'); - st.end(); - }); - - t.test('stringifies an object using an alternative delimiter', function (st) { - st.equal(qs.stringify({ a: 'b', c: 'd' }, { delimiter: ';' }), 'a=b;c=d'); - st.end(); - }); - - t.test('doesn\'t blow up when Buffer global is missing', function (st) { - var tempBuffer = global.Buffer; - delete global.Buffer; - var result = qs.stringify({ a: 'b', c: 'd' }); - global.Buffer = tempBuffer; - st.equal(result, 'a=b&c=d'); - st.end(); - }); - - t.test('selects properties when filter=array', function (st) { - st.equal(qs.stringify({ a: 'b' }, { filter: ['a'] }), 'a=b'); - st.equal(qs.stringify({ a: 1 }, { filter: [] }), ''); - st.equal(qs.stringify({ a: { b: [1, 2, 3, 4], c: 'd' }, c: 'f' }, { filter: ['a', 'b', 0, 2] }), 'a%5Bb%5D%5B0%5D=1&a%5Bb%5D%5B2%5D=3'); - st.end(); - }); - - t.test('supports custom representations when filter=function', function (st) { - var calls = 0; - var obj = { a: 'b', c: 'd', e: { f: new Date(1257894000000) } }; - var filterFunc = function (prefix, value) { - calls++; - if (calls === 1) { - st.equal(prefix, '', 'prefix is empty'); - st.equal(value, obj); - } else if (prefix === 'c') { - return; - } else if (value instanceof Date) { - st.equal(prefix, 'e[f]'); - return value.getTime(); - } - return value; - }; - - st.equal(qs.stringify(obj, { filter: filterFunc }), 'a=b&e%5Bf%5D=1257894000000'); - st.equal(calls, 5); - st.end(); - }); - - t.test('can disable uri encoding', function (st) { - st.equal(qs.stringify({ a: 'b' }, { encode: false }), 'a=b'); - st.equal(qs.stringify({ a: { b: 'c' } }, { encode: false }), 'a[b]=c'); - st.equal(qs.stringify({ a: 'b', c: null }, { strictNullHandling: true, encode: false }), 'a=b&c'); - st.end(); - }); - - t.test('can sort the keys', function (st) { - var sort = function (a, b) { return a.localeCompare(b); }; - st.equal(qs.stringify({ a: 'c', z: 'y', b: 'f' }, { sort: sort }), 'a=c&b=f&z=y'); - st.equal(qs.stringify({ a: 'c', z: { j: 'a', i: 'b' }, b: 'f' }, { sort: sort }), 'a=c&b=f&z%5Bi%5D=b&z%5Bj%5D=a'); - st.end(); - }); - - t.test('can sort the keys at depth 3 or more too', function (st) { - var sort = function (a, b) { return a.localeCompare(b); }; - st.equal(qs.stringify({ a: 'a', z: { zj: {zjb: 'zjb', zja: 'zja'}, zi: {zib: 'zib', zia: 'zia'} }, b: 'b' }, { sort: sort, encode: false }), 'a=a&b=b&z[zi][zia]=zia&z[zi][zib]=zib&z[zj][zja]=zja&z[zj][zjb]=zjb'); - st.equal(qs.stringify({ a: 'a', z: { zj: {zjb: 'zjb', zja: 'zja'}, zi: {zib: 'zib', zia: 'zia'} }, b: 'b' }, { sort: null, encode: false }), 'a=a&z[zj][zjb]=zjb&z[zj][zja]=zja&z[zi][zib]=zib&z[zi][zia]=zia&b=b'); - st.end(); - }); - - t.test('can stringify with custom encoding', function (st) { - st.equal(qs.stringify({ 県: '大阪府', '': ''}, { - encoder: function (str) { - if (str.length === 0) { - return ''; - } - var buf = iconv.encode(str, 'shiftjis'); - var result = []; - for (var i=0; i < buf.length; ++i) { - result.push(buf.readUInt8(i).toString(16)); - } - return '%' + result.join('%'); - } - }), '%8c%a7=%91%e5%8d%e3%95%7b&='); - st.end(); - }); - - t.test('throws error with wrong encoder', function (st) { - st.throws(function () { - qs.stringify({}, { - encoder: 'string' - }); - }, new TypeError('Encoder has to be a function.')); - st.end(); - }); - - t.test('can use custom encoder for a buffer object', { - skip: typeof Buffer === 'undefined' - }, function (st) { - st.equal(qs.stringify({ a: new Buffer([1]) }, { - encoder: function (buffer) { - if (typeof buffer === 'string') { - return buffer; - } - return String.fromCharCode(buffer.readUInt8(0) + 97); - } - }), 'a=b'); - st.end(); - }); -}); +'use strict'; + +var test = require('tape'); +var qs = require('../'); +var iconv = require('iconv-lite'); + +test('stringify()', function (t) { + t.test('stringifies a querystring object', function (st) { + st.equal(qs.stringify({ a: 'b' }), 'a=b'); + st.equal(qs.stringify({ a: 1 }), 'a=1'); + st.equal(qs.stringify({ a: 1, b: 2 }), 'a=1&b=2'); + st.equal(qs.stringify({ a: 'A_Z' }), 'a=A_Z'); + st.equal(qs.stringify({ a: '€' }), 'a=%E2%82%AC'); + st.equal(qs.stringify({ a: '' }), 'a=%EE%80%80'); + st.equal(qs.stringify({ a: 'א' }), 'a=%D7%90'); + st.equal(qs.stringify({ a: '𐐷' }), 'a=%F0%90%90%B7'); + st.end(); + }); + + t.test('stringifies a nested object', function (st) { + st.equal(qs.stringify({ a: { b: 'c' } }), 'a%5Bb%5D=c'); + st.equal(qs.stringify({ a: { b: { c: { d: 'e' } } } }), 'a%5Bb%5D%5Bc%5D%5Bd%5D=e'); + st.end(); + }); + + t.test('stringifies a nested object with dots notation', function (st) { + st.equal(qs.stringify({ a: { b: 'c' } }, { allowDots: true }), 'a.b=c'); + st.equal(qs.stringify({ a: { b: { c: { d: 'e' } } } }, { allowDots: true }), 'a.b.c.d=e'); + st.end(); + }); + + t.test('stringifies an array value', function (st) { + st.equal(qs.stringify({ a: ['b', 'c', 'd'] }), 'a%5B0%5D=b&a%5B1%5D=c&a%5B2%5D=d'); + st.end(); + }); + + t.test('omits nulls when asked', function (st) { + st.equal(qs.stringify({ a: 'b', c: null }, { skipNulls: true }), 'a=b'); + st.end(); + }); + + + t.test('omits nested nulls when asked', function (st) { + st.equal(qs.stringify({ a: { b: 'c', d: null } }, { skipNulls: true }), 'a%5Bb%5D=c'); + st.end(); + }); + + t.test('omits array indices when asked', function (st) { + st.equal(qs.stringify({ a: ['b', 'c', 'd'] }, { indices: false }), 'a=b&a=c&a=d'); + st.end(); + }); + + t.test('stringifies a nested array value', function (st) { + st.equal(qs.stringify({ a: { b: ['c', 'd'] } }), 'a%5Bb%5D%5B0%5D=c&a%5Bb%5D%5B1%5D=d'); + st.end(); + }); + + t.test('stringifies a nested array value with dots notation', function (st) { + st.equal(qs.stringify({ a: { b: ['c', 'd'] } }, { allowDots: true, encode: false }), 'a.b[0]=c&a.b[1]=d'); + st.end(); + }); + + t.test('stringifies an object inside an array', function (st) { + st.equal(qs.stringify({ a: [{ b: 'c' }] }), 'a%5B0%5D%5Bb%5D=c'); + st.equal(qs.stringify({ a: [{ b: { c: [1] } }] }), 'a%5B0%5D%5Bb%5D%5Bc%5D%5B0%5D=1'); + st.end(); + }); + + t.test('stringifies an array with mixed objects and primitives', function (st) { + st.equal(qs.stringify({ a: [{ b: 1 }, 2, 3] }, { encode: false }), 'a[0][b]=1&a[1]=2&a[2]=3'); + st.end(); + }); + + t.test('stringifies an object inside an array with dots notation', function (st) { + st.equal(qs.stringify({ a: [{ b: 'c' }] }, { allowDots: true, encode: false }), 'a[0].b=c'); + st.equal(qs.stringify({ a: [{ b: { c: [1] } }] }, { allowDots: true, encode: false }), 'a[0].b.c[0]=1'); + st.end(); + }); + + t.test('does not omit object keys when indices = false', function (st) { + st.equal(qs.stringify({ a: [{ b: 'c' }] }, { indices: false }), 'a%5Bb%5D=c'); + st.end(); + }); + + t.test('uses indices notation for arrays when indices=true', function (st) { + st.equal(qs.stringify({ a: ['b', 'c'] }, { indices: true }), 'a%5B0%5D=b&a%5B1%5D=c'); + st.end(); + }); + + t.test('uses indices notation for arrays when no arrayFormat is specified', function (st) { + st.equal(qs.stringify({ a: ['b', 'c'] }), 'a%5B0%5D=b&a%5B1%5D=c'); + st.end(); + }); + + t.test('uses indices notation for arrays when no arrayFormat=indices', function (st) { + st.equal(qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'indices' }), 'a%5B0%5D=b&a%5B1%5D=c'); + st.end(); + }); + + t.test('uses repeat notation for arrays when no arrayFormat=repeat', function (st) { + st.equal(qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'repeat' }), 'a=b&a=c'); + st.end(); + }); + + t.test('uses brackets notation for arrays when no arrayFormat=brackets', function (st) { + st.equal(qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'brackets' }), 'a%5B%5D=b&a%5B%5D=c'); + st.end(); + }); + + t.test('stringifies a complicated object', function (st) { + st.equal(qs.stringify({ a: { b: 'c', d: 'e' } }), 'a%5Bb%5D=c&a%5Bd%5D=e'); + st.end(); + }); + + t.test('stringifies an empty value', function (st) { + st.equal(qs.stringify({ a: '' }), 'a='); + st.equal(qs.stringify({ a: null }, { strictNullHandling: true }), 'a'); + + st.equal(qs.stringify({ a: '', b: '' }), 'a=&b='); + st.equal(qs.stringify({ a: null, b: '' }, { strictNullHandling: true }), 'a&b='); + + st.equal(qs.stringify({ a: { b: '' } }), 'a%5Bb%5D='); + st.equal(qs.stringify({ a: { b: null } }, { strictNullHandling: true }), 'a%5Bb%5D'); + st.equal(qs.stringify({ a: { b: null } }, { strictNullHandling: false }), 'a%5Bb%5D='); + + st.end(); + }); + + t.test('stringifies an empty object', function (st) { + var obj = Object.create(null); + obj.a = 'b'; + st.equal(qs.stringify(obj), 'a=b'); + st.end(); + }); + + t.test('returns an empty string for invalid input', function (st) { + st.equal(qs.stringify(undefined), ''); + st.equal(qs.stringify(false), ''); + st.equal(qs.stringify(null), ''); + st.equal(qs.stringify(''), ''); + st.end(); + }); + + t.test('stringifies an object with an empty object as a child', function (st) { + var obj = { + a: Object.create(null) + }; + + obj.a.b = 'c'; + st.equal(qs.stringify(obj), 'a%5Bb%5D=c'); + st.end(); + }); + + t.test('drops keys with a value of undefined', function (st) { + st.equal(qs.stringify({ a: undefined }), ''); + + st.equal(qs.stringify({ a: { b: undefined, c: null } }, { strictNullHandling: true }), 'a%5Bc%5D'); + st.equal(qs.stringify({ a: { b: undefined, c: null } }, { strictNullHandling: false }), 'a%5Bc%5D='); + st.equal(qs.stringify({ a: { b: undefined, c: '' } }), 'a%5Bc%5D='); + st.end(); + }); + + t.test('url encodes values', function (st) { + st.equal(qs.stringify({ a: 'b c' }), 'a=b%20c'); + st.end(); + }); + + t.test('stringifies a date', function (st) { + var now = new Date(); + var str = 'a=' + encodeURIComponent(now.toISOString()); + st.equal(qs.stringify({ a: now }), str); + st.end(); + }); + + t.test('stringifies the weird object from qs', function (st) { + st.equal(qs.stringify({ 'my weird field': '~q1!2"\'w$5&7/z8)?' }), 'my%20weird%20field=~q1%212%22%27w%245%267%2Fz8%29%3F'); + st.end(); + }); + + t.test('skips properties that are part of the object prototype', function (st) { + Object.prototype.crash = 'test'; + st.equal(qs.stringify({ a: 'b' }), 'a=b'); + st.equal(qs.stringify({ a: { b: 'c' } }), 'a%5Bb%5D=c'); + delete Object.prototype.crash; + st.end(); + }); + + t.test('stringifies boolean values', function (st) { + st.equal(qs.stringify({ a: true }), 'a=true'); + st.equal(qs.stringify({ a: { b: true } }), 'a%5Bb%5D=true'); + st.equal(qs.stringify({ b: false }), 'b=false'); + st.equal(qs.stringify({ b: { c: false } }), 'b%5Bc%5D=false'); + st.end(); + }); + + t.test('stringifies buffer values', function (st) { + st.equal(qs.stringify({ a: new Buffer('test') }), 'a=test'); + st.equal(qs.stringify({ a: { b: new Buffer('test') } }), 'a%5Bb%5D=test'); + st.end(); + }); + + t.test('stringifies an object using an alternative delimiter', function (st) { + st.equal(qs.stringify({ a: 'b', c: 'd' }, { delimiter: ';' }), 'a=b;c=d'); + st.end(); + }); + + t.test('doesn\'t blow up when Buffer global is missing', function (st) { + var tempBuffer = global.Buffer; + delete global.Buffer; + var result = qs.stringify({ a: 'b', c: 'd' }); + global.Buffer = tempBuffer; + st.equal(result, 'a=b&c=d'); + st.end(); + }); + + t.test('selects properties when filter=array', function (st) { + st.equal(qs.stringify({ a: 'b' }, { filter: ['a'] }), 'a=b'); + st.equal(qs.stringify({ a: 1 }, { filter: [] }), ''); + st.equal(qs.stringify({ a: { b: [1, 2, 3, 4], c: 'd' }, c: 'f' }, { filter: ['a', 'b', 0, 2] }), 'a%5Bb%5D%5B0%5D=1&a%5Bb%5D%5B2%5D=3'); + st.end(); + }); + + t.test('supports custom representations when filter=function', function (st) { + var calls = 0; + var obj = { a: 'b', c: 'd', e: { f: new Date(1257894000000) } }; + var filterFunc = function (prefix, value) { + calls++; + if (calls === 1) { + st.equal(prefix, '', 'prefix is empty'); + st.equal(value, obj); + } else if (prefix === 'c') { + return; + } else if (value instanceof Date) { + st.equal(prefix, 'e[f]'); + return value.getTime(); + } + return value; + }; + + st.equal(qs.stringify(obj, { filter: filterFunc }), 'a=b&e%5Bf%5D=1257894000000'); + st.equal(calls, 5); + st.end(); + }); + + t.test('can disable uri encoding', function (st) { + st.equal(qs.stringify({ a: 'b' }, { encode: false }), 'a=b'); + st.equal(qs.stringify({ a: { b: 'c' } }, { encode: false }), 'a[b]=c'); + st.equal(qs.stringify({ a: 'b', c: null }, { strictNullHandling: true, encode: false }), 'a=b&c'); + st.end(); + }); + + t.test('can sort the keys', function (st) { + var sort = function (a, b) { return a.localeCompare(b); }; + st.equal(qs.stringify({ a: 'c', z: 'y', b: 'f' }, { sort: sort }), 'a=c&b=f&z=y'); + st.equal(qs.stringify({ a: 'c', z: { j: 'a', i: 'b' }, b: 'f' }, { sort: sort }), 'a=c&b=f&z%5Bi%5D=b&z%5Bj%5D=a'); + st.end(); + }); + + t.test('can sort the keys at depth 3 or more too', function (st) { + var sort = function (a, b) { return a.localeCompare(b); }; + st.equal(qs.stringify({ a: 'a', z: { zj: {zjb: 'zjb', zja: 'zja'}, zi: {zib: 'zib', zia: 'zia'} }, b: 'b' }, { sort: sort, encode: false }), 'a=a&b=b&z[zi][zia]=zia&z[zi][zib]=zib&z[zj][zja]=zja&z[zj][zjb]=zjb'); + st.equal(qs.stringify({ a: 'a', z: { zj: {zjb: 'zjb', zja: 'zja'}, zi: {zib: 'zib', zia: 'zia'} }, b: 'b' }, { sort: null, encode: false }), 'a=a&z[zj][zjb]=zjb&z[zj][zja]=zja&z[zi][zib]=zib&z[zi][zia]=zia&b=b'); + st.end(); + }); + + t.test('can stringify with custom encoding', function (st) { + st.equal(qs.stringify({ 県: '大阪府', '': ''}, { + encoder: function (str) { + if (str.length === 0) { + return ''; + } + var buf = iconv.encode(str, 'shiftjis'); + var result = []; + for (var i=0; i < buf.length; ++i) { + result.push(buf.readUInt8(i).toString(16)); + } + return '%' + result.join('%'); + } + }), '%8c%a7=%91%e5%8d%e3%95%7b&='); + st.end(); + }); + + t.test('throws error with wrong encoder', function (st) { + st.throws(function () { + qs.stringify({}, { + encoder: 'string' + }); + }, new TypeError('Encoder has to be a function.')); + st.end(); + }); + + t.test('can use custom encoder for a buffer object', { + skip: typeof Buffer === 'undefined' + }, function (st) { + st.equal(qs.stringify({ a: new Buffer([1]) }, { + encoder: function (buffer) { + if (typeof buffer === 'string') { + return buffer; + } + return String.fromCharCode(buffer.readUInt8(0) + 97); + } + }), 'a=b'); + st.end(); + }); +}); diff --git a/ui/node_modules/express/node_modules/qs/test/utils.js b/ui/node_modules/express/node_modules/qs/test/utils.js old mode 100755 new mode 100644 index d19d962d..4a8d8246 --- a/ui/node_modules/express/node_modules/qs/test/utils.js +++ b/ui/node_modules/express/node_modules/qs/test/utils.js @@ -1,9 +1,9 @@ -'use strict'; - -var test = require('tape'); -var utils = require('../lib/utils'); - -test('merge()', function (t) { - t.deepEqual(utils.merge({ a: 'b' }, { a: 'c' }), { a: ['b', 'c'] }, 'merges two objects with the same key'); - t.end(); -}); +'use strict'; + +var test = require('tape'); +var utils = require('../lib/utils'); + +test('merge()', function (t) { + t.deepEqual(utils.merge({ a: 'b' }, { a: 'c' }), { a: ['b', 'c'] }, 'merges two objects with the same key'); + t.end(); +}); diff --git a/ui/node_modules/express/node_modules/range-parser/HISTORY.md b/ui/node_modules/express/node_modules/range-parser/HISTORY.md index 8f2ac658..5e01eef4 100644 --- a/ui/node_modules/express/node_modules/range-parser/HISTORY.md +++ b/ui/node_modules/express/node_modules/range-parser/HISTORY.md @@ -1,51 +1,51 @@ -1.2.0 / 2016-06-01 -================== - - * Add `combine` option to combine overlapping ranges - -1.1.0 / 2016-05-13 -================== - - * Fix incorrectly returning -1 when there is at least one valid range - * perf: remove internal function - -1.0.3 / 2015-10-29 -================== - - * perf: enable strict mode - -1.0.2 / 2014-09-08 -================== - - * Support Node.js 0.6 - -1.0.1 / 2014-09-07 -================== - - * Move repository to jshttp - -1.0.0 / 2013-12-11 -================== - - * Add repository to package.json - * Add MIT license - -0.0.4 / 2012-06-17 -================== - - * Change ret -1 for unsatisfiable and -2 when invalid - -0.0.3 / 2012-06-17 -================== - - * Fix last-byte-pos default to len - 1 - -0.0.2 / 2012-06-14 -================== - - * Add `.type` - -0.0.1 / 2012-06-11 -================== - - * Initial release +1.2.0 / 2016-06-01 +================== + + * Add `combine` option to combine overlapping ranges + +1.1.0 / 2016-05-13 +================== + + * Fix incorrectly returning -1 when there is at least one valid range + * perf: remove internal function + +1.0.3 / 2015-10-29 +================== + + * perf: enable strict mode + +1.0.2 / 2014-09-08 +================== + + * Support Node.js 0.6 + +1.0.1 / 2014-09-07 +================== + + * Move repository to jshttp + +1.0.0 / 2013-12-11 +================== + + * Add repository to package.json + * Add MIT license + +0.0.4 / 2012-06-17 +================== + + * Change ret -1 for unsatisfiable and -2 when invalid + +0.0.3 / 2012-06-17 +================== + + * Fix last-byte-pos default to len - 1 + +0.0.2 / 2012-06-14 +================== + + * Add `.type` + +0.0.1 / 2012-06-11 +================== + + * Initial release diff --git a/ui/node_modules/express/node_modules/range-parser/LICENSE b/ui/node_modules/express/node_modules/range-parser/LICENSE index 0043e303..35999543 100644 --- a/ui/node_modules/express/node_modules/range-parser/LICENSE +++ b/ui/node_modules/express/node_modules/range-parser/LICENSE @@ -1,23 +1,23 @@ -(The MIT License) - -Copyright (c) 2012-2014 TJ Holowaychuk -Copyright (c) 2015-2016 Douglas Christopher Wilson +Copyright (c) 2015-2016 Douglas Christopher Wilson [ -// { start: 0, end: 10 }, -// { start: 50, end: 60 } -// ] -``` - -## License - -[MIT](LICENSE) - -[npm-image]: https://img.shields.io/npm/v/range-parser.svg -[npm-url]: https://npmjs.org/package/range-parser -[node-version-image]: https://img.shields.io/node/v/range-parser.svg -[node-version-url]: https://nodejs.org/endownload -[travis-image]: https://img.shields.io/travis/jshttp/range-parser.svg -[travis-url]: https://travis-ci.org/jshttp/range-parser -[coveralls-image]: https://img.shields.io/coveralls/jshttp/range-parser.svg -[coveralls-url]: https://coveralls.io/r/jshttp/range-parser -[downloads-image]: https://img.shields.io/npm/dm/range-parser.svg -[downloads-url]: https://npmjs.org/package/range-parser +# range-parser + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-version-image]][node-version-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +Range header field parser. + +## Installation + +``` +$ npm install range-parser +``` + +## API + +```js +var parseRange = require('range-parser') +``` + +### parseRange(size, header, options) + +Parse the given `header` string where `size` is the maximum size of the resource. +An array of ranges will be returned or negative numbers indicating an error parsing. + + * `-2` signals a malformed header string + * `-1` signals an unsatisfiable range + +```js +// parse header from request +var range = parseRange(size, req.headers.range) + +// the type of the range +if (range.type === 'bytes') { + // the ranges + range.forEach(function (r) { + // do something with r.start and r.end + }) +} +``` + +#### Options + +These properties are accepted in the options object. + +##### combine + +Specifies if overlapping & adjacent ranges should be combined, defaults to `false`. +When `true`, ranges will be combined and returned as if they were specified that +way in the header. + +```js +parseRange(100, 'bytes=50-55,0-10,5-10,56-60', { combine: true }) +// => [ +// { start: 0, end: 10 }, +// { start: 50, end: 60 } +// ] +``` + +## License + +[MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/range-parser.svg +[npm-url]: https://npmjs.org/package/range-parser +[node-version-image]: https://img.shields.io/node/v/range-parser.svg +[node-version-url]: https://nodejs.org/endownload +[travis-image]: https://img.shields.io/travis/jshttp/range-parser.svg +[travis-url]: https://travis-ci.org/jshttp/range-parser +[coveralls-image]: https://img.shields.io/coveralls/jshttp/range-parser.svg +[coveralls-url]: https://coveralls.io/r/jshttp/range-parser +[downloads-image]: https://img.shields.io/npm/dm/range-parser.svg +[downloads-url]: https://npmjs.org/package/range-parser diff --git a/ui/node_modules/express/node_modules/range-parser/index.js b/ui/node_modules/express/node_modules/range-parser/index.js index fb317f80..83b2eb6b 100644 --- a/ui/node_modules/express/node_modules/range-parser/index.js +++ b/ui/node_modules/express/node_modules/range-parser/index.js @@ -1,158 +1,158 @@ -/*! - * range-parser - * Copyright(c) 2012-2014 TJ Holowaychuk - * Copyright(c) 2015-2016 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict' - -/** - * Module exports. - * @public - */ - -module.exports = rangeParser - -/** - * Parse "Range" header `str` relative to the given file `size`. - * - * @param {Number} size - * @param {String} str - * @param {Object} [options] - * @return {Array} - * @public - */ - -function rangeParser (size, str, options) { - var index = str.indexOf('=') - - if (index === -1) { - return -2 - } - - // split the range string - var arr = str.slice(index + 1).split(',') - var ranges = [] - - // add ranges type - ranges.type = str.slice(0, index) - - // parse all ranges - for (var i = 0; i < arr.length; i++) { - var range = arr[i].split('-') - var start = parseInt(range[0], 10) - var end = parseInt(range[1], 10) - - // -nnn - if (isNaN(start)) { - start = size - end - end = size - 1 - // nnn- - } else if (isNaN(end)) { - end = size - 1 - } - - // limit last-byte-pos to current length - if (end > size - 1) { - end = size - 1 - } - - // invalid or unsatisifiable - if (isNaN(start) || isNaN(end) || start > end || start < 0) { - continue - } - - // add range - ranges.push({ - start: start, - end: end - }) - } - - if (ranges.length < 1) { - // unsatisifiable - return -1 - } - - return options && options.combine - ? combineRanges(ranges) - : ranges -} - -/** - * Combine overlapping & adjacent ranges. - * @private - */ - -function combineRanges (ranges) { - var ordered = ranges.map(mapWithIndex).sort(sortByRangeStart) - - for (var j = 0, i = 1; i < ordered.length; i++) { - var range = ordered[i] - var current = ordered[j] - - if (range.start > current.end + 1) { - // next range - ordered[++j] = range - } else if (range.end > current.end) { - // extend range - current.end = range.end - current.index = Math.min(current.index, range.index) - } - } - - // trim ordered array - ordered.length = j + 1 - - // generate combined range - var combined = ordered.sort(sortByRangeIndex).map(mapWithoutIndex) - - // copy ranges type - combined.type = ranges.type - - return combined -} - -/** - * Map function to add index value to ranges. - * @private - */ - -function mapWithIndex (range, index) { - return { - start: range.start, - end: range.end, - index: index - } -} - -/** - * Map function to remove index value from ranges. - * @private - */ - -function mapWithoutIndex (range) { - return { - start: range.start, - end: range.end - } -} - -/** - * Sort function to sort ranges by index. - * @private - */ - -function sortByRangeIndex (a, b) { - return a.index - b.index -} - -/** - * Sort function to sort ranges by start position. - * @private - */ - -function sortByRangeStart (a, b) { - return a.start - b.start -} +/*! + * range-parser + * Copyright(c) 2012-2014 TJ Holowaychuk + * Copyright(c) 2015-2016 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module exports. + * @public + */ + +module.exports = rangeParser + +/** + * Parse "Range" header `str` relative to the given file `size`. + * + * @param {Number} size + * @param {String} str + * @param {Object} [options] + * @return {Array} + * @public + */ + +function rangeParser (size, str, options) { + var index = str.indexOf('=') + + if (index === -1) { + return -2 + } + + // split the range string + var arr = str.slice(index + 1).split(',') + var ranges = [] + + // add ranges type + ranges.type = str.slice(0, index) + + // parse all ranges + for (var i = 0; i < arr.length; i++) { + var range = arr[i].split('-') + var start = parseInt(range[0], 10) + var end = parseInt(range[1], 10) + + // -nnn + if (isNaN(start)) { + start = size - end + end = size - 1 + // nnn- + } else if (isNaN(end)) { + end = size - 1 + } + + // limit last-byte-pos to current length + if (end > size - 1) { + end = size - 1 + } + + // invalid or unsatisifiable + if (isNaN(start) || isNaN(end) || start > end || start < 0) { + continue + } + + // add range + ranges.push({ + start: start, + end: end + }) + } + + if (ranges.length < 1) { + // unsatisifiable + return -1 + } + + return options && options.combine + ? combineRanges(ranges) + : ranges +} + +/** + * Combine overlapping & adjacent ranges. + * @private + */ + +function combineRanges (ranges) { + var ordered = ranges.map(mapWithIndex).sort(sortByRangeStart) + + for (var j = 0, i = 1; i < ordered.length; i++) { + var range = ordered[i] + var current = ordered[j] + + if (range.start > current.end + 1) { + // next range + ordered[++j] = range + } else if (range.end > current.end) { + // extend range + current.end = range.end + current.index = Math.min(current.index, range.index) + } + } + + // trim ordered array + ordered.length = j + 1 + + // generate combined range + var combined = ordered.sort(sortByRangeIndex).map(mapWithoutIndex) + + // copy ranges type + combined.type = ranges.type + + return combined +} + +/** + * Map function to add index value to ranges. + * @private + */ + +function mapWithIndex (range, index) { + return { + start: range.start, + end: range.end, + index: index + } +} + +/** + * Map function to remove index value from ranges. + * @private + */ + +function mapWithoutIndex (range) { + return { + start: range.start, + end: range.end + } +} + +/** + * Sort function to sort ranges by index. + * @private + */ + +function sortByRangeIndex (a, b) { + return a.index - b.index +} + +/** + * Sort function to sort ranges by start position. + * @private + */ + +function sortByRangeStart (a, b) { + return a.start - b.start +} diff --git a/ui/node_modules/express/node_modules/range-parser/package.json b/ui/node_modules/express/node_modules/range-parser/package.json index a9384350..060a5cfb 100644 --- a/ui/node_modules/express/node_modules/range-parser/package.json +++ b/ui/node_modules/express/node_modules/range-parser/package.json @@ -1,99 +1,99 @@ -{ - "name": "range-parser", - "author": { - "name": "TJ Holowaychuk", - "email": "tj@vision-media.ca", - "url": "http://tjholowaychuk.com" - }, - "description": "Range header field string parser", - "version": "1.2.0", - "contributors": [ - { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "James Wyatt Cready", - "email": "wyatt.cready@lanetix.com" - }, - { - "name": "Jonathan Ong", - "email": "me@jongleberry.com", - "url": "http://jongleberry.com" - } - ], - "license": "MIT", - "keywords": [ - "range", - "parser", - "http" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/range-parser.git" - }, - "devDependencies": { - "eslint": "2.11.1", - "eslint-config-standard": "5.3.1", - "eslint-plugin-promise": "1.1.0", - "eslint-plugin-standard": "1.3.2", - "istanbul": "0.4.3", - "mocha": "1.21.5" - }, - "files": [ - "HISTORY.md", - "LICENSE", - "index.js" - ], - "engines": { - "node": ">= 0.6" - }, - "scripts": { - "lint": "eslint **/*.js", - "test": "mocha --reporter spec", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot" - }, - "gitHead": "0665aca31639d799dee1d35fb10970799559ec48", - "bugs": { - "url": "https://github.com/jshttp/range-parser/issues" - }, - "homepage": "https://github.com/jshttp/range-parser", - "_id": "range-parser@1.2.0", - "_shasum": "f49be6b487894ddc40dcc94a322f611092e00d5e", - "_from": "range-parser@>=1.2.0 <1.3.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "jonathanong", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - } - ], - "dist": { - "shasum": "f49be6b487894ddc40dcc94a322f611092e00d5e", - "tarball": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz" - }, - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/range-parser-1.2.0.tgz_1464803293097_0.6830497414339334" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "range-parser", + "author": { + "name": "TJ Holowaychuk", + "email": "tj@vision-media.ca", + "url": "http://tjholowaychuk.com" + }, + "description": "Range header field string parser", + "version": "1.2.0", + "contributors": [ + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "James Wyatt Cready", + "email": "wyatt.cready@lanetix.com" + }, + { + "name": "Jonathan Ong", + "email": "me@jongleberry.com", + "url": "http://jongleberry.com" + } + ], + "license": "MIT", + "keywords": [ + "range", + "parser", + "http" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/range-parser.git" + }, + "devDependencies": { + "eslint": "2.11.1", + "eslint-config-standard": "5.3.1", + "eslint-plugin-promise": "1.1.0", + "eslint-plugin-standard": "1.3.2", + "istanbul": "0.4.3", + "mocha": "1.21.5" + }, + "files": [ + "HISTORY.md", + "LICENSE", + "index.js" + ], + "engines": { + "node": ">= 0.6" + }, + "scripts": { + "lint": "eslint **/*.js", + "test": "mocha --reporter spec", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot" + }, + "gitHead": "0665aca31639d799dee1d35fb10970799559ec48", + "bugs": { + "url": "https://github.com/jshttp/range-parser/issues" + }, + "homepage": "https://github.com/jshttp/range-parser", + "_id": "range-parser@1.2.0", + "_shasum": "f49be6b487894ddc40dcc94a322f611092e00d5e", + "_from": "range-parser@>=1.2.0 <1.3.0", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "maintainers": [ + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "jonathanong", + "email": "jonathanrichardong@gmail.com" + }, + { + "name": "jongleberry", + "email": "jonathanrichardong@gmail.com" + }, + { + "name": "tjholowaychuk", + "email": "tj@vision-media.ca" + } + ], + "dist": { + "shasum": "f49be6b487894ddc40dcc94a322f611092e00d5e", + "tarball": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz" + }, + "_npmOperationalInternal": { + "host": "packages-16-east.internal.npmjs.com", + "tmp": "tmp/range-parser-1.2.0.tgz_1464803293097_0.6830497414339334" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/send/HISTORY.md b/ui/node_modules/express/node_modules/send/HISTORY.md index 6e83a007..f30e3453 100644 --- a/ui/node_modules/express/node_modules/send/HISTORY.md +++ b/ui/node_modules/express/node_modules/send/HISTORY.md @@ -1,346 +1,346 @@ -0.14.1 / 2016-06-09 -=================== - - * Fix redirect error when `path` contains raw non-URL characters - * Fix redirect when `path` starts with multiple forward slashes - -0.14.0 / 2016-06-06 -=================== - - * Add `acceptRanges` option - * Add `cacheControl` option - * Attempt to combine multiple ranges into single range - * Correctly inherit from `Stream` class - * Fix `Content-Range` header in 416 responses when using `start`/`end` options - * Fix `Content-Range` header missing from default 416 responses - * Ignore non-byte `Range` headers - * deps: http-errors@~1.5.0 - - Add `HttpError` export, for `err instanceof createError.HttpError` - - Support new code `421 Misdirected Request` - - Use `setprototypeof` module to replace `__proto__` setting - - deps: inherits@2.0.1 - - deps: statuses@'>= 1.3.0 < 2' - - perf: enable strict mode - * deps: range-parser@~1.2.0 - - Fix incorrectly returning -1 when there is at least one valid range - - perf: remove internal function - * deps: statuses@~1.3.0 - - Add `421 Misdirected Request` - - perf: enable strict mode - * perf: remove argument reassignment - -0.13.2 / 2016-03-05 -=================== - - * Fix invalid `Content-Type` header when `send.mime.default_type` unset - -0.13.1 / 2016-01-16 -=================== - - * deps: depd@~1.1.0 - - Support web browser loading - - perf: enable strict mode - * deps: destroy@~1.0.4 - - perf: enable strict mode - * deps: escape-html@~1.0.3 - - perf: enable strict mode - - perf: optimize string replacement - - perf: use faster string coercion - * deps: range-parser@~1.0.3 - - perf: enable strict mode - -0.13.0 / 2015-06-16 -=================== - - * Allow Node.js HTTP server to set `Date` response header - * Fix incorrectly removing `Content-Location` on 304 response - * Improve the default redirect response headers - * Send appropriate headers on default error response - * Use `http-errors` for standard emitted errors - * Use `statuses` instead of `http` module for status messages - * deps: escape-html@1.0.2 - * deps: etag@~1.7.0 - - Improve stat performance by removing hashing - * deps: fresh@0.3.0 - - Add weak `ETag` matching support - * deps: on-finished@~2.3.0 - - Add defined behavior for HTTP `CONNECT` requests - - Add defined behavior for HTTP `Upgrade` requests - - deps: ee-first@1.1.1 - * perf: enable strict mode - * perf: remove unnecessary array allocations - -0.12.3 / 2015-05-13 -=================== - - * deps: debug@~2.2.0 - - deps: ms@0.7.1 - * deps: depd@~1.0.1 - * deps: etag@~1.6.0 - - Improve support for JXcore - - Support "fake" stats objects in environments without `fs` - * deps: ms@0.7.1 - - Prevent extraordinarily long inputs - * deps: on-finished@~2.2.1 - -0.12.2 / 2015-03-13 -=================== - - * Throw errors early for invalid `extensions` or `index` options - * deps: debug@~2.1.3 - - Fix high intensity foreground color for bold - - deps: ms@0.7.0 - -0.12.1 / 2015-02-17 -=================== - - * Fix regression sending zero-length files - -0.12.0 / 2015-02-16 -=================== - - * Always read the stat size from the file - * Fix mutating passed-in `options` - * deps: mime@1.3.4 - -0.11.1 / 2015-01-20 -=================== - - * Fix `root` path disclosure - -0.11.0 / 2015-01-05 -=================== - - * deps: debug@~2.1.1 - * deps: etag@~1.5.1 - - deps: crc@3.2.1 - * deps: ms@0.7.0 - - Add `milliseconds` - - Add `msecs` - - Add `secs` - - Add `mins` - - Add `hrs` - - Add `yrs` - * deps: on-finished@~2.2.0 - -0.10.1 / 2014-10-22 -=================== - - * deps: on-finished@~2.1.1 - - Fix handling of pipelined requests - -0.10.0 / 2014-10-15 -=================== - - * deps: debug@~2.1.0 - - Implement `DEBUG_FD` env variable support - * deps: depd@~1.0.0 - * deps: etag@~1.5.0 - - Improve string performance - - Slightly improve speed for weak ETags over 1KB - -0.9.3 / 2014-09-24 -================== - - * deps: etag@~1.4.0 - - Support "fake" stats objects - -0.9.2 / 2014-09-15 -================== - - * deps: depd@0.4.5 - * deps: etag@~1.3.1 - * deps: range-parser@~1.0.2 - -0.9.1 / 2014-09-07 -================== - - * deps: fresh@0.2.4 - -0.9.0 / 2014-09-07 -================== - - * Add `lastModified` option - * Use `etag` to generate `ETag` header - * deps: debug@~2.0.0 - -0.8.5 / 2014-09-04 -================== - - * Fix malicious path detection for empty string path - -0.8.4 / 2014-09-04 -================== - - * Fix a path traversal issue when using `root` - -0.8.3 / 2014-08-16 -================== - - * deps: destroy@1.0.3 - - renamed from dethroy - * deps: on-finished@2.1.0 - -0.8.2 / 2014-08-14 -================== - - * Work around `fd` leak in Node.js 0.10 for `fs.ReadStream` - * deps: dethroy@1.0.2 - -0.8.1 / 2014-08-05 -================== - - * Fix `extensions` behavior when file already has extension - -0.8.0 / 2014-08-05 -================== - - * Add `extensions` option - -0.7.4 / 2014-08-04 -================== - - * Fix serving index files without root dir - -0.7.3 / 2014-07-29 -================== - - * Fix incorrect 403 on Windows and Node.js 0.11 - -0.7.2 / 2014-07-27 -================== - - * deps: depd@0.4.4 - - Work-around v8 generating empty stack traces - -0.7.1 / 2014-07-26 -================== - - * deps: depd@0.4.3 - - Fix exception when global `Error.stackTraceLimit` is too low - -0.7.0 / 2014-07-20 -================== - - * Deprecate `hidden` option; use `dotfiles` option - * Add `dotfiles` option - * deps: debug@1.0.4 - * deps: depd@0.4.2 - - Add `TRACE_DEPRECATION` environment variable - - Remove non-standard grey color from color output - - Support `--no-deprecation` argument - - Support `--trace-deprecation` argument - -0.6.0 / 2014-07-11 -================== - - * Deprecate `from` option; use `root` option - * Deprecate `send.etag()` -- use `etag` in `options` - * Deprecate `send.hidden()` -- use `hidden` in `options` - * Deprecate `send.index()` -- use `index` in `options` - * Deprecate `send.maxage()` -- use `maxAge` in `options` - * Deprecate `send.root()` -- use `root` in `options` - * Cap `maxAge` value to 1 year - * deps: debug@1.0.3 - - Add support for multiple wildcards in namespaces - -0.5.0 / 2014-06-28 -================== - - * Accept string for `maxAge` (converted by `ms`) - * Add `headers` event - * Include link in default redirect response - * Use `EventEmitter.listenerCount` to count listeners - -0.4.3 / 2014-06-11 -================== - - * Do not throw un-catchable error on file open race condition - * Use `escape-html` for HTML escaping - * deps: debug@1.0.2 - - fix some debugging output colors on node.js 0.8 - * deps: finished@1.2.2 - * deps: fresh@0.2.2 - -0.4.2 / 2014-06-09 -================== - - * fix "event emitter leak" warnings - * deps: debug@1.0.1 - * deps: finished@1.2.1 - -0.4.1 / 2014-06-02 -================== - - * Send `max-age` in `Cache-Control` in correct format - -0.4.0 / 2014-05-27 -================== - - * Calculate ETag with md5 for reduced collisions - * Fix wrong behavior when index file matches directory - * Ignore stream errors after request ends - - Goodbye `EBADF, read` - * Skip directories in index file search - * deps: debug@0.8.1 - -0.3.0 / 2014-04-24 -================== - - * Fix sending files with dots without root set - * Coerce option types - * Accept API options in options object - * Set etags to "weak" - * Include file path in etag - * Make "Can't set headers after they are sent." catchable - * Send full entity-body for multi range requests - * Default directory access to 403 when index disabled - * Support multiple index paths - * Support "If-Range" header - * Control whether to generate etags - * deps: mime@1.2.11 - -0.2.0 / 2014-01-29 -================== - - * update range-parser and fresh - -0.1.4 / 2013-08-11 -================== - - * update fresh - -0.1.3 / 2013-07-08 -================== - - * Revert "Fix fd leak" - -0.1.2 / 2013-07-03 -================== - - * Fix fd leak - -0.1.0 / 2012-08-25 -================== - - * add options parameter to send() that is passed to fs.createReadStream() [kanongil] - -0.0.4 / 2012-08-16 -================== - - * allow custom "Accept-Ranges" definition - -0.0.3 / 2012-07-16 -================== - - * fix normalization of the root directory. Closes #3 - -0.0.2 / 2012-07-09 -================== - - * add passing of req explicitly for now (YUCK) - -0.0.1 / 2010-01-03 -================== - - * Initial release +0.14.1 / 2016-06-09 +=================== + + * Fix redirect error when `path` contains raw non-URL characters + * Fix redirect when `path` starts with multiple forward slashes + +0.14.0 / 2016-06-06 +=================== + + * Add `acceptRanges` option + * Add `cacheControl` option + * Attempt to combine multiple ranges into single range + * Correctly inherit from `Stream` class + * Fix `Content-Range` header in 416 responses when using `start`/`end` options + * Fix `Content-Range` header missing from default 416 responses + * Ignore non-byte `Range` headers + * deps: http-errors@~1.5.0 + - Add `HttpError` export, for `err instanceof createError.HttpError` + - Support new code `421 Misdirected Request` + - Use `setprototypeof` module to replace `__proto__` setting + - deps: inherits@2.0.1 + - deps: statuses@'>= 1.3.0 < 2' + - perf: enable strict mode + * deps: range-parser@~1.2.0 + - Fix incorrectly returning -1 when there is at least one valid range + - perf: remove internal function + * deps: statuses@~1.3.0 + - Add `421 Misdirected Request` + - perf: enable strict mode + * perf: remove argument reassignment + +0.13.2 / 2016-03-05 +=================== + + * Fix invalid `Content-Type` header when `send.mime.default_type` unset + +0.13.1 / 2016-01-16 +=================== + + * deps: depd@~1.1.0 + - Support web browser loading + - perf: enable strict mode + * deps: destroy@~1.0.4 + - perf: enable strict mode + * deps: escape-html@~1.0.3 + - perf: enable strict mode + - perf: optimize string replacement + - perf: use faster string coercion + * deps: range-parser@~1.0.3 + - perf: enable strict mode + +0.13.0 / 2015-06-16 +=================== + + * Allow Node.js HTTP server to set `Date` response header + * Fix incorrectly removing `Content-Location` on 304 response + * Improve the default redirect response headers + * Send appropriate headers on default error response + * Use `http-errors` for standard emitted errors + * Use `statuses` instead of `http` module for status messages + * deps: escape-html@1.0.2 + * deps: etag@~1.7.0 + - Improve stat performance by removing hashing + * deps: fresh@0.3.0 + - Add weak `ETag` matching support + * deps: on-finished@~2.3.0 + - Add defined behavior for HTTP `CONNECT` requests + - Add defined behavior for HTTP `Upgrade` requests + - deps: ee-first@1.1.1 + * perf: enable strict mode + * perf: remove unnecessary array allocations + +0.12.3 / 2015-05-13 +=================== + + * deps: debug@~2.2.0 + - deps: ms@0.7.1 + * deps: depd@~1.0.1 + * deps: etag@~1.6.0 + - Improve support for JXcore + - Support "fake" stats objects in environments without `fs` + * deps: ms@0.7.1 + - Prevent extraordinarily long inputs + * deps: on-finished@~2.2.1 + +0.12.2 / 2015-03-13 +=================== + + * Throw errors early for invalid `extensions` or `index` options + * deps: debug@~2.1.3 + - Fix high intensity foreground color for bold + - deps: ms@0.7.0 + +0.12.1 / 2015-02-17 +=================== + + * Fix regression sending zero-length files + +0.12.0 / 2015-02-16 +=================== + + * Always read the stat size from the file + * Fix mutating passed-in `options` + * deps: mime@1.3.4 + +0.11.1 / 2015-01-20 +=================== + + * Fix `root` path disclosure + +0.11.0 / 2015-01-05 +=================== + + * deps: debug@~2.1.1 + * deps: etag@~1.5.1 + - deps: crc@3.2.1 + * deps: ms@0.7.0 + - Add `milliseconds` + - Add `msecs` + - Add `secs` + - Add `mins` + - Add `hrs` + - Add `yrs` + * deps: on-finished@~2.2.0 + +0.10.1 / 2014-10-22 +=================== + + * deps: on-finished@~2.1.1 + - Fix handling of pipelined requests + +0.10.0 / 2014-10-15 +=================== + + * deps: debug@~2.1.0 + - Implement `DEBUG_FD` env variable support + * deps: depd@~1.0.0 + * deps: etag@~1.5.0 + - Improve string performance + - Slightly improve speed for weak ETags over 1KB + +0.9.3 / 2014-09-24 +================== + + * deps: etag@~1.4.0 + - Support "fake" stats objects + +0.9.2 / 2014-09-15 +================== + + * deps: depd@0.4.5 + * deps: etag@~1.3.1 + * deps: range-parser@~1.0.2 + +0.9.1 / 2014-09-07 +================== + + * deps: fresh@0.2.4 + +0.9.0 / 2014-09-07 +================== + + * Add `lastModified` option + * Use `etag` to generate `ETag` header + * deps: debug@~2.0.0 + +0.8.5 / 2014-09-04 +================== + + * Fix malicious path detection for empty string path + +0.8.4 / 2014-09-04 +================== + + * Fix a path traversal issue when using `root` + +0.8.3 / 2014-08-16 +================== + + * deps: destroy@1.0.3 + - renamed from dethroy + * deps: on-finished@2.1.0 + +0.8.2 / 2014-08-14 +================== + + * Work around `fd` leak in Node.js 0.10 for `fs.ReadStream` + * deps: dethroy@1.0.2 + +0.8.1 / 2014-08-05 +================== + + * Fix `extensions` behavior when file already has extension + +0.8.0 / 2014-08-05 +================== + + * Add `extensions` option + +0.7.4 / 2014-08-04 +================== + + * Fix serving index files without root dir + +0.7.3 / 2014-07-29 +================== + + * Fix incorrect 403 on Windows and Node.js 0.11 + +0.7.2 / 2014-07-27 +================== + + * deps: depd@0.4.4 + - Work-around v8 generating empty stack traces + +0.7.1 / 2014-07-26 +================== + + * deps: depd@0.4.3 + - Fix exception when global `Error.stackTraceLimit` is too low + +0.7.0 / 2014-07-20 +================== + + * Deprecate `hidden` option; use `dotfiles` option + * Add `dotfiles` option + * deps: debug@1.0.4 + * deps: depd@0.4.2 + - Add `TRACE_DEPRECATION` environment variable + - Remove non-standard grey color from color output + - Support `--no-deprecation` argument + - Support `--trace-deprecation` argument + +0.6.0 / 2014-07-11 +================== + + * Deprecate `from` option; use `root` option + * Deprecate `send.etag()` -- use `etag` in `options` + * Deprecate `send.hidden()` -- use `hidden` in `options` + * Deprecate `send.index()` -- use `index` in `options` + * Deprecate `send.maxage()` -- use `maxAge` in `options` + * Deprecate `send.root()` -- use `root` in `options` + * Cap `maxAge` value to 1 year + * deps: debug@1.0.3 + - Add support for multiple wildcards in namespaces + +0.5.0 / 2014-06-28 +================== + + * Accept string for `maxAge` (converted by `ms`) + * Add `headers` event + * Include link in default redirect response + * Use `EventEmitter.listenerCount` to count listeners + +0.4.3 / 2014-06-11 +================== + + * Do not throw un-catchable error on file open race condition + * Use `escape-html` for HTML escaping + * deps: debug@1.0.2 + - fix some debugging output colors on node.js 0.8 + * deps: finished@1.2.2 + * deps: fresh@0.2.2 + +0.4.2 / 2014-06-09 +================== + + * fix "event emitter leak" warnings + * deps: debug@1.0.1 + * deps: finished@1.2.1 + +0.4.1 / 2014-06-02 +================== + + * Send `max-age` in `Cache-Control` in correct format + +0.4.0 / 2014-05-27 +================== + + * Calculate ETag with md5 for reduced collisions + * Fix wrong behavior when index file matches directory + * Ignore stream errors after request ends + - Goodbye `EBADF, read` + * Skip directories in index file search + * deps: debug@0.8.1 + +0.3.0 / 2014-04-24 +================== + + * Fix sending files with dots without root set + * Coerce option types + * Accept API options in options object + * Set etags to "weak" + * Include file path in etag + * Make "Can't set headers after they are sent." catchable + * Send full entity-body for multi range requests + * Default directory access to 403 when index disabled + * Support multiple index paths + * Support "If-Range" header + * Control whether to generate etags + * deps: mime@1.2.11 + +0.2.0 / 2014-01-29 +================== + + * update range-parser and fresh + +0.1.4 / 2013-08-11 +================== + + * update fresh + +0.1.3 / 2013-07-08 +================== + + * Revert "Fix fd leak" + +0.1.2 / 2013-07-03 +================== + + * Fix fd leak + +0.1.0 / 2012-08-25 +================== + + * add options parameter to send() that is passed to fs.createReadStream() [kanongil] + +0.0.4 / 2012-08-16 +================== + + * allow custom "Accept-Ranges" definition + +0.0.3 / 2012-07-16 +================== + + * fix normalization of the root directory. Closes #3 + +0.0.2 / 2012-07-09 +================== + + * add passing of req explicitly for now (YUCK) + +0.0.1 / 2010-01-03 +================== + + * Initial release diff --git a/ui/node_modules/express/node_modules/send/LICENSE b/ui/node_modules/express/node_modules/send/LICENSE index fccbd86e..4aa69e83 100644 --- a/ui/node_modules/express/node_modules/send/LICENSE +++ b/ui/node_modules/express/node_modules/send/LICENSE @@ -1,23 +1,23 @@ -(The MIT License) - -Copyright (c) 2012 TJ Holowaychuk -Copyright (c) 2014-2016 Douglas Christopher Wilson - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2012 TJ Holowaychuk +Copyright (c) 2014-2016 Douglas Christopher Wilson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/send/README.md b/ui/node_modules/express/node_modules/send/README.md index df8bafec..4167926a 100644 --- a/ui/node_modules/express/node_modules/send/README.md +++ b/ui/node_modules/express/node_modules/send/README.md @@ -1,247 +1,247 @@ -# send - -[![NPM Version][npm-image]][npm-url] -[![NPM Downloads][downloads-image]][downloads-url] -[![Linux Build][travis-image]][travis-url] -[![Windows Build][appveyor-image]][appveyor-url] -[![Test Coverage][coveralls-image]][coveralls-url] -[![Gratipay][gratipay-image]][gratipay-url] - -Send is a library for streaming files from the file system as a http response -supporting partial responses (Ranges), conditional-GET negotiation, high test -coverage, and granular events which may be leveraged to take appropriate actions -in your application or framework. - -Looking to serve up entire folders mapped to URLs? Try [serve-static](https://www.npmjs.org/package/serve-static). - -## Installation - -```bash -$ npm install send -``` - -## API - -```js -var send = require('send') -``` - -### send(req, path, [options]) - -Create a new `SendStream` for the given path to send to a `res`. The `req` is -the Node.js HTTP request and the `path` is a urlencoded path to send (urlencoded, -not the actual file-system path). - -#### Options - -##### acceptRanges - -Enable or disable accepting ranged requests, defaults to true. -Disabling this will not send `Accept-Ranges` and ignore the contents -of the `Range` request header. - -##### cacheControl - -Enable or disable setting `Cache-Control` response header, defaults to -true. Disabling this will ignore the `maxAge` option. - -##### dotfiles - -Set how "dotfiles" are treated when encountered. A dotfile is a file -or directory that begins with a dot ("."). Note this check is done on -the path itself without checking if the path actually exists on the -disk. If `root` is specified, only the dotfiles above the root are -checked (i.e. the root itself can be within a dotfile when when set -to "deny"). - - - `'allow'` No special treatment for dotfiles. - - `'deny'` Send a 403 for any request for a dotfile. - - `'ignore'` Pretend like the dotfile does not exist and 404. - -The default value is _similar_ to `'ignore'`, with the exception that -this default will not ignore the files within a directory that begins -with a dot, for backward-compatibility. - -##### end - -Byte offset at which the stream ends, defaults to the length of the file -minus 1. The end is inclusive in the stream, meaning `end: 3` will include -the 4th byte in the stream. - -##### etag - -Enable or disable etag generation, defaults to true. - -##### extensions - -If a given file doesn't exist, try appending one of the given extensions, -in the given order. By default, this is disabled (set to `false`). An -example value that will serve extension-less HTML files: `['html', 'htm']`. -This is skipped if the requested file already has an extension. - -##### index - -By default send supports "index.html" files, to disable this -set `false` or to supply a new index pass a string or an array -in preferred order. - -##### lastModified - -Enable or disable `Last-Modified` header, defaults to true. Uses the file -system's last modified value. - -##### maxAge - -Provide a max-age in milliseconds for http caching, defaults to 0. -This can also be a string accepted by the -[ms](https://www.npmjs.org/package/ms#readme) module. - -##### root - -Serve files relative to `path`. - -##### start - -Byte offset at which the stream starts, defaults to 0. The start is inclusive, -meaning `start: 2` will include the 3rd byte in the stream. - -#### Events - -The `SendStream` is an event emitter and will emit the following events: - - - `error` an error occurred `(err)` - - `directory` a directory was requested - - `file` a file was requested `(path, stat)` - - `headers` the headers are about to be set on a file `(res, path, stat)` - - `stream` file streaming has started `(stream)` - - `end` streaming has completed - -#### .pipe - -The `pipe` method is used to pipe the response into the Node.js HTTP response -object, typically `send(req, path, options).pipe(res)`. - -### .mime - -The `mime` export is the global instance of of the -[`mime` npm module](https://www.npmjs.com/package/mime). - -This is used to configure the MIME types that are associated with file extensions -as well as other options for how to resolve the MIME type of a file (like the -default type to use for an unknown file extension). - -## Error-handling - -By default when no `error` listeners are present an automatic response will be -made, otherwise you have full control over the response, aka you may show a 5xx -page etc. - -## Caching - -It does _not_ perform internal caching, you should use a reverse proxy cache -such as Varnish for this, or those fancy things called CDNs. If your -application is small enough that it would benefit from single-node memory -caching, it's small enough that it does not need caching at all ;). - -## Debugging - -To enable `debug()` instrumentation output export __DEBUG__: - -``` -$ DEBUG=send node app -``` - -## Running tests - -``` -$ npm install -$ npm test -``` - -## Examples - -### Small example - -```js -var http = require('http') -var parseUrl = require('parseurl') -var send = require('send') - -var app = http.createServer(function onRequest (req, res) { - send(req, parseUrl(req).pathname).pipe(res) -}).listen(3000) -``` - -### Custom file types - -```js -var http = require('http') -var parseUrl = require('parseurl') -var send = require('send') - -// Default unknown types to text/plain -send.mime.default_type = 'text/plain' - -// Add a custom type -send.mime.define({ - 'application/x-my-type': ['x-mt', 'x-mtt'] -}) - -var app = http.createServer(function onRequest (req, res) { - send(req, parseUrl(req).pathname).pipe(res) -}).listen(3000) -``` - -### Serving from a root directory with custom error-handling - -```js -var http = require('http') -var parseUrl = require('parseurl') -var send = require('send') - -var app = http.createServer(function onRequest (req, res) { - // your custom error-handling logic: - function error (err) { - res.statusCode = err.status || 500 - res.end(err.message) - } - - // your custom headers - function headers (res, path, stat) { - // serve all files for download - res.setHeader('Content-Disposition', 'attachment') - } - - // your custom directory handling logic: - function redirect () { - res.statusCode = 301 - res.setHeader('Location', req.url + '/') - res.end('Redirecting to ' + req.url + '/') - } - - // transfer arbitrary files from within - // /www/example.com/public/* - send(req, parseUrl(req).pathname, {root: '/www/example.com/public'}) - .on('error', error) - .on('directory', redirect) - .on('headers', headers) - .pipe(res); -}).listen(3000) -``` - -## License - -[MIT](LICENSE) - -[npm-image]: https://img.shields.io/npm/v/send.svg -[npm-url]: https://npmjs.org/package/send -[travis-image]: https://img.shields.io/travis/pillarjs/send/master.svg?label=linux -[travis-url]: https://travis-ci.org/pillarjs/send -[appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/send/master.svg?label=windows -[appveyor-url]: https://ci.appveyor.com/project/dougwilson/send -[coveralls-image]: https://img.shields.io/coveralls/pillarjs/send/master.svg -[coveralls-url]: https://coveralls.io/r/pillarjs/send?branch=master -[downloads-image]: https://img.shields.io/npm/dm/send.svg -[downloads-url]: https://npmjs.org/package/send -[gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg -[gratipay-url]: https://www.gratipay.com/dougwilson/ +# send + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Linux Build][travis-image]][travis-url] +[![Windows Build][appveyor-image]][appveyor-url] +[![Test Coverage][coveralls-image]][coveralls-url] +[![Gratipay][gratipay-image]][gratipay-url] + +Send is a library for streaming files from the file system as a http response +supporting partial responses (Ranges), conditional-GET negotiation, high test +coverage, and granular events which may be leveraged to take appropriate actions +in your application or framework. + +Looking to serve up entire folders mapped to URLs? Try [serve-static](https://www.npmjs.org/package/serve-static). + +## Installation + +```bash +$ npm install send +``` + +## API + +```js +var send = require('send') +``` + +### send(req, path, [options]) + +Create a new `SendStream` for the given path to send to a `res`. The `req` is +the Node.js HTTP request and the `path` is a urlencoded path to send (urlencoded, +not the actual file-system path). + +#### Options + +##### acceptRanges + +Enable or disable accepting ranged requests, defaults to true. +Disabling this will not send `Accept-Ranges` and ignore the contents +of the `Range` request header. + +##### cacheControl + +Enable or disable setting `Cache-Control` response header, defaults to +true. Disabling this will ignore the `maxAge` option. + +##### dotfiles + +Set how "dotfiles" are treated when encountered. A dotfile is a file +or directory that begins with a dot ("."). Note this check is done on +the path itself without checking if the path actually exists on the +disk. If `root` is specified, only the dotfiles above the root are +checked (i.e. the root itself can be within a dotfile when when set +to "deny"). + + - `'allow'` No special treatment for dotfiles. + - `'deny'` Send a 403 for any request for a dotfile. + - `'ignore'` Pretend like the dotfile does not exist and 404. + +The default value is _similar_ to `'ignore'`, with the exception that +this default will not ignore the files within a directory that begins +with a dot, for backward-compatibility. + +##### end + +Byte offset at which the stream ends, defaults to the length of the file +minus 1. The end is inclusive in the stream, meaning `end: 3` will include +the 4th byte in the stream. + +##### etag + +Enable or disable etag generation, defaults to true. + +##### extensions + +If a given file doesn't exist, try appending one of the given extensions, +in the given order. By default, this is disabled (set to `false`). An +example value that will serve extension-less HTML files: `['html', 'htm']`. +This is skipped if the requested file already has an extension. + +##### index + +By default send supports "index.html" files, to disable this +set `false` or to supply a new index pass a string or an array +in preferred order. + +##### lastModified + +Enable or disable `Last-Modified` header, defaults to true. Uses the file +system's last modified value. + +##### maxAge + +Provide a max-age in milliseconds for http caching, defaults to 0. +This can also be a string accepted by the +[ms](https://www.npmjs.org/package/ms#readme) module. + +##### root + +Serve files relative to `path`. + +##### start + +Byte offset at which the stream starts, defaults to 0. The start is inclusive, +meaning `start: 2` will include the 3rd byte in the stream. + +#### Events + +The `SendStream` is an event emitter and will emit the following events: + + - `error` an error occurred `(err)` + - `directory` a directory was requested + - `file` a file was requested `(path, stat)` + - `headers` the headers are about to be set on a file `(res, path, stat)` + - `stream` file streaming has started `(stream)` + - `end` streaming has completed + +#### .pipe + +The `pipe` method is used to pipe the response into the Node.js HTTP response +object, typically `send(req, path, options).pipe(res)`. + +### .mime + +The `mime` export is the global instance of of the +[`mime` npm module](https://www.npmjs.com/package/mime). + +This is used to configure the MIME types that are associated with file extensions +as well as other options for how to resolve the MIME type of a file (like the +default type to use for an unknown file extension). + +## Error-handling + +By default when no `error` listeners are present an automatic response will be +made, otherwise you have full control over the response, aka you may show a 5xx +page etc. + +## Caching + +It does _not_ perform internal caching, you should use a reverse proxy cache +such as Varnish for this, or those fancy things called CDNs. If your +application is small enough that it would benefit from single-node memory +caching, it's small enough that it does not need caching at all ;). + +## Debugging + +To enable `debug()` instrumentation output export __DEBUG__: + +``` +$ DEBUG=send node app +``` + +## Running tests + +``` +$ npm install +$ npm test +``` + +## Examples + +### Small example + +```js +var http = require('http') +var parseUrl = require('parseurl') +var send = require('send') + +var app = http.createServer(function onRequest (req, res) { + send(req, parseUrl(req).pathname).pipe(res) +}).listen(3000) +``` + +### Custom file types + +```js +var http = require('http') +var parseUrl = require('parseurl') +var send = require('send') + +// Default unknown types to text/plain +send.mime.default_type = 'text/plain' + +// Add a custom type +send.mime.define({ + 'application/x-my-type': ['x-mt', 'x-mtt'] +}) + +var app = http.createServer(function onRequest (req, res) { + send(req, parseUrl(req).pathname).pipe(res) +}).listen(3000) +``` + +### Serving from a root directory with custom error-handling + +```js +var http = require('http') +var parseUrl = require('parseurl') +var send = require('send') + +var app = http.createServer(function onRequest (req, res) { + // your custom error-handling logic: + function error (err) { + res.statusCode = err.status || 500 + res.end(err.message) + } + + // your custom headers + function headers (res, path, stat) { + // serve all files for download + res.setHeader('Content-Disposition', 'attachment') + } + + // your custom directory handling logic: + function redirect () { + res.statusCode = 301 + res.setHeader('Location', req.url + '/') + res.end('Redirecting to ' + req.url + '/') + } + + // transfer arbitrary files from within + // /www/example.com/public/* + send(req, parseUrl(req).pathname, {root: '/www/example.com/public'}) + .on('error', error) + .on('directory', redirect) + .on('headers', headers) + .pipe(res); +}).listen(3000) +``` + +## License + +[MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/send.svg +[npm-url]: https://npmjs.org/package/send +[travis-image]: https://img.shields.io/travis/pillarjs/send/master.svg?label=linux +[travis-url]: https://travis-ci.org/pillarjs/send +[appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/send/master.svg?label=windows +[appveyor-url]: https://ci.appveyor.com/project/dougwilson/send +[coveralls-image]: https://img.shields.io/coveralls/pillarjs/send/master.svg +[coveralls-url]: https://coveralls.io/r/pillarjs/send?branch=master +[downloads-image]: https://img.shields.io/npm/dm/send.svg +[downloads-url]: https://npmjs.org/package/send +[gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg +[gratipay-url]: https://www.gratipay.com/dougwilson/ diff --git a/ui/node_modules/express/node_modules/send/index.js b/ui/node_modules/express/node_modules/send/index.js index 795842b4..81ec0b3f 100644 --- a/ui/node_modules/express/node_modules/send/index.js +++ b/ui/node_modules/express/node_modules/send/index.js @@ -1,948 +1,948 @@ -/*! - * send - * Copyright(c) 2012 TJ Holowaychuk - * Copyright(c) 2014-2016 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict' - -/** - * Module dependencies. - * @private - */ - -var createError = require('http-errors') -var debug = require('debug')('send') -var deprecate = require('depd')('send') -var destroy = require('destroy') -var encodeUrl = require('encodeurl') -var escapeHtml = require('escape-html') -var etag = require('etag') -var EventEmitter = require('events').EventEmitter -var fresh = require('fresh') -var fs = require('fs') -var mime = require('mime') -var ms = require('ms') -var onFinished = require('on-finished') -var parseRange = require('range-parser') -var path = require('path') -var statuses = require('statuses') -var Stream = require('stream') -var util = require('util') - -/** - * Path function references. - * @private - */ - -var extname = path.extname -var join = path.join -var normalize = path.normalize -var resolve = path.resolve -var sep = path.sep - -/** - * Regular expression for identifying a bytes Range header. - * @private - */ - -var BYTES_RANGE_REGEXP = /^ *bytes=/ - -/** - * Maximum value allowed for the max age. - * @private - */ - -var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1000 // 1 year - -/** - * Regular expression to match a path with a directory up component. - * @private - */ - -var UP_PATH_REGEXP = /(?:^|[\\\/])\.\.(?:[\\\/]|$)/ - -/** - * Module exports. - * @public - */ - -module.exports = send -module.exports.mime = mime - -/** - * Shim EventEmitter.listenerCount for node.js < 0.10 - */ - -/* istanbul ignore next */ -var listenerCount = EventEmitter.listenerCount || - function (emitter, type) { return emitter.listeners(type).length } - -/** - * Return a `SendStream` for `req` and `path`. - * - * @param {object} req - * @param {string} path - * @param {object} [options] - * @return {SendStream} - * @public - */ - -function send (req, path, options) { - return new SendStream(req, path, options) -} - -/** - * Initialize a `SendStream` with the given `path`. - * - * @param {Request} req - * @param {String} path - * @param {object} [options] - * @private - */ - -function SendStream (req, path, options) { - Stream.call(this) - - var opts = options || {} - - this.options = opts - this.path = path - this.req = req - - this._acceptRanges = opts.acceptRanges !== undefined - ? Boolean(opts.acceptRanges) - : true - - this._cacheControl = opts.cacheControl !== undefined - ? Boolean(opts.cacheControl) - : true - - this._etag = opts.etag !== undefined - ? Boolean(opts.etag) - : true - - this._dotfiles = opts.dotfiles !== undefined - ? opts.dotfiles - : 'ignore' - - if (this._dotfiles !== 'ignore' && this._dotfiles !== 'allow' && this._dotfiles !== 'deny') { - throw new TypeError('dotfiles option must be "allow", "deny", or "ignore"') - } - - this._hidden = Boolean(opts.hidden) - - if (opts.hidden !== undefined) { - deprecate('hidden: use dotfiles: \'' + (this._hidden ? 'allow' : 'ignore') + '\' instead') - } - - // legacy support - if (opts.dotfiles === undefined) { - this._dotfiles = undefined - } - - this._extensions = opts.extensions !== undefined - ? normalizeList(opts.extensions, 'extensions option') - : [] - - this._index = opts.index !== undefined - ? normalizeList(opts.index, 'index option') - : ['index.html'] - - this._lastModified = opts.lastModified !== undefined - ? Boolean(opts.lastModified) - : true - - this._maxage = opts.maxAge || opts.maxage - this._maxage = typeof this._maxage === 'string' - ? ms(this._maxage) - : Number(this._maxage) - this._maxage = !isNaN(this._maxage) - ? Math.min(Math.max(0, this._maxage), MAX_MAXAGE) - : 0 - - this._root = opts.root - ? resolve(opts.root) - : null - - if (!this._root && opts.from) { - this.from(opts.from) - } -} - -/** - * Inherits from `Stream`. - */ - -util.inherits(SendStream, Stream) - -/** - * Enable or disable etag generation. - * - * @param {Boolean} val - * @return {SendStream} - * @api public - */ - -SendStream.prototype.etag = deprecate.function(function etag (val) { - this._etag = Boolean(val) - debug('etag %s', this._etag) - return this -}, 'send.etag: pass etag as option') - -/** - * Enable or disable "hidden" (dot) files. - * - * @param {Boolean} path - * @return {SendStream} - * @api public - */ - -SendStream.prototype.hidden = deprecate.function(function hidden (val) { - this._hidden = Boolean(val) - this._dotfiles = undefined - debug('hidden %s', this._hidden) - return this -}, 'send.hidden: use dotfiles option') - -/** - * Set index `paths`, set to a falsy - * value to disable index support. - * - * @param {String|Boolean|Array} paths - * @return {SendStream} - * @api public - */ - -SendStream.prototype.index = deprecate.function(function index (paths) { - var index = !paths ? [] : normalizeList(paths, 'paths argument') - debug('index %o', paths) - this._index = index - return this -}, 'send.index: pass index as option') - -/** - * Set root `path`. - * - * @param {String} path - * @return {SendStream} - * @api public - */ - -SendStream.prototype.root = function root (path) { - this._root = resolve(String(path)) - debug('root %s', this._root) - return this -} - -SendStream.prototype.from = deprecate.function(SendStream.prototype.root, - 'send.from: pass root as option') - -SendStream.prototype.root = deprecate.function(SendStream.prototype.root, - 'send.root: pass root as option') - -/** - * Set max-age to `maxAge`. - * - * @param {Number} maxAge - * @return {SendStream} - * @api public - */ - -SendStream.prototype.maxage = deprecate.function(function maxage (maxAge) { - this._maxage = typeof maxAge === 'string' - ? ms(maxAge) - : Number(maxAge) - this._maxage = !isNaN(this._maxage) - ? Math.min(Math.max(0, this._maxage), MAX_MAXAGE) - : 0 - debug('max-age %d', this._maxage) - return this -}, 'send.maxage: pass maxAge as option') - -/** - * Emit error with `status`. - * - * @param {number} status - * @param {Error} [error] - * @private - */ - -SendStream.prototype.error = function error (status, error) { - // emit if listeners instead of responding - if (listenerCount(this, 'error') !== 0) { - return this.emit('error', createError(error, status, { - expose: false - })) - } - - var res = this.res - var msg = statuses[status] - - // clear existing headers - clearHeaders(res) - - // add error headers - if (error && error.headers) { - setHeaders(res, error.headers) - } - - // send basic response - res.statusCode = status - res.setHeader('Content-Type', 'text/plain; charset=UTF-8') - res.setHeader('Content-Length', Buffer.byteLength(msg)) - res.setHeader('X-Content-Type-Options', 'nosniff') - res.end(msg) -} - -/** - * Check if the pathname ends with "/". - * - * @return {Boolean} - * @api private - */ - -SendStream.prototype.hasTrailingSlash = function hasTrailingSlash () { - return this.path[this.path.length - 1] === '/' -} - -/** - * Check if this is a conditional GET request. - * - * @return {Boolean} - * @api private - */ - -SendStream.prototype.isConditionalGET = function isConditionalGET () { - return this.req.headers['if-none-match'] || - this.req.headers['if-modified-since'] -} - -/** - * Strip content-* header fields. - * - * @private - */ - -SendStream.prototype.removeContentHeaderFields = function removeContentHeaderFields () { - var res = this.res - var headers = Object.keys(res._headers || {}) - - for (var i = 0; i < headers.length; i++) { - var header = headers[i] - if (header.substr(0, 8) === 'content-' && header !== 'content-location') { - res.removeHeader(header) - } - } -} - -/** - * Respond with 304 not modified. - * - * @api private - */ - -SendStream.prototype.notModified = function notModified () { - var res = this.res - debug('not modified') - this.removeContentHeaderFields() - res.statusCode = 304 - res.end() -} - -/** - * Raise error that headers already sent. - * - * @api private - */ - -SendStream.prototype.headersAlreadySent = function headersAlreadySent () { - var err = new Error('Can\'t set headers after they are sent.') - debug('headers already sent') - this.error(500, err) -} - -/** - * Check if the request is cacheable, aka - * responded with 2xx or 304 (see RFC 2616 section 14.2{5,6}). - * - * @return {Boolean} - * @api private - */ - -SendStream.prototype.isCachable = function isCachable () { - var statusCode = this.res.statusCode - return (statusCode >= 200 && statusCode < 300) || - statusCode === 304 -} - -/** - * Handle stat() error. - * - * @param {Error} error - * @private - */ - -SendStream.prototype.onStatError = function onStatError (error) { - switch (error.code) { - case 'ENAMETOOLONG': - case 'ENOENT': - case 'ENOTDIR': - this.error(404, error) - break - default: - this.error(500, error) - break - } -} - -/** - * Check if the cache is fresh. - * - * @return {Boolean} - * @api private - */ - -SendStream.prototype.isFresh = function isFresh () { - return fresh(this.req.headers, this.res._headers) -} - -/** - * Check if the range is fresh. - * - * @return {Boolean} - * @api private - */ - -SendStream.prototype.isRangeFresh = function isRangeFresh () { - var ifRange = this.req.headers['if-range'] - - if (!ifRange) { - return true - } - - return ~ifRange.indexOf('"') - ? ~ifRange.indexOf(this.res._headers['etag']) - : Date.parse(this.res._headers['last-modified']) <= Date.parse(ifRange) -} - -/** - * Redirect to path. - * - * @param {string} path - * @private - */ - -SendStream.prototype.redirect = function redirect (path) { - if (listenerCount(this, 'directory') !== 0) { - this.emit('directory') - return - } - - if (this.hasTrailingSlash()) { - this.error(403) - return - } - - var loc = encodeUrl(collapseLeadingSlashes(path + '/')) - var msg = 'Redirecting to ' + escapeHtml(loc) + '\n' - var res = this.res - - // redirect - res.statusCode = 301 - res.setHeader('Content-Type', 'text/html; charset=UTF-8') - res.setHeader('Content-Length', Buffer.byteLength(msg)) - res.setHeader('X-Content-Type-Options', 'nosniff') - res.setHeader('Location', loc) - res.end(msg) -} - -/** - * Pipe to `res. - * - * @param {Stream} res - * @return {Stream} res - * @api public - */ - -SendStream.prototype.pipe = function pipe (res) { - // root path - var root = this._root - - // references - this.res = res - - // decode the path - var path = decode(this.path) - if (path === -1) { - this.error(400) - return res - } - - // null byte(s) - if (~path.indexOf('\0')) { - this.error(400) - return res - } - - var parts - if (root !== null) { - // malicious path - if (UP_PATH_REGEXP.test(normalize('.' + sep + path))) { - debug('malicious path "%s"', path) - this.error(403) - return res - } - - // join / normalize from optional root dir - path = normalize(join(root, path)) - root = normalize(root + sep) - - // explode path parts - parts = path.substr(root.length).split(sep) - } else { - // ".." is malicious without "root" - if (UP_PATH_REGEXP.test(path)) { - debug('malicious path "%s"', path) - this.error(403) - return res - } - - // explode path parts - parts = normalize(path).split(sep) - - // resolve the path - path = resolve(path) - } - - // dotfile handling - if (containsDotFile(parts)) { - var access = this._dotfiles - - // legacy support - if (access === undefined) { - access = parts[parts.length - 1][0] === '.' - ? (this._hidden ? 'allow' : 'ignore') - : 'allow' - } - - debug('%s dotfile "%s"', access, path) - switch (access) { - case 'allow': - break - case 'deny': - this.error(403) - return res - case 'ignore': - default: - this.error(404) - return res - } - } - - // index file support - if (this._index.length && this.path[this.path.length - 1] === '/') { - this.sendIndex(path) - return res - } - - this.sendFile(path) - return res -} - -/** - * Transfer `path`. - * - * @param {String} path - * @api public - */ - -SendStream.prototype.send = function send (path, stat) { - var len = stat.size - var options = this.options - var opts = {} - var res = this.res - var req = this.req - var ranges = req.headers.range - var offset = options.start || 0 - - if (res._header) { - // impossible to send now - this.headersAlreadySent() - return - } - - debug('pipe "%s"', path) - - // set header fields - this.setHeader(path, stat) - - // set content-type - this.type(path) - - // conditional GET support - if (this.isConditionalGET() && this.isCachable() && this.isFresh()) { - this.notModified() - return - } - - // adjust len to start/end options - len = Math.max(0, len - offset) - if (options.end !== undefined) { - var bytes = options.end - offset + 1 - if (len > bytes) len = bytes - } - - // Range support - if (this._acceptRanges && BYTES_RANGE_REGEXP.test(ranges)) { - // parse - ranges = parseRange(len, ranges, { - combine: true - }) - - // If-Range support - if (!this.isRangeFresh()) { - debug('range stale') - ranges = -2 - } - - // unsatisfiable - if (ranges === -1) { - debug('range unsatisfiable') - - // Content-Range - res.setHeader('Content-Range', contentRange('bytes', len)) - - // 416 Requested Range Not Satisfiable - return this.error(416, { - headers: {'Content-Range': res.getHeader('Content-Range')} - }) - } - - // valid (syntactically invalid/multiple ranges are treated as a regular response) - if (ranges !== -2 && ranges.length === 1) { - debug('range %j', ranges) - - // Content-Range - res.statusCode = 206 - res.setHeader('Content-Range', contentRange('bytes', len, ranges[0])) - - // adjust for requested range - offset += ranges[0].start - len = ranges[0].end - ranges[0].start + 1 - } - } - - // clone options - for (var prop in options) { - opts[prop] = options[prop] - } - - // set read options - opts.start = offset - opts.end = Math.max(offset, offset + len - 1) - - // content-length - res.setHeader('Content-Length', len) - - // HEAD support - if (req.method === 'HEAD') { - res.end() - return - } - - this.stream(path, opts) -} - -/** - * Transfer file for `path`. - * - * @param {String} path - * @api private - */ -SendStream.prototype.sendFile = function sendFile (path) { - var i = 0 - var self = this - - debug('stat "%s"', path) - fs.stat(path, function onstat (err, stat) { - if (err && err.code === 'ENOENT' && !extname(path) && path[path.length - 1] !== sep) { - // not found, check extensions - return next(err) - } - if (err) return self.onStatError(err) - if (stat.isDirectory()) return self.redirect(self.path) - self.emit('file', path, stat) - self.send(path, stat) - }) - - function next (err) { - if (self._extensions.length <= i) { - return err - ? self.onStatError(err) - : self.error(404) - } - - var p = path + '.' + self._extensions[i++] - - debug('stat "%s"', p) - fs.stat(p, function (err, stat) { - if (err) return next(err) - if (stat.isDirectory()) return next() - self.emit('file', p, stat) - self.send(p, stat) - }) - } -} - -/** - * Transfer index for `path`. - * - * @param {String} path - * @api private - */ -SendStream.prototype.sendIndex = function sendIndex (path) { - var i = -1 - var self = this - - function next (err) { - if (++i >= self._index.length) { - if (err) return self.onStatError(err) - return self.error(404) - } - - var p = join(path, self._index[i]) - - debug('stat "%s"', p) - fs.stat(p, function (err, stat) { - if (err) return next(err) - if (stat.isDirectory()) return next() - self.emit('file', p, stat) - self.send(p, stat) - }) - } - - next() -} - -/** - * Stream `path` to the response. - * - * @param {String} path - * @param {Object} options - * @api private - */ - -SendStream.prototype.stream = function stream (path, options) { - // TODO: this is all lame, refactor meeee - var finished = false - var self = this - var res = this.res - - // pipe - var stream = fs.createReadStream(path, options) - this.emit('stream', stream) - stream.pipe(res) - - // response finished, done with the fd - onFinished(res, function onfinished () { - finished = true - destroy(stream) - }) - - // error handling code-smell - stream.on('error', function onerror (err) { - // request already finished - if (finished) return - - // clean up stream - finished = true - destroy(stream) - - // error - self.onStatError(err) - }) - - // end - stream.on('end', function onend () { - self.emit('end') - }) -} - -/** - * Set content-type based on `path` - * if it hasn't been explicitly set. - * - * @param {String} path - * @api private - */ - -SendStream.prototype.type = function type (path) { - var res = this.res - - if (res.getHeader('Content-Type')) return - - var type = mime.lookup(path) - - if (!type) { - debug('no content-type') - return - } - - var charset = mime.charsets.lookup(type) - - debug('content-type %s', type) - res.setHeader('Content-Type', type + (charset ? '; charset=' + charset : '')) -} - -/** - * Set response header fields, most - * fields may be pre-defined. - * - * @param {String} path - * @param {Object} stat - * @api private - */ - -SendStream.prototype.setHeader = function setHeader (path, stat) { - var res = this.res - - this.emit('headers', res, path, stat) - - if (this._acceptRanges && !res.getHeader('Accept-Ranges')) { - debug('accept ranges') - res.setHeader('Accept-Ranges', 'bytes') - } - - if (this._cacheControl && !res.getHeader('Cache-Control')) { - var cacheControl = 'public, max-age=' + Math.floor(this._maxage / 1000) - debug('cache-control %s', cacheControl) - res.setHeader('Cache-Control', cacheControl) - } - - if (this._lastModified && !res.getHeader('Last-Modified')) { - var modified = stat.mtime.toUTCString() - debug('modified %s', modified) - res.setHeader('Last-Modified', modified) - } - - if (this._etag && !res.getHeader('ETag')) { - var val = etag(stat) - debug('etag %s', val) - res.setHeader('ETag', val) - } -} - -/** - * Clear all headers from a response. - * - * @param {object} res - * @private - */ - -function clearHeaders (res) { - res._headers = {} - res._headerNames = {} -} - -/** - * Collapse all leading slashes into a single slash - * - * @param {string} str - * @private - */ -function collapseLeadingSlashes (str) { - for (var i = 0; i < str.length; i++) { - if (str[i] !== '/') { - break - } - } - - return i > 1 - ? '/' + str.substr(i) - : str -} - -/** - * Determine if path parts contain a dotfile. - * - * @api private - */ - -function containsDotFile (parts) { - for (var i = 0; i < parts.length; i++) { - if (parts[i][0] === '.') { - return true - } - } - - return false -} - -/** - * Create a Content-Range header. - * - * @param {string} type - * @param {number} size - * @param {array} [range] - */ - -function contentRange (type, size, range) { - return type + ' ' + (range ? range.start + '-' + range.end : '*') + '/' + size -} - -/** - * decodeURIComponent. - * - * Allows V8 to only deoptimize this fn instead of all - * of send(). - * - * @param {String} path - * @api private - */ - -function decode (path) { - try { - return decodeURIComponent(path) - } catch (err) { - return -1 - } -} - -/** - * Normalize the index option into an array. - * - * @param {boolean|string|array} val - * @param {string} name - * @private - */ - -function normalizeList (val, name) { - var list = [].concat(val || []) - - for (var i = 0; i < list.length; i++) { - if (typeof list[i] !== 'string') { - throw new TypeError(name + ' must be array of strings or false') - } - } - - return list -} - -/** - * Set an object of headers on a response. - * - * @param {object} res - * @param {object} headers - * @private - */ - -function setHeaders (res, headers) { - var keys = Object.keys(headers) - - for (var i = 0; i < keys.length; i++) { - var key = keys[i] - res.setHeader(key, headers[key]) - } -} +/*! + * send + * Copyright(c) 2012 TJ Holowaychuk + * Copyright(c) 2014-2016 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module dependencies. + * @private + */ + +var createError = require('http-errors') +var debug = require('debug')('send') +var deprecate = require('depd')('send') +var destroy = require('destroy') +var encodeUrl = require('encodeurl') +var escapeHtml = require('escape-html') +var etag = require('etag') +var EventEmitter = require('events').EventEmitter +var fresh = require('fresh') +var fs = require('fs') +var mime = require('mime') +var ms = require('ms') +var onFinished = require('on-finished') +var parseRange = require('range-parser') +var path = require('path') +var statuses = require('statuses') +var Stream = require('stream') +var util = require('util') + +/** + * Path function references. + * @private + */ + +var extname = path.extname +var join = path.join +var normalize = path.normalize +var resolve = path.resolve +var sep = path.sep + +/** + * Regular expression for identifying a bytes Range header. + * @private + */ + +var BYTES_RANGE_REGEXP = /^ *bytes=/ + +/** + * Maximum value allowed for the max age. + * @private + */ + +var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1000 // 1 year + +/** + * Regular expression to match a path with a directory up component. + * @private + */ + +var UP_PATH_REGEXP = /(?:^|[\\\/])\.\.(?:[\\\/]|$)/ + +/** + * Module exports. + * @public + */ + +module.exports = send +module.exports.mime = mime + +/** + * Shim EventEmitter.listenerCount for node.js < 0.10 + */ + +/* istanbul ignore next */ +var listenerCount = EventEmitter.listenerCount || + function (emitter, type) { return emitter.listeners(type).length } + +/** + * Return a `SendStream` for `req` and `path`. + * + * @param {object} req + * @param {string} path + * @param {object} [options] + * @return {SendStream} + * @public + */ + +function send (req, path, options) { + return new SendStream(req, path, options) +} + +/** + * Initialize a `SendStream` with the given `path`. + * + * @param {Request} req + * @param {String} path + * @param {object} [options] + * @private + */ + +function SendStream (req, path, options) { + Stream.call(this) + + var opts = options || {} + + this.options = opts + this.path = path + this.req = req + + this._acceptRanges = opts.acceptRanges !== undefined + ? Boolean(opts.acceptRanges) + : true + + this._cacheControl = opts.cacheControl !== undefined + ? Boolean(opts.cacheControl) + : true + + this._etag = opts.etag !== undefined + ? Boolean(opts.etag) + : true + + this._dotfiles = opts.dotfiles !== undefined + ? opts.dotfiles + : 'ignore' + + if (this._dotfiles !== 'ignore' && this._dotfiles !== 'allow' && this._dotfiles !== 'deny') { + throw new TypeError('dotfiles option must be "allow", "deny", or "ignore"') + } + + this._hidden = Boolean(opts.hidden) + + if (opts.hidden !== undefined) { + deprecate('hidden: use dotfiles: \'' + (this._hidden ? 'allow' : 'ignore') + '\' instead') + } + + // legacy support + if (opts.dotfiles === undefined) { + this._dotfiles = undefined + } + + this._extensions = opts.extensions !== undefined + ? normalizeList(opts.extensions, 'extensions option') + : [] + + this._index = opts.index !== undefined + ? normalizeList(opts.index, 'index option') + : ['index.html'] + + this._lastModified = opts.lastModified !== undefined + ? Boolean(opts.lastModified) + : true + + this._maxage = opts.maxAge || opts.maxage + this._maxage = typeof this._maxage === 'string' + ? ms(this._maxage) + : Number(this._maxage) + this._maxage = !isNaN(this._maxage) + ? Math.min(Math.max(0, this._maxage), MAX_MAXAGE) + : 0 + + this._root = opts.root + ? resolve(opts.root) + : null + + if (!this._root && opts.from) { + this.from(opts.from) + } +} + +/** + * Inherits from `Stream`. + */ + +util.inherits(SendStream, Stream) + +/** + * Enable or disable etag generation. + * + * @param {Boolean} val + * @return {SendStream} + * @api public + */ + +SendStream.prototype.etag = deprecate.function(function etag (val) { + this._etag = Boolean(val) + debug('etag %s', this._etag) + return this +}, 'send.etag: pass etag as option') + +/** + * Enable or disable "hidden" (dot) files. + * + * @param {Boolean} path + * @return {SendStream} + * @api public + */ + +SendStream.prototype.hidden = deprecate.function(function hidden (val) { + this._hidden = Boolean(val) + this._dotfiles = undefined + debug('hidden %s', this._hidden) + return this +}, 'send.hidden: use dotfiles option') + +/** + * Set index `paths`, set to a falsy + * value to disable index support. + * + * @param {String|Boolean|Array} paths + * @return {SendStream} + * @api public + */ + +SendStream.prototype.index = deprecate.function(function index (paths) { + var index = !paths ? [] : normalizeList(paths, 'paths argument') + debug('index %o', paths) + this._index = index + return this +}, 'send.index: pass index as option') + +/** + * Set root `path`. + * + * @param {String} path + * @return {SendStream} + * @api public + */ + +SendStream.prototype.root = function root (path) { + this._root = resolve(String(path)) + debug('root %s', this._root) + return this +} + +SendStream.prototype.from = deprecate.function(SendStream.prototype.root, + 'send.from: pass root as option') + +SendStream.prototype.root = deprecate.function(SendStream.prototype.root, + 'send.root: pass root as option') + +/** + * Set max-age to `maxAge`. + * + * @param {Number} maxAge + * @return {SendStream} + * @api public + */ + +SendStream.prototype.maxage = deprecate.function(function maxage (maxAge) { + this._maxage = typeof maxAge === 'string' + ? ms(maxAge) + : Number(maxAge) + this._maxage = !isNaN(this._maxage) + ? Math.min(Math.max(0, this._maxage), MAX_MAXAGE) + : 0 + debug('max-age %d', this._maxage) + return this +}, 'send.maxage: pass maxAge as option') + +/** + * Emit error with `status`. + * + * @param {number} status + * @param {Error} [error] + * @private + */ + +SendStream.prototype.error = function error (status, error) { + // emit if listeners instead of responding + if (listenerCount(this, 'error') !== 0) { + return this.emit('error', createError(error, status, { + expose: false + })) + } + + var res = this.res + var msg = statuses[status] + + // clear existing headers + clearHeaders(res) + + // add error headers + if (error && error.headers) { + setHeaders(res, error.headers) + } + + // send basic response + res.statusCode = status + res.setHeader('Content-Type', 'text/plain; charset=UTF-8') + res.setHeader('Content-Length', Buffer.byteLength(msg)) + res.setHeader('X-Content-Type-Options', 'nosniff') + res.end(msg) +} + +/** + * Check if the pathname ends with "/". + * + * @return {Boolean} + * @api private + */ + +SendStream.prototype.hasTrailingSlash = function hasTrailingSlash () { + return this.path[this.path.length - 1] === '/' +} + +/** + * Check if this is a conditional GET request. + * + * @return {Boolean} + * @api private + */ + +SendStream.prototype.isConditionalGET = function isConditionalGET () { + return this.req.headers['if-none-match'] || + this.req.headers['if-modified-since'] +} + +/** + * Strip content-* header fields. + * + * @private + */ + +SendStream.prototype.removeContentHeaderFields = function removeContentHeaderFields () { + var res = this.res + var headers = Object.keys(res._headers || {}) + + for (var i = 0; i < headers.length; i++) { + var header = headers[i] + if (header.substr(0, 8) === 'content-' && header !== 'content-location') { + res.removeHeader(header) + } + } +} + +/** + * Respond with 304 not modified. + * + * @api private + */ + +SendStream.prototype.notModified = function notModified () { + var res = this.res + debug('not modified') + this.removeContentHeaderFields() + res.statusCode = 304 + res.end() +} + +/** + * Raise error that headers already sent. + * + * @api private + */ + +SendStream.prototype.headersAlreadySent = function headersAlreadySent () { + var err = new Error('Can\'t set headers after they are sent.') + debug('headers already sent') + this.error(500, err) +} + +/** + * Check if the request is cacheable, aka + * responded with 2xx or 304 (see RFC 2616 section 14.2{5,6}). + * + * @return {Boolean} + * @api private + */ + +SendStream.prototype.isCachable = function isCachable () { + var statusCode = this.res.statusCode + return (statusCode >= 200 && statusCode < 300) || + statusCode === 304 +} + +/** + * Handle stat() error. + * + * @param {Error} error + * @private + */ + +SendStream.prototype.onStatError = function onStatError (error) { + switch (error.code) { + case 'ENAMETOOLONG': + case 'ENOENT': + case 'ENOTDIR': + this.error(404, error) + break + default: + this.error(500, error) + break + } +} + +/** + * Check if the cache is fresh. + * + * @return {Boolean} + * @api private + */ + +SendStream.prototype.isFresh = function isFresh () { + return fresh(this.req.headers, this.res._headers) +} + +/** + * Check if the range is fresh. + * + * @return {Boolean} + * @api private + */ + +SendStream.prototype.isRangeFresh = function isRangeFresh () { + var ifRange = this.req.headers['if-range'] + + if (!ifRange) { + return true + } + + return ~ifRange.indexOf('"') + ? ~ifRange.indexOf(this.res._headers['etag']) + : Date.parse(this.res._headers['last-modified']) <= Date.parse(ifRange) +} + +/** + * Redirect to path. + * + * @param {string} path + * @private + */ + +SendStream.prototype.redirect = function redirect (path) { + if (listenerCount(this, 'directory') !== 0) { + this.emit('directory') + return + } + + if (this.hasTrailingSlash()) { + this.error(403) + return + } + + var loc = encodeUrl(collapseLeadingSlashes(path + '/')) + var msg = 'Redirecting to ' + escapeHtml(loc) + '\n' + var res = this.res + + // redirect + res.statusCode = 301 + res.setHeader('Content-Type', 'text/html; charset=UTF-8') + res.setHeader('Content-Length', Buffer.byteLength(msg)) + res.setHeader('X-Content-Type-Options', 'nosniff') + res.setHeader('Location', loc) + res.end(msg) +} + +/** + * Pipe to `res. + * + * @param {Stream} res + * @return {Stream} res + * @api public + */ + +SendStream.prototype.pipe = function pipe (res) { + // root path + var root = this._root + + // references + this.res = res + + // decode the path + var path = decode(this.path) + if (path === -1) { + this.error(400) + return res + } + + // null byte(s) + if (~path.indexOf('\0')) { + this.error(400) + return res + } + + var parts + if (root !== null) { + // malicious path + if (UP_PATH_REGEXP.test(normalize('.' + sep + path))) { + debug('malicious path "%s"', path) + this.error(403) + return res + } + + // join / normalize from optional root dir + path = normalize(join(root, path)) + root = normalize(root + sep) + + // explode path parts + parts = path.substr(root.length).split(sep) + } else { + // ".." is malicious without "root" + if (UP_PATH_REGEXP.test(path)) { + debug('malicious path "%s"', path) + this.error(403) + return res + } + + // explode path parts + parts = normalize(path).split(sep) + + // resolve the path + path = resolve(path) + } + + // dotfile handling + if (containsDotFile(parts)) { + var access = this._dotfiles + + // legacy support + if (access === undefined) { + access = parts[parts.length - 1][0] === '.' + ? (this._hidden ? 'allow' : 'ignore') + : 'allow' + } + + debug('%s dotfile "%s"', access, path) + switch (access) { + case 'allow': + break + case 'deny': + this.error(403) + return res + case 'ignore': + default: + this.error(404) + return res + } + } + + // index file support + if (this._index.length && this.path[this.path.length - 1] === '/') { + this.sendIndex(path) + return res + } + + this.sendFile(path) + return res +} + +/** + * Transfer `path`. + * + * @param {String} path + * @api public + */ + +SendStream.prototype.send = function send (path, stat) { + var len = stat.size + var options = this.options + var opts = {} + var res = this.res + var req = this.req + var ranges = req.headers.range + var offset = options.start || 0 + + if (res._header) { + // impossible to send now + this.headersAlreadySent() + return + } + + debug('pipe "%s"', path) + + // set header fields + this.setHeader(path, stat) + + // set content-type + this.type(path) + + // conditional GET support + if (this.isConditionalGET() && this.isCachable() && this.isFresh()) { + this.notModified() + return + } + + // adjust len to start/end options + len = Math.max(0, len - offset) + if (options.end !== undefined) { + var bytes = options.end - offset + 1 + if (len > bytes) len = bytes + } + + // Range support + if (this._acceptRanges && BYTES_RANGE_REGEXP.test(ranges)) { + // parse + ranges = parseRange(len, ranges, { + combine: true + }) + + // If-Range support + if (!this.isRangeFresh()) { + debug('range stale') + ranges = -2 + } + + // unsatisfiable + if (ranges === -1) { + debug('range unsatisfiable') + + // Content-Range + res.setHeader('Content-Range', contentRange('bytes', len)) + + // 416 Requested Range Not Satisfiable + return this.error(416, { + headers: {'Content-Range': res.getHeader('Content-Range')} + }) + } + + // valid (syntactically invalid/multiple ranges are treated as a regular response) + if (ranges !== -2 && ranges.length === 1) { + debug('range %j', ranges) + + // Content-Range + res.statusCode = 206 + res.setHeader('Content-Range', contentRange('bytes', len, ranges[0])) + + // adjust for requested range + offset += ranges[0].start + len = ranges[0].end - ranges[0].start + 1 + } + } + + // clone options + for (var prop in options) { + opts[prop] = options[prop] + } + + // set read options + opts.start = offset + opts.end = Math.max(offset, offset + len - 1) + + // content-length + res.setHeader('Content-Length', len) + + // HEAD support + if (req.method === 'HEAD') { + res.end() + return + } + + this.stream(path, opts) +} + +/** + * Transfer file for `path`. + * + * @param {String} path + * @api private + */ +SendStream.prototype.sendFile = function sendFile (path) { + var i = 0 + var self = this + + debug('stat "%s"', path) + fs.stat(path, function onstat (err, stat) { + if (err && err.code === 'ENOENT' && !extname(path) && path[path.length - 1] !== sep) { + // not found, check extensions + return next(err) + } + if (err) return self.onStatError(err) + if (stat.isDirectory()) return self.redirect(self.path) + self.emit('file', path, stat) + self.send(path, stat) + }) + + function next (err) { + if (self._extensions.length <= i) { + return err + ? self.onStatError(err) + : self.error(404) + } + + var p = path + '.' + self._extensions[i++] + + debug('stat "%s"', p) + fs.stat(p, function (err, stat) { + if (err) return next(err) + if (stat.isDirectory()) return next() + self.emit('file', p, stat) + self.send(p, stat) + }) + } +} + +/** + * Transfer index for `path`. + * + * @param {String} path + * @api private + */ +SendStream.prototype.sendIndex = function sendIndex (path) { + var i = -1 + var self = this + + function next (err) { + if (++i >= self._index.length) { + if (err) return self.onStatError(err) + return self.error(404) + } + + var p = join(path, self._index[i]) + + debug('stat "%s"', p) + fs.stat(p, function (err, stat) { + if (err) return next(err) + if (stat.isDirectory()) return next() + self.emit('file', p, stat) + self.send(p, stat) + }) + } + + next() +} + +/** + * Stream `path` to the response. + * + * @param {String} path + * @param {Object} options + * @api private + */ + +SendStream.prototype.stream = function stream (path, options) { + // TODO: this is all lame, refactor meeee + var finished = false + var self = this + var res = this.res + + // pipe + var stream = fs.createReadStream(path, options) + this.emit('stream', stream) + stream.pipe(res) + + // response finished, done with the fd + onFinished(res, function onfinished () { + finished = true + destroy(stream) + }) + + // error handling code-smell + stream.on('error', function onerror (err) { + // request already finished + if (finished) return + + // clean up stream + finished = true + destroy(stream) + + // error + self.onStatError(err) + }) + + // end + stream.on('end', function onend () { + self.emit('end') + }) +} + +/** + * Set content-type based on `path` + * if it hasn't been explicitly set. + * + * @param {String} path + * @api private + */ + +SendStream.prototype.type = function type (path) { + var res = this.res + + if (res.getHeader('Content-Type')) return + + var type = mime.lookup(path) + + if (!type) { + debug('no content-type') + return + } + + var charset = mime.charsets.lookup(type) + + debug('content-type %s', type) + res.setHeader('Content-Type', type + (charset ? '; charset=' + charset : '')) +} + +/** + * Set response header fields, most + * fields may be pre-defined. + * + * @param {String} path + * @param {Object} stat + * @api private + */ + +SendStream.prototype.setHeader = function setHeader (path, stat) { + var res = this.res + + this.emit('headers', res, path, stat) + + if (this._acceptRanges && !res.getHeader('Accept-Ranges')) { + debug('accept ranges') + res.setHeader('Accept-Ranges', 'bytes') + } + + if (this._cacheControl && !res.getHeader('Cache-Control')) { + var cacheControl = 'public, max-age=' + Math.floor(this._maxage / 1000) + debug('cache-control %s', cacheControl) + res.setHeader('Cache-Control', cacheControl) + } + + if (this._lastModified && !res.getHeader('Last-Modified')) { + var modified = stat.mtime.toUTCString() + debug('modified %s', modified) + res.setHeader('Last-Modified', modified) + } + + if (this._etag && !res.getHeader('ETag')) { + var val = etag(stat) + debug('etag %s', val) + res.setHeader('ETag', val) + } +} + +/** + * Clear all headers from a response. + * + * @param {object} res + * @private + */ + +function clearHeaders (res) { + res._headers = {} + res._headerNames = {} +} + +/** + * Collapse all leading slashes into a single slash + * + * @param {string} str + * @private + */ +function collapseLeadingSlashes (str) { + for (var i = 0; i < str.length; i++) { + if (str[i] !== '/') { + break + } + } + + return i > 1 + ? '/' + str.substr(i) + : str +} + +/** + * Determine if path parts contain a dotfile. + * + * @api private + */ + +function containsDotFile (parts) { + for (var i = 0; i < parts.length; i++) { + if (parts[i][0] === '.') { + return true + } + } + + return false +} + +/** + * Create a Content-Range header. + * + * @param {string} type + * @param {number} size + * @param {array} [range] + */ + +function contentRange (type, size, range) { + return type + ' ' + (range ? range.start + '-' + range.end : '*') + '/' + size +} + +/** + * decodeURIComponent. + * + * Allows V8 to only deoptimize this fn instead of all + * of send(). + * + * @param {String} path + * @api private + */ + +function decode (path) { + try { + return decodeURIComponent(path) + } catch (err) { + return -1 + } +} + +/** + * Normalize the index option into an array. + * + * @param {boolean|string|array} val + * @param {string} name + * @private + */ + +function normalizeList (val, name) { + var list = [].concat(val || []) + + for (var i = 0; i < list.length; i++) { + if (typeof list[i] !== 'string') { + throw new TypeError(name + ' must be array of strings or false') + } + } + + return list +} + +/** + * Set an object of headers on a response. + * + * @param {object} res + * @param {object} headers + * @private + */ + +function setHeaders (res, headers) { + var keys = Object.keys(headers) + + for (var i = 0; i < keys.length; i++) { + var key = keys[i] + res.setHeader(key, headers[key]) + } +} diff --git a/ui/node_modules/express/node_modules/send/node_modules/destroy/LICENSE b/ui/node_modules/express/node_modules/send/node_modules/destroy/LICENSE index c1b15a1d..a7ae8ee9 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/destroy/LICENSE +++ b/ui/node_modules/express/node_modules/send/node_modules/destroy/LICENSE @@ -1,22 +1,22 @@ - -The MIT License (MIT) - -Copyright (c) 2014 Jonathan Ong me@jongleberry.com - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. + +The MIT License (MIT) + +Copyright (c) 2014 Jonathan Ong me@jongleberry.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/send/node_modules/destroy/README.md b/ui/node_modules/express/node_modules/send/node_modules/destroy/README.md index 608502a4..6474bc3c 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/destroy/README.md +++ b/ui/node_modules/express/node_modules/send/node_modules/destroy/README.md @@ -1,60 +1,60 @@ -# Destroy - -[![NPM version][npm-image]][npm-url] -[![Build status][travis-image]][travis-url] -[![Test coverage][coveralls-image]][coveralls-url] -[![License][license-image]][license-url] -[![Downloads][downloads-image]][downloads-url] -[![Gittip][gittip-image]][gittip-url] - -Destroy a stream. - -This module is meant to ensure a stream gets destroyed, handling different APIs -and Node.js bugs. - -## API - -```js -var destroy = require('destroy') -``` - -### destroy(stream) - -Destroy the given stream. In most cases, this is identical to a simple -`stream.destroy()` call. The rules are as follows for a given stream: - - 1. If the `stream` is an instance of `ReadStream`, then call `stream.destroy()` - and add a listener to the `open` event to call `stream.close()` if it is - fired. This is for a Node.js bug that will leak a file descriptor if - `.destroy()` is called before `open`. - 2. If the `stream` is not an instance of `Stream`, then nothing happens. - 3. If the `stream` has a `.destroy()` method, then call it. - -The function returns the `stream` passed in as the argument. - -## Example - -```js -var destroy = require('destroy') - -var fs = require('fs') -var stream = fs.createReadStream('package.json') - -// ... and later -destroy(stream) -``` - -[npm-image]: https://img.shields.io/npm/v/destroy.svg?style=flat-square -[npm-url]: https://npmjs.org/package/destroy -[github-tag]: http://img.shields.io/github/tag/stream-utils/destroy.svg?style=flat-square -[github-url]: https://github.com/stream-utils/destroy/tags -[travis-image]: https://img.shields.io/travis/stream-utils/destroy.svg?style=flat-square -[travis-url]: https://travis-ci.org/stream-utils/destroy -[coveralls-image]: https://img.shields.io/coveralls/stream-utils/destroy.svg?style=flat-square -[coveralls-url]: https://coveralls.io/r/stream-utils/destroy?branch=master -[license-image]: http://img.shields.io/npm/l/destroy.svg?style=flat-square -[license-url]: LICENSE.md -[downloads-image]: http://img.shields.io/npm/dm/destroy.svg?style=flat-square -[downloads-url]: https://npmjs.org/package/destroy -[gittip-image]: https://img.shields.io/gittip/jonathanong.svg?style=flat-square -[gittip-url]: https://www.gittip.com/jonathanong/ +# Destroy + +[![NPM version][npm-image]][npm-url] +[![Build status][travis-image]][travis-url] +[![Test coverage][coveralls-image]][coveralls-url] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] +[![Gittip][gittip-image]][gittip-url] + +Destroy a stream. + +This module is meant to ensure a stream gets destroyed, handling different APIs +and Node.js bugs. + +## API + +```js +var destroy = require('destroy') +``` + +### destroy(stream) + +Destroy the given stream. In most cases, this is identical to a simple +`stream.destroy()` call. The rules are as follows for a given stream: + + 1. If the `stream` is an instance of `ReadStream`, then call `stream.destroy()` + and add a listener to the `open` event to call `stream.close()` if it is + fired. This is for a Node.js bug that will leak a file descriptor if + `.destroy()` is called before `open`. + 2. If the `stream` is not an instance of `Stream`, then nothing happens. + 3. If the `stream` has a `.destroy()` method, then call it. + +The function returns the `stream` passed in as the argument. + +## Example + +```js +var destroy = require('destroy') + +var fs = require('fs') +var stream = fs.createReadStream('package.json') + +// ... and later +destroy(stream) +``` + +[npm-image]: https://img.shields.io/npm/v/destroy.svg?style=flat-square +[npm-url]: https://npmjs.org/package/destroy +[github-tag]: http://img.shields.io/github/tag/stream-utils/destroy.svg?style=flat-square +[github-url]: https://github.com/stream-utils/destroy/tags +[travis-image]: https://img.shields.io/travis/stream-utils/destroy.svg?style=flat-square +[travis-url]: https://travis-ci.org/stream-utils/destroy +[coveralls-image]: https://img.shields.io/coveralls/stream-utils/destroy.svg?style=flat-square +[coveralls-url]: https://coveralls.io/r/stream-utils/destroy?branch=master +[license-image]: http://img.shields.io/npm/l/destroy.svg?style=flat-square +[license-url]: LICENSE.md +[downloads-image]: http://img.shields.io/npm/dm/destroy.svg?style=flat-square +[downloads-url]: https://npmjs.org/package/destroy +[gittip-image]: https://img.shields.io/gittip/jonathanong.svg?style=flat-square +[gittip-url]: https://www.gittip.com/jonathanong/ diff --git a/ui/node_modules/express/node_modules/send/node_modules/destroy/index.js b/ui/node_modules/express/node_modules/send/node_modules/destroy/index.js index 48f15bea..6da2d26e 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/destroy/index.js +++ b/ui/node_modules/express/node_modules/send/node_modules/destroy/index.js @@ -1,75 +1,75 @@ -/*! - * destroy - * Copyright(c) 2014 Jonathan Ong - * MIT Licensed - */ - -'use strict' - -/** - * Module dependencies. - * @private - */ - -var ReadStream = require('fs').ReadStream -var Stream = require('stream') - -/** - * Module exports. - * @public - */ - -module.exports = destroy - -/** - * Destroy a stream. - * - * @param {object} stream - * @public - */ - -function destroy(stream) { - if (stream instanceof ReadStream) { - return destroyReadStream(stream) - } - - if (!(stream instanceof Stream)) { - return stream - } - - if (typeof stream.destroy === 'function') { - stream.destroy() - } - - return stream -} - -/** - * Destroy a ReadStream. - * - * @param {object} stream - * @private - */ - -function destroyReadStream(stream) { - stream.destroy() - - if (typeof stream.close === 'function') { - // node.js core bug work-around - stream.on('open', onOpenClose) - } - - return stream -} - -/** - * On open handler to close stream. - * @private - */ - -function onOpenClose() { - if (typeof this.fd === 'number') { - // actually close down the fd - this.close() - } -} +/*! + * destroy + * Copyright(c) 2014 Jonathan Ong + * MIT Licensed + */ + +'use strict' + +/** + * Module dependencies. + * @private + */ + +var ReadStream = require('fs').ReadStream +var Stream = require('stream') + +/** + * Module exports. + * @public + */ + +module.exports = destroy + +/** + * Destroy a stream. + * + * @param {object} stream + * @public + */ + +function destroy(stream) { + if (stream instanceof ReadStream) { + return destroyReadStream(stream) + } + + if (!(stream instanceof Stream)) { + return stream + } + + if (typeof stream.destroy === 'function') { + stream.destroy() + } + + return stream +} + +/** + * Destroy a ReadStream. + * + * @param {object} stream + * @private + */ + +function destroyReadStream(stream) { + stream.destroy() + + if (typeof stream.close === 'function') { + // node.js core bug work-around + stream.on('open', onOpenClose) + } + + return stream +} + +/** + * On open handler to close stream. + * @private + */ + +function onOpenClose() { + if (typeof this.fd === 'number') { + // actually close down the fd + this.close() + } +} diff --git a/ui/node_modules/express/node_modules/send/node_modules/destroy/package.json b/ui/node_modules/express/node_modules/send/node_modules/destroy/package.json index 290f083c..ec1ed98a 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/destroy/package.json +++ b/ui/node_modules/express/node_modules/send/node_modules/destroy/package.json @@ -1,72 +1,72 @@ -{ - "name": "destroy", - "description": "destroy a stream if possible", - "version": "1.0.4", - "author": { - "name": "Jonathan Ong", - "email": "me@jongleberry.com", - "url": "http://jongleberry.com" - }, - "contributors": [ - { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - } - ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/stream-utils/destroy.git" - }, - "devDependencies": { - "istanbul": "0.4.2", - "mocha": "2.3.4" - }, - "scripts": { - "test": "mocha --reporter spec", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot" - }, - "files": [ - "index.js", - "LICENSE" - ], - "keywords": [ - "stream", - "streams", - "destroy", - "cleanup", - "leak", - "fd" - ], - "gitHead": "86edea01456f5fa1027f6a47250c34c713cbcc3b", - "bugs": { - "url": "https://github.com/stream-utils/destroy/issues" - }, - "homepage": "https://github.com/stream-utils/destroy", - "_id": "destroy@1.0.4", - "_shasum": "978857442c44749e4206613e37946205826abd80", - "_from": "destroy@>=1.0.4 <1.1.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "978857442c44749e4206613e37946205826abd80", - "tarball": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "destroy", + "description": "destroy a stream if possible", + "version": "1.0.4", + "author": { + "name": "Jonathan Ong", + "email": "me@jongleberry.com", + "url": "http://jongleberry.com" + }, + "contributors": [ + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + } + ], + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/stream-utils/destroy.git" + }, + "devDependencies": { + "istanbul": "0.4.2", + "mocha": "2.3.4" + }, + "scripts": { + "test": "mocha --reporter spec", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot" + }, + "files": [ + "index.js", + "LICENSE" + ], + "keywords": [ + "stream", + "streams", + "destroy", + "cleanup", + "leak", + "fd" + ], + "gitHead": "86edea01456f5fa1027f6a47250c34c713cbcc3b", + "bugs": { + "url": "https://github.com/stream-utils/destroy/issues" + }, + "homepage": "https://github.com/stream-utils/destroy", + "_id": "destroy@1.0.4", + "_shasum": "978857442c44749e4206613e37946205826abd80", + "_from": "destroy@>=1.0.4 <1.1.0", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "maintainers": [ + { + "name": "jongleberry", + "email": "jonathanrichardong@gmail.com" + }, + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + } + ], + "dist": { + "shasum": "978857442c44749e4206613e37946205826abd80", + "tarball": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/send/node_modules/http-errors/HISTORY.md b/ui/node_modules/express/node_modules/send/node_modules/http-errors/HISTORY.md index f174d54f..0dfb7acd 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/http-errors/HISTORY.md +++ b/ui/node_modules/express/node_modules/send/node_modules/http-errors/HISTORY.md @@ -1,95 +1,95 @@ -2016-05-18 / 1.5.0 -================== - - * Support new code `421 Misdirected Request` - * Use `setprototypeof` module to replace `__proto__` setting - * deps: statuses@'>= 1.3.0 < 2' - - Add `421 Misdirected Request` - - perf: enable strict mode - * perf: enable strict mode - -2016-01-28 / 1.4.0 -================== - - * Add `HttpError` export, for `err instanceof createError.HttpError` - * deps: inherits@2.0.1 - * deps: statuses@'>= 1.2.1 < 2' - - Fix message for status 451 - - Remove incorrect nginx status code - -2015-02-02 / 1.3.1 -================== - - * Fix regression where status can be overwritten in `createError` `props` - -2015-02-01 / 1.3.0 -================== - - * Construct errors using defined constructors from `createError` - * Fix error names that are not identifiers - - `createError["I'mateapot"]` is now `createError.ImATeapot` - * Set a meaningful `name` property on constructed errors - -2014-12-09 / 1.2.8 -================== - - * Fix stack trace from exported function - * Remove `arguments.callee` usage - -2014-10-14 / 1.2.7 -================== - - * Remove duplicate line - -2014-10-02 / 1.2.6 -================== - - * Fix `expose` to be `true` for `ClientError` constructor - -2014-09-28 / 1.2.5 -================== - - * deps: statuses@1 - -2014-09-21 / 1.2.4 -================== - - * Fix dependency version to work with old `npm`s - -2014-09-21 / 1.2.3 -================== - - * deps: statuses@~1.1.0 - -2014-09-21 / 1.2.2 -================== - - * Fix publish error - -2014-09-21 / 1.2.1 -================== - - * Support Node.js 0.6 - * Use `inherits` instead of `util` - -2014-09-09 / 1.2.0 -================== - - * Fix the way inheriting functions - * Support `expose` being provided in properties argument - -2014-09-08 / 1.1.0 -================== - - * Default status to 500 - * Support provided `error` to extend - -2014-09-08 / 1.0.1 -================== - - * Fix accepting string message - -2014-09-08 / 1.0.0 -================== - - * Initial release +2016-05-18 / 1.5.0 +================== + + * Support new code `421 Misdirected Request` + * Use `setprototypeof` module to replace `__proto__` setting + * deps: statuses@'>= 1.3.0 < 2' + - Add `421 Misdirected Request` + - perf: enable strict mode + * perf: enable strict mode + +2016-01-28 / 1.4.0 +================== + + * Add `HttpError` export, for `err instanceof createError.HttpError` + * deps: inherits@2.0.1 + * deps: statuses@'>= 1.2.1 < 2' + - Fix message for status 451 + - Remove incorrect nginx status code + +2015-02-02 / 1.3.1 +================== + + * Fix regression where status can be overwritten in `createError` `props` + +2015-02-01 / 1.3.0 +================== + + * Construct errors using defined constructors from `createError` + * Fix error names that are not identifiers + - `createError["I'mateapot"]` is now `createError.ImATeapot` + * Set a meaningful `name` property on constructed errors + +2014-12-09 / 1.2.8 +================== + + * Fix stack trace from exported function + * Remove `arguments.callee` usage + +2014-10-14 / 1.2.7 +================== + + * Remove duplicate line + +2014-10-02 / 1.2.6 +================== + + * Fix `expose` to be `true` for `ClientError` constructor + +2014-09-28 / 1.2.5 +================== + + * deps: statuses@1 + +2014-09-21 / 1.2.4 +================== + + * Fix dependency version to work with old `npm`s + +2014-09-21 / 1.2.3 +================== + + * deps: statuses@~1.1.0 + +2014-09-21 / 1.2.2 +================== + + * Fix publish error + +2014-09-21 / 1.2.1 +================== + + * Support Node.js 0.6 + * Use `inherits` instead of `util` + +2014-09-09 / 1.2.0 +================== + + * Fix the way inheriting functions + * Support `expose` being provided in properties argument + +2014-09-08 / 1.1.0 +================== + + * Default status to 500 + * Support provided `error` to extend + +2014-09-08 / 1.0.1 +================== + + * Fix accepting string message + +2014-09-08 / 1.0.0 +================== + + * Initial release diff --git a/ui/node_modules/express/node_modules/send/node_modules/http-errors/LICENSE b/ui/node_modules/express/node_modules/send/node_modules/http-errors/LICENSE index c232b56f..82af4df5 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/http-errors/LICENSE +++ b/ui/node_modules/express/node_modules/send/node_modules/http-errors/LICENSE @@ -1,23 +1,23 @@ - -The MIT License (MIT) - -Copyright (c) 2014 Jonathan Ong me@jongleberry.com -Copyright (c) 2016 Douglas Christopher Wilson doug@somethingdoug.com - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. + +The MIT License (MIT) + +Copyright (c) 2014 Jonathan Ong me@jongleberry.com +Copyright (c) 2016 Douglas Christopher Wilson doug@somethingdoug.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/send/node_modules/http-errors/README.md b/ui/node_modules/express/node_modules/send/node_modules/http-errors/README.md index 55e6bf2f..be80f9b9 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/http-errors/README.md +++ b/ui/node_modules/express/node_modules/send/node_modules/http-errors/README.md @@ -1,112 +1,112 @@ -# http-errors - -[![NPM Version][npm-image]][npm-url] -[![NPM Downloads][downloads-image]][downloads-url] -[![Node.js Version][node-version-image]][node-version-url] -[![Build Status][travis-image]][travis-url] -[![Test Coverage][coveralls-image]][coveralls-url] - -Create HTTP errors for Express, Koa, Connect, etc. with ease. - -## Example - -```js -var createError = require('http-errors'); - -app.use(function (req, res, next) { - if (!req.user) return next(createError(401, 'Please login to view this page.')); - next(); -}) -``` - -## API - -This is the current API, currently extracted from Koa and subject to change. - -All errors inherit from JavaScript `Error` and the exported `createError.HttpError`. - -### Error Properties - -- `expose` - can be used to signal if `message` should be sent to the client, defaulting to `false` when `status` >= 500 -- `message` -- `status` and `statusCode` - the status code of the error, defaulting to `500` - -### createError([status], [message], [properties]) - -```js -var err = createError(404, 'This video does not exist!'); -``` - -- `status: 500` - the status code as a number -- `message` - the message of the error, defaulting to node's text for that status code. -- `properties` - custom properties to attach to the object - -### new createError\[code || name\](\[msg]\)) - -```js -var err = new createError.NotFound(); -``` - -- `code` - the status code as a number -- `name` - the name of the error as a "bumpy case", i.e. `NotFound` or `InternalServerError`. - -#### List of all constructors - -|Status Code|Constructor Name | -|-----------|-----------------------------| -|400 |BadRequest | -|401 |Unauthorized | -|402 |PaymentRequired | -|403 |Forbidden | -|404 |NotFound | -|405 |MethodNotAllowed | -|406 |NotAcceptable | -|407 |ProxyAuthenticationRequired | -|408 |RequestTimeout | -|409 |Conflict | -|410 |Gone | -|411 |LengthRequired | -|412 |PreconditionFailed | -|413 |PayloadTooLarge | -|414 |URITooLong | -|415 |UnsupportedMediaType | -|416 |RangeNotSatisfiable | -|417 |ExpectationFailed | -|418 |ImATeapot | -|421 |MisdirectedRequest | -|422 |UnprocessableEntity | -|423 |Locked | -|424 |FailedDependency | -|425 |UnorderedCollection | -|426 |UpgradeRequired | -|428 |PreconditionRequired | -|429 |TooManyRequests | -|431 |RequestHeaderFieldsTooLarge | -|451 |UnavailableForLegalReasons | -|500 |InternalServerError | -|501 |NotImplemented | -|502 |BadGateway | -|503 |ServiceUnavailable | -|504 |GatewayTimeout | -|505 |HTTPVersionNotSupported | -|506 |VariantAlsoNegotiates | -|507 |InsufficientStorage | -|508 |LoopDetected | -|509 |BandwidthLimitExceeded | -|510 |NotExtended | -|511 |NetworkAuthenticationRequired| - -## License - -[MIT](LICENSE) - -[npm-image]: https://img.shields.io/npm/v/http-errors.svg?style=flat -[npm-url]: https://npmjs.org/package/http-errors -[node-version-image]: https://img.shields.io/node/v/http-errors.svg?style=flat -[node-version-url]: https://nodejs.org/en/download/ -[travis-image]: https://img.shields.io/travis/jshttp/http-errors.svg?style=flat -[travis-url]: https://travis-ci.org/jshttp/http-errors -[coveralls-image]: https://img.shields.io/coveralls/jshttp/http-errors.svg?style=flat -[coveralls-url]: https://coveralls.io/r/jshttp/http-errors -[downloads-image]: https://img.shields.io/npm/dm/http-errors.svg?style=flat -[downloads-url]: https://npmjs.org/package/http-errors +# http-errors + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-version-image]][node-version-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +Create HTTP errors for Express, Koa, Connect, etc. with ease. + +## Example + +```js +var createError = require('http-errors'); + +app.use(function (req, res, next) { + if (!req.user) return next(createError(401, 'Please login to view this page.')); + next(); +}) +``` + +## API + +This is the current API, currently extracted from Koa and subject to change. + +All errors inherit from JavaScript `Error` and the exported `createError.HttpError`. + +### Error Properties + +- `expose` - can be used to signal if `message` should be sent to the client, defaulting to `false` when `status` >= 500 +- `message` +- `status` and `statusCode` - the status code of the error, defaulting to `500` + +### createError([status], [message], [properties]) + +```js +var err = createError(404, 'This video does not exist!'); +``` + +- `status: 500` - the status code as a number +- `message` - the message of the error, defaulting to node's text for that status code. +- `properties` - custom properties to attach to the object + +### new createError\[code || name\](\[msg]\)) + +```js +var err = new createError.NotFound(); +``` + +- `code` - the status code as a number +- `name` - the name of the error as a "bumpy case", i.e. `NotFound` or `InternalServerError`. + +#### List of all constructors + +|Status Code|Constructor Name | +|-----------|-----------------------------| +|400 |BadRequest | +|401 |Unauthorized | +|402 |PaymentRequired | +|403 |Forbidden | +|404 |NotFound | +|405 |MethodNotAllowed | +|406 |NotAcceptable | +|407 |ProxyAuthenticationRequired | +|408 |RequestTimeout | +|409 |Conflict | +|410 |Gone | +|411 |LengthRequired | +|412 |PreconditionFailed | +|413 |PayloadTooLarge | +|414 |URITooLong | +|415 |UnsupportedMediaType | +|416 |RangeNotSatisfiable | +|417 |ExpectationFailed | +|418 |ImATeapot | +|421 |MisdirectedRequest | +|422 |UnprocessableEntity | +|423 |Locked | +|424 |FailedDependency | +|425 |UnorderedCollection | +|426 |UpgradeRequired | +|428 |PreconditionRequired | +|429 |TooManyRequests | +|431 |RequestHeaderFieldsTooLarge | +|451 |UnavailableForLegalReasons | +|500 |InternalServerError | +|501 |NotImplemented | +|502 |BadGateway | +|503 |ServiceUnavailable | +|504 |GatewayTimeout | +|505 |HTTPVersionNotSupported | +|506 |VariantAlsoNegotiates | +|507 |InsufficientStorage | +|508 |LoopDetected | +|509 |BandwidthLimitExceeded | +|510 |NotExtended | +|511 |NetworkAuthenticationRequired| + +## License + +[MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/http-errors.svg?style=flat +[npm-url]: https://npmjs.org/package/http-errors +[node-version-image]: https://img.shields.io/node/v/http-errors.svg?style=flat +[node-version-url]: https://nodejs.org/en/download/ +[travis-image]: https://img.shields.io/travis/jshttp/http-errors.svg?style=flat +[travis-url]: https://travis-ci.org/jshttp/http-errors +[coveralls-image]: https://img.shields.io/coveralls/jshttp/http-errors.svg?style=flat +[coveralls-url]: https://coveralls.io/r/jshttp/http-errors +[downloads-image]: https://img.shields.io/npm/dm/http-errors.svg?style=flat +[downloads-url]: https://npmjs.org/package/http-errors diff --git a/ui/node_modules/express/node_modules/send/node_modules/http-errors/index.js b/ui/node_modules/express/node_modules/send/node_modules/http-errors/index.js index f3ac1535..6130db8a 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/http-errors/index.js +++ b/ui/node_modules/express/node_modules/send/node_modules/http-errors/index.js @@ -1,223 +1,223 @@ -/*! - * http-errors - * Copyright(c) 2014 Jonathan Ong - * Copyright(c) 2016 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict' - -/** - * Module dependencies. - * @private - */ - -var setPrototypeOf = require('setprototypeof') -var statuses = require('statuses') -var inherits = require('inherits') - -/** - * Module exports. - * @public - */ - -module.exports = createError -module.exports.HttpError = createHttpErrorConstructor() - -// Populate exports for all constructors -populateConstructorExports(module.exports, statuses.codes, module.exports.HttpError) - -/** - * Create a new HTTP Error. - * - * @returns {Error} - * @public - */ - -function createError () { - // so much arity going on ~_~ - var err - var msg - var status = 500 - var props = {} - for (var i = 0; i < arguments.length; i++) { - var arg = arguments[i] - if (arg instanceof Error) { - err = arg - status = err.status || err.statusCode || status - continue - } - switch (typeof arg) { - case 'string': - msg = arg - break - case 'number': - status = arg - break - case 'object': - props = arg - break - } - } - - if (typeof status !== 'number' || !statuses[status]) { - status = 500 - } - - // constructor - var HttpError = createError[status] - - if (!err) { - // create error - err = HttpError - ? new HttpError(msg) - : new Error(msg || statuses[status]) - Error.captureStackTrace(err, createError) - } - - if (!HttpError || !(err instanceof HttpError)) { - // add properties to generic error - err.expose = status < 500 - err.status = err.statusCode = status - } - - for (var key in props) { - if (key !== 'status' && key !== 'statusCode') { - err[key] = props[key] - } - } - - return err -} - -/** - * Create HTTP error abstract base class. - * @private - */ - -function createHttpErrorConstructor () { - function HttpError () { - throw new TypeError('cannot construct abstract class') - } - - inherits(HttpError, Error) - - return HttpError -} - -/** - * Create a constructor for a client error. - * @private - */ - -function createClientErrorConstructor (HttpError, name, code) { - var className = name.match(/Error$/) ? name : name + 'Error' - - function ClientError (message) { - // create the error object - var err = new Error(message != null ? message : statuses[code]) - - // capture a stack trace to the construction point - Error.captureStackTrace(err, ClientError) - - // adjust the [[Prototype]] - setPrototypeOf(err, ClientError.prototype) - - // redefine the error name - Object.defineProperty(err, 'name', { - enumerable: false, - configurable: true, - value: className, - writable: true - }) - - return err - } - - inherits(ClientError, HttpError) - - ClientError.prototype.status = code - ClientError.prototype.statusCode = code - ClientError.prototype.expose = true - - return ClientError -} - -/** - * Create a constructor for a server error. - * @private - */ - -function createServerErrorConstructor (HttpError, name, code) { - var className = name.match(/Error$/) ? name : name + 'Error' - - function ServerError (message) { - // create the error object - var err = new Error(message != null ? message : statuses[code]) - - // capture a stack trace to the construction point - Error.captureStackTrace(err, ServerError) - - // adjust the [[Prototype]] - setPrototypeOf(err, ServerError.prototype) - - // redefine the error name - Object.defineProperty(err, 'name', { - enumerable: false, - configurable: true, - value: className, - writable: true - }) - - return err - } - - inherits(ServerError, HttpError) - - ServerError.prototype.status = code - ServerError.prototype.statusCode = code - ServerError.prototype.expose = false - - return ServerError -} - -/** - * Populate the exports object with constructors for every error class. - * @private - */ - -function populateConstructorExports (exports, codes, HttpError) { - codes.forEach(function forEachCode (code) { - var CodeError - var name = toIdentifier(statuses[code]) - - switch (String(code).charAt(0)) { - case '4': - CodeError = createClientErrorConstructor(HttpError, name, code) - break - case '5': - CodeError = createServerErrorConstructor(HttpError, name, code) - break - } - - if (CodeError) { - // export the constructor - exports[code] = CodeError - exports[name] = CodeError - } - }) - - // backwards-compatibility - exports["I'mateapot"] = exports.ImATeapot -} - -/** - * Convert a string of words to a JavaScript identifier. - * @private - */ - -function toIdentifier (str) { - return str.split(' ').map(function (token) { - return token.slice(0, 1).toUpperCase() + token.slice(1) - }).join('').replace(/[^ _0-9a-z]/gi, '') -} +/*! + * http-errors + * Copyright(c) 2014 Jonathan Ong + * Copyright(c) 2016 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module dependencies. + * @private + */ + +var setPrototypeOf = require('setprototypeof') +var statuses = require('statuses') +var inherits = require('inherits') + +/** + * Module exports. + * @public + */ + +module.exports = createError +module.exports.HttpError = createHttpErrorConstructor() + +// Populate exports for all constructors +populateConstructorExports(module.exports, statuses.codes, module.exports.HttpError) + +/** + * Create a new HTTP Error. + * + * @returns {Error} + * @public + */ + +function createError () { + // so much arity going on ~_~ + var err + var msg + var status = 500 + var props = {} + for (var i = 0; i < arguments.length; i++) { + var arg = arguments[i] + if (arg instanceof Error) { + err = arg + status = err.status || err.statusCode || status + continue + } + switch (typeof arg) { + case 'string': + msg = arg + break + case 'number': + status = arg + break + case 'object': + props = arg + break + } + } + + if (typeof status !== 'number' || !statuses[status]) { + status = 500 + } + + // constructor + var HttpError = createError[status] + + if (!err) { + // create error + err = HttpError + ? new HttpError(msg) + : new Error(msg || statuses[status]) + Error.captureStackTrace(err, createError) + } + + if (!HttpError || !(err instanceof HttpError)) { + // add properties to generic error + err.expose = status < 500 + err.status = err.statusCode = status + } + + for (var key in props) { + if (key !== 'status' && key !== 'statusCode') { + err[key] = props[key] + } + } + + return err +} + +/** + * Create HTTP error abstract base class. + * @private + */ + +function createHttpErrorConstructor () { + function HttpError () { + throw new TypeError('cannot construct abstract class') + } + + inherits(HttpError, Error) + + return HttpError +} + +/** + * Create a constructor for a client error. + * @private + */ + +function createClientErrorConstructor (HttpError, name, code) { + var className = name.match(/Error$/) ? name : name + 'Error' + + function ClientError (message) { + // create the error object + var err = new Error(message != null ? message : statuses[code]) + + // capture a stack trace to the construction point + Error.captureStackTrace(err, ClientError) + + // adjust the [[Prototype]] + setPrototypeOf(err, ClientError.prototype) + + // redefine the error name + Object.defineProperty(err, 'name', { + enumerable: false, + configurable: true, + value: className, + writable: true + }) + + return err + } + + inherits(ClientError, HttpError) + + ClientError.prototype.status = code + ClientError.prototype.statusCode = code + ClientError.prototype.expose = true + + return ClientError +} + +/** + * Create a constructor for a server error. + * @private + */ + +function createServerErrorConstructor (HttpError, name, code) { + var className = name.match(/Error$/) ? name : name + 'Error' + + function ServerError (message) { + // create the error object + var err = new Error(message != null ? message : statuses[code]) + + // capture a stack trace to the construction point + Error.captureStackTrace(err, ServerError) + + // adjust the [[Prototype]] + setPrototypeOf(err, ServerError.prototype) + + // redefine the error name + Object.defineProperty(err, 'name', { + enumerable: false, + configurable: true, + value: className, + writable: true + }) + + return err + } + + inherits(ServerError, HttpError) + + ServerError.prototype.status = code + ServerError.prototype.statusCode = code + ServerError.prototype.expose = false + + return ServerError +} + +/** + * Populate the exports object with constructors for every error class. + * @private + */ + +function populateConstructorExports (exports, codes, HttpError) { + codes.forEach(function forEachCode (code) { + var CodeError + var name = toIdentifier(statuses[code]) + + switch (String(code).charAt(0)) { + case '4': + CodeError = createClientErrorConstructor(HttpError, name, code) + break + case '5': + CodeError = createServerErrorConstructor(HttpError, name, code) + break + } + + if (CodeError) { + // export the constructor + exports[code] = CodeError + exports[name] = CodeError + } + }) + + // backwards-compatibility + exports["I'mateapot"] = exports.ImATeapot +} + +/** + * Convert a string of words to a JavaScript identifier. + * @private + */ + +function toIdentifier (str) { + return str.split(' ').map(function (token) { + return token.slice(0, 1).toUpperCase() + token.slice(1) + }).join('').replace(/[^ _0-9a-z]/gi, '') +} diff --git a/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/LICENSE b/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/LICENSE index 1d68a100..dea3013d 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/LICENSE +++ b/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/LICENSE @@ -1,16 +1,16 @@ -The ISC License - -Copyright (c) Isaac Z. Schlueter - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. - +The ISC License + +Copyright (c) Isaac Z. Schlueter + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. + diff --git a/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/README.md b/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/README.md index b41e30c2..b1c56658 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/README.md +++ b/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/README.md @@ -1,42 +1,42 @@ -Browser-friendly inheritance fully compatible with standard node.js -[inherits](http://nodejs.org/api/util.html#util_util_inherits_constructor_superconstructor). - -This package exports standard `inherits` from node.js `util` module in -node environment, but also provides alternative browser-friendly -implementation through [browser -field](https://gist.github.com/shtylman/4339901). Alternative -implementation is a literal copy of standard one located in standalone -module to avoid requiring of `util`. It also has a shim for old -browsers with no `Object.create` support. - -While keeping you sure you are using standard `inherits` -implementation in node.js environment, it allows bundlers such as -[browserify](https://github.com/substack/node-browserify) to not -include full `util` package to your client code if all you need is -just `inherits` function. It worth, because browser shim for `util` -package is large and `inherits` is often the single function you need -from it. - -It's recommended to use this package instead of -`require('util').inherits` for any code that has chances to be used -not only in node.js but in browser too. - -## usage - -```js -var inherits = require('inherits'); -// then use exactly as the standard one -``` - -## note on version ~1.0 - -Version ~1.0 had completely different motivation and is not compatible -neither with 2.0 nor with standard node.js `inherits`. - -If you are using version ~1.0 and planning to switch to ~2.0, be -careful: - -* new version uses `super_` instead of `super` for referencing - superclass -* new version overwrites current prototype while old one preserves any - existing fields on it +Browser-friendly inheritance fully compatible with standard node.js +[inherits](http://nodejs.org/api/util.html#util_util_inherits_constructor_superconstructor). + +This package exports standard `inherits` from node.js `util` module in +node environment, but also provides alternative browser-friendly +implementation through [browser +field](https://gist.github.com/shtylman/4339901). Alternative +implementation is a literal copy of standard one located in standalone +module to avoid requiring of `util`. It also has a shim for old +browsers with no `Object.create` support. + +While keeping you sure you are using standard `inherits` +implementation in node.js environment, it allows bundlers such as +[browserify](https://github.com/substack/node-browserify) to not +include full `util` package to your client code if all you need is +just `inherits` function. It worth, because browser shim for `util` +package is large and `inherits` is often the single function you need +from it. + +It's recommended to use this package instead of +`require('util').inherits` for any code that has chances to be used +not only in node.js but in browser too. + +## usage + +```js +var inherits = require('inherits'); +// then use exactly as the standard one +``` + +## note on version ~1.0 + +Version ~1.0 had completely different motivation and is not compatible +neither with 2.0 nor with standard node.js `inherits`. + +If you are using version ~1.0 and planning to switch to ~2.0, be +careful: + +* new version uses `super_` instead of `super` for referencing + superclass +* new version overwrites current prototype while old one preserves any + existing fields on it diff --git a/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/inherits.js b/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/inherits.js index 1b61effa..29f5e24f 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/inherits.js +++ b/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/inherits.js @@ -1 +1 @@ -module.exports = require('util').inherits +module.exports = require('util').inherits diff --git a/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/inherits_browser.js b/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/inherits_browser.js index 1464d7f3..c1e78a75 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/inherits_browser.js +++ b/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/inherits_browser.js @@ -1,23 +1,23 @@ -if (typeof Object.create === 'function') { - // implementation from standard node.js 'util' module - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - ctor.prototype = Object.create(superCtor.prototype, { - constructor: { - value: ctor, - enumerable: false, - writable: true, - configurable: true - } - }); - }; -} else { - // old school shim for old browsers - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - var TempCtor = function () {} - TempCtor.prototype = superCtor.prototype - ctor.prototype = new TempCtor() - ctor.prototype.constructor = ctor - } -} +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } +} diff --git a/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/package.json b/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/package.json index 24b11a1a..b7b5b014 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/package.json +++ b/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/package.json @@ -1,50 +1,50 @@ -{ - "name": "inherits", - "description": "Browser-friendly inheritance fully compatible with standard node.js inherits()", - "version": "2.0.1", - "keywords": [ - "inheritance", - "class", - "klass", - "oop", - "object-oriented", - "inherits", - "browser", - "browserify" - ], - "main": "./inherits.js", - "browser": "./inherits_browser.js", - "repository": { - "type": "git", - "url": "git://github.com/isaacs/inherits.git" - }, - "license": "ISC", - "scripts": { - "test": "node test" - }, - "bugs": { - "url": "https://github.com/isaacs/inherits/issues" - }, - "_id": "inherits@2.0.1", - "dist": { - "shasum": "b17d08d326b4423e568eff719f91b0b1cbdf69f1", - "tarball": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" - }, - "_from": "inherits@2.0.1", - "_npmVersion": "1.3.8", - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "directories": {}, - "_shasum": "b17d08d326b4423e568eff719f91b0b1cbdf69f1", - "_resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", - "readme": "ERROR: No README data found!", - "homepage": "https://github.com/isaacs/inherits#readme" -} +{ + "name": "inherits", + "description": "Browser-friendly inheritance fully compatible with standard node.js inherits()", + "version": "2.0.1", + "keywords": [ + "inheritance", + "class", + "klass", + "oop", + "object-oriented", + "inherits", + "browser", + "browserify" + ], + "main": "./inherits.js", + "browser": "./inherits_browser.js", + "repository": { + "type": "git", + "url": "git://github.com/isaacs/inherits.git" + }, + "license": "ISC", + "scripts": { + "test": "node test" + }, + "bugs": { + "url": "https://github.com/isaacs/inherits/issues" + }, + "_id": "inherits@2.0.1", + "dist": { + "shasum": "b17d08d326b4423e568eff719f91b0b1cbdf69f1", + "tarball": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" + }, + "_from": "inherits@2.0.1", + "_npmVersion": "1.3.8", + "_npmUser": { + "name": "isaacs", + "email": "i@izs.me" + }, + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + } + ], + "directories": {}, + "_shasum": "b17d08d326b4423e568eff719f91b0b1cbdf69f1", + "_resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", + "readme": "ERROR: No README data found!", + "homepage": "https://github.com/isaacs/inherits#readme" +} diff --git a/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/test.js b/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/test.js index 347dd1f2..fc53012d 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/test.js +++ b/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/test.js @@ -1,25 +1,25 @@ -var inherits = require('./inherits.js') -var assert = require('assert') - -function test(c) { - assert(c.constructor === Child) - assert(c.constructor.super_ === Parent) - assert(Object.getPrototypeOf(c) === Child.prototype) - assert(Object.getPrototypeOf(Object.getPrototypeOf(c)) === Parent.prototype) - assert(c instanceof Child) - assert(c instanceof Parent) -} - -function Child() { - Parent.call(this) - test(this) -} - -function Parent() {} - -inherits(Child, Parent) - -var c = new Child -test(c) - -console.log('ok') +var inherits = require('./inherits.js') +var assert = require('assert') + +function test(c) { + assert(c.constructor === Child) + assert(c.constructor.super_ === Parent) + assert(Object.getPrototypeOf(c) === Child.prototype) + assert(Object.getPrototypeOf(Object.getPrototypeOf(c)) === Parent.prototype) + assert(c instanceof Child) + assert(c instanceof Parent) +} + +function Child() { + Parent.call(this) + test(this) +} + +function Parent() {} + +inherits(Child, Parent) + +var c = new Child +test(c) + +console.log('ok') diff --git a/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/setprototypeof/LICENSE b/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/setprototypeof/LICENSE index ca5879a6..61afa2f1 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/setprototypeof/LICENSE +++ b/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/setprototypeof/LICENSE @@ -1,13 +1,13 @@ -Copyright (c) 2015, Wes Todd - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION -OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN -CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +Copyright (c) 2015, Wes Todd + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/setprototypeof/README.md b/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/setprototypeof/README.md index 9a123d08..01d79470 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/setprototypeof/README.md +++ b/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/setprototypeof/README.md @@ -1,21 +1,21 @@ -# Polyfill for `Object.setPrototypeOf` - -A simple cross platform implementation to set the prototype of an instianted object. Supports all modern browsers and at least back to IE8. - -## Usage: - -``` -$ npm install --save setprototypeof -``` - -```javascript -var setPrototypeOf = require('setprototypeof'); - -var obj = {}; -setPrototypeOf(obj, { - foo: function() { - return 'bar'; - } -}); -obj.foo(); // bar -``` +# Polyfill for `Object.setPrototypeOf` + +A simple cross platform implementation to set the prototype of an instianted object. Supports all modern browsers and at least back to IE8. + +## Usage: + +``` +$ npm install --save setprototypeof +``` + +```javascript +var setPrototypeOf = require('setprototypeof'); + +var obj = {}; +setPrototypeOf(obj, { + foo: function() { + return 'bar'; + } +}); +obj.foo(); // bar +``` diff --git a/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/setprototypeof/index.js b/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/setprototypeof/index.js index 2f309b73..086a879a 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/setprototypeof/index.js +++ b/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/setprototypeof/index.js @@ -1,11 +1,11 @@ -module.exports = Object.setPrototypeOf || ({__proto__:[]} instanceof Array ? setProtoOf : mixinProperties); - -function setProtoOf(obj, proto) { - obj.__proto__ = proto; -} - -function mixinProperties(obj, proto) { - for (var prop in proto) { - obj[prop] = proto[prop]; - } -} +module.exports = Object.setPrototypeOf || ({__proto__:[]} instanceof Array ? setProtoOf : mixinProperties); + +function setProtoOf(obj, proto) { + obj.__proto__ = proto; +} + +function mixinProperties(obj, proto) { + for (var prop in proto) { + obj[prop] = proto[prop]; + } +} diff --git a/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/setprototypeof/package.json b/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/setprototypeof/package.json index 3b76c865..643ae9f0 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/setprototypeof/package.json +++ b/ui/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/setprototypeof/package.json @@ -1,53 +1,53 @@ -{ - "name": "setprototypeof", - "version": "1.0.1", - "description": "A small polyfill for Object.setprototypeof", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/wesleytodd/setprototypeof.git" - }, - "keywords": [ - "polyfill", - "object", - "setprototypeof" - ], - "author": { - "name": "Wes Todd" - }, - "license": "ISC", - "bugs": { - "url": "https://github.com/wesleytodd/setprototypeof/issues" - }, - "homepage": "https://github.com/wesleytodd/setprototypeof", - "gitHead": "1e3d0cde6b7f4a9fba10cd28e62b200c9d8f899f", - "_id": "setprototypeof@1.0.1", - "_shasum": "52009b27888c4dc48f591949c0a8275834c1ca7e", - "_from": "setprototypeof@1.0.1", - "_npmVersion": "3.3.6", - "_nodeVersion": "5.0.0", - "_npmUser": { - "name": "wesleytodd", - "email": "wes@wesleytodd.com" - }, - "dist": { - "shasum": "52009b27888c4dc48f591949c0a8275834c1ca7e", - "tarball": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.1.tgz" - }, - "maintainers": [ - { - "name": "wesleytodd", - "email": "wes@wesleytodd.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-5-east.internal.npmjs.com", - "tmp": "tmp/setprototypeof-1.0.1.tgz_1454803015119_0.7522649802267551" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.1.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "setprototypeof", + "version": "1.0.1", + "description": "A small polyfill for Object.setprototypeof", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/wesleytodd/setprototypeof.git" + }, + "keywords": [ + "polyfill", + "object", + "setprototypeof" + ], + "author": { + "name": "Wes Todd" + }, + "license": "ISC", + "bugs": { + "url": "https://github.com/wesleytodd/setprototypeof/issues" + }, + "homepage": "https://github.com/wesleytodd/setprototypeof", + "gitHead": "1e3d0cde6b7f4a9fba10cd28e62b200c9d8f899f", + "_id": "setprototypeof@1.0.1", + "_shasum": "52009b27888c4dc48f591949c0a8275834c1ca7e", + "_from": "setprototypeof@1.0.1", + "_npmVersion": "3.3.6", + "_nodeVersion": "5.0.0", + "_npmUser": { + "name": "wesleytodd", + "email": "wes@wesleytodd.com" + }, + "dist": { + "shasum": "52009b27888c4dc48f591949c0a8275834c1ca7e", + "tarball": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.1.tgz" + }, + "maintainers": [ + { + "name": "wesleytodd", + "email": "wes@wesleytodd.com" + } + ], + "_npmOperationalInternal": { + "host": "packages-5-east.internal.npmjs.com", + "tmp": "tmp/setprototypeof-1.0.1.tgz_1454803015119_0.7522649802267551" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.1.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/send/node_modules/http-errors/package.json b/ui/node_modules/express/node_modules/send/node_modules/http-errors/package.json index cdfcb884..245ddac8 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/http-errors/package.json +++ b/ui/node_modules/express/node_modules/send/node_modules/http-errors/package.json @@ -1,96 +1,96 @@ -{ - "name": "http-errors", - "description": "Create HTTP error objects", - "version": "1.5.0", - "author": { - "name": "Jonathan Ong", - "email": "me@jongleberry.com", - "url": "http://jongleberry.com" - }, - "contributors": [ - { - "name": "Alan Plum", - "email": "me@pluma.io" - }, - { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - } - ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/http-errors.git" - }, - "dependencies": { - "inherits": "2.0.1", - "setprototypeof": "1.0.1", - "statuses": ">= 1.3.0 < 2" - }, - "devDependencies": { - "eslint": "2.10.2", - "eslint-config-standard": "5.3.1", - "eslint-plugin-promise": "1.1.0", - "eslint-plugin-standard": "1.3.2", - "istanbul": "0.4.3", - "mocha": "1.21.5" - }, - "engines": { - "node": ">= 0.6" - }, - "scripts": { - "lint": "eslint **/*.js", - "test": "mocha --reporter spec --bail", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot" - }, - "keywords": [ - "http", - "error" - ], - "files": [ - "index.js", - "HISTORY.md", - "LICENSE", - "README.md" - ], - "gitHead": "1a826d7ac31dde16931b9c566041697939ebd0e0", - "bugs": { - "url": "https://github.com/jshttp/http-errors/issues" - }, - "homepage": "https://github.com/jshttp/http-errors#readme", - "_id": "http-errors@1.5.0", - "_shasum": "b1cb3d8260fd8e2386cad3189045943372d48211", - "_from": "http-errors@>=1.5.0 <1.6.0", - "_npmVersion": "2.15.1", - "_nodeVersion": "4.4.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "b1cb3d8260fd8e2386cad3189045943372d48211", - "tarball": "https://registry.npmjs.org/http-errors/-/http-errors-1.5.0.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "egeste", - "email": "npm@egeste.net" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/http-errors-1.5.0.tgz_1463621678183_0.44013352948240936" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.5.0.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "http-errors", + "description": "Create HTTP error objects", + "version": "1.5.0", + "author": { + "name": "Jonathan Ong", + "email": "me@jongleberry.com", + "url": "http://jongleberry.com" + }, + "contributors": [ + { + "name": "Alan Plum", + "email": "me@pluma.io" + }, + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + } + ], + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/http-errors.git" + }, + "dependencies": { + "inherits": "2.0.1", + "setprototypeof": "1.0.1", + "statuses": ">= 1.3.0 < 2" + }, + "devDependencies": { + "eslint": "2.10.2", + "eslint-config-standard": "5.3.1", + "eslint-plugin-promise": "1.1.0", + "eslint-plugin-standard": "1.3.2", + "istanbul": "0.4.3", + "mocha": "1.21.5" + }, + "engines": { + "node": ">= 0.6" + }, + "scripts": { + "lint": "eslint **/*.js", + "test": "mocha --reporter spec --bail", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot" + }, + "keywords": [ + "http", + "error" + ], + "files": [ + "index.js", + "HISTORY.md", + "LICENSE", + "README.md" + ], + "gitHead": "1a826d7ac31dde16931b9c566041697939ebd0e0", + "bugs": { + "url": "https://github.com/jshttp/http-errors/issues" + }, + "homepage": "https://github.com/jshttp/http-errors#readme", + "_id": "http-errors@1.5.0", + "_shasum": "b1cb3d8260fd8e2386cad3189045943372d48211", + "_from": "http-errors@>=1.5.0 <1.6.0", + "_npmVersion": "2.15.1", + "_nodeVersion": "4.4.3", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "dist": { + "shasum": "b1cb3d8260fd8e2386cad3189045943372d48211", + "tarball": "https://registry.npmjs.org/http-errors/-/http-errors-1.5.0.tgz" + }, + "maintainers": [ + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "egeste", + "email": "npm@egeste.net" + }, + { + "name": "jongleberry", + "email": "jonathanrichardong@gmail.com" + } + ], + "_npmOperationalInternal": { + "host": "packages-16-east.internal.npmjs.com", + "tmp": "tmp/http-errors-1.5.0.tgz_1463621678183_0.44013352948240936" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.5.0.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/send/node_modules/mime/LICENSE b/ui/node_modules/express/node_modules/send/node_modules/mime/LICENSE index 42100279..451fc455 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/mime/LICENSE +++ b/ui/node_modules/express/node_modules/send/node_modules/mime/LICENSE @@ -1,19 +1,19 @@ -Copyright (c) 2010 Benjamin Thomas, Robert Kieffer - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. +Copyright (c) 2010 Benjamin Thomas, Robert Kieffer + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/send/node_modules/mime/README.md b/ui/node_modules/express/node_modules/send/node_modules/mime/README.md index dffa79b3..506fbe55 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/mime/README.md +++ b/ui/node_modules/express/node_modules/send/node_modules/mime/README.md @@ -1,90 +1,90 @@ -# mime - -Comprehensive MIME type mapping API based on mime-db module. - -## Install - -Install with [npm](http://github.com/isaacs/npm): - - npm install mime - -## Contributing / Testing - - npm run test - -## Command Line - - mime [path_string] - -E.g. - - > mime scripts/jquery.js - application/javascript - -## API - Queries - -### mime.lookup(path) -Get the mime type associated with a file, if no mime type is found `application/octet-stream` is returned. Performs a case-insensitive lookup using the extension in `path` (the substring after the last '/' or '.'). E.g. - -```js -var mime = require('mime'); - -mime.lookup('/path/to/file.txt'); // => 'text/plain' -mime.lookup('file.txt'); // => 'text/plain' -mime.lookup('.TXT'); // => 'text/plain' -mime.lookup('htm'); // => 'text/html' -``` - -### mime.default_type -Sets the mime type returned when `mime.lookup` fails to find the extension searched for. (Default is `application/octet-stream`.) - -### mime.extension(type) -Get the default extension for `type` - -```js -mime.extension('text/html'); // => 'html' -mime.extension('application/octet-stream'); // => 'bin' -``` - -### mime.charsets.lookup() - -Map mime-type to charset - -```js -mime.charsets.lookup('text/plain'); // => 'UTF-8' -``` - -(The logic for charset lookups is pretty rudimentary. Feel free to suggest improvements.) - -## API - Defining Custom Types - -Custom type mappings can be added on a per-project basis via the following APIs. - -### mime.define() - -Add custom mime/extension mappings - -```js -mime.define({ - 'text/x-some-format': ['x-sf', 'x-sft', 'x-sfml'], - 'application/x-my-type': ['x-mt', 'x-mtt'], - // etc ... -}); - -mime.lookup('x-sft'); // => 'text/x-some-format' -``` - -The first entry in the extensions array is returned by `mime.extension()`. E.g. - -```js -mime.extension('text/x-some-format'); // => 'x-sf' -``` - -### mime.load(filepath) - -Load mappings from an Apache ".types" format file - -```js -mime.load('./my_project.types'); -``` -The .types file format is simple - See the `types` dir for examples. +# mime + +Comprehensive MIME type mapping API based on mime-db module. + +## Install + +Install with [npm](http://github.com/isaacs/npm): + + npm install mime + +## Contributing / Testing + + npm run test + +## Command Line + + mime [path_string] + +E.g. + + > mime scripts/jquery.js + application/javascript + +## API - Queries + +### mime.lookup(path) +Get the mime type associated with a file, if no mime type is found `application/octet-stream` is returned. Performs a case-insensitive lookup using the extension in `path` (the substring after the last '/' or '.'). E.g. + +```js +var mime = require('mime'); + +mime.lookup('/path/to/file.txt'); // => 'text/plain' +mime.lookup('file.txt'); // => 'text/plain' +mime.lookup('.TXT'); // => 'text/plain' +mime.lookup('htm'); // => 'text/html' +``` + +### mime.default_type +Sets the mime type returned when `mime.lookup` fails to find the extension searched for. (Default is `application/octet-stream`.) + +### mime.extension(type) +Get the default extension for `type` + +```js +mime.extension('text/html'); // => 'html' +mime.extension('application/octet-stream'); // => 'bin' +``` + +### mime.charsets.lookup() + +Map mime-type to charset + +```js +mime.charsets.lookup('text/plain'); // => 'UTF-8' +``` + +(The logic for charset lookups is pretty rudimentary. Feel free to suggest improvements.) + +## API - Defining Custom Types + +Custom type mappings can be added on a per-project basis via the following APIs. + +### mime.define() + +Add custom mime/extension mappings + +```js +mime.define({ + 'text/x-some-format': ['x-sf', 'x-sft', 'x-sfml'], + 'application/x-my-type': ['x-mt', 'x-mtt'], + // etc ... +}); + +mime.lookup('x-sft'); // => 'text/x-some-format' +``` + +The first entry in the extensions array is returned by `mime.extension()`. E.g. + +```js +mime.extension('text/x-some-format'); // => 'x-sf' +``` + +### mime.load(filepath) + +Load mappings from an Apache ".types" format file + +```js +mime.load('./my_project.types'); +``` +The .types file format is simple - See the `types` dir for examples. diff --git a/ui/node_modules/express/node_modules/send/node_modules/mime/build/build.js b/ui/node_modules/express/node_modules/send/node_modules/mime/build/build.js index 7d6e9484..ed5313e3 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/mime/build/build.js +++ b/ui/node_modules/express/node_modules/send/node_modules/mime/build/build.js @@ -1,11 +1,11 @@ -var db = require('mime-db'); - -var mapByType = {}; -Object.keys(db).forEach(function(key) { - var extensions = db[key].extensions; - if (extensions) { - mapByType[key] = extensions; - } -}); - -console.log(JSON.stringify(mapByType)); +var db = require('mime-db'); + +var mapByType = {}; +Object.keys(db).forEach(function(key) { + var extensions = db[key].extensions; + if (extensions) { + mapByType[key] = extensions; + } +}); + +console.log(JSON.stringify(mapByType)); diff --git a/ui/node_modules/express/node_modules/send/node_modules/mime/build/test.js b/ui/node_modules/express/node_modules/send/node_modules/mime/build/test.js index a1ecfa75..58b9ba7c 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/mime/build/test.js +++ b/ui/node_modules/express/node_modules/send/node_modules/mime/build/test.js @@ -1,57 +1,57 @@ -/** - * Usage: node test.js - */ - -var mime = require('../mime'); -var assert = require('assert'); -var path = require('path'); - -// -// Test mime lookups -// - -assert.equal('text/plain', mime.lookup('text.txt')); // normal file -assert.equal('text/plain', mime.lookup('TEXT.TXT')); // uppercase -assert.equal('text/plain', mime.lookup('dir/text.txt')); // dir + file -assert.equal('text/plain', mime.lookup('.text.txt')); // hidden file -assert.equal('text/plain', mime.lookup('.txt')); // nameless -assert.equal('text/plain', mime.lookup('txt')); // extension-only -assert.equal('text/plain', mime.lookup('/txt')); // extension-less () -assert.equal('text/plain', mime.lookup('\\txt')); // Windows, extension-less -assert.equal('application/octet-stream', mime.lookup('text.nope')); // unrecognized -assert.equal('fallback', mime.lookup('text.fallback', 'fallback')); // alternate default - -// -// Test extensions -// - -assert.equal('txt', mime.extension(mime.types.text)); -assert.equal('html', mime.extension(mime.types.htm)); -assert.equal('bin', mime.extension('application/octet-stream')); -assert.equal('bin', mime.extension('application/octet-stream ')); -assert.equal('html', mime.extension(' text/html; charset=UTF-8')); -assert.equal('html', mime.extension('text/html; charset=UTF-8 ')); -assert.equal('html', mime.extension('text/html; charset=UTF-8')); -assert.equal('html', mime.extension('text/html ; charset=UTF-8')); -assert.equal('html', mime.extension('text/html;charset=UTF-8')); -assert.equal('html', mime.extension('text/Html;charset=UTF-8')); -assert.equal(undefined, mime.extension('unrecognized')); - -// -// Test node.types lookups -// - -assert.equal('application/font-woff', mime.lookup('file.woff')); -assert.equal('application/octet-stream', mime.lookup('file.buffer')); -assert.equal('audio/mp4', mime.lookup('file.m4a')); -assert.equal('font/opentype', mime.lookup('file.otf')); - -// -// Test charsets -// - -assert.equal('UTF-8', mime.charsets.lookup('text/plain')); -assert.equal(undefined, mime.charsets.lookup(mime.types.js)); -assert.equal('fallback', mime.charsets.lookup('application/octet-stream', 'fallback')); - -console.log('\nAll tests passed'); +/** + * Usage: node test.js + */ + +var mime = require('../mime'); +var assert = require('assert'); +var path = require('path'); + +// +// Test mime lookups +// + +assert.equal('text/plain', mime.lookup('text.txt')); // normal file +assert.equal('text/plain', mime.lookup('TEXT.TXT')); // uppercase +assert.equal('text/plain', mime.lookup('dir/text.txt')); // dir + file +assert.equal('text/plain', mime.lookup('.text.txt')); // hidden file +assert.equal('text/plain', mime.lookup('.txt')); // nameless +assert.equal('text/plain', mime.lookup('txt')); // extension-only +assert.equal('text/plain', mime.lookup('/txt')); // extension-less () +assert.equal('text/plain', mime.lookup('\\txt')); // Windows, extension-less +assert.equal('application/octet-stream', mime.lookup('text.nope')); // unrecognized +assert.equal('fallback', mime.lookup('text.fallback', 'fallback')); // alternate default + +// +// Test extensions +// + +assert.equal('txt', mime.extension(mime.types.text)); +assert.equal('html', mime.extension(mime.types.htm)); +assert.equal('bin', mime.extension('application/octet-stream')); +assert.equal('bin', mime.extension('application/octet-stream ')); +assert.equal('html', mime.extension(' text/html; charset=UTF-8')); +assert.equal('html', mime.extension('text/html; charset=UTF-8 ')); +assert.equal('html', mime.extension('text/html; charset=UTF-8')); +assert.equal('html', mime.extension('text/html ; charset=UTF-8')); +assert.equal('html', mime.extension('text/html;charset=UTF-8')); +assert.equal('html', mime.extension('text/Html;charset=UTF-8')); +assert.equal(undefined, mime.extension('unrecognized')); + +// +// Test node.types lookups +// + +assert.equal('application/font-woff', mime.lookup('file.woff')); +assert.equal('application/octet-stream', mime.lookup('file.buffer')); +assert.equal('audio/mp4', mime.lookup('file.m4a')); +assert.equal('font/opentype', mime.lookup('file.otf')); + +// +// Test charsets +// + +assert.equal('UTF-8', mime.charsets.lookup('text/plain')); +assert.equal(undefined, mime.charsets.lookup(mime.types.js)); +assert.equal('fallback', mime.charsets.lookup('application/octet-stream', 'fallback')); + +console.log('\nAll tests passed'); diff --git a/ui/node_modules/express/node_modules/send/node_modules/mime/cli.js b/ui/node_modules/express/node_modules/send/node_modules/mime/cli.js old mode 100755 new mode 100644 index 0f0ec803..20b1ffeb --- a/ui/node_modules/express/node_modules/send/node_modules/mime/cli.js +++ b/ui/node_modules/express/node_modules/send/node_modules/mime/cli.js @@ -1,8 +1,8 @@ -#!/usr/bin/env node - -var mime = require('./mime.js'); -var file = process.argv[2]; -var type = mime.lookup(file); - -process.stdout.write(type + '\n'); - +#!/usr/bin/env node + +var mime = require('./mime.js'); +var file = process.argv[2]; +var type = mime.lookup(file); + +process.stdout.write(type + '\n'); + diff --git a/ui/node_modules/express/node_modules/send/node_modules/mime/mime.js b/ui/node_modules/express/node_modules/send/node_modules/mime/mime.js index d0756977..341b6a5c 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/mime/mime.js +++ b/ui/node_modules/express/node_modules/send/node_modules/mime/mime.js @@ -1,108 +1,108 @@ -var path = require('path'); -var fs = require('fs'); - -function Mime() { - // Map of extension -> mime type - this.types = Object.create(null); - - // Map of mime type -> extension - this.extensions = Object.create(null); -} - -/** - * Define mimetype -> extension mappings. Each key is a mime-type that maps - * to an array of extensions associated with the type. The first extension is - * used as the default extension for the type. - * - * e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']}); - * - * @param map (Object) type definitions - */ -Mime.prototype.define = function (map) { - for (var type in map) { - var exts = map[type]; - for (var i = 0; i < exts.length; i++) { - if (process.env.DEBUG_MIME && this.types[exts]) { - console.warn(this._loading.replace(/.*\//, ''), 'changes "' + exts[i] + '" extension type from ' + - this.types[exts] + ' to ' + type); - } - - this.types[exts[i]] = type; - } - - // Default extension is the first one we encounter - if (!this.extensions[type]) { - this.extensions[type] = exts[0]; - } - } -}; - -/** - * Load an Apache2-style ".types" file - * - * This may be called multiple times (it's expected). Where files declare - * overlapping types/extensions, the last file wins. - * - * @param file (String) path of file to load. - */ -Mime.prototype.load = function(file) { - this._loading = file; - // Read file and split into lines - var map = {}, - content = fs.readFileSync(file, 'ascii'), - lines = content.split(/[\r\n]+/); - - lines.forEach(function(line) { - // Clean up whitespace/comments, and split into fields - var fields = line.replace(/\s*#.*|^\s*|\s*$/g, '').split(/\s+/); - map[fields.shift()] = fields; - }); - - this.define(map); - - this._loading = null; -}; - -/** - * Lookup a mime type based on extension - */ -Mime.prototype.lookup = function(path, fallback) { - var ext = path.replace(/.*[\.\/\\]/, '').toLowerCase(); - - return this.types[ext] || fallback || this.default_type; -}; - -/** - * Return file extension associated with a mime type - */ -Mime.prototype.extension = function(mimeType) { - var type = mimeType.match(/^\s*([^;\s]*)(?:;|\s|$)/)[1].toLowerCase(); - return this.extensions[type]; -}; - -// Default instance -var mime = new Mime(); - -// Define built-in types -mime.define(require('./types.json')); - -// Default type -mime.default_type = mime.lookup('bin'); - -// -// Additional API specific to the default instance -// - -mime.Mime = Mime; - -/** - * Lookup a charset based on mime type. - */ -mime.charsets = { - lookup: function(mimeType, fallback) { - // Assume text types are utf8 - return (/^text\//).test(mimeType) ? 'UTF-8' : fallback; - } -}; - -module.exports = mime; +var path = require('path'); +var fs = require('fs'); + +function Mime() { + // Map of extension -> mime type + this.types = Object.create(null); + + // Map of mime type -> extension + this.extensions = Object.create(null); +} + +/** + * Define mimetype -> extension mappings. Each key is a mime-type that maps + * to an array of extensions associated with the type. The first extension is + * used as the default extension for the type. + * + * e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']}); + * + * @param map (Object) type definitions + */ +Mime.prototype.define = function (map) { + for (var type in map) { + var exts = map[type]; + for (var i = 0; i < exts.length; i++) { + if (process.env.DEBUG_MIME && this.types[exts]) { + console.warn(this._loading.replace(/.*\//, ''), 'changes "' + exts[i] + '" extension type from ' + + this.types[exts] + ' to ' + type); + } + + this.types[exts[i]] = type; + } + + // Default extension is the first one we encounter + if (!this.extensions[type]) { + this.extensions[type] = exts[0]; + } + } +}; + +/** + * Load an Apache2-style ".types" file + * + * This may be called multiple times (it's expected). Where files declare + * overlapping types/extensions, the last file wins. + * + * @param file (String) path of file to load. + */ +Mime.prototype.load = function(file) { + this._loading = file; + // Read file and split into lines + var map = {}, + content = fs.readFileSync(file, 'ascii'), + lines = content.split(/[\r\n]+/); + + lines.forEach(function(line) { + // Clean up whitespace/comments, and split into fields + var fields = line.replace(/\s*#.*|^\s*|\s*$/g, '').split(/\s+/); + map[fields.shift()] = fields; + }); + + this.define(map); + + this._loading = null; +}; + +/** + * Lookup a mime type based on extension + */ +Mime.prototype.lookup = function(path, fallback) { + var ext = path.replace(/.*[\.\/\\]/, '').toLowerCase(); + + return this.types[ext] || fallback || this.default_type; +}; + +/** + * Return file extension associated with a mime type + */ +Mime.prototype.extension = function(mimeType) { + var type = mimeType.match(/^\s*([^;\s]*)(?:;|\s|$)/)[1].toLowerCase(); + return this.extensions[type]; +}; + +// Default instance +var mime = new Mime(); + +// Define built-in types +mime.define(require('./types.json')); + +// Default type +mime.default_type = mime.lookup('bin'); + +// +// Additional API specific to the default instance +// + +mime.Mime = Mime; + +/** + * Lookup a charset based on mime type. + */ +mime.charsets = { + lookup: function(mimeType, fallback) { + // Assume text types are utf8 + return (/^text\//).test(mimeType) ? 'UTF-8' : fallback; + } +}; + +module.exports = mime; diff --git a/ui/node_modules/express/node_modules/send/node_modules/mime/package.json b/ui/node_modules/express/node_modules/send/node_modules/mime/package.json index aafe8925..9c9c711b 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/mime/package.json +++ b/ui/node_modules/express/node_modules/send/node_modules/mime/package.json @@ -1,73 +1,73 @@ -{ - "author": { - "name": "Robert Kieffer", - "email": "robert@broofa.com", - "url": "http://github.com/broofa" - }, - "scripts": { - "prepublish": "node build/build.js > types.json", - "test": "node build/test.js" - }, - "bin": { - "mime": "cli.js" - }, - "contributors": [ - { - "name": "Benjamin Thomas", - "email": "benjamin@benjaminthomas.org", - "url": "http://github.com/bentomas" - } - ], - "description": "A comprehensive library for mime-type mapping", - "licenses": [ - { - "type": "MIT", - "url": "https://raw.github.com/broofa/node-mime/master/LICENSE" - } - ], - "dependencies": {}, - "devDependencies": { - "mime-db": "^1.2.0" - }, - "keywords": [ - "util", - "mime" - ], - "main": "mime.js", - "name": "mime", - "repository": { - "url": "git+https://github.com/broofa/node-mime.git", - "type": "git" - }, - "version": "1.3.4", - "gitHead": "1628f6e0187095009dcef4805c3a49706f137974", - "bugs": { - "url": "https://github.com/broofa/node-mime/issues" - }, - "homepage": "https://github.com/broofa/node-mime", - "_id": "mime@1.3.4", - "_shasum": "115f9e3b6b3daf2959983cb38f149a2d40eb5d53", - "_from": "mime@1.3.4", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "broofa", - "email": "robert@broofa.com" - }, - "maintainers": [ - { - "name": "broofa", - "email": "robert@broofa.com" - }, - { - "name": "bentomas", - "email": "benjamin@benjaminthomas.org" - } - ], - "dist": { - "shasum": "115f9e3b6b3daf2959983cb38f149a2d40eb5d53", - "tarball": "https://registry.npmjs.org/mime/-/mime-1.3.4.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/mime/-/mime-1.3.4.tgz", - "readme": "ERROR: No README data found!" -} +{ + "author": { + "name": "Robert Kieffer", + "email": "robert@broofa.com", + "url": "http://github.com/broofa" + }, + "scripts": { + "prepublish": "node build/build.js > types.json", + "test": "node build/test.js" + }, + "bin": { + "mime": "cli.js" + }, + "contributors": [ + { + "name": "Benjamin Thomas", + "email": "benjamin@benjaminthomas.org", + "url": "http://github.com/bentomas" + } + ], + "description": "A comprehensive library for mime-type mapping", + "licenses": [ + { + "type": "MIT", + "url": "https://raw.github.com/broofa/node-mime/master/LICENSE" + } + ], + "dependencies": {}, + "devDependencies": { + "mime-db": "^1.2.0" + }, + "keywords": [ + "util", + "mime" + ], + "main": "mime.js", + "name": "mime", + "repository": { + "url": "git+https://github.com/broofa/node-mime.git", + "type": "git" + }, + "version": "1.3.4", + "gitHead": "1628f6e0187095009dcef4805c3a49706f137974", + "bugs": { + "url": "https://github.com/broofa/node-mime/issues" + }, + "homepage": "https://github.com/broofa/node-mime", + "_id": "mime@1.3.4", + "_shasum": "115f9e3b6b3daf2959983cb38f149a2d40eb5d53", + "_from": "mime@1.3.4", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "broofa", + "email": "robert@broofa.com" + }, + "maintainers": [ + { + "name": "broofa", + "email": "robert@broofa.com" + }, + { + "name": "bentomas", + "email": "benjamin@benjaminthomas.org" + } + ], + "dist": { + "shasum": "115f9e3b6b3daf2959983cb38f149a2d40eb5d53", + "tarball": "https://registry.npmjs.org/mime/-/mime-1.3.4.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/mime/-/mime-1.3.4.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/send/node_modules/mime/types.json b/ui/node_modules/express/node_modules/send/node_modules/mime/types.json index 2867a35c..c674b1c8 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/mime/types.json +++ b/ui/node_modules/express/node_modules/send/node_modules/mime/types.json @@ -1 +1 @@ -{"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomsvc+xml":["atomsvc"],"application/ccxml+xml":["ccxml"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mdp"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma"],"application/emma+xml":["emma"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/font-tdpfr":["pfr"],"application/font-woff":["woff"],"application/font-woff2":["woff2"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/java-archive":["jar"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/prs.cww":["cww"],"application/pskc+xml":["pskcxml"],"application/rdf+xml":["rdf"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/vnd.3gpp.pic-bw-large":["plb"],"application/vnd.3gpp.pic-bw-small":["psb"],"application/vnd.3gpp.pic-bw-var":["pvb"],"application/vnd.3gpp2.tcap":["tcap"],"application/vnd.3m.post-it-notes":["pwn"],"application/vnd.accpac.simply.aso":["aso"],"application/vnd.accpac.simply.imp":["imp"],"application/vnd.acucobol":["acu"],"application/vnd.acucorp":["atc","acutc"],"application/vnd.adobe.air-application-installer-package+zip":["air"],"application/vnd.adobe.formscentral.fcdt":["fcdt"],"application/vnd.adobe.fxp":["fxp","fxpl"],"application/vnd.adobe.xdp+xml":["xdp"],"application/vnd.adobe.xfdf":["xfdf"],"application/vnd.ahead.space":["ahead"],"application/vnd.airzip.filesecure.azf":["azf"],"application/vnd.airzip.filesecure.azs":["azs"],"application/vnd.amazon.ebook":["azw"],"application/vnd.americandynamics.acc":["acc"],"application/vnd.amiga.ami":["ami"],"application/vnd.android.package-archive":["apk"],"application/vnd.anser-web-certificate-issue-initiation":["cii"],"application/vnd.anser-web-funds-transfer-initiation":["fti"],"application/vnd.antix.game-component":["atx"],"application/vnd.apple.installer+xml":["mpkg"],"application/vnd.apple.mpegurl":["m3u8"],"application/vnd.aristanetworks.swi":["swi"],"application/vnd.astraea-software.iota":["iota"],"application/vnd.audiograph":["aep"],"application/vnd.blueice.multipass":["mpm"],"application/vnd.bmi":["bmi"],"application/vnd.businessobjects":["rep"],"application/vnd.chemdraw+xml":["cdxml"],"application/vnd.chipnuts.karaoke-mmd":["mmd"],"application/vnd.cinderella":["cdy"],"application/vnd.claymore":["cla"],"application/vnd.cloanto.rp9":["rp9"],"application/vnd.clonk.c4group":["c4g","c4d","c4f","c4p","c4u"],"application/vnd.cluetrust.cartomobile-config":["c11amc"],"application/vnd.cluetrust.cartomobile-config-pkg":["c11amz"],"application/vnd.commonspace":["csp"],"application/vnd.contact.cmsg":["cdbcmsg"],"application/vnd.cosmocaller":["cmc"],"application/vnd.crick.clicker":["clkx"],"application/vnd.crick.clicker.keyboard":["clkk"],"application/vnd.crick.clicker.palette":["clkp"],"application/vnd.crick.clicker.template":["clkt"],"application/vnd.crick.clicker.wordbank":["clkw"],"application/vnd.criticaltools.wbs+xml":["wbs"],"application/vnd.ctc-posml":["pml"],"application/vnd.cups-ppd":["ppd"],"application/vnd.curl.car":["car"],"application/vnd.curl.pcurl":["pcurl"],"application/vnd.dart":["dart"],"application/vnd.data-vision.rdz":["rdz"],"application/vnd.dece.data":["uvf","uvvf","uvd","uvvd"],"application/vnd.dece.ttml+xml":["uvt","uvvt"],"application/vnd.dece.unspecified":["uvx","uvvx"],"application/vnd.dece.zip":["uvz","uvvz"],"application/vnd.denovo.fcselayout-link":["fe_launch"],"application/vnd.dna":["dna"],"application/vnd.dolby.mlp":["mlp"],"application/vnd.dpgraph":["dpg"],"application/vnd.dreamfactory":["dfac"],"application/vnd.ds-keypoint":["kpxx"],"application/vnd.dvb.ait":["ait"],"application/vnd.dvb.service":["svc"],"application/vnd.dynageo":["geo"],"application/vnd.ecowin.chart":["mag"],"application/vnd.enliven":["nml"],"application/vnd.epson.esf":["esf"],"application/vnd.epson.msf":["msf"],"application/vnd.epson.quickanime":["qam"],"application/vnd.epson.salt":["slt"],"application/vnd.epson.ssf":["ssf"],"application/vnd.eszigno3+xml":["es3","et3"],"application/vnd.ezpix-album":["ez2"],"application/vnd.ezpix-package":["ez3"],"application/vnd.fdf":["fdf"],"application/vnd.fdsn.mseed":["mseed"],"application/vnd.fdsn.seed":["seed","dataless"],"application/vnd.flographit":["gph"],"application/vnd.fluxtime.clip":["ftc"],"application/vnd.framemaker":["fm","frame","maker","book"],"application/vnd.frogans.fnc":["fnc"],"application/vnd.frogans.ltf":["ltf"],"application/vnd.fsc.weblaunch":["fsc"],"application/vnd.fujitsu.oasys":["oas"],"application/vnd.fujitsu.oasys2":["oa2"],"application/vnd.fujitsu.oasys3":["oa3"],"application/vnd.fujitsu.oasysgp":["fg5"],"application/vnd.fujitsu.oasysprs":["bh2"],"application/vnd.fujixerox.ddd":["ddd"],"application/vnd.fujixerox.docuworks":["xdw"],"application/vnd.fujixerox.docuworks.binder":["xbd"],"application/vnd.fuzzysheet":["fzs"],"application/vnd.genomatix.tuxedo":["txd"],"application/vnd.geogebra.file":["ggb"],"application/vnd.geogebra.tool":["ggt"],"application/vnd.geometry-explorer":["gex","gre"],"application/vnd.geonext":["gxt"],"application/vnd.geoplan":["g2w"],"application/vnd.geospace":["g3w"],"application/vnd.gmx":["gmx"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/vnd.grafeq":["gqf","gqs"],"application/vnd.groove-account":["gac"],"application/vnd.groove-help":["ghf"],"application/vnd.groove-identity-message":["gim"],"application/vnd.groove-injector":["grv"],"application/vnd.groove-tool-message":["gtm"],"application/vnd.groove-tool-template":["tpl"],"application/vnd.groove-vcard":["vcg"],"application/vnd.hal+xml":["hal"],"application/vnd.handheld-entertainment+xml":["zmm"],"application/vnd.hbci":["hbci"],"application/vnd.hhe.lesson-player":["les"],"application/vnd.hp-hpgl":["hpgl"],"application/vnd.hp-hpid":["hpid"],"application/vnd.hp-hps":["hps"],"application/vnd.hp-jlyt":["jlt"],"application/vnd.hp-pcl":["pcl"],"application/vnd.hp-pclxl":["pclxl"],"application/vnd.ibm.minipay":["mpy"],"application/vnd.ibm.modcap":["afp","listafp","list3820"],"application/vnd.ibm.rights-management":["irm"],"application/vnd.ibm.secure-container":["sc"],"application/vnd.iccprofile":["icc","icm"],"application/vnd.igloader":["igl"],"application/vnd.immervision-ivp":["ivp"],"application/vnd.immervision-ivu":["ivu"],"application/vnd.insors.igm":["igm"],"application/vnd.intercon.formnet":["xpw","xpx"],"application/vnd.intergeo":["i2g"],"application/vnd.intu.qbo":["qbo"],"application/vnd.intu.qfx":["qfx"],"application/vnd.ipunplugged.rcprofile":["rcprofile"],"application/vnd.irepository.package+xml":["irp"],"application/vnd.is-xpr":["xpr"],"application/vnd.isac.fcs":["fcs"],"application/vnd.jam":["jam"],"application/vnd.jcp.javame.midlet-rms":["rms"],"application/vnd.jisp":["jisp"],"application/vnd.joost.joda-archive":["joda"],"application/vnd.kahootz":["ktz","ktr"],"application/vnd.kde.karbon":["karbon"],"application/vnd.kde.kchart":["chrt"],"application/vnd.kde.kformula":["kfo"],"application/vnd.kde.kivio":["flw"],"application/vnd.kde.kontour":["kon"],"application/vnd.kde.kpresenter":["kpr","kpt"],"application/vnd.kde.kspread":["ksp"],"application/vnd.kde.kword":["kwd","kwt"],"application/vnd.kenameaapp":["htke"],"application/vnd.kidspiration":["kia"],"application/vnd.kinar":["kne","knp"],"application/vnd.koan":["skp","skd","skt","skm"],"application/vnd.kodak-descriptor":["sse"],"application/vnd.las.las+xml":["lasxml"],"application/vnd.llamagraphics.life-balance.desktop":["lbd"],"application/vnd.llamagraphics.life-balance.exchange+xml":["lbe"],"application/vnd.lotus-1-2-3":["123"],"application/vnd.lotus-approach":["apr"],"application/vnd.lotus-freelance":["pre"],"application/vnd.lotus-notes":["nsf"],"application/vnd.lotus-organizer":["org"],"application/vnd.lotus-screencam":["scm"],"application/vnd.lotus-wordpro":["lwp"],"application/vnd.macports.portpkg":["portpkg"],"application/vnd.mcd":["mcd"],"application/vnd.medcalcdata":["mc1"],"application/vnd.mediastation.cdkey":["cdkey"],"application/vnd.mfer":["mwf"],"application/vnd.mfmp":["mfm"],"application/vnd.micrografx.flo":["flo"],"application/vnd.micrografx.igx":["igx"],"application/vnd.mif":["mif"],"application/vnd.mobius.daf":["daf"],"application/vnd.mobius.dis":["dis"],"application/vnd.mobius.mbk":["mbk"],"application/vnd.mobius.mqy":["mqy"],"application/vnd.mobius.msl":["msl"],"application/vnd.mobius.plc":["plc"],"application/vnd.mobius.txf":["txf"],"application/vnd.mophun.application":["mpn"],"application/vnd.mophun.certificate":["mpc"],"application/vnd.mozilla.xul+xml":["xul"],"application/vnd.ms-artgalry":["cil"],"application/vnd.ms-cab-compressed":["cab"],"application/vnd.ms-excel":["xls","xlm","xla","xlc","xlt","xlw"],"application/vnd.ms-excel.addin.macroenabled.12":["xlam"],"application/vnd.ms-excel.sheet.binary.macroenabled.12":["xlsb"],"application/vnd.ms-excel.sheet.macroenabled.12":["xlsm"],"application/vnd.ms-excel.template.macroenabled.12":["xltm"],"application/vnd.ms-fontobject":["eot"],"application/vnd.ms-htmlhelp":["chm"],"application/vnd.ms-ims":["ims"],"application/vnd.ms-lrm":["lrm"],"application/vnd.ms-officetheme":["thmx"],"application/vnd.ms-pki.seccat":["cat"],"application/vnd.ms-pki.stl":["stl"],"application/vnd.ms-powerpoint":["ppt","pps","pot"],"application/vnd.ms-powerpoint.addin.macroenabled.12":["ppam"],"application/vnd.ms-powerpoint.presentation.macroenabled.12":["pptm"],"application/vnd.ms-powerpoint.slide.macroenabled.12":["sldm"],"application/vnd.ms-powerpoint.slideshow.macroenabled.12":["ppsm"],"application/vnd.ms-powerpoint.template.macroenabled.12":["potm"],"application/vnd.ms-project":["mpp","mpt"],"application/vnd.ms-word.document.macroenabled.12":["docm"],"application/vnd.ms-word.template.macroenabled.12":["dotm"],"application/vnd.ms-works":["wps","wks","wcm","wdb"],"application/vnd.ms-wpl":["wpl"],"application/vnd.ms-xpsdocument":["xps"],"application/vnd.mseq":["mseq"],"application/vnd.musician":["mus"],"application/vnd.muvee.style":["msty"],"application/vnd.mynfc":["taglet"],"application/vnd.neurolanguage.nlu":["nlu"],"application/vnd.nitf":["ntf","nitf"],"application/vnd.noblenet-directory":["nnd"],"application/vnd.noblenet-sealer":["nns"],"application/vnd.noblenet-web":["nnw"],"application/vnd.nokia.n-gage.data":["ngdat"],"application/vnd.nokia.radio-preset":["rpst"],"application/vnd.nokia.radio-presets":["rpss"],"application/vnd.novadigm.edm":["edm"],"application/vnd.novadigm.edx":["edx"],"application/vnd.novadigm.ext":["ext"],"application/vnd.oasis.opendocument.chart":["odc"],"application/vnd.oasis.opendocument.chart-template":["otc"],"application/vnd.oasis.opendocument.database":["odb"],"application/vnd.oasis.opendocument.formula":["odf"],"application/vnd.oasis.opendocument.formula-template":["odft"],"application/vnd.oasis.opendocument.graphics":["odg"],"application/vnd.oasis.opendocument.graphics-template":["otg"],"application/vnd.oasis.opendocument.image":["odi"],"application/vnd.oasis.opendocument.image-template":["oti"],"application/vnd.oasis.opendocument.presentation":["odp"],"application/vnd.oasis.opendocument.presentation-template":["otp"],"application/vnd.oasis.opendocument.spreadsheet":["ods"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/vnd.oasis.opendocument.text":["odt"],"application/vnd.oasis.opendocument.text-master":["odm"],"application/vnd.oasis.opendocument.text-template":["ott"],"application/vnd.oasis.opendocument.text-web":["oth"],"application/vnd.olpc-sugar":["xo"],"application/vnd.oma.dd2+xml":["dd2"],"application/vnd.openofficeorg.extension":["oxt"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":["pptx"],"application/vnd.openxmlformats-officedocument.presentationml.slide":["sldx"],"application/vnd.openxmlformats-officedocument.presentationml.slideshow":["ppsx"],"application/vnd.openxmlformats-officedocument.presentationml.template":["potx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":["xlsx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.template":["xltx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.template":["dotx"],"application/vnd.osgeo.mapguide.package":["mgp"],"application/vnd.osgi.dp":["dp"],"application/vnd.osgi.subsystem":["esa"],"application/vnd.palm":["pdb","pqa","oprc"],"application/vnd.pawaafile":["paw"],"application/vnd.pg.format":["str"],"application/vnd.pg.osasli":["ei6"],"application/vnd.picsel":["efif"],"application/vnd.pmi.widget":["wg"],"application/vnd.pocketlearn":["plf"],"application/vnd.powerbuilder6":["pbd"],"application/vnd.previewsystems.box":["box"],"application/vnd.proteus.magazine":["mgz"],"application/vnd.publishare-delta-tree":["qps"],"application/vnd.pvi.ptid1":["ptid"],"application/vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"application/vnd.realvnc.bed":["bed"],"application/vnd.recordare.musicxml":["mxl"],"application/vnd.recordare.musicxml+xml":["musicxml"],"application/vnd.rig.cryptonote":["cryptonote"],"application/vnd.rim.cod":["cod"],"application/vnd.rn-realmedia":["rm"],"application/vnd.rn-realmedia-vbr":["rmvb"],"application/vnd.route66.link66+xml":["link66"],"application/vnd.sailingtracker.track":["st"],"application/vnd.seemail":["see"],"application/vnd.sema":["sema"],"application/vnd.semd":["semd"],"application/vnd.semf":["semf"],"application/vnd.shana.informed.formdata":["ifm"],"application/vnd.shana.informed.formtemplate":["itp"],"application/vnd.shana.informed.interchange":["iif"],"application/vnd.shana.informed.package":["ipk"],"application/vnd.simtech-mindmapper":["twd","twds"],"application/vnd.smaf":["mmf"],"application/vnd.smart.teacher":["teacher"],"application/vnd.solent.sdkm+xml":["sdkm","sdkd"],"application/vnd.spotfire.dxp":["dxp"],"application/vnd.spotfire.sfs":["sfs"],"application/vnd.stardivision.calc":["sdc"],"application/vnd.stardivision.draw":["sda"],"application/vnd.stardivision.impress":["sdd"],"application/vnd.stardivision.math":["smf"],"application/vnd.stardivision.writer":["sdw","vor"],"application/vnd.stardivision.writer-global":["sgl"],"application/vnd.stepmania.package":["smzip"],"application/vnd.stepmania.stepchart":["sm"],"application/vnd.sun.xml.calc":["sxc"],"application/vnd.sun.xml.calc.template":["stc"],"application/vnd.sun.xml.draw":["sxd"],"application/vnd.sun.xml.draw.template":["std"],"application/vnd.sun.xml.impress":["sxi"],"application/vnd.sun.xml.impress.template":["sti"],"application/vnd.sun.xml.math":["sxm"],"application/vnd.sun.xml.writer":["sxw"],"application/vnd.sun.xml.writer.global":["sxg"],"application/vnd.sun.xml.writer.template":["stw"],"application/vnd.sus-calendar":["sus","susp"],"application/vnd.svd":["svd"],"application/vnd.symbian.install":["sis","sisx"],"application/vnd.syncml+xml":["xsm"],"application/vnd.syncml.dm+wbxml":["bdm"],"application/vnd.syncml.dm+xml":["xdm"],"application/vnd.tao.intent-module-archive":["tao"],"application/vnd.tcpdump.pcap":["pcap","cap","dmp"],"application/vnd.tmobile-livetv":["tmo"],"application/vnd.trid.tpt":["tpt"],"application/vnd.triscape.mxs":["mxs"],"application/vnd.trueapp":["tra"],"application/vnd.ufdl":["ufd","ufdl"],"application/vnd.uiq.theme":["utz"],"application/vnd.umajin":["umj"],"application/vnd.unity":["unityweb"],"application/vnd.uoml+xml":["uoml"],"application/vnd.vcx":["vcx"],"application/vnd.visio":["vsd","vst","vss","vsw"],"application/vnd.visionary":["vis"],"application/vnd.vsf":["vsf"],"application/vnd.wap.wbxml":["wbxml"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.wap.wmlscriptc":["wmlsc"],"application/vnd.webturbo":["wtb"],"application/vnd.wolfram.player":["nbp"],"application/vnd.wordperfect":["wpd"],"application/vnd.wqd":["wqd"],"application/vnd.wt.stf":["stf"],"application/vnd.xara":["xar"],"application/vnd.xfdl":["xfdl"],"application/vnd.yamaha.hv-dic":["hvd"],"application/vnd.yamaha.hv-script":["hvs"],"application/vnd.yamaha.hv-voice":["hvp"],"application/vnd.yamaha.openscoreformat":["osf"],"application/vnd.yamaha.openscoreformat.osfpvg+xml":["osfpvg"],"application/vnd.yamaha.smaf-audio":["saf"],"application/vnd.yamaha.smaf-phrase":["spf"],"application/vnd.yellowriver-custom-menu":["cmp"],"application/vnd.zul":["zir","zirz"],"application/vnd.zzazz.deck+xml":["zaz"],"application/voicexml+xml":["vxml"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/x-7z-compressed":["7z"],"application/x-abiword":["abw"],"application/x-ace-compressed":["ace"],"application/x-apple-diskimage":["dmg"],"application/x-authorware-bin":["aab","x32","u32","vox"],"application/x-authorware-map":["aam"],"application/x-authorware-seg":["aas"],"application/x-bcpio":["bcpio"],"application/x-bittorrent":["torrent"],"application/x-blorb":["blb","blorb"],"application/x-bzip":["bz"],"application/x-bzip2":["bz2","boz"],"application/x-cbr":["cbr","cba","cbt","cbz","cb7"],"application/x-cdlink":["vcd"],"application/x-cfs-compressed":["cfs"],"application/x-chat":["chat"],"application/x-chess-pgn":["pgn"],"application/x-chrome-extension":["crx"],"application/x-conference":["nsc"],"application/x-cpio":["cpio"],"application/x-csh":["csh"],"application/x-debian-package":["deb","udeb"],"application/x-dgc-compressed":["dgc"],"application/x-director":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"],"application/x-doom":["wad"],"application/x-dtbncx+xml":["ncx"],"application/x-dtbook+xml":["dtb"],"application/x-dtbresource+xml":["res"],"application/x-dvi":["dvi"],"application/x-envoy":["evy"],"application/x-eva":["eva"],"application/x-font-bdf":["bdf"],"application/x-font-ghostscript":["gsf"],"application/x-font-linux-psf":["psf"],"application/x-font-otf":["otf"],"application/x-font-pcf":["pcf"],"application/x-font-snf":["snf"],"application/x-font-ttf":["ttf","ttc"],"application/x-font-type1":["pfa","pfb","pfm","afm"],"application/x-freearc":["arc"],"application/x-futuresplash":["spl"],"application/x-gca-compressed":["gca"],"application/x-glulx":["ulx"],"application/x-gnumeric":["gnumeric"],"application/x-gramps-xml":["gramps"],"application/x-gtar":["gtar"],"application/x-hdf":["hdf"],"application/x-install-instructions":["install"],"application/x-iso9660-image":["iso"],"application/x-java-jnlp-file":["jnlp"],"application/x-latex":["latex"],"application/x-lua-bytecode":["luac"],"application/x-lzh-compressed":["lzh","lha"],"application/x-mie":["mie"],"application/x-mobipocket-ebook":["prc","mobi"],"application/x-ms-application":["application"],"application/x-ms-shortcut":["lnk"],"application/x-ms-wmd":["wmd"],"application/x-ms-wmz":["wmz"],"application/x-ms-xbap":["xbap"],"application/x-msaccess":["mdb"],"application/x-msbinder":["obd"],"application/x-mscardfile":["crd"],"application/x-msclip":["clp"],"application/x-msdownload":["exe","dll","com","bat","msi"],"application/x-msmediaview":["mvb","m13","m14"],"application/x-msmetafile":["wmf","wmz","emf","emz"],"application/x-msmoney":["mny"],"application/x-mspublisher":["pub"],"application/x-msschedule":["scd"],"application/x-msterminal":["trm"],"application/x-mswrite":["wri"],"application/x-netcdf":["nc","cdf"],"application/x-nzb":["nzb"],"application/x-pkcs12":["p12","pfx"],"application/x-pkcs7-certificates":["p7b","spc"],"application/x-pkcs7-certreqresp":["p7r"],"application/x-rar-compressed":["rar"],"application/x-research-info-systems":["ris"],"application/x-sh":["sh"],"application/x-shar":["shar"],"application/x-shockwave-flash":["swf"],"application/x-silverlight-app":["xap"],"application/x-sql":["sql"],"application/x-stuffit":["sit"],"application/x-stuffitx":["sitx"],"application/x-subrip":["srt"],"application/x-sv4cpio":["sv4cpio"],"application/x-sv4crc":["sv4crc"],"application/x-t3vm-image":["t3"],"application/x-tads":["gam"],"application/x-tar":["tar"],"application/x-tcl":["tcl"],"application/x-tex":["tex"],"application/x-tex-tfm":["tfm"],"application/x-texinfo":["texinfo","texi"],"application/x-tgif":["obj"],"application/x-ustar":["ustar"],"application/x-wais-source":["src"],"application/x-web-app-manifest+json":["webapp"],"application/x-x509-ca-cert":["der","crt"],"application/x-xfig":["fig"],"application/x-xliff+xml":["xlf"],"application/x-xpinstall":["xpi"],"application/x-xz":["xz"],"application/x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"application/xaml+xml":["xaml"],"application/xcap-diff+xml":["xdf"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xml":["xml","xsl","xsd"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/adpcm":["adp"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mp4":["mp4a","m4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/webm":["weba"],"audio/x-aac":["aac"],"audio/x-aiff":["aif","aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-wav":["wav"],"audio/xm":["xm"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"font/opentype":["otf"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/g3fax":["g3"],"image/gif":["gif"],"image/ief":["ief"],"image/jpeg":["jpeg","jpg","jpe"],"image/ktx":["ktx"],"image/png":["png"],"image/prs.btif":["btif"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/tiff":["tiff","tif"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dvb.subtitle":["sub"],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/webp":["webp"],"image/x-3ds":["3ds"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["ico"],"image/x-mrsid-image":["sid"],"image/x-pcx":["pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/rfc822":["eml","mime"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/vnd.collada+xml":["dae"],"model/vnd.dwf":["dwf"],"model/vnd.gdl":["gdl"],"model/vnd.gtw":["gtw"],"model/vnd.mts":["mts"],"model/vnd.vtu":["vtu"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["x3db","x3dbz"],"model/x3d+vrml":["x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee"],"text/css":["css"],"text/csv":["csv"],"text/hjson":["hjson"],"text/html":["html","htm"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/prs.lines.tag":["dsc"],"text/richtext":["rtx"],"text/sgml":["sgml","sgm"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vnd.curl":["curl"],"text/vnd.curl.dcurl":["dcurl"],"text/vnd.curl.mcurl":["mcurl"],"text/vnd.curl.scurl":["scurl"],"text/vnd.dvb.subtitle":["sub"],"text/vnd.fly":["fly"],"text/vnd.fmi.flexstor":["flx"],"text/vnd.graphviz":["gv"],"text/vnd.in3d.3dml":["3dml"],"text/vnd.in3d.spot":["spot"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/vnd.wap.wmlscript":["wmls"],"text/vtt":["vtt"],"text/x-asm":["s","asm"],"text/x-c":["c","cc","cxx","cpp","h","hh","dic"],"text/x-component":["htc"],"text/x-fortran":["f","for","f77","f90"],"text/x-handlebars-template":["hbs"],"text/x-java-source":["java"],"text/x-lua":["lua"],"text/x-markdown":["markdown","md","mkd"],"text/x-nfo":["nfo"],"text/x-opml":["opml"],"text/x-pascal":["p","pas"],"text/x-sass":["sass"],"text/x-scss":["scss"],"text/x-setext":["etx"],"text/x-sfv":["sfv"],"text/x-uuencode":["uu"],"text/x-vcalendar":["vcs"],"text/x-vcard":["vcf"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/jpeg":["jpgv"],"video/jpm":["jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/vnd.dece.hd":["uvh","uvvh"],"video/vnd.dece.mobile":["uvm","uvvm"],"video/vnd.dece.pd":["uvp","uvvp"],"video/vnd.dece.sd":["uvs","uvvs"],"video/vnd.dece.video":["uvv","uvvv"],"video/vnd.dvb.file":["dvb"],"video/vnd.fvt":["fvt"],"video/vnd.mpegurl":["mxu","m4u"],"video/vnd.ms-playready.media.pyv":["pyv"],"video/vnd.uvvu.mp4":["uvu","uvvu"],"video/vnd.vivo":["viv"],"video/webm":["webm"],"video/x-f4v":["f4v"],"video/x-fli":["fli"],"video/x-flv":["flv"],"video/x-m4v":["m4v"],"video/x-matroska":["mkv","mk3d","mks"],"video/x-mng":["mng"],"video/x-ms-asf":["asf","asx"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]} +{"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomsvc+xml":["atomsvc"],"application/ccxml+xml":["ccxml"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mdp"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma"],"application/emma+xml":["emma"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/font-tdpfr":["pfr"],"application/font-woff":["woff"],"application/font-woff2":["woff2"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/java-archive":["jar"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/prs.cww":["cww"],"application/pskc+xml":["pskcxml"],"application/rdf+xml":["rdf"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/vnd.3gpp.pic-bw-large":["plb"],"application/vnd.3gpp.pic-bw-small":["psb"],"application/vnd.3gpp.pic-bw-var":["pvb"],"application/vnd.3gpp2.tcap":["tcap"],"application/vnd.3m.post-it-notes":["pwn"],"application/vnd.accpac.simply.aso":["aso"],"application/vnd.accpac.simply.imp":["imp"],"application/vnd.acucobol":["acu"],"application/vnd.acucorp":["atc","acutc"],"application/vnd.adobe.air-application-installer-package+zip":["air"],"application/vnd.adobe.formscentral.fcdt":["fcdt"],"application/vnd.adobe.fxp":["fxp","fxpl"],"application/vnd.adobe.xdp+xml":["xdp"],"application/vnd.adobe.xfdf":["xfdf"],"application/vnd.ahead.space":["ahead"],"application/vnd.airzip.filesecure.azf":["azf"],"application/vnd.airzip.filesecure.azs":["azs"],"application/vnd.amazon.ebook":["azw"],"application/vnd.americandynamics.acc":["acc"],"application/vnd.amiga.ami":["ami"],"application/vnd.android.package-archive":["apk"],"application/vnd.anser-web-certificate-issue-initiation":["cii"],"application/vnd.anser-web-funds-transfer-initiation":["fti"],"application/vnd.antix.game-component":["atx"],"application/vnd.apple.installer+xml":["mpkg"],"application/vnd.apple.mpegurl":["m3u8"],"application/vnd.aristanetworks.swi":["swi"],"application/vnd.astraea-software.iota":["iota"],"application/vnd.audiograph":["aep"],"application/vnd.blueice.multipass":["mpm"],"application/vnd.bmi":["bmi"],"application/vnd.businessobjects":["rep"],"application/vnd.chemdraw+xml":["cdxml"],"application/vnd.chipnuts.karaoke-mmd":["mmd"],"application/vnd.cinderella":["cdy"],"application/vnd.claymore":["cla"],"application/vnd.cloanto.rp9":["rp9"],"application/vnd.clonk.c4group":["c4g","c4d","c4f","c4p","c4u"],"application/vnd.cluetrust.cartomobile-config":["c11amc"],"application/vnd.cluetrust.cartomobile-config-pkg":["c11amz"],"application/vnd.commonspace":["csp"],"application/vnd.contact.cmsg":["cdbcmsg"],"application/vnd.cosmocaller":["cmc"],"application/vnd.crick.clicker":["clkx"],"application/vnd.crick.clicker.keyboard":["clkk"],"application/vnd.crick.clicker.palette":["clkp"],"application/vnd.crick.clicker.template":["clkt"],"application/vnd.crick.clicker.wordbank":["clkw"],"application/vnd.criticaltools.wbs+xml":["wbs"],"application/vnd.ctc-posml":["pml"],"application/vnd.cups-ppd":["ppd"],"application/vnd.curl.car":["car"],"application/vnd.curl.pcurl":["pcurl"],"application/vnd.dart":["dart"],"application/vnd.data-vision.rdz":["rdz"],"application/vnd.dece.data":["uvf","uvvf","uvd","uvvd"],"application/vnd.dece.ttml+xml":["uvt","uvvt"],"application/vnd.dece.unspecified":["uvx","uvvx"],"application/vnd.dece.zip":["uvz","uvvz"],"application/vnd.denovo.fcselayout-link":["fe_launch"],"application/vnd.dna":["dna"],"application/vnd.dolby.mlp":["mlp"],"application/vnd.dpgraph":["dpg"],"application/vnd.dreamfactory":["dfac"],"application/vnd.ds-keypoint":["kpxx"],"application/vnd.dvb.ait":["ait"],"application/vnd.dvb.service":["svc"],"application/vnd.dynageo":["geo"],"application/vnd.ecowin.chart":["mag"],"application/vnd.enliven":["nml"],"application/vnd.epson.esf":["esf"],"application/vnd.epson.msf":["msf"],"application/vnd.epson.quickanime":["qam"],"application/vnd.epson.salt":["slt"],"application/vnd.epson.ssf":["ssf"],"application/vnd.eszigno3+xml":["es3","et3"],"application/vnd.ezpix-album":["ez2"],"application/vnd.ezpix-package":["ez3"],"application/vnd.fdf":["fdf"],"application/vnd.fdsn.mseed":["mseed"],"application/vnd.fdsn.seed":["seed","dataless"],"application/vnd.flographit":["gph"],"application/vnd.fluxtime.clip":["ftc"],"application/vnd.framemaker":["fm","frame","maker","book"],"application/vnd.frogans.fnc":["fnc"],"application/vnd.frogans.ltf":["ltf"],"application/vnd.fsc.weblaunch":["fsc"],"application/vnd.fujitsu.oasys":["oas"],"application/vnd.fujitsu.oasys2":["oa2"],"application/vnd.fujitsu.oasys3":["oa3"],"application/vnd.fujitsu.oasysgp":["fg5"],"application/vnd.fujitsu.oasysprs":["bh2"],"application/vnd.fujixerox.ddd":["ddd"],"application/vnd.fujixerox.docuworks":["xdw"],"application/vnd.fujixerox.docuworks.binder":["xbd"],"application/vnd.fuzzysheet":["fzs"],"application/vnd.genomatix.tuxedo":["txd"],"application/vnd.geogebra.file":["ggb"],"application/vnd.geogebra.tool":["ggt"],"application/vnd.geometry-explorer":["gex","gre"],"application/vnd.geonext":["gxt"],"application/vnd.geoplan":["g2w"],"application/vnd.geospace":["g3w"],"application/vnd.gmx":["gmx"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/vnd.grafeq":["gqf","gqs"],"application/vnd.groove-account":["gac"],"application/vnd.groove-help":["ghf"],"application/vnd.groove-identity-message":["gim"],"application/vnd.groove-injector":["grv"],"application/vnd.groove-tool-message":["gtm"],"application/vnd.groove-tool-template":["tpl"],"application/vnd.groove-vcard":["vcg"],"application/vnd.hal+xml":["hal"],"application/vnd.handheld-entertainment+xml":["zmm"],"application/vnd.hbci":["hbci"],"application/vnd.hhe.lesson-player":["les"],"application/vnd.hp-hpgl":["hpgl"],"application/vnd.hp-hpid":["hpid"],"application/vnd.hp-hps":["hps"],"application/vnd.hp-jlyt":["jlt"],"application/vnd.hp-pcl":["pcl"],"application/vnd.hp-pclxl":["pclxl"],"application/vnd.ibm.minipay":["mpy"],"application/vnd.ibm.modcap":["afp","listafp","list3820"],"application/vnd.ibm.rights-management":["irm"],"application/vnd.ibm.secure-container":["sc"],"application/vnd.iccprofile":["icc","icm"],"application/vnd.igloader":["igl"],"application/vnd.immervision-ivp":["ivp"],"application/vnd.immervision-ivu":["ivu"],"application/vnd.insors.igm":["igm"],"application/vnd.intercon.formnet":["xpw","xpx"],"application/vnd.intergeo":["i2g"],"application/vnd.intu.qbo":["qbo"],"application/vnd.intu.qfx":["qfx"],"application/vnd.ipunplugged.rcprofile":["rcprofile"],"application/vnd.irepository.package+xml":["irp"],"application/vnd.is-xpr":["xpr"],"application/vnd.isac.fcs":["fcs"],"application/vnd.jam":["jam"],"application/vnd.jcp.javame.midlet-rms":["rms"],"application/vnd.jisp":["jisp"],"application/vnd.joost.joda-archive":["joda"],"application/vnd.kahootz":["ktz","ktr"],"application/vnd.kde.karbon":["karbon"],"application/vnd.kde.kchart":["chrt"],"application/vnd.kde.kformula":["kfo"],"application/vnd.kde.kivio":["flw"],"application/vnd.kde.kontour":["kon"],"application/vnd.kde.kpresenter":["kpr","kpt"],"application/vnd.kde.kspread":["ksp"],"application/vnd.kde.kword":["kwd","kwt"],"application/vnd.kenameaapp":["htke"],"application/vnd.kidspiration":["kia"],"application/vnd.kinar":["kne","knp"],"application/vnd.koan":["skp","skd","skt","skm"],"application/vnd.kodak-descriptor":["sse"],"application/vnd.las.las+xml":["lasxml"],"application/vnd.llamagraphics.life-balance.desktop":["lbd"],"application/vnd.llamagraphics.life-balance.exchange+xml":["lbe"],"application/vnd.lotus-1-2-3":["123"],"application/vnd.lotus-approach":["apr"],"application/vnd.lotus-freelance":["pre"],"application/vnd.lotus-notes":["nsf"],"application/vnd.lotus-organizer":["org"],"application/vnd.lotus-screencam":["scm"],"application/vnd.lotus-wordpro":["lwp"],"application/vnd.macports.portpkg":["portpkg"],"application/vnd.mcd":["mcd"],"application/vnd.medcalcdata":["mc1"],"application/vnd.mediastation.cdkey":["cdkey"],"application/vnd.mfer":["mwf"],"application/vnd.mfmp":["mfm"],"application/vnd.micrografx.flo":["flo"],"application/vnd.micrografx.igx":["igx"],"application/vnd.mif":["mif"],"application/vnd.mobius.daf":["daf"],"application/vnd.mobius.dis":["dis"],"application/vnd.mobius.mbk":["mbk"],"application/vnd.mobius.mqy":["mqy"],"application/vnd.mobius.msl":["msl"],"application/vnd.mobius.plc":["plc"],"application/vnd.mobius.txf":["txf"],"application/vnd.mophun.application":["mpn"],"application/vnd.mophun.certificate":["mpc"],"application/vnd.mozilla.xul+xml":["xul"],"application/vnd.ms-artgalry":["cil"],"application/vnd.ms-cab-compressed":["cab"],"application/vnd.ms-excel":["xls","xlm","xla","xlc","xlt","xlw"],"application/vnd.ms-excel.addin.macroenabled.12":["xlam"],"application/vnd.ms-excel.sheet.binary.macroenabled.12":["xlsb"],"application/vnd.ms-excel.sheet.macroenabled.12":["xlsm"],"application/vnd.ms-excel.template.macroenabled.12":["xltm"],"application/vnd.ms-fontobject":["eot"],"application/vnd.ms-htmlhelp":["chm"],"application/vnd.ms-ims":["ims"],"application/vnd.ms-lrm":["lrm"],"application/vnd.ms-officetheme":["thmx"],"application/vnd.ms-pki.seccat":["cat"],"application/vnd.ms-pki.stl":["stl"],"application/vnd.ms-powerpoint":["ppt","pps","pot"],"application/vnd.ms-powerpoint.addin.macroenabled.12":["ppam"],"application/vnd.ms-powerpoint.presentation.macroenabled.12":["pptm"],"application/vnd.ms-powerpoint.slide.macroenabled.12":["sldm"],"application/vnd.ms-powerpoint.slideshow.macroenabled.12":["ppsm"],"application/vnd.ms-powerpoint.template.macroenabled.12":["potm"],"application/vnd.ms-project":["mpp","mpt"],"application/vnd.ms-word.document.macroenabled.12":["docm"],"application/vnd.ms-word.template.macroenabled.12":["dotm"],"application/vnd.ms-works":["wps","wks","wcm","wdb"],"application/vnd.ms-wpl":["wpl"],"application/vnd.ms-xpsdocument":["xps"],"application/vnd.mseq":["mseq"],"application/vnd.musician":["mus"],"application/vnd.muvee.style":["msty"],"application/vnd.mynfc":["taglet"],"application/vnd.neurolanguage.nlu":["nlu"],"application/vnd.nitf":["ntf","nitf"],"application/vnd.noblenet-directory":["nnd"],"application/vnd.noblenet-sealer":["nns"],"application/vnd.noblenet-web":["nnw"],"application/vnd.nokia.n-gage.data":["ngdat"],"application/vnd.nokia.radio-preset":["rpst"],"application/vnd.nokia.radio-presets":["rpss"],"application/vnd.novadigm.edm":["edm"],"application/vnd.novadigm.edx":["edx"],"application/vnd.novadigm.ext":["ext"],"application/vnd.oasis.opendocument.chart":["odc"],"application/vnd.oasis.opendocument.chart-template":["otc"],"application/vnd.oasis.opendocument.database":["odb"],"application/vnd.oasis.opendocument.formula":["odf"],"application/vnd.oasis.opendocument.formula-template":["odft"],"application/vnd.oasis.opendocument.graphics":["odg"],"application/vnd.oasis.opendocument.graphics-template":["otg"],"application/vnd.oasis.opendocument.image":["odi"],"application/vnd.oasis.opendocument.image-template":["oti"],"application/vnd.oasis.opendocument.presentation":["odp"],"application/vnd.oasis.opendocument.presentation-template":["otp"],"application/vnd.oasis.opendocument.spreadsheet":["ods"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/vnd.oasis.opendocument.text":["odt"],"application/vnd.oasis.opendocument.text-master":["odm"],"application/vnd.oasis.opendocument.text-template":["ott"],"application/vnd.oasis.opendocument.text-web":["oth"],"application/vnd.olpc-sugar":["xo"],"application/vnd.oma.dd2+xml":["dd2"],"application/vnd.openofficeorg.extension":["oxt"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":["pptx"],"application/vnd.openxmlformats-officedocument.presentationml.slide":["sldx"],"application/vnd.openxmlformats-officedocument.presentationml.slideshow":["ppsx"],"application/vnd.openxmlformats-officedocument.presentationml.template":["potx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":["xlsx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.template":["xltx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.template":["dotx"],"application/vnd.osgeo.mapguide.package":["mgp"],"application/vnd.osgi.dp":["dp"],"application/vnd.osgi.subsystem":["esa"],"application/vnd.palm":["pdb","pqa","oprc"],"application/vnd.pawaafile":["paw"],"application/vnd.pg.format":["str"],"application/vnd.pg.osasli":["ei6"],"application/vnd.picsel":["efif"],"application/vnd.pmi.widget":["wg"],"application/vnd.pocketlearn":["plf"],"application/vnd.powerbuilder6":["pbd"],"application/vnd.previewsystems.box":["box"],"application/vnd.proteus.magazine":["mgz"],"application/vnd.publishare-delta-tree":["qps"],"application/vnd.pvi.ptid1":["ptid"],"application/vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"application/vnd.realvnc.bed":["bed"],"application/vnd.recordare.musicxml":["mxl"],"application/vnd.recordare.musicxml+xml":["musicxml"],"application/vnd.rig.cryptonote":["cryptonote"],"application/vnd.rim.cod":["cod"],"application/vnd.rn-realmedia":["rm"],"application/vnd.rn-realmedia-vbr":["rmvb"],"application/vnd.route66.link66+xml":["link66"],"application/vnd.sailingtracker.track":["st"],"application/vnd.seemail":["see"],"application/vnd.sema":["sema"],"application/vnd.semd":["semd"],"application/vnd.semf":["semf"],"application/vnd.shana.informed.formdata":["ifm"],"application/vnd.shana.informed.formtemplate":["itp"],"application/vnd.shana.informed.interchange":["iif"],"application/vnd.shana.informed.package":["ipk"],"application/vnd.simtech-mindmapper":["twd","twds"],"application/vnd.smaf":["mmf"],"application/vnd.smart.teacher":["teacher"],"application/vnd.solent.sdkm+xml":["sdkm","sdkd"],"application/vnd.spotfire.dxp":["dxp"],"application/vnd.spotfire.sfs":["sfs"],"application/vnd.stardivision.calc":["sdc"],"application/vnd.stardivision.draw":["sda"],"application/vnd.stardivision.impress":["sdd"],"application/vnd.stardivision.math":["smf"],"application/vnd.stardivision.writer":["sdw","vor"],"application/vnd.stardivision.writer-global":["sgl"],"application/vnd.stepmania.package":["smzip"],"application/vnd.stepmania.stepchart":["sm"],"application/vnd.sun.xml.calc":["sxc"],"application/vnd.sun.xml.calc.template":["stc"],"application/vnd.sun.xml.draw":["sxd"],"application/vnd.sun.xml.draw.template":["std"],"application/vnd.sun.xml.impress":["sxi"],"application/vnd.sun.xml.impress.template":["sti"],"application/vnd.sun.xml.math":["sxm"],"application/vnd.sun.xml.writer":["sxw"],"application/vnd.sun.xml.writer.global":["sxg"],"application/vnd.sun.xml.writer.template":["stw"],"application/vnd.sus-calendar":["sus","susp"],"application/vnd.svd":["svd"],"application/vnd.symbian.install":["sis","sisx"],"application/vnd.syncml+xml":["xsm"],"application/vnd.syncml.dm+wbxml":["bdm"],"application/vnd.syncml.dm+xml":["xdm"],"application/vnd.tao.intent-module-archive":["tao"],"application/vnd.tcpdump.pcap":["pcap","cap","dmp"],"application/vnd.tmobile-livetv":["tmo"],"application/vnd.trid.tpt":["tpt"],"application/vnd.triscape.mxs":["mxs"],"application/vnd.trueapp":["tra"],"application/vnd.ufdl":["ufd","ufdl"],"application/vnd.uiq.theme":["utz"],"application/vnd.umajin":["umj"],"application/vnd.unity":["unityweb"],"application/vnd.uoml+xml":["uoml"],"application/vnd.vcx":["vcx"],"application/vnd.visio":["vsd","vst","vss","vsw"],"application/vnd.visionary":["vis"],"application/vnd.vsf":["vsf"],"application/vnd.wap.wbxml":["wbxml"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.wap.wmlscriptc":["wmlsc"],"application/vnd.webturbo":["wtb"],"application/vnd.wolfram.player":["nbp"],"application/vnd.wordperfect":["wpd"],"application/vnd.wqd":["wqd"],"application/vnd.wt.stf":["stf"],"application/vnd.xara":["xar"],"application/vnd.xfdl":["xfdl"],"application/vnd.yamaha.hv-dic":["hvd"],"application/vnd.yamaha.hv-script":["hvs"],"application/vnd.yamaha.hv-voice":["hvp"],"application/vnd.yamaha.openscoreformat":["osf"],"application/vnd.yamaha.openscoreformat.osfpvg+xml":["osfpvg"],"application/vnd.yamaha.smaf-audio":["saf"],"application/vnd.yamaha.smaf-phrase":["spf"],"application/vnd.yellowriver-custom-menu":["cmp"],"application/vnd.zul":["zir","zirz"],"application/vnd.zzazz.deck+xml":["zaz"],"application/voicexml+xml":["vxml"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/x-7z-compressed":["7z"],"application/x-abiword":["abw"],"application/x-ace-compressed":["ace"],"application/x-apple-diskimage":["dmg"],"application/x-authorware-bin":["aab","x32","u32","vox"],"application/x-authorware-map":["aam"],"application/x-authorware-seg":["aas"],"application/x-bcpio":["bcpio"],"application/x-bittorrent":["torrent"],"application/x-blorb":["blb","blorb"],"application/x-bzip":["bz"],"application/x-bzip2":["bz2","boz"],"application/x-cbr":["cbr","cba","cbt","cbz","cb7"],"application/x-cdlink":["vcd"],"application/x-cfs-compressed":["cfs"],"application/x-chat":["chat"],"application/x-chess-pgn":["pgn"],"application/x-chrome-extension":["crx"],"application/x-conference":["nsc"],"application/x-cpio":["cpio"],"application/x-csh":["csh"],"application/x-debian-package":["deb","udeb"],"application/x-dgc-compressed":["dgc"],"application/x-director":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"],"application/x-doom":["wad"],"application/x-dtbncx+xml":["ncx"],"application/x-dtbook+xml":["dtb"],"application/x-dtbresource+xml":["res"],"application/x-dvi":["dvi"],"application/x-envoy":["evy"],"application/x-eva":["eva"],"application/x-font-bdf":["bdf"],"application/x-font-ghostscript":["gsf"],"application/x-font-linux-psf":["psf"],"application/x-font-otf":["otf"],"application/x-font-pcf":["pcf"],"application/x-font-snf":["snf"],"application/x-font-ttf":["ttf","ttc"],"application/x-font-type1":["pfa","pfb","pfm","afm"],"application/x-freearc":["arc"],"application/x-futuresplash":["spl"],"application/x-gca-compressed":["gca"],"application/x-glulx":["ulx"],"application/x-gnumeric":["gnumeric"],"application/x-gramps-xml":["gramps"],"application/x-gtar":["gtar"],"application/x-hdf":["hdf"],"application/x-install-instructions":["install"],"application/x-iso9660-image":["iso"],"application/x-java-jnlp-file":["jnlp"],"application/x-latex":["latex"],"application/x-lua-bytecode":["luac"],"application/x-lzh-compressed":["lzh","lha"],"application/x-mie":["mie"],"application/x-mobipocket-ebook":["prc","mobi"],"application/x-ms-application":["application"],"application/x-ms-shortcut":["lnk"],"application/x-ms-wmd":["wmd"],"application/x-ms-wmz":["wmz"],"application/x-ms-xbap":["xbap"],"application/x-msaccess":["mdb"],"application/x-msbinder":["obd"],"application/x-mscardfile":["crd"],"application/x-msclip":["clp"],"application/x-msdownload":["exe","dll","com","bat","msi"],"application/x-msmediaview":["mvb","m13","m14"],"application/x-msmetafile":["wmf","wmz","emf","emz"],"application/x-msmoney":["mny"],"application/x-mspublisher":["pub"],"application/x-msschedule":["scd"],"application/x-msterminal":["trm"],"application/x-mswrite":["wri"],"application/x-netcdf":["nc","cdf"],"application/x-nzb":["nzb"],"application/x-pkcs12":["p12","pfx"],"application/x-pkcs7-certificates":["p7b","spc"],"application/x-pkcs7-certreqresp":["p7r"],"application/x-rar-compressed":["rar"],"application/x-research-info-systems":["ris"],"application/x-sh":["sh"],"application/x-shar":["shar"],"application/x-shockwave-flash":["swf"],"application/x-silverlight-app":["xap"],"application/x-sql":["sql"],"application/x-stuffit":["sit"],"application/x-stuffitx":["sitx"],"application/x-subrip":["srt"],"application/x-sv4cpio":["sv4cpio"],"application/x-sv4crc":["sv4crc"],"application/x-t3vm-image":["t3"],"application/x-tads":["gam"],"application/x-tar":["tar"],"application/x-tcl":["tcl"],"application/x-tex":["tex"],"application/x-tex-tfm":["tfm"],"application/x-texinfo":["texinfo","texi"],"application/x-tgif":["obj"],"application/x-ustar":["ustar"],"application/x-wais-source":["src"],"application/x-web-app-manifest+json":["webapp"],"application/x-x509-ca-cert":["der","crt"],"application/x-xfig":["fig"],"application/x-xliff+xml":["xlf"],"application/x-xpinstall":["xpi"],"application/x-xz":["xz"],"application/x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"application/xaml+xml":["xaml"],"application/xcap-diff+xml":["xdf"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xml":["xml","xsl","xsd"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/adpcm":["adp"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mp4":["mp4a","m4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/webm":["weba"],"audio/x-aac":["aac"],"audio/x-aiff":["aif","aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-wav":["wav"],"audio/xm":["xm"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"font/opentype":["otf"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/g3fax":["g3"],"image/gif":["gif"],"image/ief":["ief"],"image/jpeg":["jpeg","jpg","jpe"],"image/ktx":["ktx"],"image/png":["png"],"image/prs.btif":["btif"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/tiff":["tiff","tif"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dvb.subtitle":["sub"],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/webp":["webp"],"image/x-3ds":["3ds"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["ico"],"image/x-mrsid-image":["sid"],"image/x-pcx":["pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/rfc822":["eml","mime"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/vnd.collada+xml":["dae"],"model/vnd.dwf":["dwf"],"model/vnd.gdl":["gdl"],"model/vnd.gtw":["gtw"],"model/vnd.mts":["mts"],"model/vnd.vtu":["vtu"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["x3db","x3dbz"],"model/x3d+vrml":["x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee"],"text/css":["css"],"text/csv":["csv"],"text/hjson":["hjson"],"text/html":["html","htm"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/prs.lines.tag":["dsc"],"text/richtext":["rtx"],"text/sgml":["sgml","sgm"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vnd.curl":["curl"],"text/vnd.curl.dcurl":["dcurl"],"text/vnd.curl.mcurl":["mcurl"],"text/vnd.curl.scurl":["scurl"],"text/vnd.dvb.subtitle":["sub"],"text/vnd.fly":["fly"],"text/vnd.fmi.flexstor":["flx"],"text/vnd.graphviz":["gv"],"text/vnd.in3d.3dml":["3dml"],"text/vnd.in3d.spot":["spot"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/vnd.wap.wmlscript":["wmls"],"text/vtt":["vtt"],"text/x-asm":["s","asm"],"text/x-c":["c","cc","cxx","cpp","h","hh","dic"],"text/x-component":["htc"],"text/x-fortran":["f","for","f77","f90"],"text/x-handlebars-template":["hbs"],"text/x-java-source":["java"],"text/x-lua":["lua"],"text/x-markdown":["markdown","md","mkd"],"text/x-nfo":["nfo"],"text/x-opml":["opml"],"text/x-pascal":["p","pas"],"text/x-sass":["sass"],"text/x-scss":["scss"],"text/x-setext":["etx"],"text/x-sfv":["sfv"],"text/x-uuencode":["uu"],"text/x-vcalendar":["vcs"],"text/x-vcard":["vcf"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/jpeg":["jpgv"],"video/jpm":["jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/vnd.dece.hd":["uvh","uvvh"],"video/vnd.dece.mobile":["uvm","uvvm"],"video/vnd.dece.pd":["uvp","uvvp"],"video/vnd.dece.sd":["uvs","uvvs"],"video/vnd.dece.video":["uvv","uvvv"],"video/vnd.dvb.file":["dvb"],"video/vnd.fvt":["fvt"],"video/vnd.mpegurl":["mxu","m4u"],"video/vnd.ms-playready.media.pyv":["pyv"],"video/vnd.uvvu.mp4":["uvu","uvvu"],"video/vnd.vivo":["viv"],"video/webm":["webm"],"video/x-f4v":["f4v"],"video/x-fli":["fli"],"video/x-flv":["flv"],"video/x-m4v":["m4v"],"video/x-matroska":["mkv","mk3d","mks"],"video/x-mng":["mng"],"video/x-ms-asf":["asf","asx"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]} diff --git a/ui/node_modules/express/node_modules/send/node_modules/ms/.npmignore b/ui/node_modules/express/node_modules/send/node_modules/ms/.npmignore index 93216885..d1aa0ce4 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/ms/.npmignore +++ b/ui/node_modules/express/node_modules/send/node_modules/ms/.npmignore @@ -1,5 +1,5 @@ -node_modules -test -History.md -Makefile -component.json +node_modules +test +History.md +Makefile +component.json diff --git a/ui/node_modules/express/node_modules/send/node_modules/ms/History.md b/ui/node_modules/express/node_modules/send/node_modules/ms/History.md index c9715f87..32fdfc17 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/ms/History.md +++ b/ui/node_modules/express/node_modules/send/node_modules/ms/History.md @@ -1,66 +1,66 @@ - -0.7.1 / 2015-04-20 -================== - - * prevent extraordinary long inputs (@evilpacket) - * Fixed broken readme link - -0.7.0 / 2014-11-24 -================== - - * add time abbreviations, updated tests and readme for the new units - * fix example in the readme. - * add LICENSE file - -0.6.2 / 2013-12-05 -================== - - * Adding repository section to package.json to suppress warning from NPM. - -0.6.1 / 2013-05-10 -================== - - * fix singularization [visionmedia] - -0.6.0 / 2013-03-15 -================== - - * fix minutes - -0.5.1 / 2013-02-24 -================== - - * add component namespace - -0.5.0 / 2012-11-09 -================== - - * add short formatting as default and .long option - * add .license property to component.json - * add version to component.json - -0.4.0 / 2012-10-22 -================== - - * add rounding to fix crazy decimals - -0.3.0 / 2012-09-07 -================== - - * fix `ms()` [visionmedia] - -0.2.0 / 2012-09-03 -================== - - * add component.json [visionmedia] - * add days support [visionmedia] - * add hours support [visionmedia] - * add minutes support [visionmedia] - * add seconds support [visionmedia] - * add ms string support [visionmedia] - * refactor tests to facilitate ms(number) [visionmedia] - -0.1.0 / 2012-03-07 -================== - - * Initial release + +0.7.1 / 2015-04-20 +================== + + * prevent extraordinary long inputs (@evilpacket) + * Fixed broken readme link + +0.7.0 / 2014-11-24 +================== + + * add time abbreviations, updated tests and readme for the new units + * fix example in the readme. + * add LICENSE file + +0.6.2 / 2013-12-05 +================== + + * Adding repository section to package.json to suppress warning from NPM. + +0.6.1 / 2013-05-10 +================== + + * fix singularization [visionmedia] + +0.6.0 / 2013-03-15 +================== + + * fix minutes + +0.5.1 / 2013-02-24 +================== + + * add component namespace + +0.5.0 / 2012-11-09 +================== + + * add short formatting as default and .long option + * add .license property to component.json + * add version to component.json + +0.4.0 / 2012-10-22 +================== + + * add rounding to fix crazy decimals + +0.3.0 / 2012-09-07 +================== + + * fix `ms()` [visionmedia] + +0.2.0 / 2012-09-03 +================== + + * add component.json [visionmedia] + * add days support [visionmedia] + * add hours support [visionmedia] + * add minutes support [visionmedia] + * add seconds support [visionmedia] + * add ms string support [visionmedia] + * refactor tests to facilitate ms(number) [visionmedia] + +0.1.0 / 2012-03-07 +================== + + * Initial release diff --git a/ui/node_modules/express/node_modules/send/node_modules/ms/LICENSE b/ui/node_modules/express/node_modules/send/node_modules/ms/LICENSE index 5b078ede..6c07561b 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/ms/LICENSE +++ b/ui/node_modules/express/node_modules/send/node_modules/ms/LICENSE @@ -1,20 +1,20 @@ -(The MIT License) - -Copyright (c) 2014 Guillermo Rauch - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2014 Guillermo Rauch + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/send/node_modules/ms/README.md b/ui/node_modules/express/node_modules/send/node_modules/ms/README.md index 7e3e27f9..9b4fd035 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/ms/README.md +++ b/ui/node_modules/express/node_modules/send/node_modules/ms/README.md @@ -1,35 +1,35 @@ -# ms.js: miliseconds conversion utility - -```js -ms('2 days') // 172800000 -ms('1d') // 86400000 -ms('10h') // 36000000 -ms('2.5 hrs') // 9000000 -ms('2h') // 7200000 -ms('1m') // 60000 -ms('5s') // 5000 -ms('100') // 100 -``` - -```js -ms(60000) // "1m" -ms(2 * 60000) // "2m" -ms(ms('10 hours')) // "10h" -``` - -```js -ms(60000, { long: true }) // "1 minute" -ms(2 * 60000, { long: true }) // "2 minutes" -ms(ms('10 hours'), { long: true }) // "10 hours" -``` - -- Node/Browser compatible. Published as [`ms`](https://www.npmjs.org/package/ms) in [NPM](http://nodejs.org/download). -- If a number is supplied to `ms`, a string with a unit is returned. -- If a string that contains the number is supplied, it returns it as -a number (e.g: it returns `100` for `'100'`). -- If you pass a string with a number and a valid unit, the number of -equivalent ms is returned. - -## License - -MIT +# ms.js: miliseconds conversion utility + +```js +ms('2 days') // 172800000 +ms('1d') // 86400000 +ms('10h') // 36000000 +ms('2.5 hrs') // 9000000 +ms('2h') // 7200000 +ms('1m') // 60000 +ms('5s') // 5000 +ms('100') // 100 +``` + +```js +ms(60000) // "1m" +ms(2 * 60000) // "2m" +ms(ms('10 hours')) // "10h" +``` + +```js +ms(60000, { long: true }) // "1 minute" +ms(2 * 60000, { long: true }) // "2 minutes" +ms(ms('10 hours'), { long: true }) // "10 hours" +``` + +- Node/Browser compatible. Published as [`ms`](https://www.npmjs.org/package/ms) in [NPM](http://nodejs.org/download). +- If a number is supplied to `ms`, a string with a unit is returned. +- If a string that contains the number is supplied, it returns it as +a number (e.g: it returns `100` for `'100'`). +- If you pass a string with a number and a valid unit, the number of +equivalent ms is returned. + +## License + +MIT diff --git a/ui/node_modules/express/node_modules/send/node_modules/ms/index.js b/ui/node_modules/express/node_modules/send/node_modules/ms/index.js index dd9a4607..4f927716 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/ms/index.js +++ b/ui/node_modules/express/node_modules/send/node_modules/ms/index.js @@ -1,125 +1,125 @@ -/** - * Helpers. - */ - -var s = 1000; -var m = s * 60; -var h = m * 60; -var d = h * 24; -var y = d * 365.25; - -/** - * Parse or format the given `val`. - * - * Options: - * - * - `long` verbose formatting [false] - * - * @param {String|Number} val - * @param {Object} options - * @return {String|Number} - * @api public - */ - -module.exports = function(val, options){ - options = options || {}; - if ('string' == typeof val) return parse(val); - return options.long - ? long(val) - : short(val); -}; - -/** - * Parse the given `str` and return milliseconds. - * - * @param {String} str - * @return {Number} - * @api private - */ - -function parse(str) { - str = '' + str; - if (str.length > 10000) return; - var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str); - if (!match) return; - var n = parseFloat(match[1]); - var type = (match[2] || 'ms').toLowerCase(); - switch (type) { - case 'years': - case 'year': - case 'yrs': - case 'yr': - case 'y': - return n * y; - case 'days': - case 'day': - case 'd': - return n * d; - case 'hours': - case 'hour': - case 'hrs': - case 'hr': - case 'h': - return n * h; - case 'minutes': - case 'minute': - case 'mins': - case 'min': - case 'm': - return n * m; - case 'seconds': - case 'second': - case 'secs': - case 'sec': - case 's': - return n * s; - case 'milliseconds': - case 'millisecond': - case 'msecs': - case 'msec': - case 'ms': - return n; - } -} - -/** - * Short format for `ms`. - * - * @param {Number} ms - * @return {String} - * @api private - */ - -function short(ms) { - if (ms >= d) return Math.round(ms / d) + 'd'; - if (ms >= h) return Math.round(ms / h) + 'h'; - if (ms >= m) return Math.round(ms / m) + 'm'; - if (ms >= s) return Math.round(ms / s) + 's'; - return ms + 'ms'; -} - -/** - * Long format for `ms`. - * - * @param {Number} ms - * @return {String} - * @api private - */ - -function long(ms) { - return plural(ms, d, 'day') - || plural(ms, h, 'hour') - || plural(ms, m, 'minute') - || plural(ms, s, 'second') - || ms + ' ms'; -} - -/** - * Pluralization helper. - */ - -function plural(ms, n, name) { - if (ms < n) return; - if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name; - return Math.ceil(ms / n) + ' ' + name + 's'; -} +/** + * Helpers. + */ + +var s = 1000; +var m = s * 60; +var h = m * 60; +var d = h * 24; +var y = d * 365.25; + +/** + * Parse or format the given `val`. + * + * Options: + * + * - `long` verbose formatting [false] + * + * @param {String|Number} val + * @param {Object} options + * @return {String|Number} + * @api public + */ + +module.exports = function(val, options){ + options = options || {}; + if ('string' == typeof val) return parse(val); + return options.long + ? long(val) + : short(val); +}; + +/** + * Parse the given `str` and return milliseconds. + * + * @param {String} str + * @return {Number} + * @api private + */ + +function parse(str) { + str = '' + str; + if (str.length > 10000) return; + var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str); + if (!match) return; + var n = parseFloat(match[1]); + var type = (match[2] || 'ms').toLowerCase(); + switch (type) { + case 'years': + case 'year': + case 'yrs': + case 'yr': + case 'y': + return n * y; + case 'days': + case 'day': + case 'd': + return n * d; + case 'hours': + case 'hour': + case 'hrs': + case 'hr': + case 'h': + return n * h; + case 'minutes': + case 'minute': + case 'mins': + case 'min': + case 'm': + return n * m; + case 'seconds': + case 'second': + case 'secs': + case 'sec': + case 's': + return n * s; + case 'milliseconds': + case 'millisecond': + case 'msecs': + case 'msec': + case 'ms': + return n; + } +} + +/** + * Short format for `ms`. + * + * @param {Number} ms + * @return {String} + * @api private + */ + +function short(ms) { + if (ms >= d) return Math.round(ms / d) + 'd'; + if (ms >= h) return Math.round(ms / h) + 'h'; + if (ms >= m) return Math.round(ms / m) + 'm'; + if (ms >= s) return Math.round(ms / s) + 's'; + return ms + 'ms'; +} + +/** + * Long format for `ms`. + * + * @param {Number} ms + * @return {String} + * @api private + */ + +function long(ms) { + return plural(ms, d, 'day') + || plural(ms, h, 'hour') + || plural(ms, m, 'minute') + || plural(ms, s, 'second') + || ms + ' ms'; +} + +/** + * Pluralization helper. + */ + +function plural(ms, n, name) { + if (ms < n) return; + if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name; + return Math.ceil(ms / n) + ' ' + name + 's'; +} diff --git a/ui/node_modules/express/node_modules/send/node_modules/ms/package.json b/ui/node_modules/express/node_modules/send/node_modules/ms/package.json index 5a896a3a..e36489ef 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/ms/package.json +++ b/ui/node_modules/express/node_modules/send/node_modules/ms/package.json @@ -1,48 +1,48 @@ -{ - "name": "ms", - "version": "0.7.1", - "description": "Tiny ms conversion utility", - "repository": { - "type": "git", - "url": "git://github.com/guille/ms.js.git" - }, - "main": "./index", - "devDependencies": { - "mocha": "*", - "expect.js": "*", - "serve": "*" - }, - "component": { - "scripts": { - "ms/index.js": "index.js" - } - }, - "gitHead": "713dcf26d9e6fd9dbc95affe7eff9783b7f1b909", - "bugs": { - "url": "https://github.com/guille/ms.js/issues" - }, - "homepage": "https://github.com/guille/ms.js", - "_id": "ms@0.7.1", - "scripts": {}, - "_shasum": "9cd13c03adbff25b65effde7ce864ee952017098", - "_from": "ms@0.7.1", - "_npmVersion": "2.7.5", - "_nodeVersion": "0.12.2", - "_npmUser": { - "name": "rauchg", - "email": "rauchg@gmail.com" - }, - "maintainers": [ - { - "name": "rauchg", - "email": "rauchg@gmail.com" - } - ], - "dist": { - "shasum": "9cd13c03adbff25b65effde7ce864ee952017098", - "tarball": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "ms", + "version": "0.7.1", + "description": "Tiny ms conversion utility", + "repository": { + "type": "git", + "url": "git://github.com/guille/ms.js.git" + }, + "main": "./index", + "devDependencies": { + "mocha": "*", + "expect.js": "*", + "serve": "*" + }, + "component": { + "scripts": { + "ms/index.js": "index.js" + } + }, + "gitHead": "713dcf26d9e6fd9dbc95affe7eff9783b7f1b909", + "bugs": { + "url": "https://github.com/guille/ms.js/issues" + }, + "homepage": "https://github.com/guille/ms.js", + "_id": "ms@0.7.1", + "scripts": {}, + "_shasum": "9cd13c03adbff25b65effde7ce864ee952017098", + "_from": "ms@0.7.1", + "_npmVersion": "2.7.5", + "_nodeVersion": "0.12.2", + "_npmUser": { + "name": "rauchg", + "email": "rauchg@gmail.com" + }, + "maintainers": [ + { + "name": "rauchg", + "email": "rauchg@gmail.com" + } + ], + "dist": { + "shasum": "9cd13c03adbff25b65effde7ce864ee952017098", + "tarball": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/send/node_modules/statuses/HISTORY.md b/ui/node_modules/express/node_modules/send/node_modules/statuses/HISTORY.md index 063b4bc9..b175575c 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/statuses/HISTORY.md +++ b/ui/node_modules/express/node_modules/send/node_modules/statuses/HISTORY.md @@ -1,50 +1,50 @@ -1.3.0 / 2016-05-17 -================== - - * Add `421 Misdirected Request` - * perf: enable strict mode - -1.2.1 / 2015-02-01 -================== - - * Fix message for status 451 - - `451 Unavailable For Legal Reasons` - -1.2.0 / 2014-09-28 -================== - - * Add `208 Already Repored` - * Add `226 IM Used` - * Add `306 (Unused)` - * Add `415 Unable For Legal Reasons` - * Add `508 Loop Detected` - -1.1.1 / 2014-09-24 -================== - - * Add missing 308 to `codes.json` - -1.1.0 / 2014-09-21 -================== - - * Add `codes.json` for universal support - -1.0.4 / 2014-08-20 -================== - - * Package cleanup - -1.0.3 / 2014-06-08 -================== - - * Add 308 to `.redirect` category - -1.0.2 / 2014-03-13 -================== - - * Add `.retry` category - -1.0.1 / 2014-03-12 -================== - - * Initial release +1.3.0 / 2016-05-17 +================== + + * Add `421 Misdirected Request` + * perf: enable strict mode + +1.2.1 / 2015-02-01 +================== + + * Fix message for status 451 + - `451 Unavailable For Legal Reasons` + +1.2.0 / 2014-09-28 +================== + + * Add `208 Already Repored` + * Add `226 IM Used` + * Add `306 (Unused)` + * Add `415 Unable For Legal Reasons` + * Add `508 Loop Detected` + +1.1.1 / 2014-09-24 +================== + + * Add missing 308 to `codes.json` + +1.1.0 / 2014-09-21 +================== + + * Add `codes.json` for universal support + +1.0.4 / 2014-08-20 +================== + + * Package cleanup + +1.0.3 / 2014-06-08 +================== + + * Add 308 to `.redirect` category + +1.0.2 / 2014-03-13 +================== + + * Add `.retry` category + +1.0.1 / 2014-03-12 +================== + + * Initial release diff --git a/ui/node_modules/express/node_modules/send/node_modules/statuses/LICENSE b/ui/node_modules/express/node_modules/send/node_modules/statuses/LICENSE index c232b56f..82af4df5 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/statuses/LICENSE +++ b/ui/node_modules/express/node_modules/send/node_modules/statuses/LICENSE @@ -1,23 +1,23 @@ - -The MIT License (MIT) - -Copyright (c) 2014 Jonathan Ong me@jongleberry.com -Copyright (c) 2016 Douglas Christopher Wilson doug@somethingdoug.com - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. + +The MIT License (MIT) + +Copyright (c) 2014 Jonathan Ong me@jongleberry.com +Copyright (c) 2016 Douglas Christopher Wilson doug@somethingdoug.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/send/node_modules/statuses/README.md b/ui/node_modules/express/node_modules/send/node_modules/statuses/README.md index 7868753e..1a699da0 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/statuses/README.md +++ b/ui/node_modules/express/node_modules/send/node_modules/statuses/README.md @@ -1,114 +1,114 @@ -# Statuses - -[![NPM Version][npm-image]][npm-url] -[![NPM Downloads][downloads-image]][downloads-url] -[![Node.js Version][node-version-image]][node-version-url] -[![Build Status][travis-image]][travis-url] -[![Test Coverage][coveralls-image]][coveralls-url] - -HTTP status utility for node. - -## API - -```js -var status = require('statuses') -``` - -### var code = status(Integer || String) - -If `Integer` or `String` is a valid HTTP code or status message, then the appropriate `code` will be returned. Otherwise, an error will be thrown. - -```js -status(403) // => 403 -status('403') // => 403 -status('forbidden') // => 403 -status('Forbidden') // => 403 -status(306) // throws, as it's not supported by node.js -``` - -### status.codes - -Returns an array of all the status codes as `Integer`s. - -### var msg = status[code] - -Map of `code` to `status message`. `undefined` for invalid `code`s. - -```js -status[404] // => 'Not Found' -``` - -### var code = status[msg] - -Map of `status message` to `code`. `msg` can either be title-cased or lower-cased. `undefined` for invalid `status message`s. - -```js -status['not found'] // => 404 -status['Not Found'] // => 404 -``` - -### status.redirect[code] - -Returns `true` if a status code is a valid redirect status. - -```js -status.redirect[200] // => undefined -status.redirect[301] // => true -``` - -### status.empty[code] - -Returns `true` if a status code expects an empty body. - -```js -status.empty[200] // => undefined -status.empty[204] // => true -status.empty[304] // => true -``` - -### status.retry[code] - -Returns `true` if you should retry the rest. - -```js -status.retry[501] // => undefined -status.retry[503] // => true -``` - -### statuses/codes.json - -```js -var codes = require('statuses/codes.json') -``` - -This is a JSON file of the status codes -taken from `require('http').STATUS_CODES`. -This is saved so that codes are consistent even in older node.js versions. -For example, `308` will be added in v0.12. - -## Adding Status Codes - -The status codes are primarily sourced from http://www.iana.org/assignments/http-status-codes/http-status-codes-1.csv. -Additionally, custom codes are added from http://en.wikipedia.org/wiki/List_of_HTTP_status_codes. -These are added manually in the `lib/*.json` files. -If you would like to add a status code, add it to the appropriate JSON file. - -To rebuild `codes.json`, run the following: - -```bash -# update src/iana.json -npm run fetch -# build codes.json -npm run build -``` - -[npm-image]: https://img.shields.io/npm/v/statuses.svg -[npm-url]: https://npmjs.org/package/statuses -[node-version-image]: https://img.shields.io/badge/node.js-%3E%3D_0.6-brightgreen.svg -[node-version-url]: https://nodejs.org/en/download -[travis-image]: https://img.shields.io/travis/jshttp/statuses.svg -[travis-url]: https://travis-ci.org/jshttp/statuses -[coveralls-image]: https://img.shields.io/coveralls/jshttp/statuses.svg -[coveralls-url]: https://coveralls.io/r/jshttp/statuses?branch=master -[downloads-image]: https://img.shields.io/npm/dm/statuses.svg -[downloads-url]: https://npmjs.org/package/statuses +# Statuses + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-version-image]][node-version-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +HTTP status utility for node. + +## API + +```js +var status = require('statuses') +``` + +### var code = status(Integer || String) + +If `Integer` or `String` is a valid HTTP code or status message, then the appropriate `code` will be returned. Otherwise, an error will be thrown. + +```js +status(403) // => 403 +status('403') // => 403 +status('forbidden') // => 403 +status('Forbidden') // => 403 +status(306) // throws, as it's not supported by node.js +``` + +### status.codes + +Returns an array of all the status codes as `Integer`s. + +### var msg = status[code] + +Map of `code` to `status message`. `undefined` for invalid `code`s. + +```js +status[404] // => 'Not Found' +``` + +### var code = status[msg] + +Map of `status message` to `code`. `msg` can either be title-cased or lower-cased. `undefined` for invalid `status message`s. + +```js +status['not found'] // => 404 +status['Not Found'] // => 404 +``` + +### status.redirect[code] + +Returns `true` if a status code is a valid redirect status. + +```js +status.redirect[200] // => undefined +status.redirect[301] // => true +``` + +### status.empty[code] + +Returns `true` if a status code expects an empty body. + +```js +status.empty[200] // => undefined +status.empty[204] // => true +status.empty[304] // => true +``` + +### status.retry[code] + +Returns `true` if you should retry the rest. + +```js +status.retry[501] // => undefined +status.retry[503] // => true +``` + +### statuses/codes.json + +```js +var codes = require('statuses/codes.json') +``` + +This is a JSON file of the status codes +taken from `require('http').STATUS_CODES`. +This is saved so that codes are consistent even in older node.js versions. +For example, `308` will be added in v0.12. + +## Adding Status Codes + +The status codes are primarily sourced from http://www.iana.org/assignments/http-status-codes/http-status-codes-1.csv. +Additionally, custom codes are added from http://en.wikipedia.org/wiki/List_of_HTTP_status_codes. +These are added manually in the `lib/*.json` files. +If you would like to add a status code, add it to the appropriate JSON file. + +To rebuild `codes.json`, run the following: + +```bash +# update src/iana.json +npm run fetch +# build codes.json +npm run build +``` + +[npm-image]: https://img.shields.io/npm/v/statuses.svg +[npm-url]: https://npmjs.org/package/statuses +[node-version-image]: https://img.shields.io/badge/node.js-%3E%3D_0.6-brightgreen.svg +[node-version-url]: https://nodejs.org/en/download +[travis-image]: https://img.shields.io/travis/jshttp/statuses.svg +[travis-url]: https://travis-ci.org/jshttp/statuses +[coveralls-image]: https://img.shields.io/coveralls/jshttp/statuses.svg +[coveralls-url]: https://coveralls.io/r/jshttp/statuses?branch=master +[downloads-image]: https://img.shields.io/npm/dm/statuses.svg +[downloads-url]: https://npmjs.org/package/statuses diff --git a/ui/node_modules/express/node_modules/send/node_modules/statuses/codes.json b/ui/node_modules/express/node_modules/send/node_modules/statuses/codes.json index 89e43eac..e7651233 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/statuses/codes.json +++ b/ui/node_modules/express/node_modules/send/node_modules/statuses/codes.json @@ -1,65 +1,65 @@ -{ - "100": "Continue", - "101": "Switching Protocols", - "102": "Processing", - "200": "OK", - "201": "Created", - "202": "Accepted", - "203": "Non-Authoritative Information", - "204": "No Content", - "205": "Reset Content", - "206": "Partial Content", - "207": "Multi-Status", - "208": "Already Reported", - "226": "IM Used", - "300": "Multiple Choices", - "301": "Moved Permanently", - "302": "Found", - "303": "See Other", - "304": "Not Modified", - "305": "Use Proxy", - "306": "(Unused)", - "307": "Temporary Redirect", - "308": "Permanent Redirect", - "400": "Bad Request", - "401": "Unauthorized", - "402": "Payment Required", - "403": "Forbidden", - "404": "Not Found", - "405": "Method Not Allowed", - "406": "Not Acceptable", - "407": "Proxy Authentication Required", - "408": "Request Timeout", - "409": "Conflict", - "410": "Gone", - "411": "Length Required", - "412": "Precondition Failed", - "413": "Payload Too Large", - "414": "URI Too Long", - "415": "Unsupported Media Type", - "416": "Range Not Satisfiable", - "417": "Expectation Failed", - "418": "I'm a teapot", - "421": "Misdirected Request", - "422": "Unprocessable Entity", - "423": "Locked", - "424": "Failed Dependency", - "425": "Unordered Collection", - "426": "Upgrade Required", - "428": "Precondition Required", - "429": "Too Many Requests", - "431": "Request Header Fields Too Large", - "451": "Unavailable For Legal Reasons", - "500": "Internal Server Error", - "501": "Not Implemented", - "502": "Bad Gateway", - "503": "Service Unavailable", - "504": "Gateway Timeout", - "505": "HTTP Version Not Supported", - "506": "Variant Also Negotiates", - "507": "Insufficient Storage", - "508": "Loop Detected", - "509": "Bandwidth Limit Exceeded", - "510": "Not Extended", - "511": "Network Authentication Required" +{ + "100": "Continue", + "101": "Switching Protocols", + "102": "Processing", + "200": "OK", + "201": "Created", + "202": "Accepted", + "203": "Non-Authoritative Information", + "204": "No Content", + "205": "Reset Content", + "206": "Partial Content", + "207": "Multi-Status", + "208": "Already Reported", + "226": "IM Used", + "300": "Multiple Choices", + "301": "Moved Permanently", + "302": "Found", + "303": "See Other", + "304": "Not Modified", + "305": "Use Proxy", + "306": "(Unused)", + "307": "Temporary Redirect", + "308": "Permanent Redirect", + "400": "Bad Request", + "401": "Unauthorized", + "402": "Payment Required", + "403": "Forbidden", + "404": "Not Found", + "405": "Method Not Allowed", + "406": "Not Acceptable", + "407": "Proxy Authentication Required", + "408": "Request Timeout", + "409": "Conflict", + "410": "Gone", + "411": "Length Required", + "412": "Precondition Failed", + "413": "Payload Too Large", + "414": "URI Too Long", + "415": "Unsupported Media Type", + "416": "Range Not Satisfiable", + "417": "Expectation Failed", + "418": "I'm a teapot", + "421": "Misdirected Request", + "422": "Unprocessable Entity", + "423": "Locked", + "424": "Failed Dependency", + "425": "Unordered Collection", + "426": "Upgrade Required", + "428": "Precondition Required", + "429": "Too Many Requests", + "431": "Request Header Fields Too Large", + "451": "Unavailable For Legal Reasons", + "500": "Internal Server Error", + "501": "Not Implemented", + "502": "Bad Gateway", + "503": "Service Unavailable", + "504": "Gateway Timeout", + "505": "HTTP Version Not Supported", + "506": "Variant Also Negotiates", + "507": "Insufficient Storage", + "508": "Loop Detected", + "509": "Bandwidth Limit Exceeded", + "510": "Not Extended", + "511": "Network Authentication Required" } \ No newline at end of file diff --git a/ui/node_modules/express/node_modules/send/node_modules/statuses/index.js b/ui/node_modules/express/node_modules/send/node_modules/statuses/index.js index 63aa6cee..c2b555a2 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/statuses/index.js +++ b/ui/node_modules/express/node_modules/send/node_modules/statuses/index.js @@ -1,110 +1,110 @@ -/*! - * statuses - * Copyright(c) 2014 Jonathan Ong - * Copyright(c) 2016 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict' - -/** - * Module dependencies. - * @private - */ - -var codes = require('./codes.json') - -/** - * Module exports. - * @public - */ - -module.exports = status - -// array of status codes -status.codes = populateStatusesMap(status, codes) - -// status codes for redirects -status.redirect = { - 300: true, - 301: true, - 302: true, - 303: true, - 305: true, - 307: true, - 308: true -} - -// status codes for empty bodies -status.empty = { - 204: true, - 205: true, - 304: true -} - -// status codes for when you should retry the request -status.retry = { - 502: true, - 503: true, - 504: true -} - -/** - * Populate the statuses map for given codes. - * @private - */ - -function populateStatusesMap (statuses, codes) { - var arr = [] - - Object.keys(codes).forEach(function forEachCode (code) { - var message = codes[code] - var status = Number(code) - - // Populate properties - statuses[status] = message - statuses[message] = status - statuses[message.toLowerCase()] = status - - // Add to array - arr.push(status) - }) - - return arr -} - -/** - * Get the status code. - * - * Given a number, this will throw if it is not a known status - * code, otherwise the code will be returned. Given a string, - * the string will be parsed for a number and return the code - * if valid, otherwise will lookup the code assuming this is - * the status message. - * - * @param {string|number} code - * @returns {string} - * @public - */ - -function status (code) { - if (typeof code === 'number') { - if (!status[code]) throw new Error('invalid status code: ' + code) - return code - } - - if (typeof code !== 'string') { - throw new TypeError('code must be a number or string') - } - - // '403' - var n = parseInt(code, 10) - if (!isNaN(n)) { - if (!status[n]) throw new Error('invalid status code: ' + n) - return n - } - - n = status[code.toLowerCase()] - if (!n) throw new Error('invalid status message: "' + code + '"') - return n -} +/*! + * statuses + * Copyright(c) 2014 Jonathan Ong + * Copyright(c) 2016 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module dependencies. + * @private + */ + +var codes = require('./codes.json') + +/** + * Module exports. + * @public + */ + +module.exports = status + +// array of status codes +status.codes = populateStatusesMap(status, codes) + +// status codes for redirects +status.redirect = { + 300: true, + 301: true, + 302: true, + 303: true, + 305: true, + 307: true, + 308: true +} + +// status codes for empty bodies +status.empty = { + 204: true, + 205: true, + 304: true +} + +// status codes for when you should retry the request +status.retry = { + 502: true, + 503: true, + 504: true +} + +/** + * Populate the statuses map for given codes. + * @private + */ + +function populateStatusesMap (statuses, codes) { + var arr = [] + + Object.keys(codes).forEach(function forEachCode (code) { + var message = codes[code] + var status = Number(code) + + // Populate properties + statuses[status] = message + statuses[message] = status + statuses[message.toLowerCase()] = status + + // Add to array + arr.push(status) + }) + + return arr +} + +/** + * Get the status code. + * + * Given a number, this will throw if it is not a known status + * code, otherwise the code will be returned. Given a string, + * the string will be parsed for a number and return the code + * if valid, otherwise will lookup the code assuming this is + * the status message. + * + * @param {string|number} code + * @returns {string} + * @public + */ + +function status (code) { + if (typeof code === 'number') { + if (!status[code]) throw new Error('invalid status code: ' + code) + return code + } + + if (typeof code !== 'string') { + throw new TypeError('code must be a number or string') + } + + // '403' + var n = parseInt(code, 10) + if (!isNaN(n)) { + if (!status[n]) throw new Error('invalid status code: ' + n) + return n + } + + n = status[code.toLowerCase()] + if (!n) throw new Error('invalid status message: "' + code + '"') + return n +} diff --git a/ui/node_modules/express/node_modules/send/node_modules/statuses/package.json b/ui/node_modules/express/node_modules/send/node_modules/statuses/package.json index 349925d9..450531a4 100644 --- a/ui/node_modules/express/node_modules/send/node_modules/statuses/package.json +++ b/ui/node_modules/express/node_modules/send/node_modules/statuses/package.json @@ -1,104 +1,104 @@ -{ - "name": "statuses", - "description": "HTTP status utility", - "version": "1.3.0", - "contributors": [ - { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "Jonathan Ong", - "email": "me@jongleberry.com", - "url": "http://jongleberry.com" - } - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/statuses.git" - }, - "license": "MIT", - "keywords": [ - "http", - "status", - "code" - ], - "files": [ - "HISTORY.md", - "index.js", - "codes.json", - "LICENSE" - ], - "devDependencies": { - "csv-parse": "1.0.1", - "eslint": "2.10.2", - "eslint-config-standard": "5.3.1", - "eslint-plugin-promise": "1.1.0", - "eslint-plugin-standard": "1.3.2", - "istanbul": "0.4.3", - "mocha": "1.21.5", - "stream-to-array": "2.2.0" - }, - "engines": { - "node": ">= 0.6" - }, - "scripts": { - "build": "node scripts/build.js", - "fetch": "node scripts/fetch.js", - "lint": "eslint **/*.js", - "test": "mocha --reporter spec --check-leaks --bail test/", - "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", - "update": "npm run fetch && npm run build" - }, - "gitHead": "b3e31e8c32dd8107e898b44b8c0b2dfff3cba495", - "bugs": { - "url": "https://github.com/jshttp/statuses/issues" - }, - "homepage": "https://github.com/jshttp/statuses", - "_id": "statuses@1.3.0", - "_shasum": "8e55758cb20e7682c1f4fce8dcab30bf01d1e07a", - "_from": "statuses@>=1.3.0 <1.4.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "defunctzombie", - "email": "shtylman@gmail.com" - }, - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "fishrock123", - "email": "fishrock123@rocketmail.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "mscdex", - "email": "mscdex@mscdex.net" - }, - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - } - ], - "dist": { - "shasum": "8e55758cb20e7682c1f4fce8dcab30bf01d1e07a", - "tarball": "https://registry.npmjs.org/statuses/-/statuses-1.3.0.tgz" - }, - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/statuses-1.3.0.tgz_1463517875633_0.19560232176445425" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.0.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "statuses", + "description": "HTTP status utility", + "version": "1.3.0", + "contributors": [ + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "Jonathan Ong", + "email": "me@jongleberry.com", + "url": "http://jongleberry.com" + } + ], + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/statuses.git" + }, + "license": "MIT", + "keywords": [ + "http", + "status", + "code" + ], + "files": [ + "HISTORY.md", + "index.js", + "codes.json", + "LICENSE" + ], + "devDependencies": { + "csv-parse": "1.0.1", + "eslint": "2.10.2", + "eslint-config-standard": "5.3.1", + "eslint-plugin-promise": "1.1.0", + "eslint-plugin-standard": "1.3.2", + "istanbul": "0.4.3", + "mocha": "1.21.5", + "stream-to-array": "2.2.0" + }, + "engines": { + "node": ">= 0.6" + }, + "scripts": { + "build": "node scripts/build.js", + "fetch": "node scripts/fetch.js", + "lint": "eslint **/*.js", + "test": "mocha --reporter spec --check-leaks --bail test/", + "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "update": "npm run fetch && npm run build" + }, + "gitHead": "b3e31e8c32dd8107e898b44b8c0b2dfff3cba495", + "bugs": { + "url": "https://github.com/jshttp/statuses/issues" + }, + "homepage": "https://github.com/jshttp/statuses", + "_id": "statuses@1.3.0", + "_shasum": "8e55758cb20e7682c1f4fce8dcab30bf01d1e07a", + "_from": "statuses@>=1.3.0 <1.4.0", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "maintainers": [ + { + "name": "defunctzombie", + "email": "shtylman@gmail.com" + }, + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "fishrock123", + "email": "fishrock123@rocketmail.com" + }, + { + "name": "jongleberry", + "email": "jonathanrichardong@gmail.com" + }, + { + "name": "mscdex", + "email": "mscdex@mscdex.net" + }, + { + "name": "tjholowaychuk", + "email": "tj@vision-media.ca" + } + ], + "dist": { + "shasum": "8e55758cb20e7682c1f4fce8dcab30bf01d1e07a", + "tarball": "https://registry.npmjs.org/statuses/-/statuses-1.3.0.tgz" + }, + "_npmOperationalInternal": { + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/statuses-1.3.0.tgz_1463517875633_0.19560232176445425" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.0.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/send/package.json b/ui/node_modules/express/node_modules/send/package.json index e643a017..27f8c486 100644 --- a/ui/node_modules/express/node_modules/send/package.json +++ b/ui/node_modules/express/node_modules/send/package.json @@ -1,96 +1,96 @@ -{ - "name": "send", - "description": "Better streaming static file server with Range and conditional-GET support", - "version": "0.14.1", - "author": { - "name": "TJ Holowaychuk", - "email": "tj@vision-media.ca" - }, - "contributors": [ - { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - } - ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/pillarjs/send.git" - }, - "keywords": [ - "static", - "file", - "server" - ], - "dependencies": { - "debug": "~2.2.0", - "depd": "~1.1.0", - "destroy": "~1.0.4", - "encodeurl": "~1.0.1", - "escape-html": "~1.0.3", - "etag": "~1.7.0", - "fresh": "0.3.0", - "http-errors": "~1.5.0", - "mime": "1.3.4", - "ms": "0.7.1", - "on-finished": "~2.3.0", - "range-parser": "~1.2.0", - "statuses": "~1.3.0" - }, - "devDependencies": { - "after": "0.8.1", - "eslint": "2.11.1", - "eslint-config-standard": "5.3.1", - "eslint-plugin-promise": "1.3.1", - "eslint-plugin-standard": "1.3.2", - "istanbul": "0.4.3", - "mocha": "2.5.3", - "supertest": "1.1.0" - }, - "files": [ - "HISTORY.md", - "LICENSE", - "README.md", - "index.js" - ], - "engines": { - "node": ">= 0.8.0" - }, - "scripts": { - "lint": "eslint **/*.js", - "test": "mocha --check-leaks --reporter spec --bail", - "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --check-leaks --reporter spec", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --check-leaks --reporter dot" - }, - "gitHead": "d6dd3b91bbb73ad89f1398fa227b200db9bff037", - "bugs": { - "url": "https://github.com/pillarjs/send/issues" - }, - "homepage": "https://github.com/pillarjs/send#readme", - "_id": "send@0.14.1", - "_shasum": "a954984325392f51532a7760760e459598c89f7a", - "_from": "send@0.14.1", - "_npmVersion": "2.15.1", - "_nodeVersion": "4.4.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "a954984325392f51532a7760760e459598c89f7a", - "tarball": "https://registry.npmjs.org/send/-/send-0.14.1.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/send-0.14.1.tgz_1465535036412_0.3431496580597013" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/send/-/send-0.14.1.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "send", + "description": "Better streaming static file server with Range and conditional-GET support", + "version": "0.14.1", + "author": { + "name": "TJ Holowaychuk", + "email": "tj@vision-media.ca" + }, + "contributors": [ + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + } + ], + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/pillarjs/send.git" + }, + "keywords": [ + "static", + "file", + "server" + ], + "dependencies": { + "debug": "~2.2.0", + "depd": "~1.1.0", + "destroy": "~1.0.4", + "encodeurl": "~1.0.1", + "escape-html": "~1.0.3", + "etag": "~1.7.0", + "fresh": "0.3.0", + "http-errors": "~1.5.0", + "mime": "1.3.4", + "ms": "0.7.1", + "on-finished": "~2.3.0", + "range-parser": "~1.2.0", + "statuses": "~1.3.0" + }, + "devDependencies": { + "after": "0.8.1", + "eslint": "2.11.1", + "eslint-config-standard": "5.3.1", + "eslint-plugin-promise": "1.3.1", + "eslint-plugin-standard": "1.3.2", + "istanbul": "0.4.3", + "mocha": "2.5.3", + "supertest": "1.1.0" + }, + "files": [ + "HISTORY.md", + "LICENSE", + "README.md", + "index.js" + ], + "engines": { + "node": ">= 0.8.0" + }, + "scripts": { + "lint": "eslint **/*.js", + "test": "mocha --check-leaks --reporter spec --bail", + "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --check-leaks --reporter spec", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --check-leaks --reporter dot" + }, + "gitHead": "d6dd3b91bbb73ad89f1398fa227b200db9bff037", + "bugs": { + "url": "https://github.com/pillarjs/send/issues" + }, + "homepage": "https://github.com/pillarjs/send#readme", + "_id": "send@0.14.1", + "_shasum": "a954984325392f51532a7760760e459598c89f7a", + "_from": "send@0.14.1", + "_npmVersion": "2.15.1", + "_nodeVersion": "4.4.3", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "dist": { + "shasum": "a954984325392f51532a7760760e459598c89f7a", + "tarball": "https://registry.npmjs.org/send/-/send-0.14.1.tgz" + }, + "maintainers": [ + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + } + ], + "_npmOperationalInternal": { + "host": "packages-16-east.internal.npmjs.com", + "tmp": "tmp/send-0.14.1.tgz_1465535036412_0.3431496580597013" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/send/-/send-0.14.1.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/serve-static/HISTORY.md b/ui/node_modules/express/node_modules/serve-static/HISTORY.md index f2e5e13b..0256dbb5 100644 --- a/ui/node_modules/express/node_modules/serve-static/HISTORY.md +++ b/ui/node_modules/express/node_modules/serve-static/HISTORY.md @@ -1,332 +1,332 @@ -1.11.1 / 2016-06-10 -=================== - - * Fix redirect error when `req.url` contains raw non-URL characters - * deps: send@0.14.1 - -1.11.0 / 2016-06-07 -=================== - - * Use status code 301 for redirects - * deps: send@0.14.0 - - Add `acceptRanges` option - - Add `cacheControl` option - - Attempt to combine multiple ranges into single range - - Correctly inherit from `Stream` class - - Fix `Content-Range` header in 416 responses when using `start`/`end` options - - Fix `Content-Range` header missing from default 416 responses - - Ignore non-byte `Range` headers - - deps: http-errors@~1.5.0 - - deps: range-parser@~1.2.0 - - deps: statuses@~1.3.0 - - perf: remove argument reassignment - -1.10.3 / 2016-05-30 -=================== - - * deps: send@0.13.2 - - Fix invalid `Content-Type` header when `send.mime.default_type` unset - -1.10.2 / 2016-01-19 -=================== - - * deps: parseurl@~1.3.1 - - perf: enable strict mode - -1.10.1 / 2016-01-16 -=================== - - * deps: escape-html@~1.0.3 - - perf: enable strict mode - - perf: optimize string replacement - - perf: use faster string coercion - * deps: send@0.13.1 - - deps: depd@~1.1.0 - - deps: destroy@~1.0.4 - - deps: escape-html@~1.0.3 - - deps: range-parser@~1.0.3 - -1.10.0 / 2015-06-17 -=================== - - * Add `fallthrough` option - - Allows declaring this middleware is the final destination - - Provides better integration with Express patterns - * Fix reading options from options prototype - * Improve the default redirect response headers - * deps: escape-html@1.0.2 - * deps: send@0.13.0 - - Allow Node.js HTTP server to set `Date` response header - - Fix incorrectly removing `Content-Location` on 304 response - - Improve the default redirect response headers - - Send appropriate headers on default error response - - Use `http-errors` for standard emitted errors - - Use `statuses` instead of `http` module for status messages - - deps: escape-html@1.0.2 - - deps: etag@~1.7.0 - - deps: fresh@0.3.0 - - deps: on-finished@~2.3.0 - - perf: enable strict mode - - perf: remove unnecessary array allocations - * perf: enable strict mode - * perf: remove argument reassignment - -1.9.3 / 2015-05-14 -================== - - * deps: send@0.12.3 - - deps: debug@~2.2.0 - - deps: depd@~1.0.1 - - deps: etag@~1.6.0 - - deps: ms@0.7.1 - - deps: on-finished@~2.2.1 - -1.9.2 / 2015-03-14 -================== - - * deps: send@0.12.2 - - Throw errors early for invalid `extensions` or `index` options - - deps: debug@~2.1.3 - -1.9.1 / 2015-02-17 -================== - - * deps: send@0.12.1 - - Fix regression sending zero-length files - -1.9.0 / 2015-02-16 -================== - - * deps: send@0.12.0 - - Always read the stat size from the file - - Fix mutating passed-in `options` - - deps: mime@1.3.4 - -1.8.1 / 2015-01-20 -================== - - * Fix redirect loop in Node.js 0.11.14 - * deps: send@0.11.1 - - Fix root path disclosure - -1.8.0 / 2015-01-05 -================== - - * deps: send@0.11.0 - - deps: debug@~2.1.1 - - deps: etag@~1.5.1 - - deps: ms@0.7.0 - - deps: on-finished@~2.2.0 - -1.7.2 / 2015-01-02 -================== - - * Fix potential open redirect when mounted at root - -1.7.1 / 2014-10-22 -================== - - * deps: send@0.10.1 - - deps: on-finished@~2.1.1 - -1.7.0 / 2014-10-15 -================== - - * deps: send@0.10.0 - - deps: debug@~2.1.0 - - deps: depd@~1.0.0 - - deps: etag@~1.5.0 - -1.6.5 / 2015-02-04 -================== - - * Fix potential open redirect when mounted at root - - Back-ported from v1.7.2 - -1.6.4 / 2014-10-08 -================== - - * Fix redirect loop when index file serving disabled - -1.6.3 / 2014-09-24 -================== - - * deps: send@0.9.3 - - deps: etag@~1.4.0 - -1.6.2 / 2014-09-15 -================== - - * deps: send@0.9.2 - - deps: depd@0.4.5 - - deps: etag@~1.3.1 - - deps: range-parser@~1.0.2 - -1.6.1 / 2014-09-07 -================== - - * deps: send@0.9.1 - - deps: fresh@0.2.4 - -1.6.0 / 2014-09-07 -================== - - * deps: send@0.9.0 - - Add `lastModified` option - - Use `etag` to generate `ETag` header - - deps: debug@~2.0.0 - -1.5.4 / 2014-09-04 -================== - - * deps: send@0.8.5 - - Fix a path traversal issue when using `root` - - Fix malicious path detection for empty string path - -1.5.3 / 2014-08-17 -================== - - * deps: send@0.8.3 - -1.5.2 / 2014-08-14 -================== - - * deps: send@0.8.2 - - Work around `fd` leak in Node.js 0.10 for `fs.ReadStream` - -1.5.1 / 2014-08-09 -================== - - * Fix parsing of weird `req.originalUrl` values - * deps: parseurl@~1.3.0 - * deps: utils-merge@1.0.0 - -1.5.0 / 2014-08-05 -================== - - * deps: send@0.8.1 - - Add `extensions` option - -1.4.4 / 2014-08-04 -================== - - * deps: send@0.7.4 - - Fix serving index files without root dir - -1.4.3 / 2014-07-29 -================== - - * deps: send@0.7.3 - - Fix incorrect 403 on Windows and Node.js 0.11 - -1.4.2 / 2014-07-27 -================== - - * deps: send@0.7.2 - - deps: depd@0.4.4 - -1.4.1 / 2014-07-26 -================== - - * deps: send@0.7.1 - - deps: depd@0.4.3 - -1.4.0 / 2014-07-21 -================== - - * deps: parseurl@~1.2.0 - - Cache URLs based on original value - - Remove no-longer-needed URL mis-parse work-around - - Simplify the "fast-path" `RegExp` - * deps: send@0.7.0 - - Add `dotfiles` option - - deps: debug@1.0.4 - - deps: depd@0.4.2 - -1.3.2 / 2014-07-11 -================== - - * deps: send@0.6.0 - - Cap `maxAge` value to 1 year - - deps: debug@1.0.3 - -1.3.1 / 2014-07-09 -================== - - * deps: parseurl@~1.1.3 - - faster parsing of href-only URLs - -1.3.0 / 2014-06-28 -================== - - * Add `setHeaders` option - * Include HTML link in redirect response - * deps: send@0.5.0 - - Accept string for `maxAge` (converted by `ms`) - -1.2.3 / 2014-06-11 -================== - - * deps: send@0.4.3 - - Do not throw un-catchable error on file open race condition - - Use `escape-html` for HTML escaping - - deps: debug@1.0.2 - - deps: finished@1.2.2 - - deps: fresh@0.2.2 - -1.2.2 / 2014-06-09 -================== - - * deps: send@0.4.2 - - fix "event emitter leak" warnings - - deps: debug@1.0.1 - - deps: finished@1.2.1 - -1.2.1 / 2014-06-02 -================== - - * use `escape-html` for escaping - * deps: send@0.4.1 - - Send `max-age` in `Cache-Control` in correct format - -1.2.0 / 2014-05-29 -================== - - * deps: send@0.4.0 - - Calculate ETag with md5 for reduced collisions - - Fix wrong behavior when index file matches directory - - Ignore stream errors after request ends - - Skip directories in index file search - - deps: debug@0.8.1 - -1.1.0 / 2014-04-24 -================== - - * Accept options directly to `send` module - * deps: send@0.3.0 - -1.0.4 / 2014-04-07 -================== - - * Resolve relative paths at middleware setup - * Use parseurl to parse the URL from request - -1.0.3 / 2014-03-20 -================== - - * Do not rely on connect-like environments - -1.0.2 / 2014-03-06 -================== - - * deps: send@0.2.0 - -1.0.1 / 2014-03-05 -================== - - * Add mime export for back-compat - -1.0.0 / 2014-03-05 -================== - - * Genesis from `connect` +1.11.1 / 2016-06-10 +=================== + + * Fix redirect error when `req.url` contains raw non-URL characters + * deps: send@0.14.1 + +1.11.0 / 2016-06-07 +=================== + + * Use status code 301 for redirects + * deps: send@0.14.0 + - Add `acceptRanges` option + - Add `cacheControl` option + - Attempt to combine multiple ranges into single range + - Correctly inherit from `Stream` class + - Fix `Content-Range` header in 416 responses when using `start`/`end` options + - Fix `Content-Range` header missing from default 416 responses + - Ignore non-byte `Range` headers + - deps: http-errors@~1.5.0 + - deps: range-parser@~1.2.0 + - deps: statuses@~1.3.0 + - perf: remove argument reassignment + +1.10.3 / 2016-05-30 +=================== + + * deps: send@0.13.2 + - Fix invalid `Content-Type` header when `send.mime.default_type` unset + +1.10.2 / 2016-01-19 +=================== + + * deps: parseurl@~1.3.1 + - perf: enable strict mode + +1.10.1 / 2016-01-16 +=================== + + * deps: escape-html@~1.0.3 + - perf: enable strict mode + - perf: optimize string replacement + - perf: use faster string coercion + * deps: send@0.13.1 + - deps: depd@~1.1.0 + - deps: destroy@~1.0.4 + - deps: escape-html@~1.0.3 + - deps: range-parser@~1.0.3 + +1.10.0 / 2015-06-17 +=================== + + * Add `fallthrough` option + - Allows declaring this middleware is the final destination + - Provides better integration with Express patterns + * Fix reading options from options prototype + * Improve the default redirect response headers + * deps: escape-html@1.0.2 + * deps: send@0.13.0 + - Allow Node.js HTTP server to set `Date` response header + - Fix incorrectly removing `Content-Location` on 304 response + - Improve the default redirect response headers + - Send appropriate headers on default error response + - Use `http-errors` for standard emitted errors + - Use `statuses` instead of `http` module for status messages + - deps: escape-html@1.0.2 + - deps: etag@~1.7.0 + - deps: fresh@0.3.0 + - deps: on-finished@~2.3.0 + - perf: enable strict mode + - perf: remove unnecessary array allocations + * perf: enable strict mode + * perf: remove argument reassignment + +1.9.3 / 2015-05-14 +================== + + * deps: send@0.12.3 + - deps: debug@~2.2.0 + - deps: depd@~1.0.1 + - deps: etag@~1.6.0 + - deps: ms@0.7.1 + - deps: on-finished@~2.2.1 + +1.9.2 / 2015-03-14 +================== + + * deps: send@0.12.2 + - Throw errors early for invalid `extensions` or `index` options + - deps: debug@~2.1.3 + +1.9.1 / 2015-02-17 +================== + + * deps: send@0.12.1 + - Fix regression sending zero-length files + +1.9.0 / 2015-02-16 +================== + + * deps: send@0.12.0 + - Always read the stat size from the file + - Fix mutating passed-in `options` + - deps: mime@1.3.4 + +1.8.1 / 2015-01-20 +================== + + * Fix redirect loop in Node.js 0.11.14 + * deps: send@0.11.1 + - Fix root path disclosure + +1.8.0 / 2015-01-05 +================== + + * deps: send@0.11.0 + - deps: debug@~2.1.1 + - deps: etag@~1.5.1 + - deps: ms@0.7.0 + - deps: on-finished@~2.2.0 + +1.7.2 / 2015-01-02 +================== + + * Fix potential open redirect when mounted at root + +1.7.1 / 2014-10-22 +================== + + * deps: send@0.10.1 + - deps: on-finished@~2.1.1 + +1.7.0 / 2014-10-15 +================== + + * deps: send@0.10.0 + - deps: debug@~2.1.0 + - deps: depd@~1.0.0 + - deps: etag@~1.5.0 + +1.6.5 / 2015-02-04 +================== + + * Fix potential open redirect when mounted at root + - Back-ported from v1.7.2 + +1.6.4 / 2014-10-08 +================== + + * Fix redirect loop when index file serving disabled + +1.6.3 / 2014-09-24 +================== + + * deps: send@0.9.3 + - deps: etag@~1.4.0 + +1.6.2 / 2014-09-15 +================== + + * deps: send@0.9.2 + - deps: depd@0.4.5 + - deps: etag@~1.3.1 + - deps: range-parser@~1.0.2 + +1.6.1 / 2014-09-07 +================== + + * deps: send@0.9.1 + - deps: fresh@0.2.4 + +1.6.0 / 2014-09-07 +================== + + * deps: send@0.9.0 + - Add `lastModified` option + - Use `etag` to generate `ETag` header + - deps: debug@~2.0.0 + +1.5.4 / 2014-09-04 +================== + + * deps: send@0.8.5 + - Fix a path traversal issue when using `root` + - Fix malicious path detection for empty string path + +1.5.3 / 2014-08-17 +================== + + * deps: send@0.8.3 + +1.5.2 / 2014-08-14 +================== + + * deps: send@0.8.2 + - Work around `fd` leak in Node.js 0.10 for `fs.ReadStream` + +1.5.1 / 2014-08-09 +================== + + * Fix parsing of weird `req.originalUrl` values + * deps: parseurl@~1.3.0 + * deps: utils-merge@1.0.0 + +1.5.0 / 2014-08-05 +================== + + * deps: send@0.8.1 + - Add `extensions` option + +1.4.4 / 2014-08-04 +================== + + * deps: send@0.7.4 + - Fix serving index files without root dir + +1.4.3 / 2014-07-29 +================== + + * deps: send@0.7.3 + - Fix incorrect 403 on Windows and Node.js 0.11 + +1.4.2 / 2014-07-27 +================== + + * deps: send@0.7.2 + - deps: depd@0.4.4 + +1.4.1 / 2014-07-26 +================== + + * deps: send@0.7.1 + - deps: depd@0.4.3 + +1.4.0 / 2014-07-21 +================== + + * deps: parseurl@~1.2.0 + - Cache URLs based on original value + - Remove no-longer-needed URL mis-parse work-around + - Simplify the "fast-path" `RegExp` + * deps: send@0.7.0 + - Add `dotfiles` option + - deps: debug@1.0.4 + - deps: depd@0.4.2 + +1.3.2 / 2014-07-11 +================== + + * deps: send@0.6.0 + - Cap `maxAge` value to 1 year + - deps: debug@1.0.3 + +1.3.1 / 2014-07-09 +================== + + * deps: parseurl@~1.1.3 + - faster parsing of href-only URLs + +1.3.0 / 2014-06-28 +================== + + * Add `setHeaders` option + * Include HTML link in redirect response + * deps: send@0.5.0 + - Accept string for `maxAge` (converted by `ms`) + +1.2.3 / 2014-06-11 +================== + + * deps: send@0.4.3 + - Do not throw un-catchable error on file open race condition + - Use `escape-html` for HTML escaping + - deps: debug@1.0.2 + - deps: finished@1.2.2 + - deps: fresh@0.2.2 + +1.2.2 / 2014-06-09 +================== + + * deps: send@0.4.2 + - fix "event emitter leak" warnings + - deps: debug@1.0.1 + - deps: finished@1.2.1 + +1.2.1 / 2014-06-02 +================== + + * use `escape-html` for escaping + * deps: send@0.4.1 + - Send `max-age` in `Cache-Control` in correct format + +1.2.0 / 2014-05-29 +================== + + * deps: send@0.4.0 + - Calculate ETag with md5 for reduced collisions + - Fix wrong behavior when index file matches directory + - Ignore stream errors after request ends + - Skip directories in index file search + - deps: debug@0.8.1 + +1.1.0 / 2014-04-24 +================== + + * Accept options directly to `send` module + * deps: send@0.3.0 + +1.0.4 / 2014-04-07 +================== + + * Resolve relative paths at middleware setup + * Use parseurl to parse the URL from request + +1.0.3 / 2014-03-20 +================== + + * Do not rely on connect-like environments + +1.0.2 / 2014-03-06 +================== + + * deps: send@0.2.0 + +1.0.1 / 2014-03-05 +================== + + * Add mime export for back-compat + +1.0.0 / 2014-03-05 +================== + + * Genesis from `connect` diff --git a/ui/node_modules/express/node_modules/serve-static/LICENSE b/ui/node_modules/express/node_modules/serve-static/LICENSE index 237bbaf9..cbe62e8e 100644 --- a/ui/node_modules/express/node_modules/serve-static/LICENSE +++ b/ui/node_modules/express/node_modules/serve-static/LICENSE @@ -1,25 +1,25 @@ -(The MIT License) - -Copyright (c) 2010 Sencha Inc. -Copyright (c) 2011 LearnBoost -Copyright (c) 2011 TJ Holowaychuk -Copyright (c) 2014-2016 Douglas Christopher Wilson - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2010 Sencha Inc. +Copyright (c) 2011 LearnBoost +Copyright (c) 2011 TJ Holowaychuk +Copyright (c) 2014-2016 Douglas Christopher Wilson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/serve-static/README.md b/ui/node_modules/express/node_modules/serve-static/README.md index eb9c5d3d..3bd75f3a 100644 --- a/ui/node_modules/express/node_modules/serve-static/README.md +++ b/ui/node_modules/express/node_modules/serve-static/README.md @@ -1,245 +1,245 @@ -# serve-static - -[![NPM Version][npm-image]][npm-url] -[![NPM Downloads][downloads-image]][downloads-url] -[![Linux Build][travis-image]][travis-url] -[![Windows Build][appveyor-image]][appveyor-url] -[![Test Coverage][coveralls-image]][coveralls-url] -[![Gratipay][gratipay-image]][gratipay-url] - -## Install - -```sh -$ npm install serve-static -``` - -## API - -```js -var serveStatic = require('serve-static') -``` - -### serveStatic(root, options) - -Create a new middleware function to serve files from within a given root -directory. The file to serve will be determined by combining `req.url` -with the provided root directory. When a file is not found, instead of -sending a 404 response, this module will instead call `next()` to move on -to the next middleware, allowing for stacking and fall-backs. - -#### Options - -##### acceptRanges - -Enable or disable accepting ranged requests, defaults to true. -Disabling this will not send `Accept-Ranges` and ignore the contents -of the `Range` request header. - -##### cacheControl - -Enable or disable setting `Cache-Control` response header, defaults to -true. Disabling this will ignore the `maxAge` option. - -##### dotfiles - - Set how "dotfiles" are treated when encountered. A dotfile is a file -or directory that begins with a dot ("."). Note this check is done on -the path itself without checking if the path actually exists on the -disk. If `root` is specified, only the dotfiles above the root are -checked (i.e. the root itself can be within a dotfile when set -to "deny"). - - - `'allow'` No special treatment for dotfiles. - - `'deny'` Deny a request for a dotfile and 403/`next()`. - - `'ignore'` Pretend like the dotfile does not exist and 404/`next()`. - -The default value is similar to `'ignore'`, with the exception that this -default will not ignore the files within a directory that begins with a dot. - -##### etag - -Enable or disable etag generation, defaults to true. - -##### extensions - -Set file extension fallbacks. When set, if a file is not found, the given -extensions will be added to the file name and search for. The first that -exists will be served. Example: `['html', 'htm']`. - -The default value is `false`. - -##### fallthrough - -Set the middleware to have client errors fall-through as just unhandled -requests, otherwise forward a client error. The difference is that client -errors like a bad request or a request to a non-existent file will cause -this middleware to simply `next()` to your next middleware when this value -is `true`. When this value is `false`, these errors (even 404s), will invoke -`next(err)`. - -Typically `true` is desired such that multiple physical directories can be -mapped to the same web address or for routes to fill in non-existent files. - -The value `false` can be used if this middleware is mounted at a path that -is designed to be strictly a single file system directory, which allows for -short-circuiting 404s for less overhead. This middleware will also reply to -all methods. - -The default value is `true`. - -##### index - -By default this module will send "index.html" files in response to a request -on a directory. To disable this set `false` or to supply a new index pass a -string or an array in preferred order. - -##### lastModified - -Enable or disable `Last-Modified` header, defaults to true. Uses the file -system's last modified value. - -##### maxAge - -Provide a max-age in milliseconds for http caching, defaults to 0. This -can also be a string accepted by the [ms](https://www.npmjs.org/package/ms#readme) -module. - -##### redirect - -Redirect to trailing "/" when the pathname is a dir. Defaults to `true`. - -##### setHeaders - -Function to set custom headers on response. Alterations to the headers need to -occur synchronously. The function is called as `fn(res, path, stat)`, where -the arguments are: - - - `res` the response object - - `path` the file path that is being sent - - `stat` the stat object of the file that is being sent - -## Examples - -### Serve files with vanilla node.js http server - -```js -var finalhandler = require('finalhandler') -var http = require('http') -var serveStatic = require('serve-static') - -// Serve up public/ftp folder -var serve = serveStatic('public/ftp', {'index': ['index.html', 'index.htm']}) - -// Create server -var server = http.createServer(function onRequest (req, res) { - serve(req, res, finalhandler(req, res)) -}) - -// Listen -server.listen(3000) -``` - -### Serve all files as downloads - -```js -var contentDisposition = require('content-disposition') -var finalhandler = require('finalhandler') -var http = require('http') -var serveStatic = require('serve-static') - -// Serve up public/ftp folder -var serve = serveStatic('public/ftp', { - 'index': false, - 'setHeaders': setHeaders -}) - -// Set header to force download -function setHeaders(res, path) { - res.setHeader('Content-Disposition', contentDisposition(path)) -} - -// Create server -var server = http.createServer(function onRequest (req, res) { - serve(req, res, finalhandler(req, res)) -}) - -// Listen -server.listen(3000) -``` - -### Serving using express - -#### Simple - -This is a simple example of using Express. - -```js -var express = require('express') -var serveStatic = require('serve-static') - -var app = express() - -app.use(serveStatic('public/ftp', {'index': ['default.html', 'default.htm']})) -app.listen(3000) -``` - -#### Multiple roots - -This example shows a simple way to search through multiple directories. -Files are look for in `public-optimized/` first, then `public/` second as -a fallback. - -```js -var express = require('express') -var serveStatic = require('serve-static') - -var app = express() - -app.use(serveStatic(__dirname + '/public-optimized')) -app.use(serveStatic(__dirname + '/public')) -app.listen(3000) -``` - -#### Different settings for paths - -This example shows how to set a different max age depending on the served -file type. In this example, HTML files are not cached, while everything else -is for 1 day. - -```js -var express = require('express') -var serveStatic = require('serve-static') - -var app = express() - -app.use(serveStatic(__dirname + '/public', { - maxAge: '1d', - setHeaders: setCustomCacheControl -})) - -app.listen(3000) - -function setCustomCacheControl (res, path) { - if (serveStatic.mime.lookup(path) === 'text/html') { - // Custom Cache-Control for HTML files - res.setHeader('Cache-Control', 'public, max-age=0') - } -} -``` - -## License - -[MIT](LICENSE) - -[npm-image]: https://img.shields.io/npm/v/serve-static.svg -[npm-url]: https://npmjs.org/package/serve-static -[travis-image]: https://img.shields.io/travis/expressjs/serve-static/master.svg?label=linux -[travis-url]: https://travis-ci.org/expressjs/serve-static -[appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/serve-static/master.svg?label=windows -[appveyor-url]: https://ci.appveyor.com/project/dougwilson/serve-static -[coveralls-image]: https://img.shields.io/coveralls/expressjs/serve-static/master.svg -[coveralls-url]: https://coveralls.io/r/expressjs/serve-static -[downloads-image]: https://img.shields.io/npm/dm/serve-static.svg -[downloads-url]: https://npmjs.org/package/serve-static -[gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg -[gratipay-url]: https://gratipay.com/dougwilson/ +# serve-static + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Linux Build][travis-image]][travis-url] +[![Windows Build][appveyor-image]][appveyor-url] +[![Test Coverage][coveralls-image]][coveralls-url] +[![Gratipay][gratipay-image]][gratipay-url] + +## Install + +```sh +$ npm install serve-static +``` + +## API + +```js +var serveStatic = require('serve-static') +``` + +### serveStatic(root, options) + +Create a new middleware function to serve files from within a given root +directory. The file to serve will be determined by combining `req.url` +with the provided root directory. When a file is not found, instead of +sending a 404 response, this module will instead call `next()` to move on +to the next middleware, allowing for stacking and fall-backs. + +#### Options + +##### acceptRanges + +Enable or disable accepting ranged requests, defaults to true. +Disabling this will not send `Accept-Ranges` and ignore the contents +of the `Range` request header. + +##### cacheControl + +Enable or disable setting `Cache-Control` response header, defaults to +true. Disabling this will ignore the `maxAge` option. + +##### dotfiles + + Set how "dotfiles" are treated when encountered. A dotfile is a file +or directory that begins with a dot ("."). Note this check is done on +the path itself without checking if the path actually exists on the +disk. If `root` is specified, only the dotfiles above the root are +checked (i.e. the root itself can be within a dotfile when set +to "deny"). + + - `'allow'` No special treatment for dotfiles. + - `'deny'` Deny a request for a dotfile and 403/`next()`. + - `'ignore'` Pretend like the dotfile does not exist and 404/`next()`. + +The default value is similar to `'ignore'`, with the exception that this +default will not ignore the files within a directory that begins with a dot. + +##### etag + +Enable or disable etag generation, defaults to true. + +##### extensions + +Set file extension fallbacks. When set, if a file is not found, the given +extensions will be added to the file name and search for. The first that +exists will be served. Example: `['html', 'htm']`. + +The default value is `false`. + +##### fallthrough + +Set the middleware to have client errors fall-through as just unhandled +requests, otherwise forward a client error. The difference is that client +errors like a bad request or a request to a non-existent file will cause +this middleware to simply `next()` to your next middleware when this value +is `true`. When this value is `false`, these errors (even 404s), will invoke +`next(err)`. + +Typically `true` is desired such that multiple physical directories can be +mapped to the same web address or for routes to fill in non-existent files. + +The value `false` can be used if this middleware is mounted at a path that +is designed to be strictly a single file system directory, which allows for +short-circuiting 404s for less overhead. This middleware will also reply to +all methods. + +The default value is `true`. + +##### index + +By default this module will send "index.html" files in response to a request +on a directory. To disable this set `false` or to supply a new index pass a +string or an array in preferred order. + +##### lastModified + +Enable or disable `Last-Modified` header, defaults to true. Uses the file +system's last modified value. + +##### maxAge + +Provide a max-age in milliseconds for http caching, defaults to 0. This +can also be a string accepted by the [ms](https://www.npmjs.org/package/ms#readme) +module. + +##### redirect + +Redirect to trailing "/" when the pathname is a dir. Defaults to `true`. + +##### setHeaders + +Function to set custom headers on response. Alterations to the headers need to +occur synchronously. The function is called as `fn(res, path, stat)`, where +the arguments are: + + - `res` the response object + - `path` the file path that is being sent + - `stat` the stat object of the file that is being sent + +## Examples + +### Serve files with vanilla node.js http server + +```js +var finalhandler = require('finalhandler') +var http = require('http') +var serveStatic = require('serve-static') + +// Serve up public/ftp folder +var serve = serveStatic('public/ftp', {'index': ['index.html', 'index.htm']}) + +// Create server +var server = http.createServer(function onRequest (req, res) { + serve(req, res, finalhandler(req, res)) +}) + +// Listen +server.listen(3000) +``` + +### Serve all files as downloads + +```js +var contentDisposition = require('content-disposition') +var finalhandler = require('finalhandler') +var http = require('http') +var serveStatic = require('serve-static') + +// Serve up public/ftp folder +var serve = serveStatic('public/ftp', { + 'index': false, + 'setHeaders': setHeaders +}) + +// Set header to force download +function setHeaders(res, path) { + res.setHeader('Content-Disposition', contentDisposition(path)) +} + +// Create server +var server = http.createServer(function onRequest (req, res) { + serve(req, res, finalhandler(req, res)) +}) + +// Listen +server.listen(3000) +``` + +### Serving using express + +#### Simple + +This is a simple example of using Express. + +```js +var express = require('express') +var serveStatic = require('serve-static') + +var app = express() + +app.use(serveStatic('public/ftp', {'index': ['default.html', 'default.htm']})) +app.listen(3000) +``` + +#### Multiple roots + +This example shows a simple way to search through multiple directories. +Files are look for in `public-optimized/` first, then `public/` second as +a fallback. + +```js +var express = require('express') +var serveStatic = require('serve-static') + +var app = express() + +app.use(serveStatic(__dirname + '/public-optimized')) +app.use(serveStatic(__dirname + '/public')) +app.listen(3000) +``` + +#### Different settings for paths + +This example shows how to set a different max age depending on the served +file type. In this example, HTML files are not cached, while everything else +is for 1 day. + +```js +var express = require('express') +var serveStatic = require('serve-static') + +var app = express() + +app.use(serveStatic(__dirname + '/public', { + maxAge: '1d', + setHeaders: setCustomCacheControl +})) + +app.listen(3000) + +function setCustomCacheControl (res, path) { + if (serveStatic.mime.lookup(path) === 'text/html') { + // Custom Cache-Control for HTML files + res.setHeader('Cache-Control', 'public, max-age=0') + } +} +``` + +## License + +[MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/serve-static.svg +[npm-url]: https://npmjs.org/package/serve-static +[travis-image]: https://img.shields.io/travis/expressjs/serve-static/master.svg?label=linux +[travis-url]: https://travis-ci.org/expressjs/serve-static +[appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/serve-static/master.svg?label=windows +[appveyor-url]: https://ci.appveyor.com/project/dougwilson/serve-static +[coveralls-image]: https://img.shields.io/coveralls/expressjs/serve-static/master.svg +[coveralls-url]: https://coveralls.io/r/expressjs/serve-static +[downloads-image]: https://img.shields.io/npm/dm/serve-static.svg +[downloads-url]: https://npmjs.org/package/serve-static +[gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg +[gratipay-url]: https://gratipay.com/dougwilson/ diff --git a/ui/node_modules/express/node_modules/serve-static/index.js b/ui/node_modules/express/node_modules/serve-static/index.js index 30caa31a..83c5e4f2 100644 --- a/ui/node_modules/express/node_modules/serve-static/index.js +++ b/ui/node_modules/express/node_modules/serve-static/index.js @@ -1,188 +1,188 @@ -/*! - * serve-static - * Copyright(c) 2010 Sencha Inc. - * Copyright(c) 2011 TJ Holowaychuk - * Copyright(c) 2014-2016 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict' - -/** - * Module dependencies. - * @private - */ - -var encodeUrl = require('encodeurl') -var escapeHtml = require('escape-html') -var parseUrl = require('parseurl') -var resolve = require('path').resolve -var send = require('send') -var url = require('url') - -/** - * Module exports. - * @public - */ - -module.exports = serveStatic -module.exports.mime = send.mime - -/** - * @param {string} root - * @param {object} [options] - * @return {function} - * @public - */ - -function serveStatic (root, options) { - if (!root) { - throw new TypeError('root path required') - } - - if (typeof root !== 'string') { - throw new TypeError('root path must be a string') - } - - // copy options object - var opts = Object.create(options || null) - - // fall-though - var fallthrough = opts.fallthrough !== false - - // default redirect - var redirect = opts.redirect !== false - - // headers listener - var setHeaders = opts.setHeaders - - if (setHeaders && typeof setHeaders !== 'function') { - throw new TypeError('option setHeaders must be function') - } - - // setup options for send - opts.maxage = opts.maxage || opts.maxAge || 0 - opts.root = resolve(root) - - // construct directory listener - var onDirectory = redirect - ? createRedirectDirectoryListener() - : createNotFoundDirectoryListener() - - return function serveStatic (req, res, next) { - if (req.method !== 'GET' && req.method !== 'HEAD') { - if (fallthrough) { - return next() - } - - // method not allowed - res.statusCode = 405 - res.setHeader('Allow', 'GET, HEAD') - res.setHeader('Content-Length', '0') - res.end() - return - } - - var forwardError = !fallthrough - var originalUrl = parseUrl.original(req) - var path = parseUrl(req).pathname - - // make sure redirect occurs at mount - if (path === '/' && originalUrl.pathname.substr(-1) !== '/') { - path = '' - } - - // create send stream - var stream = send(req, path, opts) - - // add directory handler - stream.on('directory', onDirectory) - - // add headers listener - if (setHeaders) { - stream.on('headers', setHeaders) - } - - // add file listener for fallthrough - if (fallthrough) { - stream.on('file', function onFile () { - // once file is determined, always forward error - forwardError = true - }) - } - - // forward errors - stream.on('error', function error (err) { - if (forwardError || !(err.statusCode < 500)) { - next(err) - return - } - - next() - }) - - // pipe - stream.pipe(res) - } -} - -/** - * Collapse all leading slashes into a single slash - * @private - */ -function collapseLeadingSlashes (str) { - for (var i = 0; i < str.length; i++) { - if (str[i] !== '/') { - break - } - } - - return i > 1 - ? '/' + str.substr(i) - : str -} - -/** - * Create a directory listener that just 404s. - * @private - */ - -function createNotFoundDirectoryListener () { - return function notFound () { - this.error(404) - } -} - -/** - * Create a directory listener that performs a redirect. - * @private - */ - -function createRedirectDirectoryListener () { - return function redirect () { - if (this.hasTrailingSlash()) { - this.error(404) - return - } - - // get original URL - var originalUrl = parseUrl.original(this.req) - - // append trailing slash - originalUrl.path = null - originalUrl.pathname = collapseLeadingSlashes(originalUrl.pathname + '/') - - // reformat the URL - var loc = encodeUrl(url.format(originalUrl)) - var msg = 'Redirecting to ' + escapeHtml(loc) + '\n' - var res = this.res - - // send redirect response - res.statusCode = 301 - res.setHeader('Content-Type', 'text/html; charset=UTF-8') - res.setHeader('Content-Length', Buffer.byteLength(msg)) - res.setHeader('X-Content-Type-Options', 'nosniff') - res.setHeader('Location', loc) - res.end(msg) - } -} +/*! + * serve-static + * Copyright(c) 2010 Sencha Inc. + * Copyright(c) 2011 TJ Holowaychuk + * Copyright(c) 2014-2016 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module dependencies. + * @private + */ + +var encodeUrl = require('encodeurl') +var escapeHtml = require('escape-html') +var parseUrl = require('parseurl') +var resolve = require('path').resolve +var send = require('send') +var url = require('url') + +/** + * Module exports. + * @public + */ + +module.exports = serveStatic +module.exports.mime = send.mime + +/** + * @param {string} root + * @param {object} [options] + * @return {function} + * @public + */ + +function serveStatic (root, options) { + if (!root) { + throw new TypeError('root path required') + } + + if (typeof root !== 'string') { + throw new TypeError('root path must be a string') + } + + // copy options object + var opts = Object.create(options || null) + + // fall-though + var fallthrough = opts.fallthrough !== false + + // default redirect + var redirect = opts.redirect !== false + + // headers listener + var setHeaders = opts.setHeaders + + if (setHeaders && typeof setHeaders !== 'function') { + throw new TypeError('option setHeaders must be function') + } + + // setup options for send + opts.maxage = opts.maxage || opts.maxAge || 0 + opts.root = resolve(root) + + // construct directory listener + var onDirectory = redirect + ? createRedirectDirectoryListener() + : createNotFoundDirectoryListener() + + return function serveStatic (req, res, next) { + if (req.method !== 'GET' && req.method !== 'HEAD') { + if (fallthrough) { + return next() + } + + // method not allowed + res.statusCode = 405 + res.setHeader('Allow', 'GET, HEAD') + res.setHeader('Content-Length', '0') + res.end() + return + } + + var forwardError = !fallthrough + var originalUrl = parseUrl.original(req) + var path = parseUrl(req).pathname + + // make sure redirect occurs at mount + if (path === '/' && originalUrl.pathname.substr(-1) !== '/') { + path = '' + } + + // create send stream + var stream = send(req, path, opts) + + // add directory handler + stream.on('directory', onDirectory) + + // add headers listener + if (setHeaders) { + stream.on('headers', setHeaders) + } + + // add file listener for fallthrough + if (fallthrough) { + stream.on('file', function onFile () { + // once file is determined, always forward error + forwardError = true + }) + } + + // forward errors + stream.on('error', function error (err) { + if (forwardError || !(err.statusCode < 500)) { + next(err) + return + } + + next() + }) + + // pipe + stream.pipe(res) + } +} + +/** + * Collapse all leading slashes into a single slash + * @private + */ +function collapseLeadingSlashes (str) { + for (var i = 0; i < str.length; i++) { + if (str[i] !== '/') { + break + } + } + + return i > 1 + ? '/' + str.substr(i) + : str +} + +/** + * Create a directory listener that just 404s. + * @private + */ + +function createNotFoundDirectoryListener () { + return function notFound () { + this.error(404) + } +} + +/** + * Create a directory listener that performs a redirect. + * @private + */ + +function createRedirectDirectoryListener () { + return function redirect () { + if (this.hasTrailingSlash()) { + this.error(404) + return + } + + // get original URL + var originalUrl = parseUrl.original(this.req) + + // append trailing slash + originalUrl.path = null + originalUrl.pathname = collapseLeadingSlashes(originalUrl.pathname + '/') + + // reformat the URL + var loc = encodeUrl(url.format(originalUrl)) + var msg = 'Redirecting to ' + escapeHtml(loc) + '\n' + var res = this.res + + // send redirect response + res.statusCode = 301 + res.setHeader('Content-Type', 'text/html; charset=UTF-8') + res.setHeader('Content-Length', Buffer.byteLength(msg)) + res.setHeader('X-Content-Type-Options', 'nosniff') + res.setHeader('Location', loc) + res.end(msg) + } +} diff --git a/ui/node_modules/express/node_modules/serve-static/package.json b/ui/node_modules/express/node_modules/serve-static/package.json index f6746b3a..41071ea8 100644 --- a/ui/node_modules/express/node_modules/serve-static/package.json +++ b/ui/node_modules/express/node_modules/serve-static/package.json @@ -1,74 +1,74 @@ -{ - "name": "serve-static", - "description": "Serve static files", - "version": "1.11.1", - "author": { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - }, - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/expressjs/serve-static.git" - }, - "dependencies": { - "encodeurl": "~1.0.1", - "escape-html": "~1.0.3", - "parseurl": "~1.3.1", - "send": "0.14.1" - }, - "devDependencies": { - "eslint": "2.11.1", - "eslint-config-standard": "5.3.1", - "eslint-plugin-promise": "1.3.2", - "eslint-plugin-standard": "1.3.2", - "istanbul": "0.4.3", - "mocha": "2.5.3", - "supertest": "1.1.0" - }, - "files": [ - "LICENSE", - "HISTORY.md", - "index.js" - ], - "engines": { - "node": ">= 0.8.0" - }, - "scripts": { - "lint": "eslint **/*.js", - "test": "mocha --reporter spec --bail --check-leaks test/", - "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/" - }, - "gitHead": "b3a24df138ea2f2c43afcbee0dcce5badf4c78ae", - "bugs": { - "url": "https://github.com/expressjs/serve-static/issues" - }, - "homepage": "https://github.com/expressjs/serve-static#readme", - "_id": "serve-static@1.11.1", - "_shasum": "d6cce7693505f733c759de57befc1af76c0f0805", - "_from": "serve-static@>=1.11.1 <1.12.0", - "_npmVersion": "2.15.1", - "_nodeVersion": "4.4.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "d6cce7693505f733c759de57befc1af76c0f0805", - "tarball": "https://registry.npmjs.org/serve-static/-/serve-static-1.11.1.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/serve-static-1.11.1.tgz_1465608601758_0.0030737747438251972" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.11.1.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "serve-static", + "description": "Serve static files", + "version": "1.11.1", + "author": { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + }, + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/expressjs/serve-static.git" + }, + "dependencies": { + "encodeurl": "~1.0.1", + "escape-html": "~1.0.3", + "parseurl": "~1.3.1", + "send": "0.14.1" + }, + "devDependencies": { + "eslint": "2.11.1", + "eslint-config-standard": "5.3.1", + "eslint-plugin-promise": "1.3.2", + "eslint-plugin-standard": "1.3.2", + "istanbul": "0.4.3", + "mocha": "2.5.3", + "supertest": "1.1.0" + }, + "files": [ + "LICENSE", + "HISTORY.md", + "index.js" + ], + "engines": { + "node": ">= 0.8.0" + }, + "scripts": { + "lint": "eslint **/*.js", + "test": "mocha --reporter spec --bail --check-leaks test/", + "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/" + }, + "gitHead": "b3a24df138ea2f2c43afcbee0dcce5badf4c78ae", + "bugs": { + "url": "https://github.com/expressjs/serve-static/issues" + }, + "homepage": "https://github.com/expressjs/serve-static#readme", + "_id": "serve-static@1.11.1", + "_shasum": "d6cce7693505f733c759de57befc1af76c0f0805", + "_from": "serve-static@>=1.11.1 <1.12.0", + "_npmVersion": "2.15.1", + "_nodeVersion": "4.4.3", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "dist": { + "shasum": "d6cce7693505f733c759de57befc1af76c0f0805", + "tarball": "https://registry.npmjs.org/serve-static/-/serve-static-1.11.1.tgz" + }, + "maintainers": [ + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + } + ], + "_npmOperationalInternal": { + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/serve-static-1.11.1.tgz_1465608601758_0.0030737747438251972" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.11.1.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/type-is/HISTORY.md b/ui/node_modules/express/node_modules/type-is/HISTORY.md index ca6f9b1b..5ec118c7 100644 --- a/ui/node_modules/express/node_modules/type-is/HISTORY.md +++ b/ui/node_modules/express/node_modules/type-is/HISTORY.md @@ -1,206 +1,206 @@ -1.6.13 / 2016-05-18 -=================== - - * deps: mime-types@~2.1.11 - - Add new mime types - -1.6.12 / 2016-02-28 -=================== - - * deps: mime-types@~2.1.10 - - Add new mime types - - Fix extension of `application/dash+xml` - - Update primary extension for `audio/mp4` - -1.6.11 / 2016-01-29 -=================== - - * deps: mime-types@~2.1.9 - - Add new mime types - -1.6.10 / 2015-12-01 -=================== - - * deps: mime-types@~2.1.8 - - Add new mime types - -1.6.9 / 2015-09-27 -================== - - * deps: mime-types@~2.1.7 - - Add new mime types - -1.6.8 / 2015-09-04 -================== - - * deps: mime-types@~2.1.6 - - Add new mime types - -1.6.7 / 2015-08-20 -================== - - * Fix type error when given invalid type to match against - * deps: mime-types@~2.1.5 - - Add new mime types - -1.6.6 / 2015-07-31 -================== - - * deps: mime-types@~2.1.4 - - Add new mime types - -1.6.5 / 2015-07-16 -================== - - * deps: mime-types@~2.1.3 - - Add new mime types - -1.6.4 / 2015-07-01 -================== - - * deps: mime-types@~2.1.2 - - Add new mime types - * perf: enable strict mode - * perf: remove argument reassignment - -1.6.3 / 2015-06-08 -================== - - * deps: mime-types@~2.1.1 - - Add new mime types - * perf: reduce try block size - * perf: remove bitwise operations - -1.6.2 / 2015-05-10 -================== - - * deps: mime-types@~2.0.11 - - Add new mime types - -1.6.1 / 2015-03-13 -================== - - * deps: mime-types@~2.0.10 - - Add new mime types - -1.6.0 / 2015-02-12 -================== - - * fix false-positives in `hasBody` `Transfer-Encoding` check - * support wildcard for both type and subtype (`*/*`) - -1.5.7 / 2015-02-09 -================== - - * fix argument reassignment - * deps: mime-types@~2.0.9 - - Add new mime types - -1.5.6 / 2015-01-29 -================== - - * deps: mime-types@~2.0.8 - - Add new mime types - -1.5.5 / 2014-12-30 -================== - - * deps: mime-types@~2.0.7 - - Add new mime types - - Fix missing extensions - - Fix various invalid MIME type entries - - Remove example template MIME types - - deps: mime-db@~1.5.0 - -1.5.4 / 2014-12-10 -================== - - * deps: mime-types@~2.0.4 - - Add new mime types - - deps: mime-db@~1.3.0 - -1.5.3 / 2014-11-09 -================== - - * deps: mime-types@~2.0.3 - - Add new mime types - - deps: mime-db@~1.2.0 - -1.5.2 / 2014-09-28 -================== - - * deps: mime-types@~2.0.2 - - Add new mime types - - deps: mime-db@~1.1.0 - -1.5.1 / 2014-09-07 -================== - - * Support Node.js 0.6 - * deps: media-typer@0.3.0 - * deps: mime-types@~2.0.1 - - Support Node.js 0.6 - -1.5.0 / 2014-09-05 -================== - - * fix `hasbody` to be true for `content-length: 0` - -1.4.0 / 2014-09-02 -================== - - * update mime-types - -1.3.2 / 2014-06-24 -================== - - * use `~` range on mime-types - -1.3.1 / 2014-06-19 -================== - - * fix global variable leak - -1.3.0 / 2014-06-19 -================== - - * improve type parsing - - - invalid media type never matches - - media type not case-sensitive - - extra LWS does not affect results - -1.2.2 / 2014-06-19 -================== - - * fix behavior on unknown type argument - -1.2.1 / 2014-06-03 -================== - - * switch dependency from `mime` to `mime-types@1.0.0` - -1.2.0 / 2014-05-11 -================== - - * support suffix matching: - - - `+json` matches `application/vnd+json` - - `*/vnd+json` matches `application/vnd+json` - - `application/*+json` matches `application/vnd+json` - -1.1.0 / 2014-04-12 -================== - - * add non-array values support - * expose internal utilities: - - - `.is()` - - `.hasBody()` - - `.normalize()` - - `.match()` - -1.0.1 / 2014-03-30 -================== - - * add `multipart` as a shorthand +1.6.13 / 2016-05-18 +=================== + + * deps: mime-types@~2.1.11 + - Add new mime types + +1.6.12 / 2016-02-28 +=================== + + * deps: mime-types@~2.1.10 + - Add new mime types + - Fix extension of `application/dash+xml` + - Update primary extension for `audio/mp4` + +1.6.11 / 2016-01-29 +=================== + + * deps: mime-types@~2.1.9 + - Add new mime types + +1.6.10 / 2015-12-01 +=================== + + * deps: mime-types@~2.1.8 + - Add new mime types + +1.6.9 / 2015-09-27 +================== + + * deps: mime-types@~2.1.7 + - Add new mime types + +1.6.8 / 2015-09-04 +================== + + * deps: mime-types@~2.1.6 + - Add new mime types + +1.6.7 / 2015-08-20 +================== + + * Fix type error when given invalid type to match against + * deps: mime-types@~2.1.5 + - Add new mime types + +1.6.6 / 2015-07-31 +================== + + * deps: mime-types@~2.1.4 + - Add new mime types + +1.6.5 / 2015-07-16 +================== + + * deps: mime-types@~2.1.3 + - Add new mime types + +1.6.4 / 2015-07-01 +================== + + * deps: mime-types@~2.1.2 + - Add new mime types + * perf: enable strict mode + * perf: remove argument reassignment + +1.6.3 / 2015-06-08 +================== + + * deps: mime-types@~2.1.1 + - Add new mime types + * perf: reduce try block size + * perf: remove bitwise operations + +1.6.2 / 2015-05-10 +================== + + * deps: mime-types@~2.0.11 + - Add new mime types + +1.6.1 / 2015-03-13 +================== + + * deps: mime-types@~2.0.10 + - Add new mime types + +1.6.0 / 2015-02-12 +================== + + * fix false-positives in `hasBody` `Transfer-Encoding` check + * support wildcard for both type and subtype (`*/*`) + +1.5.7 / 2015-02-09 +================== + + * fix argument reassignment + * deps: mime-types@~2.0.9 + - Add new mime types + +1.5.6 / 2015-01-29 +================== + + * deps: mime-types@~2.0.8 + - Add new mime types + +1.5.5 / 2014-12-30 +================== + + * deps: mime-types@~2.0.7 + - Add new mime types + - Fix missing extensions + - Fix various invalid MIME type entries + - Remove example template MIME types + - deps: mime-db@~1.5.0 + +1.5.4 / 2014-12-10 +================== + + * deps: mime-types@~2.0.4 + - Add new mime types + - deps: mime-db@~1.3.0 + +1.5.3 / 2014-11-09 +================== + + * deps: mime-types@~2.0.3 + - Add new mime types + - deps: mime-db@~1.2.0 + +1.5.2 / 2014-09-28 +================== + + * deps: mime-types@~2.0.2 + - Add new mime types + - deps: mime-db@~1.1.0 + +1.5.1 / 2014-09-07 +================== + + * Support Node.js 0.6 + * deps: media-typer@0.3.0 + * deps: mime-types@~2.0.1 + - Support Node.js 0.6 + +1.5.0 / 2014-09-05 +================== + + * fix `hasbody` to be true for `content-length: 0` + +1.4.0 / 2014-09-02 +================== + + * update mime-types + +1.3.2 / 2014-06-24 +================== + + * use `~` range on mime-types + +1.3.1 / 2014-06-19 +================== + + * fix global variable leak + +1.3.0 / 2014-06-19 +================== + + * improve type parsing + + - invalid media type never matches + - media type not case-sensitive + - extra LWS does not affect results + +1.2.2 / 2014-06-19 +================== + + * fix behavior on unknown type argument + +1.2.1 / 2014-06-03 +================== + + * switch dependency from `mime` to `mime-types@1.0.0` + +1.2.0 / 2014-05-11 +================== + + * support suffix matching: + + - `+json` matches `application/vnd+json` + - `*/vnd+json` matches `application/vnd+json` + - `application/*+json` matches `application/vnd+json` + +1.1.0 / 2014-04-12 +================== + + * add non-array values support + * expose internal utilities: + + - `.is()` + - `.hasBody()` + - `.normalize()` + - `.match()` + +1.0.1 / 2014-03-30 +================== + + * add `multipart` as a shorthand diff --git a/ui/node_modules/express/node_modules/type-is/LICENSE b/ui/node_modules/express/node_modules/type-is/LICENSE index 5bda8cc5..386b7b69 100644 --- a/ui/node_modules/express/node_modules/type-is/LICENSE +++ b/ui/node_modules/express/node_modules/type-is/LICENSE @@ -1,23 +1,23 @@ -(The MIT License) - -Copyright (c) 2014 Jonathan Ong -Copyright (c) 2014-2015 Douglas Christopher Wilson - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2014 Jonathan Ong +Copyright (c) 2014-2015 Douglas Christopher Wilson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/type-is/README.md b/ui/node_modules/express/node_modules/type-is/README.md index 35d5fc96..008a7af5 100644 --- a/ui/node_modules/express/node_modules/type-is/README.md +++ b/ui/node_modules/express/node_modules/type-is/README.md @@ -1,136 +1,136 @@ -# type-is - -[![NPM Version][npm-image]][npm-url] -[![NPM Downloads][downloads-image]][downloads-url] -[![Node.js Version][node-version-image]][node-version-url] -[![Build Status][travis-image]][travis-url] -[![Test Coverage][coveralls-image]][coveralls-url] - -Infer the content-type of a request. - -### Install - -```sh -$ npm install type-is -``` - -## API - -```js -var http = require('http') -var is = require('type-is') - -http.createServer(function (req, res) { - var istext = is(req, ['text/*']) - res.end('you ' + (istext ? 'sent' : 'did not send') + ' me text') -}) -``` - -### type = is(request, types) - -`request` is the node HTTP request. `types` is an array of types. - -```js -// req.headers.content-type = 'application/json' - -is(req, ['json']) // 'json' -is(req, ['html', 'json']) // 'json' -is(req, ['application/*']) // 'application/json' -is(req, ['application/json']) // 'application/json' - -is(req, ['html']) // false -``` - -### is.hasBody(request) - -Returns a Boolean if the given `request` has a body, regardless of the -`Content-Type` header. - -Having a body has no relation to how large the body is (it may be 0 bytes). -This is similar to how file existence works. If a body does exist, then this -indicates that there is data to read from the Node.js request stream. - -```js -if (is.hasBody(req)) { - // read the body, since there is one - - req.on('data', function (chunk) { - // ... - }) -} -``` - -### type = is.is(mediaType, types) - -`mediaType` is the [media type](https://tools.ietf.org/html/rfc6838) string. `types` is an array of types. - -```js -var mediaType = 'application/json' - -is.is(mediaType, ['json']) // 'json' -is.is(mediaType, ['html', 'json']) // 'json' -is.is(mediaType, ['application/*']) // 'application/json' -is.is(mediaType, ['application/json']) // 'application/json' - -is.is(mediaType, ['html']) // false -``` - -### Each type can be: - -- An extension name such as `json`. This name will be returned if matched. -- A mime type such as `application/json`. -- A mime type with a wildcard such as `*/*` or `*/json` or `application/*`. The full mime type will be returned if matched. -- A suffix such as `+json`. This can be combined with a wildcard such as `*/vnd+json` or `application/*+json`. The full mime type will be returned if matched. - -`false` will be returned if no type matches or the content type is invalid. - -`null` will be returned if the request does not have a body. - -## Examples - -#### Example body parser - -```js -var is = require('type-is'); - -function bodyParser(req, res, next) { - if (!is.hasBody(req)) { - return next() - } - - switch (is(req, ['urlencoded', 'json', 'multipart'])) { - case 'urlencoded': - // parse urlencoded body - throw new Error('implement urlencoded body parsing') - break - case 'json': - // parse json body - throw new Error('implement json body parsing') - break - case 'multipart': - // parse multipart body - throw new Error('implement multipart body parsing') - break - default: - // 415 error code - res.statusCode = 415 - res.end() - return - } -} -``` - -## License - -[MIT](LICENSE) - -[npm-image]: https://img.shields.io/npm/v/type-is.svg -[npm-url]: https://npmjs.org/package/type-is -[node-version-image]: https://img.shields.io/node/v/type-is.svg -[node-version-url]: https://nodejs.org/en/download/ -[travis-image]: https://img.shields.io/travis/jshttp/type-is/master.svg -[travis-url]: https://travis-ci.org/jshttp/type-is -[coveralls-image]: https://img.shields.io/coveralls/jshttp/type-is/master.svg -[coveralls-url]: https://coveralls.io/r/jshttp/type-is?branch=master -[downloads-image]: https://img.shields.io/npm/dm/type-is.svg -[downloads-url]: https://npmjs.org/package/type-is +# type-is + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-version-image]][node-version-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +Infer the content-type of a request. + +### Install + +```sh +$ npm install type-is +``` + +## API + +```js +var http = require('http') +var is = require('type-is') + +http.createServer(function (req, res) { + var istext = is(req, ['text/*']) + res.end('you ' + (istext ? 'sent' : 'did not send') + ' me text') +}) +``` + +### type = is(request, types) + +`request` is the node HTTP request. `types` is an array of types. + +```js +// req.headers.content-type = 'application/json' + +is(req, ['json']) // 'json' +is(req, ['html', 'json']) // 'json' +is(req, ['application/*']) // 'application/json' +is(req, ['application/json']) // 'application/json' + +is(req, ['html']) // false +``` + +### is.hasBody(request) + +Returns a Boolean if the given `request` has a body, regardless of the +`Content-Type` header. + +Having a body has no relation to how large the body is (it may be 0 bytes). +This is similar to how file existence works. If a body does exist, then this +indicates that there is data to read from the Node.js request stream. + +```js +if (is.hasBody(req)) { + // read the body, since there is one + + req.on('data', function (chunk) { + // ... + }) +} +``` + +### type = is.is(mediaType, types) + +`mediaType` is the [media type](https://tools.ietf.org/html/rfc6838) string. `types` is an array of types. + +```js +var mediaType = 'application/json' + +is.is(mediaType, ['json']) // 'json' +is.is(mediaType, ['html', 'json']) // 'json' +is.is(mediaType, ['application/*']) // 'application/json' +is.is(mediaType, ['application/json']) // 'application/json' + +is.is(mediaType, ['html']) // false +``` + +### Each type can be: + +- An extension name such as `json`. This name will be returned if matched. +- A mime type such as `application/json`. +- A mime type with a wildcard such as `*/*` or `*/json` or `application/*`. The full mime type will be returned if matched. +- A suffix such as `+json`. This can be combined with a wildcard such as `*/vnd+json` or `application/*+json`. The full mime type will be returned if matched. + +`false` will be returned if no type matches or the content type is invalid. + +`null` will be returned if the request does not have a body. + +## Examples + +#### Example body parser + +```js +var is = require('type-is'); + +function bodyParser(req, res, next) { + if (!is.hasBody(req)) { + return next() + } + + switch (is(req, ['urlencoded', 'json', 'multipart'])) { + case 'urlencoded': + // parse urlencoded body + throw new Error('implement urlencoded body parsing') + break + case 'json': + // parse json body + throw new Error('implement json body parsing') + break + case 'multipart': + // parse multipart body + throw new Error('implement multipart body parsing') + break + default: + // 415 error code + res.statusCode = 415 + res.end() + return + } +} +``` + +## License + +[MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/type-is.svg +[npm-url]: https://npmjs.org/package/type-is +[node-version-image]: https://img.shields.io/node/v/type-is.svg +[node-version-url]: https://nodejs.org/en/download/ +[travis-image]: https://img.shields.io/travis/jshttp/type-is/master.svg +[travis-url]: https://travis-ci.org/jshttp/type-is +[coveralls-image]: https://img.shields.io/coveralls/jshttp/type-is/master.svg +[coveralls-url]: https://coveralls.io/r/jshttp/type-is?branch=master +[downloads-image]: https://img.shields.io/npm/dm/type-is.svg +[downloads-url]: https://npmjs.org/package/type-is diff --git a/ui/node_modules/express/node_modules/type-is/index.js b/ui/node_modules/express/node_modules/type-is/index.js index 8d997e6c..4da73011 100644 --- a/ui/node_modules/express/node_modules/type-is/index.js +++ b/ui/node_modules/express/node_modules/type-is/index.js @@ -1,262 +1,262 @@ -/*! - * type-is - * Copyright(c) 2014 Jonathan Ong - * Copyright(c) 2014-2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict' - -/** - * Module dependencies. - * @private - */ - -var typer = require('media-typer') -var mime = require('mime-types') - -/** - * Module exports. - * @public - */ - -module.exports = typeofrequest -module.exports.is = typeis -module.exports.hasBody = hasbody -module.exports.normalize = normalize -module.exports.match = mimeMatch - -/** - * Compare a `value` content-type with `types`. - * Each `type` can be an extension like `html`, - * a special shortcut like `multipart` or `urlencoded`, - * or a mime type. - * - * If no types match, `false` is returned. - * Otherwise, the first `type` that matches is returned. - * - * @param {String} value - * @param {Array} types - * @public - */ - -function typeis (value, types_) { - var i - var types = types_ - - // remove parameters and normalize - var val = tryNormalizeType(value) - - // no type or invalid - if (!val) { - return false - } - - // support flattened arguments - if (types && !Array.isArray(types)) { - types = new Array(arguments.length - 1) - for (i = 0; i < types.length; i++) { - types[i] = arguments[i + 1] - } - } - - // no types, return the content type - if (!types || !types.length) { - return val - } - - var type - for (i = 0; i < types.length; i++) { - if (mimeMatch(normalize(type = types[i]), val)) { - return type[0] === '+' || type.indexOf('*') !== -1 - ? val - : type - } - } - - // no matches - return false -} - -/** - * Check if a request has a request body. - * A request with a body __must__ either have `transfer-encoding` - * or `content-length` headers set. - * http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.3 - * - * @param {Object} request - * @return {Boolean} - * @public - */ - -function hasbody (req) { - return req.headers['transfer-encoding'] !== undefined || - !isNaN(req.headers['content-length']) -} - -/** - * Check if the incoming request contains the "Content-Type" - * header field, and it contains any of the give mime `type`s. - * If there is no request body, `null` is returned. - * If there is no content type, `false` is returned. - * Otherwise, it returns the first `type` that matches. - * - * Examples: - * - * // With Content-Type: text/html; charset=utf-8 - * this.is('html'); // => 'html' - * this.is('text/html'); // => 'text/html' - * this.is('text/*', 'application/json'); // => 'text/html' - * - * // When Content-Type is application/json - * this.is('json', 'urlencoded'); // => 'json' - * this.is('application/json'); // => 'application/json' - * this.is('html', 'application/*'); // => 'application/json' - * - * this.is('html'); // => false - * - * @param {String|Array} types... - * @return {String|false|null} - * @public - */ - -function typeofrequest (req, types_) { - var types = types_ - - // no body - if (!hasbody(req)) { - return null - } - - // support flattened arguments - if (arguments.length > 2) { - types = new Array(arguments.length - 1) - for (var i = 0; i < types.length; i++) { - types[i] = arguments[i + 1] - } - } - - // request content type - var value = req.headers['content-type'] - - return typeis(value, types) -} - -/** - * Normalize a mime type. - * If it's a shorthand, expand it to a valid mime type. - * - * In general, you probably want: - * - * var type = is(req, ['urlencoded', 'json', 'multipart']); - * - * Then use the appropriate body parsers. - * These three are the most common request body types - * and are thus ensured to work. - * - * @param {String} type - * @private - */ - -function normalize (type) { - if (typeof type !== 'string') { - // invalid type - return false - } - - switch (type) { - case 'urlencoded': - return 'application/x-www-form-urlencoded' - case 'multipart': - return 'multipart/*' - } - - if (type[0] === '+') { - // "+json" -> "*/*+json" expando - return '*/*' + type - } - - return type.indexOf('/') === -1 - ? mime.lookup(type) - : type -} - -/** - * Check if `expected` mime type - * matches `actual` mime type with - * wildcard and +suffix support. - * - * @param {String} expected - * @param {String} actual - * @return {Boolean} - * @private - */ - -function mimeMatch (expected, actual) { - // invalid type - if (expected === false) { - return false - } - - // split types - var actualParts = actual.split('/') - var expectedParts = expected.split('/') - - // invalid format - if (actualParts.length !== 2 || expectedParts.length !== 2) { - return false - } - - // validate type - if (expectedParts[0] !== '*' && expectedParts[0] !== actualParts[0]) { - return false - } - - // validate suffix wildcard - if (expectedParts[1].substr(0, 2) === '*+') { - return expectedParts[1].length <= actualParts[1].length + 1 && - expectedParts[1].substr(1) === actualParts[1].substr(1 - expectedParts[1].length) - } - - // validate subtype - if (expectedParts[1] !== '*' && expectedParts[1] !== actualParts[1]) { - return false - } - - return true -} - -/** - * Normalize a type and remove parameters. - * - * @param {string} value - * @return {string} - * @private - */ - -function normalizeType (value) { - // parse the type - var type = typer.parse(value) - - // remove the parameters - type.parameters = undefined - - // reformat it - return typer.format(type) -} - -/** - * Try to normalize a type and remove parameters. - * - * @param {string} value - * @return {string} - * @private - */ - -function tryNormalizeType (value) { - try { - return normalizeType(value) - } catch (err) { - return null - } -} +/*! + * type-is + * Copyright(c) 2014 Jonathan Ong + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module dependencies. + * @private + */ + +var typer = require('media-typer') +var mime = require('mime-types') + +/** + * Module exports. + * @public + */ + +module.exports = typeofrequest +module.exports.is = typeis +module.exports.hasBody = hasbody +module.exports.normalize = normalize +module.exports.match = mimeMatch + +/** + * Compare a `value` content-type with `types`. + * Each `type` can be an extension like `html`, + * a special shortcut like `multipart` or `urlencoded`, + * or a mime type. + * + * If no types match, `false` is returned. + * Otherwise, the first `type` that matches is returned. + * + * @param {String} value + * @param {Array} types + * @public + */ + +function typeis (value, types_) { + var i + var types = types_ + + // remove parameters and normalize + var val = tryNormalizeType(value) + + // no type or invalid + if (!val) { + return false + } + + // support flattened arguments + if (types && !Array.isArray(types)) { + types = new Array(arguments.length - 1) + for (i = 0; i < types.length; i++) { + types[i] = arguments[i + 1] + } + } + + // no types, return the content type + if (!types || !types.length) { + return val + } + + var type + for (i = 0; i < types.length; i++) { + if (mimeMatch(normalize(type = types[i]), val)) { + return type[0] === '+' || type.indexOf('*') !== -1 + ? val + : type + } + } + + // no matches + return false +} + +/** + * Check if a request has a request body. + * A request with a body __must__ either have `transfer-encoding` + * or `content-length` headers set. + * http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.3 + * + * @param {Object} request + * @return {Boolean} + * @public + */ + +function hasbody (req) { + return req.headers['transfer-encoding'] !== undefined || + !isNaN(req.headers['content-length']) +} + +/** + * Check if the incoming request contains the "Content-Type" + * header field, and it contains any of the give mime `type`s. + * If there is no request body, `null` is returned. + * If there is no content type, `false` is returned. + * Otherwise, it returns the first `type` that matches. + * + * Examples: + * + * // With Content-Type: text/html; charset=utf-8 + * this.is('html'); // => 'html' + * this.is('text/html'); // => 'text/html' + * this.is('text/*', 'application/json'); // => 'text/html' + * + * // When Content-Type is application/json + * this.is('json', 'urlencoded'); // => 'json' + * this.is('application/json'); // => 'application/json' + * this.is('html', 'application/*'); // => 'application/json' + * + * this.is('html'); // => false + * + * @param {String|Array} types... + * @return {String|false|null} + * @public + */ + +function typeofrequest (req, types_) { + var types = types_ + + // no body + if (!hasbody(req)) { + return null + } + + // support flattened arguments + if (arguments.length > 2) { + types = new Array(arguments.length - 1) + for (var i = 0; i < types.length; i++) { + types[i] = arguments[i + 1] + } + } + + // request content type + var value = req.headers['content-type'] + + return typeis(value, types) +} + +/** + * Normalize a mime type. + * If it's a shorthand, expand it to a valid mime type. + * + * In general, you probably want: + * + * var type = is(req, ['urlencoded', 'json', 'multipart']); + * + * Then use the appropriate body parsers. + * These three are the most common request body types + * and are thus ensured to work. + * + * @param {String} type + * @private + */ + +function normalize (type) { + if (typeof type !== 'string') { + // invalid type + return false + } + + switch (type) { + case 'urlencoded': + return 'application/x-www-form-urlencoded' + case 'multipart': + return 'multipart/*' + } + + if (type[0] === '+') { + // "+json" -> "*/*+json" expando + return '*/*' + type + } + + return type.indexOf('/') === -1 + ? mime.lookup(type) + : type +} + +/** + * Check if `expected` mime type + * matches `actual` mime type with + * wildcard and +suffix support. + * + * @param {String} expected + * @param {String} actual + * @return {Boolean} + * @private + */ + +function mimeMatch (expected, actual) { + // invalid type + if (expected === false) { + return false + } + + // split types + var actualParts = actual.split('/') + var expectedParts = expected.split('/') + + // invalid format + if (actualParts.length !== 2 || expectedParts.length !== 2) { + return false + } + + // validate type + if (expectedParts[0] !== '*' && expectedParts[0] !== actualParts[0]) { + return false + } + + // validate suffix wildcard + if (expectedParts[1].substr(0, 2) === '*+') { + return expectedParts[1].length <= actualParts[1].length + 1 && + expectedParts[1].substr(1) === actualParts[1].substr(1 - expectedParts[1].length) + } + + // validate subtype + if (expectedParts[1] !== '*' && expectedParts[1] !== actualParts[1]) { + return false + } + + return true +} + +/** + * Normalize a type and remove parameters. + * + * @param {string} value + * @return {string} + * @private + */ + +function normalizeType (value) { + // parse the type + var type = typer.parse(value) + + // remove the parameters + type.parameters = undefined + + // reformat it + return typer.format(type) +} + +/** + * Try to normalize a type and remove parameters. + * + * @param {string} value + * @return {string} + * @private + */ + +function tryNormalizeType (value) { + try { + return normalizeType(value) + } catch (err) { + return null + } +} diff --git a/ui/node_modules/express/node_modules/type-is/node_modules/media-typer/HISTORY.md b/ui/node_modules/express/node_modules/type-is/node_modules/media-typer/HISTORY.md index 76497b1e..62c20031 100644 --- a/ui/node_modules/express/node_modules/type-is/node_modules/media-typer/HISTORY.md +++ b/ui/node_modules/express/node_modules/type-is/node_modules/media-typer/HISTORY.md @@ -1,22 +1,22 @@ -0.3.0 / 2014-09-07 -================== - - * Support Node.js 0.6 - * Throw error when parameter format invalid on parse - -0.2.0 / 2014-06-18 -================== - - * Add `typer.format()` to format media types - -0.1.0 / 2014-06-17 -================== - - * Accept `req` as argument to `parse` - * Accept `res` as argument to `parse` - * Parse media type with extra LWS between type and first parameter - -0.0.0 / 2014-06-13 -================== - - * Initial implementation +0.3.0 / 2014-09-07 +================== + + * Support Node.js 0.6 + * Throw error when parameter format invalid on parse + +0.2.0 / 2014-06-18 +================== + + * Add `typer.format()` to format media types + +0.1.0 / 2014-06-17 +================== + + * Accept `req` as argument to `parse` + * Accept `res` as argument to `parse` + * Parse media type with extra LWS between type and first parameter + +0.0.0 / 2014-06-13 +================== + + * Initial implementation diff --git a/ui/node_modules/express/node_modules/type-is/node_modules/media-typer/LICENSE b/ui/node_modules/express/node_modules/type-is/node_modules/media-typer/LICENSE index 69313376..b7dce6cf 100644 --- a/ui/node_modules/express/node_modules/type-is/node_modules/media-typer/LICENSE +++ b/ui/node_modules/express/node_modules/type-is/node_modules/media-typer/LICENSE @@ -1,22 +1,22 @@ -(The MIT License) - -Copyright (c) 2014 Douglas Christopher Wilson - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2014 Douglas Christopher Wilson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/type-is/node_modules/media-typer/README.md b/ui/node_modules/express/node_modules/type-is/node_modules/media-typer/README.md index 5a23acad..d8df6234 100644 --- a/ui/node_modules/express/node_modules/type-is/node_modules/media-typer/README.md +++ b/ui/node_modules/express/node_modules/type-is/node_modules/media-typer/README.md @@ -1,81 +1,81 @@ -# media-typer - -[![NPM Version][npm-image]][npm-url] -[![NPM Downloads][downloads-image]][downloads-url] -[![Node.js Version][node-version-image]][node-version-url] -[![Build Status][travis-image]][travis-url] -[![Test Coverage][coveralls-image]][coveralls-url] - -Simple RFC 6838 media type parser - -## Installation - -```sh -$ npm install media-typer -``` - -## API - -```js -var typer = require('media-typer') -``` - -### typer.parse(string) - -```js -var obj = typer.parse('image/svg+xml; charset=utf-8') -``` - -Parse a media type string. This will return an object with the following -properties (examples are shown for the string `'image/svg+xml; charset=utf-8'`): - - - `type`: The type of the media type (always lower case). Example: `'image'` - - - `subtype`: The subtype of the media type (always lower case). Example: `'svg'` - - - `suffix`: The suffix of the media type (always lower case). Example: `'xml'` - - - `parameters`: An object of the parameters in the media type (name of parameter always lower case). Example: `{charset: 'utf-8'}` - -### typer.parse(req) - -```js -var obj = typer.parse(req) -``` - -Parse the `content-type` header from the given `req`. Short-cut for -`typer.parse(req.headers['content-type'])`. - -### typer.parse(res) - -```js -var obj = typer.parse(res) -``` - -Parse the `content-type` header set on the given `res`. Short-cut for -`typer.parse(res.getHeader('content-type'))`. - -### typer.format(obj) - -```js -var obj = typer.format({type: 'image', subtype: 'svg', suffix: 'xml'}) -``` - -Format an object into a media type string. This will return a string of the -mime type for the given object. For the properties of the object, see the -documentation for `typer.parse(string)`. - -## License - -[MIT](LICENSE) - -[npm-image]: https://img.shields.io/npm/v/media-typer.svg?style=flat -[npm-url]: https://npmjs.org/package/media-typer -[node-version-image]: https://img.shields.io/badge/node.js-%3E%3D_0.6-brightgreen.svg?style=flat -[node-version-url]: http://nodejs.org/download/ -[travis-image]: https://img.shields.io/travis/jshttp/media-typer.svg?style=flat -[travis-url]: https://travis-ci.org/jshttp/media-typer -[coveralls-image]: https://img.shields.io/coveralls/jshttp/media-typer.svg?style=flat -[coveralls-url]: https://coveralls.io/r/jshttp/media-typer -[downloads-image]: https://img.shields.io/npm/dm/media-typer.svg?style=flat -[downloads-url]: https://npmjs.org/package/media-typer +# media-typer + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-version-image]][node-version-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +Simple RFC 6838 media type parser + +## Installation + +```sh +$ npm install media-typer +``` + +## API + +```js +var typer = require('media-typer') +``` + +### typer.parse(string) + +```js +var obj = typer.parse('image/svg+xml; charset=utf-8') +``` + +Parse a media type string. This will return an object with the following +properties (examples are shown for the string `'image/svg+xml; charset=utf-8'`): + + - `type`: The type of the media type (always lower case). Example: `'image'` + + - `subtype`: The subtype of the media type (always lower case). Example: `'svg'` + + - `suffix`: The suffix of the media type (always lower case). Example: `'xml'` + + - `parameters`: An object of the parameters in the media type (name of parameter always lower case). Example: `{charset: 'utf-8'}` + +### typer.parse(req) + +```js +var obj = typer.parse(req) +``` + +Parse the `content-type` header from the given `req`. Short-cut for +`typer.parse(req.headers['content-type'])`. + +### typer.parse(res) + +```js +var obj = typer.parse(res) +``` + +Parse the `content-type` header set on the given `res`. Short-cut for +`typer.parse(res.getHeader('content-type'))`. + +### typer.format(obj) + +```js +var obj = typer.format({type: 'image', subtype: 'svg', suffix: 'xml'}) +``` + +Format an object into a media type string. This will return a string of the +mime type for the given object. For the properties of the object, see the +documentation for `typer.parse(string)`. + +## License + +[MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/media-typer.svg?style=flat +[npm-url]: https://npmjs.org/package/media-typer +[node-version-image]: https://img.shields.io/badge/node.js-%3E%3D_0.6-brightgreen.svg?style=flat +[node-version-url]: http://nodejs.org/download/ +[travis-image]: https://img.shields.io/travis/jshttp/media-typer.svg?style=flat +[travis-url]: https://travis-ci.org/jshttp/media-typer +[coveralls-image]: https://img.shields.io/coveralls/jshttp/media-typer.svg?style=flat +[coveralls-url]: https://coveralls.io/r/jshttp/media-typer +[downloads-image]: https://img.shields.io/npm/dm/media-typer.svg?style=flat +[downloads-url]: https://npmjs.org/package/media-typer diff --git a/ui/node_modules/express/node_modules/type-is/node_modules/media-typer/index.js b/ui/node_modules/express/node_modules/type-is/node_modules/media-typer/index.js index 38ba5155..07f7295e 100644 --- a/ui/node_modules/express/node_modules/type-is/node_modules/media-typer/index.js +++ b/ui/node_modules/express/node_modules/type-is/node_modules/media-typer/index.js @@ -1,270 +1,270 @@ -/*! - * media-typer - * Copyright(c) 2014 Douglas Christopher Wilson - * MIT Licensed - */ - -/** - * RegExp to match *( ";" parameter ) in RFC 2616 sec 3.7 - * - * parameter = token "=" ( token | quoted-string ) - * token = 1* - * separators = "(" | ")" | "<" | ">" | "@" - * | "," | ";" | ":" | "\" | <"> - * | "/" | "[" | "]" | "?" | "=" - * | "{" | "}" | SP | HT - * quoted-string = ( <"> *(qdtext | quoted-pair ) <"> ) - * qdtext = > - * quoted-pair = "\" CHAR - * CHAR = - * TEXT = - * LWS = [CRLF] 1*( SP | HT ) - * CRLF = CR LF - * CR = - * LF = - * SP = - * SHT = - * CTL = - * OCTET = - */ -var paramRegExp = /; *([!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) *= *("(?:[ !\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u0020-\u007e])*"|[!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) */g; -var textRegExp = /^[\u0020-\u007e\u0080-\u00ff]+$/ -var tokenRegExp = /^[!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+$/ - -/** - * RegExp to match quoted-pair in RFC 2616 - * - * quoted-pair = "\" CHAR - * CHAR = - */ -var qescRegExp = /\\([\u0000-\u007f])/g; - -/** - * RegExp to match chars that must be quoted-pair in RFC 2616 - */ -var quoteRegExp = /([\\"])/g; - -/** - * RegExp to match type in RFC 6838 - * - * type-name = restricted-name - * subtype-name = restricted-name - * restricted-name = restricted-name-first *126restricted-name-chars - * restricted-name-first = ALPHA / DIGIT - * restricted-name-chars = ALPHA / DIGIT / "!" / "#" / - * "$" / "&" / "-" / "^" / "_" - * restricted-name-chars =/ "." ; Characters before first dot always - * ; specify a facet name - * restricted-name-chars =/ "+" ; Characters after last plus always - * ; specify a structured syntax suffix - * ALPHA = %x41-5A / %x61-7A ; A-Z / a-z - * DIGIT = %x30-39 ; 0-9 - */ -var subtypeNameRegExp = /^[A-Za-z0-9][A-Za-z0-9!#$&^_.-]{0,126}$/ -var typeNameRegExp = /^[A-Za-z0-9][A-Za-z0-9!#$&^_-]{0,126}$/ -var typeRegExp = /^ *([A-Za-z0-9][A-Za-z0-9!#$&^_-]{0,126})\/([A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}) *$/; - -/** - * Module exports. - */ - -exports.format = format -exports.parse = parse - -/** - * Format object to media type. - * - * @param {object} obj - * @return {string} - * @api public - */ - -function format(obj) { - if (!obj || typeof obj !== 'object') { - throw new TypeError('argument obj is required') - } - - var parameters = obj.parameters - var subtype = obj.subtype - var suffix = obj.suffix - var type = obj.type - - if (!type || !typeNameRegExp.test(type)) { - throw new TypeError('invalid type') - } - - if (!subtype || !subtypeNameRegExp.test(subtype)) { - throw new TypeError('invalid subtype') - } - - // format as type/subtype - var string = type + '/' + subtype - - // append +suffix - if (suffix) { - if (!typeNameRegExp.test(suffix)) { - throw new TypeError('invalid suffix') - } - - string += '+' + suffix - } - - // append parameters - if (parameters && typeof parameters === 'object') { - var param - var params = Object.keys(parameters).sort() - - for (var i = 0; i < params.length; i++) { - param = params[i] - - if (!tokenRegExp.test(param)) { - throw new TypeError('invalid parameter name') - } - - string += '; ' + param + '=' + qstring(parameters[param]) - } - } - - return string -} - -/** - * Parse media type to object. - * - * @param {string|object} string - * @return {Object} - * @api public - */ - -function parse(string) { - if (!string) { - throw new TypeError('argument string is required') - } - - // support req/res-like objects as argument - if (typeof string === 'object') { - string = getcontenttype(string) - } - - if (typeof string !== 'string') { - throw new TypeError('argument string is required to be a string') - } - - var index = string.indexOf(';') - var type = index !== -1 - ? string.substr(0, index) - : string - - var key - var match - var obj = splitType(type) - var params = {} - var value - - paramRegExp.lastIndex = index - - while (match = paramRegExp.exec(string)) { - if (match.index !== index) { - throw new TypeError('invalid parameter format') - } - - index += match[0].length - key = match[1].toLowerCase() - value = match[2] - - if (value[0] === '"') { - // remove quotes and escapes - value = value - .substr(1, value.length - 2) - .replace(qescRegExp, '$1') - } - - params[key] = value - } - - if (index !== -1 && index !== string.length) { - throw new TypeError('invalid parameter format') - } - - obj.parameters = params - - return obj -} - -/** - * Get content-type from req/res objects. - * - * @param {object} - * @return {Object} - * @api private - */ - -function getcontenttype(obj) { - if (typeof obj.getHeader === 'function') { - // res-like - return obj.getHeader('content-type') - } - - if (typeof obj.headers === 'object') { - // req-like - return obj.headers && obj.headers['content-type'] - } -} - -/** - * Quote a string if necessary. - * - * @param {string} val - * @return {string} - * @api private - */ - -function qstring(val) { - var str = String(val) - - // no need to quote tokens - if (tokenRegExp.test(str)) { - return str - } - - if (str.length > 0 && !textRegExp.test(str)) { - throw new TypeError('invalid parameter value') - } - - return '"' + str.replace(quoteRegExp, '\\$1') + '"' -} - -/** - * Simply "type/subtype+siffx" into parts. - * - * @param {string} string - * @return {Object} - * @api private - */ - -function splitType(string) { - var match = typeRegExp.exec(string.toLowerCase()) - - if (!match) { - throw new TypeError('invalid media type') - } - - var type = match[1] - var subtype = match[2] - var suffix - - // suffix after last + - var index = subtype.lastIndexOf('+') - if (index !== -1) { - suffix = subtype.substr(index + 1) - subtype = subtype.substr(0, index) - } - - var obj = { - type: type, - subtype: subtype, - suffix: suffix - } - - return obj -} +/*! + * media-typer + * Copyright(c) 2014 Douglas Christopher Wilson + * MIT Licensed + */ + +/** + * RegExp to match *( ";" parameter ) in RFC 2616 sec 3.7 + * + * parameter = token "=" ( token | quoted-string ) + * token = 1* + * separators = "(" | ")" | "<" | ">" | "@" + * | "," | ";" | ":" | "\" | <"> + * | "/" | "[" | "]" | "?" | "=" + * | "{" | "}" | SP | HT + * quoted-string = ( <"> *(qdtext | quoted-pair ) <"> ) + * qdtext = > + * quoted-pair = "\" CHAR + * CHAR = + * TEXT = + * LWS = [CRLF] 1*( SP | HT ) + * CRLF = CR LF + * CR = + * LF = + * SP = + * SHT = + * CTL = + * OCTET = + */ +var paramRegExp = /; *([!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) *= *("(?:[ !\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u0020-\u007e])*"|[!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) */g; +var textRegExp = /^[\u0020-\u007e\u0080-\u00ff]+$/ +var tokenRegExp = /^[!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+$/ + +/** + * RegExp to match quoted-pair in RFC 2616 + * + * quoted-pair = "\" CHAR + * CHAR = + */ +var qescRegExp = /\\([\u0000-\u007f])/g; + +/** + * RegExp to match chars that must be quoted-pair in RFC 2616 + */ +var quoteRegExp = /([\\"])/g; + +/** + * RegExp to match type in RFC 6838 + * + * type-name = restricted-name + * subtype-name = restricted-name + * restricted-name = restricted-name-first *126restricted-name-chars + * restricted-name-first = ALPHA / DIGIT + * restricted-name-chars = ALPHA / DIGIT / "!" / "#" / + * "$" / "&" / "-" / "^" / "_" + * restricted-name-chars =/ "." ; Characters before first dot always + * ; specify a facet name + * restricted-name-chars =/ "+" ; Characters after last plus always + * ; specify a structured syntax suffix + * ALPHA = %x41-5A / %x61-7A ; A-Z / a-z + * DIGIT = %x30-39 ; 0-9 + */ +var subtypeNameRegExp = /^[A-Za-z0-9][A-Za-z0-9!#$&^_.-]{0,126}$/ +var typeNameRegExp = /^[A-Za-z0-9][A-Za-z0-9!#$&^_-]{0,126}$/ +var typeRegExp = /^ *([A-Za-z0-9][A-Za-z0-9!#$&^_-]{0,126})\/([A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}) *$/; + +/** + * Module exports. + */ + +exports.format = format +exports.parse = parse + +/** + * Format object to media type. + * + * @param {object} obj + * @return {string} + * @api public + */ + +function format(obj) { + if (!obj || typeof obj !== 'object') { + throw new TypeError('argument obj is required') + } + + var parameters = obj.parameters + var subtype = obj.subtype + var suffix = obj.suffix + var type = obj.type + + if (!type || !typeNameRegExp.test(type)) { + throw new TypeError('invalid type') + } + + if (!subtype || !subtypeNameRegExp.test(subtype)) { + throw new TypeError('invalid subtype') + } + + // format as type/subtype + var string = type + '/' + subtype + + // append +suffix + if (suffix) { + if (!typeNameRegExp.test(suffix)) { + throw new TypeError('invalid suffix') + } + + string += '+' + suffix + } + + // append parameters + if (parameters && typeof parameters === 'object') { + var param + var params = Object.keys(parameters).sort() + + for (var i = 0; i < params.length; i++) { + param = params[i] + + if (!tokenRegExp.test(param)) { + throw new TypeError('invalid parameter name') + } + + string += '; ' + param + '=' + qstring(parameters[param]) + } + } + + return string +} + +/** + * Parse media type to object. + * + * @param {string|object} string + * @return {Object} + * @api public + */ + +function parse(string) { + if (!string) { + throw new TypeError('argument string is required') + } + + // support req/res-like objects as argument + if (typeof string === 'object') { + string = getcontenttype(string) + } + + if (typeof string !== 'string') { + throw new TypeError('argument string is required to be a string') + } + + var index = string.indexOf(';') + var type = index !== -1 + ? string.substr(0, index) + : string + + var key + var match + var obj = splitType(type) + var params = {} + var value + + paramRegExp.lastIndex = index + + while (match = paramRegExp.exec(string)) { + if (match.index !== index) { + throw new TypeError('invalid parameter format') + } + + index += match[0].length + key = match[1].toLowerCase() + value = match[2] + + if (value[0] === '"') { + // remove quotes and escapes + value = value + .substr(1, value.length - 2) + .replace(qescRegExp, '$1') + } + + params[key] = value + } + + if (index !== -1 && index !== string.length) { + throw new TypeError('invalid parameter format') + } + + obj.parameters = params + + return obj +} + +/** + * Get content-type from req/res objects. + * + * @param {object} + * @return {Object} + * @api private + */ + +function getcontenttype(obj) { + if (typeof obj.getHeader === 'function') { + // res-like + return obj.getHeader('content-type') + } + + if (typeof obj.headers === 'object') { + // req-like + return obj.headers && obj.headers['content-type'] + } +} + +/** + * Quote a string if necessary. + * + * @param {string} val + * @return {string} + * @api private + */ + +function qstring(val) { + var str = String(val) + + // no need to quote tokens + if (tokenRegExp.test(str)) { + return str + } + + if (str.length > 0 && !textRegExp.test(str)) { + throw new TypeError('invalid parameter value') + } + + return '"' + str.replace(quoteRegExp, '\\$1') + '"' +} + +/** + * Simply "type/subtype+siffx" into parts. + * + * @param {string} string + * @return {Object} + * @api private + */ + +function splitType(string) { + var match = typeRegExp.exec(string.toLowerCase()) + + if (!match) { + throw new TypeError('invalid media type') + } + + var type = match[1] + var subtype = match[2] + var suffix + + // suffix after last + + var index = subtype.lastIndexOf('+') + if (index !== -1) { + suffix = subtype.substr(index + 1) + subtype = subtype.substr(0, index) + } + + var obj = { + type: type, + subtype: subtype, + suffix: suffix + } + + return obj +} diff --git a/ui/node_modules/express/node_modules/type-is/node_modules/media-typer/package.json b/ui/node_modules/express/node_modules/type-is/node_modules/media-typer/package.json index 496ecd68..f6d67120 100644 --- a/ui/node_modules/express/node_modules/type-is/node_modules/media-typer/package.json +++ b/ui/node_modules/express/node_modules/type-is/node_modules/media-typer/package.json @@ -1,58 +1,58 @@ -{ - "name": "media-typer", - "description": "Simple RFC 6838 media type parser and formatter", - "version": "0.3.0", - "author": { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - }, - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/media-typer.git" - }, - "devDependencies": { - "istanbul": "0.3.2", - "mocha": "~1.21.4", - "should": "~4.0.4" - }, - "files": [ - "LICENSE", - "HISTORY.md", - "index.js" - ], - "engines": { - "node": ">= 0.6" - }, - "scripts": { - "test": "mocha --reporter spec --check-leaks --bail test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" - }, - "gitHead": "d49d41ffd0bb5a0655fa44a59df2ec0bfc835b16", - "bugs": { - "url": "https://github.com/jshttp/media-typer/issues" - }, - "homepage": "https://github.com/jshttp/media-typer", - "_id": "media-typer@0.3.0", - "_shasum": "8710d7af0aa626f8fffa1ce00168545263255748", - "_from": "media-typer@0.3.0", - "_npmVersion": "1.4.21", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "8710d7af0aa626f8fffa1ce00168545263255748", - "tarball": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "media-typer", + "description": "Simple RFC 6838 media type parser and formatter", + "version": "0.3.0", + "author": { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + }, + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/media-typer.git" + }, + "devDependencies": { + "istanbul": "0.3.2", + "mocha": "~1.21.4", + "should": "~4.0.4" + }, + "files": [ + "LICENSE", + "HISTORY.md", + "index.js" + ], + "engines": { + "node": ">= 0.6" + }, + "scripts": { + "test": "mocha --reporter spec --check-leaks --bail test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" + }, + "gitHead": "d49d41ffd0bb5a0655fa44a59df2ec0bfc835b16", + "bugs": { + "url": "https://github.com/jshttp/media-typer/issues" + }, + "homepage": "https://github.com/jshttp/media-typer", + "_id": "media-typer@0.3.0", + "_shasum": "8710d7af0aa626f8fffa1ce00168545263255748", + "_from": "media-typer@0.3.0", + "_npmVersion": "1.4.21", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "maintainers": [ + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + } + ], + "dist": { + "shasum": "8710d7af0aa626f8fffa1ce00168545263255748", + "tarball": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/HISTORY.md b/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/HISTORY.md index 5a848496..63bd4ea0 100644 --- a/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/HISTORY.md +++ b/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/HISTORY.md @@ -1,197 +1,197 @@ -2.1.11 / 2016-05-01 -=================== - - * deps: mime-db@~1.23.0 - - Add new mime types - -2.1.10 / 2016-02-15 -=================== - - * deps: mime-db@~1.22.0 - - Add new mime types - - Fix extension of `application/dash+xml` - - Update primary extension for `audio/mp4` - -2.1.9 / 2016-01-06 -================== - - * deps: mime-db@~1.21.0 - - Add new mime types - -2.1.8 / 2015-11-30 -================== - - * deps: mime-db@~1.20.0 - - Add new mime types - -2.1.7 / 2015-09-20 -================== - - * deps: mime-db@~1.19.0 - - Add new mime types - -2.1.6 / 2015-09-03 -================== - - * deps: mime-db@~1.18.0 - - Add new mime types - -2.1.5 / 2015-08-20 -================== - - * deps: mime-db@~1.17.0 - - Add new mime types - -2.1.4 / 2015-07-30 -================== - - * deps: mime-db@~1.16.0 - - Add new mime types - -2.1.3 / 2015-07-13 -================== - - * deps: mime-db@~1.15.0 - - Add new mime types - -2.1.2 / 2015-06-25 -================== - - * deps: mime-db@~1.14.0 - - Add new mime types - -2.1.1 / 2015-06-08 -================== - - * perf: fix deopt during mapping - -2.1.0 / 2015-06-07 -================== - - * Fix incorrectly treating extension-less file name as extension - - i.e. `'path/to/json'` will no longer return `application/json` - * Fix `.charset(type)` to accept parameters - * Fix `.charset(type)` to match case-insensitive - * Improve generation of extension to MIME mapping - * Refactor internals for readability and no argument reassignment - * Prefer `application/*` MIME types from the same source - * Prefer any type over `application/octet-stream` - * deps: mime-db@~1.13.0 - - Add nginx as a source - - Add new mime types - -2.0.14 / 2015-06-06 -=================== - - * deps: mime-db@~1.12.0 - - Add new mime types - -2.0.13 / 2015-05-31 -=================== - - * deps: mime-db@~1.11.0 - - Add new mime types - -2.0.12 / 2015-05-19 -=================== - - * deps: mime-db@~1.10.0 - - Add new mime types - -2.0.11 / 2015-05-05 -=================== - - * deps: mime-db@~1.9.1 - - Add new mime types - -2.0.10 / 2015-03-13 -=================== - - * deps: mime-db@~1.8.0 - - Add new mime types - -2.0.9 / 2015-02-09 -================== - - * deps: mime-db@~1.7.0 - - Add new mime types - - Community extensions ownership transferred from `node-mime` - -2.0.8 / 2015-01-29 -================== - - * deps: mime-db@~1.6.0 - - Add new mime types - -2.0.7 / 2014-12-30 -================== - - * deps: mime-db@~1.5.0 - - Add new mime types - - Fix various invalid MIME type entries - -2.0.6 / 2014-12-30 -================== - - * deps: mime-db@~1.4.0 - - Add new mime types - - Fix various invalid MIME type entries - - Remove example template MIME types - -2.0.5 / 2014-12-29 -================== - - * deps: mime-db@~1.3.1 - - Fix missing extensions - -2.0.4 / 2014-12-10 -================== - - * deps: mime-db@~1.3.0 - - Add new mime types - -2.0.3 / 2014-11-09 -================== - - * deps: mime-db@~1.2.0 - - Add new mime types - -2.0.2 / 2014-09-28 -================== - - * deps: mime-db@~1.1.0 - - Add new mime types - - Add additional compressible - - Update charsets - -2.0.1 / 2014-09-07 -================== - - * Support Node.js 0.6 - -2.0.0 / 2014-09-02 -================== - - * Use `mime-db` - * Remove `.define()` - -1.0.2 / 2014-08-04 -================== - - * Set charset=utf-8 for `text/javascript` - -1.0.1 / 2014-06-24 -================== - - * Add `text/jsx` type - -1.0.0 / 2014-05-12 -================== - - * Return `false` for unknown types - * Set charset=utf-8 for `application/json` - -0.1.0 / 2014-05-02 -================== - - * Initial release +2.1.11 / 2016-05-01 +=================== + + * deps: mime-db@~1.23.0 + - Add new mime types + +2.1.10 / 2016-02-15 +=================== + + * deps: mime-db@~1.22.0 + - Add new mime types + - Fix extension of `application/dash+xml` + - Update primary extension for `audio/mp4` + +2.1.9 / 2016-01-06 +================== + + * deps: mime-db@~1.21.0 + - Add new mime types + +2.1.8 / 2015-11-30 +================== + + * deps: mime-db@~1.20.0 + - Add new mime types + +2.1.7 / 2015-09-20 +================== + + * deps: mime-db@~1.19.0 + - Add new mime types + +2.1.6 / 2015-09-03 +================== + + * deps: mime-db@~1.18.0 + - Add new mime types + +2.1.5 / 2015-08-20 +================== + + * deps: mime-db@~1.17.0 + - Add new mime types + +2.1.4 / 2015-07-30 +================== + + * deps: mime-db@~1.16.0 + - Add new mime types + +2.1.3 / 2015-07-13 +================== + + * deps: mime-db@~1.15.0 + - Add new mime types + +2.1.2 / 2015-06-25 +================== + + * deps: mime-db@~1.14.0 + - Add new mime types + +2.1.1 / 2015-06-08 +================== + + * perf: fix deopt during mapping + +2.1.0 / 2015-06-07 +================== + + * Fix incorrectly treating extension-less file name as extension + - i.e. `'path/to/json'` will no longer return `application/json` + * Fix `.charset(type)` to accept parameters + * Fix `.charset(type)` to match case-insensitive + * Improve generation of extension to MIME mapping + * Refactor internals for readability and no argument reassignment + * Prefer `application/*` MIME types from the same source + * Prefer any type over `application/octet-stream` + * deps: mime-db@~1.13.0 + - Add nginx as a source + - Add new mime types + +2.0.14 / 2015-06-06 +=================== + + * deps: mime-db@~1.12.0 + - Add new mime types + +2.0.13 / 2015-05-31 +=================== + + * deps: mime-db@~1.11.0 + - Add new mime types + +2.0.12 / 2015-05-19 +=================== + + * deps: mime-db@~1.10.0 + - Add new mime types + +2.0.11 / 2015-05-05 +=================== + + * deps: mime-db@~1.9.1 + - Add new mime types + +2.0.10 / 2015-03-13 +=================== + + * deps: mime-db@~1.8.0 + - Add new mime types + +2.0.9 / 2015-02-09 +================== + + * deps: mime-db@~1.7.0 + - Add new mime types + - Community extensions ownership transferred from `node-mime` + +2.0.8 / 2015-01-29 +================== + + * deps: mime-db@~1.6.0 + - Add new mime types + +2.0.7 / 2014-12-30 +================== + + * deps: mime-db@~1.5.0 + - Add new mime types + - Fix various invalid MIME type entries + +2.0.6 / 2014-12-30 +================== + + * deps: mime-db@~1.4.0 + - Add new mime types + - Fix various invalid MIME type entries + - Remove example template MIME types + +2.0.5 / 2014-12-29 +================== + + * deps: mime-db@~1.3.1 + - Fix missing extensions + +2.0.4 / 2014-12-10 +================== + + * deps: mime-db@~1.3.0 + - Add new mime types + +2.0.3 / 2014-11-09 +================== + + * deps: mime-db@~1.2.0 + - Add new mime types + +2.0.2 / 2014-09-28 +================== + + * deps: mime-db@~1.1.0 + - Add new mime types + - Add additional compressible + - Update charsets + +2.0.1 / 2014-09-07 +================== + + * Support Node.js 0.6 + +2.0.0 / 2014-09-02 +================== + + * Use `mime-db` + * Remove `.define()` + +1.0.2 / 2014-08-04 +================== + + * Set charset=utf-8 for `text/javascript` + +1.0.1 / 2014-06-24 +================== + + * Add `text/jsx` type + +1.0.0 / 2014-05-12 +================== + + * Return `false` for unknown types + * Set charset=utf-8 for `application/json` + +0.1.0 / 2014-05-02 +================== + + * Initial release diff --git a/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/LICENSE b/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/LICENSE index 9bc6a2f9..06166077 100644 --- a/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/LICENSE +++ b/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/LICENSE @@ -1,23 +1,23 @@ -(The MIT License) - -Copyright (c) 2014 Jonathan Ong -Copyright (c) 2015 Douglas Christopher Wilson - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2014 Jonathan Ong +Copyright (c) 2015 Douglas Christopher Wilson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/README.md b/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/README.md index 38c11cc6..e77d615d 100644 --- a/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/README.md +++ b/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/README.md @@ -1,103 +1,103 @@ -# mime-types - -[![NPM Version][npm-image]][npm-url] -[![NPM Downloads][downloads-image]][downloads-url] -[![Node.js Version][node-version-image]][node-version-url] -[![Build Status][travis-image]][travis-url] -[![Test Coverage][coveralls-image]][coveralls-url] - -The ultimate javascript content-type utility. - -Similar to [node-mime](https://github.com/broofa/node-mime), except: - -- __No fallbacks.__ Instead of naively returning the first available type, `mime-types` simply returns `false`, - so do `var type = mime.lookup('unrecognized') || 'application/octet-stream'`. -- No `new Mime()` business, so you could do `var lookup = require('mime-types').lookup`. -- Additional mime types are added such as jade and stylus via [mime-db](https://github.com/jshttp/mime-db) -- No `.define()` functionality - -Otherwise, the API is compatible. - -## Install - -```sh -$ npm install mime-types -``` - -## Adding Types - -All mime types are based on [mime-db](https://github.com/jshttp/mime-db), -so open a PR there if you'd like to add mime types. - -## API - -```js -var mime = require('mime-types') -``` - -All functions return `false` if input is invalid or not found. - -### mime.lookup(path) - -Lookup the content-type associated with a file. - -```js -mime.lookup('json') // 'application/json' -mime.lookup('.md') // 'text/x-markdown' -mime.lookup('file.html') // 'text/html' -mime.lookup('folder/file.js') // 'application/javascript' -mime.lookup('folder/.htaccess') // false - -mime.lookup('cats') // false -``` - -### mime.contentType(type) - -Create a full content-type header given a content-type or extension. - -```js -mime.contentType('markdown') // 'text/x-markdown; charset=utf-8' -mime.contentType('file.json') // 'application/json; charset=utf-8' - -// from a full path -mime.contentType(path.extname('/path/to/file.json')) // 'application/json; charset=utf-8' -``` - -### mime.extension(type) - -Get the default extension for a content-type. - -```js -mime.extension('application/octet-stream') // 'bin' -``` - -### mime.charset(type) - -Lookup the implied default charset of a content-type. - -```js -mime.charset('text/x-markdown') // 'UTF-8' -``` - -### var type = mime.types[extension] - -A map of content-types by extension. - -### [extensions...] = mime.extensions[type] - -A map of extensions by content-type. - -## License - -[MIT](LICENSE) - -[npm-image]: https://img.shields.io/npm/v/mime-types.svg -[npm-url]: https://npmjs.org/package/mime-types -[node-version-image]: https://img.shields.io/node/v/mime-types.svg -[node-version-url]: https://nodejs.org/en/download/ -[travis-image]: https://img.shields.io/travis/jshttp/mime-types/master.svg -[travis-url]: https://travis-ci.org/jshttp/mime-types -[coveralls-image]: https://img.shields.io/coveralls/jshttp/mime-types/master.svg -[coveralls-url]: https://coveralls.io/r/jshttp/mime-types -[downloads-image]: https://img.shields.io/npm/dm/mime-types.svg -[downloads-url]: https://npmjs.org/package/mime-types +# mime-types + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-version-image]][node-version-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +The ultimate javascript content-type utility. + +Similar to [node-mime](https://github.com/broofa/node-mime), except: + +- __No fallbacks.__ Instead of naively returning the first available type, `mime-types` simply returns `false`, + so do `var type = mime.lookup('unrecognized') || 'application/octet-stream'`. +- No `new Mime()` business, so you could do `var lookup = require('mime-types').lookup`. +- Additional mime types are added such as jade and stylus via [mime-db](https://github.com/jshttp/mime-db) +- No `.define()` functionality + +Otherwise, the API is compatible. + +## Install + +```sh +$ npm install mime-types +``` + +## Adding Types + +All mime types are based on [mime-db](https://github.com/jshttp/mime-db), +so open a PR there if you'd like to add mime types. + +## API + +```js +var mime = require('mime-types') +``` + +All functions return `false` if input is invalid or not found. + +### mime.lookup(path) + +Lookup the content-type associated with a file. + +```js +mime.lookup('json') // 'application/json' +mime.lookup('.md') // 'text/x-markdown' +mime.lookup('file.html') // 'text/html' +mime.lookup('folder/file.js') // 'application/javascript' +mime.lookup('folder/.htaccess') // false + +mime.lookup('cats') // false +``` + +### mime.contentType(type) + +Create a full content-type header given a content-type or extension. + +```js +mime.contentType('markdown') // 'text/x-markdown; charset=utf-8' +mime.contentType('file.json') // 'application/json; charset=utf-8' + +// from a full path +mime.contentType(path.extname('/path/to/file.json')) // 'application/json; charset=utf-8' +``` + +### mime.extension(type) + +Get the default extension for a content-type. + +```js +mime.extension('application/octet-stream') // 'bin' +``` + +### mime.charset(type) + +Lookup the implied default charset of a content-type. + +```js +mime.charset('text/x-markdown') // 'UTF-8' +``` + +### var type = mime.types[extension] + +A map of content-types by extension. + +### [extensions...] = mime.extensions[type] + +A map of extensions by content-type. + +## License + +[MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/mime-types.svg +[npm-url]: https://npmjs.org/package/mime-types +[node-version-image]: https://img.shields.io/node/v/mime-types.svg +[node-version-url]: https://nodejs.org/en/download/ +[travis-image]: https://img.shields.io/travis/jshttp/mime-types/master.svg +[travis-url]: https://travis-ci.org/jshttp/mime-types +[coveralls-image]: https://img.shields.io/coveralls/jshttp/mime-types/master.svg +[coveralls-url]: https://coveralls.io/r/jshttp/mime-types +[downloads-image]: https://img.shields.io/npm/dm/mime-types.svg +[downloads-url]: https://npmjs.org/package/mime-types diff --git a/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/index.js b/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/index.js index ac47d8d8..f7008b24 100644 --- a/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/index.js +++ b/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/index.js @@ -1,188 +1,188 @@ -/*! - * mime-types - * Copyright(c) 2014 Jonathan Ong - * Copyright(c) 2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict' - -/** - * Module dependencies. - * @private - */ - -var db = require('mime-db') -var extname = require('path').extname - -/** - * Module variables. - * @private - */ - -var extractTypeRegExp = /^\s*([^;\s]*)(?:;|\s|$)/ -var textTypeRegExp = /^text\//i - -/** - * Module exports. - * @public - */ - -exports.charset = charset -exports.charsets = { lookup: charset } -exports.contentType = contentType -exports.extension = extension -exports.extensions = Object.create(null) -exports.lookup = lookup -exports.types = Object.create(null) - -// Populate the extensions/types maps -populateMaps(exports.extensions, exports.types) - -/** - * Get the default charset for a MIME type. - * - * @param {string} type - * @return {boolean|string} - */ - -function charset(type) { - if (!type || typeof type !== 'string') { - return false - } - - // TODO: use media-typer - var match = extractTypeRegExp.exec(type) - var mime = match && db[match[1].toLowerCase()] - - if (mime && mime.charset) { - return mime.charset - } - - // default text/* to utf-8 - if (match && textTypeRegExp.test(match[1])) { - return 'UTF-8' - } - - return false -} - -/** - * Create a full Content-Type header given a MIME type or extension. - * - * @param {string} str - * @return {boolean|string} - */ - -function contentType(str) { - // TODO: should this even be in this module? - if (!str || typeof str !== 'string') { - return false - } - - var mime = str.indexOf('/') === -1 - ? exports.lookup(str) - : str - - if (!mime) { - return false - } - - // TODO: use content-type or other module - if (mime.indexOf('charset') === -1) { - var charset = exports.charset(mime) - if (charset) mime += '; charset=' + charset.toLowerCase() - } - - return mime -} - -/** - * Get the default extension for a MIME type. - * - * @param {string} type - * @return {boolean|string} - */ - -function extension(type) { - if (!type || typeof type !== 'string') { - return false - } - - // TODO: use media-typer - var match = extractTypeRegExp.exec(type) - - // get extensions - var exts = match && exports.extensions[match[1].toLowerCase()] - - if (!exts || !exts.length) { - return false - } - - return exts[0] -} - -/** - * Lookup the MIME type for a file path/extension. - * - * @param {string} path - * @return {boolean|string} - */ - -function lookup(path) { - if (!path || typeof path !== 'string') { - return false - } - - // get the extension ("ext" or ".ext" or full path) - var extension = extname('x.' + path) - .toLowerCase() - .substr(1) - - if (!extension) { - return false - } - - return exports.types[extension] || false -} - -/** - * Populate the extensions and types maps. - * @private - */ - -function populateMaps(extensions, types) { - // source preference (least -> most) - var preference = ['nginx', 'apache', undefined, 'iana'] - - Object.keys(db).forEach(function forEachMimeType(type) { - var mime = db[type] - var exts = mime.extensions - - if (!exts || !exts.length) { - return - } - - // mime -> extensions - extensions[type] = exts - - // extension -> mime - for (var i = 0; i < exts.length; i++) { - var extension = exts[i] - - if (types[extension]) { - var from = preference.indexOf(db[types[extension]].source) - var to = preference.indexOf(mime.source) - - if (types[extension] !== 'application/octet-stream' - && from > to || (from === to && types[extension].substr(0, 12) === 'application/')) { - // skip the remapping - continue - } - } - - // set the extension -> mime - types[extension] = type - } - }) -} +/*! + * mime-types + * Copyright(c) 2014 Jonathan Ong + * Copyright(c) 2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module dependencies. + * @private + */ + +var db = require('mime-db') +var extname = require('path').extname + +/** + * Module variables. + * @private + */ + +var extractTypeRegExp = /^\s*([^;\s]*)(?:;|\s|$)/ +var textTypeRegExp = /^text\//i + +/** + * Module exports. + * @public + */ + +exports.charset = charset +exports.charsets = { lookup: charset } +exports.contentType = contentType +exports.extension = extension +exports.extensions = Object.create(null) +exports.lookup = lookup +exports.types = Object.create(null) + +// Populate the extensions/types maps +populateMaps(exports.extensions, exports.types) + +/** + * Get the default charset for a MIME type. + * + * @param {string} type + * @return {boolean|string} + */ + +function charset(type) { + if (!type || typeof type !== 'string') { + return false + } + + // TODO: use media-typer + var match = extractTypeRegExp.exec(type) + var mime = match && db[match[1].toLowerCase()] + + if (mime && mime.charset) { + return mime.charset + } + + // default text/* to utf-8 + if (match && textTypeRegExp.test(match[1])) { + return 'UTF-8' + } + + return false +} + +/** + * Create a full Content-Type header given a MIME type or extension. + * + * @param {string} str + * @return {boolean|string} + */ + +function contentType(str) { + // TODO: should this even be in this module? + if (!str || typeof str !== 'string') { + return false + } + + var mime = str.indexOf('/') === -1 + ? exports.lookup(str) + : str + + if (!mime) { + return false + } + + // TODO: use content-type or other module + if (mime.indexOf('charset') === -1) { + var charset = exports.charset(mime) + if (charset) mime += '; charset=' + charset.toLowerCase() + } + + return mime +} + +/** + * Get the default extension for a MIME type. + * + * @param {string} type + * @return {boolean|string} + */ + +function extension(type) { + if (!type || typeof type !== 'string') { + return false + } + + // TODO: use media-typer + var match = extractTypeRegExp.exec(type) + + // get extensions + var exts = match && exports.extensions[match[1].toLowerCase()] + + if (!exts || !exts.length) { + return false + } + + return exts[0] +} + +/** + * Lookup the MIME type for a file path/extension. + * + * @param {string} path + * @return {boolean|string} + */ + +function lookup(path) { + if (!path || typeof path !== 'string') { + return false + } + + // get the extension ("ext" or ".ext" or full path) + var extension = extname('x.' + path) + .toLowerCase() + .substr(1) + + if (!extension) { + return false + } + + return exports.types[extension] || false +} + +/** + * Populate the extensions and types maps. + * @private + */ + +function populateMaps(extensions, types) { + // source preference (least -> most) + var preference = ['nginx', 'apache', undefined, 'iana'] + + Object.keys(db).forEach(function forEachMimeType(type) { + var mime = db[type] + var exts = mime.extensions + + if (!exts || !exts.length) { + return + } + + // mime -> extensions + extensions[type] = exts + + // extension -> mime + for (var i = 0; i < exts.length; i++) { + var extension = exts[i] + + if (types[extension]) { + var from = preference.indexOf(db[types[extension]].source) + var to = preference.indexOf(mime.source) + + if (types[extension] !== 'application/octet-stream' + && from > to || (from === to && types[extension].substr(0, 12) === 'application/')) { + // skip the remapping + continue + } + } + + // set the extension -> mime + types[extension] = type + } + }) +} diff --git a/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/HISTORY.md b/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/HISTORY.md index 5dc6326a..d6705ac8 100644 --- a/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/HISTORY.md +++ b/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/HISTORY.md @@ -1,341 +1,341 @@ -1.23.0 / 2016-05-01 -=================== - - * Add `application/efi` - * Add `application/vnd.3gpp.sms+xml` - * Add `application/vnd.3lightssoftware.imagescal` - * Add `application/vnd.coreos.ignition+json` - * Add `application/vnd.desmume.movie` - * Add `application/vnd.onepager` - * Add `application/vnd.vel+json` - * Add `text/prs.prop.logic` - * Add `video/encaprtp` - * Add `video/h265` - * Add `video/iso.segment` - * Add `video/raptorfec` - * Add `video/rtploopback` - * Add `video/vnd.radgamettools.bink` - * Add `video/vnd.radgamettools.smacker` - * Add `video/vp8` - * Add extension `.3gpp` to `audio/3gpp` - -1.22.0 / 2016-02-15 -=================== - - * Add `application/ppsp-tracker+json` - * Add `application/problem+json` - * Add `application/problem+xml` - * Add `application/vnd.hdt` - * Add `application/vnd.ms-printschematicket+xml` - * Add `model/vnd.rosette.annotated-data-model` - * Add `text/slim` - * Add extension `.rng` to `application/xml` - * Fix extension of `application/dash+xml` to be `.mpd` - * Update primary extension to `.m4a` for `audio/mp4` - -1.21.0 / 2016-01-06 -=================== - - * Add `application/emergencycalldata.comment+xml` - * Add `application/emergencycalldata.deviceinfo+xml` - * Add `application/emergencycalldata.providerinfo+xml` - * Add `application/emergencycalldata.serviceinfo+xml` - * Add `application/emergencycalldata.subscriberinfo+xml` - * Add `application/vnd.filmit.zfc` - * Add `application/vnd.google-apps.document` - * Add `application/vnd.google-apps.presentation` - * Add `application/vnd.google-apps.spreadsheet` - * Add `application/vnd.mapbox-vector-tile` - * Add `application/vnd.ms-printdevicecapabilities+xml` - * Add `application/vnd.ms-windows.devicepairing` - * Add `application/vnd.ms-windows.nwprinting.oob` - * Add `application/vnd.tml` - * Add `audio/evs` - -1.20.0 / 2015-11-10 -=================== - - * Add `application/cdni` - * Add `application/csvm+json` - * Add `application/rfc+xml` - * Add `application/vnd.3gpp.access-transfer-events+xml` - * Add `application/vnd.3gpp.srvcc-ext+xml` - * Add `application/vnd.ms-windows.wsd.oob` - * Add `application/vnd.oxli.countgraph` - * Add `application/vnd.pagerduty+json` - * Add `text/x-suse-ymp` - -1.19.0 / 2015-09-17 -=================== - - * Add `application/vnd.3gpp-prose-pc3ch+xml` - * Add `application/vnd.3gpp.srvcc-info+xml` - * Add `application/vnd.apple.pkpass` - * Add `application/vnd.drive+json` - -1.18.0 / 2015-09-03 -=================== - - * Add `application/pkcs12` - * Add `application/vnd.3gpp-prose+xml` - * Add `application/vnd.3gpp.mid-call+xml` - * Add `application/vnd.3gpp.state-and-event-info+xml` - * Add `application/vnd.anki` - * Add `application/vnd.firemonkeys.cloudcell` - * Add `application/vnd.openblox.game+xml` - * Add `application/vnd.openblox.game-binary` - -1.17.0 / 2015-08-13 -=================== - - * Add `application/x-msdos-program` - * Add `audio/g711-0` - * Add `image/vnd.mozilla.apng` - * Add extension `.exe` to `application/x-msdos-program` - -1.16.0 / 2015-07-29 -=================== - - * Add `application/vnd.uri-map` - -1.15.0 / 2015-07-13 -=================== - - * Add `application/x-httpd-php` - -1.14.0 / 2015-06-25 -=================== - - * Add `application/scim+json` - * Add `application/vnd.3gpp.ussd+xml` - * Add `application/vnd.biopax.rdf+xml` - * Add `text/x-processing` - -1.13.0 / 2015-06-07 -=================== - - * Add nginx as a source - * Add `application/x-cocoa` - * Add `application/x-java-archive-diff` - * Add `application/x-makeself` - * Add `application/x-perl` - * Add `application/x-pilot` - * Add `application/x-redhat-package-manager` - * Add `application/x-sea` - * Add `audio/x-m4a` - * Add `audio/x-realaudio` - * Add `image/x-jng` - * Add `text/mathml` - -1.12.0 / 2015-06-05 -=================== - - * Add `application/bdoc` - * Add `application/vnd.hyperdrive+json` - * Add `application/x-bdoc` - * Add extension `.rtf` to `text/rtf` - -1.11.0 / 2015-05-31 -=================== - - * Add `audio/wav` - * Add `audio/wave` - * Add extension `.litcoffee` to `text/coffeescript` - * Add extension `.sfd-hdstx` to `application/vnd.hydrostatix.sof-data` - * Add extension `.n-gage` to `application/vnd.nokia.n-gage.symbian.install` - -1.10.0 / 2015-05-19 -=================== - - * Add `application/vnd.balsamiq.bmpr` - * Add `application/vnd.microsoft.portable-executable` - * Add `application/x-ns-proxy-autoconfig` - -1.9.1 / 2015-04-19 -================== - - * Remove `.json` extension from `application/manifest+json` - - This is causing bugs downstream - -1.9.0 / 2015-04-19 -================== - - * Add `application/manifest+json` - * Add `application/vnd.micro+json` - * Add `image/vnd.zbrush.pcx` - * Add `image/x-ms-bmp` - -1.8.0 / 2015-03-13 -================== - - * Add `application/vnd.citationstyles.style+xml` - * Add `application/vnd.fastcopy-disk-image` - * Add `application/vnd.gov.sk.xmldatacontainer+xml` - * Add extension `.jsonld` to `application/ld+json` - -1.7.0 / 2015-02-08 -================== - - * Add `application/vnd.gerber` - * Add `application/vnd.msa-disk-image` - -1.6.1 / 2015-02-05 -================== - - * Community extensions ownership transferred from `node-mime` - -1.6.0 / 2015-01-29 -================== - - * Add `application/jose` - * Add `application/jose+json` - * Add `application/json-seq` - * Add `application/jwk+json` - * Add `application/jwk-set+json` - * Add `application/jwt` - * Add `application/rdap+json` - * Add `application/vnd.gov.sk.e-form+xml` - * Add `application/vnd.ims.imsccv1p3` - -1.5.0 / 2014-12-30 -================== - - * Add `application/vnd.oracle.resource+json` - * Fix various invalid MIME type entries - - `application/mbox+xml` - - `application/oscp-response` - - `application/vwg-multiplexed` - - `audio/g721` - -1.4.0 / 2014-12-21 -================== - - * Add `application/vnd.ims.imsccv1p2` - * Fix various invalid MIME type entries - - `application/vnd-acucobol` - - `application/vnd-curl` - - `application/vnd-dart` - - `application/vnd-dxr` - - `application/vnd-fdf` - - `application/vnd-mif` - - `application/vnd-sema` - - `application/vnd-wap-wmlc` - - `application/vnd.adobe.flash-movie` - - `application/vnd.dece-zip` - - `application/vnd.dvb_service` - - `application/vnd.micrografx-igx` - - `application/vnd.sealed-doc` - - `application/vnd.sealed-eml` - - `application/vnd.sealed-mht` - - `application/vnd.sealed-ppt` - - `application/vnd.sealed-tiff` - - `application/vnd.sealed-xls` - - `application/vnd.sealedmedia.softseal-html` - - `application/vnd.sealedmedia.softseal-pdf` - - `application/vnd.wap-slc` - - `application/vnd.wap-wbxml` - - `audio/vnd.sealedmedia.softseal-mpeg` - - `image/vnd-djvu` - - `image/vnd-svf` - - `image/vnd-wap-wbmp` - - `image/vnd.sealed-png` - - `image/vnd.sealedmedia.softseal-gif` - - `image/vnd.sealedmedia.softseal-jpg` - - `model/vnd-dwf` - - `model/vnd.parasolid.transmit-binary` - - `model/vnd.parasolid.transmit-text` - - `text/vnd-a` - - `text/vnd-curl` - - `text/vnd.wap-wml` - * Remove example template MIME types - - `application/example` - - `audio/example` - - `image/example` - - `message/example` - - `model/example` - - `multipart/example` - - `text/example` - - `video/example` - -1.3.1 / 2014-12-16 -================== - - * Fix missing extensions - - `application/json5` - - `text/hjson` - -1.3.0 / 2014-12-07 -================== - - * Add `application/a2l` - * Add `application/aml` - * Add `application/atfx` - * Add `application/atxml` - * Add `application/cdfx+xml` - * Add `application/dii` - * Add `application/json5` - * Add `application/lxf` - * Add `application/mf4` - * Add `application/vnd.apache.thrift.compact` - * Add `application/vnd.apache.thrift.json` - * Add `application/vnd.coffeescript` - * Add `application/vnd.enphase.envoy` - * Add `application/vnd.ims.imsccv1p1` - * Add `text/csv-schema` - * Add `text/hjson` - * Add `text/markdown` - * Add `text/yaml` - -1.2.0 / 2014-11-09 -================== - - * Add `application/cea` - * Add `application/dit` - * Add `application/vnd.gov.sk.e-form+zip` - * Add `application/vnd.tmd.mediaflex.api+xml` - * Type `application/epub+zip` is now IANA-registered - -1.1.2 / 2014-10-23 -================== - - * Rebuild database for `application/x-www-form-urlencoded` change - -1.1.1 / 2014-10-20 -================== - - * Mark `application/x-www-form-urlencoded` as compressible. - -1.1.0 / 2014-09-28 -================== - - * Add `application/font-woff2` - -1.0.3 / 2014-09-25 -================== - - * Fix engine requirement in package - -1.0.2 / 2014-09-25 -================== - - * Add `application/coap-group+json` - * Add `application/dcd` - * Add `application/vnd.apache.thrift.binary` - * Add `image/vnd.tencent.tap` - * Mark all JSON-derived types as compressible - * Update `text/vtt` data - -1.0.1 / 2014-08-30 -================== - - * Fix extension ordering - -1.0.0 / 2014-08-30 -================== - - * Add `application/atf` - * Add `application/merge-patch+json` - * Add `multipart/x-mixed-replace` - * Add `source: 'apache'` metadata - * Add `source: 'iana'` metadata - * Remove badly-assumed charset data +1.23.0 / 2016-05-01 +=================== + + * Add `application/efi` + * Add `application/vnd.3gpp.sms+xml` + * Add `application/vnd.3lightssoftware.imagescal` + * Add `application/vnd.coreos.ignition+json` + * Add `application/vnd.desmume.movie` + * Add `application/vnd.onepager` + * Add `application/vnd.vel+json` + * Add `text/prs.prop.logic` + * Add `video/encaprtp` + * Add `video/h265` + * Add `video/iso.segment` + * Add `video/raptorfec` + * Add `video/rtploopback` + * Add `video/vnd.radgamettools.bink` + * Add `video/vnd.radgamettools.smacker` + * Add `video/vp8` + * Add extension `.3gpp` to `audio/3gpp` + +1.22.0 / 2016-02-15 +=================== + + * Add `application/ppsp-tracker+json` + * Add `application/problem+json` + * Add `application/problem+xml` + * Add `application/vnd.hdt` + * Add `application/vnd.ms-printschematicket+xml` + * Add `model/vnd.rosette.annotated-data-model` + * Add `text/slim` + * Add extension `.rng` to `application/xml` + * Fix extension of `application/dash+xml` to be `.mpd` + * Update primary extension to `.m4a` for `audio/mp4` + +1.21.0 / 2016-01-06 +=================== + + * Add `application/emergencycalldata.comment+xml` + * Add `application/emergencycalldata.deviceinfo+xml` + * Add `application/emergencycalldata.providerinfo+xml` + * Add `application/emergencycalldata.serviceinfo+xml` + * Add `application/emergencycalldata.subscriberinfo+xml` + * Add `application/vnd.filmit.zfc` + * Add `application/vnd.google-apps.document` + * Add `application/vnd.google-apps.presentation` + * Add `application/vnd.google-apps.spreadsheet` + * Add `application/vnd.mapbox-vector-tile` + * Add `application/vnd.ms-printdevicecapabilities+xml` + * Add `application/vnd.ms-windows.devicepairing` + * Add `application/vnd.ms-windows.nwprinting.oob` + * Add `application/vnd.tml` + * Add `audio/evs` + +1.20.0 / 2015-11-10 +=================== + + * Add `application/cdni` + * Add `application/csvm+json` + * Add `application/rfc+xml` + * Add `application/vnd.3gpp.access-transfer-events+xml` + * Add `application/vnd.3gpp.srvcc-ext+xml` + * Add `application/vnd.ms-windows.wsd.oob` + * Add `application/vnd.oxli.countgraph` + * Add `application/vnd.pagerduty+json` + * Add `text/x-suse-ymp` + +1.19.0 / 2015-09-17 +=================== + + * Add `application/vnd.3gpp-prose-pc3ch+xml` + * Add `application/vnd.3gpp.srvcc-info+xml` + * Add `application/vnd.apple.pkpass` + * Add `application/vnd.drive+json` + +1.18.0 / 2015-09-03 +=================== + + * Add `application/pkcs12` + * Add `application/vnd.3gpp-prose+xml` + * Add `application/vnd.3gpp.mid-call+xml` + * Add `application/vnd.3gpp.state-and-event-info+xml` + * Add `application/vnd.anki` + * Add `application/vnd.firemonkeys.cloudcell` + * Add `application/vnd.openblox.game+xml` + * Add `application/vnd.openblox.game-binary` + +1.17.0 / 2015-08-13 +=================== + + * Add `application/x-msdos-program` + * Add `audio/g711-0` + * Add `image/vnd.mozilla.apng` + * Add extension `.exe` to `application/x-msdos-program` + +1.16.0 / 2015-07-29 +=================== + + * Add `application/vnd.uri-map` + +1.15.0 / 2015-07-13 +=================== + + * Add `application/x-httpd-php` + +1.14.0 / 2015-06-25 +=================== + + * Add `application/scim+json` + * Add `application/vnd.3gpp.ussd+xml` + * Add `application/vnd.biopax.rdf+xml` + * Add `text/x-processing` + +1.13.0 / 2015-06-07 +=================== + + * Add nginx as a source + * Add `application/x-cocoa` + * Add `application/x-java-archive-diff` + * Add `application/x-makeself` + * Add `application/x-perl` + * Add `application/x-pilot` + * Add `application/x-redhat-package-manager` + * Add `application/x-sea` + * Add `audio/x-m4a` + * Add `audio/x-realaudio` + * Add `image/x-jng` + * Add `text/mathml` + +1.12.0 / 2015-06-05 +=================== + + * Add `application/bdoc` + * Add `application/vnd.hyperdrive+json` + * Add `application/x-bdoc` + * Add extension `.rtf` to `text/rtf` + +1.11.0 / 2015-05-31 +=================== + + * Add `audio/wav` + * Add `audio/wave` + * Add extension `.litcoffee` to `text/coffeescript` + * Add extension `.sfd-hdstx` to `application/vnd.hydrostatix.sof-data` + * Add extension `.n-gage` to `application/vnd.nokia.n-gage.symbian.install` + +1.10.0 / 2015-05-19 +=================== + + * Add `application/vnd.balsamiq.bmpr` + * Add `application/vnd.microsoft.portable-executable` + * Add `application/x-ns-proxy-autoconfig` + +1.9.1 / 2015-04-19 +================== + + * Remove `.json` extension from `application/manifest+json` + - This is causing bugs downstream + +1.9.0 / 2015-04-19 +================== + + * Add `application/manifest+json` + * Add `application/vnd.micro+json` + * Add `image/vnd.zbrush.pcx` + * Add `image/x-ms-bmp` + +1.8.0 / 2015-03-13 +================== + + * Add `application/vnd.citationstyles.style+xml` + * Add `application/vnd.fastcopy-disk-image` + * Add `application/vnd.gov.sk.xmldatacontainer+xml` + * Add extension `.jsonld` to `application/ld+json` + +1.7.0 / 2015-02-08 +================== + + * Add `application/vnd.gerber` + * Add `application/vnd.msa-disk-image` + +1.6.1 / 2015-02-05 +================== + + * Community extensions ownership transferred from `node-mime` + +1.6.0 / 2015-01-29 +================== + + * Add `application/jose` + * Add `application/jose+json` + * Add `application/json-seq` + * Add `application/jwk+json` + * Add `application/jwk-set+json` + * Add `application/jwt` + * Add `application/rdap+json` + * Add `application/vnd.gov.sk.e-form+xml` + * Add `application/vnd.ims.imsccv1p3` + +1.5.0 / 2014-12-30 +================== + + * Add `application/vnd.oracle.resource+json` + * Fix various invalid MIME type entries + - `application/mbox+xml` + - `application/oscp-response` + - `application/vwg-multiplexed` + - `audio/g721` + +1.4.0 / 2014-12-21 +================== + + * Add `application/vnd.ims.imsccv1p2` + * Fix various invalid MIME type entries + - `application/vnd-acucobol` + - `application/vnd-curl` + - `application/vnd-dart` + - `application/vnd-dxr` + - `application/vnd-fdf` + - `application/vnd-mif` + - `application/vnd-sema` + - `application/vnd-wap-wmlc` + - `application/vnd.adobe.flash-movie` + - `application/vnd.dece-zip` + - `application/vnd.dvb_service` + - `application/vnd.micrografx-igx` + - `application/vnd.sealed-doc` + - `application/vnd.sealed-eml` + - `application/vnd.sealed-mht` + - `application/vnd.sealed-ppt` + - `application/vnd.sealed-tiff` + - `application/vnd.sealed-xls` + - `application/vnd.sealedmedia.softseal-html` + - `application/vnd.sealedmedia.softseal-pdf` + - `application/vnd.wap-slc` + - `application/vnd.wap-wbxml` + - `audio/vnd.sealedmedia.softseal-mpeg` + - `image/vnd-djvu` + - `image/vnd-svf` + - `image/vnd-wap-wbmp` + - `image/vnd.sealed-png` + - `image/vnd.sealedmedia.softseal-gif` + - `image/vnd.sealedmedia.softseal-jpg` + - `model/vnd-dwf` + - `model/vnd.parasolid.transmit-binary` + - `model/vnd.parasolid.transmit-text` + - `text/vnd-a` + - `text/vnd-curl` + - `text/vnd.wap-wml` + * Remove example template MIME types + - `application/example` + - `audio/example` + - `image/example` + - `message/example` + - `model/example` + - `multipart/example` + - `text/example` + - `video/example` + +1.3.1 / 2014-12-16 +================== + + * Fix missing extensions + - `application/json5` + - `text/hjson` + +1.3.0 / 2014-12-07 +================== + + * Add `application/a2l` + * Add `application/aml` + * Add `application/atfx` + * Add `application/atxml` + * Add `application/cdfx+xml` + * Add `application/dii` + * Add `application/json5` + * Add `application/lxf` + * Add `application/mf4` + * Add `application/vnd.apache.thrift.compact` + * Add `application/vnd.apache.thrift.json` + * Add `application/vnd.coffeescript` + * Add `application/vnd.enphase.envoy` + * Add `application/vnd.ims.imsccv1p1` + * Add `text/csv-schema` + * Add `text/hjson` + * Add `text/markdown` + * Add `text/yaml` + +1.2.0 / 2014-11-09 +================== + + * Add `application/cea` + * Add `application/dit` + * Add `application/vnd.gov.sk.e-form+zip` + * Add `application/vnd.tmd.mediaflex.api+xml` + * Type `application/epub+zip` is now IANA-registered + +1.1.2 / 2014-10-23 +================== + + * Rebuild database for `application/x-www-form-urlencoded` change + +1.1.1 / 2014-10-20 +================== + + * Mark `application/x-www-form-urlencoded` as compressible. + +1.1.0 / 2014-09-28 +================== + + * Add `application/font-woff2` + +1.0.3 / 2014-09-25 +================== + + * Fix engine requirement in package + +1.0.2 / 2014-09-25 +================== + + * Add `application/coap-group+json` + * Add `application/dcd` + * Add `application/vnd.apache.thrift.binary` + * Add `image/vnd.tencent.tap` + * Mark all JSON-derived types as compressible + * Update `text/vtt` data + +1.0.1 / 2014-08-30 +================== + + * Fix extension ordering + +1.0.0 / 2014-08-30 +================== + + * Add `application/atf` + * Add `application/merge-patch+json` + * Add `multipart/x-mixed-replace` + * Add `source: 'apache'` metadata + * Add `source: 'iana'` metadata + * Remove badly-assumed charset data diff --git a/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/LICENSE b/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/LICENSE index c1b15a1d..a7ae8ee9 100644 --- a/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/LICENSE +++ b/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/LICENSE @@ -1,22 +1,22 @@ - -The MIT License (MIT) - -Copyright (c) 2014 Jonathan Ong me@jongleberry.com - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. + +The MIT License (MIT) + +Copyright (c) 2014 Jonathan Ong me@jongleberry.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/README.md b/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/README.md index 48c419fc..7662440b 100644 --- a/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/README.md +++ b/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/README.md @@ -1,82 +1,82 @@ -# mime-db - -[![NPM Version][npm-version-image]][npm-url] -[![NPM Downloads][npm-downloads-image]][npm-url] -[![Node.js Version][node-image]][node-url] -[![Build Status][travis-image]][travis-url] -[![Coverage Status][coveralls-image]][coveralls-url] - -This is a database of all mime types. -It consists of a single, public JSON file and does not include any logic, -allowing it to remain as un-opinionated as possible with an API. -It aggregates data from the following sources: - -- http://www.iana.org/assignments/media-types/media-types.xhtml -- http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types -- http://hg.nginx.org/nginx/raw-file/default/conf/mime.types - -## Installation - -```bash -npm install mime-db -``` - -### Database Download - -If you're crazy enough to use this in the browser, you can just grab the -JSON file using [RawGit](https://rawgit.com/). It is recommended to replace -`master` with [a release tag](https://github.com/jshttp/mime-db/tags) as the -JSON format may change in the future. - -``` -https://cdn.rawgit.com/jshttp/mime-db/master/db.json -``` - -## Usage - -```js -var db = require('mime-db'); - -// grab data on .js files -var data = db['application/javascript']; -``` - -## Data Structure - -The JSON file is a map lookup for lowercased mime types. -Each mime type has the following properties: - -- `.source` - where the mime type is defined. - If not set, it's probably a custom media type. - - `apache` - [Apache common media types](http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types) - - `iana` - [IANA-defined media types](http://www.iana.org/assignments/media-types/media-types.xhtml) - - `nginx` - [nginx media types](http://hg.nginx.org/nginx/raw-file/default/conf/mime.types) -- `.extensions[]` - known extensions associated with this mime type. -- `.compressible` - whether a file of this type can be gzipped. -- `.charset` - the default charset associated with this type, if any. - -If unknown, every property could be `undefined`. - -## Contributing - -To edit the database, only make PRs against `src/custom.json` or -`src/custom-suffix.json`. - -To update the build, run `npm run build`. - -## Adding Custom Media Types - -The best way to get new media types included in this library is to register -them with the IANA. The community registration procedure is outlined in -[RFC 6838 section 5](http://tools.ietf.org/html/rfc6838#section-5). Types -registered with the IANA are automatically pulled into this library. - -[npm-version-image]: https://img.shields.io/npm/v/mime-db.svg -[npm-downloads-image]: https://img.shields.io/npm/dm/mime-db.svg -[npm-url]: https://npmjs.org/package/mime-db -[travis-image]: https://img.shields.io/travis/jshttp/mime-db/master.svg -[travis-url]: https://travis-ci.org/jshttp/mime-db -[coveralls-image]: https://img.shields.io/coveralls/jshttp/mime-db/master.svg -[coveralls-url]: https://coveralls.io/r/jshttp/mime-db?branch=master -[node-image]: https://img.shields.io/node/v/mime-db.svg -[node-url]: http://nodejs.org/download/ +# mime-db + +[![NPM Version][npm-version-image]][npm-url] +[![NPM Downloads][npm-downloads-image]][npm-url] +[![Node.js Version][node-image]][node-url] +[![Build Status][travis-image]][travis-url] +[![Coverage Status][coveralls-image]][coveralls-url] + +This is a database of all mime types. +It consists of a single, public JSON file and does not include any logic, +allowing it to remain as un-opinionated as possible with an API. +It aggregates data from the following sources: + +- http://www.iana.org/assignments/media-types/media-types.xhtml +- http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types +- http://hg.nginx.org/nginx/raw-file/default/conf/mime.types + +## Installation + +```bash +npm install mime-db +``` + +### Database Download + +If you're crazy enough to use this in the browser, you can just grab the +JSON file using [RawGit](https://rawgit.com/). It is recommended to replace +`master` with [a release tag](https://github.com/jshttp/mime-db/tags) as the +JSON format may change in the future. + +``` +https://cdn.rawgit.com/jshttp/mime-db/master/db.json +``` + +## Usage + +```js +var db = require('mime-db'); + +// grab data on .js files +var data = db['application/javascript']; +``` + +## Data Structure + +The JSON file is a map lookup for lowercased mime types. +Each mime type has the following properties: + +- `.source` - where the mime type is defined. + If not set, it's probably a custom media type. + - `apache` - [Apache common media types](http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types) + - `iana` - [IANA-defined media types](http://www.iana.org/assignments/media-types/media-types.xhtml) + - `nginx` - [nginx media types](http://hg.nginx.org/nginx/raw-file/default/conf/mime.types) +- `.extensions[]` - known extensions associated with this mime type. +- `.compressible` - whether a file of this type can be gzipped. +- `.charset` - the default charset associated with this type, if any. + +If unknown, every property could be `undefined`. + +## Contributing + +To edit the database, only make PRs against `src/custom.json` or +`src/custom-suffix.json`. + +To update the build, run `npm run build`. + +## Adding Custom Media Types + +The best way to get new media types included in this library is to register +them with the IANA. The community registration procedure is outlined in +[RFC 6838 section 5](http://tools.ietf.org/html/rfc6838#section-5). Types +registered with the IANA are automatically pulled into this library. + +[npm-version-image]: https://img.shields.io/npm/v/mime-db.svg +[npm-downloads-image]: https://img.shields.io/npm/dm/mime-db.svg +[npm-url]: https://npmjs.org/package/mime-db +[travis-image]: https://img.shields.io/travis/jshttp/mime-db/master.svg +[travis-url]: https://travis-ci.org/jshttp/mime-db +[coveralls-image]: https://img.shields.io/coveralls/jshttp/mime-db/master.svg +[coveralls-url]: https://coveralls.io/r/jshttp/mime-db?branch=master +[node-image]: https://img.shields.io/node/v/mime-db.svg +[node-url]: http://nodejs.org/download/ diff --git a/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/db.json b/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/db.json index 8202792e..0a5a8a7b 100644 --- a/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/db.json +++ b/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/db.json @@ -1,6627 +1,6627 @@ -{ - "application/1d-interleaved-parityfec": { - "source": "iana" - }, - "application/3gpdash-qoe-report+xml": { - "source": "iana" - }, - "application/3gpp-ims+xml": { - "source": "iana" - }, - "application/a2l": { - "source": "iana" - }, - "application/activemessage": { - "source": "iana" - }, - "application/alto-costmap+json": { - "source": "iana", - "compressible": true - }, - "application/alto-costmapfilter+json": { - "source": "iana", - "compressible": true - }, - "application/alto-directory+json": { - "source": "iana", - "compressible": true - }, - "application/alto-endpointcost+json": { - "source": "iana", - "compressible": true - }, - "application/alto-endpointcostparams+json": { - "source": "iana", - "compressible": true - }, - "application/alto-endpointprop+json": { - "source": "iana", - "compressible": true - }, - "application/alto-endpointpropparams+json": { - "source": "iana", - "compressible": true - }, - "application/alto-error+json": { - "source": "iana", - "compressible": true - }, - "application/alto-networkmap+json": { - "source": "iana", - "compressible": true - }, - "application/alto-networkmapfilter+json": { - "source": "iana", - "compressible": true - }, - "application/aml": { - "source": "iana" - }, - "application/andrew-inset": { - "source": "iana", - "extensions": ["ez"] - }, - "application/applefile": { - "source": "iana" - }, - "application/applixware": { - "source": "apache", - "extensions": ["aw"] - }, - "application/atf": { - "source": "iana" - }, - "application/atfx": { - "source": "iana" - }, - "application/atom+xml": { - "source": "iana", - "compressible": true, - "extensions": ["atom"] - }, - "application/atomcat+xml": { - "source": "iana", - "extensions": ["atomcat"] - }, - "application/atomdeleted+xml": { - "source": "iana" - }, - "application/atomicmail": { - "source": "iana" - }, - "application/atomsvc+xml": { - "source": "iana", - "extensions": ["atomsvc"] - }, - "application/atxml": { - "source": "iana" - }, - "application/auth-policy+xml": { - "source": "iana" - }, - "application/bacnet-xdd+zip": { - "source": "iana" - }, - "application/batch-smtp": { - "source": "iana" - }, - "application/bdoc": { - "compressible": false, - "extensions": ["bdoc"] - }, - "application/beep+xml": { - "source": "iana" - }, - "application/calendar+json": { - "source": "iana", - "compressible": true - }, - "application/calendar+xml": { - "source": "iana" - }, - "application/call-completion": { - "source": "iana" - }, - "application/cals-1840": { - "source": "iana" - }, - "application/cbor": { - "source": "iana" - }, - "application/ccmp+xml": { - "source": "iana" - }, - "application/ccxml+xml": { - "source": "iana", - "extensions": ["ccxml"] - }, - "application/cdfx+xml": { - "source": "iana" - }, - "application/cdmi-capability": { - "source": "iana", - "extensions": ["cdmia"] - }, - "application/cdmi-container": { - "source": "iana", - "extensions": ["cdmic"] - }, - "application/cdmi-domain": { - "source": "iana", - "extensions": ["cdmid"] - }, - "application/cdmi-object": { - "source": "iana", - "extensions": ["cdmio"] - }, - "application/cdmi-queue": { - "source": "iana", - "extensions": ["cdmiq"] - }, - "application/cdni": { - "source": "iana" - }, - "application/cea": { - "source": "iana" - }, - "application/cea-2018+xml": { - "source": "iana" - }, - "application/cellml+xml": { - "source": "iana" - }, - "application/cfw": { - "source": "iana" - }, - "application/cms": { - "source": "iana" - }, - "application/cnrp+xml": { - "source": "iana" - }, - "application/coap-group+json": { - "source": "iana", - "compressible": true - }, - "application/commonground": { - "source": "iana" - }, - "application/conference-info+xml": { - "source": "iana" - }, - "application/cpl+xml": { - "source": "iana" - }, - "application/csrattrs": { - "source": "iana" - }, - "application/csta+xml": { - "source": "iana" - }, - "application/cstadata+xml": { - "source": "iana" - }, - "application/csvm+json": { - "source": "iana", - "compressible": true - }, - "application/cu-seeme": { - "source": "apache", - "extensions": ["cu"] - }, - "application/cybercash": { - "source": "iana" - }, - "application/dart": { - "compressible": true - }, - "application/dash+xml": { - "source": "iana", - "extensions": ["mpd"] - }, - "application/dashdelta": { - "source": "iana" - }, - "application/davmount+xml": { - "source": "iana", - "extensions": ["davmount"] - }, - "application/dca-rft": { - "source": "iana" - }, - "application/dcd": { - "source": "iana" - }, - "application/dec-dx": { - "source": "iana" - }, - "application/dialog-info+xml": { - "source": "iana" - }, - "application/dicom": { - "source": "iana" - }, - "application/dii": { - "source": "iana" - }, - "application/dit": { - "source": "iana" - }, - "application/dns": { - "source": "iana" - }, - "application/docbook+xml": { - "source": "apache", - "extensions": ["dbk"] - }, - "application/dskpp+xml": { - "source": "iana" - }, - "application/dssc+der": { - "source": "iana", - "extensions": ["dssc"] - }, - "application/dssc+xml": { - "source": "iana", - "extensions": ["xdssc"] - }, - "application/dvcs": { - "source": "iana" - }, - "application/ecmascript": { - "source": "iana", - "compressible": true, - "extensions": ["ecma"] - }, - "application/edi-consent": { - "source": "iana" - }, - "application/edi-x12": { - "source": "iana", - "compressible": false - }, - "application/edifact": { - "source": "iana", - "compressible": false - }, - "application/efi": { - "source": "iana" - }, - "application/emergencycalldata.comment+xml": { - "source": "iana" - }, - "application/emergencycalldata.deviceinfo+xml": { - "source": "iana" - }, - "application/emergencycalldata.providerinfo+xml": { - "source": "iana" - }, - "application/emergencycalldata.serviceinfo+xml": { - "source": "iana" - }, - "application/emergencycalldata.subscriberinfo+xml": { - "source": "iana" - }, - "application/emma+xml": { - "source": "iana", - "extensions": ["emma"] - }, - "application/emotionml+xml": { - "source": "iana" - }, - "application/encaprtp": { - "source": "iana" - }, - "application/epp+xml": { - "source": "iana" - }, - "application/epub+zip": { - "source": "iana", - "extensions": ["epub"] - }, - "application/eshop": { - "source": "iana" - }, - "application/exi": { - "source": "iana", - "extensions": ["exi"] - }, - "application/fastinfoset": { - "source": "iana" - }, - "application/fastsoap": { - "source": "iana" - }, - "application/fdt+xml": { - "source": "iana" - }, - "application/fits": { - "source": "iana" - }, - "application/font-sfnt": { - "source": "iana" - }, - "application/font-tdpfr": { - "source": "iana", - "extensions": ["pfr"] - }, - "application/font-woff": { - "source": "iana", - "compressible": false, - "extensions": ["woff"] - }, - "application/font-woff2": { - "compressible": false, - "extensions": ["woff2"] - }, - "application/framework-attributes+xml": { - "source": "iana" - }, - "application/gml+xml": { - "source": "apache", - "extensions": ["gml"] - }, - "application/gpx+xml": { - "source": "apache", - "extensions": ["gpx"] - }, - "application/gxf": { - "source": "apache", - "extensions": ["gxf"] - }, - "application/gzip": { - "source": "iana", - "compressible": false - }, - "application/h224": { - "source": "iana" - }, - "application/held+xml": { - "source": "iana" - }, - "application/http": { - "source": "iana" - }, - "application/hyperstudio": { - "source": "iana", - "extensions": ["stk"] - }, - "application/ibe-key-request+xml": { - "source": "iana" - }, - "application/ibe-pkg-reply+xml": { - "source": "iana" - }, - "application/ibe-pp-data": { - "source": "iana" - }, - "application/iges": { - "source": "iana" - }, - "application/im-iscomposing+xml": { - "source": "iana" - }, - "application/index": { - "source": "iana" - }, - "application/index.cmd": { - "source": "iana" - }, - "application/index.obj": { - "source": "iana" - }, - "application/index.response": { - "source": "iana" - }, - "application/index.vnd": { - "source": "iana" - }, - "application/inkml+xml": { - "source": "iana", - "extensions": ["ink","inkml"] - }, - "application/iotp": { - "source": "iana" - }, - "application/ipfix": { - "source": "iana", - "extensions": ["ipfix"] - }, - "application/ipp": { - "source": "iana" - }, - "application/isup": { - "source": "iana" - }, - "application/its+xml": { - "source": "iana" - }, - "application/java-archive": { - "source": "apache", - "compressible": false, - "extensions": ["jar","war","ear"] - }, - "application/java-serialized-object": { - "source": "apache", - "compressible": false, - "extensions": ["ser"] - }, - "application/java-vm": { - "source": "apache", - "compressible": false, - "extensions": ["class"] - }, - "application/javascript": { - "source": "iana", - "charset": "UTF-8", - "compressible": true, - "extensions": ["js"] - }, - "application/jose": { - "source": "iana" - }, - "application/jose+json": { - "source": "iana", - "compressible": true - }, - "application/jrd+json": { - "source": "iana", - "compressible": true - }, - "application/json": { - "source": "iana", - "charset": "UTF-8", - "compressible": true, - "extensions": ["json","map"] - }, - "application/json-patch+json": { - "source": "iana", - "compressible": true - }, - "application/json-seq": { - "source": "iana" - }, - "application/json5": { - "extensions": ["json5"] - }, - "application/jsonml+json": { - "source": "apache", - "compressible": true, - "extensions": ["jsonml"] - }, - "application/jwk+json": { - "source": "iana", - "compressible": true - }, - "application/jwk-set+json": { - "source": "iana", - "compressible": true - }, - "application/jwt": { - "source": "iana" - }, - "application/kpml-request+xml": { - "source": "iana" - }, - "application/kpml-response+xml": { - "source": "iana" - }, - "application/ld+json": { - "source": "iana", - "compressible": true, - "extensions": ["jsonld"] - }, - "application/link-format": { - "source": "iana" - }, - "application/load-control+xml": { - "source": "iana" - }, - "application/lost+xml": { - "source": "iana", - "extensions": ["lostxml"] - }, - "application/lostsync+xml": { - "source": "iana" - }, - "application/lxf": { - "source": "iana" - }, - "application/mac-binhex40": { - "source": "iana", - "extensions": ["hqx"] - }, - "application/mac-compactpro": { - "source": "apache", - "extensions": ["cpt"] - }, - "application/macwriteii": { - "source": "iana" - }, - "application/mads+xml": { - "source": "iana", - "extensions": ["mads"] - }, - "application/manifest+json": { - "charset": "UTF-8", - "compressible": true, - "extensions": ["webmanifest"] - }, - "application/marc": { - "source": "iana", - "extensions": ["mrc"] - }, - "application/marcxml+xml": { - "source": "iana", - "extensions": ["mrcx"] - }, - "application/mathematica": { - "source": "iana", - "extensions": ["ma","nb","mb"] - }, - "application/mathml+xml": { - "source": "iana", - "extensions": ["mathml"] - }, - "application/mathml-content+xml": { - "source": "iana" - }, - "application/mathml-presentation+xml": { - "source": "iana" - }, - "application/mbms-associated-procedure-description+xml": { - "source": "iana" - }, - "application/mbms-deregister+xml": { - "source": "iana" - }, - "application/mbms-envelope+xml": { - "source": "iana" - }, - "application/mbms-msk+xml": { - "source": "iana" - }, - "application/mbms-msk-response+xml": { - "source": "iana" - }, - "application/mbms-protection-description+xml": { - "source": "iana" - }, - "application/mbms-reception-report+xml": { - "source": "iana" - }, - "application/mbms-register+xml": { - "source": "iana" - }, - "application/mbms-register-response+xml": { - "source": "iana" - }, - "application/mbms-schedule+xml": { - "source": "iana" - }, - "application/mbms-user-service-description+xml": { - "source": "iana" - }, - "application/mbox": { - "source": "iana", - "extensions": ["mbox"] - }, - "application/media-policy-dataset+xml": { - "source": "iana" - }, - "application/media_control+xml": { - "source": "iana" - }, - "application/mediaservercontrol+xml": { - "source": "iana", - "extensions": ["mscml"] - }, - "application/merge-patch+json": { - "source": "iana", - "compressible": true - }, - "application/metalink+xml": { - "source": "apache", - "extensions": ["metalink"] - }, - "application/metalink4+xml": { - "source": "iana", - "extensions": ["meta4"] - }, - "application/mets+xml": { - "source": "iana", - "extensions": ["mets"] - }, - "application/mf4": { - "source": "iana" - }, - "application/mikey": { - "source": "iana" - }, - "application/mods+xml": { - "source": "iana", - "extensions": ["mods"] - }, - "application/moss-keys": { - "source": "iana" - }, - "application/moss-signature": { - "source": "iana" - }, - "application/mosskey-data": { - "source": "iana" - }, - "application/mosskey-request": { - "source": "iana" - }, - "application/mp21": { - "source": "iana", - "extensions": ["m21","mp21"] - }, - "application/mp4": { - "source": "iana", - "extensions": ["mp4s","m4p"] - }, - "application/mpeg4-generic": { - "source": "iana" - }, - "application/mpeg4-iod": { - "source": "iana" - }, - "application/mpeg4-iod-xmt": { - "source": "iana" - }, - "application/mrb-consumer+xml": { - "source": "iana" - }, - "application/mrb-publish+xml": { - "source": "iana" - }, - "application/msc-ivr+xml": { - "source": "iana" - }, - "application/msc-mixer+xml": { - "source": "iana" - }, - "application/msword": { - "source": "iana", - "compressible": false, - "extensions": ["doc","dot"] - }, - "application/mxf": { - "source": "iana", - "extensions": ["mxf"] - }, - "application/nasdata": { - "source": "iana" - }, - "application/news-checkgroups": { - "source": "iana" - }, - "application/news-groupinfo": { - "source": "iana" - }, - "application/news-transmission": { - "source": "iana" - }, - "application/nlsml+xml": { - "source": "iana" - }, - "application/nss": { - "source": "iana" - }, - "application/ocsp-request": { - "source": "iana" - }, - "application/ocsp-response": { - "source": "iana" - }, - "application/octet-stream": { - "source": "iana", - "compressible": false, - "extensions": ["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"] - }, - "application/oda": { - "source": "iana", - "extensions": ["oda"] - }, - "application/odx": { - "source": "iana" - }, - "application/oebps-package+xml": { - "source": "iana", - "extensions": ["opf"] - }, - "application/ogg": { - "source": "iana", - "compressible": false, - "extensions": ["ogx"] - }, - "application/omdoc+xml": { - "source": "apache", - "extensions": ["omdoc"] - }, - "application/onenote": { - "source": "apache", - "extensions": ["onetoc","onetoc2","onetmp","onepkg"] - }, - "application/oxps": { - "source": "iana", - "extensions": ["oxps"] - }, - "application/p2p-overlay+xml": { - "source": "iana" - }, - "application/parityfec": { - "source": "iana" - }, - "application/patch-ops-error+xml": { - "source": "iana", - "extensions": ["xer"] - }, - "application/pdf": { - "source": "iana", - "compressible": false, - "extensions": ["pdf"] - }, - "application/pdx": { - "source": "iana" - }, - "application/pgp-encrypted": { - "source": "iana", - "compressible": false, - "extensions": ["pgp"] - }, - "application/pgp-keys": { - "source": "iana" - }, - "application/pgp-signature": { - "source": "iana", - "extensions": ["asc","sig"] - }, - "application/pics-rules": { - "source": "apache", - "extensions": ["prf"] - }, - "application/pidf+xml": { - "source": "iana" - }, - "application/pidf-diff+xml": { - "source": "iana" - }, - "application/pkcs10": { - "source": "iana", - "extensions": ["p10"] - }, - "application/pkcs12": { - "source": "iana" - }, - "application/pkcs7-mime": { - "source": "iana", - "extensions": ["p7m","p7c"] - }, - "application/pkcs7-signature": { - "source": "iana", - "extensions": ["p7s"] - }, - "application/pkcs8": { - "source": "iana", - "extensions": ["p8"] - }, - "application/pkix-attr-cert": { - "source": "iana", - "extensions": ["ac"] - }, - "application/pkix-cert": { - "source": "iana", - "extensions": ["cer"] - }, - "application/pkix-crl": { - "source": "iana", - "extensions": ["crl"] - }, - "application/pkix-pkipath": { - "source": "iana", - "extensions": ["pkipath"] - }, - "application/pkixcmp": { - "source": "iana", - "extensions": ["pki"] - }, - "application/pls+xml": { - "source": "iana", - "extensions": ["pls"] - }, - "application/poc-settings+xml": { - "source": "iana" - }, - "application/postscript": { - "source": "iana", - "compressible": true, - "extensions": ["ai","eps","ps"] - }, - "application/ppsp-tracker+json": { - "source": "iana", - "compressible": true - }, - "application/problem+json": { - "source": "iana", - "compressible": true - }, - "application/problem+xml": { - "source": "iana" - }, - "application/provenance+xml": { - "source": "iana" - }, - "application/prs.alvestrand.titrax-sheet": { - "source": "iana" - }, - "application/prs.cww": { - "source": "iana", - "extensions": ["cww"] - }, - "application/prs.hpub+zip": { - "source": "iana" - }, - "application/prs.nprend": { - "source": "iana" - }, - "application/prs.plucker": { - "source": "iana" - }, - "application/prs.rdf-xml-crypt": { - "source": "iana" - }, - "application/prs.xsf+xml": { - "source": "iana" - }, - "application/pskc+xml": { - "source": "iana", - "extensions": ["pskcxml"] - }, - "application/qsig": { - "source": "iana" - }, - "application/raptorfec": { - "source": "iana" - }, - "application/rdap+json": { - "source": "iana", - "compressible": true - }, - "application/rdf+xml": { - "source": "iana", - "compressible": true, - "extensions": ["rdf"] - }, - "application/reginfo+xml": { - "source": "iana", - "extensions": ["rif"] - }, - "application/relax-ng-compact-syntax": { - "source": "iana", - "extensions": ["rnc"] - }, - "application/remote-printing": { - "source": "iana" - }, - "application/reputon+json": { - "source": "iana", - "compressible": true - }, - "application/resource-lists+xml": { - "source": "iana", - "extensions": ["rl"] - }, - "application/resource-lists-diff+xml": { - "source": "iana", - "extensions": ["rld"] - }, - "application/rfc+xml": { - "source": "iana" - }, - "application/riscos": { - "source": "iana" - }, - "application/rlmi+xml": { - "source": "iana" - }, - "application/rls-services+xml": { - "source": "iana", - "extensions": ["rs"] - }, - "application/rpki-ghostbusters": { - "source": "iana", - "extensions": ["gbr"] - }, - "application/rpki-manifest": { - "source": "iana", - "extensions": ["mft"] - }, - "application/rpki-roa": { - "source": "iana", - "extensions": ["roa"] - }, - "application/rpki-updown": { - "source": "iana" - }, - "application/rsd+xml": { - "source": "apache", - "extensions": ["rsd"] - }, - "application/rss+xml": { - "source": "apache", - "compressible": true, - "extensions": ["rss"] - }, - "application/rtf": { - "source": "iana", - "compressible": true, - "extensions": ["rtf"] - }, - "application/rtploopback": { - "source": "iana" - }, - "application/rtx": { - "source": "iana" - }, - "application/samlassertion+xml": { - "source": "iana" - }, - "application/samlmetadata+xml": { - "source": "iana" - }, - "application/sbml+xml": { - "source": "iana", - "extensions": ["sbml"] - }, - "application/scaip+xml": { - "source": "iana" - }, - "application/scim+json": { - "source": "iana", - "compressible": true - }, - "application/scvp-cv-request": { - "source": "iana", - "extensions": ["scq"] - }, - "application/scvp-cv-response": { - "source": "iana", - "extensions": ["scs"] - }, - "application/scvp-vp-request": { - "source": "iana", - "extensions": ["spq"] - }, - "application/scvp-vp-response": { - "source": "iana", - "extensions": ["spp"] - }, - "application/sdp": { - "source": "iana", - "extensions": ["sdp"] - }, - "application/sep+xml": { - "source": "iana" - }, - "application/sep-exi": { - "source": "iana" - }, - "application/session-info": { - "source": "iana" - }, - "application/set-payment": { - "source": "iana" - }, - "application/set-payment-initiation": { - "source": "iana", - "extensions": ["setpay"] - }, - "application/set-registration": { - "source": "iana" - }, - "application/set-registration-initiation": { - "source": "iana", - "extensions": ["setreg"] - }, - "application/sgml": { - "source": "iana" - }, - "application/sgml-open-catalog": { - "source": "iana" - }, - "application/shf+xml": { - "source": "iana", - "extensions": ["shf"] - }, - "application/sieve": { - "source": "iana" - }, - "application/simple-filter+xml": { - "source": "iana" - }, - "application/simple-message-summary": { - "source": "iana" - }, - "application/simplesymbolcontainer": { - "source": "iana" - }, - "application/slate": { - "source": "iana" - }, - "application/smil": { - "source": "iana" - }, - "application/smil+xml": { - "source": "iana", - "extensions": ["smi","smil"] - }, - "application/smpte336m": { - "source": "iana" - }, - "application/soap+fastinfoset": { - "source": "iana" - }, - "application/soap+xml": { - "source": "iana", - "compressible": true - }, - "application/sparql-query": { - "source": "iana", - "extensions": ["rq"] - }, - "application/sparql-results+xml": { - "source": "iana", - "extensions": ["srx"] - }, - "application/spirits-event+xml": { - "source": "iana" - }, - "application/sql": { - "source": "iana" - }, - "application/srgs": { - "source": "iana", - "extensions": ["gram"] - }, - "application/srgs+xml": { - "source": "iana", - "extensions": ["grxml"] - }, - "application/sru+xml": { - "source": "iana", - "extensions": ["sru"] - }, - "application/ssdl+xml": { - "source": "apache", - "extensions": ["ssdl"] - }, - "application/ssml+xml": { - "source": "iana", - "extensions": ["ssml"] - }, - "application/tamp-apex-update": { - "source": "iana" - }, - "application/tamp-apex-update-confirm": { - "source": "iana" - }, - "application/tamp-community-update": { - "source": "iana" - }, - "application/tamp-community-update-confirm": { - "source": "iana" - }, - "application/tamp-error": { - "source": "iana" - }, - "application/tamp-sequence-adjust": { - "source": "iana" - }, - "application/tamp-sequence-adjust-confirm": { - "source": "iana" - }, - "application/tamp-status-query": { - "source": "iana" - }, - "application/tamp-status-response": { - "source": "iana" - }, - "application/tamp-update": { - "source": "iana" - }, - "application/tamp-update-confirm": { - "source": "iana" - }, - "application/tar": { - "compressible": true - }, - "application/tei+xml": { - "source": "iana", - "extensions": ["tei","teicorpus"] - }, - "application/thraud+xml": { - "source": "iana", - "extensions": ["tfi"] - }, - "application/timestamp-query": { - "source": "iana" - }, - "application/timestamp-reply": { - "source": "iana" - }, - "application/timestamped-data": { - "source": "iana", - "extensions": ["tsd"] - }, - "application/ttml+xml": { - "source": "iana" - }, - "application/tve-trigger": { - "source": "iana" - }, - "application/ulpfec": { - "source": "iana" - }, - "application/urc-grpsheet+xml": { - "source": "iana" - }, - "application/urc-ressheet+xml": { - "source": "iana" - }, - "application/urc-targetdesc+xml": { - "source": "iana" - }, - "application/urc-uisocketdesc+xml": { - "source": "iana" - }, - "application/vcard+json": { - "source": "iana", - "compressible": true - }, - "application/vcard+xml": { - "source": "iana" - }, - "application/vemmi": { - "source": "iana" - }, - "application/vividence.scriptfile": { - "source": "apache" - }, - "application/vnd.3gpp-prose+xml": { - "source": "iana" - }, - "application/vnd.3gpp-prose-pc3ch+xml": { - "source": "iana" - }, - "application/vnd.3gpp.access-transfer-events+xml": { - "source": "iana" - }, - "application/vnd.3gpp.bsf+xml": { - "source": "iana" - }, - "application/vnd.3gpp.mid-call+xml": { - "source": "iana" - }, - "application/vnd.3gpp.pic-bw-large": { - "source": "iana", - "extensions": ["plb"] - }, - "application/vnd.3gpp.pic-bw-small": { - "source": "iana", - "extensions": ["psb"] - }, - "application/vnd.3gpp.pic-bw-var": { - "source": "iana", - "extensions": ["pvb"] - }, - "application/vnd.3gpp.sms": { - "source": "iana" - }, - "application/vnd.3gpp.sms+xml": { - "source": "iana" - }, - "application/vnd.3gpp.srvcc-ext+xml": { - "source": "iana" - }, - "application/vnd.3gpp.srvcc-info+xml": { - "source": "iana" - }, - "application/vnd.3gpp.state-and-event-info+xml": { - "source": "iana" - }, - "application/vnd.3gpp.ussd+xml": { - "source": "iana" - }, - "application/vnd.3gpp2.bcmcsinfo+xml": { - "source": "iana" - }, - "application/vnd.3gpp2.sms": { - "source": "iana" - }, - "application/vnd.3gpp2.tcap": { - "source": "iana", - "extensions": ["tcap"] - }, - "application/vnd.3lightssoftware.imagescal": { - "source": "iana" - }, - "application/vnd.3m.post-it-notes": { - "source": "iana", - "extensions": ["pwn"] - }, - "application/vnd.accpac.simply.aso": { - "source": "iana", - "extensions": ["aso"] - }, - "application/vnd.accpac.simply.imp": { - "source": "iana", - "extensions": ["imp"] - }, - "application/vnd.acucobol": { - "source": "iana", - "extensions": ["acu"] - }, - "application/vnd.acucorp": { - "source": "iana", - "extensions": ["atc","acutc"] - }, - "application/vnd.adobe.air-application-installer-package+zip": { - "source": "apache", - "extensions": ["air"] - }, - "application/vnd.adobe.flash.movie": { - "source": "iana" - }, - "application/vnd.adobe.formscentral.fcdt": { - "source": "iana", - "extensions": ["fcdt"] - }, - "application/vnd.adobe.fxp": { - "source": "iana", - "extensions": ["fxp","fxpl"] - }, - "application/vnd.adobe.partial-upload": { - "source": "iana" - }, - "application/vnd.adobe.xdp+xml": { - "source": "iana", - "extensions": ["xdp"] - }, - "application/vnd.adobe.xfdf": { - "source": "iana", - "extensions": ["xfdf"] - }, - "application/vnd.aether.imp": { - "source": "iana" - }, - "application/vnd.ah-barcode": { - "source": "iana" - }, - "application/vnd.ahead.space": { - "source": "iana", - "extensions": ["ahead"] - }, - "application/vnd.airzip.filesecure.azf": { - "source": "iana", - "extensions": ["azf"] - }, - "application/vnd.airzip.filesecure.azs": { - "source": "iana", - "extensions": ["azs"] - }, - "application/vnd.amazon.ebook": { - "source": "apache", - "extensions": ["azw"] - }, - "application/vnd.americandynamics.acc": { - "source": "iana", - "extensions": ["acc"] - }, - "application/vnd.amiga.ami": { - "source": "iana", - "extensions": ["ami"] - }, - "application/vnd.amundsen.maze+xml": { - "source": "iana" - }, - "application/vnd.android.package-archive": { - "source": "apache", - "compressible": false, - "extensions": ["apk"] - }, - "application/vnd.anki": { - "source": "iana" - }, - "application/vnd.anser-web-certificate-issue-initiation": { - "source": "iana", - "extensions": ["cii"] - }, - "application/vnd.anser-web-funds-transfer-initiation": { - "source": "apache", - "extensions": ["fti"] - }, - "application/vnd.antix.game-component": { - "source": "iana", - "extensions": ["atx"] - }, - "application/vnd.apache.thrift.binary": { - "source": "iana" - }, - "application/vnd.apache.thrift.compact": { - "source": "iana" - }, - "application/vnd.apache.thrift.json": { - "source": "iana" - }, - "application/vnd.api+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.apple.installer+xml": { - "source": "iana", - "extensions": ["mpkg"] - }, - "application/vnd.apple.mpegurl": { - "source": "iana", - "extensions": ["m3u8"] - }, - "application/vnd.apple.pkpass": { - "compressible": false, - "extensions": ["pkpass"] - }, - "application/vnd.arastra.swi": { - "source": "iana" - }, - "application/vnd.aristanetworks.swi": { - "source": "iana", - "extensions": ["swi"] - }, - "application/vnd.artsquare": { - "source": "iana" - }, - "application/vnd.astraea-software.iota": { - "source": "iana", - "extensions": ["iota"] - }, - "application/vnd.audiograph": { - "source": "iana", - "extensions": ["aep"] - }, - "application/vnd.autopackage": { - "source": "iana" - }, - "application/vnd.avistar+xml": { - "source": "iana" - }, - "application/vnd.balsamiq.bmml+xml": { - "source": "iana" - }, - "application/vnd.balsamiq.bmpr": { - "source": "iana" - }, - "application/vnd.bekitzur-stech+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.biopax.rdf+xml": { - "source": "iana" - }, - "application/vnd.blueice.multipass": { - "source": "iana", - "extensions": ["mpm"] - }, - "application/vnd.bluetooth.ep.oob": { - "source": "iana" - }, - "application/vnd.bluetooth.le.oob": { - "source": "iana" - }, - "application/vnd.bmi": { - "source": "iana", - "extensions": ["bmi"] - }, - "application/vnd.businessobjects": { - "source": "iana", - "extensions": ["rep"] - }, - "application/vnd.cab-jscript": { - "source": "iana" - }, - "application/vnd.canon-cpdl": { - "source": "iana" - }, - "application/vnd.canon-lips": { - "source": "iana" - }, - "application/vnd.cendio.thinlinc.clientconf": { - "source": "iana" - }, - "application/vnd.century-systems.tcp_stream": { - "source": "iana" - }, - "application/vnd.chemdraw+xml": { - "source": "iana", - "extensions": ["cdxml"] - }, - "application/vnd.chipnuts.karaoke-mmd": { - "source": "iana", - "extensions": ["mmd"] - }, - "application/vnd.cinderella": { - "source": "iana", - "extensions": ["cdy"] - }, - "application/vnd.cirpack.isdn-ext": { - "source": "iana" - }, - "application/vnd.citationstyles.style+xml": { - "source": "iana" - }, - "application/vnd.claymore": { - "source": "iana", - "extensions": ["cla"] - }, - "application/vnd.cloanto.rp9": { - "source": "iana", - "extensions": ["rp9"] - }, - "application/vnd.clonk.c4group": { - "source": "iana", - "extensions": ["c4g","c4d","c4f","c4p","c4u"] - }, - "application/vnd.cluetrust.cartomobile-config": { - "source": "iana", - "extensions": ["c11amc"] - }, - "application/vnd.cluetrust.cartomobile-config-pkg": { - "source": "iana", - "extensions": ["c11amz"] - }, - "application/vnd.coffeescript": { - "source": "iana" - }, - "application/vnd.collection+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.collection.doc+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.collection.next+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.commerce-battelle": { - "source": "iana" - }, - "application/vnd.commonspace": { - "source": "iana", - "extensions": ["csp"] - }, - "application/vnd.contact.cmsg": { - "source": "iana", - "extensions": ["cdbcmsg"] - }, - "application/vnd.coreos.ignition+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.cosmocaller": { - "source": "iana", - "extensions": ["cmc"] - }, - "application/vnd.crick.clicker": { - "source": "iana", - "extensions": ["clkx"] - }, - "application/vnd.crick.clicker.keyboard": { - "source": "iana", - "extensions": ["clkk"] - }, - "application/vnd.crick.clicker.palette": { - "source": "iana", - "extensions": ["clkp"] - }, - "application/vnd.crick.clicker.template": { - "source": "iana", - "extensions": ["clkt"] - }, - "application/vnd.crick.clicker.wordbank": { - "source": "iana", - "extensions": ["clkw"] - }, - "application/vnd.criticaltools.wbs+xml": { - "source": "iana", - "extensions": ["wbs"] - }, - "application/vnd.ctc-posml": { - "source": "iana", - "extensions": ["pml"] - }, - "application/vnd.ctct.ws+xml": { - "source": "iana" - }, - "application/vnd.cups-pdf": { - "source": "iana" - }, - "application/vnd.cups-postscript": { - "source": "iana" - }, - "application/vnd.cups-ppd": { - "source": "iana", - "extensions": ["ppd"] - }, - "application/vnd.cups-raster": { - "source": "iana" - }, - "application/vnd.cups-raw": { - "source": "iana" - }, - "application/vnd.curl": { - "source": "iana" - }, - "application/vnd.curl.car": { - "source": "apache", - "extensions": ["car"] - }, - "application/vnd.curl.pcurl": { - "source": "apache", - "extensions": ["pcurl"] - }, - "application/vnd.cyan.dean.root+xml": { - "source": "iana" - }, - "application/vnd.cybank": { - "source": "iana" - }, - "application/vnd.dart": { - "source": "iana", - "compressible": true, - "extensions": ["dart"] - }, - "application/vnd.data-vision.rdz": { - "source": "iana", - "extensions": ["rdz"] - }, - "application/vnd.debian.binary-package": { - "source": "iana" - }, - "application/vnd.dece.data": { - "source": "iana", - "extensions": ["uvf","uvvf","uvd","uvvd"] - }, - "application/vnd.dece.ttml+xml": { - "source": "iana", - "extensions": ["uvt","uvvt"] - }, - "application/vnd.dece.unspecified": { - "source": "iana", - "extensions": ["uvx","uvvx"] - }, - "application/vnd.dece.zip": { - "source": "iana", - "extensions": ["uvz","uvvz"] - }, - "application/vnd.denovo.fcselayout-link": { - "source": "iana", - "extensions": ["fe_launch"] - }, - "application/vnd.desmume-movie": { - "source": "iana" - }, - "application/vnd.desmume.movie": { - "source": "apache" - }, - "application/vnd.dir-bi.plate-dl-nosuffix": { - "source": "iana" - }, - "application/vnd.dm.delegation+xml": { - "source": "iana" - }, - "application/vnd.dna": { - "source": "iana", - "extensions": ["dna"] - }, - "application/vnd.document+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.dolby.mlp": { - "source": "apache", - "extensions": ["mlp"] - }, - "application/vnd.dolby.mobile.1": { - "source": "iana" - }, - "application/vnd.dolby.mobile.2": { - "source": "iana" - }, - "application/vnd.doremir.scorecloud-binary-document": { - "source": "iana" - }, - "application/vnd.dpgraph": { - "source": "iana", - "extensions": ["dpg"] - }, - "application/vnd.dreamfactory": { - "source": "iana", - "extensions": ["dfac"] - }, - "application/vnd.drive+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.ds-keypoint": { - "source": "apache", - "extensions": ["kpxx"] - }, - "application/vnd.dtg.local": { - "source": "iana" - }, - "application/vnd.dtg.local.flash": { - "source": "iana" - }, - "application/vnd.dtg.local.html": { - "source": "iana" - }, - "application/vnd.dvb.ait": { - "source": "iana", - "extensions": ["ait"] - }, - "application/vnd.dvb.dvbj": { - "source": "iana" - }, - "application/vnd.dvb.esgcontainer": { - "source": "iana" - }, - "application/vnd.dvb.ipdcdftnotifaccess": { - "source": "iana" - }, - "application/vnd.dvb.ipdcesgaccess": { - "source": "iana" - }, - "application/vnd.dvb.ipdcesgaccess2": { - "source": "iana" - }, - "application/vnd.dvb.ipdcesgpdd": { - "source": "iana" - }, - "application/vnd.dvb.ipdcroaming": { - "source": "iana" - }, - "application/vnd.dvb.iptv.alfec-base": { - "source": "iana" - }, - "application/vnd.dvb.iptv.alfec-enhancement": { - "source": "iana" - }, - "application/vnd.dvb.notif-aggregate-root+xml": { - "source": "iana" - }, - "application/vnd.dvb.notif-container+xml": { - "source": "iana" - }, - "application/vnd.dvb.notif-generic+xml": { - "source": "iana" - }, - "application/vnd.dvb.notif-ia-msglist+xml": { - "source": "iana" - }, - "application/vnd.dvb.notif-ia-registration-request+xml": { - "source": "iana" - }, - "application/vnd.dvb.notif-ia-registration-response+xml": { - "source": "iana" - }, - "application/vnd.dvb.notif-init+xml": { - "source": "iana" - }, - "application/vnd.dvb.pfr": { - "source": "iana" - }, - "application/vnd.dvb.service": { - "source": "iana", - "extensions": ["svc"] - }, - "application/vnd.dxr": { - "source": "iana" - }, - "application/vnd.dynageo": { - "source": "iana", - "extensions": ["geo"] - }, - "application/vnd.dzr": { - "source": "iana" - }, - "application/vnd.easykaraoke.cdgdownload": { - "source": "iana" - }, - "application/vnd.ecdis-update": { - "source": "iana" - }, - "application/vnd.ecowin.chart": { - "source": "iana", - "extensions": ["mag"] - }, - "application/vnd.ecowin.filerequest": { - "source": "iana" - }, - "application/vnd.ecowin.fileupdate": { - "source": "iana" - }, - "application/vnd.ecowin.series": { - "source": "iana" - }, - "application/vnd.ecowin.seriesrequest": { - "source": "iana" - }, - "application/vnd.ecowin.seriesupdate": { - "source": "iana" - }, - "application/vnd.emclient.accessrequest+xml": { - "source": "iana" - }, - "application/vnd.enliven": { - "source": "iana", - "extensions": ["nml"] - }, - "application/vnd.enphase.envoy": { - "source": "iana" - }, - "application/vnd.eprints.data+xml": { - "source": "iana" - }, - "application/vnd.epson.esf": { - "source": "iana", - "extensions": ["esf"] - }, - "application/vnd.epson.msf": { - "source": "iana", - "extensions": ["msf"] - }, - "application/vnd.epson.quickanime": { - "source": "iana", - "extensions": ["qam"] - }, - "application/vnd.epson.salt": { - "source": "iana", - "extensions": ["slt"] - }, - "application/vnd.epson.ssf": { - "source": "iana", - "extensions": ["ssf"] - }, - "application/vnd.ericsson.quickcall": { - "source": "iana" - }, - "application/vnd.eszigno3+xml": { - "source": "iana", - "extensions": ["es3","et3"] - }, - "application/vnd.etsi.aoc+xml": { - "source": "iana" - }, - "application/vnd.etsi.asic-e+zip": { - "source": "iana" - }, - "application/vnd.etsi.asic-s+zip": { - "source": "iana" - }, - "application/vnd.etsi.cug+xml": { - "source": "iana" - }, - "application/vnd.etsi.iptvcommand+xml": { - "source": "iana" - }, - "application/vnd.etsi.iptvdiscovery+xml": { - "source": "iana" - }, - "application/vnd.etsi.iptvprofile+xml": { - "source": "iana" - }, - "application/vnd.etsi.iptvsad-bc+xml": { - "source": "iana" - }, - "application/vnd.etsi.iptvsad-cod+xml": { - "source": "iana" - }, - "application/vnd.etsi.iptvsad-npvr+xml": { - "source": "iana" - }, - "application/vnd.etsi.iptvservice+xml": { - "source": "iana" - }, - "application/vnd.etsi.iptvsync+xml": { - "source": "iana" - }, - "application/vnd.etsi.iptvueprofile+xml": { - "source": "iana" - }, - "application/vnd.etsi.mcid+xml": { - "source": "iana" - }, - "application/vnd.etsi.mheg5": { - "source": "iana" - }, - "application/vnd.etsi.overload-control-policy-dataset+xml": { - "source": "iana" - }, - "application/vnd.etsi.pstn+xml": { - "source": "iana" - }, - "application/vnd.etsi.sci+xml": { - "source": "iana" - }, - "application/vnd.etsi.simservs+xml": { - "source": "iana" - }, - "application/vnd.etsi.timestamp-token": { - "source": "iana" - }, - "application/vnd.etsi.tsl+xml": { - "source": "iana" - }, - "application/vnd.etsi.tsl.der": { - "source": "iana" - }, - "application/vnd.eudora.data": { - "source": "iana" - }, - "application/vnd.ezpix-album": { - "source": "iana", - "extensions": ["ez2"] - }, - "application/vnd.ezpix-package": { - "source": "iana", - "extensions": ["ez3"] - }, - "application/vnd.f-secure.mobile": { - "source": "iana" - }, - "application/vnd.fastcopy-disk-image": { - "source": "iana" - }, - "application/vnd.fdf": { - "source": "iana", - "extensions": ["fdf"] - }, - "application/vnd.fdsn.mseed": { - "source": "iana", - "extensions": ["mseed"] - }, - "application/vnd.fdsn.seed": { - "source": "iana", - "extensions": ["seed","dataless"] - }, - "application/vnd.ffsns": { - "source": "iana" - }, - "application/vnd.filmit.zfc": { - "source": "iana" - }, - "application/vnd.fints": { - "source": "iana" - }, - "application/vnd.firemonkeys.cloudcell": { - "source": "iana" - }, - "application/vnd.flographit": { - "source": "iana", - "extensions": ["gph"] - }, - "application/vnd.fluxtime.clip": { - "source": "iana", - "extensions": ["ftc"] - }, - "application/vnd.font-fontforge-sfd": { - "source": "iana" - }, - "application/vnd.framemaker": { - "source": "iana", - "extensions": ["fm","frame","maker","book"] - }, - "application/vnd.frogans.fnc": { - "source": "iana", - "extensions": ["fnc"] - }, - "application/vnd.frogans.ltf": { - "source": "iana", - "extensions": ["ltf"] - }, - "application/vnd.fsc.weblaunch": { - "source": "iana", - "extensions": ["fsc"] - }, - "application/vnd.fujitsu.oasys": { - "source": "iana", - "extensions": ["oas"] - }, - "application/vnd.fujitsu.oasys2": { - "source": "iana", - "extensions": ["oa2"] - }, - "application/vnd.fujitsu.oasys3": { - "source": "iana", - "extensions": ["oa3"] - }, - "application/vnd.fujitsu.oasysgp": { - "source": "iana", - "extensions": ["fg5"] - }, - "application/vnd.fujitsu.oasysprs": { - "source": "iana", - "extensions": ["bh2"] - }, - "application/vnd.fujixerox.art-ex": { - "source": "iana" - }, - "application/vnd.fujixerox.art4": { - "source": "iana" - }, - "application/vnd.fujixerox.ddd": { - "source": "iana", - "extensions": ["ddd"] - }, - "application/vnd.fujixerox.docuworks": { - "source": "iana", - "extensions": ["xdw"] - }, - "application/vnd.fujixerox.docuworks.binder": { - "source": "iana", - "extensions": ["xbd"] - }, - "application/vnd.fujixerox.docuworks.container": { - "source": "iana" - }, - "application/vnd.fujixerox.hbpl": { - "source": "iana" - }, - "application/vnd.fut-misnet": { - "source": "iana" - }, - "application/vnd.fuzzysheet": { - "source": "iana", - "extensions": ["fzs"] - }, - "application/vnd.genomatix.tuxedo": { - "source": "iana", - "extensions": ["txd"] - }, - "application/vnd.geo+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.geocube+xml": { - "source": "iana" - }, - "application/vnd.geogebra.file": { - "source": "iana", - "extensions": ["ggb"] - }, - "application/vnd.geogebra.tool": { - "source": "iana", - "extensions": ["ggt"] - }, - "application/vnd.geometry-explorer": { - "source": "iana", - "extensions": ["gex","gre"] - }, - "application/vnd.geonext": { - "source": "iana", - "extensions": ["gxt"] - }, - "application/vnd.geoplan": { - "source": "iana", - "extensions": ["g2w"] - }, - "application/vnd.geospace": { - "source": "iana", - "extensions": ["g3w"] - }, - "application/vnd.gerber": { - "source": "iana" - }, - "application/vnd.globalplatform.card-content-mgt": { - "source": "iana" - }, - "application/vnd.globalplatform.card-content-mgt-response": { - "source": "iana" - }, - "application/vnd.gmx": { - "source": "iana", - "extensions": ["gmx"] - }, - "application/vnd.google-apps.document": { - "compressible": false, - "extensions": ["gdoc"] - }, - "application/vnd.google-apps.presentation": { - "compressible": false, - "extensions": ["gslides"] - }, - "application/vnd.google-apps.spreadsheet": { - "compressible": false, - "extensions": ["gsheet"] - }, - "application/vnd.google-earth.kml+xml": { - "source": "iana", - "compressible": true, - "extensions": ["kml"] - }, - "application/vnd.google-earth.kmz": { - "source": "iana", - "compressible": false, - "extensions": ["kmz"] - }, - "application/vnd.gov.sk.e-form+xml": { - "source": "iana" - }, - "application/vnd.gov.sk.e-form+zip": { - "source": "iana" - }, - "application/vnd.gov.sk.xmldatacontainer+xml": { - "source": "iana" - }, - "application/vnd.grafeq": { - "source": "iana", - "extensions": ["gqf","gqs"] - }, - "application/vnd.gridmp": { - "source": "iana" - }, - "application/vnd.groove-account": { - "source": "iana", - "extensions": ["gac"] - }, - "application/vnd.groove-help": { - "source": "iana", - "extensions": ["ghf"] - }, - "application/vnd.groove-identity-message": { - "source": "iana", - "extensions": ["gim"] - }, - "application/vnd.groove-injector": { - "source": "iana", - "extensions": ["grv"] - }, - "application/vnd.groove-tool-message": { - "source": "iana", - "extensions": ["gtm"] - }, - "application/vnd.groove-tool-template": { - "source": "iana", - "extensions": ["tpl"] - }, - "application/vnd.groove-vcard": { - "source": "iana", - "extensions": ["vcg"] - }, - "application/vnd.hal+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.hal+xml": { - "source": "iana", - "extensions": ["hal"] - }, - "application/vnd.handheld-entertainment+xml": { - "source": "iana", - "extensions": ["zmm"] - }, - "application/vnd.hbci": { - "source": "iana", - "extensions": ["hbci"] - }, - "application/vnd.hcl-bireports": { - "source": "iana" - }, - "application/vnd.hdt": { - "source": "iana" - }, - "application/vnd.heroku+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.hhe.lesson-player": { - "source": "iana", - "extensions": ["les"] - }, - "application/vnd.hp-hpgl": { - "source": "iana", - "extensions": ["hpgl"] - }, - "application/vnd.hp-hpid": { - "source": "iana", - "extensions": ["hpid"] - }, - "application/vnd.hp-hps": { - "source": "iana", - "extensions": ["hps"] - }, - "application/vnd.hp-jlyt": { - "source": "iana", - "extensions": ["jlt"] - }, - "application/vnd.hp-pcl": { - "source": "iana", - "extensions": ["pcl"] - }, - "application/vnd.hp-pclxl": { - "source": "iana", - "extensions": ["pclxl"] - }, - "application/vnd.httphone": { - "source": "iana" - }, - "application/vnd.hydrostatix.sof-data": { - "source": "iana", - "extensions": ["sfd-hdstx"] - }, - "application/vnd.hyperdrive+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.hzn-3d-crossword": { - "source": "iana" - }, - "application/vnd.ibm.afplinedata": { - "source": "iana" - }, - "application/vnd.ibm.electronic-media": { - "source": "iana" - }, - "application/vnd.ibm.minipay": { - "source": "iana", - "extensions": ["mpy"] - }, - "application/vnd.ibm.modcap": { - "source": "iana", - "extensions": ["afp","listafp","list3820"] - }, - "application/vnd.ibm.rights-management": { - "source": "iana", - "extensions": ["irm"] - }, - "application/vnd.ibm.secure-container": { - "source": "iana", - "extensions": ["sc"] - }, - "application/vnd.iccprofile": { - "source": "iana", - "extensions": ["icc","icm"] - }, - "application/vnd.ieee.1905": { - "source": "iana" - }, - "application/vnd.igloader": { - "source": "iana", - "extensions": ["igl"] - }, - "application/vnd.immervision-ivp": { - "source": "iana", - "extensions": ["ivp"] - }, - "application/vnd.immervision-ivu": { - "source": "iana", - "extensions": ["ivu"] - }, - "application/vnd.ims.imsccv1p1": { - "source": "iana" - }, - "application/vnd.ims.imsccv1p2": { - "source": "iana" - }, - "application/vnd.ims.imsccv1p3": { - "source": "iana" - }, - "application/vnd.ims.lis.v2.result+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.ims.lti.v2.toolconsumerprofile+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.ims.lti.v2.toolproxy+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.ims.lti.v2.toolproxy.id+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.ims.lti.v2.toolsettings+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.ims.lti.v2.toolsettings.simple+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.informedcontrol.rms+xml": { - "source": "iana" - }, - "application/vnd.informix-visionary": { - "source": "iana" - }, - "application/vnd.infotech.project": { - "source": "iana" - }, - "application/vnd.infotech.project+xml": { - "source": "iana" - }, - "application/vnd.innopath.wamp.notification": { - "source": "iana" - }, - "application/vnd.insors.igm": { - "source": "iana", - "extensions": ["igm"] - }, - "application/vnd.intercon.formnet": { - "source": "iana", - "extensions": ["xpw","xpx"] - }, - "application/vnd.intergeo": { - "source": "iana", - "extensions": ["i2g"] - }, - "application/vnd.intertrust.digibox": { - "source": "iana" - }, - "application/vnd.intertrust.nncp": { - "source": "iana" - }, - "application/vnd.intu.qbo": { - "source": "iana", - "extensions": ["qbo"] - }, - "application/vnd.intu.qfx": { - "source": "iana", - "extensions": ["qfx"] - }, - "application/vnd.iptc.g2.catalogitem+xml": { - "source": "iana" - }, - "application/vnd.iptc.g2.conceptitem+xml": { - "source": "iana" - }, - "application/vnd.iptc.g2.knowledgeitem+xml": { - "source": "iana" - }, - "application/vnd.iptc.g2.newsitem+xml": { - "source": "iana" - }, - "application/vnd.iptc.g2.newsmessage+xml": { - "source": "iana" - }, - "application/vnd.iptc.g2.packageitem+xml": { - "source": "iana" - }, - "application/vnd.iptc.g2.planningitem+xml": { - "source": "iana" - }, - "application/vnd.ipunplugged.rcprofile": { - "source": "iana", - "extensions": ["rcprofile"] - }, - "application/vnd.irepository.package+xml": { - "source": "iana", - "extensions": ["irp"] - }, - "application/vnd.is-xpr": { - "source": "iana", - "extensions": ["xpr"] - }, - "application/vnd.isac.fcs": { - "source": "iana", - "extensions": ["fcs"] - }, - "application/vnd.jam": { - "source": "iana", - "extensions": ["jam"] - }, - "application/vnd.japannet-directory-service": { - "source": "iana" - }, - "application/vnd.japannet-jpnstore-wakeup": { - "source": "iana" - }, - "application/vnd.japannet-payment-wakeup": { - "source": "iana" - }, - "application/vnd.japannet-registration": { - "source": "iana" - }, - "application/vnd.japannet-registration-wakeup": { - "source": "iana" - }, - "application/vnd.japannet-setstore-wakeup": { - "source": "iana" - }, - "application/vnd.japannet-verification": { - "source": "iana" - }, - "application/vnd.japannet-verification-wakeup": { - "source": "iana" - }, - "application/vnd.jcp.javame.midlet-rms": { - "source": "iana", - "extensions": ["rms"] - }, - "application/vnd.jisp": { - "source": "iana", - "extensions": ["jisp"] - }, - "application/vnd.joost.joda-archive": { - "source": "iana", - "extensions": ["joda"] - }, - "application/vnd.jsk.isdn-ngn": { - "source": "iana" - }, - "application/vnd.kahootz": { - "source": "iana", - "extensions": ["ktz","ktr"] - }, - "application/vnd.kde.karbon": { - "source": "iana", - "extensions": ["karbon"] - }, - "application/vnd.kde.kchart": { - "source": "iana", - "extensions": ["chrt"] - }, - "application/vnd.kde.kformula": { - "source": "iana", - "extensions": ["kfo"] - }, - "application/vnd.kde.kivio": { - "source": "iana", - "extensions": ["flw"] - }, - "application/vnd.kde.kontour": { - "source": "iana", - "extensions": ["kon"] - }, - "application/vnd.kde.kpresenter": { - "source": "iana", - "extensions": ["kpr","kpt"] - }, - "application/vnd.kde.kspread": { - "source": "iana", - "extensions": ["ksp"] - }, - "application/vnd.kde.kword": { - "source": "iana", - "extensions": ["kwd","kwt"] - }, - "application/vnd.kenameaapp": { - "source": "iana", - "extensions": ["htke"] - }, - "application/vnd.kidspiration": { - "source": "iana", - "extensions": ["kia"] - }, - "application/vnd.kinar": { - "source": "iana", - "extensions": ["kne","knp"] - }, - "application/vnd.koan": { - "source": "iana", - "extensions": ["skp","skd","skt","skm"] - }, - "application/vnd.kodak-descriptor": { - "source": "iana", - "extensions": ["sse"] - }, - "application/vnd.las.las+xml": { - "source": "iana", - "extensions": ["lasxml"] - }, - "application/vnd.liberty-request+xml": { - "source": "iana" - }, - "application/vnd.llamagraphics.life-balance.desktop": { - "source": "iana", - "extensions": ["lbd"] - }, - "application/vnd.llamagraphics.life-balance.exchange+xml": { - "source": "iana", - "extensions": ["lbe"] - }, - "application/vnd.lotus-1-2-3": { - "source": "iana", - "extensions": ["123"] - }, - "application/vnd.lotus-approach": { - "source": "iana", - "extensions": ["apr"] - }, - "application/vnd.lotus-freelance": { - "source": "iana", - "extensions": ["pre"] - }, - "application/vnd.lotus-notes": { - "source": "iana", - "extensions": ["nsf"] - }, - "application/vnd.lotus-organizer": { - "source": "iana", - "extensions": ["org"] - }, - "application/vnd.lotus-screencam": { - "source": "iana", - "extensions": ["scm"] - }, - "application/vnd.lotus-wordpro": { - "source": "iana", - "extensions": ["lwp"] - }, - "application/vnd.macports.portpkg": { - "source": "iana", - "extensions": ["portpkg"] - }, - "application/vnd.mapbox-vector-tile": { - "source": "iana" - }, - "application/vnd.marlin.drm.actiontoken+xml": { - "source": "iana" - }, - "application/vnd.marlin.drm.conftoken+xml": { - "source": "iana" - }, - "application/vnd.marlin.drm.license+xml": { - "source": "iana" - }, - "application/vnd.marlin.drm.mdcf": { - "source": "iana" - }, - "application/vnd.mason+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.maxmind.maxmind-db": { - "source": "iana" - }, - "application/vnd.mcd": { - "source": "iana", - "extensions": ["mcd"] - }, - "application/vnd.medcalcdata": { - "source": "iana", - "extensions": ["mc1"] - }, - "application/vnd.mediastation.cdkey": { - "source": "iana", - "extensions": ["cdkey"] - }, - "application/vnd.meridian-slingshot": { - "source": "iana" - }, - "application/vnd.mfer": { - "source": "iana", - "extensions": ["mwf"] - }, - "application/vnd.mfmp": { - "source": "iana", - "extensions": ["mfm"] - }, - "application/vnd.micro+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.micrografx.flo": { - "source": "iana", - "extensions": ["flo"] - }, - "application/vnd.micrografx.igx": { - "source": "iana", - "extensions": ["igx"] - }, - "application/vnd.microsoft.portable-executable": { - "source": "iana" - }, - "application/vnd.miele+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.mif": { - "source": "iana", - "extensions": ["mif"] - }, - "application/vnd.minisoft-hp3000-save": { - "source": "iana" - }, - "application/vnd.mitsubishi.misty-guard.trustweb": { - "source": "iana" - }, - "application/vnd.mobius.daf": { - "source": "iana", - "extensions": ["daf"] - }, - "application/vnd.mobius.dis": { - "source": "iana", - "extensions": ["dis"] - }, - "application/vnd.mobius.mbk": { - "source": "iana", - "extensions": ["mbk"] - }, - "application/vnd.mobius.mqy": { - "source": "iana", - "extensions": ["mqy"] - }, - "application/vnd.mobius.msl": { - "source": "iana", - "extensions": ["msl"] - }, - "application/vnd.mobius.plc": { - "source": "iana", - "extensions": ["plc"] - }, - "application/vnd.mobius.txf": { - "source": "iana", - "extensions": ["txf"] - }, - "application/vnd.mophun.application": { - "source": "iana", - "extensions": ["mpn"] - }, - "application/vnd.mophun.certificate": { - "source": "iana", - "extensions": ["mpc"] - }, - "application/vnd.motorola.flexsuite": { - "source": "iana" - }, - "application/vnd.motorola.flexsuite.adsi": { - "source": "iana" - }, - "application/vnd.motorola.flexsuite.fis": { - "source": "iana" - }, - "application/vnd.motorola.flexsuite.gotap": { - "source": "iana" - }, - "application/vnd.motorola.flexsuite.kmr": { - "source": "iana" - }, - "application/vnd.motorola.flexsuite.ttc": { - "source": "iana" - }, - "application/vnd.motorola.flexsuite.wem": { - "source": "iana" - }, - "application/vnd.motorola.iprm": { - "source": "iana" - }, - "application/vnd.mozilla.xul+xml": { - "source": "iana", - "compressible": true, - "extensions": ["xul"] - }, - "application/vnd.ms-3mfdocument": { - "source": "iana" - }, - "application/vnd.ms-artgalry": { - "source": "iana", - "extensions": ["cil"] - }, - "application/vnd.ms-asf": { - "source": "iana" - }, - "application/vnd.ms-cab-compressed": { - "source": "iana", - "extensions": ["cab"] - }, - "application/vnd.ms-color.iccprofile": { - "source": "apache" - }, - "application/vnd.ms-excel": { - "source": "iana", - "compressible": false, - "extensions": ["xls","xlm","xla","xlc","xlt","xlw"] - }, - "application/vnd.ms-excel.addin.macroenabled.12": { - "source": "iana", - "extensions": ["xlam"] - }, - "application/vnd.ms-excel.sheet.binary.macroenabled.12": { - "source": "iana", - "extensions": ["xlsb"] - }, - "application/vnd.ms-excel.sheet.macroenabled.12": { - "source": "iana", - "extensions": ["xlsm"] - }, - "application/vnd.ms-excel.template.macroenabled.12": { - "source": "iana", - "extensions": ["xltm"] - }, - "application/vnd.ms-fontobject": { - "source": "iana", - "compressible": true, - "extensions": ["eot"] - }, - "application/vnd.ms-htmlhelp": { - "source": "iana", - "extensions": ["chm"] - }, - "application/vnd.ms-ims": { - "source": "iana", - "extensions": ["ims"] - }, - "application/vnd.ms-lrm": { - "source": "iana", - "extensions": ["lrm"] - }, - "application/vnd.ms-office.activex+xml": { - "source": "iana" - }, - "application/vnd.ms-officetheme": { - "source": "iana", - "extensions": ["thmx"] - }, - "application/vnd.ms-opentype": { - "source": "apache", - "compressible": true - }, - "application/vnd.ms-package.obfuscated-opentype": { - "source": "apache" - }, - "application/vnd.ms-pki.seccat": { - "source": "apache", - "extensions": ["cat"] - }, - "application/vnd.ms-pki.stl": { - "source": "apache", - "extensions": ["stl"] - }, - "application/vnd.ms-playready.initiator+xml": { - "source": "iana" - }, - "application/vnd.ms-powerpoint": { - "source": "iana", - "compressible": false, - "extensions": ["ppt","pps","pot"] - }, - "application/vnd.ms-powerpoint.addin.macroenabled.12": { - "source": "iana", - "extensions": ["ppam"] - }, - "application/vnd.ms-powerpoint.presentation.macroenabled.12": { - "source": "iana", - "extensions": ["pptm"] - }, - "application/vnd.ms-powerpoint.slide.macroenabled.12": { - "source": "iana", - "extensions": ["sldm"] - }, - "application/vnd.ms-powerpoint.slideshow.macroenabled.12": { - "source": "iana", - "extensions": ["ppsm"] - }, - "application/vnd.ms-powerpoint.template.macroenabled.12": { - "source": "iana", - "extensions": ["potm"] - }, - "application/vnd.ms-printdevicecapabilities+xml": { - "source": "iana" - }, - "application/vnd.ms-printing.printticket+xml": { - "source": "apache" - }, - "application/vnd.ms-printschematicket+xml": { - "source": "iana" - }, - "application/vnd.ms-project": { - "source": "iana", - "extensions": ["mpp","mpt"] - }, - "application/vnd.ms-tnef": { - "source": "iana" - }, - "application/vnd.ms-windows.devicepairing": { - "source": "iana" - }, - "application/vnd.ms-windows.nwprinting.oob": { - "source": "iana" - }, - "application/vnd.ms-windows.printerpairing": { - "source": "iana" - }, - "application/vnd.ms-windows.wsd.oob": { - "source": "iana" - }, - "application/vnd.ms-wmdrm.lic-chlg-req": { - "source": "iana" - }, - "application/vnd.ms-wmdrm.lic-resp": { - "source": "iana" - }, - "application/vnd.ms-wmdrm.meter-chlg-req": { - "source": "iana" - }, - "application/vnd.ms-wmdrm.meter-resp": { - "source": "iana" - }, - "application/vnd.ms-word.document.macroenabled.12": { - "source": "iana", - "extensions": ["docm"] - }, - "application/vnd.ms-word.template.macroenabled.12": { - "source": "iana", - "extensions": ["dotm"] - }, - "application/vnd.ms-works": { - "source": "iana", - "extensions": ["wps","wks","wcm","wdb"] - }, - "application/vnd.ms-wpl": { - "source": "iana", - "extensions": ["wpl"] - }, - "application/vnd.ms-xpsdocument": { - "source": "iana", - "compressible": false, - "extensions": ["xps"] - }, - "application/vnd.msa-disk-image": { - "source": "iana" - }, - "application/vnd.mseq": { - "source": "iana", - "extensions": ["mseq"] - }, - "application/vnd.msign": { - "source": "iana" - }, - "application/vnd.multiad.creator": { - "source": "iana" - }, - "application/vnd.multiad.creator.cif": { - "source": "iana" - }, - "application/vnd.music-niff": { - "source": "iana" - }, - "application/vnd.musician": { - "source": "iana", - "extensions": ["mus"] - }, - "application/vnd.muvee.style": { - "source": "iana", - "extensions": ["msty"] - }, - "application/vnd.mynfc": { - "source": "iana", - "extensions": ["taglet"] - }, - "application/vnd.ncd.control": { - "source": "iana" - }, - "application/vnd.ncd.reference": { - "source": "iana" - }, - "application/vnd.nervana": { - "source": "iana" - }, - "application/vnd.netfpx": { - "source": "iana" - }, - "application/vnd.neurolanguage.nlu": { - "source": "iana", - "extensions": ["nlu"] - }, - "application/vnd.nintendo.nitro.rom": { - "source": "iana" - }, - "application/vnd.nintendo.snes.rom": { - "source": "iana" - }, - "application/vnd.nitf": { - "source": "iana", - "extensions": ["ntf","nitf"] - }, - "application/vnd.noblenet-directory": { - "source": "iana", - "extensions": ["nnd"] - }, - "application/vnd.noblenet-sealer": { - "source": "iana", - "extensions": ["nns"] - }, - "application/vnd.noblenet-web": { - "source": "iana", - "extensions": ["nnw"] - }, - "application/vnd.nokia.catalogs": { - "source": "iana" - }, - "application/vnd.nokia.conml+wbxml": { - "source": "iana" - }, - "application/vnd.nokia.conml+xml": { - "source": "iana" - }, - "application/vnd.nokia.iptv.config+xml": { - "source": "iana" - }, - "application/vnd.nokia.isds-radio-presets": { - "source": "iana" - }, - "application/vnd.nokia.landmark+wbxml": { - "source": "iana" - }, - "application/vnd.nokia.landmark+xml": { - "source": "iana" - }, - "application/vnd.nokia.landmarkcollection+xml": { - "source": "iana" - }, - "application/vnd.nokia.n-gage.ac+xml": { - "source": "iana" - }, - "application/vnd.nokia.n-gage.data": { - "source": "iana", - "extensions": ["ngdat"] - }, - "application/vnd.nokia.n-gage.symbian.install": { - "source": "iana", - "extensions": ["n-gage"] - }, - "application/vnd.nokia.ncd": { - "source": "iana" - }, - "application/vnd.nokia.pcd+wbxml": { - "source": "iana" - }, - "application/vnd.nokia.pcd+xml": { - "source": "iana" - }, - "application/vnd.nokia.radio-preset": { - "source": "iana", - "extensions": ["rpst"] - }, - "application/vnd.nokia.radio-presets": { - "source": "iana", - "extensions": ["rpss"] - }, - "application/vnd.novadigm.edm": { - "source": "iana", - "extensions": ["edm"] - }, - "application/vnd.novadigm.edx": { - "source": "iana", - "extensions": ["edx"] - }, - "application/vnd.novadigm.ext": { - "source": "iana", - "extensions": ["ext"] - }, - "application/vnd.ntt-local.content-share": { - "source": "iana" - }, - "application/vnd.ntt-local.file-transfer": { - "source": "iana" - }, - "application/vnd.ntt-local.ogw_remote-access": { - "source": "iana" - }, - "application/vnd.ntt-local.sip-ta_remote": { - "source": "iana" - }, - "application/vnd.ntt-local.sip-ta_tcp_stream": { - "source": "iana" - }, - "application/vnd.oasis.opendocument.chart": { - "source": "iana", - "extensions": ["odc"] - }, - "application/vnd.oasis.opendocument.chart-template": { - "source": "iana", - "extensions": ["otc"] - }, - "application/vnd.oasis.opendocument.database": { - "source": "iana", - "extensions": ["odb"] - }, - "application/vnd.oasis.opendocument.formula": { - "source": "iana", - "extensions": ["odf"] - }, - "application/vnd.oasis.opendocument.formula-template": { - "source": "iana", - "extensions": ["odft"] - }, - "application/vnd.oasis.opendocument.graphics": { - "source": "iana", - "compressible": false, - "extensions": ["odg"] - }, - "application/vnd.oasis.opendocument.graphics-template": { - "source": "iana", - "extensions": ["otg"] - }, - "application/vnd.oasis.opendocument.image": { - "source": "iana", - "extensions": ["odi"] - }, - "application/vnd.oasis.opendocument.image-template": { - "source": "iana", - "extensions": ["oti"] - }, - "application/vnd.oasis.opendocument.presentation": { - "source": "iana", - "compressible": false, - "extensions": ["odp"] - }, - "application/vnd.oasis.opendocument.presentation-template": { - "source": "iana", - "extensions": ["otp"] - }, - "application/vnd.oasis.opendocument.spreadsheet": { - "source": "iana", - "compressible": false, - "extensions": ["ods"] - }, - "application/vnd.oasis.opendocument.spreadsheet-template": { - "source": "iana", - "extensions": ["ots"] - }, - "application/vnd.oasis.opendocument.text": { - "source": "iana", - "compressible": false, - "extensions": ["odt"] - }, - "application/vnd.oasis.opendocument.text-master": { - "source": "iana", - "extensions": ["odm"] - }, - "application/vnd.oasis.opendocument.text-template": { - "source": "iana", - "extensions": ["ott"] - }, - "application/vnd.oasis.opendocument.text-web": { - "source": "iana", - "extensions": ["oth"] - }, - "application/vnd.obn": { - "source": "iana" - }, - "application/vnd.oftn.l10n+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.oipf.contentaccessdownload+xml": { - "source": "iana" - }, - "application/vnd.oipf.contentaccessstreaming+xml": { - "source": "iana" - }, - "application/vnd.oipf.cspg-hexbinary": { - "source": "iana" - }, - "application/vnd.oipf.dae.svg+xml": { - "source": "iana" - }, - "application/vnd.oipf.dae.xhtml+xml": { - "source": "iana" - }, - "application/vnd.oipf.mippvcontrolmessage+xml": { - "source": "iana" - }, - "application/vnd.oipf.pae.gem": { - "source": "iana" - }, - "application/vnd.oipf.spdiscovery+xml": { - "source": "iana" - }, - "application/vnd.oipf.spdlist+xml": { - "source": "iana" - }, - "application/vnd.oipf.ueprofile+xml": { - "source": "iana" - }, - "application/vnd.oipf.userprofile+xml": { - "source": "iana" - }, - "application/vnd.olpc-sugar": { - "source": "iana", - "extensions": ["xo"] - }, - "application/vnd.oma-scws-config": { - "source": "iana" - }, - "application/vnd.oma-scws-http-request": { - "source": "iana" - }, - "application/vnd.oma-scws-http-response": { - "source": "iana" - }, - "application/vnd.oma.bcast.associated-procedure-parameter+xml": { - "source": "iana" - }, - "application/vnd.oma.bcast.drm-trigger+xml": { - "source": "iana" - }, - "application/vnd.oma.bcast.imd+xml": { - "source": "iana" - }, - "application/vnd.oma.bcast.ltkm": { - "source": "iana" - }, - "application/vnd.oma.bcast.notification+xml": { - "source": "iana" - }, - "application/vnd.oma.bcast.provisioningtrigger": { - "source": "iana" - }, - "application/vnd.oma.bcast.sgboot": { - "source": "iana" - }, - "application/vnd.oma.bcast.sgdd+xml": { - "source": "iana" - }, - "application/vnd.oma.bcast.sgdu": { - "source": "iana" - }, - "application/vnd.oma.bcast.simple-symbol-container": { - "source": "iana" - }, - "application/vnd.oma.bcast.smartcard-trigger+xml": { - "source": "iana" - }, - "application/vnd.oma.bcast.sprov+xml": { - "source": "iana" - }, - "application/vnd.oma.bcast.stkm": { - "source": "iana" - }, - "application/vnd.oma.cab-address-book+xml": { - "source": "iana" - }, - "application/vnd.oma.cab-feature-handler+xml": { - "source": "iana" - }, - "application/vnd.oma.cab-pcc+xml": { - "source": "iana" - }, - "application/vnd.oma.cab-subs-invite+xml": { - "source": "iana" - }, - "application/vnd.oma.cab-user-prefs+xml": { - "source": "iana" - }, - "application/vnd.oma.dcd": { - "source": "iana" - }, - "application/vnd.oma.dcdc": { - "source": "iana" - }, - "application/vnd.oma.dd2+xml": { - "source": "iana", - "extensions": ["dd2"] - }, - "application/vnd.oma.drm.risd+xml": { - "source": "iana" - }, - "application/vnd.oma.group-usage-list+xml": { - "source": "iana" - }, - "application/vnd.oma.pal+xml": { - "source": "iana" - }, - "application/vnd.oma.poc.detailed-progress-report+xml": { - "source": "iana" - }, - "application/vnd.oma.poc.final-report+xml": { - "source": "iana" - }, - "application/vnd.oma.poc.groups+xml": { - "source": "iana" - }, - "application/vnd.oma.poc.invocation-descriptor+xml": { - "source": "iana" - }, - "application/vnd.oma.poc.optimized-progress-report+xml": { - "source": "iana" - }, - "application/vnd.oma.push": { - "source": "iana" - }, - "application/vnd.oma.scidm.messages+xml": { - "source": "iana" - }, - "application/vnd.oma.xcap-directory+xml": { - "source": "iana" - }, - "application/vnd.omads-email+xml": { - "source": "iana" - }, - "application/vnd.omads-file+xml": { - "source": "iana" - }, - "application/vnd.omads-folder+xml": { - "source": "iana" - }, - "application/vnd.omaloc-supl-init": { - "source": "iana" - }, - "application/vnd.onepager": { - "source": "iana" - }, - "application/vnd.openblox.game+xml": { - "source": "iana" - }, - "application/vnd.openblox.game-binary": { - "source": "iana" - }, - "application/vnd.openeye.oeb": { - "source": "iana" - }, - "application/vnd.openofficeorg.extension": { - "source": "apache", - "extensions": ["oxt"] - }, - "application/vnd.openxmlformats-officedocument.custom-properties+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.customxmlproperties+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.drawing+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.drawingml.chart+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.drawingml.diagramcolors+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.drawingml.diagramdata+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.drawingml.diagramlayout+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.drawingml.diagramstyle+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.extended-properties+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml-template": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.commentauthors+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.comments+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.handoutmaster+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.notesmaster+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.notesslide+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.presentation": { - "source": "iana", - "compressible": false, - "extensions": ["pptx"] - }, - "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.presprops+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.slide": { - "source": "iana", - "extensions": ["sldx"] - }, - "application/vnd.openxmlformats-officedocument.presentationml.slide+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.slidelayout+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.slidemaster+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.slideshow": { - "source": "iana", - "extensions": ["ppsx"] - }, - "application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.slideupdateinfo+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.tablestyles+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.tags+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.template": { - "source": "apache", - "extensions": ["potx"] - }, - "application/vnd.openxmlformats-officedocument.presentationml.template.main+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.presentationml.viewprops+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml-template": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.calcchain+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.externallink+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcachedefinition+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcacherecords+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.pivottable+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.querytable+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.revisionheaders+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.revisionlog+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedstrings+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": { - "source": "iana", - "compressible": false, - "extensions": ["xlsx"] - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheetmetadata+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.tablesinglecells+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.template": { - "source": "apache", - "extensions": ["xltx"] - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.usernames+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.volatiledependencies+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.theme+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.themeoverride+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.vmldrawing": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml-template": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml.document": { - "source": "iana", - "compressible": false, - "extensions": ["docx"] - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml.fonttable+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml.template": { - "source": "apache", - "extensions": ["dotx"] - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-officedocument.wordprocessingml.websettings+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-package.core-properties+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml": { - "source": "iana" - }, - "application/vnd.openxmlformats-package.relationships+xml": { - "source": "iana" - }, - "application/vnd.oracle.resource+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.orange.indata": { - "source": "iana" - }, - "application/vnd.osa.netdeploy": { - "source": "iana" - }, - "application/vnd.osgeo.mapguide.package": { - "source": "iana", - "extensions": ["mgp"] - }, - "application/vnd.osgi.bundle": { - "source": "iana" - }, - "application/vnd.osgi.dp": { - "source": "iana", - "extensions": ["dp"] - }, - "application/vnd.osgi.subsystem": { - "source": "iana", - "extensions": ["esa"] - }, - "application/vnd.otps.ct-kip+xml": { - "source": "iana" - }, - "application/vnd.oxli.countgraph": { - "source": "iana" - }, - "application/vnd.pagerduty+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.palm": { - "source": "iana", - "extensions": ["pdb","pqa","oprc"] - }, - "application/vnd.panoply": { - "source": "iana" - }, - "application/vnd.paos+xml": { - "source": "iana" - }, - "application/vnd.paos.xml": { - "source": "apache" - }, - "application/vnd.pawaafile": { - "source": "iana", - "extensions": ["paw"] - }, - "application/vnd.pcos": { - "source": "iana" - }, - "application/vnd.pg.format": { - "source": "iana", - "extensions": ["str"] - }, - "application/vnd.pg.osasli": { - "source": "iana", - "extensions": ["ei6"] - }, - "application/vnd.piaccess.application-licence": { - "source": "iana" - }, - "application/vnd.picsel": { - "source": "iana", - "extensions": ["efif"] - }, - "application/vnd.pmi.widget": { - "source": "iana", - "extensions": ["wg"] - }, - "application/vnd.poc.group-advertisement+xml": { - "source": "iana" - }, - "application/vnd.pocketlearn": { - "source": "iana", - "extensions": ["plf"] - }, - "application/vnd.powerbuilder6": { - "source": "iana", - "extensions": ["pbd"] - }, - "application/vnd.powerbuilder6-s": { - "source": "iana" - }, - "application/vnd.powerbuilder7": { - "source": "iana" - }, - "application/vnd.powerbuilder7-s": { - "source": "iana" - }, - "application/vnd.powerbuilder75": { - "source": "iana" - }, - "application/vnd.powerbuilder75-s": { - "source": "iana" - }, - "application/vnd.preminet": { - "source": "iana" - }, - "application/vnd.previewsystems.box": { - "source": "iana", - "extensions": ["box"] - }, - "application/vnd.proteus.magazine": { - "source": "iana", - "extensions": ["mgz"] - }, - "application/vnd.publishare-delta-tree": { - "source": "iana", - "extensions": ["qps"] - }, - "application/vnd.pvi.ptid1": { - "source": "iana", - "extensions": ["ptid"] - }, - "application/vnd.pwg-multiplexed": { - "source": "iana" - }, - "application/vnd.pwg-xhtml-print+xml": { - "source": "iana" - }, - "application/vnd.qualcomm.brew-app-res": { - "source": "iana" - }, - "application/vnd.quark.quarkxpress": { - "source": "iana", - "extensions": ["qxd","qxt","qwd","qwt","qxl","qxb"] - }, - "application/vnd.quobject-quoxdocument": { - "source": "iana" - }, - "application/vnd.radisys.moml+xml": { - "source": "iana" - }, - "application/vnd.radisys.msml+xml": { - "source": "iana" - }, - "application/vnd.radisys.msml-audit+xml": { - "source": "iana" - }, - "application/vnd.radisys.msml-audit-conf+xml": { - "source": "iana" - }, - "application/vnd.radisys.msml-audit-conn+xml": { - "source": "iana" - }, - "application/vnd.radisys.msml-audit-dialog+xml": { - "source": "iana" - }, - "application/vnd.radisys.msml-audit-stream+xml": { - "source": "iana" - }, - "application/vnd.radisys.msml-conf+xml": { - "source": "iana" - }, - "application/vnd.radisys.msml-dialog+xml": { - "source": "iana" - }, - "application/vnd.radisys.msml-dialog-base+xml": { - "source": "iana" - }, - "application/vnd.radisys.msml-dialog-fax-detect+xml": { - "source": "iana" - }, - "application/vnd.radisys.msml-dialog-fax-sendrecv+xml": { - "source": "iana" - }, - "application/vnd.radisys.msml-dialog-group+xml": { - "source": "iana" - }, - "application/vnd.radisys.msml-dialog-speech+xml": { - "source": "iana" - }, - "application/vnd.radisys.msml-dialog-transform+xml": { - "source": "iana" - }, - "application/vnd.rainstor.data": { - "source": "iana" - }, - "application/vnd.rapid": { - "source": "iana" - }, - "application/vnd.realvnc.bed": { - "source": "iana", - "extensions": ["bed"] - }, - "application/vnd.recordare.musicxml": { - "source": "iana", - "extensions": ["mxl"] - }, - "application/vnd.recordare.musicxml+xml": { - "source": "iana", - "extensions": ["musicxml"] - }, - "application/vnd.renlearn.rlprint": { - "source": "iana" - }, - "application/vnd.rig.cryptonote": { - "source": "iana", - "extensions": ["cryptonote"] - }, - "application/vnd.rim.cod": { - "source": "apache", - "extensions": ["cod"] - }, - "application/vnd.rn-realmedia": { - "source": "apache", - "extensions": ["rm"] - }, - "application/vnd.rn-realmedia-vbr": { - "source": "apache", - "extensions": ["rmvb"] - }, - "application/vnd.route66.link66+xml": { - "source": "iana", - "extensions": ["link66"] - }, - "application/vnd.rs-274x": { - "source": "iana" - }, - "application/vnd.ruckus.download": { - "source": "iana" - }, - "application/vnd.s3sms": { - "source": "iana" - }, - "application/vnd.sailingtracker.track": { - "source": "iana", - "extensions": ["st"] - }, - "application/vnd.sbm.cid": { - "source": "iana" - }, - "application/vnd.sbm.mid2": { - "source": "iana" - }, - "application/vnd.scribus": { - "source": "iana" - }, - "application/vnd.sealed.3df": { - "source": "iana" - }, - "application/vnd.sealed.csf": { - "source": "iana" - }, - "application/vnd.sealed.doc": { - "source": "iana" - }, - "application/vnd.sealed.eml": { - "source": "iana" - }, - "application/vnd.sealed.mht": { - "source": "iana" - }, - "application/vnd.sealed.net": { - "source": "iana" - }, - "application/vnd.sealed.ppt": { - "source": "iana" - }, - "application/vnd.sealed.tiff": { - "source": "iana" - }, - "application/vnd.sealed.xls": { - "source": "iana" - }, - "application/vnd.sealedmedia.softseal.html": { - "source": "iana" - }, - "application/vnd.sealedmedia.softseal.pdf": { - "source": "iana" - }, - "application/vnd.seemail": { - "source": "iana", - "extensions": ["see"] - }, - "application/vnd.sema": { - "source": "iana", - "extensions": ["sema"] - }, - "application/vnd.semd": { - "source": "iana", - "extensions": ["semd"] - }, - "application/vnd.semf": { - "source": "iana", - "extensions": ["semf"] - }, - "application/vnd.shana.informed.formdata": { - "source": "iana", - "extensions": ["ifm"] - }, - "application/vnd.shana.informed.formtemplate": { - "source": "iana", - "extensions": ["itp"] - }, - "application/vnd.shana.informed.interchange": { - "source": "iana", - "extensions": ["iif"] - }, - "application/vnd.shana.informed.package": { - "source": "iana", - "extensions": ["ipk"] - }, - "application/vnd.simtech-mindmapper": { - "source": "iana", - "extensions": ["twd","twds"] - }, - "application/vnd.siren+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.smaf": { - "source": "iana", - "extensions": ["mmf"] - }, - "application/vnd.smart.notebook": { - "source": "iana" - }, - "application/vnd.smart.teacher": { - "source": "iana", - "extensions": ["teacher"] - }, - "application/vnd.software602.filler.form+xml": { - "source": "iana" - }, - "application/vnd.software602.filler.form-xml-zip": { - "source": "iana" - }, - "application/vnd.solent.sdkm+xml": { - "source": "iana", - "extensions": ["sdkm","sdkd"] - }, - "application/vnd.spotfire.dxp": { - "source": "iana", - "extensions": ["dxp"] - }, - "application/vnd.spotfire.sfs": { - "source": "iana", - "extensions": ["sfs"] - }, - "application/vnd.sss-cod": { - "source": "iana" - }, - "application/vnd.sss-dtf": { - "source": "iana" - }, - "application/vnd.sss-ntf": { - "source": "iana" - }, - "application/vnd.stardivision.calc": { - "source": "apache", - "extensions": ["sdc"] - }, - "application/vnd.stardivision.draw": { - "source": "apache", - "extensions": ["sda"] - }, - "application/vnd.stardivision.impress": { - "source": "apache", - "extensions": ["sdd"] - }, - "application/vnd.stardivision.math": { - "source": "apache", - "extensions": ["smf"] - }, - "application/vnd.stardivision.writer": { - "source": "apache", - "extensions": ["sdw","vor"] - }, - "application/vnd.stardivision.writer-global": { - "source": "apache", - "extensions": ["sgl"] - }, - "application/vnd.stepmania.package": { - "source": "iana", - "extensions": ["smzip"] - }, - "application/vnd.stepmania.stepchart": { - "source": "iana", - "extensions": ["sm"] - }, - "application/vnd.street-stream": { - "source": "iana" - }, - "application/vnd.sun.wadl+xml": { - "source": "iana" - }, - "application/vnd.sun.xml.calc": { - "source": "apache", - "extensions": ["sxc"] - }, - "application/vnd.sun.xml.calc.template": { - "source": "apache", - "extensions": ["stc"] - }, - "application/vnd.sun.xml.draw": { - "source": "apache", - "extensions": ["sxd"] - }, - "application/vnd.sun.xml.draw.template": { - "source": "apache", - "extensions": ["std"] - }, - "application/vnd.sun.xml.impress": { - "source": "apache", - "extensions": ["sxi"] - }, - "application/vnd.sun.xml.impress.template": { - "source": "apache", - "extensions": ["sti"] - }, - "application/vnd.sun.xml.math": { - "source": "apache", - "extensions": ["sxm"] - }, - "application/vnd.sun.xml.writer": { - "source": "apache", - "extensions": ["sxw"] - }, - "application/vnd.sun.xml.writer.global": { - "source": "apache", - "extensions": ["sxg"] - }, - "application/vnd.sun.xml.writer.template": { - "source": "apache", - "extensions": ["stw"] - }, - "application/vnd.sus-calendar": { - "source": "iana", - "extensions": ["sus","susp"] - }, - "application/vnd.svd": { - "source": "iana", - "extensions": ["svd"] - }, - "application/vnd.swiftview-ics": { - "source": "iana" - }, - "application/vnd.symbian.install": { - "source": "apache", - "extensions": ["sis","sisx"] - }, - "application/vnd.syncml+xml": { - "source": "iana", - "extensions": ["xsm"] - }, - "application/vnd.syncml.dm+wbxml": { - "source": "iana", - "extensions": ["bdm"] - }, - "application/vnd.syncml.dm+xml": { - "source": "iana", - "extensions": ["xdm"] - }, - "application/vnd.syncml.dm.notification": { - "source": "iana" - }, - "application/vnd.syncml.dmddf+wbxml": { - "source": "iana" - }, - "application/vnd.syncml.dmddf+xml": { - "source": "iana" - }, - "application/vnd.syncml.dmtnds+wbxml": { - "source": "iana" - }, - "application/vnd.syncml.dmtnds+xml": { - "source": "iana" - }, - "application/vnd.syncml.ds.notification": { - "source": "iana" - }, - "application/vnd.tao.intent-module-archive": { - "source": "iana", - "extensions": ["tao"] - }, - "application/vnd.tcpdump.pcap": { - "source": "iana", - "extensions": ["pcap","cap","dmp"] - }, - "application/vnd.tmd.mediaflex.api+xml": { - "source": "iana" - }, - "application/vnd.tml": { - "source": "iana" - }, - "application/vnd.tmobile-livetv": { - "source": "iana", - "extensions": ["tmo"] - }, - "application/vnd.trid.tpt": { - "source": "iana", - "extensions": ["tpt"] - }, - "application/vnd.triscape.mxs": { - "source": "iana", - "extensions": ["mxs"] - }, - "application/vnd.trueapp": { - "source": "iana", - "extensions": ["tra"] - }, - "application/vnd.truedoc": { - "source": "iana" - }, - "application/vnd.ubisoft.webplayer": { - "source": "iana" - }, - "application/vnd.ufdl": { - "source": "iana", - "extensions": ["ufd","ufdl"] - }, - "application/vnd.uiq.theme": { - "source": "iana", - "extensions": ["utz"] - }, - "application/vnd.umajin": { - "source": "iana", - "extensions": ["umj"] - }, - "application/vnd.unity": { - "source": "iana", - "extensions": ["unityweb"] - }, - "application/vnd.uoml+xml": { - "source": "iana", - "extensions": ["uoml"] - }, - "application/vnd.uplanet.alert": { - "source": "iana" - }, - "application/vnd.uplanet.alert-wbxml": { - "source": "iana" - }, - "application/vnd.uplanet.bearer-choice": { - "source": "iana" - }, - "application/vnd.uplanet.bearer-choice-wbxml": { - "source": "iana" - }, - "application/vnd.uplanet.cacheop": { - "source": "iana" - }, - "application/vnd.uplanet.cacheop-wbxml": { - "source": "iana" - }, - "application/vnd.uplanet.channel": { - "source": "iana" - }, - "application/vnd.uplanet.channel-wbxml": { - "source": "iana" - }, - "application/vnd.uplanet.list": { - "source": "iana" - }, - "application/vnd.uplanet.list-wbxml": { - "source": "iana" - }, - "application/vnd.uplanet.listcmd": { - "source": "iana" - }, - "application/vnd.uplanet.listcmd-wbxml": { - "source": "iana" - }, - "application/vnd.uplanet.signal": { - "source": "iana" - }, - "application/vnd.uri-map": { - "source": "iana" - }, - "application/vnd.valve.source.material": { - "source": "iana" - }, - "application/vnd.vcx": { - "source": "iana", - "extensions": ["vcx"] - }, - "application/vnd.vd-study": { - "source": "iana" - }, - "application/vnd.vectorworks": { - "source": "iana" - }, - "application/vnd.vel+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.verimatrix.vcas": { - "source": "iana" - }, - "application/vnd.vidsoft.vidconference": { - "source": "iana" - }, - "application/vnd.visio": { - "source": "iana", - "extensions": ["vsd","vst","vss","vsw"] - }, - "application/vnd.visionary": { - "source": "iana", - "extensions": ["vis"] - }, - "application/vnd.vividence.scriptfile": { - "source": "iana" - }, - "application/vnd.vsf": { - "source": "iana", - "extensions": ["vsf"] - }, - "application/vnd.wap.sic": { - "source": "iana" - }, - "application/vnd.wap.slc": { - "source": "iana" - }, - "application/vnd.wap.wbxml": { - "source": "iana", - "extensions": ["wbxml"] - }, - "application/vnd.wap.wmlc": { - "source": "iana", - "extensions": ["wmlc"] - }, - "application/vnd.wap.wmlscriptc": { - "source": "iana", - "extensions": ["wmlsc"] - }, - "application/vnd.webturbo": { - "source": "iana", - "extensions": ["wtb"] - }, - "application/vnd.wfa.p2p": { - "source": "iana" - }, - "application/vnd.wfa.wsc": { - "source": "iana" - }, - "application/vnd.windows.devicepairing": { - "source": "iana" - }, - "application/vnd.wmc": { - "source": "iana" - }, - "application/vnd.wmf.bootstrap": { - "source": "iana" - }, - "application/vnd.wolfram.mathematica": { - "source": "iana" - }, - "application/vnd.wolfram.mathematica.package": { - "source": "iana" - }, - "application/vnd.wolfram.player": { - "source": "iana", - "extensions": ["nbp"] - }, - "application/vnd.wordperfect": { - "source": "iana", - "extensions": ["wpd"] - }, - "application/vnd.wqd": { - "source": "iana", - "extensions": ["wqd"] - }, - "application/vnd.wrq-hp3000-labelled": { - "source": "iana" - }, - "application/vnd.wt.stf": { - "source": "iana", - "extensions": ["stf"] - }, - "application/vnd.wv.csp+wbxml": { - "source": "iana" - }, - "application/vnd.wv.csp+xml": { - "source": "iana" - }, - "application/vnd.wv.ssp+xml": { - "source": "iana" - }, - "application/vnd.xacml+json": { - "source": "iana", - "compressible": true - }, - "application/vnd.xara": { - "source": "iana", - "extensions": ["xar"] - }, - "application/vnd.xfdl": { - "source": "iana", - "extensions": ["xfdl"] - }, - "application/vnd.xfdl.webform": { - "source": "iana" - }, - "application/vnd.xmi+xml": { - "source": "iana" - }, - "application/vnd.xmpie.cpkg": { - "source": "iana" - }, - "application/vnd.xmpie.dpkg": { - "source": "iana" - }, - "application/vnd.xmpie.plan": { - "source": "iana" - }, - "application/vnd.xmpie.ppkg": { - "source": "iana" - }, - "application/vnd.xmpie.xlim": { - "source": "iana" - }, - "application/vnd.yamaha.hv-dic": { - "source": "iana", - "extensions": ["hvd"] - }, - "application/vnd.yamaha.hv-script": { - "source": "iana", - "extensions": ["hvs"] - }, - "application/vnd.yamaha.hv-voice": { - "source": "iana", - "extensions": ["hvp"] - }, - "application/vnd.yamaha.openscoreformat": { - "source": "iana", - "extensions": ["osf"] - }, - "application/vnd.yamaha.openscoreformat.osfpvg+xml": { - "source": "iana", - "extensions": ["osfpvg"] - }, - "application/vnd.yamaha.remote-setup": { - "source": "iana" - }, - "application/vnd.yamaha.smaf-audio": { - "source": "iana", - "extensions": ["saf"] - }, - "application/vnd.yamaha.smaf-phrase": { - "source": "iana", - "extensions": ["spf"] - }, - "application/vnd.yamaha.through-ngn": { - "source": "iana" - }, - "application/vnd.yamaha.tunnel-udpencap": { - "source": "iana" - }, - "application/vnd.yaoweme": { - "source": "iana" - }, - "application/vnd.yellowriver-custom-menu": { - "source": "iana", - "extensions": ["cmp"] - }, - "application/vnd.zul": { - "source": "iana", - "extensions": ["zir","zirz"] - }, - "application/vnd.zzazz.deck+xml": { - "source": "iana", - "extensions": ["zaz"] - }, - "application/voicexml+xml": { - "source": "iana", - "extensions": ["vxml"] - }, - "application/vq-rtcpxr": { - "source": "iana" - }, - "application/watcherinfo+xml": { - "source": "iana" - }, - "application/whoispp-query": { - "source": "iana" - }, - "application/whoispp-response": { - "source": "iana" - }, - "application/widget": { - "source": "iana", - "extensions": ["wgt"] - }, - "application/winhlp": { - "source": "apache", - "extensions": ["hlp"] - }, - "application/wita": { - "source": "iana" - }, - "application/wordperfect5.1": { - "source": "iana" - }, - "application/wsdl+xml": { - "source": "iana", - "extensions": ["wsdl"] - }, - "application/wspolicy+xml": { - "source": "iana", - "extensions": ["wspolicy"] - }, - "application/x-7z-compressed": { - "source": "apache", - "compressible": false, - "extensions": ["7z"] - }, - "application/x-abiword": { - "source": "apache", - "extensions": ["abw"] - }, - "application/x-ace-compressed": { - "source": "apache", - "extensions": ["ace"] - }, - "application/x-amf": { - "source": "apache" - }, - "application/x-apple-diskimage": { - "source": "apache", - "extensions": ["dmg"] - }, - "application/x-authorware-bin": { - "source": "apache", - "extensions": ["aab","x32","u32","vox"] - }, - "application/x-authorware-map": { - "source": "apache", - "extensions": ["aam"] - }, - "application/x-authorware-seg": { - "source": "apache", - "extensions": ["aas"] - }, - "application/x-bcpio": { - "source": "apache", - "extensions": ["bcpio"] - }, - "application/x-bdoc": { - "compressible": false, - "extensions": ["bdoc"] - }, - "application/x-bittorrent": { - "source": "apache", - "extensions": ["torrent"] - }, - "application/x-blorb": { - "source": "apache", - "extensions": ["blb","blorb"] - }, - "application/x-bzip": { - "source": "apache", - "compressible": false, - "extensions": ["bz"] - }, - "application/x-bzip2": { - "source": "apache", - "compressible": false, - "extensions": ["bz2","boz"] - }, - "application/x-cbr": { - "source": "apache", - "extensions": ["cbr","cba","cbt","cbz","cb7"] - }, - "application/x-cdlink": { - "source": "apache", - "extensions": ["vcd"] - }, - "application/x-cfs-compressed": { - "source": "apache", - "extensions": ["cfs"] - }, - "application/x-chat": { - "source": "apache", - "extensions": ["chat"] - }, - "application/x-chess-pgn": { - "source": "apache", - "extensions": ["pgn"] - }, - "application/x-chrome-extension": { - "extensions": ["crx"] - }, - "application/x-cocoa": { - "source": "nginx", - "extensions": ["cco"] - }, - "application/x-compress": { - "source": "apache" - }, - "application/x-conference": { - "source": "apache", - "extensions": ["nsc"] - }, - "application/x-cpio": { - "source": "apache", - "extensions": ["cpio"] - }, - "application/x-csh": { - "source": "apache", - "extensions": ["csh"] - }, - "application/x-deb": { - "compressible": false - }, - "application/x-debian-package": { - "source": "apache", - "extensions": ["deb","udeb"] - }, - "application/x-dgc-compressed": { - "source": "apache", - "extensions": ["dgc"] - }, - "application/x-director": { - "source": "apache", - "extensions": ["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"] - }, - "application/x-doom": { - "source": "apache", - "extensions": ["wad"] - }, - "application/x-dtbncx+xml": { - "source": "apache", - "extensions": ["ncx"] - }, - "application/x-dtbook+xml": { - "source": "apache", - "extensions": ["dtb"] - }, - "application/x-dtbresource+xml": { - "source": "apache", - "extensions": ["res"] - }, - "application/x-dvi": { - "source": "apache", - "compressible": false, - "extensions": ["dvi"] - }, - "application/x-envoy": { - "source": "apache", - "extensions": ["evy"] - }, - "application/x-eva": { - "source": "apache", - "extensions": ["eva"] - }, - "application/x-font-bdf": { - "source": "apache", - "extensions": ["bdf"] - }, - "application/x-font-dos": { - "source": "apache" - }, - "application/x-font-framemaker": { - "source": "apache" - }, - "application/x-font-ghostscript": { - "source": "apache", - "extensions": ["gsf"] - }, - "application/x-font-libgrx": { - "source": "apache" - }, - "application/x-font-linux-psf": { - "source": "apache", - "extensions": ["psf"] - }, - "application/x-font-otf": { - "source": "apache", - "compressible": true, - "extensions": ["otf"] - }, - "application/x-font-pcf": { - "source": "apache", - "extensions": ["pcf"] - }, - "application/x-font-snf": { - "source": "apache", - "extensions": ["snf"] - }, - "application/x-font-speedo": { - "source": "apache" - }, - "application/x-font-sunos-news": { - "source": "apache" - }, - "application/x-font-ttf": { - "source": "apache", - "compressible": true, - "extensions": ["ttf","ttc"] - }, - "application/x-font-type1": { - "source": "apache", - "extensions": ["pfa","pfb","pfm","afm"] - }, - "application/x-font-vfont": { - "source": "apache" - }, - "application/x-freearc": { - "source": "apache", - "extensions": ["arc"] - }, - "application/x-futuresplash": { - "source": "apache", - "extensions": ["spl"] - }, - "application/x-gca-compressed": { - "source": "apache", - "extensions": ["gca"] - }, - "application/x-glulx": { - "source": "apache", - "extensions": ["ulx"] - }, - "application/x-gnumeric": { - "source": "apache", - "extensions": ["gnumeric"] - }, - "application/x-gramps-xml": { - "source": "apache", - "extensions": ["gramps"] - }, - "application/x-gtar": { - "source": "apache", - "extensions": ["gtar"] - }, - "application/x-gzip": { - "source": "apache" - }, - "application/x-hdf": { - "source": "apache", - "extensions": ["hdf"] - }, - "application/x-httpd-php": { - "compressible": true, - "extensions": ["php"] - }, - "application/x-install-instructions": { - "source": "apache", - "extensions": ["install"] - }, - "application/x-iso9660-image": { - "source": "apache", - "extensions": ["iso"] - }, - "application/x-java-archive-diff": { - "source": "nginx", - "extensions": ["jardiff"] - }, - "application/x-java-jnlp-file": { - "source": "apache", - "compressible": false, - "extensions": ["jnlp"] - }, - "application/x-javascript": { - "compressible": true - }, - "application/x-latex": { - "source": "apache", - "compressible": false, - "extensions": ["latex"] - }, - "application/x-lua-bytecode": { - "extensions": ["luac"] - }, - "application/x-lzh-compressed": { - "source": "apache", - "extensions": ["lzh","lha"] - }, - "application/x-makeself": { - "source": "nginx", - "extensions": ["run"] - }, - "application/x-mie": { - "source": "apache", - "extensions": ["mie"] - }, - "application/x-mobipocket-ebook": { - "source": "apache", - "extensions": ["prc","mobi"] - }, - "application/x-mpegurl": { - "compressible": false - }, - "application/x-ms-application": { - "source": "apache", - "extensions": ["application"] - }, - "application/x-ms-shortcut": { - "source": "apache", - "extensions": ["lnk"] - }, - "application/x-ms-wmd": { - "source": "apache", - "extensions": ["wmd"] - }, - "application/x-ms-wmz": { - "source": "apache", - "extensions": ["wmz"] - }, - "application/x-ms-xbap": { - "source": "apache", - "extensions": ["xbap"] - }, - "application/x-msaccess": { - "source": "apache", - "extensions": ["mdb"] - }, - "application/x-msbinder": { - "source": "apache", - "extensions": ["obd"] - }, - "application/x-mscardfile": { - "source": "apache", - "extensions": ["crd"] - }, - "application/x-msclip": { - "source": "apache", - "extensions": ["clp"] - }, - "application/x-msdos-program": { - "extensions": ["exe"] - }, - "application/x-msdownload": { - "source": "apache", - "extensions": ["exe","dll","com","bat","msi"] - }, - "application/x-msmediaview": { - "source": "apache", - "extensions": ["mvb","m13","m14"] - }, - "application/x-msmetafile": { - "source": "apache", - "extensions": ["wmf","wmz","emf","emz"] - }, - "application/x-msmoney": { - "source": "apache", - "extensions": ["mny"] - }, - "application/x-mspublisher": { - "source": "apache", - "extensions": ["pub"] - }, - "application/x-msschedule": { - "source": "apache", - "extensions": ["scd"] - }, - "application/x-msterminal": { - "source": "apache", - "extensions": ["trm"] - }, - "application/x-mswrite": { - "source": "apache", - "extensions": ["wri"] - }, - "application/x-netcdf": { - "source": "apache", - "extensions": ["nc","cdf"] - }, - "application/x-ns-proxy-autoconfig": { - "compressible": true, - "extensions": ["pac"] - }, - "application/x-nzb": { - "source": "apache", - "extensions": ["nzb"] - }, - "application/x-perl": { - "source": "nginx", - "extensions": ["pl","pm"] - }, - "application/x-pilot": { - "source": "nginx", - "extensions": ["prc","pdb"] - }, - "application/x-pkcs12": { - "source": "apache", - "compressible": false, - "extensions": ["p12","pfx"] - }, - "application/x-pkcs7-certificates": { - "source": "apache", - "extensions": ["p7b","spc"] - }, - "application/x-pkcs7-certreqresp": { - "source": "apache", - "extensions": ["p7r"] - }, - "application/x-rar-compressed": { - "source": "apache", - "compressible": false, - "extensions": ["rar"] - }, - "application/x-redhat-package-manager": { - "source": "nginx", - "extensions": ["rpm"] - }, - "application/x-research-info-systems": { - "source": "apache", - "extensions": ["ris"] - }, - "application/x-sea": { - "source": "nginx", - "extensions": ["sea"] - }, - "application/x-sh": { - "source": "apache", - "compressible": true, - "extensions": ["sh"] - }, - "application/x-shar": { - "source": "apache", - "extensions": ["shar"] - }, - "application/x-shockwave-flash": { - "source": "apache", - "compressible": false, - "extensions": ["swf"] - }, - "application/x-silverlight-app": { - "source": "apache", - "extensions": ["xap"] - }, - "application/x-sql": { - "source": "apache", - "extensions": ["sql"] - }, - "application/x-stuffit": { - "source": "apache", - "compressible": false, - "extensions": ["sit"] - }, - "application/x-stuffitx": { - "source": "apache", - "extensions": ["sitx"] - }, - "application/x-subrip": { - "source": "apache", - "extensions": ["srt"] - }, - "application/x-sv4cpio": { - "source": "apache", - "extensions": ["sv4cpio"] - }, - "application/x-sv4crc": { - "source": "apache", - "extensions": ["sv4crc"] - }, - "application/x-t3vm-image": { - "source": "apache", - "extensions": ["t3"] - }, - "application/x-tads": { - "source": "apache", - "extensions": ["gam"] - }, - "application/x-tar": { - "source": "apache", - "compressible": true, - "extensions": ["tar"] - }, - "application/x-tcl": { - "source": "apache", - "extensions": ["tcl","tk"] - }, - "application/x-tex": { - "source": "apache", - "extensions": ["tex"] - }, - "application/x-tex-tfm": { - "source": "apache", - "extensions": ["tfm"] - }, - "application/x-texinfo": { - "source": "apache", - "extensions": ["texinfo","texi"] - }, - "application/x-tgif": { - "source": "apache", - "extensions": ["obj"] - }, - "application/x-ustar": { - "source": "apache", - "extensions": ["ustar"] - }, - "application/x-wais-source": { - "source": "apache", - "extensions": ["src"] - }, - "application/x-web-app-manifest+json": { - "compressible": true, - "extensions": ["webapp"] - }, - "application/x-www-form-urlencoded": { - "source": "iana", - "compressible": true - }, - "application/x-x509-ca-cert": { - "source": "apache", - "extensions": ["der","crt","pem"] - }, - "application/x-xfig": { - "source": "apache", - "extensions": ["fig"] - }, - "application/x-xliff+xml": { - "source": "apache", - "extensions": ["xlf"] - }, - "application/x-xpinstall": { - "source": "apache", - "compressible": false, - "extensions": ["xpi"] - }, - "application/x-xz": { - "source": "apache", - "extensions": ["xz"] - }, - "application/x-zmachine": { - "source": "apache", - "extensions": ["z1","z2","z3","z4","z5","z6","z7","z8"] - }, - "application/x400-bp": { - "source": "iana" - }, - "application/xacml+xml": { - "source": "iana" - }, - "application/xaml+xml": { - "source": "apache", - "extensions": ["xaml"] - }, - "application/xcap-att+xml": { - "source": "iana" - }, - "application/xcap-caps+xml": { - "source": "iana" - }, - "application/xcap-diff+xml": { - "source": "iana", - "extensions": ["xdf"] - }, - "application/xcap-el+xml": { - "source": "iana" - }, - "application/xcap-error+xml": { - "source": "iana" - }, - "application/xcap-ns+xml": { - "source": "iana" - }, - "application/xcon-conference-info+xml": { - "source": "iana" - }, - "application/xcon-conference-info-diff+xml": { - "source": "iana" - }, - "application/xenc+xml": { - "source": "iana", - "extensions": ["xenc"] - }, - "application/xhtml+xml": { - "source": "iana", - "compressible": true, - "extensions": ["xhtml","xht"] - }, - "application/xhtml-voice+xml": { - "source": "apache" - }, - "application/xml": { - "source": "iana", - "compressible": true, - "extensions": ["xml","xsl","xsd","rng"] - }, - "application/xml-dtd": { - "source": "iana", - "compressible": true, - "extensions": ["dtd"] - }, - "application/xml-external-parsed-entity": { - "source": "iana" - }, - "application/xml-patch+xml": { - "source": "iana" - }, - "application/xmpp+xml": { - "source": "iana" - }, - "application/xop+xml": { - "source": "iana", - "compressible": true, - "extensions": ["xop"] - }, - "application/xproc+xml": { - "source": "apache", - "extensions": ["xpl"] - }, - "application/xslt+xml": { - "source": "iana", - "extensions": ["xslt"] - }, - "application/xspf+xml": { - "source": "apache", - "extensions": ["xspf"] - }, - "application/xv+xml": { - "source": "iana", - "extensions": ["mxml","xhvml","xvml","xvm"] - }, - "application/yang": { - "source": "iana", - "extensions": ["yang"] - }, - "application/yin+xml": { - "source": "iana", - "extensions": ["yin"] - }, - "application/zip": { - "source": "iana", - "compressible": false, - "extensions": ["zip"] - }, - "application/zlib": { - "source": "iana" - }, - "audio/1d-interleaved-parityfec": { - "source": "iana" - }, - "audio/32kadpcm": { - "source": "iana" - }, - "audio/3gpp": { - "source": "iana", - "compressible": false, - "extensions": ["3gpp"] - }, - "audio/3gpp2": { - "source": "iana" - }, - "audio/ac3": { - "source": "iana" - }, - "audio/adpcm": { - "source": "apache", - "extensions": ["adp"] - }, - "audio/amr": { - "source": "iana" - }, - "audio/amr-wb": { - "source": "iana" - }, - "audio/amr-wb+": { - "source": "iana" - }, - "audio/aptx": { - "source": "iana" - }, - "audio/asc": { - "source": "iana" - }, - "audio/atrac-advanced-lossless": { - "source": "iana" - }, - "audio/atrac-x": { - "source": "iana" - }, - "audio/atrac3": { - "source": "iana" - }, - "audio/basic": { - "source": "iana", - "compressible": false, - "extensions": ["au","snd"] - }, - "audio/bv16": { - "source": "iana" - }, - "audio/bv32": { - "source": "iana" - }, - "audio/clearmode": { - "source": "iana" - }, - "audio/cn": { - "source": "iana" - }, - "audio/dat12": { - "source": "iana" - }, - "audio/dls": { - "source": "iana" - }, - "audio/dsr-es201108": { - "source": "iana" - }, - "audio/dsr-es202050": { - "source": "iana" - }, - "audio/dsr-es202211": { - "source": "iana" - }, - "audio/dsr-es202212": { - "source": "iana" - }, - "audio/dv": { - "source": "iana" - }, - "audio/dvi4": { - "source": "iana" - }, - "audio/eac3": { - "source": "iana" - }, - "audio/encaprtp": { - "source": "iana" - }, - "audio/evrc": { - "source": "iana" - }, - "audio/evrc-qcp": { - "source": "iana" - }, - "audio/evrc0": { - "source": "iana" - }, - "audio/evrc1": { - "source": "iana" - }, - "audio/evrcb": { - "source": "iana" - }, - "audio/evrcb0": { - "source": "iana" - }, - "audio/evrcb1": { - "source": "iana" - }, - "audio/evrcnw": { - "source": "iana" - }, - "audio/evrcnw0": { - "source": "iana" - }, - "audio/evrcnw1": { - "source": "iana" - }, - "audio/evrcwb": { - "source": "iana" - }, - "audio/evrcwb0": { - "source": "iana" - }, - "audio/evrcwb1": { - "source": "iana" - }, - "audio/evs": { - "source": "iana" - }, - "audio/fwdred": { - "source": "iana" - }, - "audio/g711-0": { - "source": "iana" - }, - "audio/g719": { - "source": "iana" - }, - "audio/g722": { - "source": "iana" - }, - "audio/g7221": { - "source": "iana" - }, - "audio/g723": { - "source": "iana" - }, - "audio/g726-16": { - "source": "iana" - }, - "audio/g726-24": { - "source": "iana" - }, - "audio/g726-32": { - "source": "iana" - }, - "audio/g726-40": { - "source": "iana" - }, - "audio/g728": { - "source": "iana" - }, - "audio/g729": { - "source": "iana" - }, - "audio/g7291": { - "source": "iana" - }, - "audio/g729d": { - "source": "iana" - }, - "audio/g729e": { - "source": "iana" - }, - "audio/gsm": { - "source": "iana" - }, - "audio/gsm-efr": { - "source": "iana" - }, - "audio/gsm-hr-08": { - "source": "iana" - }, - "audio/ilbc": { - "source": "iana" - }, - "audio/ip-mr_v2.5": { - "source": "iana" - }, - "audio/isac": { - "source": "apache" - }, - "audio/l16": { - "source": "iana" - }, - "audio/l20": { - "source": "iana" - }, - "audio/l24": { - "source": "iana", - "compressible": false - }, - "audio/l8": { - "source": "iana" - }, - "audio/lpc": { - "source": "iana" - }, - "audio/midi": { - "source": "apache", - "extensions": ["mid","midi","kar","rmi"] - }, - "audio/mobile-xmf": { - "source": "iana" - }, - "audio/mp4": { - "source": "iana", - "compressible": false, - "extensions": ["m4a","mp4a"] - }, - "audio/mp4a-latm": { - "source": "iana" - }, - "audio/mpa": { - "source": "iana" - }, - "audio/mpa-robust": { - "source": "iana" - }, - "audio/mpeg": { - "source": "iana", - "compressible": false, - "extensions": ["mpga","mp2","mp2a","mp3","m2a","m3a"] - }, - "audio/mpeg4-generic": { - "source": "iana" - }, - "audio/musepack": { - "source": "apache" - }, - "audio/ogg": { - "source": "iana", - "compressible": false, - "extensions": ["oga","ogg","spx"] - }, - "audio/opus": { - "source": "iana" - }, - "audio/parityfec": { - "source": "iana" - }, - "audio/pcma": { - "source": "iana" - }, - "audio/pcma-wb": { - "source": "iana" - }, - "audio/pcmu": { - "source": "iana" - }, - "audio/pcmu-wb": { - "source": "iana" - }, - "audio/prs.sid": { - "source": "iana" - }, - "audio/qcelp": { - "source": "iana" - }, - "audio/raptorfec": { - "source": "iana" - }, - "audio/red": { - "source": "iana" - }, - "audio/rtp-enc-aescm128": { - "source": "iana" - }, - "audio/rtp-midi": { - "source": "iana" - }, - "audio/rtploopback": { - "source": "iana" - }, - "audio/rtx": { - "source": "iana" - }, - "audio/s3m": { - "source": "apache", - "extensions": ["s3m"] - }, - "audio/silk": { - "source": "apache", - "extensions": ["sil"] - }, - "audio/smv": { - "source": "iana" - }, - "audio/smv-qcp": { - "source": "iana" - }, - "audio/smv0": { - "source": "iana" - }, - "audio/sp-midi": { - "source": "iana" - }, - "audio/speex": { - "source": "iana" - }, - "audio/t140c": { - "source": "iana" - }, - "audio/t38": { - "source": "iana" - }, - "audio/telephone-event": { - "source": "iana" - }, - "audio/tone": { - "source": "iana" - }, - "audio/uemclip": { - "source": "iana" - }, - "audio/ulpfec": { - "source": "iana" - }, - "audio/vdvi": { - "source": "iana" - }, - "audio/vmr-wb": { - "source": "iana" - }, - "audio/vnd.3gpp.iufp": { - "source": "iana" - }, - "audio/vnd.4sb": { - "source": "iana" - }, - "audio/vnd.audiokoz": { - "source": "iana" - }, - "audio/vnd.celp": { - "source": "iana" - }, - "audio/vnd.cisco.nse": { - "source": "iana" - }, - "audio/vnd.cmles.radio-events": { - "source": "iana" - }, - "audio/vnd.cns.anp1": { - "source": "iana" - }, - "audio/vnd.cns.inf1": { - "source": "iana" - }, - "audio/vnd.dece.audio": { - "source": "iana", - "extensions": ["uva","uvva"] - }, - "audio/vnd.digital-winds": { - "source": "iana", - "extensions": ["eol"] - }, - "audio/vnd.dlna.adts": { - "source": "iana" - }, - "audio/vnd.dolby.heaac.1": { - "source": "iana" - }, - "audio/vnd.dolby.heaac.2": { - "source": "iana" - }, - "audio/vnd.dolby.mlp": { - "source": "iana" - }, - "audio/vnd.dolby.mps": { - "source": "iana" - }, - "audio/vnd.dolby.pl2": { - "source": "iana" - }, - "audio/vnd.dolby.pl2x": { - "source": "iana" - }, - "audio/vnd.dolby.pl2z": { - "source": "iana" - }, - "audio/vnd.dolby.pulse.1": { - "source": "iana" - }, - "audio/vnd.dra": { - "source": "iana", - "extensions": ["dra"] - }, - "audio/vnd.dts": { - "source": "iana", - "extensions": ["dts"] - }, - "audio/vnd.dts.hd": { - "source": "iana", - "extensions": ["dtshd"] - }, - "audio/vnd.dvb.file": { - "source": "iana" - }, - "audio/vnd.everad.plj": { - "source": "iana" - }, - "audio/vnd.hns.audio": { - "source": "iana" - }, - "audio/vnd.lucent.voice": { - "source": "iana", - "extensions": ["lvp"] - }, - "audio/vnd.ms-playready.media.pya": { - "source": "iana", - "extensions": ["pya"] - }, - "audio/vnd.nokia.mobile-xmf": { - "source": "iana" - }, - "audio/vnd.nortel.vbk": { - "source": "iana" - }, - "audio/vnd.nuera.ecelp4800": { - "source": "iana", - "extensions": ["ecelp4800"] - }, - "audio/vnd.nuera.ecelp7470": { - "source": "iana", - "extensions": ["ecelp7470"] - }, - "audio/vnd.nuera.ecelp9600": { - "source": "iana", - "extensions": ["ecelp9600"] - }, - "audio/vnd.octel.sbc": { - "source": "iana" - }, - "audio/vnd.qcelp": { - "source": "iana" - }, - "audio/vnd.rhetorex.32kadpcm": { - "source": "iana" - }, - "audio/vnd.rip": { - "source": "iana", - "extensions": ["rip"] - }, - "audio/vnd.rn-realaudio": { - "compressible": false - }, - "audio/vnd.sealedmedia.softseal.mpeg": { - "source": "iana" - }, - "audio/vnd.vmx.cvsd": { - "source": "iana" - }, - "audio/vnd.wave": { - "compressible": false - }, - "audio/vorbis": { - "source": "iana", - "compressible": false - }, - "audio/vorbis-config": { - "source": "iana" - }, - "audio/wav": { - "compressible": false, - "extensions": ["wav"] - }, - "audio/wave": { - "compressible": false, - "extensions": ["wav"] - }, - "audio/webm": { - "source": "apache", - "compressible": false, - "extensions": ["weba"] - }, - "audio/x-aac": { - "source": "apache", - "compressible": false, - "extensions": ["aac"] - }, - "audio/x-aiff": { - "source": "apache", - "extensions": ["aif","aiff","aifc"] - }, - "audio/x-caf": { - "source": "apache", - "compressible": false, - "extensions": ["caf"] - }, - "audio/x-flac": { - "source": "apache", - "extensions": ["flac"] - }, - "audio/x-m4a": { - "source": "nginx", - "extensions": ["m4a"] - }, - "audio/x-matroska": { - "source": "apache", - "extensions": ["mka"] - }, - "audio/x-mpegurl": { - "source": "apache", - "extensions": ["m3u"] - }, - "audio/x-ms-wax": { - "source": "apache", - "extensions": ["wax"] - }, - "audio/x-ms-wma": { - "source": "apache", - "extensions": ["wma"] - }, - "audio/x-pn-realaudio": { - "source": "apache", - "extensions": ["ram","ra"] - }, - "audio/x-pn-realaudio-plugin": { - "source": "apache", - "extensions": ["rmp"] - }, - "audio/x-realaudio": { - "source": "nginx", - "extensions": ["ra"] - }, - "audio/x-tta": { - "source": "apache" - }, - "audio/x-wav": { - "source": "apache", - "extensions": ["wav"] - }, - "audio/xm": { - "source": "apache", - "extensions": ["xm"] - }, - "chemical/x-cdx": { - "source": "apache", - "extensions": ["cdx"] - }, - "chemical/x-cif": { - "source": "apache", - "extensions": ["cif"] - }, - "chemical/x-cmdf": { - "source": "apache", - "extensions": ["cmdf"] - }, - "chemical/x-cml": { - "source": "apache", - "extensions": ["cml"] - }, - "chemical/x-csml": { - "source": "apache", - "extensions": ["csml"] - }, - "chemical/x-pdb": { - "source": "apache" - }, - "chemical/x-xyz": { - "source": "apache", - "extensions": ["xyz"] - }, - "font/opentype": { - "compressible": true, - "extensions": ["otf"] - }, - "image/bmp": { - "source": "apache", - "compressible": true, - "extensions": ["bmp"] - }, - "image/cgm": { - "source": "iana", - "extensions": ["cgm"] - }, - "image/fits": { - "source": "iana" - }, - "image/g3fax": { - "source": "iana", - "extensions": ["g3"] - }, - "image/gif": { - "source": "iana", - "compressible": false, - "extensions": ["gif"] - }, - "image/ief": { - "source": "iana", - "extensions": ["ief"] - }, - "image/jp2": { - "source": "iana" - }, - "image/jpeg": { - "source": "iana", - "compressible": false, - "extensions": ["jpeg","jpg","jpe"] - }, - "image/jpm": { - "source": "iana" - }, - "image/jpx": { - "source": "iana" - }, - "image/ktx": { - "source": "iana", - "extensions": ["ktx"] - }, - "image/naplps": { - "source": "iana" - }, - "image/pjpeg": { - "compressible": false - }, - "image/png": { - "source": "iana", - "compressible": false, - "extensions": ["png"] - }, - "image/prs.btif": { - "source": "iana", - "extensions": ["btif"] - }, - "image/prs.pti": { - "source": "iana" - }, - "image/pwg-raster": { - "source": "iana" - }, - "image/sgi": { - "source": "apache", - "extensions": ["sgi"] - }, - "image/svg+xml": { - "source": "iana", - "compressible": true, - "extensions": ["svg","svgz"] - }, - "image/t38": { - "source": "iana" - }, - "image/tiff": { - "source": "iana", - "compressible": false, - "extensions": ["tiff","tif"] - }, - "image/tiff-fx": { - "source": "iana" - }, - "image/vnd.adobe.photoshop": { - "source": "iana", - "compressible": true, - "extensions": ["psd"] - }, - "image/vnd.airzip.accelerator.azv": { - "source": "iana" - }, - "image/vnd.cns.inf2": { - "source": "iana" - }, - "image/vnd.dece.graphic": { - "source": "iana", - "extensions": ["uvi","uvvi","uvg","uvvg"] - }, - "image/vnd.djvu": { - "source": "iana", - "extensions": ["djvu","djv"] - }, - "image/vnd.dvb.subtitle": { - "source": "iana", - "extensions": ["sub"] - }, - "image/vnd.dwg": { - "source": "iana", - "extensions": ["dwg"] - }, - "image/vnd.dxf": { - "source": "iana", - "extensions": ["dxf"] - }, - "image/vnd.fastbidsheet": { - "source": "iana", - "extensions": ["fbs"] - }, - "image/vnd.fpx": { - "source": "iana", - "extensions": ["fpx"] - }, - "image/vnd.fst": { - "source": "iana", - "extensions": ["fst"] - }, - "image/vnd.fujixerox.edmics-mmr": { - "source": "iana", - "extensions": ["mmr"] - }, - "image/vnd.fujixerox.edmics-rlc": { - "source": "iana", - "extensions": ["rlc"] - }, - "image/vnd.globalgraphics.pgb": { - "source": "iana" - }, - "image/vnd.microsoft.icon": { - "source": "iana" - }, - "image/vnd.mix": { - "source": "iana" - }, - "image/vnd.mozilla.apng": { - "source": "iana" - }, - "image/vnd.ms-modi": { - "source": "iana", - "extensions": ["mdi"] - }, - "image/vnd.ms-photo": { - "source": "apache", - "extensions": ["wdp"] - }, - "image/vnd.net-fpx": { - "source": "iana", - "extensions": ["npx"] - }, - "image/vnd.radiance": { - "source": "iana" - }, - "image/vnd.sealed.png": { - "source": "iana" - }, - "image/vnd.sealedmedia.softseal.gif": { - "source": "iana" - }, - "image/vnd.sealedmedia.softseal.jpg": { - "source": "iana" - }, - "image/vnd.svf": { - "source": "iana" - }, - "image/vnd.tencent.tap": { - "source": "iana" - }, - "image/vnd.valve.source.texture": { - "source": "iana" - }, - "image/vnd.wap.wbmp": { - "source": "iana", - "extensions": ["wbmp"] - }, - "image/vnd.xiff": { - "source": "iana", - "extensions": ["xif"] - }, - "image/vnd.zbrush.pcx": { - "source": "iana" - }, - "image/webp": { - "source": "apache", - "extensions": ["webp"] - }, - "image/x-3ds": { - "source": "apache", - "extensions": ["3ds"] - }, - "image/x-cmu-raster": { - "source": "apache", - "extensions": ["ras"] - }, - "image/x-cmx": { - "source": "apache", - "extensions": ["cmx"] - }, - "image/x-freehand": { - "source": "apache", - "extensions": ["fh","fhc","fh4","fh5","fh7"] - }, - "image/x-icon": { - "source": "apache", - "compressible": true, - "extensions": ["ico"] - }, - "image/x-jng": { - "source": "nginx", - "extensions": ["jng"] - }, - "image/x-mrsid-image": { - "source": "apache", - "extensions": ["sid"] - }, - "image/x-ms-bmp": { - "source": "nginx", - "compressible": true, - "extensions": ["bmp"] - }, - "image/x-pcx": { - "source": "apache", - "extensions": ["pcx"] - }, - "image/x-pict": { - "source": "apache", - "extensions": ["pic","pct"] - }, - "image/x-portable-anymap": { - "source": "apache", - "extensions": ["pnm"] - }, - "image/x-portable-bitmap": { - "source": "apache", - "extensions": ["pbm"] - }, - "image/x-portable-graymap": { - "source": "apache", - "extensions": ["pgm"] - }, - "image/x-portable-pixmap": { - "source": "apache", - "extensions": ["ppm"] - }, - "image/x-rgb": { - "source": "apache", - "extensions": ["rgb"] - }, - "image/x-tga": { - "source": "apache", - "extensions": ["tga"] - }, - "image/x-xbitmap": { - "source": "apache", - "extensions": ["xbm"] - }, - "image/x-xcf": { - "compressible": false - }, - "image/x-xpixmap": { - "source": "apache", - "extensions": ["xpm"] - }, - "image/x-xwindowdump": { - "source": "apache", - "extensions": ["xwd"] - }, - "message/cpim": { - "source": "iana" - }, - "message/delivery-status": { - "source": "iana" - }, - "message/disposition-notification": { - "source": "iana" - }, - "message/external-body": { - "source": "iana" - }, - "message/feedback-report": { - "source": "iana" - }, - "message/global": { - "source": "iana" - }, - "message/global-delivery-status": { - "source": "iana" - }, - "message/global-disposition-notification": { - "source": "iana" - }, - "message/global-headers": { - "source": "iana" - }, - "message/http": { - "source": "iana", - "compressible": false - }, - "message/imdn+xml": { - "source": "iana", - "compressible": true - }, - "message/news": { - "source": "iana" - }, - "message/partial": { - "source": "iana", - "compressible": false - }, - "message/rfc822": { - "source": "iana", - "compressible": true, - "extensions": ["eml","mime"] - }, - "message/s-http": { - "source": "iana" - }, - "message/sip": { - "source": "iana" - }, - "message/sipfrag": { - "source": "iana" - }, - "message/tracking-status": { - "source": "iana" - }, - "message/vnd.si.simp": { - "source": "iana" - }, - "message/vnd.wfa.wsc": { - "source": "iana" - }, - "model/iges": { - "source": "iana", - "compressible": false, - "extensions": ["igs","iges"] - }, - "model/mesh": { - "source": "iana", - "compressible": false, - "extensions": ["msh","mesh","silo"] - }, - "model/vnd.collada+xml": { - "source": "iana", - "extensions": ["dae"] - }, - "model/vnd.dwf": { - "source": "iana", - "extensions": ["dwf"] - }, - "model/vnd.flatland.3dml": { - "source": "iana" - }, - "model/vnd.gdl": { - "source": "iana", - "extensions": ["gdl"] - }, - "model/vnd.gs-gdl": { - "source": "apache" - }, - "model/vnd.gs.gdl": { - "source": "iana" - }, - "model/vnd.gtw": { - "source": "iana", - "extensions": ["gtw"] - }, - "model/vnd.moml+xml": { - "source": "iana" - }, - "model/vnd.mts": { - "source": "iana", - "extensions": ["mts"] - }, - "model/vnd.opengex": { - "source": "iana" - }, - "model/vnd.parasolid.transmit.binary": { - "source": "iana" - }, - "model/vnd.parasolid.transmit.text": { - "source": "iana" - }, - "model/vnd.rosette.annotated-data-model": { - "source": "iana" - }, - "model/vnd.valve.source.compiled-map": { - "source": "iana" - }, - "model/vnd.vtu": { - "source": "iana", - "extensions": ["vtu"] - }, - "model/vrml": { - "source": "iana", - "compressible": false, - "extensions": ["wrl","vrml"] - }, - "model/x3d+binary": { - "source": "apache", - "compressible": false, - "extensions": ["x3db","x3dbz"] - }, - "model/x3d+fastinfoset": { - "source": "iana" - }, - "model/x3d+vrml": { - "source": "apache", - "compressible": false, - "extensions": ["x3dv","x3dvz"] - }, - "model/x3d+xml": { - "source": "iana", - "compressible": true, - "extensions": ["x3d","x3dz"] - }, - "model/x3d-vrml": { - "source": "iana" - }, - "multipart/alternative": { - "source": "iana", - "compressible": false - }, - "multipart/appledouble": { - "source": "iana" - }, - "multipart/byteranges": { - "source": "iana" - }, - "multipart/digest": { - "source": "iana" - }, - "multipart/encrypted": { - "source": "iana", - "compressible": false - }, - "multipart/form-data": { - "source": "iana", - "compressible": false - }, - "multipart/header-set": { - "source": "iana" - }, - "multipart/mixed": { - "source": "iana", - "compressible": false - }, - "multipart/parallel": { - "source": "iana" - }, - "multipart/related": { - "source": "iana", - "compressible": false - }, - "multipart/report": { - "source": "iana" - }, - "multipart/signed": { - "source": "iana", - "compressible": false - }, - "multipart/voice-message": { - "source": "iana" - }, - "multipart/x-mixed-replace": { - "source": "iana" - }, - "text/1d-interleaved-parityfec": { - "source": "iana" - }, - "text/cache-manifest": { - "source": "iana", - "compressible": true, - "extensions": ["appcache","manifest"] - }, - "text/calendar": { - "source": "iana", - "extensions": ["ics","ifb"] - }, - "text/calender": { - "compressible": true - }, - "text/cmd": { - "compressible": true - }, - "text/coffeescript": { - "extensions": ["coffee","litcoffee"] - }, - "text/css": { - "source": "iana", - "compressible": true, - "extensions": ["css"] - }, - "text/csv": { - "source": "iana", - "compressible": true, - "extensions": ["csv"] - }, - "text/csv-schema": { - "source": "iana" - }, - "text/directory": { - "source": "iana" - }, - "text/dns": { - "source": "iana" - }, - "text/ecmascript": { - "source": "iana" - }, - "text/encaprtp": { - "source": "iana" - }, - "text/enriched": { - "source": "iana" - }, - "text/fwdred": { - "source": "iana" - }, - "text/grammar-ref-list": { - "source": "iana" - }, - "text/hjson": { - "extensions": ["hjson"] - }, - "text/html": { - "source": "iana", - "compressible": true, - "extensions": ["html","htm","shtml"] - }, - "text/jade": { - "extensions": ["jade"] - }, - "text/javascript": { - "source": "iana", - "compressible": true - }, - "text/jcr-cnd": { - "source": "iana" - }, - "text/jsx": { - "compressible": true, - "extensions": ["jsx"] - }, - "text/less": { - "extensions": ["less"] - }, - "text/markdown": { - "source": "iana" - }, - "text/mathml": { - "source": "nginx", - "extensions": ["mml"] - }, - "text/mizar": { - "source": "iana" - }, - "text/n3": { - "source": "iana", - "compressible": true, - "extensions": ["n3"] - }, - "text/parameters": { - "source": "iana" - }, - "text/parityfec": { - "source": "iana" - }, - "text/plain": { - "source": "iana", - "compressible": true, - "extensions": ["txt","text","conf","def","list","log","in","ini"] - }, - "text/provenance-notation": { - "source": "iana" - }, - "text/prs.fallenstein.rst": { - "source": "iana" - }, - "text/prs.lines.tag": { - "source": "iana", - "extensions": ["dsc"] - }, - "text/prs.prop.logic": { - "source": "iana" - }, - "text/raptorfec": { - "source": "iana" - }, - "text/red": { - "source": "iana" - }, - "text/rfc822-headers": { - "source": "iana" - }, - "text/richtext": { - "source": "iana", - "compressible": true, - "extensions": ["rtx"] - }, - "text/rtf": { - "source": "iana", - "compressible": true, - "extensions": ["rtf"] - }, - "text/rtp-enc-aescm128": { - "source": "iana" - }, - "text/rtploopback": { - "source": "iana" - }, - "text/rtx": { - "source": "iana" - }, - "text/sgml": { - "source": "iana", - "extensions": ["sgml","sgm"] - }, - "text/slim": { - "extensions": ["slim","slm"] - }, - "text/stylus": { - "extensions": ["stylus","styl"] - }, - "text/t140": { - "source": "iana" - }, - "text/tab-separated-values": { - "source": "iana", - "compressible": true, - "extensions": ["tsv"] - }, - "text/troff": { - "source": "iana", - "extensions": ["t","tr","roff","man","me","ms"] - }, - "text/turtle": { - "source": "iana", - "extensions": ["ttl"] - }, - "text/ulpfec": { - "source": "iana" - }, - "text/uri-list": { - "source": "iana", - "compressible": true, - "extensions": ["uri","uris","urls"] - }, - "text/vcard": { - "source": "iana", - "compressible": true, - "extensions": ["vcard"] - }, - "text/vnd.a": { - "source": "iana" - }, - "text/vnd.abc": { - "source": "iana" - }, - "text/vnd.curl": { - "source": "iana", - "extensions": ["curl"] - }, - "text/vnd.curl.dcurl": { - "source": "apache", - "extensions": ["dcurl"] - }, - "text/vnd.curl.mcurl": { - "source": "apache", - "extensions": ["mcurl"] - }, - "text/vnd.curl.scurl": { - "source": "apache", - "extensions": ["scurl"] - }, - "text/vnd.debian.copyright": { - "source": "iana" - }, - "text/vnd.dmclientscript": { - "source": "iana" - }, - "text/vnd.dvb.subtitle": { - "source": "iana", - "extensions": ["sub"] - }, - "text/vnd.esmertec.theme-descriptor": { - "source": "iana" - }, - "text/vnd.fly": { - "source": "iana", - "extensions": ["fly"] - }, - "text/vnd.fmi.flexstor": { - "source": "iana", - "extensions": ["flx"] - }, - "text/vnd.graphviz": { - "source": "iana", - "extensions": ["gv"] - }, - "text/vnd.in3d.3dml": { - "source": "iana", - "extensions": ["3dml"] - }, - "text/vnd.in3d.spot": { - "source": "iana", - "extensions": ["spot"] - }, - "text/vnd.iptc.newsml": { - "source": "iana" - }, - "text/vnd.iptc.nitf": { - "source": "iana" - }, - "text/vnd.latex-z": { - "source": "iana" - }, - "text/vnd.motorola.reflex": { - "source": "iana" - }, - "text/vnd.ms-mediapackage": { - "source": "iana" - }, - "text/vnd.net2phone.commcenter.command": { - "source": "iana" - }, - "text/vnd.radisys.msml-basic-layout": { - "source": "iana" - }, - "text/vnd.si.uricatalogue": { - "source": "iana" - }, - "text/vnd.sun.j2me.app-descriptor": { - "source": "iana", - "extensions": ["jad"] - }, - "text/vnd.trolltech.linguist": { - "source": "iana" - }, - "text/vnd.wap.si": { - "source": "iana" - }, - "text/vnd.wap.sl": { - "source": "iana" - }, - "text/vnd.wap.wml": { - "source": "iana", - "extensions": ["wml"] - }, - "text/vnd.wap.wmlscript": { - "source": "iana", - "extensions": ["wmls"] - }, - "text/vtt": { - "charset": "UTF-8", - "compressible": true, - "extensions": ["vtt"] - }, - "text/x-asm": { - "source": "apache", - "extensions": ["s","asm"] - }, - "text/x-c": { - "source": "apache", - "extensions": ["c","cc","cxx","cpp","h","hh","dic"] - }, - "text/x-component": { - "source": "nginx", - "extensions": ["htc"] - }, - "text/x-fortran": { - "source": "apache", - "extensions": ["f","for","f77","f90"] - }, - "text/x-gwt-rpc": { - "compressible": true - }, - "text/x-handlebars-template": { - "extensions": ["hbs"] - }, - "text/x-java-source": { - "source": "apache", - "extensions": ["java"] - }, - "text/x-jquery-tmpl": { - "compressible": true - }, - "text/x-lua": { - "extensions": ["lua"] - }, - "text/x-markdown": { - "compressible": true, - "extensions": ["markdown","md","mkd"] - }, - "text/x-nfo": { - "source": "apache", - "extensions": ["nfo"] - }, - "text/x-opml": { - "source": "apache", - "extensions": ["opml"] - }, - "text/x-pascal": { - "source": "apache", - "extensions": ["p","pas"] - }, - "text/x-processing": { - "compressible": true, - "extensions": ["pde"] - }, - "text/x-sass": { - "extensions": ["sass"] - }, - "text/x-scss": { - "extensions": ["scss"] - }, - "text/x-setext": { - "source": "apache", - "extensions": ["etx"] - }, - "text/x-sfv": { - "source": "apache", - "extensions": ["sfv"] - }, - "text/x-suse-ymp": { - "compressible": true, - "extensions": ["ymp"] - }, - "text/x-uuencode": { - "source": "apache", - "extensions": ["uu"] - }, - "text/x-vcalendar": { - "source": "apache", - "extensions": ["vcs"] - }, - "text/x-vcard": { - "source": "apache", - "extensions": ["vcf"] - }, - "text/xml": { - "source": "iana", - "compressible": true, - "extensions": ["xml"] - }, - "text/xml-external-parsed-entity": { - "source": "iana" - }, - "text/yaml": { - "extensions": ["yaml","yml"] - }, - "video/1d-interleaved-parityfec": { - "source": "apache" - }, - "video/3gpp": { - "source": "apache", - "extensions": ["3gp","3gpp"] - }, - "video/3gpp-tt": { - "source": "apache" - }, - "video/3gpp2": { - "source": "apache", - "extensions": ["3g2"] - }, - "video/bmpeg": { - "source": "apache" - }, - "video/bt656": { - "source": "apache" - }, - "video/celb": { - "source": "apache" - }, - "video/dv": { - "source": "apache" - }, - "video/encaprtp": { - "source": "apache" - }, - "video/h261": { - "source": "apache", - "extensions": ["h261"] - }, - "video/h263": { - "source": "apache", - "extensions": ["h263"] - }, - "video/h263-1998": { - "source": "apache" - }, - "video/h263-2000": { - "source": "apache" - }, - "video/h264": { - "source": "apache", - "extensions": ["h264"] - }, - "video/h264-rcdo": { - "source": "apache" - }, - "video/h264-svc": { - "source": "apache" - }, - "video/h265": { - "source": "apache" - }, - "video/iso.segment": { - "source": "apache" - }, - "video/jpeg": { - "source": "apache", - "extensions": ["jpgv"] - }, - "video/jpeg2000": { - "source": "apache" - }, - "video/jpm": { - "source": "apache", - "extensions": ["jpm","jpgm"] - }, - "video/mj2": { - "source": "apache", - "extensions": ["mj2","mjp2"] - }, - "video/mp1s": { - "source": "apache" - }, - "video/mp2p": { - "source": "apache" - }, - "video/mp2t": { - "source": "apache", - "extensions": ["ts"] - }, - "video/mp4": { - "source": "apache", - "compressible": false, - "extensions": ["mp4","mp4v","mpg4"] - }, - "video/mp4v-es": { - "source": "apache" - }, - "video/mpeg": { - "source": "apache", - "compressible": false, - "extensions": ["mpeg","mpg","mpe","m1v","m2v"] - }, - "video/mpeg4-generic": { - "source": "apache" - }, - "video/mpv": { - "source": "apache" - }, - "video/nv": { - "source": "apache" - }, - "video/ogg": { - "source": "apache", - "compressible": false, - "extensions": ["ogv"] - }, - "video/parityfec": { - "source": "apache" - }, - "video/pointer": { - "source": "apache" - }, - "video/quicktime": { - "source": "apache", - "compressible": false, - "extensions": ["qt","mov"] - }, - "video/raptorfec": { - "source": "apache" - }, - "video/raw": { - "source": "apache" - }, - "video/rtp-enc-aescm128": { - "source": "apache" - }, - "video/rtploopback": { - "source": "apache" - }, - "video/rtx": { - "source": "apache" - }, - "video/smpte292m": { - "source": "apache" - }, - "video/ulpfec": { - "source": "apache" - }, - "video/vc1": { - "source": "apache" - }, - "video/vnd.cctv": { - "source": "apache" - }, - "video/vnd.dece.hd": { - "source": "apache", - "extensions": ["uvh","uvvh"] - }, - "video/vnd.dece.mobile": { - "source": "apache", - "extensions": ["uvm","uvvm"] - }, - "video/vnd.dece.mp4": { - "source": "apache" - }, - "video/vnd.dece.pd": { - "source": "apache", - "extensions": ["uvp","uvvp"] - }, - "video/vnd.dece.sd": { - "source": "apache", - "extensions": ["uvs","uvvs"] - }, - "video/vnd.dece.video": { - "source": "apache", - "extensions": ["uvv","uvvv"] - }, - "video/vnd.directv.mpeg": { - "source": "apache" - }, - "video/vnd.directv.mpeg-tts": { - "source": "apache" - }, - "video/vnd.dlna.mpeg-tts": { - "source": "apache" - }, - "video/vnd.dvb.file": { - "source": "apache", - "extensions": ["dvb"] - }, - "video/vnd.fvt": { - "source": "apache", - "extensions": ["fvt"] - }, - "video/vnd.hns.video": { - "source": "apache" - }, - "video/vnd.iptvforum.1dparityfec-1010": { - "source": "apache" - }, - "video/vnd.iptvforum.1dparityfec-2005": { - "source": "apache" - }, - "video/vnd.iptvforum.2dparityfec-1010": { - "source": "apache" - }, - "video/vnd.iptvforum.2dparityfec-2005": { - "source": "apache" - }, - "video/vnd.iptvforum.ttsavc": { - "source": "apache" - }, - "video/vnd.iptvforum.ttsmpeg2": { - "source": "apache" - }, - "video/vnd.motorola.video": { - "source": "apache" - }, - "video/vnd.motorola.videop": { - "source": "apache" - }, - "video/vnd.mpegurl": { - "source": "apache", - "extensions": ["mxu","m4u"] - }, - "video/vnd.ms-playready.media.pyv": { - "source": "apache", - "extensions": ["pyv"] - }, - "video/vnd.nokia.interleaved-multimedia": { - "source": "apache" - }, - "video/vnd.nokia.videovoip": { - "source": "apache" - }, - "video/vnd.objectvideo": { - "source": "apache" - }, - "video/vnd.radgamettools.bink": { - "source": "apache" - }, - "video/vnd.radgamettools.smacker": { - "source": "apache" - }, - "video/vnd.sealed.mpeg1": { - "source": "apache" - }, - "video/vnd.sealed.mpeg4": { - "source": "apache" - }, - "video/vnd.sealed.swf": { - "source": "apache" - }, - "video/vnd.sealedmedia.softseal.mov": { - "source": "apache" - }, - "video/vnd.uvvu.mp4": { - "source": "apache", - "extensions": ["uvu","uvvu"] - }, - "video/vnd.vivo": { - "source": "apache", - "extensions": ["viv"] - }, - "video/vp8": { - "source": "apache" - }, - "video/webm": { - "source": "apache", - "compressible": false, - "extensions": ["webm"] - }, - "video/x-f4v": { - "source": "apache", - "extensions": ["f4v"] - }, - "video/x-fli": { - "source": "apache", - "extensions": ["fli"] - }, - "video/x-flv": { - "source": "apache", - "compressible": false, - "extensions": ["flv"] - }, - "video/x-m4v": { - "source": "apache", - "extensions": ["m4v"] - }, - "video/x-matroska": { - "source": "apache", - "compressible": false, - "extensions": ["mkv","mk3d","mks"] - }, - "video/x-mng": { - "source": "apache", - "extensions": ["mng"] - }, - "video/x-ms-asf": { - "source": "apache", - "extensions": ["asf","asx"] - }, - "video/x-ms-vob": { - "source": "apache", - "extensions": ["vob"] - }, - "video/x-ms-wm": { - "source": "apache", - "extensions": ["wm"] - }, - "video/x-ms-wmv": { - "source": "apache", - "compressible": false, - "extensions": ["wmv"] - }, - "video/x-ms-wmx": { - "source": "apache", - "extensions": ["wmx"] - }, - "video/x-ms-wvx": { - "source": "apache", - "extensions": ["wvx"] - }, - "video/x-msvideo": { - "source": "apache", - "extensions": ["avi"] - }, - "video/x-sgi-movie": { - "source": "apache", - "extensions": ["movie"] - }, - "video/x-smv": { - "source": "apache", - "extensions": ["smv"] - }, - "x-conference/x-cooltalk": { - "source": "apache", - "extensions": ["ice"] - }, - "x-shader/x-fragment": { - "compressible": true - }, - "x-shader/x-vertex": { - "compressible": true - } -} +{ + "application/1d-interleaved-parityfec": { + "source": "iana" + }, + "application/3gpdash-qoe-report+xml": { + "source": "iana" + }, + "application/3gpp-ims+xml": { + "source": "iana" + }, + "application/a2l": { + "source": "iana" + }, + "application/activemessage": { + "source": "iana" + }, + "application/alto-costmap+json": { + "source": "iana", + "compressible": true + }, + "application/alto-costmapfilter+json": { + "source": "iana", + "compressible": true + }, + "application/alto-directory+json": { + "source": "iana", + "compressible": true + }, + "application/alto-endpointcost+json": { + "source": "iana", + "compressible": true + }, + "application/alto-endpointcostparams+json": { + "source": "iana", + "compressible": true + }, + "application/alto-endpointprop+json": { + "source": "iana", + "compressible": true + }, + "application/alto-endpointpropparams+json": { + "source": "iana", + "compressible": true + }, + "application/alto-error+json": { + "source": "iana", + "compressible": true + }, + "application/alto-networkmap+json": { + "source": "iana", + "compressible": true + }, + "application/alto-networkmapfilter+json": { + "source": "iana", + "compressible": true + }, + "application/aml": { + "source": "iana" + }, + "application/andrew-inset": { + "source": "iana", + "extensions": ["ez"] + }, + "application/applefile": { + "source": "iana" + }, + "application/applixware": { + "source": "apache", + "extensions": ["aw"] + }, + "application/atf": { + "source": "iana" + }, + "application/atfx": { + "source": "iana" + }, + "application/atom+xml": { + "source": "iana", + "compressible": true, + "extensions": ["atom"] + }, + "application/atomcat+xml": { + "source": "iana", + "extensions": ["atomcat"] + }, + "application/atomdeleted+xml": { + "source": "iana" + }, + "application/atomicmail": { + "source": "iana" + }, + "application/atomsvc+xml": { + "source": "iana", + "extensions": ["atomsvc"] + }, + "application/atxml": { + "source": "iana" + }, + "application/auth-policy+xml": { + "source": "iana" + }, + "application/bacnet-xdd+zip": { + "source": "iana" + }, + "application/batch-smtp": { + "source": "iana" + }, + "application/bdoc": { + "compressible": false, + "extensions": ["bdoc"] + }, + "application/beep+xml": { + "source": "iana" + }, + "application/calendar+json": { + "source": "iana", + "compressible": true + }, + "application/calendar+xml": { + "source": "iana" + }, + "application/call-completion": { + "source": "iana" + }, + "application/cals-1840": { + "source": "iana" + }, + "application/cbor": { + "source": "iana" + }, + "application/ccmp+xml": { + "source": "iana" + }, + "application/ccxml+xml": { + "source": "iana", + "extensions": ["ccxml"] + }, + "application/cdfx+xml": { + "source": "iana" + }, + "application/cdmi-capability": { + "source": "iana", + "extensions": ["cdmia"] + }, + "application/cdmi-container": { + "source": "iana", + "extensions": ["cdmic"] + }, + "application/cdmi-domain": { + "source": "iana", + "extensions": ["cdmid"] + }, + "application/cdmi-object": { + "source": "iana", + "extensions": ["cdmio"] + }, + "application/cdmi-queue": { + "source": "iana", + "extensions": ["cdmiq"] + }, + "application/cdni": { + "source": "iana" + }, + "application/cea": { + "source": "iana" + }, + "application/cea-2018+xml": { + "source": "iana" + }, + "application/cellml+xml": { + "source": "iana" + }, + "application/cfw": { + "source": "iana" + }, + "application/cms": { + "source": "iana" + }, + "application/cnrp+xml": { + "source": "iana" + }, + "application/coap-group+json": { + "source": "iana", + "compressible": true + }, + "application/commonground": { + "source": "iana" + }, + "application/conference-info+xml": { + "source": "iana" + }, + "application/cpl+xml": { + "source": "iana" + }, + "application/csrattrs": { + "source": "iana" + }, + "application/csta+xml": { + "source": "iana" + }, + "application/cstadata+xml": { + "source": "iana" + }, + "application/csvm+json": { + "source": "iana", + "compressible": true + }, + "application/cu-seeme": { + "source": "apache", + "extensions": ["cu"] + }, + "application/cybercash": { + "source": "iana" + }, + "application/dart": { + "compressible": true + }, + "application/dash+xml": { + "source": "iana", + "extensions": ["mpd"] + }, + "application/dashdelta": { + "source": "iana" + }, + "application/davmount+xml": { + "source": "iana", + "extensions": ["davmount"] + }, + "application/dca-rft": { + "source": "iana" + }, + "application/dcd": { + "source": "iana" + }, + "application/dec-dx": { + "source": "iana" + }, + "application/dialog-info+xml": { + "source": "iana" + }, + "application/dicom": { + "source": "iana" + }, + "application/dii": { + "source": "iana" + }, + "application/dit": { + "source": "iana" + }, + "application/dns": { + "source": "iana" + }, + "application/docbook+xml": { + "source": "apache", + "extensions": ["dbk"] + }, + "application/dskpp+xml": { + "source": "iana" + }, + "application/dssc+der": { + "source": "iana", + "extensions": ["dssc"] + }, + "application/dssc+xml": { + "source": "iana", + "extensions": ["xdssc"] + }, + "application/dvcs": { + "source": "iana" + }, + "application/ecmascript": { + "source": "iana", + "compressible": true, + "extensions": ["ecma"] + }, + "application/edi-consent": { + "source": "iana" + }, + "application/edi-x12": { + "source": "iana", + "compressible": false + }, + "application/edifact": { + "source": "iana", + "compressible": false + }, + "application/efi": { + "source": "iana" + }, + "application/emergencycalldata.comment+xml": { + "source": "iana" + }, + "application/emergencycalldata.deviceinfo+xml": { + "source": "iana" + }, + "application/emergencycalldata.providerinfo+xml": { + "source": "iana" + }, + "application/emergencycalldata.serviceinfo+xml": { + "source": "iana" + }, + "application/emergencycalldata.subscriberinfo+xml": { + "source": "iana" + }, + "application/emma+xml": { + "source": "iana", + "extensions": ["emma"] + }, + "application/emotionml+xml": { + "source": "iana" + }, + "application/encaprtp": { + "source": "iana" + }, + "application/epp+xml": { + "source": "iana" + }, + "application/epub+zip": { + "source": "iana", + "extensions": ["epub"] + }, + "application/eshop": { + "source": "iana" + }, + "application/exi": { + "source": "iana", + "extensions": ["exi"] + }, + "application/fastinfoset": { + "source": "iana" + }, + "application/fastsoap": { + "source": "iana" + }, + "application/fdt+xml": { + "source": "iana" + }, + "application/fits": { + "source": "iana" + }, + "application/font-sfnt": { + "source": "iana" + }, + "application/font-tdpfr": { + "source": "iana", + "extensions": ["pfr"] + }, + "application/font-woff": { + "source": "iana", + "compressible": false, + "extensions": ["woff"] + }, + "application/font-woff2": { + "compressible": false, + "extensions": ["woff2"] + }, + "application/framework-attributes+xml": { + "source": "iana" + }, + "application/gml+xml": { + "source": "apache", + "extensions": ["gml"] + }, + "application/gpx+xml": { + "source": "apache", + "extensions": ["gpx"] + }, + "application/gxf": { + "source": "apache", + "extensions": ["gxf"] + }, + "application/gzip": { + "source": "iana", + "compressible": false + }, + "application/h224": { + "source": "iana" + }, + "application/held+xml": { + "source": "iana" + }, + "application/http": { + "source": "iana" + }, + "application/hyperstudio": { + "source": "iana", + "extensions": ["stk"] + }, + "application/ibe-key-request+xml": { + "source": "iana" + }, + "application/ibe-pkg-reply+xml": { + "source": "iana" + }, + "application/ibe-pp-data": { + "source": "iana" + }, + "application/iges": { + "source": "iana" + }, + "application/im-iscomposing+xml": { + "source": "iana" + }, + "application/index": { + "source": "iana" + }, + "application/index.cmd": { + "source": "iana" + }, + "application/index.obj": { + "source": "iana" + }, + "application/index.response": { + "source": "iana" + }, + "application/index.vnd": { + "source": "iana" + }, + "application/inkml+xml": { + "source": "iana", + "extensions": ["ink","inkml"] + }, + "application/iotp": { + "source": "iana" + }, + "application/ipfix": { + "source": "iana", + "extensions": ["ipfix"] + }, + "application/ipp": { + "source": "iana" + }, + "application/isup": { + "source": "iana" + }, + "application/its+xml": { + "source": "iana" + }, + "application/java-archive": { + "source": "apache", + "compressible": false, + "extensions": ["jar","war","ear"] + }, + "application/java-serialized-object": { + "source": "apache", + "compressible": false, + "extensions": ["ser"] + }, + "application/java-vm": { + "source": "apache", + "compressible": false, + "extensions": ["class"] + }, + "application/javascript": { + "source": "iana", + "charset": "UTF-8", + "compressible": true, + "extensions": ["js"] + }, + "application/jose": { + "source": "iana" + }, + "application/jose+json": { + "source": "iana", + "compressible": true + }, + "application/jrd+json": { + "source": "iana", + "compressible": true + }, + "application/json": { + "source": "iana", + "charset": "UTF-8", + "compressible": true, + "extensions": ["json","map"] + }, + "application/json-patch+json": { + "source": "iana", + "compressible": true + }, + "application/json-seq": { + "source": "iana" + }, + "application/json5": { + "extensions": ["json5"] + }, + "application/jsonml+json": { + "source": "apache", + "compressible": true, + "extensions": ["jsonml"] + }, + "application/jwk+json": { + "source": "iana", + "compressible": true + }, + "application/jwk-set+json": { + "source": "iana", + "compressible": true + }, + "application/jwt": { + "source": "iana" + }, + "application/kpml-request+xml": { + "source": "iana" + }, + "application/kpml-response+xml": { + "source": "iana" + }, + "application/ld+json": { + "source": "iana", + "compressible": true, + "extensions": ["jsonld"] + }, + "application/link-format": { + "source": "iana" + }, + "application/load-control+xml": { + "source": "iana" + }, + "application/lost+xml": { + "source": "iana", + "extensions": ["lostxml"] + }, + "application/lostsync+xml": { + "source": "iana" + }, + "application/lxf": { + "source": "iana" + }, + "application/mac-binhex40": { + "source": "iana", + "extensions": ["hqx"] + }, + "application/mac-compactpro": { + "source": "apache", + "extensions": ["cpt"] + }, + "application/macwriteii": { + "source": "iana" + }, + "application/mads+xml": { + "source": "iana", + "extensions": ["mads"] + }, + "application/manifest+json": { + "charset": "UTF-8", + "compressible": true, + "extensions": ["webmanifest"] + }, + "application/marc": { + "source": "iana", + "extensions": ["mrc"] + }, + "application/marcxml+xml": { + "source": "iana", + "extensions": ["mrcx"] + }, + "application/mathematica": { + "source": "iana", + "extensions": ["ma","nb","mb"] + }, + "application/mathml+xml": { + "source": "iana", + "extensions": ["mathml"] + }, + "application/mathml-content+xml": { + "source": "iana" + }, + "application/mathml-presentation+xml": { + "source": "iana" + }, + "application/mbms-associated-procedure-description+xml": { + "source": "iana" + }, + "application/mbms-deregister+xml": { + "source": "iana" + }, + "application/mbms-envelope+xml": { + "source": "iana" + }, + "application/mbms-msk+xml": { + "source": "iana" + }, + "application/mbms-msk-response+xml": { + "source": "iana" + }, + "application/mbms-protection-description+xml": { + "source": "iana" + }, + "application/mbms-reception-report+xml": { + "source": "iana" + }, + "application/mbms-register+xml": { + "source": "iana" + }, + "application/mbms-register-response+xml": { + "source": "iana" + }, + "application/mbms-schedule+xml": { + "source": "iana" + }, + "application/mbms-user-service-description+xml": { + "source": "iana" + }, + "application/mbox": { + "source": "iana", + "extensions": ["mbox"] + }, + "application/media-policy-dataset+xml": { + "source": "iana" + }, + "application/media_control+xml": { + "source": "iana" + }, + "application/mediaservercontrol+xml": { + "source": "iana", + "extensions": ["mscml"] + }, + "application/merge-patch+json": { + "source": "iana", + "compressible": true + }, + "application/metalink+xml": { + "source": "apache", + "extensions": ["metalink"] + }, + "application/metalink4+xml": { + "source": "iana", + "extensions": ["meta4"] + }, + "application/mets+xml": { + "source": "iana", + "extensions": ["mets"] + }, + "application/mf4": { + "source": "iana" + }, + "application/mikey": { + "source": "iana" + }, + "application/mods+xml": { + "source": "iana", + "extensions": ["mods"] + }, + "application/moss-keys": { + "source": "iana" + }, + "application/moss-signature": { + "source": "iana" + }, + "application/mosskey-data": { + "source": "iana" + }, + "application/mosskey-request": { + "source": "iana" + }, + "application/mp21": { + "source": "iana", + "extensions": ["m21","mp21"] + }, + "application/mp4": { + "source": "iana", + "extensions": ["mp4s","m4p"] + }, + "application/mpeg4-generic": { + "source": "iana" + }, + "application/mpeg4-iod": { + "source": "iana" + }, + "application/mpeg4-iod-xmt": { + "source": "iana" + }, + "application/mrb-consumer+xml": { + "source": "iana" + }, + "application/mrb-publish+xml": { + "source": "iana" + }, + "application/msc-ivr+xml": { + "source": "iana" + }, + "application/msc-mixer+xml": { + "source": "iana" + }, + "application/msword": { + "source": "iana", + "compressible": false, + "extensions": ["doc","dot"] + }, + "application/mxf": { + "source": "iana", + "extensions": ["mxf"] + }, + "application/nasdata": { + "source": "iana" + }, + "application/news-checkgroups": { + "source": "iana" + }, + "application/news-groupinfo": { + "source": "iana" + }, + "application/news-transmission": { + "source": "iana" + }, + "application/nlsml+xml": { + "source": "iana" + }, + "application/nss": { + "source": "iana" + }, + "application/ocsp-request": { + "source": "iana" + }, + "application/ocsp-response": { + "source": "iana" + }, + "application/octet-stream": { + "source": "iana", + "compressible": false, + "extensions": ["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"] + }, + "application/oda": { + "source": "iana", + "extensions": ["oda"] + }, + "application/odx": { + "source": "iana" + }, + "application/oebps-package+xml": { + "source": "iana", + "extensions": ["opf"] + }, + "application/ogg": { + "source": "iana", + "compressible": false, + "extensions": ["ogx"] + }, + "application/omdoc+xml": { + "source": "apache", + "extensions": ["omdoc"] + }, + "application/onenote": { + "source": "apache", + "extensions": ["onetoc","onetoc2","onetmp","onepkg"] + }, + "application/oxps": { + "source": "iana", + "extensions": ["oxps"] + }, + "application/p2p-overlay+xml": { + "source": "iana" + }, + "application/parityfec": { + "source": "iana" + }, + "application/patch-ops-error+xml": { + "source": "iana", + "extensions": ["xer"] + }, + "application/pdf": { + "source": "iana", + "compressible": false, + "extensions": ["pdf"] + }, + "application/pdx": { + "source": "iana" + }, + "application/pgp-encrypted": { + "source": "iana", + "compressible": false, + "extensions": ["pgp"] + }, + "application/pgp-keys": { + "source": "iana" + }, + "application/pgp-signature": { + "source": "iana", + "extensions": ["asc","sig"] + }, + "application/pics-rules": { + "source": "apache", + "extensions": ["prf"] + }, + "application/pidf+xml": { + "source": "iana" + }, + "application/pidf-diff+xml": { + "source": "iana" + }, + "application/pkcs10": { + "source": "iana", + "extensions": ["p10"] + }, + "application/pkcs12": { + "source": "iana" + }, + "application/pkcs7-mime": { + "source": "iana", + "extensions": ["p7m","p7c"] + }, + "application/pkcs7-signature": { + "source": "iana", + "extensions": ["p7s"] + }, + "application/pkcs8": { + "source": "iana", + "extensions": ["p8"] + }, + "application/pkix-attr-cert": { + "source": "iana", + "extensions": ["ac"] + }, + "application/pkix-cert": { + "source": "iana", + "extensions": ["cer"] + }, + "application/pkix-crl": { + "source": "iana", + "extensions": ["crl"] + }, + "application/pkix-pkipath": { + "source": "iana", + "extensions": ["pkipath"] + }, + "application/pkixcmp": { + "source": "iana", + "extensions": ["pki"] + }, + "application/pls+xml": { + "source": "iana", + "extensions": ["pls"] + }, + "application/poc-settings+xml": { + "source": "iana" + }, + "application/postscript": { + "source": "iana", + "compressible": true, + "extensions": ["ai","eps","ps"] + }, + "application/ppsp-tracker+json": { + "source": "iana", + "compressible": true + }, + "application/problem+json": { + "source": "iana", + "compressible": true + }, + "application/problem+xml": { + "source": "iana" + }, + "application/provenance+xml": { + "source": "iana" + }, + "application/prs.alvestrand.titrax-sheet": { + "source": "iana" + }, + "application/prs.cww": { + "source": "iana", + "extensions": ["cww"] + }, + "application/prs.hpub+zip": { + "source": "iana" + }, + "application/prs.nprend": { + "source": "iana" + }, + "application/prs.plucker": { + "source": "iana" + }, + "application/prs.rdf-xml-crypt": { + "source": "iana" + }, + "application/prs.xsf+xml": { + "source": "iana" + }, + "application/pskc+xml": { + "source": "iana", + "extensions": ["pskcxml"] + }, + "application/qsig": { + "source": "iana" + }, + "application/raptorfec": { + "source": "iana" + }, + "application/rdap+json": { + "source": "iana", + "compressible": true + }, + "application/rdf+xml": { + "source": "iana", + "compressible": true, + "extensions": ["rdf"] + }, + "application/reginfo+xml": { + "source": "iana", + "extensions": ["rif"] + }, + "application/relax-ng-compact-syntax": { + "source": "iana", + "extensions": ["rnc"] + }, + "application/remote-printing": { + "source": "iana" + }, + "application/reputon+json": { + "source": "iana", + "compressible": true + }, + "application/resource-lists+xml": { + "source": "iana", + "extensions": ["rl"] + }, + "application/resource-lists-diff+xml": { + "source": "iana", + "extensions": ["rld"] + }, + "application/rfc+xml": { + "source": "iana" + }, + "application/riscos": { + "source": "iana" + }, + "application/rlmi+xml": { + "source": "iana" + }, + "application/rls-services+xml": { + "source": "iana", + "extensions": ["rs"] + }, + "application/rpki-ghostbusters": { + "source": "iana", + "extensions": ["gbr"] + }, + "application/rpki-manifest": { + "source": "iana", + "extensions": ["mft"] + }, + "application/rpki-roa": { + "source": "iana", + "extensions": ["roa"] + }, + "application/rpki-updown": { + "source": "iana" + }, + "application/rsd+xml": { + "source": "apache", + "extensions": ["rsd"] + }, + "application/rss+xml": { + "source": "apache", + "compressible": true, + "extensions": ["rss"] + }, + "application/rtf": { + "source": "iana", + "compressible": true, + "extensions": ["rtf"] + }, + "application/rtploopback": { + "source": "iana" + }, + "application/rtx": { + "source": "iana" + }, + "application/samlassertion+xml": { + "source": "iana" + }, + "application/samlmetadata+xml": { + "source": "iana" + }, + "application/sbml+xml": { + "source": "iana", + "extensions": ["sbml"] + }, + "application/scaip+xml": { + "source": "iana" + }, + "application/scim+json": { + "source": "iana", + "compressible": true + }, + "application/scvp-cv-request": { + "source": "iana", + "extensions": ["scq"] + }, + "application/scvp-cv-response": { + "source": "iana", + "extensions": ["scs"] + }, + "application/scvp-vp-request": { + "source": "iana", + "extensions": ["spq"] + }, + "application/scvp-vp-response": { + "source": "iana", + "extensions": ["spp"] + }, + "application/sdp": { + "source": "iana", + "extensions": ["sdp"] + }, + "application/sep+xml": { + "source": "iana" + }, + "application/sep-exi": { + "source": "iana" + }, + "application/session-info": { + "source": "iana" + }, + "application/set-payment": { + "source": "iana" + }, + "application/set-payment-initiation": { + "source": "iana", + "extensions": ["setpay"] + }, + "application/set-registration": { + "source": "iana" + }, + "application/set-registration-initiation": { + "source": "iana", + "extensions": ["setreg"] + }, + "application/sgml": { + "source": "iana" + }, + "application/sgml-open-catalog": { + "source": "iana" + }, + "application/shf+xml": { + "source": "iana", + "extensions": ["shf"] + }, + "application/sieve": { + "source": "iana" + }, + "application/simple-filter+xml": { + "source": "iana" + }, + "application/simple-message-summary": { + "source": "iana" + }, + "application/simplesymbolcontainer": { + "source": "iana" + }, + "application/slate": { + "source": "iana" + }, + "application/smil": { + "source": "iana" + }, + "application/smil+xml": { + "source": "iana", + "extensions": ["smi","smil"] + }, + "application/smpte336m": { + "source": "iana" + }, + "application/soap+fastinfoset": { + "source": "iana" + }, + "application/soap+xml": { + "source": "iana", + "compressible": true + }, + "application/sparql-query": { + "source": "iana", + "extensions": ["rq"] + }, + "application/sparql-results+xml": { + "source": "iana", + "extensions": ["srx"] + }, + "application/spirits-event+xml": { + "source": "iana" + }, + "application/sql": { + "source": "iana" + }, + "application/srgs": { + "source": "iana", + "extensions": ["gram"] + }, + "application/srgs+xml": { + "source": "iana", + "extensions": ["grxml"] + }, + "application/sru+xml": { + "source": "iana", + "extensions": ["sru"] + }, + "application/ssdl+xml": { + "source": "apache", + "extensions": ["ssdl"] + }, + "application/ssml+xml": { + "source": "iana", + "extensions": ["ssml"] + }, + "application/tamp-apex-update": { + "source": "iana" + }, + "application/tamp-apex-update-confirm": { + "source": "iana" + }, + "application/tamp-community-update": { + "source": "iana" + }, + "application/tamp-community-update-confirm": { + "source": "iana" + }, + "application/tamp-error": { + "source": "iana" + }, + "application/tamp-sequence-adjust": { + "source": "iana" + }, + "application/tamp-sequence-adjust-confirm": { + "source": "iana" + }, + "application/tamp-status-query": { + "source": "iana" + }, + "application/tamp-status-response": { + "source": "iana" + }, + "application/tamp-update": { + "source": "iana" + }, + "application/tamp-update-confirm": { + "source": "iana" + }, + "application/tar": { + "compressible": true + }, + "application/tei+xml": { + "source": "iana", + "extensions": ["tei","teicorpus"] + }, + "application/thraud+xml": { + "source": "iana", + "extensions": ["tfi"] + }, + "application/timestamp-query": { + "source": "iana" + }, + "application/timestamp-reply": { + "source": "iana" + }, + "application/timestamped-data": { + "source": "iana", + "extensions": ["tsd"] + }, + "application/ttml+xml": { + "source": "iana" + }, + "application/tve-trigger": { + "source": "iana" + }, + "application/ulpfec": { + "source": "iana" + }, + "application/urc-grpsheet+xml": { + "source": "iana" + }, + "application/urc-ressheet+xml": { + "source": "iana" + }, + "application/urc-targetdesc+xml": { + "source": "iana" + }, + "application/urc-uisocketdesc+xml": { + "source": "iana" + }, + "application/vcard+json": { + "source": "iana", + "compressible": true + }, + "application/vcard+xml": { + "source": "iana" + }, + "application/vemmi": { + "source": "iana" + }, + "application/vividence.scriptfile": { + "source": "apache" + }, + "application/vnd.3gpp-prose+xml": { + "source": "iana" + }, + "application/vnd.3gpp-prose-pc3ch+xml": { + "source": "iana" + }, + "application/vnd.3gpp.access-transfer-events+xml": { + "source": "iana" + }, + "application/vnd.3gpp.bsf+xml": { + "source": "iana" + }, + "application/vnd.3gpp.mid-call+xml": { + "source": "iana" + }, + "application/vnd.3gpp.pic-bw-large": { + "source": "iana", + "extensions": ["plb"] + }, + "application/vnd.3gpp.pic-bw-small": { + "source": "iana", + "extensions": ["psb"] + }, + "application/vnd.3gpp.pic-bw-var": { + "source": "iana", + "extensions": ["pvb"] + }, + "application/vnd.3gpp.sms": { + "source": "iana" + }, + "application/vnd.3gpp.sms+xml": { + "source": "iana" + }, + "application/vnd.3gpp.srvcc-ext+xml": { + "source": "iana" + }, + "application/vnd.3gpp.srvcc-info+xml": { + "source": "iana" + }, + "application/vnd.3gpp.state-and-event-info+xml": { + "source": "iana" + }, + "application/vnd.3gpp.ussd+xml": { + "source": "iana" + }, + "application/vnd.3gpp2.bcmcsinfo+xml": { + "source": "iana" + }, + "application/vnd.3gpp2.sms": { + "source": "iana" + }, + "application/vnd.3gpp2.tcap": { + "source": "iana", + "extensions": ["tcap"] + }, + "application/vnd.3lightssoftware.imagescal": { + "source": "iana" + }, + "application/vnd.3m.post-it-notes": { + "source": "iana", + "extensions": ["pwn"] + }, + "application/vnd.accpac.simply.aso": { + "source": "iana", + "extensions": ["aso"] + }, + "application/vnd.accpac.simply.imp": { + "source": "iana", + "extensions": ["imp"] + }, + "application/vnd.acucobol": { + "source": "iana", + "extensions": ["acu"] + }, + "application/vnd.acucorp": { + "source": "iana", + "extensions": ["atc","acutc"] + }, + "application/vnd.adobe.air-application-installer-package+zip": { + "source": "apache", + "extensions": ["air"] + }, + "application/vnd.adobe.flash.movie": { + "source": "iana" + }, + "application/vnd.adobe.formscentral.fcdt": { + "source": "iana", + "extensions": ["fcdt"] + }, + "application/vnd.adobe.fxp": { + "source": "iana", + "extensions": ["fxp","fxpl"] + }, + "application/vnd.adobe.partial-upload": { + "source": "iana" + }, + "application/vnd.adobe.xdp+xml": { + "source": "iana", + "extensions": ["xdp"] + }, + "application/vnd.adobe.xfdf": { + "source": "iana", + "extensions": ["xfdf"] + }, + "application/vnd.aether.imp": { + "source": "iana" + }, + "application/vnd.ah-barcode": { + "source": "iana" + }, + "application/vnd.ahead.space": { + "source": "iana", + "extensions": ["ahead"] + }, + "application/vnd.airzip.filesecure.azf": { + "source": "iana", + "extensions": ["azf"] + }, + "application/vnd.airzip.filesecure.azs": { + "source": "iana", + "extensions": ["azs"] + }, + "application/vnd.amazon.ebook": { + "source": "apache", + "extensions": ["azw"] + }, + "application/vnd.americandynamics.acc": { + "source": "iana", + "extensions": ["acc"] + }, + "application/vnd.amiga.ami": { + "source": "iana", + "extensions": ["ami"] + }, + "application/vnd.amundsen.maze+xml": { + "source": "iana" + }, + "application/vnd.android.package-archive": { + "source": "apache", + "compressible": false, + "extensions": ["apk"] + }, + "application/vnd.anki": { + "source": "iana" + }, + "application/vnd.anser-web-certificate-issue-initiation": { + "source": "iana", + "extensions": ["cii"] + }, + "application/vnd.anser-web-funds-transfer-initiation": { + "source": "apache", + "extensions": ["fti"] + }, + "application/vnd.antix.game-component": { + "source": "iana", + "extensions": ["atx"] + }, + "application/vnd.apache.thrift.binary": { + "source": "iana" + }, + "application/vnd.apache.thrift.compact": { + "source": "iana" + }, + "application/vnd.apache.thrift.json": { + "source": "iana" + }, + "application/vnd.api+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.apple.installer+xml": { + "source": "iana", + "extensions": ["mpkg"] + }, + "application/vnd.apple.mpegurl": { + "source": "iana", + "extensions": ["m3u8"] + }, + "application/vnd.apple.pkpass": { + "compressible": false, + "extensions": ["pkpass"] + }, + "application/vnd.arastra.swi": { + "source": "iana" + }, + "application/vnd.aristanetworks.swi": { + "source": "iana", + "extensions": ["swi"] + }, + "application/vnd.artsquare": { + "source": "iana" + }, + "application/vnd.astraea-software.iota": { + "source": "iana", + "extensions": ["iota"] + }, + "application/vnd.audiograph": { + "source": "iana", + "extensions": ["aep"] + }, + "application/vnd.autopackage": { + "source": "iana" + }, + "application/vnd.avistar+xml": { + "source": "iana" + }, + "application/vnd.balsamiq.bmml+xml": { + "source": "iana" + }, + "application/vnd.balsamiq.bmpr": { + "source": "iana" + }, + "application/vnd.bekitzur-stech+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.biopax.rdf+xml": { + "source": "iana" + }, + "application/vnd.blueice.multipass": { + "source": "iana", + "extensions": ["mpm"] + }, + "application/vnd.bluetooth.ep.oob": { + "source": "iana" + }, + "application/vnd.bluetooth.le.oob": { + "source": "iana" + }, + "application/vnd.bmi": { + "source": "iana", + "extensions": ["bmi"] + }, + "application/vnd.businessobjects": { + "source": "iana", + "extensions": ["rep"] + }, + "application/vnd.cab-jscript": { + "source": "iana" + }, + "application/vnd.canon-cpdl": { + "source": "iana" + }, + "application/vnd.canon-lips": { + "source": "iana" + }, + "application/vnd.cendio.thinlinc.clientconf": { + "source": "iana" + }, + "application/vnd.century-systems.tcp_stream": { + "source": "iana" + }, + "application/vnd.chemdraw+xml": { + "source": "iana", + "extensions": ["cdxml"] + }, + "application/vnd.chipnuts.karaoke-mmd": { + "source": "iana", + "extensions": ["mmd"] + }, + "application/vnd.cinderella": { + "source": "iana", + "extensions": ["cdy"] + }, + "application/vnd.cirpack.isdn-ext": { + "source": "iana" + }, + "application/vnd.citationstyles.style+xml": { + "source": "iana" + }, + "application/vnd.claymore": { + "source": "iana", + "extensions": ["cla"] + }, + "application/vnd.cloanto.rp9": { + "source": "iana", + "extensions": ["rp9"] + }, + "application/vnd.clonk.c4group": { + "source": "iana", + "extensions": ["c4g","c4d","c4f","c4p","c4u"] + }, + "application/vnd.cluetrust.cartomobile-config": { + "source": "iana", + "extensions": ["c11amc"] + }, + "application/vnd.cluetrust.cartomobile-config-pkg": { + "source": "iana", + "extensions": ["c11amz"] + }, + "application/vnd.coffeescript": { + "source": "iana" + }, + "application/vnd.collection+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.collection.doc+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.collection.next+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.commerce-battelle": { + "source": "iana" + }, + "application/vnd.commonspace": { + "source": "iana", + "extensions": ["csp"] + }, + "application/vnd.contact.cmsg": { + "source": "iana", + "extensions": ["cdbcmsg"] + }, + "application/vnd.coreos.ignition+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.cosmocaller": { + "source": "iana", + "extensions": ["cmc"] + }, + "application/vnd.crick.clicker": { + "source": "iana", + "extensions": ["clkx"] + }, + "application/vnd.crick.clicker.keyboard": { + "source": "iana", + "extensions": ["clkk"] + }, + "application/vnd.crick.clicker.palette": { + "source": "iana", + "extensions": ["clkp"] + }, + "application/vnd.crick.clicker.template": { + "source": "iana", + "extensions": ["clkt"] + }, + "application/vnd.crick.clicker.wordbank": { + "source": "iana", + "extensions": ["clkw"] + }, + "application/vnd.criticaltools.wbs+xml": { + "source": "iana", + "extensions": ["wbs"] + }, + "application/vnd.ctc-posml": { + "source": "iana", + "extensions": ["pml"] + }, + "application/vnd.ctct.ws+xml": { + "source": "iana" + }, + "application/vnd.cups-pdf": { + "source": "iana" + }, + "application/vnd.cups-postscript": { + "source": "iana" + }, + "application/vnd.cups-ppd": { + "source": "iana", + "extensions": ["ppd"] + }, + "application/vnd.cups-raster": { + "source": "iana" + }, + "application/vnd.cups-raw": { + "source": "iana" + }, + "application/vnd.curl": { + "source": "iana" + }, + "application/vnd.curl.car": { + "source": "apache", + "extensions": ["car"] + }, + "application/vnd.curl.pcurl": { + "source": "apache", + "extensions": ["pcurl"] + }, + "application/vnd.cyan.dean.root+xml": { + "source": "iana" + }, + "application/vnd.cybank": { + "source": "iana" + }, + "application/vnd.dart": { + "source": "iana", + "compressible": true, + "extensions": ["dart"] + }, + "application/vnd.data-vision.rdz": { + "source": "iana", + "extensions": ["rdz"] + }, + "application/vnd.debian.binary-package": { + "source": "iana" + }, + "application/vnd.dece.data": { + "source": "iana", + "extensions": ["uvf","uvvf","uvd","uvvd"] + }, + "application/vnd.dece.ttml+xml": { + "source": "iana", + "extensions": ["uvt","uvvt"] + }, + "application/vnd.dece.unspecified": { + "source": "iana", + "extensions": ["uvx","uvvx"] + }, + "application/vnd.dece.zip": { + "source": "iana", + "extensions": ["uvz","uvvz"] + }, + "application/vnd.denovo.fcselayout-link": { + "source": "iana", + "extensions": ["fe_launch"] + }, + "application/vnd.desmume-movie": { + "source": "iana" + }, + "application/vnd.desmume.movie": { + "source": "apache" + }, + "application/vnd.dir-bi.plate-dl-nosuffix": { + "source": "iana" + }, + "application/vnd.dm.delegation+xml": { + "source": "iana" + }, + "application/vnd.dna": { + "source": "iana", + "extensions": ["dna"] + }, + "application/vnd.document+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.dolby.mlp": { + "source": "apache", + "extensions": ["mlp"] + }, + "application/vnd.dolby.mobile.1": { + "source": "iana" + }, + "application/vnd.dolby.mobile.2": { + "source": "iana" + }, + "application/vnd.doremir.scorecloud-binary-document": { + "source": "iana" + }, + "application/vnd.dpgraph": { + "source": "iana", + "extensions": ["dpg"] + }, + "application/vnd.dreamfactory": { + "source": "iana", + "extensions": ["dfac"] + }, + "application/vnd.drive+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.ds-keypoint": { + "source": "apache", + "extensions": ["kpxx"] + }, + "application/vnd.dtg.local": { + "source": "iana" + }, + "application/vnd.dtg.local.flash": { + "source": "iana" + }, + "application/vnd.dtg.local.html": { + "source": "iana" + }, + "application/vnd.dvb.ait": { + "source": "iana", + "extensions": ["ait"] + }, + "application/vnd.dvb.dvbj": { + "source": "iana" + }, + "application/vnd.dvb.esgcontainer": { + "source": "iana" + }, + "application/vnd.dvb.ipdcdftnotifaccess": { + "source": "iana" + }, + "application/vnd.dvb.ipdcesgaccess": { + "source": "iana" + }, + "application/vnd.dvb.ipdcesgaccess2": { + "source": "iana" + }, + "application/vnd.dvb.ipdcesgpdd": { + "source": "iana" + }, + "application/vnd.dvb.ipdcroaming": { + "source": "iana" + }, + "application/vnd.dvb.iptv.alfec-base": { + "source": "iana" + }, + "application/vnd.dvb.iptv.alfec-enhancement": { + "source": "iana" + }, + "application/vnd.dvb.notif-aggregate-root+xml": { + "source": "iana" + }, + "application/vnd.dvb.notif-container+xml": { + "source": "iana" + }, + "application/vnd.dvb.notif-generic+xml": { + "source": "iana" + }, + "application/vnd.dvb.notif-ia-msglist+xml": { + "source": "iana" + }, + "application/vnd.dvb.notif-ia-registration-request+xml": { + "source": "iana" + }, + "application/vnd.dvb.notif-ia-registration-response+xml": { + "source": "iana" + }, + "application/vnd.dvb.notif-init+xml": { + "source": "iana" + }, + "application/vnd.dvb.pfr": { + "source": "iana" + }, + "application/vnd.dvb.service": { + "source": "iana", + "extensions": ["svc"] + }, + "application/vnd.dxr": { + "source": "iana" + }, + "application/vnd.dynageo": { + "source": "iana", + "extensions": ["geo"] + }, + "application/vnd.dzr": { + "source": "iana" + }, + "application/vnd.easykaraoke.cdgdownload": { + "source": "iana" + }, + "application/vnd.ecdis-update": { + "source": "iana" + }, + "application/vnd.ecowin.chart": { + "source": "iana", + "extensions": ["mag"] + }, + "application/vnd.ecowin.filerequest": { + "source": "iana" + }, + "application/vnd.ecowin.fileupdate": { + "source": "iana" + }, + "application/vnd.ecowin.series": { + "source": "iana" + }, + "application/vnd.ecowin.seriesrequest": { + "source": "iana" + }, + "application/vnd.ecowin.seriesupdate": { + "source": "iana" + }, + "application/vnd.emclient.accessrequest+xml": { + "source": "iana" + }, + "application/vnd.enliven": { + "source": "iana", + "extensions": ["nml"] + }, + "application/vnd.enphase.envoy": { + "source": "iana" + }, + "application/vnd.eprints.data+xml": { + "source": "iana" + }, + "application/vnd.epson.esf": { + "source": "iana", + "extensions": ["esf"] + }, + "application/vnd.epson.msf": { + "source": "iana", + "extensions": ["msf"] + }, + "application/vnd.epson.quickanime": { + "source": "iana", + "extensions": ["qam"] + }, + "application/vnd.epson.salt": { + "source": "iana", + "extensions": ["slt"] + }, + "application/vnd.epson.ssf": { + "source": "iana", + "extensions": ["ssf"] + }, + "application/vnd.ericsson.quickcall": { + "source": "iana" + }, + "application/vnd.eszigno3+xml": { + "source": "iana", + "extensions": ["es3","et3"] + }, + "application/vnd.etsi.aoc+xml": { + "source": "iana" + }, + "application/vnd.etsi.asic-e+zip": { + "source": "iana" + }, + "application/vnd.etsi.asic-s+zip": { + "source": "iana" + }, + "application/vnd.etsi.cug+xml": { + "source": "iana" + }, + "application/vnd.etsi.iptvcommand+xml": { + "source": "iana" + }, + "application/vnd.etsi.iptvdiscovery+xml": { + "source": "iana" + }, + "application/vnd.etsi.iptvprofile+xml": { + "source": "iana" + }, + "application/vnd.etsi.iptvsad-bc+xml": { + "source": "iana" + }, + "application/vnd.etsi.iptvsad-cod+xml": { + "source": "iana" + }, + "application/vnd.etsi.iptvsad-npvr+xml": { + "source": "iana" + }, + "application/vnd.etsi.iptvservice+xml": { + "source": "iana" + }, + "application/vnd.etsi.iptvsync+xml": { + "source": "iana" + }, + "application/vnd.etsi.iptvueprofile+xml": { + "source": "iana" + }, + "application/vnd.etsi.mcid+xml": { + "source": "iana" + }, + "application/vnd.etsi.mheg5": { + "source": "iana" + }, + "application/vnd.etsi.overload-control-policy-dataset+xml": { + "source": "iana" + }, + "application/vnd.etsi.pstn+xml": { + "source": "iana" + }, + "application/vnd.etsi.sci+xml": { + "source": "iana" + }, + "application/vnd.etsi.simservs+xml": { + "source": "iana" + }, + "application/vnd.etsi.timestamp-token": { + "source": "iana" + }, + "application/vnd.etsi.tsl+xml": { + "source": "iana" + }, + "application/vnd.etsi.tsl.der": { + "source": "iana" + }, + "application/vnd.eudora.data": { + "source": "iana" + }, + "application/vnd.ezpix-album": { + "source": "iana", + "extensions": ["ez2"] + }, + "application/vnd.ezpix-package": { + "source": "iana", + "extensions": ["ez3"] + }, + "application/vnd.f-secure.mobile": { + "source": "iana" + }, + "application/vnd.fastcopy-disk-image": { + "source": "iana" + }, + "application/vnd.fdf": { + "source": "iana", + "extensions": ["fdf"] + }, + "application/vnd.fdsn.mseed": { + "source": "iana", + "extensions": ["mseed"] + }, + "application/vnd.fdsn.seed": { + "source": "iana", + "extensions": ["seed","dataless"] + }, + "application/vnd.ffsns": { + "source": "iana" + }, + "application/vnd.filmit.zfc": { + "source": "iana" + }, + "application/vnd.fints": { + "source": "iana" + }, + "application/vnd.firemonkeys.cloudcell": { + "source": "iana" + }, + "application/vnd.flographit": { + "source": "iana", + "extensions": ["gph"] + }, + "application/vnd.fluxtime.clip": { + "source": "iana", + "extensions": ["ftc"] + }, + "application/vnd.font-fontforge-sfd": { + "source": "iana" + }, + "application/vnd.framemaker": { + "source": "iana", + "extensions": ["fm","frame","maker","book"] + }, + "application/vnd.frogans.fnc": { + "source": "iana", + "extensions": ["fnc"] + }, + "application/vnd.frogans.ltf": { + "source": "iana", + "extensions": ["ltf"] + }, + "application/vnd.fsc.weblaunch": { + "source": "iana", + "extensions": ["fsc"] + }, + "application/vnd.fujitsu.oasys": { + "source": "iana", + "extensions": ["oas"] + }, + "application/vnd.fujitsu.oasys2": { + "source": "iana", + "extensions": ["oa2"] + }, + "application/vnd.fujitsu.oasys3": { + "source": "iana", + "extensions": ["oa3"] + }, + "application/vnd.fujitsu.oasysgp": { + "source": "iana", + "extensions": ["fg5"] + }, + "application/vnd.fujitsu.oasysprs": { + "source": "iana", + "extensions": ["bh2"] + }, + "application/vnd.fujixerox.art-ex": { + "source": "iana" + }, + "application/vnd.fujixerox.art4": { + "source": "iana" + }, + "application/vnd.fujixerox.ddd": { + "source": "iana", + "extensions": ["ddd"] + }, + "application/vnd.fujixerox.docuworks": { + "source": "iana", + "extensions": ["xdw"] + }, + "application/vnd.fujixerox.docuworks.binder": { + "source": "iana", + "extensions": ["xbd"] + }, + "application/vnd.fujixerox.docuworks.container": { + "source": "iana" + }, + "application/vnd.fujixerox.hbpl": { + "source": "iana" + }, + "application/vnd.fut-misnet": { + "source": "iana" + }, + "application/vnd.fuzzysheet": { + "source": "iana", + "extensions": ["fzs"] + }, + "application/vnd.genomatix.tuxedo": { + "source": "iana", + "extensions": ["txd"] + }, + "application/vnd.geo+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.geocube+xml": { + "source": "iana" + }, + "application/vnd.geogebra.file": { + "source": "iana", + "extensions": ["ggb"] + }, + "application/vnd.geogebra.tool": { + "source": "iana", + "extensions": ["ggt"] + }, + "application/vnd.geometry-explorer": { + "source": "iana", + "extensions": ["gex","gre"] + }, + "application/vnd.geonext": { + "source": "iana", + "extensions": ["gxt"] + }, + "application/vnd.geoplan": { + "source": "iana", + "extensions": ["g2w"] + }, + "application/vnd.geospace": { + "source": "iana", + "extensions": ["g3w"] + }, + "application/vnd.gerber": { + "source": "iana" + }, + "application/vnd.globalplatform.card-content-mgt": { + "source": "iana" + }, + "application/vnd.globalplatform.card-content-mgt-response": { + "source": "iana" + }, + "application/vnd.gmx": { + "source": "iana", + "extensions": ["gmx"] + }, + "application/vnd.google-apps.document": { + "compressible": false, + "extensions": ["gdoc"] + }, + "application/vnd.google-apps.presentation": { + "compressible": false, + "extensions": ["gslides"] + }, + "application/vnd.google-apps.spreadsheet": { + "compressible": false, + "extensions": ["gsheet"] + }, + "application/vnd.google-earth.kml+xml": { + "source": "iana", + "compressible": true, + "extensions": ["kml"] + }, + "application/vnd.google-earth.kmz": { + "source": "iana", + "compressible": false, + "extensions": ["kmz"] + }, + "application/vnd.gov.sk.e-form+xml": { + "source": "iana" + }, + "application/vnd.gov.sk.e-form+zip": { + "source": "iana" + }, + "application/vnd.gov.sk.xmldatacontainer+xml": { + "source": "iana" + }, + "application/vnd.grafeq": { + "source": "iana", + "extensions": ["gqf","gqs"] + }, + "application/vnd.gridmp": { + "source": "iana" + }, + "application/vnd.groove-account": { + "source": "iana", + "extensions": ["gac"] + }, + "application/vnd.groove-help": { + "source": "iana", + "extensions": ["ghf"] + }, + "application/vnd.groove-identity-message": { + "source": "iana", + "extensions": ["gim"] + }, + "application/vnd.groove-injector": { + "source": "iana", + "extensions": ["grv"] + }, + "application/vnd.groove-tool-message": { + "source": "iana", + "extensions": ["gtm"] + }, + "application/vnd.groove-tool-template": { + "source": "iana", + "extensions": ["tpl"] + }, + "application/vnd.groove-vcard": { + "source": "iana", + "extensions": ["vcg"] + }, + "application/vnd.hal+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.hal+xml": { + "source": "iana", + "extensions": ["hal"] + }, + "application/vnd.handheld-entertainment+xml": { + "source": "iana", + "extensions": ["zmm"] + }, + "application/vnd.hbci": { + "source": "iana", + "extensions": ["hbci"] + }, + "application/vnd.hcl-bireports": { + "source": "iana" + }, + "application/vnd.hdt": { + "source": "iana" + }, + "application/vnd.heroku+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.hhe.lesson-player": { + "source": "iana", + "extensions": ["les"] + }, + "application/vnd.hp-hpgl": { + "source": "iana", + "extensions": ["hpgl"] + }, + "application/vnd.hp-hpid": { + "source": "iana", + "extensions": ["hpid"] + }, + "application/vnd.hp-hps": { + "source": "iana", + "extensions": ["hps"] + }, + "application/vnd.hp-jlyt": { + "source": "iana", + "extensions": ["jlt"] + }, + "application/vnd.hp-pcl": { + "source": "iana", + "extensions": ["pcl"] + }, + "application/vnd.hp-pclxl": { + "source": "iana", + "extensions": ["pclxl"] + }, + "application/vnd.httphone": { + "source": "iana" + }, + "application/vnd.hydrostatix.sof-data": { + "source": "iana", + "extensions": ["sfd-hdstx"] + }, + "application/vnd.hyperdrive+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.hzn-3d-crossword": { + "source": "iana" + }, + "application/vnd.ibm.afplinedata": { + "source": "iana" + }, + "application/vnd.ibm.electronic-media": { + "source": "iana" + }, + "application/vnd.ibm.minipay": { + "source": "iana", + "extensions": ["mpy"] + }, + "application/vnd.ibm.modcap": { + "source": "iana", + "extensions": ["afp","listafp","list3820"] + }, + "application/vnd.ibm.rights-management": { + "source": "iana", + "extensions": ["irm"] + }, + "application/vnd.ibm.secure-container": { + "source": "iana", + "extensions": ["sc"] + }, + "application/vnd.iccprofile": { + "source": "iana", + "extensions": ["icc","icm"] + }, + "application/vnd.ieee.1905": { + "source": "iana" + }, + "application/vnd.igloader": { + "source": "iana", + "extensions": ["igl"] + }, + "application/vnd.immervision-ivp": { + "source": "iana", + "extensions": ["ivp"] + }, + "application/vnd.immervision-ivu": { + "source": "iana", + "extensions": ["ivu"] + }, + "application/vnd.ims.imsccv1p1": { + "source": "iana" + }, + "application/vnd.ims.imsccv1p2": { + "source": "iana" + }, + "application/vnd.ims.imsccv1p3": { + "source": "iana" + }, + "application/vnd.ims.lis.v2.result+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.ims.lti.v2.toolconsumerprofile+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.ims.lti.v2.toolproxy+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.ims.lti.v2.toolproxy.id+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.ims.lti.v2.toolsettings+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.ims.lti.v2.toolsettings.simple+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.informedcontrol.rms+xml": { + "source": "iana" + }, + "application/vnd.informix-visionary": { + "source": "iana" + }, + "application/vnd.infotech.project": { + "source": "iana" + }, + "application/vnd.infotech.project+xml": { + "source": "iana" + }, + "application/vnd.innopath.wamp.notification": { + "source": "iana" + }, + "application/vnd.insors.igm": { + "source": "iana", + "extensions": ["igm"] + }, + "application/vnd.intercon.formnet": { + "source": "iana", + "extensions": ["xpw","xpx"] + }, + "application/vnd.intergeo": { + "source": "iana", + "extensions": ["i2g"] + }, + "application/vnd.intertrust.digibox": { + "source": "iana" + }, + "application/vnd.intertrust.nncp": { + "source": "iana" + }, + "application/vnd.intu.qbo": { + "source": "iana", + "extensions": ["qbo"] + }, + "application/vnd.intu.qfx": { + "source": "iana", + "extensions": ["qfx"] + }, + "application/vnd.iptc.g2.catalogitem+xml": { + "source": "iana" + }, + "application/vnd.iptc.g2.conceptitem+xml": { + "source": "iana" + }, + "application/vnd.iptc.g2.knowledgeitem+xml": { + "source": "iana" + }, + "application/vnd.iptc.g2.newsitem+xml": { + "source": "iana" + }, + "application/vnd.iptc.g2.newsmessage+xml": { + "source": "iana" + }, + "application/vnd.iptc.g2.packageitem+xml": { + "source": "iana" + }, + "application/vnd.iptc.g2.planningitem+xml": { + "source": "iana" + }, + "application/vnd.ipunplugged.rcprofile": { + "source": "iana", + "extensions": ["rcprofile"] + }, + "application/vnd.irepository.package+xml": { + "source": "iana", + "extensions": ["irp"] + }, + "application/vnd.is-xpr": { + "source": "iana", + "extensions": ["xpr"] + }, + "application/vnd.isac.fcs": { + "source": "iana", + "extensions": ["fcs"] + }, + "application/vnd.jam": { + "source": "iana", + "extensions": ["jam"] + }, + "application/vnd.japannet-directory-service": { + "source": "iana" + }, + "application/vnd.japannet-jpnstore-wakeup": { + "source": "iana" + }, + "application/vnd.japannet-payment-wakeup": { + "source": "iana" + }, + "application/vnd.japannet-registration": { + "source": "iana" + }, + "application/vnd.japannet-registration-wakeup": { + "source": "iana" + }, + "application/vnd.japannet-setstore-wakeup": { + "source": "iana" + }, + "application/vnd.japannet-verification": { + "source": "iana" + }, + "application/vnd.japannet-verification-wakeup": { + "source": "iana" + }, + "application/vnd.jcp.javame.midlet-rms": { + "source": "iana", + "extensions": ["rms"] + }, + "application/vnd.jisp": { + "source": "iana", + "extensions": ["jisp"] + }, + "application/vnd.joost.joda-archive": { + "source": "iana", + "extensions": ["joda"] + }, + "application/vnd.jsk.isdn-ngn": { + "source": "iana" + }, + "application/vnd.kahootz": { + "source": "iana", + "extensions": ["ktz","ktr"] + }, + "application/vnd.kde.karbon": { + "source": "iana", + "extensions": ["karbon"] + }, + "application/vnd.kde.kchart": { + "source": "iana", + "extensions": ["chrt"] + }, + "application/vnd.kde.kformula": { + "source": "iana", + "extensions": ["kfo"] + }, + "application/vnd.kde.kivio": { + "source": "iana", + "extensions": ["flw"] + }, + "application/vnd.kde.kontour": { + "source": "iana", + "extensions": ["kon"] + }, + "application/vnd.kde.kpresenter": { + "source": "iana", + "extensions": ["kpr","kpt"] + }, + "application/vnd.kde.kspread": { + "source": "iana", + "extensions": ["ksp"] + }, + "application/vnd.kde.kword": { + "source": "iana", + "extensions": ["kwd","kwt"] + }, + "application/vnd.kenameaapp": { + "source": "iana", + "extensions": ["htke"] + }, + "application/vnd.kidspiration": { + "source": "iana", + "extensions": ["kia"] + }, + "application/vnd.kinar": { + "source": "iana", + "extensions": ["kne","knp"] + }, + "application/vnd.koan": { + "source": "iana", + "extensions": ["skp","skd","skt","skm"] + }, + "application/vnd.kodak-descriptor": { + "source": "iana", + "extensions": ["sse"] + }, + "application/vnd.las.las+xml": { + "source": "iana", + "extensions": ["lasxml"] + }, + "application/vnd.liberty-request+xml": { + "source": "iana" + }, + "application/vnd.llamagraphics.life-balance.desktop": { + "source": "iana", + "extensions": ["lbd"] + }, + "application/vnd.llamagraphics.life-balance.exchange+xml": { + "source": "iana", + "extensions": ["lbe"] + }, + "application/vnd.lotus-1-2-3": { + "source": "iana", + "extensions": ["123"] + }, + "application/vnd.lotus-approach": { + "source": "iana", + "extensions": ["apr"] + }, + "application/vnd.lotus-freelance": { + "source": "iana", + "extensions": ["pre"] + }, + "application/vnd.lotus-notes": { + "source": "iana", + "extensions": ["nsf"] + }, + "application/vnd.lotus-organizer": { + "source": "iana", + "extensions": ["org"] + }, + "application/vnd.lotus-screencam": { + "source": "iana", + "extensions": ["scm"] + }, + "application/vnd.lotus-wordpro": { + "source": "iana", + "extensions": ["lwp"] + }, + "application/vnd.macports.portpkg": { + "source": "iana", + "extensions": ["portpkg"] + }, + "application/vnd.mapbox-vector-tile": { + "source": "iana" + }, + "application/vnd.marlin.drm.actiontoken+xml": { + "source": "iana" + }, + "application/vnd.marlin.drm.conftoken+xml": { + "source": "iana" + }, + "application/vnd.marlin.drm.license+xml": { + "source": "iana" + }, + "application/vnd.marlin.drm.mdcf": { + "source": "iana" + }, + "application/vnd.mason+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.maxmind.maxmind-db": { + "source": "iana" + }, + "application/vnd.mcd": { + "source": "iana", + "extensions": ["mcd"] + }, + "application/vnd.medcalcdata": { + "source": "iana", + "extensions": ["mc1"] + }, + "application/vnd.mediastation.cdkey": { + "source": "iana", + "extensions": ["cdkey"] + }, + "application/vnd.meridian-slingshot": { + "source": "iana" + }, + "application/vnd.mfer": { + "source": "iana", + "extensions": ["mwf"] + }, + "application/vnd.mfmp": { + "source": "iana", + "extensions": ["mfm"] + }, + "application/vnd.micro+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.micrografx.flo": { + "source": "iana", + "extensions": ["flo"] + }, + "application/vnd.micrografx.igx": { + "source": "iana", + "extensions": ["igx"] + }, + "application/vnd.microsoft.portable-executable": { + "source": "iana" + }, + "application/vnd.miele+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.mif": { + "source": "iana", + "extensions": ["mif"] + }, + "application/vnd.minisoft-hp3000-save": { + "source": "iana" + }, + "application/vnd.mitsubishi.misty-guard.trustweb": { + "source": "iana" + }, + "application/vnd.mobius.daf": { + "source": "iana", + "extensions": ["daf"] + }, + "application/vnd.mobius.dis": { + "source": "iana", + "extensions": ["dis"] + }, + "application/vnd.mobius.mbk": { + "source": "iana", + "extensions": ["mbk"] + }, + "application/vnd.mobius.mqy": { + "source": "iana", + "extensions": ["mqy"] + }, + "application/vnd.mobius.msl": { + "source": "iana", + "extensions": ["msl"] + }, + "application/vnd.mobius.plc": { + "source": "iana", + "extensions": ["plc"] + }, + "application/vnd.mobius.txf": { + "source": "iana", + "extensions": ["txf"] + }, + "application/vnd.mophun.application": { + "source": "iana", + "extensions": ["mpn"] + }, + "application/vnd.mophun.certificate": { + "source": "iana", + "extensions": ["mpc"] + }, + "application/vnd.motorola.flexsuite": { + "source": "iana" + }, + "application/vnd.motorola.flexsuite.adsi": { + "source": "iana" + }, + "application/vnd.motorola.flexsuite.fis": { + "source": "iana" + }, + "application/vnd.motorola.flexsuite.gotap": { + "source": "iana" + }, + "application/vnd.motorola.flexsuite.kmr": { + "source": "iana" + }, + "application/vnd.motorola.flexsuite.ttc": { + "source": "iana" + }, + "application/vnd.motorola.flexsuite.wem": { + "source": "iana" + }, + "application/vnd.motorola.iprm": { + "source": "iana" + }, + "application/vnd.mozilla.xul+xml": { + "source": "iana", + "compressible": true, + "extensions": ["xul"] + }, + "application/vnd.ms-3mfdocument": { + "source": "iana" + }, + "application/vnd.ms-artgalry": { + "source": "iana", + "extensions": ["cil"] + }, + "application/vnd.ms-asf": { + "source": "iana" + }, + "application/vnd.ms-cab-compressed": { + "source": "iana", + "extensions": ["cab"] + }, + "application/vnd.ms-color.iccprofile": { + "source": "apache" + }, + "application/vnd.ms-excel": { + "source": "iana", + "compressible": false, + "extensions": ["xls","xlm","xla","xlc","xlt","xlw"] + }, + "application/vnd.ms-excel.addin.macroenabled.12": { + "source": "iana", + "extensions": ["xlam"] + }, + "application/vnd.ms-excel.sheet.binary.macroenabled.12": { + "source": "iana", + "extensions": ["xlsb"] + }, + "application/vnd.ms-excel.sheet.macroenabled.12": { + "source": "iana", + "extensions": ["xlsm"] + }, + "application/vnd.ms-excel.template.macroenabled.12": { + "source": "iana", + "extensions": ["xltm"] + }, + "application/vnd.ms-fontobject": { + "source": "iana", + "compressible": true, + "extensions": ["eot"] + }, + "application/vnd.ms-htmlhelp": { + "source": "iana", + "extensions": ["chm"] + }, + "application/vnd.ms-ims": { + "source": "iana", + "extensions": ["ims"] + }, + "application/vnd.ms-lrm": { + "source": "iana", + "extensions": ["lrm"] + }, + "application/vnd.ms-office.activex+xml": { + "source": "iana" + }, + "application/vnd.ms-officetheme": { + "source": "iana", + "extensions": ["thmx"] + }, + "application/vnd.ms-opentype": { + "source": "apache", + "compressible": true + }, + "application/vnd.ms-package.obfuscated-opentype": { + "source": "apache" + }, + "application/vnd.ms-pki.seccat": { + "source": "apache", + "extensions": ["cat"] + }, + "application/vnd.ms-pki.stl": { + "source": "apache", + "extensions": ["stl"] + }, + "application/vnd.ms-playready.initiator+xml": { + "source": "iana" + }, + "application/vnd.ms-powerpoint": { + "source": "iana", + "compressible": false, + "extensions": ["ppt","pps","pot"] + }, + "application/vnd.ms-powerpoint.addin.macroenabled.12": { + "source": "iana", + "extensions": ["ppam"] + }, + "application/vnd.ms-powerpoint.presentation.macroenabled.12": { + "source": "iana", + "extensions": ["pptm"] + }, + "application/vnd.ms-powerpoint.slide.macroenabled.12": { + "source": "iana", + "extensions": ["sldm"] + }, + "application/vnd.ms-powerpoint.slideshow.macroenabled.12": { + "source": "iana", + "extensions": ["ppsm"] + }, + "application/vnd.ms-powerpoint.template.macroenabled.12": { + "source": "iana", + "extensions": ["potm"] + }, + "application/vnd.ms-printdevicecapabilities+xml": { + "source": "iana" + }, + "application/vnd.ms-printing.printticket+xml": { + "source": "apache" + }, + "application/vnd.ms-printschematicket+xml": { + "source": "iana" + }, + "application/vnd.ms-project": { + "source": "iana", + "extensions": ["mpp","mpt"] + }, + "application/vnd.ms-tnef": { + "source": "iana" + }, + "application/vnd.ms-windows.devicepairing": { + "source": "iana" + }, + "application/vnd.ms-windows.nwprinting.oob": { + "source": "iana" + }, + "application/vnd.ms-windows.printerpairing": { + "source": "iana" + }, + "application/vnd.ms-windows.wsd.oob": { + "source": "iana" + }, + "application/vnd.ms-wmdrm.lic-chlg-req": { + "source": "iana" + }, + "application/vnd.ms-wmdrm.lic-resp": { + "source": "iana" + }, + "application/vnd.ms-wmdrm.meter-chlg-req": { + "source": "iana" + }, + "application/vnd.ms-wmdrm.meter-resp": { + "source": "iana" + }, + "application/vnd.ms-word.document.macroenabled.12": { + "source": "iana", + "extensions": ["docm"] + }, + "application/vnd.ms-word.template.macroenabled.12": { + "source": "iana", + "extensions": ["dotm"] + }, + "application/vnd.ms-works": { + "source": "iana", + "extensions": ["wps","wks","wcm","wdb"] + }, + "application/vnd.ms-wpl": { + "source": "iana", + "extensions": ["wpl"] + }, + "application/vnd.ms-xpsdocument": { + "source": "iana", + "compressible": false, + "extensions": ["xps"] + }, + "application/vnd.msa-disk-image": { + "source": "iana" + }, + "application/vnd.mseq": { + "source": "iana", + "extensions": ["mseq"] + }, + "application/vnd.msign": { + "source": "iana" + }, + "application/vnd.multiad.creator": { + "source": "iana" + }, + "application/vnd.multiad.creator.cif": { + "source": "iana" + }, + "application/vnd.music-niff": { + "source": "iana" + }, + "application/vnd.musician": { + "source": "iana", + "extensions": ["mus"] + }, + "application/vnd.muvee.style": { + "source": "iana", + "extensions": ["msty"] + }, + "application/vnd.mynfc": { + "source": "iana", + "extensions": ["taglet"] + }, + "application/vnd.ncd.control": { + "source": "iana" + }, + "application/vnd.ncd.reference": { + "source": "iana" + }, + "application/vnd.nervana": { + "source": "iana" + }, + "application/vnd.netfpx": { + "source": "iana" + }, + "application/vnd.neurolanguage.nlu": { + "source": "iana", + "extensions": ["nlu"] + }, + "application/vnd.nintendo.nitro.rom": { + "source": "iana" + }, + "application/vnd.nintendo.snes.rom": { + "source": "iana" + }, + "application/vnd.nitf": { + "source": "iana", + "extensions": ["ntf","nitf"] + }, + "application/vnd.noblenet-directory": { + "source": "iana", + "extensions": ["nnd"] + }, + "application/vnd.noblenet-sealer": { + "source": "iana", + "extensions": ["nns"] + }, + "application/vnd.noblenet-web": { + "source": "iana", + "extensions": ["nnw"] + }, + "application/vnd.nokia.catalogs": { + "source": "iana" + }, + "application/vnd.nokia.conml+wbxml": { + "source": "iana" + }, + "application/vnd.nokia.conml+xml": { + "source": "iana" + }, + "application/vnd.nokia.iptv.config+xml": { + "source": "iana" + }, + "application/vnd.nokia.isds-radio-presets": { + "source": "iana" + }, + "application/vnd.nokia.landmark+wbxml": { + "source": "iana" + }, + "application/vnd.nokia.landmark+xml": { + "source": "iana" + }, + "application/vnd.nokia.landmarkcollection+xml": { + "source": "iana" + }, + "application/vnd.nokia.n-gage.ac+xml": { + "source": "iana" + }, + "application/vnd.nokia.n-gage.data": { + "source": "iana", + "extensions": ["ngdat"] + }, + "application/vnd.nokia.n-gage.symbian.install": { + "source": "iana", + "extensions": ["n-gage"] + }, + "application/vnd.nokia.ncd": { + "source": "iana" + }, + "application/vnd.nokia.pcd+wbxml": { + "source": "iana" + }, + "application/vnd.nokia.pcd+xml": { + "source": "iana" + }, + "application/vnd.nokia.radio-preset": { + "source": "iana", + "extensions": ["rpst"] + }, + "application/vnd.nokia.radio-presets": { + "source": "iana", + "extensions": ["rpss"] + }, + "application/vnd.novadigm.edm": { + "source": "iana", + "extensions": ["edm"] + }, + "application/vnd.novadigm.edx": { + "source": "iana", + "extensions": ["edx"] + }, + "application/vnd.novadigm.ext": { + "source": "iana", + "extensions": ["ext"] + }, + "application/vnd.ntt-local.content-share": { + "source": "iana" + }, + "application/vnd.ntt-local.file-transfer": { + "source": "iana" + }, + "application/vnd.ntt-local.ogw_remote-access": { + "source": "iana" + }, + "application/vnd.ntt-local.sip-ta_remote": { + "source": "iana" + }, + "application/vnd.ntt-local.sip-ta_tcp_stream": { + "source": "iana" + }, + "application/vnd.oasis.opendocument.chart": { + "source": "iana", + "extensions": ["odc"] + }, + "application/vnd.oasis.opendocument.chart-template": { + "source": "iana", + "extensions": ["otc"] + }, + "application/vnd.oasis.opendocument.database": { + "source": "iana", + "extensions": ["odb"] + }, + "application/vnd.oasis.opendocument.formula": { + "source": "iana", + "extensions": ["odf"] + }, + "application/vnd.oasis.opendocument.formula-template": { + "source": "iana", + "extensions": ["odft"] + }, + "application/vnd.oasis.opendocument.graphics": { + "source": "iana", + "compressible": false, + "extensions": ["odg"] + }, + "application/vnd.oasis.opendocument.graphics-template": { + "source": "iana", + "extensions": ["otg"] + }, + "application/vnd.oasis.opendocument.image": { + "source": "iana", + "extensions": ["odi"] + }, + "application/vnd.oasis.opendocument.image-template": { + "source": "iana", + "extensions": ["oti"] + }, + "application/vnd.oasis.opendocument.presentation": { + "source": "iana", + "compressible": false, + "extensions": ["odp"] + }, + "application/vnd.oasis.opendocument.presentation-template": { + "source": "iana", + "extensions": ["otp"] + }, + "application/vnd.oasis.opendocument.spreadsheet": { + "source": "iana", + "compressible": false, + "extensions": ["ods"] + }, + "application/vnd.oasis.opendocument.spreadsheet-template": { + "source": "iana", + "extensions": ["ots"] + }, + "application/vnd.oasis.opendocument.text": { + "source": "iana", + "compressible": false, + "extensions": ["odt"] + }, + "application/vnd.oasis.opendocument.text-master": { + "source": "iana", + "extensions": ["odm"] + }, + "application/vnd.oasis.opendocument.text-template": { + "source": "iana", + "extensions": ["ott"] + }, + "application/vnd.oasis.opendocument.text-web": { + "source": "iana", + "extensions": ["oth"] + }, + "application/vnd.obn": { + "source": "iana" + }, + "application/vnd.oftn.l10n+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.oipf.contentaccessdownload+xml": { + "source": "iana" + }, + "application/vnd.oipf.contentaccessstreaming+xml": { + "source": "iana" + }, + "application/vnd.oipf.cspg-hexbinary": { + "source": "iana" + }, + "application/vnd.oipf.dae.svg+xml": { + "source": "iana" + }, + "application/vnd.oipf.dae.xhtml+xml": { + "source": "iana" + }, + "application/vnd.oipf.mippvcontrolmessage+xml": { + "source": "iana" + }, + "application/vnd.oipf.pae.gem": { + "source": "iana" + }, + "application/vnd.oipf.spdiscovery+xml": { + "source": "iana" + }, + "application/vnd.oipf.spdlist+xml": { + "source": "iana" + }, + "application/vnd.oipf.ueprofile+xml": { + "source": "iana" + }, + "application/vnd.oipf.userprofile+xml": { + "source": "iana" + }, + "application/vnd.olpc-sugar": { + "source": "iana", + "extensions": ["xo"] + }, + "application/vnd.oma-scws-config": { + "source": "iana" + }, + "application/vnd.oma-scws-http-request": { + "source": "iana" + }, + "application/vnd.oma-scws-http-response": { + "source": "iana" + }, + "application/vnd.oma.bcast.associated-procedure-parameter+xml": { + "source": "iana" + }, + "application/vnd.oma.bcast.drm-trigger+xml": { + "source": "iana" + }, + "application/vnd.oma.bcast.imd+xml": { + "source": "iana" + }, + "application/vnd.oma.bcast.ltkm": { + "source": "iana" + }, + "application/vnd.oma.bcast.notification+xml": { + "source": "iana" + }, + "application/vnd.oma.bcast.provisioningtrigger": { + "source": "iana" + }, + "application/vnd.oma.bcast.sgboot": { + "source": "iana" + }, + "application/vnd.oma.bcast.sgdd+xml": { + "source": "iana" + }, + "application/vnd.oma.bcast.sgdu": { + "source": "iana" + }, + "application/vnd.oma.bcast.simple-symbol-container": { + "source": "iana" + }, + "application/vnd.oma.bcast.smartcard-trigger+xml": { + "source": "iana" + }, + "application/vnd.oma.bcast.sprov+xml": { + "source": "iana" + }, + "application/vnd.oma.bcast.stkm": { + "source": "iana" + }, + "application/vnd.oma.cab-address-book+xml": { + "source": "iana" + }, + "application/vnd.oma.cab-feature-handler+xml": { + "source": "iana" + }, + "application/vnd.oma.cab-pcc+xml": { + "source": "iana" + }, + "application/vnd.oma.cab-subs-invite+xml": { + "source": "iana" + }, + "application/vnd.oma.cab-user-prefs+xml": { + "source": "iana" + }, + "application/vnd.oma.dcd": { + "source": "iana" + }, + "application/vnd.oma.dcdc": { + "source": "iana" + }, + "application/vnd.oma.dd2+xml": { + "source": "iana", + "extensions": ["dd2"] + }, + "application/vnd.oma.drm.risd+xml": { + "source": "iana" + }, + "application/vnd.oma.group-usage-list+xml": { + "source": "iana" + }, + "application/vnd.oma.pal+xml": { + "source": "iana" + }, + "application/vnd.oma.poc.detailed-progress-report+xml": { + "source": "iana" + }, + "application/vnd.oma.poc.final-report+xml": { + "source": "iana" + }, + "application/vnd.oma.poc.groups+xml": { + "source": "iana" + }, + "application/vnd.oma.poc.invocation-descriptor+xml": { + "source": "iana" + }, + "application/vnd.oma.poc.optimized-progress-report+xml": { + "source": "iana" + }, + "application/vnd.oma.push": { + "source": "iana" + }, + "application/vnd.oma.scidm.messages+xml": { + "source": "iana" + }, + "application/vnd.oma.xcap-directory+xml": { + "source": "iana" + }, + "application/vnd.omads-email+xml": { + "source": "iana" + }, + "application/vnd.omads-file+xml": { + "source": "iana" + }, + "application/vnd.omads-folder+xml": { + "source": "iana" + }, + "application/vnd.omaloc-supl-init": { + "source": "iana" + }, + "application/vnd.onepager": { + "source": "iana" + }, + "application/vnd.openblox.game+xml": { + "source": "iana" + }, + "application/vnd.openblox.game-binary": { + "source": "iana" + }, + "application/vnd.openeye.oeb": { + "source": "iana" + }, + "application/vnd.openofficeorg.extension": { + "source": "apache", + "extensions": ["oxt"] + }, + "application/vnd.openxmlformats-officedocument.custom-properties+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.customxmlproperties+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.drawing+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.drawingml.chart+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.drawingml.diagramcolors+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.drawingml.diagramdata+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.drawingml.diagramlayout+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.drawingml.diagramstyle+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.extended-properties+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml-template": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.commentauthors+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.comments+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.handoutmaster+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.notesmaster+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.notesslide+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.presentation": { + "source": "iana", + "compressible": false, + "extensions": ["pptx"] + }, + "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.presprops+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.slide": { + "source": "iana", + "extensions": ["sldx"] + }, + "application/vnd.openxmlformats-officedocument.presentationml.slide+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.slidelayout+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.slidemaster+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.slideshow": { + "source": "iana", + "extensions": ["ppsx"] + }, + "application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.slideupdateinfo+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.tablestyles+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.tags+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.template": { + "source": "apache", + "extensions": ["potx"] + }, + "application/vnd.openxmlformats-officedocument.presentationml.template.main+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.presentationml.viewprops+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml-template": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.calcchain+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.externallink+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcachedefinition+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcacherecords+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.pivottable+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.querytable+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.revisionheaders+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.revisionlog+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedstrings+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": { + "source": "iana", + "compressible": false, + "extensions": ["xlsx"] + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheetmetadata+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.tablesinglecells+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.template": { + "source": "apache", + "extensions": ["xltx"] + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.usernames+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.volatiledependencies+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.theme+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.themeoverride+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.vmldrawing": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml-template": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.document": { + "source": "iana", + "compressible": false, + "extensions": ["docx"] + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.fonttable+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.template": { + "source": "apache", + "extensions": ["dotx"] + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.websettings+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-package.core-properties+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml": { + "source": "iana" + }, + "application/vnd.openxmlformats-package.relationships+xml": { + "source": "iana" + }, + "application/vnd.oracle.resource+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.orange.indata": { + "source": "iana" + }, + "application/vnd.osa.netdeploy": { + "source": "iana" + }, + "application/vnd.osgeo.mapguide.package": { + "source": "iana", + "extensions": ["mgp"] + }, + "application/vnd.osgi.bundle": { + "source": "iana" + }, + "application/vnd.osgi.dp": { + "source": "iana", + "extensions": ["dp"] + }, + "application/vnd.osgi.subsystem": { + "source": "iana", + "extensions": ["esa"] + }, + "application/vnd.otps.ct-kip+xml": { + "source": "iana" + }, + "application/vnd.oxli.countgraph": { + "source": "iana" + }, + "application/vnd.pagerduty+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.palm": { + "source": "iana", + "extensions": ["pdb","pqa","oprc"] + }, + "application/vnd.panoply": { + "source": "iana" + }, + "application/vnd.paos+xml": { + "source": "iana" + }, + "application/vnd.paos.xml": { + "source": "apache" + }, + "application/vnd.pawaafile": { + "source": "iana", + "extensions": ["paw"] + }, + "application/vnd.pcos": { + "source": "iana" + }, + "application/vnd.pg.format": { + "source": "iana", + "extensions": ["str"] + }, + "application/vnd.pg.osasli": { + "source": "iana", + "extensions": ["ei6"] + }, + "application/vnd.piaccess.application-licence": { + "source": "iana" + }, + "application/vnd.picsel": { + "source": "iana", + "extensions": ["efif"] + }, + "application/vnd.pmi.widget": { + "source": "iana", + "extensions": ["wg"] + }, + "application/vnd.poc.group-advertisement+xml": { + "source": "iana" + }, + "application/vnd.pocketlearn": { + "source": "iana", + "extensions": ["plf"] + }, + "application/vnd.powerbuilder6": { + "source": "iana", + "extensions": ["pbd"] + }, + "application/vnd.powerbuilder6-s": { + "source": "iana" + }, + "application/vnd.powerbuilder7": { + "source": "iana" + }, + "application/vnd.powerbuilder7-s": { + "source": "iana" + }, + "application/vnd.powerbuilder75": { + "source": "iana" + }, + "application/vnd.powerbuilder75-s": { + "source": "iana" + }, + "application/vnd.preminet": { + "source": "iana" + }, + "application/vnd.previewsystems.box": { + "source": "iana", + "extensions": ["box"] + }, + "application/vnd.proteus.magazine": { + "source": "iana", + "extensions": ["mgz"] + }, + "application/vnd.publishare-delta-tree": { + "source": "iana", + "extensions": ["qps"] + }, + "application/vnd.pvi.ptid1": { + "source": "iana", + "extensions": ["ptid"] + }, + "application/vnd.pwg-multiplexed": { + "source": "iana" + }, + "application/vnd.pwg-xhtml-print+xml": { + "source": "iana" + }, + "application/vnd.qualcomm.brew-app-res": { + "source": "iana" + }, + "application/vnd.quark.quarkxpress": { + "source": "iana", + "extensions": ["qxd","qxt","qwd","qwt","qxl","qxb"] + }, + "application/vnd.quobject-quoxdocument": { + "source": "iana" + }, + "application/vnd.radisys.moml+xml": { + "source": "iana" + }, + "application/vnd.radisys.msml+xml": { + "source": "iana" + }, + "application/vnd.radisys.msml-audit+xml": { + "source": "iana" + }, + "application/vnd.radisys.msml-audit-conf+xml": { + "source": "iana" + }, + "application/vnd.radisys.msml-audit-conn+xml": { + "source": "iana" + }, + "application/vnd.radisys.msml-audit-dialog+xml": { + "source": "iana" + }, + "application/vnd.radisys.msml-audit-stream+xml": { + "source": "iana" + }, + "application/vnd.radisys.msml-conf+xml": { + "source": "iana" + }, + "application/vnd.radisys.msml-dialog+xml": { + "source": "iana" + }, + "application/vnd.radisys.msml-dialog-base+xml": { + "source": "iana" + }, + "application/vnd.radisys.msml-dialog-fax-detect+xml": { + "source": "iana" + }, + "application/vnd.radisys.msml-dialog-fax-sendrecv+xml": { + "source": "iana" + }, + "application/vnd.radisys.msml-dialog-group+xml": { + "source": "iana" + }, + "application/vnd.radisys.msml-dialog-speech+xml": { + "source": "iana" + }, + "application/vnd.radisys.msml-dialog-transform+xml": { + "source": "iana" + }, + "application/vnd.rainstor.data": { + "source": "iana" + }, + "application/vnd.rapid": { + "source": "iana" + }, + "application/vnd.realvnc.bed": { + "source": "iana", + "extensions": ["bed"] + }, + "application/vnd.recordare.musicxml": { + "source": "iana", + "extensions": ["mxl"] + }, + "application/vnd.recordare.musicxml+xml": { + "source": "iana", + "extensions": ["musicxml"] + }, + "application/vnd.renlearn.rlprint": { + "source": "iana" + }, + "application/vnd.rig.cryptonote": { + "source": "iana", + "extensions": ["cryptonote"] + }, + "application/vnd.rim.cod": { + "source": "apache", + "extensions": ["cod"] + }, + "application/vnd.rn-realmedia": { + "source": "apache", + "extensions": ["rm"] + }, + "application/vnd.rn-realmedia-vbr": { + "source": "apache", + "extensions": ["rmvb"] + }, + "application/vnd.route66.link66+xml": { + "source": "iana", + "extensions": ["link66"] + }, + "application/vnd.rs-274x": { + "source": "iana" + }, + "application/vnd.ruckus.download": { + "source": "iana" + }, + "application/vnd.s3sms": { + "source": "iana" + }, + "application/vnd.sailingtracker.track": { + "source": "iana", + "extensions": ["st"] + }, + "application/vnd.sbm.cid": { + "source": "iana" + }, + "application/vnd.sbm.mid2": { + "source": "iana" + }, + "application/vnd.scribus": { + "source": "iana" + }, + "application/vnd.sealed.3df": { + "source": "iana" + }, + "application/vnd.sealed.csf": { + "source": "iana" + }, + "application/vnd.sealed.doc": { + "source": "iana" + }, + "application/vnd.sealed.eml": { + "source": "iana" + }, + "application/vnd.sealed.mht": { + "source": "iana" + }, + "application/vnd.sealed.net": { + "source": "iana" + }, + "application/vnd.sealed.ppt": { + "source": "iana" + }, + "application/vnd.sealed.tiff": { + "source": "iana" + }, + "application/vnd.sealed.xls": { + "source": "iana" + }, + "application/vnd.sealedmedia.softseal.html": { + "source": "iana" + }, + "application/vnd.sealedmedia.softseal.pdf": { + "source": "iana" + }, + "application/vnd.seemail": { + "source": "iana", + "extensions": ["see"] + }, + "application/vnd.sema": { + "source": "iana", + "extensions": ["sema"] + }, + "application/vnd.semd": { + "source": "iana", + "extensions": ["semd"] + }, + "application/vnd.semf": { + "source": "iana", + "extensions": ["semf"] + }, + "application/vnd.shana.informed.formdata": { + "source": "iana", + "extensions": ["ifm"] + }, + "application/vnd.shana.informed.formtemplate": { + "source": "iana", + "extensions": ["itp"] + }, + "application/vnd.shana.informed.interchange": { + "source": "iana", + "extensions": ["iif"] + }, + "application/vnd.shana.informed.package": { + "source": "iana", + "extensions": ["ipk"] + }, + "application/vnd.simtech-mindmapper": { + "source": "iana", + "extensions": ["twd","twds"] + }, + "application/vnd.siren+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.smaf": { + "source": "iana", + "extensions": ["mmf"] + }, + "application/vnd.smart.notebook": { + "source": "iana" + }, + "application/vnd.smart.teacher": { + "source": "iana", + "extensions": ["teacher"] + }, + "application/vnd.software602.filler.form+xml": { + "source": "iana" + }, + "application/vnd.software602.filler.form-xml-zip": { + "source": "iana" + }, + "application/vnd.solent.sdkm+xml": { + "source": "iana", + "extensions": ["sdkm","sdkd"] + }, + "application/vnd.spotfire.dxp": { + "source": "iana", + "extensions": ["dxp"] + }, + "application/vnd.spotfire.sfs": { + "source": "iana", + "extensions": ["sfs"] + }, + "application/vnd.sss-cod": { + "source": "iana" + }, + "application/vnd.sss-dtf": { + "source": "iana" + }, + "application/vnd.sss-ntf": { + "source": "iana" + }, + "application/vnd.stardivision.calc": { + "source": "apache", + "extensions": ["sdc"] + }, + "application/vnd.stardivision.draw": { + "source": "apache", + "extensions": ["sda"] + }, + "application/vnd.stardivision.impress": { + "source": "apache", + "extensions": ["sdd"] + }, + "application/vnd.stardivision.math": { + "source": "apache", + "extensions": ["smf"] + }, + "application/vnd.stardivision.writer": { + "source": "apache", + "extensions": ["sdw","vor"] + }, + "application/vnd.stardivision.writer-global": { + "source": "apache", + "extensions": ["sgl"] + }, + "application/vnd.stepmania.package": { + "source": "iana", + "extensions": ["smzip"] + }, + "application/vnd.stepmania.stepchart": { + "source": "iana", + "extensions": ["sm"] + }, + "application/vnd.street-stream": { + "source": "iana" + }, + "application/vnd.sun.wadl+xml": { + "source": "iana" + }, + "application/vnd.sun.xml.calc": { + "source": "apache", + "extensions": ["sxc"] + }, + "application/vnd.sun.xml.calc.template": { + "source": "apache", + "extensions": ["stc"] + }, + "application/vnd.sun.xml.draw": { + "source": "apache", + "extensions": ["sxd"] + }, + "application/vnd.sun.xml.draw.template": { + "source": "apache", + "extensions": ["std"] + }, + "application/vnd.sun.xml.impress": { + "source": "apache", + "extensions": ["sxi"] + }, + "application/vnd.sun.xml.impress.template": { + "source": "apache", + "extensions": ["sti"] + }, + "application/vnd.sun.xml.math": { + "source": "apache", + "extensions": ["sxm"] + }, + "application/vnd.sun.xml.writer": { + "source": "apache", + "extensions": ["sxw"] + }, + "application/vnd.sun.xml.writer.global": { + "source": "apache", + "extensions": ["sxg"] + }, + "application/vnd.sun.xml.writer.template": { + "source": "apache", + "extensions": ["stw"] + }, + "application/vnd.sus-calendar": { + "source": "iana", + "extensions": ["sus","susp"] + }, + "application/vnd.svd": { + "source": "iana", + "extensions": ["svd"] + }, + "application/vnd.swiftview-ics": { + "source": "iana" + }, + "application/vnd.symbian.install": { + "source": "apache", + "extensions": ["sis","sisx"] + }, + "application/vnd.syncml+xml": { + "source": "iana", + "extensions": ["xsm"] + }, + "application/vnd.syncml.dm+wbxml": { + "source": "iana", + "extensions": ["bdm"] + }, + "application/vnd.syncml.dm+xml": { + "source": "iana", + "extensions": ["xdm"] + }, + "application/vnd.syncml.dm.notification": { + "source": "iana" + }, + "application/vnd.syncml.dmddf+wbxml": { + "source": "iana" + }, + "application/vnd.syncml.dmddf+xml": { + "source": "iana" + }, + "application/vnd.syncml.dmtnds+wbxml": { + "source": "iana" + }, + "application/vnd.syncml.dmtnds+xml": { + "source": "iana" + }, + "application/vnd.syncml.ds.notification": { + "source": "iana" + }, + "application/vnd.tao.intent-module-archive": { + "source": "iana", + "extensions": ["tao"] + }, + "application/vnd.tcpdump.pcap": { + "source": "iana", + "extensions": ["pcap","cap","dmp"] + }, + "application/vnd.tmd.mediaflex.api+xml": { + "source": "iana" + }, + "application/vnd.tml": { + "source": "iana" + }, + "application/vnd.tmobile-livetv": { + "source": "iana", + "extensions": ["tmo"] + }, + "application/vnd.trid.tpt": { + "source": "iana", + "extensions": ["tpt"] + }, + "application/vnd.triscape.mxs": { + "source": "iana", + "extensions": ["mxs"] + }, + "application/vnd.trueapp": { + "source": "iana", + "extensions": ["tra"] + }, + "application/vnd.truedoc": { + "source": "iana" + }, + "application/vnd.ubisoft.webplayer": { + "source": "iana" + }, + "application/vnd.ufdl": { + "source": "iana", + "extensions": ["ufd","ufdl"] + }, + "application/vnd.uiq.theme": { + "source": "iana", + "extensions": ["utz"] + }, + "application/vnd.umajin": { + "source": "iana", + "extensions": ["umj"] + }, + "application/vnd.unity": { + "source": "iana", + "extensions": ["unityweb"] + }, + "application/vnd.uoml+xml": { + "source": "iana", + "extensions": ["uoml"] + }, + "application/vnd.uplanet.alert": { + "source": "iana" + }, + "application/vnd.uplanet.alert-wbxml": { + "source": "iana" + }, + "application/vnd.uplanet.bearer-choice": { + "source": "iana" + }, + "application/vnd.uplanet.bearer-choice-wbxml": { + "source": "iana" + }, + "application/vnd.uplanet.cacheop": { + "source": "iana" + }, + "application/vnd.uplanet.cacheop-wbxml": { + "source": "iana" + }, + "application/vnd.uplanet.channel": { + "source": "iana" + }, + "application/vnd.uplanet.channel-wbxml": { + "source": "iana" + }, + "application/vnd.uplanet.list": { + "source": "iana" + }, + "application/vnd.uplanet.list-wbxml": { + "source": "iana" + }, + "application/vnd.uplanet.listcmd": { + "source": "iana" + }, + "application/vnd.uplanet.listcmd-wbxml": { + "source": "iana" + }, + "application/vnd.uplanet.signal": { + "source": "iana" + }, + "application/vnd.uri-map": { + "source": "iana" + }, + "application/vnd.valve.source.material": { + "source": "iana" + }, + "application/vnd.vcx": { + "source": "iana", + "extensions": ["vcx"] + }, + "application/vnd.vd-study": { + "source": "iana" + }, + "application/vnd.vectorworks": { + "source": "iana" + }, + "application/vnd.vel+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.verimatrix.vcas": { + "source": "iana" + }, + "application/vnd.vidsoft.vidconference": { + "source": "iana" + }, + "application/vnd.visio": { + "source": "iana", + "extensions": ["vsd","vst","vss","vsw"] + }, + "application/vnd.visionary": { + "source": "iana", + "extensions": ["vis"] + }, + "application/vnd.vividence.scriptfile": { + "source": "iana" + }, + "application/vnd.vsf": { + "source": "iana", + "extensions": ["vsf"] + }, + "application/vnd.wap.sic": { + "source": "iana" + }, + "application/vnd.wap.slc": { + "source": "iana" + }, + "application/vnd.wap.wbxml": { + "source": "iana", + "extensions": ["wbxml"] + }, + "application/vnd.wap.wmlc": { + "source": "iana", + "extensions": ["wmlc"] + }, + "application/vnd.wap.wmlscriptc": { + "source": "iana", + "extensions": ["wmlsc"] + }, + "application/vnd.webturbo": { + "source": "iana", + "extensions": ["wtb"] + }, + "application/vnd.wfa.p2p": { + "source": "iana" + }, + "application/vnd.wfa.wsc": { + "source": "iana" + }, + "application/vnd.windows.devicepairing": { + "source": "iana" + }, + "application/vnd.wmc": { + "source": "iana" + }, + "application/vnd.wmf.bootstrap": { + "source": "iana" + }, + "application/vnd.wolfram.mathematica": { + "source": "iana" + }, + "application/vnd.wolfram.mathematica.package": { + "source": "iana" + }, + "application/vnd.wolfram.player": { + "source": "iana", + "extensions": ["nbp"] + }, + "application/vnd.wordperfect": { + "source": "iana", + "extensions": ["wpd"] + }, + "application/vnd.wqd": { + "source": "iana", + "extensions": ["wqd"] + }, + "application/vnd.wrq-hp3000-labelled": { + "source": "iana" + }, + "application/vnd.wt.stf": { + "source": "iana", + "extensions": ["stf"] + }, + "application/vnd.wv.csp+wbxml": { + "source": "iana" + }, + "application/vnd.wv.csp+xml": { + "source": "iana" + }, + "application/vnd.wv.ssp+xml": { + "source": "iana" + }, + "application/vnd.xacml+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.xara": { + "source": "iana", + "extensions": ["xar"] + }, + "application/vnd.xfdl": { + "source": "iana", + "extensions": ["xfdl"] + }, + "application/vnd.xfdl.webform": { + "source": "iana" + }, + "application/vnd.xmi+xml": { + "source": "iana" + }, + "application/vnd.xmpie.cpkg": { + "source": "iana" + }, + "application/vnd.xmpie.dpkg": { + "source": "iana" + }, + "application/vnd.xmpie.plan": { + "source": "iana" + }, + "application/vnd.xmpie.ppkg": { + "source": "iana" + }, + "application/vnd.xmpie.xlim": { + "source": "iana" + }, + "application/vnd.yamaha.hv-dic": { + "source": "iana", + "extensions": ["hvd"] + }, + "application/vnd.yamaha.hv-script": { + "source": "iana", + "extensions": ["hvs"] + }, + "application/vnd.yamaha.hv-voice": { + "source": "iana", + "extensions": ["hvp"] + }, + "application/vnd.yamaha.openscoreformat": { + "source": "iana", + "extensions": ["osf"] + }, + "application/vnd.yamaha.openscoreformat.osfpvg+xml": { + "source": "iana", + "extensions": ["osfpvg"] + }, + "application/vnd.yamaha.remote-setup": { + "source": "iana" + }, + "application/vnd.yamaha.smaf-audio": { + "source": "iana", + "extensions": ["saf"] + }, + "application/vnd.yamaha.smaf-phrase": { + "source": "iana", + "extensions": ["spf"] + }, + "application/vnd.yamaha.through-ngn": { + "source": "iana" + }, + "application/vnd.yamaha.tunnel-udpencap": { + "source": "iana" + }, + "application/vnd.yaoweme": { + "source": "iana" + }, + "application/vnd.yellowriver-custom-menu": { + "source": "iana", + "extensions": ["cmp"] + }, + "application/vnd.zul": { + "source": "iana", + "extensions": ["zir","zirz"] + }, + "application/vnd.zzazz.deck+xml": { + "source": "iana", + "extensions": ["zaz"] + }, + "application/voicexml+xml": { + "source": "iana", + "extensions": ["vxml"] + }, + "application/vq-rtcpxr": { + "source": "iana" + }, + "application/watcherinfo+xml": { + "source": "iana" + }, + "application/whoispp-query": { + "source": "iana" + }, + "application/whoispp-response": { + "source": "iana" + }, + "application/widget": { + "source": "iana", + "extensions": ["wgt"] + }, + "application/winhlp": { + "source": "apache", + "extensions": ["hlp"] + }, + "application/wita": { + "source": "iana" + }, + "application/wordperfect5.1": { + "source": "iana" + }, + "application/wsdl+xml": { + "source": "iana", + "extensions": ["wsdl"] + }, + "application/wspolicy+xml": { + "source": "iana", + "extensions": ["wspolicy"] + }, + "application/x-7z-compressed": { + "source": "apache", + "compressible": false, + "extensions": ["7z"] + }, + "application/x-abiword": { + "source": "apache", + "extensions": ["abw"] + }, + "application/x-ace-compressed": { + "source": "apache", + "extensions": ["ace"] + }, + "application/x-amf": { + "source": "apache" + }, + "application/x-apple-diskimage": { + "source": "apache", + "extensions": ["dmg"] + }, + "application/x-authorware-bin": { + "source": "apache", + "extensions": ["aab","x32","u32","vox"] + }, + "application/x-authorware-map": { + "source": "apache", + "extensions": ["aam"] + }, + "application/x-authorware-seg": { + "source": "apache", + "extensions": ["aas"] + }, + "application/x-bcpio": { + "source": "apache", + "extensions": ["bcpio"] + }, + "application/x-bdoc": { + "compressible": false, + "extensions": ["bdoc"] + }, + "application/x-bittorrent": { + "source": "apache", + "extensions": ["torrent"] + }, + "application/x-blorb": { + "source": "apache", + "extensions": ["blb","blorb"] + }, + "application/x-bzip": { + "source": "apache", + "compressible": false, + "extensions": ["bz"] + }, + "application/x-bzip2": { + "source": "apache", + "compressible": false, + "extensions": ["bz2","boz"] + }, + "application/x-cbr": { + "source": "apache", + "extensions": ["cbr","cba","cbt","cbz","cb7"] + }, + "application/x-cdlink": { + "source": "apache", + "extensions": ["vcd"] + }, + "application/x-cfs-compressed": { + "source": "apache", + "extensions": ["cfs"] + }, + "application/x-chat": { + "source": "apache", + "extensions": ["chat"] + }, + "application/x-chess-pgn": { + "source": "apache", + "extensions": ["pgn"] + }, + "application/x-chrome-extension": { + "extensions": ["crx"] + }, + "application/x-cocoa": { + "source": "nginx", + "extensions": ["cco"] + }, + "application/x-compress": { + "source": "apache" + }, + "application/x-conference": { + "source": "apache", + "extensions": ["nsc"] + }, + "application/x-cpio": { + "source": "apache", + "extensions": ["cpio"] + }, + "application/x-csh": { + "source": "apache", + "extensions": ["csh"] + }, + "application/x-deb": { + "compressible": false + }, + "application/x-debian-package": { + "source": "apache", + "extensions": ["deb","udeb"] + }, + "application/x-dgc-compressed": { + "source": "apache", + "extensions": ["dgc"] + }, + "application/x-director": { + "source": "apache", + "extensions": ["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"] + }, + "application/x-doom": { + "source": "apache", + "extensions": ["wad"] + }, + "application/x-dtbncx+xml": { + "source": "apache", + "extensions": ["ncx"] + }, + "application/x-dtbook+xml": { + "source": "apache", + "extensions": ["dtb"] + }, + "application/x-dtbresource+xml": { + "source": "apache", + "extensions": ["res"] + }, + "application/x-dvi": { + "source": "apache", + "compressible": false, + "extensions": ["dvi"] + }, + "application/x-envoy": { + "source": "apache", + "extensions": ["evy"] + }, + "application/x-eva": { + "source": "apache", + "extensions": ["eva"] + }, + "application/x-font-bdf": { + "source": "apache", + "extensions": ["bdf"] + }, + "application/x-font-dos": { + "source": "apache" + }, + "application/x-font-framemaker": { + "source": "apache" + }, + "application/x-font-ghostscript": { + "source": "apache", + "extensions": ["gsf"] + }, + "application/x-font-libgrx": { + "source": "apache" + }, + "application/x-font-linux-psf": { + "source": "apache", + "extensions": ["psf"] + }, + "application/x-font-otf": { + "source": "apache", + "compressible": true, + "extensions": ["otf"] + }, + "application/x-font-pcf": { + "source": "apache", + "extensions": ["pcf"] + }, + "application/x-font-snf": { + "source": "apache", + "extensions": ["snf"] + }, + "application/x-font-speedo": { + "source": "apache" + }, + "application/x-font-sunos-news": { + "source": "apache" + }, + "application/x-font-ttf": { + "source": "apache", + "compressible": true, + "extensions": ["ttf","ttc"] + }, + "application/x-font-type1": { + "source": "apache", + "extensions": ["pfa","pfb","pfm","afm"] + }, + "application/x-font-vfont": { + "source": "apache" + }, + "application/x-freearc": { + "source": "apache", + "extensions": ["arc"] + }, + "application/x-futuresplash": { + "source": "apache", + "extensions": ["spl"] + }, + "application/x-gca-compressed": { + "source": "apache", + "extensions": ["gca"] + }, + "application/x-glulx": { + "source": "apache", + "extensions": ["ulx"] + }, + "application/x-gnumeric": { + "source": "apache", + "extensions": ["gnumeric"] + }, + "application/x-gramps-xml": { + "source": "apache", + "extensions": ["gramps"] + }, + "application/x-gtar": { + "source": "apache", + "extensions": ["gtar"] + }, + "application/x-gzip": { + "source": "apache" + }, + "application/x-hdf": { + "source": "apache", + "extensions": ["hdf"] + }, + "application/x-httpd-php": { + "compressible": true, + "extensions": ["php"] + }, + "application/x-install-instructions": { + "source": "apache", + "extensions": ["install"] + }, + "application/x-iso9660-image": { + "source": "apache", + "extensions": ["iso"] + }, + "application/x-java-archive-diff": { + "source": "nginx", + "extensions": ["jardiff"] + }, + "application/x-java-jnlp-file": { + "source": "apache", + "compressible": false, + "extensions": ["jnlp"] + }, + "application/x-javascript": { + "compressible": true + }, + "application/x-latex": { + "source": "apache", + "compressible": false, + "extensions": ["latex"] + }, + "application/x-lua-bytecode": { + "extensions": ["luac"] + }, + "application/x-lzh-compressed": { + "source": "apache", + "extensions": ["lzh","lha"] + }, + "application/x-makeself": { + "source": "nginx", + "extensions": ["run"] + }, + "application/x-mie": { + "source": "apache", + "extensions": ["mie"] + }, + "application/x-mobipocket-ebook": { + "source": "apache", + "extensions": ["prc","mobi"] + }, + "application/x-mpegurl": { + "compressible": false + }, + "application/x-ms-application": { + "source": "apache", + "extensions": ["application"] + }, + "application/x-ms-shortcut": { + "source": "apache", + "extensions": ["lnk"] + }, + "application/x-ms-wmd": { + "source": "apache", + "extensions": ["wmd"] + }, + "application/x-ms-wmz": { + "source": "apache", + "extensions": ["wmz"] + }, + "application/x-ms-xbap": { + "source": "apache", + "extensions": ["xbap"] + }, + "application/x-msaccess": { + "source": "apache", + "extensions": ["mdb"] + }, + "application/x-msbinder": { + "source": "apache", + "extensions": ["obd"] + }, + "application/x-mscardfile": { + "source": "apache", + "extensions": ["crd"] + }, + "application/x-msclip": { + "source": "apache", + "extensions": ["clp"] + }, + "application/x-msdos-program": { + "extensions": ["exe"] + }, + "application/x-msdownload": { + "source": "apache", + "extensions": ["exe","dll","com","bat","msi"] + }, + "application/x-msmediaview": { + "source": "apache", + "extensions": ["mvb","m13","m14"] + }, + "application/x-msmetafile": { + "source": "apache", + "extensions": ["wmf","wmz","emf","emz"] + }, + "application/x-msmoney": { + "source": "apache", + "extensions": ["mny"] + }, + "application/x-mspublisher": { + "source": "apache", + "extensions": ["pub"] + }, + "application/x-msschedule": { + "source": "apache", + "extensions": ["scd"] + }, + "application/x-msterminal": { + "source": "apache", + "extensions": ["trm"] + }, + "application/x-mswrite": { + "source": "apache", + "extensions": ["wri"] + }, + "application/x-netcdf": { + "source": "apache", + "extensions": ["nc","cdf"] + }, + "application/x-ns-proxy-autoconfig": { + "compressible": true, + "extensions": ["pac"] + }, + "application/x-nzb": { + "source": "apache", + "extensions": ["nzb"] + }, + "application/x-perl": { + "source": "nginx", + "extensions": ["pl","pm"] + }, + "application/x-pilot": { + "source": "nginx", + "extensions": ["prc","pdb"] + }, + "application/x-pkcs12": { + "source": "apache", + "compressible": false, + "extensions": ["p12","pfx"] + }, + "application/x-pkcs7-certificates": { + "source": "apache", + "extensions": ["p7b","spc"] + }, + "application/x-pkcs7-certreqresp": { + "source": "apache", + "extensions": ["p7r"] + }, + "application/x-rar-compressed": { + "source": "apache", + "compressible": false, + "extensions": ["rar"] + }, + "application/x-redhat-package-manager": { + "source": "nginx", + "extensions": ["rpm"] + }, + "application/x-research-info-systems": { + "source": "apache", + "extensions": ["ris"] + }, + "application/x-sea": { + "source": "nginx", + "extensions": ["sea"] + }, + "application/x-sh": { + "source": "apache", + "compressible": true, + "extensions": ["sh"] + }, + "application/x-shar": { + "source": "apache", + "extensions": ["shar"] + }, + "application/x-shockwave-flash": { + "source": "apache", + "compressible": false, + "extensions": ["swf"] + }, + "application/x-silverlight-app": { + "source": "apache", + "extensions": ["xap"] + }, + "application/x-sql": { + "source": "apache", + "extensions": ["sql"] + }, + "application/x-stuffit": { + "source": "apache", + "compressible": false, + "extensions": ["sit"] + }, + "application/x-stuffitx": { + "source": "apache", + "extensions": ["sitx"] + }, + "application/x-subrip": { + "source": "apache", + "extensions": ["srt"] + }, + "application/x-sv4cpio": { + "source": "apache", + "extensions": ["sv4cpio"] + }, + "application/x-sv4crc": { + "source": "apache", + "extensions": ["sv4crc"] + }, + "application/x-t3vm-image": { + "source": "apache", + "extensions": ["t3"] + }, + "application/x-tads": { + "source": "apache", + "extensions": ["gam"] + }, + "application/x-tar": { + "source": "apache", + "compressible": true, + "extensions": ["tar"] + }, + "application/x-tcl": { + "source": "apache", + "extensions": ["tcl","tk"] + }, + "application/x-tex": { + "source": "apache", + "extensions": ["tex"] + }, + "application/x-tex-tfm": { + "source": "apache", + "extensions": ["tfm"] + }, + "application/x-texinfo": { + "source": "apache", + "extensions": ["texinfo","texi"] + }, + "application/x-tgif": { + "source": "apache", + "extensions": ["obj"] + }, + "application/x-ustar": { + "source": "apache", + "extensions": ["ustar"] + }, + "application/x-wais-source": { + "source": "apache", + "extensions": ["src"] + }, + "application/x-web-app-manifest+json": { + "compressible": true, + "extensions": ["webapp"] + }, + "application/x-www-form-urlencoded": { + "source": "iana", + "compressible": true + }, + "application/x-x509-ca-cert": { + "source": "apache", + "extensions": ["der","crt","pem"] + }, + "application/x-xfig": { + "source": "apache", + "extensions": ["fig"] + }, + "application/x-xliff+xml": { + "source": "apache", + "extensions": ["xlf"] + }, + "application/x-xpinstall": { + "source": "apache", + "compressible": false, + "extensions": ["xpi"] + }, + "application/x-xz": { + "source": "apache", + "extensions": ["xz"] + }, + "application/x-zmachine": { + "source": "apache", + "extensions": ["z1","z2","z3","z4","z5","z6","z7","z8"] + }, + "application/x400-bp": { + "source": "iana" + }, + "application/xacml+xml": { + "source": "iana" + }, + "application/xaml+xml": { + "source": "apache", + "extensions": ["xaml"] + }, + "application/xcap-att+xml": { + "source": "iana" + }, + "application/xcap-caps+xml": { + "source": "iana" + }, + "application/xcap-diff+xml": { + "source": "iana", + "extensions": ["xdf"] + }, + "application/xcap-el+xml": { + "source": "iana" + }, + "application/xcap-error+xml": { + "source": "iana" + }, + "application/xcap-ns+xml": { + "source": "iana" + }, + "application/xcon-conference-info+xml": { + "source": "iana" + }, + "application/xcon-conference-info-diff+xml": { + "source": "iana" + }, + "application/xenc+xml": { + "source": "iana", + "extensions": ["xenc"] + }, + "application/xhtml+xml": { + "source": "iana", + "compressible": true, + "extensions": ["xhtml","xht"] + }, + "application/xhtml-voice+xml": { + "source": "apache" + }, + "application/xml": { + "source": "iana", + "compressible": true, + "extensions": ["xml","xsl","xsd","rng"] + }, + "application/xml-dtd": { + "source": "iana", + "compressible": true, + "extensions": ["dtd"] + }, + "application/xml-external-parsed-entity": { + "source": "iana" + }, + "application/xml-patch+xml": { + "source": "iana" + }, + "application/xmpp+xml": { + "source": "iana" + }, + "application/xop+xml": { + "source": "iana", + "compressible": true, + "extensions": ["xop"] + }, + "application/xproc+xml": { + "source": "apache", + "extensions": ["xpl"] + }, + "application/xslt+xml": { + "source": "iana", + "extensions": ["xslt"] + }, + "application/xspf+xml": { + "source": "apache", + "extensions": ["xspf"] + }, + "application/xv+xml": { + "source": "iana", + "extensions": ["mxml","xhvml","xvml","xvm"] + }, + "application/yang": { + "source": "iana", + "extensions": ["yang"] + }, + "application/yin+xml": { + "source": "iana", + "extensions": ["yin"] + }, + "application/zip": { + "source": "iana", + "compressible": false, + "extensions": ["zip"] + }, + "application/zlib": { + "source": "iana" + }, + "audio/1d-interleaved-parityfec": { + "source": "iana" + }, + "audio/32kadpcm": { + "source": "iana" + }, + "audio/3gpp": { + "source": "iana", + "compressible": false, + "extensions": ["3gpp"] + }, + "audio/3gpp2": { + "source": "iana" + }, + "audio/ac3": { + "source": "iana" + }, + "audio/adpcm": { + "source": "apache", + "extensions": ["adp"] + }, + "audio/amr": { + "source": "iana" + }, + "audio/amr-wb": { + "source": "iana" + }, + "audio/amr-wb+": { + "source": "iana" + }, + "audio/aptx": { + "source": "iana" + }, + "audio/asc": { + "source": "iana" + }, + "audio/atrac-advanced-lossless": { + "source": "iana" + }, + "audio/atrac-x": { + "source": "iana" + }, + "audio/atrac3": { + "source": "iana" + }, + "audio/basic": { + "source": "iana", + "compressible": false, + "extensions": ["au","snd"] + }, + "audio/bv16": { + "source": "iana" + }, + "audio/bv32": { + "source": "iana" + }, + "audio/clearmode": { + "source": "iana" + }, + "audio/cn": { + "source": "iana" + }, + "audio/dat12": { + "source": "iana" + }, + "audio/dls": { + "source": "iana" + }, + "audio/dsr-es201108": { + "source": "iana" + }, + "audio/dsr-es202050": { + "source": "iana" + }, + "audio/dsr-es202211": { + "source": "iana" + }, + "audio/dsr-es202212": { + "source": "iana" + }, + "audio/dv": { + "source": "iana" + }, + "audio/dvi4": { + "source": "iana" + }, + "audio/eac3": { + "source": "iana" + }, + "audio/encaprtp": { + "source": "iana" + }, + "audio/evrc": { + "source": "iana" + }, + "audio/evrc-qcp": { + "source": "iana" + }, + "audio/evrc0": { + "source": "iana" + }, + "audio/evrc1": { + "source": "iana" + }, + "audio/evrcb": { + "source": "iana" + }, + "audio/evrcb0": { + "source": "iana" + }, + "audio/evrcb1": { + "source": "iana" + }, + "audio/evrcnw": { + "source": "iana" + }, + "audio/evrcnw0": { + "source": "iana" + }, + "audio/evrcnw1": { + "source": "iana" + }, + "audio/evrcwb": { + "source": "iana" + }, + "audio/evrcwb0": { + "source": "iana" + }, + "audio/evrcwb1": { + "source": "iana" + }, + "audio/evs": { + "source": "iana" + }, + "audio/fwdred": { + "source": "iana" + }, + "audio/g711-0": { + "source": "iana" + }, + "audio/g719": { + "source": "iana" + }, + "audio/g722": { + "source": "iana" + }, + "audio/g7221": { + "source": "iana" + }, + "audio/g723": { + "source": "iana" + }, + "audio/g726-16": { + "source": "iana" + }, + "audio/g726-24": { + "source": "iana" + }, + "audio/g726-32": { + "source": "iana" + }, + "audio/g726-40": { + "source": "iana" + }, + "audio/g728": { + "source": "iana" + }, + "audio/g729": { + "source": "iana" + }, + "audio/g7291": { + "source": "iana" + }, + "audio/g729d": { + "source": "iana" + }, + "audio/g729e": { + "source": "iana" + }, + "audio/gsm": { + "source": "iana" + }, + "audio/gsm-efr": { + "source": "iana" + }, + "audio/gsm-hr-08": { + "source": "iana" + }, + "audio/ilbc": { + "source": "iana" + }, + "audio/ip-mr_v2.5": { + "source": "iana" + }, + "audio/isac": { + "source": "apache" + }, + "audio/l16": { + "source": "iana" + }, + "audio/l20": { + "source": "iana" + }, + "audio/l24": { + "source": "iana", + "compressible": false + }, + "audio/l8": { + "source": "iana" + }, + "audio/lpc": { + "source": "iana" + }, + "audio/midi": { + "source": "apache", + "extensions": ["mid","midi","kar","rmi"] + }, + "audio/mobile-xmf": { + "source": "iana" + }, + "audio/mp4": { + "source": "iana", + "compressible": false, + "extensions": ["m4a","mp4a"] + }, + "audio/mp4a-latm": { + "source": "iana" + }, + "audio/mpa": { + "source": "iana" + }, + "audio/mpa-robust": { + "source": "iana" + }, + "audio/mpeg": { + "source": "iana", + "compressible": false, + "extensions": ["mpga","mp2","mp2a","mp3","m2a","m3a"] + }, + "audio/mpeg4-generic": { + "source": "iana" + }, + "audio/musepack": { + "source": "apache" + }, + "audio/ogg": { + "source": "iana", + "compressible": false, + "extensions": ["oga","ogg","spx"] + }, + "audio/opus": { + "source": "iana" + }, + "audio/parityfec": { + "source": "iana" + }, + "audio/pcma": { + "source": "iana" + }, + "audio/pcma-wb": { + "source": "iana" + }, + "audio/pcmu": { + "source": "iana" + }, + "audio/pcmu-wb": { + "source": "iana" + }, + "audio/prs.sid": { + "source": "iana" + }, + "audio/qcelp": { + "source": "iana" + }, + "audio/raptorfec": { + "source": "iana" + }, + "audio/red": { + "source": "iana" + }, + "audio/rtp-enc-aescm128": { + "source": "iana" + }, + "audio/rtp-midi": { + "source": "iana" + }, + "audio/rtploopback": { + "source": "iana" + }, + "audio/rtx": { + "source": "iana" + }, + "audio/s3m": { + "source": "apache", + "extensions": ["s3m"] + }, + "audio/silk": { + "source": "apache", + "extensions": ["sil"] + }, + "audio/smv": { + "source": "iana" + }, + "audio/smv-qcp": { + "source": "iana" + }, + "audio/smv0": { + "source": "iana" + }, + "audio/sp-midi": { + "source": "iana" + }, + "audio/speex": { + "source": "iana" + }, + "audio/t140c": { + "source": "iana" + }, + "audio/t38": { + "source": "iana" + }, + "audio/telephone-event": { + "source": "iana" + }, + "audio/tone": { + "source": "iana" + }, + "audio/uemclip": { + "source": "iana" + }, + "audio/ulpfec": { + "source": "iana" + }, + "audio/vdvi": { + "source": "iana" + }, + "audio/vmr-wb": { + "source": "iana" + }, + "audio/vnd.3gpp.iufp": { + "source": "iana" + }, + "audio/vnd.4sb": { + "source": "iana" + }, + "audio/vnd.audiokoz": { + "source": "iana" + }, + "audio/vnd.celp": { + "source": "iana" + }, + "audio/vnd.cisco.nse": { + "source": "iana" + }, + "audio/vnd.cmles.radio-events": { + "source": "iana" + }, + "audio/vnd.cns.anp1": { + "source": "iana" + }, + "audio/vnd.cns.inf1": { + "source": "iana" + }, + "audio/vnd.dece.audio": { + "source": "iana", + "extensions": ["uva","uvva"] + }, + "audio/vnd.digital-winds": { + "source": "iana", + "extensions": ["eol"] + }, + "audio/vnd.dlna.adts": { + "source": "iana" + }, + "audio/vnd.dolby.heaac.1": { + "source": "iana" + }, + "audio/vnd.dolby.heaac.2": { + "source": "iana" + }, + "audio/vnd.dolby.mlp": { + "source": "iana" + }, + "audio/vnd.dolby.mps": { + "source": "iana" + }, + "audio/vnd.dolby.pl2": { + "source": "iana" + }, + "audio/vnd.dolby.pl2x": { + "source": "iana" + }, + "audio/vnd.dolby.pl2z": { + "source": "iana" + }, + "audio/vnd.dolby.pulse.1": { + "source": "iana" + }, + "audio/vnd.dra": { + "source": "iana", + "extensions": ["dra"] + }, + "audio/vnd.dts": { + "source": "iana", + "extensions": ["dts"] + }, + "audio/vnd.dts.hd": { + "source": "iana", + "extensions": ["dtshd"] + }, + "audio/vnd.dvb.file": { + "source": "iana" + }, + "audio/vnd.everad.plj": { + "source": "iana" + }, + "audio/vnd.hns.audio": { + "source": "iana" + }, + "audio/vnd.lucent.voice": { + "source": "iana", + "extensions": ["lvp"] + }, + "audio/vnd.ms-playready.media.pya": { + "source": "iana", + "extensions": ["pya"] + }, + "audio/vnd.nokia.mobile-xmf": { + "source": "iana" + }, + "audio/vnd.nortel.vbk": { + "source": "iana" + }, + "audio/vnd.nuera.ecelp4800": { + "source": "iana", + "extensions": ["ecelp4800"] + }, + "audio/vnd.nuera.ecelp7470": { + "source": "iana", + "extensions": ["ecelp7470"] + }, + "audio/vnd.nuera.ecelp9600": { + "source": "iana", + "extensions": ["ecelp9600"] + }, + "audio/vnd.octel.sbc": { + "source": "iana" + }, + "audio/vnd.qcelp": { + "source": "iana" + }, + "audio/vnd.rhetorex.32kadpcm": { + "source": "iana" + }, + "audio/vnd.rip": { + "source": "iana", + "extensions": ["rip"] + }, + "audio/vnd.rn-realaudio": { + "compressible": false + }, + "audio/vnd.sealedmedia.softseal.mpeg": { + "source": "iana" + }, + "audio/vnd.vmx.cvsd": { + "source": "iana" + }, + "audio/vnd.wave": { + "compressible": false + }, + "audio/vorbis": { + "source": "iana", + "compressible": false + }, + "audio/vorbis-config": { + "source": "iana" + }, + "audio/wav": { + "compressible": false, + "extensions": ["wav"] + }, + "audio/wave": { + "compressible": false, + "extensions": ["wav"] + }, + "audio/webm": { + "source": "apache", + "compressible": false, + "extensions": ["weba"] + }, + "audio/x-aac": { + "source": "apache", + "compressible": false, + "extensions": ["aac"] + }, + "audio/x-aiff": { + "source": "apache", + "extensions": ["aif","aiff","aifc"] + }, + "audio/x-caf": { + "source": "apache", + "compressible": false, + "extensions": ["caf"] + }, + "audio/x-flac": { + "source": "apache", + "extensions": ["flac"] + }, + "audio/x-m4a": { + "source": "nginx", + "extensions": ["m4a"] + }, + "audio/x-matroska": { + "source": "apache", + "extensions": ["mka"] + }, + "audio/x-mpegurl": { + "source": "apache", + "extensions": ["m3u"] + }, + "audio/x-ms-wax": { + "source": "apache", + "extensions": ["wax"] + }, + "audio/x-ms-wma": { + "source": "apache", + "extensions": ["wma"] + }, + "audio/x-pn-realaudio": { + "source": "apache", + "extensions": ["ram","ra"] + }, + "audio/x-pn-realaudio-plugin": { + "source": "apache", + "extensions": ["rmp"] + }, + "audio/x-realaudio": { + "source": "nginx", + "extensions": ["ra"] + }, + "audio/x-tta": { + "source": "apache" + }, + "audio/x-wav": { + "source": "apache", + "extensions": ["wav"] + }, + "audio/xm": { + "source": "apache", + "extensions": ["xm"] + }, + "chemical/x-cdx": { + "source": "apache", + "extensions": ["cdx"] + }, + "chemical/x-cif": { + "source": "apache", + "extensions": ["cif"] + }, + "chemical/x-cmdf": { + "source": "apache", + "extensions": ["cmdf"] + }, + "chemical/x-cml": { + "source": "apache", + "extensions": ["cml"] + }, + "chemical/x-csml": { + "source": "apache", + "extensions": ["csml"] + }, + "chemical/x-pdb": { + "source": "apache" + }, + "chemical/x-xyz": { + "source": "apache", + "extensions": ["xyz"] + }, + "font/opentype": { + "compressible": true, + "extensions": ["otf"] + }, + "image/bmp": { + "source": "apache", + "compressible": true, + "extensions": ["bmp"] + }, + "image/cgm": { + "source": "iana", + "extensions": ["cgm"] + }, + "image/fits": { + "source": "iana" + }, + "image/g3fax": { + "source": "iana", + "extensions": ["g3"] + }, + "image/gif": { + "source": "iana", + "compressible": false, + "extensions": ["gif"] + }, + "image/ief": { + "source": "iana", + "extensions": ["ief"] + }, + "image/jp2": { + "source": "iana" + }, + "image/jpeg": { + "source": "iana", + "compressible": false, + "extensions": ["jpeg","jpg","jpe"] + }, + "image/jpm": { + "source": "iana" + }, + "image/jpx": { + "source": "iana" + }, + "image/ktx": { + "source": "iana", + "extensions": ["ktx"] + }, + "image/naplps": { + "source": "iana" + }, + "image/pjpeg": { + "compressible": false + }, + "image/png": { + "source": "iana", + "compressible": false, + "extensions": ["png"] + }, + "image/prs.btif": { + "source": "iana", + "extensions": ["btif"] + }, + "image/prs.pti": { + "source": "iana" + }, + "image/pwg-raster": { + "source": "iana" + }, + "image/sgi": { + "source": "apache", + "extensions": ["sgi"] + }, + "image/svg+xml": { + "source": "iana", + "compressible": true, + "extensions": ["svg","svgz"] + }, + "image/t38": { + "source": "iana" + }, + "image/tiff": { + "source": "iana", + "compressible": false, + "extensions": ["tiff","tif"] + }, + "image/tiff-fx": { + "source": "iana" + }, + "image/vnd.adobe.photoshop": { + "source": "iana", + "compressible": true, + "extensions": ["psd"] + }, + "image/vnd.airzip.accelerator.azv": { + "source": "iana" + }, + "image/vnd.cns.inf2": { + "source": "iana" + }, + "image/vnd.dece.graphic": { + "source": "iana", + "extensions": ["uvi","uvvi","uvg","uvvg"] + }, + "image/vnd.djvu": { + "source": "iana", + "extensions": ["djvu","djv"] + }, + "image/vnd.dvb.subtitle": { + "source": "iana", + "extensions": ["sub"] + }, + "image/vnd.dwg": { + "source": "iana", + "extensions": ["dwg"] + }, + "image/vnd.dxf": { + "source": "iana", + "extensions": ["dxf"] + }, + "image/vnd.fastbidsheet": { + "source": "iana", + "extensions": ["fbs"] + }, + "image/vnd.fpx": { + "source": "iana", + "extensions": ["fpx"] + }, + "image/vnd.fst": { + "source": "iana", + "extensions": ["fst"] + }, + "image/vnd.fujixerox.edmics-mmr": { + "source": "iana", + "extensions": ["mmr"] + }, + "image/vnd.fujixerox.edmics-rlc": { + "source": "iana", + "extensions": ["rlc"] + }, + "image/vnd.globalgraphics.pgb": { + "source": "iana" + }, + "image/vnd.microsoft.icon": { + "source": "iana" + }, + "image/vnd.mix": { + "source": "iana" + }, + "image/vnd.mozilla.apng": { + "source": "iana" + }, + "image/vnd.ms-modi": { + "source": "iana", + "extensions": ["mdi"] + }, + "image/vnd.ms-photo": { + "source": "apache", + "extensions": ["wdp"] + }, + "image/vnd.net-fpx": { + "source": "iana", + "extensions": ["npx"] + }, + "image/vnd.radiance": { + "source": "iana" + }, + "image/vnd.sealed.png": { + "source": "iana" + }, + "image/vnd.sealedmedia.softseal.gif": { + "source": "iana" + }, + "image/vnd.sealedmedia.softseal.jpg": { + "source": "iana" + }, + "image/vnd.svf": { + "source": "iana" + }, + "image/vnd.tencent.tap": { + "source": "iana" + }, + "image/vnd.valve.source.texture": { + "source": "iana" + }, + "image/vnd.wap.wbmp": { + "source": "iana", + "extensions": ["wbmp"] + }, + "image/vnd.xiff": { + "source": "iana", + "extensions": ["xif"] + }, + "image/vnd.zbrush.pcx": { + "source": "iana" + }, + "image/webp": { + "source": "apache", + "extensions": ["webp"] + }, + "image/x-3ds": { + "source": "apache", + "extensions": ["3ds"] + }, + "image/x-cmu-raster": { + "source": "apache", + "extensions": ["ras"] + }, + "image/x-cmx": { + "source": "apache", + "extensions": ["cmx"] + }, + "image/x-freehand": { + "source": "apache", + "extensions": ["fh","fhc","fh4","fh5","fh7"] + }, + "image/x-icon": { + "source": "apache", + "compressible": true, + "extensions": ["ico"] + }, + "image/x-jng": { + "source": "nginx", + "extensions": ["jng"] + }, + "image/x-mrsid-image": { + "source": "apache", + "extensions": ["sid"] + }, + "image/x-ms-bmp": { + "source": "nginx", + "compressible": true, + "extensions": ["bmp"] + }, + "image/x-pcx": { + "source": "apache", + "extensions": ["pcx"] + }, + "image/x-pict": { + "source": "apache", + "extensions": ["pic","pct"] + }, + "image/x-portable-anymap": { + "source": "apache", + "extensions": ["pnm"] + }, + "image/x-portable-bitmap": { + "source": "apache", + "extensions": ["pbm"] + }, + "image/x-portable-graymap": { + "source": "apache", + "extensions": ["pgm"] + }, + "image/x-portable-pixmap": { + "source": "apache", + "extensions": ["ppm"] + }, + "image/x-rgb": { + "source": "apache", + "extensions": ["rgb"] + }, + "image/x-tga": { + "source": "apache", + "extensions": ["tga"] + }, + "image/x-xbitmap": { + "source": "apache", + "extensions": ["xbm"] + }, + "image/x-xcf": { + "compressible": false + }, + "image/x-xpixmap": { + "source": "apache", + "extensions": ["xpm"] + }, + "image/x-xwindowdump": { + "source": "apache", + "extensions": ["xwd"] + }, + "message/cpim": { + "source": "iana" + }, + "message/delivery-status": { + "source": "iana" + }, + "message/disposition-notification": { + "source": "iana" + }, + "message/external-body": { + "source": "iana" + }, + "message/feedback-report": { + "source": "iana" + }, + "message/global": { + "source": "iana" + }, + "message/global-delivery-status": { + "source": "iana" + }, + "message/global-disposition-notification": { + "source": "iana" + }, + "message/global-headers": { + "source": "iana" + }, + "message/http": { + "source": "iana", + "compressible": false + }, + "message/imdn+xml": { + "source": "iana", + "compressible": true + }, + "message/news": { + "source": "iana" + }, + "message/partial": { + "source": "iana", + "compressible": false + }, + "message/rfc822": { + "source": "iana", + "compressible": true, + "extensions": ["eml","mime"] + }, + "message/s-http": { + "source": "iana" + }, + "message/sip": { + "source": "iana" + }, + "message/sipfrag": { + "source": "iana" + }, + "message/tracking-status": { + "source": "iana" + }, + "message/vnd.si.simp": { + "source": "iana" + }, + "message/vnd.wfa.wsc": { + "source": "iana" + }, + "model/iges": { + "source": "iana", + "compressible": false, + "extensions": ["igs","iges"] + }, + "model/mesh": { + "source": "iana", + "compressible": false, + "extensions": ["msh","mesh","silo"] + }, + "model/vnd.collada+xml": { + "source": "iana", + "extensions": ["dae"] + }, + "model/vnd.dwf": { + "source": "iana", + "extensions": ["dwf"] + }, + "model/vnd.flatland.3dml": { + "source": "iana" + }, + "model/vnd.gdl": { + "source": "iana", + "extensions": ["gdl"] + }, + "model/vnd.gs-gdl": { + "source": "apache" + }, + "model/vnd.gs.gdl": { + "source": "iana" + }, + "model/vnd.gtw": { + "source": "iana", + "extensions": ["gtw"] + }, + "model/vnd.moml+xml": { + "source": "iana" + }, + "model/vnd.mts": { + "source": "iana", + "extensions": ["mts"] + }, + "model/vnd.opengex": { + "source": "iana" + }, + "model/vnd.parasolid.transmit.binary": { + "source": "iana" + }, + "model/vnd.parasolid.transmit.text": { + "source": "iana" + }, + "model/vnd.rosette.annotated-data-model": { + "source": "iana" + }, + "model/vnd.valve.source.compiled-map": { + "source": "iana" + }, + "model/vnd.vtu": { + "source": "iana", + "extensions": ["vtu"] + }, + "model/vrml": { + "source": "iana", + "compressible": false, + "extensions": ["wrl","vrml"] + }, + "model/x3d+binary": { + "source": "apache", + "compressible": false, + "extensions": ["x3db","x3dbz"] + }, + "model/x3d+fastinfoset": { + "source": "iana" + }, + "model/x3d+vrml": { + "source": "apache", + "compressible": false, + "extensions": ["x3dv","x3dvz"] + }, + "model/x3d+xml": { + "source": "iana", + "compressible": true, + "extensions": ["x3d","x3dz"] + }, + "model/x3d-vrml": { + "source": "iana" + }, + "multipart/alternative": { + "source": "iana", + "compressible": false + }, + "multipart/appledouble": { + "source": "iana" + }, + "multipart/byteranges": { + "source": "iana" + }, + "multipart/digest": { + "source": "iana" + }, + "multipart/encrypted": { + "source": "iana", + "compressible": false + }, + "multipart/form-data": { + "source": "iana", + "compressible": false + }, + "multipart/header-set": { + "source": "iana" + }, + "multipart/mixed": { + "source": "iana", + "compressible": false + }, + "multipart/parallel": { + "source": "iana" + }, + "multipart/related": { + "source": "iana", + "compressible": false + }, + "multipart/report": { + "source": "iana" + }, + "multipart/signed": { + "source": "iana", + "compressible": false + }, + "multipart/voice-message": { + "source": "iana" + }, + "multipart/x-mixed-replace": { + "source": "iana" + }, + "text/1d-interleaved-parityfec": { + "source": "iana" + }, + "text/cache-manifest": { + "source": "iana", + "compressible": true, + "extensions": ["appcache","manifest"] + }, + "text/calendar": { + "source": "iana", + "extensions": ["ics","ifb"] + }, + "text/calender": { + "compressible": true + }, + "text/cmd": { + "compressible": true + }, + "text/coffeescript": { + "extensions": ["coffee","litcoffee"] + }, + "text/css": { + "source": "iana", + "compressible": true, + "extensions": ["css"] + }, + "text/csv": { + "source": "iana", + "compressible": true, + "extensions": ["csv"] + }, + "text/csv-schema": { + "source": "iana" + }, + "text/directory": { + "source": "iana" + }, + "text/dns": { + "source": "iana" + }, + "text/ecmascript": { + "source": "iana" + }, + "text/encaprtp": { + "source": "iana" + }, + "text/enriched": { + "source": "iana" + }, + "text/fwdred": { + "source": "iana" + }, + "text/grammar-ref-list": { + "source": "iana" + }, + "text/hjson": { + "extensions": ["hjson"] + }, + "text/html": { + "source": "iana", + "compressible": true, + "extensions": ["html","htm","shtml"] + }, + "text/jade": { + "extensions": ["jade"] + }, + "text/javascript": { + "source": "iana", + "compressible": true + }, + "text/jcr-cnd": { + "source": "iana" + }, + "text/jsx": { + "compressible": true, + "extensions": ["jsx"] + }, + "text/less": { + "extensions": ["less"] + }, + "text/markdown": { + "source": "iana" + }, + "text/mathml": { + "source": "nginx", + "extensions": ["mml"] + }, + "text/mizar": { + "source": "iana" + }, + "text/n3": { + "source": "iana", + "compressible": true, + "extensions": ["n3"] + }, + "text/parameters": { + "source": "iana" + }, + "text/parityfec": { + "source": "iana" + }, + "text/plain": { + "source": "iana", + "compressible": true, + "extensions": ["txt","text","conf","def","list","log","in","ini"] + }, + "text/provenance-notation": { + "source": "iana" + }, + "text/prs.fallenstein.rst": { + "source": "iana" + }, + "text/prs.lines.tag": { + "source": "iana", + "extensions": ["dsc"] + }, + "text/prs.prop.logic": { + "source": "iana" + }, + "text/raptorfec": { + "source": "iana" + }, + "text/red": { + "source": "iana" + }, + "text/rfc822-headers": { + "source": "iana" + }, + "text/richtext": { + "source": "iana", + "compressible": true, + "extensions": ["rtx"] + }, + "text/rtf": { + "source": "iana", + "compressible": true, + "extensions": ["rtf"] + }, + "text/rtp-enc-aescm128": { + "source": "iana" + }, + "text/rtploopback": { + "source": "iana" + }, + "text/rtx": { + "source": "iana" + }, + "text/sgml": { + "source": "iana", + "extensions": ["sgml","sgm"] + }, + "text/slim": { + "extensions": ["slim","slm"] + }, + "text/stylus": { + "extensions": ["stylus","styl"] + }, + "text/t140": { + "source": "iana" + }, + "text/tab-separated-values": { + "source": "iana", + "compressible": true, + "extensions": ["tsv"] + }, + "text/troff": { + "source": "iana", + "extensions": ["t","tr","roff","man","me","ms"] + }, + "text/turtle": { + "source": "iana", + "extensions": ["ttl"] + }, + "text/ulpfec": { + "source": "iana" + }, + "text/uri-list": { + "source": "iana", + "compressible": true, + "extensions": ["uri","uris","urls"] + }, + "text/vcard": { + "source": "iana", + "compressible": true, + "extensions": ["vcard"] + }, + "text/vnd.a": { + "source": "iana" + }, + "text/vnd.abc": { + "source": "iana" + }, + "text/vnd.curl": { + "source": "iana", + "extensions": ["curl"] + }, + "text/vnd.curl.dcurl": { + "source": "apache", + "extensions": ["dcurl"] + }, + "text/vnd.curl.mcurl": { + "source": "apache", + "extensions": ["mcurl"] + }, + "text/vnd.curl.scurl": { + "source": "apache", + "extensions": ["scurl"] + }, + "text/vnd.debian.copyright": { + "source": "iana" + }, + "text/vnd.dmclientscript": { + "source": "iana" + }, + "text/vnd.dvb.subtitle": { + "source": "iana", + "extensions": ["sub"] + }, + "text/vnd.esmertec.theme-descriptor": { + "source": "iana" + }, + "text/vnd.fly": { + "source": "iana", + "extensions": ["fly"] + }, + "text/vnd.fmi.flexstor": { + "source": "iana", + "extensions": ["flx"] + }, + "text/vnd.graphviz": { + "source": "iana", + "extensions": ["gv"] + }, + "text/vnd.in3d.3dml": { + "source": "iana", + "extensions": ["3dml"] + }, + "text/vnd.in3d.spot": { + "source": "iana", + "extensions": ["spot"] + }, + "text/vnd.iptc.newsml": { + "source": "iana" + }, + "text/vnd.iptc.nitf": { + "source": "iana" + }, + "text/vnd.latex-z": { + "source": "iana" + }, + "text/vnd.motorola.reflex": { + "source": "iana" + }, + "text/vnd.ms-mediapackage": { + "source": "iana" + }, + "text/vnd.net2phone.commcenter.command": { + "source": "iana" + }, + "text/vnd.radisys.msml-basic-layout": { + "source": "iana" + }, + "text/vnd.si.uricatalogue": { + "source": "iana" + }, + "text/vnd.sun.j2me.app-descriptor": { + "source": "iana", + "extensions": ["jad"] + }, + "text/vnd.trolltech.linguist": { + "source": "iana" + }, + "text/vnd.wap.si": { + "source": "iana" + }, + "text/vnd.wap.sl": { + "source": "iana" + }, + "text/vnd.wap.wml": { + "source": "iana", + "extensions": ["wml"] + }, + "text/vnd.wap.wmlscript": { + "source": "iana", + "extensions": ["wmls"] + }, + "text/vtt": { + "charset": "UTF-8", + "compressible": true, + "extensions": ["vtt"] + }, + "text/x-asm": { + "source": "apache", + "extensions": ["s","asm"] + }, + "text/x-c": { + "source": "apache", + "extensions": ["c","cc","cxx","cpp","h","hh","dic"] + }, + "text/x-component": { + "source": "nginx", + "extensions": ["htc"] + }, + "text/x-fortran": { + "source": "apache", + "extensions": ["f","for","f77","f90"] + }, + "text/x-gwt-rpc": { + "compressible": true + }, + "text/x-handlebars-template": { + "extensions": ["hbs"] + }, + "text/x-java-source": { + "source": "apache", + "extensions": ["java"] + }, + "text/x-jquery-tmpl": { + "compressible": true + }, + "text/x-lua": { + "extensions": ["lua"] + }, + "text/x-markdown": { + "compressible": true, + "extensions": ["markdown","md","mkd"] + }, + "text/x-nfo": { + "source": "apache", + "extensions": ["nfo"] + }, + "text/x-opml": { + "source": "apache", + "extensions": ["opml"] + }, + "text/x-pascal": { + "source": "apache", + "extensions": ["p","pas"] + }, + "text/x-processing": { + "compressible": true, + "extensions": ["pde"] + }, + "text/x-sass": { + "extensions": ["sass"] + }, + "text/x-scss": { + "extensions": ["scss"] + }, + "text/x-setext": { + "source": "apache", + "extensions": ["etx"] + }, + "text/x-sfv": { + "source": "apache", + "extensions": ["sfv"] + }, + "text/x-suse-ymp": { + "compressible": true, + "extensions": ["ymp"] + }, + "text/x-uuencode": { + "source": "apache", + "extensions": ["uu"] + }, + "text/x-vcalendar": { + "source": "apache", + "extensions": ["vcs"] + }, + "text/x-vcard": { + "source": "apache", + "extensions": ["vcf"] + }, + "text/xml": { + "source": "iana", + "compressible": true, + "extensions": ["xml"] + }, + "text/xml-external-parsed-entity": { + "source": "iana" + }, + "text/yaml": { + "extensions": ["yaml","yml"] + }, + "video/1d-interleaved-parityfec": { + "source": "apache" + }, + "video/3gpp": { + "source": "apache", + "extensions": ["3gp","3gpp"] + }, + "video/3gpp-tt": { + "source": "apache" + }, + "video/3gpp2": { + "source": "apache", + "extensions": ["3g2"] + }, + "video/bmpeg": { + "source": "apache" + }, + "video/bt656": { + "source": "apache" + }, + "video/celb": { + "source": "apache" + }, + "video/dv": { + "source": "apache" + }, + "video/encaprtp": { + "source": "apache" + }, + "video/h261": { + "source": "apache", + "extensions": ["h261"] + }, + "video/h263": { + "source": "apache", + "extensions": ["h263"] + }, + "video/h263-1998": { + "source": "apache" + }, + "video/h263-2000": { + "source": "apache" + }, + "video/h264": { + "source": "apache", + "extensions": ["h264"] + }, + "video/h264-rcdo": { + "source": "apache" + }, + "video/h264-svc": { + "source": "apache" + }, + "video/h265": { + "source": "apache" + }, + "video/iso.segment": { + "source": "apache" + }, + "video/jpeg": { + "source": "apache", + "extensions": ["jpgv"] + }, + "video/jpeg2000": { + "source": "apache" + }, + "video/jpm": { + "source": "apache", + "extensions": ["jpm","jpgm"] + }, + "video/mj2": { + "source": "apache", + "extensions": ["mj2","mjp2"] + }, + "video/mp1s": { + "source": "apache" + }, + "video/mp2p": { + "source": "apache" + }, + "video/mp2t": { + "source": "apache", + "extensions": ["ts"] + }, + "video/mp4": { + "source": "apache", + "compressible": false, + "extensions": ["mp4","mp4v","mpg4"] + }, + "video/mp4v-es": { + "source": "apache" + }, + "video/mpeg": { + "source": "apache", + "compressible": false, + "extensions": ["mpeg","mpg","mpe","m1v","m2v"] + }, + "video/mpeg4-generic": { + "source": "apache" + }, + "video/mpv": { + "source": "apache" + }, + "video/nv": { + "source": "apache" + }, + "video/ogg": { + "source": "apache", + "compressible": false, + "extensions": ["ogv"] + }, + "video/parityfec": { + "source": "apache" + }, + "video/pointer": { + "source": "apache" + }, + "video/quicktime": { + "source": "apache", + "compressible": false, + "extensions": ["qt","mov"] + }, + "video/raptorfec": { + "source": "apache" + }, + "video/raw": { + "source": "apache" + }, + "video/rtp-enc-aescm128": { + "source": "apache" + }, + "video/rtploopback": { + "source": "apache" + }, + "video/rtx": { + "source": "apache" + }, + "video/smpte292m": { + "source": "apache" + }, + "video/ulpfec": { + "source": "apache" + }, + "video/vc1": { + "source": "apache" + }, + "video/vnd.cctv": { + "source": "apache" + }, + "video/vnd.dece.hd": { + "source": "apache", + "extensions": ["uvh","uvvh"] + }, + "video/vnd.dece.mobile": { + "source": "apache", + "extensions": ["uvm","uvvm"] + }, + "video/vnd.dece.mp4": { + "source": "apache" + }, + "video/vnd.dece.pd": { + "source": "apache", + "extensions": ["uvp","uvvp"] + }, + "video/vnd.dece.sd": { + "source": "apache", + "extensions": ["uvs","uvvs"] + }, + "video/vnd.dece.video": { + "source": "apache", + "extensions": ["uvv","uvvv"] + }, + "video/vnd.directv.mpeg": { + "source": "apache" + }, + "video/vnd.directv.mpeg-tts": { + "source": "apache" + }, + "video/vnd.dlna.mpeg-tts": { + "source": "apache" + }, + "video/vnd.dvb.file": { + "source": "apache", + "extensions": ["dvb"] + }, + "video/vnd.fvt": { + "source": "apache", + "extensions": ["fvt"] + }, + "video/vnd.hns.video": { + "source": "apache" + }, + "video/vnd.iptvforum.1dparityfec-1010": { + "source": "apache" + }, + "video/vnd.iptvforum.1dparityfec-2005": { + "source": "apache" + }, + "video/vnd.iptvforum.2dparityfec-1010": { + "source": "apache" + }, + "video/vnd.iptvforum.2dparityfec-2005": { + "source": "apache" + }, + "video/vnd.iptvforum.ttsavc": { + "source": "apache" + }, + "video/vnd.iptvforum.ttsmpeg2": { + "source": "apache" + }, + "video/vnd.motorola.video": { + "source": "apache" + }, + "video/vnd.motorola.videop": { + "source": "apache" + }, + "video/vnd.mpegurl": { + "source": "apache", + "extensions": ["mxu","m4u"] + }, + "video/vnd.ms-playready.media.pyv": { + "source": "apache", + "extensions": ["pyv"] + }, + "video/vnd.nokia.interleaved-multimedia": { + "source": "apache" + }, + "video/vnd.nokia.videovoip": { + "source": "apache" + }, + "video/vnd.objectvideo": { + "source": "apache" + }, + "video/vnd.radgamettools.bink": { + "source": "apache" + }, + "video/vnd.radgamettools.smacker": { + "source": "apache" + }, + "video/vnd.sealed.mpeg1": { + "source": "apache" + }, + "video/vnd.sealed.mpeg4": { + "source": "apache" + }, + "video/vnd.sealed.swf": { + "source": "apache" + }, + "video/vnd.sealedmedia.softseal.mov": { + "source": "apache" + }, + "video/vnd.uvvu.mp4": { + "source": "apache", + "extensions": ["uvu","uvvu"] + }, + "video/vnd.vivo": { + "source": "apache", + "extensions": ["viv"] + }, + "video/vp8": { + "source": "apache" + }, + "video/webm": { + "source": "apache", + "compressible": false, + "extensions": ["webm"] + }, + "video/x-f4v": { + "source": "apache", + "extensions": ["f4v"] + }, + "video/x-fli": { + "source": "apache", + "extensions": ["fli"] + }, + "video/x-flv": { + "source": "apache", + "compressible": false, + "extensions": ["flv"] + }, + "video/x-m4v": { + "source": "apache", + "extensions": ["m4v"] + }, + "video/x-matroska": { + "source": "apache", + "compressible": false, + "extensions": ["mkv","mk3d","mks"] + }, + "video/x-mng": { + "source": "apache", + "extensions": ["mng"] + }, + "video/x-ms-asf": { + "source": "apache", + "extensions": ["asf","asx"] + }, + "video/x-ms-vob": { + "source": "apache", + "extensions": ["vob"] + }, + "video/x-ms-wm": { + "source": "apache", + "extensions": ["wm"] + }, + "video/x-ms-wmv": { + "source": "apache", + "compressible": false, + "extensions": ["wmv"] + }, + "video/x-ms-wmx": { + "source": "apache", + "extensions": ["wmx"] + }, + "video/x-ms-wvx": { + "source": "apache", + "extensions": ["wvx"] + }, + "video/x-msvideo": { + "source": "apache", + "extensions": ["avi"] + }, + "video/x-sgi-movie": { + "source": "apache", + "extensions": ["movie"] + }, + "video/x-smv": { + "source": "apache", + "extensions": ["smv"] + }, + "x-conference/x-cooltalk": { + "source": "apache", + "extensions": ["ice"] + }, + "x-shader/x-fragment": { + "compressible": true + }, + "x-shader/x-vertex": { + "compressible": true + } +} diff --git a/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/index.js b/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/index.js index d6c75569..551031f6 100644 --- a/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/index.js +++ b/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/index.js @@ -1,11 +1,11 @@ -/*! - * mime-db - * Copyright(c) 2014 Jonathan Ong - * MIT Licensed - */ - -/** - * Module exports. - */ - -module.exports = require('./db.json') +/*! + * mime-db + * Copyright(c) 2014 Jonathan Ong + * MIT Licensed + */ + +/** + * Module exports. + */ + +module.exports = require('./db.json') diff --git a/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/package.json b/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/package.json index 6fa9da44..d1af1d09 100644 --- a/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/package.json +++ b/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/package.json @@ -1,99 +1,99 @@ -{ - "name": "mime-db", - "description": "Media Type Database", - "version": "1.23.0", - "contributors": [ - { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "Jonathan Ong", - "email": "me@jongleberry.com", - "url": "http://jongleberry.com" - }, - { - "name": "Robert Kieffer", - "email": "robert@broofa.com", - "url": "http://github.com/broofa" - } - ], - "license": "MIT", - "keywords": [ - "mime", - "db", - "type", - "types", - "database", - "charset", - "charsets" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/mime-db.git" - }, - "devDependencies": { - "bluebird": "3.3.5", - "co": "4.6.0", - "cogent": "1.0.1", - "csv-parse": "1.1.0", - "gnode": "0.1.2", - "istanbul": "0.4.3", - "mocha": "1.21.5", - "raw-body": "2.1.6", - "stream-to-array": "2.3.0" - }, - "files": [ - "HISTORY.md", - "LICENSE", - "README.md", - "db.json", - "index.js" - ], - "engines": { - "node": ">= 0.6" - }, - "scripts": { - "build": "node scripts/build", - "fetch": "gnode scripts/fetch-apache && gnode scripts/fetch-iana && gnode scripts/fetch-nginx", - "test": "mocha --reporter spec --bail --check-leaks test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", - "update": "npm run fetch && npm run build" - }, - "gitHead": "ba0d99fd05b3bfdc2ebcd78f858c25cb7db6af41", - "bugs": { - "url": "https://github.com/jshttp/mime-db/issues" - }, - "homepage": "https://github.com/jshttp/mime-db#readme", - "_id": "mime-db@1.23.0", - "_shasum": "a31b4070adaea27d732ea333740a64d0ec9a6659", - "_from": "mime-db@>=1.23.0 <1.24.0", - "_npmVersion": "2.15.1", - "_nodeVersion": "4.4.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "a31b4070adaea27d732ea333740a64d0ec9a6659", - "tarball": "https://registry.npmjs.org/mime-db/-/mime-db-1.23.0.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/mime-db-1.23.0.tgz_1462163798086_0.43938886746764183" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.23.0.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "mime-db", + "description": "Media Type Database", + "version": "1.23.0", + "contributors": [ + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "Jonathan Ong", + "email": "me@jongleberry.com", + "url": "http://jongleberry.com" + }, + { + "name": "Robert Kieffer", + "email": "robert@broofa.com", + "url": "http://github.com/broofa" + } + ], + "license": "MIT", + "keywords": [ + "mime", + "db", + "type", + "types", + "database", + "charset", + "charsets" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/mime-db.git" + }, + "devDependencies": { + "bluebird": "3.3.5", + "co": "4.6.0", + "cogent": "1.0.1", + "csv-parse": "1.1.0", + "gnode": "0.1.2", + "istanbul": "0.4.3", + "mocha": "1.21.5", + "raw-body": "2.1.6", + "stream-to-array": "2.3.0" + }, + "files": [ + "HISTORY.md", + "LICENSE", + "README.md", + "db.json", + "index.js" + ], + "engines": { + "node": ">= 0.6" + }, + "scripts": { + "build": "node scripts/build", + "fetch": "gnode scripts/fetch-apache && gnode scripts/fetch-iana && gnode scripts/fetch-nginx", + "test": "mocha --reporter spec --bail --check-leaks test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", + "update": "npm run fetch && npm run build" + }, + "gitHead": "ba0d99fd05b3bfdc2ebcd78f858c25cb7db6af41", + "bugs": { + "url": "https://github.com/jshttp/mime-db/issues" + }, + "homepage": "https://github.com/jshttp/mime-db#readme", + "_id": "mime-db@1.23.0", + "_shasum": "a31b4070adaea27d732ea333740a64d0ec9a6659", + "_from": "mime-db@>=1.23.0 <1.24.0", + "_npmVersion": "2.15.1", + "_nodeVersion": "4.4.3", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "dist": { + "shasum": "a31b4070adaea27d732ea333740a64d0ec9a6659", + "tarball": "https://registry.npmjs.org/mime-db/-/mime-db-1.23.0.tgz" + }, + "maintainers": [ + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "jongleberry", + "email": "jonathanrichardong@gmail.com" + } + ], + "_npmOperationalInternal": { + "host": "packages-16-east.internal.npmjs.com", + "tmp": "tmp/mime-db-1.23.0.tgz_1462163798086_0.43938886746764183" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.23.0.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/package.json b/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/package.json index e941c289..a69300b6 100644 --- a/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/package.json +++ b/ui/node_modules/express/node_modules/type-is/node_modules/mime-types/package.json @@ -1,89 +1,89 @@ -{ - "name": "mime-types", - "description": "The ultimate javascript content-type utility.", - "version": "2.1.11", - "contributors": [ - { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "Jeremiah Senkpiel", - "email": "fishrock123@rocketmail.com", - "url": "https://searchbeam.jit.su" - }, - { - "name": "Jonathan Ong", - "email": "me@jongleberry.com", - "url": "http://jongleberry.com" - } - ], - "license": "MIT", - "keywords": [ - "mime", - "types" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/mime-types.git" - }, - "dependencies": { - "mime-db": "~1.23.0" - }, - "devDependencies": { - "istanbul": "0.4.3", - "mocha": "1.21.5" - }, - "files": [ - "HISTORY.md", - "LICENSE", - "index.js" - ], - "engines": { - "node": ">= 0.6" - }, - "scripts": { - "test": "mocha --reporter spec test/test.js", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot test/test.js", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot test/test.js" - }, - "gitHead": "298ffcf490a5d6e60edea7bf7a69036df04846b1", - "bugs": { - "url": "https://github.com/jshttp/mime-types/issues" - }, - "homepage": "https://github.com/jshttp/mime-types#readme", - "_id": "mime-types@2.1.11", - "_shasum": "c259c471bda808a85d6cd193b430a5fae4473b3c", - "_from": "mime-types@>=2.1.11 <2.2.0", - "_npmVersion": "2.15.1", - "_nodeVersion": "4.4.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "c259c471bda808a85d6cd193b430a5fae4473b3c", - "tarball": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.11.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "fishrock123", - "email": "fishrock123@rocketmail.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/mime-types-2.1.11.tgz_1462165365027_0.7217204745393246" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.11.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "mime-types", + "description": "The ultimate javascript content-type utility.", + "version": "2.1.11", + "contributors": [ + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "Jeremiah Senkpiel", + "email": "fishrock123@rocketmail.com", + "url": "https://searchbeam.jit.su" + }, + { + "name": "Jonathan Ong", + "email": "me@jongleberry.com", + "url": "http://jongleberry.com" + } + ], + "license": "MIT", + "keywords": [ + "mime", + "types" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/mime-types.git" + }, + "dependencies": { + "mime-db": "~1.23.0" + }, + "devDependencies": { + "istanbul": "0.4.3", + "mocha": "1.21.5" + }, + "files": [ + "HISTORY.md", + "LICENSE", + "index.js" + ], + "engines": { + "node": ">= 0.6" + }, + "scripts": { + "test": "mocha --reporter spec test/test.js", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot test/test.js", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot test/test.js" + }, + "gitHead": "298ffcf490a5d6e60edea7bf7a69036df04846b1", + "bugs": { + "url": "https://github.com/jshttp/mime-types/issues" + }, + "homepage": "https://github.com/jshttp/mime-types#readme", + "_id": "mime-types@2.1.11", + "_shasum": "c259c471bda808a85d6cd193b430a5fae4473b3c", + "_from": "mime-types@>=2.1.11 <2.2.0", + "_npmVersion": "2.15.1", + "_nodeVersion": "4.4.3", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "dist": { + "shasum": "c259c471bda808a85d6cd193b430a5fae4473b3c", + "tarball": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.11.tgz" + }, + "maintainers": [ + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "fishrock123", + "email": "fishrock123@rocketmail.com" + }, + { + "name": "jongleberry", + "email": "jonathanrichardong@gmail.com" + } + ], + "_npmOperationalInternal": { + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/mime-types-2.1.11.tgz_1462165365027_0.7217204745393246" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.11.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/type-is/package.json b/ui/node_modules/express/node_modules/type-is/package.json index 9d2c1361..a2150111 100644 --- a/ui/node_modules/express/node_modules/type-is/package.json +++ b/ui/node_modules/express/node_modules/type-is/package.json @@ -1,87 +1,87 @@ -{ - "name": "type-is", - "description": "Infer the content-type of a request.", - "version": "1.6.13", - "contributors": [ - { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "Jonathan Ong", - "email": "me@jongleberry.com", - "url": "http://jongleberry.com" - } - ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/type-is.git" - }, - "dependencies": { - "media-typer": "0.3.0", - "mime-types": "~2.1.11" - }, - "devDependencies": { - "eslint": "2.10.2", - "eslint-config-standard": "5.3.1", - "eslint-plugin-promise": "1.1.0", - "eslint-plugin-standard": "1.3.2", - "istanbul": "0.4.3", - "mocha": "1.21.5" - }, - "engines": { - "node": ">= 0.6" - }, - "files": [ - "LICENSE", - "HISTORY.md", - "index.js" - ], - "scripts": { - "lint": "eslint **/*.js", - "test": "mocha --reporter spec --check-leaks --bail test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" - }, - "keywords": [ - "content", - "type", - "checking" - ], - "gitHead": "88c47523fff910343b3ca7d4928dad40f21ea6cd", - "bugs": { - "url": "https://github.com/jshttp/type-is/issues" - }, - "homepage": "https://github.com/jshttp/type-is#readme", - "_id": "type-is@1.6.13", - "_shasum": "6e83ba7bc30cd33a7bb0b7fb00737a2085bf9d08", - "_from": "type-is@>=1.6.13 <1.7.0", - "_npmVersion": "2.15.1", - "_nodeVersion": "4.4.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "6e83ba7bc30cd33a7bb0b7fb00737a2085bf9d08", - "tarball": "https://registry.npmjs.org/type-is/-/type-is-1.6.13.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/type-is-1.6.13.tgz_1463622049206_0.9134831207338721" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.13.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "type-is", + "description": "Infer the content-type of a request.", + "version": "1.6.13", + "contributors": [ + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "Jonathan Ong", + "email": "me@jongleberry.com", + "url": "http://jongleberry.com" + } + ], + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/type-is.git" + }, + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.11" + }, + "devDependencies": { + "eslint": "2.10.2", + "eslint-config-standard": "5.3.1", + "eslint-plugin-promise": "1.1.0", + "eslint-plugin-standard": "1.3.2", + "istanbul": "0.4.3", + "mocha": "1.21.5" + }, + "engines": { + "node": ">= 0.6" + }, + "files": [ + "LICENSE", + "HISTORY.md", + "index.js" + ], + "scripts": { + "lint": "eslint **/*.js", + "test": "mocha --reporter spec --check-leaks --bail test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" + }, + "keywords": [ + "content", + "type", + "checking" + ], + "gitHead": "88c47523fff910343b3ca7d4928dad40f21ea6cd", + "bugs": { + "url": "https://github.com/jshttp/type-is/issues" + }, + "homepage": "https://github.com/jshttp/type-is#readme", + "_id": "type-is@1.6.13", + "_shasum": "6e83ba7bc30cd33a7bb0b7fb00737a2085bf9d08", + "_from": "type-is@>=1.6.13 <1.7.0", + "_npmVersion": "2.15.1", + "_nodeVersion": "4.4.3", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "dist": { + "shasum": "6e83ba7bc30cd33a7bb0b7fb00737a2085bf9d08", + "tarball": "https://registry.npmjs.org/type-is/-/type-is-1.6.13.tgz" + }, + "maintainers": [ + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "jongleberry", + "email": "jonathanrichardong@gmail.com" + } + ], + "_npmOperationalInternal": { + "host": "packages-16-east.internal.npmjs.com", + "tmp": "tmp/type-is-1.6.13.tgz_1463622049206_0.9134831207338721" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.13.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/node_modules/utils-merge/.travis.yml b/ui/node_modules/express/node_modules/utils-merge/.travis.yml index df2b8ba6..af92b021 100644 --- a/ui/node_modules/express/node_modules/utils-merge/.travis.yml +++ b/ui/node_modules/express/node_modules/utils-merge/.travis.yml @@ -1,6 +1,6 @@ -language: "node_js" -node_js: - - "0.4" - - "0.6" - - "0.8" - - "0.10" +language: "node_js" +node_js: + - "0.4" + - "0.6" + - "0.8" + - "0.10" diff --git a/ui/node_modules/express/node_modules/utils-merge/LICENSE b/ui/node_modules/express/node_modules/utils-merge/LICENSE index ae002a55..e33bd10b 100644 --- a/ui/node_modules/express/node_modules/utils-merge/LICENSE +++ b/ui/node_modules/express/node_modules/utils-merge/LICENSE @@ -1,20 +1,20 @@ -(The MIT License) - -Copyright (c) 2013 Jared Hanson - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2013 Jared Hanson + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/utils-merge/README.md b/ui/node_modules/express/node_modules/utils-merge/README.md index 46c6367d..2f94e9bd 100644 --- a/ui/node_modules/express/node_modules/utils-merge/README.md +++ b/ui/node_modules/express/node_modules/utils-merge/README.md @@ -1,34 +1,34 @@ -# utils-merge - -Merges the properties from a source object into a destination object. - -## Install - - $ npm install utils-merge - -## Usage - -```javascript -var a = { foo: 'bar' } - , b = { bar: 'baz' }; - -merge(a, b); -// => { foo: 'bar', bar: 'baz' } -``` - -## Tests - - $ npm install - $ npm test - -[![Build Status](https://secure.travis-ci.org/jaredhanson/utils-merge.png)](http://travis-ci.org/jaredhanson/utils-merge) - -## Credits - - - [Jared Hanson](http://github.com/jaredhanson) - -## License - -[The MIT License](http://opensource.org/licenses/MIT) - -Copyright (c) 2013 Jared Hanson <[http://jaredhanson.net/](http://jaredhanson.net/)> +# utils-merge + +Merges the properties from a source object into a destination object. + +## Install + + $ npm install utils-merge + +## Usage + +```javascript +var a = { foo: 'bar' } + , b = { bar: 'baz' }; + +merge(a, b); +// => { foo: 'bar', bar: 'baz' } +``` + +## Tests + + $ npm install + $ npm test + +[![Build Status](https://secure.travis-ci.org/jaredhanson/utils-merge.png)](http://travis-ci.org/jaredhanson/utils-merge) + +## Credits + + - [Jared Hanson](http://github.com/jaredhanson) + +## License + +[The MIT License](http://opensource.org/licenses/MIT) + +Copyright (c) 2013 Jared Hanson <[http://jaredhanson.net/](http://jaredhanson.net/)> diff --git a/ui/node_modules/express/node_modules/utils-merge/index.js b/ui/node_modules/express/node_modules/utils-merge/index.js index 59006dd1..4265c694 100644 --- a/ui/node_modules/express/node_modules/utils-merge/index.js +++ b/ui/node_modules/express/node_modules/utils-merge/index.js @@ -1,23 +1,23 @@ -/** - * Merge object b with object a. - * - * var a = { foo: 'bar' } - * , b = { bar: 'baz' }; - * - * merge(a, b); - * // => { foo: 'bar', bar: 'baz' } - * - * @param {Object} a - * @param {Object} b - * @return {Object} - * @api public - */ - -exports = module.exports = function(a, b){ - if (a && b) { - for (var key in b) { - a[key] = b[key]; - } - } - return a; -}; +/** + * Merge object b with object a. + * + * var a = { foo: 'bar' } + * , b = { bar: 'baz' }; + * + * merge(a, b); + * // => { foo: 'bar', bar: 'baz' } + * + * @param {Object} a + * @param {Object} b + * @return {Object} + * @api public + */ + +exports = module.exports = function(a, b){ + if (a && b) { + for (var key in b) { + a[key] = b[key]; + } + } + return a; +}; diff --git a/ui/node_modules/express/node_modules/utils-merge/package.json b/ui/node_modules/express/node_modules/utils-merge/package.json index 0273893c..e86cad01 100644 --- a/ui/node_modules/express/node_modules/utils-merge/package.json +++ b/ui/node_modules/express/node_modules/utils-merge/package.json @@ -1,60 +1,60 @@ -{ - "name": "utils-merge", - "version": "1.0.0", - "description": "merge() utility function", - "keywords": [ - "util" - ], - "repository": { - "type": "git", - "url": "git://github.com/jaredhanson/utils-merge.git" - }, - "bugs": { - "url": "http://github.com/jaredhanson/utils-merge/issues" - }, - "author": { - "name": "Jared Hanson", - "email": "jaredhanson@gmail.com", - "url": "http://www.jaredhanson.net/" - }, - "licenses": [ - { - "type": "MIT", - "url": "http://www.opensource.org/licenses/MIT" - } - ], - "main": "./index", - "dependencies": {}, - "devDependencies": { - "mocha": "1.x.x", - "chai": "1.x.x" - }, - "scripts": { - "test": "mocha --reporter spec --require test/bootstrap/node test/*.test.js" - }, - "engines": { - "node": ">= 0.4.0" - }, - "_id": "utils-merge@1.0.0", - "dist": { - "shasum": "0294fb922bb9375153541c4f7096231f287c8af8", - "tarball": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.0.tgz" - }, - "_from": "utils-merge@1.0.0", - "_npmVersion": "1.2.25", - "_npmUser": { - "name": "jaredhanson", - "email": "jaredhanson@gmail.com" - }, - "maintainers": [ - { - "name": "jaredhanson", - "email": "jaredhanson@gmail.com" - } - ], - "directories": {}, - "_shasum": "0294fb922bb9375153541c4f7096231f287c8af8", - "_resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.0.tgz", - "readme": "ERROR: No README data found!", - "homepage": "https://github.com/jaredhanson/utils-merge#readme" -} +{ + "name": "utils-merge", + "version": "1.0.0", + "description": "merge() utility function", + "keywords": [ + "util" + ], + "repository": { + "type": "git", + "url": "git://github.com/jaredhanson/utils-merge.git" + }, + "bugs": { + "url": "http://github.com/jaredhanson/utils-merge/issues" + }, + "author": { + "name": "Jared Hanson", + "email": "jaredhanson@gmail.com", + "url": "http://www.jaredhanson.net/" + }, + "licenses": [ + { + "type": "MIT", + "url": "http://www.opensource.org/licenses/MIT" + } + ], + "main": "./index", + "dependencies": {}, + "devDependencies": { + "mocha": "1.x.x", + "chai": "1.x.x" + }, + "scripts": { + "test": "mocha --reporter spec --require test/bootstrap/node test/*.test.js" + }, + "engines": { + "node": ">= 0.4.0" + }, + "_id": "utils-merge@1.0.0", + "dist": { + "shasum": "0294fb922bb9375153541c4f7096231f287c8af8", + "tarball": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.0.tgz" + }, + "_from": "utils-merge@1.0.0", + "_npmVersion": "1.2.25", + "_npmUser": { + "name": "jaredhanson", + "email": "jaredhanson@gmail.com" + }, + "maintainers": [ + { + "name": "jaredhanson", + "email": "jaredhanson@gmail.com" + } + ], + "directories": {}, + "_shasum": "0294fb922bb9375153541c4f7096231f287c8af8", + "_resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.0.tgz", + "readme": "ERROR: No README data found!", + "homepage": "https://github.com/jaredhanson/utils-merge#readme" +} diff --git a/ui/node_modules/express/node_modules/vary/HISTORY.md b/ui/node_modules/express/node_modules/vary/HISTORY.md index 5cebed61..ed68118e 100644 --- a/ui/node_modules/express/node_modules/vary/HISTORY.md +++ b/ui/node_modules/express/node_modules/vary/HISTORY.md @@ -1,29 +1,29 @@ -1.1.0 / 2015-09-29 -================== - - * Only accept valid field names in the `field` argument - - Ensures the resulting string is a valid HTTP header value - -1.0.1 / 2015-07-08 -================== - - * Fix setting empty header from empty `field` - * perf: enable strict mode - * perf: remove argument reassignments - -1.0.0 / 2014-08-10 -================== - - * Accept valid `Vary` header string as `field` - * Add `vary.append` for low-level string manipulation - * Move to `jshttp` orgainzation - -0.1.0 / 2014-06-05 -================== - - * Support array of fields to set - -0.0.0 / 2014-06-04 -================== - - * Initial release +1.1.0 / 2015-09-29 +================== + + * Only accept valid field names in the `field` argument + - Ensures the resulting string is a valid HTTP header value + +1.0.1 / 2015-07-08 +================== + + * Fix setting empty header from empty `field` + * perf: enable strict mode + * perf: remove argument reassignments + +1.0.0 / 2014-08-10 +================== + + * Accept valid `Vary` header string as `field` + * Add `vary.append` for low-level string manipulation + * Move to `jshttp` orgainzation + +0.1.0 / 2014-06-05 +================== + + * Support array of fields to set + +0.0.0 / 2014-06-04 +================== + + * Initial release diff --git a/ui/node_modules/express/node_modules/vary/LICENSE b/ui/node_modules/express/node_modules/vary/LICENSE index a35fc45b..142ede38 100644 --- a/ui/node_modules/express/node_modules/vary/LICENSE +++ b/ui/node_modules/express/node_modules/vary/LICENSE @@ -1,22 +1,22 @@ -(The MIT License) - -Copyright (c) 2014-2015 Douglas Christopher Wilson - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2014-2015 Douglas Christopher Wilson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/express/node_modules/vary/README.md b/ui/node_modules/express/node_modules/vary/README.md index c305836d..59665427 100644 --- a/ui/node_modules/express/node_modules/vary/README.md +++ b/ui/node_modules/express/node_modules/vary/README.md @@ -1,91 +1,91 @@ -# vary - -[![NPM Version][npm-image]][npm-url] -[![NPM Downloads][downloads-image]][downloads-url] -[![Node.js Version][node-version-image]][node-version-url] -[![Build Status][travis-image]][travis-url] -[![Test Coverage][coveralls-image]][coveralls-url] - -Manipulate the HTTP Vary header - -## Installation - -```sh -$ npm install vary -``` - -## API - -```js -var vary = require('vary') -``` - -### vary(res, field) - -Adds the given header `field` to the `Vary` response header of `res`. -This can be a string of a single field, a string of a valid `Vary` -header, or an array of multiple fields. - -This will append the header if not already listed, otherwise leaves -it listed in the current location. - -```js -// Append "Origin" to the Vary header of the response -vary(res, 'Origin') -``` - -### vary.append(header, field) - -Adds the given header `field` to the `Vary` response header string `header`. -This can be a string of a single field, a string of a valid `Vary` header, -or an array of multiple fields. - -This will append the header if not already listed, otherwise leaves -it listed in the current location. The new header string is returned. - -```js -// Get header string appending "Origin" to "Accept, User-Agent" -vary.append('Accept, User-Agent', 'Origin') -``` - -## Examples - -### Updating the Vary header when content is based on it - -```js -var http = require('http') -var vary = require('vary') - -http.createServer(function onRequest(req, res) { - // about to user-agent sniff - vary(res, 'User-Agent') - - var ua = req.headers['user-agent'] || '' - var isMobile = /mobi|android|touch|mini/i.test(ua) - - // serve site, depending on isMobile - res.setHeader('Content-Type', 'text/html') - res.end('You are (probably) ' + (isMobile ? '' : 'not ') + 'a mobile user') -}) -``` - -## Testing - -```sh -$ npm test -``` - -## License - -[MIT](LICENSE) - -[npm-image]: https://img.shields.io/npm/v/vary.svg -[npm-url]: https://npmjs.org/package/vary -[node-version-image]: https://img.shields.io/node/v/vary.svg -[node-version-url]: http://nodejs.org/download/ -[travis-image]: https://img.shields.io/travis/jshttp/vary/master.svg -[travis-url]: https://travis-ci.org/jshttp/vary -[coveralls-image]: https://img.shields.io/coveralls/jshttp/vary/master.svg -[coveralls-url]: https://coveralls.io/r/jshttp/vary -[downloads-image]: https://img.shields.io/npm/dm/vary.svg -[downloads-url]: https://npmjs.org/package/vary +# vary + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-version-image]][node-version-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +Manipulate the HTTP Vary header + +## Installation + +```sh +$ npm install vary +``` + +## API + +```js +var vary = require('vary') +``` + +### vary(res, field) + +Adds the given header `field` to the `Vary` response header of `res`. +This can be a string of a single field, a string of a valid `Vary` +header, or an array of multiple fields. + +This will append the header if not already listed, otherwise leaves +it listed in the current location. + +```js +// Append "Origin" to the Vary header of the response +vary(res, 'Origin') +``` + +### vary.append(header, field) + +Adds the given header `field` to the `Vary` response header string `header`. +This can be a string of a single field, a string of a valid `Vary` header, +or an array of multiple fields. + +This will append the header if not already listed, otherwise leaves +it listed in the current location. The new header string is returned. + +```js +// Get header string appending "Origin" to "Accept, User-Agent" +vary.append('Accept, User-Agent', 'Origin') +``` + +## Examples + +### Updating the Vary header when content is based on it + +```js +var http = require('http') +var vary = require('vary') + +http.createServer(function onRequest(req, res) { + // about to user-agent sniff + vary(res, 'User-Agent') + + var ua = req.headers['user-agent'] || '' + var isMobile = /mobi|android|touch|mini/i.test(ua) + + // serve site, depending on isMobile + res.setHeader('Content-Type', 'text/html') + res.end('You are (probably) ' + (isMobile ? '' : 'not ') + 'a mobile user') +}) +``` + +## Testing + +```sh +$ npm test +``` + +## License + +[MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/vary.svg +[npm-url]: https://npmjs.org/package/vary +[node-version-image]: https://img.shields.io/node/v/vary.svg +[node-version-url]: http://nodejs.org/download/ +[travis-image]: https://img.shields.io/travis/jshttp/vary/master.svg +[travis-url]: https://travis-ci.org/jshttp/vary +[coveralls-image]: https://img.shields.io/coveralls/jshttp/vary/master.svg +[coveralls-url]: https://coveralls.io/r/jshttp/vary +[downloads-image]: https://img.shields.io/npm/dm/vary.svg +[downloads-url]: https://npmjs.org/package/vary diff --git a/ui/node_modules/express/node_modules/vary/index.js b/ui/node_modules/express/node_modules/vary/index.js index f90af6e2..21dbaf1c 100644 --- a/ui/node_modules/express/node_modules/vary/index.js +++ b/ui/node_modules/express/node_modules/vary/index.js @@ -1,124 +1,124 @@ -/*! - * vary - * Copyright(c) 2014-2015 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict'; - -/** - * Module exports. - */ - -module.exports = vary; -module.exports.append = append; - -/** - * RegExp to match field-name in RFC 7230 sec 3.2 - * - * field-name = token - * token = 1*tchar - * tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" - * / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~" - * / DIGIT / ALPHA - * ; any VCHAR, except delimiters - */ - -var fieldNameRegExp = /^[!#$%&'\*\+\-\.\^_`\|~0-9A-Za-z]+$/ - -/** - * Append a field to a vary header. - * - * @param {String} header - * @param {String|Array} field - * @return {String} - * @api public - */ - -function append(header, field) { - if (typeof header !== 'string') { - throw new TypeError('header argument is required'); - } - - if (!field) { - throw new TypeError('field argument is required'); - } - - // get fields array - var fields = !Array.isArray(field) - ? parse(String(field)) - : field; - - // assert on invalid field names - for (var i = 0; i < fields.length; i++) { - if (!fieldNameRegExp.test(fields[i])) { - throw new TypeError('field argument contains an invalid header name'); - } - } - - // existing, unspecified vary - if (header === '*') { - return header; - } - - // enumerate current values - var val = header; - var vals = parse(header.toLowerCase()); - - // unspecified vary - if (fields.indexOf('*') !== -1 || vals.indexOf('*') !== -1) { - return '*'; - } - - for (var i = 0; i < fields.length; i++) { - var fld = fields[i].toLowerCase(); - - // append value (case-preserving) - if (vals.indexOf(fld) === -1) { - vals.push(fld); - val = val - ? val + ', ' + fields[i] - : fields[i]; - } - } - - return val; -} - -/** - * Parse a vary header into an array. - * - * @param {String} header - * @return {Array} - * @api private - */ - -function parse(header) { - return header.trim().split(/ *, */); -} - -/** - * Mark that a request is varied on a header field. - * - * @param {Object} res - * @param {String|Array} field - * @api public - */ - -function vary(res, field) { - if (!res || !res.getHeader || !res.setHeader) { - // quack quack - throw new TypeError('res argument is required'); - } - - // get existing header - var val = res.getHeader('Vary') || '' - var header = Array.isArray(val) - ? val.join(', ') - : String(val); - - // set new header - if ((val = append(header, field))) { - res.setHeader('Vary', val); - } -} +/*! + * vary + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict'; + +/** + * Module exports. + */ + +module.exports = vary; +module.exports.append = append; + +/** + * RegExp to match field-name in RFC 7230 sec 3.2 + * + * field-name = token + * token = 1*tchar + * tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" + * / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~" + * / DIGIT / ALPHA + * ; any VCHAR, except delimiters + */ + +var fieldNameRegExp = /^[!#$%&'\*\+\-\.\^_`\|~0-9A-Za-z]+$/ + +/** + * Append a field to a vary header. + * + * @param {String} header + * @param {String|Array} field + * @return {String} + * @api public + */ + +function append(header, field) { + if (typeof header !== 'string') { + throw new TypeError('header argument is required'); + } + + if (!field) { + throw new TypeError('field argument is required'); + } + + // get fields array + var fields = !Array.isArray(field) + ? parse(String(field)) + : field; + + // assert on invalid field names + for (var i = 0; i < fields.length; i++) { + if (!fieldNameRegExp.test(fields[i])) { + throw new TypeError('field argument contains an invalid header name'); + } + } + + // existing, unspecified vary + if (header === '*') { + return header; + } + + // enumerate current values + var val = header; + var vals = parse(header.toLowerCase()); + + // unspecified vary + if (fields.indexOf('*') !== -1 || vals.indexOf('*') !== -1) { + return '*'; + } + + for (var i = 0; i < fields.length; i++) { + var fld = fields[i].toLowerCase(); + + // append value (case-preserving) + if (vals.indexOf(fld) === -1) { + vals.push(fld); + val = val + ? val + ', ' + fields[i] + : fields[i]; + } + } + + return val; +} + +/** + * Parse a vary header into an array. + * + * @param {String} header + * @return {Array} + * @api private + */ + +function parse(header) { + return header.trim().split(/ *, */); +} + +/** + * Mark that a request is varied on a header field. + * + * @param {Object} res + * @param {String|Array} field + * @api public + */ + +function vary(res, field) { + if (!res || !res.getHeader || !res.setHeader) { + // quack quack + throw new TypeError('res argument is required'); + } + + // get existing header + var val = res.getHeader('Vary') || '' + var header = Array.isArray(val) + ? val.join(', ') + : String(val); + + // set new header + if ((val = append(header, field))) { + res.setHeader('Vary', val); + } +} diff --git a/ui/node_modules/express/node_modules/vary/package.json b/ui/node_modules/express/node_modules/vary/package.json index c0e6349c..ae995137 100644 --- a/ui/node_modules/express/node_modules/vary/package.json +++ b/ui/node_modules/express/node_modules/vary/package.json @@ -1,72 +1,72 @@ -{ - "name": "vary", - "description": "Manipulate the HTTP Vary header", - "version": "1.1.0", - "author": { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - }, - "license": "MIT", - "keywords": [ - "http", - "res", - "vary" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/vary.git" - }, - "devDependencies": { - "istanbul": "0.3.21", - "mocha": "2.3.3", - "supertest": "1.1.0" - }, - "files": [ - "HISTORY.md", - "LICENSE", - "README.md", - "index.js" - ], - "engines": { - "node": ">= 0.8" - }, - "scripts": { - "test": "mocha --reporter spec --bail --check-leaks test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" - }, - "gitHead": "13b03e9bf97da9d83bfeac84d84144137d84c257", - "bugs": { - "url": "https://github.com/jshttp/vary/issues" - }, - "homepage": "https://github.com/jshttp/vary", - "_id": "vary@1.1.0", - "_shasum": "e1e5affbbd16ae768dd2674394b9ad3022653140", - "_from": "vary@>=1.1.0 <1.2.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "fishrock123", - "email": "fishrock123@rocketmail.com" - } - ], - "dist": { - "shasum": "e1e5affbbd16ae768dd2674394b9ad3022653140", - "tarball": "https://registry.npmjs.org/vary/-/vary-1.1.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/vary/-/vary-1.1.0.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "vary", + "description": "Manipulate the HTTP Vary header", + "version": "1.1.0", + "author": { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + }, + "license": "MIT", + "keywords": [ + "http", + "res", + "vary" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/vary.git" + }, + "devDependencies": { + "istanbul": "0.3.21", + "mocha": "2.3.3", + "supertest": "1.1.0" + }, + "files": [ + "HISTORY.md", + "LICENSE", + "README.md", + "index.js" + ], + "engines": { + "node": ">= 0.8" + }, + "scripts": { + "test": "mocha --reporter spec --bail --check-leaks test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" + }, + "gitHead": "13b03e9bf97da9d83bfeac84d84144137d84c257", + "bugs": { + "url": "https://github.com/jshttp/vary/issues" + }, + "homepage": "https://github.com/jshttp/vary", + "_id": "vary@1.1.0", + "_shasum": "e1e5affbbd16ae768dd2674394b9ad3022653140", + "_from": "vary@>=1.1.0 <1.2.0", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "maintainers": [ + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "jongleberry", + "email": "jonathanrichardong@gmail.com" + }, + { + "name": "fishrock123", + "email": "fishrock123@rocketmail.com" + } + ], + "dist": { + "shasum": "e1e5affbbd16ae768dd2674394b9ad3022653140", + "tarball": "https://registry.npmjs.org/vary/-/vary-1.1.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/vary/-/vary-1.1.0.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/express/package.json b/ui/node_modules/express/package.json index 8a81a9f4..12d42039 100644 --- a/ui/node_modules/express/package.json +++ b/ui/node_modules/express/package.json @@ -1,160 +1,160 @@ -{ - "name": "express", - "description": "Fast, unopinionated, minimalist web framework", - "version": "4.14.0", - "author": { - "name": "TJ Holowaychuk", - "email": "tj@vision-media.ca" - }, - "contributors": [ - { - "name": "Aaron Heckmann", - "email": "aaron.heckmann+github@gmail.com" - }, - { - "name": "Ciaran Jessup", - "email": "ciaranj@gmail.com" - }, - { - "name": "Douglas Christopher Wilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "Guillermo Rauch", - "email": "rauchg@gmail.com" - }, - { - "name": "Jonathan Ong", - "email": "me@jongleberry.com" - }, - { - "name": "Roman Shtylman", - "email": "shtylman+expressjs@gmail.com" - }, - { - "name": "Young Jae Sim", - "email": "hanul@hanul.me" - } - ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/expressjs/express.git" - }, - "homepage": "http://expressjs.com/", - "keywords": [ - "express", - "framework", - "sinatra", - "web", - "rest", - "restful", - "router", - "app", - "api" - ], - "dependencies": { - "accepts": "~1.3.3", - "array-flatten": "1.1.1", - "content-disposition": "0.5.1", - "content-type": "~1.0.2", - "cookie": "0.3.1", - "cookie-signature": "1.0.6", - "debug": "~2.2.0", - "depd": "~1.1.0", - "encodeurl": "~1.0.1", - "escape-html": "~1.0.3", - "etag": "~1.7.0", - "finalhandler": "0.5.0", - "fresh": "0.3.0", - "merge-descriptors": "1.0.1", - "methods": "~1.1.2", - "on-finished": "~2.3.0", - "parseurl": "~1.3.1", - "path-to-regexp": "0.1.7", - "proxy-addr": "~1.1.2", - "qs": "6.2.0", - "range-parser": "~1.2.0", - "send": "0.14.1", - "serve-static": "~1.11.1", - "type-is": "~1.6.13", - "utils-merge": "1.0.0", - "vary": "~1.1.0" - }, - "devDependencies": { - "after": "0.8.1", - "body-parser": "~1.15.1", - "cookie-parser": "~1.4.3", - "ejs": "2.4.2", - "istanbul": "0.4.3", - "marked": "0.3.5", - "method-override": "~2.3.6", - "mocha": "2.5.3", - "morgan": "~1.7.0", - "should": "9.0.2", - "supertest": "1.2.0", - "connect-redis": "~2.4.1", - "cookie-session": "~1.2.0", - "express-session": "~1.13.0", - "jade": "~1.11.0", - "multiparty": "~4.1.2", - "vhost": "~3.0.2" - }, - "engines": { - "node": ">= 0.10.0" - }, - "files": [ - "LICENSE", - "History.md", - "Readme.md", - "index.js", - "lib/" - ], - "scripts": { - "test": "mocha --require test/support/env --reporter spec --bail --check-leaks test/ test/acceptance/", - "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/ test/acceptance/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks test/ test/acceptance/", - "test-tap": "mocha --require test/support/env --reporter tap --check-leaks test/ test/acceptance/" - }, - "gitHead": "9375a9afa9d7baa814b454c7a6818a7471aaef00", - "bugs": { - "url": "https://github.com/expressjs/express/issues" - }, - "_id": "express@4.14.0", - "_shasum": "c1ee3f42cdc891fb3dc650a8922d51ec847d0d66", - "_from": "express@*", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "hacksparrow", - "email": "captain@hacksparrow.com" - }, - { - "name": "jasnell", - "email": "jasnell@gmail.com" - }, - { - "name": "mikeal", - "email": "mikeal.rogers@gmail.com" - } - ], - "dist": { - "shasum": "c1ee3f42cdc891fb3dc650a8922d51ec847d0d66", - "tarball": "https://registry.npmjs.org/express/-/express-4.14.0.tgz" - }, - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/express-4.14.0.tgz_1466095407850_0.17484632693231106" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/express/-/express-4.14.0.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "express", + "description": "Fast, unopinionated, minimalist web framework", + "version": "4.14.0", + "author": { + "name": "TJ Holowaychuk", + "email": "tj@vision-media.ca" + }, + "contributors": [ + { + "name": "Aaron Heckmann", + "email": "aaron.heckmann+github@gmail.com" + }, + { + "name": "Ciaran Jessup", + "email": "ciaranj@gmail.com" + }, + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "Guillermo Rauch", + "email": "rauchg@gmail.com" + }, + { + "name": "Jonathan Ong", + "email": "me@jongleberry.com" + }, + { + "name": "Roman Shtylman", + "email": "shtylman+expressjs@gmail.com" + }, + { + "name": "Young Jae Sim", + "email": "hanul@hanul.me" + } + ], + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/expressjs/express.git" + }, + "homepage": "http://expressjs.com/", + "keywords": [ + "express", + "framework", + "sinatra", + "web", + "rest", + "restful", + "router", + "app", + "api" + ], + "dependencies": { + "accepts": "~1.3.3", + "array-flatten": "1.1.1", + "content-disposition": "0.5.1", + "content-type": "~1.0.2", + "cookie": "0.3.1", + "cookie-signature": "1.0.6", + "debug": "~2.2.0", + "depd": "~1.1.0", + "encodeurl": "~1.0.1", + "escape-html": "~1.0.3", + "etag": "~1.7.0", + "finalhandler": "0.5.0", + "fresh": "0.3.0", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "~2.3.0", + "parseurl": "~1.3.1", + "path-to-regexp": "0.1.7", + "proxy-addr": "~1.1.2", + "qs": "6.2.0", + "range-parser": "~1.2.0", + "send": "0.14.1", + "serve-static": "~1.11.1", + "type-is": "~1.6.13", + "utils-merge": "1.0.0", + "vary": "~1.1.0" + }, + "devDependencies": { + "after": "0.8.1", + "body-parser": "~1.15.1", + "cookie-parser": "~1.4.3", + "ejs": "2.4.2", + "istanbul": "0.4.3", + "marked": "0.3.5", + "method-override": "~2.3.6", + "mocha": "2.5.3", + "morgan": "~1.7.0", + "should": "9.0.2", + "supertest": "1.2.0", + "connect-redis": "~2.4.1", + "cookie-session": "~1.2.0", + "express-session": "~1.13.0", + "jade": "~1.11.0", + "multiparty": "~4.1.2", + "vhost": "~3.0.2" + }, + "engines": { + "node": ">= 0.10.0" + }, + "files": [ + "LICENSE", + "History.md", + "Readme.md", + "index.js", + "lib/" + ], + "scripts": { + "test": "mocha --require test/support/env --reporter spec --bail --check-leaks test/ test/acceptance/", + "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/ test/acceptance/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks test/ test/acceptance/", + "test-tap": "mocha --require test/support/env --reporter tap --check-leaks test/ test/acceptance/" + }, + "gitHead": "9375a9afa9d7baa814b454c7a6818a7471aaef00", + "bugs": { + "url": "https://github.com/expressjs/express/issues" + }, + "_id": "express@4.14.0", + "_shasum": "c1ee3f42cdc891fb3dc650a8922d51ec847d0d66", + "_from": "express@*", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + "maintainers": [ + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "hacksparrow", + "email": "captain@hacksparrow.com" + }, + { + "name": "jasnell", + "email": "jasnell@gmail.com" + }, + { + "name": "mikeal", + "email": "mikeal.rogers@gmail.com" + } + ], + "dist": { + "shasum": "c1ee3f42cdc891fb3dc650a8922d51ec847d0d66", + "tarball": "https://registry.npmjs.org/express/-/express-4.14.0.tgz" + }, + "_npmOperationalInternal": { + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/express-4.14.0.tgz_1466095407850_0.17484632693231106" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/express/-/express-4.14.0.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/socket.io/.npmignore b/ui/node_modules/socket.io/.npmignore index f59d6bfc..55a736ba 100644 --- a/ui/node_modules/socket.io/.npmignore +++ b/ui/node_modules/socket.io/.npmignore @@ -1,4 +1,4 @@ -support -test -examples -.gitignore +support +test +examples +.gitignore diff --git a/ui/node_modules/socket.io/.travis.yml b/ui/node_modules/socket.io/.travis.yml index 423ef317..93286a05 100644 --- a/ui/node_modules/socket.io/.travis.yml +++ b/ui/node_modules/socket.io/.travis.yml @@ -1,20 +1,20 @@ -sudo: false -before_install: - - npm install -g npm@'>=1.4.3' -language: node_js -node_js: - - "0.8" - - "0.10" - - "0.12" - - "4" - -git: - depth: 1 - -#matrix: - #fast_finish: true - #allow_failures: - #- node_js: "0.11" - -notifications: - irc: "irc.freenode.org#socket.io" +sudo: false +before_install: + - npm install -g npm@'>=1.4.3' +language: node_js +node_js: + - "0.8" + - "0.10" + - "0.12" + - "4" + +git: + depth: 1 + +#matrix: + #fast_finish: true + #allow_failures: + #- node_js: "0.11" + +notifications: + irc: "irc.freenode.org#socket.io" diff --git a/ui/node_modules/socket.io/History.md b/ui/node_modules/socket.io/History.md index bdff7db4..b379ef35 100644 --- a/ui/node_modules/socket.io/History.md +++ b/ui/node_modules/socket.io/History.md @@ -1,571 +1,571 @@ - -1.4.8 / 2016-06-23 -================== - - * package: bump `engine.io` - -1.4.7 / 2016-06-23 -================== - - * package: bump `engine.io` - -1.4.6 / 2016-05-02 -================== - - * package: bump engine.io - -1.4.5 / 2016-01-26 -================== - - * fix closing the underlying `http.Server` - -1.4.4 / 2016-01-10 -================== - - * package: bump `engine.io` - -1.4.3 / 2016-01-08 -================== - - * bump `socket.io-client` - -1.4.2 / 2016-01-07 -================== - - * bump `engine.io` - -1.4.1 / 2016-01-07 -================== - - * version bump - -1.4.0 / 2015-11-28 -================== - - * socket.io: increase large binary data test timeout - * package: bump `engine.io` for release - * trigger callback even when joining an already joined room - * package: bump parser - * namespace: clear rooms flag after a clients call (fixes #1978) - * package: bump `socket.io-parser` - * fixed tests with large data - * fixed a typo in the example code - * package: bump mocha - * package: bump `has-binary` and `zuul-ngrok` - * package: bump `engine.io` and `socket.io-client` - * README: clarified documentation of Socket.in - * README: fixed up legacy repo links - * test: better timeout for stress test - * socket: don't set request property which has a getter - * removed proxy index file - * support flags on namespace - * improve Socket#packet and Client#packet - * socket: warn node_redis-style about missing `error` - * test: added failing test - * test: increase timeout for large binary data test - * package: bump `has-binary` to work with all objects (fixes #1955) - * fix origin verification default https port [evanlucas] - * support compression [nkzawa] - * changed type of `Client#sockets`, `Namespace#sockets` and `Socket#rooms` to maps (instead of arrays) - -1.3.7 / 2015-09-21 -================== - - * package: bump `socket.io-client` for node4 compatibility - * package: bump `engine.io` for node4 compatibility - -1.3.6 / 2015-07-14 -================== - - * package: bump `engine.io` to fix build on windows - -1.3.5 / 2015-03-03 -================== - - * package: bump `socket.io-parser` - -1.3.4 / 2015-02-14 -================== - - * package: bump `socket.io-client` - -1.3.3 / 2015-02-03 -================== - - * socket: warn node_redis-style about missing `error` - * package: bump parser to better handle bad binary packets - -1.3.2 / 2015-01-19 -================== - - * no change on this release - -1.3.1 / 2015-01-19 -================== - - * no change on this release - * package: bump `engine.io` - -1.3.0 / 2015-01-19 -================== - - * package: bump `engine.io` - * add test for reconnection after server restarts [rase-] - * update license with up-to-date year range [fay-jai] - * fix leaving unknown rooms [defunctzombie] - * allow null origins when allowed origins is a function [drewblaisdell] - * fix tests on node 0.11 - * package: fix `npm test` to run on windows - * package: bump `debug` v2.1.0 [coderaiser] - * added tests for volatile [rase-] - -1.2.1 / 2014-11-21 -================== - - * fix protocol violations and improve error handling (GH-1880) - * package: bump `engine.io` for websocket leak fix [3rd-Eden] - * style tweaks - -1.2.0 / 2014-10-27 -================== - - * package: bump `engine.io` - * downloads badge - * add test to check that empty rooms are autopruned - * added Server#origins(v:Function) description for dynamic CORS - * added test coverage for Server#origins(function) for dynamic CORS - * added optional Server#origins(function) for dynamic CORS - * fix usage example for Server#close - * package: fix main file for example application 'chat' - * package: bump `socket.io-parser` - * update README http ctor to createServer() - * bump adapter with a lot of fixes for room bookkeeping - -1.1.0 / 2014-09-04 -================== - - * examples: minor fix of escaping - * testing for equivalence of namespaces starting with / or without - * update index.js - * added relevant tests - * take "" and "/" as equivalent namespaces on server - * use svg instead of png to get better image quality in readme - * make CI build faster - * fix splice arguments and `socket.rooms` value update in `socket.leaveAll`. - * client cannot connect to non-existing namespaces - * bump engine.io version to get the cached IP address - * fixed handshake object address property and made the test case more strict. - * package: bump `engine.io` - * fixed the failing test where server crashes on disconnect involving connectBuffer - * npmignore: ignore `.gitignore` (fixes #1607) - * test: added failing case for `socket.disconnect` and nsps - * fix repo in package.json - * improve Close documentation - * use ephemeral ports - * fix: We should use the standard http protocol to handler the etag header. - * override default browser font-family for inputs - * update has-binary-data to 1.0.3 - * add close specs - * add ability to stop the http server even if not created inside socket.io - * make sure server gets close - * Add test case for checking that reconnect_failed is fired only once upon failure - * package: bump `socket.io-parser` for `component-emitter` dep fix - -1.0.6 / 2014-06-19 -================== - - * package: bump `socket.io-client` - -1.0.5 / 2014-06-16 -================== - - * package: bump `engine.io` to fix jsonp `\n` bug and CORS warnings - * index: fix typo [yanatan16] - * add `removeListener` to blacklisted events - * examples: clearer instructions to install chat example - * index: fix namespace `connectBuffer` issue - -1.0.4 / 2014-06-02 -================== - - * package: bump socket.io-client - -1.0.3 / 2014-05-31 -================== - - * package: bump `socket.io-client` - * package: bump `socket.io-parser` for binary ACK fix - * package: bump `engine.io` for binary UTF8 fix - * example: fix XSS in chat example - -1.0.2 / 2014-05-28 -================== - - * package: bump `socket.io-parser` for windows fix - -1.0.1 / 2014-05-28 -================== - - * bump due to bad npm tag - -1.0.0 / 2014-05-28 -================== - - * stable release - -1.0.0-pre5 / 2014-05-22 -======================= - - * package: bump `socket.io-client` for parser fixes - * package: bump `engine.io` - -1.0.0-pre4 / 2014-05-19 -======================= - - * package: bump client - -1.0.0-pre3 / 2014-05-17 -======================= - - * package: bump parser - * package: bump engine.io - -1.0.0-pre2 / 2014-04-27 -======================= - - * package: bump `engine.io` - * added backwards compatible of engine.io maxHttpBufferSize - * added test that server and client using same protocol - * added support for setting allowed origins - * added information about logging - * the set function in server can be used to set some attributes for BC - * fix error in callback call 'done' instead of 'next' in docs - * package: bump `socket.io-parser` - * package: bump `expect.js` - * added some new tests, including binary with acks - -1.0.0-pre / 2014-03-14 -====================== - - * implemented `engine.io` - * implemented `socket.io-adapter` - * implemented `socket.io-protocol` - * implemented `debug` and improved instrumentation - * added binary support - * added new `require('io')(srv)` signature - * simplified `socket.io-client` serving - -0.9.14 / 2013-03-29 -=================== - - * manager: fix memory leak with SSL [jpallen] - -0.9.13 / 2012-12-13 -=================== - - * package: fixed `base64id` requirement - -0.9.12 / 2012-12-13 -=================== - - * manager: fix for latest node which is returning a clone with `listeners` [viirya] - -0.9.11 / 2012-11-02 -=================== - - * package: move redis to optionalDependenices [3rd-Eden] - * bumped client - -0.9.10 / 2012-08-10 -=================== - - * Don't lowercase log messages - * Always set the HTTP response in case an error should be returned to the client - * Create or destroy the flash policy server on configuration change - * Honour configuration to disable flash policy server - * Add express 3.0 instructions on Readme.md - * Bump client - -0.9.9 / 2012-08-01 -================== - - * Fixed sync disconnect xhrs handling - * Put license text in its own file (#965) - * Add warning to .listen() to ease the migration to Express 3.x - * Restored compatibility with node 0.4.x - -0.9.8 / 2012-07-24 -================== - - * Bumped client. - -0.9.7 / 2012-07-24 -================== - - * Prevent crash when socket leaves a room twice. - * Corrects unsafe usage of for..in - * Fix for node 0.8 with `gzip compression` [vadimi] - * Update redis to support Node 0.8.x - * Made ID generation securely random - * Fix Redis Store race condition in manager onOpen unsubscribe callback - * Fix for EventEmitters always reusing the same Array instance for listeners - -0.9.6 / 2012-04-17 -================== - - * Fixed XSS in jsonp-polling. - -0.9.5 / 2012-04-05 -================== - - * Added test for polling and socket close. - * Ensure close upon request close. - * Fix disconnection reason being lost for polling transports. - * Ensure that polling transports work with Connection: close. - * Log disconnection reason. - -0.9.4 / 2012-04-01 -================== - - * Disconnecting from namespace improvement (#795) [DanielBaulig] - * Bumped client with polling reconnection loop (#438) - -0.9.3 / 2012-03-28 -================== - - * Fix "Syntax error" on FF Web Console with XHR Polling [mikito] - -0.9.2 / 2012-03-13 -================== - - * More sensible close `timeout default` (fixes disconnect issue) - -0.9.1-1 / 2012-03-02 -==================== - - * Bumped client with NPM dependency fix. - -0.9.1 / 2012-03-02 -================== - - * Changed heartbeat timeout and interval defaults (60 and 25 seconds) - * Make tests work both on 0.4 and 0.6 - * Updated client (improvements + bug fixes). - -0.9.0 / 2012-02-26 -================== - - * Make it possible to use a regexp to match the socket.io resource URL. - We need this because we have to prefix the socket.io URL with a variable ID. - * Supplemental fix to gavinuhma/authfix, it looks like the same Access-Control-Origin logic is needed in the http and xhr-polling transports - * Updated express dep for windows compatibility. - * Combine two substr calls into one in decodePayload to improve performance - * Minor documentation fix - * Minor. Conform to style of other files. - * Switching setting to 'match origin protocol' - * Revert "Fixes leaking Redis subscriptions for #663. The local flag was not getting passed through onClientDisconnect()." - * Revert "Handle leaked dispatch:[id] subscription." - * Merge pull request #667 from dshaw/patch/redis-disconnect - * Handle leaked dispatch:[id] subscription. - * Fixes leaking Redis subscriptions for #663. The local flag was not getting passed through onClientDisconnect(). - * Prevent memory leaking on uncompleted requests & add max post size limitation - * Fix for testcase - * Set Access-Control-Allow-Credentials true, regardless of cookie - * Remove assertvarnish from package as it breaks on 0.6 - * Correct irc channel - * Added proper return after reserved field error - * Fixes manager.js failure to close connection after transport error has happened - * Added implicit port 80 for origin checks. fixes #638 - * Fixed bug #432 in 0.8.7 - * Set Access-Control-Allow-Origin header to origin to enable withCredentials - * Adding configuration variable matchOriginProtocol - * Fixes location mismatch error in Safari. - * Use tty to detect if we should add colors or not by default. - * Updated the package location. - -0.8.7 / 2011-11-05 -================== - - * Fixed memory leaks in closed clients. - * Fixed memory leaks in namespaces. - * Fixed websocket handling for malformed requests from proxies. [einaros] - * Node 0.6 compatibility. [einaros] [3rd-Eden] - * Adapted tests and examples. - -0.8.6 / 2011-10-27 -================== - - * Added JSON decoding on jsonp-polling transport. - * Fixed README example. - * Major speed optimizations [3rd-Eden] [einaros] [visionmedia] - * Added decode/encode benchmarks [visionmedia] - * Added support for black-listing client sent events. - * Fixed logging options, closes #540 [3rd-Eden] - * Added vary header for gzip [3rd-Eden] - * Properly cleaned up async websocket / flashsocket tests, after patching node-websocket-client - * Patched to properly shut down when a finishClose call is made during connection establishment - * Added support for socket.io version on url and far-future Expires [3rd-Eden] [getify] - * Began IE10 compatibility [einaros] [tbranyen] - * Misc WebSocket fixes [einaros] - * Added UTF8 to respone headers for htmlfile [3rd-Eden] - -0.8.5 / 2011-10-07 -================== - - * Added websocket draft HyBi-16 support. [einaros] - * Fixed websocket continuation bugs. [einaros] - * Fixed flashsocket transport name. - * Fixed websocket tests. - * Ensured `parser#decodePayload` doesn't choke. - * Added http referrer verification to manager verifyOrigin. - * Added access control for cross domain xhr handshakes [3rd-Eden] - * Added support for automatic generation of socket.io files [3rd-Eden] - * Added websocket binary support [einaros] - * Added gzip support for socket.io.js [3rd-Eden] - * Expose socket.transport [3rd-Eden] - * Updated client. - -0.8.4 / 2011-09-06 -================== - - * Client build - -0.8.3 / 2011-09-03 -================== - - * Fixed `\n` parsing for non-JSON packets (fixes #479). - * Fixed parsing of certain unicode characters (fixes #451). - * Fixed transport message packet logging. - * Fixed emission of `error` event resulting in an uncaught exception if unhandled (fixes #476). - * Fixed; allow for falsy values as the configuration value of `log level` (fixes #491). - * Fixed repository URI in `package.json`. Fixes #504. - * Added text/plain content-type to handshake responses [einaros] - * Improved single byte writes [einaros] - * Updated socket.io-flashsocket default port from 843 to 10843 [3rd-Eden] - * Updated client. - -0.8.2 / 2011-08-29 -================== - - * Updated client. - -0.8.1 / 2011-08-29 -================== - - * Fixed utf8 bug in send framing in websocket [einaros] - * Fixed typo in docs [Znarkus] - * Fixed bug in send framing for over 64kB of data in websocket [einaros] - * Corrected ping handling in websocket transport [einaros] - -0.8.0 / 2011-08-28 -================== - - * Updated to work with two-level websocket versioning. [einaros] - * Added hybi07 support. [einaros] - * Added hybi10 support. [einaros] - * Added http referrer verification to manager.js verifyOrigin. [einaors] - -0.7.11 / 2011-08-27 -=================== - - * Updated socket.io-client. - -0.7.10 / 2011-08-27 -=================== - - * Updated socket.io-client. - -0.7.9 / 2011-08-12 -================== - - * Updated socket.io-client. - * Make sure we only do garbage collection when the server we receive is actually run. - -0.7.8 / 2011-08-08 -================== - - * Changed; make sure sio#listen passes options to both HTTP server and socket.io manager. - * Added docs for sio#listen. - * Added options parameter support for Manager constructor. - * Added memory leaks tests and test-leaks Makefile task. - * Removed auto npm-linking from make test. - * Make sure that you can disable heartbeats. [3rd-Eden] - * Fixed rooms memory leak [3rd-Eden] - * Send response once we got all POST data, not immediately [Pita] - * Fixed onLeave behavior with missing clientsk [3rd-Eden] - * Prevent duplicate references in rooms. - * Added alias for `to` to `in` and `in` to `to`. - * Fixed roomClients definition. - * Removed dependency on redis for installation without npm [3rd-Eden] - * Expose path and querystring in handshakeData [3rd-Eden] - -0.7.7 / 2011-07-12 -================== - - * Fixed double dispatch handling with emit to closed clients. - * Added test for emitting to closed clients to prevent regression. - * Fixed race condition in redis test. - * Changed Transport#end instrumentation. - * Leveraged $emit instead of emit internally. - * Made tests faster. - * Fixed double disconnect events. - * Fixed disconnect logic - * Simplified remote events handling in Socket. - * Increased testcase timeout. - * Fixed unknown room emitting (GH-291). [3rd-Eden] - * Fixed `address` in handshakeData. [3rd-Eden] - * Removed transports definition in chat example. - * Fixed room cleanup - * Fixed; make sure the client is cleaned up after booting. - * Make sure to mark the client as non-open if the connection is closed. - * Removed unneeded `buffer` declarations. - * Fixed; make sure to clear socket handlers and subscriptions upon transport close. - -0.7.6 / 2011-06-30 -================== - - * Fixed general dispatching when a client has closed. - -0.7.5 / 2011-06-30 -================== - - * Fixed dispatching to clients that are disconnected. - -0.7.4 / 2011-06-30 -================== - - * Fixed; only clear handlers if they were set. [level09] - -0.7.3 / 2011-06-30 -================== - - * Exposed handshake data to clients. - * Refactored dispatcher interface. - * Changed; Moved id generation method into the manager. - * Added sub-namespace authorization. [3rd-Eden] - * Changed; normalized SocketNamespace local eventing [dvv] - * Changed; Use packet.reason or default to 'packet' [3rd-Eden] - * Changed console.error to console.log. - * Fixed; bind both servers at the same time do that the test never times out. - * Added 304 support. - * Removed `Transport#name` for abstract interface. - * Changed; lazily require http and https module only when needed. [3rd-Eden] - -0.7.2 / 2011-06-22 -================== - - * Make sure to write a packet (of type `noop`) when closing a poll. - This solves a problem with cross-domain requests being flagged as aborted and - reconnection being triggered. - * Added `noop` message type. - -0.7.1 / 2011-06-21 -================== - - * Fixed cross-domain XHR. - * Added CORS test to xhr-polling suite. - -0.7.0 / 2010-06-21 -================== - - * http://socket.io/announcement.html + +1.4.8 / 2016-06-23 +================== + + * package: bump `engine.io` + +1.4.7 / 2016-06-23 +================== + + * package: bump `engine.io` + +1.4.6 / 2016-05-02 +================== + + * package: bump engine.io + +1.4.5 / 2016-01-26 +================== + + * fix closing the underlying `http.Server` + +1.4.4 / 2016-01-10 +================== + + * package: bump `engine.io` + +1.4.3 / 2016-01-08 +================== + + * bump `socket.io-client` + +1.4.2 / 2016-01-07 +================== + + * bump `engine.io` + +1.4.1 / 2016-01-07 +================== + + * version bump + +1.4.0 / 2015-11-28 +================== + + * socket.io: increase large binary data test timeout + * package: bump `engine.io` for release + * trigger callback even when joining an already joined room + * package: bump parser + * namespace: clear rooms flag after a clients call (fixes #1978) + * package: bump `socket.io-parser` + * fixed tests with large data + * fixed a typo in the example code + * package: bump mocha + * package: bump `has-binary` and `zuul-ngrok` + * package: bump `engine.io` and `socket.io-client` + * README: clarified documentation of Socket.in + * README: fixed up legacy repo links + * test: better timeout for stress test + * socket: don't set request property which has a getter + * removed proxy index file + * support flags on namespace + * improve Socket#packet and Client#packet + * socket: warn node_redis-style about missing `error` + * test: added failing test + * test: increase timeout for large binary data test + * package: bump `has-binary` to work with all objects (fixes #1955) + * fix origin verification default https port [evanlucas] + * support compression [nkzawa] + * changed type of `Client#sockets`, `Namespace#sockets` and `Socket#rooms` to maps (instead of arrays) + +1.3.7 / 2015-09-21 +================== + + * package: bump `socket.io-client` for node4 compatibility + * package: bump `engine.io` for node4 compatibility + +1.3.6 / 2015-07-14 +================== + + * package: bump `engine.io` to fix build on windows + +1.3.5 / 2015-03-03 +================== + + * package: bump `socket.io-parser` + +1.3.4 / 2015-02-14 +================== + + * package: bump `socket.io-client` + +1.3.3 / 2015-02-03 +================== + + * socket: warn node_redis-style about missing `error` + * package: bump parser to better handle bad binary packets + +1.3.2 / 2015-01-19 +================== + + * no change on this release + +1.3.1 / 2015-01-19 +================== + + * no change on this release + * package: bump `engine.io` + +1.3.0 / 2015-01-19 +================== + + * package: bump `engine.io` + * add test for reconnection after server restarts [rase-] + * update license with up-to-date year range [fay-jai] + * fix leaving unknown rooms [defunctzombie] + * allow null origins when allowed origins is a function [drewblaisdell] + * fix tests on node 0.11 + * package: fix `npm test` to run on windows + * package: bump `debug` v2.1.0 [coderaiser] + * added tests for volatile [rase-] + +1.2.1 / 2014-11-21 +================== + + * fix protocol violations and improve error handling (GH-1880) + * package: bump `engine.io` for websocket leak fix [3rd-Eden] + * style tweaks + +1.2.0 / 2014-10-27 +================== + + * package: bump `engine.io` + * downloads badge + * add test to check that empty rooms are autopruned + * added Server#origins(v:Function) description for dynamic CORS + * added test coverage for Server#origins(function) for dynamic CORS + * added optional Server#origins(function) for dynamic CORS + * fix usage example for Server#close + * package: fix main file for example application 'chat' + * package: bump `socket.io-parser` + * update README http ctor to createServer() + * bump adapter with a lot of fixes for room bookkeeping + +1.1.0 / 2014-09-04 +================== + + * examples: minor fix of escaping + * testing for equivalence of namespaces starting with / or without + * update index.js + * added relevant tests + * take "" and "/" as equivalent namespaces on server + * use svg instead of png to get better image quality in readme + * make CI build faster + * fix splice arguments and `socket.rooms` value update in `socket.leaveAll`. + * client cannot connect to non-existing namespaces + * bump engine.io version to get the cached IP address + * fixed handshake object address property and made the test case more strict. + * package: bump `engine.io` + * fixed the failing test where server crashes on disconnect involving connectBuffer + * npmignore: ignore `.gitignore` (fixes #1607) + * test: added failing case for `socket.disconnect` and nsps + * fix repo in package.json + * improve Close documentation + * use ephemeral ports + * fix: We should use the standard http protocol to handler the etag header. + * override default browser font-family for inputs + * update has-binary-data to 1.0.3 + * add close specs + * add ability to stop the http server even if not created inside socket.io + * make sure server gets close + * Add test case for checking that reconnect_failed is fired only once upon failure + * package: bump `socket.io-parser` for `component-emitter` dep fix + +1.0.6 / 2014-06-19 +================== + + * package: bump `socket.io-client` + +1.0.5 / 2014-06-16 +================== + + * package: bump `engine.io` to fix jsonp `\n` bug and CORS warnings + * index: fix typo [yanatan16] + * add `removeListener` to blacklisted events + * examples: clearer instructions to install chat example + * index: fix namespace `connectBuffer` issue + +1.0.4 / 2014-06-02 +================== + + * package: bump socket.io-client + +1.0.3 / 2014-05-31 +================== + + * package: bump `socket.io-client` + * package: bump `socket.io-parser` for binary ACK fix + * package: bump `engine.io` for binary UTF8 fix + * example: fix XSS in chat example + +1.0.2 / 2014-05-28 +================== + + * package: bump `socket.io-parser` for windows fix + +1.0.1 / 2014-05-28 +================== + + * bump due to bad npm tag + +1.0.0 / 2014-05-28 +================== + + * stable release + +1.0.0-pre5 / 2014-05-22 +======================= + + * package: bump `socket.io-client` for parser fixes + * package: bump `engine.io` + +1.0.0-pre4 / 2014-05-19 +======================= + + * package: bump client + +1.0.0-pre3 / 2014-05-17 +======================= + + * package: bump parser + * package: bump engine.io + +1.0.0-pre2 / 2014-04-27 +======================= + + * package: bump `engine.io` + * added backwards compatible of engine.io maxHttpBufferSize + * added test that server and client using same protocol + * added support for setting allowed origins + * added information about logging + * the set function in server can be used to set some attributes for BC + * fix error in callback call 'done' instead of 'next' in docs + * package: bump `socket.io-parser` + * package: bump `expect.js` + * added some new tests, including binary with acks + +1.0.0-pre / 2014-03-14 +====================== + + * implemented `engine.io` + * implemented `socket.io-adapter` + * implemented `socket.io-protocol` + * implemented `debug` and improved instrumentation + * added binary support + * added new `require('io')(srv)` signature + * simplified `socket.io-client` serving + +0.9.14 / 2013-03-29 +=================== + + * manager: fix memory leak with SSL [jpallen] + +0.9.13 / 2012-12-13 +=================== + + * package: fixed `base64id` requirement + +0.9.12 / 2012-12-13 +=================== + + * manager: fix for latest node which is returning a clone with `listeners` [viirya] + +0.9.11 / 2012-11-02 +=================== + + * package: move redis to optionalDependenices [3rd-Eden] + * bumped client + +0.9.10 / 2012-08-10 +=================== + + * Don't lowercase log messages + * Always set the HTTP response in case an error should be returned to the client + * Create or destroy the flash policy server on configuration change + * Honour configuration to disable flash policy server + * Add express 3.0 instructions on Readme.md + * Bump client + +0.9.9 / 2012-08-01 +================== + + * Fixed sync disconnect xhrs handling + * Put license text in its own file (#965) + * Add warning to .listen() to ease the migration to Express 3.x + * Restored compatibility with node 0.4.x + +0.9.8 / 2012-07-24 +================== + + * Bumped client. + +0.9.7 / 2012-07-24 +================== + + * Prevent crash when socket leaves a room twice. + * Corrects unsafe usage of for..in + * Fix for node 0.8 with `gzip compression` [vadimi] + * Update redis to support Node 0.8.x + * Made ID generation securely random + * Fix Redis Store race condition in manager onOpen unsubscribe callback + * Fix for EventEmitters always reusing the same Array instance for listeners + +0.9.6 / 2012-04-17 +================== + + * Fixed XSS in jsonp-polling. + +0.9.5 / 2012-04-05 +================== + + * Added test for polling and socket close. + * Ensure close upon request close. + * Fix disconnection reason being lost for polling transports. + * Ensure that polling transports work with Connection: close. + * Log disconnection reason. + +0.9.4 / 2012-04-01 +================== + + * Disconnecting from namespace improvement (#795) [DanielBaulig] + * Bumped client with polling reconnection loop (#438) + +0.9.3 / 2012-03-28 +================== + + * Fix "Syntax error" on FF Web Console with XHR Polling [mikito] + +0.9.2 / 2012-03-13 +================== + + * More sensible close `timeout default` (fixes disconnect issue) + +0.9.1-1 / 2012-03-02 +==================== + + * Bumped client with NPM dependency fix. + +0.9.1 / 2012-03-02 +================== + + * Changed heartbeat timeout and interval defaults (60 and 25 seconds) + * Make tests work both on 0.4 and 0.6 + * Updated client (improvements + bug fixes). + +0.9.0 / 2012-02-26 +================== + + * Make it possible to use a regexp to match the socket.io resource URL. + We need this because we have to prefix the socket.io URL with a variable ID. + * Supplemental fix to gavinuhma/authfix, it looks like the same Access-Control-Origin logic is needed in the http and xhr-polling transports + * Updated express dep for windows compatibility. + * Combine two substr calls into one in decodePayload to improve performance + * Minor documentation fix + * Minor. Conform to style of other files. + * Switching setting to 'match origin protocol' + * Revert "Fixes leaking Redis subscriptions for #663. The local flag was not getting passed through onClientDisconnect()." + * Revert "Handle leaked dispatch:[id] subscription." + * Merge pull request #667 from dshaw/patch/redis-disconnect + * Handle leaked dispatch:[id] subscription. + * Fixes leaking Redis subscriptions for #663. The local flag was not getting passed through onClientDisconnect(). + * Prevent memory leaking on uncompleted requests & add max post size limitation + * Fix for testcase + * Set Access-Control-Allow-Credentials true, regardless of cookie + * Remove assertvarnish from package as it breaks on 0.6 + * Correct irc channel + * Added proper return after reserved field error + * Fixes manager.js failure to close connection after transport error has happened + * Added implicit port 80 for origin checks. fixes #638 + * Fixed bug #432 in 0.8.7 + * Set Access-Control-Allow-Origin header to origin to enable withCredentials + * Adding configuration variable matchOriginProtocol + * Fixes location mismatch error in Safari. + * Use tty to detect if we should add colors or not by default. + * Updated the package location. + +0.8.7 / 2011-11-05 +================== + + * Fixed memory leaks in closed clients. + * Fixed memory leaks in namespaces. + * Fixed websocket handling for malformed requests from proxies. [einaros] + * Node 0.6 compatibility. [einaros] [3rd-Eden] + * Adapted tests and examples. + +0.8.6 / 2011-10-27 +================== + + * Added JSON decoding on jsonp-polling transport. + * Fixed README example. + * Major speed optimizations [3rd-Eden] [einaros] [visionmedia] + * Added decode/encode benchmarks [visionmedia] + * Added support for black-listing client sent events. + * Fixed logging options, closes #540 [3rd-Eden] + * Added vary header for gzip [3rd-Eden] + * Properly cleaned up async websocket / flashsocket tests, after patching node-websocket-client + * Patched to properly shut down when a finishClose call is made during connection establishment + * Added support for socket.io version on url and far-future Expires [3rd-Eden] [getify] + * Began IE10 compatibility [einaros] [tbranyen] + * Misc WebSocket fixes [einaros] + * Added UTF8 to respone headers for htmlfile [3rd-Eden] + +0.8.5 / 2011-10-07 +================== + + * Added websocket draft HyBi-16 support. [einaros] + * Fixed websocket continuation bugs. [einaros] + * Fixed flashsocket transport name. + * Fixed websocket tests. + * Ensured `parser#decodePayload` doesn't choke. + * Added http referrer verification to manager verifyOrigin. + * Added access control for cross domain xhr handshakes [3rd-Eden] + * Added support for automatic generation of socket.io files [3rd-Eden] + * Added websocket binary support [einaros] + * Added gzip support for socket.io.js [3rd-Eden] + * Expose socket.transport [3rd-Eden] + * Updated client. + +0.8.4 / 2011-09-06 +================== + + * Client build + +0.8.3 / 2011-09-03 +================== + + * Fixed `\n` parsing for non-JSON packets (fixes #479). + * Fixed parsing of certain unicode characters (fixes #451). + * Fixed transport message packet logging. + * Fixed emission of `error` event resulting in an uncaught exception if unhandled (fixes #476). + * Fixed; allow for falsy values as the configuration value of `log level` (fixes #491). + * Fixed repository URI in `package.json`. Fixes #504. + * Added text/plain content-type to handshake responses [einaros] + * Improved single byte writes [einaros] + * Updated socket.io-flashsocket default port from 843 to 10843 [3rd-Eden] + * Updated client. + +0.8.2 / 2011-08-29 +================== + + * Updated client. + +0.8.1 / 2011-08-29 +================== + + * Fixed utf8 bug in send framing in websocket [einaros] + * Fixed typo in docs [Znarkus] + * Fixed bug in send framing for over 64kB of data in websocket [einaros] + * Corrected ping handling in websocket transport [einaros] + +0.8.0 / 2011-08-28 +================== + + * Updated to work with two-level websocket versioning. [einaros] + * Added hybi07 support. [einaros] + * Added hybi10 support. [einaros] + * Added http referrer verification to manager.js verifyOrigin. [einaors] + +0.7.11 / 2011-08-27 +=================== + + * Updated socket.io-client. + +0.7.10 / 2011-08-27 +=================== + + * Updated socket.io-client. + +0.7.9 / 2011-08-12 +================== + + * Updated socket.io-client. + * Make sure we only do garbage collection when the server we receive is actually run. + +0.7.8 / 2011-08-08 +================== + + * Changed; make sure sio#listen passes options to both HTTP server and socket.io manager. + * Added docs for sio#listen. + * Added options parameter support for Manager constructor. + * Added memory leaks tests and test-leaks Makefile task. + * Removed auto npm-linking from make test. + * Make sure that you can disable heartbeats. [3rd-Eden] + * Fixed rooms memory leak [3rd-Eden] + * Send response once we got all POST data, not immediately [Pita] + * Fixed onLeave behavior with missing clientsk [3rd-Eden] + * Prevent duplicate references in rooms. + * Added alias for `to` to `in` and `in` to `to`. + * Fixed roomClients definition. + * Removed dependency on redis for installation without npm [3rd-Eden] + * Expose path and querystring in handshakeData [3rd-Eden] + +0.7.7 / 2011-07-12 +================== + + * Fixed double dispatch handling with emit to closed clients. + * Added test for emitting to closed clients to prevent regression. + * Fixed race condition in redis test. + * Changed Transport#end instrumentation. + * Leveraged $emit instead of emit internally. + * Made tests faster. + * Fixed double disconnect events. + * Fixed disconnect logic + * Simplified remote events handling in Socket. + * Increased testcase timeout. + * Fixed unknown room emitting (GH-291). [3rd-Eden] + * Fixed `address` in handshakeData. [3rd-Eden] + * Removed transports definition in chat example. + * Fixed room cleanup + * Fixed; make sure the client is cleaned up after booting. + * Make sure to mark the client as non-open if the connection is closed. + * Removed unneeded `buffer` declarations. + * Fixed; make sure to clear socket handlers and subscriptions upon transport close. + +0.7.6 / 2011-06-30 +================== + + * Fixed general dispatching when a client has closed. + +0.7.5 / 2011-06-30 +================== + + * Fixed dispatching to clients that are disconnected. + +0.7.4 / 2011-06-30 +================== + + * Fixed; only clear handlers if they were set. [level09] + +0.7.3 / 2011-06-30 +================== + + * Exposed handshake data to clients. + * Refactored dispatcher interface. + * Changed; Moved id generation method into the manager. + * Added sub-namespace authorization. [3rd-Eden] + * Changed; normalized SocketNamespace local eventing [dvv] + * Changed; Use packet.reason or default to 'packet' [3rd-Eden] + * Changed console.error to console.log. + * Fixed; bind both servers at the same time do that the test never times out. + * Added 304 support. + * Removed `Transport#name` for abstract interface. + * Changed; lazily require http and https module only when needed. [3rd-Eden] + +0.7.2 / 2011-06-22 +================== + + * Make sure to write a packet (of type `noop`) when closing a poll. + This solves a problem with cross-domain requests being flagged as aborted and + reconnection being triggered. + * Added `noop` message type. + +0.7.1 / 2011-06-21 +================== + + * Fixed cross-domain XHR. + * Added CORS test to xhr-polling suite. + +0.7.0 / 2010-06-21 +================== + + * http://socket.io/announcement.html diff --git a/ui/node_modules/socket.io/LICENSE b/ui/node_modules/socket.io/LICENSE index 2c016546..b248ba1b 100644 --- a/ui/node_modules/socket.io/LICENSE +++ b/ui/node_modules/socket.io/LICENSE @@ -1,22 +1,22 @@ -(The MIT License) - -Copyright (c) 2014-2015 Automattic - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2014-2015 Automattic + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/socket.io/Makefile b/ui/node_modules/socket.io/Makefile index 5b1ffad7..4acf1e52 100644 --- a/ui/node_modules/socket.io/Makefile +++ b/ui/node_modules/socket.io/Makefile @@ -1,15 +1,15 @@ - -REPORTER = dot - -test: - @./node_modules/.bin/mocha \ - --reporter $(REPORTER) \ - --slow 200ms \ - --bail - -test-cov: - @./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- \ - --reporter $(REPORTER) \ - test/ - -.PHONY: test + +REPORTER = dot + +test: + @./node_modules/.bin/mocha \ + --reporter $(REPORTER) \ + --slow 200ms \ + --bail + +test-cov: + @./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- \ + --reporter $(REPORTER) \ + test/ + +.PHONY: test diff --git a/ui/node_modules/socket.io/Readme.md b/ui/node_modules/socket.io/Readme.md index 4bf79ed5..74e2e898 100644 --- a/ui/node_modules/socket.io/Readme.md +++ b/ui/node_modules/socket.io/Readme.md @@ -1,427 +1,427 @@ - -# socket.io - -[![Build Status](https://secure.travis-ci.org/socketio/socket.io.svg)](https://travis-ci.org/socketio/socket.io) -[![Dependency Status](https://david-dm.org/socketio/socket.io.svg)](https://david-dm.org/socketio/socket.io) -[![devDependency Status](https://david-dm.org/socketio/socket.io/dev-status.svg)](https://david-dm.org/socketio/socket.io#info=devDependencies) -![NPM version](https://badge.fury.io/js/socket.io.svg) -![Downloads](https://img.shields.io/npm/dm/socket.io.svg?style=flat) -[![](http://slack.socket.io/badge.svg?)](http://slack.socket.io) - -## How to use - -The following example attaches socket.io to a plain Node.JS -HTTP server listening on port `3000`. - -```js -var server = require('http').createServer(); -var io = require('socket.io')(server); -io.on('connection', function(socket){ - socket.on('event', function(data){}); - socket.on('disconnect', function(){}); -}); -server.listen(3000); -``` - -### Standalone - -```js -var io = require('socket.io')(); -io.on('connection', function(socket){}); -io.listen(3000); -``` - -### In conjunction with Express - -Starting with **3.0**, express applications have become request handler -functions that you pass to `http` or `http` `Server` instances. You need -to pass the `Server` to `socket.io`, and not the express application -function. - -```js -var app = require('express')(); -var server = require('http').createServer(app); -var io = require('socket.io')(server); -io.on('connection', function(){ /* … */ }); -server.listen(3000); -``` - -### In conjunction with Koa - -Like Express.JS, Koa works by exposing an application as a request -handler function, but only by calling the `callback` method. - -```js -var app = require('koa')(); -var server = require('http').createServer(app.callback()); -var io = require('socket.io')(server); -io.on('connection', function(){ /* … */ }); -server.listen(3000); -``` - -## API - -### Server - - Exposed by `require('socket.io')`. - -### Server() - - Creates a new `Server`. Works with and without `new`: - - ```js - var io = require('socket.io')(); - // or - var Server = require('socket.io'); - var io = new Server(); - ``` - -### Server(opts:Object) - - Optionally, the first or second argument (see below) of the `Server` - constructor can be an options object. - - The following options are supported: - - - `serveClient` sets the value for Server#serveClient() - - `path` sets the value for Server#path() - - The same options passed to socket.io are always passed to - the `engine.io` `Server` that gets created. See engine.io - [options](https://github.com/socketio/engine.io#methods-1) - as reference. - -### Server(srv:http#Server, opts:Object) - - Creates a new `Server` and attaches it to the given `srv`. Optionally - `opts` can be passed. - -### Server(port:Number, opts:Object) - - Binds socket.io to a new `http.Server` that listens on `port`. - -### Server#serveClient(v:Boolean):Server - - If `v` is `true` the attached server (see `Server#attach`) will serve - the client files. Defaults to `true`. - - This method has no effect after `attach` is called. - - ```js - // pass a server and the `serveClient` option - var io = require('socket.io')(http, { serveClient: false }); - - // or pass no server and then you can call the method - var io = require('socket.io')(); - io.serveClient(false); - io.attach(http); - ``` - - If no arguments are supplied this method returns the current value. - -### Server#path(v:String):Server - - Sets the path `v` under which `engine.io` and the static files will be - served. Defaults to `/socket.io`. - - If no arguments are supplied this method returns the current value. - -### Server#adapter(v:Adapter):Server - - Sets the adapter `v`. Defaults to an instance of the `Adapter` that - ships with socket.io which is memory based. See - [socket.io-adapter](https://github.com/socketio/socket.io-adapter). - - If no arguments are supplied this method returns the current value. - -### Server#origins(v:String):Server - - Sets the allowed origins `v`. Defaults to any origins being allowed. - - If no arguments are supplied this method returns the current value. - -### Server#origins(v:Function):Server - - Sets the allowed origins as dynamic function. Function takes two arguments `origin:String` and `callback(error, success)`, where `success` is a boolean value indicating whether origin is allowed or not. - - __Potential drawbacks__: - * in some situations, when it is not possible to determine `origin` it may have value of `*` - * As this function will be executed for every request, it is advised to make this function work as fast as possible - * If `socket.io` is used together with `Express`, the CORS headers will be affected only for `socket.io` requests. For Express can use [cors](https://github.com/expressjs/cors) - - -### Server#sockets:Namespace - - The default (`/`) namespace. - -### Server#attach(srv:http#Server, opts:Object):Server - - Attaches the `Server` to an engine.io instance on `srv` with the - supplied `opts` (optionally). - -### Server#attach(port:Number, opts:Object):Server - - Attaches the `Server` to an engine.io instance that is bound to `port` - with the given `opts` (optionally). - -### Server#listen - - Synonym of `Server#attach`. - -### Server#bind(srv:engine#Server):Server - - Advanced use only. Binds the server to a specific engine.io `Server` - (or compatible API) instance. - -### Server#onconnection(socket:engine#Socket):Server - - Advanced use only. Creates a new `socket.io` client from the incoming - engine.io (or compatible API) `socket`. - -### Server#of(nsp:String):Namespace - - Initializes and retrieves the given `Namespace` by its pathname - identifier `nsp`. - - If the namespace was already initialized it returns it right away. - -### Server#emit - - Emits an event to all connected clients. The following two are - equivalent: - - ```js - var io = require('socket.io')(); - io.sockets.emit('an event sent to all connected clients'); - io.emit('an event sent to all connected clients'); - ``` - - For other available methods, see `Namespace` below. - -### Server#close - - Closes socket server - - ```js - var Server = require('socket.io'); - var PORT = 3030; - var server = require('http').Server(); - - var io = Server(PORT); - - io.close(); // Close current server - - server.listen(PORT); // PORT is free to use - - io = Server(server); - ``` - -### Server#use - - See `Namespace#use` below. - -### Namespace - - Represents a pool of sockets connected under a given scope identified - by a pathname (eg: `/chat`). - - By default the client always connects to `/`. - -#### Events - - - `connection` / `connect`. Fired upon a connection. - - Parameters: - - `Socket` the incoming socket. - -### Namespace#name:String - - The namespace identifier property. - -### Namespace#connected:Object - - Hash of `Socket` objects that are connected to this namespace indexed - by `id`. - -### Namespace#clients(fn:Function) - - Gets a list of client IDs connected to this namespace (across all nodes if applicable). - - An example to get all clients in a namespace: - - ```js - var io = require('socket.io')(); - io.of('/chat').clients(function(error, clients){ - if (error) throw error; - console.log(clients); // => [PZDoMHjiu8PYfRiKAAAF, Anw2LatarvGVVXEIAAAD] - }); - ``` - - An example to get all clients in namespace's room: - - ```js - var io = require('socket.io')(); - io.of('/chat').in('general').clients(function(error, clients){ - if (error) throw error; - console.log(clients); // => [Anw2LatarvGVVXEIAAAD] - }); - ``` - - As with broadcasting, the default is all clients from the default namespace ('/'): - - ```js - var io = require('socket.io')(); - io.clients(function(error, clients){ - if (error) throw error; - console.log(clients); // => [6em3d4TJP8Et9EMNAAAA, G5p55dHhGgUnLUctAAAB] - }); - ``` - -### Namespace#use(fn:Function):Namespace - - Registers a middleware, which is a function that gets executed for - every incoming `Socket` and receives as parameter the socket and a - function to optionally defer execution to the next registered - middleware. - - ```js - var io = require('socket.io')(); - io.use(function(socket, next){ - if (socket.request.headers.cookie) return next(); - next(new Error('Authentication error')); - }); - ``` - - Errors passed to middleware callbacks are sent as special `error` - packets to clients. - -### Socket - - A `Socket` is the fundamental class for interacting with browser - clients. A `Socket` belongs to a certain `Namespace` (by default `/`) - and uses an underlying `Client` to communicate. - -### Socket#rooms:Object - - A hash of strings identifying the rooms this socket is in, indexed by - room name. - -### Socket#client:Client - - A reference to the underlying `Client` object. - -### Socket#conn:Socket - - A reference to the underlying `Client` transport connection (engine.io - `Socket` object). - -### Socket#request:Request - - A getter proxy that returns the reference to the `request` that - originated the underlying engine.io `Client`. Useful for accessing - request headers such as `Cookie` or `User-Agent`. - -### Socket#id:String - - A unique identifier for the socket session, that comes from the - underlying `Client`. - -### Socket#emit(name:String[, …]):Socket - - Emits an event to the socket identified by the string `name`. Any - other parameters can be included. - - All datastructures are supported, including `Buffer`. JavaScript - functions can't be serialized/deserialized. - - ```js - var io = require('socket.io')(); - io.on('connection', function(socket){ - socket.emit('an event', { some: 'data' }); - }); - ``` - -### Socket#join(name:String[, fn:Function]):Socket - - Adds the socket to the `room`, and fires optionally a callback `fn` - with `err` signature (if any). - - The socket is automatically a member of a room identified with its - session id (see `Socket#id`). - - The mechanics of joining rooms are handled by the `Adapter` - that has been configured (see `Server#adapter` above), defaulting to - [socket.io-adapter](https://github.com/socketio/socket.io-adapter). - -### Socket#leave(name:String[, fn:Function]):Socket - - Removes the socket from `room`, and fires optionally a callback `fn` - with `err` signature (if any). - - **Rooms are left automatically upon disconnection**. - - The mechanics of leaving rooms are handled by the `Adapter` - that has been configured (see `Server#adapter` above), defaulting to - [socket.io-adapter](https://github.com/socketio/socket.io-adapter). - -### Socket#to(room:String):Socket - - Sets a modifier for a subsequent event emission that the event will - only be _broadcasted_ to sockets that have joined the given `room`. - - To emit to multiple rooms, you can call `to` several times. - - ```js - var io = require('socket.io')(); - io.on('connection', function(socket){ - socket.to('others').emit('an event', { some: 'data' }); - }); - ``` - -### Socket#in(room:String):Socket - - Same as `Socket#to` - -### Socket#compress(v:Boolean):Socket - - Sets a modifier for a subsequent event emission that the event data will - only be _compressed_ if the value is `true`. Defaults to `true` when you don't call the method. - - ```js - var io = require('socket.io')(); - io.on('connection', function(socket){ - socket.compress(false).emit('an event', { some: 'data' }); - }); - ``` - -### Client - - The `Client` class represents an incoming transport (engine.io) - connection. A `Client` can be associated with many multiplexed `Socket` - that belong to different `Namespace`s. - -### Client#conn - - A reference to the underlying `engine.io` `Socket` connection. - -### Client#request - - A getter proxy that returns the reference to the `request` that - originated the engine.io connection. Useful for accessing - request headers such as `Cookie` or `User-Agent`. - -## Debug / logging - -Socket.IO is powered by [debug](https://github.com/visionmedia/debug). -In order to see all the debug output, run your app with the environment variable -`DEBUG` including the desired scope. - -To see the output from all of Socket.IO's debugging scopes you can use: - -``` -DEBUG=socket.io* node myapp -``` - -## License - -MIT + +# socket.io + +[![Build Status](https://secure.travis-ci.org/socketio/socket.io.svg)](https://travis-ci.org/socketio/socket.io) +[![Dependency Status](https://david-dm.org/socketio/socket.io.svg)](https://david-dm.org/socketio/socket.io) +[![devDependency Status](https://david-dm.org/socketio/socket.io/dev-status.svg)](https://david-dm.org/socketio/socket.io#info=devDependencies) +![NPM version](https://badge.fury.io/js/socket.io.svg) +![Downloads](https://img.shields.io/npm/dm/socket.io.svg?style=flat) +[![](http://slack.socket.io/badge.svg?)](http://slack.socket.io) + +## How to use + +The following example attaches socket.io to a plain Node.JS +HTTP server listening on port `3000`. + +```js +var server = require('http').createServer(); +var io = require('socket.io')(server); +io.on('connection', function(socket){ + socket.on('event', function(data){}); + socket.on('disconnect', function(){}); +}); +server.listen(3000); +``` + +### Standalone + +```js +var io = require('socket.io')(); +io.on('connection', function(socket){}); +io.listen(3000); +``` + +### In conjunction with Express + +Starting with **3.0**, express applications have become request handler +functions that you pass to `http` or `http` `Server` instances. You need +to pass the `Server` to `socket.io`, and not the express application +function. + +```js +var app = require('express')(); +var server = require('http').createServer(app); +var io = require('socket.io')(server); +io.on('connection', function(){ /* … */ }); +server.listen(3000); +``` + +### In conjunction with Koa + +Like Express.JS, Koa works by exposing an application as a request +handler function, but only by calling the `callback` method. + +```js +var app = require('koa')(); +var server = require('http').createServer(app.callback()); +var io = require('socket.io')(server); +io.on('connection', function(){ /* … */ }); +server.listen(3000); +``` + +## API + +### Server + + Exposed by `require('socket.io')`. + +### Server() + + Creates a new `Server`. Works with and without `new`: + + ```js + var io = require('socket.io')(); + // or + var Server = require('socket.io'); + var io = new Server(); + ``` + +### Server(opts:Object) + + Optionally, the first or second argument (see below) of the `Server` + constructor can be an options object. + + The following options are supported: + + - `serveClient` sets the value for Server#serveClient() + - `path` sets the value for Server#path() + + The same options passed to socket.io are always passed to + the `engine.io` `Server` that gets created. See engine.io + [options](https://github.com/socketio/engine.io#methods-1) + as reference. + +### Server(srv:http#Server, opts:Object) + + Creates a new `Server` and attaches it to the given `srv`. Optionally + `opts` can be passed. + +### Server(port:Number, opts:Object) + + Binds socket.io to a new `http.Server` that listens on `port`. + +### Server#serveClient(v:Boolean):Server + + If `v` is `true` the attached server (see `Server#attach`) will serve + the client files. Defaults to `true`. + + This method has no effect after `attach` is called. + + ```js + // pass a server and the `serveClient` option + var io = require('socket.io')(http, { serveClient: false }); + + // or pass no server and then you can call the method + var io = require('socket.io')(); + io.serveClient(false); + io.attach(http); + ``` + + If no arguments are supplied this method returns the current value. + +### Server#path(v:String):Server + + Sets the path `v` under which `engine.io` and the static files will be + served. Defaults to `/socket.io`. + + If no arguments are supplied this method returns the current value. + +### Server#adapter(v:Adapter):Server + + Sets the adapter `v`. Defaults to an instance of the `Adapter` that + ships with socket.io which is memory based. See + [socket.io-adapter](https://github.com/socketio/socket.io-adapter). + + If no arguments are supplied this method returns the current value. + +### Server#origins(v:String):Server + + Sets the allowed origins `v`. Defaults to any origins being allowed. + + If no arguments are supplied this method returns the current value. + +### Server#origins(v:Function):Server + + Sets the allowed origins as dynamic function. Function takes two arguments `origin:String` and `callback(error, success)`, where `success` is a boolean value indicating whether origin is allowed or not. + + __Potential drawbacks__: + * in some situations, when it is not possible to determine `origin` it may have value of `*` + * As this function will be executed for every request, it is advised to make this function work as fast as possible + * If `socket.io` is used together with `Express`, the CORS headers will be affected only for `socket.io` requests. For Express can use [cors](https://github.com/expressjs/cors) + + +### Server#sockets:Namespace + + The default (`/`) namespace. + +### Server#attach(srv:http#Server, opts:Object):Server + + Attaches the `Server` to an engine.io instance on `srv` with the + supplied `opts` (optionally). + +### Server#attach(port:Number, opts:Object):Server + + Attaches the `Server` to an engine.io instance that is bound to `port` + with the given `opts` (optionally). + +### Server#listen + + Synonym of `Server#attach`. + +### Server#bind(srv:engine#Server):Server + + Advanced use only. Binds the server to a specific engine.io `Server` + (or compatible API) instance. + +### Server#onconnection(socket:engine#Socket):Server + + Advanced use only. Creates a new `socket.io` client from the incoming + engine.io (or compatible API) `socket`. + +### Server#of(nsp:String):Namespace + + Initializes and retrieves the given `Namespace` by its pathname + identifier `nsp`. + + If the namespace was already initialized it returns it right away. + +### Server#emit + + Emits an event to all connected clients. The following two are + equivalent: + + ```js + var io = require('socket.io')(); + io.sockets.emit('an event sent to all connected clients'); + io.emit('an event sent to all connected clients'); + ``` + + For other available methods, see `Namespace` below. + +### Server#close + + Closes socket server + + ```js + var Server = require('socket.io'); + var PORT = 3030; + var server = require('http').Server(); + + var io = Server(PORT); + + io.close(); // Close current server + + server.listen(PORT); // PORT is free to use + + io = Server(server); + ``` + +### Server#use + + See `Namespace#use` below. + +### Namespace + + Represents a pool of sockets connected under a given scope identified + by a pathname (eg: `/chat`). + + By default the client always connects to `/`. + +#### Events + + - `connection` / `connect`. Fired upon a connection. + + Parameters: + - `Socket` the incoming socket. + +### Namespace#name:String + + The namespace identifier property. + +### Namespace#connected:Object + + Hash of `Socket` objects that are connected to this namespace indexed + by `id`. + +### Namespace#clients(fn:Function) + + Gets a list of client IDs connected to this namespace (across all nodes if applicable). + + An example to get all clients in a namespace: + + ```js + var io = require('socket.io')(); + io.of('/chat').clients(function(error, clients){ + if (error) throw error; + console.log(clients); // => [PZDoMHjiu8PYfRiKAAAF, Anw2LatarvGVVXEIAAAD] + }); + ``` + + An example to get all clients in namespace's room: + + ```js + var io = require('socket.io')(); + io.of('/chat').in('general').clients(function(error, clients){ + if (error) throw error; + console.log(clients); // => [Anw2LatarvGVVXEIAAAD] + }); + ``` + + As with broadcasting, the default is all clients from the default namespace ('/'): + + ```js + var io = require('socket.io')(); + io.clients(function(error, clients){ + if (error) throw error; + console.log(clients); // => [6em3d4TJP8Et9EMNAAAA, G5p55dHhGgUnLUctAAAB] + }); + ``` + +### Namespace#use(fn:Function):Namespace + + Registers a middleware, which is a function that gets executed for + every incoming `Socket` and receives as parameter the socket and a + function to optionally defer execution to the next registered + middleware. + + ```js + var io = require('socket.io')(); + io.use(function(socket, next){ + if (socket.request.headers.cookie) return next(); + next(new Error('Authentication error')); + }); + ``` + + Errors passed to middleware callbacks are sent as special `error` + packets to clients. + +### Socket + + A `Socket` is the fundamental class for interacting with browser + clients. A `Socket` belongs to a certain `Namespace` (by default `/`) + and uses an underlying `Client` to communicate. + +### Socket#rooms:Object + + A hash of strings identifying the rooms this socket is in, indexed by + room name. + +### Socket#client:Client + + A reference to the underlying `Client` object. + +### Socket#conn:Socket + + A reference to the underlying `Client` transport connection (engine.io + `Socket` object). + +### Socket#request:Request + + A getter proxy that returns the reference to the `request` that + originated the underlying engine.io `Client`. Useful for accessing + request headers such as `Cookie` or `User-Agent`. + +### Socket#id:String + + A unique identifier for the socket session, that comes from the + underlying `Client`. + +### Socket#emit(name:String[, …]):Socket + + Emits an event to the socket identified by the string `name`. Any + other parameters can be included. + + All datastructures are supported, including `Buffer`. JavaScript + functions can't be serialized/deserialized. + + ```js + var io = require('socket.io')(); + io.on('connection', function(socket){ + socket.emit('an event', { some: 'data' }); + }); + ``` + +### Socket#join(name:String[, fn:Function]):Socket + + Adds the socket to the `room`, and fires optionally a callback `fn` + with `err` signature (if any). + + The socket is automatically a member of a room identified with its + session id (see `Socket#id`). + + The mechanics of joining rooms are handled by the `Adapter` + that has been configured (see `Server#adapter` above), defaulting to + [socket.io-adapter](https://github.com/socketio/socket.io-adapter). + +### Socket#leave(name:String[, fn:Function]):Socket + + Removes the socket from `room`, and fires optionally a callback `fn` + with `err` signature (if any). + + **Rooms are left automatically upon disconnection**. + + The mechanics of leaving rooms are handled by the `Adapter` + that has been configured (see `Server#adapter` above), defaulting to + [socket.io-adapter](https://github.com/socketio/socket.io-adapter). + +### Socket#to(room:String):Socket + + Sets a modifier for a subsequent event emission that the event will + only be _broadcasted_ to sockets that have joined the given `room`. + + To emit to multiple rooms, you can call `to` several times. + + ```js + var io = require('socket.io')(); + io.on('connection', function(socket){ + socket.to('others').emit('an event', { some: 'data' }); + }); + ``` + +### Socket#in(room:String):Socket + + Same as `Socket#to` + +### Socket#compress(v:Boolean):Socket + + Sets a modifier for a subsequent event emission that the event data will + only be _compressed_ if the value is `true`. Defaults to `true` when you don't call the method. + + ```js + var io = require('socket.io')(); + io.on('connection', function(socket){ + socket.compress(false).emit('an event', { some: 'data' }); + }); + ``` + +### Client + + The `Client` class represents an incoming transport (engine.io) + connection. A `Client` can be associated with many multiplexed `Socket` + that belong to different `Namespace`s. + +### Client#conn + + A reference to the underlying `engine.io` `Socket` connection. + +### Client#request + + A getter proxy that returns the reference to the `request` that + originated the engine.io connection. Useful for accessing + request headers such as `Cookie` or `User-Agent`. + +## Debug / logging + +Socket.IO is powered by [debug](https://github.com/visionmedia/debug). +In order to see all the debug output, run your app with the environment variable +`DEBUG` including the desired scope. + +To see the output from all of Socket.IO's debugging scopes you can use: + +``` +DEBUG=socket.io* node myapp +``` + +## License + +MIT diff --git a/ui/node_modules/socket.io/lib/client.js b/ui/node_modules/socket.io/lib/client.js index 3e68f3a8..407d6c3a 100644 --- a/ui/node_modules/socket.io/lib/client.js +++ b/ui/node_modules/socket.io/lib/client.js @@ -1,251 +1,251 @@ - -/** - * Module dependencies. - */ - -var parser = require('socket.io-parser'); -var debug = require('debug')('socket.io:client'); - -/** - * Module exports. - */ - -module.exports = Client; - -/** - * Client constructor. - * - * @param {Server} server instance - * @param {Socket} conn - * @api private - */ - -function Client(server, conn){ - this.server = server; - this.conn = conn; - this.encoder = new parser.Encoder(); - this.decoder = new parser.Decoder(); - this.id = conn.id; - this.request = conn.request; - this.setup(); - this.sockets = {}; - this.nsps = {}; - this.connectBuffer = []; -} - -/** - * Sets up event listeners. - * - * @api private - */ - -Client.prototype.setup = function(){ - this.onclose = this.onclose.bind(this); - this.ondata = this.ondata.bind(this); - this.onerror = this.onerror.bind(this); - this.ondecoded = this.ondecoded.bind(this); - - this.decoder.on('decoded', this.ondecoded); - this.conn.on('data', this.ondata); - this.conn.on('error', this.onerror); - this.conn.on('close', this.onclose); -}; - -/** - * Connects a client to a namespace. - * - * @param {String} name namespace - * @api private - */ - -Client.prototype.connect = function(name){ - debug('connecting to namespace %s', name); - var nsp = this.server.nsps[name]; - if (!nsp) { - this.packet({ type: parser.ERROR, nsp: name, data : 'Invalid namespace'}); - return; - } - - if ('/' != name && !this.nsps['/']) { - this.connectBuffer.push(name); - return; - } - - var self = this; - var socket = nsp.add(this, function(){ - self.sockets[socket.id] = socket; - self.nsps[nsp.name] = socket; - - if ('/' == nsp.name && self.connectBuffer.length > 0) { - self.connectBuffer.forEach(self.connect, self); - self.connectBuffer = []; - } - }); -}; - -/** - * Disconnects from all namespaces and closes transport. - * - * @api private - */ - -Client.prototype.disconnect = function(){ - for (var id in this.sockets) { - if (this.sockets.hasOwnProperty(id)) { - this.sockets[id].disconnect(); - } - } - this.sockets = {}; - this.close(); -}; - -/** - * Removes a socket. Called by each `Socket`. - * - * @api private - */ - -Client.prototype.remove = function(socket){ - if (this.sockets.hasOwnProperty(socket.id)) { - var nsp = this.sockets[socket.id].nsp.name; - delete this.sockets[socket.id]; - delete this.nsps[nsp]; - } else { - debug('ignoring remove for %s', socket.id); - } -}; - -/** - * Closes the underlying connection. - * - * @api private - */ - -Client.prototype.close = function(){ - if ('open' == this.conn.readyState) { - debug('forcing transport close'); - this.conn.close(); - this.onclose('forced server close'); - } -}; - -/** - * Writes a packet to the transport. - * - * @param {Object} packet object - * @param {Object} opts - * @api private - */ - -Client.prototype.packet = function(packet, opts){ - opts = opts || {}; - var self = this; - - // this writes to the actual connection - function writeToEngine(encodedPackets) { - if (opts.volatile && !self.conn.transport.writable) return; - for (var i = 0; i < encodedPackets.length; i++) { - self.conn.write(encodedPackets[i], { compress: opts.compress }); - } - } - - if ('open' == this.conn.readyState) { - debug('writing packet %j', packet); - if (!opts.preEncoded) { // not broadcasting, need to encode - this.encoder.encode(packet, function (encodedPackets) { // encode, then write results to engine - writeToEngine(encodedPackets); - }); - } else { // a broadcast pre-encodes a packet - writeToEngine(packet); - } - } else { - debug('ignoring packet write %j', packet); - } -}; - -/** - * Called with incoming transport data. - * - * @api private - */ - -Client.prototype.ondata = function(data){ - // try/catch is needed for protocol violations (GH-1880) - try { - this.decoder.add(data); - } catch(e) { - this.onerror(e); - } -}; - -/** - * Called when parser fully decodes a packet. - * - * @api private - */ - -Client.prototype.ondecoded = function(packet) { - if (parser.CONNECT == packet.type) { - this.connect(packet.nsp); - } else { - var socket = this.nsps[packet.nsp]; - if (socket) { - socket.onpacket(packet); - } else { - debug('no socket for namespace %s', packet.nsp); - } - } -}; - -/** - * Handles an error. - * - * @param {Object} err object - * @api private - */ - -Client.prototype.onerror = function(err){ - for (var id in this.sockets) { - if (this.sockets.hasOwnProperty(id)) { - this.sockets[id].onerror(err); - } - } - this.onclose('client error'); -}; - -/** - * Called upon transport close. - * - * @param {String} reason - * @api private - */ - -Client.prototype.onclose = function(reason){ - debug('client close with reason %s', reason); - - // ignore a potential subsequent `close` event - this.destroy(); - - // `nsps` and `sockets` are cleaned up seamlessly - for (var id in this.sockets) { - if (this.sockets.hasOwnProperty(id)) { - this.sockets[id].onclose(reason); - } - } - this.sockets = {}; - - this.decoder.destroy(); // clean up decoder -}; - -/** - * Cleans up event listeners. - * - * @api private - */ - -Client.prototype.destroy = function(){ - this.conn.removeListener('data', this.ondata); - this.conn.removeListener('error', this.onerror); - this.conn.removeListener('close', this.onclose); - this.decoder.removeListener('decoded', this.ondecoded); -}; + +/** + * Module dependencies. + */ + +var parser = require('socket.io-parser'); +var debug = require('debug')('socket.io:client'); + +/** + * Module exports. + */ + +module.exports = Client; + +/** + * Client constructor. + * + * @param {Server} server instance + * @param {Socket} conn + * @api private + */ + +function Client(server, conn){ + this.server = server; + this.conn = conn; + this.encoder = new parser.Encoder(); + this.decoder = new parser.Decoder(); + this.id = conn.id; + this.request = conn.request; + this.setup(); + this.sockets = {}; + this.nsps = {}; + this.connectBuffer = []; +} + +/** + * Sets up event listeners. + * + * @api private + */ + +Client.prototype.setup = function(){ + this.onclose = this.onclose.bind(this); + this.ondata = this.ondata.bind(this); + this.onerror = this.onerror.bind(this); + this.ondecoded = this.ondecoded.bind(this); + + this.decoder.on('decoded', this.ondecoded); + this.conn.on('data', this.ondata); + this.conn.on('error', this.onerror); + this.conn.on('close', this.onclose); +}; + +/** + * Connects a client to a namespace. + * + * @param {String} name namespace + * @api private + */ + +Client.prototype.connect = function(name){ + debug('connecting to namespace %s', name); + var nsp = this.server.nsps[name]; + if (!nsp) { + this.packet({ type: parser.ERROR, nsp: name, data : 'Invalid namespace'}); + return; + } + + if ('/' != name && !this.nsps['/']) { + this.connectBuffer.push(name); + return; + } + + var self = this; + var socket = nsp.add(this, function(){ + self.sockets[socket.id] = socket; + self.nsps[nsp.name] = socket; + + if ('/' == nsp.name && self.connectBuffer.length > 0) { + self.connectBuffer.forEach(self.connect, self); + self.connectBuffer = []; + } + }); +}; + +/** + * Disconnects from all namespaces and closes transport. + * + * @api private + */ + +Client.prototype.disconnect = function(){ + for (var id in this.sockets) { + if (this.sockets.hasOwnProperty(id)) { + this.sockets[id].disconnect(); + } + } + this.sockets = {}; + this.close(); +}; + +/** + * Removes a socket. Called by each `Socket`. + * + * @api private + */ + +Client.prototype.remove = function(socket){ + if (this.sockets.hasOwnProperty(socket.id)) { + var nsp = this.sockets[socket.id].nsp.name; + delete this.sockets[socket.id]; + delete this.nsps[nsp]; + } else { + debug('ignoring remove for %s', socket.id); + } +}; + +/** + * Closes the underlying connection. + * + * @api private + */ + +Client.prototype.close = function(){ + if ('open' == this.conn.readyState) { + debug('forcing transport close'); + this.conn.close(); + this.onclose('forced server close'); + } +}; + +/** + * Writes a packet to the transport. + * + * @param {Object} packet object + * @param {Object} opts + * @api private + */ + +Client.prototype.packet = function(packet, opts){ + opts = opts || {}; + var self = this; + + // this writes to the actual connection + function writeToEngine(encodedPackets) { + if (opts.volatile && !self.conn.transport.writable) return; + for (var i = 0; i < encodedPackets.length; i++) { + self.conn.write(encodedPackets[i], { compress: opts.compress }); + } + } + + if ('open' == this.conn.readyState) { + debug('writing packet %j', packet); + if (!opts.preEncoded) { // not broadcasting, need to encode + this.encoder.encode(packet, function (encodedPackets) { // encode, then write results to engine + writeToEngine(encodedPackets); + }); + } else { // a broadcast pre-encodes a packet + writeToEngine(packet); + } + } else { + debug('ignoring packet write %j', packet); + } +}; + +/** + * Called with incoming transport data. + * + * @api private + */ + +Client.prototype.ondata = function(data){ + // try/catch is needed for protocol violations (GH-1880) + try { + this.decoder.add(data); + } catch(e) { + this.onerror(e); + } +}; + +/** + * Called when parser fully decodes a packet. + * + * @api private + */ + +Client.prototype.ondecoded = function(packet) { + if (parser.CONNECT == packet.type) { + this.connect(packet.nsp); + } else { + var socket = this.nsps[packet.nsp]; + if (socket) { + socket.onpacket(packet); + } else { + debug('no socket for namespace %s', packet.nsp); + } + } +}; + +/** + * Handles an error. + * + * @param {Object} err object + * @api private + */ + +Client.prototype.onerror = function(err){ + for (var id in this.sockets) { + if (this.sockets.hasOwnProperty(id)) { + this.sockets[id].onerror(err); + } + } + this.onclose('client error'); +}; + +/** + * Called upon transport close. + * + * @param {String} reason + * @api private + */ + +Client.prototype.onclose = function(reason){ + debug('client close with reason %s', reason); + + // ignore a potential subsequent `close` event + this.destroy(); + + // `nsps` and `sockets` are cleaned up seamlessly + for (var id in this.sockets) { + if (this.sockets.hasOwnProperty(id)) { + this.sockets[id].onclose(reason); + } + } + this.sockets = {}; + + this.decoder.destroy(); // clean up decoder +}; + +/** + * Cleans up event listeners. + * + * @api private + */ + +Client.prototype.destroy = function(){ + this.conn.removeListener('data', this.ondata); + this.conn.removeListener('error', this.onerror); + this.conn.removeListener('close', this.onclose); + this.decoder.removeListener('decoded', this.ondecoded); +}; diff --git a/ui/node_modules/socket.io/lib/index.js b/ui/node_modules/socket.io/lib/index.js index d8203b3e..b35d1b1a 100644 --- a/ui/node_modules/socket.io/lib/index.js +++ b/ui/node_modules/socket.io/lib/index.js @@ -1,385 +1,385 @@ - -/** - * Module dependencies. - */ - -var http = require('http'); -var read = require('fs').readFileSync; -var engine = require('engine.io'); -var client = require('socket.io-client'); -var clientVersion = require('socket.io-client/package').version; -var Client = require('./client'); -var Namespace = require('./namespace'); -var Adapter = require('socket.io-adapter'); -var debug = require('debug')('socket.io:server'); -var url = require('url'); - -/** - * Module exports. - */ - -module.exports = Server; - -/** - * Socket.IO client source. - */ - -var clientSource = read(require.resolve('socket.io-client/socket.io.js'), 'utf-8'); - -/** - * Server constructor. - * - * @param {http.Server|Number|Object} srv http server, port or options - * @param {Object} opts - * @api public - */ - -function Server(srv, opts){ - if (!(this instanceof Server)) return new Server(srv, opts); - if ('object' == typeof srv && !srv.listen) { - opts = srv; - srv = null; - } - opts = opts || {}; - this.nsps = {}; - this.path(opts.path || '/socket.io'); - this.serveClient(false !== opts.serveClient); - this.adapter(opts.adapter || Adapter); - this.origins(opts.origins || '*:*'); - this.sockets = this.of('/'); - if (srv) this.attach(srv, opts); -} - -/** - * Server request verification function, that checks for allowed origins - * - * @param {http.IncomingMessage} req request - * @param {Function} fn callback to be called with the result: `fn(err, success)` - */ - -Server.prototype.checkRequest = function(req, fn) { - var origin = req.headers.origin || req.headers.referer; - - // file:// URLs produce a null Origin which can't be authorized via echo-back - if ('null' == origin || null == origin) origin = '*'; - - if (!!origin && typeof(this._origins) == 'function') return this._origins(origin, fn); - if (this._origins.indexOf('*:*') !== -1) return fn(null, true); - if (origin) { - try { - var parts = url.parse(origin); - var defaultPort = 'https:' == parts.protocol ? 443 : 80; - parts.port = parts.port != null - ? parts.port - : defaultPort; - var ok = - ~this._origins.indexOf(parts.hostname + ':' + parts.port) || - ~this._origins.indexOf(parts.hostname + ':*') || - ~this._origins.indexOf('*:' + parts.port); - return fn(null, !!ok); - } catch (ex) { - } - } - fn(null, false); -}; - -/** - * Sets/gets whether client code is being served. - * - * @param {Boolean} v whether to serve client code - * @return {Server|Boolean} self when setting or value when getting - * @api public - */ - -Server.prototype.serveClient = function(v){ - if (!arguments.length) return this._serveClient; - this._serveClient = v; - return this; -}; - -/** - * Old settings for backwards compatibility - */ - -var oldSettings = { - "transports": "transports", - "heartbeat timeout": "pingTimeout", - "heartbeat interval": "pingInterval", - "destroy buffer size": "maxHttpBufferSize" -}; - -/** - * Backwards compatiblity. - * - * @api public - */ - -Server.prototype.set = function(key, val){ - if ('authorization' == key && val) { - this.use(function(socket, next) { - val(socket.request, function(err, authorized) { - if (err) return next(new Error(err)); - if (!authorized) return next(new Error('Not authorized')); - next(); - }); - }); - } else if ('origins' == key && val) { - this.origins(val); - } else if ('resource' == key) { - this.path(val); - } else if (oldSettings[key] && this.eio[oldSettings[key]]) { - this.eio[oldSettings[key]] = val; - } else { - console.error('Option %s is not valid. Please refer to the README.', key); - } - - return this; -}; - -/** - * Sets the client serving path. - * - * @param {String} v pathname - * @return {Server|String} self when setting or value when getting - * @api public - */ - -Server.prototype.path = function(v){ - if (!arguments.length) return this._path; - this._path = v.replace(/\/$/, ''); - return this; -}; - -/** - * Sets the adapter for rooms. - * - * @param {Adapter} v pathname - * @return {Server|Adapter} self when setting or value when getting - * @api public - */ - -Server.prototype.adapter = function(v){ - if (!arguments.length) return this._adapter; - this._adapter = v; - for (var i in this.nsps) { - if (this.nsps.hasOwnProperty(i)) { - this.nsps[i].initAdapter(); - } - } - return this; -}; - -/** - * Sets the allowed origins for requests. - * - * @param {String} v origins - * @return {Server|Adapter} self when setting or value when getting - * @api public - */ - -Server.prototype.origins = function(v){ - if (!arguments.length) return this._origins; - - this._origins = v; - return this; -}; - -/** - * Attaches socket.io to a server or port. - * - * @param {http.Server|Number} server or port - * @param {Object} options passed to engine.io - * @return {Server} self - * @api public - */ - -Server.prototype.listen = -Server.prototype.attach = function(srv, opts){ - if ('function' == typeof srv) { - var msg = 'You are trying to attach socket.io to an express ' + - 'request handler function. Please pass a http.Server instance.'; - throw new Error(msg); - } - - // handle a port as a string - if (Number(srv) == srv) { - srv = Number(srv); - } - - if ('number' == typeof srv) { - debug('creating http server and binding to %d', srv); - var port = srv; - srv = http.Server(function(req, res){ - res.writeHead(404); - res.end(); - }); - srv.listen(port); - - } - - // set engine.io path to `/socket.io` - opts = opts || {}; - opts.path = opts.path || this.path(); - // set origins verification - opts.allowRequest = opts.allowRequest || this.checkRequest.bind(this); - - // initialize engine - debug('creating engine.io instance with opts %j', opts); - this.eio = engine.attach(srv, opts); - - // attach static file serving - if (this._serveClient) this.attachServe(srv); - - // Export http server - this.httpServer = srv; - - // bind to engine events - this.bind(this.eio); - - return this; -}; - -/** - * Attaches the static file serving. - * - * @param {Function|http.Server} srv http server - * @api private - */ - -Server.prototype.attachServe = function(srv){ - debug('attaching client serving req handler'); - var url = this._path + '/socket.io.js'; - var evs = srv.listeners('request').slice(0); - var self = this; - srv.removeAllListeners('request'); - srv.on('request', function(req, res) { - if (0 === req.url.indexOf(url)) { - self.serve(req, res); - } else { - for (var i = 0; i < evs.length; i++) { - evs[i].call(srv, req, res); - } - } - }); -}; - -/** - * Handles a request serving `/socket.io.js` - * - * @param {http.Request} req - * @param {http.Response} res - * @api private - */ - -Server.prototype.serve = function(req, res){ - var etag = req.headers['if-none-match']; - if (etag) { - if (clientVersion == etag) { - debug('serve client 304'); - res.writeHead(304); - res.end(); - return; - } - } - - debug('serve client source'); - res.setHeader('Content-Type', 'application/javascript'); - res.setHeader('ETag', clientVersion); - res.writeHead(200); - res.end(clientSource); -}; - -/** - * Binds socket.io to an engine.io instance. - * - * @param {engine.Server} engine engine.io (or compatible) server - * @return {Server} self - * @api public - */ - -Server.prototype.bind = function(engine){ - this.engine = engine; - this.engine.on('connection', this.onconnection.bind(this)); - return this; -}; - -/** - * Called with each incoming transport connection. - * - * @param {engine.Socket} conn - * @return {Server} self - * @api public - */ - -Server.prototype.onconnection = function(conn){ - debug('incoming connection with id %s', conn.id); - var client = new Client(this, conn); - client.connect('/'); - return this; -}; - -/** - * Looks up a namespace. - * - * @param {String} name nsp name - * @param {Function} fn optional, nsp `connection` ev handler - * @api public - */ - -Server.prototype.of = function(name, fn){ - if (String(name)[0] !== '/') name = '/' + name; - - var nsp = this.nsps[name]; - if (!nsp) { - debug('initializing namespace %s', name); - nsp = new Namespace(this, name); - this.nsps[name] = nsp; - } - if (fn) nsp.on('connect', fn); - return nsp; -}; - -/** - * Closes server connection - * - * @api public - */ - -Server.prototype.close = function(){ - for (var id in this.nsps['/'].sockets) { - if (this.nsps['/'].sockets.hasOwnProperty(id)) { - this.nsps['/'].sockets[id].onclose(); - } - } - - this.engine.close(); - - if(this.httpServer){ - this.httpServer.close(); - } -}; - -/** - * Expose main namespace (/). - */ - -['on', 'to', 'in', 'use', 'emit', 'send', 'write', 'clients', 'compress'].forEach(function(fn){ - Server.prototype[fn] = function(){ - var nsp = this.sockets[fn]; - return nsp.apply(this.sockets, arguments); - }; -}); - -Namespace.flags.forEach(function(flag){ - Server.prototype.__defineGetter__(flag, function(){ - this.sockets.flags = this.sockets.flags || {}; - this.sockets.flags[flag] = true; - return this; - }); -}); - -/** - * BC with `io.listen` - */ - -Server.listen = Server; + +/** + * Module dependencies. + */ + +var http = require('http'); +var read = require('fs').readFileSync; +var engine = require('engine.io'); +var client = require('socket.io-client'); +var clientVersion = require('socket.io-client/package').version; +var Client = require('./client'); +var Namespace = require('./namespace'); +var Adapter = require('socket.io-adapter'); +var debug = require('debug')('socket.io:server'); +var url = require('url'); + +/** + * Module exports. + */ + +module.exports = Server; + +/** + * Socket.IO client source. + */ + +var clientSource = read(require.resolve('socket.io-client/socket.io.js'), 'utf-8'); + +/** + * Server constructor. + * + * @param {http.Server|Number|Object} srv http server, port or options + * @param {Object} opts + * @api public + */ + +function Server(srv, opts){ + if (!(this instanceof Server)) return new Server(srv, opts); + if ('object' == typeof srv && !srv.listen) { + opts = srv; + srv = null; + } + opts = opts || {}; + this.nsps = {}; + this.path(opts.path || '/socket.io'); + this.serveClient(false !== opts.serveClient); + this.adapter(opts.adapter || Adapter); + this.origins(opts.origins || '*:*'); + this.sockets = this.of('/'); + if (srv) this.attach(srv, opts); +} + +/** + * Server request verification function, that checks for allowed origins + * + * @param {http.IncomingMessage} req request + * @param {Function} fn callback to be called with the result: `fn(err, success)` + */ + +Server.prototype.checkRequest = function(req, fn) { + var origin = req.headers.origin || req.headers.referer; + + // file:// URLs produce a null Origin which can't be authorized via echo-back + if ('null' == origin || null == origin) origin = '*'; + + if (!!origin && typeof(this._origins) == 'function') return this._origins(origin, fn); + if (this._origins.indexOf('*:*') !== -1) return fn(null, true); + if (origin) { + try { + var parts = url.parse(origin); + var defaultPort = 'https:' == parts.protocol ? 443 : 80; + parts.port = parts.port != null + ? parts.port + : defaultPort; + var ok = + ~this._origins.indexOf(parts.hostname + ':' + parts.port) || + ~this._origins.indexOf(parts.hostname + ':*') || + ~this._origins.indexOf('*:' + parts.port); + return fn(null, !!ok); + } catch (ex) { + } + } + fn(null, false); +}; + +/** + * Sets/gets whether client code is being served. + * + * @param {Boolean} v whether to serve client code + * @return {Server|Boolean} self when setting or value when getting + * @api public + */ + +Server.prototype.serveClient = function(v){ + if (!arguments.length) return this._serveClient; + this._serveClient = v; + return this; +}; + +/** + * Old settings for backwards compatibility + */ + +var oldSettings = { + "transports": "transports", + "heartbeat timeout": "pingTimeout", + "heartbeat interval": "pingInterval", + "destroy buffer size": "maxHttpBufferSize" +}; + +/** + * Backwards compatiblity. + * + * @api public + */ + +Server.prototype.set = function(key, val){ + if ('authorization' == key && val) { + this.use(function(socket, next) { + val(socket.request, function(err, authorized) { + if (err) return next(new Error(err)); + if (!authorized) return next(new Error('Not authorized')); + next(); + }); + }); + } else if ('origins' == key && val) { + this.origins(val); + } else if ('resource' == key) { + this.path(val); + } else if (oldSettings[key] && this.eio[oldSettings[key]]) { + this.eio[oldSettings[key]] = val; + } else { + console.error('Option %s is not valid. Please refer to the README.', key); + } + + return this; +}; + +/** + * Sets the client serving path. + * + * @param {String} v pathname + * @return {Server|String} self when setting or value when getting + * @api public + */ + +Server.prototype.path = function(v){ + if (!arguments.length) return this._path; + this._path = v.replace(/\/$/, ''); + return this; +}; + +/** + * Sets the adapter for rooms. + * + * @param {Adapter} v pathname + * @return {Server|Adapter} self when setting or value when getting + * @api public + */ + +Server.prototype.adapter = function(v){ + if (!arguments.length) return this._adapter; + this._adapter = v; + for (var i in this.nsps) { + if (this.nsps.hasOwnProperty(i)) { + this.nsps[i].initAdapter(); + } + } + return this; +}; + +/** + * Sets the allowed origins for requests. + * + * @param {String} v origins + * @return {Server|Adapter} self when setting or value when getting + * @api public + */ + +Server.prototype.origins = function(v){ + if (!arguments.length) return this._origins; + + this._origins = v; + return this; +}; + +/** + * Attaches socket.io to a server or port. + * + * @param {http.Server|Number} server or port + * @param {Object} options passed to engine.io + * @return {Server} self + * @api public + */ + +Server.prototype.listen = +Server.prototype.attach = function(srv, opts){ + if ('function' == typeof srv) { + var msg = 'You are trying to attach socket.io to an express ' + + 'request handler function. Please pass a http.Server instance.'; + throw new Error(msg); + } + + // handle a port as a string + if (Number(srv) == srv) { + srv = Number(srv); + } + + if ('number' == typeof srv) { + debug('creating http server and binding to %d', srv); + var port = srv; + srv = http.Server(function(req, res){ + res.writeHead(404); + res.end(); + }); + srv.listen(port); + + } + + // set engine.io path to `/socket.io` + opts = opts || {}; + opts.path = opts.path || this.path(); + // set origins verification + opts.allowRequest = opts.allowRequest || this.checkRequest.bind(this); + + // initialize engine + debug('creating engine.io instance with opts %j', opts); + this.eio = engine.attach(srv, opts); + + // attach static file serving + if (this._serveClient) this.attachServe(srv); + + // Export http server + this.httpServer = srv; + + // bind to engine events + this.bind(this.eio); + + return this; +}; + +/** + * Attaches the static file serving. + * + * @param {Function|http.Server} srv http server + * @api private + */ + +Server.prototype.attachServe = function(srv){ + debug('attaching client serving req handler'); + var url = this._path + '/socket.io.js'; + var evs = srv.listeners('request').slice(0); + var self = this; + srv.removeAllListeners('request'); + srv.on('request', function(req, res) { + if (0 === req.url.indexOf(url)) { + self.serve(req, res); + } else { + for (var i = 0; i < evs.length; i++) { + evs[i].call(srv, req, res); + } + } + }); +}; + +/** + * Handles a request serving `/socket.io.js` + * + * @param {http.Request} req + * @param {http.Response} res + * @api private + */ + +Server.prototype.serve = function(req, res){ + var etag = req.headers['if-none-match']; + if (etag) { + if (clientVersion == etag) { + debug('serve client 304'); + res.writeHead(304); + res.end(); + return; + } + } + + debug('serve client source'); + res.setHeader('Content-Type', 'application/javascript'); + res.setHeader('ETag', clientVersion); + res.writeHead(200); + res.end(clientSource); +}; + +/** + * Binds socket.io to an engine.io instance. + * + * @param {engine.Server} engine engine.io (or compatible) server + * @return {Server} self + * @api public + */ + +Server.prototype.bind = function(engine){ + this.engine = engine; + this.engine.on('connection', this.onconnection.bind(this)); + return this; +}; + +/** + * Called with each incoming transport connection. + * + * @param {engine.Socket} conn + * @return {Server} self + * @api public + */ + +Server.prototype.onconnection = function(conn){ + debug('incoming connection with id %s', conn.id); + var client = new Client(this, conn); + client.connect('/'); + return this; +}; + +/** + * Looks up a namespace. + * + * @param {String} name nsp name + * @param {Function} fn optional, nsp `connection` ev handler + * @api public + */ + +Server.prototype.of = function(name, fn){ + if (String(name)[0] !== '/') name = '/' + name; + + var nsp = this.nsps[name]; + if (!nsp) { + debug('initializing namespace %s', name); + nsp = new Namespace(this, name); + this.nsps[name] = nsp; + } + if (fn) nsp.on('connect', fn); + return nsp; +}; + +/** + * Closes server connection + * + * @api public + */ + +Server.prototype.close = function(){ + for (var id in this.nsps['/'].sockets) { + if (this.nsps['/'].sockets.hasOwnProperty(id)) { + this.nsps['/'].sockets[id].onclose(); + } + } + + this.engine.close(); + + if(this.httpServer){ + this.httpServer.close(); + } +}; + +/** + * Expose main namespace (/). + */ + +['on', 'to', 'in', 'use', 'emit', 'send', 'write', 'clients', 'compress'].forEach(function(fn){ + Server.prototype[fn] = function(){ + var nsp = this.sockets[fn]; + return nsp.apply(this.sockets, arguments); + }; +}); + +Namespace.flags.forEach(function(flag){ + Server.prototype.__defineGetter__(flag, function(){ + this.sockets.flags = this.sockets.flags || {}; + this.sockets.flags[flag] = true; + return this; + }); +}); + +/** + * BC with `io.listen` + */ + +Server.listen = Server; diff --git a/ui/node_modules/socket.io/lib/namespace.js b/ui/node_modules/socket.io/lib/namespace.js index 6e40a137..a0be4f75 100644 --- a/ui/node_modules/socket.io/lib/namespace.js +++ b/ui/node_modules/socket.io/lib/namespace.js @@ -1,272 +1,272 @@ - -/** - * Module dependencies. - */ - -var Socket = require('./socket'); -var Emitter = require('events').EventEmitter; -var parser = require('socket.io-parser'); -var debug = require('debug')('socket.io:namespace'); -var hasBin = require('has-binary'); - -/** - * Module exports. - */ - -module.exports = exports = Namespace; - -/** - * Blacklisted events. - */ - -exports.events = [ - 'connect', // for symmetry with client - 'connection', - 'newListener' -]; - -/** - * Flags. - */ - -exports.flags = [ - 'json', - 'volatile' -]; - -/** - * `EventEmitter#emit` reference. - */ - -var emit = Emitter.prototype.emit; - -/** - * Namespace constructor. - * - * @param {Server} server instance - * @param {Socket} name - * @api private - */ - -function Namespace(server, name){ - this.name = name; - this.server = server; - this.sockets = {}; - this.connected = {}; - this.fns = []; - this.ids = 0; - this.initAdapter(); -} - -/** - * Inherits from `EventEmitter`. - */ - -Namespace.prototype.__proto__ = Emitter.prototype; - -/** - * Apply flags from `Socket`. - */ - -exports.flags.forEach(function(flag){ - Namespace.prototype.__defineGetter__(flag, function(){ - this.flags = this.flags || {}; - this.flags[flag] = true; - return this; - }); -}); - -/** - * Initializes the `Adapter` for this nsp. - * Run upon changing adapter by `Server#adapter` - * in addition to the constructor. - * - * @api private - */ - -Namespace.prototype.initAdapter = function(){ - this.adapter = new (this.server.adapter())(this); -}; - -/** - * Sets up namespace middleware. - * - * @return {Namespace} self - * @api public - */ - -Namespace.prototype.use = function(fn){ - this.fns.push(fn); - return this; -}; - -/** - * Executes the middleware for an incoming client. - * - * @param {Socket} socket that will get added - * @param {Function} fn last fn call in the middleware - * @api private - */ - -Namespace.prototype.run = function(socket, fn){ - var fns = this.fns.slice(0); - if (!fns.length) return fn(null); - - function run(i){ - fns[i](socket, function(err){ - // upon error, short-circuit - if (err) return fn(err); - - // if no middleware left, summon callback - if (!fns[i + 1]) return fn(null); - - // go on to next - run(i + 1); - }); - } - - run(0); -}; - -/** - * Targets a room when emitting. - * - * @param {String} name - * @return {Namespace} self - * @api public - */ - -Namespace.prototype.to = -Namespace.prototype['in'] = function(name){ - this.rooms = this.rooms || []; - if (!~this.rooms.indexOf(name)) this.rooms.push(name); - return this; -}; - -/** - * Adds a new client. - * - * @return {Socket} - * @api private - */ - -Namespace.prototype.add = function(client, fn){ - debug('adding socket to nsp %s', this.name); - var socket = new Socket(this, client); - var self = this; - this.run(socket, function(err){ - process.nextTick(function(){ - if ('open' == client.conn.readyState) { - if (err) return socket.error(err.data || err.message); - - // track socket - self.sockets[socket.id] = socket; - - // it's paramount that the internal `onconnect` logic - // fires before user-set events to prevent state order - // violations (such as a disconnection before the connection - // logic is complete) - socket.onconnect(); - if (fn) fn(); - - // fire user-set events - self.emit('connect', socket); - self.emit('connection', socket); - } else { - debug('next called after client was closed - ignoring socket'); - } - }); - }); - return socket; -}; - -/** - * Removes a client. Called by each `Socket`. - * - * @api private - */ - -Namespace.prototype.remove = function(socket){ - if (this.sockets.hasOwnProperty(socket.id)) { - delete this.sockets[socket.id]; - } else { - debug('ignoring remove for %s', socket.id); - } -}; - -/** - * Emits to all clients. - * - * @return {Namespace} self - * @api public - */ - -Namespace.prototype.emit = function(ev){ - if (~exports.events.indexOf(ev)) { - emit.apply(this, arguments); - } else { - // set up packet object - var args = Array.prototype.slice.call(arguments); - var parserType = parser.EVENT; // default - if (hasBin(args)) { parserType = parser.BINARY_EVENT; } // binary - - var packet = { type: parserType, data: args }; - - if ('function' == typeof args[args.length - 1]) { - throw new Error('Callbacks are not supported when broadcasting'); - } - - this.adapter.broadcast(packet, { - rooms: this.rooms, - flags: this.flags - }); - - delete this.rooms; - delete this.flags; - } - return this; -}; - -/** - * Sends a `message` event to all clients. - * - * @return {Namespace} self - * @api public - */ - -Namespace.prototype.send = -Namespace.prototype.write = function(){ - var args = Array.prototype.slice.call(arguments); - args.unshift('message'); - this.emit.apply(this, args); - return this; -}; - -/** - * Gets a list of clients. - * - * @return {Namespace} self - * @api public - */ - -Namespace.prototype.clients = function(fn){ - this.adapter.clients(this.rooms, fn); - // delete rooms flag for scenario: - // .in('room').clients() (GH-1978) - delete this.rooms; - return this; -}; - -/** - * Sets the compress flag. - * - * @param {Boolean} compress if `true`, compresses the sending data - * @return {Socket} self - * @api public - */ - -Namespace.prototype.compress = function(compress){ - this.flags = this.flags || {}; - this.flags.compress = compress; - return this; -}; + +/** + * Module dependencies. + */ + +var Socket = require('./socket'); +var Emitter = require('events').EventEmitter; +var parser = require('socket.io-parser'); +var debug = require('debug')('socket.io:namespace'); +var hasBin = require('has-binary'); + +/** + * Module exports. + */ + +module.exports = exports = Namespace; + +/** + * Blacklisted events. + */ + +exports.events = [ + 'connect', // for symmetry with client + 'connection', + 'newListener' +]; + +/** + * Flags. + */ + +exports.flags = [ + 'json', + 'volatile' +]; + +/** + * `EventEmitter#emit` reference. + */ + +var emit = Emitter.prototype.emit; + +/** + * Namespace constructor. + * + * @param {Server} server instance + * @param {Socket} name + * @api private + */ + +function Namespace(server, name){ + this.name = name; + this.server = server; + this.sockets = {}; + this.connected = {}; + this.fns = []; + this.ids = 0; + this.initAdapter(); +} + +/** + * Inherits from `EventEmitter`. + */ + +Namespace.prototype.__proto__ = Emitter.prototype; + +/** + * Apply flags from `Socket`. + */ + +exports.flags.forEach(function(flag){ + Namespace.prototype.__defineGetter__(flag, function(){ + this.flags = this.flags || {}; + this.flags[flag] = true; + return this; + }); +}); + +/** + * Initializes the `Adapter` for this nsp. + * Run upon changing adapter by `Server#adapter` + * in addition to the constructor. + * + * @api private + */ + +Namespace.prototype.initAdapter = function(){ + this.adapter = new (this.server.adapter())(this); +}; + +/** + * Sets up namespace middleware. + * + * @return {Namespace} self + * @api public + */ + +Namespace.prototype.use = function(fn){ + this.fns.push(fn); + return this; +}; + +/** + * Executes the middleware for an incoming client. + * + * @param {Socket} socket that will get added + * @param {Function} fn last fn call in the middleware + * @api private + */ + +Namespace.prototype.run = function(socket, fn){ + var fns = this.fns.slice(0); + if (!fns.length) return fn(null); + + function run(i){ + fns[i](socket, function(err){ + // upon error, short-circuit + if (err) return fn(err); + + // if no middleware left, summon callback + if (!fns[i + 1]) return fn(null); + + // go on to next + run(i + 1); + }); + } + + run(0); +}; + +/** + * Targets a room when emitting. + * + * @param {String} name + * @return {Namespace} self + * @api public + */ + +Namespace.prototype.to = +Namespace.prototype['in'] = function(name){ + this.rooms = this.rooms || []; + if (!~this.rooms.indexOf(name)) this.rooms.push(name); + return this; +}; + +/** + * Adds a new client. + * + * @return {Socket} + * @api private + */ + +Namespace.prototype.add = function(client, fn){ + debug('adding socket to nsp %s', this.name); + var socket = new Socket(this, client); + var self = this; + this.run(socket, function(err){ + process.nextTick(function(){ + if ('open' == client.conn.readyState) { + if (err) return socket.error(err.data || err.message); + + // track socket + self.sockets[socket.id] = socket; + + // it's paramount that the internal `onconnect` logic + // fires before user-set events to prevent state order + // violations (such as a disconnection before the connection + // logic is complete) + socket.onconnect(); + if (fn) fn(); + + // fire user-set events + self.emit('connect', socket); + self.emit('connection', socket); + } else { + debug('next called after client was closed - ignoring socket'); + } + }); + }); + return socket; +}; + +/** + * Removes a client. Called by each `Socket`. + * + * @api private + */ + +Namespace.prototype.remove = function(socket){ + if (this.sockets.hasOwnProperty(socket.id)) { + delete this.sockets[socket.id]; + } else { + debug('ignoring remove for %s', socket.id); + } +}; + +/** + * Emits to all clients. + * + * @return {Namespace} self + * @api public + */ + +Namespace.prototype.emit = function(ev){ + if (~exports.events.indexOf(ev)) { + emit.apply(this, arguments); + } else { + // set up packet object + var args = Array.prototype.slice.call(arguments); + var parserType = parser.EVENT; // default + if (hasBin(args)) { parserType = parser.BINARY_EVENT; } // binary + + var packet = { type: parserType, data: args }; + + if ('function' == typeof args[args.length - 1]) { + throw new Error('Callbacks are not supported when broadcasting'); + } + + this.adapter.broadcast(packet, { + rooms: this.rooms, + flags: this.flags + }); + + delete this.rooms; + delete this.flags; + } + return this; +}; + +/** + * Sends a `message` event to all clients. + * + * @return {Namespace} self + * @api public + */ + +Namespace.prototype.send = +Namespace.prototype.write = function(){ + var args = Array.prototype.slice.call(arguments); + args.unshift('message'); + this.emit.apply(this, args); + return this; +}; + +/** + * Gets a list of clients. + * + * @return {Namespace} self + * @api public + */ + +Namespace.prototype.clients = function(fn){ + this.adapter.clients(this.rooms, fn); + // delete rooms flag for scenario: + // .in('room').clients() (GH-1978) + delete this.rooms; + return this; +}; + +/** + * Sets the compress flag. + * + * @param {Boolean} compress if `true`, compresses the sending data + * @return {Socket} self + * @api public + */ + +Namespace.prototype.compress = function(compress){ + this.flags = this.flags || {}; + this.flags.compress = compress; + return this; +}; diff --git a/ui/node_modules/socket.io/lib/socket.js b/ui/node_modules/socket.io/lib/socket.js index 6e28076e..de5ebb71 100644 --- a/ui/node_modules/socket.io/lib/socket.js +++ b/ui/node_modules/socket.io/lib/socket.js @@ -1,470 +1,470 @@ - -/** - * Module dependencies. - */ - -var Emitter = require('events').EventEmitter; -var parser = require('socket.io-parser'); -var url = require('url'); -var debug = require('debug')('socket.io:socket'); -var hasBin = require('has-binary'); - -/** - * Module exports. - */ - -module.exports = exports = Socket; - -/** - * Blacklisted events. - * - * @api public - */ - -exports.events = [ - 'error', - 'connect', - 'disconnect', - 'newListener', - 'removeListener' -]; - -/** - * Flags. - * - * @api private - */ - -var flags = [ - 'json', - 'volatile', - 'broadcast' -]; - -/** - * `EventEmitter#emit` reference. - */ - -var emit = Emitter.prototype.emit; - -/** - * Interface to a `Client` for a given `Namespace`. - * - * @param {Namespace} nsp - * @param {Client} client - * @api public - */ - -function Socket(nsp, client){ - this.nsp = nsp; - this.server = nsp.server; - this.adapter = this.nsp.adapter; - this.id = nsp.name + '#' + client.id; - this.client = client; - this.conn = client.conn; - this.rooms = {}; - this.acks = {}; - this.connected = true; - this.disconnected = false; - this.handshake = this.buildHandshake(); -} - -/** - * Inherits from `EventEmitter`. - */ - -Socket.prototype.__proto__ = Emitter.prototype; - -/** - * Apply flags from `Socket`. - */ - -flags.forEach(function(flag){ - Socket.prototype.__defineGetter__(flag, function(){ - this.flags = this.flags || {}; - this.flags[flag] = true; - return this; - }); -}); - -/** - * `request` engine.io shortcut. - * - * @api public - */ - -Socket.prototype.__defineGetter__('request', function(){ - return this.conn.request; -}); - -/** - * Builds the `handshake` BC object - * - * @api private - */ - -Socket.prototype.buildHandshake = function(){ - return { - headers: this.request.headers, - time: (new Date) + '', - address: this.conn.remoteAddress, - xdomain: !!this.request.headers.origin, - secure: !!this.request.connection.encrypted, - issued: +(new Date), - url: this.request.url, - query: url.parse(this.request.url, true).query || {} - }; -}; - -/** - * Emits to this client. - * - * @return {Socket} self - * @api public - */ - -Socket.prototype.emit = function(ev){ - if (~exports.events.indexOf(ev)) { - emit.apply(this, arguments); - } else { - var args = Array.prototype.slice.call(arguments); - var packet = {}; - packet.type = hasBin(args) ? parser.BINARY_EVENT : parser.EVENT; - packet.data = args; - var flags = this.flags || {}; - - // access last argument to see if it's an ACK callback - if ('function' == typeof args[args.length - 1]) { - if (this._rooms || flags.broadcast) { - throw new Error('Callbacks are not supported when broadcasting'); - } - - debug('emitting packet with ack id %d', this.nsp.ids); - this.acks[this.nsp.ids] = args.pop(); - packet.id = this.nsp.ids++; - } - - if (this._rooms || flags.broadcast) { - this.adapter.broadcast(packet, { - except: [this.id], - rooms: this._rooms, - flags: flags - }); - } else { - // dispatch packet - this.packet(packet, { - volatile: flags.volatile, - compress: flags.compress - }); - } - - // reset flags - delete this._rooms; - delete this.flags; - } - return this; -}; - -/** - * Targets a room when broadcasting. - * - * @param {String} name - * @return {Socket} self - * @api public - */ - -Socket.prototype.to = -Socket.prototype.in = function(name){ - this._rooms = this._rooms || []; - if (!~this._rooms.indexOf(name)) this._rooms.push(name); - return this; -}; - -/** - * Sends a `message` event. - * - * @return {Socket} self - * @api public - */ - -Socket.prototype.send = -Socket.prototype.write = function(){ - var args = Array.prototype.slice.call(arguments); - args.unshift('message'); - this.emit.apply(this, args); - return this; -}; - -/** - * Writes a packet. - * - * @param {Object} packet object - * @param {Object} opts options - * @api private - */ - -Socket.prototype.packet = function(packet, opts){ - packet.nsp = this.nsp.name; - opts = opts || {}; - opts.compress = false !== opts.compress; - this.client.packet(packet, opts); -}; - -/** - * Joins a room. - * - * @param {String} room - * @param {Function} fn optional, callback - * @return {Socket} self - * @api private - */ - -Socket.prototype.join = function(room, fn){ - debug('joining room %s', room); - var self = this; - if (this.rooms.hasOwnProperty(room)) { - fn && fn(null); - return this; - } - this.adapter.add(this.id, room, function(err){ - if (err) return fn && fn(err); - debug('joined room %s', room); - self.rooms[room] = room; - fn && fn(null); - }); - return this; -}; - -/** - * Leaves a room. - * - * @param {String} room - * @param {Function} fn optional, callback - * @return {Socket} self - * @api private - */ - -Socket.prototype.leave = function(room, fn){ - debug('leave room %s', room); - var self = this; - this.adapter.del(this.id, room, function(err){ - if (err) return fn && fn(err); - debug('left room %s', room); - delete self.rooms[room]; - fn && fn(null); - }); - return this; -}; - -/** - * Leave all rooms. - * - * @api private - */ - -Socket.prototype.leaveAll = function(){ - this.adapter.delAll(this.id); - this.rooms = {}; -}; - -/** - * Called by `Namespace` upon succesful - * middleware execution (ie: authorization). - * - * @api private - */ - -Socket.prototype.onconnect = function(){ - debug('socket connected - writing packet'); - this.nsp.connected[this.id] = this; - this.join(this.id); - this.packet({ type: parser.CONNECT }); -}; - -/** - * Called with each packet. Called by `Client`. - * - * @param {Object} packet - * @api private - */ - -Socket.prototype.onpacket = function(packet){ - debug('got packet %j', packet); - switch (packet.type) { - case parser.EVENT: - this.onevent(packet); - break; - - case parser.BINARY_EVENT: - this.onevent(packet); - break; - - case parser.ACK: - this.onack(packet); - break; - - case parser.BINARY_ACK: - this.onack(packet); - break; - - case parser.DISCONNECT: - this.ondisconnect(); - break; - - case parser.ERROR: - this.emit('error', packet.data); - } -}; - -/** - * Called upon event packet. - * - * @param {Object} packet object - * @api private - */ - -Socket.prototype.onevent = function(packet){ - var args = packet.data || []; - debug('emitting event %j', args); - - if (null != packet.id) { - debug('attaching ack callback to event'); - args.push(this.ack(packet.id)); - } - - emit.apply(this, args); -}; - -/** - * Produces an ack callback to emit with an event. - * - * @param {Number} id packet id - * @api private - */ - -Socket.prototype.ack = function(id){ - var self = this; - var sent = false; - return function(){ - // prevent double callbacks - if (sent) return; - var args = Array.prototype.slice.call(arguments); - debug('sending ack %j', args); - - var type = hasBin(args) ? parser.BINARY_ACK : parser.ACK; - self.packet({ - id: id, - type: type, - data: args - }); - - sent = true; - }; -}; - -/** - * Called upon ack packet. - * - * @api private - */ - -Socket.prototype.onack = function(packet){ - var ack = this.acks[packet.id]; - if ('function' == typeof ack) { - debug('calling ack %s with %j', packet.id, packet.data); - ack.apply(this, packet.data); - delete this.acks[packet.id]; - } else { - debug('bad ack %s', packet.id); - } -}; - -/** - * Called upon client disconnect packet. - * - * @api private - */ - -Socket.prototype.ondisconnect = function(){ - debug('got disconnect packet'); - this.onclose('client namespace disconnect'); -}; - -/** - * Handles a client error. - * - * @api private - */ - -Socket.prototype.onerror = function(err){ - if (this.listeners('error').length) { - this.emit('error', err); - } else { - console.error('Missing error handler on `socket`.'); - console.error(err.stack); - } -}; - -/** - * Called upon closing. Called by `Client`. - * - * @param {String} reason - * @throw {Error} optional error object - * @api private - */ - -Socket.prototype.onclose = function(reason){ - if (!this.connected) return this; - debug('closing socket - reason %s', reason); - this.leaveAll(); - this.nsp.remove(this); - this.client.remove(this); - this.connected = false; - this.disconnected = true; - delete this.nsp.connected[this.id]; - this.emit('disconnect', reason); -}; - -/** - * Produces an `error` packet. - * - * @param {Object} err error object - * @api private - */ - -Socket.prototype.error = function(err){ - this.packet({ type: parser.ERROR, data: err }); -}; - -/** - * Disconnects this client. - * - * @param {Boolean} close if `true`, closes the underlying connection - * @return {Socket} self - * @api public - */ - -Socket.prototype.disconnect = function(close){ - if (!this.connected) return this; - if (close) { - this.client.disconnect(); - } else { - this.packet({ type: parser.DISCONNECT }); - this.onclose('server namespace disconnect'); - } - return this; -}; - -/** - * Sets the compress flag. - * - * @param {Boolean} compress if `true`, compresses the sending data - * @return {Socket} self - * @api public - */ - -Socket.prototype.compress = function(compress){ - this.flags = this.flags || {}; - this.flags.compress = compress; - return this; -}; + +/** + * Module dependencies. + */ + +var Emitter = require('events').EventEmitter; +var parser = require('socket.io-parser'); +var url = require('url'); +var debug = require('debug')('socket.io:socket'); +var hasBin = require('has-binary'); + +/** + * Module exports. + */ + +module.exports = exports = Socket; + +/** + * Blacklisted events. + * + * @api public + */ + +exports.events = [ + 'error', + 'connect', + 'disconnect', + 'newListener', + 'removeListener' +]; + +/** + * Flags. + * + * @api private + */ + +var flags = [ + 'json', + 'volatile', + 'broadcast' +]; + +/** + * `EventEmitter#emit` reference. + */ + +var emit = Emitter.prototype.emit; + +/** + * Interface to a `Client` for a given `Namespace`. + * + * @param {Namespace} nsp + * @param {Client} client + * @api public + */ + +function Socket(nsp, client){ + this.nsp = nsp; + this.server = nsp.server; + this.adapter = this.nsp.adapter; + this.id = nsp.name + '#' + client.id; + this.client = client; + this.conn = client.conn; + this.rooms = {}; + this.acks = {}; + this.connected = true; + this.disconnected = false; + this.handshake = this.buildHandshake(); +} + +/** + * Inherits from `EventEmitter`. + */ + +Socket.prototype.__proto__ = Emitter.prototype; + +/** + * Apply flags from `Socket`. + */ + +flags.forEach(function(flag){ + Socket.prototype.__defineGetter__(flag, function(){ + this.flags = this.flags || {}; + this.flags[flag] = true; + return this; + }); +}); + +/** + * `request` engine.io shortcut. + * + * @api public + */ + +Socket.prototype.__defineGetter__('request', function(){ + return this.conn.request; +}); + +/** + * Builds the `handshake` BC object + * + * @api private + */ + +Socket.prototype.buildHandshake = function(){ + return { + headers: this.request.headers, + time: (new Date) + '', + address: this.conn.remoteAddress, + xdomain: !!this.request.headers.origin, + secure: !!this.request.connection.encrypted, + issued: +(new Date), + url: this.request.url, + query: url.parse(this.request.url, true).query || {} + }; +}; + +/** + * Emits to this client. + * + * @return {Socket} self + * @api public + */ + +Socket.prototype.emit = function(ev){ + if (~exports.events.indexOf(ev)) { + emit.apply(this, arguments); + } else { + var args = Array.prototype.slice.call(arguments); + var packet = {}; + packet.type = hasBin(args) ? parser.BINARY_EVENT : parser.EVENT; + packet.data = args; + var flags = this.flags || {}; + + // access last argument to see if it's an ACK callback + if ('function' == typeof args[args.length - 1]) { + if (this._rooms || flags.broadcast) { + throw new Error('Callbacks are not supported when broadcasting'); + } + + debug('emitting packet with ack id %d', this.nsp.ids); + this.acks[this.nsp.ids] = args.pop(); + packet.id = this.nsp.ids++; + } + + if (this._rooms || flags.broadcast) { + this.adapter.broadcast(packet, { + except: [this.id], + rooms: this._rooms, + flags: flags + }); + } else { + // dispatch packet + this.packet(packet, { + volatile: flags.volatile, + compress: flags.compress + }); + } + + // reset flags + delete this._rooms; + delete this.flags; + } + return this; +}; + +/** + * Targets a room when broadcasting. + * + * @param {String} name + * @return {Socket} self + * @api public + */ + +Socket.prototype.to = +Socket.prototype.in = function(name){ + this._rooms = this._rooms || []; + if (!~this._rooms.indexOf(name)) this._rooms.push(name); + return this; +}; + +/** + * Sends a `message` event. + * + * @return {Socket} self + * @api public + */ + +Socket.prototype.send = +Socket.prototype.write = function(){ + var args = Array.prototype.slice.call(arguments); + args.unshift('message'); + this.emit.apply(this, args); + return this; +}; + +/** + * Writes a packet. + * + * @param {Object} packet object + * @param {Object} opts options + * @api private + */ + +Socket.prototype.packet = function(packet, opts){ + packet.nsp = this.nsp.name; + opts = opts || {}; + opts.compress = false !== opts.compress; + this.client.packet(packet, opts); +}; + +/** + * Joins a room. + * + * @param {String} room + * @param {Function} fn optional, callback + * @return {Socket} self + * @api private + */ + +Socket.prototype.join = function(room, fn){ + debug('joining room %s', room); + var self = this; + if (this.rooms.hasOwnProperty(room)) { + fn && fn(null); + return this; + } + this.adapter.add(this.id, room, function(err){ + if (err) return fn && fn(err); + debug('joined room %s', room); + self.rooms[room] = room; + fn && fn(null); + }); + return this; +}; + +/** + * Leaves a room. + * + * @param {String} room + * @param {Function} fn optional, callback + * @return {Socket} self + * @api private + */ + +Socket.prototype.leave = function(room, fn){ + debug('leave room %s', room); + var self = this; + this.adapter.del(this.id, room, function(err){ + if (err) return fn && fn(err); + debug('left room %s', room); + delete self.rooms[room]; + fn && fn(null); + }); + return this; +}; + +/** + * Leave all rooms. + * + * @api private + */ + +Socket.prototype.leaveAll = function(){ + this.adapter.delAll(this.id); + this.rooms = {}; +}; + +/** + * Called by `Namespace` upon succesful + * middleware execution (ie: authorization). + * + * @api private + */ + +Socket.prototype.onconnect = function(){ + debug('socket connected - writing packet'); + this.nsp.connected[this.id] = this; + this.join(this.id); + this.packet({ type: parser.CONNECT }); +}; + +/** + * Called with each packet. Called by `Client`. + * + * @param {Object} packet + * @api private + */ + +Socket.prototype.onpacket = function(packet){ + debug('got packet %j', packet); + switch (packet.type) { + case parser.EVENT: + this.onevent(packet); + break; + + case parser.BINARY_EVENT: + this.onevent(packet); + break; + + case parser.ACK: + this.onack(packet); + break; + + case parser.BINARY_ACK: + this.onack(packet); + break; + + case parser.DISCONNECT: + this.ondisconnect(); + break; + + case parser.ERROR: + this.emit('error', packet.data); + } +}; + +/** + * Called upon event packet. + * + * @param {Object} packet object + * @api private + */ + +Socket.prototype.onevent = function(packet){ + var args = packet.data || []; + debug('emitting event %j', args); + + if (null != packet.id) { + debug('attaching ack callback to event'); + args.push(this.ack(packet.id)); + } + + emit.apply(this, args); +}; + +/** + * Produces an ack callback to emit with an event. + * + * @param {Number} id packet id + * @api private + */ + +Socket.prototype.ack = function(id){ + var self = this; + var sent = false; + return function(){ + // prevent double callbacks + if (sent) return; + var args = Array.prototype.slice.call(arguments); + debug('sending ack %j', args); + + var type = hasBin(args) ? parser.BINARY_ACK : parser.ACK; + self.packet({ + id: id, + type: type, + data: args + }); + + sent = true; + }; +}; + +/** + * Called upon ack packet. + * + * @api private + */ + +Socket.prototype.onack = function(packet){ + var ack = this.acks[packet.id]; + if ('function' == typeof ack) { + debug('calling ack %s with %j', packet.id, packet.data); + ack.apply(this, packet.data); + delete this.acks[packet.id]; + } else { + debug('bad ack %s', packet.id); + } +}; + +/** + * Called upon client disconnect packet. + * + * @api private + */ + +Socket.prototype.ondisconnect = function(){ + debug('got disconnect packet'); + this.onclose('client namespace disconnect'); +}; + +/** + * Handles a client error. + * + * @api private + */ + +Socket.prototype.onerror = function(err){ + if (this.listeners('error').length) { + this.emit('error', err); + } else { + console.error('Missing error handler on `socket`.'); + console.error(err.stack); + } +}; + +/** + * Called upon closing. Called by `Client`. + * + * @param {String} reason + * @throw {Error} optional error object + * @api private + */ + +Socket.prototype.onclose = function(reason){ + if (!this.connected) return this; + debug('closing socket - reason %s', reason); + this.leaveAll(); + this.nsp.remove(this); + this.client.remove(this); + this.connected = false; + this.disconnected = true; + delete this.nsp.connected[this.id]; + this.emit('disconnect', reason); +}; + +/** + * Produces an `error` packet. + * + * @param {Object} err error object + * @api private + */ + +Socket.prototype.error = function(err){ + this.packet({ type: parser.ERROR, data: err }); +}; + +/** + * Disconnects this client. + * + * @param {Boolean} close if `true`, closes the underlying connection + * @return {Socket} self + * @api public + */ + +Socket.prototype.disconnect = function(close){ + if (!this.connected) return this; + if (close) { + this.client.disconnect(); + } else { + this.packet({ type: parser.DISCONNECT }); + this.onclose('server namespace disconnect'); + } + return this; +}; + +/** + * Sets the compress flag. + * + * @param {Boolean} compress if `true`, compresses the sending data + * @return {Socket} self + * @api public + */ + +Socket.prototype.compress = function(compress){ + this.flags = this.flags || {}; + this.flags.compress = compress; + return this; +}; diff --git a/ui/node_modules/socket.io/node_modules/debug/.jshintrc b/ui/node_modules/socket.io/node_modules/debug/.jshintrc index cf343ce0..299877f2 100644 --- a/ui/node_modules/socket.io/node_modules/debug/.jshintrc +++ b/ui/node_modules/socket.io/node_modules/debug/.jshintrc @@ -1,3 +1,3 @@ -{ - "laxbreak": true -} +{ + "laxbreak": true +} diff --git a/ui/node_modules/socket.io/node_modules/debug/.npmignore b/ui/node_modules/socket.io/node_modules/debug/.npmignore index 71f1cedc..7e6163db 100644 --- a/ui/node_modules/socket.io/node_modules/debug/.npmignore +++ b/ui/node_modules/socket.io/node_modules/debug/.npmignore @@ -1,6 +1,6 @@ -support -test -examples -example -*.sock -dist +support +test +examples +example +*.sock +dist diff --git a/ui/node_modules/socket.io/node_modules/debug/History.md b/ui/node_modules/socket.io/node_modules/debug/History.md index cc4a66ed..854c9711 100644 --- a/ui/node_modules/socket.io/node_modules/debug/History.md +++ b/ui/node_modules/socket.io/node_modules/debug/History.md @@ -1,195 +1,195 @@ - -2.2.0 / 2015-05-09 -================== - - * package: update "ms" to v0.7.1 (#202, @dougwilson) - * README: add logging to file example (#193, @DanielOchoa) - * README: fixed a typo (#191, @amir-s) - * browser: expose `storage` (#190, @stephenmathieson) - * Makefile: add a `distclean` target (#189, @stephenmathieson) - -2.1.3 / 2015-03-13 -================== - - * Updated stdout/stderr example (#186) - * Updated example/stdout.js to match debug current behaviour - * Renamed example/stderr.js to stdout.js - * Update Readme.md (#184) - * replace high intensity foreground color for bold (#182, #183) - -2.1.2 / 2015-03-01 -================== - - * dist: recompile - * update "ms" to v0.7.0 - * package: update "browserify" to v9.0.3 - * component: fix "ms.js" repo location - * changed bower package name - * updated documentation about using debug in a browser - * fix: security error on safari (#167, #168, @yields) - -2.1.1 / 2014-12-29 -================== - - * browser: use `typeof` to check for `console` existence - * browser: check for `console.log` truthiness (fix IE 8/9) - * browser: add support for Chrome apps - * Readme: added Windows usage remarks - * Add `bower.json` to properly support bower install - -2.1.0 / 2014-10-15 -================== - - * node: implement `DEBUG_FD` env variable support - * package: update "browserify" to v6.1.0 - * package: add "license" field to package.json (#135, @panuhorsmalahti) - -2.0.0 / 2014-09-01 -================== - - * package: update "browserify" to v5.11.0 - * node: use stderr rather than stdout for logging (#29, @stephenmathieson) - -1.0.4 / 2014-07-15 -================== - - * dist: recompile - * example: remove `console.info()` log usage - * example: add "Content-Type" UTF-8 header to browser example - * browser: place %c marker after the space character - * browser: reset the "content" color via `color: inherit` - * browser: add colors support for Firefox >= v31 - * debug: prefer an instance `log()` function over the global one (#119) - * Readme: update documentation about styled console logs for FF v31 (#116, @wryk) - -1.0.3 / 2014-07-09 -================== - - * Add support for multiple wildcards in namespaces (#122, @seegno) - * browser: fix lint - -1.0.2 / 2014-06-10 -================== - - * browser: update color palette (#113, @gscottolson) - * common: make console logging function configurable (#108, @timoxley) - * node: fix %o colors on old node <= 0.8.x - * Makefile: find node path using shell/which (#109, @timoxley) - -1.0.1 / 2014-06-06 -================== - - * browser: use `removeItem()` to clear localStorage - * browser, node: don't set DEBUG if namespaces is undefined (#107, @leedm777) - * package: add "contributors" section - * node: fix comment typo - * README: list authors - -1.0.0 / 2014-06-04 -================== - - * make ms diff be global, not be scope - * debug: ignore empty strings in enable() - * node: make DEBUG_COLORS able to disable coloring - * *: export the `colors` array - * npmignore: don't publish the `dist` dir - * Makefile: refactor to use browserify - * package: add "browserify" as a dev dependency - * Readme: add Web Inspector Colors section - * node: reset terminal color for the debug content - * node: map "%o" to `util.inspect()` - * browser: map "%j" to `JSON.stringify()` - * debug: add custom "formatters" - * debug: use "ms" module for humanizing the diff - * Readme: add "bash" syntax highlighting - * browser: add Firebug color support - * browser: add colors for WebKit browsers - * node: apply log to `console` - * rewrite: abstract common logic for Node & browsers - * add .jshintrc file - -0.8.1 / 2014-04-14 -================== - - * package: re-add the "component" section - -0.8.0 / 2014-03-30 -================== - - * add `enable()` method for nodejs. Closes #27 - * change from stderr to stdout - * remove unnecessary index.js file - -0.7.4 / 2013-11-13 -================== - - * remove "browserify" key from package.json (fixes something in browserify) - -0.7.3 / 2013-10-30 -================== - - * fix: catch localStorage security error when cookies are blocked (Chrome) - * add debug(err) support. Closes #46 - * add .browser prop to package.json. Closes #42 - -0.7.2 / 2013-02-06 -================== - - * fix package.json - * fix: Mobile Safari (private mode) is broken with debug - * fix: Use unicode to send escape character to shell instead of octal to work with strict mode javascript - -0.7.1 / 2013-02-05 -================== - - * add repository URL to package.json - * add DEBUG_COLORED to force colored output - * add browserify support - * fix component. Closes #24 - -0.7.0 / 2012-05-04 -================== - - * Added .component to package.json - * Added debug.component.js build - -0.6.0 / 2012-03-16 -================== - - * Added support for "-" prefix in DEBUG [Vinay Pulim] - * Added `.enabled` flag to the node version [TooTallNate] - -0.5.0 / 2012-02-02 -================== - - * Added: humanize diffs. Closes #8 - * Added `debug.disable()` to the CS variant - * Removed padding. Closes #10 - * Fixed: persist client-side variant again. Closes #9 - -0.4.0 / 2012-02-01 -================== - - * Added browser variant support for older browsers [TooTallNate] - * Added `debug.enable('project:*')` to browser variant [TooTallNate] - * Added padding to diff (moved it to the right) - -0.3.0 / 2012-01-26 -================== - - * Added millisecond diff when isatty, otherwise UTC string - -0.2.0 / 2012-01-22 -================== - - * Added wildcard support - -0.1.0 / 2011-12-02 -================== - - * Added: remove colors unless stderr isatty [TooTallNate] - -0.0.1 / 2010-01-03 -================== - - * Initial release + +2.2.0 / 2015-05-09 +================== + + * package: update "ms" to v0.7.1 (#202, @dougwilson) + * README: add logging to file example (#193, @DanielOchoa) + * README: fixed a typo (#191, @amir-s) + * browser: expose `storage` (#190, @stephenmathieson) + * Makefile: add a `distclean` target (#189, @stephenmathieson) + +2.1.3 / 2015-03-13 +================== + + * Updated stdout/stderr example (#186) + * Updated example/stdout.js to match debug current behaviour + * Renamed example/stderr.js to stdout.js + * Update Readme.md (#184) + * replace high intensity foreground color for bold (#182, #183) + +2.1.2 / 2015-03-01 +================== + + * dist: recompile + * update "ms" to v0.7.0 + * package: update "browserify" to v9.0.3 + * component: fix "ms.js" repo location + * changed bower package name + * updated documentation about using debug in a browser + * fix: security error on safari (#167, #168, @yields) + +2.1.1 / 2014-12-29 +================== + + * browser: use `typeof` to check for `console` existence + * browser: check for `console.log` truthiness (fix IE 8/9) + * browser: add support for Chrome apps + * Readme: added Windows usage remarks + * Add `bower.json` to properly support bower install + +2.1.0 / 2014-10-15 +================== + + * node: implement `DEBUG_FD` env variable support + * package: update "browserify" to v6.1.0 + * package: add "license" field to package.json (#135, @panuhorsmalahti) + +2.0.0 / 2014-09-01 +================== + + * package: update "browserify" to v5.11.0 + * node: use stderr rather than stdout for logging (#29, @stephenmathieson) + +1.0.4 / 2014-07-15 +================== + + * dist: recompile + * example: remove `console.info()` log usage + * example: add "Content-Type" UTF-8 header to browser example + * browser: place %c marker after the space character + * browser: reset the "content" color via `color: inherit` + * browser: add colors support for Firefox >= v31 + * debug: prefer an instance `log()` function over the global one (#119) + * Readme: update documentation about styled console logs for FF v31 (#116, @wryk) + +1.0.3 / 2014-07-09 +================== + + * Add support for multiple wildcards in namespaces (#122, @seegno) + * browser: fix lint + +1.0.2 / 2014-06-10 +================== + + * browser: update color palette (#113, @gscottolson) + * common: make console logging function configurable (#108, @timoxley) + * node: fix %o colors on old node <= 0.8.x + * Makefile: find node path using shell/which (#109, @timoxley) + +1.0.1 / 2014-06-06 +================== + + * browser: use `removeItem()` to clear localStorage + * browser, node: don't set DEBUG if namespaces is undefined (#107, @leedm777) + * package: add "contributors" section + * node: fix comment typo + * README: list authors + +1.0.0 / 2014-06-04 +================== + + * make ms diff be global, not be scope + * debug: ignore empty strings in enable() + * node: make DEBUG_COLORS able to disable coloring + * *: export the `colors` array + * npmignore: don't publish the `dist` dir + * Makefile: refactor to use browserify + * package: add "browserify" as a dev dependency + * Readme: add Web Inspector Colors section + * node: reset terminal color for the debug content + * node: map "%o" to `util.inspect()` + * browser: map "%j" to `JSON.stringify()` + * debug: add custom "formatters" + * debug: use "ms" module for humanizing the diff + * Readme: add "bash" syntax highlighting + * browser: add Firebug color support + * browser: add colors for WebKit browsers + * node: apply log to `console` + * rewrite: abstract common logic for Node & browsers + * add .jshintrc file + +0.8.1 / 2014-04-14 +================== + + * package: re-add the "component" section + +0.8.0 / 2014-03-30 +================== + + * add `enable()` method for nodejs. Closes #27 + * change from stderr to stdout + * remove unnecessary index.js file + +0.7.4 / 2013-11-13 +================== + + * remove "browserify" key from package.json (fixes something in browserify) + +0.7.3 / 2013-10-30 +================== + + * fix: catch localStorage security error when cookies are blocked (Chrome) + * add debug(err) support. Closes #46 + * add .browser prop to package.json. Closes #42 + +0.7.2 / 2013-02-06 +================== + + * fix package.json + * fix: Mobile Safari (private mode) is broken with debug + * fix: Use unicode to send escape character to shell instead of octal to work with strict mode javascript + +0.7.1 / 2013-02-05 +================== + + * add repository URL to package.json + * add DEBUG_COLORED to force colored output + * add browserify support + * fix component. Closes #24 + +0.7.0 / 2012-05-04 +================== + + * Added .component to package.json + * Added debug.component.js build + +0.6.0 / 2012-03-16 +================== + + * Added support for "-" prefix in DEBUG [Vinay Pulim] + * Added `.enabled` flag to the node version [TooTallNate] + +0.5.0 / 2012-02-02 +================== + + * Added: humanize diffs. Closes #8 + * Added `debug.disable()` to the CS variant + * Removed padding. Closes #10 + * Fixed: persist client-side variant again. Closes #9 + +0.4.0 / 2012-02-01 +================== + + * Added browser variant support for older browsers [TooTallNate] + * Added `debug.enable('project:*')` to browser variant [TooTallNate] + * Added padding to diff (moved it to the right) + +0.3.0 / 2012-01-26 +================== + + * Added millisecond diff when isatty, otherwise UTC string + +0.2.0 / 2012-01-22 +================== + + * Added wildcard support + +0.1.0 / 2011-12-02 +================== + + * Added: remove colors unless stderr isatty [TooTallNate] + +0.0.1 / 2010-01-03 +================== + + * Initial release diff --git a/ui/node_modules/socket.io/node_modules/debug/Makefile b/ui/node_modules/socket.io/node_modules/debug/Makefile index 7f0b731f..5cf4a596 100644 --- a/ui/node_modules/socket.io/node_modules/debug/Makefile +++ b/ui/node_modules/socket.io/node_modules/debug/Makefile @@ -1,36 +1,36 @@ - -# get Makefile directory name: http://stackoverflow.com/a/5982798/376773 -THIS_MAKEFILE_PATH:=$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) -THIS_DIR:=$(shell cd $(dir $(THIS_MAKEFILE_PATH));pwd) - -# BIN directory -BIN := $(THIS_DIR)/node_modules/.bin - -# applications -NODE ?= $(shell which node) -NPM ?= $(NODE) $(shell which npm) -BROWSERIFY ?= $(NODE) $(BIN)/browserify - -all: dist/debug.js - -install: node_modules - -clean: - @rm -rf dist - -dist: - @mkdir -p $@ - -dist/debug.js: node_modules browser.js debug.js dist - @$(BROWSERIFY) \ - --standalone debug \ - . > $@ - -distclean: clean - @rm -rf node_modules - -node_modules: package.json - @NODE_ENV= $(NPM) install - @touch node_modules - -.PHONY: all install clean distclean + +# get Makefile directory name: http://stackoverflow.com/a/5982798/376773 +THIS_MAKEFILE_PATH:=$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) +THIS_DIR:=$(shell cd $(dir $(THIS_MAKEFILE_PATH));pwd) + +# BIN directory +BIN := $(THIS_DIR)/node_modules/.bin + +# applications +NODE ?= $(shell which node) +NPM ?= $(NODE) $(shell which npm) +BROWSERIFY ?= $(NODE) $(BIN)/browserify + +all: dist/debug.js + +install: node_modules + +clean: + @rm -rf dist + +dist: + @mkdir -p $@ + +dist/debug.js: node_modules browser.js debug.js dist + @$(BROWSERIFY) \ + --standalone debug \ + . > $@ + +distclean: clean + @rm -rf node_modules + +node_modules: package.json + @NODE_ENV= $(NPM) install + @touch node_modules + +.PHONY: all install clean distclean diff --git a/ui/node_modules/socket.io/node_modules/debug/Readme.md b/ui/node_modules/socket.io/node_modules/debug/Readme.md index 9327d73e..b4f45e3c 100644 --- a/ui/node_modules/socket.io/node_modules/debug/Readme.md +++ b/ui/node_modules/socket.io/node_modules/debug/Readme.md @@ -1,188 +1,188 @@ -# debug - - tiny node.js debugging utility modelled after node core's debugging technique. - -## Installation - -```bash -$ npm install debug -``` - -## Usage - - With `debug` you simply invoke the exported function to generate your debug function, passing it a name which will determine if a noop function is returned, or a decorated `console.error`, so all of the `console` format string goodies you're used to work fine. A unique color is selected per-function for visibility. - -Example _app.js_: - -```js -var debug = require('debug')('http') - , http = require('http') - , name = 'My App'; - -// fake app - -debug('booting %s', name); - -http.createServer(function(req, res){ - debug(req.method + ' ' + req.url); - res.end('hello\n'); -}).listen(3000, function(){ - debug('listening'); -}); - -// fake worker of some kind - -require('./worker'); -``` - -Example _worker.js_: - -```js -var debug = require('debug')('worker'); - -setInterval(function(){ - debug('doing some work'); -}, 1000); -``` - - The __DEBUG__ environment variable is then used to enable these based on space or comma-delimited names. Here are some examples: - - ![debug http and worker](http://f.cl.ly/items/18471z1H402O24072r1J/Screenshot.png) - - ![debug worker](http://f.cl.ly/items/1X413v1a3M0d3C2c1E0i/Screenshot.png) - -#### Windows note - - On Windows the environment variable is set using the `set` command. - - ```cmd - set DEBUG=*,-not_this - ``` - -Then, run the program to be debugged as usual. - -## Millisecond diff - - When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls. - - ![](http://f.cl.ly/items/2i3h1d3t121M2Z1A3Q0N/Screenshot.png) - - When stdout is not a TTY, `Date#toUTCString()` is used, making it more useful for logging the debug information as shown below: - - ![](http://f.cl.ly/items/112H3i0e0o0P0a2Q2r11/Screenshot.png) - -## Conventions - - If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". - -## Wildcards - - The `*` character may be used as a wildcard. Suppose for example your library has debuggers named "connect:bodyParser", "connect:compress", "connect:session", instead of listing all three with `DEBUG=connect:bodyParser,connect:compress,connect:session`, you may simply do `DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`. - - You can also exclude specific debuggers by prefixing them with a "-" character. For example, `DEBUG=*,-connect:*` would include all debuggers except those starting with "connect:". - -## Browser support - - Debug works in the browser as well, currently persisted by `localStorage`. Consider the situation shown below where you have `worker:a` and `worker:b`, and wish to debug both. Somewhere in the code on your page, include: - -```js -window.myDebug = require("debug"); -``` - - ("debug" is a global object in the browser so we give this object a different name.) When your page is open in the browser, type the following in the console: - -```js -myDebug.enable("worker:*") -``` - - Refresh the page. Debug output will continue to be sent to the console until it is disabled by typing `myDebug.disable()` in the console. - -```js -a = debug('worker:a'); -b = debug('worker:b'); - -setInterval(function(){ - a('doing some work'); -}, 1000); - -setInterval(function(){ - b('doing some work'); -}, 1200); -``` - -#### Web Inspector Colors - - Colors are also enabled on "Web Inspectors" that understand the `%c` formatting - option. These are WebKit web inspectors, Firefox ([since version - 31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/)) - and the Firebug plugin for Firefox (any version). - - Colored output looks something like: - - ![](https://cloud.githubusercontent.com/assets/71256/3139768/b98c5fd8-e8ef-11e3-862a-f7253b6f47c6.png) - -### stderr vs stdout - -You can set an alternative logging method per-namespace by overriding the `log` method on a per-namespace or globally: - -Example _stdout.js_: - -```js -var debug = require('debug'); -var error = debug('app:error'); - -// by default stderr is used -error('goes to stderr!'); - -var log = debug('app:log'); -// set this namespace to log via console.log -log.log = console.log.bind(console); // don't forget to bind to console! -log('goes to stdout'); -error('still goes to stderr!'); - -// set all output to go via console.info -// overrides all per-namespace log settings -debug.log = console.info.bind(console); -error('now goes to stdout via console.info'); -log('still goes to stdout, but via console.info now'); -``` - -### Save debug output to a file - -You can save all debug statements to a file by piping them. - -Example: - -```bash -$ DEBUG_FD=3 node your-app.js 3> whatever.log -``` - -## Authors - - - TJ Holowaychuk - - Nathan Rajlich - -## License - -(The MIT License) - -Copyright (c) 2014 TJ Holowaychuk <tj@vision-media.ca> - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# debug + + tiny node.js debugging utility modelled after node core's debugging technique. + +## Installation + +```bash +$ npm install debug +``` + +## Usage + + With `debug` you simply invoke the exported function to generate your debug function, passing it a name which will determine if a noop function is returned, or a decorated `console.error`, so all of the `console` format string goodies you're used to work fine. A unique color is selected per-function for visibility. + +Example _app.js_: + +```js +var debug = require('debug')('http') + , http = require('http') + , name = 'My App'; + +// fake app + +debug('booting %s', name); + +http.createServer(function(req, res){ + debug(req.method + ' ' + req.url); + res.end('hello\n'); +}).listen(3000, function(){ + debug('listening'); +}); + +// fake worker of some kind + +require('./worker'); +``` + +Example _worker.js_: + +```js +var debug = require('debug')('worker'); + +setInterval(function(){ + debug('doing some work'); +}, 1000); +``` + + The __DEBUG__ environment variable is then used to enable these based on space or comma-delimited names. Here are some examples: + + ![debug http and worker](http://f.cl.ly/items/18471z1H402O24072r1J/Screenshot.png) + + ![debug worker](http://f.cl.ly/items/1X413v1a3M0d3C2c1E0i/Screenshot.png) + +#### Windows note + + On Windows the environment variable is set using the `set` command. + + ```cmd + set DEBUG=*,-not_this + ``` + +Then, run the program to be debugged as usual. + +## Millisecond diff + + When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls. + + ![](http://f.cl.ly/items/2i3h1d3t121M2Z1A3Q0N/Screenshot.png) + + When stdout is not a TTY, `Date#toUTCString()` is used, making it more useful for logging the debug information as shown below: + + ![](http://f.cl.ly/items/112H3i0e0o0P0a2Q2r11/Screenshot.png) + +## Conventions + + If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". + +## Wildcards + + The `*` character may be used as a wildcard. Suppose for example your library has debuggers named "connect:bodyParser", "connect:compress", "connect:session", instead of listing all three with `DEBUG=connect:bodyParser,connect:compress,connect:session`, you may simply do `DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`. + + You can also exclude specific debuggers by prefixing them with a "-" character. For example, `DEBUG=*,-connect:*` would include all debuggers except those starting with "connect:". + +## Browser support + + Debug works in the browser as well, currently persisted by `localStorage`. Consider the situation shown below where you have `worker:a` and `worker:b`, and wish to debug both. Somewhere in the code on your page, include: + +```js +window.myDebug = require("debug"); +``` + + ("debug" is a global object in the browser so we give this object a different name.) When your page is open in the browser, type the following in the console: + +```js +myDebug.enable("worker:*") +``` + + Refresh the page. Debug output will continue to be sent to the console until it is disabled by typing `myDebug.disable()` in the console. + +```js +a = debug('worker:a'); +b = debug('worker:b'); + +setInterval(function(){ + a('doing some work'); +}, 1000); + +setInterval(function(){ + b('doing some work'); +}, 1200); +``` + +#### Web Inspector Colors + + Colors are also enabled on "Web Inspectors" that understand the `%c` formatting + option. These are WebKit web inspectors, Firefox ([since version + 31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/)) + and the Firebug plugin for Firefox (any version). + + Colored output looks something like: + + ![](https://cloud.githubusercontent.com/assets/71256/3139768/b98c5fd8-e8ef-11e3-862a-f7253b6f47c6.png) + +### stderr vs stdout + +You can set an alternative logging method per-namespace by overriding the `log` method on a per-namespace or globally: + +Example _stdout.js_: + +```js +var debug = require('debug'); +var error = debug('app:error'); + +// by default stderr is used +error('goes to stderr!'); + +var log = debug('app:log'); +// set this namespace to log via console.log +log.log = console.log.bind(console); // don't forget to bind to console! +log('goes to stdout'); +error('still goes to stderr!'); + +// set all output to go via console.info +// overrides all per-namespace log settings +debug.log = console.info.bind(console); +error('now goes to stdout via console.info'); +log('still goes to stdout, but via console.info now'); +``` + +### Save debug output to a file + +You can save all debug statements to a file by piping them. + +Example: + +```bash +$ DEBUG_FD=3 node your-app.js 3> whatever.log +``` + +## Authors + + - TJ Holowaychuk + - Nathan Rajlich + +## License + +(The MIT License) + +Copyright (c) 2014 TJ Holowaychuk <tj@vision-media.ca> + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/socket.io/node_modules/debug/bower.json b/ui/node_modules/socket.io/node_modules/debug/bower.json index e3aa7138..6af573ff 100644 --- a/ui/node_modules/socket.io/node_modules/debug/bower.json +++ b/ui/node_modules/socket.io/node_modules/debug/bower.json @@ -1,28 +1,28 @@ -{ - "name": "visionmedia-debug", - "main": "dist/debug.js", - "version": "2.2.0", - "homepage": "https://github.com/visionmedia/debug", - "authors": [ - "TJ Holowaychuk " - ], - "description": "visionmedia-debug", - "moduleType": [ - "amd", - "es6", - "globals", - "node" - ], - "keywords": [ - "visionmedia", - "debug" - ], - "license": "MIT", - "ignore": [ - "**/.*", - "node_modules", - "bower_components", - "test", - "tests" - ] -} +{ + "name": "visionmedia-debug", + "main": "dist/debug.js", + "version": "2.2.0", + "homepage": "https://github.com/visionmedia/debug", + "authors": [ + "TJ Holowaychuk " + ], + "description": "visionmedia-debug", + "moduleType": [ + "amd", + "es6", + "globals", + "node" + ], + "keywords": [ + "visionmedia", + "debug" + ], + "license": "MIT", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ] +} diff --git a/ui/node_modules/socket.io/node_modules/debug/browser.js b/ui/node_modules/socket.io/node_modules/debug/browser.js index afe80edd..7c764522 100644 --- a/ui/node_modules/socket.io/node_modules/debug/browser.js +++ b/ui/node_modules/socket.io/node_modules/debug/browser.js @@ -1,168 +1,168 @@ - -/** - * This is the web browser implementation of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = require('./debug'); -exports.log = log; -exports.formatArgs = formatArgs; -exports.save = save; -exports.load = load; -exports.useColors = useColors; -exports.storage = 'undefined' != typeof chrome - && 'undefined' != typeof chrome.storage - ? chrome.storage.local - : localstorage(); - -/** - * Colors. - */ - -exports.colors = [ - 'lightseagreen', - 'forestgreen', - 'goldenrod', - 'dodgerblue', - 'darkorchid', - 'crimson' -]; - -/** - * Currently only WebKit-based Web Inspectors, Firefox >= v31, - * and the Firebug extension (any Firefox version) are known - * to support "%c" CSS customizations. - * - * TODO: add a `localStorage` variable to explicitly enable/disable colors - */ - -function useColors() { - // is webkit? http://stackoverflow.com/a/16459606/376773 - return ('WebkitAppearance' in document.documentElement.style) || - // is firebug? http://stackoverflow.com/a/398120/376773 - (window.console && (console.firebug || (console.exception && console.table))) || - // is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31); -} - -/** - * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. - */ - -exports.formatters.j = function(v) { - return JSON.stringify(v); -}; - - -/** - * Colorize log arguments if enabled. - * - * @api public - */ - -function formatArgs() { - var args = arguments; - var useColors = this.useColors; - - args[0] = (useColors ? '%c' : '') - + this.namespace - + (useColors ? ' %c' : ' ') - + args[0] - + (useColors ? '%c ' : ' ') - + '+' + exports.humanize(this.diff); - - if (!useColors) return args; - - var c = 'color: ' + this.color; - args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1)); - - // the final "%c" is somewhat tricky, because there could be other - // arguments passed either before or after the %c, so we need to - // figure out the correct index to insert the CSS into - var index = 0; - var lastC = 0; - args[0].replace(/%[a-z%]/g, function(match) { - if ('%%' === match) return; - index++; - if ('%c' === match) { - // we only are interested in the *last* %c - // (the user may have provided their own) - lastC = index; - } - }); - - args.splice(lastC, 0, c); - return args; -} - -/** - * Invokes `console.log()` when available. - * No-op when `console.log` is not a "function". - * - * @api public - */ - -function log() { - // this hackery is required for IE8/9, where - // the `console.log` function doesn't have 'apply' - return 'object' === typeof console - && console.log - && Function.prototype.apply.call(console.log, console, arguments); -} - -/** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ - -function save(namespaces) { - try { - if (null == namespaces) { - exports.storage.removeItem('debug'); - } else { - exports.storage.debug = namespaces; - } - } catch(e) {} -} - -/** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ - -function load() { - var r; - try { - r = exports.storage.debug; - } catch(e) {} - return r; -} - -/** - * Enable namespaces listed in `localStorage.debug` initially. - */ - -exports.enable(load()); - -/** - * Localstorage attempts to return the localstorage. - * - * This is necessary because safari throws - * when a user disables cookies/localstorage - * and you attempt to access it. - * - * @return {LocalStorage} - * @api private - */ - -function localstorage(){ - try { - return window.localStorage; - } catch (e) {} -} + +/** + * This is the web browser implementation of `debug()`. + * + * Expose `debug()` as the module. + */ + +exports = module.exports = require('./debug'); +exports.log = log; +exports.formatArgs = formatArgs; +exports.save = save; +exports.load = load; +exports.useColors = useColors; +exports.storage = 'undefined' != typeof chrome + && 'undefined' != typeof chrome.storage + ? chrome.storage.local + : localstorage(); + +/** + * Colors. + */ + +exports.colors = [ + 'lightseagreen', + 'forestgreen', + 'goldenrod', + 'dodgerblue', + 'darkorchid', + 'crimson' +]; + +/** + * Currently only WebKit-based Web Inspectors, Firefox >= v31, + * and the Firebug extension (any Firefox version) are known + * to support "%c" CSS customizations. + * + * TODO: add a `localStorage` variable to explicitly enable/disable colors + */ + +function useColors() { + // is webkit? http://stackoverflow.com/a/16459606/376773 + return ('WebkitAppearance' in document.documentElement.style) || + // is firebug? http://stackoverflow.com/a/398120/376773 + (window.console && (console.firebug || (console.exception && console.table))) || + // is firefox >= v31? + // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages + (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31); +} + +/** + * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. + */ + +exports.formatters.j = function(v) { + return JSON.stringify(v); +}; + + +/** + * Colorize log arguments if enabled. + * + * @api public + */ + +function formatArgs() { + var args = arguments; + var useColors = this.useColors; + + args[0] = (useColors ? '%c' : '') + + this.namespace + + (useColors ? ' %c' : ' ') + + args[0] + + (useColors ? '%c ' : ' ') + + '+' + exports.humanize(this.diff); + + if (!useColors) return args; + + var c = 'color: ' + this.color; + args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1)); + + // the final "%c" is somewhat tricky, because there could be other + // arguments passed either before or after the %c, so we need to + // figure out the correct index to insert the CSS into + var index = 0; + var lastC = 0; + args[0].replace(/%[a-z%]/g, function(match) { + if ('%%' === match) return; + index++; + if ('%c' === match) { + // we only are interested in the *last* %c + // (the user may have provided their own) + lastC = index; + } + }); + + args.splice(lastC, 0, c); + return args; +} + +/** + * Invokes `console.log()` when available. + * No-op when `console.log` is not a "function". + * + * @api public + */ + +function log() { + // this hackery is required for IE8/9, where + // the `console.log` function doesn't have 'apply' + return 'object' === typeof console + && console.log + && Function.prototype.apply.call(console.log, console, arguments); +} + +/** + * Save `namespaces`. + * + * @param {String} namespaces + * @api private + */ + +function save(namespaces) { + try { + if (null == namespaces) { + exports.storage.removeItem('debug'); + } else { + exports.storage.debug = namespaces; + } + } catch(e) {} +} + +/** + * Load `namespaces`. + * + * @return {String} returns the previously persisted debug modes + * @api private + */ + +function load() { + var r; + try { + r = exports.storage.debug; + } catch(e) {} + return r; +} + +/** + * Enable namespaces listed in `localStorage.debug` initially. + */ + +exports.enable(load()); + +/** + * Localstorage attempts to return the localstorage. + * + * This is necessary because safari throws + * when a user disables cookies/localstorage + * and you attempt to access it. + * + * @return {LocalStorage} + * @api private + */ + +function localstorage(){ + try { + return window.localStorage; + } catch (e) {} +} diff --git a/ui/node_modules/socket.io/node_modules/debug/component.json b/ui/node_modules/socket.io/node_modules/debug/component.json index 139846b1..ca106372 100644 --- a/ui/node_modules/socket.io/node_modules/debug/component.json +++ b/ui/node_modules/socket.io/node_modules/debug/component.json @@ -1,19 +1,19 @@ -{ - "name": "debug", - "repo": "visionmedia/debug", - "description": "small debugging utility", - "version": "2.2.0", - "keywords": [ - "debug", - "log", - "debugger" - ], - "main": "browser.js", - "scripts": [ - "browser.js", - "debug.js" - ], - "dependencies": { - "rauchg/ms.js": "0.7.1" - } -} +{ + "name": "debug", + "repo": "visionmedia/debug", + "description": "small debugging utility", + "version": "2.2.0", + "keywords": [ + "debug", + "log", + "debugger" + ], + "main": "browser.js", + "scripts": [ + "browser.js", + "debug.js" + ], + "dependencies": { + "rauchg/ms.js": "0.7.1" + } +} diff --git a/ui/node_modules/socket.io/node_modules/debug/debug.js b/ui/node_modules/socket.io/node_modules/debug/debug.js index 801b417b..7571a860 100644 --- a/ui/node_modules/socket.io/node_modules/debug/debug.js +++ b/ui/node_modules/socket.io/node_modules/debug/debug.js @@ -1,197 +1,197 @@ - -/** - * This is the common logic for both the Node.js and web browser - * implementations of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = debug; -exports.coerce = coerce; -exports.disable = disable; -exports.enable = enable; -exports.enabled = enabled; -exports.humanize = require('ms'); - -/** - * The currently active debug mode names, and names to skip. - */ - -exports.names = []; -exports.skips = []; - -/** - * Map of special "%n" handling functions, for the debug "format" argument. - * - * Valid key names are a single, lowercased letter, i.e. "n". - */ - -exports.formatters = {}; - -/** - * Previously assigned color. - */ - -var prevColor = 0; - -/** - * Previous log timestamp. - */ - -var prevTime; - -/** - * Select a color. - * - * @return {Number} - * @api private - */ - -function selectColor() { - return exports.colors[prevColor++ % exports.colors.length]; -} - -/** - * Create a debugger with the given `namespace`. - * - * @param {String} namespace - * @return {Function} - * @api public - */ - -function debug(namespace) { - - // define the `disabled` version - function disabled() { - } - disabled.enabled = false; - - // define the `enabled` version - function enabled() { - - var self = enabled; - - // set `diff` timestamp - var curr = +new Date(); - var ms = curr - (prevTime || curr); - self.diff = ms; - self.prev = prevTime; - self.curr = curr; - prevTime = curr; - - // add the `color` if not set - if (null == self.useColors) self.useColors = exports.useColors(); - if (null == self.color && self.useColors) self.color = selectColor(); - - var args = Array.prototype.slice.call(arguments); - - args[0] = exports.coerce(args[0]); - - if ('string' !== typeof args[0]) { - // anything else let's inspect with %o - args = ['%o'].concat(args); - } - - // apply any `formatters` transformations - var index = 0; - args[0] = args[0].replace(/%([a-z%])/g, function(match, format) { - // if we encounter an escaped % then don't increase the array index - if (match === '%%') return match; - index++; - var formatter = exports.formatters[format]; - if ('function' === typeof formatter) { - var val = args[index]; - match = formatter.call(self, val); - - // now we need to remove `args[index]` since it's inlined in the `format` - args.splice(index, 1); - index--; - } - return match; - }); - - if ('function' === typeof exports.formatArgs) { - args = exports.formatArgs.apply(self, args); - } - var logFn = enabled.log || exports.log || console.log.bind(console); - logFn.apply(self, args); - } - enabled.enabled = true; - - var fn = exports.enabled(namespace) ? enabled : disabled; - - fn.namespace = namespace; - - return fn; -} - -/** - * Enables a debug mode by namespaces. This can include modes - * separated by a colon and wildcards. - * - * @param {String} namespaces - * @api public - */ - -function enable(namespaces) { - exports.save(namespaces); - - var split = (namespaces || '').split(/[\s,]+/); - var len = split.length; - - for (var i = 0; i < len; i++) { - if (!split[i]) continue; // ignore empty strings - namespaces = split[i].replace(/\*/g, '.*?'); - if (namespaces[0] === '-') { - exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); - } else { - exports.names.push(new RegExp('^' + namespaces + '$')); - } - } -} - -/** - * Disable debug output. - * - * @api public - */ - -function disable() { - exports.enable(''); -} - -/** - * Returns true if the given mode name is enabled, false otherwise. - * - * @param {String} name - * @return {Boolean} - * @api public - */ - -function enabled(name) { - var i, len; - for (i = 0, len = exports.skips.length; i < len; i++) { - if (exports.skips[i].test(name)) { - return false; - } - } - for (i = 0, len = exports.names.length; i < len; i++) { - if (exports.names[i].test(name)) { - return true; - } - } - return false; -} - -/** - * Coerce `val`. - * - * @param {Mixed} val - * @return {Mixed} - * @api private - */ - -function coerce(val) { - if (val instanceof Error) return val.stack || val.message; - return val; -} + +/** + * This is the common logic for both the Node.js and web browser + * implementations of `debug()`. + * + * Expose `debug()` as the module. + */ + +exports = module.exports = debug; +exports.coerce = coerce; +exports.disable = disable; +exports.enable = enable; +exports.enabled = enabled; +exports.humanize = require('ms'); + +/** + * The currently active debug mode names, and names to skip. + */ + +exports.names = []; +exports.skips = []; + +/** + * Map of special "%n" handling functions, for the debug "format" argument. + * + * Valid key names are a single, lowercased letter, i.e. "n". + */ + +exports.formatters = {}; + +/** + * Previously assigned color. + */ + +var prevColor = 0; + +/** + * Previous log timestamp. + */ + +var prevTime; + +/** + * Select a color. + * + * @return {Number} + * @api private + */ + +function selectColor() { + return exports.colors[prevColor++ % exports.colors.length]; +} + +/** + * Create a debugger with the given `namespace`. + * + * @param {String} namespace + * @return {Function} + * @api public + */ + +function debug(namespace) { + + // define the `disabled` version + function disabled() { + } + disabled.enabled = false; + + // define the `enabled` version + function enabled() { + + var self = enabled; + + // set `diff` timestamp + var curr = +new Date(); + var ms = curr - (prevTime || curr); + self.diff = ms; + self.prev = prevTime; + self.curr = curr; + prevTime = curr; + + // add the `color` if not set + if (null == self.useColors) self.useColors = exports.useColors(); + if (null == self.color && self.useColors) self.color = selectColor(); + + var args = Array.prototype.slice.call(arguments); + + args[0] = exports.coerce(args[0]); + + if ('string' !== typeof args[0]) { + // anything else let's inspect with %o + args = ['%o'].concat(args); + } + + // apply any `formatters` transformations + var index = 0; + args[0] = args[0].replace(/%([a-z%])/g, function(match, format) { + // if we encounter an escaped % then don't increase the array index + if (match === '%%') return match; + index++; + var formatter = exports.formatters[format]; + if ('function' === typeof formatter) { + var val = args[index]; + match = formatter.call(self, val); + + // now we need to remove `args[index]` since it's inlined in the `format` + args.splice(index, 1); + index--; + } + return match; + }); + + if ('function' === typeof exports.formatArgs) { + args = exports.formatArgs.apply(self, args); + } + var logFn = enabled.log || exports.log || console.log.bind(console); + logFn.apply(self, args); + } + enabled.enabled = true; + + var fn = exports.enabled(namespace) ? enabled : disabled; + + fn.namespace = namespace; + + return fn; +} + +/** + * Enables a debug mode by namespaces. This can include modes + * separated by a colon and wildcards. + * + * @param {String} namespaces + * @api public + */ + +function enable(namespaces) { + exports.save(namespaces); + + var split = (namespaces || '').split(/[\s,]+/); + var len = split.length; + + for (var i = 0; i < len; i++) { + if (!split[i]) continue; // ignore empty strings + namespaces = split[i].replace(/\*/g, '.*?'); + if (namespaces[0] === '-') { + exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); + } else { + exports.names.push(new RegExp('^' + namespaces + '$')); + } + } +} + +/** + * Disable debug output. + * + * @api public + */ + +function disable() { + exports.enable(''); +} + +/** + * Returns true if the given mode name is enabled, false otherwise. + * + * @param {String} name + * @return {Boolean} + * @api public + */ + +function enabled(name) { + var i, len; + for (i = 0, len = exports.skips.length; i < len; i++) { + if (exports.skips[i].test(name)) { + return false; + } + } + for (i = 0, len = exports.names.length; i < len; i++) { + if (exports.names[i].test(name)) { + return true; + } + } + return false; +} + +/** + * Coerce `val`. + * + * @param {Mixed} val + * @return {Mixed} + * @api private + */ + +function coerce(val) { + if (val instanceof Error) return val.stack || val.message; + return val; +} diff --git a/ui/node_modules/socket.io/node_modules/debug/node.js b/ui/node_modules/socket.io/node_modules/debug/node.js index b246d603..1d392a81 100644 --- a/ui/node_modules/socket.io/node_modules/debug/node.js +++ b/ui/node_modules/socket.io/node_modules/debug/node.js @@ -1,209 +1,209 @@ - -/** - * Module dependencies. - */ - -var tty = require('tty'); -var util = require('util'); - -/** - * This is the Node.js implementation of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = require('./debug'); -exports.log = log; -exports.formatArgs = formatArgs; -exports.save = save; -exports.load = load; -exports.useColors = useColors; - -/** - * Colors. - */ - -exports.colors = [6, 2, 3, 4, 5, 1]; - -/** - * The file descriptor to write the `debug()` calls to. - * Set the `DEBUG_FD` env variable to override with another value. i.e.: - * - * $ DEBUG_FD=3 node script.js 3>debug.log - */ - -var fd = parseInt(process.env.DEBUG_FD, 10) || 2; -var stream = 1 === fd ? process.stdout : - 2 === fd ? process.stderr : - createWritableStdioStream(fd); - -/** - * Is stdout a TTY? Colored output is enabled when `true`. - */ - -function useColors() { - var debugColors = (process.env.DEBUG_COLORS || '').trim().toLowerCase(); - if (0 === debugColors.length) { - return tty.isatty(fd); - } else { - return '0' !== debugColors - && 'no' !== debugColors - && 'false' !== debugColors - && 'disabled' !== debugColors; - } -} - -/** - * Map %o to `util.inspect()`, since Node doesn't do that out of the box. - */ - -var inspect = (4 === util.inspect.length ? - // node <= 0.8.x - function (v, colors) { - return util.inspect(v, void 0, void 0, colors); - } : - // node > 0.8.x - function (v, colors) { - return util.inspect(v, { colors: colors }); - } -); - -exports.formatters.o = function(v) { - return inspect(v, this.useColors) - .replace(/\s*\n\s*/g, ' '); -}; - -/** - * Adds ANSI color escape codes if enabled. - * - * @api public - */ - -function formatArgs() { - var args = arguments; - var useColors = this.useColors; - var name = this.namespace; - - if (useColors) { - var c = this.color; - - args[0] = ' \u001b[3' + c + ';1m' + name + ' ' - + '\u001b[0m' - + args[0] + '\u001b[3' + c + 'm' - + ' +' + exports.humanize(this.diff) + '\u001b[0m'; - } else { - args[0] = new Date().toUTCString() - + ' ' + name + ' ' + args[0]; - } - return args; -} - -/** - * Invokes `console.error()` with the specified arguments. - */ - -function log() { - return stream.write(util.format.apply(this, arguments) + '\n'); -} - -/** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ - -function save(namespaces) { - if (null == namespaces) { - // If you set a process.env field to null or undefined, it gets cast to the - // string 'null' or 'undefined'. Just delete instead. - delete process.env.DEBUG; - } else { - process.env.DEBUG = namespaces; - } -} - -/** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ - -function load() { - return process.env.DEBUG; -} - -/** - * Copied from `node/src/node.js`. - * - * XXX: It's lame that node doesn't expose this API out-of-the-box. It also - * relies on the undocumented `tty_wrap.guessHandleType()` which is also lame. - */ - -function createWritableStdioStream (fd) { - var stream; - var tty_wrap = process.binding('tty_wrap'); - - // Note stream._type is used for test-module-load-list.js - - switch (tty_wrap.guessHandleType(fd)) { - case 'TTY': - stream = new tty.WriteStream(fd); - stream._type = 'tty'; - - // Hack to have stream not keep the event loop alive. - // See https://github.com/joyent/node/issues/1726 - if (stream._handle && stream._handle.unref) { - stream._handle.unref(); - } - break; - - case 'FILE': - var fs = require('fs'); - stream = new fs.SyncWriteStream(fd, { autoClose: false }); - stream._type = 'fs'; - break; - - case 'PIPE': - case 'TCP': - var net = require('net'); - stream = new net.Socket({ - fd: fd, - readable: false, - writable: true - }); - - // FIXME Should probably have an option in net.Socket to create a - // stream from an existing fd which is writable only. But for now - // we'll just add this hack and set the `readable` member to false. - // Test: ./node test/fixtures/echo.js < /etc/passwd - stream.readable = false; - stream.read = null; - stream._type = 'pipe'; - - // FIXME Hack to have stream not keep the event loop alive. - // See https://github.com/joyent/node/issues/1726 - if (stream._handle && stream._handle.unref) { - stream._handle.unref(); - } - break; - - default: - // Probably an error on in uv_guess_handle() - throw new Error('Implement me. Unknown stream file type!'); - } - - // For supporting legacy API we put the FD here. - stream.fd = fd; - - stream._isStdio = true; - - return stream; -} - -/** - * Enable namespaces listed in `process.env.DEBUG` initially. - */ - -exports.enable(load()); + +/** + * Module dependencies. + */ + +var tty = require('tty'); +var util = require('util'); + +/** + * This is the Node.js implementation of `debug()`. + * + * Expose `debug()` as the module. + */ + +exports = module.exports = require('./debug'); +exports.log = log; +exports.formatArgs = formatArgs; +exports.save = save; +exports.load = load; +exports.useColors = useColors; + +/** + * Colors. + */ + +exports.colors = [6, 2, 3, 4, 5, 1]; + +/** + * The file descriptor to write the `debug()` calls to. + * Set the `DEBUG_FD` env variable to override with another value. i.e.: + * + * $ DEBUG_FD=3 node script.js 3>debug.log + */ + +var fd = parseInt(process.env.DEBUG_FD, 10) || 2; +var stream = 1 === fd ? process.stdout : + 2 === fd ? process.stderr : + createWritableStdioStream(fd); + +/** + * Is stdout a TTY? Colored output is enabled when `true`. + */ + +function useColors() { + var debugColors = (process.env.DEBUG_COLORS || '').trim().toLowerCase(); + if (0 === debugColors.length) { + return tty.isatty(fd); + } else { + return '0' !== debugColors + && 'no' !== debugColors + && 'false' !== debugColors + && 'disabled' !== debugColors; + } +} + +/** + * Map %o to `util.inspect()`, since Node doesn't do that out of the box. + */ + +var inspect = (4 === util.inspect.length ? + // node <= 0.8.x + function (v, colors) { + return util.inspect(v, void 0, void 0, colors); + } : + // node > 0.8.x + function (v, colors) { + return util.inspect(v, { colors: colors }); + } +); + +exports.formatters.o = function(v) { + return inspect(v, this.useColors) + .replace(/\s*\n\s*/g, ' '); +}; + +/** + * Adds ANSI color escape codes if enabled. + * + * @api public + */ + +function formatArgs() { + var args = arguments; + var useColors = this.useColors; + var name = this.namespace; + + if (useColors) { + var c = this.color; + + args[0] = ' \u001b[3' + c + ';1m' + name + ' ' + + '\u001b[0m' + + args[0] + '\u001b[3' + c + 'm' + + ' +' + exports.humanize(this.diff) + '\u001b[0m'; + } else { + args[0] = new Date().toUTCString() + + ' ' + name + ' ' + args[0]; + } + return args; +} + +/** + * Invokes `console.error()` with the specified arguments. + */ + +function log() { + return stream.write(util.format.apply(this, arguments) + '\n'); +} + +/** + * Save `namespaces`. + * + * @param {String} namespaces + * @api private + */ + +function save(namespaces) { + if (null == namespaces) { + // If you set a process.env field to null or undefined, it gets cast to the + // string 'null' or 'undefined'. Just delete instead. + delete process.env.DEBUG; + } else { + process.env.DEBUG = namespaces; + } +} + +/** + * Load `namespaces`. + * + * @return {String} returns the previously persisted debug modes + * @api private + */ + +function load() { + return process.env.DEBUG; +} + +/** + * Copied from `node/src/node.js`. + * + * XXX: It's lame that node doesn't expose this API out-of-the-box. It also + * relies on the undocumented `tty_wrap.guessHandleType()` which is also lame. + */ + +function createWritableStdioStream (fd) { + var stream; + var tty_wrap = process.binding('tty_wrap'); + + // Note stream._type is used for test-module-load-list.js + + switch (tty_wrap.guessHandleType(fd)) { + case 'TTY': + stream = new tty.WriteStream(fd); + stream._type = 'tty'; + + // Hack to have stream not keep the event loop alive. + // See https://github.com/joyent/node/issues/1726 + if (stream._handle && stream._handle.unref) { + stream._handle.unref(); + } + break; + + case 'FILE': + var fs = require('fs'); + stream = new fs.SyncWriteStream(fd, { autoClose: false }); + stream._type = 'fs'; + break; + + case 'PIPE': + case 'TCP': + var net = require('net'); + stream = new net.Socket({ + fd: fd, + readable: false, + writable: true + }); + + // FIXME Should probably have an option in net.Socket to create a + // stream from an existing fd which is writable only. But for now + // we'll just add this hack and set the `readable` member to false. + // Test: ./node test/fixtures/echo.js < /etc/passwd + stream.readable = false; + stream.read = null; + stream._type = 'pipe'; + + // FIXME Hack to have stream not keep the event loop alive. + // See https://github.com/joyent/node/issues/1726 + if (stream._handle && stream._handle.unref) { + stream._handle.unref(); + } + break; + + default: + // Probably an error on in uv_guess_handle() + throw new Error('Implement me. Unknown stream file type!'); + } + + // For supporting legacy API we put the FD here. + stream.fd = fd; + + stream._isStdio = true; + + return stream; +} + +/** + * Enable namespaces listed in `process.env.DEBUG` initially. + */ + +exports.enable(load()); diff --git a/ui/node_modules/socket.io/node_modules/debug/node_modules/ms/.npmignore b/ui/node_modules/socket.io/node_modules/debug/node_modules/ms/.npmignore index 93216885..d1aa0ce4 100644 --- a/ui/node_modules/socket.io/node_modules/debug/node_modules/ms/.npmignore +++ b/ui/node_modules/socket.io/node_modules/debug/node_modules/ms/.npmignore @@ -1,5 +1,5 @@ -node_modules -test -History.md -Makefile -component.json +node_modules +test +History.md +Makefile +component.json diff --git a/ui/node_modules/socket.io/node_modules/debug/node_modules/ms/History.md b/ui/node_modules/socket.io/node_modules/debug/node_modules/ms/History.md index c9715f87..32fdfc17 100644 --- a/ui/node_modules/socket.io/node_modules/debug/node_modules/ms/History.md +++ b/ui/node_modules/socket.io/node_modules/debug/node_modules/ms/History.md @@ -1,66 +1,66 @@ - -0.7.1 / 2015-04-20 -================== - - * prevent extraordinary long inputs (@evilpacket) - * Fixed broken readme link - -0.7.0 / 2014-11-24 -================== - - * add time abbreviations, updated tests and readme for the new units - * fix example in the readme. - * add LICENSE file - -0.6.2 / 2013-12-05 -================== - - * Adding repository section to package.json to suppress warning from NPM. - -0.6.1 / 2013-05-10 -================== - - * fix singularization [visionmedia] - -0.6.0 / 2013-03-15 -================== - - * fix minutes - -0.5.1 / 2013-02-24 -================== - - * add component namespace - -0.5.0 / 2012-11-09 -================== - - * add short formatting as default and .long option - * add .license property to component.json - * add version to component.json - -0.4.0 / 2012-10-22 -================== - - * add rounding to fix crazy decimals - -0.3.0 / 2012-09-07 -================== - - * fix `ms()` [visionmedia] - -0.2.0 / 2012-09-03 -================== - - * add component.json [visionmedia] - * add days support [visionmedia] - * add hours support [visionmedia] - * add minutes support [visionmedia] - * add seconds support [visionmedia] - * add ms string support [visionmedia] - * refactor tests to facilitate ms(number) [visionmedia] - -0.1.0 / 2012-03-07 -================== - - * Initial release + +0.7.1 / 2015-04-20 +================== + + * prevent extraordinary long inputs (@evilpacket) + * Fixed broken readme link + +0.7.0 / 2014-11-24 +================== + + * add time abbreviations, updated tests and readme for the new units + * fix example in the readme. + * add LICENSE file + +0.6.2 / 2013-12-05 +================== + + * Adding repository section to package.json to suppress warning from NPM. + +0.6.1 / 2013-05-10 +================== + + * fix singularization [visionmedia] + +0.6.0 / 2013-03-15 +================== + + * fix minutes + +0.5.1 / 2013-02-24 +================== + + * add component namespace + +0.5.0 / 2012-11-09 +================== + + * add short formatting as default and .long option + * add .license property to component.json + * add version to component.json + +0.4.0 / 2012-10-22 +================== + + * add rounding to fix crazy decimals + +0.3.0 / 2012-09-07 +================== + + * fix `ms()` [visionmedia] + +0.2.0 / 2012-09-03 +================== + + * add component.json [visionmedia] + * add days support [visionmedia] + * add hours support [visionmedia] + * add minutes support [visionmedia] + * add seconds support [visionmedia] + * add ms string support [visionmedia] + * refactor tests to facilitate ms(number) [visionmedia] + +0.1.0 / 2012-03-07 +================== + + * Initial release diff --git a/ui/node_modules/socket.io/node_modules/debug/node_modules/ms/LICENSE b/ui/node_modules/socket.io/node_modules/debug/node_modules/ms/LICENSE index 5b078ede..6c07561b 100644 --- a/ui/node_modules/socket.io/node_modules/debug/node_modules/ms/LICENSE +++ b/ui/node_modules/socket.io/node_modules/debug/node_modules/ms/LICENSE @@ -1,20 +1,20 @@ -(The MIT License) - -Copyright (c) 2014 Guillermo Rauch - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2014 Guillermo Rauch + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/socket.io/node_modules/debug/node_modules/ms/README.md b/ui/node_modules/socket.io/node_modules/debug/node_modules/ms/README.md index 7e3e27f9..9b4fd035 100644 --- a/ui/node_modules/socket.io/node_modules/debug/node_modules/ms/README.md +++ b/ui/node_modules/socket.io/node_modules/debug/node_modules/ms/README.md @@ -1,35 +1,35 @@ -# ms.js: miliseconds conversion utility - -```js -ms('2 days') // 172800000 -ms('1d') // 86400000 -ms('10h') // 36000000 -ms('2.5 hrs') // 9000000 -ms('2h') // 7200000 -ms('1m') // 60000 -ms('5s') // 5000 -ms('100') // 100 -``` - -```js -ms(60000) // "1m" -ms(2 * 60000) // "2m" -ms(ms('10 hours')) // "10h" -``` - -```js -ms(60000, { long: true }) // "1 minute" -ms(2 * 60000, { long: true }) // "2 minutes" -ms(ms('10 hours'), { long: true }) // "10 hours" -``` - -- Node/Browser compatible. Published as [`ms`](https://www.npmjs.org/package/ms) in [NPM](http://nodejs.org/download). -- If a number is supplied to `ms`, a string with a unit is returned. -- If a string that contains the number is supplied, it returns it as -a number (e.g: it returns `100` for `'100'`). -- If you pass a string with a number and a valid unit, the number of -equivalent ms is returned. - -## License - -MIT +# ms.js: miliseconds conversion utility + +```js +ms('2 days') // 172800000 +ms('1d') // 86400000 +ms('10h') // 36000000 +ms('2.5 hrs') // 9000000 +ms('2h') // 7200000 +ms('1m') // 60000 +ms('5s') // 5000 +ms('100') // 100 +``` + +```js +ms(60000) // "1m" +ms(2 * 60000) // "2m" +ms(ms('10 hours')) // "10h" +``` + +```js +ms(60000, { long: true }) // "1 minute" +ms(2 * 60000, { long: true }) // "2 minutes" +ms(ms('10 hours'), { long: true }) // "10 hours" +``` + +- Node/Browser compatible. Published as [`ms`](https://www.npmjs.org/package/ms) in [NPM](http://nodejs.org/download). +- If a number is supplied to `ms`, a string with a unit is returned. +- If a string that contains the number is supplied, it returns it as +a number (e.g: it returns `100` for `'100'`). +- If you pass a string with a number and a valid unit, the number of +equivalent ms is returned. + +## License + +MIT diff --git a/ui/node_modules/socket.io/node_modules/debug/node_modules/ms/index.js b/ui/node_modules/socket.io/node_modules/debug/node_modules/ms/index.js index dd9a4607..4f927716 100644 --- a/ui/node_modules/socket.io/node_modules/debug/node_modules/ms/index.js +++ b/ui/node_modules/socket.io/node_modules/debug/node_modules/ms/index.js @@ -1,125 +1,125 @@ -/** - * Helpers. - */ - -var s = 1000; -var m = s * 60; -var h = m * 60; -var d = h * 24; -var y = d * 365.25; - -/** - * Parse or format the given `val`. - * - * Options: - * - * - `long` verbose formatting [false] - * - * @param {String|Number} val - * @param {Object} options - * @return {String|Number} - * @api public - */ - -module.exports = function(val, options){ - options = options || {}; - if ('string' == typeof val) return parse(val); - return options.long - ? long(val) - : short(val); -}; - -/** - * Parse the given `str` and return milliseconds. - * - * @param {String} str - * @return {Number} - * @api private - */ - -function parse(str) { - str = '' + str; - if (str.length > 10000) return; - var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str); - if (!match) return; - var n = parseFloat(match[1]); - var type = (match[2] || 'ms').toLowerCase(); - switch (type) { - case 'years': - case 'year': - case 'yrs': - case 'yr': - case 'y': - return n * y; - case 'days': - case 'day': - case 'd': - return n * d; - case 'hours': - case 'hour': - case 'hrs': - case 'hr': - case 'h': - return n * h; - case 'minutes': - case 'minute': - case 'mins': - case 'min': - case 'm': - return n * m; - case 'seconds': - case 'second': - case 'secs': - case 'sec': - case 's': - return n * s; - case 'milliseconds': - case 'millisecond': - case 'msecs': - case 'msec': - case 'ms': - return n; - } -} - -/** - * Short format for `ms`. - * - * @param {Number} ms - * @return {String} - * @api private - */ - -function short(ms) { - if (ms >= d) return Math.round(ms / d) + 'd'; - if (ms >= h) return Math.round(ms / h) + 'h'; - if (ms >= m) return Math.round(ms / m) + 'm'; - if (ms >= s) return Math.round(ms / s) + 's'; - return ms + 'ms'; -} - -/** - * Long format for `ms`. - * - * @param {Number} ms - * @return {String} - * @api private - */ - -function long(ms) { - return plural(ms, d, 'day') - || plural(ms, h, 'hour') - || plural(ms, m, 'minute') - || plural(ms, s, 'second') - || ms + ' ms'; -} - -/** - * Pluralization helper. - */ - -function plural(ms, n, name) { - if (ms < n) return; - if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name; - return Math.ceil(ms / n) + ' ' + name + 's'; -} +/** + * Helpers. + */ + +var s = 1000; +var m = s * 60; +var h = m * 60; +var d = h * 24; +var y = d * 365.25; + +/** + * Parse or format the given `val`. + * + * Options: + * + * - `long` verbose formatting [false] + * + * @param {String|Number} val + * @param {Object} options + * @return {String|Number} + * @api public + */ + +module.exports = function(val, options){ + options = options || {}; + if ('string' == typeof val) return parse(val); + return options.long + ? long(val) + : short(val); +}; + +/** + * Parse the given `str` and return milliseconds. + * + * @param {String} str + * @return {Number} + * @api private + */ + +function parse(str) { + str = '' + str; + if (str.length > 10000) return; + var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str); + if (!match) return; + var n = parseFloat(match[1]); + var type = (match[2] || 'ms').toLowerCase(); + switch (type) { + case 'years': + case 'year': + case 'yrs': + case 'yr': + case 'y': + return n * y; + case 'days': + case 'day': + case 'd': + return n * d; + case 'hours': + case 'hour': + case 'hrs': + case 'hr': + case 'h': + return n * h; + case 'minutes': + case 'minute': + case 'mins': + case 'min': + case 'm': + return n * m; + case 'seconds': + case 'second': + case 'secs': + case 'sec': + case 's': + return n * s; + case 'milliseconds': + case 'millisecond': + case 'msecs': + case 'msec': + case 'ms': + return n; + } +} + +/** + * Short format for `ms`. + * + * @param {Number} ms + * @return {String} + * @api private + */ + +function short(ms) { + if (ms >= d) return Math.round(ms / d) + 'd'; + if (ms >= h) return Math.round(ms / h) + 'h'; + if (ms >= m) return Math.round(ms / m) + 'm'; + if (ms >= s) return Math.round(ms / s) + 's'; + return ms + 'ms'; +} + +/** + * Long format for `ms`. + * + * @param {Number} ms + * @return {String} + * @api private + */ + +function long(ms) { + return plural(ms, d, 'day') + || plural(ms, h, 'hour') + || plural(ms, m, 'minute') + || plural(ms, s, 'second') + || ms + ' ms'; +} + +/** + * Pluralization helper. + */ + +function plural(ms, n, name) { + if (ms < n) return; + if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name; + return Math.ceil(ms / n) + ' ' + name + 's'; +} diff --git a/ui/node_modules/socket.io/node_modules/debug/node_modules/ms/package.json b/ui/node_modules/socket.io/node_modules/debug/node_modules/ms/package.json index 5a896a3a..e36489ef 100644 --- a/ui/node_modules/socket.io/node_modules/debug/node_modules/ms/package.json +++ b/ui/node_modules/socket.io/node_modules/debug/node_modules/ms/package.json @@ -1,48 +1,48 @@ -{ - "name": "ms", - "version": "0.7.1", - "description": "Tiny ms conversion utility", - "repository": { - "type": "git", - "url": "git://github.com/guille/ms.js.git" - }, - "main": "./index", - "devDependencies": { - "mocha": "*", - "expect.js": "*", - "serve": "*" - }, - "component": { - "scripts": { - "ms/index.js": "index.js" - } - }, - "gitHead": "713dcf26d9e6fd9dbc95affe7eff9783b7f1b909", - "bugs": { - "url": "https://github.com/guille/ms.js/issues" - }, - "homepage": "https://github.com/guille/ms.js", - "_id": "ms@0.7.1", - "scripts": {}, - "_shasum": "9cd13c03adbff25b65effde7ce864ee952017098", - "_from": "ms@0.7.1", - "_npmVersion": "2.7.5", - "_nodeVersion": "0.12.2", - "_npmUser": { - "name": "rauchg", - "email": "rauchg@gmail.com" - }, - "maintainers": [ - { - "name": "rauchg", - "email": "rauchg@gmail.com" - } - ], - "dist": { - "shasum": "9cd13c03adbff25b65effde7ce864ee952017098", - "tarball": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "ms", + "version": "0.7.1", + "description": "Tiny ms conversion utility", + "repository": { + "type": "git", + "url": "git://github.com/guille/ms.js.git" + }, + "main": "./index", + "devDependencies": { + "mocha": "*", + "expect.js": "*", + "serve": "*" + }, + "component": { + "scripts": { + "ms/index.js": "index.js" + } + }, + "gitHead": "713dcf26d9e6fd9dbc95affe7eff9783b7f1b909", + "bugs": { + "url": "https://github.com/guille/ms.js/issues" + }, + "homepage": "https://github.com/guille/ms.js", + "_id": "ms@0.7.1", + "scripts": {}, + "_shasum": "9cd13c03adbff25b65effde7ce864ee952017098", + "_from": "ms@0.7.1", + "_npmVersion": "2.7.5", + "_nodeVersion": "0.12.2", + "_npmUser": { + "name": "rauchg", + "email": "rauchg@gmail.com" + }, + "maintainers": [ + { + "name": "rauchg", + "email": "rauchg@gmail.com" + } + ], + "dist": { + "shasum": "9cd13c03adbff25b65effde7ce864ee952017098", + "tarball": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/socket.io/node_modules/debug/package.json b/ui/node_modules/socket.io/node_modules/debug/package.json index 4115ccaa..46ce4c53 100644 --- a/ui/node_modules/socket.io/node_modules/debug/package.json +++ b/ui/node_modules/socket.io/node_modules/debug/package.json @@ -1,73 +1,73 @@ -{ - "name": "debug", - "version": "2.2.0", - "repository": { - "type": "git", - "url": "git://github.com/visionmedia/debug.git" - }, - "description": "small debugging utility", - "keywords": [ - "debug", - "log", - "debugger" - ], - "author": { - "name": "TJ Holowaychuk", - "email": "tj@vision-media.ca" - }, - "contributors": [ - { - "name": "Nathan Rajlich", - "email": "nathan@tootallnate.net", - "url": "http://n8.io" - } - ], - "license": "MIT", - "dependencies": { - "ms": "0.7.1" - }, - "devDependencies": { - "browserify": "9.0.3", - "mocha": "*" - }, - "main": "./node.js", - "browser": "./browser.js", - "component": { - "scripts": { - "debug/index.js": "browser.js", - "debug/debug.js": "debug.js" - } - }, - "gitHead": "b38458422b5aa8aa6d286b10dfe427e8a67e2b35", - "bugs": { - "url": "https://github.com/visionmedia/debug/issues" - }, - "homepage": "https://github.com/visionmedia/debug", - "_id": "debug@2.2.0", - "scripts": {}, - "_shasum": "f87057e995b1a1f6ae6a4960664137bc56f039da", - "_from": "debug@2.2.0", - "_npmVersion": "2.7.4", - "_nodeVersion": "0.12.2", - "_npmUser": { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - }, - "maintainers": [ - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - } - ], - "dist": { - "shasum": "f87057e995b1a1f6ae6a4960664137bc56f039da", - "tarball": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "debug", + "version": "2.2.0", + "repository": { + "type": "git", + "url": "git://github.com/visionmedia/debug.git" + }, + "description": "small debugging utility", + "keywords": [ + "debug", + "log", + "debugger" + ], + "author": { + "name": "TJ Holowaychuk", + "email": "tj@vision-media.ca" + }, + "contributors": [ + { + "name": "Nathan Rajlich", + "email": "nathan@tootallnate.net", + "url": "http://n8.io" + } + ], + "license": "MIT", + "dependencies": { + "ms": "0.7.1" + }, + "devDependencies": { + "browserify": "9.0.3", + "mocha": "*" + }, + "main": "./node.js", + "browser": "./browser.js", + "component": { + "scripts": { + "debug/index.js": "browser.js", + "debug/debug.js": "debug.js" + } + }, + "gitHead": "b38458422b5aa8aa6d286b10dfe427e8a67e2b35", + "bugs": { + "url": "https://github.com/visionmedia/debug/issues" + }, + "homepage": "https://github.com/visionmedia/debug", + "_id": "debug@2.2.0", + "scripts": {}, + "_shasum": "f87057e995b1a1f6ae6a4960664137bc56f039da", + "_from": "debug@2.2.0", + "_npmVersion": "2.7.4", + "_nodeVersion": "0.12.2", + "_npmUser": { + "name": "tootallnate", + "email": "nathan@tootallnate.net" + }, + "maintainers": [ + { + "name": "tjholowaychuk", + "email": "tj@vision-media.ca" + }, + { + "name": "tootallnate", + "email": "nathan@tootallnate.net" + } + ], + "dist": { + "shasum": "f87057e995b1a1f6ae6a4960664137bc56f039da", + "tarball": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/socket.io/node_modules/engine.io/.npmignore b/ui/node_modules/socket.io/node_modules/engine.io/.npmignore index abb1d923..f09f6306 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/.npmignore +++ b/ui/node_modules/socket.io/node_modules/engine.io/.npmignore @@ -1,6 +1,6 @@ -examples -node_modules -test -npm-debug.log -coverage.html -.gitignore +examples +node_modules +test +npm-debug.log +coverage.html +.gitignore diff --git a/ui/node_modules/socket.io/node_modules/engine.io/.travis.yml b/ui/node_modules/socket.io/node_modules/engine.io/.travis.yml index e0c5ee10..148075d8 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/.travis.yml +++ b/ui/node_modules/socket.io/node_modules/engine.io/.travis.yml @@ -1,10 +1,10 @@ -sudo: false -language: node_js -node_js: - - "0.8" - - "0.10" - - "0.12" - - "4.0.0" - -notifications: - irc: "irc.freenode.org#socket.io" +sudo: false +language: node_js +node_js: + - "0.8" + - "0.10" + - "0.12" + - "4.0.0" + +notifications: + irc: "irc.freenode.org#socket.io" diff --git a/ui/node_modules/socket.io/node_modules/engine.io/History.md b/ui/node_modules/socket.io/node_modules/engine.io/History.md index 1b50d008..31d1e3ed 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/History.md +++ b/ui/node_modules/socket.io/node_modules/engine.io/History.md @@ -1,501 +1,501 @@ - -1.6.11 / 2016-06-23 -=================== - - * package: bump `ws` to support `maxPayload` - -1.6.10 / 2016-06-23 -=================== - - * set a default ws `maxPayload` [security fix] - * bump `accepts` [security fix] - -1.6.9 / 2016-05-03 -================== - - * bump client - -1.6.8 / 2016-01-25 -================== - - * fix graceful close [nkzawa] - * polling: don't set the `closeTimeoutTimer` if the transport is upgraded - -1.6.7 / 2016-01-10 -================== - - * bump version - -1.6.6 / 2016-01-07 -================== - - * bump version - -1.6.5 / 2016-01-05 -================== - - * package: upgrade ws for sec advisory - * server: catch websocket errors before upgrade - -1.6.4 / 2015-12-04 -================== - - * package: bump parser for arraybuffer base64 fix - -1.6.3 / 2015-12-01 -================== - - * restore testing on 0.8 - * improve X-XSS-Protection header definition [nkzawa] - * add threshold for permessage-deflate [nkzawa] - -1.6.2 / 2015-11-30 -================== - - * don't compress control packets - -1.6.1 / 2015-11-28 -================== - - * package: bump `engine.io-client` for `ws` options fix - * fix `latency` example - -1.6.0 / 2015-11-28 -================== - - * add support for environments that extend `Object.prototype` - * remove listeners upon `clearTransport` - * support for all versions of node - * fix lingering sockets that can stay open when upgrade failed - * ensure sockets are closed on error - * bump `ws` for several improvements - * fix for a rare race condition on some error scenarios - * support custom socket id - * use container-based infrastructure for faster build - * fix package.json wrongly referrering to self - * allow overriding the `cookiePath` - * fix potential encoding errors under certain conditions - * support compression - -1.5.4 / 2015-09-09 -================== - - * package: bump `engine.io-parser` - -1.5.3 / 2015-09-09 -================== - - * package: bump `ws` to fix node 4.0.0 - -1.5.2 / 2015-07-09 -================== - - * package: bump `ws` to fix build issues - -1.5.1 / 2015-01-19 -================== - - * no change on this release - * package: bump `engine.io-client` - -1.5.0 / 2015-01-18 -================== - - * package: bump `engine.io-parser` - * polling: correctly abort the ongoing data request when closing [lpinca] - * add cert-related client tests [rase-] - -1.4.3 / 2014-11-21 -================== - - * package: bump `ws` to fix fd leaks - * socket: flush the write buffer before closing the socket [lpinca] - * polling: close the pending poll request when closing transport [lpinca] - -1.4.2 / 2014-10-08 -================== - - * add iframe onload handling to jsonp tests [rase-] - -1.4.1 / 2014-10-03 -================== - - * socket: allow upgrades if the socket is still in closing state - * README: fix typo - -1.4.0 / 2014-09-03 -================== - - * readme: fix formatting for goals numbering - * server: ref fix by @nicokaiser - * server: fix ws memory leak (fixes #268) - * cache remote address in handshake since it might be lost later. - * correct git ref - * update client to commit with bumped parser - * package: bump parser - * npmignore: ignore `.gitignore` - * package: bump `debug` - * package: bump `engine.io-parser` for memleak fix - -1.3.1 / 2014-06-19 -================== - - * package: bump `engine.io-client` - -1.3.0 / 2014-06-13 -================== - - * update example to use v1.2.2 - * fixed newline parsing in jsonp - * make require('engine.io')() return a new Server instance [defunctzombie] - * add Server.attach method [defunctzombie] - * fix GH-211, set CORS headers when sending error message [mokesmokes] - -1.2.2 / 2014-05-30 -================== - - * package: bump `engine.io-parser` for binary utf8 fix - -1.2.1 / 2014-05-22 -================== - - * package: bump engine.io-client - -1.2.0 / 2014-05-18 -================== - - * removed flashsocket, moving to userland - -1.1.1 / 2014-05-14 -================== - - * test: reduce packet size - * package: bump parser - -1.1.0 / 2014-04-27 -================== - - * socket: removed unneeded `clearTimeout` (fixes #250) - * made the request verification process async - * package: bump `engine.io-parser` - * use _query instead of query, fixes compat with restify - * added a maximum buffer size to received data from polling - * fixing looping array via for in to normal loop - -1.0.5 / 2014-03-18 -================== - - * package: bump `engine.io-parser` and `engine.io-client` - -1.0.4 / 2014-03-14 -================== - - * package: bump `engine.io-client` - -1.0.3 / 2014-03-12 -================== - - * package: bump `engine.io-client` - -1.0.2 / 2014-03-12 -================== - - * bump engine.io-client - -1.0.1 / 2014-03-06 -================== - - * package: bump `engine.io-parser` - * transports: fix jshint warnings and style - -1.0.0 / 2014-03-06 -================== - - * polling-xhr: added `OPTIONS` support, fixes CORS - * close() properly when triggered in connection handler - * fix DDOS vector by setting up too many intervals - * binary support - -0.9.0 / 2014-02-09 -================== - - * Prevent errors with connections behind proxies without WS support - like Squid [nicklagrow, samaanghani, davidhcummings] - * Socket#request a simple property [mokesmokes] - * Changed `Socket`'s `upgrade` event to happen after upgrade [mokesmokes] - * Document `Socket#id` [mokesmokes] - -0.8.2 / 2014-01-18 -================== - - * package: bump `engine.io-client` - -0.8.1 / 2014-01-17 -================== - - * package: bump `engine.io-client` - * package: pin dev deps - * examples: fix port output - * fix latency example - -0.8.0 / 2014-01-05 -================== - - * package: bump `engine.io-client` to `0.8.0` - * test: fix syntax, remove globals - -0.7.14 / 2014-01-01 -=================== - - * package: bump `engine.io-client` to `0.7.14` - -0.7.13 / 2013-12-20 -=================== - - * package: bump `engine.io-client` - * transports: added support for XSS filters on IE [guille, 3rd-eden] - -0.7.12 / 2013-11-11 -=================== - - * package: bump `engine.io-client` - -0.7.11 / 2013-11-06 -=================== - - * package: bump engine.io-client - * fix GH-198 - -0.7.10 / 2013-10-28 -=================== - - * package: bump `engine.io-client` - * package: update "ws" to v0.4.31 - -0.7.9 / 2013-08-30 -================== - - * package: bump `engine.io-client` - -0.7.8 / 2013-08-30 -================== - - * package: bump `engine.io-client` - * package: bump ws - -0.7.7 / 2013-08-30 -================== - - * package: bump `engine.io-client` - -0.7.6 / 2013-08-30 -================== - - * package: bump engine.io-client - -0.7.5 / 2013-08-30 -================== - - * package: bump engine.io-client - -0.7.4 / 2013-08-25 -================== - - * package: bump `engine.io-client` - -0.7.3 / 2013-08-23 -================== - - * package: bump engine.io-client (noop) - * package: fix regresison in upgrade cause by ws update - -0.7.2 / 2013-08-23 -================== - - * package: bump `engine.io-client` for `WebSocket` browser fix - -0.7.1 / 2013-08-23 -================== - - * package: bump engine.io-client for ws fix - -0.7.0 / 2013-08-23 -================== - - * package: bump engine.io-client - * updated example - * inline merge - * added support node version 0.10 to .travis.yml - * fixed respond to flash policy request test. Closes #184 - * fixed upgrade with timeout test. Closes #185 - * engine.io: don't use __proto__, closes #170 - -0.6.3 / 2013-06-21 -================== - - * package: bumped `engine.io-client` to `0.6.3` - -0.6.2 / 2013-06-15 -================== - - * fix upgrade stalling edge case introduced with #174 fix - * remove unneeded client code related to iOS - * added test for `engine.io-client` `0.6.1` - -0.6.1 / 2013-06-06 -================== - - * package: bumped `engine.io-client` to `0.6.1` - -0.6.0 / 2013-05-31 -================== - - * socket: clear timer after sending one noop packet (fixes #174) - * clear all timers on socket close - * sending error on transport creation upon a bad request - * added test for client-side buffer cleanup - * changed flushComplete to flush - * ended support for node 0.6 - -0.5.0 / 2013-03-16 -================== - - * polling: implemented new parser - * test writeBuffer isn't cleared onError, removed 'closing' check in .flush() - * fixed bug89 and added tests: writeBuffer not flushed until nextTick - -0.4.3 / 2013-02-08 -================== - - * package: bumped `engine.io-client` to `0.4.3` - -0.4.2 / 2013-02-08 -================== - - * Only end upgrade socket connections if unhandled - * Fix websocket dependency - * Close socket if upgrade is received and socket.readyState != open - -0.4.1 / 2013-01-18 -================== - - * package: bumped versions - * Fixed bugs in previous send callback fix and updated test cases - * Added a test case which makes the code before the send callback fix fail - * socket: emit `data` event (synonym with `message`) - * socket: added `Socket#write` - * engine.io: cleanup - * engine.io: deprecated `resource` - * `npm docs engine.io` works now - -0.3.10 / 2012-12-03 -=================== - - * package: bumped `engine.io-client` with `close` fixes - * add packetCreate event [jxck] - * add packet event to socket [jxck] - * transport: remove `Connection` headers and let node handle it - * server: send validation failure reason to clients - * engine: invoking as a function causes attach - * socket: reset `writeBuffer` before send - -0.3.9 / 2012-10-23 -================== - - * package: bumped `engine.io-client` - -0.3.8 / 2012-10-23 -================== - - * package: bumped engine.io-client - * examples: added first example - -0.3.7 / 2012-10-21 -================== - - * package: bumped `engine.io-client` - -0.3.6 / 2012-10-21 -================== - - [skipped] - -0.3.5 / 2012-10-14 -================== - - * package: reverted last commit - we use the parser from the client - -0.3.4 / 2012-10-14 -================== - - * package: `engine.io-client` moved to `devDependencies` - * socket: added missing jsdoc - -0.3.3 / 2012-10-10 -================== - - * socket: fixed check interval clearing [joewalnes] - * transports: improved instrumentation - -0.3.2 / 2012-10-08 -================== - - * socket: improve check interval for upgrade - -0.3.1 / 2012-10-08 -================== - - * socket: faster upgrades (we perform a check immediately) - * server: don't assume sid is numeric - -0.3.0 / 2012-10-04 -================== - - * socket: `writeBuffer` now gets sliced, and is recoverable after `close` [afshinm] - * server: expect ping from client and send interval with handshake [cadorn] - * polling-jsonp: prevent client breakage with utf8 whitespace - * socket: fix `flush` and `drain` events - * socket: add `send` callback [afshinm] - * transport: avoid unhandled error events for stale transports - * README: documentation improvements [EugenDueck] - -0.2.2 / 2012-08-26 -================== - - * server: remove buffering for flash policy requests - * transport: avoid unhandled error events for stale transports (fixes #69) - * readme: documented `toString` behavior on `send` [EugenDueck] - -0.2.1 / 2012-08-13 -================== - - * polling-xhr: skip Keep-Alive when it's implied [EugenDueck] - * polling-jsonp: skip Keep-Alive when it's implied [EugenDueck] - * README: added plugins list with engine.io-conflation - * socket: added flush/drain events (fixes #56) - * server: avoid passing websocket to non-websocket transports (fixes #24) - -0.2.0 / 2012-08-06 -================== - - * Bumped client - * test: added closing connection test - * server: implemented stronger id generator with collision detection - -0.1.2 / 2012-08-02 -================== - - * Fixed a jsonp bug in Nokia mobile phones and potentially other UAs. - -0.1.1 / 2012-08-01 -================== - - * Fixed errors when a socket is closed while upgrade probe is happening. - * Improved WS error handling - * Replaced websocket.io with ws, now that it supports older drafts - * README fixes - -0.1.0 / 2012-07-03 -================== - - * Initial release. + +1.6.11 / 2016-06-23 +=================== + + * package: bump `ws` to support `maxPayload` + +1.6.10 / 2016-06-23 +=================== + + * set a default ws `maxPayload` [security fix] + * bump `accepts` [security fix] + +1.6.9 / 2016-05-03 +================== + + * bump client + +1.6.8 / 2016-01-25 +================== + + * fix graceful close [nkzawa] + * polling: don't set the `closeTimeoutTimer` if the transport is upgraded + +1.6.7 / 2016-01-10 +================== + + * bump version + +1.6.6 / 2016-01-07 +================== + + * bump version + +1.6.5 / 2016-01-05 +================== + + * package: upgrade ws for sec advisory + * server: catch websocket errors before upgrade + +1.6.4 / 2015-12-04 +================== + + * package: bump parser for arraybuffer base64 fix + +1.6.3 / 2015-12-01 +================== + + * restore testing on 0.8 + * improve X-XSS-Protection header definition [nkzawa] + * add threshold for permessage-deflate [nkzawa] + +1.6.2 / 2015-11-30 +================== + + * don't compress control packets + +1.6.1 / 2015-11-28 +================== + + * package: bump `engine.io-client` for `ws` options fix + * fix `latency` example + +1.6.0 / 2015-11-28 +================== + + * add support for environments that extend `Object.prototype` + * remove listeners upon `clearTransport` + * support for all versions of node + * fix lingering sockets that can stay open when upgrade failed + * ensure sockets are closed on error + * bump `ws` for several improvements + * fix for a rare race condition on some error scenarios + * support custom socket id + * use container-based infrastructure for faster build + * fix package.json wrongly referrering to self + * allow overriding the `cookiePath` + * fix potential encoding errors under certain conditions + * support compression + +1.5.4 / 2015-09-09 +================== + + * package: bump `engine.io-parser` + +1.5.3 / 2015-09-09 +================== + + * package: bump `ws` to fix node 4.0.0 + +1.5.2 / 2015-07-09 +================== + + * package: bump `ws` to fix build issues + +1.5.1 / 2015-01-19 +================== + + * no change on this release + * package: bump `engine.io-client` + +1.5.0 / 2015-01-18 +================== + + * package: bump `engine.io-parser` + * polling: correctly abort the ongoing data request when closing [lpinca] + * add cert-related client tests [rase-] + +1.4.3 / 2014-11-21 +================== + + * package: bump `ws` to fix fd leaks + * socket: flush the write buffer before closing the socket [lpinca] + * polling: close the pending poll request when closing transport [lpinca] + +1.4.2 / 2014-10-08 +================== + + * add iframe onload handling to jsonp tests [rase-] + +1.4.1 / 2014-10-03 +================== + + * socket: allow upgrades if the socket is still in closing state + * README: fix typo + +1.4.0 / 2014-09-03 +================== + + * readme: fix formatting for goals numbering + * server: ref fix by @nicokaiser + * server: fix ws memory leak (fixes #268) + * cache remote address in handshake since it might be lost later. + * correct git ref + * update client to commit with bumped parser + * package: bump parser + * npmignore: ignore `.gitignore` + * package: bump `debug` + * package: bump `engine.io-parser` for memleak fix + +1.3.1 / 2014-06-19 +================== + + * package: bump `engine.io-client` + +1.3.0 / 2014-06-13 +================== + + * update example to use v1.2.2 + * fixed newline parsing in jsonp + * make require('engine.io')() return a new Server instance [defunctzombie] + * add Server.attach method [defunctzombie] + * fix GH-211, set CORS headers when sending error message [mokesmokes] + +1.2.2 / 2014-05-30 +================== + + * package: bump `engine.io-parser` for binary utf8 fix + +1.2.1 / 2014-05-22 +================== + + * package: bump engine.io-client + +1.2.0 / 2014-05-18 +================== + + * removed flashsocket, moving to userland + +1.1.1 / 2014-05-14 +================== + + * test: reduce packet size + * package: bump parser + +1.1.0 / 2014-04-27 +================== + + * socket: removed unneeded `clearTimeout` (fixes #250) + * made the request verification process async + * package: bump `engine.io-parser` + * use _query instead of query, fixes compat with restify + * added a maximum buffer size to received data from polling + * fixing looping array via for in to normal loop + +1.0.5 / 2014-03-18 +================== + + * package: bump `engine.io-parser` and `engine.io-client` + +1.0.4 / 2014-03-14 +================== + + * package: bump `engine.io-client` + +1.0.3 / 2014-03-12 +================== + + * package: bump `engine.io-client` + +1.0.2 / 2014-03-12 +================== + + * bump engine.io-client + +1.0.1 / 2014-03-06 +================== + + * package: bump `engine.io-parser` + * transports: fix jshint warnings and style + +1.0.0 / 2014-03-06 +================== + + * polling-xhr: added `OPTIONS` support, fixes CORS + * close() properly when triggered in connection handler + * fix DDOS vector by setting up too many intervals + * binary support + +0.9.0 / 2014-02-09 +================== + + * Prevent errors with connections behind proxies without WS support + like Squid [nicklagrow, samaanghani, davidhcummings] + * Socket#request a simple property [mokesmokes] + * Changed `Socket`'s `upgrade` event to happen after upgrade [mokesmokes] + * Document `Socket#id` [mokesmokes] + +0.8.2 / 2014-01-18 +================== + + * package: bump `engine.io-client` + +0.8.1 / 2014-01-17 +================== + + * package: bump `engine.io-client` + * package: pin dev deps + * examples: fix port output + * fix latency example + +0.8.0 / 2014-01-05 +================== + + * package: bump `engine.io-client` to `0.8.0` + * test: fix syntax, remove globals + +0.7.14 / 2014-01-01 +=================== + + * package: bump `engine.io-client` to `0.7.14` + +0.7.13 / 2013-12-20 +=================== + + * package: bump `engine.io-client` + * transports: added support for XSS filters on IE [guille, 3rd-eden] + +0.7.12 / 2013-11-11 +=================== + + * package: bump `engine.io-client` + +0.7.11 / 2013-11-06 +=================== + + * package: bump engine.io-client + * fix GH-198 + +0.7.10 / 2013-10-28 +=================== + + * package: bump `engine.io-client` + * package: update "ws" to v0.4.31 + +0.7.9 / 2013-08-30 +================== + + * package: bump `engine.io-client` + +0.7.8 / 2013-08-30 +================== + + * package: bump `engine.io-client` + * package: bump ws + +0.7.7 / 2013-08-30 +================== + + * package: bump `engine.io-client` + +0.7.6 / 2013-08-30 +================== + + * package: bump engine.io-client + +0.7.5 / 2013-08-30 +================== + + * package: bump engine.io-client + +0.7.4 / 2013-08-25 +================== + + * package: bump `engine.io-client` + +0.7.3 / 2013-08-23 +================== + + * package: bump engine.io-client (noop) + * package: fix regresison in upgrade cause by ws update + +0.7.2 / 2013-08-23 +================== + + * package: bump `engine.io-client` for `WebSocket` browser fix + +0.7.1 / 2013-08-23 +================== + + * package: bump engine.io-client for ws fix + +0.7.0 / 2013-08-23 +================== + + * package: bump engine.io-client + * updated example + * inline merge + * added support node version 0.10 to .travis.yml + * fixed respond to flash policy request test. Closes #184 + * fixed upgrade with timeout test. Closes #185 + * engine.io: don't use __proto__, closes #170 + +0.6.3 / 2013-06-21 +================== + + * package: bumped `engine.io-client` to `0.6.3` + +0.6.2 / 2013-06-15 +================== + + * fix upgrade stalling edge case introduced with #174 fix + * remove unneeded client code related to iOS + * added test for `engine.io-client` `0.6.1` + +0.6.1 / 2013-06-06 +================== + + * package: bumped `engine.io-client` to `0.6.1` + +0.6.0 / 2013-05-31 +================== + + * socket: clear timer after sending one noop packet (fixes #174) + * clear all timers on socket close + * sending error on transport creation upon a bad request + * added test for client-side buffer cleanup + * changed flushComplete to flush + * ended support for node 0.6 + +0.5.0 / 2013-03-16 +================== + + * polling: implemented new parser + * test writeBuffer isn't cleared onError, removed 'closing' check in .flush() + * fixed bug89 and added tests: writeBuffer not flushed until nextTick + +0.4.3 / 2013-02-08 +================== + + * package: bumped `engine.io-client` to `0.4.3` + +0.4.2 / 2013-02-08 +================== + + * Only end upgrade socket connections if unhandled + * Fix websocket dependency + * Close socket if upgrade is received and socket.readyState != open + +0.4.1 / 2013-01-18 +================== + + * package: bumped versions + * Fixed bugs in previous send callback fix and updated test cases + * Added a test case which makes the code before the send callback fix fail + * socket: emit `data` event (synonym with `message`) + * socket: added `Socket#write` + * engine.io: cleanup + * engine.io: deprecated `resource` + * `npm docs engine.io` works now + +0.3.10 / 2012-12-03 +=================== + + * package: bumped `engine.io-client` with `close` fixes + * add packetCreate event [jxck] + * add packet event to socket [jxck] + * transport: remove `Connection` headers and let node handle it + * server: send validation failure reason to clients + * engine: invoking as a function causes attach + * socket: reset `writeBuffer` before send + +0.3.9 / 2012-10-23 +================== + + * package: bumped `engine.io-client` + +0.3.8 / 2012-10-23 +================== + + * package: bumped engine.io-client + * examples: added first example + +0.3.7 / 2012-10-21 +================== + + * package: bumped `engine.io-client` + +0.3.6 / 2012-10-21 +================== + + [skipped] + +0.3.5 / 2012-10-14 +================== + + * package: reverted last commit - we use the parser from the client + +0.3.4 / 2012-10-14 +================== + + * package: `engine.io-client` moved to `devDependencies` + * socket: added missing jsdoc + +0.3.3 / 2012-10-10 +================== + + * socket: fixed check interval clearing [joewalnes] + * transports: improved instrumentation + +0.3.2 / 2012-10-08 +================== + + * socket: improve check interval for upgrade + +0.3.1 / 2012-10-08 +================== + + * socket: faster upgrades (we perform a check immediately) + * server: don't assume sid is numeric + +0.3.0 / 2012-10-04 +================== + + * socket: `writeBuffer` now gets sliced, and is recoverable after `close` [afshinm] + * server: expect ping from client and send interval with handshake [cadorn] + * polling-jsonp: prevent client breakage with utf8 whitespace + * socket: fix `flush` and `drain` events + * socket: add `send` callback [afshinm] + * transport: avoid unhandled error events for stale transports + * README: documentation improvements [EugenDueck] + +0.2.2 / 2012-08-26 +================== + + * server: remove buffering for flash policy requests + * transport: avoid unhandled error events for stale transports (fixes #69) + * readme: documented `toString` behavior on `send` [EugenDueck] + +0.2.1 / 2012-08-13 +================== + + * polling-xhr: skip Keep-Alive when it's implied [EugenDueck] + * polling-jsonp: skip Keep-Alive when it's implied [EugenDueck] + * README: added plugins list with engine.io-conflation + * socket: added flush/drain events (fixes #56) + * server: avoid passing websocket to non-websocket transports (fixes #24) + +0.2.0 / 2012-08-06 +================== + + * Bumped client + * test: added closing connection test + * server: implemented stronger id generator with collision detection + +0.1.2 / 2012-08-02 +================== + + * Fixed a jsonp bug in Nokia mobile phones and potentially other UAs. + +0.1.1 / 2012-08-01 +================== + + * Fixed errors when a socket is closed while upgrade probe is happening. + * Improved WS error handling + * Replaced websocket.io with ws, now that it supports older drafts + * README fixes + +0.1.0 / 2012-07-03 +================== + + * Initial release. diff --git a/ui/node_modules/socket.io/node_modules/engine.io/LICENSE b/ui/node_modules/socket.io/node_modules/engine.io/LICENSE index 3c718ba3..6494c3c7 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/LICENSE +++ b/ui/node_modules/socket.io/node_modules/engine.io/LICENSE @@ -1,19 +1,19 @@ -(The MIT License) - -Copyright (c) 2014 Guillermo Rauch - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the 'Software'), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or -substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +(The MIT License) + +Copyright (c) 2014 Guillermo Rauch + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the 'Software'), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/ui/node_modules/socket.io/node_modules/engine.io/Makefile b/ui/node_modules/socket.io/node_modules/engine.io/Makefile index ed22dc77..5046cedf 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/Makefile +++ b/ui/node_modules/socket.io/node_modules/engine.io/Makefile @@ -1,23 +1,23 @@ - -TESTS = test/*.js -BENCHMARKS = $(shell find bench -type f ! -name 'runner.js') -REPORTER = dot - -test: - @./node_modules/.bin/mocha \ - --reporter $(REPORTER) \ - --slow 500ms \ - --bail \ - --globals ___eio,document \ - $(TESTS) - -test-cov: lib-cov - EIO_COV=1 $(MAKE) test REPORTER=html-cov > coverage.html - -lib-cov: - jscoverage --no-highlight lib lib-cov - -bench: - @node $(PROFILEFLAGS) bench/runner.js $(BENCHMARKS) - -.PHONY: test test-cov bench + +TESTS = test/*.js +BENCHMARKS = $(shell find bench -type f ! -name 'runner.js') +REPORTER = dot + +test: + @./node_modules/.bin/mocha \ + --reporter $(REPORTER) \ + --slow 500ms \ + --bail \ + --globals ___eio,document \ + $(TESTS) + +test-cov: lib-cov + EIO_COV=1 $(MAKE) test REPORTER=html-cov > coverage.html + +lib-cov: + jscoverage --no-highlight lib lib-cov + +bench: + @node $(PROFILEFLAGS) bench/runner.js $(BENCHMARKS) + +.PHONY: test test-cov bench diff --git a/ui/node_modules/socket.io/node_modules/engine.io/README.md b/ui/node_modules/socket.io/node_modules/engine.io/README.md index cd254b2e..e0f793a4 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/README.md +++ b/ui/node_modules/socket.io/node_modules/engine.io/README.md @@ -1,534 +1,534 @@ - -# Engine.IO: the realtime engine - -[![Build Status](https://secure.travis-ci.org/socketio/engine.io.svg)](http://travis-ci.org/socketio/engine.io) -[![NPM version](https://badge.fury.io/js/engine.io.svg)](http://badge.fury.io/js/engine.io) - -`Engine.IO` is the implementation of transport-based -cross-browser/cross-device bi-directional communication layer for -[Socket.IO](http://github.com/socketio/socket.io). - -## How to use - -### Server - -#### (A) Listening on a port - -```js -var engine = require('engine.io'); -var server = engine.listen(80); - -server.on('connection', function(socket){ - socket.send('utf 8 string'); - socket.send(new Buffer([0, 1, 2, 3, 4, 5])); // binary data -}); -``` - -#### (B) Intercepting requests for a http.Server - -```js -var engine = require('engine.io'); -var http = require('http').createServer().listen(3000); -var server = engine.attach(http); - -server.on('connection', function (socket) { - socket.on('message', function(data){ }); - socket.on('close', function(){ }); -}); -``` - -#### (C) Passing in requests - -```js -var engine = require('engine.io'); -var server = new engine.Server(); - -server.on('connection', function(socket){ - socket.send('hi'); -}); - -// … -httpServer.on('upgrade', function(req, socket, head){ - server.handleUpgrade(req, socket, head); -}); -httpServer.on('request', function(req, res){ - server.handleRequest(req, res); -}); -``` - -### Client - -```html - - -``` - -For more information on the client refer to the -[engine-client](http://github.com/learnboost/engine.io-client) repository. - -## What features does it have? - -- **Maximum reliability**. Connections are established even in the presence of: - - proxies and load balancers. - - personal firewall and antivirus software. - - for more information refer to **Goals** and **Architecture** sections -- **Minimal client size** aided by: - - lazy loading of flash transports. - - lack of redundant transports. -- **Scalable** - - load balancer friendly -- **Future proof** -- **100% Node.JS core style** - - No API sugar (left for higher level projects) - - Written in readable vanilla JavaScript - -## API - -### Server - -

- -#### Top-level - -These are exposed by `require('engine.io')`: - -##### Events - -- `flush` - - Called when a socket buffer is being flushed. - - **Arguments** - - `Socket`: socket being flushed - - `Array`: write buffer -- `drain` - - Called when a socket buffer is drained - - **Arguments** - - `Socket`: socket being flushed - -##### Properties - -- `protocol` _(Number)_: protocol revision number -- `Server`: Server class constructor -- `Socket`: Socket class constructor -- `Transport` _(Function)_: transport constructor -- `transports` _(Object)_: map of available transports - -##### Methods - -- `()` - - Returns a new `Server` instance. If the first argument is an `http.Server` then the - new `Server` instance will be attached to it. Otherwise, the arguments are passed - directly to the `Server` constructor. - - **Parameters** - - `http.Server`: optional, server to attach to. - - `Object`: optional, options object (see `Server#constructor` api docs below) - - The following are identical ways to instantiate a server and then attach it. - ```js - var httpServer; // previously created with `http.createServer();` from node.js api. - - // create a server first, and then attach - var eioServer = require('engine.io').Server(); - eioServer.attach(httpServer); - - // or call the module as a function to get `Server` - var eioServer = require('engine.io')(); - eioServer.attach(httpServer); - - // immediately attach - var eioServer = require('engine.io')(httpServer); - ``` - -- `listen` - - Creates an `http.Server` which listens on the given port and attaches WS - to it. It returns `501 Not Implemented` for regular http requests. - - **Parameters** - - `Number`: port to listen on. - - `Object`: optional, options object - - `Function`: callback for `listen`. - - **Options** - - All options from `Server.attach` method, documented below. - - **Additionally** See Server `constructor` below for options you can pass for creating the new Server - - **Returns** `Server` -- `attach` - - Captures `upgrade` requests for a `http.Server`. In other words, makes - a regular http.Server WebSocket-compatible. - - **Parameters** - - `http.Server`: server to attach to. - - `Object`: optional, options object - - **Options** - - All options from `Server.attach` method, documented below. - - **Additionally** See Server `constructor` below for options you can pass for creating the new Server - - **Returns** `Server` a new Server instance. - -

- -#### Server - -The main server/manager. _Inherits from EventEmitter_. - -##### Events - -- `connection` - - Fired when a new connection is established. - - **Arguments** - - `Socket`: a Socket object - -##### Properties - -**Important**: if you plan to use Engine.IO in a scalable way, please -keep in mind the properties below will only reflect the clients connected -to a single process. - -- `clients` _(Object)_: hash of connected clients by id. -- `clientsCount` _(Number)_: number of connected clients. - -##### Methods - -- **constructor** - - Initializes the server - - **Parameters** - - `Object`: optional, options object - - **Options** - - `pingTimeout` (`Number`): how many ms without a pong packet to - consider the connection closed (`60000`) - - `pingInterval` (`Number`): how many ms before sending a new ping - packet (`25000`) - - `maxHttpBufferSize` (`Number`): how many bytes or characters a message - can be when polling, before closing the session (to avoid DoS). Default - value is `10E7`. - - `allowRequest` (`Function`): A function that receives a given handshake - or upgrade request as its first parameter, and can decide whether to - continue or not. The second argument is a function that needs to be - called with the decided information: `fn(err, success)`, where - `success` is a boolean value where false means that the request is - rejected, and err is an error code. - - `transports` (` String`): transports to allow connections - to (`['polling', 'websocket']`) - - `allowUpgrades` (`Boolean`): whether to allow transport upgrades - (`true`) - - `perMessageDeflate` (`Object|Boolean`): parameters of the WebSocket permessage-deflate extension - (see [ws module](https://github.com/einaros/ws) api docs). Set to `false` to disable. (`true`) - - `threshold` (`Number`): data is compressed only if the byte size is above this value (`1024`) - - `httpCompression` (`Object|Boolean`): parameters of the http compression for the polling transports - (see [zlib](http://nodejs.org/api/zlib.html#zlib_options) api docs). Set to `false` to disable. (`true`) - - `threshold` (`Number`): data is compressed only if the byte size is above this value (`1024`) - - `cookie` (`String|Boolean`): name of the HTTP cookie that - contains the client sid to send as part of handshake response - headers. Set to `false` to not send one. (`io`) - - `cookiePath` (`String|Boolean`): path of the above `cookie` - option. If false, no path will be sent, which means browsers will only send the cookie on the engine.io attached path (`/engine.io`). - Set this to `/` to send the io cookie on all requests. (`false`) -- `close` - - Closes all clients - - **Returns** `Server` for chaining -- `handleRequest` - - Called internally when a `Engine` request is intercepted. - - **Parameters** - - `http.ServerRequest`: a node request object - - `http.ServerResponse`: a node response object - - **Returns** `Server` for chaining -- `handleUpgrade` - - Called internally when a `Engine` ws upgrade is intercepted. - - **Parameters** (same as `upgrade` event) - - `http.ServerRequest`: a node request object - - `net.Stream`: TCP socket for the request - - `Buffer`: legacy tail bytes - - **Returns** `Server` for chaining -- `attach` - - Attach this Server instance to an `http.Server` - - Captures `upgrade` requests for a `http.Server`. In other words, makes - a regular http.Server WebSocket-compatible. - - **Parameters** - - `http.Server`: server to attach to. - - `Object`: optional, options object - - **Options** - - `path` (`String`): name of the path to capture (`/engine.io`). - - `destroyUpgrade` (`Boolean`): destroy unhandled upgrade requests (`true`) - - `destroyUpgradeTimeout` (`Number`): milliseconds after which unhandled requests are ended (`1000`) -- `generateId` - - Generate a socket id. - - Overwrite this method to generate your custom socket id. - - **Parameters** - - `http.ServerRequest`: a node request object - - **Returns** A socket id for connected client. - -

- -#### Socket - -A representation of a client. _Inherits from EventEmitter_. - -##### Events - -- `close` - - Fired when the client is disconnected. - - **Arguments** - - `String`: reason for closing - - `Object`: description object (optional) -- `message` - - Fired when the client sends a message. - - **Arguments** - - `String` or `Buffer`: Unicode string or Buffer with binary contents -- `error` - - Fired when an error occurs. - - **Arguments** - - `Error`: error object -- `flush` - - Called when the write buffer is being flushed. - - **Arguments** - - `Array`: write buffer -- `drain` - - Called when the write buffer is drained -- `packet` - - Called when a socket received a packet (`message`, `ping`) - - **Arguments** - - `type`: packet type - - `data`: packet data (if type is message) -- `packetCreate` - - Called before a socket sends a packet (`message`, `pong`) - - **Arguments** - - `type`: packet type - - `data`: packet data (if type is message) - -##### Properties - -- `id` _(String)_: unique identifier -- `server` _(Server)_: engine parent reference -- `request` _(http.ServerRequest)_: request that originated the Socket -- `upgraded` _(Boolean)_: whether the transport has been upgraded -- `readyState` _(String)_: opening|open|closing|closed -- `transport` _(Transport)_: transport reference - -##### Methods - -- `send`: - - Sends a message, performing `message = toString(arguments[0])` unless - sending binary data, which is sent as is. - - **Parameters** - - `String` | `Buffer` | `ArrayBuffer` | `ArrayBufferView`: a string or any object implementing `toString()`, with outgoing data, or a Buffer or ArrayBuffer with binary data. Also any ArrayBufferView can be sent as is. - - `Object`: optional, options object - - `Function`: optional, a callback executed when the message gets flushed out by the transport - - **Options** - - `compress` (`Boolean`): whether to compress sending data. This option might be ignored and forced to be `true` when using polling. (`true`) - - **Returns** `Socket` for chaining -- `close` - - Disconnects the client - - **Returns** `Socket` for chaining - -### Client - -

- -Exposed in the `eio` global namespace (in the browser), or by -`require('engine.io-client')` (in Node.JS). - -For the client API refer to the -[engine-client](http://github.com/learnboost/engine.io-client) repository. - -## Debug / logging - -Engine.IO is powered by [debug](http://github.com/visionmedia/debug). -In order to see all the debug output, run your app with the environment variable -`DEBUG` including the desired scope. - -To see the output from all of Engine.IO's debugging scopes you can use: - -``` -DEBUG=engine* node myapp -``` - -## Transports - -- `polling`: XHR / JSONP polling transport. -- `websocket`: WebSocket transport. - -## Plugins - -- [engine.io-conflation](https://github.com/EugenDueck/engine.io-conflation): Makes **conflation and aggregation** of messages straightforward. - -## Support - -The support channels for `engine.io` are the same as `socket.io`: - - irc.freenode.net **#socket.io** - - [Google Groups](http://groups.google.com/group/socket_io) - - [Website](http://socket.io) - -## Development - -To contribute patches, run tests or benchmarks, make sure to clone the -repository: - -``` -git clone git://github.com/LearnBoost/engine.io.git -``` - -Then: - -``` -cd engine.io -npm install -``` - -## Tests - -Tests run with `make test`. It runs the server tests that are aided by -the usage of `engine.io-client`. - -Make sure `npm install` is run first. - -## Goals - -The main goal of `Engine` is ensuring the most reliable realtime communication. -Unlike the previous Socket.IO core, it always establishes a long-polling -connection first, then tries to upgrade to better transports that are "tested" on -the side. - -During the lifetime of the Socket.IO projects, we've found countless drawbacks -to relying on `HTML5 WebSocket` or `Flash Socket` as the first connection -mechanisms. - -Both are clearly the _right way_ of establishing a bidirectional communication, -with HTML5 WebSocket being the way of the future. However, to answer most business -needs, alternative traditional HTTP 1.1 mechanisms are just as good as delivering -the same solution. - -WebSocket based connections have two fundamental benefits: - -1. **Better server performance** - - _A: Load balancers_
- Load balancing a long polling connection poses a serious architectural nightmare - since requests can come from any number of open sockets by the user agent, but - they all need to be routed to the process and computer that owns the `Engine` - connection. This negatively impacts RAM and CPU usage. - - _B: Network traffic_
- WebSocket is designed around the premise that each message frame has to be - surrounded by the least amount of data. In HTTP 1.1 transports, each message - frame is surrounded by HTTP headers and chunked encoding frames. If you try to - send the message _"Hello world"_ with xhr-polling, the message ultimately - becomes larger than if you were to send it with WebSocket. - - _C: Lightweight parser_
- As an effect of **B**, the server has to do a lot more work to parse the network - data and figure out the message when traditional HTTP requests are used - (as in long polling). This means that another advantage of WebSocket is - less server CPU usage. - -2. **Better user experience** - - Due to the reasons stated in point **1**, the most important effect of being able - to establish a WebSocket connection is raw data transfer speed, which translates - in _some_ cases in better user experience. - - Applications with heavy realtime interaction (such as games) will benefit greatly, - whereas applications like realtime chat (Gmail/Facebook), newsfeeds (Facebook) or - timelines (Twitter) will have negligible user experience improvements. - -Having said this, attempting to establish a WebSocket connection directly so far has -proven problematic: - -1. **Proxies**
- Many corporate proxies block WebSocket traffic. - -2. **Personal firewall and antivirus software**
- As a result of our research, we've found that at least 3 personal security - applications block WebSocket traffic. - -3. **Cloud application platforms**
- Platforms like Heroku or No.de have had trouble keeping up with the fast-paced - nature of the evolution of the WebSocket protocol. Applications therefore end up - inevitably using long polling, but the seamless installation experience of - Socket.IO we strive for (_"require() it and it just works"_) disappears. - -Some of these problems have solutions. In the case of proxies and personal programs, -however, the solutions many times involve upgrading software. Experience has shown -that relying on client software upgrades to deliver a business solution is -fruitless: the very existence of this project has to do with a fragmented panorama -of user agent distribution, with clients connecting with latest versions of the most -modern user agents (Chrome, Firefox and Safari), but others with versions as low as -IE 5.5. - -From the user perspective, an unsuccessful WebSocket connection can translate in -up to at least 10 seconds of waiting for the realtime application to begin -exchanging data. This **perceptively** hurts user experience. - -To summarize, **Engine** focuses on reliability and user experience first, marginal -potential UX improvements and increased server performance second. `Engine` is the -result of all the lessons learned with WebSocket in the wild. - -## Architecture - -The main premise of `Engine`, and the core of its existence, is the ability to -swap transports on the fly. A connection starts as xhr-polling, but it can -switch to WebSocket. - -The central problem this poses is: how do we switch transports without losing -messages? - -`Engine` only switches from polling to another transport in between polling -cycles. Since the server closes the connection after a certain timeout when -there's no activity, and the polling transport implementation buffers messages -in between connections, this ensures no message loss and optimal performance. - -Another benefit of this design is that we workaround almost all the limitations -of **Flash Socket**, such as slow connection times, increased file size (we can -safely lazy load it without hurting user experience), etc. - -## FAQ - -### Can I use engine without Socket.IO ? - -Absolutely. Although the recommended framework for building realtime applications -is Socket.IO, since it provides fundamental features for real-world applications -such as multiplexing, reconnection support, etc. - -`Engine` is to Socket.IO what Connect is to Express. An essential piece for building -realtime frameworks, but something you _probably_ won't be using for building -actual applications. - -### Does the server serve the client? - -No. The main reason is that `Engine` is meant to be bundled with frameworks. -Socket.IO includes `Engine`, therefore serving two clients is not necessary. If -you use Socket.IO, including - -```html - + +``` + +For more information on the client refer to the +[engine-client](http://github.com/learnboost/engine.io-client) repository. + +## What features does it have? + +- **Maximum reliability**. Connections are established even in the presence of: + - proxies and load balancers. + - personal firewall and antivirus software. + - for more information refer to **Goals** and **Architecture** sections +- **Minimal client size** aided by: + - lazy loading of flash transports. + - lack of redundant transports. +- **Scalable** + - load balancer friendly +- **Future proof** +- **100% Node.JS core style** + - No API sugar (left for higher level projects) + - Written in readable vanilla JavaScript + +## API + +### Server + +

+ +#### Top-level + +These are exposed by `require('engine.io')`: + +##### Events + +- `flush` + - Called when a socket buffer is being flushed. + - **Arguments** + - `Socket`: socket being flushed + - `Array`: write buffer +- `drain` + - Called when a socket buffer is drained + - **Arguments** + - `Socket`: socket being flushed + +##### Properties + +- `protocol` _(Number)_: protocol revision number +- `Server`: Server class constructor +- `Socket`: Socket class constructor +- `Transport` _(Function)_: transport constructor +- `transports` _(Object)_: map of available transports + +##### Methods + +- `()` + - Returns a new `Server` instance. If the first argument is an `http.Server` then the + new `Server` instance will be attached to it. Otherwise, the arguments are passed + directly to the `Server` constructor. + - **Parameters** + - `http.Server`: optional, server to attach to. + - `Object`: optional, options object (see `Server#constructor` api docs below) + + The following are identical ways to instantiate a server and then attach it. + ```js + var httpServer; // previously created with `http.createServer();` from node.js api. + + // create a server first, and then attach + var eioServer = require('engine.io').Server(); + eioServer.attach(httpServer); + + // or call the module as a function to get `Server` + var eioServer = require('engine.io')(); + eioServer.attach(httpServer); + + // immediately attach + var eioServer = require('engine.io')(httpServer); + ``` + +- `listen` + - Creates an `http.Server` which listens on the given port and attaches WS + to it. It returns `501 Not Implemented` for regular http requests. + - **Parameters** + - `Number`: port to listen on. + - `Object`: optional, options object + - `Function`: callback for `listen`. + - **Options** + - All options from `Server.attach` method, documented below. + - **Additionally** See Server `constructor` below for options you can pass for creating the new Server + - **Returns** `Server` +- `attach` + - Captures `upgrade` requests for a `http.Server`. In other words, makes + a regular http.Server WebSocket-compatible. + - **Parameters** + - `http.Server`: server to attach to. + - `Object`: optional, options object + - **Options** + - All options from `Server.attach` method, documented below. + - **Additionally** See Server `constructor` below for options you can pass for creating the new Server + - **Returns** `Server` a new Server instance. + +

+ +#### Server + +The main server/manager. _Inherits from EventEmitter_. + +##### Events + +- `connection` + - Fired when a new connection is established. + - **Arguments** + - `Socket`: a Socket object + +##### Properties + +**Important**: if you plan to use Engine.IO in a scalable way, please +keep in mind the properties below will only reflect the clients connected +to a single process. + +- `clients` _(Object)_: hash of connected clients by id. +- `clientsCount` _(Number)_: number of connected clients. + +##### Methods + +- **constructor** + - Initializes the server + - **Parameters** + - `Object`: optional, options object + - **Options** + - `pingTimeout` (`Number`): how many ms without a pong packet to + consider the connection closed (`60000`) + - `pingInterval` (`Number`): how many ms before sending a new ping + packet (`25000`) + - `maxHttpBufferSize` (`Number`): how many bytes or characters a message + can be when polling, before closing the session (to avoid DoS). Default + value is `10E7`. + - `allowRequest` (`Function`): A function that receives a given handshake + or upgrade request as its first parameter, and can decide whether to + continue or not. The second argument is a function that needs to be + called with the decided information: `fn(err, success)`, where + `success` is a boolean value where false means that the request is + rejected, and err is an error code. + - `transports` (` String`): transports to allow connections + to (`['polling', 'websocket']`) + - `allowUpgrades` (`Boolean`): whether to allow transport upgrades + (`true`) + - `perMessageDeflate` (`Object|Boolean`): parameters of the WebSocket permessage-deflate extension + (see [ws module](https://github.com/einaros/ws) api docs). Set to `false` to disable. (`true`) + - `threshold` (`Number`): data is compressed only if the byte size is above this value (`1024`) + - `httpCompression` (`Object|Boolean`): parameters of the http compression for the polling transports + (see [zlib](http://nodejs.org/api/zlib.html#zlib_options) api docs). Set to `false` to disable. (`true`) + - `threshold` (`Number`): data is compressed only if the byte size is above this value (`1024`) + - `cookie` (`String|Boolean`): name of the HTTP cookie that + contains the client sid to send as part of handshake response + headers. Set to `false` to not send one. (`io`) + - `cookiePath` (`String|Boolean`): path of the above `cookie` + option. If false, no path will be sent, which means browsers will only send the cookie on the engine.io attached path (`/engine.io`). + Set this to `/` to send the io cookie on all requests. (`false`) +- `close` + - Closes all clients + - **Returns** `Server` for chaining +- `handleRequest` + - Called internally when a `Engine` request is intercepted. + - **Parameters** + - `http.ServerRequest`: a node request object + - `http.ServerResponse`: a node response object + - **Returns** `Server` for chaining +- `handleUpgrade` + - Called internally when a `Engine` ws upgrade is intercepted. + - **Parameters** (same as `upgrade` event) + - `http.ServerRequest`: a node request object + - `net.Stream`: TCP socket for the request + - `Buffer`: legacy tail bytes + - **Returns** `Server` for chaining +- `attach` + - Attach this Server instance to an `http.Server` + - Captures `upgrade` requests for a `http.Server`. In other words, makes + a regular http.Server WebSocket-compatible. + - **Parameters** + - `http.Server`: server to attach to. + - `Object`: optional, options object + - **Options** + - `path` (`String`): name of the path to capture (`/engine.io`). + - `destroyUpgrade` (`Boolean`): destroy unhandled upgrade requests (`true`) + - `destroyUpgradeTimeout` (`Number`): milliseconds after which unhandled requests are ended (`1000`) +- `generateId` + - Generate a socket id. + - Overwrite this method to generate your custom socket id. + - **Parameters** + - `http.ServerRequest`: a node request object + - **Returns** A socket id for connected client. + +

+ +#### Socket + +A representation of a client. _Inherits from EventEmitter_. + +##### Events + +- `close` + - Fired when the client is disconnected. + - **Arguments** + - `String`: reason for closing + - `Object`: description object (optional) +- `message` + - Fired when the client sends a message. + - **Arguments** + - `String` or `Buffer`: Unicode string or Buffer with binary contents +- `error` + - Fired when an error occurs. + - **Arguments** + - `Error`: error object +- `flush` + - Called when the write buffer is being flushed. + - **Arguments** + - `Array`: write buffer +- `drain` + - Called when the write buffer is drained +- `packet` + - Called when a socket received a packet (`message`, `ping`) + - **Arguments** + - `type`: packet type + - `data`: packet data (if type is message) +- `packetCreate` + - Called before a socket sends a packet (`message`, `pong`) + - **Arguments** + - `type`: packet type + - `data`: packet data (if type is message) + +##### Properties + +- `id` _(String)_: unique identifier +- `server` _(Server)_: engine parent reference +- `request` _(http.ServerRequest)_: request that originated the Socket +- `upgraded` _(Boolean)_: whether the transport has been upgraded +- `readyState` _(String)_: opening|open|closing|closed +- `transport` _(Transport)_: transport reference + +##### Methods + +- `send`: + - Sends a message, performing `message = toString(arguments[0])` unless + sending binary data, which is sent as is. + - **Parameters** + - `String` | `Buffer` | `ArrayBuffer` | `ArrayBufferView`: a string or any object implementing `toString()`, with outgoing data, or a Buffer or ArrayBuffer with binary data. Also any ArrayBufferView can be sent as is. + - `Object`: optional, options object + - `Function`: optional, a callback executed when the message gets flushed out by the transport + - **Options** + - `compress` (`Boolean`): whether to compress sending data. This option might be ignored and forced to be `true` when using polling. (`true`) + - **Returns** `Socket` for chaining +- `close` + - Disconnects the client + - **Returns** `Socket` for chaining + +### Client + +

+ +Exposed in the `eio` global namespace (in the browser), or by +`require('engine.io-client')` (in Node.JS). + +For the client API refer to the +[engine-client](http://github.com/learnboost/engine.io-client) repository. + +## Debug / logging + +Engine.IO is powered by [debug](http://github.com/visionmedia/debug). +In order to see all the debug output, run your app with the environment variable +`DEBUG` including the desired scope. + +To see the output from all of Engine.IO's debugging scopes you can use: + +``` +DEBUG=engine* node myapp +``` + +## Transports + +- `polling`: XHR / JSONP polling transport. +- `websocket`: WebSocket transport. + +## Plugins + +- [engine.io-conflation](https://github.com/EugenDueck/engine.io-conflation): Makes **conflation and aggregation** of messages straightforward. + +## Support + +The support channels for `engine.io` are the same as `socket.io`: + - irc.freenode.net **#socket.io** + - [Google Groups](http://groups.google.com/group/socket_io) + - [Website](http://socket.io) + +## Development + +To contribute patches, run tests or benchmarks, make sure to clone the +repository: + +``` +git clone git://github.com/LearnBoost/engine.io.git +``` + +Then: + +``` +cd engine.io +npm install +``` + +## Tests + +Tests run with `make test`. It runs the server tests that are aided by +the usage of `engine.io-client`. + +Make sure `npm install` is run first. + +## Goals + +The main goal of `Engine` is ensuring the most reliable realtime communication. +Unlike the previous Socket.IO core, it always establishes a long-polling +connection first, then tries to upgrade to better transports that are "tested" on +the side. + +During the lifetime of the Socket.IO projects, we've found countless drawbacks +to relying on `HTML5 WebSocket` or `Flash Socket` as the first connection +mechanisms. + +Both are clearly the _right way_ of establishing a bidirectional communication, +with HTML5 WebSocket being the way of the future. However, to answer most business +needs, alternative traditional HTTP 1.1 mechanisms are just as good as delivering +the same solution. + +WebSocket based connections have two fundamental benefits: + +1. **Better server performance** + - _A: Load balancers_
+ Load balancing a long polling connection poses a serious architectural nightmare + since requests can come from any number of open sockets by the user agent, but + they all need to be routed to the process and computer that owns the `Engine` + connection. This negatively impacts RAM and CPU usage. + - _B: Network traffic_
+ WebSocket is designed around the premise that each message frame has to be + surrounded by the least amount of data. In HTTP 1.1 transports, each message + frame is surrounded by HTTP headers and chunked encoding frames. If you try to + send the message _"Hello world"_ with xhr-polling, the message ultimately + becomes larger than if you were to send it with WebSocket. + - _C: Lightweight parser_
+ As an effect of **B**, the server has to do a lot more work to parse the network + data and figure out the message when traditional HTTP requests are used + (as in long polling). This means that another advantage of WebSocket is + less server CPU usage. + +2. **Better user experience** + + Due to the reasons stated in point **1**, the most important effect of being able + to establish a WebSocket connection is raw data transfer speed, which translates + in _some_ cases in better user experience. + + Applications with heavy realtime interaction (such as games) will benefit greatly, + whereas applications like realtime chat (Gmail/Facebook), newsfeeds (Facebook) or + timelines (Twitter) will have negligible user experience improvements. + +Having said this, attempting to establish a WebSocket connection directly so far has +proven problematic: + +1. **Proxies**
+ Many corporate proxies block WebSocket traffic. + +2. **Personal firewall and antivirus software**
+ As a result of our research, we've found that at least 3 personal security + applications block WebSocket traffic. + +3. **Cloud application platforms**
+ Platforms like Heroku or No.de have had trouble keeping up with the fast-paced + nature of the evolution of the WebSocket protocol. Applications therefore end up + inevitably using long polling, but the seamless installation experience of + Socket.IO we strive for (_"require() it and it just works"_) disappears. + +Some of these problems have solutions. In the case of proxies and personal programs, +however, the solutions many times involve upgrading software. Experience has shown +that relying on client software upgrades to deliver a business solution is +fruitless: the very existence of this project has to do with a fragmented panorama +of user agent distribution, with clients connecting with latest versions of the most +modern user agents (Chrome, Firefox and Safari), but others with versions as low as +IE 5.5. + +From the user perspective, an unsuccessful WebSocket connection can translate in +up to at least 10 seconds of waiting for the realtime application to begin +exchanging data. This **perceptively** hurts user experience. + +To summarize, **Engine** focuses on reliability and user experience first, marginal +potential UX improvements and increased server performance second. `Engine` is the +result of all the lessons learned with WebSocket in the wild. + +## Architecture + +The main premise of `Engine`, and the core of its existence, is the ability to +swap transports on the fly. A connection starts as xhr-polling, but it can +switch to WebSocket. + +The central problem this poses is: how do we switch transports without losing +messages? + +`Engine` only switches from polling to another transport in between polling +cycles. Since the server closes the connection after a certain timeout when +there's no activity, and the polling transport implementation buffers messages +in between connections, this ensures no message loss and optimal performance. + +Another benefit of this design is that we workaround almost all the limitations +of **Flash Socket**, such as slow connection times, increased file size (we can +safely lazy load it without hurting user experience), etc. + +## FAQ + +### Can I use engine without Socket.IO ? + +Absolutely. Although the recommended framework for building realtime applications +is Socket.IO, since it provides fundamental features for real-world applications +such as multiplexing, reconnection support, etc. + +`Engine` is to Socket.IO what Connect is to Express. An essential piece for building +realtime frameworks, but something you _probably_ won't be using for building +actual applications. + +### Does the server serve the client? + +No. The main reason is that `Engine` is meant to be bundled with frameworks. +Socket.IO includes `Engine`, therefore serving two clients is not necessary. If +you use Socket.IO, including + +```html + - ``` - -## Features - -- Runs on browser and node.js seamlessly -- Runs inside HTML5 WebWorker -- Can encode and decode packets - - Encodes from/to ArrayBuffer or Blob when in browser, and Buffer or ArrayBuffer in Node - -## API - -Note: `cb(type)` means the type is a callback function that contains a parameter of type `type` when called. - -### Node - -- `encodePacket` - - Encodes a packet. - - **Parameters** - - `Object`: the packet to encode, has `type` and `data`. - - `data`: can be a `String`, `Number`, `Buffer`, `ArrayBuffer` - - `Boolean`: optional, binary support - - `Function`: callback, returns the encoded packet (`cb(String)`) -- `decodePacket` - - Decodes a packet. Data also available as an ArrayBuffer if requested. - - Returns data as `String` or (`Blob` on browser, `ArrayBuffer` on Node) - - **Parameters** - - `String` | `ArrayBuffer`: the packet to decode, has `type` and `data` - - `String`: optional, the binary type - -- `encodeBase64Packet` - - Encodes a packet with binary data in a base64 string (`String`) - - **Parameters** - - `Object`: the packet to encode, has `type` and `data` - - `Function`: callback, returns the base64 encoded message (`cb(String)`) -- `decodeBase64Packet` - - Decodes a packet encoded in a base64 string. - - **Parameters** - - `String`: the base64 encoded message - - `String`: optional, the binary type - -- `encodePayload` - - Encodes multiple messages (payload). - - If any contents are binary, they will be encoded as base64 strings. Base64 - encoded strings are marked with a b before the length specifier - - **Parameters** - - `Array`: an array of packets - - `Boolean`: optional, binary support - - `Function`: callback, returns the encoded payload (`cb(String)`) -- `decodePayload` - - Decodes data when a payload is maybe expected. Possible binary contents are - decoded from their base64 representation. - - **Parameters** - - `String`: the payload - - `String`: optional, the binary type - - `Function`: callback, returns (cb(`Object`: packet, `Number`:packet index, `Number`:packet total)) - -- `encodePayloadAsBinary` - - Encodes multiple messages (payload) as binary. - - **Parameters** - - `Array`: an array of packets - - `Function`: callback, returns the encoded payload (`cb(Buffer)`) -- `decodePayloadAsBinary` - - Decodes data when a payload is maybe expected. Strings are decoded by - interpreting each byte as a key code for entries marked to start with 0. See - description of encodePayloadAsBinary. - - **Parameters** - - `Buffer`: the buffer - - `String`: optional, the binary type - - `Function`: callback, returns the decoded packet (`cb(Object)`) - -### Browser - -- `encodePayloadAsArrayBuffer` - - Encodes multiple messages (payload) as binary. - - **Parameters** - - `Array`: an array of packets - - `Function`: callback, returns the encoded payload (`cb(ArrayBuffer)`) -- `encodePayloadAsBlob` - - Encodes multiple messages (payload) as blob. - - **Parameters** - - `Array`: an array of packets - - `Function`: callback, returns the encoded payload (`cb(Blob)`) - -## Tests - -Standalone tests can be run with `make test` which will run both node.js and browser tests. - -Browser tests are run using [zuul](https://github.com/defunctzombie/zuul). -(You must have zuul setup with a saucelabs account.) - -You can run the tests locally using the following command: - -``` -./node_modules/.bin/zuul --local 8080 -- test/index.js -``` - -## Support - -The support channels for `engine.io-parser` are the same as `socket.io`: - - irc.freenode.net **#socket.io** - - [Google Groups](http://groups.google.com/group/socket_io) - - [Website](http://socket.io) - -## Development - -To contribute patches, run tests or benchmarks, make sure to clone the -repository: - -```bash -git clone git://github.com/LearnBoost/engine.io-parser.git -``` - -Then: - -```bash -cd engine.io-parser -npm install -``` - -See the `Tests` section above for how to run tests before submitting any patches. - -## License - -MIT + +# engine.io-parser + +[![Build Status](https://secure.travis-ci.org/socketio/engine.io-parser.svg)](http://travis-ci.org/socketio/engine.io-parser) +[![NPM version](https://badge.fury.io/js/engine.io-parser.svg)](http://badge.fury.io/js/engine.io-parser) + +This is the JavaScript parser for the engine.io protocol encoding, +shared by both +[engine.io-client](https://github.com/socketio/engine.io-client) and +[engine.io](https://github.com/socketio/engine.io). + +## How to use + +### Standalone + +The parser can encode/decode packets, payloads, and payloads as binary +with the following methods: `encodePacket`, `decodePacket`, `encodePayload`, +`decodePayload`, `encodePayloadAsBinary`, `decodePayloadAsBinary`. + +The browser-side parser also includes `encodePayloadAsArrayBuffer` and `encodePayloadAsBlob`. + +Example: + +```js +var parser = require('engine.io-parser'); + +var data = new Buffer(5); +for (var i = 0; i < data.length; i++) { data[i] = i; } + +parser.encodePacket({ type: 'message', data: data }, function(encoded) { + var decodedData = parser.decodePacket(encoded); // { type: 'message', data: data } +}); +``` + +### With browserify + +Engine.IO Parser is a commonjs module, which means you can include it by using +`require` on the browser and package using [browserify](http://browserify.org/): + +1. install the parser package + + ```shell + npm install engine.io-parser + ``` + +1. write your app code + + ```js + var parser = require('engine.io-parser'); + + var testBuffer = new Int8Array(10); + for (var i = 0; i < testBuffer.length; i++) testBuffer[i] = i; + + var packets = [{ type: 'message', data: testBuffer.buffer }, { type: 'message', data: 'hello' }]; + + parser.encodePayload(packets, function(encoded) { + parser.decodePayload(encoded, + function(packet, index, total) { + var isLast = index + 1 == total; + if (!isLast) { + var buffer = new Int8Array(packet.data); // testBuffer + } else { + var message = packet.data; // 'hello' + } + }); + }); + ``` + +1. build your app bundle + + ```bash + $ browserify app.js > bundle.js + ``` + +1. include on your page + + ```html + + ``` + +## Features + +- Runs on browser and node.js seamlessly +- Runs inside HTML5 WebWorker +- Can encode and decode packets + - Encodes from/to ArrayBuffer or Blob when in browser, and Buffer or ArrayBuffer in Node + +## API + +Note: `cb(type)` means the type is a callback function that contains a parameter of type `type` when called. + +### Node + +- `encodePacket` + - Encodes a packet. + - **Parameters** + - `Object`: the packet to encode, has `type` and `data`. + - `data`: can be a `String`, `Number`, `Buffer`, `ArrayBuffer` + - `Boolean`: optional, binary support + - `Function`: callback, returns the encoded packet (`cb(String)`) +- `decodePacket` + - Decodes a packet. Data also available as an ArrayBuffer if requested. + - Returns data as `String` or (`Blob` on browser, `ArrayBuffer` on Node) + - **Parameters** + - `String` | `ArrayBuffer`: the packet to decode, has `type` and `data` + - `String`: optional, the binary type + +- `encodeBase64Packet` + - Encodes a packet with binary data in a base64 string (`String`) + - **Parameters** + - `Object`: the packet to encode, has `type` and `data` + - `Function`: callback, returns the base64 encoded message (`cb(String)`) +- `decodeBase64Packet` + - Decodes a packet encoded in a base64 string. + - **Parameters** + - `String`: the base64 encoded message + - `String`: optional, the binary type + +- `encodePayload` + - Encodes multiple messages (payload). + - If any contents are binary, they will be encoded as base64 strings. Base64 + encoded strings are marked with a b before the length specifier + - **Parameters** + - `Array`: an array of packets + - `Boolean`: optional, binary support + - `Function`: callback, returns the encoded payload (`cb(String)`) +- `decodePayload` + - Decodes data when a payload is maybe expected. Possible binary contents are + decoded from their base64 representation. + - **Parameters** + - `String`: the payload + - `String`: optional, the binary type + - `Function`: callback, returns (cb(`Object`: packet, `Number`:packet index, `Number`:packet total)) + +- `encodePayloadAsBinary` + - Encodes multiple messages (payload) as binary. + - **Parameters** + - `Array`: an array of packets + - `Function`: callback, returns the encoded payload (`cb(Buffer)`) +- `decodePayloadAsBinary` + - Decodes data when a payload is maybe expected. Strings are decoded by + interpreting each byte as a key code for entries marked to start with 0. See + description of encodePayloadAsBinary. + - **Parameters** + - `Buffer`: the buffer + - `String`: optional, the binary type + - `Function`: callback, returns the decoded packet (`cb(Object)`) + +### Browser + +- `encodePayloadAsArrayBuffer` + - Encodes multiple messages (payload) as binary. + - **Parameters** + - `Array`: an array of packets + - `Function`: callback, returns the encoded payload (`cb(ArrayBuffer)`) +- `encodePayloadAsBlob` + - Encodes multiple messages (payload) as blob. + - **Parameters** + - `Array`: an array of packets + - `Function`: callback, returns the encoded payload (`cb(Blob)`) + +## Tests + +Standalone tests can be run with `make test` which will run both node.js and browser tests. + +Browser tests are run using [zuul](https://github.com/defunctzombie/zuul). +(You must have zuul setup with a saucelabs account.) + +You can run the tests locally using the following command: + +``` +./node_modules/.bin/zuul --local 8080 -- test/index.js +``` + +## Support + +The support channels for `engine.io-parser` are the same as `socket.io`: + - irc.freenode.net **#socket.io** + - [Google Groups](http://groups.google.com/group/socket_io) + - [Website](http://socket.io) + +## Development + +To contribute patches, run tests or benchmarks, make sure to clone the +repository: + +```bash +git clone git://github.com/LearnBoost/engine.io-parser.git +``` + +Then: + +```bash +cd engine.io-parser +npm install +``` + +See the `Tests` section above for how to run tests before submitting any patches. + +## License + +MIT diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/index.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/index.js index 469fae09..887727fd 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/index.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/index.js @@ -1,2 +1,2 @@ - -module.exports = require('./lib/'); + +module.exports = require('./lib/'); diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/lib/browser.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/lib/browser.js index 1cc57863..8dc26cdf 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/lib/browser.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/lib/browser.js @@ -1,594 +1,594 @@ -/** - * Module dependencies. - */ - -var keys = require('./keys'); -var hasBinary = require('has-binary'); -var sliceBuffer = require('arraybuffer.slice'); -var base64encoder = require('base64-arraybuffer'); -var after = require('after'); -var utf8 = require('utf8'); - -/** - * Check if we are running an android browser. That requires us to use - * ArrayBuffer with polling transports... - * - * http://ghinda.net/jpeg-blob-ajax-android/ - */ - -var isAndroid = navigator.userAgent.match(/Android/i); - -/** - * Check if we are running in PhantomJS. - * Uploading a Blob with PhantomJS does not work correctly, as reported here: - * https://github.com/ariya/phantomjs/issues/11395 - * @type boolean - */ -var isPhantomJS = /PhantomJS/i.test(navigator.userAgent); - -/** - * When true, avoids using Blobs to encode payloads. - * @type boolean - */ -var dontSendBlobs = isAndroid || isPhantomJS; - -/** - * Current protocol version. - */ - -exports.protocol = 3; - -/** - * Packet types. - */ - -var packets = exports.packets = { - open: 0 // non-ws - , close: 1 // non-ws - , ping: 2 - , pong: 3 - , message: 4 - , upgrade: 5 - , noop: 6 -}; - -var packetslist = keys(packets); - -/** - * Premade error packet. - */ - -var err = { type: 'error', data: 'parser error' }; - -/** - * Create a blob api even for blob builder when vendor prefixes exist - */ - -var Blob = require('blob'); - -/** - * Encodes a packet. - * - * [ ] - * - * Example: - * - * 5hello world - * 3 - * 4 - * - * Binary is encoded in an identical principle - * - * @api private - */ - -exports.encodePacket = function (packet, supportsBinary, utf8encode, callback) { - if ('function' == typeof supportsBinary) { - callback = supportsBinary; - supportsBinary = false; - } - - if ('function' == typeof utf8encode) { - callback = utf8encode; - utf8encode = null; - } - - var data = (packet.data === undefined) - ? undefined - : packet.data.buffer || packet.data; - - if (global.ArrayBuffer && data instanceof ArrayBuffer) { - return encodeArrayBuffer(packet, supportsBinary, callback); - } else if (Blob && data instanceof global.Blob) { - return encodeBlob(packet, supportsBinary, callback); - } - - // might be an object with { base64: true, data: dataAsBase64String } - if (data && data.base64) { - return encodeBase64Object(packet, callback); - } - - // Sending data as a utf-8 string - var encoded = packets[packet.type]; - - // data fragment is optional - if (undefined !== packet.data) { - encoded += utf8encode ? utf8.encode(String(packet.data)) : String(packet.data); - } - - return callback('' + encoded); - -}; - -function encodeBase64Object(packet, callback) { - // packet data is an object { base64: true, data: dataAsBase64String } - var message = 'b' + exports.packets[packet.type] + packet.data.data; - return callback(message); -} - -/** - * Encode packet helpers for binary types - */ - -function encodeArrayBuffer(packet, supportsBinary, callback) { - if (!supportsBinary) { - return exports.encodeBase64Packet(packet, callback); - } - - var data = packet.data; - var contentArray = new Uint8Array(data); - var resultBuffer = new Uint8Array(1 + data.byteLength); - - resultBuffer[0] = packets[packet.type]; - for (var i = 0; i < contentArray.length; i++) { - resultBuffer[i+1] = contentArray[i]; - } - - return callback(resultBuffer.buffer); -} - -function encodeBlobAsArrayBuffer(packet, supportsBinary, callback) { - if (!supportsBinary) { - return exports.encodeBase64Packet(packet, callback); - } - - var fr = new FileReader(); - fr.onload = function() { - packet.data = fr.result; - exports.encodePacket(packet, supportsBinary, true, callback); - }; - return fr.readAsArrayBuffer(packet.data); -} - -function encodeBlob(packet, supportsBinary, callback) { - if (!supportsBinary) { - return exports.encodeBase64Packet(packet, callback); - } - - if (dontSendBlobs) { - return encodeBlobAsArrayBuffer(packet, supportsBinary, callback); - } - - var length = new Uint8Array(1); - length[0] = packets[packet.type]; - var blob = new Blob([length.buffer, packet.data]); - - return callback(blob); -} - -/** - * Encodes a packet with binary data in a base64 string - * - * @param {Object} packet, has `type` and `data` - * @return {String} base64 encoded message - */ - -exports.encodeBase64Packet = function(packet, callback) { - var message = 'b' + exports.packets[packet.type]; - if (Blob && packet.data instanceof global.Blob) { - var fr = new FileReader(); - fr.onload = function() { - var b64 = fr.result.split(',')[1]; - callback(message + b64); - }; - return fr.readAsDataURL(packet.data); - } - - var b64data; - try { - b64data = String.fromCharCode.apply(null, new Uint8Array(packet.data)); - } catch (e) { - // iPhone Safari doesn't let you apply with typed arrays - var typed = new Uint8Array(packet.data); - var basic = new Array(typed.length); - for (var i = 0; i < typed.length; i++) { - basic[i] = typed[i]; - } - b64data = String.fromCharCode.apply(null, basic); - } - message += global.btoa(b64data); - return callback(message); -}; - -/** - * Decodes a packet. Changes format to Blob if requested. - * - * @return {Object} with `type` and `data` (if any) - * @api private - */ - -exports.decodePacket = function (data, binaryType, utf8decode) { - // String data - if (typeof data == 'string' || data === undefined) { - if (data.charAt(0) == 'b') { - return exports.decodeBase64Packet(data.substr(1), binaryType); - } - - if (utf8decode) { - try { - data = utf8.decode(data); - } catch (e) { - return err; - } - } - var type = data.charAt(0); - - if (Number(type) != type || !packetslist[type]) { - return err; - } - - if (data.length > 1) { - return { type: packetslist[type], data: data.substring(1) }; - } else { - return { type: packetslist[type] }; - } - } - - var asArray = new Uint8Array(data); - var type = asArray[0]; - var rest = sliceBuffer(data, 1); - if (Blob && binaryType === 'blob') { - rest = new Blob([rest]); - } - return { type: packetslist[type], data: rest }; -}; - -/** - * Decodes a packet encoded in a base64 string - * - * @param {String} base64 encoded message - * @return {Object} with `type` and `data` (if any) - */ - -exports.decodeBase64Packet = function(msg, binaryType) { - var type = packetslist[msg.charAt(0)]; - if (!global.ArrayBuffer) { - return { type: type, data: { base64: true, data: msg.substr(1) } }; - } - - var data = base64encoder.decode(msg.substr(1)); - - if (binaryType === 'blob' && Blob) { - data = new Blob([data]); - } - - return { type: type, data: data }; -}; - -/** - * Encodes multiple messages (payload). - * - * :data - * - * Example: - * - * 11:hello world2:hi - * - * If any contents are binary, they will be encoded as base64 strings. Base64 - * encoded strings are marked with a b before the length specifier - * - * @param {Array} packets - * @api private - */ - -exports.encodePayload = function (packets, supportsBinary, callback) { - if (typeof supportsBinary == 'function') { - callback = supportsBinary; - supportsBinary = null; - } - - var isBinary = hasBinary(packets); - - if (supportsBinary && isBinary) { - if (Blob && !dontSendBlobs) { - return exports.encodePayloadAsBlob(packets, callback); - } - - return exports.encodePayloadAsArrayBuffer(packets, callback); - } - - if (!packets.length) { - return callback('0:'); - } - - function setLengthHeader(message) { - return message.length + ':' + message; - } - - function encodeOne(packet, doneCallback) { - exports.encodePacket(packet, !isBinary ? false : supportsBinary, true, function(message) { - doneCallback(null, setLengthHeader(message)); - }); - } - - map(packets, encodeOne, function(err, results) { - return callback(results.join('')); - }); -}; - -/** - * Async array map using after - */ - -function map(ary, each, done) { - var result = new Array(ary.length); - var next = after(ary.length, done); - - var eachWithIndex = function(i, el, cb) { - each(el, function(error, msg) { - result[i] = msg; - cb(error, result); - }); - }; - - for (var i = 0; i < ary.length; i++) { - eachWithIndex(i, ary[i], next); - } -} - -/* - * Decodes data when a payload is maybe expected. Possible binary contents are - * decoded from their base64 representation - * - * @param {String} data, callback method - * @api public - */ - -exports.decodePayload = function (data, binaryType, callback) { - if (typeof data != 'string') { - return exports.decodePayloadAsBinary(data, binaryType, callback); - } - - if (typeof binaryType === 'function') { - callback = binaryType; - binaryType = null; - } - - var packet; - if (data == '') { - // parser error - ignoring payload - return callback(err, 0, 1); - } - - var length = '' - , n, msg; - - for (var i = 0, l = data.length; i < l; i++) { - var chr = data.charAt(i); - - if (':' != chr) { - length += chr; - } else { - if ('' == length || (length != (n = Number(length)))) { - // parser error - ignoring payload - return callback(err, 0, 1); - } - - msg = data.substr(i + 1, n); - - if (length != msg.length) { - // parser error - ignoring payload - return callback(err, 0, 1); - } - - if (msg.length) { - packet = exports.decodePacket(msg, binaryType, true); - - if (err.type == packet.type && err.data == packet.data) { - // parser error in individual packet - ignoring payload - return callback(err, 0, 1); - } - - var ret = callback(packet, i + n, l); - if (false === ret) return; - } - - // advance cursor - i += n; - length = ''; - } - } - - if (length != '') { - // parser error - ignoring payload - return callback(err, 0, 1); - } - -}; - -/** - * Encodes multiple messages (payload) as binary. - * - * <1 = binary, 0 = string>[...] - * - * Example: - * 1 3 255 1 2 3, if the binary contents are interpreted as 8 bit integers - * - * @param {Array} packets - * @return {ArrayBuffer} encoded payload - * @api private - */ - -exports.encodePayloadAsArrayBuffer = function(packets, callback) { - if (!packets.length) { - return callback(new ArrayBuffer(0)); - } - - function encodeOne(packet, doneCallback) { - exports.encodePacket(packet, true, true, function(data) { - return doneCallback(null, data); - }); - } - - map(packets, encodeOne, function(err, encodedPackets) { - var totalLength = encodedPackets.reduce(function(acc, p) { - var len; - if (typeof p === 'string'){ - len = p.length; - } else { - len = p.byteLength; - } - return acc + len.toString().length + len + 2; // string/binary identifier + separator = 2 - }, 0); - - var resultArray = new Uint8Array(totalLength); - - var bufferIndex = 0; - encodedPackets.forEach(function(p) { - var isString = typeof p === 'string'; - var ab = p; - if (isString) { - var view = new Uint8Array(p.length); - for (var i = 0; i < p.length; i++) { - view[i] = p.charCodeAt(i); - } - ab = view.buffer; - } - - if (isString) { // not true binary - resultArray[bufferIndex++] = 0; - } else { // true binary - resultArray[bufferIndex++] = 1; - } - - var lenStr = ab.byteLength.toString(); - for (var i = 0; i < lenStr.length; i++) { - resultArray[bufferIndex++] = parseInt(lenStr[i]); - } - resultArray[bufferIndex++] = 255; - - var view = new Uint8Array(ab); - for (var i = 0; i < view.length; i++) { - resultArray[bufferIndex++] = view[i]; - } - }); - - return callback(resultArray.buffer); - }); -}; - -/** - * Encode as Blob - */ - -exports.encodePayloadAsBlob = function(packets, callback) { - function encodeOne(packet, doneCallback) { - exports.encodePacket(packet, true, true, function(encoded) { - var binaryIdentifier = new Uint8Array(1); - binaryIdentifier[0] = 1; - if (typeof encoded === 'string') { - var view = new Uint8Array(encoded.length); - for (var i = 0; i < encoded.length; i++) { - view[i] = encoded.charCodeAt(i); - } - encoded = view.buffer; - binaryIdentifier[0] = 0; - } - - var len = (encoded instanceof ArrayBuffer) - ? encoded.byteLength - : encoded.size; - - var lenStr = len.toString(); - var lengthAry = new Uint8Array(lenStr.length + 1); - for (var i = 0; i < lenStr.length; i++) { - lengthAry[i] = parseInt(lenStr[i]); - } - lengthAry[lenStr.length] = 255; - - if (Blob) { - var blob = new Blob([binaryIdentifier.buffer, lengthAry.buffer, encoded]); - doneCallback(null, blob); - } - }); - } - - map(packets, encodeOne, function(err, results) { - return callback(new Blob(results)); - }); -}; - -/* - * Decodes data when a payload is maybe expected. Strings are decoded by - * interpreting each byte as a key code for entries marked to start with 0. See - * description of encodePayloadAsBinary - * - * @param {ArrayBuffer} data, callback method - * @api public - */ - -exports.decodePayloadAsBinary = function (data, binaryType, callback) { - if (typeof binaryType === 'function') { - callback = binaryType; - binaryType = null; - } - - var bufferTail = data; - var buffers = []; - - var numberTooLong = false; - while (bufferTail.byteLength > 0) { - var tailArray = new Uint8Array(bufferTail); - var isString = tailArray[0] === 0; - var msgLength = ''; - - for (var i = 1; ; i++) { - if (tailArray[i] == 255) break; - - if (msgLength.length > 310) { - numberTooLong = true; - break; - } - - msgLength += tailArray[i]; - } - - if(numberTooLong) return callback(err, 0, 1); - - bufferTail = sliceBuffer(bufferTail, 2 + msgLength.length); - msgLength = parseInt(msgLength); - - var msg = sliceBuffer(bufferTail, 0, msgLength); - if (isString) { - try { - msg = String.fromCharCode.apply(null, new Uint8Array(msg)); - } catch (e) { - // iPhone Safari doesn't let you apply to typed arrays - var typed = new Uint8Array(msg); - msg = ''; - for (var i = 0; i < typed.length; i++) { - msg += String.fromCharCode(typed[i]); - } - } - } - - buffers.push(msg); - bufferTail = sliceBuffer(bufferTail, msgLength); - } - - var total = buffers.length; - buffers.forEach(function(buffer, i) { - callback(exports.decodePacket(buffer, binaryType, true), i, total); - }); -}; +/** + * Module dependencies. + */ + +var keys = require('./keys'); +var hasBinary = require('has-binary'); +var sliceBuffer = require('arraybuffer.slice'); +var base64encoder = require('base64-arraybuffer'); +var after = require('after'); +var utf8 = require('utf8'); + +/** + * Check if we are running an android browser. That requires us to use + * ArrayBuffer with polling transports... + * + * http://ghinda.net/jpeg-blob-ajax-android/ + */ + +var isAndroid = navigator.userAgent.match(/Android/i); + +/** + * Check if we are running in PhantomJS. + * Uploading a Blob with PhantomJS does not work correctly, as reported here: + * https://github.com/ariya/phantomjs/issues/11395 + * @type boolean + */ +var isPhantomJS = /PhantomJS/i.test(navigator.userAgent); + +/** + * When true, avoids using Blobs to encode payloads. + * @type boolean + */ +var dontSendBlobs = isAndroid || isPhantomJS; + +/** + * Current protocol version. + */ + +exports.protocol = 3; + +/** + * Packet types. + */ + +var packets = exports.packets = { + open: 0 // non-ws + , close: 1 // non-ws + , ping: 2 + , pong: 3 + , message: 4 + , upgrade: 5 + , noop: 6 +}; + +var packetslist = keys(packets); + +/** + * Premade error packet. + */ + +var err = { type: 'error', data: 'parser error' }; + +/** + * Create a blob api even for blob builder when vendor prefixes exist + */ + +var Blob = require('blob'); + +/** + * Encodes a packet. + * + * [ ] + * + * Example: + * + * 5hello world + * 3 + * 4 + * + * Binary is encoded in an identical principle + * + * @api private + */ + +exports.encodePacket = function (packet, supportsBinary, utf8encode, callback) { + if ('function' == typeof supportsBinary) { + callback = supportsBinary; + supportsBinary = false; + } + + if ('function' == typeof utf8encode) { + callback = utf8encode; + utf8encode = null; + } + + var data = (packet.data === undefined) + ? undefined + : packet.data.buffer || packet.data; + + if (global.ArrayBuffer && data instanceof ArrayBuffer) { + return encodeArrayBuffer(packet, supportsBinary, callback); + } else if (Blob && data instanceof global.Blob) { + return encodeBlob(packet, supportsBinary, callback); + } + + // might be an object with { base64: true, data: dataAsBase64String } + if (data && data.base64) { + return encodeBase64Object(packet, callback); + } + + // Sending data as a utf-8 string + var encoded = packets[packet.type]; + + // data fragment is optional + if (undefined !== packet.data) { + encoded += utf8encode ? utf8.encode(String(packet.data)) : String(packet.data); + } + + return callback('' + encoded); + +}; + +function encodeBase64Object(packet, callback) { + // packet data is an object { base64: true, data: dataAsBase64String } + var message = 'b' + exports.packets[packet.type] + packet.data.data; + return callback(message); +} + +/** + * Encode packet helpers for binary types + */ + +function encodeArrayBuffer(packet, supportsBinary, callback) { + if (!supportsBinary) { + return exports.encodeBase64Packet(packet, callback); + } + + var data = packet.data; + var contentArray = new Uint8Array(data); + var resultBuffer = new Uint8Array(1 + data.byteLength); + + resultBuffer[0] = packets[packet.type]; + for (var i = 0; i < contentArray.length; i++) { + resultBuffer[i+1] = contentArray[i]; + } + + return callback(resultBuffer.buffer); +} + +function encodeBlobAsArrayBuffer(packet, supportsBinary, callback) { + if (!supportsBinary) { + return exports.encodeBase64Packet(packet, callback); + } + + var fr = new FileReader(); + fr.onload = function() { + packet.data = fr.result; + exports.encodePacket(packet, supportsBinary, true, callback); + }; + return fr.readAsArrayBuffer(packet.data); +} + +function encodeBlob(packet, supportsBinary, callback) { + if (!supportsBinary) { + return exports.encodeBase64Packet(packet, callback); + } + + if (dontSendBlobs) { + return encodeBlobAsArrayBuffer(packet, supportsBinary, callback); + } + + var length = new Uint8Array(1); + length[0] = packets[packet.type]; + var blob = new Blob([length.buffer, packet.data]); + + return callback(blob); +} + +/** + * Encodes a packet with binary data in a base64 string + * + * @param {Object} packet, has `type` and `data` + * @return {String} base64 encoded message + */ + +exports.encodeBase64Packet = function(packet, callback) { + var message = 'b' + exports.packets[packet.type]; + if (Blob && packet.data instanceof global.Blob) { + var fr = new FileReader(); + fr.onload = function() { + var b64 = fr.result.split(',')[1]; + callback(message + b64); + }; + return fr.readAsDataURL(packet.data); + } + + var b64data; + try { + b64data = String.fromCharCode.apply(null, new Uint8Array(packet.data)); + } catch (e) { + // iPhone Safari doesn't let you apply with typed arrays + var typed = new Uint8Array(packet.data); + var basic = new Array(typed.length); + for (var i = 0; i < typed.length; i++) { + basic[i] = typed[i]; + } + b64data = String.fromCharCode.apply(null, basic); + } + message += global.btoa(b64data); + return callback(message); +}; + +/** + * Decodes a packet. Changes format to Blob if requested. + * + * @return {Object} with `type` and `data` (if any) + * @api private + */ + +exports.decodePacket = function (data, binaryType, utf8decode) { + // String data + if (typeof data == 'string' || data === undefined) { + if (data.charAt(0) == 'b') { + return exports.decodeBase64Packet(data.substr(1), binaryType); + } + + if (utf8decode) { + try { + data = utf8.decode(data); + } catch (e) { + return err; + } + } + var type = data.charAt(0); + + if (Number(type) != type || !packetslist[type]) { + return err; + } + + if (data.length > 1) { + return { type: packetslist[type], data: data.substring(1) }; + } else { + return { type: packetslist[type] }; + } + } + + var asArray = new Uint8Array(data); + var type = asArray[0]; + var rest = sliceBuffer(data, 1); + if (Blob && binaryType === 'blob') { + rest = new Blob([rest]); + } + return { type: packetslist[type], data: rest }; +}; + +/** + * Decodes a packet encoded in a base64 string + * + * @param {String} base64 encoded message + * @return {Object} with `type` and `data` (if any) + */ + +exports.decodeBase64Packet = function(msg, binaryType) { + var type = packetslist[msg.charAt(0)]; + if (!global.ArrayBuffer) { + return { type: type, data: { base64: true, data: msg.substr(1) } }; + } + + var data = base64encoder.decode(msg.substr(1)); + + if (binaryType === 'blob' && Blob) { + data = new Blob([data]); + } + + return { type: type, data: data }; +}; + +/** + * Encodes multiple messages (payload). + * + * :data + * + * Example: + * + * 11:hello world2:hi + * + * If any contents are binary, they will be encoded as base64 strings. Base64 + * encoded strings are marked with a b before the length specifier + * + * @param {Array} packets + * @api private + */ + +exports.encodePayload = function (packets, supportsBinary, callback) { + if (typeof supportsBinary == 'function') { + callback = supportsBinary; + supportsBinary = null; + } + + var isBinary = hasBinary(packets); + + if (supportsBinary && isBinary) { + if (Blob && !dontSendBlobs) { + return exports.encodePayloadAsBlob(packets, callback); + } + + return exports.encodePayloadAsArrayBuffer(packets, callback); + } + + if (!packets.length) { + return callback('0:'); + } + + function setLengthHeader(message) { + return message.length + ':' + message; + } + + function encodeOne(packet, doneCallback) { + exports.encodePacket(packet, !isBinary ? false : supportsBinary, true, function(message) { + doneCallback(null, setLengthHeader(message)); + }); + } + + map(packets, encodeOne, function(err, results) { + return callback(results.join('')); + }); +}; + +/** + * Async array map using after + */ + +function map(ary, each, done) { + var result = new Array(ary.length); + var next = after(ary.length, done); + + var eachWithIndex = function(i, el, cb) { + each(el, function(error, msg) { + result[i] = msg; + cb(error, result); + }); + }; + + for (var i = 0; i < ary.length; i++) { + eachWithIndex(i, ary[i], next); + } +} + +/* + * Decodes data when a payload is maybe expected. Possible binary contents are + * decoded from their base64 representation + * + * @param {String} data, callback method + * @api public + */ + +exports.decodePayload = function (data, binaryType, callback) { + if (typeof data != 'string') { + return exports.decodePayloadAsBinary(data, binaryType, callback); + } + + if (typeof binaryType === 'function') { + callback = binaryType; + binaryType = null; + } + + var packet; + if (data == '') { + // parser error - ignoring payload + return callback(err, 0, 1); + } + + var length = '' + , n, msg; + + for (var i = 0, l = data.length; i < l; i++) { + var chr = data.charAt(i); + + if (':' != chr) { + length += chr; + } else { + if ('' == length || (length != (n = Number(length)))) { + // parser error - ignoring payload + return callback(err, 0, 1); + } + + msg = data.substr(i + 1, n); + + if (length != msg.length) { + // parser error - ignoring payload + return callback(err, 0, 1); + } + + if (msg.length) { + packet = exports.decodePacket(msg, binaryType, true); + + if (err.type == packet.type && err.data == packet.data) { + // parser error in individual packet - ignoring payload + return callback(err, 0, 1); + } + + var ret = callback(packet, i + n, l); + if (false === ret) return; + } + + // advance cursor + i += n; + length = ''; + } + } + + if (length != '') { + // parser error - ignoring payload + return callback(err, 0, 1); + } + +}; + +/** + * Encodes multiple messages (payload) as binary. + * + * <1 = binary, 0 = string>[...] + * + * Example: + * 1 3 255 1 2 3, if the binary contents are interpreted as 8 bit integers + * + * @param {Array} packets + * @return {ArrayBuffer} encoded payload + * @api private + */ + +exports.encodePayloadAsArrayBuffer = function(packets, callback) { + if (!packets.length) { + return callback(new ArrayBuffer(0)); + } + + function encodeOne(packet, doneCallback) { + exports.encodePacket(packet, true, true, function(data) { + return doneCallback(null, data); + }); + } + + map(packets, encodeOne, function(err, encodedPackets) { + var totalLength = encodedPackets.reduce(function(acc, p) { + var len; + if (typeof p === 'string'){ + len = p.length; + } else { + len = p.byteLength; + } + return acc + len.toString().length + len + 2; // string/binary identifier + separator = 2 + }, 0); + + var resultArray = new Uint8Array(totalLength); + + var bufferIndex = 0; + encodedPackets.forEach(function(p) { + var isString = typeof p === 'string'; + var ab = p; + if (isString) { + var view = new Uint8Array(p.length); + for (var i = 0; i < p.length; i++) { + view[i] = p.charCodeAt(i); + } + ab = view.buffer; + } + + if (isString) { // not true binary + resultArray[bufferIndex++] = 0; + } else { // true binary + resultArray[bufferIndex++] = 1; + } + + var lenStr = ab.byteLength.toString(); + for (var i = 0; i < lenStr.length; i++) { + resultArray[bufferIndex++] = parseInt(lenStr[i]); + } + resultArray[bufferIndex++] = 255; + + var view = new Uint8Array(ab); + for (var i = 0; i < view.length; i++) { + resultArray[bufferIndex++] = view[i]; + } + }); + + return callback(resultArray.buffer); + }); +}; + +/** + * Encode as Blob + */ + +exports.encodePayloadAsBlob = function(packets, callback) { + function encodeOne(packet, doneCallback) { + exports.encodePacket(packet, true, true, function(encoded) { + var binaryIdentifier = new Uint8Array(1); + binaryIdentifier[0] = 1; + if (typeof encoded === 'string') { + var view = new Uint8Array(encoded.length); + for (var i = 0; i < encoded.length; i++) { + view[i] = encoded.charCodeAt(i); + } + encoded = view.buffer; + binaryIdentifier[0] = 0; + } + + var len = (encoded instanceof ArrayBuffer) + ? encoded.byteLength + : encoded.size; + + var lenStr = len.toString(); + var lengthAry = new Uint8Array(lenStr.length + 1); + for (var i = 0; i < lenStr.length; i++) { + lengthAry[i] = parseInt(lenStr[i]); + } + lengthAry[lenStr.length] = 255; + + if (Blob) { + var blob = new Blob([binaryIdentifier.buffer, lengthAry.buffer, encoded]); + doneCallback(null, blob); + } + }); + } + + map(packets, encodeOne, function(err, results) { + return callback(new Blob(results)); + }); +}; + +/* + * Decodes data when a payload is maybe expected. Strings are decoded by + * interpreting each byte as a key code for entries marked to start with 0. See + * description of encodePayloadAsBinary + * + * @param {ArrayBuffer} data, callback method + * @api public + */ + +exports.decodePayloadAsBinary = function (data, binaryType, callback) { + if (typeof binaryType === 'function') { + callback = binaryType; + binaryType = null; + } + + var bufferTail = data; + var buffers = []; + + var numberTooLong = false; + while (bufferTail.byteLength > 0) { + var tailArray = new Uint8Array(bufferTail); + var isString = tailArray[0] === 0; + var msgLength = ''; + + for (var i = 1; ; i++) { + if (tailArray[i] == 255) break; + + if (msgLength.length > 310) { + numberTooLong = true; + break; + } + + msgLength += tailArray[i]; + } + + if(numberTooLong) return callback(err, 0, 1); + + bufferTail = sliceBuffer(bufferTail, 2 + msgLength.length); + msgLength = parseInt(msgLength); + + var msg = sliceBuffer(bufferTail, 0, msgLength); + if (isString) { + try { + msg = String.fromCharCode.apply(null, new Uint8Array(msg)); + } catch (e) { + // iPhone Safari doesn't let you apply to typed arrays + var typed = new Uint8Array(msg); + msg = ''; + for (var i = 0; i < typed.length; i++) { + msg += String.fromCharCode(typed[i]); + } + } + } + + buffers.push(msg); + bufferTail = sliceBuffer(bufferTail, msgLength); + } + + var total = buffers.length; + buffers.forEach(function(buffer, i) { + callback(exports.decodePacket(buffer, binaryType, true), i, total); + }); +}; diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/lib/index.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/lib/index.js index fcb4e9c7..836b1c61 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/lib/index.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/lib/index.js @@ -1,460 +1,460 @@ -/** - * Module dependencies. - */ - -var utf8 = require('utf8'); -var after = require('after'); -var keys = require('./keys'); - -/** - * Current protocol version. - */ -exports.protocol = 3; - -/** - * Packet types. - */ - -var packets = exports.packets = { - open: 0 // non-ws - , close: 1 // non-ws - , ping: 2 - , pong: 3 - , message: 4 - , upgrade: 5 - , noop: 6 -}; - -var packetslist = keys(packets); - -/** - * Premade error packet. - */ - -var err = { type: 'error', data: 'parser error' }; - -/** - * Encodes a packet. - * - * [ ] - * - * Example: - * - * 5hello world - * 3 - * 4 - * - * Binary is encoded in an identical principle - * - * @api private - */ - -exports.encodePacket = function (packet, supportsBinary, utf8encode, callback) { - if ('function' == typeof supportsBinary) { - callback = supportsBinary; - supportsBinary = null; - } - - if ('function' == typeof utf8encode ) { - callback = utf8encode; - utf8encode = null; - } - - if (Buffer.isBuffer(packet.data)) { - return encodeBuffer(packet, supportsBinary, callback); - } else if (packet.data && (packet.data.buffer || packet.data) instanceof ArrayBuffer) { - packet.data = arrayBufferToBuffer(packet.data); - return encodeBuffer(packet, supportsBinary, callback); - } - - // Sending data as a utf-8 string - var encoded = packets[packet.type]; - - // data fragment is optional - if (undefined !== packet.data) { - encoded += utf8encode ? utf8.encode(String(packet.data)) : String(packet.data); - } - - return callback('' + encoded); -}; - -/** - * Encode Buffer data - */ - -function encodeBuffer(packet, supportsBinary, callback) { - var data = packet.data; - if (!supportsBinary) { - return exports.encodeBase64Packet(packet, callback); - } - - var typeBuffer = new Buffer(1); - typeBuffer[0] = packets[packet.type]; - return callback(Buffer.concat([typeBuffer, data])); -} - -/** - * Encodes a packet with binary data in a base64 string - * - * @param {Object} packet, has `type` and `data` - * @return {String} base64 encoded message - */ - -exports.encodeBase64Packet = function(packet, callback){ - if (!Buffer.isBuffer(packet.data)) { - packet.data = arrayBufferToBuffer(packet.data); - } - - var message = 'b' + packets[packet.type]; - message += packet.data.toString('base64'); - return callback(message); -}; - -/** - * Decodes a packet. Data also available as an ArrayBuffer if requested. - * - * @return {Object} with `type` and `data` (if any) - * @api private - */ - -exports.decodePacket = function (data, binaryType, utf8decode) { - // String data - if (typeof data == 'string' || data === undefined) { - if (data.charAt(0) == 'b') { - return exports.decodeBase64Packet(data.substr(1), binaryType); - } - - var type = data.charAt(0); - if (utf8decode) { - try { - data = utf8.decode(data); - } catch (e) { - return err; - } - } - - if (Number(type) != type || !packetslist[type]) { - return err; - } - - if (data.length > 1) { - return { type: packetslist[type], data: data.substring(1) }; - } else { - return { type: packetslist[type] }; - } - } - - // Binary data - if (binaryType === 'arraybuffer') { - var type = data[0]; - var intArray = new Uint8Array(data.length - 1); - for (var i = 1; i < data.length; i++) { - intArray[i - 1] = data[i]; - } - return { type: packetslist[type], data: intArray.buffer }; - } - var type = data[0]; - return { type: packetslist[type], data: data.slice(1) }; -}; - -/** - * Decodes a packet encoded in a base64 string. - * - * @param {String} base64 encoded message - * @return {Object} with `type` and `data` (if any) - */ - -exports.decodeBase64Packet = function(msg, binaryType) { - var type = packetslist[msg.charAt(0)]; - var data = new Buffer(msg.substr(1), 'base64'); - if (binaryType === 'arraybuffer') { - var abv = new Uint8Array(data.length); - for (var i = 0; i < abv.length; i++){ - abv[i] = data[i]; - } - data = abv.buffer; - } - return { type: type, data: data }; -}; - -/** - * Encodes multiple messages (payload). - * - * :data - * - * Example: - * - * 11:hello world2:hi - * - * If any contents are binary, they will be encoded as base64 strings. Base64 - * encoded strings are marked with a b before the length specifier - * - * @param {Array} packets - * @api private - */ - -exports.encodePayload = function (packets, supportsBinary, callback) { - if (typeof supportsBinary == 'function') { - callback = supportsBinary; - supportsBinary = null; - } - - if (supportsBinary) { - return exports.encodePayloadAsBinary(packets, callback); - } - - if (!packets.length) { - return callback('0:'); - } - - function setLengthHeader(message) { - return message.length + ':' + message; - } - - function encodeOne(packet, doneCallback) { - exports.encodePacket(packet, supportsBinary, true, function(message) { - doneCallback(null, setLengthHeader(message)); - }); - } - - map(packets, encodeOne, function(err, results) { - return callback(results.join('')); - }); -}; - -/** - * Async array map using after - */ - -function map(ary, each, done) { - var result = new Array(ary.length); - var next = after(ary.length, done); - - var eachWithIndex = function(i, el, cb) { - each(el, function(error, msg) { - result[i] = msg; - cb(error, result); - }); - }; - - for (var i = 0; i < ary.length; i++) { - eachWithIndex(i, ary[i], next); - } -} - -/* - * Decodes data when a payload is maybe expected. Possible binary contents are - * decoded from their base64 representation - * - * @param {String} data, callback method - * @api public - */ - -exports.decodePayload = function (data, binaryType, callback) { - if ('string' != typeof data) { - return exports.decodePayloadAsBinary(data, binaryType, callback); - } - - if (typeof binaryType === 'function') { - callback = binaryType; - binaryType = null; - } - - var packet; - if (data == '') { - // parser error - ignoring payload - return callback(err, 0, 1); - } - - var length = '' - , n, msg; - - for (var i = 0, l = data.length; i < l; i++) { - var chr = data.charAt(i); - - if (':' != chr) { - length += chr; - } else { - if ('' == length || (length != (n = Number(length)))) { - // parser error - ignoring payload - return callback(err, 0, 1); - } - - msg = data.substr(i + 1, n); - - if (length != msg.length) { - // parser error - ignoring payload - return callback(err, 0, 1); - } - - if (msg.length) { - packet = exports.decodePacket(msg, binaryType, true); - - if (err.type == packet.type && err.data == packet.data) { - // parser error in individual packet - ignoring payload - return callback(err, 0, 1); - } - - var ret = callback(packet, i + n, l); - if (false === ret) return; - } - - // advance cursor - i += n; - length = ''; - } - } - - if (length != '') { - // parser error - ignoring payload - return callback(err, 0, 1); - } - -}; - -/** - * - * Converts a buffer to a utf8.js encoded string - * - * @api private - */ - -function bufferToString(buffer) { - var str = ''; - for (var i = 0; i < buffer.length; i++) { - str += String.fromCharCode(buffer[i]); - } - return str; -} - -/** - * - * Converts a utf8.js encoded string to a buffer - * - * @api private - */ - -function stringToBuffer(string) { - var buf = new Buffer(string.length); - for (var i = 0; i < string.length; i++) { - buf.writeUInt8(string.charCodeAt(i), i); - } - return buf; -} - -/** - * - * Converts an ArrayBuffer to a Buffer - * - * @api private - */ - -function arrayBufferToBuffer(data) { - // data is either an ArrayBuffer or ArrayBufferView. - var array = new Uint8Array(data.buffer || data); - var length = data.byteLength || data.length; - var offset = data.byteOffset || 0; - var buffer = new Buffer(length); - - for (var i = 0; i < length; i++) { - buffer[i] = array[offset + i]; - } - return buffer; -} - -/** - * Encodes multiple messages (payload) as binary. - * - * <1 = binary, 0 = string>[...] - * - * Example: - * 1 3 255 1 2 3, if the binary contents are interpreted as 8 bit integers - * - * @param {Array} packets - * @return {Buffer} encoded payload - * @api private - */ - -exports.encodePayloadAsBinary = function (packets, callback) { - if (!packets.length) { - return callback(new Buffer(0)); - } - - function encodeOne(p, doneCallback) { - exports.encodePacket(p, true, true, function(packet) { - - if (typeof packet === 'string') { - var encodingLength = '' + packet.length; - var sizeBuffer = new Buffer(encodingLength.length + 2); - sizeBuffer[0] = 0; // is a string (not true binary = 0) - for (var i = 0; i < encodingLength.length; i++) { - sizeBuffer[i + 1] = parseInt(encodingLength[i], 10); - } - sizeBuffer[sizeBuffer.length - 1] = 255; - return doneCallback(null, Buffer.concat([sizeBuffer, stringToBuffer(packet)])); - } - - var encodingLength = '' + packet.length; - var sizeBuffer = new Buffer(encodingLength.length + 2); - sizeBuffer[0] = 1; // is binary (true binary = 1) - for (var i = 0; i < encodingLength.length; i++) { - sizeBuffer[i + 1] = parseInt(encodingLength[i], 10); - } - sizeBuffer[sizeBuffer.length - 1] = 255; - doneCallback(null, Buffer.concat([sizeBuffer, packet])); - }); - } - - map(packets, encodeOne, function(err, results) { - return callback(Buffer.concat(results)); - }); -}; - -/* - * Decodes data when a payload is maybe expected. Strings are decoded by - * interpreting each byte as a key code for entries marked to start with 0. See - * description of encodePayloadAsBinary - - * @param {Buffer} data, callback method - * @api public - */ - -exports.decodePayloadAsBinary = function (data, binaryType, callback) { - if (typeof binaryType === 'function') { - callback = binaryType; - binaryType = null; - } - - var bufferTail = data; - var buffers = []; - - while (bufferTail.length > 0) { - var strLen = ''; - var isString = bufferTail[0] === 0; - var numberTooLong = false; - for (var i = 1; ; i++) { - if (bufferTail[i] == 255) break; - // 310 = char length of Number.MAX_VALUE - if (strLen.length > 310) { - numberTooLong = true; - break; - } - strLen += '' + bufferTail[i]; - } - if(numberTooLong) return callback(err, 0, 1); - bufferTail = bufferTail.slice(strLen.length + 1); - - var msgLength = parseInt(strLen, 10); - - var msg = bufferTail.slice(1, msgLength + 1); - if (isString) msg = bufferToString(msg); - buffers.push(msg); - bufferTail = bufferTail.slice(msgLength + 1); - } - - var total = buffers.length; - buffers.forEach(function(buffer, i) { - callback(exports.decodePacket(buffer, binaryType, true), i, total); - }); -}; +/** + * Module dependencies. + */ + +var utf8 = require('utf8'); +var after = require('after'); +var keys = require('./keys'); + +/** + * Current protocol version. + */ +exports.protocol = 3; + +/** + * Packet types. + */ + +var packets = exports.packets = { + open: 0 // non-ws + , close: 1 // non-ws + , ping: 2 + , pong: 3 + , message: 4 + , upgrade: 5 + , noop: 6 +}; + +var packetslist = keys(packets); + +/** + * Premade error packet. + */ + +var err = { type: 'error', data: 'parser error' }; + +/** + * Encodes a packet. + * + * [ ] + * + * Example: + * + * 5hello world + * 3 + * 4 + * + * Binary is encoded in an identical principle + * + * @api private + */ + +exports.encodePacket = function (packet, supportsBinary, utf8encode, callback) { + if ('function' == typeof supportsBinary) { + callback = supportsBinary; + supportsBinary = null; + } + + if ('function' == typeof utf8encode ) { + callback = utf8encode; + utf8encode = null; + } + + if (Buffer.isBuffer(packet.data)) { + return encodeBuffer(packet, supportsBinary, callback); + } else if (packet.data && (packet.data.buffer || packet.data) instanceof ArrayBuffer) { + packet.data = arrayBufferToBuffer(packet.data); + return encodeBuffer(packet, supportsBinary, callback); + } + + // Sending data as a utf-8 string + var encoded = packets[packet.type]; + + // data fragment is optional + if (undefined !== packet.data) { + encoded += utf8encode ? utf8.encode(String(packet.data)) : String(packet.data); + } + + return callback('' + encoded); +}; + +/** + * Encode Buffer data + */ + +function encodeBuffer(packet, supportsBinary, callback) { + var data = packet.data; + if (!supportsBinary) { + return exports.encodeBase64Packet(packet, callback); + } + + var typeBuffer = new Buffer(1); + typeBuffer[0] = packets[packet.type]; + return callback(Buffer.concat([typeBuffer, data])); +} + +/** + * Encodes a packet with binary data in a base64 string + * + * @param {Object} packet, has `type` and `data` + * @return {String} base64 encoded message + */ + +exports.encodeBase64Packet = function(packet, callback){ + if (!Buffer.isBuffer(packet.data)) { + packet.data = arrayBufferToBuffer(packet.data); + } + + var message = 'b' + packets[packet.type]; + message += packet.data.toString('base64'); + return callback(message); +}; + +/** + * Decodes a packet. Data also available as an ArrayBuffer if requested. + * + * @return {Object} with `type` and `data` (if any) + * @api private + */ + +exports.decodePacket = function (data, binaryType, utf8decode) { + // String data + if (typeof data == 'string' || data === undefined) { + if (data.charAt(0) == 'b') { + return exports.decodeBase64Packet(data.substr(1), binaryType); + } + + var type = data.charAt(0); + if (utf8decode) { + try { + data = utf8.decode(data); + } catch (e) { + return err; + } + } + + if (Number(type) != type || !packetslist[type]) { + return err; + } + + if (data.length > 1) { + return { type: packetslist[type], data: data.substring(1) }; + } else { + return { type: packetslist[type] }; + } + } + + // Binary data + if (binaryType === 'arraybuffer') { + var type = data[0]; + var intArray = new Uint8Array(data.length - 1); + for (var i = 1; i < data.length; i++) { + intArray[i - 1] = data[i]; + } + return { type: packetslist[type], data: intArray.buffer }; + } + var type = data[0]; + return { type: packetslist[type], data: data.slice(1) }; +}; + +/** + * Decodes a packet encoded in a base64 string. + * + * @param {String} base64 encoded message + * @return {Object} with `type` and `data` (if any) + */ + +exports.decodeBase64Packet = function(msg, binaryType) { + var type = packetslist[msg.charAt(0)]; + var data = new Buffer(msg.substr(1), 'base64'); + if (binaryType === 'arraybuffer') { + var abv = new Uint8Array(data.length); + for (var i = 0; i < abv.length; i++){ + abv[i] = data[i]; + } + data = abv.buffer; + } + return { type: type, data: data }; +}; + +/** + * Encodes multiple messages (payload). + * + * :data + * + * Example: + * + * 11:hello world2:hi + * + * If any contents are binary, they will be encoded as base64 strings. Base64 + * encoded strings are marked with a b before the length specifier + * + * @param {Array} packets + * @api private + */ + +exports.encodePayload = function (packets, supportsBinary, callback) { + if (typeof supportsBinary == 'function') { + callback = supportsBinary; + supportsBinary = null; + } + + if (supportsBinary) { + return exports.encodePayloadAsBinary(packets, callback); + } + + if (!packets.length) { + return callback('0:'); + } + + function setLengthHeader(message) { + return message.length + ':' + message; + } + + function encodeOne(packet, doneCallback) { + exports.encodePacket(packet, supportsBinary, true, function(message) { + doneCallback(null, setLengthHeader(message)); + }); + } + + map(packets, encodeOne, function(err, results) { + return callback(results.join('')); + }); +}; + +/** + * Async array map using after + */ + +function map(ary, each, done) { + var result = new Array(ary.length); + var next = after(ary.length, done); + + var eachWithIndex = function(i, el, cb) { + each(el, function(error, msg) { + result[i] = msg; + cb(error, result); + }); + }; + + for (var i = 0; i < ary.length; i++) { + eachWithIndex(i, ary[i], next); + } +} + +/* + * Decodes data when a payload is maybe expected. Possible binary contents are + * decoded from their base64 representation + * + * @param {String} data, callback method + * @api public + */ + +exports.decodePayload = function (data, binaryType, callback) { + if ('string' != typeof data) { + return exports.decodePayloadAsBinary(data, binaryType, callback); + } + + if (typeof binaryType === 'function') { + callback = binaryType; + binaryType = null; + } + + var packet; + if (data == '') { + // parser error - ignoring payload + return callback(err, 0, 1); + } + + var length = '' + , n, msg; + + for (var i = 0, l = data.length; i < l; i++) { + var chr = data.charAt(i); + + if (':' != chr) { + length += chr; + } else { + if ('' == length || (length != (n = Number(length)))) { + // parser error - ignoring payload + return callback(err, 0, 1); + } + + msg = data.substr(i + 1, n); + + if (length != msg.length) { + // parser error - ignoring payload + return callback(err, 0, 1); + } + + if (msg.length) { + packet = exports.decodePacket(msg, binaryType, true); + + if (err.type == packet.type && err.data == packet.data) { + // parser error in individual packet - ignoring payload + return callback(err, 0, 1); + } + + var ret = callback(packet, i + n, l); + if (false === ret) return; + } + + // advance cursor + i += n; + length = ''; + } + } + + if (length != '') { + // parser error - ignoring payload + return callback(err, 0, 1); + } + +}; + +/** + * + * Converts a buffer to a utf8.js encoded string + * + * @api private + */ + +function bufferToString(buffer) { + var str = ''; + for (var i = 0; i < buffer.length; i++) { + str += String.fromCharCode(buffer[i]); + } + return str; +} + +/** + * + * Converts a utf8.js encoded string to a buffer + * + * @api private + */ + +function stringToBuffer(string) { + var buf = new Buffer(string.length); + for (var i = 0; i < string.length; i++) { + buf.writeUInt8(string.charCodeAt(i), i); + } + return buf; +} + +/** + * + * Converts an ArrayBuffer to a Buffer + * + * @api private + */ + +function arrayBufferToBuffer(data) { + // data is either an ArrayBuffer or ArrayBufferView. + var array = new Uint8Array(data.buffer || data); + var length = data.byteLength || data.length; + var offset = data.byteOffset || 0; + var buffer = new Buffer(length); + + for (var i = 0; i < length; i++) { + buffer[i] = array[offset + i]; + } + return buffer; +} + +/** + * Encodes multiple messages (payload) as binary. + * + * <1 = binary, 0 = string>[...] + * + * Example: + * 1 3 255 1 2 3, if the binary contents are interpreted as 8 bit integers + * + * @param {Array} packets + * @return {Buffer} encoded payload + * @api private + */ + +exports.encodePayloadAsBinary = function (packets, callback) { + if (!packets.length) { + return callback(new Buffer(0)); + } + + function encodeOne(p, doneCallback) { + exports.encodePacket(p, true, true, function(packet) { + + if (typeof packet === 'string') { + var encodingLength = '' + packet.length; + var sizeBuffer = new Buffer(encodingLength.length + 2); + sizeBuffer[0] = 0; // is a string (not true binary = 0) + for (var i = 0; i < encodingLength.length; i++) { + sizeBuffer[i + 1] = parseInt(encodingLength[i], 10); + } + sizeBuffer[sizeBuffer.length - 1] = 255; + return doneCallback(null, Buffer.concat([sizeBuffer, stringToBuffer(packet)])); + } + + var encodingLength = '' + packet.length; + var sizeBuffer = new Buffer(encodingLength.length + 2); + sizeBuffer[0] = 1; // is binary (true binary = 1) + for (var i = 0; i < encodingLength.length; i++) { + sizeBuffer[i + 1] = parseInt(encodingLength[i], 10); + } + sizeBuffer[sizeBuffer.length - 1] = 255; + doneCallback(null, Buffer.concat([sizeBuffer, packet])); + }); + } + + map(packets, encodeOne, function(err, results) { + return callback(Buffer.concat(results)); + }); +}; + +/* + * Decodes data when a payload is maybe expected. Strings are decoded by + * interpreting each byte as a key code for entries marked to start with 0. See + * description of encodePayloadAsBinary + + * @param {Buffer} data, callback method + * @api public + */ + +exports.decodePayloadAsBinary = function (data, binaryType, callback) { + if (typeof binaryType === 'function') { + callback = binaryType; + binaryType = null; + } + + var bufferTail = data; + var buffers = []; + + while (bufferTail.length > 0) { + var strLen = ''; + var isString = bufferTail[0] === 0; + var numberTooLong = false; + for (var i = 1; ; i++) { + if (bufferTail[i] == 255) break; + // 310 = char length of Number.MAX_VALUE + if (strLen.length > 310) { + numberTooLong = true; + break; + } + strLen += '' + bufferTail[i]; + } + if(numberTooLong) return callback(err, 0, 1); + bufferTail = bufferTail.slice(strLen.length + 1); + + var msgLength = parseInt(strLen, 10); + + var msg = bufferTail.slice(1, msgLength + 1); + if (isString) msg = bufferToString(msg); + buffers.push(msg); + bufferTail = bufferTail.slice(msgLength + 1); + } + + var total = buffers.length; + buffers.forEach(function(buffer, i) { + callback(exports.decodePacket(buffer, binaryType, true), i, total); + }); +}; diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/lib/keys.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/lib/keys.js index bcfc6477..947dafda 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/lib/keys.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/lib/keys.js @@ -1,19 +1,19 @@ - -/** - * Gets the keys for an object. - * - * @return {Array} keys - * @api private - */ - -module.exports = Object.keys || function keys (obj){ - var arr = []; - var has = Object.prototype.hasOwnProperty; - - for (var i in obj) { - if (has.call(obj, i)) { - arr.push(i); - } - } - return arr; -}; + +/** + * Gets the keys for an object. + * + * @return {Array} keys + * @api private + */ + +module.exports = Object.keys || function keys (obj){ + var arr = []; + var has = Object.prototype.hasOwnProperty; + + for (var i in obj) { + if (has.call(obj, i)) { + arr.push(i); + } + } + return arr; +}; diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/.npmignore b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/.npmignore index a6ad0934..6c786024 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/.npmignore +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/.npmignore @@ -1,2 +1,2 @@ -node_modules -.monitor +node_modules +.monitor diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/.travis.yml b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/.travis.yml index 5d5a07ec..84fd7ca2 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/.travis.yml +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/.travis.yml @@ -1,5 +1,5 @@ -language: node_js -node_js: - - 0.6 - - 0.8 - - 0.9 +language: node_js +node_js: + - 0.6 + - 0.8 + - 0.9 diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/LICENCE b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/LICENCE index c4c82e90..7c351306 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/LICENCE +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/LICENCE @@ -1,19 +1,19 @@ -Copyright (c) 2011 Raynos. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +Copyright (c) 2011 Raynos. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/README.md b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/README.md index 23d3339c..0012d357 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/README.md +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/README.md @@ -1,75 +1,75 @@ -# After [![Build Status][1]][2] - -Invoke callback after n calls - -## Status: production ready - -## Example - - var after = require("after") - , next = after(3, logItWorks) - - next() - next() - next() // it works - - function logItWorks() { - console.log("it works!") - } - -## Example with error handling - - var after = require("after") - , next = after(3, logError) - - next() - next(new Error("oops")) // logs oops - next() // does nothing - - function logError(err) { - console.log(err) - } - -## After < 0.6.0 - -Older versions of after had iterators and flows in them. - -These have been replaced with seperate modules - - - [iterators][8] - - [composite][9] - -## Installation - -`npm install after` - -## Tests - -`npm test` - -## Blog post - - - [Flow control in node.js][3] - -## Examples : - - - [Determining the end of asynchronous operations][4] - - [In javascript what are best practices for executing multiple asynchronous functions][5] - - [JavaScript performance long running tasks][6] - - [Synchronous database queries with node.js][7] - -## Contributors - - - Raynos - -## MIT Licenced - - [1]: https://secure.travis-ci.org/Raynos/after.png - [2]: http://travis-ci.org/Raynos/after - [3]: http://raynos.org/blog/2/Flow-control-in-node.js - [4]: http://stackoverflow.com/questions/6852059/determining-the-end-of-asynchronous-operations-javascript/6852307#6852307 - [5]: http://stackoverflow.com/questions/6869872/in-javascript-what-are-best-practices-for-executing-multiple-asynchronous-functi/6870031#6870031 - [6]: http://stackoverflow.com/questions/6864397/javascript-performance-long-running-tasks/6889419#6889419 - [7]: http://stackoverflow.com/questions/6597493/synchronous-database-queries-with-node-js/6620091#6620091 - [8]: http://github.com/Raynos/iterators - [9]: http://github.com/Raynos/composite +# After [![Build Status][1]][2] + +Invoke callback after n calls + +## Status: production ready + +## Example + + var after = require("after") + , next = after(3, logItWorks) + + next() + next() + next() // it works + + function logItWorks() { + console.log("it works!") + } + +## Example with error handling + + var after = require("after") + , next = after(3, logError) + + next() + next(new Error("oops")) // logs oops + next() // does nothing + + function logError(err) { + console.log(err) + } + +## After < 0.6.0 + +Older versions of after had iterators and flows in them. + +These have been replaced with seperate modules + + - [iterators][8] + - [composite][9] + +## Installation + +`npm install after` + +## Tests + +`npm test` + +## Blog post + + - [Flow control in node.js][3] + +## Examples : + + - [Determining the end of asynchronous operations][4] + - [In javascript what are best practices for executing multiple asynchronous functions][5] + - [JavaScript performance long running tasks][6] + - [Synchronous database queries with node.js][7] + +## Contributors + + - Raynos + +## MIT Licenced + + [1]: https://secure.travis-ci.org/Raynos/after.png + [2]: http://travis-ci.org/Raynos/after + [3]: http://raynos.org/blog/2/Flow-control-in-node.js + [4]: http://stackoverflow.com/questions/6852059/determining-the-end-of-asynchronous-operations-javascript/6852307#6852307 + [5]: http://stackoverflow.com/questions/6869872/in-javascript-what-are-best-practices-for-executing-multiple-asynchronous-functi/6870031#6870031 + [6]: http://stackoverflow.com/questions/6864397/javascript-performance-long-running-tasks/6889419#6889419 + [7]: http://stackoverflow.com/questions/6597493/synchronous-database-queries-with-node-js/6620091#6620091 + [8]: http://github.com/Raynos/iterators + [9]: http://github.com/Raynos/composite diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/index.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/index.js index 66f45c9d..ec248797 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/index.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/index.js @@ -1,28 +1,28 @@ -module.exports = after - -function after(count, callback, err_cb) { - var bail = false - err_cb = err_cb || noop - proxy.count = count - - return (count === 0) ? callback() : proxy - - function proxy(err, result) { - if (proxy.count <= 0) { - throw new Error('after called too many times') - } - --proxy.count - - // after first error, rest are passed to err_cb - if (err) { - bail = true - callback(err) - // future error callbacks will go to error handler - callback = err_cb - } else if (proxy.count === 0 && !bail) { - callback(null, result) - } - } -} - -function noop() {} +module.exports = after + +function after(count, callback, err_cb) { + var bail = false + err_cb = err_cb || noop + proxy.count = count + + return (count === 0) ? callback() : proxy + + function proxy(err, result) { + if (proxy.count <= 0) { + throw new Error('after called too many times') + } + --proxy.count + + // after first error, rest are passed to err_cb + if (err) { + bail = true + callback(err) + // future error callbacks will go to error handler + callback = err_cb + } else if (proxy.count === 0 && !bail) { + callback(null, result) + } + } +} + +function noop() {} diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/package.json b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/package.json index 22f1445b..004bc9a4 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/package.json +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/package.json @@ -1,62 +1,62 @@ -{ - "name": "after", - "description": "after - tiny flow control", - "version": "0.8.1", - "author": { - "name": "Raynos", - "email": "raynos2@gmail.com" - }, - "contributors": [ - { - "name": "Raynos", - "email": "raynos2@gmail.com", - "url": "http://raynos.org" - } - ], - "scripts": { - "test": "mocha --ui tdd --reporter spec test/*.js" - }, - "devDependencies": { - "mocha": "~1.8.1" - }, - "keywords": [ - "flowcontrol", - "after", - "flow", - "control", - "arch" - ], - "repository": { - "type": "git", - "url": "git://github.com/Raynos/after.git" - }, - "bugs": { - "url": "https://github.com/Raynos/after/issues" - }, - "_id": "after@0.8.1", - "dist": { - "shasum": "ab5d4fb883f596816d3515f8f791c0af486dd627", - "tarball": "https://registry.npmjs.org/after/-/after-0.8.1.tgz" - }, - "_from": "after@0.8.1", - "_npmVersion": "1.2.25", - "_npmUser": { - "name": "raynos", - "email": "raynos2@gmail.com" - }, - "maintainers": [ - { - "name": "raynos", - "email": "raynos2@gmail.com" - }, - { - "name": "shtylman", - "email": "shtylman@gmail.com" - } - ], - "directories": {}, - "_shasum": "ab5d4fb883f596816d3515f8f791c0af486dd627", - "_resolved": "https://registry.npmjs.org/after/-/after-0.8.1.tgz", - "readme": "ERROR: No README data found!", - "homepage": "https://github.com/Raynos/after#readme" -} +{ + "name": "after", + "description": "after - tiny flow control", + "version": "0.8.1", + "author": { + "name": "Raynos", + "email": "raynos2@gmail.com" + }, + "contributors": [ + { + "name": "Raynos", + "email": "raynos2@gmail.com", + "url": "http://raynos.org" + } + ], + "scripts": { + "test": "mocha --ui tdd --reporter spec test/*.js" + }, + "devDependencies": { + "mocha": "~1.8.1" + }, + "keywords": [ + "flowcontrol", + "after", + "flow", + "control", + "arch" + ], + "repository": { + "type": "git", + "url": "git://github.com/Raynos/after.git" + }, + "bugs": { + "url": "https://github.com/Raynos/after/issues" + }, + "_id": "after@0.8.1", + "dist": { + "shasum": "ab5d4fb883f596816d3515f8f791c0af486dd627", + "tarball": "https://registry.npmjs.org/after/-/after-0.8.1.tgz" + }, + "_from": "after@0.8.1", + "_npmVersion": "1.2.25", + "_npmUser": { + "name": "raynos", + "email": "raynos2@gmail.com" + }, + "maintainers": [ + { + "name": "raynos", + "email": "raynos2@gmail.com" + }, + { + "name": "shtylman", + "email": "shtylman@gmail.com" + } + ], + "directories": {}, + "_shasum": "ab5d4fb883f596816d3515f8f791c0af486dd627", + "_resolved": "https://registry.npmjs.org/after/-/after-0.8.1.tgz", + "readme": "ERROR: No README data found!", + "homepage": "https://github.com/Raynos/after#readme" +} diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/test/after-test.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/test/after-test.js index 1c7f9e66..0d63f4c2 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/test/after-test.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/test/after-test.js @@ -1,120 +1,120 @@ -/*global suite, test*/ - -var assert = require("assert") - , after = require("../") - -test("exists", function () { - assert(typeof after === "function", "after is not a function") -}) - -test("after when called with 0 invokes", function (done) { - after(0, done) -}); - -test("after 1", function (done) { - var next = after(1, done) - next() -}) - -test("after 5", function (done) { - var next = after(5, done) - , i = 5 - - while (i--) { - next() - } -}) - -test("manipulate count", function (done) { - var next = after(1, done) - , i = 5 - - next.count = i - while (i--) { - next() - } -}) - -test("after terminates on error", function (done) { - var next = after(2, function(err) { - assert.equal(err.message, 'test'); - done(); - }) - next(new Error('test')) - next(new Error('test2')) -}) - -test('gee', function(done) { - done = after(2, done) - - function cb(err) { - assert.equal(err.message, 1); - done() - } - - var next = after(3, cb, function(err) { - assert.equal(err.message, 2) - done() - }); - - next() - next(new Error(1)) - next(new Error(2)) -}) - -test('eee', function(done) { - done = after(3, done) - - function cb(err) { - assert.equal(err.message, 1); - done() - } - - var next = after(3, cb, function(err) { - assert.equal(err.message, 2) - done() - }); - - next(new Error(1)) - next(new Error(2)) - next(new Error(2)) -}) - -test('gge', function(done) { - function cb(err) { - assert.equal(err.message, 1); - done() - } - - var next = after(3, cb, function(err) { - // should not happen - assert.ok(false); - }); - - next() - next() - next(new Error(1)) -}) - -test('egg', function(done) { - function cb(err) { - assert.equal(err.message, 1); - done() - } - - var next = after(3, cb, function(err) { - // should not happen - assert.ok(false); - }); - - next(new Error(1)) - next() - next() -}) - -test('throws on too many calls', function(done) { - var next = after(1, done); - next() - assert.throws(next, /after called too many times/); -}); - +/*global suite, test*/ + +var assert = require("assert") + , after = require("../") + +test("exists", function () { + assert(typeof after === "function", "after is not a function") +}) + +test("after when called with 0 invokes", function (done) { + after(0, done) +}); + +test("after 1", function (done) { + var next = after(1, done) + next() +}) + +test("after 5", function (done) { + var next = after(5, done) + , i = 5 + + while (i--) { + next() + } +}) + +test("manipulate count", function (done) { + var next = after(1, done) + , i = 5 + + next.count = i + while (i--) { + next() + } +}) + +test("after terminates on error", function (done) { + var next = after(2, function(err) { + assert.equal(err.message, 'test'); + done(); + }) + next(new Error('test')) + next(new Error('test2')) +}) + +test('gee', function(done) { + done = after(2, done) + + function cb(err) { + assert.equal(err.message, 1); + done() + } + + var next = after(3, cb, function(err) { + assert.equal(err.message, 2) + done() + }); + + next() + next(new Error(1)) + next(new Error(2)) +}) + +test('eee', function(done) { + done = after(3, done) + + function cb(err) { + assert.equal(err.message, 1); + done() + } + + var next = after(3, cb, function(err) { + assert.equal(err.message, 2) + done() + }); + + next(new Error(1)) + next(new Error(2)) + next(new Error(2)) +}) + +test('gge', function(done) { + function cb(err) { + assert.equal(err.message, 1); + done() + } + + var next = after(3, cb, function(err) { + // should not happen + assert.ok(false); + }); + + next() + next() + next(new Error(1)) +}) + +test('egg', function(done) { + function cb(err) { + assert.equal(err.message, 1); + done() + } + + var next = after(3, cb, function(err) { + // should not happen + assert.ok(false); + }); + + next(new Error(1)) + next() + next() +}) + +test('throws on too many calls', function(done) { + var next = after(1, done); + next() + assert.throws(next, /after called too many times/); +}); + diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/.npmignore b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/.npmignore index 0a6c554f..cfbee8d8 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/.npmignore +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/.npmignore @@ -1,17 +1,17 @@ -lib-cov -lcov.info -*.seed -*.log -*.csv -*.dat -*.out -*.pid -*.gz - -pids -logs -results -build -.grunt - -node_modules +lib-cov +lcov.info +*.seed +*.log +*.csv +*.dat +*.out +*.pid +*.gz + +pids +logs +results +build +.grunt + +node_modules diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/Makefile b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/Makefile index b045438a..849887f7 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/Makefile +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/Makefile @@ -1,8 +1,8 @@ - -REPORTER = dot - -test: - @./node_modules/.bin/mocha \ - --reporter $(REPORTER) - -.PHONY: test + +REPORTER = dot + +test: + @./node_modules/.bin/mocha \ + --reporter $(REPORTER) + +.PHONY: test diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/README.md b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/README.md index dd58b92a..15e465ef 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/README.md +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/README.md @@ -1,17 +1,17 @@ -# How to -```javascript -var sliceBuffer = require('arraybuffer.slice'); -var ab = (new Int8Array(5)).buffer; -var sliced = sliceBuffer(ab, 1, 3); -sliced = sliceBuffer(ab, 1); -``` - -# Licence (MIT) -Copyright (C) 2013 Rase- - - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# How to +```javascript +var sliceBuffer = require('arraybuffer.slice'); +var ab = (new Int8Array(5)).buffer; +var sliced = sliceBuffer(ab, 1, 3); +sliced = sliceBuffer(ab, 1); +``` + +# Licence (MIT) +Copyright (C) 2013 Rase- + + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/index.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/index.js index 1fbed279..11ac556e 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/index.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/index.js @@ -1,29 +1,29 @@ -/** - * An abstraction for slicing an arraybuffer even when - * ArrayBuffer.prototype.slice is not supported - * - * @api public - */ - -module.exports = function(arraybuffer, start, end) { - var bytes = arraybuffer.byteLength; - start = start || 0; - end = end || bytes; - - if (arraybuffer.slice) { return arraybuffer.slice(start, end); } - - if (start < 0) { start += bytes; } - if (end < 0) { end += bytes; } - if (end > bytes) { end = bytes; } - - if (start >= bytes || start >= end || bytes === 0) { - return new ArrayBuffer(0); - } - - var abv = new Uint8Array(arraybuffer); - var result = new Uint8Array(end - start); - for (var i = start, ii = 0; i < end; i++, ii++) { - result[ii] = abv[i]; - } - return result.buffer; -}; +/** + * An abstraction for slicing an arraybuffer even when + * ArrayBuffer.prototype.slice is not supported + * + * @api public + */ + +module.exports = function(arraybuffer, start, end) { + var bytes = arraybuffer.byteLength; + start = start || 0; + end = end || bytes; + + if (arraybuffer.slice) { return arraybuffer.slice(start, end); } + + if (start < 0) { start += bytes; } + if (end < 0) { end += bytes; } + if (end > bytes) { end = bytes; } + + if (start >= bytes || start >= end || bytes === 0) { + return new ArrayBuffer(0); + } + + var abv = new Uint8Array(arraybuffer); + var result = new Uint8Array(end - start); + for (var i = start, ii = 0; i < end; i++, ii++) { + result[ii] = abv[i]; + } + return result.buffer; +}; diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/package.json b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/package.json index 2b61e99a..35bbdf7d 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/package.json +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/package.json @@ -1,39 +1,39 @@ -{ - "name": "arraybuffer.slice", - "description": "Exports a function for slicing ArrayBuffers (no polyfilling)", - "version": "0.0.6", - "homepage": "https://github.com/rase-/arraybuffer.slice", - "dependencies": {}, - "devDependencies": { - "mocha": "1.17.1", - "expect.js": "0.2.0" - }, - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/rase-/arraybuffer.slice.git" - }, - "bugs": { - "url": "https://github.com/rase-/arraybuffer.slice/issues" - }, - "_id": "arraybuffer.slice@0.0.6", - "dist": { - "shasum": "f33b2159f0532a3f3107a272c0ccfbd1ad2979ca", - "tarball": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.6.tgz" - }, - "_from": "arraybuffer.slice@0.0.6", - "_npmVersion": "1.3.5", - "_npmUser": { - "name": "rase-", - "email": "tonykovanen@hotmail.com" - }, - "maintainers": [ - { - "name": "rase-", - "email": "tonykovanen@hotmail.com" - } - ], - "directories": {}, - "_shasum": "f33b2159f0532a3f3107a272c0ccfbd1ad2979ca", - "_resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.6.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "arraybuffer.slice", + "description": "Exports a function for slicing ArrayBuffers (no polyfilling)", + "version": "0.0.6", + "homepage": "https://github.com/rase-/arraybuffer.slice", + "dependencies": {}, + "devDependencies": { + "mocha": "1.17.1", + "expect.js": "0.2.0" + }, + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/rase-/arraybuffer.slice.git" + }, + "bugs": { + "url": "https://github.com/rase-/arraybuffer.slice/issues" + }, + "_id": "arraybuffer.slice@0.0.6", + "dist": { + "shasum": "f33b2159f0532a3f3107a272c0ccfbd1ad2979ca", + "tarball": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.6.tgz" + }, + "_from": "arraybuffer.slice@0.0.6", + "_npmVersion": "1.3.5", + "_npmUser": { + "name": "rase-", + "email": "tonykovanen@hotmail.com" + }, + "maintainers": [ + { + "name": "rase-", + "email": "tonykovanen@hotmail.com" + } + ], + "directories": {}, + "_shasum": "f33b2159f0532a3f3107a272c0ccfbd1ad2979ca", + "_resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.6.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/test/slice-buffer.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/test/slice-buffer.js index 1373c621..4778da67 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/test/slice-buffer.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/arraybuffer.slice/test/slice-buffer.js @@ -1,227 +1,227 @@ -/* - * Test dependencies - */ - -var sliceBuffer = require('../index.js'); -var expect = require('expect.js'); - -/** - * Tests - */ - -describe('sliceBuffer', function() { - describe('using standard slice', function() { - it('should slice correctly with only start provided', function() { - var abv = new Uint8Array(10); - for (var i = 0; i < abv.length; i++) { - abv[i] = i; - } - - var sliced = sliceBuffer(abv.buffer, 3); - var sabv = new Uint8Array(sliced); - for (var i = 3, ii = 0; i < abv.length; i++, ii++) { - expect(abv[i]).to.equal(sabv[ii]); - } - }); - - it('should slice correctly with start and end provided', function() { - var abv = new Uint8Array(10); - for (var i = 0; i < abv.length; i++) { - abv[i] = i; - } - - var sliced = sliceBuffer(abv.buffer, 3, 8); - var sabv = new Uint8Array(sliced); - for (var i = 3, ii = 0; i < 8; i++, ii++) { - expect(abv[i]).to.equal(sabv[ii]); - } - }); - - it('should slice correctly with negative start', function() { - var abv = new Uint8Array(10); - for (var i = 0; i < abv.length; i++) { - abv[i] = i; - } - - var sliced = sliceBuffer(abv.buffer, -3); - var sabv = new Uint8Array(sliced); - for (var i = abv.length - 3, ii = 0; i < abv.length; i++, ii++) { - expect(abv[i]).to.equal(sabv[ii]); - } - }); - - it('should slice correctly with negative end', function() { - var abv = new Uint8Array(10); - for (var i = 0; i < abv.length; i++) { - abv[i] = i; - } - - var sliced = sliceBuffer(abv.buffer, 0, -3); - var sabv = new Uint8Array(sliced); - for (var i = 0, ii = 0; i < abv.length - 3; i++, ii++) { - expect(abv[i]).to.equal(sabv[ii]); - } - }); - - it('should slice correctly with negative start and end', function() { - var abv = new Uint8Array(10); - for (var i = 0; i < abv.length; i++) { - abv[i] = i; - } - - var sliced = sliceBuffer(abv.buffer, -6, -3); - var sabv = new Uint8Array(sliced); - for (var i = abv.length - 6, ii = 0; i < abv.length - 3; i++, ii++) { - expect(abv[i]).to.equal(sabv[ii]); - } - }); - - it('should slice correctly with equal start and end', function() { - var abv = new Uint8Array(10); - for (var i = 0; i < abv.length; i++) { - abv[i] = i; - } - - var sliced = sliceBuffer(abv.buffer, 1, 1); - expect(sliced.byteLength).to.equal(0); - }); - - it('should slice correctly when end larger than buffer', function() { - var abv = new Uint8Array(10); - for (var i = 0; i < abv.length; i++) { - abv[i] = i; - } - - var sliced = sliceBuffer(abv.buffer, 0, 100); - expect(new Uint8Array(sliced)).to.eql(abv); - }); - - it('shoud slice correctly when start larger than end', function() { - var abv = new Uint8Array(10); - for (var i = 0; i < abv.length; i++) { - abv[i] = i; - } - - var sliced = sliceBuffer(abv.buffer, 6, 5); - expect(sliced.byteLength).to.equal(0); - }); - }); - - describe('using fallback', function() { - it('should slice correctly with only start provided', function() { - var abv = new Uint8Array(10); - for (var i = 0; i < abv.length; i++) { - abv[i] = i; - } - var ab = abv.buffer; - ab.slice = undefined; - - var sliced = sliceBuffer(ab, 3); - var sabv = new Uint8Array(sliced); - for (var i = 3, ii = 0; i < abv.length; i++, ii++) { - expect(abv[i]).to.equal(sabv[ii]); - } - }); - - it('should slice correctly with start and end provided', function() { - var abv = new Uint8Array(10); - for (var i = 0; i < abv.length; i++) { - abv[i] = i; - } - var ab = abv.buffer; - ab.slice = undefined; - - - var sliced = sliceBuffer(ab, 3, 8); - var sabv = new Uint8Array(sliced); - for (var i = 3, ii = 0; i < 8; i++, ii++) { - expect(abv[i]).to.equal(sabv[ii]); - } - }); - - it('should slice correctly with negative start', function() { - var abv = new Uint8Array(10); - for (var i = 0; i < abv.length; i++) { - abv[i] = i; - } - var ab = abv.buffer; - ab.slice = undefined; - - - var sliced = sliceBuffer(ab, -3); - var sabv = new Uint8Array(sliced); - for (var i = abv.length - 3, ii = 0; i < abv.length; i++, ii++) { - expect(abv[i]).to.equal(sabv[ii]); - } - }); - - it('should slice correctly with negative end', function() { - var abv = new Uint8Array(10); - for (var i = 0; i < abv.length; i++) { - abv[i] = i; - } - var ab = abv.buffer; - ab.slice = undefined; - - var sliced = sliceBuffer(ab, 0, -3); - var sabv = new Uint8Array(sliced); - for (var i = 0, ii = 0; i < abv.length - 3; i++, ii++) { - expect(abv[i]).to.equal(sabv[ii]); - } - }); - - it('should slice correctly with negative start and end', function() { - var abv = new Uint8Array(10); - for (var i = 0; i < abv.length; i++) { - abv[i] = i; - } - var ab = abv.buffer; - ab.slice = undefined; - - var sliced = sliceBuffer(ab, -6, -3); - var sabv = new Uint8Array(sliced); - for (var i = abv.length - 6, ii = 0; i < abv.length - 3; i++, ii++) { - expect(abv[i]).to.equal(sabv[ii]); - } - }); - - it('should slice correctly with equal start and end', function() { - var abv = new Uint8Array(10); - for (var i = 0; i < abv.length; i++) { - abv[i] = i; - } - var ab = abv.buffer; - ab.slice = undefined; - - var sliced = sliceBuffer(ab, 1, 1); - expect(sliced.byteLength).to.equal(0); - }); - - it('should slice correctly when end larger than buffer', function() { - var abv = new Uint8Array(10); - for (var i = 0; i < abv.length; i++) { - abv[i] = i; - } - var ab = abv.buffer; - ab.slice = undefined; - - var sliced = sliceBuffer(ab, 0, 100); - var sabv = new Uint8Array(sliced); - for (var i = 0; i < abv.length; i++) { - expect(abv[i]).to.equal(sabv[i]); - } - }); - - it('shoud slice correctly when start larger than end', function() { - var abv = new Uint8Array(10); - for (var i = 0; i < abv.length; i++) { - abv[i] = i; - } - var ab = abv.buffer; - ab.slice = undefined; - - var sliced = sliceBuffer(ab, 6, 5); - expect(sliced.byteLength).to.equal(0); - }); - }); -}); +/* + * Test dependencies + */ + +var sliceBuffer = require('../index.js'); +var expect = require('expect.js'); + +/** + * Tests + */ + +describe('sliceBuffer', function() { + describe('using standard slice', function() { + it('should slice correctly with only start provided', function() { + var abv = new Uint8Array(10); + for (var i = 0; i < abv.length; i++) { + abv[i] = i; + } + + var sliced = sliceBuffer(abv.buffer, 3); + var sabv = new Uint8Array(sliced); + for (var i = 3, ii = 0; i < abv.length; i++, ii++) { + expect(abv[i]).to.equal(sabv[ii]); + } + }); + + it('should slice correctly with start and end provided', function() { + var abv = new Uint8Array(10); + for (var i = 0; i < abv.length; i++) { + abv[i] = i; + } + + var sliced = sliceBuffer(abv.buffer, 3, 8); + var sabv = new Uint8Array(sliced); + for (var i = 3, ii = 0; i < 8; i++, ii++) { + expect(abv[i]).to.equal(sabv[ii]); + } + }); + + it('should slice correctly with negative start', function() { + var abv = new Uint8Array(10); + for (var i = 0; i < abv.length; i++) { + abv[i] = i; + } + + var sliced = sliceBuffer(abv.buffer, -3); + var sabv = new Uint8Array(sliced); + for (var i = abv.length - 3, ii = 0; i < abv.length; i++, ii++) { + expect(abv[i]).to.equal(sabv[ii]); + } + }); + + it('should slice correctly with negative end', function() { + var abv = new Uint8Array(10); + for (var i = 0; i < abv.length; i++) { + abv[i] = i; + } + + var sliced = sliceBuffer(abv.buffer, 0, -3); + var sabv = new Uint8Array(sliced); + for (var i = 0, ii = 0; i < abv.length - 3; i++, ii++) { + expect(abv[i]).to.equal(sabv[ii]); + } + }); + + it('should slice correctly with negative start and end', function() { + var abv = new Uint8Array(10); + for (var i = 0; i < abv.length; i++) { + abv[i] = i; + } + + var sliced = sliceBuffer(abv.buffer, -6, -3); + var sabv = new Uint8Array(sliced); + for (var i = abv.length - 6, ii = 0; i < abv.length - 3; i++, ii++) { + expect(abv[i]).to.equal(sabv[ii]); + } + }); + + it('should slice correctly with equal start and end', function() { + var abv = new Uint8Array(10); + for (var i = 0; i < abv.length; i++) { + abv[i] = i; + } + + var sliced = sliceBuffer(abv.buffer, 1, 1); + expect(sliced.byteLength).to.equal(0); + }); + + it('should slice correctly when end larger than buffer', function() { + var abv = new Uint8Array(10); + for (var i = 0; i < abv.length; i++) { + abv[i] = i; + } + + var sliced = sliceBuffer(abv.buffer, 0, 100); + expect(new Uint8Array(sliced)).to.eql(abv); + }); + + it('shoud slice correctly when start larger than end', function() { + var abv = new Uint8Array(10); + for (var i = 0; i < abv.length; i++) { + abv[i] = i; + } + + var sliced = sliceBuffer(abv.buffer, 6, 5); + expect(sliced.byteLength).to.equal(0); + }); + }); + + describe('using fallback', function() { + it('should slice correctly with only start provided', function() { + var abv = new Uint8Array(10); + for (var i = 0; i < abv.length; i++) { + abv[i] = i; + } + var ab = abv.buffer; + ab.slice = undefined; + + var sliced = sliceBuffer(ab, 3); + var sabv = new Uint8Array(sliced); + for (var i = 3, ii = 0; i < abv.length; i++, ii++) { + expect(abv[i]).to.equal(sabv[ii]); + } + }); + + it('should slice correctly with start and end provided', function() { + var abv = new Uint8Array(10); + for (var i = 0; i < abv.length; i++) { + abv[i] = i; + } + var ab = abv.buffer; + ab.slice = undefined; + + + var sliced = sliceBuffer(ab, 3, 8); + var sabv = new Uint8Array(sliced); + for (var i = 3, ii = 0; i < 8; i++, ii++) { + expect(abv[i]).to.equal(sabv[ii]); + } + }); + + it('should slice correctly with negative start', function() { + var abv = new Uint8Array(10); + for (var i = 0; i < abv.length; i++) { + abv[i] = i; + } + var ab = abv.buffer; + ab.slice = undefined; + + + var sliced = sliceBuffer(ab, -3); + var sabv = new Uint8Array(sliced); + for (var i = abv.length - 3, ii = 0; i < abv.length; i++, ii++) { + expect(abv[i]).to.equal(sabv[ii]); + } + }); + + it('should slice correctly with negative end', function() { + var abv = new Uint8Array(10); + for (var i = 0; i < abv.length; i++) { + abv[i] = i; + } + var ab = abv.buffer; + ab.slice = undefined; + + var sliced = sliceBuffer(ab, 0, -3); + var sabv = new Uint8Array(sliced); + for (var i = 0, ii = 0; i < abv.length - 3; i++, ii++) { + expect(abv[i]).to.equal(sabv[ii]); + } + }); + + it('should slice correctly with negative start and end', function() { + var abv = new Uint8Array(10); + for (var i = 0; i < abv.length; i++) { + abv[i] = i; + } + var ab = abv.buffer; + ab.slice = undefined; + + var sliced = sliceBuffer(ab, -6, -3); + var sabv = new Uint8Array(sliced); + for (var i = abv.length - 6, ii = 0; i < abv.length - 3; i++, ii++) { + expect(abv[i]).to.equal(sabv[ii]); + } + }); + + it('should slice correctly with equal start and end', function() { + var abv = new Uint8Array(10); + for (var i = 0; i < abv.length; i++) { + abv[i] = i; + } + var ab = abv.buffer; + ab.slice = undefined; + + var sliced = sliceBuffer(ab, 1, 1); + expect(sliced.byteLength).to.equal(0); + }); + + it('should slice correctly when end larger than buffer', function() { + var abv = new Uint8Array(10); + for (var i = 0; i < abv.length; i++) { + abv[i] = i; + } + var ab = abv.buffer; + ab.slice = undefined; + + var sliced = sliceBuffer(ab, 0, 100); + var sabv = new Uint8Array(sliced); + for (var i = 0; i < abv.length; i++) { + expect(abv[i]).to.equal(sabv[i]); + } + }); + + it('shoud slice correctly when start larger than end', function() { + var abv = new Uint8Array(10); + for (var i = 0; i < abv.length; i++) { + abv[i] = i; + } + var ab = abv.buffer; + ab.slice = undefined; + + var sliced = sliceBuffer(ab, 6, 5); + expect(sliced.byteLength).to.equal(0); + }); + }); +}); diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/.npmignore b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/.npmignore index a0c00cd7..2ccbe465 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/.npmignore +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/.npmignore @@ -1 +1 @@ -/node_modules/ +/node_modules/ diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/.travis.yml b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/.travis.yml index ebc4c9e0..e2eeb993 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/.travis.yml +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/.travis.yml @@ -1,6 +1,6 @@ ---- -language: node_js -node_js: -- '0.10' -before_script: -- npm install +--- +language: node_js +node_js: +- '0.10' +before_script: +- npm install diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/LICENSE-MIT b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/LICENSE-MIT index ef2285de..ed27b41b 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/LICENSE-MIT +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/LICENSE-MIT @@ -1,22 +1,22 @@ -Copyright (c) 2012 Niklas von Hertzen - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. +Copyright (c) 2012 Niklas von Hertzen + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/README.md b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/README.md index 15ce1501..b841154c 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/README.md +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/README.md @@ -1,23 +1,23 @@ -# base64-arraybuffer - -[![Build Status](https://travis-ci.org/niklasvh/base64-arraybuffer.png)](https://travis-ci.org/niklasvh/base64-arraybuffer) - -Encode/decode base64 data into ArrayBuffers - -## Getting Started -Install the module with: `npm install base64-arraybuffer` - -## API -The library encodes and decodes base64 to and from ArrayBuffers - - - __encode(buffer)__ - Encodes `ArrayBuffer` into base64 string - - __decode(str)__ - Decodes base64 string to `ArrayBuffer` - -## Release History - - - 0.1.2 - Fix old format of typed arrays - - 0.1.0 - Initial version, basic decode/encode base64 to and from ArrayBuffer - -## License -Copyright (c) 2012 Niklas von Hertzen -Licensed under the MIT license. +# base64-arraybuffer + +[![Build Status](https://travis-ci.org/niklasvh/base64-arraybuffer.png)](https://travis-ci.org/niklasvh/base64-arraybuffer) + +Encode/decode base64 data into ArrayBuffers + +## Getting Started +Install the module with: `npm install base64-arraybuffer` + +## API +The library encodes and decodes base64 to and from ArrayBuffers + + - __encode(buffer)__ - Encodes `ArrayBuffer` into base64 string + - __decode(str)__ - Decodes base64 string to `ArrayBuffer` + +## Release History + + - 0.1.2 - Fix old format of typed arrays + - 0.1.0 - Initial version, basic decode/encode base64 to and from ArrayBuffer + +## License +Copyright (c) 2012 Niklas von Hertzen +Licensed under the MIT license. diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/README.md~ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/README.md~ index 15ce1501..b841154c 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/README.md~ +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/README.md~ @@ -1,23 +1,23 @@ -# base64-arraybuffer - -[![Build Status](https://travis-ci.org/niklasvh/base64-arraybuffer.png)](https://travis-ci.org/niklasvh/base64-arraybuffer) - -Encode/decode base64 data into ArrayBuffers - -## Getting Started -Install the module with: `npm install base64-arraybuffer` - -## API -The library encodes and decodes base64 to and from ArrayBuffers - - - __encode(buffer)__ - Encodes `ArrayBuffer` into base64 string - - __decode(str)__ - Decodes base64 string to `ArrayBuffer` - -## Release History - - - 0.1.2 - Fix old format of typed arrays - - 0.1.0 - Initial version, basic decode/encode base64 to and from ArrayBuffer - -## License -Copyright (c) 2012 Niklas von Hertzen -Licensed under the MIT license. +# base64-arraybuffer + +[![Build Status](https://travis-ci.org/niklasvh/base64-arraybuffer.png)](https://travis-ci.org/niklasvh/base64-arraybuffer) + +Encode/decode base64 data into ArrayBuffers + +## Getting Started +Install the module with: `npm install base64-arraybuffer` + +## API +The library encodes and decodes base64 to and from ArrayBuffers + + - __encode(buffer)__ - Encodes `ArrayBuffer` into base64 string + - __decode(str)__ - Decodes base64 string to `ArrayBuffer` + +## Release History + + - 0.1.2 - Fix old format of typed arrays + - 0.1.0 - Initial version, basic decode/encode base64 to and from ArrayBuffer + +## License +Copyright (c) 2012 Niklas von Hertzen +Licensed under the MIT license. diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/grunt.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/grunt.js index 4916f4bf..73c4e7a0 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/grunt.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/grunt.js @@ -1,39 +1,39 @@ -module.exports = function(grunt) { - "use strict"; - // Project configuration. - grunt.initConfig({ - pkg: '', - test: { - files: ['test/**/*.js'] - }, - lint: { - files: ['grunt.js', 'lib/**/*.js', 'test/**/*.js'] - }, - watch: { - files: '', - tasks: 'default' - }, - jshint: { - options: { - curly: true, - eqeqeq: true, - immed: true, - latedef: true, - newcap: true, - noarg: true, - sub: true, - undef: true, - boss: true, - eqnull: true, - node: true - }, - globals: { - exports: true - } - } - }); - - // Default task. - grunt.registerTask('default', 'test'); - +module.exports = function(grunt) { + "use strict"; + // Project configuration. + grunt.initConfig({ + pkg: '', + test: { + files: ['test/**/*.js'] + }, + lint: { + files: ['grunt.js', 'lib/**/*.js', 'test/**/*.js'] + }, + watch: { + files: '', + tasks: 'default' + }, + jshint: { + options: { + curly: true, + eqeqeq: true, + immed: true, + latedef: true, + newcap: true, + noarg: true, + sub: true, + undef: true, + boss: true, + eqnull: true, + node: true + }, + globals: { + exports: true + } + } + }); + + // Default task. + grunt.registerTask('default', 'test'); + }; \ No newline at end of file diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/lib/base64-arraybuffer.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/lib/base64-arraybuffer.js index e39d3aaa..362fbfaf 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/lib/base64-arraybuffer.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/lib/base64-arraybuffer.js @@ -1,59 +1,59 @@ -/* - * base64-arraybuffer - * https://github.com/niklasvh/base64-arraybuffer - * - * Copyright (c) 2012 Niklas von Hertzen - * Licensed under the MIT license. - */ -(function(chars){ - "use strict"; - - exports.encode = function(arraybuffer) { - var bytes = new Uint8Array(arraybuffer), - i, len = bytes.length, base64 = ""; - - for (i = 0; i < len; i+=3) { - base64 += chars[bytes[i] >> 2]; - base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)]; - base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)]; - base64 += chars[bytes[i + 2] & 63]; - } - - if ((len % 3) === 2) { - base64 = base64.substring(0, base64.length - 1) + "="; - } else if (len % 3 === 1) { - base64 = base64.substring(0, base64.length - 2) + "=="; - } - - return base64; - }; - - exports.decode = function(base64) { - var bufferLength = base64.length * 0.75, - len = base64.length, i, p = 0, - encoded1, encoded2, encoded3, encoded4; - - if (base64[base64.length - 1] === "=") { - bufferLength--; - if (base64[base64.length - 2] === "=") { - bufferLength--; - } - } - - var arraybuffer = new ArrayBuffer(bufferLength), - bytes = new Uint8Array(arraybuffer); - - for (i = 0; i < len; i+=4) { - encoded1 = chars.indexOf(base64[i]); - encoded2 = chars.indexOf(base64[i+1]); - encoded3 = chars.indexOf(base64[i+2]); - encoded4 = chars.indexOf(base64[i+3]); - - bytes[p++] = (encoded1 << 2) | (encoded2 >> 4); - bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2); - bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63); - } - - return arraybuffer; - }; -})("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"); +/* + * base64-arraybuffer + * https://github.com/niklasvh/base64-arraybuffer + * + * Copyright (c) 2012 Niklas von Hertzen + * Licensed under the MIT license. + */ +(function(chars){ + "use strict"; + + exports.encode = function(arraybuffer) { + var bytes = new Uint8Array(arraybuffer), + i, len = bytes.length, base64 = ""; + + for (i = 0; i < len; i+=3) { + base64 += chars[bytes[i] >> 2]; + base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)]; + base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)]; + base64 += chars[bytes[i + 2] & 63]; + } + + if ((len % 3) === 2) { + base64 = base64.substring(0, base64.length - 1) + "="; + } else if (len % 3 === 1) { + base64 = base64.substring(0, base64.length - 2) + "=="; + } + + return base64; + }; + + exports.decode = function(base64) { + var bufferLength = base64.length * 0.75, + len = base64.length, i, p = 0, + encoded1, encoded2, encoded3, encoded4; + + if (base64[base64.length - 1] === "=") { + bufferLength--; + if (base64[base64.length - 2] === "=") { + bufferLength--; + } + } + + var arraybuffer = new ArrayBuffer(bufferLength), + bytes = new Uint8Array(arraybuffer); + + for (i = 0; i < len; i+=4) { + encoded1 = chars.indexOf(base64[i]); + encoded2 = chars.indexOf(base64[i+1]); + encoded3 = chars.indexOf(base64[i+2]); + encoded4 = chars.indexOf(base64[i+3]); + + bytes[p++] = (encoded1 << 2) | (encoded2 >> 4); + bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2); + bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63); + } + + return arraybuffer; + }; +})("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"); diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/package.json b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/package.json index ed045703..cc988f94 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/package.json +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/package.json @@ -1,56 +1,56 @@ -{ - "name": "base64-arraybuffer", - "description": "Encode/decode base64 data into ArrayBuffers", - "version": "0.1.2", - "homepage": "https://github.com/niklasvh/base64-arraybuffer", - "author": { - "name": "Niklas von Hertzen", - "email": "niklasvh@gmail.com", - "url": "http://hertzen.com" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/niklasvh/base64-arraybuffer.git" - }, - "bugs": { - "url": "https://github.com/niklasvh/base64-arraybuffer/issues" - }, - "licenses": [ - { - "type": "MIT", - "url": "https://github.com/niklasvh/base64-arraybuffer/blob/master/LICENSE-MIT" - } - ], - "main": "lib/base64-arraybuffer", - "engines": { - "node": ">= 0.6.0" - }, - "scripts": { - "test": "grunt test" - }, - "devDependencies": { - "grunt": "~0.3.17" - }, - "keywords": [], - "_id": "base64-arraybuffer@0.1.2", - "dist": { - "shasum": "474df4a9f2da24e05df3158c3b1db3c3cd46a154", - "tarball": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.2.tgz" - }, - "_from": "base64-arraybuffer@0.1.2", - "_npmVersion": "1.3.21", - "_npmUser": { - "name": "niklasvh", - "email": "niklasvh@gmail.com" - }, - "maintainers": [ - { - "name": "niklasvh", - "email": "niklasvh@gmail.com" - } - ], - "directories": {}, - "_shasum": "474df4a9f2da24e05df3158c3b1db3c3cd46a154", - "_resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.2.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "base64-arraybuffer", + "description": "Encode/decode base64 data into ArrayBuffers", + "version": "0.1.2", + "homepage": "https://github.com/niklasvh/base64-arraybuffer", + "author": { + "name": "Niklas von Hertzen", + "email": "niklasvh@gmail.com", + "url": "http://hertzen.com" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/niklasvh/base64-arraybuffer.git" + }, + "bugs": { + "url": "https://github.com/niklasvh/base64-arraybuffer/issues" + }, + "licenses": [ + { + "type": "MIT", + "url": "https://github.com/niklasvh/base64-arraybuffer/blob/master/LICENSE-MIT" + } + ], + "main": "lib/base64-arraybuffer", + "engines": { + "node": ">= 0.6.0" + }, + "scripts": { + "test": "grunt test" + }, + "devDependencies": { + "grunt": "~0.3.17" + }, + "keywords": [], + "_id": "base64-arraybuffer@0.1.2", + "dist": { + "shasum": "474df4a9f2da24e05df3158c3b1db3c3cd46a154", + "tarball": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.2.tgz" + }, + "_from": "base64-arraybuffer@0.1.2", + "_npmVersion": "1.3.21", + "_npmUser": { + "name": "niklasvh", + "email": "niklasvh@gmail.com" + }, + "maintainers": [ + { + "name": "niklasvh", + "email": "niklasvh@gmail.com" + } + ], + "directories": {}, + "_shasum": "474df4a9f2da24e05df3158c3b1db3c3cd46a154", + "_resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.2.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/package.json~ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/package.json~ index 3d6ac0fb..251031a0 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/package.json~ +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/package.json~ @@ -1,35 +1,35 @@ -{ - "name": "base64-arraybuffer", - "description": "Encode/decode base64 data into ArrayBuffers", - "version": "0.1.1", - "homepage": "https://github.com/niklasvh/base64-arraybuffer", - "author": { - "name": "Niklas von Hertzen", - "email": "niklasvh@gmail.com", - "url": "http://hertzen.com" - }, - "repository": { - "type": "git", - "url": "https://github.com/niklasvh/base64-arraybuffer" - }, - "bugs": { - "url": "https://github.com/niklasvh/base64-arraybuffer/issues" - }, - "licenses": [ - { - "type": "MIT", - "url": "https://github.com/niklasvh/base64-arraybuffer/blob/master/LICENSE-MIT" - } - ], - "main": "lib/base64-arraybuffer", - "engines": { - "node": ">= 0.6.0" - }, - "scripts": { - "test": "grunt test" - }, - "devDependencies": { - "grunt": "~0.3.17" - }, - "keywords": [] -} +{ + "name": "base64-arraybuffer", + "description": "Encode/decode base64 data into ArrayBuffers", + "version": "0.1.1", + "homepage": "https://github.com/niklasvh/base64-arraybuffer", + "author": { + "name": "Niklas von Hertzen", + "email": "niklasvh@gmail.com", + "url": "http://hertzen.com" + }, + "repository": { + "type": "git", + "url": "https://github.com/niklasvh/base64-arraybuffer" + }, + "bugs": { + "url": "https://github.com/niklasvh/base64-arraybuffer/issues" + }, + "licenses": [ + { + "type": "MIT", + "url": "https://github.com/niklasvh/base64-arraybuffer/blob/master/LICENSE-MIT" + } + ], + "main": "lib/base64-arraybuffer", + "engines": { + "node": ">= 0.6.0" + }, + "scripts": { + "test": "grunt test" + }, + "devDependencies": { + "grunt": "~0.3.17" + }, + "keywords": [] +} diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/test/base64-arraybuffer_test.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/test/base64-arraybuffer_test.js index f9d93946..fe89c222 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/test/base64-arraybuffer_test.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/base64-arraybuffer/test/base64-arraybuffer_test.js @@ -1,72 +1,72 @@ -(function(){ - "use strict"; - var base64_arraybuffer = require('../lib/base64-arraybuffer.js'); - - /* - ======== A Handy Little Nodeunit Reference ======== - https://github.com/caolan/nodeunit - - Test methods: - test.expect(numAssertions) - test.done() - Test assertions: - test.ok(value, [message]) - test.equal(actual, expected, [message]) - test.notEqual(actual, expected, [message]) - test.deepEqual(actual, expected, [message]) - test.notDeepEqual(actual, expected, [message]) - test.strictEqual(actual, expected, [message]) - test.notStrictEqual(actual, expected, [message]) - test.throws(block, [error], [message]) - test.doesNotThrow(block, [error], [message]) - test.ifError(value) -*/ - - - function stringArrayBuffer(str) { - var buffer = new ArrayBuffer(str.length); - var bytes = new Uint8Array(buffer); - - str.split('').forEach(function(str, i) { - bytes[i] = str.charCodeAt(0); - }); - - return buffer; - } - - function testArrayBuffers(buffer1, buffer2) { - var len1 = buffer1.byteLength, - len2 = buffer2.byteLength; - if (len1 !== len2) { - console.log(buffer1, buffer2); - return false; - } - - for (var i = 0; i < len1; i++) { - if (buffer1[i] !== buffer1[i]) { - console.log(i, buffer1, buffer2); - return false; - } - } - return true; - } - - exports['base64tests'] = { - 'encode': function(test) { - test.expect(4); - - test.equal(base64_arraybuffer.encode(stringArrayBuffer("Hello world")), "SGVsbG8gd29ybGQ=", 'encode "Hello world"'); - test.equal(base64_arraybuffer.encode(stringArrayBuffer("Man")), 'TWFu', 'encode "Man"'); - test.equal(base64_arraybuffer.encode(stringArrayBuffer("Ma")), "TWE=", 'encode "Ma"'); - test.equal(base64_arraybuffer.encode(stringArrayBuffer("Hello worlds!")), "SGVsbG8gd29ybGRzIQ==", 'encode "Hello worlds!"'); - test.done(); - }, - 'decode': function(test) { - test.expect(3); - test.ok(testArrayBuffers(base64_arraybuffer.decode("TWFu"), stringArrayBuffer("Man")), 'decode "Man"'); - test.ok(testArrayBuffers(base64_arraybuffer.decode("SGVsbG8gd29ybGQ="), stringArrayBuffer("Hello world")), 'decode "Hello world"'); - test.ok(testArrayBuffers(base64_arraybuffer.decode("SGVsbG8gd29ybGRzIQ=="), stringArrayBuffer("Hello worlds!")), 'decode "Hello worlds!"'); - test.done(); - } - }; -})(); +(function(){ + "use strict"; + var base64_arraybuffer = require('../lib/base64-arraybuffer.js'); + + /* + ======== A Handy Little Nodeunit Reference ======== + https://github.com/caolan/nodeunit + + Test methods: + test.expect(numAssertions) + test.done() + Test assertions: + test.ok(value, [message]) + test.equal(actual, expected, [message]) + test.notEqual(actual, expected, [message]) + test.deepEqual(actual, expected, [message]) + test.notDeepEqual(actual, expected, [message]) + test.strictEqual(actual, expected, [message]) + test.notStrictEqual(actual, expected, [message]) + test.throws(block, [error], [message]) + test.doesNotThrow(block, [error], [message]) + test.ifError(value) +*/ + + + function stringArrayBuffer(str) { + var buffer = new ArrayBuffer(str.length); + var bytes = new Uint8Array(buffer); + + str.split('').forEach(function(str, i) { + bytes[i] = str.charCodeAt(0); + }); + + return buffer; + } + + function testArrayBuffers(buffer1, buffer2) { + var len1 = buffer1.byteLength, + len2 = buffer2.byteLength; + if (len1 !== len2) { + console.log(buffer1, buffer2); + return false; + } + + for (var i = 0; i < len1; i++) { + if (buffer1[i] !== buffer1[i]) { + console.log(i, buffer1, buffer2); + return false; + } + } + return true; + } + + exports['base64tests'] = { + 'encode': function(test) { + test.expect(4); + + test.equal(base64_arraybuffer.encode(stringArrayBuffer("Hello world")), "SGVsbG8gd29ybGQ=", 'encode "Hello world"'); + test.equal(base64_arraybuffer.encode(stringArrayBuffer("Man")), 'TWFu', 'encode "Man"'); + test.equal(base64_arraybuffer.encode(stringArrayBuffer("Ma")), "TWE=", 'encode "Ma"'); + test.equal(base64_arraybuffer.encode(stringArrayBuffer("Hello worlds!")), "SGVsbG8gd29ybGRzIQ==", 'encode "Hello worlds!"'); + test.done(); + }, + 'decode': function(test) { + test.expect(3); + test.ok(testArrayBuffers(base64_arraybuffer.decode("TWFu"), stringArrayBuffer("Man")), 'decode "Man"'); + test.ok(testArrayBuffers(base64_arraybuffer.decode("SGVsbG8gd29ybGQ="), stringArrayBuffer("Hello world")), 'decode "Hello world"'); + test.ok(testArrayBuffers(base64_arraybuffer.decode("SGVsbG8gd29ybGRzIQ=="), stringArrayBuffer("Hello worlds!")), 'decode "Hello worlds!"'); + test.done(); + } + }; +})(); diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/.npmignore b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/.npmignore index c2f810fa..548a3688 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/.npmignore +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/.npmignore @@ -1,2 +1,2 @@ -node_modules -blob.js +node_modules +blob.js diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/.zuul.yml b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/.zuul.yml index d95890ba..380c3950 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/.zuul.yml +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/.zuul.yml @@ -1,14 +1,14 @@ -ui: mocha-bdd -browsers: - - name: chrome - version: 8..latest - - name: firefox - version: 7..latest - - name: safari - version: 6..latest - - name: opera - version: 12.1..latest - - name: ie - version: 10..latest - - name: android - version: latest +ui: mocha-bdd +browsers: + - name: chrome + version: 8..latest + - name: firefox + version: 7..latest + - name: safari + version: 6..latest + - name: opera + version: 12.1..latest + - name: ie + version: 10..latest + - name: android + version: latest diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/Makefile b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/Makefile index e886c414..7d9601a9 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/Makefile +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/Makefile @@ -1,14 +1,14 @@ -REPORTER = dot - -build: blob.js - -blob.js: - @./node_modules/.bin/browserify --standalone blob index.js > blob.js - -test: - @./node_modules/.bin/zuul -- test/index.js - -clean: - rm blob.js - -.PHONY: test blob.js +REPORTER = dot + +build: blob.js + +blob.js: + @./node_modules/.bin/browserify --standalone blob index.js > blob.js + +test: + @./node_modules/.bin/zuul -- test/index.js + +clean: + rm blob.js + +.PHONY: test blob.js diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/README.md b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/README.md index 2bd80c19..69159558 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/README.md +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/README.md @@ -1,14 +1,14 @@ -Blob -==== - -A module that exports a constructor that uses window.Blob when available, and a BlobBuilder with any vendor prefix in other cases. If neither is available, it exports undefined. - -Usage: - -```javascript -var Blob = require('blob'); -var b = new Blob(['hi', 'constructing', 'a', 'blob']); -``` - -## Licence -MIT +Blob +==== + +A module that exports a constructor that uses window.Blob when available, and a BlobBuilder with any vendor prefix in other cases. If neither is available, it exports undefined. + +Usage: + +```javascript +var Blob = require('blob'); +var b = new Blob(['hi', 'constructing', 'a', 'blob']); +``` + +## Licence +MIT diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/index.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/index.js index 9c250b2f..cad3f84a 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/index.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/index.js @@ -1,96 +1,96 @@ -/** - * Create a blob builder even when vendor prefixes exist - */ - -var BlobBuilder = global.BlobBuilder - || global.WebKitBlobBuilder - || global.MSBlobBuilder - || global.MozBlobBuilder; - -/** - * Check if Blob constructor is supported - */ - -var blobSupported = (function() { - try { - var a = new Blob(['hi']); - return a.size === 2; - } catch(e) { - return false; - } -})(); - -/** - * Check if Blob constructor supports ArrayBufferViews - * Fails in Safari 6, so we need to map to ArrayBuffers there. - */ - -var blobSupportsArrayBufferView = blobSupported && (function() { - try { - var b = new Blob([new Uint8Array([1,2])]); - return b.size === 2; - } catch(e) { - return false; - } -})(); - -/** - * Check if BlobBuilder is supported - */ - -var blobBuilderSupported = BlobBuilder - && BlobBuilder.prototype.append - && BlobBuilder.prototype.getBlob; - -/** - * Helper function that maps ArrayBufferViews to ArrayBuffers - * Used by BlobBuilder constructor and old browsers that didn't - * support it in the Blob constructor. - */ - -function mapArrayBufferViews(ary) { - for (var i = 0; i < ary.length; i++) { - var chunk = ary[i]; - if (chunk.buffer instanceof ArrayBuffer) { - var buf = chunk.buffer; - - // if this is a subarray, make a copy so we only - // include the subarray region from the underlying buffer - if (chunk.byteLength !== buf.byteLength) { - var copy = new Uint8Array(chunk.byteLength); - copy.set(new Uint8Array(buf, chunk.byteOffset, chunk.byteLength)); - buf = copy.buffer; - } - - ary[i] = buf; - } - } -} - -function BlobBuilderConstructor(ary, options) { - options = options || {}; - - var bb = new BlobBuilder(); - mapArrayBufferViews(ary); - - for (var i = 0; i < ary.length; i++) { - bb.append(ary[i]); - } - - return (options.type) ? bb.getBlob(options.type) : bb.getBlob(); -}; - -function BlobConstructor(ary, options) { - mapArrayBufferViews(ary); - return new Blob(ary, options || {}); -}; - -module.exports = (function() { - if (blobSupported) { - return blobSupportsArrayBufferView ? global.Blob : BlobConstructor; - } else if (blobBuilderSupported) { - return BlobBuilderConstructor; - } else { - return undefined; - } -})(); +/** + * Create a blob builder even when vendor prefixes exist + */ + +var BlobBuilder = global.BlobBuilder + || global.WebKitBlobBuilder + || global.MSBlobBuilder + || global.MozBlobBuilder; + +/** + * Check if Blob constructor is supported + */ + +var blobSupported = (function() { + try { + var a = new Blob(['hi']); + return a.size === 2; + } catch(e) { + return false; + } +})(); + +/** + * Check if Blob constructor supports ArrayBufferViews + * Fails in Safari 6, so we need to map to ArrayBuffers there. + */ + +var blobSupportsArrayBufferView = blobSupported && (function() { + try { + var b = new Blob([new Uint8Array([1,2])]); + return b.size === 2; + } catch(e) { + return false; + } +})(); + +/** + * Check if BlobBuilder is supported + */ + +var blobBuilderSupported = BlobBuilder + && BlobBuilder.prototype.append + && BlobBuilder.prototype.getBlob; + +/** + * Helper function that maps ArrayBufferViews to ArrayBuffers + * Used by BlobBuilder constructor and old browsers that didn't + * support it in the Blob constructor. + */ + +function mapArrayBufferViews(ary) { + for (var i = 0; i < ary.length; i++) { + var chunk = ary[i]; + if (chunk.buffer instanceof ArrayBuffer) { + var buf = chunk.buffer; + + // if this is a subarray, make a copy so we only + // include the subarray region from the underlying buffer + if (chunk.byteLength !== buf.byteLength) { + var copy = new Uint8Array(chunk.byteLength); + copy.set(new Uint8Array(buf, chunk.byteOffset, chunk.byteLength)); + buf = copy.buffer; + } + + ary[i] = buf; + } + } +} + +function BlobBuilderConstructor(ary, options) { + options = options || {}; + + var bb = new BlobBuilder(); + mapArrayBufferViews(ary); + + for (var i = 0; i < ary.length; i++) { + bb.append(ary[i]); + } + + return (options.type) ? bb.getBlob(options.type) : bb.getBlob(); +}; + +function BlobConstructor(ary, options) { + mapArrayBufferViews(ary); + return new Blob(ary, options || {}); +}; + +module.exports = (function() { + if (blobSupported) { + return blobSupportsArrayBufferView ? global.Blob : BlobConstructor; + } else if (blobBuilderSupported) { + return BlobBuilderConstructor; + } else { + return undefined; + } +})(); diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/package.json b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/package.json index ee28c852..b5874552 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/package.json +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/package.json @@ -1,44 +1,44 @@ -{ - "name": "blob", - "description": "Abstracts out Blob and uses BlobBulder in cases where it is supported with any vendor prefix.", - "version": "0.0.4", - "homepage": "https://github.com/rase-/blob", - "dependencies": {}, - "devDependencies": { - "mocha": "1.17.1", - "expect.js": "0.2.0", - "zuul": "1.5.4", - "browserify": "3.30.1" - }, - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/rase-/blob.git" - }, - "scripts": { - "test": "make test" - }, - "bugs": { - "url": "https://github.com/rase-/blob/issues" - }, - "_id": "blob@0.0.4", - "dist": { - "shasum": "bcf13052ca54463f30f9fc7e95b9a47630a94921", - "tarball": "https://registry.npmjs.org/blob/-/blob-0.0.4.tgz" - }, - "_from": "blob@0.0.4", - "_npmVersion": "1.4.6", - "_npmUser": { - "name": "rase-", - "email": "tonykovanen@hotmail.com" - }, - "maintainers": [ - { - "name": "rase-", - "email": "tonykovanen@hotmail.com" - } - ], - "directories": {}, - "_shasum": "bcf13052ca54463f30f9fc7e95b9a47630a94921", - "_resolved": "https://registry.npmjs.org/blob/-/blob-0.0.4.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "blob", + "description": "Abstracts out Blob and uses BlobBulder in cases where it is supported with any vendor prefix.", + "version": "0.0.4", + "homepage": "https://github.com/rase-/blob", + "dependencies": {}, + "devDependencies": { + "mocha": "1.17.1", + "expect.js": "0.2.0", + "zuul": "1.5.4", + "browserify": "3.30.1" + }, + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/rase-/blob.git" + }, + "scripts": { + "test": "make test" + }, + "bugs": { + "url": "https://github.com/rase-/blob/issues" + }, + "_id": "blob@0.0.4", + "dist": { + "shasum": "bcf13052ca54463f30f9fc7e95b9a47630a94921", + "tarball": "https://registry.npmjs.org/blob/-/blob-0.0.4.tgz" + }, + "_from": "blob@0.0.4", + "_npmVersion": "1.4.6", + "_npmUser": { + "name": "rase-", + "email": "tonykovanen@hotmail.com" + }, + "maintainers": [ + { + "name": "rase-", + "email": "tonykovanen@hotmail.com" + } + ], + "directories": {}, + "_shasum": "bcf13052ca54463f30f9fc7e95b9a47630a94921", + "_resolved": "https://registry.npmjs.org/blob/-/blob-0.0.4.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/test/index.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/test/index.js index 8bda507a..df9303f7 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/test/index.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/blob/test/index.js @@ -1,94 +1,94 @@ -var Blob = require('../'); -var expect = require('expect.js'); - -describe('blob', function() { - if (!Blob) { - it('should not have a blob or a blob builder in the global namespace, or blob should not be a constructor function if the module exports false', function() { - try { - var ab = (new Uint8Array(5)).buffer; - global.Blob([ab]); - expect().fail('Blob shouldn\'t be constructable'); - } catch (e) {} - - var BlobBuilder = global.BlobBuilder - || global.WebKitBlobBuilder - || global.MSBlobBuilder - || global.MozBlobBuilder; - expect(BlobBuilder).to.be(undefined); - }); - } else { - it('should encode a proper sized blob when given a string argument', function() { - var b = new Blob(['hi']); - expect(b.size).to.be(2); - }); - - it('should encode a blob with proper size when given two strings as arguments', function() { - var b = new Blob(['hi', 'hello']); - expect(b.size).to.be(7); - }); - - it('should encode arraybuffers with right content', function(done) { - var ary = new Uint8Array(5); - for (var i = 0; i < 5; i++) ary[i] = i; - var b = new Blob([ary.buffer]); - var fr = new FileReader(); - fr.onload = function() { - var newAry = new Uint8Array(this.result); - for (var i = 0; i < 5; i++) expect(newAry[i]).to.be(i); - done(); - }; - fr.readAsArrayBuffer(b); - }); - - it('should encode typed arrays with right content', function(done) { - var ary = new Uint8Array(5); - for (var i = 0; i < 5; i++) ary[i] = i; - var b = new Blob([ary]); - var fr = new FileReader(); - fr.onload = function() { - var newAry = new Uint8Array(this.result); - for (var i = 0; i < 5; i++) expect(newAry[i]).to.be(i); - done(); - }; - fr.readAsArrayBuffer(b); - }); - - it('should encode sliced typed arrays with right content', function(done) { - var ary = new Uint8Array(5); - for (var i = 0; i < 5; i++) ary[i] = i; - var b = new Blob([ary.subarray(2)]); - var fr = new FileReader(); - fr.onload = function() { - var newAry = new Uint8Array(this.result); - for (var i = 0; i < 3; i++) expect(newAry[i]).to.be(i + 2); - done(); - }; - fr.readAsArrayBuffer(b); - }); - - it('should encode with blobs', function(done) { - var ary = new Uint8Array(5); - for (var i = 0; i < 5; i++) ary[i] = i; - var b = new Blob([new Blob([ary.buffer])]); - var fr = new FileReader(); - fr.onload = function() { - var newAry = new Uint8Array(this.result); - for (var i = 0; i < 5; i++) expect(newAry[i]).to.be(i); - done(); - }; - fr.readAsArrayBuffer(b); - }); - - it('should enode mixed contents to right size', function() { - var ary = new Uint8Array(5); - for (var i = 0; i < 5; i++) ary[i] = i; - var b = new Blob([ary.buffer, 'hello']); - expect(b.size).to.be(10); - }); - - it('should accept mime type', function() { - var b = new Blob(['hi', 'hello'], { type: 'text/html' }); - expect(b.type).to.be('text/html'); - }); - } -}); +var Blob = require('../'); +var expect = require('expect.js'); + +describe('blob', function() { + if (!Blob) { + it('should not have a blob or a blob builder in the global namespace, or blob should not be a constructor function if the module exports false', function() { + try { + var ab = (new Uint8Array(5)).buffer; + global.Blob([ab]); + expect().fail('Blob shouldn\'t be constructable'); + } catch (e) {} + + var BlobBuilder = global.BlobBuilder + || global.WebKitBlobBuilder + || global.MSBlobBuilder + || global.MozBlobBuilder; + expect(BlobBuilder).to.be(undefined); + }); + } else { + it('should encode a proper sized blob when given a string argument', function() { + var b = new Blob(['hi']); + expect(b.size).to.be(2); + }); + + it('should encode a blob with proper size when given two strings as arguments', function() { + var b = new Blob(['hi', 'hello']); + expect(b.size).to.be(7); + }); + + it('should encode arraybuffers with right content', function(done) { + var ary = new Uint8Array(5); + for (var i = 0; i < 5; i++) ary[i] = i; + var b = new Blob([ary.buffer]); + var fr = new FileReader(); + fr.onload = function() { + var newAry = new Uint8Array(this.result); + for (var i = 0; i < 5; i++) expect(newAry[i]).to.be(i); + done(); + }; + fr.readAsArrayBuffer(b); + }); + + it('should encode typed arrays with right content', function(done) { + var ary = new Uint8Array(5); + for (var i = 0; i < 5; i++) ary[i] = i; + var b = new Blob([ary]); + var fr = new FileReader(); + fr.onload = function() { + var newAry = new Uint8Array(this.result); + for (var i = 0; i < 5; i++) expect(newAry[i]).to.be(i); + done(); + }; + fr.readAsArrayBuffer(b); + }); + + it('should encode sliced typed arrays with right content', function(done) { + var ary = new Uint8Array(5); + for (var i = 0; i < 5; i++) ary[i] = i; + var b = new Blob([ary.subarray(2)]); + var fr = new FileReader(); + fr.onload = function() { + var newAry = new Uint8Array(this.result); + for (var i = 0; i < 3; i++) expect(newAry[i]).to.be(i + 2); + done(); + }; + fr.readAsArrayBuffer(b); + }); + + it('should encode with blobs', function(done) { + var ary = new Uint8Array(5); + for (var i = 0; i < 5; i++) ary[i] = i; + var b = new Blob([new Blob([ary.buffer])]); + var fr = new FileReader(); + fr.onload = function() { + var newAry = new Uint8Array(this.result); + for (var i = 0; i < 5; i++) expect(newAry[i]).to.be(i); + done(); + }; + fr.readAsArrayBuffer(b); + }); + + it('should enode mixed contents to right size', function() { + var ary = new Uint8Array(5); + for (var i = 0; i < 5; i++) ary[i] = i; + var b = new Blob([ary.buffer, 'hello']); + expect(b.size).to.be(10); + }); + + it('should accept mime type', function() { + var b = new Blob(['hi', 'hello'], { type: 'text/html' }); + expect(b.type).to.be('text/html'); + }); + } +}); diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/.npmignore b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/.npmignore index 78cdbf85..a72b52eb 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/.npmignore +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/.npmignore @@ -1,15 +1,15 @@ -lib-cov -*.seed -*.log -*.csv -*.dat -*.out -*.pid -*.gz - -pids -logs -results - -npm-debug.log -node_modules +lib-cov +*.seed +*.log +*.csv +*.dat +*.out +*.pid +*.gz + +pids +logs +results + +npm-debug.log +node_modules diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/History.md b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/History.md index 90d93bd3..a1e3867e 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/History.md +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/History.md @@ -1,11 +1,11 @@ - -0.1.6 / 2015-01-24 -================== - - * fix "undefined function" bug when iterating - an object created with Object.create(null) [gunta] - -0.1.5 / 2014-09-04 -================== - - * prevent browserify from bundling `Buffer` + +0.1.6 / 2015-01-24 +================== + + * fix "undefined function" bug when iterating + an object created with Object.create(null) [gunta] + +0.1.5 / 2014-09-04 +================== + + * prevent browserify from bundling `Buffer` diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/LICENSE b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/LICENSE index 5e1e23f6..e6603cdf 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/LICENSE +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/LICENSE @@ -1,20 +1,20 @@ -The MIT License (MIT) - -Copyright (c) 2014 Kevin Roark - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +The MIT License (MIT) + +Copyright (c) 2014 Kevin Roark + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/Makefile b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/Makefile index 2fbcce99..1d90629d 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/Makefile +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/Makefile @@ -1,3 +1,3 @@ - -test: - @./node_modules/.bin/mocha test.js + +test: + @./node_modules/.bin/mocha test.js diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/README.md b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/README.md index 5dedc64e..76a00356 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/README.md +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/README.md @@ -1,4 +1,4 @@ -has-binarydata.js -================= - -Simple module to test if an object contains binary data +has-binarydata.js +================= + +Simple module to test if an object contains binary data diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/fixtures/big.json b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/fixtures/big.json index d6e99a79..3172879b 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/fixtures/big.json +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/fixtures/big.json @@ -1 +1 @@ -{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":"cool"}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} +{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":"cool"}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/index.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/index.js index 49017d34..7684d234 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/index.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/index.js @@ -1,58 +1,58 @@ - -/* - * Module requirements. - */ - -var isArray = require('isarray'); - -/** - * Module exports. - */ - -module.exports = hasBinary; - -/** - * Checks for binary data. - * - * Right now only Buffer and ArrayBuffer are supported.. - * - * @param {Object} anything - * @api public - */ - -function hasBinary(data) { - - function _hasBinary(obj) { - if (!obj) return false; - - if ( (global.Buffer && global.Buffer.isBuffer(obj)) || - (global.ArrayBuffer && obj instanceof ArrayBuffer) || - (global.Blob && obj instanceof Blob) || - (global.File && obj instanceof File) - ) { - return true; - } - - if (isArray(obj)) { - for (var i = 0; i < obj.length; i++) { - if (_hasBinary(obj[i])) { - return true; - } - } - } else if (obj && 'object' == typeof obj) { - if (obj.toJSON) { - obj = obj.toJSON(); - } - - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key) && _hasBinary(obj[key])) { - return true; - } - } - } - - return false; - } - - return _hasBinary(data); -} + +/* + * Module requirements. + */ + +var isArray = require('isarray'); + +/** + * Module exports. + */ + +module.exports = hasBinary; + +/** + * Checks for binary data. + * + * Right now only Buffer and ArrayBuffer are supported.. + * + * @param {Object} anything + * @api public + */ + +function hasBinary(data) { + + function _hasBinary(obj) { + if (!obj) return false; + + if ( (global.Buffer && global.Buffer.isBuffer(obj)) || + (global.ArrayBuffer && obj instanceof ArrayBuffer) || + (global.Blob && obj instanceof Blob) || + (global.File && obj instanceof File) + ) { + return true; + } + + if (isArray(obj)) { + for (var i = 0; i < obj.length; i++) { + if (_hasBinary(obj[i])) { + return true; + } + } + } else if (obj && 'object' == typeof obj) { + if (obj.toJSON) { + obj = obj.toJSON(); + } + + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key) && _hasBinary(obj[key])) { + return true; + } + } + } + + return false; + } + + return _hasBinary(data); +} diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/node_modules/isarray/README.md b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/node_modules/isarray/README.md index 0bda6119..052a62b8 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/node_modules/isarray/README.md +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/node_modules/isarray/README.md @@ -1,54 +1,54 @@ - -# isarray - -`Array#isArray` for older browsers. - -## Usage - -```js -var isArray = require('isarray'); - -console.log(isArray([])); // => true -console.log(isArray({})); // => false -``` - -## Installation - -With [npm](http://npmjs.org) do - -```bash -$ npm install isarray -``` - -Then bundle for the browser with -[browserify](https://github.com/substack/browserify). - -With [component](http://component.io) do - -```bash -$ component install juliangruber/isarray -``` - -## License - -(MIT) - -Copyright (c) 2013 Julian Gruber <julian@juliangruber.com> - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. + +# isarray + +`Array#isArray` for older browsers. + +## Usage + +```js +var isArray = require('isarray'); + +console.log(isArray([])); // => true +console.log(isArray({})); // => false +``` + +## Installation + +With [npm](http://npmjs.org) do + +```bash +$ npm install isarray +``` + +Then bundle for the browser with +[browserify](https://github.com/substack/browserify). + +With [component](http://component.io) do + +```bash +$ component install juliangruber/isarray +``` + +## License + +(MIT) + +Copyright (c) 2013 Julian Gruber <julian@juliangruber.com> + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/node_modules/isarray/build/build.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/node_modules/isarray/build/build.js index 204cba26..ec58596a 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/node_modules/isarray/build/build.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/node_modules/isarray/build/build.js @@ -1,209 +1,209 @@ - -/** - * Require the given path. - * - * @param {String} path - * @return {Object} exports - * @api public - */ - -function require(path, parent, orig) { - var resolved = require.resolve(path); - - // lookup failed - if (null == resolved) { - orig = orig || path; - parent = parent || 'root'; - var err = new Error('Failed to require "' + orig + '" from "' + parent + '"'); - err.path = orig; - err.parent = parent; - err.require = true; - throw err; - } - - var module = require.modules[resolved]; - - // perform real require() - // by invoking the module's - // registered function - if (!module.exports) { - module.exports = {}; - module.client = module.component = true; - module.call(this, module.exports, require.relative(resolved), module); - } - - return module.exports; -} - -/** - * Registered modules. - */ - -require.modules = {}; - -/** - * Registered aliases. - */ - -require.aliases = {}; - -/** - * Resolve `path`. - * - * Lookup: - * - * - PATH/index.js - * - PATH.js - * - PATH - * - * @param {String} path - * @return {String} path or null - * @api private - */ - -require.resolve = function(path) { - if (path.charAt(0) === '/') path = path.slice(1); - var index = path + '/index.js'; - - var paths = [ - path, - path + '.js', - path + '.json', - path + '/index.js', - path + '/index.json' - ]; - - for (var i = 0; i < paths.length; i++) { - var path = paths[i]; - if (require.modules.hasOwnProperty(path)) return path; - } - - if (require.aliases.hasOwnProperty(index)) { - return require.aliases[index]; - } -}; - -/** - * Normalize `path` relative to the current path. - * - * @param {String} curr - * @param {String} path - * @return {String} - * @api private - */ - -require.normalize = function(curr, path) { - var segs = []; - - if ('.' != path.charAt(0)) return path; - - curr = curr.split('/'); - path = path.split('/'); - - for (var i = 0; i < path.length; ++i) { - if ('..' == path[i]) { - curr.pop(); - } else if ('.' != path[i] && '' != path[i]) { - segs.push(path[i]); - } - } - - return curr.concat(segs).join('/'); -}; - -/** - * Register module at `path` with callback `definition`. - * - * @param {String} path - * @param {Function} definition - * @api private - */ - -require.register = function(path, definition) { - require.modules[path] = definition; -}; - -/** - * Alias a module definition. - * - * @param {String} from - * @param {String} to - * @api private - */ - -require.alias = function(from, to) { - if (!require.modules.hasOwnProperty(from)) { - throw new Error('Failed to alias "' + from + '", it does not exist'); - } - require.aliases[to] = from; -}; - -/** - * Return a require function relative to the `parent` path. - * - * @param {String} parent - * @return {Function} - * @api private - */ - -require.relative = function(parent) { - var p = require.normalize(parent, '..'); - - /** - * lastIndexOf helper. - */ - - function lastIndexOf(arr, obj) { - var i = arr.length; - while (i--) { - if (arr[i] === obj) return i; - } - return -1; - } - - /** - * The relative require() itself. - */ - - function localRequire(path) { - var resolved = localRequire.resolve(path); - return require(resolved, parent, path); - } - - /** - * Resolve relative to the parent. - */ - - localRequire.resolve = function(path) { - var c = path.charAt(0); - if ('/' == c) return path.slice(1); - if ('.' == c) return require.normalize(p, path); - - // resolve deps by returning - // the dep in the nearest "deps" - // directory - var segs = parent.split('/'); - var i = lastIndexOf(segs, 'deps') + 1; - if (!i) i = 0; - path = segs.slice(0, i + 1).join('/') + '/deps/' + path; - return path; - }; - - /** - * Check if module is defined at `path`. - */ - - localRequire.exists = function(path) { - return require.modules.hasOwnProperty(localRequire.resolve(path)); - }; - - return localRequire; -}; -require.register("isarray/index.js", function(exports, require, module){ -module.exports = Array.isArray || function (arr) { - return Object.prototype.toString.call(arr) == '[object Array]'; -}; - -}); -require.alias("isarray/index.js", "isarray/index.js"); - + +/** + * Require the given path. + * + * @param {String} path + * @return {Object} exports + * @api public + */ + +function require(path, parent, orig) { + var resolved = require.resolve(path); + + // lookup failed + if (null == resolved) { + orig = orig || path; + parent = parent || 'root'; + var err = new Error('Failed to require "' + orig + '" from "' + parent + '"'); + err.path = orig; + err.parent = parent; + err.require = true; + throw err; + } + + var module = require.modules[resolved]; + + // perform real require() + // by invoking the module's + // registered function + if (!module.exports) { + module.exports = {}; + module.client = module.component = true; + module.call(this, module.exports, require.relative(resolved), module); + } + + return module.exports; +} + +/** + * Registered modules. + */ + +require.modules = {}; + +/** + * Registered aliases. + */ + +require.aliases = {}; + +/** + * Resolve `path`. + * + * Lookup: + * + * - PATH/index.js + * - PATH.js + * - PATH + * + * @param {String} path + * @return {String} path or null + * @api private + */ + +require.resolve = function(path) { + if (path.charAt(0) === '/') path = path.slice(1); + var index = path + '/index.js'; + + var paths = [ + path, + path + '.js', + path + '.json', + path + '/index.js', + path + '/index.json' + ]; + + for (var i = 0; i < paths.length; i++) { + var path = paths[i]; + if (require.modules.hasOwnProperty(path)) return path; + } + + if (require.aliases.hasOwnProperty(index)) { + return require.aliases[index]; + } +}; + +/** + * Normalize `path` relative to the current path. + * + * @param {String} curr + * @param {String} path + * @return {String} + * @api private + */ + +require.normalize = function(curr, path) { + var segs = []; + + if ('.' != path.charAt(0)) return path; + + curr = curr.split('/'); + path = path.split('/'); + + for (var i = 0; i < path.length; ++i) { + if ('..' == path[i]) { + curr.pop(); + } else if ('.' != path[i] && '' != path[i]) { + segs.push(path[i]); + } + } + + return curr.concat(segs).join('/'); +}; + +/** + * Register module at `path` with callback `definition`. + * + * @param {String} path + * @param {Function} definition + * @api private + */ + +require.register = function(path, definition) { + require.modules[path] = definition; +}; + +/** + * Alias a module definition. + * + * @param {String} from + * @param {String} to + * @api private + */ + +require.alias = function(from, to) { + if (!require.modules.hasOwnProperty(from)) { + throw new Error('Failed to alias "' + from + '", it does not exist'); + } + require.aliases[to] = from; +}; + +/** + * Return a require function relative to the `parent` path. + * + * @param {String} parent + * @return {Function} + * @api private + */ + +require.relative = function(parent) { + var p = require.normalize(parent, '..'); + + /** + * lastIndexOf helper. + */ + + function lastIndexOf(arr, obj) { + var i = arr.length; + while (i--) { + if (arr[i] === obj) return i; + } + return -1; + } + + /** + * The relative require() itself. + */ + + function localRequire(path) { + var resolved = localRequire.resolve(path); + return require(resolved, parent, path); + } + + /** + * Resolve relative to the parent. + */ + + localRequire.resolve = function(path) { + var c = path.charAt(0); + if ('/' == c) return path.slice(1); + if ('.' == c) return require.normalize(p, path); + + // resolve deps by returning + // the dep in the nearest "deps" + // directory + var segs = parent.split('/'); + var i = lastIndexOf(segs, 'deps') + 1; + if (!i) i = 0; + path = segs.slice(0, i + 1).join('/') + '/deps/' + path; + return path; + }; + + /** + * Check if module is defined at `path`. + */ + + localRequire.exists = function(path) { + return require.modules.hasOwnProperty(localRequire.resolve(path)); + }; + + return localRequire; +}; +require.register("isarray/index.js", function(exports, require, module){ +module.exports = Array.isArray || function (arr) { + return Object.prototype.toString.call(arr) == '[object Array]'; +}; + +}); +require.alias("isarray/index.js", "isarray/index.js"); + diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/node_modules/isarray/component.json b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/node_modules/isarray/component.json index d21b0c89..9e31b683 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/node_modules/isarray/component.json +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/node_modules/isarray/component.json @@ -1,19 +1,19 @@ -{ - "name" : "isarray", - "description" : "Array#isArray for older browsers", - "version" : "0.0.1", - "repository" : "juliangruber/isarray", - "homepage": "https://github.com/juliangruber/isarray", - "main" : "index.js", - "scripts" : [ - "index.js" - ], - "dependencies" : {}, - "keywords": ["browser","isarray","array"], - "author": { - "name": "Julian Gruber", - "email": "mail@juliangruber.com", - "url": "http://juliangruber.com" - }, - "license": "MIT" -} +{ + "name" : "isarray", + "description" : "Array#isArray for older browsers", + "version" : "0.0.1", + "repository" : "juliangruber/isarray", + "homepage": "https://github.com/juliangruber/isarray", + "main" : "index.js", + "scripts" : [ + "index.js" + ], + "dependencies" : {}, + "keywords": ["browser","isarray","array"], + "author": { + "name": "Julian Gruber", + "email": "mail@juliangruber.com", + "url": "http://juliangruber.com" + }, + "license": "MIT" +} diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/node_modules/isarray/index.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/node_modules/isarray/index.js index 25533a38..5f5ad45d 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/node_modules/isarray/index.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/node_modules/isarray/index.js @@ -1,3 +1,3 @@ -module.exports = Array.isArray || function (arr) { - return Object.prototype.toString.call(arr) == '[object Array]'; -}; +module.exports = Array.isArray || function (arr) { + return Object.prototype.toString.call(arr) == '[object Array]'; +}; diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/node_modules/isarray/package.json b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/node_modules/isarray/package.json index d6ef34cd..060e073f 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/node_modules/isarray/package.json +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/node_modules/isarray/package.json @@ -1,53 +1,53 @@ -{ - "name": "isarray", - "description": "Array#isArray for older browsers", - "version": "0.0.1", - "repository": { - "type": "git", - "url": "git://github.com/juliangruber/isarray.git" - }, - "homepage": "https://github.com/juliangruber/isarray", - "main": "index.js", - "scripts": { - "test": "tap test/*.js" - }, - "dependencies": {}, - "devDependencies": { - "tap": "*" - }, - "keywords": [ - "browser", - "isarray", - "array" - ], - "author": { - "name": "Julian Gruber", - "email": "mail@juliangruber.com", - "url": "http://juliangruber.com" - }, - "license": "MIT", - "_id": "isarray@0.0.1", - "dist": { - "shasum": "8a18acfca9a8f4177e09abfc6038939b05d1eedf", - "tarball": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" - }, - "_from": "isarray@0.0.1", - "_npmVersion": "1.2.18", - "_npmUser": { - "name": "juliangruber", - "email": "julian@juliangruber.com" - }, - "maintainers": [ - { - "name": "juliangruber", - "email": "julian@juliangruber.com" - } - ], - "directories": {}, - "_shasum": "8a18acfca9a8f4177e09abfc6038939b05d1eedf", - "_resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "bugs": { - "url": "https://github.com/juliangruber/isarray/issues" - }, - "readme": "ERROR: No README data found!" -} +{ + "name": "isarray", + "description": "Array#isArray for older browsers", + "version": "0.0.1", + "repository": { + "type": "git", + "url": "git://github.com/juliangruber/isarray.git" + }, + "homepage": "https://github.com/juliangruber/isarray", + "main": "index.js", + "scripts": { + "test": "tap test/*.js" + }, + "dependencies": {}, + "devDependencies": { + "tap": "*" + }, + "keywords": [ + "browser", + "isarray", + "array" + ], + "author": { + "name": "Julian Gruber", + "email": "mail@juliangruber.com", + "url": "http://juliangruber.com" + }, + "license": "MIT", + "_id": "isarray@0.0.1", + "dist": { + "shasum": "8a18acfca9a8f4177e09abfc6038939b05d1eedf", + "tarball": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" + }, + "_from": "isarray@0.0.1", + "_npmVersion": "1.2.18", + "_npmUser": { + "name": "juliangruber", + "email": "julian@juliangruber.com" + }, + "maintainers": [ + { + "name": "juliangruber", + "email": "julian@juliangruber.com" + } + ], + "directories": {}, + "_shasum": "8a18acfca9a8f4177e09abfc6038939b05d1eedf", + "_resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "bugs": { + "url": "https://github.com/juliangruber/isarray/issues" + }, + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/package.json b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/package.json index a9e10562..72bff47e 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/package.json +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/package.json @@ -1,39 +1,39 @@ -{ - "name": "has-binary", - "version": "0.1.6", - "description": "A function that takes anything in javascript and returns true if its argument contains binary data.", - "dependencies": { - "isarray": "0.0.1" - }, - "devDependencies": { - "better-assert": "1.0.0", - "mocha": "1.17.1" - }, - "author": { - "name": "Kevin Roark" - }, - "license": "MIT", - "gitHead": "a37d7ed88fb88e49d5ed1ca15e6cc7dd004dd0e8", - "_id": "has-binary@0.1.6", - "scripts": {}, - "_shasum": "25326f39cfa4f616ad8787894e3af2cfbc7b6e10", - "_from": "has-binary@0.1.6", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "rauchg", - "email": "rauchg@gmail.com" - }, - "maintainers": [ - { - "name": "rauchg", - "email": "rauchg@gmail.com" - } - ], - "dist": { - "shasum": "25326f39cfa4f616ad8787894e3af2cfbc7b6e10", - "tarball": "https://registry.npmjs.org/has-binary/-/has-binary-0.1.6.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/has-binary/-/has-binary-0.1.6.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "has-binary", + "version": "0.1.6", + "description": "A function that takes anything in javascript and returns true if its argument contains binary data.", + "dependencies": { + "isarray": "0.0.1" + }, + "devDependencies": { + "better-assert": "1.0.0", + "mocha": "1.17.1" + }, + "author": { + "name": "Kevin Roark" + }, + "license": "MIT", + "gitHead": "a37d7ed88fb88e49d5ed1ca15e6cc7dd004dd0e8", + "_id": "has-binary@0.1.6", + "scripts": {}, + "_shasum": "25326f39cfa4f616ad8787894e3af2cfbc7b6e10", + "_from": "has-binary@0.1.6", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "rauchg", + "email": "rauchg@gmail.com" + }, + "maintainers": [ + { + "name": "rauchg", + "email": "rauchg@gmail.com" + } + ], + "dist": { + "shasum": "25326f39cfa4f616ad8787894e3af2cfbc7b6e10", + "tarball": "https://registry.npmjs.org/has-binary/-/has-binary-0.1.6.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/has-binary/-/has-binary-0.1.6.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/test.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/test.js index c5aa5f39..5320d4fe 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/test.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/has-binary/test.js @@ -1,108 +1,108 @@ - -var hasBinary = require('./'); -var assert = require('better-assert'); -var fs = require('fs'); - -var start = new Date(); - -describe('has-binarydata', function(){ - - it('should work with buffer', function(){ - assert(hasBinary(fs.readFileSync('./test.js'))); - }); - - it('should work with an array that does not contain binary', function() { - var arr = [1, 'cool', 2]; - assert(!hasBinary(arr)); - }); - - it('should work with an array that contains a buffer', function() { - var arr = [1, new Buffer('asdfasdf', 'utf8'), 2]; - assert(hasBinary(arr)); - }); - - it('should work with an object that does not contain binary', function() { - var ob = {a: 'a', b: [], c: 1234}; - assert(!hasBinary(ob)); - }); - - it('should work with an object that contains a buffer', function() { - var ob = {a: 'a', b: new Buffer('abc'), c: 1234}; - assert(hasBinary(ob)); - }); - - it('should work with null', function() { - assert(!hasBinary(null)); - }); - - it('should work with undefined', function() { - assert(!hasBinary(undefined)); - }); - - it('should work with a complex object that contains undefined and no binary', function() { - var ob = { - x: ['a', 'b', 123], - y: undefined, - z: {a: 'x', b: 'y', c: 3, d: null}, - w: [] - }; - assert(!hasBinary(ob)); - }); - - it('should work with a complex object that contains undefined and binary', function() { - var ob = { - x: ['a', 'b', 123], - y: undefined, - z: {a: 'x', b: 'y', c: 3, d: null}, - w: [], - bin: new Buffer('xxx') - }; - assert(hasBinary(ob)); - }); - - it('should handle a very large json object with no binary', function(done) { - this.timeout(); - fs.readFile(__dirname + '/fixtures/big.json', function(err, data) { - if (err) { - console.log(err); - assert(false); - } - data = JSON.parse(data); - assert(!hasBinary(data)); - done(); - }); - }); - - it('should handle a very large json object with binary', function(done) { - this.timeout(); - fs.readFile(__dirname + '/fixtures/big.json', function(err, data) { - if (err) { - console.log(err); - assert(false); - } - var ob = JSON.parse(data); - ob.bin = {bin: {bin: {bin: new Buffer('abc')}}}; - assert(hasBinary(ob)); - done(); - }); - }); - - if (global.ArrayBuffer) { - it('should work with an ArrayBuffer', function() { - assert(hasBinary(new ArrayBuffer())); - }); - } - - if (global.Blob) { - it('should work with a Blob', function() { - assert(hasBinary(new Blob())); - }); - } - - it('should print the test time', function() { - var end = new Date(); - var diff = end - start; - console.log('\ntest time: ' + diff + ' ms'); - }); - -}); + +var hasBinary = require('./'); +var assert = require('better-assert'); +var fs = require('fs'); + +var start = new Date(); + +describe('has-binarydata', function(){ + + it('should work with buffer', function(){ + assert(hasBinary(fs.readFileSync('./test.js'))); + }); + + it('should work with an array that does not contain binary', function() { + var arr = [1, 'cool', 2]; + assert(!hasBinary(arr)); + }); + + it('should work with an array that contains a buffer', function() { + var arr = [1, new Buffer('asdfasdf', 'utf8'), 2]; + assert(hasBinary(arr)); + }); + + it('should work with an object that does not contain binary', function() { + var ob = {a: 'a', b: [], c: 1234}; + assert(!hasBinary(ob)); + }); + + it('should work with an object that contains a buffer', function() { + var ob = {a: 'a', b: new Buffer('abc'), c: 1234}; + assert(hasBinary(ob)); + }); + + it('should work with null', function() { + assert(!hasBinary(null)); + }); + + it('should work with undefined', function() { + assert(!hasBinary(undefined)); + }); + + it('should work with a complex object that contains undefined and no binary', function() { + var ob = { + x: ['a', 'b', 123], + y: undefined, + z: {a: 'x', b: 'y', c: 3, d: null}, + w: [] + }; + assert(!hasBinary(ob)); + }); + + it('should work with a complex object that contains undefined and binary', function() { + var ob = { + x: ['a', 'b', 123], + y: undefined, + z: {a: 'x', b: 'y', c: 3, d: null}, + w: [], + bin: new Buffer('xxx') + }; + assert(hasBinary(ob)); + }); + + it('should handle a very large json object with no binary', function(done) { + this.timeout(); + fs.readFile(__dirname + '/fixtures/big.json', function(err, data) { + if (err) { + console.log(err); + assert(false); + } + data = JSON.parse(data); + assert(!hasBinary(data)); + done(); + }); + }); + + it('should handle a very large json object with binary', function(done) { + this.timeout(); + fs.readFile(__dirname + '/fixtures/big.json', function(err, data) { + if (err) { + console.log(err); + assert(false); + } + var ob = JSON.parse(data); + ob.bin = {bin: {bin: {bin: new Buffer('abc')}}}; + assert(hasBinary(ob)); + done(); + }); + }); + + if (global.ArrayBuffer) { + it('should work with an ArrayBuffer', function() { + assert(hasBinary(new ArrayBuffer())); + }); + } + + if (global.Blob) { + it('should work with a Blob', function() { + assert(hasBinary(new Blob())); + }); + } + + it('should print the test time', function() { + var end = new Date(); + var diff = end - start; + console.log('\ntest time: ' + diff + ' ms'); + }); + +}); diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/.gitattributes b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/.gitattributes index e535a0fc..0a91f751 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/.gitattributes +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/.gitattributes @@ -1,2 +1,2 @@ -# Automatically normalize line endings for all text-based files -* text=auto +# Automatically normalize line endings for all text-based files +* text=auto diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/.npmignore b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/.npmignore index cf08ae20..63423244 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/.npmignore +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/.npmignore @@ -1,20 +1,20 @@ -# Generated test data file (> 100 MB) -tests/data.json - -# Coverage report -coverage - -# Installed npm modules -node_modules - -# Folder view configuration files -.DS_Store -Desktop.ini - -# Thumbnail cache files -._* -Thumbs.db - -# Files that might appear on external disks -.Spotlight-V100 -.Trashes +# Generated test data file (> 100 MB) +tests/data.json + +# Coverage report +coverage + +# Installed npm modules +node_modules + +# Folder view configuration files +.DS_Store +Desktop.ini + +# Thumbnail cache files +._* +Thumbs.db + +# Files that might appear on external disks +.Spotlight-V100 +.Trashes diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/.travis.yml b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/.travis.yml index 04d4006d..ff7cdb4a 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/.travis.yml +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/.travis.yml @@ -1,21 +1,21 @@ -language: node_js -node_js: - - "0.10" -before_script: - - "npm install -g grunt-cli" - # Narwhal uses a hardcoded path to openjdk v6, so use that version - - "sudo apt-get update -qq" - - "sudo apt-get install -qq openjdk-6-jre" - - "PACKAGE=rhino1_7R3; wget http://ftp.mozilla.org/pub/mozilla.org/js/$PACKAGE.zip && sudo unzip $PACKAGE -d /opt/ && rm $PACKAGE.zip" - - "PACKAGE=rhino1_7R3; echo -e '#!/bin/sh\\njava -jar /opt/'$PACKAGE'/js.jar $@' | sudo tee /usr/local/bin/rhino && sudo chmod +x /usr/local/bin/rhino" - - "PACKAGE=ringojs-0.11; wget https://github.com/ringo/ringojs/releases/download/v0.11.0/$PACKAGE.zip && sudo unzip $PACKAGE -d /opt/ && rm $PACKAGE.zip" - - "PACKAGE=ringojs-0.11; sudo ln -s /opt/$PACKAGE/bin/ringo /usr/local/bin/ringo && sudo chmod +x /usr/local/bin/ringo" - - "PACKAGE=v0.3.2; wget https://github.com/280north/narwhal/archive/$PACKAGE.zip && sudo unzip $PACKAGE -d /opt/ && rm $PACKAGE.zip" - - "PACKAGE=narwhal-0.3.2; sudo ln -s /opt/$PACKAGE/bin/narwhal /usr/local/bin/narwhal && sudo chmod +x /usr/local/bin/narwhal" - # If the enviroment stores rt.jar in a different directory, find it and symlink the directory - - "PREFIX=/usr/lib/jvm; if [ ! -d $PREFIX/java-6-openjdk ]; then for d in $PREFIX/java-6-openjdk-*; do if [ -e $d/jre/lib/rt.jar ]; then sudo ln -s $d $PREFIX/java-6-openjdk; break; fi; done; fi" - - "sudo apt-get install -qq python; python --version" -script: - - "grunt ci" -after_script: - - "grunt shell:cover-coveralls" +language: node_js +node_js: + - "0.10" +before_script: + - "npm install -g grunt-cli" + # Narwhal uses a hardcoded path to openjdk v6, so use that version + - "sudo apt-get update -qq" + - "sudo apt-get install -qq openjdk-6-jre" + - "PACKAGE=rhino1_7R3; wget http://ftp.mozilla.org/pub/mozilla.org/js/$PACKAGE.zip && sudo unzip $PACKAGE -d /opt/ && rm $PACKAGE.zip" + - "PACKAGE=rhino1_7R3; echo -e '#!/bin/sh\\njava -jar /opt/'$PACKAGE'/js.jar $@' | sudo tee /usr/local/bin/rhino && sudo chmod +x /usr/local/bin/rhino" + - "PACKAGE=ringojs-0.11; wget https://github.com/ringo/ringojs/releases/download/v0.11.0/$PACKAGE.zip && sudo unzip $PACKAGE -d /opt/ && rm $PACKAGE.zip" + - "PACKAGE=ringojs-0.11; sudo ln -s /opt/$PACKAGE/bin/ringo /usr/local/bin/ringo && sudo chmod +x /usr/local/bin/ringo" + - "PACKAGE=v0.3.2; wget https://github.com/280north/narwhal/archive/$PACKAGE.zip && sudo unzip $PACKAGE -d /opt/ && rm $PACKAGE.zip" + - "PACKAGE=narwhal-0.3.2; sudo ln -s /opt/$PACKAGE/bin/narwhal /usr/local/bin/narwhal && sudo chmod +x /usr/local/bin/narwhal" + # If the enviroment stores rt.jar in a different directory, find it and symlink the directory + - "PREFIX=/usr/lib/jvm; if [ ! -d $PREFIX/java-6-openjdk ]; then for d in $PREFIX/java-6-openjdk-*; do if [ -e $d/jre/lib/rt.jar ]; then sudo ln -s $d $PREFIX/java-6-openjdk; break; fi; done; fi" + - "sudo apt-get install -qq python; python --version" +script: + - "grunt ci" +after_script: + - "grunt shell:cover-coveralls" diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/Gruntfile.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/Gruntfile.js index d81020dd..2af2bf59 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/Gruntfile.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/Gruntfile.js @@ -1,75 +1,75 @@ -module.exports = function(grunt) { - - grunt.initConfig({ - 'shell': { - 'options': { - 'stdout': true, - 'stderr': true, - 'failOnError': true - }, - 'generate-test-data': { // Only when needed - 'command': 'if [ ! -f data.json ]; then python generate-test-data.py; fi', - 'options': { - 'execOptions': { - 'cwd': 'tests' - } - } - }, - 'cover-html': { - 'command': 'istanbul cover --report "html" --verbose --dir "coverage" "tests/tests.js"; istanbul report --root "coverage" --format "html"' - }, - 'cover-coveralls': { - 'command': 'istanbul cover --verbose --dir "coverage" "tests/tests.js" && cat coverage/lcov.info | coveralls; rm -rf coverage/lcov*' - }, - 'test-narwhal': { - 'command': 'echo "Testing in Narwhal..."; export NARWHAL_OPTIMIZATION=-1; narwhal "tests/tests.js"' - }, - 'test-phantomjs': { - 'command': 'echo "Testing in PhantomJS..."; phantomjs "tests/tests.js"' - }, - // Rhino 1.7R4 has a bug that makes it impossible to test in. - // https://bugzilla.mozilla.org/show_bug.cgi?id=775566 - // To test, use Rhino 1.7R3, or wait (heh) for the 1.7R5 release. - 'test-rhino': { - 'command': 'echo "Testing in Rhino..."; rhino -opt -1 "tests.js"', - 'options': { - 'execOptions': { - 'cwd': 'tests' - } - } - }, - 'test-ringo': { - 'command': 'echo "Testing in Ringo..."; ringo -o -1 "tests/tests.js"' - }, - 'test-node': { - 'command': 'echo "Testing in Node..."; node "tests/tests.js" --extended' - }, - 'test-browser': { - 'command': 'echo "Testing in a browser..."; open "tests/index.html"' - } - } - }); - - grunt.loadNpmTasks('grunt-shell'); - - grunt.registerTask('cover', 'shell:cover-html'); - grunt.registerTask('ci', [ - 'shell:generate-test-data', - 'shell:test-narwhal', - 'shell:test-phantomjs', - 'shell:test-rhino', - 'shell:test-ringo', - 'shell:test-node', - ]); - grunt.registerTask('test', [ - 'shell:generate-test-data', - 'ci', - 'shell:test-browser' - ]); - - grunt.registerTask('default', [ - 'shell:test-node', - 'cover' - ]); - -}; +module.exports = function(grunt) { + + grunt.initConfig({ + 'shell': { + 'options': { + 'stdout': true, + 'stderr': true, + 'failOnError': true + }, + 'generate-test-data': { // Only when needed + 'command': 'if [ ! -f data.json ]; then python generate-test-data.py; fi', + 'options': { + 'execOptions': { + 'cwd': 'tests' + } + } + }, + 'cover-html': { + 'command': 'istanbul cover --report "html" --verbose --dir "coverage" "tests/tests.js"; istanbul report --root "coverage" --format "html"' + }, + 'cover-coveralls': { + 'command': 'istanbul cover --verbose --dir "coverage" "tests/tests.js" && cat coverage/lcov.info | coveralls; rm -rf coverage/lcov*' + }, + 'test-narwhal': { + 'command': 'echo "Testing in Narwhal..."; export NARWHAL_OPTIMIZATION=-1; narwhal "tests/tests.js"' + }, + 'test-phantomjs': { + 'command': 'echo "Testing in PhantomJS..."; phantomjs "tests/tests.js"' + }, + // Rhino 1.7R4 has a bug that makes it impossible to test in. + // https://bugzilla.mozilla.org/show_bug.cgi?id=775566 + // To test, use Rhino 1.7R3, or wait (heh) for the 1.7R5 release. + 'test-rhino': { + 'command': 'echo "Testing in Rhino..."; rhino -opt -1 "tests.js"', + 'options': { + 'execOptions': { + 'cwd': 'tests' + } + } + }, + 'test-ringo': { + 'command': 'echo "Testing in Ringo..."; ringo -o -1 "tests/tests.js"' + }, + 'test-node': { + 'command': 'echo "Testing in Node..."; node "tests/tests.js" --extended' + }, + 'test-browser': { + 'command': 'echo "Testing in a browser..."; open "tests/index.html"' + } + } + }); + + grunt.loadNpmTasks('grunt-shell'); + + grunt.registerTask('cover', 'shell:cover-html'); + grunt.registerTask('ci', [ + 'shell:generate-test-data', + 'shell:test-narwhal', + 'shell:test-phantomjs', + 'shell:test-rhino', + 'shell:test-ringo', + 'shell:test-node', + ]); + grunt.registerTask('test', [ + 'shell:generate-test-data', + 'ci', + 'shell:test-browser' + ]); + + grunt.registerTask('default', [ + 'shell:test-node', + 'cover' + ]); + +}; diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/LICENSE-MIT.txt b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/LICENSE-MIT.txt index b216658d..a41e0a7e 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/LICENSE-MIT.txt +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/LICENSE-MIT.txt @@ -1,20 +1,20 @@ -Copyright Mathias Bynens - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +Copyright Mathias Bynens + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/README.md b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/README.md index 12e84de0..32351cd1 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/README.md +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/README.md @@ -1,119 +1,119 @@ -# utf8.js [![Build status](https://travis-ci.org/mathiasbynens/utf8.js.svg?branch=master)](https://travis-ci.org/mathiasbynens/utf8.js) [![Code coverage status](http://img.shields.io/coveralls/mathiasbynens/utf8.js/master.svg)](https://coveralls.io/r/mathiasbynens/utf8.js) [![Dependency status](https://gemnasium.com/mathiasbynens/utf8.js.svg)](https://gemnasium.com/mathiasbynens/utf8.js) - -_utf8.js_ is a well-tested UTF-8 encoder/decoder written in JavaScript. Unlike many other JavaScript solutions, it is designed to be a _proper_ UTF-8 encoder/decoder: it can encode/decode any scalar Unicode code point values, as per [the Encoding Standard](https://encoding.spec.whatwg.org/#utf-8). [Here’s an online demo.](https://mothereff.in/utf-8) - -Feel free to fork if you see possible improvements! - -## Installation - -Via [npm](https://www.npmjs.org/): - -```bash -npm install utf8 -``` - -Via [Bower](http://bower.io/): - -```bash -bower install utf8 -``` - -Via [Component](https://github.com/component/component): - -```bash -component install mathiasbynens/utf8.js -``` - -In a browser: - -```html - -``` - -In [Narwhal](http://narwhaljs.org/), [Node.js](https://nodejs.org/), and [RingoJS ≥ v0.8.0](http://ringojs.org/): - -```js -var utf8 = require('utf8'); -``` - -In [Rhino](http://www.mozilla.org/rhino/): - -```js -load('utf8.js'); -``` - -Using an AMD loader like [RequireJS](http://requirejs.org/): - -```js -require( - { - 'paths': { - 'utf8': 'path/to/utf8' - } - }, - ['utf8'], - function(utf8) { - console.log(utf8); - } -); -``` - -## API - -### `utf8.encode(string)` - -Encodes any given JavaScript string (`string`) as UTF-8, and returns the UTF-8-encoded version of the string. It throws an error if the input string contains a non-scalar value, i.e. a lone surrogate. (If you need to be able to encode non-scalar values as well, use [WTF-8](https://mths.be/wtf8) instead.) - -```js -// U+00A9 COPYRIGHT SIGN; see http://codepoints.net/U+00A9 -utf8.encode('\xA9'); -// → '\xC2\xA9' -// U+10001 LINEAR B SYLLABLE B038 E; see http://codepoints.net/U+10001 -utf8.encode('\uD800\uDC01'); -// → '\xF0\x90\x80\x81' -``` - -### `utf8.decode(byteString)` - -Decodes any given UTF-8-encoded string (`byteString`) as UTF-8, and returns the UTF-8-decoded version of the string. It throws an error when malformed UTF-8 is detected. (If you need to be able to decode encoded non-scalar values as well, use [WTF-8](https://mths.be/wtf8) instead.) - -```js -utf8.decode('\xC2\xA9'); -// → '\xA9' - -utf8.decode('\xF0\x90\x80\x81'); -// → '\uD800\uDC01' -// → U+10001 LINEAR B SYLLABLE B038 E -``` - -### `utf8.version` - -A string representing the semantic version number. - -## Support - -utf8.js has been tested in at least Chrome 27-39, Firefox 3-34, Safari 4-8, Opera 10-28, IE 6-11, Node.js v0.10.0, Narwhal 0.3.2, RingoJS 0.8-0.11, PhantomJS 1.9.0, and Rhino 1.7RC4. - -## Unit tests & code coverage - -After cloning this repository, run `npm install` to install the dependencies needed for development and testing. You may want to install Istanbul _globally_ using `npm install istanbul -g`. - -Once that’s done, you can run the unit tests in Node using `npm test` or `node tests/tests.js`. To run the tests in Rhino, Ringo, Narwhal, PhantomJS, and web browsers as well, use `grunt test`. - -To generate the code coverage report, use `grunt cover`. - -## FAQ - -### Why is the first release named v2.0.0? Haven’t you heard of [semantic versioning](http://semver.org/)? - -Long before utf8.js was created, the `utf8` module on npm was registered and used by another (slightly buggy) library. @ryanmcgrath was kind enough to give me access to the `utf8` package on npm when I told him about utf8.js. Since there has already been a v1.0.0 release of the old library, and to avoid breaking backwards compatibility with projects that rely on the `utf8` npm package, I decided the tag the first release of utf8.js as v2.0.0 and take it from there. - -## Author - -| [![twitter/mathias](https://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter") | -|---| -| [Mathias Bynens](https://mathiasbynens.be/) | - -## License - -utf8.js is available under the [MIT](https://mths.be/mit) license. +# utf8.js [![Build status](https://travis-ci.org/mathiasbynens/utf8.js.svg?branch=master)](https://travis-ci.org/mathiasbynens/utf8.js) [![Code coverage status](http://img.shields.io/coveralls/mathiasbynens/utf8.js/master.svg)](https://coveralls.io/r/mathiasbynens/utf8.js) [![Dependency status](https://gemnasium.com/mathiasbynens/utf8.js.svg)](https://gemnasium.com/mathiasbynens/utf8.js) + +_utf8.js_ is a well-tested UTF-8 encoder/decoder written in JavaScript. Unlike many other JavaScript solutions, it is designed to be a _proper_ UTF-8 encoder/decoder: it can encode/decode any scalar Unicode code point values, as per [the Encoding Standard](https://encoding.spec.whatwg.org/#utf-8). [Here’s an online demo.](https://mothereff.in/utf-8) + +Feel free to fork if you see possible improvements! + +## Installation + +Via [npm](https://www.npmjs.org/): + +```bash +npm install utf8 +``` + +Via [Bower](http://bower.io/): + +```bash +bower install utf8 +``` + +Via [Component](https://github.com/component/component): + +```bash +component install mathiasbynens/utf8.js +``` + +In a browser: + +```html + +``` + +In [Narwhal](http://narwhaljs.org/), [Node.js](https://nodejs.org/), and [RingoJS ≥ v0.8.0](http://ringojs.org/): + +```js +var utf8 = require('utf8'); +``` + +In [Rhino](http://www.mozilla.org/rhino/): + +```js +load('utf8.js'); +``` + +Using an AMD loader like [RequireJS](http://requirejs.org/): + +```js +require( + { + 'paths': { + 'utf8': 'path/to/utf8' + } + }, + ['utf8'], + function(utf8) { + console.log(utf8); + } +); +``` + +## API + +### `utf8.encode(string)` + +Encodes any given JavaScript string (`string`) as UTF-8, and returns the UTF-8-encoded version of the string. It throws an error if the input string contains a non-scalar value, i.e. a lone surrogate. (If you need to be able to encode non-scalar values as well, use [WTF-8](https://mths.be/wtf8) instead.) + +```js +// U+00A9 COPYRIGHT SIGN; see http://codepoints.net/U+00A9 +utf8.encode('\xA9'); +// → '\xC2\xA9' +// U+10001 LINEAR B SYLLABLE B038 E; see http://codepoints.net/U+10001 +utf8.encode('\uD800\uDC01'); +// → '\xF0\x90\x80\x81' +``` + +### `utf8.decode(byteString)` + +Decodes any given UTF-8-encoded string (`byteString`) as UTF-8, and returns the UTF-8-decoded version of the string. It throws an error when malformed UTF-8 is detected. (If you need to be able to decode encoded non-scalar values as well, use [WTF-8](https://mths.be/wtf8) instead.) + +```js +utf8.decode('\xC2\xA9'); +// → '\xA9' + +utf8.decode('\xF0\x90\x80\x81'); +// → '\uD800\uDC01' +// → U+10001 LINEAR B SYLLABLE B038 E +``` + +### `utf8.version` + +A string representing the semantic version number. + +## Support + +utf8.js has been tested in at least Chrome 27-39, Firefox 3-34, Safari 4-8, Opera 10-28, IE 6-11, Node.js v0.10.0, Narwhal 0.3.2, RingoJS 0.8-0.11, PhantomJS 1.9.0, and Rhino 1.7RC4. + +## Unit tests & code coverage + +After cloning this repository, run `npm install` to install the dependencies needed for development and testing. You may want to install Istanbul _globally_ using `npm install istanbul -g`. + +Once that’s done, you can run the unit tests in Node using `npm test` or `node tests/tests.js`. To run the tests in Rhino, Ringo, Narwhal, PhantomJS, and web browsers as well, use `grunt test`. + +To generate the code coverage report, use `grunt cover`. + +## FAQ + +### Why is the first release named v2.0.0? Haven’t you heard of [semantic versioning](http://semver.org/)? + +Long before utf8.js was created, the `utf8` module on npm was registered and used by another (slightly buggy) library. @ryanmcgrath was kind enough to give me access to the `utf8` package on npm when I told him about utf8.js. Since there has already been a v1.0.0 release of the old library, and to avoid breaking backwards compatibility with projects that rely on the `utf8` npm package, I decided the tag the first release of utf8.js as v2.0.0 and take it from there. + +## Author + +| [![twitter/mathias](https://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter") | +|---| +| [Mathias Bynens](https://mathiasbynens.be/) | + +## License + +utf8.js is available under the [MIT](https://mths.be/mit) license. diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/bower.json b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/bower.json index 5676e0f8..fe8fa726 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/bower.json +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/bower.json @@ -1,14 +1,14 @@ -{ - "name": "utf8", - "version": "2.0.0", - "main": "utf8.js", - "ignore": [ - "coverage", - "tests", - ".*", - "component.json", - "Gruntfile.js", - "node_modules", - "package.json" - ] -} +{ + "name": "utf8", + "version": "2.0.0", + "main": "utf8.js", + "ignore": [ + "coverage", + "tests", + ".*", + "component.json", + "Gruntfile.js", + "node_modules", + "package.json" + ] +} diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/component.json b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/component.json index 37329bb1..5165d4fe 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/component.json +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/component.json @@ -1,16 +1,16 @@ -{ - "name": "utf8", - "version": "2.0.0", - "description": "A well-tested UTF-8 encoder/decoder written in JavaScript.", - "repo": "mathiasbynens/utf8.js", - "license": "MIT/GPL", - "scripts": [ - "utf8.js" - ], - "keywords": [ - "charset", - "encoding", - "unicode", - "utf8" - ] -} +{ + "name": "utf8", + "version": "2.0.0", + "description": "A well-tested UTF-8 encoder/decoder written in JavaScript.", + "repo": "mathiasbynens/utf8.js", + "license": "MIT/GPL", + "scripts": [ + "utf8.js" + ], + "keywords": [ + "charset", + "encoding", + "unicode", + "utf8" + ] +} diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/package.json b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/package.json index 6d04d07d..0498ae03 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/package.json +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/package.json @@ -1,64 +1,64 @@ -{ - "name": "utf8", - "version": "2.1.0", - "description": "A well-tested UTF-8 encoder/decoder written in JavaScript.", - "homepage": "https://mths.be/utf8js", - "main": "utf8.js", - "keywords": [ - "charset", - "encoding", - "unicode", - "utf8" - ], - "license": "MIT", - "author": { - "name": "Mathias Bynens", - "url": "https://mathiasbynens.be/" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/mathiasbynens/utf8.js.git" - }, - "bugs": { - "url": "https://github.com/mathiasbynens/utf8.js/issues" - }, - "scripts": { - "test": "node tests/tests.js" - }, - "devDependencies": { - "coveralls": "^2.11.1", - "grunt": "^0.4.5", - "grunt-shell": "^1.1.1", - "istanbul": "^0.3.5", - "qunit-extras": "^1.4.0", - "qunitjs": "~1.11.0", - "requirejs": "^2.1.11" - }, - "gitHead": "1961da40649c4103b5d01c29f8e6bcc3231a1372", - "_id": "utf8@2.1.0", - "_shasum": "0cfec5c8052d44a23e3aaa908104e8075f95dfd5", - "_from": "utf8@2.1.0", - "_npmVersion": "2.1.11", - "_nodeVersion": "0.10.32", - "_npmUser": { - "name": "mathias", - "email": "mathias@qiwi.be" - }, - "maintainers": [ - { - "name": "ryanmcgrath", - "email": "ryan@venodesigns.net" - }, - { - "name": "mathias", - "email": "mathias@qiwi.be" - } - ], - "dist": { - "shasum": "0cfec5c8052d44a23e3aaa908104e8075f95dfd5", - "tarball": "https://registry.npmjs.org/utf8/-/utf8-2.1.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/utf8/-/utf8-2.1.0.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "utf8", + "version": "2.1.0", + "description": "A well-tested UTF-8 encoder/decoder written in JavaScript.", + "homepage": "https://mths.be/utf8js", + "main": "utf8.js", + "keywords": [ + "charset", + "encoding", + "unicode", + "utf8" + ], + "license": "MIT", + "author": { + "name": "Mathias Bynens", + "url": "https://mathiasbynens.be/" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/mathiasbynens/utf8.js.git" + }, + "bugs": { + "url": "https://github.com/mathiasbynens/utf8.js/issues" + }, + "scripts": { + "test": "node tests/tests.js" + }, + "devDependencies": { + "coveralls": "^2.11.1", + "grunt": "^0.4.5", + "grunt-shell": "^1.1.1", + "istanbul": "^0.3.5", + "qunit-extras": "^1.4.0", + "qunitjs": "~1.11.0", + "requirejs": "^2.1.11" + }, + "gitHead": "1961da40649c4103b5d01c29f8e6bcc3231a1372", + "_id": "utf8@2.1.0", + "_shasum": "0cfec5c8052d44a23e3aaa908104e8075f95dfd5", + "_from": "utf8@2.1.0", + "_npmVersion": "2.1.11", + "_nodeVersion": "0.10.32", + "_npmUser": { + "name": "mathias", + "email": "mathias@qiwi.be" + }, + "maintainers": [ + { + "name": "ryanmcgrath", + "email": "ryan@venodesigns.net" + }, + { + "name": "mathias", + "email": "mathias@qiwi.be" + } + ], + "dist": { + "shasum": "0cfec5c8052d44a23e3aaa908104e8075f95dfd5", + "tarball": "https://registry.npmjs.org/utf8/-/utf8-2.1.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/utf8/-/utf8-2.1.0.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/tests/generate-test-data.py b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/tests/generate-test-data.py old mode 100755 new mode 100644 index 3d8bcdc2..08be0d2c --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/tests/generate-test-data.py +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/tests/generate-test-data.py @@ -1,50 +1,50 @@ -#!/usr/bin/env python - -import re -import json - -# https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae -# http://stackoverflow.com/a/13436167/96656 -def unisymbol(codePoint): - if codePoint >= 0x0000 and codePoint <= 0xFFFF: - return unichr(codePoint) - elif codePoint >= 0x010000 and codePoint <= 0x10FFFF: - highSurrogate = int((codePoint - 0x10000) / 0x400) + 0xD800 - lowSurrogate = int((codePoint - 0x10000) % 0x400) + 0xDC00 - return unichr(highSurrogate) + unichr(lowSurrogate) - else: - return 'Error' - -def hexify(codePoint): - return 'U+' + hex(codePoint)[2:].upper().zfill(6) - -def writeFile(filename, contents): - print filename - with open(filename, 'w') as f: - f.write(contents.strip() + '\n') - -data = [] -for codePoint in range(0x000000, 0x10FFFF + 1): - # Skip non-scalar values. - if codePoint >= 0xD800 and codePoint <= 0xDFFF: - continue - symbol = unisymbol(codePoint) - # http://stackoverflow.com/a/17199950/96656 - bytes = symbol.encode('utf8').decode('latin1') - data.append({ - 'codePoint': codePoint, - 'decoded': symbol, - 'encoded': bytes - }); - -jsonData = json.dumps(data, sort_keys=False, indent=2, separators=(',', ': ')) -# Use tabs instead of double spaces for indentation -jsonData = jsonData.replace(' ', '\t') -# Escape hexadecimal digits in escape sequences -jsonData = re.sub( - r'\\u([a-fA-F0-9]{4})', - lambda match: r'\u{}'.format(match.group(1).upper()), - jsonData -) - -writeFile('data.json', jsonData) +#!/usr/bin/env python + +import re +import json + +# https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae +# http://stackoverflow.com/a/13436167/96656 +def unisymbol(codePoint): + if codePoint >= 0x0000 and codePoint <= 0xFFFF: + return unichr(codePoint) + elif codePoint >= 0x010000 and codePoint <= 0x10FFFF: + highSurrogate = int((codePoint - 0x10000) / 0x400) + 0xD800 + lowSurrogate = int((codePoint - 0x10000) % 0x400) + 0xDC00 + return unichr(highSurrogate) + unichr(lowSurrogate) + else: + return 'Error' + +def hexify(codePoint): + return 'U+' + hex(codePoint)[2:].upper().zfill(6) + +def writeFile(filename, contents): + print filename + with open(filename, 'w') as f: + f.write(contents.strip() + '\n') + +data = [] +for codePoint in range(0x000000, 0x10FFFF + 1): + # Skip non-scalar values. + if codePoint >= 0xD800 and codePoint <= 0xDFFF: + continue + symbol = unisymbol(codePoint) + # http://stackoverflow.com/a/17199950/96656 + bytes = symbol.encode('utf8').decode('latin1') + data.append({ + 'codePoint': codePoint, + 'decoded': symbol, + 'encoded': bytes + }); + +jsonData = json.dumps(data, sort_keys=False, indent=2, separators=(',', ': ')) +# Use tabs instead of double spaces for indentation +jsonData = jsonData.replace(' ', '\t') +# Escape hexadecimal digits in escape sequences +jsonData = re.sub( + r'\\u([a-fA-F0-9]{4})', + lambda match: r'\u{}'.format(match.group(1).upper()), + jsonData +) + +writeFile('data.json', jsonData) diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/tests/index.html b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/tests/index.html index d85dd4b5..13cc04d5 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/tests/index.html +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/tests/index.html @@ -1,35 +1,35 @@ - - - - - utf8.js test suite - - - -
- - - - - - + + + + + utf8.js test suite + + + +
+ + + + + + diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/tests/tests.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/tests/tests.js index 73fb1e71..5ebe5135 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/tests/tests.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/tests/tests.js @@ -1,276 +1,276 @@ -(function(root) { - 'use strict'; - - var noop = Function.prototype; - - var load = (typeof require == 'function' && !(root.define && define.amd)) ? - require : - (!root.document && root.java && root.load) || noop; - - var QUnit = (function() { - return root.QUnit || ( - root.addEventListener || (root.addEventListener = noop), - root.setTimeout || (root.setTimeout = noop), - root.QUnit = load('../node_modules/qunitjs/qunit/qunit.js') || root.QUnit, - addEventListener === noop && delete root.addEventListener, - root.QUnit - ); - }()); - - var qe = load('../node_modules/qunit-extras/qunit-extras.js'); - if (qe) { - qe.runInContext(root); - } - - /** The `utf8` object to test */ - var utf8 = root.utf8 || (root.utf8 = ( - utf8 = load('../utf8.js') || root.utf8, - utf8 = utf8.utf8 || utf8 - )); - - /*--------------------------------------------------------------------------*/ - - function forEach(array, fn) { - var index = -1; - var length = array.length; - while (++index < length) { - fn(array[index]); - } - } - - // Quick and dirty test to see if we’re in Node & need extended tests - var runExtendedTests = (function() { - try { - return process.argv[0] == 'node' && process.argv[2] == '--extended'; - } catch(error) { } - }()); - - var data = [ - // 1-byte - { - 'codePoint': 0x0000, - 'decoded': '\0', - 'encoded': '\0' - }, - { - 'codePoint': 0x005C, - 'decoded': '\x5C', - 'encoded': '\x5C' - }, - { - 'codePoint': 0x007F, - 'decoded': '\x7F', - 'encoded': '\x7F' - }, - - // 2-byte - { - 'codePoint': 0x0080, - 'decoded': '\x80', - 'encoded': '\xC2\x80' - }, - { - 'codePoint': 0x05CA, - 'decoded': '\u05CA', - 'encoded': '\xD7\x8A' - }, - { - 'codePoint': 0x07FF, - 'decoded': '\u07FF', - 'encoded': '\xDF\xBF', - }, - - // 3-byte - { - 'codePoint': 0x0800, - 'decoded': '\u0800', - 'encoded': '\xE0\xA0\x80', - }, - { - 'codePoint': 0x2C3C, - 'decoded': '\u2C3C', - 'encoded': '\xE2\xB0\xBC' - }, - { - 'codePoint': 0xFFFF, - 'decoded': '\uFFFF', - 'encoded': '\xEF\xBF\xBF' - }, - // unmatched surrogate halves - // high surrogates: 0xD800 to 0xDBFF - { - 'codePoint': 0xD800, - 'decoded': '\uD800', - 'encoded': '\xED\xA0\x80', - 'error': true - }, - { - 'description': 'High surrogate followed by another high surrogate', - 'decoded': '\uD800\uD800', - 'encoded': '\xED\xA0\x80\xED\xA0\x80', - 'error': true - }, - { - 'description': 'High surrogate followed by a symbol that is not a surrogate', - 'decoded': '\uD800A', - 'encoded': '\xED\xA0\x80A', - 'error': true - }, - { - 'description': 'Unmatched high surrogate, followed by a surrogate pair, followed by an unmatched high surrogate', - 'decoded': '\uD800\uD834\uDF06\uD800', - 'encoded': '\xED\xA0\x80\xF0\x9D\x8C\x86\xED\xA0\x80', - 'error': true - }, - { - 'codePoint': 0xD9AF, - 'decoded': '\uD9AF', - 'encoded': '\xED\xA6\xAF', - 'error': true - }, - { - 'codePoint': 0xDBFF, - 'decoded': '\uDBFF', - 'encoded': '\xED\xAF\xBF', - 'error': true - }, - // low surrogates: 0xDC00 to 0xDFFF - { - 'codePoint': 0xDC00, - 'decoded': '\uDC00', - 'encoded': '\xED\xB0\x80', - 'error': true - }, - { - 'description': 'Low surrogate followed by another low surrogate', - 'decoded': '\uDC00\uDC00', - 'encoded': '\xED\xB0\x80\xED\xB0\x80', - 'error': true - }, - { - 'description': 'Low surrogate followed by a symbol that is not a surrogate', - 'decoded': '\uDC00A', - 'encoded': '\xED\xB0\x80A', - 'error': true - }, - { - 'description': 'Unmatched low surrogate, followed by a surrogate pair, followed by an unmatched low surrogate', - 'decoded': '\uDC00\uD834\uDF06\uDC00', - 'encoded': '\xED\xB0\x80\xF0\x9D\x8C\x86\xED\xB0\x80', - 'error': true - }, - { - 'codePoint': 0xDEEE, - 'decoded': '\uDEEE', - 'encoded': '\xED\xBB\xAE', - 'error': true - }, - { - 'codePoint': 0xDFFF, - 'decoded': '\uDFFF', - 'encoded': '\xED\xBF\xBF', - 'error': true - }, - - // 4-byte - { - 'codePoint': 0x010000, - 'decoded': '\uD800\uDC00', - 'encoded': '\xF0\x90\x80\x80' - }, - { - 'codePoint': 0x01D306, - 'decoded': '\uD834\uDF06', - 'encoded': '\xF0\x9D\x8C\x86' - }, - { - 'codePoint': 0x10FFF, - 'decoded': '\uDBFF\uDFFF', - 'encoded': '\xF4\x8F\xBF\xBF' - } - ]; - - if (runExtendedTests) { - data = data.concat(require('./data.json')); - } - - // `throws` is a reserved word in ES3; alias it to avoid errors - var raises = QUnit.assert['throws']; - - // explicitly call `QUnit.module()` instead of `module()` - // in case we are in a CLI environment - QUnit.module('utf8.js'); - - test('encode/decode', function() { - forEach(data, function(object) { - var description = object.description || 'U+' + object.codePoint.toString(16).toUpperCase(); - ; - if (object.error) { - raises( - function() { - utf8.decode(object.encoded); - }, - Error, - 'Error: non-scalar value detected' - ); - raises( - function() { - utf8.encode(object.decoded); - }, - Error, - 'Error: non-scalar value detected' - ); - } else { - equal( - object.encoded, - utf8.encode(object.decoded), - 'Encoding: ' + description - ); - equal( - object.decoded, - utf8.decode(object.encoded), - 'Decoding: ' + description - ); - } - }); - - // Error handling - raises( - function() { - utf8.decode('\uFFFF'); - }, - Error, - 'Error: invalid UTF-8 detected' - ); - raises( - function() { - utf8.decode('\xE9\x00\x00'); - }, - Error, - 'Error: invalid continuation byte (4-byte sequence expected)' - ); - raises( - function() { - utf8.decode('\xC2\uFFFF'); - }, - Error, - 'Error: invalid continuation byte' - ); - raises( - function() { - utf8.decode('\xF0\x9D'); - }, - Error, - 'Error: invalid byte index' - ); - }); - - /*--------------------------------------------------------------------------*/ - - // configure QUnit and call `QUnit.start()` for - // Narwhal, Node.js, PhantomJS, Rhino, and RingoJS - if (!root.document || root.phantom) { - QUnit.config.noglobals = true; - QUnit.start(); - } -}(typeof global == 'object' && global || this)); +(function(root) { + 'use strict'; + + var noop = Function.prototype; + + var load = (typeof require == 'function' && !(root.define && define.amd)) ? + require : + (!root.document && root.java && root.load) || noop; + + var QUnit = (function() { + return root.QUnit || ( + root.addEventListener || (root.addEventListener = noop), + root.setTimeout || (root.setTimeout = noop), + root.QUnit = load('../node_modules/qunitjs/qunit/qunit.js') || root.QUnit, + addEventListener === noop && delete root.addEventListener, + root.QUnit + ); + }()); + + var qe = load('../node_modules/qunit-extras/qunit-extras.js'); + if (qe) { + qe.runInContext(root); + } + + /** The `utf8` object to test */ + var utf8 = root.utf8 || (root.utf8 = ( + utf8 = load('../utf8.js') || root.utf8, + utf8 = utf8.utf8 || utf8 + )); + + /*--------------------------------------------------------------------------*/ + + function forEach(array, fn) { + var index = -1; + var length = array.length; + while (++index < length) { + fn(array[index]); + } + } + + // Quick and dirty test to see if we’re in Node & need extended tests + var runExtendedTests = (function() { + try { + return process.argv[0] == 'node' && process.argv[2] == '--extended'; + } catch(error) { } + }()); + + var data = [ + // 1-byte + { + 'codePoint': 0x0000, + 'decoded': '\0', + 'encoded': '\0' + }, + { + 'codePoint': 0x005C, + 'decoded': '\x5C', + 'encoded': '\x5C' + }, + { + 'codePoint': 0x007F, + 'decoded': '\x7F', + 'encoded': '\x7F' + }, + + // 2-byte + { + 'codePoint': 0x0080, + 'decoded': '\x80', + 'encoded': '\xC2\x80' + }, + { + 'codePoint': 0x05CA, + 'decoded': '\u05CA', + 'encoded': '\xD7\x8A' + }, + { + 'codePoint': 0x07FF, + 'decoded': '\u07FF', + 'encoded': '\xDF\xBF', + }, + + // 3-byte + { + 'codePoint': 0x0800, + 'decoded': '\u0800', + 'encoded': '\xE0\xA0\x80', + }, + { + 'codePoint': 0x2C3C, + 'decoded': '\u2C3C', + 'encoded': '\xE2\xB0\xBC' + }, + { + 'codePoint': 0xFFFF, + 'decoded': '\uFFFF', + 'encoded': '\xEF\xBF\xBF' + }, + // unmatched surrogate halves + // high surrogates: 0xD800 to 0xDBFF + { + 'codePoint': 0xD800, + 'decoded': '\uD800', + 'encoded': '\xED\xA0\x80', + 'error': true + }, + { + 'description': 'High surrogate followed by another high surrogate', + 'decoded': '\uD800\uD800', + 'encoded': '\xED\xA0\x80\xED\xA0\x80', + 'error': true + }, + { + 'description': 'High surrogate followed by a symbol that is not a surrogate', + 'decoded': '\uD800A', + 'encoded': '\xED\xA0\x80A', + 'error': true + }, + { + 'description': 'Unmatched high surrogate, followed by a surrogate pair, followed by an unmatched high surrogate', + 'decoded': '\uD800\uD834\uDF06\uD800', + 'encoded': '\xED\xA0\x80\xF0\x9D\x8C\x86\xED\xA0\x80', + 'error': true + }, + { + 'codePoint': 0xD9AF, + 'decoded': '\uD9AF', + 'encoded': '\xED\xA6\xAF', + 'error': true + }, + { + 'codePoint': 0xDBFF, + 'decoded': '\uDBFF', + 'encoded': '\xED\xAF\xBF', + 'error': true + }, + // low surrogates: 0xDC00 to 0xDFFF + { + 'codePoint': 0xDC00, + 'decoded': '\uDC00', + 'encoded': '\xED\xB0\x80', + 'error': true + }, + { + 'description': 'Low surrogate followed by another low surrogate', + 'decoded': '\uDC00\uDC00', + 'encoded': '\xED\xB0\x80\xED\xB0\x80', + 'error': true + }, + { + 'description': 'Low surrogate followed by a symbol that is not a surrogate', + 'decoded': '\uDC00A', + 'encoded': '\xED\xB0\x80A', + 'error': true + }, + { + 'description': 'Unmatched low surrogate, followed by a surrogate pair, followed by an unmatched low surrogate', + 'decoded': '\uDC00\uD834\uDF06\uDC00', + 'encoded': '\xED\xB0\x80\xF0\x9D\x8C\x86\xED\xB0\x80', + 'error': true + }, + { + 'codePoint': 0xDEEE, + 'decoded': '\uDEEE', + 'encoded': '\xED\xBB\xAE', + 'error': true + }, + { + 'codePoint': 0xDFFF, + 'decoded': '\uDFFF', + 'encoded': '\xED\xBF\xBF', + 'error': true + }, + + // 4-byte + { + 'codePoint': 0x010000, + 'decoded': '\uD800\uDC00', + 'encoded': '\xF0\x90\x80\x80' + }, + { + 'codePoint': 0x01D306, + 'decoded': '\uD834\uDF06', + 'encoded': '\xF0\x9D\x8C\x86' + }, + { + 'codePoint': 0x10FFF, + 'decoded': '\uDBFF\uDFFF', + 'encoded': '\xF4\x8F\xBF\xBF' + } + ]; + + if (runExtendedTests) { + data = data.concat(require('./data.json')); + } + + // `throws` is a reserved word in ES3; alias it to avoid errors + var raises = QUnit.assert['throws']; + + // explicitly call `QUnit.module()` instead of `module()` + // in case we are in a CLI environment + QUnit.module('utf8.js'); + + test('encode/decode', function() { + forEach(data, function(object) { + var description = object.description || 'U+' + object.codePoint.toString(16).toUpperCase(); + ; + if (object.error) { + raises( + function() { + utf8.decode(object.encoded); + }, + Error, + 'Error: non-scalar value detected' + ); + raises( + function() { + utf8.encode(object.decoded); + }, + Error, + 'Error: non-scalar value detected' + ); + } else { + equal( + object.encoded, + utf8.encode(object.decoded), + 'Encoding: ' + description + ); + equal( + object.decoded, + utf8.decode(object.encoded), + 'Decoding: ' + description + ); + } + }); + + // Error handling + raises( + function() { + utf8.decode('\uFFFF'); + }, + Error, + 'Error: invalid UTF-8 detected' + ); + raises( + function() { + utf8.decode('\xE9\x00\x00'); + }, + Error, + 'Error: invalid continuation byte (4-byte sequence expected)' + ); + raises( + function() { + utf8.decode('\xC2\uFFFF'); + }, + Error, + 'Error: invalid continuation byte' + ); + raises( + function() { + utf8.decode('\xF0\x9D'); + }, + Error, + 'Error: invalid byte index' + ); + }); + + /*--------------------------------------------------------------------------*/ + + // configure QUnit and call `QUnit.start()` for + // Narwhal, Node.js, PhantomJS, Rhino, and RingoJS + if (!root.document || root.phantom) { + QUnit.config.noglobals = true; + QUnit.start(); + } +}(typeof global == 'object' && global || this)); diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/utf8.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/utf8.js index 8f2855da..c138a38e 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/utf8.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/utf8/utf8.js @@ -1,244 +1,244 @@ -/*! https://mths.be/utf8js v2.0.0 by @mathias */ -;(function(root) { - - // Detect free variables `exports` - var freeExports = typeof exports == 'object' && exports; - - // Detect free variable `module` - var freeModule = typeof module == 'object' && module && - module.exports == freeExports && module; - - // Detect free variable `global`, from Node.js or Browserified code, - // and use it as `root` - var freeGlobal = typeof global == 'object' && global; - if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) { - root = freeGlobal; - } - - /*--------------------------------------------------------------------------*/ - - var stringFromCharCode = String.fromCharCode; - - // Taken from https://mths.be/punycode - function ucs2decode(string) { - var output = []; - var counter = 0; - var length = string.length; - var value; - var extra; - while (counter < length) { - value = string.charCodeAt(counter++); - if (value >= 0xD800 && value <= 0xDBFF && counter < length) { - // high surrogate, and there is a next character - extra = string.charCodeAt(counter++); - if ((extra & 0xFC00) == 0xDC00) { // low surrogate - output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); - } else { - // unmatched surrogate; only append this code unit, in case the next - // code unit is the high surrogate of a surrogate pair - output.push(value); - counter--; - } - } else { - output.push(value); - } - } - return output; - } - - // Taken from https://mths.be/punycode - function ucs2encode(array) { - var length = array.length; - var index = -1; - var value; - var output = ''; - while (++index < length) { - value = array[index]; - if (value > 0xFFFF) { - value -= 0x10000; - output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800); - value = 0xDC00 | value & 0x3FF; - } - output += stringFromCharCode(value); - } - return output; - } - - function checkScalarValue(codePoint) { - if (codePoint >= 0xD800 && codePoint <= 0xDFFF) { - throw Error( - 'Lone surrogate U+' + codePoint.toString(16).toUpperCase() + - ' is not a scalar value' - ); - } - } - /*--------------------------------------------------------------------------*/ - - function createByte(codePoint, shift) { - return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80); - } - - function encodeCodePoint(codePoint) { - if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence - return stringFromCharCode(codePoint); - } - var symbol = ''; - if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence - symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0); - } - else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence - checkScalarValue(codePoint); - symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0); - symbol += createByte(codePoint, 6); - } - else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence - symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0); - symbol += createByte(codePoint, 12); - symbol += createByte(codePoint, 6); - } - symbol += stringFromCharCode((codePoint & 0x3F) | 0x80); - return symbol; - } - - function utf8encode(string) { - var codePoints = ucs2decode(string); - var length = codePoints.length; - var index = -1; - var codePoint; - var byteString = ''; - while (++index < length) { - codePoint = codePoints[index]; - byteString += encodeCodePoint(codePoint); - } - return byteString; - } - - /*--------------------------------------------------------------------------*/ - - function readContinuationByte() { - if (byteIndex >= byteCount) { - throw Error('Invalid byte index'); - } - - var continuationByte = byteArray[byteIndex] & 0xFF; - byteIndex++; - - if ((continuationByte & 0xC0) == 0x80) { - return continuationByte & 0x3F; - } - - // If we end up here, it’s not a continuation byte - throw Error('Invalid continuation byte'); - } - - function decodeSymbol() { - var byte1; - var byte2; - var byte3; - var byte4; - var codePoint; - - if (byteIndex > byteCount) { - throw Error('Invalid byte index'); - } - - if (byteIndex == byteCount) { - return false; - } - - // Read first byte - byte1 = byteArray[byteIndex] & 0xFF; - byteIndex++; - - // 1-byte sequence (no continuation bytes) - if ((byte1 & 0x80) == 0) { - return byte1; - } - - // 2-byte sequence - if ((byte1 & 0xE0) == 0xC0) { - var byte2 = readContinuationByte(); - codePoint = ((byte1 & 0x1F) << 6) | byte2; - if (codePoint >= 0x80) { - return codePoint; - } else { - throw Error('Invalid continuation byte'); - } - } - - // 3-byte sequence (may include unpaired surrogates) - if ((byte1 & 0xF0) == 0xE0) { - byte2 = readContinuationByte(); - byte3 = readContinuationByte(); - codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3; - if (codePoint >= 0x0800) { - checkScalarValue(codePoint); - return codePoint; - } else { - throw Error('Invalid continuation byte'); - } - } - - // 4-byte sequence - if ((byte1 & 0xF8) == 0xF0) { - byte2 = readContinuationByte(); - byte3 = readContinuationByte(); - byte4 = readContinuationByte(); - codePoint = ((byte1 & 0x0F) << 0x12) | (byte2 << 0x0C) | - (byte3 << 0x06) | byte4; - if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) { - return codePoint; - } - } - - throw Error('Invalid UTF-8 detected'); - } - - var byteArray; - var byteCount; - var byteIndex; - function utf8decode(byteString) { - byteArray = ucs2decode(byteString); - byteCount = byteArray.length; - byteIndex = 0; - var codePoints = []; - var tmp; - while ((tmp = decodeSymbol()) !== false) { - codePoints.push(tmp); - } - return ucs2encode(codePoints); - } - - /*--------------------------------------------------------------------------*/ - - var utf8 = { - 'version': '2.0.0', - 'encode': utf8encode, - 'decode': utf8decode - }; - - // Some AMD build optimizers, like r.js, check for specific condition patterns - // like the following: - if ( - typeof define == 'function' && - typeof define.amd == 'object' && - define.amd - ) { - define(function() { - return utf8; - }); - } else if (freeExports && !freeExports.nodeType) { - if (freeModule) { // in Node.js or RingoJS v0.8.0+ - freeModule.exports = utf8; - } else { // in Narwhal or RingoJS v0.7.0- - var object = {}; - var hasOwnProperty = object.hasOwnProperty; - for (var key in utf8) { - hasOwnProperty.call(utf8, key) && (freeExports[key] = utf8[key]); - } - } - } else { // in Rhino or a web browser - root.utf8 = utf8; - } - -}(this)); +/*! https://mths.be/utf8js v2.0.0 by @mathias */ +;(function(root) { + + // Detect free variables `exports` + var freeExports = typeof exports == 'object' && exports; + + // Detect free variable `module` + var freeModule = typeof module == 'object' && module && + module.exports == freeExports && module; + + // Detect free variable `global`, from Node.js or Browserified code, + // and use it as `root` + var freeGlobal = typeof global == 'object' && global; + if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) { + root = freeGlobal; + } + + /*--------------------------------------------------------------------------*/ + + var stringFromCharCode = String.fromCharCode; + + // Taken from https://mths.be/punycode + function ucs2decode(string) { + var output = []; + var counter = 0; + var length = string.length; + var value; + var extra; + while (counter < length) { + value = string.charCodeAt(counter++); + if (value >= 0xD800 && value <= 0xDBFF && counter < length) { + // high surrogate, and there is a next character + extra = string.charCodeAt(counter++); + if ((extra & 0xFC00) == 0xDC00) { // low surrogate + output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); + } else { + // unmatched surrogate; only append this code unit, in case the next + // code unit is the high surrogate of a surrogate pair + output.push(value); + counter--; + } + } else { + output.push(value); + } + } + return output; + } + + // Taken from https://mths.be/punycode + function ucs2encode(array) { + var length = array.length; + var index = -1; + var value; + var output = ''; + while (++index < length) { + value = array[index]; + if (value > 0xFFFF) { + value -= 0x10000; + output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800); + value = 0xDC00 | value & 0x3FF; + } + output += stringFromCharCode(value); + } + return output; + } + + function checkScalarValue(codePoint) { + if (codePoint >= 0xD800 && codePoint <= 0xDFFF) { + throw Error( + 'Lone surrogate U+' + codePoint.toString(16).toUpperCase() + + ' is not a scalar value' + ); + } + } + /*--------------------------------------------------------------------------*/ + + function createByte(codePoint, shift) { + return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80); + } + + function encodeCodePoint(codePoint) { + if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence + return stringFromCharCode(codePoint); + } + var symbol = ''; + if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence + symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0); + } + else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence + checkScalarValue(codePoint); + symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0); + symbol += createByte(codePoint, 6); + } + else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence + symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0); + symbol += createByte(codePoint, 12); + symbol += createByte(codePoint, 6); + } + symbol += stringFromCharCode((codePoint & 0x3F) | 0x80); + return symbol; + } + + function utf8encode(string) { + var codePoints = ucs2decode(string); + var length = codePoints.length; + var index = -1; + var codePoint; + var byteString = ''; + while (++index < length) { + codePoint = codePoints[index]; + byteString += encodeCodePoint(codePoint); + } + return byteString; + } + + /*--------------------------------------------------------------------------*/ + + function readContinuationByte() { + if (byteIndex >= byteCount) { + throw Error('Invalid byte index'); + } + + var continuationByte = byteArray[byteIndex] & 0xFF; + byteIndex++; + + if ((continuationByte & 0xC0) == 0x80) { + return continuationByte & 0x3F; + } + + // If we end up here, it’s not a continuation byte + throw Error('Invalid continuation byte'); + } + + function decodeSymbol() { + var byte1; + var byte2; + var byte3; + var byte4; + var codePoint; + + if (byteIndex > byteCount) { + throw Error('Invalid byte index'); + } + + if (byteIndex == byteCount) { + return false; + } + + // Read first byte + byte1 = byteArray[byteIndex] & 0xFF; + byteIndex++; + + // 1-byte sequence (no continuation bytes) + if ((byte1 & 0x80) == 0) { + return byte1; + } + + // 2-byte sequence + if ((byte1 & 0xE0) == 0xC0) { + var byte2 = readContinuationByte(); + codePoint = ((byte1 & 0x1F) << 6) | byte2; + if (codePoint >= 0x80) { + return codePoint; + } else { + throw Error('Invalid continuation byte'); + } + } + + // 3-byte sequence (may include unpaired surrogates) + if ((byte1 & 0xF0) == 0xE0) { + byte2 = readContinuationByte(); + byte3 = readContinuationByte(); + codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3; + if (codePoint >= 0x0800) { + checkScalarValue(codePoint); + return codePoint; + } else { + throw Error('Invalid continuation byte'); + } + } + + // 4-byte sequence + if ((byte1 & 0xF8) == 0xF0) { + byte2 = readContinuationByte(); + byte3 = readContinuationByte(); + byte4 = readContinuationByte(); + codePoint = ((byte1 & 0x0F) << 0x12) | (byte2 << 0x0C) | + (byte3 << 0x06) | byte4; + if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) { + return codePoint; + } + } + + throw Error('Invalid UTF-8 detected'); + } + + var byteArray; + var byteCount; + var byteIndex; + function utf8decode(byteString) { + byteArray = ucs2decode(byteString); + byteCount = byteArray.length; + byteIndex = 0; + var codePoints = []; + var tmp; + while ((tmp = decodeSymbol()) !== false) { + codePoints.push(tmp); + } + return ucs2encode(codePoints); + } + + /*--------------------------------------------------------------------------*/ + + var utf8 = { + 'version': '2.0.0', + 'encode': utf8encode, + 'decode': utf8decode + }; + + // Some AMD build optimizers, like r.js, check for specific condition patterns + // like the following: + if ( + typeof define == 'function' && + typeof define.amd == 'object' && + define.amd + ) { + define(function() { + return utf8; + }); + } else if (freeExports && !freeExports.nodeType) { + if (freeModule) { // in Node.js or RingoJS v0.8.0+ + freeModule.exports = utf8; + } else { // in Narwhal or RingoJS v0.7.0- + var object = {}; + var hasOwnProperty = object.hasOwnProperty; + for (var key in utf8) { + hasOwnProperty.call(utf8, key) && (freeExports[key] = utf8[key]); + } + } + } else { // in Rhino or a web browser + root.utf8 = utf8; + } + +}(this)); diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/package.json b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/package.json index 38f25748..4014c1b3 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/package.json +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/package.json @@ -1,54 +1,54 @@ -{ - "name": "engine.io-parser", - "description": "Parser for the client for the realtime Engine", - "version": "1.2.4", - "homepage": "https://github.com/Automattic/engine.io-parser", - "devDependencies": { - "expect.js": "0.3.1", - "mocha": "2.2.5", - "zuul": "3.7.3", - "zuul-ngrok": "3.2.0" - }, - "dependencies": { - "after": "0.8.1", - "arraybuffer.slice": "0.0.6", - "base64-arraybuffer": "0.1.2", - "blob": "0.0.4", - "has-binary": "0.1.6", - "utf8": "2.1.0" - }, - "scripts": { - "test": "make test" - }, - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/Automattic/engine.io-parser.git" - }, - "browser": "./lib/browser.js", - "gitHead": "ca248c5238a42d8383a4ab7de347adc2578abeac", - "bugs": { - "url": "https://github.com/Automattic/engine.io-parser/issues" - }, - "_id": "engine.io-parser@1.2.4", - "_shasum": "e0897b0bf14e792d4cd2a5950553919c56948c42", - "_from": "engine.io-parser@1.2.4", - "_npmVersion": "3.4.1", - "_nodeVersion": "4.2.2", - "_npmUser": { - "name": "rauchg", - "email": "rauchg@gmail.com" - }, - "maintainers": [ - { - "name": "rauchg", - "email": "rauchg@gmail.com" - } - ], - "dist": { - "shasum": "e0897b0bf14e792d4cd2a5950553919c56948c42", - "tarball": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-1.2.4.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-1.2.4.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "engine.io-parser", + "description": "Parser for the client for the realtime Engine", + "version": "1.2.4", + "homepage": "https://github.com/Automattic/engine.io-parser", + "devDependencies": { + "expect.js": "0.3.1", + "mocha": "2.2.5", + "zuul": "3.7.3", + "zuul-ngrok": "3.2.0" + }, + "dependencies": { + "after": "0.8.1", + "arraybuffer.slice": "0.0.6", + "base64-arraybuffer": "0.1.2", + "blob": "0.0.4", + "has-binary": "0.1.6", + "utf8": "2.1.0" + }, + "scripts": { + "test": "make test" + }, + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/Automattic/engine.io-parser.git" + }, + "browser": "./lib/browser.js", + "gitHead": "ca248c5238a42d8383a4ab7de347adc2578abeac", + "bugs": { + "url": "https://github.com/Automattic/engine.io-parser/issues" + }, + "_id": "engine.io-parser@1.2.4", + "_shasum": "e0897b0bf14e792d4cd2a5950553919c56948c42", + "_from": "engine.io-parser@1.2.4", + "_npmVersion": "3.4.1", + "_nodeVersion": "4.2.2", + "_npmUser": { + "name": "rauchg", + "email": "rauchg@gmail.com" + }, + "maintainers": [ + { + "name": "rauchg", + "email": "rauchg@gmail.com" + } + ], + "dist": { + "shasum": "e0897b0bf14e792d4cd2a5950553919c56948c42", + "tarball": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-1.2.4.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-1.2.4.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/.npmignore b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/.npmignore index e52e399a..1eba800f 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/.npmignore +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/.npmignore @@ -1,11 +1,11 @@ -npm-debug.log -node_modules -.*.swp -.lock-* -build - -bench -doc -examples -test - +npm-debug.log +node_modules +.*.swp +.lock-* +build + +bench +doc +examples +test + diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/.travis.yml b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/.travis.yml index 99309a82..5002b498 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/.travis.yml +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/.travis.yml @@ -1,15 +1,15 @@ -language: node_js -sudo: false -node_js: - - "5" - - "4" - - "0.12" -addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - gcc-4.9 - - g++-4.9 -before_install: - - export CC="gcc-4.9" CXX="g++-4.9" +language: node_js +sudo: false +node_js: + - "5" + - "4" + - "0.12" +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - gcc-4.9 + - g++-4.9 +before_install: + - export CC="gcc-4.9" CXX="g++-4.9" diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/Makefile b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/Makefile index 563d1eb6..94612c5c 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/Makefile +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/Makefile @@ -1,45 +1,45 @@ -ALL_TESTS = $(shell find test/ -name '*.test.js') -ALL_INTEGRATION = $(shell find test/ -name '*.integration.js') - -run-tests: - @./node_modules/.bin/mocha \ - -t 5000 \ - -s 2400 \ - $(TESTFLAGS) \ - $(TESTS) - -run-integrationtests: - @./node_modules/.bin/mocha \ - -t 5000 \ - -s 6000 \ - $(TESTFLAGS) \ - $(TESTS) - -run-coverage: - @./node_modules/.bin/istanbul cover --report html \ - ./node_modules/.bin/_mocha -- \ - -t 5000 \ - -s 6000 \ - $(TESTFLAGS) \ - $(TESTS) - -test: - @$(MAKE) NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_PATH=lib TESTS="$(ALL_TESTS)" run-tests - -integrationtest: - @$(MAKE) NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_PATH=lib TESTS="$(ALL_INTEGRATION)" run-integrationtests - -coverage: - @$(MAKE) NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_PATH=lib TESTS="$(ALL_TESTS)" run-coverage - -benchmark: - @node bench/sender.benchmark.js - @node bench/parser.benchmark.js - -autobahn: - @NODE_PATH=lib node test/autobahn.js - -autobahn-server: - @NODE_PATH=lib node test/autobahn-server.js - -.PHONY: test coverage +ALL_TESTS = $(shell find test/ -name '*.test.js') +ALL_INTEGRATION = $(shell find test/ -name '*.integration.js') + +run-tests: + @./node_modules/.bin/mocha \ + -t 5000 \ + -s 2400 \ + $(TESTFLAGS) \ + $(TESTS) + +run-integrationtests: + @./node_modules/.bin/mocha \ + -t 5000 \ + -s 6000 \ + $(TESTFLAGS) \ + $(TESTS) + +run-coverage: + @./node_modules/.bin/istanbul cover --report html \ + ./node_modules/.bin/_mocha -- \ + -t 5000 \ + -s 6000 \ + $(TESTFLAGS) \ + $(TESTS) + +test: + @$(MAKE) NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_PATH=lib TESTS="$(ALL_TESTS)" run-tests + +integrationtest: + @$(MAKE) NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_PATH=lib TESTS="$(ALL_INTEGRATION)" run-integrationtests + +coverage: + @$(MAKE) NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_PATH=lib TESTS="$(ALL_TESTS)" run-coverage + +benchmark: + @node bench/sender.benchmark.js + @node bench/parser.benchmark.js + +autobahn: + @NODE_PATH=lib node test/autobahn.js + +autobahn-server: + @NODE_PATH=lib node test/autobahn-server.js + +.PHONY: test coverage diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/README.md b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/README.md index b2f6fcf1..93106d7a 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/README.md +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/README.md @@ -1,235 +1,235 @@ -# ws: a node.js websocket library - -[![Build Status](https://travis-ci.org/websockets/ws.svg?branch=master)](https://travis-ci.org/websockets/ws) - -`ws` is a simple to use WebSocket implementation, up-to-date against RFC-6455, -and [probably the fastest WebSocket library for node.js][archive]. - -Passes the quite extensive Autobahn test suite. See http://websockets.github.com/ws -for the full reports. - -## Protocol support - -* **Hixie draft 76** (Old and deprecated, but still in use by Safari and Opera. - Added to ws version 0.4.2, but server only. Can be disabled by setting the - `disableHixie` option to true.) -* **HyBi drafts 07-12** (Use the option `protocolVersion: 8`) -* **HyBi drafts 13-17** (Current default, alternatively option `protocolVersion: 13`) - -### Installing - -``` -npm install --save ws -``` - -### Opt-in for performance - -There are 2 optional modules that can be installed along side with the `ws` -module. These modules are binary addons which improve certain operations, but as -they are binary addons they require compilation which can fail if no c++ -compiler is installed on the host system. - -- `npm install --save bufferutil`: Improves internal buffer operations which - allows for faster processing of masked WebSocket frames and general buffer - operations. -- `npm install --save utf-8-validate`: The specification requires validation of - invalid UTF-8 chars, some of these validations could not be done in JavaScript - hence the need for a binary addon. In most cases you will already be - validating the input that you receive for security purposes leading to double - validation. But if you want to be 100% spec-conforming and have fast - validation of UTF-8 then this module is a must. - -### Sending and receiving text data - -```js -var WebSocket = require('ws'); -var ws = new WebSocket('ws://www.host.com/path'); - -ws.on('open', function open() { - ws.send('something'); -}); - -ws.on('message', function(data, flags) { - // flags.binary will be set if a binary data is received. - // flags.masked will be set if the data was masked. -}); -``` - -### Sending binary data - -```js -var WebSocket = require('ws'); -var ws = new WebSocket('ws://www.host.com/path'); - -ws.on('open', function open() { - var array = new Float32Array(5); - - for (var i = 0; i < array.length; ++i) { - array[i] = i / 2; - } - - ws.send(array, { binary: true, mask: true }); -}); -``` - -Setting `mask`, as done for the send options above, will cause the data to be -masked according to the WebSocket protocol. The same option applies for text -data. - -### Server example - -```js -var WebSocketServer = require('ws').Server - , wss = new WebSocketServer({ port: 8080 }); - -wss.on('connection', function connection(ws) { - ws.on('message', function incoming(message) { - console.log('received: %s', message); - }); - - ws.send('something'); -}); -``` - -### ExpressJS example - -```js -var server = require('http').createServer() - , url = require('url') - , WebSocketServer = require('ws').Server - , wss = new WebSocketServer({ server: server }) - , express = require('express') - , app = express() - , port = 4080; - -app.use(function (req, res) { - res.send({ msg: "hello" }); -}); - -wss.on('connection', function connection(ws) { - var location = url.parse(ws.upgradeReq.url, true); - // you might use location.query.access_token to authenticate or share sessions - // or ws.upgradeReq.headers.cookie (see http://stackoverflow.com/a/16395220/151312) - - ws.on('message', function incoming(message) { - console.log('received: %s', message); - }); - - ws.send('something'); -}); - -server.on('request', app); -server.listen(port, function () { console.log('Listening on ' + server.address().port) }); -``` - -### Server sending broadcast data - -```js -var WebSocketServer = require('ws').Server - , wss = new WebSocketServer({ port: 8080 }); - -wss.broadcast = function broadcast(data) { - wss.clients.forEach(function each(client) { - client.send(data); - }); -}; -``` - -### Error handling best practices - -```js -// If the WebSocket is closed before the following send is attempted -ws.send('something'); - -// Errors (both immediate and async write errors) can be detected in an optional -// callback. The callback is also the only way of being notified that data has -// actually been sent. -ws.send('something', function ack(error) { - // if error is not defined, the send has been completed, - // otherwise the error object will indicate what failed. -}); - -// Immediate errors can also be handled with try/catch-blocks, but **note** that -// since sends are inherently asynchronous, socket write failures will *not* be -// captured when this technique is used. -try { ws.send('something'); } -catch (e) { /* handle error */ } -``` - -### echo.websocket.org demo - -```js -var WebSocket = require('ws'); -var ws = new WebSocket('ws://echo.websocket.org/', { - protocolVersion: 8, - origin: 'http://websocket.org' -}); - -ws.on('open', function open() { - console.log('connected'); - ws.send(Date.now().toString(), {mask: true}); -}); - -ws.on('close', function close() { - console.log('disconnected'); -}); - -ws.on('message', function message(data, flags) { - console.log('Roundtrip time: ' + (Date.now() - parseInt(data)) + 'ms', flags); - - setTimeout(function timeout() { - ws.send(Date.now().toString(), {mask: true}); - }, 500); -}); -``` - -### Other examples - -For a full example with a browser client communicating with a ws server, see the -examples folder. - -Note that the usage together with Express 3.0 is quite different from Express -2.x. The difference is expressed in the two different serverstats-examples. - -Otherwise, see the test cases. - -### Running the tests - -``` -make test -``` - -## API Docs - -See [`/doc/ws.md`](https://github.com/websockets/ws/blob/master/doc/ws.md) for Node.js-like docs for the ws classes. - -## Changelog - -We're using the GitHub [`releases`](https://github.com/websockets/ws/releases) for changelog entries. - -## License - -(The MIT License) - -Copyright (c) 2011 Einar Otto Stangvik <einaros@gmail.com> - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -[archive]: http://web.archive.org/web/20130314230536/http://hobbycoding.posterous.com/the-fastest-websocket-module-for-nodejs +# ws: a node.js websocket library + +[![Build Status](https://travis-ci.org/websockets/ws.svg?branch=master)](https://travis-ci.org/websockets/ws) + +`ws` is a simple to use WebSocket implementation, up-to-date against RFC-6455, +and [probably the fastest WebSocket library for node.js][archive]. + +Passes the quite extensive Autobahn test suite. See http://websockets.github.com/ws +for the full reports. + +## Protocol support + +* **Hixie draft 76** (Old and deprecated, but still in use by Safari and Opera. + Added to ws version 0.4.2, but server only. Can be disabled by setting the + `disableHixie` option to true.) +* **HyBi drafts 07-12** (Use the option `protocolVersion: 8`) +* **HyBi drafts 13-17** (Current default, alternatively option `protocolVersion: 13`) + +### Installing + +``` +npm install --save ws +``` + +### Opt-in for performance + +There are 2 optional modules that can be installed along side with the `ws` +module. These modules are binary addons which improve certain operations, but as +they are binary addons they require compilation which can fail if no c++ +compiler is installed on the host system. + +- `npm install --save bufferutil`: Improves internal buffer operations which + allows for faster processing of masked WebSocket frames and general buffer + operations. +- `npm install --save utf-8-validate`: The specification requires validation of + invalid UTF-8 chars, some of these validations could not be done in JavaScript + hence the need for a binary addon. In most cases you will already be + validating the input that you receive for security purposes leading to double + validation. But if you want to be 100% spec-conforming and have fast + validation of UTF-8 then this module is a must. + +### Sending and receiving text data + +```js +var WebSocket = require('ws'); +var ws = new WebSocket('ws://www.host.com/path'); + +ws.on('open', function open() { + ws.send('something'); +}); + +ws.on('message', function(data, flags) { + // flags.binary will be set if a binary data is received. + // flags.masked will be set if the data was masked. +}); +``` + +### Sending binary data + +```js +var WebSocket = require('ws'); +var ws = new WebSocket('ws://www.host.com/path'); + +ws.on('open', function open() { + var array = new Float32Array(5); + + for (var i = 0; i < array.length; ++i) { + array[i] = i / 2; + } + + ws.send(array, { binary: true, mask: true }); +}); +``` + +Setting `mask`, as done for the send options above, will cause the data to be +masked according to the WebSocket protocol. The same option applies for text +data. + +### Server example + +```js +var WebSocketServer = require('ws').Server + , wss = new WebSocketServer({ port: 8080 }); + +wss.on('connection', function connection(ws) { + ws.on('message', function incoming(message) { + console.log('received: %s', message); + }); + + ws.send('something'); +}); +``` + +### ExpressJS example + +```js +var server = require('http').createServer() + , url = require('url') + , WebSocketServer = require('ws').Server + , wss = new WebSocketServer({ server: server }) + , express = require('express') + , app = express() + , port = 4080; + +app.use(function (req, res) { + res.send({ msg: "hello" }); +}); + +wss.on('connection', function connection(ws) { + var location = url.parse(ws.upgradeReq.url, true); + // you might use location.query.access_token to authenticate or share sessions + // or ws.upgradeReq.headers.cookie (see http://stackoverflow.com/a/16395220/151312) + + ws.on('message', function incoming(message) { + console.log('received: %s', message); + }); + + ws.send('something'); +}); + +server.on('request', app); +server.listen(port, function () { console.log('Listening on ' + server.address().port) }); +``` + +### Server sending broadcast data + +```js +var WebSocketServer = require('ws').Server + , wss = new WebSocketServer({ port: 8080 }); + +wss.broadcast = function broadcast(data) { + wss.clients.forEach(function each(client) { + client.send(data); + }); +}; +``` + +### Error handling best practices + +```js +// If the WebSocket is closed before the following send is attempted +ws.send('something'); + +// Errors (both immediate and async write errors) can be detected in an optional +// callback. The callback is also the only way of being notified that data has +// actually been sent. +ws.send('something', function ack(error) { + // if error is not defined, the send has been completed, + // otherwise the error object will indicate what failed. +}); + +// Immediate errors can also be handled with try/catch-blocks, but **note** that +// since sends are inherently asynchronous, socket write failures will *not* be +// captured when this technique is used. +try { ws.send('something'); } +catch (e) { /* handle error */ } +``` + +### echo.websocket.org demo + +```js +var WebSocket = require('ws'); +var ws = new WebSocket('ws://echo.websocket.org/', { + protocolVersion: 8, + origin: 'http://websocket.org' +}); + +ws.on('open', function open() { + console.log('connected'); + ws.send(Date.now().toString(), {mask: true}); +}); + +ws.on('close', function close() { + console.log('disconnected'); +}); + +ws.on('message', function message(data, flags) { + console.log('Roundtrip time: ' + (Date.now() - parseInt(data)) + 'ms', flags); + + setTimeout(function timeout() { + ws.send(Date.now().toString(), {mask: true}); + }, 500); +}); +``` + +### Other examples + +For a full example with a browser client communicating with a ws server, see the +examples folder. + +Note that the usage together with Express 3.0 is quite different from Express +2.x. The difference is expressed in the two different serverstats-examples. + +Otherwise, see the test cases. + +### Running the tests + +``` +make test +``` + +## API Docs + +See [`/doc/ws.md`](https://github.com/websockets/ws/blob/master/doc/ws.md) for Node.js-like docs for the ws classes. + +## Changelog + +We're using the GitHub [`releases`](https://github.com/websockets/ws/releases) for changelog entries. + +## License + +(The MIT License) + +Copyright (c) 2011 Einar Otto Stangvik <einaros@gmail.com> + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +[archive]: http://web.archive.org/web/20130314230536/http://hobbycoding.posterous.com/the-fastest-websocket-module-for-nodejs diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/SECURITY.md b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/SECURITY.md index 067c80a1..fd8e07bc 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/SECURITY.md +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/SECURITY.md @@ -1,33 +1,33 @@ -# Security Guidelines - -Please contact us directly at **security@3rd-Eden.com** for any bug that might -impact the security of this project. Please prefix the subject of your email -with `[security]` in lowercase and square brackets. Our email filters will -automatically prevent these messages from being moved to our spam box. - -You will receive an acknowledgement of your report within **24 hours**. - -All emails that do not include security vulnerabilities will be removed and -blocked instantly. - -## Exceptions - -If you do not receive an acknowledgement within the said time frame please give -us the benefit of the doubt as it's possible that we haven't seen it yet. In -this case please send us a message **without details** using one of the -following methods: - -- Contact the lead developers of this project on their personal e-mails. You - can find the e-mails in the git logs, for example using the following command: - `git --no-pager show -s --format='%an <%ae>' ` where `` is the - SHA1 of their latest commit in the project. -- Create a GitHub issue stating contact details and the severity of the issue. - -Once we have acknowledged receipt of your report and confirmed the bug -ourselves we will work with you to fix the vulnerability and publicly acknowledge -your responsible disclosure, if you wish. In addition to that we will report -all vulnerabilities to the [Node Security Project](https://nodesecurity.io/). - -## History - -04 Jan 2016: [Buffer vulnerablity](https://github.com/websockets/ws/releases/tag/1.0.1) +# Security Guidelines + +Please contact us directly at **security@3rd-Eden.com** for any bug that might +impact the security of this project. Please prefix the subject of your email +with `[security]` in lowercase and square brackets. Our email filters will +automatically prevent these messages from being moved to our spam box. + +You will receive an acknowledgement of your report within **24 hours**. + +All emails that do not include security vulnerabilities will be removed and +blocked instantly. + +## Exceptions + +If you do not receive an acknowledgement within the said time frame please give +us the benefit of the doubt as it's possible that we haven't seen it yet. In +this case please send us a message **without details** using one of the +following methods: + +- Contact the lead developers of this project on their personal e-mails. You + can find the e-mails in the git logs, for example using the following command: + `git --no-pager show -s --format='%an <%ae>' ` where `` is the + SHA1 of their latest commit in the project. +- Create a GitHub issue stating contact details and the severity of the issue. + +Once we have acknowledged receipt of your report and confirmed the bug +ourselves we will work with you to fix the vulnerability and publicly acknowledge +your responsible disclosure, if you wish. In addition to that we will report +all vulnerabilities to the [Node Security Project](https://nodesecurity.io/). + +## History + +04 Jan 2016: [Buffer vulnerablity](https://github.com/websockets/ws/releases/tag/1.0.1) diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/index.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/index.js index 77b67d8c..a7e8644b 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/index.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/index.js @@ -1,49 +1,49 @@ -'use strict'; - -/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - -var WS = module.exports = require('./lib/WebSocket'); - -WS.Server = require('./lib/WebSocketServer'); -WS.Sender = require('./lib/Sender'); -WS.Receiver = require('./lib/Receiver'); - -/** - * Create a new WebSocket server. - * - * @param {Object} options Server options - * @param {Function} fn Optional connection listener. - * @returns {WS.Server} - * @api public - */ -WS.createServer = function createServer(options, fn) { - var server = new WS.Server(options); - - if (typeof fn === 'function') { - server.on('connection', fn); - } - - return server; -}; - -/** - * Create a new WebSocket connection. - * - * @param {String} address The URL/address we need to connect to. - * @param {Function} fn Open listener. - * @returns {WS} - * @api public - */ -WS.connect = WS.createConnection = function connect(address, fn) { - var client = new WS(address); - - if (typeof fn === 'function') { - client.on('open', fn); - } - - return client; -}; +'use strict'; + +/*! + * ws: a node.js websocket client + * Copyright(c) 2011 Einar Otto Stangvik + * MIT Licensed + */ + +var WS = module.exports = require('./lib/WebSocket'); + +WS.Server = require('./lib/WebSocketServer'); +WS.Sender = require('./lib/Sender'); +WS.Receiver = require('./lib/Receiver'); + +/** + * Create a new WebSocket server. + * + * @param {Object} options Server options + * @param {Function} fn Optional connection listener. + * @returns {WS.Server} + * @api public + */ +WS.createServer = function createServer(options, fn) { + var server = new WS.Server(options); + + if (typeof fn === 'function') { + server.on('connection', fn); + } + + return server; +}; + +/** + * Create a new WebSocket connection. + * + * @param {String} address The URL/address we need to connect to. + * @param {Function} fn Open listener. + * @returns {WS} + * @api public + */ +WS.connect = WS.createConnection = function connect(address, fn) { + var client = new WS(address); + + if (typeof fn === 'function') { + client.on('open', fn); + } + + return client; +}; diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/BufferPool.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/BufferPool.js index d968036c..8ee59905 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/BufferPool.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/BufferPool.js @@ -1,63 +1,63 @@ -/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - -var util = require('util'); - -function BufferPool(initialSize, growStrategy, shrinkStrategy) { - if (this instanceof BufferPool === false) { - throw new TypeError("Classes can't be function-called"); - } - - if (typeof initialSize === 'function') { - shrinkStrategy = growStrategy; - growStrategy = initialSize; - initialSize = 0; - } - else if (typeof initialSize === 'undefined') { - initialSize = 0; - } - this._growStrategy = (growStrategy || function(db, size) { - return db.used + size; - }).bind(null, this); - this._shrinkStrategy = (shrinkStrategy || function(db) { - return initialSize; - }).bind(null, this); - this._buffer = initialSize ? new Buffer(initialSize) : null; - this._offset = 0; - this._used = 0; - this._changeFactor = 0; - this.__defineGetter__('size', function(){ - return this._buffer == null ? 0 : this._buffer.length; - }); - this.__defineGetter__('used', function(){ - return this._used; - }); -} - -BufferPool.prototype.get = function(length) { - if (this._buffer == null || this._offset + length > this._buffer.length) { - var newBuf = new Buffer(this._growStrategy(length)); - this._buffer = newBuf; - this._offset = 0; - } - this._used += length; - var buf = this._buffer.slice(this._offset, this._offset + length); - this._offset += length; - return buf; -} - -BufferPool.prototype.reset = function(forceNewBuffer) { - var len = this._shrinkStrategy(); - if (len < this.size) this._changeFactor -= 1; - if (forceNewBuffer || this._changeFactor < -2) { - this._changeFactor = 0; - this._buffer = len ? new Buffer(len) : null; - } - this._offset = 0; - this._used = 0; -} - -module.exports = BufferPool; +/*! + * ws: a node.js websocket client + * Copyright(c) 2011 Einar Otto Stangvik + * MIT Licensed + */ + +var util = require('util'); + +function BufferPool(initialSize, growStrategy, shrinkStrategy) { + if (this instanceof BufferPool === false) { + throw new TypeError("Classes can't be function-called"); + } + + if (typeof initialSize === 'function') { + shrinkStrategy = growStrategy; + growStrategy = initialSize; + initialSize = 0; + } + else if (typeof initialSize === 'undefined') { + initialSize = 0; + } + this._growStrategy = (growStrategy || function(db, size) { + return db.used + size; + }).bind(null, this); + this._shrinkStrategy = (shrinkStrategy || function(db) { + return initialSize; + }).bind(null, this); + this._buffer = initialSize ? new Buffer(initialSize) : null; + this._offset = 0; + this._used = 0; + this._changeFactor = 0; + this.__defineGetter__('size', function(){ + return this._buffer == null ? 0 : this._buffer.length; + }); + this.__defineGetter__('used', function(){ + return this._used; + }); +} + +BufferPool.prototype.get = function(length) { + if (this._buffer == null || this._offset + length > this._buffer.length) { + var newBuf = new Buffer(this._growStrategy(length)); + this._buffer = newBuf; + this._offset = 0; + } + this._used += length; + var buf = this._buffer.slice(this._offset, this._offset + length); + this._offset += length; + return buf; +} + +BufferPool.prototype.reset = function(forceNewBuffer) { + var len = this._shrinkStrategy(); + if (len < this.size) this._changeFactor -= 1; + if (forceNewBuffer || this._changeFactor < -2) { + this._changeFactor = 0; + this._buffer = len ? new Buffer(len) : null; + } + this._offset = 0; + this._used = 0; +} + +module.exports = BufferPool; diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/BufferUtil.fallback.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/BufferUtil.fallback.js index 7b6caefa..7abd0d8a 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/BufferUtil.fallback.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/BufferUtil.fallback.js @@ -1,47 +1,47 @@ -/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - -exports.BufferUtil = { - merge: function(mergedBuffer, buffers) { - var offset = 0; - for (var i = 0, l = buffers.length; i < l; ++i) { - var buf = buffers[i]; - buf.copy(mergedBuffer, offset); - offset += buf.length; - } - }, - mask: function(source, mask, output, offset, length) { - var maskNum = mask.readUInt32LE(0, true); - var i = 0; - for (; i < length - 3; i += 4) { - var num = maskNum ^ source.readUInt32LE(i, true); - if (num < 0) num = 4294967296 + num; - output.writeUInt32LE(num, offset + i, true); - } - switch (length % 4) { - case 3: output[offset + i + 2] = source[i + 2] ^ mask[2]; - case 2: output[offset + i + 1] = source[i + 1] ^ mask[1]; - case 1: output[offset + i] = source[i] ^ mask[0]; - case 0:; - } - }, - unmask: function(data, mask) { - var maskNum = mask.readUInt32LE(0, true); - var length = data.length; - var i = 0; - for (; i < length - 3; i += 4) { - var num = maskNum ^ data.readUInt32LE(i, true); - if (num < 0) num = 4294967296 + num; - data.writeUInt32LE(num, i, true); - } - switch (length % 4) { - case 3: data[i + 2] = data[i + 2] ^ mask[2]; - case 2: data[i + 1] = data[i + 1] ^ mask[1]; - case 1: data[i] = data[i] ^ mask[0]; - case 0:; - } - } -} +/*! + * ws: a node.js websocket client + * Copyright(c) 2011 Einar Otto Stangvik + * MIT Licensed + */ + +exports.BufferUtil = { + merge: function(mergedBuffer, buffers) { + var offset = 0; + for (var i = 0, l = buffers.length; i < l; ++i) { + var buf = buffers[i]; + buf.copy(mergedBuffer, offset); + offset += buf.length; + } + }, + mask: function(source, mask, output, offset, length) { + var maskNum = mask.readUInt32LE(0, true); + var i = 0; + for (; i < length - 3; i += 4) { + var num = maskNum ^ source.readUInt32LE(i, true); + if (num < 0) num = 4294967296 + num; + output.writeUInt32LE(num, offset + i, true); + } + switch (length % 4) { + case 3: output[offset + i + 2] = source[i + 2] ^ mask[2]; + case 2: output[offset + i + 1] = source[i + 1] ^ mask[1]; + case 1: output[offset + i] = source[i] ^ mask[0]; + case 0:; + } + }, + unmask: function(data, mask) { + var maskNum = mask.readUInt32LE(0, true); + var length = data.length; + var i = 0; + for (; i < length - 3; i += 4) { + var num = maskNum ^ data.readUInt32LE(i, true); + if (num < 0) num = 4294967296 + num; + data.writeUInt32LE(num, i, true); + } + switch (length % 4) { + case 3: data[i + 2] = data[i + 2] ^ mask[2]; + case 2: data[i + 1] = data[i + 1] ^ mask[1]; + case 1: data[i] = data[i] ^ mask[0]; + case 0:; + } + } +} diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/BufferUtil.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/BufferUtil.js index 17e6a4ad..18c69989 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/BufferUtil.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/BufferUtil.js @@ -1,13 +1,13 @@ -'use strict'; - -/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - -try { - module.exports = require('bufferutil'); -} catch (e) { - module.exports = require('./BufferUtil.fallback'); -} +'use strict'; + +/*! + * ws: a node.js websocket client + * Copyright(c) 2011 Einar Otto Stangvik + * MIT Licensed + */ + +try { + module.exports = require('bufferutil'); +} catch (e) { + module.exports = require('./BufferUtil.fallback'); +} diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/ErrorCodes.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/ErrorCodes.js index b07f7fb5..55ebd529 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/ErrorCodes.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/ErrorCodes.js @@ -1,24 +1,24 @@ -/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - -module.exports = { - isValidErrorCode: function(code) { - return (code >= 1000 && code <= 1011 && code != 1004 && code != 1005 && code != 1006) || - (code >= 3000 && code <= 4999); - }, - 1000: 'normal', - 1001: 'going away', - 1002: 'protocol error', - 1003: 'unsupported data', - 1004: 'reserved', - 1005: 'reserved for extensions', - 1006: 'reserved for extensions', - 1007: 'inconsistent or invalid data', - 1008: 'policy violation', - 1009: 'message too big', - 1010: 'extension handshake missing', - 1011: 'an unexpected condition prevented the request from being fulfilled', +/*! + * ws: a node.js websocket client + * Copyright(c) 2011 Einar Otto Stangvik + * MIT Licensed + */ + +module.exports = { + isValidErrorCode: function(code) { + return (code >= 1000 && code <= 1011 && code != 1004 && code != 1005 && code != 1006) || + (code >= 3000 && code <= 4999); + }, + 1000: 'normal', + 1001: 'going away', + 1002: 'protocol error', + 1003: 'unsupported data', + 1004: 'reserved', + 1005: 'reserved for extensions', + 1006: 'reserved for extensions', + 1007: 'inconsistent or invalid data', + 1008: 'policy violation', + 1009: 'message too big', + 1010: 'extension handshake missing', + 1011: 'an unexpected condition prevented the request from being fulfilled', }; \ No newline at end of file diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/Extensions.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/Extensions.js index 3db88a0c..a465ace2 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/Extensions.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/Extensions.js @@ -1,70 +1,70 @@ - -var util = require('util'); - -/** - * Module exports. - */ - -exports.parse = parse; -exports.format = format; - -/** - * Parse extensions header value - */ - -function parse(value) { - value = value || ''; - - var extensions = {}; - - value.split(',').forEach(function(v) { - var params = v.split(';'); - var token = params.shift().trim(); - var paramsList = extensions[token] = extensions[token] || []; - var parsedParams = {}; - - params.forEach(function(param) { - var parts = param.trim().split('='); - var key = parts[0]; - var value = parts[1]; - if (typeof value === 'undefined') { - value = true; - } else { - // unquote value - if (value[0] === '"') { - value = value.slice(1); - } - if (value[value.length - 1] === '"') { - value = value.slice(0, value.length - 1); - } - } - (parsedParams[key] = parsedParams[key] || []).push(value); - }); - - paramsList.push(parsedParams); - }); - - return extensions; -} - -/** - * Format extensions header value - */ - -function format(value) { - return Object.keys(value).map(function(token) { - var paramsList = value[token]; - if (!util.isArray(paramsList)) { - paramsList = [paramsList]; - } - return paramsList.map(function(params) { - return [token].concat(Object.keys(params).map(function(k) { - var p = params[k]; - if (!util.isArray(p)) p = [p]; - return p.map(function(v) { - return v === true ? k : k + '=' + v; - }).join('; '); - })).join('; '); - }).join(', '); - }).join(', '); -} + +var util = require('util'); + +/** + * Module exports. + */ + +exports.parse = parse; +exports.format = format; + +/** + * Parse extensions header value + */ + +function parse(value) { + value = value || ''; + + var extensions = {}; + + value.split(',').forEach(function(v) { + var params = v.split(';'); + var token = params.shift().trim(); + var paramsList = extensions[token] = extensions[token] || []; + var parsedParams = {}; + + params.forEach(function(param) { + var parts = param.trim().split('='); + var key = parts[0]; + var value = parts[1]; + if (typeof value === 'undefined') { + value = true; + } else { + // unquote value + if (value[0] === '"') { + value = value.slice(1); + } + if (value[value.length - 1] === '"') { + value = value.slice(0, value.length - 1); + } + } + (parsedParams[key] = parsedParams[key] || []).push(value); + }); + + paramsList.push(parsedParams); + }); + + return extensions; +} + +/** + * Format extensions header value + */ + +function format(value) { + return Object.keys(value).map(function(token) { + var paramsList = value[token]; + if (!util.isArray(paramsList)) { + paramsList = [paramsList]; + } + return paramsList.map(function(params) { + return [token].concat(Object.keys(params).map(function(k) { + var p = params[k]; + if (!util.isArray(p)) p = [p]; + return p.map(function(v) { + return v === true ? k : k + '=' + v; + }).join('; '); + })).join('; '); + }).join(', '); + }).join(', '); +} diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/PerMessageDeflate.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/PerMessageDeflate.js index 7ef74bec..00a6ea62 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/PerMessageDeflate.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/PerMessageDeflate.js @@ -1,337 +1,337 @@ - -var zlib = require('zlib'); - -var AVAILABLE_WINDOW_BITS = [8, 9, 10, 11, 12, 13, 14, 15]; -var DEFAULT_WINDOW_BITS = 15; -var DEFAULT_MEM_LEVEL = 8; - -PerMessageDeflate.extensionName = 'permessage-deflate'; - -/** - * Per-message Compression Extensions implementation - */ - -function PerMessageDeflate(options, isServer,maxPayload) { - if (this instanceof PerMessageDeflate === false) { - throw new TypeError("Classes can't be function-called"); - } - - this._options = options || {}; - this._isServer = !!isServer; - this._inflate = null; - this._deflate = null; - this.params = null; - this._maxPayload = maxPayload || 0; -} - -/** - * Create extension parameters offer - * - * @api public - */ - -PerMessageDeflate.prototype.offer = function() { - var params = {}; - if (this._options.serverNoContextTakeover) { - params.server_no_context_takeover = true; - } - if (this._options.clientNoContextTakeover) { - params.client_no_context_takeover = true; - } - if (this._options.serverMaxWindowBits) { - params.server_max_window_bits = this._options.serverMaxWindowBits; - } - if (this._options.clientMaxWindowBits) { - params.client_max_window_bits = this._options.clientMaxWindowBits; - } else if (this._options.clientMaxWindowBits == null) { - params.client_max_window_bits = true; - } - return params; -}; - -/** - * Accept extension offer - * - * @api public - */ - -PerMessageDeflate.prototype.accept = function(paramsList) { - paramsList = this.normalizeParams(paramsList); - - var params; - if (this._isServer) { - params = this.acceptAsServer(paramsList); - } else { - params = this.acceptAsClient(paramsList); - } - - this.params = params; - return params; -}; - -/** - * Releases all resources used by the extension - * - * @api public - */ - -PerMessageDeflate.prototype.cleanup = function() { - if (this._inflate) { - if (this._inflate.writeInProgress) { - this._inflate.pendingClose = true; - } else { - if (this._inflate.close) this._inflate.close(); - this._inflate = null; - } - } - if (this._deflate) { - if (this._deflate.writeInProgress) { - this._deflate.pendingClose = true; - } else { - if (this._deflate.close) this._deflate.close(); - this._deflate = null; - } - } -}; - -/** - * Accept extension offer from client - * - * @api private - */ - -PerMessageDeflate.prototype.acceptAsServer = function(paramsList) { - var accepted = {}; - var result = paramsList.some(function(params) { - accepted = {}; - if (this._options.serverNoContextTakeover === false && params.server_no_context_takeover) { - return; - } - if (this._options.serverMaxWindowBits === false && params.server_max_window_bits) { - return; - } - if (typeof this._options.serverMaxWindowBits === 'number' && - typeof params.server_max_window_bits === 'number' && - this._options.serverMaxWindowBits > params.server_max_window_bits) { - return; - } - if (typeof this._options.clientMaxWindowBits === 'number' && !params.client_max_window_bits) { - return; - } - - if (this._options.serverNoContextTakeover || params.server_no_context_takeover) { - accepted.server_no_context_takeover = true; - } - if (this._options.clientNoContextTakeover) { - accepted.client_no_context_takeover = true; - } - if (this._options.clientNoContextTakeover !== false && params.client_no_context_takeover) { - accepted.client_no_context_takeover = true; - } - if (typeof this._options.serverMaxWindowBits === 'number') { - accepted.server_max_window_bits = this._options.serverMaxWindowBits; - } else if (typeof params.server_max_window_bits === 'number') { - accepted.server_max_window_bits = params.server_max_window_bits; - } - if (typeof this._options.clientMaxWindowBits === 'number') { - accepted.client_max_window_bits = this._options.clientMaxWindowBits; - } else if (this._options.clientMaxWindowBits !== false && typeof params.client_max_window_bits === 'number') { - accepted.client_max_window_bits = params.client_max_window_bits; - } - return true; - }, this); - - if (!result) { - throw new Error('Doesn\'t support the offered configuration'); - } - - return accepted; -}; - -/** - * Accept extension response from server - * - * @api privaye - */ - -PerMessageDeflate.prototype.acceptAsClient = function(paramsList) { - var params = paramsList[0]; - if (this._options.clientNoContextTakeover != null) { - if (this._options.clientNoContextTakeover === false && params.client_no_context_takeover) { - throw new Error('Invalid value for "client_no_context_takeover"'); - } - } - if (this._options.clientMaxWindowBits != null) { - if (this._options.clientMaxWindowBits === false && params.client_max_window_bits) { - throw new Error('Invalid value for "client_max_window_bits"'); - } - if (typeof this._options.clientMaxWindowBits === 'number' && - (!params.client_max_window_bits || params.client_max_window_bits > this._options.clientMaxWindowBits)) { - throw new Error('Invalid value for "client_max_window_bits"'); - } - } - return params; -}; - -/** - * Normalize extensions parameters - * - * @api private - */ - -PerMessageDeflate.prototype.normalizeParams = function(paramsList) { - return paramsList.map(function(params) { - Object.keys(params).forEach(function(key) { - var value = params[key]; - if (value.length > 1) { - throw new Error('Multiple extension parameters for ' + key); - } - - value = value[0]; - - switch (key) { - case 'server_no_context_takeover': - case 'client_no_context_takeover': - if (value !== true) { - throw new Error('invalid extension parameter value for ' + key + ' (' + value + ')'); - } - params[key] = true; - break; - case 'server_max_window_bits': - case 'client_max_window_bits': - if (typeof value === 'string') { - value = parseInt(value, 10); - if (!~AVAILABLE_WINDOW_BITS.indexOf(value)) { - throw new Error('invalid extension parameter value for ' + key + ' (' + value + ')'); - } - } - if (!this._isServer && value === true) { - throw new Error('Missing extension parameter value for ' + key); - } - params[key] = value; - break; - default: - throw new Error('Not defined extension parameter (' + key + ')'); - } - }, this); - return params; - }, this); -}; - -/** - * Decompress message - * - * @api public - */ - -PerMessageDeflate.prototype.decompress = function (data, fin, callback) { - var endpoint = this._isServer ? 'client' : 'server'; - - if (!this._inflate) { - var maxWindowBits = this.params[endpoint + '_max_window_bits']; - this._inflate = zlib.createInflateRaw({ - windowBits: 'number' === typeof maxWindowBits ? maxWindowBits : DEFAULT_WINDOW_BITS - }); - } - this._inflate.writeInProgress = true; - - var self = this; - var buffers = []; - var cumulativeBufferLength=0; - - this._inflate.on('error', onError).on('data', onData); - this._inflate.write(data); - if (fin) { - this._inflate.write(new Buffer([0x00, 0x00, 0xff, 0xff])); - } - this._inflate.flush(function() { - cleanup(); - callback(null, Buffer.concat(buffers)); - }); - - function onError(err) { - cleanup(); - callback(err); - } - - function onData(data) { - if(self._maxPayload!==undefined && self._maxPayload!==null && self._maxPayload>0){ - cumulativeBufferLength+=data.length; - if(cumulativeBufferLength>self._maxPayload){ - buffers=[]; - cleanup(); - var err={type:1009}; - callback(err); - return; - } - } - buffers.push(data); - } - - function cleanup() { - if (!self._inflate) return; - self._inflate.removeListener('error', onError); - self._inflate.removeListener('data', onData); - self._inflate.writeInProgress = false; - if ((fin && self.params[endpoint + '_no_context_takeover']) || self._inflate.pendingClose) { - if (self._inflate.close) self._inflate.close(); - self._inflate = null; - } - } -}; - -/** - * Compress message - * - * @api public - */ - -PerMessageDeflate.prototype.compress = function (data, fin, callback) { - var endpoint = this._isServer ? 'server' : 'client'; - - if (!this._deflate) { - var maxWindowBits = this.params[endpoint + '_max_window_bits']; - this._deflate = zlib.createDeflateRaw({ - flush: zlib.Z_SYNC_FLUSH, - windowBits: 'number' === typeof maxWindowBits ? maxWindowBits : DEFAULT_WINDOW_BITS, - memLevel: this._options.memLevel || DEFAULT_MEM_LEVEL - }); - } - this._deflate.writeInProgress = true; - - var self = this; - var buffers = []; - - this._deflate.on('error', onError).on('data', onData); - this._deflate.write(data); - this._deflate.flush(function() { - cleanup(); - var data = Buffer.concat(buffers); - if (fin) { - data = data.slice(0, data.length - 4); - } - callback(null, data); - }); - - function onError(err) { - cleanup(); - callback(err); - } - - function onData(data) { - buffers.push(data); - } - - function cleanup() { - if (!self._deflate) return; - self._deflate.removeListener('error', onError); - self._deflate.removeListener('data', onData); - self._deflate.writeInProgress = false; - if ((fin && self.params[endpoint + '_no_context_takeover']) || self._deflate.pendingClose) { - if (self._deflate.close) self._deflate.close(); - self._deflate = null; - } - } -}; - -module.exports = PerMessageDeflate; + +var zlib = require('zlib'); + +var AVAILABLE_WINDOW_BITS = [8, 9, 10, 11, 12, 13, 14, 15]; +var DEFAULT_WINDOW_BITS = 15; +var DEFAULT_MEM_LEVEL = 8; + +PerMessageDeflate.extensionName = 'permessage-deflate'; + +/** + * Per-message Compression Extensions implementation + */ + +function PerMessageDeflate(options, isServer,maxPayload) { + if (this instanceof PerMessageDeflate === false) { + throw new TypeError("Classes can't be function-called"); + } + + this._options = options || {}; + this._isServer = !!isServer; + this._inflate = null; + this._deflate = null; + this.params = null; + this._maxPayload = maxPayload || 0; +} + +/** + * Create extension parameters offer + * + * @api public + */ + +PerMessageDeflate.prototype.offer = function() { + var params = {}; + if (this._options.serverNoContextTakeover) { + params.server_no_context_takeover = true; + } + if (this._options.clientNoContextTakeover) { + params.client_no_context_takeover = true; + } + if (this._options.serverMaxWindowBits) { + params.server_max_window_bits = this._options.serverMaxWindowBits; + } + if (this._options.clientMaxWindowBits) { + params.client_max_window_bits = this._options.clientMaxWindowBits; + } else if (this._options.clientMaxWindowBits == null) { + params.client_max_window_bits = true; + } + return params; +}; + +/** + * Accept extension offer + * + * @api public + */ + +PerMessageDeflate.prototype.accept = function(paramsList) { + paramsList = this.normalizeParams(paramsList); + + var params; + if (this._isServer) { + params = this.acceptAsServer(paramsList); + } else { + params = this.acceptAsClient(paramsList); + } + + this.params = params; + return params; +}; + +/** + * Releases all resources used by the extension + * + * @api public + */ + +PerMessageDeflate.prototype.cleanup = function() { + if (this._inflate) { + if (this._inflate.writeInProgress) { + this._inflate.pendingClose = true; + } else { + if (this._inflate.close) this._inflate.close(); + this._inflate = null; + } + } + if (this._deflate) { + if (this._deflate.writeInProgress) { + this._deflate.pendingClose = true; + } else { + if (this._deflate.close) this._deflate.close(); + this._deflate = null; + } + } +}; + +/** + * Accept extension offer from client + * + * @api private + */ + +PerMessageDeflate.prototype.acceptAsServer = function(paramsList) { + var accepted = {}; + var result = paramsList.some(function(params) { + accepted = {}; + if (this._options.serverNoContextTakeover === false && params.server_no_context_takeover) { + return; + } + if (this._options.serverMaxWindowBits === false && params.server_max_window_bits) { + return; + } + if (typeof this._options.serverMaxWindowBits === 'number' && + typeof params.server_max_window_bits === 'number' && + this._options.serverMaxWindowBits > params.server_max_window_bits) { + return; + } + if (typeof this._options.clientMaxWindowBits === 'number' && !params.client_max_window_bits) { + return; + } + + if (this._options.serverNoContextTakeover || params.server_no_context_takeover) { + accepted.server_no_context_takeover = true; + } + if (this._options.clientNoContextTakeover) { + accepted.client_no_context_takeover = true; + } + if (this._options.clientNoContextTakeover !== false && params.client_no_context_takeover) { + accepted.client_no_context_takeover = true; + } + if (typeof this._options.serverMaxWindowBits === 'number') { + accepted.server_max_window_bits = this._options.serverMaxWindowBits; + } else if (typeof params.server_max_window_bits === 'number') { + accepted.server_max_window_bits = params.server_max_window_bits; + } + if (typeof this._options.clientMaxWindowBits === 'number') { + accepted.client_max_window_bits = this._options.clientMaxWindowBits; + } else if (this._options.clientMaxWindowBits !== false && typeof params.client_max_window_bits === 'number') { + accepted.client_max_window_bits = params.client_max_window_bits; + } + return true; + }, this); + + if (!result) { + throw new Error('Doesn\'t support the offered configuration'); + } + + return accepted; +}; + +/** + * Accept extension response from server + * + * @api privaye + */ + +PerMessageDeflate.prototype.acceptAsClient = function(paramsList) { + var params = paramsList[0]; + if (this._options.clientNoContextTakeover != null) { + if (this._options.clientNoContextTakeover === false && params.client_no_context_takeover) { + throw new Error('Invalid value for "client_no_context_takeover"'); + } + } + if (this._options.clientMaxWindowBits != null) { + if (this._options.clientMaxWindowBits === false && params.client_max_window_bits) { + throw new Error('Invalid value for "client_max_window_bits"'); + } + if (typeof this._options.clientMaxWindowBits === 'number' && + (!params.client_max_window_bits || params.client_max_window_bits > this._options.clientMaxWindowBits)) { + throw new Error('Invalid value for "client_max_window_bits"'); + } + } + return params; +}; + +/** + * Normalize extensions parameters + * + * @api private + */ + +PerMessageDeflate.prototype.normalizeParams = function(paramsList) { + return paramsList.map(function(params) { + Object.keys(params).forEach(function(key) { + var value = params[key]; + if (value.length > 1) { + throw new Error('Multiple extension parameters for ' + key); + } + + value = value[0]; + + switch (key) { + case 'server_no_context_takeover': + case 'client_no_context_takeover': + if (value !== true) { + throw new Error('invalid extension parameter value for ' + key + ' (' + value + ')'); + } + params[key] = true; + break; + case 'server_max_window_bits': + case 'client_max_window_bits': + if (typeof value === 'string') { + value = parseInt(value, 10); + if (!~AVAILABLE_WINDOW_BITS.indexOf(value)) { + throw new Error('invalid extension parameter value for ' + key + ' (' + value + ')'); + } + } + if (!this._isServer && value === true) { + throw new Error('Missing extension parameter value for ' + key); + } + params[key] = value; + break; + default: + throw new Error('Not defined extension parameter (' + key + ')'); + } + }, this); + return params; + }, this); +}; + +/** + * Decompress message + * + * @api public + */ + +PerMessageDeflate.prototype.decompress = function (data, fin, callback) { + var endpoint = this._isServer ? 'client' : 'server'; + + if (!this._inflate) { + var maxWindowBits = this.params[endpoint + '_max_window_bits']; + this._inflate = zlib.createInflateRaw({ + windowBits: 'number' === typeof maxWindowBits ? maxWindowBits : DEFAULT_WINDOW_BITS + }); + } + this._inflate.writeInProgress = true; + + var self = this; + var buffers = []; + var cumulativeBufferLength=0; + + this._inflate.on('error', onError).on('data', onData); + this._inflate.write(data); + if (fin) { + this._inflate.write(new Buffer([0x00, 0x00, 0xff, 0xff])); + } + this._inflate.flush(function() { + cleanup(); + callback(null, Buffer.concat(buffers)); + }); + + function onError(err) { + cleanup(); + callback(err); + } + + function onData(data) { + if(self._maxPayload!==undefined && self._maxPayload!==null && self._maxPayload>0){ + cumulativeBufferLength+=data.length; + if(cumulativeBufferLength>self._maxPayload){ + buffers=[]; + cleanup(); + var err={type:1009}; + callback(err); + return; + } + } + buffers.push(data); + } + + function cleanup() { + if (!self._inflate) return; + self._inflate.removeListener('error', onError); + self._inflate.removeListener('data', onData); + self._inflate.writeInProgress = false; + if ((fin && self.params[endpoint + '_no_context_takeover']) || self._inflate.pendingClose) { + if (self._inflate.close) self._inflate.close(); + self._inflate = null; + } + } +}; + +/** + * Compress message + * + * @api public + */ + +PerMessageDeflate.prototype.compress = function (data, fin, callback) { + var endpoint = this._isServer ? 'server' : 'client'; + + if (!this._deflate) { + var maxWindowBits = this.params[endpoint + '_max_window_bits']; + this._deflate = zlib.createDeflateRaw({ + flush: zlib.Z_SYNC_FLUSH, + windowBits: 'number' === typeof maxWindowBits ? maxWindowBits : DEFAULT_WINDOW_BITS, + memLevel: this._options.memLevel || DEFAULT_MEM_LEVEL + }); + } + this._deflate.writeInProgress = true; + + var self = this; + var buffers = []; + + this._deflate.on('error', onError).on('data', onData); + this._deflate.write(data); + this._deflate.flush(function() { + cleanup(); + var data = Buffer.concat(buffers); + if (fin) { + data = data.slice(0, data.length - 4); + } + callback(null, data); + }); + + function onError(err) { + cleanup(); + callback(err); + } + + function onData(data) { + buffers.push(data); + } + + function cleanup() { + if (!self._deflate) return; + self._deflate.removeListener('error', onError); + self._deflate.removeListener('data', onData); + self._deflate.writeInProgress = false; + if ((fin && self.params[endpoint + '_no_context_takeover']) || self._deflate.pendingClose) { + if (self._deflate.close) self._deflate.close(); + self._deflate = null; + } + } +}; + +module.exports = PerMessageDeflate; diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/Receiver.hixie.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/Receiver.hixie.js index a30ed45c..598ccbda 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/Receiver.hixie.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/Receiver.hixie.js @@ -1,194 +1,194 @@ -/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - -var util = require('util'); - -/** - * State constants - */ - -var EMPTY = 0 - , BODY = 1; -var BINARYLENGTH = 2 - , BINARYBODY = 3; - -/** - * Hixie Receiver implementation - */ - -function Receiver () { - if (this instanceof Receiver === false) { - throw new TypeError("Classes can't be function-called"); - } - - this.state = EMPTY; - this.buffers = []; - this.messageEnd = -1; - this.spanLength = 0; - this.dead = false; - - this.onerror = function() {}; - this.ontext = function() {}; - this.onbinary = function() {}; - this.onclose = function() {}; - this.onping = function() {}; - this.onpong = function() {}; -} - -module.exports = Receiver; - -/** - * Add new data to the parser. - * - * @api public - */ - -Receiver.prototype.add = function(data) { - if (this.dead) return; - var self = this; - function doAdd() { - if (self.state === EMPTY) { - if (data.length == 2 && data[0] == 0xFF && data[1] == 0x00) { - self.reset(); - self.onclose(); - return; - } - if (data[0] === 0x80) { - self.messageEnd = 0; - self.state = BINARYLENGTH; - data = data.slice(1); - } else { - - if (data[0] !== 0x00) { - self.error('payload must start with 0x00 byte', true); - return; - } - data = data.slice(1); - self.state = BODY; - - } - } - if (self.state === BINARYLENGTH) { - var i = 0; - while ((i < data.length) && (data[i] & 0x80)) { - self.messageEnd = 128 * self.messageEnd + (data[i] & 0x7f); - ++i; - } - if (i < data.length) { - self.messageEnd = 128 * self.messageEnd + (data[i] & 0x7f); - self.state = BINARYBODY; - ++i; - } - if (i > 0) - data = data.slice(i); - } - if (self.state === BINARYBODY) { - var dataleft = self.messageEnd - self.spanLength; - if (data.length >= dataleft) { - // consume the whole buffer to finish the frame - self.buffers.push(data); - self.spanLength += dataleft; - self.messageEnd = dataleft; - return self.parse(); - } - // frame's not done even if we consume it all - self.buffers.push(data); - self.spanLength += data.length; - return; - } - self.buffers.push(data); - if ((self.messageEnd = bufferIndex(data, 0xFF)) != -1) { - self.spanLength += self.messageEnd; - return self.parse(); - } - else self.spanLength += data.length; - } - while(data) data = doAdd(); -}; - -/** - * Releases all resources used by the receiver. - * - * @api public - */ - -Receiver.prototype.cleanup = function() { - this.dead = true; - this.state = EMPTY; - this.buffers = []; -}; - -/** - * Process buffered data. - * - * @api public - */ - -Receiver.prototype.parse = function() { - var output = new Buffer(this.spanLength); - var outputIndex = 0; - for (var bi = 0, bl = this.buffers.length; bi < bl - 1; ++bi) { - var buffer = this.buffers[bi]; - buffer.copy(output, outputIndex); - outputIndex += buffer.length; - } - var lastBuffer = this.buffers[this.buffers.length - 1]; - if (this.messageEnd > 0) lastBuffer.copy(output, outputIndex, 0, this.messageEnd); - if (this.state !== BODY) --this.messageEnd; - var tail = null; - if (this.messageEnd < lastBuffer.length - 1) { - tail = lastBuffer.slice(this.messageEnd + 1); - } - this.reset(); - this.ontext(output.toString('utf8')); - return tail; -}; - -/** - * Handles an error - * - * @api private - */ - -Receiver.prototype.error = function (reason, terminate) { - if (this.dead) return; - this.reset(); - if(typeof reason == 'string'){ - this.onerror(new Error(reason), terminate); - } - else if(reason.constructor == Error){ - this.onerror(reason, terminate); - } - else{ - this.onerror(new Error("An error occured"),terminate); - } - return this; -}; - -/** - * Reset parser state - * - * @api private - */ - -Receiver.prototype.reset = function (reason) { - if (this.dead) return; - this.state = EMPTY; - this.buffers = []; - this.messageEnd = -1; - this.spanLength = 0; -}; - -/** - * Internal api - */ - -function bufferIndex(buffer, byte) { - for (var i = 0, l = buffer.length; i < l; ++i) { - if (buffer[i] === byte) return i; - } - return -1; -} +/*! + * ws: a node.js websocket client + * Copyright(c) 2011 Einar Otto Stangvik + * MIT Licensed + */ + +var util = require('util'); + +/** + * State constants + */ + +var EMPTY = 0 + , BODY = 1; +var BINARYLENGTH = 2 + , BINARYBODY = 3; + +/** + * Hixie Receiver implementation + */ + +function Receiver () { + if (this instanceof Receiver === false) { + throw new TypeError("Classes can't be function-called"); + } + + this.state = EMPTY; + this.buffers = []; + this.messageEnd = -1; + this.spanLength = 0; + this.dead = false; + + this.onerror = function() {}; + this.ontext = function() {}; + this.onbinary = function() {}; + this.onclose = function() {}; + this.onping = function() {}; + this.onpong = function() {}; +} + +module.exports = Receiver; + +/** + * Add new data to the parser. + * + * @api public + */ + +Receiver.prototype.add = function(data) { + if (this.dead) return; + var self = this; + function doAdd() { + if (self.state === EMPTY) { + if (data.length == 2 && data[0] == 0xFF && data[1] == 0x00) { + self.reset(); + self.onclose(); + return; + } + if (data[0] === 0x80) { + self.messageEnd = 0; + self.state = BINARYLENGTH; + data = data.slice(1); + } else { + + if (data[0] !== 0x00) { + self.error('payload must start with 0x00 byte', true); + return; + } + data = data.slice(1); + self.state = BODY; + + } + } + if (self.state === BINARYLENGTH) { + var i = 0; + while ((i < data.length) && (data[i] & 0x80)) { + self.messageEnd = 128 * self.messageEnd + (data[i] & 0x7f); + ++i; + } + if (i < data.length) { + self.messageEnd = 128 * self.messageEnd + (data[i] & 0x7f); + self.state = BINARYBODY; + ++i; + } + if (i > 0) + data = data.slice(i); + } + if (self.state === BINARYBODY) { + var dataleft = self.messageEnd - self.spanLength; + if (data.length >= dataleft) { + // consume the whole buffer to finish the frame + self.buffers.push(data); + self.spanLength += dataleft; + self.messageEnd = dataleft; + return self.parse(); + } + // frame's not done even if we consume it all + self.buffers.push(data); + self.spanLength += data.length; + return; + } + self.buffers.push(data); + if ((self.messageEnd = bufferIndex(data, 0xFF)) != -1) { + self.spanLength += self.messageEnd; + return self.parse(); + } + else self.spanLength += data.length; + } + while(data) data = doAdd(); +}; + +/** + * Releases all resources used by the receiver. + * + * @api public + */ + +Receiver.prototype.cleanup = function() { + this.dead = true; + this.state = EMPTY; + this.buffers = []; +}; + +/** + * Process buffered data. + * + * @api public + */ + +Receiver.prototype.parse = function() { + var output = new Buffer(this.spanLength); + var outputIndex = 0; + for (var bi = 0, bl = this.buffers.length; bi < bl - 1; ++bi) { + var buffer = this.buffers[bi]; + buffer.copy(output, outputIndex); + outputIndex += buffer.length; + } + var lastBuffer = this.buffers[this.buffers.length - 1]; + if (this.messageEnd > 0) lastBuffer.copy(output, outputIndex, 0, this.messageEnd); + if (this.state !== BODY) --this.messageEnd; + var tail = null; + if (this.messageEnd < lastBuffer.length - 1) { + tail = lastBuffer.slice(this.messageEnd + 1); + } + this.reset(); + this.ontext(output.toString('utf8')); + return tail; +}; + +/** + * Handles an error + * + * @api private + */ + +Receiver.prototype.error = function (reason, terminate) { + if (this.dead) return; + this.reset(); + if(typeof reason == 'string'){ + this.onerror(new Error(reason), terminate); + } + else if(reason.constructor == Error){ + this.onerror(reason, terminate); + } + else{ + this.onerror(new Error("An error occured"),terminate); + } + return this; +}; + +/** + * Reset parser state + * + * @api private + */ + +Receiver.prototype.reset = function (reason) { + if (this.dead) return; + this.state = EMPTY; + this.buffers = []; + this.messageEnd = -1; + this.spanLength = 0; +}; + +/** + * Internal api + */ + +function bufferIndex(buffer, byte) { + for (var i = 0, l = buffer.length; i < l; ++i) { + if (buffer[i] === byte) return i; + } + return -1; +} diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/Receiver.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/Receiver.js index e7e28872..0bf29d80 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/Receiver.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/Receiver.js @@ -1,793 +1,793 @@ -/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - -var util = require('util') - , Validation = require('./Validation').Validation - , ErrorCodes = require('./ErrorCodes') - , BufferPool = require('./BufferPool') - , bufferUtil = require('./BufferUtil').BufferUtil - , PerMessageDeflate = require('./PerMessageDeflate'); - -/** - * HyBi Receiver implementation - */ - -function Receiver (extensions,maxPayload) { - if (this instanceof Receiver === false) { - throw new TypeError("Classes can't be function-called"); - } - if(typeof extensions==='number'){ - maxPayload=extensions; - extensions={}; - } - - - // memory pool for fragmented messages - var fragmentedPoolPrevUsed = -1; - this.fragmentedBufferPool = new BufferPool(1024, function(db, length) { - return db.used + length; - }, function(db) { - return fragmentedPoolPrevUsed = fragmentedPoolPrevUsed >= 0 ? - Math.ceil((fragmentedPoolPrevUsed + db.used) / 2) : - db.used; - }); - - // memory pool for unfragmented messages - var unfragmentedPoolPrevUsed = -1; - this.unfragmentedBufferPool = new BufferPool(1024, function(db, length) { - return db.used + length; - }, function(db) { - return unfragmentedPoolPrevUsed = unfragmentedPoolPrevUsed >= 0 ? - Math.ceil((unfragmentedPoolPrevUsed + db.used) / 2) : - db.used; - }); - this.extensions = extensions || {}; - this.maxPayload = maxPayload || 0; - this.currentPayloadLength = 0; - this.state = { - activeFragmentedOperation: null, - lastFragment: false, - masked: false, - opcode: 0, - fragmentedOperation: false - }; - this.overflow = []; - this.headerBuffer = new Buffer(10); - this.expectOffset = 0; - this.expectBuffer = null; - this.expectHandler = null; - this.currentMessage = []; - this.currentMessageLength = 0; - this.messageHandlers = []; - this.expectHeader(2, this.processPacket); - this.dead = false; - this.processing = false; - - this.onerror = function() {}; - this.ontext = function() {}; - this.onbinary = function() {}; - this.onclose = function() {}; - this.onping = function() {}; - this.onpong = function() {}; -} - -module.exports = Receiver; - -/** - * Add new data to the parser. - * - * @api public - */ - -Receiver.prototype.add = function(data) { - if (this.dead) return; - var dataLength = data.length; - if (dataLength == 0) return; - if (this.expectBuffer == null) { - this.overflow.push(data); - return; - } - var toRead = Math.min(dataLength, this.expectBuffer.length - this.expectOffset); - fastCopy(toRead, data, this.expectBuffer, this.expectOffset); - this.expectOffset += toRead; - if (toRead < dataLength) { - this.overflow.push(data.slice(toRead)); - } - while (this.expectBuffer && this.expectOffset == this.expectBuffer.length) { - var bufferForHandler = this.expectBuffer; - this.expectBuffer = null; - this.expectOffset = 0; - this.expectHandler.call(this, bufferForHandler); - } -}; - -/** - * Releases all resources used by the receiver. - * - * @api public - */ - -Receiver.prototype.cleanup = function() { - this.dead = true; - this.overflow = null; - this.headerBuffer = null; - this.expectBuffer = null; - this.expectHandler = null; - this.unfragmentedBufferPool = null; - this.fragmentedBufferPool = null; - this.state = null; - this.currentMessage = null; - this.onerror = null; - this.ontext = null; - this.onbinary = null; - this.onclose = null; - this.onping = null; - this.onpong = null; -}; - -/** - * Waits for a certain amount of header bytes to be available, then fires a callback. - * - * @api private - */ - -Receiver.prototype.expectHeader = function(length, handler) { - if (length == 0) { - handler(null); - return; - } - this.expectBuffer = this.headerBuffer.slice(this.expectOffset, this.expectOffset + length); - this.expectHandler = handler; - var toRead = length; - while (toRead > 0 && this.overflow.length > 0) { - var fromOverflow = this.overflow.pop(); - if (toRead < fromOverflow.length) this.overflow.push(fromOverflow.slice(toRead)); - var read = Math.min(fromOverflow.length, toRead); - fastCopy(read, fromOverflow, this.expectBuffer, this.expectOffset); - this.expectOffset += read; - toRead -= read; - } -}; - -/** - * Waits for a certain amount of data bytes to be available, then fires a callback. - * - * @api private - */ - -Receiver.prototype.expectData = function(length, handler) { - if (length == 0) { - handler(null); - return; - } - this.expectBuffer = this.allocateFromPool(length, this.state.fragmentedOperation); - this.expectHandler = handler; - var toRead = length; - while (toRead > 0 && this.overflow.length > 0) { - var fromOverflow = this.overflow.pop(); - if (toRead < fromOverflow.length) this.overflow.push(fromOverflow.slice(toRead)); - var read = Math.min(fromOverflow.length, toRead); - fastCopy(read, fromOverflow, this.expectBuffer, this.expectOffset); - this.expectOffset += read; - toRead -= read; - } -}; - -/** - * Allocates memory from the buffer pool. - * - * @api private - */ - -Receiver.prototype.allocateFromPool = function(length, isFragmented) { - return (isFragmented ? this.fragmentedBufferPool : this.unfragmentedBufferPool).get(length); -}; - -/** - * Start processing a new packet. - * - * @api private - */ - -Receiver.prototype.processPacket = function (data) { - if (this.extensions[PerMessageDeflate.extensionName]) { - if ((data[0] & 0x30) != 0) { - this.error('reserved fields (2, 3) must be empty', 1002); - return; - } - } else { - if ((data[0] & 0x70) != 0) { - this.error('reserved fields must be empty', 1002); - return; - } - } - this.state.lastFragment = (data[0] & 0x80) == 0x80; - this.state.masked = (data[1] & 0x80) == 0x80; - var compressed = (data[0] & 0x40) == 0x40; - var opcode = data[0] & 0xf; - if (opcode === 0) { - if (compressed) { - this.error('continuation frame cannot have the Per-message Compressed bits', 1002); - return; - } - // continuation frame - this.state.fragmentedOperation = true; - this.state.opcode = this.state.activeFragmentedOperation; - if (!(this.state.opcode == 1 || this.state.opcode == 2)) { - this.error('continuation frame cannot follow current opcode', 1002); - return; - } - } - else { - if (opcode < 3 && this.state.activeFragmentedOperation != null) { - this.error('data frames after the initial data frame must have opcode 0', 1002); - return; - } - if (opcode >= 8 && compressed) { - this.error('control frames cannot have the Per-message Compressed bits', 1002); - return; - } - this.state.compressed = compressed; - this.state.opcode = opcode; - if (this.state.lastFragment === false) { - this.state.fragmentedOperation = true; - this.state.activeFragmentedOperation = opcode; - } - else this.state.fragmentedOperation = false; - } - var handler = opcodes[this.state.opcode]; - if (typeof handler == 'undefined') this.error('no handler for opcode ' + this.state.opcode, 1002); - else { - handler.start.call(this, data); - } -}; - -/** - * Endprocessing a packet. - * - * @api private - */ - -Receiver.prototype.endPacket = function() { - if (this.dead) return; - if (!this.state.fragmentedOperation) this.unfragmentedBufferPool.reset(true); - else if (this.state.lastFragment) this.fragmentedBufferPool.reset(true); - this.expectOffset = 0; - this.expectBuffer = null; - this.expectHandler = null; - if (this.state.lastFragment && this.state.opcode === this.state.activeFragmentedOperation) { - // end current fragmented operation - this.state.activeFragmentedOperation = null; - } - this.currentPayloadLength = 0; - this.state.lastFragment = false; - this.state.opcode = this.state.activeFragmentedOperation != null ? this.state.activeFragmentedOperation : 0; - this.state.masked = false; - this.expectHeader(2, this.processPacket); -}; - -/** - * Reset the parser state. - * - * @api private - */ - -Receiver.prototype.reset = function() { - if (this.dead) return; - this.state = { - activeFragmentedOperation: null, - lastFragment: false, - masked: false, - opcode: 0, - fragmentedOperation: false - }; - this.fragmentedBufferPool.reset(true); - this.unfragmentedBufferPool.reset(true); - this.expectOffset = 0; - this.expectBuffer = null; - this.expectHandler = null; - this.overflow = []; - this.currentMessage = []; - this.currentMessageLength = 0; - this.messageHandlers = []; - this.currentPayloadLength = 0; -}; - -/** - * Unmask received data. - * - * @api private - */ - -Receiver.prototype.unmask = function (mask, buf, binary) { - if (mask != null && buf != null) bufferUtil.unmask(buf, mask); - if (binary) return buf; - return buf != null ? buf.toString('utf8') : ''; -}; - -/** - * Handles an error - * - * @api private - */ - -Receiver.prototype.error = function (reason, protocolErrorCode) { - if (this.dead) return; - this.reset(); - if(typeof reason == 'string'){ - this.onerror(new Error(reason), protocolErrorCode); - } - else if(reason.constructor == Error){ - this.onerror(reason, protocolErrorCode); - } - else{ - this.onerror(new Error("An error occured"),protocolErrorCode); - } - return this; -}; - -/** - * Execute message handler buffers - * - * @api private - */ - -Receiver.prototype.flush = function() { - if (this.processing || this.dead) return; - - var handler = this.messageHandlers.shift(); - if (!handler) return; - - this.processing = true; - var self = this; - - handler(function() { - self.processing = false; - self.flush(); - }); -}; - -/** - * Apply extensions to message - * - * @api private - */ - -Receiver.prototype.applyExtensions = function(messageBuffer, fin, compressed, callback) { - var self = this; - if (compressed) { - this.extensions[PerMessageDeflate.extensionName].decompress(messageBuffer, fin, function(err, buffer) { - if (self.dead) return; - if (err) { - callback(new Error('invalid compressed data')); - return; - } - callback(null, buffer); - }); - } else { - callback(null, messageBuffer); - } -}; - -/** -* Checks payload size, disconnects socket when it exceeds maxPayload -* -* @api private -*/ -Receiver.prototype.maxPayloadExceeded = function(length) { - if (this.maxPayload=== undefined || this.maxPayload === null || this.maxPayload < 1) { - return false; - } - var fullLength = this.currentPayloadLength + length; - if (fullLength < this.maxPayload) { - this.currentPayloadLength = fullLength; - return false; - } - this.error('payload cannot exceed ' + this.maxPayload + ' bytes', 1009); - this.messageBuffer=[]; - this.cleanup(); - - return true; -}; - -/** - * Buffer utilities - */ - -function readUInt16BE(start) { - return (this[start]<<8) + - this[start+1]; -} - -function readUInt32BE(start) { - return (this[start]<<24) + - (this[start+1]<<16) + - (this[start+2]<<8) + - this[start+3]; -} - -function fastCopy(length, srcBuffer, dstBuffer, dstOffset) { - switch (length) { - default: srcBuffer.copy(dstBuffer, dstOffset, 0, length); break; - case 16: dstBuffer[dstOffset+15] = srcBuffer[15]; - case 15: dstBuffer[dstOffset+14] = srcBuffer[14]; - case 14: dstBuffer[dstOffset+13] = srcBuffer[13]; - case 13: dstBuffer[dstOffset+12] = srcBuffer[12]; - case 12: dstBuffer[dstOffset+11] = srcBuffer[11]; - case 11: dstBuffer[dstOffset+10] = srcBuffer[10]; - case 10: dstBuffer[dstOffset+9] = srcBuffer[9]; - case 9: dstBuffer[dstOffset+8] = srcBuffer[8]; - case 8: dstBuffer[dstOffset+7] = srcBuffer[7]; - case 7: dstBuffer[dstOffset+6] = srcBuffer[6]; - case 6: dstBuffer[dstOffset+5] = srcBuffer[5]; - case 5: dstBuffer[dstOffset+4] = srcBuffer[4]; - case 4: dstBuffer[dstOffset+3] = srcBuffer[3]; - case 3: dstBuffer[dstOffset+2] = srcBuffer[2]; - case 2: dstBuffer[dstOffset+1] = srcBuffer[1]; - case 1: dstBuffer[dstOffset] = srcBuffer[0]; - } -} - -function clone(obj) { - var cloned = {}; - for (var k in obj) { - if (obj.hasOwnProperty(k)) { - cloned[k] = obj[k]; - } - } - return cloned; -} - -/** - * Opcode handlers - */ - -var opcodes = { - // text - '1': { - start: function(data) { - var self = this; - // decode length - var firstLength = data[1] & 0x7f; - if (firstLength < 126) { - if (self.maxPayloadExceeded(firstLength)){ - self.error('Maximumpayload exceeded in compressed text message. Aborting...', 1009); - return; - } - opcodes['1'].getData.call(self, firstLength); - } - else if (firstLength == 126) { - self.expectHeader(2, function(data) { - var length = readUInt16BE.call(data, 0); - if (self.maxPayloadExceeded(length)){ - self.error('Maximumpayload exceeded in compressed text message. Aborting...', 1009); - return; - } - opcodes['1'].getData.call(self, length); - }); - } - else if (firstLength == 127) { - self.expectHeader(8, function(data) { - if (readUInt32BE.call(data, 0) != 0) { - self.error('packets with length spanning more than 32 bit is currently not supported', 1008); - return; - } - var length = readUInt32BE.call(data, 4); - if (self.maxPayloadExceeded(length)){ - self.error('Maximumpayload exceeded in compressed text message. Aborting...', 1009); - return; - } - opcodes['1'].getData.call(self, readUInt32BE.call(data, 4)); - }); - } - }, - getData: function(length) { - var self = this; - if (self.state.masked) { - self.expectHeader(4, function(data) { - var mask = data; - self.expectData(length, function(data) { - opcodes['1'].finish.call(self, mask, data); - }); - }); - } - else { - self.expectData(length, function(data) { - opcodes['1'].finish.call(self, null, data); - }); - } - }, - finish: function(mask, data) { - var self = this; - var packet = this.unmask(mask, data, true) || new Buffer(0); - var state = clone(this.state); - this.messageHandlers.push(function(callback) { - self.applyExtensions(packet, state.lastFragment, state.compressed, function(err, buffer) { - if (err) { - if(err.type===1009){ - return self.error('Maximumpayload exceeded in compressed text message. Aborting...', 1009); - } - return self.error(err.message, 1007); - } - if (buffer != null) { - if( self.maxPayload==0 || (self.maxPayload > 0 && (self.currentMessageLength + buffer.length) < self.maxPayload) ){ - self.currentMessage.push(buffer); - } - else{ - self.currentMessage=null; - self.currentMessage = []; - self.currentMessageLength = 0; - self.error(new Error('Maximum payload exceeded. maxPayload: '+self.maxPayload), 1009); - return; - } - self.currentMessageLength += buffer.length; - } - if (state.lastFragment) { - var messageBuffer = Buffer.concat(self.currentMessage); - self.currentMessage = []; - self.currentMessageLength = 0; - if (!Validation.isValidUTF8(messageBuffer)) { - self.error('invalid utf8 sequence', 1007); - return; - } - self.ontext(messageBuffer.toString('utf8'), {masked: state.masked, buffer: messageBuffer}); - } - callback(); - }); - }); - this.flush(); - this.endPacket(); - } - }, - // binary - '2': { - start: function(data) { - var self = this; - // decode length - var firstLength = data[1] & 0x7f; - if (firstLength < 126) { - if (self.maxPayloadExceeded(firstLength)){ - self.error('Max payload exceeded in compressed text message. Aborting...', 1009); - return; - } - opcodes['2'].getData.call(self, firstLength); - } - else if (firstLength == 126) { - self.expectHeader(2, function(data) { - var length = readUInt16BE.call(data, 0); - if (self.maxPayloadExceeded(length)){ - self.error('Max payload exceeded in compressed text message. Aborting...', 1009); - return; - } - opcodes['2'].getData.call(self, length); - }); - } - else if (firstLength == 127) { - self.expectHeader(8, function(data) { - if (readUInt32BE.call(data, 0) != 0) { - self.error('packets with length spanning more than 32 bit is currently not supported', 1008); - return; - } - var length = readUInt32BE.call(data, 4, true); - if (self.maxPayloadExceeded(length)){ - self.error('Max payload exceeded in compressed text message. Aborting...', 1009); - return; - } - opcodes['2'].getData.call(self, length); - }); - } - }, - getData: function(length) { - var self = this; - if (self.state.masked) { - self.expectHeader(4, function(data) { - var mask = data; - self.expectData(length, function(data) { - opcodes['2'].finish.call(self, mask, data); - }); - }); - } - else { - self.expectData(length, function(data) { - opcodes['2'].finish.call(self, null, data); - }); - } - }, - finish: function(mask, data) { - var self = this; - var packet = this.unmask(mask, data, true) || new Buffer(0); - var state = clone(this.state); - this.messageHandlers.push(function(callback) { - self.applyExtensions(packet, state.lastFragment, state.compressed, function(err, buffer) { - if (err) { - if(err.type===1009){ - return self.error('Max payload exceeded in compressed binary message. Aborting...', 1009); - } - return self.error(err.message, 1007); - } - if (buffer != null) { - if( self.maxPayload==0 || (self.maxPayload > 0 && (self.currentMessageLength + buffer.length) < self.maxPayload) ){ - self.currentMessage.push(buffer); - } - else{ - self.currentMessage=null; - self.currentMessage = []; - self.currentMessageLength = 0; - self.error(new Error('Maximum payload exceeded'), 1009); - return; - } - self.currentMessageLength += buffer.length; - } - if (state.lastFragment) { - var messageBuffer = Buffer.concat(self.currentMessage); - self.currentMessage = []; - self.currentMessageLength = 0; - self.onbinary(messageBuffer, {masked: state.masked, buffer: messageBuffer}); - } - callback(); - }); - }); - this.flush(); - this.endPacket(); - } - }, - // close - '8': { - start: function(data) { - var self = this; - if (self.state.lastFragment == false) { - self.error('fragmented close is not supported', 1002); - return; - } - - // decode length - var firstLength = data[1] & 0x7f; - if (firstLength < 126) { - opcodes['8'].getData.call(self, firstLength); - } - else { - self.error('control frames cannot have more than 125 bytes of data', 1002); - } - }, - getData: function(length) { - var self = this; - if (self.state.masked) { - self.expectHeader(4, function(data) { - var mask = data; - self.expectData(length, function(data) { - opcodes['8'].finish.call(self, mask, data); - }); - }); - } - else { - self.expectData(length, function(data) { - opcodes['8'].finish.call(self, null, data); - }); - } - }, - finish: function(mask, data) { - var self = this; - data = self.unmask(mask, data, true); - - var state = clone(this.state); - this.messageHandlers.push(function() { - if (data && data.length == 1) { - self.error('close packets with data must be at least two bytes long', 1002); - return; - } - var code = data && data.length > 1 ? readUInt16BE.call(data, 0) : 1000; - if (!ErrorCodes.isValidErrorCode(code)) { - self.error('invalid error code', 1002); - return; - } - var message = ''; - if (data && data.length > 2) { - var messageBuffer = data.slice(2); - if (!Validation.isValidUTF8(messageBuffer)) { - self.error('invalid utf8 sequence', 1007); - return; - } - message = messageBuffer.toString('utf8'); - } - self.onclose(code, message, {masked: state.masked}); - self.reset(); - }); - this.flush(); - }, - }, - // ping - '9': { - start: function(data) { - var self = this; - if (self.state.lastFragment == false) { - self.error('fragmented ping is not supported', 1002); - return; - } - - // decode length - var firstLength = data[1] & 0x7f; - if (firstLength < 126) { - opcodes['9'].getData.call(self, firstLength); - } - else { - self.error('control frames cannot have more than 125 bytes of data', 1002); - } - }, - getData: function(length) { - var self = this; - if (self.state.masked) { - self.expectHeader(4, function(data) { - var mask = data; - self.expectData(length, function(data) { - opcodes['9'].finish.call(self, mask, data); - }); - }); - } - else { - self.expectData(length, function(data) { - opcodes['9'].finish.call(self, null, data); - }); - } - }, - finish: function(mask, data) { - var self = this; - data = this.unmask(mask, data, true); - var state = clone(this.state); - this.messageHandlers.push(function(callback) { - self.onping(data, {masked: state.masked, binary: true}); - callback(); - }); - this.flush(); - this.endPacket(); - } - }, - // pong - '10': { - start: function(data) { - var self = this; - if (self.state.lastFragment == false) { - self.error('fragmented pong is not supported', 1002); - return; - } - - // decode length - var firstLength = data[1] & 0x7f; - if (firstLength < 126) { - opcodes['10'].getData.call(self, firstLength); - } - else { - self.error('control frames cannot have more than 125 bytes of data', 1002); - } - }, - getData: function(length) { - var self = this; - if (this.state.masked) { - this.expectHeader(4, function(data) { - var mask = data; - self.expectData(length, function(data) { - opcodes['10'].finish.call(self, mask, data); - }); - }); - } - else { - this.expectData(length, function(data) { - opcodes['10'].finish.call(self, null, data); - }); - } - }, - finish: function(mask, data) { - var self = this; - data = self.unmask(mask, data, true); - var state = clone(this.state); - this.messageHandlers.push(function(callback) { - self.onpong(data, {masked: state.masked, binary: true}); - callback(); - }); - this.flush(); - this.endPacket(); - } - } -} +/*! + * ws: a node.js websocket client + * Copyright(c) 2011 Einar Otto Stangvik + * MIT Licensed + */ + +var util = require('util') + , Validation = require('./Validation').Validation + , ErrorCodes = require('./ErrorCodes') + , BufferPool = require('./BufferPool') + , bufferUtil = require('./BufferUtil').BufferUtil + , PerMessageDeflate = require('./PerMessageDeflate'); + +/** + * HyBi Receiver implementation + */ + +function Receiver (extensions,maxPayload) { + if (this instanceof Receiver === false) { + throw new TypeError("Classes can't be function-called"); + } + if(typeof extensions==='number'){ + maxPayload=extensions; + extensions={}; + } + + + // memory pool for fragmented messages + var fragmentedPoolPrevUsed = -1; + this.fragmentedBufferPool = new BufferPool(1024, function(db, length) { + return db.used + length; + }, function(db) { + return fragmentedPoolPrevUsed = fragmentedPoolPrevUsed >= 0 ? + Math.ceil((fragmentedPoolPrevUsed + db.used) / 2) : + db.used; + }); + + // memory pool for unfragmented messages + var unfragmentedPoolPrevUsed = -1; + this.unfragmentedBufferPool = new BufferPool(1024, function(db, length) { + return db.used + length; + }, function(db) { + return unfragmentedPoolPrevUsed = unfragmentedPoolPrevUsed >= 0 ? + Math.ceil((unfragmentedPoolPrevUsed + db.used) / 2) : + db.used; + }); + this.extensions = extensions || {}; + this.maxPayload = maxPayload || 0; + this.currentPayloadLength = 0; + this.state = { + activeFragmentedOperation: null, + lastFragment: false, + masked: false, + opcode: 0, + fragmentedOperation: false + }; + this.overflow = []; + this.headerBuffer = new Buffer(10); + this.expectOffset = 0; + this.expectBuffer = null; + this.expectHandler = null; + this.currentMessage = []; + this.currentMessageLength = 0; + this.messageHandlers = []; + this.expectHeader(2, this.processPacket); + this.dead = false; + this.processing = false; + + this.onerror = function() {}; + this.ontext = function() {}; + this.onbinary = function() {}; + this.onclose = function() {}; + this.onping = function() {}; + this.onpong = function() {}; +} + +module.exports = Receiver; + +/** + * Add new data to the parser. + * + * @api public + */ + +Receiver.prototype.add = function(data) { + if (this.dead) return; + var dataLength = data.length; + if (dataLength == 0) return; + if (this.expectBuffer == null) { + this.overflow.push(data); + return; + } + var toRead = Math.min(dataLength, this.expectBuffer.length - this.expectOffset); + fastCopy(toRead, data, this.expectBuffer, this.expectOffset); + this.expectOffset += toRead; + if (toRead < dataLength) { + this.overflow.push(data.slice(toRead)); + } + while (this.expectBuffer && this.expectOffset == this.expectBuffer.length) { + var bufferForHandler = this.expectBuffer; + this.expectBuffer = null; + this.expectOffset = 0; + this.expectHandler.call(this, bufferForHandler); + } +}; + +/** + * Releases all resources used by the receiver. + * + * @api public + */ + +Receiver.prototype.cleanup = function() { + this.dead = true; + this.overflow = null; + this.headerBuffer = null; + this.expectBuffer = null; + this.expectHandler = null; + this.unfragmentedBufferPool = null; + this.fragmentedBufferPool = null; + this.state = null; + this.currentMessage = null; + this.onerror = null; + this.ontext = null; + this.onbinary = null; + this.onclose = null; + this.onping = null; + this.onpong = null; +}; + +/** + * Waits for a certain amount of header bytes to be available, then fires a callback. + * + * @api private + */ + +Receiver.prototype.expectHeader = function(length, handler) { + if (length == 0) { + handler(null); + return; + } + this.expectBuffer = this.headerBuffer.slice(this.expectOffset, this.expectOffset + length); + this.expectHandler = handler; + var toRead = length; + while (toRead > 0 && this.overflow.length > 0) { + var fromOverflow = this.overflow.pop(); + if (toRead < fromOverflow.length) this.overflow.push(fromOverflow.slice(toRead)); + var read = Math.min(fromOverflow.length, toRead); + fastCopy(read, fromOverflow, this.expectBuffer, this.expectOffset); + this.expectOffset += read; + toRead -= read; + } +}; + +/** + * Waits for a certain amount of data bytes to be available, then fires a callback. + * + * @api private + */ + +Receiver.prototype.expectData = function(length, handler) { + if (length == 0) { + handler(null); + return; + } + this.expectBuffer = this.allocateFromPool(length, this.state.fragmentedOperation); + this.expectHandler = handler; + var toRead = length; + while (toRead > 0 && this.overflow.length > 0) { + var fromOverflow = this.overflow.pop(); + if (toRead < fromOverflow.length) this.overflow.push(fromOverflow.slice(toRead)); + var read = Math.min(fromOverflow.length, toRead); + fastCopy(read, fromOverflow, this.expectBuffer, this.expectOffset); + this.expectOffset += read; + toRead -= read; + } +}; + +/** + * Allocates memory from the buffer pool. + * + * @api private + */ + +Receiver.prototype.allocateFromPool = function(length, isFragmented) { + return (isFragmented ? this.fragmentedBufferPool : this.unfragmentedBufferPool).get(length); +}; + +/** + * Start processing a new packet. + * + * @api private + */ + +Receiver.prototype.processPacket = function (data) { + if (this.extensions[PerMessageDeflate.extensionName]) { + if ((data[0] & 0x30) != 0) { + this.error('reserved fields (2, 3) must be empty', 1002); + return; + } + } else { + if ((data[0] & 0x70) != 0) { + this.error('reserved fields must be empty', 1002); + return; + } + } + this.state.lastFragment = (data[0] & 0x80) == 0x80; + this.state.masked = (data[1] & 0x80) == 0x80; + var compressed = (data[0] & 0x40) == 0x40; + var opcode = data[0] & 0xf; + if (opcode === 0) { + if (compressed) { + this.error('continuation frame cannot have the Per-message Compressed bits', 1002); + return; + } + // continuation frame + this.state.fragmentedOperation = true; + this.state.opcode = this.state.activeFragmentedOperation; + if (!(this.state.opcode == 1 || this.state.opcode == 2)) { + this.error('continuation frame cannot follow current opcode', 1002); + return; + } + } + else { + if (opcode < 3 && this.state.activeFragmentedOperation != null) { + this.error('data frames after the initial data frame must have opcode 0', 1002); + return; + } + if (opcode >= 8 && compressed) { + this.error('control frames cannot have the Per-message Compressed bits', 1002); + return; + } + this.state.compressed = compressed; + this.state.opcode = opcode; + if (this.state.lastFragment === false) { + this.state.fragmentedOperation = true; + this.state.activeFragmentedOperation = opcode; + } + else this.state.fragmentedOperation = false; + } + var handler = opcodes[this.state.opcode]; + if (typeof handler == 'undefined') this.error('no handler for opcode ' + this.state.opcode, 1002); + else { + handler.start.call(this, data); + } +}; + +/** + * Endprocessing a packet. + * + * @api private + */ + +Receiver.prototype.endPacket = function() { + if (this.dead) return; + if (!this.state.fragmentedOperation) this.unfragmentedBufferPool.reset(true); + else if (this.state.lastFragment) this.fragmentedBufferPool.reset(true); + this.expectOffset = 0; + this.expectBuffer = null; + this.expectHandler = null; + if (this.state.lastFragment && this.state.opcode === this.state.activeFragmentedOperation) { + // end current fragmented operation + this.state.activeFragmentedOperation = null; + } + this.currentPayloadLength = 0; + this.state.lastFragment = false; + this.state.opcode = this.state.activeFragmentedOperation != null ? this.state.activeFragmentedOperation : 0; + this.state.masked = false; + this.expectHeader(2, this.processPacket); +}; + +/** + * Reset the parser state. + * + * @api private + */ + +Receiver.prototype.reset = function() { + if (this.dead) return; + this.state = { + activeFragmentedOperation: null, + lastFragment: false, + masked: false, + opcode: 0, + fragmentedOperation: false + }; + this.fragmentedBufferPool.reset(true); + this.unfragmentedBufferPool.reset(true); + this.expectOffset = 0; + this.expectBuffer = null; + this.expectHandler = null; + this.overflow = []; + this.currentMessage = []; + this.currentMessageLength = 0; + this.messageHandlers = []; + this.currentPayloadLength = 0; +}; + +/** + * Unmask received data. + * + * @api private + */ + +Receiver.prototype.unmask = function (mask, buf, binary) { + if (mask != null && buf != null) bufferUtil.unmask(buf, mask); + if (binary) return buf; + return buf != null ? buf.toString('utf8') : ''; +}; + +/** + * Handles an error + * + * @api private + */ + +Receiver.prototype.error = function (reason, protocolErrorCode) { + if (this.dead) return; + this.reset(); + if(typeof reason == 'string'){ + this.onerror(new Error(reason), protocolErrorCode); + } + else if(reason.constructor == Error){ + this.onerror(reason, protocolErrorCode); + } + else{ + this.onerror(new Error("An error occured"),protocolErrorCode); + } + return this; +}; + +/** + * Execute message handler buffers + * + * @api private + */ + +Receiver.prototype.flush = function() { + if (this.processing || this.dead) return; + + var handler = this.messageHandlers.shift(); + if (!handler) return; + + this.processing = true; + var self = this; + + handler(function() { + self.processing = false; + self.flush(); + }); +}; + +/** + * Apply extensions to message + * + * @api private + */ + +Receiver.prototype.applyExtensions = function(messageBuffer, fin, compressed, callback) { + var self = this; + if (compressed) { + this.extensions[PerMessageDeflate.extensionName].decompress(messageBuffer, fin, function(err, buffer) { + if (self.dead) return; + if (err) { + callback(new Error('invalid compressed data')); + return; + } + callback(null, buffer); + }); + } else { + callback(null, messageBuffer); + } +}; + +/** +* Checks payload size, disconnects socket when it exceeds maxPayload +* +* @api private +*/ +Receiver.prototype.maxPayloadExceeded = function(length) { + if (this.maxPayload=== undefined || this.maxPayload === null || this.maxPayload < 1) { + return false; + } + var fullLength = this.currentPayloadLength + length; + if (fullLength < this.maxPayload) { + this.currentPayloadLength = fullLength; + return false; + } + this.error('payload cannot exceed ' + this.maxPayload + ' bytes', 1009); + this.messageBuffer=[]; + this.cleanup(); + + return true; +}; + +/** + * Buffer utilities + */ + +function readUInt16BE(start) { + return (this[start]<<8) + + this[start+1]; +} + +function readUInt32BE(start) { + return (this[start]<<24) + + (this[start+1]<<16) + + (this[start+2]<<8) + + this[start+3]; +} + +function fastCopy(length, srcBuffer, dstBuffer, dstOffset) { + switch (length) { + default: srcBuffer.copy(dstBuffer, dstOffset, 0, length); break; + case 16: dstBuffer[dstOffset+15] = srcBuffer[15]; + case 15: dstBuffer[dstOffset+14] = srcBuffer[14]; + case 14: dstBuffer[dstOffset+13] = srcBuffer[13]; + case 13: dstBuffer[dstOffset+12] = srcBuffer[12]; + case 12: dstBuffer[dstOffset+11] = srcBuffer[11]; + case 11: dstBuffer[dstOffset+10] = srcBuffer[10]; + case 10: dstBuffer[dstOffset+9] = srcBuffer[9]; + case 9: dstBuffer[dstOffset+8] = srcBuffer[8]; + case 8: dstBuffer[dstOffset+7] = srcBuffer[7]; + case 7: dstBuffer[dstOffset+6] = srcBuffer[6]; + case 6: dstBuffer[dstOffset+5] = srcBuffer[5]; + case 5: dstBuffer[dstOffset+4] = srcBuffer[4]; + case 4: dstBuffer[dstOffset+3] = srcBuffer[3]; + case 3: dstBuffer[dstOffset+2] = srcBuffer[2]; + case 2: dstBuffer[dstOffset+1] = srcBuffer[1]; + case 1: dstBuffer[dstOffset] = srcBuffer[0]; + } +} + +function clone(obj) { + var cloned = {}; + for (var k in obj) { + if (obj.hasOwnProperty(k)) { + cloned[k] = obj[k]; + } + } + return cloned; +} + +/** + * Opcode handlers + */ + +var opcodes = { + // text + '1': { + start: function(data) { + var self = this; + // decode length + var firstLength = data[1] & 0x7f; + if (firstLength < 126) { + if (self.maxPayloadExceeded(firstLength)){ + self.error('Maximumpayload exceeded in compressed text message. Aborting...', 1009); + return; + } + opcodes['1'].getData.call(self, firstLength); + } + else if (firstLength == 126) { + self.expectHeader(2, function(data) { + var length = readUInt16BE.call(data, 0); + if (self.maxPayloadExceeded(length)){ + self.error('Maximumpayload exceeded in compressed text message. Aborting...', 1009); + return; + } + opcodes['1'].getData.call(self, length); + }); + } + else if (firstLength == 127) { + self.expectHeader(8, function(data) { + if (readUInt32BE.call(data, 0) != 0) { + self.error('packets with length spanning more than 32 bit is currently not supported', 1008); + return; + } + var length = readUInt32BE.call(data, 4); + if (self.maxPayloadExceeded(length)){ + self.error('Maximumpayload exceeded in compressed text message. Aborting...', 1009); + return; + } + opcodes['1'].getData.call(self, readUInt32BE.call(data, 4)); + }); + } + }, + getData: function(length) { + var self = this; + if (self.state.masked) { + self.expectHeader(4, function(data) { + var mask = data; + self.expectData(length, function(data) { + opcodes['1'].finish.call(self, mask, data); + }); + }); + } + else { + self.expectData(length, function(data) { + opcodes['1'].finish.call(self, null, data); + }); + } + }, + finish: function(mask, data) { + var self = this; + var packet = this.unmask(mask, data, true) || new Buffer(0); + var state = clone(this.state); + this.messageHandlers.push(function(callback) { + self.applyExtensions(packet, state.lastFragment, state.compressed, function(err, buffer) { + if (err) { + if(err.type===1009){ + return self.error('Maximumpayload exceeded in compressed text message. Aborting...', 1009); + } + return self.error(err.message, 1007); + } + if (buffer != null) { + if( self.maxPayload==0 || (self.maxPayload > 0 && (self.currentMessageLength + buffer.length) < self.maxPayload) ){ + self.currentMessage.push(buffer); + } + else{ + self.currentMessage=null; + self.currentMessage = []; + self.currentMessageLength = 0; + self.error(new Error('Maximum payload exceeded. maxPayload: '+self.maxPayload), 1009); + return; + } + self.currentMessageLength += buffer.length; + } + if (state.lastFragment) { + var messageBuffer = Buffer.concat(self.currentMessage); + self.currentMessage = []; + self.currentMessageLength = 0; + if (!Validation.isValidUTF8(messageBuffer)) { + self.error('invalid utf8 sequence', 1007); + return; + } + self.ontext(messageBuffer.toString('utf8'), {masked: state.masked, buffer: messageBuffer}); + } + callback(); + }); + }); + this.flush(); + this.endPacket(); + } + }, + // binary + '2': { + start: function(data) { + var self = this; + // decode length + var firstLength = data[1] & 0x7f; + if (firstLength < 126) { + if (self.maxPayloadExceeded(firstLength)){ + self.error('Max payload exceeded in compressed text message. Aborting...', 1009); + return; + } + opcodes['2'].getData.call(self, firstLength); + } + else if (firstLength == 126) { + self.expectHeader(2, function(data) { + var length = readUInt16BE.call(data, 0); + if (self.maxPayloadExceeded(length)){ + self.error('Max payload exceeded in compressed text message. Aborting...', 1009); + return; + } + opcodes['2'].getData.call(self, length); + }); + } + else if (firstLength == 127) { + self.expectHeader(8, function(data) { + if (readUInt32BE.call(data, 0) != 0) { + self.error('packets with length spanning more than 32 bit is currently not supported', 1008); + return; + } + var length = readUInt32BE.call(data, 4, true); + if (self.maxPayloadExceeded(length)){ + self.error('Max payload exceeded in compressed text message. Aborting...', 1009); + return; + } + opcodes['2'].getData.call(self, length); + }); + } + }, + getData: function(length) { + var self = this; + if (self.state.masked) { + self.expectHeader(4, function(data) { + var mask = data; + self.expectData(length, function(data) { + opcodes['2'].finish.call(self, mask, data); + }); + }); + } + else { + self.expectData(length, function(data) { + opcodes['2'].finish.call(self, null, data); + }); + } + }, + finish: function(mask, data) { + var self = this; + var packet = this.unmask(mask, data, true) || new Buffer(0); + var state = clone(this.state); + this.messageHandlers.push(function(callback) { + self.applyExtensions(packet, state.lastFragment, state.compressed, function(err, buffer) { + if (err) { + if(err.type===1009){ + return self.error('Max payload exceeded in compressed binary message. Aborting...', 1009); + } + return self.error(err.message, 1007); + } + if (buffer != null) { + if( self.maxPayload==0 || (self.maxPayload > 0 && (self.currentMessageLength + buffer.length) < self.maxPayload) ){ + self.currentMessage.push(buffer); + } + else{ + self.currentMessage=null; + self.currentMessage = []; + self.currentMessageLength = 0; + self.error(new Error('Maximum payload exceeded'), 1009); + return; + } + self.currentMessageLength += buffer.length; + } + if (state.lastFragment) { + var messageBuffer = Buffer.concat(self.currentMessage); + self.currentMessage = []; + self.currentMessageLength = 0; + self.onbinary(messageBuffer, {masked: state.masked, buffer: messageBuffer}); + } + callback(); + }); + }); + this.flush(); + this.endPacket(); + } + }, + // close + '8': { + start: function(data) { + var self = this; + if (self.state.lastFragment == false) { + self.error('fragmented close is not supported', 1002); + return; + } + + // decode length + var firstLength = data[1] & 0x7f; + if (firstLength < 126) { + opcodes['8'].getData.call(self, firstLength); + } + else { + self.error('control frames cannot have more than 125 bytes of data', 1002); + } + }, + getData: function(length) { + var self = this; + if (self.state.masked) { + self.expectHeader(4, function(data) { + var mask = data; + self.expectData(length, function(data) { + opcodes['8'].finish.call(self, mask, data); + }); + }); + } + else { + self.expectData(length, function(data) { + opcodes['8'].finish.call(self, null, data); + }); + } + }, + finish: function(mask, data) { + var self = this; + data = self.unmask(mask, data, true); + + var state = clone(this.state); + this.messageHandlers.push(function() { + if (data && data.length == 1) { + self.error('close packets with data must be at least two bytes long', 1002); + return; + } + var code = data && data.length > 1 ? readUInt16BE.call(data, 0) : 1000; + if (!ErrorCodes.isValidErrorCode(code)) { + self.error('invalid error code', 1002); + return; + } + var message = ''; + if (data && data.length > 2) { + var messageBuffer = data.slice(2); + if (!Validation.isValidUTF8(messageBuffer)) { + self.error('invalid utf8 sequence', 1007); + return; + } + message = messageBuffer.toString('utf8'); + } + self.onclose(code, message, {masked: state.masked}); + self.reset(); + }); + this.flush(); + }, + }, + // ping + '9': { + start: function(data) { + var self = this; + if (self.state.lastFragment == false) { + self.error('fragmented ping is not supported', 1002); + return; + } + + // decode length + var firstLength = data[1] & 0x7f; + if (firstLength < 126) { + opcodes['9'].getData.call(self, firstLength); + } + else { + self.error('control frames cannot have more than 125 bytes of data', 1002); + } + }, + getData: function(length) { + var self = this; + if (self.state.masked) { + self.expectHeader(4, function(data) { + var mask = data; + self.expectData(length, function(data) { + opcodes['9'].finish.call(self, mask, data); + }); + }); + } + else { + self.expectData(length, function(data) { + opcodes['9'].finish.call(self, null, data); + }); + } + }, + finish: function(mask, data) { + var self = this; + data = this.unmask(mask, data, true); + var state = clone(this.state); + this.messageHandlers.push(function(callback) { + self.onping(data, {masked: state.masked, binary: true}); + callback(); + }); + this.flush(); + this.endPacket(); + } + }, + // pong + '10': { + start: function(data) { + var self = this; + if (self.state.lastFragment == false) { + self.error('fragmented pong is not supported', 1002); + return; + } + + // decode length + var firstLength = data[1] & 0x7f; + if (firstLength < 126) { + opcodes['10'].getData.call(self, firstLength); + } + else { + self.error('control frames cannot have more than 125 bytes of data', 1002); + } + }, + getData: function(length) { + var self = this; + if (this.state.masked) { + this.expectHeader(4, function(data) { + var mask = data; + self.expectData(length, function(data) { + opcodes['10'].finish.call(self, mask, data); + }); + }); + } + else { + this.expectData(length, function(data) { + opcodes['10'].finish.call(self, null, data); + }); + } + }, + finish: function(mask, data) { + var self = this; + data = self.unmask(mask, data, true); + var state = clone(this.state); + this.messageHandlers.push(function(callback) { + self.onpong(data, {masked: state.masked, binary: true}); + callback(); + }); + this.flush(); + this.endPacket(); + } + } +} diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/Sender.hixie.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/Sender.hixie.js index e313d568..b87d9dd9 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/Sender.hixie.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/Sender.hixie.js @@ -1,124 +1,124 @@ -/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - -var events = require('events') - , util = require('util') - , EventEmitter = events.EventEmitter; - -/** - * Hixie Sender implementation - */ - -function Sender(socket) { - if (this instanceof Sender === false) { - throw new TypeError("Classes can't be function-called"); - } - - events.EventEmitter.call(this); - - this.socket = socket; - this.continuationFrame = false; - this.isClosed = false; -} - -module.exports = Sender; - -/** - * Inherits from EventEmitter. - */ - -util.inherits(Sender, events.EventEmitter); - -/** - * Frames and writes data. - * - * @api public - */ - -Sender.prototype.send = function(data, options, cb) { - if (this.isClosed) return; - - var isString = typeof data == 'string' - , length = isString ? Buffer.byteLength(data) : data.length - , lengthbytes = (length > 127) ? 2 : 1 // assume less than 2**14 bytes - , writeStartMarker = this.continuationFrame == false - , writeEndMarker = !options || !(typeof options.fin != 'undefined' && !options.fin) - , buffer = new Buffer((writeStartMarker ? ((options && options.binary) ? (1 + lengthbytes) : 1) : 0) + length + ((writeEndMarker && !(options && options.binary)) ? 1 : 0)) - , offset = writeStartMarker ? 1 : 0; - - if (writeStartMarker) { - if (options && options.binary) { - buffer.write('\x80', 'binary'); - // assume length less than 2**14 bytes - if (lengthbytes > 1) - buffer.write(String.fromCharCode(128+length/128), offset++, 'binary'); - buffer.write(String.fromCharCode(length&0x7f), offset++, 'binary'); - } else - buffer.write('\x00', 'binary'); - } - - if (isString) buffer.write(data, offset, 'utf8'); - else data.copy(buffer, offset, 0); - - if (writeEndMarker) { - if (options && options.binary) { - // sending binary, not writing end marker - } else - buffer.write('\xff', offset + length, 'binary'); - this.continuationFrame = false; - } - else this.continuationFrame = true; - - try { - this.socket.write(buffer, 'binary', cb); - } catch (e) { - this.error(e.toString()); - } -}; - -/** - * Sends a close instruction to the remote party. - * - * @api public - */ - -Sender.prototype.close = function(code, data, mask, cb) { - if (this.isClosed) return; - this.isClosed = true; - try { - if (this.continuationFrame) this.socket.write(new Buffer([0xff], 'binary')); - this.socket.write(new Buffer([0xff, 0x00]), 'binary', cb); - } catch (e) { - this.error(e.toString()); - } -}; - -/** - * Sends a ping message to the remote party. Not available for hixie. - * - * @api public - */ - -Sender.prototype.ping = function(data, options) {}; - -/** - * Sends a pong message to the remote party. Not available for hixie. - * - * @api public - */ - -Sender.prototype.pong = function(data, options) {}; - -/** - * Handles an error - * - * @api private - */ - -Sender.prototype.error = function (reason) { - this.emit('error', reason); - return this; -}; +/*! + * ws: a node.js websocket client + * Copyright(c) 2011 Einar Otto Stangvik + * MIT Licensed + */ + +var events = require('events') + , util = require('util') + , EventEmitter = events.EventEmitter; + +/** + * Hixie Sender implementation + */ + +function Sender(socket) { + if (this instanceof Sender === false) { + throw new TypeError("Classes can't be function-called"); + } + + events.EventEmitter.call(this); + + this.socket = socket; + this.continuationFrame = false; + this.isClosed = false; +} + +module.exports = Sender; + +/** + * Inherits from EventEmitter. + */ + +util.inherits(Sender, events.EventEmitter); + +/** + * Frames and writes data. + * + * @api public + */ + +Sender.prototype.send = function(data, options, cb) { + if (this.isClosed) return; + + var isString = typeof data == 'string' + , length = isString ? Buffer.byteLength(data) : data.length + , lengthbytes = (length > 127) ? 2 : 1 // assume less than 2**14 bytes + , writeStartMarker = this.continuationFrame == false + , writeEndMarker = !options || !(typeof options.fin != 'undefined' && !options.fin) + , buffer = new Buffer((writeStartMarker ? ((options && options.binary) ? (1 + lengthbytes) : 1) : 0) + length + ((writeEndMarker && !(options && options.binary)) ? 1 : 0)) + , offset = writeStartMarker ? 1 : 0; + + if (writeStartMarker) { + if (options && options.binary) { + buffer.write('\x80', 'binary'); + // assume length less than 2**14 bytes + if (lengthbytes > 1) + buffer.write(String.fromCharCode(128+length/128), offset++, 'binary'); + buffer.write(String.fromCharCode(length&0x7f), offset++, 'binary'); + } else + buffer.write('\x00', 'binary'); + } + + if (isString) buffer.write(data, offset, 'utf8'); + else data.copy(buffer, offset, 0); + + if (writeEndMarker) { + if (options && options.binary) { + // sending binary, not writing end marker + } else + buffer.write('\xff', offset + length, 'binary'); + this.continuationFrame = false; + } + else this.continuationFrame = true; + + try { + this.socket.write(buffer, 'binary', cb); + } catch (e) { + this.error(e.toString()); + } +}; + +/** + * Sends a close instruction to the remote party. + * + * @api public + */ + +Sender.prototype.close = function(code, data, mask, cb) { + if (this.isClosed) return; + this.isClosed = true; + try { + if (this.continuationFrame) this.socket.write(new Buffer([0xff], 'binary')); + this.socket.write(new Buffer([0xff, 0x00]), 'binary', cb); + } catch (e) { + this.error(e.toString()); + } +}; + +/** + * Sends a ping message to the remote party. Not available for hixie. + * + * @api public + */ + +Sender.prototype.ping = function(data, options) {}; + +/** + * Sends a pong message to the remote party. Not available for hixie. + * + * @api public + */ + +Sender.prototype.pong = function(data, options) {}; + +/** + * Handles an error + * + * @api private + */ + +Sender.prototype.error = function (reason) { + this.emit('error', reason); + return this; +}; diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/Sender.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/Sender.js index 36e59e5e..6ef2ea27 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/Sender.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/Sender.js @@ -1,324 +1,324 @@ -/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - -var events = require('events') - , util = require('util') - , EventEmitter = events.EventEmitter - , ErrorCodes = require('./ErrorCodes') - , bufferUtil = require('./BufferUtil').BufferUtil - , PerMessageDeflate = require('./PerMessageDeflate'); - -/** - * HyBi Sender implementation - */ - -function Sender(socket, extensions) { - if (this instanceof Sender === false) { - throw new TypeError("Classes can't be function-called"); - } - - events.EventEmitter.call(this); - - this._socket = socket; - this.extensions = extensions || {}; - this.firstFragment = true; - this.compress = false; - this.messageHandlers = []; - this.processing = false; -} - -/** - * Inherits from EventEmitter. - */ - -util.inherits(Sender, events.EventEmitter); - -/** - * Sends a close instruction to the remote party. - * - * @api public - */ - -Sender.prototype.close = function(code, data, mask, cb) { - if (typeof code !== 'undefined') { - if (typeof code !== 'number' || - !ErrorCodes.isValidErrorCode(code)) throw new Error('first argument must be a valid error code number'); - } - code = code || 1000; - var dataBuffer = new Buffer(2 + (data ? Buffer.byteLength(data) : 0)); - writeUInt16BE.call(dataBuffer, code, 0); - if (dataBuffer.length > 2) dataBuffer.write(data, 2); - - var self = this; - this.messageHandlers.push(function(callback) { - self.frameAndSend(0x8, dataBuffer, true, mask); - callback(); - if (typeof cb == 'function') cb(); - }); - this.flush(); -}; - -/** - * Sends a ping message to the remote party. - * - * @api public - */ - -Sender.prototype.ping = function(data, options) { - var mask = options && options.mask; - var self = this; - this.messageHandlers.push(function(callback) { - self.frameAndSend(0x9, data || '', true, mask); - callback(); - }); - this.flush(); -}; - -/** - * Sends a pong message to the remote party. - * - * @api public - */ - -Sender.prototype.pong = function(data, options) { - var mask = options && options.mask; - var self = this; - this.messageHandlers.push(function(callback) { - self.frameAndSend(0xa, data || '', true, mask); - callback(); - }); - this.flush(); -}; - -/** - * Sends text or binary data to the remote party. - * - * @api public - */ - -Sender.prototype.send = function(data, options, cb) { - var finalFragment = options && options.fin === false ? false : true; - var mask = options && options.mask; - var compress = options && options.compress; - var opcode = options && options.binary ? 2 : 1; - if (this.firstFragment === false) { - opcode = 0; - compress = false; - } else { - this.firstFragment = false; - this.compress = compress; - } - if (finalFragment) this.firstFragment = true - - var compressFragment = this.compress; - - var self = this; - this.messageHandlers.push(function(callback) { - self.applyExtensions(data, finalFragment, compressFragment, function(err, data) { - if (err) { - if (typeof cb == 'function') cb(err); - else self.emit('error', err); - return; - } - self.frameAndSend(opcode, data, finalFragment, mask, compress, cb); - callback(); - }); - }); - this.flush(); -}; - -/** - * Frames and sends a piece of data according to the HyBi WebSocket protocol. - * - * @api private - */ - -Sender.prototype.frameAndSend = function(opcode, data, finalFragment, maskData, compressed, cb) { - var canModifyData = false; - - if (!data) { - try { - this._socket.write(new Buffer([opcode | (finalFragment ? 0x80 : 0), 0 | (maskData ? 0x80 : 0)].concat(maskData ? [0, 0, 0, 0] : [])), 'binary', cb); - } - catch (e) { - if (typeof cb == 'function') cb(e); - else this.emit('error', e); - } - return; - } - - if (!Buffer.isBuffer(data)) { - canModifyData = true; - if (data && (typeof data.byteLength !== 'undefined' || typeof data.buffer !== 'undefined')) { - data = getArrayBuffer(data); - } else { - // - // If people want to send a number, this would allocate the number in - // bytes as memory size instead of storing the number as buffer value. So - // we need to transform it to string in order to prevent possible - // vulnerabilities / memory attacks. - // - if (typeof data === 'number') data = data.toString(); - - data = new Buffer(data); - } - } - - var dataLength = data.length - , dataOffset = maskData ? 6 : 2 - , secondByte = dataLength; - - if (dataLength >= 65536) { - dataOffset += 8; - secondByte = 127; - } - else if (dataLength > 125) { - dataOffset += 2; - secondByte = 126; - } - - var mergeBuffers = dataLength < 32768 || (maskData && !canModifyData); - var totalLength = mergeBuffers ? dataLength + dataOffset : dataOffset; - var outputBuffer = new Buffer(totalLength); - outputBuffer[0] = finalFragment ? opcode | 0x80 : opcode; - if (compressed) outputBuffer[0] |= 0x40; - - switch (secondByte) { - case 126: - writeUInt16BE.call(outputBuffer, dataLength, 2); - break; - case 127: - writeUInt32BE.call(outputBuffer, 0, 2); - writeUInt32BE.call(outputBuffer, dataLength, 6); - } - - if (maskData) { - outputBuffer[1] = secondByte | 0x80; - var mask = getRandomMask(); - outputBuffer[dataOffset - 4] = mask[0]; - outputBuffer[dataOffset - 3] = mask[1]; - outputBuffer[dataOffset - 2] = mask[2]; - outputBuffer[dataOffset - 1] = mask[3]; - if (mergeBuffers) { - bufferUtil.mask(data, mask, outputBuffer, dataOffset, dataLength); - try { - this._socket.write(outputBuffer, 'binary', cb); - } - catch (e) { - if (typeof cb == 'function') cb(e); - else this.emit('error', e); - } - } - else { - bufferUtil.mask(data, mask, data, 0, dataLength); - try { - this._socket.write(outputBuffer, 'binary'); - this._socket.write(data, 'binary', cb); - } - catch (e) { - if (typeof cb == 'function') cb(e); - else this.emit('error', e); - } - } - } - else { - outputBuffer[1] = secondByte; - if (mergeBuffers) { - data.copy(outputBuffer, dataOffset); - try { - this._socket.write(outputBuffer, 'binary', cb); - } - catch (e) { - if (typeof cb == 'function') cb(e); - else this.emit('error', e); - } - } - else { - try { - this._socket.write(outputBuffer, 'binary'); - this._socket.write(data, 'binary', cb); - } - catch (e) { - if (typeof cb == 'function') cb(e); - else this.emit('error', e); - } - } - } -}; - -/** - * Execute message handler buffers - * - * @api private - */ - -Sender.prototype.flush = function() { - if (this.processing) return; - - var handler = this.messageHandlers.shift(); - if (!handler) return; - - this.processing = true; - - var self = this; - - handler(function() { - self.processing = false; - self.flush(); - }); -}; - -/** - * Apply extensions to message - * - * @api private - */ - -Sender.prototype.applyExtensions = function(data, fin, compress, callback) { - if (compress && data) { - if ((data.buffer || data) instanceof ArrayBuffer) { - data = getArrayBuffer(data); - } - this.extensions[PerMessageDeflate.extensionName].compress(data, fin, callback); - } else { - callback(null, data); - } -}; - -module.exports = Sender; - -function writeUInt16BE(value, offset) { - this[offset] = (value & 0xff00)>>8; - this[offset+1] = value & 0xff; -} - -function writeUInt32BE(value, offset) { - this[offset] = (value & 0xff000000)>>24; - this[offset+1] = (value & 0xff0000)>>16; - this[offset+2] = (value & 0xff00)>>8; - this[offset+3] = value & 0xff; -} - -function getArrayBuffer(data) { - // data is either an ArrayBuffer or ArrayBufferView. - var array = new Uint8Array(data.buffer || data) - , l = data.byteLength || data.length - , o = data.byteOffset || 0 - , buffer = new Buffer(l); - for (var i = 0; i < l; ++i) { - buffer[i] = array[o+i]; - } - return buffer; -} - -function getRandomMask() { - return new Buffer([ - ~~(Math.random() * 255), - ~~(Math.random() * 255), - ~~(Math.random() * 255), - ~~(Math.random() * 255) - ]); -} +/*! + * ws: a node.js websocket client + * Copyright(c) 2011 Einar Otto Stangvik + * MIT Licensed + */ + +var events = require('events') + , util = require('util') + , EventEmitter = events.EventEmitter + , ErrorCodes = require('./ErrorCodes') + , bufferUtil = require('./BufferUtil').BufferUtil + , PerMessageDeflate = require('./PerMessageDeflate'); + +/** + * HyBi Sender implementation + */ + +function Sender(socket, extensions) { + if (this instanceof Sender === false) { + throw new TypeError("Classes can't be function-called"); + } + + events.EventEmitter.call(this); + + this._socket = socket; + this.extensions = extensions || {}; + this.firstFragment = true; + this.compress = false; + this.messageHandlers = []; + this.processing = false; +} + +/** + * Inherits from EventEmitter. + */ + +util.inherits(Sender, events.EventEmitter); + +/** + * Sends a close instruction to the remote party. + * + * @api public + */ + +Sender.prototype.close = function(code, data, mask, cb) { + if (typeof code !== 'undefined') { + if (typeof code !== 'number' || + !ErrorCodes.isValidErrorCode(code)) throw new Error('first argument must be a valid error code number'); + } + code = code || 1000; + var dataBuffer = new Buffer(2 + (data ? Buffer.byteLength(data) : 0)); + writeUInt16BE.call(dataBuffer, code, 0); + if (dataBuffer.length > 2) dataBuffer.write(data, 2); + + var self = this; + this.messageHandlers.push(function(callback) { + self.frameAndSend(0x8, dataBuffer, true, mask); + callback(); + if (typeof cb == 'function') cb(); + }); + this.flush(); +}; + +/** + * Sends a ping message to the remote party. + * + * @api public + */ + +Sender.prototype.ping = function(data, options) { + var mask = options && options.mask; + var self = this; + this.messageHandlers.push(function(callback) { + self.frameAndSend(0x9, data || '', true, mask); + callback(); + }); + this.flush(); +}; + +/** + * Sends a pong message to the remote party. + * + * @api public + */ + +Sender.prototype.pong = function(data, options) { + var mask = options && options.mask; + var self = this; + this.messageHandlers.push(function(callback) { + self.frameAndSend(0xa, data || '', true, mask); + callback(); + }); + this.flush(); +}; + +/** + * Sends text or binary data to the remote party. + * + * @api public + */ + +Sender.prototype.send = function(data, options, cb) { + var finalFragment = options && options.fin === false ? false : true; + var mask = options && options.mask; + var compress = options && options.compress; + var opcode = options && options.binary ? 2 : 1; + if (this.firstFragment === false) { + opcode = 0; + compress = false; + } else { + this.firstFragment = false; + this.compress = compress; + } + if (finalFragment) this.firstFragment = true + + var compressFragment = this.compress; + + var self = this; + this.messageHandlers.push(function(callback) { + self.applyExtensions(data, finalFragment, compressFragment, function(err, data) { + if (err) { + if (typeof cb == 'function') cb(err); + else self.emit('error', err); + return; + } + self.frameAndSend(opcode, data, finalFragment, mask, compress, cb); + callback(); + }); + }); + this.flush(); +}; + +/** + * Frames and sends a piece of data according to the HyBi WebSocket protocol. + * + * @api private + */ + +Sender.prototype.frameAndSend = function(opcode, data, finalFragment, maskData, compressed, cb) { + var canModifyData = false; + + if (!data) { + try { + this._socket.write(new Buffer([opcode | (finalFragment ? 0x80 : 0), 0 | (maskData ? 0x80 : 0)].concat(maskData ? [0, 0, 0, 0] : [])), 'binary', cb); + } + catch (e) { + if (typeof cb == 'function') cb(e); + else this.emit('error', e); + } + return; + } + + if (!Buffer.isBuffer(data)) { + canModifyData = true; + if (data && (typeof data.byteLength !== 'undefined' || typeof data.buffer !== 'undefined')) { + data = getArrayBuffer(data); + } else { + // + // If people want to send a number, this would allocate the number in + // bytes as memory size instead of storing the number as buffer value. So + // we need to transform it to string in order to prevent possible + // vulnerabilities / memory attacks. + // + if (typeof data === 'number') data = data.toString(); + + data = new Buffer(data); + } + } + + var dataLength = data.length + , dataOffset = maskData ? 6 : 2 + , secondByte = dataLength; + + if (dataLength >= 65536) { + dataOffset += 8; + secondByte = 127; + } + else if (dataLength > 125) { + dataOffset += 2; + secondByte = 126; + } + + var mergeBuffers = dataLength < 32768 || (maskData && !canModifyData); + var totalLength = mergeBuffers ? dataLength + dataOffset : dataOffset; + var outputBuffer = new Buffer(totalLength); + outputBuffer[0] = finalFragment ? opcode | 0x80 : opcode; + if (compressed) outputBuffer[0] |= 0x40; + + switch (secondByte) { + case 126: + writeUInt16BE.call(outputBuffer, dataLength, 2); + break; + case 127: + writeUInt32BE.call(outputBuffer, 0, 2); + writeUInt32BE.call(outputBuffer, dataLength, 6); + } + + if (maskData) { + outputBuffer[1] = secondByte | 0x80; + var mask = getRandomMask(); + outputBuffer[dataOffset - 4] = mask[0]; + outputBuffer[dataOffset - 3] = mask[1]; + outputBuffer[dataOffset - 2] = mask[2]; + outputBuffer[dataOffset - 1] = mask[3]; + if (mergeBuffers) { + bufferUtil.mask(data, mask, outputBuffer, dataOffset, dataLength); + try { + this._socket.write(outputBuffer, 'binary', cb); + } + catch (e) { + if (typeof cb == 'function') cb(e); + else this.emit('error', e); + } + } + else { + bufferUtil.mask(data, mask, data, 0, dataLength); + try { + this._socket.write(outputBuffer, 'binary'); + this._socket.write(data, 'binary', cb); + } + catch (e) { + if (typeof cb == 'function') cb(e); + else this.emit('error', e); + } + } + } + else { + outputBuffer[1] = secondByte; + if (mergeBuffers) { + data.copy(outputBuffer, dataOffset); + try { + this._socket.write(outputBuffer, 'binary', cb); + } + catch (e) { + if (typeof cb == 'function') cb(e); + else this.emit('error', e); + } + } + else { + try { + this._socket.write(outputBuffer, 'binary'); + this._socket.write(data, 'binary', cb); + } + catch (e) { + if (typeof cb == 'function') cb(e); + else this.emit('error', e); + } + } + } +}; + +/** + * Execute message handler buffers + * + * @api private + */ + +Sender.prototype.flush = function() { + if (this.processing) return; + + var handler = this.messageHandlers.shift(); + if (!handler) return; + + this.processing = true; + + var self = this; + + handler(function() { + self.processing = false; + self.flush(); + }); +}; + +/** + * Apply extensions to message + * + * @api private + */ + +Sender.prototype.applyExtensions = function(data, fin, compress, callback) { + if (compress && data) { + if ((data.buffer || data) instanceof ArrayBuffer) { + data = getArrayBuffer(data); + } + this.extensions[PerMessageDeflate.extensionName].compress(data, fin, callback); + } else { + callback(null, data); + } +}; + +module.exports = Sender; + +function writeUInt16BE(value, offset) { + this[offset] = (value & 0xff00)>>8; + this[offset+1] = value & 0xff; +} + +function writeUInt32BE(value, offset) { + this[offset] = (value & 0xff000000)>>24; + this[offset+1] = (value & 0xff0000)>>16; + this[offset+2] = (value & 0xff00)>>8; + this[offset+3] = value & 0xff; +} + +function getArrayBuffer(data) { + // data is either an ArrayBuffer or ArrayBufferView. + var array = new Uint8Array(data.buffer || data) + , l = data.byteLength || data.length + , o = data.byteOffset || 0 + , buffer = new Buffer(l); + for (var i = 0; i < l; ++i) { + buffer[i] = array[o+i]; + } + return buffer; +} + +function getRandomMask() { + return new Buffer([ + ~~(Math.random() * 255), + ~~(Math.random() * 255), + ~~(Math.random() * 255), + ~~(Math.random() * 255) + ]); +} diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/Validation.fallback.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/Validation.fallback.js index eae02542..639b0d31 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/Validation.fallback.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/Validation.fallback.js @@ -1,11 +1,11 @@ -/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - -exports.Validation = { - isValidUTF8: function(buffer) { - return true; - } -}; +/*! + * ws: a node.js websocket client + * Copyright(c) 2011 Einar Otto Stangvik + * MIT Licensed + */ + +exports.Validation = { + isValidUTF8: function(buffer) { + return true; + } +}; diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/Validation.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/Validation.js index f8dc0603..0795fb7f 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/Validation.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/Validation.js @@ -1,13 +1,13 @@ -'use strict'; - -/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - -try { - module.exports = require('utf-8-validate'); -} catch (e) { - module.exports = require('./Validation.fallback'); -} +'use strict'; + +/*! + * ws: a node.js websocket client + * Copyright(c) 2011 Einar Otto Stangvik + * MIT Licensed + */ + +try { + module.exports = require('utf-8-validate'); +} catch (e) { + module.exports = require('./Validation.fallback'); +} diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/WebSocket.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/WebSocket.js index 3285f69a..bb09e851 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/WebSocket.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/WebSocket.js @@ -1,987 +1,987 @@ -'use strict'; - -/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - -var url = require('url') - , util = require('util') - , http = require('http') - , https = require('https') - , crypto = require('crypto') - , stream = require('stream') - , Ultron = require('ultron') - , Options = require('options') - , Sender = require('./Sender') - , Receiver = require('./Receiver') - , SenderHixie = require('./Sender.hixie') - , ReceiverHixie = require('./Receiver.hixie') - , Extensions = require('./Extensions') - , PerMessageDeflate = require('./PerMessageDeflate') - , EventEmitter = require('events').EventEmitter; - -/** - * Constants - */ - -// Default protocol version - -var protocolVersion = 13; - -// Close timeout - -var closeTimeout = 30 * 1000; // Allow 30 seconds to terminate the connection cleanly - -/** - * WebSocket implementation - * - * @constructor - * @param {String} address Connection address. - * @param {String|Array} protocols WebSocket protocols. - * @param {Object} options Additional connection options. - * @api public - */ -function WebSocket(address, protocols, options) { - if (this instanceof WebSocket === false) { - return new WebSocket(address, protocols, options); - } - - EventEmitter.call(this); - - if (protocols && !Array.isArray(protocols) && 'object' === typeof protocols) { - // accept the "options" Object as the 2nd argument - options = protocols; - protocols = null; - } - - if ('string' === typeof protocols) { - protocols = [ protocols ]; - } - - if (!Array.isArray(protocols)) { - protocols = []; - } - - this._socket = null; - this._ultron = null; - this._closeReceived = false; - this.bytesReceived = 0; - this.readyState = null; - this.supports = {}; - this.extensions = {}; - this._binaryType = 'nodebuffer'; - - if (Array.isArray(address)) { - initAsServerClient.apply(this, address.concat(options)); - } else { - initAsClient.apply(this, [address, protocols, options]); - } -} - -/** - * Inherits from EventEmitter. - */ -util.inherits(WebSocket, EventEmitter); - -/** - * Ready States - */ -["CONNECTING", "OPEN", "CLOSING", "CLOSED"].forEach(function each(state, index) { - WebSocket.prototype[state] = WebSocket[state] = index; -}); - -/** - * Gracefully closes the connection, after sending a description message to the server - * - * @param {Object} data to be sent to the server - * @api public - */ -WebSocket.prototype.close = function close(code, data) { - if (this.readyState === WebSocket.CLOSED) return; - - if (this.readyState === WebSocket.CONNECTING) { - this.readyState = WebSocket.CLOSED; - return; - } - - if (this.readyState === WebSocket.CLOSING) { - if (this._closeReceived && this._isServer) { - this.terminate(); - } - return; - } - - var self = this; - try { - this.readyState = WebSocket.CLOSING; - this._closeCode = code; - this._closeMessage = data; - var mask = !this._isServer; - this._sender.close(code, data, mask, function(err) { - if (err) self.emit('error', err); - - if (self._closeReceived && self._isServer) { - self.terminate(); - } else { - // ensure that the connection is cleaned up even when no response of closing handshake. - clearTimeout(self._closeTimer); - self._closeTimer = setTimeout(cleanupWebsocketResources.bind(self, true), closeTimeout); - } - }); - } catch (e) { - this.emit('error', e); - } -}; - -/** - * Pause the client stream - * - * @api public - */ -WebSocket.prototype.pause = function pauser() { - if (this.readyState !== WebSocket.OPEN) throw new Error('not opened'); - - return this._socket.pause(); -}; - -/** - * Sends a ping - * - * @param {Object} data to be sent to the server - * @param {Object} Members - mask: boolean, binary: boolean - * @param {boolean} dontFailWhenClosed indicates whether or not to throw if the connection isnt open - * @api public - */ -WebSocket.prototype.ping = function ping(data, options, dontFailWhenClosed) { - if (this.readyState !== WebSocket.OPEN) { - if (dontFailWhenClosed === true) return; - throw new Error('not opened'); - } - - options = options || {}; - - if (typeof options.mask === 'undefined') options.mask = !this._isServer; - - this._sender.ping(data, options); -}; - -/** - * Sends a pong - * - * @param {Object} data to be sent to the server - * @param {Object} Members - mask: boolean, binary: boolean - * @param {boolean} dontFailWhenClosed indicates whether or not to throw if the connection isnt open - * @api public - */ -WebSocket.prototype.pong = function(data, options, dontFailWhenClosed) { - if (this.readyState !== WebSocket.OPEN) { - if (dontFailWhenClosed === true) return; - throw new Error('not opened'); - } - - options = options || {}; - - if (typeof options.mask === 'undefined') options.mask = !this._isServer; - - this._sender.pong(data, options); -}; - -/** - * Resume the client stream - * - * @api public - */ -WebSocket.prototype.resume = function resume() { - if (this.readyState !== WebSocket.OPEN) throw new Error('not opened'); - - return this._socket.resume(); -}; - -/** - * Sends a piece of data - * - * @param {Object} data to be sent to the server - * @param {Object} Members - mask: boolean, binary: boolean, compress: boolean - * @param {function} Optional callback which is executed after the send completes - * @api public - */ - -WebSocket.prototype.send = function send(data, options, cb) { - if (typeof options === 'function') { - cb = options; - options = {}; - } - - if (this.readyState !== WebSocket.OPEN) { - if (typeof cb === 'function') cb(new Error('not opened')); - else throw new Error('not opened'); - return; - } - - if (!data) data = ''; - if (this._queue) { - var self = this; - this._queue.push(function() { self.send(data, options, cb); }); - return; - } - - options = options || {}; - options.fin = true; - - if (typeof options.binary === 'undefined') { - options.binary = (data instanceof ArrayBuffer || data instanceof Buffer || - data instanceof Uint8Array || - data instanceof Uint16Array || - data instanceof Uint32Array || - data instanceof Int8Array || - data instanceof Int16Array || - data instanceof Int32Array || - data instanceof Float32Array || - data instanceof Float64Array); - } - - if (typeof options.mask === 'undefined') options.mask = !this._isServer; - if (typeof options.compress === 'undefined') options.compress = true; - if (!this.extensions[PerMessageDeflate.extensionName]) { - options.compress = false; - } - - var readable = typeof stream.Readable === 'function' - ? stream.Readable - : stream.Stream; - - if (data instanceof readable) { - startQueue(this); - var self = this; - - sendStream(this, data, options, function send(error) { - process.nextTick(function tock() { - executeQueueSends(self); - }); - - if (typeof cb === 'function') cb(error); - }); - } else { - this._sender.send(data, options, cb); - } -}; - -/** - * Streams data through calls to a user supplied function - * - * @param {Object} Members - mask: boolean, binary: boolean, compress: boolean - * @param {function} 'function (error, send)' which is executed on successive ticks of which send is 'function (data, final)'. - * @api public - */ -WebSocket.prototype.stream = function stream(options, cb) { - if (typeof options === 'function') { - cb = options; - options = {}; - } - - var self = this; - - if (typeof cb !== 'function') throw new Error('callback must be provided'); - - if (this.readyState !== WebSocket.OPEN) { - if (typeof cb === 'function') cb(new Error('not opened')); - else throw new Error('not opened'); - return; - } - - if (this._queue) { - this._queue.push(function () { self.stream(options, cb); }); - return; - } - - options = options || {}; - - if (typeof options.mask === 'undefined') options.mask = !this._isServer; - if (typeof options.compress === 'undefined') options.compress = true; - if (!this.extensions[PerMessageDeflate.extensionName]) { - options.compress = false; - } - - startQueue(this); - - function send(data, final) { - try { - if (self.readyState !== WebSocket.OPEN) throw new Error('not opened'); - options.fin = final === true; - self._sender.send(data, options); - if (!final) process.nextTick(cb.bind(null, null, send)); - else executeQueueSends(self); - } catch (e) { - if (typeof cb === 'function') cb(e); - else { - delete self._queue; - self.emit('error', e); - } - } - } - - process.nextTick(cb.bind(null, null, send)); -}; - -/** - * Immediately shuts down the connection - * - * @api public - */ -WebSocket.prototype.terminate = function terminate() { - if (this.readyState === WebSocket.CLOSED) return; - - if (this._socket) { - this.readyState = WebSocket.CLOSING; - - // End the connection - try { this._socket.end(); } - catch (e) { - // Socket error during end() call, so just destroy it right now - cleanupWebsocketResources.call(this, true); - return; - } - - // Add a timeout to ensure that the connection is completely - // cleaned up within 30 seconds, even if the clean close procedure - // fails for whatever reason - // First cleanup any pre-existing timeout from an earlier "terminate" call, - // if one exists. Otherwise terminate calls in quick succession will leak timeouts - // and hold the program open for `closeTimout` time. - if (this._closeTimer) { clearTimeout(this._closeTimer); } - this._closeTimer = setTimeout(cleanupWebsocketResources.bind(this, true), closeTimeout); - } else if (this.readyState === WebSocket.CONNECTING) { - cleanupWebsocketResources.call(this, true); - } -}; - -/** - * Expose bufferedAmount - * - * @api public - */ -Object.defineProperty(WebSocket.prototype, 'bufferedAmount', { - get: function get() { - var amount = 0; - if (this._socket) { - amount = this._socket.bufferSize || 0; - } - return amount; - } -}); - -/** - * Expose binaryType - * - * This deviates from the W3C interface since ws doesn't support the required - * default "blob" type (instead we define a custom "nodebuffer" type). - * - * @see http://dev.w3.org/html5/websockets/#the-websocket-interface - * @api public - */ -Object.defineProperty(WebSocket.prototype, 'binaryType', { - get: function get() { - return this._binaryType; - }, - set: function set(type) { - if (type === 'arraybuffer' || type === 'nodebuffer') - this._binaryType = type; - else - throw new SyntaxError('unsupported binaryType: must be either "nodebuffer" or "arraybuffer"'); - } -}); - -/** - * Emulates the W3C Browser based WebSocket interface using function members. - * - * @see http://dev.w3.org/html5/websockets/#the-websocket-interface - * @api public - */ -['open', 'error', 'close', 'message'].forEach(function(method) { - Object.defineProperty(WebSocket.prototype, 'on' + method, { - /** - * Returns the current listener - * - * @returns {Mixed} the set function or undefined - * @api public - */ - get: function get() { - var listener = this.listeners(method)[0]; - return listener ? (listener._listener ? listener._listener : listener) : undefined; - }, - - /** - * Start listening for events - * - * @param {Function} listener the listener - * @returns {Mixed} the set function or undefined - * @api public - */ - set: function set(listener) { - this.removeAllListeners(method); - this.addEventListener(method, listener); - } - }); -}); - -/** - * Emulates the W3C Browser based WebSocket interface using addEventListener. - * - * @see https://developer.mozilla.org/en/DOM/element.addEventListener - * @see http://dev.w3.org/html5/websockets/#the-websocket-interface - * @api public - */ -WebSocket.prototype.addEventListener = function(method, listener) { - var target = this; - - function onMessage (data, flags) { - if (flags.binary && this.binaryType === 'arraybuffer') - data = new Uint8Array(data).buffer; - listener.call(target, new MessageEvent(data, !!flags.binary, target)); - } - - function onClose (code, message) { - listener.call(target, new CloseEvent(code, message, target)); - } - - function onError (event) { - event.type = 'error'; - event.target = target; - listener.call(target, event); - } - - function onOpen () { - listener.call(target, new OpenEvent(target)); - } - - if (typeof listener === 'function') { - if (method === 'message') { - // store a reference so we can return the original function from the - // addEventListener hook - onMessage._listener = listener; - this.on(method, onMessage); - } else if (method === 'close') { - // store a reference so we can return the original function from the - // addEventListener hook - onClose._listener = listener; - this.on(method, onClose); - } else if (method === 'error') { - // store a reference so we can return the original function from the - // addEventListener hook - onError._listener = listener; - this.on(method, onError); - } else if (method === 'open') { - // store a reference so we can return the original function from the - // addEventListener hook - onOpen._listener = listener; - this.on(method, onOpen); - } else { - this.on(method, listener); - } - } -}; - -module.exports = WebSocket; -module.exports.buildHostHeader = buildHostHeader - -/** - * W3C MessageEvent - * - * @see http://www.w3.org/TR/html5/comms.html - * @constructor - * @api private - */ -function MessageEvent(dataArg, isBinary, target) { - this.type = 'message'; - this.data = dataArg; - this.target = target; - this.binary = isBinary; // non-standard. -} - -/** - * W3C CloseEvent - * - * @see http://www.w3.org/TR/html5/comms.html - * @constructor - * @api private - */ -function CloseEvent(code, reason, target) { - this.type = 'close'; - this.wasClean = (typeof code === 'undefined' || code === 1000); - this.code = code; - this.reason = reason; - this.target = target; -} - -/** - * W3C OpenEvent - * - * @see http://www.w3.org/TR/html5/comms.html - * @constructor - * @api private - */ -function OpenEvent(target) { - this.type = 'open'; - this.target = target; -} - -// Append port number to Host header, only if specified in the url -// and non-default -function buildHostHeader(isSecure, hostname, port) { - var headerHost = hostname; - if (hostname) { - if ((isSecure && (port != 443)) || (!isSecure && (port != 80))){ - headerHost = headerHost + ':' + port; - } - } - return headerHost; -} - -/** - * Entirely private apis, - * which may or may not be bound to a sepcific WebSocket instance. - */ -function initAsServerClient(req, socket, upgradeHead, options) { - options = new Options({ - protocolVersion: protocolVersion, - protocol: null, - extensions: {}, - maxPayload: 0 - }).merge(options); - - // expose state properties - this.protocol = options.value.protocol; - this.protocolVersion = options.value.protocolVersion; - this.extensions = options.value.extensions; - this.supports.binary = (this.protocolVersion !== 'hixie-76'); - this.upgradeReq = req; - this.readyState = WebSocket.CONNECTING; - this._isServer = true; - this.maxPayload = options.value.maxPayload; - // establish connection - if (options.value.protocolVersion === 'hixie-76') { - establishConnection.call(this, ReceiverHixie, SenderHixie, socket, upgradeHead); - } else { - establishConnection.call(this, Receiver, Sender, socket, upgradeHead); - } -} - -function initAsClient(address, protocols, options) { - options = new Options({ - origin: null, - protocolVersion: protocolVersion, - host: null, - headers: null, - protocol: protocols.join(','), - agent: null, - - // ssl-related options - pfx: null, - key: null, - passphrase: null, - cert: null, - ca: null, - ciphers: null, - rejectUnauthorized: null, - perMessageDeflate: true, - localAddress: null - }).merge(options); - - if (options.value.protocolVersion !== 8 && options.value.protocolVersion !== 13) { - throw new Error('unsupported protocol version'); - } - - // verify URL and establish http class - var serverUrl = url.parse(address); - var isUnixSocket = serverUrl.protocol === 'ws+unix:'; - if (!serverUrl.host && !isUnixSocket) throw new Error('invalid url'); - var isSecure = serverUrl.protocol === 'wss:' || serverUrl.protocol === 'https:'; - var httpObj = isSecure ? https : http; - var port = serverUrl.port || (isSecure ? 443 : 80); - var auth = serverUrl.auth; - - // prepare extensions - var extensionsOffer = {}; - var perMessageDeflate; - if (options.value.perMessageDeflate) { - perMessageDeflate = new PerMessageDeflate(typeof options.value.perMessageDeflate !== true ? options.value.perMessageDeflate : {}, false); - extensionsOffer[PerMessageDeflate.extensionName] = perMessageDeflate.offer(); - } - - // expose state properties - this._isServer = false; - this.url = address; - this.protocolVersion = options.value.protocolVersion; - this.supports.binary = (this.protocolVersion !== 'hixie-76'); - - // begin handshake - var key = new Buffer(options.value.protocolVersion + '-' + Date.now()).toString('base64'); - var shasum = crypto.createHash('sha1'); - shasum.update(key + '258EAFA5-E914-47DA-95CA-C5AB0DC85B11'); - var expectedServerKey = shasum.digest('base64'); - - var agent = options.value.agent; - - var headerHost = buildHostHeader(isSecure, serverUrl.hostname, port) - - var requestOptions = { - port: port, - host: serverUrl.hostname, - headers: { - 'Connection': 'Upgrade', - 'Upgrade': 'websocket', - 'Host': headerHost, - 'Sec-WebSocket-Version': options.value.protocolVersion, - 'Sec-WebSocket-Key': key - } - }; - - // If we have basic auth. - if (auth) { - requestOptions.headers.Authorization = 'Basic ' + new Buffer(auth).toString('base64'); - } - - if (options.value.protocol) { - requestOptions.headers['Sec-WebSocket-Protocol'] = options.value.protocol; - } - - if (options.value.host) { - requestOptions.headers.Host = options.value.host; - } - - if (options.value.headers) { - for (var header in options.value.headers) { - if (options.value.headers.hasOwnProperty(header)) { - requestOptions.headers[header] = options.value.headers[header]; - } - } - } - - if (Object.keys(extensionsOffer).length) { - requestOptions.headers['Sec-WebSocket-Extensions'] = Extensions.format(extensionsOffer); - } - - if (options.isDefinedAndNonNull('pfx') - || options.isDefinedAndNonNull('key') - || options.isDefinedAndNonNull('passphrase') - || options.isDefinedAndNonNull('cert') - || options.isDefinedAndNonNull('ca') - || options.isDefinedAndNonNull('ciphers') - || options.isDefinedAndNonNull('rejectUnauthorized')) { - - if (options.isDefinedAndNonNull('pfx')) requestOptions.pfx = options.value.pfx; - if (options.isDefinedAndNonNull('key')) requestOptions.key = options.value.key; - if (options.isDefinedAndNonNull('passphrase')) requestOptions.passphrase = options.value.passphrase; - if (options.isDefinedAndNonNull('cert')) requestOptions.cert = options.value.cert; - if (options.isDefinedAndNonNull('ca')) requestOptions.ca = options.value.ca; - if (options.isDefinedAndNonNull('ciphers')) requestOptions.ciphers = options.value.ciphers; - if (options.isDefinedAndNonNull('rejectUnauthorized')) requestOptions.rejectUnauthorized = options.value.rejectUnauthorized; - - if (!agent) { - // global agent ignores client side certificates - agent = new httpObj.Agent(requestOptions); - } - } - - requestOptions.path = serverUrl.path || '/'; - - if (agent) { - requestOptions.agent = agent; - } - - if (isUnixSocket) { - requestOptions.socketPath = serverUrl.pathname; - } - - if (options.value.localAddress) { - requestOptions.localAddress = options.value.localAddress; - } - - if (options.value.origin) { - if (options.value.protocolVersion < 13) requestOptions.headers['Sec-WebSocket-Origin'] = options.value.origin; - else requestOptions.headers.Origin = options.value.origin; - } - - var self = this; - var req = httpObj.request(requestOptions); - - req.on('error', function onerror(error) { - self.emit('error', error); - cleanupWebsocketResources.call(self, error); - }); - - req.once('response', function response(res) { - var error; - - if (!self.emit('unexpected-response', req, res)) { - error = new Error('unexpected server response (' + res.statusCode + ')'); - req.abort(); - self.emit('error', error); - } - - cleanupWebsocketResources.call(self, error); - }); - - req.once('upgrade', function upgrade(res, socket, upgradeHead) { - if (self.readyState === WebSocket.CLOSED) { - // client closed before server accepted connection - self.emit('close'); - self.removeAllListeners(); - socket.end(); - return; - } - - var serverKey = res.headers['sec-websocket-accept']; - if (typeof serverKey === 'undefined' || serverKey !== expectedServerKey) { - self.emit('error', 'invalid server key'); - self.removeAllListeners(); - socket.end(); - return; - } - - var serverProt = res.headers['sec-websocket-protocol']; - var protList = (options.value.protocol || "").split(/, */); - var protError = null; - - if (!options.value.protocol && serverProt) { - protError = 'server sent a subprotocol even though none requested'; - } else if (options.value.protocol && !serverProt) { - protError = 'server sent no subprotocol even though requested'; - } else if (serverProt && protList.indexOf(serverProt) === -1) { - protError = 'server responded with an invalid protocol'; - } - - if (protError) { - self.emit('error', protError); - self.removeAllListeners(); - socket.end(); - return; - } else if (serverProt) { - self.protocol = serverProt; - } - - var serverExtensions = Extensions.parse(res.headers['sec-websocket-extensions']); - if (perMessageDeflate && serverExtensions[PerMessageDeflate.extensionName]) { - try { - perMessageDeflate.accept(serverExtensions[PerMessageDeflate.extensionName]); - } catch (err) { - self.emit('error', 'invalid extension parameter'); - self.removeAllListeners(); - socket.end(); - return; - } - self.extensions[PerMessageDeflate.extensionName] = perMessageDeflate; - } - - establishConnection.call(self, Receiver, Sender, socket, upgradeHead); - - // perform cleanup on http resources - req.removeAllListeners(); - req = null; - agent = null; - }); - - req.end(); - this.readyState = WebSocket.CONNECTING; -} - -function establishConnection(ReceiverClass, SenderClass, socket, upgradeHead) { - var ultron = this._ultron = new Ultron(socket) - , called = false - , self = this; - - socket.setTimeout(0); - socket.setNoDelay(true); - - this._receiver = new ReceiverClass(this.extensions,this.maxPayload); - this._socket = socket; - - // socket cleanup handlers - ultron.on('end', cleanupWebsocketResources.bind(this)); - ultron.on('close', cleanupWebsocketResources.bind(this)); - ultron.on('error', cleanupWebsocketResources.bind(this)); - - // ensure that the upgradeHead is added to the receiver - function firstHandler(data) { - if (called || self.readyState === WebSocket.CLOSED) return; - - called = true; - socket.removeListener('data', firstHandler); - ultron.on('data', realHandler); - - if (upgradeHead && upgradeHead.length > 0) { - realHandler(upgradeHead); - upgradeHead = null; - } - - if (data) realHandler(data); - } - - // subsequent packets are pushed straight to the receiver - function realHandler(data) { - self.bytesReceived += data.length; - self._receiver.add(data); - } - - ultron.on('data', firstHandler); - - // if data was passed along with the http upgrade, - // this will schedule a push of that on to the receiver. - // this has to be done on next tick, since the caller - // hasn't had a chance to set event handlers on this client - // object yet. - process.nextTick(firstHandler); - - // receiver event handlers - self._receiver.ontext = function ontext(data, flags) { - flags = flags || {}; - - self.emit('message', data, flags); - }; - - self._receiver.onbinary = function onbinary(data, flags) { - flags = flags || {}; - - flags.binary = true; - self.emit('message', data, flags); - }; - - self._receiver.onping = function onping(data, flags) { - flags = flags || {}; - - self.pong(data, { - mask: !self._isServer, - binary: flags.binary === true - }, true); - - self.emit('ping', data, flags); - }; - - self._receiver.onpong = function onpong(data, flags) { - self.emit('pong', data, flags || {}); - }; - - self._receiver.onclose = function onclose(code, data, flags) { - flags = flags || {}; - - self._closeReceived = true; - self.close(code, data); - }; - - self._receiver.onerror = function onerror(reason, errorCode) { - // close the connection when the receiver reports a HyBi error code - self.close(typeof errorCode !== 'undefined' ? errorCode : 1002, ''); - self.emit('error', (reason instanceof Error) ? reason : (new Error(reason))); - }; - - // finalize the client - this._sender = new SenderClass(socket, this.extensions); - this._sender.on('error', function onerror(error) { - self.close(1002, ''); - self.emit('error', error); - }); - - this.readyState = WebSocket.OPEN; - this.emit('open'); -} - -function startQueue(instance) { - instance._queue = instance._queue || []; -} - -function executeQueueSends(instance) { - var queue = instance._queue; - if (typeof queue === 'undefined') return; - - delete instance._queue; - for (var i = 0, l = queue.length; i < l; ++i) { - queue[i](); - } -} - -function sendStream(instance, stream, options, cb) { - stream.on('data', function incoming(data) { - if (instance.readyState !== WebSocket.OPEN) { - if (typeof cb === 'function') cb(new Error('not opened')); - else { - delete instance._queue; - instance.emit('error', new Error('not opened')); - } - return; - } - - options.fin = false; - instance._sender.send(data, options); - }); - - stream.on('end', function end() { - if (instance.readyState !== WebSocket.OPEN) { - if (typeof cb === 'function') cb(new Error('not opened')); - else { - delete instance._queue; - instance.emit('error', new Error('not opened')); - } - return; - } - - options.fin = true; - instance._sender.send(null, options); - - if (typeof cb === 'function') cb(null); - }); -} - -function cleanupWebsocketResources(error) { - if (this.readyState === WebSocket.CLOSED) return; - - this.readyState = WebSocket.CLOSED; - - clearTimeout(this._closeTimer); - this._closeTimer = null; - - // If the connection was closed abnormally (with an error), or if - // the close control frame was not received then the close code - // must default to 1006. - if (error || !this._closeReceived) { - this._closeCode = 1006; - } - this.emit('close', this._closeCode || 1000, this._closeMessage || ''); - - if (this._socket) { - if (this._ultron) this._ultron.destroy(); - this._socket.on('error', function onerror() { - try { this.destroy(); } - catch (e) {} - }); - - try { - if (!error) this._socket.end(); - else this._socket.destroy(); - } catch (e) { /* Ignore termination errors */ } - - this._socket = null; - this._ultron = null; - } - - if (this._sender) { - this._sender.removeAllListeners(); - this._sender = null; - } - - if (this._receiver) { - this._receiver.cleanup(); - this._receiver = null; - } - - if (this.extensions[PerMessageDeflate.extensionName]) { - this.extensions[PerMessageDeflate.extensionName].cleanup(); - } - - this.extensions = null; - - this.removeAllListeners(); - this.on('error', function onerror() {}); // catch all errors after this - delete this._queue; -} +'use strict'; + +/*! + * ws: a node.js websocket client + * Copyright(c) 2011 Einar Otto Stangvik + * MIT Licensed + */ + +var url = require('url') + , util = require('util') + , http = require('http') + , https = require('https') + , crypto = require('crypto') + , stream = require('stream') + , Ultron = require('ultron') + , Options = require('options') + , Sender = require('./Sender') + , Receiver = require('./Receiver') + , SenderHixie = require('./Sender.hixie') + , ReceiverHixie = require('./Receiver.hixie') + , Extensions = require('./Extensions') + , PerMessageDeflate = require('./PerMessageDeflate') + , EventEmitter = require('events').EventEmitter; + +/** + * Constants + */ + +// Default protocol version + +var protocolVersion = 13; + +// Close timeout + +var closeTimeout = 30 * 1000; // Allow 30 seconds to terminate the connection cleanly + +/** + * WebSocket implementation + * + * @constructor + * @param {String} address Connection address. + * @param {String|Array} protocols WebSocket protocols. + * @param {Object} options Additional connection options. + * @api public + */ +function WebSocket(address, protocols, options) { + if (this instanceof WebSocket === false) { + return new WebSocket(address, protocols, options); + } + + EventEmitter.call(this); + + if (protocols && !Array.isArray(protocols) && 'object' === typeof protocols) { + // accept the "options" Object as the 2nd argument + options = protocols; + protocols = null; + } + + if ('string' === typeof protocols) { + protocols = [ protocols ]; + } + + if (!Array.isArray(protocols)) { + protocols = []; + } + + this._socket = null; + this._ultron = null; + this._closeReceived = false; + this.bytesReceived = 0; + this.readyState = null; + this.supports = {}; + this.extensions = {}; + this._binaryType = 'nodebuffer'; + + if (Array.isArray(address)) { + initAsServerClient.apply(this, address.concat(options)); + } else { + initAsClient.apply(this, [address, protocols, options]); + } +} + +/** + * Inherits from EventEmitter. + */ +util.inherits(WebSocket, EventEmitter); + +/** + * Ready States + */ +["CONNECTING", "OPEN", "CLOSING", "CLOSED"].forEach(function each(state, index) { + WebSocket.prototype[state] = WebSocket[state] = index; +}); + +/** + * Gracefully closes the connection, after sending a description message to the server + * + * @param {Object} data to be sent to the server + * @api public + */ +WebSocket.prototype.close = function close(code, data) { + if (this.readyState === WebSocket.CLOSED) return; + + if (this.readyState === WebSocket.CONNECTING) { + this.readyState = WebSocket.CLOSED; + return; + } + + if (this.readyState === WebSocket.CLOSING) { + if (this._closeReceived && this._isServer) { + this.terminate(); + } + return; + } + + var self = this; + try { + this.readyState = WebSocket.CLOSING; + this._closeCode = code; + this._closeMessage = data; + var mask = !this._isServer; + this._sender.close(code, data, mask, function(err) { + if (err) self.emit('error', err); + + if (self._closeReceived && self._isServer) { + self.terminate(); + } else { + // ensure that the connection is cleaned up even when no response of closing handshake. + clearTimeout(self._closeTimer); + self._closeTimer = setTimeout(cleanupWebsocketResources.bind(self, true), closeTimeout); + } + }); + } catch (e) { + this.emit('error', e); + } +}; + +/** + * Pause the client stream + * + * @api public + */ +WebSocket.prototype.pause = function pauser() { + if (this.readyState !== WebSocket.OPEN) throw new Error('not opened'); + + return this._socket.pause(); +}; + +/** + * Sends a ping + * + * @param {Object} data to be sent to the server + * @param {Object} Members - mask: boolean, binary: boolean + * @param {boolean} dontFailWhenClosed indicates whether or not to throw if the connection isnt open + * @api public + */ +WebSocket.prototype.ping = function ping(data, options, dontFailWhenClosed) { + if (this.readyState !== WebSocket.OPEN) { + if (dontFailWhenClosed === true) return; + throw new Error('not opened'); + } + + options = options || {}; + + if (typeof options.mask === 'undefined') options.mask = !this._isServer; + + this._sender.ping(data, options); +}; + +/** + * Sends a pong + * + * @param {Object} data to be sent to the server + * @param {Object} Members - mask: boolean, binary: boolean + * @param {boolean} dontFailWhenClosed indicates whether or not to throw if the connection isnt open + * @api public + */ +WebSocket.prototype.pong = function(data, options, dontFailWhenClosed) { + if (this.readyState !== WebSocket.OPEN) { + if (dontFailWhenClosed === true) return; + throw new Error('not opened'); + } + + options = options || {}; + + if (typeof options.mask === 'undefined') options.mask = !this._isServer; + + this._sender.pong(data, options); +}; + +/** + * Resume the client stream + * + * @api public + */ +WebSocket.prototype.resume = function resume() { + if (this.readyState !== WebSocket.OPEN) throw new Error('not opened'); + + return this._socket.resume(); +}; + +/** + * Sends a piece of data + * + * @param {Object} data to be sent to the server + * @param {Object} Members - mask: boolean, binary: boolean, compress: boolean + * @param {function} Optional callback which is executed after the send completes + * @api public + */ + +WebSocket.prototype.send = function send(data, options, cb) { + if (typeof options === 'function') { + cb = options; + options = {}; + } + + if (this.readyState !== WebSocket.OPEN) { + if (typeof cb === 'function') cb(new Error('not opened')); + else throw new Error('not opened'); + return; + } + + if (!data) data = ''; + if (this._queue) { + var self = this; + this._queue.push(function() { self.send(data, options, cb); }); + return; + } + + options = options || {}; + options.fin = true; + + if (typeof options.binary === 'undefined') { + options.binary = (data instanceof ArrayBuffer || data instanceof Buffer || + data instanceof Uint8Array || + data instanceof Uint16Array || + data instanceof Uint32Array || + data instanceof Int8Array || + data instanceof Int16Array || + data instanceof Int32Array || + data instanceof Float32Array || + data instanceof Float64Array); + } + + if (typeof options.mask === 'undefined') options.mask = !this._isServer; + if (typeof options.compress === 'undefined') options.compress = true; + if (!this.extensions[PerMessageDeflate.extensionName]) { + options.compress = false; + } + + var readable = typeof stream.Readable === 'function' + ? stream.Readable + : stream.Stream; + + if (data instanceof readable) { + startQueue(this); + var self = this; + + sendStream(this, data, options, function send(error) { + process.nextTick(function tock() { + executeQueueSends(self); + }); + + if (typeof cb === 'function') cb(error); + }); + } else { + this._sender.send(data, options, cb); + } +}; + +/** + * Streams data through calls to a user supplied function + * + * @param {Object} Members - mask: boolean, binary: boolean, compress: boolean + * @param {function} 'function (error, send)' which is executed on successive ticks of which send is 'function (data, final)'. + * @api public + */ +WebSocket.prototype.stream = function stream(options, cb) { + if (typeof options === 'function') { + cb = options; + options = {}; + } + + var self = this; + + if (typeof cb !== 'function') throw new Error('callback must be provided'); + + if (this.readyState !== WebSocket.OPEN) { + if (typeof cb === 'function') cb(new Error('not opened')); + else throw new Error('not opened'); + return; + } + + if (this._queue) { + this._queue.push(function () { self.stream(options, cb); }); + return; + } + + options = options || {}; + + if (typeof options.mask === 'undefined') options.mask = !this._isServer; + if (typeof options.compress === 'undefined') options.compress = true; + if (!this.extensions[PerMessageDeflate.extensionName]) { + options.compress = false; + } + + startQueue(this); + + function send(data, final) { + try { + if (self.readyState !== WebSocket.OPEN) throw new Error('not opened'); + options.fin = final === true; + self._sender.send(data, options); + if (!final) process.nextTick(cb.bind(null, null, send)); + else executeQueueSends(self); + } catch (e) { + if (typeof cb === 'function') cb(e); + else { + delete self._queue; + self.emit('error', e); + } + } + } + + process.nextTick(cb.bind(null, null, send)); +}; + +/** + * Immediately shuts down the connection + * + * @api public + */ +WebSocket.prototype.terminate = function terminate() { + if (this.readyState === WebSocket.CLOSED) return; + + if (this._socket) { + this.readyState = WebSocket.CLOSING; + + // End the connection + try { this._socket.end(); } + catch (e) { + // Socket error during end() call, so just destroy it right now + cleanupWebsocketResources.call(this, true); + return; + } + + // Add a timeout to ensure that the connection is completely + // cleaned up within 30 seconds, even if the clean close procedure + // fails for whatever reason + // First cleanup any pre-existing timeout from an earlier "terminate" call, + // if one exists. Otherwise terminate calls in quick succession will leak timeouts + // and hold the program open for `closeTimout` time. + if (this._closeTimer) { clearTimeout(this._closeTimer); } + this._closeTimer = setTimeout(cleanupWebsocketResources.bind(this, true), closeTimeout); + } else if (this.readyState === WebSocket.CONNECTING) { + cleanupWebsocketResources.call(this, true); + } +}; + +/** + * Expose bufferedAmount + * + * @api public + */ +Object.defineProperty(WebSocket.prototype, 'bufferedAmount', { + get: function get() { + var amount = 0; + if (this._socket) { + amount = this._socket.bufferSize || 0; + } + return amount; + } +}); + +/** + * Expose binaryType + * + * This deviates from the W3C interface since ws doesn't support the required + * default "blob" type (instead we define a custom "nodebuffer" type). + * + * @see http://dev.w3.org/html5/websockets/#the-websocket-interface + * @api public + */ +Object.defineProperty(WebSocket.prototype, 'binaryType', { + get: function get() { + return this._binaryType; + }, + set: function set(type) { + if (type === 'arraybuffer' || type === 'nodebuffer') + this._binaryType = type; + else + throw new SyntaxError('unsupported binaryType: must be either "nodebuffer" or "arraybuffer"'); + } +}); + +/** + * Emulates the W3C Browser based WebSocket interface using function members. + * + * @see http://dev.w3.org/html5/websockets/#the-websocket-interface + * @api public + */ +['open', 'error', 'close', 'message'].forEach(function(method) { + Object.defineProperty(WebSocket.prototype, 'on' + method, { + /** + * Returns the current listener + * + * @returns {Mixed} the set function or undefined + * @api public + */ + get: function get() { + var listener = this.listeners(method)[0]; + return listener ? (listener._listener ? listener._listener : listener) : undefined; + }, + + /** + * Start listening for events + * + * @param {Function} listener the listener + * @returns {Mixed} the set function or undefined + * @api public + */ + set: function set(listener) { + this.removeAllListeners(method); + this.addEventListener(method, listener); + } + }); +}); + +/** + * Emulates the W3C Browser based WebSocket interface using addEventListener. + * + * @see https://developer.mozilla.org/en/DOM/element.addEventListener + * @see http://dev.w3.org/html5/websockets/#the-websocket-interface + * @api public + */ +WebSocket.prototype.addEventListener = function(method, listener) { + var target = this; + + function onMessage (data, flags) { + if (flags.binary && this.binaryType === 'arraybuffer') + data = new Uint8Array(data).buffer; + listener.call(target, new MessageEvent(data, !!flags.binary, target)); + } + + function onClose (code, message) { + listener.call(target, new CloseEvent(code, message, target)); + } + + function onError (event) { + event.type = 'error'; + event.target = target; + listener.call(target, event); + } + + function onOpen () { + listener.call(target, new OpenEvent(target)); + } + + if (typeof listener === 'function') { + if (method === 'message') { + // store a reference so we can return the original function from the + // addEventListener hook + onMessage._listener = listener; + this.on(method, onMessage); + } else if (method === 'close') { + // store a reference so we can return the original function from the + // addEventListener hook + onClose._listener = listener; + this.on(method, onClose); + } else if (method === 'error') { + // store a reference so we can return the original function from the + // addEventListener hook + onError._listener = listener; + this.on(method, onError); + } else if (method === 'open') { + // store a reference so we can return the original function from the + // addEventListener hook + onOpen._listener = listener; + this.on(method, onOpen); + } else { + this.on(method, listener); + } + } +}; + +module.exports = WebSocket; +module.exports.buildHostHeader = buildHostHeader + +/** + * W3C MessageEvent + * + * @see http://www.w3.org/TR/html5/comms.html + * @constructor + * @api private + */ +function MessageEvent(dataArg, isBinary, target) { + this.type = 'message'; + this.data = dataArg; + this.target = target; + this.binary = isBinary; // non-standard. +} + +/** + * W3C CloseEvent + * + * @see http://www.w3.org/TR/html5/comms.html + * @constructor + * @api private + */ +function CloseEvent(code, reason, target) { + this.type = 'close'; + this.wasClean = (typeof code === 'undefined' || code === 1000); + this.code = code; + this.reason = reason; + this.target = target; +} + +/** + * W3C OpenEvent + * + * @see http://www.w3.org/TR/html5/comms.html + * @constructor + * @api private + */ +function OpenEvent(target) { + this.type = 'open'; + this.target = target; +} + +// Append port number to Host header, only if specified in the url +// and non-default +function buildHostHeader(isSecure, hostname, port) { + var headerHost = hostname; + if (hostname) { + if ((isSecure && (port != 443)) || (!isSecure && (port != 80))){ + headerHost = headerHost + ':' + port; + } + } + return headerHost; +} + +/** + * Entirely private apis, + * which may or may not be bound to a sepcific WebSocket instance. + */ +function initAsServerClient(req, socket, upgradeHead, options) { + options = new Options({ + protocolVersion: protocolVersion, + protocol: null, + extensions: {}, + maxPayload: 0 + }).merge(options); + + // expose state properties + this.protocol = options.value.protocol; + this.protocolVersion = options.value.protocolVersion; + this.extensions = options.value.extensions; + this.supports.binary = (this.protocolVersion !== 'hixie-76'); + this.upgradeReq = req; + this.readyState = WebSocket.CONNECTING; + this._isServer = true; + this.maxPayload = options.value.maxPayload; + // establish connection + if (options.value.protocolVersion === 'hixie-76') { + establishConnection.call(this, ReceiverHixie, SenderHixie, socket, upgradeHead); + } else { + establishConnection.call(this, Receiver, Sender, socket, upgradeHead); + } +} + +function initAsClient(address, protocols, options) { + options = new Options({ + origin: null, + protocolVersion: protocolVersion, + host: null, + headers: null, + protocol: protocols.join(','), + agent: null, + + // ssl-related options + pfx: null, + key: null, + passphrase: null, + cert: null, + ca: null, + ciphers: null, + rejectUnauthorized: null, + perMessageDeflate: true, + localAddress: null + }).merge(options); + + if (options.value.protocolVersion !== 8 && options.value.protocolVersion !== 13) { + throw new Error('unsupported protocol version'); + } + + // verify URL and establish http class + var serverUrl = url.parse(address); + var isUnixSocket = serverUrl.protocol === 'ws+unix:'; + if (!serverUrl.host && !isUnixSocket) throw new Error('invalid url'); + var isSecure = serverUrl.protocol === 'wss:' || serverUrl.protocol === 'https:'; + var httpObj = isSecure ? https : http; + var port = serverUrl.port || (isSecure ? 443 : 80); + var auth = serverUrl.auth; + + // prepare extensions + var extensionsOffer = {}; + var perMessageDeflate; + if (options.value.perMessageDeflate) { + perMessageDeflate = new PerMessageDeflate(typeof options.value.perMessageDeflate !== true ? options.value.perMessageDeflate : {}, false); + extensionsOffer[PerMessageDeflate.extensionName] = perMessageDeflate.offer(); + } + + // expose state properties + this._isServer = false; + this.url = address; + this.protocolVersion = options.value.protocolVersion; + this.supports.binary = (this.protocolVersion !== 'hixie-76'); + + // begin handshake + var key = new Buffer(options.value.protocolVersion + '-' + Date.now()).toString('base64'); + var shasum = crypto.createHash('sha1'); + shasum.update(key + '258EAFA5-E914-47DA-95CA-C5AB0DC85B11'); + var expectedServerKey = shasum.digest('base64'); + + var agent = options.value.agent; + + var headerHost = buildHostHeader(isSecure, serverUrl.hostname, port) + + var requestOptions = { + port: port, + host: serverUrl.hostname, + headers: { + 'Connection': 'Upgrade', + 'Upgrade': 'websocket', + 'Host': headerHost, + 'Sec-WebSocket-Version': options.value.protocolVersion, + 'Sec-WebSocket-Key': key + } + }; + + // If we have basic auth. + if (auth) { + requestOptions.headers.Authorization = 'Basic ' + new Buffer(auth).toString('base64'); + } + + if (options.value.protocol) { + requestOptions.headers['Sec-WebSocket-Protocol'] = options.value.protocol; + } + + if (options.value.host) { + requestOptions.headers.Host = options.value.host; + } + + if (options.value.headers) { + for (var header in options.value.headers) { + if (options.value.headers.hasOwnProperty(header)) { + requestOptions.headers[header] = options.value.headers[header]; + } + } + } + + if (Object.keys(extensionsOffer).length) { + requestOptions.headers['Sec-WebSocket-Extensions'] = Extensions.format(extensionsOffer); + } + + if (options.isDefinedAndNonNull('pfx') + || options.isDefinedAndNonNull('key') + || options.isDefinedAndNonNull('passphrase') + || options.isDefinedAndNonNull('cert') + || options.isDefinedAndNonNull('ca') + || options.isDefinedAndNonNull('ciphers') + || options.isDefinedAndNonNull('rejectUnauthorized')) { + + if (options.isDefinedAndNonNull('pfx')) requestOptions.pfx = options.value.pfx; + if (options.isDefinedAndNonNull('key')) requestOptions.key = options.value.key; + if (options.isDefinedAndNonNull('passphrase')) requestOptions.passphrase = options.value.passphrase; + if (options.isDefinedAndNonNull('cert')) requestOptions.cert = options.value.cert; + if (options.isDefinedAndNonNull('ca')) requestOptions.ca = options.value.ca; + if (options.isDefinedAndNonNull('ciphers')) requestOptions.ciphers = options.value.ciphers; + if (options.isDefinedAndNonNull('rejectUnauthorized')) requestOptions.rejectUnauthorized = options.value.rejectUnauthorized; + + if (!agent) { + // global agent ignores client side certificates + agent = new httpObj.Agent(requestOptions); + } + } + + requestOptions.path = serverUrl.path || '/'; + + if (agent) { + requestOptions.agent = agent; + } + + if (isUnixSocket) { + requestOptions.socketPath = serverUrl.pathname; + } + + if (options.value.localAddress) { + requestOptions.localAddress = options.value.localAddress; + } + + if (options.value.origin) { + if (options.value.protocolVersion < 13) requestOptions.headers['Sec-WebSocket-Origin'] = options.value.origin; + else requestOptions.headers.Origin = options.value.origin; + } + + var self = this; + var req = httpObj.request(requestOptions); + + req.on('error', function onerror(error) { + self.emit('error', error); + cleanupWebsocketResources.call(self, error); + }); + + req.once('response', function response(res) { + var error; + + if (!self.emit('unexpected-response', req, res)) { + error = new Error('unexpected server response (' + res.statusCode + ')'); + req.abort(); + self.emit('error', error); + } + + cleanupWebsocketResources.call(self, error); + }); + + req.once('upgrade', function upgrade(res, socket, upgradeHead) { + if (self.readyState === WebSocket.CLOSED) { + // client closed before server accepted connection + self.emit('close'); + self.removeAllListeners(); + socket.end(); + return; + } + + var serverKey = res.headers['sec-websocket-accept']; + if (typeof serverKey === 'undefined' || serverKey !== expectedServerKey) { + self.emit('error', 'invalid server key'); + self.removeAllListeners(); + socket.end(); + return; + } + + var serverProt = res.headers['sec-websocket-protocol']; + var protList = (options.value.protocol || "").split(/, */); + var protError = null; + + if (!options.value.protocol && serverProt) { + protError = 'server sent a subprotocol even though none requested'; + } else if (options.value.protocol && !serverProt) { + protError = 'server sent no subprotocol even though requested'; + } else if (serverProt && protList.indexOf(serverProt) === -1) { + protError = 'server responded with an invalid protocol'; + } + + if (protError) { + self.emit('error', protError); + self.removeAllListeners(); + socket.end(); + return; + } else if (serverProt) { + self.protocol = serverProt; + } + + var serverExtensions = Extensions.parse(res.headers['sec-websocket-extensions']); + if (perMessageDeflate && serverExtensions[PerMessageDeflate.extensionName]) { + try { + perMessageDeflate.accept(serverExtensions[PerMessageDeflate.extensionName]); + } catch (err) { + self.emit('error', 'invalid extension parameter'); + self.removeAllListeners(); + socket.end(); + return; + } + self.extensions[PerMessageDeflate.extensionName] = perMessageDeflate; + } + + establishConnection.call(self, Receiver, Sender, socket, upgradeHead); + + // perform cleanup on http resources + req.removeAllListeners(); + req = null; + agent = null; + }); + + req.end(); + this.readyState = WebSocket.CONNECTING; +} + +function establishConnection(ReceiverClass, SenderClass, socket, upgradeHead) { + var ultron = this._ultron = new Ultron(socket) + , called = false + , self = this; + + socket.setTimeout(0); + socket.setNoDelay(true); + + this._receiver = new ReceiverClass(this.extensions,this.maxPayload); + this._socket = socket; + + // socket cleanup handlers + ultron.on('end', cleanupWebsocketResources.bind(this)); + ultron.on('close', cleanupWebsocketResources.bind(this)); + ultron.on('error', cleanupWebsocketResources.bind(this)); + + // ensure that the upgradeHead is added to the receiver + function firstHandler(data) { + if (called || self.readyState === WebSocket.CLOSED) return; + + called = true; + socket.removeListener('data', firstHandler); + ultron.on('data', realHandler); + + if (upgradeHead && upgradeHead.length > 0) { + realHandler(upgradeHead); + upgradeHead = null; + } + + if (data) realHandler(data); + } + + // subsequent packets are pushed straight to the receiver + function realHandler(data) { + self.bytesReceived += data.length; + self._receiver.add(data); + } + + ultron.on('data', firstHandler); + + // if data was passed along with the http upgrade, + // this will schedule a push of that on to the receiver. + // this has to be done on next tick, since the caller + // hasn't had a chance to set event handlers on this client + // object yet. + process.nextTick(firstHandler); + + // receiver event handlers + self._receiver.ontext = function ontext(data, flags) { + flags = flags || {}; + + self.emit('message', data, flags); + }; + + self._receiver.onbinary = function onbinary(data, flags) { + flags = flags || {}; + + flags.binary = true; + self.emit('message', data, flags); + }; + + self._receiver.onping = function onping(data, flags) { + flags = flags || {}; + + self.pong(data, { + mask: !self._isServer, + binary: flags.binary === true + }, true); + + self.emit('ping', data, flags); + }; + + self._receiver.onpong = function onpong(data, flags) { + self.emit('pong', data, flags || {}); + }; + + self._receiver.onclose = function onclose(code, data, flags) { + flags = flags || {}; + + self._closeReceived = true; + self.close(code, data); + }; + + self._receiver.onerror = function onerror(reason, errorCode) { + // close the connection when the receiver reports a HyBi error code + self.close(typeof errorCode !== 'undefined' ? errorCode : 1002, ''); + self.emit('error', (reason instanceof Error) ? reason : (new Error(reason))); + }; + + // finalize the client + this._sender = new SenderClass(socket, this.extensions); + this._sender.on('error', function onerror(error) { + self.close(1002, ''); + self.emit('error', error); + }); + + this.readyState = WebSocket.OPEN; + this.emit('open'); +} + +function startQueue(instance) { + instance._queue = instance._queue || []; +} + +function executeQueueSends(instance) { + var queue = instance._queue; + if (typeof queue === 'undefined') return; + + delete instance._queue; + for (var i = 0, l = queue.length; i < l; ++i) { + queue[i](); + } +} + +function sendStream(instance, stream, options, cb) { + stream.on('data', function incoming(data) { + if (instance.readyState !== WebSocket.OPEN) { + if (typeof cb === 'function') cb(new Error('not opened')); + else { + delete instance._queue; + instance.emit('error', new Error('not opened')); + } + return; + } + + options.fin = false; + instance._sender.send(data, options); + }); + + stream.on('end', function end() { + if (instance.readyState !== WebSocket.OPEN) { + if (typeof cb === 'function') cb(new Error('not opened')); + else { + delete instance._queue; + instance.emit('error', new Error('not opened')); + } + return; + } + + options.fin = true; + instance._sender.send(null, options); + + if (typeof cb === 'function') cb(null); + }); +} + +function cleanupWebsocketResources(error) { + if (this.readyState === WebSocket.CLOSED) return; + + this.readyState = WebSocket.CLOSED; + + clearTimeout(this._closeTimer); + this._closeTimer = null; + + // If the connection was closed abnormally (with an error), or if + // the close control frame was not received then the close code + // must default to 1006. + if (error || !this._closeReceived) { + this._closeCode = 1006; + } + this.emit('close', this._closeCode || 1000, this._closeMessage || ''); + + if (this._socket) { + if (this._ultron) this._ultron.destroy(); + this._socket.on('error', function onerror() { + try { this.destroy(); } + catch (e) {} + }); + + try { + if (!error) this._socket.end(); + else this._socket.destroy(); + } catch (e) { /* Ignore termination errors */ } + + this._socket = null; + this._ultron = null; + } + + if (this._sender) { + this._sender.removeAllListeners(); + this._sender = null; + } + + if (this._receiver) { + this._receiver.cleanup(); + this._receiver = null; + } + + if (this.extensions[PerMessageDeflate.extensionName]) { + this.extensions[PerMessageDeflate.extensionName].cleanup(); + } + + this.extensions = null; + + this.removeAllListeners(); + this.on('error', function onerror() {}); // catch all errors after this + delete this._queue; +} diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/WebSocketServer.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/WebSocketServer.js index 96c830eb..476cf710 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/WebSocketServer.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib/WebSocketServer.js @@ -1,554 +1,554 @@ -/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - -var util = require('util') - , events = require('events') - , http = require('http') - , crypto = require('crypto') - , Options = require('options') - , WebSocket = require('./WebSocket') - , Extensions = require('./Extensions') - , PerMessageDeflate = require('./PerMessageDeflate') - , tls = require('tls') - , url = require('url'); - -/** - * WebSocket Server implementation - */ - -function WebSocketServer(options, callback) { - if (this instanceof WebSocketServer === false) { - return new WebSocketServer(options, callback); - } - - events.EventEmitter.call(this); - - options = new Options({ - host: '0.0.0.0', - port: null, - server: null, - verifyClient: null, - handleProtocols: null, - path: null, - noServer: false, - disableHixie: false, - clientTracking: true, - perMessageDeflate: true, - maxPayload: null - }).merge(options); - - if (!options.isDefinedAndNonNull('port') && !options.isDefinedAndNonNull('server') && !options.value.noServer) { - throw new TypeError('`port` or a `server` must be provided'); - } - - var self = this; - - if (options.isDefinedAndNonNull('port')) { - this._server = http.createServer(function (req, res) { - var body = http.STATUS_CODES[426]; - res.writeHead(426, { - 'Content-Length': body.length, - 'Content-Type': 'text/plain' - }); - res.end(body); - }); - this._server.allowHalfOpen = false; - this._server.listen(options.value.port, options.value.host, callback); - this._closeServer = function() { if (self._server) self._server.close(); }; - } - else if (options.value.server) { - this._server = options.value.server; - if (options.value.path) { - // take note of the path, to avoid collisions when multiple websocket servers are - // listening on the same http server - if (this._server._webSocketPaths && options.value.server._webSocketPaths[options.value.path]) { - throw new Error('two instances of WebSocketServer cannot listen on the same http server path'); - } - if (typeof this._server._webSocketPaths !== 'object') { - this._server._webSocketPaths = {}; - } - this._server._webSocketPaths[options.value.path] = 1; - } - } - if (this._server) { - this._onceServerListening = function() { self.emit('listening'); }; - this._server.once('listening', this._onceServerListening); - } - - if (typeof this._server != 'undefined') { - this._onServerError = function(error) { self.emit('error', error) }; - this._server.on('error', this._onServerError); - this._onServerUpgrade = function(req, socket, upgradeHead) { - //copy upgradeHead to avoid retention of large slab buffers used in node core - var head = new Buffer(upgradeHead.length); - upgradeHead.copy(head); - - self.handleUpgrade(req, socket, head, function(client) { - self.emit('connection'+req.url, client); - self.emit('connection', client); - }); - }; - this._server.on('upgrade', this._onServerUpgrade); - } - - this.options = options.value; - this.path = options.value.path; - this.clients = []; -} - -/** - * Inherits from EventEmitter. - */ - -util.inherits(WebSocketServer, events.EventEmitter); - -/** - * Immediately shuts down the connection. - * - * @api public - */ - -WebSocketServer.prototype.close = function(callback) { - // terminate all associated clients - var error = null; - try { - for (var i = 0, l = this.clients.length; i < l; ++i) { - this.clients[i].terminate(); - } - } - catch (e) { - error = e; - } - - // remove path descriptor, if any - if (this.path && this._server._webSocketPaths) { - delete this._server._webSocketPaths[this.path]; - if (Object.keys(this._server._webSocketPaths).length == 0) { - delete this._server._webSocketPaths; - } - } - - // close the http server if it was internally created - try { - if (typeof this._closeServer !== 'undefined') { - this._closeServer(); - } - } - finally { - if (this._server) { - this._server.removeListener('listening', this._onceServerListening); - this._server.removeListener('error', this._onServerError); - this._server.removeListener('upgrade', this._onServerUpgrade); - } - delete this._server; - } - if(callback) - callback(error); - else if(error) - throw error; -} - -/** - * Handle a HTTP Upgrade request. - * - * @api public - */ - -WebSocketServer.prototype.handleUpgrade = function(req, socket, upgradeHead, cb) { - // check for wrong path - if (this.options.path) { - var u = url.parse(req.url); - if (u && u.pathname !== this.options.path) return; - } - - if (typeof req.headers.upgrade === 'undefined' || req.headers.upgrade.toLowerCase() !== 'websocket') { - abortConnection(socket, 400, 'Bad Request'); - return; - } - - if (req.headers['sec-websocket-key1']) handleHixieUpgrade.apply(this, arguments); - else handleHybiUpgrade.apply(this, arguments); -} - -module.exports = WebSocketServer; - -/** - * Entirely private apis, - * which may or may not be bound to a sepcific WebSocket instance. - */ - -function handleHybiUpgrade(req, socket, upgradeHead, cb) { - // handle premature socket errors - var errorHandler = function() { - try { socket.destroy(); } catch (e) {} - } - socket.on('error', errorHandler); - - // verify key presence - if (!req.headers['sec-websocket-key']) { - abortConnection(socket, 400, 'Bad Request'); - return; - } - - // verify version - var version = parseInt(req.headers['sec-websocket-version']); - if ([8, 13].indexOf(version) === -1) { - abortConnection(socket, 400, 'Bad Request'); - return; - } - - // verify protocol - var protocols = req.headers['sec-websocket-protocol']; - - // verify client - var origin = version < 13 ? - req.headers['sec-websocket-origin'] : - req.headers['origin']; - - // handle extensions offer - var extensionsOffer = Extensions.parse(req.headers['sec-websocket-extensions']); - - // handler to call when the connection sequence completes - var self = this; - var completeHybiUpgrade2 = function(protocol) { - - // calc key - var key = req.headers['sec-websocket-key']; - var shasum = crypto.createHash('sha1'); - shasum.update(key + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"); - key = shasum.digest('base64'); - - var headers = [ - 'HTTP/1.1 101 Switching Protocols' - , 'Upgrade: websocket' - , 'Connection: Upgrade' - , 'Sec-WebSocket-Accept: ' + key - ]; - - if (typeof protocol != 'undefined') { - headers.push('Sec-WebSocket-Protocol: ' + protocol); - } - - var extensions = {}; - try { - extensions = acceptExtensions.call(self, extensionsOffer); - } catch (err) { - abortConnection(socket, 400, 'Bad Request'); - return; - } - - if (Object.keys(extensions).length) { - var serverExtensions = {}; - Object.keys(extensions).forEach(function(token) { - serverExtensions[token] = [extensions[token].params] - }); - headers.push('Sec-WebSocket-Extensions: ' + Extensions.format(serverExtensions)); - } - - // allows external modification/inspection of handshake headers - self.emit('headers', headers); - - socket.setTimeout(0); - socket.setNoDelay(true); - try { - socket.write(headers.concat('', '').join('\r\n')); - } - catch (e) { - // if the upgrade write fails, shut the connection down hard - try { socket.destroy(); } catch (e) {} - return; - } - - var client = new WebSocket([req, socket, upgradeHead], { - protocolVersion: version, - protocol: protocol, - extensions: extensions, - maxPayload: self.options.maxPayload - }); - - if (self.options.clientTracking) { - self.clients.push(client); - client.on('close', function() { - var index = self.clients.indexOf(client); - if (index != -1) { - self.clients.splice(index, 1); - } - }); - } - - // signal upgrade complete - socket.removeListener('error', errorHandler); - cb(client); - } - - // optionally call external protocol selection handler before - // calling completeHybiUpgrade2 - var completeHybiUpgrade1 = function() { - // choose from the sub-protocols - if (typeof self.options.handleProtocols == 'function') { - var protList = (protocols || "").split(/, */); - var callbackCalled = false; - var res = self.options.handleProtocols(protList, function(result, protocol) { - callbackCalled = true; - if (!result) abortConnection(socket, 401, 'Unauthorized'); - else completeHybiUpgrade2(protocol); - }); - if (!callbackCalled) { - // the handleProtocols handler never called our callback - abortConnection(socket, 501, 'Could not process protocols'); - } - return; - } else { - if (typeof protocols !== 'undefined') { - completeHybiUpgrade2(protocols.split(/, */)[0]); - } - else { - completeHybiUpgrade2(); - } - } - } - - // optionally call external client verification handler - if (typeof this.options.verifyClient == 'function') { - var info = { - origin: origin, - secure: typeof req.connection.authorized !== 'undefined' || typeof req.connection.encrypted !== 'undefined', - req: req - }; - if (this.options.verifyClient.length == 2) { - this.options.verifyClient(info, function(result, code, name) { - if (typeof code === 'undefined') code = 401; - if (typeof name === 'undefined') name = http.STATUS_CODES[code]; - - if (!result) abortConnection(socket, code, name); - else completeHybiUpgrade1(); - }); - return; - } - else if (!this.options.verifyClient(info)) { - abortConnection(socket, 401, 'Unauthorized'); - return; - } - } - - completeHybiUpgrade1(); -} - -function handleHixieUpgrade(req, socket, upgradeHead, cb) { - // handle premature socket errors - var errorHandler = function() { - try { socket.destroy(); } catch (e) {} - } - socket.on('error', errorHandler); - - // bail if options prevent hixie - if (this.options.disableHixie) { - abortConnection(socket, 401, 'Hixie support disabled'); - return; - } - - // verify key presence - if (!req.headers['sec-websocket-key2']) { - abortConnection(socket, 400, 'Bad Request'); - return; - } - - var origin = req.headers['origin'] - , self = this; - - // setup handshake completion to run after client has been verified - var onClientVerified = function() { - var wshost; - if (!req.headers['x-forwarded-host']) - wshost = req.headers.host; - else - wshost = req.headers['x-forwarded-host']; - var location = ((req.headers['x-forwarded-proto'] === 'https' || socket.encrypted) ? 'wss' : 'ws') + '://' + wshost + req.url - , protocol = req.headers['sec-websocket-protocol']; - - // build the response header and return a Buffer - var buildResponseHeader = function() { - var headers = [ - 'HTTP/1.1 101 Switching Protocols' - , 'Upgrade: WebSocket' - , 'Connection: Upgrade' - , 'Sec-WebSocket-Location: ' + location - ]; - if (typeof protocol != 'undefined') headers.push('Sec-WebSocket-Protocol: ' + protocol); - if (typeof origin != 'undefined') headers.push('Sec-WebSocket-Origin: ' + origin); - - return new Buffer(headers.concat('', '').join('\r\n')); - }; - - // send handshake response before receiving the nonce - var handshakeResponse = function() { - - socket.setTimeout(0); - socket.setNoDelay(true); - - var headerBuffer = buildResponseHeader(); - - try { - socket.write(headerBuffer, 'binary', function(err) { - // remove listener if there was an error - if (err) socket.removeListener('data', handler); - return; - }); - } catch (e) { - try { socket.destroy(); } catch (e) {} - return; - }; - }; - - // handshake completion code to run once nonce has been successfully retrieved - var completeHandshake = function(nonce, rest, headerBuffer) { - // calculate key - var k1 = req.headers['sec-websocket-key1'] - , k2 = req.headers['sec-websocket-key2'] - , md5 = crypto.createHash('md5'); - - [k1, k2].forEach(function (k) { - var n = parseInt(k.replace(/[^\d]/g, '')) - , spaces = k.replace(/[^ ]/g, '').length; - if (spaces === 0 || n % spaces !== 0){ - abortConnection(socket, 400, 'Bad Request'); - return; - } - n /= spaces; - md5.update(String.fromCharCode( - n >> 24 & 0xFF, - n >> 16 & 0xFF, - n >> 8 & 0xFF, - n & 0xFF)); - }); - md5.update(nonce.toString('binary')); - - socket.setTimeout(0); - socket.setNoDelay(true); - - try { - var hashBuffer = new Buffer(md5.digest('binary'), 'binary'); - var handshakeBuffer = new Buffer(headerBuffer.length + hashBuffer.length); - headerBuffer.copy(handshakeBuffer, 0); - hashBuffer.copy(handshakeBuffer, headerBuffer.length); - - // do a single write, which - upon success - causes a new client websocket to be setup - socket.write(handshakeBuffer, 'binary', function(err) { - if (err) return; // do not create client if an error happens - var client = new WebSocket([req, socket, rest], { - protocolVersion: 'hixie-76', - protocol: protocol - }); - if (self.options.clientTracking) { - self.clients.push(client); - client.on('close', function() { - var index = self.clients.indexOf(client); - if (index != -1) { - self.clients.splice(index, 1); - } - }); - } - - // signal upgrade complete - socket.removeListener('error', errorHandler); - cb(client); - }); - } - catch (e) { - try { socket.destroy(); } catch (e) {} - return; - } - } - - // retrieve nonce - var nonceLength = 8; - if (upgradeHead && upgradeHead.length >= nonceLength) { - var nonce = upgradeHead.slice(0, nonceLength); - var rest = upgradeHead.length > nonceLength ? upgradeHead.slice(nonceLength) : null; - completeHandshake.call(self, nonce, rest, buildResponseHeader()); - } - else { - // nonce not present in upgradeHead - var nonce = new Buffer(nonceLength); - upgradeHead.copy(nonce, 0); - var received = upgradeHead.length; - var rest = null; - var handler = function (data) { - var toRead = Math.min(data.length, nonceLength - received); - if (toRead === 0) return; - data.copy(nonce, received, 0, toRead); - received += toRead; - if (received == nonceLength) { - socket.removeListener('data', handler); - if (toRead < data.length) rest = data.slice(toRead); - - // complete the handshake but send empty buffer for headers since they have already been sent - completeHandshake.call(self, nonce, rest, new Buffer(0)); - } - } - - // handle additional data as we receive it - socket.on('data', handler); - - // send header response before we have the nonce to fix haproxy buffering - handshakeResponse(); - } - } - - // verify client - if (typeof this.options.verifyClient == 'function') { - var info = { - origin: origin, - secure: typeof req.connection.authorized !== 'undefined' || typeof req.connection.encrypted !== 'undefined', - req: req - }; - if (this.options.verifyClient.length == 2) { - var self = this; - this.options.verifyClient(info, function(result, code, name) { - if (typeof code === 'undefined') code = 401; - if (typeof name === 'undefined') name = http.STATUS_CODES[code]; - - if (!result) abortConnection(socket, code, name); - else onClientVerified.apply(self); - }); - return; - } - else if (!this.options.verifyClient(info)) { - abortConnection(socket, 401, 'Unauthorized'); - return; - } - } - - // no client verification required - onClientVerified(); -} - -function acceptExtensions(offer) { - var extensions = {}; - var options = this.options.perMessageDeflate; - var maxPayload = this.options.maxPayload; - if (options && offer[PerMessageDeflate.extensionName]) { - var perMessageDeflate = new PerMessageDeflate(options !== true ? options : {}, true, maxPayload); - perMessageDeflate.accept(offer[PerMessageDeflate.extensionName]); - extensions[PerMessageDeflate.extensionName] = perMessageDeflate; - } - return extensions; -} - -function abortConnection(socket, code, name) { - try { - var response = [ - 'HTTP/1.1 ' + code + ' ' + name, - 'Content-type: text/html' - ]; - socket.write(response.concat('', '').join('\r\n')); - } - catch (e) { /* ignore errors - we've aborted this connection */ } - finally { - // ensure that an early aborted connection is shut down completely - try { socket.destroy(); } catch (e) {} - } -} +/*! + * ws: a node.js websocket client + * Copyright(c) 2011 Einar Otto Stangvik + * MIT Licensed + */ + +var util = require('util') + , events = require('events') + , http = require('http') + , crypto = require('crypto') + , Options = require('options') + , WebSocket = require('./WebSocket') + , Extensions = require('./Extensions') + , PerMessageDeflate = require('./PerMessageDeflate') + , tls = require('tls') + , url = require('url'); + +/** + * WebSocket Server implementation + */ + +function WebSocketServer(options, callback) { + if (this instanceof WebSocketServer === false) { + return new WebSocketServer(options, callback); + } + + events.EventEmitter.call(this); + + options = new Options({ + host: '0.0.0.0', + port: null, + server: null, + verifyClient: null, + handleProtocols: null, + path: null, + noServer: false, + disableHixie: false, + clientTracking: true, + perMessageDeflate: true, + maxPayload: null + }).merge(options); + + if (!options.isDefinedAndNonNull('port') && !options.isDefinedAndNonNull('server') && !options.value.noServer) { + throw new TypeError('`port` or a `server` must be provided'); + } + + var self = this; + + if (options.isDefinedAndNonNull('port')) { + this._server = http.createServer(function (req, res) { + var body = http.STATUS_CODES[426]; + res.writeHead(426, { + 'Content-Length': body.length, + 'Content-Type': 'text/plain' + }); + res.end(body); + }); + this._server.allowHalfOpen = false; + this._server.listen(options.value.port, options.value.host, callback); + this._closeServer = function() { if (self._server) self._server.close(); }; + } + else if (options.value.server) { + this._server = options.value.server; + if (options.value.path) { + // take note of the path, to avoid collisions when multiple websocket servers are + // listening on the same http server + if (this._server._webSocketPaths && options.value.server._webSocketPaths[options.value.path]) { + throw new Error('two instances of WebSocketServer cannot listen on the same http server path'); + } + if (typeof this._server._webSocketPaths !== 'object') { + this._server._webSocketPaths = {}; + } + this._server._webSocketPaths[options.value.path] = 1; + } + } + if (this._server) { + this._onceServerListening = function() { self.emit('listening'); }; + this._server.once('listening', this._onceServerListening); + } + + if (typeof this._server != 'undefined') { + this._onServerError = function(error) { self.emit('error', error) }; + this._server.on('error', this._onServerError); + this._onServerUpgrade = function(req, socket, upgradeHead) { + //copy upgradeHead to avoid retention of large slab buffers used in node core + var head = new Buffer(upgradeHead.length); + upgradeHead.copy(head); + + self.handleUpgrade(req, socket, head, function(client) { + self.emit('connection'+req.url, client); + self.emit('connection', client); + }); + }; + this._server.on('upgrade', this._onServerUpgrade); + } + + this.options = options.value; + this.path = options.value.path; + this.clients = []; +} + +/** + * Inherits from EventEmitter. + */ + +util.inherits(WebSocketServer, events.EventEmitter); + +/** + * Immediately shuts down the connection. + * + * @api public + */ + +WebSocketServer.prototype.close = function(callback) { + // terminate all associated clients + var error = null; + try { + for (var i = 0, l = this.clients.length; i < l; ++i) { + this.clients[i].terminate(); + } + } + catch (e) { + error = e; + } + + // remove path descriptor, if any + if (this.path && this._server._webSocketPaths) { + delete this._server._webSocketPaths[this.path]; + if (Object.keys(this._server._webSocketPaths).length == 0) { + delete this._server._webSocketPaths; + } + } + + // close the http server if it was internally created + try { + if (typeof this._closeServer !== 'undefined') { + this._closeServer(); + } + } + finally { + if (this._server) { + this._server.removeListener('listening', this._onceServerListening); + this._server.removeListener('error', this._onServerError); + this._server.removeListener('upgrade', this._onServerUpgrade); + } + delete this._server; + } + if(callback) + callback(error); + else if(error) + throw error; +} + +/** + * Handle a HTTP Upgrade request. + * + * @api public + */ + +WebSocketServer.prototype.handleUpgrade = function(req, socket, upgradeHead, cb) { + // check for wrong path + if (this.options.path) { + var u = url.parse(req.url); + if (u && u.pathname !== this.options.path) return; + } + + if (typeof req.headers.upgrade === 'undefined' || req.headers.upgrade.toLowerCase() !== 'websocket') { + abortConnection(socket, 400, 'Bad Request'); + return; + } + + if (req.headers['sec-websocket-key1']) handleHixieUpgrade.apply(this, arguments); + else handleHybiUpgrade.apply(this, arguments); +} + +module.exports = WebSocketServer; + +/** + * Entirely private apis, + * which may or may not be bound to a sepcific WebSocket instance. + */ + +function handleHybiUpgrade(req, socket, upgradeHead, cb) { + // handle premature socket errors + var errorHandler = function() { + try { socket.destroy(); } catch (e) {} + } + socket.on('error', errorHandler); + + // verify key presence + if (!req.headers['sec-websocket-key']) { + abortConnection(socket, 400, 'Bad Request'); + return; + } + + // verify version + var version = parseInt(req.headers['sec-websocket-version']); + if ([8, 13].indexOf(version) === -1) { + abortConnection(socket, 400, 'Bad Request'); + return; + } + + // verify protocol + var protocols = req.headers['sec-websocket-protocol']; + + // verify client + var origin = version < 13 ? + req.headers['sec-websocket-origin'] : + req.headers['origin']; + + // handle extensions offer + var extensionsOffer = Extensions.parse(req.headers['sec-websocket-extensions']); + + // handler to call when the connection sequence completes + var self = this; + var completeHybiUpgrade2 = function(protocol) { + + // calc key + var key = req.headers['sec-websocket-key']; + var shasum = crypto.createHash('sha1'); + shasum.update(key + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"); + key = shasum.digest('base64'); + + var headers = [ + 'HTTP/1.1 101 Switching Protocols' + , 'Upgrade: websocket' + , 'Connection: Upgrade' + , 'Sec-WebSocket-Accept: ' + key + ]; + + if (typeof protocol != 'undefined') { + headers.push('Sec-WebSocket-Protocol: ' + protocol); + } + + var extensions = {}; + try { + extensions = acceptExtensions.call(self, extensionsOffer); + } catch (err) { + abortConnection(socket, 400, 'Bad Request'); + return; + } + + if (Object.keys(extensions).length) { + var serverExtensions = {}; + Object.keys(extensions).forEach(function(token) { + serverExtensions[token] = [extensions[token].params] + }); + headers.push('Sec-WebSocket-Extensions: ' + Extensions.format(serverExtensions)); + } + + // allows external modification/inspection of handshake headers + self.emit('headers', headers); + + socket.setTimeout(0); + socket.setNoDelay(true); + try { + socket.write(headers.concat('', '').join('\r\n')); + } + catch (e) { + // if the upgrade write fails, shut the connection down hard + try { socket.destroy(); } catch (e) {} + return; + } + + var client = new WebSocket([req, socket, upgradeHead], { + protocolVersion: version, + protocol: protocol, + extensions: extensions, + maxPayload: self.options.maxPayload + }); + + if (self.options.clientTracking) { + self.clients.push(client); + client.on('close', function() { + var index = self.clients.indexOf(client); + if (index != -1) { + self.clients.splice(index, 1); + } + }); + } + + // signal upgrade complete + socket.removeListener('error', errorHandler); + cb(client); + } + + // optionally call external protocol selection handler before + // calling completeHybiUpgrade2 + var completeHybiUpgrade1 = function() { + // choose from the sub-protocols + if (typeof self.options.handleProtocols == 'function') { + var protList = (protocols || "").split(/, */); + var callbackCalled = false; + var res = self.options.handleProtocols(protList, function(result, protocol) { + callbackCalled = true; + if (!result) abortConnection(socket, 401, 'Unauthorized'); + else completeHybiUpgrade2(protocol); + }); + if (!callbackCalled) { + // the handleProtocols handler never called our callback + abortConnection(socket, 501, 'Could not process protocols'); + } + return; + } else { + if (typeof protocols !== 'undefined') { + completeHybiUpgrade2(protocols.split(/, */)[0]); + } + else { + completeHybiUpgrade2(); + } + } + } + + // optionally call external client verification handler + if (typeof this.options.verifyClient == 'function') { + var info = { + origin: origin, + secure: typeof req.connection.authorized !== 'undefined' || typeof req.connection.encrypted !== 'undefined', + req: req + }; + if (this.options.verifyClient.length == 2) { + this.options.verifyClient(info, function(result, code, name) { + if (typeof code === 'undefined') code = 401; + if (typeof name === 'undefined') name = http.STATUS_CODES[code]; + + if (!result) abortConnection(socket, code, name); + else completeHybiUpgrade1(); + }); + return; + } + else if (!this.options.verifyClient(info)) { + abortConnection(socket, 401, 'Unauthorized'); + return; + } + } + + completeHybiUpgrade1(); +} + +function handleHixieUpgrade(req, socket, upgradeHead, cb) { + // handle premature socket errors + var errorHandler = function() { + try { socket.destroy(); } catch (e) {} + } + socket.on('error', errorHandler); + + // bail if options prevent hixie + if (this.options.disableHixie) { + abortConnection(socket, 401, 'Hixie support disabled'); + return; + } + + // verify key presence + if (!req.headers['sec-websocket-key2']) { + abortConnection(socket, 400, 'Bad Request'); + return; + } + + var origin = req.headers['origin'] + , self = this; + + // setup handshake completion to run after client has been verified + var onClientVerified = function() { + var wshost; + if (!req.headers['x-forwarded-host']) + wshost = req.headers.host; + else + wshost = req.headers['x-forwarded-host']; + var location = ((req.headers['x-forwarded-proto'] === 'https' || socket.encrypted) ? 'wss' : 'ws') + '://' + wshost + req.url + , protocol = req.headers['sec-websocket-protocol']; + + // build the response header and return a Buffer + var buildResponseHeader = function() { + var headers = [ + 'HTTP/1.1 101 Switching Protocols' + , 'Upgrade: WebSocket' + , 'Connection: Upgrade' + , 'Sec-WebSocket-Location: ' + location + ]; + if (typeof protocol != 'undefined') headers.push('Sec-WebSocket-Protocol: ' + protocol); + if (typeof origin != 'undefined') headers.push('Sec-WebSocket-Origin: ' + origin); + + return new Buffer(headers.concat('', '').join('\r\n')); + }; + + // send handshake response before receiving the nonce + var handshakeResponse = function() { + + socket.setTimeout(0); + socket.setNoDelay(true); + + var headerBuffer = buildResponseHeader(); + + try { + socket.write(headerBuffer, 'binary', function(err) { + // remove listener if there was an error + if (err) socket.removeListener('data', handler); + return; + }); + } catch (e) { + try { socket.destroy(); } catch (e) {} + return; + }; + }; + + // handshake completion code to run once nonce has been successfully retrieved + var completeHandshake = function(nonce, rest, headerBuffer) { + // calculate key + var k1 = req.headers['sec-websocket-key1'] + , k2 = req.headers['sec-websocket-key2'] + , md5 = crypto.createHash('md5'); + + [k1, k2].forEach(function (k) { + var n = parseInt(k.replace(/[^\d]/g, '')) + , spaces = k.replace(/[^ ]/g, '').length; + if (spaces === 0 || n % spaces !== 0){ + abortConnection(socket, 400, 'Bad Request'); + return; + } + n /= spaces; + md5.update(String.fromCharCode( + n >> 24 & 0xFF, + n >> 16 & 0xFF, + n >> 8 & 0xFF, + n & 0xFF)); + }); + md5.update(nonce.toString('binary')); + + socket.setTimeout(0); + socket.setNoDelay(true); + + try { + var hashBuffer = new Buffer(md5.digest('binary'), 'binary'); + var handshakeBuffer = new Buffer(headerBuffer.length + hashBuffer.length); + headerBuffer.copy(handshakeBuffer, 0); + hashBuffer.copy(handshakeBuffer, headerBuffer.length); + + // do a single write, which - upon success - causes a new client websocket to be setup + socket.write(handshakeBuffer, 'binary', function(err) { + if (err) return; // do not create client if an error happens + var client = new WebSocket([req, socket, rest], { + protocolVersion: 'hixie-76', + protocol: protocol + }); + if (self.options.clientTracking) { + self.clients.push(client); + client.on('close', function() { + var index = self.clients.indexOf(client); + if (index != -1) { + self.clients.splice(index, 1); + } + }); + } + + // signal upgrade complete + socket.removeListener('error', errorHandler); + cb(client); + }); + } + catch (e) { + try { socket.destroy(); } catch (e) {} + return; + } + } + + // retrieve nonce + var nonceLength = 8; + if (upgradeHead && upgradeHead.length >= nonceLength) { + var nonce = upgradeHead.slice(0, nonceLength); + var rest = upgradeHead.length > nonceLength ? upgradeHead.slice(nonceLength) : null; + completeHandshake.call(self, nonce, rest, buildResponseHeader()); + } + else { + // nonce not present in upgradeHead + var nonce = new Buffer(nonceLength); + upgradeHead.copy(nonce, 0); + var received = upgradeHead.length; + var rest = null; + var handler = function (data) { + var toRead = Math.min(data.length, nonceLength - received); + if (toRead === 0) return; + data.copy(nonce, received, 0, toRead); + received += toRead; + if (received == nonceLength) { + socket.removeListener('data', handler); + if (toRead < data.length) rest = data.slice(toRead); + + // complete the handshake but send empty buffer for headers since they have already been sent + completeHandshake.call(self, nonce, rest, new Buffer(0)); + } + } + + // handle additional data as we receive it + socket.on('data', handler); + + // send header response before we have the nonce to fix haproxy buffering + handshakeResponse(); + } + } + + // verify client + if (typeof this.options.verifyClient == 'function') { + var info = { + origin: origin, + secure: typeof req.connection.authorized !== 'undefined' || typeof req.connection.encrypted !== 'undefined', + req: req + }; + if (this.options.verifyClient.length == 2) { + var self = this; + this.options.verifyClient(info, function(result, code, name) { + if (typeof code === 'undefined') code = 401; + if (typeof name === 'undefined') name = http.STATUS_CODES[code]; + + if (!result) abortConnection(socket, code, name); + else onClientVerified.apply(self); + }); + return; + } + else if (!this.options.verifyClient(info)) { + abortConnection(socket, 401, 'Unauthorized'); + return; + } + } + + // no client verification required + onClientVerified(); +} + +function acceptExtensions(offer) { + var extensions = {}; + var options = this.options.perMessageDeflate; + var maxPayload = this.options.maxPayload; + if (options && offer[PerMessageDeflate.extensionName]) { + var perMessageDeflate = new PerMessageDeflate(options !== true ? options : {}, true, maxPayload); + perMessageDeflate.accept(offer[PerMessageDeflate.extensionName]); + extensions[PerMessageDeflate.extensionName] = perMessageDeflate; + } + return extensions; +} + +function abortConnection(socket, code, name) { + try { + var response = [ + 'HTTP/1.1 ' + code + ' ' + name, + 'Content-type: text/html' + ]; + socket.write(response.concat('', '').join('\r\n')); + } + catch (e) { /* ignore errors - we've aborted this connection */ } + finally { + // ensure that an early aborted connection is shut down completely + try { socket.destroy(); } catch (e) {} + } +} diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/options/.npmignore b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/options/.npmignore index 13c1f0ee..1b18fb39 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/options/.npmignore +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/options/.npmignore @@ -1,7 +1,7 @@ -npm-debug.log -node_modules -.*.swp -.lock-* -build/ - -test +npm-debug.log +node_modules +.*.swp +.lock-* +build/ + +test diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/options/Makefile b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/options/Makefile index 634d1da2..7496b6fc 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/options/Makefile +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/options/Makefile @@ -1,12 +1,12 @@ -ALL_TESTS = $(shell find test/ -name '*.test.js') - -run-tests: - @./node_modules/.bin/mocha \ - -t 2000 \ - $(TESTFLAGS) \ - $(TESTS) - -test: - @$(MAKE) NODE_PATH=lib TESTS="$(ALL_TESTS)" run-tests - -.PHONY: test +ALL_TESTS = $(shell find test/ -name '*.test.js') + +run-tests: + @./node_modules/.bin/mocha \ + -t 2000 \ + $(TESTFLAGS) \ + $(TESTS) + +test: + @$(MAKE) NODE_PATH=lib TESTS="$(ALL_TESTS)" run-tests + +.PHONY: test diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/options/README.md b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/options/README.md index bfe66ed3..0dabc755 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/options/README.md +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/options/README.md @@ -1,69 +1,69 @@ -# options.js # - -A very light-weight in-code option parsers for node.js. - -## Usage ## - -``` js -var Options = require("options"); - -// Create an Options object -function foo(options) { - var default_options = { - foo : "bar" - }; - - // Create an option object with default value - var opts = new Options(default_options); - - // Merge options - opts = opts.merge(options); - - // Reset to default value - opts.reset(); - - // Copy selected attributes out - var seled_att = opts.copy("foo"); - - // Read json options from a file. - opts.read("options.file"); // Sync - opts.read("options.file", function(err){ // Async - if(err){ // If error occurs - console.log("File error."); - }else{ - // No error - } - }); - - // Attributes defined or not - opts.isDefinedAndNonNull("foobar"); - opts.isDefined("foobar"); -} - -``` - - -## License ## - -(The MIT License) - -Copyright (c) 2012 Einar Otto Stangvik <einaros@gmail.com> - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# options.js # + +A very light-weight in-code option parsers for node.js. + +## Usage ## + +``` js +var Options = require("options"); + +// Create an Options object +function foo(options) { + var default_options = { + foo : "bar" + }; + + // Create an option object with default value + var opts = new Options(default_options); + + // Merge options + opts = opts.merge(options); + + // Reset to default value + opts.reset(); + + // Copy selected attributes out + var seled_att = opts.copy("foo"); + + // Read json options from a file. + opts.read("options.file"); // Sync + opts.read("options.file", function(err){ // Async + if(err){ // If error occurs + console.log("File error."); + }else{ + // No error + } + }); + + // Attributes defined or not + opts.isDefinedAndNonNull("foobar"); + opts.isDefined("foobar"); +} + +``` + + +## License ## + +(The MIT License) + +Copyright (c) 2012 Einar Otto Stangvik <einaros@gmail.com> + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/options/lib/options.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/options/lib/options.js index 4613a206..4fc45e90 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/options/lib/options.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/options/lib/options.js @@ -1,86 +1,86 @@ -/*! - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - -var fs = require('fs'); - -function Options(defaults) { - var internalValues = {}; - var values = this.value = {}; - Object.keys(defaults).forEach(function(key) { - internalValues[key] = defaults[key]; - Object.defineProperty(values, key, { - get: function() { return internalValues[key]; }, - configurable: false, - enumerable: true - }); - }); - this.reset = function() { - Object.keys(defaults).forEach(function(key) { - internalValues[key] = defaults[key]; - }); - return this; - }; - this.merge = function(options, required) { - options = options || {}; - if (Object.prototype.toString.call(required) === '[object Array]') { - var missing = []; - for (var i = 0, l = required.length; i < l; ++i) { - var key = required[i]; - if (!(key in options)) { - missing.push(key); - } - } - if (missing.length > 0) { - if (missing.length > 1) { - throw new Error('options ' + - missing.slice(0, missing.length - 1).join(', ') + ' and ' + - missing[missing.length - 1] + ' must be defined'); - } - else throw new Error('option ' + missing[0] + ' must be defined'); - } - } - Object.keys(options).forEach(function(key) { - if (key in internalValues) { - internalValues[key] = options[key]; - } - }); - return this; - }; - this.copy = function(keys) { - var obj = {}; - Object.keys(defaults).forEach(function(key) { - if (keys.indexOf(key) !== -1) { - obj[key] = values[key]; - } - }); - return obj; - }; - this.read = function(filename, cb) { - if (typeof cb == 'function') { - var self = this; - fs.readFile(filename, function(error, data) { - if (error) return cb(error); - var conf = JSON.parse(data); - self.merge(conf); - cb(); - }); - } - else { - var conf = JSON.parse(fs.readFileSync(filename)); - this.merge(conf); - } - return this; - }; - this.isDefined = function(key) { - return typeof values[key] != 'undefined'; - }; - this.isDefinedAndNonNull = function(key) { - return typeof values[key] != 'undefined' && values[key] !== null; - }; - Object.freeze(values); - Object.freeze(this); -} - -module.exports = Options; +/*! + * Copyright(c) 2011 Einar Otto Stangvik + * MIT Licensed + */ + +var fs = require('fs'); + +function Options(defaults) { + var internalValues = {}; + var values = this.value = {}; + Object.keys(defaults).forEach(function(key) { + internalValues[key] = defaults[key]; + Object.defineProperty(values, key, { + get: function() { return internalValues[key]; }, + configurable: false, + enumerable: true + }); + }); + this.reset = function() { + Object.keys(defaults).forEach(function(key) { + internalValues[key] = defaults[key]; + }); + return this; + }; + this.merge = function(options, required) { + options = options || {}; + if (Object.prototype.toString.call(required) === '[object Array]') { + var missing = []; + for (var i = 0, l = required.length; i < l; ++i) { + var key = required[i]; + if (!(key in options)) { + missing.push(key); + } + } + if (missing.length > 0) { + if (missing.length > 1) { + throw new Error('options ' + + missing.slice(0, missing.length - 1).join(', ') + ' and ' + + missing[missing.length - 1] + ' must be defined'); + } + else throw new Error('option ' + missing[0] + ' must be defined'); + } + } + Object.keys(options).forEach(function(key) { + if (key in internalValues) { + internalValues[key] = options[key]; + } + }); + return this; + }; + this.copy = function(keys) { + var obj = {}; + Object.keys(defaults).forEach(function(key) { + if (keys.indexOf(key) !== -1) { + obj[key] = values[key]; + } + }); + return obj; + }; + this.read = function(filename, cb) { + if (typeof cb == 'function') { + var self = this; + fs.readFile(filename, function(error, data) { + if (error) return cb(error); + var conf = JSON.parse(data); + self.merge(conf); + cb(); + }); + } + else { + var conf = JSON.parse(fs.readFileSync(filename)); + this.merge(conf); + } + return this; + }; + this.isDefined = function(key) { + return typeof values[key] != 'undefined'; + }; + this.isDefinedAndNonNull = function(key) { + return typeof values[key] != 'undefined' && values[key] !== null; + }; + Object.freeze(values); + Object.freeze(this); +} + +module.exports = Options; diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/options/package.json b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/options/package.json index 7637843f..f60bb1ab 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/options/package.json +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/options/package.json @@ -1,51 +1,51 @@ -{ - "author": { - "name": "Einar Otto Stangvik", - "email": "einaros@gmail.com", - "url": "http://2x.io" - }, - "name": "options", - "description": "A very light-weight in-code option parsers for node.js.", - "version": "0.0.6", - "repository": { - "type": "git", - "url": "git://github.com/einaros/options.js.git" - }, - "main": "lib/options", - "scripts": { - "test": "make test" - }, - "engines": { - "node": ">=0.4.0" - }, - "dependencies": {}, - "devDependencies": { - "mocha": "latest" - }, - "gitHead": "ff53d0a092c897cb95964232a96fe17da65c11af", - "bugs": { - "url": "https://github.com/einaros/options.js/issues" - }, - "homepage": "https://github.com/einaros/options.js", - "_id": "options@0.0.6", - "_shasum": "ec22d312806bb53e731773e7cdaefcf1c643128f", - "_from": "options@>=0.0.5", - "_npmVersion": "1.4.21", - "_npmUser": { - "name": "einaros", - "email": "einaros@gmail.com" - }, - "maintainers": [ - { - "name": "einaros", - "email": "einaros@gmail.com" - } - ], - "dist": { - "shasum": "ec22d312806bb53e731773e7cdaefcf1c643128f", - "tarball": "https://registry.npmjs.org/options/-/options-0.0.6.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/options/-/options-0.0.6.tgz", - "readme": "ERROR: No README data found!" -} +{ + "author": { + "name": "Einar Otto Stangvik", + "email": "einaros@gmail.com", + "url": "http://2x.io" + }, + "name": "options", + "description": "A very light-weight in-code option parsers for node.js.", + "version": "0.0.6", + "repository": { + "type": "git", + "url": "git://github.com/einaros/options.js.git" + }, + "main": "lib/options", + "scripts": { + "test": "make test" + }, + "engines": { + "node": ">=0.4.0" + }, + "dependencies": {}, + "devDependencies": { + "mocha": "latest" + }, + "gitHead": "ff53d0a092c897cb95964232a96fe17da65c11af", + "bugs": { + "url": "https://github.com/einaros/options.js/issues" + }, + "homepage": "https://github.com/einaros/options.js", + "_id": "options@0.0.6", + "_shasum": "ec22d312806bb53e731773e7cdaefcf1c643128f", + "_from": "options@>=0.0.5", + "_npmVersion": "1.4.21", + "_npmUser": { + "name": "einaros", + "email": "einaros@gmail.com" + }, + "maintainers": [ + { + "name": "einaros", + "email": "einaros@gmail.com" + } + ], + "dist": { + "shasum": "ec22d312806bb53e731773e7cdaefcf1c643128f", + "tarball": "https://registry.npmjs.org/options/-/options-0.0.6.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/options/-/options-0.0.6.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/ultron/.npmignore b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/ultron/.npmignore index 0f365f6b..66210a2a 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/ultron/.npmignore +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/ultron/.npmignore @@ -1,3 +1,3 @@ -node_modules -coverage -.tern-port +node_modules +coverage +.tern-port diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/ultron/.travis.yml b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/ultron/.travis.yml index 0cd5e506..a505004b 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/ultron/.travis.yml +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/ultron/.travis.yml @@ -1,21 +1,21 @@ -sudo: false -language: node_js -node_js: - - "0.12" - - "0.10" - - "0.8" - - "iojs" -before_install: - - 'if [ "${TRAVIS_NODE_VERSION}" == "0.8" ]; then npm install -g npm@2.11.1; fi' -script: - - "npm run test-travis" -after_script: - - "npm install coveralls@2.11.x && cat coverage/lcov.info | coveralls" -matrix: - fast_finish: true -notifications: - irc: - channels: - - "irc.freenode.org#unshift" - on_success: change - on_failure: change +sudo: false +language: node_js +node_js: + - "0.12" + - "0.10" + - "0.8" + - "iojs" +before_install: + - 'if [ "${TRAVIS_NODE_VERSION}" == "0.8" ]; then npm install -g npm@2.11.1; fi' +script: + - "npm run test-travis" +after_script: + - "npm install coveralls@2.11.x && cat coverage/lcov.info | coveralls" +matrix: + fast_finish: true +notifications: + irc: + channels: + - "irc.freenode.org#unshift" + on_success: change + on_failure: change diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/ultron/LICENSE b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/ultron/LICENSE index 87bcc3bc..6dc9316a 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/ultron/LICENSE +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/ultron/LICENSE @@ -1,22 +1,22 @@ -The MIT License (MIT) - -Copyright (c) 2015 Unshift.io, Arnout Kazemier, the Contributors. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - +The MIT License (MIT) + +Copyright (c) 2015 Unshift.io, Arnout Kazemier, the Contributors. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/ultron/README.md b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/ultron/README.md index 521cf11f..84fa3f23 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/ultron/README.md +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/ultron/README.md @@ -1,97 +1,97 @@ -# Ultron - -[![Made by unshift](https://img.shields.io/badge/made%20by-unshift-00ffcc.svg?style=flat-square)](http://unshift.io)[![Version npm](http://img.shields.io/npm/v/ultron.svg?style=flat-square)](http://browsenpm.org/package/ultron)[![Build Status](http://img.shields.io/travis/unshiftio/ultron/master.svg?style=flat-square)](https://travis-ci.org/unshiftio/ultron)[![Dependencies](https://img.shields.io/david/unshiftio/ultron.svg?style=flat-square)](https://david-dm.org/unshiftio/ultron)[![Coverage Status](http://img.shields.io/coveralls/unshiftio/ultron/master.svg?style=flat-square)](https://coveralls.io/r/unshiftio/ultron?branch=master)[![IRC channel](http://img.shields.io/badge/IRC-irc.freenode.net%23unshift-00a8ff.svg?style=flat-square)](http://webchat.freenode.net/?channels=unshift) - -Ultron is a high-intelligence robot. It gathers intelligence so it can start -improving upon his rudimentary design. It will learn your event emitting -patterns and find ways to exterminate them. Allowing you to remove only the -event emitters that **you** assigned and not the ones that your users or -developers assigned. This can prevent race conditions, memory leaks and even file -descriptor leaks from ever happening as you won't remove clean up processes. - -## Installation - -The module is designed to be used in browsers using browserify and in Node.js. -You can install the module through the public npm registry by running the -following command in CLI: - -``` -npm install --save ultron -``` - -## Usage - -In all examples we assume that you've required the library as following: - -```js -'use strict'; - -var Ultron = require('ultron'); -``` - -Now that we've required the library we can construct our first `Ultron` instance. -The constructor requires one argument which should be the `EventEmitter` -instance that we need to operate upon. This can be the `EventEmitter` module -that ships with Node.js or `EventEmitter3` or anything else as long as it -follow the same API and internal structure as these 2. So with that in mind we -can create the instance: - -```js -// -// For the sake of this example we're going to construct an empty EventEmitter -// -var EventEmitter = require('events').EventEmitter; // or require('eventmitter3'); -var events = new EventEmitter(); - -var ultron = new Ultron(events); -``` - -You can now use the following API's from the Ultron instance: - -### Ultron.on - -Register a new event listener for the given event. It follows the exact same API -as `EventEmitter.on` but it will return itself instead of returning the -EventEmitter instance. If you are using EventEmitter3 it also supports the -context param: - -```js -ultron.on('event-name', handler, { custom: 'function context' }); -``` - -### Ultron.once - -Exactly the same as the [Ultron.on](#ultronon) but it only allows the execution -once. - -### Ultron.remove - -This is where all the magic happens and the safe removal starts. This function -accepts different argument styles: - -- No arguments, assume that all events need to be removed so it will work as - `removeAllListeners()` API. -- 1 argument, when it's a string it will be split on ` ` and `,` to create a - list of events that need to be cleared. -- Multiple arguments, we assume that they are all names of events that need to - be cleared. - -```js -ultron.remove('foo, bar baz'); // Removes foo, bar and baz. -ultron.remove('foo', 'bar', 'baz'); // Removes foo, bar and baz. -ultron.remove(); // Removes everything. -``` - -If you just want to remove a single event listener using a function reference -you can still use the EventEmitter's `removeListener(event, fn)` API: - -```js -function foo() {} - -ulton.on('foo', foo); -events.removeListener('foo', foo); -``` - -## License - -MIT +# Ultron + +[![Made by unshift](https://img.shields.io/badge/made%20by-unshift-00ffcc.svg?style=flat-square)](http://unshift.io)[![Version npm](http://img.shields.io/npm/v/ultron.svg?style=flat-square)](http://browsenpm.org/package/ultron)[![Build Status](http://img.shields.io/travis/unshiftio/ultron/master.svg?style=flat-square)](https://travis-ci.org/unshiftio/ultron)[![Dependencies](https://img.shields.io/david/unshiftio/ultron.svg?style=flat-square)](https://david-dm.org/unshiftio/ultron)[![Coverage Status](http://img.shields.io/coveralls/unshiftio/ultron/master.svg?style=flat-square)](https://coveralls.io/r/unshiftio/ultron?branch=master)[![IRC channel](http://img.shields.io/badge/IRC-irc.freenode.net%23unshift-00a8ff.svg?style=flat-square)](http://webchat.freenode.net/?channels=unshift) + +Ultron is a high-intelligence robot. It gathers intelligence so it can start +improving upon his rudimentary design. It will learn your event emitting +patterns and find ways to exterminate them. Allowing you to remove only the +event emitters that **you** assigned and not the ones that your users or +developers assigned. This can prevent race conditions, memory leaks and even file +descriptor leaks from ever happening as you won't remove clean up processes. + +## Installation + +The module is designed to be used in browsers using browserify and in Node.js. +You can install the module through the public npm registry by running the +following command in CLI: + +``` +npm install --save ultron +``` + +## Usage + +In all examples we assume that you've required the library as following: + +```js +'use strict'; + +var Ultron = require('ultron'); +``` + +Now that we've required the library we can construct our first `Ultron` instance. +The constructor requires one argument which should be the `EventEmitter` +instance that we need to operate upon. This can be the `EventEmitter` module +that ships with Node.js or `EventEmitter3` or anything else as long as it +follow the same API and internal structure as these 2. So with that in mind we +can create the instance: + +```js +// +// For the sake of this example we're going to construct an empty EventEmitter +// +var EventEmitter = require('events').EventEmitter; // or require('eventmitter3'); +var events = new EventEmitter(); + +var ultron = new Ultron(events); +``` + +You can now use the following API's from the Ultron instance: + +### Ultron.on + +Register a new event listener for the given event. It follows the exact same API +as `EventEmitter.on` but it will return itself instead of returning the +EventEmitter instance. If you are using EventEmitter3 it also supports the +context param: + +```js +ultron.on('event-name', handler, { custom: 'function context' }); +``` + +### Ultron.once + +Exactly the same as the [Ultron.on](#ultronon) but it only allows the execution +once. + +### Ultron.remove + +This is where all the magic happens and the safe removal starts. This function +accepts different argument styles: + +- No arguments, assume that all events need to be removed so it will work as + `removeAllListeners()` API. +- 1 argument, when it's a string it will be split on ` ` and `,` to create a + list of events that need to be cleared. +- Multiple arguments, we assume that they are all names of events that need to + be cleared. + +```js +ultron.remove('foo, bar baz'); // Removes foo, bar and baz. +ultron.remove('foo', 'bar', 'baz'); // Removes foo, bar and baz. +ultron.remove(); // Removes everything. +``` + +If you just want to remove a single event listener using a function reference +you can still use the EventEmitter's `removeListener(event, fn)` API: + +```js +function foo() {} + +ulton.on('foo', foo); +events.removeListener('foo', foo); +``` + +## License + +MIT diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/ultron/index.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/ultron/index.js index b343837b..af17ab7c 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/ultron/index.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/ultron/index.js @@ -1,129 +1,129 @@ -'use strict'; - -var has = Object.prototype.hasOwnProperty; - -/** - * An auto incrementing id which we can use to create "unique" Ultron instances - * so we can track the event emitters that are added through the Ultron - * interface. - * - * @type {Number} - * @private - */ -var id = 0; - -/** - * Ultron is high-intelligence robot. It gathers intelligence so it can start improving - * upon his rudimentary design. It will learn from your EventEmitting patterns - * and exterminate them. - * - * @constructor - * @param {EventEmitter} ee EventEmitter instance we need to wrap. - * @api public - */ -function Ultron(ee) { - if (!(this instanceof Ultron)) return new Ultron(ee); - - this.id = id++; - this.ee = ee; -} - -/** - * Register a new EventListener for the given event. - * - * @param {String} event Name of the event. - * @param {Functon} fn Callback function. - * @param {Mixed} context The context of the function. - * @returns {Ultron} - * @api public - */ -Ultron.prototype.on = function on(event, fn, context) { - fn.__ultron = this.id; - this.ee.on(event, fn, context); - - return this; -}; -/** - * Add an EventListener that's only called once. - * - * @param {String} event Name of the event. - * @param {Function} fn Callback function. - * @param {Mixed} context The context of the function. - * @returns {Ultron} - * @api public - */ -Ultron.prototype.once = function once(event, fn, context) { - fn.__ultron = this.id; - this.ee.once(event, fn, context); - - return this; -}; - -/** - * Remove the listeners we assigned for the given event. - * - * @returns {Ultron} - * @api public - */ -Ultron.prototype.remove = function remove() { - var args = arguments - , event; - - // - // When no event names are provided we assume that we need to clear all the - // events that were assigned through us. - // - if (args.length === 1 && 'string' === typeof args[0]) { - args = args[0].split(/[, ]+/); - } else if (!args.length) { - args = []; - - for (event in this.ee._events) { - if (has.call(this.ee._events, event)) args.push(event); - } - } - - for (var i = 0; i < args.length; i++) { - var listeners = this.ee.listeners(args[i]); - - for (var j = 0; j < listeners.length; j++) { - event = listeners[j]; - - // - // Once listeners have a `listener` property that stores the real listener - // in the EventEmitter that ships with Node.js. - // - if (event.listener) { - if (event.listener.__ultron !== this.id) continue; - delete event.listener.__ultron; - } else { - if (event.__ultron !== this.id) continue; - delete event.__ultron; - } - - this.ee.removeListener(args[i], event); - } - } - - return this; -}; - -/** - * Destroy the Ultron instance, remove all listeners and release all references. - * - * @returns {Boolean} - * @api public - */ -Ultron.prototype.destroy = function destroy() { - if (!this.ee) return false; - - this.remove(); - this.ee = null; - - return true; -}; - -// -// Expose the module. -// -module.exports = Ultron; +'use strict'; + +var has = Object.prototype.hasOwnProperty; + +/** + * An auto incrementing id which we can use to create "unique" Ultron instances + * so we can track the event emitters that are added through the Ultron + * interface. + * + * @type {Number} + * @private + */ +var id = 0; + +/** + * Ultron is high-intelligence robot. It gathers intelligence so it can start improving + * upon his rudimentary design. It will learn from your EventEmitting patterns + * and exterminate them. + * + * @constructor + * @param {EventEmitter} ee EventEmitter instance we need to wrap. + * @api public + */ +function Ultron(ee) { + if (!(this instanceof Ultron)) return new Ultron(ee); + + this.id = id++; + this.ee = ee; +} + +/** + * Register a new EventListener for the given event. + * + * @param {String} event Name of the event. + * @param {Functon} fn Callback function. + * @param {Mixed} context The context of the function. + * @returns {Ultron} + * @api public + */ +Ultron.prototype.on = function on(event, fn, context) { + fn.__ultron = this.id; + this.ee.on(event, fn, context); + + return this; +}; +/** + * Add an EventListener that's only called once. + * + * @param {String} event Name of the event. + * @param {Function} fn Callback function. + * @param {Mixed} context The context of the function. + * @returns {Ultron} + * @api public + */ +Ultron.prototype.once = function once(event, fn, context) { + fn.__ultron = this.id; + this.ee.once(event, fn, context); + + return this; +}; + +/** + * Remove the listeners we assigned for the given event. + * + * @returns {Ultron} + * @api public + */ +Ultron.prototype.remove = function remove() { + var args = arguments + , event; + + // + // When no event names are provided we assume that we need to clear all the + // events that were assigned through us. + // + if (args.length === 1 && 'string' === typeof args[0]) { + args = args[0].split(/[, ]+/); + } else if (!args.length) { + args = []; + + for (event in this.ee._events) { + if (has.call(this.ee._events, event)) args.push(event); + } + } + + for (var i = 0; i < args.length; i++) { + var listeners = this.ee.listeners(args[i]); + + for (var j = 0; j < listeners.length; j++) { + event = listeners[j]; + + // + // Once listeners have a `listener` property that stores the real listener + // in the EventEmitter that ships with Node.js. + // + if (event.listener) { + if (event.listener.__ultron !== this.id) continue; + delete event.listener.__ultron; + } else { + if (event.__ultron !== this.id) continue; + delete event.__ultron; + } + + this.ee.removeListener(args[i], event); + } + } + + return this; +}; + +/** + * Destroy the Ultron instance, remove all listeners and release all references. + * + * @returns {Boolean} + * @api public + */ +Ultron.prototype.destroy = function destroy() { + if (!this.ee) return false; + + this.remove(); + this.ee = null; + + return true; +}; + +// +// Expose the module. +// +module.exports = Ultron; diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/ultron/package.json b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/ultron/package.json index 120da130..258514a3 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/ultron/package.json +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/ultron/package.json @@ -1,74 +1,74 @@ -{ - "name": "ultron", - "version": "1.0.2", - "description": "Ultron is high-intelligence robot. It gathers intel so it can start improving upon his rudimentary design", - "main": "index.js", - "scripts": { - "100%": "istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100", - "test": "mocha test.js", - "watch": "mocha --watch test.js", - "coverage": "istanbul cover ./node_modules/.bin/_mocha -- test.js", - "test-travis": "istanbul cover node_modules/.bin/_mocha --report lcovonly -- test.js" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/unshiftio/ultron.git" - }, - "keywords": [ - "Ultron", - "robot", - "gather", - "intelligence", - "event", - "events", - "eventemitter", - "emitter", - "cleanup" - ], - "author": { - "name": "Arnout Kazemier" - }, - "license": "MIT", - "devDependencies": { - "assume": "1.2.x", - "eventemitter3": "1.1.x", - "istanbul": "0.3.x", - "mocha": "2.2.x", - "pre-commit": "1.0.x" - }, - "bugs": { - "url": "https://github.com/unshiftio/ultron/issues" - }, - "homepage": "https://github.com/unshiftio/ultron", - "gitHead": "a10482ae98a09120821545456c90c6d60d540f7c", - "_id": "ultron@1.0.2", - "_shasum": "ace116ab557cd197386a4e88f4685378c8b2e4fa", - "_from": "ultron@>=1.0.0 <1.1.0", - "_npmVersion": "2.9.1", - "_nodeVersion": "0.12.3", - "_npmUser": { - "name": "3rdeden", - "email": "npm@3rd-Eden.com" - }, - "maintainers": [ - { - "name": "unshift", - "email": "npm@unshift.io" - }, - { - "name": "v1", - "email": "info@3rd-Eden.com" - }, - { - "name": "3rdeden", - "email": "npm@3rd-Eden.com" - } - ], - "dist": { - "shasum": "ace116ab557cd197386a4e88f4685378c8b2e4fa", - "tarball": "https://registry.npmjs.org/ultron/-/ultron-1.0.2.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/ultron/-/ultron-1.0.2.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "ultron", + "version": "1.0.2", + "description": "Ultron is high-intelligence robot. It gathers intel so it can start improving upon his rudimentary design", + "main": "index.js", + "scripts": { + "100%": "istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100", + "test": "mocha test.js", + "watch": "mocha --watch test.js", + "coverage": "istanbul cover ./node_modules/.bin/_mocha -- test.js", + "test-travis": "istanbul cover node_modules/.bin/_mocha --report lcovonly -- test.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/unshiftio/ultron.git" + }, + "keywords": [ + "Ultron", + "robot", + "gather", + "intelligence", + "event", + "events", + "eventemitter", + "emitter", + "cleanup" + ], + "author": { + "name": "Arnout Kazemier" + }, + "license": "MIT", + "devDependencies": { + "assume": "1.2.x", + "eventemitter3": "1.1.x", + "istanbul": "0.3.x", + "mocha": "2.2.x", + "pre-commit": "1.0.x" + }, + "bugs": { + "url": "https://github.com/unshiftio/ultron/issues" + }, + "homepage": "https://github.com/unshiftio/ultron", + "gitHead": "a10482ae98a09120821545456c90c6d60d540f7c", + "_id": "ultron@1.0.2", + "_shasum": "ace116ab557cd197386a4e88f4685378c8b2e4fa", + "_from": "ultron@>=1.0.0 <1.1.0", + "_npmVersion": "2.9.1", + "_nodeVersion": "0.12.3", + "_npmUser": { + "name": "3rdeden", + "email": "npm@3rd-Eden.com" + }, + "maintainers": [ + { + "name": "unshift", + "email": "npm@unshift.io" + }, + { + "name": "v1", + "email": "info@3rd-Eden.com" + }, + { + "name": "3rdeden", + "email": "npm@3rd-Eden.com" + } + ], + "dist": { + "shasum": "ace116ab557cd197386a4e88f4685378c8b2e4fa", + "tarball": "https://registry.npmjs.org/ultron/-/ultron-1.0.2.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/ultron/-/ultron-1.0.2.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/ultron/test.js b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/ultron/test.js index b0fbd28e..1fd4f1bb 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/ultron/test.js +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/ultron/test.js @@ -1,327 +1,327 @@ -/* istanbul ignore next */ -describe('Ultron', function () { - 'use strict'; - - var EventEmitter = require('eventemitter3') - , EE = require('events').EventEmitter - , assume = require('assume') - , Ultron = require('./') - , ultron - , ee; - - beforeEach(function () { - ee = new EventEmitter(); - ultron = new Ultron(ee); - }); - - afterEach(function () { - ultron.destroy(); - ee.removeAllListeners(); - }); - - it('is exposed as a function', function () { - assume(Ultron).is.a('function'); - }); - - it('can be initialized without the new keyword', function () { - assume(Ultron(ee)).is.instanceOf(Ultron); - }); - - it('assigns a unique id to every instance', function () { - for (var i = 0; i < 100; i++) { - assume(ultron.id).does.not.equal((new Ultron()).id); - } - }); - - it('allows removal through the event emitter', function () { - function foo() {} - function bar() {} - - ultron.on('foo', foo); - ultron.once('foo', bar); - - assume(foo.__ultron).equals(ultron.id); - assume(bar.__ultron).equals(ultron.id); - assume(ee.listeners('foo').length).equals(2); - - ee.removeListener('foo', foo); - assume(ee.listeners('foo').length).equals(1); - - ee.removeListener('foo', bar); - assume(ee.listeners('foo').length).equals(0); - }); - - describe('#on', function () { - it('assigns a listener', function () { - assume(ee.listeners('foo').length).equals(0); - - function foo() {} - - ultron.on('foo', foo); - assume(ee.listeners('foo').length).equals(1); - assume(ee.listeners('foo')[0]).equals(foo); - }); - - it('tags the assigned function', function () { - assume(ee.listeners('foo').length).equals(0); - - ultron.on('foo', function () {}); - assume(ee.listeners('foo')[0].__ultron).equals(ultron.id); - }); - - it('also passes in the context', function (next) { - var context = 1313; - - ultron.on('foo', function (a, b, c) { - assume(a).equals('a'); - assume(b).equals('b'); - assume(c).equals('c'); - - assume(this).equals(context); - - next(); - }, context); - - ee.emit('foo', 'a', 'b', 'c'); - }); - - it('works with regular eventemitters as well', function (next) { - var ee = new EE() - , ultron = new Ultron(ee); - - ultron.on('foo', function (a, b, c) { - assume(a).equals('a'); - assume(b).equals('b'); - assume(c).equals('c'); - - next(); - }); - - ee.emit('foo', 'a', 'b', 'c'); - }); - }); - - describe('#once', function () { - it('assigns a listener', function () { - assume(ee.listeners('foo').length).equals(0); - - function foo() {} - ultron.once('foo', foo); - assume(ee.listeners('foo').length).equals(1); - assume(ee.listeners('foo')[0]).equals(foo); - }); - - it('tags the assigned function', function () { - assume(ee.listeners('foo').length).equals(0); - - ultron.once('foo', function () {}); - assume(ee.listeners('foo')[0].__ultron).equals(ultron.id); - }); - - it('also passes in the context', function (next) { - var context = 1313; - - ultron.once('foo', function (a, b, c) { - assume(a).equals('a'); - assume(b).equals('b'); - assume(c).equals('c'); - - assume(this).equals(context); - - next(); - }, context); - - ee.emit('foo', 'a', 'b', 'c'); - ee.emit('foo', 'a', 'b', 'c'); // Ensure that we don't double execute - }); - - it('works with regular eventemitters as well', function (next) { - var ee = new EE() - , ultron = new Ultron(ee); - - ultron.once('foo', function (a, b, c) { - assume(a).equals('a'); - assume(b).equals('b'); - assume(c).equals('c'); - - next(); - }); - - ee.emit('foo', 'a', 'b', 'c'); - ee.emit('foo', 'a', 'b', 'c'); // Ensure that we don't double execute - }); - }); - - describe('#remove', function () { - it('removes only our assigned `on` listeners', function () { - function foo() {} - function bar() {} - - ee.on('foo', foo); - ultron.on('foo', bar); - assume(ee.listeners('foo').length).equals(2); - - ultron.remove('foo'); - assume(ee.listeners('foo').length).equals(1); - assume(ee.listeners('foo')[0]).equals(foo); - }); - - it('removes our private __ultron references', function () { - function once() {} - function on() {} - - assume('__ultron' in once).is.false(); - assume('__ultron' in on).is.false(); - - ultron.on('foo', on); - ultron.once('bar', once); - - assume('__ultron' in once).is.true(); - assume('__ultron' in on).is.true(); - - ultron.remove('foo, bar'); - - assume('__ultron' in once).is.false(); - assume('__ultron' in on).is.false(); - - ultron.destroy(); - - ee = new EE(); - ultron = new Ultron(ee); - - assume('__ultron' in once).is.false(); - assume('__ultron' in on).is.false(); - - ultron.on('foo', on); - ultron.once('bar', once); - - assume('__ultron' in once).is.true(); - assume('__ultron' in on).is.true(); - - ultron.remove('foo, bar'); - - assume('__ultron' in once).is.false(); - assume('__ultron' in on).is.false(); - }); - - it('removes only our assigned `once` listeners', function () { - function foo() {} - function bar() {} - - ee.once('foo', foo); - ultron.once('foo', bar); - assume(ee.listeners('foo').length).equals(2); - - ultron.remove('foo'); - assume(ee.listeners('foo').length).equals(1); - assume(ee.listeners('foo')[0]).equals(foo); - }); - - it('removes only our assigned `once` listeners from regular EE', function () { - var ee = new EE() - , ultron = new Ultron(ee); - - function foo() {} - function bar() {} - - ee.once('foo', foo); - ultron.once('foo', bar); - assume(ee.listeners('foo').length).equals(2); - - ultron.remove('foo'); - assume(ee.listeners('foo').length).equals(1); - assume(ee.listeners('foo')[0].listener).equals(foo); - }); - - it('removes all assigned events if called without args', function () { - function foo() {} - function bar() {} - - ultron.on('foo', foo); - ultron.on('bar', bar); - - assume(ee.listeners('foo').length).equals(1); - assume(ee.listeners('bar').length).equals(1); - - ultron.remove(); - - assume(ee.listeners('foo').length).equals(0); - assume(ee.listeners('bar').length).equals(0); - }); - - it('removes multiple listeners based on args', function () { - function foo() {} - function bar() {} - function baz() {} - - ultron.on('foo', foo); - ultron.on('bar', bar); - ultron.on('baz', baz); - - assume(ee.listeners('foo').length).equals(1); - assume(ee.listeners('bar').length).equals(1); - assume(ee.listeners('baz').length).equals(1); - - ultron.remove('foo', 'bar'); - - assume(ee.listeners('foo').length).equals(0); - assume(ee.listeners('bar').length).equals(0); - assume(ee.listeners('baz').length).equals(1); - }); - - it('removes multiple listeners if first arg is seperated string', function () { - function foo() {} - function bar() {} - function baz() {} - - ultron.on('foo', foo); - ultron.on('bar', bar); - ultron.on('baz', baz); - - assume(ee.listeners('foo').length).equals(1); - assume(ee.listeners('bar').length).equals(1); - assume(ee.listeners('baz').length).equals(1); - - ultron.remove('foo, bar'); - - assume(ee.listeners('foo').length).equals(0); - assume(ee.listeners('bar').length).equals(0); - assume(ee.listeners('baz').length).equals(1); - }); - }); - - describe('#destroy', function () { - it('removes all listeners', function () { - function foo() {} - function bar() {} - function baz() {} - - ultron.on('foo', foo); - ultron.on('bar', bar); - ultron.on('baz', baz); - - assume(ee.listeners('foo').length).equals(1); - assume(ee.listeners('bar').length).equals(1); - assume(ee.listeners('baz').length).equals(1); - - ultron.destroy(); - - assume(ee.listeners('foo').length).equals(0); - assume(ee.listeners('bar').length).equals(0); - assume(ee.listeners('baz').length).equals(0); - }); - - it('removes the .ee reference', function () { - assume(ultron.ee).equals(ee); - ultron.destroy(); - assume(ultron.ee).equals(null); - }); - - it('returns booleans for state indication', function () { - assume(ultron.destroy()).is.true(); - assume(ultron.destroy()).is.false(); - assume(ultron.destroy()).is.false(); - assume(ultron.destroy()).is.false(); - }); - }); -}); +/* istanbul ignore next */ +describe('Ultron', function () { + 'use strict'; + + var EventEmitter = require('eventemitter3') + , EE = require('events').EventEmitter + , assume = require('assume') + , Ultron = require('./') + , ultron + , ee; + + beforeEach(function () { + ee = new EventEmitter(); + ultron = new Ultron(ee); + }); + + afterEach(function () { + ultron.destroy(); + ee.removeAllListeners(); + }); + + it('is exposed as a function', function () { + assume(Ultron).is.a('function'); + }); + + it('can be initialized without the new keyword', function () { + assume(Ultron(ee)).is.instanceOf(Ultron); + }); + + it('assigns a unique id to every instance', function () { + for (var i = 0; i < 100; i++) { + assume(ultron.id).does.not.equal((new Ultron()).id); + } + }); + + it('allows removal through the event emitter', function () { + function foo() {} + function bar() {} + + ultron.on('foo', foo); + ultron.once('foo', bar); + + assume(foo.__ultron).equals(ultron.id); + assume(bar.__ultron).equals(ultron.id); + assume(ee.listeners('foo').length).equals(2); + + ee.removeListener('foo', foo); + assume(ee.listeners('foo').length).equals(1); + + ee.removeListener('foo', bar); + assume(ee.listeners('foo').length).equals(0); + }); + + describe('#on', function () { + it('assigns a listener', function () { + assume(ee.listeners('foo').length).equals(0); + + function foo() {} + + ultron.on('foo', foo); + assume(ee.listeners('foo').length).equals(1); + assume(ee.listeners('foo')[0]).equals(foo); + }); + + it('tags the assigned function', function () { + assume(ee.listeners('foo').length).equals(0); + + ultron.on('foo', function () {}); + assume(ee.listeners('foo')[0].__ultron).equals(ultron.id); + }); + + it('also passes in the context', function (next) { + var context = 1313; + + ultron.on('foo', function (a, b, c) { + assume(a).equals('a'); + assume(b).equals('b'); + assume(c).equals('c'); + + assume(this).equals(context); + + next(); + }, context); + + ee.emit('foo', 'a', 'b', 'c'); + }); + + it('works with regular eventemitters as well', function (next) { + var ee = new EE() + , ultron = new Ultron(ee); + + ultron.on('foo', function (a, b, c) { + assume(a).equals('a'); + assume(b).equals('b'); + assume(c).equals('c'); + + next(); + }); + + ee.emit('foo', 'a', 'b', 'c'); + }); + }); + + describe('#once', function () { + it('assigns a listener', function () { + assume(ee.listeners('foo').length).equals(0); + + function foo() {} + ultron.once('foo', foo); + assume(ee.listeners('foo').length).equals(1); + assume(ee.listeners('foo')[0]).equals(foo); + }); + + it('tags the assigned function', function () { + assume(ee.listeners('foo').length).equals(0); + + ultron.once('foo', function () {}); + assume(ee.listeners('foo')[0].__ultron).equals(ultron.id); + }); + + it('also passes in the context', function (next) { + var context = 1313; + + ultron.once('foo', function (a, b, c) { + assume(a).equals('a'); + assume(b).equals('b'); + assume(c).equals('c'); + + assume(this).equals(context); + + next(); + }, context); + + ee.emit('foo', 'a', 'b', 'c'); + ee.emit('foo', 'a', 'b', 'c'); // Ensure that we don't double execute + }); + + it('works with regular eventemitters as well', function (next) { + var ee = new EE() + , ultron = new Ultron(ee); + + ultron.once('foo', function (a, b, c) { + assume(a).equals('a'); + assume(b).equals('b'); + assume(c).equals('c'); + + next(); + }); + + ee.emit('foo', 'a', 'b', 'c'); + ee.emit('foo', 'a', 'b', 'c'); // Ensure that we don't double execute + }); + }); + + describe('#remove', function () { + it('removes only our assigned `on` listeners', function () { + function foo() {} + function bar() {} + + ee.on('foo', foo); + ultron.on('foo', bar); + assume(ee.listeners('foo').length).equals(2); + + ultron.remove('foo'); + assume(ee.listeners('foo').length).equals(1); + assume(ee.listeners('foo')[0]).equals(foo); + }); + + it('removes our private __ultron references', function () { + function once() {} + function on() {} + + assume('__ultron' in once).is.false(); + assume('__ultron' in on).is.false(); + + ultron.on('foo', on); + ultron.once('bar', once); + + assume('__ultron' in once).is.true(); + assume('__ultron' in on).is.true(); + + ultron.remove('foo, bar'); + + assume('__ultron' in once).is.false(); + assume('__ultron' in on).is.false(); + + ultron.destroy(); + + ee = new EE(); + ultron = new Ultron(ee); + + assume('__ultron' in once).is.false(); + assume('__ultron' in on).is.false(); + + ultron.on('foo', on); + ultron.once('bar', once); + + assume('__ultron' in once).is.true(); + assume('__ultron' in on).is.true(); + + ultron.remove('foo, bar'); + + assume('__ultron' in once).is.false(); + assume('__ultron' in on).is.false(); + }); + + it('removes only our assigned `once` listeners', function () { + function foo() {} + function bar() {} + + ee.once('foo', foo); + ultron.once('foo', bar); + assume(ee.listeners('foo').length).equals(2); + + ultron.remove('foo'); + assume(ee.listeners('foo').length).equals(1); + assume(ee.listeners('foo')[0]).equals(foo); + }); + + it('removes only our assigned `once` listeners from regular EE', function () { + var ee = new EE() + , ultron = new Ultron(ee); + + function foo() {} + function bar() {} + + ee.once('foo', foo); + ultron.once('foo', bar); + assume(ee.listeners('foo').length).equals(2); + + ultron.remove('foo'); + assume(ee.listeners('foo').length).equals(1); + assume(ee.listeners('foo')[0].listener).equals(foo); + }); + + it('removes all assigned events if called without args', function () { + function foo() {} + function bar() {} + + ultron.on('foo', foo); + ultron.on('bar', bar); + + assume(ee.listeners('foo').length).equals(1); + assume(ee.listeners('bar').length).equals(1); + + ultron.remove(); + + assume(ee.listeners('foo').length).equals(0); + assume(ee.listeners('bar').length).equals(0); + }); + + it('removes multiple listeners based on args', function () { + function foo() {} + function bar() {} + function baz() {} + + ultron.on('foo', foo); + ultron.on('bar', bar); + ultron.on('baz', baz); + + assume(ee.listeners('foo').length).equals(1); + assume(ee.listeners('bar').length).equals(1); + assume(ee.listeners('baz').length).equals(1); + + ultron.remove('foo', 'bar'); + + assume(ee.listeners('foo').length).equals(0); + assume(ee.listeners('bar').length).equals(0); + assume(ee.listeners('baz').length).equals(1); + }); + + it('removes multiple listeners if first arg is seperated string', function () { + function foo() {} + function bar() {} + function baz() {} + + ultron.on('foo', foo); + ultron.on('bar', bar); + ultron.on('baz', baz); + + assume(ee.listeners('foo').length).equals(1); + assume(ee.listeners('bar').length).equals(1); + assume(ee.listeners('baz').length).equals(1); + + ultron.remove('foo, bar'); + + assume(ee.listeners('foo').length).equals(0); + assume(ee.listeners('bar').length).equals(0); + assume(ee.listeners('baz').length).equals(1); + }); + }); + + describe('#destroy', function () { + it('removes all listeners', function () { + function foo() {} + function bar() {} + function baz() {} + + ultron.on('foo', foo); + ultron.on('bar', bar); + ultron.on('baz', baz); + + assume(ee.listeners('foo').length).equals(1); + assume(ee.listeners('bar').length).equals(1); + assume(ee.listeners('baz').length).equals(1); + + ultron.destroy(); + + assume(ee.listeners('foo').length).equals(0); + assume(ee.listeners('bar').length).equals(0); + assume(ee.listeners('baz').length).equals(0); + }); + + it('removes the .ee reference', function () { + assume(ultron.ee).equals(ee); + ultron.destroy(); + assume(ultron.ee).equals(null); + }); + + it('returns booleans for state indication', function () { + assume(ultron.destroy()).is.true(); + assume(ultron.destroy()).is.false(); + assume(ultron.destroy()).is.false(); + assume(ultron.destroy()).is.false(); + }); + }); +}); diff --git a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/package.json b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/package.json index 36dd7111..087c590d 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/package.json +++ b/ui/node_modules/socket.io/node_modules/engine.io/node_modules/ws/package.json @@ -1,82 +1,82 @@ -{ - "author": { - "name": "Einar Otto Stangvik", - "email": "einaros@gmail.com", - "url": "http://2x.io" - }, - "name": "ws", - "description": "simple to use, blazing fast and thoroughly tested websocket client, server and console for node.js, up-to-date against RFC-6455", - "version": "1.1.0", - "license": "MIT", - "main": "index.js", - "keywords": [ - "Hixie", - "HyBi", - "Push", - "RFC-6455", - "WebSocket", - "WebSockets", - "real-time" - ], - "repository": { - "type": "git", - "url": "git://github.com/websockets/ws.git" - }, - "scripts": { - "test": "make test" - }, - "dependencies": { - "options": ">=0.0.5", - "ultron": "1.0.x" - }, - "devDependencies": { - "ansi": "0.3.x", - "benchmark": "0.3.x", - "bufferutil": "1.2.x", - "expect.js": "0.3.x", - "istanbul": "^0.4.1", - "mocha": "2.3.x", - "should": "8.0.x", - "tinycolor": "0.0.x", - "utf-8-validate": "1.2.x" - }, - "gypfile": true, - "gitHead": "4263f26d4dbe27e781c41a1ddfe3dab87dd9e1dc", - "bugs": { - "url": "https://github.com/websockets/ws/issues" - }, - "homepage": "https://github.com/websockets/ws#readme", - "_id": "ws@1.1.0", - "_shasum": "c1d6fd1515d3ceff1f0ae2759bf5fd77030aad1d", - "_from": "ws@1.1.0", - "_npmVersion": "3.8.0", - "_nodeVersion": "4.3.1", - "_npmUser": { - "name": "3rdeden", - "email": "npm@3rd-Eden.com" - }, - "maintainers": [ - { - "name": "einaros", - "email": "einaros@gmail.com" - }, - { - "name": "v1", - "email": "info@3rd-Eden.com" - }, - { - "name": "3rdeden", - "email": "npm@3rd-Eden.com" - } - ], - "dist": { - "shasum": "c1d6fd1515d3ceff1f0ae2759bf5fd77030aad1d", - "tarball": "https://registry.npmjs.org/ws/-/ws-1.1.0.tgz" - }, - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/ws-1.1.0.tgz_1460376022305_0.992860296042636" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/ws/-/ws-1.1.0.tgz" -} +{ + "author": { + "name": "Einar Otto Stangvik", + "email": "einaros@gmail.com", + "url": "http://2x.io" + }, + "name": "ws", + "description": "simple to use, blazing fast and thoroughly tested websocket client, server and console for node.js, up-to-date against RFC-6455", + "version": "1.1.0", + "license": "MIT", + "main": "index.js", + "keywords": [ + "Hixie", + "HyBi", + "Push", + "RFC-6455", + "WebSocket", + "WebSockets", + "real-time" + ], + "repository": { + "type": "git", + "url": "git://github.com/websockets/ws.git" + }, + "scripts": { + "test": "make test" + }, + "dependencies": { + "options": ">=0.0.5", + "ultron": "1.0.x" + }, + "devDependencies": { + "ansi": "0.3.x", + "benchmark": "0.3.x", + "bufferutil": "1.2.x", + "expect.js": "0.3.x", + "istanbul": "^0.4.1", + "mocha": "2.3.x", + "should": "8.0.x", + "tinycolor": "0.0.x", + "utf-8-validate": "1.2.x" + }, + "gypfile": true, + "gitHead": "4263f26d4dbe27e781c41a1ddfe3dab87dd9e1dc", + "bugs": { + "url": "https://github.com/websockets/ws/issues" + }, + "homepage": "https://github.com/websockets/ws#readme", + "_id": "ws@1.1.0", + "_shasum": "c1d6fd1515d3ceff1f0ae2759bf5fd77030aad1d", + "_from": "ws@1.1.0", + "_npmVersion": "3.8.0", + "_nodeVersion": "4.3.1", + "_npmUser": { + "name": "3rdeden", + "email": "npm@3rd-Eden.com" + }, + "maintainers": [ + { + "name": "einaros", + "email": "einaros@gmail.com" + }, + { + "name": "v1", + "email": "info@3rd-Eden.com" + }, + { + "name": "3rdeden", + "email": "npm@3rd-Eden.com" + } + ], + "dist": { + "shasum": "c1d6fd1515d3ceff1f0ae2759bf5fd77030aad1d", + "tarball": "https://registry.npmjs.org/ws/-/ws-1.1.0.tgz" + }, + "_npmOperationalInternal": { + "host": "packages-16-east.internal.npmjs.com", + "tmp": "tmp/ws-1.1.0.tgz_1460376022305_0.992860296042636" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/ws/-/ws-1.1.0.tgz" +} diff --git a/ui/node_modules/socket.io/node_modules/engine.io/package.json b/ui/node_modules/socket.io/node_modules/engine.io/package.json index 888a0a66..4101463b 100644 --- a/ui/node_modules/socket.io/node_modules/engine.io/package.json +++ b/ui/node_modules/socket.io/node_modules/engine.io/package.json @@ -1,81 +1,81 @@ -{ - "name": "engine.io", - "version": "1.6.11", - "description": "The realtime engine behind Socket.IO. Provides the foundation of a bidirectional connection between client and server", - "main": "./lib/engine.io", - "author": { - "name": "Guillermo Rauch", - "email": "guillermo@learnboost.com" - }, - "homepage": "https://github.com/socketio/engine.io", - "contributors": [ - { - "name": "Eugen Dueck", - "url": "https://github.com/EugenDueck" - }, - { - "name": "Afshin Mehrabani", - "url": "https://github.com/afshinm" - }, - { - "name": "Christoph Dorn", - "url": "https://github.com/cadorn" - }, - { - "name": "Mark Mokryn", - "email": "mokesmokes@gmail.com" - } - ], - "license": "MIT", - "dependencies": { - "base64id": "0.1.0", - "debug": "2.2.0", - "ws": "1.1.0", - "engine.io-parser": "1.2.4", - "accepts": "1.1.4" - }, - "devDependencies": { - "engine.io-client": "1.6.11", - "expect.js": "0.2.0", - "mocha": "2.3.4", - "s": "0.1.1", - "superagent": "0.15.4" - }, - "scripts": { - "test": "make test" - }, - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/socketio/engine.io.git" - }, - "gitHead": "10c4360bde25271279d5b1250327a7db68a1532d", - "bugs": { - "url": "https://github.com/socketio/engine.io/issues" - }, - "_id": "engine.io@1.6.11", - "_shasum": "2533a97a65876c40ffcf95397b7ef9b495c423fe", - "_from": "engine.io@1.6.11", - "_npmVersion": "3.7.3", - "_nodeVersion": "5.9.1", - "_npmUser": { - "name": "rauchg", - "email": "rauchg@gmail.com" - }, - "dist": { - "shasum": "2533a97a65876c40ffcf95397b7ef9b495c423fe", - "tarball": "https://registry.npmjs.org/engine.io/-/engine.io-1.6.11.tgz" - }, - "maintainers": [ - { - "name": "rauchg", - "email": "rauchg@gmail.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/engine.io-1.6.11.tgz_1466734218879_0.13038815814070404" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/engine.io/-/engine.io-1.6.11.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "engine.io", + "version": "1.6.11", + "description": "The realtime engine behind Socket.IO. Provides the foundation of a bidirectional connection between client and server", + "main": "./lib/engine.io", + "author": { + "name": "Guillermo Rauch", + "email": "guillermo@learnboost.com" + }, + "homepage": "https://github.com/socketio/engine.io", + "contributors": [ + { + "name": "Eugen Dueck", + "url": "https://github.com/EugenDueck" + }, + { + "name": "Afshin Mehrabani", + "url": "https://github.com/afshinm" + }, + { + "name": "Christoph Dorn", + "url": "https://github.com/cadorn" + }, + { + "name": "Mark Mokryn", + "email": "mokesmokes@gmail.com" + } + ], + "license": "MIT", + "dependencies": { + "base64id": "0.1.0", + "debug": "2.2.0", + "ws": "1.1.0", + "engine.io-parser": "1.2.4", + "accepts": "1.1.4" + }, + "devDependencies": { + "engine.io-client": "1.6.11", + "expect.js": "0.2.0", + "mocha": "2.3.4", + "s": "0.1.1", + "superagent": "0.15.4" + }, + "scripts": { + "test": "make test" + }, + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/socketio/engine.io.git" + }, + "gitHead": "10c4360bde25271279d5b1250327a7db68a1532d", + "bugs": { + "url": "https://github.com/socketio/engine.io/issues" + }, + "_id": "engine.io@1.6.11", + "_shasum": "2533a97a65876c40ffcf95397b7ef9b495c423fe", + "_from": "engine.io@1.6.11", + "_npmVersion": "3.7.3", + "_nodeVersion": "5.9.1", + "_npmUser": { + "name": "rauchg", + "email": "rauchg@gmail.com" + }, + "dist": { + "shasum": "2533a97a65876c40ffcf95397b7ef9b495c423fe", + "tarball": "https://registry.npmjs.org/engine.io/-/engine.io-1.6.11.tgz" + }, + "maintainers": [ + { + "name": "rauchg", + "email": "rauchg@gmail.com" + } + ], + "_npmOperationalInternal": { + "host": "packages-16-east.internal.npmjs.com", + "tmp": "tmp/engine.io-1.6.11.tgz_1466734218879_0.13038815814070404" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/engine.io/-/engine.io-1.6.11.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/socket.io/node_modules/has-binary/.npmignore b/ui/node_modules/socket.io/node_modules/has-binary/.npmignore index 78cdbf85..a72b52eb 100644 --- a/ui/node_modules/socket.io/node_modules/has-binary/.npmignore +++ b/ui/node_modules/socket.io/node_modules/has-binary/.npmignore @@ -1,15 +1,15 @@ -lib-cov -*.seed -*.log -*.csv -*.dat -*.out -*.pid -*.gz - -pids -logs -results - -npm-debug.log -node_modules +lib-cov +*.seed +*.log +*.csv +*.dat +*.out +*.pid +*.gz + +pids +logs +results + +npm-debug.log +node_modules diff --git a/ui/node_modules/socket.io/node_modules/has-binary/History.md b/ui/node_modules/socket.io/node_modules/has-binary/History.md index 752d706a..9a5f2e8a 100644 --- a/ui/node_modules/socket.io/node_modules/has-binary/History.md +++ b/ui/node_modules/socket.io/node_modules/has-binary/History.md @@ -1,19 +1,19 @@ - -0.1.7 / 2015-11-18 -================== - - * fix toJSON [@jderuere] - * fix `global.isBuffer` usage [@tonetheman] - * fix tests on modern versions of node - * bump mocha - -0.1.6 / 2015-01-24 -================== - - * fix "undefined function" bug when iterating - an object created with Object.create(null) [gunta] - -0.1.5 / 2014-09-04 -================== - - * prevent browserify from bundling `Buffer` + +0.1.7 / 2015-11-18 +================== + + * fix toJSON [@jderuere] + * fix `global.isBuffer` usage [@tonetheman] + * fix tests on modern versions of node + * bump mocha + +0.1.6 / 2015-01-24 +================== + + * fix "undefined function" bug when iterating + an object created with Object.create(null) [gunta] + +0.1.5 / 2014-09-04 +================== + + * prevent browserify from bundling `Buffer` diff --git a/ui/node_modules/socket.io/node_modules/has-binary/LICENSE b/ui/node_modules/socket.io/node_modules/has-binary/LICENSE index 5e1e23f6..e6603cdf 100644 --- a/ui/node_modules/socket.io/node_modules/has-binary/LICENSE +++ b/ui/node_modules/socket.io/node_modules/has-binary/LICENSE @@ -1,20 +1,20 @@ -The MIT License (MIT) - -Copyright (c) 2014 Kevin Roark - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +The MIT License (MIT) + +Copyright (c) 2014 Kevin Roark + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/socket.io/node_modules/has-binary/Makefile b/ui/node_modules/socket.io/node_modules/has-binary/Makefile index 2fbcce99..1d90629d 100644 --- a/ui/node_modules/socket.io/node_modules/has-binary/Makefile +++ b/ui/node_modules/socket.io/node_modules/has-binary/Makefile @@ -1,3 +1,3 @@ - -test: - @./node_modules/.bin/mocha test.js + +test: + @./node_modules/.bin/mocha test.js diff --git a/ui/node_modules/socket.io/node_modules/has-binary/README.md b/ui/node_modules/socket.io/node_modules/has-binary/README.md index 5dedc64e..76a00356 100644 --- a/ui/node_modules/socket.io/node_modules/has-binary/README.md +++ b/ui/node_modules/socket.io/node_modules/has-binary/README.md @@ -1,4 +1,4 @@ -has-binarydata.js -================= - -Simple module to test if an object contains binary data +has-binarydata.js +================= + +Simple module to test if an object contains binary data diff --git a/ui/node_modules/socket.io/node_modules/has-binary/index.js b/ui/node_modules/socket.io/node_modules/has-binary/index.js index 0f411b1e..434ccfae 100644 --- a/ui/node_modules/socket.io/node_modules/has-binary/index.js +++ b/ui/node_modules/socket.io/node_modules/has-binary/index.js @@ -1,59 +1,59 @@ - -/* - * Module requirements. - */ - -var isArray = require('isarray'); - -/** - * Module exports. - */ - -module.exports = hasBinary; - -/** - * Checks for binary data. - * - * Right now only Buffer and ArrayBuffer are supported.. - * - * @param {Object} anything - * @api public - */ - -function hasBinary(data) { - - function _hasBinary(obj) { - if (!obj) return false; - - if ( (global.Buffer && global.Buffer.isBuffer && global.Buffer.isBuffer(obj)) || - (global.ArrayBuffer && obj instanceof ArrayBuffer) || - (global.Blob && obj instanceof Blob) || - (global.File && obj instanceof File) - ) { - return true; - } - - if (isArray(obj)) { - for (var i = 0; i < obj.length; i++) { - if (_hasBinary(obj[i])) { - return true; - } - } - } else if (obj && 'object' == typeof obj) { - // see: https://github.com/Automattic/has-binary/pull/4 - if (obj.toJSON && 'function' == typeof obj.toJSON) { - obj = obj.toJSON(); - } - - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key) && _hasBinary(obj[key])) { - return true; - } - } - } - - return false; - } - - return _hasBinary(data); -} + +/* + * Module requirements. + */ + +var isArray = require('isarray'); + +/** + * Module exports. + */ + +module.exports = hasBinary; + +/** + * Checks for binary data. + * + * Right now only Buffer and ArrayBuffer are supported.. + * + * @param {Object} anything + * @api public + */ + +function hasBinary(data) { + + function _hasBinary(obj) { + if (!obj) return false; + + if ( (global.Buffer && global.Buffer.isBuffer && global.Buffer.isBuffer(obj)) || + (global.ArrayBuffer && obj instanceof ArrayBuffer) || + (global.Blob && obj instanceof Blob) || + (global.File && obj instanceof File) + ) { + return true; + } + + if (isArray(obj)) { + for (var i = 0; i < obj.length; i++) { + if (_hasBinary(obj[i])) { + return true; + } + } + } else if (obj && 'object' == typeof obj) { + // see: https://github.com/Automattic/has-binary/pull/4 + if (obj.toJSON && 'function' == typeof obj.toJSON) { + obj = obj.toJSON(); + } + + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key) && _hasBinary(obj[key])) { + return true; + } + } + } + + return false; + } + + return _hasBinary(data); +} diff --git a/ui/node_modules/socket.io/node_modules/has-binary/node_modules/isarray/README.md b/ui/node_modules/socket.io/node_modules/has-binary/node_modules/isarray/README.md index 0bda6119..052a62b8 100644 --- a/ui/node_modules/socket.io/node_modules/has-binary/node_modules/isarray/README.md +++ b/ui/node_modules/socket.io/node_modules/has-binary/node_modules/isarray/README.md @@ -1,54 +1,54 @@ - -# isarray - -`Array#isArray` for older browsers. - -## Usage - -```js -var isArray = require('isarray'); - -console.log(isArray([])); // => true -console.log(isArray({})); // => false -``` - -## Installation - -With [npm](http://npmjs.org) do - -```bash -$ npm install isarray -``` - -Then bundle for the browser with -[browserify](https://github.com/substack/browserify). - -With [component](http://component.io) do - -```bash -$ component install juliangruber/isarray -``` - -## License - -(MIT) - -Copyright (c) 2013 Julian Gruber <julian@juliangruber.com> - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. + +# isarray + +`Array#isArray` for older browsers. + +## Usage + +```js +var isArray = require('isarray'); + +console.log(isArray([])); // => true +console.log(isArray({})); // => false +``` + +## Installation + +With [npm](http://npmjs.org) do + +```bash +$ npm install isarray +``` + +Then bundle for the browser with +[browserify](https://github.com/substack/browserify). + +With [component](http://component.io) do + +```bash +$ component install juliangruber/isarray +``` + +## License + +(MIT) + +Copyright (c) 2013 Julian Gruber <julian@juliangruber.com> + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/ui/node_modules/socket.io/node_modules/has-binary/node_modules/isarray/build/build.js b/ui/node_modules/socket.io/node_modules/has-binary/node_modules/isarray/build/build.js index 204cba26..ec58596a 100644 --- a/ui/node_modules/socket.io/node_modules/has-binary/node_modules/isarray/build/build.js +++ b/ui/node_modules/socket.io/node_modules/has-binary/node_modules/isarray/build/build.js @@ -1,209 +1,209 @@ - -/** - * Require the given path. - * - * @param {String} path - * @return {Object} exports - * @api public - */ - -function require(path, parent, orig) { - var resolved = require.resolve(path); - - // lookup failed - if (null == resolved) { - orig = orig || path; - parent = parent || 'root'; - var err = new Error('Failed to require "' + orig + '" from "' + parent + '"'); - err.path = orig; - err.parent = parent; - err.require = true; - throw err; - } - - var module = require.modules[resolved]; - - // perform real require() - // by invoking the module's - // registered function - if (!module.exports) { - module.exports = {}; - module.client = module.component = true; - module.call(this, module.exports, require.relative(resolved), module); - } - - return module.exports; -} - -/** - * Registered modules. - */ - -require.modules = {}; - -/** - * Registered aliases. - */ - -require.aliases = {}; - -/** - * Resolve `path`. - * - * Lookup: - * - * - PATH/index.js - * - PATH.js - * - PATH - * - * @param {String} path - * @return {String} path or null - * @api private - */ - -require.resolve = function(path) { - if (path.charAt(0) === '/') path = path.slice(1); - var index = path + '/index.js'; - - var paths = [ - path, - path + '.js', - path + '.json', - path + '/index.js', - path + '/index.json' - ]; - - for (var i = 0; i < paths.length; i++) { - var path = paths[i]; - if (require.modules.hasOwnProperty(path)) return path; - } - - if (require.aliases.hasOwnProperty(index)) { - return require.aliases[index]; - } -}; - -/** - * Normalize `path` relative to the current path. - * - * @param {String} curr - * @param {String} path - * @return {String} - * @api private - */ - -require.normalize = function(curr, path) { - var segs = []; - - if ('.' != path.charAt(0)) return path; - - curr = curr.split('/'); - path = path.split('/'); - - for (var i = 0; i < path.length; ++i) { - if ('..' == path[i]) { - curr.pop(); - } else if ('.' != path[i] && '' != path[i]) { - segs.push(path[i]); - } - } - - return curr.concat(segs).join('/'); -}; - -/** - * Register module at `path` with callback `definition`. - * - * @param {String} path - * @param {Function} definition - * @api private - */ - -require.register = function(path, definition) { - require.modules[path] = definition; -}; - -/** - * Alias a module definition. - * - * @param {String} from - * @param {String} to - * @api private - */ - -require.alias = function(from, to) { - if (!require.modules.hasOwnProperty(from)) { - throw new Error('Failed to alias "' + from + '", it does not exist'); - } - require.aliases[to] = from; -}; - -/** - * Return a require function relative to the `parent` path. - * - * @param {String} parent - * @return {Function} - * @api private - */ - -require.relative = function(parent) { - var p = require.normalize(parent, '..'); - - /** - * lastIndexOf helper. - */ - - function lastIndexOf(arr, obj) { - var i = arr.length; - while (i--) { - if (arr[i] === obj) return i; - } - return -1; - } - - /** - * The relative require() itself. - */ - - function localRequire(path) { - var resolved = localRequire.resolve(path); - return require(resolved, parent, path); - } - - /** - * Resolve relative to the parent. - */ - - localRequire.resolve = function(path) { - var c = path.charAt(0); - if ('/' == c) return path.slice(1); - if ('.' == c) return require.normalize(p, path); - - // resolve deps by returning - // the dep in the nearest "deps" - // directory - var segs = parent.split('/'); - var i = lastIndexOf(segs, 'deps') + 1; - if (!i) i = 0; - path = segs.slice(0, i + 1).join('/') + '/deps/' + path; - return path; - }; - - /** - * Check if module is defined at `path`. - */ - - localRequire.exists = function(path) { - return require.modules.hasOwnProperty(localRequire.resolve(path)); - }; - - return localRequire; -}; -require.register("isarray/index.js", function(exports, require, module){ -module.exports = Array.isArray || function (arr) { - return Object.prototype.toString.call(arr) == '[object Array]'; -}; - -}); -require.alias("isarray/index.js", "isarray/index.js"); - + +/** + * Require the given path. + * + * @param {String} path + * @return {Object} exports + * @api public + */ + +function require(path, parent, orig) { + var resolved = require.resolve(path); + + // lookup failed + if (null == resolved) { + orig = orig || path; + parent = parent || 'root'; + var err = new Error('Failed to require "' + orig + '" from "' + parent + '"'); + err.path = orig; + err.parent = parent; + err.require = true; + throw err; + } + + var module = require.modules[resolved]; + + // perform real require() + // by invoking the module's + // registered function + if (!module.exports) { + module.exports = {}; + module.client = module.component = true; + module.call(this, module.exports, require.relative(resolved), module); + } + + return module.exports; +} + +/** + * Registered modules. + */ + +require.modules = {}; + +/** + * Registered aliases. + */ + +require.aliases = {}; + +/** + * Resolve `path`. + * + * Lookup: + * + * - PATH/index.js + * - PATH.js + * - PATH + * + * @param {String} path + * @return {String} path or null + * @api private + */ + +require.resolve = function(path) { + if (path.charAt(0) === '/') path = path.slice(1); + var index = path + '/index.js'; + + var paths = [ + path, + path + '.js', + path + '.json', + path + '/index.js', + path + '/index.json' + ]; + + for (var i = 0; i < paths.length; i++) { + var path = paths[i]; + if (require.modules.hasOwnProperty(path)) return path; + } + + if (require.aliases.hasOwnProperty(index)) { + return require.aliases[index]; + } +}; + +/** + * Normalize `path` relative to the current path. + * + * @param {String} curr + * @param {String} path + * @return {String} + * @api private + */ + +require.normalize = function(curr, path) { + var segs = []; + + if ('.' != path.charAt(0)) return path; + + curr = curr.split('/'); + path = path.split('/'); + + for (var i = 0; i < path.length; ++i) { + if ('..' == path[i]) { + curr.pop(); + } else if ('.' != path[i] && '' != path[i]) { + segs.push(path[i]); + } + } + + return curr.concat(segs).join('/'); +}; + +/** + * Register module at `path` with callback `definition`. + * + * @param {String} path + * @param {Function} definition + * @api private + */ + +require.register = function(path, definition) { + require.modules[path] = definition; +}; + +/** + * Alias a module definition. + * + * @param {String} from + * @param {String} to + * @api private + */ + +require.alias = function(from, to) { + if (!require.modules.hasOwnProperty(from)) { + throw new Error('Failed to alias "' + from + '", it does not exist'); + } + require.aliases[to] = from; +}; + +/** + * Return a require function relative to the `parent` path. + * + * @param {String} parent + * @return {Function} + * @api private + */ + +require.relative = function(parent) { + var p = require.normalize(parent, '..'); + + /** + * lastIndexOf helper. + */ + + function lastIndexOf(arr, obj) { + var i = arr.length; + while (i--) { + if (arr[i] === obj) return i; + } + return -1; + } + + /** + * The relative require() itself. + */ + + function localRequire(path) { + var resolved = localRequire.resolve(path); + return require(resolved, parent, path); + } + + /** + * Resolve relative to the parent. + */ + + localRequire.resolve = function(path) { + var c = path.charAt(0); + if ('/' == c) return path.slice(1); + if ('.' == c) return require.normalize(p, path); + + // resolve deps by returning + // the dep in the nearest "deps" + // directory + var segs = parent.split('/'); + var i = lastIndexOf(segs, 'deps') + 1; + if (!i) i = 0; + path = segs.slice(0, i + 1).join('/') + '/deps/' + path; + return path; + }; + + /** + * Check if module is defined at `path`. + */ + + localRequire.exists = function(path) { + return require.modules.hasOwnProperty(localRequire.resolve(path)); + }; + + return localRequire; +}; +require.register("isarray/index.js", function(exports, require, module){ +module.exports = Array.isArray || function (arr) { + return Object.prototype.toString.call(arr) == '[object Array]'; +}; + +}); +require.alias("isarray/index.js", "isarray/index.js"); + diff --git a/ui/node_modules/socket.io/node_modules/has-binary/node_modules/isarray/component.json b/ui/node_modules/socket.io/node_modules/has-binary/node_modules/isarray/component.json index d21b0c89..9e31b683 100644 --- a/ui/node_modules/socket.io/node_modules/has-binary/node_modules/isarray/component.json +++ b/ui/node_modules/socket.io/node_modules/has-binary/node_modules/isarray/component.json @@ -1,19 +1,19 @@ -{ - "name" : "isarray", - "description" : "Array#isArray for older browsers", - "version" : "0.0.1", - "repository" : "juliangruber/isarray", - "homepage": "https://github.com/juliangruber/isarray", - "main" : "index.js", - "scripts" : [ - "index.js" - ], - "dependencies" : {}, - "keywords": ["browser","isarray","array"], - "author": { - "name": "Julian Gruber", - "email": "mail@juliangruber.com", - "url": "http://juliangruber.com" - }, - "license": "MIT" -} +{ + "name" : "isarray", + "description" : "Array#isArray for older browsers", + "version" : "0.0.1", + "repository" : "juliangruber/isarray", + "homepage": "https://github.com/juliangruber/isarray", + "main" : "index.js", + "scripts" : [ + "index.js" + ], + "dependencies" : {}, + "keywords": ["browser","isarray","array"], + "author": { + "name": "Julian Gruber", + "email": "mail@juliangruber.com", + "url": "http://juliangruber.com" + }, + "license": "MIT" +} diff --git a/ui/node_modules/socket.io/node_modules/has-binary/node_modules/isarray/index.js b/ui/node_modules/socket.io/node_modules/has-binary/node_modules/isarray/index.js index 25533a38..5f5ad45d 100644 --- a/ui/node_modules/socket.io/node_modules/has-binary/node_modules/isarray/index.js +++ b/ui/node_modules/socket.io/node_modules/has-binary/node_modules/isarray/index.js @@ -1,3 +1,3 @@ -module.exports = Array.isArray || function (arr) { - return Object.prototype.toString.call(arr) == '[object Array]'; -}; +module.exports = Array.isArray || function (arr) { + return Object.prototype.toString.call(arr) == '[object Array]'; +}; diff --git a/ui/node_modules/socket.io/node_modules/has-binary/node_modules/isarray/package.json b/ui/node_modules/socket.io/node_modules/has-binary/node_modules/isarray/package.json index d6ef34cd..060e073f 100644 --- a/ui/node_modules/socket.io/node_modules/has-binary/node_modules/isarray/package.json +++ b/ui/node_modules/socket.io/node_modules/has-binary/node_modules/isarray/package.json @@ -1,53 +1,53 @@ -{ - "name": "isarray", - "description": "Array#isArray for older browsers", - "version": "0.0.1", - "repository": { - "type": "git", - "url": "git://github.com/juliangruber/isarray.git" - }, - "homepage": "https://github.com/juliangruber/isarray", - "main": "index.js", - "scripts": { - "test": "tap test/*.js" - }, - "dependencies": {}, - "devDependencies": { - "tap": "*" - }, - "keywords": [ - "browser", - "isarray", - "array" - ], - "author": { - "name": "Julian Gruber", - "email": "mail@juliangruber.com", - "url": "http://juliangruber.com" - }, - "license": "MIT", - "_id": "isarray@0.0.1", - "dist": { - "shasum": "8a18acfca9a8f4177e09abfc6038939b05d1eedf", - "tarball": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" - }, - "_from": "isarray@0.0.1", - "_npmVersion": "1.2.18", - "_npmUser": { - "name": "juliangruber", - "email": "julian@juliangruber.com" - }, - "maintainers": [ - { - "name": "juliangruber", - "email": "julian@juliangruber.com" - } - ], - "directories": {}, - "_shasum": "8a18acfca9a8f4177e09abfc6038939b05d1eedf", - "_resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "bugs": { - "url": "https://github.com/juliangruber/isarray/issues" - }, - "readme": "ERROR: No README data found!" -} +{ + "name": "isarray", + "description": "Array#isArray for older browsers", + "version": "0.0.1", + "repository": { + "type": "git", + "url": "git://github.com/juliangruber/isarray.git" + }, + "homepage": "https://github.com/juliangruber/isarray", + "main": "index.js", + "scripts": { + "test": "tap test/*.js" + }, + "dependencies": {}, + "devDependencies": { + "tap": "*" + }, + "keywords": [ + "browser", + "isarray", + "array" + ], + "author": { + "name": "Julian Gruber", + "email": "mail@juliangruber.com", + "url": "http://juliangruber.com" + }, + "license": "MIT", + "_id": "isarray@0.0.1", + "dist": { + "shasum": "8a18acfca9a8f4177e09abfc6038939b05d1eedf", + "tarball": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" + }, + "_from": "isarray@0.0.1", + "_npmVersion": "1.2.18", + "_npmUser": { + "name": "juliangruber", + "email": "julian@juliangruber.com" + }, + "maintainers": [ + { + "name": "juliangruber", + "email": "julian@juliangruber.com" + } + ], + "directories": {}, + "_shasum": "8a18acfca9a8f4177e09abfc6038939b05d1eedf", + "_resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "bugs": { + "url": "https://github.com/juliangruber/isarray/issues" + }, + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/socket.io/node_modules/has-binary/package.json b/ui/node_modules/socket.io/node_modules/has-binary/package.json index 3176e7a0..861e0d30 100644 --- a/ui/node_modules/socket.io/node_modules/has-binary/package.json +++ b/ui/node_modules/socket.io/node_modules/has-binary/package.json @@ -1,40 +1,40 @@ -{ - "name": "has-binary", - "version": "0.1.7", - "description": "A function that takes anything in javascript and returns true if its argument contains binary data.", - "dependencies": { - "isarray": "0.0.1" - }, - "devDependencies": { - "better-assert": "1.0.0", - "mocha": "2.3.4" - }, - "author": { - "name": "Kevin Roark" - }, - "license": "MIT", - "gitHead": "73875a20978a219f726f7d313ccd1de19335f5a1", - "_id": "has-binary@0.1.7", - "scripts": {}, - "_shasum": "68e61eb16210c9545a0a5cce06a873912fe1e68c", - "_from": "has-binary@0.1.7", - "_npmVersion": "2.14.7", - "_nodeVersion": "4.2.2", - "_npmUser": { - "name": "rauchg", - "email": "rauchg@gmail.com" - }, - "maintainers": [ - { - "name": "rauchg", - "email": "rauchg@gmail.com" - } - ], - "dist": { - "shasum": "68e61eb16210c9545a0a5cce06a873912fe1e68c", - "tarball": "https://registry.npmjs.org/has-binary/-/has-binary-0.1.7.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/has-binary/-/has-binary-0.1.7.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "has-binary", + "version": "0.1.7", + "description": "A function that takes anything in javascript and returns true if its argument contains binary data.", + "dependencies": { + "isarray": "0.0.1" + }, + "devDependencies": { + "better-assert": "1.0.0", + "mocha": "2.3.4" + }, + "author": { + "name": "Kevin Roark" + }, + "license": "MIT", + "gitHead": "73875a20978a219f726f7d313ccd1de19335f5a1", + "_id": "has-binary@0.1.7", + "scripts": {}, + "_shasum": "68e61eb16210c9545a0a5cce06a873912fe1e68c", + "_from": "has-binary@0.1.7", + "_npmVersion": "2.14.7", + "_nodeVersion": "4.2.2", + "_npmUser": { + "name": "rauchg", + "email": "rauchg@gmail.com" + }, + "maintainers": [ + { + "name": "rauchg", + "email": "rauchg@gmail.com" + } + ], + "dist": { + "shasum": "68e61eb16210c9545a0a5cce06a873912fe1e68c", + "tarball": "https://registry.npmjs.org/has-binary/-/has-binary-0.1.7.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/has-binary/-/has-binary-0.1.7.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/socket.io/node_modules/has-binary/test.js b/ui/node_modules/socket.io/node_modules/has-binary/test.js index 441b0048..c6bd5aa5 100644 --- a/ui/node_modules/socket.io/node_modules/has-binary/test.js +++ b/ui/node_modules/socket.io/node_modules/has-binary/test.js @@ -1,73 +1,73 @@ - -var hasBinary = require('./'); -var assert = require('better-assert'); -var fs = require('fs'); - -describe('has-binarydata', function(){ - - it('should work with buffer', function(){ - assert(hasBinary(fs.readFileSync('./test.js'))); - }); - - it('should work with an array that does not contain binary', function() { - var arr = [1, 'cool', 2]; - assert(!hasBinary(arr)); - }); - - it('should work with an array that contains a buffer', function() { - var arr = [1, new Buffer('asdfasdf', 'utf8'), 2]; - assert(hasBinary(arr)); - }); - - it('should work with an object that does not contain binary', function() { - var ob = {a: 'a', b: [], c: 1234, toJSON: '{\"a\": \"a\"}'}; - assert(!hasBinary(ob)); - }); - - it('should work with an object that contains a buffer', function() { - var ob = {a: 'a', b: new Buffer('abc'), c: 1234, toJSON: '{\"a\": \"a\"}'}; - assert(hasBinary(ob)); - }); - - it('should work with null', function() { - assert(!hasBinary(null)); - }); - - it('should work with undefined', function() { - assert(!hasBinary(undefined)); - }); - - it('should work with a complex object that contains undefined and no binary', function() { - var ob = { - x: ['a', 'b', 123], - y: undefined, - z: {a: 'x', b: 'y', c: 3, d: null}, - w: [] - }; - assert(!hasBinary(ob)); - }); - - it('should work with a complex object that contains undefined and binary', function() { - var ob = { - x: ['a', 'b', 123], - y: undefined, - z: {a: 'x', b: 'y', c: 3, d: null}, - w: [], - bin: new Buffer('xxx') - }; - assert(hasBinary(ob)); - }); - - if (global.ArrayBuffer) { - it('should work with an ArrayBuffer', function() { - assert(hasBinary(new ArrayBuffer())); - }); - } - - if (global.Blob) { - it('should work with a Blob', function() { - assert(hasBinary(new Blob())); - }); - } - -}); + +var hasBinary = require('./'); +var assert = require('better-assert'); +var fs = require('fs'); + +describe('has-binarydata', function(){ + + it('should work with buffer', function(){ + assert(hasBinary(fs.readFileSync('./test.js'))); + }); + + it('should work with an array that does not contain binary', function() { + var arr = [1, 'cool', 2]; + assert(!hasBinary(arr)); + }); + + it('should work with an array that contains a buffer', function() { + var arr = [1, new Buffer('asdfasdf', 'utf8'), 2]; + assert(hasBinary(arr)); + }); + + it('should work with an object that does not contain binary', function() { + var ob = {a: 'a', b: [], c: 1234, toJSON: '{\"a\": \"a\"}'}; + assert(!hasBinary(ob)); + }); + + it('should work with an object that contains a buffer', function() { + var ob = {a: 'a', b: new Buffer('abc'), c: 1234, toJSON: '{\"a\": \"a\"}'}; + assert(hasBinary(ob)); + }); + + it('should work with null', function() { + assert(!hasBinary(null)); + }); + + it('should work with undefined', function() { + assert(!hasBinary(undefined)); + }); + + it('should work with a complex object that contains undefined and no binary', function() { + var ob = { + x: ['a', 'b', 123], + y: undefined, + z: {a: 'x', b: 'y', c: 3, d: null}, + w: [] + }; + assert(!hasBinary(ob)); + }); + + it('should work with a complex object that contains undefined and binary', function() { + var ob = { + x: ['a', 'b', 123], + y: undefined, + z: {a: 'x', b: 'y', c: 3, d: null}, + w: [], + bin: new Buffer('xxx') + }; + assert(hasBinary(ob)); + }); + + if (global.ArrayBuffer) { + it('should work with an ArrayBuffer', function() { + assert(hasBinary(new ArrayBuffer())); + }); + } + + if (global.Blob) { + it('should work with a Blob', function() { + assert(hasBinary(new Blob())); + }); + } + +}); diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/.npmignore b/ui/node_modules/socket.io/node_modules/socket.io-adapter/.npmignore index 08b25532..3c3629e6 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/.npmignore +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/.npmignore @@ -1 +1 @@ -node_modules +node_modules diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/History.md b/ui/node_modules/socket.io/node_modules/socket.io-adapter/History.md index 15fe24c0..02abe950 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/History.md +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/History.md @@ -1,33 +1,33 @@ - -0.4.0 / 2015-12-03 -================== - - * package: bump `debug` - * use a `Room` class to efficiently track room size - * allow `clients(fn)` - * call the callback on `delAll` - -0.3.1 / 2014-10-27 -================== - - * bump parser version - * fix room autopruning - * add autoprunning of empty rooms - * rooms are now created as objects - * added the repository field. - * updated the debug dependency. - -0.3.0 / 2014-05-30 -================== - - * bump `socket.io-parser` for binary ack fix - -0.2.0 / 2014-03-14 -================== - - * upgraded faster parser - -0.1.0 / 2014-03-07 -================== - - * initial commit + +0.4.0 / 2015-12-03 +================== + + * package: bump `debug` + * use a `Room` class to efficiently track room size + * allow `clients(fn)` + * call the callback on `delAll` + +0.3.1 / 2014-10-27 +================== + + * bump parser version + * fix room autopruning + * add autoprunning of empty rooms + * rooms are now created as objects + * added the repository field. + * updated the debug dependency. + +0.3.0 / 2014-05-30 +================== + + * bump `socket.io-parser` for binary ack fix + +0.2.0 / 2014-03-14 +================== + + * upgraded faster parser + +0.1.0 / 2014-03-07 +================== + + * initial commit diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/LICENSE b/ui/node_modules/socket.io/node_modules/socket.io-adapter/LICENSE index f2fd6d22..7e43606b 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/LICENSE +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/LICENSE @@ -1,20 +1,20 @@ -(The MIT License) - -Copyright (c) 2014 Guillermo Rauch - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the 'Software'), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2014 Guillermo Rauch + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the 'Software'), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/Readme.md b/ui/node_modules/socket.io/node_modules/socket.io-adapter/Readme.md index 2b1cfbae..bcef6531 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/Readme.md +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/Readme.md @@ -1,16 +1,16 @@ - -# socket.io-adapter - -Default socket.io in-memory adapter class. - -## How to use - -This module is not intended for end-user usage, but can be used as an -interface to inheirt from from other adapters you might want to build. - -As an example of an adapter that builds on top of this, please take a look -at [socket.io-redis](https://github.com/learnboost/socket.io-redis). - -## License - -MIT + +# socket.io-adapter + +Default socket.io in-memory adapter class. + +## How to use + +This module is not intended for end-user usage, but can be used as an +interface to inheirt from from other adapters you might want to build. + +As an example of an adapter that builds on top of this, please take a look +at [socket.io-redis](https://github.com/learnboost/socket.io-redis). + +## License + +MIT diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/index.js b/ui/node_modules/socket.io/node_modules/socket.io-adapter/index.js index be7147f9..d5e2201a 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/index.js +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/index.js @@ -1,236 +1,236 @@ - -/** - * Module dependencies. - */ - -var Emitter = require('events').EventEmitter; -var parser = require('socket.io-parser'); - -/** - * Module exports. - */ - -module.exports = Adapter; - -/** - * Memory adapter constructor. - * - * @param {Namespace} nsp - * @api public - */ - -function Adapter(nsp){ - this.nsp = nsp; - this.rooms = {}; - this.sids = {}; - this.encoder = new parser.Encoder(); -} - -/** - * Inherits from `EventEmitter`. - */ - -Adapter.prototype.__proto__ = Emitter.prototype; - -/** - * Adds a socket to a room. - * - * @param {String} socket id - * @param {String} room name - * @param {Function} callback - * @api public - */ - -Adapter.prototype.add = function(id, room, fn){ - this.sids[id] = this.sids[id] || {}; - this.sids[id][room] = true; - this.rooms[room] = this.rooms[room] || Room(); - this.rooms[room].add(id); - if (fn) process.nextTick(fn.bind(null, null)); -}; - -/** - * Removes a socket from a room. - * - * @param {String} socket id - * @param {String} room name - * @param {Function} callback - * @api public - */ - -Adapter.prototype.del = function(id, room, fn){ - this.sids[id] = this.sids[id] || {}; - delete this.sids[id][room]; - if (this.rooms.hasOwnProperty(room)) { - this.rooms[room].del(id); - if (this.rooms[room].length === 0) delete this.rooms[room]; - } - - if (fn) process.nextTick(fn.bind(null, null)); -}; - -/** - * Removes a socket from all rooms it's joined. - * - * @param {String} socket id - * @param {Function} callback - * @api public - */ - -Adapter.prototype.delAll = function(id, fn){ - var rooms = this.sids[id]; - if (rooms) { - for (var room in rooms) { - if (this.rooms.hasOwnProperty(room)) { - this.rooms[room].del(id); - if (this.rooms[room].length === 0) delete this.rooms[room]; - } - } - } - delete this.sids[id]; - - if (fn) process.nextTick(fn.bind(null, null)); -}; - -/** - * Broadcasts a packet. - * - * Options: - * - `flags` {Object} flags for this packet - * - `except` {Array} sids that should be excluded - * - `rooms` {Array} list of rooms to broadcast to - * - * @param {Object} packet object - * @api public - */ - -Adapter.prototype.broadcast = function(packet, opts){ - var rooms = opts.rooms || []; - var except = opts.except || []; - var flags = opts.flags || {}; - var packetOpts = { - preEncoded: true, - volatile: flags.volatile, - compress: flags.compress - }; - var ids = {}; - var self = this; - var socket; - - packet.nsp = this.nsp.name; - this.encoder.encode(packet, function(encodedPackets) { - if (rooms.length) { - for (var i = 0; i < rooms.length; i++) { - var room = self.rooms[rooms[i]]; - if (!room) continue; - var sockets = room.sockets; - for (var id in sockets) { - if (sockets.hasOwnProperty(id)) { - if (ids[id] || ~except.indexOf(id)) continue; - socket = self.nsp.connected[id]; - if (socket) { - socket.packet(encodedPackets, packetOpts); - ids[id] = true; - } - } - } - } - } else { - for (var id in self.sids) { - if (self.sids.hasOwnProperty(id)) { - if (~except.indexOf(id)) continue; - socket = self.nsp.connected[id]; - if (socket) socket.packet(encodedPackets, packetOpts); - } - } - } - }); -}; - -/** - * Gets a list of clients by sid. - * - * @param {Array} explicit set of rooms to check. - * @api public - */ - -Adapter.prototype.clients = function(rooms, fn){ - if ('function' == typeof rooms){ - fn = rooms; - rooms = null; - } - - rooms = rooms || []; - - var ids = {}; - var self = this; - var sids = []; - var socket; - - if (rooms.length) { - for (var i = 0; i < rooms.length; i++) { - var room = self.rooms[rooms[i]]; - if (!room) continue; - var sockets = room.sockets; - for (var id in sockets) { - if (sockets.hasOwnProperty(id)) { - if (ids[id]) continue; - socket = self.nsp.connected[id]; - if (socket) { - sids.push(id); - ids[id] = true; - } - } - } - } - } else { - for (var id in self.sids) { - if (self.sids.hasOwnProperty(id)) { - socket = self.nsp.connected[id]; - if (socket) sids.push(id); - } - } - } - - if (fn) process.nextTick(fn.bind(null, null, sids)); -}; - -/** -* Room constructor. -* -* @api private -*/ - -function Room(){ - if (!(this instanceof Room)) return new Room(); - this.sockets = {}; - this.length = 0; -} - -/** - * Adds a socket to a room. - * - * @param {String} socket id - * @api private - */ - -Room.prototype.add = function(id){ - if (!this.sockets.hasOwnProperty(id)) { - this.sockets[id] = true; - this.length++; - } -}; - -/** - * Removes a socket from a room. - * - * @param {String} socket id - * @api private - */ - -Room.prototype.del = function(id){ - if (this.sockets.hasOwnProperty(id)) { - delete this.sockets[id]; - this.length--; - } -}; + +/** + * Module dependencies. + */ + +var Emitter = require('events').EventEmitter; +var parser = require('socket.io-parser'); + +/** + * Module exports. + */ + +module.exports = Adapter; + +/** + * Memory adapter constructor. + * + * @param {Namespace} nsp + * @api public + */ + +function Adapter(nsp){ + this.nsp = nsp; + this.rooms = {}; + this.sids = {}; + this.encoder = new parser.Encoder(); +} + +/** + * Inherits from `EventEmitter`. + */ + +Adapter.prototype.__proto__ = Emitter.prototype; + +/** + * Adds a socket to a room. + * + * @param {String} socket id + * @param {String} room name + * @param {Function} callback + * @api public + */ + +Adapter.prototype.add = function(id, room, fn){ + this.sids[id] = this.sids[id] || {}; + this.sids[id][room] = true; + this.rooms[room] = this.rooms[room] || Room(); + this.rooms[room].add(id); + if (fn) process.nextTick(fn.bind(null, null)); +}; + +/** + * Removes a socket from a room. + * + * @param {String} socket id + * @param {String} room name + * @param {Function} callback + * @api public + */ + +Adapter.prototype.del = function(id, room, fn){ + this.sids[id] = this.sids[id] || {}; + delete this.sids[id][room]; + if (this.rooms.hasOwnProperty(room)) { + this.rooms[room].del(id); + if (this.rooms[room].length === 0) delete this.rooms[room]; + } + + if (fn) process.nextTick(fn.bind(null, null)); +}; + +/** + * Removes a socket from all rooms it's joined. + * + * @param {String} socket id + * @param {Function} callback + * @api public + */ + +Adapter.prototype.delAll = function(id, fn){ + var rooms = this.sids[id]; + if (rooms) { + for (var room in rooms) { + if (this.rooms.hasOwnProperty(room)) { + this.rooms[room].del(id); + if (this.rooms[room].length === 0) delete this.rooms[room]; + } + } + } + delete this.sids[id]; + + if (fn) process.nextTick(fn.bind(null, null)); +}; + +/** + * Broadcasts a packet. + * + * Options: + * - `flags` {Object} flags for this packet + * - `except` {Array} sids that should be excluded + * - `rooms` {Array} list of rooms to broadcast to + * + * @param {Object} packet object + * @api public + */ + +Adapter.prototype.broadcast = function(packet, opts){ + var rooms = opts.rooms || []; + var except = opts.except || []; + var flags = opts.flags || {}; + var packetOpts = { + preEncoded: true, + volatile: flags.volatile, + compress: flags.compress + }; + var ids = {}; + var self = this; + var socket; + + packet.nsp = this.nsp.name; + this.encoder.encode(packet, function(encodedPackets) { + if (rooms.length) { + for (var i = 0; i < rooms.length; i++) { + var room = self.rooms[rooms[i]]; + if (!room) continue; + var sockets = room.sockets; + for (var id in sockets) { + if (sockets.hasOwnProperty(id)) { + if (ids[id] || ~except.indexOf(id)) continue; + socket = self.nsp.connected[id]; + if (socket) { + socket.packet(encodedPackets, packetOpts); + ids[id] = true; + } + } + } + } + } else { + for (var id in self.sids) { + if (self.sids.hasOwnProperty(id)) { + if (~except.indexOf(id)) continue; + socket = self.nsp.connected[id]; + if (socket) socket.packet(encodedPackets, packetOpts); + } + } + } + }); +}; + +/** + * Gets a list of clients by sid. + * + * @param {Array} explicit set of rooms to check. + * @api public + */ + +Adapter.prototype.clients = function(rooms, fn){ + if ('function' == typeof rooms){ + fn = rooms; + rooms = null; + } + + rooms = rooms || []; + + var ids = {}; + var self = this; + var sids = []; + var socket; + + if (rooms.length) { + for (var i = 0; i < rooms.length; i++) { + var room = self.rooms[rooms[i]]; + if (!room) continue; + var sockets = room.sockets; + for (var id in sockets) { + if (sockets.hasOwnProperty(id)) { + if (ids[id]) continue; + socket = self.nsp.connected[id]; + if (socket) { + sids.push(id); + ids[id] = true; + } + } + } + } + } else { + for (var id in self.sids) { + if (self.sids.hasOwnProperty(id)) { + socket = self.nsp.connected[id]; + if (socket) sids.push(id); + } + } + } + + if (fn) process.nextTick(fn.bind(null, null, sids)); +}; + +/** +* Room constructor. +* +* @api private +*/ + +function Room(){ + if (!(this instanceof Room)) return new Room(); + this.sockets = {}; + this.length = 0; +} + +/** + * Adds a socket to a room. + * + * @param {String} socket id + * @api private + */ + +Room.prototype.add = function(id){ + if (!this.sockets.hasOwnProperty(id)) { + this.sockets[id] = true; + this.length++; + } +}; + +/** + * Removes a socket from a room. + * + * @param {String} socket id + * @api private + */ + +Room.prototype.del = function(id){ + if (this.sockets.hasOwnProperty(id)) { + delete this.sockets[id]; + this.length--; + } +}; diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/.npmignore b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/.npmignore index dfb13523..7fbb06ff 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/.npmignore +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/.npmignore @@ -1,5 +1,5 @@ -node_modules -build -components - -test +node_modules +build +components + +test diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/.travis.yml b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/.travis.yml index 1484c7de..c1c830af 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/.travis.yml +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/.travis.yml @@ -1,11 +1,11 @@ -language: node_js -node_js: - - 0.10 -notifications: - irc: irc.freenode.org##socket.io -git: - depth: 1 -env: - global: - - secure: 28HHk1J0H64KNjzmmlxG/Ro0EPuLnhO0rU+kZjjthDHj/FaugIsqjAVQ1Dl6heWV2/MlVzw6nDCyMNiGwiVk0ruZPQ0SYdAKLplrdMtzAihbU3xx+ULFQPLM3SoW0ZFCEpe8dWPGy4WdgW7aLByeel9TJb3vlhAu7p7AvrcO7Fs= - - secure: rKEG0Cfw0vkw8thk63RHYG7h8XWYcBlvZ0w1IWpr2dAfnnLMi1palSTrBrFQc77flk7rN00zGIe76FhKydV9r4WWYAUYKPqo4k+9/FkpzjZlNtL49QRoNwC9jmJ8OeUwGowA13gZPyl/5P13wVaKCB0YrKnzz5LHo3Sp7So6J8U= +language: node_js +node_js: + - 0.10 +notifications: + irc: irc.freenode.org##socket.io +git: + depth: 1 +env: + global: + - secure: 28HHk1J0H64KNjzmmlxG/Ro0EPuLnhO0rU+kZjjthDHj/FaugIsqjAVQ1Dl6heWV2/MlVzw6nDCyMNiGwiVk0ruZPQ0SYdAKLplrdMtzAihbU3xx+ULFQPLM3SoW0ZFCEpe8dWPGy4WdgW7aLByeel9TJb3vlhAu7p7AvrcO7Fs= + - secure: rKEG0Cfw0vkw8thk63RHYG7h8XWYcBlvZ0w1IWpr2dAfnnLMi1palSTrBrFQc77flk7rN00zGIe76FhKydV9r4WWYAUYKPqo4k+9/FkpzjZlNtL49QRoNwC9jmJ8OeUwGowA13gZPyl/5P13wVaKCB0YrKnzz5LHo3Sp7So6J8U= diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/.zuul.yml b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/.zuul.yml index f6f6d86f..38bc342e 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/.zuul.yml +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/.zuul.yml @@ -1,16 +1,16 @@ -ui: mocha-bdd -browsers: - - name: chrome - version: 29..latest - - name: firefox - version: latest - - name: safari - version: latest - - name: ie - version: 10 - platform: Windows 2012 - - name: ie - version: 9 - version: [6..9, latest] - - name: iphone - version: oldest..latest +ui: mocha-bdd +browsers: + - name: chrome + version: 29..latest + - name: firefox + version: latest + - name: safari + version: latest + - name: ie + version: 10 + platform: Windows 2012 + - name: ie + version: 9 + version: [6..9, latest] + - name: iphone + version: oldest..latest diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/History.md b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/History.md index 58354c63..3563380f 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/History.md +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/History.md @@ -1,87 +1,87 @@ - -2.2.2 / 2014-09-04 -================== - - * prevent direct `Buffer` reference that breaks browserify - * binary: reuse `isBuf` helper - -2.2.1 / 2014-06-20 -================== - - * added benchmarking [kevin-roark] - * upgrade component-emitter to 1.1.2 [kevin-roark] - * update protocol version [kevin-roark] - * less indentation and a small optimization [kevin-roark] - -2.2.0 / 2014-05-30 -================== - - * added a BINARY_ACK type [kevin-roark] - -2.1.5 / 2014-05-24 -================== - - * don't iterate keys of `Date` objects [Rase-] - -2.1.4 / 2014-05-17 -================== - - * fix null reconstruction bug [kevin-roark] - -2.1.3 / 2014-04-27 -================== - - * bump zuul version - * updated protocol version - -2.1.2 / 2014-03-06 -================== - - * added support for binary in ACK packets - -2.1.1 / 2014-03-04 -================== - - * removed has-binary-data dependency - * fixed the object check in binary.removeBlobs - -2.1.0 / 2014-03-01 -================== - - * faster and smaller binary parser and protocol [kevin-roark] - -2.0.0 / 2014-02-19 -================== - - * binary support [kevin-roark] - -1.1.2 / 2014-02-11 -================== - - * package: bump `json3` to fix IE6-7 - -1.1.1 / 2014-02-10 -================== - - * package: bump debug to fix browserify issues - -1.1.0 / 2013-12-25 -================== - - * index: use `json3` - -1.0.3 / 2012-12-18 -================== - - * index: added instrumentation through `debug` - * index: make sure decoded `id` is a `Number` - -1.0.2 / 2012-12-18 -================== - - * index: allow for falsy values in `id` and `data` - -1.0.1 / 2012-12-10 -================== - - * Revision 1 + +2.2.2 / 2014-09-04 +================== + + * prevent direct `Buffer` reference that breaks browserify + * binary: reuse `isBuf` helper + +2.2.1 / 2014-06-20 +================== + + * added benchmarking [kevin-roark] + * upgrade component-emitter to 1.1.2 [kevin-roark] + * update protocol version [kevin-roark] + * less indentation and a small optimization [kevin-roark] + +2.2.0 / 2014-05-30 +================== + + * added a BINARY_ACK type [kevin-roark] + +2.1.5 / 2014-05-24 +================== + + * don't iterate keys of `Date` objects [Rase-] + +2.1.4 / 2014-05-17 +================== + + * fix null reconstruction bug [kevin-roark] + +2.1.3 / 2014-04-27 +================== + + * bump zuul version + * updated protocol version + +2.1.2 / 2014-03-06 +================== + + * added support for binary in ACK packets + +2.1.1 / 2014-03-04 +================== + + * removed has-binary-data dependency + * fixed the object check in binary.removeBlobs + +2.1.0 / 2014-03-01 +================== + + * faster and smaller binary parser and protocol [kevin-roark] + +2.0.0 / 2014-02-19 +================== + + * binary support [kevin-roark] + +1.1.2 / 2014-02-11 +================== + + * package: bump `json3` to fix IE6-7 + +1.1.1 / 2014-02-10 +================== + + * package: bump debug to fix browserify issues + +1.1.0 / 2013-12-25 +================== + + * index: use `json3` + +1.0.3 / 2012-12-18 +================== + + * index: added instrumentation through `debug` + * index: make sure decoded `id` is a `Number` + +1.0.2 / 2012-12-18 +================== + + * index: allow for falsy values in `id` and `data` + +1.0.1 / 2012-12-10 +================== + + * Revision 1 diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/Makefile b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/Makefile index 2fa99862..ee0a3b27 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/Makefile +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/Makefile @@ -1,11 +1,11 @@ - -REPORTER = dot - -test: - @./node_modules/.bin/mocha \ - --reporter $(REPORTER) \ - --bail \ - test/index.js - @./node_modules/.bin/zuul -- test/index.js - -.PHONY: test + +REPORTER = dot + +test: + @./node_modules/.bin/mocha \ + --reporter $(REPORTER) \ + --bail \ + test/index.js + @./node_modules/.bin/zuul -- test/index.js + +.PHONY: test diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/Readme.md b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/Readme.md index 34ad306d..2fa0f82d 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/Readme.md +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/Readme.md @@ -1,73 +1,73 @@ - -# socket.io-parser - -[![Build Status](https://secure.travis-ci.org/Automattic/socket.io-parser.svg)](http://travis-ci.org/Automattic/socket.io-parser) -[![NPM version](https://badge.fury.io/js/socket.io-parser.svg)](http://badge.fury.io/js/socket.io-parser) - -A socket.io encoder and decoder written in JavaScript complying with version `3` -of [socket.io-protocol](https://github.com/learnboost/socket.io-protocol). -Used by [socket.io](https://github.com/learnboost/socket.io) and -[socket.io-client](https://github.com/learnboost/socket.io-client). - -## Parser API - - socket.io-parser is the reference implementation of socket.io-protocol. Read - the full API here: - [socket.io-protocol](https://github.com/learnboost/socket.io-protocol). - -## Example Usage - -### Encoding and decoding a packet - -```js -var parser = require('socket.io-parser'); -var encoder = new parser.Encoder(); -var packet = { - type: parser.EVENT, - data: 'test-packet', - id: 13 -}; -encoder.encode(packet, function(encodedPackets) { - var decoder = new parser.Decoder(); - decoder.on('decoded', function(decodedPacket) { - // decodedPacket.type == parser.EVENT - // decodedPacket.data == 'test-packet' - // decodedPacket.id == 13 - }); - - for (var i = 0; i < encodedPackets.length; i++) { - decoder.add(encodedPackets[i]); - } -}); -``` - -### Encoding and decoding a packet with binary data - -```js -var parser = require('socket.io-parser'); -var encoder = new parser.Encoder(); -var packet = { - type: parser.BINARY_EVENT, - data: {i: new Buffer(1234), j: new Blob([new ArrayBuffer(2)])} - id: 15 -}; -encoder.encode(packet, function(encodedPackets) { - var decoder = new parser.Decoder(); - decoder.on('decoded', function(decodedPacket) { - // decodedPacket.type == parser.BINARY_EVENTEVENT - // Buffer.isBuffer(decodedPacket.data.i) == true - // Buffer.isBuffer(decodedPacket.data.j) == true - // decodedPacket.id == 15 - }); - - for (var i = 0; i < encodedPackets.length; i++) { - decoder.add(encodedPackets[i]); - } -}); -``` -See the test suite for more examples of how socket.io-parser is used. - - -## License - -MIT + +# socket.io-parser + +[![Build Status](https://secure.travis-ci.org/Automattic/socket.io-parser.svg)](http://travis-ci.org/Automattic/socket.io-parser) +[![NPM version](https://badge.fury.io/js/socket.io-parser.svg)](http://badge.fury.io/js/socket.io-parser) + +A socket.io encoder and decoder written in JavaScript complying with version `3` +of [socket.io-protocol](https://github.com/learnboost/socket.io-protocol). +Used by [socket.io](https://github.com/learnboost/socket.io) and +[socket.io-client](https://github.com/learnboost/socket.io-client). + +## Parser API + + socket.io-parser is the reference implementation of socket.io-protocol. Read + the full API here: + [socket.io-protocol](https://github.com/learnboost/socket.io-protocol). + +## Example Usage + +### Encoding and decoding a packet + +```js +var parser = require('socket.io-parser'); +var encoder = new parser.Encoder(); +var packet = { + type: parser.EVENT, + data: 'test-packet', + id: 13 +}; +encoder.encode(packet, function(encodedPackets) { + var decoder = new parser.Decoder(); + decoder.on('decoded', function(decodedPacket) { + // decodedPacket.type == parser.EVENT + // decodedPacket.data == 'test-packet' + // decodedPacket.id == 13 + }); + + for (var i = 0; i < encodedPackets.length; i++) { + decoder.add(encodedPackets[i]); + } +}); +``` + +### Encoding and decoding a packet with binary data + +```js +var parser = require('socket.io-parser'); +var encoder = new parser.Encoder(); +var packet = { + type: parser.BINARY_EVENT, + data: {i: new Buffer(1234), j: new Blob([new ArrayBuffer(2)])} + id: 15 +}; +encoder.encode(packet, function(encodedPackets) { + var decoder = new parser.Decoder(); + decoder.on('decoded', function(decodedPacket) { + // decodedPacket.type == parser.BINARY_EVENTEVENT + // Buffer.isBuffer(decodedPacket.data.i) == true + // Buffer.isBuffer(decodedPacket.data.j) == true + // decodedPacket.id == 15 + }); + + for (var i = 0; i < encodedPackets.length; i++) { + decoder.add(encodedPackets[i]); + } +}); +``` +See the test suite for more examples of how socket.io-parser is used. + + +## License + +MIT diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/bench/bench.js b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/bench/bench.js index bba227e8..d767d5a7 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/bench/bench.js +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/bench/bench.js @@ -1,10 +1,10 @@ -var bencher = require('./index'); -bencher(function(benchmark) { - function logMean(test) { - console.log(test.name + ' mean run time: ' + test.stats.mean); - } - - for (var i = 0; i < benchmark.length; i++) { - logMean(benchmark[i]); - } -}); +var bencher = require('./index'); +bencher(function(benchmark) { + function logMean(test) { + console.log(test.name + ' mean run time: ' + test.stats.mean); + } + + for (var i = 0; i < benchmark.length; i++) { + logMean(benchmark[i]); + } +}); diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/bench/index.js b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/bench/index.js index 562584ad..8c1994e0 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/bench/index.js +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/bench/index.js @@ -1,81 +1,81 @@ -var Benchmark = require('benchmark'); -var parser = require('../index'); - -function test(packet, deferred) { - var encoder = new parser.Encoder(); - var decoder = new parser.Decoder(); - encoder.encode(packet, function(encodedPackets) { - var decoder = new parser.Decoder(); - decoder.on('decoded', function(packet) { - deferred.resolve(); - }); - - decoder.add(encodedPackets[0]); - }); -} - -var dataObject = { - 'a': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17], - 'b': 'xxxyyyzzzalsdfalskdjfalksdjfalksdjfalksdjfjjfjfjfjjfjfjfj', - 'data': { - 'is': 'cool', - 'or': { - 'is': { - 'it': true - } - } - } -}; -var bigArray = []; -for (var i = 0; i < 250; i++) { - bigArray.push(dataObject); -} - - - -module.exports = function(callback) { - var suite = new Benchmark.Suite(); - - suite.add('small json parse', {defer: true, fn: function(deferred) { - var packet = { - type: parser.EVENT, - nsp: '/bench', - data: dataObject - }; - test(packet, deferred); - }}) - .add('big json parse', {defer: true, fn: function(deferred) { - var packet = { - type: parser.EVENT, - nsp: '/bench', - data: bigArray - }; - test(packet, deferred); - }}) - .add('json with small binary parse', {defer: true, fn: function(deferred) { - var packet = { - type: parser.EVENT, - nsp: '/bench', - data: {'a': [1, 2, 3], 'b': 'xxxyyyzzz', 'data': new Buffer(1000)} - }; - test(packet, deferred); - }}) - .add('json with big binary parse', {defer: true, fn: function(deferred) { - var bigBinaryData = { - bin1: new Buffer(10000), - arr: bigArray, - bin2: new Buffer(10000), - bin3: new Buffer(10000) - }; - var packet = { - type: parser.EVENT, - nsp: '/bench', - data: bigBinaryData - }; - test(packet, deferred); - }}) - .on('complete', function() { - callback(this); - }) - .run({'async': true}); -}; +var Benchmark = require('benchmark'); +var parser = require('../index'); + +function test(packet, deferred) { + var encoder = new parser.Encoder(); + var decoder = new parser.Decoder(); + encoder.encode(packet, function(encodedPackets) { + var decoder = new parser.Decoder(); + decoder.on('decoded', function(packet) { + deferred.resolve(); + }); + + decoder.add(encodedPackets[0]); + }); +} + +var dataObject = { + 'a': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17], + 'b': 'xxxyyyzzzalsdfalskdjfalksdjfalksdjfalksdjfjjfjfjfjjfjfjfj', + 'data': { + 'is': 'cool', + 'or': { + 'is': { + 'it': true + } + } + } +}; +var bigArray = []; +for (var i = 0; i < 250; i++) { + bigArray.push(dataObject); +} + + + +module.exports = function(callback) { + var suite = new Benchmark.Suite(); + + suite.add('small json parse', {defer: true, fn: function(deferred) { + var packet = { + type: parser.EVENT, + nsp: '/bench', + data: dataObject + }; + test(packet, deferred); + }}) + .add('big json parse', {defer: true, fn: function(deferred) { + var packet = { + type: parser.EVENT, + nsp: '/bench', + data: bigArray + }; + test(packet, deferred); + }}) + .add('json with small binary parse', {defer: true, fn: function(deferred) { + var packet = { + type: parser.EVENT, + nsp: '/bench', + data: {'a': [1, 2, 3], 'b': 'xxxyyyzzz', 'data': new Buffer(1000)} + }; + test(packet, deferred); + }}) + .add('json with big binary parse', {defer: true, fn: function(deferred) { + var bigBinaryData = { + bin1: new Buffer(10000), + arr: bigArray, + bin2: new Buffer(10000), + bin3: new Buffer(10000) + }; + var packet = { + type: parser.EVENT, + nsp: '/bench', + data: bigBinaryData + }; + test(packet, deferred); + }}) + .on('complete', function() { + callback(this); + }) + .run({'async': true}); +}; diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/binary.js b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/binary.js index 5e019f19..b31f40cf 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/binary.js +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/binary.js @@ -1,141 +1,141 @@ -/*global Blob,File*/ - -/** - * Module requirements - */ - -var isArray = require('isarray'); -var isBuf = require('./is-buffer'); - -/** - * Replaces every Buffer | ArrayBuffer in packet with a numbered placeholder. - * Anything with blobs or files should be fed through removeBlobs before coming - * here. - * - * @param {Object} packet - socket.io event packet - * @return {Object} with deconstructed packet and list of buffers - * @api public - */ - -exports.deconstructPacket = function(packet){ - var buffers = []; - var packetData = packet.data; - - function _deconstructPacket(data) { - if (!data) return data; - - if (isBuf(data)) { - var placeholder = { _placeholder: true, num: buffers.length }; - buffers.push(data); - return placeholder; - } else if (isArray(data)) { - var newData = new Array(data.length); - for (var i = 0; i < data.length; i++) { - newData[i] = _deconstructPacket(data[i]); - } - return newData; - } else if ('object' == typeof data && !(data instanceof Date)) { - var newData = {}; - for (var key in data) { - newData[key] = _deconstructPacket(data[key]); - } - return newData; - } - return data; - } - - var pack = packet; - pack.data = _deconstructPacket(packetData); - pack.attachments = buffers.length; // number of binary 'attachments' - return {packet: pack, buffers: buffers}; -}; - -/** - * Reconstructs a binary packet from its placeholder packet and buffers - * - * @param {Object} packet - event packet with placeholders - * @param {Array} buffers - binary buffers to put in placeholder positions - * @return {Object} reconstructed packet - * @api public - */ - -exports.reconstructPacket = function(packet, buffers) { - var curPlaceHolder = 0; - - function _reconstructPacket(data) { - if (data && data._placeholder) { - var buf = buffers[data.num]; // appropriate buffer (should be natural order anyway) - return buf; - } else if (isArray(data)) { - for (var i = 0; i < data.length; i++) { - data[i] = _reconstructPacket(data[i]); - } - return data; - } else if (data && 'object' == typeof data) { - for (var key in data) { - data[key] = _reconstructPacket(data[key]); - } - return data; - } - return data; - } - - packet.data = _reconstructPacket(packet.data); - packet.attachments = undefined; // no longer useful - return packet; -}; - -/** - * Asynchronously removes Blobs or Files from data via - * FileReader's readAsArrayBuffer method. Used before encoding - * data as msgpack. Calls callback with the blobless data. - * - * @param {Object} data - * @param {Function} callback - * @api private - */ - -exports.removeBlobs = function(data, callback) { - function _removeBlobs(obj, curKey, containingObject) { - if (!obj) return obj; - - // convert any blob - if ((global.Blob && obj instanceof Blob) || - (global.File && obj instanceof File)) { - pendingBlobs++; - - // async filereader - var fileReader = new FileReader(); - fileReader.onload = function() { // this.result == arraybuffer - if (containingObject) { - containingObject[curKey] = this.result; - } - else { - bloblessData = this.result; - } - - // if nothing pending its callback time - if(! --pendingBlobs) { - callback(bloblessData); - } - }; - - fileReader.readAsArrayBuffer(obj); // blob -> arraybuffer - } else if (isArray(obj)) { // handle array - for (var i = 0; i < obj.length; i++) { - _removeBlobs(obj[i], i, obj); - } - } else if (obj && 'object' == typeof obj && !isBuf(obj)) { // and object - for (var key in obj) { - _removeBlobs(obj[key], key, obj); - } - } - } - - var pendingBlobs = 0; - var bloblessData = data; - _removeBlobs(bloblessData); - if (!pendingBlobs) { - callback(bloblessData); - } -}; +/*global Blob,File*/ + +/** + * Module requirements + */ + +var isArray = require('isarray'); +var isBuf = require('./is-buffer'); + +/** + * Replaces every Buffer | ArrayBuffer in packet with a numbered placeholder. + * Anything with blobs or files should be fed through removeBlobs before coming + * here. + * + * @param {Object} packet - socket.io event packet + * @return {Object} with deconstructed packet and list of buffers + * @api public + */ + +exports.deconstructPacket = function(packet){ + var buffers = []; + var packetData = packet.data; + + function _deconstructPacket(data) { + if (!data) return data; + + if (isBuf(data)) { + var placeholder = { _placeholder: true, num: buffers.length }; + buffers.push(data); + return placeholder; + } else if (isArray(data)) { + var newData = new Array(data.length); + for (var i = 0; i < data.length; i++) { + newData[i] = _deconstructPacket(data[i]); + } + return newData; + } else if ('object' == typeof data && !(data instanceof Date)) { + var newData = {}; + for (var key in data) { + newData[key] = _deconstructPacket(data[key]); + } + return newData; + } + return data; + } + + var pack = packet; + pack.data = _deconstructPacket(packetData); + pack.attachments = buffers.length; // number of binary 'attachments' + return {packet: pack, buffers: buffers}; +}; + +/** + * Reconstructs a binary packet from its placeholder packet and buffers + * + * @param {Object} packet - event packet with placeholders + * @param {Array} buffers - binary buffers to put in placeholder positions + * @return {Object} reconstructed packet + * @api public + */ + +exports.reconstructPacket = function(packet, buffers) { + var curPlaceHolder = 0; + + function _reconstructPacket(data) { + if (data && data._placeholder) { + var buf = buffers[data.num]; // appropriate buffer (should be natural order anyway) + return buf; + } else if (isArray(data)) { + for (var i = 0; i < data.length; i++) { + data[i] = _reconstructPacket(data[i]); + } + return data; + } else if (data && 'object' == typeof data) { + for (var key in data) { + data[key] = _reconstructPacket(data[key]); + } + return data; + } + return data; + } + + packet.data = _reconstructPacket(packet.data); + packet.attachments = undefined; // no longer useful + return packet; +}; + +/** + * Asynchronously removes Blobs or Files from data via + * FileReader's readAsArrayBuffer method. Used before encoding + * data as msgpack. Calls callback with the blobless data. + * + * @param {Object} data + * @param {Function} callback + * @api private + */ + +exports.removeBlobs = function(data, callback) { + function _removeBlobs(obj, curKey, containingObject) { + if (!obj) return obj; + + // convert any blob + if ((global.Blob && obj instanceof Blob) || + (global.File && obj instanceof File)) { + pendingBlobs++; + + // async filereader + var fileReader = new FileReader(); + fileReader.onload = function() { // this.result == arraybuffer + if (containingObject) { + containingObject[curKey] = this.result; + } + else { + bloblessData = this.result; + } + + // if nothing pending its callback time + if(! --pendingBlobs) { + callback(bloblessData); + } + }; + + fileReader.readAsArrayBuffer(obj); // blob -> arraybuffer + } else if (isArray(obj)) { // handle array + for (var i = 0; i < obj.length; i++) { + _removeBlobs(obj[i], i, obj); + } + } else if (obj && 'object' == typeof obj && !isBuf(obj)) { // and object + for (var key in obj) { + _removeBlobs(obj[key], key, obj); + } + } + } + + var pendingBlobs = 0; + var bloblessData = data; + _removeBlobs(bloblessData); + if (!pendingBlobs) { + callback(bloblessData); + } +}; diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/index.js b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/index.js index 0339d99b..378c4ddf 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/index.js +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/index.js @@ -1,396 +1,396 @@ - -/** - * Module dependencies. - */ - -var debug = require('debug')('socket.io-parser'); -var json = require('json3'); -var isArray = require('isarray'); -var Emitter = require('component-emitter'); -var binary = require('./binary'); -var isBuf = require('./is-buffer'); - -/** - * Protocol version. - * - * @api public - */ - -exports.protocol = 4; - -/** - * Packet types. - * - * @api public - */ - -exports.types = [ - 'CONNECT', - 'DISCONNECT', - 'EVENT', - 'BINARY_EVENT', - 'ACK', - 'BINARY_ACK', - 'ERROR' -]; - -/** - * Packet type `connect`. - * - * @api public - */ - -exports.CONNECT = 0; - -/** - * Packet type `disconnect`. - * - * @api public - */ - -exports.DISCONNECT = 1; - -/** - * Packet type `event`. - * - * @api public - */ - -exports.EVENT = 2; - -/** - * Packet type `ack`. - * - * @api public - */ - -exports.ACK = 3; - -/** - * Packet type `error`. - * - * @api public - */ - -exports.ERROR = 4; - -/** - * Packet type 'binary event' - * - * @api public - */ - -exports.BINARY_EVENT = 5; - -/** - * Packet type `binary ack`. For acks with binary arguments. - * - * @api public - */ - -exports.BINARY_ACK = 6; - -/** - * Encoder constructor. - * - * @api public - */ - -exports.Encoder = Encoder; - -/** - * Decoder constructor. - * - * @api public - */ - -exports.Decoder = Decoder; - -/** - * A socket.io Encoder instance - * - * @api public - */ - -function Encoder() {} - -/** - * Encode a packet as a single string if non-binary, or as a - * buffer sequence, depending on packet type. - * - * @param {Object} obj - packet object - * @param {Function} callback - function to handle encodings (likely engine.write) - * @return Calls callback with Array of encodings - * @api public - */ - -Encoder.prototype.encode = function(obj, callback){ - debug('encoding packet %j', obj); - - if (exports.BINARY_EVENT == obj.type || exports.BINARY_ACK == obj.type) { - encodeAsBinary(obj, callback); - } - else { - var encoding = encodeAsString(obj); - callback([encoding]); - } -}; - -/** - * Encode packet as string. - * - * @param {Object} packet - * @return {String} encoded - * @api private - */ - -function encodeAsString(obj) { - var str = ''; - var nsp = false; - - // first is type - str += obj.type; - - // attachments if we have them - if (exports.BINARY_EVENT == obj.type || exports.BINARY_ACK == obj.type) { - str += obj.attachments; - str += '-'; - } - - // if we have a namespace other than `/` - // we append it followed by a comma `,` - if (obj.nsp && '/' != obj.nsp) { - nsp = true; - str += obj.nsp; - } - - // immediately followed by the id - if (null != obj.id) { - if (nsp) { - str += ','; - nsp = false; - } - str += obj.id; - } - - // json data - if (null != obj.data) { - if (nsp) str += ','; - str += json.stringify(obj.data); - } - - debug('encoded %j as %s', obj, str); - return str; -} - -/** - * Encode packet as 'buffer sequence' by removing blobs, and - * deconstructing packet into object with placeholders and - * a list of buffers. - * - * @param {Object} packet - * @return {Buffer} encoded - * @api private - */ - -function encodeAsBinary(obj, callback) { - - function writeEncoding(bloblessData) { - var deconstruction = binary.deconstructPacket(bloblessData); - var pack = encodeAsString(deconstruction.packet); - var buffers = deconstruction.buffers; - - buffers.unshift(pack); // add packet info to beginning of data list - callback(buffers); // write all the buffers - } - - binary.removeBlobs(obj, writeEncoding); -} - -/** - * A socket.io Decoder instance - * - * @return {Object} decoder - * @api public - */ - -function Decoder() { - this.reconstructor = null; -} - -/** - * Mix in `Emitter` with Decoder. - */ - -Emitter(Decoder.prototype); - -/** - * Decodes an ecoded packet string into packet JSON. - * - * @param {String} obj - encoded packet - * @return {Object} packet - * @api public - */ - -Decoder.prototype.add = function(obj) { - var packet; - if ('string' == typeof obj) { - packet = decodeString(obj); - if (exports.BINARY_EVENT == packet.type || exports.BINARY_ACK == packet.type) { // binary packet's json - this.reconstructor = new BinaryReconstructor(packet); - - // no attachments, labeled binary but no binary data to follow - if (this.reconstructor.reconPack.attachments == 0) { - this.emit('decoded', packet); - } - } else { // non-binary full packet - this.emit('decoded', packet); - } - } - else if (isBuf(obj) || obj.base64) { // raw binary data - if (!this.reconstructor) { - throw new Error('got binary data when not reconstructing a packet'); - } else { - packet = this.reconstructor.takeBinaryData(obj); - if (packet) { // received final buffer - this.reconstructor = null; - this.emit('decoded', packet); - } - } - } - else { - throw new Error('Unknown type: ' + obj); - } -}; - -/** - * Decode a packet String (JSON data) - * - * @param {String} str - * @return {Object} packet - * @api private - */ - -function decodeString(str) { - var p = {}; - var i = 0; - - // look up type - p.type = Number(str.charAt(0)); - if (null == exports.types[p.type]) return error(); - - // look up attachments if type binary - if (exports.BINARY_EVENT == p.type || exports.BINARY_ACK == p.type) { - p.attachments = ''; - while (str.charAt(++i) != '-') { - p.attachments += str.charAt(i); - } - p.attachments = Number(p.attachments); - } - - // look up namespace (if any) - if ('/' == str.charAt(i + 1)) { - p.nsp = ''; - while (++i) { - var c = str.charAt(i); - if (',' == c) break; - p.nsp += c; - if (i + 1 == str.length) break; - } - } else { - p.nsp = '/'; - } - - // look up id - var next = str.charAt(i + 1); - if ('' != next && Number(next) == next) { - p.id = ''; - while (++i) { - var c = str.charAt(i); - if (null == c || Number(c) != c) { - --i; - break; - } - p.id += str.charAt(i); - if (i + 1 == str.length) break; - } - p.id = Number(p.id); - } - - // look up json data - if (str.charAt(++i)) { - try { - p.data = json.parse(str.substr(i)); - } catch(e){ - return error(); - } - } - - debug('decoded %s as %j', str, p); - return p; -} - -/** - * Deallocates a parser's resources - * - * @api public - */ - -Decoder.prototype.destroy = function() { - if (this.reconstructor) { - this.reconstructor.finishedReconstruction(); - } -}; - -/** - * A manager of a binary event's 'buffer sequence'. Should - * be constructed whenever a packet of type BINARY_EVENT is - * decoded. - * - * @param {Object} packet - * @return {BinaryReconstructor} initialized reconstructor - * @api private - */ - -function BinaryReconstructor(packet) { - this.reconPack = packet; - this.buffers = []; -} - -/** - * Method to be called when binary data received from connection - * after a BINARY_EVENT packet. - * - * @param {Buffer | ArrayBuffer} binData - the raw binary data received - * @return {null | Object} returns null if more binary data is expected or - * a reconstructed packet object if all buffers have been received. - * @api private - */ - -BinaryReconstructor.prototype.takeBinaryData = function(binData) { - this.buffers.push(binData); - if (this.buffers.length == this.reconPack.attachments) { // done with buffer list - var packet = binary.reconstructPacket(this.reconPack, this.buffers); - this.finishedReconstruction(); - return packet; - } - return null; -}; - -/** - * Cleans up binary packet reconstruction variables. - * - * @api private - */ - -BinaryReconstructor.prototype.finishedReconstruction = function() { - this.reconPack = null; - this.buffers = []; -}; - -function error(data){ - return { - type: exports.ERROR, - data: 'parser error' - }; -} + +/** + * Module dependencies. + */ + +var debug = require('debug')('socket.io-parser'); +var json = require('json3'); +var isArray = require('isarray'); +var Emitter = require('component-emitter'); +var binary = require('./binary'); +var isBuf = require('./is-buffer'); + +/** + * Protocol version. + * + * @api public + */ + +exports.protocol = 4; + +/** + * Packet types. + * + * @api public + */ + +exports.types = [ + 'CONNECT', + 'DISCONNECT', + 'EVENT', + 'BINARY_EVENT', + 'ACK', + 'BINARY_ACK', + 'ERROR' +]; + +/** + * Packet type `connect`. + * + * @api public + */ + +exports.CONNECT = 0; + +/** + * Packet type `disconnect`. + * + * @api public + */ + +exports.DISCONNECT = 1; + +/** + * Packet type `event`. + * + * @api public + */ + +exports.EVENT = 2; + +/** + * Packet type `ack`. + * + * @api public + */ + +exports.ACK = 3; + +/** + * Packet type `error`. + * + * @api public + */ + +exports.ERROR = 4; + +/** + * Packet type 'binary event' + * + * @api public + */ + +exports.BINARY_EVENT = 5; + +/** + * Packet type `binary ack`. For acks with binary arguments. + * + * @api public + */ + +exports.BINARY_ACK = 6; + +/** + * Encoder constructor. + * + * @api public + */ + +exports.Encoder = Encoder; + +/** + * Decoder constructor. + * + * @api public + */ + +exports.Decoder = Decoder; + +/** + * A socket.io Encoder instance + * + * @api public + */ + +function Encoder() {} + +/** + * Encode a packet as a single string if non-binary, or as a + * buffer sequence, depending on packet type. + * + * @param {Object} obj - packet object + * @param {Function} callback - function to handle encodings (likely engine.write) + * @return Calls callback with Array of encodings + * @api public + */ + +Encoder.prototype.encode = function(obj, callback){ + debug('encoding packet %j', obj); + + if (exports.BINARY_EVENT == obj.type || exports.BINARY_ACK == obj.type) { + encodeAsBinary(obj, callback); + } + else { + var encoding = encodeAsString(obj); + callback([encoding]); + } +}; + +/** + * Encode packet as string. + * + * @param {Object} packet + * @return {String} encoded + * @api private + */ + +function encodeAsString(obj) { + var str = ''; + var nsp = false; + + // first is type + str += obj.type; + + // attachments if we have them + if (exports.BINARY_EVENT == obj.type || exports.BINARY_ACK == obj.type) { + str += obj.attachments; + str += '-'; + } + + // if we have a namespace other than `/` + // we append it followed by a comma `,` + if (obj.nsp && '/' != obj.nsp) { + nsp = true; + str += obj.nsp; + } + + // immediately followed by the id + if (null != obj.id) { + if (nsp) { + str += ','; + nsp = false; + } + str += obj.id; + } + + // json data + if (null != obj.data) { + if (nsp) str += ','; + str += json.stringify(obj.data); + } + + debug('encoded %j as %s', obj, str); + return str; +} + +/** + * Encode packet as 'buffer sequence' by removing blobs, and + * deconstructing packet into object with placeholders and + * a list of buffers. + * + * @param {Object} packet + * @return {Buffer} encoded + * @api private + */ + +function encodeAsBinary(obj, callback) { + + function writeEncoding(bloblessData) { + var deconstruction = binary.deconstructPacket(bloblessData); + var pack = encodeAsString(deconstruction.packet); + var buffers = deconstruction.buffers; + + buffers.unshift(pack); // add packet info to beginning of data list + callback(buffers); // write all the buffers + } + + binary.removeBlobs(obj, writeEncoding); +} + +/** + * A socket.io Decoder instance + * + * @return {Object} decoder + * @api public + */ + +function Decoder() { + this.reconstructor = null; +} + +/** + * Mix in `Emitter` with Decoder. + */ + +Emitter(Decoder.prototype); + +/** + * Decodes an ecoded packet string into packet JSON. + * + * @param {String} obj - encoded packet + * @return {Object} packet + * @api public + */ + +Decoder.prototype.add = function(obj) { + var packet; + if ('string' == typeof obj) { + packet = decodeString(obj); + if (exports.BINARY_EVENT == packet.type || exports.BINARY_ACK == packet.type) { // binary packet's json + this.reconstructor = new BinaryReconstructor(packet); + + // no attachments, labeled binary but no binary data to follow + if (this.reconstructor.reconPack.attachments == 0) { + this.emit('decoded', packet); + } + } else { // non-binary full packet + this.emit('decoded', packet); + } + } + else if (isBuf(obj) || obj.base64) { // raw binary data + if (!this.reconstructor) { + throw new Error('got binary data when not reconstructing a packet'); + } else { + packet = this.reconstructor.takeBinaryData(obj); + if (packet) { // received final buffer + this.reconstructor = null; + this.emit('decoded', packet); + } + } + } + else { + throw new Error('Unknown type: ' + obj); + } +}; + +/** + * Decode a packet String (JSON data) + * + * @param {String} str + * @return {Object} packet + * @api private + */ + +function decodeString(str) { + var p = {}; + var i = 0; + + // look up type + p.type = Number(str.charAt(0)); + if (null == exports.types[p.type]) return error(); + + // look up attachments if type binary + if (exports.BINARY_EVENT == p.type || exports.BINARY_ACK == p.type) { + p.attachments = ''; + while (str.charAt(++i) != '-') { + p.attachments += str.charAt(i); + } + p.attachments = Number(p.attachments); + } + + // look up namespace (if any) + if ('/' == str.charAt(i + 1)) { + p.nsp = ''; + while (++i) { + var c = str.charAt(i); + if (',' == c) break; + p.nsp += c; + if (i + 1 == str.length) break; + } + } else { + p.nsp = '/'; + } + + // look up id + var next = str.charAt(i + 1); + if ('' != next && Number(next) == next) { + p.id = ''; + while (++i) { + var c = str.charAt(i); + if (null == c || Number(c) != c) { + --i; + break; + } + p.id += str.charAt(i); + if (i + 1 == str.length) break; + } + p.id = Number(p.id); + } + + // look up json data + if (str.charAt(++i)) { + try { + p.data = json.parse(str.substr(i)); + } catch(e){ + return error(); + } + } + + debug('decoded %s as %j', str, p); + return p; +} + +/** + * Deallocates a parser's resources + * + * @api public + */ + +Decoder.prototype.destroy = function() { + if (this.reconstructor) { + this.reconstructor.finishedReconstruction(); + } +}; + +/** + * A manager of a binary event's 'buffer sequence'. Should + * be constructed whenever a packet of type BINARY_EVENT is + * decoded. + * + * @param {Object} packet + * @return {BinaryReconstructor} initialized reconstructor + * @api private + */ + +function BinaryReconstructor(packet) { + this.reconPack = packet; + this.buffers = []; +} + +/** + * Method to be called when binary data received from connection + * after a BINARY_EVENT packet. + * + * @param {Buffer | ArrayBuffer} binData - the raw binary data received + * @return {null | Object} returns null if more binary data is expected or + * a reconstructed packet object if all buffers have been received. + * @api private + */ + +BinaryReconstructor.prototype.takeBinaryData = function(binData) { + this.buffers.push(binData); + if (this.buffers.length == this.reconPack.attachments) { // done with buffer list + var packet = binary.reconstructPacket(this.reconPack, this.buffers); + this.finishedReconstruction(); + return packet; + } + return null; +}; + +/** + * Cleans up binary packet reconstruction variables. + * + * @api private + */ + +BinaryReconstructor.prototype.finishedReconstruction = function() { + this.reconPack = null; + this.buffers = []; +}; + +function error(data){ + return { + type: exports.ERROR, + data: 'parser error' + }; +} diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/is-buffer.js b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/is-buffer.js index f71d8226..977df883 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/is-buffer.js +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/is-buffer.js @@ -1,13 +1,13 @@ - -module.exports = isBuf; - -/** - * Returns true if obj is a buffer or an arraybuffer. - * - * @api private - */ - -function isBuf(obj) { - return (global.Buffer && global.Buffer.isBuffer(obj)) || - (global.ArrayBuffer && obj instanceof ArrayBuffer); -} + +module.exports = isBuf; + +/** + * Returns true if obj is a buffer or an arraybuffer. + * + * @api private + */ + +function isBuf(obj) { + return (global.Buffer && global.Buffer.isBuffer(obj)) || + (global.ArrayBuffer && obj instanceof ArrayBuffer); +} diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/benchmark/LICENSE.txt b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/benchmark/LICENSE.txt index 15911c67..e33e63f7 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/benchmark/LICENSE.txt +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/benchmark/LICENSE.txt @@ -1,22 +1,22 @@ -Copyright 2010-2012 Mathias Bynens -Based on JSLitmus.js, copyright Robert Kieffer -Modified by John-David Dalton - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +Copyright 2010-2012 Mathias Bynens +Based on JSLitmus.js, copyright Robert Kieffer +Modified by John-David Dalton + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/benchmark/README.md b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/benchmark/README.md index b418bb57..a3ab3f84 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/benchmark/README.md +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/benchmark/README.md @@ -1,131 +1,131 @@ -# Benchmark.js v1.0.0 - -A [robust](http://calendar.perfplanet.com/2010/bulletproof-javascript-benchmarks/ "Bulletproof JavaScript benchmarks") benchmarking library that works on nearly all JavaScript platforms1, supports high-resolution timers, and returns statistically significant results. As seen on [jsPerf](http://jsperf.com/). - -## BestieJS - -Benchmark.js is part of the BestieJS *"Best in Class"* module collection. This means we promote solid browser/environment support, ES5 precedents, unit testing, and plenty of documentation. - -## Documentation - -The documentation for Benchmark.js can be viewed here: - -For a list of upcoming features, check out our [roadmap](https://github.com/bestiejs/benchmark.js/wiki/Roadmap). - -## Support - -Benchmark.js has been tested in at least Adobe AIR 3.1, Chrome 5-21, Firefox 1.5-13, IE 6-9, Opera 9.25-12.01, Safari 3-6, Node.js 0.8.6, Narwhal 0.3.2, RingoJS 0.8, and Rhino 1.7RC5. - -## Installation and usage - -In a browser or Adobe AIR: - -~~~ html - -~~~ - -Optionally, expose Java’s nanosecond timer by adding the `nano` applet to the ``: - -~~~ html - -~~~ - -Or enable Chrome’s microsecond timer by using the [command line switch](http://peter.sh/experiments/chromium-command-line-switches/#enable-benchmarking): - - --enable-benchmarking - -Via [npm](http://npmjs.org/): - -~~~ bash -npm install benchmark -~~~ - -In [Node.js](http://nodejs.org/) and [RingoJS v0.8.0+](http://ringojs.org/): - -~~~ js -var Benchmark = require('benchmark'); -~~~ - -Optionally, use the [microtime module](https://github.com/wadey/node-microtime) by Wade Simmons: - -~~~ bash -npm install microtime -~~~ - -In [RingoJS v0.7.0-](http://ringojs.org/): - -~~~ js -var Benchmark = require('benchmark').Benchmark; -~~~ - -In [Rhino](http://www.mozilla.org/rhino/): - -~~~ js -load('benchmark.js'); -~~~ - -In an AMD loader like [RequireJS](http://requirejs.org/): - -~~~ js -require({ - 'paths': { - 'benchmark': 'path/to/benchmark' - } -}, -['benchmark'], function(Benchmark) { - console.log(Benchmark.version); -}); - -// or with platform.js -// https://github.com/bestiejs/platform.js -require({ - 'paths': { - 'benchmark': 'path/to/benchmark', - 'platform': 'path/to/platform' - } -}, -['benchmark', 'platform'], function(Benchmark, platform) { - Benchmark.platform = platform; - console.log(Benchmark.platform.name); -}); -~~~ - -Usage example: - -~~~ js -var suite = new Benchmark.Suite; - -// add tests -suite.add('RegExp#test', function() { - /o/.test('Hello World!'); -}) -.add('String#indexOf', function() { - 'Hello World!'.indexOf('o') > -1; -}) -// add listeners -.on('cycle', function(event) { - console.log(String(event.target)); -}) -.on('complete', function() { - console.log('Fastest is ' + this.filter('fastest').pluck('name')); -}) -// run async -.run({ 'async': true }); - -// logs: -// > RegExp#test x 4,161,532 +-0.99% (59 cycles) -// > String#indexOf x 6,139,623 +-1.00% (131 cycles) -// > Fastest is String#indexOf -~~~ - -## Authors - -* [Mathias Bynens](http://mathiasbynens.be/) - [![twitter/mathias](http://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter") -* [John-David Dalton](http://allyoucanleet.com/) - [![twitter/jdalton](http://gravatar.com/avatar/299a3d891ff1920b69c364d061007043?s=70)](https://twitter.com/jdalton "Follow @jdalton on Twitter") - -## Contributors - -* [Kit Cambridge](http://kitcambridge.github.com/) - [![twitter/kitcambridge](http://gravatar.com/avatar/6662a1d02f351b5ef2f8b4d815804661?s=70)](https://twitter.com/kitcambridge "Follow @kitcambridge on Twitter") +# Benchmark.js v1.0.0 + +A [robust](http://calendar.perfplanet.com/2010/bulletproof-javascript-benchmarks/ "Bulletproof JavaScript benchmarks") benchmarking library that works on nearly all JavaScript platforms1, supports high-resolution timers, and returns statistically significant results. As seen on [jsPerf](http://jsperf.com/). + +## BestieJS + +Benchmark.js is part of the BestieJS *"Best in Class"* module collection. This means we promote solid browser/environment support, ES5 precedents, unit testing, and plenty of documentation. + +## Documentation + +The documentation for Benchmark.js can be viewed here: + +For a list of upcoming features, check out our [roadmap](https://github.com/bestiejs/benchmark.js/wiki/Roadmap). + +## Support + +Benchmark.js has been tested in at least Adobe AIR 3.1, Chrome 5-21, Firefox 1.5-13, IE 6-9, Opera 9.25-12.01, Safari 3-6, Node.js 0.8.6, Narwhal 0.3.2, RingoJS 0.8, and Rhino 1.7RC5. + +## Installation and usage + +In a browser or Adobe AIR: + +~~~ html + +~~~ + +Optionally, expose Java’s nanosecond timer by adding the `nano` applet to the ``: + +~~~ html + +~~~ + +Or enable Chrome’s microsecond timer by using the [command line switch](http://peter.sh/experiments/chromium-command-line-switches/#enable-benchmarking): + + --enable-benchmarking + +Via [npm](http://npmjs.org/): + +~~~ bash +npm install benchmark +~~~ + +In [Node.js](http://nodejs.org/) and [RingoJS v0.8.0+](http://ringojs.org/): + +~~~ js +var Benchmark = require('benchmark'); +~~~ + +Optionally, use the [microtime module](https://github.com/wadey/node-microtime) by Wade Simmons: + +~~~ bash +npm install microtime +~~~ + +In [RingoJS v0.7.0-](http://ringojs.org/): + +~~~ js +var Benchmark = require('benchmark').Benchmark; +~~~ + +In [Rhino](http://www.mozilla.org/rhino/): + +~~~ js +load('benchmark.js'); +~~~ + +In an AMD loader like [RequireJS](http://requirejs.org/): + +~~~ js +require({ + 'paths': { + 'benchmark': 'path/to/benchmark' + } +}, +['benchmark'], function(Benchmark) { + console.log(Benchmark.version); +}); + +// or with platform.js +// https://github.com/bestiejs/platform.js +require({ + 'paths': { + 'benchmark': 'path/to/benchmark', + 'platform': 'path/to/platform' + } +}, +['benchmark', 'platform'], function(Benchmark, platform) { + Benchmark.platform = platform; + console.log(Benchmark.platform.name); +}); +~~~ + +Usage example: + +~~~ js +var suite = new Benchmark.Suite; + +// add tests +suite.add('RegExp#test', function() { + /o/.test('Hello World!'); +}) +.add('String#indexOf', function() { + 'Hello World!'.indexOf('o') > -1; +}) +// add listeners +.on('cycle', function(event) { + console.log(String(event.target)); +}) +.on('complete', function() { + console.log('Fastest is ' + this.filter('fastest').pluck('name')); +}) +// run async +.run({ 'async': true }); + +// logs: +// > RegExp#test x 4,161,532 +-0.99% (59 cycles) +// > String#indexOf x 6,139,623 +-1.00% (131 cycles) +// > Fastest is String#indexOf +~~~ + +## Authors + +* [Mathias Bynens](http://mathiasbynens.be/) + [![twitter/mathias](http://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter") +* [John-David Dalton](http://allyoucanleet.com/) + [![twitter/jdalton](http://gravatar.com/avatar/299a3d891ff1920b69c364d061007043?s=70)](https://twitter.com/jdalton "Follow @jdalton on Twitter") + +## Contributors + +* [Kit Cambridge](http://kitcambridge.github.com/) + [![twitter/kitcambridge](http://gravatar.com/avatar/6662a1d02f351b5ef2f8b4d815804661?s=70)](https://twitter.com/kitcambridge "Follow @kitcambridge on Twitter") diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/benchmark/benchmark.js b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/benchmark/benchmark.js index d885a654..d8eb3094 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/benchmark/benchmark.js +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/benchmark/benchmark.js @@ -1,3918 +1,3918 @@ -/*! - * Benchmark.js v1.0.0 - * Copyright 2010-2012 Mathias Bynens - * Based on JSLitmus.js, copyright Robert Kieffer - * Modified by John-David Dalton - * Available under MIT license - */ -;(function(window, undefined) { - 'use strict'; - - /** Used to assign each benchmark an incrimented id */ - var counter = 0; - - /** Detect DOM document object */ - var doc = isHostType(window, 'document') && document; - - /** Detect free variable `define` */ - var freeDefine = typeof define == 'function' && - typeof define.amd == 'object' && define.amd && define; - - /** Detect free variable `exports` */ - var freeExports = typeof exports == 'object' && exports && - (typeof global == 'object' && global && global == global.global && (window = global), exports); - - /** Detect free variable `require` */ - var freeRequire = typeof require == 'function' && require; - - /** Used to crawl all properties regardless of enumerability */ - var getAllKeys = Object.getOwnPropertyNames; - - /** Used to get property descriptors */ - var getDescriptor = Object.getOwnPropertyDescriptor; - - /** Used in case an object doesn't have its own method */ - var hasOwnProperty = {}.hasOwnProperty; - - /** Used to check if an object is extensible */ - var isExtensible = Object.isExtensible || function() { return true; }; - - /** Used to access Wade Simmons' Node microtime module */ - var microtimeObject = req('microtime'); - - /** Used to access the browser's high resolution timer */ - var perfObject = isHostType(window, 'performance') && performance; - - /** Used to call the browser's high resolution timer */ - var perfName = perfObject && ( - perfObject.now && 'now' || - perfObject.webkitNow && 'webkitNow' - ); - - /** Used to access Node's high resolution timer */ - var processObject = isHostType(window, 'process') && process; - - /** Used to check if an own property is enumerable */ - var propertyIsEnumerable = {}.propertyIsEnumerable; - - /** Used to set property descriptors */ - var setDescriptor = Object.defineProperty; - - /** Used to resolve a value's internal [[Class]] */ - var toString = {}.toString; - - /** Used to prevent a `removeChild` memory leak in IE < 9 */ - var trash = doc && doc.createElement('div'); - - /** Used to integrity check compiled tests */ - var uid = 'uid' + (+new Date); - - /** Used to avoid infinite recursion when methods call each other */ - var calledBy = {}; - - /** Used to avoid hz of Infinity */ - var divisors = { - '1': 4096, - '2': 512, - '3': 64, - '4': 8, - '5': 0 - }; - - /** - * T-Distribution two-tailed critical values for 95% confidence - * http://www.itl.nist.gov/div898/handbook/eda/section3/eda3672.htm - */ - var tTable = { - '1': 12.706,'2': 4.303, '3': 3.182, '4': 2.776, '5': 2.571, '6': 2.447, - '7': 2.365, '8': 2.306, '9': 2.262, '10': 2.228, '11': 2.201, '12': 2.179, - '13': 2.16, '14': 2.145, '15': 2.131, '16': 2.12, '17': 2.11, '18': 2.101, - '19': 2.093, '20': 2.086, '21': 2.08, '22': 2.074, '23': 2.069, '24': 2.064, - '25': 2.06, '26': 2.056, '27': 2.052, '28': 2.048, '29': 2.045, '30': 2.042, - 'infinity': 1.96 - }; - - /** - * Critical Mann-Whitney U-values for 95% confidence - * http://www.saburchill.com/IBbiology/stats/003.html - */ - var uTable = { - '5': [0, 1, 2], - '6': [1, 2, 3, 5], - '7': [1, 3, 5, 6, 8], - '8': [2, 4, 6, 8, 10, 13], - '9': [2, 4, 7, 10, 12, 15, 17], - '10': [3, 5, 8, 11, 14, 17, 20, 23], - '11': [3, 6, 9, 13, 16, 19, 23, 26, 30], - '12': [4, 7, 11, 14, 18, 22, 26, 29, 33, 37], - '13': [4, 8, 12, 16, 20, 24, 28, 33, 37, 41, 45], - '14': [5, 9, 13, 17, 22, 26, 31, 36, 40, 45, 50, 55], - '15': [5, 10, 14, 19, 24, 29, 34, 39, 44, 49, 54, 59, 64], - '16': [6, 11, 15, 21, 26, 31, 37, 42, 47, 53, 59, 64, 70, 75], - '17': [6, 11, 17, 22, 28, 34, 39, 45, 51, 57, 63, 67, 75, 81, 87], - '18': [7, 12, 18, 24, 30, 36, 42, 48, 55, 61, 67, 74, 80, 86, 93, 99], - '19': [7, 13, 19, 25, 32, 38, 45, 52, 58, 65, 72, 78, 85, 92, 99, 106, 113], - '20': [8, 14, 20, 27, 34, 41, 48, 55, 62, 69, 76, 83, 90, 98, 105, 112, 119, 127], - '21': [8, 15, 22, 29, 36, 43, 50, 58, 65, 73, 80, 88, 96, 103, 111, 119, 126, 134, 142], - '22': [9, 16, 23, 30, 38, 45, 53, 61, 69, 77, 85, 93, 101, 109, 117, 125, 133, 141, 150, 158], - '23': [9, 17, 24, 32, 40, 48, 56, 64, 73, 81, 89, 98, 106, 115, 123, 132, 140, 149, 157, 166, 175], - '24': [10, 17, 25, 33, 42, 50, 59, 67, 76, 85, 94, 102, 111, 120, 129, 138, 147, 156, 165, 174, 183, 192], - '25': [10, 18, 27, 35, 44, 53, 62, 71, 80, 89, 98, 107, 117, 126, 135, 145, 154, 163, 173, 182, 192, 201, 211], - '26': [11, 19, 28, 37, 46, 55, 64, 74, 83, 93, 102, 112, 122, 132, 141, 151, 161, 171, 181, 191, 200, 210, 220, 230], - '27': [11, 20, 29, 38, 48, 57, 67, 77, 87, 97, 107, 118, 125, 138, 147, 158, 168, 178, 188, 199, 209, 219, 230, 240, 250], - '28': [12, 21, 30, 40, 50, 60, 70, 80, 90, 101, 111, 122, 132, 143, 154, 164, 175, 186, 196, 207, 218, 228, 239, 250, 261, 272], - '29': [13, 22, 32, 42, 52, 62, 73, 83, 94, 105, 116, 127, 138, 149, 160, 171, 182, 193, 204, 215, 226, 238, 249, 260, 271, 282, 294], - '30': [13, 23, 33, 43, 54, 65, 76, 87, 98, 109, 120, 131, 143, 154, 166, 177, 189, 200, 212, 223, 235, 247, 258, 270, 282, 293, 305, 317] - }; - - /** - * An object used to flag environments/features. - * - * @static - * @memberOf Benchmark - * @type Object - */ - var support = {}; - - (function() { - - /** - * Detect Adobe AIR. - * - * @memberOf Benchmark.support - * @type Boolean - */ - support.air = isClassOf(window.runtime, 'ScriptBridgingProxyObject'); - - /** - * Detect if `arguments` objects have the correct internal [[Class]] value. - * - * @memberOf Benchmark.support - * @type Boolean - */ - support.argumentsClass = isClassOf(arguments, 'Arguments'); - - /** - * Detect if in a browser environment. - * - * @memberOf Benchmark.support - * @type Boolean - */ - support.browser = doc && isHostType(window, 'navigator'); - - /** - * Detect if strings support accessing characters by index. - * - * @memberOf Benchmark.support - * @type Boolean - */ - support.charByIndex = - // IE 8 supports indexes on string literals but not string objects - ('x'[0] + Object('x')[0]) == 'xx'; - - /** - * Detect if strings have indexes as own properties. - * - * @memberOf Benchmark.support - * @type Boolean - */ - support.charByOwnIndex = - // Narwhal, Rhino, RingoJS, IE 8, and Opera < 10.52 support indexes on - // strings but don't detect them as own properties - support.charByIndex && hasKey('x', '0'); - - /** - * Detect if Java is enabled/exposed. - * - * @memberOf Benchmark.support - * @type Boolean - */ - support.java = isClassOf(window.java, 'JavaPackage'); - - /** - * Detect if the Timers API exists. - * - * @memberOf Benchmark.support - * @type Boolean - */ - support.timeout = isHostType(window, 'setTimeout') && isHostType(window, 'clearTimeout'); - - /** - * Detect if functions support decompilation. - * - * @name decompilation - * @memberOf Benchmark.support - * @type Boolean - */ - try { - // Safari 2.x removes commas in object literals - // from Function#toString results - // http://webk.it/11609 - // Firefox 3.6 and Opera 9.25 strip grouping - // parentheses from Function#toString results - // http://bugzil.la/559438 - support.decompilation = Function( - 'return (' + (function(x) { return { 'x': '' + (1 + x) + '', 'y': 0 }; }) + ')' - )()(0).x === '1'; - } catch(e) { - support.decompilation = false; - } - - /** - * Detect ES5+ property descriptor API. - * - * @name descriptors - * @memberOf Benchmark.support - * @type Boolean - */ - try { - var o = {}; - support.descriptors = (setDescriptor(o, o, o), 'value' in getDescriptor(o, o)); - } catch(e) { - support.descriptors = false; - } - - /** - * Detect ES5+ Object.getOwnPropertyNames(). - * - * @name getAllKeys - * @memberOf Benchmark.support - * @type Boolean - */ - try { - support.getAllKeys = /\bvalueOf\b/.test(getAllKeys(Object.prototype)); - } catch(e) { - support.getAllKeys = false; - } - - /** - * Detect if own properties are iterated before inherited properties (all but IE < 9). - * - * @name iteratesOwnLast - * @memberOf Benchmark.support - * @type Boolean - */ - support.iteratesOwnFirst = (function() { - var props = []; - function ctor() { this.x = 1; } - ctor.prototype = { 'y': 1 }; - for (var prop in new ctor) { props.push(prop); } - return props[0] == 'x'; - }()); - - /** - * Detect if a node's [[Class]] is resolvable (all but IE < 9) - * and that the JS engine errors when attempting to coerce an object to a - * string without a `toString` property value of `typeof` "function". - * - * @name nodeClass - * @memberOf Benchmark.support - * @type Boolean - */ - try { - support.nodeClass = ({ 'toString': 0 } + '', toString.call(doc || 0) != '[object Object]'); - } catch(e) { - support.nodeClass = true; - } - }()); - - /** - * Timer object used by `clock()` and `Deferred#resolve`. - * - * @private - * @type Object - */ - var timer = { - - /** - * The timer namespace object or constructor. - * - * @private - * @memberOf timer - * @type Function|Object - */ - 'ns': Date, - - /** - * Starts the deferred timer. - * - * @private - * @memberOf timer - * @param {Object} deferred The deferred instance. - */ - 'start': null, // lazy defined in `clock()` - - /** - * Stops the deferred timer. - * - * @private - * @memberOf timer - * @param {Object} deferred The deferred instance. - */ - 'stop': null // lazy defined in `clock()` - }; - - /** Shortcut for inverse results */ - var noArgumentsClass = !support.argumentsClass, - noCharByIndex = !support.charByIndex, - noCharByOwnIndex = !support.charByOwnIndex; - - /** Math shortcuts */ - var abs = Math.abs, - floor = Math.floor, - max = Math.max, - min = Math.min, - pow = Math.pow, - sqrt = Math.sqrt; - - /*--------------------------------------------------------------------------*/ - - /** - * The Benchmark constructor. - * - * @constructor - * @param {String} name A name to identify the benchmark. - * @param {Function|String} fn The test to benchmark. - * @param {Object} [options={}] Options object. - * @example - * - * // basic usage (the `new` operator is optional) - * var bench = new Benchmark(fn); - * - * // or using a name first - * var bench = new Benchmark('foo', fn); - * - * // or with options - * var bench = new Benchmark('foo', fn, { - * - * // displayed by Benchmark#toString if `name` is not available - * 'id': 'xyz', - * - * // called when the benchmark starts running - * 'onStart': onStart, - * - * // called after each run cycle - * 'onCycle': onCycle, - * - * // called when aborted - * 'onAbort': onAbort, - * - * // called when a test errors - * 'onError': onError, - * - * // called when reset - * 'onReset': onReset, - * - * // called when the benchmark completes running - * 'onComplete': onComplete, - * - * // compiled/called before the test loop - * 'setup': setup, - * - * // compiled/called after the test loop - * 'teardown': teardown - * }); - * - * // or name and options - * var bench = new Benchmark('foo', { - * - * // a flag to indicate the benchmark is deferred - * 'defer': true, - * - * // benchmark test function - * 'fn': function(deferred) { - * // call resolve() when the deferred test is finished - * deferred.resolve(); - * } - * }); - * - * // or options only - * var bench = new Benchmark({ - * - * // benchmark name - * 'name': 'foo', - * - * // benchmark test as a string - * 'fn': '[1,2,3,4].sort()' - * }); - * - * // a test's `this` binding is set to the benchmark instance - * var bench = new Benchmark('foo', function() { - * 'My name is '.concat(this.name); // My name is foo - * }); - */ - function Benchmark(name, fn, options) { - var me = this; - - // allow instance creation without the `new` operator - if (me == null || me.constructor != Benchmark) { - return new Benchmark(name, fn, options); - } - // juggle arguments - if (isClassOf(name, 'Object')) { - // 1 argument (options) - options = name; - } - else if (isClassOf(name, 'Function')) { - // 2 arguments (fn, options) - options = fn; - fn = name; - } - else if (isClassOf(fn, 'Object')) { - // 2 arguments (name, options) - options = fn; - fn = null; - me.name = name; - } - else { - // 3 arguments (name, fn [, options]) - me.name = name; - } - setOptions(me, options); - me.id || (me.id = ++counter); - me.fn == null && (me.fn = fn); - me.stats = deepClone(me.stats); - me.times = deepClone(me.times); - } - - /** - * The Deferred constructor. - * - * @constructor - * @memberOf Benchmark - * @param {Object} clone The cloned benchmark instance. - */ - function Deferred(clone) { - var me = this; - if (me == null || me.constructor != Deferred) { - return new Deferred(clone); - } - me.benchmark = clone; - clock(me); - } - - /** - * The Event constructor. - * - * @constructor - * @memberOf Benchmark - * @param {String|Object} type The event type. - */ - function Event(type) { - var me = this; - return (me == null || me.constructor != Event) - ? new Event(type) - : (type instanceof Event) - ? type - : extend(me, { 'timeStamp': +new Date }, typeof type == 'string' ? { 'type': type } : type); - } - - /** - * The Suite constructor. - * - * @constructor - * @memberOf Benchmark - * @param {String} name A name to identify the suite. - * @param {Object} [options={}] Options object. - * @example - * - * // basic usage (the `new` operator is optional) - * var suite = new Benchmark.Suite; - * - * // or using a name first - * var suite = new Benchmark.Suite('foo'); - * - * // or with options - * var suite = new Benchmark.Suite('foo', { - * - * // called when the suite starts running - * 'onStart': onStart, - * - * // called between running benchmarks - * 'onCycle': onCycle, - * - * // called when aborted - * 'onAbort': onAbort, - * - * // called when a test errors - * 'onError': onError, - * - * // called when reset - * 'onReset': onReset, - * - * // called when the suite completes running - * 'onComplete': onComplete - * }); - */ - function Suite(name, options) { - var me = this; - - // allow instance creation without the `new` operator - if (me == null || me.constructor != Suite) { - return new Suite(name, options); - } - // juggle arguments - if (isClassOf(name, 'Object')) { - // 1 argument (options) - options = name; - } else { - // 2 arguments (name [, options]) - me.name = name; - } - setOptions(me, options); - } - - /*--------------------------------------------------------------------------*/ - - /** - * Note: Some array methods have been implemented in plain JavaScript to avoid - * bugs in IE, Opera, Rhino, and Mobile Safari. - * - * IE compatibility mode and IE < 9 have buggy Array `shift()` and `splice()` - * functions that fail to remove the last element, `object[0]`, of - * array-like-objects even though the `length` property is set to `0`. - * The `shift()` method is buggy in IE 8 compatibility mode, while `splice()` - * is buggy regardless of mode in IE < 9 and buggy in compatibility mode in IE 9. - * - * In Opera < 9.50 and some older/beta Mobile Safari versions using `unshift()` - * generically to augment the `arguments` object will pave the value at index 0 - * without incrimenting the other values's indexes. - * https://github.com/documentcloud/underscore/issues/9 - * - * Rhino and environments it powers, like Narwhal and RingoJS, may have - * buggy Array `concat()`, `reverse()`, `shift()`, `slice()`, `splice()` and - * `unshift()` functions that make sparse arrays non-sparse by assigning the - * undefined indexes a value of undefined. - * https://github.com/mozilla/rhino/commit/702abfed3f8ca043b2636efd31c14ba7552603dd - */ - - /** - * Creates an array containing the elements of the host array followed by the - * elements of each argument in order. - * - * @memberOf Benchmark.Suite - * @returns {Array} The new array. - */ - function concat() { - var value, - j = -1, - length = arguments.length, - result = slice.call(this), - index = result.length; - - while (++j < length) { - value = arguments[j]; - if (isClassOf(value, 'Array')) { - for (var k = 0, l = value.length; k < l; k++, index++) { - if (k in value) { - result[index] = value[k]; - } - } - } else { - result[index++] = value; - } - } - return result; - } - - /** - * Utility function used by `shift()`, `splice()`, and `unshift()`. - * - * @private - * @param {Number} start The index to start inserting elements. - * @param {Number} deleteCount The number of elements to delete from the insert point. - * @param {Array} elements The elements to insert. - * @returns {Array} An array of deleted elements. - */ - function insert(start, deleteCount, elements) { - // `result` should have its length set to the `deleteCount` - // see https://bugs.ecmascript.org/show_bug.cgi?id=332 - var deleteEnd = start + deleteCount, - elementCount = elements ? elements.length : 0, - index = start - 1, - length = start + elementCount, - object = this, - result = Array(deleteCount), - tail = slice.call(object, deleteEnd); - - // delete elements from the array - while (++index < deleteEnd) { - if (index in object) { - result[index - start] = object[index]; - delete object[index]; - } - } - // insert elements - index = start - 1; - while (++index < length) { - object[index] = elements[index - start]; - } - // append tail elements - start = index--; - length = max(0, (object.length >>> 0) - deleteCount + elementCount); - while (++index < length) { - if ((index - start) in tail) { - object[index] = tail[index - start]; - } else if (index in object) { - delete object[index]; - } - } - // delete excess elements - deleteCount = deleteCount > elementCount ? deleteCount - elementCount : 0; - while (deleteCount--) { - index = length + deleteCount; - if (index in object) { - delete object[index]; - } - } - object.length = length; - return result; - } - - /** - * Rearrange the host array's elements in reverse order. - * - * @memberOf Benchmark.Suite - * @returns {Array} The reversed array. - */ - function reverse() { - var upperIndex, - value, - index = -1, - object = Object(this), - length = object.length >>> 0, - middle = floor(length / 2); - - if (length > 1) { - while (++index < middle) { - upperIndex = length - index - 1; - value = upperIndex in object ? object[upperIndex] : uid; - if (index in object) { - object[upperIndex] = object[index]; - } else { - delete object[upperIndex]; - } - if (value != uid) { - object[index] = value; - } else { - delete object[index]; - } - } - } - return object; - } - - /** - * Removes the first element of the host array and returns it. - * - * @memberOf Benchmark.Suite - * @returns {Mixed} The first element of the array. - */ - function shift() { - return insert.call(this, 0, 1)[0]; - } - - /** - * Creates an array of the host array's elements from the start index up to, - * but not including, the end index. - * - * @memberOf Benchmark.Suite - * @param {Number} start The starting index. - * @param {Number} end The end index. - * @returns {Array} The new array. - */ - function slice(start, end) { - var index = -1, - object = Object(this), - length = object.length >>> 0, - result = []; - - start = toInteger(start); - start = start < 0 ? max(length + start, 0) : min(start, length); - start--; - end = end == null ? length : toInteger(end); - end = end < 0 ? max(length + end, 0) : min(end, length); - - while ((++index, ++start) < end) { - if (start in object) { - result[index] = object[start]; - } - } - return result; - } - - /** - * Allows removing a range of elements and/or inserting elements into the - * host array. - * - * @memberOf Benchmark.Suite - * @param {Number} start The start index. - * @param {Number} deleteCount The number of elements to delete. - * @param {Mixed} [val1, val2, ...] values to insert at the `start` index. - * @returns {Array} An array of removed elements. - */ - function splice(start, deleteCount) { - var object = Object(this), - length = object.length >>> 0; - - start = toInteger(start); - start = start < 0 ? max(length + start, 0) : min(start, length); - - // support the de-facto SpiderMonkey extension - // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/splice#Parameters - // https://bugs.ecmascript.org/show_bug.cgi?id=429 - deleteCount = arguments.length == 1 - ? length - start - : min(max(toInteger(deleteCount), 0), length - start); - - return insert.call(object, start, deleteCount, slice.call(arguments, 2)); - } - - /** - * Converts the specified `value` to an integer. - * - * @private - * @param {Mixed} value The value to convert. - * @returns {Number} The resulting integer. - */ - function toInteger(value) { - value = +value; - return value === 0 || !isFinite(value) ? value || 0 : value - (value % 1); - } - - /** - * Appends arguments to the host array. - * - * @memberOf Benchmark.Suite - * @returns {Number} The new length. - */ - function unshift() { - var object = Object(this); - insert.call(object, 0, 0, arguments); - return object.length; - } - - /*--------------------------------------------------------------------------*/ - - /** - * A generic `Function#bind` like method. - * - * @private - * @param {Function} fn The function to be bound to `thisArg`. - * @param {Mixed} thisArg The `this` binding for the given function. - * @returns {Function} The bound function. - */ - function bind(fn, thisArg) { - return function() { fn.apply(thisArg, arguments); }; - } - - /** - * Creates a function from the given arguments string and body. - * - * @private - * @param {String} args The comma separated function arguments. - * @param {String} body The function body. - * @returns {Function} The new function. - */ - function createFunction() { - // lazy define - createFunction = function(args, body) { - var result, - anchor = freeDefine ? define.amd : Benchmark, - prop = uid + 'createFunction'; - - runScript((freeDefine ? 'define.amd.' : 'Benchmark.') + prop + '=function(' + args + '){' + body + '}'); - result = anchor[prop]; - delete anchor[prop]; - return result; - }; - // fix JaegerMonkey bug - // http://bugzil.la/639720 - createFunction = support.browser && (createFunction('', 'return"' + uid + '"') || noop)() == uid ? createFunction : Function; - return createFunction.apply(null, arguments); - } - - /** - * Delay the execution of a function based on the benchmark's `delay` property. - * - * @private - * @param {Object} bench The benchmark instance. - * @param {Object} fn The function to execute. - */ - function delay(bench, fn) { - bench._timerId = setTimeout(fn, bench.delay * 1e3); - } - - /** - * Destroys the given element. - * - * @private - * @param {Element} element The element to destroy. - */ - function destroyElement(element) { - trash.appendChild(element); - trash.innerHTML = ''; - } - - /** - * Iterates over an object's properties, executing the `callback` for each. - * Callbacks may terminate the loop by explicitly returning `false`. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} callback The function executed per own property. - * @param {Object} options The options object. - * @returns {Object} Returns the object iterated over. - */ - function forProps() { - var forShadowed, - skipSeen, - forArgs = true, - shadowed = ['constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf']; - - (function(enumFlag, key) { - // must use a non-native constructor to catch the Safari 2 issue - function Klass() { this.valueOf = 0; }; - Klass.prototype.valueOf = 0; - // check various for-in bugs - for (key in new Klass) { - enumFlag += key == 'valueOf' ? 1 : 0; - } - // check if `arguments` objects have non-enumerable indexes - for (key in arguments) { - key == '0' && (forArgs = false); - } - // Safari 2 iterates over shadowed properties twice - // http://replay.waybackmachine.org/20090428222941/http://tobielangel.com/2007/1/29/for-in-loop-broken-in-safari/ - skipSeen = enumFlag == 2; - // IE < 9 incorrectly makes an object's properties non-enumerable if they have - // the same name as other non-enumerable properties in its prototype chain. - forShadowed = !enumFlag; - }(0)); - - // lazy define - forProps = function(object, callback, options) { - options || (options = {}); - - var result = object; - object = Object(object); - - var ctor, - key, - keys, - skipCtor, - done = !result, - which = options.which, - allFlag = which == 'all', - index = -1, - iteratee = object, - length = object.length, - ownFlag = allFlag || which == 'own', - seen = {}, - skipProto = isClassOf(object, 'Function'), - thisArg = options.bind; - - if (thisArg !== undefined) { - callback = bind(callback, thisArg); - } - // iterate all properties - if (allFlag && support.getAllKeys) { - for (index = 0, keys = getAllKeys(object), length = keys.length; index < length; index++) { - key = keys[index]; - if (callback(object[key], key, object) === false) { - break; - } - } - } - // else iterate only enumerable properties - else { - for (key in object) { - // Firefox < 3.6, Opera > 9.50 - Opera < 11.60, and Safari < 5.1 - // (if the prototype or a property on the prototype has been set) - // incorrectly set a function's `prototype` property [[Enumerable]] value - // to `true`. Because of this we standardize on skipping the `prototype` - // property of functions regardless of their [[Enumerable]] value. - if ((done = - !(skipProto && key == 'prototype') && - !(skipSeen && (hasKey(seen, key) || !(seen[key] = true))) && - (!ownFlag || ownFlag && hasKey(object, key)) && - callback(object[key], key, object) === false)) { - break; - } - } - // in IE < 9 strings don't support accessing characters by index - if (!done && (forArgs && isArguments(object) || - ((noCharByIndex || noCharByOwnIndex) && isClassOf(object, 'String') && - (iteratee = noCharByIndex ? object.split('') : object)))) { - while (++index < length) { - if ((done = - callback(iteratee[index], String(index), object) === false)) { - break; - } - } - } - if (!done && forShadowed) { - // Because IE < 9 can't set the `[[Enumerable]]` attribute of an existing - // property and the `constructor` property of a prototype defaults to - // non-enumerable, we manually skip the `constructor` property when we - // think we are iterating over a `prototype` object. - ctor = object.constructor; - skipCtor = ctor && ctor.prototype && ctor.prototype.constructor === ctor; - for (index = 0; index < 7; index++) { - key = shadowed[index]; - if (!(skipCtor && key == 'constructor') && - hasKey(object, key) && - callback(object[key], key, object) === false) { - break; - } - } - } - } - return result; - }; - return forProps.apply(null, arguments); - } - - /** - * Gets the name of the first argument from a function's source. - * - * @private - * @param {Function} fn The function. - * @returns {String} The argument name. - */ - function getFirstArgument(fn) { - return (!hasKey(fn, 'toString') && - (/^[\s(]*function[^(]*\(([^\s,)]+)/.exec(fn) || 0)[1]) || ''; - } - - /** - * Computes the arithmetic mean of a sample. - * - * @private - * @param {Array} sample The sample. - * @returns {Number} The mean. - */ - function getMean(sample) { - return reduce(sample, function(sum, x) { - return sum + x; - }) / sample.length || 0; - } - - /** - * Gets the source code of a function. - * - * @private - * @param {Function} fn The function. - * @param {String} altSource A string used when a function's source code is unretrievable. - * @returns {String} The function's source code. - */ - function getSource(fn, altSource) { - var result = altSource; - if (isStringable(fn)) { - result = String(fn); - } else if (support.decompilation) { - // escape the `{` for Firefox 1 - result = (/^[^{]+\{([\s\S]*)}\s*$/.exec(fn) || 0)[1]; - } - // trim string - result = (result || '').replace(/^\s+|\s+$/g, ''); - - // detect strings containing only the "use strict" directive - return /^(?:\/\*+[\w|\W]*?\*\/|\/\/.*?[\n\r\u2028\u2029]|\s)*(["'])use strict\1;?$/.test(result) - ? '' - : result; - } - - /** - * Checks if a value is an `arguments` object. - * - * @private - * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the value is an `arguments` object, else `false`. - */ - function isArguments() { - // lazy define - isArguments = function(value) { - return toString.call(value) == '[object Arguments]'; - }; - if (noArgumentsClass) { - isArguments = function(value) { - return hasKey(value, 'callee') && - !(propertyIsEnumerable && propertyIsEnumerable.call(value, 'callee')); - }; - } - return isArguments(arguments[0]); - } - - /** - * Checks if an object is of the specified class. - * - * @private - * @param {Mixed} value The value to check. - * @param {String} name The name of the class. - * @returns {Boolean} Returns `true` if the value is of the specified class, else `false`. - */ - function isClassOf(value, name) { - return value != null && toString.call(value) == '[object ' + name + ']'; - } - - /** - * Host objects can return type values that are different from their actual - * data type. The objects we are concerned with usually return non-primitive - * types of object, function, or unknown. - * - * @private - * @param {Mixed} object The owner of the property. - * @param {String} property The property to check. - * @returns {Boolean} Returns `true` if the property value is a non-primitive, else `false`. - */ - function isHostType(object, property) { - var type = object != null ? typeof object[property] : 'number'; - return !/^(?:boolean|number|string|undefined)$/.test(type) && - (type == 'object' ? !!object[property] : true); - } - - /** - * Checks if a given `value` is an object created by the `Object` constructor - * assuming objects created by the `Object` constructor have no inherited - * enumerable properties and that there are no `Object.prototype` extensions. - * - * @private - * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is a plain `Object` object, else `false`. - */ - function isPlainObject(value) { - // avoid non-objects and false positives for `arguments` objects in IE < 9 - var result = false; - if (!(value && typeof value == 'object') || (noArgumentsClass && isArguments(value))) { - return result; - } - // IE < 9 presents DOM nodes as `Object` objects except they have `toString` - // methods that are `typeof` "string" and still can coerce nodes to strings. - // Also check that the constructor is `Object` (i.e. `Object instanceof Object`) - var ctor = value.constructor; - if ((support.nodeClass || !(typeof value.toString != 'function' && typeof (value + '') == 'string')) && - (!isClassOf(ctor, 'Function') || ctor instanceof ctor)) { - // In most environments an object's own properties are iterated before - // its inherited properties. If the last iterated property is an object's - // own property then there are no inherited enumerable properties. - if (support.iteratesOwnFirst) { - forProps(value, function(subValue, subKey) { - result = subKey; - }); - return result === false || hasKey(value, result); - } - // IE < 9 iterates inherited properties before own properties. If the first - // iterated property is an object's own property then there are no inherited - // enumerable properties. - forProps(value, function(subValue, subKey) { - result = !hasKey(value, subKey); - return false; - }); - return result === false; - } - return result; - } - - /** - * Checks if a value can be safely coerced to a string. - * - * @private - * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the value can be coerced, else `false`. - */ - function isStringable(value) { - return hasKey(value, 'toString') || isClassOf(value, 'String'); - } - - /** - * Wraps a function and passes `this` to the original function as the - * first argument. - * - * @private - * @param {Function} fn The function to be wrapped. - * @returns {Function} The new function. - */ - function methodize(fn) { - return function() { - var args = [this]; - args.push.apply(args, arguments); - return fn.apply(null, args); - }; - } - - /** - * A no-operation function. - * - * @private - */ - function noop() { - // no operation performed - } - - /** - * A wrapper around require() to suppress `module missing` errors. - * - * @private - * @param {String} id The module id. - * @returns {Mixed} The exported module or `null`. - */ - function req(id) { - try { - var result = freeExports && freeRequire(id); - } catch(e) { } - return result || null; - } - - /** - * Runs a snippet of JavaScript via script injection. - * - * @private - * @param {String} code The code to run. - */ - function runScript(code) { - var anchor = freeDefine ? define.amd : Benchmark, - script = doc.createElement('script'), - sibling = doc.getElementsByTagName('script')[0], - parent = sibling.parentNode, - prop = uid + 'runScript', - prefix = '(' + (freeDefine ? 'define.amd.' : 'Benchmark.') + prop + '||function(){})();'; - - // Firefox 2.0.0.2 cannot use script injection as intended because it executes - // asynchronously, but that's OK because script injection is only used to avoid - // the previously commented JaegerMonkey bug. - try { - // remove the inserted script *before* running the code to avoid differences - // in the expected script element count/order of the document. - script.appendChild(doc.createTextNode(prefix + code)); - anchor[prop] = function() { destroyElement(script); }; - } catch(e) { - parent = parent.cloneNode(false); - sibling = null; - script.text = code; - } - parent.insertBefore(script, sibling); - delete anchor[prop]; - } - - /** - * A helper function for setting options/event handlers. - * - * @private - * @param {Object} bench The benchmark instance. - * @param {Object} [options={}] Options object. - */ - function setOptions(bench, options) { - options = extend({}, bench.constructor.options, options); - bench.options = forOwn(options, function(value, key) { - if (value != null) { - // add event listeners - if (/^on[A-Z]/.test(key)) { - forEach(key.split(' '), function(key) { - bench.on(key.slice(2).toLowerCase(), value); - }); - } else if (!hasKey(bench, key)) { - bench[key] = deepClone(value); - } - } - }); - } - - /*--------------------------------------------------------------------------*/ - - /** - * Handles cycling/completing the deferred benchmark. - * - * @memberOf Benchmark.Deferred - */ - function resolve() { - var me = this, - clone = me.benchmark, - bench = clone._original; - - if (bench.aborted) { - // cycle() -> clone cycle/complete event -> compute()'s invoked bench.run() cycle/complete - me.teardown(); - clone.running = false; - cycle(me); - } - else if (++me.cycles < clone.count) { - // continue the test loop - if (support.timeout) { - // use setTimeout to avoid a call stack overflow if called recursively - setTimeout(function() { clone.compiled.call(me, timer); }, 0); - } else { - clone.compiled.call(me, timer); - } - } - else { - timer.stop(me); - me.teardown(); - delay(clone, function() { cycle(me); }); - } - } - - /*--------------------------------------------------------------------------*/ - - /** - * A deep clone utility. - * - * @static - * @memberOf Benchmark - * @param {Mixed} value The value to clone. - * @returns {Mixed} The cloned value. - */ - function deepClone(value) { - var accessor, - circular, - clone, - ctor, - descriptor, - extensible, - key, - length, - markerKey, - parent, - result, - source, - subIndex, - data = { 'value': value }, - index = 0, - marked = [], - queue = { 'length': 0 }, - unmarked = []; - - /** - * An easily detectable decorator for cloned values. - */ - function Marker(object) { - this.raw = object; - } - - /** - * The callback used by `forProps()`. - */ - function forPropsCallback(subValue, subKey) { - // exit early to avoid cloning the marker - if (subValue && subValue.constructor == Marker) { - return; - } - // add objects to the queue - if (subValue === Object(subValue)) { - queue[queue.length++] = { 'key': subKey, 'parent': clone, 'source': value }; - } - // assign non-objects - else { - try { - // will throw an error in strict mode if the property is read-only - clone[subKey] = subValue; - } catch(e) { } - } - } - - /** - * Gets an available marker key for the given object. - */ - function getMarkerKey(object) { - // avoid collisions with existing keys - var result = uid; - while (object[result] && object[result].constructor != Marker) { - result += 1; - } - return result; - } - - do { - key = data.key; - parent = data.parent; - source = data.source; - clone = value = source ? source[key] : data.value; - accessor = circular = descriptor = false; - - // create a basic clone to filter out functions, DOM elements, and - // other non `Object` objects - if (value === Object(value)) { - // use custom deep clone function if available - if (isClassOf(value.deepClone, 'Function')) { - clone = value.deepClone(); - } else { - ctor = value.constructor; - switch (toString.call(value)) { - case '[object Array]': - clone = new ctor(value.length); - break; - - case '[object Boolean]': - clone = new ctor(value == true); - break; - - case '[object Date]': - clone = new ctor(+value); - break; - - case '[object Object]': - isPlainObject(value) && (clone = {}); - break; - - case '[object Number]': - case '[object String]': - clone = new ctor(value); - break; - - case '[object RegExp]': - clone = ctor(value.source, - (value.global ? 'g' : '') + - (value.ignoreCase ? 'i' : '') + - (value.multiline ? 'm' : '')); - } - } - // continue clone if `value` doesn't have an accessor descriptor - // http://es5.github.com/#x8.10.1 - if (clone && clone != value && - !(descriptor = source && support.descriptors && getDescriptor(source, key), - accessor = descriptor && (descriptor.get || descriptor.set))) { - // use an existing clone (circular reference) - if ((extensible = isExtensible(value))) { - markerKey = getMarkerKey(value); - if (value[markerKey]) { - circular = clone = value[markerKey].raw; - } - } else { - // for frozen/sealed objects - for (subIndex = 0, length = unmarked.length; subIndex < length; subIndex++) { - data = unmarked[subIndex]; - if (data.object === value) { - circular = clone = data.clone; - break; - } - } - } - if (!circular) { - // mark object to allow quickly detecting circular references and tie it to its clone - if (extensible) { - value[markerKey] = new Marker(clone); - marked.push({ 'key': markerKey, 'object': value }); - } else { - // for frozen/sealed objects - unmarked.push({ 'clone': clone, 'object': value }); - } - // iterate over object properties - forProps(value, forPropsCallback, { 'which': 'all' }); - } - } - } - if (parent) { - // for custom property descriptors - if (accessor || (descriptor && !(descriptor.configurable && descriptor.enumerable && descriptor.writable))) { - if ('value' in descriptor) { - descriptor.value = clone; - } - setDescriptor(parent, key, descriptor); - } - // for default property descriptors - else { - parent[key] = clone; - } - } else { - result = clone; - } - } while ((data = queue[index++])); - - // remove markers - for (index = 0, length = marked.length; index < length; index++) { - data = marked[index]; - delete data.object[data.key]; - } - return result; - } - - /** - * An iteration utility for arrays and objects. - * Callbacks may terminate the loop by explicitly returning `false`. - * - * @static - * @memberOf Benchmark - * @param {Array|Object} object The object to iterate over. - * @param {Function} callback The function called per iteration. - * @param {Mixed} thisArg The `this` binding for the callback. - * @returns {Array|Object} Returns the object iterated over. - */ - function each(object, callback, thisArg) { - var result = object; - object = Object(object); - - var fn = callback, - index = -1, - length = object.length, - isSnapshot = !!(object.snapshotItem && (length = object.snapshotLength)), - isSplittable = (noCharByIndex || noCharByOwnIndex) && isClassOf(object, 'String'), - isConvertable = isSnapshot || isSplittable || 'item' in object, - origObject = object; - - // in Opera < 10.5 `hasKey(object, 'length')` returns `false` for NodeLists - if (length === length >>> 0) { - if (isConvertable) { - // the third argument of the callback is the original non-array object - callback = function(value, index) { - return fn.call(this, value, index, origObject); - }; - // in IE < 9 strings don't support accessing characters by index - if (isSplittable) { - object = object.split(''); - } else { - object = []; - while (++index < length) { - // in Safari 2 `index in object` is always `false` for NodeLists - object[index] = isSnapshot ? result.snapshotItem(index) : result[index]; - } - } - } - forEach(object, callback, thisArg); - } else { - forOwn(object, callback, thisArg); - } - return result; - } - - /** - * Copies enumerable properties from the source(s) object to the destination object. - * - * @static - * @memberOf Benchmark - * @param {Object} destination The destination object. - * @param {Object} [source={}] The source object. - * @returns {Object} The destination object. - */ - function extend(destination, source) { - // Chrome < 14 incorrectly sets `destination` to `undefined` when we `delete arguments[0]` - // http://code.google.com/p/v8/issues/detail?id=839 - var result = destination; - delete arguments[0]; - - forEach(arguments, function(source) { - forProps(source, function(value, key) { - result[key] = value; - }); - }); - return result; - } - - /** - * A generic `Array#filter` like method. - * - * @static - * @memberOf Benchmark - * @param {Array} array The array to iterate over. - * @param {Function|String} callback The function/alias called per iteration. - * @param {Mixed} thisArg The `this` binding for the callback. - * @returns {Array} A new array of values that passed callback filter. - * @example - * - * // get odd numbers - * Benchmark.filter([1, 2, 3, 4, 5], function(n) { - * return n % 2; - * }); // -> [1, 3, 5]; - * - * // get fastest benchmarks - * Benchmark.filter(benches, 'fastest'); - * - * // get slowest benchmarks - * Benchmark.filter(benches, 'slowest'); - * - * // get benchmarks that completed without erroring - * Benchmark.filter(benches, 'successful'); - */ - function filter(array, callback, thisArg) { - var result; - - if (callback == 'successful') { - // callback to exclude those that are errored, unrun, or have hz of Infinity - callback = function(bench) { return bench.cycles && isFinite(bench.hz); }; - } - else if (callback == 'fastest' || callback == 'slowest') { - // get successful, sort by period + margin of error, and filter fastest/slowest - result = filter(array, 'successful').sort(function(a, b) { - a = a.stats; b = b.stats; - return (a.mean + a.moe > b.mean + b.moe ? 1 : -1) * (callback == 'fastest' ? 1 : -1); - }); - result = filter(result, function(bench) { - return result[0].compare(bench) == 0; - }); - } - return result || reduce(array, function(result, value, index) { - return callback.call(thisArg, value, index, array) ? (result.push(value), result) : result; - }, []); - } - - /** - * A generic `Array#forEach` like method. - * Callbacks may terminate the loop by explicitly returning `false`. - * - * @static - * @memberOf Benchmark - * @param {Array} array The array to iterate over. - * @param {Function} callback The function called per iteration. - * @param {Mixed} thisArg The `this` binding for the callback. - * @returns {Array} Returns the array iterated over. - */ - function forEach(array, callback, thisArg) { - var index = -1, - length = (array = Object(array)).length >>> 0; - - if (thisArg !== undefined) { - callback = bind(callback, thisArg); - } - while (++index < length) { - if (index in array && - callback(array[index], index, array) === false) { - break; - } - } - return array; - } - - /** - * Iterates over an object's own properties, executing the `callback` for each. - * Callbacks may terminate the loop by explicitly returning `false`. - * - * @static - * @memberOf Benchmark - * @param {Object} object The object to iterate over. - * @param {Function} callback The function executed per own property. - * @param {Mixed} thisArg The `this` binding for the callback. - * @returns {Object} Returns the object iterated over. - */ - function forOwn(object, callback, thisArg) { - return forProps(object, callback, { 'bind': thisArg, 'which': 'own' }); - } - - /** - * Converts a number to a more readable comma-separated string representation. - * - * @static - * @memberOf Benchmark - * @param {Number} number The number to convert. - * @returns {String} The more readable string representation. - */ - function formatNumber(number) { - number = String(number).split('.'); - return number[0].replace(/(?=(?:\d{3})+$)(?!\b)/g, ',') + - (number[1] ? '.' + number[1] : ''); - } - - /** - * Checks if an object has the specified key as a direct property. - * - * @static - * @memberOf Benchmark - * @param {Object} object The object to check. - * @param {String} key The key to check for. - * @returns {Boolean} Returns `true` if key is a direct property, else `false`. - */ - function hasKey() { - // lazy define for worst case fallback (not as accurate) - hasKey = function(object, key) { - var parent = object != null && (object.constructor || Object).prototype; - return !!parent && key in Object(object) && !(key in parent && object[key] === parent[key]); - }; - // for modern browsers - if (isClassOf(hasOwnProperty, 'Function')) { - hasKey = function(object, key) { - return object != null && hasOwnProperty.call(object, key); - }; - } - // for Safari 2 - else if ({}.__proto__ == Object.prototype) { - hasKey = function(object, key) { - var result = false; - if (object != null) { - object = Object(object); - object.__proto__ = [object.__proto__, object.__proto__ = null, result = key in object][0]; - } - return result; - }; - } - return hasKey.apply(this, arguments); - } - - /** - * A generic `Array#indexOf` like method. - * - * @static - * @memberOf Benchmark - * @param {Array} array The array to iterate over. - * @param {Mixed} value The value to search for. - * @param {Number} [fromIndex=0] The index to start searching from. - * @returns {Number} The index of the matched value or `-1`. - */ - function indexOf(array, value, fromIndex) { - var index = toInteger(fromIndex), - length = (array = Object(array)).length >>> 0; - - index = (index < 0 ? max(0, length + index) : index) - 1; - while (++index < length) { - if (index in array && value === array[index]) { - return index; - } - } - return -1; - } - - /** - * Modify a string by replacing named tokens with matching object property values. - * - * @static - * @memberOf Benchmark - * @param {String} string The string to modify. - * @param {Object} object The template object. - * @returns {String} The modified string. - */ - function interpolate(string, object) { - forOwn(object, function(value, key) { - // escape regexp special characters in `key` - string = string.replace(RegExp('#\\{' + key.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1') + '\\}', 'g'), value); - }); - return string; - } - - /** - * Invokes a method on all items in an array. - * - * @static - * @memberOf Benchmark - * @param {Array} benches Array of benchmarks to iterate over. - * @param {String|Object} name The name of the method to invoke OR options object. - * @param {Mixed} [arg1, arg2, ...] Arguments to invoke the method with. - * @returns {Array} A new array of values returned from each method invoked. - * @example - * - * // invoke `reset` on all benchmarks - * Benchmark.invoke(benches, 'reset'); - * - * // invoke `emit` with arguments - * Benchmark.invoke(benches, 'emit', 'complete', listener); - * - * // invoke `run(true)`, treat benchmarks as a queue, and register invoke callbacks - * Benchmark.invoke(benches, { - * - * // invoke the `run` method - * 'name': 'run', - * - * // pass a single argument - * 'args': true, - * - * // treat as queue, removing benchmarks from front of `benches` until empty - * 'queued': true, - * - * // called before any benchmarks have been invoked. - * 'onStart': onStart, - * - * // called between invoking benchmarks - * 'onCycle': onCycle, - * - * // called after all benchmarks have been invoked. - * 'onComplete': onComplete - * }); - */ - function invoke(benches, name) { - var args, - bench, - queued, - index = -1, - eventProps = { 'currentTarget': benches }, - options = { 'onStart': noop, 'onCycle': noop, 'onComplete': noop }, - result = map(benches, function(bench) { return bench; }); - - /** - * Invokes the method of the current object and if synchronous, fetches the next. - */ - function execute() { - var listeners, - async = isAsync(bench); - - if (async) { - // use `getNext` as the first listener - bench.on('complete', getNext); - listeners = bench.events.complete; - listeners.splice(0, 0, listeners.pop()); - } - // execute method - result[index] = isClassOf(bench && bench[name], 'Function') ? bench[name].apply(bench, args) : undefined; - // if synchronous return true until finished - return !async && getNext(); - } - - /** - * Fetches the next bench or executes `onComplete` callback. - */ - function getNext(event) { - var cycleEvent, - last = bench, - async = isAsync(last); - - if (async) { - last.off('complete', getNext); - last.emit('complete'); - } - // emit "cycle" event - eventProps.type = 'cycle'; - eventProps.target = last; - cycleEvent = Event(eventProps); - options.onCycle.call(benches, cycleEvent); - - // choose next benchmark if not exiting early - if (!cycleEvent.aborted && raiseIndex() !== false) { - bench = queued ? benches[0] : result[index]; - if (isAsync(bench)) { - delay(bench, execute); - } - else if (async) { - // resume execution if previously asynchronous but now synchronous - while (execute()) { } - } - else { - // continue synchronous execution - return true; - } - } else { - // emit "complete" event - eventProps.type = 'complete'; - options.onComplete.call(benches, Event(eventProps)); - } - // When used as a listener `event.aborted = true` will cancel the rest of - // the "complete" listeners because they were already called above and when - // used as part of `getNext` the `return false` will exit the execution while-loop. - if (event) { - event.aborted = true; - } else { - return false; - } - } - - /** - * Checks if invoking `Benchmark#run` with asynchronous cycles. - */ - function isAsync(object) { - // avoid using `instanceof` here because of IE memory leak issues with host objects - var async = args[0] && args[0].async; - return Object(object).constructor == Benchmark && name == 'run' && - ((async == null ? object.options.async : async) && support.timeout || object.defer); - } - - /** - * Raises `index` to the next defined index or returns `false`. - */ - function raiseIndex() { - var length = result.length; - if (queued) { - // if queued remove the previous bench and subsequent skipped non-entries - do { - ++index > 0 && shift.call(benches); - } while ((length = benches.length) && !('0' in benches)); - } - else { - while (++index < length && !(index in result)) { } - } - // if we reached the last index then return `false` - return (queued ? length : index < length) ? index : (index = false); - } - - // juggle arguments - if (isClassOf(name, 'String')) { - // 2 arguments (array, name) - args = slice.call(arguments, 2); - } else { - // 2 arguments (array, options) - options = extend(options, name); - name = options.name; - args = isClassOf(args = 'args' in options ? options.args : [], 'Array') ? args : [args]; - queued = options.queued; - } - - // start iterating over the array - if (raiseIndex() !== false) { - // emit "start" event - bench = result[index]; - eventProps.type = 'start'; - eventProps.target = bench; - options.onStart.call(benches, Event(eventProps)); - - // end early if the suite was aborted in an "onStart" listener - if (benches.aborted && benches.constructor == Suite && name == 'run') { - // emit "cycle" event - eventProps.type = 'cycle'; - options.onCycle.call(benches, Event(eventProps)); - // emit "complete" event - eventProps.type = 'complete'; - options.onComplete.call(benches, Event(eventProps)); - } - // else start - else { - if (isAsync(bench)) { - delay(bench, execute); - } else { - while (execute()) { } - } - } - } - return result; - } - - /** - * Creates a string of joined array values or object key-value pairs. - * - * @static - * @memberOf Benchmark - * @param {Array|Object} object The object to operate on. - * @param {String} [separator1=','] The separator used between key-value pairs. - * @param {String} [separator2=': '] The separator used between keys and values. - * @returns {String} The joined result. - */ - function join(object, separator1, separator2) { - var result = [], - length = (object = Object(object)).length, - arrayLike = length === length >>> 0; - - separator2 || (separator2 = ': '); - each(object, function(value, key) { - result.push(arrayLike ? value : key + separator2 + value); - }); - return result.join(separator1 || ','); - } - - /** - * A generic `Array#map` like method. - * - * @static - * @memberOf Benchmark - * @param {Array} array The array to iterate over. - * @param {Function} callback The function called per iteration. - * @param {Mixed} thisArg The `this` binding for the callback. - * @returns {Array} A new array of values returned by the callback. - */ - function map(array, callback, thisArg) { - return reduce(array, function(result, value, index) { - result[index] = callback.call(thisArg, value, index, array); - return result; - }, Array(Object(array).length >>> 0)); - } - - /** - * Retrieves the value of a specified property from all items in an array. - * - * @static - * @memberOf Benchmark - * @param {Array} array The array to iterate over. - * @param {String} property The property to pluck. - * @returns {Array} A new array of property values. - */ - function pluck(array, property) { - return map(array, function(object) { - return object == null ? undefined : object[property]; - }); - } - - /** - * A generic `Array#reduce` like method. - * - * @static - * @memberOf Benchmark - * @param {Array} array The array to iterate over. - * @param {Function} callback The function called per iteration. - * @param {Mixed} accumulator Initial value of the accumulator. - * @returns {Mixed} The accumulator. - */ - function reduce(array, callback, accumulator) { - var noaccum = arguments.length < 3; - forEach(array, function(value, index) { - accumulator = noaccum ? (noaccum = false, value) : callback(accumulator, value, index, array); - }); - return accumulator; - } - - /*--------------------------------------------------------------------------*/ - - /** - * Aborts all benchmarks in the suite. - * - * @name abort - * @memberOf Benchmark.Suite - * @returns {Object} The suite instance. - */ - function abortSuite() { - var event, - me = this, - resetting = calledBy.resetSuite; - - if (me.running) { - event = Event('abort'); - me.emit(event); - if (!event.cancelled || resetting) { - // avoid infinite recursion - calledBy.abortSuite = true; - me.reset(); - delete calledBy.abortSuite; - - if (!resetting) { - me.aborted = true; - invoke(me, 'abort'); - } - } - } - return me; - } - - /** - * Adds a test to the benchmark suite. - * - * @memberOf Benchmark.Suite - * @param {String} name A name to identify the benchmark. - * @param {Function|String} fn The test to benchmark. - * @param {Object} [options={}] Options object. - * @returns {Object} The benchmark instance. - * @example - * - * // basic usage - * suite.add(fn); - * - * // or using a name first - * suite.add('foo', fn); - * - * // or with options - * suite.add('foo', fn, { - * 'onCycle': onCycle, - * 'onComplete': onComplete - * }); - * - * // or name and options - * suite.add('foo', { - * 'fn': fn, - * 'onCycle': onCycle, - * 'onComplete': onComplete - * }); - * - * // or options only - * suite.add({ - * 'name': 'foo', - * 'fn': fn, - * 'onCycle': onCycle, - * 'onComplete': onComplete - * }); - */ - function add(name, fn, options) { - var me = this, - bench = Benchmark(name, fn, options), - event = Event({ 'type': 'add', 'target': bench }); - - if (me.emit(event), !event.cancelled) { - me.push(bench); - } - return me; - } - - /** - * Creates a new suite with cloned benchmarks. - * - * @name clone - * @memberOf Benchmark.Suite - * @param {Object} options Options object to overwrite cloned options. - * @returns {Object} The new suite instance. - */ - function cloneSuite(options) { - var me = this, - result = new me.constructor(extend({}, me.options, options)); - - // copy own properties - forOwn(me, function(value, key) { - if (!hasKey(result, key)) { - result[key] = value && isClassOf(value.clone, 'Function') - ? value.clone() - : deepClone(value); - } - }); - return result; - } - - /** - * An `Array#filter` like method. - * - * @name filter - * @memberOf Benchmark.Suite - * @param {Function|String} callback The function/alias called per iteration. - * @returns {Object} A new suite of benchmarks that passed callback filter. - */ - function filterSuite(callback) { - var me = this, - result = new me.constructor; - - result.push.apply(result, filter(me, callback)); - return result; - } - - /** - * Resets all benchmarks in the suite. - * - * @name reset - * @memberOf Benchmark.Suite - * @returns {Object} The suite instance. - */ - function resetSuite() { - var event, - me = this, - aborting = calledBy.abortSuite; - - if (me.running && !aborting) { - // no worries, `resetSuite()` is called within `abortSuite()` - calledBy.resetSuite = true; - me.abort(); - delete calledBy.resetSuite; - } - // reset if the state has changed - else if ((me.aborted || me.running) && - (me.emit(event = Event('reset')), !event.cancelled)) { - me.running = false; - if (!aborting) { - invoke(me, 'reset'); - } - } - return me; - } - - /** - * Runs the suite. - * - * @name run - * @memberOf Benchmark.Suite - * @param {Object} [options={}] Options object. - * @returns {Object} The suite instance. - * @example - * - * // basic usage - * suite.run(); - * - * // or with options - * suite.run({ 'async': true, 'queued': true }); - */ - function runSuite(options) { - var me = this; - - me.reset(); - me.running = true; - options || (options = {}); - - invoke(me, { - 'name': 'run', - 'args': options, - 'queued': options.queued, - 'onStart': function(event) { - me.emit(event); - }, - 'onCycle': function(event) { - var bench = event.target; - if (bench.error) { - me.emit({ 'type': 'error', 'target': bench }); - } - me.emit(event); - event.aborted = me.aborted; - }, - 'onComplete': function(event) { - me.running = false; - me.emit(event); - } - }); - return me; - } - - /*--------------------------------------------------------------------------*/ - - /** - * Executes all registered listeners of the specified event type. - * - * @memberOf Benchmark, Benchmark.Suite - * @param {String|Object} type The event type or object. - * @returns {Mixed} Returns the return value of the last listener executed. - */ - function emit(type) { - var listeners, - me = this, - event = Event(type), - events = me.events, - args = (arguments[0] = event, arguments); - - event.currentTarget || (event.currentTarget = me); - event.target || (event.target = me); - delete event.result; - - if (events && (listeners = hasKey(events, event.type) && events[event.type])) { - forEach(listeners.slice(), function(listener) { - if ((event.result = listener.apply(me, args)) === false) { - event.cancelled = true; - } - return !event.aborted; - }); - } - return event.result; - } - - /** - * Returns an array of event listeners for a given type that can be manipulated - * to add or remove listeners. - * - * @memberOf Benchmark, Benchmark.Suite - * @param {String} type The event type. - * @returns {Array} The listeners array. - */ - function listeners(type) { - var me = this, - events = me.events || (me.events = {}); - - return hasKey(events, type) ? events[type] : (events[type] = []); - } - - /** - * Unregisters a listener for the specified event type(s), - * or unregisters all listeners for the specified event type(s), - * or unregisters all listeners for all event types. - * - * @memberOf Benchmark, Benchmark.Suite - * @param {String} [type] The event type. - * @param {Function} [listener] The function to unregister. - * @returns {Object} The benchmark instance. - * @example - * - * // unregister a listener for an event type - * bench.off('cycle', listener); - * - * // unregister a listener for multiple event types - * bench.off('start cycle', listener); - * - * // unregister all listeners for an event type - * bench.off('cycle'); - * - * // unregister all listeners for multiple event types - * bench.off('start cycle complete'); - * - * // unregister all listeners for all event types - * bench.off(); - */ - function off(type, listener) { - var me = this, - events = me.events; - - events && each(type ? type.split(' ') : events, function(listeners, type) { - var index; - if (typeof listeners == 'string') { - type = listeners; - listeners = hasKey(events, type) && events[type]; - } - if (listeners) { - if (listener) { - index = indexOf(listeners, listener); - if (index > -1) { - listeners.splice(index, 1); - } - } else { - listeners.length = 0; - } - } - }); - return me; - } - - /** - * Registers a listener for the specified event type(s). - * - * @memberOf Benchmark, Benchmark.Suite - * @param {String} type The event type. - * @param {Function} listener The function to register. - * @returns {Object} The benchmark instance. - * @example - * - * // register a listener for an event type - * bench.on('cycle', listener); - * - * // register a listener for multiple event types - * bench.on('start cycle', listener); - */ - function on(type, listener) { - var me = this, - events = me.events || (me.events = {}); - - forEach(type.split(' '), function(type) { - (hasKey(events, type) - ? events[type] - : (events[type] = []) - ).push(listener); - }); - return me; - } - - /*--------------------------------------------------------------------------*/ - - /** - * Aborts the benchmark without recording times. - * - * @memberOf Benchmark - * @returns {Object} The benchmark instance. - */ - function abort() { - var event, - me = this, - resetting = calledBy.reset; - - if (me.running) { - event = Event('abort'); - me.emit(event); - if (!event.cancelled || resetting) { - // avoid infinite recursion - calledBy.abort = true; - me.reset(); - delete calledBy.abort; - - if (support.timeout) { - clearTimeout(me._timerId); - delete me._timerId; - } - if (!resetting) { - me.aborted = true; - me.running = false; - } - } - } - return me; - } - - /** - * Creates a new benchmark using the same test and options. - * - * @memberOf Benchmark - * @param {Object} options Options object to overwrite cloned options. - * @returns {Object} The new benchmark instance. - * @example - * - * var bizarro = bench.clone({ - * 'name': 'doppelganger' - * }); - */ - function clone(options) { - var me = this, - result = new me.constructor(extend({}, me, options)); - - // correct the `options` object - result.options = extend({}, me.options, options); - - // copy own custom properties - forOwn(me, function(value, key) { - if (!hasKey(result, key)) { - result[key] = deepClone(value); - } - }); - return result; - } - - /** - * Determines if a benchmark is faster than another. - * - * @memberOf Benchmark - * @param {Object} other The benchmark to compare. - * @returns {Number} Returns `-1` if slower, `1` if faster, and `0` if indeterminate. - */ - function compare(other) { - var critical, - zStat, - me = this, - sample1 = me.stats.sample, - sample2 = other.stats.sample, - size1 = sample1.length, - size2 = sample2.length, - maxSize = max(size1, size2), - minSize = min(size1, size2), - u1 = getU(sample1, sample2), - u2 = getU(sample2, sample1), - u = min(u1, u2); - - function getScore(xA, sampleB) { - return reduce(sampleB, function(total, xB) { - return total + (xB > xA ? 0 : xB < xA ? 1 : 0.5); - }, 0); - } - - function getU(sampleA, sampleB) { - return reduce(sampleA, function(total, xA) { - return total + getScore(xA, sampleB); - }, 0); - } - - function getZ(u) { - return (u - ((size1 * size2) / 2)) / sqrt((size1 * size2 * (size1 + size2 + 1)) / 12); - } - - // exit early if comparing the same benchmark - if (me == other) { - return 0; - } - // reject the null hyphothesis the two samples come from the - // same population (i.e. have the same median) if... - if (size1 + size2 > 30) { - // ...the z-stat is greater than 1.96 or less than -1.96 - // http://www.statisticslectures.com/topics/mannwhitneyu/ - zStat = getZ(u); - return abs(zStat) > 1.96 ? (zStat > 0 ? -1 : 1) : 0; - } - // ...the U value is less than or equal the critical U value - // http://www.geoib.com/mann-whitney-u-test.html - critical = maxSize < 5 || minSize < 3 ? 0 : uTable[maxSize][minSize - 3]; - return u <= critical ? (u == u1 ? 1 : -1) : 0; - } - - /** - * Reset properties and abort if running. - * - * @memberOf Benchmark - * @returns {Object} The benchmark instance. - */ - function reset() { - var data, - event, - me = this, - index = 0, - changes = { 'length': 0 }, - queue = { 'length': 0 }; - - if (me.running && !calledBy.abort) { - // no worries, `reset()` is called within `abort()` - calledBy.reset = true; - me.abort(); - delete calledBy.reset; - } - else { - // a non-recursive solution to check if properties have changed - // http://www.jslab.dk/articles/non.recursive.preorder.traversal.part4 - data = { 'destination': me, 'source': extend({}, me.constructor.prototype, me.options) }; - do { - forOwn(data.source, function(value, key) { - var changed, - destination = data.destination, - currValue = destination[key]; - - if (value && typeof value == 'object') { - if (isClassOf(value, 'Array')) { - // check if an array value has changed to a non-array value - if (!isClassOf(currValue, 'Array')) { - changed = currValue = []; - } - // or has changed its length - if (currValue.length != value.length) { - changed = currValue = currValue.slice(0, value.length); - currValue.length = value.length; - } - } - // check if an object has changed to a non-object value - else if (!currValue || typeof currValue != 'object') { - changed = currValue = {}; - } - // register a changed object - if (changed) { - changes[changes.length++] = { 'destination': destination, 'key': key, 'value': currValue }; - } - queue[queue.length++] = { 'destination': currValue, 'source': value }; - } - // register a changed primitive - else if (value !== currValue && !(value == null || isClassOf(value, 'Function'))) { - changes[changes.length++] = { 'destination': destination, 'key': key, 'value': value }; - } - }); - } - while ((data = queue[index++])); - - // if changed emit the `reset` event and if it isn't cancelled reset the benchmark - if (changes.length && (me.emit(event = Event('reset')), !event.cancelled)) { - forEach(changes, function(data) { - data.destination[data.key] = data.value; - }); - } - } - return me; - } - - /** - * Displays relevant benchmark information when coerced to a string. - * - * @name toString - * @memberOf Benchmark - * @returns {String} A string representation of the benchmark instance. - */ - function toStringBench() { - var me = this, - error = me.error, - hz = me.hz, - id = me.id, - stats = me.stats, - size = stats.sample.length, - pm = support.java ? '+/-' : '\xb1', - result = me.name || (isNaN(id) ? id : ''); - - if (error) { - result += ': ' + join(error); - } else { - result += ' x ' + formatNumber(hz.toFixed(hz < 100 ? 2 : 0)) + ' ops/sec ' + pm + - stats.rme.toFixed(2) + '% (' + size + ' run' + (size == 1 ? '' : 's') + ' sampled)'; - } - return result; - } - - /*--------------------------------------------------------------------------*/ - - /** - * Clocks the time taken to execute a test per cycle (secs). - * - * @private - * @param {Object} bench The benchmark instance. - * @returns {Number} The time taken. - */ - function clock() { - var applet, - options = Benchmark.options, - template = { 'begin': 's$=new n$', 'end': 'r$=(new n$-s$)/1e3', 'uid': uid }, - timers = [{ 'ns': timer.ns, 'res': max(0.0015, getRes('ms')), 'unit': 'ms' }]; - - // lazy define for hi-res timers - clock = function(clone) { - var deferred; - if (clone instanceof Deferred) { - deferred = clone; - clone = deferred.benchmark; - } - - var bench = clone._original, - fn = bench.fn, - fnArg = deferred ? getFirstArgument(fn) || 'deferred' : '', - stringable = isStringable(fn); - - var source = { - 'setup': getSource(bench.setup, preprocess('m$.setup()')), - 'fn': getSource(fn, preprocess('m$.fn(' + fnArg + ')')), - 'fnArg': fnArg, - 'teardown': getSource(bench.teardown, preprocess('m$.teardown()')) - }; - - var count = bench.count = clone.count, - decompilable = support.decompilation || stringable, - id = bench.id, - isEmpty = !(source.fn || stringable), - name = bench.name || (typeof id == 'number' ? '' : id), - ns = timer.ns, - result = 0; - - // init `minTime` if needed - clone.minTime = bench.minTime || (bench.minTime = bench.options.minTime = options.minTime); - - // repair nanosecond timer - // (some Chrome builds erase the `ns` variable after millions of executions) - if (applet) { - try { - ns.nanoTime(); - } catch(e) { - // use non-element to avoid issues with libs that augment them - ns = timer.ns = new applet.Packages.nano; - } - } - - // Compile in setup/teardown functions and the test loop. - // Create a new compiled test, instead of using the cached `bench.compiled`, - // to avoid potential engine optimizations enabled over the life of the test. - var compiled = bench.compiled = createFunction(preprocess('t$'), interpolate( - preprocess(deferred - ? 'var d$=this,#{fnArg}=d$,m$=d$.benchmark._original,f$=m$.fn,su$=m$.setup,td$=m$.teardown;' + - // when `deferred.cycles` is `0` then... - 'if(!d$.cycles){' + - // set `deferred.fn` - 'd$.fn=function(){var #{fnArg}=d$;if(typeof f$=="function"){try{#{fn}\n}catch(e$){f$(d$)}}else{#{fn}\n}};' + - // set `deferred.teardown` - 'd$.teardown=function(){d$.cycles=0;if(typeof td$=="function"){try{#{teardown}\n}catch(e$){td$()}}else{#{teardown}\n}};' + - // execute the benchmark's `setup` - 'if(typeof su$=="function"){try{#{setup}\n}catch(e$){su$()}}else{#{setup}\n};' + - // start timer - 't$.start(d$);' + - // execute `deferred.fn` and return a dummy object - '}d$.fn();return{}' - - : 'var r$,s$,m$=this,f$=m$.fn,i$=m$.count,n$=t$.ns;#{setup}\n#{begin};' + - 'while(i$--){#{fn}\n}#{end};#{teardown}\nreturn{elapsed:r$,uid:"#{uid}"}'), - source - )); - - try { - if (isEmpty) { - // Firefox may remove dead code from Function#toString results - // http://bugzil.la/536085 - throw new Error('The test "' + name + '" is empty. This may be the result of dead code removal.'); - } - else if (!deferred) { - // pretest to determine if compiled code is exits early, usually by a - // rogue `return` statement, by checking for a return object with the uid - bench.count = 1; - compiled = (compiled.call(bench, timer) || {}).uid == uid && compiled; - bench.count = count; - } - } catch(e) { - compiled = null; - clone.error = e || new Error(String(e)); - bench.count = count; - } - // fallback when a test exits early or errors during pretest - if (decompilable && !compiled && !deferred && !isEmpty) { - compiled = createFunction(preprocess('t$'), interpolate( - preprocess( - (clone.error && !stringable - ? 'var r$,s$,m$=this,f$=m$.fn,i$=m$.count' - : 'function f$(){#{fn}\n}var r$,s$,m$=this,i$=m$.count' - ) + - ',n$=t$.ns;#{setup}\n#{begin};m$.f$=f$;while(i$--){m$.f$()}#{end};' + - 'delete m$.f$;#{teardown}\nreturn{elapsed:r$}' - ), - source - )); - - try { - // pretest one more time to check for errors - bench.count = 1; - compiled.call(bench, timer); - bench.compiled = compiled; - bench.count = count; - delete clone.error; - } - catch(e) { - bench.count = count; - if (clone.error) { - compiled = null; - } else { - bench.compiled = compiled; - clone.error = e || new Error(String(e)); - } - } - } - // assign `compiled` to `clone` before calling in case a deferred benchmark - // immediately calls `deferred.resolve()` - clone.compiled = compiled; - // if no errors run the full test loop - if (!clone.error) { - result = compiled.call(deferred || bench, timer).elapsed; - } - return result; - }; - - /*------------------------------------------------------------------------*/ - - /** - * Gets the current timer's minimum resolution (secs). - */ - function getRes(unit) { - var measured, - begin, - count = 30, - divisor = 1e3, - ns = timer.ns, - sample = []; - - // get average smallest measurable time - while (count--) { - if (unit == 'us') { - divisor = 1e6; - if (ns.stop) { - ns.start(); - while (!(measured = ns.microseconds())) { } - } else if (ns[perfName]) { - divisor = 1e3; - measured = Function('n', 'var r,s=n.' + perfName + '();while(!(r=n.' + perfName + '()-s)){};return r')(ns); - } else { - begin = ns(); - while (!(measured = ns() - begin)) { } - } - } - else if (unit == 'ns') { - divisor = 1e9; - if (ns.nanoTime) { - begin = ns.nanoTime(); - while (!(measured = ns.nanoTime() - begin)) { } - } else { - begin = (begin = ns())[0] + (begin[1] / divisor); - while (!(measured = ((measured = ns())[0] + (measured[1] / divisor)) - begin)) { } - divisor = 1; - } - } - else { - begin = new ns; - while (!(measured = new ns - begin)) { } - } - // check for broken timers (nanoTime may have issues) - // http://alivebutsleepy.srnet.cz/unreliable-system-nanotime/ - if (measured > 0) { - sample.push(measured); - } else { - sample.push(Infinity); - break; - } - } - // convert to seconds - return getMean(sample) / divisor; - } - - /** - * Replaces all occurrences of `$` with a unique number and - * template tokens with content. - */ - function preprocess(code) { - return interpolate(code, template).replace(/\$/g, /\d+/.exec(uid)); - } - - /*------------------------------------------------------------------------*/ - - // detect nanosecond support from a Java applet - each(doc && doc.applets || [], function(element) { - return !(timer.ns = applet = 'nanoTime' in element && element); - }); - - // check type in case Safari returns an object instead of a number - try { - if (typeof timer.ns.nanoTime() == 'number') { - timers.push({ 'ns': timer.ns, 'res': getRes('ns'), 'unit': 'ns' }); - } - } catch(e) { } - - // detect Chrome's microsecond timer: - // enable benchmarking via the --enable-benchmarking command - // line switch in at least Chrome 7 to use chrome.Interval - try { - if ((timer.ns = new (window.chrome || window.chromium).Interval)) { - timers.push({ 'ns': timer.ns, 'res': getRes('us'), 'unit': 'us' }); - } - } catch(e) { } - - // detect `performance.now` microsecond resolution timer - if ((timer.ns = perfName && perfObject)) { - timers.push({ 'ns': timer.ns, 'res': getRes('us'), 'unit': 'us' }); - } - - // detect Node's nanosecond resolution timer available in Node >= 0.8 - if (processObject && typeof (timer.ns = processObject.hrtime) == 'function') { - timers.push({ 'ns': timer.ns, 'res': getRes('ns'), 'unit': 'ns' }); - } - - // detect Wade Simmons' Node microtime module - if (microtimeObject && typeof (timer.ns = microtimeObject.now) == 'function') { - timers.push({ 'ns': timer.ns, 'res': getRes('us'), 'unit': 'us' }); - } - - // pick timer with highest resolution - timer = reduce(timers, function(timer, other) { - return other.res < timer.res ? other : timer; - }); - - // remove unused applet - if (timer.unit != 'ns' && applet) { - applet = destroyElement(applet); - } - // error if there are no working timers - if (timer.res == Infinity) { - throw new Error('Benchmark.js was unable to find a working timer.'); - } - // use API of chosen timer - if (timer.unit == 'ns') { - if (timer.ns.nanoTime) { - extend(template, { - 'begin': 's$=n$.nanoTime()', - 'end': 'r$=(n$.nanoTime()-s$)/1e9' - }); - } else { - extend(template, { - 'begin': 's$=n$()', - 'end': 'r$=n$(s$);r$=r$[0]+(r$[1]/1e9)' - }); - } - } - else if (timer.unit == 'us') { - if (timer.ns.stop) { - extend(template, { - 'begin': 's$=n$.start()', - 'end': 'r$=n$.microseconds()/1e6' - }); - } else if (perfName) { - extend(template, { - 'begin': 's$=n$.' + perfName + '()', - 'end': 'r$=(n$.' + perfName + '()-s$)/1e3' - }); - } else { - extend(template, { - 'begin': 's$=n$()', - 'end': 'r$=(n$()-s$)/1e6' - }); - } - } - - // define `timer` methods - timer.start = createFunction(preprocess('o$'), - preprocess('var n$=this.ns,#{begin};o$.elapsed=0;o$.timeStamp=s$')); - - timer.stop = createFunction(preprocess('o$'), - preprocess('var n$=this.ns,s$=o$.timeStamp,#{end};o$.elapsed=r$')); - - // resolve time span required to achieve a percent uncertainty of at most 1% - // http://spiff.rit.edu/classes/phys273/uncert/uncert.html - options.minTime || (options.minTime = max(timer.res / 2 / 0.01, 0.05)); - return clock.apply(null, arguments); - } - - /*--------------------------------------------------------------------------*/ - - /** - * Computes stats on benchmark results. - * - * @private - * @param {Object} bench The benchmark instance. - * @param {Object} options The options object. - */ - function compute(bench, options) { - options || (options = {}); - - var async = options.async, - elapsed = 0, - initCount = bench.initCount, - minSamples = bench.minSamples, - queue = [], - sample = bench.stats.sample; - - /** - * Adds a clone to the queue. - */ - function enqueue() { - queue.push(bench.clone({ - '_original': bench, - 'events': { - 'abort': [update], - 'cycle': [update], - 'error': [update], - 'start': [update] - } - })); - } - - /** - * Updates the clone/original benchmarks to keep their data in sync. - */ - function update(event) { - var clone = this, - type = event.type; - - if (bench.running) { - if (type == 'start') { - // Note: `clone.minTime` prop is inited in `clock()` - clone.count = bench.initCount; - } - else { - if (type == 'error') { - bench.error = clone.error; - } - if (type == 'abort') { - bench.abort(); - bench.emit('cycle'); - } else { - event.currentTarget = event.target = bench; - bench.emit(event); - } - } - } else if (bench.aborted) { - // clear abort listeners to avoid triggering bench's abort/cycle again - clone.events.abort.length = 0; - clone.abort(); - } - } - - /** - * Determines if more clones should be queued or if cycling should stop. - */ - function evaluate(event) { - var critical, - df, - mean, - moe, - rme, - sd, - sem, - variance, - clone = event.target, - done = bench.aborted, - now = +new Date, - size = sample.push(clone.times.period), - maxedOut = size >= minSamples && (elapsed += now - clone.times.timeStamp) / 1e3 > bench.maxTime, - times = bench.times, - varOf = function(sum, x) { return sum + pow(x - mean, 2); }; - - // exit early for aborted or unclockable tests - if (done || clone.hz == Infinity) { - maxedOut = !(size = sample.length = queue.length = 0); - } - - if (!done) { - // sample mean (estimate of the population mean) - mean = getMean(sample); - // sample variance (estimate of the population variance) - variance = reduce(sample, varOf, 0) / (size - 1) || 0; - // sample standard deviation (estimate of the population standard deviation) - sd = sqrt(variance); - // standard error of the mean (a.k.a. the standard deviation of the sampling distribution of the sample mean) - sem = sd / sqrt(size); - // degrees of freedom - df = size - 1; - // critical value - critical = tTable[Math.round(df) || 1] || tTable.infinity; - // margin of error - moe = sem * critical; - // relative margin of error - rme = (moe / mean) * 100 || 0; - - extend(bench.stats, { - 'deviation': sd, - 'mean': mean, - 'moe': moe, - 'rme': rme, - 'sem': sem, - 'variance': variance - }); - - // Abort the cycle loop when the minimum sample size has been collected - // and the elapsed time exceeds the maximum time allowed per benchmark. - // We don't count cycle delays toward the max time because delays may be - // increased by browsers that clamp timeouts for inactive tabs. - // https://developer.mozilla.org/en/window.setTimeout#Inactive_tabs - if (maxedOut) { - // reset the `initCount` in case the benchmark is rerun - bench.initCount = initCount; - bench.running = false; - done = true; - times.elapsed = (now - times.timeStamp) / 1e3; - } - if (bench.hz != Infinity) { - bench.hz = 1 / mean; - times.cycle = mean * bench.count; - times.period = mean; - } - } - // if time permits, increase sample size to reduce the margin of error - if (queue.length < 2 && !maxedOut) { - enqueue(); - } - // abort the invoke cycle when done - event.aborted = done; - } - - // init queue and begin - enqueue(); - invoke(queue, { - 'name': 'run', - 'args': { 'async': async }, - 'queued': true, - 'onCycle': evaluate, - 'onComplete': function() { bench.emit('complete'); } - }); - } - - /*--------------------------------------------------------------------------*/ - - /** - * Cycles a benchmark until a run `count` can be established. - * - * @private - * @param {Object} clone The cloned benchmark instance. - * @param {Object} options The options object. - */ - function cycle(clone, options) { - options || (options = {}); - - var deferred; - if (clone instanceof Deferred) { - deferred = clone; - clone = clone.benchmark; - } - - var clocked, - cycles, - divisor, - event, - minTime, - period, - async = options.async, - bench = clone._original, - count = clone.count, - times = clone.times; - - // continue, if not aborted between cycles - if (clone.running) { - // `minTime` is set to `Benchmark.options.minTime` in `clock()` - cycles = ++clone.cycles; - clocked = deferred ? deferred.elapsed : clock(clone); - minTime = clone.minTime; - - if (cycles > bench.cycles) { - bench.cycles = cycles; - } - if (clone.error) { - event = Event('error'); - event.message = clone.error; - clone.emit(event); - if (!event.cancelled) { - clone.abort(); - } - } - } - - // continue, if not errored - if (clone.running) { - // time taken to complete last test cycle - bench.times.cycle = times.cycle = clocked; - // seconds per operation - period = bench.times.period = times.period = clocked / count; - // ops per second - bench.hz = clone.hz = 1 / period; - // avoid working our way up to this next time - bench.initCount = clone.initCount = count; - // do we need to do another cycle? - clone.running = clocked < minTime; - - if (clone.running) { - // tests may clock at `0` when `initCount` is a small number, - // to avoid that we set its count to something a bit higher - if (!clocked && (divisor = divisors[clone.cycles]) != null) { - count = floor(4e6 / divisor); - } - // calculate how many more iterations it will take to achive the `minTime` - if (count <= clone.count) { - count += Math.ceil((minTime - clocked) / period); - } - clone.running = count != Infinity; - } - } - // should we exit early? - event = Event('cycle'); - clone.emit(event); - if (event.aborted) { - clone.abort(); - } - // figure out what to do next - if (clone.running) { - // start a new cycle - clone.count = count; - if (deferred) { - clone.compiled.call(deferred, timer); - } else if (async) { - delay(clone, function() { cycle(clone, options); }); - } else { - cycle(clone); - } - } - else { - // fix TraceMonkey bug associated with clock fallbacks - // http://bugzil.la/509069 - if (support.browser) { - runScript(uid + '=1;delete ' + uid); - } - // done - clone.emit('complete'); - } - } - - /*--------------------------------------------------------------------------*/ - - /** - * Runs the benchmark. - * - * @memberOf Benchmark - * @param {Object} [options={}] Options object. - * @returns {Object} The benchmark instance. - * @example - * - * // basic usage - * bench.run(); - * - * // or with options - * bench.run({ 'async': true }); - */ - function run(options) { - var me = this, - event = Event('start'); - - // set `running` to `false` so `reset()` won't call `abort()` - me.running = false; - me.reset(); - me.running = true; - - me.count = me.initCount; - me.times.timeStamp = +new Date; - me.emit(event); - - if (!event.cancelled) { - options = { 'async': ((options = options && options.async) == null ? me.async : options) && support.timeout }; - - // for clones created within `compute()` - if (me._original) { - if (me.defer) { - Deferred(me); - } else { - cycle(me, options); - } - } - // for original benchmarks - else { - compute(me, options); - } - } - return me; - } - - /*--------------------------------------------------------------------------*/ - - // Firefox 1 erroneously defines variable and argument names of functions on - // the function itself as non-configurable properties with `undefined` values. - // The bugginess continues as the `Benchmark` constructor has an argument - // named `options` and Firefox 1 will not assign a value to `Benchmark.options`, - // making it non-writable in the process, unless it is the first property - // assigned by for-in loop of `extend()`. - extend(Benchmark, { - - /** - * The default options copied by benchmark instances. - * - * @static - * @memberOf Benchmark - * @type Object - */ - 'options': { - - /** - * A flag to indicate that benchmark cycles will execute asynchronously - * by default. - * - * @memberOf Benchmark.options - * @type Boolean - */ - 'async': false, - - /** - * A flag to indicate that the benchmark clock is deferred. - * - * @memberOf Benchmark.options - * @type Boolean - */ - 'defer': false, - - /** - * The delay between test cycles (secs). - * @memberOf Benchmark.options - * @type Number - */ - 'delay': 0.005, - - /** - * Displayed by Benchmark#toString when a `name` is not available - * (auto-generated if absent). - * - * @memberOf Benchmark.options - * @type String - */ - 'id': undefined, - - /** - * The default number of times to execute a test on a benchmark's first cycle. - * - * @memberOf Benchmark.options - * @type Number - */ - 'initCount': 1, - - /** - * The maximum time a benchmark is allowed to run before finishing (secs). - * Note: Cycle delays aren't counted toward the maximum time. - * - * @memberOf Benchmark.options - * @type Number - */ - 'maxTime': 5, - - /** - * The minimum sample size required to perform statistical analysis. - * - * @memberOf Benchmark.options - * @type Number - */ - 'minSamples': 5, - - /** - * The time needed to reduce the percent uncertainty of measurement to 1% (secs). - * - * @memberOf Benchmark.options - * @type Number - */ - 'minTime': 0, - - /** - * The name of the benchmark. - * - * @memberOf Benchmark.options - * @type String - */ - 'name': undefined, - - /** - * An event listener called when the benchmark is aborted. - * - * @memberOf Benchmark.options - * @type Function - */ - 'onAbort': undefined, - - /** - * An event listener called when the benchmark completes running. - * - * @memberOf Benchmark.options - * @type Function - */ - 'onComplete': undefined, - - /** - * An event listener called after each run cycle. - * - * @memberOf Benchmark.options - * @type Function - */ - 'onCycle': undefined, - - /** - * An event listener called when a test errors. - * - * @memberOf Benchmark.options - * @type Function - */ - 'onError': undefined, - - /** - * An event listener called when the benchmark is reset. - * - * @memberOf Benchmark.options - * @type Function - */ - 'onReset': undefined, - - /** - * An event listener called when the benchmark starts running. - * - * @memberOf Benchmark.options - * @type Function - */ - 'onStart': undefined - }, - - /** - * Platform object with properties describing things like browser name, - * version, and operating system. - * - * @static - * @memberOf Benchmark - * @type Object - */ - 'platform': req('platform') || window.platform || { - - /** - * The platform description. - * - * @memberOf Benchmark.platform - * @type String - */ - 'description': window.navigator && navigator.userAgent || null, - - /** - * The name of the browser layout engine. - * - * @memberOf Benchmark.platform - * @type String|Null - */ - 'layout': null, - - /** - * The name of the product hosting the browser. - * - * @memberOf Benchmark.platform - * @type String|Null - */ - 'product': null, - - /** - * The name of the browser/environment. - * - * @memberOf Benchmark.platform - * @type String|Null - */ - 'name': null, - - /** - * The name of the product's manufacturer. - * - * @memberOf Benchmark.platform - * @type String|Null - */ - 'manufacturer': null, - - /** - * The name of the operating system. - * - * @memberOf Benchmark.platform - * @type String|Null - */ - 'os': null, - - /** - * The alpha/beta release indicator. - * - * @memberOf Benchmark.platform - * @type String|Null - */ - 'prerelease': null, - - /** - * The browser/environment version. - * - * @memberOf Benchmark.platform - * @type String|Null - */ - 'version': null, - - /** - * Return platform description when the platform object is coerced to a string. - * - * @memberOf Benchmark.platform - * @type Function - * @returns {String} The platform description. - */ - 'toString': function() { - return this.description || ''; - } - }, - - /** - * The semantic version number. - * - * @static - * @memberOf Benchmark - * @type String - */ - 'version': '1.0.0', - - // an object of environment/feature detection flags - 'support': support, - - // clone objects - 'deepClone': deepClone, - - // iteration utility - 'each': each, - - // augment objects - 'extend': extend, - - // generic Array#filter - 'filter': filter, - - // generic Array#forEach - 'forEach': forEach, - - // generic own property iteration utility - 'forOwn': forOwn, - - // converts a number to a comma-separated string - 'formatNumber': formatNumber, - - // generic Object#hasOwnProperty - // (trigger hasKey's lazy define before assigning it to Benchmark) - 'hasKey': (hasKey(Benchmark, ''), hasKey), - - // generic Array#indexOf - 'indexOf': indexOf, - - // template utility - 'interpolate': interpolate, - - // invokes a method on each item in an array - 'invoke': invoke, - - // generic Array#join for arrays and objects - 'join': join, - - // generic Array#map - 'map': map, - - // retrieves a property value from each item in an array - 'pluck': pluck, - - // generic Array#reduce - 'reduce': reduce - }); - - /*--------------------------------------------------------------------------*/ - - extend(Benchmark.prototype, { - - /** - * The number of times a test was executed. - * - * @memberOf Benchmark - * @type Number - */ - 'count': 0, - - /** - * The number of cycles performed while benchmarking. - * - * @memberOf Benchmark - * @type Number - */ - 'cycles': 0, - - /** - * The number of executions per second. - * - * @memberOf Benchmark - * @type Number - */ - 'hz': 0, - - /** - * The compiled test function. - * - * @memberOf Benchmark - * @type Function|String - */ - 'compiled': undefined, - - /** - * The error object if the test failed. - * - * @memberOf Benchmark - * @type Object - */ - 'error': undefined, - - /** - * The test to benchmark. - * - * @memberOf Benchmark - * @type Function|String - */ - 'fn': undefined, - - /** - * A flag to indicate if the benchmark is aborted. - * - * @memberOf Benchmark - * @type Boolean - */ - 'aborted': false, - - /** - * A flag to indicate if the benchmark is running. - * - * @memberOf Benchmark - * @type Boolean - */ - 'running': false, - - /** - * Compiled into the test and executed immediately **before** the test loop. - * - * @memberOf Benchmark - * @type Function|String - * @example - * - * // basic usage - * var bench = Benchmark({ - * 'setup': function() { - * var c = this.count, - * element = document.getElementById('container'); - * while (c--) { - * element.appendChild(document.createElement('div')); - * } - * }, - * 'fn': function() { - * element.removeChild(element.lastChild); - * } - * }); - * - * // compiles to something like: - * var c = this.count, - * element = document.getElementById('container'); - * while (c--) { - * element.appendChild(document.createElement('div')); - * } - * var start = new Date; - * while (count--) { - * element.removeChild(element.lastChild); - * } - * var end = new Date - start; - * - * // or using strings - * var bench = Benchmark({ - * 'setup': '\ - * var a = 0;\n\ - * (function() {\n\ - * (function() {\n\ - * (function() {', - * 'fn': 'a += 1;', - * 'teardown': '\ - * }())\n\ - * }())\n\ - * }())' - * }); - * - * // compiles to something like: - * var a = 0; - * (function() { - * (function() { - * (function() { - * var start = new Date; - * while (count--) { - * a += 1; - * } - * var end = new Date - start; - * }()) - * }()) - * }()) - */ - 'setup': noop, - - /** - * Compiled into the test and executed immediately **after** the test loop. - * - * @memberOf Benchmark - * @type Function|String - */ - 'teardown': noop, - - /** - * An object of stats including mean, margin or error, and standard deviation. - * - * @memberOf Benchmark - * @type Object - */ - 'stats': { - - /** - * The margin of error. - * - * @memberOf Benchmark#stats - * @type Number - */ - 'moe': 0, - - /** - * The relative margin of error (expressed as a percentage of the mean). - * - * @memberOf Benchmark#stats - * @type Number - */ - 'rme': 0, - - /** - * The standard error of the mean. - * - * @memberOf Benchmark#stats - * @type Number - */ - 'sem': 0, - - /** - * The sample standard deviation. - * - * @memberOf Benchmark#stats - * @type Number - */ - 'deviation': 0, - - /** - * The sample arithmetic mean. - * - * @memberOf Benchmark#stats - * @type Number - */ - 'mean': 0, - - /** - * The array of sampled periods. - * - * @memberOf Benchmark#stats - * @type Array - */ - 'sample': [], - - /** - * The sample variance. - * - * @memberOf Benchmark#stats - * @type Number - */ - 'variance': 0 - }, - - /** - * An object of timing data including cycle, elapsed, period, start, and stop. - * - * @memberOf Benchmark - * @type Object - */ - 'times': { - - /** - * The time taken to complete the last cycle (secs). - * - * @memberOf Benchmark#times - * @type Number - */ - 'cycle': 0, - - /** - * The time taken to complete the benchmark (secs). - * - * @memberOf Benchmark#times - * @type Number - */ - 'elapsed': 0, - - /** - * The time taken to execute the test once (secs). - * - * @memberOf Benchmark#times - * @type Number - */ - 'period': 0, - - /** - * A timestamp of when the benchmark started (ms). - * - * @memberOf Benchmark#times - * @type Number - */ - 'timeStamp': 0 - }, - - // aborts benchmark (does not record times) - 'abort': abort, - - // creates a new benchmark using the same test and options - 'clone': clone, - - // compares benchmark's hertz with another - 'compare': compare, - - // executes listeners - 'emit': emit, - - // get listeners - 'listeners': listeners, - - // unregister listeners - 'off': off, - - // register listeners - 'on': on, - - // reset benchmark properties - 'reset': reset, - - // runs the benchmark - 'run': run, - - // pretty print benchmark info - 'toString': toStringBench - }); - - /*--------------------------------------------------------------------------*/ - - extend(Deferred.prototype, { - - /** - * The deferred benchmark instance. - * - * @memberOf Benchmark.Deferred - * @type Object - */ - 'benchmark': null, - - /** - * The number of deferred cycles performed while benchmarking. - * - * @memberOf Benchmark.Deferred - * @type Number - */ - 'cycles': 0, - - /** - * The time taken to complete the deferred benchmark (secs). - * - * @memberOf Benchmark.Deferred - * @type Number - */ - 'elapsed': 0, - - /** - * A timestamp of when the deferred benchmark started (ms). - * - * @memberOf Benchmark.Deferred - * @type Number - */ - 'timeStamp': 0, - - // cycles/completes the deferred benchmark - 'resolve': resolve - }); - - /*--------------------------------------------------------------------------*/ - - extend(Event.prototype, { - - /** - * A flag to indicate if the emitters listener iteration is aborted. - * - * @memberOf Benchmark.Event - * @type Boolean - */ - 'aborted': false, - - /** - * A flag to indicate if the default action is cancelled. - * - * @memberOf Benchmark.Event - * @type Boolean - */ - 'cancelled': false, - - /** - * The object whose listeners are currently being processed. - * - * @memberOf Benchmark.Event - * @type Object - */ - 'currentTarget': undefined, - - /** - * The return value of the last executed listener. - * - * @memberOf Benchmark.Event - * @type Mixed - */ - 'result': undefined, - - /** - * The object to which the event was originally emitted. - * - * @memberOf Benchmark.Event - * @type Object - */ - 'target': undefined, - - /** - * A timestamp of when the event was created (ms). - * - * @memberOf Benchmark.Event - * @type Number - */ - 'timeStamp': 0, - - /** - * The event type. - * - * @memberOf Benchmark.Event - * @type String - */ - 'type': '' - }); - - /*--------------------------------------------------------------------------*/ - - /** - * The default options copied by suite instances. - * - * @static - * @memberOf Benchmark.Suite - * @type Object - */ - Suite.options = { - - /** - * The name of the suite. - * - * @memberOf Benchmark.Suite.options - * @type String - */ - 'name': undefined - }; - - /*--------------------------------------------------------------------------*/ - - extend(Suite.prototype, { - - /** - * The number of benchmarks in the suite. - * - * @memberOf Benchmark.Suite - * @type Number - */ - 'length': 0, - - /** - * A flag to indicate if the suite is aborted. - * - * @memberOf Benchmark.Suite - * @type Boolean - */ - 'aborted': false, - - /** - * A flag to indicate if the suite is running. - * - * @memberOf Benchmark.Suite - * @type Boolean - */ - 'running': false, - - /** - * An `Array#forEach` like method. - * Callbacks may terminate the loop by explicitly returning `false`. - * - * @memberOf Benchmark.Suite - * @param {Function} callback The function called per iteration. - * @returns {Object} The suite iterated over. - */ - 'forEach': methodize(forEach), - - /** - * An `Array#indexOf` like method. - * - * @memberOf Benchmark.Suite - * @param {Mixed} value The value to search for. - * @returns {Number} The index of the matched value or `-1`. - */ - 'indexOf': methodize(indexOf), - - /** - * Invokes a method on all benchmarks in the suite. - * - * @memberOf Benchmark.Suite - * @param {String|Object} name The name of the method to invoke OR options object. - * @param {Mixed} [arg1, arg2, ...] Arguments to invoke the method with. - * @returns {Array} A new array of values returned from each method invoked. - */ - 'invoke': methodize(invoke), - - /** - * Converts the suite of benchmarks to a string. - * - * @memberOf Benchmark.Suite - * @param {String} [separator=','] A string to separate each element of the array. - * @returns {String} The string. - */ - 'join': [].join, - - /** - * An `Array#map` like method. - * - * @memberOf Benchmark.Suite - * @param {Function} callback The function called per iteration. - * @returns {Array} A new array of values returned by the callback. - */ - 'map': methodize(map), - - /** - * Retrieves the value of a specified property from all benchmarks in the suite. - * - * @memberOf Benchmark.Suite - * @param {String} property The property to pluck. - * @returns {Array} A new array of property values. - */ - 'pluck': methodize(pluck), - - /** - * Removes the last benchmark from the suite and returns it. - * - * @memberOf Benchmark.Suite - * @returns {Mixed} The removed benchmark. - */ - 'pop': [].pop, - - /** - * Appends benchmarks to the suite. - * - * @memberOf Benchmark.Suite - * @returns {Number} The suite's new length. - */ - 'push': [].push, - - /** - * Sorts the benchmarks of the suite. - * - * @memberOf Benchmark.Suite - * @param {Function} [compareFn=null] A function that defines the sort order. - * @returns {Object} The sorted suite. - */ - 'sort': [].sort, - - /** - * An `Array#reduce` like method. - * - * @memberOf Benchmark.Suite - * @param {Function} callback The function called per iteration. - * @param {Mixed} accumulator Initial value of the accumulator. - * @returns {Mixed} The accumulator. - */ - 'reduce': methodize(reduce), - - // aborts all benchmarks in the suite - 'abort': abortSuite, - - // adds a benchmark to the suite - 'add': add, - - // creates a new suite with cloned benchmarks - 'clone': cloneSuite, - - // executes listeners of a specified type - 'emit': emit, - - // creates a new suite of filtered benchmarks - 'filter': filterSuite, - - // get listeners - 'listeners': listeners, - - // unregister listeners - 'off': off, - - // register listeners - 'on': on, - - // resets all benchmarks in the suite - 'reset': resetSuite, - - // runs all benchmarks in the suite - 'run': runSuite, - - // array methods - 'concat': concat, - - 'reverse': reverse, - - 'shift': shift, - - 'slice': slice, - - 'splice': splice, - - 'unshift': unshift - }); - - /*--------------------------------------------------------------------------*/ - - // expose Deferred, Event and Suite - extend(Benchmark, { - 'Deferred': Deferred, - 'Event': Event, - 'Suite': Suite - }); - - // expose Benchmark - // some AMD build optimizers, like r.js, check for specific condition patterns like the following: - if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) { - // define as an anonymous module so, through path mapping, it can be aliased - define(function() { - return Benchmark; - }); - } - // check for `exports` after `define` in case a build optimizer adds an `exports` object - else if (freeExports) { - // in Node.js or RingoJS v0.8.0+ - if (typeof module == 'object' && module && module.exports == freeExports) { - (module.exports = Benchmark).Benchmark = Benchmark; - } - // in Narwhal or RingoJS v0.7.0- - else { - freeExports.Benchmark = Benchmark; - } - } - // in a browser or Rhino - else { - // use square bracket notation so Closure Compiler won't munge `Benchmark` - // http://code.google.com/closure/compiler/docs/api-tutorial3.html#export - window['Benchmark'] = Benchmark; - } - - // trigger clock's lazy define early to avoid a security error - if (support.air) { - clock({ '_original': { 'fn': noop, 'count': 1, 'options': {} } }); - } -}(this)); +/*! + * Benchmark.js v1.0.0 + * Copyright 2010-2012 Mathias Bynens + * Based on JSLitmus.js, copyright Robert Kieffer + * Modified by John-David Dalton + * Available under MIT license + */ +;(function(window, undefined) { + 'use strict'; + + /** Used to assign each benchmark an incrimented id */ + var counter = 0; + + /** Detect DOM document object */ + var doc = isHostType(window, 'document') && document; + + /** Detect free variable `define` */ + var freeDefine = typeof define == 'function' && + typeof define.amd == 'object' && define.amd && define; + + /** Detect free variable `exports` */ + var freeExports = typeof exports == 'object' && exports && + (typeof global == 'object' && global && global == global.global && (window = global), exports); + + /** Detect free variable `require` */ + var freeRequire = typeof require == 'function' && require; + + /** Used to crawl all properties regardless of enumerability */ + var getAllKeys = Object.getOwnPropertyNames; + + /** Used to get property descriptors */ + var getDescriptor = Object.getOwnPropertyDescriptor; + + /** Used in case an object doesn't have its own method */ + var hasOwnProperty = {}.hasOwnProperty; + + /** Used to check if an object is extensible */ + var isExtensible = Object.isExtensible || function() { return true; }; + + /** Used to access Wade Simmons' Node microtime module */ + var microtimeObject = req('microtime'); + + /** Used to access the browser's high resolution timer */ + var perfObject = isHostType(window, 'performance') && performance; + + /** Used to call the browser's high resolution timer */ + var perfName = perfObject && ( + perfObject.now && 'now' || + perfObject.webkitNow && 'webkitNow' + ); + + /** Used to access Node's high resolution timer */ + var processObject = isHostType(window, 'process') && process; + + /** Used to check if an own property is enumerable */ + var propertyIsEnumerable = {}.propertyIsEnumerable; + + /** Used to set property descriptors */ + var setDescriptor = Object.defineProperty; + + /** Used to resolve a value's internal [[Class]] */ + var toString = {}.toString; + + /** Used to prevent a `removeChild` memory leak in IE < 9 */ + var trash = doc && doc.createElement('div'); + + /** Used to integrity check compiled tests */ + var uid = 'uid' + (+new Date); + + /** Used to avoid infinite recursion when methods call each other */ + var calledBy = {}; + + /** Used to avoid hz of Infinity */ + var divisors = { + '1': 4096, + '2': 512, + '3': 64, + '4': 8, + '5': 0 + }; + + /** + * T-Distribution two-tailed critical values for 95% confidence + * http://www.itl.nist.gov/div898/handbook/eda/section3/eda3672.htm + */ + var tTable = { + '1': 12.706,'2': 4.303, '3': 3.182, '4': 2.776, '5': 2.571, '6': 2.447, + '7': 2.365, '8': 2.306, '9': 2.262, '10': 2.228, '11': 2.201, '12': 2.179, + '13': 2.16, '14': 2.145, '15': 2.131, '16': 2.12, '17': 2.11, '18': 2.101, + '19': 2.093, '20': 2.086, '21': 2.08, '22': 2.074, '23': 2.069, '24': 2.064, + '25': 2.06, '26': 2.056, '27': 2.052, '28': 2.048, '29': 2.045, '30': 2.042, + 'infinity': 1.96 + }; + + /** + * Critical Mann-Whitney U-values for 95% confidence + * http://www.saburchill.com/IBbiology/stats/003.html + */ + var uTable = { + '5': [0, 1, 2], + '6': [1, 2, 3, 5], + '7': [1, 3, 5, 6, 8], + '8': [2, 4, 6, 8, 10, 13], + '9': [2, 4, 7, 10, 12, 15, 17], + '10': [3, 5, 8, 11, 14, 17, 20, 23], + '11': [3, 6, 9, 13, 16, 19, 23, 26, 30], + '12': [4, 7, 11, 14, 18, 22, 26, 29, 33, 37], + '13': [4, 8, 12, 16, 20, 24, 28, 33, 37, 41, 45], + '14': [5, 9, 13, 17, 22, 26, 31, 36, 40, 45, 50, 55], + '15': [5, 10, 14, 19, 24, 29, 34, 39, 44, 49, 54, 59, 64], + '16': [6, 11, 15, 21, 26, 31, 37, 42, 47, 53, 59, 64, 70, 75], + '17': [6, 11, 17, 22, 28, 34, 39, 45, 51, 57, 63, 67, 75, 81, 87], + '18': [7, 12, 18, 24, 30, 36, 42, 48, 55, 61, 67, 74, 80, 86, 93, 99], + '19': [7, 13, 19, 25, 32, 38, 45, 52, 58, 65, 72, 78, 85, 92, 99, 106, 113], + '20': [8, 14, 20, 27, 34, 41, 48, 55, 62, 69, 76, 83, 90, 98, 105, 112, 119, 127], + '21': [8, 15, 22, 29, 36, 43, 50, 58, 65, 73, 80, 88, 96, 103, 111, 119, 126, 134, 142], + '22': [9, 16, 23, 30, 38, 45, 53, 61, 69, 77, 85, 93, 101, 109, 117, 125, 133, 141, 150, 158], + '23': [9, 17, 24, 32, 40, 48, 56, 64, 73, 81, 89, 98, 106, 115, 123, 132, 140, 149, 157, 166, 175], + '24': [10, 17, 25, 33, 42, 50, 59, 67, 76, 85, 94, 102, 111, 120, 129, 138, 147, 156, 165, 174, 183, 192], + '25': [10, 18, 27, 35, 44, 53, 62, 71, 80, 89, 98, 107, 117, 126, 135, 145, 154, 163, 173, 182, 192, 201, 211], + '26': [11, 19, 28, 37, 46, 55, 64, 74, 83, 93, 102, 112, 122, 132, 141, 151, 161, 171, 181, 191, 200, 210, 220, 230], + '27': [11, 20, 29, 38, 48, 57, 67, 77, 87, 97, 107, 118, 125, 138, 147, 158, 168, 178, 188, 199, 209, 219, 230, 240, 250], + '28': [12, 21, 30, 40, 50, 60, 70, 80, 90, 101, 111, 122, 132, 143, 154, 164, 175, 186, 196, 207, 218, 228, 239, 250, 261, 272], + '29': [13, 22, 32, 42, 52, 62, 73, 83, 94, 105, 116, 127, 138, 149, 160, 171, 182, 193, 204, 215, 226, 238, 249, 260, 271, 282, 294], + '30': [13, 23, 33, 43, 54, 65, 76, 87, 98, 109, 120, 131, 143, 154, 166, 177, 189, 200, 212, 223, 235, 247, 258, 270, 282, 293, 305, 317] + }; + + /** + * An object used to flag environments/features. + * + * @static + * @memberOf Benchmark + * @type Object + */ + var support = {}; + + (function() { + + /** + * Detect Adobe AIR. + * + * @memberOf Benchmark.support + * @type Boolean + */ + support.air = isClassOf(window.runtime, 'ScriptBridgingProxyObject'); + + /** + * Detect if `arguments` objects have the correct internal [[Class]] value. + * + * @memberOf Benchmark.support + * @type Boolean + */ + support.argumentsClass = isClassOf(arguments, 'Arguments'); + + /** + * Detect if in a browser environment. + * + * @memberOf Benchmark.support + * @type Boolean + */ + support.browser = doc && isHostType(window, 'navigator'); + + /** + * Detect if strings support accessing characters by index. + * + * @memberOf Benchmark.support + * @type Boolean + */ + support.charByIndex = + // IE 8 supports indexes on string literals but not string objects + ('x'[0] + Object('x')[0]) == 'xx'; + + /** + * Detect if strings have indexes as own properties. + * + * @memberOf Benchmark.support + * @type Boolean + */ + support.charByOwnIndex = + // Narwhal, Rhino, RingoJS, IE 8, and Opera < 10.52 support indexes on + // strings but don't detect them as own properties + support.charByIndex && hasKey('x', '0'); + + /** + * Detect if Java is enabled/exposed. + * + * @memberOf Benchmark.support + * @type Boolean + */ + support.java = isClassOf(window.java, 'JavaPackage'); + + /** + * Detect if the Timers API exists. + * + * @memberOf Benchmark.support + * @type Boolean + */ + support.timeout = isHostType(window, 'setTimeout') && isHostType(window, 'clearTimeout'); + + /** + * Detect if functions support decompilation. + * + * @name decompilation + * @memberOf Benchmark.support + * @type Boolean + */ + try { + // Safari 2.x removes commas in object literals + // from Function#toString results + // http://webk.it/11609 + // Firefox 3.6 and Opera 9.25 strip grouping + // parentheses from Function#toString results + // http://bugzil.la/559438 + support.decompilation = Function( + 'return (' + (function(x) { return { 'x': '' + (1 + x) + '', 'y': 0 }; }) + ')' + )()(0).x === '1'; + } catch(e) { + support.decompilation = false; + } + + /** + * Detect ES5+ property descriptor API. + * + * @name descriptors + * @memberOf Benchmark.support + * @type Boolean + */ + try { + var o = {}; + support.descriptors = (setDescriptor(o, o, o), 'value' in getDescriptor(o, o)); + } catch(e) { + support.descriptors = false; + } + + /** + * Detect ES5+ Object.getOwnPropertyNames(). + * + * @name getAllKeys + * @memberOf Benchmark.support + * @type Boolean + */ + try { + support.getAllKeys = /\bvalueOf\b/.test(getAllKeys(Object.prototype)); + } catch(e) { + support.getAllKeys = false; + } + + /** + * Detect if own properties are iterated before inherited properties (all but IE < 9). + * + * @name iteratesOwnLast + * @memberOf Benchmark.support + * @type Boolean + */ + support.iteratesOwnFirst = (function() { + var props = []; + function ctor() { this.x = 1; } + ctor.prototype = { 'y': 1 }; + for (var prop in new ctor) { props.push(prop); } + return props[0] == 'x'; + }()); + + /** + * Detect if a node's [[Class]] is resolvable (all but IE < 9) + * and that the JS engine errors when attempting to coerce an object to a + * string without a `toString` property value of `typeof` "function". + * + * @name nodeClass + * @memberOf Benchmark.support + * @type Boolean + */ + try { + support.nodeClass = ({ 'toString': 0 } + '', toString.call(doc || 0) != '[object Object]'); + } catch(e) { + support.nodeClass = true; + } + }()); + + /** + * Timer object used by `clock()` and `Deferred#resolve`. + * + * @private + * @type Object + */ + var timer = { + + /** + * The timer namespace object or constructor. + * + * @private + * @memberOf timer + * @type Function|Object + */ + 'ns': Date, + + /** + * Starts the deferred timer. + * + * @private + * @memberOf timer + * @param {Object} deferred The deferred instance. + */ + 'start': null, // lazy defined in `clock()` + + /** + * Stops the deferred timer. + * + * @private + * @memberOf timer + * @param {Object} deferred The deferred instance. + */ + 'stop': null // lazy defined in `clock()` + }; + + /** Shortcut for inverse results */ + var noArgumentsClass = !support.argumentsClass, + noCharByIndex = !support.charByIndex, + noCharByOwnIndex = !support.charByOwnIndex; + + /** Math shortcuts */ + var abs = Math.abs, + floor = Math.floor, + max = Math.max, + min = Math.min, + pow = Math.pow, + sqrt = Math.sqrt; + + /*--------------------------------------------------------------------------*/ + + /** + * The Benchmark constructor. + * + * @constructor + * @param {String} name A name to identify the benchmark. + * @param {Function|String} fn The test to benchmark. + * @param {Object} [options={}] Options object. + * @example + * + * // basic usage (the `new` operator is optional) + * var bench = new Benchmark(fn); + * + * // or using a name first + * var bench = new Benchmark('foo', fn); + * + * // or with options + * var bench = new Benchmark('foo', fn, { + * + * // displayed by Benchmark#toString if `name` is not available + * 'id': 'xyz', + * + * // called when the benchmark starts running + * 'onStart': onStart, + * + * // called after each run cycle + * 'onCycle': onCycle, + * + * // called when aborted + * 'onAbort': onAbort, + * + * // called when a test errors + * 'onError': onError, + * + * // called when reset + * 'onReset': onReset, + * + * // called when the benchmark completes running + * 'onComplete': onComplete, + * + * // compiled/called before the test loop + * 'setup': setup, + * + * // compiled/called after the test loop + * 'teardown': teardown + * }); + * + * // or name and options + * var bench = new Benchmark('foo', { + * + * // a flag to indicate the benchmark is deferred + * 'defer': true, + * + * // benchmark test function + * 'fn': function(deferred) { + * // call resolve() when the deferred test is finished + * deferred.resolve(); + * } + * }); + * + * // or options only + * var bench = new Benchmark({ + * + * // benchmark name + * 'name': 'foo', + * + * // benchmark test as a string + * 'fn': '[1,2,3,4].sort()' + * }); + * + * // a test's `this` binding is set to the benchmark instance + * var bench = new Benchmark('foo', function() { + * 'My name is '.concat(this.name); // My name is foo + * }); + */ + function Benchmark(name, fn, options) { + var me = this; + + // allow instance creation without the `new` operator + if (me == null || me.constructor != Benchmark) { + return new Benchmark(name, fn, options); + } + // juggle arguments + if (isClassOf(name, 'Object')) { + // 1 argument (options) + options = name; + } + else if (isClassOf(name, 'Function')) { + // 2 arguments (fn, options) + options = fn; + fn = name; + } + else if (isClassOf(fn, 'Object')) { + // 2 arguments (name, options) + options = fn; + fn = null; + me.name = name; + } + else { + // 3 arguments (name, fn [, options]) + me.name = name; + } + setOptions(me, options); + me.id || (me.id = ++counter); + me.fn == null && (me.fn = fn); + me.stats = deepClone(me.stats); + me.times = deepClone(me.times); + } + + /** + * The Deferred constructor. + * + * @constructor + * @memberOf Benchmark + * @param {Object} clone The cloned benchmark instance. + */ + function Deferred(clone) { + var me = this; + if (me == null || me.constructor != Deferred) { + return new Deferred(clone); + } + me.benchmark = clone; + clock(me); + } + + /** + * The Event constructor. + * + * @constructor + * @memberOf Benchmark + * @param {String|Object} type The event type. + */ + function Event(type) { + var me = this; + return (me == null || me.constructor != Event) + ? new Event(type) + : (type instanceof Event) + ? type + : extend(me, { 'timeStamp': +new Date }, typeof type == 'string' ? { 'type': type } : type); + } + + /** + * The Suite constructor. + * + * @constructor + * @memberOf Benchmark + * @param {String} name A name to identify the suite. + * @param {Object} [options={}] Options object. + * @example + * + * // basic usage (the `new` operator is optional) + * var suite = new Benchmark.Suite; + * + * // or using a name first + * var suite = new Benchmark.Suite('foo'); + * + * // or with options + * var suite = new Benchmark.Suite('foo', { + * + * // called when the suite starts running + * 'onStart': onStart, + * + * // called between running benchmarks + * 'onCycle': onCycle, + * + * // called when aborted + * 'onAbort': onAbort, + * + * // called when a test errors + * 'onError': onError, + * + * // called when reset + * 'onReset': onReset, + * + * // called when the suite completes running + * 'onComplete': onComplete + * }); + */ + function Suite(name, options) { + var me = this; + + // allow instance creation without the `new` operator + if (me == null || me.constructor != Suite) { + return new Suite(name, options); + } + // juggle arguments + if (isClassOf(name, 'Object')) { + // 1 argument (options) + options = name; + } else { + // 2 arguments (name [, options]) + me.name = name; + } + setOptions(me, options); + } + + /*--------------------------------------------------------------------------*/ + + /** + * Note: Some array methods have been implemented in plain JavaScript to avoid + * bugs in IE, Opera, Rhino, and Mobile Safari. + * + * IE compatibility mode and IE < 9 have buggy Array `shift()` and `splice()` + * functions that fail to remove the last element, `object[0]`, of + * array-like-objects even though the `length` property is set to `0`. + * The `shift()` method is buggy in IE 8 compatibility mode, while `splice()` + * is buggy regardless of mode in IE < 9 and buggy in compatibility mode in IE 9. + * + * In Opera < 9.50 and some older/beta Mobile Safari versions using `unshift()` + * generically to augment the `arguments` object will pave the value at index 0 + * without incrimenting the other values's indexes. + * https://github.com/documentcloud/underscore/issues/9 + * + * Rhino and environments it powers, like Narwhal and RingoJS, may have + * buggy Array `concat()`, `reverse()`, `shift()`, `slice()`, `splice()` and + * `unshift()` functions that make sparse arrays non-sparse by assigning the + * undefined indexes a value of undefined. + * https://github.com/mozilla/rhino/commit/702abfed3f8ca043b2636efd31c14ba7552603dd + */ + + /** + * Creates an array containing the elements of the host array followed by the + * elements of each argument in order. + * + * @memberOf Benchmark.Suite + * @returns {Array} The new array. + */ + function concat() { + var value, + j = -1, + length = arguments.length, + result = slice.call(this), + index = result.length; + + while (++j < length) { + value = arguments[j]; + if (isClassOf(value, 'Array')) { + for (var k = 0, l = value.length; k < l; k++, index++) { + if (k in value) { + result[index] = value[k]; + } + } + } else { + result[index++] = value; + } + } + return result; + } + + /** + * Utility function used by `shift()`, `splice()`, and `unshift()`. + * + * @private + * @param {Number} start The index to start inserting elements. + * @param {Number} deleteCount The number of elements to delete from the insert point. + * @param {Array} elements The elements to insert. + * @returns {Array} An array of deleted elements. + */ + function insert(start, deleteCount, elements) { + // `result` should have its length set to the `deleteCount` + // see https://bugs.ecmascript.org/show_bug.cgi?id=332 + var deleteEnd = start + deleteCount, + elementCount = elements ? elements.length : 0, + index = start - 1, + length = start + elementCount, + object = this, + result = Array(deleteCount), + tail = slice.call(object, deleteEnd); + + // delete elements from the array + while (++index < deleteEnd) { + if (index in object) { + result[index - start] = object[index]; + delete object[index]; + } + } + // insert elements + index = start - 1; + while (++index < length) { + object[index] = elements[index - start]; + } + // append tail elements + start = index--; + length = max(0, (object.length >>> 0) - deleteCount + elementCount); + while (++index < length) { + if ((index - start) in tail) { + object[index] = tail[index - start]; + } else if (index in object) { + delete object[index]; + } + } + // delete excess elements + deleteCount = deleteCount > elementCount ? deleteCount - elementCount : 0; + while (deleteCount--) { + index = length + deleteCount; + if (index in object) { + delete object[index]; + } + } + object.length = length; + return result; + } + + /** + * Rearrange the host array's elements in reverse order. + * + * @memberOf Benchmark.Suite + * @returns {Array} The reversed array. + */ + function reverse() { + var upperIndex, + value, + index = -1, + object = Object(this), + length = object.length >>> 0, + middle = floor(length / 2); + + if (length > 1) { + while (++index < middle) { + upperIndex = length - index - 1; + value = upperIndex in object ? object[upperIndex] : uid; + if (index in object) { + object[upperIndex] = object[index]; + } else { + delete object[upperIndex]; + } + if (value != uid) { + object[index] = value; + } else { + delete object[index]; + } + } + } + return object; + } + + /** + * Removes the first element of the host array and returns it. + * + * @memberOf Benchmark.Suite + * @returns {Mixed} The first element of the array. + */ + function shift() { + return insert.call(this, 0, 1)[0]; + } + + /** + * Creates an array of the host array's elements from the start index up to, + * but not including, the end index. + * + * @memberOf Benchmark.Suite + * @param {Number} start The starting index. + * @param {Number} end The end index. + * @returns {Array} The new array. + */ + function slice(start, end) { + var index = -1, + object = Object(this), + length = object.length >>> 0, + result = []; + + start = toInteger(start); + start = start < 0 ? max(length + start, 0) : min(start, length); + start--; + end = end == null ? length : toInteger(end); + end = end < 0 ? max(length + end, 0) : min(end, length); + + while ((++index, ++start) < end) { + if (start in object) { + result[index] = object[start]; + } + } + return result; + } + + /** + * Allows removing a range of elements and/or inserting elements into the + * host array. + * + * @memberOf Benchmark.Suite + * @param {Number} start The start index. + * @param {Number} deleteCount The number of elements to delete. + * @param {Mixed} [val1, val2, ...] values to insert at the `start` index. + * @returns {Array} An array of removed elements. + */ + function splice(start, deleteCount) { + var object = Object(this), + length = object.length >>> 0; + + start = toInteger(start); + start = start < 0 ? max(length + start, 0) : min(start, length); + + // support the de-facto SpiderMonkey extension + // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/splice#Parameters + // https://bugs.ecmascript.org/show_bug.cgi?id=429 + deleteCount = arguments.length == 1 + ? length - start + : min(max(toInteger(deleteCount), 0), length - start); + + return insert.call(object, start, deleteCount, slice.call(arguments, 2)); + } + + /** + * Converts the specified `value` to an integer. + * + * @private + * @param {Mixed} value The value to convert. + * @returns {Number} The resulting integer. + */ + function toInteger(value) { + value = +value; + return value === 0 || !isFinite(value) ? value || 0 : value - (value % 1); + } + + /** + * Appends arguments to the host array. + * + * @memberOf Benchmark.Suite + * @returns {Number} The new length. + */ + function unshift() { + var object = Object(this); + insert.call(object, 0, 0, arguments); + return object.length; + } + + /*--------------------------------------------------------------------------*/ + + /** + * A generic `Function#bind` like method. + * + * @private + * @param {Function} fn The function to be bound to `thisArg`. + * @param {Mixed} thisArg The `this` binding for the given function. + * @returns {Function} The bound function. + */ + function bind(fn, thisArg) { + return function() { fn.apply(thisArg, arguments); }; + } + + /** + * Creates a function from the given arguments string and body. + * + * @private + * @param {String} args The comma separated function arguments. + * @param {String} body The function body. + * @returns {Function} The new function. + */ + function createFunction() { + // lazy define + createFunction = function(args, body) { + var result, + anchor = freeDefine ? define.amd : Benchmark, + prop = uid + 'createFunction'; + + runScript((freeDefine ? 'define.amd.' : 'Benchmark.') + prop + '=function(' + args + '){' + body + '}'); + result = anchor[prop]; + delete anchor[prop]; + return result; + }; + // fix JaegerMonkey bug + // http://bugzil.la/639720 + createFunction = support.browser && (createFunction('', 'return"' + uid + '"') || noop)() == uid ? createFunction : Function; + return createFunction.apply(null, arguments); + } + + /** + * Delay the execution of a function based on the benchmark's `delay` property. + * + * @private + * @param {Object} bench The benchmark instance. + * @param {Object} fn The function to execute. + */ + function delay(bench, fn) { + bench._timerId = setTimeout(fn, bench.delay * 1e3); + } + + /** + * Destroys the given element. + * + * @private + * @param {Element} element The element to destroy. + */ + function destroyElement(element) { + trash.appendChild(element); + trash.innerHTML = ''; + } + + /** + * Iterates over an object's properties, executing the `callback` for each. + * Callbacks may terminate the loop by explicitly returning `false`. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} callback The function executed per own property. + * @param {Object} options The options object. + * @returns {Object} Returns the object iterated over. + */ + function forProps() { + var forShadowed, + skipSeen, + forArgs = true, + shadowed = ['constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf']; + + (function(enumFlag, key) { + // must use a non-native constructor to catch the Safari 2 issue + function Klass() { this.valueOf = 0; }; + Klass.prototype.valueOf = 0; + // check various for-in bugs + for (key in new Klass) { + enumFlag += key == 'valueOf' ? 1 : 0; + } + // check if `arguments` objects have non-enumerable indexes + for (key in arguments) { + key == '0' && (forArgs = false); + } + // Safari 2 iterates over shadowed properties twice + // http://replay.waybackmachine.org/20090428222941/http://tobielangel.com/2007/1/29/for-in-loop-broken-in-safari/ + skipSeen = enumFlag == 2; + // IE < 9 incorrectly makes an object's properties non-enumerable if they have + // the same name as other non-enumerable properties in its prototype chain. + forShadowed = !enumFlag; + }(0)); + + // lazy define + forProps = function(object, callback, options) { + options || (options = {}); + + var result = object; + object = Object(object); + + var ctor, + key, + keys, + skipCtor, + done = !result, + which = options.which, + allFlag = which == 'all', + index = -1, + iteratee = object, + length = object.length, + ownFlag = allFlag || which == 'own', + seen = {}, + skipProto = isClassOf(object, 'Function'), + thisArg = options.bind; + + if (thisArg !== undefined) { + callback = bind(callback, thisArg); + } + // iterate all properties + if (allFlag && support.getAllKeys) { + for (index = 0, keys = getAllKeys(object), length = keys.length; index < length; index++) { + key = keys[index]; + if (callback(object[key], key, object) === false) { + break; + } + } + } + // else iterate only enumerable properties + else { + for (key in object) { + // Firefox < 3.6, Opera > 9.50 - Opera < 11.60, and Safari < 5.1 + // (if the prototype or a property on the prototype has been set) + // incorrectly set a function's `prototype` property [[Enumerable]] value + // to `true`. Because of this we standardize on skipping the `prototype` + // property of functions regardless of their [[Enumerable]] value. + if ((done = + !(skipProto && key == 'prototype') && + !(skipSeen && (hasKey(seen, key) || !(seen[key] = true))) && + (!ownFlag || ownFlag && hasKey(object, key)) && + callback(object[key], key, object) === false)) { + break; + } + } + // in IE < 9 strings don't support accessing characters by index + if (!done && (forArgs && isArguments(object) || + ((noCharByIndex || noCharByOwnIndex) && isClassOf(object, 'String') && + (iteratee = noCharByIndex ? object.split('') : object)))) { + while (++index < length) { + if ((done = + callback(iteratee[index], String(index), object) === false)) { + break; + } + } + } + if (!done && forShadowed) { + // Because IE < 9 can't set the `[[Enumerable]]` attribute of an existing + // property and the `constructor` property of a prototype defaults to + // non-enumerable, we manually skip the `constructor` property when we + // think we are iterating over a `prototype` object. + ctor = object.constructor; + skipCtor = ctor && ctor.prototype && ctor.prototype.constructor === ctor; + for (index = 0; index < 7; index++) { + key = shadowed[index]; + if (!(skipCtor && key == 'constructor') && + hasKey(object, key) && + callback(object[key], key, object) === false) { + break; + } + } + } + } + return result; + }; + return forProps.apply(null, arguments); + } + + /** + * Gets the name of the first argument from a function's source. + * + * @private + * @param {Function} fn The function. + * @returns {String} The argument name. + */ + function getFirstArgument(fn) { + return (!hasKey(fn, 'toString') && + (/^[\s(]*function[^(]*\(([^\s,)]+)/.exec(fn) || 0)[1]) || ''; + } + + /** + * Computes the arithmetic mean of a sample. + * + * @private + * @param {Array} sample The sample. + * @returns {Number} The mean. + */ + function getMean(sample) { + return reduce(sample, function(sum, x) { + return sum + x; + }) / sample.length || 0; + } + + /** + * Gets the source code of a function. + * + * @private + * @param {Function} fn The function. + * @param {String} altSource A string used when a function's source code is unretrievable. + * @returns {String} The function's source code. + */ + function getSource(fn, altSource) { + var result = altSource; + if (isStringable(fn)) { + result = String(fn); + } else if (support.decompilation) { + // escape the `{` for Firefox 1 + result = (/^[^{]+\{([\s\S]*)}\s*$/.exec(fn) || 0)[1]; + } + // trim string + result = (result || '').replace(/^\s+|\s+$/g, ''); + + // detect strings containing only the "use strict" directive + return /^(?:\/\*+[\w|\W]*?\*\/|\/\/.*?[\n\r\u2028\u2029]|\s)*(["'])use strict\1;?$/.test(result) + ? '' + : result; + } + + /** + * Checks if a value is an `arguments` object. + * + * @private + * @param {Mixed} value The value to check. + * @returns {Boolean} Returns `true` if the value is an `arguments` object, else `false`. + */ + function isArguments() { + // lazy define + isArguments = function(value) { + return toString.call(value) == '[object Arguments]'; + }; + if (noArgumentsClass) { + isArguments = function(value) { + return hasKey(value, 'callee') && + !(propertyIsEnumerable && propertyIsEnumerable.call(value, 'callee')); + }; + } + return isArguments(arguments[0]); + } + + /** + * Checks if an object is of the specified class. + * + * @private + * @param {Mixed} value The value to check. + * @param {String} name The name of the class. + * @returns {Boolean} Returns `true` if the value is of the specified class, else `false`. + */ + function isClassOf(value, name) { + return value != null && toString.call(value) == '[object ' + name + ']'; + } + + /** + * Host objects can return type values that are different from their actual + * data type. The objects we are concerned with usually return non-primitive + * types of object, function, or unknown. + * + * @private + * @param {Mixed} object The owner of the property. + * @param {String} property The property to check. + * @returns {Boolean} Returns `true` if the property value is a non-primitive, else `false`. + */ + function isHostType(object, property) { + var type = object != null ? typeof object[property] : 'number'; + return !/^(?:boolean|number|string|undefined)$/.test(type) && + (type == 'object' ? !!object[property] : true); + } + + /** + * Checks if a given `value` is an object created by the `Object` constructor + * assuming objects created by the `Object` constructor have no inherited + * enumerable properties and that there are no `Object.prototype` extensions. + * + * @private + * @param {Mixed} value The value to check. + * @returns {Boolean} Returns `true` if the `value` is a plain `Object` object, else `false`. + */ + function isPlainObject(value) { + // avoid non-objects and false positives for `arguments` objects in IE < 9 + var result = false; + if (!(value && typeof value == 'object') || (noArgumentsClass && isArguments(value))) { + return result; + } + // IE < 9 presents DOM nodes as `Object` objects except they have `toString` + // methods that are `typeof` "string" and still can coerce nodes to strings. + // Also check that the constructor is `Object` (i.e. `Object instanceof Object`) + var ctor = value.constructor; + if ((support.nodeClass || !(typeof value.toString != 'function' && typeof (value + '') == 'string')) && + (!isClassOf(ctor, 'Function') || ctor instanceof ctor)) { + // In most environments an object's own properties are iterated before + // its inherited properties. If the last iterated property is an object's + // own property then there are no inherited enumerable properties. + if (support.iteratesOwnFirst) { + forProps(value, function(subValue, subKey) { + result = subKey; + }); + return result === false || hasKey(value, result); + } + // IE < 9 iterates inherited properties before own properties. If the first + // iterated property is an object's own property then there are no inherited + // enumerable properties. + forProps(value, function(subValue, subKey) { + result = !hasKey(value, subKey); + return false; + }); + return result === false; + } + return result; + } + + /** + * Checks if a value can be safely coerced to a string. + * + * @private + * @param {Mixed} value The value to check. + * @returns {Boolean} Returns `true` if the value can be coerced, else `false`. + */ + function isStringable(value) { + return hasKey(value, 'toString') || isClassOf(value, 'String'); + } + + /** + * Wraps a function and passes `this` to the original function as the + * first argument. + * + * @private + * @param {Function} fn The function to be wrapped. + * @returns {Function} The new function. + */ + function methodize(fn) { + return function() { + var args = [this]; + args.push.apply(args, arguments); + return fn.apply(null, args); + }; + } + + /** + * A no-operation function. + * + * @private + */ + function noop() { + // no operation performed + } + + /** + * A wrapper around require() to suppress `module missing` errors. + * + * @private + * @param {String} id The module id. + * @returns {Mixed} The exported module or `null`. + */ + function req(id) { + try { + var result = freeExports && freeRequire(id); + } catch(e) { } + return result || null; + } + + /** + * Runs a snippet of JavaScript via script injection. + * + * @private + * @param {String} code The code to run. + */ + function runScript(code) { + var anchor = freeDefine ? define.amd : Benchmark, + script = doc.createElement('script'), + sibling = doc.getElementsByTagName('script')[0], + parent = sibling.parentNode, + prop = uid + 'runScript', + prefix = '(' + (freeDefine ? 'define.amd.' : 'Benchmark.') + prop + '||function(){})();'; + + // Firefox 2.0.0.2 cannot use script injection as intended because it executes + // asynchronously, but that's OK because script injection is only used to avoid + // the previously commented JaegerMonkey bug. + try { + // remove the inserted script *before* running the code to avoid differences + // in the expected script element count/order of the document. + script.appendChild(doc.createTextNode(prefix + code)); + anchor[prop] = function() { destroyElement(script); }; + } catch(e) { + parent = parent.cloneNode(false); + sibling = null; + script.text = code; + } + parent.insertBefore(script, sibling); + delete anchor[prop]; + } + + /** + * A helper function for setting options/event handlers. + * + * @private + * @param {Object} bench The benchmark instance. + * @param {Object} [options={}] Options object. + */ + function setOptions(bench, options) { + options = extend({}, bench.constructor.options, options); + bench.options = forOwn(options, function(value, key) { + if (value != null) { + // add event listeners + if (/^on[A-Z]/.test(key)) { + forEach(key.split(' '), function(key) { + bench.on(key.slice(2).toLowerCase(), value); + }); + } else if (!hasKey(bench, key)) { + bench[key] = deepClone(value); + } + } + }); + } + + /*--------------------------------------------------------------------------*/ + + /** + * Handles cycling/completing the deferred benchmark. + * + * @memberOf Benchmark.Deferred + */ + function resolve() { + var me = this, + clone = me.benchmark, + bench = clone._original; + + if (bench.aborted) { + // cycle() -> clone cycle/complete event -> compute()'s invoked bench.run() cycle/complete + me.teardown(); + clone.running = false; + cycle(me); + } + else if (++me.cycles < clone.count) { + // continue the test loop + if (support.timeout) { + // use setTimeout to avoid a call stack overflow if called recursively + setTimeout(function() { clone.compiled.call(me, timer); }, 0); + } else { + clone.compiled.call(me, timer); + } + } + else { + timer.stop(me); + me.teardown(); + delay(clone, function() { cycle(me); }); + } + } + + /*--------------------------------------------------------------------------*/ + + /** + * A deep clone utility. + * + * @static + * @memberOf Benchmark + * @param {Mixed} value The value to clone. + * @returns {Mixed} The cloned value. + */ + function deepClone(value) { + var accessor, + circular, + clone, + ctor, + descriptor, + extensible, + key, + length, + markerKey, + parent, + result, + source, + subIndex, + data = { 'value': value }, + index = 0, + marked = [], + queue = { 'length': 0 }, + unmarked = []; + + /** + * An easily detectable decorator for cloned values. + */ + function Marker(object) { + this.raw = object; + } + + /** + * The callback used by `forProps()`. + */ + function forPropsCallback(subValue, subKey) { + // exit early to avoid cloning the marker + if (subValue && subValue.constructor == Marker) { + return; + } + // add objects to the queue + if (subValue === Object(subValue)) { + queue[queue.length++] = { 'key': subKey, 'parent': clone, 'source': value }; + } + // assign non-objects + else { + try { + // will throw an error in strict mode if the property is read-only + clone[subKey] = subValue; + } catch(e) { } + } + } + + /** + * Gets an available marker key for the given object. + */ + function getMarkerKey(object) { + // avoid collisions with existing keys + var result = uid; + while (object[result] && object[result].constructor != Marker) { + result += 1; + } + return result; + } + + do { + key = data.key; + parent = data.parent; + source = data.source; + clone = value = source ? source[key] : data.value; + accessor = circular = descriptor = false; + + // create a basic clone to filter out functions, DOM elements, and + // other non `Object` objects + if (value === Object(value)) { + // use custom deep clone function if available + if (isClassOf(value.deepClone, 'Function')) { + clone = value.deepClone(); + } else { + ctor = value.constructor; + switch (toString.call(value)) { + case '[object Array]': + clone = new ctor(value.length); + break; + + case '[object Boolean]': + clone = new ctor(value == true); + break; + + case '[object Date]': + clone = new ctor(+value); + break; + + case '[object Object]': + isPlainObject(value) && (clone = {}); + break; + + case '[object Number]': + case '[object String]': + clone = new ctor(value); + break; + + case '[object RegExp]': + clone = ctor(value.source, + (value.global ? 'g' : '') + + (value.ignoreCase ? 'i' : '') + + (value.multiline ? 'm' : '')); + } + } + // continue clone if `value` doesn't have an accessor descriptor + // http://es5.github.com/#x8.10.1 + if (clone && clone != value && + !(descriptor = source && support.descriptors && getDescriptor(source, key), + accessor = descriptor && (descriptor.get || descriptor.set))) { + // use an existing clone (circular reference) + if ((extensible = isExtensible(value))) { + markerKey = getMarkerKey(value); + if (value[markerKey]) { + circular = clone = value[markerKey].raw; + } + } else { + // for frozen/sealed objects + for (subIndex = 0, length = unmarked.length; subIndex < length; subIndex++) { + data = unmarked[subIndex]; + if (data.object === value) { + circular = clone = data.clone; + break; + } + } + } + if (!circular) { + // mark object to allow quickly detecting circular references and tie it to its clone + if (extensible) { + value[markerKey] = new Marker(clone); + marked.push({ 'key': markerKey, 'object': value }); + } else { + // for frozen/sealed objects + unmarked.push({ 'clone': clone, 'object': value }); + } + // iterate over object properties + forProps(value, forPropsCallback, { 'which': 'all' }); + } + } + } + if (parent) { + // for custom property descriptors + if (accessor || (descriptor && !(descriptor.configurable && descriptor.enumerable && descriptor.writable))) { + if ('value' in descriptor) { + descriptor.value = clone; + } + setDescriptor(parent, key, descriptor); + } + // for default property descriptors + else { + parent[key] = clone; + } + } else { + result = clone; + } + } while ((data = queue[index++])); + + // remove markers + for (index = 0, length = marked.length; index < length; index++) { + data = marked[index]; + delete data.object[data.key]; + } + return result; + } + + /** + * An iteration utility for arrays and objects. + * Callbacks may terminate the loop by explicitly returning `false`. + * + * @static + * @memberOf Benchmark + * @param {Array|Object} object The object to iterate over. + * @param {Function} callback The function called per iteration. + * @param {Mixed} thisArg The `this` binding for the callback. + * @returns {Array|Object} Returns the object iterated over. + */ + function each(object, callback, thisArg) { + var result = object; + object = Object(object); + + var fn = callback, + index = -1, + length = object.length, + isSnapshot = !!(object.snapshotItem && (length = object.snapshotLength)), + isSplittable = (noCharByIndex || noCharByOwnIndex) && isClassOf(object, 'String'), + isConvertable = isSnapshot || isSplittable || 'item' in object, + origObject = object; + + // in Opera < 10.5 `hasKey(object, 'length')` returns `false` for NodeLists + if (length === length >>> 0) { + if (isConvertable) { + // the third argument of the callback is the original non-array object + callback = function(value, index) { + return fn.call(this, value, index, origObject); + }; + // in IE < 9 strings don't support accessing characters by index + if (isSplittable) { + object = object.split(''); + } else { + object = []; + while (++index < length) { + // in Safari 2 `index in object` is always `false` for NodeLists + object[index] = isSnapshot ? result.snapshotItem(index) : result[index]; + } + } + } + forEach(object, callback, thisArg); + } else { + forOwn(object, callback, thisArg); + } + return result; + } + + /** + * Copies enumerable properties from the source(s) object to the destination object. + * + * @static + * @memberOf Benchmark + * @param {Object} destination The destination object. + * @param {Object} [source={}] The source object. + * @returns {Object} The destination object. + */ + function extend(destination, source) { + // Chrome < 14 incorrectly sets `destination` to `undefined` when we `delete arguments[0]` + // http://code.google.com/p/v8/issues/detail?id=839 + var result = destination; + delete arguments[0]; + + forEach(arguments, function(source) { + forProps(source, function(value, key) { + result[key] = value; + }); + }); + return result; + } + + /** + * A generic `Array#filter` like method. + * + * @static + * @memberOf Benchmark + * @param {Array} array The array to iterate over. + * @param {Function|String} callback The function/alias called per iteration. + * @param {Mixed} thisArg The `this` binding for the callback. + * @returns {Array} A new array of values that passed callback filter. + * @example + * + * // get odd numbers + * Benchmark.filter([1, 2, 3, 4, 5], function(n) { + * return n % 2; + * }); // -> [1, 3, 5]; + * + * // get fastest benchmarks + * Benchmark.filter(benches, 'fastest'); + * + * // get slowest benchmarks + * Benchmark.filter(benches, 'slowest'); + * + * // get benchmarks that completed without erroring + * Benchmark.filter(benches, 'successful'); + */ + function filter(array, callback, thisArg) { + var result; + + if (callback == 'successful') { + // callback to exclude those that are errored, unrun, or have hz of Infinity + callback = function(bench) { return bench.cycles && isFinite(bench.hz); }; + } + else if (callback == 'fastest' || callback == 'slowest') { + // get successful, sort by period + margin of error, and filter fastest/slowest + result = filter(array, 'successful').sort(function(a, b) { + a = a.stats; b = b.stats; + return (a.mean + a.moe > b.mean + b.moe ? 1 : -1) * (callback == 'fastest' ? 1 : -1); + }); + result = filter(result, function(bench) { + return result[0].compare(bench) == 0; + }); + } + return result || reduce(array, function(result, value, index) { + return callback.call(thisArg, value, index, array) ? (result.push(value), result) : result; + }, []); + } + + /** + * A generic `Array#forEach` like method. + * Callbacks may terminate the loop by explicitly returning `false`. + * + * @static + * @memberOf Benchmark + * @param {Array} array The array to iterate over. + * @param {Function} callback The function called per iteration. + * @param {Mixed} thisArg The `this` binding for the callback. + * @returns {Array} Returns the array iterated over. + */ + function forEach(array, callback, thisArg) { + var index = -1, + length = (array = Object(array)).length >>> 0; + + if (thisArg !== undefined) { + callback = bind(callback, thisArg); + } + while (++index < length) { + if (index in array && + callback(array[index], index, array) === false) { + break; + } + } + return array; + } + + /** + * Iterates over an object's own properties, executing the `callback` for each. + * Callbacks may terminate the loop by explicitly returning `false`. + * + * @static + * @memberOf Benchmark + * @param {Object} object The object to iterate over. + * @param {Function} callback The function executed per own property. + * @param {Mixed} thisArg The `this` binding for the callback. + * @returns {Object} Returns the object iterated over. + */ + function forOwn(object, callback, thisArg) { + return forProps(object, callback, { 'bind': thisArg, 'which': 'own' }); + } + + /** + * Converts a number to a more readable comma-separated string representation. + * + * @static + * @memberOf Benchmark + * @param {Number} number The number to convert. + * @returns {String} The more readable string representation. + */ + function formatNumber(number) { + number = String(number).split('.'); + return number[0].replace(/(?=(?:\d{3})+$)(?!\b)/g, ',') + + (number[1] ? '.' + number[1] : ''); + } + + /** + * Checks if an object has the specified key as a direct property. + * + * @static + * @memberOf Benchmark + * @param {Object} object The object to check. + * @param {String} key The key to check for. + * @returns {Boolean} Returns `true` if key is a direct property, else `false`. + */ + function hasKey() { + // lazy define for worst case fallback (not as accurate) + hasKey = function(object, key) { + var parent = object != null && (object.constructor || Object).prototype; + return !!parent && key in Object(object) && !(key in parent && object[key] === parent[key]); + }; + // for modern browsers + if (isClassOf(hasOwnProperty, 'Function')) { + hasKey = function(object, key) { + return object != null && hasOwnProperty.call(object, key); + }; + } + // for Safari 2 + else if ({}.__proto__ == Object.prototype) { + hasKey = function(object, key) { + var result = false; + if (object != null) { + object = Object(object); + object.__proto__ = [object.__proto__, object.__proto__ = null, result = key in object][0]; + } + return result; + }; + } + return hasKey.apply(this, arguments); + } + + /** + * A generic `Array#indexOf` like method. + * + * @static + * @memberOf Benchmark + * @param {Array} array The array to iterate over. + * @param {Mixed} value The value to search for. + * @param {Number} [fromIndex=0] The index to start searching from. + * @returns {Number} The index of the matched value or `-1`. + */ + function indexOf(array, value, fromIndex) { + var index = toInteger(fromIndex), + length = (array = Object(array)).length >>> 0; + + index = (index < 0 ? max(0, length + index) : index) - 1; + while (++index < length) { + if (index in array && value === array[index]) { + return index; + } + } + return -1; + } + + /** + * Modify a string by replacing named tokens with matching object property values. + * + * @static + * @memberOf Benchmark + * @param {String} string The string to modify. + * @param {Object} object The template object. + * @returns {String} The modified string. + */ + function interpolate(string, object) { + forOwn(object, function(value, key) { + // escape regexp special characters in `key` + string = string.replace(RegExp('#\\{' + key.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1') + '\\}', 'g'), value); + }); + return string; + } + + /** + * Invokes a method on all items in an array. + * + * @static + * @memberOf Benchmark + * @param {Array} benches Array of benchmarks to iterate over. + * @param {String|Object} name The name of the method to invoke OR options object. + * @param {Mixed} [arg1, arg2, ...] Arguments to invoke the method with. + * @returns {Array} A new array of values returned from each method invoked. + * @example + * + * // invoke `reset` on all benchmarks + * Benchmark.invoke(benches, 'reset'); + * + * // invoke `emit` with arguments + * Benchmark.invoke(benches, 'emit', 'complete', listener); + * + * // invoke `run(true)`, treat benchmarks as a queue, and register invoke callbacks + * Benchmark.invoke(benches, { + * + * // invoke the `run` method + * 'name': 'run', + * + * // pass a single argument + * 'args': true, + * + * // treat as queue, removing benchmarks from front of `benches` until empty + * 'queued': true, + * + * // called before any benchmarks have been invoked. + * 'onStart': onStart, + * + * // called between invoking benchmarks + * 'onCycle': onCycle, + * + * // called after all benchmarks have been invoked. + * 'onComplete': onComplete + * }); + */ + function invoke(benches, name) { + var args, + bench, + queued, + index = -1, + eventProps = { 'currentTarget': benches }, + options = { 'onStart': noop, 'onCycle': noop, 'onComplete': noop }, + result = map(benches, function(bench) { return bench; }); + + /** + * Invokes the method of the current object and if synchronous, fetches the next. + */ + function execute() { + var listeners, + async = isAsync(bench); + + if (async) { + // use `getNext` as the first listener + bench.on('complete', getNext); + listeners = bench.events.complete; + listeners.splice(0, 0, listeners.pop()); + } + // execute method + result[index] = isClassOf(bench && bench[name], 'Function') ? bench[name].apply(bench, args) : undefined; + // if synchronous return true until finished + return !async && getNext(); + } + + /** + * Fetches the next bench or executes `onComplete` callback. + */ + function getNext(event) { + var cycleEvent, + last = bench, + async = isAsync(last); + + if (async) { + last.off('complete', getNext); + last.emit('complete'); + } + // emit "cycle" event + eventProps.type = 'cycle'; + eventProps.target = last; + cycleEvent = Event(eventProps); + options.onCycle.call(benches, cycleEvent); + + // choose next benchmark if not exiting early + if (!cycleEvent.aborted && raiseIndex() !== false) { + bench = queued ? benches[0] : result[index]; + if (isAsync(bench)) { + delay(bench, execute); + } + else if (async) { + // resume execution if previously asynchronous but now synchronous + while (execute()) { } + } + else { + // continue synchronous execution + return true; + } + } else { + // emit "complete" event + eventProps.type = 'complete'; + options.onComplete.call(benches, Event(eventProps)); + } + // When used as a listener `event.aborted = true` will cancel the rest of + // the "complete" listeners because they were already called above and when + // used as part of `getNext` the `return false` will exit the execution while-loop. + if (event) { + event.aborted = true; + } else { + return false; + } + } + + /** + * Checks if invoking `Benchmark#run` with asynchronous cycles. + */ + function isAsync(object) { + // avoid using `instanceof` here because of IE memory leak issues with host objects + var async = args[0] && args[0].async; + return Object(object).constructor == Benchmark && name == 'run' && + ((async == null ? object.options.async : async) && support.timeout || object.defer); + } + + /** + * Raises `index` to the next defined index or returns `false`. + */ + function raiseIndex() { + var length = result.length; + if (queued) { + // if queued remove the previous bench and subsequent skipped non-entries + do { + ++index > 0 && shift.call(benches); + } while ((length = benches.length) && !('0' in benches)); + } + else { + while (++index < length && !(index in result)) { } + } + // if we reached the last index then return `false` + return (queued ? length : index < length) ? index : (index = false); + } + + // juggle arguments + if (isClassOf(name, 'String')) { + // 2 arguments (array, name) + args = slice.call(arguments, 2); + } else { + // 2 arguments (array, options) + options = extend(options, name); + name = options.name; + args = isClassOf(args = 'args' in options ? options.args : [], 'Array') ? args : [args]; + queued = options.queued; + } + + // start iterating over the array + if (raiseIndex() !== false) { + // emit "start" event + bench = result[index]; + eventProps.type = 'start'; + eventProps.target = bench; + options.onStart.call(benches, Event(eventProps)); + + // end early if the suite was aborted in an "onStart" listener + if (benches.aborted && benches.constructor == Suite && name == 'run') { + // emit "cycle" event + eventProps.type = 'cycle'; + options.onCycle.call(benches, Event(eventProps)); + // emit "complete" event + eventProps.type = 'complete'; + options.onComplete.call(benches, Event(eventProps)); + } + // else start + else { + if (isAsync(bench)) { + delay(bench, execute); + } else { + while (execute()) { } + } + } + } + return result; + } + + /** + * Creates a string of joined array values or object key-value pairs. + * + * @static + * @memberOf Benchmark + * @param {Array|Object} object The object to operate on. + * @param {String} [separator1=','] The separator used between key-value pairs. + * @param {String} [separator2=': '] The separator used between keys and values. + * @returns {String} The joined result. + */ + function join(object, separator1, separator2) { + var result = [], + length = (object = Object(object)).length, + arrayLike = length === length >>> 0; + + separator2 || (separator2 = ': '); + each(object, function(value, key) { + result.push(arrayLike ? value : key + separator2 + value); + }); + return result.join(separator1 || ','); + } + + /** + * A generic `Array#map` like method. + * + * @static + * @memberOf Benchmark + * @param {Array} array The array to iterate over. + * @param {Function} callback The function called per iteration. + * @param {Mixed} thisArg The `this` binding for the callback. + * @returns {Array} A new array of values returned by the callback. + */ + function map(array, callback, thisArg) { + return reduce(array, function(result, value, index) { + result[index] = callback.call(thisArg, value, index, array); + return result; + }, Array(Object(array).length >>> 0)); + } + + /** + * Retrieves the value of a specified property from all items in an array. + * + * @static + * @memberOf Benchmark + * @param {Array} array The array to iterate over. + * @param {String} property The property to pluck. + * @returns {Array} A new array of property values. + */ + function pluck(array, property) { + return map(array, function(object) { + return object == null ? undefined : object[property]; + }); + } + + /** + * A generic `Array#reduce` like method. + * + * @static + * @memberOf Benchmark + * @param {Array} array The array to iterate over. + * @param {Function} callback The function called per iteration. + * @param {Mixed} accumulator Initial value of the accumulator. + * @returns {Mixed} The accumulator. + */ + function reduce(array, callback, accumulator) { + var noaccum = arguments.length < 3; + forEach(array, function(value, index) { + accumulator = noaccum ? (noaccum = false, value) : callback(accumulator, value, index, array); + }); + return accumulator; + } + + /*--------------------------------------------------------------------------*/ + + /** + * Aborts all benchmarks in the suite. + * + * @name abort + * @memberOf Benchmark.Suite + * @returns {Object} The suite instance. + */ + function abortSuite() { + var event, + me = this, + resetting = calledBy.resetSuite; + + if (me.running) { + event = Event('abort'); + me.emit(event); + if (!event.cancelled || resetting) { + // avoid infinite recursion + calledBy.abortSuite = true; + me.reset(); + delete calledBy.abortSuite; + + if (!resetting) { + me.aborted = true; + invoke(me, 'abort'); + } + } + } + return me; + } + + /** + * Adds a test to the benchmark suite. + * + * @memberOf Benchmark.Suite + * @param {String} name A name to identify the benchmark. + * @param {Function|String} fn The test to benchmark. + * @param {Object} [options={}] Options object. + * @returns {Object} The benchmark instance. + * @example + * + * // basic usage + * suite.add(fn); + * + * // or using a name first + * suite.add('foo', fn); + * + * // or with options + * suite.add('foo', fn, { + * 'onCycle': onCycle, + * 'onComplete': onComplete + * }); + * + * // or name and options + * suite.add('foo', { + * 'fn': fn, + * 'onCycle': onCycle, + * 'onComplete': onComplete + * }); + * + * // or options only + * suite.add({ + * 'name': 'foo', + * 'fn': fn, + * 'onCycle': onCycle, + * 'onComplete': onComplete + * }); + */ + function add(name, fn, options) { + var me = this, + bench = Benchmark(name, fn, options), + event = Event({ 'type': 'add', 'target': bench }); + + if (me.emit(event), !event.cancelled) { + me.push(bench); + } + return me; + } + + /** + * Creates a new suite with cloned benchmarks. + * + * @name clone + * @memberOf Benchmark.Suite + * @param {Object} options Options object to overwrite cloned options. + * @returns {Object} The new suite instance. + */ + function cloneSuite(options) { + var me = this, + result = new me.constructor(extend({}, me.options, options)); + + // copy own properties + forOwn(me, function(value, key) { + if (!hasKey(result, key)) { + result[key] = value && isClassOf(value.clone, 'Function') + ? value.clone() + : deepClone(value); + } + }); + return result; + } + + /** + * An `Array#filter` like method. + * + * @name filter + * @memberOf Benchmark.Suite + * @param {Function|String} callback The function/alias called per iteration. + * @returns {Object} A new suite of benchmarks that passed callback filter. + */ + function filterSuite(callback) { + var me = this, + result = new me.constructor; + + result.push.apply(result, filter(me, callback)); + return result; + } + + /** + * Resets all benchmarks in the suite. + * + * @name reset + * @memberOf Benchmark.Suite + * @returns {Object} The suite instance. + */ + function resetSuite() { + var event, + me = this, + aborting = calledBy.abortSuite; + + if (me.running && !aborting) { + // no worries, `resetSuite()` is called within `abortSuite()` + calledBy.resetSuite = true; + me.abort(); + delete calledBy.resetSuite; + } + // reset if the state has changed + else if ((me.aborted || me.running) && + (me.emit(event = Event('reset')), !event.cancelled)) { + me.running = false; + if (!aborting) { + invoke(me, 'reset'); + } + } + return me; + } + + /** + * Runs the suite. + * + * @name run + * @memberOf Benchmark.Suite + * @param {Object} [options={}] Options object. + * @returns {Object} The suite instance. + * @example + * + * // basic usage + * suite.run(); + * + * // or with options + * suite.run({ 'async': true, 'queued': true }); + */ + function runSuite(options) { + var me = this; + + me.reset(); + me.running = true; + options || (options = {}); + + invoke(me, { + 'name': 'run', + 'args': options, + 'queued': options.queued, + 'onStart': function(event) { + me.emit(event); + }, + 'onCycle': function(event) { + var bench = event.target; + if (bench.error) { + me.emit({ 'type': 'error', 'target': bench }); + } + me.emit(event); + event.aborted = me.aborted; + }, + 'onComplete': function(event) { + me.running = false; + me.emit(event); + } + }); + return me; + } + + /*--------------------------------------------------------------------------*/ + + /** + * Executes all registered listeners of the specified event type. + * + * @memberOf Benchmark, Benchmark.Suite + * @param {String|Object} type The event type or object. + * @returns {Mixed} Returns the return value of the last listener executed. + */ + function emit(type) { + var listeners, + me = this, + event = Event(type), + events = me.events, + args = (arguments[0] = event, arguments); + + event.currentTarget || (event.currentTarget = me); + event.target || (event.target = me); + delete event.result; + + if (events && (listeners = hasKey(events, event.type) && events[event.type])) { + forEach(listeners.slice(), function(listener) { + if ((event.result = listener.apply(me, args)) === false) { + event.cancelled = true; + } + return !event.aborted; + }); + } + return event.result; + } + + /** + * Returns an array of event listeners for a given type that can be manipulated + * to add or remove listeners. + * + * @memberOf Benchmark, Benchmark.Suite + * @param {String} type The event type. + * @returns {Array} The listeners array. + */ + function listeners(type) { + var me = this, + events = me.events || (me.events = {}); + + return hasKey(events, type) ? events[type] : (events[type] = []); + } + + /** + * Unregisters a listener for the specified event type(s), + * or unregisters all listeners for the specified event type(s), + * or unregisters all listeners for all event types. + * + * @memberOf Benchmark, Benchmark.Suite + * @param {String} [type] The event type. + * @param {Function} [listener] The function to unregister. + * @returns {Object} The benchmark instance. + * @example + * + * // unregister a listener for an event type + * bench.off('cycle', listener); + * + * // unregister a listener for multiple event types + * bench.off('start cycle', listener); + * + * // unregister all listeners for an event type + * bench.off('cycle'); + * + * // unregister all listeners for multiple event types + * bench.off('start cycle complete'); + * + * // unregister all listeners for all event types + * bench.off(); + */ + function off(type, listener) { + var me = this, + events = me.events; + + events && each(type ? type.split(' ') : events, function(listeners, type) { + var index; + if (typeof listeners == 'string') { + type = listeners; + listeners = hasKey(events, type) && events[type]; + } + if (listeners) { + if (listener) { + index = indexOf(listeners, listener); + if (index > -1) { + listeners.splice(index, 1); + } + } else { + listeners.length = 0; + } + } + }); + return me; + } + + /** + * Registers a listener for the specified event type(s). + * + * @memberOf Benchmark, Benchmark.Suite + * @param {String} type The event type. + * @param {Function} listener The function to register. + * @returns {Object} The benchmark instance. + * @example + * + * // register a listener for an event type + * bench.on('cycle', listener); + * + * // register a listener for multiple event types + * bench.on('start cycle', listener); + */ + function on(type, listener) { + var me = this, + events = me.events || (me.events = {}); + + forEach(type.split(' '), function(type) { + (hasKey(events, type) + ? events[type] + : (events[type] = []) + ).push(listener); + }); + return me; + } + + /*--------------------------------------------------------------------------*/ + + /** + * Aborts the benchmark without recording times. + * + * @memberOf Benchmark + * @returns {Object} The benchmark instance. + */ + function abort() { + var event, + me = this, + resetting = calledBy.reset; + + if (me.running) { + event = Event('abort'); + me.emit(event); + if (!event.cancelled || resetting) { + // avoid infinite recursion + calledBy.abort = true; + me.reset(); + delete calledBy.abort; + + if (support.timeout) { + clearTimeout(me._timerId); + delete me._timerId; + } + if (!resetting) { + me.aborted = true; + me.running = false; + } + } + } + return me; + } + + /** + * Creates a new benchmark using the same test and options. + * + * @memberOf Benchmark + * @param {Object} options Options object to overwrite cloned options. + * @returns {Object} The new benchmark instance. + * @example + * + * var bizarro = bench.clone({ + * 'name': 'doppelganger' + * }); + */ + function clone(options) { + var me = this, + result = new me.constructor(extend({}, me, options)); + + // correct the `options` object + result.options = extend({}, me.options, options); + + // copy own custom properties + forOwn(me, function(value, key) { + if (!hasKey(result, key)) { + result[key] = deepClone(value); + } + }); + return result; + } + + /** + * Determines if a benchmark is faster than another. + * + * @memberOf Benchmark + * @param {Object} other The benchmark to compare. + * @returns {Number} Returns `-1` if slower, `1` if faster, and `0` if indeterminate. + */ + function compare(other) { + var critical, + zStat, + me = this, + sample1 = me.stats.sample, + sample2 = other.stats.sample, + size1 = sample1.length, + size2 = sample2.length, + maxSize = max(size1, size2), + minSize = min(size1, size2), + u1 = getU(sample1, sample2), + u2 = getU(sample2, sample1), + u = min(u1, u2); + + function getScore(xA, sampleB) { + return reduce(sampleB, function(total, xB) { + return total + (xB > xA ? 0 : xB < xA ? 1 : 0.5); + }, 0); + } + + function getU(sampleA, sampleB) { + return reduce(sampleA, function(total, xA) { + return total + getScore(xA, sampleB); + }, 0); + } + + function getZ(u) { + return (u - ((size1 * size2) / 2)) / sqrt((size1 * size2 * (size1 + size2 + 1)) / 12); + } + + // exit early if comparing the same benchmark + if (me == other) { + return 0; + } + // reject the null hyphothesis the two samples come from the + // same population (i.e. have the same median) if... + if (size1 + size2 > 30) { + // ...the z-stat is greater than 1.96 or less than -1.96 + // http://www.statisticslectures.com/topics/mannwhitneyu/ + zStat = getZ(u); + return abs(zStat) > 1.96 ? (zStat > 0 ? -1 : 1) : 0; + } + // ...the U value is less than or equal the critical U value + // http://www.geoib.com/mann-whitney-u-test.html + critical = maxSize < 5 || minSize < 3 ? 0 : uTable[maxSize][minSize - 3]; + return u <= critical ? (u == u1 ? 1 : -1) : 0; + } + + /** + * Reset properties and abort if running. + * + * @memberOf Benchmark + * @returns {Object} The benchmark instance. + */ + function reset() { + var data, + event, + me = this, + index = 0, + changes = { 'length': 0 }, + queue = { 'length': 0 }; + + if (me.running && !calledBy.abort) { + // no worries, `reset()` is called within `abort()` + calledBy.reset = true; + me.abort(); + delete calledBy.reset; + } + else { + // a non-recursive solution to check if properties have changed + // http://www.jslab.dk/articles/non.recursive.preorder.traversal.part4 + data = { 'destination': me, 'source': extend({}, me.constructor.prototype, me.options) }; + do { + forOwn(data.source, function(value, key) { + var changed, + destination = data.destination, + currValue = destination[key]; + + if (value && typeof value == 'object') { + if (isClassOf(value, 'Array')) { + // check if an array value has changed to a non-array value + if (!isClassOf(currValue, 'Array')) { + changed = currValue = []; + } + // or has changed its length + if (currValue.length != value.length) { + changed = currValue = currValue.slice(0, value.length); + currValue.length = value.length; + } + } + // check if an object has changed to a non-object value + else if (!currValue || typeof currValue != 'object') { + changed = currValue = {}; + } + // register a changed object + if (changed) { + changes[changes.length++] = { 'destination': destination, 'key': key, 'value': currValue }; + } + queue[queue.length++] = { 'destination': currValue, 'source': value }; + } + // register a changed primitive + else if (value !== currValue && !(value == null || isClassOf(value, 'Function'))) { + changes[changes.length++] = { 'destination': destination, 'key': key, 'value': value }; + } + }); + } + while ((data = queue[index++])); + + // if changed emit the `reset` event and if it isn't cancelled reset the benchmark + if (changes.length && (me.emit(event = Event('reset')), !event.cancelled)) { + forEach(changes, function(data) { + data.destination[data.key] = data.value; + }); + } + } + return me; + } + + /** + * Displays relevant benchmark information when coerced to a string. + * + * @name toString + * @memberOf Benchmark + * @returns {String} A string representation of the benchmark instance. + */ + function toStringBench() { + var me = this, + error = me.error, + hz = me.hz, + id = me.id, + stats = me.stats, + size = stats.sample.length, + pm = support.java ? '+/-' : '\xb1', + result = me.name || (isNaN(id) ? id : ''); + + if (error) { + result += ': ' + join(error); + } else { + result += ' x ' + formatNumber(hz.toFixed(hz < 100 ? 2 : 0)) + ' ops/sec ' + pm + + stats.rme.toFixed(2) + '% (' + size + ' run' + (size == 1 ? '' : 's') + ' sampled)'; + } + return result; + } + + /*--------------------------------------------------------------------------*/ + + /** + * Clocks the time taken to execute a test per cycle (secs). + * + * @private + * @param {Object} bench The benchmark instance. + * @returns {Number} The time taken. + */ + function clock() { + var applet, + options = Benchmark.options, + template = { 'begin': 's$=new n$', 'end': 'r$=(new n$-s$)/1e3', 'uid': uid }, + timers = [{ 'ns': timer.ns, 'res': max(0.0015, getRes('ms')), 'unit': 'ms' }]; + + // lazy define for hi-res timers + clock = function(clone) { + var deferred; + if (clone instanceof Deferred) { + deferred = clone; + clone = deferred.benchmark; + } + + var bench = clone._original, + fn = bench.fn, + fnArg = deferred ? getFirstArgument(fn) || 'deferred' : '', + stringable = isStringable(fn); + + var source = { + 'setup': getSource(bench.setup, preprocess('m$.setup()')), + 'fn': getSource(fn, preprocess('m$.fn(' + fnArg + ')')), + 'fnArg': fnArg, + 'teardown': getSource(bench.teardown, preprocess('m$.teardown()')) + }; + + var count = bench.count = clone.count, + decompilable = support.decompilation || stringable, + id = bench.id, + isEmpty = !(source.fn || stringable), + name = bench.name || (typeof id == 'number' ? '' : id), + ns = timer.ns, + result = 0; + + // init `minTime` if needed + clone.minTime = bench.minTime || (bench.minTime = bench.options.minTime = options.minTime); + + // repair nanosecond timer + // (some Chrome builds erase the `ns` variable after millions of executions) + if (applet) { + try { + ns.nanoTime(); + } catch(e) { + // use non-element to avoid issues with libs that augment them + ns = timer.ns = new applet.Packages.nano; + } + } + + // Compile in setup/teardown functions and the test loop. + // Create a new compiled test, instead of using the cached `bench.compiled`, + // to avoid potential engine optimizations enabled over the life of the test. + var compiled = bench.compiled = createFunction(preprocess('t$'), interpolate( + preprocess(deferred + ? 'var d$=this,#{fnArg}=d$,m$=d$.benchmark._original,f$=m$.fn,su$=m$.setup,td$=m$.teardown;' + + // when `deferred.cycles` is `0` then... + 'if(!d$.cycles){' + + // set `deferred.fn` + 'd$.fn=function(){var #{fnArg}=d$;if(typeof f$=="function"){try{#{fn}\n}catch(e$){f$(d$)}}else{#{fn}\n}};' + + // set `deferred.teardown` + 'd$.teardown=function(){d$.cycles=0;if(typeof td$=="function"){try{#{teardown}\n}catch(e$){td$()}}else{#{teardown}\n}};' + + // execute the benchmark's `setup` + 'if(typeof su$=="function"){try{#{setup}\n}catch(e$){su$()}}else{#{setup}\n};' + + // start timer + 't$.start(d$);' + + // execute `deferred.fn` and return a dummy object + '}d$.fn();return{}' + + : 'var r$,s$,m$=this,f$=m$.fn,i$=m$.count,n$=t$.ns;#{setup}\n#{begin};' + + 'while(i$--){#{fn}\n}#{end};#{teardown}\nreturn{elapsed:r$,uid:"#{uid}"}'), + source + )); + + try { + if (isEmpty) { + // Firefox may remove dead code from Function#toString results + // http://bugzil.la/536085 + throw new Error('The test "' + name + '" is empty. This may be the result of dead code removal.'); + } + else if (!deferred) { + // pretest to determine if compiled code is exits early, usually by a + // rogue `return` statement, by checking for a return object with the uid + bench.count = 1; + compiled = (compiled.call(bench, timer) || {}).uid == uid && compiled; + bench.count = count; + } + } catch(e) { + compiled = null; + clone.error = e || new Error(String(e)); + bench.count = count; + } + // fallback when a test exits early or errors during pretest + if (decompilable && !compiled && !deferred && !isEmpty) { + compiled = createFunction(preprocess('t$'), interpolate( + preprocess( + (clone.error && !stringable + ? 'var r$,s$,m$=this,f$=m$.fn,i$=m$.count' + : 'function f$(){#{fn}\n}var r$,s$,m$=this,i$=m$.count' + ) + + ',n$=t$.ns;#{setup}\n#{begin};m$.f$=f$;while(i$--){m$.f$()}#{end};' + + 'delete m$.f$;#{teardown}\nreturn{elapsed:r$}' + ), + source + )); + + try { + // pretest one more time to check for errors + bench.count = 1; + compiled.call(bench, timer); + bench.compiled = compiled; + bench.count = count; + delete clone.error; + } + catch(e) { + bench.count = count; + if (clone.error) { + compiled = null; + } else { + bench.compiled = compiled; + clone.error = e || new Error(String(e)); + } + } + } + // assign `compiled` to `clone` before calling in case a deferred benchmark + // immediately calls `deferred.resolve()` + clone.compiled = compiled; + // if no errors run the full test loop + if (!clone.error) { + result = compiled.call(deferred || bench, timer).elapsed; + } + return result; + }; + + /*------------------------------------------------------------------------*/ + + /** + * Gets the current timer's minimum resolution (secs). + */ + function getRes(unit) { + var measured, + begin, + count = 30, + divisor = 1e3, + ns = timer.ns, + sample = []; + + // get average smallest measurable time + while (count--) { + if (unit == 'us') { + divisor = 1e6; + if (ns.stop) { + ns.start(); + while (!(measured = ns.microseconds())) { } + } else if (ns[perfName]) { + divisor = 1e3; + measured = Function('n', 'var r,s=n.' + perfName + '();while(!(r=n.' + perfName + '()-s)){};return r')(ns); + } else { + begin = ns(); + while (!(measured = ns() - begin)) { } + } + } + else if (unit == 'ns') { + divisor = 1e9; + if (ns.nanoTime) { + begin = ns.nanoTime(); + while (!(measured = ns.nanoTime() - begin)) { } + } else { + begin = (begin = ns())[0] + (begin[1] / divisor); + while (!(measured = ((measured = ns())[0] + (measured[1] / divisor)) - begin)) { } + divisor = 1; + } + } + else { + begin = new ns; + while (!(measured = new ns - begin)) { } + } + // check for broken timers (nanoTime may have issues) + // http://alivebutsleepy.srnet.cz/unreliable-system-nanotime/ + if (measured > 0) { + sample.push(measured); + } else { + sample.push(Infinity); + break; + } + } + // convert to seconds + return getMean(sample) / divisor; + } + + /** + * Replaces all occurrences of `$` with a unique number and + * template tokens with content. + */ + function preprocess(code) { + return interpolate(code, template).replace(/\$/g, /\d+/.exec(uid)); + } + + /*------------------------------------------------------------------------*/ + + // detect nanosecond support from a Java applet + each(doc && doc.applets || [], function(element) { + return !(timer.ns = applet = 'nanoTime' in element && element); + }); + + // check type in case Safari returns an object instead of a number + try { + if (typeof timer.ns.nanoTime() == 'number') { + timers.push({ 'ns': timer.ns, 'res': getRes('ns'), 'unit': 'ns' }); + } + } catch(e) { } + + // detect Chrome's microsecond timer: + // enable benchmarking via the --enable-benchmarking command + // line switch in at least Chrome 7 to use chrome.Interval + try { + if ((timer.ns = new (window.chrome || window.chromium).Interval)) { + timers.push({ 'ns': timer.ns, 'res': getRes('us'), 'unit': 'us' }); + } + } catch(e) { } + + // detect `performance.now` microsecond resolution timer + if ((timer.ns = perfName && perfObject)) { + timers.push({ 'ns': timer.ns, 'res': getRes('us'), 'unit': 'us' }); + } + + // detect Node's nanosecond resolution timer available in Node >= 0.8 + if (processObject && typeof (timer.ns = processObject.hrtime) == 'function') { + timers.push({ 'ns': timer.ns, 'res': getRes('ns'), 'unit': 'ns' }); + } + + // detect Wade Simmons' Node microtime module + if (microtimeObject && typeof (timer.ns = microtimeObject.now) == 'function') { + timers.push({ 'ns': timer.ns, 'res': getRes('us'), 'unit': 'us' }); + } + + // pick timer with highest resolution + timer = reduce(timers, function(timer, other) { + return other.res < timer.res ? other : timer; + }); + + // remove unused applet + if (timer.unit != 'ns' && applet) { + applet = destroyElement(applet); + } + // error if there are no working timers + if (timer.res == Infinity) { + throw new Error('Benchmark.js was unable to find a working timer.'); + } + // use API of chosen timer + if (timer.unit == 'ns') { + if (timer.ns.nanoTime) { + extend(template, { + 'begin': 's$=n$.nanoTime()', + 'end': 'r$=(n$.nanoTime()-s$)/1e9' + }); + } else { + extend(template, { + 'begin': 's$=n$()', + 'end': 'r$=n$(s$);r$=r$[0]+(r$[1]/1e9)' + }); + } + } + else if (timer.unit == 'us') { + if (timer.ns.stop) { + extend(template, { + 'begin': 's$=n$.start()', + 'end': 'r$=n$.microseconds()/1e6' + }); + } else if (perfName) { + extend(template, { + 'begin': 's$=n$.' + perfName + '()', + 'end': 'r$=(n$.' + perfName + '()-s$)/1e3' + }); + } else { + extend(template, { + 'begin': 's$=n$()', + 'end': 'r$=(n$()-s$)/1e6' + }); + } + } + + // define `timer` methods + timer.start = createFunction(preprocess('o$'), + preprocess('var n$=this.ns,#{begin};o$.elapsed=0;o$.timeStamp=s$')); + + timer.stop = createFunction(preprocess('o$'), + preprocess('var n$=this.ns,s$=o$.timeStamp,#{end};o$.elapsed=r$')); + + // resolve time span required to achieve a percent uncertainty of at most 1% + // http://spiff.rit.edu/classes/phys273/uncert/uncert.html + options.minTime || (options.minTime = max(timer.res / 2 / 0.01, 0.05)); + return clock.apply(null, arguments); + } + + /*--------------------------------------------------------------------------*/ + + /** + * Computes stats on benchmark results. + * + * @private + * @param {Object} bench The benchmark instance. + * @param {Object} options The options object. + */ + function compute(bench, options) { + options || (options = {}); + + var async = options.async, + elapsed = 0, + initCount = bench.initCount, + minSamples = bench.minSamples, + queue = [], + sample = bench.stats.sample; + + /** + * Adds a clone to the queue. + */ + function enqueue() { + queue.push(bench.clone({ + '_original': bench, + 'events': { + 'abort': [update], + 'cycle': [update], + 'error': [update], + 'start': [update] + } + })); + } + + /** + * Updates the clone/original benchmarks to keep their data in sync. + */ + function update(event) { + var clone = this, + type = event.type; + + if (bench.running) { + if (type == 'start') { + // Note: `clone.minTime` prop is inited in `clock()` + clone.count = bench.initCount; + } + else { + if (type == 'error') { + bench.error = clone.error; + } + if (type == 'abort') { + bench.abort(); + bench.emit('cycle'); + } else { + event.currentTarget = event.target = bench; + bench.emit(event); + } + } + } else if (bench.aborted) { + // clear abort listeners to avoid triggering bench's abort/cycle again + clone.events.abort.length = 0; + clone.abort(); + } + } + + /** + * Determines if more clones should be queued or if cycling should stop. + */ + function evaluate(event) { + var critical, + df, + mean, + moe, + rme, + sd, + sem, + variance, + clone = event.target, + done = bench.aborted, + now = +new Date, + size = sample.push(clone.times.period), + maxedOut = size >= minSamples && (elapsed += now - clone.times.timeStamp) / 1e3 > bench.maxTime, + times = bench.times, + varOf = function(sum, x) { return sum + pow(x - mean, 2); }; + + // exit early for aborted or unclockable tests + if (done || clone.hz == Infinity) { + maxedOut = !(size = sample.length = queue.length = 0); + } + + if (!done) { + // sample mean (estimate of the population mean) + mean = getMean(sample); + // sample variance (estimate of the population variance) + variance = reduce(sample, varOf, 0) / (size - 1) || 0; + // sample standard deviation (estimate of the population standard deviation) + sd = sqrt(variance); + // standard error of the mean (a.k.a. the standard deviation of the sampling distribution of the sample mean) + sem = sd / sqrt(size); + // degrees of freedom + df = size - 1; + // critical value + critical = tTable[Math.round(df) || 1] || tTable.infinity; + // margin of error + moe = sem * critical; + // relative margin of error + rme = (moe / mean) * 100 || 0; + + extend(bench.stats, { + 'deviation': sd, + 'mean': mean, + 'moe': moe, + 'rme': rme, + 'sem': sem, + 'variance': variance + }); + + // Abort the cycle loop when the minimum sample size has been collected + // and the elapsed time exceeds the maximum time allowed per benchmark. + // We don't count cycle delays toward the max time because delays may be + // increased by browsers that clamp timeouts for inactive tabs. + // https://developer.mozilla.org/en/window.setTimeout#Inactive_tabs + if (maxedOut) { + // reset the `initCount` in case the benchmark is rerun + bench.initCount = initCount; + bench.running = false; + done = true; + times.elapsed = (now - times.timeStamp) / 1e3; + } + if (bench.hz != Infinity) { + bench.hz = 1 / mean; + times.cycle = mean * bench.count; + times.period = mean; + } + } + // if time permits, increase sample size to reduce the margin of error + if (queue.length < 2 && !maxedOut) { + enqueue(); + } + // abort the invoke cycle when done + event.aborted = done; + } + + // init queue and begin + enqueue(); + invoke(queue, { + 'name': 'run', + 'args': { 'async': async }, + 'queued': true, + 'onCycle': evaluate, + 'onComplete': function() { bench.emit('complete'); } + }); + } + + /*--------------------------------------------------------------------------*/ + + /** + * Cycles a benchmark until a run `count` can be established. + * + * @private + * @param {Object} clone The cloned benchmark instance. + * @param {Object} options The options object. + */ + function cycle(clone, options) { + options || (options = {}); + + var deferred; + if (clone instanceof Deferred) { + deferred = clone; + clone = clone.benchmark; + } + + var clocked, + cycles, + divisor, + event, + minTime, + period, + async = options.async, + bench = clone._original, + count = clone.count, + times = clone.times; + + // continue, if not aborted between cycles + if (clone.running) { + // `minTime` is set to `Benchmark.options.minTime` in `clock()` + cycles = ++clone.cycles; + clocked = deferred ? deferred.elapsed : clock(clone); + minTime = clone.minTime; + + if (cycles > bench.cycles) { + bench.cycles = cycles; + } + if (clone.error) { + event = Event('error'); + event.message = clone.error; + clone.emit(event); + if (!event.cancelled) { + clone.abort(); + } + } + } + + // continue, if not errored + if (clone.running) { + // time taken to complete last test cycle + bench.times.cycle = times.cycle = clocked; + // seconds per operation + period = bench.times.period = times.period = clocked / count; + // ops per second + bench.hz = clone.hz = 1 / period; + // avoid working our way up to this next time + bench.initCount = clone.initCount = count; + // do we need to do another cycle? + clone.running = clocked < minTime; + + if (clone.running) { + // tests may clock at `0` when `initCount` is a small number, + // to avoid that we set its count to something a bit higher + if (!clocked && (divisor = divisors[clone.cycles]) != null) { + count = floor(4e6 / divisor); + } + // calculate how many more iterations it will take to achive the `minTime` + if (count <= clone.count) { + count += Math.ceil((minTime - clocked) / period); + } + clone.running = count != Infinity; + } + } + // should we exit early? + event = Event('cycle'); + clone.emit(event); + if (event.aborted) { + clone.abort(); + } + // figure out what to do next + if (clone.running) { + // start a new cycle + clone.count = count; + if (deferred) { + clone.compiled.call(deferred, timer); + } else if (async) { + delay(clone, function() { cycle(clone, options); }); + } else { + cycle(clone); + } + } + else { + // fix TraceMonkey bug associated with clock fallbacks + // http://bugzil.la/509069 + if (support.browser) { + runScript(uid + '=1;delete ' + uid); + } + // done + clone.emit('complete'); + } + } + + /*--------------------------------------------------------------------------*/ + + /** + * Runs the benchmark. + * + * @memberOf Benchmark + * @param {Object} [options={}] Options object. + * @returns {Object} The benchmark instance. + * @example + * + * // basic usage + * bench.run(); + * + * // or with options + * bench.run({ 'async': true }); + */ + function run(options) { + var me = this, + event = Event('start'); + + // set `running` to `false` so `reset()` won't call `abort()` + me.running = false; + me.reset(); + me.running = true; + + me.count = me.initCount; + me.times.timeStamp = +new Date; + me.emit(event); + + if (!event.cancelled) { + options = { 'async': ((options = options && options.async) == null ? me.async : options) && support.timeout }; + + // for clones created within `compute()` + if (me._original) { + if (me.defer) { + Deferred(me); + } else { + cycle(me, options); + } + } + // for original benchmarks + else { + compute(me, options); + } + } + return me; + } + + /*--------------------------------------------------------------------------*/ + + // Firefox 1 erroneously defines variable and argument names of functions on + // the function itself as non-configurable properties with `undefined` values. + // The bugginess continues as the `Benchmark` constructor has an argument + // named `options` and Firefox 1 will not assign a value to `Benchmark.options`, + // making it non-writable in the process, unless it is the first property + // assigned by for-in loop of `extend()`. + extend(Benchmark, { + + /** + * The default options copied by benchmark instances. + * + * @static + * @memberOf Benchmark + * @type Object + */ + 'options': { + + /** + * A flag to indicate that benchmark cycles will execute asynchronously + * by default. + * + * @memberOf Benchmark.options + * @type Boolean + */ + 'async': false, + + /** + * A flag to indicate that the benchmark clock is deferred. + * + * @memberOf Benchmark.options + * @type Boolean + */ + 'defer': false, + + /** + * The delay between test cycles (secs). + * @memberOf Benchmark.options + * @type Number + */ + 'delay': 0.005, + + /** + * Displayed by Benchmark#toString when a `name` is not available + * (auto-generated if absent). + * + * @memberOf Benchmark.options + * @type String + */ + 'id': undefined, + + /** + * The default number of times to execute a test on a benchmark's first cycle. + * + * @memberOf Benchmark.options + * @type Number + */ + 'initCount': 1, + + /** + * The maximum time a benchmark is allowed to run before finishing (secs). + * Note: Cycle delays aren't counted toward the maximum time. + * + * @memberOf Benchmark.options + * @type Number + */ + 'maxTime': 5, + + /** + * The minimum sample size required to perform statistical analysis. + * + * @memberOf Benchmark.options + * @type Number + */ + 'minSamples': 5, + + /** + * The time needed to reduce the percent uncertainty of measurement to 1% (secs). + * + * @memberOf Benchmark.options + * @type Number + */ + 'minTime': 0, + + /** + * The name of the benchmark. + * + * @memberOf Benchmark.options + * @type String + */ + 'name': undefined, + + /** + * An event listener called when the benchmark is aborted. + * + * @memberOf Benchmark.options + * @type Function + */ + 'onAbort': undefined, + + /** + * An event listener called when the benchmark completes running. + * + * @memberOf Benchmark.options + * @type Function + */ + 'onComplete': undefined, + + /** + * An event listener called after each run cycle. + * + * @memberOf Benchmark.options + * @type Function + */ + 'onCycle': undefined, + + /** + * An event listener called when a test errors. + * + * @memberOf Benchmark.options + * @type Function + */ + 'onError': undefined, + + /** + * An event listener called when the benchmark is reset. + * + * @memberOf Benchmark.options + * @type Function + */ + 'onReset': undefined, + + /** + * An event listener called when the benchmark starts running. + * + * @memberOf Benchmark.options + * @type Function + */ + 'onStart': undefined + }, + + /** + * Platform object with properties describing things like browser name, + * version, and operating system. + * + * @static + * @memberOf Benchmark + * @type Object + */ + 'platform': req('platform') || window.platform || { + + /** + * The platform description. + * + * @memberOf Benchmark.platform + * @type String + */ + 'description': window.navigator && navigator.userAgent || null, + + /** + * The name of the browser layout engine. + * + * @memberOf Benchmark.platform + * @type String|Null + */ + 'layout': null, + + /** + * The name of the product hosting the browser. + * + * @memberOf Benchmark.platform + * @type String|Null + */ + 'product': null, + + /** + * The name of the browser/environment. + * + * @memberOf Benchmark.platform + * @type String|Null + */ + 'name': null, + + /** + * The name of the product's manufacturer. + * + * @memberOf Benchmark.platform + * @type String|Null + */ + 'manufacturer': null, + + /** + * The name of the operating system. + * + * @memberOf Benchmark.platform + * @type String|Null + */ + 'os': null, + + /** + * The alpha/beta release indicator. + * + * @memberOf Benchmark.platform + * @type String|Null + */ + 'prerelease': null, + + /** + * The browser/environment version. + * + * @memberOf Benchmark.platform + * @type String|Null + */ + 'version': null, + + /** + * Return platform description when the platform object is coerced to a string. + * + * @memberOf Benchmark.platform + * @type Function + * @returns {String} The platform description. + */ + 'toString': function() { + return this.description || ''; + } + }, + + /** + * The semantic version number. + * + * @static + * @memberOf Benchmark + * @type String + */ + 'version': '1.0.0', + + // an object of environment/feature detection flags + 'support': support, + + // clone objects + 'deepClone': deepClone, + + // iteration utility + 'each': each, + + // augment objects + 'extend': extend, + + // generic Array#filter + 'filter': filter, + + // generic Array#forEach + 'forEach': forEach, + + // generic own property iteration utility + 'forOwn': forOwn, + + // converts a number to a comma-separated string + 'formatNumber': formatNumber, + + // generic Object#hasOwnProperty + // (trigger hasKey's lazy define before assigning it to Benchmark) + 'hasKey': (hasKey(Benchmark, ''), hasKey), + + // generic Array#indexOf + 'indexOf': indexOf, + + // template utility + 'interpolate': interpolate, + + // invokes a method on each item in an array + 'invoke': invoke, + + // generic Array#join for arrays and objects + 'join': join, + + // generic Array#map + 'map': map, + + // retrieves a property value from each item in an array + 'pluck': pluck, + + // generic Array#reduce + 'reduce': reduce + }); + + /*--------------------------------------------------------------------------*/ + + extend(Benchmark.prototype, { + + /** + * The number of times a test was executed. + * + * @memberOf Benchmark + * @type Number + */ + 'count': 0, + + /** + * The number of cycles performed while benchmarking. + * + * @memberOf Benchmark + * @type Number + */ + 'cycles': 0, + + /** + * The number of executions per second. + * + * @memberOf Benchmark + * @type Number + */ + 'hz': 0, + + /** + * The compiled test function. + * + * @memberOf Benchmark + * @type Function|String + */ + 'compiled': undefined, + + /** + * The error object if the test failed. + * + * @memberOf Benchmark + * @type Object + */ + 'error': undefined, + + /** + * The test to benchmark. + * + * @memberOf Benchmark + * @type Function|String + */ + 'fn': undefined, + + /** + * A flag to indicate if the benchmark is aborted. + * + * @memberOf Benchmark + * @type Boolean + */ + 'aborted': false, + + /** + * A flag to indicate if the benchmark is running. + * + * @memberOf Benchmark + * @type Boolean + */ + 'running': false, + + /** + * Compiled into the test and executed immediately **before** the test loop. + * + * @memberOf Benchmark + * @type Function|String + * @example + * + * // basic usage + * var bench = Benchmark({ + * 'setup': function() { + * var c = this.count, + * element = document.getElementById('container'); + * while (c--) { + * element.appendChild(document.createElement('div')); + * } + * }, + * 'fn': function() { + * element.removeChild(element.lastChild); + * } + * }); + * + * // compiles to something like: + * var c = this.count, + * element = document.getElementById('container'); + * while (c--) { + * element.appendChild(document.createElement('div')); + * } + * var start = new Date; + * while (count--) { + * element.removeChild(element.lastChild); + * } + * var end = new Date - start; + * + * // or using strings + * var bench = Benchmark({ + * 'setup': '\ + * var a = 0;\n\ + * (function() {\n\ + * (function() {\n\ + * (function() {', + * 'fn': 'a += 1;', + * 'teardown': '\ + * }())\n\ + * }())\n\ + * }())' + * }); + * + * // compiles to something like: + * var a = 0; + * (function() { + * (function() { + * (function() { + * var start = new Date; + * while (count--) { + * a += 1; + * } + * var end = new Date - start; + * }()) + * }()) + * }()) + */ + 'setup': noop, + + /** + * Compiled into the test and executed immediately **after** the test loop. + * + * @memberOf Benchmark + * @type Function|String + */ + 'teardown': noop, + + /** + * An object of stats including mean, margin or error, and standard deviation. + * + * @memberOf Benchmark + * @type Object + */ + 'stats': { + + /** + * The margin of error. + * + * @memberOf Benchmark#stats + * @type Number + */ + 'moe': 0, + + /** + * The relative margin of error (expressed as a percentage of the mean). + * + * @memberOf Benchmark#stats + * @type Number + */ + 'rme': 0, + + /** + * The standard error of the mean. + * + * @memberOf Benchmark#stats + * @type Number + */ + 'sem': 0, + + /** + * The sample standard deviation. + * + * @memberOf Benchmark#stats + * @type Number + */ + 'deviation': 0, + + /** + * The sample arithmetic mean. + * + * @memberOf Benchmark#stats + * @type Number + */ + 'mean': 0, + + /** + * The array of sampled periods. + * + * @memberOf Benchmark#stats + * @type Array + */ + 'sample': [], + + /** + * The sample variance. + * + * @memberOf Benchmark#stats + * @type Number + */ + 'variance': 0 + }, + + /** + * An object of timing data including cycle, elapsed, period, start, and stop. + * + * @memberOf Benchmark + * @type Object + */ + 'times': { + + /** + * The time taken to complete the last cycle (secs). + * + * @memberOf Benchmark#times + * @type Number + */ + 'cycle': 0, + + /** + * The time taken to complete the benchmark (secs). + * + * @memberOf Benchmark#times + * @type Number + */ + 'elapsed': 0, + + /** + * The time taken to execute the test once (secs). + * + * @memberOf Benchmark#times + * @type Number + */ + 'period': 0, + + /** + * A timestamp of when the benchmark started (ms). + * + * @memberOf Benchmark#times + * @type Number + */ + 'timeStamp': 0 + }, + + // aborts benchmark (does not record times) + 'abort': abort, + + // creates a new benchmark using the same test and options + 'clone': clone, + + // compares benchmark's hertz with another + 'compare': compare, + + // executes listeners + 'emit': emit, + + // get listeners + 'listeners': listeners, + + // unregister listeners + 'off': off, + + // register listeners + 'on': on, + + // reset benchmark properties + 'reset': reset, + + // runs the benchmark + 'run': run, + + // pretty print benchmark info + 'toString': toStringBench + }); + + /*--------------------------------------------------------------------------*/ + + extend(Deferred.prototype, { + + /** + * The deferred benchmark instance. + * + * @memberOf Benchmark.Deferred + * @type Object + */ + 'benchmark': null, + + /** + * The number of deferred cycles performed while benchmarking. + * + * @memberOf Benchmark.Deferred + * @type Number + */ + 'cycles': 0, + + /** + * The time taken to complete the deferred benchmark (secs). + * + * @memberOf Benchmark.Deferred + * @type Number + */ + 'elapsed': 0, + + /** + * A timestamp of when the deferred benchmark started (ms). + * + * @memberOf Benchmark.Deferred + * @type Number + */ + 'timeStamp': 0, + + // cycles/completes the deferred benchmark + 'resolve': resolve + }); + + /*--------------------------------------------------------------------------*/ + + extend(Event.prototype, { + + /** + * A flag to indicate if the emitters listener iteration is aborted. + * + * @memberOf Benchmark.Event + * @type Boolean + */ + 'aborted': false, + + /** + * A flag to indicate if the default action is cancelled. + * + * @memberOf Benchmark.Event + * @type Boolean + */ + 'cancelled': false, + + /** + * The object whose listeners are currently being processed. + * + * @memberOf Benchmark.Event + * @type Object + */ + 'currentTarget': undefined, + + /** + * The return value of the last executed listener. + * + * @memberOf Benchmark.Event + * @type Mixed + */ + 'result': undefined, + + /** + * The object to which the event was originally emitted. + * + * @memberOf Benchmark.Event + * @type Object + */ + 'target': undefined, + + /** + * A timestamp of when the event was created (ms). + * + * @memberOf Benchmark.Event + * @type Number + */ + 'timeStamp': 0, + + /** + * The event type. + * + * @memberOf Benchmark.Event + * @type String + */ + 'type': '' + }); + + /*--------------------------------------------------------------------------*/ + + /** + * The default options copied by suite instances. + * + * @static + * @memberOf Benchmark.Suite + * @type Object + */ + Suite.options = { + + /** + * The name of the suite. + * + * @memberOf Benchmark.Suite.options + * @type String + */ + 'name': undefined + }; + + /*--------------------------------------------------------------------------*/ + + extend(Suite.prototype, { + + /** + * The number of benchmarks in the suite. + * + * @memberOf Benchmark.Suite + * @type Number + */ + 'length': 0, + + /** + * A flag to indicate if the suite is aborted. + * + * @memberOf Benchmark.Suite + * @type Boolean + */ + 'aborted': false, + + /** + * A flag to indicate if the suite is running. + * + * @memberOf Benchmark.Suite + * @type Boolean + */ + 'running': false, + + /** + * An `Array#forEach` like method. + * Callbacks may terminate the loop by explicitly returning `false`. + * + * @memberOf Benchmark.Suite + * @param {Function} callback The function called per iteration. + * @returns {Object} The suite iterated over. + */ + 'forEach': methodize(forEach), + + /** + * An `Array#indexOf` like method. + * + * @memberOf Benchmark.Suite + * @param {Mixed} value The value to search for. + * @returns {Number} The index of the matched value or `-1`. + */ + 'indexOf': methodize(indexOf), + + /** + * Invokes a method on all benchmarks in the suite. + * + * @memberOf Benchmark.Suite + * @param {String|Object} name The name of the method to invoke OR options object. + * @param {Mixed} [arg1, arg2, ...] Arguments to invoke the method with. + * @returns {Array} A new array of values returned from each method invoked. + */ + 'invoke': methodize(invoke), + + /** + * Converts the suite of benchmarks to a string. + * + * @memberOf Benchmark.Suite + * @param {String} [separator=','] A string to separate each element of the array. + * @returns {String} The string. + */ + 'join': [].join, + + /** + * An `Array#map` like method. + * + * @memberOf Benchmark.Suite + * @param {Function} callback The function called per iteration. + * @returns {Array} A new array of values returned by the callback. + */ + 'map': methodize(map), + + /** + * Retrieves the value of a specified property from all benchmarks in the suite. + * + * @memberOf Benchmark.Suite + * @param {String} property The property to pluck. + * @returns {Array} A new array of property values. + */ + 'pluck': methodize(pluck), + + /** + * Removes the last benchmark from the suite and returns it. + * + * @memberOf Benchmark.Suite + * @returns {Mixed} The removed benchmark. + */ + 'pop': [].pop, + + /** + * Appends benchmarks to the suite. + * + * @memberOf Benchmark.Suite + * @returns {Number} The suite's new length. + */ + 'push': [].push, + + /** + * Sorts the benchmarks of the suite. + * + * @memberOf Benchmark.Suite + * @param {Function} [compareFn=null] A function that defines the sort order. + * @returns {Object} The sorted suite. + */ + 'sort': [].sort, + + /** + * An `Array#reduce` like method. + * + * @memberOf Benchmark.Suite + * @param {Function} callback The function called per iteration. + * @param {Mixed} accumulator Initial value of the accumulator. + * @returns {Mixed} The accumulator. + */ + 'reduce': methodize(reduce), + + // aborts all benchmarks in the suite + 'abort': abortSuite, + + // adds a benchmark to the suite + 'add': add, + + // creates a new suite with cloned benchmarks + 'clone': cloneSuite, + + // executes listeners of a specified type + 'emit': emit, + + // creates a new suite of filtered benchmarks + 'filter': filterSuite, + + // get listeners + 'listeners': listeners, + + // unregister listeners + 'off': off, + + // register listeners + 'on': on, + + // resets all benchmarks in the suite + 'reset': resetSuite, + + // runs all benchmarks in the suite + 'run': runSuite, + + // array methods + 'concat': concat, + + 'reverse': reverse, + + 'shift': shift, + + 'slice': slice, + + 'splice': splice, + + 'unshift': unshift + }); + + /*--------------------------------------------------------------------------*/ + + // expose Deferred, Event and Suite + extend(Benchmark, { + 'Deferred': Deferred, + 'Event': Event, + 'Suite': Suite + }); + + // expose Benchmark + // some AMD build optimizers, like r.js, check for specific condition patterns like the following: + if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) { + // define as an anonymous module so, through path mapping, it can be aliased + define(function() { + return Benchmark; + }); + } + // check for `exports` after `define` in case a build optimizer adds an `exports` object + else if (freeExports) { + // in Node.js or RingoJS v0.8.0+ + if (typeof module == 'object' && module && module.exports == freeExports) { + (module.exports = Benchmark).Benchmark = Benchmark; + } + // in Narwhal or RingoJS v0.7.0- + else { + freeExports.Benchmark = Benchmark; + } + } + // in a browser or Rhino + else { + // use square bracket notation so Closure Compiler won't munge `Benchmark` + // http://code.google.com/closure/compiler/docs/api-tutorial3.html#export + window['Benchmark'] = Benchmark; + } + + // trigger clock's lazy define early to avoid a security error + if (support.air) { + clock({ '_original': { 'fn': noop, 'count': 1, 'options': {} } }); + } +}(this)); diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/benchmark/doc/README.md b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/benchmark/doc/README.md index e173b997..5b8960a5 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/benchmark/doc/README.md +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/benchmark/doc/README.md @@ -1,2629 +1,2629 @@ -# Benchmark.js v1.0.0 - - - - - - -## `Benchmark` -* [`Benchmark`](#benchmarkname-fn--options) -* [`Benchmark.version`](#benchmarkversion) -* [`Benchmark.deepClone`](#benchmarkdeepclonevalue) -* [`Benchmark.each`](#benchmarkeachobject-callback-thisarg) -* [`Benchmark.extend`](#benchmarkextenddestination--source) -* [`Benchmark.filter`](#benchmarkfilterarray-callback-thisarg) -* [`Benchmark.forEach`](#benchmarkforeacharray-callback-thisarg) -* [`Benchmark.formatNumber`](#benchmarkformatnumbernumber) -* [`Benchmark.forOwn`](#benchmarkforownobject-callback-thisarg) -* [`Benchmark.hasKey`](#benchmarkhaskeyobject-key) -* [`Benchmark.indexOf`](#benchmarkindexofarray-value--fromindex0) -* [`Benchmark.interpolate`](#benchmarkinterpolatestring-object) -* [`Benchmark.invoke`](#benchmarkinvokebenches-name--arg1-arg2-) -* [`Benchmark.join`](#benchmarkjoinobject--separator1--separator2:) -* [`Benchmark.map`](#benchmarkmaparray-callback-thisarg) -* [`Benchmark.pluck`](#benchmarkpluckarray-property) -* [`Benchmark.reduce`](#benchmarkreducearray-callback-accumulator) - - - - - - -## `Benchmark.prototype` -* [`Benchmark.prototype.aborted`](#benchmarkprototypeaborted) -* [`Benchmark.prototype.compiled`](#benchmarkprototypecompiled) -* [`Benchmark.prototype.count`](#benchmarkprototypecount) -* [`Benchmark.prototype.cycles`](#benchmarkprototypecycles) -* [`Benchmark.prototype.fn`](#benchmarkprototypefn) -* [`Benchmark.prototype.hz`](#benchmarkprototypehz) -* [`Benchmark.prototype.running`](#benchmarkprototyperunning) -* [`Benchmark.prototype.setup`](#benchmarkprototypesetup) -* [`Benchmark.prototype.teardown`](#benchmarkprototypeteardown) -* [`Benchmark.prototype.abort`](#benchmarkprototypeabort) -* [`Benchmark.prototype.clone`](#benchmarkprototypecloneoptions) -* [`Benchmark.prototype.compare`](#benchmarkprototypecompareother) -* [`Benchmark.prototype.emit`](#benchmarkprototypeemittype) -* [`Benchmark.prototype.listeners`](#benchmarkprototypelistenerstype) -* [`Benchmark.prototype.off`](#benchmarkprototypeofftype-listener) -* [`Benchmark.prototype.on`](#benchmarkprototypeontype-listener) -* [`Benchmark.prototype.reset`](#benchmarkprototypereset) -* [`Benchmark.prototype.run`](#benchmarkprototyperunoptions) -* [`Benchmark.prototype.toString`](#benchmarkprototypetostring) - - - - - - -## `Benchmark.options` -* [`Benchmark.options`](#benchmarkoptions) -* [`Benchmark.options.async`](#benchmarkoptionsasync) -* [`Benchmark.options.defer`](#benchmarkoptionsdefer) -* [`Benchmark.options.delay`](#benchmarkoptionsdelay) -* [`Benchmark.options.id`](#benchmarkoptionsid) -* [`Benchmark.options.initCount`](#benchmarkoptionsinitcount) -* [`Benchmark.options.maxTime`](#benchmarkoptionsmaxtime) -* [`Benchmark.options.minSamples`](#benchmarkoptionsminsamples) -* [`Benchmark.options.minTime`](#benchmarkoptionsmintime) -* [`Benchmark.options.name`](#benchmarkoptionsname) -* [`Benchmark.options.onAbort`](#benchmarkoptionsonabort) -* [`Benchmark.options.onComplete`](#benchmarkoptionsoncomplete) -* [`Benchmark.options.onCycle`](#benchmarkoptionsoncycle) -* [`Benchmark.options.onError`](#benchmarkoptionsonerror) -* [`Benchmark.options.onReset`](#benchmarkoptionsonreset) -* [`Benchmark.options.onStart`](#benchmarkoptionsonstart) - - - - - - -## `Benchmark.platform` -* [`Benchmark.platform`](#benchmarkplatform) -* [`Benchmark.platform.description`](#benchmarkplatformdescription) -* [`Benchmark.platform.layout`](#benchmarkplatformlayout) -* [`Benchmark.platform.manufacturer`](#benchmarkplatformmanufacturer) -* [`Benchmark.platform.name`](#benchmarkplatformname) -* [`Benchmark.platform.os`](#benchmarkplatformos) -* [`Benchmark.platform.prerelease`](#benchmarkplatformprerelease) -* [`Benchmark.platform.product`](#benchmarkplatformproduct) -* [`Benchmark.platform.version`](#benchmarkplatformversion) -* [`Benchmark.platform.toString`](#benchmarkplatformtostring) - - - - - - -## `Benchmark.support` -* [`Benchmark.support`](#benchmarksupport) -* [`Benchmark.support.air`](#benchmarksupportair) -* [`Benchmark.support.argumentsClass`](#benchmarksupportargumentsclass) -* [`Benchmark.support.browser`](#benchmarksupportbrowser) -* [`Benchmark.support.charByIndex`](#benchmarksupportcharbyindex) -* [`Benchmark.support.charByOwnIndex`](#benchmarksupportcharbyownindex) -* [`Benchmark.support.decompilation`](#benchmarksupportdecompilation) -* [`Benchmark.support.descriptors`](#benchmarksupportdescriptors) -* [`Benchmark.support.getAllKeys`](#benchmarksupportgetallkeys) -* [`Benchmark.support.iteratesOwnLast`](#benchmarksupportiteratesownfirst) -* [`Benchmark.support.java`](#benchmarksupportjava) -* [`Benchmark.support.nodeClass`](#benchmarksupportnodeclass) -* [`Benchmark.support.timeout`](#benchmarksupporttimeout) - - - - - - -## `Benchmark.prototype.error` -* [`Benchmark.prototype.error`](#benchmarkprototypeerror) - - - - - - -## `Benchmark.prototype.stats` -* [`Benchmark.prototype.stats`](#benchmarkprototypestats) -* [`Benchmark.prototype.stats.deviation`](#benchmark-statsdeviation) -* [`Benchmark.prototype.stats.mean`](#benchmark-statsmean) -* [`Benchmark.prototype.stats.moe`](#benchmark-statsmoe) -* [`Benchmark.prototype.stats.rme`](#benchmark-statsrme) -* [`Benchmark.prototype.stats.sample`](#benchmark-statssample) -* [`Benchmark.prototype.stats.sem`](#benchmark-statssem) -* [`Benchmark.prototype.stats.variance`](#benchmark-statsvariance) - - - - - - -## `Benchmark.prototype.times` -* [`Benchmark.prototype.times`](#benchmarkprototypetimes) -* [`Benchmark.prototype.times.cycle`](#benchmark-timescycle) -* [`Benchmark.prototype.times.elapsed`](#benchmark-timeselapsed) -* [`Benchmark.prototype.times.period`](#benchmark-timesperiod) -* [`Benchmark.prototype.times.timeStamp`](#benchmark-timestimestamp) - - - - - - -## `Benchmark.Deferred` -* [`Benchmark.Deferred`](#benchmarkdeferredclone) - - - - - - -## `Benchmark.Deferred.prototype` -* [`Benchmark.Deferred.prototype.benchmark`](#benchmarkdeferredprototypebenchmark) -* [`Benchmark.Deferred.prototype.cycles`](#benchmarkdeferredprototypecycles) -* [`Benchmark.Deferred.prototype.elapsed`](#benchmarkdeferredprototypeelapsed) -* [`Benchmark.Deferred.prototype.resolve`](#benchmarkdeferredprototyperesolve) -* [`Benchmark.Deferred.prototype.timeStamp`](#benchmarkdeferredprototypetimestamp) - - - - - - -## `Benchmark.Event` -* [`Benchmark.Event`](#benchmarkeventtype) - - - - - - -## `Benchmark.Event.prototype` -* [`Benchmark.Event.prototype.aborted`](#benchmarkeventprototypeaborted) -* [`Benchmark.Event.prototype.cancelled`](#benchmarkeventprototypecancelled) -* [`Benchmark.Event.prototype.result`](#benchmarkeventprototyperesult) -* [`Benchmark.Event.prototype.timeStamp`](#benchmarkeventprototypetimestamp) -* [`Benchmark.Event.prototype.type`](#benchmarkeventprototypetype) - - - - - - -## `Benchmark.Event.prototype.currentTarget` -* [`Benchmark.Event.prototype.currentTarget`](#benchmarkeventprototypecurrenttarget) - - - - - - -## `Benchmark.Event.prototype.target` -* [`Benchmark.Event.prototype.target`](#benchmarkeventprototypetarget) - - - - - - -## `Benchmark.Suite` -* [`Benchmark.Suite`](#benchmarksuitename--options) - - - - - - -## `Benchmark.Suite.prototype` -* [`Benchmark.Suite.prototype.aborted`](#benchmarksuiteprototypeaborted) -* [`Benchmark.Suite.prototype.length`](#benchmarksuiteprototypelength) -* [`Benchmark.Suite.prototype.running`](#benchmarksuiteprototyperunning) -* [`Benchmark.Suite.prototype.abort`](#benchmarksuiteprototypeabort) -* [`Benchmark.Suite.prototype.add`](#benchmarksuiteprototypeaddname-fn--options) -* [`Benchmark.Suite.prototype.clone`](#benchmarksuiteprototypecloneoptions) -* [`Benchmark.Suite.prototype.emit`](#benchmarkprototypeemittype) -* [`Benchmark.Suite.prototype.filter`](#benchmarksuiteprototypefiltercallback) -* [`Benchmark.Suite.prototype.forEach`](#benchmarksuiteprototypeforeachcallback) -* [`Benchmark.Suite.prototype.indexOf`](#benchmarksuiteprototypeindexofvalue) -* [`Benchmark.Suite.prototype.invoke`](#benchmarksuiteprototypeinvokename--arg1-arg2-) -* [`Benchmark.Suite.prototype.join`](#benchmarksuiteprototypejoinseparator-) -* [`Benchmark.Suite.prototype.listeners`](#benchmarkprototypelistenerstype) -* [`Benchmark.Suite.prototype.map`](#benchmarksuiteprototypemapcallback) -* [`Benchmark.Suite.prototype.off`](#benchmarkprototypeofftype-listener) -* [`Benchmark.Suite.prototype.on`](#benchmarkprototypeontype-listener) -* [`Benchmark.Suite.prototype.pluck`](#benchmarksuiteprototypepluckproperty) -* [`Benchmark.Suite.prototype.pop`](#benchmarksuiteprototypepop) -* [`Benchmark.Suite.prototype.push`](#benchmarksuiteprototypepush) -* [`Benchmark.Suite.prototype.reduce`](#benchmarksuiteprototypereducecallback-accumulator) -* [`Benchmark.Suite.prototype.reset`](#benchmarksuiteprototypereset) -* [`Benchmark.Suite.prototype.reverse`](#benchmarksuiteprototypereverse) -* [`Benchmark.Suite.prototype.run`](#benchmarksuiteprototyperunoptions) -* [`Benchmark.Suite.prototype.shift`](#benchmarksuiteprototypeshift) -* [`Benchmark.Suite.prototype.slice`](#benchmarksuiteprototypeslicestart-end) -* [`Benchmark.Suite.prototype.sort`](#benchmarksuiteprototypesortcomparefnnull) -* [`Benchmark.Suite.prototype.splice`](#benchmarksuiteprototypesplicestart-deletecount--val1-val2-) -* [`Benchmark.Suite.prototype.unshift`](#benchmarksuiteprototypeunshift) - - - - - - -## `Benchmark.Suite.options` -* [`Benchmark.Suite.options`](#benchmarksuiteoptions) -* [`Benchmark.Suite.options.name`](#benchmarksuiteoptionsname) - - - - - - - - - - - - -## `Benchmark` - - - -### `Benchmark(name, fn [, options={}])` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L404 "View in source") [Ⓣ][1] - -The Benchmark constructor. - -#### Arguments -1. `name` *(String)*: A name to identify the benchmark. -2. `fn` *(Function|String)*: The test to benchmark. -3. `[options={}]` *(Object)*: Options object. - -#### Example -~~~ js -// basic usage (the `new` operator is optional) -var bench = new Benchmark(fn); - -// or using a name first -var bench = new Benchmark('foo', fn); - -// or with options -var bench = new Benchmark('foo', fn, { - - // displayed by Benchmark#toString if `name` is not available - 'id': 'xyz', - - // called when the benchmark starts running - 'onStart': onStart, - - // called after each run cycle - 'onCycle': onCycle, - - // called when aborted - 'onAbort': onAbort, - - // called when a test errors - 'onError': onError, - - // called when reset - 'onReset': onReset, - - // called when the benchmark completes running - 'onComplete': onComplete, - - // compiled/called before the test loop - 'setup': setup, - - // compiled/called after the test loop - 'teardown': teardown -}); - -// or name and options -var bench = new Benchmark('foo', { - - // a flag to indicate the benchmark is deferred - 'defer': true, - - // benchmark test function - 'fn': function(deferred) { - // call resolve() when the deferred test is finished - deferred.resolve(); - } -}); - -// or options only -var bench = new Benchmark({ - - // benchmark name - 'name': 'foo', - - // benchmark test as a string - 'fn': '[1,2,3,4].sort()' -}); - -// a test's `this` binding is set to the benchmark instance -var bench = new Benchmark('foo', function() { - 'My name is '.concat(this.name); // My name is foo -}); -~~~ - -* * * - - - - - - -### `Benchmark.version` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3267 "View in source") [Ⓣ][1] - -*(String)*: The semantic version number. - -* * * - - - - - - -### `Benchmark.deepClone(value)` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1225 "View in source") [Ⓣ][1] - -A deep clone utility. - -#### Arguments -1. `value` *(Mixed)*: The value to clone. - -#### Returns -*(Mixed)*: The cloned value. - -* * * - - - - - - -### `Benchmark.each(object, callback, thisArg)` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1400 "View in source") [Ⓣ][1] - -An iteration utility for arrays and objects. Callbacks may terminate the loop by explicitly returning `false`. - -#### Arguments -1. `object` *(Array|Object)*: The object to iterate over. -2. `callback` *(Function)*: The function called per iteration. -3. `thisArg` *(Mixed)*: The `this` binding for the callback. - -#### Returns -*(Array, Object)*: Returns the object iterated over. - -* * * - - - - - - -### `Benchmark.extend(destination [, source={}])` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1446 "View in source") [Ⓣ][1] - -Copies enumerable properties from the source(s) object to the destination object. - -#### Arguments -1. `destination` *(Object)*: The destination object. -2. `[source={}]` *(Object)*: The source object. - -#### Returns -*(Object)*: The destination object. - -* * * - - - - - - -### `Benchmark.filter(array, callback, thisArg)` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1485 "View in source") [Ⓣ][1] - -A generic `Array#filter` like method. - -#### Arguments -1. `array` *(Array)*: The array to iterate over. -2. `callback` *(Function|String)*: The function/alias called per iteration. -3. `thisArg` *(Mixed)*: The `this` binding for the callback. - -#### Returns -*(Array)*: A new array of values that passed callback filter. - -#### Example -~~~ js -// get odd numbers -Benchmark.filter([1, 2, 3, 4, 5], function(n) { - return n % 2; -}); // -> [1, 3, 5]; - -// get fastest benchmarks -Benchmark.filter(benches, 'fastest'); - -// get slowest benchmarks -Benchmark.filter(benches, 'slowest'); - -// get benchmarks that completed without erroring -Benchmark.filter(benches, 'successful'); -~~~ - -* * * - - - - - - -### `Benchmark.forEach(array, callback, thisArg)` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1518 "View in source") [Ⓣ][1] - -A generic `Array#forEach` like method. Callbacks may terminate the loop by explicitly returning `false`. - -#### Arguments -1. `array` *(Array)*: The array to iterate over. -2. `callback` *(Function)*: The function called per iteration. -3. `thisArg` *(Mixed)*: The `this` binding for the callback. - -#### Returns -*(Array)*: Returns the array iterated over. - -* * * - - - - - - -### `Benchmark.formatNumber(number)` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1557 "View in source") [Ⓣ][1] - -Converts a number to a more readable comma-separated string representation. - -#### Arguments -1. `number` *(Number)*: The number to convert. - -#### Returns -*(String)*: The more readable string representation. - -* * * - - - - - - -### `Benchmark.forOwn(object, callback, thisArg)` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1545 "View in source") [Ⓣ][1] - -Iterates over an object's own properties, executing the `callback` for each. Callbacks may terminate the loop by explicitly returning `false`. - -#### Arguments -1. `object` *(Object)*: The object to iterate over. -2. `callback` *(Function)*: The function executed per own property. -3. `thisArg` *(Mixed)*: The `this` binding for the callback. - -#### Returns -*(Object)*: Returns the object iterated over. - -* * * - - - - - - -### `Benchmark.hasKey(object, key)` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1572 "View in source") [Ⓣ][1] - -Checks if an object has the specified key as a direct property. - -#### Arguments -1. `object` *(Object)*: The object to check. -2. `key` *(String)*: The key to check for. - -#### Returns -*(Boolean)*: Returns `true` if key is a direct property, else `false`. - -* * * - - - - - - -### `Benchmark.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1608 "View in source") [Ⓣ][1] - -A generic `Array#indexOf` like method. - -#### Arguments -1. `array` *(Array)*: The array to iterate over. -2. `value` *(Mixed)*: The value to search for. -3. `[fromIndex=0]` *(Number)*: The index to start searching from. - -#### Returns -*(Number)*: The index of the matched value or `-1`. - -* * * - - - - - - -### `Benchmark.interpolate(string, object)` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1630 "View in source") [Ⓣ][1] - -Modify a string by replacing named tokens with matching object property values. - -#### Arguments -1. `string` *(String)*: The string to modify. -2. `object` *(Object)*: The template object. - -#### Returns -*(String)*: The modified string. - -* * * - - - - - - -### `Benchmark.invoke(benches, name [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1677 "View in source") [Ⓣ][1] - -Invokes a method on all items in an array. - -#### Arguments -1. `benches` *(Array)*: Array of benchmarks to iterate over. -2. `name` *(String|Object)*: The name of the method to invoke OR options object. -3. `[arg1, arg2, ...]` *(Mixed)*: Arguments to invoke the method with. - -#### Returns -*(Array)*: A new array of values returned from each method invoked. - -#### Example -~~~ js -// invoke `reset` on all benchmarks -Benchmark.invoke(benches, 'reset'); - -// invoke `emit` with arguments -Benchmark.invoke(benches, 'emit', 'complete', listener); - -// invoke `run(true)`, treat benchmarks as a queue, and register invoke callbacks -Benchmark.invoke(benches, { - - // invoke the `run` method - 'name': 'run', - - // pass a single argument - 'args': true, - - // treat as queue, removing benchmarks from front of `benches` until empty - 'queued': true, - - // called before any benchmarks have been invoked. - 'onStart': onStart, - - // called between invoking benchmarks - 'onCycle': onCycle, - - // called after all benchmarks have been invoked. - 'onComplete': onComplete -}); -~~~ - -* * * - - - - - - -### `Benchmark.join(object [, separator1=',', separator2=': '])` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1831 "View in source") [Ⓣ][1] - -Creates a string of joined array values or object key-value pairs. - -#### Arguments -1. `object` *(Array|Object)*: The object to operate on. -2. `[separator1=',']` *(String)*: The separator used between key-value pairs. -3. `[separator2=': ']` *(String)*: The separator used between keys and values. - -#### Returns -*(String)*: The joined result. - -* * * - - - - - - -### `Benchmark.map(array, callback, thisArg)` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1853 "View in source") [Ⓣ][1] - -A generic `Array#map` like method. - -#### Arguments -1. `array` *(Array)*: The array to iterate over. -2. `callback` *(Function)*: The function called per iteration. -3. `thisArg` *(Mixed)*: The `this` binding for the callback. - -#### Returns -*(Array)*: A new array of values returned by the callback. - -* * * - - - - - - -### `Benchmark.pluck(array, property)` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1869 "View in source") [Ⓣ][1] - -Retrieves the value of a specified property from all items in an array. - -#### Arguments -1. `array` *(Array)*: The array to iterate over. -2. `property` *(String)*: The property to pluck. - -#### Returns -*(Array)*: A new array of property values. - -* * * - - - - - - -### `Benchmark.reduce(array, callback, accumulator)` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1885 "View in source") [Ⓣ][1] - -A generic `Array#reduce` like method. - -#### Arguments -1. `array` *(Array)*: The array to iterate over. -2. `callback` *(Function)*: The function called per iteration. -3. `accumulator` *(Mixed)*: Initial value of the accumulator. - -#### Returns -*(Mixed)*: The accumulator. - -* * * - - - - - - - - - -## `Benchmark.prototype` - - - -### `Benchmark.prototype.aborted` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3377 "View in source") [Ⓣ][1] - -*(Boolean)*: A flag to indicate if the benchmark is aborted. - -* * * - - - - - - -### `Benchmark.prototype.compiled` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3353 "View in source") [Ⓣ][1] - -*(Function, String)*: The compiled test function. - -* * * - - - - - - -### `Benchmark.prototype.count` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3329 "View in source") [Ⓣ][1] - -*(Number)*: The number of times a test was executed. - -* * * - - - - - - -### `Benchmark.prototype.cycles` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3337 "View in source") [Ⓣ][1] - -*(Number)*: The number of cycles performed while benchmarking. - -* * * - - - - - - -### `Benchmark.prototype.fn` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3369 "View in source") [Ⓣ][1] - -*(Function, String)*: The test to benchmark. - -* * * - - - - - - -### `Benchmark.prototype.hz` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3345 "View in source") [Ⓣ][1] - -*(Number)*: The number of executions per second. - -* * * - - - - - - -### `Benchmark.prototype.running` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3385 "View in source") [Ⓣ][1] - -*(Boolean)*: A flag to indicate if the benchmark is running. - -* * * - - - - - - -### `Benchmark.prototype.setup` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3448 "View in source") [Ⓣ][1] - -*(Function, String)*: Compiled into the test and executed immediately **before** the test loop. - -#### Example -~~~ js -// basic usage -var bench = Benchmark({ - 'setup': function() { - var c = this.count, - element = document.getElementById('container'); - while (c--) { - element.appendChild(document.createElement('div')); - } - }, - 'fn': function() { - element.removeChild(element.lastChild); - } -}); - -// compiles to something like: -var c = this.count, - element = document.getElementById('container'); -while (c--) { - element.appendChild(document.createElement('div')); -} -var start = new Date; -while (count--) { - element.removeChild(element.lastChild); -} -var end = new Date - start; - -// or using strings -var bench = Benchmark({ - 'setup': '\ - var a = 0;\n\ - (function() {\n\ - (function() {\n\ - (function() {', - 'fn': 'a += 1;', - 'teardown': '\ - }())\n\ - }())\n\ - }())' -}); - -// compiles to something like: -var a = 0; -(function() { - (function() { - (function() { - var start = new Date; - while (count--) { - a += 1; - } - var end = new Date - start; - }()) - }()) -}()) -~~~ - -* * * - - - - - - -### `Benchmark.prototype.teardown` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3456 "View in source") [Ⓣ][1] - -*(Function, String)*: Compiled into the test and executed immediately **after** the test loop. - -* * * - - - - - - -### `Benchmark.prototype.abort()` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2218 "View in source") [Ⓣ][1] - -Aborts the benchmark without recording times. - -#### Returns -*(Object)*: The benchmark instance. - -* * * - - - - - - -### `Benchmark.prototype.clone(options)` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2257 "View in source") [Ⓣ][1] - -Creates a new benchmark using the same test and options. - -#### Arguments -1. `options` *(Object)*: Options object to overwrite cloned options. - -#### Returns -*(Object)*: The new benchmark instance. - -#### Example -~~~ js -var bizarro = bench.clone({ - 'name': 'doppelganger' -}); -~~~ - -* * * - - - - - - -### `Benchmark.prototype.compare(other)` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2280 "View in source") [Ⓣ][1] - -Determines if a benchmark is faster than another. - -#### Arguments -1. `other` *(Object)*: The benchmark to compare. - -#### Returns -*(Number)*: Returns `-1` if slower, `1` if faster, and `0` if indeterminate. - -* * * - - - - - - -### `Benchmark.Suite.prototype.emit(type)` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2095 "View in source") [Ⓣ][1] - -Executes all registered listeners of the specified event type. - -#### Arguments -1. `type` *(String|Object)*: The event type or object. - -#### Returns -*(Mixed)*: Returns the return value of the last listener executed. - -* * * - - - - - - -### `Benchmark.Suite.prototype.listeners(type)` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2125 "View in source") [Ⓣ][1] - -Returns an array of event listeners for a given type that can be manipulated to add or remove listeners. - -#### Arguments -1. `type` *(String)*: The event type. - -#### Returns -*(Array)*: The listeners array. - -* * * - - - - - - -### `Benchmark.Suite.prototype.off([type, listener])` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2158 "View in source") [Ⓣ][1] - -Unregisters a listener for the specified event type(s), or unregisters all listeners for the specified event type(s), or unregisters all listeners for all event types. - -#### Arguments -1. `[type]` *(String)*: The event type. -2. `[listener]` *(Function)*: The function to unregister. - -#### Returns -*(Object)*: The benchmark instance. - -#### Example -~~~ js -// unregister a listener for an event type -bench.off('cycle', listener); - -// unregister a listener for multiple event types -bench.off('start cycle', listener); - -// unregister all listeners for an event type -bench.off('cycle'); - -// unregister all listeners for multiple event types -bench.off('start cycle complete'); - -// unregister all listeners for all event types -bench.off(); -~~~ - -* * * - - - - - - -### `Benchmark.Suite.prototype.on(type, listener)` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2197 "View in source") [Ⓣ][1] - -Registers a listener for the specified event type(s). - -#### Arguments -1. `type` *(String)*: The event type. -2. `listener` *(Function)*: The function to register. - -#### Returns -*(Object)*: The benchmark instance. - -#### Example -~~~ js -// register a listener for an event type -bench.on('cycle', listener); - -// register a listener for multiple event types -bench.on('start cycle', listener); -~~~ - -* * * - - - - - - -### `Benchmark.prototype.reset()` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2334 "View in source") [Ⓣ][1] - -Reset properties and abort if running. - -#### Returns -*(Object)*: The benchmark instance. - -* * * - - - - - - -### `Benchmark.prototype.run([options={}])` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3000 "View in source") [Ⓣ][1] - -Runs the benchmark. - -#### Arguments -1. `[options={}]` *(Object)*: Options object. - -#### Returns -*(Object)*: The benchmark instance. - -#### Example -~~~ js -// basic usage -bench.run(); - -// or with options -bench.run({ 'async': true }); -~~~ - -* * * - - - - - - -### `Benchmark.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2405 "View in source") [Ⓣ][1] - -Displays relevant benchmark information when coerced to a string. - -#### Returns -*(String)*: A string representation of the benchmark instance. - -* * * - - - - - - - - - -## `Benchmark.options` - - - -### `Benchmark.options` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3049 "View in source") [Ⓣ][1] - -*(Object)*: The default options copied by benchmark instances. - -* * * - - - - - - -### `Benchmark.options.async` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3058 "View in source") [Ⓣ][1] - -*(Boolean)*: A flag to indicate that benchmark cycles will execute asynchronously by default. - -* * * - - - - - - -### `Benchmark.options.defer` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3066 "View in source") [Ⓣ][1] - -*(Boolean)*: A flag to indicate that the benchmark clock is deferred. - -* * * - - - - - - -### `Benchmark.options.delay` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3073 "View in source") [Ⓣ][1] - -*(Number)*: The delay between test cycles *(secs)*. - -* * * - - - - - - -### `Benchmark.options.id` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3082 "View in source") [Ⓣ][1] - -*(String)*: Displayed by Benchmark#toString when a `name` is not available *(auto-generated if absent)*. - -* * * - - - - - - -### `Benchmark.options.initCount` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3090 "View in source") [Ⓣ][1] - -*(Number)*: The default number of times to execute a test on a benchmark's first cycle. - -* * * - - - - - - -### `Benchmark.options.maxTime` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3099 "View in source") [Ⓣ][1] - -*(Number)*: The maximum time a benchmark is allowed to run before finishing *(secs)*. Note: Cycle delays aren't counted toward the maximum time. - -* * * - - - - - - -### `Benchmark.options.minSamples` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3107 "View in source") [Ⓣ][1] - -*(Number)*: The minimum sample size required to perform statistical analysis. - -* * * - - - - - - -### `Benchmark.options.minTime` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3115 "View in source") [Ⓣ][1] - -*(Number)*: The time needed to reduce the percent uncertainty of measurement to `1`% *(secs)*. - -* * * - - - - - - -### `Benchmark.options.name` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3123 "View in source") [Ⓣ][1] - -*(String)*: The name of the benchmark. - -* * * - - - - - - -### `Benchmark.options.onAbort` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3131 "View in source") [Ⓣ][1] - -An event listener called when the benchmark is aborted. - -* * * - - - - - - -### `Benchmark.options.onComplete` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3139 "View in source") [Ⓣ][1] - -An event listener called when the benchmark completes running. - -* * * - - - - - - -### `Benchmark.options.onCycle` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3147 "View in source") [Ⓣ][1] - -An event listener called after each run cycle. - -* * * - - - - - - -### `Benchmark.options.onError` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3155 "View in source") [Ⓣ][1] - -An event listener called when a test errors. - -* * * - - - - - - -### `Benchmark.options.onReset` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3163 "View in source") [Ⓣ][1] - -An event listener called when the benchmark is reset. - -* * * - - - - - - -### `Benchmark.options.onStart` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3171 "View in source") [Ⓣ][1] - -An event listener called when the benchmark starts running. - -* * * - - - - - - - - - -## `Benchmark.platform` - - - -### `Benchmark.platform` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3182 "View in source") [Ⓣ][1] - -*(Object)*: Platform object with properties describing things like browser name, version, and operating system. - -* * * - - - - - - -### `Benchmark.platform.description` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3190 "View in source") [Ⓣ][1] - -*(String)*: The platform description. - -* * * - - - - - - -### `Benchmark.platform.layout` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3198 "View in source") [Ⓣ][1] - -*(String, Null)*: The name of the browser layout engine. - -* * * - - - - - - -### `Benchmark.platform.manufacturer` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3222 "View in source") [Ⓣ][1] - -*(String, Null)*: The name of the product's manufacturer. - -* * * - - - - - - -### `Benchmark.platform.name` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3214 "View in source") [Ⓣ][1] - -*(String, Null)*: The name of the browser/environment. - -* * * - - - - - - -### `Benchmark.platform.os` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3230 "View in source") [Ⓣ][1] - -*(String, Null)*: The name of the operating system. - -* * * - - - - - - -### `Benchmark.platform.prerelease` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3238 "View in source") [Ⓣ][1] - -*(String, Null)*: The alpha/beta release indicator. - -* * * - - - - - - -### `Benchmark.platform.product` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3206 "View in source") [Ⓣ][1] - -*(String, Null)*: The name of the product hosting the browser. - -* * * - - - - - - -### `Benchmark.platform.version` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3246 "View in source") [Ⓣ][1] - -*(String, Null)*: The browser/environment version. - -* * * - - - - - - -### `Benchmark.platform.toString()` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3255 "View in source") [Ⓣ][1] - -Return platform description when the platform object is coerced to a string. - -#### Returns -*(String)*: The platform description. - -* * * - - - - - - - - - -## `Benchmark.support` - - - -### `Benchmark.support` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L135 "View in source") [Ⓣ][1] - -*(Object)*: An object used to flag environments/features. - -* * * - - - - - - -### `Benchmark.support.air` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L145 "View in source") [Ⓣ][1] - -*(Boolean)*: Detect Adobe AIR. - -* * * - - - - - - -### `Benchmark.support.argumentsClass` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L153 "View in source") [Ⓣ][1] - -*(Boolean)*: Detect if `arguments` objects have the correct internal [[Class]] value. - -* * * - - - - - - -### `Benchmark.support.browser` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L161 "View in source") [Ⓣ][1] - -*(Boolean)*: Detect if in a browser environment. - -* * * - - - - - - -### `Benchmark.support.charByIndex` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L169 "View in source") [Ⓣ][1] - -*(Boolean)*: Detect if strings support accessing characters by index. - -* * * - - - - - - -### `Benchmark.support.charByOwnIndex` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L179 "View in source") [Ⓣ][1] - -*(Boolean)*: Detect if strings have indexes as own properties. - -* * * - - - - - - -### `Benchmark.support.decompilation` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L207 "View in source") [Ⓣ][1] - -*(Boolean)*: Detect if functions support decompilation. - -* * * - - - - - - -### `Benchmark.support.descriptors` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L228 "View in source") [Ⓣ][1] - -*(Boolean)*: Detect ES5+ property descriptor API. - -* * * - - - - - - -### `Benchmark.support.getAllKeys` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L242 "View in source") [Ⓣ][1] - -*(Boolean)*: Detect ES5+ Object.getOwnPropertyNames(). - -* * * - - - - - - -### `Benchmark.support.iteratesOwnFirst` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L255 "View in source") [Ⓣ][1] - -*(Boolean)*: Detect if own properties are iterated before inherited properties *(all but IE < `9`)*. - -* * * - - - - - - -### `Benchmark.support.java` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L190 "View in source") [Ⓣ][1] - -*(Boolean)*: Detect if Java is enabled/exposed. - -* * * - - - - - - -### `Benchmark.support.nodeClass` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L272 "View in source") [Ⓣ][1] - -*(Boolean)*: Detect if a node's [[Class]] is resolvable *(all but IE < `9`)* and that the JS engine errors when attempting to coerce an object to a string without a `toString` property value of `typeof` "function". - -* * * - - - - - - -### `Benchmark.support.timeout` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L198 "View in source") [Ⓣ][1] - -*(Boolean)*: Detect if the Timers API exists. - -* * * - - - - - - - - - -## `Benchmark.prototype.error` - - - -### `Benchmark.prototype.error` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3361 "View in source") [Ⓣ][1] - -*(Object)*: The error object if the test failed. - -* * * - - - - - - - - - -## `Benchmark.prototype.stats` - - - -### `Benchmark.prototype.stats` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3464 "View in source") [Ⓣ][1] - -*(Object)*: An object of stats including mean, margin or error, and standard deviation. - -* * * - - - - - - -### `Benchmark.prototype.stats.deviation` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3496 "View in source") [Ⓣ][1] - -*(Number)*: The sample standard deviation. - -* * * - - - - - - -### `Benchmark.prototype.stats.mean` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3504 "View in source") [Ⓣ][1] - -*(Number)*: The sample arithmetic mean. - -* * * - - - - - - -### `Benchmark.prototype.stats.moe` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3472 "View in source") [Ⓣ][1] - -*(Number)*: The margin of error. - -* * * - - - - - - -### `Benchmark.prototype.stats.rme` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3480 "View in source") [Ⓣ][1] - -*(Number)*: The relative margin of error *(expressed as a percentage of the mean)*. - -* * * - - - - - - -### `Benchmark.prototype.stats.sample` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3512 "View in source") [Ⓣ][1] - -*(Array)*: The array of sampled periods. - -* * * - - - - - - -### `Benchmark.prototype.stats.sem` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3488 "View in source") [Ⓣ][1] - -*(Number)*: The standard error of the mean. - -* * * - - - - - - -### `Benchmark.prototype.stats.variance` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3520 "View in source") [Ⓣ][1] - -*(Number)*: The sample variance. - -* * * - - - - - - - - - -## `Benchmark.prototype.times` - - - -### `Benchmark.prototype.times` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3529 "View in source") [Ⓣ][1] - -*(Object)*: An object of timing data including cycle, elapsed, period, start, and stop. - -* * * - - - - - - -### `Benchmark.prototype.times.cycle` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3537 "View in source") [Ⓣ][1] - -*(Number)*: The time taken to complete the last cycle *(secs)*. - -* * * - - - - - - -### `Benchmark.prototype.times.elapsed` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3545 "View in source") [Ⓣ][1] - -*(Number)*: The time taken to complete the benchmark *(secs)*. - -* * * - - - - - - -### `Benchmark.prototype.times.period` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3553 "View in source") [Ⓣ][1] - -*(Number)*: The time taken to execute the test once *(secs)*. - -* * * - - - - - - -### `Benchmark.prototype.times.timeStamp` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3561 "View in source") [Ⓣ][1] - -*(Number)*: A timestamp of when the benchmark started *(ms)*. - -* * * - - - - - - - - - -## `Benchmark.Deferred` - - - -### `Benchmark.Deferred(clone)` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L445 "View in source") [Ⓣ][1] - -The Deferred constructor. - -#### Arguments -1. `clone` *(Object)*: The cloned benchmark instance. - -* * * - - - - - - - - - -## `Benchmark.Deferred.prototype` - - - -### `Benchmark.Deferred.prototype.benchmark` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3605 "View in source") [Ⓣ][1] - -*(Object)*: The deferred benchmark instance. - -* * * - - - - - - -### `Benchmark.Deferred.prototype.cycles` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3613 "View in source") [Ⓣ][1] - -*(Number)*: The number of deferred cycles performed while benchmarking. - -* * * - - - - - - -### `Benchmark.Deferred.prototype.elapsed` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3621 "View in source") [Ⓣ][1] - -*(Number)*: The time taken to complete the deferred benchmark *(secs)*. - -* * * - - - - - - -### `Benchmark.Deferred.prototype.resolve` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1188 "View in source") [Ⓣ][1] - -*(Unknown)*: Handles cycling/completing the deferred benchmark. - -* * * - - - - - - -### `Benchmark.Deferred.prototype.timeStamp` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3629 "View in source") [Ⓣ][1] - -*(Number)*: A timestamp of when the deferred benchmark started *(ms)*. - -* * * - - - - - - - - - -## `Benchmark.Event` - - - -### `Benchmark.Event(type)` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L461 "View in source") [Ⓣ][1] - -The Event constructor. - -#### Arguments -1. `type` *(String|Object)*: The event type. - -* * * - - - - - - - - - -## `Benchmark.Event.prototype` - - - -### `Benchmark.Event.prototype.aborted` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3645 "View in source") [Ⓣ][1] - -*(Boolean)*: A flag to indicate if the emitters listener iteration is aborted. - -* * * - - - - - - -### `Benchmark.Event.prototype.cancelled` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3653 "View in source") [Ⓣ][1] - -*(Boolean)*: A flag to indicate if the default action is cancelled. - -* * * - - - - - - -### `Benchmark.Event.prototype.result` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3669 "View in source") [Ⓣ][1] - -*(Mixed)*: The return value of the last executed listener. - -* * * - - - - - - -### `Benchmark.Event.prototype.timeStamp` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3685 "View in source") [Ⓣ][1] - -*(Number)*: A timestamp of when the event was created *(ms)*. - -* * * - - - - - - -### `Benchmark.Event.prototype.type` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3693 "View in source") [Ⓣ][1] - -*(String)*: The event type. - -* * * - - - - - - - - - -## `Benchmark.Event.prototype.currentTarget` - - - -### `Benchmark.Event.prototype.currentTarget` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3661 "View in source") [Ⓣ][1] - -*(Object)*: The object whose listeners are currently being processed. - -* * * - - - - - - - - - -## `Benchmark.Event.prototype.target` - - - -### `Benchmark.Event.prototype.target` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3677 "View in source") [Ⓣ][1] - -*(Object)*: The object to which the event was originally emitted. - -* * * - - - - - - - - - -## `Benchmark.Suite` - - - -### `Benchmark.Suite(name [, options={}])` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L507 "View in source") [Ⓣ][1] - -The Suite constructor. - -#### Arguments -1. `name` *(String)*: A name to identify the suite. -2. `[options={}]` *(Object)*: Options object. - -#### Example -~~~ js -// basic usage (the `new` operator is optional) -var suite = new Benchmark.Suite; - -// or using a name first -var suite = new Benchmark.Suite('foo'); - -// or with options -var suite = new Benchmark.Suite('foo', { - - // called when the suite starts running - 'onStart': onStart, - - // called between running benchmarks - 'onCycle': onCycle, - - // called when aborted - 'onAbort': onAbort, - - // called when a test errors - 'onError': onError, - - // called when reset - 'onReset': onReset, - - // called when the suite completes running - 'onComplete': onComplete -}); -~~~ - -* * * - - - - - - - - - -## `Benchmark.Suite.prototype` - - - -### `Benchmark.Suite.prototype.aborted` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3734 "View in source") [Ⓣ][1] - -*(Boolean)*: A flag to indicate if the suite is aborted. - -* * * - - - - - - -### `Benchmark.Suite.prototype.length` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3726 "View in source") [Ⓣ][1] - -*(Number)*: The number of benchmarks in the suite. - -* * * - - - - - - -### `Benchmark.Suite.prototype.running` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3742 "View in source") [Ⓣ][1] - -*(Boolean)*: A flag to indicate if the suite is running. - -* * * - - - - - - -### `Benchmark.Suite.prototype.abort()` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1902 "View in source") [Ⓣ][1] - -Aborts all benchmarks in the suite. - -#### Returns -*(Object)*: The suite instance. - -* * * - - - - - - -### `Benchmark.Suite.prototype.add(name, fn [, options={}])` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1962 "View in source") [Ⓣ][1] - -Adds a test to the benchmark suite. - -#### Arguments -1. `name` *(String)*: A name to identify the benchmark. -2. `fn` *(Function|String)*: The test to benchmark. -3. `[options={}]` *(Object)*: Options object. - -#### Returns -*(Object)*: The benchmark instance. - -#### Example -~~~ js -// basic usage -suite.add(fn); - -// or using a name first -suite.add('foo', fn); - -// or with options -suite.add('foo', fn, { - 'onCycle': onCycle, - 'onComplete': onComplete -}); - -// or name and options -suite.add('foo', { - 'fn': fn, - 'onCycle': onCycle, - 'onComplete': onComplete -}); - -// or options only -suite.add({ - 'name': 'foo', - 'fn': fn, - 'onCycle': onCycle, - 'onComplete': onComplete -}); -~~~ - -* * * - - - - - - -### `Benchmark.Suite.prototype.clone(options)` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1981 "View in source") [Ⓣ][1] - -Creates a new suite with cloned benchmarks. - -#### Arguments -1. `options` *(Object)*: Options object to overwrite cloned options. - -#### Returns -*(Object)*: The new suite instance. - -* * * - - - - - - -### `Benchmark.Suite.prototype.emit(type)` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2095 "View in source") [Ⓣ][1] - -Executes all registered listeners of the specified event type. - -#### Arguments -1. `type` *(String|Object)*: The event type or object. - -#### Returns -*(Mixed)*: Returns the return value of the last listener executed. - -* * * - - - - - - -### `Benchmark.Suite.prototype.filter(callback)` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2004 "View in source") [Ⓣ][1] - -An `Array#filter` like method. - -#### Arguments -1. `callback` *(Function|String)*: The function/alias called per iteration. - -#### Returns -*(Object)*: A new suite of benchmarks that passed callback filter. - -* * * - - - - - - -### `Benchmark.Suite.prototype.forEach(callback)` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3752 "View in source") [Ⓣ][1] - -An `Array#forEach` like method. Callbacks may terminate the loop by explicitly returning `false`. - -#### Arguments -1. `callback` *(Function)*: The function called per iteration. - -#### Returns -*(Object)*: The suite iterated over. - -* * * - - - - - - -### `Benchmark.Suite.prototype.indexOf(value)` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3761 "View in source") [Ⓣ][1] - -An `Array#indexOf` like method. - -#### Arguments -1. `value` *(Mixed)*: The value to search for. - -#### Returns -*(Number)*: The index of the matched value or `-1`. - -* * * - - - - - - -### `Benchmark.Suite.prototype.invoke(name [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3771 "View in source") [Ⓣ][1] - -Invokes a method on all benchmarks in the suite. - -#### Arguments -1. `name` *(String|Object)*: The name of the method to invoke OR options object. -2. `[arg1, arg2, ...]` *(Mixed)*: Arguments to invoke the method with. - -#### Returns -*(Array)*: A new array of values returned from each method invoked. - -* * * - - - - - - -### `Benchmark.Suite.prototype.join([separator=','])` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3780 "View in source") [Ⓣ][1] - -Converts the suite of benchmarks to a string. - -#### Arguments -1. `[separator=',']` *(String)*: A string to separate each element of the array. - -#### Returns -*(String)*: The string. - -* * * - - - - - - -### `Benchmark.Suite.prototype.listeners(type)` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2125 "View in source") [Ⓣ][1] - -Returns an array of event listeners for a given type that can be manipulated to add or remove listeners. - -#### Arguments -1. `type` *(String)*: The event type. - -#### Returns -*(Array)*: The listeners array. - -* * * - - - - - - -### `Benchmark.Suite.prototype.map(callback)` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3789 "View in source") [Ⓣ][1] - -An `Array#map` like method. - -#### Arguments -1. `callback` *(Function)*: The function called per iteration. - -#### Returns -*(Array)*: A new array of values returned by the callback. - -* * * - - - - - - -### `Benchmark.Suite.prototype.off([type, listener])` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2158 "View in source") [Ⓣ][1] - -Unregisters a listener for the specified event type(s), or unregisters all listeners for the specified event type(s), or unregisters all listeners for all event types. - -#### Arguments -1. `[type]` *(String)*: The event type. -2. `[listener]` *(Function)*: The function to unregister. - -#### Returns -*(Object)*: The benchmark instance. - -#### Example -~~~ js -// unregister a listener for an event type -bench.off('cycle', listener); - -// unregister a listener for multiple event types -bench.off('start cycle', listener); - -// unregister all listeners for an event type -bench.off('cycle'); - -// unregister all listeners for multiple event types -bench.off('start cycle complete'); - -// unregister all listeners for all event types -bench.off(); -~~~ - -* * * - - - - - - -### `Benchmark.Suite.prototype.on(type, listener)` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2197 "View in source") [Ⓣ][1] - -Registers a listener for the specified event type(s). - -#### Arguments -1. `type` *(String)*: The event type. -2. `listener` *(Function)*: The function to register. - -#### Returns -*(Object)*: The benchmark instance. - -#### Example -~~~ js -// register a listener for an event type -bench.on('cycle', listener); - -// register a listener for multiple event types -bench.on('start cycle', listener); -~~~ - -* * * - - - - - - -### `Benchmark.Suite.prototype.pluck(property)` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3798 "View in source") [Ⓣ][1] - -Retrieves the value of a specified property from all benchmarks in the suite. - -#### Arguments -1. `property` *(String)*: The property to pluck. - -#### Returns -*(Array)*: A new array of property values. - -* * * - - - - - - -### `Benchmark.Suite.prototype.pop()` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3806 "View in source") [Ⓣ][1] - -Removes the last benchmark from the suite and returns it. - -#### Returns -*(Mixed)*: The removed benchmark. - -* * * - - - - - - -### `Benchmark.Suite.prototype.push()` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3814 "View in source") [Ⓣ][1] - -Appends benchmarks to the suite. - -#### Returns -*(Number)*: The suite's new length. - -* * * - - - - - - -### `Benchmark.Suite.prototype.reduce(callback, accumulator)` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3833 "View in source") [Ⓣ][1] - -An `Array#reduce` like method. - -#### Arguments -1. `callback` *(Function)*: The function called per iteration. -2. `accumulator` *(Mixed)*: Initial value of the accumulator. - -#### Returns -*(Mixed)*: The accumulator. - -* * * - - - - - - -### `Benchmark.Suite.prototype.reset()` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2019 "View in source") [Ⓣ][1] - -Resets all benchmarks in the suite. - -#### Returns -*(Object)*: The suite instance. - -* * * - - - - - - -### `Benchmark.Suite.prototype.reverse()` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L638 "View in source") [Ⓣ][1] - -Rearrange the host array's elements in reverse order. - -#### Returns -*(Array)*: The reversed array. - -* * * - - - - - - -### `Benchmark.Suite.prototype.run([options={}])` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2056 "View in source") [Ⓣ][1] - -Runs the suite. - -#### Arguments -1. `[options={}]` *(Object)*: Options object. - -#### Returns -*(Object)*: The suite instance. - -#### Example -~~~ js -// basic usage -suite.run(); - -// or with options -suite.run({ 'async': true, 'queued': true }); -~~~ - -* * * - - - - - - -### `Benchmark.Suite.prototype.shift()` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L671 "View in source") [Ⓣ][1] - -Removes the first element of the host array and returns it. - -#### Returns -*(Mixed)*: The first element of the array. - -* * * - - - - - - -### `Benchmark.Suite.prototype.slice(start, end)` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L684 "View in source") [Ⓣ][1] - -Creates an array of the host array's elements from the start index up to, but not including, the end index. - -#### Arguments -1. `start` *(Number)*: The starting index. -2. `end` *(Number)*: The end index. - -#### Returns -*(Array)*: The new array. - -* * * - - - - - - -### `Benchmark.Suite.prototype.sort([compareFn=null])` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3823 "View in source") [Ⓣ][1] - -Sorts the benchmarks of the suite. - -#### Arguments -1. `[compareFn=null]` *(Function)*: A function that defines the sort order. - -#### Returns -*(Object)*: The sorted suite. - -* * * - - - - - - -### `Benchmark.Suite.prototype.splice(start, deleteCount [, val1, val2, ...])` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L714 "View in source") [Ⓣ][1] - -Allows removing a range of elements and/or inserting elements into the host array. - -#### Arguments -1. `start` *(Number)*: The start index. -2. `deleteCount` *(Number)*: The number of elements to delete. -3. `[val1, val2, ...]` *(Mixed)*: values to insert at the `start` index. - -#### Returns -*(Array)*: An array of removed elements. - -* * * - - - - - - -### `Benchmark.Suite.prototype.unshift()` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L749 "View in source") [Ⓣ][1] - -Appends arguments to the host array. - -#### Returns -*(Number)*: The new length. - -* * * - - - - - - - - - -## `Benchmark.Suite.options` - - - -### `Benchmark.Suite.options` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3705 "View in source") [Ⓣ][1] - -*(Object)*: The default options copied by suite instances. - -* * * - - - - - - -### `Benchmark.Suite.options.name` -# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3713 "View in source") [Ⓣ][1] - -*(String)*: The name of the suite. - -* * * - - - - - - - - - - +# Benchmark.js v1.0.0 + + + + + + +## `Benchmark` +* [`Benchmark`](#benchmarkname-fn--options) +* [`Benchmark.version`](#benchmarkversion) +* [`Benchmark.deepClone`](#benchmarkdeepclonevalue) +* [`Benchmark.each`](#benchmarkeachobject-callback-thisarg) +* [`Benchmark.extend`](#benchmarkextenddestination--source) +* [`Benchmark.filter`](#benchmarkfilterarray-callback-thisarg) +* [`Benchmark.forEach`](#benchmarkforeacharray-callback-thisarg) +* [`Benchmark.formatNumber`](#benchmarkformatnumbernumber) +* [`Benchmark.forOwn`](#benchmarkforownobject-callback-thisarg) +* [`Benchmark.hasKey`](#benchmarkhaskeyobject-key) +* [`Benchmark.indexOf`](#benchmarkindexofarray-value--fromindex0) +* [`Benchmark.interpolate`](#benchmarkinterpolatestring-object) +* [`Benchmark.invoke`](#benchmarkinvokebenches-name--arg1-arg2-) +* [`Benchmark.join`](#benchmarkjoinobject--separator1--separator2:) +* [`Benchmark.map`](#benchmarkmaparray-callback-thisarg) +* [`Benchmark.pluck`](#benchmarkpluckarray-property) +* [`Benchmark.reduce`](#benchmarkreducearray-callback-accumulator) + + + + + + +## `Benchmark.prototype` +* [`Benchmark.prototype.aborted`](#benchmarkprototypeaborted) +* [`Benchmark.prototype.compiled`](#benchmarkprototypecompiled) +* [`Benchmark.prototype.count`](#benchmarkprototypecount) +* [`Benchmark.prototype.cycles`](#benchmarkprototypecycles) +* [`Benchmark.prototype.fn`](#benchmarkprototypefn) +* [`Benchmark.prototype.hz`](#benchmarkprototypehz) +* [`Benchmark.prototype.running`](#benchmarkprototyperunning) +* [`Benchmark.prototype.setup`](#benchmarkprototypesetup) +* [`Benchmark.prototype.teardown`](#benchmarkprototypeteardown) +* [`Benchmark.prototype.abort`](#benchmarkprototypeabort) +* [`Benchmark.prototype.clone`](#benchmarkprototypecloneoptions) +* [`Benchmark.prototype.compare`](#benchmarkprototypecompareother) +* [`Benchmark.prototype.emit`](#benchmarkprototypeemittype) +* [`Benchmark.prototype.listeners`](#benchmarkprototypelistenerstype) +* [`Benchmark.prototype.off`](#benchmarkprototypeofftype-listener) +* [`Benchmark.prototype.on`](#benchmarkprototypeontype-listener) +* [`Benchmark.prototype.reset`](#benchmarkprototypereset) +* [`Benchmark.prototype.run`](#benchmarkprototyperunoptions) +* [`Benchmark.prototype.toString`](#benchmarkprototypetostring) + + + + + + +## `Benchmark.options` +* [`Benchmark.options`](#benchmarkoptions) +* [`Benchmark.options.async`](#benchmarkoptionsasync) +* [`Benchmark.options.defer`](#benchmarkoptionsdefer) +* [`Benchmark.options.delay`](#benchmarkoptionsdelay) +* [`Benchmark.options.id`](#benchmarkoptionsid) +* [`Benchmark.options.initCount`](#benchmarkoptionsinitcount) +* [`Benchmark.options.maxTime`](#benchmarkoptionsmaxtime) +* [`Benchmark.options.minSamples`](#benchmarkoptionsminsamples) +* [`Benchmark.options.minTime`](#benchmarkoptionsmintime) +* [`Benchmark.options.name`](#benchmarkoptionsname) +* [`Benchmark.options.onAbort`](#benchmarkoptionsonabort) +* [`Benchmark.options.onComplete`](#benchmarkoptionsoncomplete) +* [`Benchmark.options.onCycle`](#benchmarkoptionsoncycle) +* [`Benchmark.options.onError`](#benchmarkoptionsonerror) +* [`Benchmark.options.onReset`](#benchmarkoptionsonreset) +* [`Benchmark.options.onStart`](#benchmarkoptionsonstart) + + + + + + +## `Benchmark.platform` +* [`Benchmark.platform`](#benchmarkplatform) +* [`Benchmark.platform.description`](#benchmarkplatformdescription) +* [`Benchmark.platform.layout`](#benchmarkplatformlayout) +* [`Benchmark.platform.manufacturer`](#benchmarkplatformmanufacturer) +* [`Benchmark.platform.name`](#benchmarkplatformname) +* [`Benchmark.platform.os`](#benchmarkplatformos) +* [`Benchmark.platform.prerelease`](#benchmarkplatformprerelease) +* [`Benchmark.platform.product`](#benchmarkplatformproduct) +* [`Benchmark.platform.version`](#benchmarkplatformversion) +* [`Benchmark.platform.toString`](#benchmarkplatformtostring) + + + + + + +## `Benchmark.support` +* [`Benchmark.support`](#benchmarksupport) +* [`Benchmark.support.air`](#benchmarksupportair) +* [`Benchmark.support.argumentsClass`](#benchmarksupportargumentsclass) +* [`Benchmark.support.browser`](#benchmarksupportbrowser) +* [`Benchmark.support.charByIndex`](#benchmarksupportcharbyindex) +* [`Benchmark.support.charByOwnIndex`](#benchmarksupportcharbyownindex) +* [`Benchmark.support.decompilation`](#benchmarksupportdecompilation) +* [`Benchmark.support.descriptors`](#benchmarksupportdescriptors) +* [`Benchmark.support.getAllKeys`](#benchmarksupportgetallkeys) +* [`Benchmark.support.iteratesOwnLast`](#benchmarksupportiteratesownfirst) +* [`Benchmark.support.java`](#benchmarksupportjava) +* [`Benchmark.support.nodeClass`](#benchmarksupportnodeclass) +* [`Benchmark.support.timeout`](#benchmarksupporttimeout) + + + + + + +## `Benchmark.prototype.error` +* [`Benchmark.prototype.error`](#benchmarkprototypeerror) + + + + + + +## `Benchmark.prototype.stats` +* [`Benchmark.prototype.stats`](#benchmarkprototypestats) +* [`Benchmark.prototype.stats.deviation`](#benchmark-statsdeviation) +* [`Benchmark.prototype.stats.mean`](#benchmark-statsmean) +* [`Benchmark.prototype.stats.moe`](#benchmark-statsmoe) +* [`Benchmark.prototype.stats.rme`](#benchmark-statsrme) +* [`Benchmark.prototype.stats.sample`](#benchmark-statssample) +* [`Benchmark.prototype.stats.sem`](#benchmark-statssem) +* [`Benchmark.prototype.stats.variance`](#benchmark-statsvariance) + + + + + + +## `Benchmark.prototype.times` +* [`Benchmark.prototype.times`](#benchmarkprototypetimes) +* [`Benchmark.prototype.times.cycle`](#benchmark-timescycle) +* [`Benchmark.prototype.times.elapsed`](#benchmark-timeselapsed) +* [`Benchmark.prototype.times.period`](#benchmark-timesperiod) +* [`Benchmark.prototype.times.timeStamp`](#benchmark-timestimestamp) + + + + + + +## `Benchmark.Deferred` +* [`Benchmark.Deferred`](#benchmarkdeferredclone) + + + + + + +## `Benchmark.Deferred.prototype` +* [`Benchmark.Deferred.prototype.benchmark`](#benchmarkdeferredprototypebenchmark) +* [`Benchmark.Deferred.prototype.cycles`](#benchmarkdeferredprototypecycles) +* [`Benchmark.Deferred.prototype.elapsed`](#benchmarkdeferredprototypeelapsed) +* [`Benchmark.Deferred.prototype.resolve`](#benchmarkdeferredprototyperesolve) +* [`Benchmark.Deferred.prototype.timeStamp`](#benchmarkdeferredprototypetimestamp) + + + + + + +## `Benchmark.Event` +* [`Benchmark.Event`](#benchmarkeventtype) + + + + + + +## `Benchmark.Event.prototype` +* [`Benchmark.Event.prototype.aborted`](#benchmarkeventprototypeaborted) +* [`Benchmark.Event.prototype.cancelled`](#benchmarkeventprototypecancelled) +* [`Benchmark.Event.prototype.result`](#benchmarkeventprototyperesult) +* [`Benchmark.Event.prototype.timeStamp`](#benchmarkeventprototypetimestamp) +* [`Benchmark.Event.prototype.type`](#benchmarkeventprototypetype) + + + + + + +## `Benchmark.Event.prototype.currentTarget` +* [`Benchmark.Event.prototype.currentTarget`](#benchmarkeventprototypecurrenttarget) + + + + + + +## `Benchmark.Event.prototype.target` +* [`Benchmark.Event.prototype.target`](#benchmarkeventprototypetarget) + + + + + + +## `Benchmark.Suite` +* [`Benchmark.Suite`](#benchmarksuitename--options) + + + + + + +## `Benchmark.Suite.prototype` +* [`Benchmark.Suite.prototype.aborted`](#benchmarksuiteprototypeaborted) +* [`Benchmark.Suite.prototype.length`](#benchmarksuiteprototypelength) +* [`Benchmark.Suite.prototype.running`](#benchmarksuiteprototyperunning) +* [`Benchmark.Suite.prototype.abort`](#benchmarksuiteprototypeabort) +* [`Benchmark.Suite.prototype.add`](#benchmarksuiteprototypeaddname-fn--options) +* [`Benchmark.Suite.prototype.clone`](#benchmarksuiteprototypecloneoptions) +* [`Benchmark.Suite.prototype.emit`](#benchmarkprototypeemittype) +* [`Benchmark.Suite.prototype.filter`](#benchmarksuiteprototypefiltercallback) +* [`Benchmark.Suite.prototype.forEach`](#benchmarksuiteprototypeforeachcallback) +* [`Benchmark.Suite.prototype.indexOf`](#benchmarksuiteprototypeindexofvalue) +* [`Benchmark.Suite.prototype.invoke`](#benchmarksuiteprototypeinvokename--arg1-arg2-) +* [`Benchmark.Suite.prototype.join`](#benchmarksuiteprototypejoinseparator-) +* [`Benchmark.Suite.prototype.listeners`](#benchmarkprototypelistenerstype) +* [`Benchmark.Suite.prototype.map`](#benchmarksuiteprototypemapcallback) +* [`Benchmark.Suite.prototype.off`](#benchmarkprototypeofftype-listener) +* [`Benchmark.Suite.prototype.on`](#benchmarkprototypeontype-listener) +* [`Benchmark.Suite.prototype.pluck`](#benchmarksuiteprototypepluckproperty) +* [`Benchmark.Suite.prototype.pop`](#benchmarksuiteprototypepop) +* [`Benchmark.Suite.prototype.push`](#benchmarksuiteprototypepush) +* [`Benchmark.Suite.prototype.reduce`](#benchmarksuiteprototypereducecallback-accumulator) +* [`Benchmark.Suite.prototype.reset`](#benchmarksuiteprototypereset) +* [`Benchmark.Suite.prototype.reverse`](#benchmarksuiteprototypereverse) +* [`Benchmark.Suite.prototype.run`](#benchmarksuiteprototyperunoptions) +* [`Benchmark.Suite.prototype.shift`](#benchmarksuiteprototypeshift) +* [`Benchmark.Suite.prototype.slice`](#benchmarksuiteprototypeslicestart-end) +* [`Benchmark.Suite.prototype.sort`](#benchmarksuiteprototypesortcomparefnnull) +* [`Benchmark.Suite.prototype.splice`](#benchmarksuiteprototypesplicestart-deletecount--val1-val2-) +* [`Benchmark.Suite.prototype.unshift`](#benchmarksuiteprototypeunshift) + + + + + + +## `Benchmark.Suite.options` +* [`Benchmark.Suite.options`](#benchmarksuiteoptions) +* [`Benchmark.Suite.options.name`](#benchmarksuiteoptionsname) + + + + + + + + + + + + +## `Benchmark` + + + +### `Benchmark(name, fn [, options={}])` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L404 "View in source") [Ⓣ][1] + +The Benchmark constructor. + +#### Arguments +1. `name` *(String)*: A name to identify the benchmark. +2. `fn` *(Function|String)*: The test to benchmark. +3. `[options={}]` *(Object)*: Options object. + +#### Example +~~~ js +// basic usage (the `new` operator is optional) +var bench = new Benchmark(fn); + +// or using a name first +var bench = new Benchmark('foo', fn); + +// or with options +var bench = new Benchmark('foo', fn, { + + // displayed by Benchmark#toString if `name` is not available + 'id': 'xyz', + + // called when the benchmark starts running + 'onStart': onStart, + + // called after each run cycle + 'onCycle': onCycle, + + // called when aborted + 'onAbort': onAbort, + + // called when a test errors + 'onError': onError, + + // called when reset + 'onReset': onReset, + + // called when the benchmark completes running + 'onComplete': onComplete, + + // compiled/called before the test loop + 'setup': setup, + + // compiled/called after the test loop + 'teardown': teardown +}); + +// or name and options +var bench = new Benchmark('foo', { + + // a flag to indicate the benchmark is deferred + 'defer': true, + + // benchmark test function + 'fn': function(deferred) { + // call resolve() when the deferred test is finished + deferred.resolve(); + } +}); + +// or options only +var bench = new Benchmark({ + + // benchmark name + 'name': 'foo', + + // benchmark test as a string + 'fn': '[1,2,3,4].sort()' +}); + +// a test's `this` binding is set to the benchmark instance +var bench = new Benchmark('foo', function() { + 'My name is '.concat(this.name); // My name is foo +}); +~~~ + +* * * + + + + + + +### `Benchmark.version` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3267 "View in source") [Ⓣ][1] + +*(String)*: The semantic version number. + +* * * + + + + + + +### `Benchmark.deepClone(value)` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1225 "View in source") [Ⓣ][1] + +A deep clone utility. + +#### Arguments +1. `value` *(Mixed)*: The value to clone. + +#### Returns +*(Mixed)*: The cloned value. + +* * * + + + + + + +### `Benchmark.each(object, callback, thisArg)` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1400 "View in source") [Ⓣ][1] + +An iteration utility for arrays and objects. Callbacks may terminate the loop by explicitly returning `false`. + +#### Arguments +1. `object` *(Array|Object)*: The object to iterate over. +2. `callback` *(Function)*: The function called per iteration. +3. `thisArg` *(Mixed)*: The `this` binding for the callback. + +#### Returns +*(Array, Object)*: Returns the object iterated over. + +* * * + + + + + + +### `Benchmark.extend(destination [, source={}])` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1446 "View in source") [Ⓣ][1] + +Copies enumerable properties from the source(s) object to the destination object. + +#### Arguments +1. `destination` *(Object)*: The destination object. +2. `[source={}]` *(Object)*: The source object. + +#### Returns +*(Object)*: The destination object. + +* * * + + + + + + +### `Benchmark.filter(array, callback, thisArg)` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1485 "View in source") [Ⓣ][1] + +A generic `Array#filter` like method. + +#### Arguments +1. `array` *(Array)*: The array to iterate over. +2. `callback` *(Function|String)*: The function/alias called per iteration. +3. `thisArg` *(Mixed)*: The `this` binding for the callback. + +#### Returns +*(Array)*: A new array of values that passed callback filter. + +#### Example +~~~ js +// get odd numbers +Benchmark.filter([1, 2, 3, 4, 5], function(n) { + return n % 2; +}); // -> [1, 3, 5]; + +// get fastest benchmarks +Benchmark.filter(benches, 'fastest'); + +// get slowest benchmarks +Benchmark.filter(benches, 'slowest'); + +// get benchmarks that completed without erroring +Benchmark.filter(benches, 'successful'); +~~~ + +* * * + + + + + + +### `Benchmark.forEach(array, callback, thisArg)` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1518 "View in source") [Ⓣ][1] + +A generic `Array#forEach` like method. Callbacks may terminate the loop by explicitly returning `false`. + +#### Arguments +1. `array` *(Array)*: The array to iterate over. +2. `callback` *(Function)*: The function called per iteration. +3. `thisArg` *(Mixed)*: The `this` binding for the callback. + +#### Returns +*(Array)*: Returns the array iterated over. + +* * * + + + + + + +### `Benchmark.formatNumber(number)` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1557 "View in source") [Ⓣ][1] + +Converts a number to a more readable comma-separated string representation. + +#### Arguments +1. `number` *(Number)*: The number to convert. + +#### Returns +*(String)*: The more readable string representation. + +* * * + + + + + + +### `Benchmark.forOwn(object, callback, thisArg)` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1545 "View in source") [Ⓣ][1] + +Iterates over an object's own properties, executing the `callback` for each. Callbacks may terminate the loop by explicitly returning `false`. + +#### Arguments +1. `object` *(Object)*: The object to iterate over. +2. `callback` *(Function)*: The function executed per own property. +3. `thisArg` *(Mixed)*: The `this` binding for the callback. + +#### Returns +*(Object)*: Returns the object iterated over. + +* * * + + + + + + +### `Benchmark.hasKey(object, key)` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1572 "View in source") [Ⓣ][1] + +Checks if an object has the specified key as a direct property. + +#### Arguments +1. `object` *(Object)*: The object to check. +2. `key` *(String)*: The key to check for. + +#### Returns +*(Boolean)*: Returns `true` if key is a direct property, else `false`. + +* * * + + + + + + +### `Benchmark.indexOf(array, value [, fromIndex=0])` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1608 "View in source") [Ⓣ][1] + +A generic `Array#indexOf` like method. + +#### Arguments +1. `array` *(Array)*: The array to iterate over. +2. `value` *(Mixed)*: The value to search for. +3. `[fromIndex=0]` *(Number)*: The index to start searching from. + +#### Returns +*(Number)*: The index of the matched value or `-1`. + +* * * + + + + + + +### `Benchmark.interpolate(string, object)` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1630 "View in source") [Ⓣ][1] + +Modify a string by replacing named tokens with matching object property values. + +#### Arguments +1. `string` *(String)*: The string to modify. +2. `object` *(Object)*: The template object. + +#### Returns +*(String)*: The modified string. + +* * * + + + + + + +### `Benchmark.invoke(benches, name [, arg1, arg2, ...])` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1677 "View in source") [Ⓣ][1] + +Invokes a method on all items in an array. + +#### Arguments +1. `benches` *(Array)*: Array of benchmarks to iterate over. +2. `name` *(String|Object)*: The name of the method to invoke OR options object. +3. `[arg1, arg2, ...]` *(Mixed)*: Arguments to invoke the method with. + +#### Returns +*(Array)*: A new array of values returned from each method invoked. + +#### Example +~~~ js +// invoke `reset` on all benchmarks +Benchmark.invoke(benches, 'reset'); + +// invoke `emit` with arguments +Benchmark.invoke(benches, 'emit', 'complete', listener); + +// invoke `run(true)`, treat benchmarks as a queue, and register invoke callbacks +Benchmark.invoke(benches, { + + // invoke the `run` method + 'name': 'run', + + // pass a single argument + 'args': true, + + // treat as queue, removing benchmarks from front of `benches` until empty + 'queued': true, + + // called before any benchmarks have been invoked. + 'onStart': onStart, + + // called between invoking benchmarks + 'onCycle': onCycle, + + // called after all benchmarks have been invoked. + 'onComplete': onComplete +}); +~~~ + +* * * + + + + + + +### `Benchmark.join(object [, separator1=',', separator2=': '])` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1831 "View in source") [Ⓣ][1] + +Creates a string of joined array values or object key-value pairs. + +#### Arguments +1. `object` *(Array|Object)*: The object to operate on. +2. `[separator1=',']` *(String)*: The separator used between key-value pairs. +3. `[separator2=': ']` *(String)*: The separator used between keys and values. + +#### Returns +*(String)*: The joined result. + +* * * + + + + + + +### `Benchmark.map(array, callback, thisArg)` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1853 "View in source") [Ⓣ][1] + +A generic `Array#map` like method. + +#### Arguments +1. `array` *(Array)*: The array to iterate over. +2. `callback` *(Function)*: The function called per iteration. +3. `thisArg` *(Mixed)*: The `this` binding for the callback. + +#### Returns +*(Array)*: A new array of values returned by the callback. + +* * * + + + + + + +### `Benchmark.pluck(array, property)` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1869 "View in source") [Ⓣ][1] + +Retrieves the value of a specified property from all items in an array. + +#### Arguments +1. `array` *(Array)*: The array to iterate over. +2. `property` *(String)*: The property to pluck. + +#### Returns +*(Array)*: A new array of property values. + +* * * + + + + + + +### `Benchmark.reduce(array, callback, accumulator)` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1885 "View in source") [Ⓣ][1] + +A generic `Array#reduce` like method. + +#### Arguments +1. `array` *(Array)*: The array to iterate over. +2. `callback` *(Function)*: The function called per iteration. +3. `accumulator` *(Mixed)*: Initial value of the accumulator. + +#### Returns +*(Mixed)*: The accumulator. + +* * * + + + + + + + + + +## `Benchmark.prototype` + + + +### `Benchmark.prototype.aborted` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3377 "View in source") [Ⓣ][1] + +*(Boolean)*: A flag to indicate if the benchmark is aborted. + +* * * + + + + + + +### `Benchmark.prototype.compiled` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3353 "View in source") [Ⓣ][1] + +*(Function, String)*: The compiled test function. + +* * * + + + + + + +### `Benchmark.prototype.count` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3329 "View in source") [Ⓣ][1] + +*(Number)*: The number of times a test was executed. + +* * * + + + + + + +### `Benchmark.prototype.cycles` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3337 "View in source") [Ⓣ][1] + +*(Number)*: The number of cycles performed while benchmarking. + +* * * + + + + + + +### `Benchmark.prototype.fn` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3369 "View in source") [Ⓣ][1] + +*(Function, String)*: The test to benchmark. + +* * * + + + + + + +### `Benchmark.prototype.hz` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3345 "View in source") [Ⓣ][1] + +*(Number)*: The number of executions per second. + +* * * + + + + + + +### `Benchmark.prototype.running` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3385 "View in source") [Ⓣ][1] + +*(Boolean)*: A flag to indicate if the benchmark is running. + +* * * + + + + + + +### `Benchmark.prototype.setup` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3448 "View in source") [Ⓣ][1] + +*(Function, String)*: Compiled into the test and executed immediately **before** the test loop. + +#### Example +~~~ js +// basic usage +var bench = Benchmark({ + 'setup': function() { + var c = this.count, + element = document.getElementById('container'); + while (c--) { + element.appendChild(document.createElement('div')); + } + }, + 'fn': function() { + element.removeChild(element.lastChild); + } +}); + +// compiles to something like: +var c = this.count, + element = document.getElementById('container'); +while (c--) { + element.appendChild(document.createElement('div')); +} +var start = new Date; +while (count--) { + element.removeChild(element.lastChild); +} +var end = new Date - start; + +// or using strings +var bench = Benchmark({ + 'setup': '\ + var a = 0;\n\ + (function() {\n\ + (function() {\n\ + (function() {', + 'fn': 'a += 1;', + 'teardown': '\ + }())\n\ + }())\n\ + }())' +}); + +// compiles to something like: +var a = 0; +(function() { + (function() { + (function() { + var start = new Date; + while (count--) { + a += 1; + } + var end = new Date - start; + }()) + }()) +}()) +~~~ + +* * * + + + + + + +### `Benchmark.prototype.teardown` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3456 "View in source") [Ⓣ][1] + +*(Function, String)*: Compiled into the test and executed immediately **after** the test loop. + +* * * + + + + + + +### `Benchmark.prototype.abort()` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2218 "View in source") [Ⓣ][1] + +Aborts the benchmark without recording times. + +#### Returns +*(Object)*: The benchmark instance. + +* * * + + + + + + +### `Benchmark.prototype.clone(options)` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2257 "View in source") [Ⓣ][1] + +Creates a new benchmark using the same test and options. + +#### Arguments +1. `options` *(Object)*: Options object to overwrite cloned options. + +#### Returns +*(Object)*: The new benchmark instance. + +#### Example +~~~ js +var bizarro = bench.clone({ + 'name': 'doppelganger' +}); +~~~ + +* * * + + + + + + +### `Benchmark.prototype.compare(other)` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2280 "View in source") [Ⓣ][1] + +Determines if a benchmark is faster than another. + +#### Arguments +1. `other` *(Object)*: The benchmark to compare. + +#### Returns +*(Number)*: Returns `-1` if slower, `1` if faster, and `0` if indeterminate. + +* * * + + + + + + +### `Benchmark.Suite.prototype.emit(type)` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2095 "View in source") [Ⓣ][1] + +Executes all registered listeners of the specified event type. + +#### Arguments +1. `type` *(String|Object)*: The event type or object. + +#### Returns +*(Mixed)*: Returns the return value of the last listener executed. + +* * * + + + + + + +### `Benchmark.Suite.prototype.listeners(type)` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2125 "View in source") [Ⓣ][1] + +Returns an array of event listeners for a given type that can be manipulated to add or remove listeners. + +#### Arguments +1. `type` *(String)*: The event type. + +#### Returns +*(Array)*: The listeners array. + +* * * + + + + + + +### `Benchmark.Suite.prototype.off([type, listener])` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2158 "View in source") [Ⓣ][1] + +Unregisters a listener for the specified event type(s), or unregisters all listeners for the specified event type(s), or unregisters all listeners for all event types. + +#### Arguments +1. `[type]` *(String)*: The event type. +2. `[listener]` *(Function)*: The function to unregister. + +#### Returns +*(Object)*: The benchmark instance. + +#### Example +~~~ js +// unregister a listener for an event type +bench.off('cycle', listener); + +// unregister a listener for multiple event types +bench.off('start cycle', listener); + +// unregister all listeners for an event type +bench.off('cycle'); + +// unregister all listeners for multiple event types +bench.off('start cycle complete'); + +// unregister all listeners for all event types +bench.off(); +~~~ + +* * * + + + + + + +### `Benchmark.Suite.prototype.on(type, listener)` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2197 "View in source") [Ⓣ][1] + +Registers a listener for the specified event type(s). + +#### Arguments +1. `type` *(String)*: The event type. +2. `listener` *(Function)*: The function to register. + +#### Returns +*(Object)*: The benchmark instance. + +#### Example +~~~ js +// register a listener for an event type +bench.on('cycle', listener); + +// register a listener for multiple event types +bench.on('start cycle', listener); +~~~ + +* * * + + + + + + +### `Benchmark.prototype.reset()` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2334 "View in source") [Ⓣ][1] + +Reset properties and abort if running. + +#### Returns +*(Object)*: The benchmark instance. + +* * * + + + + + + +### `Benchmark.prototype.run([options={}])` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3000 "View in source") [Ⓣ][1] + +Runs the benchmark. + +#### Arguments +1. `[options={}]` *(Object)*: Options object. + +#### Returns +*(Object)*: The benchmark instance. + +#### Example +~~~ js +// basic usage +bench.run(); + +// or with options +bench.run({ 'async': true }); +~~~ + +* * * + + + + + + +### `Benchmark.prototype.toString()` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2405 "View in source") [Ⓣ][1] + +Displays relevant benchmark information when coerced to a string. + +#### Returns +*(String)*: A string representation of the benchmark instance. + +* * * + + + + + + + + + +## `Benchmark.options` + + + +### `Benchmark.options` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3049 "View in source") [Ⓣ][1] + +*(Object)*: The default options copied by benchmark instances. + +* * * + + + + + + +### `Benchmark.options.async` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3058 "View in source") [Ⓣ][1] + +*(Boolean)*: A flag to indicate that benchmark cycles will execute asynchronously by default. + +* * * + + + + + + +### `Benchmark.options.defer` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3066 "View in source") [Ⓣ][1] + +*(Boolean)*: A flag to indicate that the benchmark clock is deferred. + +* * * + + + + + + +### `Benchmark.options.delay` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3073 "View in source") [Ⓣ][1] + +*(Number)*: The delay between test cycles *(secs)*. + +* * * + + + + + + +### `Benchmark.options.id` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3082 "View in source") [Ⓣ][1] + +*(String)*: Displayed by Benchmark#toString when a `name` is not available *(auto-generated if absent)*. + +* * * + + + + + + +### `Benchmark.options.initCount` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3090 "View in source") [Ⓣ][1] + +*(Number)*: The default number of times to execute a test on a benchmark's first cycle. + +* * * + + + + + + +### `Benchmark.options.maxTime` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3099 "View in source") [Ⓣ][1] + +*(Number)*: The maximum time a benchmark is allowed to run before finishing *(secs)*. Note: Cycle delays aren't counted toward the maximum time. + +* * * + + + + + + +### `Benchmark.options.minSamples` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3107 "View in source") [Ⓣ][1] + +*(Number)*: The minimum sample size required to perform statistical analysis. + +* * * + + + + + + +### `Benchmark.options.minTime` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3115 "View in source") [Ⓣ][1] + +*(Number)*: The time needed to reduce the percent uncertainty of measurement to `1`% *(secs)*. + +* * * + + + + + + +### `Benchmark.options.name` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3123 "View in source") [Ⓣ][1] + +*(String)*: The name of the benchmark. + +* * * + + + + + + +### `Benchmark.options.onAbort` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3131 "View in source") [Ⓣ][1] + +An event listener called when the benchmark is aborted. + +* * * + + + + + + +### `Benchmark.options.onComplete` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3139 "View in source") [Ⓣ][1] + +An event listener called when the benchmark completes running. + +* * * + + + + + + +### `Benchmark.options.onCycle` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3147 "View in source") [Ⓣ][1] + +An event listener called after each run cycle. + +* * * + + + + + + +### `Benchmark.options.onError` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3155 "View in source") [Ⓣ][1] + +An event listener called when a test errors. + +* * * + + + + + + +### `Benchmark.options.onReset` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3163 "View in source") [Ⓣ][1] + +An event listener called when the benchmark is reset. + +* * * + + + + + + +### `Benchmark.options.onStart` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3171 "View in source") [Ⓣ][1] + +An event listener called when the benchmark starts running. + +* * * + + + + + + + + + +## `Benchmark.platform` + + + +### `Benchmark.platform` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3182 "View in source") [Ⓣ][1] + +*(Object)*: Platform object with properties describing things like browser name, version, and operating system. + +* * * + + + + + + +### `Benchmark.platform.description` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3190 "View in source") [Ⓣ][1] + +*(String)*: The platform description. + +* * * + + + + + + +### `Benchmark.platform.layout` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3198 "View in source") [Ⓣ][1] + +*(String, Null)*: The name of the browser layout engine. + +* * * + + + + + + +### `Benchmark.platform.manufacturer` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3222 "View in source") [Ⓣ][1] + +*(String, Null)*: The name of the product's manufacturer. + +* * * + + + + + + +### `Benchmark.platform.name` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3214 "View in source") [Ⓣ][1] + +*(String, Null)*: The name of the browser/environment. + +* * * + + + + + + +### `Benchmark.platform.os` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3230 "View in source") [Ⓣ][1] + +*(String, Null)*: The name of the operating system. + +* * * + + + + + + +### `Benchmark.platform.prerelease` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3238 "View in source") [Ⓣ][1] + +*(String, Null)*: The alpha/beta release indicator. + +* * * + + + + + + +### `Benchmark.platform.product` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3206 "View in source") [Ⓣ][1] + +*(String, Null)*: The name of the product hosting the browser. + +* * * + + + + + + +### `Benchmark.platform.version` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3246 "View in source") [Ⓣ][1] + +*(String, Null)*: The browser/environment version. + +* * * + + + + + + +### `Benchmark.platform.toString()` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3255 "View in source") [Ⓣ][1] + +Return platform description when the platform object is coerced to a string. + +#### Returns +*(String)*: The platform description. + +* * * + + + + + + + + + +## `Benchmark.support` + + + +### `Benchmark.support` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L135 "View in source") [Ⓣ][1] + +*(Object)*: An object used to flag environments/features. + +* * * + + + + + + +### `Benchmark.support.air` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L145 "View in source") [Ⓣ][1] + +*(Boolean)*: Detect Adobe AIR. + +* * * + + + + + + +### `Benchmark.support.argumentsClass` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L153 "View in source") [Ⓣ][1] + +*(Boolean)*: Detect if `arguments` objects have the correct internal [[Class]] value. + +* * * + + + + + + +### `Benchmark.support.browser` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L161 "View in source") [Ⓣ][1] + +*(Boolean)*: Detect if in a browser environment. + +* * * + + + + + + +### `Benchmark.support.charByIndex` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L169 "View in source") [Ⓣ][1] + +*(Boolean)*: Detect if strings support accessing characters by index. + +* * * + + + + + + +### `Benchmark.support.charByOwnIndex` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L179 "View in source") [Ⓣ][1] + +*(Boolean)*: Detect if strings have indexes as own properties. + +* * * + + + + + + +### `Benchmark.support.decompilation` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L207 "View in source") [Ⓣ][1] + +*(Boolean)*: Detect if functions support decompilation. + +* * * + + + + + + +### `Benchmark.support.descriptors` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L228 "View in source") [Ⓣ][1] + +*(Boolean)*: Detect ES5+ property descriptor API. + +* * * + + + + + + +### `Benchmark.support.getAllKeys` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L242 "View in source") [Ⓣ][1] + +*(Boolean)*: Detect ES5+ Object.getOwnPropertyNames(). + +* * * + + + + + + +### `Benchmark.support.iteratesOwnFirst` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L255 "View in source") [Ⓣ][1] + +*(Boolean)*: Detect if own properties are iterated before inherited properties *(all but IE < `9`)*. + +* * * + + + + + + +### `Benchmark.support.java` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L190 "View in source") [Ⓣ][1] + +*(Boolean)*: Detect if Java is enabled/exposed. + +* * * + + + + + + +### `Benchmark.support.nodeClass` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L272 "View in source") [Ⓣ][1] + +*(Boolean)*: Detect if a node's [[Class]] is resolvable *(all but IE < `9`)* and that the JS engine errors when attempting to coerce an object to a string without a `toString` property value of `typeof` "function". + +* * * + + + + + + +### `Benchmark.support.timeout` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L198 "View in source") [Ⓣ][1] + +*(Boolean)*: Detect if the Timers API exists. + +* * * + + + + + + + + + +## `Benchmark.prototype.error` + + + +### `Benchmark.prototype.error` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3361 "View in source") [Ⓣ][1] + +*(Object)*: The error object if the test failed. + +* * * + + + + + + + + + +## `Benchmark.prototype.stats` + + + +### `Benchmark.prototype.stats` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3464 "View in source") [Ⓣ][1] + +*(Object)*: An object of stats including mean, margin or error, and standard deviation. + +* * * + + + + + + +### `Benchmark.prototype.stats.deviation` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3496 "View in source") [Ⓣ][1] + +*(Number)*: The sample standard deviation. + +* * * + + + + + + +### `Benchmark.prototype.stats.mean` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3504 "View in source") [Ⓣ][1] + +*(Number)*: The sample arithmetic mean. + +* * * + + + + + + +### `Benchmark.prototype.stats.moe` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3472 "View in source") [Ⓣ][1] + +*(Number)*: The margin of error. + +* * * + + + + + + +### `Benchmark.prototype.stats.rme` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3480 "View in source") [Ⓣ][1] + +*(Number)*: The relative margin of error *(expressed as a percentage of the mean)*. + +* * * + + + + + + +### `Benchmark.prototype.stats.sample` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3512 "View in source") [Ⓣ][1] + +*(Array)*: The array of sampled periods. + +* * * + + + + + + +### `Benchmark.prototype.stats.sem` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3488 "View in source") [Ⓣ][1] + +*(Number)*: The standard error of the mean. + +* * * + + + + + + +### `Benchmark.prototype.stats.variance` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3520 "View in source") [Ⓣ][1] + +*(Number)*: The sample variance. + +* * * + + + + + + + + + +## `Benchmark.prototype.times` + + + +### `Benchmark.prototype.times` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3529 "View in source") [Ⓣ][1] + +*(Object)*: An object of timing data including cycle, elapsed, period, start, and stop. + +* * * + + + + + + +### `Benchmark.prototype.times.cycle` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3537 "View in source") [Ⓣ][1] + +*(Number)*: The time taken to complete the last cycle *(secs)*. + +* * * + + + + + + +### `Benchmark.prototype.times.elapsed` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3545 "View in source") [Ⓣ][1] + +*(Number)*: The time taken to complete the benchmark *(secs)*. + +* * * + + + + + + +### `Benchmark.prototype.times.period` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3553 "View in source") [Ⓣ][1] + +*(Number)*: The time taken to execute the test once *(secs)*. + +* * * + + + + + + +### `Benchmark.prototype.times.timeStamp` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3561 "View in source") [Ⓣ][1] + +*(Number)*: A timestamp of when the benchmark started *(ms)*. + +* * * + + + + + + + + + +## `Benchmark.Deferred` + + + +### `Benchmark.Deferred(clone)` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L445 "View in source") [Ⓣ][1] + +The Deferred constructor. + +#### Arguments +1. `clone` *(Object)*: The cloned benchmark instance. + +* * * + + + + + + + + + +## `Benchmark.Deferred.prototype` + + + +### `Benchmark.Deferred.prototype.benchmark` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3605 "View in source") [Ⓣ][1] + +*(Object)*: The deferred benchmark instance. + +* * * + + + + + + +### `Benchmark.Deferred.prototype.cycles` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3613 "View in source") [Ⓣ][1] + +*(Number)*: The number of deferred cycles performed while benchmarking. + +* * * + + + + + + +### `Benchmark.Deferred.prototype.elapsed` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3621 "View in source") [Ⓣ][1] + +*(Number)*: The time taken to complete the deferred benchmark *(secs)*. + +* * * + + + + + + +### `Benchmark.Deferred.prototype.resolve` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1188 "View in source") [Ⓣ][1] + +*(Unknown)*: Handles cycling/completing the deferred benchmark. + +* * * + + + + + + +### `Benchmark.Deferred.prototype.timeStamp` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3629 "View in source") [Ⓣ][1] + +*(Number)*: A timestamp of when the deferred benchmark started *(ms)*. + +* * * + + + + + + + + + +## `Benchmark.Event` + + + +### `Benchmark.Event(type)` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L461 "View in source") [Ⓣ][1] + +The Event constructor. + +#### Arguments +1. `type` *(String|Object)*: The event type. + +* * * + + + + + + + + + +## `Benchmark.Event.prototype` + + + +### `Benchmark.Event.prototype.aborted` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3645 "View in source") [Ⓣ][1] + +*(Boolean)*: A flag to indicate if the emitters listener iteration is aborted. + +* * * + + + + + + +### `Benchmark.Event.prototype.cancelled` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3653 "View in source") [Ⓣ][1] + +*(Boolean)*: A flag to indicate if the default action is cancelled. + +* * * + + + + + + +### `Benchmark.Event.prototype.result` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3669 "View in source") [Ⓣ][1] + +*(Mixed)*: The return value of the last executed listener. + +* * * + + + + + + +### `Benchmark.Event.prototype.timeStamp` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3685 "View in source") [Ⓣ][1] + +*(Number)*: A timestamp of when the event was created *(ms)*. + +* * * + + + + + + +### `Benchmark.Event.prototype.type` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3693 "View in source") [Ⓣ][1] + +*(String)*: The event type. + +* * * + + + + + + + + + +## `Benchmark.Event.prototype.currentTarget` + + + +### `Benchmark.Event.prototype.currentTarget` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3661 "View in source") [Ⓣ][1] + +*(Object)*: The object whose listeners are currently being processed. + +* * * + + + + + + + + + +## `Benchmark.Event.prototype.target` + + + +### `Benchmark.Event.prototype.target` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3677 "View in source") [Ⓣ][1] + +*(Object)*: The object to which the event was originally emitted. + +* * * + + + + + + + + + +## `Benchmark.Suite` + + + +### `Benchmark.Suite(name [, options={}])` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L507 "View in source") [Ⓣ][1] + +The Suite constructor. + +#### Arguments +1. `name` *(String)*: A name to identify the suite. +2. `[options={}]` *(Object)*: Options object. + +#### Example +~~~ js +// basic usage (the `new` operator is optional) +var suite = new Benchmark.Suite; + +// or using a name first +var suite = new Benchmark.Suite('foo'); + +// or with options +var suite = new Benchmark.Suite('foo', { + + // called when the suite starts running + 'onStart': onStart, + + // called between running benchmarks + 'onCycle': onCycle, + + // called when aborted + 'onAbort': onAbort, + + // called when a test errors + 'onError': onError, + + // called when reset + 'onReset': onReset, + + // called when the suite completes running + 'onComplete': onComplete +}); +~~~ + +* * * + + + + + + + + + +## `Benchmark.Suite.prototype` + + + +### `Benchmark.Suite.prototype.aborted` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3734 "View in source") [Ⓣ][1] + +*(Boolean)*: A flag to indicate if the suite is aborted. + +* * * + + + + + + +### `Benchmark.Suite.prototype.length` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3726 "View in source") [Ⓣ][1] + +*(Number)*: The number of benchmarks in the suite. + +* * * + + + + + + +### `Benchmark.Suite.prototype.running` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3742 "View in source") [Ⓣ][1] + +*(Boolean)*: A flag to indicate if the suite is running. + +* * * + + + + + + +### `Benchmark.Suite.prototype.abort()` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1902 "View in source") [Ⓣ][1] + +Aborts all benchmarks in the suite. + +#### Returns +*(Object)*: The suite instance. + +* * * + + + + + + +### `Benchmark.Suite.prototype.add(name, fn [, options={}])` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1962 "View in source") [Ⓣ][1] + +Adds a test to the benchmark suite. + +#### Arguments +1. `name` *(String)*: A name to identify the benchmark. +2. `fn` *(Function|String)*: The test to benchmark. +3. `[options={}]` *(Object)*: Options object. + +#### Returns +*(Object)*: The benchmark instance. + +#### Example +~~~ js +// basic usage +suite.add(fn); + +// or using a name first +suite.add('foo', fn); + +// or with options +suite.add('foo', fn, { + 'onCycle': onCycle, + 'onComplete': onComplete +}); + +// or name and options +suite.add('foo', { + 'fn': fn, + 'onCycle': onCycle, + 'onComplete': onComplete +}); + +// or options only +suite.add({ + 'name': 'foo', + 'fn': fn, + 'onCycle': onCycle, + 'onComplete': onComplete +}); +~~~ + +* * * + + + + + + +### `Benchmark.Suite.prototype.clone(options)` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L1981 "View in source") [Ⓣ][1] + +Creates a new suite with cloned benchmarks. + +#### Arguments +1. `options` *(Object)*: Options object to overwrite cloned options. + +#### Returns +*(Object)*: The new suite instance. + +* * * + + + + + + +### `Benchmark.Suite.prototype.emit(type)` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2095 "View in source") [Ⓣ][1] + +Executes all registered listeners of the specified event type. + +#### Arguments +1. `type` *(String|Object)*: The event type or object. + +#### Returns +*(Mixed)*: Returns the return value of the last listener executed. + +* * * + + + + + + +### `Benchmark.Suite.prototype.filter(callback)` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2004 "View in source") [Ⓣ][1] + +An `Array#filter` like method. + +#### Arguments +1. `callback` *(Function|String)*: The function/alias called per iteration. + +#### Returns +*(Object)*: A new suite of benchmarks that passed callback filter. + +* * * + + + + + + +### `Benchmark.Suite.prototype.forEach(callback)` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3752 "View in source") [Ⓣ][1] + +An `Array#forEach` like method. Callbacks may terminate the loop by explicitly returning `false`. + +#### Arguments +1. `callback` *(Function)*: The function called per iteration. + +#### Returns +*(Object)*: The suite iterated over. + +* * * + + + + + + +### `Benchmark.Suite.prototype.indexOf(value)` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3761 "View in source") [Ⓣ][1] + +An `Array#indexOf` like method. + +#### Arguments +1. `value` *(Mixed)*: The value to search for. + +#### Returns +*(Number)*: The index of the matched value or `-1`. + +* * * + + + + + + +### `Benchmark.Suite.prototype.invoke(name [, arg1, arg2, ...])` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3771 "View in source") [Ⓣ][1] + +Invokes a method on all benchmarks in the suite. + +#### Arguments +1. `name` *(String|Object)*: The name of the method to invoke OR options object. +2. `[arg1, arg2, ...]` *(Mixed)*: Arguments to invoke the method with. + +#### Returns +*(Array)*: A new array of values returned from each method invoked. + +* * * + + + + + + +### `Benchmark.Suite.prototype.join([separator=','])` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3780 "View in source") [Ⓣ][1] + +Converts the suite of benchmarks to a string. + +#### Arguments +1. `[separator=',']` *(String)*: A string to separate each element of the array. + +#### Returns +*(String)*: The string. + +* * * + + + + + + +### `Benchmark.Suite.prototype.listeners(type)` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2125 "View in source") [Ⓣ][1] + +Returns an array of event listeners for a given type that can be manipulated to add or remove listeners. + +#### Arguments +1. `type` *(String)*: The event type. + +#### Returns +*(Array)*: The listeners array. + +* * * + + + + + + +### `Benchmark.Suite.prototype.map(callback)` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3789 "View in source") [Ⓣ][1] + +An `Array#map` like method. + +#### Arguments +1. `callback` *(Function)*: The function called per iteration. + +#### Returns +*(Array)*: A new array of values returned by the callback. + +* * * + + + + + + +### `Benchmark.Suite.prototype.off([type, listener])` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2158 "View in source") [Ⓣ][1] + +Unregisters a listener for the specified event type(s), or unregisters all listeners for the specified event type(s), or unregisters all listeners for all event types. + +#### Arguments +1. `[type]` *(String)*: The event type. +2. `[listener]` *(Function)*: The function to unregister. + +#### Returns +*(Object)*: The benchmark instance. + +#### Example +~~~ js +// unregister a listener for an event type +bench.off('cycle', listener); + +// unregister a listener for multiple event types +bench.off('start cycle', listener); + +// unregister all listeners for an event type +bench.off('cycle'); + +// unregister all listeners for multiple event types +bench.off('start cycle complete'); + +// unregister all listeners for all event types +bench.off(); +~~~ + +* * * + + + + + + +### `Benchmark.Suite.prototype.on(type, listener)` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2197 "View in source") [Ⓣ][1] + +Registers a listener for the specified event type(s). + +#### Arguments +1. `type` *(String)*: The event type. +2. `listener` *(Function)*: The function to register. + +#### Returns +*(Object)*: The benchmark instance. + +#### Example +~~~ js +// register a listener for an event type +bench.on('cycle', listener); + +// register a listener for multiple event types +bench.on('start cycle', listener); +~~~ + +* * * + + + + + + +### `Benchmark.Suite.prototype.pluck(property)` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3798 "View in source") [Ⓣ][1] + +Retrieves the value of a specified property from all benchmarks in the suite. + +#### Arguments +1. `property` *(String)*: The property to pluck. + +#### Returns +*(Array)*: A new array of property values. + +* * * + + + + + + +### `Benchmark.Suite.prototype.pop()` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3806 "View in source") [Ⓣ][1] + +Removes the last benchmark from the suite and returns it. + +#### Returns +*(Mixed)*: The removed benchmark. + +* * * + + + + + + +### `Benchmark.Suite.prototype.push()` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3814 "View in source") [Ⓣ][1] + +Appends benchmarks to the suite. + +#### Returns +*(Number)*: The suite's new length. + +* * * + + + + + + +### `Benchmark.Suite.prototype.reduce(callback, accumulator)` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3833 "View in source") [Ⓣ][1] + +An `Array#reduce` like method. + +#### Arguments +1. `callback` *(Function)*: The function called per iteration. +2. `accumulator` *(Mixed)*: Initial value of the accumulator. + +#### Returns +*(Mixed)*: The accumulator. + +* * * + + + + + + +### `Benchmark.Suite.prototype.reset()` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2019 "View in source") [Ⓣ][1] + +Resets all benchmarks in the suite. + +#### Returns +*(Object)*: The suite instance. + +* * * + + + + + + +### `Benchmark.Suite.prototype.reverse()` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L638 "View in source") [Ⓣ][1] + +Rearrange the host array's elements in reverse order. + +#### Returns +*(Array)*: The reversed array. + +* * * + + + + + + +### `Benchmark.Suite.prototype.run([options={}])` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L2056 "View in source") [Ⓣ][1] + +Runs the suite. + +#### Arguments +1. `[options={}]` *(Object)*: Options object. + +#### Returns +*(Object)*: The suite instance. + +#### Example +~~~ js +// basic usage +suite.run(); + +// or with options +suite.run({ 'async': true, 'queued': true }); +~~~ + +* * * + + + + + + +### `Benchmark.Suite.prototype.shift()` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L671 "View in source") [Ⓣ][1] + +Removes the first element of the host array and returns it. + +#### Returns +*(Mixed)*: The first element of the array. + +* * * + + + + + + +### `Benchmark.Suite.prototype.slice(start, end)` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L684 "View in source") [Ⓣ][1] + +Creates an array of the host array's elements from the start index up to, but not including, the end index. + +#### Arguments +1. `start` *(Number)*: The starting index. +2. `end` *(Number)*: The end index. + +#### Returns +*(Array)*: The new array. + +* * * + + + + + + +### `Benchmark.Suite.prototype.sort([compareFn=null])` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3823 "View in source") [Ⓣ][1] + +Sorts the benchmarks of the suite. + +#### Arguments +1. `[compareFn=null]` *(Function)*: A function that defines the sort order. + +#### Returns +*(Object)*: The sorted suite. + +* * * + + + + + + +### `Benchmark.Suite.prototype.splice(start, deleteCount [, val1, val2, ...])` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L714 "View in source") [Ⓣ][1] + +Allows removing a range of elements and/or inserting elements into the host array. + +#### Arguments +1. `start` *(Number)*: The start index. +2. `deleteCount` *(Number)*: The number of elements to delete. +3. `[val1, val2, ...]` *(Mixed)*: values to insert at the `start` index. + +#### Returns +*(Array)*: An array of removed elements. + +* * * + + + + + + +### `Benchmark.Suite.prototype.unshift()` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L749 "View in source") [Ⓣ][1] + +Appends arguments to the host array. + +#### Returns +*(Number)*: The new length. + +* * * + + + + + + + + + +## `Benchmark.Suite.options` + + + +### `Benchmark.Suite.options` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3705 "View in source") [Ⓣ][1] + +*(Object)*: The default options copied by suite instances. + +* * * + + + + + + +### `Benchmark.Suite.options.name` +# [Ⓢ](https://github.com/bestiejs/benchmark.js/blob/master/benchmark.js#L3713 "View in source") [Ⓣ][1] + +*(String)*: The name of the suite. + +* * * + + + + + + + + + + [1]: #Benchmark "Jump back to the TOC." \ No newline at end of file diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/benchmark/package.json b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/benchmark/package.json index 18d67c1d..87ed09f3 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/benchmark/package.json +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/benchmark/package.json @@ -1,61 +1,61 @@ -{ - "name": "benchmark", - "version": "1.0.0", - "description": "A benchmarking library that works on nearly all JavaScript platforms, supports high-resolution timers, and returns statistically significant results.", - "homepage": "http://benchmarkjs.com/", - "main": "benchmark", - "keywords": [ - "benchmark", - "narwhal", - "node", - "performance", - "ringo", - "speed" - ], - "licenses": [ - { - "type": "MIT", - "url": "http://mths.be/mit" - } - ], - "author": { - "name": "Mathias Bynens", - "email": "mathias@benchmarkjs.com", - "url": "http://mathiasbynens.be/" - }, - "maintainers": [ - { - "name": "jdalton", - "email": "john@fusejs.com" - }, - { - "name": "mathias", - "email": "mathias@qiwi.be" - } - ], - "bugs": { - "url": "https://github.com/bestiejs/benchmark.js/issues", - "email": "bugs@benchmarkjs.com" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/bestiejs/benchmark.js.git" - }, - "engines": [ - "node", - "rhino" - ], - "directories": { - "doc": "./doc", - "test": "./test" - }, - "_id": "benchmark@1.0.0", - "dist": { - "shasum": "2f1e2fa4c359f11122aa183082218e957e390c73", - "tarball": "https://registry.npmjs.org/benchmark/-/benchmark-1.0.0.tgz" - }, - "_shasum": "2f1e2fa4c359f11122aa183082218e957e390c73", - "_resolved": "https://registry.npmjs.org/benchmark/-/benchmark-1.0.0.tgz", - "_from": "benchmark@1.0.0", - "readme": "ERROR: No README data found!" -} +{ + "name": "benchmark", + "version": "1.0.0", + "description": "A benchmarking library that works on nearly all JavaScript platforms, supports high-resolution timers, and returns statistically significant results.", + "homepage": "http://benchmarkjs.com/", + "main": "benchmark", + "keywords": [ + "benchmark", + "narwhal", + "node", + "performance", + "ringo", + "speed" + ], + "licenses": [ + { + "type": "MIT", + "url": "http://mths.be/mit" + } + ], + "author": { + "name": "Mathias Bynens", + "email": "mathias@benchmarkjs.com", + "url": "http://mathiasbynens.be/" + }, + "maintainers": [ + { + "name": "jdalton", + "email": "john@fusejs.com" + }, + { + "name": "mathias", + "email": "mathias@qiwi.be" + } + ], + "bugs": { + "url": "https://github.com/bestiejs/benchmark.js/issues", + "email": "bugs@benchmarkjs.com" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/bestiejs/benchmark.js.git" + }, + "engines": [ + "node", + "rhino" + ], + "directories": { + "doc": "./doc", + "test": "./test" + }, + "_id": "benchmark@1.0.0", + "dist": { + "shasum": "2f1e2fa4c359f11122aa183082218e957e390c73", + "tarball": "https://registry.npmjs.org/benchmark/-/benchmark-1.0.0.tgz" + }, + "_shasum": "2f1e2fa4c359f11122aa183082218e957e390c73", + "_resolved": "https://registry.npmjs.org/benchmark/-/benchmark-1.0.0.tgz", + "_from": "benchmark@1.0.0", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/benchmark/test/run-test.sh b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/benchmark/test/run-test.sh old mode 100755 new mode 100644 index 972af5d2..43424e43 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/benchmark/test/run-test.sh +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/benchmark/test/run-test.sh @@ -1,9 +1,9 @@ -cd "$(dirname "$0")" -for cmd in rhino ringo narwhal node; do - echo "" - echo "Testing in $cmd..." - $cmd test.js -done -echo "" -echo "Testing in a browser..." -open index.html +cd "$(dirname "$0")" +for cmd in rhino ringo narwhal node; do + echo "" + echo "Testing in $cmd..." + $cmd test.js +done +echo "" +echo "Testing in a browser..." +open index.html diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/benchmark/test/test.js b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/benchmark/test/test.js index 2fc87edb..d6944940 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/benchmark/test/test.js +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/benchmark/test/test.js @@ -1,2074 +1,2074 @@ -;(function(window, undefined) { - 'use strict'; - - /** Use a single load function */ - var load = typeof require == 'function' ? require : window.load; - - /** The `platform` object to check */ - var platform = - window.platform || - load('../vendor/platform.js/platform.js') || - window.platform; - - /** The unit testing framework */ - var QUnit = - window.QUnit || ( - window.setTimeout || (window.addEventListener = window.setTimeout = / /), - window.QUnit = load('../vendor/qunit/qunit/qunit' + (platform.name == 'Narwhal' ? '-1.8.0' : '') + '.js') || window.QUnit, - load('../vendor/qunit-clib/qunit-clib.js'), - (window.addEventListener || 0).test && delete window.addEventListener, - window.QUnit - ); - - /** The `Benchmark` constructor to test */ - var Benchmark = - window.Benchmark || ( - Benchmark = load('../benchmark.js') || window.Benchmark, - Benchmark.Benchmark || Benchmark - ); - - /** API shortcut */ - var forOwn = Benchmark.forOwn; - - /** Used to get property descriptors */ - var getDescriptor = Object.getOwnPropertyDescriptor; - - /** Used to set property descriptors */ - var setDescriptor = Object.defineProperty; - - /** Shortcut used to convert array-like objects to arrays */ - var slice = [].slice; - - /** Used to resolve a value's internal [[Class]] */ - var toString = {}.toString; - - /** Used to check problem JScript properties (a.k.a. the [[DontEnum]] bug) */ - var shadowed = { - 'constructor': 1, - 'hasOwnProperty': 2, - 'isPrototypeOf': 3, - 'propertyIsEnumerable': 4, - 'toLocaleString': 5, - 'toString': 6, - 'valueOf': 7 - }; - - /** Used to flag environments/features */ - var support = { - 'descriptors': !!function() { - try { - var o = {}; - return (setDescriptor(o, o, o), 'value' in getDescriptor(o, o)); - } catch(e) { } - }() - }; - - /*--------------------------------------------------------------------------*/ - - /** - * Skips a given number of tests with a passing result. - * - * @private - * @param {Number} [count=1] The number of tests to skip. - */ - function skipTest(count) { - count || (count = 1); - while (count--) { - ok(true, 'test skipped'); - } - } - - /*--------------------------------------------------------------------------*/ - - // init Benchmark.options.minTime - Benchmark(function() { throw 0; }).run(); - - // set a shorter max time - Benchmark.options.maxTime = Benchmark.options.minTime * 5; - - // explicitly call `QUnit.module()` instead of `module()` - // in case we are in a CLI environment - QUnit.module('Benchmark'); - - (function() { - test('has the default `Benchmark.platform` value', function() { - if (window.document) { - equal(String(Benchmark.platform), navigator.userAgent); - } else { - skipTest(1) - } - }); - - test('supports loading Benchmark.js as a module', function() { - if (window.document && window.require) { - equal((Benchmark2 || {}).version, Benchmark.version); - } else { - skipTest(1) - } - }); - - test('supports loading Platform.js as a module', function() { - if (window.document && window.require) { - var platform = (Benchmark2 || {}).platform || {}; - equal(typeof platform.name, 'string'); - } else { - skipTest(1) - } - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Benchmark constructor'); - - (function() { - test('creates a new instance when called without the `new` operator', function() { - ok(Benchmark() instanceof Benchmark); - }); - - test('supports passing an options object', function() { - var bench = Benchmark({ 'name': 'foo', 'fn': function() { } }); - ok(bench.fn && bench.name == 'foo'); - }); - - test('supports passing a "name" and "fn" argument', function() { - var bench = Benchmark('foo', function() { }); - ok(bench.fn && bench.name == 'foo'); - }); - - test('supports passing a "name" argument and an options object', function() { - var bench = Benchmark('foo', { 'fn': function() { } }); - ok(bench.fn && bench.name == 'foo'); - }); - - test('supports passing a "name" argument and an options object', function() { - var bench = Benchmark('foo', function() { }, { 'id': 'bar' }); - ok(bench.fn && bench.name == 'foo' && bench.id == 'bar'); - }); - - test('supports passing an empy string for the "fn" options property', function() { - var bench = Benchmark({ 'fn': '' }).run(); - ok(!bench.error); - }); - - test('detects dead code', function() { - var bench = Benchmark(function() { }).run(); - ok(/setup\(\)/.test(bench.compiled) ? !bench.error : bench.error); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Benchmark compilation'); - - (function() { - test('compiles using the default `Function#toString`', function() { - var bench = Benchmark({ - 'setup': function() { var a = 1; }, - 'fn': function() { throw a; }, - 'teardown': function() { a = 2; } - }).run(); - - var compiled = bench.compiled; - if (/setup\(\)/.test(compiled)) { - skipTest(); - } - else { - ok(/var a\s*=\s*1/.test(compiled) && /throw a/.test(compiled) && /a\s*=\s*2/.test(compiled)); - } - }); - - test('compiles using a custom "toString" method', function() { - var bench = Benchmark({ - 'setup': function() { }, - 'fn': function() { }, - 'teardown': function() { } - }); - - bench.setup.toString = function() { return 'var a = 1;' }; - bench.fn.toString = function() { return 'throw a;' }; - bench.teardown.toString = function() { return 'a = 2;' }; - bench.run(); - - var compiled = bench.compiled; - if (/setup\(\)/.test(compiled)) { - skipTest(); - } - else { - ok(/var a\s*=\s*1/.test(compiled) && /throw a/.test(compiled) && /a\s*=\s*2/.test(compiled)); - } - }); - - test('compiles using a string value', function() { - var bench = Benchmark({ - 'setup': 'var a = 1;', - 'fn': 'throw a;', - 'teardown': 'a = 2;' - }).run(); - - var compiled = bench.compiled; - if (/setup\(\)/.test(compiled)) { - skipTest(); - } - else { - ok(/var a\s*=\s*1/.test(compiled) && /throw a/.test(compiled) && /a\s*=\s*2/.test(compiled)); - } - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Benchmark test binding'); - - (function() { - var count = 0; - - var tests = { - 'inlined "setup", "fn", and "teardown"': ( - 'if(/ops/.test(this))this._fn=true;' - ), - 'called "fn" and inlined "setup"/"teardown" reached by error': function() { - count++; - if (/ops/.test(this)) { - this._fn = true; - } - }, - 'called "fn" and inlined "setup"/"teardown" reached by `return` statement': function() { - if (/ops/.test(this)) { - this._fn = true; - } - return; - } - }; - - forOwn(tests, function(fn, title) { - test('has correct binding for ' + title, function() { - var bench = Benchmark({ - 'setup': 'if(/ops/.test(this))this._setup=true;', - 'fn': fn, - 'teardown': 'if(/ops/.test(this))this._teardown=true;', - 'onCycle': function() { this.abort(); } - }).run(); - - var compiled = bench.compiled; - if (/setup\(\)/.test(compiled)) { - skipTest(3); - } - else { - ok(bench._setup, 'correct binding for "setup"'); - ok(bench._fn, 'correct binding for "fn"'); - ok(bench._teardown, 'correct binding for "teardown"'); - } - }); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Benchmark.deepClone'); - - (function() { - function createCircularObject() { - var result = { - 'foo': { 'b': { 'foo': { 'c': { } } } }, - 'bar': { } - }; - - result.foo.b.foo.c.foo = result; - result.bar.b = result.foo.b; - return result; - } - - function Klass() { - this.a = 1; - } - - Klass.prototype = { 'b': 1 }; - - var notCloneable = { - 'an arguments object': arguments, - 'an element': window.document && document.body, - 'a function': Klass, - 'a Klass instance': new Klass - }; - - var objects = { - 'an array': ['a', 'b', 'c', ''], - 'an array-like-object': { '0': 'a', '1': 'b', '2': 'c', '3': '', 'length': 5 }, - 'boolean': false, - 'boolean object': Object(false), - 'an object': { 'a': 0, 'b': 1, 'c': 3 }, - 'an object with object values': { 'a': /a/, 'b': ['B'], 'c': { 'C': 1 } }, - 'null': null, - 'a number': 3, - 'a number object': Object(3), - 'a regexp': /x/gim, - 'a string': 'x', - 'a string object': Object('x'), - 'undefined': undefined - }; - - objects['an array'].length = 5; - - forOwn(objects, function(object, key) { - test('clones ' + key + ' correctly', function() { - var kind = toString.call(object), - clone = Benchmark.deepClone(object); - - if (object == null) { - equal(clone, object); - } else { - deepEqual(clone.valueOf(), object.valueOf()); - } - if (object === Object(object)) { - ok(clone !== object); - } else { - skipTest(); - } - }); - }); - - forOwn(notCloneable, function(object, key) { - test('does not clone ' + key, function() { - ok(Benchmark.deepClone(object) === object); - }); - }); - - test('clones using Klass#deepClone', function() { - var object = new Klass; - Klass.prototype.deepClone = function() { return new Klass; }; - - var clone = Benchmark.deepClone(object); - ok(clone !== object && clone instanceof Klass); - - delete Klass.prototype.clone; - }); - - test('clones problem JScript properties', function() { - var clone = Benchmark.deepClone(shadowed); - deepEqual(clone, shadowed); - }); - - test('clones string object with custom property', function() { - var object = new String('x'); - object.x = 1; - - var clone = Benchmark.deepClone(object); - ok(clone == 'x' && typeof clone == 'object' && clone.x === 1 && toString.call(clone) == '[object String]'); - }); - - test('clones objects with circular references', function() { - var object = createCircularObject(), - clone = Benchmark.deepClone(object); - - ok(clone.bar.b === clone.foo.b && clone === clone.foo.b.foo.c.foo && clone !== object); - }); - - test('clones non-extensible objects with circular references', function() { - if (Object.preventExtensions) { - var object = Object.preventExtensions(createCircularObject()); - Object.preventExtensions(object.bar.b); - - var clone = Benchmark.deepClone(object); - ok(clone.bar.b === clone.foo.b && clone === clone.foo.b.foo.c.foo && clone !== object); - } else { - skipTest(1) - } - }); - - test('clones sealed objects with circular references', function() { - if (Object.seal) { - var object = Object.seal(createCircularObject()); - Object.seal(object.bar.b); - - var clone = Benchmark.deepClone(object); - ok(clone.bar.b === clone.foo.b && clone === clone.foo.b.foo.c.foo && clone !== object); - } else { - skipTest(1) - } - }); - - test('clones frozen objects with circular references', function() { - if (Object.freeze) { - var object = Object.freeze(createCircularObject()); - Object.freeze(object.bar.b); - - var clone = Benchmark.deepClone(object); - ok(clone.bar.b === clone.foo.b && clone === clone.foo.b.foo.c.foo && clone !== object); - } else { - skipTest(1) - } - }); - - test('clones objects with custom descriptors and circular references', function() { - var accessor, - descriptor; - - if (support.descriptors) { - var object = setDescriptor({}, 'foo', { - 'configurable': true, - 'value': setDescriptor({}, 'b', { - 'writable': true, - 'value': setDescriptor({}, 'foo', { - 'get': function() { return accessor; }, - 'set': function(value) { accessor = value; } - }) - }) - }); - - setDescriptor(object, 'bar', { 'value': {} }); - object.foo.b.foo = { 'c': object }; - object.bar.b = object.foo.b; - - var clone = Benchmark.deepClone(object); - ok(clone !== object && - clone.bar.b === clone.foo.b && - clone !== clone.foo.b.foo.c.foo && - (descriptor = getDescriptor(clone, 'foo')) && - descriptor.configurable && !(descriptor.enumerable && descriptor.writable) && - (descriptor = getDescriptor(clone.foo, 'b')) && - descriptor.writable && !(descriptor.configurable && descriptor.enumerable) && - (descriptor = getDescriptor(clone.foo.b, 'foo')) && - descriptor.get && descriptor.set && - (descriptor = getDescriptor(clone.foo.b, 'foo')) && - !(descriptor.configurable && descriptor.enumerable && descriptor.writable) && - (descriptor = getDescriptor(clone, 'bar')) && - !(descriptor.configurable && descriptor.enumerable && descriptor.writable)); - } - else { - skipTest(1) - } - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Benchmark.each'); - - (function() { - var xpathResult; - - var objects = { - 'array': ['a', 'b', 'c', ''], - 'array-like-object': { '0': 'a', '1': 'b', '2': 'c', '3': '', 'length': 5 }, - 'xpath snapshot': null - }; - - if (window.document && document.evaluate) { - xpathResult = [document.documentElement, document.getElementsByTagName('head')[0], document.body]; - objects['xpath snapshot'] = document.evaluate('//*[self::html or self::head or self::body]', document, null, 7, null); - } - - objects.array.length = 5; - - forOwn(objects, function(object, key) { - test('passes the correct arguments when passing an ' + key, function() { - if (object) { - var args - Benchmark.each(object, function() { - args || (args = slice.call(arguments)); - }); - - if (key == 'xpath snapshot') { - ok(args[0] === xpathResult[0]); - } else { - equal(args[0], 'a'); - } - equal(args[1], 0); - ok(args[2] === object); - } - else { - skipTest(3); - } - }); - - test('returns the passed object when passing an ' + key, function() { - if (object) { - var actual = Benchmark.each(object, function() { }); - ok(actual === object); - } - else { - skipTest(); - } - }); - - test('iterates over all indexes when passing an ' + key, function() { - if (object) { - var values = []; - Benchmark.each(object, function(value) { - values.push(value); - }); - - deepEqual(values, key == 'xpath snapshot' ? xpathResult : ['a', 'b', 'c', '']); - } - else { - skipTest(); - } - }); - - test('exits early when returning `false` when passing an ' + key, function() { - if (object) { - var values = []; - Benchmark.each(object, function(value) { - values.push(value); - return values.length < 2; - }); - - deepEqual(values, key == 'xpath snapshot' ? xpathResult.slice(0, 2) : ['a', 'b']); - } - else { - skipTest(); - } - }); - }); - - test('passes the third callback argument as an object', function() { - var thirdArg; - Benchmark.each('hello', function(value, index, object) { - thirdArg = object; - }); - - ok(thirdArg && typeof thirdArg == 'object'); - }); - - test('iterates over strings by index', function() { - var values = []; - Benchmark.each('hello', function(value) { - values.push(value) - }); - - deepEqual(values, ['h', 'e', 'l', 'l', 'o']); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Benchmark.extend'); - - (function() { - test('allows no source argument', function() { - var object = {}; - equal(Benchmark.extend(object), object); - }); - - test('allows a single source argument', function() { - var source = { 'x': 1, 'y': 1 }, - actual = Benchmark.extend({}, source); - - deepEqual(Benchmark.extend({}, source), { 'x': 1, 'y': 1 }); - }); - - test('allows multiple source arguments', function() { - var source1 = { 'x': 1, 'y': 1 }, - source2 = { 'y': 2, 'z': 2 }, - actual = Benchmark.extend({}, source1, source2); - - deepEqual(actual, { 'x': 1, 'y': 2, 'z': 2 }); - }); - - test('will add inherited source properties', function() { - function Source() { } - Source.prototype.x = 1; - deepEqual(Benchmark.extend({}, new Source), { 'x': 1 }); - }); - - test('will add problem JScript properties', function() { - deepEqual(Benchmark.extend({}, shadowed), shadowed); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Benchmark.filter'); - - (function() { - var objects = { - 'array': ['a', 'b', 'c', ''], - 'array-like-object': { '0': 'a', '1': 'b', '2': 'c', '3': '', 'length': 5 } - }; - - objects.array.length = 5; - - forOwn(objects, function(object, key) { - test('passes the correct arguments when passing an ' + key, function() { - var args; - Benchmark.filter(object, function() { - args || (args = slice.call(arguments)); - }); - - deepEqual(args, ['a', 0, object]); - }); - - test('produces the correct result when passing an ' + key, function() { - var actual = Benchmark.filter(object, function(value, index) { - return index > 0; - }); - - deepEqual(actual, ['b', 'c', '']); - }); - - test('iterates over sparse ' + key + 's correctly', function() { - var actual = Benchmark.filter(object, function(value) { - return value === undefined; - }); - - deepEqual(actual, []); - }); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Benchmark.forOwn'); - - (function() { - function fn() { - // no-op - } - - function KlassA() { - this.a = 1; - this.b = 2; - this.c = 3; - } - - function KlassB() { - this.a = 1; - this.constructor = 2; - this.hasOwnProperty = 3; - this.isPrototypeOf = 4; - this.propertyIsEnumerable = 5; - this.toLocaleString = 6; - this.toString = 7; - this.valueOf = 8; - } - - function KlassC() { - // no-op - } - - fn.a = 1; - fn.b = 2; - fn.c = 3; - - KlassC.prototype.a = 1; - KlassC.prototype.b = 2; - KlassC.prototype.c = 3; - - var objects = { - 'an arguments object': arguments, - 'a function': fn, - 'an object': new KlassA, - 'an object shadowing properties on Object.prototype': new KlassB, - 'a prototype object': KlassC.prototype, - 'a string': 'abc' - }; - - forOwn(objects, function(object, key) { - test('passes the correct arguments when passing ' + key, function() { - var args; - Benchmark.forOwn(object, function() { - args || (args = slice.call(arguments)); - }); - - equal(typeof args[0], key == 'a string' ? 'string' : 'number'); - equal(typeof args[1], 'string'); - equal(args[2] && typeof args[2], key == 'a function' ? 'function' : 'object'); - }); - - test('returns the passed object when passing ' + key, function() { - var actual = Benchmark.forOwn(object, function() { }); - deepEqual(actual, object); - }); - - test('iterates over own properties when passing ' + key, function() { - var values = []; - Benchmark.forOwn(object, function(value) { - values.push(value); - }); - - if (object instanceof KlassB) { - deepEqual(values.sort(), [1, 2, 3, 4, 5, 6, 7, 8]); - } else if (key == 'a string') { - deepEqual(values, ['a', 'b', 'c']); - } else { - deepEqual(values.sort(), [1, 2, 3]); - } - }); - - test('exits early when returning `false` when passing ' + key, function() { - var values = []; - Benchmark.forOwn(object, function(value) { - values.push(value); - return false; - }); - - equal(values.length, 1); - }); - - if (object instanceof KlassB) { - test('exits correctly when transitioning to the JScript [[DontEnum]] fix', function() { - var values = []; - Benchmark.forOwn(object, function(value) { - values.push(value); - return values.length < 2; - }); - - equal(values.length, 2); - }); - } - }); - }(1, 2, 3)); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Benchmark.formatNumber'); - - (function() { - test('formats a million correctly', function() { - equal(Benchmark.formatNumber(1e6), '1,000,000'); - }); - - test('formats less than 100 correctly', function() { - equal(Benchmark.formatNumber(23), '23'); - }); - - test('formats numbers with decimal values correctly', function() { - equal(Benchmark.formatNumber(1234.56), '1,234.56'); - }); - - test('formats negative numbers correctly', function() { - equal(Benchmark.formatNumber(-1234.56), '-1,234.56'); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Benchmark.hasKey'); - - (function() { - test('returns `true` for own properties', function() { - var object = { 'x': 1 }; - equal(Benchmark.hasKey(object, 'x'), true); - }); - - test('returns `false` for inherited properties', function() { - equal(Benchmark.hasKey({}, 'toString'), false); - }); - - test('doesn\'t use an object\'s `hasOwnProperty` method', function() { - var object = { 'hasOwnProperty': function() { return true; } }; - equal(Benchmark.hasKey(object, 'x'), false); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Benchmark.indexOf'); - - (function() { - var objects = { - 'array': ['a', 'b', 'c', ''], - 'array-like-object': { '0': 'a', '1': 'b', '2': 'c', '3': '', 'length': 5 } - }; - - objects.array.length = 5; - - forOwn(objects, function(object, key) { - test('produces the correct result when passing an ' + key, function() { - equal(Benchmark.indexOf(object, 'b'), 1); - }); - - test('matches values by strict equality when passing an ' + key, function() { - equal(Benchmark.indexOf(object, new String('b')), -1); - }); - - test('iterates over sparse ' + key + 's correctly', function() { - equal(Benchmark.indexOf(object, undefined), -1); - }); - }); - - test('searches from the given `fromIndex`', function() { - var array = ['a', 'b', 'c', 'a']; - equal(Benchmark.indexOf(array, 'a', 1), 3); - }); - - test('handles extreme negative `fromIndex` values correctly', function() { - var array = ['a']; - array['-1'] = 'z'; - equal(Benchmark.indexOf(array, 'z', -2), -1); - }); - - test('handles extreme positive `fromIndex` values correctly', function() { - var object = { '0': 'a', '1': 'b', '2': 'c', 'length': 2 }; - equal(Benchmark.indexOf(object, 'c', 2), -1); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Benchmark.interpolate'); - - (function() { - test('replaces tokens correctly', function() { - var actual = Benchmark.interpolate('#{greeting} #{location}.', { - 'greeting': 'Hello', - 'location': 'world' - }); - - equal(actual, 'Hello world.'); - }); - - test('ignores inherited object properties', function() { - var actual = Benchmark.interpolate('x#{toString}', {}); - equal(actual, 'x#{toString}'); - }); - - test('allows for no template object', function() { - var actual = Benchmark.interpolate('x'); - equal(actual, 'x'); - }); - - test('replaces duplicate tokens', function() { - var actual = Benchmark.interpolate('#{x}#{x}#{x}', { 'x': 'a' }); - equal(actual, 'aaa'); - }); - - test('handles keys containing RegExp special characters', function() { - var actual = Benchmark.interpolate('#{.*+?^=!:${}()|[]\\/}', { '.*+?^=!:${}()|[]\\/': 'x' }); - equal(actual, 'x'); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Benchmark.invoke'); - - (function() { - var objects = { - 'array': ['a', ['b'], 'c', null], - 'array-like-object': { '0': 'a', '1': ['b'], '2': 'c', '3': null, 'length': 5 } - }; - - objects.array.length = 5; - - forOwn(objects, function(object, key) { - test('produces the correct result when passing an ' + key, function() { - var actual = Benchmark.invoke(object, 'concat'); - deepEqual(actual, ['a', ['b'], 'c', undefined, undefined]); - equal('4' in actual, false); - }); - - test('passes the correct arguments to the invoked method when passing an ' + key, function() { - var actual = Benchmark.invoke(object, 'concat', 'x', 'y', 'z'); - deepEqual(actual, ['axyz', ['b', 'x', 'y', 'z'], 'cxyz', undefined, undefined]); - equal('4' in actual, false); - }); - - test('handles options object with callbacks correctly when passing an ' + key, function() { - function callback() { - callbacks.push(slice.call(arguments)); - } - - var callbacks = []; - var actual = Benchmark.invoke(object, { - 'name': 'concat', - 'args': ['x', 'y', 'z'], - 'onStart': callback, - 'onCycle': callback, - 'onComplete': callback - }); - - deepEqual(actual, ['axyz', ['b', 'x', 'y', 'z'], 'cxyz', undefined, undefined]); - equal('4' in actual, false); - - equal(callbacks[0].length, 1); - equal(callbacks[0][0].target, 'a'); - deepEqual(callbacks[0][0].currentTarget, object); - equal(callbacks[0][0].type, 'start'); - equal(callbacks[1][0].type, 'cycle'); - equal(callbacks[5][0].type, 'complete'); - }); - - test('supports queuing when passing an ' + key, function() { - var lengths = []; - var actual = Benchmark.invoke(object, { - 'name': 'concat', - 'queued': true, - 'args': 'x', - 'onCycle': function() { - lengths.push(object.length); - } - }); - - deepEqual(lengths, [5, 4, 3, 2]); - deepEqual(actual, ['ax', ['b', 'x'], 'cx', undefined, undefined]); - }); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Benchmark.join'); - - (function() { - var objects = { - 'array': ['a', 'b', ''], - 'array-like-object': { '0': 'a', '1': 'b', '2': '', 'length': 4 }, - 'object': { 'a': '0', 'b': '1', '': '2' } - }; - - objects.array.length = 4; - - forOwn(objects, function(object, key) { - test('joins correctly using the default separator when passing an ' + key, function() { - equal(Benchmark.join(object), key == 'object' ? 'a: 0,b: 1,: 2' : 'a,b,'); - }); - - test('joins correctly using a custom separator when passing an ' + key, function() { - equal(Benchmark.join(object, '+', '@'), key == 'object' ? 'a@0+b@1+@2' : 'a+b+'); - }); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Benchmark.map'); - - (function() { - var objects = { - 'array': ['a', 'b', 'c', ''], - 'array-like-object': { '0': 'a', '1': 'b', '2': 'c', '3': '', 'length': 5 } - }; - - objects.array.length = 5; - - forOwn(objects, function(object, key) { - test('passes the correct arguments when passing an ' + key, function() { - var args; - Benchmark.map(object, function() { - args || (args = slice.call(arguments)); - }); - - deepEqual(args, ['a', 0, object]); - }); - - test('produces the correct result when passing an ' + key, function() { - var actual = Benchmark.map(object, function(value, index) { - return value + index; - }); - - deepEqual(actual, ['a0', 'b1', 'c2', '3', undefined]); - equal('4' in actual, false); - }); - - test('produces an array of the correct length for sparse ' + key + 's', function() { - equal(Benchmark.map(object, function() { }).length, 5); - }); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Benchmark.pluck'); - - (function() { - var objects = { - 'array': [{ '_': 'a' }, { '_': 'b' }, { '_': 'c' }, null], - 'array-like-object': { '0': { '_': 'a' }, '1': { '_': 'b' }, '2': { '_': 'c' }, '3': null, 'length': 5 } - }; - - objects.array.length = 5; - - forOwn(objects, function(object, key) { - test('produces the correct result when passing an ' + key, function() { - var actual = Benchmark.pluck(object, '_'); - deepEqual(actual, ['a', 'b', 'c', undefined, undefined]); - equal('4' in actual, false); - }); - - test('produces the correct result for non-existent keys when passing an ' + key, function() { - var actual = Benchmark.pluck(object, 'non-existent'); - deepEqual(actual, [undefined, undefined, undefined, undefined, undefined]); - equal('4' in actual, false); - }); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Benchmark.reduce'); - - (function() { - var objects = { - 'array': ['b', 'c', ''], - 'array-like-object': { '0': 'b', '1': 'c', '2': '', 'length': 4 } - }; - - objects.array.length = 4; - - forOwn(objects, function(object, key) { - test('passes the correct arguments when passing an ' + key, function() { - var args; - Benchmark.reduce(object, function() { - args || (args = slice.call(arguments)); - }, 'a'); - - deepEqual(args, ['a', 'b', 0, object]); - }); - - test('accumulates correctly when passing an ' + key, function() { - var actual = Benchmark.reduce(object, function(string, value) { - return string + value; - }, 'a'); - - equal(actual, 'abc'); - }); - - test('handles arguments with no initial value correctly when passing an ' + key, function() { - var args; - Benchmark.reduce(object, function() { - args || (args = slice.call(arguments)); - }); - - deepEqual(args, ['b', 'c', 1, object]); - }); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Benchmark#clone'); - - (function() { - var bench = Benchmark(function() { this.count += 0; }).run(); - - test('produces the correct result passing no arguments', function() { - var clone = bench.clone(); - deepEqual(clone, bench); - ok(clone.stats != bench.stats && clone.times != bench.times && clone.options != bench.options); - }); - - test('produces the correct result passing a data object', function() { - var clone = bench.clone({ 'fn': '', 'name': 'foo' }); - ok(clone.fn === '' && clone.options.fn === ''); - ok(clone.name == 'foo' && clone.options.name == 'foo'); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Benchmark#run'); - - (function() { - var data = { 'onComplete': 0, 'onCycle': 0, 'onStart': 0 }; - - var bench = Benchmark({ - 'fn': function() { - this.count += 0; - }, - 'onStart': function() { - data.onStart++; - }, - 'onComplete': function() { - data.onComplete++; - } - }) - .run(); - - test('onXYZ callbacks should not be triggered by internal benchmark clones', function() { - equal(data.onStart, 1); - equal(data.onComplete, 1); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - forOwn({ - 'Benchmark': Benchmark, - 'Benchmark.Suite': Benchmark.Suite - }, - function(Constructor, namespace) { - - QUnit.module(namespace + '#emit'); - - (function() { - test('emits passed arguments', function() { - var args, - object = Constructor(); - - object.on('args', function() { args = slice.call(arguments, 1); }); - object.emit('args', 'a', 'b', 'c'); - deepEqual(args, ['a', 'b', 'c']); - }); - - test('emits with no listeners', function() { - var event = Benchmark.Event('empty'), - object = Constructor(); - - object.emit(event); - equal(event.cancelled, false); - }); - - test('emits with an event type of "toString"', function() { - var event = Benchmark.Event('toString'), - object = Constructor(); - - object.emit(event); - equal(event.cancelled, false); - }); - - test('returns the last listeners returned value', function() { - var event = Benchmark.Event('result'), - object = Constructor(); - - object.on('result', function() { return 'x'; }); - object.on('result', function() { return 'y'; }); - equal(object.emit(event), 'y'); - }); - - test('aborts the emitters listener iteration when `event.aborted` is `true`', function() { - var event = Benchmark.Event('aborted'), - object = Constructor(); - - object.on('aborted', function(event) { - event.aborted = true; - return false; - }); - - object.on('aborted', function(event) { - // should not get here - event.aborted = false; - return true; - }); - - equal(object.emit(event), false); - equal(event.aborted, true); - }); - - test('cancels the event if a listener explicitly returns `false`', function() { - var event = Benchmark.Event('cancel'), - object = Constructor(); - - object.on('cancel', function() { return false; }); - object.on('cancel', function() { return true; }); - object.emit(event); - equal(event.cancelled, true); - }); - - test('uses a shallow clone of the listeners when emitting', function() { - var event, - listener2 = function(eventObject) { eventObject.listener2 = true }, - object = Constructor(); - - object.on('shallowclone', function(eventObject) { - event = eventObject; - object.off(event.type, listener2); - }) - .on('shallowclone', listener2) - .emit('shallowclone'); - - ok(event.listener2); - }); - - test('emits a custom event object', function() { - var event = Benchmark.Event('custom'), - object = Constructor(); - - object.on('custom', function(eventObject) { eventObject.touched = true; }); - object.emit(event); - ok(event.touched); - }); - - test('sets `event.result` correctly', function() { - var event = Benchmark.Event('result'), - object = Constructor(); - - object.on('result', function() { return 'x'; }); - object.emit(event); - equal(event.result, 'x'); - }); - - test('sets `event.type` correctly', function() { - var event, - object = Constructor(); - - object.on('type', function(eventObj) { - event = eventObj; - }); - - object.emit('type'); - equal(event.type, 'type'); - }); - }()); - - /*------------------------------------------------------------------------*/ - - QUnit.module(namespace + '#listeners'); - - (function() { - test('returns the correct listeners', function() { - var listener = function() { }, - object = Constructor(); - - object.on('x', listener); - deepEqual(object.listeners('x'), [listener]); - }); - - test('returns an array and initializes previously uninitialized listeners', function() { - var object = Constructor(); - deepEqual(object.listeners('x'), []); - deepEqual(object.events, { 'x': [] }); - }); - }()); - - /*------------------------------------------------------------------------*/ - - QUnit.module(namespace + '#off'); - - (function() { - test('returns the benchmark', function() { - var listener = function() { }, - object = Constructor(); - - object.on('x', listener); - equal(object.off('x', listener), object); - }); - - test('will ignore inherited properties of the event cache', function() { - var Dummy = function() { }, - listener = function() { }, - object = Constructor(); - - Dummy.prototype.x = [listener]; - object.events = new Dummy; - - object.off('x', listener); - deepEqual(object.events.x, [listener]); - }); - - test('handles an event type and listener', function() { - var listener = function() { }, - object = Constructor(); - - object.on('x', listener); - object.off('x', listener); - deepEqual(object.events.x, []); - }); - - test('handles unregistering duplicate listeners', function() { - var listener = function() { }, - object = Constructor(); - - object.on('x', listener); - object.on('x', listener); - - var events = object.events; - object.off('x', listener); - deepEqual(events.x, [listener]); - - object.off('x', listener); - deepEqual(events.x, []); - }); - - test('handles a non-registered listener', function() { - var object = Constructor(); - object.off('x', function() { }); - equal(object.events, undefined); - }); - - test('handles space separated event type and listener', function() { - var listener = function() { }, - object = Constructor(); - - object.on('x', listener); - object.on('y', listener); - - var events = object.events; - object.off('x y', listener); - deepEqual(events.x, []); - deepEqual(events.y, []); - }); - - test('handles space separated event type and no listener', function() { - var listener1 = function() { }, - listener2 = function() { }, - object = Constructor(); - - object.on('x', listener1); - object.on('y', listener2); - - var events = object.events; - object.off('x y'); - deepEqual(events.x, []); - deepEqual(events.y, []); - }); - - test('handles no arguments', function() { - var listener1 = function() { }, - listener2 = function() { }, - listener3 = function() { }, - object = Constructor(); - - object.on('x', listener1); - object.on('y', listener2); - object.on('z', listener3); - - var events = object.events; - object.off(); - deepEqual(events.x, []); - deepEqual(events.y, []); - deepEqual(events.z, []); - }); - }()); - - /*------------------------------------------------------------------------*/ - - QUnit.module(namespace + '#on'); - - (function() { - test('returns the benchmark', function() { - var listener = function() { }, - object = Constructor(); - - equal(object.on('x', listener), object); - }); - - test('will ignore inherited properties of the event cache', function() { - var Dummy = function() { }, - listener1 = function() { }, - listener2 = function() { }, - object = Constructor(); - - Dummy.prototype.x = [listener1]; - object.events = new Dummy; - - object.on('x', listener2); - deepEqual(object.events.x, [listener2]); - }); - - test('handles an event type and listener', function() { - var listener = function() { }, - object = Constructor(); - - object.on('x', listener); - deepEqual(object.events.x, [listener]); - }); - - test('handles registering duplicate listeners', function() { - var listener = function() { }, - object = Constructor(); - - object.on('x', listener); - object.on('x', listener); - deepEqual(object.events.x, [listener, listener]); - }); - - test('handles space separated event type and listener', function() { - var listener = function() { }, - object = Constructor(); - - object.on('x y', listener); - - var events = object.events; - deepEqual(events.x, [listener]); - deepEqual(events.y, [listener]); - }); - }()); - }); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Benchmark.Suite#abort'); - - (function() { - test('igores abort calls when the suite isn\'t running', function() { - var fired = false; - var suite = Benchmark.Suite('suite', { - 'onAbort': function() { fired = true; } - }); - - suite.add('foo', function() { }); - suite.abort(); - equal(fired, false); - }); - - test('ignores abort calls from `Benchmark.Suite#reset` when the suite isn\'t running', function() { - var fired = false; - var suite = Benchmark.Suite('suite', { - 'onAbort': function() { fired = true; } - }); - - suite.add('foo', function() { }); - suite.reset(); - equal(fired, false); - }); - - asyncTest('emits an abort event when running', function() { - var fired = false; - - Benchmark.Suite({ - 'onAbort': function() { fired = true; } - }) - .on('start', function() { - this.abort(); - }) - .on('complete', function() { - ok(fired); - QUnit.start(); - }) - .add(function(){ }) - .run({ 'async': true }); - }); - - asyncTest('emits an abort event after calling `Benchmark.Suite#reset`', function() { - var fired = false; - - Benchmark.Suite({ - 'onAbort': function() { fired = true; } - }) - .on('start', function() { - this.reset(); - }) - .on('complete', function() { - ok(fired); - QUnit.start(); - }) - .add(function(){ }) - .run({ 'async': true }); - }); - - asyncTest('should abort deferred benchmark', function() { - var fired = false, - suite = Benchmark.Suite(); - - suite.on('complete', function() { - equal(fired, false); - QUnit.start(); - }) - .add('a', { - 'defer': true, - 'fn': function(deferred) { - // avoid test inlining - suite.name; - // delay resolve - setTimeout(function() { - deferred.resolve(); - suite.abort(); - }, 10); - } - }) - .add('b', { - 'defer': true, - 'fn': function(deferred) { - // avoid test inlining - suite.name; - // delay resolve - setTimeout(function() { - deferred.resolve(); - fired = true; - }, 10); - } - }) - .run(); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Benchmark.Suite#concat'); - - (function() { - var args = arguments; - - test('doesn\'t treat an arguments object like an array', function() { - var suite = Benchmark.Suite(); - deepEqual(suite.concat(args), [args]); - }); - - test('flattens array arguments', function() { - var suite = Benchmark.Suite(); - deepEqual(suite.concat([1, 2], 3, [4, 5]), [1, 2, 3, 4, 5]); - }); - - test('supports concating sparse arrays', function() { - var suite = Benchmark.Suite(); - suite[0] = 0; - suite[2] = 2; - suite.length = 3; - - var actual = suite.concat(3); - deepEqual(actual, [0, undefined, 2, 3]); - equal('1' in actual, false); - }); - - test('supports sparse arrays as arguments', function() { - var suite = Benchmark.Suite(), - sparse = []; - - sparse[0] = 0; - sparse[2] = 2; - sparse.length = 3; - - var actual = suite.concat(sparse); - deepEqual(actual, [0, undefined, 2]); - equal('1' in actual, false); - }); - - test('creates a new array', function() { - var suite = Benchmark.Suite(); - ok(suite.concat(1) !== suite); - }); - }(1, 2, 3)); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Benchmark.Suite#reverse'); - - (function() { - test('reverses the element order', function() { - var suite = Benchmark.Suite(); - suite[0] = 0; - suite[1] = 1; - suite.length = 2; - - var actual = suite.reverse(); - equal(actual, suite); - deepEqual(slice.call(actual), [1, 0]); - }); - - test('supports reversing sparse arrays', function() { - var suite = Benchmark.Suite(); - suite[0] = 0; - suite[2] = 2; - suite.length = 3; - - var actual = suite.reverse(); - equal(actual, suite); - deepEqual(slice.call(actual), [2, undefined, 0]); - equal('1' in actual, false); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Benchmark.Suite#shift'); - - (function() { - test('removes the first element', function() { - var suite = Benchmark.Suite(); - suite[0] = 0; - suite[1] = 1; - suite.length = 2; - - var actual = suite.shift(); - equal(actual, 0); - deepEqual(slice.call(suite), [1]); - }); - - test('shifts an object with no elements', function() { - var suite = Benchmark.Suite(), - actual = suite.shift(); - - equal(actual, undefined); - deepEqual(slice.call(suite), []); - }); - - test('should have no elements when length is 0 after shift', function() { - var suite = Benchmark.Suite(); - suite[0] = 0; - suite.length = 1; - suite.shift(); - - // ensure element is removed - equal('0' in suite, false); - equal(suite.length, 0); - }); - - test('supports shifting sparse arrays', function() { - var suite = Benchmark.Suite(); - suite[1] = 1; - suite[3] = 3; - suite.length = 4; - - var actual = suite.shift(); - equal(actual, undefined); - deepEqual(slice.call(suite), [1, undefined, 3]); - equal('1' in suite, false); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Benchmark.Suite#slice'); - - (function() { - var suite = Benchmark.Suite(); - suite[0] = 0; - suite[1] = 1; - suite[2] = 2; - suite[3] = 3; - suite.length = 4; - - test('works with no arguments', function() { - var actual = suite.slice(); - deepEqual(actual, [0, 1, 2, 3]); - ok(suite !== actual); - }); - - test('works with positive `start` argument', function() { - var actual = suite.slice(2); - deepEqual(actual, [2, 3]); - ok(suite !== actual); - }); - - test('works with positive `start` and `end` arguments', function() { - var actual = suite.slice(1, 3); - deepEqual(actual, [1, 2]); - ok(suite !== actual); - }); - - test('works with `end` values exceeding length', function() { - var actual = suite.slice(1, 10); - deepEqual(actual, [1, 2, 3]); - ok(suite !== actual); - }); - - test('works with negative `start` and `end` arguments', function() { - var actual = suite.slice(-3, -1); - deepEqual(actual, [1, 2]); - ok(suite !== actual); - }); - - test('works with an extreme negative `end` value', function() { - var actual = suite.slice(1, -10); - deepEqual(actual, []); - equal('-1' in actual, false); - ok(suite !== actual); - }); - - test('supports slicing sparse arrays', function() { - var sparse = Benchmark.Suite(); - sparse[1] = 1; - sparse[3] = 3; - sparse.length = 4; - - var actual = sparse.slice(0, 2); - deepEqual(actual, [undefined, 1]); - equal('0' in actual, false); - - actual = sparse.slice(1); - deepEqual(actual, [1, undefined, 3]); - equal('1' in actual, false); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Benchmark.Suite#splice'); - - (function() { - test('works with no arguments', function() { - var suite = Benchmark.Suite(); - suite[0] = 0; - suite.length = 1; - - var actual = suite.splice(); - deepEqual(actual, []); - deepEqual(slice.call(suite), [0]); - }); - - test('works with only the `start` argument', function() { - var suite = Benchmark.Suite(); - suite[0] = 0; - suite[1] = 1; - suite.length = 2; - - var actual = suite.splice(1); - deepEqual(actual, [1]); - deepEqual(slice.call(suite), [0]); - }); - - test('should have no elements when length is 0 after splice', function() { - var suite = Benchmark.Suite(); - suite[0] = 0; - suite.length = 1 - suite.splice(0, 1); - - // ensure element is removed - equal('0' in suite, false); - equal(suite.length, 0); - }); - - test('works with positive `start` argument', function() { - var suite = Benchmark.Suite(); - suite[0] = 0; - suite[1] = 3; - suite.length = 2; - - var actual = suite.splice(1, 0, 1, 2); - deepEqual(actual, []); - deepEqual(slice.call(suite), [0, 1, 2, 3]); - }); - - test('works with positive `start` and `deleteCount` arguments', function() { - var suite = Benchmark.Suite(); - suite[0] = 0; - suite[1] = 3; - suite.length = 2; - - var actual = suite.splice(1, 1, 1, 2); - deepEqual(actual, [3]); - deepEqual(slice.call(suite), [0, 1, 2]); - }); - - test('works with `deleteCount` values exceeding length', function() { - var suite = Benchmark.Suite(); - suite[0] = 0; - suite[1] = 3; - suite.length = 2; - - var actual = suite.splice(1, 10, 1, 2); - deepEqual(actual, [3]); - deepEqual(slice.call(suite), [0, 1, 2]); - }); - - test('works with negative `start` and `deleteCount` arguments', function() { - var suite = Benchmark.Suite(); - suite[0] = 0; - suite[1] = 3; - suite.length = 2; - - var actual = suite.splice(-1, -1, 1, 2); - deepEqual(actual, []); - deepEqual(slice.call(suite), [0, 1, 2, 3]); - }); - - test('works with an extreme negative `deleteCount` value', function() { - var suite = Benchmark.Suite(); - suite[0] = 0; - suite[1] = 3; - suite.length = 2; - - var actual = suite.splice(0, -10, 1, 2); - deepEqual(actual, []); - deepEqual(slice.call(suite), [1, 2, 0, 3]); - }); - - test('supports splicing sparse arrays', function() { - var suite = Benchmark.Suite(); - suite[1] = 1; - suite[3] = 3; - suite.length = 4; - - var actual = suite.splice(1, 2, 1, 2); - deepEqual(actual, [1, undefined]); - equal(actual.length, 2); - deepEqual(slice.call(suite), [undefined, 1, 2, 3]); - equal('0' in suite, false); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Benchmark.Suite#unshift'); - - (function() { - test('adds a first element', function() { - var suite = Benchmark.Suite(); - suite[0] = 1; - suite.length = 1; - - var actual = suite.unshift(0); - equal(actual, 2); - deepEqual(slice.call(suite), [0, 1]); - }); - - test('adds multiple elements to the front', function() { - var suite = Benchmark.Suite(); - suite[0] = 3; - suite.length = 1; - - var actual = suite.unshift(0, 1, 2); - equal(actual, 4); - deepEqual(slice.call(suite), [0, 1, 2, 3]); - }); - - test('supports unshifting sparse arrays', function() { - var suite = Benchmark.Suite(); - suite[1] = 2; - suite.length = 2; - - var actual = suite.unshift(0); - equal(actual, 3); - deepEqual(slice.call(suite), [0, undefined, 2]); - equal('1' in suite, false); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Benchmark.Suite filtered results onComplete'); - - (function() { - var count = 0, - suite = Benchmark.Suite(); - - suite.add('a', function() { - count++; - }) - .add('b', function() { - for (var i = 0; i < 1e6; i++) { - count++; - } - }) - .add('c', function() { - throw new TypeError; - }); - - asyncTest('should filter by fastest', function() { - suite.on('complete', function() { - suite.off(); - deepEqual(this.filter('fastest').pluck('name'), ['a']); - QUnit.start(); - }) - .run({ 'async': true }); - }); - - asyncTest('should filter by slowest', function() { - suite.on('complete', function() { - suite.off(); - deepEqual(this.filter('slowest').pluck('name'), ['b']); - QUnit.start(); - }) - .run({ 'async': true }); - }); - - asyncTest('should filter by successful', function() { - suite.on('complete', function() { - suite.off(); - deepEqual(this.filter('successful').pluck('name'), ['a', 'b']); - QUnit.start(); - }) - .run({ 'async': true }); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Benchmark.Suite event flow'); - - (function() { - var events = [], - callback = function(event) { events.push(event); }; - - var suite = Benchmark.Suite('suite', { - 'onAdd': callback, - 'onAbort': callback, - 'onClone': callback, - 'onError': callback, - 'onStart': callback, - 'onCycle': callback, - 'onComplete': callback, - 'onReset': callback - }) - .add('bench', function() { - throw null; - }, { - 'onAbort': callback, - 'onClone': callback, - 'onError': callback, - 'onStart': callback, - 'onCycle': callback, - 'onComplete': callback, - 'onReset': callback - }) - .run({ 'async': false }); - - // first Suite#onAdd - test('should emit the suite "add" event first', function() { - var event = events[0]; - ok(event.type == 'add' && event.currentTarget.name == 'suite' && event.target.name == 'bench'); - }); - - // next we start the Suite because no reset was needed - test('should emit the suite "start" event', function() { - var event = events[1]; - ok(event.type == 'start' && event.currentTarget.name == 'suite' && event.target.name == 'bench'); - }); - - // and so start the first benchmark - test('should emit the benchmark "start" event', function() { - var event = events[2]; - ok(event.type == 'start' && event.currentTarget.name == 'bench'); - }); - - // oh no! we abort because of an error - test('should emit the benchmark "error" event', function() { - var event = events[3]; - ok(event.type == 'error' && event.currentTarget.name == 'bench'); - }); - - // benchmark error triggered - test('should emit the benchmark "abort" event', function() { - var event = events[4]; - ok(event.type == 'abort' && event.currentTarget.name == 'bench'); - }); - - // we reset the benchmark as part of the abort - test('should emit the benchmark "reset" event', function() { - var event = events[5]; - ok(event.type == 'reset' && event.currentTarget.name == 'bench'); - }); - - // benchmark is cycle is finished - test('should emit the benchmark "cycle" event', function() { - var event = events[6]; - ok(event.type == 'cycle' && event.currentTarget.name == 'bench'); - }); - - // benchmark is complete - test('should emit the benchmark "complete" event', function() { - var event = events[7]; - ok(event.type == 'complete' && event.currentTarget.name == 'bench'); - }); - - // the benchmark error triggers a Suite error - test('should emit the suite "error" event', function() { - var event = events[8]; - ok(event.type == 'error' && event.currentTarget.name == 'suite' && event.target.name == 'bench'); - }); - - // the Suite cycle finishes - test('should emit the suite "cycle" event', function() { - var event = events[9]; - ok(event.type == 'cycle' && event.currentTarget.name == 'suite' && event.target.name == 'bench'); - }); - - // the Suite completes - test('finally it should emit the suite "complete" event', function() { - var event = events[10]; - ok(event.type == 'complete' && event.currentTarget.name == 'suite' && event.target.name == 'bench'); - }); - - test('emitted all expected events', function() { - ok(events.length == 11); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Deferred benchmarks'); - - (function() { - asyncTest('should run a deferred benchmark correctly', function() { - Benchmark(function(deferred) { - setTimeout(function() { deferred.resolve(); }, 1e3); - }, { - 'defer': true, - 'onComplete': function() { - equal(this.hz.toFixed(0), 1); - QUnit.start(); - } - }) - .run(); - }); - - asyncTest('should run with string values for "fn", "setup", and "teardown"', function() { - Benchmark({ - 'defer': true, - 'setup': 'var x = [3, 2, 1];', - 'fn': 'setTimeout(function() { x.sort(); deferred.resolve(); }, 10);', - 'teardown': 'x.length = 0;', - 'onComplete': function() { - ok(true); - QUnit.start(); - } - }) - .run(); - }); - - asyncTest('should run recursively', function() { - Benchmark({ - 'defer': true, - 'setup': 'var x = [3, 2, 1];', - 'fn': 'for (var i = 0; i < 100; i++) x[ i % 2 ? "sort" : "reverse" ](); deferred.resolve();', - 'teardown': 'x.length = 0;', - 'onComplete': function() { - ok(true); - QUnit.start(); - } - }) - .run(); - }); - - asyncTest('should execute "setup", "fn", and "teardown" in correct order', function() { - var fired = []; - - Benchmark({ - 'defer': true, - 'setup': function() { - fired.push('setup'); - }, - 'fn': function(deferred) { - fired.push('fn'); - setTimeout(function() { deferred.resolve(); }, 10); - }, - 'teardown': function() { - fired.push('teardown'); - }, - 'onComplete': function() { - var actual = fired.join().replace(/(fn,)+/g, '$1').replace(/(setup,fn,teardown(?:,|$))+/, '$1'); - equal(actual, 'setup,fn,teardown'); - QUnit.start(); - } - }) - .run(); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('Benchmark.deepClone'); - - (function() { - asyncTest('avoids call stack limits', function() { - var result, - count = 0, - object = {}, - recurse = function() { count++; recurse(); }; - - setTimeout(function() { - ok(result, 'avoids call stack limits (stack limit is ' + (count - 1) + ')'); - QUnit.start(); - }, 15); - - if (toString.call(window.java) == '[object JavaPackage]') { - // Java throws uncatchable errors on call stack overflows, so to avoid - // them I chose a number higher than Rhino's call stack limit without - // dynamically testing for the actual limit - count = 3e3; - } else { - try { recurse(); } catch(e) { } - } - - // exceed limit - count++; - for (var i = 0, sub = object; i <= count; i++) { - sub = sub[i] = {}; - } - - try { - for (var i = 0, sub = Benchmark.deepClone(object); sub = sub[i]; i++) { } - result = --i == count; - } catch(e) { } - }); - }()); - - /*--------------------------------------------------------------------------*/ - - // explicitly call `QUnit.start()` for Narwhal, Rhino, and RingoJS - if (!window.document) { - QUnit.start(); - } -}(typeof global == 'object' && global || this)); +;(function(window, undefined) { + 'use strict'; + + /** Use a single load function */ + var load = typeof require == 'function' ? require : window.load; + + /** The `platform` object to check */ + var platform = + window.platform || + load('../vendor/platform.js/platform.js') || + window.platform; + + /** The unit testing framework */ + var QUnit = + window.QUnit || ( + window.setTimeout || (window.addEventListener = window.setTimeout = / /), + window.QUnit = load('../vendor/qunit/qunit/qunit' + (platform.name == 'Narwhal' ? '-1.8.0' : '') + '.js') || window.QUnit, + load('../vendor/qunit-clib/qunit-clib.js'), + (window.addEventListener || 0).test && delete window.addEventListener, + window.QUnit + ); + + /** The `Benchmark` constructor to test */ + var Benchmark = + window.Benchmark || ( + Benchmark = load('../benchmark.js') || window.Benchmark, + Benchmark.Benchmark || Benchmark + ); + + /** API shortcut */ + var forOwn = Benchmark.forOwn; + + /** Used to get property descriptors */ + var getDescriptor = Object.getOwnPropertyDescriptor; + + /** Used to set property descriptors */ + var setDescriptor = Object.defineProperty; + + /** Shortcut used to convert array-like objects to arrays */ + var slice = [].slice; + + /** Used to resolve a value's internal [[Class]] */ + var toString = {}.toString; + + /** Used to check problem JScript properties (a.k.a. the [[DontEnum]] bug) */ + var shadowed = { + 'constructor': 1, + 'hasOwnProperty': 2, + 'isPrototypeOf': 3, + 'propertyIsEnumerable': 4, + 'toLocaleString': 5, + 'toString': 6, + 'valueOf': 7 + }; + + /** Used to flag environments/features */ + var support = { + 'descriptors': !!function() { + try { + var o = {}; + return (setDescriptor(o, o, o), 'value' in getDescriptor(o, o)); + } catch(e) { } + }() + }; + + /*--------------------------------------------------------------------------*/ + + /** + * Skips a given number of tests with a passing result. + * + * @private + * @param {Number} [count=1] The number of tests to skip. + */ + function skipTest(count) { + count || (count = 1); + while (count--) { + ok(true, 'test skipped'); + } + } + + /*--------------------------------------------------------------------------*/ + + // init Benchmark.options.minTime + Benchmark(function() { throw 0; }).run(); + + // set a shorter max time + Benchmark.options.maxTime = Benchmark.options.minTime * 5; + + // explicitly call `QUnit.module()` instead of `module()` + // in case we are in a CLI environment + QUnit.module('Benchmark'); + + (function() { + test('has the default `Benchmark.platform` value', function() { + if (window.document) { + equal(String(Benchmark.platform), navigator.userAgent); + } else { + skipTest(1) + } + }); + + test('supports loading Benchmark.js as a module', function() { + if (window.document && window.require) { + equal((Benchmark2 || {}).version, Benchmark.version); + } else { + skipTest(1) + } + }); + + test('supports loading Platform.js as a module', function() { + if (window.document && window.require) { + var platform = (Benchmark2 || {}).platform || {}; + equal(typeof platform.name, 'string'); + } else { + skipTest(1) + } + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Benchmark constructor'); + + (function() { + test('creates a new instance when called without the `new` operator', function() { + ok(Benchmark() instanceof Benchmark); + }); + + test('supports passing an options object', function() { + var bench = Benchmark({ 'name': 'foo', 'fn': function() { } }); + ok(bench.fn && bench.name == 'foo'); + }); + + test('supports passing a "name" and "fn" argument', function() { + var bench = Benchmark('foo', function() { }); + ok(bench.fn && bench.name == 'foo'); + }); + + test('supports passing a "name" argument and an options object', function() { + var bench = Benchmark('foo', { 'fn': function() { } }); + ok(bench.fn && bench.name == 'foo'); + }); + + test('supports passing a "name" argument and an options object', function() { + var bench = Benchmark('foo', function() { }, { 'id': 'bar' }); + ok(bench.fn && bench.name == 'foo' && bench.id == 'bar'); + }); + + test('supports passing an empy string for the "fn" options property', function() { + var bench = Benchmark({ 'fn': '' }).run(); + ok(!bench.error); + }); + + test('detects dead code', function() { + var bench = Benchmark(function() { }).run(); + ok(/setup\(\)/.test(bench.compiled) ? !bench.error : bench.error); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Benchmark compilation'); + + (function() { + test('compiles using the default `Function#toString`', function() { + var bench = Benchmark({ + 'setup': function() { var a = 1; }, + 'fn': function() { throw a; }, + 'teardown': function() { a = 2; } + }).run(); + + var compiled = bench.compiled; + if (/setup\(\)/.test(compiled)) { + skipTest(); + } + else { + ok(/var a\s*=\s*1/.test(compiled) && /throw a/.test(compiled) && /a\s*=\s*2/.test(compiled)); + } + }); + + test('compiles using a custom "toString" method', function() { + var bench = Benchmark({ + 'setup': function() { }, + 'fn': function() { }, + 'teardown': function() { } + }); + + bench.setup.toString = function() { return 'var a = 1;' }; + bench.fn.toString = function() { return 'throw a;' }; + bench.teardown.toString = function() { return 'a = 2;' }; + bench.run(); + + var compiled = bench.compiled; + if (/setup\(\)/.test(compiled)) { + skipTest(); + } + else { + ok(/var a\s*=\s*1/.test(compiled) && /throw a/.test(compiled) && /a\s*=\s*2/.test(compiled)); + } + }); + + test('compiles using a string value', function() { + var bench = Benchmark({ + 'setup': 'var a = 1;', + 'fn': 'throw a;', + 'teardown': 'a = 2;' + }).run(); + + var compiled = bench.compiled; + if (/setup\(\)/.test(compiled)) { + skipTest(); + } + else { + ok(/var a\s*=\s*1/.test(compiled) && /throw a/.test(compiled) && /a\s*=\s*2/.test(compiled)); + } + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Benchmark test binding'); + + (function() { + var count = 0; + + var tests = { + 'inlined "setup", "fn", and "teardown"': ( + 'if(/ops/.test(this))this._fn=true;' + ), + 'called "fn" and inlined "setup"/"teardown" reached by error': function() { + count++; + if (/ops/.test(this)) { + this._fn = true; + } + }, + 'called "fn" and inlined "setup"/"teardown" reached by `return` statement': function() { + if (/ops/.test(this)) { + this._fn = true; + } + return; + } + }; + + forOwn(tests, function(fn, title) { + test('has correct binding for ' + title, function() { + var bench = Benchmark({ + 'setup': 'if(/ops/.test(this))this._setup=true;', + 'fn': fn, + 'teardown': 'if(/ops/.test(this))this._teardown=true;', + 'onCycle': function() { this.abort(); } + }).run(); + + var compiled = bench.compiled; + if (/setup\(\)/.test(compiled)) { + skipTest(3); + } + else { + ok(bench._setup, 'correct binding for "setup"'); + ok(bench._fn, 'correct binding for "fn"'); + ok(bench._teardown, 'correct binding for "teardown"'); + } + }); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Benchmark.deepClone'); + + (function() { + function createCircularObject() { + var result = { + 'foo': { 'b': { 'foo': { 'c': { } } } }, + 'bar': { } + }; + + result.foo.b.foo.c.foo = result; + result.bar.b = result.foo.b; + return result; + } + + function Klass() { + this.a = 1; + } + + Klass.prototype = { 'b': 1 }; + + var notCloneable = { + 'an arguments object': arguments, + 'an element': window.document && document.body, + 'a function': Klass, + 'a Klass instance': new Klass + }; + + var objects = { + 'an array': ['a', 'b', 'c', ''], + 'an array-like-object': { '0': 'a', '1': 'b', '2': 'c', '3': '', 'length': 5 }, + 'boolean': false, + 'boolean object': Object(false), + 'an object': { 'a': 0, 'b': 1, 'c': 3 }, + 'an object with object values': { 'a': /a/, 'b': ['B'], 'c': { 'C': 1 } }, + 'null': null, + 'a number': 3, + 'a number object': Object(3), + 'a regexp': /x/gim, + 'a string': 'x', + 'a string object': Object('x'), + 'undefined': undefined + }; + + objects['an array'].length = 5; + + forOwn(objects, function(object, key) { + test('clones ' + key + ' correctly', function() { + var kind = toString.call(object), + clone = Benchmark.deepClone(object); + + if (object == null) { + equal(clone, object); + } else { + deepEqual(clone.valueOf(), object.valueOf()); + } + if (object === Object(object)) { + ok(clone !== object); + } else { + skipTest(); + } + }); + }); + + forOwn(notCloneable, function(object, key) { + test('does not clone ' + key, function() { + ok(Benchmark.deepClone(object) === object); + }); + }); + + test('clones using Klass#deepClone', function() { + var object = new Klass; + Klass.prototype.deepClone = function() { return new Klass; }; + + var clone = Benchmark.deepClone(object); + ok(clone !== object && clone instanceof Klass); + + delete Klass.prototype.clone; + }); + + test('clones problem JScript properties', function() { + var clone = Benchmark.deepClone(shadowed); + deepEqual(clone, shadowed); + }); + + test('clones string object with custom property', function() { + var object = new String('x'); + object.x = 1; + + var clone = Benchmark.deepClone(object); + ok(clone == 'x' && typeof clone == 'object' && clone.x === 1 && toString.call(clone) == '[object String]'); + }); + + test('clones objects with circular references', function() { + var object = createCircularObject(), + clone = Benchmark.deepClone(object); + + ok(clone.bar.b === clone.foo.b && clone === clone.foo.b.foo.c.foo && clone !== object); + }); + + test('clones non-extensible objects with circular references', function() { + if (Object.preventExtensions) { + var object = Object.preventExtensions(createCircularObject()); + Object.preventExtensions(object.bar.b); + + var clone = Benchmark.deepClone(object); + ok(clone.bar.b === clone.foo.b && clone === clone.foo.b.foo.c.foo && clone !== object); + } else { + skipTest(1) + } + }); + + test('clones sealed objects with circular references', function() { + if (Object.seal) { + var object = Object.seal(createCircularObject()); + Object.seal(object.bar.b); + + var clone = Benchmark.deepClone(object); + ok(clone.bar.b === clone.foo.b && clone === clone.foo.b.foo.c.foo && clone !== object); + } else { + skipTest(1) + } + }); + + test('clones frozen objects with circular references', function() { + if (Object.freeze) { + var object = Object.freeze(createCircularObject()); + Object.freeze(object.bar.b); + + var clone = Benchmark.deepClone(object); + ok(clone.bar.b === clone.foo.b && clone === clone.foo.b.foo.c.foo && clone !== object); + } else { + skipTest(1) + } + }); + + test('clones objects with custom descriptors and circular references', function() { + var accessor, + descriptor; + + if (support.descriptors) { + var object = setDescriptor({}, 'foo', { + 'configurable': true, + 'value': setDescriptor({}, 'b', { + 'writable': true, + 'value': setDescriptor({}, 'foo', { + 'get': function() { return accessor; }, + 'set': function(value) { accessor = value; } + }) + }) + }); + + setDescriptor(object, 'bar', { 'value': {} }); + object.foo.b.foo = { 'c': object }; + object.bar.b = object.foo.b; + + var clone = Benchmark.deepClone(object); + ok(clone !== object && + clone.bar.b === clone.foo.b && + clone !== clone.foo.b.foo.c.foo && + (descriptor = getDescriptor(clone, 'foo')) && + descriptor.configurable && !(descriptor.enumerable && descriptor.writable) && + (descriptor = getDescriptor(clone.foo, 'b')) && + descriptor.writable && !(descriptor.configurable && descriptor.enumerable) && + (descriptor = getDescriptor(clone.foo.b, 'foo')) && + descriptor.get && descriptor.set && + (descriptor = getDescriptor(clone.foo.b, 'foo')) && + !(descriptor.configurable && descriptor.enumerable && descriptor.writable) && + (descriptor = getDescriptor(clone, 'bar')) && + !(descriptor.configurable && descriptor.enumerable && descriptor.writable)); + } + else { + skipTest(1) + } + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Benchmark.each'); + + (function() { + var xpathResult; + + var objects = { + 'array': ['a', 'b', 'c', ''], + 'array-like-object': { '0': 'a', '1': 'b', '2': 'c', '3': '', 'length': 5 }, + 'xpath snapshot': null + }; + + if (window.document && document.evaluate) { + xpathResult = [document.documentElement, document.getElementsByTagName('head')[0], document.body]; + objects['xpath snapshot'] = document.evaluate('//*[self::html or self::head or self::body]', document, null, 7, null); + } + + objects.array.length = 5; + + forOwn(objects, function(object, key) { + test('passes the correct arguments when passing an ' + key, function() { + if (object) { + var args + Benchmark.each(object, function() { + args || (args = slice.call(arguments)); + }); + + if (key == 'xpath snapshot') { + ok(args[0] === xpathResult[0]); + } else { + equal(args[0], 'a'); + } + equal(args[1], 0); + ok(args[2] === object); + } + else { + skipTest(3); + } + }); + + test('returns the passed object when passing an ' + key, function() { + if (object) { + var actual = Benchmark.each(object, function() { }); + ok(actual === object); + } + else { + skipTest(); + } + }); + + test('iterates over all indexes when passing an ' + key, function() { + if (object) { + var values = []; + Benchmark.each(object, function(value) { + values.push(value); + }); + + deepEqual(values, key == 'xpath snapshot' ? xpathResult : ['a', 'b', 'c', '']); + } + else { + skipTest(); + } + }); + + test('exits early when returning `false` when passing an ' + key, function() { + if (object) { + var values = []; + Benchmark.each(object, function(value) { + values.push(value); + return values.length < 2; + }); + + deepEqual(values, key == 'xpath snapshot' ? xpathResult.slice(0, 2) : ['a', 'b']); + } + else { + skipTest(); + } + }); + }); + + test('passes the third callback argument as an object', function() { + var thirdArg; + Benchmark.each('hello', function(value, index, object) { + thirdArg = object; + }); + + ok(thirdArg && typeof thirdArg == 'object'); + }); + + test('iterates over strings by index', function() { + var values = []; + Benchmark.each('hello', function(value) { + values.push(value) + }); + + deepEqual(values, ['h', 'e', 'l', 'l', 'o']); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Benchmark.extend'); + + (function() { + test('allows no source argument', function() { + var object = {}; + equal(Benchmark.extend(object), object); + }); + + test('allows a single source argument', function() { + var source = { 'x': 1, 'y': 1 }, + actual = Benchmark.extend({}, source); + + deepEqual(Benchmark.extend({}, source), { 'x': 1, 'y': 1 }); + }); + + test('allows multiple source arguments', function() { + var source1 = { 'x': 1, 'y': 1 }, + source2 = { 'y': 2, 'z': 2 }, + actual = Benchmark.extend({}, source1, source2); + + deepEqual(actual, { 'x': 1, 'y': 2, 'z': 2 }); + }); + + test('will add inherited source properties', function() { + function Source() { } + Source.prototype.x = 1; + deepEqual(Benchmark.extend({}, new Source), { 'x': 1 }); + }); + + test('will add problem JScript properties', function() { + deepEqual(Benchmark.extend({}, shadowed), shadowed); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Benchmark.filter'); + + (function() { + var objects = { + 'array': ['a', 'b', 'c', ''], + 'array-like-object': { '0': 'a', '1': 'b', '2': 'c', '3': '', 'length': 5 } + }; + + objects.array.length = 5; + + forOwn(objects, function(object, key) { + test('passes the correct arguments when passing an ' + key, function() { + var args; + Benchmark.filter(object, function() { + args || (args = slice.call(arguments)); + }); + + deepEqual(args, ['a', 0, object]); + }); + + test('produces the correct result when passing an ' + key, function() { + var actual = Benchmark.filter(object, function(value, index) { + return index > 0; + }); + + deepEqual(actual, ['b', 'c', '']); + }); + + test('iterates over sparse ' + key + 's correctly', function() { + var actual = Benchmark.filter(object, function(value) { + return value === undefined; + }); + + deepEqual(actual, []); + }); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Benchmark.forOwn'); + + (function() { + function fn() { + // no-op + } + + function KlassA() { + this.a = 1; + this.b = 2; + this.c = 3; + } + + function KlassB() { + this.a = 1; + this.constructor = 2; + this.hasOwnProperty = 3; + this.isPrototypeOf = 4; + this.propertyIsEnumerable = 5; + this.toLocaleString = 6; + this.toString = 7; + this.valueOf = 8; + } + + function KlassC() { + // no-op + } + + fn.a = 1; + fn.b = 2; + fn.c = 3; + + KlassC.prototype.a = 1; + KlassC.prototype.b = 2; + KlassC.prototype.c = 3; + + var objects = { + 'an arguments object': arguments, + 'a function': fn, + 'an object': new KlassA, + 'an object shadowing properties on Object.prototype': new KlassB, + 'a prototype object': KlassC.prototype, + 'a string': 'abc' + }; + + forOwn(objects, function(object, key) { + test('passes the correct arguments when passing ' + key, function() { + var args; + Benchmark.forOwn(object, function() { + args || (args = slice.call(arguments)); + }); + + equal(typeof args[0], key == 'a string' ? 'string' : 'number'); + equal(typeof args[1], 'string'); + equal(args[2] && typeof args[2], key == 'a function' ? 'function' : 'object'); + }); + + test('returns the passed object when passing ' + key, function() { + var actual = Benchmark.forOwn(object, function() { }); + deepEqual(actual, object); + }); + + test('iterates over own properties when passing ' + key, function() { + var values = []; + Benchmark.forOwn(object, function(value) { + values.push(value); + }); + + if (object instanceof KlassB) { + deepEqual(values.sort(), [1, 2, 3, 4, 5, 6, 7, 8]); + } else if (key == 'a string') { + deepEqual(values, ['a', 'b', 'c']); + } else { + deepEqual(values.sort(), [1, 2, 3]); + } + }); + + test('exits early when returning `false` when passing ' + key, function() { + var values = []; + Benchmark.forOwn(object, function(value) { + values.push(value); + return false; + }); + + equal(values.length, 1); + }); + + if (object instanceof KlassB) { + test('exits correctly when transitioning to the JScript [[DontEnum]] fix', function() { + var values = []; + Benchmark.forOwn(object, function(value) { + values.push(value); + return values.length < 2; + }); + + equal(values.length, 2); + }); + } + }); + }(1, 2, 3)); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Benchmark.formatNumber'); + + (function() { + test('formats a million correctly', function() { + equal(Benchmark.formatNumber(1e6), '1,000,000'); + }); + + test('formats less than 100 correctly', function() { + equal(Benchmark.formatNumber(23), '23'); + }); + + test('formats numbers with decimal values correctly', function() { + equal(Benchmark.formatNumber(1234.56), '1,234.56'); + }); + + test('formats negative numbers correctly', function() { + equal(Benchmark.formatNumber(-1234.56), '-1,234.56'); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Benchmark.hasKey'); + + (function() { + test('returns `true` for own properties', function() { + var object = { 'x': 1 }; + equal(Benchmark.hasKey(object, 'x'), true); + }); + + test('returns `false` for inherited properties', function() { + equal(Benchmark.hasKey({}, 'toString'), false); + }); + + test('doesn\'t use an object\'s `hasOwnProperty` method', function() { + var object = { 'hasOwnProperty': function() { return true; } }; + equal(Benchmark.hasKey(object, 'x'), false); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Benchmark.indexOf'); + + (function() { + var objects = { + 'array': ['a', 'b', 'c', ''], + 'array-like-object': { '0': 'a', '1': 'b', '2': 'c', '3': '', 'length': 5 } + }; + + objects.array.length = 5; + + forOwn(objects, function(object, key) { + test('produces the correct result when passing an ' + key, function() { + equal(Benchmark.indexOf(object, 'b'), 1); + }); + + test('matches values by strict equality when passing an ' + key, function() { + equal(Benchmark.indexOf(object, new String('b')), -1); + }); + + test('iterates over sparse ' + key + 's correctly', function() { + equal(Benchmark.indexOf(object, undefined), -1); + }); + }); + + test('searches from the given `fromIndex`', function() { + var array = ['a', 'b', 'c', 'a']; + equal(Benchmark.indexOf(array, 'a', 1), 3); + }); + + test('handles extreme negative `fromIndex` values correctly', function() { + var array = ['a']; + array['-1'] = 'z'; + equal(Benchmark.indexOf(array, 'z', -2), -1); + }); + + test('handles extreme positive `fromIndex` values correctly', function() { + var object = { '0': 'a', '1': 'b', '2': 'c', 'length': 2 }; + equal(Benchmark.indexOf(object, 'c', 2), -1); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Benchmark.interpolate'); + + (function() { + test('replaces tokens correctly', function() { + var actual = Benchmark.interpolate('#{greeting} #{location}.', { + 'greeting': 'Hello', + 'location': 'world' + }); + + equal(actual, 'Hello world.'); + }); + + test('ignores inherited object properties', function() { + var actual = Benchmark.interpolate('x#{toString}', {}); + equal(actual, 'x#{toString}'); + }); + + test('allows for no template object', function() { + var actual = Benchmark.interpolate('x'); + equal(actual, 'x'); + }); + + test('replaces duplicate tokens', function() { + var actual = Benchmark.interpolate('#{x}#{x}#{x}', { 'x': 'a' }); + equal(actual, 'aaa'); + }); + + test('handles keys containing RegExp special characters', function() { + var actual = Benchmark.interpolate('#{.*+?^=!:${}()|[]\\/}', { '.*+?^=!:${}()|[]\\/': 'x' }); + equal(actual, 'x'); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Benchmark.invoke'); + + (function() { + var objects = { + 'array': ['a', ['b'], 'c', null], + 'array-like-object': { '0': 'a', '1': ['b'], '2': 'c', '3': null, 'length': 5 } + }; + + objects.array.length = 5; + + forOwn(objects, function(object, key) { + test('produces the correct result when passing an ' + key, function() { + var actual = Benchmark.invoke(object, 'concat'); + deepEqual(actual, ['a', ['b'], 'c', undefined, undefined]); + equal('4' in actual, false); + }); + + test('passes the correct arguments to the invoked method when passing an ' + key, function() { + var actual = Benchmark.invoke(object, 'concat', 'x', 'y', 'z'); + deepEqual(actual, ['axyz', ['b', 'x', 'y', 'z'], 'cxyz', undefined, undefined]); + equal('4' in actual, false); + }); + + test('handles options object with callbacks correctly when passing an ' + key, function() { + function callback() { + callbacks.push(slice.call(arguments)); + } + + var callbacks = []; + var actual = Benchmark.invoke(object, { + 'name': 'concat', + 'args': ['x', 'y', 'z'], + 'onStart': callback, + 'onCycle': callback, + 'onComplete': callback + }); + + deepEqual(actual, ['axyz', ['b', 'x', 'y', 'z'], 'cxyz', undefined, undefined]); + equal('4' in actual, false); + + equal(callbacks[0].length, 1); + equal(callbacks[0][0].target, 'a'); + deepEqual(callbacks[0][0].currentTarget, object); + equal(callbacks[0][0].type, 'start'); + equal(callbacks[1][0].type, 'cycle'); + equal(callbacks[5][0].type, 'complete'); + }); + + test('supports queuing when passing an ' + key, function() { + var lengths = []; + var actual = Benchmark.invoke(object, { + 'name': 'concat', + 'queued': true, + 'args': 'x', + 'onCycle': function() { + lengths.push(object.length); + } + }); + + deepEqual(lengths, [5, 4, 3, 2]); + deepEqual(actual, ['ax', ['b', 'x'], 'cx', undefined, undefined]); + }); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Benchmark.join'); + + (function() { + var objects = { + 'array': ['a', 'b', ''], + 'array-like-object': { '0': 'a', '1': 'b', '2': '', 'length': 4 }, + 'object': { 'a': '0', 'b': '1', '': '2' } + }; + + objects.array.length = 4; + + forOwn(objects, function(object, key) { + test('joins correctly using the default separator when passing an ' + key, function() { + equal(Benchmark.join(object), key == 'object' ? 'a: 0,b: 1,: 2' : 'a,b,'); + }); + + test('joins correctly using a custom separator when passing an ' + key, function() { + equal(Benchmark.join(object, '+', '@'), key == 'object' ? 'a@0+b@1+@2' : 'a+b+'); + }); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Benchmark.map'); + + (function() { + var objects = { + 'array': ['a', 'b', 'c', ''], + 'array-like-object': { '0': 'a', '1': 'b', '2': 'c', '3': '', 'length': 5 } + }; + + objects.array.length = 5; + + forOwn(objects, function(object, key) { + test('passes the correct arguments when passing an ' + key, function() { + var args; + Benchmark.map(object, function() { + args || (args = slice.call(arguments)); + }); + + deepEqual(args, ['a', 0, object]); + }); + + test('produces the correct result when passing an ' + key, function() { + var actual = Benchmark.map(object, function(value, index) { + return value + index; + }); + + deepEqual(actual, ['a0', 'b1', 'c2', '3', undefined]); + equal('4' in actual, false); + }); + + test('produces an array of the correct length for sparse ' + key + 's', function() { + equal(Benchmark.map(object, function() { }).length, 5); + }); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Benchmark.pluck'); + + (function() { + var objects = { + 'array': [{ '_': 'a' }, { '_': 'b' }, { '_': 'c' }, null], + 'array-like-object': { '0': { '_': 'a' }, '1': { '_': 'b' }, '2': { '_': 'c' }, '3': null, 'length': 5 } + }; + + objects.array.length = 5; + + forOwn(objects, function(object, key) { + test('produces the correct result when passing an ' + key, function() { + var actual = Benchmark.pluck(object, '_'); + deepEqual(actual, ['a', 'b', 'c', undefined, undefined]); + equal('4' in actual, false); + }); + + test('produces the correct result for non-existent keys when passing an ' + key, function() { + var actual = Benchmark.pluck(object, 'non-existent'); + deepEqual(actual, [undefined, undefined, undefined, undefined, undefined]); + equal('4' in actual, false); + }); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Benchmark.reduce'); + + (function() { + var objects = { + 'array': ['b', 'c', ''], + 'array-like-object': { '0': 'b', '1': 'c', '2': '', 'length': 4 } + }; + + objects.array.length = 4; + + forOwn(objects, function(object, key) { + test('passes the correct arguments when passing an ' + key, function() { + var args; + Benchmark.reduce(object, function() { + args || (args = slice.call(arguments)); + }, 'a'); + + deepEqual(args, ['a', 'b', 0, object]); + }); + + test('accumulates correctly when passing an ' + key, function() { + var actual = Benchmark.reduce(object, function(string, value) { + return string + value; + }, 'a'); + + equal(actual, 'abc'); + }); + + test('handles arguments with no initial value correctly when passing an ' + key, function() { + var args; + Benchmark.reduce(object, function() { + args || (args = slice.call(arguments)); + }); + + deepEqual(args, ['b', 'c', 1, object]); + }); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Benchmark#clone'); + + (function() { + var bench = Benchmark(function() { this.count += 0; }).run(); + + test('produces the correct result passing no arguments', function() { + var clone = bench.clone(); + deepEqual(clone, bench); + ok(clone.stats != bench.stats && clone.times != bench.times && clone.options != bench.options); + }); + + test('produces the correct result passing a data object', function() { + var clone = bench.clone({ 'fn': '', 'name': 'foo' }); + ok(clone.fn === '' && clone.options.fn === ''); + ok(clone.name == 'foo' && clone.options.name == 'foo'); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Benchmark#run'); + + (function() { + var data = { 'onComplete': 0, 'onCycle': 0, 'onStart': 0 }; + + var bench = Benchmark({ + 'fn': function() { + this.count += 0; + }, + 'onStart': function() { + data.onStart++; + }, + 'onComplete': function() { + data.onComplete++; + } + }) + .run(); + + test('onXYZ callbacks should not be triggered by internal benchmark clones', function() { + equal(data.onStart, 1); + equal(data.onComplete, 1); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + forOwn({ + 'Benchmark': Benchmark, + 'Benchmark.Suite': Benchmark.Suite + }, + function(Constructor, namespace) { + + QUnit.module(namespace + '#emit'); + + (function() { + test('emits passed arguments', function() { + var args, + object = Constructor(); + + object.on('args', function() { args = slice.call(arguments, 1); }); + object.emit('args', 'a', 'b', 'c'); + deepEqual(args, ['a', 'b', 'c']); + }); + + test('emits with no listeners', function() { + var event = Benchmark.Event('empty'), + object = Constructor(); + + object.emit(event); + equal(event.cancelled, false); + }); + + test('emits with an event type of "toString"', function() { + var event = Benchmark.Event('toString'), + object = Constructor(); + + object.emit(event); + equal(event.cancelled, false); + }); + + test('returns the last listeners returned value', function() { + var event = Benchmark.Event('result'), + object = Constructor(); + + object.on('result', function() { return 'x'; }); + object.on('result', function() { return 'y'; }); + equal(object.emit(event), 'y'); + }); + + test('aborts the emitters listener iteration when `event.aborted` is `true`', function() { + var event = Benchmark.Event('aborted'), + object = Constructor(); + + object.on('aborted', function(event) { + event.aborted = true; + return false; + }); + + object.on('aborted', function(event) { + // should not get here + event.aborted = false; + return true; + }); + + equal(object.emit(event), false); + equal(event.aborted, true); + }); + + test('cancels the event if a listener explicitly returns `false`', function() { + var event = Benchmark.Event('cancel'), + object = Constructor(); + + object.on('cancel', function() { return false; }); + object.on('cancel', function() { return true; }); + object.emit(event); + equal(event.cancelled, true); + }); + + test('uses a shallow clone of the listeners when emitting', function() { + var event, + listener2 = function(eventObject) { eventObject.listener2 = true }, + object = Constructor(); + + object.on('shallowclone', function(eventObject) { + event = eventObject; + object.off(event.type, listener2); + }) + .on('shallowclone', listener2) + .emit('shallowclone'); + + ok(event.listener2); + }); + + test('emits a custom event object', function() { + var event = Benchmark.Event('custom'), + object = Constructor(); + + object.on('custom', function(eventObject) { eventObject.touched = true; }); + object.emit(event); + ok(event.touched); + }); + + test('sets `event.result` correctly', function() { + var event = Benchmark.Event('result'), + object = Constructor(); + + object.on('result', function() { return 'x'; }); + object.emit(event); + equal(event.result, 'x'); + }); + + test('sets `event.type` correctly', function() { + var event, + object = Constructor(); + + object.on('type', function(eventObj) { + event = eventObj; + }); + + object.emit('type'); + equal(event.type, 'type'); + }); + }()); + + /*------------------------------------------------------------------------*/ + + QUnit.module(namespace + '#listeners'); + + (function() { + test('returns the correct listeners', function() { + var listener = function() { }, + object = Constructor(); + + object.on('x', listener); + deepEqual(object.listeners('x'), [listener]); + }); + + test('returns an array and initializes previously uninitialized listeners', function() { + var object = Constructor(); + deepEqual(object.listeners('x'), []); + deepEqual(object.events, { 'x': [] }); + }); + }()); + + /*------------------------------------------------------------------------*/ + + QUnit.module(namespace + '#off'); + + (function() { + test('returns the benchmark', function() { + var listener = function() { }, + object = Constructor(); + + object.on('x', listener); + equal(object.off('x', listener), object); + }); + + test('will ignore inherited properties of the event cache', function() { + var Dummy = function() { }, + listener = function() { }, + object = Constructor(); + + Dummy.prototype.x = [listener]; + object.events = new Dummy; + + object.off('x', listener); + deepEqual(object.events.x, [listener]); + }); + + test('handles an event type and listener', function() { + var listener = function() { }, + object = Constructor(); + + object.on('x', listener); + object.off('x', listener); + deepEqual(object.events.x, []); + }); + + test('handles unregistering duplicate listeners', function() { + var listener = function() { }, + object = Constructor(); + + object.on('x', listener); + object.on('x', listener); + + var events = object.events; + object.off('x', listener); + deepEqual(events.x, [listener]); + + object.off('x', listener); + deepEqual(events.x, []); + }); + + test('handles a non-registered listener', function() { + var object = Constructor(); + object.off('x', function() { }); + equal(object.events, undefined); + }); + + test('handles space separated event type and listener', function() { + var listener = function() { }, + object = Constructor(); + + object.on('x', listener); + object.on('y', listener); + + var events = object.events; + object.off('x y', listener); + deepEqual(events.x, []); + deepEqual(events.y, []); + }); + + test('handles space separated event type and no listener', function() { + var listener1 = function() { }, + listener2 = function() { }, + object = Constructor(); + + object.on('x', listener1); + object.on('y', listener2); + + var events = object.events; + object.off('x y'); + deepEqual(events.x, []); + deepEqual(events.y, []); + }); + + test('handles no arguments', function() { + var listener1 = function() { }, + listener2 = function() { }, + listener3 = function() { }, + object = Constructor(); + + object.on('x', listener1); + object.on('y', listener2); + object.on('z', listener3); + + var events = object.events; + object.off(); + deepEqual(events.x, []); + deepEqual(events.y, []); + deepEqual(events.z, []); + }); + }()); + + /*------------------------------------------------------------------------*/ + + QUnit.module(namespace + '#on'); + + (function() { + test('returns the benchmark', function() { + var listener = function() { }, + object = Constructor(); + + equal(object.on('x', listener), object); + }); + + test('will ignore inherited properties of the event cache', function() { + var Dummy = function() { }, + listener1 = function() { }, + listener2 = function() { }, + object = Constructor(); + + Dummy.prototype.x = [listener1]; + object.events = new Dummy; + + object.on('x', listener2); + deepEqual(object.events.x, [listener2]); + }); + + test('handles an event type and listener', function() { + var listener = function() { }, + object = Constructor(); + + object.on('x', listener); + deepEqual(object.events.x, [listener]); + }); + + test('handles registering duplicate listeners', function() { + var listener = function() { }, + object = Constructor(); + + object.on('x', listener); + object.on('x', listener); + deepEqual(object.events.x, [listener, listener]); + }); + + test('handles space separated event type and listener', function() { + var listener = function() { }, + object = Constructor(); + + object.on('x y', listener); + + var events = object.events; + deepEqual(events.x, [listener]); + deepEqual(events.y, [listener]); + }); + }()); + }); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Benchmark.Suite#abort'); + + (function() { + test('igores abort calls when the suite isn\'t running', function() { + var fired = false; + var suite = Benchmark.Suite('suite', { + 'onAbort': function() { fired = true; } + }); + + suite.add('foo', function() { }); + suite.abort(); + equal(fired, false); + }); + + test('ignores abort calls from `Benchmark.Suite#reset` when the suite isn\'t running', function() { + var fired = false; + var suite = Benchmark.Suite('suite', { + 'onAbort': function() { fired = true; } + }); + + suite.add('foo', function() { }); + suite.reset(); + equal(fired, false); + }); + + asyncTest('emits an abort event when running', function() { + var fired = false; + + Benchmark.Suite({ + 'onAbort': function() { fired = true; } + }) + .on('start', function() { + this.abort(); + }) + .on('complete', function() { + ok(fired); + QUnit.start(); + }) + .add(function(){ }) + .run({ 'async': true }); + }); + + asyncTest('emits an abort event after calling `Benchmark.Suite#reset`', function() { + var fired = false; + + Benchmark.Suite({ + 'onAbort': function() { fired = true; } + }) + .on('start', function() { + this.reset(); + }) + .on('complete', function() { + ok(fired); + QUnit.start(); + }) + .add(function(){ }) + .run({ 'async': true }); + }); + + asyncTest('should abort deferred benchmark', function() { + var fired = false, + suite = Benchmark.Suite(); + + suite.on('complete', function() { + equal(fired, false); + QUnit.start(); + }) + .add('a', { + 'defer': true, + 'fn': function(deferred) { + // avoid test inlining + suite.name; + // delay resolve + setTimeout(function() { + deferred.resolve(); + suite.abort(); + }, 10); + } + }) + .add('b', { + 'defer': true, + 'fn': function(deferred) { + // avoid test inlining + suite.name; + // delay resolve + setTimeout(function() { + deferred.resolve(); + fired = true; + }, 10); + } + }) + .run(); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Benchmark.Suite#concat'); + + (function() { + var args = arguments; + + test('doesn\'t treat an arguments object like an array', function() { + var suite = Benchmark.Suite(); + deepEqual(suite.concat(args), [args]); + }); + + test('flattens array arguments', function() { + var suite = Benchmark.Suite(); + deepEqual(suite.concat([1, 2], 3, [4, 5]), [1, 2, 3, 4, 5]); + }); + + test('supports concating sparse arrays', function() { + var suite = Benchmark.Suite(); + suite[0] = 0; + suite[2] = 2; + suite.length = 3; + + var actual = suite.concat(3); + deepEqual(actual, [0, undefined, 2, 3]); + equal('1' in actual, false); + }); + + test('supports sparse arrays as arguments', function() { + var suite = Benchmark.Suite(), + sparse = []; + + sparse[0] = 0; + sparse[2] = 2; + sparse.length = 3; + + var actual = suite.concat(sparse); + deepEqual(actual, [0, undefined, 2]); + equal('1' in actual, false); + }); + + test('creates a new array', function() { + var suite = Benchmark.Suite(); + ok(suite.concat(1) !== suite); + }); + }(1, 2, 3)); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Benchmark.Suite#reverse'); + + (function() { + test('reverses the element order', function() { + var suite = Benchmark.Suite(); + suite[0] = 0; + suite[1] = 1; + suite.length = 2; + + var actual = suite.reverse(); + equal(actual, suite); + deepEqual(slice.call(actual), [1, 0]); + }); + + test('supports reversing sparse arrays', function() { + var suite = Benchmark.Suite(); + suite[0] = 0; + suite[2] = 2; + suite.length = 3; + + var actual = suite.reverse(); + equal(actual, suite); + deepEqual(slice.call(actual), [2, undefined, 0]); + equal('1' in actual, false); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Benchmark.Suite#shift'); + + (function() { + test('removes the first element', function() { + var suite = Benchmark.Suite(); + suite[0] = 0; + suite[1] = 1; + suite.length = 2; + + var actual = suite.shift(); + equal(actual, 0); + deepEqual(slice.call(suite), [1]); + }); + + test('shifts an object with no elements', function() { + var suite = Benchmark.Suite(), + actual = suite.shift(); + + equal(actual, undefined); + deepEqual(slice.call(suite), []); + }); + + test('should have no elements when length is 0 after shift', function() { + var suite = Benchmark.Suite(); + suite[0] = 0; + suite.length = 1; + suite.shift(); + + // ensure element is removed + equal('0' in suite, false); + equal(suite.length, 0); + }); + + test('supports shifting sparse arrays', function() { + var suite = Benchmark.Suite(); + suite[1] = 1; + suite[3] = 3; + suite.length = 4; + + var actual = suite.shift(); + equal(actual, undefined); + deepEqual(slice.call(suite), [1, undefined, 3]); + equal('1' in suite, false); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Benchmark.Suite#slice'); + + (function() { + var suite = Benchmark.Suite(); + suite[0] = 0; + suite[1] = 1; + suite[2] = 2; + suite[3] = 3; + suite.length = 4; + + test('works with no arguments', function() { + var actual = suite.slice(); + deepEqual(actual, [0, 1, 2, 3]); + ok(suite !== actual); + }); + + test('works with positive `start` argument', function() { + var actual = suite.slice(2); + deepEqual(actual, [2, 3]); + ok(suite !== actual); + }); + + test('works with positive `start` and `end` arguments', function() { + var actual = suite.slice(1, 3); + deepEqual(actual, [1, 2]); + ok(suite !== actual); + }); + + test('works with `end` values exceeding length', function() { + var actual = suite.slice(1, 10); + deepEqual(actual, [1, 2, 3]); + ok(suite !== actual); + }); + + test('works with negative `start` and `end` arguments', function() { + var actual = suite.slice(-3, -1); + deepEqual(actual, [1, 2]); + ok(suite !== actual); + }); + + test('works with an extreme negative `end` value', function() { + var actual = suite.slice(1, -10); + deepEqual(actual, []); + equal('-1' in actual, false); + ok(suite !== actual); + }); + + test('supports slicing sparse arrays', function() { + var sparse = Benchmark.Suite(); + sparse[1] = 1; + sparse[3] = 3; + sparse.length = 4; + + var actual = sparse.slice(0, 2); + deepEqual(actual, [undefined, 1]); + equal('0' in actual, false); + + actual = sparse.slice(1); + deepEqual(actual, [1, undefined, 3]); + equal('1' in actual, false); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Benchmark.Suite#splice'); + + (function() { + test('works with no arguments', function() { + var suite = Benchmark.Suite(); + suite[0] = 0; + suite.length = 1; + + var actual = suite.splice(); + deepEqual(actual, []); + deepEqual(slice.call(suite), [0]); + }); + + test('works with only the `start` argument', function() { + var suite = Benchmark.Suite(); + suite[0] = 0; + suite[1] = 1; + suite.length = 2; + + var actual = suite.splice(1); + deepEqual(actual, [1]); + deepEqual(slice.call(suite), [0]); + }); + + test('should have no elements when length is 0 after splice', function() { + var suite = Benchmark.Suite(); + suite[0] = 0; + suite.length = 1 + suite.splice(0, 1); + + // ensure element is removed + equal('0' in suite, false); + equal(suite.length, 0); + }); + + test('works with positive `start` argument', function() { + var suite = Benchmark.Suite(); + suite[0] = 0; + suite[1] = 3; + suite.length = 2; + + var actual = suite.splice(1, 0, 1, 2); + deepEqual(actual, []); + deepEqual(slice.call(suite), [0, 1, 2, 3]); + }); + + test('works with positive `start` and `deleteCount` arguments', function() { + var suite = Benchmark.Suite(); + suite[0] = 0; + suite[1] = 3; + suite.length = 2; + + var actual = suite.splice(1, 1, 1, 2); + deepEqual(actual, [3]); + deepEqual(slice.call(suite), [0, 1, 2]); + }); + + test('works with `deleteCount` values exceeding length', function() { + var suite = Benchmark.Suite(); + suite[0] = 0; + suite[1] = 3; + suite.length = 2; + + var actual = suite.splice(1, 10, 1, 2); + deepEqual(actual, [3]); + deepEqual(slice.call(suite), [0, 1, 2]); + }); + + test('works with negative `start` and `deleteCount` arguments', function() { + var suite = Benchmark.Suite(); + suite[0] = 0; + suite[1] = 3; + suite.length = 2; + + var actual = suite.splice(-1, -1, 1, 2); + deepEqual(actual, []); + deepEqual(slice.call(suite), [0, 1, 2, 3]); + }); + + test('works with an extreme negative `deleteCount` value', function() { + var suite = Benchmark.Suite(); + suite[0] = 0; + suite[1] = 3; + suite.length = 2; + + var actual = suite.splice(0, -10, 1, 2); + deepEqual(actual, []); + deepEqual(slice.call(suite), [1, 2, 0, 3]); + }); + + test('supports splicing sparse arrays', function() { + var suite = Benchmark.Suite(); + suite[1] = 1; + suite[3] = 3; + suite.length = 4; + + var actual = suite.splice(1, 2, 1, 2); + deepEqual(actual, [1, undefined]); + equal(actual.length, 2); + deepEqual(slice.call(suite), [undefined, 1, 2, 3]); + equal('0' in suite, false); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Benchmark.Suite#unshift'); + + (function() { + test('adds a first element', function() { + var suite = Benchmark.Suite(); + suite[0] = 1; + suite.length = 1; + + var actual = suite.unshift(0); + equal(actual, 2); + deepEqual(slice.call(suite), [0, 1]); + }); + + test('adds multiple elements to the front', function() { + var suite = Benchmark.Suite(); + suite[0] = 3; + suite.length = 1; + + var actual = suite.unshift(0, 1, 2); + equal(actual, 4); + deepEqual(slice.call(suite), [0, 1, 2, 3]); + }); + + test('supports unshifting sparse arrays', function() { + var suite = Benchmark.Suite(); + suite[1] = 2; + suite.length = 2; + + var actual = suite.unshift(0); + equal(actual, 3); + deepEqual(slice.call(suite), [0, undefined, 2]); + equal('1' in suite, false); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Benchmark.Suite filtered results onComplete'); + + (function() { + var count = 0, + suite = Benchmark.Suite(); + + suite.add('a', function() { + count++; + }) + .add('b', function() { + for (var i = 0; i < 1e6; i++) { + count++; + } + }) + .add('c', function() { + throw new TypeError; + }); + + asyncTest('should filter by fastest', function() { + suite.on('complete', function() { + suite.off(); + deepEqual(this.filter('fastest').pluck('name'), ['a']); + QUnit.start(); + }) + .run({ 'async': true }); + }); + + asyncTest('should filter by slowest', function() { + suite.on('complete', function() { + suite.off(); + deepEqual(this.filter('slowest').pluck('name'), ['b']); + QUnit.start(); + }) + .run({ 'async': true }); + }); + + asyncTest('should filter by successful', function() { + suite.on('complete', function() { + suite.off(); + deepEqual(this.filter('successful').pluck('name'), ['a', 'b']); + QUnit.start(); + }) + .run({ 'async': true }); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Benchmark.Suite event flow'); + + (function() { + var events = [], + callback = function(event) { events.push(event); }; + + var suite = Benchmark.Suite('suite', { + 'onAdd': callback, + 'onAbort': callback, + 'onClone': callback, + 'onError': callback, + 'onStart': callback, + 'onCycle': callback, + 'onComplete': callback, + 'onReset': callback + }) + .add('bench', function() { + throw null; + }, { + 'onAbort': callback, + 'onClone': callback, + 'onError': callback, + 'onStart': callback, + 'onCycle': callback, + 'onComplete': callback, + 'onReset': callback + }) + .run({ 'async': false }); + + // first Suite#onAdd + test('should emit the suite "add" event first', function() { + var event = events[0]; + ok(event.type == 'add' && event.currentTarget.name == 'suite' && event.target.name == 'bench'); + }); + + // next we start the Suite because no reset was needed + test('should emit the suite "start" event', function() { + var event = events[1]; + ok(event.type == 'start' && event.currentTarget.name == 'suite' && event.target.name == 'bench'); + }); + + // and so start the first benchmark + test('should emit the benchmark "start" event', function() { + var event = events[2]; + ok(event.type == 'start' && event.currentTarget.name == 'bench'); + }); + + // oh no! we abort because of an error + test('should emit the benchmark "error" event', function() { + var event = events[3]; + ok(event.type == 'error' && event.currentTarget.name == 'bench'); + }); + + // benchmark error triggered + test('should emit the benchmark "abort" event', function() { + var event = events[4]; + ok(event.type == 'abort' && event.currentTarget.name == 'bench'); + }); + + // we reset the benchmark as part of the abort + test('should emit the benchmark "reset" event', function() { + var event = events[5]; + ok(event.type == 'reset' && event.currentTarget.name == 'bench'); + }); + + // benchmark is cycle is finished + test('should emit the benchmark "cycle" event', function() { + var event = events[6]; + ok(event.type == 'cycle' && event.currentTarget.name == 'bench'); + }); + + // benchmark is complete + test('should emit the benchmark "complete" event', function() { + var event = events[7]; + ok(event.type == 'complete' && event.currentTarget.name == 'bench'); + }); + + // the benchmark error triggers a Suite error + test('should emit the suite "error" event', function() { + var event = events[8]; + ok(event.type == 'error' && event.currentTarget.name == 'suite' && event.target.name == 'bench'); + }); + + // the Suite cycle finishes + test('should emit the suite "cycle" event', function() { + var event = events[9]; + ok(event.type == 'cycle' && event.currentTarget.name == 'suite' && event.target.name == 'bench'); + }); + + // the Suite completes + test('finally it should emit the suite "complete" event', function() { + var event = events[10]; + ok(event.type == 'complete' && event.currentTarget.name == 'suite' && event.target.name == 'bench'); + }); + + test('emitted all expected events', function() { + ok(events.length == 11); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Deferred benchmarks'); + + (function() { + asyncTest('should run a deferred benchmark correctly', function() { + Benchmark(function(deferred) { + setTimeout(function() { deferred.resolve(); }, 1e3); + }, { + 'defer': true, + 'onComplete': function() { + equal(this.hz.toFixed(0), 1); + QUnit.start(); + } + }) + .run(); + }); + + asyncTest('should run with string values for "fn", "setup", and "teardown"', function() { + Benchmark({ + 'defer': true, + 'setup': 'var x = [3, 2, 1];', + 'fn': 'setTimeout(function() { x.sort(); deferred.resolve(); }, 10);', + 'teardown': 'x.length = 0;', + 'onComplete': function() { + ok(true); + QUnit.start(); + } + }) + .run(); + }); + + asyncTest('should run recursively', function() { + Benchmark({ + 'defer': true, + 'setup': 'var x = [3, 2, 1];', + 'fn': 'for (var i = 0; i < 100; i++) x[ i % 2 ? "sort" : "reverse" ](); deferred.resolve();', + 'teardown': 'x.length = 0;', + 'onComplete': function() { + ok(true); + QUnit.start(); + } + }) + .run(); + }); + + asyncTest('should execute "setup", "fn", and "teardown" in correct order', function() { + var fired = []; + + Benchmark({ + 'defer': true, + 'setup': function() { + fired.push('setup'); + }, + 'fn': function(deferred) { + fired.push('fn'); + setTimeout(function() { deferred.resolve(); }, 10); + }, + 'teardown': function() { + fired.push('teardown'); + }, + 'onComplete': function() { + var actual = fired.join().replace(/(fn,)+/g, '$1').replace(/(setup,fn,teardown(?:,|$))+/, '$1'); + equal(actual, 'setup,fn,teardown'); + QUnit.start(); + } + }) + .run(); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('Benchmark.deepClone'); + + (function() { + asyncTest('avoids call stack limits', function() { + var result, + count = 0, + object = {}, + recurse = function() { count++; recurse(); }; + + setTimeout(function() { + ok(result, 'avoids call stack limits (stack limit is ' + (count - 1) + ')'); + QUnit.start(); + }, 15); + + if (toString.call(window.java) == '[object JavaPackage]') { + // Java throws uncatchable errors on call stack overflows, so to avoid + // them I chose a number higher than Rhino's call stack limit without + // dynamically testing for the actual limit + count = 3e3; + } else { + try { recurse(); } catch(e) { } + } + + // exceed limit + count++; + for (var i = 0, sub = object; i <= count; i++) { + sub = sub[i] = {}; + } + + try { + for (var i = 0, sub = Benchmark.deepClone(object); sub = sub[i]; i++) { } + result = --i == count; + } catch(e) { } + }); + }()); + + /*--------------------------------------------------------------------------*/ + + // explicitly call `QUnit.start()` for Narwhal, Rhino, and RingoJS + if (!window.document) { + QUnit.start(); + } +}(typeof global == 'object' && global || this)); diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/.npmignore b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/.npmignore index 3594b135..f05b1f26 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/.npmignore +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/.npmignore @@ -1,2 +1,2 @@ -node_modules -test +node_modules +test diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/.travis.yml b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/.travis.yml index f16a9690..8750e3bc 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/.travis.yml +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/.travis.yml @@ -1,4 +1,4 @@ -node_js: -- "0.8" -- "0.10" +node_js: +- "0.8" +- "0.10" language: node_js \ No newline at end of file diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/History.md b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/History.md index fffc9d7a..b898ca63 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/History.md +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/History.md @@ -1,52 +1,52 @@ - -1.1.2 / 2014-02-10 -================== - - * package: rename to "component-emitter" - * package: update "main" and "component" fields - * Add license to Readme (same format as the other components) - * created .npmignore - * travis stuff - -1.1.1 / 2013-12-01 -================== - - * fix .once adding .on to the listener - * docs: Emitter#off() - * component: add `.repo` prop - -1.1.0 / 2013-10-20 -================== - - * add `.addEventListener()` and `.removeEventListener()` aliases - -1.0.1 / 2013-06-27 -================== - - * add support for legacy ie - -1.0.0 / 2013-02-26 -================== - - * add `.off()` support for removing all listeners - -0.0.6 / 2012-10-08 -================== - - * add `this._callbacks` initialization to prevent funky gotcha - -0.0.5 / 2012-09-07 -================== - - * fix `Emitter.call(this)` usage - -0.0.3 / 2012-07-11 -================== - - * add `.listeners()` - * rename `.has()` to `.hasListeners()` - -0.0.2 / 2012-06-28 -================== - - * fix `.off()` with `.once()`-registered callbacks + +1.1.2 / 2014-02-10 +================== + + * package: rename to "component-emitter" + * package: update "main" and "component" fields + * Add license to Readme (same format as the other components) + * created .npmignore + * travis stuff + +1.1.1 / 2013-12-01 +================== + + * fix .once adding .on to the listener + * docs: Emitter#off() + * component: add `.repo` prop + +1.1.0 / 2013-10-20 +================== + + * add `.addEventListener()` and `.removeEventListener()` aliases + +1.0.1 / 2013-06-27 +================== + + * add support for legacy ie + +1.0.0 / 2013-02-26 +================== + + * add `.off()` support for removing all listeners + +0.0.6 / 2012-10-08 +================== + + * add `this._callbacks` initialization to prevent funky gotcha + +0.0.5 / 2012-09-07 +================== + + * fix `Emitter.call(this)` usage + +0.0.3 / 2012-07-11 +================== + + * add `.listeners()` + * rename `.has()` to `.hasListeners()` + +0.0.2 / 2012-06-28 +================== + + * fix `.off()` with `.once()`-registered callbacks diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/Makefile b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/Makefile index 3a62b882..4e9c8d36 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/Makefile +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/Makefile @@ -1,7 +1,7 @@ - -test: - @./node_modules/.bin/mocha \ - --require should \ - --reporter spec - + +test: + @./node_modules/.bin/mocha \ + --require should \ + --reporter spec + .PHONY: test \ No newline at end of file diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/Readme.md b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/Readme.md index 04664111..0f3f9b9f 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/Readme.md +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/Readme.md @@ -1,74 +1,74 @@ -# Emitter [![Build Status](https://travis-ci.org/component/emitter.png)](https://travis-ci.org/component/emitter) - - Event emitter component. - -## Installation - -``` -$ component install component/emitter -``` - -## API - -### Emitter(obj) - - The `Emitter` may also be used as a mixin. For example - a "plain" object may become an emitter, or you may - extend an existing prototype. - - As an `Emitter` instance: - -```js -var Emitter = require('emitter'); -var emitter = new Emitter; -emitter.emit('something'); -``` - - As a mixin: - -```js -var Emitter = require('emitter'); -var user = { name: 'tobi' }; -Emitter(user); - -user.emit('im a user'); -``` - - As a prototype mixin: - -```js -var Emitter = require('emitter'); -Emitter(User.prototype); -``` - -### Emitter#on(event, fn) - - Register an `event` handler `fn`. - -### Emitter#once(event, fn) - - Register a single-shot `event` handler `fn`, - removed immediately after it is invoked the - first time. - -### Emitter#off(event, fn) - - * Pass `event` and `fn` to remove a listener. - * Pass `event` to remove all listeners on that event. - * Pass nothing to remove all listeners on all events. - -### Emitter#emit(event, ...) - - Emit an `event` with variable option args. - -### Emitter#listeners(event) - - Return an array of callbacks, or an empty array. - -### Emitter#hasListeners(event) - - Check if this emitter has `event` handlers. - -## License - -MIT +# Emitter [![Build Status](https://travis-ci.org/component/emitter.png)](https://travis-ci.org/component/emitter) + + Event emitter component. + +## Installation + +``` +$ component install component/emitter +``` + +## API + +### Emitter(obj) + + The `Emitter` may also be used as a mixin. For example + a "plain" object may become an emitter, or you may + extend an existing prototype. + + As an `Emitter` instance: + +```js +var Emitter = require('emitter'); +var emitter = new Emitter; +emitter.emit('something'); +``` + + As a mixin: + +```js +var Emitter = require('emitter'); +var user = { name: 'tobi' }; +Emitter(user); + +user.emit('im a user'); +``` + + As a prototype mixin: + +```js +var Emitter = require('emitter'); +Emitter(User.prototype); +``` + +### Emitter#on(event, fn) + + Register an `event` handler `fn`. + +### Emitter#once(event, fn) + + Register a single-shot `event` handler `fn`, + removed immediately after it is invoked the + first time. + +### Emitter#off(event, fn) + + * Pass `event` and `fn` to remove a listener. + * Pass `event` to remove all listeners on that event. + * Pass nothing to remove all listeners on all events. + +### Emitter#emit(event, ...) + + Emit an `event` with variable option args. + +### Emitter#listeners(event) + + Return an array of callbacks, or an empty array. + +### Emitter#hasListeners(event) + + Check if this emitter has `event` handlers. + +## License + +MIT diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/bower.json b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/bower.json index f4a53bf8..c618d418 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/bower.json +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/bower.json @@ -1,21 +1,21 @@ -{ - "name": "emitter", - "description": "Event emitter", - "keywords": [ - "emitter", - "events" - ], - "version": "1.1.2", - "license": "MIT", - "main": "index.js", - "homepage": "https://github.com/component/emitter", - "ignore": [ - "**/.*", - "node_modules", - "bower_components", - "test", - "Makefile", - "package.json", - "component.json" - ] -} +{ + "name": "emitter", + "description": "Event emitter", + "keywords": [ + "emitter", + "events" + ], + "version": "1.1.2", + "license": "MIT", + "main": "index.js", + "homepage": "https://github.com/component/emitter", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "Makefile", + "package.json", + "component.json" + ] +} diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/component.json b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/component.json index 15e73979..68ba0b14 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/component.json +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/component.json @@ -1,14 +1,14 @@ -{ - "name": "emitter", - "repo": "component/emitter", - "description": "Event emitter", - "keywords": [ - "emitter", - "events" - ], - "version": "1.1.2", - "scripts": [ - "index.js" - ], - "license": "MIT" -} +{ + "name": "emitter", + "repo": "component/emitter", + "description": "Event emitter", + "keywords": [ + "emitter", + "events" + ], + "version": "1.1.2", + "scripts": [ + "index.js" + ], + "license": "MIT" +} diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/index.js b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/index.js index b78e758a..ad711633 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/index.js +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/index.js @@ -1,164 +1,164 @@ - -/** - * Expose `Emitter`. - */ - -module.exports = Emitter; - -/** - * Initialize a new `Emitter`. - * - * @api public - */ - -function Emitter(obj) { - if (obj) return mixin(obj); -}; - -/** - * Mixin the emitter properties. - * - * @param {Object} obj - * @return {Object} - * @api private - */ - -function mixin(obj) { - for (var key in Emitter.prototype) { - obj[key] = Emitter.prototype[key]; - } - return obj; -} - -/** - * Listen on the given `event` with `fn`. - * - * @param {String} event - * @param {Function} fn - * @return {Emitter} - * @api public - */ - -Emitter.prototype.on = -Emitter.prototype.addEventListener = function(event, fn){ - this._callbacks = this._callbacks || {}; - (this._callbacks[event] = this._callbacks[event] || []) - .push(fn); - return this; -}; - -/** - * Adds an `event` listener that will be invoked a single - * time then automatically removed. - * - * @param {String} event - * @param {Function} fn - * @return {Emitter} - * @api public - */ - -Emitter.prototype.once = function(event, fn){ - var self = this; - this._callbacks = this._callbacks || {}; - - function on() { - self.off(event, on); - fn.apply(this, arguments); - } - - on.fn = fn; - this.on(event, on); - return this; -}; - -/** - * Remove the given callback for `event` or all - * registered callbacks. - * - * @param {String} event - * @param {Function} fn - * @return {Emitter} - * @api public - */ - -Emitter.prototype.off = -Emitter.prototype.removeListener = -Emitter.prototype.removeAllListeners = -Emitter.prototype.removeEventListener = function(event, fn){ - this._callbacks = this._callbacks || {}; - - // all - if (0 == arguments.length) { - this._callbacks = {}; - return this; - } - - // specific event - var callbacks = this._callbacks[event]; - if (!callbacks) return this; - - // remove all handlers - if (1 == arguments.length) { - delete this._callbacks[event]; - return this; - } - - // remove specific handler - var cb; - for (var i = 0; i < callbacks.length; i++) { - cb = callbacks[i]; - if (cb === fn || cb.fn === fn) { - callbacks.splice(i, 1); - break; - } - } - return this; -}; - -/** - * Emit `event` with the given args. - * - * @param {String} event - * @param {Mixed} ... - * @return {Emitter} - */ - -Emitter.prototype.emit = function(event){ - this._callbacks = this._callbacks || {}; - var args = [].slice.call(arguments, 1) - , callbacks = this._callbacks[event]; - - if (callbacks) { - callbacks = callbacks.slice(0); - for (var i = 0, len = callbacks.length; i < len; ++i) { - callbacks[i].apply(this, args); - } - } - - return this; -}; - -/** - * Return array of callbacks for `event`. - * - * @param {String} event - * @return {Array} - * @api public - */ - -Emitter.prototype.listeners = function(event){ - this._callbacks = this._callbacks || {}; - return this._callbacks[event] || []; -}; - -/** - * Check if this emitter has `event` handlers. - * - * @param {String} event - * @return {Boolean} - * @api public - */ - -Emitter.prototype.hasListeners = function(event){ - return !! this.listeners(event).length; -}; + +/** + * Expose `Emitter`. + */ + +module.exports = Emitter; + +/** + * Initialize a new `Emitter`. + * + * @api public + */ + +function Emitter(obj) { + if (obj) return mixin(obj); +}; + +/** + * Mixin the emitter properties. + * + * @param {Object} obj + * @return {Object} + * @api private + */ + +function mixin(obj) { + for (var key in Emitter.prototype) { + obj[key] = Emitter.prototype[key]; + } + return obj; +} + +/** + * Listen on the given `event` with `fn`. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ + +Emitter.prototype.on = +Emitter.prototype.addEventListener = function(event, fn){ + this._callbacks = this._callbacks || {}; + (this._callbacks[event] = this._callbacks[event] || []) + .push(fn); + return this; +}; + +/** + * Adds an `event` listener that will be invoked a single + * time then automatically removed. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ + +Emitter.prototype.once = function(event, fn){ + var self = this; + this._callbacks = this._callbacks || {}; + + function on() { + self.off(event, on); + fn.apply(this, arguments); + } + + on.fn = fn; + this.on(event, on); + return this; +}; + +/** + * Remove the given callback for `event` or all + * registered callbacks. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ + +Emitter.prototype.off = +Emitter.prototype.removeListener = +Emitter.prototype.removeAllListeners = +Emitter.prototype.removeEventListener = function(event, fn){ + this._callbacks = this._callbacks || {}; + + // all + if (0 == arguments.length) { + this._callbacks = {}; + return this; + } + + // specific event + var callbacks = this._callbacks[event]; + if (!callbacks) return this; + + // remove all handlers + if (1 == arguments.length) { + delete this._callbacks[event]; + return this; + } + + // remove specific handler + var cb; + for (var i = 0; i < callbacks.length; i++) { + cb = callbacks[i]; + if (cb === fn || cb.fn === fn) { + callbacks.splice(i, 1); + break; + } + } + return this; +}; + +/** + * Emit `event` with the given args. + * + * @param {String} event + * @param {Mixed} ... + * @return {Emitter} + */ + +Emitter.prototype.emit = function(event){ + this._callbacks = this._callbacks || {}; + var args = [].slice.call(arguments, 1) + , callbacks = this._callbacks[event]; + + if (callbacks) { + callbacks = callbacks.slice(0); + for (var i = 0, len = callbacks.length; i < len; ++i) { + callbacks[i].apply(this, args); + } + } + + return this; +}; + +/** + * Return array of callbacks for `event`. + * + * @param {String} event + * @return {Array} + * @api public + */ + +Emitter.prototype.listeners = function(event){ + this._callbacks = this._callbacks || {}; + return this._callbacks[event] || []; +}; + +/** + * Check if this emitter has `event` handlers. + * + * @param {String} event + * @return {Boolean} + * @api public + */ + +Emitter.prototype.hasListeners = function(event){ + return !! this.listeners(event).length; +}; diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/package.json b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/package.json index 6d8846e7..d72bce08 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/package.json +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/package.json @@ -1,47 +1,47 @@ -{ - "name": "component-emitter", - "description": "Event emitter", - "version": "1.1.2", - "devDependencies": { - "mocha": "*", - "should": "*" - }, - "component": { - "scripts": { - "emitter/index.js": "index.js" - } - }, - "main": "index.js", - "repository": { - "type": "git", - "url": "git+https://github.com/component/emitter.git" - }, - "scripts": { - "test": "make test" - }, - "bugs": { - "url": "https://github.com/component/emitter/issues" - }, - "homepage": "https://github.com/component/emitter", - "_id": "component-emitter@1.1.2", - "dist": { - "shasum": "296594f2753daa63996d2af08d15a95116c9aec3", - "tarball": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.1.2.tgz" - }, - "_from": "component-emitter@1.1.2", - "_npmVersion": "1.3.24", - "_npmUser": { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - }, - "maintainers": [ - { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - } - ], - "directories": {}, - "_shasum": "296594f2753daa63996d2af08d15a95116c9aec3", - "_resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.1.2.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "component-emitter", + "description": "Event emitter", + "version": "1.1.2", + "devDependencies": { + "mocha": "*", + "should": "*" + }, + "component": { + "scripts": { + "emitter/index.js": "index.js" + } + }, + "main": "index.js", + "repository": { + "type": "git", + "url": "git+https://github.com/component/emitter.git" + }, + "scripts": { + "test": "make test" + }, + "bugs": { + "url": "https://github.com/component/emitter/issues" + }, + "homepage": "https://github.com/component/emitter", + "_id": "component-emitter@1.1.2", + "dist": { + "shasum": "296594f2753daa63996d2af08d15a95116c9aec3", + "tarball": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.1.2.tgz" + }, + "_from": "component-emitter@1.1.2", + "_npmVersion": "1.3.24", + "_npmUser": { + "name": "tootallnate", + "email": "nathan@tootallnate.net" + }, + "maintainers": [ + { + "name": "tootallnate", + "email": "nathan@tootallnate.net" + } + ], + "directories": {}, + "_shasum": "296594f2753daa63996d2af08d15a95116c9aec3", + "_resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.1.2.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/debug/Readme.md b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/debug/Readme.md index 48690134..c5a34e8b 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/debug/Readme.md +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/debug/Readme.md @@ -1,115 +1,115 @@ -# debug - - tiny node.js debugging utility modelled after node core's debugging technique. - -## Installation - -``` -$ npm install debug -``` - -## Usage - - With `debug` you simply invoke the exported function to generate your debug function, passing it a name which will determine if a noop function is returned, or a decorated `console.error`, so all of the `console` format string goodies you're used to work fine. A unique color is selected per-function for visibility. - -Example _app.js_: - -```js -var debug = require('debug')('http') - , http = require('http') - , name = 'My App'; - -// fake app - -debug('booting %s', name); - -http.createServer(function(req, res){ - debug(req.method + ' ' + req.url); - res.end('hello\n'); -}).listen(3000, function(){ - debug('listening'); -}); - -// fake worker of some kind - -require('./worker'); -``` - -Example _worker.js_: - -```js -var debug = require('debug')('worker'); - -setInterval(function(){ - debug('doing some work'); -}, 1000); -``` - - The __DEBUG__ environment variable is then used to enable these based on space or comma-delimited names. Here are some examples: - - ![debug http and worker](http://f.cl.ly/items/18471z1H402O24072r1J/Screenshot.png) - - ![debug worker](http://f.cl.ly/items/1X413v1a3M0d3C2c1E0i/Screenshot.png) - -## Millisecond diff - - When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls. - - ![](http://f.cl.ly/items/2i3h1d3t121M2Z1A3Q0N/Screenshot.png) - - When stderr is not a TTY, `Date#toUTCString()` is used, making it more useful for logging the debug information as shown below: - _(NOTE: Debug now uses stderr instead of stdout, so the correct shell command for this example is actually `DEBUG=* node example/worker 2> out &`)_ - - ![](http://f.cl.ly/items/112H3i0e0o0P0a2Q2r11/Screenshot.png) - -## Conventions - - If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". - -## Wildcards - - The "*" character may be used as a wildcard. Suppose for example your library has debuggers named "connect:bodyParser", "connect:compress", "connect:session", instead of listing all three with `DEBUG=connect:bodyParser,connect.compress,connect:session`, you may simply do `DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`. - - You can also exclude specific debuggers by prefixing them with a "-" character. For example, `DEBUG=* -connect:*` would include all debuggers except those starting with "connect:". - -## Browser support - - Debug works in the browser as well, currently persisted by `localStorage`. For example if you have `worker:a` and `worker:b` as shown below, and wish to debug both type `debug.enable('worker:*')` in the console and refresh the page, this will remain until you disable with `debug.disable()`. - -```js -a = debug('worker:a'); -b = debug('worker:b'); - -setInterval(function(){ - a('doing some work'); -}, 1000); - -setInterval(function(){ - a('doing some work'); -}, 1200); -``` - -## License - -(The MIT License) - -Copyright (c) 2011 TJ Holowaychuk <tj@vision-media.ca> - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# debug + + tiny node.js debugging utility modelled after node core's debugging technique. + +## Installation + +``` +$ npm install debug +``` + +## Usage + + With `debug` you simply invoke the exported function to generate your debug function, passing it a name which will determine if a noop function is returned, or a decorated `console.error`, so all of the `console` format string goodies you're used to work fine. A unique color is selected per-function for visibility. + +Example _app.js_: + +```js +var debug = require('debug')('http') + , http = require('http') + , name = 'My App'; + +// fake app + +debug('booting %s', name); + +http.createServer(function(req, res){ + debug(req.method + ' ' + req.url); + res.end('hello\n'); +}).listen(3000, function(){ + debug('listening'); +}); + +// fake worker of some kind + +require('./worker'); +``` + +Example _worker.js_: + +```js +var debug = require('debug')('worker'); + +setInterval(function(){ + debug('doing some work'); +}, 1000); +``` + + The __DEBUG__ environment variable is then used to enable these based on space or comma-delimited names. Here are some examples: + + ![debug http and worker](http://f.cl.ly/items/18471z1H402O24072r1J/Screenshot.png) + + ![debug worker](http://f.cl.ly/items/1X413v1a3M0d3C2c1E0i/Screenshot.png) + +## Millisecond diff + + When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls. + + ![](http://f.cl.ly/items/2i3h1d3t121M2Z1A3Q0N/Screenshot.png) + + When stderr is not a TTY, `Date#toUTCString()` is used, making it more useful for logging the debug information as shown below: + _(NOTE: Debug now uses stderr instead of stdout, so the correct shell command for this example is actually `DEBUG=* node example/worker 2> out &`)_ + + ![](http://f.cl.ly/items/112H3i0e0o0P0a2Q2r11/Screenshot.png) + +## Conventions + + If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". + +## Wildcards + + The "*" character may be used as a wildcard. Suppose for example your library has debuggers named "connect:bodyParser", "connect:compress", "connect:session", instead of listing all three with `DEBUG=connect:bodyParser,connect.compress,connect:session`, you may simply do `DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`. + + You can also exclude specific debuggers by prefixing them with a "-" character. For example, `DEBUG=* -connect:*` would include all debuggers except those starting with "connect:". + +## Browser support + + Debug works in the browser as well, currently persisted by `localStorage`. For example if you have `worker:a` and `worker:b` as shown below, and wish to debug both type `debug.enable('worker:*')` in the console and refresh the page, this will remain until you disable with `debug.disable()`. + +```js +a = debug('worker:a'); +b = debug('worker:b'); + +setInterval(function(){ + a('doing some work'); +}, 1000); + +setInterval(function(){ + a('doing some work'); +}, 1200); +``` + +## License + +(The MIT License) + +Copyright (c) 2011 TJ Holowaychuk <tj@vision-media.ca> + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/debug/debug.js b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/debug/debug.js index 5c8cebe8..509dc0de 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/debug/debug.js +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/debug/debug.js @@ -1,137 +1,137 @@ - -/** - * Expose `debug()` as the module. - */ - -module.exports = debug; - -/** - * Create a debugger with the given `name`. - * - * @param {String} name - * @return {Type} - * @api public - */ - -function debug(name) { - if (!debug.enabled(name)) return function(){}; - - return function(fmt){ - fmt = coerce(fmt); - - var curr = new Date; - var ms = curr - (debug[name] || curr); - debug[name] = curr; - - fmt = name - + ' ' - + fmt - + ' +' + debug.humanize(ms); - - // This hackery is required for IE8 - // where `console.log` doesn't have 'apply' - window.console - && console.log - && Function.prototype.apply.call(console.log, console, arguments); - } -} - -/** - * The currently active debug mode names. - */ - -debug.names = []; -debug.skips = []; - -/** - * Enables a debug mode by name. This can include modes - * separated by a colon and wildcards. - * - * @param {String} name - * @api public - */ - -debug.enable = function(name) { - try { - localStorage.debug = name; - } catch(e){} - - var split = (name || '').split(/[\s,]+/) - , len = split.length; - - for (var i = 0; i < len; i++) { - name = split[i].replace('*', '.*?'); - if (name[0] === '-') { - debug.skips.push(new RegExp('^' + name.substr(1) + '$')); - } - else { - debug.names.push(new RegExp('^' + name + '$')); - } - } -}; - -/** - * Disable debug output. - * - * @api public - */ - -debug.disable = function(){ - debug.enable(''); -}; - -/** - * Humanize the given `ms`. - * - * @param {Number} m - * @return {String} - * @api private - */ - -debug.humanize = function(ms) { - var sec = 1000 - , min = 60 * 1000 - , hour = 60 * min; - - if (ms >= hour) return (ms / hour).toFixed(1) + 'h'; - if (ms >= min) return (ms / min).toFixed(1) + 'm'; - if (ms >= sec) return (ms / sec | 0) + 's'; - return ms + 'ms'; -}; - -/** - * Returns true if the given mode name is enabled, false otherwise. - * - * @param {String} name - * @return {Boolean} - * @api public - */ - -debug.enabled = function(name) { - for (var i = 0, len = debug.skips.length; i < len; i++) { - if (debug.skips[i].test(name)) { - return false; - } - } - for (var i = 0, len = debug.names.length; i < len; i++) { - if (debug.names[i].test(name)) { - return true; - } - } - return false; -}; - -/** - * Coerce `val`. - */ - -function coerce(val) { - if (val instanceof Error) return val.stack || val.message; - return val; -} - -// persist - -try { - if (window.localStorage) debug.enable(localStorage.debug); -} catch(e){} + +/** + * Expose `debug()` as the module. + */ + +module.exports = debug; + +/** + * Create a debugger with the given `name`. + * + * @param {String} name + * @return {Type} + * @api public + */ + +function debug(name) { + if (!debug.enabled(name)) return function(){}; + + return function(fmt){ + fmt = coerce(fmt); + + var curr = new Date; + var ms = curr - (debug[name] || curr); + debug[name] = curr; + + fmt = name + + ' ' + + fmt + + ' +' + debug.humanize(ms); + + // This hackery is required for IE8 + // where `console.log` doesn't have 'apply' + window.console + && console.log + && Function.prototype.apply.call(console.log, console, arguments); + } +} + +/** + * The currently active debug mode names. + */ + +debug.names = []; +debug.skips = []; + +/** + * Enables a debug mode by name. This can include modes + * separated by a colon and wildcards. + * + * @param {String} name + * @api public + */ + +debug.enable = function(name) { + try { + localStorage.debug = name; + } catch(e){} + + var split = (name || '').split(/[\s,]+/) + , len = split.length; + + for (var i = 0; i < len; i++) { + name = split[i].replace('*', '.*?'); + if (name[0] === '-') { + debug.skips.push(new RegExp('^' + name.substr(1) + '$')); + } + else { + debug.names.push(new RegExp('^' + name + '$')); + } + } +}; + +/** + * Disable debug output. + * + * @api public + */ + +debug.disable = function(){ + debug.enable(''); +}; + +/** + * Humanize the given `ms`. + * + * @param {Number} m + * @return {String} + * @api private + */ + +debug.humanize = function(ms) { + var sec = 1000 + , min = 60 * 1000 + , hour = 60 * min; + + if (ms >= hour) return (ms / hour).toFixed(1) + 'h'; + if (ms >= min) return (ms / min).toFixed(1) + 'm'; + if (ms >= sec) return (ms / sec | 0) + 's'; + return ms + 'ms'; +}; + +/** + * Returns true if the given mode name is enabled, false otherwise. + * + * @param {String} name + * @return {Boolean} + * @api public + */ + +debug.enabled = function(name) { + for (var i = 0, len = debug.skips.length; i < len; i++) { + if (debug.skips[i].test(name)) { + return false; + } + } + for (var i = 0, len = debug.names.length; i < len; i++) { + if (debug.names[i].test(name)) { + return true; + } + } + return false; +}; + +/** + * Coerce `val`. + */ + +function coerce(val) { + if (val instanceof Error) return val.stack || val.message; + return val; +} + +// persist + +try { + if (window.localStorage) debug.enable(localStorage.debug); +} catch(e){} diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/debug/index.js b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/debug/index.js index c4ac7e13..e02c13b7 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/debug/index.js +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/debug/index.js @@ -1,5 +1,5 @@ -if ('undefined' == typeof window) { - module.exports = require('./lib/debug'); -} else { - module.exports = require('./debug'); -} +if ('undefined' == typeof window) { + module.exports = require('./lib/debug'); +} else { + module.exports = require('./debug'); +} diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/debug/lib/debug.js b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/debug/lib/debug.js index 307efed4..3b0a9183 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/debug/lib/debug.js +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/debug/lib/debug.js @@ -1,147 +1,147 @@ -/** - * Module dependencies. - */ - -var tty = require('tty'); - -/** - * Expose `debug()` as the module. - */ - -module.exports = debug; - -/** - * Enabled debuggers. - */ - -var names = [] - , skips = []; - -(process.env.DEBUG || '') - .split(/[\s,]+/) - .forEach(function(name){ - name = name.replace('*', '.*?'); - if (name[0] === '-') { - skips.push(new RegExp('^' + name.substr(1) + '$')); - } else { - names.push(new RegExp('^' + name + '$')); - } - }); - -/** - * Colors. - */ - -var colors = [6, 2, 3, 4, 5, 1]; - -/** - * Previous debug() call. - */ - -var prev = {}; - -/** - * Previously assigned color. - */ - -var prevColor = 0; - -/** - * Is stdout a TTY? Colored output is disabled when `true`. - */ - -var isatty = tty.isatty(2); - -/** - * Select a color. - * - * @return {Number} - * @api private - */ - -function color() { - return colors[prevColor++ % colors.length]; -} - -/** - * Humanize the given `ms`. - * - * @param {Number} m - * @return {String} - * @api private - */ - -function humanize(ms) { - var sec = 1000 - , min = 60 * 1000 - , hour = 60 * min; - - if (ms >= hour) return (ms / hour).toFixed(1) + 'h'; - if (ms >= min) return (ms / min).toFixed(1) + 'm'; - if (ms >= sec) return (ms / sec | 0) + 's'; - return ms + 'ms'; -} - -/** - * Create a debugger with the given `name`. - * - * @param {String} name - * @return {Type} - * @api public - */ - -function debug(name) { - function disabled(){} - disabled.enabled = false; - - var match = skips.some(function(re){ - return re.test(name); - }); - - if (match) return disabled; - - match = names.some(function(re){ - return re.test(name); - }); - - if (!match) return disabled; - var c = color(); - - function colored(fmt) { - fmt = coerce(fmt); - - var curr = new Date; - var ms = curr - (prev[name] || curr); - prev[name] = curr; - - fmt = ' \u001b[9' + c + 'm' + name + ' ' - + '\u001b[3' + c + 'm\u001b[90m' - + fmt + '\u001b[3' + c + 'm' - + ' +' + humanize(ms) + '\u001b[0m'; - - console.error.apply(this, arguments); - } - - function plain(fmt) { - fmt = coerce(fmt); - - fmt = new Date().toUTCString() - + ' ' + name + ' ' + fmt; - console.error.apply(this, arguments); - } - - colored.enabled = plain.enabled = true; - - return isatty || process.env.DEBUG_COLORS - ? colored - : plain; -} - -/** - * Coerce `val`. - */ - -function coerce(val) { - if (val instanceof Error) return val.stack || val.message; - return val; -} +/** + * Module dependencies. + */ + +var tty = require('tty'); + +/** + * Expose `debug()` as the module. + */ + +module.exports = debug; + +/** + * Enabled debuggers. + */ + +var names = [] + , skips = []; + +(process.env.DEBUG || '') + .split(/[\s,]+/) + .forEach(function(name){ + name = name.replace('*', '.*?'); + if (name[0] === '-') { + skips.push(new RegExp('^' + name.substr(1) + '$')); + } else { + names.push(new RegExp('^' + name + '$')); + } + }); + +/** + * Colors. + */ + +var colors = [6, 2, 3, 4, 5, 1]; + +/** + * Previous debug() call. + */ + +var prev = {}; + +/** + * Previously assigned color. + */ + +var prevColor = 0; + +/** + * Is stdout a TTY? Colored output is disabled when `true`. + */ + +var isatty = tty.isatty(2); + +/** + * Select a color. + * + * @return {Number} + * @api private + */ + +function color() { + return colors[prevColor++ % colors.length]; +} + +/** + * Humanize the given `ms`. + * + * @param {Number} m + * @return {String} + * @api private + */ + +function humanize(ms) { + var sec = 1000 + , min = 60 * 1000 + , hour = 60 * min; + + if (ms >= hour) return (ms / hour).toFixed(1) + 'h'; + if (ms >= min) return (ms / min).toFixed(1) + 'm'; + if (ms >= sec) return (ms / sec | 0) + 's'; + return ms + 'ms'; +} + +/** + * Create a debugger with the given `name`. + * + * @param {String} name + * @return {Type} + * @api public + */ + +function debug(name) { + function disabled(){} + disabled.enabled = false; + + var match = skips.some(function(re){ + return re.test(name); + }); + + if (match) return disabled; + + match = names.some(function(re){ + return re.test(name); + }); + + if (!match) return disabled; + var c = color(); + + function colored(fmt) { + fmt = coerce(fmt); + + var curr = new Date; + var ms = curr - (prev[name] || curr); + prev[name] = curr; + + fmt = ' \u001b[9' + c + 'm' + name + ' ' + + '\u001b[3' + c + 'm\u001b[90m' + + fmt + '\u001b[3' + c + 'm' + + ' +' + humanize(ms) + '\u001b[0m'; + + console.error.apply(this, arguments); + } + + function plain(fmt) { + fmt = coerce(fmt); + + fmt = new Date().toUTCString() + + ' ' + name + ' ' + fmt; + console.error.apply(this, arguments); + } + + colored.enabled = plain.enabled = true; + + return isatty || process.env.DEBUG_COLORS + ? colored + : plain; +} + +/** + * Coerce `val`. + */ + +function coerce(val) { + if (val instanceof Error) return val.stack || val.message; + return val; +} diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/debug/package.json b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/debug/package.json index 6a730269..69fc942a 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/debug/package.json +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/debug/package.json @@ -1,63 +1,63 @@ -{ - "name": "debug", - "version": "0.7.4", - "repository": { - "type": "git", - "url": "git://github.com/visionmedia/debug.git" - }, - "description": "small debugging utility", - "keywords": [ - "debug", - "log", - "debugger" - ], - "author": { - "name": "TJ Holowaychuk", - "email": "tj@vision-media.ca" - }, - "dependencies": {}, - "devDependencies": { - "mocha": "*" - }, - "main": "lib/debug.js", - "browser": "./debug.js", - "engines": { - "node": "*" - }, - "files": [ - "lib/debug.js", - "debug.js", - "index.js" - ], - "component": { - "scripts": { - "debug/index.js": "index.js", - "debug/debug.js": "debug.js" - } - }, - "bugs": { - "url": "https://github.com/visionmedia/debug/issues" - }, - "homepage": "https://github.com/visionmedia/debug", - "_id": "debug@0.7.4", - "dist": { - "shasum": "06e1ea8082c2cb14e39806e22e2f6f757f92af39", - "tarball": "https://registry.npmjs.org/debug/-/debug-0.7.4.tgz" - }, - "_from": "debug@0.7.4", - "_npmVersion": "1.3.13", - "_npmUser": { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - "maintainers": [ - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - } - ], - "directories": {}, - "_shasum": "06e1ea8082c2cb14e39806e22e2f6f757f92af39", - "_resolved": "https://registry.npmjs.org/debug/-/debug-0.7.4.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "debug", + "version": "0.7.4", + "repository": { + "type": "git", + "url": "git://github.com/visionmedia/debug.git" + }, + "description": "small debugging utility", + "keywords": [ + "debug", + "log", + "debugger" + ], + "author": { + "name": "TJ Holowaychuk", + "email": "tj@vision-media.ca" + }, + "dependencies": {}, + "devDependencies": { + "mocha": "*" + }, + "main": "lib/debug.js", + "browser": "./debug.js", + "engines": { + "node": "*" + }, + "files": [ + "lib/debug.js", + "debug.js", + "index.js" + ], + "component": { + "scripts": { + "debug/index.js": "index.js", + "debug/debug.js": "debug.js" + } + }, + "bugs": { + "url": "https://github.com/visionmedia/debug/issues" + }, + "homepage": "https://github.com/visionmedia/debug", + "_id": "debug@0.7.4", + "dist": { + "shasum": "06e1ea8082c2cb14e39806e22e2f6f757f92af39", + "tarball": "https://registry.npmjs.org/debug/-/debug-0.7.4.tgz" + }, + "_from": "debug@0.7.4", + "_npmVersion": "1.3.13", + "_npmUser": { + "name": "tjholowaychuk", + "email": "tj@vision-media.ca" + }, + "maintainers": [ + { + "name": "tjholowaychuk", + "email": "tj@vision-media.ca" + } + ], + "directories": {}, + "_shasum": "06e1ea8082c2cb14e39806e22e2f6f757f92af39", + "_resolved": "https://registry.npmjs.org/debug/-/debug-0.7.4.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/isarray/README.md b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/isarray/README.md index 0bda6119..052a62b8 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/isarray/README.md +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/isarray/README.md @@ -1,54 +1,54 @@ - -# isarray - -`Array#isArray` for older browsers. - -## Usage - -```js -var isArray = require('isarray'); - -console.log(isArray([])); // => true -console.log(isArray({})); // => false -``` - -## Installation - -With [npm](http://npmjs.org) do - -```bash -$ npm install isarray -``` - -Then bundle for the browser with -[browserify](https://github.com/substack/browserify). - -With [component](http://component.io) do - -```bash -$ component install juliangruber/isarray -``` - -## License - -(MIT) - -Copyright (c) 2013 Julian Gruber <julian@juliangruber.com> - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. + +# isarray + +`Array#isArray` for older browsers. + +## Usage + +```js +var isArray = require('isarray'); + +console.log(isArray([])); // => true +console.log(isArray({})); // => false +``` + +## Installation + +With [npm](http://npmjs.org) do + +```bash +$ npm install isarray +``` + +Then bundle for the browser with +[browserify](https://github.com/substack/browserify). + +With [component](http://component.io) do + +```bash +$ component install juliangruber/isarray +``` + +## License + +(MIT) + +Copyright (c) 2013 Julian Gruber <julian@juliangruber.com> + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/isarray/build/build.js b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/isarray/build/build.js index 204cba26..ec58596a 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/isarray/build/build.js +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/isarray/build/build.js @@ -1,209 +1,209 @@ - -/** - * Require the given path. - * - * @param {String} path - * @return {Object} exports - * @api public - */ - -function require(path, parent, orig) { - var resolved = require.resolve(path); - - // lookup failed - if (null == resolved) { - orig = orig || path; - parent = parent || 'root'; - var err = new Error('Failed to require "' + orig + '" from "' + parent + '"'); - err.path = orig; - err.parent = parent; - err.require = true; - throw err; - } - - var module = require.modules[resolved]; - - // perform real require() - // by invoking the module's - // registered function - if (!module.exports) { - module.exports = {}; - module.client = module.component = true; - module.call(this, module.exports, require.relative(resolved), module); - } - - return module.exports; -} - -/** - * Registered modules. - */ - -require.modules = {}; - -/** - * Registered aliases. - */ - -require.aliases = {}; - -/** - * Resolve `path`. - * - * Lookup: - * - * - PATH/index.js - * - PATH.js - * - PATH - * - * @param {String} path - * @return {String} path or null - * @api private - */ - -require.resolve = function(path) { - if (path.charAt(0) === '/') path = path.slice(1); - var index = path + '/index.js'; - - var paths = [ - path, - path + '.js', - path + '.json', - path + '/index.js', - path + '/index.json' - ]; - - for (var i = 0; i < paths.length; i++) { - var path = paths[i]; - if (require.modules.hasOwnProperty(path)) return path; - } - - if (require.aliases.hasOwnProperty(index)) { - return require.aliases[index]; - } -}; - -/** - * Normalize `path` relative to the current path. - * - * @param {String} curr - * @param {String} path - * @return {String} - * @api private - */ - -require.normalize = function(curr, path) { - var segs = []; - - if ('.' != path.charAt(0)) return path; - - curr = curr.split('/'); - path = path.split('/'); - - for (var i = 0; i < path.length; ++i) { - if ('..' == path[i]) { - curr.pop(); - } else if ('.' != path[i] && '' != path[i]) { - segs.push(path[i]); - } - } - - return curr.concat(segs).join('/'); -}; - -/** - * Register module at `path` with callback `definition`. - * - * @param {String} path - * @param {Function} definition - * @api private - */ - -require.register = function(path, definition) { - require.modules[path] = definition; -}; - -/** - * Alias a module definition. - * - * @param {String} from - * @param {String} to - * @api private - */ - -require.alias = function(from, to) { - if (!require.modules.hasOwnProperty(from)) { - throw new Error('Failed to alias "' + from + '", it does not exist'); - } - require.aliases[to] = from; -}; - -/** - * Return a require function relative to the `parent` path. - * - * @param {String} parent - * @return {Function} - * @api private - */ - -require.relative = function(parent) { - var p = require.normalize(parent, '..'); - - /** - * lastIndexOf helper. - */ - - function lastIndexOf(arr, obj) { - var i = arr.length; - while (i--) { - if (arr[i] === obj) return i; - } - return -1; - } - - /** - * The relative require() itself. - */ - - function localRequire(path) { - var resolved = localRequire.resolve(path); - return require(resolved, parent, path); - } - - /** - * Resolve relative to the parent. - */ - - localRequire.resolve = function(path) { - var c = path.charAt(0); - if ('/' == c) return path.slice(1); - if ('.' == c) return require.normalize(p, path); - - // resolve deps by returning - // the dep in the nearest "deps" - // directory - var segs = parent.split('/'); - var i = lastIndexOf(segs, 'deps') + 1; - if (!i) i = 0; - path = segs.slice(0, i + 1).join('/') + '/deps/' + path; - return path; - }; - - /** - * Check if module is defined at `path`. - */ - - localRequire.exists = function(path) { - return require.modules.hasOwnProperty(localRequire.resolve(path)); - }; - - return localRequire; -}; -require.register("isarray/index.js", function(exports, require, module){ -module.exports = Array.isArray || function (arr) { - return Object.prototype.toString.call(arr) == '[object Array]'; -}; - -}); -require.alias("isarray/index.js", "isarray/index.js"); - + +/** + * Require the given path. + * + * @param {String} path + * @return {Object} exports + * @api public + */ + +function require(path, parent, orig) { + var resolved = require.resolve(path); + + // lookup failed + if (null == resolved) { + orig = orig || path; + parent = parent || 'root'; + var err = new Error('Failed to require "' + orig + '" from "' + parent + '"'); + err.path = orig; + err.parent = parent; + err.require = true; + throw err; + } + + var module = require.modules[resolved]; + + // perform real require() + // by invoking the module's + // registered function + if (!module.exports) { + module.exports = {}; + module.client = module.component = true; + module.call(this, module.exports, require.relative(resolved), module); + } + + return module.exports; +} + +/** + * Registered modules. + */ + +require.modules = {}; + +/** + * Registered aliases. + */ + +require.aliases = {}; + +/** + * Resolve `path`. + * + * Lookup: + * + * - PATH/index.js + * - PATH.js + * - PATH + * + * @param {String} path + * @return {String} path or null + * @api private + */ + +require.resolve = function(path) { + if (path.charAt(0) === '/') path = path.slice(1); + var index = path + '/index.js'; + + var paths = [ + path, + path + '.js', + path + '.json', + path + '/index.js', + path + '/index.json' + ]; + + for (var i = 0; i < paths.length; i++) { + var path = paths[i]; + if (require.modules.hasOwnProperty(path)) return path; + } + + if (require.aliases.hasOwnProperty(index)) { + return require.aliases[index]; + } +}; + +/** + * Normalize `path` relative to the current path. + * + * @param {String} curr + * @param {String} path + * @return {String} + * @api private + */ + +require.normalize = function(curr, path) { + var segs = []; + + if ('.' != path.charAt(0)) return path; + + curr = curr.split('/'); + path = path.split('/'); + + for (var i = 0; i < path.length; ++i) { + if ('..' == path[i]) { + curr.pop(); + } else if ('.' != path[i] && '' != path[i]) { + segs.push(path[i]); + } + } + + return curr.concat(segs).join('/'); +}; + +/** + * Register module at `path` with callback `definition`. + * + * @param {String} path + * @param {Function} definition + * @api private + */ + +require.register = function(path, definition) { + require.modules[path] = definition; +}; + +/** + * Alias a module definition. + * + * @param {String} from + * @param {String} to + * @api private + */ + +require.alias = function(from, to) { + if (!require.modules.hasOwnProperty(from)) { + throw new Error('Failed to alias "' + from + '", it does not exist'); + } + require.aliases[to] = from; +}; + +/** + * Return a require function relative to the `parent` path. + * + * @param {String} parent + * @return {Function} + * @api private + */ + +require.relative = function(parent) { + var p = require.normalize(parent, '..'); + + /** + * lastIndexOf helper. + */ + + function lastIndexOf(arr, obj) { + var i = arr.length; + while (i--) { + if (arr[i] === obj) return i; + } + return -1; + } + + /** + * The relative require() itself. + */ + + function localRequire(path) { + var resolved = localRequire.resolve(path); + return require(resolved, parent, path); + } + + /** + * Resolve relative to the parent. + */ + + localRequire.resolve = function(path) { + var c = path.charAt(0); + if ('/' == c) return path.slice(1); + if ('.' == c) return require.normalize(p, path); + + // resolve deps by returning + // the dep in the nearest "deps" + // directory + var segs = parent.split('/'); + var i = lastIndexOf(segs, 'deps') + 1; + if (!i) i = 0; + path = segs.slice(0, i + 1).join('/') + '/deps/' + path; + return path; + }; + + /** + * Check if module is defined at `path`. + */ + + localRequire.exists = function(path) { + return require.modules.hasOwnProperty(localRequire.resolve(path)); + }; + + return localRequire; +}; +require.register("isarray/index.js", function(exports, require, module){ +module.exports = Array.isArray || function (arr) { + return Object.prototype.toString.call(arr) == '[object Array]'; +}; + +}); +require.alias("isarray/index.js", "isarray/index.js"); + diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/isarray/component.json b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/isarray/component.json index d21b0c89..9e31b683 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/isarray/component.json +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/isarray/component.json @@ -1,19 +1,19 @@ -{ - "name" : "isarray", - "description" : "Array#isArray for older browsers", - "version" : "0.0.1", - "repository" : "juliangruber/isarray", - "homepage": "https://github.com/juliangruber/isarray", - "main" : "index.js", - "scripts" : [ - "index.js" - ], - "dependencies" : {}, - "keywords": ["browser","isarray","array"], - "author": { - "name": "Julian Gruber", - "email": "mail@juliangruber.com", - "url": "http://juliangruber.com" - }, - "license": "MIT" -} +{ + "name" : "isarray", + "description" : "Array#isArray for older browsers", + "version" : "0.0.1", + "repository" : "juliangruber/isarray", + "homepage": "https://github.com/juliangruber/isarray", + "main" : "index.js", + "scripts" : [ + "index.js" + ], + "dependencies" : {}, + "keywords": ["browser","isarray","array"], + "author": { + "name": "Julian Gruber", + "email": "mail@juliangruber.com", + "url": "http://juliangruber.com" + }, + "license": "MIT" +} diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/isarray/index.js b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/isarray/index.js index 25533a38..5f5ad45d 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/isarray/index.js +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/isarray/index.js @@ -1,3 +1,3 @@ -module.exports = Array.isArray || function (arr) { - return Object.prototype.toString.call(arr) == '[object Array]'; -}; +module.exports = Array.isArray || function (arr) { + return Object.prototype.toString.call(arr) == '[object Array]'; +}; diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/isarray/package.json b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/isarray/package.json index d6ef34cd..060e073f 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/isarray/package.json +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/isarray/package.json @@ -1,53 +1,53 @@ -{ - "name": "isarray", - "description": "Array#isArray for older browsers", - "version": "0.0.1", - "repository": { - "type": "git", - "url": "git://github.com/juliangruber/isarray.git" - }, - "homepage": "https://github.com/juliangruber/isarray", - "main": "index.js", - "scripts": { - "test": "tap test/*.js" - }, - "dependencies": {}, - "devDependencies": { - "tap": "*" - }, - "keywords": [ - "browser", - "isarray", - "array" - ], - "author": { - "name": "Julian Gruber", - "email": "mail@juliangruber.com", - "url": "http://juliangruber.com" - }, - "license": "MIT", - "_id": "isarray@0.0.1", - "dist": { - "shasum": "8a18acfca9a8f4177e09abfc6038939b05d1eedf", - "tarball": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" - }, - "_from": "isarray@0.0.1", - "_npmVersion": "1.2.18", - "_npmUser": { - "name": "juliangruber", - "email": "julian@juliangruber.com" - }, - "maintainers": [ - { - "name": "juliangruber", - "email": "julian@juliangruber.com" - } - ], - "directories": {}, - "_shasum": "8a18acfca9a8f4177e09abfc6038939b05d1eedf", - "_resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "bugs": { - "url": "https://github.com/juliangruber/isarray/issues" - }, - "readme": "ERROR: No README data found!" -} +{ + "name": "isarray", + "description": "Array#isArray for older browsers", + "version": "0.0.1", + "repository": { + "type": "git", + "url": "git://github.com/juliangruber/isarray.git" + }, + "homepage": "https://github.com/juliangruber/isarray", + "main": "index.js", + "scripts": { + "test": "tap test/*.js" + }, + "dependencies": {}, + "devDependencies": { + "tap": "*" + }, + "keywords": [ + "browser", + "isarray", + "array" + ], + "author": { + "name": "Julian Gruber", + "email": "mail@juliangruber.com", + "url": "http://juliangruber.com" + }, + "license": "MIT", + "_id": "isarray@0.0.1", + "dist": { + "shasum": "8a18acfca9a8f4177e09abfc6038939b05d1eedf", + "tarball": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" + }, + "_from": "isarray@0.0.1", + "_npmVersion": "1.2.18", + "_npmUser": { + "name": "juliangruber", + "email": "julian@juliangruber.com" + }, + "maintainers": [ + { + "name": "juliangruber", + "email": "julian@juliangruber.com" + } + ], + "directories": {}, + "_shasum": "8a18acfca9a8f4177e09abfc6038939b05d1eedf", + "_resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "bugs": { + "url": "https://github.com/juliangruber/isarray/issues" + }, + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/.gitmodules b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/.gitmodules index e496e673..dc5a1740 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/.gitmodules +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/.gitmodules @@ -1,6 +1,6 @@ -[submodule "vendor/spec"] - path = vendor/spec - url = git://github.com/kitcambridge/spec.git -[submodule "vendor/marked"] - path = vendor/marked - url = git://github.com/chjj/marked.git +[submodule "vendor/spec"] + path = vendor/spec + url = git://github.com/kitcambridge/spec.git +[submodule "vendor/marked"] + path = vendor/marked + url = git://github.com/chjj/marked.git diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/.jamignore b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/.jamignore index 0c5184b9..ab53ee0a 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/.jamignore +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/.jamignore @@ -1,10 +1,10 @@ -.* -build.js -index.html -component.json -bower.json -index.js -benchmark -page -test -vendor +.* +build.js +index.html +component.json +bower.json +index.js +benchmark +page +test +vendor diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/.npmignore b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/.npmignore index 30dc6b66..6b67b559 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/.npmignore +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/.npmignore @@ -1,11 +1,11 @@ -bower.json -component.json -build.js -index.html -index.js -.jshintrc - -benchmark -page -test -vendor +bower.json +component.json +build.js +index.html +index.js +.jshintrc + +benchmark +page +test +vendor diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/.travis.yml b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/.travis.yml index f98cca87..d8e3ae78 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/.travis.yml +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/.travis.yml @@ -1,33 +1,33 @@ -language: node_js -node_js: - - "0.6" - - "0.8" - - "0.10" -env: - matrix: - - BIN="node" - - BIN="phantomjs" -matrix: - include: - - node_js: "0.10" - env: BIN="narwhal" - - node_js: "0.10" - env: BIN="rhino" - - node_js: "0.10" - env: BIN="ringo" -git: - depth: 10 -branches: - only: - - gh-pages -before_install: - - "[ $BIN == 'istanbul' ] && npm i -g istanbul@\"~0.1.0\" || true" - - "[ $BIN == 'narwhal' ] && wget https://github.com/280north/narwhal/archive/v0.3.2.zip && sudo unzip v0.3.2 -d /opt/ && rm v0.3.2.zip || true" - - "[ $BIN == 'narwhal' ] && sudo ln -s /opt/narwhal-0.3.2/bin/narwhal /usr/local/bin/narwhal && sudo chmod +x /usr/local/bin/narwhal || true" - - "[ $BIN == 'rhino' ] && sudo mkdir /opt/rhino-1.7R5 && sudo wget -O /opt/rhino-1.7R5/js.jar https://oss.sonatype.org/content/repositories/snapshots/org/mozilla/rhino/1.7R5-SNAPSHOT/rhino-1.7R5-20120629.144839-4.jar || true" - - "[ $BIN == 'rhino' ] && echo -e '#!/bin/sh\\njava -jar /opt/rhino-1.7R5/js.jar $@' | sudo tee /usr/local/bin/rhino && sudo chmod +x /usr/local/bin/rhino || true" - - "[ $BIN == 'ringo' ] && wget http://ringojs.org/downloads/ringojs-0.9.zip && sudo unzip ringojs-0.9 -d /opt && rm ringojs-0.9.zip || true" - - "[ $BIN == 'ringo' ] && sudo ln -s /opt/ringojs-0.9/bin/ringo /usr/local/bin/ringo && sudo chmod +x /usr/local/bin/ringo || true" -install: true -script: - - "[ $BIN == 'istanbul' ] && $BIN cover ./test/test_json3.js || cd test && $BIN ./test_json3.js" +language: node_js +node_js: + - "0.6" + - "0.8" + - "0.10" +env: + matrix: + - BIN="node" + - BIN="phantomjs" +matrix: + include: + - node_js: "0.10" + env: BIN="narwhal" + - node_js: "0.10" + env: BIN="rhino" + - node_js: "0.10" + env: BIN="ringo" +git: + depth: 10 +branches: + only: + - gh-pages +before_install: + - "[ $BIN == 'istanbul' ] && npm i -g istanbul@\"~0.1.0\" || true" + - "[ $BIN == 'narwhal' ] && wget https://github.com/280north/narwhal/archive/v0.3.2.zip && sudo unzip v0.3.2 -d /opt/ && rm v0.3.2.zip || true" + - "[ $BIN == 'narwhal' ] && sudo ln -s /opt/narwhal-0.3.2/bin/narwhal /usr/local/bin/narwhal && sudo chmod +x /usr/local/bin/narwhal || true" + - "[ $BIN == 'rhino' ] && sudo mkdir /opt/rhino-1.7R5 && sudo wget -O /opt/rhino-1.7R5/js.jar https://oss.sonatype.org/content/repositories/snapshots/org/mozilla/rhino/1.7R5-SNAPSHOT/rhino-1.7R5-20120629.144839-4.jar || true" + - "[ $BIN == 'rhino' ] && echo -e '#!/bin/sh\\njava -jar /opt/rhino-1.7R5/js.jar $@' | sudo tee /usr/local/bin/rhino && sudo chmod +x /usr/local/bin/rhino || true" + - "[ $BIN == 'ringo' ] && wget http://ringojs.org/downloads/ringojs-0.9.zip && sudo unzip ringojs-0.9 -d /opt && rm ringojs-0.9.zip || true" + - "[ $BIN == 'ringo' ] && sudo ln -s /opt/ringojs-0.9/bin/ringo /usr/local/bin/ringo && sudo chmod +x /usr/local/bin/ringo || true" +install: true +script: + - "[ $BIN == 'istanbul' ] && $BIN cover ./test/test_json3.js || cd test && $BIN ./test_json3.js" diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/LICENSE b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/LICENSE index 2d5f7560..6d42c549 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/LICENSE +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/LICENSE @@ -1,20 +1,20 @@ -Copyright (c) 2012-2013 Kit Cambridge. -http://kitcambridge.be/ - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +Copyright (c) 2012-2013 Kit Cambridge. +http://kitcambridge.be/ + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/README.md b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/README.md index 407441fd..bcb807a9 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/README.md +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/README.md @@ -1,126 +1,126 @@ -# JSON 3 # - -![JSON 3 Logo](http://bestiejs.github.io/json3/page/logo.png) - -**JSON 3** is a modern JSON implementation compatible with a variety of JavaScript platforms, including Internet Explorer 6, Opera 7, Safari 2, and Netscape 6. The current version is **3.2.6**. - -- [Development Version](https://raw.github.com/bestiejs/json3/v3.2.6/lib/json3.js) *(40 KB; uncompressed with comments)* -- [Production Version](https://raw.github.com/bestiejs/json3/v3.2.6/lib/json3.min.js) *(3.3 KB; compressed and `gzip`-ped)* - -CDN copies are also available at [cdnjs](http://cdnjs.com/libraries/json3/) & [jsDelivr](http://www.jsdelivr.com/#!json3). - -[JSON](http://json.org/) is a language-independent data interchange format based on a loose subset of the JavaScript grammar. Originally popularized by [Douglas Crockford](http://www.crockford.com/), the format was standardized in the [fifth edition](http://es5.github.com/) of the ECMAScript specification. The 5.1 edition, ratified in June 2011, incorporates several modifications to the grammar pertaining to the serialization of dates. - -JSON 3 exposes two functions: `stringify()` for [serializing](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/JSON/stringify) a JavaScript value to JSON, and `parse()` for [producing](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/JSON/parse) a JavaScript value from a JSON source string. It is a **drop-in replacement** for [JSON 2](http://json.org/js). The functions behave exactly as described in the ECMAScript spec, **except** for the date serialization discrepancy noted below. - -The JSON 3 parser does **not** use `eval` or regular expressions. This provides security and performance benefits in obsolete and mobile environments, where the margin is particularly significant. The complete [benchmark suite](http://jsperf.com/json3) is available on [jsPerf](http://jsperf.com/). - -The project is [hosted on GitHub](http://git.io/json3), along with the [unit tests](http://bestiejs.github.io/json3/test/test_browser.html). It is part of the [BestieJS](https://github.com/bestiejs) family, a collection of best-in-class JavaScript libraries that promote cross-platform support, specification precedents, unit testing, and plenty of documentation. - -# Changes from JSON 2 # - -JSON 3... - -* Correctly serializes primitive wrapper objects. -* Throws a `TypeError` when serializing cyclic structures (JSON 2 recurses until the call stack overflows). -* Utilizes **feature tests** to detect broken or incomplete *native* JSON implementations (JSON 2 only checks for the presence of the native functions). The tests are only executed once at runtime, so there is no additional performance cost when parsing or serializing values. - -**As of v3.2.3**, JSON 3 is compatible with [Prototype](http://prototypejs.org) 1.6.1 and older. - -In contrast to JSON 2, JSON 3 **does not**... - -* Add `toJSON()` methods to the `Boolean`, `Number`, and `String` prototypes. These are not part of any standard, and are made redundant by the design of the `stringify()` implementation. -* Add `toJSON()` or `toISOString()` methods to `Date.prototype`. See the note about date serialization below. - -## Date Serialization - -**JSON 3 deviates from the specification in one important way**: it does not define `Date#toISOString()` or `Date#toJSON()`. This preserves CommonJS compatibility and avoids polluting native prototypes. Instead, date serialization is performed internally by the `stringify()` implementation: if a date object does not define a custom `toJSON()` method, it is serialized as a [simplified ISO 8601 date-time string](http://es5.github.com/#x15.9.1.15). - -**Several native `Date#toJSON()` implementations produce date time strings that do *not* conform to the grammar outlined in the spec**. For instance, all versions of Safari 4, as well as JSON 2, fail to serialize extended years correctly. Furthermore, JSON 2 and older implementations omit the milliseconds from the date-time string (optional in ES 5, but required in 5.1). Finally, in all versions of Safari 4 and 5, serializing an invalid date will produce the string `"Invalid Date"`, rather than `null`. Because these environments exhibit other serialization bugs, however, JSON 3 will override the native `stringify()` implementation. - -Portions of the date serialization code are adapted from the [`date-shim`](https://github.com/Yaffle/date-shim) project. - -# Usage # - -## Web Browsers - - - - -## CommonJS Environments - - var JSON3 = require("./path/to/json3"); - JSON3.parse("[1, 2, 3]"); - // => [1, 2, 3] - -## JavaScript Engines - - load("path/to/json3.js"); - JSON.stringify({"Hello": 123, "Good-bye": 456}, ["Hello"], "\t"); - // => '{\n\t"Hello": 123\n}' - -# Compatibility # - -JSON 3 has been **tested** with the following web browsers, CommonJS environments, and JavaScript engines. - -## Web Browsers - -- Windows [Internet Explorer](http://www.microsoft.com/windows/internet-explorer), version 6.0 and higher -- Mozilla [Firefox](http://www.mozilla.com/firefox), version 1.0 and higher -- Apple [Safari](http://www.apple.com/safari), version 2.0 and higher -- [Opera](http://www.opera.com) 7.02 and higher -- [Mozilla](http://sillydog.org/narchive/gecko.php) 1.0, [Netscape](http://sillydog.org/narchive/) 6.2.3, and [SeaMonkey](http://www.seamonkey-project.org/) 1.0 and higher - -## CommonJS Environments - -- [Node](http://nodejs.org/) 0.2.6 and higher -- [RingoJS](http://ringojs.org/) 0.4 and higher -- [Narwhal](http://narwhaljs.org/) 0.3.2 and higher - -## JavaScript Engines - -- Mozilla [Rhino](http://www.mozilla.org/rhino) 1.5R5 and higher -- WebKit [JSC](https://trac.webkit.org/wiki/JSC) -- Google [V8](http://code.google.com/p/v8) - -## Known Incompatibilities - -* Attempting to serialize the `arguments` object may produce inconsistent results across environments due to specification version differences. As a workaround, please convert the `arguments` object to an array first: `JSON.stringify([].slice.call(arguments, 0))`. - -## Required Native Methods - -JSON 3 assumes that the following methods exist and function as described in the ECMAScript specification: - -- The `Number`, `String`, `Array`, `Object`, `Date`, `SyntaxError`, and `TypeError` constructors. -- `String.fromCharCode` -- `Object#toString` -- `Function#call` -- `Math.floor` -- `Number#toString` -- `Date#valueOf` -- `String.prototype`: `indexOf`, `charCodeAt`, `charAt`, `slice`. -- `Array.prototype`: `push`, `pop`, `join`. - -# Contribute # - -Check out a working copy of the JSON 3 source code with [Git](http://git-scm.com/): - - $ git clone git://github.com/bestiejs/json3.git - $ cd json3 - $ git submodule update --init - -If you'd like to contribute a feature or bug fix, you can [fork](http://help.github.com/fork-a-repo/) JSON 3, commit your changes, and [send a pull request](http://help.github.com/send-pull-requests/). Please make sure to update the unit tests in the `test` directory as well. - -Alternatively, you can use the [GitHub issue tracker](https://github.com/bestiejs/json3/issues) to submit bug reports, feature requests, and questions, or send tweets to [@kitcambridge](http://twitter.com/kitcambridge). - +# JSON 3 # + +![JSON 3 Logo](http://bestiejs.github.io/json3/page/logo.png) + +**JSON 3** is a modern JSON implementation compatible with a variety of JavaScript platforms, including Internet Explorer 6, Opera 7, Safari 2, and Netscape 6. The current version is **3.2.6**. + +- [Development Version](https://raw.github.com/bestiejs/json3/v3.2.6/lib/json3.js) *(40 KB; uncompressed with comments)* +- [Production Version](https://raw.github.com/bestiejs/json3/v3.2.6/lib/json3.min.js) *(3.3 KB; compressed and `gzip`-ped)* + +CDN copies are also available at [cdnjs](http://cdnjs.com/libraries/json3/) & [jsDelivr](http://www.jsdelivr.com/#!json3). + +[JSON](http://json.org/) is a language-independent data interchange format based on a loose subset of the JavaScript grammar. Originally popularized by [Douglas Crockford](http://www.crockford.com/), the format was standardized in the [fifth edition](http://es5.github.com/) of the ECMAScript specification. The 5.1 edition, ratified in June 2011, incorporates several modifications to the grammar pertaining to the serialization of dates. + +JSON 3 exposes two functions: `stringify()` for [serializing](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/JSON/stringify) a JavaScript value to JSON, and `parse()` for [producing](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/JSON/parse) a JavaScript value from a JSON source string. It is a **drop-in replacement** for [JSON 2](http://json.org/js). The functions behave exactly as described in the ECMAScript spec, **except** for the date serialization discrepancy noted below. + +The JSON 3 parser does **not** use `eval` or regular expressions. This provides security and performance benefits in obsolete and mobile environments, where the margin is particularly significant. The complete [benchmark suite](http://jsperf.com/json3) is available on [jsPerf](http://jsperf.com/). + +The project is [hosted on GitHub](http://git.io/json3), along with the [unit tests](http://bestiejs.github.io/json3/test/test_browser.html). It is part of the [BestieJS](https://github.com/bestiejs) family, a collection of best-in-class JavaScript libraries that promote cross-platform support, specification precedents, unit testing, and plenty of documentation. + +# Changes from JSON 2 # + +JSON 3... + +* Correctly serializes primitive wrapper objects. +* Throws a `TypeError` when serializing cyclic structures (JSON 2 recurses until the call stack overflows). +* Utilizes **feature tests** to detect broken or incomplete *native* JSON implementations (JSON 2 only checks for the presence of the native functions). The tests are only executed once at runtime, so there is no additional performance cost when parsing or serializing values. + +**As of v3.2.3**, JSON 3 is compatible with [Prototype](http://prototypejs.org) 1.6.1 and older. + +In contrast to JSON 2, JSON 3 **does not**... + +* Add `toJSON()` methods to the `Boolean`, `Number`, and `String` prototypes. These are not part of any standard, and are made redundant by the design of the `stringify()` implementation. +* Add `toJSON()` or `toISOString()` methods to `Date.prototype`. See the note about date serialization below. + +## Date Serialization + +**JSON 3 deviates from the specification in one important way**: it does not define `Date#toISOString()` or `Date#toJSON()`. This preserves CommonJS compatibility and avoids polluting native prototypes. Instead, date serialization is performed internally by the `stringify()` implementation: if a date object does not define a custom `toJSON()` method, it is serialized as a [simplified ISO 8601 date-time string](http://es5.github.com/#x15.9.1.15). + +**Several native `Date#toJSON()` implementations produce date time strings that do *not* conform to the grammar outlined in the spec**. For instance, all versions of Safari 4, as well as JSON 2, fail to serialize extended years correctly. Furthermore, JSON 2 and older implementations omit the milliseconds from the date-time string (optional in ES 5, but required in 5.1). Finally, in all versions of Safari 4 and 5, serializing an invalid date will produce the string `"Invalid Date"`, rather than `null`. Because these environments exhibit other serialization bugs, however, JSON 3 will override the native `stringify()` implementation. + +Portions of the date serialization code are adapted from the [`date-shim`](https://github.com/Yaffle/date-shim) project. + +# Usage # + +## Web Browsers + + + + +## CommonJS Environments + + var JSON3 = require("./path/to/json3"); + JSON3.parse("[1, 2, 3]"); + // => [1, 2, 3] + +## JavaScript Engines + + load("path/to/json3.js"); + JSON.stringify({"Hello": 123, "Good-bye": 456}, ["Hello"], "\t"); + // => '{\n\t"Hello": 123\n}' + +# Compatibility # + +JSON 3 has been **tested** with the following web browsers, CommonJS environments, and JavaScript engines. + +## Web Browsers + +- Windows [Internet Explorer](http://www.microsoft.com/windows/internet-explorer), version 6.0 and higher +- Mozilla [Firefox](http://www.mozilla.com/firefox), version 1.0 and higher +- Apple [Safari](http://www.apple.com/safari), version 2.0 and higher +- [Opera](http://www.opera.com) 7.02 and higher +- [Mozilla](http://sillydog.org/narchive/gecko.php) 1.0, [Netscape](http://sillydog.org/narchive/) 6.2.3, and [SeaMonkey](http://www.seamonkey-project.org/) 1.0 and higher + +## CommonJS Environments + +- [Node](http://nodejs.org/) 0.2.6 and higher +- [RingoJS](http://ringojs.org/) 0.4 and higher +- [Narwhal](http://narwhaljs.org/) 0.3.2 and higher + +## JavaScript Engines + +- Mozilla [Rhino](http://www.mozilla.org/rhino) 1.5R5 and higher +- WebKit [JSC](https://trac.webkit.org/wiki/JSC) +- Google [V8](http://code.google.com/p/v8) + +## Known Incompatibilities + +* Attempting to serialize the `arguments` object may produce inconsistent results across environments due to specification version differences. As a workaround, please convert the `arguments` object to an array first: `JSON.stringify([].slice.call(arguments, 0))`. + +## Required Native Methods + +JSON 3 assumes that the following methods exist and function as described in the ECMAScript specification: + +- The `Number`, `String`, `Array`, `Object`, `Date`, `SyntaxError`, and `TypeError` constructors. +- `String.fromCharCode` +- `Object#toString` +- `Function#call` +- `Math.floor` +- `Number#toString` +- `Date#valueOf` +- `String.prototype`: `indexOf`, `charCodeAt`, `charAt`, `slice`. +- `Array.prototype`: `push`, `pop`, `join`. + +# Contribute # + +Check out a working copy of the JSON 3 source code with [Git](http://git-scm.com/): + + $ git clone git://github.com/bestiejs/json3.git + $ cd json3 + $ git submodule update --init + +If you'd like to contribute a feature or bug fix, you can [fork](http://help.github.com/fork-a-repo/) JSON 3, commit your changes, and [send a pull request](http://help.github.com/send-pull-requests/). Please make sure to update the unit tests in the `test` directory as well. + +Alternatively, you can use the [GitHub issue tracker](https://github.com/bestiejs/json3/issues) to submit bug reports, feature requests, and questions, or send tweets to [@kitcambridge](http://twitter.com/kitcambridge). + JSON 3 is released under the [MIT License](http://kit.mit-license.org/). \ No newline at end of file diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/coverage/lcov-report/lib/json3.js.html b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/coverage/lcov-report/lib/json3.js.html index dd9fb923..11c49b42 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/coverage/lcov-report/lib/json3.js.html +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/coverage/lcov-report/lib/json3.js.html @@ -1,2903 +1,2903 @@ - - - - Code coverage report for lib/json3.js - - - - - - - -
-

Code coverage report for lib/json3.js

-

- - Statements: 13.77% (50 / 363)      - - - Branches: 15.32% (59 / 385)      - - - Functions: 11.54% (3 / 26)      - - - Lines: 13.77% (50 / 363)      - -

-
All files » lib/ » json3.js
-
-
-
- -
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 -254 -255 -256 -257 -258 -259 -260 -261 -262 -263 -264 -265 -266 -267 -268 -269 -270 -271 -272 -273 -274 -275 -276 -277 -278 -279 -280 -281 -282 -283 -284 -285 -286 -287 -288 -289 -290 -291 -292 -293 -294 -295 -296 -297 -298 -299 -300 -301 -302 -303 -304 -305 -306 -307 -308 -309 -310 -311 -312 -313 -314 -315 -316 -317 -318 -319 -320 -321 -322 -323 -324 -325 -326 -327 -328 -329 -330 -331 -332 -333 -334 -335 -336 -337 -338 -339 -340 -341 -342 -343 -344 -345 -346 -347 -348 -349 -350 -351 -352 -353 -354 -355 -356 -357 -358 -359 -360 -361 -362 -363 -364 -365 -366 -367 -368 -369 -370 -371 -372 -373 -374 -375 -376 -377 -378 -379 -380 -381 -382 -383 -384 -385 -386 -387 -388 -389 -390 -391 -392 -393 -394 -395 -396 -397 -398 -399 -400 -401 -402 -403 -404 -405 -406 -407 -408 -409 -410 -411 -412 -413 -414 -415 -416 -417 -418 -419 -420 -421 -422 -423 -424 -425 -426 -427 -428 -429 -430 -431 -432 -433 -434 -435 -436 -437 -438 -439 -440 -441 -442 -443 -444 -445 -446 -447 -448 -449 -450 -451 -452 -453 -454 -455 -456 -457 -458 -459 -460 -461 -462 -463 -464 -465 -466 -467 -468 -469 -470 -471 -472 -473 -474 -475 -476 -477 -478 -479 -480 -481 -482 -483 -484 -485 -486 -487 -488 -489 -490 -491 -492 -493 -494 -495 -496 -497 -498 -499 -500 -501 -502 -503 -504 -505 -506 -507 -508 -509 -510 -511 -512 -513 -514 -515 -516 -517 -518 -519 -520 -521 -522 -523 -524 -525 -526 -527 -528 -529 -530 -531 -532 -533 -534 -535 -536 -537 -538 -539 -540 -541 -542 -543 -544 -545 -546 -547 -548 -549 -550 -551 -552 -553 -554 -555 -556 -557 -558 -559 -560 -561 -562 -563 -564 -565 -566 -567 -568 -569 -570 -571 -572 -573 -574 -575 -576 -577 -578 -579 -580 -581 -582 -583 -584 -585 -586 -587 -588 -589 -590 -591 -592 -593 -594 -595 -596 -597 -598 -599 -600 -601 -602 -603 -604 -605 -606 -607 -608 -609 -610 -611 -612 -613 -614 -615 -616 -617 -618 -619 -620 -621 -622 -623 -624 -625 -626 -627 -628 -629 -630 -631 -632 -633 -634 -635 -636 -637 -638 -639 -640 -641 -642 -643 -644 -645 -646 -647 -648 -649 -650 -651 -652 -653 -654 -655 -656 -657 -658 -659 -660 -661 -662 -663 -664 -665 -666 -667 -668 -669 -670 -671 -672 -673 -674 -675 -676 -677 -678 -679 -680 -681 -682 -683 -684 -685 -686 -687 -688 -689 -690 -691 -692 -693 -694 -695 -696 -697 -698 -699 -700 -701 -702 -703 -704 -705 -706 -707 -708 -709 -710 -711 -712 -713 -714 -715 -716 -717 -718 -719 -720 -721 -722 -723 -724 -725 -726 -727 -728 -729 -730 -731 -732 -733 -734 -735 -736 -737 -738 -739 -740 -741 -742 -743 -744 -745 -746 -747 -748 -749 -750 -751 -752 -753 -754 -755 -756 -757 -758 -759 -760 -761 -762 -763 -764 -765 -766 -767 -768 -769 -770 -771 -772 -773 -774 -775 -776 -777 -778 -779 -780 -781 -782 -783 -784 -785 -786 -787 -788 -789 -790 -791 -792 -793 -794 -795 -796 -797 -798 -799 -800 -801 -802 -803 -804 -805 -806 -807 -808 -809 -810 -811 -812 -813 -814 -815 -816 -817 -818 -819 -820 -821 -822 -823 -824 -825 -826 -827 -828 -829 -830 -831 -832 -833 -834 -835 -836 -837 -838 -839 -840 -841 -842 -843 -844 -845 -846 -847 -848 -849 -850 -851 -852 -853 -854 -855 -856 -857 -858 -859 -860 -861 -862 -863 -864 -865 -866 -867  -1 -  -1 -  -  -  -1 -  -  -1 -  -  -  -1 -  -1 -  -  -1 -1 -  -  -  -  -  -  -  -1 -1 -  -  -1 -  -  -  -  -  -  -  -  -1 -3 -  -  -  -  -3 -3 -  -  -  -3 -  -  -1 -  -2 -  -2 -1 -1 -  -1 -4 -  -1 -1 -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -1 -  -  -2 -1 -1 -1 -  -  -  -1 -  -1 -1 -1 -1 -  -1 -  -1 -1 -  -  -  -1 -  -  -1 -1 -  -  -  -1 -  -  -  -  -  -  -  -  -1 -  -  -3 -  -1 -1 -1 -1 -  -1 -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -1 -  -  -  -  -  - 
/*! JSON v3.2.5 | http://bestiejs.github.io/json3 | Copyright 2012-2013, Kit Cambridge | http://kit.mit-license.org */
-;(function (window) {
-  // Convenience aliases.
-  var getClass = {}.toString, isProperty, forEach, undef;
- 
-  // Detect the `define` function exposed by asynchronous module loaders. The
-  // strict `define` check is necessary for compatibility with `r.js`.
-  var isLoader = typeof define === "function" && define.amd;
- 
-  // Detect native implementations.
-  var nativeJSON = typeof JSON == "object" && JSON;
- 
-  // Set up the JSON 3 namespace, preferring the CommonJS `exports` object if
-  // available.
-  var JSON3 = typeof exports == "object" && exports && !exports.nodeType && exports;
- 
-  Eif (JSON3 && nativeJSON) {
-    // Explicitly delegate to the native `stringify` and `parse`
-    // implementations in CommonJS environments.
-    JSON3.stringify = nativeJSON.stringify;
-    JSON3.parse = nativeJSON.parse;
-  } else {
-    // Export for web browsers, JavaScript engines, and asynchronous module
-    // loaders, using the global `JSON` object if available.
-    JSON3 = window.JSON = nativeJSON || {};
-  }
- 
-  // Test the `Date#getUTC*` methods. Based on work by @Yaffle.
-  var isExtended = new Date(-3509827334573292);
-  try {
-    // The `getUTCFullYear`, `Month`, and `Date` methods return nonsensical
-    // results for certain dates in Opera >= 10.53.
-    isExtended = isExtended.getUTCFullYear() == -109252 && isExtended.getUTCMonth() === 0 && isExtended.getUTCDate() === 1 &&
-      // Safari < 2.0.2 stores the internal millisecond time value correctly,
-      // but clips the values returned by the date methods to the range of
-      // signed 32-bit integers ([-2 ** 31, 2 ** 31 - 1]).
-      isExtended.getUTCHours() == 10 && isExtended.getUTCMinutes() == 37 && isExtended.getUTCSeconds() == 6 && isExtended.getUTCMilliseconds() == 708;
-  } catch (exception) {}
- 
-  // Internal: Determines whether the native `JSON.stringify` and `parse`
-  // implementations are spec-compliant. Based on work by Ken Snyder.
-  function has(name) {
-    Iif (has[name] != null) {
-      // Return cached feature test result.
-      return has[name];
-    }
- 
-    var isSupported;
-    Iif (name == "bug-string-char-index") {
-      // IE <= 7 doesn't support accessing string characters using square
-      // bracket notation. IE 8 only supports this for primitives.
-      isSupported = "a"[0] != "a";
-    } else if (name == "json") {
-      // Indicates whether both `JSON.stringify` and `JSON.parse` are
-      // supported.
-      isSupported = has("json-stringify") && has("json-parse");
-    } else {
-      var value, serialized = '{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}';
-      // Test `JSON.stringify`.
-      if (name == "json-stringify") {
-        var stringify = JSON3.stringify, stringifySupported = typeof stringify == "function" && isExtended;
-        Eif (stringifySupported) {
-          // A test function object with a custom `toJSON` method.
-          (value = function () {
-            return 1;
-          }).toJSON = value;
-          try {
-            stringifySupported =
-              // Firefox 3.1b1 and b2 serialize string, number, and boolean
-              // primitives as object literals.
-              stringify(0) === "0" &&
-              // FF 3.1b1, b2, and JSON 2 serialize wrapped primitives as object
-              // literals.
-              stringify(new Number()) === "0" &&
-              stringify(new String()) == '""' &&
-              // FF 3.1b1, 2 throw an error if the value is `null`, `undefined`, or
-              // does not define a canonical JSON representation (this applies to
-              // objects with `toJSON` properties as well, *unless* they are nested
-              // within an object or array).
-              stringify(getClass) === undef &&
-              // IE 8 serializes `undefined` as `"undefined"`. Safari <= 5.1.7 and
-              // FF 3.1b3 pass this test.
-              stringify(undef) === undef &&
-              // Safari <= 5.1.7 and FF 3.1b3 throw `Error`s and `TypeError`s,
-              // respectively, if the value is omitted entirely.
-              stringify() === undef &&
-              // FF 3.1b1, 2 throw an error if the given value is not a number,
-              // string, array, object, Boolean, or `null` literal. This applies to
-              // objects with custom `toJSON` methods as well, unless they are nested
-              // inside object or array literals. YUI 3.0.0b1 ignores custom `toJSON`
-              // methods entirely.
-              stringify(value) === "1" &&
-              stringify([value]) == "[1]" &&
-              // Prototype <= 1.6.1 serializes `[undefined]` as `"[]"` instead of
-              // `"[null]"`.
-              stringify([undef]) == "[null]" &&
-              // YUI 3.0.0b1 fails to serialize `null` literals.
-              stringify(null) == "null" &&
-              // FF 3.1b1, 2 halts serialization if an array contains a function:
-              // `[1, true, getClass, 1]` serializes as "[1,true,],". FF 3.1b3
-              // elides non-JSON values from objects and arrays, unless they
-              // define custom `toJSON` methods.
-              stringify([undef, getClass, null]) == "[null,null,null]" &&
-              // Simple serialization test. FF 3.1b1 uses Unicode escape sequences
-              // where character escape codes are expected (e.g., `\b` => `\u0008`).
-              stringify({ "a": [value, true, false, null, "\x00\b\n\f\r\t"] }) == serialized &&
-              // FF 3.1b1 and b2 ignore the `filter` and `width` arguments.
-              stringify(null, value) === "1" &&
-              stringify([1, 2], null, 1) == "[\n 1,\n 2\n]" &&
-              // JSON 2, Prototype <= 1.7, and older WebKit builds incorrectly
-              // serialize extended years.
-              stringify(new Date(-8.64e15)) == '"-271821-04-20T00:00:00.000Z"' &&
-              // The milliseconds are optional in ES 5, but required in 5.1.
-              stringify(new Date(8.64e15)) == '"+275760-09-13T00:00:00.000Z"' &&
-              // Firefox <= 11.0 incorrectly serializes years prior to 0 as negative
-              // four-digit years instead of six-digit years. Credits: @Yaffle.
-              stringify(new Date(-621987552e5)) == '"-000001-01-01T00:00:00.000Z"' &&
-              // Safari <= 5.1.5 and Opera >= 10.53 incorrectly serialize millisecond
-              // values less than 1000. Credits: @Yaffle.
-              stringify(new Date(-1)) == '"1969-12-31T23:59:59.999Z"';
-          } catch (exception) {
-            stringifySupported = false;
-          }
-        }
-        isSupported = stringifySupported;
-      }
-      // Test `JSON.parse`.
-      if (name == "json-parse") {
-        var parse = JSON3.parse;
-        Eif (typeof parse == "function") {
-          try {
-            // FF 3.1b1, b2 will throw an exception if a bare literal is provided.
-            // Conforming implementations should also coerce the initial argument to
-            // a string prior to parsing.
-            Eif (parse("0") === 0 && !parse(false)) {
-              // Simple parsing test.
-              value = parse(serialized);
-              var parseSupported = value["a"].length == 5 && value["a"][0] === 1;
-              Eif (parseSupported) {
-                try {
-                  // Safari <= 5.1.2 and FF 3.1b1 allow unescaped tabs in strings.
-                  parseSupported = !parse('"\t"');
-                } catch (exception) {}
-                Eif (parseSupported) {
-                  try {
-                    // FF 4.0 and 4.0.1 allow leading `+` signs and leading
-                    // decimal points. FF 4.0, 4.0.1, and IE 9-10 also allow
-                    // certain octal literals.
-                    parseSupported = parse("01") !== 1;
-                  } catch (exception) {}
-                }
-                Eif (parseSupported) {
-                  try {
-                    // FF 4.0, 4.0.1, and Rhino 1.7R3-R4 allow trailing decimal
-                    // points. These environments, along with FF 3.1b1 and 2,
-                    // also allow trailing commas in JSON objects and arrays.
-                    parseSupported = parse("1.") !== 1;
-                  } catch (exception) {}
-                }
-              }
-            }
-          } catch (exception) {
-            parseSupported = false;
-          }
-        }
-        isSupported = parseSupported;
-      }
-    }
-    return has[name] = !!isSupported;
-  }
-  has["bug-string-char-index"] = null;
-  has["json"] = null;
-  has["json-stringify"] = null;
-  has["json-parse"] = null;
- 
-  Iif (!has("json")) {
-    // Common `[[Class]]` name aliases.
-    var functionClass = "[object Function]";
-    var dateClass = "[object Date]";
-    var numberClass = "[object Number]";
-    var stringClass = "[object String]";
-    var arrayClass = "[object Array]";
-    var booleanClass = "[object Boolean]";
- 
-    // Detect incomplete support for accessing string characters by index.
-    var charIndexBuggy = has("bug-string-char-index");
- 
-    // Define additional utility methods if the `Date` methods are buggy.
-    if (!isExtended) {
-      var floor = Math.floor;
-      // A mapping between the months of the year and the number of days between
-      // January 1st and the first of the respective month.
-      var Months = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
-      // Internal: Calculates the number of days between the Unix epoch and the
-      // first day of the given month.
-      var getDay = function (year, month) {
-        return Months[month] + 365 * (year - 1970) + floor((year - 1969 + (month = +(month > 1))) / 4) - floor((year - 1901 + month) / 100) + floor((year - 1601 + month) / 400);
-      };
-    }
- 
-    // Internal: Determines if a property is a direct property of the given
-    // object. Delegates to the native `Object#hasOwnProperty` method.
-    if (!(isProperty = {}.hasOwnProperty)) {
-      isProperty = function (property) {
-        var members = {}, constructor;
-        if ((members.__proto__ = null, members.__proto__ = {
-          // The *proto* property cannot be set multiple times in recent
-          // versions of Firefox and SeaMonkey.
-          "toString": 1
-        }, members).toString != getClass) {
-          // Safari <= 2.0.3 doesn't implement `Object#hasOwnProperty`, but
-          // supports the mutable *proto* property.
-          isProperty = function (property) {
-            // Capture and break the object's prototype chain (see section 8.6.2
-            // of the ES 5.1 spec). The parenthesized expression prevents an
-            // unsafe transformation by the Closure Compiler.
-            var original = this.__proto__, result = property in (this.__proto__ = null, this);
-            // Restore the original prototype chain.
-            this.__proto__ = original;
-            return result;
-          };
-        } else {
-          // Capture a reference to the top-level `Object` constructor.
-          constructor = members.constructor;
-          // Use the `constructor` property to simulate `Object#hasOwnProperty` in
-          // other environments.
-          isProperty = function (property) {
-            var parent = (this.constructor || constructor).prototype;
-            return property in this && !(property in parent && this[property] === parent[property]);
-          };
-        }
-        members = null;
-        return isProperty.call(this, property);
-      };
-    }
- 
-    // Internal: A set of primitive types used by `isHostType`.
-    var PrimitiveTypes = {
-      'boolean': 1,
-      'number': 1,
-      'string': 1,
-      'undefined': 1
-    };
- 
-    // Internal: Determines if the given object `property` value is a
-    // non-primitive.
-    var isHostType = function (object, property) {
-      var type = typeof object[property];
-      return type == 'object' ? !!object[property] : !PrimitiveTypes[type];
-    };
- 
-    // Internal: Normalizes the `for...in` iteration algorithm across
-    // environments. Each enumerated key is yielded to a `callback` function.
-    forEach = function (object, callback) {
-      var size = 0, Properties, members, property;
- 
-      // Tests for bugs in the current environment's `for...in` algorithm. The
-      // `valueOf` property inherits the non-enumerable flag from
-      // `Object.prototype` in older versions of IE, Netscape, and Mozilla.
-      (Properties = function () {
-        this.valueOf = 0;
-      }).prototype.valueOf = 0;
- 
-      // Iterate over a new instance of the `Properties` class.
-      members = new Properties();
-      for (property in members) {
-        // Ignore all properties inherited from `Object.prototype`.
-        if (isProperty.call(members, property)) {
-          size++;
-        }
-      }
-      Properties = members = null;
- 
-      // Normalize the iteration algorithm.
-      if (!size) {
-        // A list of non-enumerable properties inherited from `Object.prototype`.
-        members = ["valueOf", "toString", "toLocaleString", "propertyIsEnumerable", "isPrototypeOf", "hasOwnProperty", "constructor"];
-        // IE <= 8, Mozilla 1.0, and Netscape 6.2 ignore shadowed non-enumerable
-        // properties.
-        forEach = function (object, callback) {
-          var isFunction = getClass.call(object) == functionClass, property, length;
-          var hasProperty = !isFunction && typeof object.constructor != 'function' && isHostType(object, 'hasOwnProperty') ? object.hasOwnProperty : isProperty;
-          for (property in object) {
-            // Gecko <= 1.0 enumerates the `prototype` property of functions under
-            // certain conditions; IE does not.
-            if (!(isFunction && property == "prototype") && hasProperty.call(object, property)) {
-              callback(property);
-            }
-          }
-          // Manually invoke the callback for each non-enumerable property.
-          for (length = members.length; property = members[--length]; hasProperty.call(object, property) && callback(property));
-        };
-      } else if (size == 2) {
-        // Safari <= 2.0.4 enumerates shadowed properties twice.
-        forEach = function (object, callback) {
-          // Create a set of iterated properties.
-          var members = {}, isFunction = getClass.call(object) == functionClass, property;
-          for (property in object) {
-            // Store each property name to prevent double enumeration. The
-            // `prototype` property of functions is not enumerated due to cross-
-            // environment inconsistencies.
-            if (!(isFunction && property == "prototype") && !isProperty.call(members, property) && (members[property] = 1) && isProperty.call(object, property)) {
-              callback(property);
-            }
-          }
-        };
-      } else {
-        // No bugs detected; use the standard `for...in` algorithm.
-        forEach = function (object, callback) {
-          var isFunction = getClass.call(object) == functionClass, property, isConstructor;
-          for (property in object) {
-            if (!(isFunction && property == "prototype") && isProperty.call(object, property) && !(isConstructor = property === "constructor")) {
-              callback(property);
-            }
-          }
-          // Manually invoke the callback for the `constructor` property due to
-          // cross-environment inconsistencies.
-          if (isConstructor || isProperty.call(object, (property = "constructor"))) {
-            callback(property);
-          }
-        };
-      }
-      return forEach(object, callback);
-    };
- 
-    // Public: Serializes a JavaScript `value` as a JSON string. The optional
-    // `filter` argument may specify either a function that alters how object and
-    // array members are serialized, or an array of strings and numbers that
-    // indicates which properties should be serialized. The optional `width`
-    // argument may be either a string or number that specifies the indentation
-    // level of the output.
-    if (!has("json-stringify")) {
-      // Internal: A map of control characters and their escaped equivalents.
-      var Escapes = {
-        92: "\\\\",
-        34: '\\"',
-        8: "\\b",
-        12: "\\f",
-        10: "\\n",
-        13: "\\r",
-        9: "\\t"
-      };
- 
-      // Internal: Converts `value` into a zero-padded string such that its
-      // length is at least equal to `width`. The `width` must be <= 6.
-      var leadingZeroes = "000000";
-      var toPaddedString = function (width, value) {
-        // The `|| 0` expression is necessary to work around a bug in
-        // Opera <= 7.54u2 where `0 == -0`, but `String(-0) !== "0"`.
-        return (leadingZeroes + (value || 0)).slice(-width);
-      };
- 
-      // Internal: Double-quotes a string `value`, replacing all ASCII control
-      // characters (characters with code unit values between 0 and 31) with
-      // their escaped equivalents. This is an implementation of the
-      // `Quote(value)` operation defined in ES 5.1 section 15.12.3.
-      var unicodePrefix = "\\u00";
-      var quote = function (value) {
-        var result = '"', index = 0, length = value.length, isLarge = length > 10 && charIndexBuggy, symbols;
-        if (isLarge) {
-          symbols = value.split("");
-        }
-        for (; index < length; index++) {
-          var charCode = value.charCodeAt(index);
-          // If the character is a control character, append its Unicode or
-          // shorthand escape sequence; otherwise, append the character as-is.
-          switch (charCode) {
-            case 8: case 9: case 10: case 12: case 13: case 34: case 92:
-              result += Escapes[charCode];
-              break;
-            default:
-              if (charCode < 32) {
-                result += unicodePrefix + toPaddedString(2, charCode.toString(16));
-                break;
-              }
-              result += isLarge ? symbols[index] : charIndexBuggy ? value.charAt(index) : value[index];
-          }
-        }
-        return result + '"';
-      };
- 
-      // Internal: Recursively serializes an object. Implements the
-      // `Str(key, holder)`, `JO(value)`, and `JA(value)` operations.
-      var serialize = function (property, object, callback, properties, whitespace, indentation, stack) {
-        var value, className, year, month, date, time, hours, minutes, seconds, milliseconds, results, element, index, length, prefix, hasMembers, result;
-        try {
-          // Necessary for host object support.
-          value = object[property];
-        } catch (exception) {}
-        if (typeof value == "object" && value) {
-          className = getClass.call(value);
-          if (className == dateClass && !isProperty.call(value, "toJSON")) {
-            if (value > -1 / 0 && value < 1 / 0) {
-              // Dates are serialized according to the `Date#toJSON` method
-              // specified in ES 5.1 section 15.9.5.44. See section 15.9.1.15
-              // for the ISO 8601 date time string format.
-              if (getDay) {
-                // Manually compute the year, month, date, hours, minutes,
-                // seconds, and milliseconds if the `getUTC*` methods are
-                // buggy. Adapted from @Yaffle's `date-shim` project.
-                date = floor(value / 864e5);
-                for (year = floor(date / 365.2425) + 1970 - 1; getDay(year + 1, 0) <= date; year++);
-                for (month = floor((date - getDay(year, 0)) / 30.42); getDay(year, month + 1) <= date; month++);
-                date = 1 + date - getDay(year, month);
-                // The `time` value specifies the time within the day (see ES
-                // 5.1 section 15.9.1.2). The formula `(A % B + B) % B` is used
-                // to compute `A modulo B`, as the `%` operator does not
-                // correspond to the `modulo` operation for negative numbers.
-                time = (value % 864e5 + 864e5) % 864e5;
-                // The hours, minutes, seconds, and milliseconds are obtained by
-                // decomposing the time within the day. See section 15.9.1.10.
-                hours = floor(time / 36e5) % 24;
-                minutes = floor(time / 6e4) % 60;
-                seconds = floor(time / 1e3) % 60;
-                milliseconds = time % 1e3;
-              } else {
-                year = value.getUTCFullYear();
-                month = value.getUTCMonth();
-                date = value.getUTCDate();
-                hours = value.getUTCHours();
-                minutes = value.getUTCMinutes();
-                seconds = value.getUTCSeconds();
-                milliseconds = value.getUTCMilliseconds();
-              }
-              // Serialize extended years correctly.
-              value = (year <= 0 || year >= 1e4 ? (year < 0 ? "-" : "+") + toPaddedString(6, year < 0 ? -year : year) : toPaddedString(4, year)) +
-                "-" + toPaddedString(2, month + 1) + "-" + toPaddedString(2, date) +
-                // Months, dates, hours, minutes, and seconds should have two
-                // digits; milliseconds should have three.
-                "T" + toPaddedString(2, hours) + ":" + toPaddedString(2, minutes) + ":" + toPaddedString(2, seconds) +
-                // Milliseconds are optional in ES 5.0, but required in 5.1.
-                "." + toPaddedString(3, milliseconds) + "Z";
-            } else {
-              value = null;
-            }
-          } else if (typeof value.toJSON == "function" && ((className != numberClass && className != stringClass && className != arrayClass) || isProperty.call(value, "toJSON"))) {
-            // Prototype <= 1.6.1 adds non-standard `toJSON` methods to the
-            // `Number`, `String`, `Date`, and `Array` prototypes. JSON 3
-            // ignores all `toJSON` methods on these objects unless they are
-            // defined directly on an instance.
-            value = value.toJSON(property);
-          }
-        }
-        if (callback) {
-          // If a replacement function was provided, call it to obtain the value
-          // for serialization.
-          value = callback.call(object, property, value);
-        }
-        if (value === null) {
-          return "null";
-        }
-        className = getClass.call(value);
-        if (className == booleanClass) {
-          // Booleans are represented literally.
-          return "" + value;
-        } else if (className == numberClass) {
-          // JSON numbers must be finite. `Infinity` and `NaN` are serialized as
-          // `"null"`.
-          return value > -1 / 0 && value < 1 / 0 ? "" + value : "null";
-        } else if (className == stringClass) {
-          // Strings are double-quoted and escaped.
-          return quote("" + value);
-        }
-        // Recursively serialize objects and arrays.
-        if (typeof value == "object") {
-          // Check for cyclic structures. This is a linear search; performance
-          // is inversely proportional to the number of unique nested objects.
-          for (length = stack.length; length--;) {
-            if (stack[length] === value) {
-              // Cyclic structures cannot be serialized by `JSON.stringify`.
-              throw TypeError();
-            }
-          }
-          // Add the object to the stack of traversed objects.
-          stack.push(value);
-          results = [];
-          // Save the current indentation level and indent one additional level.
-          prefix = indentation;
-          indentation += whitespace;
-          if (className == arrayClass) {
-            // Recursively serialize array elements.
-            for (index = 0, length = value.length; index < length; hasMembers || (hasMembers = true), index++) {
-              element = serialize(index, value, callback, properties, whitespace, indentation, stack);
-              results.push(element === undef ? "null" : element);
-            }
-            result = hasMembers ? (whitespace ? "[\n" + indentation + results.join(",\n" + indentation) + "\n" + prefix + "]" : ("[" + results.join(",") + "]")) : "[]";
-          } else {
-            // Recursively serialize object members. Members are selected from
-            // either a user-specified list of property names, or the object
-            // itself.
-            forEach(properties || value, function (property) {
-              var element = serialize(property, value, callback, properties, whitespace, indentation, stack);
-              if (element !== undef) {
-                // According to ES 5.1 section 15.12.3: "If `gap` {whitespace}
-                // is not the empty string, let `member` {quote(property) + ":"}
-                // be the concatenation of `member` and the `space` character."
-                // The "`space` character" refers to the literal space
-                // character, not the `space` {width} argument provided to
-                // `JSON.stringify`.
-                results.push(quote(property) + ":" + (whitespace ? " " : "") + element);
-              }
-              hasMembers || (hasMembers = true);
-            });
-            result = hasMembers ? (whitespace ? "{\n" + indentation + results.join(",\n" + indentation) + "\n" + prefix + "}" : ("{" + results.join(",") + "}")) : "{}";
-          }
-          // Remove the object from the traversed object stack.
-          stack.pop();
-          return result;
-        }
-      };
- 
-      // Public: `JSON.stringify`. See ES 5.1 section 15.12.3.
-      JSON3.stringify = function (source, filter, width) {
-        var whitespace, callback, properties, className;
-        if (typeof filter == "function" || typeof filter == "object" && filter) {
-          if ((className = getClass.call(filter)) == functionClass) {
-            callback = filter;
-          } else if (className == arrayClass) {
-            // Convert the property names array into a makeshift set.
-            properties = {};
-            for (var index = 0, length = filter.length, value; index < length; value = filter[index++], ((getClass.call(value) == stringClass || getClass.call(value) == numberClass) && (properties[value] = 1)));
-          }
-        }
-        if (width) {
-          if ((className = getClass.call(width)) == numberClass) {
-            // Convert the `width` to an integer and create a string containing
-            // `width` number of space characters.
-            if ((width -= width % 1) > 0) {
-              for (whitespace = "", width > 10 && (width = 10); whitespace.length < width; whitespace += " ");
-            }
-          } else if (className == stringClass) {
-            whitespace = width.length <= 10 ? width : width.slice(0, 10);
-          }
-        }
-        // Opera <= 7.54u2 discards the values associated with empty string keys
-        // (`""`) only if they are used directly within an object member list
-        // (e.g., `!("" in { "": 1})`).
-        return serialize("", (value = {}, value[""] = source, value), callback, properties, whitespace, "", []);
-      };
-    }
- 
-    // Public: Parses a JSON source string.
-    if (!has("json-parse")) {
-      var fromCharCode = String.fromCharCode;
- 
-      // Internal: A map of escaped control characters and their unescaped
-      // equivalents.
-      var Unescapes = {
-        92: "\\",
-        34: '"',
-        47: "/",
-        98: "\b",
-        116: "\t",
-        110: "\n",
-        102: "\f",
-        114: "\r"
-      };
- 
-      // Internal: Stores the parser state.
-      var Index, Source;
- 
-      // Internal: Resets the parser state and throws a `SyntaxError`.
-      var abort = function() {
-        Index = Source = null;
-        throw SyntaxError();
-      };
- 
-      // Internal: Returns the next token, or `"$"` if the parser has reached
-      // the end of the source string. A token may be a string, number, `null`
-      // literal, or Boolean literal.
-      var lex = function () {
-        var source = Source, length = source.length, value, begin, position, isSigned, charCode;
-        while (Index < length) {
-          charCode = source.charCodeAt(Index);
-          switch (charCode) {
-            case 9: case 10: case 13: case 32:
-              // Skip whitespace tokens, including tabs, carriage returns, line
-              // feeds, and space characters.
-              Index++;
-              break;
-            case 123: case 125: case 91: case 93: case 58: case 44:
-              // Parse a punctuator token (`{`, `}`, `[`, `]`, `:`, or `,`) at
-              // the current position.
-              value = charIndexBuggy ? source.charAt(Index) : source[Index];
-              Index++;
-              return value;
-            case 34:
-              // `"` delimits a JSON string; advance to the next character and
-              // begin parsing the string. String tokens are prefixed with the
-              // sentinel `@` character to distinguish them from punctuators and
-              // end-of-string tokens.
-              for (value = "@", Index++; Index < length;) {
-                charCode = source.charCodeAt(Index);
-                if (charCode < 32) {
-                  // Unescaped ASCII control characters (those with a code unit
-                  // less than the space character) are not permitted.
-                  abort();
-                } else if (charCode == 92) {
-                  // A reverse solidus (`\`) marks the beginning of an escaped
-                  // control character (including `"`, `\`, and `/`) or Unicode
-                  // escape sequence.
-                  charCode = source.charCodeAt(++Index);
-                  switch (charCode) {
-                    case 92: case 34: case 47: case 98: case 116: case 110: case 102: case 114:
-                      // Revive escaped control characters.
-                      value += Unescapes[charCode];
-                      Index++;
-                      break;
-                    case 117:
-                      // `\u` marks the beginning of a Unicode escape sequence.
-                      // Advance to the first character and validate the
-                      // four-digit code point.
-                      begin = ++Index;
-                      for (position = Index + 4; Index < position; Index++) {
-                        charCode = source.charCodeAt(Index);
-                        // A valid sequence comprises four hexdigits (case-
-                        // insensitive) that form a single hexadecimal value.
-                        if (!(charCode >= 48 && charCode <= 57 || charCode >= 97 && charCode <= 102 || charCode >= 65 && charCode <= 70)) {
-                          // Invalid Unicode escape sequence.
-                          abort();
-                        }
-                      }
-                      // Revive the escaped character.
-                      value += fromCharCode("0x" + source.slice(begin, Index));
-                      break;
-                    default:
-                      // Invalid escape sequence.
-                      abort();
-                  }
-                } else {
-                  if (charCode == 34) {
-                    // An unescaped double-quote character marks the end of the
-                    // string.
-                    break;
-                  }
-                  charCode = source.charCodeAt(Index);
-                  begin = Index;
-                  // Optimize for the common case where a string is valid.
-                  while (charCode >= 32 && charCode != 92 && charCode != 34) {
-                    charCode = source.charCodeAt(++Index);
-                  }
-                  // Append the string as-is.
-                  value += source.slice(begin, Index);
-                }
-              }
-              if (source.charCodeAt(Index) == 34) {
-                // Advance to the next character and return the revived string.
-                Index++;
-                return value;
-              }
-              // Unterminated string.
-              abort();
-            default:
-              // Parse numbers and literals.
-              begin = Index;
-              // Advance past the negative sign, if one is specified.
-              if (charCode == 45) {
-                isSigned = true;
-                charCode = source.charCodeAt(++Index);
-              }
-              // Parse an integer or floating-point value.
-              if (charCode >= 48 && charCode <= 57) {
-                // Leading zeroes are interpreted as octal literals.
-                if (charCode == 48 && ((charCode = source.charCodeAt(Index + 1)), charCode >= 48 && charCode <= 57)) {
-                  // Illegal octal literal.
-                  abort();
-                }
-                isSigned = false;
-                // Parse the integer component.
-                for (; Index < length && ((charCode = source.charCodeAt(Index)), charCode >= 48 && charCode <= 57); Index++);
-                // Floats cannot contain a leading decimal point; however, this
-                // case is already accounted for by the parser.
-                if (source.charCodeAt(Index) == 46) {
-                  position = ++Index;
-                  // Parse the decimal component.
-                  for (; position < length && ((charCode = source.charCodeAt(position)), charCode >= 48 && charCode <= 57); position++);
-                  if (position == Index) {
-                    // Illegal trailing decimal.
-                    abort();
-                  }
-                  Index = position;
-                }
-                // Parse exponents. The `e` denoting the exponent is
-                // case-insensitive.
-                charCode = source.charCodeAt(Index);
-                if (charCode == 101 || charCode == 69) {
-                  charCode = source.charCodeAt(++Index);
-                  // Skip past the sign following the exponent, if one is
-                  // specified.
-                  if (charCode == 43 || charCode == 45) {
-                    Index++;
-                  }
-                  // Parse the exponential component.
-                  for (position = Index; position < length && ((charCode = source.charCodeAt(position)), charCode >= 48 && charCode <= 57); position++);
-                  if (position == Index) {
-                    // Illegal empty exponent.
-                    abort();
-                  }
-                  Index = position;
-                }
-                // Coerce the parsed value to a JavaScript number.
-                return +source.slice(begin, Index);
-              }
-              // A negative sign may only precede numbers.
-              if (isSigned) {
-                abort();
-              }
-              // `true`, `false`, and `null` literals.
-              if (source.slice(Index, Index + 4) == "true") {
-                Index += 4;
-                return true;
-              } else if (source.slice(Index, Index + 5) == "false") {
-                Index += 5;
-                return false;
-              } else if (source.slice(Index, Index + 4) == "null") {
-                Index += 4;
-                return null;
-              }
-              // Unrecognized token.
-              abort();
-          }
-        }
-        // Return the sentinel `$` character if the parser has reached the end
-        // of the source string.
-        return "$";
-      };
- 
-      // Internal: Parses a JSON `value` token.
-      var get = function (value) {
-        var results, hasMembers;
-        if (value == "$") {
-          // Unexpected end of input.
-          abort();
-        }
-        if (typeof value == "string") {
-          if ((charIndexBuggy ? value.charAt(0) : value[0]) == "@") {
-            // Remove the sentinel `@` character.
-            return value.slice(1);
-          }
-          // Parse object and array literals.
-          if (value == "[") {
-            // Parses a JSON array, returning a new JavaScript array.
-            results = [];
-            for (;; hasMembers || (hasMembers = true)) {
-              value = lex();
-              // A closing square bracket marks the end of the array literal.
-              if (value == "]") {
-                break;
-              }
-              // If the array literal contains elements, the current token
-              // should be a comma separating the previous element from the
-              // next.
-              if (hasMembers) {
-                if (value == ",") {
-                  value = lex();
-                  if (value == "]") {
-                    // Unexpected trailing `,` in array literal.
-                    abort();
-                  }
-                } else {
-                  // A `,` must separate each array element.
-                  abort();
-                }
-              }
-              // Elisions and leading commas are not permitted.
-              if (value == ",") {
-                abort();
-              }
-              results.push(get(value));
-            }
-            return results;
-          } else if (value == "{") {
-            // Parses a JSON object, returning a new JavaScript object.
-            results = {};
-            for (;; hasMembers || (hasMembers = true)) {
-              value = lex();
-              // A closing curly brace marks the end of the object literal.
-              if (value == "}") {
-                break;
-              }
-              // If the object literal contains members, the current token
-              // should be a comma separator.
-              if (hasMembers) {
-                if (value == ",") {
-                  value = lex();
-                  if (value == "}") {
-                    // Unexpected trailing `,` in object literal.
-                    abort();
-                  }
-                } else {
-                  // A `,` must separate each object member.
-                  abort();
-                }
-              }
-              // Leading commas are not permitted, object property names must be
-              // double-quoted strings, and a `:` must separate each property
-              // name and value.
-              if (value == "," || typeof value != "string" || (charIndexBuggy ? value.charAt(0) : value[0]) != "@" || lex() != ":") {
-                abort();
-              }
-              results[value.slice(1)] = get(lex());
-            }
-            return results;
-          }
-          // Unexpected token encountered.
-          abort();
-        }
-        return value;
-      };
- 
-      // Internal: Updates a traversed object member.
-      var update = function(source, property, callback) {
-        var element = walk(source, property, callback);
-        if (element === undef) {
-          delete source[property];
-        } else {
-          source[property] = element;
-        }
-      };
- 
-      // Internal: Recursively traverses a parsed JSON object, invoking the
-      // `callback` function for each value. This is an implementation of the
-      // `Walk(holder, name)` operation defined in ES 5.1 section 15.12.2.
-      var walk = function (source, property, callback) {
-        var value = source[property], length;
-        if (typeof value == "object" && value) {
-          // `forEach` can't be used to traverse an array in Opera <= 8.54
-          // because its `Object#hasOwnProperty` implementation returns `false`
-          // for array indices (e.g., `![1, 2, 3].hasOwnProperty("0")`).
-          if (getClass.call(value) == arrayClass) {
-            for (length = value.length; length--;) {
-              update(value, length, callback);
-            }
-          } else {
-            forEach(value, function (property) {
-              update(value, property, callback);
-            });
-          }
-        }
-        return callback.call(source, property, value);
-      };
- 
-      // Public: `JSON.parse`. See ES 5.1 section 15.12.2.
-      JSON3.parse = function (source, callback) {
-        var result, value;
-        Index = 0;
-        Source = "" + source;
-        result = get(lex());
-        // If a JSON string contains multiple tokens, it is invalid.
-        if (lex() != "$") {
-          abort();
-        }
-        // Reset the parser state.
-        Index = Source = null;
-        return callback && getClass.call(callback) == functionClass ? walk((value = {}, value[""] = result, value), "", callback) : result;
-      };
-    }
-  }
- 
-  // Export for asynchronous module loaders.
-  Iif (isLoader) {
-    define(function () {
-      return JSON3;
-    });
-  }
-}(this));
- 
- - -

- - - - - - - + + + + Code coverage report for lib/json3.js + + + + + + + +
+

Code coverage report for lib/json3.js

+

+ + Statements: 13.77% (50 / 363)      + + + Branches: 15.32% (59 / 385)      + + + Functions: 11.54% (3 / 26)      + + + Lines: 13.77% (50 / 363)      + +

+
All files » lib/ » json3.js
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503 +504 +505 +506 +507 +508 +509 +510 +511 +512 +513 +514 +515 +516 +517 +518 +519 +520 +521 +522 +523 +524 +525 +526 +527 +528 +529 +530 +531 +532 +533 +534 +535 +536 +537 +538 +539 +540 +541 +542 +543 +544 +545 +546 +547 +548 +549 +550 +551 +552 +553 +554 +555 +556 +557 +558 +559 +560 +561 +562 +563 +564 +565 +566 +567 +568 +569 +570 +571 +572 +573 +574 +575 +576 +577 +578 +579 +580 +581 +582 +583 +584 +585 +586 +587 +588 +589 +590 +591 +592 +593 +594 +595 +596 +597 +598 +599 +600 +601 +602 +603 +604 +605 +606 +607 +608 +609 +610 +611 +612 +613 +614 +615 +616 +617 +618 +619 +620 +621 +622 +623 +624 +625 +626 +627 +628 +629 +630 +631 +632 +633 +634 +635 +636 +637 +638 +639 +640 +641 +642 +643 +644 +645 +646 +647 +648 +649 +650 +651 +652 +653 +654 +655 +656 +657 +658 +659 +660 +661 +662 +663 +664 +665 +666 +667 +668 +669 +670 +671 +672 +673 +674 +675 +676 +677 +678 +679 +680 +681 +682 +683 +684 +685 +686 +687 +688 +689 +690 +691 +692 +693 +694 +695 +696 +697 +698 +699 +700 +701 +702 +703 +704 +705 +706 +707 +708 +709 +710 +711 +712 +713 +714 +715 +716 +717 +718 +719 +720 +721 +722 +723 +724 +725 +726 +727 +728 +729 +730 +731 +732 +733 +734 +735 +736 +737 +738 +739 +740 +741 +742 +743 +744 +745 +746 +747 +748 +749 +750 +751 +752 +753 +754 +755 +756 +757 +758 +759 +760 +761 +762 +763 +764 +765 +766 +767 +768 +769 +770 +771 +772 +773 +774 +775 +776 +777 +778 +779 +780 +781 +782 +783 +784 +785 +786 +787 +788 +789 +790 +791 +792 +793 +794 +795 +796 +797 +798 +799 +800 +801 +802 +803 +804 +805 +806 +807 +808 +809 +810 +811 +812 +813 +814 +815 +816 +817 +818 +819 +820 +821 +822 +823 +824 +825 +826 +827 +828 +829 +830 +831 +832 +833 +834 +835 +836 +837 +838 +839 +840 +841 +842 +843 +844 +845 +846 +847 +848 +849 +850 +851 +852 +853 +854 +855 +856 +857 +858 +859 +860 +861 +862 +863 +864 +865 +866 +867  +1 +  +1 +  +  +  +1 +  +  +1 +  +  +  +1 +  +1 +  +  +1 +1 +  +  +  +  +  +  +  +1 +1 +  +  +1 +  +  +  +  +  +  +  +  +1 +3 +  +  +  +  +3 +3 +  +  +  +3 +  +  +1 +  +2 +  +2 +1 +1 +  +1 +4 +  +1 +1 +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1 +  +  +2 +1 +1 +1 +  +  +  +1 +  +1 +1 +1 +1 +  +1 +  +1 +1 +  +  +  +1 +  +  +1 +1 +  +  +  +1 +  +  +  +  +  +  +  +  +1 +  +  +3 +  +1 +1 +1 +1 +  +1 +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1 +  +  +  +  +  + 
/*! JSON v3.2.5 | http://bestiejs.github.io/json3 | Copyright 2012-2013, Kit Cambridge | http://kit.mit-license.org */
+;(function (window) {
+  // Convenience aliases.
+  var getClass = {}.toString, isProperty, forEach, undef;
+ 
+  // Detect the `define` function exposed by asynchronous module loaders. The
+  // strict `define` check is necessary for compatibility with `r.js`.
+  var isLoader = typeof define === "function" && define.amd;
+ 
+  // Detect native implementations.
+  var nativeJSON = typeof JSON == "object" && JSON;
+ 
+  // Set up the JSON 3 namespace, preferring the CommonJS `exports` object if
+  // available.
+  var JSON3 = typeof exports == "object" && exports && !exports.nodeType && exports;
+ 
+  Eif (JSON3 && nativeJSON) {
+    // Explicitly delegate to the native `stringify` and `parse`
+    // implementations in CommonJS environments.
+    JSON3.stringify = nativeJSON.stringify;
+    JSON3.parse = nativeJSON.parse;
+  } else {
+    // Export for web browsers, JavaScript engines, and asynchronous module
+    // loaders, using the global `JSON` object if available.
+    JSON3 = window.JSON = nativeJSON || {};
+  }
+ 
+  // Test the `Date#getUTC*` methods. Based on work by @Yaffle.
+  var isExtended = new Date(-3509827334573292);
+  try {
+    // The `getUTCFullYear`, `Month`, and `Date` methods return nonsensical
+    // results for certain dates in Opera >= 10.53.
+    isExtended = isExtended.getUTCFullYear() == -109252 && isExtended.getUTCMonth() === 0 && isExtended.getUTCDate() === 1 &&
+      // Safari < 2.0.2 stores the internal millisecond time value correctly,
+      // but clips the values returned by the date methods to the range of
+      // signed 32-bit integers ([-2 ** 31, 2 ** 31 - 1]).
+      isExtended.getUTCHours() == 10 && isExtended.getUTCMinutes() == 37 && isExtended.getUTCSeconds() == 6 && isExtended.getUTCMilliseconds() == 708;
+  } catch (exception) {}
+ 
+  // Internal: Determines whether the native `JSON.stringify` and `parse`
+  // implementations are spec-compliant. Based on work by Ken Snyder.
+  function has(name) {
+    Iif (has[name] != null) {
+      // Return cached feature test result.
+      return has[name];
+    }
+ 
+    var isSupported;
+    Iif (name == "bug-string-char-index") {
+      // IE <= 7 doesn't support accessing string characters using square
+      // bracket notation. IE 8 only supports this for primitives.
+      isSupported = "a"[0] != "a";
+    } else if (name == "json") {
+      // Indicates whether both `JSON.stringify` and `JSON.parse` are
+      // supported.
+      isSupported = has("json-stringify") && has("json-parse");
+    } else {
+      var value, serialized = '{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}';
+      // Test `JSON.stringify`.
+      if (name == "json-stringify") {
+        var stringify = JSON3.stringify, stringifySupported = typeof stringify == "function" && isExtended;
+        Eif (stringifySupported) {
+          // A test function object with a custom `toJSON` method.
+          (value = function () {
+            return 1;
+          }).toJSON = value;
+          try {
+            stringifySupported =
+              // Firefox 3.1b1 and b2 serialize string, number, and boolean
+              // primitives as object literals.
+              stringify(0) === "0" &&
+              // FF 3.1b1, b2, and JSON 2 serialize wrapped primitives as object
+              // literals.
+              stringify(new Number()) === "0" &&
+              stringify(new String()) == '""' &&
+              // FF 3.1b1, 2 throw an error if the value is `null`, `undefined`, or
+              // does not define a canonical JSON representation (this applies to
+              // objects with `toJSON` properties as well, *unless* they are nested
+              // within an object or array).
+              stringify(getClass) === undef &&
+              // IE 8 serializes `undefined` as `"undefined"`. Safari <= 5.1.7 and
+              // FF 3.1b3 pass this test.
+              stringify(undef) === undef &&
+              // Safari <= 5.1.7 and FF 3.1b3 throw `Error`s and `TypeError`s,
+              // respectively, if the value is omitted entirely.
+              stringify() === undef &&
+              // FF 3.1b1, 2 throw an error if the given value is not a number,
+              // string, array, object, Boolean, or `null` literal. This applies to
+              // objects with custom `toJSON` methods as well, unless they are nested
+              // inside object or array literals. YUI 3.0.0b1 ignores custom `toJSON`
+              // methods entirely.
+              stringify(value) === "1" &&
+              stringify([value]) == "[1]" &&
+              // Prototype <= 1.6.1 serializes `[undefined]` as `"[]"` instead of
+              // `"[null]"`.
+              stringify([undef]) == "[null]" &&
+              // YUI 3.0.0b1 fails to serialize `null` literals.
+              stringify(null) == "null" &&
+              // FF 3.1b1, 2 halts serialization if an array contains a function:
+              // `[1, true, getClass, 1]` serializes as "[1,true,],". FF 3.1b3
+              // elides non-JSON values from objects and arrays, unless they
+              // define custom `toJSON` methods.
+              stringify([undef, getClass, null]) == "[null,null,null]" &&
+              // Simple serialization test. FF 3.1b1 uses Unicode escape sequences
+              // where character escape codes are expected (e.g., `\b` => `\u0008`).
+              stringify({ "a": [value, true, false, null, "\x00\b\n\f\r\t"] }) == serialized &&
+              // FF 3.1b1 and b2 ignore the `filter` and `width` arguments.
+              stringify(null, value) === "1" &&
+              stringify([1, 2], null, 1) == "[\n 1,\n 2\n]" &&
+              // JSON 2, Prototype <= 1.7, and older WebKit builds incorrectly
+              // serialize extended years.
+              stringify(new Date(-8.64e15)) == '"-271821-04-20T00:00:00.000Z"' &&
+              // The milliseconds are optional in ES 5, but required in 5.1.
+              stringify(new Date(8.64e15)) == '"+275760-09-13T00:00:00.000Z"' &&
+              // Firefox <= 11.0 incorrectly serializes years prior to 0 as negative
+              // four-digit years instead of six-digit years. Credits: @Yaffle.
+              stringify(new Date(-621987552e5)) == '"-000001-01-01T00:00:00.000Z"' &&
+              // Safari <= 5.1.5 and Opera >= 10.53 incorrectly serialize millisecond
+              // values less than 1000. Credits: @Yaffle.
+              stringify(new Date(-1)) == '"1969-12-31T23:59:59.999Z"';
+          } catch (exception) {
+            stringifySupported = false;
+          }
+        }
+        isSupported = stringifySupported;
+      }
+      // Test `JSON.parse`.
+      if (name == "json-parse") {
+        var parse = JSON3.parse;
+        Eif (typeof parse == "function") {
+          try {
+            // FF 3.1b1, b2 will throw an exception if a bare literal is provided.
+            // Conforming implementations should also coerce the initial argument to
+            // a string prior to parsing.
+            Eif (parse("0") === 0 && !parse(false)) {
+              // Simple parsing test.
+              value = parse(serialized);
+              var parseSupported = value["a"].length == 5 && value["a"][0] === 1;
+              Eif (parseSupported) {
+                try {
+                  // Safari <= 5.1.2 and FF 3.1b1 allow unescaped tabs in strings.
+                  parseSupported = !parse('"\t"');
+                } catch (exception) {}
+                Eif (parseSupported) {
+                  try {
+                    // FF 4.0 and 4.0.1 allow leading `+` signs and leading
+                    // decimal points. FF 4.0, 4.0.1, and IE 9-10 also allow
+                    // certain octal literals.
+                    parseSupported = parse("01") !== 1;
+                  } catch (exception) {}
+                }
+                Eif (parseSupported) {
+                  try {
+                    // FF 4.0, 4.0.1, and Rhino 1.7R3-R4 allow trailing decimal
+                    // points. These environments, along with FF 3.1b1 and 2,
+                    // also allow trailing commas in JSON objects and arrays.
+                    parseSupported = parse("1.") !== 1;
+                  } catch (exception) {}
+                }
+              }
+            }
+          } catch (exception) {
+            parseSupported = false;
+          }
+        }
+        isSupported = parseSupported;
+      }
+    }
+    return has[name] = !!isSupported;
+  }
+  has["bug-string-char-index"] = null;
+  has["json"] = null;
+  has["json-stringify"] = null;
+  has["json-parse"] = null;
+ 
+  Iif (!has("json")) {
+    // Common `[[Class]]` name aliases.
+    var functionClass = "[object Function]";
+    var dateClass = "[object Date]";
+    var numberClass = "[object Number]";
+    var stringClass = "[object String]";
+    var arrayClass = "[object Array]";
+    var booleanClass = "[object Boolean]";
+ 
+    // Detect incomplete support for accessing string characters by index.
+    var charIndexBuggy = has("bug-string-char-index");
+ 
+    // Define additional utility methods if the `Date` methods are buggy.
+    if (!isExtended) {
+      var floor = Math.floor;
+      // A mapping between the months of the year and the number of days between
+      // January 1st and the first of the respective month.
+      var Months = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
+      // Internal: Calculates the number of days between the Unix epoch and the
+      // first day of the given month.
+      var getDay = function (year, month) {
+        return Months[month] + 365 * (year - 1970) + floor((year - 1969 + (month = +(month > 1))) / 4) - floor((year - 1901 + month) / 100) + floor((year - 1601 + month) / 400);
+      };
+    }
+ 
+    // Internal: Determines if a property is a direct property of the given
+    // object. Delegates to the native `Object#hasOwnProperty` method.
+    if (!(isProperty = {}.hasOwnProperty)) {
+      isProperty = function (property) {
+        var members = {}, constructor;
+        if ((members.__proto__ = null, members.__proto__ = {
+          // The *proto* property cannot be set multiple times in recent
+          // versions of Firefox and SeaMonkey.
+          "toString": 1
+        }, members).toString != getClass) {
+          // Safari <= 2.0.3 doesn't implement `Object#hasOwnProperty`, but
+          // supports the mutable *proto* property.
+          isProperty = function (property) {
+            // Capture and break the object's prototype chain (see section 8.6.2
+            // of the ES 5.1 spec). The parenthesized expression prevents an
+            // unsafe transformation by the Closure Compiler.
+            var original = this.__proto__, result = property in (this.__proto__ = null, this);
+            // Restore the original prototype chain.
+            this.__proto__ = original;
+            return result;
+          };
+        } else {
+          // Capture a reference to the top-level `Object` constructor.
+          constructor = members.constructor;
+          // Use the `constructor` property to simulate `Object#hasOwnProperty` in
+          // other environments.
+          isProperty = function (property) {
+            var parent = (this.constructor || constructor).prototype;
+            return property in this && !(property in parent && this[property] === parent[property]);
+          };
+        }
+        members = null;
+        return isProperty.call(this, property);
+      };
+    }
+ 
+    // Internal: A set of primitive types used by `isHostType`.
+    var PrimitiveTypes = {
+      'boolean': 1,
+      'number': 1,
+      'string': 1,
+      'undefined': 1
+    };
+ 
+    // Internal: Determines if the given object `property` value is a
+    // non-primitive.
+    var isHostType = function (object, property) {
+      var type = typeof object[property];
+      return type == 'object' ? !!object[property] : !PrimitiveTypes[type];
+    };
+ 
+    // Internal: Normalizes the `for...in` iteration algorithm across
+    // environments. Each enumerated key is yielded to a `callback` function.
+    forEach = function (object, callback) {
+      var size = 0, Properties, members, property;
+ 
+      // Tests for bugs in the current environment's `for...in` algorithm. The
+      // `valueOf` property inherits the non-enumerable flag from
+      // `Object.prototype` in older versions of IE, Netscape, and Mozilla.
+      (Properties = function () {
+        this.valueOf = 0;
+      }).prototype.valueOf = 0;
+ 
+      // Iterate over a new instance of the `Properties` class.
+      members = new Properties();
+      for (property in members) {
+        // Ignore all properties inherited from `Object.prototype`.
+        if (isProperty.call(members, property)) {
+          size++;
+        }
+      }
+      Properties = members = null;
+ 
+      // Normalize the iteration algorithm.
+      if (!size) {
+        // A list of non-enumerable properties inherited from `Object.prototype`.
+        members = ["valueOf", "toString", "toLocaleString", "propertyIsEnumerable", "isPrototypeOf", "hasOwnProperty", "constructor"];
+        // IE <= 8, Mozilla 1.0, and Netscape 6.2 ignore shadowed non-enumerable
+        // properties.
+        forEach = function (object, callback) {
+          var isFunction = getClass.call(object) == functionClass, property, length;
+          var hasProperty = !isFunction && typeof object.constructor != 'function' && isHostType(object, 'hasOwnProperty') ? object.hasOwnProperty : isProperty;
+          for (property in object) {
+            // Gecko <= 1.0 enumerates the `prototype` property of functions under
+            // certain conditions; IE does not.
+            if (!(isFunction && property == "prototype") && hasProperty.call(object, property)) {
+              callback(property);
+            }
+          }
+          // Manually invoke the callback for each non-enumerable property.
+          for (length = members.length; property = members[--length]; hasProperty.call(object, property) && callback(property));
+        };
+      } else if (size == 2) {
+        // Safari <= 2.0.4 enumerates shadowed properties twice.
+        forEach = function (object, callback) {
+          // Create a set of iterated properties.
+          var members = {}, isFunction = getClass.call(object) == functionClass, property;
+          for (property in object) {
+            // Store each property name to prevent double enumeration. The
+            // `prototype` property of functions is not enumerated due to cross-
+            // environment inconsistencies.
+            if (!(isFunction && property == "prototype") && !isProperty.call(members, property) && (members[property] = 1) && isProperty.call(object, property)) {
+              callback(property);
+            }
+          }
+        };
+      } else {
+        // No bugs detected; use the standard `for...in` algorithm.
+        forEach = function (object, callback) {
+          var isFunction = getClass.call(object) == functionClass, property, isConstructor;
+          for (property in object) {
+            if (!(isFunction && property == "prototype") && isProperty.call(object, property) && !(isConstructor = property === "constructor")) {
+              callback(property);
+            }
+          }
+          // Manually invoke the callback for the `constructor` property due to
+          // cross-environment inconsistencies.
+          if (isConstructor || isProperty.call(object, (property = "constructor"))) {
+            callback(property);
+          }
+        };
+      }
+      return forEach(object, callback);
+    };
+ 
+    // Public: Serializes a JavaScript `value` as a JSON string. The optional
+    // `filter` argument may specify either a function that alters how object and
+    // array members are serialized, or an array of strings and numbers that
+    // indicates which properties should be serialized. The optional `width`
+    // argument may be either a string or number that specifies the indentation
+    // level of the output.
+    if (!has("json-stringify")) {
+      // Internal: A map of control characters and their escaped equivalents.
+      var Escapes = {
+        92: "\\\\",
+        34: '\\"',
+        8: "\\b",
+        12: "\\f",
+        10: "\\n",
+        13: "\\r",
+        9: "\\t"
+      };
+ 
+      // Internal: Converts `value` into a zero-padded string such that its
+      // length is at least equal to `width`. The `width` must be <= 6.
+      var leadingZeroes = "000000";
+      var toPaddedString = function (width, value) {
+        // The `|| 0` expression is necessary to work around a bug in
+        // Opera <= 7.54u2 where `0 == -0`, but `String(-0) !== "0"`.
+        return (leadingZeroes + (value || 0)).slice(-width);
+      };
+ 
+      // Internal: Double-quotes a string `value`, replacing all ASCII control
+      // characters (characters with code unit values between 0 and 31) with
+      // their escaped equivalents. This is an implementation of the
+      // `Quote(value)` operation defined in ES 5.1 section 15.12.3.
+      var unicodePrefix = "\\u00";
+      var quote = function (value) {
+        var result = '"', index = 0, length = value.length, isLarge = length > 10 && charIndexBuggy, symbols;
+        if (isLarge) {
+          symbols = value.split("");
+        }
+        for (; index < length; index++) {
+          var charCode = value.charCodeAt(index);
+          // If the character is a control character, append its Unicode or
+          // shorthand escape sequence; otherwise, append the character as-is.
+          switch (charCode) {
+            case 8: case 9: case 10: case 12: case 13: case 34: case 92:
+              result += Escapes[charCode];
+              break;
+            default:
+              if (charCode < 32) {
+                result += unicodePrefix + toPaddedString(2, charCode.toString(16));
+                break;
+              }
+              result += isLarge ? symbols[index] : charIndexBuggy ? value.charAt(index) : value[index];
+          }
+        }
+        return result + '"';
+      };
+ 
+      // Internal: Recursively serializes an object. Implements the
+      // `Str(key, holder)`, `JO(value)`, and `JA(value)` operations.
+      var serialize = function (property, object, callback, properties, whitespace, indentation, stack) {
+        var value, className, year, month, date, time, hours, minutes, seconds, milliseconds, results, element, index, length, prefix, hasMembers, result;
+        try {
+          // Necessary for host object support.
+          value = object[property];
+        } catch (exception) {}
+        if (typeof value == "object" && value) {
+          className = getClass.call(value);
+          if (className == dateClass && !isProperty.call(value, "toJSON")) {
+            if (value > -1 / 0 && value < 1 / 0) {
+              // Dates are serialized according to the `Date#toJSON` method
+              // specified in ES 5.1 section 15.9.5.44. See section 15.9.1.15
+              // for the ISO 8601 date time string format.
+              if (getDay) {
+                // Manually compute the year, month, date, hours, minutes,
+                // seconds, and milliseconds if the `getUTC*` methods are
+                // buggy. Adapted from @Yaffle's `date-shim` project.
+                date = floor(value / 864e5);
+                for (year = floor(date / 365.2425) + 1970 - 1; getDay(year + 1, 0) <= date; year++);
+                for (month = floor((date - getDay(year, 0)) / 30.42); getDay(year, month + 1) <= date; month++);
+                date = 1 + date - getDay(year, month);
+                // The `time` value specifies the time within the day (see ES
+                // 5.1 section 15.9.1.2). The formula `(A % B + B) % B` is used
+                // to compute `A modulo B`, as the `%` operator does not
+                // correspond to the `modulo` operation for negative numbers.
+                time = (value % 864e5 + 864e5) % 864e5;
+                // The hours, minutes, seconds, and milliseconds are obtained by
+                // decomposing the time within the day. See section 15.9.1.10.
+                hours = floor(time / 36e5) % 24;
+                minutes = floor(time / 6e4) % 60;
+                seconds = floor(time / 1e3) % 60;
+                milliseconds = time % 1e3;
+              } else {
+                year = value.getUTCFullYear();
+                month = value.getUTCMonth();
+                date = value.getUTCDate();
+                hours = value.getUTCHours();
+                minutes = value.getUTCMinutes();
+                seconds = value.getUTCSeconds();
+                milliseconds = value.getUTCMilliseconds();
+              }
+              // Serialize extended years correctly.
+              value = (year <= 0 || year >= 1e4 ? (year < 0 ? "-" : "+") + toPaddedString(6, year < 0 ? -year : year) : toPaddedString(4, year)) +
+                "-" + toPaddedString(2, month + 1) + "-" + toPaddedString(2, date) +
+                // Months, dates, hours, minutes, and seconds should have two
+                // digits; milliseconds should have three.
+                "T" + toPaddedString(2, hours) + ":" + toPaddedString(2, minutes) + ":" + toPaddedString(2, seconds) +
+                // Milliseconds are optional in ES 5.0, but required in 5.1.
+                "." + toPaddedString(3, milliseconds) + "Z";
+            } else {
+              value = null;
+            }
+          } else if (typeof value.toJSON == "function" && ((className != numberClass && className != stringClass && className != arrayClass) || isProperty.call(value, "toJSON"))) {
+            // Prototype <= 1.6.1 adds non-standard `toJSON` methods to the
+            // `Number`, `String`, `Date`, and `Array` prototypes. JSON 3
+            // ignores all `toJSON` methods on these objects unless they are
+            // defined directly on an instance.
+            value = value.toJSON(property);
+          }
+        }
+        if (callback) {
+          // If a replacement function was provided, call it to obtain the value
+          // for serialization.
+          value = callback.call(object, property, value);
+        }
+        if (value === null) {
+          return "null";
+        }
+        className = getClass.call(value);
+        if (className == booleanClass) {
+          // Booleans are represented literally.
+          return "" + value;
+        } else if (className == numberClass) {
+          // JSON numbers must be finite. `Infinity` and `NaN` are serialized as
+          // `"null"`.
+          return value > -1 / 0 && value < 1 / 0 ? "" + value : "null";
+        } else if (className == stringClass) {
+          // Strings are double-quoted and escaped.
+          return quote("" + value);
+        }
+        // Recursively serialize objects and arrays.
+        if (typeof value == "object") {
+          // Check for cyclic structures. This is a linear search; performance
+          // is inversely proportional to the number of unique nested objects.
+          for (length = stack.length; length--;) {
+            if (stack[length] === value) {
+              // Cyclic structures cannot be serialized by `JSON.stringify`.
+              throw TypeError();
+            }
+          }
+          // Add the object to the stack of traversed objects.
+          stack.push(value);
+          results = [];
+          // Save the current indentation level and indent one additional level.
+          prefix = indentation;
+          indentation += whitespace;
+          if (className == arrayClass) {
+            // Recursively serialize array elements.
+            for (index = 0, length = value.length; index < length; hasMembers || (hasMembers = true), index++) {
+              element = serialize(index, value, callback, properties, whitespace, indentation, stack);
+              results.push(element === undef ? "null" : element);
+            }
+            result = hasMembers ? (whitespace ? "[\n" + indentation + results.join(",\n" + indentation) + "\n" + prefix + "]" : ("[" + results.join(",") + "]")) : "[]";
+          } else {
+            // Recursively serialize object members. Members are selected from
+            // either a user-specified list of property names, or the object
+            // itself.
+            forEach(properties || value, function (property) {
+              var element = serialize(property, value, callback, properties, whitespace, indentation, stack);
+              if (element !== undef) {
+                // According to ES 5.1 section 15.12.3: "If `gap` {whitespace}
+                // is not the empty string, let `member` {quote(property) + ":"}
+                // be the concatenation of `member` and the `space` character."
+                // The "`space` character" refers to the literal space
+                // character, not the `space` {width} argument provided to
+                // `JSON.stringify`.
+                results.push(quote(property) + ":" + (whitespace ? " " : "") + element);
+              }
+              hasMembers || (hasMembers = true);
+            });
+            result = hasMembers ? (whitespace ? "{\n" + indentation + results.join(",\n" + indentation) + "\n" + prefix + "}" : ("{" + results.join(",") + "}")) : "{}";
+          }
+          // Remove the object from the traversed object stack.
+          stack.pop();
+          return result;
+        }
+      };
+ 
+      // Public: `JSON.stringify`. See ES 5.1 section 15.12.3.
+      JSON3.stringify = function (source, filter, width) {
+        var whitespace, callback, properties, className;
+        if (typeof filter == "function" || typeof filter == "object" && filter) {
+          if ((className = getClass.call(filter)) == functionClass) {
+            callback = filter;
+          } else if (className == arrayClass) {
+            // Convert the property names array into a makeshift set.
+            properties = {};
+            for (var index = 0, length = filter.length, value; index < length; value = filter[index++], ((getClass.call(value) == stringClass || getClass.call(value) == numberClass) && (properties[value] = 1)));
+          }
+        }
+        if (width) {
+          if ((className = getClass.call(width)) == numberClass) {
+            // Convert the `width` to an integer and create a string containing
+            // `width` number of space characters.
+            if ((width -= width % 1) > 0) {
+              for (whitespace = "", width > 10 && (width = 10); whitespace.length < width; whitespace += " ");
+            }
+          } else if (className == stringClass) {
+            whitespace = width.length <= 10 ? width : width.slice(0, 10);
+          }
+        }
+        // Opera <= 7.54u2 discards the values associated with empty string keys
+        // (`""`) only if they are used directly within an object member list
+        // (e.g., `!("" in { "": 1})`).
+        return serialize("", (value = {}, value[""] = source, value), callback, properties, whitespace, "", []);
+      };
+    }
+ 
+    // Public: Parses a JSON source string.
+    if (!has("json-parse")) {
+      var fromCharCode = String.fromCharCode;
+ 
+      // Internal: A map of escaped control characters and their unescaped
+      // equivalents.
+      var Unescapes = {
+        92: "\\",
+        34: '"',
+        47: "/",
+        98: "\b",
+        116: "\t",
+        110: "\n",
+        102: "\f",
+        114: "\r"
+      };
+ 
+      // Internal: Stores the parser state.
+      var Index, Source;
+ 
+      // Internal: Resets the parser state and throws a `SyntaxError`.
+      var abort = function() {
+        Index = Source = null;
+        throw SyntaxError();
+      };
+ 
+      // Internal: Returns the next token, or `"$"` if the parser has reached
+      // the end of the source string. A token may be a string, number, `null`
+      // literal, or Boolean literal.
+      var lex = function () {
+        var source = Source, length = source.length, value, begin, position, isSigned, charCode;
+        while (Index < length) {
+          charCode = source.charCodeAt(Index);
+          switch (charCode) {
+            case 9: case 10: case 13: case 32:
+              // Skip whitespace tokens, including tabs, carriage returns, line
+              // feeds, and space characters.
+              Index++;
+              break;
+            case 123: case 125: case 91: case 93: case 58: case 44:
+              // Parse a punctuator token (`{`, `}`, `[`, `]`, `:`, or `,`) at
+              // the current position.
+              value = charIndexBuggy ? source.charAt(Index) : source[Index];
+              Index++;
+              return value;
+            case 34:
+              // `"` delimits a JSON string; advance to the next character and
+              // begin parsing the string. String tokens are prefixed with the
+              // sentinel `@` character to distinguish them from punctuators and
+              // end-of-string tokens.
+              for (value = "@", Index++; Index < length;) {
+                charCode = source.charCodeAt(Index);
+                if (charCode < 32) {
+                  // Unescaped ASCII control characters (those with a code unit
+                  // less than the space character) are not permitted.
+                  abort();
+                } else if (charCode == 92) {
+                  // A reverse solidus (`\`) marks the beginning of an escaped
+                  // control character (including `"`, `\`, and `/`) or Unicode
+                  // escape sequence.
+                  charCode = source.charCodeAt(++Index);
+                  switch (charCode) {
+                    case 92: case 34: case 47: case 98: case 116: case 110: case 102: case 114:
+                      // Revive escaped control characters.
+                      value += Unescapes[charCode];
+                      Index++;
+                      break;
+                    case 117:
+                      // `\u` marks the beginning of a Unicode escape sequence.
+                      // Advance to the first character and validate the
+                      // four-digit code point.
+                      begin = ++Index;
+                      for (position = Index + 4; Index < position; Index++) {
+                        charCode = source.charCodeAt(Index);
+                        // A valid sequence comprises four hexdigits (case-
+                        // insensitive) that form a single hexadecimal value.
+                        if (!(charCode >= 48 && charCode <= 57 || charCode >= 97 && charCode <= 102 || charCode >= 65 && charCode <= 70)) {
+                          // Invalid Unicode escape sequence.
+                          abort();
+                        }
+                      }
+                      // Revive the escaped character.
+                      value += fromCharCode("0x" + source.slice(begin, Index));
+                      break;
+                    default:
+                      // Invalid escape sequence.
+                      abort();
+                  }
+                } else {
+                  if (charCode == 34) {
+                    // An unescaped double-quote character marks the end of the
+                    // string.
+                    break;
+                  }
+                  charCode = source.charCodeAt(Index);
+                  begin = Index;
+                  // Optimize for the common case where a string is valid.
+                  while (charCode >= 32 && charCode != 92 && charCode != 34) {
+                    charCode = source.charCodeAt(++Index);
+                  }
+                  // Append the string as-is.
+                  value += source.slice(begin, Index);
+                }
+              }
+              if (source.charCodeAt(Index) == 34) {
+                // Advance to the next character and return the revived string.
+                Index++;
+                return value;
+              }
+              // Unterminated string.
+              abort();
+            default:
+              // Parse numbers and literals.
+              begin = Index;
+              // Advance past the negative sign, if one is specified.
+              if (charCode == 45) {
+                isSigned = true;
+                charCode = source.charCodeAt(++Index);
+              }
+              // Parse an integer or floating-point value.
+              if (charCode >= 48 && charCode <= 57) {
+                // Leading zeroes are interpreted as octal literals.
+                if (charCode == 48 && ((charCode = source.charCodeAt(Index + 1)), charCode >= 48 && charCode <= 57)) {
+                  // Illegal octal literal.
+                  abort();
+                }
+                isSigned = false;
+                // Parse the integer component.
+                for (; Index < length && ((charCode = source.charCodeAt(Index)), charCode >= 48 && charCode <= 57); Index++);
+                // Floats cannot contain a leading decimal point; however, this
+                // case is already accounted for by the parser.
+                if (source.charCodeAt(Index) == 46) {
+                  position = ++Index;
+                  // Parse the decimal component.
+                  for (; position < length && ((charCode = source.charCodeAt(position)), charCode >= 48 && charCode <= 57); position++);
+                  if (position == Index) {
+                    // Illegal trailing decimal.
+                    abort();
+                  }
+                  Index = position;
+                }
+                // Parse exponents. The `e` denoting the exponent is
+                // case-insensitive.
+                charCode = source.charCodeAt(Index);
+                if (charCode == 101 || charCode == 69) {
+                  charCode = source.charCodeAt(++Index);
+                  // Skip past the sign following the exponent, if one is
+                  // specified.
+                  if (charCode == 43 || charCode == 45) {
+                    Index++;
+                  }
+                  // Parse the exponential component.
+                  for (position = Index; position < length && ((charCode = source.charCodeAt(position)), charCode >= 48 && charCode <= 57); position++);
+                  if (position == Index) {
+                    // Illegal empty exponent.
+                    abort();
+                  }
+                  Index = position;
+                }
+                // Coerce the parsed value to a JavaScript number.
+                return +source.slice(begin, Index);
+              }
+              // A negative sign may only precede numbers.
+              if (isSigned) {
+                abort();
+              }
+              // `true`, `false`, and `null` literals.
+              if (source.slice(Index, Index + 4) == "true") {
+                Index += 4;
+                return true;
+              } else if (source.slice(Index, Index + 5) == "false") {
+                Index += 5;
+                return false;
+              } else if (source.slice(Index, Index + 4) == "null") {
+                Index += 4;
+                return null;
+              }
+              // Unrecognized token.
+              abort();
+          }
+        }
+        // Return the sentinel `$` character if the parser has reached the end
+        // of the source string.
+        return "$";
+      };
+ 
+      // Internal: Parses a JSON `value` token.
+      var get = function (value) {
+        var results, hasMembers;
+        if (value == "$") {
+          // Unexpected end of input.
+          abort();
+        }
+        if (typeof value == "string") {
+          if ((charIndexBuggy ? value.charAt(0) : value[0]) == "@") {
+            // Remove the sentinel `@` character.
+            return value.slice(1);
+          }
+          // Parse object and array literals.
+          if (value == "[") {
+            // Parses a JSON array, returning a new JavaScript array.
+            results = [];
+            for (;; hasMembers || (hasMembers = true)) {
+              value = lex();
+              // A closing square bracket marks the end of the array literal.
+              if (value == "]") {
+                break;
+              }
+              // If the array literal contains elements, the current token
+              // should be a comma separating the previous element from the
+              // next.
+              if (hasMembers) {
+                if (value == ",") {
+                  value = lex();
+                  if (value == "]") {
+                    // Unexpected trailing `,` in array literal.
+                    abort();
+                  }
+                } else {
+                  // A `,` must separate each array element.
+                  abort();
+                }
+              }
+              // Elisions and leading commas are not permitted.
+              if (value == ",") {
+                abort();
+              }
+              results.push(get(value));
+            }
+            return results;
+          } else if (value == "{") {
+            // Parses a JSON object, returning a new JavaScript object.
+            results = {};
+            for (;; hasMembers || (hasMembers = true)) {
+              value = lex();
+              // A closing curly brace marks the end of the object literal.
+              if (value == "}") {
+                break;
+              }
+              // If the object literal contains members, the current token
+              // should be a comma separator.
+              if (hasMembers) {
+                if (value == ",") {
+                  value = lex();
+                  if (value == "}") {
+                    // Unexpected trailing `,` in object literal.
+                    abort();
+                  }
+                } else {
+                  // A `,` must separate each object member.
+                  abort();
+                }
+              }
+              // Leading commas are not permitted, object property names must be
+              // double-quoted strings, and a `:` must separate each property
+              // name and value.
+              if (value == "," || typeof value != "string" || (charIndexBuggy ? value.charAt(0) : value[0]) != "@" || lex() != ":") {
+                abort();
+              }
+              results[value.slice(1)] = get(lex());
+            }
+            return results;
+          }
+          // Unexpected token encountered.
+          abort();
+        }
+        return value;
+      };
+ 
+      // Internal: Updates a traversed object member.
+      var update = function(source, property, callback) {
+        var element = walk(source, property, callback);
+        if (element === undef) {
+          delete source[property];
+        } else {
+          source[property] = element;
+        }
+      };
+ 
+      // Internal: Recursively traverses a parsed JSON object, invoking the
+      // `callback` function for each value. This is an implementation of the
+      // `Walk(holder, name)` operation defined in ES 5.1 section 15.12.2.
+      var walk = function (source, property, callback) {
+        var value = source[property], length;
+        if (typeof value == "object" && value) {
+          // `forEach` can't be used to traverse an array in Opera <= 8.54
+          // because its `Object#hasOwnProperty` implementation returns `false`
+          // for array indices (e.g., `![1, 2, 3].hasOwnProperty("0")`).
+          if (getClass.call(value) == arrayClass) {
+            for (length = value.length; length--;) {
+              update(value, length, callback);
+            }
+          } else {
+            forEach(value, function (property) {
+              update(value, property, callback);
+            });
+          }
+        }
+        return callback.call(source, property, value);
+      };
+ 
+      // Public: `JSON.parse`. See ES 5.1 section 15.12.2.
+      JSON3.parse = function (source, callback) {
+        var result, value;
+        Index = 0;
+        Source = "" + source;
+        result = get(lex());
+        // If a JSON string contains multiple tokens, it is invalid.
+        if (lex() != "$") {
+          abort();
+        }
+        // Reset the parser state.
+        Index = Source = null;
+        return callback && getClass.call(callback) == functionClass ? walk((value = {}, value[""] = result, value), "", callback) : result;
+      };
+    }
+  }
+ 
+  // Export for asynchronous module loaders.
+  Iif (isLoader) {
+    define(function () {
+      return JSON3;
+    });
+  }
+}(this));
+ 
+ +
+ + + + + + + + diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/coverage/lcov-report/prettify.css b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/coverage/lcov-report/prettify.css index 5181e157..b317a7cd 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/coverage/lcov-report/prettify.css +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/coverage/lcov-report/prettify.css @@ -1 +1 @@ -.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} +.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/coverage/lcov-report/prettify.js b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/coverage/lcov-report/prettify.js index eaf4912c..ef51e038 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/coverage/lcov-report/prettify.js +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/coverage/lcov-report/prettify.js @@ -1 +1 @@ -window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); +window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/coverage/lcov.info b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/coverage/lcov.info index ea341e47..9a4d72d2 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/coverage/lcov.info +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/coverage/lcov.info @@ -1,2035 +1,2035 @@ -TN: -SF:/Users/kit/Dropbox/Projects/json3/vendor/spec/lib/spec.js -FN:11,(anonymous_1) -FN:20,(anonymous_2) -FN:21,noConflict -FN:31,(anonymous_4) -FN:70,(anonymous_5) -FN:78,hasKey -FN:86,hasKey -FN:102,hasKey -FN:117,(anonymous_9) -FN:123,Properties -FN:145,forOwn -FN:169,forOwn -FN:188,forOwn -FN:210,(anonymous_14) -FN:213,eq -FN:289,(anonymous_16) -FN:297,(anonymous_17) -FN:311,equals -FN:328,forEach -FN:343,(anonymous_20) -FN:347,defer -FN:354,run -FN:361,defer -FN:362,run -FN:370,defer -FN:372,run -FN:387,(anonymous_27) -FN:395,defer -FN:404,rethrow -FN:405,(anonymous_30) -FN:418,Events -FN:429,addListener -FN:431,(anonymous_33) -FN:454,removeListener -FN:459,(anonymous_35) -FN:483,emit -FN:531,Suite -FN:547,(anonymous_38) -FN:555,shuffle -FN:567,addTest -FN:575,index -FN:594,onSuiteEvent -FN:622,runSuite -FN:645,Test -FN:668,onTestEvent -FN:697,assert -FN:698,assertion -FN:710,runTest -FN:720,ok -FN:735,notOk -FN:742,assertEqual -FN:748,assertNotEqual -FN:754,assertStrictEqual -FN:760,assertStrictNotEqual -FN:770,assertNotDeepEqual -FN:776,assertError -FN:793,assertNoError -FN:806,done -FNF:58 -FNH:38 -FNDA:1,(anonymous_1) -FNDA:0,(anonymous_2) -FNDA:0,noConflict -FNDA:1,(anonymous_4) -FNDA:1,(anonymous_5) -FNDA:5538,hasKey -FNDA:0,hasKey -FNDA:0,hasKey -FNDA:1,(anonymous_9) -FNDA:1,Properties -FNDA:0,forOwn -FNDA:0,forOwn -FNDA:26,forOwn -FNDA:1,(anonymous_14) -FNDA:102,eq -FNDA:15,(anonymous_16) -FNDA:15,(anonymous_17) -FNDA:51,equals -FNDA:49,forEach -FNDA:1,(anonymous_20) -FNDA:0,defer -FNDA:0,run -FNDA:0,defer -FNDA:0,run -FNDA:0,defer -FNDA:0,run -FNDA:0,(anonymous_27) -FNDA:11,defer -FNDA:0,rethrow -FNDA:0,(anonymous_30) -FNDA:14,Events -FNDA:34,addListener -FNDA:34,(anonymous_33) -FNDA:11,removeListener -FNDA:11,(anonymous_35) -FNDA:594,emit -FNDA:1,Suite -FNDA:1,(anonymous_38) -FNDA:1,shuffle -FNDA:11,addTest -FNDA:12,index -FNDA:296,onSuiteEvent -FNDA:1,runSuite -FNDA:11,Test -FNDA:296,onTestEvent -FNDA:6,assert -FNDA:117,assertion -FNDA:11,runTest -FNDA:274,ok -FNDA:0,notOk -FNDA:15,assertEqual -FNDA:0,assertNotEqual -FNDA:51,assertStrictEqual -FNDA:0,assertStrictNotEqual -FNDA:0,assertNotDeepEqual -FNDA:156,assertError -FNDA:0,assertNoError -FNDA:11,done -DA:11,1 -DA:12,1 -DA:14,0 -DA:17,1 -DA:21,1 -DA:22,0 -DA:24,0 -DA:25,0 -DA:27,0 -DA:35,1 -DA:41,1 -DA:71,1 -DA:73,1 -DA:74,1 -DA:76,1 -DA:78,1 -DA:79,5538 -DA:80,0 -DA:82,5538 -DA:84,0 -DA:86,0 -DA:87,0 -DA:88,0 -DA:89,0 -DA:93,0 -DA:94,0 -DA:96,0 -DA:97,0 -DA:102,0 -DA:103,0 -DA:104,0 -DA:106,0 -DA:107,0 -DA:110,1 -DA:118,1 -DA:123,1 -DA:124,1 -DA:126,1 -DA:129,1 -DA:130,1 -DA:132,1 -DA:133,1 -DA:136,1 -DA:139,1 -DA:141,0 -DA:144,0 -DA:145,0 -DA:146,0 -DA:147,0 -DA:148,0 -DA:150,0 -DA:151,0 -DA:154,0 -DA:155,0 -DA:159,0 -DA:160,0 -DA:161,0 -DA:162,0 -DA:166,1 -DA:168,0 -DA:169,0 -DA:170,0 -DA:171,0 -DA:172,0 -DA:175,0 -DA:176,0 -DA:177,0 -DA:181,0 -DA:182,0 -DA:188,1 -DA:189,26 -DA:190,26 -DA:191,0 -DA:193,26 -DA:194,26 -DA:195,30 -DA:196,0 -DA:201,26 -DA:202,0 -DA:206,1 -DA:213,1 -DA:214,102 -DA:216,102 -DA:219,72 -DA:222,30 -DA:223,0 -DA:225,30 -DA:226,30 -DA:227,0 -DA:229,30 -DA:234,0 -DA:236,0 -DA:237,0 -DA:240,0 -DA:246,0 -DA:250,0 -DA:256,30 -DA:257,0 -DA:263,30 -DA:264,22 -DA:265,0 -DA:269,30 -DA:270,30 -DA:272,30 -DA:274,17 -DA:275,17 -DA:276,17 -DA:278,17 -DA:280,36 -DA:281,0 -DA:286,13 -DA:288,13 -DA:289,13 -DA:291,15 -DA:293,15 -DA:296,13 -DA:297,13 -DA:298,15 -DA:299,0 -DA:302,13 -DA:306,30 -DA:307,30 -DA:311,1 -DA:312,51 -DA:315,51 -DA:316,0 -DA:319,51 -DA:322,1 -DA:329,49 -DA:330,49 -DA:331,0 -DA:333,49 -DA:334,114 -DA:335,0 -DA:338,49 -DA:344,1 -DA:346,1 -DA:347,1 -DA:354,1 -DA:355,0 -DA:357,0 -DA:360,0 -DA:361,0 -DA:362,1 -DA:363,0 -DA:365,0 -DA:369,0 -DA:370,0 -DA:371,0 -DA:372,1 -DA:376,0 -DA:377,0 -DA:382,0 -DA:386,0 -DA:387,0 -DA:388,0 -DA:390,0 -DA:394,1 -DA:395,1 -DA:396,11 -DA:399,1 -DA:404,1 -DA:405,0 -DA:406,0 -DA:417,1 -DA:418,1 -DA:419,14 -DA:428,1 -DA:429,1 -DA:430,34 -DA:431,34 -DA:432,34 -DA:433,34 -DA:435,34 -DA:436,34 -DA:438,34 -DA:444,34 -DA:453,1 -DA:454,1 -DA:455,11 -DA:457,0 -DA:458,11 -DA:459,11 -DA:460,11 -DA:461,11 -DA:463,11 -DA:464,11 -DA:466,11 -DA:467,11 -DA:468,22 -DA:469,11 -DA:476,11 -DA:482,1 -DA:483,1 -DA:484,594 -DA:486,594 -DA:487,13 -DA:489,594 -DA:491,594 -DA:492,298 -DA:495,594 -DA:496,594 -DA:497,0 -DA:498,0 -DA:500,0 -DA:501,0 -DA:503,0 -DA:508,594 -DA:509,594 -DA:510,594 -DA:511,890 -DA:512,890 -DA:514,0 -DA:518,594 -DA:528,1 -DA:531,1 -DA:532,1 -DA:533,1 -DA:534,1 -DA:536,1 -DA:540,1 -DA:543,1 -DA:544,1 -DA:547,1 -DA:548,1 -DA:549,8 -DA:554,1 -DA:555,1 -DA:556,1 -DA:557,11 -DA:558,11 -DA:559,11 -DA:560,11 -DA:562,1 -DA:566,1 -DA:567,1 -DA:568,11 -DA:569,11 -DA:574,1 -DA:575,1 -DA:576,12 -DA:577,12 -DA:578,12 -DA:579,0 -DA:581,12 -DA:582,11 -DA:583,11 -DA:584,11 -DA:587,1 -DA:593,1 -DA:594,1 -DA:595,296 -DA:597,296 -DA:598,296 -DA:601,274 -DA:602,274 -DA:604,0 -DA:605,0 -DA:608,11 -DA:609,11 -DA:610,10 -DA:612,10 -DA:615,1 -DA:621,1 -DA:622,1 -DA:624,1 -DA:625,1 -DA:627,1 -DA:629,1 -DA:630,1 -DA:632,1 -DA:635,0 -DA:637,1 -DA:644,1 -DA:645,1 -DA:646,11 -DA:647,11 -DA:648,0 -DA:649,0 -DA:651,11 -DA:652,11 -DA:654,11 -DA:656,11 -DA:660,1 -DA:661,1 -DA:664,1 -DA:667,1 -DA:668,1 -DA:669,296 -DA:670,296 -DA:672,11 -DA:673,11 -DA:675,274 -DA:676,274 -DA:678,0 -DA:679,0 -DA:681,11 -DA:683,11 -DA:684,0 -DA:696,1 -DA:697,1 -DA:698,1 -DA:699,117 -DA:705,6 -DA:709,1 -DA:710,1 -DA:711,11 -DA:713,11 -DA:714,11 -DA:719,1 -DA:720,1 -DA:721,274 -DA:722,157 -DA:729,274 -DA:730,274 -DA:734,1 -DA:735,1 -DA:736,0 -DA:741,1 -DA:742,1 -DA:743,15 -DA:747,1 -DA:748,1 -DA:749,0 -DA:753,1 -DA:754,1 -DA:755,51 -DA:759,1 -DA:760,1 -DA:761,0 -DA:766,1 -DA:769,1 -DA:770,1 -DA:771,0 -DA:775,1 -DA:776,1 -DA:777,156 -DA:779,156 -DA:780,0 -DA:781,0 -DA:783,156 -DA:784,156 -DA:786,156 -DA:788,156 -DA:792,1 -DA:793,1 -DA:794,0 -DA:795,0 -DA:796,0 -DA:798,0 -DA:800,0 -DA:805,1 -DA:806,1 -DA:807,11 -DA:812,1 -LF:355 -LH:248 -BRDA:12,1,0,0 -BRDA:12,1,1,1 -BRDA:12,2,0,1 -BRDA:12,2,1,0 -BRDA:17,3,0,1 -BRDA:17,3,1,1 -BRDA:17,3,2,0 -BRDA:59,4,0,1 -BRDA:59,4,1,1 -BRDA:59,4,2,1 -BRDA:63,5,0,1 -BRDA:63,5,1,0 -BRDA:63,5,2,0 -BRDA:63,5,3,0 -BRDA:76,6,0,1 -BRDA:76,6,1,0 -BRDA:79,7,0,0 -BRDA:79,7,1,5538 -BRDA:84,8,0,0 -BRDA:84,8,1,0 -BRDA:88,9,0,0 -BRDA:88,9,1,0 -BRDA:103,10,0,0 -BRDA:103,10,1,0 -BRDA:106,11,0,0 -BRDA:106,11,1,0 -BRDA:107,12,0,0 -BRDA:107,12,1,0 -BRDA:107,13,0,0 -BRDA:107,13,1,0 -BRDA:132,14,0,1 -BRDA:132,14,1,0 -BRDA:139,15,0,0 -BRDA:139,15,1,1 -BRDA:147,16,0,0 -BRDA:147,16,1,0 -BRDA:154,17,0,0 -BRDA:154,17,1,0 -BRDA:154,18,0,0 -BRDA:154,18,1,0 -BRDA:154,18,2,0 -BRDA:154,19,0,0 -BRDA:154,19,1,0 -BRDA:161,20,0,0 -BRDA:161,20,1,0 -BRDA:161,21,0,0 -BRDA:161,21,1,0 -BRDA:166,22,0,0 -BRDA:166,22,1,1 -BRDA:171,23,0,0 -BRDA:171,23,1,0 -BRDA:181,24,0,0 -BRDA:181,24,1,0 -BRDA:181,25,0,0 -BRDA:181,25,1,0 -BRDA:181,25,2,0 -BRDA:181,25,3,0 -BRDA:181,25,4,0 -BRDA:181,26,0,0 -BRDA:181,26,1,0 -BRDA:190,27,0,0 -BRDA:190,27,1,26 -BRDA:195,28,0,0 -BRDA:195,28,1,30 -BRDA:195,29,0,30 -BRDA:195,29,1,30 -BRDA:195,29,2,30 -BRDA:195,29,3,30 -BRDA:195,30,0,30 -BRDA:195,30,1,0 -BRDA:201,31,0,0 -BRDA:201,31,1,26 -BRDA:201,32,0,26 -BRDA:201,32,1,26 -BRDA:216,33,0,72 -BRDA:216,33,1,30 -BRDA:219,34,0,72 -BRDA:219,34,1,15 -BRDA:222,35,0,0 -BRDA:222,35,1,30 -BRDA:226,36,0,0 -BRDA:226,36,1,30 -BRDA:229,37,0,0 -BRDA:229,37,1,0 -BRDA:229,37,2,0 -BRDA:229,37,3,0 -BRDA:229,37,4,0 -BRDA:240,38,0,0 -BRDA:240,38,1,0 -BRDA:240,39,0,0 -BRDA:240,39,1,0 -BRDA:250,40,0,0 -BRDA:250,40,1,0 -BRDA:250,40,2,0 -BRDA:250,40,3,0 -BRDA:250,40,4,0 -BRDA:256,41,0,0 -BRDA:256,41,1,30 -BRDA:256,42,0,30 -BRDA:256,42,1,30 -BRDA:264,43,0,0 -BRDA:264,43,1,22 -BRDA:272,44,0,17 -BRDA:272,44,1,13 -BRDA:276,45,0,17 -BRDA:276,45,1,0 -BRDA:280,46,0,0 -BRDA:280,46,1,36 -BRDA:280,47,0,36 -BRDA:280,47,1,36 -BRDA:293,48,0,15 -BRDA:293,48,1,15 -BRDA:296,49,0,13 -BRDA:296,49,1,0 -BRDA:298,50,0,0 -BRDA:298,50,1,15 -BRDA:315,51,0,0 -BRDA:315,51,1,51 -BRDA:330,52,0,0 -BRDA:330,52,1,49 -BRDA:334,53,0,0 -BRDA:334,53,1,114 -BRDA:346,54,0,1 -BRDA:346,54,1,0 -BRDA:360,55,0,0 -BRDA:360,55,1,0 -BRDA:369,56,0,0 -BRDA:369,56,1,0 -BRDA:394,57,0,1 -BRDA:394,57,1,0 -BRDA:394,58,0,1 -BRDA:394,58,1,1 -BRDA:430,59,0,34 -BRDA:430,59,1,0 -BRDA:430,60,0,34 -BRDA:430,60,1,34 -BRDA:432,61,0,34 -BRDA:432,61,1,11 -BRDA:432,62,0,11 -BRDA:432,62,1,23 -BRDA:440,63,0,11 -BRDA:440,63,1,23 -BRDA:455,64,0,0 -BRDA:455,64,1,11 -BRDA:458,65,0,11 -BRDA:458,65,1,0 -BRDA:460,66,0,11 -BRDA:460,66,1,11 -BRDA:461,67,0,11 -BRDA:461,67,1,0 -BRDA:464,68,0,11 -BRDA:464,68,1,0 -BRDA:466,69,0,11 -BRDA:466,69,1,11 -BRDA:467,70,0,33 -BRDA:467,70,1,33 -BRDA:468,71,0,11 -BRDA:468,71,1,11 -BRDA:468,72,0,22 -BRDA:468,72,1,22 -BRDA:468,72,2,11 -BRDA:468,72,3,11 -BRDA:468,72,4,11 -BRDA:486,73,0,13 -BRDA:486,73,1,581 -BRDA:486,74,0,594 -BRDA:486,74,1,581 -BRDA:489,75,0,594 -BRDA:489,75,1,594 -BRDA:491,76,0,298 -BRDA:491,76,1,296 -BRDA:495,77,0,594 -BRDA:495,77,1,594 -BRDA:495,77,2,594 -BRDA:496,78,0,0 -BRDA:496,78,1,594 -BRDA:496,79,0,594 -BRDA:496,79,1,0 -BRDA:497,80,0,0 -BRDA:497,80,1,0 -BRDA:498,81,0,0 -BRDA:498,81,1,0 -BRDA:501,82,0,0 -BRDA:501,82,1,0 -BRDA:501,82,2,0 -BRDA:508,83,0,594 -BRDA:508,83,1,0 -BRDA:509,84,0,594 -BRDA:509,84,1,594 -BRDA:510,85,0,1484 -BRDA:510,85,1,1484 -BRDA:512,86,0,890 -BRDA:512,86,1,890 -BRDA:512,86,2,298 -BRDA:533,87,0,1 -BRDA:533,87,1,0 -BRDA:577,88,0,12 -BRDA:577,88,1,1 -BRDA:578,89,0,0 -BRDA:578,89,1,12 -BRDA:582,90,0,11 -BRDA:582,90,1,11 -BRDA:583,91,0,11 -BRDA:583,91,1,0 -BRDA:583,92,0,11 -BRDA:583,92,1,11 -BRDA:583,92,2,11 -BRDA:598,93,0,274 -BRDA:598,93,1,0 -BRDA:598,93,2,11 -BRDA:609,94,0,10 -BRDA:609,94,1,1 -BRDA:629,95,0,1 -BRDA:629,95,1,0 -BRDA:647,96,0,0 -BRDA:647,96,1,11 -BRDA:647,97,0,11 -BRDA:647,97,1,11 -BRDA:651,98,0,11 -BRDA:651,98,1,0 -BRDA:670,99,0,11 -BRDA:670,99,1,274 -BRDA:670,99,2,0 -BRDA:670,99,3,11 -BRDA:683,100,0,0 -BRDA:683,100,1,11 -BRDA:683,101,0,11 -BRDA:683,101,1,0 -BRDA:683,101,2,11 -BRDA:702,102,0,0 -BRDA:702,102,1,117 -BRDA:721,103,0,157 -BRDA:721,103,1,117 -BRDA:725,104,0,0 -BRDA:725,104,1,157 -BRDA:729,105,0,274 -BRDA:729,105,1,0 -BRDA:736,106,0,0 -BRDA:736,106,1,0 -BRDA:779,107,0,0 -BRDA:779,107,1,156 -BRDA:779,108,0,156 -BRDA:779,108,1,0 -BRDA:786,109,0,156 -BRDA:786,109,1,156 -BRDA:786,109,2,156 -BRDA:788,110,0,0 -BRDA:788,110,1,156 -BRDA:800,111,0,0 -BRDA:800,111,1,0 -BRF:250 -BRH:133 -end_of_record -TN: -SF:/Users/kit/Dropbox/Projects/json3/vendor/spec/lib/newton.js -FN:8,(anonymous_1) -FN:26,(anonymous_2) -FN:42,(anonymous_3) -FN:43,noConflict -FN:52,(anonymous_5) -FN:61,(anonymous_6) -FN:62,stringify -FN:68,toPaddedString -FN:85,quote -FN:99,serialize -FN:155,(anonymous_11) -FN:172,all -FN:174,(anonymous_13) -FN:181,toQueryPair -FN:200,serializeQuery -FN:202,(anonymous_16) -FN:204,(anonymous_17) -FN:223,parseQuery -FN:256,isEmpty -FN:275,(anonymous_20) -FN:283,substitute -FN:333,createConsole -FN:334,onEvent -FN:359,createTAP -FN:362,description -FN:365,onEvent -FN:391,onClick -FN:401,(anonymous_28) -FN:405,(anonymous_29) -FN:427,serializeAttribute -FN:433,buildNode -FN:458,(anonymous_32) -FN:464,(anonymous_33) -FN:470,(anonymous_34) -FN:480,clearElement -FN:489,createReport -FN:490,onEvent -FNF:37 -FNH:6 -FNDA:1,(anonymous_1) -FNDA:0,(anonymous_2) -FNDA:0,(anonymous_3) -FNDA:0,noConflict -FNDA:1,(anonymous_5) -FNDA:1,(anonymous_6) -FNDA:0,stringify -FNDA:0,toPaddedString -FNDA:0,quote -FNDA:0,serialize -FNDA:0,(anonymous_11) -FNDA:0,all -FNDA:0,(anonymous_13) -FNDA:0,toQueryPair -FNDA:0,serializeQuery -FNDA:0,(anonymous_16) -FNDA:0,(anonymous_17) -FNDA:0,parseQuery -FNDA:0,isEmpty -FNDA:0,(anonymous_20) -FNDA:298,substitute -FNDA:1,createConsole -FNDA:298,onEvent -FNDA:0,createTAP -FNDA:0,description -FNDA:0,onEvent -FNDA:0,onClick -FNDA:0,(anonymous_28) -FNDA:0,(anonymous_29) -FNDA:0,serializeAttribute -FNDA:0,buildNode -FNDA:0,(anonymous_32) -FNDA:0,(anonymous_33) -FNDA:0,(anonymous_34) -FNDA:0,clearElement -FNDA:0,createReport -FNDA:0,onEvent -DA:8,1 -DA:10,1 -DA:24,1 -DA:26,0 -DA:27,0 -DA:29,1 -DA:31,1 -DA:33,1 -DA:35,1 -DA:38,0 -DA:39,0 -DA:41,0 -DA:43,1 -DA:44,0 -DA:45,0 -DA:46,0 -DA:48,0 -DA:56,1 -DA:62,1 -DA:63,0 -DA:68,1 -DA:69,0 -DA:73,1 -DA:85,1 -DA:86,0 -DA:87,0 -DA:90,0 -DA:95,0 -DA:99,1 -DA:100,0 -DA:101,0 -DA:102,0 -DA:104,0 -DA:105,0 -DA:110,0 -DA:113,0 -DA:115,0 -DA:116,0 -DA:121,0 -DA:123,0 -DA:131,0 -DA:134,0 -DA:138,0 -DA:139,0 -DA:140,0 -DA:144,0 -DA:145,0 -DA:146,0 -DA:148,0 -DA:149,0 -DA:150,0 -DA:153,0 -DA:155,0 -DA:157,0 -DA:159,0 -DA:162,0 -DA:164,0 -DA:167,1 -DA:173,0 -DA:174,0 -DA:175,0 -DA:177,0 -DA:182,0 -DA:183,0 -DA:184,0 -DA:186,0 -DA:190,0 -DA:201,0 -DA:202,0 -DA:203,0 -DA:204,0 -DA:205,0 -DA:206,0 -DA:207,0 -DA:210,0 -DA:211,0 -DA:214,0 -DA:224,0 -DA:226,0 -DA:227,0 -DA:229,0 -DA:230,0 -DA:231,0 -DA:232,0 -DA:233,0 -DA:234,0 -DA:235,0 -DA:236,0 -DA:237,0 -DA:240,0 -DA:242,0 -DA:243,0 -DA:244,0 -DA:246,0 -DA:248,0 -DA:252,0 -DA:257,0 -DA:258,0 -DA:259,0 -DA:261,0 -DA:265,0 -DA:266,0 -DA:270,0 -DA:273,0 -DA:275,0 -DA:276,0 -DA:284,298 -DA:285,298 -DA:286,298 -DA:287,0 -DA:289,298 -DA:290,4294 -DA:291,4294 -DA:292,322 -DA:293,322 -DA:295,0 -DA:297,322 -DA:299,322 -DA:303,24 -DA:304,24 -DA:307,0 -DA:308,0 -DA:311,0 -DA:312,0 -DA:315,298 -DA:319,0 -DA:322,322 -DA:324,322 -DA:326,3972 -DA:329,298 -DA:334,1 -DA:335,298 -DA:337,1 -DA:338,1 -DA:340,11 -DA:341,11 -DA:343,274 -DA:344,274 -DA:346,0 -DA:347,0 -DA:349,11 -DA:350,11 -DA:352,1 -DA:355,1 -DA:360,0 -DA:362,1 -DA:363,0 -DA:365,1 -DA:366,0 -DA:368,0 -DA:369,0 -DA:371,0 -DA:372,0 -DA:373,0 -DA:374,0 -DA:376,0 -DA:377,0 -DA:378,0 -DA:379,0 -DA:380,0 -DA:383,0 -DA:389,1 -DA:391,0 -DA:393,0 -DA:394,0 -DA:395,0 -DA:401,0 -DA:405,0 -DA:406,0 -DA:407,0 -DA:408,0 -DA:409,0 -DA:411,0 -DA:412,0 -DA:428,0 -DA:429,0 -DA:434,0 -DA:435,0 -DA:436,0 -DA:437,0 -DA:439,0 -DA:442,0 -DA:443,0 -DA:444,0 -DA:445,0 -DA:446,0 -DA:448,0 -DA:449,0 -DA:450,0 -DA:452,0 -DA:454,0 -DA:456,0 -DA:457,0 -DA:458,0 -DA:460,0 -DA:462,0 -DA:464,0 -DA:465,0 -DA:469,0 -DA:470,0 -DA:471,0 -DA:474,0 -DA:476,0 -DA:480,0 -DA:481,0 -DA:482,0 -DA:484,0 -DA:489,0 -DA:490,1 -DA:491,0 -DA:492,0 -DA:493,0 -DA:495,0 -DA:496,0 -DA:498,0 -DA:502,0 -DA:504,0 -DA:513,0 -DA:517,0 -DA:520,0 -DA:523,0 -DA:524,0 -DA:528,0 -DA:530,0 -DA:532,0 -DA:533,0 -DA:537,0 -DA:539,0 -DA:540,0 -DA:543,0 -DA:566,0 -DA:569,0 -DA:574,1 -DA:576,1 -LF:234 -LH:50 -BRDA:10,1,0,1 -BRDA:10,1,1,0 -BRDA:11,2,0,1 -BRDA:11,2,1,1 -BRDA:11,2,2,1 -BRDA:11,2,3,1 -BRDA:14,3,0,1 -BRDA:14,3,1,0 -BRDA:14,3,2,0 -BRDA:15,4,0,1 -BRDA:15,4,1,1 -BRDA:15,4,2,0 -BRDA:24,5,0,0 -BRDA:24,5,1,1 -BRDA:29,6,0,1 -BRDA:29,6,1,0 -BRDA:35,7,0,1 -BRDA:35,7,1,0 -BRDA:38,8,0,0 -BRDA:38,8,1,0 -BRDA:50,9,0,0 -BRDA:50,9,1,0 -BRDA:90,10,0,0 -BRDA:90,10,1,0 -BRDA:93,11,0,0 -BRDA:93,11,1,0 -BRDA:101,12,0,0 -BRDA:101,12,1,0 -BRDA:105,13,0,0 -BRDA:105,13,1,0 -BRDA:105,13,2,0 -BRDA:105,13,3,0 -BRDA:105,13,4,0 -BRDA:110,14,0,0 -BRDA:110,14,1,0 -BRDA:115,15,0,0 -BRDA:115,15,1,0 -BRDA:123,16,0,0 -BRDA:123,16,1,0 -BRDA:123,17,0,0 -BRDA:123,17,1,0 -BRDA:123,18,0,0 -BRDA:123,18,1,0 -BRDA:134,19,0,0 -BRDA:134,19,1,0 -BRDA:139,20,0,0 -BRDA:139,20,1,0 -BRDA:146,21,0,0 -BRDA:146,21,1,0 -BRDA:149,22,0,0 -BRDA:149,22,1,0 -BRDA:183,23,0,0 -BRDA:183,23,1,0 -BRDA:186,24,0,0 -BRDA:186,24,1,0 -BRDA:186,24,2,0 -BRDA:203,25,0,0 -BRDA:203,25,1,0 -BRDA:203,26,0,0 -BRDA:203,26,1,0 -BRDA:206,27,0,0 -BRDA:206,27,1,0 -BRDA:210,28,0,0 -BRDA:210,28,1,0 -BRDA:214,29,0,0 -BRDA:214,29,1,0 -BRDA:226,30,0,0 -BRDA:226,30,1,0 -BRDA:226,31,0,0 -BRDA:226,31,1,0 -BRDA:226,31,2,0 -BRDA:226,32,0,0 -BRDA:226,32,1,0 -BRDA:226,33,0,0 -BRDA:226,33,1,0 -BRDA:229,34,0,0 -BRDA:229,34,1,0 -BRDA:233,35,0,0 -BRDA:233,35,1,0 -BRDA:233,36,0,0 -BRDA:233,36,1,0 -BRDA:234,37,0,0 -BRDA:234,37,1,0 -BRDA:236,38,0,0 -BRDA:236,38,1,0 -BRDA:242,39,0,0 -BRDA:242,39,1,0 -BRDA:243,40,0,0 -BRDA:243,40,1,0 -BRDA:258,41,0,0 -BRDA:258,41,1,0 -BRDA:261,42,0,0 -BRDA:261,42,1,0 -BRDA:261,42,2,0 -BRDA:261,42,3,0 -BRDA:261,42,4,0 -BRDA:261,42,5,0 -BRDA:261,42,6,0 -BRDA:261,42,7,0 -BRDA:266,43,0,0 -BRDA:266,43,1,0 -BRDA:286,44,0,0 -BRDA:286,44,1,298 -BRDA:286,45,0,298 -BRDA:286,45,1,298 -BRDA:291,46,0,322 -BRDA:291,46,1,3972 -BRDA:293,47,0,0 -BRDA:293,47,1,322 -BRDA:297,48,0,322 -BRDA:297,48,1,0 -BRDA:299,49,0,0 -BRDA:299,49,1,24 -BRDA:299,49,2,0 -BRDA:299,49,3,0 -BRDA:299,49,4,298 -BRDA:303,50,0,24 -BRDA:303,50,1,12 -BRDA:307,51,0,0 -BRDA:307,51,1,0 -BRDA:335,52,0,1 -BRDA:335,52,1,11 -BRDA:335,52,2,274 -BRDA:335,52,3,0 -BRDA:335,52,4,11 -BRDA:335,52,5,1 -BRDA:366,53,0,0 -BRDA:366,53,1,0 -BRDA:366,53,2,0 -BRDA:389,54,0,0 -BRDA:389,54,1,1 -BRDA:393,55,0,0 -BRDA:393,55,1,0 -BRDA:394,56,0,0 -BRDA:394,56,1,0 -BRDA:395,57,0,0 -BRDA:395,57,1,0 -BRDA:409,58,0,0 -BRDA:409,58,1,0 -BRDA:418,59,0,0 -BRDA:418,59,1,0 -BRDA:435,60,0,0 -BRDA:435,60,1,0 -BRDA:435,61,0,0 -BRDA:435,61,1,0 -BRDA:442,62,0,0 -BRDA:442,62,1,0 -BRDA:442,63,0,0 -BRDA:442,63,1,0 -BRDA:444,64,0,0 -BRDA:444,64,1,0 -BRDA:448,65,0,0 -BRDA:448,65,1,0 -BRDA:456,66,0,0 -BRDA:456,66,1,0 -BRDA:457,67,0,0 -BRDA:457,67,1,0 -BRDA:460,68,0,0 -BRDA:460,68,1,0 -BRDA:469,69,0,0 -BRDA:469,69,1,0 -BRDA:492,70,0,0 -BRDA:492,70,1,0 -BRDA:495,71,0,0 -BRDA:495,71,1,0 -BRDA:498,72,0,0 -BRDA:498,72,1,0 -BRDA:498,72,2,0 -BRDA:498,72,3,0 -BRDA:498,72,4,0 -BRDA:498,72,5,0 -BRDA:523,73,0,0 -BRDA:523,73,1,0 -BRDA:528,74,0,0 -BRDA:528,74,1,0 -BRDA:537,75,0,0 -BRDA:537,75,1,0 -BRDA:543,76,0,0 -BRDA:543,76,1,0 -BRF:179 -BRH:28 -end_of_record -TN: -SF:/Users/kit/Dropbox/Projects/json3/lib/json3.js -FN:2,(anonymous_1) -FN:42,has -FN:64,(anonymous_3) -FN:196,(anonymous_4) -FN:204,(anonymous_5) -FN:213,(anonymous_6) -FN:227,(anonymous_7) -FN:247,(anonymous_8) -FN:254,(anonymous_9) -FN:260,(anonymous_10) -FN:280,(anonymous_11) -FN:295,(anonymous_12) -FN:309,(anonymous_13) -FN:347,(anonymous_14) -FN:358,(anonymous_15) -FN:384,(anonymous_16) -FN:491,(anonymous_17) -FN:513,(anonymous_18) -FN:563,(anonymous_19) -FN:571,(anonymous_20) -FN:729,(anonymous_21) -FN:812,(anonymous_22) -FN:824,(anonymous_23) -FN:835,(anonymous_24) -FN:844,(anonymous_25) -FN:862,(anonymous_26) -FNF:26 -FNH:3 -FNDA:1,(anonymous_1) -FNDA:3,has -FNDA:4,(anonymous_3) -FNDA:0,(anonymous_4) -FNDA:0,(anonymous_5) -FNDA:0,(anonymous_6) -FNDA:0,(anonymous_7) -FNDA:0,(anonymous_8) -FNDA:0,(anonymous_9) -FNDA:0,(anonymous_10) -FNDA:0,(anonymous_11) -FNDA:0,(anonymous_12) -FNDA:0,(anonymous_13) -FNDA:0,(anonymous_14) -FNDA:0,(anonymous_15) -FNDA:0,(anonymous_16) -FNDA:0,(anonymous_17) -FNDA:0,(anonymous_18) -FNDA:0,(anonymous_19) -FNDA:0,(anonymous_20) -FNDA:0,(anonymous_21) -FNDA:0,(anonymous_22) -FNDA:0,(anonymous_23) -FNDA:0,(anonymous_24) -FNDA:0,(anonymous_25) -FNDA:0,(anonymous_26) -DA:2,1 -DA:4,1 -DA:8,1 -DA:11,1 -DA:15,1 -DA:17,1 -DA:20,1 -DA:21,1 -DA:25,0 -DA:29,1 -DA:30,1 -DA:33,1 -DA:42,1 -DA:43,3 -DA:45,0 -DA:48,3 -DA:49,3 -DA:52,0 -DA:53,3 -DA:56,1 -DA:58,2 -DA:60,2 -DA:61,1 -DA:62,1 -DA:64,1 -DA:65,4 -DA:67,1 -DA:68,1 -DA:122,0 -DA:125,1 -DA:128,2 -DA:129,1 -DA:130,1 -DA:131,1 -DA:135,1 -DA:137,1 -DA:138,1 -DA:139,1 -DA:140,1 -DA:142,1 -DA:144,1 -DA:145,1 -DA:149,1 -DA:152,1 -DA:153,1 -DA:157,1 -DA:163,0 -DA:166,1 -DA:169,3 -DA:171,1 -DA:172,1 -DA:173,1 -DA:174,1 -DA:176,1 -DA:178,0 -DA:179,0 -DA:180,0 -DA:181,0 -DA:182,0 -DA:183,0 -DA:186,0 -DA:189,0 -DA:190,0 -DA:193,0 -DA:196,0 -DA:197,0 -DA:203,0 -DA:204,0 -DA:205,0 -DA:206,0 -DA:213,0 -DA:217,0 -DA:219,0 -DA:220,0 -DA:224,0 -DA:227,0 -DA:228,0 -DA:229,0 -DA:232,0 -DA:233,0 -DA:238,0 -DA:247,0 -DA:248,0 -DA:249,0 -DA:254,0 -DA:255,0 -DA:260,0 -DA:261,0 -DA:265,0 -DA:266,0 -DA:268,0 -DA:269,0 -DA:272,0 -DA:275,0 -DA:277,0 -DA:280,0 -DA:281,0 -DA:282,0 -DA:283,0 -DA:286,0 -DA:287,0 -DA:291,0 -DA:293,0 -DA:295,0 -DA:297,0 -DA:298,0 -DA:302,0 -DA:303,0 -DA:309,0 -DA:310,0 -DA:311,0 -DA:312,0 -DA:313,0 -DA:318,0 -DA:319,0 -DA:323,0 -DA:332,0 -DA:334,0 -DA:346,0 -DA:347,0 -DA:350,0 -DA:357,0 -DA:358,0 -DA:359,0 -DA:360,0 -DA:361,0 -DA:363,0 -DA:364,0 -DA:367,0 -DA:369,0 -DA:370,0 -DA:372,0 -DA:373,0 -DA:374,0 -DA:376,0 -DA:379,0 -DA:384,0 -DA:385,0 -DA:386,0 -DA:388,0 -DA:390,0 -DA:391,0 -DA:392,0 -DA:393,0 -DA:397,0 -DA:401,0 -DA:402,0 -DA:403,0 -DA:404,0 -DA:409,0 -DA:412,0 -DA:413,0 -DA:414,0 -DA:415,0 -DA:417,0 -DA:418,0 -DA:419,0 -DA:420,0 -DA:421,0 -DA:422,0 -DA:423,0 -DA:426,0 -DA:434,0 -DA:436,0 -DA:441,0 -DA:444,0 -DA:447,0 -DA:449,0 -DA:450,0 -DA:452,0 -DA:453,0 -DA:455,0 -DA:456,0 -DA:459,0 -DA:460,0 -DA:462,0 -DA:465,0 -DA:468,0 -DA:469,0 -DA:471,0 -DA:475,0 -DA:476,0 -DA:478,0 -DA:479,0 -DA:480,0 -DA:482,0 -DA:483,0 -DA:484,0 -DA:486,0 -DA:491,0 -DA:492,0 -DA:493,0 -DA:500,0 -DA:502,0 -DA:504,0 -DA:507,0 -DA:508,0 -DA:513,0 -DA:514,0 -DA:515,0 -DA:516,0 -DA:517,0 -DA:518,0 -DA:520,0 -DA:521,0 -DA:524,0 -DA:525,0 -DA:528,0 -DA:529,0 -DA:531,0 -DA:532,0 -DA:538,0 -DA:543,0 -DA:544,0 -DA:548,0 -DA:560,0 -DA:563,0 -DA:564,0 -DA:565,0 -DA:571,0 -DA:572,0 -DA:573,0 -DA:574,0 -DA:575,0 -DA:579,0 -DA:580,0 -DA:584,0 -DA:585,0 -DA:586,0 -DA:592,0 -DA:593,0 -DA:594,0 -DA:597,0 -DA:598,0 -DA:602,0 -DA:603,0 -DA:606,0 -DA:607,0 -DA:608,0 -DA:613,0 -DA:614,0 -DA:615,0 -DA:618,0 -DA:620,0 -DA:624,0 -DA:625,0 -DA:628,0 -DA:631,0 -DA:634,0 -DA:636,0 -DA:637,0 -DA:639,0 -DA:640,0 -DA:643,0 -DA:646,0 -DA:648,0 -DA:649,0 -DA:652,0 -DA:655,0 -DA:657,0 -DA:658,0 -DA:659,0 -DA:662,0 -DA:664,0 -DA:666,0 -DA:668,0 -DA:670,0 -DA:673,0 -DA:674,0 -DA:676,0 -DA:677,0 -DA:679,0 -DA:681,0 -DA:685,0 -DA:686,0 -DA:687,0 -DA:690,0 -DA:691,0 -DA:694,0 -DA:695,0 -DA:697,0 -DA:699,0 -DA:702,0 -DA:705,0 -DA:706,0 -DA:709,0 -DA:710,0 -DA:711,0 -DA:712,0 -DA:713,0 -DA:714,0 -DA:715,0 -DA:716,0 -DA:717,0 -DA:720,0 -DA:725,0 -DA:729,0 -DA:730,0 -DA:731,0 -DA:733,0 -DA:735,0 -DA:736,0 -DA:738,0 -DA:741,0 -DA:743,0 -DA:744,0 -DA:745,0 -DA:747,0 -DA:748,0 -DA:753,0 -DA:754,0 -DA:755,0 -DA:756,0 -DA:758,0 -DA:762,0 -DA:766,0 -DA:767,0 -DA:769,0 -DA:771,0 -DA:772,0 -DA:774,0 -DA:775,0 -DA:776,0 -DA:778,0 -DA:779,0 -DA:783,0 -DA:784,0 -DA:785,0 -DA:786,0 -DA:788,0 -DA:792,0 -DA:798,0 -DA:799,0 -DA:801,0 -DA:803,0 -DA:806,0 -DA:808,0 -DA:812,0 -DA:813,0 -DA:814,0 -DA:815,0 -DA:817,0 -DA:824,0 -DA:825,0 -DA:826,0 -DA:830,0 -DA:831,0 -DA:832,0 -DA:835,0 -DA:836,0 -DA:840,0 -DA:844,0 -DA:845,0 -DA:846,0 -DA:847,0 -DA:848,0 -DA:850,0 -DA:851,0 -DA:854,0 -DA:855,0 -DA:861,1 -DA:862,0 -DA:863,0 -LF:363 -LH:50 -BRDA:8,1,0,1 -BRDA:8,1,1,0 -BRDA:11,2,0,1 -BRDA:11,2,1,1 -BRDA:15,3,0,1 -BRDA:15,3,1,1 -BRDA:15,3,2,1 -BRDA:15,3,3,1 -BRDA:17,4,0,1 -BRDA:17,4,1,0 -BRDA:17,5,0,1 -BRDA:17,5,1,1 -BRDA:25,6,0,0 -BRDA:25,6,1,0 -BRDA:33,7,0,1 -BRDA:33,7,1,1 -BRDA:33,7,2,1 -BRDA:33,7,3,1 -BRDA:33,7,4,1 -BRDA:33,7,5,1 -BRDA:33,7,6,1 -BRDA:43,8,0,0 -BRDA:43,8,1,3 -BRDA:49,9,0,0 -BRDA:49,9,1,3 -BRDA:53,10,0,1 -BRDA:53,10,1,2 -BRDA:56,11,0,1 -BRDA:56,11,1,1 -BRDA:60,12,0,1 -BRDA:60,12,1,1 -BRDA:61,13,0,1 -BRDA:61,13,1,1 -BRDA:62,14,0,1 -BRDA:62,14,1,0 -BRDA:71,15,0,1 -BRDA:71,15,1,1 -BRDA:71,15,2,1 -BRDA:71,15,3,1 -BRDA:71,15,4,1 -BRDA:71,15,5,1 -BRDA:71,15,6,1 -BRDA:71,15,7,1 -BRDA:71,15,8,1 -BRDA:71,15,9,1 -BRDA:71,15,10,1 -BRDA:71,15,11,1 -BRDA:71,15,12,1 -BRDA:71,15,13,1 -BRDA:71,15,14,1 -BRDA:71,15,15,1 -BRDA:71,15,16,1 -BRDA:71,15,17,1 -BRDA:128,16,0,1 -BRDA:128,16,1,1 -BRDA:130,17,0,1 -BRDA:130,17,1,0 -BRDA:135,18,0,1 -BRDA:135,18,1,0 -BRDA:135,19,0,1 -BRDA:135,19,1,1 -BRDA:138,20,0,1 -BRDA:138,20,1,1 -BRDA:139,21,0,1 -BRDA:139,21,1,0 -BRDA:144,22,0,1 -BRDA:144,22,1,0 -BRDA:152,23,0,1 -BRDA:152,23,1,0 -BRDA:176,24,0,0 -BRDA:176,24,1,1 -BRDA:189,25,0,0 -BRDA:189,25,1,0 -BRDA:203,26,0,0 -BRDA:203,26,1,0 -BRDA:206,27,0,0 -BRDA:206,27,1,0 -BRDA:228,28,0,0 -BRDA:228,28,1,0 -BRDA:229,29,0,0 -BRDA:229,29,1,0 -BRDA:229,30,0,0 -BRDA:229,30,1,0 -BRDA:249,31,0,0 -BRDA:249,31,1,0 -BRDA:268,32,0,0 -BRDA:268,32,1,0 -BRDA:275,33,0,0 -BRDA:275,33,1,0 -BRDA:282,34,0,0 -BRDA:282,34,1,0 -BRDA:282,35,0,0 -BRDA:282,35,1,0 -BRDA:282,35,2,0 -BRDA:286,36,0,0 -BRDA:286,36,1,0 -BRDA:286,37,0,0 -BRDA:286,37,1,0 -BRDA:286,38,0,0 -BRDA:286,38,1,0 -BRDA:291,39,0,0 -BRDA:291,39,1,0 -BRDA:293,40,0,0 -BRDA:293,40,1,0 -BRDA:302,41,0,0 -BRDA:302,41,1,0 -BRDA:302,42,0,0 -BRDA:302,42,1,0 -BRDA:302,42,2,0 -BRDA:302,42,3,0 -BRDA:302,43,0,0 -BRDA:302,43,1,0 -BRDA:312,44,0,0 -BRDA:312,44,1,0 -BRDA:312,45,0,0 -BRDA:312,45,1,0 -BRDA:312,45,2,0 -BRDA:312,46,0,0 -BRDA:312,46,1,0 -BRDA:318,47,0,0 -BRDA:318,47,1,0 -BRDA:318,48,0,0 -BRDA:318,48,1,0 -BRDA:332,49,0,0 -BRDA:332,49,1,0 -BRDA:350,50,0,0 -BRDA:350,50,1,0 -BRDA:359,51,0,0 -BRDA:359,51,1,0 -BRDA:360,52,0,0 -BRDA:360,52,1,0 -BRDA:367,53,0,0 -BRDA:367,53,1,0 -BRDA:367,53,2,0 -BRDA:367,53,3,0 -BRDA:367,53,4,0 -BRDA:367,53,5,0 -BRDA:367,53,6,0 -BRDA:367,53,7,0 -BRDA:372,54,0,0 -BRDA:372,54,1,0 -BRDA:376,55,0,0 -BRDA:376,55,1,0 -BRDA:376,56,0,0 -BRDA:376,56,1,0 -BRDA:390,57,0,0 -BRDA:390,57,1,0 -BRDA:390,58,0,0 -BRDA:390,58,1,0 -BRDA:392,59,0,0 -BRDA:392,59,1,0 -BRDA:392,60,0,0 -BRDA:392,60,1,0 -BRDA:393,61,0,0 -BRDA:393,61,1,0 -BRDA:393,62,0,0 -BRDA:393,62,1,0 -BRDA:397,63,0,0 -BRDA:397,63,1,0 -BRDA:426,64,0,0 -BRDA:426,64,1,0 -BRDA:426,65,0,0 -BRDA:426,65,1,0 -BRDA:426,66,0,0 -BRDA:426,66,1,0 -BRDA:426,67,0,0 -BRDA:426,67,1,0 -BRDA:436,68,0,0 -BRDA:436,68,1,0 -BRDA:436,69,0,0 -BRDA:436,69,1,0 -BRDA:436,69,2,0 -BRDA:436,69,3,0 -BRDA:436,69,4,0 -BRDA:444,70,0,0 -BRDA:444,70,1,0 -BRDA:449,71,0,0 -BRDA:449,71,1,0 -BRDA:453,72,0,0 -BRDA:453,72,1,0 -BRDA:456,73,0,0 -BRDA:456,73,1,0 -BRDA:459,74,0,0 -BRDA:459,74,1,0 -BRDA:459,75,0,0 -BRDA:459,75,1,0 -BRDA:460,76,0,0 -BRDA:460,76,1,0 -BRDA:465,77,0,0 -BRDA:465,77,1,0 -BRDA:469,78,0,0 -BRDA:469,78,1,0 -BRDA:480,79,0,0 -BRDA:480,79,1,0 -BRDA:482,80,0,0 -BRDA:482,80,1,0 -BRDA:484,81,0,0 -BRDA:484,81,1,0 -BRDA:486,82,0,0 -BRDA:486,82,1,0 -BRDA:486,83,0,0 -BRDA:486,83,1,0 -BRDA:491,84,0,0 -BRDA:491,84,1,0 -BRDA:493,85,0,0 -BRDA:493,85,1,0 -BRDA:500,86,0,0 -BRDA:500,86,1,0 -BRDA:502,87,0,0 -BRDA:502,87,1,0 -BRDA:504,88,0,0 -BRDA:504,88,1,0 -BRDA:504,89,0,0 -BRDA:504,89,1,0 -BRDA:515,90,0,0 -BRDA:515,90,1,0 -BRDA:515,91,0,0 -BRDA:515,91,1,0 -BRDA:515,91,2,0 -BRDA:516,92,0,0 -BRDA:516,92,1,0 -BRDA:518,93,0,0 -BRDA:518,93,1,0 -BRDA:521,94,0,0 -BRDA:521,94,1,0 -BRDA:521,94,2,0 -BRDA:524,95,0,0 -BRDA:524,95,1,0 -BRDA:525,96,0,0 -BRDA:525,96,1,0 -BRDA:528,97,0,0 -BRDA:528,97,1,0 -BRDA:531,98,0,0 -BRDA:531,98,1,0 -BRDA:532,99,0,0 -BRDA:532,99,1,0 -BRDA:543,100,0,0 -BRDA:543,100,1,0 -BRDA:575,101,0,0 -BRDA:575,101,1,0 -BRDA:575,101,2,0 -BRDA:575,101,3,0 -BRDA:575,101,4,0 -BRDA:575,101,5,0 -BRDA:575,101,6,0 -BRDA:575,101,7,0 -BRDA:575,101,8,0 -BRDA:575,101,9,0 -BRDA:575,101,10,0 -BRDA:575,101,11,0 -BRDA:584,102,0,0 -BRDA:584,102,1,0 -BRDA:594,103,0,0 -BRDA:594,103,1,0 -BRDA:598,104,0,0 -BRDA:598,104,1,0 -BRDA:603,105,0,0 -BRDA:603,105,1,0 -BRDA:603,105,2,0 -BRDA:603,105,3,0 -BRDA:603,105,4,0 -BRDA:603,105,5,0 -BRDA:603,105,6,0 -BRDA:603,105,7,0 -BRDA:603,105,8,0 -BRDA:603,105,9,0 -BRDA:618,106,0,0 -BRDA:618,106,1,0 -BRDA:618,107,0,0 -BRDA:618,107,1,0 -BRDA:618,107,2,0 -BRDA:618,107,3,0 -BRDA:618,107,4,0 -BRDA:618,107,5,0 -BRDA:631,108,0,0 -BRDA:631,108,1,0 -BRDA:639,109,0,0 -BRDA:639,109,1,0 -BRDA:639,109,2,0 -BRDA:646,110,0,0 -BRDA:646,110,1,0 -BRDA:657,111,0,0 -BRDA:657,111,1,0 -BRDA:662,112,0,0 -BRDA:662,112,1,0 -BRDA:662,113,0,0 -BRDA:662,113,1,0 -BRDA:664,114,0,0 -BRDA:664,114,1,0 -BRDA:664,115,0,0 -BRDA:664,115,1,0 -BRDA:664,116,0,0 -BRDA:664,116,1,0 -BRDA:670,117,0,0 -BRDA:670,117,1,0 -BRDA:670,118,0,0 -BRDA:670,118,1,0 -BRDA:673,119,0,0 -BRDA:673,119,1,0 -BRDA:676,120,0,0 -BRDA:676,120,1,0 -BRDA:676,121,0,0 -BRDA:676,121,1,0 -BRDA:677,122,0,0 -BRDA:677,122,1,0 -BRDA:686,123,0,0 -BRDA:686,123,1,0 -BRDA:686,124,0,0 -BRDA:686,124,1,0 -BRDA:690,125,0,0 -BRDA:690,125,1,0 -BRDA:690,126,0,0 -BRDA:690,126,1,0 -BRDA:694,127,0,0 -BRDA:694,127,1,0 -BRDA:694,128,0,0 -BRDA:694,128,1,0 -BRDA:695,129,0,0 -BRDA:695,129,1,0 -BRDA:705,130,0,0 -BRDA:705,130,1,0 -BRDA:709,131,0,0 -BRDA:709,131,1,0 -BRDA:712,132,0,0 -BRDA:712,132,1,0 -BRDA:715,133,0,0 -BRDA:715,133,1,0 -BRDA:731,134,0,0 -BRDA:731,134,1,0 -BRDA:735,135,0,0 -BRDA:735,135,1,0 -BRDA:736,136,0,0 -BRDA:736,136,1,0 -BRDA:736,137,0,0 -BRDA:736,137,1,0 -BRDA:741,138,0,0 -BRDA:741,138,1,0 -BRDA:744,139,0,0 -BRDA:744,139,1,0 -BRDA:747,140,0,0 -BRDA:747,140,1,0 -BRDA:753,141,0,0 -BRDA:753,141,1,0 -BRDA:754,142,0,0 -BRDA:754,142,1,0 -BRDA:756,143,0,0 -BRDA:756,143,1,0 -BRDA:766,144,0,0 -BRDA:766,144,1,0 -BRDA:772,145,0,0 -BRDA:772,145,1,0 -BRDA:775,146,0,0 -BRDA:775,146,1,0 -BRDA:778,147,0,0 -BRDA:778,147,1,0 -BRDA:783,148,0,0 -BRDA:783,148,1,0 -BRDA:784,149,0,0 -BRDA:784,149,1,0 -BRDA:786,150,0,0 -BRDA:786,150,1,0 -BRDA:798,151,0,0 -BRDA:798,151,1,0 -BRDA:798,152,0,0 -BRDA:798,152,1,0 -BRDA:798,152,2,0 -BRDA:798,152,3,0 -BRDA:798,153,0,0 -BRDA:798,153,1,0 -BRDA:814,154,0,0 -BRDA:814,154,1,0 -BRDA:826,155,0,0 -BRDA:826,155,1,0 -BRDA:826,156,0,0 -BRDA:826,156,1,0 -BRDA:830,157,0,0 -BRDA:830,157,1,0 -BRDA:850,158,0,0 -BRDA:850,158,1,0 -BRDA:855,159,0,0 -BRDA:855,159,1,0 -BRDA:855,160,0,0 -BRDA:855,160,1,0 -BRDA:861,161,0,0 -BRDA:861,161,1,1 -BRF:385 -BRH:59 -end_of_record +TN: +SF:/Users/kit/Dropbox/Projects/json3/vendor/spec/lib/spec.js +FN:11,(anonymous_1) +FN:20,(anonymous_2) +FN:21,noConflict +FN:31,(anonymous_4) +FN:70,(anonymous_5) +FN:78,hasKey +FN:86,hasKey +FN:102,hasKey +FN:117,(anonymous_9) +FN:123,Properties +FN:145,forOwn +FN:169,forOwn +FN:188,forOwn +FN:210,(anonymous_14) +FN:213,eq +FN:289,(anonymous_16) +FN:297,(anonymous_17) +FN:311,equals +FN:328,forEach +FN:343,(anonymous_20) +FN:347,defer +FN:354,run +FN:361,defer +FN:362,run +FN:370,defer +FN:372,run +FN:387,(anonymous_27) +FN:395,defer +FN:404,rethrow +FN:405,(anonymous_30) +FN:418,Events +FN:429,addListener +FN:431,(anonymous_33) +FN:454,removeListener +FN:459,(anonymous_35) +FN:483,emit +FN:531,Suite +FN:547,(anonymous_38) +FN:555,shuffle +FN:567,addTest +FN:575,index +FN:594,onSuiteEvent +FN:622,runSuite +FN:645,Test +FN:668,onTestEvent +FN:697,assert +FN:698,assertion +FN:710,runTest +FN:720,ok +FN:735,notOk +FN:742,assertEqual +FN:748,assertNotEqual +FN:754,assertStrictEqual +FN:760,assertStrictNotEqual +FN:770,assertNotDeepEqual +FN:776,assertError +FN:793,assertNoError +FN:806,done +FNF:58 +FNH:38 +FNDA:1,(anonymous_1) +FNDA:0,(anonymous_2) +FNDA:0,noConflict +FNDA:1,(anonymous_4) +FNDA:1,(anonymous_5) +FNDA:5538,hasKey +FNDA:0,hasKey +FNDA:0,hasKey +FNDA:1,(anonymous_9) +FNDA:1,Properties +FNDA:0,forOwn +FNDA:0,forOwn +FNDA:26,forOwn +FNDA:1,(anonymous_14) +FNDA:102,eq +FNDA:15,(anonymous_16) +FNDA:15,(anonymous_17) +FNDA:51,equals +FNDA:49,forEach +FNDA:1,(anonymous_20) +FNDA:0,defer +FNDA:0,run +FNDA:0,defer +FNDA:0,run +FNDA:0,defer +FNDA:0,run +FNDA:0,(anonymous_27) +FNDA:11,defer +FNDA:0,rethrow +FNDA:0,(anonymous_30) +FNDA:14,Events +FNDA:34,addListener +FNDA:34,(anonymous_33) +FNDA:11,removeListener +FNDA:11,(anonymous_35) +FNDA:594,emit +FNDA:1,Suite +FNDA:1,(anonymous_38) +FNDA:1,shuffle +FNDA:11,addTest +FNDA:12,index +FNDA:296,onSuiteEvent +FNDA:1,runSuite +FNDA:11,Test +FNDA:296,onTestEvent +FNDA:6,assert +FNDA:117,assertion +FNDA:11,runTest +FNDA:274,ok +FNDA:0,notOk +FNDA:15,assertEqual +FNDA:0,assertNotEqual +FNDA:51,assertStrictEqual +FNDA:0,assertStrictNotEqual +FNDA:0,assertNotDeepEqual +FNDA:156,assertError +FNDA:0,assertNoError +FNDA:11,done +DA:11,1 +DA:12,1 +DA:14,0 +DA:17,1 +DA:21,1 +DA:22,0 +DA:24,0 +DA:25,0 +DA:27,0 +DA:35,1 +DA:41,1 +DA:71,1 +DA:73,1 +DA:74,1 +DA:76,1 +DA:78,1 +DA:79,5538 +DA:80,0 +DA:82,5538 +DA:84,0 +DA:86,0 +DA:87,0 +DA:88,0 +DA:89,0 +DA:93,0 +DA:94,0 +DA:96,0 +DA:97,0 +DA:102,0 +DA:103,0 +DA:104,0 +DA:106,0 +DA:107,0 +DA:110,1 +DA:118,1 +DA:123,1 +DA:124,1 +DA:126,1 +DA:129,1 +DA:130,1 +DA:132,1 +DA:133,1 +DA:136,1 +DA:139,1 +DA:141,0 +DA:144,0 +DA:145,0 +DA:146,0 +DA:147,0 +DA:148,0 +DA:150,0 +DA:151,0 +DA:154,0 +DA:155,0 +DA:159,0 +DA:160,0 +DA:161,0 +DA:162,0 +DA:166,1 +DA:168,0 +DA:169,0 +DA:170,0 +DA:171,0 +DA:172,0 +DA:175,0 +DA:176,0 +DA:177,0 +DA:181,0 +DA:182,0 +DA:188,1 +DA:189,26 +DA:190,26 +DA:191,0 +DA:193,26 +DA:194,26 +DA:195,30 +DA:196,0 +DA:201,26 +DA:202,0 +DA:206,1 +DA:213,1 +DA:214,102 +DA:216,102 +DA:219,72 +DA:222,30 +DA:223,0 +DA:225,30 +DA:226,30 +DA:227,0 +DA:229,30 +DA:234,0 +DA:236,0 +DA:237,0 +DA:240,0 +DA:246,0 +DA:250,0 +DA:256,30 +DA:257,0 +DA:263,30 +DA:264,22 +DA:265,0 +DA:269,30 +DA:270,30 +DA:272,30 +DA:274,17 +DA:275,17 +DA:276,17 +DA:278,17 +DA:280,36 +DA:281,0 +DA:286,13 +DA:288,13 +DA:289,13 +DA:291,15 +DA:293,15 +DA:296,13 +DA:297,13 +DA:298,15 +DA:299,0 +DA:302,13 +DA:306,30 +DA:307,30 +DA:311,1 +DA:312,51 +DA:315,51 +DA:316,0 +DA:319,51 +DA:322,1 +DA:329,49 +DA:330,49 +DA:331,0 +DA:333,49 +DA:334,114 +DA:335,0 +DA:338,49 +DA:344,1 +DA:346,1 +DA:347,1 +DA:354,1 +DA:355,0 +DA:357,0 +DA:360,0 +DA:361,0 +DA:362,1 +DA:363,0 +DA:365,0 +DA:369,0 +DA:370,0 +DA:371,0 +DA:372,1 +DA:376,0 +DA:377,0 +DA:382,0 +DA:386,0 +DA:387,0 +DA:388,0 +DA:390,0 +DA:394,1 +DA:395,1 +DA:396,11 +DA:399,1 +DA:404,1 +DA:405,0 +DA:406,0 +DA:417,1 +DA:418,1 +DA:419,14 +DA:428,1 +DA:429,1 +DA:430,34 +DA:431,34 +DA:432,34 +DA:433,34 +DA:435,34 +DA:436,34 +DA:438,34 +DA:444,34 +DA:453,1 +DA:454,1 +DA:455,11 +DA:457,0 +DA:458,11 +DA:459,11 +DA:460,11 +DA:461,11 +DA:463,11 +DA:464,11 +DA:466,11 +DA:467,11 +DA:468,22 +DA:469,11 +DA:476,11 +DA:482,1 +DA:483,1 +DA:484,594 +DA:486,594 +DA:487,13 +DA:489,594 +DA:491,594 +DA:492,298 +DA:495,594 +DA:496,594 +DA:497,0 +DA:498,0 +DA:500,0 +DA:501,0 +DA:503,0 +DA:508,594 +DA:509,594 +DA:510,594 +DA:511,890 +DA:512,890 +DA:514,0 +DA:518,594 +DA:528,1 +DA:531,1 +DA:532,1 +DA:533,1 +DA:534,1 +DA:536,1 +DA:540,1 +DA:543,1 +DA:544,1 +DA:547,1 +DA:548,1 +DA:549,8 +DA:554,1 +DA:555,1 +DA:556,1 +DA:557,11 +DA:558,11 +DA:559,11 +DA:560,11 +DA:562,1 +DA:566,1 +DA:567,1 +DA:568,11 +DA:569,11 +DA:574,1 +DA:575,1 +DA:576,12 +DA:577,12 +DA:578,12 +DA:579,0 +DA:581,12 +DA:582,11 +DA:583,11 +DA:584,11 +DA:587,1 +DA:593,1 +DA:594,1 +DA:595,296 +DA:597,296 +DA:598,296 +DA:601,274 +DA:602,274 +DA:604,0 +DA:605,0 +DA:608,11 +DA:609,11 +DA:610,10 +DA:612,10 +DA:615,1 +DA:621,1 +DA:622,1 +DA:624,1 +DA:625,1 +DA:627,1 +DA:629,1 +DA:630,1 +DA:632,1 +DA:635,0 +DA:637,1 +DA:644,1 +DA:645,1 +DA:646,11 +DA:647,11 +DA:648,0 +DA:649,0 +DA:651,11 +DA:652,11 +DA:654,11 +DA:656,11 +DA:660,1 +DA:661,1 +DA:664,1 +DA:667,1 +DA:668,1 +DA:669,296 +DA:670,296 +DA:672,11 +DA:673,11 +DA:675,274 +DA:676,274 +DA:678,0 +DA:679,0 +DA:681,11 +DA:683,11 +DA:684,0 +DA:696,1 +DA:697,1 +DA:698,1 +DA:699,117 +DA:705,6 +DA:709,1 +DA:710,1 +DA:711,11 +DA:713,11 +DA:714,11 +DA:719,1 +DA:720,1 +DA:721,274 +DA:722,157 +DA:729,274 +DA:730,274 +DA:734,1 +DA:735,1 +DA:736,0 +DA:741,1 +DA:742,1 +DA:743,15 +DA:747,1 +DA:748,1 +DA:749,0 +DA:753,1 +DA:754,1 +DA:755,51 +DA:759,1 +DA:760,1 +DA:761,0 +DA:766,1 +DA:769,1 +DA:770,1 +DA:771,0 +DA:775,1 +DA:776,1 +DA:777,156 +DA:779,156 +DA:780,0 +DA:781,0 +DA:783,156 +DA:784,156 +DA:786,156 +DA:788,156 +DA:792,1 +DA:793,1 +DA:794,0 +DA:795,0 +DA:796,0 +DA:798,0 +DA:800,0 +DA:805,1 +DA:806,1 +DA:807,11 +DA:812,1 +LF:355 +LH:248 +BRDA:12,1,0,0 +BRDA:12,1,1,1 +BRDA:12,2,0,1 +BRDA:12,2,1,0 +BRDA:17,3,0,1 +BRDA:17,3,1,1 +BRDA:17,3,2,0 +BRDA:59,4,0,1 +BRDA:59,4,1,1 +BRDA:59,4,2,1 +BRDA:63,5,0,1 +BRDA:63,5,1,0 +BRDA:63,5,2,0 +BRDA:63,5,3,0 +BRDA:76,6,0,1 +BRDA:76,6,1,0 +BRDA:79,7,0,0 +BRDA:79,7,1,5538 +BRDA:84,8,0,0 +BRDA:84,8,1,0 +BRDA:88,9,0,0 +BRDA:88,9,1,0 +BRDA:103,10,0,0 +BRDA:103,10,1,0 +BRDA:106,11,0,0 +BRDA:106,11,1,0 +BRDA:107,12,0,0 +BRDA:107,12,1,0 +BRDA:107,13,0,0 +BRDA:107,13,1,0 +BRDA:132,14,0,1 +BRDA:132,14,1,0 +BRDA:139,15,0,0 +BRDA:139,15,1,1 +BRDA:147,16,0,0 +BRDA:147,16,1,0 +BRDA:154,17,0,0 +BRDA:154,17,1,0 +BRDA:154,18,0,0 +BRDA:154,18,1,0 +BRDA:154,18,2,0 +BRDA:154,19,0,0 +BRDA:154,19,1,0 +BRDA:161,20,0,0 +BRDA:161,20,1,0 +BRDA:161,21,0,0 +BRDA:161,21,1,0 +BRDA:166,22,0,0 +BRDA:166,22,1,1 +BRDA:171,23,0,0 +BRDA:171,23,1,0 +BRDA:181,24,0,0 +BRDA:181,24,1,0 +BRDA:181,25,0,0 +BRDA:181,25,1,0 +BRDA:181,25,2,0 +BRDA:181,25,3,0 +BRDA:181,25,4,0 +BRDA:181,26,0,0 +BRDA:181,26,1,0 +BRDA:190,27,0,0 +BRDA:190,27,1,26 +BRDA:195,28,0,0 +BRDA:195,28,1,30 +BRDA:195,29,0,30 +BRDA:195,29,1,30 +BRDA:195,29,2,30 +BRDA:195,29,3,30 +BRDA:195,30,0,30 +BRDA:195,30,1,0 +BRDA:201,31,0,0 +BRDA:201,31,1,26 +BRDA:201,32,0,26 +BRDA:201,32,1,26 +BRDA:216,33,0,72 +BRDA:216,33,1,30 +BRDA:219,34,0,72 +BRDA:219,34,1,15 +BRDA:222,35,0,0 +BRDA:222,35,1,30 +BRDA:226,36,0,0 +BRDA:226,36,1,30 +BRDA:229,37,0,0 +BRDA:229,37,1,0 +BRDA:229,37,2,0 +BRDA:229,37,3,0 +BRDA:229,37,4,0 +BRDA:240,38,0,0 +BRDA:240,38,1,0 +BRDA:240,39,0,0 +BRDA:240,39,1,0 +BRDA:250,40,0,0 +BRDA:250,40,1,0 +BRDA:250,40,2,0 +BRDA:250,40,3,0 +BRDA:250,40,4,0 +BRDA:256,41,0,0 +BRDA:256,41,1,30 +BRDA:256,42,0,30 +BRDA:256,42,1,30 +BRDA:264,43,0,0 +BRDA:264,43,1,22 +BRDA:272,44,0,17 +BRDA:272,44,1,13 +BRDA:276,45,0,17 +BRDA:276,45,1,0 +BRDA:280,46,0,0 +BRDA:280,46,1,36 +BRDA:280,47,0,36 +BRDA:280,47,1,36 +BRDA:293,48,0,15 +BRDA:293,48,1,15 +BRDA:296,49,0,13 +BRDA:296,49,1,0 +BRDA:298,50,0,0 +BRDA:298,50,1,15 +BRDA:315,51,0,0 +BRDA:315,51,1,51 +BRDA:330,52,0,0 +BRDA:330,52,1,49 +BRDA:334,53,0,0 +BRDA:334,53,1,114 +BRDA:346,54,0,1 +BRDA:346,54,1,0 +BRDA:360,55,0,0 +BRDA:360,55,1,0 +BRDA:369,56,0,0 +BRDA:369,56,1,0 +BRDA:394,57,0,1 +BRDA:394,57,1,0 +BRDA:394,58,0,1 +BRDA:394,58,1,1 +BRDA:430,59,0,34 +BRDA:430,59,1,0 +BRDA:430,60,0,34 +BRDA:430,60,1,34 +BRDA:432,61,0,34 +BRDA:432,61,1,11 +BRDA:432,62,0,11 +BRDA:432,62,1,23 +BRDA:440,63,0,11 +BRDA:440,63,1,23 +BRDA:455,64,0,0 +BRDA:455,64,1,11 +BRDA:458,65,0,11 +BRDA:458,65,1,0 +BRDA:460,66,0,11 +BRDA:460,66,1,11 +BRDA:461,67,0,11 +BRDA:461,67,1,0 +BRDA:464,68,0,11 +BRDA:464,68,1,0 +BRDA:466,69,0,11 +BRDA:466,69,1,11 +BRDA:467,70,0,33 +BRDA:467,70,1,33 +BRDA:468,71,0,11 +BRDA:468,71,1,11 +BRDA:468,72,0,22 +BRDA:468,72,1,22 +BRDA:468,72,2,11 +BRDA:468,72,3,11 +BRDA:468,72,4,11 +BRDA:486,73,0,13 +BRDA:486,73,1,581 +BRDA:486,74,0,594 +BRDA:486,74,1,581 +BRDA:489,75,0,594 +BRDA:489,75,1,594 +BRDA:491,76,0,298 +BRDA:491,76,1,296 +BRDA:495,77,0,594 +BRDA:495,77,1,594 +BRDA:495,77,2,594 +BRDA:496,78,0,0 +BRDA:496,78,1,594 +BRDA:496,79,0,594 +BRDA:496,79,1,0 +BRDA:497,80,0,0 +BRDA:497,80,1,0 +BRDA:498,81,0,0 +BRDA:498,81,1,0 +BRDA:501,82,0,0 +BRDA:501,82,1,0 +BRDA:501,82,2,0 +BRDA:508,83,0,594 +BRDA:508,83,1,0 +BRDA:509,84,0,594 +BRDA:509,84,1,594 +BRDA:510,85,0,1484 +BRDA:510,85,1,1484 +BRDA:512,86,0,890 +BRDA:512,86,1,890 +BRDA:512,86,2,298 +BRDA:533,87,0,1 +BRDA:533,87,1,0 +BRDA:577,88,0,12 +BRDA:577,88,1,1 +BRDA:578,89,0,0 +BRDA:578,89,1,12 +BRDA:582,90,0,11 +BRDA:582,90,1,11 +BRDA:583,91,0,11 +BRDA:583,91,1,0 +BRDA:583,92,0,11 +BRDA:583,92,1,11 +BRDA:583,92,2,11 +BRDA:598,93,0,274 +BRDA:598,93,1,0 +BRDA:598,93,2,11 +BRDA:609,94,0,10 +BRDA:609,94,1,1 +BRDA:629,95,0,1 +BRDA:629,95,1,0 +BRDA:647,96,0,0 +BRDA:647,96,1,11 +BRDA:647,97,0,11 +BRDA:647,97,1,11 +BRDA:651,98,0,11 +BRDA:651,98,1,0 +BRDA:670,99,0,11 +BRDA:670,99,1,274 +BRDA:670,99,2,0 +BRDA:670,99,3,11 +BRDA:683,100,0,0 +BRDA:683,100,1,11 +BRDA:683,101,0,11 +BRDA:683,101,1,0 +BRDA:683,101,2,11 +BRDA:702,102,0,0 +BRDA:702,102,1,117 +BRDA:721,103,0,157 +BRDA:721,103,1,117 +BRDA:725,104,0,0 +BRDA:725,104,1,157 +BRDA:729,105,0,274 +BRDA:729,105,1,0 +BRDA:736,106,0,0 +BRDA:736,106,1,0 +BRDA:779,107,0,0 +BRDA:779,107,1,156 +BRDA:779,108,0,156 +BRDA:779,108,1,0 +BRDA:786,109,0,156 +BRDA:786,109,1,156 +BRDA:786,109,2,156 +BRDA:788,110,0,0 +BRDA:788,110,1,156 +BRDA:800,111,0,0 +BRDA:800,111,1,0 +BRF:250 +BRH:133 +end_of_record +TN: +SF:/Users/kit/Dropbox/Projects/json3/vendor/spec/lib/newton.js +FN:8,(anonymous_1) +FN:26,(anonymous_2) +FN:42,(anonymous_3) +FN:43,noConflict +FN:52,(anonymous_5) +FN:61,(anonymous_6) +FN:62,stringify +FN:68,toPaddedString +FN:85,quote +FN:99,serialize +FN:155,(anonymous_11) +FN:172,all +FN:174,(anonymous_13) +FN:181,toQueryPair +FN:200,serializeQuery +FN:202,(anonymous_16) +FN:204,(anonymous_17) +FN:223,parseQuery +FN:256,isEmpty +FN:275,(anonymous_20) +FN:283,substitute +FN:333,createConsole +FN:334,onEvent +FN:359,createTAP +FN:362,description +FN:365,onEvent +FN:391,onClick +FN:401,(anonymous_28) +FN:405,(anonymous_29) +FN:427,serializeAttribute +FN:433,buildNode +FN:458,(anonymous_32) +FN:464,(anonymous_33) +FN:470,(anonymous_34) +FN:480,clearElement +FN:489,createReport +FN:490,onEvent +FNF:37 +FNH:6 +FNDA:1,(anonymous_1) +FNDA:0,(anonymous_2) +FNDA:0,(anonymous_3) +FNDA:0,noConflict +FNDA:1,(anonymous_5) +FNDA:1,(anonymous_6) +FNDA:0,stringify +FNDA:0,toPaddedString +FNDA:0,quote +FNDA:0,serialize +FNDA:0,(anonymous_11) +FNDA:0,all +FNDA:0,(anonymous_13) +FNDA:0,toQueryPair +FNDA:0,serializeQuery +FNDA:0,(anonymous_16) +FNDA:0,(anonymous_17) +FNDA:0,parseQuery +FNDA:0,isEmpty +FNDA:0,(anonymous_20) +FNDA:298,substitute +FNDA:1,createConsole +FNDA:298,onEvent +FNDA:0,createTAP +FNDA:0,description +FNDA:0,onEvent +FNDA:0,onClick +FNDA:0,(anonymous_28) +FNDA:0,(anonymous_29) +FNDA:0,serializeAttribute +FNDA:0,buildNode +FNDA:0,(anonymous_32) +FNDA:0,(anonymous_33) +FNDA:0,(anonymous_34) +FNDA:0,clearElement +FNDA:0,createReport +FNDA:0,onEvent +DA:8,1 +DA:10,1 +DA:24,1 +DA:26,0 +DA:27,0 +DA:29,1 +DA:31,1 +DA:33,1 +DA:35,1 +DA:38,0 +DA:39,0 +DA:41,0 +DA:43,1 +DA:44,0 +DA:45,0 +DA:46,0 +DA:48,0 +DA:56,1 +DA:62,1 +DA:63,0 +DA:68,1 +DA:69,0 +DA:73,1 +DA:85,1 +DA:86,0 +DA:87,0 +DA:90,0 +DA:95,0 +DA:99,1 +DA:100,0 +DA:101,0 +DA:102,0 +DA:104,0 +DA:105,0 +DA:110,0 +DA:113,0 +DA:115,0 +DA:116,0 +DA:121,0 +DA:123,0 +DA:131,0 +DA:134,0 +DA:138,0 +DA:139,0 +DA:140,0 +DA:144,0 +DA:145,0 +DA:146,0 +DA:148,0 +DA:149,0 +DA:150,0 +DA:153,0 +DA:155,0 +DA:157,0 +DA:159,0 +DA:162,0 +DA:164,0 +DA:167,1 +DA:173,0 +DA:174,0 +DA:175,0 +DA:177,0 +DA:182,0 +DA:183,0 +DA:184,0 +DA:186,0 +DA:190,0 +DA:201,0 +DA:202,0 +DA:203,0 +DA:204,0 +DA:205,0 +DA:206,0 +DA:207,0 +DA:210,0 +DA:211,0 +DA:214,0 +DA:224,0 +DA:226,0 +DA:227,0 +DA:229,0 +DA:230,0 +DA:231,0 +DA:232,0 +DA:233,0 +DA:234,0 +DA:235,0 +DA:236,0 +DA:237,0 +DA:240,0 +DA:242,0 +DA:243,0 +DA:244,0 +DA:246,0 +DA:248,0 +DA:252,0 +DA:257,0 +DA:258,0 +DA:259,0 +DA:261,0 +DA:265,0 +DA:266,0 +DA:270,0 +DA:273,0 +DA:275,0 +DA:276,0 +DA:284,298 +DA:285,298 +DA:286,298 +DA:287,0 +DA:289,298 +DA:290,4294 +DA:291,4294 +DA:292,322 +DA:293,322 +DA:295,0 +DA:297,322 +DA:299,322 +DA:303,24 +DA:304,24 +DA:307,0 +DA:308,0 +DA:311,0 +DA:312,0 +DA:315,298 +DA:319,0 +DA:322,322 +DA:324,322 +DA:326,3972 +DA:329,298 +DA:334,1 +DA:335,298 +DA:337,1 +DA:338,1 +DA:340,11 +DA:341,11 +DA:343,274 +DA:344,274 +DA:346,0 +DA:347,0 +DA:349,11 +DA:350,11 +DA:352,1 +DA:355,1 +DA:360,0 +DA:362,1 +DA:363,0 +DA:365,1 +DA:366,0 +DA:368,0 +DA:369,0 +DA:371,0 +DA:372,0 +DA:373,0 +DA:374,0 +DA:376,0 +DA:377,0 +DA:378,0 +DA:379,0 +DA:380,0 +DA:383,0 +DA:389,1 +DA:391,0 +DA:393,0 +DA:394,0 +DA:395,0 +DA:401,0 +DA:405,0 +DA:406,0 +DA:407,0 +DA:408,0 +DA:409,0 +DA:411,0 +DA:412,0 +DA:428,0 +DA:429,0 +DA:434,0 +DA:435,0 +DA:436,0 +DA:437,0 +DA:439,0 +DA:442,0 +DA:443,0 +DA:444,0 +DA:445,0 +DA:446,0 +DA:448,0 +DA:449,0 +DA:450,0 +DA:452,0 +DA:454,0 +DA:456,0 +DA:457,0 +DA:458,0 +DA:460,0 +DA:462,0 +DA:464,0 +DA:465,0 +DA:469,0 +DA:470,0 +DA:471,0 +DA:474,0 +DA:476,0 +DA:480,0 +DA:481,0 +DA:482,0 +DA:484,0 +DA:489,0 +DA:490,1 +DA:491,0 +DA:492,0 +DA:493,0 +DA:495,0 +DA:496,0 +DA:498,0 +DA:502,0 +DA:504,0 +DA:513,0 +DA:517,0 +DA:520,0 +DA:523,0 +DA:524,0 +DA:528,0 +DA:530,0 +DA:532,0 +DA:533,0 +DA:537,0 +DA:539,0 +DA:540,0 +DA:543,0 +DA:566,0 +DA:569,0 +DA:574,1 +DA:576,1 +LF:234 +LH:50 +BRDA:10,1,0,1 +BRDA:10,1,1,0 +BRDA:11,2,0,1 +BRDA:11,2,1,1 +BRDA:11,2,2,1 +BRDA:11,2,3,1 +BRDA:14,3,0,1 +BRDA:14,3,1,0 +BRDA:14,3,2,0 +BRDA:15,4,0,1 +BRDA:15,4,1,1 +BRDA:15,4,2,0 +BRDA:24,5,0,0 +BRDA:24,5,1,1 +BRDA:29,6,0,1 +BRDA:29,6,1,0 +BRDA:35,7,0,1 +BRDA:35,7,1,0 +BRDA:38,8,0,0 +BRDA:38,8,1,0 +BRDA:50,9,0,0 +BRDA:50,9,1,0 +BRDA:90,10,0,0 +BRDA:90,10,1,0 +BRDA:93,11,0,0 +BRDA:93,11,1,0 +BRDA:101,12,0,0 +BRDA:101,12,1,0 +BRDA:105,13,0,0 +BRDA:105,13,1,0 +BRDA:105,13,2,0 +BRDA:105,13,3,0 +BRDA:105,13,4,0 +BRDA:110,14,0,0 +BRDA:110,14,1,0 +BRDA:115,15,0,0 +BRDA:115,15,1,0 +BRDA:123,16,0,0 +BRDA:123,16,1,0 +BRDA:123,17,0,0 +BRDA:123,17,1,0 +BRDA:123,18,0,0 +BRDA:123,18,1,0 +BRDA:134,19,0,0 +BRDA:134,19,1,0 +BRDA:139,20,0,0 +BRDA:139,20,1,0 +BRDA:146,21,0,0 +BRDA:146,21,1,0 +BRDA:149,22,0,0 +BRDA:149,22,1,0 +BRDA:183,23,0,0 +BRDA:183,23,1,0 +BRDA:186,24,0,0 +BRDA:186,24,1,0 +BRDA:186,24,2,0 +BRDA:203,25,0,0 +BRDA:203,25,1,0 +BRDA:203,26,0,0 +BRDA:203,26,1,0 +BRDA:206,27,0,0 +BRDA:206,27,1,0 +BRDA:210,28,0,0 +BRDA:210,28,1,0 +BRDA:214,29,0,0 +BRDA:214,29,1,0 +BRDA:226,30,0,0 +BRDA:226,30,1,0 +BRDA:226,31,0,0 +BRDA:226,31,1,0 +BRDA:226,31,2,0 +BRDA:226,32,0,0 +BRDA:226,32,1,0 +BRDA:226,33,0,0 +BRDA:226,33,1,0 +BRDA:229,34,0,0 +BRDA:229,34,1,0 +BRDA:233,35,0,0 +BRDA:233,35,1,0 +BRDA:233,36,0,0 +BRDA:233,36,1,0 +BRDA:234,37,0,0 +BRDA:234,37,1,0 +BRDA:236,38,0,0 +BRDA:236,38,1,0 +BRDA:242,39,0,0 +BRDA:242,39,1,0 +BRDA:243,40,0,0 +BRDA:243,40,1,0 +BRDA:258,41,0,0 +BRDA:258,41,1,0 +BRDA:261,42,0,0 +BRDA:261,42,1,0 +BRDA:261,42,2,0 +BRDA:261,42,3,0 +BRDA:261,42,4,0 +BRDA:261,42,5,0 +BRDA:261,42,6,0 +BRDA:261,42,7,0 +BRDA:266,43,0,0 +BRDA:266,43,1,0 +BRDA:286,44,0,0 +BRDA:286,44,1,298 +BRDA:286,45,0,298 +BRDA:286,45,1,298 +BRDA:291,46,0,322 +BRDA:291,46,1,3972 +BRDA:293,47,0,0 +BRDA:293,47,1,322 +BRDA:297,48,0,322 +BRDA:297,48,1,0 +BRDA:299,49,0,0 +BRDA:299,49,1,24 +BRDA:299,49,2,0 +BRDA:299,49,3,0 +BRDA:299,49,4,298 +BRDA:303,50,0,24 +BRDA:303,50,1,12 +BRDA:307,51,0,0 +BRDA:307,51,1,0 +BRDA:335,52,0,1 +BRDA:335,52,1,11 +BRDA:335,52,2,274 +BRDA:335,52,3,0 +BRDA:335,52,4,11 +BRDA:335,52,5,1 +BRDA:366,53,0,0 +BRDA:366,53,1,0 +BRDA:366,53,2,0 +BRDA:389,54,0,0 +BRDA:389,54,1,1 +BRDA:393,55,0,0 +BRDA:393,55,1,0 +BRDA:394,56,0,0 +BRDA:394,56,1,0 +BRDA:395,57,0,0 +BRDA:395,57,1,0 +BRDA:409,58,0,0 +BRDA:409,58,1,0 +BRDA:418,59,0,0 +BRDA:418,59,1,0 +BRDA:435,60,0,0 +BRDA:435,60,1,0 +BRDA:435,61,0,0 +BRDA:435,61,1,0 +BRDA:442,62,0,0 +BRDA:442,62,1,0 +BRDA:442,63,0,0 +BRDA:442,63,1,0 +BRDA:444,64,0,0 +BRDA:444,64,1,0 +BRDA:448,65,0,0 +BRDA:448,65,1,0 +BRDA:456,66,0,0 +BRDA:456,66,1,0 +BRDA:457,67,0,0 +BRDA:457,67,1,0 +BRDA:460,68,0,0 +BRDA:460,68,1,0 +BRDA:469,69,0,0 +BRDA:469,69,1,0 +BRDA:492,70,0,0 +BRDA:492,70,1,0 +BRDA:495,71,0,0 +BRDA:495,71,1,0 +BRDA:498,72,0,0 +BRDA:498,72,1,0 +BRDA:498,72,2,0 +BRDA:498,72,3,0 +BRDA:498,72,4,0 +BRDA:498,72,5,0 +BRDA:523,73,0,0 +BRDA:523,73,1,0 +BRDA:528,74,0,0 +BRDA:528,74,1,0 +BRDA:537,75,0,0 +BRDA:537,75,1,0 +BRDA:543,76,0,0 +BRDA:543,76,1,0 +BRF:179 +BRH:28 +end_of_record +TN: +SF:/Users/kit/Dropbox/Projects/json3/lib/json3.js +FN:2,(anonymous_1) +FN:42,has +FN:64,(anonymous_3) +FN:196,(anonymous_4) +FN:204,(anonymous_5) +FN:213,(anonymous_6) +FN:227,(anonymous_7) +FN:247,(anonymous_8) +FN:254,(anonymous_9) +FN:260,(anonymous_10) +FN:280,(anonymous_11) +FN:295,(anonymous_12) +FN:309,(anonymous_13) +FN:347,(anonymous_14) +FN:358,(anonymous_15) +FN:384,(anonymous_16) +FN:491,(anonymous_17) +FN:513,(anonymous_18) +FN:563,(anonymous_19) +FN:571,(anonymous_20) +FN:729,(anonymous_21) +FN:812,(anonymous_22) +FN:824,(anonymous_23) +FN:835,(anonymous_24) +FN:844,(anonymous_25) +FN:862,(anonymous_26) +FNF:26 +FNH:3 +FNDA:1,(anonymous_1) +FNDA:3,has +FNDA:4,(anonymous_3) +FNDA:0,(anonymous_4) +FNDA:0,(anonymous_5) +FNDA:0,(anonymous_6) +FNDA:0,(anonymous_7) +FNDA:0,(anonymous_8) +FNDA:0,(anonymous_9) +FNDA:0,(anonymous_10) +FNDA:0,(anonymous_11) +FNDA:0,(anonymous_12) +FNDA:0,(anonymous_13) +FNDA:0,(anonymous_14) +FNDA:0,(anonymous_15) +FNDA:0,(anonymous_16) +FNDA:0,(anonymous_17) +FNDA:0,(anonymous_18) +FNDA:0,(anonymous_19) +FNDA:0,(anonymous_20) +FNDA:0,(anonymous_21) +FNDA:0,(anonymous_22) +FNDA:0,(anonymous_23) +FNDA:0,(anonymous_24) +FNDA:0,(anonymous_25) +FNDA:0,(anonymous_26) +DA:2,1 +DA:4,1 +DA:8,1 +DA:11,1 +DA:15,1 +DA:17,1 +DA:20,1 +DA:21,1 +DA:25,0 +DA:29,1 +DA:30,1 +DA:33,1 +DA:42,1 +DA:43,3 +DA:45,0 +DA:48,3 +DA:49,3 +DA:52,0 +DA:53,3 +DA:56,1 +DA:58,2 +DA:60,2 +DA:61,1 +DA:62,1 +DA:64,1 +DA:65,4 +DA:67,1 +DA:68,1 +DA:122,0 +DA:125,1 +DA:128,2 +DA:129,1 +DA:130,1 +DA:131,1 +DA:135,1 +DA:137,1 +DA:138,1 +DA:139,1 +DA:140,1 +DA:142,1 +DA:144,1 +DA:145,1 +DA:149,1 +DA:152,1 +DA:153,1 +DA:157,1 +DA:163,0 +DA:166,1 +DA:169,3 +DA:171,1 +DA:172,1 +DA:173,1 +DA:174,1 +DA:176,1 +DA:178,0 +DA:179,0 +DA:180,0 +DA:181,0 +DA:182,0 +DA:183,0 +DA:186,0 +DA:189,0 +DA:190,0 +DA:193,0 +DA:196,0 +DA:197,0 +DA:203,0 +DA:204,0 +DA:205,0 +DA:206,0 +DA:213,0 +DA:217,0 +DA:219,0 +DA:220,0 +DA:224,0 +DA:227,0 +DA:228,0 +DA:229,0 +DA:232,0 +DA:233,0 +DA:238,0 +DA:247,0 +DA:248,0 +DA:249,0 +DA:254,0 +DA:255,0 +DA:260,0 +DA:261,0 +DA:265,0 +DA:266,0 +DA:268,0 +DA:269,0 +DA:272,0 +DA:275,0 +DA:277,0 +DA:280,0 +DA:281,0 +DA:282,0 +DA:283,0 +DA:286,0 +DA:287,0 +DA:291,0 +DA:293,0 +DA:295,0 +DA:297,0 +DA:298,0 +DA:302,0 +DA:303,0 +DA:309,0 +DA:310,0 +DA:311,0 +DA:312,0 +DA:313,0 +DA:318,0 +DA:319,0 +DA:323,0 +DA:332,0 +DA:334,0 +DA:346,0 +DA:347,0 +DA:350,0 +DA:357,0 +DA:358,0 +DA:359,0 +DA:360,0 +DA:361,0 +DA:363,0 +DA:364,0 +DA:367,0 +DA:369,0 +DA:370,0 +DA:372,0 +DA:373,0 +DA:374,0 +DA:376,0 +DA:379,0 +DA:384,0 +DA:385,0 +DA:386,0 +DA:388,0 +DA:390,0 +DA:391,0 +DA:392,0 +DA:393,0 +DA:397,0 +DA:401,0 +DA:402,0 +DA:403,0 +DA:404,0 +DA:409,0 +DA:412,0 +DA:413,0 +DA:414,0 +DA:415,0 +DA:417,0 +DA:418,0 +DA:419,0 +DA:420,0 +DA:421,0 +DA:422,0 +DA:423,0 +DA:426,0 +DA:434,0 +DA:436,0 +DA:441,0 +DA:444,0 +DA:447,0 +DA:449,0 +DA:450,0 +DA:452,0 +DA:453,0 +DA:455,0 +DA:456,0 +DA:459,0 +DA:460,0 +DA:462,0 +DA:465,0 +DA:468,0 +DA:469,0 +DA:471,0 +DA:475,0 +DA:476,0 +DA:478,0 +DA:479,0 +DA:480,0 +DA:482,0 +DA:483,0 +DA:484,0 +DA:486,0 +DA:491,0 +DA:492,0 +DA:493,0 +DA:500,0 +DA:502,0 +DA:504,0 +DA:507,0 +DA:508,0 +DA:513,0 +DA:514,0 +DA:515,0 +DA:516,0 +DA:517,0 +DA:518,0 +DA:520,0 +DA:521,0 +DA:524,0 +DA:525,0 +DA:528,0 +DA:529,0 +DA:531,0 +DA:532,0 +DA:538,0 +DA:543,0 +DA:544,0 +DA:548,0 +DA:560,0 +DA:563,0 +DA:564,0 +DA:565,0 +DA:571,0 +DA:572,0 +DA:573,0 +DA:574,0 +DA:575,0 +DA:579,0 +DA:580,0 +DA:584,0 +DA:585,0 +DA:586,0 +DA:592,0 +DA:593,0 +DA:594,0 +DA:597,0 +DA:598,0 +DA:602,0 +DA:603,0 +DA:606,0 +DA:607,0 +DA:608,0 +DA:613,0 +DA:614,0 +DA:615,0 +DA:618,0 +DA:620,0 +DA:624,0 +DA:625,0 +DA:628,0 +DA:631,0 +DA:634,0 +DA:636,0 +DA:637,0 +DA:639,0 +DA:640,0 +DA:643,0 +DA:646,0 +DA:648,0 +DA:649,0 +DA:652,0 +DA:655,0 +DA:657,0 +DA:658,0 +DA:659,0 +DA:662,0 +DA:664,0 +DA:666,0 +DA:668,0 +DA:670,0 +DA:673,0 +DA:674,0 +DA:676,0 +DA:677,0 +DA:679,0 +DA:681,0 +DA:685,0 +DA:686,0 +DA:687,0 +DA:690,0 +DA:691,0 +DA:694,0 +DA:695,0 +DA:697,0 +DA:699,0 +DA:702,0 +DA:705,0 +DA:706,0 +DA:709,0 +DA:710,0 +DA:711,0 +DA:712,0 +DA:713,0 +DA:714,0 +DA:715,0 +DA:716,0 +DA:717,0 +DA:720,0 +DA:725,0 +DA:729,0 +DA:730,0 +DA:731,0 +DA:733,0 +DA:735,0 +DA:736,0 +DA:738,0 +DA:741,0 +DA:743,0 +DA:744,0 +DA:745,0 +DA:747,0 +DA:748,0 +DA:753,0 +DA:754,0 +DA:755,0 +DA:756,0 +DA:758,0 +DA:762,0 +DA:766,0 +DA:767,0 +DA:769,0 +DA:771,0 +DA:772,0 +DA:774,0 +DA:775,0 +DA:776,0 +DA:778,0 +DA:779,0 +DA:783,0 +DA:784,0 +DA:785,0 +DA:786,0 +DA:788,0 +DA:792,0 +DA:798,0 +DA:799,0 +DA:801,0 +DA:803,0 +DA:806,0 +DA:808,0 +DA:812,0 +DA:813,0 +DA:814,0 +DA:815,0 +DA:817,0 +DA:824,0 +DA:825,0 +DA:826,0 +DA:830,0 +DA:831,0 +DA:832,0 +DA:835,0 +DA:836,0 +DA:840,0 +DA:844,0 +DA:845,0 +DA:846,0 +DA:847,0 +DA:848,0 +DA:850,0 +DA:851,0 +DA:854,0 +DA:855,0 +DA:861,1 +DA:862,0 +DA:863,0 +LF:363 +LH:50 +BRDA:8,1,0,1 +BRDA:8,1,1,0 +BRDA:11,2,0,1 +BRDA:11,2,1,1 +BRDA:15,3,0,1 +BRDA:15,3,1,1 +BRDA:15,3,2,1 +BRDA:15,3,3,1 +BRDA:17,4,0,1 +BRDA:17,4,1,0 +BRDA:17,5,0,1 +BRDA:17,5,1,1 +BRDA:25,6,0,0 +BRDA:25,6,1,0 +BRDA:33,7,0,1 +BRDA:33,7,1,1 +BRDA:33,7,2,1 +BRDA:33,7,3,1 +BRDA:33,7,4,1 +BRDA:33,7,5,1 +BRDA:33,7,6,1 +BRDA:43,8,0,0 +BRDA:43,8,1,3 +BRDA:49,9,0,0 +BRDA:49,9,1,3 +BRDA:53,10,0,1 +BRDA:53,10,1,2 +BRDA:56,11,0,1 +BRDA:56,11,1,1 +BRDA:60,12,0,1 +BRDA:60,12,1,1 +BRDA:61,13,0,1 +BRDA:61,13,1,1 +BRDA:62,14,0,1 +BRDA:62,14,1,0 +BRDA:71,15,0,1 +BRDA:71,15,1,1 +BRDA:71,15,2,1 +BRDA:71,15,3,1 +BRDA:71,15,4,1 +BRDA:71,15,5,1 +BRDA:71,15,6,1 +BRDA:71,15,7,1 +BRDA:71,15,8,1 +BRDA:71,15,9,1 +BRDA:71,15,10,1 +BRDA:71,15,11,1 +BRDA:71,15,12,1 +BRDA:71,15,13,1 +BRDA:71,15,14,1 +BRDA:71,15,15,1 +BRDA:71,15,16,1 +BRDA:71,15,17,1 +BRDA:128,16,0,1 +BRDA:128,16,1,1 +BRDA:130,17,0,1 +BRDA:130,17,1,0 +BRDA:135,18,0,1 +BRDA:135,18,1,0 +BRDA:135,19,0,1 +BRDA:135,19,1,1 +BRDA:138,20,0,1 +BRDA:138,20,1,1 +BRDA:139,21,0,1 +BRDA:139,21,1,0 +BRDA:144,22,0,1 +BRDA:144,22,1,0 +BRDA:152,23,0,1 +BRDA:152,23,1,0 +BRDA:176,24,0,0 +BRDA:176,24,1,1 +BRDA:189,25,0,0 +BRDA:189,25,1,0 +BRDA:203,26,0,0 +BRDA:203,26,1,0 +BRDA:206,27,0,0 +BRDA:206,27,1,0 +BRDA:228,28,0,0 +BRDA:228,28,1,0 +BRDA:229,29,0,0 +BRDA:229,29,1,0 +BRDA:229,30,0,0 +BRDA:229,30,1,0 +BRDA:249,31,0,0 +BRDA:249,31,1,0 +BRDA:268,32,0,0 +BRDA:268,32,1,0 +BRDA:275,33,0,0 +BRDA:275,33,1,0 +BRDA:282,34,0,0 +BRDA:282,34,1,0 +BRDA:282,35,0,0 +BRDA:282,35,1,0 +BRDA:282,35,2,0 +BRDA:286,36,0,0 +BRDA:286,36,1,0 +BRDA:286,37,0,0 +BRDA:286,37,1,0 +BRDA:286,38,0,0 +BRDA:286,38,1,0 +BRDA:291,39,0,0 +BRDA:291,39,1,0 +BRDA:293,40,0,0 +BRDA:293,40,1,0 +BRDA:302,41,0,0 +BRDA:302,41,1,0 +BRDA:302,42,0,0 +BRDA:302,42,1,0 +BRDA:302,42,2,0 +BRDA:302,42,3,0 +BRDA:302,43,0,0 +BRDA:302,43,1,0 +BRDA:312,44,0,0 +BRDA:312,44,1,0 +BRDA:312,45,0,0 +BRDA:312,45,1,0 +BRDA:312,45,2,0 +BRDA:312,46,0,0 +BRDA:312,46,1,0 +BRDA:318,47,0,0 +BRDA:318,47,1,0 +BRDA:318,48,0,0 +BRDA:318,48,1,0 +BRDA:332,49,0,0 +BRDA:332,49,1,0 +BRDA:350,50,0,0 +BRDA:350,50,1,0 +BRDA:359,51,0,0 +BRDA:359,51,1,0 +BRDA:360,52,0,0 +BRDA:360,52,1,0 +BRDA:367,53,0,0 +BRDA:367,53,1,0 +BRDA:367,53,2,0 +BRDA:367,53,3,0 +BRDA:367,53,4,0 +BRDA:367,53,5,0 +BRDA:367,53,6,0 +BRDA:367,53,7,0 +BRDA:372,54,0,0 +BRDA:372,54,1,0 +BRDA:376,55,0,0 +BRDA:376,55,1,0 +BRDA:376,56,0,0 +BRDA:376,56,1,0 +BRDA:390,57,0,0 +BRDA:390,57,1,0 +BRDA:390,58,0,0 +BRDA:390,58,1,0 +BRDA:392,59,0,0 +BRDA:392,59,1,0 +BRDA:392,60,0,0 +BRDA:392,60,1,0 +BRDA:393,61,0,0 +BRDA:393,61,1,0 +BRDA:393,62,0,0 +BRDA:393,62,1,0 +BRDA:397,63,0,0 +BRDA:397,63,1,0 +BRDA:426,64,0,0 +BRDA:426,64,1,0 +BRDA:426,65,0,0 +BRDA:426,65,1,0 +BRDA:426,66,0,0 +BRDA:426,66,1,0 +BRDA:426,67,0,0 +BRDA:426,67,1,0 +BRDA:436,68,0,0 +BRDA:436,68,1,0 +BRDA:436,69,0,0 +BRDA:436,69,1,0 +BRDA:436,69,2,0 +BRDA:436,69,3,0 +BRDA:436,69,4,0 +BRDA:444,70,0,0 +BRDA:444,70,1,0 +BRDA:449,71,0,0 +BRDA:449,71,1,0 +BRDA:453,72,0,0 +BRDA:453,72,1,0 +BRDA:456,73,0,0 +BRDA:456,73,1,0 +BRDA:459,74,0,0 +BRDA:459,74,1,0 +BRDA:459,75,0,0 +BRDA:459,75,1,0 +BRDA:460,76,0,0 +BRDA:460,76,1,0 +BRDA:465,77,0,0 +BRDA:465,77,1,0 +BRDA:469,78,0,0 +BRDA:469,78,1,0 +BRDA:480,79,0,0 +BRDA:480,79,1,0 +BRDA:482,80,0,0 +BRDA:482,80,1,0 +BRDA:484,81,0,0 +BRDA:484,81,1,0 +BRDA:486,82,0,0 +BRDA:486,82,1,0 +BRDA:486,83,0,0 +BRDA:486,83,1,0 +BRDA:491,84,0,0 +BRDA:491,84,1,0 +BRDA:493,85,0,0 +BRDA:493,85,1,0 +BRDA:500,86,0,0 +BRDA:500,86,1,0 +BRDA:502,87,0,0 +BRDA:502,87,1,0 +BRDA:504,88,0,0 +BRDA:504,88,1,0 +BRDA:504,89,0,0 +BRDA:504,89,1,0 +BRDA:515,90,0,0 +BRDA:515,90,1,0 +BRDA:515,91,0,0 +BRDA:515,91,1,0 +BRDA:515,91,2,0 +BRDA:516,92,0,0 +BRDA:516,92,1,0 +BRDA:518,93,0,0 +BRDA:518,93,1,0 +BRDA:521,94,0,0 +BRDA:521,94,1,0 +BRDA:521,94,2,0 +BRDA:524,95,0,0 +BRDA:524,95,1,0 +BRDA:525,96,0,0 +BRDA:525,96,1,0 +BRDA:528,97,0,0 +BRDA:528,97,1,0 +BRDA:531,98,0,0 +BRDA:531,98,1,0 +BRDA:532,99,0,0 +BRDA:532,99,1,0 +BRDA:543,100,0,0 +BRDA:543,100,1,0 +BRDA:575,101,0,0 +BRDA:575,101,1,0 +BRDA:575,101,2,0 +BRDA:575,101,3,0 +BRDA:575,101,4,0 +BRDA:575,101,5,0 +BRDA:575,101,6,0 +BRDA:575,101,7,0 +BRDA:575,101,8,0 +BRDA:575,101,9,0 +BRDA:575,101,10,0 +BRDA:575,101,11,0 +BRDA:584,102,0,0 +BRDA:584,102,1,0 +BRDA:594,103,0,0 +BRDA:594,103,1,0 +BRDA:598,104,0,0 +BRDA:598,104,1,0 +BRDA:603,105,0,0 +BRDA:603,105,1,0 +BRDA:603,105,2,0 +BRDA:603,105,3,0 +BRDA:603,105,4,0 +BRDA:603,105,5,0 +BRDA:603,105,6,0 +BRDA:603,105,7,0 +BRDA:603,105,8,0 +BRDA:603,105,9,0 +BRDA:618,106,0,0 +BRDA:618,106,1,0 +BRDA:618,107,0,0 +BRDA:618,107,1,0 +BRDA:618,107,2,0 +BRDA:618,107,3,0 +BRDA:618,107,4,0 +BRDA:618,107,5,0 +BRDA:631,108,0,0 +BRDA:631,108,1,0 +BRDA:639,109,0,0 +BRDA:639,109,1,0 +BRDA:639,109,2,0 +BRDA:646,110,0,0 +BRDA:646,110,1,0 +BRDA:657,111,0,0 +BRDA:657,111,1,0 +BRDA:662,112,0,0 +BRDA:662,112,1,0 +BRDA:662,113,0,0 +BRDA:662,113,1,0 +BRDA:664,114,0,0 +BRDA:664,114,1,0 +BRDA:664,115,0,0 +BRDA:664,115,1,0 +BRDA:664,116,0,0 +BRDA:664,116,1,0 +BRDA:670,117,0,0 +BRDA:670,117,1,0 +BRDA:670,118,0,0 +BRDA:670,118,1,0 +BRDA:673,119,0,0 +BRDA:673,119,1,0 +BRDA:676,120,0,0 +BRDA:676,120,1,0 +BRDA:676,121,0,0 +BRDA:676,121,1,0 +BRDA:677,122,0,0 +BRDA:677,122,1,0 +BRDA:686,123,0,0 +BRDA:686,123,1,0 +BRDA:686,124,0,0 +BRDA:686,124,1,0 +BRDA:690,125,0,0 +BRDA:690,125,1,0 +BRDA:690,126,0,0 +BRDA:690,126,1,0 +BRDA:694,127,0,0 +BRDA:694,127,1,0 +BRDA:694,128,0,0 +BRDA:694,128,1,0 +BRDA:695,129,0,0 +BRDA:695,129,1,0 +BRDA:705,130,0,0 +BRDA:705,130,1,0 +BRDA:709,131,0,0 +BRDA:709,131,1,0 +BRDA:712,132,0,0 +BRDA:712,132,1,0 +BRDA:715,133,0,0 +BRDA:715,133,1,0 +BRDA:731,134,0,0 +BRDA:731,134,1,0 +BRDA:735,135,0,0 +BRDA:735,135,1,0 +BRDA:736,136,0,0 +BRDA:736,136,1,0 +BRDA:736,137,0,0 +BRDA:736,137,1,0 +BRDA:741,138,0,0 +BRDA:741,138,1,0 +BRDA:744,139,0,0 +BRDA:744,139,1,0 +BRDA:747,140,0,0 +BRDA:747,140,1,0 +BRDA:753,141,0,0 +BRDA:753,141,1,0 +BRDA:754,142,0,0 +BRDA:754,142,1,0 +BRDA:756,143,0,0 +BRDA:756,143,1,0 +BRDA:766,144,0,0 +BRDA:766,144,1,0 +BRDA:772,145,0,0 +BRDA:772,145,1,0 +BRDA:775,146,0,0 +BRDA:775,146,1,0 +BRDA:778,147,0,0 +BRDA:778,147,1,0 +BRDA:783,148,0,0 +BRDA:783,148,1,0 +BRDA:784,149,0,0 +BRDA:784,149,1,0 +BRDA:786,150,0,0 +BRDA:786,150,1,0 +BRDA:798,151,0,0 +BRDA:798,151,1,0 +BRDA:798,152,0,0 +BRDA:798,152,1,0 +BRDA:798,152,2,0 +BRDA:798,152,3,0 +BRDA:798,153,0,0 +BRDA:798,153,1,0 +BRDA:814,154,0,0 +BRDA:814,154,1,0 +BRDA:826,155,0,0 +BRDA:826,155,1,0 +BRDA:826,156,0,0 +BRDA:826,156,1,0 +BRDA:830,157,0,0 +BRDA:830,157,1,0 +BRDA:850,158,0,0 +BRDA:850,158,1,0 +BRDA:855,159,0,0 +BRDA:855,159,1,0 +BRDA:855,160,0,0 +BRDA:855,160,1,0 +BRDA:861,161,0,0 +BRDA:861,161,1,1 +BRF:385 +BRH:59 +end_of_record diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/lib/json3.js b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/lib/json3.js index 7bf22d2c..ea4a0ea6 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/lib/json3.js +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/lib/json3.js @@ -1,861 +1,861 @@ -/*! JSON v3.2.6 | http://bestiejs.github.io/json3 | Copyright 2012-2013, Kit Cambridge | http://kit.mit-license.org */ -;(function (window) { - // Convenience aliases. - var getClass = {}.toString, isProperty, forEach, undef; - - // Detect the `define` function exposed by asynchronous module loaders. The - // strict `define` check is necessary for compatibility with `r.js`. - var isLoader = typeof define === "function" && define.amd; - - // Detect native implementations. - var nativeJSON = typeof JSON == "object" && JSON; - - // Set up the JSON 3 namespace, preferring the CommonJS `exports` object if - // available. - var JSON3 = typeof exports == "object" && exports && !exports.nodeType && exports; - - if (JSON3 && nativeJSON) { - // Explicitly delegate to the native `stringify` and `parse` - // implementations in CommonJS environments. - JSON3.stringify = nativeJSON.stringify; - JSON3.parse = nativeJSON.parse; - } else { - // Export for web browsers, JavaScript engines, and asynchronous module - // loaders, using the global `JSON` object if available. - JSON3 = window.JSON = nativeJSON || {}; - } - - // Test the `Date#getUTC*` methods. Based on work by @Yaffle. - var isExtended = new Date(-3509827334573292); - try { - // The `getUTCFullYear`, `Month`, and `Date` methods return nonsensical - // results for certain dates in Opera >= 10.53. - isExtended = isExtended.getUTCFullYear() == -109252 && isExtended.getUTCMonth() === 0 && isExtended.getUTCDate() === 1 && - // Safari < 2.0.2 stores the internal millisecond time value correctly, - // but clips the values returned by the date methods to the range of - // signed 32-bit integers ([-2 ** 31, 2 ** 31 - 1]). - isExtended.getUTCHours() == 10 && isExtended.getUTCMinutes() == 37 && isExtended.getUTCSeconds() == 6 && isExtended.getUTCMilliseconds() == 708; - } catch (exception) {} - - // Internal: Determines whether the native `JSON.stringify` and `parse` - // implementations are spec-compliant. Based on work by Ken Snyder. - function has(name) { - if (has[name] !== undef) { - // Return cached feature test result. - return has[name]; - } - - var isSupported; - if (name == "bug-string-char-index") { - // IE <= 7 doesn't support accessing string characters using square - // bracket notation. IE 8 only supports this for primitives. - isSupported = "a"[0] != "a"; - } else if (name == "json") { - // Indicates whether both `JSON.stringify` and `JSON.parse` are - // supported. - isSupported = has("json-stringify") && has("json-parse"); - } else { - var value, serialized = '{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}'; - // Test `JSON.stringify`. - if (name == "json-stringify") { - var stringify = JSON3.stringify, stringifySupported = typeof stringify == "function" && isExtended; - if (stringifySupported) { - // A test function object with a custom `toJSON` method. - (value = function () { - return 1; - }).toJSON = value; - try { - stringifySupported = - // Firefox 3.1b1 and b2 serialize string, number, and boolean - // primitives as object literals. - stringify(0) === "0" && - // FF 3.1b1, b2, and JSON 2 serialize wrapped primitives as object - // literals. - stringify(new Number()) === "0" && - stringify(new String()) == '""' && - // FF 3.1b1, 2 throw an error if the value is `null`, `undefined`, or - // does not define a canonical JSON representation (this applies to - // objects with `toJSON` properties as well, *unless* they are nested - // within an object or array). - stringify(getClass) === undef && - // IE 8 serializes `undefined` as `"undefined"`. Safari <= 5.1.7 and - // FF 3.1b3 pass this test. - stringify(undef) === undef && - // Safari <= 5.1.7 and FF 3.1b3 throw `Error`s and `TypeError`s, - // respectively, if the value is omitted entirely. - stringify() === undef && - // FF 3.1b1, 2 throw an error if the given value is not a number, - // string, array, object, Boolean, or `null` literal. This applies to - // objects with custom `toJSON` methods as well, unless they are nested - // inside object or array literals. YUI 3.0.0b1 ignores custom `toJSON` - // methods entirely. - stringify(value) === "1" && - stringify([value]) == "[1]" && - // Prototype <= 1.6.1 serializes `[undefined]` as `"[]"` instead of - // `"[null]"`. - stringify([undef]) == "[null]" && - // YUI 3.0.0b1 fails to serialize `null` literals. - stringify(null) == "null" && - // FF 3.1b1, 2 halts serialization if an array contains a function: - // `[1, true, getClass, 1]` serializes as "[1,true,],". FF 3.1b3 - // elides non-JSON values from objects and arrays, unless they - // define custom `toJSON` methods. - stringify([undef, getClass, null]) == "[null,null,null]" && - // Simple serialization test. FF 3.1b1 uses Unicode escape sequences - // where character escape codes are expected (e.g., `\b` => `\u0008`). - stringify({ "a": [value, true, false, null, "\x00\b\n\f\r\t"] }) == serialized && - // FF 3.1b1 and b2 ignore the `filter` and `width` arguments. - stringify(null, value) === "1" && - stringify([1, 2], null, 1) == "[\n 1,\n 2\n]" && - // JSON 2, Prototype <= 1.7, and older WebKit builds incorrectly - // serialize extended years. - stringify(new Date(-8.64e15)) == '"-271821-04-20T00:00:00.000Z"' && - // The milliseconds are optional in ES 5, but required in 5.1. - stringify(new Date(8.64e15)) == '"+275760-09-13T00:00:00.000Z"' && - // Firefox <= 11.0 incorrectly serializes years prior to 0 as negative - // four-digit years instead of six-digit years. Credits: @Yaffle. - stringify(new Date(-621987552e5)) == '"-000001-01-01T00:00:00.000Z"' && - // Safari <= 5.1.5 and Opera >= 10.53 incorrectly serialize millisecond - // values less than 1000. Credits: @Yaffle. - stringify(new Date(-1)) == '"1969-12-31T23:59:59.999Z"'; - } catch (exception) { - stringifySupported = false; - } - } - isSupported = stringifySupported; - } - // Test `JSON.parse`. - if (name == "json-parse") { - var parse = JSON3.parse; - if (typeof parse == "function") { - try { - // FF 3.1b1, b2 will throw an exception if a bare literal is provided. - // Conforming implementations should also coerce the initial argument to - // a string prior to parsing. - if (parse("0") === 0 && !parse(false)) { - // Simple parsing test. - value = parse(serialized); - var parseSupported = value["a"].length == 5 && value["a"][0] === 1; - if (parseSupported) { - try { - // Safari <= 5.1.2 and FF 3.1b1 allow unescaped tabs in strings. - parseSupported = !parse('"\t"'); - } catch (exception) {} - if (parseSupported) { - try { - // FF 4.0 and 4.0.1 allow leading `+` signs and leading - // decimal points. FF 4.0, 4.0.1, and IE 9-10 also allow - // certain octal literals. - parseSupported = parse("01") !== 1; - } catch (exception) {} - } - if (parseSupported) { - try { - // FF 4.0, 4.0.1, and Rhino 1.7R3-R4 allow trailing decimal - // points. These environments, along with FF 3.1b1 and 2, - // also allow trailing commas in JSON objects and arrays. - parseSupported = parse("1.") !== 1; - } catch (exception) {} - } - } - } - } catch (exception) { - parseSupported = false; - } - } - isSupported = parseSupported; - } - } - return has[name] = !!isSupported; - } - - if (!has("json")) { - // Common `[[Class]]` name aliases. - var functionClass = "[object Function]"; - var dateClass = "[object Date]"; - var numberClass = "[object Number]"; - var stringClass = "[object String]"; - var arrayClass = "[object Array]"; - var booleanClass = "[object Boolean]"; - - // Detect incomplete support for accessing string characters by index. - var charIndexBuggy = has("bug-string-char-index"); - - // Define additional utility methods if the `Date` methods are buggy. - if (!isExtended) { - var floor = Math.floor; - // A mapping between the months of the year and the number of days between - // January 1st and the first of the respective month. - var Months = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334]; - // Internal: Calculates the number of days between the Unix epoch and the - // first day of the given month. - var getDay = function (year, month) { - return Months[month] + 365 * (year - 1970) + floor((year - 1969 + (month = +(month > 1))) / 4) - floor((year - 1901 + month) / 100) + floor((year - 1601 + month) / 400); - }; - } - - // Internal: Determines if a property is a direct property of the given - // object. Delegates to the native `Object#hasOwnProperty` method. - if (!(isProperty = {}.hasOwnProperty)) { - isProperty = function (property) { - var members = {}, constructor; - if ((members.__proto__ = null, members.__proto__ = { - // The *proto* property cannot be set multiple times in recent - // versions of Firefox and SeaMonkey. - "toString": 1 - }, members).toString != getClass) { - // Safari <= 2.0.3 doesn't implement `Object#hasOwnProperty`, but - // supports the mutable *proto* property. - isProperty = function (property) { - // Capture and break the object's prototype chain (see section 8.6.2 - // of the ES 5.1 spec). The parenthesized expression prevents an - // unsafe transformation by the Closure Compiler. - var original = this.__proto__, result = property in (this.__proto__ = null, this); - // Restore the original prototype chain. - this.__proto__ = original; - return result; - }; - } else { - // Capture a reference to the top-level `Object` constructor. - constructor = members.constructor; - // Use the `constructor` property to simulate `Object#hasOwnProperty` in - // other environments. - isProperty = function (property) { - var parent = (this.constructor || constructor).prototype; - return property in this && !(property in parent && this[property] === parent[property]); - }; - } - members = null; - return isProperty.call(this, property); - }; - } - - // Internal: A set of primitive types used by `isHostType`. - var PrimitiveTypes = { - 'boolean': 1, - 'number': 1, - 'string': 1, - 'undefined': 1 - }; - - // Internal: Determines if the given object `property` value is a - // non-primitive. - var isHostType = function (object, property) { - var type = typeof object[property]; - return type == 'object' ? !!object[property] : !PrimitiveTypes[type]; - }; - - // Internal: Normalizes the `for...in` iteration algorithm across - // environments. Each enumerated key is yielded to a `callback` function. - forEach = function (object, callback) { - var size = 0, Properties, members, property; - - // Tests for bugs in the current environment's `for...in` algorithm. The - // `valueOf` property inherits the non-enumerable flag from - // `Object.prototype` in older versions of IE, Netscape, and Mozilla. - (Properties = function () { - this.valueOf = 0; - }).prototype.valueOf = 0; - - // Iterate over a new instance of the `Properties` class. - members = new Properties(); - for (property in members) { - // Ignore all properties inherited from `Object.prototype`. - if (isProperty.call(members, property)) { - size++; - } - } - Properties = members = null; - - // Normalize the iteration algorithm. - if (!size) { - // A list of non-enumerable properties inherited from `Object.prototype`. - members = ["valueOf", "toString", "toLocaleString", "propertyIsEnumerable", "isPrototypeOf", "hasOwnProperty", "constructor"]; - // IE <= 8, Mozilla 1.0, and Netscape 6.2 ignore shadowed non-enumerable - // properties. - forEach = function (object, callback) { - var isFunction = getClass.call(object) == functionClass, property, length; - var hasProperty = !isFunction && typeof object.constructor != 'function' && isHostType(object, 'hasOwnProperty') ? object.hasOwnProperty : isProperty; - for (property in object) { - // Gecko <= 1.0 enumerates the `prototype` property of functions under - // certain conditions; IE does not. - if (!(isFunction && property == "prototype") && hasProperty.call(object, property)) { - callback(property); - } - } - // Manually invoke the callback for each non-enumerable property. - for (length = members.length; property = members[--length]; hasProperty.call(object, property) && callback(property)); - }; - } else if (size == 2) { - // Safari <= 2.0.4 enumerates shadowed properties twice. - forEach = function (object, callback) { - // Create a set of iterated properties. - var members = {}, isFunction = getClass.call(object) == functionClass, property; - for (property in object) { - // Store each property name to prevent double enumeration. The - // `prototype` property of functions is not enumerated due to cross- - // environment inconsistencies. - if (!(isFunction && property == "prototype") && !isProperty.call(members, property) && (members[property] = 1) && isProperty.call(object, property)) { - callback(property); - } - } - }; - } else { - // No bugs detected; use the standard `for...in` algorithm. - forEach = function (object, callback) { - var isFunction = getClass.call(object) == functionClass, property, isConstructor; - for (property in object) { - if (!(isFunction && property == "prototype") && isProperty.call(object, property) && !(isConstructor = property === "constructor")) { - callback(property); - } - } - // Manually invoke the callback for the `constructor` property due to - // cross-environment inconsistencies. - if (isConstructor || isProperty.call(object, (property = "constructor"))) { - callback(property); - } - }; - } - return forEach(object, callback); - }; - - // Public: Serializes a JavaScript `value` as a JSON string. The optional - // `filter` argument may specify either a function that alters how object and - // array members are serialized, or an array of strings and numbers that - // indicates which properties should be serialized. The optional `width` - // argument may be either a string or number that specifies the indentation - // level of the output. - if (!has("json-stringify")) { - // Internal: A map of control characters and their escaped equivalents. - var Escapes = { - 92: "\\\\", - 34: '\\"', - 8: "\\b", - 12: "\\f", - 10: "\\n", - 13: "\\r", - 9: "\\t" - }; - - // Internal: Converts `value` into a zero-padded string such that its - // length is at least equal to `width`. The `width` must be <= 6. - var leadingZeroes = "000000"; - var toPaddedString = function (width, value) { - // The `|| 0` expression is necessary to work around a bug in - // Opera <= 7.54u2 where `0 == -0`, but `String(-0) !== "0"`. - return (leadingZeroes + (value || 0)).slice(-width); - }; - - // Internal: Double-quotes a string `value`, replacing all ASCII control - // characters (characters with code unit values between 0 and 31) with - // their escaped equivalents. This is an implementation of the - // `Quote(value)` operation defined in ES 5.1 section 15.12.3. - var unicodePrefix = "\\u00"; - var quote = function (value) { - var result = '"', index = 0, length = value.length, isLarge = length > 10 && charIndexBuggy, symbols; - if (isLarge) { - symbols = value.split(""); - } - for (; index < length; index++) { - var charCode = value.charCodeAt(index); - // If the character is a control character, append its Unicode or - // shorthand escape sequence; otherwise, append the character as-is. - switch (charCode) { - case 8: case 9: case 10: case 12: case 13: case 34: case 92: - result += Escapes[charCode]; - break; - default: - if (charCode < 32) { - result += unicodePrefix + toPaddedString(2, charCode.toString(16)); - break; - } - result += isLarge ? symbols[index] : charIndexBuggy ? value.charAt(index) : value[index]; - } - } - return result + '"'; - }; - - // Internal: Recursively serializes an object. Implements the - // `Str(key, holder)`, `JO(value)`, and `JA(value)` operations. - var serialize = function (property, object, callback, properties, whitespace, indentation, stack) { - var value, className, year, month, date, time, hours, minutes, seconds, milliseconds, results, element, index, length, prefix, result; - try { - // Necessary for host object support. - value = object[property]; - } catch (exception) {} - if (typeof value == "object" && value) { - className = getClass.call(value); - if (className == dateClass && !isProperty.call(value, "toJSON")) { - if (value > -1 / 0 && value < 1 / 0) { - // Dates are serialized according to the `Date#toJSON` method - // specified in ES 5.1 section 15.9.5.44. See section 15.9.1.15 - // for the ISO 8601 date time string format. - if (getDay) { - // Manually compute the year, month, date, hours, minutes, - // seconds, and milliseconds if the `getUTC*` methods are - // buggy. Adapted from @Yaffle's `date-shim` project. - date = floor(value / 864e5); - for (year = floor(date / 365.2425) + 1970 - 1; getDay(year + 1, 0) <= date; year++); - for (month = floor((date - getDay(year, 0)) / 30.42); getDay(year, month + 1) <= date; month++); - date = 1 + date - getDay(year, month); - // The `time` value specifies the time within the day (see ES - // 5.1 section 15.9.1.2). The formula `(A % B + B) % B` is used - // to compute `A modulo B`, as the `%` operator does not - // correspond to the `modulo` operation for negative numbers. - time = (value % 864e5 + 864e5) % 864e5; - // The hours, minutes, seconds, and milliseconds are obtained by - // decomposing the time within the day. See section 15.9.1.10. - hours = floor(time / 36e5) % 24; - minutes = floor(time / 6e4) % 60; - seconds = floor(time / 1e3) % 60; - milliseconds = time % 1e3; - } else { - year = value.getUTCFullYear(); - month = value.getUTCMonth(); - date = value.getUTCDate(); - hours = value.getUTCHours(); - minutes = value.getUTCMinutes(); - seconds = value.getUTCSeconds(); - milliseconds = value.getUTCMilliseconds(); - } - // Serialize extended years correctly. - value = (year <= 0 || year >= 1e4 ? (year < 0 ? "-" : "+") + toPaddedString(6, year < 0 ? -year : year) : toPaddedString(4, year)) + - "-" + toPaddedString(2, month + 1) + "-" + toPaddedString(2, date) + - // Months, dates, hours, minutes, and seconds should have two - // digits; milliseconds should have three. - "T" + toPaddedString(2, hours) + ":" + toPaddedString(2, minutes) + ":" + toPaddedString(2, seconds) + - // Milliseconds are optional in ES 5.0, but required in 5.1. - "." + toPaddedString(3, milliseconds) + "Z"; - } else { - value = null; - } - } else if (typeof value.toJSON == "function" && ((className != numberClass && className != stringClass && className != arrayClass) || isProperty.call(value, "toJSON"))) { - // Prototype <= 1.6.1 adds non-standard `toJSON` methods to the - // `Number`, `String`, `Date`, and `Array` prototypes. JSON 3 - // ignores all `toJSON` methods on these objects unless they are - // defined directly on an instance. - value = value.toJSON(property); - } - } - if (callback) { - // If a replacement function was provided, call it to obtain the value - // for serialization. - value = callback.call(object, property, value); - } - if (value === null) { - return "null"; - } - className = getClass.call(value); - if (className == booleanClass) { - // Booleans are represented literally. - return "" + value; - } else if (className == numberClass) { - // JSON numbers must be finite. `Infinity` and `NaN` are serialized as - // `"null"`. - return value > -1 / 0 && value < 1 / 0 ? "" + value : "null"; - } else if (className == stringClass) { - // Strings are double-quoted and escaped. - return quote("" + value); - } - // Recursively serialize objects and arrays. - if (typeof value == "object") { - // Check for cyclic structures. This is a linear search; performance - // is inversely proportional to the number of unique nested objects. - for (length = stack.length; length--;) { - if (stack[length] === value) { - // Cyclic structures cannot be serialized by `JSON.stringify`. - throw TypeError(); - } - } - // Add the object to the stack of traversed objects. - stack.push(value); - results = []; - // Save the current indentation level and indent one additional level. - prefix = indentation; - indentation += whitespace; - if (className == arrayClass) { - // Recursively serialize array elements. - for (index = 0, length = value.length; index < length; index++) { - element = serialize(index, value, callback, properties, whitespace, indentation, stack); - results.push(element === undef ? "null" : element); - } - result = results.length ? (whitespace ? "[\n" + indentation + results.join(",\n" + indentation) + "\n" + prefix + "]" : ("[" + results.join(",") + "]")) : "[]"; - } else { - // Recursively serialize object members. Members are selected from - // either a user-specified list of property names, or the object - // itself. - forEach(properties || value, function (property) { - var element = serialize(property, value, callback, properties, whitespace, indentation, stack); - if (element !== undef) { - // According to ES 5.1 section 15.12.3: "If `gap` {whitespace} - // is not the empty string, let `member` {quote(property) + ":"} - // be the concatenation of `member` and the `space` character." - // The "`space` character" refers to the literal space - // character, not the `space` {width} argument provided to - // `JSON.stringify`. - results.push(quote(property) + ":" + (whitespace ? " " : "") + element); - } - }); - result = results.length ? (whitespace ? "{\n" + indentation + results.join(",\n" + indentation) + "\n" + prefix + "}" : ("{" + results.join(",") + "}")) : "{}"; - } - // Remove the object from the traversed object stack. - stack.pop(); - return result; - } - }; - - // Public: `JSON.stringify`. See ES 5.1 section 15.12.3. - JSON3.stringify = function (source, filter, width) { - var whitespace, callback, properties, className; - if (typeof filter == "function" || typeof filter == "object" && filter) { - if ((className = getClass.call(filter)) == functionClass) { - callback = filter; - } else if (className == arrayClass) { - // Convert the property names array into a makeshift set. - properties = {}; - for (var index = 0, length = filter.length, value; index < length; value = filter[index++], ((className = getClass.call(value)), className == stringClass || className == numberClass) && (properties[value] = 1)); - } - } - if (width) { - if ((className = getClass.call(width)) == numberClass) { - // Convert the `width` to an integer and create a string containing - // `width` number of space characters. - if ((width -= width % 1) > 0) { - for (whitespace = "", width > 10 && (width = 10); whitespace.length < width; whitespace += " "); - } - } else if (className == stringClass) { - whitespace = width.length <= 10 ? width : width.slice(0, 10); - } - } - // Opera <= 7.54u2 discards the values associated with empty string keys - // (`""`) only if they are used directly within an object member list - // (e.g., `!("" in { "": 1})`). - return serialize("", (value = {}, value[""] = source, value), callback, properties, whitespace, "", []); - }; - } - - // Public: Parses a JSON source string. - if (!has("json-parse")) { - var fromCharCode = String.fromCharCode; - - // Internal: A map of escaped control characters and their unescaped - // equivalents. - var Unescapes = { - 92: "\\", - 34: '"', - 47: "/", - 98: "\b", - 116: "\t", - 110: "\n", - 102: "\f", - 114: "\r" - }; - - // Internal: Stores the parser state. - var Index, Source; - - // Internal: Resets the parser state and throws a `SyntaxError`. - var abort = function() { - Index = Source = null; - throw SyntaxError(); - }; - - // Internal: Returns the next token, or `"$"` if the parser has reached - // the end of the source string. A token may be a string, number, `null` - // literal, or Boolean literal. - var lex = function () { - var source = Source, length = source.length, value, begin, position, isSigned, charCode; - while (Index < length) { - charCode = source.charCodeAt(Index); - switch (charCode) { - case 9: case 10: case 13: case 32: - // Skip whitespace tokens, including tabs, carriage returns, line - // feeds, and space characters. - Index++; - break; - case 123: case 125: case 91: case 93: case 58: case 44: - // Parse a punctuator token (`{`, `}`, `[`, `]`, `:`, or `,`) at - // the current position. - value = charIndexBuggy ? source.charAt(Index) : source[Index]; - Index++; - return value; - case 34: - // `"` delimits a JSON string; advance to the next character and - // begin parsing the string. String tokens are prefixed with the - // sentinel `@` character to distinguish them from punctuators and - // end-of-string tokens. - for (value = "@", Index++; Index < length;) { - charCode = source.charCodeAt(Index); - if (charCode < 32) { - // Unescaped ASCII control characters (those with a code unit - // less than the space character) are not permitted. - abort(); - } else if (charCode == 92) { - // A reverse solidus (`\`) marks the beginning of an escaped - // control character (including `"`, `\`, and `/`) or Unicode - // escape sequence. - charCode = source.charCodeAt(++Index); - switch (charCode) { - case 92: case 34: case 47: case 98: case 116: case 110: case 102: case 114: - // Revive escaped control characters. - value += Unescapes[charCode]; - Index++; - break; - case 117: - // `\u` marks the beginning of a Unicode escape sequence. - // Advance to the first character and validate the - // four-digit code point. - begin = ++Index; - for (position = Index + 4; Index < position; Index++) { - charCode = source.charCodeAt(Index); - // A valid sequence comprises four hexdigits (case- - // insensitive) that form a single hexadecimal value. - if (!(charCode >= 48 && charCode <= 57 || charCode >= 97 && charCode <= 102 || charCode >= 65 && charCode <= 70)) { - // Invalid Unicode escape sequence. - abort(); - } - } - // Revive the escaped character. - value += fromCharCode("0x" + source.slice(begin, Index)); - break; - default: - // Invalid escape sequence. - abort(); - } - } else { - if (charCode == 34) { - // An unescaped double-quote character marks the end of the - // string. - break; - } - charCode = source.charCodeAt(Index); - begin = Index; - // Optimize for the common case where a string is valid. - while (charCode >= 32 && charCode != 92 && charCode != 34) { - charCode = source.charCodeAt(++Index); - } - // Append the string as-is. - value += source.slice(begin, Index); - } - } - if (source.charCodeAt(Index) == 34) { - // Advance to the next character and return the revived string. - Index++; - return value; - } - // Unterminated string. - abort(); - default: - // Parse numbers and literals. - begin = Index; - // Advance past the negative sign, if one is specified. - if (charCode == 45) { - isSigned = true; - charCode = source.charCodeAt(++Index); - } - // Parse an integer or floating-point value. - if (charCode >= 48 && charCode <= 57) { - // Leading zeroes are interpreted as octal literals. - if (charCode == 48 && ((charCode = source.charCodeAt(Index + 1)), charCode >= 48 && charCode <= 57)) { - // Illegal octal literal. - abort(); - } - isSigned = false; - // Parse the integer component. - for (; Index < length && ((charCode = source.charCodeAt(Index)), charCode >= 48 && charCode <= 57); Index++); - // Floats cannot contain a leading decimal point; however, this - // case is already accounted for by the parser. - if (source.charCodeAt(Index) == 46) { - position = ++Index; - // Parse the decimal component. - for (; position < length && ((charCode = source.charCodeAt(position)), charCode >= 48 && charCode <= 57); position++); - if (position == Index) { - // Illegal trailing decimal. - abort(); - } - Index = position; - } - // Parse exponents. The `e` denoting the exponent is - // case-insensitive. - charCode = source.charCodeAt(Index); - if (charCode == 101 || charCode == 69) { - charCode = source.charCodeAt(++Index); - // Skip past the sign following the exponent, if one is - // specified. - if (charCode == 43 || charCode == 45) { - Index++; - } - // Parse the exponential component. - for (position = Index; position < length && ((charCode = source.charCodeAt(position)), charCode >= 48 && charCode <= 57); position++); - if (position == Index) { - // Illegal empty exponent. - abort(); - } - Index = position; - } - // Coerce the parsed value to a JavaScript number. - return +source.slice(begin, Index); - } - // A negative sign may only precede numbers. - if (isSigned) { - abort(); - } - // `true`, `false`, and `null` literals. - if (source.slice(Index, Index + 4) == "true") { - Index += 4; - return true; - } else if (source.slice(Index, Index + 5) == "false") { - Index += 5; - return false; - } else if (source.slice(Index, Index + 4) == "null") { - Index += 4; - return null; - } - // Unrecognized token. - abort(); - } - } - // Return the sentinel `$` character if the parser has reached the end - // of the source string. - return "$"; - }; - - // Internal: Parses a JSON `value` token. - var get = function (value) { - var results, hasMembers; - if (value == "$") { - // Unexpected end of input. - abort(); - } - if (typeof value == "string") { - if ((charIndexBuggy ? value.charAt(0) : value[0]) == "@") { - // Remove the sentinel `@` character. - return value.slice(1); - } - // Parse object and array literals. - if (value == "[") { - // Parses a JSON array, returning a new JavaScript array. - results = []; - for (;; hasMembers || (hasMembers = true)) { - value = lex(); - // A closing square bracket marks the end of the array literal. - if (value == "]") { - break; - } - // If the array literal contains elements, the current token - // should be a comma separating the previous element from the - // next. - if (hasMembers) { - if (value == ",") { - value = lex(); - if (value == "]") { - // Unexpected trailing `,` in array literal. - abort(); - } - } else { - // A `,` must separate each array element. - abort(); - } - } - // Elisions and leading commas are not permitted. - if (value == ",") { - abort(); - } - results.push(get(value)); - } - return results; - } else if (value == "{") { - // Parses a JSON object, returning a new JavaScript object. - results = {}; - for (;; hasMembers || (hasMembers = true)) { - value = lex(); - // A closing curly brace marks the end of the object literal. - if (value == "}") { - break; - } - // If the object literal contains members, the current token - // should be a comma separator. - if (hasMembers) { - if (value == ",") { - value = lex(); - if (value == "}") { - // Unexpected trailing `,` in object literal. - abort(); - } - } else { - // A `,` must separate each object member. - abort(); - } - } - // Leading commas are not permitted, object property names must be - // double-quoted strings, and a `:` must separate each property - // name and value. - if (value == "," || typeof value != "string" || (charIndexBuggy ? value.charAt(0) : value[0]) != "@" || lex() != ":") { - abort(); - } - results[value.slice(1)] = get(lex()); - } - return results; - } - // Unexpected token encountered. - abort(); - } - return value; - }; - - // Internal: Updates a traversed object member. - var update = function(source, property, callback) { - var element = walk(source, property, callback); - if (element === undef) { - delete source[property]; - } else { - source[property] = element; - } - }; - - // Internal: Recursively traverses a parsed JSON object, invoking the - // `callback` function for each value. This is an implementation of the - // `Walk(holder, name)` operation defined in ES 5.1 section 15.12.2. - var walk = function (source, property, callback) { - var value = source[property], length; - if (typeof value == "object" && value) { - // `forEach` can't be used to traverse an array in Opera <= 8.54 - // because its `Object#hasOwnProperty` implementation returns `false` - // for array indices (e.g., `![1, 2, 3].hasOwnProperty("0")`). - if (getClass.call(value) == arrayClass) { - for (length = value.length; length--;) { - update(value, length, callback); - } - } else { - forEach(value, function (property) { - update(value, property, callback); - }); - } - } - return callback.call(source, property, value); - }; - - // Public: `JSON.parse`. See ES 5.1 section 15.12.2. - JSON3.parse = function (source, callback) { - var result, value; - Index = 0; - Source = "" + source; - result = get(lex()); - // If a JSON string contains multiple tokens, it is invalid. - if (lex() != "$") { - abort(); - } - // Reset the parser state. - Index = Source = null; - return callback && getClass.call(callback) == functionClass ? walk((value = {}, value[""] = result, value), "", callback) : result; - }; - } - } - - // Export for asynchronous module loaders. - if (isLoader) { - define(function () { - return JSON3; - }); - } -}(this)); +/*! JSON v3.2.6 | http://bestiejs.github.io/json3 | Copyright 2012-2013, Kit Cambridge | http://kit.mit-license.org */ +;(function (window) { + // Convenience aliases. + var getClass = {}.toString, isProperty, forEach, undef; + + // Detect the `define` function exposed by asynchronous module loaders. The + // strict `define` check is necessary for compatibility with `r.js`. + var isLoader = typeof define === "function" && define.amd; + + // Detect native implementations. + var nativeJSON = typeof JSON == "object" && JSON; + + // Set up the JSON 3 namespace, preferring the CommonJS `exports` object if + // available. + var JSON3 = typeof exports == "object" && exports && !exports.nodeType && exports; + + if (JSON3 && nativeJSON) { + // Explicitly delegate to the native `stringify` and `parse` + // implementations in CommonJS environments. + JSON3.stringify = nativeJSON.stringify; + JSON3.parse = nativeJSON.parse; + } else { + // Export for web browsers, JavaScript engines, and asynchronous module + // loaders, using the global `JSON` object if available. + JSON3 = window.JSON = nativeJSON || {}; + } + + // Test the `Date#getUTC*` methods. Based on work by @Yaffle. + var isExtended = new Date(-3509827334573292); + try { + // The `getUTCFullYear`, `Month`, and `Date` methods return nonsensical + // results for certain dates in Opera >= 10.53. + isExtended = isExtended.getUTCFullYear() == -109252 && isExtended.getUTCMonth() === 0 && isExtended.getUTCDate() === 1 && + // Safari < 2.0.2 stores the internal millisecond time value correctly, + // but clips the values returned by the date methods to the range of + // signed 32-bit integers ([-2 ** 31, 2 ** 31 - 1]). + isExtended.getUTCHours() == 10 && isExtended.getUTCMinutes() == 37 && isExtended.getUTCSeconds() == 6 && isExtended.getUTCMilliseconds() == 708; + } catch (exception) {} + + // Internal: Determines whether the native `JSON.stringify` and `parse` + // implementations are spec-compliant. Based on work by Ken Snyder. + function has(name) { + if (has[name] !== undef) { + // Return cached feature test result. + return has[name]; + } + + var isSupported; + if (name == "bug-string-char-index") { + // IE <= 7 doesn't support accessing string characters using square + // bracket notation. IE 8 only supports this for primitives. + isSupported = "a"[0] != "a"; + } else if (name == "json") { + // Indicates whether both `JSON.stringify` and `JSON.parse` are + // supported. + isSupported = has("json-stringify") && has("json-parse"); + } else { + var value, serialized = '{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}'; + // Test `JSON.stringify`. + if (name == "json-stringify") { + var stringify = JSON3.stringify, stringifySupported = typeof stringify == "function" && isExtended; + if (stringifySupported) { + // A test function object with a custom `toJSON` method. + (value = function () { + return 1; + }).toJSON = value; + try { + stringifySupported = + // Firefox 3.1b1 and b2 serialize string, number, and boolean + // primitives as object literals. + stringify(0) === "0" && + // FF 3.1b1, b2, and JSON 2 serialize wrapped primitives as object + // literals. + stringify(new Number()) === "0" && + stringify(new String()) == '""' && + // FF 3.1b1, 2 throw an error if the value is `null`, `undefined`, or + // does not define a canonical JSON representation (this applies to + // objects with `toJSON` properties as well, *unless* they are nested + // within an object or array). + stringify(getClass) === undef && + // IE 8 serializes `undefined` as `"undefined"`. Safari <= 5.1.7 and + // FF 3.1b3 pass this test. + stringify(undef) === undef && + // Safari <= 5.1.7 and FF 3.1b3 throw `Error`s and `TypeError`s, + // respectively, if the value is omitted entirely. + stringify() === undef && + // FF 3.1b1, 2 throw an error if the given value is not a number, + // string, array, object, Boolean, or `null` literal. This applies to + // objects with custom `toJSON` methods as well, unless they are nested + // inside object or array literals. YUI 3.0.0b1 ignores custom `toJSON` + // methods entirely. + stringify(value) === "1" && + stringify([value]) == "[1]" && + // Prototype <= 1.6.1 serializes `[undefined]` as `"[]"` instead of + // `"[null]"`. + stringify([undef]) == "[null]" && + // YUI 3.0.0b1 fails to serialize `null` literals. + stringify(null) == "null" && + // FF 3.1b1, 2 halts serialization if an array contains a function: + // `[1, true, getClass, 1]` serializes as "[1,true,],". FF 3.1b3 + // elides non-JSON values from objects and arrays, unless they + // define custom `toJSON` methods. + stringify([undef, getClass, null]) == "[null,null,null]" && + // Simple serialization test. FF 3.1b1 uses Unicode escape sequences + // where character escape codes are expected (e.g., `\b` => `\u0008`). + stringify({ "a": [value, true, false, null, "\x00\b\n\f\r\t"] }) == serialized && + // FF 3.1b1 and b2 ignore the `filter` and `width` arguments. + stringify(null, value) === "1" && + stringify([1, 2], null, 1) == "[\n 1,\n 2\n]" && + // JSON 2, Prototype <= 1.7, and older WebKit builds incorrectly + // serialize extended years. + stringify(new Date(-8.64e15)) == '"-271821-04-20T00:00:00.000Z"' && + // The milliseconds are optional in ES 5, but required in 5.1. + stringify(new Date(8.64e15)) == '"+275760-09-13T00:00:00.000Z"' && + // Firefox <= 11.0 incorrectly serializes years prior to 0 as negative + // four-digit years instead of six-digit years. Credits: @Yaffle. + stringify(new Date(-621987552e5)) == '"-000001-01-01T00:00:00.000Z"' && + // Safari <= 5.1.5 and Opera >= 10.53 incorrectly serialize millisecond + // values less than 1000. Credits: @Yaffle. + stringify(new Date(-1)) == '"1969-12-31T23:59:59.999Z"'; + } catch (exception) { + stringifySupported = false; + } + } + isSupported = stringifySupported; + } + // Test `JSON.parse`. + if (name == "json-parse") { + var parse = JSON3.parse; + if (typeof parse == "function") { + try { + // FF 3.1b1, b2 will throw an exception if a bare literal is provided. + // Conforming implementations should also coerce the initial argument to + // a string prior to parsing. + if (parse("0") === 0 && !parse(false)) { + // Simple parsing test. + value = parse(serialized); + var parseSupported = value["a"].length == 5 && value["a"][0] === 1; + if (parseSupported) { + try { + // Safari <= 5.1.2 and FF 3.1b1 allow unescaped tabs in strings. + parseSupported = !parse('"\t"'); + } catch (exception) {} + if (parseSupported) { + try { + // FF 4.0 and 4.0.1 allow leading `+` signs and leading + // decimal points. FF 4.0, 4.0.1, and IE 9-10 also allow + // certain octal literals. + parseSupported = parse("01") !== 1; + } catch (exception) {} + } + if (parseSupported) { + try { + // FF 4.0, 4.0.1, and Rhino 1.7R3-R4 allow trailing decimal + // points. These environments, along with FF 3.1b1 and 2, + // also allow trailing commas in JSON objects and arrays. + parseSupported = parse("1.") !== 1; + } catch (exception) {} + } + } + } + } catch (exception) { + parseSupported = false; + } + } + isSupported = parseSupported; + } + } + return has[name] = !!isSupported; + } + + if (!has("json")) { + // Common `[[Class]]` name aliases. + var functionClass = "[object Function]"; + var dateClass = "[object Date]"; + var numberClass = "[object Number]"; + var stringClass = "[object String]"; + var arrayClass = "[object Array]"; + var booleanClass = "[object Boolean]"; + + // Detect incomplete support for accessing string characters by index. + var charIndexBuggy = has("bug-string-char-index"); + + // Define additional utility methods if the `Date` methods are buggy. + if (!isExtended) { + var floor = Math.floor; + // A mapping between the months of the year and the number of days between + // January 1st and the first of the respective month. + var Months = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334]; + // Internal: Calculates the number of days between the Unix epoch and the + // first day of the given month. + var getDay = function (year, month) { + return Months[month] + 365 * (year - 1970) + floor((year - 1969 + (month = +(month > 1))) / 4) - floor((year - 1901 + month) / 100) + floor((year - 1601 + month) / 400); + }; + } + + // Internal: Determines if a property is a direct property of the given + // object. Delegates to the native `Object#hasOwnProperty` method. + if (!(isProperty = {}.hasOwnProperty)) { + isProperty = function (property) { + var members = {}, constructor; + if ((members.__proto__ = null, members.__proto__ = { + // The *proto* property cannot be set multiple times in recent + // versions of Firefox and SeaMonkey. + "toString": 1 + }, members).toString != getClass) { + // Safari <= 2.0.3 doesn't implement `Object#hasOwnProperty`, but + // supports the mutable *proto* property. + isProperty = function (property) { + // Capture and break the object's prototype chain (see section 8.6.2 + // of the ES 5.1 spec). The parenthesized expression prevents an + // unsafe transformation by the Closure Compiler. + var original = this.__proto__, result = property in (this.__proto__ = null, this); + // Restore the original prototype chain. + this.__proto__ = original; + return result; + }; + } else { + // Capture a reference to the top-level `Object` constructor. + constructor = members.constructor; + // Use the `constructor` property to simulate `Object#hasOwnProperty` in + // other environments. + isProperty = function (property) { + var parent = (this.constructor || constructor).prototype; + return property in this && !(property in parent && this[property] === parent[property]); + }; + } + members = null; + return isProperty.call(this, property); + }; + } + + // Internal: A set of primitive types used by `isHostType`. + var PrimitiveTypes = { + 'boolean': 1, + 'number': 1, + 'string': 1, + 'undefined': 1 + }; + + // Internal: Determines if the given object `property` value is a + // non-primitive. + var isHostType = function (object, property) { + var type = typeof object[property]; + return type == 'object' ? !!object[property] : !PrimitiveTypes[type]; + }; + + // Internal: Normalizes the `for...in` iteration algorithm across + // environments. Each enumerated key is yielded to a `callback` function. + forEach = function (object, callback) { + var size = 0, Properties, members, property; + + // Tests for bugs in the current environment's `for...in` algorithm. The + // `valueOf` property inherits the non-enumerable flag from + // `Object.prototype` in older versions of IE, Netscape, and Mozilla. + (Properties = function () { + this.valueOf = 0; + }).prototype.valueOf = 0; + + // Iterate over a new instance of the `Properties` class. + members = new Properties(); + for (property in members) { + // Ignore all properties inherited from `Object.prototype`. + if (isProperty.call(members, property)) { + size++; + } + } + Properties = members = null; + + // Normalize the iteration algorithm. + if (!size) { + // A list of non-enumerable properties inherited from `Object.prototype`. + members = ["valueOf", "toString", "toLocaleString", "propertyIsEnumerable", "isPrototypeOf", "hasOwnProperty", "constructor"]; + // IE <= 8, Mozilla 1.0, and Netscape 6.2 ignore shadowed non-enumerable + // properties. + forEach = function (object, callback) { + var isFunction = getClass.call(object) == functionClass, property, length; + var hasProperty = !isFunction && typeof object.constructor != 'function' && isHostType(object, 'hasOwnProperty') ? object.hasOwnProperty : isProperty; + for (property in object) { + // Gecko <= 1.0 enumerates the `prototype` property of functions under + // certain conditions; IE does not. + if (!(isFunction && property == "prototype") && hasProperty.call(object, property)) { + callback(property); + } + } + // Manually invoke the callback for each non-enumerable property. + for (length = members.length; property = members[--length]; hasProperty.call(object, property) && callback(property)); + }; + } else if (size == 2) { + // Safari <= 2.0.4 enumerates shadowed properties twice. + forEach = function (object, callback) { + // Create a set of iterated properties. + var members = {}, isFunction = getClass.call(object) == functionClass, property; + for (property in object) { + // Store each property name to prevent double enumeration. The + // `prototype` property of functions is not enumerated due to cross- + // environment inconsistencies. + if (!(isFunction && property == "prototype") && !isProperty.call(members, property) && (members[property] = 1) && isProperty.call(object, property)) { + callback(property); + } + } + }; + } else { + // No bugs detected; use the standard `for...in` algorithm. + forEach = function (object, callback) { + var isFunction = getClass.call(object) == functionClass, property, isConstructor; + for (property in object) { + if (!(isFunction && property == "prototype") && isProperty.call(object, property) && !(isConstructor = property === "constructor")) { + callback(property); + } + } + // Manually invoke the callback for the `constructor` property due to + // cross-environment inconsistencies. + if (isConstructor || isProperty.call(object, (property = "constructor"))) { + callback(property); + } + }; + } + return forEach(object, callback); + }; + + // Public: Serializes a JavaScript `value` as a JSON string. The optional + // `filter` argument may specify either a function that alters how object and + // array members are serialized, or an array of strings and numbers that + // indicates which properties should be serialized. The optional `width` + // argument may be either a string or number that specifies the indentation + // level of the output. + if (!has("json-stringify")) { + // Internal: A map of control characters and their escaped equivalents. + var Escapes = { + 92: "\\\\", + 34: '\\"', + 8: "\\b", + 12: "\\f", + 10: "\\n", + 13: "\\r", + 9: "\\t" + }; + + // Internal: Converts `value` into a zero-padded string such that its + // length is at least equal to `width`. The `width` must be <= 6. + var leadingZeroes = "000000"; + var toPaddedString = function (width, value) { + // The `|| 0` expression is necessary to work around a bug in + // Opera <= 7.54u2 where `0 == -0`, but `String(-0) !== "0"`. + return (leadingZeroes + (value || 0)).slice(-width); + }; + + // Internal: Double-quotes a string `value`, replacing all ASCII control + // characters (characters with code unit values between 0 and 31) with + // their escaped equivalents. This is an implementation of the + // `Quote(value)` operation defined in ES 5.1 section 15.12.3. + var unicodePrefix = "\\u00"; + var quote = function (value) { + var result = '"', index = 0, length = value.length, isLarge = length > 10 && charIndexBuggy, symbols; + if (isLarge) { + symbols = value.split(""); + } + for (; index < length; index++) { + var charCode = value.charCodeAt(index); + // If the character is a control character, append its Unicode or + // shorthand escape sequence; otherwise, append the character as-is. + switch (charCode) { + case 8: case 9: case 10: case 12: case 13: case 34: case 92: + result += Escapes[charCode]; + break; + default: + if (charCode < 32) { + result += unicodePrefix + toPaddedString(2, charCode.toString(16)); + break; + } + result += isLarge ? symbols[index] : charIndexBuggy ? value.charAt(index) : value[index]; + } + } + return result + '"'; + }; + + // Internal: Recursively serializes an object. Implements the + // `Str(key, holder)`, `JO(value)`, and `JA(value)` operations. + var serialize = function (property, object, callback, properties, whitespace, indentation, stack) { + var value, className, year, month, date, time, hours, minutes, seconds, milliseconds, results, element, index, length, prefix, result; + try { + // Necessary for host object support. + value = object[property]; + } catch (exception) {} + if (typeof value == "object" && value) { + className = getClass.call(value); + if (className == dateClass && !isProperty.call(value, "toJSON")) { + if (value > -1 / 0 && value < 1 / 0) { + // Dates are serialized according to the `Date#toJSON` method + // specified in ES 5.1 section 15.9.5.44. See section 15.9.1.15 + // for the ISO 8601 date time string format. + if (getDay) { + // Manually compute the year, month, date, hours, minutes, + // seconds, and milliseconds if the `getUTC*` methods are + // buggy. Adapted from @Yaffle's `date-shim` project. + date = floor(value / 864e5); + for (year = floor(date / 365.2425) + 1970 - 1; getDay(year + 1, 0) <= date; year++); + for (month = floor((date - getDay(year, 0)) / 30.42); getDay(year, month + 1) <= date; month++); + date = 1 + date - getDay(year, month); + // The `time` value specifies the time within the day (see ES + // 5.1 section 15.9.1.2). The formula `(A % B + B) % B` is used + // to compute `A modulo B`, as the `%` operator does not + // correspond to the `modulo` operation for negative numbers. + time = (value % 864e5 + 864e5) % 864e5; + // The hours, minutes, seconds, and milliseconds are obtained by + // decomposing the time within the day. See section 15.9.1.10. + hours = floor(time / 36e5) % 24; + minutes = floor(time / 6e4) % 60; + seconds = floor(time / 1e3) % 60; + milliseconds = time % 1e3; + } else { + year = value.getUTCFullYear(); + month = value.getUTCMonth(); + date = value.getUTCDate(); + hours = value.getUTCHours(); + minutes = value.getUTCMinutes(); + seconds = value.getUTCSeconds(); + milliseconds = value.getUTCMilliseconds(); + } + // Serialize extended years correctly. + value = (year <= 0 || year >= 1e4 ? (year < 0 ? "-" : "+") + toPaddedString(6, year < 0 ? -year : year) : toPaddedString(4, year)) + + "-" + toPaddedString(2, month + 1) + "-" + toPaddedString(2, date) + + // Months, dates, hours, minutes, and seconds should have two + // digits; milliseconds should have three. + "T" + toPaddedString(2, hours) + ":" + toPaddedString(2, minutes) + ":" + toPaddedString(2, seconds) + + // Milliseconds are optional in ES 5.0, but required in 5.1. + "." + toPaddedString(3, milliseconds) + "Z"; + } else { + value = null; + } + } else if (typeof value.toJSON == "function" && ((className != numberClass && className != stringClass && className != arrayClass) || isProperty.call(value, "toJSON"))) { + // Prototype <= 1.6.1 adds non-standard `toJSON` methods to the + // `Number`, `String`, `Date`, and `Array` prototypes. JSON 3 + // ignores all `toJSON` methods on these objects unless they are + // defined directly on an instance. + value = value.toJSON(property); + } + } + if (callback) { + // If a replacement function was provided, call it to obtain the value + // for serialization. + value = callback.call(object, property, value); + } + if (value === null) { + return "null"; + } + className = getClass.call(value); + if (className == booleanClass) { + // Booleans are represented literally. + return "" + value; + } else if (className == numberClass) { + // JSON numbers must be finite. `Infinity` and `NaN` are serialized as + // `"null"`. + return value > -1 / 0 && value < 1 / 0 ? "" + value : "null"; + } else if (className == stringClass) { + // Strings are double-quoted and escaped. + return quote("" + value); + } + // Recursively serialize objects and arrays. + if (typeof value == "object") { + // Check for cyclic structures. This is a linear search; performance + // is inversely proportional to the number of unique nested objects. + for (length = stack.length; length--;) { + if (stack[length] === value) { + // Cyclic structures cannot be serialized by `JSON.stringify`. + throw TypeError(); + } + } + // Add the object to the stack of traversed objects. + stack.push(value); + results = []; + // Save the current indentation level and indent one additional level. + prefix = indentation; + indentation += whitespace; + if (className == arrayClass) { + // Recursively serialize array elements. + for (index = 0, length = value.length; index < length; index++) { + element = serialize(index, value, callback, properties, whitespace, indentation, stack); + results.push(element === undef ? "null" : element); + } + result = results.length ? (whitespace ? "[\n" + indentation + results.join(",\n" + indentation) + "\n" + prefix + "]" : ("[" + results.join(",") + "]")) : "[]"; + } else { + // Recursively serialize object members. Members are selected from + // either a user-specified list of property names, or the object + // itself. + forEach(properties || value, function (property) { + var element = serialize(property, value, callback, properties, whitespace, indentation, stack); + if (element !== undef) { + // According to ES 5.1 section 15.12.3: "If `gap` {whitespace} + // is not the empty string, let `member` {quote(property) + ":"} + // be the concatenation of `member` and the `space` character." + // The "`space` character" refers to the literal space + // character, not the `space` {width} argument provided to + // `JSON.stringify`. + results.push(quote(property) + ":" + (whitespace ? " " : "") + element); + } + }); + result = results.length ? (whitespace ? "{\n" + indentation + results.join(",\n" + indentation) + "\n" + prefix + "}" : ("{" + results.join(",") + "}")) : "{}"; + } + // Remove the object from the traversed object stack. + stack.pop(); + return result; + } + }; + + // Public: `JSON.stringify`. See ES 5.1 section 15.12.3. + JSON3.stringify = function (source, filter, width) { + var whitespace, callback, properties, className; + if (typeof filter == "function" || typeof filter == "object" && filter) { + if ((className = getClass.call(filter)) == functionClass) { + callback = filter; + } else if (className == arrayClass) { + // Convert the property names array into a makeshift set. + properties = {}; + for (var index = 0, length = filter.length, value; index < length; value = filter[index++], ((className = getClass.call(value)), className == stringClass || className == numberClass) && (properties[value] = 1)); + } + } + if (width) { + if ((className = getClass.call(width)) == numberClass) { + // Convert the `width` to an integer and create a string containing + // `width` number of space characters. + if ((width -= width % 1) > 0) { + for (whitespace = "", width > 10 && (width = 10); whitespace.length < width; whitespace += " "); + } + } else if (className == stringClass) { + whitespace = width.length <= 10 ? width : width.slice(0, 10); + } + } + // Opera <= 7.54u2 discards the values associated with empty string keys + // (`""`) only if they are used directly within an object member list + // (e.g., `!("" in { "": 1})`). + return serialize("", (value = {}, value[""] = source, value), callback, properties, whitespace, "", []); + }; + } + + // Public: Parses a JSON source string. + if (!has("json-parse")) { + var fromCharCode = String.fromCharCode; + + // Internal: A map of escaped control characters and their unescaped + // equivalents. + var Unescapes = { + 92: "\\", + 34: '"', + 47: "/", + 98: "\b", + 116: "\t", + 110: "\n", + 102: "\f", + 114: "\r" + }; + + // Internal: Stores the parser state. + var Index, Source; + + // Internal: Resets the parser state and throws a `SyntaxError`. + var abort = function() { + Index = Source = null; + throw SyntaxError(); + }; + + // Internal: Returns the next token, or `"$"` if the parser has reached + // the end of the source string. A token may be a string, number, `null` + // literal, or Boolean literal. + var lex = function () { + var source = Source, length = source.length, value, begin, position, isSigned, charCode; + while (Index < length) { + charCode = source.charCodeAt(Index); + switch (charCode) { + case 9: case 10: case 13: case 32: + // Skip whitespace tokens, including tabs, carriage returns, line + // feeds, and space characters. + Index++; + break; + case 123: case 125: case 91: case 93: case 58: case 44: + // Parse a punctuator token (`{`, `}`, `[`, `]`, `:`, or `,`) at + // the current position. + value = charIndexBuggy ? source.charAt(Index) : source[Index]; + Index++; + return value; + case 34: + // `"` delimits a JSON string; advance to the next character and + // begin parsing the string. String tokens are prefixed with the + // sentinel `@` character to distinguish them from punctuators and + // end-of-string tokens. + for (value = "@", Index++; Index < length;) { + charCode = source.charCodeAt(Index); + if (charCode < 32) { + // Unescaped ASCII control characters (those with a code unit + // less than the space character) are not permitted. + abort(); + } else if (charCode == 92) { + // A reverse solidus (`\`) marks the beginning of an escaped + // control character (including `"`, `\`, and `/`) or Unicode + // escape sequence. + charCode = source.charCodeAt(++Index); + switch (charCode) { + case 92: case 34: case 47: case 98: case 116: case 110: case 102: case 114: + // Revive escaped control characters. + value += Unescapes[charCode]; + Index++; + break; + case 117: + // `\u` marks the beginning of a Unicode escape sequence. + // Advance to the first character and validate the + // four-digit code point. + begin = ++Index; + for (position = Index + 4; Index < position; Index++) { + charCode = source.charCodeAt(Index); + // A valid sequence comprises four hexdigits (case- + // insensitive) that form a single hexadecimal value. + if (!(charCode >= 48 && charCode <= 57 || charCode >= 97 && charCode <= 102 || charCode >= 65 && charCode <= 70)) { + // Invalid Unicode escape sequence. + abort(); + } + } + // Revive the escaped character. + value += fromCharCode("0x" + source.slice(begin, Index)); + break; + default: + // Invalid escape sequence. + abort(); + } + } else { + if (charCode == 34) { + // An unescaped double-quote character marks the end of the + // string. + break; + } + charCode = source.charCodeAt(Index); + begin = Index; + // Optimize for the common case where a string is valid. + while (charCode >= 32 && charCode != 92 && charCode != 34) { + charCode = source.charCodeAt(++Index); + } + // Append the string as-is. + value += source.slice(begin, Index); + } + } + if (source.charCodeAt(Index) == 34) { + // Advance to the next character and return the revived string. + Index++; + return value; + } + // Unterminated string. + abort(); + default: + // Parse numbers and literals. + begin = Index; + // Advance past the negative sign, if one is specified. + if (charCode == 45) { + isSigned = true; + charCode = source.charCodeAt(++Index); + } + // Parse an integer or floating-point value. + if (charCode >= 48 && charCode <= 57) { + // Leading zeroes are interpreted as octal literals. + if (charCode == 48 && ((charCode = source.charCodeAt(Index + 1)), charCode >= 48 && charCode <= 57)) { + // Illegal octal literal. + abort(); + } + isSigned = false; + // Parse the integer component. + for (; Index < length && ((charCode = source.charCodeAt(Index)), charCode >= 48 && charCode <= 57); Index++); + // Floats cannot contain a leading decimal point; however, this + // case is already accounted for by the parser. + if (source.charCodeAt(Index) == 46) { + position = ++Index; + // Parse the decimal component. + for (; position < length && ((charCode = source.charCodeAt(position)), charCode >= 48 && charCode <= 57); position++); + if (position == Index) { + // Illegal trailing decimal. + abort(); + } + Index = position; + } + // Parse exponents. The `e` denoting the exponent is + // case-insensitive. + charCode = source.charCodeAt(Index); + if (charCode == 101 || charCode == 69) { + charCode = source.charCodeAt(++Index); + // Skip past the sign following the exponent, if one is + // specified. + if (charCode == 43 || charCode == 45) { + Index++; + } + // Parse the exponential component. + for (position = Index; position < length && ((charCode = source.charCodeAt(position)), charCode >= 48 && charCode <= 57); position++); + if (position == Index) { + // Illegal empty exponent. + abort(); + } + Index = position; + } + // Coerce the parsed value to a JavaScript number. + return +source.slice(begin, Index); + } + // A negative sign may only precede numbers. + if (isSigned) { + abort(); + } + // `true`, `false`, and `null` literals. + if (source.slice(Index, Index + 4) == "true") { + Index += 4; + return true; + } else if (source.slice(Index, Index + 5) == "false") { + Index += 5; + return false; + } else if (source.slice(Index, Index + 4) == "null") { + Index += 4; + return null; + } + // Unrecognized token. + abort(); + } + } + // Return the sentinel `$` character if the parser has reached the end + // of the source string. + return "$"; + }; + + // Internal: Parses a JSON `value` token. + var get = function (value) { + var results, hasMembers; + if (value == "$") { + // Unexpected end of input. + abort(); + } + if (typeof value == "string") { + if ((charIndexBuggy ? value.charAt(0) : value[0]) == "@") { + // Remove the sentinel `@` character. + return value.slice(1); + } + // Parse object and array literals. + if (value == "[") { + // Parses a JSON array, returning a new JavaScript array. + results = []; + for (;; hasMembers || (hasMembers = true)) { + value = lex(); + // A closing square bracket marks the end of the array literal. + if (value == "]") { + break; + } + // If the array literal contains elements, the current token + // should be a comma separating the previous element from the + // next. + if (hasMembers) { + if (value == ",") { + value = lex(); + if (value == "]") { + // Unexpected trailing `,` in array literal. + abort(); + } + } else { + // A `,` must separate each array element. + abort(); + } + } + // Elisions and leading commas are not permitted. + if (value == ",") { + abort(); + } + results.push(get(value)); + } + return results; + } else if (value == "{") { + // Parses a JSON object, returning a new JavaScript object. + results = {}; + for (;; hasMembers || (hasMembers = true)) { + value = lex(); + // A closing curly brace marks the end of the object literal. + if (value == "}") { + break; + } + // If the object literal contains members, the current token + // should be a comma separator. + if (hasMembers) { + if (value == ",") { + value = lex(); + if (value == "}") { + // Unexpected trailing `,` in object literal. + abort(); + } + } else { + // A `,` must separate each object member. + abort(); + } + } + // Leading commas are not permitted, object property names must be + // double-quoted strings, and a `:` must separate each property + // name and value. + if (value == "," || typeof value != "string" || (charIndexBuggy ? value.charAt(0) : value[0]) != "@" || lex() != ":") { + abort(); + } + results[value.slice(1)] = get(lex()); + } + return results; + } + // Unexpected token encountered. + abort(); + } + return value; + }; + + // Internal: Updates a traversed object member. + var update = function(source, property, callback) { + var element = walk(source, property, callback); + if (element === undef) { + delete source[property]; + } else { + source[property] = element; + } + }; + + // Internal: Recursively traverses a parsed JSON object, invoking the + // `callback` function for each value. This is an implementation of the + // `Walk(holder, name)` operation defined in ES 5.1 section 15.12.2. + var walk = function (source, property, callback) { + var value = source[property], length; + if (typeof value == "object" && value) { + // `forEach` can't be used to traverse an array in Opera <= 8.54 + // because its `Object#hasOwnProperty` implementation returns `false` + // for array indices (e.g., `![1, 2, 3].hasOwnProperty("0")`). + if (getClass.call(value) == arrayClass) { + for (length = value.length; length--;) { + update(value, length, callback); + } + } else { + forEach(value, function (property) { + update(value, property, callback); + }); + } + } + return callback.call(source, property, value); + }; + + // Public: `JSON.parse`. See ES 5.1 section 15.12.2. + JSON3.parse = function (source, callback) { + var result, value; + Index = 0; + Source = "" + source; + result = get(lex()); + // If a JSON string contains multiple tokens, it is invalid. + if (lex() != "$") { + abort(); + } + // Reset the parser state. + Index = Source = null; + return callback && getClass.call(callback) == functionClass ? walk((value = {}, value[""] = result, value), "", callback) : result; + }; + } + } + + // Export for asynchronous module loaders. + if (isLoader) { + define(function () { + return JSON3; + }); + } +}(this)); diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/lib/json3.min.js b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/lib/json3.min.js index cc8e94c1..f9a45cea 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/lib/json3.min.js +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/lib/json3.min.js @@ -1,18 +1,18 @@ -/*! JSON v3.2.6 | http://bestiejs.github.io/json3 | Copyright 2012-2013, Kit Cambridge | http://kit.mit-license.org */ -;(function(){var n=null; -(function(G){function m(a){if(m[a]!==s)return m[a];var c;if("bug-string-char-index"==a)c="a"!="a"[0];else if("json"==a)c=m("json-stringify")&&m("json-parse");else{var e;if("json-stringify"==a){c=o.stringify;var b="function"==typeof c&&l;if(b){(e=function(){return 1}).toJSON=e;try{b="0"===c(0)&&"0"===c(new Number)&&'""'==c(new String)&&c(p)===s&&c(s)===s&&c()===s&&"1"===c(e)&&"[1]"==c([e])&&"[null]"==c([s])&&"null"==c(n)&&"[null,null,null]"==c([s,p,n])&&'{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}'==c({a:[e, -!0,!1,n,"\x00\u0008\n\u000c\r\t"]})&&"1"===c(n,e)&&"[\n 1,\n 2\n]"==c([1,2],n,1)&&'"-271821-04-20T00:00:00.000Z"'==c(new Date(-864E13))&&'"+275760-09-13T00:00:00.000Z"'==c(new Date(864E13))&&'"-000001-01-01T00:00:00.000Z"'==c(new Date(-621987552E5))&&'"1969-12-31T23:59:59.999Z"'==c(new Date(-1))}catch(f){b=!1}}c=b}if("json-parse"==a){c=o.parse;if("function"==typeof c)try{if(0===c("0")&&!c(!1)){e=c('{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}');var j=5==e.a.length&&1===e.a[0];if(j){try{j=!c('"\t"')}catch(d){}if(j)try{j= -1!==c("01")}catch(h){}if(j)try{j=1!==c("1.")}catch(k){}}}}catch(N){j=!1}c=j}}return m[a]=!!c}var p={}.toString,q,x,s,H=typeof define==="function"&&define.amd,y="object"==typeof JSON&&JSON,o="object"==typeof exports&&exports&&!exports.nodeType&&exports;o&&y?(o.stringify=y.stringify,o.parse=y.parse):o=G.JSON=y||{};var l=new Date(-3509827334573292);try{l=-109252==l.getUTCFullYear()&&0===l.getUTCMonth()&&1===l.getUTCDate()&&10==l.getUTCHours()&&37==l.getUTCMinutes()&&6==l.getUTCSeconds()&&708==l.getUTCMilliseconds()}catch(O){}if(!m("json")){var t= -m("bug-string-char-index");if(!l)var u=Math.floor,I=[0,31,59,90,120,151,181,212,243,273,304,334],z=function(a,c){return I[c]+365*(a-1970)+u((a-1969+(c=+(c>1)))/4)-u((a-1901+c)/100)+u((a-1601+c)/400)};if(!(q={}.hasOwnProperty))q=function(a){var c={},e;if((c.__proto__=n,c.__proto__={toString:1},c).toString!=p)q=function(a){var c=this.__proto__,a=a in(this.__proto__=n,this);this.__proto__=c;return a};else{e=c.constructor;q=function(a){var c=(this.constructor||e).prototype;return a in this&&!(a in c&& -this[a]===c[a])}}c=n;return q.call(this,a)};var J={"boolean":1,number:1,string:1,undefined:1};x=function(a,c){var e=0,b,f,j;(b=function(){this.valueOf=0}).prototype.valueOf=0;f=new b;for(j in f)q.call(f,j)&&e++;b=f=n;if(e)x=e==2?function(a,c){var e={},b=p.call(a)=="[object Function]",f;for(f in a)!(b&&f=="prototype")&&!q.call(e,f)&&(e[f]=1)&&q.call(a,f)&&c(f)}:function(a,c){var e=p.call(a)=="[object Function]",b,f;for(b in a)!(e&&b=="prototype")&&q.call(a,b)&&!(f=b==="constructor")&&c(b);(f||q.call(a, -b="constructor"))&&c(b)};else{f=["valueOf","toString","toLocaleString","propertyIsEnumerable","isPrototypeOf","hasOwnProperty","constructor"];x=function(a,c){var e=p.call(a)=="[object Function]",b,g;if(g=!e)if(g=typeof a.constructor!="function"){g=typeof a.hasOwnProperty;g=g=="object"?!!a.hasOwnProperty:!J[g]}g=g?a.hasOwnProperty:q;for(b in a)!(e&&b=="prototype")&&g.call(a,b)&&c(b);for(e=f.length;b=f[--e];g.call(a,b)&&c(b));}}return x(a,c)};if(!m("json-stringify")){var K={92:"\\\\",34:'\\"',8:"\\b", -12:"\\f",10:"\\n",13:"\\r",9:"\\t"},v=function(a,c){return("000000"+(c||0)).slice(-a)},D=function(a){var c='"',b=0,g=a.length,f=g>10&&t,j;for(f&&(j=a.split(""));b-1/0&&h<1/0){if(z){l=u(h/864E5);for(k=u(l/365.2425)+1970-1;z(k+1,0)<=l;k++);for(i=u((l-z(k,0))/30.42);z(k,i+1)<=l;i++);l=1+l-z(k,i);m=(h%864E5+864E5)%864E5;o=u(m/36E5)%24;r=u(m/6E4)%60;t=u(m/1E3)%60;m=m%1E3}else{k=h.getUTCFullYear();i=h.getUTCMonth();l=h.getUTCDate();o=h.getUTCHours();r=h.getUTCMinutes();t=h.getUTCSeconds();m=h.getUTCMilliseconds()}h=(k<=0||k>=1E4?(k<0?"-":"+")+v(6,k<0?-k:k):v(4,k))+"-"+v(2,i+1)+"-"+v(2,l)+"T"+v(2,o)+":"+v(2,r)+":"+v(2,t)+"."+v(3,m)+"Z"}else h= -n;else if(typeof h.toJSON=="function"&&(k!="[object Number]"&&k!="[object String]"&&k!="[object Array]"||q.call(h,"toJSON")))h=h.toJSON(a)}b&&(h=b.call(c,a,h));if(h===n)return"null";k=p.call(h);if(k=="[object Boolean]")return""+h;if(k=="[object Number]")return h>-1/0&&h<1/0?""+h:"null";if(k=="[object String]")return D(""+h);if(typeof h=="object"){for(a=d.length;a--;)if(d[a]===h)throw TypeError();d.push(h);w=[];c=j;j=j+f;if(k=="[object Array]"){i=0;for(a=h.length;i0){g="";for(b>10&&(b=10);g.length=48&&d<=57||d>=97&&d<=102||d>=65&&d<=70||i()}e=e+L("0x"+a.slice(g,b));break;default:i()}}else{if(d==34)break;d=a.charCodeAt(b);for(g=b;d>=32&&d!=92&&d!=34;)d=a.charCodeAt(++b); -e=e+a.slice(g,b)}}if(a.charCodeAt(b)==34){b++;return e}i();default:g=b;if(d==45){j=true;d=a.charCodeAt(++b)}if(d>=48&&d<=57){for(d==48&&(d=a.charCodeAt(b+1),d>=48&&d<=57)&&i();b=48&&d<=57);b++);if(a.charCodeAt(b)==46){for(f=++b;f=48&&d<=57);f++);f==b&&i();b=f}d=a.charCodeAt(b);if(d==101||d==69){d=a.charCodeAt(++b);(d==43||d==45)&&b++;for(f=b;f=48&&d<=57);f++);f==b&&i();b=f}return+a.slice(g,b)}j&&i();if(a.slice(b,b+4)=="true"){b= -b+4;return true}if(a.slice(b,b+5)=="false"){b=b+5;return false}if(a.slice(b,b+4)=="null"){b=b+4;return n}i()}}return"$"},C=function(a){var c,b;a=="$"&&i();if(typeof a=="string"){if((t?a.charAt(0):a[0])=="@")return a.slice(1);if(a=="["){for(c=[];;b||(b=true)){a=r();if(a=="]")break;if(b)if(a==","){a=r();a=="]"&&i()}else i();a==","&&i();c.push(C(a))}return c}if(a=="{"){for(c={};;b||(b=true)){a=r();if(a=="}")break;if(b)if(a==","){a=r();a=="}"&&i()}else i();(a==","||typeof a!="string"||(t?a.charAt(0): -a[0])!="@"||r()!=":")&&i();c[a.slice(1)]=C(r())}return c}i()}return a},F=function(a,b,e){e=E(a,b,e);e===s?delete a[b]:a[b]=e},E=function(a,b,e){var g=a[b],f;if(typeof g=="object"&&g)if(p.call(g)=="[object Array]")for(f=g.length;f--;)F(g,f,e);else x(g,function(a){F(g,a,e)});return e.call(a,b,g)};o.parse=function(a,c){var e,g;b=0;A=""+a;e=C(r());r()!="$"&&i();b=A=n;return c&&p.call(c)=="[object Function]"?E((g={},g[""]=e,g),"",c):e}}}H&&define(function(){return o})})(this); +/*! JSON v3.2.6 | http://bestiejs.github.io/json3 | Copyright 2012-2013, Kit Cambridge | http://kit.mit-license.org */ +;(function(){var n=null; +(function(G){function m(a){if(m[a]!==s)return m[a];var c;if("bug-string-char-index"==a)c="a"!="a"[0];else if("json"==a)c=m("json-stringify")&&m("json-parse");else{var e;if("json-stringify"==a){c=o.stringify;var b="function"==typeof c&&l;if(b){(e=function(){return 1}).toJSON=e;try{b="0"===c(0)&&"0"===c(new Number)&&'""'==c(new String)&&c(p)===s&&c(s)===s&&c()===s&&"1"===c(e)&&"[1]"==c([e])&&"[null]"==c([s])&&"null"==c(n)&&"[null,null,null]"==c([s,p,n])&&'{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}'==c({a:[e, +!0,!1,n,"\x00\u0008\n\u000c\r\t"]})&&"1"===c(n,e)&&"[\n 1,\n 2\n]"==c([1,2],n,1)&&'"-271821-04-20T00:00:00.000Z"'==c(new Date(-864E13))&&'"+275760-09-13T00:00:00.000Z"'==c(new Date(864E13))&&'"-000001-01-01T00:00:00.000Z"'==c(new Date(-621987552E5))&&'"1969-12-31T23:59:59.999Z"'==c(new Date(-1))}catch(f){b=!1}}c=b}if("json-parse"==a){c=o.parse;if("function"==typeof c)try{if(0===c("0")&&!c(!1)){e=c('{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}');var j=5==e.a.length&&1===e.a[0];if(j){try{j=!c('"\t"')}catch(d){}if(j)try{j= +1!==c("01")}catch(h){}if(j)try{j=1!==c("1.")}catch(k){}}}}catch(N){j=!1}c=j}}return m[a]=!!c}var p={}.toString,q,x,s,H=typeof define==="function"&&define.amd,y="object"==typeof JSON&&JSON,o="object"==typeof exports&&exports&&!exports.nodeType&&exports;o&&y?(o.stringify=y.stringify,o.parse=y.parse):o=G.JSON=y||{};var l=new Date(-3509827334573292);try{l=-109252==l.getUTCFullYear()&&0===l.getUTCMonth()&&1===l.getUTCDate()&&10==l.getUTCHours()&&37==l.getUTCMinutes()&&6==l.getUTCSeconds()&&708==l.getUTCMilliseconds()}catch(O){}if(!m("json")){var t= +m("bug-string-char-index");if(!l)var u=Math.floor,I=[0,31,59,90,120,151,181,212,243,273,304,334],z=function(a,c){return I[c]+365*(a-1970)+u((a-1969+(c=+(c>1)))/4)-u((a-1901+c)/100)+u((a-1601+c)/400)};if(!(q={}.hasOwnProperty))q=function(a){var c={},e;if((c.__proto__=n,c.__proto__={toString:1},c).toString!=p)q=function(a){var c=this.__proto__,a=a in(this.__proto__=n,this);this.__proto__=c;return a};else{e=c.constructor;q=function(a){var c=(this.constructor||e).prototype;return a in this&&!(a in c&& +this[a]===c[a])}}c=n;return q.call(this,a)};var J={"boolean":1,number:1,string:1,undefined:1};x=function(a,c){var e=0,b,f,j;(b=function(){this.valueOf=0}).prototype.valueOf=0;f=new b;for(j in f)q.call(f,j)&&e++;b=f=n;if(e)x=e==2?function(a,c){var e={},b=p.call(a)=="[object Function]",f;for(f in a)!(b&&f=="prototype")&&!q.call(e,f)&&(e[f]=1)&&q.call(a,f)&&c(f)}:function(a,c){var e=p.call(a)=="[object Function]",b,f;for(b in a)!(e&&b=="prototype")&&q.call(a,b)&&!(f=b==="constructor")&&c(b);(f||q.call(a, +b="constructor"))&&c(b)};else{f=["valueOf","toString","toLocaleString","propertyIsEnumerable","isPrototypeOf","hasOwnProperty","constructor"];x=function(a,c){var e=p.call(a)=="[object Function]",b,g;if(g=!e)if(g=typeof a.constructor!="function"){g=typeof a.hasOwnProperty;g=g=="object"?!!a.hasOwnProperty:!J[g]}g=g?a.hasOwnProperty:q;for(b in a)!(e&&b=="prototype")&&g.call(a,b)&&c(b);for(e=f.length;b=f[--e];g.call(a,b)&&c(b));}}return x(a,c)};if(!m("json-stringify")){var K={92:"\\\\",34:'\\"',8:"\\b", +12:"\\f",10:"\\n",13:"\\r",9:"\\t"},v=function(a,c){return("000000"+(c||0)).slice(-a)},D=function(a){var c='"',b=0,g=a.length,f=g>10&&t,j;for(f&&(j=a.split(""));b-1/0&&h<1/0){if(z){l=u(h/864E5);for(k=u(l/365.2425)+1970-1;z(k+1,0)<=l;k++);for(i=u((l-z(k,0))/30.42);z(k,i+1)<=l;i++);l=1+l-z(k,i);m=(h%864E5+864E5)%864E5;o=u(m/36E5)%24;r=u(m/6E4)%60;t=u(m/1E3)%60;m=m%1E3}else{k=h.getUTCFullYear();i=h.getUTCMonth();l=h.getUTCDate();o=h.getUTCHours();r=h.getUTCMinutes();t=h.getUTCSeconds();m=h.getUTCMilliseconds()}h=(k<=0||k>=1E4?(k<0?"-":"+")+v(6,k<0?-k:k):v(4,k))+"-"+v(2,i+1)+"-"+v(2,l)+"T"+v(2,o)+":"+v(2,r)+":"+v(2,t)+"."+v(3,m)+"Z"}else h= +n;else if(typeof h.toJSON=="function"&&(k!="[object Number]"&&k!="[object String]"&&k!="[object Array]"||q.call(h,"toJSON")))h=h.toJSON(a)}b&&(h=b.call(c,a,h));if(h===n)return"null";k=p.call(h);if(k=="[object Boolean]")return""+h;if(k=="[object Number]")return h>-1/0&&h<1/0?""+h:"null";if(k=="[object String]")return D(""+h);if(typeof h=="object"){for(a=d.length;a--;)if(d[a]===h)throw TypeError();d.push(h);w=[];c=j;j=j+f;if(k=="[object Array]"){i=0;for(a=h.length;i0){g="";for(b>10&&(b=10);g.length=48&&d<=57||d>=97&&d<=102||d>=65&&d<=70||i()}e=e+L("0x"+a.slice(g,b));break;default:i()}}else{if(d==34)break;d=a.charCodeAt(b);for(g=b;d>=32&&d!=92&&d!=34;)d=a.charCodeAt(++b); +e=e+a.slice(g,b)}}if(a.charCodeAt(b)==34){b++;return e}i();default:g=b;if(d==45){j=true;d=a.charCodeAt(++b)}if(d>=48&&d<=57){for(d==48&&(d=a.charCodeAt(b+1),d>=48&&d<=57)&&i();b=48&&d<=57);b++);if(a.charCodeAt(b)==46){for(f=++b;f=48&&d<=57);f++);f==b&&i();b=f}d=a.charCodeAt(b);if(d==101||d==69){d=a.charCodeAt(++b);(d==43||d==45)&&b++;for(f=b;f=48&&d<=57);f++);f==b&&i();b=f}return+a.slice(g,b)}j&&i();if(a.slice(b,b+4)=="true"){b= +b+4;return true}if(a.slice(b,b+5)=="false"){b=b+5;return false}if(a.slice(b,b+4)=="null"){b=b+4;return n}i()}}return"$"},C=function(a){var c,b;a=="$"&&i();if(typeof a=="string"){if((t?a.charAt(0):a[0])=="@")return a.slice(1);if(a=="["){for(c=[];;b||(b=true)){a=r();if(a=="]")break;if(b)if(a==","){a=r();a=="]"&&i()}else i();a==","&&i();c.push(C(a))}return c}if(a=="{"){for(c={};;b||(b=true)){a=r();if(a=="}")break;if(b)if(a==","){a=r();a=="}"&&i()}else i();(a==","||typeof a!="string"||(t?a.charAt(0): +a[0])!="@"||r()!=":")&&i();c[a.slice(1)]=C(r())}return c}i()}return a},F=function(a,b,e){e=E(a,b,e);e===s?delete a[b]:a[b]=e},E=function(a,b,e){var g=a[b],f;if(typeof g=="object"&&g)if(p.call(g)=="[object Array]")for(f=g.length;f--;)F(g,f,e);else x(g,function(a){F(g,a,e)});return e.call(a,b,g)};o.parse=function(a,c){var e,g;b=0;A=""+a;e=C(r());r()!="$"&&i();b=A=n;return c&&p.call(c)=="[object Function]"?E((g={},g[""]=e,g),"",c):e}}}H&&define(function(){return o})})(this); }()); \ No newline at end of file diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/package.json b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/package.json index d216918c..66de7886 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/package.json +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/json3/package.json @@ -1,102 +1,102 @@ -{ - "name": "json3", - "version": "3.2.6", - "description": "A modern JSON implementation compatible with nearly all JavaScript platforms.", - "homepage": "http://bestiejs.github.io/json3", - "main": "./lib/json3", - "keywords": [ - "json", - "spec", - "ecma", - "es5", - "lexer", - "parser", - "stringify" - ], - "licenses": [ - { - "type": "MIT", - "url": "http://kit.mit-license.org/" - } - ], - "author": { - "name": "Kit Cambridge", - "email": "github@kitcambridge.be", - "url": "http://kitcambridge.be/" - }, - "maintainers": [ - { - "name": "kitcambridge", - "email": "kitcambridge@me.com" - } - ], - "contributors": [ - { - "name": "Mangled Deutz", - "email": "olivier@webitup.fr", - "url": "http://tech.roxee.tv/" - }, - { - "name": "Øyvind Sean Kinsey", - "email": "oyvind@kinsey.no", - "url": "http://fb.me/ok" - }, - { - "name": "Oskar Schöldström", - "email": "public@oxy.fi", - "url": "http://oxy.fi/" - }, - { - "name": "Benjamin Tan", - "email": "demoneaux@gmail.com", - "url": "http://d10.github.io/" - }, - { - "name": "Kiryl Yermakou", - "email": "rma4ok@gmail.com", - "url": "https://github.com/rma4ok" - } - ], - "bugs": { - "url": "https://github.com/bestiejs/json3/issues" - }, - "scripts": { - "test": "node test/test_*.js" - }, - "repository": { - "type": "git", - "url": "git://github.com/bestiejs/json3.git" - }, - "jam": { - "main": "./lib/json3.js" - }, - "volo": { - "type": "directory", - "ignore": [ - ".*", - "build.js", - "index.html", - "component.json", - "bower.json", - "benchmark", - "page", - "test", - "vendor" - ] - }, - "_id": "json3@3.2.6", - "dist": { - "shasum": "f6efc93c06a04de9aec53053df2559bb19e2038b", - "tarball": "https://registry.npmjs.org/json3/-/json3-3.2.6.tgz" - }, - "_from": "json3@3.2.6", - "_npmVersion": "1.3.8", - "_npmUser": { - "name": "kitcambridge", - "email": "github@kitcambridge.be" - }, - "directories": {}, - "_shasum": "f6efc93c06a04de9aec53053df2559bb19e2038b", - "_resolved": "https://registry.npmjs.org/json3/-/json3-3.2.6.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "json3", + "version": "3.2.6", + "description": "A modern JSON implementation compatible with nearly all JavaScript platforms.", + "homepage": "http://bestiejs.github.io/json3", + "main": "./lib/json3", + "keywords": [ + "json", + "spec", + "ecma", + "es5", + "lexer", + "parser", + "stringify" + ], + "licenses": [ + { + "type": "MIT", + "url": "http://kit.mit-license.org/" + } + ], + "author": { + "name": "Kit Cambridge", + "email": "github@kitcambridge.be", + "url": "http://kitcambridge.be/" + }, + "maintainers": [ + { + "name": "kitcambridge", + "email": "kitcambridge@me.com" + } + ], + "contributors": [ + { + "name": "Mangled Deutz", + "email": "olivier@webitup.fr", + "url": "http://tech.roxee.tv/" + }, + { + "name": "Øyvind Sean Kinsey", + "email": "oyvind@kinsey.no", + "url": "http://fb.me/ok" + }, + { + "name": "Oskar Schöldström", + "email": "public@oxy.fi", + "url": "http://oxy.fi/" + }, + { + "name": "Benjamin Tan", + "email": "demoneaux@gmail.com", + "url": "http://d10.github.io/" + }, + { + "name": "Kiryl Yermakou", + "email": "rma4ok@gmail.com", + "url": "https://github.com/rma4ok" + } + ], + "bugs": { + "url": "https://github.com/bestiejs/json3/issues" + }, + "scripts": { + "test": "node test/test_*.js" + }, + "repository": { + "type": "git", + "url": "git://github.com/bestiejs/json3.git" + }, + "jam": { + "main": "./lib/json3.js" + }, + "volo": { + "type": "directory", + "ignore": [ + ".*", + "build.js", + "index.html", + "component.json", + "bower.json", + "benchmark", + "page", + "test", + "vendor" + ] + }, + "_id": "json3@3.2.6", + "dist": { + "shasum": "f6efc93c06a04de9aec53053df2559bb19e2038b", + "tarball": "https://registry.npmjs.org/json3/-/json3-3.2.6.tgz" + }, + "_from": "json3@3.2.6", + "_npmVersion": "1.3.8", + "_npmUser": { + "name": "kitcambridge", + "email": "github@kitcambridge.be" + }, + "directories": {}, + "_shasum": "f6efc93c06a04de9aec53053df2559bb19e2038b", + "_resolved": "https://registry.npmjs.org/json3/-/json3-3.2.6.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/package.json b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/package.json index 1f638b9c..2ecc78e1 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/package.json +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/package.json @@ -1,51 +1,51 @@ -{ - "name": "socket.io-parser", - "version": "2.2.2", - "description": "socket.io protocol parser", - "repository": { - "type": "git", - "url": "git+https://github.com/Automattic/socket.io-parser.git" - }, - "dependencies": { - "debug": "0.7.4", - "json3": "3.2.6", - "component-emitter": "1.1.2", - "isarray": "0.0.1", - "benchmark": "1.0.0" - }, - "devDependencies": { - "mocha": "1.16.2", - "expect.js": "0.2.0", - "zuul": "1.6.3" - }, - "scripts": { - "test": "make test" - }, - "license": "MIT", - "gitHead": "83c68c7a715ac54e95c5dae6445f751b3a4dfe9f", - "bugs": { - "url": "https://github.com/Automattic/socket.io-parser/issues" - }, - "homepage": "https://github.com/Automattic/socket.io-parser", - "_id": "socket.io-parser@2.2.2", - "_shasum": "3d7af6b64497e956b7d9fe775f999716027f9417", - "_from": "socket.io-parser@2.2.2", - "_npmVersion": "1.4.25", - "_npmUser": { - "name": "rauchg", - "email": "rauchg@gmail.com" - }, - "maintainers": [ - { - "name": "rauchg", - "email": "rauchg@gmail.com" - } - ], - "dist": { - "shasum": "3d7af6b64497e956b7d9fe775f999716027f9417", - "tarball": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-2.2.2.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-2.2.2.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "socket.io-parser", + "version": "2.2.2", + "description": "socket.io protocol parser", + "repository": { + "type": "git", + "url": "git+https://github.com/Automattic/socket.io-parser.git" + }, + "dependencies": { + "debug": "0.7.4", + "json3": "3.2.6", + "component-emitter": "1.1.2", + "isarray": "0.0.1", + "benchmark": "1.0.0" + }, + "devDependencies": { + "mocha": "1.16.2", + "expect.js": "0.2.0", + "zuul": "1.6.3" + }, + "scripts": { + "test": "make test" + }, + "license": "MIT", + "gitHead": "83c68c7a715ac54e95c5dae6445f751b3a4dfe9f", + "bugs": { + "url": "https://github.com/Automattic/socket.io-parser/issues" + }, + "homepage": "https://github.com/Automattic/socket.io-parser", + "_id": "socket.io-parser@2.2.2", + "_shasum": "3d7af6b64497e956b7d9fe775f999716027f9417", + "_from": "socket.io-parser@2.2.2", + "_npmVersion": "1.4.25", + "_npmUser": { + "name": "rauchg", + "email": "rauchg@gmail.com" + }, + "maintainers": [ + { + "name": "rauchg", + "email": "rauchg@gmail.com" + } + ], + "dist": { + "shasum": "3d7af6b64497e956b7d9fe775f999716027f9417", + "tarball": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-2.2.2.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-2.2.2.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/socket.io/node_modules/socket.io-adapter/package.json b/ui/node_modules/socket.io/node_modules/socket.io-adapter/package.json index ff249494..bd3dadce 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-adapter/package.json +++ b/ui/node_modules/socket.io/node_modules/socket.io-adapter/package.json @@ -1,41 +1,41 @@ -{ - "name": "socket.io-adapter", - "version": "0.4.0", - "license": "MIT", - "repository": { - "type": "git", - "url": "git://github.com/Automattic/socket.io-adapter.git" - }, - "description": "Default socket.io in-memory adapter class.", - "dependencies": { - "debug": "2.2.0", - "socket.io-parser": "2.2.2" - }, - "gitHead": "efd6141dbd6947761ee9ce91fa729f3bec0aaab0", - "bugs": { - "url": "https://github.com/Automattic/socket.io-adapter/issues" - }, - "homepage": "https://github.com/Automattic/socket.io-adapter#readme", - "_id": "socket.io-adapter@0.4.0", - "scripts": {}, - "_shasum": "fb9f82ab1aa65290bf72c3657955b930a991a24f", - "_from": "socket.io-adapter@0.4.0", - "_npmVersion": "3.4.1", - "_nodeVersion": "4.2.2", - "_npmUser": { - "name": "rauchg", - "email": "rauchg@gmail.com" - }, - "maintainers": [ - { - "name": "rauchg", - "email": "rauchg@gmail.com" - } - ], - "dist": { - "shasum": "fb9f82ab1aa65290bf72c3657955b930a991a24f", - "tarball": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-0.4.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-0.4.0.tgz" -} +{ + "name": "socket.io-adapter", + "version": "0.4.0", + "license": "MIT", + "repository": { + "type": "git", + "url": "git://github.com/Automattic/socket.io-adapter.git" + }, + "description": "Default socket.io in-memory adapter class.", + "dependencies": { + "debug": "2.2.0", + "socket.io-parser": "2.2.2" + }, + "gitHead": "efd6141dbd6947761ee9ce91fa729f3bec0aaab0", + "bugs": { + "url": "https://github.com/Automattic/socket.io-adapter/issues" + }, + "homepage": "https://github.com/Automattic/socket.io-adapter#readme", + "_id": "socket.io-adapter@0.4.0", + "scripts": {}, + "_shasum": "fb9f82ab1aa65290bf72c3657955b930a991a24f", + "_from": "socket.io-adapter@0.4.0", + "_npmVersion": "3.4.1", + "_nodeVersion": "4.2.2", + "_npmUser": { + "name": "rauchg", + "email": "rauchg@gmail.com" + }, + "maintainers": [ + { + "name": "rauchg", + "email": "rauchg@gmail.com" + } + ], + "dist": { + "shasum": "fb9f82ab1aa65290bf72c3657955b930a991a24f", + "tarball": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-0.4.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-0.4.0.tgz" +} diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/History.md b/ui/node_modules/socket.io/node_modules/socket.io-client/History.md index 69429dee..9ff030f1 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/History.md +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/History.md @@ -1,461 +1,461 @@ - -1.4.8 / 2016-06-23 -================== - - * package: bump `engine.io-client` - -1.4.7 / 2016-06-23 -================== - - * bump engine.io-client - -1.4.6 / 2016-05-02 -================== - - * bump engine.io-client - -1.4.5 / 2016-01-26 -================== - - * fix `NativeScript` support - -1.4.4 / 2016-01-10 -================== - - * bump `engine.io-client` - -1.4.3 / 2016-01-08 -================== - - * remove `webpack.config.js` - -1.4.2 / 2016-01-07 -================== - - * exclude `ws` instead of `ignore`ing it from build [@lpinca] - * add global object as another fallback [@ligaz] - * bump `engine.io-client` - -1.4.1 / 2016-01-07 -================== - - * package: bump `engine.io-client` - -1.4.0 / 2015-11-28 -================== - - * package: bump `engine.io-client` - * manager: fix `Object.prototype` extensions - * package: bump `zuul` and `zuul-ngrok` - * package: bump `debug` - * package: bump `socket.io-parser` - * package: bump `has-binary` - * remove unnecessary `index.js` - * added support for `ping` and `pong` events - * proper handling of disconnection while in `opening` state - * instrumentation / style tweaks - * added tests for same-namespace new connection handling - * do not call apply if packet id is not in acks - * build sio client with make to autogenerate new socket.io.js - * bugfix/1956 don't reuse same-namespace connections #2 - * fix has-binary to work with all objects [gunta] - * bugfix/1956 don't reuse same-namespace connections - * add support for compression [nkzawa] - * fix: location.port was ignored - -1.3.7 / 2015-09-21 -================== - - * package: bump `socket.io` for node4 support - * package: bump `engine.io-client` for node4 compatibility - -1.3.6 / 2015-07-14 -================== - - * package: bump `engine.io-client` to fix build on windows - -1.3.5 / 2015-03-03 -================== - - * package: bump parser - -1.3.4 / 2015-02-14 -================== - - * build `socket.io.js` with `engine.io-client` `1.5.1` - -1.3.3 / 2015-02-03 -================== - - * package: bump parser - -1.3.2 / 2015-01-19 -================== - - * build `socket.io.js` - -1.3.1 / 2015-01-19 -================== - - * no change on this release - * package: bump `engine.io-client` to not depend on `git(1)` for a dep - -1.3.0 / 2015-01-19 -================== - - * package: bump `engine.io-client` - * added `socket.id` property pointing to session id [rase-] - * fix url parsing when uri string is undefined [defunctzombie] - * implemented `backo` for exponential backoff with randomization [mokesmokes] - * reset reconnection attempts state after a successul connection [mokesmokes] - -1.2.1 / 2014-11-21 -================== - - * package: bump `engine.io-client` - * README: fixes to prevent duplicate events [nkzawa] - * fix reconnection after reconnecting manually [nkzawa] - * make ACK callbacks idempotent [thexeos] - * package: bump `uglify-js` - -1.2.0 / 2014-10-27 -================== - - * bump `engine.io-client`. - * set `readyState` before engine.io close event - * fix reconnection after reconnecting manually - * enable to stop reconnecting - * downloads badge - * support no schema relative url - * enable to reconnect manually - -1.1.0 / 2014-09-04 -================== - - * socket: fix in `has-binary` - * package: bump `socket.io-parser` - * package: bump `engine.io-client` - * further increase test timeout. - * double to singly quotes in tests. - * extend timeout and remember to close everything in each test case - * fix travis - * add travis + zuul matrix - * use svg instead of png to get better image quality in readme - * make CI build faster - * removed unnecessary code from try block. Only decode packet is needed. - * package: bump `browserify` - * package: bump `engine.io-client` - * fix autoConnect option - * npmignore: ignore `.gitignore` - * package: update `browserify` - * don't fire an extra reconnect when we're not reconnecting - after a failed initial connect attempt - * package: bump `socket.io-parser` for `component-emitter` dep fix - * updated tests to reflect `autoConnect` option - * add `autoConnect` option to wait with connecting - -1.0.6 / 2014-06-19 -================== - - * test fixes on internet explorer - * fixes for duplicate event propagation from manager instance [Rase-] - -1.0.5 / 2014-06-16 -================== - - * package: bump `engine.io-client` for better deps and smaller build - * handle io.connect(null, opts) correctly [audreyt] - * url: fix incorrect ports in certain connections [holic] - * manager: propagate all reconnection events to sockets [Rase-] - * index: added BC for `force new connection` - * socket: fix event buffering while in disconnected state [kevin-roark] - * package: stop using tarballs in dependencies [reid] - * manager: relay `connect_error` and `connect_timeout` to sockets - -1.0.4 / 2014-06-02 -================== - - * update build - -1.0.3 / 2014-05-31 -================== - - * package; bump `socket.io-parser` for binary ACK fix - * package: bump `engine.io-client` for binary UTF8 fix - -1.0.2 / 2014-05-28 -================== - - * package: bump `socket.io-parser` for windows fix - -1.0.1 / 2014-05-28 -================== - - * override npm tag - -1.0.0 / 2014-05-28 -================== - - * stable release - -1.0.0-pre5 / 2014-05-22 -======================= - - * package: bump `engine.io-client` for parser fixes - -1.0.0-pre4 / 2014-05-19 -======================= - - * build - -1.0.0-pre3 / 2014-05-17 -======================= - - * package: bump parser - * package: bump engine.io-client - -1.0.0-pre2 / 2014-04-27 -======================= - - * package: bump `engine.io-client` - * package: bump `zuul` - * allows user-level query string parameters to be in socket.request - * package: bump `socket.io-parser` - * package: bump `engine.io-client` for android fix - * tidy up .gitignore - -1.0.0-pre / 2014-03-14 -====================== - - * implemented `engine.io-client` - * implemented `socket.io-parser` - * implemented `json3` to avoid env pollution - * implemented `debug` - * added binary support - * added `browserify` support - -0.9.11 / 2012-11-02 -=================== - - * Enable use of 'xhr' transport in Node.js - * Fix the problem with disconnecting xhr-polling users - * Add should to devDependencies - * Prefer XmlHttpRequest if CORS is available - * Make client compatible with AMD loaders. - -0.9.10 / 2012-08-10 -=================== - - * fix removeAllListeners to behave as expected. - * set withCredentials to true only if xdomain. - * socket: disable disconnect on unload by default. - -0.9.9 / 2012-08-01 -================== - - * socket: fixed disconnect xhr url and made it actually sync - * *: bump xmlhttprequest dep - -0.9.8 / 2012-07-24 -================== - - * Fixed build. - -0.9.7 / 2012-07-24 -================== - - * iOS websocket crash fix. - * Fixed potential `open` collision. - * Fixed disconnectSync. - -0.9.6 / 2012-04-17 -================== - - * Don't position the jsonp form off the screen (android fix). - -0.9.5 / 2012-04-05 -================== - - * Bumped version. - -0.9.4 / 2012-04-01 -================== - - * Fixes polling loop upon reconnect advice (fixes #438). - -0.9.3 / 2012-03-28 -================== - - * Fix XHR.check, which was throwing an error transparently and causing non-IE browsers to fall back to JSONP [mikito] - * Fixed forced disconnect on window close [zzzaaa] - -0.9.2 / 2012-03-13 -================== - - * Transport order set by "options" [zzzaaa] - -0.9.1-1 / 2012-03-02 -==================== - - * Fixed active-x-obfuscator NPM dependency. - -0.9.1 / 2012-03-02 -================== - - * Misc corrections. - * Added warning within Firefox about webworker test in test runner. - * Update ws dependency [einaros] - * Implemented client side heartbeat checks. [felixge] - * Improved Firewall support with ActiveX obfuscation. [felixge] - * Fixed error handling during connection process. [Outsideris] - -0.9.0 / 2012-02-26 -================== - - * Added DS_Store to gitignore. - * Updated depedencies. - * Bumped uglify - * Tweaking code so it doesn't throw an exception when used inside a WebWorker in Firefox - * Do not rely on Array.prototype.indexOf as it breaks with pages that use the Prototype.js library. - * Windows support landed - * Use @einaros ws module instead of the old crap one - * Fix for broken closeTimeout and 'IE + xhr' goes into infinite loop on disconnection - * Disabled reconnection on error if reconnect option is set to false - * Set withCredentials to true before xhr to fix authentication - * Clears the timeout from reconnection attempt when there is a successful or failed reconnection. - This fixes the issue of setTimeout's carrying over from previous reconnection - and changing (skipping) values of self.reconnectionDelay in the newer reconnection. - * Removed decoding of parameters when chunking the query string. - This was used later on to construct the url to post to the socket.io server - for connection and if we're adding custom parameters of our own to this url - (for example for OAuth authentication) they were being sent decoded, which is wrong. - -0.8.7 / 2011-11-05 -================== - - * Bumped client - -0.8.6 / 2011-10-27 -================== - - * Added WebWorker support. - * Fixed swfobject and web_socket.js to not assume window. - * Fixed CORS detection for webworker. - * Fix `defer` for webkit in a webworker. - * Fixed io.util.request to not rely on window. - * FIxed; use global instead of window and dont rely on document. - * Fixed; JSON-P handshake if CORS is not available. - * Made underlying Transport disconnection trigger immediate socket.io disconnect. - * Fixed warning when compressing with Google Closure Compiler. - * Fixed builder's uglify utf-8 support. - * Added workaround for loading indicator in FF jsonp-polling. [3rd-Eden] - * Fixed host discovery lookup. [holic] - * Fixed close timeout when disconnected/reconnecting. [jscharlach] - * Fixed jsonp-polling feature detection. - * Fixed jsonp-polling client POSTing of \n. - * Fixed test runner on IE6/7 - -0.8.5 / 2011-10-07 -================== - - * Bumped client - -0.8.4 / 2011-09-06 -================== - - * Corrected build - -0.8.3 / 2011-09-03 -================== - - * Fixed `\n` parsing for non-JSON packets. - * Fixed; make Socket.IO XHTML doctype compatible (fixes #460 from server) - * Fixed support for Node.JS running `socket.io-client`. - * Updated repository name in `package.json`. - * Added support for different policy file ports without having to port - forward 843 on the server side [3rd-Eden] - -0.8.2 / 2011-08-29 -================== - - * Fixed flashsocket detection. - -0.8.1 / 2011-08-29 -================== - - * Bump version. - -0.8.0 / 2011-08-28 -================== - - * Added MozWebSocket support (hybi-10 doesn't require API changes) [einaros]. - -0.7.11 / 2011-08-27 -=================== - - * Corrected previous release (missing build). - -0.7.10 / 2011-08-27 -=================== - - * Fix for failing fallback in websockets - -0.7.9 / 2011-08-12 -================== - - * Added check on `Socket#onConnect` to prevent double `connect` events on the main manager. - * Fixed socket namespace connect test. Remove broken alternative namespace connect test. - * Removed test handler for removed test. - * Bumped version to match `socket.io` server. - -0.7.5 / 2011-08-08 -================== - - * Added querystring support for `connect` [3rd-Eden] - * Added partial Node.JS transports support [3rd-Eden, josephg] - * Fixed builder test. - * Changed `util.inherit` to replicate Object.create / __proto__. - * Changed and cleaned up some acceptance tests. - * Fixed race condition with a test that could not be run multiple times. - * Added test for encoding a payload. - * Added the ability to override the transport to use in acceptance test [3rd-Eden] - * Fixed multiple connect packets [DanielBaulig] - * Fixed jsonp-polling over-buffering [3rd-Eden] - * Fixed ascii preservation in minified socket.io client [3rd-Eden] - * Fixed socket.io in situations where the page is not served through utf8. - * Fixed namespaces not reconnecting after disconnect [3rd-Eden] - * Fixed default port for secure connections. - -0.7.4 / 2011-07-12 -================== - - * Added `SocketNamespace#of` shortcut. [3rd-Eden] - * Fixed a IE payload decoding bug. [3rd-Eden] - * Honor document protocol, unless overriden. [dvv] - * Fixed new builder dependencies. [3rd-Eden] - -0.7.3 / 2011-06-30 -================== - - * Fixed; acks don't depend on arity. They're automatic for `.send` and - callback based for `.emit`. [dvv] - * Added support for sub-sockets authorization. [3rd-Eden] - * Added BC support for `new io.connect`. [fat] - * Fixed double `connect` events. [3rd-Eden] - * Fixed reconnection with jsonp-polling maintaining old sessionid. [franck34] - -0.7.2 / 2011-06-22 -================== - - * Added `noop` message type. - -0.7.1 / 2011-06-21 -================== - - * Bumped socket.io dependency version for acceptance tests. - -0.7.0 / 2011-06-21 -================== - - * http://socket.io/announcement.html - + +1.4.8 / 2016-06-23 +================== + + * package: bump `engine.io-client` + +1.4.7 / 2016-06-23 +================== + + * bump engine.io-client + +1.4.6 / 2016-05-02 +================== + + * bump engine.io-client + +1.4.5 / 2016-01-26 +================== + + * fix `NativeScript` support + +1.4.4 / 2016-01-10 +================== + + * bump `engine.io-client` + +1.4.3 / 2016-01-08 +================== + + * remove `webpack.config.js` + +1.4.2 / 2016-01-07 +================== + + * exclude `ws` instead of `ignore`ing it from build [@lpinca] + * add global object as another fallback [@ligaz] + * bump `engine.io-client` + +1.4.1 / 2016-01-07 +================== + + * package: bump `engine.io-client` + +1.4.0 / 2015-11-28 +================== + + * package: bump `engine.io-client` + * manager: fix `Object.prototype` extensions + * package: bump `zuul` and `zuul-ngrok` + * package: bump `debug` + * package: bump `socket.io-parser` + * package: bump `has-binary` + * remove unnecessary `index.js` + * added support for `ping` and `pong` events + * proper handling of disconnection while in `opening` state + * instrumentation / style tweaks + * added tests for same-namespace new connection handling + * do not call apply if packet id is not in acks + * build sio client with make to autogenerate new socket.io.js + * bugfix/1956 don't reuse same-namespace connections #2 + * fix has-binary to work with all objects [gunta] + * bugfix/1956 don't reuse same-namespace connections + * add support for compression [nkzawa] + * fix: location.port was ignored + +1.3.7 / 2015-09-21 +================== + + * package: bump `socket.io` for node4 support + * package: bump `engine.io-client` for node4 compatibility + +1.3.6 / 2015-07-14 +================== + + * package: bump `engine.io-client` to fix build on windows + +1.3.5 / 2015-03-03 +================== + + * package: bump parser + +1.3.4 / 2015-02-14 +================== + + * build `socket.io.js` with `engine.io-client` `1.5.1` + +1.3.3 / 2015-02-03 +================== + + * package: bump parser + +1.3.2 / 2015-01-19 +================== + + * build `socket.io.js` + +1.3.1 / 2015-01-19 +================== + + * no change on this release + * package: bump `engine.io-client` to not depend on `git(1)` for a dep + +1.3.0 / 2015-01-19 +================== + + * package: bump `engine.io-client` + * added `socket.id` property pointing to session id [rase-] + * fix url parsing when uri string is undefined [defunctzombie] + * implemented `backo` for exponential backoff with randomization [mokesmokes] + * reset reconnection attempts state after a successul connection [mokesmokes] + +1.2.1 / 2014-11-21 +================== + + * package: bump `engine.io-client` + * README: fixes to prevent duplicate events [nkzawa] + * fix reconnection after reconnecting manually [nkzawa] + * make ACK callbacks idempotent [thexeos] + * package: bump `uglify-js` + +1.2.0 / 2014-10-27 +================== + + * bump `engine.io-client`. + * set `readyState` before engine.io close event + * fix reconnection after reconnecting manually + * enable to stop reconnecting + * downloads badge + * support no schema relative url + * enable to reconnect manually + +1.1.0 / 2014-09-04 +================== + + * socket: fix in `has-binary` + * package: bump `socket.io-parser` + * package: bump `engine.io-client` + * further increase test timeout. + * double to singly quotes in tests. + * extend timeout and remember to close everything in each test case + * fix travis + * add travis + zuul matrix + * use svg instead of png to get better image quality in readme + * make CI build faster + * removed unnecessary code from try block. Only decode packet is needed. + * package: bump `browserify` + * package: bump `engine.io-client` + * fix autoConnect option + * npmignore: ignore `.gitignore` + * package: update `browserify` + * don't fire an extra reconnect when we're not reconnecting + after a failed initial connect attempt + * package: bump `socket.io-parser` for `component-emitter` dep fix + * updated tests to reflect `autoConnect` option + * add `autoConnect` option to wait with connecting + +1.0.6 / 2014-06-19 +================== + + * test fixes on internet explorer + * fixes for duplicate event propagation from manager instance [Rase-] + +1.0.5 / 2014-06-16 +================== + + * package: bump `engine.io-client` for better deps and smaller build + * handle io.connect(null, opts) correctly [audreyt] + * url: fix incorrect ports in certain connections [holic] + * manager: propagate all reconnection events to sockets [Rase-] + * index: added BC for `force new connection` + * socket: fix event buffering while in disconnected state [kevin-roark] + * package: stop using tarballs in dependencies [reid] + * manager: relay `connect_error` and `connect_timeout` to sockets + +1.0.4 / 2014-06-02 +================== + + * update build + +1.0.3 / 2014-05-31 +================== + + * package; bump `socket.io-parser` for binary ACK fix + * package: bump `engine.io-client` for binary UTF8 fix + +1.0.2 / 2014-05-28 +================== + + * package: bump `socket.io-parser` for windows fix + +1.0.1 / 2014-05-28 +================== + + * override npm tag + +1.0.0 / 2014-05-28 +================== + + * stable release + +1.0.0-pre5 / 2014-05-22 +======================= + + * package: bump `engine.io-client` for parser fixes + +1.0.0-pre4 / 2014-05-19 +======================= + + * build + +1.0.0-pre3 / 2014-05-17 +======================= + + * package: bump parser + * package: bump engine.io-client + +1.0.0-pre2 / 2014-04-27 +======================= + + * package: bump `engine.io-client` + * package: bump `zuul` + * allows user-level query string parameters to be in socket.request + * package: bump `socket.io-parser` + * package: bump `engine.io-client` for android fix + * tidy up .gitignore + +1.0.0-pre / 2014-03-14 +====================== + + * implemented `engine.io-client` + * implemented `socket.io-parser` + * implemented `json3` to avoid env pollution + * implemented `debug` + * added binary support + * added `browserify` support + +0.9.11 / 2012-11-02 +=================== + + * Enable use of 'xhr' transport in Node.js + * Fix the problem with disconnecting xhr-polling users + * Add should to devDependencies + * Prefer XmlHttpRequest if CORS is available + * Make client compatible with AMD loaders. + +0.9.10 / 2012-08-10 +=================== + + * fix removeAllListeners to behave as expected. + * set withCredentials to true only if xdomain. + * socket: disable disconnect on unload by default. + +0.9.9 / 2012-08-01 +================== + + * socket: fixed disconnect xhr url and made it actually sync + * *: bump xmlhttprequest dep + +0.9.8 / 2012-07-24 +================== + + * Fixed build. + +0.9.7 / 2012-07-24 +================== + + * iOS websocket crash fix. + * Fixed potential `open` collision. + * Fixed disconnectSync. + +0.9.6 / 2012-04-17 +================== + + * Don't position the jsonp form off the screen (android fix). + +0.9.5 / 2012-04-05 +================== + + * Bumped version. + +0.9.4 / 2012-04-01 +================== + + * Fixes polling loop upon reconnect advice (fixes #438). + +0.9.3 / 2012-03-28 +================== + + * Fix XHR.check, which was throwing an error transparently and causing non-IE browsers to fall back to JSONP [mikito] + * Fixed forced disconnect on window close [zzzaaa] + +0.9.2 / 2012-03-13 +================== + + * Transport order set by "options" [zzzaaa] + +0.9.1-1 / 2012-03-02 +==================== + + * Fixed active-x-obfuscator NPM dependency. + +0.9.1 / 2012-03-02 +================== + + * Misc corrections. + * Added warning within Firefox about webworker test in test runner. + * Update ws dependency [einaros] + * Implemented client side heartbeat checks. [felixge] + * Improved Firewall support with ActiveX obfuscation. [felixge] + * Fixed error handling during connection process. [Outsideris] + +0.9.0 / 2012-02-26 +================== + + * Added DS_Store to gitignore. + * Updated depedencies. + * Bumped uglify + * Tweaking code so it doesn't throw an exception when used inside a WebWorker in Firefox + * Do not rely on Array.prototype.indexOf as it breaks with pages that use the Prototype.js library. + * Windows support landed + * Use @einaros ws module instead of the old crap one + * Fix for broken closeTimeout and 'IE + xhr' goes into infinite loop on disconnection + * Disabled reconnection on error if reconnect option is set to false + * Set withCredentials to true before xhr to fix authentication + * Clears the timeout from reconnection attempt when there is a successful or failed reconnection. + This fixes the issue of setTimeout's carrying over from previous reconnection + and changing (skipping) values of self.reconnectionDelay in the newer reconnection. + * Removed decoding of parameters when chunking the query string. + This was used later on to construct the url to post to the socket.io server + for connection and if we're adding custom parameters of our own to this url + (for example for OAuth authentication) they were being sent decoded, which is wrong. + +0.8.7 / 2011-11-05 +================== + + * Bumped client + +0.8.6 / 2011-10-27 +================== + + * Added WebWorker support. + * Fixed swfobject and web_socket.js to not assume window. + * Fixed CORS detection for webworker. + * Fix `defer` for webkit in a webworker. + * Fixed io.util.request to not rely on window. + * FIxed; use global instead of window and dont rely on document. + * Fixed; JSON-P handshake if CORS is not available. + * Made underlying Transport disconnection trigger immediate socket.io disconnect. + * Fixed warning when compressing with Google Closure Compiler. + * Fixed builder's uglify utf-8 support. + * Added workaround for loading indicator in FF jsonp-polling. [3rd-Eden] + * Fixed host discovery lookup. [holic] + * Fixed close timeout when disconnected/reconnecting. [jscharlach] + * Fixed jsonp-polling feature detection. + * Fixed jsonp-polling client POSTing of \n. + * Fixed test runner on IE6/7 + +0.8.5 / 2011-10-07 +================== + + * Bumped client + +0.8.4 / 2011-09-06 +================== + + * Corrected build + +0.8.3 / 2011-09-03 +================== + + * Fixed `\n` parsing for non-JSON packets. + * Fixed; make Socket.IO XHTML doctype compatible (fixes #460 from server) + * Fixed support for Node.JS running `socket.io-client`. + * Updated repository name in `package.json`. + * Added support for different policy file ports without having to port + forward 843 on the server side [3rd-Eden] + +0.8.2 / 2011-08-29 +================== + + * Fixed flashsocket detection. + +0.8.1 / 2011-08-29 +================== + + * Bump version. + +0.8.0 / 2011-08-28 +================== + + * Added MozWebSocket support (hybi-10 doesn't require API changes) [einaros]. + +0.7.11 / 2011-08-27 +=================== + + * Corrected previous release (missing build). + +0.7.10 / 2011-08-27 +=================== + + * Fix for failing fallback in websockets + +0.7.9 / 2011-08-12 +================== + + * Added check on `Socket#onConnect` to prevent double `connect` events on the main manager. + * Fixed socket namespace connect test. Remove broken alternative namespace connect test. + * Removed test handler for removed test. + * Bumped version to match `socket.io` server. + +0.7.5 / 2011-08-08 +================== + + * Added querystring support for `connect` [3rd-Eden] + * Added partial Node.JS transports support [3rd-Eden, josephg] + * Fixed builder test. + * Changed `util.inherit` to replicate Object.create / __proto__. + * Changed and cleaned up some acceptance tests. + * Fixed race condition with a test that could not be run multiple times. + * Added test for encoding a payload. + * Added the ability to override the transport to use in acceptance test [3rd-Eden] + * Fixed multiple connect packets [DanielBaulig] + * Fixed jsonp-polling over-buffering [3rd-Eden] + * Fixed ascii preservation in minified socket.io client [3rd-Eden] + * Fixed socket.io in situations where the page is not served through utf8. + * Fixed namespaces not reconnecting after disconnect [3rd-Eden] + * Fixed default port for secure connections. + +0.7.4 / 2011-07-12 +================== + + * Added `SocketNamespace#of` shortcut. [3rd-Eden] + * Fixed a IE payload decoding bug. [3rd-Eden] + * Honor document protocol, unless overriden. [dvv] + * Fixed new builder dependencies. [3rd-Eden] + +0.7.3 / 2011-06-30 +================== + + * Fixed; acks don't depend on arity. They're automatic for `.send` and + callback based for `.emit`. [dvv] + * Added support for sub-sockets authorization. [3rd-Eden] + * Added BC support for `new io.connect`. [fat] + * Fixed double `connect` events. [3rd-Eden] + * Fixed reconnection with jsonp-polling maintaining old sessionid. [franck34] + +0.7.2 / 2011-06-22 +================== + + * Added `noop` message type. + +0.7.1 / 2011-06-21 +================== + + * Bumped socket.io dependency version for acceptance tests. + +0.7.0 / 2011-06-21 +================== + + * http://socket.io/announcement.html + diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/LICENSE b/ui/node_modules/socket.io/node_modules/socket.io-client/LICENSE index 1149bfb9..9338df18 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/LICENSE +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/LICENSE @@ -1,22 +1,22 @@ -The MIT License (MIT) - -Copyright (c) 2014 Guillermo Rauch - - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +The MIT License (MIT) + +Copyright (c) 2014 Guillermo Rauch + + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/README.md b/ui/node_modules/socket.io/node_modules/socket.io-client/README.md index 2d485ec2..3ad59942 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/README.md +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/README.md @@ -1,188 +1,188 @@ - -# socket.io-client - -[![Build Status](https://secure.travis-ci.org/socketio/socket.io-client.svg)](http://travis-ci.org/socketio/socket.io-client) -[![Dependency Status](https://david-dm.org/socketio/socket.io-client.svg)](https://david-dm.org/socketio/socket.io-client) -[![devDependency Status](https://david-dm.org/socketio/socket.io-client/dev-status.svg)](https://david-dm.org/socketio/socket.io-client#info=devDependencies) -![NPM version](https://badge.fury.io/js/socket.io-client.svg) -![Downloads](http://img.shields.io/npm/dm/socket.io-client.svg?style=flat) -[![](http://slack.socket.io/badge.svg?)](http://slack.socket.io) - -## How to use - -A standalone build of `socket.io-client` is exposed automatically by the -socket.io server as `/socket.io/socket.io.js`. Alternatively you can -serve the file `socket.io.js` found at the root of this repository. - -```html - - -``` - -Socket.IO is compatible with [browserify](http://browserify.org/). - -### Node.JS (server-side usage) - - Add `socket.io-client` to your `package.json` and then: - - ```js - var socket = require('socket.io-client')('http://localhost'); - socket.on('connect', function(){}); - socket.on('event', function(data){}); - socket.on('disconnect', function(){}); - ``` - -## API - -### IO(url:String, opts:Object):Socket - - Exposed as the `io` namespace in the standalone build, or the result - of calling `require('socket.io-client')`. - - When called, it creates a new `Manager` for the given URL, and attempts - to reuse an existing `Manager` for subsequent calls, unless the - `multiplex` option is passed with `false`. - - The rest of the options are passed to the `Manager` constructor (see below - for details). - - A `Socket` instance is returned for the namespace specified by the - pathname in the URL, defaulting to `/`. For example, if the `url` is - `http://localhost/users`, a transport connection will be established to - `http://localhost` and a Socket.IO connection will be established to - `/users`. - -### IO#protocol - - Socket.io protocol revision number this client works with. - -### IO#Socket - - Reference to the `Socket` constructor. - -### IO#Manager - - Reference to the `Manager` constructor. - -### IO#Emitter - - Reference to the `Emitter` constructor. - -### Manager(url:String, opts:Object) - - A `Manager` represents a connection to a given Socket.IO server. One or - more `Socket` instances are associated with the manager. The manager - can be accessed through the `io` property of each `Socket` instance. - - The `opts` are also passed to `engine.io` upon initialization of the - underlying `Socket`. - - Options: - - `reconnection` whether to reconnect automatically (`true`) - - `reconnectionAttempts` (`Infinity`) before giving up - - `reconnectionDelay` how long to initially wait before attempting a new - reconnection (`1000`). Affected by +/- `randomizationFactor`, - for example the default initial delay will be between 500 to 1500ms. - - `reconnectionDelayMax` maximum amount of time to wait between - reconnections (`5000`). Each attempt increases the reconnection delay by 2x - along with a randomization as above - - `randomizationFactor` (`0.5`), 0 <= randomizationFactor <= 1 - - `timeout` connection timeout before a `connect_error` - and `connect_timeout` events are emitted (`20000`) - - `autoConnect` by setting this false, you have to call `manager.open` - whenever you decide it's appropriate - -#### Events - - - `connect_error`. Fired upon a connection error. - Parameters: - - `Object` error object - - `connect_timeout`. Fired upon a connection timeout. - - `reconnect`. Fired upon a successful reconnection. - Parameters: - - `Number` reconnection attempt number - - `reconnect_attempt`. Fired upon an attempt to reconnect. - - `reconnecting`. Fired upon an attempt to reconnect. - Parameters: - - `Number` reconnection attempt number - - `reconnect_error`. Fired upon a reconnection attempt error. - Parameters: - - `Object` error object - - `reconnect_failed`. Fired when couldn't reconnect within `reconnectionAttempts` - - `ping`. Fired when a ping packet is written out to the server. - - `pong`. Fired when a pong is received from the server. - Parameters: - - `Number` number of ms elapsed since `ping` packet (i.e.: latency). - -The events above are also emitted on the individual sockets that -reconnect that depend on this `Manager`. - -### Manager#reconnection(v:Boolean):Manager - - Sets the `reconnection` option, or returns it if no parameters - are passed. - -### Manager#reconnectionAttempts(v:Boolean):Manager - - Sets the `reconnectionAttempts` option, or returns it if no parameters - are passed. - -### Manager#reconnectionDelay(v:Boolean):Manager - - Sets the `reconectionDelay` option, or returns it if no parameters - are passed. - -### Manager#reconnectionDelayMax(v:Boolean):Manager - - Sets the `reconectionDelayMax` option, or returns it if no parameters - are passed. - -### Manager#timeout(v:Boolean):Manager - - Sets the `timeout` option, or returns it if no parameters - are passed. - -### Socket - -#### Socket#id:String - -A property on the `socket` instance that is equal to the underlying engine.io socket id. - -The property is present once the socket has connected, is removed when the socket disconnects and is updated if the socket reconnects. - -#### Socket#compress(v:Boolean):Socket - - Sets a modifier for a subsequent event emission that the event data will - only be _compressed_ if the value is `true`. Defaults to `true` when you don't call the method. - - ```js - socket.compress(false).emit('an event', { some: 'data' }); - ``` - -#### Events - - - `connect`. Fired upon a connection including a successful reconnection. - - `error`. Fired upon a connection error - Parameters: - - `Object` error data - - `disconnect`. Fired upon a disconnection. - - `reconnect`. Fired upon a successful reconnection. - Parameters: - - `Number` reconnection attempt number - - `reconnect_attempt`. Fired upon an attempt to reconnect. - - `reconnecting`. Fired upon an attempt to reconnect. - Parameters: - - `Number` reconnection attempt number - - `reconnect_error`. Fired upon a reconnection attempt error. - Parameters: - - `Object` error object - - `reconnect_failed`. Fired when couldn't reconnect within `reconnectionAttempts` - -## License - -[MIT](/LICENSE) + +# socket.io-client + +[![Build Status](https://secure.travis-ci.org/socketio/socket.io-client.svg)](http://travis-ci.org/socketio/socket.io-client) +[![Dependency Status](https://david-dm.org/socketio/socket.io-client.svg)](https://david-dm.org/socketio/socket.io-client) +[![devDependency Status](https://david-dm.org/socketio/socket.io-client/dev-status.svg)](https://david-dm.org/socketio/socket.io-client#info=devDependencies) +![NPM version](https://badge.fury.io/js/socket.io-client.svg) +![Downloads](http://img.shields.io/npm/dm/socket.io-client.svg?style=flat) +[![](http://slack.socket.io/badge.svg?)](http://slack.socket.io) + +## How to use + +A standalone build of `socket.io-client` is exposed automatically by the +socket.io server as `/socket.io/socket.io.js`. Alternatively you can +serve the file `socket.io.js` found at the root of this repository. + +```html + + +``` + +Socket.IO is compatible with [browserify](http://browserify.org/). + +### Node.JS (server-side usage) + + Add `socket.io-client` to your `package.json` and then: + + ```js + var socket = require('socket.io-client')('http://localhost'); + socket.on('connect', function(){}); + socket.on('event', function(data){}); + socket.on('disconnect', function(){}); + ``` + +## API + +### IO(url:String, opts:Object):Socket + + Exposed as the `io` namespace in the standalone build, or the result + of calling `require('socket.io-client')`. + + When called, it creates a new `Manager` for the given URL, and attempts + to reuse an existing `Manager` for subsequent calls, unless the + `multiplex` option is passed with `false`. + + The rest of the options are passed to the `Manager` constructor (see below + for details). + + A `Socket` instance is returned for the namespace specified by the + pathname in the URL, defaulting to `/`. For example, if the `url` is + `http://localhost/users`, a transport connection will be established to + `http://localhost` and a Socket.IO connection will be established to + `/users`. + +### IO#protocol + + Socket.io protocol revision number this client works with. + +### IO#Socket + + Reference to the `Socket` constructor. + +### IO#Manager + + Reference to the `Manager` constructor. + +### IO#Emitter + + Reference to the `Emitter` constructor. + +### Manager(url:String, opts:Object) + + A `Manager` represents a connection to a given Socket.IO server. One or + more `Socket` instances are associated with the manager. The manager + can be accessed through the `io` property of each `Socket` instance. + + The `opts` are also passed to `engine.io` upon initialization of the + underlying `Socket`. + + Options: + - `reconnection` whether to reconnect automatically (`true`) + - `reconnectionAttempts` (`Infinity`) before giving up + - `reconnectionDelay` how long to initially wait before attempting a new + reconnection (`1000`). Affected by +/- `randomizationFactor`, + for example the default initial delay will be between 500 to 1500ms. + - `reconnectionDelayMax` maximum amount of time to wait between + reconnections (`5000`). Each attempt increases the reconnection delay by 2x + along with a randomization as above + - `randomizationFactor` (`0.5`), 0 <= randomizationFactor <= 1 + - `timeout` connection timeout before a `connect_error` + and `connect_timeout` events are emitted (`20000`) + - `autoConnect` by setting this false, you have to call `manager.open` + whenever you decide it's appropriate + +#### Events + + - `connect_error`. Fired upon a connection error. + Parameters: + - `Object` error object + - `connect_timeout`. Fired upon a connection timeout. + - `reconnect`. Fired upon a successful reconnection. + Parameters: + - `Number` reconnection attempt number + - `reconnect_attempt`. Fired upon an attempt to reconnect. + - `reconnecting`. Fired upon an attempt to reconnect. + Parameters: + - `Number` reconnection attempt number + - `reconnect_error`. Fired upon a reconnection attempt error. + Parameters: + - `Object` error object + - `reconnect_failed`. Fired when couldn't reconnect within `reconnectionAttempts` + - `ping`. Fired when a ping packet is written out to the server. + - `pong`. Fired when a pong is received from the server. + Parameters: + - `Number` number of ms elapsed since `ping` packet (i.e.: latency). + +The events above are also emitted on the individual sockets that +reconnect that depend on this `Manager`. + +### Manager#reconnection(v:Boolean):Manager + + Sets the `reconnection` option, or returns it if no parameters + are passed. + +### Manager#reconnectionAttempts(v:Boolean):Manager + + Sets the `reconnectionAttempts` option, or returns it if no parameters + are passed. + +### Manager#reconnectionDelay(v:Boolean):Manager + + Sets the `reconectionDelay` option, or returns it if no parameters + are passed. + +### Manager#reconnectionDelayMax(v:Boolean):Manager + + Sets the `reconectionDelayMax` option, or returns it if no parameters + are passed. + +### Manager#timeout(v:Boolean):Manager + + Sets the `timeout` option, or returns it if no parameters + are passed. + +### Socket + +#### Socket#id:String + +A property on the `socket` instance that is equal to the underlying engine.io socket id. + +The property is present once the socket has connected, is removed when the socket disconnects and is updated if the socket reconnects. + +#### Socket#compress(v:Boolean):Socket + + Sets a modifier for a subsequent event emission that the event data will + only be _compressed_ if the value is `true`. Defaults to `true` when you don't call the method. + + ```js + socket.compress(false).emit('an event', { some: 'data' }); + ``` + +#### Events + + - `connect`. Fired upon a connection including a successful reconnection. + - `error`. Fired upon a connection error + Parameters: + - `Object` error data + - `disconnect`. Fired upon a disconnection. + - `reconnect`. Fired upon a successful reconnection. + Parameters: + - `Number` reconnection attempt number + - `reconnect_attempt`. Fired upon an attempt to reconnect. + - `reconnecting`. Fired upon an attempt to reconnect. + Parameters: + - `Number` reconnection attempt number + - `reconnect_error`. Fired upon a reconnection attempt error. + Parameters: + - `Object` error object + - `reconnect_failed`. Fired when couldn't reconnect within `reconnectionAttempts` + +## License + +[MIT](/LICENSE) diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/lib/index.js b/ui/node_modules/socket.io/node_modules/socket.io-client/lib/index.js index 50f916bb..91887e4e 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/lib/index.js +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/lib/index.js @@ -1,92 +1,92 @@ - -/** - * Module dependencies. - */ - -var url = require('./url'); -var parser = require('socket.io-parser'); -var Manager = require('./manager'); -var debug = require('debug')('socket.io-client'); - -/** - * Module exports. - */ - -module.exports = exports = lookup; - -/** - * Managers cache. - */ - -var cache = exports.managers = {}; - -/** - * Looks up an existing `Manager` for multiplexing. - * If the user summons: - * - * `io('http://localhost/a');` - * `io('http://localhost/b');` - * - * We reuse the existing instance based on same scheme/port/host, - * and we initialize sockets for each namespace. - * - * @api public - */ - -function lookup(uri, opts) { - if (typeof uri == 'object') { - opts = uri; - uri = undefined; - } - - opts = opts || {}; - - var parsed = url(uri); - var source = parsed.source; - var id = parsed.id; - var path = parsed.path; - var sameNamespace = cache[id] && path in cache[id].nsps; - var newConnection = opts.forceNew || opts['force new connection'] || - false === opts.multiplex || sameNamespace; - - var io; - - if (newConnection) { - debug('ignoring socket cache for %s', source); - io = Manager(source, opts); - } else { - if (!cache[id]) { - debug('new io instance for %s', source); - cache[id] = Manager(source, opts); - } - io = cache[id]; - } - - return io.socket(parsed.path); -} - -/** - * Protocol version. - * - * @api public - */ - -exports.protocol = parser.protocol; - -/** - * `connect`. - * - * @param {String} uri - * @api public - */ - -exports.connect = lookup; - -/** - * Expose constructors for standalone build. - * - * @api public - */ - -exports.Manager = require('./manager'); -exports.Socket = require('./socket'); + +/** + * Module dependencies. + */ + +var url = require('./url'); +var parser = require('socket.io-parser'); +var Manager = require('./manager'); +var debug = require('debug')('socket.io-client'); + +/** + * Module exports. + */ + +module.exports = exports = lookup; + +/** + * Managers cache. + */ + +var cache = exports.managers = {}; + +/** + * Looks up an existing `Manager` for multiplexing. + * If the user summons: + * + * `io('http://localhost/a');` + * `io('http://localhost/b');` + * + * We reuse the existing instance based on same scheme/port/host, + * and we initialize sockets for each namespace. + * + * @api public + */ + +function lookup(uri, opts) { + if (typeof uri == 'object') { + opts = uri; + uri = undefined; + } + + opts = opts || {}; + + var parsed = url(uri); + var source = parsed.source; + var id = parsed.id; + var path = parsed.path; + var sameNamespace = cache[id] && path in cache[id].nsps; + var newConnection = opts.forceNew || opts['force new connection'] || + false === opts.multiplex || sameNamespace; + + var io; + + if (newConnection) { + debug('ignoring socket cache for %s', source); + io = Manager(source, opts); + } else { + if (!cache[id]) { + debug('new io instance for %s', source); + cache[id] = Manager(source, opts); + } + io = cache[id]; + } + + return io.socket(parsed.path); +} + +/** + * Protocol version. + * + * @api public + */ + +exports.protocol = parser.protocol; + +/** + * `connect`. + * + * @param {String} uri + * @api public + */ + +exports.connect = lookup; + +/** + * Expose constructors for standalone build. + * + * @api public + */ + +exports.Manager = require('./manager'); +exports.Socket = require('./socket'); diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/lib/manager.js b/ui/node_modules/socket.io/node_modules/socket.io-client/lib/manager.js index a3528cbf..5d7f88c6 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/lib/manager.js +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/lib/manager.js @@ -1,557 +1,557 @@ - -/** - * Module dependencies. - */ - -var eio = require('engine.io-client'); -var Socket = require('./socket'); -var Emitter = require('component-emitter'); -var parser = require('socket.io-parser'); -var on = require('./on'); -var bind = require('component-bind'); -var debug = require('debug')('socket.io-client:manager'); -var indexOf = require('indexof'); -var Backoff = require('backo2'); - -/** - * IE6+ hasOwnProperty - */ - -var has = Object.prototype.hasOwnProperty; - -/** - * Module exports - */ - -module.exports = Manager; - -/** - * `Manager` constructor. - * - * @param {String} engine instance or engine uri/opts - * @param {Object} options - * @api public - */ - -function Manager(uri, opts){ - if (!(this instanceof Manager)) return new Manager(uri, opts); - if (uri && ('object' == typeof uri)) { - opts = uri; - uri = undefined; - } - opts = opts || {}; - - opts.path = opts.path || '/socket.io'; - this.nsps = {}; - this.subs = []; - this.opts = opts; - this.reconnection(opts.reconnection !== false); - this.reconnectionAttempts(opts.reconnectionAttempts || Infinity); - this.reconnectionDelay(opts.reconnectionDelay || 1000); - this.reconnectionDelayMax(opts.reconnectionDelayMax || 5000); - this.randomizationFactor(opts.randomizationFactor || 0.5); - this.backoff = new Backoff({ - min: this.reconnectionDelay(), - max: this.reconnectionDelayMax(), - jitter: this.randomizationFactor() - }); - this.timeout(null == opts.timeout ? 20000 : opts.timeout); - this.readyState = 'closed'; - this.uri = uri; - this.connecting = []; - this.lastPing = null; - this.encoding = false; - this.packetBuffer = []; - this.encoder = new parser.Encoder(); - this.decoder = new parser.Decoder(); - this.autoConnect = opts.autoConnect !== false; - if (this.autoConnect) this.open(); -} - -/** - * Propagate given event to sockets and emit on `this` - * - * @api private - */ - -Manager.prototype.emitAll = function() { - this.emit.apply(this, arguments); - for (var nsp in this.nsps) { - if (has.call(this.nsps, nsp)) { - this.nsps[nsp].emit.apply(this.nsps[nsp], arguments); - } - } -}; - -/** - * Update `socket.id` of all sockets - * - * @api private - */ - -Manager.prototype.updateSocketIds = function(){ - for (var nsp in this.nsps) { - if (has.call(this.nsps, nsp)) { - this.nsps[nsp].id = this.engine.id; - } - } -}; - -/** - * Mix in `Emitter`. - */ - -Emitter(Manager.prototype); - -/** - * Sets the `reconnection` config. - * - * @param {Boolean} true/false if it should automatically reconnect - * @return {Manager} self or value - * @api public - */ - -Manager.prototype.reconnection = function(v){ - if (!arguments.length) return this._reconnection; - this._reconnection = !!v; - return this; -}; - -/** - * Sets the reconnection attempts config. - * - * @param {Number} max reconnection attempts before giving up - * @return {Manager} self or value - * @api public - */ - -Manager.prototype.reconnectionAttempts = function(v){ - if (!arguments.length) return this._reconnectionAttempts; - this._reconnectionAttempts = v; - return this; -}; - -/** - * Sets the delay between reconnections. - * - * @param {Number} delay - * @return {Manager} self or value - * @api public - */ - -Manager.prototype.reconnectionDelay = function(v){ - if (!arguments.length) return this._reconnectionDelay; - this._reconnectionDelay = v; - this.backoff && this.backoff.setMin(v); - return this; -}; - -Manager.prototype.randomizationFactor = function(v){ - if (!arguments.length) return this._randomizationFactor; - this._randomizationFactor = v; - this.backoff && this.backoff.setJitter(v); - return this; -}; - -/** - * Sets the maximum delay between reconnections. - * - * @param {Number} delay - * @return {Manager} self or value - * @api public - */ - -Manager.prototype.reconnectionDelayMax = function(v){ - if (!arguments.length) return this._reconnectionDelayMax; - this._reconnectionDelayMax = v; - this.backoff && this.backoff.setMax(v); - return this; -}; - -/** - * Sets the connection timeout. `false` to disable - * - * @return {Manager} self or value - * @api public - */ - -Manager.prototype.timeout = function(v){ - if (!arguments.length) return this._timeout; - this._timeout = v; - return this; -}; - -/** - * Starts trying to reconnect if reconnection is enabled and we have not - * started reconnecting yet - * - * @api private - */ - -Manager.prototype.maybeReconnectOnOpen = function() { - // Only try to reconnect if it's the first time we're connecting - if (!this.reconnecting && this._reconnection && this.backoff.attempts === 0) { - // keeps reconnection from firing twice for the same reconnection loop - this.reconnect(); - } -}; - - -/** - * Sets the current transport `socket`. - * - * @param {Function} optional, callback - * @return {Manager} self - * @api public - */ - -Manager.prototype.open = -Manager.prototype.connect = function(fn){ - debug('readyState %s', this.readyState); - if (~this.readyState.indexOf('open')) return this; - - debug('opening %s', this.uri); - this.engine = eio(this.uri, this.opts); - var socket = this.engine; - var self = this; - this.readyState = 'opening'; - this.skipReconnect = false; - - // emit `open` - var openSub = on(socket, 'open', function() { - self.onopen(); - fn && fn(); - }); - - // emit `connect_error` - var errorSub = on(socket, 'error', function(data){ - debug('connect_error'); - self.cleanup(); - self.readyState = 'closed'; - self.emitAll('connect_error', data); - if (fn) { - var err = new Error('Connection error'); - err.data = data; - fn(err); - } else { - // Only do this if there is no fn to handle the error - self.maybeReconnectOnOpen(); - } - }); - - // emit `connect_timeout` - if (false !== this._timeout) { - var timeout = this._timeout; - debug('connect attempt will timeout after %d', timeout); - - // set timer - var timer = setTimeout(function(){ - debug('connect attempt timed out after %d', timeout); - openSub.destroy(); - socket.close(); - socket.emit('error', 'timeout'); - self.emitAll('connect_timeout', timeout); - }, timeout); - - this.subs.push({ - destroy: function(){ - clearTimeout(timer); - } - }); - } - - this.subs.push(openSub); - this.subs.push(errorSub); - - return this; -}; - -/** - * Called upon transport open. - * - * @api private - */ - -Manager.prototype.onopen = function(){ - debug('open'); - - // clear old subs - this.cleanup(); - - // mark as open - this.readyState = 'open'; - this.emit('open'); - - // add new subs - var socket = this.engine; - this.subs.push(on(socket, 'data', bind(this, 'ondata'))); - this.subs.push(on(socket, 'ping', bind(this, 'onping'))); - this.subs.push(on(socket, 'pong', bind(this, 'onpong'))); - this.subs.push(on(socket, 'error', bind(this, 'onerror'))); - this.subs.push(on(socket, 'close', bind(this, 'onclose'))); - this.subs.push(on(this.decoder, 'decoded', bind(this, 'ondecoded'))); -}; - -/** - * Called upon a ping. - * - * @api private - */ - -Manager.prototype.onping = function(){ - this.lastPing = new Date; - this.emitAll('ping'); -}; - -/** - * Called upon a packet. - * - * @api private - */ - -Manager.prototype.onpong = function(){ - this.emitAll('pong', new Date - this.lastPing); -}; - -/** - * Called with data. - * - * @api private - */ - -Manager.prototype.ondata = function(data){ - this.decoder.add(data); -}; - -/** - * Called when parser fully decodes a packet. - * - * @api private - */ - -Manager.prototype.ondecoded = function(packet) { - this.emit('packet', packet); -}; - -/** - * Called upon socket error. - * - * @api private - */ - -Manager.prototype.onerror = function(err){ - debug('error', err); - this.emitAll('error', err); -}; - -/** - * Creates a new socket for the given `nsp`. - * - * @return {Socket} - * @api public - */ - -Manager.prototype.socket = function(nsp){ - var socket = this.nsps[nsp]; - if (!socket) { - socket = new Socket(this, nsp); - this.nsps[nsp] = socket; - var self = this; - socket.on('connecting', onConnecting); - socket.on('connect', function(){ - socket.id = self.engine.id; - }); - - if (this.autoConnect) { - // manually call here since connecting evnet is fired before listening - onConnecting(); - } - } - - function onConnecting() { - if (!~indexOf(self.connecting, socket)) { - self.connecting.push(socket); - } - } - - return socket; -}; - -/** - * Called upon a socket close. - * - * @param {Socket} socket - */ - -Manager.prototype.destroy = function(socket){ - var index = indexOf(this.connecting, socket); - if (~index) this.connecting.splice(index, 1); - if (this.connecting.length) return; - - this.close(); -}; - -/** - * Writes a packet. - * - * @param {Object} packet - * @api private - */ - -Manager.prototype.packet = function(packet){ - debug('writing packet %j', packet); - var self = this; - - if (!self.encoding) { - // encode, then write to engine with result - self.encoding = true; - this.encoder.encode(packet, function(encodedPackets) { - for (var i = 0; i < encodedPackets.length; i++) { - self.engine.write(encodedPackets[i], packet.options); - } - self.encoding = false; - self.processPacketQueue(); - }); - } else { // add packet to the queue - self.packetBuffer.push(packet); - } -}; - -/** - * If packet buffer is non-empty, begins encoding the - * next packet in line. - * - * @api private - */ - -Manager.prototype.processPacketQueue = function() { - if (this.packetBuffer.length > 0 && !this.encoding) { - var pack = this.packetBuffer.shift(); - this.packet(pack); - } -}; - -/** - * Clean up transport subscriptions and packet buffer. - * - * @api private - */ - -Manager.prototype.cleanup = function(){ - debug('cleanup'); - - var sub; - while (sub = this.subs.shift()) sub.destroy(); - - this.packetBuffer = []; - this.encoding = false; - this.lastPing = null; - - this.decoder.destroy(); -}; - -/** - * Close the current socket. - * - * @api private - */ - -Manager.prototype.close = -Manager.prototype.disconnect = function(){ - debug('disconnect'); - this.skipReconnect = true; - this.reconnecting = false; - if ('opening' == this.readyState) { - // `onclose` will not fire because - // an open event never happened - this.cleanup(); - } - this.backoff.reset(); - this.readyState = 'closed'; - if (this.engine) this.engine.close(); -}; - -/** - * Called upon engine close. - * - * @api private - */ - -Manager.prototype.onclose = function(reason){ - debug('onclose'); - - this.cleanup(); - this.backoff.reset(); - this.readyState = 'closed'; - this.emit('close', reason); - - if (this._reconnection && !this.skipReconnect) { - this.reconnect(); - } -}; - -/** - * Attempt a reconnection. - * - * @api private - */ - -Manager.prototype.reconnect = function(){ - if (this.reconnecting || this.skipReconnect) return this; - - var self = this; - - if (this.backoff.attempts >= this._reconnectionAttempts) { - debug('reconnect failed'); - this.backoff.reset(); - this.emitAll('reconnect_failed'); - this.reconnecting = false; - } else { - var delay = this.backoff.duration(); - debug('will wait %dms before reconnect attempt', delay); - - this.reconnecting = true; - var timer = setTimeout(function(){ - if (self.skipReconnect) return; - - debug('attempting reconnect'); - self.emitAll('reconnect_attempt', self.backoff.attempts); - self.emitAll('reconnecting', self.backoff.attempts); - - // check again for the case socket closed in above events - if (self.skipReconnect) return; - - self.open(function(err){ - if (err) { - debug('reconnect attempt error'); - self.reconnecting = false; - self.reconnect(); - self.emitAll('reconnect_error', err.data); - } else { - debug('reconnect success'); - self.onreconnect(); - } - }); - }, delay); - - this.subs.push({ - destroy: function(){ - clearTimeout(timer); - } - }); - } -}; - -/** - * Called upon successful reconnect. - * - * @api private - */ - -Manager.prototype.onreconnect = function(){ - var attempt = this.backoff.attempts; - this.reconnecting = false; - this.backoff.reset(); - this.updateSocketIds(); - this.emitAll('reconnect', attempt); -}; + +/** + * Module dependencies. + */ + +var eio = require('engine.io-client'); +var Socket = require('./socket'); +var Emitter = require('component-emitter'); +var parser = require('socket.io-parser'); +var on = require('./on'); +var bind = require('component-bind'); +var debug = require('debug')('socket.io-client:manager'); +var indexOf = require('indexof'); +var Backoff = require('backo2'); + +/** + * IE6+ hasOwnProperty + */ + +var has = Object.prototype.hasOwnProperty; + +/** + * Module exports + */ + +module.exports = Manager; + +/** + * `Manager` constructor. + * + * @param {String} engine instance or engine uri/opts + * @param {Object} options + * @api public + */ + +function Manager(uri, opts){ + if (!(this instanceof Manager)) return new Manager(uri, opts); + if (uri && ('object' == typeof uri)) { + opts = uri; + uri = undefined; + } + opts = opts || {}; + + opts.path = opts.path || '/socket.io'; + this.nsps = {}; + this.subs = []; + this.opts = opts; + this.reconnection(opts.reconnection !== false); + this.reconnectionAttempts(opts.reconnectionAttempts || Infinity); + this.reconnectionDelay(opts.reconnectionDelay || 1000); + this.reconnectionDelayMax(opts.reconnectionDelayMax || 5000); + this.randomizationFactor(opts.randomizationFactor || 0.5); + this.backoff = new Backoff({ + min: this.reconnectionDelay(), + max: this.reconnectionDelayMax(), + jitter: this.randomizationFactor() + }); + this.timeout(null == opts.timeout ? 20000 : opts.timeout); + this.readyState = 'closed'; + this.uri = uri; + this.connecting = []; + this.lastPing = null; + this.encoding = false; + this.packetBuffer = []; + this.encoder = new parser.Encoder(); + this.decoder = new parser.Decoder(); + this.autoConnect = opts.autoConnect !== false; + if (this.autoConnect) this.open(); +} + +/** + * Propagate given event to sockets and emit on `this` + * + * @api private + */ + +Manager.prototype.emitAll = function() { + this.emit.apply(this, arguments); + for (var nsp in this.nsps) { + if (has.call(this.nsps, nsp)) { + this.nsps[nsp].emit.apply(this.nsps[nsp], arguments); + } + } +}; + +/** + * Update `socket.id` of all sockets + * + * @api private + */ + +Manager.prototype.updateSocketIds = function(){ + for (var nsp in this.nsps) { + if (has.call(this.nsps, nsp)) { + this.nsps[nsp].id = this.engine.id; + } + } +}; + +/** + * Mix in `Emitter`. + */ + +Emitter(Manager.prototype); + +/** + * Sets the `reconnection` config. + * + * @param {Boolean} true/false if it should automatically reconnect + * @return {Manager} self or value + * @api public + */ + +Manager.prototype.reconnection = function(v){ + if (!arguments.length) return this._reconnection; + this._reconnection = !!v; + return this; +}; + +/** + * Sets the reconnection attempts config. + * + * @param {Number} max reconnection attempts before giving up + * @return {Manager} self or value + * @api public + */ + +Manager.prototype.reconnectionAttempts = function(v){ + if (!arguments.length) return this._reconnectionAttempts; + this._reconnectionAttempts = v; + return this; +}; + +/** + * Sets the delay between reconnections. + * + * @param {Number} delay + * @return {Manager} self or value + * @api public + */ + +Manager.prototype.reconnectionDelay = function(v){ + if (!arguments.length) return this._reconnectionDelay; + this._reconnectionDelay = v; + this.backoff && this.backoff.setMin(v); + return this; +}; + +Manager.prototype.randomizationFactor = function(v){ + if (!arguments.length) return this._randomizationFactor; + this._randomizationFactor = v; + this.backoff && this.backoff.setJitter(v); + return this; +}; + +/** + * Sets the maximum delay between reconnections. + * + * @param {Number} delay + * @return {Manager} self or value + * @api public + */ + +Manager.prototype.reconnectionDelayMax = function(v){ + if (!arguments.length) return this._reconnectionDelayMax; + this._reconnectionDelayMax = v; + this.backoff && this.backoff.setMax(v); + return this; +}; + +/** + * Sets the connection timeout. `false` to disable + * + * @return {Manager} self or value + * @api public + */ + +Manager.prototype.timeout = function(v){ + if (!arguments.length) return this._timeout; + this._timeout = v; + return this; +}; + +/** + * Starts trying to reconnect if reconnection is enabled and we have not + * started reconnecting yet + * + * @api private + */ + +Manager.prototype.maybeReconnectOnOpen = function() { + // Only try to reconnect if it's the first time we're connecting + if (!this.reconnecting && this._reconnection && this.backoff.attempts === 0) { + // keeps reconnection from firing twice for the same reconnection loop + this.reconnect(); + } +}; + + +/** + * Sets the current transport `socket`. + * + * @param {Function} optional, callback + * @return {Manager} self + * @api public + */ + +Manager.prototype.open = +Manager.prototype.connect = function(fn){ + debug('readyState %s', this.readyState); + if (~this.readyState.indexOf('open')) return this; + + debug('opening %s', this.uri); + this.engine = eio(this.uri, this.opts); + var socket = this.engine; + var self = this; + this.readyState = 'opening'; + this.skipReconnect = false; + + // emit `open` + var openSub = on(socket, 'open', function() { + self.onopen(); + fn && fn(); + }); + + // emit `connect_error` + var errorSub = on(socket, 'error', function(data){ + debug('connect_error'); + self.cleanup(); + self.readyState = 'closed'; + self.emitAll('connect_error', data); + if (fn) { + var err = new Error('Connection error'); + err.data = data; + fn(err); + } else { + // Only do this if there is no fn to handle the error + self.maybeReconnectOnOpen(); + } + }); + + // emit `connect_timeout` + if (false !== this._timeout) { + var timeout = this._timeout; + debug('connect attempt will timeout after %d', timeout); + + // set timer + var timer = setTimeout(function(){ + debug('connect attempt timed out after %d', timeout); + openSub.destroy(); + socket.close(); + socket.emit('error', 'timeout'); + self.emitAll('connect_timeout', timeout); + }, timeout); + + this.subs.push({ + destroy: function(){ + clearTimeout(timer); + } + }); + } + + this.subs.push(openSub); + this.subs.push(errorSub); + + return this; +}; + +/** + * Called upon transport open. + * + * @api private + */ + +Manager.prototype.onopen = function(){ + debug('open'); + + // clear old subs + this.cleanup(); + + // mark as open + this.readyState = 'open'; + this.emit('open'); + + // add new subs + var socket = this.engine; + this.subs.push(on(socket, 'data', bind(this, 'ondata'))); + this.subs.push(on(socket, 'ping', bind(this, 'onping'))); + this.subs.push(on(socket, 'pong', bind(this, 'onpong'))); + this.subs.push(on(socket, 'error', bind(this, 'onerror'))); + this.subs.push(on(socket, 'close', bind(this, 'onclose'))); + this.subs.push(on(this.decoder, 'decoded', bind(this, 'ondecoded'))); +}; + +/** + * Called upon a ping. + * + * @api private + */ + +Manager.prototype.onping = function(){ + this.lastPing = new Date; + this.emitAll('ping'); +}; + +/** + * Called upon a packet. + * + * @api private + */ + +Manager.prototype.onpong = function(){ + this.emitAll('pong', new Date - this.lastPing); +}; + +/** + * Called with data. + * + * @api private + */ + +Manager.prototype.ondata = function(data){ + this.decoder.add(data); +}; + +/** + * Called when parser fully decodes a packet. + * + * @api private + */ + +Manager.prototype.ondecoded = function(packet) { + this.emit('packet', packet); +}; + +/** + * Called upon socket error. + * + * @api private + */ + +Manager.prototype.onerror = function(err){ + debug('error', err); + this.emitAll('error', err); +}; + +/** + * Creates a new socket for the given `nsp`. + * + * @return {Socket} + * @api public + */ + +Manager.prototype.socket = function(nsp){ + var socket = this.nsps[nsp]; + if (!socket) { + socket = new Socket(this, nsp); + this.nsps[nsp] = socket; + var self = this; + socket.on('connecting', onConnecting); + socket.on('connect', function(){ + socket.id = self.engine.id; + }); + + if (this.autoConnect) { + // manually call here since connecting evnet is fired before listening + onConnecting(); + } + } + + function onConnecting() { + if (!~indexOf(self.connecting, socket)) { + self.connecting.push(socket); + } + } + + return socket; +}; + +/** + * Called upon a socket close. + * + * @param {Socket} socket + */ + +Manager.prototype.destroy = function(socket){ + var index = indexOf(this.connecting, socket); + if (~index) this.connecting.splice(index, 1); + if (this.connecting.length) return; + + this.close(); +}; + +/** + * Writes a packet. + * + * @param {Object} packet + * @api private + */ + +Manager.prototype.packet = function(packet){ + debug('writing packet %j', packet); + var self = this; + + if (!self.encoding) { + // encode, then write to engine with result + self.encoding = true; + this.encoder.encode(packet, function(encodedPackets) { + for (var i = 0; i < encodedPackets.length; i++) { + self.engine.write(encodedPackets[i], packet.options); + } + self.encoding = false; + self.processPacketQueue(); + }); + } else { // add packet to the queue + self.packetBuffer.push(packet); + } +}; + +/** + * If packet buffer is non-empty, begins encoding the + * next packet in line. + * + * @api private + */ + +Manager.prototype.processPacketQueue = function() { + if (this.packetBuffer.length > 0 && !this.encoding) { + var pack = this.packetBuffer.shift(); + this.packet(pack); + } +}; + +/** + * Clean up transport subscriptions and packet buffer. + * + * @api private + */ + +Manager.prototype.cleanup = function(){ + debug('cleanup'); + + var sub; + while (sub = this.subs.shift()) sub.destroy(); + + this.packetBuffer = []; + this.encoding = false; + this.lastPing = null; + + this.decoder.destroy(); +}; + +/** + * Close the current socket. + * + * @api private + */ + +Manager.prototype.close = +Manager.prototype.disconnect = function(){ + debug('disconnect'); + this.skipReconnect = true; + this.reconnecting = false; + if ('opening' == this.readyState) { + // `onclose` will not fire because + // an open event never happened + this.cleanup(); + } + this.backoff.reset(); + this.readyState = 'closed'; + if (this.engine) this.engine.close(); +}; + +/** + * Called upon engine close. + * + * @api private + */ + +Manager.prototype.onclose = function(reason){ + debug('onclose'); + + this.cleanup(); + this.backoff.reset(); + this.readyState = 'closed'; + this.emit('close', reason); + + if (this._reconnection && !this.skipReconnect) { + this.reconnect(); + } +}; + +/** + * Attempt a reconnection. + * + * @api private + */ + +Manager.prototype.reconnect = function(){ + if (this.reconnecting || this.skipReconnect) return this; + + var self = this; + + if (this.backoff.attempts >= this._reconnectionAttempts) { + debug('reconnect failed'); + this.backoff.reset(); + this.emitAll('reconnect_failed'); + this.reconnecting = false; + } else { + var delay = this.backoff.duration(); + debug('will wait %dms before reconnect attempt', delay); + + this.reconnecting = true; + var timer = setTimeout(function(){ + if (self.skipReconnect) return; + + debug('attempting reconnect'); + self.emitAll('reconnect_attempt', self.backoff.attempts); + self.emitAll('reconnecting', self.backoff.attempts); + + // check again for the case socket closed in above events + if (self.skipReconnect) return; + + self.open(function(err){ + if (err) { + debug('reconnect attempt error'); + self.reconnecting = false; + self.reconnect(); + self.emitAll('reconnect_error', err.data); + } else { + debug('reconnect success'); + self.onreconnect(); + } + }); + }, delay); + + this.subs.push({ + destroy: function(){ + clearTimeout(timer); + } + }); + } +}; + +/** + * Called upon successful reconnect. + * + * @api private + */ + +Manager.prototype.onreconnect = function(){ + var attempt = this.backoff.attempts; + this.reconnecting = false; + this.backoff.reset(); + this.updateSocketIds(); + this.emitAll('reconnect', attempt); +}; diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/lib/on.js b/ui/node_modules/socket.io/node_modules/socket.io-client/lib/on.js index 728badc0..6be286d5 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/lib/on.js +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/lib/on.js @@ -1,24 +1,24 @@ - -/** - * Module exports. - */ - -module.exports = on; - -/** - * Helper for subscriptions. - * - * @param {Object|EventEmitter} obj with `Emitter` mixin or `EventEmitter` - * @param {String} event name - * @param {Function} callback - * @api public - */ - -function on(obj, ev, fn) { - obj.on(ev, fn); - return { - destroy: function(){ - obj.removeListener(ev, fn); - } - }; -} + +/** + * Module exports. + */ + +module.exports = on; + +/** + * Helper for subscriptions. + * + * @param {Object|EventEmitter} obj with `Emitter` mixin or `EventEmitter` + * @param {String} event name + * @param {Function} callback + * @api public + */ + +function on(obj, ev, fn) { + obj.on(ev, fn); + return { + destroy: function(){ + obj.removeListener(ev, fn); + } + }; +} diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/lib/socket.js b/ui/node_modules/socket.io/node_modules/socket.io-client/lib/socket.js index 6f0bcfc9..6c19a0cd 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/lib/socket.js +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/lib/socket.js @@ -1,412 +1,412 @@ - -/** - * Module dependencies. - */ - -var parser = require('socket.io-parser'); -var Emitter = require('component-emitter'); -var toArray = require('to-array'); -var on = require('./on'); -var bind = require('component-bind'); -var debug = require('debug')('socket.io-client:socket'); -var hasBin = require('has-binary'); - -/** - * Module exports. - */ - -module.exports = exports = Socket; - -/** - * Internal events (blacklisted). - * These events can't be emitted by the user. - * - * @api private - */ - -var events = { - connect: 1, - connect_error: 1, - connect_timeout: 1, - connecting: 1, - disconnect: 1, - error: 1, - reconnect: 1, - reconnect_attempt: 1, - reconnect_failed: 1, - reconnect_error: 1, - reconnecting: 1, - ping: 1, - pong: 1 -}; - -/** - * Shortcut to `Emitter#emit`. - */ - -var emit = Emitter.prototype.emit; - -/** - * `Socket` constructor. - * - * @api public - */ - -function Socket(io, nsp){ - this.io = io; - this.nsp = nsp; - this.json = this; // compat - this.ids = 0; - this.acks = {}; - this.receiveBuffer = []; - this.sendBuffer = []; - this.connected = false; - this.disconnected = true; - if (this.io.autoConnect) this.open(); -} - -/** - * Mix in `Emitter`. - */ - -Emitter(Socket.prototype); - -/** - * Subscribe to open, close and packet events - * - * @api private - */ - -Socket.prototype.subEvents = function() { - if (this.subs) return; - - var io = this.io; - this.subs = [ - on(io, 'open', bind(this, 'onopen')), - on(io, 'packet', bind(this, 'onpacket')), - on(io, 'close', bind(this, 'onclose')) - ]; -}; - -/** - * "Opens" the socket. - * - * @api public - */ - -Socket.prototype.open = -Socket.prototype.connect = function(){ - if (this.connected) return this; - - this.subEvents(); - this.io.open(); // ensure open - if ('open' == this.io.readyState) this.onopen(); - this.emit('connecting'); - return this; -}; - -/** - * Sends a `message` event. - * - * @return {Socket} self - * @api public - */ - -Socket.prototype.send = function(){ - var args = toArray(arguments); - args.unshift('message'); - this.emit.apply(this, args); - return this; -}; - -/** - * Override `emit`. - * If the event is in `events`, it's emitted normally. - * - * @param {String} event name - * @return {Socket} self - * @api public - */ - -Socket.prototype.emit = function(ev){ - if (events.hasOwnProperty(ev)) { - emit.apply(this, arguments); - return this; - } - - var args = toArray(arguments); - var parserType = parser.EVENT; // default - if (hasBin(args)) { parserType = parser.BINARY_EVENT; } // binary - var packet = { type: parserType, data: args }; - - packet.options = {}; - packet.options.compress = !this.flags || false !== this.flags.compress; - - // event ack callback - if ('function' == typeof args[args.length - 1]) { - debug('emitting packet with ack id %d', this.ids); - this.acks[this.ids] = args.pop(); - packet.id = this.ids++; - } - - if (this.connected) { - this.packet(packet); - } else { - this.sendBuffer.push(packet); - } - - delete this.flags; - - return this; -}; - -/** - * Sends a packet. - * - * @param {Object} packet - * @api private - */ - -Socket.prototype.packet = function(packet){ - packet.nsp = this.nsp; - this.io.packet(packet); -}; - -/** - * Called upon engine `open`. - * - * @api private - */ - -Socket.prototype.onopen = function(){ - debug('transport is open - connecting'); - - // write connect packet if necessary - if ('/' != this.nsp) { - this.packet({ type: parser.CONNECT }); - } -}; - -/** - * Called upon engine `close`. - * - * @param {String} reason - * @api private - */ - -Socket.prototype.onclose = function(reason){ - debug('close (%s)', reason); - this.connected = false; - this.disconnected = true; - delete this.id; - this.emit('disconnect', reason); -}; - -/** - * Called with socket packet. - * - * @param {Object} packet - * @api private - */ - -Socket.prototype.onpacket = function(packet){ - if (packet.nsp != this.nsp) return; - - switch (packet.type) { - case parser.CONNECT: - this.onconnect(); - break; - - case parser.EVENT: - this.onevent(packet); - break; - - case parser.BINARY_EVENT: - this.onevent(packet); - break; - - case parser.ACK: - this.onack(packet); - break; - - case parser.BINARY_ACK: - this.onack(packet); - break; - - case parser.DISCONNECT: - this.ondisconnect(); - break; - - case parser.ERROR: - this.emit('error', packet.data); - break; - } -}; - -/** - * Called upon a server event. - * - * @param {Object} packet - * @api private - */ - -Socket.prototype.onevent = function(packet){ - var args = packet.data || []; - debug('emitting event %j', args); - - if (null != packet.id) { - debug('attaching ack callback to event'); - args.push(this.ack(packet.id)); - } - - if (this.connected) { - emit.apply(this, args); - } else { - this.receiveBuffer.push(args); - } -}; - -/** - * Produces an ack callback to emit with an event. - * - * @api private - */ - -Socket.prototype.ack = function(id){ - var self = this; - var sent = false; - return function(){ - // prevent double callbacks - if (sent) return; - sent = true; - var args = toArray(arguments); - debug('sending ack %j', args); - - var type = hasBin(args) ? parser.BINARY_ACK : parser.ACK; - self.packet({ - type: type, - id: id, - data: args - }); - }; -}; - -/** - * Called upon a server acknowlegement. - * - * @param {Object} packet - * @api private - */ - -Socket.prototype.onack = function(packet){ - var ack = this.acks[packet.id]; - if ('function' == typeof ack) { - debug('calling ack %s with %j', packet.id, packet.data); - ack.apply(this, packet.data); - delete this.acks[packet.id]; - } else { - debug('bad ack %s', packet.id); - } -}; - -/** - * Called upon server connect. - * - * @api private - */ - -Socket.prototype.onconnect = function(){ - this.connected = true; - this.disconnected = false; - this.emit('connect'); - this.emitBuffered(); -}; - -/** - * Emit buffered events (received and emitted). - * - * @api private - */ - -Socket.prototype.emitBuffered = function(){ - var i; - for (i = 0; i < this.receiveBuffer.length; i++) { - emit.apply(this, this.receiveBuffer[i]); - } - this.receiveBuffer = []; - - for (i = 0; i < this.sendBuffer.length; i++) { - this.packet(this.sendBuffer[i]); - } - this.sendBuffer = []; -}; - -/** - * Called upon server disconnect. - * - * @api private - */ - -Socket.prototype.ondisconnect = function(){ - debug('server disconnect (%s)', this.nsp); - this.destroy(); - this.onclose('io server disconnect'); -}; - -/** - * Called upon forced client/server side disconnections, - * this method ensures the manager stops tracking us and - * that reconnections don't get triggered for this. - * - * @api private. - */ - -Socket.prototype.destroy = function(){ - if (this.subs) { - // clean subscriptions to avoid reconnections - for (var i = 0; i < this.subs.length; i++) { - this.subs[i].destroy(); - } - this.subs = null; - } - - this.io.destroy(this); -}; - -/** - * Disconnects the socket manually. - * - * @return {Socket} self - * @api public - */ - -Socket.prototype.close = -Socket.prototype.disconnect = function(){ - if (this.connected) { - debug('performing disconnect (%s)', this.nsp); - this.packet({ type: parser.DISCONNECT }); - } - - // remove socket from pool - this.destroy(); - - if (this.connected) { - // fire events - this.onclose('io client disconnect'); - } - return this; -}; - -/** - * Sets the compress flag. - * - * @param {Boolean} if `true`, compresses the sending data - * @return {Socket} self - * @api public - */ - -Socket.prototype.compress = function(compress){ - this.flags = this.flags || {}; - this.flags.compress = compress; - return this; -}; + +/** + * Module dependencies. + */ + +var parser = require('socket.io-parser'); +var Emitter = require('component-emitter'); +var toArray = require('to-array'); +var on = require('./on'); +var bind = require('component-bind'); +var debug = require('debug')('socket.io-client:socket'); +var hasBin = require('has-binary'); + +/** + * Module exports. + */ + +module.exports = exports = Socket; + +/** + * Internal events (blacklisted). + * These events can't be emitted by the user. + * + * @api private + */ + +var events = { + connect: 1, + connect_error: 1, + connect_timeout: 1, + connecting: 1, + disconnect: 1, + error: 1, + reconnect: 1, + reconnect_attempt: 1, + reconnect_failed: 1, + reconnect_error: 1, + reconnecting: 1, + ping: 1, + pong: 1 +}; + +/** + * Shortcut to `Emitter#emit`. + */ + +var emit = Emitter.prototype.emit; + +/** + * `Socket` constructor. + * + * @api public + */ + +function Socket(io, nsp){ + this.io = io; + this.nsp = nsp; + this.json = this; // compat + this.ids = 0; + this.acks = {}; + this.receiveBuffer = []; + this.sendBuffer = []; + this.connected = false; + this.disconnected = true; + if (this.io.autoConnect) this.open(); +} + +/** + * Mix in `Emitter`. + */ + +Emitter(Socket.prototype); + +/** + * Subscribe to open, close and packet events + * + * @api private + */ + +Socket.prototype.subEvents = function() { + if (this.subs) return; + + var io = this.io; + this.subs = [ + on(io, 'open', bind(this, 'onopen')), + on(io, 'packet', bind(this, 'onpacket')), + on(io, 'close', bind(this, 'onclose')) + ]; +}; + +/** + * "Opens" the socket. + * + * @api public + */ + +Socket.prototype.open = +Socket.prototype.connect = function(){ + if (this.connected) return this; + + this.subEvents(); + this.io.open(); // ensure open + if ('open' == this.io.readyState) this.onopen(); + this.emit('connecting'); + return this; +}; + +/** + * Sends a `message` event. + * + * @return {Socket} self + * @api public + */ + +Socket.prototype.send = function(){ + var args = toArray(arguments); + args.unshift('message'); + this.emit.apply(this, args); + return this; +}; + +/** + * Override `emit`. + * If the event is in `events`, it's emitted normally. + * + * @param {String} event name + * @return {Socket} self + * @api public + */ + +Socket.prototype.emit = function(ev){ + if (events.hasOwnProperty(ev)) { + emit.apply(this, arguments); + return this; + } + + var args = toArray(arguments); + var parserType = parser.EVENT; // default + if (hasBin(args)) { parserType = parser.BINARY_EVENT; } // binary + var packet = { type: parserType, data: args }; + + packet.options = {}; + packet.options.compress = !this.flags || false !== this.flags.compress; + + // event ack callback + if ('function' == typeof args[args.length - 1]) { + debug('emitting packet with ack id %d', this.ids); + this.acks[this.ids] = args.pop(); + packet.id = this.ids++; + } + + if (this.connected) { + this.packet(packet); + } else { + this.sendBuffer.push(packet); + } + + delete this.flags; + + return this; +}; + +/** + * Sends a packet. + * + * @param {Object} packet + * @api private + */ + +Socket.prototype.packet = function(packet){ + packet.nsp = this.nsp; + this.io.packet(packet); +}; + +/** + * Called upon engine `open`. + * + * @api private + */ + +Socket.prototype.onopen = function(){ + debug('transport is open - connecting'); + + // write connect packet if necessary + if ('/' != this.nsp) { + this.packet({ type: parser.CONNECT }); + } +}; + +/** + * Called upon engine `close`. + * + * @param {String} reason + * @api private + */ + +Socket.prototype.onclose = function(reason){ + debug('close (%s)', reason); + this.connected = false; + this.disconnected = true; + delete this.id; + this.emit('disconnect', reason); +}; + +/** + * Called with socket packet. + * + * @param {Object} packet + * @api private + */ + +Socket.prototype.onpacket = function(packet){ + if (packet.nsp != this.nsp) return; + + switch (packet.type) { + case parser.CONNECT: + this.onconnect(); + break; + + case parser.EVENT: + this.onevent(packet); + break; + + case parser.BINARY_EVENT: + this.onevent(packet); + break; + + case parser.ACK: + this.onack(packet); + break; + + case parser.BINARY_ACK: + this.onack(packet); + break; + + case parser.DISCONNECT: + this.ondisconnect(); + break; + + case parser.ERROR: + this.emit('error', packet.data); + break; + } +}; + +/** + * Called upon a server event. + * + * @param {Object} packet + * @api private + */ + +Socket.prototype.onevent = function(packet){ + var args = packet.data || []; + debug('emitting event %j', args); + + if (null != packet.id) { + debug('attaching ack callback to event'); + args.push(this.ack(packet.id)); + } + + if (this.connected) { + emit.apply(this, args); + } else { + this.receiveBuffer.push(args); + } +}; + +/** + * Produces an ack callback to emit with an event. + * + * @api private + */ + +Socket.prototype.ack = function(id){ + var self = this; + var sent = false; + return function(){ + // prevent double callbacks + if (sent) return; + sent = true; + var args = toArray(arguments); + debug('sending ack %j', args); + + var type = hasBin(args) ? parser.BINARY_ACK : parser.ACK; + self.packet({ + type: type, + id: id, + data: args + }); + }; +}; + +/** + * Called upon a server acknowlegement. + * + * @param {Object} packet + * @api private + */ + +Socket.prototype.onack = function(packet){ + var ack = this.acks[packet.id]; + if ('function' == typeof ack) { + debug('calling ack %s with %j', packet.id, packet.data); + ack.apply(this, packet.data); + delete this.acks[packet.id]; + } else { + debug('bad ack %s', packet.id); + } +}; + +/** + * Called upon server connect. + * + * @api private + */ + +Socket.prototype.onconnect = function(){ + this.connected = true; + this.disconnected = false; + this.emit('connect'); + this.emitBuffered(); +}; + +/** + * Emit buffered events (received and emitted). + * + * @api private + */ + +Socket.prototype.emitBuffered = function(){ + var i; + for (i = 0; i < this.receiveBuffer.length; i++) { + emit.apply(this, this.receiveBuffer[i]); + } + this.receiveBuffer = []; + + for (i = 0; i < this.sendBuffer.length; i++) { + this.packet(this.sendBuffer[i]); + } + this.sendBuffer = []; +}; + +/** + * Called upon server disconnect. + * + * @api private + */ + +Socket.prototype.ondisconnect = function(){ + debug('server disconnect (%s)', this.nsp); + this.destroy(); + this.onclose('io server disconnect'); +}; + +/** + * Called upon forced client/server side disconnections, + * this method ensures the manager stops tracking us and + * that reconnections don't get triggered for this. + * + * @api private. + */ + +Socket.prototype.destroy = function(){ + if (this.subs) { + // clean subscriptions to avoid reconnections + for (var i = 0; i < this.subs.length; i++) { + this.subs[i].destroy(); + } + this.subs = null; + } + + this.io.destroy(this); +}; + +/** + * Disconnects the socket manually. + * + * @return {Socket} self + * @api public + */ + +Socket.prototype.close = +Socket.prototype.disconnect = function(){ + if (this.connected) { + debug('performing disconnect (%s)', this.nsp); + this.packet({ type: parser.DISCONNECT }); + } + + // remove socket from pool + this.destroy(); + + if (this.connected) { + // fire events + this.onclose('io client disconnect'); + } + return this; +}; + +/** + * Sets the compress flag. + * + * @param {Boolean} if `true`, compresses the sending data + * @return {Socket} self + * @api public + */ + +Socket.prototype.compress = function(compress){ + this.flags = this.flags || {}; + this.flags.compress = compress; + return this; +}; diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/lib/url.js b/ui/node_modules/socket.io/node_modules/socket.io-client/lib/url.js index a14653f0..dd3982bd 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/lib/url.js +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/lib/url.js @@ -1,76 +1,76 @@ - -/** - * Module dependencies. - */ - -var parseuri = require('parseuri'); -var debug = require('debug')('socket.io-client:url'); - -/** - * Module exports. - */ - -module.exports = url; - -/** - * URL parser. - * - * @param {String} url - * @param {Object} An object meant to mimic window.location. - * Defaults to window.location. - * @api public - */ - -function url(uri, loc){ - var obj = uri; - - // default to window.location - var loc = loc || global.location; - if (null == uri) uri = loc.protocol + '//' + loc.host; - - // relative path support - if ('string' == typeof uri) { - if ('/' == uri.charAt(0)) { - if ('/' == uri.charAt(1)) { - uri = loc.protocol + uri; - } else { - uri = loc.host + uri; - } - } - - if (!/^(https?|wss?):\/\//.test(uri)) { - debug('protocol-less url %s', uri); - if ('undefined' != typeof loc) { - uri = loc.protocol + '//' + uri; - } else { - uri = 'https://' + uri; - } - } - - // parse - debug('parse %s', uri); - obj = parseuri(uri); - } - - // make sure we treat `localhost:80` and `localhost` equally - if (!obj.port) { - if (/^(http|ws)$/.test(obj.protocol)) { - obj.port = '80'; - } - else if (/^(http|ws)s$/.test(obj.protocol)) { - obj.port = '443'; - } - } - - obj.path = obj.path || '/'; - - var ipv6 = obj.host.indexOf(':') !== -1; - var host = ipv6 ? '[' + obj.host + ']' : obj.host; - - // define unique id - obj.id = obj.protocol + '://' + host + ':' + obj.port; - // define href - obj.href = obj.protocol + '://' + host + (loc && loc.port == obj.port ? '' : (':' + obj.port)); - - return obj; -} + +/** + * Module dependencies. + */ + +var parseuri = require('parseuri'); +var debug = require('debug')('socket.io-client:url'); + +/** + * Module exports. + */ + +module.exports = url; + +/** + * URL parser. + * + * @param {String} url + * @param {Object} An object meant to mimic window.location. + * Defaults to window.location. + * @api public + */ + +function url(uri, loc){ + var obj = uri; + + // default to window.location + var loc = loc || global.location; + if (null == uri) uri = loc.protocol + '//' + loc.host; + + // relative path support + if ('string' == typeof uri) { + if ('/' == uri.charAt(0)) { + if ('/' == uri.charAt(1)) { + uri = loc.protocol + uri; + } else { + uri = loc.host + uri; + } + } + + if (!/^(https?|wss?):\/\//.test(uri)) { + debug('protocol-less url %s', uri); + if ('undefined' != typeof loc) { + uri = loc.protocol + '//' + uri; + } else { + uri = 'https://' + uri; + } + } + + // parse + debug('parse %s', uri); + obj = parseuri(uri); + } + + // make sure we treat `localhost:80` and `localhost` equally + if (!obj.port) { + if (/^(http|ws)$/.test(obj.protocol)) { + obj.port = '80'; + } + else if (/^(http|ws)s$/.test(obj.protocol)) { + obj.port = '443'; + } + } + + obj.path = obj.path || '/'; + + var ipv6 = obj.host.indexOf(':') !== -1; + var host = ipv6 ? '[' + obj.host + ']' : obj.host; + + // define unique id + obj.id = obj.protocol + '://' + host + ':' + obj.port; + // define href + obj.href = obj.protocol + '://' + host + (loc && loc.port == obj.port ? '' : (':' + obj.port)); + + return obj; +} diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/.npmignore b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/.npmignore index bca51b35..c2658d7d 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/.npmignore +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/.npmignore @@ -1 +1 @@ -node_modules/ +node_modules/ diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/History.md b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/History.md index 19d9e314..8eb28b8e 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/History.md +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/History.md @@ -1,12 +1,12 @@ - -1.0.1 / 2014-02-17 -================== - - * go away decimal point - * history - -1.0.0 / 2014-02-17 -================== - - * add jitter option - * Initial commit + +1.0.1 / 2014-02-17 +================== + + * go away decimal point + * history + +1.0.0 / 2014-02-17 +================== + + * add jitter option + * Initial commit diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/Makefile b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/Makefile index 7510a4e1..9987df81 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/Makefile +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/Makefile @@ -1,8 +1,8 @@ - -test: - @./node_modules/.bin/mocha \ - --require should \ - --reporter dot \ - --bail - + +test: + @./node_modules/.bin/mocha \ + --require should \ + --reporter dot \ + --bail + .PHONY: test \ No newline at end of file diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/Readme.md b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/Readme.md index 6744d87c..0df2a399 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/Readme.md +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/Readme.md @@ -1,34 +1,34 @@ -# backo - - Simple exponential backoff because the others seem to have weird abstractions. - -## Installation - -``` -$ npm install backo -``` - -## Options - - - `min` initial timeout in milliseconds [100] - - `max` max timeout [10000] - - `jitter` [0] - - `factor` [2] - -## Example - -```js -var Backoff = require('backo'); -var backoff = new Backoff({ min: 100, max: 20000 }); - -setTimeout(function(){ - something.reconnect(); -}, backoff.duration()); - -// later when something works -backoff.reset() -``` - -# License - - MIT +# backo + + Simple exponential backoff because the others seem to have weird abstractions. + +## Installation + +``` +$ npm install backo +``` + +## Options + + - `min` initial timeout in milliseconds [100] + - `max` max timeout [10000] + - `jitter` [0] + - `factor` [2] + +## Example + +```js +var Backoff = require('backo'); +var backoff = new Backoff({ min: 100, max: 20000 }); + +setTimeout(function(){ + something.reconnect(); +}, backoff.duration()); + +// later when something works +backoff.reset() +``` + +# License + + MIT diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/component.json b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/component.json index 2ed0e4b1..994845ac 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/component.json +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/component.json @@ -1,11 +1,11 @@ -{ - "name": "backo", - "repo": "segmentio/backo", - "dependencies": {}, - "version": "1.0.1", - "description": "simple backoff without the weird abstractions", - "keywords": ["backoff"], - "license": "MIT", - "scripts": ["index.js"], - "main": "index.js" -} +{ + "name": "backo", + "repo": "segmentio/backo", + "dependencies": {}, + "version": "1.0.1", + "description": "simple backoff without the weird abstractions", + "keywords": ["backoff"], + "license": "MIT", + "scripts": ["index.js"], + "main": "index.js" +} diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/index.js b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/index.js index 9861de1f..fac4429b 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/index.js +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/index.js @@ -1,85 +1,85 @@ - -/** - * Expose `Backoff`. - */ - -module.exports = Backoff; - -/** - * Initialize backoff timer with `opts`. - * - * - `min` initial timeout in milliseconds [100] - * - `max` max timeout [10000] - * - `jitter` [0] - * - `factor` [2] - * - * @param {Object} opts - * @api public - */ - -function Backoff(opts) { - opts = opts || {}; - this.ms = opts.min || 100; - this.max = opts.max || 10000; - this.factor = opts.factor || 2; - this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0; - this.attempts = 0; -} - -/** - * Return the backoff duration. - * - * @return {Number} - * @api public - */ - -Backoff.prototype.duration = function(){ - var ms = this.ms * Math.pow(this.factor, this.attempts++); - if (this.jitter) { - var rand = Math.random(); - var deviation = Math.floor(rand * this.jitter * ms); - ms = (Math.floor(rand * 10) & 1) == 0 ? ms - deviation : ms + deviation; - } - return Math.min(ms, this.max) | 0; -}; - -/** - * Reset the number of attempts. - * - * @api public - */ - -Backoff.prototype.reset = function(){ - this.attempts = 0; -}; - -/** - * Set the minimum duration - * - * @api public - */ - -Backoff.prototype.setMin = function(min){ - this.ms = min; -}; - -/** - * Set the maximum duration - * - * @api public - */ - -Backoff.prototype.setMax = function(max){ - this.max = max; -}; - -/** - * Set the jitter - * - * @api public - */ - -Backoff.prototype.setJitter = function(jitter){ - this.jitter = jitter; -}; - + +/** + * Expose `Backoff`. + */ + +module.exports = Backoff; + +/** + * Initialize backoff timer with `opts`. + * + * - `min` initial timeout in milliseconds [100] + * - `max` max timeout [10000] + * - `jitter` [0] + * - `factor` [2] + * + * @param {Object} opts + * @api public + */ + +function Backoff(opts) { + opts = opts || {}; + this.ms = opts.min || 100; + this.max = opts.max || 10000; + this.factor = opts.factor || 2; + this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0; + this.attempts = 0; +} + +/** + * Return the backoff duration. + * + * @return {Number} + * @api public + */ + +Backoff.prototype.duration = function(){ + var ms = this.ms * Math.pow(this.factor, this.attempts++); + if (this.jitter) { + var rand = Math.random(); + var deviation = Math.floor(rand * this.jitter * ms); + ms = (Math.floor(rand * 10) & 1) == 0 ? ms - deviation : ms + deviation; + } + return Math.min(ms, this.max) | 0; +}; + +/** + * Reset the number of attempts. + * + * @api public + */ + +Backoff.prototype.reset = function(){ + this.attempts = 0; +}; + +/** + * Set the minimum duration + * + * @api public + */ + +Backoff.prototype.setMin = function(min){ + this.ms = min; +}; + +/** + * Set the maximum duration + * + * @api public + */ + +Backoff.prototype.setMax = function(max){ + this.max = max; +}; + +/** + * Set the jitter + * + * @api public + */ + +Backoff.prototype.setJitter = function(jitter){ + this.jitter = jitter; +}; + diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/package.json b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/package.json index fd6b5d8b..f2bf16bb 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/package.json +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/package.json @@ -1,45 +1,45 @@ -{ - "name": "backo2", - "version": "1.0.2", - "repository": { - "type": "git", - "url": "git+https://github.com/mokesmokes/backo.git" - }, - "description": "simple backoff based on segmentio/backo", - "keywords": [ - "backoff" - ], - "dependencies": {}, - "devDependencies": { - "mocha": "*", - "should": "*" - }, - "license": "MIT", - "gitHead": "3e695bade7756fef2295e8883bf3570a06e5d9ec", - "bugs": { - "url": "https://github.com/mokesmokes/backo/issues" - }, - "homepage": "https://github.com/mokesmokes/backo", - "_id": "backo2@1.0.2", - "scripts": {}, - "_shasum": "31ab1ac8b129363463e35b3ebb69f4dfcfba7947", - "_from": "backo2@1.0.2", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "mokesmokes", - "email": "mokesmokes@gmail.com" - }, - "maintainers": [ - { - "name": "mokesmokes", - "email": "mokesmokes@gmail.com" - } - ], - "dist": { - "shasum": "31ab1ac8b129363463e35b3ebb69f4dfcfba7947", - "tarball": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "backo2", + "version": "1.0.2", + "repository": { + "type": "git", + "url": "git+https://github.com/mokesmokes/backo.git" + }, + "description": "simple backoff based on segmentio/backo", + "keywords": [ + "backoff" + ], + "dependencies": {}, + "devDependencies": { + "mocha": "*", + "should": "*" + }, + "license": "MIT", + "gitHead": "3e695bade7756fef2295e8883bf3570a06e5d9ec", + "bugs": { + "url": "https://github.com/mokesmokes/backo/issues" + }, + "homepage": "https://github.com/mokesmokes/backo", + "_id": "backo2@1.0.2", + "scripts": {}, + "_shasum": "31ab1ac8b129363463e35b3ebb69f4dfcfba7947", + "_from": "backo2@1.0.2", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "mokesmokes", + "email": "mokesmokes@gmail.com" + }, + "maintainers": [ + { + "name": "mokesmokes", + "email": "mokesmokes@gmail.com" + } + ], + "dist": { + "shasum": "31ab1ac8b129363463e35b3ebb69f4dfcfba7947", + "tarball": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/test/index.js b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/test/index.js index 61d4aa59..ea1f6de1 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/test/index.js +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/backo2/test/index.js @@ -1,18 +1,18 @@ - -var Backoff = require('..'); -var assert = require('assert'); - -describe('.duration()', function(){ - it('should increase the backoff', function(){ - var b = new Backoff; - - assert(100 == b.duration()); - assert(200 == b.duration()); - assert(400 == b.duration()); - assert(800 == b.duration()); - - b.reset(); - assert(100 == b.duration()); - assert(200 == b.duration()); - }) + +var Backoff = require('..'); +var assert = require('assert'); + +describe('.duration()', function(){ + it('should increase the backoff', function(){ + var b = new Backoff; + + assert(100 == b.duration()); + assert(200 == b.duration()); + assert(400 == b.duration()); + assert(800 == b.duration()); + + b.reset(); + assert(100 == b.duration()); + assert(200 == b.duration()); + }) }) \ No newline at end of file diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-bind/.npmignore b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-bind/.npmignore index 47c4a951..f1250e58 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-bind/.npmignore +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-bind/.npmignore @@ -1,4 +1,4 @@ -support -test -examples -*.sock +support +test +examples +*.sock diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-bind/History.md b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-bind/History.md index b11250ee..2795fdbc 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-bind/History.md +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-bind/History.md @@ -1,13 +1,13 @@ - -1.0.0 / 2014-05-27 -================== - - * index: use slice ref (#7, @viatropos) - * package: rename package to "component-bind" - * package: add "repository" field (#6, @repoify) - * package: add "component" section - -0.0.1 / 2010-01-03 -================== - - * Initial release + +1.0.0 / 2014-05-27 +================== + + * index: use slice ref (#7, @viatropos) + * package: rename package to "component-bind" + * package: add "repository" field (#6, @repoify) + * package: add "component" section + +0.0.1 / 2010-01-03 +================== + + * Initial release diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-bind/Makefile b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-bind/Makefile index 3a62b882..4e9c8d36 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-bind/Makefile +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-bind/Makefile @@ -1,7 +1,7 @@ - -test: - @./node_modules/.bin/mocha \ - --require should \ - --reporter spec - + +test: + @./node_modules/.bin/mocha \ + --require should \ + --reporter spec + .PHONY: test \ No newline at end of file diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-bind/Readme.md b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-bind/Readme.md index ed7508d2..6a8febc8 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-bind/Readme.md +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-bind/Readme.md @@ -1,64 +1,64 @@ -# bind - - Function binding utility. - -## Installation - -``` -$ component install component/bind -``` - -## API - - - [bind(obj, fn)](#bindobj-fn) - - [bind(obj, fn, ...)](#bindobj-fn-) - - [bind(obj, name)](#bindobj-name) - - - -### bind(obj, fn) -should bind the function to the given object. - -```js -var tobi = { name: 'tobi' }; - -function name() { - return this.name; -} - -var fn = bind(tobi, name); -fn().should.equal('tobi'); -``` - - -### bind(obj, fn, ...) -should curry the remaining arguments. - -```js -function add(a, b) { - return a + b; -} - -bind(null, add)(1, 2).should.equal(3); -bind(null, add, 1)(2).should.equal(3); -bind(null, add, 1, 2)().should.equal(3); -``` - - -### bind(obj, name) -should bind the method of the given name. - -```js -var tobi = { name: 'tobi' }; - -tobi.getName = function() { - return this.name; -}; - -var fn = bind(tobi, 'getName'); -fn().should.equal('tobi'); -``` - -## License - +# bind + + Function binding utility. + +## Installation + +``` +$ component install component/bind +``` + +## API + + - [bind(obj, fn)](#bindobj-fn) + - [bind(obj, fn, ...)](#bindobj-fn-) + - [bind(obj, name)](#bindobj-name) + + + +### bind(obj, fn) +should bind the function to the given object. + +```js +var tobi = { name: 'tobi' }; + +function name() { + return this.name; +} + +var fn = bind(tobi, name); +fn().should.equal('tobi'); +``` + + +### bind(obj, fn, ...) +should curry the remaining arguments. + +```js +function add(a, b) { + return a + b; +} + +bind(null, add)(1, 2).should.equal(3); +bind(null, add, 1)(2).should.equal(3); +bind(null, add, 1, 2)().should.equal(3); +``` + + +### bind(obj, name) +should bind the method of the given name. + +```js +var tobi = { name: 'tobi' }; + +tobi.getName = function() { + return this.name; +}; + +var fn = bind(tobi, 'getName'); +fn().should.equal('tobi'); +``` + +## License + MIT \ No newline at end of file diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-bind/component.json b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-bind/component.json index a9f19fda..4e1e93f5 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-bind/component.json +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-bind/component.json @@ -1,13 +1,13 @@ -{ - "name": "bind", - "version": "1.0.0", - "description": "function binding utility", - "keywords": [ - "bind", - "utility" - ], - "dependencies": {}, - "scripts": [ - "index.js" - ] -} +{ + "name": "bind", + "version": "1.0.0", + "description": "function binding utility", + "keywords": [ + "bind", + "utility" + ], + "dependencies": {}, + "scripts": [ + "index.js" + ] +} diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-bind/index.js b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-bind/index.js index f53406f6..4eeb2c0a 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-bind/index.js +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-bind/index.js @@ -1,23 +1,23 @@ -/** - * Slice reference. - */ - -var slice = [].slice; - -/** - * Bind `obj` to `fn`. - * - * @param {Object} obj - * @param {Function|String} fn or string - * @return {Function} - * @api public - */ - -module.exports = function(obj, fn){ - if ('string' == typeof fn) fn = obj[fn]; - if ('function' != typeof fn) throw new Error('bind() requires a function'); - var args = slice.call(arguments, 2); - return function(){ - return fn.apply(obj, args.concat(slice.call(arguments))); - } -}; +/** + * Slice reference. + */ + +var slice = [].slice; + +/** + * Bind `obj` to `fn`. + * + * @param {Object} obj + * @param {Function|String} fn or string + * @return {Function} + * @api public + */ + +module.exports = function(obj, fn){ + if ('string' == typeof fn) fn = obj[fn]; + if ('function' != typeof fn) throw new Error('bind() requires a function'); + var args = slice.call(arguments, 2); + return function(){ + return fn.apply(obj, args.concat(slice.call(arguments))); + } +}; diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-bind/package.json b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-bind/package.json index 0fc5ee45..4a65518a 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-bind/package.json +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-bind/package.json @@ -1,47 +1,47 @@ -{ - "name": "component-bind", - "version": "1.0.0", - "description": "function binding utility", - "keywords": [ - "bind", - "utility" - ], - "devDependencies": { - "mocha": "*", - "should": "*" - }, - "component": { - "scripts": { - "bind/index.js": "index.js" - } - }, - "repository": { - "type": "git", - "url": "git+https://github.com/component/bind.git" - }, - "bugs": { - "url": "https://github.com/component/bind/issues" - }, - "homepage": "https://github.com/component/bind", - "_id": "component-bind@1.0.0", - "_shasum": "00c608ab7dcd93897c0009651b1d3a8e1e73bbd1", - "_from": "component-bind@1.0.0", - "_npmVersion": "1.4.9", - "_npmUser": { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - }, - "maintainers": [ - { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - } - ], - "dist": { - "shasum": "00c608ab7dcd93897c0009651b1d3a8e1e73bbd1", - "tarball": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "component-bind", + "version": "1.0.0", + "description": "function binding utility", + "keywords": [ + "bind", + "utility" + ], + "devDependencies": { + "mocha": "*", + "should": "*" + }, + "component": { + "scripts": { + "bind/index.js": "index.js" + } + }, + "repository": { + "type": "git", + "url": "git+https://github.com/component/bind.git" + }, + "bugs": { + "url": "https://github.com/component/bind/issues" + }, + "homepage": "https://github.com/component/bind", + "_id": "component-bind@1.0.0", + "_shasum": "00c608ab7dcd93897c0009651b1d3a8e1e73bbd1", + "_from": "component-bind@1.0.0", + "_npmVersion": "1.4.9", + "_npmUser": { + "name": "tootallnate", + "email": "nathan@tootallnate.net" + }, + "maintainers": [ + { + "name": "tootallnate", + "email": "nathan@tootallnate.net" + } + ], + "dist": { + "shasum": "00c608ab7dcd93897c0009651b1d3a8e1e73bbd1", + "tarball": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-emitter/History.md b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-emitter/History.md index 6fd687e6..2ab07791 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-emitter/History.md +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-emitter/History.md @@ -1,63 +1,63 @@ - -1.2.0 / 2014-02-12 -================== - - * prefix events with `$` to support object prototype method names - -1.1.3 / 2014-06-20 -================== - - * republish for npm - * add LICENSE file - -1.1.2 / 2014-02-10 -================== - - * package: rename to "component-emitter" - * package: update "main" and "component" fields - * Add license to Readme (same format as the other components) - * created .npmignore - * travis stuff - -1.1.1 / 2013-12-01 -================== - - * fix .once adding .on to the listener - * docs: Emitter#off() - * component: add `.repo` prop - -1.1.0 / 2013-10-20 -================== - - * add `.addEventListener()` and `.removeEventListener()` aliases - -1.0.1 / 2013-06-27 -================== - - * add support for legacy ie - -1.0.0 / 2013-02-26 -================== - - * add `.off()` support for removing all listeners - -0.0.6 / 2012-10-08 -================== - - * add `this._callbacks` initialization to prevent funky gotcha - -0.0.5 / 2012-09-07 -================== - - * fix `Emitter.call(this)` usage - -0.0.3 / 2012-07-11 -================== - - * add `.listeners()` - * rename `.has()` to `.hasListeners()` - -0.0.2 / 2012-06-28 -================== - - * fix `.off()` with `.once()`-registered callbacks + +1.2.0 / 2014-02-12 +================== + + * prefix events with `$` to support object prototype method names + +1.1.3 / 2014-06-20 +================== + + * republish for npm + * add LICENSE file + +1.1.2 / 2014-02-10 +================== + + * package: rename to "component-emitter" + * package: update "main" and "component" fields + * Add license to Readme (same format as the other components) + * created .npmignore + * travis stuff + +1.1.1 / 2013-12-01 +================== + + * fix .once adding .on to the listener + * docs: Emitter#off() + * component: add `.repo` prop + +1.1.0 / 2013-10-20 +================== + + * add `.addEventListener()` and `.removeEventListener()` aliases + +1.0.1 / 2013-06-27 +================== + + * add support for legacy ie + +1.0.0 / 2013-02-26 +================== + + * add `.off()` support for removing all listeners + +0.0.6 / 2012-10-08 +================== + + * add `this._callbacks` initialization to prevent funky gotcha + +0.0.5 / 2012-09-07 +================== + + * fix `Emitter.call(this)` usage + +0.0.3 / 2012-07-11 +================== + + * add `.listeners()` + * rename `.has()` to `.hasListeners()` + +0.0.2 / 2012-06-28 +================== + + * fix `.off()` with `.once()`-registered callbacks diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-emitter/LICENSE b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-emitter/LICENSE index d6e43f2b..de516927 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-emitter/LICENSE +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-emitter/LICENSE @@ -1,24 +1,24 @@ -(The MIT License) - -Copyright (c) 2014 Component contributors - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. +(The MIT License) + +Copyright (c) 2014 Component contributors + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-emitter/Readme.md b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-emitter/Readme.md index 04664111..0f3f9b9f 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-emitter/Readme.md +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-emitter/Readme.md @@ -1,74 +1,74 @@ -# Emitter [![Build Status](https://travis-ci.org/component/emitter.png)](https://travis-ci.org/component/emitter) - - Event emitter component. - -## Installation - -``` -$ component install component/emitter -``` - -## API - -### Emitter(obj) - - The `Emitter` may also be used as a mixin. For example - a "plain" object may become an emitter, or you may - extend an existing prototype. - - As an `Emitter` instance: - -```js -var Emitter = require('emitter'); -var emitter = new Emitter; -emitter.emit('something'); -``` - - As a mixin: - -```js -var Emitter = require('emitter'); -var user = { name: 'tobi' }; -Emitter(user); - -user.emit('im a user'); -``` - - As a prototype mixin: - -```js -var Emitter = require('emitter'); -Emitter(User.prototype); -``` - -### Emitter#on(event, fn) - - Register an `event` handler `fn`. - -### Emitter#once(event, fn) - - Register a single-shot `event` handler `fn`, - removed immediately after it is invoked the - first time. - -### Emitter#off(event, fn) - - * Pass `event` and `fn` to remove a listener. - * Pass `event` to remove all listeners on that event. - * Pass nothing to remove all listeners on all events. - -### Emitter#emit(event, ...) - - Emit an `event` with variable option args. - -### Emitter#listeners(event) - - Return an array of callbacks, or an empty array. - -### Emitter#hasListeners(event) - - Check if this emitter has `event` handlers. - -## License - -MIT +# Emitter [![Build Status](https://travis-ci.org/component/emitter.png)](https://travis-ci.org/component/emitter) + + Event emitter component. + +## Installation + +``` +$ component install component/emitter +``` + +## API + +### Emitter(obj) + + The `Emitter` may also be used as a mixin. For example + a "plain" object may become an emitter, or you may + extend an existing prototype. + + As an `Emitter` instance: + +```js +var Emitter = require('emitter'); +var emitter = new Emitter; +emitter.emit('something'); +``` + + As a mixin: + +```js +var Emitter = require('emitter'); +var user = { name: 'tobi' }; +Emitter(user); + +user.emit('im a user'); +``` + + As a prototype mixin: + +```js +var Emitter = require('emitter'); +Emitter(User.prototype); +``` + +### Emitter#on(event, fn) + + Register an `event` handler `fn`. + +### Emitter#once(event, fn) + + Register a single-shot `event` handler `fn`, + removed immediately after it is invoked the + first time. + +### Emitter#off(event, fn) + + * Pass `event` and `fn` to remove a listener. + * Pass `event` to remove all listeners on that event. + * Pass nothing to remove all listeners on all events. + +### Emitter#emit(event, ...) + + Emit an `event` with variable option args. + +### Emitter#listeners(event) + + Return an array of callbacks, or an empty array. + +### Emitter#hasListeners(event) + + Check if this emitter has `event` handlers. + +## License + +MIT diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-emitter/index.js b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-emitter/index.js index bfd4262c..1c781764 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-emitter/index.js +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-emitter/index.js @@ -1,161 +1,161 @@ - -/** - * Expose `Emitter`. - */ - -module.exports = Emitter; - -/** - * Initialize a new `Emitter`. - * - * @api public - */ - -function Emitter(obj) { - if (obj) return mixin(obj); -}; - -/** - * Mixin the emitter properties. - * - * @param {Object} obj - * @return {Object} - * @api private - */ - -function mixin(obj) { - for (var key in Emitter.prototype) { - obj[key] = Emitter.prototype[key]; - } - return obj; -} - -/** - * Listen on the given `event` with `fn`. - * - * @param {String} event - * @param {Function} fn - * @return {Emitter} - * @api public - */ - -Emitter.prototype.on = -Emitter.prototype.addEventListener = function(event, fn){ - this._callbacks = this._callbacks || {}; - (this._callbacks['$' + event] = this._callbacks['$' + event] || []) - .push(fn); - return this; -}; - -/** - * Adds an `event` listener that will be invoked a single - * time then automatically removed. - * - * @param {String} event - * @param {Function} fn - * @return {Emitter} - * @api public - */ - -Emitter.prototype.once = function(event, fn){ - function on() { - this.off(event, on); - fn.apply(this, arguments); - } - - on.fn = fn; - this.on(event, on); - return this; -}; - -/** - * Remove the given callback for `event` or all - * registered callbacks. - * - * @param {String} event - * @param {Function} fn - * @return {Emitter} - * @api public - */ - -Emitter.prototype.off = -Emitter.prototype.removeListener = -Emitter.prototype.removeAllListeners = -Emitter.prototype.removeEventListener = function(event, fn){ - this._callbacks = this._callbacks || {}; - - // all - if (0 == arguments.length) { - this._callbacks = {}; - return this; - } - - // specific event - var callbacks = this._callbacks['$' + event]; - if (!callbacks) return this; - - // remove all handlers - if (1 == arguments.length) { - delete this._callbacks['$' + event]; - return this; - } - - // remove specific handler - var cb; - for (var i = 0; i < callbacks.length; i++) { - cb = callbacks[i]; - if (cb === fn || cb.fn === fn) { - callbacks.splice(i, 1); - break; - } - } - return this; -}; - -/** - * Emit `event` with the given args. - * - * @param {String} event - * @param {Mixed} ... - * @return {Emitter} - */ - -Emitter.prototype.emit = function(event){ - this._callbacks = this._callbacks || {}; - var args = [].slice.call(arguments, 1) - , callbacks = this._callbacks['$' + event]; - - if (callbacks) { - callbacks = callbacks.slice(0); - for (var i = 0, len = callbacks.length; i < len; ++i) { - callbacks[i].apply(this, args); - } - } - - return this; -}; - -/** - * Return array of callbacks for `event`. - * - * @param {String} event - * @return {Array} - * @api public - */ - -Emitter.prototype.listeners = function(event){ - this._callbacks = this._callbacks || {}; - return this._callbacks['$' + event] || []; -}; - -/** - * Check if this emitter has `event` handlers. - * - * @param {String} event - * @return {Boolean} - * @api public - */ - -Emitter.prototype.hasListeners = function(event){ - return !! this.listeners(event).length; -}; + +/** + * Expose `Emitter`. + */ + +module.exports = Emitter; + +/** + * Initialize a new `Emitter`. + * + * @api public + */ + +function Emitter(obj) { + if (obj) return mixin(obj); +}; + +/** + * Mixin the emitter properties. + * + * @param {Object} obj + * @return {Object} + * @api private + */ + +function mixin(obj) { + for (var key in Emitter.prototype) { + obj[key] = Emitter.prototype[key]; + } + return obj; +} + +/** + * Listen on the given `event` with `fn`. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ + +Emitter.prototype.on = +Emitter.prototype.addEventListener = function(event, fn){ + this._callbacks = this._callbacks || {}; + (this._callbacks['$' + event] = this._callbacks['$' + event] || []) + .push(fn); + return this; +}; + +/** + * Adds an `event` listener that will be invoked a single + * time then automatically removed. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ + +Emitter.prototype.once = function(event, fn){ + function on() { + this.off(event, on); + fn.apply(this, arguments); + } + + on.fn = fn; + this.on(event, on); + return this; +}; + +/** + * Remove the given callback for `event` or all + * registered callbacks. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ + +Emitter.prototype.off = +Emitter.prototype.removeListener = +Emitter.prototype.removeAllListeners = +Emitter.prototype.removeEventListener = function(event, fn){ + this._callbacks = this._callbacks || {}; + + // all + if (0 == arguments.length) { + this._callbacks = {}; + return this; + } + + // specific event + var callbacks = this._callbacks['$' + event]; + if (!callbacks) return this; + + // remove all handlers + if (1 == arguments.length) { + delete this._callbacks['$' + event]; + return this; + } + + // remove specific handler + var cb; + for (var i = 0; i < callbacks.length; i++) { + cb = callbacks[i]; + if (cb === fn || cb.fn === fn) { + callbacks.splice(i, 1); + break; + } + } + return this; +}; + +/** + * Emit `event` with the given args. + * + * @param {String} event + * @param {Mixed} ... + * @return {Emitter} + */ + +Emitter.prototype.emit = function(event){ + this._callbacks = this._callbacks || {}; + var args = [].slice.call(arguments, 1) + , callbacks = this._callbacks['$' + event]; + + if (callbacks) { + callbacks = callbacks.slice(0); + for (var i = 0, len = callbacks.length; i < len; ++i) { + callbacks[i].apply(this, args); + } + } + + return this; +}; + +/** + * Return array of callbacks for `event`. + * + * @param {String} event + * @return {Array} + * @api public + */ + +Emitter.prototype.listeners = function(event){ + this._callbacks = this._callbacks || {}; + return this._callbacks['$' + event] || []; +}; + +/** + * Check if this emitter has `event` handlers. + * + * @param {String} event + * @return {Boolean} + * @api public + */ + +Emitter.prototype.hasListeners = function(event){ + return !! this.listeners(event).length; +}; diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-emitter/package.json b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-emitter/package.json index f9b78653..cf788ee5 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-emitter/package.json +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-emitter/package.json @@ -1,174 +1,174 @@ -{ - "name": "component-emitter", - "description": "Event emitter", - "version": "1.2.0", - "license": "MIT", - "devDependencies": { - "mocha": "*", - "should": "*" - }, - "component": { - "scripts": { - "emitter/index.js": "index.js" - } - }, - "main": "index.js", - "repository": { - "type": "git", - "url": "git+https://github.com/component/emitter.git" - }, - "scripts": { - "test": "make test" - }, - "files": [ - "index.js", - "LICENSE" - ], - "gitHead": "4d18307a2cdd2cec16d1fadf9e04f02351a8d62e", - "bugs": { - "url": "https://github.com/component/emitter/issues" - }, - "homepage": "https://github.com/component/emitter", - "_id": "component-emitter@1.2.0", - "_shasum": "ccd113a86388d06482d03de3fc7df98526ba8efe", - "_from": "component-emitter@1.2.0", - "_npmVersion": "2.5.1", - "_nodeVersion": "1.2.0", - "_npmUser": { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - }, - "maintainers": [ - { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - }, - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - { - "name": "rauchg", - "email": "rauchg@gmail.com" - }, - { - "name": "retrofox", - "email": "rdsuarez@gmail.com" - }, - { - "name": "coreh", - "email": "thecoreh@gmail.com" - }, - { - "name": "forbeslindesay", - "email": "forbes@lindesay.co.uk" - }, - { - "name": "kelonye", - "email": "kelonyemitchel@gmail.com" - }, - { - "name": "mattmueller", - "email": "mattmuelle@gmail.com" - }, - { - "name": "yields", - "email": "yields@icloud.com" - }, - { - "name": "anthonyshort", - "email": "antshort@gmail.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "ianstormtaylor", - "email": "ian@ianstormtaylor.com" - }, - { - "name": "cristiandouce", - "email": "cristian@gravityonmars.com" - }, - { - "name": "swatinem", - "email": "arpad.borsos@googlemail.com" - }, - { - "name": "stagas", - "email": "gstagas@gmail.com" - }, - { - "name": "amasad", - "email": "amjad.masad@gmail.com" - }, - { - "name": "juliangruber", - "email": "julian@juliangruber.com" - }, - { - "name": "shtylman", - "email": "shtylman@gmail.com" - }, - { - "name": "calvinfo", - "email": "calvin@calv.info" - }, - { - "name": "dominicbarnes", - "email": "dominic@dbarnes.info" - }, - { - "name": "blakeembrey", - "email": "hello@blakeembrey.com" - }, - { - "name": "timoxley", - "email": "secoif@gmail.com" - }, - { - "name": "jonathanong", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "queckezz", - "email": "fabian.eichenberger@gmail.com" - }, - { - "name": "nami-doc", - "email": "vendethiel@hotmail.fr" - }, - { - "name": "clintwood", - "email": "clint@anotherway.co.za" - }, - { - "name": "thehydroimpulse", - "email": "dnfagnan@gmail.com" - }, - { - "name": "stephenmathieson", - "email": "me@stephenmathieson.com" - }, - { - "name": "trevorgerhardt", - "email": "trevorgerhardt@gmail.com" - }, - { - "name": "timaschew", - "email": "timaschew@gmail.com" - }, - { - "name": "hughsk", - "email": "hughskennedy@gmail.com" - } - ], - "dist": { - "shasum": "ccd113a86388d06482d03de3fc7df98526ba8efe", - "tarball": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.0.tgz", - "readme": "ERROR: No README data found!" -} +{ + "name": "component-emitter", + "description": "Event emitter", + "version": "1.2.0", + "license": "MIT", + "devDependencies": { + "mocha": "*", + "should": "*" + }, + "component": { + "scripts": { + "emitter/index.js": "index.js" + } + }, + "main": "index.js", + "repository": { + "type": "git", + "url": "git+https://github.com/component/emitter.git" + }, + "scripts": { + "test": "make test" + }, + "files": [ + "index.js", + "LICENSE" + ], + "gitHead": "4d18307a2cdd2cec16d1fadf9e04f02351a8d62e", + "bugs": { + "url": "https://github.com/component/emitter/issues" + }, + "homepage": "https://github.com/component/emitter", + "_id": "component-emitter@1.2.0", + "_shasum": "ccd113a86388d06482d03de3fc7df98526ba8efe", + "_from": "component-emitter@1.2.0", + "_npmVersion": "2.5.1", + "_nodeVersion": "1.2.0", + "_npmUser": { + "name": "jongleberry", + "email": "jonathanrichardong@gmail.com" + }, + "maintainers": [ + { + "name": "tootallnate", + "email": "nathan@tootallnate.net" + }, + { + "name": "tjholowaychuk", + "email": "tj@vision-media.ca" + }, + { + "name": "rauchg", + "email": "rauchg@gmail.com" + }, + { + "name": "retrofox", + "email": "rdsuarez@gmail.com" + }, + { + "name": "coreh", + "email": "thecoreh@gmail.com" + }, + { + "name": "forbeslindesay", + "email": "forbes@lindesay.co.uk" + }, + { + "name": "kelonye", + "email": "kelonyemitchel@gmail.com" + }, + { + "name": "mattmueller", + "email": "mattmuelle@gmail.com" + }, + { + "name": "yields", + "email": "yields@icloud.com" + }, + { + "name": "anthonyshort", + "email": "antshort@gmail.com" + }, + { + "name": "jongleberry", + "email": "jonathanrichardong@gmail.com" + }, + { + "name": "ianstormtaylor", + "email": "ian@ianstormtaylor.com" + }, + { + "name": "cristiandouce", + "email": "cristian@gravityonmars.com" + }, + { + "name": "swatinem", + "email": "arpad.borsos@googlemail.com" + }, + { + "name": "stagas", + "email": "gstagas@gmail.com" + }, + { + "name": "amasad", + "email": "amjad.masad@gmail.com" + }, + { + "name": "juliangruber", + "email": "julian@juliangruber.com" + }, + { + "name": "shtylman", + "email": "shtylman@gmail.com" + }, + { + "name": "calvinfo", + "email": "calvin@calv.info" + }, + { + "name": "dominicbarnes", + "email": "dominic@dbarnes.info" + }, + { + "name": "blakeembrey", + "email": "hello@blakeembrey.com" + }, + { + "name": "timoxley", + "email": "secoif@gmail.com" + }, + { + "name": "jonathanong", + "email": "jonathanrichardong@gmail.com" + }, + { + "name": "queckezz", + "email": "fabian.eichenberger@gmail.com" + }, + { + "name": "nami-doc", + "email": "vendethiel@hotmail.fr" + }, + { + "name": "clintwood", + "email": "clint@anotherway.co.za" + }, + { + "name": "thehydroimpulse", + "email": "dnfagnan@gmail.com" + }, + { + "name": "stephenmathieson", + "email": "me@stephenmathieson.com" + }, + { + "name": "trevorgerhardt", + "email": "trevorgerhardt@gmail.com" + }, + { + "name": "timaschew", + "email": "timaschew@gmail.com" + }, + { + "name": "hughsk", + "email": "hughskennedy@gmail.com" + } + ], + "dist": { + "shasum": "ccd113a86388d06482d03de3fc7df98526ba8efe", + "tarball": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.0.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/.npmignore b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/.npmignore index 585e8739..3957910d 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/.npmignore +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/.npmignore @@ -1,2 +1,2 @@ -support/ -test +support/ +test diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/.travis.yml b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/.travis.yml index 05e1ef0a..3eb12a70 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/.travis.yml +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/.travis.yml @@ -1,46 +1,46 @@ -language: node_js -sudo: false -node_js: - - '0.10' - - '0.12' - - '4' -notifications: - irc: "irc.freenode.org#socket.io" -matrix: - include: - - node_js: '0.10' - env: BROWSER_NAME=chrome BROWSER_VERSION=latest - - node_js: '0.10' - env: BROWSER_NAME=safari BROWSER_VERSION=latest - - node_js: '0.10' - env: BROWSER_NAME=ie BROWSER_VERSION=6 - - node_js: '0.10' - env: BROWSER_NAME=ie BROWSER_VERSION=7 - - node_js: '0.10' - env: BROWSER_NAME=ie BROWSER_VERSION=8 - - node_js: '0.10' - env: BROWSER_NAME=ie BROWSER_VERSION=9 - - node_js: '0.10' - env: BROWSER_NAME=ie BROWSER_VERSION=10 BROWSER_PLATFORM="Windows 2012" - - node_js: '0.10' - env: BROWSER_NAME=ie BROWSER_VERSION=latest BROWSER_PLATFORM="Windows 2012" - - node_js: '0.10' - env: BROWSER_NAME=iphone BROWSER_VERSION=5.1 - - node_js: '0.10' - env: BROWSER_NAME=iphone BROWSER_VERSION=6.1 - - node_js: '0.10' - env: BROWSER_NAME=iphone BROWSER_VERSION=7.1 - - node_js: '0.10' - env: BROWSER_NAME=iphone BROWSER_VERSION=8.4 - - node_js: '0.10' - env: BROWSER_NAME=iphone BROWSER_VERSION=latest - - node_js: '0.10' - env: BROWSER_NAME=android BROWSER_VERSION=4.0 - - node_js: '0.10' - env: BROWSER_NAME=android BROWSER_VERSION=4.1 - - node_js: '0.10' - env: BROWSER_NAME=android BROWSER_VERSION=4.2 - - node_js: '0.10' - env: BROWSER_NAME=android BROWSER_VERSION=4.3 - - node_js: '0.10' - env: BROWSER_NAME=android BROWSER_VERSION=4.4 +language: node_js +sudo: false +node_js: + - '0.10' + - '0.12' + - '4' +notifications: + irc: "irc.freenode.org#socket.io" +matrix: + include: + - node_js: '0.10' + env: BROWSER_NAME=chrome BROWSER_VERSION=latest + - node_js: '0.10' + env: BROWSER_NAME=safari BROWSER_VERSION=latest + - node_js: '0.10' + env: BROWSER_NAME=ie BROWSER_VERSION=6 + - node_js: '0.10' + env: BROWSER_NAME=ie BROWSER_VERSION=7 + - node_js: '0.10' + env: BROWSER_NAME=ie BROWSER_VERSION=8 + - node_js: '0.10' + env: BROWSER_NAME=ie BROWSER_VERSION=9 + - node_js: '0.10' + env: BROWSER_NAME=ie BROWSER_VERSION=10 BROWSER_PLATFORM="Windows 2012" + - node_js: '0.10' + env: BROWSER_NAME=ie BROWSER_VERSION=latest BROWSER_PLATFORM="Windows 2012" + - node_js: '0.10' + env: BROWSER_NAME=iphone BROWSER_VERSION=5.1 + - node_js: '0.10' + env: BROWSER_NAME=iphone BROWSER_VERSION=6.1 + - node_js: '0.10' + env: BROWSER_NAME=iphone BROWSER_VERSION=7.1 + - node_js: '0.10' + env: BROWSER_NAME=iphone BROWSER_VERSION=8.4 + - node_js: '0.10' + env: BROWSER_NAME=iphone BROWSER_VERSION=latest + - node_js: '0.10' + env: BROWSER_NAME=android BROWSER_VERSION=4.0 + - node_js: '0.10' + env: BROWSER_NAME=android BROWSER_VERSION=4.1 + - node_js: '0.10' + env: BROWSER_NAME=android BROWSER_VERSION=4.2 + - node_js: '0.10' + env: BROWSER_NAME=android BROWSER_VERSION=4.3 + - node_js: '0.10' + env: BROWSER_NAME=android BROWSER_VERSION=4.4 diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/.zuul.yml b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/.zuul.yml index 794b0cbb..15d68929 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/.zuul.yml +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/.zuul.yml @@ -1,6 +1,6 @@ -ui: mocha-bdd -server: ./test/support/server.js -tunnel: - type: ngrok - authtoken: 6Aw8vTgcG5EvXdQywVvbh_3fMxvd4Q7dcL2caAHAFjV - proto: tcp +ui: mocha-bdd +server: ./test/support/server.js +tunnel: + type: ngrok + authtoken: 6Aw8vTgcG5EvXdQywVvbh_3fMxvd4Q7dcL2caAHAFjV + proto: tcp diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/History.md b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/History.md index 15cac8ab..7b1dc9b6 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/History.md +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/History.md @@ -1,568 +1,568 @@ - -1.6.11 / 2016-06-23 -=================== - - * bump version - -1.6.10 / 2016-06-23 -=================== - - * bump version - -1.6.9 / 2016-05-02 -================== - - * default `rejectUnauthorized` to `true` - -1.6.8 / 2016-01-25 -================== - - * safely resolve `ws` module - -1.6.7 / 2016-01-10 -================== - - * prevent `ws` from being added to the bundle - * added jsonp fix for when no ` - -``` - -### With browserify - -Engine.IO is a commonjs module, which means you can include it by using -`require` on the browser and package using [browserify](http://browserify.org/): - -1. install the client package - - ```bash - $ npm install engine.io-client - ``` - -1. write your app code - - ```js - var socket = require('engine.io-client')('ws://localhost'); - socket.on('open', function(){ - socket.on('message', function(data){}); - socket.on('close', function(){}); - }); - ``` - -1. build your app bundle - - ```bash - $ browserify app.js > bundle.js - ``` - -1. include on your page - - ```html - - ``` - -### Sending and receiving binary - -```html - - -``` - -### Node.JS - -Add `engine.io-client` to your `package.json` and then: - -```js -var socket = require('engine.io-client')('ws://localhost'); -socket.on('open', function(){ - socket.on('message', function(data){}); - socket.on('close', function(){}); -}); -``` - -### Node.js with certificates -```js -var opts = { - key: fs.readFileSync('test/fixtures/client.key'), - cert: fs.readFileSync('test/fixtures/client.crt'), - ca: fs.readFileSync('test/fixtures/ca.crt') -}; - -var socket = require('engine.io-client')('ws://localhost', opts); -socket.on('open', function(){ - socket.on('message', function(data){}); - socket.on('close', function(){}); -}); -``` - -### Node.js with extraHeaders -```js -var opts = { - extraHeaders: { - 'X-Custom-Header-For-My-Project': 'my-secret-access-token', - 'Cookie': 'user_session=NI2JlCKF90aE0sJZD9ZzujtdsUqNYSBYxzlTsvdSUe35ZzdtVRGqYFr0kdGxbfc5gUOkR9RGp20GVKza; path=/; expires=Tue, 07-Apr-2015 18:18:08 GMT; secure; HttpOnly' - } -}; - -var socket = require('engine.io-client')('ws://localhost', opts); -socket.on('open', function(){ - socket.on('message', function(data){}); - socket.on('close', function(){}); -}); -``` - -## Features - -- Lightweight -- Runs on browser and node.js seamlessly -- Transports are independent of `Engine` - - Easy to debug - - Easy to unit test -- Runs inside HTML5 WebWorker -- Can send and receive binary data - - Receives as ArrayBuffer or Blob when in browser, and Buffer or ArrayBuffer - in Node - - When XHR2 or WebSockets are used, binary is emitted directly. Otherwise - binary is encoded into base64 strings, and decoded when binary types are - supported. - - With browsers that don't support ArrayBuffer, an object { base64: true, - data: dataAsBase64String } is emitted on the `message` event. - -## API - -### Socket - -The client class. Mixes in [Emitter](http://github.com/component/emitter). -Exposed as `eio` in the browser standalone build. - -#### Properties - -- `protocol` _(Number)_: protocol revision number -- `binaryType` _(String)_ : can be set to 'arraybuffer' or 'blob' in browsers, - and `buffer` or `arraybuffer` in Node. Blob is only used in browser if it's - supported. - -#### Events - -- `open` - - Fired upon successful connection. -- `message` - - Fired when data is received from the server. - - **Arguments** - - `String` | `ArrayBuffer`: utf-8 encoded data or ArrayBuffer containing - binary data -- `close` - - Fired upon disconnection. In compliance with the WebSocket API spec, this event may be - fired even if the `open` event does not occur (i.e. due to connection error or `close()`). -- `error` - - Fired when an error occurs. -- `flush` - - Fired upon completing a buffer flush -- `drain` - - Fired after `drain` event of transport if writeBuffer is empty -- `upgradeError` - - Fired if an error occurs with a transport we're trying to upgrade to. -- `upgrade` - - Fired upon upgrade success, after the new transport is set -- `ping` - - Fired upon _flushing_ a ping packet (ie: actual packet write out) -- `pong` - - Fired upon receiving a pong packet. - -#### Methods - -- **constructor** - - Initializes the client - - **Parameters** - - `String` uri - - `Object`: optional, options object - - **Options** - - `agent` (`http.Agent`): `http.Agent` to use, defaults to `false` (NodeJS only) - - `upgrade` (`Boolean`): defaults to true, whether the client should try - to upgrade the transport from long-polling to something better. - - `forceJSONP` (`Boolean`): forces JSONP for polling transport. - - `jsonp` (`Boolean`): determines whether to use JSONP when - necessary for polling. If disabled (by settings to false) an error will - be emitted (saying "No transports available") if no other transports - are available. If another transport is available for opening a - connection (e.g. WebSocket) that transport - will be used instead. - - `forceBase64` (`Boolean`): forces base 64 encoding for polling transport even when XHR2 responseType is available and WebSocket even if the used standard supports binary. - - `enablesXDR` (`Boolean`): enables XDomainRequest for IE8 to avoid loading bar flashing with click sound. default to `false` because XDomainRequest has a flaw of not sending cookie. - - `timestampRequests` (`Boolean`): whether to add the timestamp with each - transport request. Note: polling requests are always stamped unless this - option is explicitly set to `false` (`false`) - - `timestampParam` (`String`): timestamp parameter (`t`) - - `policyPort` (`Number`): port the policy server listens on (`843`) - - `path` (`String`): path to connect to, default is `/engine.io` - - `transports` (`Array`): a list of transports to try (in order). - Defaults to `['polling', 'websocket']`. `Engine` - always attempts to connect directly with the first one, provided the - feature detection test for it passes. - - `rememberUpgrade` (`Boolean`): defaults to false. - If true and if the previous websocket connection to the server succeeded, - the connection attempt will bypass the normal upgrade process and will initially - try websocket. A connection attempt following a transport error will use the - normal upgrade process. It is recommended you turn this on only when using - SSL/TLS connections, or if you know that your network does not block websockets. - - `pfx` (`String`): Certificate, Private key and CA certificates to use for SSL. Can be used in Node.js client environment to manually specify certificate information. - - `key` (`String`): Private key to use for SSL. Can be used in Node.js client environment to manually specify certificate information. - - `passphrase` (`String`): A string of passphrase for the private key or pfx. Can be used in Node.js client environment to manually specify certificate information. - - `cert` (`String`): Public x509 certificate to use. Can be used in Node.js client environment to manually specify certificate information. - - `ca` (`String`|`Array`): An authority certificate or array of authority certificates to check the remote host against.. Can be used in Node.js client environment to manually specify certificate information. - - `ciphers` (`String`): A string describing the ciphers to use or exclude. Consult the [cipher format list](http://www.openssl.org/docs/apps/ciphers.html#CIPHER_LIST_FORMAT) for details on the format. Can be used in Node.js client environment to manually specify certificate information. - - `rejectUnauthorized` (`Boolean`): If true, the server certificate is verified against the list of supplied CAs. An 'error' event is emitted if verification fails. Verification happens at the connection level, before the HTTP request is sent. Can be used in Node.js client environment to manually specify certificate information. - - `perMessageDeflate` (`Object|Boolean`): parameters of the WebSocket permessage-deflate extension - (see [ws module](https://github.com/einaros/ws) api docs). Set to `false` to disable. (`true`) - - `threshold` (`Number`): data is compressed only if the byte size is above this value. This option is ignored on the browser. (`1024`) - - `extraHeaders` (`Object`): Headers that will be passed for each request to the server (via xhr-polling and via websockets). These values then can be used during handshake or for special proxies. Can only be used in Node.js client environment. -- `send` - - Sends a message to the server - - **Parameters** - - `String` | `ArrayBuffer` | `ArrayBufferView` | `Blob`: data to send - - `Object`: optional, options object - - `Function`: optional, callback upon `drain` - - **Options** - - `compress` (`Boolean`): whether to compress sending data. This option is ignored and forced to be `true` on the browser. (`true`) -- `close` - - Disconnects the client. - -### Transport - -The transport class. Private. _Inherits from EventEmitter_. - -#### Events - -- `poll`: emitted by polling transports upon starting a new request -- `pollComplete`: emitted by polling transports upon completing a request -- `drain`: emitted by polling transports upon a buffer drain - -## Tests - -`engine.io-client` is used to test -[engine](http://github.com/socketio/engine.io). Running the `engine.io` -test suite ensures the client works and vice-versa. - -Browser tests are run using [zuul](https://github.com/defunctzombie/zuul). You can -run the tests locally using the following command. - -``` -./node_modules/.bin/zuul --local 8080 -- test/index.js -``` - -Additionally, `engine.io-client` has a standalone test suite you can run -with `make test` which will run node.js and browser tests. You must have zuul setup with -a saucelabs account. - -## Support - -The support channels for `engine.io-client` are the same as `socket.io`: - - irc.freenode.net **#socket.io** - - [Google Groups](http://groups.google.com/group/socket_io) - - [Website](http://socket.io) - -## Development - -To contribute patches, run tests or benchmarks, make sure to clone the -repository: - -```bash -git clone git://github.com/socketio/engine.io-client.git -``` - -Then: - -```bash -cd engine.io-client -npm install -``` - -See the `Tests` section above for how to run tests before submitting any patches. - -## License - -MIT - Copyright (c) 2014 Automattic, Inc. - + +# Engine.IO client + +[![Build Status](https://secure.travis-ci.org/socketio/engine.io-client.svg)](http://travis-ci.org/socketio/engine.io-client) +[![NPM version](https://badge.fury.io/js/engine.io-client.svg)](http://badge.fury.io/js/engine.io-client) + +This is the client for [Engine.IO](http://github.com/socketio/engine.io), +the implementation of transport-based cross-browser/cross-device +bi-directional communication layer for [Socket.IO](http://github.com/socketio/socket.io). + +## How to use + +### Standalone + +You can find an `engine.io.js` file in this repository, which is a +standalone build you can use as follows: + +```html + + +``` + +### With browserify + +Engine.IO is a commonjs module, which means you can include it by using +`require` on the browser and package using [browserify](http://browserify.org/): + +1. install the client package + + ```bash + $ npm install engine.io-client + ``` + +1. write your app code + + ```js + var socket = require('engine.io-client')('ws://localhost'); + socket.on('open', function(){ + socket.on('message', function(data){}); + socket.on('close', function(){}); + }); + ``` + +1. build your app bundle + + ```bash + $ browserify app.js > bundle.js + ``` + +1. include on your page + + ```html + + ``` + +### Sending and receiving binary + +```html + + +``` + +### Node.JS + +Add `engine.io-client` to your `package.json` and then: + +```js +var socket = require('engine.io-client')('ws://localhost'); +socket.on('open', function(){ + socket.on('message', function(data){}); + socket.on('close', function(){}); +}); +``` + +### Node.js with certificates +```js +var opts = { + key: fs.readFileSync('test/fixtures/client.key'), + cert: fs.readFileSync('test/fixtures/client.crt'), + ca: fs.readFileSync('test/fixtures/ca.crt') +}; + +var socket = require('engine.io-client')('ws://localhost', opts); +socket.on('open', function(){ + socket.on('message', function(data){}); + socket.on('close', function(){}); +}); +``` + +### Node.js with extraHeaders +```js +var opts = { + extraHeaders: { + 'X-Custom-Header-For-My-Project': 'my-secret-access-token', + 'Cookie': 'user_session=NI2JlCKF90aE0sJZD9ZzujtdsUqNYSBYxzlTsvdSUe35ZzdtVRGqYFr0kdGxbfc5gUOkR9RGp20GVKza; path=/; expires=Tue, 07-Apr-2015 18:18:08 GMT; secure; HttpOnly' + } +}; + +var socket = require('engine.io-client')('ws://localhost', opts); +socket.on('open', function(){ + socket.on('message', function(data){}); + socket.on('close', function(){}); +}); +``` + +## Features + +- Lightweight +- Runs on browser and node.js seamlessly +- Transports are independent of `Engine` + - Easy to debug + - Easy to unit test +- Runs inside HTML5 WebWorker +- Can send and receive binary data + - Receives as ArrayBuffer or Blob when in browser, and Buffer or ArrayBuffer + in Node + - When XHR2 or WebSockets are used, binary is emitted directly. Otherwise + binary is encoded into base64 strings, and decoded when binary types are + supported. + - With browsers that don't support ArrayBuffer, an object { base64: true, + data: dataAsBase64String } is emitted on the `message` event. + +## API + +### Socket + +The client class. Mixes in [Emitter](http://github.com/component/emitter). +Exposed as `eio` in the browser standalone build. + +#### Properties + +- `protocol` _(Number)_: protocol revision number +- `binaryType` _(String)_ : can be set to 'arraybuffer' or 'blob' in browsers, + and `buffer` or `arraybuffer` in Node. Blob is only used in browser if it's + supported. + +#### Events + +- `open` + - Fired upon successful connection. +- `message` + - Fired when data is received from the server. + - **Arguments** + - `String` | `ArrayBuffer`: utf-8 encoded data or ArrayBuffer containing + binary data +- `close` + - Fired upon disconnection. In compliance with the WebSocket API spec, this event may be + fired even if the `open` event does not occur (i.e. due to connection error or `close()`). +- `error` + - Fired when an error occurs. +- `flush` + - Fired upon completing a buffer flush +- `drain` + - Fired after `drain` event of transport if writeBuffer is empty +- `upgradeError` + - Fired if an error occurs with a transport we're trying to upgrade to. +- `upgrade` + - Fired upon upgrade success, after the new transport is set +- `ping` + - Fired upon _flushing_ a ping packet (ie: actual packet write out) +- `pong` + - Fired upon receiving a pong packet. + +#### Methods + +- **constructor** + - Initializes the client + - **Parameters** + - `String` uri + - `Object`: optional, options object + - **Options** + - `agent` (`http.Agent`): `http.Agent` to use, defaults to `false` (NodeJS only) + - `upgrade` (`Boolean`): defaults to true, whether the client should try + to upgrade the transport from long-polling to something better. + - `forceJSONP` (`Boolean`): forces JSONP for polling transport. + - `jsonp` (`Boolean`): determines whether to use JSONP when + necessary for polling. If disabled (by settings to false) an error will + be emitted (saying "No transports available") if no other transports + are available. If another transport is available for opening a + connection (e.g. WebSocket) that transport + will be used instead. + - `forceBase64` (`Boolean`): forces base 64 encoding for polling transport even when XHR2 responseType is available and WebSocket even if the used standard supports binary. + - `enablesXDR` (`Boolean`): enables XDomainRequest for IE8 to avoid loading bar flashing with click sound. default to `false` because XDomainRequest has a flaw of not sending cookie. + - `timestampRequests` (`Boolean`): whether to add the timestamp with each + transport request. Note: polling requests are always stamped unless this + option is explicitly set to `false` (`false`) + - `timestampParam` (`String`): timestamp parameter (`t`) + - `policyPort` (`Number`): port the policy server listens on (`843`) + - `path` (`String`): path to connect to, default is `/engine.io` + - `transports` (`Array`): a list of transports to try (in order). + Defaults to `['polling', 'websocket']`. `Engine` + always attempts to connect directly with the first one, provided the + feature detection test for it passes. + - `rememberUpgrade` (`Boolean`): defaults to false. + If true and if the previous websocket connection to the server succeeded, + the connection attempt will bypass the normal upgrade process and will initially + try websocket. A connection attempt following a transport error will use the + normal upgrade process. It is recommended you turn this on only when using + SSL/TLS connections, or if you know that your network does not block websockets. + - `pfx` (`String`): Certificate, Private key and CA certificates to use for SSL. Can be used in Node.js client environment to manually specify certificate information. + - `key` (`String`): Private key to use for SSL. Can be used in Node.js client environment to manually specify certificate information. + - `passphrase` (`String`): A string of passphrase for the private key or pfx. Can be used in Node.js client environment to manually specify certificate information. + - `cert` (`String`): Public x509 certificate to use. Can be used in Node.js client environment to manually specify certificate information. + - `ca` (`String`|`Array`): An authority certificate or array of authority certificates to check the remote host against.. Can be used in Node.js client environment to manually specify certificate information. + - `ciphers` (`String`): A string describing the ciphers to use or exclude. Consult the [cipher format list](http://www.openssl.org/docs/apps/ciphers.html#CIPHER_LIST_FORMAT) for details on the format. Can be used in Node.js client environment to manually specify certificate information. + - `rejectUnauthorized` (`Boolean`): If true, the server certificate is verified against the list of supplied CAs. An 'error' event is emitted if verification fails. Verification happens at the connection level, before the HTTP request is sent. Can be used in Node.js client environment to manually specify certificate information. + - `perMessageDeflate` (`Object|Boolean`): parameters of the WebSocket permessage-deflate extension + (see [ws module](https://github.com/einaros/ws) api docs). Set to `false` to disable. (`true`) + - `threshold` (`Number`): data is compressed only if the byte size is above this value. This option is ignored on the browser. (`1024`) + - `extraHeaders` (`Object`): Headers that will be passed for each request to the server (via xhr-polling and via websockets). These values then can be used during handshake or for special proxies. Can only be used in Node.js client environment. +- `send` + - Sends a message to the server + - **Parameters** + - `String` | `ArrayBuffer` | `ArrayBufferView` | `Blob`: data to send + - `Object`: optional, options object + - `Function`: optional, callback upon `drain` + - **Options** + - `compress` (`Boolean`): whether to compress sending data. This option is ignored and forced to be `true` on the browser. (`true`) +- `close` + - Disconnects the client. + +### Transport + +The transport class. Private. _Inherits from EventEmitter_. + +#### Events + +- `poll`: emitted by polling transports upon starting a new request +- `pollComplete`: emitted by polling transports upon completing a request +- `drain`: emitted by polling transports upon a buffer drain + +## Tests + +`engine.io-client` is used to test +[engine](http://github.com/socketio/engine.io). Running the `engine.io` +test suite ensures the client works and vice-versa. + +Browser tests are run using [zuul](https://github.com/defunctzombie/zuul). You can +run the tests locally using the following command. + +``` +./node_modules/.bin/zuul --local 8080 -- test/index.js +``` + +Additionally, `engine.io-client` has a standalone test suite you can run +with `make test` which will run node.js and browser tests. You must have zuul setup with +a saucelabs account. + +## Support + +The support channels for `engine.io-client` are the same as `socket.io`: + - irc.freenode.net **#socket.io** + - [Google Groups](http://groups.google.com/group/socket_io) + - [Website](http://socket.io) + +## Development + +To contribute patches, run tests or benchmarks, make sure to clone the +repository: + +```bash +git clone git://github.com/socketio/engine.io-client.git +``` + +Then: + +```bash +cd engine.io-client +npm install +``` + +See the `Tests` section above for how to run tests before submitting any patches. + +## License + +MIT - Copyright (c) 2014 Automattic, Inc. + diff --git a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/engine.io.js b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/engine.io.js index 77b96141..eeefaa91 100644 --- a/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/engine.io.js +++ b/ui/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/engine.io.js @@ -1,4244 +1,4244 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.eio=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0) { - this.extraHeaders = opts.extraHeaders; - } - } - - this.open(); -} - -Socket.priorWebsocketSuccess = false; - -/** - * Mix in `Emitter`. - */ - -Emitter(Socket.prototype); - -/** - * Protocol version. - * - * @api public - */ - -Socket.protocol = parser.protocol; // this is an int - -/** - * Expose deps for legacy compatibility - * and standalone browser access. - */ - -Socket.Socket = Socket; -Socket.Transport = _dereq_('./transport'); -Socket.transports = _dereq_('./transports'); -Socket.parser = _dereq_('engine.io-parser'); - -/** - * Creates transport of the given type. - * - * @param {String} transport name - * @return {Transport} - * @api private - */ - -Socket.prototype.createTransport = function (name) { - debug('creating transport "%s"', name); - var query = clone(this.query); - - // append engine.io protocol identifier - query.EIO = parser.protocol; - - // transport name - query.transport = name; - - // session id if we already have one - if (this.id) query.sid = this.id; - - var transport = new transports[name]({ - agent: this.agent, - hostname: this.hostname, - port: this.port, - secure: this.secure, - path: this.path, - query: query, - forceJSONP: this.forceJSONP, - jsonp: this.jsonp, - forceBase64: this.forceBase64, - enablesXDR: this.enablesXDR, - timestampRequests: this.timestampRequests, - timestampParam: this.timestampParam, - policyPort: this.policyPort, - socket: this, - pfx: this.pfx, - key: this.key, - passphrase: this.passphrase, - cert: this.cert, - ca: this.ca, - ciphers: this.ciphers, - rejectUnauthorized: this.rejectUnauthorized, - perMessageDeflate: this.perMessageDeflate, - extraHeaders: this.extraHeaders - }); - - return transport; -}; - -function clone (obj) { - var o = {}; - for (var i in obj) { - if (obj.hasOwnProperty(i)) { - o[i] = obj[i]; - } - } - return o; -} - -/** - * Initializes transport to use and starts probe. - * - * @api private - */ -Socket.prototype.open = function () { - var transport; - if (this.rememberUpgrade && Socket.priorWebsocketSuccess && this.transports.indexOf('websocket') != -1) { - transport = 'websocket'; - } else if (0 === this.transports.length) { - // Emit error on next tick so it can be listened to - var self = this; - setTimeout(function() { - self.emit('error', 'No transports available'); - }, 0); - return; - } else { - transport = this.transports[0]; - } - this.readyState = 'opening'; - - // Retry with the next transport if the transport is disabled (jsonp: false) - try { - transport = this.createTransport(transport); - } catch (e) { - this.transports.shift(); - this.open(); - return; - } - - transport.open(); - this.setTransport(transport); -}; - -/** - * Sets the current transport. Disables the existing one (if any). - * - * @api private - */ - -Socket.prototype.setTransport = function(transport){ - debug('setting transport %s', transport.name); - var self = this; - - if (this.transport) { - debug('clearing existing transport %s', this.transport.name); - this.transport.removeAllListeners(); - } - - // set up transport - this.transport = transport; - - // set up transport listeners - transport - .on('drain', function(){ - self.onDrain(); - }) - .on('packet', function(packet){ - self.onPacket(packet); - }) - .on('error', function(e){ - self.onError(e); - }) - .on('close', function(){ - self.onClose('transport close'); - }); -}; - -/** - * Probes a transport. - * - * @param {String} transport name - * @api private - */ - -Socket.prototype.probe = function (name) { - debug('probing transport "%s"', name); - var transport = this.createTransport(name, { probe: 1 }) - , failed = false - , self = this; - - Socket.priorWebsocketSuccess = false; - - function onTransportOpen(){ - if (self.onlyBinaryUpgrades) { - var upgradeLosesBinary = !this.supportsBinary && self.transport.supportsBinary; - failed = failed || upgradeLosesBinary; - } - if (failed) return; - - debug('probe transport "%s" opened', name); - transport.send([{ type: 'ping', data: 'probe' }]); - transport.once('packet', function (msg) { - if (failed) return; - if ('pong' == msg.type && 'probe' == msg.data) { - debug('probe transport "%s" pong', name); - self.upgrading = true; - self.emit('upgrading', transport); - if (!transport) return; - Socket.priorWebsocketSuccess = 'websocket' == transport.name; - - debug('pausing current transport "%s"', self.transport.name); - self.transport.pause(function () { - if (failed) return; - if ('closed' == self.readyState) return; - debug('changing transport and sending upgrade packet'); - - cleanup(); - - self.setTransport(transport); - transport.send([{ type: 'upgrade' }]); - self.emit('upgrade', transport); - transport = null; - self.upgrading = false; - self.flush(); - }); - } else { - debug('probe transport "%s" failed', name); - var err = new Error('probe error'); - err.transport = transport.name; - self.emit('upgradeError', err); - } - }); - } - - function freezeTransport() { - if (failed) return; - - // Any callback called by transport should be ignored since now - failed = true; - - cleanup(); - - transport.close(); - transport = null; - } - - //Handle any error that happens while probing - function onerror(err) { - var error = new Error('probe error: ' + err); - error.transport = transport.name; - - freezeTransport(); - - debug('probe transport "%s" failed because of error: %s', name, err); - - self.emit('upgradeError', error); - } - - function onTransportClose(){ - onerror("transport closed"); - } - - //When the socket is closed while we're probing - function onclose(){ - onerror("socket closed"); - } - - //When the socket is upgraded while we're probing - function onupgrade(to){ - if (transport && to.name != transport.name) { - debug('"%s" works - aborting "%s"', to.name, transport.name); - freezeTransport(); - } - } - - //Remove all listeners on the transport and on self - function cleanup(){ - transport.removeListener('open', onTransportOpen); - transport.removeListener('error', onerror); - transport.removeListener('close', onTransportClose); - self.removeListener('close', onclose); - self.removeListener('upgrading', onupgrade); - } - - transport.once('open', onTransportOpen); - transport.once('error', onerror); - transport.once('close', onTransportClose); - - this.once('close', onclose); - this.once('upgrading', onupgrade); - - transport.open(); - -}; - -/** - * Called when connection is deemed open. - * - * @api public - */ - -Socket.prototype.onOpen = function () { - debug('socket open'); - this.readyState = 'open'; - Socket.priorWebsocketSuccess = 'websocket' == this.transport.name; - this.emit('open'); - this.flush(); - - // we check for `readyState` in case an `open` - // listener already closed the socket - if ('open' == this.readyState && this.upgrade && this.transport.pause) { - debug('starting upgrade probes'); - for (var i = 0, l = this.upgrades.length; i < l; i++) { - this.probe(this.upgrades[i]); - } - } -}; - -/** - * Handles a packet. - * - * @api private - */ - -Socket.prototype.onPacket = function (packet) { - if ('opening' == this.readyState || 'open' == this.readyState) { - debug('socket receive: type "%s", data "%s"', packet.type, packet.data); - - this.emit('packet', packet); - - // Socket is live - any packet counts - this.emit('heartbeat'); - - switch (packet.type) { - case 'open': - this.onHandshake(parsejson(packet.data)); - break; - - case 'pong': - this.setPing(); - this.emit('pong'); - break; - - case 'error': - var err = new Error('server error'); - err.code = packet.data; - this.onError(err); - break; - - case 'message': - this.emit('data', packet.data); - this.emit('message', packet.data); - break; - } - } else { - debug('packet received with socket readyState "%s"', this.readyState); - } -}; - -/** - * Called upon handshake completion. - * - * @param {Object} handshake obj - * @api private - */ - -Socket.prototype.onHandshake = function (data) { - this.emit('handshake', data); - this.id = data.sid; - this.transport.query.sid = data.sid; - this.upgrades = this.filterUpgrades(data.upgrades); - this.pingInterval = data.pingInterval; - this.pingTimeout = data.pingTimeout; - this.onOpen(); - // In case open handler closes socket - if ('closed' == this.readyState) return; - this.setPing(); - - // Prolong liveness of socket on heartbeat - this.removeListener('heartbeat', this.onHeartbeat); - this.on('heartbeat', this.onHeartbeat); -}; - -/** - * Resets ping timeout. - * - * @api private - */ - -Socket.prototype.onHeartbeat = function (timeout) { - clearTimeout(this.pingTimeoutTimer); - var self = this; - self.pingTimeoutTimer = setTimeout(function () { - if ('closed' == self.readyState) return; - self.onClose('ping timeout'); - }, timeout || (self.pingInterval + self.pingTimeout)); -}; - -/** - * Pings server every `this.pingInterval` and expects response - * within `this.pingTimeout` or closes connection. - * - * @api private - */ - -Socket.prototype.setPing = function () { - var self = this; - clearTimeout(self.pingIntervalTimer); - self.pingIntervalTimer = setTimeout(function () { - debug('writing ping packet - expecting pong within %sms', self.pingTimeout); - self.ping(); - self.onHeartbeat(self.pingTimeout); - }, self.pingInterval); -}; - -/** -* Sends a ping packet. -* -* @api private -*/ - -Socket.prototype.ping = function () { - var self = this; - this.sendPacket('ping', function(){ - self.emit('ping'); - }); -}; - -/** - * Called on `drain` event - * - * @api private - */ - -Socket.prototype.onDrain = function() { - this.writeBuffer.splice(0, this.prevBufferLen); - - // setting prevBufferLen = 0 is very important - // for example, when upgrading, upgrade packet is sent over, - // and a nonzero prevBufferLen could cause problems on `drain` - this.prevBufferLen = 0; - - if (0 === this.writeBuffer.length) { - this.emit('drain'); - } else { - this.flush(); - } -}; - -/** - * Flush write buffers. - * - * @api private - */ - -Socket.prototype.flush = function () { - if ('closed' != this.readyState && this.transport.writable && - !this.upgrading && this.writeBuffer.length) { - debug('flushing %d packets in socket', this.writeBuffer.length); - this.transport.send(this.writeBuffer); - // keep track of current length of writeBuffer - // splice writeBuffer and callbackBuffer on `drain` - this.prevBufferLen = this.writeBuffer.length; - this.emit('flush'); - } -}; - -/** - * Sends a message. - * - * @param {String} message. - * @param {Function} callback function. - * @param {Object} options. - * @return {Socket} for chaining. - * @api public - */ - -Socket.prototype.write = -Socket.prototype.send = function (msg, options, fn) { - this.sendPacket('message', msg, options, fn); - return this; -}; - -/** - * Sends a packet. - * - * @param {String} packet type. - * @param {String} data. - * @param {Object} options. - * @param {Function} callback function. - * @api private - */ - -Socket.prototype.sendPacket = function (type, data, options, fn) { - if('function' == typeof data) { - fn = data; - data = undefined; - } - - if ('function' == typeof options) { - fn = options; - options = null; - } - - if ('closing' == this.readyState || 'closed' == this.readyState) { - return; - } - - options = options || {}; - options.compress = false !== options.compress; - - var packet = { - type: type, - data: data, - options: options - }; - this.emit('packetCreate', packet); - this.writeBuffer.push(packet); - if (fn) this.once('flush', fn); - this.flush(); -}; - -/** - * Closes the connection. - * - * @api private - */ - -Socket.prototype.close = function () { - if ('opening' == this.readyState || 'open' == this.readyState) { - this.readyState = 'closing'; - - var self = this; - - if (this.writeBuffer.length) { - this.once('drain', function() { - if (this.upgrading) { - waitForUpgrade(); - } else { - close(); - } - }); - } else if (this.upgrading) { - waitForUpgrade(); - } else { - close(); - } - } - - function close() { - self.onClose('forced close'); - debug('socket closing - telling transport to close'); - self.transport.close(); - } - - function cleanupAndClose() { - self.removeListener('upgrade', cleanupAndClose); - self.removeListener('upgradeError', cleanupAndClose); - close(); - } - - function waitForUpgrade() { - // wait for upgrade to finish since we can't send packets while pausing a transport - self.once('upgrade', cleanupAndClose); - self.once('upgradeError', cleanupAndClose); - } - - return this; -}; - -/** - * Called upon transport error - * - * @api private - */ - -Socket.prototype.onError = function (err) { - debug('socket error %j', err); - Socket.priorWebsocketSuccess = false; - this.emit('error', err); - this.onClose('transport error', err); -}; - -/** - * Called upon transport close. - * - * @api private - */ - -Socket.prototype.onClose = function (reason, desc) { - if ('opening' == this.readyState || 'open' == this.readyState || 'closing' == this.readyState) { - debug('socket close with reason: "%s"', reason); - var self = this; - - // clear timers - clearTimeout(this.pingIntervalTimer); - clearTimeout(this.pingTimeoutTimer); - - // stop event from firing again for transport - this.transport.removeAllListeners('close'); - - // ensure transport won't stay open - this.transport.close(); - - // ignore further transport communication - this.transport.removeAllListeners(); - - // set ready state - this.readyState = 'closed'; - - // clear session id - this.id = null; - - // emit close event - this.emit('close', reason, desc); - - // clean buffers after, so users can still - // grab the buffers on `close` event - self.writeBuffer = []; - self.prevBufferLen = 0; - } -}; - -/** - * Filters upgrades, returning only those matching client transports. - * - * @param {Array} server upgrades - * @api private - * - */ - -Socket.prototype.filterUpgrades = function (upgrades) { - var filteredUpgrades = []; - for (var i = 0, j = upgrades.length; i