Work in progress.

This commit is contained in:
Woody Folsom
2012-03-11 16:49:20 -04:00
parent 571d0a1922
commit d5d73003d2
13 changed files with 833 additions and 67 deletions

628
data/survey.xml Normal file
View File

@@ -0,0 +1,628 @@
<?xml version="1.0" encoding="UTF-8" ?>
<survey>
<dishes>
<entry>
<int>0</int>
<string>Honey cake</string>
</entry>
<entry>
<int>1</int>
<string>Kahlua Cake</string>
</entry>
<entry>
<int>2</int>
<string>Ice Cream, Lowfat</string>
</entry>
<entry>
<int>3</int>
<string>Southwest Smoothie</string>
</entry>
<entry>
<int>4</int>
<string>Margarita Sunrise</string>
</entry>
<entry>
<int>5</int>
<string>Breaded Veal Cutlet ( Weinerschnitzel )</string>
</entry>
<entry>
<int>6</int>
<string>Blender Double Fudge Cake</string>
</entry>
<entry>
<int>7</int>
<string>Chinese: Cashew Chicken 1</string>
</entry>
<entry>
<int>8</int>
<string>Bayou Shrimp Creole</string>
</entry>
<entry>
<int>9</int>
<string>Crab Burgers</string>
</entry>
<entry>
<int>10</int>
<string>Broiled Flounder</string>
</entry>
<entry>
<int>11</int>
<string>Coconut Beer Batter Shrimp</string>
</entry>
<entry>
<int>12</int>
<string>Coconut Fish Curry</string>
</entry>
<entry>
<int>13</int>
<string>Catalan Rice</string>
</entry>
<entry>
<int>14</int>
<string>Baked Steak And Lima Beans</string>
</entry>
<entry>
<int>15</int>
<string>Tabasco Classic - Perfect Seared Steaks ****</string>
</entry>
<entry>
<int>16</int>
<string>Salisbury Steak with Mushroom Sauce</string>
</entry>
<entry>
<int>17</int>
<string>Meatless Loaf</string>
</entry>
<entry>
<int>18</int>
<string>Black Bean Soup</string>
</entry>
<entry>
<int>29</int>
<string>Fava Bean Burgers</string>
</entry>
<entry>
<int>20</int>
<string>Angel Hair Pesto Primavera</string>
</entry>
<entry>
<int>21</int>
<string>EGGPLANT LASAGNE</string>
</entry>
</dishes>
<categories>
<entry>
<int>0</int>
<string>
chocolate
</string>
</entry>
<entry>
<int>1</int>
<string>
nuts
</string>
</entry>
<entry>
<int>2</int>
<string>
shellfish
</string>
</entry>
</categories>
<diner>
<id>0</id>
<ratings>
<entry>
<int>0</int>
<int>10</int>
</entry>
<entry>
<int>1</int>
<int>10</int>
</entry>
<entry>
<int>2</int>
<int>10</int>
</entry>
<entry>
<int>3</int>
<int>10</int>
</entry>
<entry>
<int>4</int>
<int>10</int>
</entry>
<entry>
<int>5</int>
<int>10</int>
</entry>
<entry>
<int>6</int>
<int>10</int>
</entry>
<entry>
<int>7</int>
<int>10</int>
</entry>
<entry>
<int>8</int>
<int>10</int>
</entry>
<entry>
<int>9</int>
<int>10</int>
</entry>
<entry>
<int>10</int>
<int>10</int>
</entry>
<entry>
<int>11</int>
<int>10</int>
</entry>
<entry>
<int>12</int>
<int>10</int>
</entry>
<entry>
<int>13</int>
<int>10</int>
</entry>
<entry>
<int>14</int>
<int>10</int>
</entry>
<entry>
<int>15</int>
<int>10</int>
</entry>
<entry>
<int>16</int>
<int>10</int>
</entry>
<entry>
<int>17</int>
<int>10</int>
</entry>
<entry>
<int>18</int>
<int>10</int>
</entry>
<entry>
<int>19</int>
<int>10</int>
</entry>
<entry>
<int>20</int>
<int>10</int>
</entry>
</ratings>
<allergies>
<entry>
<int>0</int>
<boolean>false</boolean>
</entry>
<entry>
<int>1</int>
<boolean>false</boolean>
</entry>
<entry>
<int>2</int>
<boolean>false</boolean>
</entry>
</allergies>
</diner>
<diner>
<id>1</id>
<ratings>
<entry>
<int>0</int>
<int>10</int>
</entry>
<entry>
<int>1</int>
<int>10</int>
</entry>
<entry>
<int>2</int>
<int>10</int>
</entry>
<entry>
<int>3</int>
<int>10</int>
</entry>
<entry>
<int>4</int>
<int>10</int>
</entry>
<entry>
<int>5</int>
<int>10</int>
</entry>
<entry>
<int>6</int>
<int>10</int>
</entry>
<entry>
<int>7</int>
<int>10</int>
</entry>
<entry>
<int>8</int>
<int>10</int>
</entry>
<entry>
<int>9</int>
<int>10</int>
</entry>
<entry>
<int>10</int>
<int>10</int>
</entry>
<entry>
<int>11</int>
<int>10</int>
</entry>
<entry>
<int>12</int>
<int>10</int>
</entry>
<entry>
<int>13</int>
<int>10</int>
</entry>
<entry>
<int>14</int>
<int>10</int>
</entry>
<entry>
<int>15</int>
<int>10</int>
</entry>
<entry>
<int>16</int>
<int>10</int>
</entry>
<entry>
<int>17</int>
<int>10</int>
</entry>
<entry>
<int>18</int>
<int>10</int>
</entry>
<entry>
<int>19</int>
<int>10</int>
</entry>
<entry>
<int>20</int>
<int>10</int>
</entry>
</ratings>
<allergies>
<entry>
<int>0</int>
<boolean>false</boolean>
</entry>
<entry>
<int>1</int>
<boolean>false</boolean>
</entry>
<entry>
<int>2</int>
<boolean>false</boolean>
</entry>
</allergies>
</diner>
<diner>
<id>2</id>
<ratings>
<entry>
<int>0</int>
<int>10</int>
</entry>
<entry>
<int>1</int>
<int>10</int>
</entry>
<entry>
<int>2</int>
<int>10</int>
</entry>
<entry>
<int>3</int>
<int>10</int>
</entry>
<entry>
<int>4</int>
<int>10</int>
</entry>
<entry>
<int>5</int>
<int>10</int>
</entry>
<entry>
<int>6</int>
<int>10</int>
</entry>
<entry>
<int>7</int>
<int>10</int>
</entry>
<entry>
<int>8</int>
<int>10</int>
</entry>
<entry>
<int>9</int>
<int>10</int>
</entry>
<entry>
<int>10</int>
<int>10</int>
</entry>
<entry>
<int>11</int>
<int>10</int>
</entry>
<entry>
<int>12</int>
<int>10</int>
</entry>
<entry>
<int>13</int>
<int>10</int>
</entry>
<entry>
<int>14</int>
<int>10</int>
</entry>
<entry>
<int>15</int>
<int>10</int>
</entry>
<entry>
<int>16</int>
<int>10</int>
</entry>
<entry>
<int>17</int>
<int>10</int>
</entry>
<entry>
<int>18</int>
<int>10</int>
</entry>
<entry>
<int>19</int>
<int>10</int>
</entry>
<entry>
<int>20</int>
<int>10</int>
</entry>
</ratings>
<allergies>
<entry>
<int>0</int>
<boolean>false</boolean>
</entry>
<entry>
<int>1</int>
<boolean>false</boolean>
</entry>
<entry>
<int>2</int>
<boolean>false</boolean>
</entry>
</allergies>
</diner>
<diner>
<id>3</id>
<ratings>
<entry>
<int>0</int>
<int>10</int>
</entry>
<entry>
<int>1</int>
<int>10</int>
</entry>
<entry>
<int>2</int>
<int>10</int>
</entry>
<entry>
<int>3</int>
<int>10</int>
</entry>
<entry>
<int>4</int>
<int>10</int>
</entry>
<entry>
<int>5</int>
<int>10</int>
</entry>
<entry>
<int>6</int>
<int>10</int>
</entry>
<entry>
<int>7</int>
<int>10</int>
</entry>
<entry>
<int>8</int>
<int>10</int>
</entry>
<entry>
<int>9</int>
<int>10</int>
</entry>
<entry>
<int>10</int>
<int>10</int>
</entry>
<entry>
<int>11</int>
<int>10</int>
</entry>
<entry>
<int>12</int>
<int>10</int>
</entry>
<entry>
<int>13</int>
<int>10</int>
</entry>
<entry>
<int>14</int>
<int>10</int>
</entry>
<entry>
<int>15</int>
<int>10</int>
</entry>
<entry>
<int>16</int>
<int>10</int>
</entry>
<entry>
<int>17</int>
<int>10</int>
</entry>
<entry>
<int>18</int>
<int>10</int>
</entry>
<entry>
<int>19</int>
<int>10</int>
</entry>
<entry>
<int>20</int>
<int>10</int>
</entry>
</ratings>
<allergies>
<entry>
<int>0</int>
<boolean>false</boolean>
</entry>
<entry>
<int>1</int>
<boolean>false</boolean>
</entry>
<entry>
<int>2</int>
<boolean>false</boolean>
</entry>
</allergies>
</diner>
<diner>
<id>4</id>
<ratings>
<entry>
<int>0</int>
<int>10</int>
</entry>
<entry>
<int>1</int>
<int>10</int>
</entry>
<entry>
<int>2</int>
<int>10</int>
</entry>
<entry>
<int>3</int>
<int>10</int>
</entry>
<entry>
<int>4</int>
<int>10</int>
</entry>
<entry>
<int>5</int>
<int>10</int>
</entry>
<entry>
<int>6</int>
<int>10</int>
</entry>
<entry>
<int>7</int>
<int>10</int>
</entry>
<entry>
<int>8</int>
<int>10</int>
</entry>
<entry>
<int>9</int>
<int>10</int>
</entry>
<entry>
<int>10</int>
<int>10</int>
</entry>
<entry>
<int>11</int>
<int>10</int>
</entry>
<entry>
<int>12</int>
<int>10</int>
</entry>
<entry>
<int>13</int>
<int>10</int>
</entry>
<entry>
<int>14</int>
<int>10</int>
</entry>
<entry>
<int>15</int>
<int>10</int>
</entry>
<entry>
<int>16</int>
<int>10</int>
</entry>
<entry>
<int>17</int>
<int>10</int>
</entry>
<entry>
<int>18</int>
<int>10</int>
</entry>
<entry>
<int>19</int>
<int>10</int>
</entry>
<entry>
<int>20</int>
<int>10</int>
</entry>
</ratings>
<allergies>
<entry>
<int>0</int>
<boolean>false</boolean>
</entry>
<entry>
<int>1</int>
<boolean>false</boolean>
</entry>
<entry>
<int>2</int>
<boolean>false</boolean>
</entry>
</allergies>
</diner>
</survey>

