Renewed MacBooks are on sale on Amazon (including a rose gold one)
by Dylan HaasRefurbished tech tends to get a bad rap — most people assume that because it’s technically not a new device, that means that it’s broken in some way. In fact, that’s not the case at all. “Refurbished” or “renewed” just means that the item was bought, opened, and returned for some reason — and that reason doesn’t necessarily have to be some sort of defect. In a lot of cases, buying a renewed device can mean that you’re getting almost brand-new quality for way below the usual asking price.
Now that we’ve gotten that out of the way, we’re happy to announce that Amazon is offering of a bunch of renewed MacBooks right now; some of them for up to $500 off. Here are a few of the highlights, and if you want to see the full list of discounts, go here.
12-inch MacBook in Space Gray
The MacBook that we all know and love for a whole $500 off — what a steal. This one comes with an Intel Core i5 Dual-Core processor (1.3 GHz), 512GB of storage, and 8GB of RAM.
12-inch MacBook in Space Gray — $899.99 See Details
12-inch MacBook in Gold
This one is also $500 off with all the same specs as the one above, but it’s gold. So, why not?
12-inch MacBook in Gold — $899.99 See Details
12-inch MacBook in Rose Gold
This one isn’t discounted nearly as much, but we couldn’t resist that striking rose gold finish. Time to rose to your goals. Grab one on Amazon for $134.96 off.
12-inch MacBook in Rose Gold — $699.99 See Details
Classic 13-inch MacBook Pro
For $289.01 off, you can get the even more powerful MacBook Pro (sans touchbar, though) with a 227ppi Retina Display, an Intel Core i5 2.3GHz processor, 256GB of SSD storage, and 8GB of RAM.
Classic 13-inch MacBook Pro — $899.99 See Details
13-inch MacBook Pro in Space Gray
Same discount and same specs as the classic, but in the newer, sleeker Space Gray finish. Grab one for $289.01 off of the usual price.


University of Miami Music Business and Entertainment Industries Degree Program
University of Miami Overview:
What: University of Miami Music Business and Entertainment degree program
Where: Miami, Florida, USA
Degrees Offered: B.M. and M.A.
Music Business and Entertainment Industries:
Basic Program Information:
The University of Miami's Music Business and Entertainment Industries degree program is part of the university's Frost School of Music, although students also take many classes in the School of Business.
The Frost School of Music also offers a Bachelor's degree in music, but the difference between that degree and the music business degree is that the emphasis in the latter is on preparing students for the business side of the industry. Although students in the music business program still must take classes in music performance and theory, learning the industry is the focus.
What Will You Learn?:
There is plenty of room within the music degree program for students to develop their own interests, including recording and studio work, management, record label jobs, music promotion, and even teaching music. Although students are able to develop their specialty, they are exposed to all aspects of the music industry so they will be able to see how their chosen field fits into the larger picture.


All transactions to and from my normal account and my savings account. Debits and credits summed separately, per day.


When we write the bits of a byte as 8 bits each having the value of 0 or 1, we are actually writing the numeric value of the byte as a binary number. This number can represent a numeric value or it can just be used to identify one of many possible things. For example, a byte can be used to represent a character (alphabetic, digits, punctuation etc), where it being a number is not particularly relevant, except, perhaps, for defining an order to the characters. We will talk about character sets in a later section.
Hexadecimal Notation
A group of X bits can store 2^X different values. So a single bit can store 2^1 or just 2 values (which we will call 0 and 1). A byte has 8 bits so it can store 2^8 or 256 different values. Similarly a nybble can store 2^4 or 16 values, a word 2^16 or 65,536, a double word 2^32 or 4,294,967,296, and a quad word 2^64 or a lot.
The number of different symbols (or digits) used to display numbers is called the radix or base. Decimal numbers use 10 different digits, binary numbers use 2, while hexadecimal numbers use 16. Generally, people are used to seeing and manipulating numbers using the decimal or base 10 system, not because it is the best system, but for historical (and anatomical) reasons. In a decimal system there are 10 different digits (0, 1, … 9). It turns out that the easiest way for electronic circuits to store and manipulate numbers is using the binary or base 2 system. In this system there are just 2 digits (0 and 1).
When people need to work with binary data, looking at large numbers of zeroes and ones can be tedious and error-prone. This is where hexadecimal or base 16 is useful. But for hexadecimal (or hex for short) we need 16 digits. So to the normal 10 decimal digits (0 to 9) we add the 6 alphabetic characters A to F which represent the values 10 to 15.
Why not display binary data as decimal rather than hex, you may ask? Well it turns out that mathematically, binary and hex are closely related, since 16 is a power of 2 (ie, 16 = 2*2*2*2). Any hex digit can represent exactly 4 binary digits (ie., one nybble). Hence it is simple to convert between binary and hex. This is important as binary values are not always used to store numbers - they may be used to store a sequence of flags, for example. It is relatively easy to convert hex digits to binary to see which flags are on; it would be more difficult to convert from decimal back to binary.
Well then why not use octal (base 8), you may ask? Trust me, hex is better. Octal was popular for a time, but hex has the advantage that a byte can be displayed as 2 hex digits. In octal you need 3 octal digits for a byte with one bit left over, so it’s not quite as neat. Here is a table showing some binary, octal, decimal and hex values.
|
Binary |
Octal |
Decimal |
Hex |
|
0000 0000 |
000 |
0 |
00 |
|
0000 0001 |
001 |
1 |
01 |
|
0000 0010 |
002 |
2 |
02 |
|
0000 0011 |
003 |
3 |
03 |
|
0000 0100 |
004 |
4 |
04 |
|
0000 0101 |
005 |
5 |
05 |
|
0000 0110 |
006 |
6 |
06 |
|
0000 0111 |
007 |
7 |
07 |
|
0000 1000 |
010 |
8 |
08 |
|
0000 1001 |
011 |
9 |
09 |
|
0000 1010 |
012 |
10 |
0A |
|
0000 1011 |
013 |
11 |
0B |
|
0000 1100 |
014 |
12 |
0C |
|
0000 1101 |
015 |
13 |
0D |
|
0000 1110 |
016 |
14 |
0E |
|
0000 1111 |
017 |
15 |
0F |
|
0001 0000 |
020 |
16 |
10 |
|
0001 0001 |
021 |
17 |
11 |
|
1111 1111 |
377 |
255 |
FF |
Note that since many hex numbers (especially if they happen to not contain any of the digits A to F) may be mistaken for innocent decimal numbers we need to distinguish them from decimal to avoid confusion. There are several conventions. A very old convention is to precede the number with a dollar sign ($). A convention that comes from Intel assembler is to append a lower case ‘h’. While C/C++ programmers use a ‘0x’ prefix. Another convention is to simply prepend or append an 'x'. So the number 16 (decimal) may be written in hex as $10, 10h, 10x, or 0x10.
Base Conversion
You may remember from school about how numbers are stored in different bases. In general a number, say ABCD in base X is A*X*X*X + B*X*X + C*X + D. That is, the number is the sum of the values for each digit. The value for digit N is the digit times X^N (where N = 0, 1, 2, …). Don’t forget that anything to the power zero (X^0) is one.
For example, if you convert the hex number 468A to decimal you get 4*16^3 + 6*16^2 + 8*16^1 + 10*16^0 = 4*4096 + 6*256 + 8*16 + 10*1 = 18,058 (base 10). Converting the same number to binary is easier since each hex digit converts to 4 binary digits. So 468A = 0100 0110 1000 1010 (base 2).
The point of all this is that files are stored as a sequence of bytes, and bytes are most easily shown in hex (because, as we saw above, it’s too hard to convert decimal to binary, octal is ugly and binary would just take up too much screen space). This is the reason that HexEdit Pro’s (main) display of binary files is a sequence of pairs of hex digits representing the bytes of the file.
Next topic: Boolean Operations


A real pressure cooker: Shrewsbury chef Neil stars on MasterChef: The Professionals
by Charlotte BentleyA young Shrewsbury-based chef impressed the judges on MasterChef: The Professionals after reaching the quarter finals.
Neil Roberts, who is junior sous chef at Mercure Shrewsbury Albrighton Hall Hotel and Spa, said he had an "amazing experience" reaching the quarter finals of the hit TV show.
The 20-year-old, who lives in Wales, said he entered the competition on a whim and thoroughly enjoyed the whole experience.
His father and great-grandfather were both chefs, and he said: “It runs in my blood. Ever since I started school, being a chef was all I could ever see myself doing.
He said about competing on the show: “It was the most pressure I have ever been under. I did not realise how much pressure it would be.
“But the experience of working with different chefs and the feedback from such well-known judges has been absolutely incredible.
Amazing
“Doing something like this means putting your reputation on the line. Doing it so early in my career meant I had nothing to lose really, so there was no better time to do it.
“It is a massive judge of character and was an amazing experience.”
Neil finished school at 16 and started an apprenticeship. He worked in a small country house hotel in Wales, where the head chef had a big influence on him, and even went on to work in Melbourne, Australia for six months at a restaurant that is regularly named amongst the top ten in the country.
Jennifer Sibbald-Wall, manager of the Albrighton Hall Hotel and Spa, said: “We are all extremely proud of Neil.
“I think nerves may have got the better of him in the end, but he is only 20 and I have no doubt that he is definitely one to watch for the future."


