sphinx using JSGF grammar with weights: java.lang.NullPointerException exception - grammar

I am using the following grammar:
#JSGF V1.0;
grammar tag;
public <tag> = <tagPart> +;
<tagPart> = <digit> | <letter>;
<digit> = oh | zero | one | two | three | four | five | six |seven | eight | nine ;
<letter> = a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | x | y | z ;
Everything works well unless I add weights. Running with weights:
<tagPart> = /0.8/ <digit> | /0.1/ <letter>;
I am getting the following error:
Exception in thread "main" java.lang.NullPointerException
at edu.cmu.sphinx.jsgf.JSGFGrammar.getNormalizedWeights(JSGFGrammar.java:49)
The way I am using grammar is:
Configuration configuration = new Configuration();
configuration.setAcousticModelPath("file:/E/sphinx4-5prealpha-src/sphinx4-data/src/main/resources/edu/cmu/sphinx/models/en-us/en-us");
configuration.setDictionaryPath("file:/E/sphinx4-5prealpha-src/sphinx4-data/src/main/resources/edu/cmu/sphinx/models/en-us/cmudict-en-us.dict");
configuration.setGrammarPath("file:/E/sT/src/main/resources/");
configuration.setGrammarName("tag");
configuration.setUseGrammar(true);
StreamSpeechRecognizer recognizer = new StreamSpeechRecognizer(configuration);

I'm sorry for delay, this issue has been just fixed in trunk in revision 13217, please update and try again, it should work.

Related

Copy fields from one column to another with criteria

I have a table called 02_Month with the following information:
|------------------------------------------------------------------
| Soc | Society | USD_STD | USD_STD_R |
|------------------------------------------------------------------|
| AB02 | Plants | 3.8 | 1 |
| JK01 | Trees | 2.4 | 1 |
| WB09 | Bushes | 1.2 | 3 |
| COIN | Flowers | 4.6 | 2 |
| KK99 | Stones | 66.9 | 3 |
| TCTC | Ruby | 19.0 | 5 |
| WNOL | Steel | 71.1 | 7 |
|------------------------------------------------------------------
I want to copy what says in column USD_STD to USD_STD_R if the column Soc is COIN or TCTC. I want to have this at the end:
|------------------------------------------------------------------
| Soc | Society | USD_STD | USD_STD_R |
|------------------------------------------------------------------|
| AB02 | Plants | 3.8 | 1 |
| JK01 | Trees | 2.4 | 1 |
| WB09 | Bushes | 1.2 | 3 |
| COIN | Flowers | 4.6 | 4.6 |
| KK99 | Stones | 66.9 | 3 |
| TCTC | Ruby | 19.0 | 19.0 |
| WNOL | Steel | 71.1 | 7 |
|------------------------------------------------------------------
I wrote this:
UPDATE 02_Month
SET [02_Month].USD_STD_R = USD_STD
WHERE (([02_Month].Soc="COIN") or ([02_Month].Soc="TCTC"));
It is not working as expected. I suppose it's due to the WHERE condition. if I don't write that line it copies the entire column USD_STD in USD_STD_R.
The code I wrote prints 0 in all of the fields of USD_STD_R. Why doesn't it work and how can it be corrected?
The following should be sufficient:
update [02_month] t
set t.usd_std_r = t.usd_std
where t.soc="COIN" or t.soc="TCTC"
A few notes:
Since your table name starts with a number, it must be enclosed in square brackets.
The use of t is merely an alias to avoid the need to repeatedly write [02_month]
You can use either t.soc="COIN" or t.soc="TCTC" or t.soc in ("COIN","TCTC") both should yield the same result.
Double-quotes " are typically used by MS Access, but single-quotes ' should also be valid.
USD_STD instead of STD_USD
Also you can use IN operator
UPDATE 02_Month
SET [02_Month].USD_STD_R = USD_STD
FROM [02_Month]
WHERE ([02_Month].Soc IN ('COIN','TCTC'));
Please, try with below query. string value always within ''.
UPDATE 02_Month
SET USD_STD_R = USD_STD
WHERE Soc in ('COIN','TCTC');
your relation 02_month with column field USD_STD USD_STD_R but in update statement column field name is STD_USD_R and STD_USD.
You can use inner join update as shown below.
UPDATE a
SET a.USD_STD_R = b.USD_STD --You can change another column here as per your need.
FROM [02_Month] a
INNER JOIN [02_Month] b ON a.soc = b.soc
AND a.society = b.society
AND a.USD_STD = b.USD_STD
AND a.USD_STD_R = b.USD_STD_R
WHERE a.Soc in ('COIN','TCTC');
Live Demo Here
If you do not want alias name for updating table.
UPDATE [02_Month]
SET [02_Month].USD_STD_R = b.USD_STD --You can change another column here as per your need.
FROM [02_Month]
INNER JOIN [02_Month] b ON [02_Month].soc = b.soc
AND [02_Month].society = b.society
AND [02_Month].USD_STD = b.USD_STD
AND [02_Month].USD_STD_R = b.USD_STD_R
WHERE [02_Month].Soc in ('COIN','TCTC');
db<>fiddle Demo

How to select Multiple Rows based on one Column

So I have looked around the internet, and couldn't find anything that could be related to my issue.
This is part of my DB:
ID | English | Pun | SID | Writer |
=======================================================
1 | stuff | stuff | 1 | Full |
2 | stuff | stuff | 1 | Rec. |
3 | stuff | stuff | 2 | Full |
4 | stuff | stuff | 2 | Rec. |
Now how would I get all rows with SID being equal to 1.
Like this
ID | English | Pun | SID | Writer |
=======================================================
1 | stuff | stuff | 1 | Full |
2 | stuff | stuff | 1 | Rec. |
Or when I want to get all rows with SID being equal to 2.
ID | English | Pun | SID | Writer |
=======================================================
3 | stuff | stuff | 2 | Full |
4 | stuff | stuff | 2 | Rec. |
This is my current SQL Query using SQLite:
SELECT * FROM table_name WHERE SID = 1
And I only get the first row, how would I be able to get all of the rows?
Here is my PHP Code:
class GurDB extends SQLite3
{
function __construct()
{
$this->open('gurbani.db3');
}
}
$db = new GurDB();
$mode = $_GET["mode"];
if($mode == "2") {
$shabadnum = $_GET["shabadNo"];
$result = $db->query("SELECT * FROM table_name WHERE SID = $shabadnum");
$array = $result->fetchArray(SQLITE3_ASSOC);
print_r($array);
}
Fetch array only gives you one row... you want something like this:
while($row = $result->fetch_array())
{
$rows[] = $row;
}

JSFG grammar not parsing

I can't see where im breaking my jsfg grammar (for Sphinx4).
Or is there any debugging tool for parsing?
This compiles:
#JSGF V1.0;
grammar dialog;
<digit> = oh |
zero |
one |
two |
three |
four |
five |
six |
seven |
eight |
nine ;
<number> = <digit>+ [point <digit>+];
<menu_command> = digits |
[go to [the]] bank account |
weather forecast |
[play] music |
v |
hud |
exit [[the] program] ;
<bank_command> = [show | check] balance |
deposit <number> |
withdraw <number> |
back ;
<artist_command> = elvis |
moby |
[the] beatles |
sia |
random;
<song_command> = [a little less] converstion |
moby |
[the] beatles |
sia ;
<music_command> = [play] music;
public <command> = <menu_command> | <bank_command>;
But this doesnt:
#JSGF V1.0;
grammar dialog;
<digit> = oh |
zero |
one |
two |
three |
four |
five |
six |
seven |
eight |
nine ;
<number> = <digit>+ [point <digit>+];
<hud_command> = voicehud | hud
<menu_command> = digits |
[go to [the]] bank account |
weather forecast |
v |
hud |
exit [[the] program] |
hide ;
<bank_command> = [show | check] balance |
deposit <number> |
withdraw <number> |
back ;
<artist_command> = elvis |
moby |
[the] beatles |
sia |
random;
<song_command> = burning love |
moby |
[the] beatles |
sia ;
<album_command> = [one thousand] forms of fear |
play |
[the] white album |
burning love ;
<musicapp_command> = play | music;
<music_selector_command> = artist | song | album | random | mix;
<music_selection_command> = <artist_command> | <song_command> | <album_command>;
<music_command> = <musicapp_command><music_selector_command><music_selection_command>;
public <command> = <menu_command> | <bank_command> | <music_command>;

Join tables on a geo range

I have 2 independent tables (Links & Sections). The information inside link table is somewhat like this,
Links Table
----------------------------------------------------------------------------
| id | Description | startLat | startLng | endLat | endLng |
----------------------------------------------------------------------------
| 1000259 | Link Number 1 |52.891372 |-1.768254 |52.892545 |-1.775278 |
| 1000359 | Link Number 2 |52.894892 |-1.780513 |52.894306 |-1.774793 |
| 1000279 | Link Number 3 |52.894306 |-1.774793 |52.895000 |-1.765273 |
| 1000258 | Link Number 4 |52.895000 |-1.765273 |52.895500 |-1.755278 |
| 1000255 | Link Number 5 |52.895500 |-1.755278 |52.896500 |-1.745278 |
| 1000555 | Link Number 6 |52.896500 |-1.745278 |52.897250 |-1.735278 |
----------------------------------------------------------------------------
And the Sections table appears like this,
Sections Table
-----------------------------------------------------------------------------
| id | Description | fromLat | fromLng | toLat | toLng |
-----------------------------------------------------------------------------
| 625 | Section 1 | 52.893598 | -1.775120 | 52.885053|-1.756409 |
| 713 | Section 2 | 52.897273 | -1.788324 | 52.898285|-1.724721 |
| ... | ... | ... | ... | ... | ... |
| ... | ... | ... | ... | ... | ... |
-----------------------------------------------------------------------------
I want to run a query which gives me all the links which are covered by a section. So if I say how many links come under Section 2, I should receive all the links that are covered by the lat/lng of section information.
P.S. Please note, Sections are longer than Links ... Any Help!!!
You do this with a join, just the conditions are inequalities rather than equalities. It is unclear whether you want partial coverage or total coverage. Here is an example for partial coverage:
select s.*, l.*
from sections s join
links l
on (l.startlat < s.tolat and l.endlast > s.fromlat) and
(l.startlong < s.tolong and l.endlong > s.fromlong);

Using Scenario Outline and Examples with Strings

I'm facing the following "issue" when trying out cucumber-jvm with an Arabic to Roman Numeral converter - the "then" piece gets converted into several step defs instead of one.
here's my scenario outline:
Scenario Outline:
Given a romanizer
When I romanize <arabic number>
Then I get the <roman numeral>
Examples:
| arabic number | roman numeral |
| 1 | I |
| 2 | II |
| 3 | III |
| 4 | IV |
| 5 | V |
| 6 | VI |
| 7 | VII |
| 8 | VIII |
| 9 | IX |
| 10 | X |
For this, i was expecting the then stepdef to simply be:
I_get_the(String value)
but instead it turns it into one stepdef for each example:
I_get_the_I()
I_get_the_II()
etc.
what am i doing wrong?
Thanks,
Nilesh
use (note the double quotes)
Scenario Outline:
Given a romanizer
When I romanize "<arabic number>"
Then I get the "<roman numeral>"