Count occurrences of matched words
All,Does anyone know the syntax or the algorithm to count the occurrences of matched words that separate compared cases of two tables or columns? Here is a simple example of the type of comparison, I would like to perform. I found the regexp_count function, but it only works in 11g. Unfortunately, I have Oracle 10 g. Any help would be greatly appreciated. Thank you
i.e.
drop table compare_matched_words;
create table compare_matched_words)
number of query_id,
query_string1 varchar2 (80).
query_string2 varchar2 (80)
);
insert into compare_matched_words values (1, 'oracle' 255', oracle1 255');
insert into compare_matched_words values (2, ' larry ellison or ','larry or ');
insert into compare_matched_words values (3, 'oracle and text', 'and');
insert into compare_matched_words values (4, ' groups1 market share ","market share");
insert into compare_matched_words values (5, ' larry or "," larry ellison ");
insert into compare_matched_words values (6, 'oracle1' 255', oracle 255');
Is not in 11g. Before that you can solve the task, you need to split QUERY_STRING1 and QUERY_STRING2 in words and then compare the words for QUERY_ID even. To split the string into words use something like:
select query_id,
regexp_substr(query_string1,'\w+',1,column_value) query_string1_word
from compare_matched_words t,
table(
cast(
multiset(
select level
from dual
connect by level <= length(regexp_replace(regexp_replace(QUERY_STRING1,'\w+','A'),'[^A]'))
) as sys.OdciNumberList
)
)
/
SQL> /
QUERY_ID QUERY_STRING1_WORD
------------------- -------------------
1 oracle
1 255
2 larry
2 or
2 ellison
3 oracle
3 and
3 text
4 market1
4 share
5 larry
QUERY_ID QUERY_STRING1_WORD
------------------- -------------------
5 or
6 oracle1
6 255
14 rows selected.
SQL>
Now:
select t1.query_id,
t1.query_string1,
t2.query_string2,
count(*) matchin_word_count
from (
select query_id,
query_string1,
regexp_substr(query_string1,'\w+',1,column_value) query_string1_word
from compare_matched_words t,
table(
cast(
multiset(
select level
from dual
connect by level <= length(regexp_replace(regexp_replace(query_string1,'\w+','A'),'[^A]'))
) as sys.OdciNumberList
)
)
) t1,
(
select query_id,
query_string2,
regexp_substr(query_string2,'\w+',1,column_value) query_string2_word
from compare_matched_words t,
table(
cast(
multiset(
select level
from dual
connect by level <= length(regexp_replace(regexp_replace(query_string2,'\w+','A'),'[^A]'))
) as sys.OdciNumberList
)
)
) t2
where t2.query_id = t1.query_id
and t2.query_string2_word = t1.query_string1_word
group by t1.query_id,
t1.query_string1,
t2.query_string2
order by t1.query_id
/
QUERY_ID QUERY_STRING1 QUERY_STRING2 MATCHIN_WORD_COUNT
------------------- ------------------------------ ------------------------------ -------------------
1 oracle 255 oracle1 255 1
2 larry or ellison larry or 2
3 oracle and text and 1
4 market1 share market share 1
5 larry or larry or ellison 2
6 oracle1 255 oracle 255 1
6 rows selected.
SQL>
SY.
Tags: Database
Similar Questions
-
Add the signature field to the second occurrence of two words (nieme Word) on the page
I have a script that searches for two words ("APP ENG") on a page and adds a digital signature field.The trick is that there are two occurrences of these words and place the script in the field of digital signature on the first ocurrance of the two words.
I need the digital signature script to add to the second occurrence of these two words.There was a counter added the script, but this place then the field on the word ("ENG"), it might have to do with the meter to count one word instead of two.
If someone can help me to modify the script to count the words and the occurrences of two words instead of one word it would be most appreciated.Script as follows:
var ckWords; pair of words to testvar number = 0;
numWords = this.getPageNumWords (0); number of words on the page
loop through the words on the page
for (var j = 0; j < numWords-1; j ++) {}
get the pair of words to test
ckWords = this.getPageNthWord (0, j) + ' ' + this.getPageNthWord (0, j + 1); test words
If (ckWords == "ENG APP") {}
Count += 1;
If (count == 2) {}
var q = this.getPageNthWordQuads (0, j);
convert quads in the rotation by default user space
Userspace used by links
m = (new Matrix2D).fromRotated(this,0);
mInv = m.invert)
r = mInv.transform (q)
r = r.ToString)
r = r.split(",");
var m = this.addField ("EngSignature", "signature", 0,
([r [0], [1] r, r [2], r [5]]) ;
}
}
}
Thank you.
You must use the left coordinates of the first table and the right of the second table.
-
How will I know what search fuzzy matching word
I tried to find something about my problem, but research has resulted in no relevant thread. I do not use fuzzy to search text, but the names and I use it mainly to work even if the user misspelled the name of a resource.
In order to set the search I want to know what the fuzzy search word was actually and what was the outcome for this match.
So if I search for 'sumer' I get hit for "hot summer" and the relationship is clear. But if I get soon "swimming is not possible that the Summit ends" the blow is not clear more.You can use fuzzy with weight and use the partition function for the score. You can use ctx_doc.highlight to get the positions (offsets and length) of the matching words and then use it in a function in pipeline to return these words and this function in your query. Please see the demo below.
-data and index table:
SCOTT@orcl_11gR2> CREATE TABLE test_tab 2 (test_col VARCHAR2(46)) 3 / Table created. SCOTT@orcl_11gR2> INSERT ALL 2 INTO test_tab VALUES ('warm summer') 3 INTO test_tab VALUES ('soon swimming is not possible as summit closes') 4 INTO test_tab VALUES ('other data') 5 SELECT * FROM DUAL 6 / 3 rows created. SCOTT@orcl_11gR2> CREATE INDEX test_idx 2 ON test_tab (test_col) 3 INDEXTYPE IS CTXSYS.CONTEXT 4 / Index created.
-function
SCOTT@orcl_11gR2> create or replace function get_words 2 (p_idx in varchar2, 3 p_rid in rowid, 4 p_query in varchar2, 5 p_col in varchar2) 6 return sys.odcivarchar2list 7 authid definer 8 pipelined 9 as 10 v_hightab ctx_doc.highlight_tab; 11 begin 12 ctx_doc.set_key_type ('rowid'); 13 ctx_doc.highlight (p_idx, p_rid, p_query, v_hightab); 14 for i in 1 .. v_hightab.count loop 15 pipe row 16 (dbms_lob.substr 17 (p_col, 18 v_hightab(i).length, 19 v_hightab(i).offset)); 20 end loop; 21 return; 22 end get_words; 23 / Function created. SCOTT@orcl_11gR2> show errors No errors.
-Research:
SCOTT@orcl_11gR2> VARIABLE search_string VARCHAR2(100) SCOTT@orcl_11gR2> EXEC :search_string := 'sumer' PL/SQL procedure successfully completed. SCOTT@orcl_11gR2> COLUMN words FORMAT A15 SCOTT@orcl_11gR2> SELECT SCORE(1), x.column_value words, t.test_col 2 FROM test_tab t, 3 TABLE 4 (get_words 5 ('test_idx', 6 t.ROWID, 7 'FUZZY (?' || :search_string || ', 1, 5000, W)', 8 t.test_col)) x 9 WHERE CONTAINS 10 (t.test_col, 11 'FUZZY (?' || :search_string || ', 1, 5000, W)', 12 1) > 0 13 ORDER BY SCORE(1) DESC 14 / SCORE(1) WORDS TEST_COL ---------- --------------- ---------------------------------------------- 36 summer warm summer 12 summit soon swimming is not possible as summit closes 2 rows selected.
-
Find the occurrence of the word in a list separated by commas
Hello
I need to find the first occurrence of a word in a list separated by commas.
Example list:
Now I'm looking for the word: bambimonster,daemon,shark,bambi,sky
Result should be the first calculation of the event: 4
Now I'm looking for the word: Monster
Result should be the first calculation of the event: 1
Hope you can help.
TobiasHi, Tobias,.
This can be more efficient, because it does not use CONNECT BY or regular expressions. Instead of splitting the string to the level of every comma, just find the target string and count how many commas occur in front of her.
WITH got_found_pos AS ( SELECT list_txt , INSTR ( ',' || list_txt || ',' , ',bambi,' ) AS found_pos FROM table_x ) SELECT list_txt , found_pos + 1 - LENGTH ( REPLACE ( SUBSTR (list_txt, 1, found_pos) , ',' ) ) AS item_num , found_pos FROM got_found_pos WHERE found_pos > 0 ;
Delimited lsits storage is usually a bad idea in a relational database. It is best to store each item in the list on a separate line.
-
Get all occurrences of a Word.
Hello
Is it possible to find all occurrences of a word in a single document using Oracle text?
Or maybe a count of how many times a word appears in a document?
I had a glance at the documentation and the web and don't think it is, could anyone suggest a way to do this?
Thank you very much
Darren.Hello
You can, as Roger said to use ctx_doc.tokens. This works if you already have a clue (text) on the document. You also have the option to use ctx_doc.policy_tokens. This does not have a clue, but needs a policy. The two proceedings are with examples in the Manual: [url http://download.oracle.com/docs/cd/E11882_01/text.112/e16593/cdocpkg.htm#CEGCIDAJ] package CTX_DOC.
Herald tiomela
http://htendam.WordPress.com -
Find the first occurrence of a Word
I have a script which detects and counts all occurrences of a Word.
I need the script to find the FIRST occurrence of a Word only.
Can any advise please how do I change the script to find the first occurrence of the word?
Script as follows:
{
numWords = this.getPageNumWords var (0);
for (var i = 0; i < numWords; i ++)
{
var ckWord = this.getPageNthWord(0,i);
If (ckWord is 'MATERIAL')
{
/ * Script going here based on the finds the first occurrence of the word 'MATTER ' * /.
}
}
}
I tried var CKWord = this.getPageNthWord (0,0); but reports from the rear console is UNDEFINED?
numWords = this.getPageNumWords var (0);
var number = 0;
for (var i = 0; i)
var ckWord = this.getPageNthWord(0,i);
If (ckWord == "ISSUED") {}
Count ++;
If (count == 2) {}
var = this.mouseX Coord.var annot = this.addAnnot({)
page: 0.
type: "Stamp."
name: "AppStamp."
Rect: [coord + 1000, 2300, 30, 2820]
rotation: 90,.
({AP: '#C94cHAFFa42U1gTH5Tug5C'});
break;
/ * this.flattenPages (); */
}
}
} -
Replace the last occurrence of a word in a string
Hello
I need to replace the last occurrence of a word in the string. Example of form:
"I like fruits and vegetables as" need to replace the last occurrence of 'like' that is just before the vegetables and not 'as' before the fruit.
Something like that!
SELECT REGEXP_REPLACE('I like fruits and also like vegetables','like','hate',1,2) data_col FROM dual;
-
How can I add a style "BOLD" grep on the first occurrence of a Word?
Hi all
I need help on adding a style "BOLD" grep on the first occurrence of a Word.
I can add the "BOLD" to the word, but it adds to all occurrences, see below:
GREP style (Incorrect)
Apply Style: "BOLD"
Text: \ < Lorem Ipsum\ >
Nam Lorem Ipsum semper pellentesque tincidunt. UT nisi sit amet arcu nulla tristique dictum. SED commodo total non mauris cursus pretium. Lorem Ipsum Aliquam erat volutpat. Morbi id pretium justo. Nam lorem quis facilisis molestie risus fermentum. Vestibule ut sem elit. Nunc eget neque Sed elementum augue EU outbound.
I need only the "BOLD" to add to the first occurrence of the word, as below:
Nam Lorem Ipsum semper pellentesque tincidunt. UT nisi sit amet arcu nulla tristique dictum. SED commodo total non mauris cursus pretium. Lorem Ipsum Aliquam erat volutpat. Morbi id pretium justo. Nam lorem quis facilisis molestie risus fermentum. Vestibule ut sem elit. Nunc eget neque Sed elementum augue EU outbound.
Thanks in advance for the help!
This should do it for you
Apply style
"BOLD"
text (? i) ^(.+?) Lorem Ipsum
apply the stye
Book
text: ^. * ? (? = Lorem Ipsum)
The first expression search all the text from the beginning of the parapgrah through the Lorem Ipsum
The other defines the rest of the text before the Lorem Ipsum to the base style (book, novel, or whatever your basic style)
-
Replacing the occurrences of a Word by links
Hello
I'm writing a Javascript script that should replace all occurrences of a word given in an Indesign CS3 document by a hyperlink pointing to a given URL.
I am very new to Indesign scripting, and I don't know where to start. I tried searching this forum, but couldn't find the answer to my problem.
If anyone can help...
Thank you
Bertrand
You can use my findAndDo Script (the blog is in German): http://www.indesignblog.com/?p=7
for a hyperlink, you need to change:
app.changeGrepPreferences = NothingEnum.nothing; app.findGrepPreferences = NothingEnum.nothing; app.findGrepPreferences.findWhat = "SEARCH"; var erg = app.activeDocument.findGrep (); for (var i = erg.length - 1; i >= 0; i--) { var _hlinkSource = app.activeDocument.hyperlinkTextSources.add(erg[i]); var _destination = app.activeDocument.hyperlinkURLDestinations.add("http://www.google.de"); app.activeDocument.hyperlinks.add(_hlinkSource, _destination); }
-
Grep for styling the second occurrence of a Word
Hi all
I'm putting a dictionary for children.
name of the bicycle
a vehicle with two wheels in tandem, usually propelled by pedals attached to the rear wheel by a chain and have the handlebars for steering and a saddlelike seat. • Some find it faster to ride a bicycle and weaving through cars to take the bus or drive a private car.
I managed to match the first occurrence of the bicycle to the second (underlined below) using the following grep.
(?:^( \w+).+\r.+(\r.+)?) (\1)
bike noun
a vehicle with two wheels in tandem, usually propelled by pedals attached to the rear wheel by a chain and having the steering handlebars and a seat saddlelike. • some found it quicker to mount a bike and weaving through cars to take the bus or drive a private vehicle.
This grep (that which) works as expected in the dictionary, but now I need to be able to select only the second word (in italics and in red in the example above) to be able to give him the correct character style.
Any help would be greatly appreciated.
Thanks in advance.
Stephen
GOAL!
-
Find seems to have changed in Firefox. Before, when making a (CTRL + F) to find, research was not specific or non-specific to the caps CAPS. "In other words, if I typed in"firefox"(without ceiling), it will find the words"firefox,"Firefox", or "FIREFOX", regardless of capitalization. Now, however, the function finds will only match exact same capitalization. Totally, this undermines the usefulness of the service and is a major concern. Please fix.
This has happened
A few times a week
== I noticed in during the two or two weeks.
Make sure that the "match case" box in the find (Ctrl + F) bar is not activated.
Start Firefox in Firefox to solve the issues in Safe Mode to check if one of your modules is causing your problem (switch to the DEFAULT theme: Tools > Modules > themes).
See the extensions, themes and problems of hardware acceleration to resolve common troubleshooting Firefox problems and troubleshooting questions with plugins like Flash or Java to solve common Firefox problems -
Hello
I want to retrieve those records where full word of the 'text' column does not match with the word in the column 'object' of another table.
for example
for id 101 table abc, it contains the Word as "Air Blow" which is exactly with 101 id of table of bcd. I don't want the case
With abc as
(
Select 101 as id, "Air Blow" as double union text
Select 102, 'Air' Union double
Select 103, 'Sink' double union
Select 104, 'Air press' Union double
Select 105, 'Putting out fires' double
),
BCD as
(
Select 101 as id, "Air blown near the mount" as subject, 'WE' as a double union countries
Select 102, "Air breath seen here," 'China' of the double union
Select 103, 'Throughput', 'canada' to double union
Select 104, 'air pressure', 'UK' Union double
Select 105, 'Fire engine', 'Ubdy' from dual
)
Select * from abc, bcd
where abc.id = bcd.id
and upper (abc.text) <>(bcd.subject) upper
OUTPUT
ID TEXT ID_1 Object COUNTRY 102 Air blown 102 Blowing air saw China 103 Water flow 103 Water flow Canada 105 Putting out fires 105 Firefighter Ubdy Another corresponding original solution post results...
SQL > ed
A written file afiedt.buf1 with abc as)
2. Select 101 as id, "Air BLOW" as double union text
3. Select 102, 'Air' Union double
4. Select 103, 'Sink' double union
5. Select 104, 'Air press' Union double
6 select 105, 'Fire extinguish' from dual
7 ),
8 bcd as
9 (
10. Select 101 as id, "Air blown near the mount" as subject, 'WE' as a double union countries
11. Select 102, "Air breath seen here," 'China' of the double union
12. Select 103, 'Throughput', 'canada' to double union
13. Select 104, 'air pressure', 'UK' Union double
14 select 105, 'Fire engine', 'Ubdy' from dual
15)
16. Select *.
17 ABC join bcd on (abc.id = bcd.id)
18 * where no regexp_like (bcd.subject, abc.text, 'i')
SQL > /.
TEXT ID COUNTR OBJECT ID
---------- --------------- ---------- ----------------------- ------
102 air blowing here view China 102
103 103 water flow flow of water canada
Fire 105 105 fire Ubdy3 selected lines.
-
Array of string to search for the exact match words
I need to create a search feature.
There is a textfield where the user will enter one or more words.
Then I need to check if are any reference in the array of names.
namesArray ["ocean in the sky", "cean on sky", "cean is white"]; keywordsArray ["cean", "sky"]; matchCounter = 0;
If I entered the word "cean" I don't want in my results 'ocean in heaven', 'cean's heaven
I have the following code:
for (var j:int = 0; j < namesArray.length; ++j) { var tempStr:String = namesArray[j]; for (var k:int = 0; k < keywordsArray.length; ++k) { if (tempStr.indexOf(arrayKeywords[k]) != -1) { matchCounter++; } } if(lengthKeywords == matchCounter) { trace("yeahhh... there's a match!!"); } matchCounter = 0; }
Is there a better way? How can I do this?
There are little things, but the main problem is that 'new RegExp()' needs double escapes ("\")
... var namesArray:Array = ["ocean in the sky", "cean on sky", "cean is white"]; var keywordsArray:Array = ["cean", "sky"]; for (var j:int = 0; j < namesArray.length; j++){ var matchCounter:uint = 0; var tempStr:String = namesArray[j]; for (var k:int = 0; k < keywordsArray.length; k++){ var regExp:RegExp = new RegExp("(\\s+|^)" + keywordsArray[k] + "(\\s+|$)"); if (tempStr.search(regExp) > -1){ matchCounter++; } } if(keywordsArray.length == matchCounter){ trace("\"" + namesArray[j] + "\" matched all the keywords"); } } ...
Traces:
'cean on Sky' set match all keywords
-
Can someone help me create a procedure with the DML statements that insert values from 1 to 100 in a table "abc" and the procedure must connect the numbers into words in another table "xyz" without doing a commit explicitly. "."
Currently on trial...
SQL > create table abc (num number);
Table created.
SQL > create table xyz (num varchar2 (100));
Table created.
SQL > ed
A written file afiedt.buf1. insert all
2 values of 1 = 1 then in abc (num) (l)
3 when the values of 1 = 1 then in xyz (num) (to_char (to_date(l,'j'), 'jsp'))
4 * Select the level from dual connect by level<=>=>
SQL > /.200 rows created.
And the result...
SQL > select * from abc;
NUM
----------
1
2
3
4
5
6
7
8
9
10
11
12
..
..
..
98
99
100100 selected lines.
SQL > select * from xyz;
NUM
----------------------------------------------------------------------------------------------------
one
two
three
four
five
six
seven
eight
nine
ten
Eleven
twelve
..
..
..
98
Nineteen eighty
Cent100 selected lines.
-
How to count the number of words in a string?
It is only possible by counting the number of white spaces in the string?
You can use the String.Split method to divide the string into an array using the character space as delimiter, and then check the length property of the resulting table.
Maybe you are looking for
-
Can't access websites from symantec
I use 19.0a2 Aurora (2012-12-21). I can't use liveupdate to update my Symantec antivirus.I can connect to symantec.com but not LiveUpdate.symantecliveupdate.com LiveUpdate.Symantec.com Akamai.NETI'll be back what about error message cannot find the i
-
I know that the bookmarks toolbar is only a long line and I know how to add multiple toolbars (customization) but somehow I just can't get the bookmarks toolbar to expand to the next line or so. Is it possible that Firefox can do this or not?
-
My ultimate 64 bit vista mce said no internet tv available in canada, I live in
MY mce internet tv work now it dosnt suddenly (says no internet tv available in canada) pls help no settings have changed.
-
Download and install the upgrades of windows...
About 5 months ago, I got my computer fixed and made some changes. I also got put Windows Vista, I love it so far except that when I try to download the new updates and try to install, it gives me an error code and does nothing. This has happened for
-
How can I get a split screen?
I want a word document on one side and the pictures of the other side, so I can drag pictures to the word document.