[
  {
    "path": ".gitattributes",
    "content": "# normalize all text\n# when committed they are stored with LF,\n# on checkout they are converted to the OS's native line endings\n# https://help.github.com/articles/dealing-with-line-endings\n\n*.java text\n*.scala text\n*.sh text\n\n*.xml text\n*.json text\n*.nt text\n\n*.md text\n"
  },
  {
    "path": ".gitignore",
    "content": ".idea\n\nsyntax: glob\n*.iml\n*.ipr\n*.iws\ntarget/*\n\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: java\njdk:\n  - oraclejdk8\n\n\n# Workaround for https://github.com/travis-ci/travis-ci/issues/5227\n# Buffer overflow in Java_java_net_Inet4AddressImpl_getLocalHostName\nbefore_install:\n  - cat /etc/hosts # optionally check the content *before*\n  - sudo hostname \"$(hostname | cut -c1-63)\"\n  - sed -e \"s/^\\\\(127\\\\.0\\\\.0\\\\.1.*\\\\)/\\\\1 $(hostname | cut -c1-63)/\" /etc/hosts | sudo tee /etc/hosts\n  - cat /etc/hosts # optionally check the content *after*\n\n\nbranches:\n  only:\n    - master\ninstall: /bin/true\nscript: \"mvn clean install\"\nnotifications:\n  email:\n    recipients:\n      - dbpedia-developers@lists.sourceforge.net\n    on_success: change \n    on_failure: change\n"
  },
  {
    "path": "LICENSE",
    "content": "\n                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright [yyyy] [name of copyright owner]\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "README.md",
    "content": "# IMPORTANT NOTE:\nThere is a newer and DBpedia Databus compatible version of the DBpedia Lookup here: https://github.com/dbpedia/dbpedia-lookup. The discussion concerning the transition to the new service can be found here: https://forum.dbpedia.org/t/new-dbpedia-lookup-application/607\n\n\n# DBpedia Lookup\n\n[![Build Status](https://travis-ci.org/dbpedia/lookup.svg?branch=master)](https://travis-ci.org/dbpedia/lookup)\n\nDBpedia Lookup is a web service that can be used to look up DBpedia URIs by related keywords. Related means that either the label of a resource matches, or an anchor text that was frequently used in Wikipedia to refer to a specific resource matches (for example the resource http://dbpedia.org/resource/United_States can be looked up by the string \"USA\"). The results are ranked by the number of inlinks pointing from other Wikipedia pages at a result page.\n\n\n## Web APIs\n\nTwo APIs are offered: Keyword Search and Prefix Search. A hosted version of the Lookup service is available on the DBpedia server infrastructure.\n\n### Keyword Search\n\nThe Keyword Search API can be used to find related DBpedia resources for a given string. The string may consist of a single or multiple words.\n\nExample: Places that have the related keyword \"berlin\"\n\nhttp://lookup.dbpedia.org/api/search/KeywordSearch?QueryClass=place&QueryString=berlin\n\n### Prefix Search (i.e. Autocomplete)\n\nThe Prefix Search API can be used to implement autocomplete input boxes. For a given partial keyword like *berl* the API returns URIs of related DBpedia resources like http://dbpedia.org/resource/Berlin.\n\nExample: Top five resources for which a keyword starts with \"berl\"\n\nhttp://lookup.dbpedia.org/api/search/PrefixSearch?QueryClass=&MaxHits=5&QueryString=berl\n\n### Parameters\n\nThe query parameters accepted by the endpoints are\n\n* `QueryString`: a string for which a DBpedia URI should be found.\n* `QueryClass`: a DBpedia class from the Ontology that the results should have (for owl#Thing and untyped resource, leave this parameter empty).\n* `MaxHits`: the maximum number of returned results (default: 5)\n\n### JSON support\n\nBy default all data is returned as XML, the service also retuns JSON to any request including the `Accept: application/json` header.\n\n## Running a local mirror of the webservice\n\n### Clone and build DBpedia Lookup\n\n    git clone git://github.com/dbpedia/lookup.git\n    cd lookup\n    mvn clean install\n\n### Download and configure the index\n\nYou can get our indexes from [HERE](http://downloads.dbpedia-spotlight.org/dbpedia_lookup/)\n\n### Run the server\n\n    \n    `./run Server [PATH TO THE INDEX]/[VERSION]/`\n   \n   E.g:\n    \n    `./run Server /opt/dbpedia-lookup/2015-04`\n\n**Note: The index file must be decompressed**\n    \n#### Available versions: \n    \n* current - from Latest DBpedia Dump (2015-10)\n\n    \n#### Available languages (i18n working in progress): \n    \n* en - English\n    \n    \n\nThe server should now be running at http://localhost:1111\n\n## Rebuilding the index\n\nRebuilding an index is usually not required, if you only intend on running a local mirror of the service you can donwload a prebuilt index as outlined above.\n\nTo re-build the index you will require\n\n* DBpedia datasets\n* [Wikistatsextractor output](http://downloads.dbpedia-spotlight.org) - [wikistatsextractor](https://github.com/jodaiber/wikistatsextractor) is a drop-in replacement of [pignlproc](https://github.com/dbpedia-spotlight/pignlproc)\n* Unix\n\n\n### Get the following DBpedia datasets\nfrom http://downloads.dbpedia.org/2015-10/core-i18n/en/\n\n* redirects\\_en.nt (or .ttl)\n* short\\_abstracts\\_en.nt (or .ttl)\n* instance\\_types\\_en.nt (or .ttl)\n* article\\_categories\\_en.nt (or .ttl)\n\nfrom http://downloads.dbpedia.org/2015-10/core\n\n* instance_types_en.ttl\n* instance_types_sdtyped_dbo_en.ttl\n* instance_types_transitive_en.ttl\n\n### Concatenate all data and sort by URI\n\nThis is necessary because indexing in sorted order is significantly faster.\n\n      cat instance_types_en.nt (or .ttl)  \\\n          short_abstracts_en.nt (or .ttl) \\\n          article_categories_en.nt (or .ttl) \\\n          instance_types_en.ttl  \\\n          instance_types_sdtyped_dbo_en.ttl \\\n          instance_types_transitive_en.ttl | sort >all_dbpedia_data.nt (or .ttl)\n\n### Get the dataset redirects\\_en.nt (or .ttl)\n\nRedirects are not indexed, but they are excluded as targets of lookup.\n\n### Run Indexer\n\nThe indexer has to be run twice:\n\n1. with the DBpedia data \n\n        ./run Indexer lookup_index_dir redirects_en.nt (or .ttl) all_dbpedia_data.nt (or .ttl)\n\n2. with the wikistatsextractor data\n\n        ./run Indexer lookup_index_dir redirects_en.nt (or .ttl) pairCounts\n\n## Support and feedback\n\nThe best way to get support or give feedback on the Lookup project is via the [DBpedia discussion mailing list](https://lists.sourceforge.net/lists/listinfo/dbpedia-discussion). More technical queries about the code base should be directed to the [DBpedia developers mailing list](https://lists.sourceforge.net/lists/listinfo/dbpedia-developers).\n\nThe [DBpedia wiki](http://wiki.dbpedia.org/lookup/) also has useful information on the project.\n\n## Maintainers\n\n* Kunal Jha [@Kunal-Jha](https://github.com/Kunal-Jha)\n* Sandro Coelho [@sandroacoelho](https://github.com/sandroacoelho)\n* Pablo Mendes [@pablomendes](https://github.com/pablomendes) (less active)\n* Max Jakob [@maxjakob](https://github.com/maxjakob) (less active)\n* Matt Haynes [@matth](https://github.com/matth) (less active)\n"
  },
  {
    "path": "docker/Dockerfile_2015-10",
    "content": "FROM java:8\n\nMAINTAINER  DBpedia Team <dbpedia-developers@lists.sourceforge.net>\n\nRUN apt-get update && apt-get install -y \\\n    curl\n\nENV INDEX_URL downloads.dbpedia-spotlight.org/dbpedia_lookup/models\nENV INDEX_FILENAME 2015-10.tar.gz\n\nENV LOOKUP_JAR dbpedia-lookup-3.1-jar-with-dependencies.jar\nENV LOOKUP_URL downloads.dbpedia-spotlight.org/dbpedia_lookup/\n\nRUN mkdir -p /opt/lookup && \\\n    cd /opt/lookup && \\\n    wget \"http://$LOOKUP_URL/$LOOKUP_JAR\" -O $LOOKUP_JAR  && \\\n    wget \"http://$INDEX_URL/$INDEX_FILENAME\" -O $INDEX_FILENAME  && \\\n    tar xvf $INDEX_FILENAME   && \\\n    rm  $INDEX_FILENAME\n\nEXPOSE 1111\n"
  },
  {
    "path": "docker/README.md",
    "content": "## Supported tags and respective Dockerfile links\n* latest (DBpedia dump 2015-10)\n\n## How to run\n\n* English    - ``docker run -p 1111:1111 -it dbpedia/lookup java -jar /opt/lookup/dbpedia-lookup-3.1-jar-with-dependencies.jar /opt/lookup/2015-10/``\n\n\nAnd then try \n\n```\nhttp://localhost:1111/api/search/PrefixSearch?QueryClass=&MaxHits=5&QueryString=berl\n```\n\nIf you are using Docker Compose you can do the same with this minimal Compose file:\n\n```yml\nversion: '2'\nservices:\n  lookup:\n    container_name: lookup\n    image: dbpedia/lookup\n    ports:\n     - \"1111:1111\"\n    command: java -jar /opt/lookup/dbpedia-lookup-3.1-jar-with-dependencies.jar /opt/lookup/2015-10/\n```\n\n## Supported Docker versions\nThis image is officially supported on Docker version 1.9.1.\n\nPlease see the [Docker installation documentation] (https://docs.docker.com/installation/) for details on how to upgrade your Docker daemon.\n\n\n## Issues\nIf you have any problems with or questions about this image, please contact us through a [GitHub issue](http://github.com/dbpedia/lookup/issues).\n\n\n## Contributing\n\nFirst of all, thank you for helping! :) .\n\nPlease see [DBpedia Contribute Guide](https://github.com/dbpedia/lookup/wiki/Contributing) for details on how to contribute\n"
  },
  {
    "path": "pom.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\n    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n    xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n    <modelVersion>4.0.0</modelVersion>\n\n    <groupId>org.dbpedia.lookup</groupId>\n    <artifactId>dbpedia-lookup</artifactId>\n    <packaging>jar</packaging>\n    <version>3.1</version>\n    <name>DBpedia Lookup Service</name>\n\n\n    <description>\n        DBpedia Lookup is a web service that can be used to look up DBpedia URIs by related keywords\n    </description>\n\n    <url>http://www.dbpedia.org</url>\n\n    <licenses>\n        <license>\n            <name>Apache License, Version 2.0</name>\n            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>\n            <distribution>repo</distribution>\n        </license>\n    </licenses>\n\n    <developers>\n        <developer>\n            <name>DBpedia Team</name>\n            <email>dbpedia-developers@lists.sourceforge.net</email>\n            <organization>DBpedia</organization>\n            <organizationUrl>http://www.dbpedia.org</organizationUrl>\n        </developer>\n    </developers>\n\n    <scm>\n        <connection>scm:git:git@github.com:dbpedia/extraction-framework.git</connection>\n        <developerConnection>scm:git:git@github.com:dbpedia/lookup.git</developerConnection>\n        <url>git@github.com:dbpedia/extraction-framework.git</url>\n    </scm>\n\n    <properties>\n        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>\n        <maven.scala.plugin.version>3.2.2</maven.scala.plugin.version>\n        <maven.surefire.plugin.version>2.12.4</maven.surefire.plugin.version>\n        <scala.compiler.version.revision>2.11.7</scala.compiler.version.revision>\n        <scala.compiler.version>2.11</scala.compiler.version>\n        <scala.test.version>2.2.6</scala.test.version>\n        <maven.scala.test.plugin.version>1.0</maven.scala.test.plugin.version>\n        <dbpedia.extraction.version>4.0</dbpedia.extraction.version>\n        <lucene.core.version>3.6.2</lucene.core.version>\n        <jersey.server.version>1.19.1</jersey.server.version>\n        <commons.compress.version>1.0</commons.compress.version>\n        <lift.json.version>2.6.2</lift.json.version>\n        <logback.classic.version>1.0.9</logback.classic.version>\n        <yars.nxparser.version>1.2.3</yars.nxparser.version>\n        <aksw.keyname>AKSW.GPG</aksw.keyname>\n    </properties>\n\n    <build>\n        <plugins>\n\n            <plugin>\n                <artifactId>maven-resources-plugin</artifactId>\n                <version>2.6</version>\n                <executions>\n                    <execution>\n                        <id>process-test-resources</id>\n                        <phase>process-test-resources</phase>\n                        <goals>\n                            <goal>testResources</goal>\n                        </goals>\n                    </execution>\n                    <execution>\n                        <id>copy-resources</id>\n                        <phase>compile</phase>\n                        <goals>\n                            <goal>resources</goal>\n                        </goals>\n                    </execution>\n                </executions>\n            </plugin>\n\n            <plugin>\n                <groupId>net.alchim31.maven</groupId>\n                <artifactId>scala-maven-plugin</artifactId>\n                <version>${maven.scala.plugin.version}</version>\n\n                <executions>\n                    <execution>\n                        <id>compile</id>\n                        <goals>\n                            <goal>compile</goal>\n                        </goals>\n                        <phase>compile</phase>\n                    </execution>\n                    <execution>\n                        <id>test-compile</id>\n                        <goals>\n                            <goal>testCompile</goal>\n                        </goals>\n                        <phase>test-compile</phase>\n                    </execution>\n                    <execution>\n                        <id>attach-docs-sources</id>\n                        <goals>\n                            <goal>add-source</goal>\n                            <goal>doc-jar</goal>\n                        </goals>\n                   </execution>\n                </executions>\n\n                <configuration>\n                    <args>\n                        <arg>-deprecation</arg>\n                    </args>\n                    <launchers>\n                        <launcher>\n                            <id>Server</id>\n                            <mainClass>org.dbpedia.lookup.server.Server</mainClass>\n                            <jvmArgs>\n                                <jvmArg>-Xmx512m</jvmArg>\n                                <jvmArg>-Dlogback.configurationFile=logback.xml</jvmArg>\n                                <jvmArg>-Dhttp.port=1111</jvmArg>\n                            </jvmArgs>\n                        </launcher>\n                        <launcher>\n                            <id>Indexer</id>\n                            <mainClass>org.dbpedia.lookup.lucene.Indexer</mainClass>\n                            <jvmArgs>\n                                <jvmArg>-Xms5g</jvmArg>\n                                <jvmArg>-Xmx5g</jvmArg>\n                                <jvmArg>-Dlogback.configurationFile=logback.xml</jvmArg>\n                            </jvmArgs>\n                        </launcher>\n                    </launchers>\n                </configuration>\n            </plugin>\n\n            <plugin>\n                <groupId>org.scalatest</groupId>\n                <artifactId>scalatest-maven-plugin</artifactId>\n                <version>${maven.scala.test.plugin.version}</version>\n                <executions>\n                    <execution>\n                        <id>test</id>\n                        <goals>\n                            <goal>test</goal>\n                        </goals>\n                    </execution>\n                </executions>\n            </plugin>\n\n            <plugin>\n                <artifactId>maven-assembly-plugin</artifactId>\n                <executions>\n                    <execution>\n                        <phase>package</phase>\n                        <goals>\n                            <goal>single</goal>\n                        </goals>\n                    </execution>\n                </executions>\n                <configuration>\n                    <archive>\n                        <manifest>\n                            <addClasspath>true</addClasspath>\n                            <mainClass>org.dbpedia.lookup.server.Server</mainClass>\n                        </manifest>\n                    </archive>\n                    <descriptorRefs>\n                        <descriptorRef>jar-with-dependencies</descriptorRef>\n                    </descriptorRefs>\n                </configuration>\n            </plugin>\n\n            <plugin>\n                <groupId>org.sonatype.plugins</groupId>\n                <artifactId>nexus-staging-maven-plugin</artifactId>\n                <extensions>true</extensions>\n                <configuration>\n                    <serverId>ossrh</serverId>\n                    <nexusUrl>https://oss.sonatype.org/</nexusUrl>\n                    <autoReleaseAfterClose>true</autoReleaseAfterClose>\n                </configuration>\n            </plugin>\n\n            <plugin>\n                <groupId>org.apache.maven.plugins</groupId>\n                <artifactId>maven-source-plugin</artifactId>\n                <executions>\n                    <execution>\n                        <id>attach-sources</id>\n                        <goals>\n                            <goal>jar</goal>\n                        </goals>\n                    </execution>\n                </executions>\n            </plugin>\n\n        </plugins>\n    </build>\n\n    <dependencies>\n        <dependency>\n            <groupId>org.scala-lang</groupId>\n            <artifactId>scala-compiler</artifactId>\n            <version>${scala.compiler.version.revision}</version>\n            <scope>provided</scope>\n        </dependency>\n\n        <dependency>\n            <groupId>org.scala-lang</groupId>\n            <artifactId>scala-library</artifactId>\n            <version>${scala.compiler.version.revision}</version>\n        </dependency>\n\n        <dependency>\n            <groupId>org.dbpedia.extraction</groupId>\n            <artifactId>core</artifactId>\n            <version>${dbpedia.extraction.version}</version>\n        </dependency>\n\n        <dependency>\n            <groupId>org.apache.lucene</groupId>\n            <artifactId>lucene-core</artifactId>\n            <version>${lucene.core.version}</version>\n        </dependency>\n\n        <dependency>\n            <groupId>com.sun.jersey</groupId>\n            <artifactId>jersey-bundle</artifactId>\n            <version>${jersey.server.version}</version>\n        </dependency>\n\n        <dependency>\n            <groupId>org.apache.commons</groupId>\n            <artifactId>commons-compress</artifactId>\n            <version>${commons.compress.version}</version>\n        </dependency>\n\n        <dependency>\n            <groupId>net.liftweb</groupId>\n            <artifactId>lift-json_${scala.compiler.version}</artifactId>\n            <version>${lift.json.version}</version>\n        </dependency>\n\n        <dependency>\n            <groupId>ch.qos.logback</groupId>\n            <artifactId>logback-classic</artifactId>\n            <version>${logback.classic.version}</version>\n        </dependency>\n\n        <dependency>\n            <groupId>org.semanticweb.yars</groupId>\n            <artifactId>nxparser</artifactId>\n            <version>${yars.nxparser.version}</version>\n        </dependency>\n\n        <dependency>\n            <groupId>org.scalatest</groupId>\n            <artifactId>scalatest_${scala.compiler.version}</artifactId>\n            <version>${scala.test.version}</version>\n            <scope>test</scope>\n        </dependency>\n    </dependencies>\n\n    <repositories>\n\n       <repository>\n            <id>spotlight-releases-repository</id>\n            <url>https://github.com/dbpedia-spotlight/maven-repo/raw/master/releases</url>\n        </repository>\n\n        <repository>\n            <id>sonatype-oss-public</id>\n            <name>Sonatype OSS Public Maven repo</name>\n            <url>https://oss.sonatype.org/content/groups/public</url>\n        </repository>\n\n    </repositories>\n\n    <pluginRepositories>\n        <pluginRepository>\n            <id>sonatype-oss-public</id>\n            <name>Sonatype OSS Public Maven repo</name>\n            <url>https://oss.sonatype.org/content/groups/public</url>\n        </pluginRepository>\n    </pluginRepositories>\n\n    <profiles>\n        <profile>\n            <id>release</id>\n            <build>\n                <plugins>\n                    <plugin>\n                        <groupId>org.apache.maven.plugins</groupId>\n                        <artifactId>maven-gpg-plugin</artifactId>\n                        <version>1.6</version>\n                        <executions>\n                            <execution>\n                                <id>sign-artifacts</id>\n                                <phase>verify</phase>\n                                <goals>\n                                    <goal>sign</goal>\n                                </goals>\n                                <configuration>\n                                    <keyname>AKSW</keyname>\n                                    <passphraseServerId>${aksw.keyname}</passphraseServerId>\n                                </configuration>\n                            </execution>\n                        </executions>\n                    </plugin>\n                    <plugin>\n                        <groupId>org.apache.maven.plugins</groupId>\n                        <artifactId>maven-release-plugin</artifactId>\n                        <version>2.5.2</version>\n                        <configuration>\n                            <goals>deploy</goals>\n                            <autoVersionSubmodules>true</autoVersionSubmodules>\n                            <useReleaseProfile>false</useReleaseProfile>\n                            <releaseProfiles>release</releaseProfiles>\n                            <tagNameFormat>v@{project.version}</tagNameFormat>\n                            <scmCommentPrefix>[maven-release-plugin] [ci build-cli] [ci build-webdemo] -</scmCommentPrefix>\n                        </configuration>\n                    </plugin>\n                </plugins>\n            </build>\n        </profile>\n    </profiles>\n\n</project>\n"
  },
  {
    "path": "run",
    "content": "#!/bin/bash\n\n# Shortcut for mvn scala:run -Dlauncher=... -DaddArgs=...\n# Example:\n# lookup> ./run LAUNCHER ARG1 ARG2 ARG3\n# is equivalent to\n# lookup> mvn scala:run \"-Dlauncher=LAUNCHER\" \"-DaddArgs=ARG1|ARG2|ARG3\"\n\nLAUNCHER=\"$1\"\n\nADD_ARGS=\"$2\"\nfor ARG in ${@:3}\ndo\n  ADD_ARGS=\"$ADD_ARGS|$ARG\"\ndone\n\nmvn scala:run \"-Dlauncher=$LAUNCHER\" \"-DaddArgs=$ADD_ARGS\" \n"
  },
  {
    "path": "scripts/index.sh",
    "content": "#!/bin/bash\n\nreadonly DBPEDIA_VERSION=$1\nreadonly LANG_i18n=$2\nreadonly DBPEDIA_DOWNLOADS=\"http://downloads.dbpedia.org\"/$DBPEDIA_VERSION/core-i18n\nreadonly DBPEDIA_ROOT=~/lookup\nreadonly DBPEDIA_DATA=$DBPEDIA_ROOT/dbpedia_data/$DBPEDIA_VERSION\nreadonly DBPEDIA_INDEX=dbpedia-lookup-index/$LANG_i18n/$DBPEDIA_VERSION\nreadonly ALL_FILES=(redirects short_abstracts instance_types article_categories)\n\n#+------------------------------------------------------------------------------------------------------------------------------+\n#| Functions                                                                                                                    |\n#+------------------------------------------------------------------------------------------------------------------------------+\n\n# Error_exit function by William Shotts. http://stackoverflow.com/questions/64786/error-handling-in-bash\nfunction error_exit\n{\n    echo -e \"${PROGNAME}: ${1:-\"Unknown Error\"}\" 1>&2\n    exit 1\n}\n\n# The function used to create all the directories needed\nfunction create_dir()\n{\n    if [ -e $1 ]; then\n        echo -e $1\" already exists. Skipping creating this directory!\"\n    else\n        mkdir -p $1\n    fi\n}\n\n# A helper function to download files from a given path. The first parameter is the path from where to download the file\n# without the file name, the second states the file name, and the third is where to save that file\nfunction download_file()\n{\n    # Only downloads if there is no current file or there is a newer version\n    echo \"$#\"\n    case \"$#\" in\n        \"3\")\n            wget -q --spider $1/$2\n            if [ $? -eq 0 ] ; then\n                wget -N $1/$2 --directory-prefix=$3\n            else\n                # The file can't be found. We can extract a substring with the file name and show it to the user\n                error_exit \"ERROR: The file '\"$2\"' cannot be found for download.\\n\"\n            fi\n            ;;\n        \"4\")\n            wget -q --spider $1 $2/$3\n            if [ $? -eq 0 ] ; then\n                wget -N $1 $2/$3 --directory-prefix=$4\n            else\n                # The file can't be found. We can extract a substring with the file name and show it to the user\n                error_exit \"ERROR: The file '\"$3\"' cannot be found for download.\\n\"\n            fi\n            ;;\n        *)\n            error_exit \"ERROR: Incorrect number of parameters!\";\n    esac\n    echo -e \"done!\\n\"\n}\n\n#-----------------------------------------------------------------------------------------------------------------------------+\ncreate_dir $DBPEDIA_DATA\ncreate_dir $DBPEDIA_ROOT/$DBPEDIA_INDEX\n\nfor i in ${ALL_FILES[@]}\ndo\n download_file $DBPEDIA_DOWNLOADS/$LANG_i18n ${i}_$LANG_i18n.ttl.bz2 $DBPEDIA_DATA/$LANG_i18n    \ndone\n\nfor i in ${ALL_FILES[@]}\ndo\n  bunzip2 -dc  $DBPEDIA_DATA/$LANG_i18n/${i}_$LANG_i18n.ttl.bz2 >  $DBPEDIA_DATA/$LANG_i18n/${i}_$LANG_i18n.nt\ndone\n\ncat $DBPEDIA_DATA/$LANG_i18n/short_abstracts_$LANG_i18n.nt $DBPEDIA_DATA/$LANG_i18n/instance_types_$LANG_i18n.nt $DBPEDIA_DATA/$LANG_i18n/article_categories_$LANG_i18n.nt > $DBPEDIA_DATA/$LANG_i18n/all_dbpedia_data.nt\n\ngit clone https://github.com/dbpedia/lookup.git\ncd lookup\nmvn clean install\n\n./run Indexer $DBPEDIA_ROOT/$DBPEDIA_INDEX $DBPEDIA_DATA/$LANG_i18n/redirects_$LANG_i18n.nt $DBPEDIA_DATA/$LANG_i18n/all_dbpedia_data.nt\n\ncd $DBPEDIA_ROOT\ntar -zcvf ${LANG_i18n}_$DBPEDIA_VERSION.tar.gz $DBPEDIA_INDEX\n"
  },
  {
    "path": "src/main/resources/logback.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<configuration>\n\n    <appender name=\"STDOUT\" class=\"ch.qos.logback.core.ConsoleAppender\">\n        <encoder>\n            <pattern>%-5level - %msg%n</pattern>\n            <!-- <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> -->\n        </encoder>\n    </appender>\n\n    <root level=\"info\">\n        <appender-ref ref=\"STDOUT\" />\n    </root>\n</configuration>\n"
  },
  {
    "path": "src/main/scala/org/dbpedia/lookup/entities/Entities.scala",
    "content": "package org.dbpedia.lookup.entities\n\nimport org.dbpedia.extraction.util.WikiUtil._\n\ntrait Uri   { val uri   : String }\ntrait Label { val label : String }\n\ncase class Redirect(uri: String) extends Uri\n\ncase class Template(uri: String) extends Uri\n\ncase class Category(uri: String) extends Uri with Label {\n    val label: String = wikiDecode(uri.replace(\"http://dbpedia.org/resource/Category:\", \"\"))\n}\n\ncase class OntologyClass(uri: String) extends Uri with Label {\n\n    val label: String = {\n        if (uri endsWith \"owl#Thing\") {\n            \"owl#Thing\"\n        } else {\n            val s = wikiDecode(uri.replace(\"http://dbpedia.org/ontology/\", \"\")\n                                  .replace(\"http://schema.org/\", \"\")\n            )\n                s.replaceAll(\"([A-Z])\", \" $1\").trim.toLowerCase\n        }\n        }\n    }\n\ncase class Result(\n    uri: String,\n    description: String,\n    classes: Set[OntologyClass],\n    categories: Set[Category],\n    templates: Set[Template],\n    redirects: Set[Redirect],\n    refCount: Int\n) extends Uri with Label {\n    val label: String = wikiDecode(uri.replace(\"http://dbpedia.org/resource/\", \"\"))\n}\n"
  },
  {
    "path": "src/main/scala/org/dbpedia/lookup/entities/EntitiesSerialization.scala",
    "content": "package org.dbpedia.lookup.entities\n\nimport scala.xml._\nimport net.liftweb.json._\n\ntrait ResultSerializer {\n  def prettyPrint(results: Traversable[Result]) : String\n}\n\nclass ResultJsonSerializer extends ResultSerializer {\n\n  def prettyPrint(results: Traversable[Result]) : String = {\n\n    import net.liftweb.json.JsonDSL._\n\n    val json = (\"results\" -> results.map { result =>\n      (\"uri\" -> result.uri) ~\n      (\"label\" -> result.label) ~\n      (\"description\" -> result.description) ~\n      (\"refCount\" -> result.refCount) ~\n      (\"classes\" -> result.classes.map(c => (\"uri\" -> c.uri) ~ (\"label\" -> c.label))) ~\n      (\"categories\" -> result.categories.map(c => (\"uri\" -> c.uri) ~ (\"label\" -> c.label))) ~\n      (\"templates\" -> result.templates.map(c => (\"uri\" -> c.uri))) ~\n      (\"redirects\" -> result.redirects.map(c => (\"uri\" -> c.uri)))\n    })\n\n    pretty(render(json))\n  }\n\n}\n\nclass ResultXmlSerializer extends ResultSerializer {\n\n  def prettyPrint(results: Traversable[Result]) : String = {\n    val xml = serialize(results)\n  /*  val printer = new scala.xml.PrettyPrinter(120, 4)\n    \"<?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\"?>\\n\" + printer.format(xml)*/\n    \"<?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\"?>\\n\" + xml.toString()\n  }\n\n  def serialize(results : Traversable[Result]) : Node = {\n    <ArrayOfResult xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n                   xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\n                   xmlns=\"http://lookup.dbpedia.org/\">\n      { results.map(r => serialize(r)) }\n    </ArrayOfResult>\n  }\n\n  def serialize(result : Result) : Node = {\n    <Result>\n      <Label>{result.label}</Label>\n      <URI>{result.uri}</URI>\n      <Description>{result.description}</Description>\n      <Classes>{ urisWithLabels(result.classes, \"Class\") }</Classes>\n      <Categories>{ urisWithLabels(result.categories, \"Category\") }</Categories>\n      <Templates>{ uris(result.templates, \"Template\") }</Templates>\n      <Redirects>{ uris(result.redirects, \"Redirect\") }</Redirects>\n      <Refcount>{ result.refCount }</Refcount>\n    </Result>\n  }\n\n  private def urisWithLabels[A <: Uri with Label](items: Set[A], nodeName: String) = {\n    items.map(item => new Elem(null, nodeName, Null, TopScope, <Label>{item.label}</Label>, <URI>{item.uri}</URI>))\n  }\n\n  private def uris[A <: Uri](items: Set[A], nodeName: String) = {\n    items.map(item => new Elem(null, nodeName, Null, TopScope, <URI>{item.uri}</URI>))\n  }\n\n}\n"
  },
  {
    "path": "src/main/scala/org/dbpedia/lookup/inputformat/DBpediaNTriplesInputFormat.scala",
    "content": "package org.dbpedia.lookup.inputformat\n\nimport org.semanticweb.yars.nx.parser.NxParser\nimport java.io.InputStream\nimport org.dbpedia.lookup.lucene.LuceneConfig\n\n/**\n * Class to itereate over DBpedia NTriples dataset and\n */\nclass DBpediaNTriplesInputFormat(val dataSet: InputStream, val redirects: scala.collection.Set[String]) extends InputFormat {\n\n    private val it = new NxParser(dataSet)\n\n    val predicate2field = Map(\n        \"http://lexvo.org/ontology#label\" -> LuceneConfig.Fields.SURFACE_FORM_KEYWORD,   // no DBpedia dataset, has to be created\n        \"http://dbpedia.org/property/refCount\" -> LuceneConfig.Fields.REFCOUNT,  // no DBpedia dataset, has to be created\n        \"http://dbpedia.org/ontology/abstract\" -> LuceneConfig.Fields.DESCRIPTION,\n        \"http://www.w3.org/2000/01/rdf-schema#comment\" -> LuceneConfig.Fields.DESCRIPTION,\n        \"http://www.w3.org/1999/02/22-rdf-syntax-ns#type\" -> LuceneConfig.Fields.CLASS,\n        \"http://purl.org/dc/terms/subject\" -> LuceneConfig.Fields.CATEGORY,\n        \"http://dbpedia.org/property/wikiPageUsesTemplate\" -> LuceneConfig.Fields.TEMPLATE,  // not really necessary\n        \"http://dbpedia.org/ontology/wikiPageRedirects\" -> LuceneConfig.Fields.REDIRECT      // not really necessary\n    )\n\n    override def foreach[U](f: ((String,String,String)) => U) {\n\n        while(it.hasNext) {\n            val triple = it.next\n            val uri = triple(0).toString\n            val pred = triple(1).toString\n            val obj = triple(2).toString\n\n            predicate2field.get(pred) match {\n                case Some(field: String) if(redirects.isEmpty || !redirects.contains(uri)) => {\n                    if(field == LuceneConfig.Fields.REDIRECT) {\n                        f( (obj, field, uri) )   // make it a \"hasRedirect\" relation\n                    }\n                    else {\n                        f( (uri, field, obj) )\n                    }\n                }\n                case _ =>\n            }\n        }\n\n    }\n\n}"
  },
  {
    "path": "src/main/scala/org/dbpedia/lookup/inputformat/InputFormat.scala",
    "content": "package org.dbpedia.lookup.inputformat\n\ntrait InputFormat extends Traversable[(String, String, String)] {\n\n}\n"
  },
  {
    "path": "src/main/scala/org/dbpedia/lookup/inputformat/PignlprocTSVInputFormat.scala",
    "content": "package org.dbpedia.lookup.inputformat\n\nimport java.io.InputStream\nimport org.dbpedia.lookup.lucene.LuceneConfig\nimport io.Source\nimport org.dbpedia.extraction.util.WikiUtil\n\n/**\n * Class to itereate over a pignlproc nerd-stats result.\n */\n\nclass PignlprocTSVInputFormat(dataSet: InputStream, pSfGivenUriThreshold: Double, uriField: Int=0, sfField: Int=1, pSfGivenUriField: Int=3, refCountField: Int=6)\n    extends InputFormat {\n\n    val DBPEDIA_RESOURCE_NAMESPACE = \"http://dbpedia.org/resource/\"\n\n    private val it = Source.fromInputStream(dataSet, \"utf-8\").getLines()\n\n    override def foreach[U](f: ((String,String,String)) => U) {\n\n        while(it.hasNext) {\n            val elements = it.next().split(\"\\t\")\n\n            val uri = DBPEDIA_RESOURCE_NAMESPACE + WikiUtil.wikiEncode(elements(uriField))\n            val sf = elements(sfField)\n            //val pUriGivenSf = elements(2)\n            val pSfGivenUri = elements(pSfGivenUriField)\n            //val pSf = elements(4)\n            //val wikiPageId = elements(5)\n            val uriCount = elements(refCountField)\n\n            if (pSfGivenUri.toDouble > pSfGivenUriThreshold) {\n                f( (uri, LuceneConfig.Fields.SURFACE_FORM_KEYWORD, sf) )\n            }\n            f( (uri, LuceneConfig.Fields.REFCOUNT, uriCount) )\n        }\n\n    }\n\n}"
  },
  {
    "path": "src/main/scala/org/dbpedia/lookup/inputformat/WikiStatsExtractor.scala",
    "content": "package org.dbpedia.lookup.inputformat\n\nimport java.io.InputStream\n\nimport org.dbpedia.extraction.util.WikiUtil\nimport org.dbpedia.lookup.lucene.LuceneConfig\n\nimport scala.io.Source\n\nclass WikiStatsExtractor(dataSet: InputStream, pSfGivenUriThreshold: Double) extends InputFormat {\n\n  private val it = Source.fromInputStream(dataSet, \"utf-8\").getLines()\n\n  override def foreach[U](f: ((String,String,String)) => U) {\n\n    while(it.hasNext) {\n      val elements = it.next().split(\"\\t\")\n\n      if (elements.size >= 3) {\n        val uri = WikiUtil.wikiEncode(elements(1))\n        val sf = elements(0)\n\n        val uriCount = elements(2)\n\n        f((uri, LuceneConfig.Fields.SURFACE_FORM_KEYWORD, sf))\n        f((uri, LuceneConfig.Fields.REFCOUNT, uriCount))\n      } \n    }\n  }\n}\n\n"
  },
  {
    "path": "src/main/scala/org/dbpedia/lookup/lucene/Indexer.scala",
    "content": "package org.dbpedia.lookup.lucene\n\nimport org.apache.lucene.store.FSDirectory\nimport org.apache.lucene.document.{Field, Document}\nimport org.apache.lucene.index.{IndexReader, Term, IndexWriter}\nimport org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream\nimport java.io.{FileInputStream, InputStream, File}\nimport org.semanticweb.yars.nx.parser.NxParser\nimport org.dbpedia.extraction.util.WikiUtil\nimport org.dbpedia.lookup.inputformat.{WikiStatsExtractor, InputFormat, DBpediaNTriplesInputFormat, PignlprocTSVInputFormat}\nimport org.apache.lucene.search.{IndexSearcher, TermQuery}\nimport org.dbpedia.lookup.util.Logging\n\n/**\n * Indexes the lookup data to a Lucene directory.\n */\nclass Indexer(val indexDir: File) extends Logging {\n\n    private val indexWriter = new IndexWriter(FSDirectory.open(indexDir), LuceneConfig.indexWriterConfig)\n    indexWriter.commit()\n    private val indexSearcher = new IndexSearcher(IndexReader.open(FSDirectory.open(indexDir)))\n    logger.info(\"Directory \"+indexDir+\" opened for indexing\")\n\n    /**\n     * Index a data file for the lookup service.\n     */\n    def index(dataTraversable: InputFormat) {\n        var count = 0\n        val collector = scala.collection.mutable.HashMap[String, scala.collection.mutable.HashMap[String, scala.collection.mutable.HashSet[String]]]()\n\n        dataTraversable.foreach{ case (uri:String, field:String, value:String) => {\n            val fields = collector.getOrElse(uri, scala.collection.mutable.HashMap[String, scala.collection.mutable.HashSet[String]]())\n            val values: scala.collection.mutable.HashSet[String] = fields.getOrElse(field, scala.collection.mutable.HashSet[String]())\n            values.add(value)\n            fields.put(field, values)\n            collector.put(uri, fields)\n\n            count += 1\n            if(count%100000 == 0) {\n                logger.info(count+\" data points read\")\n            }\n            if(count%LuceneConfig.commitAfterDataPointsNum == 0) {\n                updateIndex(collector)\n                collector.clear()\n            }\n        }}\n        updateIndex(collector)\n        logger.info(count+\" data points indexed. Done\")\n\n        //TODO remove?\n        logger.info(\"Optimizing\")\n        indexWriter.optimize()\n        logger.info(\"Done optimizing\")\n    }\n\n\n    private def updateIndex(collector:scala.collection.mutable.HashMap[String,scala.collection.mutable.HashMap[String, scala.collection.mutable.HashSet[String]]]) {\n        logger.info(\"Updating\")\n        collector.foreach(t => {\n            val (uri, fields) = t\n            updateDataForUri(uri, fields)\n        })\n        logger.info(\"Committing\")\n        indexWriter.commit()\n}\n\n    private def updateDataForUri(currentUri: String, fieldCollector:scala.collection.mutable.HashMap[String, scala.collection.mutable.HashSet[String]]) {\n\n        val uriTerm = new Term(LuceneConfig.Fields.URI, currentUri)\n        val hits = indexSearcher.search(new TermQuery(uriTerm), 2)\n\n        val doc =\n            if (hits.scoreDocs.length == 1) {\n                indexSearcher.doc(hits.scoreDocs(0).doc)\n            } else if (hits.scoreDocs.length == 0) {\n                val d = new Document\n                updateField(d, new Field(LuceneConfig.Fields.URI, uriTerm.text, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS, Field.TermVector.NO))\n\n                val label = WikiUtil.wikiDecode(uriTerm.text.replace(\"http://dbpedia.org/resource/\", \"\"))\n                updateField(d, new Field(LuceneConfig.Fields.SURFACE_FORM_KEYWORD, label, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO))\n\n                val prefixTerm = LuceneConfig.PrefixSearchPseudoAnalyzer.analyze(label)\n                updateField(d, new Field(LuceneConfig.Fields.SURFACE_FORM_PREFIX, prefixTerm, Field.Store.YES, Field.Index.NOT_ANALYZED, Field.TermVector.NO))\n\n                d\n            } else { //  if (hits.scoreDocs.length > 1) {\n                throw new IllegalStateException(\"Given Term matches more than 1 document in the index.\")\n            }\n\n        indexWriter.updateDocument(uriTerm, getUpdatedDocument(doc, uriTerm, fieldCollector))\n    }\n\n    def close() {\n        indexWriter.close()\n        logger.info(\"Closed index \"+indexDir)\n    }\n\n\n    private def getUpdatedDocument(doc: Document, uriTerm: Term, fields: scala.collection.Map[String, scala.collection.Set[String]]): Document = {\n        for((field, valueSet) <- fields) {\n            val addedPrefixTerms = new scala.collection.mutable.HashSet[String]()\n            for(value <- valueSet) {\n                if(field == LuceneConfig.Fields.SURFACE_FORM_KEYWORD) {\n                    updateField(doc, new Field(LuceneConfig.Fields.SURFACE_FORM_KEYWORD, value, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO))\n\n                    val prefixTerm = LuceneConfig.PrefixSearchPseudoAnalyzer.analyze(value)\n                    if (!addedPrefixTerms.contains(prefixTerm)) {\n                        updateField(doc, new Field(LuceneConfig.Fields.SURFACE_FORM_PREFIX, prefixTerm, Field.Store.YES, Field.Index.NOT_ANALYZED, Field.TermVector.NO))\n                        addedPrefixTerms.add(prefixTerm)\n                    }\n                }\n                else {\n                    updateField(doc, new Field(field, value, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS, Field.TermVector.NO))\n                }\n            }\n        }\n\n        doc\n    }\n\n    private def updateField(doc: Document, field: Field) {\n        doc.add(field)\n    }\n\n}\n\n\nobject Indexer extends Logging {\n\n    private val pSfGivenUriThreshold = 0.001\n\n    /**\n     * Index data to a directory.\n     */\n    def main(args: Array[String]) {\n        val indexDir = new File(args(0))\n        val redirectsFile = new File(args(1))\n        val data = args.drop(2)\n\n        val indexer = new Indexer(indexDir)\n\n        for(fileName <- data) {\n            var in: InputStream = new FileInputStream(fileName)\n            if (fileName.endsWith(\".bz2\")) {\n                in = new BZip2CompressorInputStream(in)\n            }\n\n            logger.info(\"Indexing \"+fileName)\n            indexer.index(getDataInput(fileName, in, redirectsFile))\n            logger.info(\"Done Indexing \"+fileName)\n        }\n        indexer.close()\n    }\n\n    private def getDataInput(fileName: String, inputStream: InputStream, redirectsFile: File) = {\n        if (fileName.contains(\".nt\") || fileName.contains(\".nq\")|| fileName.contains(\".ttl\")) {\n            logger.debug(\"using DBpediaNTriplesInputFormat\")\n            new DBpediaNTriplesInputFormat(inputStream, getRedirectUris(redirectsFile))\n        }\n        else if (fileName.contains(\".tsv\")) {\n            logger.debug(\"using PignlprocTSVInputFormat\")\n            val refCountField = if (fileName.contains(\"_alx\")) 7 else 6\n            new PignlprocTSVInputFormat(inputStream, pSfGivenUriThreshold, refCountField=refCountField)\n        } else if (fileName.contains(\"pairCounts\")) {\n            new WikiStatsExtractor(inputStream, pSfGivenUriThreshold)\n        }\n        else {\n            throw new IllegalArgumentException(\"only know how to handle file types .nt, .nq and .tsv\")\n        }\n    }\n\n    private def getRedirectUris(redirectsFile: File): scala.collection.Set[String] = {\n        val reds = new scala.collection.mutable.HashSet[String]()\n        logger.info(\"Reading redirects from \"+redirectsFile)\n        val parser = new NxParser(new FileInputStream(redirectsFile))\n        while (parser.hasNext) {\n            val triple = parser.next\n            if(triple(1).toString != \"http://dbpedia.org/ontology/wikiPageRedirects\") {\n                throw new Exception(\"predicate must be http://dbpedia.org/ontology/wikiPageRedirects; got \"+triple(1).toString)\n            }\n            reds.add(triple(0).toString)\n        }\n        logger.info(\"Done reading redirects\")\n        reds\n    }\n\n}\n"
  },
  {
    "path": "src/main/scala/org/dbpedia/lookup/lucene/LuceneConfig.scala",
    "content": "package org.dbpedia.lookup.lucene\n\nimport org.apache.lucene.index.IndexWriterConfig\nimport org.apache.lucene.util.Version\nimport org.apache.lucene.analysis._\nimport java.io.{Reader, File}\nimport standard.{StandardFilter, StandardAnalyzer}\nimport org.apache.lucene.queryParser.QueryParser\nimport org.dbpedia.lookup.util.Logging\n\n/**\n * Created by IntelliJ IDEA.\n * User: Max\n * Date: 14.01.11\n * Time: 15:10\n * Lucene configuration data.\n */\n\nobject LuceneConfig extends Logging {\n\n    // default_index_path is not used any more\n\n    // Overwrite existing directories when indexing (must be true if target directory does not exist)\n    val overwriteExisting = true\n\n    // number of data points to read in memory before updating the index\n    val commitAfterDataPointsNum = 1500000\n\n    // Lucene Version\n    val version = Version.LUCENE_36\n\n    // Analyzer for KeywordSearch\n    val analyzer = new StandardAnalyzer(version, StopAnalyzer.ENGLISH_STOP_WORDS_SET)\n\n    // index writer configuration\n    val indexWriterConfig = new IndexWriterConfig(version, analyzer)\n\n    //HACK!: Analyzer for PrefixSearch. The result is converted back to a string and indexed/search NOT_ANALYZED!\n    object PrefixSearchPseudoAnalyzer {\n        private val prefixSearchQueryParser = new QueryParser(version, Fields.SURFACE_FORM_KEYWORD, analyzer)\n\n        def analyze(keyword: String) = {\n            prefixSearchQueryParser.parse('\"' + QueryParser.escape(keyword) + '\"')\n                    .toString.replace(Fields.SURFACE_FORM_KEYWORD+\":\", \"\")\n                             .replaceFirst(\"^\\\"\", \"\")\n                             .replaceFirst(\"\\\"$\", \"\")\n                             .toLowerCase\n        }\n    }\n\n    object Fields {\n        val URI = \"URI\"\n        val SURFACE_FORM_KEYWORD = \"SURFACE_FORM_KEYWORD\"\n        val SURFACE_FORM_PREFIX = \"SURFACE_FORM_PREFIX\"\n        val REFCOUNT = \"REFCOUNT\"\n\n        val DESCRIPTION = \"DESCRIPTION\"\n        val CLASS = \"CLASS\"\n        val CATEGORY = \"CATEGORY\"\n        val TEMPLATE = \"TEMPLATE\"\n        val REDIRECT = \"REDIRECT\"\n    }\n\n}\n"
  },
  {
    "path": "src/main/scala/org/dbpedia/lookup/lucene/Searcher.scala",
    "content": "package org.dbpedia.lookup.lucene\n\nimport java.io.File\nimport org.apache.lucene.store.FSDirectory\nimport org.apache.lucene.search._\nimport org.apache.lucene.index.{Term, IndexReader}\nimport org.dbpedia.extraction.util.WikiUtil\nimport org.dbpedia.lookup.entities._\nimport org.apache.lucene.queryParser.QueryParser\n\n/**\n * Created by IntelliJ IDEA.\n * User: Max Jakob\n * Date: 14.01.11\n * Time: 14:43\n * Class to query the Lucene index for the best URI given a surface form.\n */\n\nclass Searcher(val indexDir: File) {\n\n    private val indexReader = IndexReader.open(FSDirectory.open(indexDir))\n    private val indexSearcher = new IndexSearcher(indexReader)\n    private val sort = new Sort(new SortField(LuceneConfig.Fields.REFCOUNT, SortField.INT, true))\n    private val queryParser = new QueryParser(LuceneConfig.version, LuceneConfig.Fields.SURFACE_FORM_KEYWORD, LuceneConfig.analyzer)\n\n\n    def keywordSearch(keyword: String, ontologyClass: String=\"\", maxResults: Int=5): List[Result] = {\n        if(keyword == null || keyword.isEmpty) {\n            return List.empty\n        }\n        val query = getQuery(keyword, ontologyClass, prefixQuery = false)\n        search(query, maxResults)\n    }\n\n    def prefixSearch(keyword: String, ontologyClass: String=\"\", maxResults: Int=5): List[Result] = {\n        if(keyword == null || keyword.isEmpty) {\n            return List.empty\n        }\n        val query = getQuery(keyword, ontologyClass, prefixQuery = true)\n        search(query, maxResults)\n    }\n\n    def close() {\n        indexSearcher.close()\n        indexReader.close()\n    }\n\n\n    private def search(query: Query, maxResults: Int): List[Result] = {\n        indexSearcher.search(query, null, maxResults, sort).scoreDocs.toList.map(getResult)\n    }\n\n    private def getQuery(keyword: String, ontologyClass: String, prefixQuery: Boolean = false): Query = {\n        val bq = new BooleanQuery\n\n        val decodedKeyword = WikiUtil.wikiDecode(keyword)\n\n        if(prefixQuery) {\n            val pseudoAnalyzedKeyword = LuceneConfig.PrefixSearchPseudoAnalyzer.analyze(decodedKeyword)\n            val prefixQuery = new PrefixQuery(new Term(LuceneConfig.Fields.SURFACE_FORM_PREFIX, pseudoAnalyzedKeyword))\n            bq.add(prefixQuery, BooleanClause.Occur.MUST)\n        }\n        else {\n            val escapedKeyword = QueryParser.escape(decodedKeyword)\n            val phraseQuery = synchronized { // query parser is not thread safe!\n              queryParser.parse('\"' + escapedKeyword + '\"')  //quotes keep word order\n            }\n            bq.add(phraseQuery, BooleanClause.Occur.MUST)\n        }\n\n        getOntologyClassQuery(ontologyClass) match {\n            case Some(q: Query) => bq.add(q, BooleanClause.Occur.MUST)\n            case _ =>\n        }\n\n        bq\n    }\n\n    private def getOntologyClassQuery(ontologyClass: String): Option[Query] = {\n        if(ontologyClass == null || ontologyClass.trim == \"\") {\n            None\n        }\n        else if(ontologyClass.toLowerCase == \"thing\" || ontologyClass.toLowerCase.endsWith(\"#thing\")) {\n            None\n        }\n        else {\n            val ontologyPrefix = \"http://dbpedia.org/ontology/\"\n            //is full class URI\n            if(ontologyClass startsWith ontologyPrefix) {\n                Some(new TermQuery(new Term(LuceneConfig.Fields.CLASS, ontologyClass.trim)))\n            }\n            //abbreviated namespace prefix\n            else if(ontologyClass.startsWith(\"dbpedia:\") || ontologyClass.startsWith(\"dbpedia-owl:\")) {\n                val c = ontologyClass.trim.replace(\"dbpedia:\", \"\").replace(\"dbpedia-owl:\", \"\")\n                Some(new TermQuery(new Term(LuceneConfig.Fields.CLASS, ontologyPrefix+c)))\n            }\n            //label given: make camel case and attach namespace\n            else {\n                val camel = ontologyClass.trim.split(\" \").map(_.capitalize).mkString(\"\")\n                Some(new TermQuery(new Term(LuceneConfig.Fields.CLASS, ontologyPrefix+camel)))\n            }\n        }\n    }\n\n    private def getResult(scoreDoc: ScoreDoc): Result = {\n        val doc = indexReader.document(scoreDoc.doc)\n\n        val uri: String = doc.get(LuceneConfig.Fields.URI)\n        val description: String = doc.get(LuceneConfig.Fields.DESCRIPTION)\n        val ontologyClasses: Set[OntologyClass] = doc.getValues(LuceneConfig.Fields.CLASS) match {\n            case null => Set.empty\n            case classes => classes.map(uri => new OntologyClass(uri)).toSet\n        }\n        val categories: Set[Category] = doc.getValues(LuceneConfig.Fields.CATEGORY) match {\n            case null => Set.empty\n            case cats => cats.map(uri => new Category(uri)).toSet\n        }\n        val templates: Set[Template] = doc.getValues(LuceneConfig.Fields.TEMPLATE) match {\n            case null => Set.empty\n            case temps => temps.map(uri => new Template(uri)).toSet\n        }\n        val redirects: Set[Redirect] = doc.getValues(LuceneConfig.Fields.REDIRECT) match {\n            case null => Set.empty\n            case reds => reds.map(uri => new Redirect(uri)).toSet\n        }\n        val refCount: Int = doc.get(LuceneConfig.Fields.REFCOUNT) match {\n            case null => 0\n            case count: String => count.toInt\n        }\n\n        new Result(uri, description, ontologyClasses, categories, templates, redirects, refCount)\n    }\n\n}\n"
  },
  {
    "path": "src/main/scala/org/dbpedia/lookup/server/LookupResource.scala",
    "content": "package org.dbpedia.lookup.server\n\nimport javax.ws.rs._\nimport javax.ws.rs.core.Context\nimport core.Response\nimport org.dbpedia.lookup.entities._\nimport org.dbpedia.lookup.lucene.Searcher\nimport org.dbpedia.lookup.util.Logging\n\n/**\n * Controller for DBpedia Lookup web service.\n */\n@Path(\"/api/search{ext:(.asmx)?}\")\n@Produces(Array(\"application/xml\", \"application/json\"))\nclass LookupResource extends Logging {\n\n    @Context\n    var searcher : Searcher = _\n\n    @DefaultValue(\"\") @HeaderParam(\"accept\")\n    var accept   : String   = _\n\n    @DefaultValue(\"\") @QueryParam(\"QueryString\")\n    var query    : String   = _\n\n    @DefaultValue(\"\") @QueryParam(\"QueryClass\")\n    var ontologyClass : String = _\n\n    @DefaultValue(\"5\") @QueryParam(\"MaxHits\")\n    var maxHits : Int = _\n\n    @GET\n    @Path(\"/KeywordSearch\")\n    def keywordSearch : Response = {\n        val results = searcher.keywordSearch(query, ontologyClass, maxHits)\n        logger.info(\"KeywordSearch found \"+results.length+\": MaxHits=\"+maxHits.toString+\" QueryClass=\"+ontologyClass+\" QueryString=\"+query)\n        ok(results)\n    }\n\n    @GET\n    @Path(\"/PrefixSearch\")\n    def prefixSearch : Response = {\n        val results = searcher.prefixSearch(query, ontologyClass, maxHits)\n        logger.info(\"PrefixSearch found \"+results.length+\": MaxHits=\"+maxHits.toString+\" QueryClass=\"+ontologyClass+\" QueryString=\"+query)\n        ok(results)\n    }\n\n    // Sets the necessary headers in order to enable CORS\n    private def ok(results: List[Result]): Response = {\n        Response.ok().entity(serialize(results)).header(\"Access-Control-Allow-Origin\", \"*\").build()\n    }\n\n    private def serialize(results: List[Result]): String = {\n        val serializer = (accept contains \"application/json\") match {\n            case true  => new ResultJsonSerializer\n            case _     => new ResultXmlSerializer\n        }\n        serializer.prettyPrint(results)\n    }\n\n}\n"
  },
  {
    "path": "src/main/scala/org/dbpedia/lookup/server/Server.scala",
    "content": "package org.dbpedia.lookup.server\n\nimport com.sun.jersey.api.container.httpserver.HttpServerFactory\nimport com.sun.jersey.api.core.ClassNamesResourceConfig\nimport com.sun.jersey.spi.inject.SingletonTypeInjectableProvider\nimport javax.ws.rs.core.Context\nimport java.net.URI\nimport org.dbpedia.lookup.lucene.Searcher\nimport java.io.File\nimport org.dbpedia.lookup.util.Logging\n\n/**\n * Created by IntelliJ IDEA.\n * User: Max\n * Date: 17.01.11\n * Time: 13:48\n * DBpedia Lookup Server\n */\n\nclass SearcherProvider(searcher: Searcher)\n    extends SingletonTypeInjectableProvider[Context, Searcher](classOf[Searcher], searcher)\n\nclass Server(port: Int, searcher: Searcher) {\n\n    val resources = {\n        val config = new ClassNamesResourceConfig(classOf[LookupResource])\n        config.getSingletons.add(new SearcherProvider(searcher))\n        config\n    }\n\n    val serverUri = new URI(\"http://localhost:\" + port.toString + \"/\")\n    val server    = HttpServerFactory.create(serverUri, resources)\n\n    def start() {\n        server.start()\n    }\n    def stop() {\n        server.stop(0)\n    }\n\n}\n\nobject Server extends Logging {\n\n    @volatile private var running = true\n\n    def main(args : Array[String]) {\n        val indexDir = new File(args(0))\n\n        val port   = System.getProperty(\"http.port\", \"1111\").toInt\n        val server = new Server(port, new Searcher(indexDir))\n\n        server.start()\n\n        val baseUri = server.serverUri.toString\n\n        logger.info(\"Server started in \" + System.getProperty(\"user.dir\") + \" listening on \" + baseUri)\n\n        while(running) {\n            Thread.sleep(100)\n        }\n\n        //Stop the HTTP server\n        server.stop()\n    }\n\n}\n"
  },
  {
    "path": "src/main/scala/org/dbpedia/lookup/util/Logging.scala",
    "content": "package org.dbpedia.lookup.util\n\nimport org.slf4j.LoggerFactory\n\ntrait Logging {\n    protected val logger = LoggerFactory.getLogger(getClass.getName)\n}\n"
  },
  {
    "path": "src/test/resources/data.nt",
    "content": "<http://dbpedia.org/resource/Berlin> <http://www.w3.org/2000/01/rdf-schema#comment> \"Berlin is the capital city of Germany and one of the 16 states of Germany. With a population of 3.5\\u00A0million people, Berlin is Germany's largest city and is the second most populous city proper and the eighth most populous urban area in the European Union. Located in northeastern Germany, it is the center of the Berlin-Brandenburg Metropolitan Region, which has 5.9\\u00A0million residents from over 190 nations. Located in the European Plains, Berlin is influenced by a temperate seasonal climate.\"@en .\n<http://dbpedia.org/resource/Berlin> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://dbpedia.org/ontology/City> .\n<http://dbpedia.org/resource/Berlin> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/City> .\n<http://dbpedia.org/resource/Berlin> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://dbpedia.org/ontology/Settlement> .\n<http://dbpedia.org/resource/Berlin> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://dbpedia.org/ontology/PopulatedPlace> .\n<http://dbpedia.org/resource/Berlin> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://dbpedia.org/ontology/Place> .\n<http://dbpedia.org/resource/Berlin> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Place> .\n<http://dbpedia.org/resource/Berlin> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> .\n<http://dbpedia.org/resource/Berlin> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Berlin> .\n<http://dbpedia.org/resource/Berlin> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Capitals_in_Europe> .\n<http://dbpedia.org/resource/Berlin> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:City-states> .\n<http://dbpedia.org/resource/Berlin> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:European_Capitals_of_Culture> .\n<http://dbpedia.org/resource/Berlin> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:German_state_capitals> .\n<http://dbpedia.org/resource/Berlin> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Host_cities_of_the_Summer_Olympic_Games> .\n<http://dbpedia.org/resource/Berlin> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Members_of_the_Hanseatic_League> .\n<http://dbpedia.org/resource/Berlin> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Populated_places_established_in_the_13th_century> .\n<http://dbpedia.org/resource/Berlin> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:States_and_territories_established_in_1237> .\n<http://dbpedia.org/resource/Berlin> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:States_of_Germany> .\n<http://dbpedia.org/resource/Berlin> <http://lexvo.org/ontology#label> \"Berlin\"@en .\n<http://dbpedia.org/resource/Berlin> <http://lexvo.org/ontology#label> \"capital of Germany\"@en .\n<http://dbpedia.org/resource/Berlin> <http://dbpedia.org/property/refCount> \"100\"^^<http://www.w3.org/2001/XMLSchema#integer> .\n<http://dbpedia.org/resource/Beirut> <http://www.w3.org/2000/01/rdf-schema#comment> \"Beirut is the capital and largest city of Lebanon. As there has been no recent population census, the exact population is unknown; estimates in 2007 ranged from slightly less than 1\\u00A0million to slightly more than 2\\u00A0million. Located on a peninsula at the midpoint of Lebanon's Mediterranean coast, it serves as the country's largest and main seaport. The Beirut metropolitan area consists of the city and its suburbs.\"@en .\n<http://dbpedia.org/resource/Beirut> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://dbpedia.org/ontology/Settlement> .\n<http://dbpedia.org/resource/Beirut> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://dbpedia.org/ontology/PopulatedPlace> .\n<http://dbpedia.org/resource/Beirut> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://dbpedia.org/ontology/Place> .\n<http://dbpedia.org/resource/Beirut> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Place> .\n<http://dbpedia.org/resource/Beirut> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> .\n<http://dbpedia.org/resource/Beirut> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Beirut> .\n<http://dbpedia.org/resource/Beirut> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Amarna_letters_locations> .\n<http://dbpedia.org/resource/Beirut> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Ancient_cities> .\n<http://dbpedia.org/resource/Beirut> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Ancient_Greek_sites_in_Lebanon> .\n<http://dbpedia.org/resource/Beirut> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Ancient_mints> .\n<http://dbpedia.org/resource/Beirut> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Archaeological_sites_in_Lebanon> .\n<http://dbpedia.org/resource/Beirut> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Capitals_in_Asia> .\n<http://dbpedia.org/resource/Beirut> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Populated_places_in_the_Beirut_Governorate> .\n<http://dbpedia.org/resource/Beirut> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Populated_coastal_places_in_Lebanon> .\n<http://dbpedia.org/resource/Beirut> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Crusades> .\n<http://dbpedia.org/resource/Beirut> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Hellenistic_colonies> .\n<http://dbpedia.org/resource/Beirut> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Mediterranean> .\n<http://dbpedia.org/resource/Beirut> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Mediterranean_port_cities_and_towns_in_Lebanon> .\n<http://dbpedia.org/resource/Beirut> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Phoenician_cities> .\n<http://dbpedia.org/resource/Beirut> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Phoenician_sites_in_Lebanon> .\n<http://dbpedia.org/resource/Beirut> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Roman_colonies> .\n<http://dbpedia.org/resource/Beirut> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Roman_sites_in_Lebanon> .\n<http://dbpedia.org/resource/Beirut> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Populated_places_established_in_the_3rd_millennium_BC> .\n<http://dbpedia.org/resource/Beirut> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Paleolithic> .\n<http://dbpedia.org/resource/Beirut> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Neolithic_settlements> .\n<http://dbpedia.org/resource/Beirut> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Fertile_Crescent> .\n<http://dbpedia.org/resource/Beirut> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Ancient_Levant> .\n<http://dbpedia.org/resource/Beirut> <http://lexvo.org/ontology#label> \"Beirut\"@en .\n<http://dbpedia.org/resource/Beirut> <http://lexvo.org/ontology#label> \"largest city of Lebanon\"@en .\n<http://dbpedia.org/resource/Beirut> <http://dbpedia.org/property/refCount> \"99\"^^<http://www.w3.org/2001/XMLSchema#integer> .\n<http://dbpedia.org/resource/Beirut_(band)> <http://www.w3.org/2000/01/rdf-schema#comment> \"Beirut is an American band which was originally the solo musical project of Santa Fe native Zachary Francis Condon, and later expanded into a band. The band's first performances were in New York, in May 2006, to support the release of their debut album, Gulag Orkestar. Beirut's music combines elements of indie-rock and world music.\"@en .\n<http://dbpedia.org/resource/Beirut_(band)> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://dbpedia.org/ontology/Band> .\n<http://dbpedia.org/resource/Beirut_(band)> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://dbpedia.org/ontology/Organisation> .\n<http://dbpedia.org/resource/Beirut_(band)> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Organization> .\n<http://dbpedia.org/resource/Beirut_(band)> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://dbpedia.org/ontology/Agent> .\n<http://dbpedia.org/resource/Beirut_(band)> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> .\n<http://dbpedia.org/resource/Beirut_(band)> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/MusicGroup> .\n<http://dbpedia.org/resource/Beirut_(band)> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:American_indie_rock_groups> .\n<http://dbpedia.org/resource/Beirut_(band)> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Musical_groups_from_New_Mexico> .\n<http://dbpedia.org/resource/Beirut_(band)> <http://lexvo.org/ontology#label> \"Beirut\"@en .\n<http://dbpedia.org/resource/Beirut_(band)> <http://lexvo.org/ontology#label> \"American band\"@en .\n<http://dbpedia.org/resource/Beirut_(band)> <http://dbpedia.org/property/refCount> \"98\"^^<http://www.w3.org/2001/XMLSchema#integer> .\n"
  },
  {
    "path": "src/test/resources/logback-test.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<configuration>\n    <root>\n        <level value=\"OFF\"/>\n    </root>\n</configuration>\n"
  },
  {
    "path": "src/test/resources/redirects.nt",
    "content": "<http://dbpedia.org/resource/CityBerlin> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Berlin> .\n<http://dbpedia.org/resource/Berlin,_Germany> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Berlin> .\n<http://dbpedia.org/resource/Capital_of_East_Germany> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Berlin> .\n<http://dbpedia.org/resource/DEBER> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Berlin> .\n<http://dbpedia.org/resource/Berullin> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Berlin> .\n<http://dbpedia.org/resource/Berulin> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Berlin> .\n<http://dbpedia.org/resource/Bereullin> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Berlin> .\n<http://dbpedia.org/resource/UN/LOCODE:DEBER> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Berlin> .\n<http://dbpedia.org/resource/Berlin-Zentrum> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Berlin> .\n<http://dbpedia.org/resource/Berlib> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Berlin> .\n<http://dbpedia.org/resource/Land_Berlin> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Berlin> .\n<http://dbpedia.org/resource/Berlin.de> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Berlin> .\n<http://dbpedia.org/resource/Berlin-ru.net> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Berlin> .\n<http://dbpedia.org/resource/Berlin-turkish.com> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Berlin> .\n<http://dbpedia.org/resource/Berlin-china.net> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Berlin> .\n<http://dbpedia.org/resource/Berlin_(Germany)> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Berlin> .\n<http://dbpedia.org/resource/Federal_State_of_Berlin> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Berlin> .\n<http://dbpedia.org/resource/City_of_Berlin> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Berlin> .\n<http://dbpedia.org/resource/Historical_sites_in_berlin> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Berlin> .\n<http://dbpedia.org/resource/Bayrut> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Beirut,_Lebanon> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Beroth> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Capital_of_Lebanon> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Beyrouth> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Beyreuth> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Beyrut> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Bayr%C3%BBt> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Beyrout> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/West_Beirut> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Bairut> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Berytus> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Beiruit> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Pigeon's_Rock> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/BEIRUT> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Bayr%C5%ABt> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Biruta> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Beirut_District> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Beiruth> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Galerie_Semaan> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Bkirki> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/%D8%A8%D9%8A%D8%B1%D9%88%D8%AA> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/West_Beirut_lebanon> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Beirut_west> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/East_Beirut> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/East_beirut> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Laodicea_in_Phoenicia> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Beiro%C3%BBt> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Asia/Beirut> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Rmeil> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Beirut_I> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Beirut_II> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Beirut_III> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Beirut_IV> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Beirut_V> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Beirut_VI> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Beirut_VII> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Minet_el_Hosn> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Um_el_Khatib> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Furn_esh_Shebbak> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Plateau_Tabet> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Furn_esh_Shebbak_(river_banks)> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Rivoli_Cinema> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Byblos_Cinema> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut> .\n<http://dbpedia.org/resource/Zach_Condon> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut_(band)> .\n<http://dbpedia.org/resource/Beirut_band> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut_(band)> .\n<http://dbpedia.org/resource/Beirut_(musician)> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut_(band)> .\n<http://dbpedia.org/resource/Beirutando> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut_(band)> .\n<http://dbpedia.org/resource/Zach_condon> <http://dbpedia.org/ontology/wikiPageRedirects> <http://dbpedia.org/resource/Beirut_(band)> .\n"
  },
  {
    "path": "src/test/scala/org/dbpedia/lookup/IntegrationTest.scala",
    "content": "package org.dbpedia.lookup\n\nimport org.dbpedia.lookup.lucene._\nimport org.dbpedia.lookup.server._\nimport com.sun.jersey.api.client._\nimport net.liftweb.json._\nimport scala.xml._\n\nimport org.scalatest.FunSuite\nimport org.scalatest.BeforeAndAfterAll\n\n/**\n * Full stack test\n *\n * 1. build index\n * 2. Start server\n * 3. Interrogate server via Jersey client over HTTP\n * 4. Kill server, delete index\n */\nclass IntegrationTest extends FunSuite with BeforeAndAfterAll {\n\n  val tmpDir = TestUtils.tempDirectory\n  val port   = TestUtils.tempPort\n\n  var server : Server = _\n\n  override def beforeAll() {\n    Indexer.main(Array(tmpDir.toString, \"src/test/resources/redirects.nt\", \"src/test/resources/data.nt\"))\n    server = new Server(port, new Searcher(tmpDir))\n    server.start\n  }\n\n  override def afterAll() {\n    server.stop\n    tmpDir.delete\n  }\n\n  def get(path: String, accepts: String = \"application/xml\") = {\n    val client   = new Client\n    val resource = client.resource(\"http://localhost:\" + port.toString + path)\n    resource.accept(accepts).get(classOf[ClientResponse])\n  }\n\n  test(\"KeywordSearch works\") {\n    val body   = get(\"/api/search/KeywordSearch?QueryString=Beirut\").getEntity(classOf[String])\n    val xml    = XML.loadString(body)\n    assert((xml \\ \"Result\" \\ \"Label\").head.text == \"Beirut\")\n    assert((xml \\ \"Result\" \\ \"Label\").tail.head.text == \"Beirut (band)\")\n    assert((xml \\ \"Result\").size == 2)\n  }\n\n  test(\"PrefixSearch works\") {\n    val body   = get(\"/api/search/PrefixSearch?QueryString=berl\").getEntity(classOf[String])\n    val xml    = XML.loadString(body)\n    assert((xml \\ \"Result\" \\ \"Label\").head.text == \"Berlin\")\n    assert((xml \\ \"Result\").size == 1)\n  }\n\n  test(\"QueryClass works\") {\n    val body   = get(\"/api/search/KeywordSearch?QueryClass=place&QueryString=Beirut\").getEntity(classOf[String])\n    val xml    = XML.loadString(body)\n    assert((xml \\ \"Result\" \\ \"Label\").head.text == \"Beirut\")\n    assert((xml \\ \"Result\").size == 1)\n  }\n\n  test(\"MaxHits works\") {\n    val body = get(\"/api/search/KeywordSearch?MaxHits=1&QueryString=beirut\").getEntity(classOf[String])\n    val xml  = XML.loadString(body)\n    assert((xml \\ \"Result\").size == 1)\n  }\n\n  test(\"legacy .asmx in url is optional\") {\n    assert(get(\"/api/search.asmx/KeywordSearch\").getStatus == 200)\n    assert(get(\"/api/search/KeywordSearch\").getStatus == 200)\n  }\n\n  test(\"json results are returned when correct accepts header given\") {\n    val response = get(\"/api/search/KeywordSearch\", \"application/json\")\n    assert(response.getType.toString == \"application/json\")\n    assert(parse(response.getEntity(classOf[String])) \\\\ \"results\" == JArray(List()))\n  }\n\n}\n"
  },
  {
    "path": "src/test/scala/org/dbpedia/lookup/TestUtils.scala",
    "content": "package org.dbpedia.lookup\n\nimport org.dbpedia.lookup.lucene._\nimport org.dbpedia.lookup.server._\nimport java.io.File\n\nobject TestUtils {\n\n  def tempDirectory : File = {\n    val file = File.createTempFile(\"lookup\", \"\")\n    file.delete\n    file.mkdir\n    file\n  }\n\n  def tempPort : Int = new java.net.ServerSocket(0).getLocalPort\n\n}\n\n"
  },
  {
    "path": "src/test/scala/org/dbpedia/lookup/entities/EntitiesSerializationTest.scala",
    "content": "package org.dbpedia.lookup.entities\n\nimport org.scalatest.FunSuite\nimport net.liftweb.json._\n\ntrait SerializationTest extends FunSuite {\n\n  val template = new Template(\"http://en.wikipedia.org/wiki/Template:Infobox\")\n\n  val redirect = new Redirect(\"http://en.wikipedia.org/wiki/A_page\")\n\n  val klass    = new OntologyClass(\"http://dbpedia.org/ontology/City\")\n\n  val category = new Category(\"http://dbpedia.org/resource/Category:Berlin\")\n\n  val result   = new Result(\n     \"http://dbpedia.org/resource/Berlin\",\n     \"Berlin is the capital city of Germany & <> ...\",\n     Set(klass),\n     Set(category),\n     Set(template),\n     Set(redirect),\n     100\n   )\n\n}\n\nclass EntitiesJsonSerializationTest extends SerializationTest {\n\n  val serializer = new ResultJsonSerializer\n\n  test(\"a list of result entities should serialize to json correctly\") {\n    implicit val formats = net.liftweb.json.DefaultFormats\n\n    val json = serializer.prettyPrint(List(result, result))\n    val data = Serialization.read[Map[String, List[Result]]](json)\n\n    assert(data(\"results\").size == 2)\n    assert(data(\"results\").head == result)\n  }\n\n}\n\nclass EntitiesXmlSerializationTest extends SerializationTest {\n\n  val serializer = new ResultXmlSerializer\n\n  test(\"a list of result entities should serialize to xml correctly\") {\n    val xml = serializer.serialize(List(result, result))\n    assert((xml \\ \"Result\").size == 2)\n  }\n\n  test(\"the result entity should serialize to XML correctly\") {\n\n    val xml = serializer.serialize(result)\n\n    assert((xml \\ \"Label\").text == result.label)\n    assert((xml \\ \"URI\").text == result.uri)\n    assert((xml \\ \"Description\").text == result.description)\n    assert((xml \\ \"Refcount\").text == result.refCount.toString)\n\n    assert((xml \\ \"Classes\" \\ \"Class\" \\ \"URI\").text == result.classes.head.uri)\n    assert((xml \\ \"Classes\" \\ \"Class\" \\ \"Label\").text == result.classes.head.label)\n\n    assert((xml \\ \"Categories\" \\ \"Category\" \\ \"URI\").text == result.categories.head.uri)\n    assert((xml \\ \"Categories\" \\ \"Category\" \\ \"Label\").text == result.categories.head.label)\n\n    assert((xml \\ \"Templates\" \\ \"Template\" \\ \"URI\").text == result.templates.head.uri)\n    assert((xml \\ \"Redirects\" \\ \"Redirect\" \\ \"URI\").text == result.redirects.head.uri)\n\n  }\n\n}\n"
  },
  {
    "path": "src/test/scala/org/dbpedia/lookup/entities/EntitiesTest.scala",
    "content": "package org.dbpedia.lookup.entities\n\nimport org.scalatest.FunSuite\n\nclass EntitiesTest extends FunSuite {\n\n  test(\"category entity has correct label for uri\") {\n    val category = new Category(\"http://dbpedia.org/resource/Category:Berlin\")\n    assert(category.label == \"Berlin\", \"category label incorrect\")\n  }\n\n  test(\"class entity has correct label for uri\") {\n    val klass = new OntologyClass(\"http://dbpedia.org/ontology/City\")\n    assert(klass.label == \"city\", \"class label incorrect\")\n  }\n\n  test(\"class entity has correct label for owl#Thing\") {\n    val klass = new OntologyClass(\"http://www.w3.org/2002/07/owl#Thing\")\n    assert(klass.label == \"owl#Thing\", \"class label incorrect\")\n  }\n\n  test(\"result entity has correct label for uri\") {\n    val result = new Result(\n      \"http://dbpedia.org/resource/Berlin\",\n      \"Some description ...\",\n      Set[OntologyClass](),\n      Set[Category](),\n      Set[Template](),\n      Set[Redirect](),\n      100\n    )\n    assert(result.label == \"Berlin\", \"result label incorrect\")\n  }\n\n}\n"
  }
]