Program jusText is a tool for removing boilerplate content, such as navigation links, headers, and footers from HTML pages.
- Version 0.0.1 - Convert from python code
- Version 0.0.2 - Add logger lib
- Version 0.0.3 - Migrate to rollup
Program jusText is a tool for removing boilerplate content, such as navigation links, headers, and footers from HTML pages.
License: MIT License
Program jusText is a tool for removing boilerplate content, such as navigation links, headers, and footers from HTML pages.
Function Core.getHtmlOfUrl returns promise. So you need return this promise to a caller.
export function url(externalUrl, language = '', format = 'default', options = {
lengthLow: LENGTH_LOW_DEFAULT,
lengthHigh: LENGTH_HIGH_DEFAULT,
stopwordsLow: STOPWORDS_LOW_DEFAULT,
stopwordsHigh: STOPWORDS_HIGH_DEFAULT,
maxLinkDensity: MAX_LINK_DENSITY_DEFAULT,
maxHeadingDistance: MAX_HEADING_DISTANCE_DEFAULT,
noHeadings: NO_HEADINGS_DEFAULT,
}) {
return Core.getHtmlOfUrl(externalUrl).then((response) => {
const htmlText = response.data;
return rawHtml(htmlText, language, format, options);
}).catch((error) => {
throw error;
});
}
And justext.url(url, language, 'detailed', options).then((data)=>console.log(data));
reviseParagraphClassification
returns paragraphs
, but it doesn't look like the paragraphs
get manipulated in any way, and that reviseParagraphs
is where the new filtered data is. Is reviseParagraphs
supposed to be returned instead of paragraphs
?
I added the python reference code for convenience.
def revise_paragraph_classification(paragraphs, max_heading_distance=MAX_HEADING_DISTANCE_DEFAULT):
"""
Context-sensitive paragraph classification. Assumes that classify_pragraphs
has already been called.
"""
# copy classes
for paragraph in paragraphs:
paragraph.class_type = paragraph.cf_class
# good headings
for i, paragraph in enumerate(paragraphs):
if not (paragraph.heading and paragraph.class_type == 'short'):
continue
j = i + 1
distance = 0
while j < len(paragraphs) and distance <= max_heading_distance:
if paragraphs[j].class_type == 'good':
paragraph.class_type = 'neargood'
break
distance += len(paragraphs[j].text)
j += 1
# classify short
new_classes = {}
for i, paragraph in enumerate(paragraphs):
if paragraph.class_type != 'short':
continue
prev_neighbour = get_prev_neighbour(i, paragraphs, ignore_neargood=True)
next_neighbour = get_next_neighbour(i, paragraphs, ignore_neargood=True)
neighbours = set((prev_neighbour, next_neighbour))
if neighbours == set(['good']):
new_classes[i] = 'good'
elif neighbours == set(['bad']):
new_classes[i] = 'bad'
# it must be set(['good', 'bad'])
elif (prev_neighbour == 'bad' and get_prev_neighbour(i, paragraphs, ignore_neargood=False) == 'neargood') or \
(next_neighbour == 'bad' and get_next_neighbour(i, paragraphs, ignore_neargood=False) == 'neargood'):
new_classes[i] = 'good'
else:
new_classes[i] = 'bad'
for i, c in new_classes.items():
paragraphs[i].class_type = c
# revise neargood
for i, paragraph in enumerate(paragraphs):
if paragraph.class_type != 'neargood':
continue
prev_neighbour = get_prev_neighbour(i, paragraphs, ignore_neargood=True)
next_neighbour = get_next_neighbour(i, paragraphs, ignore_neargood=True)
if (prev_neighbour, next_neighbour) == ('bad', 'bad'):
paragraph.class_type = 'bad'
else:
paragraph.class_type = 'good'
# more good headings
for i, paragraph in enumerate(paragraphs):
if not (paragraph.heading and paragraph.class_type == 'bad' and paragraph.cf_class != 'bad'):
continue
j = i + 1
distance = 0
while j < len(paragraphs) and distance <= max_heading_distance:
if paragraphs[j].class_type == 'good':
paragraph.class_type = 'good'
break
distance += len(paragraphs[j].text)
j += 1
Thank you for making this package. Is this sufficiently up to date with the python implementation (https://github.com/miso-belica/jusText) ? Or was it a nearly identical replica at the time of this implementation?
[] โ Migrate to build with Rollup
[] - Fix the demo
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.