From 8444136be1aee077354dbc2bb7e5f378a832e206 Mon Sep 17 00:00:00 2001 From: David Huynh Date: Fri, 5 Feb 2010 08:39:10 +0000 Subject: [PATCH] Added control constructs to expression language. Fixed bugs in multi-value cell split/join operations. Condensed movies-condensed.tsv test data further. git-svn-id: http://google-refine.googlecode.com/svn/trunk@45 7d457c2a-affb-35e4-300a-418c747d4874 --- .../com/metaweb/gridworks/expr/Control.java | 7 ++ .../gridworks/expr/ControlCallExpr.java | 32 ++++++ .../gridworks/expr/ExpressionUtils.java | 11 ++ .../com/metaweb/gridworks/expr/Parser.java | 28 ++++- .../metaweb/gridworks/expr/VariableExpr.java | 4 + .../gridworks/expr/controls/ForEach.java | 50 +++++++++ .../gridworks/expr/controls/ForNonBlank.java | 40 +++++++ .../metaweb/gridworks/expr/controls/If.java | 25 +++++ .../metaweb/gridworks/expr/functions/Get.java | 101 ++++++++++-------- .../gridworks/expr/functions/IsBlank.java | 15 +++ .../gridworks/expr/functions/IsNotBlank.java | 15 +++ .../java/com/metaweb/gridworks/model/Row.java | 3 +- .../MultiValueCellJoinOperation.java | 2 +- .../MultiValueCellSplitOperation.java | 2 +- tests/movies-condensed.tsv | 46 ++++---- 15 files changed, 302 insertions(+), 79 deletions(-) create mode 100644 src/main/java/com/metaweb/gridworks/expr/Control.java create mode 100644 src/main/java/com/metaweb/gridworks/expr/ControlCallExpr.java create mode 100644 src/main/java/com/metaweb/gridworks/expr/controls/ForEach.java create mode 100644 src/main/java/com/metaweb/gridworks/expr/controls/ForNonBlank.java create mode 100644 src/main/java/com/metaweb/gridworks/expr/controls/If.java create mode 100644 src/main/java/com/metaweb/gridworks/expr/functions/IsBlank.java create mode 100644 src/main/java/com/metaweb/gridworks/expr/functions/IsNotBlank.java diff --git a/src/main/java/com/metaweb/gridworks/expr/Control.java b/src/main/java/com/metaweb/gridworks/expr/Control.java new file mode 100644 index 000000000..67432c365 --- /dev/null +++ b/src/main/java/com/metaweb/gridworks/expr/Control.java @@ -0,0 +1,7 @@ +package com.metaweb.gridworks.expr; + +import java.util.Properties; + +public interface Control { + public Object call(Properties bindings, Evaluable[] args); +} diff --git a/src/main/java/com/metaweb/gridworks/expr/ControlCallExpr.java b/src/main/java/com/metaweb/gridworks/expr/ControlCallExpr.java new file mode 100644 index 000000000..db8dce2e9 --- /dev/null +++ b/src/main/java/com/metaweb/gridworks/expr/ControlCallExpr.java @@ -0,0 +1,32 @@ +package com.metaweb.gridworks.expr; + +import java.util.Properties; + +public class ControlCallExpr implements Evaluable { + final protected Evaluable[] _args; + final protected Control _control; + + public ControlCallExpr(Evaluable[] args, Control c) { + _args = args; + _control = c; + } + + @Override + public Object evaluate(Properties bindings) { + return _control.call(bindings, _args); + } + + @Override + public String toString() { + StringBuffer sb = new StringBuffer(); + + for (Evaluable ev : _args) { + if (sb.length() > 0) { + sb.append(", "); + } + sb.append(ev.toString()); + } + + return _control.getClass().getSimpleName() + "(" + sb.toString() + ")"; + } +} diff --git a/src/main/java/com/metaweb/gridworks/expr/ExpressionUtils.java b/src/main/java/com/metaweb/gridworks/expr/ExpressionUtils.java index 79f0a34a6..c103d1f13 100644 --- a/src/main/java/com/metaweb/gridworks/expr/ExpressionUtils.java +++ b/src/main/java/com/metaweb/gridworks/expr/ExpressionUtils.java @@ -25,4 +25,15 @@ public class ExpressionUtils { bindings.put("cell", cell); bindings.put("value", cell.value); } + + static public boolean isBlank(Object o) { + return o == null || (o instanceof String && ((String) o).isEmpty()); + } + + static public boolean isTrue(Object o) { + return o != null && + (o instanceof Boolean ? + ((Boolean) o).booleanValue() : + Boolean.parseBoolean(o.toString())); + } } diff --git a/src/main/java/com/metaweb/gridworks/expr/Parser.java b/src/main/java/com/metaweb/gridworks/expr/Parser.java index f902178c7..25a41b7c6 100644 --- a/src/main/java/com/metaweb/gridworks/expr/Parser.java +++ b/src/main/java/com/metaweb/gridworks/expr/Parser.java @@ -8,8 +8,13 @@ import java.util.Map; import com.metaweb.gridworks.expr.Scanner.NumberToken; import com.metaweb.gridworks.expr.Scanner.Token; import com.metaweb.gridworks.expr.Scanner.TokenType; +import com.metaweb.gridworks.expr.controls.ForEach; +import com.metaweb.gridworks.expr.controls.ForNonBlank; +import com.metaweb.gridworks.expr.controls.If; import com.metaweb.gridworks.expr.functions.And; import com.metaweb.gridworks.expr.functions.Get; +import com.metaweb.gridworks.expr.functions.IsBlank; +import com.metaweb.gridworks.expr.functions.IsNotBlank; import com.metaweb.gridworks.expr.functions.IsNotNull; import com.metaweb.gridworks.expr.functions.IsNull; import com.metaweb.gridworks.expr.functions.Not; @@ -27,6 +32,8 @@ public class Parser { protected Evaluable _root; static public Map functionTable = new HashMap(); + static public Map controlTable = new HashMap(); + static { functionTable.put("toUppercase", new ToUppercase()); functionTable.put("toLowercase", new ToLowercase()); @@ -43,8 +50,14 @@ public class Parser { functionTable.put("not", new Not()); functionTable.put("isNull", new IsNull()); functionTable.put("isNotNull", new IsNotNull()); - } - + functionTable.put("isBlank", new IsBlank()); + functionTable.put("isNotBlank", new IsNotBlank()); + + controlTable.put("if", new If()); + controlTable.put("forEach", new ForEach()); + controlTable.put("forNonBlank", new ForNonBlank()); + } + public Parser(String s) throws Exception { this(s, 0, s.length()); } @@ -157,15 +170,20 @@ public class Parser { eval = new VariableExpr(text); } else { Function f = functionTable.get(text); - if (f == null) { - throw makeException("Unknown function " + text); + Control c = controlTable.get(text); + if (f == null && c == null) { + throw makeException("Unknown function or control named " + text); } next(); // swallow ( List args = parseExpressionList(")"); - eval = new FunctionCallExpr(makeArray(args), f); + if (c != null) { + eval = new ControlCallExpr(makeArray(args), c); + } else { + eval = new FunctionCallExpr(makeArray(args), f); + } } } else if (_token.type == TokenType.Delimiter && _token.text.equals("(")) { next(); diff --git a/src/main/java/com/metaweb/gridworks/expr/VariableExpr.java b/src/main/java/com/metaweb/gridworks/expr/VariableExpr.java index 74227acfc..7bac3e190 100644 --- a/src/main/java/com/metaweb/gridworks/expr/VariableExpr.java +++ b/src/main/java/com/metaweb/gridworks/expr/VariableExpr.java @@ -18,4 +18,8 @@ public class VariableExpr implements Evaluable { public String toString() { return _name; } + + public String getName() { + return _name; + } } diff --git a/src/main/java/com/metaweb/gridworks/expr/controls/ForEach.java b/src/main/java/com/metaweb/gridworks/expr/controls/ForEach.java new file mode 100644 index 000000000..e7ac56c9a --- /dev/null +++ b/src/main/java/com/metaweb/gridworks/expr/controls/ForEach.java @@ -0,0 +1,50 @@ +package com.metaweb.gridworks.expr.controls; + +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +import com.metaweb.gridworks.expr.Control; +import com.metaweb.gridworks.expr.Evaluable; +import com.metaweb.gridworks.expr.VariableExpr; + +public class ForEach implements Control { + + @Override + public Object call(Properties bindings, Evaluable[] args) { + if (args.length >= 3) { + Object o = args[0].evaluate(bindings); + Evaluable var = args[1]; + String name = (var instanceof VariableExpr) ? ((VariableExpr) var).getName() : + ((String) var.evaluate(bindings)); + + if (o != null) { + Object oldValue = bindings.get(name); + try { + Object[] values; + if (o.getClass().isArray()) { + values = (Object[]) o; + } else { + values = new Object[] { o }; + } + + List results = new ArrayList(values.length); + for (Object v : values) { + bindings.put(name, v); + + Object r = args[2].evaluate(bindings); + if (r != null) { + results.add(r); + } + } + + return results.toArray(); + } finally { + bindings.put(name, oldValue); + } + } + } + return null; + } + +} diff --git a/src/main/java/com/metaweb/gridworks/expr/controls/ForNonBlank.java b/src/main/java/com/metaweb/gridworks/expr/controls/ForNonBlank.java new file mode 100644 index 000000000..187c62ce6 --- /dev/null +++ b/src/main/java/com/metaweb/gridworks/expr/controls/ForNonBlank.java @@ -0,0 +1,40 @@ +package com.metaweb.gridworks.expr.controls; + +import java.util.Properties; + +import com.metaweb.gridworks.expr.Control; +import com.metaweb.gridworks.expr.Evaluable; +import com.metaweb.gridworks.expr.ExpressionUtils; +import com.metaweb.gridworks.expr.VariableExpr; + +public class ForNonBlank implements Control { + + @Override + public Object call(Properties bindings, Evaluable[] args) { + if (args.length >= 3) { + Object o = args[0].evaluate(bindings); + Evaluable var = args[1]; + String name = (var instanceof VariableExpr) ? ((VariableExpr) var).getName() : + ((String) var.evaluate(bindings)); + + if (!ExpressionUtils.isBlank(o)) { + Object oldValue = bindings.containsKey(name) ? bindings.get(name) : null; + bindings.put(name, o); + + try { + return args[2].evaluate(bindings); + } finally { + if (oldValue != null) { + bindings.put(name, oldValue); + } else { + bindings.remove(name); + } + } + } else if (args.length >= 4) { + return args[3].evaluate(bindings); + } + } + return null; + } + +} diff --git a/src/main/java/com/metaweb/gridworks/expr/controls/If.java b/src/main/java/com/metaweb/gridworks/expr/controls/If.java new file mode 100644 index 000000000..ede3fe84e --- /dev/null +++ b/src/main/java/com/metaweb/gridworks/expr/controls/If.java @@ -0,0 +1,25 @@ +package com.metaweb.gridworks.expr.controls; + + import java.util.Properties; + +import com.metaweb.gridworks.expr.Control; +import com.metaweb.gridworks.expr.Evaluable; +import com.metaweb.gridworks.expr.ExpressionUtils; + +public class If implements Control { + + @Override + public Object call(Properties bindings, Evaluable[] args) { + if (args.length >= 3) { + Object o = args[0].evaluate(bindings); + + if (ExpressionUtils.isTrue(o)) { + return args[1].evaluate(bindings); + } else if (args.length >= 3) { + return args[2].evaluate(bindings); + } + } + return null; + } + +} diff --git a/src/main/java/com/metaweb/gridworks/expr/functions/Get.java b/src/main/java/com/metaweb/gridworks/expr/functions/Get.java index f9e201e3f..cbac26024 100644 --- a/src/main/java/com/metaweb/gridworks/expr/functions/Get.java +++ b/src/main/java/com/metaweb/gridworks/expr/functions/Get.java @@ -3,6 +3,7 @@ package com.metaweb.gridworks.expr.functions; import java.util.Properties; import com.metaweb.gridworks.expr.Function; +import com.metaweb.gridworks.expr.HasFields; public class Get implements Function { @@ -13,52 +14,60 @@ public class Get implements Function { Object from = args[1]; Object to = args.length == 3 ? args[2] : null; - if (v != null && from != null && from instanceof Number && (to == null || to instanceof Number)) { - if (v.getClass().isArray()) { - Object[] a = (Object[]) v; - int start = ((Number) from).intValue(); - if (start < 0) { - start = a.length + start; - } - start = Math.min(a.length, Math.max(0, start)); - - if (to == null) { - return a[start]; - } else { - int end = to != null && to instanceof Number ? - ((Number) to).intValue() : a.length; - - if (end < 0) { - end = a.length - end; - } - end = Math.min(a.length, Math.max(start, end)); - - Object[] a2 = new Object[end - start]; - System.arraycopy(a, start, a2, 0, end - start); - - return a2; - } - } else { - String s = (v instanceof String ? (String) v : v.toString()); - - int start = ((Number) from).intValue(); - if (start < 0) { - start = s.length() + start; - } - start = Math.min(s.length(), Math.max(0, start)); - - if (to != null && to instanceof Number) { - int end = ((Number) to).intValue(); - if (end < 0) { - end = s.length() - end; - } - end = Math.min(s.length(), Math.max(start, end)); - - return s.substring(start, end); - } else { - return s.substring(start, start + 1); - } - } + if (v != null && from != null) { + if (v instanceof HasFields) { + if (from instanceof String) { + return ((HasFields) v).getField((String) from, bindings); + } + } else { + if (from instanceof Number && (to == null || to instanceof Number)) { + if (v.getClass().isArray()) { + Object[] a = (Object[]) v; + int start = ((Number) from).intValue(); + if (start < 0) { + start = a.length + start; + } + start = Math.min(a.length, Math.max(0, start)); + + if (to == null) { + return a[start]; + } else { + int end = to != null && to instanceof Number ? + ((Number) to).intValue() : a.length; + + if (end < 0) { + end = a.length - end; + } + end = Math.min(a.length, Math.max(start, end)); + + Object[] a2 = new Object[end - start]; + System.arraycopy(a, start, a2, 0, end - start); + + return a2; + } + } else { + String s = (v instanceof String ? (String) v : v.toString()); + + int start = ((Number) from).intValue(); + if (start < 0) { + start = s.length() + start; + } + start = Math.min(s.length(), Math.max(0, start)); + + if (to != null && to instanceof Number) { + int end = ((Number) to).intValue(); + if (end < 0) { + end = s.length() - end; + } + end = Math.min(s.length(), Math.max(start, end)); + + return s.substring(start, end); + } else { + return s.substring(start, start + 1); + } + } + } + } } } return null; diff --git a/src/main/java/com/metaweb/gridworks/expr/functions/IsBlank.java b/src/main/java/com/metaweb/gridworks/expr/functions/IsBlank.java new file mode 100644 index 000000000..04956713c --- /dev/null +++ b/src/main/java/com/metaweb/gridworks/expr/functions/IsBlank.java @@ -0,0 +1,15 @@ +package com.metaweb.gridworks.expr.functions; + +import java.util.Properties; + +import com.metaweb.gridworks.expr.ExpressionUtils; +import com.metaweb.gridworks.expr.Function; + +public class IsBlank implements Function { + + @Override + public Object call(Properties bindings, Object[] args) { + return args.length == 0 || ExpressionUtils.isBlank(args[0]); + } + +} diff --git a/src/main/java/com/metaweb/gridworks/expr/functions/IsNotBlank.java b/src/main/java/com/metaweb/gridworks/expr/functions/IsNotBlank.java new file mode 100644 index 000000000..38fb2e3de --- /dev/null +++ b/src/main/java/com/metaweb/gridworks/expr/functions/IsNotBlank.java @@ -0,0 +1,15 @@ +package com.metaweb.gridworks.expr.functions; + +import java.util.Properties; + +import com.metaweb.gridworks.expr.ExpressionUtils; +import com.metaweb.gridworks.expr.Function; + +public class IsNotBlank implements Function { + + @Override + public Object call(Properties bindings, Object[] args) { + return args.length > 0 && !ExpressionUtils.isBlank(args[0]); + } + +} diff --git a/src/main/java/com/metaweb/gridworks/model/Row.java b/src/main/java/com/metaweb/gridworks/model/Row.java index 8f33cb568..b40cd722c 100644 --- a/src/main/java/com/metaweb/gridworks/model/Row.java +++ b/src/main/java/com/metaweb/gridworks/model/Row.java @@ -99,7 +99,8 @@ public class Row implements Serializable, HasFields, Jsonizable { Project project = (Project) bindings.get("project"); Column column = project.columnModel.getColumnByName(name); if (column != null) { - return cells.get(column.getCellIndex()); + int cellIndex = column.getCellIndex(); + return getCell(cellIndex); } return null; } diff --git a/src/main/java/com/metaweb/gridworks/model/operations/MultiValueCellJoinOperation.java b/src/main/java/com/metaweb/gridworks/model/operations/MultiValueCellJoinOperation.java index 5e2950259..e833e737e 100644 --- a/src/main/java/com/metaweb/gridworks/model/operations/MultiValueCellJoinOperation.java +++ b/src/main/java/com/metaweb/gridworks/model/operations/MultiValueCellJoinOperation.java @@ -39,7 +39,7 @@ public class MultiValueCellJoinOperation implements AbstractOperation { public Process createProcess(Project project, Properties options) throws Exception { - Column column = project.columnModel.columns.get(_cellIndex); + Column column = project.columnModel.getColumnByCellIndex(_cellIndex); if (column == null) { throw new Exception("No column corresponding to cell index " + _cellIndex); } diff --git a/src/main/java/com/metaweb/gridworks/model/operations/MultiValueCellSplitOperation.java b/src/main/java/com/metaweb/gridworks/model/operations/MultiValueCellSplitOperation.java index 854fbbd65..7a37e9be6 100644 --- a/src/main/java/com/metaweb/gridworks/model/operations/MultiValueCellSplitOperation.java +++ b/src/main/java/com/metaweb/gridworks/model/operations/MultiValueCellSplitOperation.java @@ -43,7 +43,7 @@ public class MultiValueCellSplitOperation implements AbstractOperation { public Process createProcess(Project project, Properties options) throws Exception { - Column column = project.columnModel.columns.get(_cellIndex); + Column column = project.columnModel.getColumnByCellIndex(_cellIndex); if (column == null) { throw new Exception("No column corresponding to cell index " + _cellIndex); } diff --git a/tests/movies-condensed.tsv b/tests/movies-condensed.tsv index 8cfb159d1..e813a6805 100644 --- a/tests/movies-condensed.tsv +++ b/tests/movies-condensed.tsv @@ -1,25 +1,21 @@ -name Directed by Performances - Actor Performances - Character Estimated budget - Currency Estimated budget - Amount Genres Initial release date Languages -Wayne's World Penelope Spheeris Mike Myers, Dana Carvey, Rob Lowe, Tia Carrere, Lara Flynn Boyle, Chris Farley, Ed O'Neill, Robert Patrick, Alice Cooper Wayne Campbell, Garth Algar, Stacy US$ 20000000 Comedy, Satire, Buddy film 2/14/1992 English Language -Wayne's World 2 Stephen Surjik Mike Myers, Dana Carvey, Christopher Walken, Tia Carrere, Chris Farley, Ted McGinley, Olivia d'Abo, Kevin Pollak, Ed O'Neill, Kim Basinger, Heather Locklear Wayne Campbell, Garth Algar Comedy, Buddy film 12/10/1993 English Language -Austin Powers: Goldmember Jay Roach Mike Myers, BeyoncÈ, Seth Green, Michael York, Robert Wagner, Michael Caine, Verne Troyer, Gwyneth Paltrow, Fred Savage, Aaron Himelstein, Mindy Sterling, Josh Zuckerman, Greg Grunberg, Tommy 'Tiny' Lister, Rob Lowe, Masi Oka, Nikki Schieler Ziering, Britney Spears, Tom Cruise, John Travolta, Danny DeVito, Katie Couric, Steven Spielberg Austin Powers, Foxxy Cleopatra, Scott Evil, Dixie Normous, Him/Herself, Prison Guard Parody, Time travel, Comedy 7/26/2002 English Language -Austin Powers: International Man of Mystery Jay Roach Mike Myers, Elizabeth Hurley, Michael York, Mimi Rogers, Robert Wagner, Patrick Bristow, Fabiana Udenio, Elya Baskin, Paul Dillon, Lois Chiles, Christian Slater, Brian George, Cynthia Lamontagne, Cindy Margolis, Mindy Sterling, Joe Son Austin Powers, Fembot Parody, Time travel, Comedy 5/2/1997 English Language -So I Married an Axe Murderer Thomas Schlamme Mike Myers, Nancy Travis, Anthony LaPaglia, Amanda Plummer, Brenda Fricker, Michael G. Hagerty, Luenell, Debi Mazar, Matt Doherty, Steven Wright, Charles Grodin, Patrick Bristow, Phil Hartman, Cintra Wilson, Michael Richards, Sheila Kelley, Alan Arkin, M. C. Brennan, Holly Lewis Police Records Officer Comedy 7/30/1993 English Language -Austin Powers: The Spy Who Shagged Me Jay Roach, Mike Myers, Heather Graham, Robert Wagner, Rob Lowe, Michael York, Verne Troyer, David Koechner, Muse Watson, Michael G. Hagerty, Kristen Johnston, Mindy Sterling, Gia Carides, Will Ferrell, Bree Turner, Scott Cooper Austin Powers, Parody, Comedy, Time travel 6/11/1999 English Language - German Language -Shrek 2 Andrew Adamson, Kelly Asbury, Conrad Vernon John Lithgow, Mike Myers, Eddie Murphy, Cameron Diaz, Julie Andrews, Antonio Banderas, John Cleese, Rupert Everett, Jennifer Saunders, Aron Warner, Kelly Asbury, Cody Cameron, Conrad Vernon, Christopher Knights, Mark Moseley Lord Farquaad, Shrek, Donkey, Princess Fiona, Queen, Puss in Boots, King, Prince Charming, Fairy Godmother, Wolf, Page, Pinocchio, Gingerbread Man, Blind Mouse, Mirror US$ 125000000 Comedy, Computer animation, Fantasy 5/19/2004 English Language -Inglourious Basterds Quentin Tarantino, , , , Mark Christopher Brad Pitt, Mike Myers, Diane Kruger, Daniel Br¸hl, Til Schweiger, B. J. Novak, Michael Fassbender, Julie Dreyfus, Maggie Cheung, Rod Taylor, Gedeon Burkhard, Christian Berkel, Samuel L. Jackson, Samm Levine, Cloris Leachman, Christoph Waltz, Ludger Pistor, Omar Doom, Jana Pallaske, Enzo G. Castellari, Jacky Ido, Eli Roth, MÈlanie Laurent, Ryan Phillippe, Salma Hayek, Neve Campbell, Mike Myers, Sela Ward, Breckin Meyer, Sherry Stringfield, Ellen Albertini Dow, Cameron Mathison, Noam Jenkins, Jay Goede, Patrick Taylor, Heather Matarazzo, Heidi Klum, Mark Ruffalo, Lauren Hutton, Skipp Sudduth, Michael York Lt. Aldo Raine, General Ed French, Bridget von Hammersmark, Frederick Zoller, Sgt. Hugo Stiglitz, PFC Utivich, Lt. Archie Hicox, Francesca Mondino, Madame Mimieux, Winston Churchhill, Eric the Barkeeper, PFC Hirschberg, Mrs. Himmelstein, Colonel Hans Landa, PFC Omar Ulmer, Shane O'Shea, Anita Randazzo, Julie Black, Steve Rubell, Billie Auster, Greg Randazzo, Viv, Disco Dottie, Atlanta, Romeo, Buck, Tarzan, Grace O'Shea, VIP Patron US$ 70000000 War, Adventure, Action, Black comedy, LGBT, Drama 8/21/2009 English Language - German Language - French Language - Italian Language -54 US$ 18000000 8/28/1998 English Language -Shrek the Third Raman Hui, Chris Miller, Raman Hui Mike Myers, Cameron Diaz, Eddie Murphy, Antonio Banderas, Julie Andrews, John Cleese, Rupert Everett, Justin Timberlake, Regis Philbin, Seth Rogen, Eric Idle, Cheri Oteri, Edison Chen Shrek, Princess Fiona, , Artie, Ship Captain Comedy, Computer animation, Fantasy 5/18/2007 English Language -View from the Top Bruno Barreto Gwyneth Paltrow, Christina Applegate, Mark Ruffalo, Candice Bergen, Joshua Malina, Kelly Preston, Mike Myers, Rob Lowe, Marc Blucas Donna Jensen Romantic comedy, Comedy 3/21/2003 English Language -Pete's Meteor Brenda Fricker, Mike Myers Drama 1998 -The Cat in the Hat Bo Welch Mike Myers, Alec Baldwin, Kelly Preston, Dakota Fanning, Spencer Breslin, Amy Hill, Sean Hayes The Cat in the Hat, Larry Quinn, Joan Walden, Sally Walden, Conrad Walden, The Fish US$ 109000000 Musical, Fantasy 11/21/2003 English Language -Shrek Andrew Adamson, Vicky Jenson Mike Myers, Eddie Murphy, Cameron Diaz, John Lithgow, Chris Farley, Conrad Vernon, Vincent Cassel, Val Bettin, Christopher Knights Shrek, Donkey, Princess Fiona, Lord Farquaad US$ 60000000 Parody, Computer animation, Comedy, Fantasy 5/18/2001 English Language -The Thin Pink Line Joe Dietl, Michael Irpino Laura Kightlinger, Janeane Garofalo, Margaret Cho, Jennifer Aniston, David Schwimmer, Mike Myers, Will Ferrell Joyce Wintergarden-Dingle, Clove Satire, Indie, Comedy 1998 English Language -Shrek the Halls Gary Trousdale Eddie Murphy, Antonio Banderas, Cameron Diaz, Mike Myers, Aron Warner, Conrad Vernon, Christopher Knights, Marissa Jaret Winokur Princess Fiona Animation, Fantasy, Short film, Adventure, Comedy 11/28/2007 English Language -Shrek Ever After Mike Mitchell, Mike Mitchell Cameron Diaz, Eric Idle, Antonio Banderas, Eddie Murphy, Justin Timberlake, Julie Andrews, Mike Myers, Paul McCartney, Larry King Princess Fiona, Merlin, Puss in Boots, Donkey, Arthur Pendragon, Queen Lillian, Shrek, Rumpelstiltskin, Doris the Ugly Stepsister Comedy, Computer animation, Fantasy 5/21/2010 English Language -The Love Guru Mike Myers, Jessica Alba, Justin Timberlake, Romany Malco, Jessica Simpson, Ben Kingsley, Verne Troyer Maurice Pitka, Jane Bullard, Jacques Grande, Darren Roanoke US$ 62000000 Comedy 6/20/2008 English Language -Shrek Goes Fourth Cameron Diaz, Antonio Banderas, Eddie Murphy, Mike Myers Princess Fiona, Puss in Boots, Donkey, Shrek Computer animation -View from the top Bruno Barreto Gwyneth Paltrow, Mike Myers, Rob Lowe, Christina Applegate, Kelly Preston, Candice Bergen, Mark Ruffalo, Joshua Malina Romantic comedy 3/21/2003 English Language +name Directed by Performances Estimated budget - Currency Estimated budget - Amount Genres Initial release date Languages +Wayne's World Penelope Spheeris Mike Myers (Wayne Campbell), Dana Carvey (Garth Algar), Rob Lowe, Tia Carrere, Lara Flynn Boyle (Stacy), Chris Farley, Ed O'Neill, Robert Patrick, Alice Cooper US$ 20000000 Comedy, Satire, Buddy film 2/14/1992 English Language +Wayne's World 2 Stephen Surjik Mike Myers (Wayne Campbell), Dana Carvey (Garth Algar), Christopher Walken, Tia Carrere, Chris Farley, Ted McGinley, Olivia d'Abo, Kevin Pollak, Ed O'Neill, Kim Basinger, Heather Locklear Comedy, Buddy film 12/10/1993 English Language +Austin Powers: Goldmember Jay Roach Mike Myers (Austin Powers), BeyoncÈ (Foxxy Cleopatra), Seth Green (Scott Evil), Michael York, Robert Wagner, Michael Caine, Verne Troyer, Gwyneth Paltrow (Dixie Normous), Fred Savage, Aaron Himelstein, Mindy Sterling, Josh Zuckerman, Greg Grunberg, Tommy 'Tiny' Lister, Rob Lowe, Masi Oka, Nikki Schieler Ziering, Britney Spears, Tom Cruise (Him/Herself), John Travolta, Danny DeVito, Katie Couric (Prison Guard), Steven Spielberg Parody, Time travel, Comedy 7/26/2002 English Language +Austin Powers: International Man of Mystery Jay Roach Mike Myers (Austin Powers), Elizabeth Hurley, Michael York, Mimi Rogers, Robert Wagner, Patrick Bristow, Fabiana Udenio, Elya Baskin, Paul Dillon, Lois Chiles, Christian Slater, Brian George, Cynthia Lamontagne, Cindy Margolis (Fembot), Mindy Sterling, Joe Son Parody, Time travel, Comedy 5/2/1997 English Language +So I Married an Axe Murderer Thomas Schlamme Mike Myers, Nancy Travis, Anthony LaPaglia, Amanda Plummer, Brenda Fricker, Michael G. Hagerty, Luenell (Police Records Officer), Debi Mazar, Matt Doherty, Steven Wright, Charles Grodin, Patrick Bristow, Phil Hartman, Cintra Wilson, Michael Richards, Sheila Kelley, Alan Arkin, M. C. Brennan, Holly Lewis Comedy 7/30/1993 English Language +Austin Powers: The Spy Who Shagged Me Jay Roach Mike Myers (Austin Powers), Heather Graham, Robert Wagner, Rob Lowe, Michael York, Verne Troyer, David Koechner, Muse Watson, Michael G. Hagerty, Kristen Johnston, Mindy Sterling, Gia Carides, Will Ferrell, Bree Turner, Scott Cooper Parody, Comedy, Time travel 6/11/1999 English Language, German Language +Shrek 2 Andrew Adamson, Kelly Asbury, Conrad Vernon John Lithgow (Lord Farquaad), Mike Myers (Shrek), Eddie Murphy (Donkey), Cameron Diaz (Princess Fiona), Julie Andrews (Queen), Antonio Banderas (Puss in Boots), John Cleese (King), Rupert Everett (Prince Charming), Jennifer Saunders (Fairy Godmother), Aron Warner (Wolf), Kelly Asbury (Page), Cody Cameron (Pinocchio), Conrad Vernon (Gingerbread Man), Christopher Knights (Blind Mouse), Mark Moseley (Mirror) US$ 125000000 Comedy, Computer animation, Fantasy 5/19/2004 English Language +Inglourious Basterds Quentin Tarantino, Mark Christopher Brad Pitt (Lt. Aldo Raine), Mike Myers (General Ed French), Diane Kruger (Bridget von Hammersmark), Daniel Br¸hl (Frederick Zoller), Til Schweiger (Sgt. Hugo Stiglitz), B. J. Novak (PFC Utivich), Michael Fassbender (Lt. Archie Hicox), Julie Dreyfus (Francesca Mondino), Maggie Cheung (Madame Mimieux), Rod Taylor (Winston Churchhill), Gedeon Burkhard, Christian Berkel (Eric the Barkeeper), Samuel L. Jackson, Samm Levine (PFC Hirschberg), Cloris Leachman (Mrs. Himmelstein), Christoph Waltz (Colonel Hans Landa), Ludger Pistor, Omar Doom (PFC Omar Ulmer), Jana Pallaske, Enzo G. Castellari, Jacky Ido, Eli Roth, MÈlanie Laurent, Ryan Phillippe (Shane O'Shea), Salma Hayek (Anita Randazzo), Neve Campbell (Julie Black), Mike Myers (Steve Rubell), Sela Ward (Billie Auster), Breckin Meyer (Greg Randazzo), Sherry Stringfield (Viv), Ellen Albertini Dow (Disco Dottie), Cameron Mathison (Atlanta), Noam Jenkins (Romeo), Jay Goede (Buck), Patrick Taylor (Tarzan), Heather Matarazzo (Grace O'Shea), Heidi Klum (VIP Patron), Mark Ruffalo, Lauren Hutton, Skipp Sudduth, Michael York US$ 70000000 War, Adventure, Action, Black comedy, LGBT, Drama 8/21/2009 English Language, German Language, French Language, Italian Language, English Language +54 US$ 18000000 8/28/1998 +Shrek the Third Raman Hui, Chris Miller, Raman Hui Mike Myers (Shrek), Cameron Diaz (Princess Fiona), Eddie Murphy, Antonio Banderas, Julie Andrews, John Cleese, Rupert Everett, Justin Timberlake (Artie), Regis Philbin, Seth Rogen (Ship Captain), Eric Idle, Cheri Oteri, Edison Chen Comedy, Computer animation, Fantasy 5/18/2007 English Language +View from the Top Bruno Barreto Gwyneth Paltrow (Donna Jensen), Christina Applegate, Mark Ruffalo, Candice Bergen, Joshua Malina, Kelly Preston, Mike Myers, Rob Lowe, Marc Blucas Romantic comedy, Comedy 3/21/2003 English Language +Pete's Meteor Brenda Fricker, Mike Myers Drama 1998 +The Cat in the Hat Bo Welch Mike Myers (The Cat in the Hat), Alec Baldwin (Larry Quinn), Kelly Preston (Joan Walden), Dakota Fanning (Sally Walden), Spencer Breslin (Conrad Walden), Amy Hill, Sean Hayes (The Fish) US$ 109000000 Musical, Fantasy 11/21/2003 English Language +Shrek Andrew Adamson, Vicky Jenson Mike Myers (Shrek), Eddie Murphy (Donkey), Cameron Diaz (Princess Fiona), John Lithgow (Lord Farquaad), Chris Farley, Conrad Vernon, Vincent Cassel, Val Bettin, Christopher Knights US$ 60000000 Parody, Computer animation, Comedy, Fantasy 5/18/2001 English Language +The Thin Pink Line Joe Dietl, Michael Irpino Laura Kightlinger, Janeane Garofalo (Joyce Wintergarden-Dingle), Margaret Cho, Jennifer Aniston (Clove), David Schwimmer, Mike Myers, Will Ferrell Satire, Indie, Comedy 1998 English Language +Shrek the Halls Gary Trousdale Eddie Murphy, Antonio Banderas, Cameron Diaz (Princess Fiona), Mike Myers, Aron Warner, Conrad Vernon, Christopher Knights, Marissa Jaret Winokur Animation, Fantasy, Short film, Adventure, Comedy 11/28/2007 English Language +Shrek Ever After Mike Mitchell, Mike Mitchell Cameron Diaz (Princess Fiona), Eric Idle (Merlin), Antonio Banderas (Puss in Boots), Eddie Murphy (Donkey), Justin Timberlake (Arthur Pendragon), Julie Andrews (Queen Lillian), Mike Myers (Shrek), Paul McCartney (Rumpelstiltskin), Larry King (Doris the Ugly Stepsister) Comedy, Computer animation, Fantasy 5/21/2010 English Language +The Love Guru Mike Myers (Maurice Pitka), Jessica Alba (Jane Bullard), Justin Timberlake (Jacques Grande), Romany Malco (Darren Roanoke), Jessica Simpson, Ben Kingsley, Verne Troyer US$ 62000000 Comedy 6/20/2008 English Language +Shrek Goes Fourth Cameron Diaz (Princess Fiona), Antonio Banderas (Puss in Boots), Eddie Murphy (Donkey), Mike Myers (Shrek) Computer animation +View from the top Bruno Barreto Gwyneth Paltrow, Mike Myers, Rob Lowe, Christina Applegate, Kelly Preston, Candice Bergen, Mark Ruffalo, Joshua Malina Romantic comedy 3/21/2003 English Language