Difference between revisions of "User:Mono/GSoC 2017"
Line 158: | Line 158: | ||
1. A notification that appears when the requests made to the APy take more than a threshold time. <br/> |
1. A notification that appears when the requests made to the APy take more than a threshold time. <br/> |
||
2. This notification also appears when a cumulative average of the requests duration exceeds a certain threshold indicating that the servers may be overloaded and thus, one could set the APy locally too. |
2. This notification also appears when a cumulative average of the requests duration exceeds a certain threshold indicating that the servers may be overloaded in that particular time phase and thus, one could set the APy locally too. |
||
=== Code === |
=== Code === |
||
Line 169: | Line 169: | ||
1. Initially, the AJAX requests made use of GET method to retrieve data from the backend. <br/> |
1. Initially, the AJAX requests made use of GET method to retrieve data from the backend. <br/> |
||
2. The GET method was used along with ''jsonp'' to allow cross domain requests. However, this gave a ''414-request URI too large'' error when the input size was large and thus, resulted in failed requests. <br/> |
2. The GET method was used along with ''jsonp'' to allow cross domain requests. However, this gave a ''414-request URI too large'' error when the input size was large and thus, resulted in failed requests. <br/> |
||
3. This issue was resolved by making use of a POST method if the request size was beyond a threshold size and GET method otherwise. |
3. This issue was resolved by making use of a POST method if the request size was beyond a threshold size, and a GET method otherwise. |
||
=== Code === |
=== Code === |
||
Line 178: | Line 178: | ||
1. The language dropdown used to go offscreen when the browser window size was adjusted. This would obstruct the user from choosing the language of his choice. <br/> |
1. The language dropdown used to go offscreen when the browser window size was adjusted. This would obstruct the user from choosing the language of his choice. <br/> |
||
2. This issue was fixed by dynamically determining the available space on the browser window (triggered on resize) and |
2. This issue was fixed by dynamically determining the available space on the browser window (triggered on resize) and adjusting the number of columns to fit the languages inside the viewport. |
||
=== Code === |
=== Code === |
||
Line 188: | Line 188: | ||
1. Inspite of setting the left-to-right or right-to-left orientation for the language display names, the browser did not render it in the expected manner. <br/> |
1. Inspite of setting the left-to-right or right-to-left orientation for the language display names, the browser did not render it in the expected manner. <br/> |
||
2. A patch was created which applied the necessary styling to the display names along with the styling of other associated UI elements to achieve the right |
2. A patch was created which applied the necessary styling to the display names along with the styling of other associated UI elements to achieve the right rendering. |
||
=== Code === |
=== Code === |
||
* https://github.com/goavki/apertium-html-tools/pull/159 |
* https://github.com/goavki/apertium-html-tools/pull/159 |
||
== Interface breaks when cookies disabled == |
|||
1. The Apertium interface used to break when the cookies were disabled. <br/> |
|||
2. This was because the interface used to interact with the localStorage of the browser and when the cookies were disabled, this interaction was prohibited by the browser. This was unhandled in the code. <br/> |
|||
3. The issue was resolved by handling the exception that occurs when the cookies were disabled. |
|||
=== Code === |
|||
* https://github.com/goavki/apertium-html-tools/commit/07d96a23162d4b4e8e772d8fc0f2d5b5f411973b |
|||
== Improve detectLanguage() functionality == |
|||
1. This method did not call the autoDstSelectLang() method to detect a destination language automatically after the langauge for a given text identified. <br/> |
|||
=== Code === |
|||
* https://github.com/goavki/apertium-html-tools/commit/ec1e1ace75db0d55ca5c443309eda81dc8301e35 |
|||
== Prevent the requests when input is empty == |
|||
1. The handlers on the backend gave a server error when the requests were made with empty inputs or if any of the necessary arguments were missing. <br/> |
|||
2. This validation was added for a lot of functionalities such as that of Analyzer, Generator, Detect Language, APy Sandbox. |
|||
=== Code === |
|||
* https://github.com/goavki/apertium-html-tools/commit/f274430c648a9d2fabb5b76f88a226420f14449f |
|||
* https://github.com/goavki/apertium-html-tools/commit/928f43a205355549580174bc37bcbdb3b5cd29e8 |
|||
* https://github.com/goavki/apertium-html-tools/commit/e8fa8dc755a065a1f568ee52a38cd01f1fd0188d |
|||
* https://github.com/goavki/apertium-html-tools/commit/2518e5042da41bc1007f586569c8bd31d79eb63a |
Revision as of 16:26, 27 August 2017
Contents
- 1 Webpage Translation mode
- 2 SpellChecker mode
- 3 Dictionary Lookup mode
- 4 Installation Notification
- 5 POST v/s GET
- 6 Language Dropdown going offscreen Issue
- 7 LTR/RTL alignment of languages in dropdown
- 8 Interface breaks when cookies disabled
- 9 Improve detectLanguage() functionality
- 10 Prevent the requests when input is empty
Webpage Translation mode
An interface that lets the user to input a URL, choose a source and a destination language and translate the webpage.
Code
Backend
Frontend
- https://github.com/goavki/apertium-html-tools/pull/154
- https://github.com/goavki/apertium-html-tools/pull/202
- https://github.com/goavki/apertium-html-tools/pull/205
Documentation
Backend
URL | Function | Parameters | Output |
---|---|---|---|
/translatePage | Translates a webpage |
|
Returns the translated webpage
curl -Ss 'http://localhost:2737/translatePage?langpair=eng|spa&url=http://facebook.com' |
Frontend
ENABLED_MODES: an array of the enabled interfaces, a non-empty subset of ['translation', 'analyzation', 'generation', 'sandbox']
translation lookup
turns on webpage translation mode.
Future Work
1. The backend for this mode is merged in this commit. The screenshot of the current state of interface can be found here.
2. The interface is pretty much functional. However, a future task is to make use of a form handler while submitting the URL links for translation. The related issues are in this comment.
SpellChecker mode
Checks for the spelling of input text for a given language and suggests alternatives if the spelling is wrong.
Code
Backend
Frontend
Documentation
Backend
URL | Function | Parameters | Output |
---|---|---|---|
/speller | Performs spellchecking on a given text for a given language |
|
Returns the spellchecking results
curl -Ss 'http://localhost:2737/speller?lang=hin&q=माय' | ascii2uni -a U -q [{"sugg": [["काय", "1.000000"], ["चाय", "1.000000"], ["राय", "1.000000"], ["हाय", "1.000000"], ["साय", "1.000000"], ["मा", "1.000000"], ["वाय", "1.000000"], ["दाय", "1.000000"], ["गाय", "1.000000"], ["जाय", "1.000000"]], "known": false, "token": "माय"}] |
Frontend
ENABLED_MODES: an array of the enabled interfaces, a non-empty subset of ['translation', 'analyzation', 'generation', 'sandbox', 'speller']
speller
turns on spell checking mode.
Future Work
1. The screenshot of the current state of interface can be found here.
2. Improving the logic of mapping the suggestions returned from the backend for the tokens appropriately to the corresponding text on the frontend.
Dictionary Lookup mode
An interface that generates all forms of a given word. It renders the definitions of a given word for a given language pair after translating them.
Code
Backend
Frontend
Documentation
Backend
URL | Function | Parameters | Output |
---|---|---|---|
/dictionaryLookup | Generate dictionary forms of a given word |
|
Returns the possible forms of after translation
curl -Ss 'http://localhost:2737/dictionaryLookup?langpair=eng|spa&q=light' {"vblex": ["encender", "iluminar"], "n": ["luz"], "adj": ["ligero", "claro"]} |
Frontend
ENABLED_MODES: an array of the enabled interfaces, a non-empty subset of ['translation', 'analyzation', 'generation', 'sandbox']
translation lookup
turns on dictionary lookup mode.
Future Work
1. The screenshot of the current state of interface can be found here.
2. The pending tasks with respect to dictionary lookup mode are discussed in this comment.
Installation Notification
1. A notification that appears when the requests made to the APy take more than a threshold time.
2. This notification also appears when a cumulative average of the requests duration exceeds a certain threshold indicating that the servers may be overloaded in that particular time phase and thus, one could set the APy locally too.
Code
POST v/s GET
1. Initially, the AJAX requests made use of GET method to retrieve data from the backend.
2. The GET method was used along with jsonp to allow cross domain requests. However, this gave a 414-request URI too large error when the input size was large and thus, resulted in failed requests.
3. This issue was resolved by making use of a POST method if the request size was beyond a threshold size, and a GET method otherwise.
Code
Language Dropdown going offscreen Issue
1. The language dropdown used to go offscreen when the browser window size was adjusted. This would obstruct the user from choosing the language of his choice.
2. This issue was fixed by dynamically determining the available space on the browser window (triggered on resize) and adjusting the number of columns to fit the languages inside the viewport.
Code
LTR/RTL alignment of languages in dropdown
1. Inspite of setting the left-to-right or right-to-left orientation for the language display names, the browser did not render it in the expected manner.
2. A patch was created which applied the necessary styling to the display names along with the styling of other associated UI elements to achieve the right rendering.
Code
Interface breaks when cookies disabled
1. The Apertium interface used to break when the cookies were disabled.
2. This was because the interface used to interact with the localStorage of the browser and when the cookies were disabled, this interaction was prohibited by the browser. This was unhandled in the code.
3. The issue was resolved by handling the exception that occurs when the cookies were disabled.
Code
Improve detectLanguage() functionality
1. This method did not call the autoDstSelectLang() method to detect a destination language automatically after the langauge for a given text identified.
Code
Prevent the requests when input is empty
1. The handlers on the backend gave a server error when the requests were made with empty inputs or if any of the necessary arguments were missing.
2. This validation was added for a lot of functionalities such as that of Analyzer, Generator, Detect Language, APy Sandbox.
Code
- https://github.com/goavki/apertium-html-tools/commit/f274430c648a9d2fabb5b76f88a226420f14449f
- https://github.com/goavki/apertium-html-tools/commit/928f43a205355549580174bc37bcbdb3b5cd29e8
- https://github.com/goavki/apertium-html-tools/commit/e8fa8dc755a065a1f568ee52a38cd01f1fd0188d
- https://github.com/goavki/apertium-html-tools/commit/2518e5042da41bc1007f586569c8bd31d79eb63a