|
1 | 1 | # Netspeak Java Client |
2 | 2 |
|
3 | | -## Build |
| 3 | +Java wrapper for the Python client of the [Netspeak](https://netspeak.org) API. |
| 4 | + |
| 5 | +## Getting started |
| 6 | + |
| 7 | +### Installation |
| 8 | + |
| 9 | +Include the following dependency to your project with a Java build tool or as a jar. |
| 10 | + |
| 11 | +#### Maven |
| 12 | + |
| 13 | +Add this to your `pom.xml`: |
| 14 | +```xml |
| 15 | +<dependencies> |
| 16 | + <dependency> |
| 17 | + <groupId>org.netspeak</groupId> |
| 18 | + <artifactId>netspeak-client</artifactId> |
| 19 | + <version>1.0</version> |
| 20 | + </dependency> |
| 21 | +</dependencies> |
| 22 | + |
| 23 | +<repositories> |
| 24 | + <repository> |
| 25 | + <id>central</id> |
| 26 | + <name>repo.webis.de-releases</name> |
| 27 | + <url>https://repo.webis.de/artifactory/libs-release-webis-gradle</url> |
| 28 | + </repository> |
| 29 | +</repositories> |
| 30 | +``` |
| 31 | + |
| 32 | +#### Gradle |
| 33 | +Add this to your ```build.gradle```: |
| 34 | +``` |
| 35 | +allprojects { |
| 36 | + dependencies { |
| 37 | + implementation: 'org.netspeak:netspeak-client:1.0' |
| 38 | + } |
| 39 | +} |
| 40 | +
|
| 41 | +repositories { |
| 42 | + maven { |
| 43 | + url = uri('https://repo.webis.de/artifactory/libs-release-webis-gradle') |
| 44 | + } |
| 45 | +} |
| 46 | +``` |
| 47 | + |
| 48 | +### Example |
| 49 | + |
| 50 | +```java |
| 51 | +public class NetspeakExample { |
| 52 | + public static void main(String[] args) throws IOException { |
| 53 | + NetspeakClient netspeakClient = null; |
| 54 | + try { |
| 55 | + netspeakClient = new NetspeakClient(); |
| 56 | + SearchResults searchResults = netspeakClient.search("how to ? this"); |
| 57 | + searchResults.getPhrases().forEach(System.out::println); |
| 58 | + searchResults = netspeakClient.search("see ... works"); |
| 59 | + searchResults.getPhrases().forEach(System.out::println); |
| 60 | + } catch (Exception e) { |
| 61 | + throw new RuntimeException("Oh no. Something went wrong :(", e); |
| 62 | + } finally { |
| 63 | + if (netspeakClient != null) { |
| 64 | + netspeakClient.close(); |
| 65 | + } |
| 66 | + } |
| 67 | + } |
| 68 | +} |
| 69 | +``` |
| 70 | +Output: |
| 71 | +``` |
| 72 | +17792498317 | how to use this | 1173949 |
| 73 | +18070422879 | how to do this | 683555 |
| 74 | +17539336244 | how to cite this | 238643 |
| 75 | +17484924196 | how to replace this | 107430 |
| 76 | +17459212956 | how to make this | 99505 |
| 77 | +17638239519 | how to fix this | 93255 |
| 78 | +18090204579 | how to read this | 79438 |
| 79 | +17258432776 | how to get this | 69259 |
| 80 | +18138655059 | how to buy this | 68219 |
| 81 | +18015051915 | how to solve this | 57270 |
| 82 | +18005462970 | see how it works | 153607 |
| 83 | +17958967532 | see if it works | 109130 |
| 84 | +8809913773 | see works | 57119 |
| 85 | +18117207447 | see how this works | 55568 |
| 86 | +13100502274 | see what works | 51526 |
| 87 | +13214698030 | see the works | 51438 |
| 88 | +17592059436 | see if that works | 28690 |
| 89 | +17555456765 | see your good works | 28615 |
| 90 | +17870947984 | see how that works | 25243 |
| 91 | +17599975532 | see how technorati works | 23345 |
| 92 | +``` |
| 93 | + |
| 94 | +## Build from source |
4 | 95 |
|
5 | 96 | ### Requirements |
6 | 97 | * Python 3.10 or newer |
7 | 98 | * Virtualenv |
8 | | -* Java 15 and Maven |
| 99 | +* Java 15 |
| 100 | +* Maven |
9 | 101 | * Make |
10 | 102 |
|
11 | 103 | ### Commands |
12 | 104 |
|
13 | | -``make build`` |
| 105 | +```bash |
| 106 | +git clone git@github.com:netspeak/netspeak-client-java.git |
| 107 | +make build |
| 108 | +``` |
14 | 109 |
|
0 commit comments