From dea94984b3a46e852e3e50519814672a8ea3f1f5 Mon Sep 17 00:00:00 2001 From: lintool Date: Sat, 18 Dec 2021 13:09:32 -0500 Subject: [PATCH] Cleanup build warnings --- .../io/anserini/collection/CommonCrawlWetCollection.java | 3 ++- src/main/java/io/anserini/collection/DocumentCollection.java | 4 +++- .../java/io/anserini/collection/FeverSentenceCollection.java | 3 +++ src/main/java/io/anserini/collection/WarcBaseDocument.java | 1 + src/main/java/io/anserini/ltr/FeatureExtractorUtils.java | 5 +++-- src/main/java/io/anserini/ltr/QueryFieldContext.java | 3 +++ .../io/anserini/search/SimpleNearestNeighborSearcher.java | 4 ++-- .../search/topicreader/BackgroundLinkingTopicReader.java | 3 --- src/main/java/io/anserini/search/topicreader/Topics.java | 4 ++-- 9 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/main/java/io/anserini/collection/CommonCrawlWetCollection.java b/src/main/java/io/anserini/collection/CommonCrawlWetCollection.java index 2d543eed8c..7abcdbcfbf 100644 --- a/src/main/java/io/anserini/collection/CommonCrawlWetCollection.java +++ b/src/main/java/io/anserini/collection/CommonCrawlWetCollection.java @@ -88,7 +88,7 @@ public static class Document extends WarcBaseDocument { /** * Reads in a WARC record from a data input stream. * - * @param in the input stream + * @param in the input stream * @return a WARC record (or null if EOF) * @throws IOException if error encountered reading from stream */ @@ -112,6 +112,7 @@ public static Document readNextWarcRecord(DataInputStream in) * * @param in the data input stream * @param headerBuffer a blank string buffer to contain the WARC header + * @param headerEndKey delimiter of the end of the header * @return the content bytes (with the headerBuffer populated) * @throws IOException if error encountered reading from stream */ diff --git a/src/main/java/io/anserini/collection/DocumentCollection.java b/src/main/java/io/anserini/collection/DocumentCollection.java index cdc5bd1f8e..0301077a07 100644 --- a/src/main/java/io/anserini/collection/DocumentCollection.java +++ b/src/main/java/io/anserini/collection/DocumentCollection.java @@ -154,8 +154,10 @@ public List getSegmentPaths() { } /** - * Returns the paths in the collection, taking into account sharding + * Returns the paths in the collection, taking into account sharding. * + * @param currShard the current shard + * @param shardCount the total number of shards * @return file segments in current shard */ public List getSegmentPaths(int shardCount, int currShard) { diff --git a/src/main/java/io/anserini/collection/FeverSentenceCollection.java b/src/main/java/io/anserini/collection/FeverSentenceCollection.java index c097a283c9..1860219d82 100644 --- a/src/main/java/io/anserini/collection/FeverSentenceCollection.java +++ b/src/main/java/io/anserini/collection/FeverSentenceCollection.java @@ -96,6 +96,9 @@ protected void readNext() throws NoSuchElementException { * Extracts the sentences out of the "lines" field in the FEVER JSONL * files. Takes a JsonNode object for a single document as input and * returns a Stream of JsonNodes, one for each sentence. + * + * @param json object representing a single document + * @return stream of sentences */ protected Stream flattenToSentences(JsonNode json) { ObjectMapper mapper = new ObjectMapper(); diff --git a/src/main/java/io/anserini/collection/WarcBaseDocument.java b/src/main/java/io/anserini/collection/WarcBaseDocument.java index 00a39b11eb..15691f2be6 100644 --- a/src/main/java/io/anserini/collection/WarcBaseDocument.java +++ b/src/main/java/io/anserini/collection/WarcBaseDocument.java @@ -222,6 +222,7 @@ protected static String readLineFromInputStream(DataInputStream in) throws IOExc * * @param in the data input stream * @param headerBuffer a blank string buffer to contain the WARC header + * @param headerEndKey delimiter of the end of the header * @return the content bytes (with the headerBuffer populated) * @throws IOException if error encountered reading from stream */ diff --git a/src/main/java/io/anserini/ltr/FeatureExtractorUtils.java b/src/main/java/io/anserini/ltr/FeatureExtractorUtils.java index ca46d0c2e3..0e79e12d1d 100644 --- a/src/main/java/io/anserini/ltr/FeatureExtractorUtils.java +++ b/src/main/java/io/anserini/ltr/FeatureExtractorUtils.java @@ -98,6 +98,7 @@ public List list() { * @throws InterruptedException * @throws JsonProcessingException */ + @SuppressWarnings("unchecked") public List extract(String qid, List docIds, List queryTokens) throws ExecutionException, InterruptedException, JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); Map json = new HashMap(); @@ -188,12 +189,11 @@ public void addTask(String qid, List docIds, JsonNode jsonQuery) { })); } - - /** * submit tasks to workers, exposed in Pyserini * @throws JsonProcessingException */ + @SuppressWarnings("unchecked") public String lazyExtract(String jsonInput) throws JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); JsonNode root = mapper.readValue(jsonInput, JsonNode.class); @@ -207,6 +207,7 @@ public String lazyExtract(String jsonInput) throws JsonProcessingException { * submit tasks to workers, exposed in Pyserini * @throws JsonProcessingException */ + @SuppressWarnings("unchecked") public String debugExtract(String jsonInput) throws JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); JsonNode root = mapper.readValue(jsonInput, JsonNode.class); diff --git a/src/main/java/io/anserini/ltr/QueryFieldContext.java b/src/main/java/io/anserini/ltr/QueryFieldContext.java index 2d989c02a3..0618a10eb1 100644 --- a/src/main/java/io/anserini/ltr/QueryFieldContext.java +++ b/src/main/java/io/anserini/ltr/QueryFieldContext.java @@ -32,6 +32,8 @@ public class QueryFieldContext { public int querySize; private Map> featureLog; + + @SuppressWarnings("unchecked") public QueryFieldContext(String fieldName, JsonNode root){ this.fieldName = fieldName; ObjectMapper mapper = new ObjectMapper(); @@ -42,6 +44,7 @@ public QueryFieldContext(String fieldName, JsonNode root){ queryFreqs.put(token, queryFreqs.getOrDefault(token,0)+1); this.featureLog = new HashMap<>(); } + public List> genQueryPair() { List> queryPairs = new ArrayList<>(); for (int i = 0; i < queryTokens.size() - 1; i++) { diff --git a/src/main/java/io/anserini/search/SimpleNearestNeighborSearcher.java b/src/main/java/io/anserini/search/SimpleNearestNeighborSearcher.java index 60800550bd..2cf51d50ac 100644 --- a/src/main/java/io/anserini/search/SimpleNearestNeighborSearcher.java +++ b/src/main/java/io/anserini/search/SimpleNearestNeighborSearcher.java @@ -74,7 +74,7 @@ public SimpleNearestNeighborSearcher(String path, String encoding) throws IOExce * @param id the input document identifier * @param d the number of nearest neighbors to retrieve * @return an array of nearest neighbors - * @throws IOException + * @throws IOException if error encountered during search */ public Result[] search(String id, int d) throws IOException { Result[][] neighbors = multisearch(id, 1, d); @@ -87,7 +87,7 @@ public Result[] search(String id, int d) throws IOException { * @param id documents' identifier * @param k the number of nearest neighbors to retrieve for each document with the given id * @return an array of nearest neighbors for each matching document - * @throws IOException + * @throws IOException if error encountered during search */ public Result[][] multisearch(String id, int k) throws IOException { return multisearch(id, Integer.MAX_VALUE, k); diff --git a/src/main/java/io/anserini/search/topicreader/BackgroundLinkingTopicReader.java b/src/main/java/io/anserini/search/topicreader/BackgroundLinkingTopicReader.java index 267cc3e66c..576e86af27 100644 --- a/src/main/java/io/anserini/search/topicreader/BackgroundLinkingTopicReader.java +++ b/src/main/java/io/anserini/search/topicreader/BackgroundLinkingTopicReader.java @@ -102,9 +102,6 @@ public SortedMap> read(BufferedReader bRdr) throws return map; } - /** - * Extracts the top k terms from document in terms of tf-idf. - */ public static List extractTerms(IndexReader reader, String docid, int k, Analyzer analyzer) throws IOException { // Fetch the raw JSON representation of the document. diff --git a/src/main/java/io/anserini/search/topicreader/Topics.java b/src/main/java/io/anserini/search/topicreader/Topics.java index 3f449e9295..4c11cc5ebb 100755 --- a/src/main/java/io/anserini/search/topicreader/Topics.java +++ b/src/main/java/io/anserini/search/topicreader/Topics.java @@ -125,9 +125,9 @@ public enum Topics { MRTYDI_V11_TH_TEST(TsvIntTopicReader.class, "topics-and-qrels/topics.mrtydi-v1.1-th.test.txt.gz"); public final String path; - public final Class readerClass; + public final Class readerClass; - Topics(Class c, String path) { + Topics(Class c, String path) { this.readerClass = c; this.path = path; }