View File

@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE recipeml PUBLIC "-//FormatData//DTD RecipeML 0.5//EN" "http://www.formatdata.com/recipeml/recipeml.dtd"><recipeml version="0.5" generator="Krecipes v2.0-beta1">
<!DOCTYPE recipeml PUBLIC "-//FormatData//DTD RecipeML 0.5//EN"
"http://www.formatdata.com/recipeml/recipeml.dtd">
<recipeml version="0.5" generator="Krecipes v2.0-beta1">
<recipe>
<head>
<title>Honey cake</title>

View File

@@ -0,0 +1,28 @@
package net.woodyfolsom.cs6601.p2;
import java.io.File;
public class BayesChef {
public static void main(String... args) {
System.out.println("Reading recipe book.");
RecipeBook recipeBook = RecipeBookReader.readRecipeBook(new File("data/survey_recipes.xml"));
System.out.println("Read data for " + recipeBook.getSize() + " recipes.");
System.out.println("Reading survey data.");
Survey survey = SurveyReader.readSurvey(new File("data/survey.xml"));
System.out.println("Read data for " + survey.getDinerCount() + " diner(s).");
System.out.println("Setting evidence for first 11 recipes.");
System.out.println("Evaluating preference for remaining recipes.");
System.out.println("RMSE for recipes #12-22 (calculated vs. surveyed preference):");
for (int dinerIndex = 0; dinerIndex < survey.getDinerCount(); dinerIndex++) {
System.out.println("Diner # " + (dinerIndex + 1) + "...");
}
}
}

