@@ -35,7 +35,7 @@ namespace IBM.Watson.DeveloperCloud.Editor
3535 class NLCEditor : EditorWindow
3636 {
3737 #region Constants
38- private const string CLASSIFIERS_DIRECTORY = "/Watson/Editor/ Classifiers" ;
38+ private const string CLASSIFIERS_DIRECTORY = "/Classifiers" ;
3939 #endregion
4040
4141 #region Private Types
@@ -148,6 +148,7 @@ private static void EditConfig()
148148 GetWindow < NLCEditor > ( ) . Show ( ) ;
149149 }
150150
151+ private string m_ClassifiersFolder = null ;
151152 private Texture m_WatsonIcon = null ;
152153 private Vector2 m_ScrollPos = Vector2 . zero ;
153154 private NaturalLanguageClassifier m_NLC = new NaturalLanguageClassifier ( ) ;
@@ -194,15 +195,38 @@ private void OnClassiferTrained(Classifier classifier)
194195 OnRefresh ( ) ;
195196 }
196197
198+ private static string FindDirectory ( string check , string name )
199+ {
200+ foreach ( var d in Directory . GetDirectories ( check ) )
201+ {
202+ string dir = d . Replace ( "\\ " , "/" ) ; // normalize the slashes
203+ if ( dir . EndsWith ( name ) )
204+ return d ;
205+
206+ string found = FindDirectory ( d , name ) ;
207+ if ( found != null )
208+ return found ;
209+ }
210+
211+ return null ;
212+ }
213+
197214 private void OnRefresh ( )
198215 {
199216 if ( ! m_Refreshing )
200217 {
201- if ( ! Directory . Exists ( Application . dataPath + CLASSIFIERS_DIRECTORY ) )
202- Directory . CreateDirectory ( Application . dataPath + CLASSIFIERS_DIRECTORY ) ;
218+ if ( m_ClassifiersFolder != null && ! Directory . Exists ( m_ClassifiersFolder ) )
219+ m_ClassifiersFolder = null ;
220+ if ( m_ClassifiersFolder == null )
221+ m_ClassifiersFolder = FindDirectory ( Application . dataPath , CLASSIFIERS_DIRECTORY ) ;
222+ if ( m_ClassifiersFolder == null )
223+ {
224+ m_ClassifiersFolder = Application . dataPath + "/Watson/Editor" + CLASSIFIERS_DIRECTORY ;
225+ Directory . CreateDirectory ( m_ClassifiersFolder ) ;
226+ }
203227
204228 m_ClassifierData = new List < ClassifierData > ( ) ;
205- foreach ( var file in Directory . GetFiles ( Application . dataPath + CLASSIFIERS_DIRECTORY , "*.json" ) )
229+ foreach ( var file in Directory . GetFiles ( m_ClassifiersFolder , "*.json" ) )
206230 {
207231 ClassifierData data = new ClassifierData ( ) ;
208232 if ( data . Load ( file ) )
@@ -458,7 +482,7 @@ private void OnGUI()
458482 {
459483 m_NewClassifierName = m_NewClassifierName . Replace ( "/" , "_" ) ;
460484
461- string classifierFile = Application . dataPath + CLASSIFIERS_DIRECTORY + "/" + m_NewClassifierName + ".json" ;
485+ string classifierFile = m_ClassifiersFolder + "/" + m_NewClassifierName + ".json" ;
462486 if ( ! File . Exists ( classifierFile )
463487 || EditorUtility . DisplayDialog ( "Confirm" , string . Format ( "Classifier file {0} already exists, are you sure you wish to overwrite?" , classifierFile ) , "YES" , "NO" ) )
464488 {
0 commit comments