Skip to content

N-gram character models #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 13, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions 22-Natural-Language-Processing/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,34 @@
<link rel="stylesheet" href="../styles.css">
<script src="http://code.jquery.com/jquery-1.12.4.js"></script>
<script type="text/javascript" src="../main.js"></script>
<script type="text/javascript" src="../22-Natural-Language-Processing/nGramModels.js"></script>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be simpler as src="nGramModels.js"

</head>
<body>

<div class="row">
<div class="col-sm-6 col-md-offset-3" id="content">
<h1>Natural Language Processing</h1>
<p>TODO</p>
<h3>Table of contents</h3>
<ul class="content-table">
<li><a href="#n-gram-character-models">N-gram character models</a></li>
</ul>


<h2 id="n-gram-character-models">N-gram character models</h2><br>

<form id="form">
<div class="form-group">
<label >Enter a phrase</label>
<input type="text" class="form-control" name="firstname" id="phrase"/>
</div>
<div class="form-group">
<button type="submit" class="submit btn btn-success">Submit</button>
</div>
</form>
<span><h5>Character Level Unigrams :-</h5></span><div id="character-level-unigram"></div><br>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A span is an “inline element” and an h5 is a “block element”. Normally a block element can contain inline elements, but inline elements should not contain block elements. I think you can remove the span here

<span><h5>Character Level Bigrams :-</h5></span><div id="character-level-bigram"></div><br>
<span><h5>Character Level Triigrams :-</h5></span><div id="character-level-trigram"></div><br>
</div>
</div>


</body>
</html>
22 changes: 22 additions & 0 deletions 22-Natural-Language-Processing/nGramModels.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
$(document).ready(function() {
$('#form').submit(function() {
var str = $('#phrase').val();
var charUnigram;
for (var x = 0; x < str.length; x++)
{
var a = str.charAt(x);
var b = str.charAt(x+1);
var c = str.charAt(x+2);
//Unigram
$('#character-level-unigram').append("<kbd>"+a+"</kbd>");
$('#character-level-unigram').append(", ");
//Bigram
$('#character-level-bigram').append("<kbd>"+a+b+"</kbd>");
$('#character-level-bigram').append(", ");
//Trigram
$('#character-level-trigram').append("<kbd>"+a+b+c+"</kbd>");
$('#character-level-trigram').append(", ");
}
return false;
});
});