View File

@@ -0,0 +1,25 @@
package net.woodyfolsom.cs6601.p2;
import java.util.HashMap;
import java.util.Map;
import com.thoughtworks.xstream.annotations.XStreamAlias;
@XStreamAlias("diner")
public class Diner {
private int id;
private Map<Integer,Integer> ratings = new HashMap<Integer,Integer>();
private Map<Integer,Boolean> allergies = new HashMap<Integer,Boolean>();
public int getId() {
return id;
}
public int getRating(int dishId) {
return ratings.get(dishId);
}
public boolean isAllergic(int categoryId) {
return allergies.get(categoryId);
}
}

View File

@@ -0,0 +1,42 @@
package net.woodyfolsom.cs6601.p2;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamImplicit;
@XStreamAlias("survey")
public class Survey {
private Map<Integer,String> dishes = new HashMap<Integer,String>();
private Map<Integer,String> categories = new HashMap<Integer,String>();
@XStreamImplicit(itemFieldName="diner")
private List<Diner> diners = new ArrayList<Diner>();
public Diner getDiner(int dinerIndex) {
return diners.get(dinerIndex);
}
public int getDinerCount() {
return diners.size();
}
public String getDish(int dishId) {
return dishes.get(dishId);
}
public int getDishCount() {
return dishes.size();
}
public String getCategory(int catId) {
return categories.get(catId);
}
public int getCategoryCount() {
return categories.size();
}
}

