Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create langLibrary form different directories #24

Open
IgorFrancais opened this issue Aug 20, 2019 · 3 comments
Open

Create langLibrary form different directories #24

IgorFrancais opened this issue Aug 20, 2019 · 3 comments

Comments

@IgorFrancais
Copy link

IgorFrancais commented Aug 20, 2019

Hello,

Now, when we create a library, we can use following ways:

  1. new Language() - following directory will be used (by default): DIR . '/../../resources//.json';

  2. We use other .json-files (take as an example, en language):
    2.1 Create at any place folder $dirname=LanguageDetection/en/.
    2.2 Put there your own text file: en.txt.
    2.3 Train library:

          $t = new Trainer();
          $t->learn($dirname);
    

    2.4 Then use newly created/updated .json-file: LanguageDetection/en/en.json by:

new Language([], $dirname)

So, if we want to use default lang file, we should:

  1. Copy already existing en.txt to our newly created folder.
  2. Add our text to existing
  3. Train library.
  4. Use newly created/updated en.json

Request:

Not to copy-paste, it would be good have a possibility to use already existing en.json and newly created together, something like:
new Language([], $dirname, $useDefaultFile = true):

  • 3rd params by default is false
  • if dirname is defined and $useDefaultFile=true: use 2 path together - default one (
    __DIR__ . '/../../resources/*/*.json'_)
    and new - dirname
@patrickschur
Copy link
Owner

Hello,

if I understand you correctly, you just want a simple merge function, right? That shouldn't be hard to implement. :)

@IgorFrancais
Copy link
Author

IgorFrancais commented Aug 22, 2019

Yes:)
Something like

  1. Use default directory only
    or
  2. To use 2 directories with *.json-files together:
    default
    __DIR__ . '/../../resources/*/*.json'

and other, custom user's directory :)

@patrickschur
Copy link
Owner

Sorry for waiting so long... It's not as easy as I thought. I've stumpled across some issues here.
When merging both directories (default and user directory), we also have to merge the language files. But we can't just merge the language files, because they are pre-sorted and merging would destroy the order.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants