<commit_before>/*
 *  Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  See the NOTICE file distributed with
 *  this work for additional information regarding copyright ownership.
 *  The ASF licenses this file to You under the Apache License, Version 2.0
 *  (the "License"); you may not use this file except in compliance with
 *  the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.yawni.wn;

import org.yawni.util.Utils;
import static org.yawni.util.Utils.*;
import static org.fest.assertions.Assertions.assertThat;
import java.util.*;
import org.junit.BeforeClass;
import org.junit.Test;
import org.yawni.util.Joiner;

public class DictionaryDatabaseTest {
  private static DictionaryDatabase dictionary;
  @BeforeClass
  public static void init() {
    dictionary = FileBackedDictionary.getInstance();
  }

  /** 
   * test POS.ALL support
   * + List<String> lookupBaseForms(POS pos, String someString)
   * - List<Synset> lookupSynsets(POS pos, String someString)
   * - Iterator<Relation> relations(POS pos)
   * - Iterator<Relation> relations(POS pos, RelationType relationType)
   * - Iterator<Word> words(POS pos)
   * - Iterator<Synset> synsets(POS pos)
   * - Iterator<WordSense> wordSenses(POS pos)
   */
  //@Ignore
  @Test
  public void test() {
    final List<String> tanks = dictionary.lookupBaseForms("tank", POS.ALL);
    System.err.println("tanks: "+tanks);
    final List<String> geese = dictionary.lookupBaseForms("geese", POS.ALL);
    System.err.println("geese: "+geese);
  }

  /**
   * Expects exception because POS.ALL does not make sense for method 
   * lookupWord(POS, lemma) which returns at most 1 result.
   * TODO subclass IllegalArgumentException (a RuntimeException) 
   * indicating this.
   */
  @Test(expected=IllegalArgumentException.class)
  public void test_lookupWord() {
    dictionary.lookupWord("tank", POS.ALL);
  }

  /**
   * Look for warning issues with lookupSynsets()
   */
  @Test
  public void lookupSynsetsTest() {
    //String str = "allow for";
    //String str = "allowing for";
    String str = "allows for";
    POS pos = POS.VERB;<commit_msg>exploring lookupBaseForms()<commit_after>/*
 *  Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  See the NOTICE file distributed with
 *  this work for additional information regarding copyright ownership.
 *  The ASF licenses this file to You under the Apache License, Version 2.0
 *  (the "License"); you may not use this file except in compliance with
 *  the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.yawni.wn;

import org.yawni.util.Utils;
import static org.yawni.util.Utils.*;
import static org.fest.assertions.Assertions.assertThat;
import java.util.*;
import org.junit.BeforeClass;
import org.junit.Test;
import org.yawni.util.Joiner;

public class DictionaryDatabaseTest {
  private static DictionaryDatabase dictionary;
  @BeforeClass
  public static void init() {
    dictionary = FileBackedDictionary.getInstance();
  }

  /** 
   * test POS.ALL support
   * + List<String> lookupBaseForms(POS pos, String someString)
   * - List<Synset> lookupSynsets(POS pos, String someString)
   * - Iterator<Relation> relations(POS pos)
   * - Iterator<Relation> relations(POS pos, RelationType relationType)
   * - Iterator<Word> words(POS pos)
   * - Iterator<Synset> synsets(POS pos)
   * - Iterator<WordSense> wordSenses(POS pos)
   */
  //@Ignore
  @Test
  public void test() {
    String query;
    List<String> results;
    query = "tank";
    results = dictionary.lookupBaseForms(query, POS.ALL);
    System.err.println("query: "+query+" results: "+results);
    query = "geese";
    results = dictionary.lookupBaseForms(query, POS.ALL);
    System.err.println("query: "+query+" results: "+results);
    query = "mouse";
    results = dictionary.lookupBaseForms(query, POS.ALL);
    System.err.println("query: "+query+" results: "+results);
    // queries with more than 1 baseform
    query = "mice";
    results = dictionary.lookupBaseForms(query, POS.ALL);
    System.err.println("query: "+query+" results: "+results);
    query = "wings";
    results = dictionary.lookupBaseForms(query, POS.ALL);
    System.err.println("query: "+query+" results: "+results);
    query = "years";
    results = dictionary.lookupBaseForms(query, POS.ALL);
    System.err.println("query: "+query+" results: "+results);
    query = "businessmen";
    results = dictionary.lookupBaseForms(query, POS.ALL);
    System.err.println("query: "+query+" results: "+results);
    query = "men";
    results = dictionary.lookupBaseForms(query, POS.ALL);
    System.err.println("query: "+query+" results: "+results);
  }

  /**
   * Expects exception because POS.ALL does not make sense for method 
   * lookupWord(POS, lemma) which returns at most 1 result.
   * TODO subclass IllegalArgumentException (a RuntimeException) 
   * indicating this.
   */
  @Test(expected=IllegalArgumentException.class)
  public void test_lookupWord() {
    dictionary.lookupWord("tank", POS.ALL);
  }

  /**
   * Look for warning issues with lookupSynsets()
   */
  @Test
  public void lookupSynsetsTest() {
    //String str = "allow for";
    //String str = "allowing for";
    String str = "allows for";
    POS pos = POS.VERB;
{'fraction_non_alphanumeric': 0.11187438665358194, 'fraction_numerical': 0.001799149492966961, 'mean_word_length': 3.781078967943706, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '825870', 'n_tokens_mistral': 1805, 'n_tokens_neox': 1753, 'n_words': 568}