Uima Ruta Heading Levels - uima

I'm trying to tag the Heading Levels (Level 1,Level 2,Level 3) from many headings. Using font size Information which is coming from HTML. First I took font size using regex like
"<span style=\"font-family:\'(.+?)\'"->1=fontfamily;
"<span style=\"font-family(.+?)font-size:\'(.+?)\'"->2=font size;
Now I need to compare all these heading sizes using fontsize information and tag heading levels based on it.
Input:
<span style="font-family:'Times New Roman'; font-size:'14pt'"><span class="">MATERIALS AND METHODS</span></span>
<span style="font-family:'Times New Roman'; font-size:'12pt'"><span class="">Chemicals</span></span>
<span style="font-family:'Times New Roman'; font-size:'10pt'"><span class="">HILIC-MS Profiling of Metabolites</span>

You can do something like this (tested with UIMA Ruta 2.5.0):
ENGINE utils.HtmlAnnotator;
TYPESYSTEM utils.HtmlTypeSystem;
CONFIGURE(HtmlAnnotator, "onlyContent" = false);
EXEC(HtmlAnnotator, {TAG});
DECLARE FontFamily;
DECLARE FontSize;
DECLARE Heading (INT level, INT size);
"<span style=\"font-family:\'(.+?)\'"->1=FontFamily;
"<span style=\"font-family(.+?)font-size:\'(\\d+.+?)\'"->2=FontSize;
INT size;
RETAINTYPE(MARKUP);
SPAN{-PARTOF(Heading) -> Heading, Heading.size = size}
<-{FontFamily # FontSize{PARSE(size)};};
# h:Heading{-> size = h.size};
h:Heading{h.size == size -> Heading.level = 1};
h1:Heading{h1.level != 0} # h2:Heading.level == 0
{h1.size>h2.size -> h2.level = (h1.level + 1)};
h1:Heading{h1.level != 0} # h2:Heading.level == 0
{h1.size==h2.size -> h2.level = h1.level};
RETAINTYPE;
These rules use the HtmlAnnotator, which requires somewhat valid html. I needed to added <html> tags to the document in order to get it to work.
These rules are not optimal but just a starting point. The actual rules that you should use depend mainly on the use case and on how robust they need to be.
DISCLAIMER: I am a developer of UIMA Ruta

Related

Make GTK Entry box smaller

I am trying to make a GUI program in Julia using Gtk. My program includes a large number of GtkEntry boxes. However, I am running into space issues because the Entry boxes have a lot of internal padding around the actual characters. I would like to reduce, at least, the top and bottom whitespace. I have tried to use the setproperty!() function to change the height-request value, but that seems to be only able to make the box bigger, not smaller. Additionally, the margin, margin-top, etc. fields are all set to 0 by default. Again, I can make them bigger but not smaller.
Is this possible to fix? I have included below a minimal working example, a screenshot, and a Julia REPL output displaying the available properties.
Edit:
I have also tried using a css file (test.css) with the contents
entry {
margin-top: 0;
margin-bottom: 0;
padding-top: 0;
padding-bottom: 0;
}
Julia 0.6.0 code:
using Gtk
win = GtkWindow("Example")
sb = GtkGrid()
function sb_entry(label)
frame = GtkFrame(label)
entry = GtkEntry()
setproperty!(entry, :input_purpose, 2)
push!(frame, entry)
return frame
end
sb_rows = sb_entry("rows")
sb_cols = sb_entry("cols")
sb_row_off = sb_entry("row off")
sb_col_off = sb_entry("col off")
sb[1,1] = sb_rows
sb[2,1] = sb_cols
sb[1,2] = sb_row_off
sb[2,2] = sb_col_off
setproperty!(sb, :column_homogeneous, true)
setproperty!(sb, :column_spacing, 5)
setproperty!(sb, :row_spacing, 5)
push!(win, sb)
### begin edit (css)
screen = Gtk.GAccessor.screen(win)
provider = GtkCssProviderLeaf(filename="/path/to/test.css")
ccall((:gtk_style_context_add_provider_for_screen, Gtk.libgtk), Void,
(Ptr{Void}, Ptr{GObject}, Cuint),
screen, provider, 1)
### end edit (css)
showall(win)
if !isinteractive()
c = Condition()
signal_connect(win, :destroy) do widget
notify(c)
end
wait(c)
end
julia> sb_row_off[1]
Gtk.GtkEntryLeaf(editing-canceled=FALSE, name="", parent, width-request=-1,
height-request=-1, visible=TRUE, sensitive=TRUE, app-paintable=FALSE,
can-focus=TRUE, has-focus=FALSE, is-focus=TRUE, focus-on-click=TRUE,
can-default=FALSE, has-default=FALSE, receives-default=FALSE, composite-child=FALSE,
style, events=0, no-show-all=FALSE, has-tooltip=FALSE, tooltip-markup=NULL,
tooltip-text=NULL, window, opacity=1.000000, double-buffered, halign=GTK_ALIGN_FILL,
valign=GTK_ALIGN_FILL, margin-left, margin-right, margin-start=0, margin-end=0,
margin-top=0, margin-bottom=0, margin=0, hexpand=FALSE, vexpand=FALSE,
hexpand-set=FALSE, vexpand-set=FALSE, expand=FALSE, scale-factor=2, buffer,
cursor-position=0, selection-bound=0, editable=TRUE, max-length=0, visibility=TRUE,
has-frame=TRUE, inner-border, invisible-char=9679, activates-default=FALSE,
width-chars=-1, max-width-chars=-1, scroll-offset=0, text="", xalign=0.000000,
truncate-multiline=FALSE, shadow-type, overwrite-mode=FALSE, text-length=0,
invisible-char-set=FALSE, caps-lock-warning=TRUE, progress-fraction=0.000000,
progress-pulse-step=0.100000, primary-icon-pixbuf, secondary-icon-pixbuf,
primary-icon-stock, secondary-icon-stock, primary-icon-name=NULL,
secondary-icon-name=NULL, primary-icon-gicon, secondary-icon-gicon,
primary-icon-storage-type=GTK_IMAGE_EMPTY,
secondary-icon-storage-type=GTK_IMAGE_EMPTY, primary-icon-activatable=TRUE,
secondary-icon-activatable=TRUE, primary-icon-sensitive=TRUE,
secondary-icon-sensitive=TRUE, primary-icon-tooltip-text=NULL,
secondary-icon-tooltip-text=NULL, primary-icon-tooltip-markup=NULL,
secondary-icon-tooltip-markup=NULL, im-module=NULL, placeholder-text=NULL,
completion, input-purpose=GTK_INPUT_PURPOSE_DIGITS, input-hints=GTK_INPUT_HINT_NONE,
attributes, populate-all=FALSE, tabs)
entry { min-height: 0px; } allows it to be as small as possible. Adjust size as required.

p:barChart y axis format

I use primefaces 4.0 barchart, but i want to modify some default proprieties. This is my xhtml page
<p:barChart id="chart" value="#{marchebean.model}" legendPosition="ne" xaxisLabel="Année" yaxisLabel="Montant en DT" title="Factures payés par années" />
What i want to do
1.I want to separate between hundreds , thousands and millions in y axis by a space i.e changing the format of my numbers , i use NumberFormat.getNumberInstance(Locale.FRANCE).format(mynumber); in java but i don't know how to achieve this with charts in primefaces.
I want to display on the top of every bar the value setted in backing bean and change it's size.
Edit
Separation between thousand done, but i still don't know how display values above every bar or change their size. this is my new code
<p:barChart id="chart" value="#{marchebean.model}" extender="ext" style="height:600px;" legendPosition="ne" xaxisLabel="Année" yaxisLabel="Montant en DT" title="Factures payés par années" />
<script type="text/javascript">
function ext() {
this.cfg.axes.yaxis.tickOptions = {
formatString: "%'i"
};
this.cfg.seriesDefaults={
renderer: $.jqplot.BarRenderer,
pointLabels:{show:true}
},
$.jqplot.sprintf.thousandsSeparator = ' ';
}
</script>
First question
You can fulfill your need #1 using an extender.
Here's the related excerpt from Primefaces' manual regarding extenders:
3.14.15 Extender Chart API provide high level access to commonly used jqplot options however there are many more customization options
available in jqplot. Extender feature provide access to low level apis
to do advanced customization by enhancing the configuration object,
here is an example to increase shadow depth of the line series where
model's extender property is set to "ext".
<p:chart type="line" model="#{bean.model}" />
function ext() {
//this = chart widget instance
//this.cfg = options
this.cfg.seriesDefaults = {
shadowDepth: 5
};
}
Refer to jqPlot docs for available options.
Note: in Primefaces 4.0, the extender function name is provided as an attribute of the component tag, eg. <p:barChart extender="ext" .../>
To use whitespaces as thousands separator, use the following extender:
function ext() {
this.cfg.axes.yaxis.tickOptions = {
formatString: "%'i"
};
$.jqplot.sprintf.thousandsSeparator = ' ';
}
Second question
You will also manage to do it making some tweaking in your extender.
For example, the following piece of configuration will display values above every bar:
seriesDefaults: {
renderer: $.jqplot.BarRenderer,
pointLabels:{show:true}
},
And just use some CSS to change the size!
--
Zim

Add Field for custom class in TYPO3 CE

I'm trying to add a field for adding a custom class to all TYPO3 CE (i.e Bootstrap Classes).
The Field is shown in the BE CEs and I'm able to write f.e. col-md-6 in this field.
The DB has a field called bootstrap_css where the values are stored.
But I've no Idea on how to get a wrap around the CE in FE with that custom class:
Example: Adding col-md-6 in the BE Field should result in something like this:
<div class="col-md-6">
<div class="csc-default">
....
</div>
</div>
Any Idea?
A free input for classes is generally considered bad practice (-> separation of concerns).
For such cases, I use the classic 'header_layout' method, based on www.typo3wizard.com/en/snippets/cool-stuff-typoscript/using-the-layout-field-in-tt-content-and-pages.html
This works very robustly, and editors can pick any value you offer them.
It IS a workaround, but it's been used for ages.
The header_layout box has been used because it's in a convenient place for editors. Originally, it was designed to pick a layout just for the element.
in page TSConfig:
TCEFORM.tt_content {
// Layout-Selector
header_layout.altLabels.0 = Normal
header_layout.altLabels.1 = Kasten
header_layout.altLabels.2 = Bilder 1/2
header_layout.altLabels.3 = Bilder 1/3
header_layout.altLabels.4 = Dokumente 1/2 (mit Rand)
header_layout.altLabels.5 = Dokumente 1/3 (mit Rand)
// everything higher than 5 goes here
header_layout.addItems {
// 6 = Box für wichtige Daten
// 7 = Box für Kosten
// 8 = Box für Arbeiten / Literatur
}
// Remove items if less than 5
// 100 is "hidden"
header_layout.removeItems = 100
}
Then in page TS:
Assuming we want to wrap text and textpic elements:
tt_content.text.stdWrap.outerWrap.cObject=CASE
tt_content.text.stdWrap.outerWrap.cObject=CASE
tt_content.text.stdWrap.outerWrap.cObject{
key.field = header_layout
default=TEXT
default.value=|
1=TEXT
1.value=<aside class="kasten halfimg clearfix">|</aside>
2=TEXT
2.value=<div class="halfimg clearfix">|</div>
3=TEXT
3.value=<div class="thirdimg clearfix">|</div>
4=TEXT
4.value=<div class="halfimg-border clearfix">|</div>
5=TEXT
5.value=<div class="thirdimg-border clearfix">|</div>
}
tt_content.textpic.stdWrap.outerWrap.cObject=CASE
tt_content.textpic.stdWrap.outerWrap.cObject{
key.field = header_layout
default=TEXT
default.value=|
1=TEXT
1.value=<aside class="kasten halfimg clearfix">|</aside>
2=TEXT
2.value=<div class="halfimg clearfix">|</div>
3=TEXT
3.value=<div class="thirdimg clearfix">|</div>
4=TEXT
4.value=<div class="halfimg-border clearfix">|</div>
5=TEXT
5.value=<div class="thirdimg-border clearfix">|</div>
}
So basically, you tap into the rendering of css_styled_content and tell it to wrap that content element depending on what is set in header_layout.

With TypoScript, how to modify a global setting per content element

The background: I am using ext:a21glossary, but I would like to disable it's replacing of for certain types of content elements. Actually, not for cTypes, but depending on what is selected via header_layout.
Now the question is more general: is it possible to access a general setting per Content element independently?
That's my basic, often-used way to use header_layout to wrap content elements:
tt_content.text.stdWrap.outerWrap.cObject=CASE
tt_content.text.stdWrap.outerWrap.cObject{
key.field = header_layout
default=TEXT
default.value=<section class="clearfix" id="c{field:uid}">|</section>
default.insertData = 1
4=TEXT
4.value=<section class="clearfix lit-container" id="c{field:uid}">|</section>
4.insertData = 1
}
So just for daring, I tried this (config.tx_a21glossary.noglossary=1 being the desired setting for that CE):
config.tx_a21glossary.noglossary.cObject = CASE
config.tx_a21glossary.noglossary.cObject {
key.field = header_layout
default=TEXT
default.value= 0
4 = TEXT
4.value = 1
}
Of course, this wouldn't work.
Before I look further: is this approach (modify a global setting per CE) possible at all?

The proper use of jsoup

I recently began to study how to use jsoup
Document doc = Jsoup.parse(responseString);
 Elements pngs = doc.select ("div.kk2");
To using jsoup made ​​a web page to put pictures of example I
<div class="kk2" id="12" style="border:2px solid #FFFF00; top:-1px; left:-203px; height:151px; width:200px"> <img src = "http:// kk.org / t / ea / ff.jpg "alt =" text "style =" fff "/> </ div>
After screening of the example
for(Element png : pngs){
sff2.append(png.attr("abs:href")).append(" ").append(png.text()).append("\n");
}
To obtain this value
init ~ kk.org ~ t / ea / ff.jpg ~ text
If I simply just want to get this value
http://kk.org/t/ea/ff.jpg
How can I do it??
I try to use
sff2.append (png.attr ("alt")). append (""). append (png.text ()). append ("\ n");
But without success
If I understand correctly, you just want to get the address of the image?
If so, this should do it.
Elements div = doc.select("div[class=kk2]");
Elements pngs = div.select("img");
for (Element png : pngs) {
String src = png.attr("abs:src");
src = src.replace(" ", ""); // Remove spaces
System.out.println(src);
}