Skip to content

Commit

Permalink
StructuredFilename: Use a tokenizing approach to improve accuracy. (#250
Browse files Browse the repository at this point in the history
)

* StructuredFilename: Use a tokenizing approach to improve accuracy and information

* Tokenizer: Increase test coverage
  • Loading branch information
chyyran authored Jun 27, 2017
1 parent cd39263 commit ec92643
Show file tree
Hide file tree
Showing 11 changed files with 969 additions and 247 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public interface IStructuredFilename
/// GoodTools uses it's own 1 or 2 letter format
/// No-Intro uses full-country names that seem to follow their own conventions.
/// </remarks>
StructuredFilenameConvention NamingConvention { get; }
NamingConvention NamingConvention { get; }
/// <summary>
/// The title of the game according to the filename.
/// May or may not differ from the final queryable filename.
Expand Down Expand Up @@ -60,7 +60,7 @@ public interface IStructuredFilename
/// <summary>
/// Types of filename conventions
/// </summary>
public enum StructuredFilenameConvention
public enum NamingConvention
{
/// <summary>
/// No-Intro Naming Convention
Expand Down
56 changes: 41 additions & 15 deletions src/Snowflake.Framework.Tests/Romfile/StructuredFilenameTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Snowflake.Romfile.Tokenizer;
using System;
using System.Collections.Generic;
using System.Text;
using Xunit;
Expand All @@ -8,21 +9,46 @@ namespace Snowflake.Romfile.Tests
public class StructuredFilenameTests
{
[Theory]
[InlineData("Bart Simpson's Escape from Camp Deadly (USA, Europe).gb", "Bart Simpson's Escape from Camp Deadly", StructuredFilenameConvention.NoIntro, "US-EU")]
[InlineData("[BIOS] X'Eye (USA) (v2.00).md", "X'Eye", StructuredFilenameConvention.NoIntro, "US")]
[InlineData("Adventures of Batman & Robin, The (USA)", "The Adventures of Batman & Robin", StructuredFilenameConvention.NoIntro, "US")]
[InlineData("Pokemon - Versione Blu (Italy) (SGB Enhanced).gb", "Pokemon - Versione Blu", StructuredFilenameConvention.NoIntro, "IT")]
[InlineData("Pop'n TwinBee (Europe).gb", "Pop'n TwinBee", StructuredFilenameConvention.NoIntro, "EU")]
[InlineData("Prince of Persia (Europe) (En,Fr,De,Es,It).gb", "Prince of Persia", StructuredFilenameConvention.NoIntro, "EU")]
[InlineData("RPG Maker Fes (Europe) (En,Fr,De,Es,It)", "RPG Maker Fes", NamingConvention.NoIntro, "EU")]
[InlineData("Seisen Chronicle (Japan) (eShop) [b]", "Seisen Chronicle", NamingConvention.NoIntro, "JP")]
[InlineData("Pachio-kun 3 (Japan) (Rev A)", "Pachio-kun 3", NamingConvention.NoIntro, "JP")]
[InlineData("Barbie - Jet, Set & Style! (Europe) (De,Es,It) (VMZX) (NDSi Enhanced)", "Barbie - Jet, Set & Style!", NamingConvention.NoIntro, "EU")]
[InlineData("Barbie - Jet, Set & Style! (Europe) (De,Es,It) (Beta) (Proto) (Sample) (Unl) (VMZX) (NDSi Enhanced)", "Barbie - Jet, Set & Style!", NamingConvention.NoIntro, "EU")]
[InlineData("Bart Simpson's Escape from Camp Deadly (USA, Europe).gb", "Bart Simpson's Escape from Camp Deadly", NamingConvention.NoIntro, "US-EU")]
[InlineData("[BIOS] X'Eye (USA) (v2.00).md", "X'Eye", NamingConvention.NoIntro, "US")]
[InlineData("[BIOS] X'Eye (USA) (v2.00) (En,Es,Fr).md", "X'Eye", NamingConvention.NoIntro, "US")]
[InlineData("Adventures of Batman & Robin, The (USA)", "The Adventures of Batman & Robin", NamingConvention.NoIntro, "US")]
[InlineData("Pokemon - Versione Blu (Italy) (SGB Enhanced).gb", "Pokemon - Versione Blu", NamingConvention.NoIntro, "IT")]
[InlineData("Pop'n TwinBee (Europe).gb", "Pop'n TwinBee", NamingConvention.NoIntro, "EU")]
[InlineData("Prince of Persia (Europe) (En,Fr,De,Es,It).gb", "Prince of Persia", NamingConvention.NoIntro, "EU")]
[InlineData("Purikura Pocket 2 - Kareshi Kaizou Daisakusen (Japan) (SGB Enhanced).gb", "Purikura Pocket 2 - Kareshi Kaizou Daisakusen",
StructuredFilenameConvention.NoIntro, "JP")]
//[InlineData("Thrill Kill (1998-07-09)(Virgin)(proto).ccd", "Thrill Kill", StructuredFilenameConvention.TheOldSchoolEmulationCenter, "ZZ")]
[InlineData("Biohazard 2 v2 (1997)(Capcom)(JP)(beta)", "Biohazard 2 v2", StructuredFilenameConvention.TheOldSchoolEmulationCenter, "JP")]
//[InlineData("Femten-Spill v1.2 (1986)(Datalauget)(NO)", "Femten-Spill v1.2", StructuredFilenameConvention.TheOldSchoolEmulationCenter, "NO")]
[InlineData("Alien 3 (1992)(BITS - LJN)(JP)(en)", "Alien 3", StructuredFilenameConvention.TheOldSchoolEmulationCenter, "JP")]
[InlineData("Aoki Densetsu Shoot! (J)", "Aoki Densetsu Shoot!", StructuredFilenameConvention.GoodTools, "JP")]
[InlineData("Bionic Commando (1992)(Capcom)(US)", "Bionic Commando", StructuredFilenameConvention.TheOldSchoolEmulationCenter, "US")]
public void StructuredFilename_Tests(string filename, string title, StructuredFilenameConvention convention, string regioncode)
NamingConvention.NoIntro, "JP")]
[InlineData("Thrill Kill (1998-07-09)(Virgin)(proto).ccd", "Thrill Kill", NamingConvention.TheOldSchoolEmulationCenter, "ZZ")]
[InlineData("Biohazard 2 v2 (1997)(Capcom)(JP)(beta)", "Biohazard 2", NamingConvention.TheOldSchoolEmulationCenter, "JP")]
[InlineData("Femten-Spill v1.2 (1986)(Datalauget)(NO)", "Femten-Spill", NamingConvention.TheOldSchoolEmulationCenter, "NO")]
[InlineData("Alien 3 (1992)(BITS - LJN)(JP)(en)", "Alien 3", NamingConvention.TheOldSchoolEmulationCenter, "JP")]
[InlineData("Aoki Densetsu Shoot! (J)", "Aoki Densetsu Shoot!", NamingConvention.GoodTools, "JP")]
[InlineData("Bionic Commando (1992)(Capcom)(US)", "Bionic Commando", NamingConvention.TheOldSchoolEmulationCenter, "US")]
[InlineData("Legend of TOSEC, The (demo) (1986)(Devstudio)", "The Legend of TOSEC", NamingConvention.TheOldSchoolEmulationCenter, "ZZ")]
[InlineData("Legend of TOSEC, The (demo) (19xx-08-09)(Devstudio)", "The Legend of TOSEC", NamingConvention.TheOldSchoolEmulationCenter, "ZZ")]
[InlineData("Legend of TOSEC, The (demo) (20xx-08-09)(Devstudio)", "The Legend of TOSEC", NamingConvention.TheOldSchoolEmulationCenter, "ZZ")]
[InlineData("Legend of TOSEC, The (demo) (20xx-08-09)(Devstudio)", "The Legend of TOSEC", NamingConvention.TheOldSchoolEmulationCenter, "ZZ")]
[InlineData("Legend of TOSEC, The (demo) (20xx-08-09)(Devstudio)(US-BR)", "The Legend of TOSEC", NamingConvention.TheOldSchoolEmulationCenter, "US-BR")]
[InlineData("Legend of TOSEC, The (demo) (20xx-08-09)(Devstudio)(US-BR)(jp-yi)(NTSC)(Disc 1 of 1)[cr][!]", "The Legend of TOSEC", NamingConvention.TheOldSchoolEmulationCenter, "US-BR")]
[InlineData("Legend of TOSEC, The (demo) (20xx-08-09)(Devstudio)(US-BR)(jp-yi)(NTSC)(Side A)[cr][!]", "The Legend of TOSEC", NamingConvention.TheOldSchoolEmulationCenter, "US-BR")]
[InlineData("Guilty Gear Xrd Rev 2 (demo) (20xx-08-09)(Devstudio)(US-BR)(jp-yi)(NTSC)(Side A)[cr][!]", "Guilty Gear Xrd Rev 2", NamingConvention.TheOldSchoolEmulationCenter, "US-BR")]
[InlineData("Liable Gear Xrd Rev 2 (demo) (20xx-08-09)(Devstudio)(US-BR)(jp-yi)(NTSC)(Side A)[cr][!]", "Liable Gear Xrd", NamingConvention.TheOldSchoolEmulationCenter, "US-BR")]
[InlineData("Legend of Zelda, The - A Link to the Past (Canada) .zip", "The Legend of Zelda - A Link to the Past", NamingConvention.NoIntro, "CA")]
[InlineData("Legend of Zelda, The - A Link to the Past (U) [!].zip", "The Legend of Zelda - A Link to the Past", NamingConvention.GoodTools, "US")]
[InlineData("Legend of Zelda, The - A Link to the Past (U) [a?][!].zip", "The Legend of Zelda - A Link to the Past", NamingConvention.GoodTools, "US")]
[InlineData("Legend of Zelda, The (U) (PRG 0).nes", "The Legend of Zelda", NamingConvention.GoodTools, "US")]
[InlineData("Legend of Zelda, The (U) (NTSC) (8k) (M4) (PRG 0).nes", "The Legend of Zelda", NamingConvention.GoodTools, "US")]
[InlineData("Legend of Zelda, The (U) (PAL) (32k) (PRG 0).nes", "The Legend of Zelda", NamingConvention.GoodTools, "US")]
[InlineData("Legend of Zelda, The (1) (PRG 0).nes", "The Legend of Zelda", NamingConvention.GoodTools, "JP-KR")]
[InlineData("Legend of Zelda, The (4) (PRG 0).nes", "The Legend of Zelda", NamingConvention.GoodTools, "US-BR")]
[InlineData("Legend of GoodTools, The (Unl) (PRG 0).nes", "The Legend of GoodTools", NamingConvention.GoodTools, "ZZ")]
[InlineData("Legend of Zelda, The (B) (PRG 0).nes", "The Legend of Zelda", NamingConvention.GoodTools, "BR")]
public void StructuredFilename_Tests(string filename, string title, NamingConvention convention, string regioncode)
{
var structuredFilename = new StructuredFilename(filename);
Assert.Equal(filename, structuredFilename.OriginalFilename);
Expand Down
33 changes: 0 additions & 33 deletions src/Snowflake.Framework.Utility/DirectoryInfoExtensions.cs

This file was deleted.

135 changes: 0 additions & 135 deletions src/Snowflake.Framework/Romfile/StructuredFilename.LookupTables.cs

This file was deleted.

Loading

0 comments on commit ec92643

Please sign in to comment.