View File

@@ -0,0 +1,13 @@
package net.woodyfolsom.cs6601.p2;
import java.io.File;
import com.thoughtworks.xstream.XStream;
public class SurveyReader {
private static XStream xstream = XStreamFactory.getInstance();
public static Survey readSurvey(File surveyFile) {
return (Survey) xstream.fromXML(surveyFile);
}
}

View File

@@ -10,9 +10,9 @@ public class XStreamFactory {
public static XStream getInstance() {
XStream xstream = new XStream(new DomDriver());
///RecipeBook
xstream.processAnnotations(RecipeBook.class);
xstream.processAnnotations(Recipe.class);
xstream.omitField(Recipe.class, "directions");
@@ -32,6 +32,10 @@ public class XStreamFactory {
xstream.omitField(Ingredient.class, "amt");
xstream.omitField(Ingredient.class, "prep");
///Survey
xstream.processAnnotations(Survey.class);
xstream.processAnnotations(Diner.class);
return xstream;
}
}

View File

@@ -34,9 +34,9 @@ public class FoodExampleTest {
+ table.getAssignments().get(assignment).getProbability());
}
System.out.println("MEET: ");
System.out.println("MEAT: ");
table = (ProbabilityTable) net.getNodes().get(
FoodExampleBuilder.CONTAINS_MEET);
FoodExampleBuilder.CONTAINS_MEAT);
for (String name : table.getNames()) {
System.out.print(name + " ");
}

View File

