diff --git a/dollar/Engine.cpp b/dollar/Engine.cpp index ea562e0..4b1f60f 100644 --- a/dollar/Engine.cpp +++ b/dollar/Engine.cpp @@ -8,10 +8,10 @@ #include #include #include -#include #include #include #include +#include dollar::Engine::Engine(): @@ -28,12 +28,14 @@ size_t dollar::Engine::getNumberResult() { } -bool dollar::Engine::loadPath(const etk::String& _path) { - DOLLAR_INFO("Load Path: " << _path); - etk::FSNode path(_path); - etk::Vector files = path.folderGetSub(false, true, "*.json"); +bool dollar::Engine::loadPath(const etk::Uri& _uri) { + DOLLAR_INFO("Load Path: " << _uri); + etk::Vector files = etk::uri::list(_uri); for (auto &it : files) { - if (etk::end_with(it, ".json") == true) { + if (etk::uri::isFile(it) == false) { + continue; + } + if (it.getPath().getExtention().toLower() == "json") { loadGesture(it); } } diff --git a/dollar/Engine.hpp b/dollar/Engine.hpp index 8cac7d1..456fcd8 100644 --- a/dollar/Engine.hpp +++ b/dollar/Engine.hpp @@ -32,8 +32,8 @@ namespace dollar { protected: virtual dollar::Results recognize2(const etk::Vector>& _paths) = 0; public: - virtual bool loadPath(const etk::String& _path); - virtual bool loadGesture(const etk::String& _filename) = 0; + virtual bool loadPath(const etk::Uri& _uri); + virtual bool loadGesture(const etk::Uri& _uri) = 0; virtual void addGesture(ememory::SharedPtr _gesture) = 0; }; diff --git a/dollar/EngineN.cpp b/dollar/EngineN.cpp index 369f9ab..59a052c 100644 --- a/dollar/EngineN.cpp +++ b/dollar/EngineN.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include @@ -138,10 +137,10 @@ void dollar::EngineN::setRotationInvariance(bool _ignoreRotation) { } } -bool dollar::EngineN::loadGesture(const etk::String& _filename) { +bool dollar::EngineN::loadGesture(const etk::Uri& _uri) { ememory::SharedPtr ref = ememory::makeShared(); - DOLLAR_DEBUG("Load Gesture: " << _filename); - if (ref->load(_filename) == true) { + DOLLAR_DEBUG("Load Gesture: " << _uri); + if (ref->load(_uri) == true) { addGesture(ref); return true; } diff --git a/dollar/EngineN.hpp b/dollar/EngineN.hpp index 154ff02..f76293f 100644 --- a/dollar/EngineN.hpp +++ b/dollar/EngineN.hpp @@ -34,7 +34,7 @@ namespace dollar { public: EngineN(bool _protractor); dollar::Results recognize2(const etk::Vector>& _points) override; - bool loadGesture(const etk::String& _filename) override; + bool loadGesture(const etk::Uri& _uri) override; void addGesture(ememory::SharedPtr _gesture) override; protected: float distanceAtBestAngle(const etk::Vector& _points, const etk::Vector& _reference); diff --git a/dollar/EngineP.cpp b/dollar/EngineP.cpp index def4f61..c5f2dc9 100644 --- a/dollar/EngineP.cpp +++ b/dollar/EngineP.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #define MAX_FLOAT std::numeric_limits::max() @@ -101,10 +100,10 @@ static float calculateBestDistance(const etk::Vector& _points, const etk:: } -bool dollar::EngineP::loadGesture(const etk::String& _filename) { +bool dollar::EngineP::loadGesture(const etk::Uri& _uri) { ememory::SharedPtr ref = ememory::makeShared(); - DOLLAR_DEBUG("Load Gesture: " << _filename); - if (ref->load(_filename) == true) { + DOLLAR_DEBUG("Load Gesture: " << _uri); + if (ref->load(_uri) == true) { addGesture(ref); return true; } diff --git a/dollar/EngineP.hpp b/dollar/EngineP.hpp index 60ed439..aec3805 100644 --- a/dollar/EngineP.hpp +++ b/dollar/EngineP.hpp @@ -31,7 +31,7 @@ namespace dollar { public: EngineP(); dollar::Results recognize2(const etk::Vector>& _paths) override; - bool loadGesture(const etk::String& _filename) override; + bool loadGesture(const etk::Uri& _uri) override; void addGesture(ememory::SharedPtr _gesture) override; }; } diff --git a/dollar/EnginePPlus.cpp b/dollar/EnginePPlus.cpp index 25fbd4f..7d33a0f 100644 --- a/dollar/EnginePPlus.cpp +++ b/dollar/EnginePPlus.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include @@ -233,10 +232,10 @@ float dollar::EnginePPlus::calculatePPlusDistance(const etk::Vector& _poin -bool dollar::EnginePPlus::loadGesture(const etk::String& _filename) { +bool dollar::EnginePPlus::loadGesture(const etk::Uri& _uri) { ememory::SharedPtr ref = ememory::makeShared(); - DOLLAR_DEBUG("Load Gesture: " << _filename); - if (ref->load(_filename) == true) { + DOLLAR_DEBUG("Load Gesture: " << _uri); + if (ref->load(_uri) == true) { addGesture(ref); return true; } @@ -251,7 +250,7 @@ void dollar::EnginePPlus::addGesture(ememory::SharedPtr _gestur } } -static void storeSVG(const etk::String& _fileName, +static void storeSVG(const etk::Uri& _fileName, const ememory::SharedPtr& _gesture, const etk::Vector>& _strokes, const etk::Vector& _points, @@ -305,7 +304,14 @@ static void storeSVG(const etk::String& _fileName, data += " />\n"; } data += "\n"; - etk::FSNodeWriteAllData(_fileName, data); + { + ememory::SharedPtr fileIO = etk::uri::get(_fileName); + if (fileIO->open(etk::io::OpenMode::Write) == false) { + return; + } + fileIO->writeAll(data); + fileIO->close(); + } } diff --git a/dollar/EnginePPlus.hpp b/dollar/EnginePPlus.hpp index 09413f4..2130cca 100644 --- a/dollar/EnginePPlus.hpp +++ b/dollar/EnginePPlus.hpp @@ -52,7 +52,7 @@ namespace dollar { public: EnginePPlus(); dollar::Results recognize2(const etk::Vector>& _paths) override; - bool loadGesture(const etk::String& _filename) override; + bool loadGesture(const etk::Uri& _uri) override; void addGesture(ememory::SharedPtr _gesture) override; protected: float calculatePPlusDistance(const etk::Vector& _points, diff --git a/dollar/Gesture.cpp b/dollar/Gesture.cpp index 5022e02..975d5c1 100644 --- a/dollar/Gesture.cpp +++ b/dollar/Gesture.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include @@ -35,7 +35,7 @@ static etk::Vector> loadPointsJson(const ejson::Document& _doc return out; } -etk::Vector> dollar::loadPoints(const etk::String& _fileName, etk::String* _label, etk::String* _type) { +etk::Vector> dollar::loadPoints(const etk::Uri& _fileName, etk::String* _label, etk::String* _type) { ejson::Document doc; doc.load(_fileName); if (_label != null) { @@ -70,11 +70,11 @@ dollar::Gesture::Gesture(): } -bool dollar::Gesture::load(const etk::String& _fileName) { - etk::String tmpName = etk::toLower(_fileName); - if (etk::end_with(tmpName, ".json") == true) { +bool dollar::Gesture::load(const etk::Uri& _fileName) { + etk::String extention = etk::toLower(_fileName.getPath().getExtention()); + if (extention == "json") { return loadJSON(_fileName); - } else if (etk::end_with(tmpName, ".svg") == true) { + } else if (extention == "svg") { return loadSVG(_fileName); } DOLLAR_ERROR("Un-sopported LOAD extention : " << _fileName); @@ -82,7 +82,7 @@ bool dollar::Gesture::load(const etk::String& _fileName) { return false; } -bool dollar::Gesture::loadJSON(const etk::String& _fileName) { +bool dollar::Gesture::loadJSON(const etk::Uri& _fileName) { ejson::Document doc; doc.load(_fileName); if (doc["type"].toString().get() != "REFERENCE") { @@ -96,12 +96,10 @@ bool dollar::Gesture::loadJSON(const etk::String& _fileName) { return true; } -bool dollar::Gesture::loadSVG(const etk::String& _fileName) { +bool dollar::Gesture::loadSVG(const etk::Uri& _fileName) { esvg::Document doc; doc.load(_fileName); - etk::Vector plop = etk::split(_fileName, '.'); - plop = etk::split(plop[plop.size() -2], '/'); - plop = etk::split(plop[plop.size() -1], '_'); + etk::Vector plop = etk::split(_fileName.getPath().getFileName(), '_'); m_name = plop[0]; m_subId = etk::string_to_int32_t(plop[1]); m_path = doc.getLines(); @@ -116,12 +114,12 @@ bool dollar::Gesture::loadSVG(const etk::String& _fileName) { } -bool dollar::Gesture::store(const etk::String& _fileName) { - etk::String tmpName = etk::toLower(_fileName); - if (etk::end_with(tmpName, ".json") == true) { +bool dollar::Gesture::store(const etk::Uri& _fileName) { + etk::String extention = etk::toLower(_fileName.getPath().getExtention()); + if (extention == "json") { storeJSON(_fileName); return true; - } else if (etk::end_with(tmpName, ".svg") == true) { + } else if (extention == "svg") { storeSVG(_fileName); return true; } @@ -130,7 +128,7 @@ bool dollar::Gesture::store(const etk::String& _fileName) { return false; } -void dollar::Gesture::storeJSON(const etk::String& _fileName) { +void dollar::Gesture::storeJSON(const etk::Uri& _fileName) { ejson::Document doc; doc.add("type", ejson::String("REFERENCE")); doc.add("value", ejson::String(m_name)); @@ -151,7 +149,7 @@ void dollar::Gesture::storeJSON(const etk::String& _fileName) { doc.store(_fileName); } -void dollar::Gesture::storeSVG(const etk::String& _fileName, bool _storeDot) { +void dollar::Gesture::storeSVG(const etk::Uri& _fileName, bool _storeDot) { etk::Vector> strokes = dollar::scaleToOne(m_path, true); etk::String data("\n"); data += "\n"; @@ -177,7 +175,14 @@ void dollar::Gesture::storeSVG(const etk::String& _fileName, bool _storeDot) { */ } data += "\n"; - etk::FSNodeWriteAllData(_fileName, data); + { + ememory::SharedPtr fileIO = etk::uri::get(_fileName); + if (fileIO->open(etk::io::OpenMode::Write) == false) { + return; + } + fileIO->writeAll(data); + fileIO->close(); + } } void dollar::Gesture::set(const etk::String& _name, uint32_t _subId, etk::Vector> _path) { diff --git a/dollar/Gesture.hpp b/dollar/Gesture.hpp index 0599adc..7fd9893 100644 --- a/dollar/Gesture.hpp +++ b/dollar/Gesture.hpp @@ -8,6 +8,7 @@ #include #include +#include #include namespace dollar { @@ -26,14 +27,14 @@ namespace dollar { float getKeepAspectRatio() { return m_aspectRatio; } - bool load(const etk::String& _filename); - bool store(const etk::String& _filename); + bool load(const etk::Uri& _filename); + bool store(const etk::Uri& _filename); void set(const etk::String& _name, uint32_t _subId, etk::Vector> _path); protected: - bool loadJSON(const etk::String& _filename); - bool loadSVG(const etk::String& _filename); - void storeJSON(const etk::String& _filename); - void storeSVG(const etk::String& _filename, bool _storeDot=false); + bool loadJSON(const etk::Uri& _filename); + bool loadSVG(const etk::Uri& _filename); + void storeJSON(const etk::Uri& _filename); + void storeSVG(const etk::Uri& _filename, bool _storeDot=false); public: const etk::String& getName() { return m_name; @@ -46,5 +47,5 @@ namespace dollar { * @brief Load all point from a specific file * */ - etk::Vector> loadPoints(const etk::String& _fileName, etk::String* _label=null, etk::String* _type=null); + etk::Vector> loadPoints(const etk::Uri& _fileName, etk::String* _label=null, etk::String* _type=null); } diff --git a/dollar/GestureN.cpp b/dollar/GestureN.cpp index f66826e..8cad9d3 100644 --- a/dollar/GestureN.cpp +++ b/dollar/GestureN.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/dollar/GestureP.cpp b/dollar/GestureP.cpp index 31eb007..009995a 100644 --- a/dollar/GestureP.cpp +++ b/dollar/GestureP.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/dollar/GesturePPlus.cpp b/dollar/GesturePPlus.cpp index 0651430..d8ad60a 100644 --- a/dollar/GesturePPlus.cpp +++ b/dollar/GesturePPlus.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/test/main.cpp b/test/main.cpp index 54efa25..b89e224 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -20,7 +20,7 @@ int main(int _argc, const char *_argv[]) { TEST(TestAll, plop) { /* dollar::Gesture gest; - gest.set("test", 55, dollar::loadPoints("DATA:test/P.json")); + gest.set("test", 55, dollar::loadPoints("DATA:///test/P.json")); gest.configure(0.1, 64, false, 0.1f); */ } @@ -30,8 +30,8 @@ TEST(TestAll, plop) { */ TEST(TestAll, singleStroke_normal) { ememory::SharedPtr reco = dollar::createEngine("$N"); - reco->loadPath("DATA:figure"); - dollar::Results res = reco->recognize(dollar::loadPoints("DATA:test/arrow.json")); + reco->loadPath("DATA:///figure"); + dollar::Results res = reco->recognize(dollar::loadPoints("DATA:///test/arrow.json")); EXPECT_EQ(res.haveMatch(), true); if (res.haveMatch() == false) { TEST_INFO(" Recognise noting ..."); @@ -46,8 +46,8 @@ TEST(TestAll, singleStroke_normal) { TEST(TestAll, singleStroke_protractor) { ememory::SharedPtr reco = dollar::createEngine("$N"); - reco->loadPath("DATA:figure"); - dollar::Results res = reco->recognize(dollar::loadPoints("DATA:test/arrow.json")); + reco->loadPath("DATA:///figure"); + dollar::Results res = reco->recognize(dollar::loadPoints("DATA:///test/arrow.json")); EXPECT_EQ(res.haveMatch(), true); if (res.haveMatch() == false) { TEST_INFO(" Recognise noting ..."); @@ -66,8 +66,8 @@ TEST(TestAll, singleStroke_protractor) { */ TEST(TestAll, multiStroke_normal) { ememory::SharedPtr reco = dollar::createEngine("$N"); - reco->loadPath("DATA:text"); - dollar::Results res = reco->recognize(dollar::loadPoints("DATA:test/P.json")); + reco->loadPath("DATA:///text"); + dollar::Results res = reco->recognize(dollar::loadPoints("DATA:///test/P.json")); EXPECT_EQ(res.haveMatch(), true); if (res.haveMatch() == false) { TEST_INFO(" Recognise noting ..."); @@ -82,8 +82,8 @@ TEST(TestAll, multiStroke_normal) { TEST(TestAll, multiStroke_protractor) { ememory::SharedPtr reco = dollar::createEngine("$N-protractor"); - reco->loadPath("DATA:text"); - dollar::Results res = reco->recognize(dollar::loadPoints("DATA:test/P.json")); + reco->loadPath("DATA:///text"); + dollar::Results res = reco->recognize(dollar::loadPoints("DATA:///test/P.json")); EXPECT_EQ(res.haveMatch(), true); if (res.haveMatch() == false) { TEST_INFO(" Recognise noting ..."); @@ -100,8 +100,8 @@ TEST(TestAll, multiStroke_protractor) { */ TEST(TestAll, multiStroke_point) { ememory::SharedPtr reco = dollar::createEngine("$P"); - reco->loadPath("DATA:text"); - dollar::Results res = reco->recognize(dollar::loadPoints("DATA:test/P.json")); + reco->loadPath("DATA:///text"); + dollar::Results res = reco->recognize(dollar::loadPoints("DATA:///test/P.json")); EXPECT_EQ(res.haveMatch(), true); if (res.haveMatch() == false) { TEST_INFO(" Recognise noting ..."); @@ -118,8 +118,8 @@ TEST(TestAll, multiStroke_point) { */ TEST(TestAll, multiStroke_pointPlus) { ememory::SharedPtr reco = dollar::createEngine("$P+"); - reco->loadPath("DATA:text"); - dollar::Results res = reco->recognize(dollar::loadPoints("DATA:test/P.json")); + reco->loadPath("DATA:///text"); + dollar::Results res = reco->recognize(dollar::loadPoints("DATA:///test/P.json")); EXPECT_EQ(res.haveMatch(), true); if (res.haveMatch() == false) { TEST_INFO(" Recognise noting ..."); diff --git a/tool/bench-corpus/main.cpp b/tool/bench-corpus/main.cpp index 1e1f406..257c90e 100644 --- a/tool/bench-corpus/main.cpp +++ b/tool/bench-corpus/main.cpp @@ -10,7 +10,6 @@ #include #include -#include #include static bool keepAspectRatio = false; @@ -36,14 +35,14 @@ void usage(const etk::String& _progName) { TEST_PRINT(" corpus_path Path of the corpus files"); } -bool testCorpus(const etk::String& _srcGesture, const etk::String& _srcCorpus); +bool testCorpus(const etk::Uri& _srcGesture, const etk::Uri& _srcCorpus); int main(int _argc, const char *_argv[]) { // init etk log system and file interface: etk::init(_argc, _argv); - etk::String srcGesture; - etk::String srcCorpus; + etk::Path srcGesture; + etk::Path srcCorpus; for (int32_t iii=1; iii<_argc; ++iii) { etk::String arg = _argv[iii]; if ( arg == "-h" @@ -110,7 +109,7 @@ int main(int _argc, const char *_argv[]) { return testCorpus(srcGesture, srcCorpus); } -void generateFile(const etk::String& _fileName, const etk::Vector& _list) { +void generateFile(const etk::Uri& _fileName, const etk::Vector& _list) { etk::String data("\n"); data += "\n"; for (auto &itFile : _list) { @@ -131,10 +130,17 @@ void generateFile(const etk::String& _fileName, const etk::Vector& } } data += "\n"; - etk::FSNodeWriteAllData(_fileName, data); + { + ememory::SharedPtr fileIO = etk::uri::get(_fileName); + if (fileIO->open(etk::io::OpenMode::Write) == false) { + return; + } + fileIO->writeAll(data); + fileIO->close(); + } } -void annalyseResult(etk::Map>>& _result) { +void annalyseResult(etk::Map>>& _result) { TEST_PRINT("Full results:"); for (auto &it : _result) { int32_t nbRecognise = 0; @@ -144,8 +150,8 @@ void annalyseResult(etk::Map 1) { type = etk::split(it.first, ' ')[1]; } - etk::Vector listFull; - etk::Vector listWrong; + etk::Vector listFull; + etk::Vector listWrong; etk::Map wrongValues; for (auto itRes : it.second) { nbtested ++; @@ -174,16 +180,16 @@ void annalyseResult(etk::Map files = path.folderGetSub(false, true, "*.json"); + etk::Vector filesTmp = etk::uri::list(_srcCorpus); + etk::Vector files; + for (auto &it: filesTmp) { + if (etk::uri::isFile(it) == false) { + continue; + } + if (it.getPath().getExtention().toLower() == "json") { + files.pushBack(it); + } + } TEST_PRINT("---------------------------------------------------------------------------"); TEST_PRINT("-- test gestures: "); TEST_PRINT("---------------------------------------------------------------------------"); // "label_type" ==> list of (result, file test name) - etk::Map>> agregateResults; + etk::Map>> agregateResults; int32_t nbRecognise = 0; int32_t nbRecognise2 = 0; int32_t nbtested = 0; @@ -220,8 +234,7 @@ bool testCorpus(const etk::String& _srcGesture, const etk::String& _srcCorpus) { //continue; // rejest for now ... } nbtested++; - etk::Vector path = etk::split(it, '/'); - etk::String filename = path[path.size()-1]; + etk::String filename = it.getPath().getFileName(); TEST_PRINT("Test '" << label << "' type=" << type << " " << filename); dollar::Results res = reco.recognize(listPoints); diff --git a/tool/generate-form/main.cpp b/tool/generate-form/main.cpp index b6752f8..937a96a 100644 --- a/tool/generate-form/main.cpp +++ b/tool/generate-form/main.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include @@ -44,13 +43,13 @@ void usage(const etk::String& _progName) { TEST_PRINT(" example:"); } -bool testCorpus(const etk::String& _srcCorpus); +bool testCorpus(const etk::Uri& _srcCorpus); int main(int _argc, const char *_argv[]) { // init etk log system and file interface: etk::init(_argc, _argv); - etk::String srcCorpus; + etk::Path srcCorpus; for (int32_t iii=1; iii<_argc; ++iii) { etk::String arg = _argv[iii]; @@ -119,7 +118,7 @@ int main(int _argc, const char *_argv[]) { return testCorpus(srcCorpus); } -void generateFile(const etk::String& _fileName, const etk::Vector& _list, const etk::String& _refName) { +void generateFile(const etk::Uri& _fileName, const etk::Vector& _list, const etk::Uri& _refName) { TEST_PRINT(" " << _fileName); etk::String data("\n"); data += "\n"; @@ -164,24 +163,38 @@ void generateFile(const etk::String& _fileName, const etk::Vector& } } data += "\n"; - etk::FSNodeWriteAllData(_fileName, data); + { + ememory::SharedPtr fileIO = etk::uri::get(_fileName); + if (fileIO->open(etk::io::OpenMode::Write) == false) { + return; + } + fileIO->writeAll(data); + fileIO->close(); + } } #define OUT_OF_RANGE (999999.0f) -bool testCorpus(const etk::String& _srcCorpus) { +bool testCorpus(const etk::Uri& _srcCorpus) { TEST_PRINT("---------------------------------------------------------------------------"); TEST_PRINT("-- Create list of files: " << _srcCorpus); TEST_PRINT("---------------------------------------------------------------------------"); - etk::FSNode path(_srcCorpus); - etk::Vector files = path.folderGetSub(false, true, "*.json"); + etk::Vector filesTmp = etk::uri::list(_srcCorpus); + etk::Vector files; + for (auto &it: filesTmp) { + if (etk::uri::isFile(it) == false) { + continue; + } + if (it.getPath().getExtention().toLower() == "json") { + files.pushBack(it); + } + } TEST_PRINT("corpus have " << files.size() << " files"); etk::Vector listOfElementInCorpus; for (auto &it : files) { - if (etk::end_with(it, ".json") == true) { - etk::Vector path = etk::split(it, '/'); - etk::String elemName = etk::split(path[path.size()-1],'_')[0]; + if (it.getPath().getExtention().toLower() == "json") { + etk::String elemName = etk::split(it.getPath().getFileName(),'_')[0]; if (elemName == "slash") { elemName = "/"; }if (elemName == "back-slash") { @@ -196,7 +209,7 @@ bool testCorpus(const etk::String& _srcCorpus) { } } // remove generation path ... - etk::FSNodeRemove("out_dollar/generate-form"); + etk::uri::remove(etk::Path("out_dollar/generate-form")); //listOfElementInCorpus.clear(); //listOfElementInCorpus.pushBack("slash"); @@ -207,7 +220,7 @@ bool testCorpus(const etk::String& _srcCorpus) { TEST_PRINT("---------------------------------------------------------------------------"); TEST_PRINT("-- Generate FOR: '" << itTypeOfCorpus << "'"); TEST_PRINT("---------------------------------------------------------------------------"); - etk::Vector fileFiltered; + etk::Vector fileFiltered; etk::String fileNameIt = itTypeOfCorpus; if (fileNameIt == "/") { fileNameIt = "slash"; @@ -215,9 +228,8 @@ bool testCorpus(const etk::String& _srcCorpus) { fileNameIt = "back-slash"; } for (auto &it : files) { - if (etk::end_with(it, ".json") == true) { - etk::Vector path = etk::split(it, '/'); - etk::String filename = path[path.size()-1]; + if (it.getPath().getExtention().toLower() == "json") { + etk::String filename = it.getPath().getFileName(); if (etk::start_with(filename, fileNameIt + "_") == true) { fileFiltered.pushBack(it); } @@ -239,11 +251,11 @@ bool testCorpus(const etk::String& _srcCorpus) { itTypeOfCorpusFileName = "question"; } { - etk::Vector listPath; + etk::Vector listPath; for (size_t iii=0; iii gest = ememory::makeShared(); @@ -257,8 +269,7 @@ bool testCorpus(const etk::String& _srcCorpus) { reco.setPenalityNotLinkSample(penalitySample); reco.setPenalityAspectRatio(penalityAspectRatio); reco.addGesture(gest); - etk::Vector path = etk::split(fileFiltered[iii], '/'); - etk::String filename = path[path.size()-1]; + etk::String filename = fileFiltered[iii].getPath().getFileName(); TEST_DEBUG("Test : " << fileFiltered[iii]); for (size_t jjj=0; jjj= jjj) { @@ -269,8 +280,7 @@ bool testCorpus(const etk::String& _srcCorpus) { dollar::Results res = reco.recognize(listPoints); results[iii][jjj] = res.getConfidence(); results[jjj][iii] = res.getConfidence(); - path = etk::split(fileFiltered[jjj], '/'); - etk::String filename2 = path[path.size()-1]; + etk::String filename2 = fileFiltered[jjj].getPath().getFileName(); TEST_DEBUG(" " << res.getConfidence() << " " << filename2); } } @@ -362,8 +372,7 @@ bool testCorpus(const etk::String& _srcCorpus) { TEST_INFO(" nbElement : " << linkIds.size() << " / " << residualValues << " / " << fileFiltered.size()); TEST_INFO(" values : " << linkIds); for (size_t jjj=0; jjj path = etk::split(fileFiltered[ordered[jjj].second], '/'); - etk::String filename = path[path.size()-1]; + etk::String filename = fileFiltered[ordered[jjj].second].getPath().getFileName();; etk::String tmppp = " "; if (jjj listPath; + etk::Vector listPath; for (size_t iii=0; iii #include #include -#include appl::widget::TextAreaRecognition::TextAreaRecognition() { addObjectType("appl::widget::TextAreaRecognition"); @@ -20,9 +19,9 @@ void appl::widget::TextAreaRecognition::init() { ewol::Widget::init(); m_updateDone = false; - //m_dollarEngine.loadPath("DATA:text"); + //m_dollarEngine.loadPath("DATA:///text"); m_dollarEngine = dollar::createEngine("$P+"); - m_dollarEngine->loadPath("DATA:reference"); + m_dollarEngine->loadPath("DATA:///reference"); // TODO: m_dollarEngine->setScaleKeepRatio(true); markToRedraw(); // connect a periodic update ... @@ -81,14 +80,13 @@ void appl::widget::TextAreaRecognition::store(const etk::String& _userName, cons list.add(obj); } etk::String streamOut = doc.generateMachineString(); - etk::String fileName; - fileName = "HOME:DOLLAR/corpus/"; + etk::Path fileName = "~/DOLLAR/corpus"; if (_value == "/") { - fileName += "slash"; + fileName /= "slash"; } else if (_value == "\\") { - fileName += "back-slash"; + fileName /= "back-slash"; } else { - fileName += _value; + fileName /= _value; } fileName += "_"; fileName += _type; @@ -97,7 +95,14 @@ void appl::widget::TextAreaRecognition::store(const etk::String& _userName, cons fileName += "_"; fileName += etk::toString(m_time.get()); fileName += ".json"; - etk::FSNodeWriteAllData(fileName, streamOut); + { + ememory::SharedPtr fileIO = etk::uri::get(fileName); + if (fileIO->open(etk::io::OpenMode::Write) == false) { + return; + } + fileIO->writeAll(streamOut); + fileIO->close(); + } APPL_WARNING("store: " << fileName); } @@ -137,7 +142,7 @@ etk::Vector> scalePoints(etk::Vector> _list, return _list; } -etk::Vector> renderWithSVG(const etk::Vector>& _list, int32_t _objectSize, const etk::String& _filename) { +etk::Vector> renderWithSVG(const etk::Vector>& _list, int32_t _objectSize, const etk::Uri& _filename) { // generate SVG to render: esvg::Document docSvg; etk::String data("\n"); @@ -163,7 +168,13 @@ etk::Vector> renderWithSVG(const etk::VectorgetName()+ ".svg"); - etk::FSNodeWriteAllData(_filename, data); + { + ememory::SharedPtr fileIO = etk::uri::get(_filename); + if (fileIO->open(etk::io::OpenMode::Write) == true) { + fileIO->writeAll(data); + fileIO->close(); + } + } // generate SVG output ... ivec2 renderSize = ivec2(_objectSize,_objectSize);