Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
dev:translator_framework [2011/04/04 16:50] – more info on functions ajlyon | dev:translator_framework [2017/11/12 19:53] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Translator Framework ===== | + | < |
- | The translator framework is a way to build web translators that lets translator authors avoid most of the boilerplate that usually is required | + | in the process |
+ | <a href=" | ||
+ | may be outdated in the meantime. Thanks for your understanding.</ | ||
- | The framework was written and contributed by Erik Hetzner and is licensed under the GPLv3+. It currently resides at http:// | ||
- | To use the framework, simply insert the framework code at the beginning of your translator, after the translator information block (JSON header). If you are using [[dev/scaffold|Scaffold]] to develop your translator, you won't see the information block, and you can just insert the framework at the top of the code box. The latest version of the code is [[http:// | + | See [[dev/translators/Framework]]. |
- | + | ||
- | You'll start writing beneath the line that reads: | + | |
- | ''/ | + | |
- | + | ||
- | ===Example Translator=== | + | |
- | From APN.ru.js (GPLv3+ licensed): | + | |
- | <code javascript> | + | |
- | function detectWeb(doc, | + | |
- | function doWeb(doc, url) { return FW.doWeb(doc, | + | |
- | + | ||
- | /** Articles */ | + | |
- | FW.Scraper({ | + | |
- | itemType | + | |
- | detect | + | |
- | title : FW.Xpath('// | + | |
- | attachments | + | |
- | creators | + | |
- | date : FW.Xpath('// | + | |
- | publicationTitle : " | + | |
- | }); | + | |
- | + | ||
- | /** Search results */ | + | |
- | FW.MultiScraper({ | + | |
- | itemType | + | |
- | detect | + | |
- | titles | + | |
- | urls : FW.Xpath('// | + | |
- | }); | + | |
- | </ | + | |
- | + | ||
- | This is the functional portion of a real, working web translator using the translator framework. It defines two scrapers, in this case one for newspaper articles and one for multiple result pages. | + | |
- | + | ||
- | ==== Functions ==== | + | |
- | FIXME Functions that can be used with the framework. | + | |
- | === Main functions === | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | === String functions === | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | === Zotero functions === | + | |
- | * '' | + | |
- | * '' | + |