Created
June 13, 2020 04:06
-
-
Save vivekteega/62ab508c7299b9cc3730d99105edc3ad to your computer and use it in GitHub Desktop.
parsePlot discussion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var plotDiagram = `(Hooghly, Calcutta, 2020, Painting Hooghly with words-Build background and bridge to Writers Building) -> | |
(Writers Building, 2020, Calcutta, Painting Writers) | |
-> | |
(Chief Minster Cabin, Calcutta, 2021, Painting the process who will sit here-painting Chief Minister Cabin-Bridge to current occupant) -> | |
(Mamata Banerji, Calcutta, 2020, Profile about current occupant-one interesting fact from her life to trigger - like being unmarried) -> | |
(Hooghly-Origin of Calcutta, Calcutta, 1690, go qqqback to start how Calcutta was created in British times) -> | |
(Aurangzeb, Dhaka, 1690, Explain State of Mughal affairs - and how Bengal became independent country) -> | |
(Murshid Quli Khan, Murshidabad, 1707-1717, Go upriver to Murshidabad-Explain how the richest country in the world is born) -> | |
(Alivardi Khan, Murshidabad, 1717-1756, continuation of Murshid Story-Alivardi was last strong man Britishers feared in Bengal) -> | |
(Robert Clive, Murshidabad-Plassey-Calcutta, 1757, Start of British power in Bengal and in India-Battle of Plassey) -> | |
(Battle Theme- Sheikh Mujibur Rehman-Bangladesh, Bangladesh, 1971-1975, Creation of Bangladesh and Pakistan role in Bengal till Sheikh Mujibur Rehman was assassinated-Bridge to his daugher Sheikh Haseena) -> | |
(Creation of East Pakistan-Suhrawady,United India, 1945-1947, Talk about events in Bengal when it broke out of India) -> | |
(Sheikh Haseena, Dhaka-Bangladesh, 2020, Regeneration to be the fast growing region in the world-Bridge to Mamata) -> | |
(Mamata Banerji, Calcutta, 2020, Another aspect of her life- a short event - Bridge to her political predecessor system Communism and Jyoti Basu) -> | |
(Jyoti Basu-Communism, West Bengal, 1977-2000, Impact of Communism in Bengal-Bridge to Cornwallis Permanent Settlement) -> | |
(Cornwallis, Bengal, 1790-1800, Permanent Settlement System and how it impacted West Bengal) -> | |
(William Bentick, Bengal, 1828-1835, Bentick social reforms) -> | |
(Lord Dalhousie, Bengal, 1857, events leading to first war of independence) -> | |
(Lord Curzon, Bengal, 1905, partition of Bengal) -> | |
(Hooghly, Bengal, 1905-1947, an event in Hooghly in this time period) -> | |
(Writers Building-Bidhan Chandra Roy, Calcutta, 1950, explain his contribution in governing West Bengal) -> | |
(Hoogly-Writers Building, Calcutta, 2020, Come back to present, talk about current political situation and talk about upcoming elections) -> | |
(Amit Shah - Bengal Elections 2021, Bengal, 2021, Give a closure to readers and make them look forward to Elections 2021-CONCLUSION)` | |
function parsePlot(plottext) { | |
var tstring = plottext.replace(/\s+/g, " "); // collapse all whitespace to single whitespace | |
tstring = tstring.replace(/(\r\n|\n|\r|\t)/gm, ""); | |
tstring = tstring.trim(); // trim whitespace from both ends | |
tstring = tstring.replace(") -> (", ")->( "); | |
tstring = tstring.replace(") ->(", ")->( "); | |
tstring = tstring.replace(")-> (", ")->( "); | |
tstring = tstring.split(")->("); // split string based on the delimiter | |
return tstring; | |
if (tstring.length > 0) { | |
if (tstring[0].trim()[0] == "(") { | |
tstring[0] = tstring[0].trim().slice(1) | |
} | |
else { | |
return 'error'; | |
} | |
var lastobj = tstring[tstring.length-1]; | |
var lastobjlen = lastobj.length; | |
if (lastobj.trim()[lastobjlen-1] == ")") { | |
tstring[tstring.length-1] = lastobj.trim().slice(0, lastobjlen-1) | |
} | |
else { | |
return 'error'; | |
} | |
} | |
else { | |
return 'error'; | |
} | |
return tstring; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment