Skip to content

Commit

Permalink
Clean up build warnings (#1710)
Browse files Browse the repository at this point in the history
  • Loading branch information
lintool committed Dec 18, 2021
1 parent 2dc2bff commit c0fa772
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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
*/
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/io/anserini/collection/DocumentCollection.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,10 @@ public List<Path> 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<Path> getSegmentPaths(int shardCount, int currShard) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<JsonNode> flattenToSentences(JsonNode json) {
ObjectMapper mapper = new ObjectMapper();
Expand Down
1 change: 1 addition & 0 deletions src/main/java/io/anserini/collection/WarcBaseDocument.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/io/anserini/ltr/FeatureExtractorUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public List<String> list() {
* @throws InterruptedException
* @throws JsonProcessingException
*/
@SuppressWarnings("unchecked")
public List<debugOutput> extract(String qid, List<String> docIds, List<String> queryTokens) throws ExecutionException, InterruptedException, JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> json = new HashMap();
Expand Down Expand Up @@ -188,12 +189,11 @@ public void addTask(String qid, List<String> 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);
Expand All @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/io/anserini/ltr/QueryFieldContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public class QueryFieldContext {
public int querySize;

private Map<String, Map<String, Float>> featureLog;

@SuppressWarnings("unchecked")
public QueryFieldContext(String fieldName, JsonNode root){
this.fieldName = fieldName;
ObjectMapper mapper = new ObjectMapper();
Expand All @@ -42,6 +44,7 @@ public QueryFieldContext(String fieldName, JsonNode root){
queryFreqs.put(token, queryFreqs.getOrDefault(token,0)+1);
this.featureLog = new HashMap<>();
}

public List<Pair<String, String>> genQueryPair() {
List<Pair<String, String>> queryPairs = new ArrayList<>();
for (int i = 0; i < queryTokens.size() - 1; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ public SortedMap<Integer, Map<String, String>> read(BufferedReader bRdr) throws
return map;
}

/**
* Extracts the top <i>k</i> terms from document in terms of tf-idf.
*/
public static List<String> extractTerms(IndexReader reader, String docid, int k, Analyzer analyzer)
throws IOException {
// Fetch the raw JSON representation of the document.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/anserini/search/topicreader/Topics.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<? extends TopicReader> readerClass;

Topics(Class c, String path) {
Topics(Class<? extends TopicReader> c, String path) {
this.readerClass = c;
this.path = path;
}
Expand Down

0 comments on commit c0fa772

Please sign in to comment.