Microsoft Interview Question
Program ManagersPre-requisites
1. Create as a service which runs on background, and checks the key-typed ins
2. A program to look at full words, segregated by punctuation marks or commas
3. A API call to the existing dictionary - installed in the computer system by default to take out mapping
4. An API to mark the wrong words if there is a match and user input is incorrect
5. An API to provide suggest multiple words on search-as-you-type based on X number of letters
6. An API to add/delete to the existing dictionary.
7. An API to ignore the spell check where the service would still run, but would not validate the text.
8. An API to connect to various devices, i.e. Desktop, Web, Mobile etc
9. An API to connect to any other user defined resource along side standard default dictionary
10. A feature to correct the spelling if the user intends to change.
11. Auto correct feature as you type with most familiar/popular word which is nearest match.
SpellChecker can be designed using Ternary SearchTree. It works in 0(h) complexity. where h is height of tree. Ternary Search Tree works like trie data structure but with property of BST. In each node of Ternary Search Tree , there are 3 pointers unlike trie where there are 26 pointers for all character . This way it reduces space. One pointer is for words less than left pointer, middle pointer for values which are equal and Third pointer for values greater than right pointer value.
Also leaf node 0 and 1 is for isEndof Word true and isEndofWord false.
functiondoGet() {
returnHtmlService.createHtmlOutputFromFile('Index');
}
functiongetLoc(value) {
vardestId = FormApp.getActiveForm().getDestinationId() ;
varss = SpreadsheetApp.openById(destId) ;
varrespSheet = ss.getSheets()[0] ;
var data = respSheet.getDataRange().getValues() ;
var headers = data[0] ;
varnumColumns = headers.length ;
varnumResponses = data.length;
var c=value[0];
var d=value[1];
var e=c + "," + d ;
// the script will add device geocode data in last submit data row by clicking the link on confirmation page that shows up after hitting the submit button
// geocode data here consists of 3 columns : time to click the link, longitude & latitude and address (using reverse geocode)
// as long as clicking the link is done before next respondent submit button, data will be entered in the right row.
// however particularly for the case of multiple devices that submit data at about the same time then whichever device clicks the link closer to the last submit time, their geodata will be entered in the last submit data row.
// this may leave geocode column in the row above empty. In this case the geocode data will be in red font
// If sometime later another device click the link then the geodata will be entered in closest missing geodata row. The data will also be in red font
// Therefore for red font data you may want to check manually after completion for correct geodata entry. In the questionnaire add question about address to help checking.
// script iniakanmenambahkan data geocode pada row data terakhir yang disubmitdenganmeng-klik link pada confirmation page yang munculsetelahkitamengklik submit
// data geocode disiniterdiridari 3 kolom :waktumengklik link, longitude dan latitude, danalamat (dari geocode)
// selama link di kliksebelumrespondenselanjutnya, data akandimasukkandalam row yang benar.
// tetapijikauntukbeberapa device yang mengklikdalamwaktuhampirbersamaanmakasiapapun yang mengklikterdekatwaktunyadenganwaktu data submit terakhir, data geocode dari device tersebutdakandimasukkanke row terakhir.
// Iniakanmengakibatkan geocode untuk device lain di row sebelumnyakosong. Data geocode akandalam font merah.
// Jikasetelahitu device lain menekan link, data geocode akandimasukkandalam row kosongterdekat.
// Karenanyauntuk data yang berwarnamerahperlu di check secara manual setelahpengisiankuesioner. Untukmembantu checking bisaditambahkanpertanyaanmengenaialamat di kuesioner.
if (respSheet.getRange(1,numColumns).getValue()=="GeoAddress") {
//fill data for second respondents onwards no missing geo data
// time here is Jakarta, you may need to change time to your local time (in GMT)
if (respSheet.getRange(numResponses,numColumns-2).getValue()=="" &&respSheet.getRange(numResponses-1,numColumns-2).getValue()!="" ){
respSheet.getRange(numResponses,numColumns-2).setValue(Utilities.formatDate(new Date(), "GMT+7", "MM/dd/yyyyHH:mm:ss"));
respSheet.getRange(numResponses,numColumns-1).setValue(e);
var response = Maps.newGeocoder().reverseGeocode(value[0], value[1]);
f= response.results[0].formatted_address;
respSheet.getRange(numResponses,numColumns).setValue(f);
}
//fill data with previous geo data missing. red font
else if (respSheet.getRange(numResponses,numColumns-2).getValue()=="" &&respSheet.getRange(numResponses-1,numColumns-2).getValue()=="" ){
respSheet.getRange(numResponses,numColumns-2).setValue(Utilities.formatDate(new Date(), "GMT+7", "MM/dd/yyyyHH:mm:ss")).setFontColor("red");
respSheet.getRange(numResponses,numColumns-1).setValue(e).setFontColor("red");
var response = Maps.newGeocoder().reverseGeocode(value[0], value[1]);
f= response.results[0].formatted_address;
respSheet.getRange(numResponses,numColumns).setValue(f).setFontColor("red");
}
//to fill missing previous data. red font
else if (respSheet.getRange(numResponses,numColumns-2).getValue()!=""){
for (i = 0; i<numResponses; i++) {
if (respSheet.getRange(numResponses-i,numColumns-2).getValue()=="") {
respSheet.getRange(numResponses-i,numColumns-2).setValue(Utilities.formatDate(new Date(), "GMT+7", "MM/dd/yyyyHH:mm:ss")).setFontColor("red");
respSheet.getRange(numResponses-i,numColumns-1).setValue(e).setFontColor("red");
var response = Maps.newGeocoder().reverseGeocode(value[0], value[1]);
f= response.results[0].formatted_address;
respSheet.getRange(numResponses-i,numColumns).setValue(f).setFontColor("red");
break; }
}
}
}
else if (respSheet.getRange(1,numColumns).getValue()!="GeoAddress") {
//create labels in first row
respSheet.getRange(1,numColumns+1).setValue("GeoStamp");
respSheet.getRange(1,numColumns+2).setValue("GeoCode");
respSheet.getRange(1,numColumns+3).setValue("GeoAddress");
//fill data for first respondent
if (numResponses==2) {
respSheet.getRange(numResponses,numColumns+1).setValue(Utilities.formatDate(new Date(), "GMT+7", "MM/dd/yyyyHH:mm:ss"));
respSheet.getRange(numResponses,numColumns+2).setValue(e);
var response = Maps.newGeocoder().reverseGeocode(value[0], value[1]);
f= response.results[0].formatted_address;
respSheet.getRange(numResponses,numColumns+3).setValue(f);
}
else if (numResponses> 2){
respSheet.getRange(numResponses,numColumns+1).setValue(Utilities.formatDate(new Date(), "GMT+7", "MM/dd/yyyyHH:mm:ss")).setFontColor("red");
respSheet.getRange(numResponses,numColumns+2).setValue(e).setFontColor("red");
var response = Maps.newGeocoder().reverseGeocode(value[0], value[1]);
f= response.results[0].formatted_address;
respSheet.getRange(numResponses,numColumns+3).setValue(f).setFontColor("red");
}
}
}
A very light-weight Spell-checker which runs as a background process all the time.
- Sphinx April 17, 2013At any time you can sign in, and see the mis-spellings that you have done in all the softwares - text editor, browser, etc.