Resend my activation email : Register : Log in 
BCF: Bike Chat Forums


Javascript programming help

Reply to topic
Bike Chat Forums Index -> The Geek Zone
View previous topic : View next topic  
Author Message

5v3d3b0
World Chat Champion



Joined: 24 Sep 2006
Karma :

PostPosted: 20:23 - 14 Nov 2010    Post subject: Javascript programming help Reply with quote

Right, if nobody wants to help me out I understand it, but I'm in serious shit. Coursework in for tomorrow, and I'm lost beyond imagination. I don't even understand what they're asking me...
Here's the spec:
Quote:
Write a program to simulate some aspects of a search engine.

The data to be searched will be represented by an array of pages. Each page will be represented by a string containing a URL in square brackets, then the readable content of the page in plain text, i.e. "[URL]content".

var pages=[
"[www.lboro.ac.uk]Loughborough University offers degree programmes and world class research. ",
...
];
You should 'invent' your own test data (i.e. content for array pages) but bear in mind that your program will ultimately be tested on data which you have not seen in advance.

The following functions are required. Be careful that you use EXACTLY the names specified and follow the specifications precisely. The functions will treat the array pages as a global variable.
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts

5v3d3b0
World Chat Champion



Joined: 24 Sep 2006
Karma :

PostPosted: 20:25 - 14 Nov 2010    Post subject: Reply with quote

These are the questions, then I have to write a page or 2 explaining why I've used the scripts I've chosen. How screwed am I? I can't see the light at the end of this one :/

i) function URL(page) - to return the URL part (not including the brackets) part of page (which is a string). [Note that this function will not contain an alert]
Example call: URL("[www.lboro.ac.uk]Loughborough University offers degree programmes and world class research. ")
Example result: "www.lboro.ac.uk"

ii) function content(page) - to return the content part (not including the URL) part of page (which is a string). [Note that this function will not contain an alert]
Example call: content(pages[0])
Example result: "Loughborough University offers degree programmes and world class research. "

iii) function find1C(s,p) - p is a number which is an index to the pages array and thus identifies one particular page. The function is to discover if the string s appears in the content (not the URL) part of page p. Gives an alert message containing the value of s together with either the text 'found' or 'not found'. [Note that s need not be a full word so that if p was 0 and s had any of the values "programmes", "programme", "program", "prog", "rog", "og", or "g" the result would be 'found' but if s had the value 'PROG' the result would be 'not found' because this is a case sensitive search. ]
Example call: find1C("prog",0)
Example result:
example result iii
[Note: The image above and two others below were added 9/11/2010 to replace the previous textual representation of the Example result.]

iv) function findAnyU(s) - to discover if string s appears in any of the URLs in the array pages. Gives an alert of s together with 'found' or 'not found' as for find1C. [Note that the search should be case insensitive so that 'lboro' and 'Lboro' and 'LBORO' would all be found in 'www.lboro.ac.uk' - all remaining functions should also be case insensitive in this way]
Example call: findAnyU("Lboro")
Example result:
Example result iv

v) function findIdxsC(s) - to return a string containing the indexes in the pages array where s was found in the content part, e.g. "prog found in pages 0,3,5,6,9" [Note that this function will not contain an alert]
Example call:findIdxsC("prog")
Example result:"prog found in pages 0,3,5,6,9"

vi) function findScoresC(s) - to return an array of scores for each content string in the pages array. [Score 0 for string s not found, 1 for string s found once, 2 for string s found twice, etc. Try to ensure that your program does not find s more than once in each word - e.g. if s='w' then it should be found twice in "The WWW. Hello world", not four times. ]
Example call: scores=findScoresC("prog")
Exploring the (array) result: alert(scores[2])

vii) function sortScores(scoreRecs) - to take an array of score records (each containing a score and a page index) return a sorted version where the records are arranged in descending order of score.
Example call: sortScores( [ { score:0, index:0 }, { score:2, index:1 }, { score:1, index:2 } ] )
Example result: [ { score:2, index:1 }, { score:1, index:2 }, { score:0, index:0 } ]

viii) function findScoreC2(s) - to find scores information as in findScoresC but return it in an array of records suitable as data for function sortScores. However this time the score is not just a straight count of the number of matches but a percentage score. The percentage score is obtained by the number of times the pattern occurs in the page divided by the number of words in the page, expressed as a percentage.
Example call: findScoreC2("prog")
Example result (an array): [ { score:0, index:0 }, { score:20, index:1 }, { score:10, index:2 } ]

ix) function findRanked(s) - to find scores information as in findScoresC2 and sort them as in sortScores and to finally return a string containing '(URL, %)\n' pairs where the percentage scores are in descending order.
Example call: findRanked("prog")
Example result: (www.lboro.ac.uk, 20%)
(www.other.com, 10%)
(www.zzz.tv, 1%)

x) function findMulti(wds) - to discover if any of the words in wds appear in the string pages[0]. This is a multiword search. The value for wds could be "univ deg LOUGH". Gives an alert of 'found' if any combination of 'univ' or 'deg' or 'LOUGH' is found.
Example call: findMulti("univ deg LOUGH")
Example result:
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts

