Comments (1)
No bug, just some JavaScript code issues. I've updated the sample code to let
folks working in web browsers know that the print function is not available.
--- Copied from Email Thread with Yoni ---
There were a couple of issues with your code:
- The sample text was wrapped onto a new line. Javascript doesn't recognize
multi-line strings unless you terminate each line with a backslash \
- The print command doesn't work in a browser (my example was from Google's V8
standalone javascript interpreter). Instead, you could do document.writeln.
I've updated the website to make note of this.
For Javascript development, I strongly recommend that you get yourself a good
debugger. If you use Firefox, there's a great add on that includes a debugger
- http://getfirebug.com/. If you're using Google Chrome, it has a built in
debugger that you can use per the below instructions:
http://stackoverflow.com/questions/66420/how-do-you-launch-the-javascript-debugg
er-in-google-chrome
I've included a working version of your code at the end of my email.
Cheers,
Percy
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<script type = "text/javascript" src="lexer.js"></script>
<script type = "text/javascript"src="lexicon.js_"></script>
<script type = "text/javascript"src="POSTagger.js"></script>
<script type="text/javascript">
// Note the \ at the end of the first line
var words = new Lexer().lex("This is some sample text. \
This text can contain multiple sentences.");
var taggedWords = new POSTagger().tag(words);
for (i in taggedWords) {
var taggedWord = taggedWords[i];
var word = taggedWord[0];
var tag = taggedWord[1];
// Note the use of document.writeln instead of print
document.writeln(word + " /" + tag + "<br/>");
}
</script>
<script type = "text/javascript">
document.write('Hello World!');
</script>
</body>
</html>
Original comment by [email protected]
on 9 Sep 2010 at 3:37
- Changed state: Invalid
from jspos.
Related Issues (5)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jspos.