I write a number of simple scala scripts that end up starting with a simple pattern match on args like:
val Array(path, foo, whatever) = args
// .. rest of the script uses "path", "foo", etc.
Of course, if I supply the wrong number of arguments, I get an inscrutable error like:
scala.MatchError: [Ljava.lang.String;@7786df0f
at Ma...
I've been playing around with natural language parse trees and manipulating them in various ways. I've been using Stanford's Tregex and Tsurgeon tools but the code is a mess and doesn't fit in well with my mostly Python environment (those tools are Java and aren't ideal for tweaking). I'd like to have a toolset that would allow for easy ...
Hi
I want to process a String, in which I want to find multiple strings, i am trying to make some highlighter in html text in java..
Example:
Find and process phrases table, row, primary key in Each table row contains a primary key column
The text is html text with tags like <b>,<img..>...
if there is ignorable tag in the middle of phras...
I am trying to match the beginning of strings in f#. Not sure if I have to treat them as a list of characters or what. Any suggestions would be appreciated.
Here is a psuedo code version of what I am trying to do
let text = "The brown fox.."
match text with
| "The"::_ -> true
| "If"::_ -> true
| _ -> false
So, I want to look at th...
Hi,
The following shell sessions shows some behavior I would like to understand:
1> A = "Some text".
"Some text"
2> "Some " ++ R = A.
"Some text"
3> R.
"text"
4> B = "Some ".
"Some "
5> B ++ L = A.
* 1: illegal pattern
Surely statements 2 and 5 are syntacticially identical? I would like to use this idiom to extract some text from a s...
I had a List of Scala tuples like the following:
val l = List((1,2),(2,3),(3,4))
and I wanted to map it in a list of Int where each item is the sum of the Ints in a the corresponding tuple. I also didn't want to use to use the x._1 notation so I solved the problem with a pattern matching like this
def addTuple(t: (Int, Int)) : Int = ...
Hello,
I've got a simple enough question, but no guidance yet through the forums or bash. The question is as follows:
I want to add a prefix string to each filename in a directory that matches *.h or *.cpp. HOWEVER, if the prefix has already been applied to the filename, do NOT apply it again.
Why the following doesn't work is somethi...
I have two strings which must be compared for similarity. The algorithm must be designed to find the maximal similarity. In this instance, the ordering matters, but intervening (or missing) characters do not. Edit distance cannot be used in this case for various reasons.
The situation is basically as follows:
string 1: ABCDEFG
string...
I have come across a problem that I cannot see to solve. I have extracted a line from a web page into a variable. lets say for argument sake this is:
rhyme = "three blind mice Version 6.0"
and I want to be able to first of all locate the version number within this string (6.0) and secondly extract this number into another seperate vari...
I want to extract the middle part of a string using FSharp if it is quoted, similar like this:
let middle =
match original with
| "\"" + mid + "\"" -> mid
| all -> all
But it doesn't work because of the infix operator + in pattern expression. How can I extract this?
...
match value with
| :? list<#SomeType> as l -> l //Is it possible to match any list of a type derived from SomeType?
| _ -> failwith "doesn't match"
...
I have a text field in which user can enter any character he/she wants. But in server i have a string patter [a-z0-9][a-z0-9+.-]*, if any of the character in the value from the text box doesn't match the pattern, then i must remove that character from that string. How can i do that in php. is there any functions for that?
Thanks in adva...
greetings all
i have a text that may contain links something like:
" hello..... visit us on http://www.google.com.eg, and for more info, please contact us on
http://www.myweb.com/help"
and i want to find and replace any link with the following link
anyone knows how to do so ?
and i have another question is that how any website li...
Dear All,
We have an email template which needs to be processed using Java. We have to replace the variables in the template with actual values. We were able to achieve this using pattern matching , ie; by searching the template for particular patters and replace them with actual values.
Now we need have conditions in the XML file.For ex...
I have the following Scala code.
import scala.actors.Actor
object Alice extends Actor {
this.start
def act{
loop{
react {
case "Hello" => sender ! "Hi"
case i:Int => sender ! 0
}
}
}
}
object Test {
def test = {
(Alice !? (100, "Hello")) match {
case i:Some[Int] => println ("Int rec...
Lets say i have a piece of code like this:
test pattern
| pattern == (_,NOT (WIRE _)) = 1
| pattern == (_,AND (WIRE _) (WIRE _)) = 2
| otherwise = 0
Where i am trying to match it against one of several possibilities, some with one (WIRE ""), some with two. I have actual input as follows e.g.: ("p",NOT (WIRE "x")). I would like...
Hi All,
I've a long template from which I need to extract certain strings based on certain patterns. When I went through some examples I found that use of quantifiers is good in such situations.For example following is my template, from which I need to extract while and doWhile.
This is a sample document.
$while($variable)This text can ...
My problem is Given a set of fixed 2D points, N, and a set of corresponding 2D points, A, I want to find a mapping using a translation and a rotation which maps A onto N such that the largest distance between any two corresponding points is minimized. The points which correspond is known.
I would also like to know the translation and/or...
hi,
I am trying to print out lines from a file which match a particular pattern in java.
I am using the Pattern class for doing this.
I tried putting the patter as "[harry]" so that every line which has "harry" gets printed out.
But pattern always evaluates to false.
My assumption is that the regex pattern I am entering is a string.
M...
I need to get all characters between a particular expression.
For example below is my sample document
This is a sample document.
$if ( $variable)
FIRST This text can be repeated many times until do while is called.
$elseif($variable2)
Some sample text follows this.
$endif
I need to get all the characters be...