Parsing & Implicit Parsing in SymPy
This is a work-in-progress and will be periodically revised to reflect changes in SymPy. Last updated: 2014-6-21
One of the annoyances of entering mathematics on the computer is the rigidity of the format the computer generally expects. In SymPy, sympify()
won’t accept any of the following, though a human would:
2x
5 sin x
6(9)
sin x^3 + y
ln sin x
sin^2 x
xyz
SymPy’s implicit parsing aims to fix this. Implicit multiplication takes care of statements like 2x
, symbol splitting allows for xyz
, implicit application enables sin x
, and function exponentiation allows sin^2 x
.
But first, we have a problem: some of these statements are ambiguous. For instance, should sin x^3 + y
be interpreted as sin(x^3) + y
, sin(x^3 + y)
, or sin(x)^3 + y
? The last one, to a human, wouldn't make much sense, but the other two are perfectly valid. For SymPy, we’ve arbitrarily chosen the first interpretation.
That’s not all. Let’s look at the last case more: xyz
. To a human, this represents x*y*z
, so naturally to handle this SymPy should simply split the name into three. But we can’t split every token; consider these:
x_2
alpha
Splitting these names would not match user expectations at all.
So taking these considerations into account, how should we implement implicit parsing? We have a few options:
- Transform the input string (regular expression). This is what Sage does.
- Transform the token stream. This is what SymPy does.
- Use a custom parser.
(AST transforms aren’t an option because this syntax isn’t valid Python syntax.)
Let’s look at the SymPy parser. If you just want to read about implicit parsing, jump to the section about token transformations.
The SymPy Parser
Note: all data here is based on SymPy 0.7.3
Overall, SymPy follows these steps. You can follow along in sympy_parser.py
:
- Tokenize the input (which is not necessarily valid Python) using a modified Python 2 tokenizer.
- Run the tokens through a series of transformations.
- Untokenize the tokens, generating valid Python code.
- Evaluate the string.
Yes, we use eval()
. It’s not safe. (SymPy Live and SymPy Gamma deal with this by ignoring the problem: they run on Google App Engine, which is sandboxed.)
The SymPy Tokenizer
The tokenizer handles some syntax not in vanilla Python. In particular, we’d like to be able to parse expressions like these:
x!
(\(x\) factorial)x!!
(\(x\) double factorial)0.[123]
(\(0.\overline{123}\))
Note that the last example is valid Python—it’s equivalent to (0.)[123]
. But to make it easier to recognize and transform, we modified the tokenizer to handle it as a special case:
# Standard library
>>> tokenize.tokenize(StringIO('0.[123]').readline)
1,0-1,2: NUMBER '0.'
1,2-1,3: OP '['
1,3-1,6: NUMBER '123'
1,6-1,7: OP ']'
2,0-2,0: ENDMARKER ''
# SymPy
>>> sympy.parsing.sympy_tokenize.tokenize(StringIO('0.[123]').readline)
1,0-1,7: NUMBER '0.[123]'
2,0-2,0: ENDMARKER ''
!
and !!
are simply operators now:
>>> sympy.parsing.sympy_tokenize.tokenize(StringIO('x!!').readline)
1,0-1,1: NAME 'x'
1,1-1,3: OP '!!'
2,0-2,0: ENDMARKER ''
>>> sympy.parsing.sympy_tokenize.tokenize(StringIO('x!').readline)
1,0-1,1: NAME 'x'
1,1-1,2: OP '!'
2,0-2,0: ENDMARKER ''
Unfortunately, since this is based on an older tokenizer, it doesn’t support Python 3 features, such as bytestrings, and it’ll incorrectly parse longs in Python 3, not to mention it doesn’t support Unicode.
Transformations
Say you’re making a SymPy calculator/grapher/what-have-you. The user inputs this expression:
sin(x) + 3
and your app spits out this error message:
NameError: name 'x' is not defined
Not a very good calculator. SymPy handles this by transforming the token stream; in this case, undefined variables are wrapped in Symbol()
calls to turn them into SymPy symbols. By default, parsing uses these transformations:
- Undefined variables become
Symbol
s. - Complex numbers become SymPy complex numbers (
3 + 4j
becomes3 + 4*I
) - Repeating decimals become
Rational
s (0.[123]
becomesRational(123, 999)
). - Floating-point constants become
Float
s. - Integer constants become
Integer
s. - Factorial notation becomes calls to
factorial
orfactorial2
as appropriate.
SymPy also provides other useful transformations:
- XOR,
^
, becomes exponentiation. - Floats become rational numbers.
- Implicit parsing.
Note that SymPy’s transformations always produce valid Python code, since we’re not modifying the parser.
The API for this is a bit hidden. Here’s an example:
>>> from sympy.parsing.sympy_parser import parse_expr
>>> parse_expr("1/2")
1/2
>>> type(_)
<class 'sympy.core.numbers.Half'>
>>> from sympy.parsing.sympy_parser import standard_transformations,\
... implicit_multiplication_application, convert_xor
>>> transformations = (standard_transformations +
... (implicit_multiplication_application,))
>>> parse_expr("2x", transformations=transformations)
2*x
>>> transformations = (standard_transformations + (convert_xor,))
>>> parse_expr("x^3", transformations=transformations)
x**3
How do the implicit parsing transformations work? They’re split into four transformations: symbol splitting, multiplication, application, and exponentiation, which must be run in that order, though not all need to be run.
Symbol splitting is quite simple: for each name in the token stream, the transformation checks if it 1) is part of a Symbol
, so that it doesn’t split function names 2) is not a Greek letter, and 3) does not contain an underscore. If so, it makes one Symbol
for each letter in the original name.
Implicit multiplication scans the tokens two at a time, looking for one of these conditions:
- Closing parenthesis followed by opening parenthesis (
(x + 2)(x + 3)
) - Closing parenthesis followed by variable name (
(x + 2) sin(x)
) - Variable name followed by opening parenthesis (
pi (x + 3)
) - Variable name followed by variable name (
pi E EulerGamma
)
Application (and multiplication, though it’s not necessary) depends on an intermediate step that groups function calls into one token—sin(x)
, while represented with seven tokens normally (['sin', '(', 'Symbol', '(', "'x'", ')', ')']
), is first grouped into one “token” (called AppliedFunction
in the source). Then it follows these steps:
- Keep track of how many parentheses we have to insert and how many tokens to skip.
- For each token,
- If it’s a function name not followed by an opening parenthesis, increment the counter and insert an opening parenthesis.
- Else, if the parenthesis counter is nonzero,
- If the next token is a multiplication or exponentiation, increment the skip counter.
- Else, if the skip counter is nonzero, decrement it.
- Else, insert a closing parenthesis after this token and decrement the counter.
This way, sin x^2
gets parsed as sin(x^2)
, not sin(x)^2
. There’s some more logic to make life easier for the function exponentiation transformation as well.
To implement function exponentiation, think about how the token stream would look at this point. All functions are applied, so for sin**2 x
, we would have something like this:
['sin', '**', 'Integer', '(', '2', ')', '(', 'Symbol', '(', "'x'", ')', ')']
If you have implicit multiplication enabled, it’ll actually look like this (note the extraneous multiplication):
['sin', '**', 'Integer', '(', '2', ')', '*', '(', 'Symbol', '(', "'x'", ')', ')']
The transformation has to figure out what constitutes the exponent and what constitutes the function call. The rule SymPy uses is, essentially, the exponent is everything from and including the exponentiation operator to the first closing parenthesis it sees (this rules out anything but simple integer and symbolic exponents; sin**(x+3)(x+5)
won’t be parsed correctly). It then parses the following tokens, discarding the extraneous multiplication if it exists, to find the closing parenthesis of the function call (this correctly handles nested parentheses), and moves the tokens for the exponent to the end. So what the parser ends up seeing is
['sin', '(', 'Symbol', '(', "'x'", ')', ')', '**', 'Integer', '(', '2', ')']
which is equivalent to sin(Symbol(x))**2
.
Evaluation
One final note: SymPy uses a an evaluation trick for the final result. SymPy defines Symbol.__call__
so that this works:
>>> spam = sympify('f(x)')
f(x)
>>> x = Symbol('x')
>>> eggs = Function('f')(x)
f(x)
>>> spam == eggs
True
However, it’s a point of contention whether this should be done at all.
So there you have it. SymPy’s parser.
comments powered by Disqus


This is a test.
Annotation:3 "This" sofa: _InitialView begin: 0 end: 4
DocumentAnnotation:2 "This is a ..." sofa: _InitialView begin: 0 end: 15 language: "x-unspecified"


