Comments (8)
Hello, jzohrab! Dictionaries with sametypesequence=h
is not yet supported. To force read the dict data as is try to set sametypesequence
to m
: sametypesequence=m
which is mean pure text but in this case you have to convert output yourself.
from stardict.
Added in #12, update to 0.2
version and try this demo:
require_once __DIR__ . '/vendor/autoload.php';
$files = \StarDict\DictFiles::create('dict-data.ifo', 'dict-data.idx', 'dict-data.dict.dz', new \StarDict\Files\Factory);
$dict = \StarDict\StarDict::create($files, false);
$result = $dict->get('gato');
var_dump($result[0]->asText());
from stardict.
Súper thank you! I’ll give it a shot soon.
from stardict.
AWESOME! Thank you very much!
composer require skoro/stardict:0.2.0
and using your demo above, dumping the whole variable:
$ php main.php
array(1) {
[0]=>
object(StarDict\DictData\Sequences\HtmlCodes)#17 (1) {
["value":"StarDict\DictData\Sequences\TypeSequence":private]=>
string(2233) "[ˈɡa.to]
<p>Del latín vulgar <i>cattus</i>, del imperial <i>catta</i>, de origen incierto. La hipótesis más probable lo deriva de alguna lengua afroasiática. Compárese el catalán <i>gat</i>, ...</ol></html>"
}
}
fyi, I'm considering using this as an offline dictionary for my project Lute, which is for reading and learning foreign languages. May I use this project in my own project? Lute is free, uses Unlicense (ref https://github.com/jzohrab/lute/blob/master/UNLICENSE.md). Cheers! jz
Note: before I use this in Lute, I'll need to figure out how to handle things like verb declensions. Eg. with the example code, the word "tener" returns data, but "tengo" (the "I" form) throws:
$ php main.php tener
array(1) {
[0]=>
object(StarDict\DictData\Sequences\HtmlCodes)#17 (1) {
["value":"StarDict\DictData\Sequences\TypeSequence":private]=>
string(420) "<p>Del castellano antiguo <i>tener</i> ("tener"), y este del latín <i>tenēre</i> ("sujetar").</p><ol><li>Poseer, ser dueño de algo.</li><li>Sostener.</li><li><i>Úsase para expresar una sensación</i>.</li><li><i>Úsase para medir la cantidad de tiempo de existencia de algo o alguien</i>.</li><li>(tener que) <i>Junto con la conjunción <b>que</b> indica la necesidad u obligación de hacer algo</i></li></ol></html>"
}
}
MacBook-Pro:__stardict_test jeff$ php main.php tengo
PHP Warning: Undefined array key "tengo" in /Users/jeff/Downloads/__stardict_test/vendor/skoro/stardict/src/StarDict.php on line 85
Warning: Undefined array key "tengo" in /Users/jeff/Downloads/__stardict_test/vendor/skoro/stardict/src/StarDict.php on line 85
PHP Fatal error: Uncaught TypeError: StarDict\DictData\DataReader::fillSequences(): Argument #1 ($offset) must be of type StarDict\Index\DataOffsetItem, null given, called in /Users/jeff/Downloads/__stardict_test/vendor/skoro/stardict/src/StarDict.php on line 86 and defined in /Users/jeff/Downloads/__stardict_test/vendor/skoro/stardict/src/DictData/DataReader.php:17
Stack trace:
#0 /Users/jeff/Downloads/__stardict_test/vendor/skoro/stardict/src/StarDict.php(86): StarDict\DictData\DataReader->fillSequences(NULL, Array)
#1 /Users/jeff/Downloads/__stardict_test/main.php(10): StarDict\StarDict->get('tengo')
#2 {main}
thrown in /Users/jeff/Downloads/__stardict_test/vendor/skoro/stardict/src/DictData/DataReader.php on line 17
Fatal error: Uncaught TypeError: StarDict\DictData\DataReader::fillSequences(): Argument #1 ($offset) must be of type StarDict\Index\DataOffsetItem, null given, called in /Users/jeff/Downloads/__stardict_test/vendor/skoro/stardict/src/StarDict.php on line 86 and defined in /Users/jeff/Downloads/__stardict_test/vendor/skoro/stardict/src/DictData/DataReader.php:17
Stack trace:
#0 /Users/jeff/Downloads/__stardict_test/vendor/skoro/stardict/src/StarDict.php(86): StarDict\DictData\DataReader->fillSequences(NULL, Array)
#1 /Users/jeff/Downloads/__stardict_test/main.php(10): StarDict\StarDict->get('tengo')
#2 {main}
thrown in /Users/jeff/Downloads/__stardict_test/vendor/skoro/stardict/src/DictData/DataReader.php on line 17
from stardict.
Thanks for reporting the issue! Fixed in 0.2.1
from stardict.
Cheers and thank you very much. I think I'll need to look further into StarDicts that have information for declensions (e.g., "tener" => "tengo" for Spanish, "avoir" => "ai" for French, etc). In the meantime, with v0.2.1, my test program just returns empty:
MacBook-Pro:__stardict_test jeff$ php main.php tengo
array(0) {
}
but that's ok. Do you feel that this issue is closed, or is there something else I should check?
from stardict.
I close the issue, if you find something wrong with the package, please post another issue and I will take a look. Regarding to declensions, StarDict provides just only index with the words as is, this package doesn't do any transformations of the input and searches what you provide. So, I think there should be a special algorithm which firstly transforms the input to any possible declensions and then passes them to StarDict for further searching.
from stardict.
A belated thank you, @skoro. Cheers and best wishes! jz
from stardict.
Related Issues (11)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stardict.