我需要从文本文件中提取带有撇号的单词。我有一个程序,提取单词的长度是一定的量(在下面的程序3),并有撇号。然而,我需要那个人只考虑那些带有撇号的词,而不考虑任何其他条件。
public static void main(String[] args) throws IOException {
ArrayList<String> words = new ArrayList<String>();
String s = "I want to have a lot of money's when I am older.";
我想从文本文件中解析单词。应保留撇号,但应删除单引号。以下是一些测试数据:
john's apostrophe is a 'challenge'
我正在尝试使用grep,如下所示:
grep -o "[a-z'A-Z]*" file.txt
它会产生:
john's
apostrophe
is
a
'challenge'
需要去掉单词challenge周围的引号。
正确/所需的输出应为:
john's
apostrophe
is
a
challenge
编辑:由于一致认为撇号很难识别,我现在正在寻找一种方法来从所有
我正在尝试使用正则表达式将句子/短语拆分成单词。
var phrase = "This isn't a test.";
var words = Regex.Split(phrase, @"\W+").ToList();
单词包含"This“、"isn”、"t“、"a”、"test“
显然,它正在拾取撇号并对其进行拆分。我可以更改此行为吗?它还需要多语言支持多种语言(西班牙语、法语、俄语、韩语等)。
我需要把单词传给拼写检查器。具体地说,就是Nhunspell。
return (from word in words
如果我用键盘将一段文字直接写入HTML文档的文本编辑器中,并且其中一个单词有撇号,那么撇号的写法将完全如下所示:
Here's an example of some text.
然而,如果抄袭字,同样的句子将出现如下:
Hereʼs an example of some text.
在HTML文档中显示它们的正确方法是什么?正如我通常所做的那样,查找和替换使它们与'相同。
此外,我还可以使用编码编写它们:
ʼ = ʼ
&pos; = '
' = '
有什么标准的方法吗?我知道&pos;是HTML5的东西,所以
如何删除R中字符串中的所有特殊字符并将其替换为空格?
要删除的一些特殊字符是:~!@#$%^&*(){}_+:"<>?,./;'[]-=
我尝试过带有[:punct:]模式的regex,但它只删除标点符号。
问题2:如何从外语中删除字符,如:â í ü Â á ą ę ś ć?
答:使用[^[:alnum:]]删除~!@#$%^&*(){}_+:"<>?,./;'[]-=,并使用[^a-zA-Z0-9]删除regex或regexpr函数中的â í ü Â á ą ę ś ć。
base R中的解决方案:
x <- &
我想从字符串中删除单引号,但不想删除撇号的引号。
例如,我想要转换为:
"I'm a very 'dumb' stackoverflow user."
#=> I'm a very dumb stackoverflow user.
所以像string.gsub("'", "")这样的东西不会起作用,因为它替换了所有的单引号。不应替换"I'm中的'“。
当运行以下查询获取上述错误时,
String sql = "((NAME= '" + sReceipts[0] + "' ) OR (SECTION IN ('RECEIPT', 'PROJECT') AND NAME IS NULL))";
sReceipts[0]值是“Tom‘s”(带有撇号),给出错误
但如果sReceipts = 'Ann‘,则不会出现错误。
我试着用String.Format解决问题,但我做不到。请问最好的方法是什么?
我有一个字符串,它有一个带撇号的单词。他是个非常非常好的男孩,不是吗?
public class Solution {
public static void main(String[] args) {
String s = "He is a very very good boy, isn't he?";
String[] words = s.split("\\s+");
int itemCount = words.length;
System.out.
我正在传递一个文本文件,我希望去掉所有可能的单引号。我正在使用以下函数:
def apost(nostop):
for n in nostop:
final=[]
removed=[]
for y in n:
r=remove_apos(y)
final.append(r)
removed.append(final)
print("Task 2: Apostrophy removed!")
return removed
这是remove_apo
我有一个很长的字符串,里面有几个单词。
这些词中有些有撇号。别这样。有些词在单词外有撇号,例如“电影是伟大的”或“大量的撇号”。
我想删除所有不属于这个词的撇号。
例如,在字符串=不要尝试‘中删除使徒’word‘。输出应该是不要试图移除word中的apostr。
I wrote the regex for it .*[^a-z]'[^a-z].* But I am not getting the desired output in my java code.
String s = "don't try to ''''remove
我有一个由系统生成的CSV文件。问题出在其中一个字段,该字段过去是一个项目列表。以下是原始列表的一个示例...
The serial number of the desk is 45TYTU
This is the second item in the list
The colour of the apple is green
The ID code is 489RUI
This is the fourth item in the list.
不幸的是,系统输出的代码如下……
The serial number of the desk is 45TYTUThis is the second i
用于清除文本的函数
def clean_before_tok(text):
text=text.replace("'"," ")
exclude=[" le "," la "," l "," un "," une "," du "," de "," les "," des "," s "," d "]
for e in exclude:
te
我的问题是,我正试图在Weblogic中创建一个有效的jaas_config文件。只要我在配置文件中有一行,就可以了。
MyServices {
com.example.myservices required;};
但当我键入更多行时,我总是会收到
No Configuration was registered that can handle the configuration named MyServices
这是我的完整文件:
MyServcies {
com.example.myservices required
debug=true
programName=My First Progr
我想保留一个文件中的每个单词的计数,这个计数不应该包括非字母,如撇号,逗号,句号,问号,感叹号,e.t.c。也就是说,只是字母表中的字母。我尝试使用这样的分隔符,但它没有包括撇号。
Scanner fileScanner = new Scanner("C:\\MyJavaFolder\\JavaAssignment1\\TestFile.txt");
int totalWordCount = 0;
//Firstly to count all the words in the file without the restricted characters