Methods
-
<static> closure(action, paramList, context, settings) → {function}
-
Create function that executes specified function with given parameters and context and returns result of call.
Parameters:
Name Type Argument Description action
function Target function that will be executed when created function is called.
paramList
Array <optional>
Array-like object representing parameters that should be passed into the target function specified in
action
argument.context
Object <optional>
Object that will be used as
this
value when calling the target function specified inaction
argument. Default value isnull
.settings
Object <optional>
Operation settings. Keys are settings names, values are corresponding settings values. The following settings are supported:
ignoreArgs
:Boolean
- Whether arguments passed into the created function should be ignored. Default value isfalse
and means that arguments will be included in parameters list for the target function depending of the value ofprependArgs
setting.prependArgs
:Boolean
- Whether arguments passed into the created function should be passed into the target function before parameters specified inparamList
argument. Default value isfalse
and means that parameters list for the target function will contain values fromparamList
argument followed by arguments passed into the created function (this is similar toFunction.prototype.bind
behavior).
Returns:
Created function.
- Type
- function
-
<static> createDelegateMethod(delegate, sMethod, settings) → {function}
-
Create function that executes specified method of the given object.
Parameters:
Name Type Argument Description delegate
Object Object whose method will be executed when created function is called.
sMethod
String Name of method that will be executed.
settings
Object <optional>
Operation settings. Keys are settings names, values are corresponding settings values. The following settings are supported:
destination
:Object
- target object into which the method will be added that should be used to access the created functiondestinationMethod
:String
- name of method of the target object that will be used to access the created function; the value ofsMethod
parameter by default
Returns:
Created function.
- Type
- function
-
<static> createFunction(sCode, settings) → {function}
-
Create function to further use.
Parameters:
Name Type Argument Description sCode
String Function's code.
settings
Object <optional>
Operation settings. Keys are settings names, values are corresponding settings values. The following settings are supported (setting's default value is specified in parentheses):
debug
:Boolean
(false
) - specifies whether simple means for debugging should be added into function; whentrue
value is specified (debug mode), the function's code is enclosed intry
statement; the correspondingcatch
block containsconsole.log
statement to display message (namely, value ofdebugMessage
setting) and details about errordebugFunc
:String
(console.log
) - expression specifying a function that should be used to process error when the error is caught in debug mode; the expression should be resolvable in global scope; debug message (value ofdebugMessage
setting) and error object will be passed into the functiondebugMessage
:String
(Error in created function:
) - specifies message that should be shown/passed before data about error when the error is caught in debug modeexpression
:Boolean
(false
) - specifies whether function's code is an expression; whentrue
value is specified,return
statement is added at the beginning of function's codeparamNames
:String
(''
) - specifies names of function parametersscope
:Boolean
(false
) - specifies whether function's code should be wrapped inwith
statement; the value of function's first parameter is used as expression forwith
statement
Returns:
Created function.
- Type
- function
-
<static> evalWith(sExpression, context, scope) → {Any}
-
Calculate/evaluate value of specified expression using given context and scope.
Parameters:
Name Type Argument Description sExpression
String Expression whose value should be calculated.
context
Object <optional>
Object that should be used as context (
this
) when expression is evaluated.scope
Object <optional>
Object that should be used as scope when expression is evaluated.
- Source:
- See:
Returns:
Result of expression evaluation.
- Type
- Any
-
<static> map(funcList, paramList, context, settings) → {Array}
-
Call each function from specified list and return array containing results of calls.
Parameters:
Name Type Argument Description funcList
Array Target functions that should be called.
paramList
Array | function <optional>
Parameters that should be passed into each target function. If function is specified it should return array that will be used as parameters for target functions. The following parameters will be passed into the function:
- a target function for which parameters list should be returned
- index of the target function
- array of all target functions
context
Object | function <optional>
Object that will be used as
this
value when calling each target function. Default value isnull
. If function is specified it should return object that will be used asthis
value. Parameters of the function are equal to parameters ofparamList
function (see above).settings
Object <optional>
Operation settings. Keys are settings names, values are corresponding settings values. The following settings are supported:
funcContext
:Boolean
- Whether function that is specified ascontext
parameter should be used directly asthis
value. Default value isfalse
.
Returns:
Results of functions calling.
- Type
- Array


| Constructor and Description |
|---|
QueryScorer
(
Query
query)
|
QueryScorer
(
Query
query,
IndexReader
reader,
String
field)
|
QueryScorer
(
Query
query,
IndexReader
reader,
String
field,
String
defaultField)
|
QueryScorer
(
Query
query,
String
field)
|
QueryScorer
(
Query
query,
String
field,
String
defaultField)
|
QueryScorer
(
WeightedSpanTerm
[] weightedTerms)
|
| Modifier and Type | Method and Description |
|---|---|
float
|
getFragmentScore
()
Called when the
Highlighter
has no more tokens for the current fragment -
the Scorer returns the weighting it has derived for the most recent
fragment, typically based on the results of
Scorer.getTokenScore()
.
|
float
|
getMaxTermWeight
()
|
float
|
getTokenScore
()
Called for each token in the current fragment.
|
WeightedSpanTerm
|
getWeightedSpanTerm
(
String
token)
Retrieve the
WeightedSpanTerm
for the specified token.
|
TokenStream
|
init
(
TokenStream
tokenStream)
Called to init the Scorer with a
TokenStream
.
|
boolean
|
isExpandMultiTermQuery
()
|
protected
WeightedSpanTermExtractor
|
newTermExtractor
(
String
defaultField)
|
void
|
setExpandMultiTermQuery
(boolean expandMultiTermQuery)
Controls whether or not multi-term queries are expanded
against a
MemoryIndex
IndexReader
.
|
void
|
setMaxDocCharsToAnalyze
(int maxDocCharsToAnalyze)
|
void
|
setWrapIfNotCachingTokenFilter
(boolean wrap)
By default,
TokenStream
s that are not of the type
CachingTokenFilter
are wrapped in a
CachingTokenFilter
to
ensure an efficient reset - if you are already using a different caching
TokenStream
impl and you don't want it to be wrapped, set this to
false.
|
void
|
startFragment
(
TextFragment
newFragment)
Called when a new fragment is started for consideration.
|
public QueryScorer( Query query)
query
- Query to use for highlighting
public QueryScorer( Query query, String field)
query
- Query to use for highlighting
field
- Field to highlight - pass null to ignore fields
public QueryScorer( Query query, IndexReader reader, String field)
query
- Query to use for highlighting
field
- Field to highlight - pass null to ignore fields
reader
-
IndexReader
to use for quasi tf/idf scoring
public QueryScorer( Query query, IndexReader reader, String field, String defaultField)
query
- to use for highlighting
reader
-
IndexReader
to use for quasi tf/idf scoring
field
- to highlight - pass null to ignore fields
defaultField
-
public QueryScorer( Query query, String field, String defaultField)
defaultField
- - The default field for queries with the field name unspecified
public QueryScorer( WeightedSpanTerm [] weightedTerms)
weightedTerms
- an array of pre-created
WeightedSpanTerm
s
public float getFragmentScore()
Scorer
Highlighter
has no more tokens for the current fragment -
the Scorer returns the weighting it has derived for the most recent
fragment, typically based on the results of
Scorer.getTokenScore()
.
getFragmentScore
in interface
Scorer
public float getMaxTermWeight()
public float getTokenScore()
Scorer
Highlighter
will
increment the
TokenStream
passed to init on every call.
getTokenScore
in interface
Scorer
Highlighter
class to influence the
mark-up of the text (this return value is NOT used to score the
fragment)
public TokenStream init( TokenStream tokenStream) throws IOException
Scorer
TokenStream
. You can grab references to
the attributes you are interested in here and access them from
Scorer.getTokenScore()
.
init
in interface
Scorer
tokenStream
- the
TokenStream
that will be scored.
TokenStream
that the Highlighter should continue using (eg
if you read the tokenSream in this method) or null to continue
using the same
TokenStream
that was passed in.
IOException
public WeightedSpanTerm getWeightedSpanTerm( String token)
WeightedSpanTerm
for the specified token. Useful for passing
Span information to a
Fragmenter
.
token
- to get
WeightedSpanTerm
for
protected WeightedSpanTermExtractor newTermExtractor( String defaultField)
public void startFragment( TextFragment newFragment)
Scorer
startFragment
in interface
Scorer
newFragment
- the fragment that will be scored next
public boolean isExpandMultiTermQuery()
public void setExpandMultiTermQuery(boolean expandMultiTermQuery)
MemoryIndex
IndexReader
.
expandMultiTermQuery
- true if multi-term queries should be expanded
public void setWrapIfNotCachingTokenFilter(boolean wrap)
TokenStream
s that are not of the type
CachingTokenFilter
are wrapped in a
CachingTokenFilter
to
ensure an efficient reset - if you are already using a different caching
TokenStream
impl and you don't want it to be wrapped, set this to
false.
wrap
-
public void setMaxDocCharsToAnalyze(int maxDocCharsToAnalyze)


{% load static %}
Almost 90% of the working capital of a business is invested in inventories. The management should do proper planning on how to purchase, handle, store, and account with an inventory management system. The main aim of an inventory management system is to keep the stock in such a way that it is neither overstock nor understock.
Inventory Management is a process of ordering, storing, and using inventories. This stock management includes generating the lead on raw materials, components, and finished products, along-side warehousing and processing of such items in your company.
We provides the best environment to our user to deal with the management of the stock.We let them know the status of every item.We provide every operations on the stock by which user can manage it very well.
We consults with the user and ask about the sevice which we are providing.And taaking every meaningful feedback from them and improvise ourselves more efficient.
Developer
Developer of this management website
Contact
Email<EMAIL_ADDRESS>Mobile :<PHONE_NUMBER>
Developer
Developer of this management website
Contact
Email<EMAIL_ADDRESS>Mobile :<PHONE_NUMBER>


Functions for the mass-univariate voxelwise analysis of medical imaging data that follows the NIfTI <http://nifti.nimh.nih.gov> format.
| Version: | 1.3.5 |
| Depends: | R (≥ 3.2.3), lmerTest (≥ 3.0-1) |
| Imports: | parallel, stats, mgcv, gamm4, oro.nifti, ggplot2, methods, purrr |
| Published: | 2018-06-26 |
| Author: | Angel Garcia de la Garza [aut, cre], Simon Vandekar [aut], David Roalf [aut], Kosha Ruparel [aut], Ruben Gur [aut], Raquel Gur [aut], Theodore Satterthwaite [aut], R. Taki Shinohara [aut] |
| Maintainer: | Angel Garcia de la Garza <agarciadlg at gmail.com> |
| License: | GPL-2 |
| URL: | https://github.com/angelgar/voxel |
| NeedsCompilation: | no |
| Materials: | NEWS |
| CRAN checks: | voxel results |
| Reference manual: | voxel.pdf |
| Package source: | voxel_1.3.5.tar.gz |
| Windows binaries: | r-devel: voxel_1.3.5.zip, r-release: voxel_1.3.5.zip, r-oldrel: voxel_1.3.5.zip |
| OS X binaries: | r-release: voxel_1.3.5.tgz, r-oldrel: voxel_1.3.5.tgz |
| Old sources: | voxel archive |
Please use the canonical form https://CRAN.R-project.org/package=voxel to link to this page.


Leafs fan, 11, gets massive Twitter response to disappointing birthday
None of Kade Foster’s friends showed up to his birthday, his dad said
by The Canadian PressSome high-profile athletes are rallying around a young Toronto Maple Leafs fan after the boy’s dad tweeted that the 11-year-old had a disappointing birthday.
Leafs forwards Mitch Marner and John Tavares are among those sending birthday wishes to Kade Foster in response to a viral tweet from his father, Jason Foster of Corner Brook, N.L.
Foster wrote that none of Kade’s friends showed up to the Saturday night party.
“That hurt. I’m asking my Twitter friends to show him some love today. If you have a minute, please send him a birthday wish,” he wrote, tagging Marner and Tavares.
A photo linked to the tweet shows Kade in a Maple Leafs T-shirt, a Leafs birthday cake in front of him.
“Wanted to wish my friend Kade a Happy 11th Birthday! Your friends from the Maple Leafs have a surprise gift coming your way!” Marner tweeted in response.
Tavares added that he was “looking forward to celebrating” with Kade.
By Sunday evening, Foster’s post had been shared more than 10,000 times and garnered at least 25,000 responses, including messages from Prime Minister Justin Trudeau and actor Ben Stiller — who specified that he doesn’t play hockey.
Lance McCullers Jr., a pitcher for the Houston Astros, also sent birthday wishes to Kade and offered to meet up with him in Toronto after the team plays there in May — but only if Kade wants.
Foster tweeted his thanks several hours after his initial message went out.
“We can’t comprehend what has happened today. Kade and the rest of us are just amazed,” he wrote. “To everyone who sent Kade a message — thank you from the bottom of our hearts.”
The Canadian Press


| Fig 1 |
Sampling sites, sample sizes, and concatenated COI and CytB ... |
| Fig 2 |
Minimum-spanning haplotype network for concatenated COI and ... |
| Fig 3 |
Gene (A), nucleotide (B), and allelic (C) diversity for popu ... |
| Fig 4 |
Estimates of G st analog 95% confidence intervals from SMOGD ... |


place marker on floor. open iOS app and scan with device.
look up with device. walk through the door. tap shoes to interact.
open booklet.
place shoe
marker (top left)
on a table.
open iOS app
and scan
with device.
place store display
marker (top right)
on the floor.
a store
model will pop-up.
you will be able to
walk around the
inside of the store.
stick/tape the window marker (bottom)
on wall.
scan the marker to view animation.
place the WebAR marker on a wall or similar surface (do not place on a table). navigate to URLs (index.html must be included in url). scan the entire poster into the given scan area. allow access to your camera.


Science and its applications
"My Name is zahra rostami " I'm Student of Hakim Sabzevari University in Computer Sceince ,My main research interests is Data Mining and Programming


This command, which is available beginning with GrADS version 2.1, is used to create a new pattern fill. Patterns are defined in the form of "tiles" which are small images that are used repeatedly to fill an area. GrADS supports the automatic generation of tiles for drawing certain simple patterns. More complex patterns can be acheived by providing a custom image file.
set tile number type <width <height <lwid <fgcolor <bgcolor>>>>>
(for automatic generation of basic tile patters)
... or ...
set tile number 0 filename
(for user-supplied file containing the custom tile image)
where:
number
is the tile number; it can range from 0 to 2047.
type
is the tile type, valid values and what they mean are shown below.
width
is the width of the generated tile in pixels (default is 9).
height
is the height of the generated tile in pixels (default is 9).
lwid
is the line thickness used to draw the lines in the tile. lwid
must be an integer between 1 and 12 (default is 3).
fgcolor
is the color used to draw the lines or dots in the tile (default is opaque white).
bgcolor
is the color used to fill the background of the tile (default is fully transparent).
filename
the full name of the .png file (including the path) to be used as a custom tile for creating the patern.
Valid options for the tile type
are as follows:
0 -
tile image is provided with specified filename
1 -
solid
2 -
dots
3 -
diagonal downward lines
4 -
diagonal upward lines
5 -
diagonal cross hatching
6 -
vertical lines
7 -
horizontal lines
8 -
rectangular cross hatching
Once you have defined a new tile, create the pattern fill by assigning the defined tile number to a color using the set rgb
command. The special syntax is:
set rgb nn tile tt
where:
nn
is the color number (must be between 16 and 2047)
tt
is the defined tile number
For the automatically generated tiles, GrADS creates a small image on the fly using the specified width and height. This tile image is filled with the foreground color (if the type
is 1), or it is filled with the background color and then the dots or lines are drawn on top using the foreground color and the specified line thickness. Note that the lines are drawn from corner to corner (for diagonal lines) or through the middle of the image (for dots and horizontal or vertical lines). Thus the size of the image, as controlled by the width and height settings, will determine the spacing of the dots or lines in the pattern, and the aspect ratio of the image will control the angle of the lines. A smaller image will result in more closely spaced lines in the pattern, and a larger image will result in a more widely spaced pattern.
The fully described pattern fill will be a combination of the "set tile" command and "set rgb" commands. You may use the 16 pre-defined colors in the tiles or any newly defined color. The only restriction is that a color number that has a tile assigned to it may not be used as a foreground or background color for another tile. New colors and tiles may be defined in any order, but they should be set before any drawing is done. Changing color or tile values mid-stream in a plot may result in inconsistent behavior.
The table of small images below shows what some basic automatically generated tiles can look like.
Each colum has a different type
number, from 1-8. Each row has a different foreground color and different values for the width
and height
, which are written to the left of each row. The value for
lwid
is 1 for all tiles.
This image illustrates how you can use a stippled pattern fill as an overlay on a shaded plot. Script sample to generate the plot is provided below.
* set up a grey scale color sequence with 'set rbcols' * define 2 colors * define 2 patterns * draw the height field with the gray shades * overlay stippled red/blue shading of v greater than 5 and less than -5
i = 60
n = 60
cmd = 'set rbcols'
while (i<256)
'set rgb 'n' 'i' 'i' 'i
cmd = cmd%' '%n
i = i + 15
n = n + 1
endwhile
cmd
'set rgb 20 255 0 0'
'set rgb 21 0 0 255'
'set tile 0 2 6 6 3 20'
'set tile 1 2 6 6 3 21'
'set rgb 22 tile 0'
'set rgb 23 tile 1'
'set gxout shaded'
'set lev 200'
'd z'
'set clevs 5'
'set ccols -1 22'
'd v'
'set clevs -5'
'set ccols 23 -1'
'd v'


At the Mozilla/Berkeley meeting on 2/10, an important concern was how to use our FTL synthesizer for difficult features of CSS such as tables, floats, and text. As promised, this document shows how we generated code for the core of automatic table layoutHTML4 Tables. We were able to automatically generate parallel code and, by the same reasoning, see no obstacle for generating incremental code. We did have to slightly modify our runtime library and have been planning a language extension to automate this modification.
I picked two features from the CSS standard to implement. On the left, you can see them computed live by a JavaScript engine we generated, and on the right, by the browser's native layout engine:
In total, we only edited the specification (see above) and the runtime. Our runtime edits were to use a breadth-first traversal for traversing a table and, to lookup the children of a column, search table rows for cells with the corresponding column number attribute. We did not have to add table-specific code into the synthesizer (the offline scheduling analysis) nor the code generator. Furthermore, we are extending the specification language to better handle the patterns we encountered, which would simplify the specification and eliminate some if not all of the runtime modifications.
The rest of this document overviews our implementation in HTML5, one of our ideas for an FTL extension for an even cleaner specification, and shows our code.
Unsurprisingly, our specification traverses the cells in top-down, left-to-right order. For each row, it computes what columns its cells are placed in as a function of the list of columns that are still occuppied by preceding cells. It likewise computes what cells overflow the current row: the process repeats with the next row examining this result. Our specification of this behavior is interesting in that it is just calls to functional list manipulation methods written in our host language (C++/JavaScript):
//Specification in an idealized syntax class TableBox { rows[-1].colAssignment := emptyColumnList(colCount); rows[i >= 0].colAssignment := columnsAppendRow( rows[i - 1].colAssignment, rows[i].cells, rows[i].rowNum);
//Equivalent specification in FTL's current surface syntax class TableBox (shrinkToFitHeightWidth, strokeBox) : Node { loop rows { rows.colAssignment := fold emptyColumnList(colCount) .. columnsAppendRow( rows$-.colAssignment, rows$i.cells, rows$i.rowNum);
The specification on the left uses a slightly cleaner syntax than our FTL prototype (shown on the right), but the important part is the calls to functions emptyColumnList() and columnsAppendRow(). As long as emptyColumnList() and columnsAppendRow() implement a functionally pure interface, attribute grammar techniques for automatic parallelization and incrementalization still apply. For example, instead of a destructive append that mutates a list, we use a functional append. If a script adds a cell to row 3, incremental evaluation could therefore safely reuse rows[2].colAssignment to recompute rows[3].colAssignment without first recomputing rows[-1,0,1].colAssignment.
The grid is stored in an attribute, so we simply propagated the grid to all the table nodes as an attribute (cellsready). We were then able to declare the dependency on cellsready to the column computations:
//Specification in an idealized syntax Schedule { Col.childs[i].relX <- Col.cellsready Col.childs[i].absX <- Col.cellsready
//Equivalent specification in FTL's current surface syntax schedule { asserta(assignment(col, self, childs_relx_step, self, cellsready)), asserta(assignment(col, self, childs_absx_step, self, cellsready)),
The synthesizer now knows to schedule relX and absX computations only after the grid cellsready is computed.
<table> <tr> //row <td/> //cell </tr> <col/> </table>An important invariant of a top down traversal is that a node's parent is visited before the node itself. A valid implementation for trees is depth first. However, consider a depth first traversal of a table's parse tree (see box on the right). It would visit the table, the row, the cell, and then the column. The cell is visited before its column!
Our modification was simple: we edited the runtime to visit the nodes of a table with a breadth first traversal. We kept the overall document traversal as depth first for performance reasons.
We chose not to modify the synthesizer, so it still assumes a table is a tree. To pass unambiguity and conflict checks, we extended the specification to tell the synthesizer that external code defines certain attributes:
class Col { phantom { childs.relY; childs.absY;
class Row { phantom { childs.relX; childs.absX;
The synthesizer can now assume that the external code provides definitions for a column's childs.relY and childs.absY and a row's childs.relX and childs.absX. Unimportant to the synthesizer, the definitions just happen to come from elsewhere in the same specification, such as class Row defining the phantom attributes not set by Column. If we wanted to further verify our specification, we could further specify that the assignments of a row and a column to a cell are disjoint sets that, together, hold the assignments needed for a cell, but this is unnecessary for code generation.
For example, a column should be able to alias its cells:
class Col { children { cells : [ CellI ] = ../rows/childs[.column == self.colNum]; ... cells[i].relX := ...
This specification provides two important pieces of information. First, the synthesizer now knows that any computation over a column's cells depends on first being able to compute the result of the selector, which in turn requires having already computed cell attribute column and column attribute colNum. Second, the localized DAG structure of tables is exposed, so the code generator now knows to use a breadth-first traversal to topologically evaluate any table/rows/columns/cells region of a document.
Most nodes are by default shrink-to-fit and all can have their size overriden by an XML attribute:
Other attributes are set as attributes directly in the XML:
asdf
It is fairly naive for the HTML5 backend. Of note:


phonegap symbian.wrt
Geolocation
latitude:
finding satellites
longitude:
finding satellites
altitude:
finding satellites
heading:
finding satellites
speed:
finding satellites
Accelerometer
X-Accel:
Y-Accel:
Z-Accel:
Contacts
Notification (vibrate)
SMS
Send SMS
Camera
Take picture
Orientation
Current orientation:
-
Storage
Store this
Clear this


Beautiful Soup Documentation — Beautiful Soup 4.4.0 documentation var DOCUMENTATION_OPTIONS = { URL_ROOT: './', VERSION: '4.4.0', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; Navigation index Beautiful Soup 4.4.0 documentation » Beautiful Soup Documentation¶ Beautiful Soup is a Python library for pulling data out of HTML and XML files. It works with your favorite parser to provide idiomatic ways of navigating, searching, and modifying the parse tree. It commonly saves programmers hours or days of work. These instructions illustrate all major features of Beautiful Soup 4, with examples. I show you what the library is good for, how it works, how to use it, how to make it do what you want, and what to do when it violates your expectations. The examples in this documentation should work the same way in Python 2.7 and Python 3.2. You might be looking for the documentation for Beautiful Soup 3. If so, you should know that Beautiful Soup 3 is no longer being developed, and that Beautiful Soup 4 is recommended for all new projects. If you want to learn about the differences between Beautiful Soup 3 and Beautiful Soup 4, see Porting code to BS4. This documentation has been translated into other languages by Beautiful Soup users: 这篇文档当然还有中文版. このページは日本語で利用できます(外部リンク) 이 문서는 한국어 번역도 가능합니다. (외부 링크) Getting help¶ If you have questions about Beautiful Soup, or run into problems, send mail to the discussion group. If your problem involves parsing an HTML document, be sure to mention what the diagnose() function says about that document. Quick Start¶ Here’s an HTML document I’ll be using as an example throughout this document. It’s part of a story from Alice in Wonderland: html_doc = """
The Dormouse's story
Once upon a time there were three little sisters; and their names were Elsie, Lacie and Tillie; and they lived at the bottom of a well.
...
""" Running the “three sisters” document through Beautiful Soup gives us a BeautifulSoup object, which represents the document as a nested data structure: from bs4 import BeautifulSoup soup = BeautifulSoup(html_doc, 'html.parser') print(soup.prettify()) # # ## # The Dormouse's story # #
## Once upon a time there were three little sisters; and their names were # # Elsie # # , # # Lacie # # and # # Tillie # # ; and they lived at the bottom of a well. #
## ... #
# # Here are some simple ways to navigate that data structure: soup.title #The Dormouse's story
soup.p['class'] # u'title' soup.a # Elsie soup.find_all('a') # [Elsie, # Lacie, # Tillie] soup.find(id="link3") # Tillie One common task is extracting all the URLs found within a page’s tags: for link in soup.find_all('a'): print(link.get('href')) # http://example.com/elsie # http://example.com/lacie # http://example.com/tillie Another common task is extracting all the text from a page: print(soup.get_text()) # The Dormouse's story # # The Dormouse's story # # Once upon a time there were three little sisters; and their names were # Elsie, # Lacie and # Tillie; # and they lived at the bottom of a well. # # ... Does this look like what you need? If so, read on. Installing Beautiful Soup¶ If you’re using a recent version of Debian or Ubuntu Linux, you can install Beautiful Soup with the system package manager: $ apt-get install python-bs4 (for Python 2) $ apt-get install python3-bs4 (for Python 3) Beautiful Soup 4 is published through PyPi, so if you can’t install it with the system packager, you can install it with easy_install or pip. The package name is beautifulsoup4, and the same package works on Python 2 and Python 3. Make sure you use the right version of pip or easy_install for your Python version (these may be named pip3 and easy_install3 respectively if you’re using Python 3). $ easy_install beautifulsoup4 $ pip install beautifulsoup4 (The BeautifulSoup package is probably not what you want. That’s the previous major release, Beautiful Soup 3. Lots of software uses BS3, so it’s still available, but if you’re writing new code you should install beautifulsoup4.) If you don’t have easy_install or pip installed, you can download the Beautiful Soup 4 source tarball and install it with setup.py. $ python setup.py install If all else fails, the license for Beautiful Soup allows you to package the entire library with your application. You can download the tarball, copy its bs4 directory into your application’s codebase, and use Beautiful Soup without installing it at all. I use Python 2.7 and Python 3.2 to develop Beautiful Soup, but it should work with other recent versions. Problems after installation¶ Beautiful Soup is packaged as Python 2 code. When you install it for use with Python 3, it’s automatically converted to Python 3 code. If you don’t install the package, the code won’t be converted. There have also been reports on Windows machines of the wrong version being installed. If you get the ImportError “No module named HTMLParser”, your problem is that you’re running the Python 2 version of the code under Python 3. If you get the ImportError “No module named html.parser”, your problem is that you’re running the Python 3 version of the code under Python 2. In both cases, your best bet is to completely remove the Beautiful Soup installation from your system (including any directory created when you unzipped the tarball) and try the installation again. If you get the SyntaxError “Invalid syntax” on the line ROOT_TAG_NAME = u'[document]', you need to convert the Python 2 code to Python 3. You can do this either by installing the package: $ python3 setup.py install or by manually running Python’s 2to3 conversion script on the bs4 directory: $ 2to3-3.2 -w bs4 Installing a parser¶ Beautiful Soup supports the HTML parser included in Python’s standard library, but it also supports a number of third-party Python parsers. One is the lxml parser. Depending on your setup, you might install lxml with one of these commands: $ apt-get install python-lxml $ easy_install lxml $ pip install lxml Another alternative is the pure-Python html5lib parser, which parses HTML the way a web browser does. Depending on your setup, you might install html5lib with one of these commands: $ apt-get install python-html5lib $ easy_install html5lib $ pip install html5lib This table summarizes the advantages and disadvantages of each parser library: Parser Typical usage Advantages Disadvantages Python’s html.parser BeautifulSoup(markup, "html.parser") Batteries included Decent speed Lenient (as of Python 2.7.3 and 3.2.) Not very lenient (before Python 2.7.3 or 3.2.2) lxml’s HTML parser BeautifulSoup(markup, "lxml") Very fast Lenient External C dependency lxml’s XML parser BeautifulSoup(markup, "lxml-xml") BeautifulSoup(markup, "xml") Very fast The only currently supported XML parser External C dependency html5lib BeautifulSoup(markup, "html5lib") Extremely lenient Parses pages the same way a web browser does Creates valid HTML5 Very slow External Python dependency If you can, I recommend you install and use lxml for speed. If you’re using a version of Python 2 earlier than 2.7.3, or a version of Python 3 earlier than 3.2.2, it’s essential that you install lxml or html5lib–Python’s built-in HTML parser is just not very good in older versions. Note that if a document is invalid, different parsers will generate different Beautiful Soup trees for it. See Differences between parsers for details. Making the soup¶ To parse a document, pass it into the BeautifulSoup constructor. You can pass in a string or an open filehandle: from bs4 import BeautifulSoup with open("index.html") as fp: soup = BeautifulSoup(fp) soup = BeautifulSoup("data") First, the document is converted to Unicode, and HTML entities are converted to Unicode characters: BeautifulSoup("Sacré bleu!") Sacré bleu! Beautiful Soup then parses the document using the best available parser. It will use an HTML parser unless you specifically tell it to use an XML parser. (See Parsing XML.) Kinds of objects¶ Beautiful Soup transforms a complex HTML document into a complex tree of Python objects. But you’ll only ever have to deal with about four kinds of objects: Tag, NavigableString, BeautifulSoup, and Comment. Tag¶ A Tag object corresponds to an XML or HTML tag in the original document: soup = BeautifulSoup('Extremely bold') tag = soup.b type(tag) #Extremely boldAttributes¶ A tag may have any number of attributes. The tag has an attribute “id” whose value is “boldest”. You can access a tag’s attributes by treating the tag like a dictionary: tag['id'] # u'boldest' You can access that dictionary directly as .attrs: tag.attrs # {u'id': 'boldest'} You can add, remove, and modify a tag’s attributes. Again, this is done by treating the tag as a dictionary: tag['id'] = 'verybold' tag['another-attribute'] = 1 tag # del tag['id'] del tag['another-attribute'] tag # tag['id'] # KeyError: 'id' print(tag.get('id')) # None Multi-valued attributes¶ HTML 4 defines a few attributes that can have multiple values. HTML 5 removes a couple of them, but defines a few more. The most common multi-valued attribute is class (that is, a tag can have more than one CSS class). Others include rel, rev, accept-charset, headers, and accesskey. Beautiful Soup presents the value(s) of a multi-valued attribute as a list: css_soup = BeautifulSoup('') css_soup.p['class'] # ["body"] css_soup = BeautifulSoup('') css_soup.p['class'] # ["body", "strikeout"] If an attribute looks like it has more than one value, but it’s not a multi-valued attribute as defined by any version of the HTML standard, Beautiful Soup will leave the attribute alone: id_soup = BeautifulSoup('') id_soup.p['id'] # 'my id' When you turn a tag back into a string, multiple attribute values are consolidated: rel_soup = BeautifulSoup('
Back to the homepage
') rel_soup.a['rel'] # ['index'] rel_soup.a['rel'] = ['index', 'contents'] print(rel_soup.p) #Back to the homepage
You can use `get_attribute_list to get a value that’s always a list, string, whether or not it’s a multi-valued atribute id_soup.p.get_attribute_list(‘id’) # [“my id”] If you parse a document as XML, there are no multi-valued attributes: xml_soup = BeautifulSoup('', 'xml') xml_soup.p['class'] # u'body strikeout' NavigableString¶ A string corresponds to a bit of text within a tag. Beautiful Soup uses the NavigableString class to contain these bits of text: tag.string # u'Extremely bold' type(tag.string) #No longer boldNavigableString supports most of the features described in Navigating the tree and Searching the tree, but not all of them. In particular, since a string can’t contain anything (the way a tag may contain a string or another tag), strings don’t support the .contents or .string attributes, or the find() method. If you want to use a NavigableString outside of Beautiful Soup, you should call unicode() on it to turn it into a normal Python Unicode string. If you don’t, your string will carry around a reference to the entire Beautiful Soup parse tree, even when you’re done using Beautiful Soup. This is a big waste of memory. BeautifulSoup¶ The BeautifulSoup object itself represents the document as a whole. For most purposes, you can treat it as a Tag object. This means it supports most of the methods described in Navigating the tree and Searching the tree. Since the BeautifulSoup object doesn’t correspond to an actual HTML or XML tag, it has no name and no attributes. But sometimes it’s useful to look at its .name, so it’s been given the special .name “[document]”: soup.name # u'[document]' Comments and other special strings¶ Tag, NavigableString, and BeautifulSoup cover almost everything you’ll see in an HTML or XML file, but there are a few leftover bits. The only one you’ll probably ever need to worry about is the comment: markup = "" soup = BeautifulSoup(markup) comment = soup.b.string type(comment) #
The Dormouse's story
Once upon a time there were three little sisters; and their names were Elsie, Lacie and Tillie; and they lived at the bottom of a well.
...
""" from bs4 import BeautifulSoup soup = BeautifulSoup(html_doc, 'html.parser') I’ll use this as an example to show you how to move from one part of a document to another. Going down¶ Tags may contain strings and other tags. These elements are the tag’s children. Beautiful Soup provides a lot of different attributes for navigating and iterating over a tag’s children. Note that Beautiful Soup strings don’t support any of these attributes, because a string can’t have children. Navigating using tag names¶ The simplest way to navigate the parse tree is to say the name of the tag you want. If you want the tag, just say soup.head: soup.head #The Dormouse's story
An HTML parser takes this string of characters and turns it into a series of events: “open an tag”, “open a tag”, “open atag”, and so on. Beautiful Soup offers tools for reconstructing the initial parse of the document. .next_element and .previous_element¶ The .next_element attribute of a string or tag points to whatever was parsed immediately afterwards. It might be the same as .next_sibling, but it’s usually drastically different. Here’s the final tag in the “three sisters” document. Its .next_sibling is a string: the conclusion of the sentence that was interrupted by the start of the tag.: last_a_tag = soup.find("a", id="link3") last_a_tag # Tillie last_a_tag.next_sibling # '; and they lived at the bottom of a well.' But the .next_element of that tag, the thing that was parsed immediately after the tag, is not the rest of that sentence: it’s the word “Tillie”: last_a_tag.next_element # u'Tillie' That’s because in the original markup, the word “Tillie” appeared before that semicolon. The parser encountered an tag, then the word “Tillie”, then the closing tag, then the semicolon and rest of the sentence. The semicolon is on the same level as the tag, but the word “Tillie” was encountered first. The .previous_element attribute is the exact opposite of .next_element. It points to whatever element was parsed immediately before this one: last_a_tag.previous_element # u' and\n' last_a_tag.previous_element.next_element # Tillie .next_elements and .previous_elements¶ You should get the idea by now. You can use these iterators to move forward or backward in the document as it was parsed: for element in last_a_tag.next_elements: print(repr(element)) # u'Tillie' # u';\nand they lived at the bottom of a well.' # u'\n\n' #
...
# u'...' # u'\n' # None Searching the tree¶ Beautiful Soup defines a lot of methods for searching the parse tree, but they’re all very similar. I’m going to spend a lot of time explaining the two most popular methods: find() and find_all(). The other methods take almost exactly the same arguments, so I’ll just cover them briefly. Once again, I’ll be using the “three sisters” document as an example: html_doc = """The Dormouse's story
Once upon a time there were three little sisters; and their names were Elsie, Lacie and Tillie; and they lived at the bottom of a well.
...
""" from bs4 import BeautifulSoup soup = BeautifulSoup(html_doc, 'html.parser') By passing in a filter to an argument like find_all(), you can zoom in on the parts of the document you’re interested in. Kinds of filters¶ Before talking in detail about find_all() and similar methods, I want to show examples of different filters you can pass into these methods. These filters show up again and again, throughout the search API. You can use them to filter based on a tag’s name, on its attributes, on the text of a string, or on some combination of these. A string¶ The simplest filter is a string. Pass a string to a search method and Beautiful Soup will perform a match against that exact string. This code finds all the tags in the document: soup.find_all('b') # [The Dormouse's story] If you pass in a byte string, Beautiful Soup will assume the string is encoded as UTF-8. You can avoid this by passing in a Unicode string instead. A regular expression¶ If you pass in a regular expression object, Beautiful Soup will filter against that regular expression using its search() method. This code finds all the tags whose names start with the letter “b”; in this case, the tag and the tag: import re for tag in soup.find_all(re.compile("^b")): print(tag.name) # body # b This code finds all the tags whose names contain the letter ‘t’: for tag in soup.find_all(re.compile("t")): print(tag.name) # html # title A list¶ If you pass in a list, Beautiful Soup will allow a string match against any item in that list. This code finds all the tags and all the tags: soup.find_all(["a", "b"]) # [The Dormouse's story, # Elsie, # Lacie, # Tillie] True¶ The value True matches everything it can. This code finds all the tags in the document, but none of the text strings: for tag in soup.find_all(True): print(tag.name) # html # head # title # body # p # b # p # a # a # a # p A function¶ If none of the other matches work for you, define a function that takes an element as its only argument. The function should return True if the argument matches, and False otherwise. Here’s a function that returns True if a tag defines the “class” attribute but doesn’t define the “id” attribute: def has_class_but_no_id(tag): return tag.has_attr('class') and not tag.has_attr('id') Pass this function into find_all() and you’ll pick up all thetags: soup.find_all(has_class_but_no_id) # [
The Dormouse's story
, #Once upon a time there were...
, #...
] This function only picks up the tags. It doesn’t pick up the
tags, because those tags define both “class” and “id”. It doesn’t pick
up tags like and The Dormouse's story tag with the CSS class “title”?
Let’s look at the arguments to find_all().
The name argument¶
Pass in a value for name and you’ll tell Beautiful Soup to only
consider tags with certain names. Text strings will be ignored, as
will tags whose names that don’t match.
This is the simplest usage:
soup.find_all("title")
# [ The Dormouse's story
Once upon a time there were three little sisters; and their names were # Elsie, # Lacie and # Tillie; # and they lived at the bottom of a well.
a_string.find_parents("p", class="title") # [] One of the three tags is the direct parent of the string in question, so our search finds it. One of the threetags is an indirect parent of the string, and our search finds that as well. There’s a
tag with the CSS class “title” somewhere in the document, but it’s not one of this string’s parents, so we can’t find it with find_parents(). You may have made the connection between find_parent() and find_parents(), and the .parent and .parents attributes mentioned earlier. The connection is very strong. These search methods actually use .parents to iterate over all the parents, and check each one against the provided filter to see if it matches. find_next_siblings() and find_next_sibling()¶ Signature: find_next_siblings(name, attrs, string, limit, **kwargs) Signature: find_next_sibling(name, attrs, string, **kwargs) These methods use .next_siblings to iterate over the rest of an element’s siblings in the tree. The find_next_siblings() method returns all the siblings that match, and find_next_sibling() only returns the first one: first_link = soup.a first_link # Elsie first_link.find_next_siblings("a") # [Lacie, # Tillie] first_story_paragraph = soup.find("p", "story") first_story_paragraph.find_next_sibling("p") #
...
find_previous_siblings() and find_previous_sibling()¶ Signature: find_previous_siblings(name, attrs, string, limit, **kwargs) Signature: find_previous_sibling(name, attrs, string, **kwargs) These methods use .previous_siblings to iterate over an element’s siblings that precede it in the tree. The find_previous_siblings() method returns all the siblings that match, and find_previous_sibling() only returns the first one: last_link = soup.find("a", id="link3") last_link # Tillie last_link.find_previous_siblings("a") # [Lacie, # Elsie] first_story_paragraph = soup.find("p", "story") first_story_paragraph.find_previous_sibling("p") #The Dormouse's story
find_all_next() and find_next()¶ Signature: find_all_next(name, attrs, string, limit, **kwargs) Signature: find_next(name, attrs, string, **kwargs) These methods use .next_elements to iterate over whatever tags and strings that come after it in the document. The find_all_next() method returns all matches, and find_next() only returns the first match: first_link = soup.a first_link # Elsie first_link.find_all_next(string=True) # [u'Elsie', u',\n', u'Lacie', u' and\n', u'Tillie', # u';\nand they lived at the bottom of a well.', u'\n\n', u'...', u'\n'] first_link.find_next("p") #...
In the first example, the string “Elsie” showed up, even though it was contained within the tag we started from. In the second example, the lasttag in the document showed up, even though it’s not in the same part of the tree as the tag we started from. For these methods, all that matters is that an element match the filter, and show up later in the document than the starting element. find_all_previous() and find_previous()¶ Signature: find_all_previous(name, attrs, string, limit, **kwargs) Signature: find_previous(name, attrs, string, **kwargs) These methods use .previous_elements to iterate over the tags and strings that came before it in the document. The find_all_previous() method returns all matches, and find_previous() only returns the first match: first_link = soup.a first_link # Elsie first_link.find_all_previous("p") # [
Once upon a time there were three little sisters; ...
, #The Dormouse's story
] first_link.find_previous("title") # tag that contains the tag we started
with. This shouldn’t be too surprising: we’re looking at all the tags
that show up earlier in the document than the one we started with. A
tag that contains an tag must have shown up before the
tag it contains.
CSS selectors¶
Beautiful Soup supports the most commonly-used CSS selectors. Just
pass a string into the .select() method of a Tag object or the
BeautifulSoup object itself.
You can find tags:
soup.select("title")
# [ ...
Hello
Howdy, y'all
Pip-pip, old fruit
Bonjour mes amis
""" multilingual_soup = BeautifulSoup(multilingual_markup) multilingual_soup.select('p[lang|=en]') # [Hello
, #Howdy, y'all
, #Pip-pip, old fruit
] Find only the first tag that matches a selector: soup.select_one(".sister") # Elsie This is all a convenience for users who know the CSS selector syntax. You can do all this stuff with the Beautiful Soup API. And if CSS selectors are all you need, you might as well use lxml directly: it’s a lot faster, and it supports more CSS selectors. But this lets you combine simple CSS selectors with the Beautiful Soup API. Modifying the tree¶ Beautiful Soup’s main strength is in searching the parse tree, but you can also modify the tree and write your changes as a new HTML or XML document. Changing tag names and attributes¶ I covered this earlier, in Attributes, but it bears repeating. You can rename a tag, change the values of its attributes, add new attributes, and delete attributes: soup = BeautifulSoup('Extremely bold') tag = soup.b tag.name = "blockquote" tag['class'] = 'verybold' tag['id'] = 1 tag #Extremely bolddel tag['class'] del tag['id'] tag #
Extremely boldModifying .string¶ If you set a tag’s .string attribute, the tag’s contents are replaced with the string you give: markup = 'I linked to example.com' soup = BeautifulSoup(markup) tag = soup.a tag.string = "New link text." tag # New link text. Be careful: if the tag contained other tags, they and all their contents will be destroyed. append()¶ You can add to a tag’s contents with Tag.append(). It works just like calling .append() on a Python list: soup = BeautifulSoup("Foo") soup.a.append("Bar") soup # FooBar soup.a.contents # [u'Foo', u'Bar'] NavigableString() and .new_tag()¶ If you need to add a string to a document, no problem–you can pass a Python string in to append(), or you can call the NavigableString constructor: soup = BeautifulSoup("") tag = soup.b tag.append("Hello") new_string = NavigableString(" there") tag.append(new_string) tag # Hello there. tag.contents # [u'Hello', u' there'] If you want to create a comment or some other subclass of NavigableString, just call the constructor: from bs4 import Comment new_comment = Comment("Nice to see you.") tag.append(new_comment) tag # Hello there tag.contents # [u'Hello', u' there', u'Nice to see you.'] (This is a new feature in Beautiful Soup 4.4.0.) What if you need to create a whole new tag? The best solution is to call the factory method BeautifulSoup.new_tag(): soup = BeautifulSoup("") original_tag = soup.b new_tag = soup.new_tag("a", href="http://www.example.com") original_tag.append(new_tag) original_tag # new_tag.string = "Link text." original_tag # Link text. Only the first argument, the tag name, is required. insert()¶ Tag.insert() is just like Tag.append(), except the new element doesn’t necessarily go at the end of its parent’s .contents. It’ll be inserted at whatever numeric position you say. It works just like .insert() on a Python list: markup = 'I linked to example.com' soup = BeautifulSoup(markup) tag = soup.a tag.insert(1, "but did not endorse ") tag # I linked to but did not endorse example.com tag.contents # [u'I linked to ', u'but did not endorse', example.com] insert_before() and insert_after()¶ The insert_before() method inserts a tag or string immediately before something else in the parse tree: soup = BeautifulSoup("stop") tag = soup.new_tag("i") tag.string = "Don't" soup.b.string.insert_before(tag) soup.b # Don'tstop The insert_after() method moves a tag or string so that it immediately follows something else in the parse tree: soup.b.i.insert_after(soup.new_string(" ever ")) soup.b # Don't ever stop soup.b.contents # [Don't, u' ever ', u'stop'] clear()¶ Tag.clear() removes the contents of a tag: markup = 'I linked to example.com' soup = BeautifulSoup(markup) tag = soup.a tag.clear() tag # extract()¶ PageElement.extract() removes a tag or string from the tree. It returns the tag or string that was extracted: markup = 'I linked to example.com' soup = BeautifulSoup(markup) a_tag = soup.a i_tag = soup.i.extract() a_tag # I linked to i_tag # example.com print(i_tag.parent) None At this point you effectively have two parse trees: one rooted at the BeautifulSoup object you used to parse the document, and one rooted at the tag that was extracted. You can go on to call extract on a child of the element you extracted: my_string = i_tag.string.extract() my_string # u'example.com' print(my_string.parent) # None i_tag # decompose()¶ Tag.decompose() removes a tag from the tree, then completely destroys it and its contents: markup = 'I linked to example.com' soup = BeautifulSoup(markup) a_tag = soup.a soup.i.decompose() a_tag # I linked to replace_with()¶ PageElement.replace_with() removes a tag or string from the tree, and replaces it with the tag or string of your choice: markup = 'I linked to example.com' soup = BeautifulSoup(markup) a_tag = soup.a new_tag = soup.new_tag("b") new_tag.string = "example.net" a_tag.i.replace_with(new_tag) a_tag # I linked to example.net replace_with() returns the tag or string that was replaced, so that you can examine it or add it back to another part of the tree. wrap()¶ PageElement.wrap() wraps an element in the tag you specify. It returns the new wrapper: soup = BeautifulSoup("
I wish I was bold.
") soup.p.string.wrap(soup.new_tag("b")) # I wish I was bold. soup.p.wrap(soup.new_tag("div") #I wish I was bold.
The law firm of Dewey, Cheatem, & Howe
") soup.p #The law firm of Dewey, Cheatem, & Howe
soup = BeautifulSoup('A link') soup.a # A link You can change this behavior by providing a value for the formatter argument to prettify(), encode(), or decode(). Beautiful Soup recognizes six possible values for formatter. The default is formatter="minimal". Strings will only be processed enough to ensure that Beautiful Soup generates valid HTML/XML: french = "Il a dit <<Sacré bleu!>>
" soup = BeautifulSoup(french) print(soup.prettify(formatter="minimal")) # # ## Il a dit <<Sacré bleu!>> #
# # If you pass in formatter="html", Beautiful Soup will convert Unicode characters to HTML entities whenever possible: print(soup.prettify(formatter="html")) # # ## Il a dit <<Sacré bleu!>> #
# # If you pass in ``formatter="html5"``, it's the same as formatter="html5", but Beautiful Soup will omit the closing slash in HTML void tags like “br”: soup = BeautifulSoup("
# Il a dit <
# IL A DIT <
# IL A DIT <<SACRÉ BLEU!>> #
# # One last caveat: if you create a CData object, the text inside that object is always presented exactly as it appears, with no formatting. Beautiful Soup will call the formatter method, just in case you’ve written a custom method that counts all the strings in the document or something, but it will ignore the return value: from bs4.element import CData soup = BeautifulSoup("") soup.a.string = CData("one < three") print(soup.a.prettify(formatter="xml")) # # # get_text()¶ If you only want the text part of a document or tag, you can use the get_text() method. It returns all the text in a document or beneath a tag, as a single Unicode string: markup = '\nI linked to example.com\n' soup = BeautifulSoup(markup) soup.get_text() u'\nI linked to example.com\n' soup.i.get_text() u'example.com' You can specify a string to be used to join the bits of text together: # soup.get_text("|") u'\nI linked to |example.com|\n' You can tell Beautiful Soup to strip whitespace from the beginning and end of each bit of text: # soup.get_text("|", strip=True) u'I linked to|example.com' But at that point you might want to use the .stripped_strings generator instead, and process the text yourself: [text for text in soup.stripped_strings] # [u'I linked to', u'example.com'] Specifying the parser to use¶ If you just need to parse some HTML, you can dump the markup into the BeautifulSoup constructor, and it’ll probably be fine. Beautiful Soup will pick a parser for you and parse the data. But there are a few additional arguments you can pass in to the constructor to change which parser is used. The first argument to the BeautifulSoup constructor is a string or an open filehandle–the markup you want parsed. The second argument is how you’d like the markup parsed. If you don’t specify anything, you’ll get the best HTML parser that’s installed. Beautiful Soup ranks lxml’s parser as being the best, then html5lib’s, then Python’s built-in parser. You can override this by specifying one of the following: What type of markup you want to parse. Currently supported are “html”, “xml”, and “html5”. The name of the parser library you want to use. Currently supported options are “lxml”, “html5lib”, and “html.parser” (Python’s built-in HTML parser). The section Installing a parser contrasts the supported parsers. If you don’t have an appropriate parser installed, Beautiful Soup will ignore your request and pick a different parser. Right now, the only supported XML parser is lxml. If you don’t have lxml installed, asking for an XML parser won’t give you one, and asking for “lxml” won’t work either. Differences between parsers¶ Beautiful Soup presents the same interface to a number of different parsers, but each parser is different. Different parsers will create different parse trees from the same document. The biggest differences are between the HTML parsers and the XML parsers. Here’s a short document, parsed as HTML: BeautifulSoup("") # Since an empty tag is not valid HTML, the parser turns it into a tag pair. Here’s the same document parsed as XML (running this requires that you have lxml installed). Note that the empty tag is left alone, and that the document is given an XML declaration instead of being put into an tag.: BeautifulSoup("", "xml") # # There are also differences between HTML parsers. If you give Beautiful Soup a perfectly-formed HTML document, these differences won’t matter. One parser will be faster than another, but they’ll all give you a data structure that looks exactly like the original HTML document. But if the document is not perfectly-formed, different parsers will give different results. Here’s a short, invalid document parsed using lxml’s HTML parser. Note that the dangling tag is simply ignored: BeautifulSoup("", "lxml") # Here’s the same document parsed using html5lib: BeautifulSoup("", "html5lib") # Instead of ignoring the dangling tag, html5lib pairs it with an openingtag. This parser also adds an empty
tag to the document. Here’s the same document parsed with Python’s built-in HTML parser: BeautifulSoup("", "html.parser") # Like html5lib, this parser ignores the closing tag. Unlike html5lib, this parser makes no attempt to create a well-formed HTML document by adding a tag. Unlike lxml, it doesn’t even bother to add an tag. Since the document “” is invalid, none of these techniques is the “correct” way to handle it. The html5lib parser uses techniques that are part of the HTML5 standard, so it has the best claim on being the “correct” way, but all three techniques are legitimate. Differences between parsers can affect your script. If you’re planning on distributing your script to other people, or running it on multiple machines, you should specify a parser in the BeautifulSoup constructor. That will reduce the chances that your users parse a document differently from the way you parse it. Encodings¶ Any HTML or XML document is written in a specific encoding like ASCII or UTF-8. But when you load that document into Beautiful Soup, you’ll discover it’s been converted to Unicode: markup = "Sacr\xe9 bleu!
''' soup = BeautifulSoup(markup) print(soup.prettify()) # # # # # ## Sacré bleu! #
# # Note that the tag has been rewritten to reflect the fact that the document is now in UTF-8. If you don’t want UTF-8, you can pass an encoding into prettify(): print(soup.prettify("latin-1")) # # # # ... You can also call encode() on the BeautifulSoup object, or any element in the soup, just as if it were a Python string: soup.p.encode("latin-1") # 'Sacr\xe9 bleu!
' soup.p.encode("utf-8") # 'Sacr\xc3\xa9 bleu!
' Any characters that can’t be represented in your chosen encoding will be converted into numeric XML entity references. Here’s a document that includes the Unicode character SNOWMAN: markup = u"\N{SNOWMAN}" snowman_soup = BeautifulSoup(markup) tag = snowman_soup.b The SNOWMAN character can be part of a UTF-8 document (it looks like ☃), but there’s no representation for that character in ISO-Latin-1 or ASCII, so it’s converted into “☃” for those encodings: print(tag.encode("utf-8")) # ☃ print tag.encode("latin-1") # ☃ print tag.encode("ascii") # ☃ Unicode, Dammit¶ You can use Unicode, Dammit without using Beautiful Soup. It’s useful whenever you have data in an unknown encoding and you just want it to become Unicode: from bs4 import UnicodeDammit dammit = UnicodeDammit("Sacr\xc3\xa9 bleu!") print(dammit.unicode_markup) # Sacré bleu! dammit.original_encoding # 'utf-8' Unicode, Dammit’s guesses will get a lot more accurate if you install the chardet or cchardet Python libraries. The more data you give Unicode, Dammit, the more accurately it will guess. If you have your own suspicions as to what the encoding might be, you can pass them in as a list: dammit = UnicodeDammit("Sacr\xe9 bleu!", ["latin-1", "iso-8859-1"]) print(dammit.unicode_markup) # Sacré bleu! dammit.original_encoding # 'latin-1' Unicode, Dammit has two special features that Beautiful Soup doesn’t use. Smart quotes¶ You can use Unicode, Dammit to convert Microsoft smart quotes to HTML or XML entities: markup = b"I just \x93love\x94 Microsoft Word\x92s smart quotes
" UnicodeDammit(markup, ["windows-1252"], smart_quotes_to="html").unicode_markup # u'I just “love” Microsoft Word’s smart quotes
' UnicodeDammit(markup, ["windows-1252"], smart_quotes_to="xml").unicode_markup # u'I just “love” Microsoft Word’s smart quotes
' You can also convert Microsoft smart quotes to ASCII quotes: UnicodeDammit(markup, ["windows-1252"], smart_quotes_to="ascii").unicode_markup # u'I just "love" Microsoft Word\'s smart quotes
' Hopefully you’ll find this feature useful, but Beautiful Soup doesn’t use it. Beautiful Soup prefers the default behavior, which is to convert Microsoft smart quotes to Unicode characters along with everything else: UnicodeDammit(markup, ["windows-1252"]).unicode_markup # u'I just \u201clove\u201d Microsoft Word\u2019s smart quotes
' Inconsistent encodings¶ Sometimes a document is mostly in UTF-8, but contains Windows-1252 characters such as (again) Microsoft smart quotes. This can happen when a website includes data from multiple sources. You can use UnicodeDammit.detwingle() to turn such a document into pure UTF-8. Here’s a simple example: snowmen = (u"\N{SNOWMAN}" * 3) quote = (u"\N{LEFT DOUBLE QUOTATION MARK}I like snowmen!\N{RIGHT DOUBLE QUOTATION MARK}") doc = snowmen.encode("utf8") + quote.encode("windows_1252") This document is a mess. The snowmen are in UTF-8 and the quotes are in Windows-1252. You can display the snowmen or the quotes, but not both: print(doc) # ☃☃☃�I like snowmen!� print(doc.decode("windows-1252")) # â˜ƒâ˜ƒâ˜ƒ“I like snowmen!” Decoding the document as UTF-8 raises a UnicodeDecodeError, and decoding it as Windows-1252 gives you gibberish. Fortunately, UnicodeDammit.detwingle() will convert the string to pure UTF-8, allowing you to decode it to Unicode and display the snowmen and quote marks simultaneously: new_doc = UnicodeDammit.detwingle(doc) print(new_doc.decode("utf8")) # ☃☃☃“I like snowmen!” UnicodeDammit.detwingle() only knows how to handle Windows-1252 embedded in UTF-8 (or vice versa, I suppose), but this is the most common case. Note that you must know to call UnicodeDammit.detwingle() on your data before passing it into BeautifulSoup or the UnicodeDammit constructor. Beautiful Soup assumes that a document has a single encoding, whatever it might be. If you pass it a document that contains both UTF-8 and Windows-1252, it’s likely to think the whole document is Windows-1252, and the document will come out looking like â˜ƒâ˜ƒâ˜ƒ“I like snowmen!”. UnicodeDammit.detwingle() is new in Beautiful Soup 4.1.0. Comparing objects for equality¶ Beautiful Soup says that two NavigableString or Tag objects are equal when they represent the same HTML or XML markup. In this example, the two tags are treated as equal, even though they live in different parts of the object tree, because they both look like “pizza”: markup = "I want pizza and more pizza!
" soup = BeautifulSoup(markup, 'html.parser') first_b, second_b = soup.find_all('b') print first_b == second_b # True print first_b.previous_element == second_b.previous_element # False If you want to see whether two variables refer to exactly the same object, use is: print first_b is second_b # False Copying Beautiful Soup objects¶ You can use copy.copy() to create a copy of any Tag or NavigableString: import copy p_copy = copy.copy(soup.p) print p_copy #I want pizza and more pizza!
The copy is considered equal to the original, since it represents the same markup as the original, but it’s not the same object: print soup.p == p_copy # True print soup.p is p_copy # False The only real difference is that the copy is completely detached from the original Beautiful Soup object tree, just as if extract() had been called on it: print p_copy.parent # None This is because two different Tag objects can’t occupy the same space at the same time. Parsing only part of a document¶ Let’s say you want to use Beautiful Soup look at a document’s tags. It’s a waste of time and memory to parse the entire document and then go over it again looking for tags. It would be much faster to ignore everything that wasn’t an tag in the first place. The SoupStrainer class allows you to choose which parts of an incoming document are parsed. You just create a SoupStrainer and pass it in to the BeautifulSoup constructor as the parse_only argument. (Note that this feature won’t work if you’re using the html5lib parser. If you use html5lib, the whole document will be parsed, no matter what. This is because html5lib constantly rearranges the parse tree as it works, and if some part of the document didn’t actually make it into the parse tree, it’ll crash. To avoid confusion, in the examples below I’ll be forcing Beautiful Soup to use Python’s built-in parser.) SoupStrainer¶ The SoupStrainer class takes the same arguments as a typical method from Searching the tree: name, attrs, string, and **kwargs. Here are three SoupStrainer objects: from bs4 import SoupStrainer only_a_tags = SoupStrainer("a") only_tags_with_id_link2 = SoupStrainer(id="link2") def is_short_string(string): return len(string) < 10 only_short_strings = SoupStrainer(string=is_short_string) I’m going to bring back the “three sisters” document one more time, and we’ll see what the document looks like when it’s parsed with these three SoupStrainer objects: html_doc = """The Dormouse's story
Once upon a time there were three little sisters; and their names were Elsie, Lacie and Tillie; and they lived at the bottom of a well.
...
""" print(BeautifulSoup(html_doc, "html.parser", parse_only=only_a_tags).prettify()) # # Elsie # # # Lacie # # # Tillie # print(BeautifulSoup(html_doc, "html.parser", parse_only=only_tags_with_id_link2).prettify()) # # Lacie # print(BeautifulSoup(html_doc, "html.parser", parse_only=only_short_strings).prettify()) # Elsie # , # Lacie # and # Tillie # ... # You can also pass a SoupStrainer into any of the methods covered in Searching the tree. This probably isn’t terribly useful, but I thought I’d mention it: soup = BeautifulSoup(html_doc) soup.find_all(only_short_strings) # [u'\n\n', u'\n\n', u'Elsie', u',\n', u'Lacie', u' and\n', u'Tillie', # u'\n\n', u'...', u'\n'] Troubleshooting¶ diagnose()¶ If you’re having trouble understanding what Beautiful Soup does to a document, pass the document into the diagnose() function. (New in Beautiful Soup 4.2.0.) Beautiful Soup will print out a report showing you how different parsers handle the document, and tell you if you’re missing a parser that Beautiful Soup could be using: from bs4.diagnose import diagnose with open("bad.html") as fp: data = fp.read() diagnose(data) # Diagnostic running on Beautiful Soup 4.2.0 # Python version 2.7.3 (default, Aug 1 2012, 05:16:07) # I noticed that html5lib is not installed. Installing it may help. # Found lxml version <IP_ADDRESS> # # Trying to parse your data with html.parser # Here's what html.parser did with the document: # ... Just looking at the output of diagnose() may show you how to solve the problem. Even if not, you can paste the output of diagnose() when asking for help. Errors when parsing a document¶ There are two different kinds of parse errors. There are crashes, where you feed a document to Beautiful Soup and it raises an exception, usually an HTMLParser.HTMLParseError. And there is unexpected behavior, where a Beautiful Soup parse tree looks a lot different than the document used to create it. Almost none of these problems turn out to be problems with Beautiful Soup. This is not because Beautiful Soup is an amazingly well-written piece of software. It’s because Beautiful Soup doesn’t include any parsing code. Instead, it relies on external parsers. If one parser isn’t working on a certain document, the best solution is to try a different parser. See Installing a parser for details and a parser comparison. The most common parse errors are HTMLParser.HTMLParseError: malformed start tag and HTMLParser.HTMLParseError: bad end tag. These are both generated by Python’s built-in HTML parser library, and the solution is to install lxml or html5lib. The most common type of unexpected behavior is that you can’t find a tag that you know is in the document. You saw it going in, but find_all() returns [] or find() returns None. This is another common problem with Python’s built-in HTML parser, which sometimes skips tags it doesn’t understand. Again, the solution is to install lxml or html5lib. Version mismatch problems¶ SyntaxError: Invalid syntax (on the line ROOT_TAG_NAME = u'[document]'): Caused by running the Python 2 version of Beautiful Soup under Python 3, without converting the code. ImportError: No module named HTMLParser - Caused by running the Python 2 version of Beautiful Soup under Python 3. ImportError: No module named html.parser - Caused by running the Python 3 version of Beautiful Soup under Python 2. ImportError: No module named BeautifulSoup - Caused by running Beautiful Soup 3 code on a system that doesn’t have BS3 installed. Or, by writing Beautiful Soup 4 code without knowing that the package name has changed to bs4. ImportError: No module named bs4 - Caused by running Beautiful Soup 4 code on a system that doesn’t have BS4 installed. Parsing XML¶ By default, Beautiful Soup parses documents as HTML. To parse a document as XML, pass in “xml” as the second argument to the BeautifulSoup constructor: soup = BeautifulSoup(markup, "xml") You’ll need to have lxml installed. Other parser problems¶ If your script works on one computer but not another, or in one virtual environment but not another, or outside the virtual environment but not inside, it’s probably because the two environments have different parser libraries available. For example, you may have developed the script on a computer that has lxml installed, and then tried to run it on a computer that only has html5lib installed. See Differences between parsers for why this matters, and fix the problem by mentioning a specific parser library in the BeautifulSoup constructor. Because HTML tags and attributes are case-insensitive, all three HTML parsers convert tag and attribute names to lowercase. That is, the markup


Mexico Will Reject U.S. Designations of Cartels as Terrorists, Says AMLO
Mexico’s president announced Monday that he will reject any designation of cartels as terrorist organizations by the U.S. government.
by Ildefonso Ortiz and Brandon DarbyDuring his morning press conference, Mexican President Andres Manuel Lopez Obrador (AMLO) said he would not accept the U.S.’s potential designation of cartels as foreign terrorist organizations–which could enable direct actions in Mexico.
“We will never accept that, we are not ‘vendepatrias’ (nation sellers),” Lopez Obrador said.
The president’s statements come after the relatives of nine U.S. women and children who died in a cartel ambush in Sonora revealed they would be meeting with President Donald Trump. The family is expected to ask for some cartels to be labeled as terrorist organizations.
Last week, Tamaulipas Governor Francisco Cabeza de Vaca used the term “narco-terrorism” to refer to the brazen attacks on citizens of Nuevo Laredo by a faction of Los Zetas Cartel called Cartel Del Noreste. Cabeza de Vaca publicly called out Mexico City for past inaction in confronting Los Zetas.
Earlier this year, Rep. Chip Roy (R-TX) filed legislation for the most violent cartels in Mexico to be labeled as a foreign terrorist organizations, a move that would limit cartel members’ abilities to travel and provide tools to better clamp down on financial transactions, Breitbart Texas reported.
On Monday morning, Lopez Obrador’s foreign relations minister Marcelo Ebrard called designations unnecessary and inconvenient, adding that the U.S. and Mexico have a healthy working relationship in fighting cartels. According to Ebrard, terrorist designations would give the U.S. the legal avenue to take direct action on cartels on Mexican soil.
Ildefonso Ortiz is an award-winning journalist with Breitbart Texas. He co-founded Breitbart Texas’ Cartel Chronicles project with Brandon Darby and senior Breitbart management. You can follow him on Twitter and on Facebook . He can be contacted at<EMAIL_ADDRESS>.
Brandon Darby is the managing director and editor-in-chief of Breitbart Texas. He co-founded Breitbart Texas’ Cartel Chronicles project with Ildefonso Ortiz and senior Breitbart management. Follow him on Twitter and Facebook . He can be contacted at<EMAIL_ADDRESS>.


Thank you for your registration.Next time you visit our site, you can login directly by using your login info.


NOTE: Any imported session with the same name as an existing session will replace the existing session.
Import failed!
Success!
Copy the text below, transfer it to another computer with Chrome and Session Manager installed, and import it.


Similar
Jaccard coefficient is greater or equal to 0.75
| Prediction () | Signature | Comparison | Integration | ||||||
|---|---|---|---|---|---|---|---|---|---|
| Accession | Proteins | Proteins | Overlaps | Entry | |||||
|
Relationship
Similar
Jaccard coefficient is greater or equal to 0.75
Related
Both query and target signatures contain at least 75% of the other signature
Parent
Query signature contains at least 75% of the target signature
Child
Target signature contains at least 75% of the query signature
None
Query and target signatures are not significantly close
|
Score
Relationship predicted using protein overlaps
Relationship predicted using protein and residue overlaps
Relationship predicted using protein and residue overlaps, with the residue score (similarity or containment) being greater or equal to 0.9
|
Comments
UniProtKB


With one in six adults still struggling to read, Quick Reads continues its work to break down the barriers to reading. Since its launch, Quick Reads has distributed over 4.5m books and there have been over 3.5m library loans.
Each year, Quick Reads publishes six short, plot-filled books written by well-known authors. They are designed to help people who have lost the reading habit or struggle with aspects of reading. Whether you’re looking for an entertaining gateway to reading or already like these authors and want to read more from them, we encourage you to borrow them.
Cut Off, by Mark Billingham
“It’s the moment we all fear: losing our phone, leaving us cut off from family and friends.
“But, for Louise, losing hers in a local café takes her somewhere much darker. After many hours of panic, Louise is relieved when someone gets in touch offering to return the phone. From then on she is impatient to get back to normal life. But when they meet on the beach, Louise realises you should be careful what you wish for.”
The Great Cornish Getaway, by Fern Britton
“As the sun sits high in the sky over Cornwall, and the sea breeze brings a welcome relief to the residents of the seaside village of Trevay, a stranger arrives in need of a safe haven.
“The fact that the stranger is a Hollywood heartthrob makes villagers Penny and Dorrie even more keen to help. They both know what it’s like to feel that you need a break from life, and they bring the village together to keep their stranger’s secret. It’s not long before he’s helping some of the villagers find the answers to their own problems.
Clean Break, by Tammy Cohen
“Marriage is complicated, especially for Kate. Her husband Jack has a temper, and has been an absent father for years. Kate knows it’s time for a divorce, but Jack refuses. Can Kate rid herself of her jealous husband before it’s too late?”
 Even Mumbai’s biggest gangster shops there - he’s just ordered a classic race car worth millions.
“But now the car is gone. Stolen from a locked room, in the middle of the night. Who stole it? The mechanic who is addicted to gambling? The angry ex-worker? The car thief pulling off one last job? And how on earth did they make it vanish from the locked garage?
“Inspector Chopra has just days to find the culprit - and the missing car - before its owner finds out and takes violent revenge.”
The Beach Wedding, by Dorothy Koomson
“Will your past always catch up with you?
“Tessa Dannall is excited and happy when her daughter, Nia, arrives at their family’s tropical beach resort to get married. Tessa is also trying to forget the last time she went to a wedding on this beach and how that day changed her life forever.
“But as the big day draws near, Tessa realises she must face the deadly ghosts from her past - or they may ruin her daughter’s future.”
Six Foot Six, by Kit De Waal
“It’s an exciting day for Timothy Flowers. It’s the third of November, and it’s Friday, and it’s his 21st birthday.
“When Timothy walks to his usual street corner to see his favourite special bus, he meets Charlie. Charlie is a builder who is desperate for Timothy’s help because Timothy is very tall, six feet six inches. Timothy has never had a job before - or no work that he’s kept for more than a day.
“But when Timothy and Charlie have to collect money from a local thug, things don’t exactly go according to plan. Over the course of one day, Timothy’s life will change forever.”


{{x.payload.doc.data().title}}
{{x.payload.doc.data().description}}
How To...
If there is one thing we can count on in menstruation and in life is that it is unprdictable
{{x.payload.doc.data().description}}
The only thing required to become a woman is to identify as one


This beast was so feared that even its name was spoken in hushed tones. To be free of fear, one must stop being afraid of a name. Solve the puzzle to find out this vicious dragon’s name.


INSTRUCTIONS: Complete this form in order to compete for a special prize!
Page developed by Gustavo Correa for Free Code Camp learning


Client Services
Created At
22 Février 2021
22 Février 2021
1200
Issue Type
Support
Support
80
Project Name
NWA Service Desk
262
User
Iheb Bousnina
26
| ID | Subject | Create At | Status | Updated At | Action | |
|---|---|---|---|---|---|---|
| NWA-246341 | Dear Pasquale, Thanks | Apr 29, 2020 |
Completed
|
May 9, 2020 | ||
| NWA-246341 | Dear Pasquale, Thanks | Apr 29, 2020 |
Completed
|
May 9, 2020 | ||
| NWA-246341 | Dear Pasquale, Thanks | Apr 29, 2020 |
Completed
|
May 9, 2020 | ||
| NWA-246341 | Dear Pasquale, Thanks | Apr 29, 2020 |
Completed
|
May 9, 2020 | ||
| NWA-246341 | Dear Pasquale, Thanks | Apr 29, 2020 |
Completed
|
May 9, 2020 | ||
| NWA-246341 | Dear Pasquale, Thanks | Apr 29, 2020 |
Completed
|
May 9, 2020 | ||
| NWA-246341 | Dear Pasquale, Thanks | Apr 29, 2020 |
Completed
|
May 9, 2020 | ||
| NWA-246341 | Dear Pasquale, Thanks | Apr 29, 2020 |
Completed
|
May 9, 2020 |


Shorten
Url
Shorten
Copy to clipboard
Copy
Build with:
Vue.js
API
Assets source:
House vector created by stories -
www.freepik.com
Icons made by
Freepik
from
www.flaticon.com