@@ -19,7 +19,7 @@ public class FoodExampleBuilder {
public static final String TASTE = "Taste";
public static final String SOMEONE_VEGETARIAN = "Vegetarian";
public static final String CONTAINS_MEET = "Meet";
public static final String CONTAINS_MEAT = "Meat";
public static final String CONTAINS_VEGETABLE = "Vegetable";
public static final String CONTAINS_BEEF = "Beef";
public static final String CONTAINS_PORK = "Pork";
@@ -35,7 +35,7 @@ public class FoodExampleBuilder {
"6", "7", "8", "9", "10" };
private static final String[] VARIABLES = { SOMEONE_VEGETARIAN,
CONTAINS_BEEF, CONTAINS_MEET, CONTAINS_PORK, CONTAINS_POTATOS,
CONTAINS_BEEF, CONTAINS_MEAT, CONTAINS_PORK, CONTAINS_POTATOS,
CONTAINS_TOMATOS, CONTAINS_VEGETABLE, TASTE };
private static final String[] OBSERVED = { CONTAINS_BEEF, CONTAINS_PORK,
@@ -59,13 +59,13 @@ public class FoodExampleBuilder {
return new LinkedList<Assignment>(assignment);
}
public static Ontology onto() {
public static Ontology createOntology() {
HashSet<String> classes = new HashSet<String>();
classes.add(CONTAINS_MEET);
classes.add(CONTAINS_MEAT);
classes.add(CONTAINS_VEGETABLE);
Ontology onthology = new Ontology(classes);
onthology.define(CONTAINS_PORK, CONTAINS_MEET);
onthology.define(CONTAINS_BEEF, CONTAINS_MEET);
onthology.define(CONTAINS_PORK, CONTAINS_MEAT);
onthology.define(CONTAINS_BEEF, CONTAINS_MEAT);
onthology.define(CONTAINS_TOMATOS, CONTAINS_VEGETABLE);
onthology.define(CONTAINS_POTATOS, CONTAINS_VEGETABLE);
@@ -146,7 +146,7 @@ public class FoodExampleBuilder {
public static DataSet examples() {
DataSet data = new DataSet();
Ontology onto = onto();
Ontology onto = createOntology();
// user one ratings
data.add(normalize(porkTomatoDish(10), onto));
data.add(normalize(porkPotatoDish(9), onto));
@@ -184,19 +184,19 @@ public class FoodExampleBuilder {
}
public static ProbabilityDistribution beef() {
String names[] = { CONTAINS_MEET, CONTAINS_BEEF };
String names[] = { CONTAINS_MEAT, CONTAINS_BEEF };
ProbabilityTable table = new ProbabilityTable(names);
return table;
}
public static ProbabilityDistribution pork() {
String names[] = { CONTAINS_MEET, CONTAINS_PORK };
String names[] = { CONTAINS_MEAT, CONTAINS_PORK };
ProbabilityTable table = new ProbabilityTable(names);
return table;
}
public static ProbabilityDistribution meet() {
String names[] = { SOMEONE_VEGETARIAN, CONTAINS_MEET };
String names[] = { SOMEONE_VEGETARIAN, CONTAINS_MEAT };
ProbabilityTable table = new ProbabilityTable(names);
return table;
}
@@ -229,7 +229,7 @@ public class FoodExampleBuilder {
public static BayesNet dishNet() {
BayesNet net = new BayesNet(VARIABLES);
net.setDistribution(new Variable(SOMEONE_VEGETARIAN, DOMAIN), vegi());
net.setDistribution(new Variable(CONTAINS_MEET, DOMAIN), meet());
net.setDistribution(new Variable(CONTAINS_MEAT, DOMAIN), meet());
net.setDistribution(new Variable(CONTAINS_VEGETABLE, DOMAIN),
vegetables());
net.setDistribution(new Variable(CONTAINS_BEEF, DOMAIN), beef());
@@ -238,19 +238,19 @@ public class FoodExampleBuilder {
net.setDistribution(new Variable(CONTAINS_TOMATOS, DOMAIN), tomatos());
net.setDistribution(new Variable(TASTE, RATING_DOMAIN), taste());
Ontology onthology = onto();
for (String category : onthology.getClasses()) {
Ontology ontology = createOntology();
for (String category : ontology.getClasses()) {
net.connect(category, SOMEONE_VEGETARIAN);
}
for (String thing : OBSERVED) {
net.connect(thing, onthology.getInheritance().get(thing));
net.connect(thing, ontology.getInheritance().get(thing));
net.connect(TASTE, thing);
}
for (String category : onthology.getClasses()) {
for (String category : ontology.getClasses()) {
MaximumLikelihoodEstimation.estimate(examples(), net, category);
for (String thing : onthology.getClasses2thing().get(category)) {
for (String thing : ontology.getClasses2thing().get(category)) {
MaximumLikelihoodEstimation.estimate(examples(), net, thing);
}
}

View File

@@ -8,6 +8,7 @@ import static org.hamcrest.CoreMatchers.*;
import java.io.File;
import net.woodyfolsom.cs6601.p2.Ingredient.TYPE;
import net.woodyfolsom.cs6601.p2.Recipe;
import net.woodyfolsom.cs6601.p2.RecipeBook;
import net.woodyfolsom.cs6601.p2.RecipeBookReader;
@@ -17,15 +18,23 @@ import org.junit.Test;
public class RecipeBookReaderTest {
@Test
public void testReadRecipeBook() {
RecipeBook recipeBook = RecipeBookReader.readRecipeBook(new File("data/PastelVasco.xml"));
public void testReadSurveyDataset() {
RecipeBook recipeBook = RecipeBookReader.readRecipeBook(new File("data/survey_recipes.xml"));
assertNotNull(recipeBook);
assertThat(recipeBook.getSize(), is(equalTo(1)));
assertThat(recipeBook.getSize(), is(equalTo(22)));
Recipe recipe = recipeBook.getRecipe(0);
assertThat(recipe.getHead().getTitle(), is(equalTo("Gateau Basque / Pastel Vasco")));
assertTrue(recipe.getHead().isCategoryMatch("Desserts"));
assertTrue(recipe.getHead().isCategoryMatch("Sweets"));
assertFalse(recipe.getHead().isCategoryMatch("Meat"));
System.out.println(recipe.getHead().getTitle());
assertThat(recipe.getHead().getTitle(), is(equalTo("Honey cake")));
assertTrue(recipe.getIngredients().contains(TYPE.EGGS));
assertTrue(recipe.getIngredients().contains(TYPE.GLUTEN));
assertTrue(recipe.getIngredients().contains(TYPE.SPICE));
assertFalse(recipe.getIngredients().contains(TYPE.RED_MEAT));
assertFalse(recipe.getIngredients().contains(TYPE.POULTRY));
assertFalse(recipe.getIngredients().contains(TYPE.SHELLFISH));
for (int rIndex = 0; rIndex < recipeBook.getSize(); rIndex++) {
System.out.println(recipeBook.getRecipe(rIndex).getHead().getTitle());
}
}
}

View File

@@ -0,0 +1,31 @@
package net.woodyfolsom.cs6601.p2;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.hamcrest.CoreMatchers.*;
import java.io.File;
import net.woodyfolsom.cs6601.p2.Recipe;
import net.woodyfolsom.cs6601.p2.RecipeBook;
import net.woodyfolsom.cs6601.p2.RecipeBookReader;
import org.junit.Test;
public class RecipeReaderTest {
@Test
public void testReadRecipeBook() {
RecipeBook recipeBook = RecipeBookReader.readRecipeBook(new File("data/PastelVasco.xml"));
assertNotNull(recipeBook);
assertThat(recipeBook.getSize(), is(equalTo(1)));
Recipe recipe = recipeBook.getRecipe(0);
assertThat(recipe.getHead().getTitle(), is(equalTo("Gateau Basque / Pastel Vasco")));
assertTrue(recipe.getHead().isCategoryMatch("Desserts"));
assertTrue(recipe.getHead().isCategoryMatch("Sweets"));
assertFalse(recipe.getHead().isCategoryMatch("Meat"));
}
}

View File

@@ -1,40 +0,0 @@
package net.woodyfolsom.cs6601.p2;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.hamcrest.CoreMatchers.*;
import java.io.File;
import net.woodyfolsom.cs6601.p2.Ingredient.TYPE;
import net.woodyfolsom.cs6601.p2.Recipe;
import net.woodyfolsom.cs6601.p2.RecipeBook;
import net.woodyfolsom.cs6601.p2.RecipeBookReader;
import org.junit.Test;
public class SurveyDatasetReaderTest {
@Test
public void testReadSurveyDataset() {
RecipeBook recipeBook = RecipeBookReader.readRecipeBook(new File("data/survey_dataset.xml"));
assertNotNull(recipeBook);
assertThat(recipeBook.getSize(), is(equalTo(22)));
Recipe recipe = recipeBook.getRecipe(0);
System.out.println(recipe.getHead().getTitle());
assertThat(recipe.getHead().getTitle(), is(equalTo("Honey cake")));
assertTrue(recipe.getIngredients().contains(TYPE.EGGS));
assertTrue(recipe.getIngredients().contains(TYPE.GLUTEN));
assertTrue(recipe.getIngredients().contains(TYPE.SPICE));
assertFalse(recipe.getIngredients().contains(TYPE.RED_MEAT));
assertFalse(recipe.getIngredients().contains(TYPE.POULTRY));
assertFalse(recipe.getIngredients().contains(TYPE.SHELLFISH));
for (int rIndex = 0; rIndex < recipeBook.getSize(); rIndex++) {
System.out.println(recipeBook.getRecipe(rIndex).getHead().getTitle());
}
}
}

View File

@@ -0,0 +1,24 @@
package net.woodyfolsom.cs6601.p2;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.hamcrest.core.Is.*;
import java.io.File;
import org.junit.Test;
public class SurveyReaderTest {
@Test
public void testReadSurveyDataset() {
Survey survey = SurveyReader.readSurvey(new File("data/survey.xml"));
assertNotNull(survey);
assertThat(survey.getDinerCount(), equalTo(5));
Diner diner = survey.getDiner(0);
assertThat(diner.isAllergic(0), is(false));
}
}