The Shaggy D.A.
Super Spammer



Joined: 12 Sep 2008
Karma :

PostPosted: 20:56 - 14 Nov 2010    Post subject: Reply with quote

https://buzzedition.com/wp-content/uploads/2010/01/FAIL-Cats-We-shall-decide.jpg
____________________
Chances are quite high you are not in my Monkeysphere, and I don't care about you. Don't take it personally.
Currently : Royal Enfield 350 Meteor
Previously : CB100N > CB250RS > XJ900F > GT550 > GPZ750R/1000RX > AJS M16 > R100RT > Bullet 500 > CB500 > LS650P > Bullet Electra X & YBR125 > Bullet 350 "Superstar" & YBR125 Custom > Royal Enfield Classic 500 Despatch Limited Edition (28 of 200) & CB Two-Fifty Nighthawk > ER5
 Back to top
View user's profile Send private message You must be logged in to rate posts

5v3d3b0
World Chat Champion



Joined: 24 Sep 2006
Karma :

PostPosted: 23:03 - 14 Nov 2010    Post subject: Reply with quote

Thanks for the support Crying or Very sad
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts

Astridax
Nitrous Nuisance



Joined: 27 Jul 2010
Karma :

PostPosted: 02:00 - 15 Nov 2010    Post subject: Reply with quote

Are You given a list of websites that need to be searches through. If so it's easy. Order them alphabetically, have two arrays, one ordered by url, the other content. Then have a function like this:

Function search (var term:string) : string
((while term != ArrUrl(i).value
next I) else
Return ArrUrl.value
)

Call on something like this

On button click do
Search (urlbox.text)

Have similar boxes and arrays for content. Sorry I can't help you with the language specifics, I don't know java too well? Something that will change by the end of the academic year. Sorry about the fail formatting, typing this off my phone.
 Back to top
View user's profile Send private message You must be logged in to rate posts

Luke_Retrofly
Silly Lesbian



Joined: 05 Jul 2003
Karma :

PostPosted: 12:55 - 15 Nov 2010    Post subject: Reply with quote

This is why you should listen in skool instead of getting other peeps to do your work for you.....
____________________
Flounced - Long overdue
Fuck you bitch I'm in the top 10 list I can do the what the fuck I want!
 Back to top
View user's profile Send private message Visit poster's website You must be logged in to rate posts

chris-red
Have you considered a TDM?



Joined: 21 Sep 2005
Karma :

PostPosted: 13:07 - 15 Nov 2010    Post subject: Reply with quote

Luke wrote:
This is why you should listen in skool instead of getting other peeps to do your work for you.....


Or at least ask them to do it earlier than a day beforehand.
____________________
Well, you know what they say. If you want to save the world, you have to push a few old ladies down the stairs.
Skudd:- Perhaps she just thinks you are a window licker and is being nice just in case she becomes another Jill Dando.
WANTED:- Fujinon (Fuji) M42 (Screw on) lenses, let me know if you have anything.
 Back to top
View user's profile Send private message You must be logged in to rate posts

skatefreak
World Chat Champion



Joined: 06 Feb 2010
Karma :

PostPosted: 13:07 - 15 Nov 2010    Post subject: Reply with quote

If it is not to late,
i would suggest submitting whatever you have done so far...
If your uni is anything like mine,
no submission = fail (fail module),
Submit a pile of shite = shite mark but can do a referral!

So the bare arsed face of it is if your screwed, aim for a refurral...

Best of luck, it isnt the end of the world.

-Jvr
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts

el_oso
World Chat Champion



Joined: 17 May 2008
Karma :

PostPosted: 14:03 - 15 Nov 2010    Post subject: Reply with quote

you go to lboro?
____________________
Duke 390
Previous: '05 XR125L | '96 XJ600S Diversion |'05 Suzuki GSXR1000 | '05 Honda CBR125-R | '97 YZF 600R Thundercat | '11 Honda CBR250
Car: Jeep Wrangler 4.0L
 Back to top
View user's profile Send private message You must be logged in to rate posts

5v3d3b0
World Chat Champion



Joined: 24 Sep 2006
Karma :

PostPosted: 18:36 - 15 Nov 2010    Post subject: Reply with quote

Yes I go to lufbra, anyone else? Razz
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts

Kickstart
The Oracle



Joined: 04 Feb 2002
Karma :

PostPosted: 18:45 - 15 Nov 2010    Post subject: Reply with quote

Hi

Do you still need to do this or did you cobble something together?

All the best

Keith
____________________
Traxpics, track day and racing photographs - Bimota Forum - Bike performance / thrust graphs for choosing gearing
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts

5v3d3b0
World Chat Champion



Joined: 24 Sep 2006
Karma :

PostPosted: 19:34 - 15 Nov 2010    Post subject: Reply with quote

Well, I don't need it any more cause hand in has passed. I ended up getting 2 questions from my mate just to hand something in, but I'm screwed anyway. There is enough of the module left for me to pass the year, but it's gonna be tight :/
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts

The Shaggy D.A.
Super Spammer



Joined: 12 Sep 2008
Karma :

PostPosted: 19:36 - 15 Nov 2010    Post subject: Reply with quote

Don't worry about it, just leave it until the night before and post a request for help on BCF.
____________________
Chances are quite high you are not in my Monkeysphere, and I don't care about you. Don't take it personally.
Currently : Royal Enfield 350 Meteor
Previously : CB100N > CB250RS > XJ900F > GT550 > GPZ750R/1000RX > AJS M16 > R100RT > Bullet 500 > CB500 > LS650P > Bullet Electra X & YBR125 > Bullet 350 "Superstar" & YBR125 Custom > Royal Enfield Classic 500 Despatch Limited Edition (28 of 200) & CB Two-Fifty Nighthawk > ER5
 Back to top
View user's profile Send private message You must be logged in to rate posts

Syris the Indomitable
Crazy Courier



Joined: 22 Oct 2010
Karma :

PostPosted: 20:29 - 15 Nov 2010    Post subject: Reply with quote

you need to look into Python, google uses a lot of Python.
Write your user interface using PHP, and some of your back-end using Python or PERL, the core indexing routines are better written in 'C'


Adding a simple google search to your website:

<form method="get" action="https://www.google.com/search">

<input type="text" name="q" size="31"
maxlength="255" value="" />
<input type="submit" value="Google Search" />
<input type="radio" name="sitesearch" value="" />
The Web
<input type="radio" name="sitesearch"
value="askdavetaylor.com" checked /> Ask Dave Taylor<br />

</form>
____________________
In Greek mythology Ichor is what immortals have in the place of blood
Those that mind, don't matter...Those that matter, don't mind. Do you agree with this?


Last edited by Syris the Indomitable on 20:51 - 15 Nov 2010; edited 1 time in total
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts

Syris the Indomitable
Crazy Courier



Joined: 22 Oct 2010
Karma :

PostPosted: 20:49 - 15 Nov 2010    Post subject: Reply with quote

Only joking!

All here:
https://www.trans4mind.com/personal_development/JavaScript/searchEngine.htm

https://www.the-art-of-web.com/php/parse-links/
____________________
In Greek mythology Ichor is what immortals have in the place of blood
Those that mind, don't matter...Those that matter, don't mind. Do you agree with this?


Last edited by Syris the Indomitable on 20:55 - 15 Nov 2010; edited 1 time in total
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts

bazza
World Chat Champion



Joined: 27 Aug 2004
Karma :

PostPosted: 20:53 - 15 Nov 2010    Post subject: Reply with quote

Svedebo wrote:
Well, I don't need it any more cause hand in has passed. I ended up getting 2 questions from my mate just to hand something in, but I'm screwed anyway. There is enough of the module left for me to pass the year, but it's gonna be tight :/


Don't worry, Java isn't all that useful in the real world...

https://tinyurl.com/392mr68
____________________
"That's it. You people have stood in my way long enough. I'm going to clown college."
'98 Ducati 750SS, '08 Suzuki GSX650F ©2004-2014, Bazza's Harmless Banter
 Back to top
View user's profile Send private message You must be logged in to rate posts

Christopher
Derestricted Danger



Joined: 01 Oct 2008
Karma :

PostPosted: 21:05 - 15 Nov 2010    Post subject: Reply with quote

alert('Java' == 'JavaScript' ? 'Yes' : 'No');
 Back to top
View user's profile Send private message Visit poster's website You must be logged in to rate posts

Frost
World Chat Champion



Joined: 26 May 2004
Karma :

PostPosted: 21:42 - 15 Nov 2010    Post subject: Reply with quote

No.
ECMAscript as Sun, now oracle own the Javascript name, though Java can't be trademarked as it's an island.
Java + web page = Applet == epic fail.
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts

Astridax
Nitrous Nuisance



Joined: 27 Jul 2010
Karma :

PostPosted: 00:05 - 16 Nov 2010    Post subject: Reply with quote

Tell me if my code worked. I'd have tested it if I was near my comp.
 Back to top
View user's profile Send private message You must be logged in to rate posts

paledude101
L Plate Warrior



Joined: 02 Apr 2010
Karma :

PostPosted: 14:02 - 18 Nov 2010    Post subject: Reply with quote

Hehehe Monotone Stone's module?? I did this in first year, can't remember how though!
 Back to top
View user's profile Send private message You must be logged in to rate posts
Old Thread Alert!

The last post was made 15 years, 336 days ago. Instead of replying here, would creating a new thread be more useful?
  Display posts from previous:   
This page may contain affiliate links, which means we may earn a small commission if a visitor clicks through and makes a purchase. By clicking on an affiliate link, you accept that third-party cookies will be set.

Post new topic   Reply to topic    Bike Chat Forums Index -> The Geek Zone All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Read the Terms of Use! - Powered by phpBB © phpBB Group
 

Debug Mode: ON - Server: birks (www) - Page Generation Time: 0.10 Sec - Server Load: 0.77 - MySQL Queries: 13 - Page Size: 111.18 Kb